2 * libzvbi -- Bit slicer
4 * Copyright (C) 2000-2007 Michael H. Schimek
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301 USA.
22 /* $Id: bit_slicer.h,v 1.11 2008-02-24 14:18:13 mschimek Exp $ */
24 #ifndef __ZVBI_BIT_SLICER_H__
25 #define __ZVBI_BIT_SLICER_H__
27 #include "sampling_par.h"
32 * @addtogroup BitSlicer
37 * @brief Modulation used for VBI data transmission.
41 * The data is 'non-return to zero' coded, logical '1' bits
42 * are described by high sample values, logical '0' bits by
43 * low values. The data is last significant bit first transmitted.
45 VBI3_MODULATION_NRZ_LSB,
48 * 'Non-return to zero' coded, most significant bit first
51 VBI3_MODULATION_NRZ_MSB,
54 * The data is 'bi-phase' coded. Each data bit is described
55 * by two complementary signalling elements, a logical '1'
56 * by a sequence of '10' elements, a logical '0' by a '01'
57 * sequence. The data is last significant bit first transmitted.
59 VBI3_MODULATION_BIPHASE_LSB,
61 /** 'Bi-phase' coded, most significant bit first transmitted. */
62 VBI3_MODULATION_BIPHASE_MSB
66 * @brief Bit slicer context.
68 * The contents of this structure are private.
69 * Call vbi3_bit_slicer_new() to allocate a bit slicer context.
71 typedef struct _vbi3_bit_slicer vbi3_bit_slicer;
77 } vbi3_bit_slicer_bit;
80 * @brief Bit slicer sampling point.
82 * This structure contains information about
83 * a bit sampled by the bit slicer.
86 /** Whether this struct refers to a CRI, FRC or payload bit. */
87 vbi3_bit_slicer_bit kind;
89 /** Number of the sample times 256. */
92 /** Signal amplitude at this sample, in range 0 to 65535. */
95 /** 0/1 threshold at this sample, in range 0 to 65535. */
97 } vbi3_bit_slicer_point;
100 vbi3_bit_slicer_slice_with_points
101 (vbi3_bit_slicer * bs,
103 unsigned int buffer_size,
104 vbi3_bit_slicer_point *points,
105 unsigned int * n_points,
106 unsigned int max_points,
108 _vbi_nonnull ((1, 2, 4, 5, 7));
110 vbi3_bit_slicer_slice (vbi3_bit_slicer * bs,
112 unsigned int buffer_size,
114 _vbi_nonnull ((1, 2, 4));
116 vbi3_bit_slicer_set_params (vbi3_bit_slicer * bs,
117 vbi_pixfmt sample_format,
118 unsigned int sampling_rate,
119 unsigned int sample_offset,
120 unsigned int samples_per_line,
122 unsigned int cri_mask,
123 unsigned int cri_bits,
124 unsigned int cri_rate,
125 unsigned int cri_end,
127 unsigned int frc_bits,
128 unsigned int payload_bits,
129 unsigned int payload_rate,
130 vbi3_modulation modulation)
133 vbi3_bit_slicer_set_log_fn (vbi3_bit_slicer * bs,
139 vbi3_bit_slicer_delete (vbi3_bit_slicer * bs);
140 extern vbi3_bit_slicer *
141 vbi3_bit_slicer_new (void)
147 _vbi3_bit_slicer_fn (vbi3_bit_slicer * bs,
149 vbi3_bit_slicer_point *points,
150 unsigned int * n_points,
151 const uint8_t * raw);
154 struct _vbi3_bit_slicer {
155 _vbi3_bit_slicer_fn * func;
157 vbi_pixfmt sample_format;
159 unsigned int cri_mask;
161 unsigned int thresh_frac;
162 unsigned int cri_samples;
163 unsigned int cri_rate;
164 unsigned int oversampling_rate;
165 unsigned int phase_shift;
168 unsigned int frc_bits;
169 unsigned int total_bits;
170 unsigned int payload;
172 unsigned int bytes_per_sample;
174 unsigned int green_mask;
180 _vbi3_bit_slicer_destroy (vbi3_bit_slicer * bs)
183 _vbi3_bit_slicer_init (vbi3_bit_slicer * bs)
190 #endif /* __ZVBI_BIT_SLICER_H__ */