From b5e119bbccbf7e1e69e58c69317d3c0ad54bc233 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Tue, 17 Sep 2024 11:47:47 +0300 Subject: [PATCH] ccconverter: Don't override in_fps_entry when trying to take output This allows to handle CDP streams where the framerate is not provided by the caps and generally gives preference to the framerate inside the CDP packets over the one in the caps. Part-of: --- .../ext/closedcaption/gstccconverter.c | 20 ++++++++++--------- .../tests/check/elements/ccconverter.c | 2 +- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/subprojects/gst-plugins-bad/ext/closedcaption/gstccconverter.c b/subprojects/gst-plugins-bad/ext/closedcaption/gstccconverter.c index ceb6d3dbfc..b5158a1586 100644 --- a/subprojects/gst-plugins-bad/ext/closedcaption/gstccconverter.c +++ b/subprojects/gst-plugins-bad/ext/closedcaption/gstccconverter.c @@ -502,7 +502,7 @@ static void get_framerate_output_scale (GstCCConverter * self, const struct cdp_fps_entry *in_fps_entry, gint * scale_n, gint * scale_d) { - if (self->in_fps_n == 0 || self->out_fps_d == 0) { + if (in_fps_entry->fps_n == 0 || self->out_fps_d == 0) { *scale_n = 1; *scale_d = 1; return; @@ -590,24 +590,30 @@ can_take_buffer (GstCCConverter * self, int input_frame_n, input_frame_d, output_frame_n, output_frame_d; int output_time_cmp, scale_n, scale_d; + g_assert (out_fps_entry); + + if (!in_fps_entry || in_fps_entry->fps_n == 0) + in_fps_entry = cdp_fps_entry_from_fps (self->in_fps_n, self->in_fps_d); + g_assert (in_fps_entry); + /* TODO: handle input discont */ - if (self->in_fps_n == 0) { + if (in_fps_entry->fps_n == 0) { input_frame_n = self->input_frames; input_frame_d = 1; } else { /* compute the relative frame count for each */ - if (!gst_util_fraction_multiply (self->in_fps_d, self->in_fps_n, + if (!gst_util_fraction_multiply (in_fps_entry->fps_d, in_fps_entry->fps_n, self->input_frames, 1, &input_frame_n, &input_frame_d)) /* we should never overflow */ g_assert_not_reached (); } - if (self->in_fps_n == 0) { + if (in_fps_entry->fps_n == 0) { output_frame_n = self->output_frames; output_frame_d = 1; } else { - if (!gst_util_fraction_multiply (self->out_fps_d, self->out_fps_n, + if (!gst_util_fraction_multiply (out_fps_entry->fps_d, out_fps_entry->fps_n, self->output_frames, 1, &output_frame_n, &output_frame_d)) /* we should never overflow */ g_assert_not_reached (); @@ -621,10 +627,6 @@ can_take_buffer (GstCCConverter * self, self->input_frames = 0; } - in_fps_entry = cdp_fps_entry_from_fps (self->in_fps_n, self->in_fps_d); - if (!in_fps_entry || in_fps_entry->fps_n == 0) - g_assert_not_reached (); - /* compute the relative rates of the two framerates */ get_framerate_output_scale (self, in_fps_entry, &scale_n, &scale_d); diff --git a/subprojects/gst-plugins-bad/tests/check/elements/ccconverter.c b/subprojects/gst-plugins-bad/tests/check/elements/ccconverter.c index 3d7946cdf7..34d89642a9 100644 --- a/subprojects/gst-plugins-bad/tests/check/elements/ccconverter.c +++ b/subprojects/gst-plugins-bad/tests/check/elements/ccconverter.c @@ -524,7 +524,7 @@ GST_START_TEST (convert_cea708_cdp_cea708_cc_data_too_big) { /* tests that too large input is truncated */ const guint8 in[] = - { 0x96, 0x69, 0x4c, 0x8f, 0x43, 0x00, 0x00, 0x72, 0xf5, 0xfc, 0x81, 0x82, + { 0x96, 0x69, 0x4c, 0x5f, 0x43, 0x00, 0x00, 0x72, 0xf5, 0xfc, 0x81, 0x82, 0xfe, 0x80, 0x80, 0xfe, 0x80, 0x80, 0xfe, 0x80, 0x80, 0xfe, 0x80, 0x80, 0xfe, 0x80, 0x80, 0xfe, 0x80, 0x80, 0xfe, 0x80, 0x80, 0xfe, 0x80, 0x80, 0xfe, 0x80, 0x80, 0xfe, 0x80, 0x80, 0xfe, 0x80, 0x80, 0xfe, 0x80, 0x80,