[x265] [PATCH 1 of 3] primitives: added C primitives for upShift/downShift of input pixels

murugan at multicorewareinc.com murugan at multicorewareinc.com
Fri Mar 21 06:35:29 CET 2014


# HG changeset patch
# User Murugan Vairavel <murugan at multicorewareinc.com>
# Date 1395379028 -19800
#      Fri Mar 21 10:47:08 2014 +0530
# Node ID 0c4fdd43325e6501698a281862b1c027238a9c9d
# Parent  fe3fcd9838c02fb65fed8638a13dea9f06f8a9be
primitives: added C primitives for upShift/downShift of input pixels

diff -r fe3fcd9838c0 -r 0c4fdd43325e source/Lib/TLibCommon/TComPicYuv.cpp
--- a/source/Lib/TLibCommon/TComPicYuv.cpp	Thu Mar 20 19:06:54 2014 -0500
+++ b/source/Lib/TLibCommon/TComPicYuv.cpp	Fri Mar 21 10:47:08 2014 +0530
@@ -193,30 +193,9 @@
         uint8_t *uChar = (uint8_t*)pic.planes[1];
         uint8_t *vChar = (uint8_t*)pic.planes[2];
 
-        for (int r = 0; r < height; r++)
-        {
-            for (int c = 0; c < width; c++)
-            {
-                yPixel[c] = ((pixel)yChar[c]) << 2;
-            }
-
-            yPixel += getStride();
-            yChar += pic.stride[0] / sizeof(*yChar);
-        }
-
-        for (int r = 0; r < height >> m_vChromaShift; r++)
-        {
-            for (int c = 0; c < width >> m_hChromaShift; c++)
-            {
-                uPixel[c] = ((pixel)uChar[c]) << 2;
-                vPixel[c] = ((pixel)vChar[c]) << 2;
-            }
-
-            uPixel += getCStride();
-            vPixel += getCStride();
-            uChar += pic.stride[1] / sizeof(*uChar);
-            vChar += pic.stride[2] / sizeof(*vChar);
-        }
+        primitives.planecopy_cp(yChar, pic.stride[0] / sizeof(*yChar), yPixel, getStride(), width, height);
+        primitives.planecopy_cp(uChar, pic.stride[1] / sizeof(*uChar), uPixel, getCStride(), width >> m_hChromaShift, height >> m_vChromaShift);
+        primitives.planecopy_cp(vChar, pic.stride[2] / sizeof(*vChar), vPixel, getCStride(), width >> m_hChromaShift, height >> m_vChromaShift);
     }
     else if (pic.bitDepth == 8)
     {
@@ -268,30 +247,10 @@
         int shift = X265_MAX(0, pic.bitDepth - X265_DEPTH);
 
         /* shift and mask pixels to final size */
-        for (int r = 0; r < height; r++)
-        {
-            for (int c = 0; c < width; c++)
-            {
-                yPixel[c] = (pixel)((yShort[c] >> shift) & mask);
-            }
 
-            yPixel += getStride();
-            yShort += pic.stride[0] / sizeof(*yShort);
-        }
-
-        for (int r = 0; r < height >> m_vChromaShift; r++)
-        {
-            for (int c = 0; c < width >> m_hChromaShift; c++)
-            {
-                uPixel[c] = (pixel)((uShort[c] >> shift) & mask);
-                vPixel[c] = (pixel)((vShort[c] >> shift) & mask);
-            }
-
-            uPixel += getCStride();
-            vPixel += getCStride();
-            uShort += pic.stride[1] / sizeof(*uShort);
-            vShort += pic.stride[2] / sizeof(*vShort);
-        }
+        primitives.planecopy_sp(yShort, pic.stride[0] / sizeof(*yShort), yPixel, getStride(), width, height, shift, mask);
+        primitives.planecopy_sp(uShort, pic.stride[1] / sizeof(*uShort), uPixel, getCStride(), width >> m_hChromaShift, height >> m_vChromaShift, shift, mask);
+        primitives.planecopy_sp(vShort, pic.stride[2] / sizeof(*vShort), vPixel, getCStride(), width >> m_hChromaShift, height >> m_vChromaShift, shift, mask);
     }
 
     /* extend the right edge if width was not multiple of the minimum CU size */
diff -r fe3fcd9838c0 -r 0c4fdd43325e source/common/pixel.cpp
--- a/source/common/pixel.cpp	Thu Mar 20 19:06:54 2014 -0500
+++ b/source/common/pixel.cpp	Fri Mar 21 10:47:08 2014 +0530
@@ -852,6 +852,34 @@
         dst  += dstStride;
     }
 }
+
+void planecopy_cp_c(uint8_t *src, intptr_t srcStride, pixel *dst, intptr_t dstStride, int width, int height)
+{
+    for (int r = 0; r < height; r++)
+    {
+        for (int c = 0; c < width; c++)
+        {
+            dst[c] = ((pixel)src[c]) << 2;
+        }
+
+        dst += dstStride;
+        src += srcStride;
+    }
+}
+
+void planecopy_sp_c(uint16_t *src, intptr_t srcStride, pixel *dst, intptr_t dstStride, int width, int height, int shift, uint16_t mask)
+{
+    for (int r = 0; r < height; r++)
+    {
+        for (int c = 0; c < width; c++)
+        {
+            dst[c] = (pixel)((src[c] >> shift) & mask);
+        }
+
+        dst += dstStride;
+        src += srcStride;
+    }
+}
 }  // end anonymous namespace
 
 namespace x265 {
@@ -1099,5 +1127,7 @@
     p.var[BLOCK_32x32] = pixel_var<32>;
     p.var[BLOCK_64x64] = pixel_var<64>;
     p.plane_copy_deinterleave_c = plane_copy_deinterleave_chroma;
+    p.planecopy_cp = planecopy_cp_c;
+    p.planecopy_sp = planecopy_sp_c;
 }
 }
diff -r fe3fcd9838c0 -r 0c4fdd43325e source/common/primitives.h
--- a/source/common/primitives.h	Thu Mar 20 19:06:54 2014 -0500
+++ b/source/common/primitives.h	Fri Mar 21 10:47:08 2014 +0530
@@ -163,6 +163,8 @@
 typedef void (*addAvg_t)(int16_t* src0, int16_t* src1, pixel* dst, intptr_t src0Stride, intptr_t src1Stride, intptr_t dstStride);
 
 typedef void (*saoCuOrgE0_t)(pixel * rec, int8_t * offsetEo, int lcuWidth, int8_t signLeft);
+typedef void (*planecopy_cp_t) (uint8_t *src, intptr_t srcStride, pixel *dst, intptr_t dstStride, int width, int height);
+typedef void (*planecopy_sp_t) (uint16_t *src, intptr_t srcStride, pixel *dst, intptr_t dstStride, int width, int height, int shift, uint16_t mask);
 
 /* Define a structure containing function pointers to optimized encoder
  * primitives.  Each pointer can reference either an assembly routine,
@@ -233,6 +235,8 @@
     extendCURowBorder_t extendRowBorder;
     // sao primitives
     saoCuOrgE0_t      saoCuOrgE0;
+    planecopy_cp_t    planecopy_cp;
+    planecopy_sp_t    planecopy_sp;
 
     struct
     {


More information about the x265-devel mailing list