diff options
author | Sebastian Dröge <sebastian@centricular.com> | 2019-12-03 15:35:57 +0200 |
---|---|---|
committer | Tim-Philipp Müller <tim@centricular.com> | 2019-12-06 11:27:12 +0000 |
commit | 9fb5c5f466fb707931bf783d9518c661c53f334e (patch) | |
tree | 08743063e7090508fbc186108925dbfddc50c82b | |
parent | a6f26408f74a60d02ce6b4f0daee392ce847055f (diff) | |
download | gstreamer-plugins-bad-9fb5c5f466fb707931bf783d9518c661c53f334e.tar.gz |
interlace: Increment phase_index before checking if we're at the end of the phase
Incrementing it afterwards will always have to phase_index >= 1 and we
will never be at the beginning (0) of the phase again, and thus never
reset timestamp tracking accordingly.
This was broken in bea13ef43b719aad96e28766cd4d23652a891a20 in 2010, and
causes interlace to run into integer overflows after 2^31 frames or
about 5 hours at 29.97fps. Due to usage of wrong types for the integers
this then causes negative numbers to be used in calculations and all
calculations spectacularly fail, leading to all following buffers to
have the timestamp of the first buffer minus one nanosecond.
-rw-r--r-- | gst/interlace/gstinterlace.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/gst/interlace/gstinterlace.c b/gst/interlace/gstinterlace.c index e0ff1aa4b..8121eec01 100644 --- a/gst/interlace/gstinterlace.c +++ b/gst/interlace/gstinterlace.c @@ -899,13 +899,13 @@ gst_interlace_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer) interlace->fields_since_timebase = 0; } + current_fields = format->n_fields[interlace->phase_index]; + /* increment the phase index */ + interlace->phase_index++; if (!format->n_fields[interlace->phase_index]) { interlace->phase_index = 0; } - current_fields = format->n_fields[interlace->phase_index]; - /* increment the phase index */ - interlace->phase_index++; GST_DEBUG ("incoming buffer assigned %d fields", current_fields); num_fields = interlace->stored_fields + current_fields; |