ccconverter: fix overflow when not doing framerate conversion
authorMathieu Duponchelle <mathieu@centricular.com>
Thu, 12 Aug 2021 18:39:24 +0000 (20:39 +0200)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Fri, 13 Aug 2021 03:37:28 +0000 (03:37 +0000)
When converting from one framerate to another, counters are
reset periodically, however when not converting they never are
and can_genearte_output ends up making overflow-prone calculations
with large values for input_frames and output_frames.

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

ext/closedcaption/gstccconverter.c

index c7a3ef5..08a1e7f 100644 (file)
@@ -884,6 +884,12 @@ fit_and_scale_cc_data (GstCCConverter * self,
     if (tc && tc->config.fps_n != 0)
       interpolate_time_code_with_framerate (self, tc, out_fps_entry->fps_n,
           out_fps_entry->fps_d, 1, 1, &self->current_output_timecode);
+
+    self->scratch_ccp_len = 0;
+    self->scratch_cea608_1_len = 0;
+    self->scratch_cea608_2_len = 0;
+    self->input_frames = 0;
+    self->output_frames = 0;
   } else {
     int input_frame_n, input_frame_d, output_frame_n, output_frame_d;
     int output_time_cmp, scale_n, scale_d, rate_cmp;