On 04/23/2011 04:33 PM, Ronald S. Bultje wrote:

> Hi,
> 
> On Sun, Apr 17, 2011 at 11:39 AM, Justin Ruggles
> <[email protected]> wrote:
> [..]
>> +    /* calculate energy in each band in coupling channel and each fbw 
>> channel */
>> +    bnd = 0;
>> +    i = s->start_freq[CPL_CH];
>> +    while (i < s->cpl_end_freq) {
>> +        int band_size = s->cpl_band_sizes[bnd];
>> +        for (ch = CPL_CH; ch <= s->fbw_channels; ch++) {
>> +            for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) {
>> +                AC3Block *block = &s->blocks[blk];
>> +                if (!block->cpl_in_use || (ch > CPL_CH && 
>> !block->channel_in_cpl[ch]))
>> +                    continue;
>> +                for (j = 0; j < band_size; j++) {
>> +                    float v = block->mdct_coef[ch][i+j];
>> +                    energy[blk][ch][bnd] += v * v;
> 
> This looks somewhat SIMD'able. (Don't bother if an existing simd
> function doesn't already exist, but sum of squares seems common enough
> to exist...)

scalarproduct_float() would work, but i would need to play around with
the alignment and size.  the start position for all bands are i%4=1, and
band_size is a multiple of 12.  we would likely have to modify
scalarproduct_float() to handle unaligned data.  that's easy enough for
the sse version, but i don't know about the neon version.

>> +                coord = 0.125f;
>> +                if (energy_cpl > 0)
>> +                    coord = sqrtf(energy_ch / energy_cpl) / 8.0f;
> 
> coord *= sqrtf(energy_ch / energy_cpl);

indeed. :)

>> @@ -1129,7 +1489,21 @@ static int compute_bit_allocation(AC3EncodeContext *s)
>>      ret = cbr_bit_allocation(s);
>>      while (ret) {
>> -        /* fallback 1: downgrade exponents */
>> +        /* fallback 1: disable channel coupling */
>> +        if (s->cpl_on) {
>> +            s->cpl_on = 0;
>> +            apply_mdct(s);
>> +            compute_coupling_strategy(s);
>> +            compute_rematrixing_strategy(s);
>> +            scale_coefficients(s);
>> +            compute_rematrixing_strategy(s);
>> +            apply_rematrixing(s);
>> +            process_exponents(s);
>> +            ret = compute_bit_allocation(s);
>> +            continue;
>> +        }
>> +
>> +        /* fallback 2: downgrade exponents */
>>          if (!downgrade_exponents(s)) {
>>              extract_exponents(s);
>>              encode_exponents(s);
> 
> So if there's no bits left, first thing you do is to disable channel
> coupling. Does that always provide less quality loss per bits saved
> than changing exponents? Since you now have multiple things to try,
> you could maybe try both and calculate which provides best "bits saved
> per quality loss" scenarios.


The fallbacks are only needed at really low bitrates in order to
generate a valid stream.  Either way it will sound like crap.  Modifying
exponents when coupling is turned on is much more complicated.

-Justin
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to