Raw VBI output example.
#undef NDEBUG
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <libzvbi.h>
static uint8_t pes_buffer[2048];
static vbi_sampling_par sp;
static uint8_t * image;
static unsigned int image_size;
static unsigned int pixel_mask;
static int64_t last_pts;
static void
unsigned int expect_n_lines)
{
unsigned int n_lines;
unsigned int i;
assert (n_lines == expect_n_lines);
for (i = 0; i < n_lines; ++i) {
unsigned int payload;
assert (sliced[i].id == expect_sliced[i].id);
assert (sliced[i].line == expect_sliced[i].line);
assert (0 == memcmp (sliced[i].data,
expect_sliced[i].data,
payload));
}
}
static vbi_bool
void * user_data,
unsigned int n_lines,
int64_t pts)
{
vbi_bool success;
ssize_t actual;
dx = dx;
user_data = user_data;
pts &= ((int64_t) 1 << 33) - 1;
if (0 == last_pts) {
last_pts = pts;
} else if (pts < last_pts) {
last_pts -= (int64_t) 1 << 33;
}
while (pts - last_pts > 90000 / 25 * 3 / 2) {
0, 0, 0, pixel_mask, FALSE,
NULL, 0);
assert (success);
raw_test (NULL, 0);
actual = write (STDOUT_FILENO, image, image_size);
assert (actual == (ssize_t) image_size);
last_pts += 90000 / 25;
}
0,
0,
0,
pixel_mask,
FALSE,
sliced, n_lines);
assert (success);
raw_test (sliced, n_lines);
actual = write (STDOUT_FILENO, image, image_size);
assert (actual == (ssize_t) image_size);
last_pts = pts;
return TRUE;
}
static void
mainloop (void)
{
while (1 == fread (pes_buffer, sizeof (pes_buffer), 1, stdin)) {
vbi_bool success;
pes_buffer,
sizeof (pes_buffer));
assert (success);
}
fprintf (stderr, "End of stream.\n");
}
int
main (void)
{
if (isatty (STDIN_FILENO)) {
fprintf (stderr, "No DVB PES on standard input.\n");
exit (EXIT_FAILURE);
}
if (isatty (STDOUT_FILENO)) {
fprintf (stderr, "Output is binary image data. Pipe to "
"another tool or redirect to a file.\n");
exit (EXIT_FAILURE);
}
NULL);
assert (NULL != dvb);
memset (&sp, 0, sizeof (sp));
#if 1
sp.scanning = 625;
sp.sampling_format = VBI_PIXFMT_YUYV;
sp.sampling_rate = 13.5e6;
sp.bytes_per_line = 720 * 2;
sp.offset = 9.5e-6 * 13.5e6;
sp.start[0] = 6;
sp.count[0] = 17;
sp.start[1] = 319;
sp.count[1] = 17;
sp.interlaced = TRUE;
sp.synchronous = TRUE;
pixel_mask = 0x000000FF;
#else
sp.scanning = 625;
sp.sampling_format = VBI_PIXFMT_BGRA32_LE;
sp.sampling_rate = 14.75e6;
sp.bytes_per_line = 768 * 4;
sp.offset = 10.2e-6 * 14.75e6;
sp.start[0] = 6;
sp.count[0] = 17;
sp.start[1] = 319;
sp.count[1] = 17;
sp.interlaced = TRUE;
sp.synchronous = TRUE;
pixel_mask = 0x0000FF00;
#endif
image_size = (sp.count[0] + sp.count[1]) * sp.bytes_per_line;
image = malloc (image_size);
assert (NULL != image);
if (VBI_PIXFMT_YUYV == sp.sampling_format) {
memset (image, 0x80, image_size);
} else {
memset (image, 0x00, image_size);
}
rd.
start[0] = sp.start[0];
rd.
start[1] = sp.start[1];
rd.
count[0] = sp.count[0];
rd.
count[1] = sp.count[1];
(VBI_SLICED_TELETEXT_B |
VBI_SLICED_VPS |
VBI_SLICED_CAPTION_625),
0);
mainloop ();
exit (EXIT_SUCCESS);
return 0;
}