Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mpc-hc/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2014-02-19 00:43:57 +0400
committerMichael Niedermayer <michaelni@gmx.at>2014-02-19 00:49:56 +0400
commit8f853159f6ea6f6453e69a26f4ea62f9d35f4181 (patch)
tree9a433b12f50b26acd087d38c863a5739f8af5cf6 /libavutil
parent3e70c7023e598afa15d40ae3fce62ae1eee25195 (diff)
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@gmx.at>
Diffstat (limited to 'libavutil')
-rw-r--r--libavutil/opt.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/libavutil/opt.c b/libavutil/opt.c
index 6ecc14eb09..c74f220ca1 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];