This patch (against 0.3.4j) fixes the dropped VBI frames and the out-of-order
frames. I'm very interested in how this performs for CC handling. I think
that this should finally give a workable CC passthrough. Please let me know
how well it works, and especially if the synchronization with the video/audio
is correct and if the widescreen encoding is also passed through.
Before this ends up in a stable release some duration tests should be run
(provided the basics work) to see if the added VBI packets cause any decoding
problems.
Hans
diff -ru ivtv-0.3.4j/driver/ivtv-fileops.c ivtv-0.3.4j-64/driver/ivtv-fileops.c
--- ivtv-0.3.4j/driver/ivtv-fileops.c 2005-05-09 23:23:51.000000000 +0200
+++ ivtv-0.3.4j-64/driver/ivtv-fileops.c 2005-05-10 23:30:38.000000000 +0200
@@ -615,8 +615,8 @@
vbi_sliced_mpeg_offset
[idx]))) {
u8 *p;
- static u8 ba[] = { 0, 0, 1, 0xba };
- static u8 be[] = { 0, 0, 1, 0xbe };
+ static u8 code00[] = { 0, 0, 1, 0x00 }; /* start of frame code */
+ static u8 codeba[] = { 0, 0, 1, 0xba }; /* start of pack data code */
int read_from_buf = 1;
int sliced_mpeg_offset = (type == IVTV_ENC_STREAM_TYPE_MPG) ?
itv->vbi_sliced_mpeg_offset[idx] : 0;
@@ -687,13 +687,13 @@
while (n >= 4) {
if (!itv->vbi_search_ba) {
- if (!memcmp(f, be, 4))
+ if (!memcmp(f, code00, 4))
itv->vbi_search_ba = 1;
f++;
n--;
continue;
}
- if (memcmp(f, ba, 4)) {
+ if (memcmp(f, codeba, 4)) {
f++;
n--;
continue;
@@ -922,6 +922,11 @@
/* Mark as having no reader process,
the data is copied internally */
set_bit(IVTV_F_S_NO_READ, &vbi_stream->s_flags);
+
+ itv->vbi_frame = 0;
+ itv->vbi_inserted_frame = 0;
+ memset(itv->vbi_sliced_mpeg_offset, 0, sizeof(itv->vbi_sliced_mpeg_offset));
+ memset(itv->vbi_sliced_mpeg_size, 0, sizeof(itv->vbi_sliced_mpeg_size));
if (ivtv_start_v4l2_encode_stream(itv,
IVTV_ENC_STREAM_TYPE_VBI))
diff -ru ivtv-0.3.4j/driver/ivtv-vbi.c ivtv-0.3.4j-64/driver/ivtv-vbi.c
--- ivtv-0.3.4j/driver/ivtv-vbi.c 2005-05-10 08:02:37.000000000 +0200
+++ ivtv-0.3.4j-64/driver/ivtv-vbi.c 2005-05-10 23:28:56.000000000 +0200
@@ -233,10 +233,11 @@
long linemask[2] = { 0, 0 };
unsigned short size;
static u8 mpeg_hdr_data[] = {
+ 0x00, 0x00, 0x01, 0xba, 0x44, 0x00, 0x0c, 0x66, 0x24, 0x01, 0x01, 0xd1, 0xd3, 0xf8,
0x00, 0x00, 0x01, 0xbd, 0x00, 0x1a, 0x84, 0x80,
0x07, 0x21, 0x00, 0x5d, 0x63, 0xa7, 0xff, 0xff
};
- const int sd = 17; /* start of vbi data */
+ const int sd = 31; /* start of vbi data */
int idx = (itv->vbi_frame + IVTV_VBI_FRAMES - 1) % IVTV_VBI_FRAMES;
u8 *dst = &itv->vbi_sliced_mpeg_data[idx][0];
int invert = (itv->std & V4L2_STD_525_60);
@@ -286,15 +287,15 @@
memcpy(dst + sd + 4, &linemask[0], 8);
size = 10 + 12 + ((43 * line + 3) & ~3);
}
- dst[5] = size >> 8;
- dst[6] = size & 0xff;
- dst[10] = 0x21 | ((pts_stamp >> 29) & 0x6);
- dst[11] = (pts_stamp >> 22) & 0xff;
- dst[12] = 1 | ((pts_stamp >> 14) & 0xff);
- dst[13] = (pts_stamp >> 7) & 0xff;
- dst[14] = 1 | ((pts_stamp & 0x7f) << 1);
+ dst[19] = size >> 8;
+ dst[20] = size & 0xff;
+ dst[24] = 0x21 | ((pts_stamp >> 29) & 0x6);
+ dst[25] = (pts_stamp >> 22) & 0xff;
+ dst[26] = 1 | ((pts_stamp >> 14) & 0xff);
+ dst[27] = (pts_stamp >> 7) & 0xff;
+ dst[28] = 1 | ((pts_stamp & 0x7f) << 1);
itv->vbi_sliced_mpeg_offset[idx] = 0;
- itv->vbi_sliced_mpeg_size[idx] = 7 + size;
+ itv->vbi_sliced_mpeg_size[idx] = 31 + size;
}
int ivtv_DEC_VBI_fixup(struct ivtv *itv, u8 * p, int cnt, int field_lines)