[x265] [PATCH] primitives: added C primitives for upShift/downShift input pixels
Steve Borho
steve at borho.org
Tue Mar 11 20:46:13 CET 2014
On Tue, Mar 11, 2014 at 4:18 AM, <murugan at multicorewareinc.com> wrote:
> # HG changeset patch
> # User Murugan Vairavel <murugan at multicorewareinc.com>
> # Date 1394529456 -19800
> # Tue Mar 11 14:47:36 2014 +0530
> # Node ID 6f60664fd99d54839cf8c71386d5419849e98b1f
> # Parent 1417ba917211abb9f4a43ff44ca28ad9d9a0ab43
> primitives: added C primitives for upShift/downShift input pixels
>
> diff -r 1417ba917211 -r 6f60664fd99d source/Lib/TLibCommon/TComPicYuv.cpp
> --- a/source/Lib/TLibCommon/TComPicYuv.cpp Mon Mar 10 16:59:22 2014 +0530
> +++ b/source/Lib/TLibCommon/TComPicYuv.cpp Tue Mar 11 14:47:36 2014 +0530
> @@ -193,30 +193,9 @@
> uint8_t *u = (uint8_t*)pic.planes[1];
> uint8_t *v = (uint8_t*)pic.planes[2];
>
> - for (int r = 0; r < height; r++)
> - {
> - for (int c = 0; c < width; c++)
> - {
> - Y[c] = ((pixel)y[c]) << 2;
> - }
> -
> - Y += getStride();
> - y += pic.stride[0] / sizeof(*y);
> - }
> -
> - for (int r = 0; r < height >> m_vChromaShift; r++)
> - {
> - for (int c = 0; c < width >> m_hChromaShift; c++)
> - {
> - U[c] = ((pixel)u[c]) << 2;
> - V[c] = ((pixel)v[c]) << 2;
> - }
> -
> - U += getCStride();
> - V += getCStride();
> - u += pic.stride[1] / sizeof(*u);
> - v += pic.stride[2] / sizeof(*v);
> - }
> + primitives.upShift(y, pic.stride[0] / sizeof(*y), Y,getStride(), width, height);
> + primitives.upShift(u, pic.stride[1] / sizeof(*u), U,getStride(), width >> m_hChromaShift, height >> m_vChromaShift);
> + primitives.upShift(v, pic.stride[2] / sizeof(*v), V,getStride(), width >> m_hChromaShift, height >> m_vChromaShift);
pretty sure those should be U, getCStride(), and V, getCStride(). plus
it is missing some spaces
> }
> else if (pic.bitDepth == 8)
> {
> @@ -268,30 +247,9 @@
> 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++)
> - {
> - Y[c] = (pixel)((y[c] >> shift) & mask);
> - }
> -
> - Y += getStride();
> - y += pic.stride[0] / sizeof(*y);
> - }
> -
> - for (int r = 0; r < height >> m_vChromaShift; r++)
> - {
> - for (int c = 0; c < width >> m_hChromaShift; c++)
> - {
> - U[c] = (pixel)((u[c] >> shift) & mask);
> - V[c] = (pixel)((v[c] >> shift) & mask);
> - }
> -
> - U += getCStride();
> - V += getCStride();
> - u += pic.stride[1] / sizeof(*u);
> - v += pic.stride[2] / sizeof(*v);
> - }
> + primitives.downShift(y, pic.stride[0] / sizeof(*y), Y,getCStride(), width, height, shift, mask);
and this should be Y, getStride()
> + primitives.downShift(u, pic.stride[1] / sizeof(*u), U,getCStride(), width >> m_hChromaShift, height >> m_vChromaShift, shift, mask);
> + primitives.downShift(v, pic.stride[2] / sizeof(*v), V,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 1417ba917211 -r 6f60664fd99d source/common/pixel.cpp
> --- a/source/common/pixel.cpp Mon Mar 10 16:59:22 2014 +0530
> +++ b/source/common/pixel.cpp Tue Mar 11 14:47:36 2014 +0530
> @@ -852,6 +852,34 @@
> dst += dstStride;
> }
> }
> +
> +void upShift(uint8_t *src, int srcStride, pixel *dst, int 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 downShift(uint16_t *src, int srcStride, pixel *dst, int 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.upShift = upShift;
> + p.downShift = downShift;
> }
> }
> diff -r 1417ba917211 -r 6f60664fd99d source/common/primitives.h
> --- a/source/common/primitives.h Mon Mar 10 16:59:22 2014 +0530
> +++ b/source/common/primitives.h Tue Mar 11 14:47:36 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 (*upShift_t) (uint8_t *src, int srcStride, pixel *dst, int dstStride, int width, int height);
> +typedef void (*downShift_t) (uint16_t *src, int srcStride, pixel *dst, int 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;
> + upShift_t upShift;
> + downShift_t downShift;
>
> struct
> {
> _______________________________________________
> x265-devel mailing list
> x265-devel at videolan.org
> https://mailman.videolan.org/listinfo/x265-devel
--
Steve Borho
More information about the x265-devel
mailing list