[x265] [PATCH 2 of 3] Adding C primitive for luma vps filter functions

nabajit at multicorewareinc.com nabajit at multicorewareinc.com
Tue Nov 5 08:22:50 CET 2013


# HG changeset patch
# User Nabajit Deka
# Date 1383635862 -19800
#      Tue Nov 05 12:47:42 2013 +0530
# Node ID a1644f4f03eb425830a0e9a547912dc411f078d9
# Parent  88a476ed9ed2ccfa2964a15a9f5795b79b99a195
Adding C primitive for luma vps filter functions.

diff -r 88a476ed9ed2 -r a1644f4f03eb source/common/ipfilter.cpp
--- a/source/common/ipfilter.cpp	Tue Nov 05 12:45:18 2013 +0530
+++ b/source/common/ipfilter.cpp	Tue Nov 05 12:47:42 2013 +0530
@@ -422,6 +422,44 @@
         dst += dstStride;
     }
 }
+
+template<int N, int width, int height>
+void interp_vert_ps_c(pixel *src, intptr_t srcStride, int16_t *dst, intptr_t dstStride, int coeffIdx)
+{
+    int16_t const * c = (N == 4) ? g_chromaFilter[coeffIdx] : g_lumaFilter[coeffIdx];
+    int headRoom = IF_INTERNAL_PREC - X265_DEPTH;
+    int shift = IF_FILTER_PREC - headRoom;
+    int offset = -IF_INTERNAL_OFFS << shift;
+    src -= (N / 2 - 1) * srcStride;
+
+    int row, col;
+    for (row = 0; row < height; row++)
+    {
+        for (col = 0; col < width; col++)
+        {
+            int sum;
+
+            sum  = src[col + 0 * srcStride] * c[0];
+            sum += src[col + 1 * srcStride] * c[1];
+            sum += src[col + 2 * srcStride] * c[2];
+            sum += src[col + 3 * srcStride] * c[3];
+            if (N == 8)
+            {
+                sum += src[col + 4 * srcStride] * c[4];
+                sum += src[col + 5 * srcStride] * c[5];
+                sum += src[col + 6 * srcStride] * c[6];
+                sum += src[col + 7 * srcStride] * c[7];
+            }
+
+            int16_t val = (int16_t)((sum + offset) >> shift);
+            dst[col] = val;
+        }
+
+        src += srcStride;
+        dst += dstStride;
+    }
+}
+
 typedef void (*ipfilter_ps_t)(pixel *src, intptr_t srcStride, short *dst, intptr_t dstStride, int width, int height, const short *coeff);
 typedef void (*ipfilter_sp_t)(short *src, intptr_t srcStride, pixel *dst, intptr_t dstStride, int width, int height, const short *coeff);
 
@@ -445,6 +483,7 @@
 #define LUMA(W, H) \
     p.luma_hpp[LUMA_ ## W ## x ## H]     = interp_horiz_pp_c<8, W, H>;\
     p.luma_vpp[LUMA_ ## W ## x ## H]     = interp_vert_pp_c<8, W, H>; \
+    p.luma_vps[LUMA_ ## W ## x ## H]     = interp_vert_ps_c<8, W, H>; \
     p.luma_hvpp[LUMA_ ## W ## x ## H]    = interp_hv_pp_c<8, W, H>;
 
 void Setup_C_IPFilterPrimitives(EncoderPrimitives& p)


More information about the x265-devel mailing list