oggdec: subtract time of first packet only from duration when it is significant

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>
This commit is contained in:
Michael Niedermayer 2011-08-24 23:20:09 +02:00
parent d2cab951e3
commit 7e7012d0b4
1 changed files with 3 additions and 2 deletions

View 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--;
}