Help - Search - Members - Calendar
Full Version: Requantization
Hydrogenaudio Forums > Lossy Audio Compression > MP3 > MP3 - Tech
Woffie
Hi!

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
Gabriel
The "two different formulas" are the same one:

CODE
   xr[i] = sign(is[i]) * abs(is[i])^(4/3) *
           2^((1/4) * (global_gain - 210 - 8 * subblock_gain[w])) *
           2^-(scalefac_multiplier *
               (scalefac_l[sfb] + preflag * pretab[sfb]))

Preflag can only be used on long blocks, and subblock_gain can only be used on short blocks.
Woffie
Alright...
I took another look at the ISO-spec after your post and found the same info there.
It takes a while to fully get all the details of it unsure.gif

Thanks a bunch
/C.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.