From caef38a849c081eb52944d676b0d83a1692a8870 Mon Sep 17 00:00:00 2001 From: Edward Hervey Date: Sat, 4 Nov 2017 11:29:52 +0100 Subject: oggstream: Fix default granuleshift usage 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 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ext/ogg/gstoggstream.c b/ext/ogg/gstoggstream.c index c24fa2bc9..5577ef39c 100644 --- a/ext/ogg/gstoggstream.c +++ b/ext/ogg/gstoggstream.c @@ -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. */ -- cgit v1.2.1