aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2011-08-24 23:13:57 +0200
committerMichael Niedermayer <michaelni@gmx.at>2011-08-24 23:13:57 +0200
commitd2cab951e32d7688d41f475cd55475772c70dd39 (patch)
treed7f159357e1835b90c6d0da7a7560efc0bd9eae5
parentbd4640375e24fc0aa8846d9ee42cebe3c1fa9c12 (diff)
downloadffmpeg-d2cab951e32d7688d41f475cd55475772c70dd39.tar.gz
oggdec: Make sure start time correction is applied once to each stream
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r--libavformat/oggdec.c20
-rw-r--r--libavformat/oggdec.h1
2 files changed, 17 insertions, 4 deletions
diff --git a/libavformat/oggdec.c b/libavformat/oggdec.c
index cd5592208a..3d7c87f427 100644
--- a/libavformat/oggdec.c
+++ b/libavformat/oggdec.c
@@ -452,6 +452,7 @@ static int ogg_get_length(AVFormatContext *s)
struct ogg *ogg = s->priv_data;
int i;
int64_t size, end;
+ int streams_left=0;
if(!s->pb->seekable)
return 0;
@@ -473,8 +474,14 @@ static int ogg_get_length(AVFormatContext *s)
ogg->streams[i].codec) {
s->streams[i]->duration =
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;
+ 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)
while (!ogg_read_page (s, &i)){
if (ogg->streams[i].granule != -1 && ogg->streams[i].granule != 0 &&
ogg->streams[i].codec) {
- s->streams[i]->duration -=
- ogg_gptopts (s, i, ogg->streams[i].granule, NULL);
- break;
+ 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);
+ ogg->streams[i].got_start= 1;
+ streams_left--;
+ }
+ if(streams_left<=0)
+ break;
}
}
ogg_restore (s, 0);
diff --git a/libavformat/oggdec.h b/libavformat/oggdec.h
index 184a628622..7f5452f2b0 100644
--- a/libavformat/oggdec.h
+++ b/libavformat/oggdec.h
@@ -75,6 +75,7 @@ struct ogg_stream {
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 keyframe_seek;
+ int got_start;
void *private;
};