[FFmpeg-devel] [PATCH 2/2] ac3enc: add SIMD-optimized shifting functions for use with the fixed-point AC3 encoder.

Måns Rullgård mans
Sat Mar 12 16:02:59 CET 2011


Justin Ruggles <justin.ruggles at gmail.com> writes:

> ---
> Moved the shift>0 check out of the ac3dsp functions since it is not needed
> for ac3_rshift_int32().
>
> The x86 asm versions no longer benefit from ALIGN 8 after then shift>0 check
> was removed (only tested on x86-64).
>
> Unrolled the C versions, which makes them twice as fast on Athlon64.
>
>  libavcodec/ac3dsp.c         |   42 ++++++++++++++++++++++++++++++++++++++++
>  libavcodec/ac3dsp.h         |   22 +++++++++++++++++++++
>  libavcodec/ac3enc_fixed.c   |   41 +++-----------------------------------
>  libavcodec/x86/ac3dsp.asm   |   45 +++++++++++++++++++++++++++++++++++++++++++
>  libavcodec/x86/ac3dsp_mmx.c |   12 +++++++++++
>  5 files changed, 125 insertions(+), 37 deletions(-)
>
>
> diff --git a/libavcodec/ac3dsp.c b/libavcodec/ac3dsp.c
> index da3a123..9501be5 100644
> --- a/libavcodec/ac3dsp.c
> +++ b/libavcodec/ac3dsp.c
> @@ -50,10 +50,52 @@ static int ac3_max_msb_abs_int16_c(const int16_t *src, int len)
>      return v;
>  }
>
> +static void ac3_lshift_int16_c(int16_t *src, unsigned int len,
> +                               unsigned int shift)
> +{
> +    while (len > 0) {
> +        *src++ <<= shift;
> +        *src++ <<= shift;
> +        *src++ <<= shift;
> +        *src++ <<= shift;
> +        *src++ <<= shift;
> +        *src++ <<= shift;
> +        *src++ <<= shift;
> +        *src++ <<= shift;
> +        *src++ <<= shift;
> +        *src++ <<= shift;
> +        *src++ <<= shift;
> +        *src++ <<= shift;
> +        *src++ <<= shift;
> +        *src++ <<= shift;
> +        *src++ <<= shift;
> +        *src++ <<= shift;
> +        len -= 16;
> +    }
> +}

If you're going to optimise these, you should use a do/while loop
instead.  It will get rid of the initial check which you've already done
outside this function.

-- 
M?ns Rullg?rd
mans at mansr.com



More information about the ffmpeg-devel mailing list