[FFmpeg-devel] [PATCH] RealAudio 14.4K encoder

Francesco Lavra francescolavra
Tue May 25 19:48:23 CEST 2010


On Mon, 2010-05-24 at 02:53 +0200, Michael Niedermayer wrote:
> On Sun, May 23, 2010 at 08:52:30PM +0200, Francesco Lavra wrote:
> > I'd say we should go for the fast gain qantization, and in attachment is
> > an cleaned up patch for it, with code duplication removed.
> 
> the attached code looks like float brute

Yes, it is brute force, but it's the faster version: instead of
LP-filtering the sum of the 3 codebook vectors for each gain
quantization value, LP filtering is done only once for each of the 3
vectors (in floating point) and the search is done with the sum of the
filtered vectors.

[...]
> > +    best_error = FLT_MAX;
> > +    gain = 0;
> > +    for (n = 0; n < 256; n++) {
> > +        g[1] = ((ff_gain_val_tab[n][1] * m[1]) >> ff_gain_exp_tab[n]) *
> > +               (1/4096.0);
> > +        g[2] = ((ff_gain_val_tab[n][2] * m[2]) >> ff_gain_exp_tab[n]) *
> > +               (1/4096.0);
> > +        error = 0;
> > +        if (cba_idx) {
> > +            g[0] = ((ff_gain_val_tab[n][0] * m[0]) >> ff_gain_exp_tab[n]) *
> > +                   (1/4096.0);
> > +            for (i = 0; i < BLOCKSIZE; i++) {
> > +                data[i] = zero[i] + g[0] * cba[i] + g[1] * cb1[i] +
> > +                          g[2] * cb2[i];
> > +                error += (data[i] - sblock_data[i]) *
> > +                         (data[i] - sblock_data[i]);
> > +            }
> > +        } else {
> > +            for (i = 0; i < BLOCKSIZE; i++) {
> > +                data[i] = zero[i] + g[1] * cb1[i] + g[2] * cb2[i];
> > +                error += (data[i] - sblock_data[i]) *
> > +                         (data[i] - sblock_data[i]);
> > +            }
> > +        }
> > +        if (error < best_error) {
> > +            best_error = error;
> > +            gain = n;
> > +        }
> > +    }





More information about the ffmpeg-devel mailing list