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

Reimar Döffinger Reimar.Doeffinger
Sat Jun 6 20:55:11 CEST 2009


On Sat, Jun 06, 2009 at 02:26:25PM -0400, Justin Ruggles wrote:
> 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).

Huh?? You can just multiply it by 1.0/(1<<23)



More information about the ffmpeg-devel mailing list