Browse Source

Sega FILM: set dts and duration when demuxing

Reviewed-by: Kyle Swanson <k@ylo.ph>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
tags/n4.0
Misty De Meo Michael Niedermayer 7 years ago
parent
commit
d64183ea5d
1 changed files with 19 additions and 0 deletions
  1. +19
    -0
      libavformat/segafilm.c

+ 19
- 0
libavformat/segafilm.c View File

@@ -270,6 +270,8 @@ static int film_read_packet(AVFormatContext *s,
FilmDemuxContext *film = s->priv_data; FilmDemuxContext *film = s->priv_data;
AVIOContext *pb = s->pb; AVIOContext *pb = s->pb;
film_sample *sample; film_sample *sample;
film_sample *next_sample = NULL;
int next_sample_id;
int ret = 0; int ret = 0;


if (film->current_sample >= film->sample_count) if (film->current_sample >= film->sample_count)
@@ -277,6 +279,20 @@ static int film_read_packet(AVFormatContext *s,


sample = &film->sample_table[film->current_sample]; sample = &film->sample_table[film->current_sample];


/* Find the next sample from the same stream, assuming there is one;
* this is used to calculate the duration below */
next_sample_id = film->current_sample + 1;
while (next_sample == NULL) {
if (next_sample_id >= film->sample_count)
break;

next_sample = &film->sample_table[next_sample_id];
if (next_sample->stream != sample->stream) {
next_sample = NULL;
next_sample_id++;
}
}

/* position the stream (will probably be there anyway) */ /* position the stream (will probably be there anyway) */
avio_seek(pb, sample->sample_offset, SEEK_SET); avio_seek(pb, sample->sample_offset, SEEK_SET);


@@ -285,8 +301,11 @@ static int film_read_packet(AVFormatContext *s,
ret = AVERROR(EIO); ret = AVERROR(EIO);


pkt->stream_index = sample->stream; pkt->stream_index = sample->stream;
pkt->dts = sample->pts;
pkt->pts = sample->pts; pkt->pts = sample->pts;
pkt->flags |= sample->keyframe ? AV_PKT_FLAG_KEY : 0; pkt->flags |= sample->keyframe ? AV_PKT_FLAG_KEY : 0;
if (next_sample != NULL)
pkt->duration = next_sample->pts - sample->pts;


film->current_sample++; film->current_sample++;




Loading…
Cancel
Save