Commit d2cab951 authored by Michael Niedermayer's avatar Michael Niedermayer

oggdec: Make sure start time correction is applied once to each stream

Signed-off-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parent bd464037
...@@ -452,6 +452,7 @@ static int ogg_get_length(AVFormatContext *s) ...@@ -452,6 +452,7 @@ static int ogg_get_length(AVFormatContext *s)
struct ogg *ogg = s->priv_data; struct ogg *ogg = s->priv_data;
int i; int i;
int64_t size, end; int64_t size, end;
int streams_left=0;
if(!s->pb->seekable) if(!s->pb->seekable)
return 0; return 0;
...@@ -473,8 +474,14 @@ static int ogg_get_length(AVFormatContext *s) ...@@ -473,8 +474,14 @@ static int ogg_get_length(AVFormatContext *s)
ogg->streams[i].codec) { ogg->streams[i].codec) {
s->streams[i]->duration = s->streams[i]->duration =
ogg_gptopts (s, i, ogg->streams[i].granule, NULL); ogg_gptopts (s, i, ogg->streams[i].granule, NULL);
if (s->streams[i]->start_time != AV_NOPTS_VALUE) if (s->streams[i]->start_time != AV_NOPTS_VALUE){
s->streams[i]->duration -= s->streams[i]->start_time; s->streams[i]->duration -= s->streams[i]->start_time;
streams_left-= (ogg->streams[i].got_start==-1);
ogg->streams[i].got_start= 1;
}else if(!ogg->streams[i].got_start){
ogg->streams[i].got_start= -1;
streams_left++;
}
} }
} }
...@@ -485,9 +492,14 @@ static int ogg_get_length(AVFormatContext *s) ...@@ -485,9 +492,14 @@ static int ogg_get_length(AVFormatContext *s)
while (!ogg_read_page (s, &i)){ while (!ogg_read_page (s, &i)){
if (ogg->streams[i].granule != -1 && ogg->streams[i].granule != 0 && if (ogg->streams[i].granule != -1 && ogg->streams[i].granule != 0 &&
ogg->streams[i].codec) { ogg->streams[i].codec) {
s->streams[i]->duration -= if(s->streams[i]->duration && s->streams[i]->start_time == AV_NOPTS_VALUE && !ogg->streams[i].got_start){
ogg_gptopts (s, i, ogg->streams[i].granule, NULL); s->streams[i]->duration -=
break; ogg_gptopts (s, i, ogg->streams[i].granule, NULL);
ogg->streams[i].got_start= 1;
streams_left--;
}
if(streams_left<=0)
break;
} }
} }
ogg_restore (s, 0); ogg_restore (s, 0);
......
...@@ -75,6 +75,7 @@ struct ogg_stream { ...@@ -75,6 +75,7 @@ struct ogg_stream {
int incomplete; ///< whether we're expecting a continuation in the next page int incomplete; ///< whether we're expecting a continuation in the next page
int page_end; ///< current packet is the last one completed in the page int page_end; ///< current packet is the last one completed in the page
int keyframe_seek; int keyframe_seek;
int got_start;
void *private; void *private;
}; };
......
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