diff options
author | Neil Brown <neilb@suse.de> | 2007-09-03 07:56:26 +0000 |
---|---|---|
committer | Benoit Fouet <benoit.fouet@free.fr> | 2007-09-03 07:56:26 +0000 |
commit | 9fcbcca60a6d838924d662df95b194525254f0ac (patch) | |
tree | 1b68cb002611acda250da9e337ee70eb5f8738cf /libavformat/utils.c | |
parent | 3f19004e467991095f678e6bcac168af0d959be3 (diff) | |
download | ffmpeg-9fcbcca60a6d838924d662df95b194525254f0ac.tar.gz |
If a stream has no start time, but the first packet has a 'pts', use that
pts to set the start_time.
patch by Neil Brown: [neilb suse de]
original thread: [FFmpeg-devel] [patch 3/3] Make timing calculations less
dependant on start_time being defined.
date: 08/16/2007 08:27 AM
Originally committed as revision 10285 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat/utils.c')
-rw-r--r-- | libavformat/utils.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/libavformat/utils.c b/libavformat/utils.c index de11835ff3..0e323831d3 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -590,7 +590,9 @@ static int is_intra_only(AVCodecContext *enc){ return 0; } -static void update_initial_timestamps(AVFormatContext *s, int stream_index, int64_t dts){ +static void update_initial_timestamps(AVFormatContext *s, int stream_index, + int64_t dts, int64_t pts) +{ AVStream *st= s->streams[stream_index]; AVPacketList *pktl= s->packet_buffer; @@ -613,6 +615,8 @@ static void update_initial_timestamps(AVFormatContext *s, int stream_index, int6 if(st->start_time == AV_NOPTS_VALUE && pktl->pkt.pts != AV_NOPTS_VALUE) st->start_time= pktl->pkt.pts; } + if (st->start_time == AV_NOPTS_VALUE) + st->start_time = pts; } static void compute_pkt_fields(AVFormatContext *s, AVStream *st, @@ -670,7 +674,7 @@ static void compute_pkt_fields(AVFormatContext *s, AVStream *st, /* PTS = presentation time stamp */ if (pkt->dts == AV_NOPTS_VALUE) pkt->dts = st->last_IP_pts; - update_initial_timestamps(s, pkt->stream_index, pkt->dts); + update_initial_timestamps(s, pkt->stream_index, pkt->dts, pkt->pts); if (pkt->dts == AV_NOPTS_VALUE) pkt->dts = st->cur_dts; @@ -696,7 +700,7 @@ static void compute_pkt_fields(AVFormatContext *s, AVStream *st, /* presentation is not delayed : PTS and DTS are the same */ if(pkt->pts == AV_NOPTS_VALUE) pkt->pts = pkt->dts; - update_initial_timestamps(s, pkt->stream_index, pkt->pts); + update_initial_timestamps(s, pkt->stream_index, pkt->pts, pkt->pts); if(pkt->pts == AV_NOPTS_VALUE) pkt->pts = st->cur_dts; pkt->dts = pkt->pts; @@ -713,7 +717,7 @@ static void compute_pkt_fields(AVFormatContext *s, AVStream *st, if(pkt->dts == AV_NOPTS_VALUE) pkt->dts= st->pts_buffer[0]; if(delay>1){ - update_initial_timestamps(s, pkt->stream_index, pkt->dts); // this should happen on the first packet + update_initial_timestamps(s, pkt->stream_index, pkt->dts, pkt->pts); // this should happen on the first packet } if(pkt->dts > st->cur_dts) st->cur_dts = pkt->dts; |