decoder/mad: fix negative replay gain values

Negating an unsigned integer does not work.
This commit is contained in:
Max Kellermann 2014-10-28 22:22:30 +01:00
parent 217d88f21f
commit 54c591bd9d
2 changed files with 2 additions and 1 deletions

1
NEWS
View File

@ -5,6 +5,7 @@ ver 0.19.2 (not yet released)
* decoder * decoder
- faad: remove workaround for ancient libfaad2 ABI bug - faad: remove workaround for ancient libfaad2 ABI bug
- ffmpeg: recognize MIME type audio/aacp - ffmpeg: recognize MIME type audio/aacp
- mad: fix negative replay gain values
* output * output
- fix memory leak after filter initialization error - fix memory leak after filter initialization error
- fall back to PCM if given DSD sample rate is not supported - fall back to PCM if given DSD sample rate is not supported

View File

@ -657,7 +657,7 @@ parse_lame(struct lame *lame, struct mad_bitptr *ptr, int *bitlen)
unsigned name = mad_bit_read(ptr, 3); /* gain name */ unsigned name = mad_bit_read(ptr, 3); /* gain name */
unsigned orig = mad_bit_read(ptr, 3); /* gain originator */ unsigned orig = mad_bit_read(ptr, 3); /* gain originator */
unsigned sign = mad_bit_read(ptr, 1); /* sign bit */ unsigned sign = mad_bit_read(ptr, 1); /* sign bit */
unsigned gain = mad_bit_read(ptr, 9); /* gain*10 */ int gain = mad_bit_read(ptr, 9); /* gain*10 */
if (gain && name == 1 && orig != 0) { if (gain && name == 1 && orig != 0) {
lame->track_gain = ((sign ? -gain : gain) / 10.0) + adj; lame->track_gain = ((sign ? -gain : gain) / 10.0) + adj;
FormatDebug(mad_domain, "LAME track gain found: %f", FormatDebug(mad_domain, "LAME track gain found: %f",