Message ID | 20180321161444.68475-2-misty@brew.sh |
---|---|
State | Superseded |
Headers | show |
On Wed, Mar 21, 2018 at 09:14:44AM -0700, misty@brew.sh wrote: > From: Misty De Meo <mistydemeo@gmail.com> > > --- > Changelog | 1 + > libavformat/segafilm.c | 24 ++++++++++++++++++++++++ > 2 files changed, 25 insertions(+) > > diff --git a/Changelog b/Changelog > index 7969b414c4..6b3b2bf7fe 100644 > --- a/Changelog > +++ b/Changelog > @@ -47,6 +47,7 @@ version <next>: > - native SBC encoder and decoder > - drmeter audio filter > - hapqa_extract bitstream filter > +- segafilm: set timestamps when demuxing > > > version 3.4: > diff --git a/libavformat/segafilm.c b/libavformat/segafilm.c > index 11768823fc..2295fb3fa5 100644 > --- a/libavformat/segafilm.c > +++ b/libavformat/segafilm.c > @@ -270,6 +270,8 @@ static int film_read_packet(AVFormatContext *s, > FilmDemuxContext *film = s->priv_data; > AVIOContext *pb = s->pb; > film_sample *sample; > + film_sample *next_sample = NULL; > + int next_sample_id; > int ret = 0; > > if (film->current_sample >= film->sample_count) > @@ -277,6 +279,21 @@ static int film_read_packet(AVFormatContext *s, > > 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) */ > avio_seek(pb, sample->sample_offset, SEEK_SET); > > @@ -287,6 +304,13 @@ static int film_read_packet(AVFormatContext *s, > pkt->stream_index = sample->stream; > pkt->pts = sample->pts; > pkt->flags |= sample->keyframe; > + pkt->dts = sample->pts; this may be redundant > + pkt->size = sample->sample_size; This is not correct, the packet has its size already set, if for some reason like IO failures its different overriding this could crash the code later > + if (next_sample != NULL) { > + pkt->duration = next_sample->pts - sample->pts; > + } else { > + pkt->duration = 0; > + } setting duration to "nothing" should not be needed, this should be already teh default [...]
From: Misty De Meo <mistydemeo@gmail.com>
OK, made both requested changes.
Misty De Meo (1):
Sega FILM: set dts and duration when demuxing
Changelog | 1 +
libavformat/segafilm.c | 21 +++++++++++++++++++++
2 files changed, 22 insertions(+)
diff --git a/Changelog b/Changelog index 7969b414c4..6b3b2bf7fe 100644 --- a/Changelog +++ b/Changelog @@ -47,6 +47,7 @@ version <next>: - native SBC encoder and decoder - drmeter audio filter - hapqa_extract bitstream filter +- segafilm: set timestamps when demuxing version 3.4: diff --git a/libavformat/segafilm.c b/libavformat/segafilm.c index 11768823fc..2295fb3fa5 100644 --- a/libavformat/segafilm.c +++ b/libavformat/segafilm.c @@ -270,6 +270,8 @@ static int film_read_packet(AVFormatContext *s, FilmDemuxContext *film = s->priv_data; AVIOContext *pb = s->pb; film_sample *sample; + film_sample *next_sample = NULL; + int next_sample_id; int ret = 0; if (film->current_sample >= film->sample_count) @@ -277,6 +279,21 @@ static int film_read_packet(AVFormatContext *s, 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) */ avio_seek(pb, sample->sample_offset, SEEK_SET); @@ -287,6 +304,13 @@ static int film_read_packet(AVFormatContext *s, pkt->stream_index = sample->stream; pkt->pts = sample->pts; pkt->flags |= sample->keyframe; + pkt->dts = sample->pts; + pkt->size = sample->sample_size; + if (next_sample != NULL) { + pkt->duration = next_sample->pts - sample->pts; + } else { + pkt->duration = 0; + } film->current_sample++;
From: Misty De Meo <mistydemeo@gmail.com> --- Changelog | 1 + libavformat/segafilm.c | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+)