x264enc: CEA-708 cc_data structure contains invalid values
Hi,
CEA-708 Closed Captions injection support was introduced in encoder by commit c4456d57. However em_data field (see this line of gstx264enc.c) should not be zero. As CEA-708-D states (section 4.4 table 2) this field should be initialized with all bits set (i.e. 0xFF). h264parse element also expects this value while validating CC SEI message. I could suppose that other decoders (such as FFMpeg) also rely on this.
I've attached a test problematic stream which can reproduce the issue. Sample pipeline is:
$ gst-launch-1.0 -v filesrc location=bbb_sei_cc.h264 ! h264parse ! identity silent=false ! fakesink
You should notice no metadata on buffers. I've also added correct stream to compare against.
I'd propose following fix:
diff --git a/ext/x264/gstx264enc.c b/ext/x264/gstx264enc.c
index f313b211..ca9ccb8d 100644
--- a/ext/x264/gstx264enc.c
+++ b/ext/x264/gstx264enc.c
@@ -2413,7 +2413,7 @@ gst_x264_enc_add_cc (GstBuffer * buffer, x264_picture_t * pic_in)
*/
pic_in->extra_sei.payloads[i].payload[8] =
((cc_meta->size / 3) & 0x1f) | 0x40;
- pic_in->extra_sei.payloads[i].payload[9] = 0; /* 8 bits em_data, unused */
+ pic_in->extra_sei.payloads[i].payload[9] = 255; /* 8 bits em_data, unused */
pic_in->extra_sei.payloads[i].payload[cc_meta->size + 10] = 255; /* 8 marker bits */
}
}
Reproduced on:
Ubuntu 19.04 Disco Dingo
GStreamer: 1.15.90 (installed by package manager, first installation, git version from tag 1.15.90 also reproduces the issue)