Commit b18c9f1e authored by Michael Niedermayer's avatar Michael Niedermayer

oggtheora: Port changes from oggvorbis timestamp handling.

Signed-off-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parent fe5c5bcc
...@@ -162,27 +162,22 @@ static int theora_packet(AVFormatContext *s, int idx) ...@@ -162,27 +162,22 @@ static int theora_packet(AVFormatContext *s, int idx)
the total duration to the page granule to find the encoder delay and the total duration to the page granule to find the encoder delay and
set the first timestamp */ set the first timestamp */
if (!os->lastpts) { if ((!os->lastpts || os->lastpts == AV_NOPTS_VALUE) && !(os->flags & OGG_FLAG_EOS)) {
int seg; int seg;
uint8_t *last_pkt = os->buf + os->pstart;
uint8_t *next_pkt = last_pkt; duration = 1;
int first_duration = 0; for (seg = os->segp; seg < os->nsegs; seg++) {
if (os->segments[seg] < 255)
duration = 0; duration ++;
for (seg = 0; seg < os->nsegs; seg++) {
if (os->segments[seg] < 255) {
if (!duration)
first_duration = 1;
duration++;
last_pkt = next_pkt + os->segments[seg];
}
next_pkt += os->segments[seg];
} }
os->lastpts = os->lastdts = theora_gptopts(s, idx, os->granule, NULL) - duration; os->lastpts = os->lastdts = theora_gptopts(s, idx, os->granule, NULL) - duration;
s->streams[idx]->start_time = os->lastpts + first_duration; if(s->streams[idx]->start_time == AV_NOPTS_VALUE) {
s->streams[idx]->start_time = os->lastpts;
if (s->streams[idx]->duration) if (s->streams[idx]->duration)
s->streams[idx]->duration -= s->streams[idx]->start_time; s->streams[idx]->duration -= s->streams[idx]->start_time;
} }
}
/* parse packet duration */ /* parse packet duration */
if (os->psize > 0) { if (os->psize > 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