OSDN Git Service

oggdec: subtract time of first packet only from duration when it is significant
authorMichael Niedermayer <michaelni@gmx.at>
Wed, 24 Aug 2011 21:20:09 +0000 (23:20 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Wed, 24 Aug 2011 21:20:09 +0000 (23:20 +0200)
this fixes accuracy with normal ogg files while keeping support for ogg files
starting at times different from 0

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavformat/oggdec.c

index 3d7c87f..e8d4fc5 100644 (file)
@@ -493,8 +493,9 @@ static int ogg_get_length(AVFormatContext *s)
         if (ogg->streams[i].granule != -1 && ogg->streams[i].granule != 0 &&
             ogg->streams[i].codec) {
             if(s->streams[i]->duration && s->streams[i]->start_time == AV_NOPTS_VALUE && !ogg->streams[i].got_start){
-                s->streams[i]->duration -=
-                    ogg_gptopts (s, i, ogg->streams[i].granule, NULL);
+                int64_t start= ogg_gptopts (s, i, ogg->streams[i].granule, NULL);
+                if(av_rescale_q(start, s->streams[i]->time_base, AV_TIME_BASE_Q) > AV_TIME_BASE)
+                    s->streams[i]->duration -= start;
                 ogg->streams[i].got_start= 1;
                 streams_left--;
             }