diff options
author | Aurelien Jacobs <aurel@gnuage.org> | 2008-05-24 21:44:29 +0000 |
---|---|---|
committer | Aurelien Jacobs <aurel@gnuage.org> | 2008-05-24 21:44:29 +0000 |
commit | c2c3dedf6e280c0e520b868976648e055f226f5d (patch) | |
tree | d1aca43004e7e7cb071b1446343705a552e791fe /libavformat/utils.c | |
parent | a6072fdc184f863c84852864a53da1b2e53c8eb0 (diff) | |
download | ffmpeg-streaming-c2c3dedf6e280c0e520b868976648e055f226f5d.zip ffmpeg-streaming-c2c3dedf6e280c0e520b868976648e055f226f5d.tar.gz |
compute the end of all chapters when end is not specified in the container
Originally committed as revision 13363 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat/utils.c')
-rw-r--r-- | libavformat/utils.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/libavformat/utils.c b/libavformat/utils.c index eb50535..fbc5c8b 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -1805,6 +1805,26 @@ enum CodecID av_codec_get_id(const AVCodecTag *tags[4], unsigned int tag) return CODEC_ID_NONE; } +static void compute_chapters_end(AVFormatContext *s) +{ + unsigned int i; + + for (i=0; i+1<s->nb_chapters; i++) + if (s->chapters[i]->end == AV_NOPTS_VALUE) { + assert(s->chapters[i]->start <= s->chapters[i+1]->start); + assert(!av_cmp_q(s->chapters[i]->time_base, s->chapters[i+1]->time_base)); + s->chapters[i]->end = s->chapters[i+1]->start; + } + + if (s->nb_chapters && s->chapters[i]->end == AV_NOPTS_VALUE) { + assert(s->start_time != AV_NOPTS_VALUE); + assert(s->duration > 0); + s->chapters[i]->end = av_rescale_q(s->start_time + s->duration, + AV_TIME_BASE_Q, + s->chapters[i]->time_base); + } +} + /* absolute maximum size we read until we abort */ #define MAX_READ_SIZE 5000000 @@ -2075,6 +2095,8 @@ int av_find_stream_info(AVFormatContext *ic) url_fseek(ic->pb, ic->data_offset, SEEK_SET); } + compute_chapters_end(ic); + #if 0 /* correct DTS for B-frame streams with no timestamps */ for(i=0;i<ic->nb_streams;i++) { |