ZVBI Library  0.2.33
Functions
Raw VBI encoder
Raw VBI

Converting sliced VBI data to raw VBI images. More...

Functions

vbi_bool vbi_raw_video_image (uint8_t *raw, unsigned long raw_size, const vbi_sampling_par *sp, int blank_level, int black_level, int white_level, unsigned int pixel_mask, vbi_bool swap_fields, const vbi_sliced *sliced, unsigned int n_sliced_lines)
vbi_bool vbi_raw_add_noise (uint8_t *raw, const vbi_sampling_par *sp, unsigned int min_freq, unsigned int max_freq, unsigned int amplitude, unsigned int seed)
vbi_bool vbi_raw_vbi_image (uint8_t *raw, unsigned long raw_size, const vbi_sampling_par *sp, int blank_level, int white_level, vbi_bool swap_fields, const vbi_sliced *sliced, unsigned int n_sliced_lines)

Detailed Description

Converting sliced VBI data to raw VBI images.

These are functions converting sliced VBI data to raw VBI images as transmitted in the vertical blanking interval of analog video standards. They are mainly intended for tests of the libzvbi bit slicer and raw VBI decoder.


Function Documentation

vbi_bool vbi_raw_video_image ( uint8_t *  raw,
unsigned long  raw_size,
const vbi_sampling_par *  sp,
int  blank_level,
int  black_level,
int  white_level,
unsigned int  pixel_mask,
vbi_bool  swap_fields,
const vbi_sliced sliced,
unsigned int  n_sliced_lines 
)
Parameters:
rawA raw VBI image will be stored here.
raw_sizeSize of the raw buffer in bytes. The buffer must be large enough for sp->count[0] + count[1] lines of sp->bytes_per_line each, with sp->samples_per_line times bytes per pixel (in libzvbi 0.2.x sp->bytes_per_line) actually written.
spDescribes the raw VBI data to generate. Note for compatibility in libzvbi 0.2.x vbi_sampling_par is a synonym of vbi_raw_decoder, but the (private) decoder fields in this structure are ignored.
blank_levelThe level of the horizontal blanking in the raw VBI image. Must be <= black_level.
black_levelThe black level in the raw VBI image. Must be <= white_level.
white_levelThe peak white level in the raw VBI image. Set to zero to get the default blanking, black and white level.
pixel_maskThis mask selects which color or alpha channel shall contain VBI data. Depending on sp->sampling_format it is interpreted as 0xAABBGGRR or 0xAAVVUUYY. A value of 0x000000FF for example writes data in "red bits", not changing other bits in the raw buffer. When the sp->sampling_format is a planar YUV the function writes the Y plane only.
swap_fieldsIf TRUE the second field will be stored first in the raw buffer. Note you can also get an interlaced image by setting sp->interlaced to TRUE. sp->synchronous is ignored.
slicedPointer to an array of vbi_sliced containing the VBI data to be encoded.
n_sliced_linesNumber of elements in the sliced array.

Generates a raw VBI image similar to those you get from video capture hardware. Otherwise identical to vbi_raw_vbi_image().

Returns:
FALSE if the raw_size is too small, if the sp sampling parameters are invalid, if the signal levels are invalid, if the sliced array contains unsupported services or line numbers outside the sp sampling parameters.
Since:
0.2.22
vbi_bool vbi_raw_add_noise ( uint8_t *  raw,
const vbi_sampling_par *  sp,
unsigned int  min_freq,
unsigned int  max_freq,
unsigned int  amplitude,
unsigned int  seed 
)
Parameters:
rawNoise will be added to this raw VBI image.
spDescribes the raw VBI data in the buffer. sp->sampling_format must be VBI_PIXFMT_Y8 (VBI_PIXFMT_YUV420 in libzvbi 0.2.x). Note for compatibility in libzvbi 0.2.x vbi_sampling_par is a synonym of vbi_raw_decoder, but the (private) decoder fields in this structure are ignored.
min_freqMinimum frequency of the noise in Hz.
max_freqMaximum frequency of the noise in Hz. min_freq and max_freq define the cut off frequency at the half power points (gain -3 dB).
amplitudeMaximum amplitude of the noise, should lie in range 0 to 256.
seedSeed for the pseudo random number generator built into this function. Given the same seed value the function will add the same noise, which can be useful for tests.

This function adds white noise to a raw VBI image.

To produce realistic noise min_freq = 0, max_freq = 5e6 and amplitude = 20 to 50 seems appropriate.

Returns:
FALSE if the sp sampling parameters are invalid.
Since:
0.2.26
vbi_bool vbi_raw_vbi_image ( uint8_t *  raw,
unsigned long  raw_size,
const vbi_sampling_par *  sp,
int  blank_level,
int  white_level,
vbi_bool  swap_fields,
const vbi_sliced sliced,
unsigned int  n_sliced_lines 
)
Parameters:
rawA raw VBI image will be stored here.
raw_sizeSize of the raw buffer in bytes. The buffer must be large enough for sp->count[0] + count[1] lines of sp->bytes_per_line each, with sp->samples_per_line (in libzvbi 0.2.x sp->bytes_per_line) bytes actually written.
spDescribes the raw VBI data to generate. sp->sampling_format must be VBI_PIXFMT_Y8 (VBI_PIXFMT_YUV420 with libzvbi 0.2.x). sp->synchronous is ignored. Note for compatibility in libzvbi 0.2.x vbi_sampling_par is a synonym of vbi_raw_decoder, but the (private) decoder fields in this structure are ignored.
blank_levelThe level of the horizontal blanking in the raw VBI image. Must be <= white_level.
white_levelThe peak white level in the raw VBI image. Set to zero to get the default blanking and white level.
swap_fieldsIf TRUE the second field will be stored first in the raw buffer. Note you can also get an interlaced image by setting sp->interlaced to TRUE. sp->synchronous is ignored.
slicedPointer to an array of vbi_sliced containing the VBI data to be encoded.
n_sliced_linesNumber of elements in the sliced array.

This function basically reverses the operation of the vbi_raw_decoder, taking sliced VBI data and generating a raw VBI image similar to those you would get from raw VBI sampling hardware. The following data services are currently supported: All Teletext services, VPS, WSS 625, Closed Caption 525 and 625.

The function encodes sliced data as is, e.g. without adding or checking parity bits, without checking if the line number is correct for the respective data service, or if the signal will fit completely in the given space (sp->offset and sp->samples_per_line at sp->sampling_rate).

Apart of the payload the generated video signal is invariable and attempts to be faithful to related standards. You can only change the characteristics of the assumed capture device. Sync pulses and color bursts and not generated if the sampling parameters extend to this area.

Note:
This function is mainly intended for testing purposes. It is optimized for accuracy, not for speed.
Returns:
FALSE if the raw_size is too small, if the sp sampling parameters are invalid, if the signal levels are invalid, if the sliced array contains unsupported services or line numbers outside the sp sampling parameters.
Since:
0.2.22