[FFmpeg-devel] [PATCH 3/3] Use DSPContext.vector_fmul() and DSPContext.vector_fmul_reverse() in floating-point version of apply_window(). 46% faster in function apply_window().

Michael Niedermayer michaelni
Sun Jan 2 04:09:11 CET 2011


On Fri, Dec 31, 2010 at 03:11:40PM -0500, Justin Ruggles wrote:
> ---
>  libavcodec/ac3enc.c       |    4 ++--
>  libavcodec/ac3enc_fixed.c |    2 +-
>  libavcodec/ac3enc_float.c |   11 ++++-------
>  3 files changed, 7 insertions(+), 10 deletions(-)
> 

>  ac3enc.c       |    4 ++--
>  ac3enc_fixed.c |    2 +-
>  ac3enc_float.c |   11 ++++-------
>  3 files changed, 7 insertions(+), 10 deletions(-)
> 7ff4adfd7085b5e627cb0db126b15b9b061a9955  0003-Use-DSPContext.vector_fmul-and-DSPContext.vector_fmu.patch
> diff --git libavcodec/ac3enc.c libavcodec/ac3enc.c
> index 8ef061d..98bdd1e 100644
> --- libavcodec/ac3enc.c
> +++ libavcodec/ac3enc.c
> @@ -148,7 +148,7 @@ static av_cold int mdct_init(AVCodecContext *avctx, AC3MDCTContext *mdct,
>  
>  static void mdct512(AC3MDCTContext *mdct, CoefType *out, SampleType *in);
>  
> -static void apply_window(SampleType *output, const SampleType *input,
> +static void apply_window(DSPContext *dsp, SampleType *output, const SampleType *input,
>                           const SampleType *window, int n);
>  
>  static int normalize_samples(AC3EncodeContext *s);
> @@ -247,7 +247,7 @@ static void apply_mdct(AC3EncodeContext *s)
>              AC3Block *block = &s->blocks[blk];
>              const SampleType *input_samples = &s->planar_samples[ch][blk * AC3_BLOCK_SIZE];
>  
> -            apply_window(s->windowed_samples, input_samples, s->mdct.window, AC3_WINDOW_SIZE);
> +            apply_window(&s->dsp, s->windowed_samples, input_samples, s->mdct.window, AC3_WINDOW_SIZE);
>  
>              block->exp_shift[ch] = normalize_samples(s);
>  
> diff --git libavcodec/ac3enc_fixed.c libavcodec/ac3enc_fixed.c
> index 9d3b195..9fff6d8 100644
> --- libavcodec/ac3enc_fixed.c
> +++ libavcodec/ac3enc_fixed.c
> @@ -251,7 +251,7 @@ static void mdct512(AC3MDCTContext *mdct, int32_t *out, int16_t *in)
>  /**
>   * Apply KBD window to input samples prior to MDCT.
>   */
> -static void apply_window(int16_t *output, const int16_t *input,
> +static void apply_window(DSPContext *dsp, int16_t *output, const int16_t *input,
>                           const int16_t *window, int n)
>  {
>      int i;
> diff --git libavcodec/ac3enc_float.c libavcodec/ac3enc_float.c
> index 6a061d6..addc84f 100644
> --- libavcodec/ac3enc_float.c
> +++ libavcodec/ac3enc_float.c
> @@ -77,16 +77,13 @@ static void mdct512(AC3MDCTContext *mdct, float *out, float *in)
>  /**
>   * Apply KBD window to input samples prior to MDCT.
>   */
> -static void apply_window(float *output, const float *input,
> +static void apply_window(DSPContext *dsp, float *output, const float *input,
>                           const float *window, int n)
>  {
> -    int i;
>      int n2 = n >> 1;
> -
> -    for (i = 0; i < n2; i++) {
> -        output[i]     = input[i]     * window[i];
> -        output[n-i-1] = input[n-i-1] * window[i];
> -    }
> +    memcpy(output, input, n2 * sizeof(*input));
> +    dsp->vector_fmul(output, window, n2);
> +    dsp->vector_fmul_reverse(output+n2, input+n2, window, n2);

The memcpy is ugly

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

When you are offended at any man's fault, turn to yourself and study your
own failings. Then you will forget your anger. -- Epictetus
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20110102/3015fc85/attachment.pgp>



More information about the ffmpeg-devel mailing list