Commit e14dc4bc authored by Timothy B. Terriberry's avatar Timothy B. Terriberry

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.

svn path=/trunk/vorbis-tools/; revision=18497
parent 89891771
...@@ -506,11 +506,18 @@ static void theora_end(stream_processor *stream) ...@@ -506,11 +506,18 @@ static void theora_end(stream_processor *stream)
misc_theora_info *inf = stream->data; misc_theora_info *inf = stream->data;
long minutes, seconds, milliseconds; long minutes, seconds, milliseconds;
double bitrate, time; 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*/ /* This should be lastgranulepos - startgranulepos, or something like that*/
ogg_int64_t iframe=inf->lastgranulepos>>inf->ti.granule_shift; ogg_int64_t iframe=inf->lastgranulepos>>inf->ti.granule_shift;
ogg_int64_t pframe=inf->lastgranulepos-(iframe<<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); ((float)inf->ti.fps_numerator/(float)inf->ti.fps_denominator);
minutes = (long)time / 60; minutes = (long)time / 60;
seconds = (long)time - minutes*60; seconds = (long)time - minutes*60;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment