[FFmpeg-cvslog] ogg: rewrite first timestamp reading code.
Michael Niedermayer
git at videolan.org
Mon May 14 14:16:27 CEST 2012
ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Mon May 14 14:07:09 2012 +0200| [8443082db68daa044b85c2b91368b460990c7677] | committer: Michael Niedermayer
ogg: rewrite first timestamp reading code.
this is simpler and closer to how timestamps are found for seeking.
Fixes Ticket1186
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=8443082db68daa044b85c2b91368b460990c7677
---
libavformat/oggdec.c | 21 ++++++++++-----------
1 files changed, 10 insertions(+), 11 deletions(-)
diff --git a/libavformat/oggdec.c b/libavformat/oggdec.c
index 17b9673..6f3a565 100644
--- a/libavformat/oggdec.c
+++ b/libavformat/oggdec.c
@@ -55,6 +55,8 @@ static const struct ogg_codec * const ogg_codecs[] = {
NULL
};
+static int64_t ogg_calc_pts(AVFormatContext *s, int idx, int64_t *dts);
+
//FIXME We could avoid some structure duplication
static int ogg_save(AVFormatContext *s)
{
@@ -521,19 +523,16 @@ static int ogg_get_length(AVFormatContext *s)
ogg_save (s);
avio_seek (s->pb, s->data_offset, SEEK_SET);
- while (!ogg_read_page (s, &i)){
- 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){
- 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--;
- }
+ ogg_reset(s);
+ while (!ogg_packet(s, &i, NULL, NULL, NULL)) {
+ int64_t pts = ogg_calc_pts(s, i, NULL);
+ if (pts != AV_NOPTS_VALUE && s->streams[i]->start_time == AV_NOPTS_VALUE && !ogg->streams[i].got_start){
+ s->streams[i]->duration -= pts;
+ ogg->streams[i].got_start= 1;
+ streams_left--;
+ }
if(streams_left<=0)
break;
- }
}
ogg_restore (s, 0);
More information about the ffmpeg-cvslog
mailing list