From 466441dc14f2463dbd48aa6ab268317269100e4a Mon Sep 17 00:00:00 2001 From: Thomas Martitz Date: Tue, 15 Apr 2014 23:49:07 +0200 Subject: [PATCH] libmad: Use 32bit unsigned for requantize table. Implicit promotion of integer literals to unsigned long introduced a subtle bug on 64-bit systems due to weird sign extensions (leads to audible glitches in a few files). The table is originally designed for unsigned 32bit integers, and it works with those so use them. As a consequence the lookup table size is halved as well. Change-Id: I35d878d6df03300387f0e403e0f3c3bdc73eea00 --- lib/rbcodec/codecs/libmad/layer3.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/rbcodec/codecs/libmad/layer3.c b/lib/rbcodec/codecs/libmad/layer3.c index ffb0fb20ff..48bb643b93 100644 --- a/lib/rbcodec/codecs/libmad/layer3.c +++ b/lib/rbcodec/codecs/libmad/layer3.c @@ -339,7 +339,7 @@ unsigned char const pretab[22] = { * format rq_table: bit31-27=exponent bit26-0=mantissa */ static -unsigned long const rq_table[8207] = { +uint32_t const rq_table[8207] = { # include "rq_table.dat" }; @@ -885,7 +885,7 @@ mad_fixed_t III_requantize(unsigned int value, signed int exp) { mad_fixed_t requantized; signed int frac; - unsigned long power; + uint32_t power; frac = exp % 4; /* assumes sign(frac) == sign(exp) */ exp /= 4;