diff options
author | Alessandro Ghedini <alessandro@ghedini.me> | 2014-04-04 11:50:43 +0200 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2014-04-04 17:04:37 +0200 |
commit | 25b6837f7cacd691b19cbc12b9dad1ce84a318a1 (patch) | |
tree | a3936158fa157db433249b4e8467d7b96925e51d | |
parent | f37815b1d5ee85d266ad27214a71831707111aa8 (diff) | |
download | ffmpeg-25b6837f7cacd691b19cbc12b9dad1ce84a318a1.tar.gz |
replaygain: fix gain sign decoding
The gain sign was incorrectly decoded: since the FFSIGN() macro treats 0 as
negative, gain values starting with "0." were always decoded as negative.
Signed-off-by: Anton Khirnov <anton@khirnov.net>
-rw-r--r-- | libavformat/replaygain.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/libavformat/replaygain.c b/libavformat/replaygain.c index cf4dbf8f01..6983601491 100644 --- a/libavformat/replaygain.c +++ b/libavformat/replaygain.c @@ -40,6 +40,7 @@ static int32_t parse_gain(const char *gain) char *fraction; int scale = 10000; int32_t mb = 0; + int sign = 1; int db; if (!gain) @@ -47,6 +48,9 @@ static int32_t parse_gain(const char *gain) gain += strspn(gain, " \t"); + if (*gain == '-') + sign = -1; + db = strtol(gain, &fraction, 0); if (*fraction++ == '.') { while (av_isdigit(*fraction) && scale) { @@ -59,7 +63,7 @@ static int32_t parse_gain(const char *gain) if (abs(db) > (INT32_MAX - mb) / 100000) return INT32_MIN; - return db * 100000 + FFSIGN(db) * mb; + return db * 100000 + sign * mb; } static uint32_t parse_peak(const uint8_t *peak) |