mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-08 16:35:40 +00:00
ccutils: generate valid padding in field 1 when needing to generate field 2
Fixes CC in Field 2 but not in Field 1 errors. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4490>
This commit is contained in:
parent
4710f45e65
commit
262be30b6f
2 changed files with 43 additions and 3 deletions
|
@ -888,7 +888,18 @@ cc_buffer_take_cc_data (CCBuffer * buf,
|
|||
cea608_1_i += 2;
|
||||
buf->last_cea608_written_was_field1 = TRUE;
|
||||
} else if (cea608_1_i < write_cea608_1_size + field1_padding) {
|
||||
cc_data[out_i++] = 0xf8;
|
||||
GST_TRACE_OBJECT (buf,
|
||||
"write field2:%u field2_i:%u, cea608-2 buf len:%u",
|
||||
write_cea608_2_size, cea608_2_i, buf->cea608_2->len);
|
||||
if (cea608_2_i < write_cea608_2_size
|
||||
|| buf->cea608_2->len > write_cea608_2_size) {
|
||||
/* if we are writing field 2, then we have to write valid field 1 */
|
||||
GST_TRACE_OBJECT (buf, "writing valid field1 padding because "
|
||||
"we need to write valid field2");
|
||||
cc_data[out_i++] = 0xfc;
|
||||
} else {
|
||||
cc_data[out_i++] = 0xf8;
|
||||
}
|
||||
cc_data[out_i++] = 0x80;
|
||||
cc_data[out_i++] = 0x80;
|
||||
cea608_1_i += 2;
|
||||
|
|
|
@ -1014,13 +1014,13 @@ GST_START_TEST (convert_cea608_raw_cea708_cdp_field_one)
|
|||
{
|
||||
const guint8 in[] = { 0x81, 0x82 };
|
||||
const guint8 out[] =
|
||||
{ 0x96, 0x69, 0x49, 0x5f, 0x43, 0x00, 0x00, 0x72, 0xf4, 0xf8, 0x80, 0x80,
|
||||
{ 0x96, 0x69, 0x49, 0x5f, 0x43, 0x00, 0x00, 0x72, 0xf4, 0xfc, 0x80, 0x80,
|
||||
0xfd, 0x81, 0x82, 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,
|
||||
0xb0
|
||||
0xac
|
||||
};
|
||||
|
||||
check_conversion (in, sizeof (in), out, sizeof (out),
|
||||
|
@ -1257,6 +1257,34 @@ GST_START_TEST (convert_cea708_cc_data_cea708_cdp_field1_overflow)
|
|||
|
||||
GST_END_TEST;
|
||||
|
||||
GST_START_TEST (convert_cea608_raw_field1_cea708_cdp_60fps)
|
||||
{
|
||||
const guint8 in1[] = { 0x81, 0x82 };
|
||||
const guint8 *in[] = { in1 };
|
||||
guint in_len[] = { sizeof (in1) };
|
||||
const guint8 out1[] =
|
||||
{ 0x96, 0x69, 0x2b, 0x8f, 0x43, 0x00, 0x00, 0x72, 0xea, 0xfc, 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,
|
||||
0xfa, 0x00, 0x00, 0x74, 0x00, 0x00, 0x6e,
|
||||
};
|
||||
const guint8 out2[] =
|
||||
{ 0x96, 0x69, 0x2b, 0x8f, 0x43, 0x00, 0x01, 0x72, 0xea, 0xfd, 0x81, 0x82,
|
||||
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, 0x68,
|
||||
};
|
||||
const guint8 *out[] = { out1, out2 };
|
||||
guint out_len[] = { sizeof (out1), sizeof (out2) };
|
||||
check_conversion_multiple (1, in, in_len, G_N_ELEMENTS (out_len), out,
|
||||
out_len,
|
||||
"closedcaption/x-cea-608,format=(string)raw,framerate=30/1,field=1",
|
||||
"closedcaption/x-cea-708,format=(string)cdp,framerate=60/1", NULL, NULL,
|
||||
0);
|
||||
}
|
||||
|
||||
GST_END_TEST;
|
||||
|
||||
static Suite *
|
||||
ccextractor_suite (void)
|
||||
{
|
||||
|
@ -1303,6 +1331,7 @@ ccextractor_suite (void)
|
|||
tcase_add_test (tc, convert_cea708_cc_data_cea608_raw_field_one);
|
||||
tcase_add_test (tc, convert_cea708_cdp_cea608_raw_field_one);
|
||||
tcase_add_test (tc, convert_cea608_raw_cea608_raw_field_one);
|
||||
tcase_add_test (tc, convert_cea608_raw_field1_cea708_cdp_60fps);
|
||||
|
||||
return s;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue