From 78bc3d53dd2f3b2f7f0377b8edc34319401755ef Mon Sep 17 00:00:00 2001 From: Vivia Nikolaidou Date: Wed, 18 Oct 2023 15:12:38 +0300 Subject: [PATCH] ccutils: Keep upstream padding payload A payload of 0x80 0x80 means that it's padding. It's not a good idea to throw this away though, because of the cc_valid field. According to CEA 10-B section 25.2.1, if cc_valid is zero, the run-in clock and start bit should not be generated. In practice, this means that any closed captions will be erased and the end-user TV will show that captions are not available for this stream. This might have undesired consequences, e.g. we were just showing a long line of captions and we disable it before the user has had time to read it, or you can't enable closed captions during silence/music intervals. We cannot reliably detect whether there's a currently-silent closed caption stream or just nothing, but we have this information coming from upstream, so we can at least not discard it. Part-of: --- .../gst-plugins-bad/ext/closedcaption/ccutils.c | 12 ++++-------- .../tests/check/elements/ccconverter.c | 16 ++++++++-------- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/subprojects/gst-plugins-bad/ext/closedcaption/ccutils.c b/subprojects/gst-plugins-bad/ext/closedcaption/ccutils.c index 84f73632c1..04d15538b1 100644 --- a/subprojects/gst-plugins-bad/ext/closedcaption/ccutils.c +++ b/subprojects/gst-plugins-bad/ext/closedcaption/ccutils.c @@ -382,10 +382,8 @@ cc_data_extract_cea608 (const guint8 * cc_data, guint cc_data_len, return CC_DATA_EXTRACT_TOO_MANY_FIELD1; } - if (byte1 != 0x80 || byte2 != 0x80) { - cea608_field1[(*cea608_field1_len)++] = byte1; - cea608_field1[(*cea608_field1_len)++] = byte2; - } + cea608_field1[(*cea608_field1_len)++] = byte1; + cea608_field1[(*cea608_field1_len)++] = byte2; } } else if (cc_type == 0x01) { if (!cc_valid) @@ -397,10 +395,8 @@ cc_data_extract_cea608 (const guint8 * cc_data, guint cc_data_len, *cea608_field2_len + 2); return CC_DATA_EXTRACT_TOO_MANY_FIELD2; } - if (byte1 != 0x80 || byte2 != 0x80) { - cea608_field2[(*cea608_field2_len)++] = byte1; - cea608_field2[(*cea608_field2_len)++] = byte2; - } + cea608_field2[(*cea608_field2_len)++] = byte1; + cea608_field2[(*cea608_field2_len)++] = byte2; } } else { /* all cea608 packets must be at the beginning of a cc_data */ diff --git a/subprojects/gst-plugins-bad/tests/check/elements/ccconverter.c b/subprojects/gst-plugins-bad/tests/check/elements/ccconverter.c index 36b4c7e83a..d74fccb4fe 100644 --- a/subprojects/gst-plugins-bad/tests/check/elements/ccconverter.c +++ b/subprojects/gst-plugins-bad/tests/check/elements/ccconverter.c @@ -458,10 +458,10 @@ GST_START_TEST (convert_cea708_cc_data_cea708_cdp) { const guint8 in[] = { 0xfc, 0x80, 0x80, 0xfe, 0x80, 0x80 }; const guint8 out[] = - { 0x96, 0x69, 0x2b, 0x8f, 0x43, 0x00, 0x00, 0x72, 0xea, 0xf8, 0x00, 0x00, + { 0x96, 0x69, 0x2b, 0x8f, 0x43, 0x00, 0x00, 0x72, 0xea, 0xfc, 0x80, 0x80, 0xfe, 0x80, 0x80, 0xfa, 0x00, 0x00, 0xfa, 0x00, 0x00, 0xfa, 0x00, 0x00, 0xfa, 0x00, 0x00, 0xfa, 0x00, 0x00, 0xfa, 0x00, 0x00, 0xfa, 0x00, 0x00, - 0xfa, 0x00, 0x00, 0x74, 0x00, 0x00, 0x6e + 0xfa, 0x00, 0x00, 0x74, 0x00, 0x00, 0x6a }; check_conversion (in, sizeof (in), out, sizeof (out), "closedcaption/x-cea-708,format=(string)cc_data,framerate=(fraction)60/1", @@ -512,7 +512,7 @@ GST_START_TEST (convert_cea708_cdp_cea708_cc_data) { 0x96, 0x69, 0x13, 0x5f, 0x43, 0x00, 0x00, 0x72, 0xe2, 0xfc, 0x80, 0x80, 0xfd, 0x80, 0x80, 0x74, 0x00, 0x00, 0x8a }; - const guint8 out[] = { 0xf8, 0x00, 0x00, 0xf9, 0x00, 0x00 }; + const guint8 out[] = { 0xfc, 0x80, 0x80, 0xfd, 0x80, 0x80 }; check_conversion_tc_passthrough (in, sizeof (in), out, sizeof (out), "closedcaption/x-cea-708,format=(string)cdp,framerate=30/1", "closedcaption/x-cea-708,format=(string)cc_data"); @@ -813,21 +813,21 @@ GST_START_TEST (convert_cea708_cdp_cea708_cdp_from_drop_frame_scaling) const guint8 out1[] = { 0x96, 0x69, 0x4e, 0x5f, 0xc3, 0x00, 0x00, 0x71, 0xc0, 0x81, 0x59, 0x29, - 0x72, 0xf4, 0xf8, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xfa, 0x00, 0x00, 0xfa, + 0x72, 0xf4, 0xfc, 0x80, 0x80, 0xf9, 0x00, 0x00, 0xfa, 0x00, 0x00, 0xfa, 0x00, 0x00, 0xfa, 0x00, 0x00, 0xfa, 0x00, 0x00, 0xfa, 0x00, 0x00, 0xfa, 0x00, 0x00, 0xfa, 0x00, 0x00, 0xfa, 0x00, 0x00, 0xfa, 0x00, 0x00, 0xfa, 0x00, 0x00, 0xfa, 0x00, 0x00, 0xfa, 0x00, 0x00, 0xfa, 0x00, 0x00, 0xfa, 0x00, 0x00, 0xfa, 0x00, 0x00, 0xfa, 0x00, 0x00, 0xfa, 0x00, 0x00, 0xfa, - 0x00, 0x00, 0x74, 0x00, 0x00, 0xfe + 0x00, 0x00, 0x74, 0x00, 0x00, 0xfa }; const guint8 out2[] = { 0x96, 0x69, 0x4e, 0x5f, 0xc3, 0x00, 0x01, 0x71, 0xc0, 0x82, 0x00, 0x00, - 0x72, 0xf4, 0xf8, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xfa, 0x00, 0x00, 0xfa, + 0x72, 0xf4, 0xfc, 0x80, 0x80, 0xf9, 0x00, 0x00, 0xfa, 0x00, 0x00, 0xfa, 0x00, 0x00, 0xfa, 0x00, 0x00, 0xfa, 0x00, 0x00, 0xfa, 0x00, 0x00, 0xfa, 0x00, 0x00, 0xfa, 0x00, 0x00, 0xfa, 0x00, 0x00, 0xfa, 0x00, 0x00, 0xfa, 0x00, 0x00, 0xfa, 0x00, 0x00, 0xfa, 0x00, 0x00, 0xfa, 0x00, 0x00, 0xfa, 0x00, 0x00, 0xfa, 0x00, 0x00, 0xfa, 0x00, 0x00, 0xfa, 0x00, 0x00, 0xfa, - 0x00, 0x00, 0x74, 0x00, 0x01, 0x7d + 0x00, 0x00, 0x74, 0x00, 0x01, 0x79 }; const guint8 *out[] = { out1, out2 }; guint out_len[] = { sizeof (out1), sizeof (out2) }; @@ -1102,7 +1102,7 @@ GST_START_TEST (convert_cea708_cdp_cea708_cc_data_double_input_data) * buffer */ const guint8 out1[] = { 0xfc, 0x81, 0x82, }; const guint8 out2[] = { 0xfd, 0x83, 0x84, }; - const guint8 out3[] = { 0xfc, 0x85, 0x86, }; + const guint8 out3[] = { 0xfc, 0x80, 0x80, }; const guint8 *out[] = { out1, out2, out3, }; guint out_len[] = { sizeof (out1), sizeof (out2), sizeof (out3), }; check_conversion_multiple (G_N_ELEMENTS (in_len), in, in_len,