[x265] [PATCH] Adapting lowress frame dimensions to multiples of lowress CU size
shazeb at multicorewareinc.com
shazeb at multicorewareinc.com
Mon Sep 23 11:15:19 CEST 2013
# HG changeset patch
# User Shazeb Nawaz Khan <shazeb at multicorewareinc.com>
# Date 1379926862 -19800
# Mon Sep 23 14:31:02 2013 +0530
# Node ID fad6eaab768aeb01f2dc865062271366400edb8c
# Parent ff797c5087ae1547b01168eecc300cf7be981243
Adapting lowress frame dimensions to multiples of lowress CU size.
The full res frame is required to be extended accordingly to achieve a lowres frame with dimensions in multiples of lowres CU size.
diff -r ff797c5087ae -r fad6eaab768a source/common/lowres.cpp
--- a/source/common/lowres.cpp Fri Sep 20 14:21:29 2013 -0500
+++ b/source/common/lowres.cpp Mon Sep 23 14:31:02 2013 +0530
@@ -37,6 +37,13 @@
lumaStride = width + 2 * orig->getLumaMarginX();
if (lumaStride & 31)
lumaStride += 32 - (lumaStride & 31);
+ int cuWidth = (width + X265_LOWRES_CU_SIZE - 1) >> X265_LOWRES_CU_BITS;
+ int cuHeight = (lines + X265_LOWRES_CU_SIZE - 1) >> X265_LOWRES_CU_BITS;
+ int cuCount = cuWidth * cuHeight;
+
+ /* rounding the width to multiple of lowres CU size */
+ width = cuWidth * X265_LOWRES_CU_SIZE;
+ lines = cuHeight * X265_LOWRES_CU_SIZE;
/* allocate lowres buffers */
for (int i = 0; i < 4; i++)
@@ -50,10 +57,6 @@
lowresPlane[2] = buffer[2] + padoffset;
lowresPlane[3] = buffer[3] + padoffset;
- int cuWidth = (width + X265_LOWRES_CU_SIZE - 1) >> X265_LOWRES_CU_BITS;
- int cuHeight = (lines + X265_LOWRES_CU_SIZE - 1) >> X265_LOWRES_CU_BITS;
- int cuCount = cuWidth * cuHeight;
-
intraCost = (int*)X265_MALLOC(int, cuCount);
for (int i = 0; i < bframes + 2; i++)
@@ -127,6 +130,31 @@
lowresMvs[1][i][0].x = 0x7FFF;
}
+ int y, extWidth = (orig->getWidth() + X265_LOWRES_CU_SIZE - 1);
+ int srcStride = orig->getStride();
+ int srcHeight = orig->getHeight();
+ int srcWidth = orig->getWidth();
+ Pel *src;
+ src = orig->getLumaAddr();
+
+ /* extending right margin*/
+ if( 2 * width > orig->getWidth())
+ {
+ for (y = 0; y < srcHeight; y++)
+ {
+ ::memset(src+srcWidth, src[srcWidth-1], sizeof(Pel) * (X265_LOWRES_CU_SIZE - 1));
+ src += srcStride;
+ }
+ }
+
+ /* extending bottom margin */
+ src = orig->getLumaAddr() + (srcHeight - 1 ) * srcStride;
+
+ for (y = 1; y <= 2 * lines - srcHeight; y++)
+ {
+ ::memcpy(src + y * srcStride, src, sizeof(Pel) * (extWidth));
+ }
+
/* downscale and generate 4 HPEL planes for lookahead */
primitives.frame_init_lowres_core(orig->getLumaAddr(),
lowresPlane[0], lowresPlane[1], lowresPlane[2], lowresPlane[3],
More information about the x265-devel
mailing list