[x265] [PATCH] tcompicyuv: fix for copyFromPicture() when HIGH_BIT_DEPTH enable, sizeof(Pel)=2 and pic.bitDepth=8

Gopu Govindaswamy gopu at multicorewareinc.com
Thu Nov 7 08:36:05 CET 2013


# HG changeset patch
# User Gopu Govindaswamy <gopu at multicorewareinc.com>
# Date 1383809753 -19800
# Node ID 013defdbd19792c7ccb73128c965be295ac840e3
# Parent  93cccbe49a93dd4c054ef06aca76974948793613
tcompicyuv: fix for copyFromPicture() when HIGH_BIT_DEPTH enable, sizeof(Pel)=2 and pic.bitDepth=8

diff -r 93cccbe49a93 -r 013defdbd197 source/Lib/TLibCommon/TComPicYuv.cpp
--- a/source/Lib/TLibCommon/TComPicYuv.cpp	Wed Nov 06 19:49:38 2013 -0600
+++ b/source/Lib/TLibCommon/TComPicYuv.cpp	Thu Nov 07 13:05:53 2013 +0530
@@ -423,6 +423,93 @@
             }
         }
     }
+    else if(pic.bitDepth == 8)
+    {
+        uint8_t *y = (uint8_t*)pic.planes[0];
+        uint8_t *u = (uint8_t*)pic.planes[1];
+        uint8_t *v = (uint8_t*)pic.planes[2];
+
+        /* width and height - without padsize */
+        int width = m_picWidth - padx;
+        int height = m_picHeight - pady;
+
+        // Manually copy pixels to up-size them
+        for (int r = 0; r < height; r++)
+        {
+            for (int c = 0; c < width; c++)
+            {
+                Y[c] = (Pel)y[c];
+            }
+
+            Y += getStride();
+            y += pic.stride[0];
+        }
+
+        for (int r = 0; r < height >> m_vChromaShift; r++)
+        {
+            for (int c = 0; c < width >> m_hChromaShift; c++)
+            {
+                U[c] = (Pel)u[c];
+                V[c] = (Pel)v[c];
+            }
+
+            U += getCStride();
+            V += getCStride();
+            u += pic.stride[1];
+            v += pic.stride[2];
+        }
+
+        /* Extend the right if width is not multiple of minimum CU size */
+
+        if (padx)
+        {
+            Y = getLumaAddr();
+            U = getCbAddr();
+            V = getCrAddr();
+
+            for (int r = 0; r < height; r++)
+            {
+                for (int x = 0; x < padx; x++)
+                {
+                    Y[width + x] = Y[width - 1];
+                }
+
+                Y += getStride();
+            }
+
+            for (int r = 0; r < height >> m_vChromaShift; r++)
+            {
+                for (int x = 0; x < padx >> m_hChromaShift; x++)
+                {
+                    U[(width >> m_hChromaShift) + x] = U[(width >> m_hChromaShift) - 1];
+                    V[(width >> m_hChromaShift) + x] = V[(width >> m_hChromaShift) - 1];
+                }
+
+                U += getCStride();
+                V += getCStride();
+            }
+        }
+
+        /* extend the bottom if height is not multiple of the minimum CU size */
+        if (pady)
+        {
+            width = m_picWidth;
+            Y = getLumaAddr() + (height - 1) * getStride();
+            U = getCbAddr() + ((height >> m_vChromaShift) - 1) * getCStride();
+            V = getCrAddr() + ((height >> m_vChromaShift) - 1) * getCStride();
+
+            for (uint32_t i = 1; i <= pady; i++)
+            {
+                memcpy(Y + i * getStride(), Y, width * sizeof(Pel));
+            }
+
+            for (uint32_t j = 1; j <= pady >> m_vChromaShift; j++)
+            {
+                memcpy(U + j * getCStride(), U, (width >> m_hChromaShift) * sizeof(Pel));
+                memcpy(V + j * getCStride(), V, (width >> m_hChromaShift) * sizeof(Pel));
+            }
+        }
+    }
     else
 #endif // if HIGH_BIT_DEPTH
     {


More information about the x265-devel mailing list