[FFmpeg-devel] [PATCH] E-AC-3 spectral extension (bump)

Christophe Gisquet christophe.gisquet
Fri Mar 19 13:03:16 CET 2010


Hi,

in the sake of restarting the review process, I'm restarting a thread left here:
http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/2009-October/077490.html

The one complain remaining on the patch at that time was the following
(sorry for the shoddy editing):

> > +    copy_sizes[num_copy_sections++] = bin - s->spx_copy_start_freq;
> > +
> > +    for (ch = 1; ch <= s->fbw_channels; ch++) {
> > +        if (!s->channel_uses_spx[ch])
> > +            continue;
> > +
> > +        /* Copy coeffs from normal bands to extension bands */
> > +        bin = s->spx_start_freq;
> > +        for (i = 0; i < num_copy_sections; i++) {
> > +            memcpy(&s->transform_coeffs[ch][bin],
> > +                   &s->transform_coeffs[ch][s->spx_copy_start_freq],
> > +                   copy_sizes[i]*sizeof(float));
> > +            bin += copy_sizes[i];
> > +        }
> > +
> > +        /* Calculate RMS energy for each SPX band. */
> > +        bin = s->spx_start_freq;
> > +        for (bnd = 0; bnd < s->num_spx_bands; bnd++) {
> > +            int bandsize = s->spx_band_sizes[bnd];
> > +            float accum = 0.0f;
> > +            for (i = 0; i < bandsize; i++) {
> > +                float coeff = s->transform_coeffs[ch][bin++];
> > +                accum += coeff * coeff;
> > +            }
> > +            rms_energy[bnd] = sqrtf(accum / bandsize);
> > +        }
>
> if i understand the code correctly, the same source coefficients can be
> copied to several destinations, thus it would be more efficient to not
> calculate this for all destination but rather for the source and copy
> as needed to destination bands

The RMS computations occur on strictly non-overlapping samples from
band to band, and always on the SPX bands, never on the original
source:
s->spx_copy_start_freq+sum(copy_sizes[i]) <= s->spx_start_freq

If one would output some info over the 2 samples available at:
http://samples.mplayerhq.hu/A-codecs/AC3/eac3/
one would see for the 5.1 sample:
Channel 1: Copying 72 elements to bin 109 from bin 25
RMS for band 0 on 109-121 elements
RMS for band 1 on 121-133 elements
RMS for band 2 on 133-145 elements
RMS for band 3 on 145-157 elements
RMS for band 4 on 157-181 elements
(and so on for each channel and call to that function)
For the stereo sample:
Channel 1: Copying 24 elements to bin 133 from bin 25
RMS for band 0 on 133-145 elements
RMS for band 1 on 145-157 elements
(repeat for each channel and call)

So:
- no computation is remade
- the number of samples for each iteration is for the available
samples 12 and 24
- each band may start on an unaligned position (for SSE code at
least), so scalarproduct & co functions can't be reused directly
- ff_eac3_apply_spectral_extension is 0.5% of execution time at best
(from a oprofile log)

Attached is the patch rediff'ed against current SVN. I declare myself
incompetent for more theoretical discussions, though.

Best regards,
Christophe
-------------- next part --------------
A non-text attachment was scrubbed...
Name: eac3_spx_9.diff
Type: text/x-diff
Size: 21275 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100319/1317fd0c/attachment.diff>



More information about the ffmpeg-devel mailing list