[Bug 785948] New: audioencoder: Integer overflows in timestamp/granulepos calculation code on discont

GStreamer (GNOME Bugzilla) bugzilla at gnome.org
Mon Aug 7 14:08:21 UTC 2017


https://bugzilla.gnome.org/show_bug.cgi?id=785948

            Bug ID: 785948
           Summary: audioencoder: Integer overflows in
                    timestamp/granulepos calculation code on discont
    Classification: Platform
           Product: GStreamer
           Version: unspecified
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: Normal
         Component: gst-plugins-base
          Assignee: gstreamer-bugs at lists.freedesktop.org
          Reporter: slomo at coaxion.net
        QA Contact: gstreamer-bugs at lists.freedesktop.org
                CC: mnauw at users.sourceforge.net
     GNOME version: ---

In gst_audio_encoder_chain() we calculate the difference "diff" between the
expected and actual timestamp.

> diff = GST_CLOCK_DIFF (next_ts, GST_BUFFER_TIMESTAMP (buffer));

This can sometimes be negative and that's not necessarily a problem.

Further below we shift the base_ts by that difference, and that's where things
go wrong:

>     if (discont) {
>       /* now re-sync ts */
>       priv->base_ts += diff;
>       gst_audio_encoder_set_base_gp (enc);
>       priv->discont |= discont;
>     }

If base_ts was 0 before (which it usually is), this would cause an integer
overflow and suddenly we have a huge timestamp.

There seem to be two potential solutions:
1) Make this an error
2) Store base_ts as a signed integer, and make sure that everything is handled
correctly with negative values everywhere where it is used


As a side-note, it would also make sense to add the "discont-wait" code from
e.g. audiobasesink or audiomixer here, to allow a bigger timestamp
discontinuity as long as it is not that big for a longer timespan.

-- 
You are receiving this mail because:
You are the QA Contact for the bug.
You are the assignee for the bug.


More information about the gstreamer-bugs mailing list