[FFmpeg-devel] [PATCH] Support for variable frame duration
Baptiste Coudurier
baptiste.coudurier
Wed Apr 23 00:19:35 CEST 2008
Hi,
Henrik Gulbrandsen wrote:
> [...]
>
> Index: libavformat/mov.c
> ===================================================================
> --- libavformat/mov.c (revision 12920)
> +++ libavformat/mov.c (working copy)
> @@ -1729,6 +1729,8 @@ static int mov_read_packet(AVFormatConte
> MOVStreamContext *sc = 0;
> AVIndexEntry *sample = 0;
> int64_t best_dts = INT64_MAX;
> + int64_t next_dts = 0;
> + int next_index;
> int i;
> retry:
> for (i = 0; i < s->nb_streams; i++) {
> @@ -1747,6 +1749,10 @@ static int mov_read_packet(AVFormatConte
> sample = current_sample;
> best_dts = dts;
> sc = msc;
> +
> + next_index = msc->current_sample + 1;
> + next_dts = (next_index < msc->sample_count)?
> + st->index_entries[next_index].timestamp : st->duration;
> }
> }
> }
> @@ -1790,6 +1796,7 @@ static int mov_read_packet(AVFormatConte
> }
> } else {
> pkt->pts = pkt->dts;
> + pkt->duration = next_dts - pkt->dts;
> }
> pkt->flags |= sample->flags & AVINDEX_KEYFRAME ? PKT_FLAG_KEY : 0;
> pkt->pos = sample->pos;
>
Better to get duration at the end when needed, thus removing computation
from the loop. Besides idea is ok.
--
Baptiste COUDURIER GnuPG Key Id: 0x5C1ABAAA
SMARTJOG S.A. http://www.smartjog.com
Key fingerprint 8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA
Phone: +33 1 49966312
More information about the ffmpeg-devel
mailing list