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

Mans Rullgard mans
Sun Sep 27 12:49:20 CEST 2009


---
 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;
+        }
+    } 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++;
+                tmp[j] = s;
+            }
+            for (j = 0; j < w; j++)
+                v[j][i] = tmp[j];
+        }
+    }
+}
+
 static void int32_to_float_fmul_scalar_c(float *dst, const int *src, float mul, int len){
     int i;
     for(i=0; i<len; i++)
@@ -4858,6 +4885,7 @@ void dsputil_init(DSPContext* c, AVCodecContext *avctx)
     c->sub_int16 = sub_int16_c;
     c->scalarproduct_int16 = scalarproduct_int16_c;
     c->scalarproduct_float = scalarproduct_float_c;
+    c->vector_fmul_matrix = ff_vector_fmul_matrix_c;
     c->butterflies_float = butterflies_float_c;
     c->vector_fmul_scalar = vector_fmul_scalar_c;
     c->vector_fmul_step_scalar = vector_fmul_step_scalar_c;
diff --git a/libavcodec/dsputil.h b/libavcodec/dsputil.h
index 86ea1d0..11cc1b6 100644
--- a/libavcodec/dsputil.h
+++ b/libavcodec/dsputil.h
@@ -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
-- 
1.6.4.4




More information about the ffmpeg-devel mailing list