ccconvert: compact input cc_data where possible
authorMatthew Waters <matthew@centricular.com>
Tue, 17 Mar 2020 06:23:44 +0000 (17:23 +1100)
committerGStreamer Merge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Mon, 11 May 2020 12:30:31 +0000 (12:30 +0000)
Skip over padding cc_data triples.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1116>

ext/closedcaption/gstccconverter.c
tests/check/elements/ccconverter.c

index 344a17d..6c7a4a2 100644 (file)
@@ -502,6 +502,46 @@ interpolate_time_code_with_framerate (GstCCConverter * self,
   return TRUE;
 }
 
+/* remove padding bytes from a cc_data packet. Returns the length of the new
+ * data in @cc_data */
+static guint
+compact_cc_data (guint8 * cc_data, guint cc_data_len)
+{
+  gboolean started_ccp = FALSE;
+  guint out_len = 0;
+  guint i;
+
+  if (cc_data_len % 3 != 0) {
+    GST_WARNING ("Invalid cc_data buffer size");
+    cc_data_len = cc_data_len - (cc_data_len % 3);
+  }
+
+  for (i = 0; i < cc_data_len / 3; i++) {
+    gboolean cc_valid = (cc_data[i * 3] & 0x04) == 0x04;
+    guint8 cc_type = cc_data[i * 3] & 0x03;
+
+    if (!started_ccp && cc_valid && (cc_type == 0x00 || cc_type == 0x01)) {
+      /* skip over 608 data */
+      cc_data[out_len++] = cc_data[i * 3];
+      cc_data[out_len++] = cc_data[i * 3 + 1];
+      cc_data[out_len++] = cc_data[i * 3 + 2];
+      continue;
+    }
+
+    if (cc_type & 0x10)
+      started_ccp = TRUE;
+
+    if (!cc_valid)
+      continue;
+
+    cc_data[out_len++] = cc_data[i * 3];
+    cc_data[out_len++] = cc_data[i * 3 + 1];
+    cc_data[out_len++] = cc_data[i * 3 + 2];
+  }
+
+  return out_len;
+}
+
 /* takes cc_data and cc_data_len and attempts to fit it into a hypothetical
  * output packet.  Any leftover data is stored for later addition.  Returns
  * the number of bytes of @cc_data to place in a new output packet */
@@ -572,7 +612,7 @@ fit_and_scale_cc_data (GstCCConverter * self,
       GST_DEBUG_OBJECT (self, "holding cc_data of len %u until next input "
           "buffer", self->scratch_len);
       memcpy (self->scratch, cc_data, self->scratch_len);
-      return 0;
+      return -1;
     } else if (rate_cmp != 0) {
       /* we are changing the framerate and may overflow the max output packet
        * size. Split them where necessary. */
@@ -834,6 +874,7 @@ cdp_to_cc_data (GstCCConverter * self, GstBuffer * inbuf, guint8 * out,
           cc_data_len / 3);
       cc_data_len = 3 * (*out_fps_entry)->max_cc_count;
     }
+    cc_data_len = compact_cc_data (&out[len], cc_data_len);
     len += cc_data_len;
 
     gst_buffer_unmap (inbuf, &in);
@@ -928,7 +969,8 @@ convert_cea608_raw_cea708_cdp (GstCCConverter * self, GstBuffer * inbuf,
     GstBuffer * outbuf)
 {
   GstMapInfo in, out;
-  guint i, n, len;
+  guint i, n;
+  gint len;
   guint8 cc_data[MAX_CDP_PACKET_LEN];
   const GstVideoTimeCodeMeta *tc_meta;
   const struct cdp_fps_entry *fps_entry;
@@ -964,10 +1006,12 @@ convert_cea608_raw_cea708_cdp (GstCCConverter * self, GstBuffer * inbuf,
 
   len = fit_and_scale_cc_data (self, NULL, fps_entry, cc_data,
       n * 3, tc_meta ? &tc_meta->tc : NULL);
-  if (len > 0) {
+  if (len >= 0) {
     len =
         convert_cea708_cc_data_cea708_cdp_internal (self, cc_data, len,
         out.data, out.size, &self->current_output_timecode, fps_entry);
+  } else {
+    len = 0;
   }
 
   gst_buffer_unmap (inbuf, &in);
@@ -1060,7 +1104,8 @@ convert_cea608_s334_1a_cea708_cdp (GstCCConverter * self, GstBuffer * inbuf,
     GstBuffer * outbuf)
 {
   GstMapInfo in, out;
-  guint i, n, len;
+  guint i, n;
+  gint len;
   guint8 cc_data[MAX_CDP_PACKET_LEN];
   const GstVideoTimeCodeMeta *tc_meta;
   const struct cdp_fps_entry *fps_entry;
@@ -1095,10 +1140,12 @@ convert_cea608_s334_1a_cea708_cdp (GstCCConverter * self, GstBuffer * inbuf,
 
   len = fit_and_scale_cc_data (self, NULL, fps_entry, cc_data,
       n * 3, tc_meta ? &tc_meta->tc : NULL);
-  if (len > 0) {
+  if (len >= 0) {
     len =
         convert_cea708_cc_data_cea708_cdp_internal (self, cc_data, len,
         out.data, out.size, &self->current_output_timecode, fps_entry);
+  } else {
+    len = 0;
   }
 
   gst_buffer_unmap (inbuf, &in);
@@ -1201,7 +1248,7 @@ convert_cea708_cc_data_cea708_cdp (GstCCConverter * self, GstBuffer * inbuf,
 {
   GstMapInfo in, out;
   guint n;
-  guint len;
+  gint len;
   const GstVideoTimeCodeMeta *tc_meta;
   const struct cdp_fps_entry *fps_entry;
 
@@ -1229,10 +1276,12 @@ convert_cea708_cc_data_cea708_cdp (GstCCConverter * self, GstBuffer * inbuf,
 
   len = fit_and_scale_cc_data (self, NULL, fps_entry, in.data,
       in.size, tc_meta ? &tc_meta->tc : NULL);
-  if (len > 0) {
+  if (len >= 0) {
     len =
         convert_cea708_cc_data_cea708_cdp_internal (self, in.data, len,
         out.data, out.size, &self->current_output_timecode, fps_entry);
+  } else {
+    len = 0;
   }
 
   gst_buffer_unmap (inbuf, &in);
@@ -1249,7 +1298,8 @@ convert_cea708_cdp_cea608_raw (GstCCConverter * self, GstBuffer * inbuf,
 {
   GstMapInfo out;
   GstVideoTimeCode tc = GST_VIDEO_TIME_CODE_INIT;
-  guint i, len = 0, cea608 = 0;
+  guint i, cea608 = 0;
+  gint len = 0;
   const struct cdp_fps_entry *in_fps_entry = NULL, *out_fps_entry;
   guint8 cc_data[MAX_CDP_PACKET_LEN] = { 0, };
 
@@ -1301,7 +1351,8 @@ convert_cea708_cdp_cea608_s334_1a (GstCCConverter * self, GstBuffer * inbuf,
 {
   GstMapInfo out;
   GstVideoTimeCode tc = GST_VIDEO_TIME_CODE_INIT;
-  guint i, len = 0, cea608 = 0;
+  guint i, cea608 = 0;
+  gint len = 0;
   const struct cdp_fps_entry *in_fps_entry = NULL, *out_fps_entry;
   guint8 cc_data[MAX_CDP_PACKET_LEN] = { 0, };
 
@@ -1350,7 +1401,7 @@ convert_cea708_cdp_cea708_cc_data (GstCCConverter * self, GstBuffer * inbuf,
 {
   GstMapInfo out;
   GstVideoTimeCode tc = GST_VIDEO_TIME_CODE_INIT;
-  guint len = 0;
+  gint len = 0;
   const struct cdp_fps_entry *in_fps_entry = NULL, *out_fps_entry;
   guint8 cc_data[MAX_CDP_PACKET_LEN] = { 0, };
 
@@ -1364,11 +1415,13 @@ convert_cea708_cdp_cea708_cc_data (GstCCConverter * self, GstBuffer * inbuf,
 
   len = fit_and_scale_cc_data (self, in_fps_entry, out_fps_entry, cc_data, len,
       &tc);
-  if (len > 0) {
+  if (len >= 0) {
     gst_buffer_map (outbuf, &out, GST_MAP_WRITE);
     memcpy (out.data, cc_data, len);
     gst_buffer_unmap (outbuf, &out);
     self->output_frames++;
+  } else {
+    len = 0;
   }
 
   if (self->current_output_timecode.config.fps_n != 0
@@ -1389,7 +1442,7 @@ convert_cea708_cdp_cea708_cdp (GstCCConverter * self, GstBuffer * inbuf,
 {
   GstMapInfo out;
   GstVideoTimeCode tc = GST_VIDEO_TIME_CODE_INIT;
-  guint len = 0;
+  gint len = 0;
   const struct cdp_fps_entry *in_fps_entry = NULL, *out_fps_entry;
   guint8 cc_data[MAX_CDP_PACKET_LEN] = { 0, };
 
@@ -1403,7 +1456,7 @@ convert_cea708_cdp_cea708_cdp (GstCCConverter * self, GstBuffer * inbuf,
 
   len = fit_and_scale_cc_data (self, in_fps_entry, out_fps_entry, cc_data, len,
       &tc);
-  if (len > 0) {
+  if (len >= 0) {
     gst_buffer_map (outbuf, &out, GST_MAP_WRITE);
     len =
         convert_cea708_cc_data_cea708_cdp_internal (self, cc_data, len,
@@ -1411,6 +1464,8 @@ convert_cea708_cdp_cea708_cdp (GstCCConverter * self, GstBuffer * inbuf,
 
     gst_buffer_unmap (outbuf, &out);
     self->output_frames++;
+  } else {
+    len = 0;
   }
 
   gst_buffer_set_size (outbuf, len);
@@ -1570,6 +1625,36 @@ gst_cc_converter_transform_meta (GstBaseTransform * base, GstBuffer * outbuf,
       meta, inbuf);
 }
 
+static gboolean
+can_generate_output (GstCCConverter * self)
+{
+  int input_frame_n, input_frame_d, output_frame_n, output_frame_d;
+  int output_time_cmp;
+
+  if (self->in_fps_n == 0 || self->out_fps_n == 0)
+    return FALSE;
+
+  /* compute the relative frame count for each */
+  if (!gst_util_fraction_multiply (self->in_fps_d, self->in_fps_n,
+          self->input_frames, 1, &input_frame_n, &input_frame_d))
+    /* we should never overflow */
+    g_assert_not_reached ();
+
+  if (!gst_util_fraction_multiply (self->out_fps_d, self->out_fps_n,
+          self->output_frames + 1, 1, &output_frame_n, &output_frame_d))
+    /* we should never overflow */
+    g_assert_not_reached ();
+
+  output_time_cmp = gst_util_fraction_compare (input_frame_n, input_frame_d,
+      output_frame_n, output_frame_d);
+
+  /* if the next output frame is at or before the current input frame */
+  if (output_time_cmp >= 0)
+    return TRUE;
+
+  return FALSE;
+}
+
 static GstFlowReturn
 gst_cc_converter_generate_output (GstBaseTransform * base, GstBuffer ** outbuf)
 {
@@ -1580,7 +1665,7 @@ gst_cc_converter_generate_output (GstBaseTransform * base, GstBuffer ** outbuf)
 
   *outbuf = NULL;
   base->queued_buf = NULL;
-  if (!inbuf && self->scratch_len == 0) {
+  if (!inbuf && !can_generate_output (self)) {
     return GST_FLOW_OK;
   }
 
@@ -1630,7 +1715,7 @@ gst_cc_converter_sink_event (GstBaseTransform * trans, GstEvent * event)
     case GST_EVENT_EOS:
       GST_DEBUG_OBJECT (self, "received EOS");
 
-      while (self->scratch_len > 0) {
+      while (self->scratch_len > 0 || can_generate_output (self)) {
         GstBuffer *outbuf;
         GstFlowReturn ret;
 
index 0234c7d..ac48ddf 100644 (file)
@@ -459,16 +459,16 @@ GST_START_TEST (convert_cea708_cdp_cea708_cdp_double_framerate)
   const GstVideoTimeCode *in_tc[] = { &in_tc1 };
 
   const guint8 out1[] = { 0x96, 0x69, 0x30, 0x8f, 0xc3, 0x00, 0x00, 0x71, 0xd0,
-    0xa0, 0x30, 0x00, 0x72, 0xea, 0xfc, 0x80, 0x80, 0xfe, 0x80, 0x80, 0xf8,
-    0x00, 0x00, 0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00, 0xf8,
+    0xa0, 0x30, 0x00, 0x72, 0xea, 0xfc, 0x80, 0x80, 0xfe, 0x80, 0x80, 0xfe,
+    0x00, 0x00, 0xfc, 0x00, 0x00, 0xfc, 0x00, 0x00, 0xfc, 0x00, 0x00, 0xf8,
     0x00, 0x00, 0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00, 0x74,
-    0x00, 0x00, 0xe4
+    0x00, 0x00, 0xd2
   };
   const guint8 out2[] = { 0x96, 0x69, 0x30, 0x8f, 0xc3, 0x00, 0x01, 0x71, 0xd0,
-    0xa0, 0x30, 0x10, 0x72, 0xea, 0xfe, 0x00, 0x00, 0xfc, 0x00, 0x00, 0xfc,
-    0x00, 0x00, 0xfc, 0x00, 0x00, 0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00, 0xf8,
+    0xa0, 0x30, 0x10, 0x72, 0xea, 0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00, 0xf8,
+    0x00, 0x00, 0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00, 0xf8,
     0x00, 0x00, 0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00, 0x74,
-    0x00, 0x01, 0xca
+    0x00, 0x01, 0xdc
   };
   const guint8 *out[] = { out1, out2 };
   guint out_len[] = { sizeof (out1), sizeof (out2) };
@@ -502,14 +502,14 @@ GST_END_TEST;
 GST_START_TEST (convert_cea708_cdp_cea708_cdp_half_framerate)
 {
   /* tests that two input packets are merged together when halving the
-   * framerate */
+   * framerate.  With cc_data compaction! */
   const guint8 in1[] = { 0x96, 0x69, 0x2b, 0x8f, 0x43, 0x00, 0x00, 0x72, 0xea,
     0xfc, 0x80, 0x80, 0xfe, 0x80, 0x80, 0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00,
     0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00,
     0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00, 0x74, 0x00, 0x00, 0x7a
   };
   const guint8 in2[] = { 0x96, 0x69, 0x2b, 0x8f, 0x43, 0x00, 0x01, 0x72, 0xea,
-    0xfe, 0x00, 0x00, 0xfc, 0x00, 0x00, 0xfc, 0x00, 0x00, 0xfc, 0x00, 0x00,
+    0xfe, 0x00, 0x00, 0xfc, 0x00, 0x00, 0xfc, 0x00, 0x00, 0xf8, 0x00, 0x00,
     0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00,
     0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00, 0x74, 0x00, 0x01, 0x70
   };
@@ -520,12 +520,12 @@ GST_START_TEST (convert_cea708_cdp_cea708_cdp_half_framerate)
 
   const guint8 out1[] =
       { 0x96, 0x69, 0x4e, 0x5f, 0xc3, 0x00, 0x00, 0x71, 0xd0, 0xa0, 0x30, 0x00,
-    0x72, 0xf4, 0xfc, 0x80, 0x80, 0xfe, 0x80, 0x80, 0xf8, 0x00, 0x00, 0xf8,
+    0x72, 0xf4, 0xfc, 0x80, 0x80, 0xfe, 0x80, 0x80, 0xfe, 0x00, 0x00, 0xfc,
+    0x00, 0x00, 0xfc, 0x00, 0x00, 0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00, 0xf8,
+    0x00, 0x00, 0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00, 0xf8,
     0x00, 0x00, 0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00, 0xf8,
-    0x00, 0x00, 0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00, 0xfe, 0x00, 0x00, 0xfc,
-    0x00, 0x00, 0xfc, 0x00, 0x00, 0xfc, 0x00, 0x00, 0xf8, 0x00, 0x00, 0xf8,
     0x00, 0x00, 0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00, 0xf8,
-    0x00, 0x00, 0x74, 0x00, 0x00, 0x2a
+    0x00, 0x00, 0x74, 0x00, 0x00, 0x2e
   };
   const guint8 *out[] = { out1 };
   guint out_len[] = { sizeof (out1) };
@@ -562,9 +562,9 @@ GST_START_TEST (convert_cea708_cdp_cea708_cdp_max_merge)
    * packets with the extra data on the third input packet being placed at the
    * beginning of the second output packet */
   const guint8 in1[] = { 0x96, 0x69, 0x2b, 0x8f, 0x43, 0x00, 0x00, 0x72, 0xea,
-    0xfc, 0x80, 0x80, 0xfe, 0x80, 0x80, 0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00,
-    0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00,
-    0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00, 0x74, 0x00, 0x00, 0x7a
+    0xfc, 0x80, 0x80, 0xfe, 0x00, 0x00, 0xfe, 0x00, 0x00, 0xfe, 0x00, 0x00,
+    0xfe, 0x00, 0x00, 0xfe, 0x80, 0x80, 0xfe, 0x00, 0x00, 0xfe, 0x00, 0x00,
+    0xfe, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x74, 0x00, 0x00, 0x7a
   };
   /* enough input to fully cover two output packets. Extra is discarded */
   const guint8 *in[] = { in1, in1, in1, in1, in1, in1, in1 };
@@ -575,23 +575,23 @@ GST_START_TEST (convert_cea708_cdp_cea708_cdp_max_merge)
 
   const guint8 out1[] =
       { 0x96, 0x69, 0x58, 0x1f, 0x43, 0x00, 0x00, 0x72, 0xf9, 0xfc, 0x80, 0x80,
-    0xfe, 0x80, 0x80, 0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00,
-    0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00,
-    0xf8, 0x00, 0x00, 0xfc, 0x80, 0x80, 0xfe, 0x80, 0x80, 0xf8, 0x00, 0x00,
-    0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00,
-    0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00, 0xfc, 0x80, 0x80,
-    0xfe, 0x80, 0x80, 0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00,
-    0x74, 0x00, 0x00, 0x12
+    0xfe, 0x00, 0x00, 0xfe, 0x00, 0x00, 0xfe, 0x00, 0x00, 0xfe, 0x00, 0x00,
+    0xfe, 0x80, 0x80, 0xfe, 0x00, 0x00, 0xfe, 0x00, 0x00, 0xfe, 0x00, 0x00,
+    0xfe, 0x00, 0x00, 0xfc, 0x80, 0x80, 0xfe, 0x00, 0x00, 0xfe, 0x00, 0x00,
+    0xfe, 0x00, 0x00, 0xfe, 0x00, 0x00, 0xfe, 0x80, 0x80, 0xfe, 0x00, 0x00,
+    0xfe, 0x00, 0x00, 0xfe, 0x00, 0x00, 0xfe, 0x00, 0x00, 0xfc, 0x80, 0x80,
+    0xfe, 0x00, 0x00, 0xfe, 0x00, 0x00, 0xfe, 0x00, 0x00, 0xfe, 0x00, 0x00,
+    0x74, 0x00, 0x00, 0xa0
   };
   const guint8 out2[] =
-      { 0x96, 0x69, 0x58, 0x1f, 0x43, 0x00, 0x01, 0x72, 0xf9, 0xf8, 0x00, 0x00,
-    0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00,
-    0xfc, 0x80, 0x80, 0xfe, 0x80, 0x80, 0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00,
-    0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00,
-    0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00, 0xfc, 0x80, 0x80, 0xfe, 0x80, 0x80,
-    0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00,
-    0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00,
-    0x74, 0x00, 0x01, 0x1a
+      { 0x96, 0x69, 0x58, 0x1f, 0x43, 0x00, 0x01, 0x72, 0xf9, 0xfe, 0x80, 0x80,
+    0xfe, 0x00, 0x00, 0xfe, 0x00, 0x00, 0xfe, 0x00, 0x00, 0xfe, 0x00, 0x00,
+    0xfc, 0x80, 0x80, 0xfe, 0x00, 0x00, 0xfe, 0x00, 0x00, 0xfe, 0x00, 0x00,
+    0xfe, 0x00, 0x00, 0xfe, 0x80, 0x80, 0xfe, 0x00, 0x00, 0xfe, 0x00, 0x00,
+    0xfe, 0x00, 0x00, 0xfe, 0x00, 0x00, 0xfc, 0x80, 0x80, 0xfe, 0x00, 0x00,
+    0xfe, 0x00, 0x00, 0xfe, 0x00, 0x00, 0xfe, 0x00, 0x00, 0xfe, 0x80, 0x80,
+    0xfe, 0x00, 0x00, 0xfe, 0x00, 0x00, 0xfe, 0x00, 0x00, 0xfe, 0x00, 0x00,
+    0x74, 0x00, 0x01, 0x9c
   };
   const guint8 *out[] = { out1, out2 };
   guint out_len[] = { sizeof (out1), sizeof (out2) };
@@ -610,36 +610,36 @@ GST_START_TEST (convert_cea708_cdp_cea708_cdp_max_split)
    * high framerate */
   const guint8 in1[] =
       { 0x96, 0x69, 0x58, 0x1f, 0x43, 0x00, 0x00, 0x72, 0xf9, 0xfc, 0x80, 0x80,
-    0xfe, 0x80, 0x80, 0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00,
-    0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00,
-    0xf8, 0x00, 0x00, 0xfc, 0x80, 0x80, 0xfe, 0x80, 0x80, 0xf8, 0x00, 0x00,
-    0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00,
-    0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00, 0xfc, 0x80, 0x80,
-    0xfe, 0x80, 0x80, 0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00,
+    0xfe, 0x80, 0x80, 0xfe, 0x00, 0x00, 0xfe, 0x00, 0x00, 0xfe, 0x00, 0x00,
+    0xfe, 0x00, 0x00, 0xfe, 0x00, 0x00, 0xfe, 0x00, 0x00, 0xfe, 0x00, 0x00,
+    0xfe, 0x00, 0x00, 0xfc, 0x80, 0x80, 0xfe, 0x80, 0x80, 0xfe, 0x00, 0x00,
+    0xfe, 0x00, 0x00, 0xfe, 0x00, 0x00, 0xfe, 0x00, 0x00, 0xfe, 0x00, 0x00,
+    0xfe, 0x00, 0x00, 0xfe, 0x00, 0x00, 0xfe, 0x00, 0x00, 0xfe, 0x80, 0x80,
+    0xfe, 0x80, 0x80, 0xfe, 0x00, 0x00, 0xfe, 0x00, 0x00, 0xfe, 0x00, 0x00,
     0x74, 0x00, 0x00, 0x12
   };
   const guint8 *in[] = { in1, in1 };
   guint in_len[] = { sizeof (in1), sizeof (in1) };
 
   const guint8 out1[] = { 0x96, 0x69, 0x2b, 0x8f, 0x43, 0x00, 0x00, 0x72, 0xea,
-    0xfc, 0x80, 0x80, 0xfe, 0x80, 0x80, 0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00,
-    0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00,
-    0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00, 0x74, 0x00, 0x00, 0x7a
+    0xfc, 0x80, 0x80, 0xfe, 0x80, 0x80, 0xfe, 0x00, 0x00, 0xfe, 0x00, 0x00,
+    0xfe, 0x00, 0x00, 0xfe, 0x00, 0x00, 0xfe, 0x00, 0x00, 0xfe, 0x00, 0x00,
+    0xfe, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x74, 0x00, 0x00, 0x4a
   };
   const guint8 out2[] = { 0x96, 0x69, 0x2b, 0x8f, 0x43, 0x00, 0x01, 0x72, 0xea,
-    0xfc, 0x80, 0x80, 0xfe, 0x80, 0x80, 0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00,
-    0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00,
-    0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00, 0x74, 0x00, 0x01, 0x78
+    0xfc, 0x80, 0x80, 0xfe, 0x80, 0x80, 0xfe, 0x00, 0x00, 0xfe, 0x00, 0x00,
+    0xfe, 0x00, 0x00, 0xfe, 0x00, 0x00, 0xfe, 0x00, 0x00, 0xfe, 0x00, 0x00,
+    0xfe, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x74, 0x00, 0x01, 0x48
   };
   const guint8 out3[] = { 0x96, 0x69, 0x2b, 0x8f, 0x43, 0x00, 0x02, 0x72, 0xea,
-    0xfc, 0x80, 0x80, 0xfe, 0x80, 0x80, 0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00,
-    0xf8, 0x00, 0x00, 0xfc, 0x80, 0x80, 0xfe, 0x80, 0x80, 0xf8, 0x00, 0x00,
-    0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00, 0x74, 0x00, 0x02, 0x6c
+    0xfe, 0x80, 0x80, 0xfe, 0x80, 0x80, 0xfe, 0x00, 0x00, 0xfe, 0x00, 0x00,
+    0xfe, 0x00, 0x00, 0xfc, 0x80, 0x80, 0xfe, 0x80, 0x80, 0xfe, 0x00, 0x00,
+    0xfe, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x74, 0x00, 0x02, 0x46
   };
   const guint8 out4[] = { 0x96, 0x69, 0x2b, 0x8f, 0x43, 0x00, 0x03, 0x72, 0xea,
-    0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00,
-    0xf8, 0x00, 0x00, 0xfc, 0x80, 0x80, 0xfe, 0x80, 0x80, 0xf8, 0x00, 0x00,
-    0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00, 0x74, 0x00, 0x03, 0x74
+    0xfe, 0x00, 0x00, 0xfe, 0x00, 0x00, 0xfe, 0x00, 0x00, 0xfe, 0x00, 0x00,
+    0xfe, 0x00, 0x00, 0xfc, 0x80, 0x80, 0xfe, 0x80, 0x80, 0xfe, 0x00, 0x00,
+    0xfe, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x74, 0x00, 0x03, 0x44
   };
   const guint8 *out[] = { out1, out2, out3, out4 };
   guint out_len[] =
@@ -659,31 +659,31 @@ GST_START_TEST (convert_cea708_cdp_cea708_cdp_max_split_eos)
    * high framerate and that an EOS will push the pending data */
   const guint8 in1[] =
       { 0x96, 0x69, 0x58, 0x1f, 0x43, 0x00, 0x00, 0x72, 0xf9, 0xfc, 0x80, 0x80,
-    0xfe, 0x80, 0x80, 0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00,
-    0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00,
-    0xf8, 0x00, 0x00, 0xfc, 0x80, 0x80, 0xfe, 0x80, 0x80, 0xf8, 0x00, 0x00,
-    0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00,
-    0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00, 0xfc, 0x80, 0x80,
-    0xfe, 0x80, 0x80, 0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00, 0xf9, 0x00, 0x00,
+    0xfe, 0x80, 0x80, 0xfe, 0x00, 0x00, 0xfe, 0x00, 0x00, 0xfe, 0x00, 0x00,
+    0xfe, 0x00, 0x00, 0xfe, 0x00, 0x00, 0xfe, 0x00, 0x00, 0xfe, 0x00, 0x00,
+    0xfe, 0x00, 0x00, 0xfc, 0x80, 0x80, 0xfe, 0x80, 0x80, 0xfe, 0x00, 0x00,
+    0xfe, 0x00, 0x00, 0xfe, 0x00, 0x00, 0xfe, 0x00, 0x00, 0xfe, 0x00, 0x00,
+    0xfe, 0x00, 0x00, 0xfe, 0x00, 0x00, 0xfe, 0x00, 0x00, 0xfe, 0x80, 0x80,
+    0xfe, 0x80, 0x80, 0xfe, 0x00, 0x00, 0xfe, 0x00, 0x00, 0xfe, 0x00, 0x00,
     0x74, 0x00, 0x00, 0x12
   };
   const guint8 *in[] = { in1 };
   guint in_len[] = { sizeof (in1) };
 
   const guint8 out1[] = { 0x96, 0x69, 0x2b, 0x8f, 0x43, 0x00, 0x00, 0x72, 0xea,
-    0xfc, 0x80, 0x80, 0xfe, 0x80, 0x80, 0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00,
-    0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00,
-    0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00, 0x74, 0x00, 0x00, 0x7a
+    0xfc, 0x80, 0x80, 0xfe, 0x80, 0x80, 0xfe, 0x00, 0x00, 0xfe, 0x00, 0x00,
+    0xfe, 0x00, 0x00, 0xfe, 0x00, 0x00, 0xfe, 0x00, 0x00, 0xfe, 0x00, 0x00,
+    0xfe, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x74, 0x00, 0x00, 0x4a
   };
   const guint8 out2[] = { 0x96, 0x69, 0x2b, 0x8f, 0x43, 0x00, 0x01, 0x72, 0xea,
-    0xfc, 0x80, 0x80, 0xfe, 0x80, 0x80, 0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00,
-    0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00,
-    0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00, 0x74, 0x00, 0x01, 0x78
+    0xfc, 0x80, 0x80, 0xfe, 0x80, 0x80, 0xfe, 0x00, 0x00, 0xfe, 0x00, 0x00,
+    0xfe, 0x00, 0x00, 0xfe, 0x00, 0x00, 0xfe, 0x00, 0x00, 0xfe, 0x00, 0x00,
+    0xfe, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x74, 0x00, 0x01, 0x48
   };
   const guint8 out3[] = { 0x96, 0x69, 0x2b, 0x8f, 0x43, 0x00, 0x02, 0x72, 0xea,
-    0xfc, 0x80, 0x80, 0xfe, 0x80, 0x80, 0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00,
-    0xf9, 0x00, 0x00, 0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00,
-    0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00, 0x74, 0x00, 0x02, 0x75
+    0xfe, 0x80, 0x80, 0xfe, 0x80, 0x80, 0xfe, 0x00, 0x00, 0xfe, 0x00, 0x00,
+    0xfe, 0x00, 0x00, 0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00,
+    0xf8, 0x00, 0x00, 0xf8, 0x00, 0x00, 0x74, 0x00, 0x02, 0x62
   };
   const guint8 *out[] = { out1, out2, out3 };
   guint out_len[] = { sizeof (out1), sizeof (out2), sizeof (out3) };