Commit 65206131 authored by Michael Niedermayer's avatar Michael Niedermayer

Merge commit '25b6837f'

* commit '25b6837f':
  replaygain: fix gain sign decoding
Merged-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parents dfd865e5 25b6837f
...@@ -40,6 +40,7 @@ static int32_t parse_gain(const char *gain) ...@@ -40,6 +40,7 @@ static int32_t parse_gain(const char *gain)
char *fraction; char *fraction;
int scale = 10000; int scale = 10000;
int32_t mb = 0; int32_t mb = 0;
int sign = 1;
int db; int db;
if (!gain) if (!gain)
...@@ -47,6 +48,9 @@ static int32_t parse_gain(const char *gain) ...@@ -47,6 +48,9 @@ static int32_t parse_gain(const char *gain)
gain += strspn(gain, " \t"); gain += strspn(gain, " \t");
if (*gain == '-')
sign = -1;
db = strtol(gain, &fraction, 0); db = strtol(gain, &fraction, 0);
if (*fraction++ == '.') { if (*fraction++ == '.') {
while (av_isdigit(*fraction) && scale) { while (av_isdigit(*fraction) && scale) {
...@@ -59,7 +63,7 @@ static int32_t parse_gain(const char *gain) ...@@ -59,7 +63,7 @@ static int32_t parse_gain(const char *gain)
if (abs(db) > (INT32_MAX - mb) / 100000) if (abs(db) > (INT32_MAX - mb) / 100000)
return INT32_MIN; return INT32_MIN;
return db * 100000 + FFSIGN(db) * mb; return db * 100000 + sign * mb;
} }
static uint32_t parse_peak(const uint8_t *peak) static uint32_t parse_peak(const uint8_t *peak)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment