Commit 8443082d authored by Michael Niedermayer's avatar 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: 's avatarMichael Niedermayer <michaelni@gmx.at>
parent 5931c754
...@@ -55,6 +55,8 @@ static const struct ogg_codec * const ogg_codecs[] = { ...@@ -55,6 +55,8 @@ static const struct ogg_codec * const ogg_codecs[] = {
NULL NULL
}; };
static int64_t ogg_calc_pts(AVFormatContext *s, int idx, int64_t *dts);
//FIXME We could avoid some structure duplication //FIXME We could avoid some structure duplication
static int ogg_save(AVFormatContext *s) static int ogg_save(AVFormatContext *s)
{ {
...@@ -521,19 +523,16 @@ static int ogg_get_length(AVFormatContext *s) ...@@ -521,19 +523,16 @@ static int ogg_get_length(AVFormatContext *s)
ogg_save (s); ogg_save (s);
avio_seek (s->pb, s->data_offset, SEEK_SET); avio_seek (s->pb, s->data_offset, SEEK_SET);
while (!ogg_read_page (s, &i)){ ogg_reset(s);
if (ogg->streams[i].granule != -1 && ogg->streams[i].granule != 0 && while (!ogg_packet(s, &i, NULL, NULL, NULL)) {
ogg->streams[i].codec) { int64_t pts = ogg_calc_pts(s, i, NULL);
if(s->streams[i]->duration && s->streams[i]->start_time == AV_NOPTS_VALUE && !ogg->streams[i].got_start){ if (pts != AV_NOPTS_VALUE && 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); s->streams[i]->duration -= pts;
if(av_rescale_q(start, s->streams[i]->time_base, AV_TIME_BASE_Q) > AV_TIME_BASE) ogg->streams[i].got_start= 1;
s->streams[i]->duration -= start; streams_left--;
ogg->streams[i].got_start= 1; }
streams_left--;
}
if(streams_left<=0) if(streams_left<=0)
break; break;
}
} }
ogg_restore (s, 0); ogg_restore (s, 0);
......
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