aboutsummaryrefslogtreecommitdiff
path: root/libavformat/replaygain.c
diff options
context:
space:
mode:
authorMichael Niedermayer2014-04-04 22:43:37 +0200
committerMichael Niedermayer2014-04-04 22:44:17 +0200
commit652061313979b99f91b27309ecd8baeef7b7865f (patch)
tree2c2241bc2c3ee9b9813db9c11b1f3a35a5a6fe23 /libavformat/replaygain.c
parentdfd865e51b890d9be394804bccddf55198f4a251 (diff)
parent25b6837f7cacd691b19cbc12b9dad1ce84a318a1 (diff)
Merge commit '25b6837f7cacd691b19cbc12b9dad1ce84a318a1'
* commit '25b6837f7cacd691b19cbc12b9dad1ce84a318a1': replaygain: fix gain sign decoding Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/replaygain.c')
-rw-r--r--libavformat/replaygain.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/libavformat/replaygain.c b/libavformat/replaygain.c
index 35b3f26a4e..95924fab7f 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)