[FFmpeg-devel] [PATCH] ac3enc: change default floor code to 7.
Justin Ruggles
justin.ruggles
Tue Feb 15 22:38:04 CET 2011
On 02/15/2011 02:47 PM, M?ns Rullg?rd wrote:
> Justin Ruggles <justin.ruggles at gmail.com> writes:
>
>> This is to match the value in every (E-)AC-3 file from commercial sources.
>> It has a negligible effect on audio quality.
>> ---
>> libavcodec/ac3enc.c | 2 +-
>> tests/ref/acodec/ac3_fixed | 2 +-
>> tests/ref/lavf/rm | 2 +-
>> 3 files changed, 3 insertions(+), 3 deletions(-)
>
> What is the effect of this change? Why is matching commercial encoders
> valuable?
Matching commercial encoders makes it easier to do encoder comparisons
for all points in the process after bit allocation.
There are many ways to describe the effect of this field. One way to
look at it is this:
- exponents are used to estimate spectral density
- this is used as a baseline for allocating bits to mantissas
- one effect of the floor value is to change this baseline
- the value effectively puts a ceiling on bit allocation
- floor code 7 cooresponds to a negative floor value, so instead it
raises the ceiling and allows bits to be allocated to mantissas when
available rather than having them end up as padding at the end of the frame.
If we have VBR AC-3 encoding at some point it would be better to use a
value of 4 in that case, but for CBR AC-3 or E-AC-3 (see below) a value
of 7 is better.
>> diff --git a/libavcodec/ac3enc.c b/libavcodec/ac3enc.c
>> index 851fdc9..dc7e4ad 100644
>> --- a/libavcodec/ac3enc.c
>> +++ b/libavcodec/ac3enc.c
>> @@ -752,7 +752,7 @@ static void bit_alloc_init(AC3EncodeContext *s)
>> s->fast_decay_code = 1;
>> s->slow_gain_code = 1;
>> s->db_per_bit_code = 3;
>> - s->floor_code = 4;
>> + s->floor_code = 7;
>
> FWIW, 4 is mentioned as a nominal default in the spec.
But for E-AC-3 the default is 7. And that part of the bit allocation is
the same for AC-3 and E-AC-3. Plus in E-AC-3 you save some bits by
using the defaults.
-Justin
More information about the ffmpeg-devel
mailing list