aboutsummaryrefslogtreecommitdiffstats
path: root/utils/qv4l2/raw2sliced.h
blob: d53725dbefa8f56640c158e42e53040378f55448 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/*
 * Raw VBI to sliced VBI parser.
 *
 * The slicing code was copied from libzvbi. The original copyright notice is:
 *
 * Copyright (C) 2000-2004 Michael H. Schimek
 *
 * The vbi_prepare/vbi_parse functions are:
 *
 * Copyright (C) 2012 Hans Verkuil <hans.verkuil@cisco.com>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the 
 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 
 * Boston, MA  02110-1301  USA.
 */

#ifndef _RAW2SLICED_H
#define _RAW2SLICED_H

#include <linux/videodev2.h>

#define VBI_MAX_SERVICES (3)

// Bit slicer internal struct
struct vbi_bit_slicer {
	unsigned int		service;
	unsigned int		cri;
	unsigned int		cri_mask;
	unsigned int		thresh;
	unsigned int		thresh_frac;
	unsigned int		cri_samples;
	unsigned int		cri_rate;
	unsigned int		oversampling_rate;
	unsigned int		phase_shift;
	unsigned int		step;
	unsigned int		frc;
	unsigned int		frc_bits;
	unsigned int		payload;
	unsigned int		endian;
};

struct vbi_handle {
	unsigned services;
	unsigned start_of_field_2;
	unsigned stride;
	bool interlaced;
	int start[2];
	int count[2];
	struct vbi_bit_slicer slicers[VBI_MAX_SERVICES];
};

// Fills in vbi_handle based on the standard and VBI format
// Returns true if one or more services are valid for the fmt/std combination.
bool vbi_prepare(struct vbi_handle *vh,
		const struct v4l2_vbi_format *fmt, v4l2_std_id std);

// Parses the raw buffer and fills in sliced_vbi_format and _data.
// data must be an array of count[0] + count[1] v4l2_sliced_vbi_data structs.
void vbi_parse(struct vbi_handle *vh, const unsigned char *buf,
		struct v4l2_sliced_vbi_format *vbi,
		struct v4l2_sliced_vbi_data *data);

#endif

Privacy Policy