<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Nov 7, 2013 at 1:36 AM, Gopu Govindaswamy <span dir="ltr"><<a href="mailto:gopu@multicorewareinc.com" target="_blank">gopu@multicorewareinc.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"># HG changeset patch<br>
# User Gopu Govindaswamy <<a href="mailto:gopu@multicorewareinc.com">gopu@multicorewareinc.com</a>><br>
# Date 1383809753 -19800<br>
# Node ID 013defdbd19792c7ccb73128c965be295ac840e3<br>
# Parent  93cccbe49a93dd4c054ef06aca76974948793613<br>
tcompicyuv: fix for copyFromPicture() when HIGH_BIT_DEPTH enable, sizeof(Pel)=2 and pic.bitDepth=8<br></blockquote><div><br></div><div>queued for default, but I saw some room for further improvements in this file</div><div>
 </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<br>
diff -r 93cccbe49a93 -r 013defdbd197 source/Lib/TLibCommon/TComPicYuv.cpp<br>
--- a/source/Lib/TLibCommon/TComPicYuv.cpp      Wed Nov 06 19:49:38 2013 -0600<br>
+++ b/source/Lib/TLibCommon/TComPicYuv.cpp      Thu Nov 07 13:05:53 2013 +0530<br>
@@ -423,6 +423,93 @@<br>
             }<br>
         }<br>
     }<br>
+    else if(pic.bitDepth == 8)<br>
+    {<br>
+        uint8_t *y = (uint8_t*)pic.planes[0];<br>
+        uint8_t *u = (uint8_t*)pic.planes[1];<br>
+        uint8_t *v = (uint8_t*)pic.planes[2];<br>
+<br>
+        /* width and height - without padsize */<br>
+        int width = m_picWidth - padx;<br>
+        int height = m_picHeight - pady;<br>
+<br>
+        // Manually copy pixels to up-size them<br>
+        for (int r = 0; r < height; r++)<br>
+        {<br>
+            for (int c = 0; c < width; c++)<br>
+            {<br>
+                Y[c] = (Pel)y[c];<br>
+            }<br></blockquote><div><br></div><div>in both this loop and the one above, here would be the best place to extend each row; this would be much more cache line friendly.  ie: add these lines here:</div><div><br>
</div><div>               for (int x = 0; x < padx; x++)</div>               {<br>                   Y[width + x] = Y[width - 1];<br>               }<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
 +<br>
+            Y += getStride();<br>
+            y += pic.stride[0];<br>
+        }<br>
+<br>
+        for (int r = 0; r < height >> m_vChromaShift; r++)<br>
+        {<br>
+            for (int c = 0; c < width >> m_hChromaShift; c++)<br>
+            {<br>
+                U[c] = (Pel)u[c];<br>
+                V[c] = (Pel)v[c];<br>
+            }<br>
+<br></blockquote><div><br></div><div>and similar code here</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

+            U += getCStride();<br>
+            V += getCStride();<br>
+            u += pic.stride[1];<br>
+            v += pic.stride[2];<br>
+        }<br>
+<br>
+        /* Extend the right if width is not multiple of minimum CU size */<br>
+<br>
+        if (padx)<br>
+        {<br>
+            Y = getLumaAddr();<br>
+            U = getCbAddr();<br>
+            V = getCrAddr();<br>
+<br>
+            for (int r = 0; r < height; r++)<br>
+            {<br>
+                for (int x = 0; x < padx; x++)<br>
+                {<br>
+                    Y[width + x] = Y[width - 1];<br>
+                }<br>
+<br>
+                Y += getStride();<br>
+            }<br>
+<br>
+            for (int r = 0; r < height >> m_vChromaShift; r++)<br>
+            {<br>
+                for (int x = 0; x < padx >> m_hChromaShift; x++)<br>
+                {<br>
+                    U[(width >> m_hChromaShift) + x] = U[(width >> m_hChromaShift) - 1];<br>
+                    V[(width >> m_hChromaShift) + x] = V[(width >> m_hChromaShift) - 1];<br>
+                }<br>
+<br>
+                U += getCStride();<br>
+                V += getCStride();<br>
+            }<br>
+        }<br>
+<br>
+        /* extend the bottom if height is not multiple of the minimum CU size */<br></blockquote><div><br></div><div>the Y padding can stay like it is</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

+        if (pady)<br>
+        {<br>
+            width = m_picWidth;<br>
+            Y = getLumaAddr() + (height - 1) * getStride();<br>
+            U = getCbAddr() + ((height >> m_vChromaShift) - 1) * getCStride();<br>
+            V = getCrAddr() + ((height >> m_vChromaShift) - 1) * getCStride();<br>
+<br>
+            for (uint32_t i = 1; i <= pady; i++)<br>
+            {<br>
+                memcpy(Y + i * getStride(), Y, width * sizeof(Pel));<br>
+            }<br>
+<br>
+            for (uint32_t j = 1; j <= pady >> m_vChromaShift; j++)<br>
+            {<br>
+                memcpy(U + j * getCStride(), U, (width >> m_hChromaShift) * sizeof(Pel));<br>
+                memcpy(V + j * getCStride(), V, (width >> m_hChromaShift) * sizeof(Pel));<br>
+            }<br>
+        }<br>
+    }<br>
     else<br>
 #endif // if HIGH_BIT_DEPTH<br>
     {<br>
_______________________________________________<br>
x265-devel mailing list<br>
<a href="mailto:x265-devel@videolan.org">x265-devel@videolan.org</a><br>
<a href="https://mailman.videolan.org/listinfo/x265-devel" target="_blank">https://mailman.videolan.org/listinfo/x265-devel</a><br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>Steve Borho
</div></div>