mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-03 05:59:10 +00:00
cccombiner: fix output-padding=false for a cea608 field 1 only stream
If we have data that needs outputting but we have to output padding to meet the alternating field requirements of cea608, then output that padding anyway. Also includes a test Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4124>
This commit is contained in:
parent
2eab37f231
commit
be72fbc334
2 changed files with 112 additions and 2 deletions
|
@ -775,11 +775,18 @@ cc_buffer_get_out_sizes (CCBuffer * buf, const struct cdp_fps_entry *fps_entry,
|
|||
wrote_first = TRUE;
|
||||
}
|
||||
|
||||
// don't write padding if not requested
|
||||
if (!buf->output_padding && write_cea608_1_size == 0
|
||||
&& write_cea608_2_size == 0) {
|
||||
// however if we are producing data for a cdp that only has a single 608 field,
|
||||
// in order to keep processing data will still need to alternate fields and
|
||||
// produce the relevant padding data
|
||||
if (fps_entry->max_cea608_count != 1 || (extra_cea608_1 == 0
|
||||
&& extra_cea608_2 == 0)) {
|
||||
*field1_padding = 0;
|
||||
*field2_padding = 0;
|
||||
}
|
||||
}
|
||||
|
||||
GST_TRACE_OBJECT (buf, "allocated sizes ccp:%u, cea608-1:%u (pad:%u), "
|
||||
"cea608-2:%u (pad:%u)", write_ccp_size, write_cea608_1_size,
|
||||
|
|
|
@ -29,6 +29,8 @@
|
|||
#include <string.h>
|
||||
|
||||
static GstStaticCaps foo_bar_caps = GST_STATIC_CAPS ("foo/bar");
|
||||
static GstStaticCaps foo_bar_caps_60fps =
|
||||
GST_STATIC_CAPS ("foo/bar,framerate=60/1");
|
||||
static GstStaticCaps cea708_cc_data_caps =
|
||||
GST_STATIC_CAPS ("closedcaption/x-cea-708,format=(string) cc_data");
|
||||
|
||||
|
@ -191,6 +193,106 @@ GST_START_TEST (captions_and_eos)
|
|||
|
||||
GST_END_TEST;
|
||||
|
||||
GST_START_TEST (captions_no_output_padding_60fps_608_field1_only)
|
||||
{
|
||||
GstHarness *h, *h2;
|
||||
GstBuffer *outbuf;
|
||||
GstPad *caption_pad;
|
||||
GstCaps *caps;
|
||||
GstVideoCaptionMeta *meta;
|
||||
const guint8 cc_data[3] = { 0xfc, 0x20, 0x20 };
|
||||
int i = 0;
|
||||
|
||||
h = gst_harness_new_with_padnames ("cccombiner", "sink", "src");
|
||||
h2 = gst_harness_new_with_element (h->element, NULL, NULL);
|
||||
caption_pad = gst_element_request_pad_simple (h->element, "caption");
|
||||
gst_harness_add_element_sink_pad (h2, caption_pad);
|
||||
gst_object_unref (caption_pad);
|
||||
|
||||
g_object_set (h->element, "emit-signals", TRUE, NULL);
|
||||
g_signal_connect (h->element, "samples-selected",
|
||||
G_CALLBACK (samples_selected_cb), NULL);
|
||||
g_object_set (h->element, "output-padding", FALSE, NULL);
|
||||
|
||||
gst_element_set_state (h->element, GST_STATE_NULL);
|
||||
gst_element_set_state (h->element, GST_STATE_PLAYING);
|
||||
|
||||
gst_harness_set_src_caps_str (h, foo_bar_caps_60fps.string);
|
||||
gst_harness_set_src_caps_str (h2, cea708_cc_data_caps.string);
|
||||
|
||||
/* Push a buffer and caption buffer */
|
||||
for (i = 0; i < 8; i++) {
|
||||
GstBuffer *video_buf, *caption_buf = NULL;
|
||||
|
||||
video_buf = gst_buffer_new_and_alloc (128);
|
||||
GST_BUFFER_PTS (video_buf) = i * 40 * GST_MSECOND;
|
||||
GST_BUFFER_DURATION (video_buf) = 40 * GST_MSECOND;
|
||||
gst_harness_push (h, video_buf);
|
||||
|
||||
caption_buf = gst_buffer_new_and_alloc (3);
|
||||
gst_buffer_fill (caption_buf, 0, cc_data, 3);
|
||||
GST_BUFFER_PTS (caption_buf) = i * 40 * GST_MSECOND;
|
||||
GST_BUFFER_DURATION (caption_buf) = 40 * GST_MSECOND;
|
||||
gst_harness_push (h2, caption_buf);
|
||||
|
||||
/* Pull the previous output buffer */
|
||||
if (i > 0) {
|
||||
int j;
|
||||
outbuf = gst_harness_pull (h);
|
||||
fail_unless (outbuf != NULL);
|
||||
|
||||
meta = gst_buffer_get_video_caption_meta (outbuf);
|
||||
fail_unless (meta != NULL);
|
||||
fail_unless_equals_int (meta->caption_type,
|
||||
GST_VIDEO_CAPTION_TYPE_CEA708_RAW);
|
||||
fail_unless_equals_int (meta->size, 3);
|
||||
GST_MEMDUMP ("caption data", meta->data, meta->size);
|
||||
|
||||
for (j = 0; j < meta->size; j++) {
|
||||
if ((i % 2) == 1) {
|
||||
fail_unless_equals_int (meta->data[j], cc_data[j]);
|
||||
} else {
|
||||
int padding_field2[] = { 0xf9, 0x80, 0x80 };
|
||||
fail_unless_equals_int (meta->data[j], padding_field2[j]);
|
||||
}
|
||||
}
|
||||
|
||||
gst_buffer_unref (outbuf);
|
||||
}
|
||||
expected_video_buffer = video_buf;
|
||||
if (caption_buf)
|
||||
expected_caption_buffer = caption_buf;
|
||||
}
|
||||
|
||||
/* Push EOS on both pads get the second output buffer, we otherwise wait
|
||||
* in case there are further captions for the current video buffer */
|
||||
gst_harness_push_event (h, gst_event_new_eos ());
|
||||
gst_harness_push_event (h2, gst_event_new_eos ());
|
||||
|
||||
outbuf = gst_harness_pull (h);
|
||||
fail_unless (outbuf != NULL);
|
||||
|
||||
meta = gst_buffer_get_video_caption_meta (outbuf);
|
||||
fail_unless (meta != NULL);
|
||||
fail_unless_equals_int (meta->caption_type,
|
||||
GST_VIDEO_CAPTION_TYPE_CEA708_RAW);
|
||||
fail_unless_equals_int (meta->size, 3);
|
||||
|
||||
gst_buffer_unref (outbuf);
|
||||
|
||||
/* Caps should be equal to input caps */
|
||||
caps = gst_pad_get_current_caps (h->sinkpad);
|
||||
fail_unless (caps != NULL);
|
||||
fail_unless (gst_caps_can_intersect (caps,
|
||||
gst_static_caps_get (&foo_bar_caps)));
|
||||
gst_caps_unref (caps);
|
||||
|
||||
gst_harness_teardown (h);
|
||||
gst_harness_teardown (h2);
|
||||
}
|
||||
|
||||
GST_END_TEST;
|
||||
|
||||
static Suite *
|
||||
cccombiner_suite (void)
|
||||
{
|
||||
|
@ -201,6 +303,7 @@ cccombiner_suite (void)
|
|||
|
||||
tcase_add_test (tc, no_captions);
|
||||
tcase_add_test (tc, captions_and_eos);
|
||||
tcase_add_test (tc, captions_no_output_padding_60fps_608_field1_only);
|
||||
|
||||
return s;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue