[FFmpeg-cvslog] avutil/opt: preserve fractions in set_string_number()
Michael Niedermayer
git at videolan.org
Wed Feb 19 01:57:52 CET 2014
ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Tue Feb 18 21:43:57 2014 +0100| [8f853159f6ea6f6453e69a26f4ea62f9d35f4181] | committer: Michael Niedermayer
avutil/opt: preserve fractions in set_string_number()
This avoids going over a double precission float, which may loose precission
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=8f853159f6ea6f6453e69a26f4ea62f9d35f4181
---
libavutil/opt.c | 9 +++++++++
tests/ref/fate/zmbv-8bit | 2 +-
2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/libavutil/opt.c b/libavutil/opt.c
index 6ecc14e..c74f220 100644
--- a/libavutil/opt.c
+++ b/libavutil/opt.c
@@ -195,6 +195,15 @@ static int set_string(void *obj, const AVOption *o, const char *val, uint8_t **d
static int set_string_number(void *obj, void *target_obj, const AVOption *o, const char *val, void *dst)
{
int ret = 0, notfirst = 0;
+ int num, den;
+ char c;
+
+ if (sscanf(val, "%d%*1[:/]%d%c", &num, &den, &c) == 2) {
+ if ((ret = write_number(obj, o, dst, 1, den, num)) >= 0)
+ return ret;
+ ret = 0;
+ }
+
for (;;) {
int i, den = 1;
char buf[256];
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
More information about the ffmpeg-cvslog
mailing list