[Ffmpeg-devel] ac3enc.c modifications

Justin Ruggles jruggle
Mon Apr 25 17:55:23 CEST 2005

matthieu castet wrote:

> Justin Ruggles wrote:
>> Hello,
>> channels are similar.  Channel gain range is used in the decoder to 
>> increase dynamic range.  The only thing I've changed (rather than 
>> added) is on line 1404.  I changed v-8 to v-9 because I noticed that 
>> the output was too quiet.  Using v-8, the exponent is limited to 1-24 
>> instead of 0-24.  Changing to v-9 fixes this.
> Yes there were somebody who claim that there were a missing factor 2 
> in the encoder.
> If I remenber well it was someone from transcode called simone, search 
> the ML for more info.

I looked back at that thread about the ac3 scaling factor.  I both agree 
and disagree with Simone about scaling by 2 during the mdct.  I ran a 
test using the formula directly from the specification (including the 
-2/N scaling) and got the same results (too quiet).  So I don't think 
the issue is with the mdct not being correct.  I think the problem lies 
somewhere in the normalization routine which also adjusts for using 
signed 16-bit input.  The signed 16-bit integers really only have 15-bit 
resolution because of the sign bit.  From what I can tell, the (v-8) 
part scales from 15-bit to 23-bit.  But ac3 uses a separated 
floating-point value with full 24-bit resolution in the exponent and 
bitrate-adjusted resolution in the mantissa (which includes the sign).  
Another reason I think this is the issue is that when I was playing 
around with using floating-point input I took out the normalization.  
When scaling the floating-point coefficients, I had to multiply by 2^24, 
not 2^23 to get them to be the correct loudness.  Scaling the 
coefficients by 2 during the mdct does resolve the issue, but I don't 
think it's the right place, logically, to do it.

More information about the ffmpeg-devel mailing list