oggstream: Fix default granuleshift usage
authorEdward Hervey <edward@centricular.com>
Sat, 4 Nov 2017 10:29:52 +0000 (11:29 +0100)
committerEdward Hervey <bilboed@bilboed.com>
Sat, 4 Nov 2017 10:50:13 +0000 (11:50 +0100)
For stream mappers that don't set a specific granuleshift, it will
have the default value of -1.

Protect the code for that and return the granule value as-is

ext/ogg/gstoggstream.c

index b4ee557..cc59024 100644 (file)
@@ -311,7 +311,7 @@ granulepos_to_granule_default (GstOggStream * pad, gint64 granulepos)
 {
   gint64 keyindex, keyoffset;
 
-  if (pad->granuleshift != 0) {
+  if (pad->granuleshift != 0 && pad->granuleshift != -1) {
     keyindex = granulepos >> pad->granuleshift;
     keyoffset = granulepos - (keyindex << pad->granuleshift);
     return keyindex + keyoffset;
@@ -327,7 +327,7 @@ granule_to_granulepos_default (GstOggStream * pad, gint64 granule,
 {
   gint64 keyoffset;
 
-  if (pad->granuleshift != 0) {
+  if (pad->granuleshift != 0 && pad->granuleshift != -1) {
     /* If we don't know where the previous keyframe is yet, assume it is
        at 0 or 1, depending on bitstream version. If nothing else, this
        avoids getting negative granpos back. */