summaryrefslogtreecommitdiff
path: root/libavutil/parseutils.c
diff options
context:
space:
mode:
authorStefano Sabatini <stefasab@gmail.com>2012-10-16 18:15:58 +0200
committerStefano Sabatini <stefasab@gmail.com>2012-10-20 12:19:53 +0200
commitcdea54b4c8cd891aa12f85c41b0cd4bd81be83f9 (patch)
tree52865d658e5e9f1b265f613d9f289d54433b8dab /libavutil/parseutils.c
parent935ecfb002385697d57573975f95c401eba68d64 (diff)
lavu/parseutils: rework rational reduction logic in av_parse_ratio()
Avoid to divide num and den by gcd in case of a parsed expression, since that is already done in av_d2q(), and force reduction in case of "a:b" form, allowing to honour the max parameter. The latter change is consistent with the a/b case, and with the documentation.
Diffstat (limited to 'libavutil/parseutils.c')
-rw-r--r--libavutil/parseutils.c8
1 files changed, 2 insertions, 6 deletions
diff --git a/libavutil/parseutils.c b/libavutil/parseutils.c
index 84bb9f7876..b201331fe1 100644
--- a/libavutil/parseutils.c
+++ b/libavutil/parseutils.c
@@ -57,12 +57,8 @@ int av_parse_ratio(AVRational *q, const char *str, int max,
if (ret < 0)
return ret;
*q = av_d2q(d, max);
- }
-
- gcd = av_gcd(FFABS(q->num), FFABS(q->den));
- if (gcd) {
- q->num /= gcd;
- q->den /= gcd;
+ } else {
+ av_reduce(&q->num, &q->den, q->num, q->den, max);
}
return 0;