changeset 4170:3a2297992a24

primitives: add pixelavg primitive
author Deepthi Devaki <deepthidevaki@multicorewareinc.com>
date Thu, 03 Oct 2013 09:21:30 +0530
parents 2d04a0bb09c3
children a6a0e6e90536
files source/common/pixel.cpp source/common/primitives.h
diffstat 2 files changed, 19 insertions(+-), 0 deletions(-) [+]
line wrap: on
line diff
--- a/source/common/pixel.cpp	Thu Oct 03 18:17:34 2013 +0530
+++ b/source/common/pixel.cpp	Thu Oct 03 09:21:30 2013 +0530
@@ -579,6 +579,22 @@ void pixeladd_pp_c(int bx, int by, pixel
     }
 }
 
+template<int lx, int ly>
+void pixelavg_pp(pixel* dst, intptr_t dstride, pixel* src0, pixel* src1, intptr_t sstride0, intptr_t sstride1)
+{
+    for (int y = 0; y < ly; y++)
+    {
+        for (int x = 0; x < lx; x++)
+        {
+            dst[x] = (src0[x] + src1[x] + 1) >> 1;
+        }
+
+        src0 += sstride0;
+        src1 += sstride1;
+        dst += dstride;
+    }
+}
+
 void scale1D_128to64(pixel *dst, pixel *src, intptr_t /*stride*/)
 {
     int x;
@@ -648,6 +664,7 @@ void Setup_C_PixelPrimitives(EncoderPrim
     SET_FUNC_PRIMITIVE_TABLE_C2(sad)
     SET_FUNC_PRIMITIVE_TABLE_C2(sad_x3)
     SET_FUNC_PRIMITIVE_TABLE_C2(sad_x4)
+    SET_FUNC_PRIMITIVE_TABLE_C2(pixelavg_pp)
 
     // satd
     p.satd[PARTITION_4x4]   = satd_4x4;
--- a/source/common/primitives.h	Thu Oct 03 18:17:34 2013 +0530
+++ b/source/common/primitives.h	Thu Oct 03 09:21:30 2013 +0530
@@ -196,6 +196,7 @@ typedef void (*blockcpy_sc_t)(int bx, in
 typedef void (*pixelsub_sp_t)(int bx, int by, short *dst, intptr_t dstride, pixel *src0, pixel *src1, intptr_t sstride0, intptr_t sstride1);
 typedef void (*pixeladd_ss_t)(int bx, int by, short *dst, intptr_t dstride, short *src0, short *src1, intptr_t sstride0, intptr_t sstride1);
 typedef void (*pixeladd_pp_t)(int bx, int by, pixel *dst, intptr_t dstride, pixel *src0, pixel *src1, intptr_t sstride0, intptr_t sstride1);
+typedef void (*pixelavg_pp_t)(pixel *dst, intptr_t dstride, pixel *src0, pixel *src1, intptr_t sstride0, intptr_t sstride1);
 typedef void (*blockfil_s_t)(short *dst, intptr_t dstride, short val);
 
 typedef void (*intra_dc_t)(pixel* above, pixel* left, pixel* dst, intptr_t dstStride, int width, int bFilter);
@@ -292,6 +293,7 @@ struct EncoderPrimitives
     pixelsub_sp_t   pixelsub_sp;
     pixeladd_ss_t   pixeladd_ss;
     pixeladd_pp_t   pixeladd_pp;
+    pixelavg_pp_t   pixelavg_pp[NUM_PARTITIONS];
 
     filterVwghtd_t  filterVwghtd;
     filterHwghtd_t  filterHwghtd;