summaryrefslogtreecommitdiff
path: root/libavformat/utils.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2009-07-01 20:52:48 +0000
committerMichael Niedermayer <michaelni@gmx.at>2009-07-01 20:52:48 +0000
commitd218a86a0da7b2630828d31393d52295f0e311e9 (patch)
treec1c71c31956c90b4b71dde13f31d37976858e0ef /libavformat/utils.c
parent6be8b20466b7bf44029ff5b621fc24f67ed75183 (diff)
Make sure av_set_pts_info() does not set the fields of a timebase to
negative values. Originally committed as revision 19325 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat/utils.c')
-rw-r--r--libavformat/utils.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/libavformat/utils.c b/libavformat/utils.c
index b1c0363fde..d7bc23f3c9 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -3306,11 +3306,11 @@ char *ff_data_to_hex(char *buff, const uint8_t *src, int s)
void av_set_pts_info(AVStream *s, int pts_wrap_bits,
unsigned int pts_num, unsigned int pts_den)
{
- unsigned int gcd= av_gcd(pts_num, pts_den);
s->pts_wrap_bits = pts_wrap_bits;
- s->time_base.num = pts_num/gcd;
- s->time_base.den = pts_den/gcd;
- if(gcd>1)
- av_log(NULL, AV_LOG_DEBUG, "st:%d removing common factor %d from timebase\n", s->index, gcd);
+ 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);
+ }else
+ av_log(NULL, AV_LOG_WARNING, "st:%d has too large timebase, reducing\n", s->index);
}