[x265] [PATCH] picyuv: cleanup, remove always on padx, pady conditionals

deepthi at multicorewareinc.com deepthi at multicorewareinc.com
Fri Aug 14 07:38:59 CEST 2015


# HG changeset patch
# User Deepthi Nandakumar <deepthi at multicorewareinc.com>
# Date 1439530515 -19800
#      Fri Aug 14 11:05:15 2015 +0530
# Node ID b4ef42c9a18922a48f44799b3d9f8d3e2f6912f2
# Parent  409d6f7461223eddc17db7a45747b2b6450ff10c
picyuv: cleanup, remove always on padx, pady conditionals

diff -r 409d6f746122 -r b4ef42c9a189 source/common/picyuv.cpp
--- a/source/common/picyuv.cpp	Fri Aug 14 11:02:40 2015 +0530
+++ b/source/common/picyuv.cpp	Fri Aug 14 11:05:15 2015 +0530
@@ -232,60 +232,55 @@
     }
 
     /* extend the right edge if width was not multiple of the minimum CU size */
-    if (padx)
+
+    pixel *Y = m_picOrg[0];
+    pixel *U = m_picOrg[1];
+    pixel *V = m_picOrg[2];
+
+    uint64_t sumLuma = 0;
+    for (int r = 0; r < height; r++)
     {
-        pixel *Y = m_picOrg[0];
-        pixel *U = m_picOrg[1];
-        pixel *V = m_picOrg[2];
+        for (int c = 0; c < width; c++)
+        {
+            /* Clip luma of source picture to max and min values before extending edges of picYuv */
+            Y[c] = x265_clip3((pixel)param.minLuma, (pixel)param.maxLuma, Y[c]);
 
-        uint64_t sumLuma = 0;
-        for (int r = 0; r < height; r++)
+            /* Determine maximum and average luma level in a picture */
+            m_maxLumaLevel = X265_MAX(Y[c], m_maxLumaLevel);
+            sumLuma += Y[c];
+        }
+
+        for (int x = 0; x < padx; x++)
+            Y[width + x] = Y[width - 1];
+
+        Y += m_stride;
+    }
+    m_avgLumaLevel = (double)(sumLuma) / (m_picHeight * m_picWidth);
+
+    for (int r = 0; r < height >> m_vChromaShift; r++)
+    {
+        for (int x = 0; x < padx >> m_hChromaShift; x++)
         {
-            for (int c = 0; c < width; c++)
-            {
-                /* Clip luma of source picture to max and min values before extending edges of picYuv */
-                Y[c] = x265_clip3((pixel)param.minLuma, (pixel)param.maxLuma, Y[c]);
+            U[(width >> m_hChromaShift) + x] = U[(width >> m_hChromaShift) - 1];
+            V[(width >> m_hChromaShift) + x] = V[(width >> m_hChromaShift) - 1];
+        }
 
-                /* Determine maximum and average luma level in a picture */
-                m_maxLumaLevel = X265_MAX(Y[c], m_maxLumaLevel);
-                sumLuma += Y[c];
-            }
-
-            for (int x = 0; x < padx; x++)
-                Y[width + x] = Y[width - 1];
-
-            Y += m_stride;
-        }
-        m_avgLumaLevel = (double)(sumLuma) / (m_picHeight * m_picWidth);
-
-        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 += m_strideC;
-            V += m_strideC;
-        }
+        U += m_strideC;
+        V += m_strideC;
     }
 
     /* extend the bottom if height was not multiple of the minimum CU size */
-    if (pady)
+    Y = m_picOrg[0] + (height - 1) * m_stride;
+    U = m_picOrg[1] + ((height >> m_vChromaShift) - 1) * m_strideC;
+    V = m_picOrg[2] + ((height >> m_vChromaShift) - 1) * m_strideC;
+
+    for (int i = 1; i <= pady; i++)
+        memcpy(Y + i * m_stride, Y, (width + padx) * sizeof(pixel));
+
+    for (int j = 1; j <= pady >> m_vChromaShift; j++)
     {
-        pixel *Y = m_picOrg[0] + (height - 1) * m_stride;
-        pixel *U = m_picOrg[1] + ((height >> m_vChromaShift) - 1) * m_strideC;
-        pixel *V = m_picOrg[2] + ((height >> m_vChromaShift) - 1) * m_strideC;
-
-        for (int i = 1; i <= pady; i++)
-            memcpy(Y + i * m_stride, Y, (width + padx) * sizeof(pixel));
-
-        for (int j = 1; j <= pady >> m_vChromaShift; j++)
-        {
-            memcpy(U + j * m_strideC, U, ((width + padx) >> m_hChromaShift) * sizeof(pixel));
-            memcpy(V + j * m_strideC, V, ((width + padx) >> m_hChromaShift) * sizeof(pixel));
-        }
+        memcpy(U + j * m_strideC, U, ((width + padx) >> m_hChromaShift) * sizeof(pixel));
+        memcpy(V + j * m_strideC, V, ((width + padx) >> m_hChromaShift) * sizeof(pixel));
     }
 }
 


More information about the x265-devel mailing list