[FFmpeg-devel] [PATCH] E-AC-3 spectral extension

Justin Ruggles justin.ruggles
Sat Jun 6 20:26:25 CEST 2009


Michael Niedermayer wrote:
> On Tue, Jun 02, 2009 at 09:19:23PM -0400, Justin Ruggles wrote:
>> +                    for (bnd = 0; bnd < s->num_spx_bands; bnd++) {
>> +                        int bandsize;
>> +                        int spx_coord_exp, spx_coord_mant;
>> +                        float nratio, sblend, nblend, spx_coord;
>> +
>> +                        /* calculate blending factors */
>> +                        bandsize = s->spx_band_sizes[bnd];
>> +                        nratio = ((float)((bin + (bandsize >> 1))) / s->spx_end_freq) - spx_blend;
>> +                        nratio = av_clipf(nratio, 0.0f, 1.0f);
>> +                        nblend = sqrt(3.0f * nratio); // noise is scaled by sqrt(3) to give unity variance
>> +                        sblend = sqrt(1.0f - nratio);
>> +                        bin += bandsize;
>> +
> 
>> +                        /* decode spx coordinates */
>> +                        spx_coord_exp  = get_bits(gbc, 4);
>> +                        spx_coord_mant = get_bits(gbc, 2);
>> +                        if (spx_coord_exp == 15)
>> +                            spx_coord = spx_coord_mant * 8.0f;
>> +                        else
>> +                            spx_coord = (spx_coord_mant + 4) * 4.0f;
>> +                        spx_coord /= 1 << (spx_coord_exp + master_spx_coord);
> 
> something based on the following would avoid the /
> spx_coord *= (1<<123) >> (spx_coord_exp + master_spx_coord)
> 
> also *4 can be factored out of the if/else and into the factor above

I don't see how this would avoid a division.  The result would still
have to be divided by (1<<23).  Although I could maybe combine it with
the division by (1<<31) for the random noise and make it /(1LL<<54).

-Justin



More information about the ffmpeg-devel mailing list