[xiph-commits] r18497 - trunk/vorbis-tools/ogginfo

tterribe at svn.xiph.org tterribe at svn.xiph.org
Thu Aug 2 09:37:02 PDT 2012


Author: tterribe
Date: 2012-08-02 09:37:02 -0700 (Thu, 02 Aug 2012)
New Revision: 18497

Modified:
   trunk/vorbis-tools/ogginfo/ogginfo2.c
Log:
Fix duration reporting for Theora streams.

ogginfo wasn't correcting for the granule position difference
 between 3.2.0 and 3.2.1 streams.
It was always assuming the 3.2.1 behavior, but since this code
 hasn't been changed since 2005 and the 3.2.1 bitstream bump was
 done in 2007, it was simply wrong before.


Modified: trunk/vorbis-tools/ogginfo/ogginfo2.c
===================================================================
--- trunk/vorbis-tools/ogginfo/ogginfo2.c	2012-08-02 06:44:11 UTC (rev 18496)
+++ trunk/vorbis-tools/ogginfo/ogginfo2.c	2012-08-02 16:37:02 UTC (rev 18497)
@@ -506,11 +506,18 @@
     misc_theora_info *inf = stream->data;
     long minutes, seconds, milliseconds;
     double bitrate, time;
+    int new_gp;
+    new_gp = inf->ti.version_major > 3
+       || (inf->ti.version_major == 3 && (inf->ti.version_minor > 2
+       || (inf->ti.version_minor == 2 && inf->ti.version_subminor > 0)));
 
     /* This should be lastgranulepos - startgranulepos, or something like that*/
     ogg_int64_t iframe=inf->lastgranulepos>>inf->ti.granule_shift;
     ogg_int64_t pframe=inf->lastgranulepos-(iframe<<inf->ti.granule_shift);
-    time = (double)(iframe+pframe) /
+    /* The granule position starts at 0 for stream version 3.2.0, but starts at
+       1 for version 3.2.1 and above. In the former case, we need to add one
+       to the final granule position to get the frame count. */
+    time = (double)(iframe+pframe+!new_gp) /
 	((float)inf->ti.fps_numerator/(float)inf->ti.fps_denominator);
     minutes = (long)time / 60;
     seconds = (long)time - minutes*60;



More information about the commits mailing list