[Ffmpeg-devel] Re: BUG: AC3 encode volume is low

Justin Ruggles jruggle
Sat Apr 8 14:59:26 CEST 2006


Pierre Marc Dumuid wrote:
> Hi Matthieu,
> Re: http://mplayerhq.hu/pipermail/ffmpeg-devel/2006-April/010010.html  
> As I said, I wasn't on the mailing list, (I took a peek on the logs to 
> see if any discussion had resulted)  Please CC me any discussion, 
> (though I will take a peek)
> Regarding there being a discussion, these discussions are quite old... I 
> read them, and didn't completely understand them, though I get the 
> feeling that nothing got committed to fix the problem.  Is the problem 
> unfixable?  (because a poor definition of a formula).  If so, maybe a 
> message should be displayed indicating the attenuation.  Alternatively, 
> a command argument could be used such as --use_dodgy_ac3_formula...

IMO, neither ac3's MDCT formula nor FFmpeg's implementation of it is
dodgy.  You're right, though, that there was never any consensus on a
resolution to the issue and no fix was ever committed.  I still haven't
changed my opinion on the matter, although there is one thing that I am
not 100% sure about...

Why does the MDCT output to a 32-bit int instead of 16-bit?  Isn't it
just a signed 15-bit fixed-point implementation of the formula in the
spec?  I can't find where the output coefficients would need to be more
than a 16-bit signed integer.

>From what I can tell from the MDCT code, and from the fix15() function,
the output coefficients should have a range of -32767 to 32767.  Thus,
the abs(av_log2(mdct_coeff)) would have a range of 0 to 14.  Looking at
the code that calculates the exponent based on the MDCT coefficient, (23
- v) would have a range of 23 to 9.  In order to get the desired
exponent range of 0 to 24, the value of exp_samples, which is generated
during normalization, would have to have a minimum value of -9.

The current code generates a minimum value for exp_samples of -8.  To
me, changing the normalization code to generate a minimum value of -9
seems to be the proper solution.

I don't think I ever submitted this in its own patch way back when, so
I'll go ahead and do it now.  I hope I'm doing the regression test
checksums correctly...I've never really used regression tests before.

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: ac3enc-volume.diff
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20060408/dda3f4f8/attachment.txt>

More information about the ffmpeg-devel mailing list