[FFmpeg-devel] [PATCH 11/12] WMAPRO: use vector_fmul_matrix()

Sascha Sommer saschasommer
Tue Sep 29 21:38:10 CEST 2009


Hi,

On Sonntag, 27. September 2009, Mans Rullgard wrote:
> ---
>  libavcodec/wmaprodec.c |   27 +++++++--------------------
>  1 files changed, 7 insertions(+), 20 deletions(-)
>
> diff --git a/libavcodec/wmaprodec.c b/libavcodec/wmaprodec.c
> index ac559a4..e483733 100644
> --- a/libavcodec/wmaprodec.c
> +++ b/libavcodec/wmaprodec.c
> @@ -956,36 +956,23 @@ static void inverse_channel_transform(WMAProDecodeCtx
> *s) float data[WMAPRO_MAX_CHANNELS];
>              const int num_channels = s->chgroup[i].num_channels;
>              float** ch_data = s->chgroup[i].channel_data;
> -            float** ch_end = ch_data + num_channels;
>              const int8_t* tb = s->chgroup[i].transform_band;
>              int16_t* sfb;
>
>              /** multichannel decorrelation */
>              for (sfb = s->cur_sfb_offsets;
>                   sfb < s->cur_sfb_offsets + s->num_bands; sfb++) {
> +                int len = FFMIN(sfb[1], s->subframe_len) - sfb[0];
>                  int y;
>                  if (*tb++ == 1) {
>                      /** multiply values with the decorrelation_matrix */
> -                    for (y = sfb[0]; y < FFMIN(sfb[1], s->subframe_len);
> y++) { -                        const float* mat =
> s->chgroup[i].decorrelation_matrix; -                        const float*
> data_end = data + num_channels; -                        float* data_ptr =
> data;
> -                        float** ch;
> -
> -                        for (ch = ch_data; ch < ch_end; ch++)
> -                            *data_ptr++ = (*ch)[y];
> -
> -                        for (ch = ch_data; ch < ch_end; ch++) {
> -                            float sum = 0;
> -                            data_ptr = data;
> -                            while (data_ptr < data_end)
> -                                sum += *data_ptr++ * *mat++;
> -
> -                            (*ch)[y] = sum;
> -                        }
> -                    }
> +                    const float* mat = s->chgroup[i].decorrelation_matrix;
> +                    float *chp[WMAPRO_MAX_CHANNELS];
> +                    for (y = 0; y < num_channels; y++)
> +                        chp[y] = ch_data[y] + sfb[0];
> +                    s->dsp.vector_fmul_matrix(chp, mat, len, num_channels,
> +                                              data);
>                  } else if (s->num_channels == 2) {
> -                    int len = FFMIN(sfb[1], s->subframe_len) - sfb[0];
>                      s->dsp.vector_fmul_scalar(ch_data[0] + sfb[0],
>                                                ch_data[0] + sfb[0],
>                                                181.0 / 128, len);


Nice. Looks ok apart from the points mentioned by Reimar.
I only wonder if special alignment might sometimes be needed for the arrays 
that are passed to vector_fmul_matrix?
Also one could now get rid of ch_data and use s->chgroup[i].channel_data 
directly if this is not slower.

Regards

Sascha



More information about the ffmpeg-devel mailing list