[x265] [PATCH] tcompicyuv: fix for copyFromPicture() when HIGH_BIT_DEPTH enable, sizeof(Pel)=2 and pic.bitDepth=8
Steve Borho
steve at borho.org
Thu Nov 7 08:41:40 CET 2013
On Thu, Nov 7, 2013 at 1:36 AM, Gopu Govindaswamy <gopu at multicorewareinc.com
> wrote:
> # 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
>
queued for default, but I saw some room for further improvements in this
file
>
> 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];
> + }
>
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:
for (int x = 0; x < padx; x++)
{
Y[width + x] = Y[width - 1];
}
> +
> + 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];
> + }
> +
>
and similar code here
> + 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 */
>
the Y padding can stay like it is
> + 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
> {
> _______________________________________________
> x265-devel mailing list
> x265-devel at videolan.org
> https://mailman.videolan.org/listinfo/x265-devel
>
--
Steve Borho
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/x265-devel/attachments/20131107/88f93edc/attachment.html>
More information about the x265-devel
mailing list