From: Monty Date: Thu, 9 Apr 2009 05:52:38 +0000 (+0000) Subject: Add an optimization case to _get_prev_page that avoids a redundant seek/resync/reread... X-Git-Tag: v1.3.3~164 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=eaa6e6ebc90dec4d4cd837e1ba787aa87b3e8c70;p=platform%2Fupstream%2Flibvorbis.git Add an optimization case to _get_prev_page that avoids a redundant seek/resync/reread in the common seek case. svn path=/trunk/vorbis/; revision=15925 --- diff --git a/lib/vorbisfile.c b/lib/vorbisfile.c index 08a55f3..000a7f0 100644 --- a/lib/vorbisfile.c +++ b/lib/vorbisfile.c @@ -154,6 +154,7 @@ static ogg_int64_t _get_prev_page(OggVorbis_File *vf,ogg_page *og){ if(ret)return(ret); while(vf->offsetoffset); if(ret==OV_EREAD)return(OV_EREAD); if(ret<0){ @@ -164,14 +165,18 @@ static ogg_int64_t _get_prev_page(OggVorbis_File *vf,ogg_page *og){ } } - /* we have the offset. Actually snork and hold the page now */ - ret=_seek_helper(vf,offset); - if(ret)return(ret); + /* In a fully compliant, non-multiplexed stream, we'll still be + holding the last page. In multiplexed (or noncompliant streams), + we may need to re-read the last page we saw */ + if(og->header_len==0){ + ret=_seek_helper(vf,offset); + if(ret)return(ret); - ret=_get_next_page(vf,og,CHUNKSIZE); - if(ret<0) - /* this shouldn't be possible */ - return(OV_EFAULT); + ret=_get_next_page(vf,og,CHUNKSIZE); + if(ret<0) + /* this shouldn't be possible */ + return(OV_EFAULT); + } return(offset); }