[FFmpeg-devel] [RFC] slightly "simplify" ff_ac3_bit_alloc_calc_psd

Justin Ruggles justin.ruggles
Thu Jan 14 00:20:46 CET 2010


Reimar D?ffinger wrote:

> Hello,
> this is one instruction less in the inner loop due to a "clever" use of
> lea by the compiler instead of needing a cmov.
> Might help more on machines without cmov, because on Intel Atom the
> difference is quite unstable even with START_TIMER/STOP_TIMER.
> Somewhat representative values (sorry, the numbers I got were
> all next to useless):
> new:
> 30846 dezicycles in calc_psd, 65501 runs, 35 skips
> old:
> 31299 dezicycles in calc_psd, 65496 runs, 40 skips
> 
> Index: libavcodec/ac3.c
> ===================================================================
> --- libavcodec/ac3.c	(revision 21191)
> +++ libavcodec/ac3.c	(working copy)
> @@ -112,9 +112,10 @@
>          int v = psd[bin++];
>          int band_end = FFMIN(band_start_tab[band+1], end);
>          for (; bin < band_end; bin++) {
> +            int max = FFMAX(v, psd[bin]);
>              /* logadd */
> -            int adr = FFMIN(FFABS(v - psd[bin]) >> 1, 255);
> -            v = FFMAX(v, psd[bin]) + ff_ac3_log_add_tab[adr];
> +            int adr = FFMIN(max - ((v + psd[bin] + 1) >> 1), 255);
> +            v = max + ff_ac3_log_add_tab[adr];
>          }
>          band_psd[band++] = v;
>      } while (end > band_start_tab[band]);

ok, as long as they are mathematically equivalent, which appears to be
the case at first glance.

-Justin




More information about the ffmpeg-devel mailing list