ZVBI Library
0.2.33
|
Converting raw VBI samples to bits and bytes. More...
Data Structures | |
struct | vbi_bit_slicer |
Bit slicer context. More... | |
struct | vbi_raw_decoder |
Raw vbi decoder context. More... |
Typedefs | |
typedef struct vbi_bit_slicer | vbi_bit_slicer |
Bit slicer context. | |
typedef struct vbi_raw_decoder | vbi_raw_decoder |
Raw vbi decoder context. |
Enumerations | |
enum | vbi_pixfmt { VBI_PIXFMT_YUV420 = 1, VBI_PIXFMT_YUYV, VBI_PIXFMT_YVYU, VBI_PIXFMT_UYVY, VBI_PIXFMT_VYUY, VBI_PIXFMT_PAL8, VBI_PIXFMT_RGBA32_LE = 32, VBI_PIXFMT_RGBA32_BE, VBI_PIXFMT_BGRA32_LE, VBI_PIXFMT_BGRA32_BE, VBI_PIXFMT_ABGR32_BE = 32, VBI_PIXFMT_ABGR32_LE, VBI_PIXFMT_ARGB32_BE, VBI_PIXFMT_ARGB32_LE, VBI_PIXFMT_RGB24, VBI_PIXFMT_BGR24, VBI_PIXFMT_RGB16_LE, VBI_PIXFMT_RGB16_BE, VBI_PIXFMT_BGR16_LE, VBI_PIXFMT_BGR16_BE, VBI_PIXFMT_RGBA15_LE, VBI_PIXFMT_RGBA15_BE, VBI_PIXFMT_BGRA15_LE, VBI_PIXFMT_BGRA15_BE, VBI_PIXFMT_ARGB15_LE, VBI_PIXFMT_ARGB15_BE, VBI_PIXFMT_ABGR15_LE, VBI_PIXFMT_ABGR15_BE } |
Image format used as source to vbi_bit_slice() and vbi_raw_decode(). More... | |
enum | vbi_modulation { VBI_MODULATION_NRZ_LSB, VBI_MODULATION_NRZ_MSB, VBI_MODULATION_BIPHASE_LSB, VBI_MODULATION_BIPHASE_MSB } |
Modulation used for VBI data transmission. More... |
Functions | |
void | vbi_bit_slicer_init (vbi_bit_slicer *slicer, int raw_samples, int sampling_rate, int cri_rate, int bit_rate, unsigned int cri_frc, unsigned int cri_mask, int cri_bits, int frc_bits, int payload, vbi_modulation modulation, vbi_pixfmt fmt) |
_vbi_inline vbi_bool | vbi_bit_slice (vbi_bit_slicer *slicer, uint8_t *raw, uint8_t *buf) |
void | vbi_raw_decoder_init (vbi_raw_decoder *rd) |
void | vbi_raw_decoder_reset (vbi_raw_decoder *rd) |
void | vbi_raw_decoder_destroy (vbi_raw_decoder *rd) |
unsigned int | vbi_raw_decoder_add_services (vbi_raw_decoder *rd, unsigned int services, int strict) |
unsigned int | vbi_raw_decoder_check_services (vbi_raw_decoder *rd, unsigned int services, int strict) |
unsigned int | vbi_raw_decoder_remove_services (vbi_raw_decoder *rd, unsigned int services) |
void | vbi_raw_decoder_resize (vbi_raw_decoder *rd, int *start, unsigned int *count) |
unsigned int | vbi_raw_decoder_parameters (vbi_raw_decoder *rd, unsigned int services, int scanning, int *max_rate) |
int | vbi_raw_decode (vbi_raw_decoder *rd, uint8_t *raw, vbi_sliced *out) |
Converting raw VBI samples to bits and bytes.
The libzvbi already offers hardware interfaces to obtain sliced VBI data for further processing. However if you want to write your own interface or decode data services not covered by libzvbi you can use these lower level functions.
typedef struct vbi_bit_slicer vbi_bit_slicer |
Bit slicer context.
The contents of this structure are private, use vbi_bit_slicer_init() to initialize.
typedef struct vbi_raw_decoder vbi_raw_decoder |
Raw vbi decoder context.
Only the sampling parameters are public. See vbi_raw_decoder_parameters() and vbi_raw_decoder_add_services() for usage.
enum vbi_pixfmt |
Image format used as source to vbi_bit_slice() and vbi_raw_decode().
Symbol | Byte 0 | Byte 1 | Byte 2 | Byte 3 | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Planar YUV 4:2:0 data. | ||||||||||||||||||||||||||||||||||
VBI_PIXFMT_YUV420 |
|
|||||||||||||||||||||||||||||||||
Packed YUV 4:2:2 data. | ||||||||||||||||||||||||||||||||||
VBI_PIXFMT_YUYV | Y0 | Cb | Y1 | Cr | ||||||||||||||||||||||||||||||
VBI_PIXFMT_YVYU | Y0 | Cr | Y1 | Cb | ||||||||||||||||||||||||||||||
VBI_PIXFMT_UYVY | Cb | Y0 | Cr | Y1 | ||||||||||||||||||||||||||||||
VBI_PIXFMT_VYUY | Cr | Y0 | Cb | Y1 | ||||||||||||||||||||||||||||||
Packed 32 bit RGB data. | ||||||||||||||||||||||||||||||||||
VBI_PIXFMT_RGBA32_LE VBI_PIXFMT_ARGB32_BE | r7 ... r0 | g7 ... g0 | b7 ... b0 | a7 ... a0 | ||||||||||||||||||||||||||||||
VBI_PIXFMT_BGRA32_LE VBI_PIXFMT_ARGB32_BE | b7 ... b0 | g7 ... g0 | r7 ... r0 | a7 ... a0 | ||||||||||||||||||||||||||||||
VBI_PIXFMT_ARGB32_LE VBI_PIXFMT_BGRA32_BE | a7 ... a0 | r7 ... r0 | g7 ... g0 | b7 ... b0 | ||||||||||||||||||||||||||||||
VBI_PIXFMT_ABGR32_LE VBI_PIXFMT_RGBA32_BE | a7 ... a0 | b7 ... b0 | g7 ... g0 | r7 ... r0 | ||||||||||||||||||||||||||||||
Packed 24 bit RGB data. | ||||||||||||||||||||||||||||||||||
VBI_PIXFMT_RGBA24 | r7 ... r0 | g7 ... g0 | b7 ... b0 | |||||||||||||||||||||||||||||||
VBI_PIXFMT_BGRA24 | b7 ... b0 | g7 ... g0 | r7 ... r0 | |||||||||||||||||||||||||||||||
Packed 16 bit RGB data. | ||||||||||||||||||||||||||||||||||
VBI_PIXFMT_RGB16_LE | g2 g1 g0 r4 r3 r2 r1 r0 | b4 b3 b2 b1 b0 g5 g4 g3 | ||||||||||||||||||||||||||||||||
VBI_PIXFMT_BGR16_LE | g2 g1 g0 b4 b3 b2 b1 b0 | r4 r3 r2 r1 r0 g5 g4 g3 | ||||||||||||||||||||||||||||||||
VBI_PIXFMT_RGB16_BE | b4 b3 b2 b1 b0 g5 g4 g3 | g2 g1 g0 r4 r3 r2 r1 r0 | ||||||||||||||||||||||||||||||||
VBI_PIXFMT_BGR16_BE | r4 r3 r2 r1 r0 g5 g4 g3 | g2 g1 g0 b4 b3 b2 b1 b0 | ||||||||||||||||||||||||||||||||
Packed 15 bit RGB data. | ||||||||||||||||||||||||||||||||||
VBI_PIXFMT_RGBA15_LE | g2 g1 g0 r4 r3 r2 r1 r0 | a0 b4 b3 b2 b1 b0 g4 g3 | ||||||||||||||||||||||||||||||||
VBI_PIXFMT_BGRA15_LE | g2 g1 g0 b4 b3 b2 b1 b0 | a0 r4 r3 r2 r1 r0 g4 g3 | ||||||||||||||||||||||||||||||||
VBI_PIXFMT_ARGB15_LE | g1 g0 r4 r3 r2 r1 r0 a0 | b4 b3 b2 b1 b0 g4 g3 g2 | ||||||||||||||||||||||||||||||||
VBI_PIXFMT_ABGR15_LE | g1 g0 b4 b3 b2 b1 b0 a0 | r4 r3 r2 r1 r0 g4 g3 g2 | ||||||||||||||||||||||||||||||||
VBI_PIXFMT_RGBA15_BE | a0 b4 b3 b2 b1 b0 g4 g3 | g2 g1 g0 r4 r3 r2 r1 r0 | ||||||||||||||||||||||||||||||||
VBI_PIXFMT_BGRA15_BE | a0 r4 r3 r2 r1 r0 g4 g3 | g2 g1 g0 b4 b3 b2 b1 b0 | ||||||||||||||||||||||||||||||||
VBI_PIXFMT_ARGB15_BE | b4 b3 b2 b1 b0 g4 g3 g2 | g1 g0 r4 r3 r2 r1 r0 a0 | ||||||||||||||||||||||||||||||||
VBI_PIXFMT_ABGR15_BE | r4 r3 r2 r1 r0 g4 g3 g2 | g1 g0 b4 b3 b2 b1 b0 a0 |
enum vbi_modulation |
Modulation used for VBI data transmission.
void vbi_bit_slicer_init | ( | vbi_bit_slicer * | slicer, |
int | raw_samples, | ||
int | sampling_rate, | ||
int | cri_rate, | ||
int | bit_rate, | ||
unsigned int | cri_frc, | ||
unsigned int | cri_mask, | ||
int | cri_bits, | ||
int | frc_bits, | ||
int | payload, | ||
vbi_modulation | modulation, | ||
vbi_pixfmt | fmt | ||
) |
slicer | Pointer to vbi_bit_slicer object to be initialized. |
raw_samples | Number of samples or pixels in one raw vbi line later passed to vbi_bit_slice(). This limits the number of bytes read from the sample buffer. |
sampling_rate | Raw vbi sampling rate in Hz, that is the number of samples or pixels sampled per second by the hardware. |
cri_rate | The Clock Run In is a NRZ modulated sequence of '0' and '1' bits prepending most data transmissions to synchronize data acquisition circuits. This parameter gives the CRI bit rate in Hz, that is the number of CRI bits transmitted per second. |
bit_rate | The transmission bit rate of all data bits following the CRI in Hz. |
cri_frc | The FRaming Code usually following the CRI is a bit sequence identifying the data service, and per libzvbi definition modulated and transmitted at the same bit rate as the payload (however nothing stops you from counting all nominal CRI and FRC bits as CRI). The bit slicer compares the bits in this word, lsb last transmitted, against the transmitted CRI and FRC. Decoding of payload starts with the next bit after a match. |
cri_mask | Of the CRI bits in cri_frc , only these bits are actually significant for a match. For instance it is wise not to rely on the very first CRI bits transmitted. Note this mask is not shifted left by frc_bits. |
cri_bits | |
frc_bits | Number of CRI and FRC bits in cri_frc, respectively. Their sum is limited to 32. |
payload | Number of payload bits. Only this data will be stored in the vbi_bit_slice() output. If this number is no multiple of eight, the most significant bits of the last byte are undefined. |
modulation | Modulation of the vbi data, see vbi_modulation. |
fmt | Format of the raw data, see vbi_pixfmt. |
Initializes vbi_bit_slicer object. Usually you will not use this function but vbi_raw_decode(), the vbi image decoder which handles all these details.
_vbi_inline vbi_bool vbi_bit_slice | ( | vbi_bit_slicer * | slicer, |
uint8_t * | raw, | ||
uint8_t * | buf | ||
) |
slicer | Pointer to initialized vbi_bit_slicer object. |
raw | Input data. At least the number of pixels or samples given as raw_samples to vbi_bit_slicer_init(). |
buf | Output data. The buffer must be large enough to store the number of bits given as payload to vbi_bit_slicer_init(). |
Decode one scan line of raw vbi data. Note the bit slicer tries to adapt to the average signal amplitude, you should avoid using the same vbi_bit_slicer object for data from different devices.
FALSE
if the raw data does not contain the expected information, i. e. the CRI/FRC has not been found. This may also result from a too weak or noisy signal. Error correction must be implemented at a higher layer. void vbi_raw_decoder_init | ( | vbi_raw_decoder * | rd | ) |
rd | Pointer to a vbi_raw_decoder structure. |
Initializes a vbi_raw_decoder structure.
void vbi_raw_decoder_reset | ( | vbi_raw_decoder * | rd | ) |
rd | Initialized vbi_raw_decoder structure. |
Reset a vbi_raw_decoder structure. This removes all previously added services to be decoded (if any) but does not touch the sampling parameters. You are free to change the sampling parameters after calling this.
void vbi_raw_decoder_destroy | ( | vbi_raw_decoder * | rd | ) |
rd | Pointer to initialized vbi_raw_decoder structure, can be NULL . |
Free all resources associated with rd.
unsigned int vbi_raw_decoder_add_services | ( | vbi_raw_decoder * | rd, |
unsigned int | services, | ||
int | strict | ||
) |
rd | Initialized vbi_raw_decoder structure. |
services | Set of VBI_SLICED_ symbols. |
strict | A value of 0, 1 or 2 requests loose, reliable or strict matching of sampling parameters. For example if the data service requires knowledge of line numbers while they are not known, 0 will accept the service (which may work if the scan lines are populated in a non-confusing way) but 1 or 2 will not. If the data service may use more lines than are sampled, 1 will accept but 2 will not. If unsure, set to 1 . |
After you initialized the sampling parameters in rd (according to the abilities of your raw vbi source), this function adds one or more data services to be decoded. The libzvbi raw vbi decoder can decode up to eight data services in parallel. You can call this function while already decoding, it does not change sampling parameters and you must not change them either after calling this.
unsigned int vbi_raw_decoder_check_services | ( | vbi_raw_decoder * | rd, |
unsigned int | services, | ||
int | strict | ||
) |
rd | Initialized vbi_raw_decoder structure. |
services | Set of VBI_SLICED_ symbols. |
strict | See description of vbi_raw_decoder_add_services() |
Check which of the given services can be decoded with current capture parameters at a given strictness level.
unsigned int vbi_raw_decoder_remove_services | ( | vbi_raw_decoder * | rd, |
unsigned int | services | ||
) |
rd | Initialized vbi_raw_decoder structure. |
services | Set of VBI_SLICED_ symbols. |
Removes one or more data services to be decoded from the vbi_raw_decoder structure. This function can be called at any time and does not touch sampling parameters.
void vbi_raw_decoder_resize | ( | vbi_raw_decoder * | rd, |
int * | start, | ||
unsigned int * | count | ||
) |
rd | Initialized vbi_raw_decoder structure. |
start | Array of start line indices for both fields |
count | Array of line counts for both fields |
Grows or shrinks the internal state arrays for VBI geometry changes
unsigned int vbi_raw_decoder_parameters | ( | vbi_raw_decoder * | rd, |
unsigned int | services, | ||
int | scanning, | ||
int * | max_rate | ||
) |
rd | Initialized vbi_raw_decoder structure. |
services | Set of VBI_SLICED_ symbols. Here (and only here) you can add VBI_SLICED_VBI_625 or VBI_SLICED_VBI_525 to include all vbi scan lines in the calculated sampling parameters. |
scanning | When 525 accept only NTSC services, when 625 only PAL/SECAM services. When scanning is 0, determine the scanning from the requested services, an ambiguous set will pick a 525 or 625 line system at random. |
max_rate | If given, the highest data bit rate in Hz of all services requested is stored here. (The sampling rate should be at least twice as high; rd->sampling_rate will be set to a more reasonable value of 27 MHz derived from ITU-R Rec. 601.) |
Calculate the sampling parameters in rd required to receive and decode the requested data services. rd->sampling_format will be VBI_PIXFMT_YUV420
, rd->bytes_per_line set accordingly to a reasonable minimum. This function can be used to initialize hardware prior to calling vbi_raw_decoder_add_service().
int vbi_raw_decode | ( | vbi_raw_decoder * | rd, |
uint8_t * | raw, | ||
vbi_sliced * | out | ||
) |
rd | Initialized vbi_raw_decoder structure. |
raw | A raw vbi image as defined in the vbi_raw_decoder structure (rd->sampling_format, rd->bytes_per_line, rd->count[0] + rd->count[1] scan lines). |
out | Buffer to store the decoded vbi_sliced data. Since every vbi scan line may contain data, this must be an array of vbi_sliced with the same number of entries as scan lines in the raw image (rd->count[0] + rd->count[1]). |
Decode a raw vbi image, consisting of several scan lines of raw vbi data, into sliced vbi data. The output is sorted by line number.
Note this function attempts to learn which lines carry which data service, or none, to speed up decoding. You should avoid using the same vbi_raw_decoder structure for different sources.