diff options
author | Reimar Döffinger <Reimar.Doeffinger@gmx.de> | 2011-02-06 15:27:30 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2011-02-09 03:31:17 +0100 |
commit | 2f35beae4d0994dda925d6b4de68411fbeb55100 (patch) | |
tree | 44fe14c49949b56617eea310f010bb634449dd52 | |
parent | e11afd71a37316e2ea4e765dcb7a6a72867d9bc8 (diff) | |
download | ffmpeg-2f35beae4d0994dda925d6b4de68411fbeb55100.tar.gz |
Make av_set_pts_info keep previous time base if new one is invalid.
Fixes issue 2475.
Signed-off-by: Ronald S. Bultje <rsbultje@gmail.com>
(cherry picked from commit b3190529dfefe3226302b23e76e16c631cde6649)
-rw-r--r-- | libavformat/avformat.h | 3 | ||||
-rw-r--r-- | libavformat/utils.c | 17 |
2 files changed, 12 insertions, 8 deletions
diff --git a/libavformat/avformat.h b/libavformat/avformat.h index 6215ca59ee..e1b753e3f4 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -1267,7 +1267,8 @@ AVChapter *ff_new_chapter(AVFormatContext *s, int id, AVRational time_base, int64_t start, int64_t end, const char *title); /** - * Set the pts for a given stream. + * Set the pts for a given stream. If the new values would be invalid + * (<= 0), it leaves the AVStream unchanged. * * @param s stream * @param pts_wrap_bits number of bits effectively used by the pts diff --git a/libavformat/utils.c b/libavformat/utils.c index d12bbc26c6..4f71f8c0a4 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -3762,16 +3762,19 @@ int ff_hex_to_data(uint8_t *data, const char *p) void av_set_pts_info(AVStream *s, int pts_wrap_bits, unsigned int pts_num, unsigned int pts_den) { - s->pts_wrap_bits = pts_wrap_bits; - - if(av_reduce(&s->time_base.num, &s->time_base.den, pts_num, pts_den, INT_MAX)){ - if(s->time_base.num != pts_num) - av_log(NULL, AV_LOG_DEBUG, "st:%d removing common factor %d from timebase\n", s->index, pts_num/s->time_base.num); + AVRational new_tb; + if(av_reduce(&new_tb.num, &new_tb.den, pts_num, pts_den, INT_MAX)){ + if(new_tb.num != pts_num) + av_log(NULL, AV_LOG_DEBUG, "st:%d removing common factor %d from timebase\n", s->index, pts_num/new_tb.num); }else av_log(NULL, AV_LOG_WARNING, "st:%d has too large timebase, reducing\n", s->index); - if(!s->time_base.num || !s->time_base.den) - s->time_base.num= s->time_base.den= 0; + if(new_tb.num <= 0 || new_tb.den <= 0) { + av_log(NULL, AV_LOG_ERROR, "Ignoring attempt to set invalid timebase for st:%d\n", s->index); + return; + } + s->time_base = new_tb; + s->pts_wrap_bits = pts_wrap_bits; } int ff_url_join(char *str, int size, const char *proto, |