[FFmpeg-devel] [PATCH 04/12] Add vector_fmul_matrix to dsputil

Michael Niedermayer michaelni
Sun Oct 18 22:06:47 CEST 2009


On Sun, Sep 27, 2009 at 11:49:20AM +0100, Mans Rullgard wrote:
> ---
>  libavcodec/dsputil.c |   28 ++++++++++++++++++++++++++++
>  libavcodec/dsputil.h |    2 ++
>  2 files changed, 30 insertions(+), 0 deletions(-)
> 
> diff --git a/libavcodec/dsputil.c b/libavcodec/dsputil.c
> index ab916b7..b2cb0e3 100644
> --- a/libavcodec/dsputil.c
> +++ b/libavcodec/dsputil.c
> @@ -4178,6 +4178,33 @@ static float scalarproduct_float_c(const float *v1, const float *v2, int len)
>      return p;
>  }
>  
> +void ff_vector_fmul_matrix_c(float **v, const float *mtx, int len, int w,
> +                             float *restrict tmp)
> +{
> +    int i, j, k;
> +
> +    if (w == 2) {
> +        for (i = 0; i < len; i++) {
> +            float v0 = v[0][i]*mtx[0] + v[1][i]*mtx[1];
> +            float v1 = v[0][i]*mtx[2] + v[1][i]*mtx[3];
> +            v[0][i] = v0;
> +            v[1][i] = v1;

v1 is redundant, it can be written directly


> +        }
> +    } else {
> +        for (i = 0; i < len; i++) {
> +            const float *m = mtx;
> +            for (j = 0; j < w; j++) {
> +                float s = 0;

> +                for (k = 0; k < w; k++)
> +                    s += v[k][i] * *m++;

this is quite inefficient because for(k) v[k][i] needs 2 memory reads
a flat 2d array would be better


[...]

> @@ -445,6 +445,8 @@ typedef struct DSPContext {
>       * @param len length of vectors, multiple of 4
>       */
>      float (*scalarproduct_float)(const float *v1, const float *v2, int len);
> +    void (*vector_fmul_matrix)(float **v, const float *mtx, int len, int w,
> +                               float *restrict tmp);
>      /**
>       * Calculate the sum and difference of two vectors of floats.
>       * @param v1  first input vector, sum output, 16-byte aligned

missing doxy explaining what this does
(in case you wonder why do i complain and you would add it before commit
 its because it makes review easier if one can check the API without
 reverse engeneering it from the code ...)


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

Many that live deserve death. And some that die deserve life. Can you give
it to them? Then do not be too eager to deal out death in judgement. For
even the very wise cannot see all ends. -- Gandalf
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20091018/58a25db3/attachment.pgp>



More information about the ffmpeg-devel mailing list