I've been trying to decode the ISO CD11172-3 specification to find out how to do the re-quantization in MP3.
Libmad has a bigger comment block about this in it's code which gives two different ways of decoding long/short blocks.
CODE
/*
* long blocks:
* xr[i] = sign(is[i]) * abs(is[i])^(4/3) *
* 2^((1/4) * (global_gain - 210)) *
* 2^-(scalefac_multiplier *
* (scalefac_l[sfb] + preflag * pretab[sfb]))
*
* short blocks:
* xr[i] = sign(is[i]) * abs(is[i])^(4/3) *
* 2^((1/4) * (global_gain - 210 - 8 * subblock_gain[w])) *
* 2^-(scalefac_multiplier * scalefac_s[sfb][w])
*
* where:
* scalefac_multiplier = (scalefac_scale + 1) / 2
*/
However, I don't really understand how they came up with the two different computations. I guess that the thing about preflag isn't availible in short blocks, but where does all the other stuff come from?
My goal is to make a fixed-point mp3-decoder, but as for now I use double during computation of xr[i].
So, my questions are:
- Why does libmad uses two different formulas, or where can I read more about it - I've tried to understand the ISO before writing here...
- When looking at libmad they only compute 39 exponents. I thought that a exponent had to be calculated for every value in is[i] - am I wrong?
- Why does most decoders use a gain with 210 (for scaling) instead of 64 as the specification propose?
Thanks /Charlie