cccombiner: fix s334-1a scheduling
authorMathieu Duponchelle <mathieu@centricular.com>
Fri, 7 Jan 2022 23:16:29 +0000 (00:16 +0100)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Wed, 12 Jan 2022 14:34:22 +0000 (14:34 +0000)
The previous code was mistakenly trying to compute a cc_type out
of the first byte in the byte triplet, whereas it is to be interpreted
as:

> Bit b7 of the LINE value is the field number (0 for field 2; 1 for field 1).
> Bits b6 and b5 are 0. Bits b4-b0 form a 5-bit unsigned integer which
> represents the offset

The same mistake was made when creating padding packets.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1496>

subprojects/gst-plugins-bad/ext/closedcaption/gstcccombiner.c

index ce88727..3a1dc62 100644 (file)
@@ -359,7 +359,7 @@ make_padding (GstCCCombiner * self, const GstVideoTimeCode * tc, guint field)
 
       gst_buffer_map (ret, &map, GST_MAP_WRITE);
 
-      map.data[0] = 0x80 | (field == 0 ? 0x01 : 0x00);
+      map.data[0] = field == 0 ? 0x80 : 0x00;
       map.data[1] = 0x80;
       map.data[2] = 0x80;
 
@@ -493,9 +493,7 @@ schedule_cea608_s334_1a (GstCCCombiner * self, guint8 * data, guint len,
   }
 
   for (i = 0; i < len / 3; i++) {
-    guint8 cc_type = data[i * 3] & 0x03;
-
-    if (cc_type == 0x01) {
+    if (data[i * 3] & 0x80) {
       if (field0_608)
         continue;
 
@@ -507,7 +505,7 @@ schedule_cea608_s334_1a (GstCCCombiner * self, guint8 * data, guint len,
       field0_data[field0_len++] = data[i * 3];
       field0_data[field0_len++] = data[i * 3 + 1];
       field0_data[field0_len++] = data[i * 3 + 2];
-    } else if (cc_type == 0x00) {
+    } else {
       if (field1_608)
         continue;
 
@@ -519,8 +517,6 @@ schedule_cea608_s334_1a (GstCCCombiner * self, guint8 * data, guint len,
       field1_data[field1_len++] = data[i * 3];
       field1_data[field1_len++] = data[i * 3 + 1];
       field1_data[field1_len++] = data[i * 3 + 2];
-    } else {
-      break;
     }
   }