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

Reimar Döffinger Reimar.Doeffinger
Tue Sep 29 16:11:59 CEST 2009


On Sun, Sep 27, 2009 at 11:49:27AM +0100, 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);

Hm, I'd suggest to remove the y variable and instead add int ch one
level lower and used that, makes more sense to use "ch" to iterate over
channels than using "y".
The extra "mat" variable seems a bit pointless to me, too.
Apart from that it seems to make sense to me if it is generally faster
(I'd hope so, otherwise vector_fmul_matrix would be quite useless).



More information about the ffmpeg-devel mailing list