[xiph-commits] r17562 - trunk/vorbis/lib
xiphmont at svn.xiph.org
xiphmont at svn.xiph.org
Sat Oct 23 21:50:46 PDT 2010
Author: xiphmont
Date: 2010-10-23 21:50:46 -0700 (Sat, 23 Oct 2010)
New Revision: 17562
Modified:
trunk/vorbis/lib/info.c
trunk/vorbis/lib/vorbisfile.c
Log:
Commit change to libvorbis that returns correct timestamp for granule
positions with high bit set.
Make two 'better safe than sorry' changes in vorbisfile that clamp
pcmoffsets entries to being strictly >=0.
Modified: trunk/vorbis/lib/info.c
===================================================================
--- trunk/vorbis/lib/info.c 2010-10-23 10:34:24 UTC (rev 17561)
+++ trunk/vorbis/lib/info.c 2010-10-24 04:50:46 UTC (rev 17562)
@@ -645,9 +645,18 @@
}
double vorbis_granule_time(vorbis_dsp_state *v,ogg_int64_t granulepos){
- if(granulepos>=0)
+ if(granulepos == -1) return -1;
+
+ /* We're not guaranteed a 64 bit unsigned type everywhere, so we
+ have to put the unsigned granpo in a signed type. */
+ if(granulepos>=0){
return((double)granulepos/v->vi->rate);
- return(-1);
+ }else{
+ ogg_int64_t granuleoff=0xffffffff;
+ granuleoff<<=31;
+ granuleoff|=0x7ffffffff;
+ return(((double)granulepos+2+granuleoff+granuleoff)/v->vi->rate);
+ }
}
const char *vorbis_version_string(void){
Modified: trunk/vorbis/lib/vorbisfile.c
===================================================================
--- trunk/vorbis/lib/vorbisfile.c 2010-10-23 10:34:24 UTC (rev 17561)
+++ trunk/vorbis/lib/vorbisfile.c 2010-10-24 04:50:46 UTC (rev 17562)
@@ -451,8 +451,9 @@
}
}
- /* less than zero? This is a stream with samples trimmed off
- the beginning, a normal occurrence; set the offset to zero */
+ /* less than zero? Either a corrupt file or a stream with samples
+ trimmed off the beginning, a normal occurrence; in both cases set
+ the offset to zero */
if(accumulated<0)accumulated=0;
return accumulated;
@@ -513,7 +514,7 @@
vf->offsets[m+1]=end;
vf->offsets[m]=begin;
- vf->pcmlengths[m*2+1]=endgran;
+ vf->pcmlengths[m*2+1]=(endgran<0?0:endgran);
}else{
@@ -590,7 +591,7 @@
vf->pcmlengths[m*2+1]=searchgran;
vf->pcmlengths[m*2+2]=pcmoffset;
vf->pcmlengths[m*2+3]-=pcmoffset;
-
+ if(vf->pcmlengths[m*2+3]<0)vf->pcmlengths[m*2+3]=0;
}
return(0);
}
@@ -649,6 +650,7 @@
vf->dataoffsets[0]=dataoffset;
vf->pcmlengths[0]=pcmoffset;
vf->pcmlengths[1]-=pcmoffset;
+ if(vf->pcmlengths[1]<0)vf->pcmlengths[1]=0;
return(ov_raw_seek(vf,dataoffset));
}
More information about the commits
mailing list