oggdemux: reject opus streams with negative start time
authorVincent Penquerc'h <vincent.penquerch@collabora.co.uk>
Wed, 6 Jun 2012 16:42:36 +0000 (17:42 +0100)
committerVincent Penquerc'h <vincent.penquerch@collabora.co.uk>
Wed, 6 Jun 2012 16:49:13 +0000 (17:49 +0100)
This is used by Vorbis for sample accurate clipping, but this is
deemed an invalid stream by the opus spec.

ext/ogg/gstoggdemux.c

index 5f10263f227d5bae3408113529b2a263f5f6e9cb..031c25d860f687789c16d5758afe749f060aa47f 100644 (file)
@@ -922,10 +922,16 @@ gst_ogg_pad_submit_packet (GstOggPad * pad, ogg_packet * packet)
           return GST_FLOW_ERROR;
         }
 
-        if (granule > pad->map.accumulated_granule)
+        if (granule >= pad->map.accumulated_granule)
           start_granule = granule - pad->map.accumulated_granule;
-        else
-          start_granule = 0;
+        else {
+          if (pad->map.forbid_start_clamping) {
+            GST_ERROR_OBJECT (ogg, "Start of stream maps to negative time");
+            return GST_FLOW_ERROR;
+          } else {
+            start_granule = 0;
+          }
+        }
 
         pad->start_time = gst_ogg_stream_granule_to_time (&pad->map,
             start_granule);