[FFmpeg-devel] [PATCH] opt: Do not clip numerator / denominator arbitrarily in write_number

Mashiat Sarker Shakkhar mashiat.sarker at gmail.com
Tue Feb 18 20:16:57 CET 2014


It is not clear why this has to be `1 << 24` and can't be INT_MAX. Making
this change fixes decoding of files with very large timebase.

This also updates one FATE test ref. Although the tb num / den are
different now, they still evaluate to the same number.
---
 libavutil/opt.c          |    2 +-
 tests/ref/fate/zmbv-8bit |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavutil/opt.c b/libavutil/opt.c
index 6ecc14e..7a6a58a 100644
--- a/libavutil/opt.c
+++ b/libavutil/opt.c
@@ -121,7 +121,7 @@ static int write_number(void *obj, const AVOption *o, void *dst, double num, int
     case AV_OPT_TYPE_DOUBLE:*(double    *)dst= num*intnum/den;         break;
     case AV_OPT_TYPE_RATIONAL:
         if ((int)num == num) *(AVRational*)dst= (AVRational){num*intnum, den};
-        else                 *(AVRational*)dst= av_d2q(num*intnum/den, 1<<24);
+        else                 *(AVRational*)dst= av_d2q(num*intnum/den, INT_MAX);
         break;
     default:
         return AVERROR(EINVAL);
diff --git a/tests/ref/fate/zmbv-8bit b/tests/ref/fate/zmbv-8bit
index f104c98..9f02ae3 100644
--- a/tests/ref/fate/zmbv-8bit
+++ b/tests/ref/fate/zmbv-8bit
@@ -1,4 +1,4 @@
-#tb 0: 15967/1119068
+#tb 0: 1000000/70086303
 0,          0,          0,        1,   192000, 0x5234b617
 0,          1,          1,        1,   192000, 0x5234b617
 0,          2,          2,        1,   192000, 0x5234b617
-- 
1.7.9.5



More information about the ffmpeg-devel mailing list