<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jun 21, 2017 at 12:14 PM, <span dir="ltr"><<a href="mailto:kavitha@multicorewareinc.com" target="_blank">kavitha@multicorewareinc.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"># HG changeset patch<br>
# User Kavitha Sampath <<a href="mailto:kavitha@multicorewareinc.com">kavitha@multicorewareinc.com</a>><br>
# Date 1498023302 -19800<br>
# Wed Jun 21 11:05:02 2017 +0530<br>
# Node ID 68b27c44790d200ceb95b26962a84c<wbr>8230d29eba<br>
# Parent 4436e1ca6f3987292dea608c7ecb27<wbr>80fdcfc4df<br>
replace global g_maxCUSize with param->maxCUSize<br></blockquote><div><br></div><div>This will enable running multiple instances of x265 in the same application with different maxCUsizes. Thanks!</div><div>Pushed the full set of 7 patches into default branch</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
diff -r 4436e1ca6f39 -r 68b27c44790d source/common/cudata.cpp<br>
--- a/source/common/cudata.cpp Tue Jun 20 16:38:20 2017 +0530<br>
+++ b/source/common/cudata.cpp Wed Jun 21 11:05:02 2017 +0530<br>
@@ -119,8 +119,9 @@<br>
memset(this, 0, sizeof(*this));<br>
}<br>
<br>
-void CUData::initialize(const CUDataMemPool& dataPool, uint32_t depth, int csp, int instance)<br>
+void CUData::initialize(const CUDataMemPool& dataPool, uint32_t depth, const x265_param& param, int instance)<br>
{<br>
+ int csp = param.internalCsp;<br>
m_chromaFormat = csp;<br>
m_hChromaShift = CHROMA_H_SHIFT(csp);<br>
m_vChromaShift = CHROMA_V_SHIFT(csp);<br>
@@ -221,7 +222,7 @@<br>
<br>
m_distortion = dataPool.distortionMemBlock + instance * m_numPartitions;<br>
<br>
- uint32_t cuSize = g_maxCUSize >> depth;<br>
+ uint32_t cuSize = param.maxCUSize >> depth;<br>
m_trCoeff[0] = dataPool.trCoeffMemBlock + instance * (cuSize * cuSize);<br>
m_trCoeff[1] = m_trCoeff[2] = 0;<br>
m_transformSkip[1] = m_transformSkip[2] = m_cbf[1] = m_cbf[2] = 0;<br>
@@ -263,7 +264,7 @@<br>
<br>
m_distortion = dataPool.distortionMemBlock + instance * m_numPartitions;<br>
<br>
- uint32_t cuSize = g_maxCUSize >> depth;<br>
+ uint32_t cuSize = param.maxCUSize >> depth;<br>
uint32_t sizeL = cuSize * cuSize;<br>
uint32_t sizeC = sizeL >> (m_hChromaShift + m_vChromaShift); // block chroma part<br>
m_trCoeff[0] = dataPool.trCoeffMemBlock + instance * (sizeL + sizeC * 2);<br>
@@ -1917,10 +1918,10 @@<br>
uint32_t offset = 8;<br>
<br>
int16_t xmax = (int16_t)((m_slice->m_sps-><wbr>picWidthInLumaSamples + offset - m_cuPelX - 1) << mvshift);<br>
- int16_t xmin = -(int16_t)((g_maxCUSize + offset + m_cuPelX - 1) << mvshift);<br>
+ int16_t xmin = -(int16_t)((m_encData->m_<wbr>param->maxCUSize + offset + m_cuPelX - 1) << mvshift);<br>
<br>
int16_t ymax = (int16_t)((m_slice->m_sps-><wbr>picHeightInLumaSamples + offset - m_cuPelY - 1) << mvshift);<br>
- int16_t ymin = -(int16_t)((g_maxCUSize + offset + m_cuPelY - 1) << mvshift);<br>
+ int16_t ymin = -(int16_t)((m_encData->m_<wbr>param->maxCUSize + offset + m_cuPelY - 1) << mvshift);<br>
<br>
outMV.x = X265_MIN(xmax, X265_MAX(xmin, outMV.x));<br>
outMV.y = X265_MIN(ymax, X265_MAX(ymin, outMV.y));<br>
diff -r 4436e1ca6f39 -r 68b27c44790d source/common/cudata.h<br>
--- a/source/common/cudata.h Tue Jun 20 16:38:20 2017 +0530<br>
+++ b/source/common/cudata.h Wed Jun 21 11:05:02 2017 +0530<br>
@@ -225,7 +225,7 @@<br>
<br>
CUData();<br>
<br>
- void initialize(const CUDataMemPool& dataPool, uint32_t depth, int csp, int instance);<br>
+ void initialize(const CUDataMemPool& dataPool, uint32_t depth, const x265_param& param, int instance);<br>
static void calcCTUGeoms(uint32_t ctuWidth, uint32_t ctuHeight, uint32_t maxCUSize, uint32_t minCUSize, CUGeom cuDataArray[CUGeom::MAX_GEOMS]<wbr>);<br>
<br>
void initCTU(const Frame& frame, uint32_t cuAddr, int qp, uint32_t firstRowInSlice, uint32_t lastRowInSlice, uint32_t lastCUInSlice);<br>
@@ -350,10 +350,10 @@<br>
<br>
CUDataMemPool() { charMemBlock = NULL; trCoeffMemBlock = NULL; mvMemBlock = NULL; distortionMemBlock = NULL; }<br>
<br>
- bool create(uint32_t depth, uint32_t csp, uint32_t numInstances)<br>
+ bool create(uint32_t depth, uint32_t csp, uint32_t numInstances, const x265_param& param)<br>
{<br>
uint32_t numPartition = NUM_4x4_PARTITIONS >> (depth * 2);<br>
- uint32_t cuSize = g_maxCUSize >> depth;<br>
+ uint32_t cuSize = param.maxCUSize >> depth;<br>
uint32_t sizeL = cuSize * cuSize;<br>
if (csp == X265_CSP_I400)<br>
{<br>
diff -r 4436e1ca6f39 -r 68b27c44790d source/common/frame.cpp<br>
--- a/source/common/frame.cpp Tue Jun 20 16:38:20 2017 +0530<br>
+++ b/source/common/frame.cpp Wed Jun 21 11:05:02 2017 +0530<br>
@@ -63,8 +63,8 @@<br>
<br>
if (param->bCTUInfo)<br>
{<br>
- uint32_t widthInCTU = (m_param->sourceWidth + g_maxCUSize - 1) >> g_maxLog2CUSize;<br>
- uint32_t heightInCTU = (m_param->sourceHeight + g_maxCUSize - 1) >> g_maxLog2CUSize;<br>
+ uint32_t widthInCTU = (m_param->sourceWidth + param->maxCUSize - 1) >> g_maxLog2CUSize;<br>
+ uint32_t heightInCTU = (m_param->sourceHeight + param->maxCUSize - 1) >> g_maxLog2CUSize;<br>
uint32_t numCTUsInFrame = widthInCTU * heightInCTU;<br>
CHECKED_MALLOC_ZERO(m_<wbr>addOnDepth, uint8_t *, numCTUsInFrame);<br>
CHECKED_MALLOC_ZERO(m_<wbr>addOnCtuInfo, uint8_t *, numCTUsInFrame);<br>
@@ -77,11 +77,10 @@<br>
}<br>
}<br>
<br>
- if (m_fencPic->create(param-><wbr>sourceWidth, param->sourceHeight, param->internalCsp) &&<br>
- m_lowres.create(m_fencPic, param->bframes, !!param->rc.aqMode || !!param->bAQMotion, param->rc.qgSize))<br>
+ if (m_fencPic->create(param) && m_lowres.create(m_fencPic, param->bframes, !!param->rc.aqMode || !!param->bAQMotion, param->rc.qgSize))<br>
{<br>
X265_CHECK((m_reconColCount == NULL), "m_reconColCount was initialized");<br>
- m_numRows = (m_fencPic->m_picHeight + g_maxCUSize - 1) / g_maxCUSize;<br>
+ m_numRows = (m_fencPic->m_picHeight + param->maxCUSize - 1) / param->maxCUSize;<br>
m_reconRowFlag = new ThreadSafeInteger[m_numRows];<br>
m_reconColCount = new ThreadSafeInteger[m_numRows];<br>
<br>
@@ -107,12 +106,12 @@<br>
m_reconPic = new PicYuv;<br>
m_param = param;<br>
m_encData->m_reconPic = m_reconPic;<br>
- bool ok = m_encData->create(*param, sps, m_fencPic->m_picCsp) && m_reconPic->create(param-><wbr>sourceWidth, param->sourceHeight, param->internalCsp);<br>
+ bool ok = m_encData->create(*param, sps, m_fencPic->m_picCsp) && m_reconPic->create(param);<br>
if (ok)<br>
{<br>
/* initialize right border of m_reconpicYuv as SAO may read beyond the<br>
* end of the picture accessing uninitialized pixels */<br>
- int maxHeight = sps.numCuInHeight * g_maxCUSize;<br>
+ int maxHeight = sps.numCuInHeight * param->maxCUSize;<br>
memset(m_reconPic->m_picOrg[0]<wbr>, 0, sizeof(pixel)* m_reconPic->m_stride * maxHeight);<br>
<br>
/* use pre-calculated cu/pu offsets cached in the SPS structure */<br>
@@ -189,8 +188,8 @@<br>
<br>
if (m_ctuInfo)<br>
{<br>
- uint32_t widthInCU = (m_param->sourceWidth + g_maxCUSize - 1) >> g_maxLog2CUSize;<br>
- uint32_t heightInCU = (m_param->sourceHeight + g_maxCUSize - 1) >> g_maxLog2CUSize;<br>
+ uint32_t widthInCU = (m_param->sourceWidth + m_param->maxCUSize - 1) >> g_maxLog2CUSize;<br>
+ uint32_t heightInCU = (m_param->sourceHeight + m_param->maxCUSize - 1) >> g_maxLog2CUSize;<br>
uint32_t numCUsInFrame = widthInCU * heightInCU;<br>
for (uint32_t i = 0; i < numCUsInFrame; i++)<br>
{<br>
diff -r 4436e1ca6f39 -r 68b27c44790d source/common/framedata.cpp<br>
--- a/source/common/framedata.cpp Tue Jun 20 16:38:20 2017 +0530<br>
+++ b/source/common/framedata.cpp Wed Jun 21 11:05:02 2017 +0530<br>
@@ -41,9 +41,9 @@<br>
if (param.rc.bStatWrite)<br>
m_spsrps = const_cast<RPS*>(sps.spsrps);<br>
<br>
- m_cuMemPool.create(0, param.internalCsp, sps.numCUsInFrame);<br>
+ m_cuMemPool.create(0, param.internalCsp, sps.numCUsInFrame, param);<br>
for (uint32_t ctuAddr = 0; ctuAddr < sps.numCUsInFrame; ctuAddr++)<br>
- m_picCTU[ctuAddr].initialize(<wbr>m_cuMemPool, 0, param.internalCsp, ctuAddr);<br>
+ m_picCTU[ctuAddr].initialize(<wbr>m_cuMemPool, 0, param, ctuAddr);<br>
<br>
CHECKED_MALLOC_ZERO(m_cuStat, RCStatCU, sps.numCUsInFrame);<br>
CHECKED_MALLOC(m_rowStat, RCStatRow, sps.numCuInHeight);<br>
diff -r 4436e1ca6f39 -r 68b27c44790d source/common/picyuv.cpp<br>
--- a/source/common/picyuv.cpp Tue Jun 20 16:38:20 2017 +0530<br>
+++ b/source/common/picyuv.cpp Wed Jun 21 11:05:02 2017 +0530<br>
@@ -69,22 +69,26 @@<br>
m_vChromaShift = 0;<br>
}<br>
<br>
-bool PicYuv::create(uint32_t picWidth, uint32_t picHeight, uint32_t picCsp, pixel *pixelbuf)<br>
+bool PicYuv::create(x265_param* param, pixel *pixelbuf)<br>
{<br>
+ m_param = param;<br>
+ uint32_t picWidth = m_param->sourceWidth;<br>
+ uint32_t picHeight = m_param->sourceHeight;<br>
+ uint32_t picCsp = m_param->internalCsp;<br>
m_picWidth = picWidth;<br>
m_picHeight = picHeight;<br>
m_hChromaShift = CHROMA_H_SHIFT(picCsp);<br>
m_vChromaShift = CHROMA_V_SHIFT(picCsp);<br>
m_picCsp = picCsp;<br>
<br>
- uint32_t numCuInWidth = (m_picWidth + g_maxCUSize - 1) / g_maxCUSize;<br>
- uint32_t numCuInHeight = (m_picHeight + g_maxCUSize - 1) / g_maxCUSize;<br>
+ uint32_t numCuInWidth = (m_picWidth + param->maxCUSize - 1) / param->maxCUSize;<br>
+ uint32_t numCuInHeight = (m_picHeight + param->maxCUSize - 1) / param->maxCUSize;<br>
<br>
- m_lumaMarginX = g_maxCUSize + 32; // search margin and 8-tap filter half-length, padded for 32-byte alignment<br>
- m_lumaMarginY = g_maxCUSize + 16; // margin for 8-tap filter and infinite padding<br>
- m_stride = (numCuInWidth * g_maxCUSize) + (m_lumaMarginX << 1);<br>
+ m_lumaMarginX = param->maxCUSize + 32; // search margin and 8-tap filter half-length, padded for 32-byte alignment<br>
+ m_lumaMarginY = param->maxCUSize + 16; // margin for 8-tap filter and infinite padding<br>
+ m_stride = (numCuInWidth * param->maxCUSize) + (m_lumaMarginX << 1);<br>
<br>
- int maxHeight = numCuInHeight * g_maxCUSize;<br>
+ int maxHeight = numCuInHeight * param->maxCUSize;<br>
if (pixelbuf)<br>
m_picOrg[0] = pixelbuf;<br>
else<br>
@@ -97,7 +101,7 @@<br>
{<br>
m_chromaMarginX = m_lumaMarginX; // keep 16-byte alignment for chroma CTUs<br>
m_chromaMarginY = m_lumaMarginY >> m_vChromaShift;<br>
- m_strideC = ((numCuInWidth * g_maxCUSize) >> m_hChromaShift) + (m_chromaMarginX * 2);<br>
+ m_strideC = ((numCuInWidth * m_param->maxCUSize) >> m_hChromaShift) + (m_chromaMarginX * 2);<br>
<br>
CHECKED_MALLOC(m_picBuf[1], pixel, m_strideC * ((maxHeight >> m_vChromaShift) + (m_chromaMarginY * 2)));<br>
CHECKED_MALLOC(m_picBuf[2], pixel, m_strideC * ((maxHeight >> m_vChromaShift) + (m_chromaMarginY * 2)));<br>
@@ -124,14 +128,14 @@<br>
m_vChromaShift = CHROMA_V_SHIFT(picCsp);<br>
m_picCsp = picCsp;<br>
<br>
- uint32_t numCuInWidth = (m_picWidth + g_maxCUSize - 1) / g_maxCUSize;<br>
- uint32_t numCuInHeight = (m_picHeight + g_maxCUSize - 1) / g_maxCUSize;<br>
+ uint32_t numCuInWidth = (m_picWidth + m_param->maxCUSize - 1) / m_param->maxCUSize;<br>
+ uint32_t numCuInHeight = (m_picHeight + m_param->maxCUSize - 1) / m_param->maxCUSize;<br>
<br>
- m_lumaMarginX = g_maxCUSize + 32; // search margin and 8-tap filter half-length, padded for 32-byte alignment<br>
- m_lumaMarginY = g_maxCUSize + 16; // margin for 8-tap filter and infinite padding<br>
- m_stride = (numCuInWidth * g_maxCUSize) + (m_lumaMarginX << 1);<br>
+ m_lumaMarginX = m_param->maxCUSize + 32; // search margin and 8-tap filter half-length, padded for 32-byte alignment<br>
+ m_lumaMarginY = m_param->maxCUSize + 16; // margin for 8-tap filter and infinite padding<br>
+ m_stride = (numCuInWidth * m_param->maxCUSize) + (m_lumaMarginX << 1);<br>
<br>
- int maxHeight = numCuInHeight * g_maxCUSize;<br>
+ int maxHeight = numCuInHeight * m_param->maxCUSize;<br>
int bufLen = (int)(m_stride * (maxHeight + (m_lumaMarginY * 2)));<br>
<br>
return bufLen;<br>
@@ -152,8 +156,8 @@<br>
{<br>
for (uint32_t cuCol = 0; cuCol < sps.numCuInWidth; cuCol++)<br>
{<br>
- m_cuOffsetY[cuRow * sps.numCuInWidth + cuCol] = m_stride * cuRow * g_maxCUSize + cuCol * g_maxCUSize;<br>
- m_cuOffsetC[cuRow * sps.numCuInWidth + cuCol] = m_strideC * cuRow * (g_maxCUSize >> m_vChromaShift) + cuCol * (g_maxCUSize >> m_hChromaShift);<br>
+ m_cuOffsetY[cuRow * sps.numCuInWidth + cuCol] = m_stride * cuRow * m_param->maxCUSize + cuCol * m_param->maxCUSize;<br>
+ m_cuOffsetC[cuRow * sps.numCuInWidth + cuCol] = m_strideC * cuRow * (m_param->maxCUSize >> m_vChromaShift) + cuCol * (m_param->maxCUSize >> m_hChromaShift);<br>
}<br>
}<br>
<br>
@@ -172,7 +176,7 @@<br>
CHECKED_MALLOC(m_cuOffsetY, intptr_t, sps.numCuInWidth * sps.numCuInHeight);<br>
for (uint32_t cuRow = 0; cuRow < sps.numCuInHeight; cuRow++)<br>
for (uint32_t cuCol = 0; cuCol < sps.numCuInWidth; cuCol++)<br>
- m_cuOffsetY[cuRow * sps.numCuInWidth + cuCol] = m_stride * cuRow * g_maxCUSize + cuCol * g_maxCUSize;<br>
+ m_cuOffsetY[cuRow * sps.numCuInWidth + cuCol] = m_stride * cuRow * m_param->maxCUSize + cuCol * m_param->maxCUSize;<br>
<br>
CHECKED_MALLOC(m_buOffsetY, intptr_t, (size_t)numPartitions);<br>
for (uint32_t idx = 0; idx < numPartitions; ++idx)<br>
diff -r 4436e1ca6f39 -r 68b27c44790d source/common/picyuv.h<br>
--- a/source/common/picyuv.h Tue Jun 20 16:38:20 2017 +0530<br>
+++ b/source/common/picyuv.h Wed Jun 21 11:05:02 2017 +0530<br>
@@ -71,10 +71,11 @@<br>
pixel m_maxChromaVLevel;<br>
pixel m_minChromaVLevel;<br>
double m_avgChromaVLevel;<br>
+ x265_param *m_param;<br>
<br>
PicYuv();<br>
<br>
- bool create(uint32_t picWidth, uint32_t picHeight, uint32_t csp, pixel *pixelbuf = NULL);<br>
+ bool create(x265_param* param, pixel *pixelbuf = NULL);<br>
bool createOffsets(const SPS& sps);<br>
void destroy();<br>
int getLumaBufLen(uint32_t picWidth, uint32_t picHeight, uint32_t picCsp);<br>
diff -r 4436e1ca6f39 -r 68b27c44790d source/common/slice.cpp<br>
--- a/source/common/slice.cpp Tue Jun 20 16:38:20 2017 +0530<br>
+++ b/source/common/slice.cpp Wed Jun 21 11:05:02 2017 +0530<br>
@@ -187,8 +187,8 @@<br>
// Calculate end address<br>
uint32_t internalAddress = (endCUAddr - 1) % NUM_4x4_PARTITIONS;<br>
uint32_t externalAddress = (endCUAddr - 1) / NUM_4x4_PARTITIONS;<br>
- uint32_t xmax = m_sps->picWidthInLumaSamples - (externalAddress % m_sps->numCuInWidth) * g_maxCUSize;<br>
- uint32_t ymax = m_sps->picHeightInLumaSamples - (externalAddress / m_sps->numCuInWidth) * g_maxCUSize;<br>
+ uint32_t xmax = m_sps->picWidthInLumaSamples - (externalAddress % m_sps->numCuInWidth) * m_param->maxCUSize;<br>
+ uint32_t ymax = m_sps->picHeightInLumaSamples - (externalAddress / m_sps->numCuInWidth) * m_param->maxCUSize;<br>
<br>
while (g_zscanToPelX[<wbr>internalAddress] >= xmax || g_zscanToPelY[internalAddress] >= ymax)<br>
internalAddress--;<br>
diff -r 4436e1ca6f39 -r 68b27c44790d source/common/slice.h<br>
--- a/source/common/slice.h Tue Jun 20 16:38:20 2017 +0530<br>
+++ b/source/common/slice.h Wed Jun 21 11:05:02 2017 +0530<br>
@@ -360,6 +360,7 @@<br>
int m_iPPSQpMinus26;<br>
int numRefIdxDefault[2];<br>
int m_iNumRPSInSPS;<br>
+ const x265_param *m_param;<br>
<br>
Slice()<br>
{<br>
diff -r 4436e1ca6f39 -r 68b27c44790d source/encoder/analysis.cpp<br>
--- a/source/encoder/analysis.cpp Tue Jun 20 16:38:20 2017 +0530<br>
+++ b/source/encoder/analysis.cpp Wed Jun 21 11:05:02 2017 +0530<br>
@@ -90,19 +90,19 @@<br>
cacheCost = X265_MALLOC(uint64_t, costArrSize);<br>
<br>
int csp = m_param->internalCsp;<br>
- uint32_t cuSize = g_maxCUSize;<br>
+ uint32_t cuSize = m_param->maxCUSize;<br>
<br>
bool ok = true;<br>
for (uint32_t depth = 0; depth <= g_maxCUDepth; depth++, cuSize >>= 1)<br>
{<br>
ModeDepth &md = m_modeDepth[depth];<br>
<br>
- md.cuMemPool.create(depth, csp, MAX_PRED_TYPES);<br>
+ md.cuMemPool.create(depth, csp, MAX_PRED_TYPES, *m_param);<br>
ok &= md.fencYuv.create(cuSize, csp);<br>
<br>
for (int j = 0; j < MAX_PRED_TYPES; j++)<br>
{<br>
- md.pred[j].cu.initialize(md.<wbr>cuMemPool, depth, csp, j);<br>
+ md.pred[j].cu.initialize(md.<wbr>cuMemPool, depth, *m_param, j);<br>
ok &= md.pred[j].predYuv.create(<wbr>cuSize, csp);<br>
ok &= md.pred[j].reconYuv.create(<wbr>cuSize, csp);<br>
md.pred[j].fencYuv = &md.fencYuv;<br>
@@ -236,8 +236,8 @@<br>
else<br>
{<br>
if (m_param->bIntraRefresh && m_slice->m_sliceType == P_SLICE &&<br>
- ctu.m_cuPelX / g_maxCUSize >= frame.m_encData->m_pir.<wbr>pirStartCol<br>
- && ctu.m_cuPelX / g_maxCUSize < frame.m_encData->m_pir.<wbr>pirEndCol)<br>
+ ctu.m_cuPelX / m_param->maxCUSize >= frame.m_encData->m_pir.<wbr>pirStartCol<br>
+ && ctu.m_cuPelX / m_param->maxCUSize < frame.m_encData->m_pir.<wbr>pirEndCol)<br>
compressIntraCU(ctu, cuGeom, qp);<br>
else if (!m_param->rdLevel)<br>
{<br>
@@ -2440,7 +2440,7 @@<br>
int safeX, maxSafeMv;<br>
if (m_param->bIntraRefresh && m_slice->m_sliceType == P_SLICE)<br>
{<br>
- safeX = m_slice->m_refFrameList[0][0]-<wbr>>m_encData->m_pir.pirEndCol * g_maxCUSize - 3;<br>
+ safeX = m_slice->m_refFrameList[0][0]-<wbr>>m_encData->m_pir.pirEndCol * m_param->maxCUSize - 3;<br>
maxSafeMv = (safeX - tempPred->cu.m_cuPelX) * 4;<br>
}<br>
for (uint32_t i = 0; i < numMergeCand; ++i)<br>
@@ -2466,7 +2466,7 @@<br>
}<br>
<br>
if (m_param->bIntraRefresh && m_slice->m_sliceType == P_SLICE &&<br>
- tempPred->cu.m_cuPelX / g_maxCUSize < m_frame->m_encData->m_pir.<wbr>pirEndCol &&<br>
+ tempPred->cu.m_cuPelX / m_param->maxCUSize < m_frame->m_encData->m_pir.<wbr>pirEndCol &&<br>
candMvField[i][0].mv.x > maxSafeMv)<br>
// skip merge candidates which reference beyond safe reference area<br>
continue;<br>
@@ -2570,7 +2570,7 @@<br>
int safeX, maxSafeMv;<br>
if (m_param->bIntraRefresh && m_slice->m_sliceType == P_SLICE)<br>
{<br>
- safeX = m_slice->m_refFrameList[0][0]-<wbr>>m_encData->m_pir.pirEndCol * g_maxCUSize - 3;<br>
+ safeX = m_slice->m_refFrameList[0][0]-<wbr>>m_encData->m_pir.pirEndCol * m_param->maxCUSize - 3;<br>
maxSafeMv = (safeX - tempPred->cu.m_cuPelX) * 4;<br>
}<br>
for (uint32_t i = 0; i < numMergeCand; i++)<br>
@@ -2611,7 +2611,7 @@<br>
triedBZero = true;<br>
}<br>
if (m_param->bIntraRefresh && m_slice->m_sliceType == P_SLICE &&<br>
- tempPred->cu.m_cuPelX / g_maxCUSize < m_frame->m_encData->m_pir.<wbr>pirEndCol &&<br>
+ tempPred->cu.m_cuPelX / m_param->maxCUSize < m_frame->m_encData->m_pir.<wbr>pirEndCol &&<br>
candMvField[i][0].mv.x > maxSafeMv)<br>
// skip merge candidates which reference beyond safe reference area<br>
continue;<br>
@@ -3236,7 +3236,7 @@<br>
uint32_t block_x = ctu.m_cuPelX + g_zscanToPelX[cuGeom.<wbr>absPartIdx];<br>
uint32_t block_y = ctu.m_cuPelY + g_zscanToPelY[cuGeom.<wbr>absPartIdx];<br>
uint32_t maxCols = (m_frame->m_fencPic->m_<wbr>picWidth + (loopIncr - 1)) / loopIncr;<br>
- uint32_t blockSize = g_maxCUSize >> cuGeom.depth;<br>
+ uint32_t blockSize = m_param->maxCUSize >> cuGeom.depth;<br>
double qp_offset = 0;<br>
uint32_t cnt = 0;<br>
uint32_t idx;<br>
diff -r 4436e1ca6f39 -r 68b27c44790d source/encoder/api.cpp<br>
--- a/source/encoder/api.cpp Tue Jun 20 16:38:20 2017 +0530<br>
+++ b/source/encoder/api.cpp Wed Jun 21 11:05:02 2017 +0530<br>
@@ -361,8 +361,8 @@<br>
<br>
if (param->analysisMode)<br>
{<br>
- uint32_t widthInCU = (param->sourceWidth + g_maxCUSize - 1) >> g_maxLog2CUSize;<br>
- uint32_t heightInCU = (param->sourceHeight + g_maxCUSize - 1) >> g_maxLog2CUSize;<br>
+ uint32_t widthInCU = (param->sourceWidth + param->maxCUSize - 1) >> g_maxLog2CUSize;<br>
+ uint32_t heightInCU = (param->sourceHeight + param->maxCUSize - 1) >> g_maxLog2CUSize;<br>
<br>
uint32_t numCUsInFrame = widthInCU * heightInCU;<br>
pic->analysisData.<wbr>numCUsInFrame = numCUsInFrame;<br>
diff -r 4436e1ca6f39 -r 68b27c44790d source/encoder/dpb.cpp<br>
--- a/source/encoder/dpb.cpp Tue Jun 20 16:38:20 2017 +0530<br>
+++ b/source/encoder/dpb.cpp Wed Jun 21 11:05:02 2017 +0530<br>
@@ -107,8 +107,8 @@<br>
<br>
if (curFrame->m_ctuInfo != NULL)<br>
{<br>
- uint32_t widthInCU = (curFrame->m_param-><wbr>sourceWidth + g_maxCUSize - 1) >> g_maxLog2CUSize;<br>
- uint32_t heightInCU = (curFrame->m_param-><wbr>sourceHeight + g_maxCUSize - 1) >> g_maxLog2CUSize;<br>
+ uint32_t widthInCU = (curFrame->m_param-><wbr>sourceWidth + curFrame->m_param->maxCUSize - 1) >> g_maxLog2CUSize;<br>
+ uint32_t heightInCU = (curFrame->m_param-><wbr>sourceHeight + curFrame->m_param->maxCUSize - 1) >> g_maxLog2CUSize;<br>
uint32_t numCUsInFrame = widthInCU * heightInCU;<br>
for (uint32_t i = 0; i < numCUsInFrame; i++)<br>
{<br>
diff -r 4436e1ca6f39 -r 68b27c44790d source/encoder/encoder.cpp<br>
--- a/source/encoder/encoder.cpp Tue Jun 20 16:38:20 2017 +0530<br>
+++ b/source/encoder/encoder.cpp Wed Jun 21 11:05:02 2017 +0530<br>
@@ -321,8 +321,8 @@<br>
else<br>
m_scalingList.<wbr>setupQuantMatrices(m_sps.<wbr>chromaFormatIdc);<br>
<br>
- int numRows = (m_param->sourceHeight + g_maxCUSize - 1) / g_maxCUSize;<br>
- int numCols = (m_param->sourceWidth + g_maxCUSize - 1) / g_maxCUSize;<br>
+ int numRows = (m_param->sourceHeight + m_param->maxCUSize - 1) / m_param->maxCUSize;<br>
+ int numCols = (m_param->sourceWidth + m_param->maxCUSize - 1) / m_param->maxCUSize;<br>
for (int i = 0; i < m_param->frameNumThreads; i++)<br>
{<br>
if (!m_frameEncoder[i]->init(<wbr>this, numRows, numCols))<br>
@@ -1035,16 +1035,17 @@<br>
Slice* slice = frameEnc->m_encData->m_slice;<br>
slice->m_sps = &m_sps;<br>
slice->m_pps = &m_pps;<br>
+ slice->m_param = m_param;<br>
slice->m_maxNumMergeCand = m_param->maxNumMergeCand;<br>
slice->m_endCUAddr = slice->realEndAddress(m_sps.<wbr>numCUsInFrame * NUM_4x4_PARTITIONS);<br>
}<br>
<br>
if (m_param->searchMethod == X265_SEA && frameEnc->m_lowres.sliceType != X265_TYPE_B)<br>
{<br>
- int padX = g_maxCUSize + 32;<br>
- int padY = g_maxCUSize + 16;<br>
- uint32_t numCuInHeight = (frameEnc->m_encData->m_<wbr>reconPic->m_picHeight + g_maxCUSize - 1) / g_maxCUSize;<br>
- int maxHeight = numCuInHeight * g_maxCUSize;<br>
+ int padX = m_param->maxCUSize + 32;<br>
+ int padY = m_param->maxCUSize + 16;<br>
+ uint32_t numCuInHeight = (frameEnc->m_encData->m_<wbr>reconPic->m_picHeight + m_param->maxCUSize - 1) / m_param->maxCUSize;<br>
+ int maxHeight = numCuInHeight * m_param->maxCUSize;<br>
for (int i = 0; i < INTEGRAL_PLANE_NUM; i++)<br>
{<br>
frameEnc->m_encData->m_<wbr>meBuffer[i] = X265_MALLOC(uint32_t, frameEnc->m_reconPic->m_stride * (maxHeight + (2 * padY)));<br>
@@ -1108,8 +1109,8 @@<br>
x265_analysis_data* analysis = &frameEnc->m_analysisData;<br>
analysis->poc = frameEnc->m_poc;<br>
analysis->sliceType = frameEnc->m_lowres.sliceType;<br>
- uint32_t widthInCU = (m_param->sourceWidth + g_maxCUSize - 1) >> g_maxLog2CUSize;<br>
- uint32_t heightInCU = (m_param->sourceHeight + g_maxCUSize - 1) >> g_maxLog2CUSize;<br>
+ uint32_t widthInCU = (m_param->sourceWidth + m_param->maxCUSize - 1) >> g_maxLog2CUSize;<br>
+ uint32_t heightInCU = (m_param->sourceHeight + m_param->maxCUSize - 1) >> g_maxLog2CUSize;<br>
<br>
uint32_t numCUsInFrame = widthInCU * heightInCU;<br>
analysis->numCUsInFrame = numCUsInFrame;<br>
@@ -1182,8 +1183,8 @@<br>
<br>
void Encoder::copyCtuInfo(x265_ctu_<wbr>info_t** frameCtuInfo, int poc)<br>
{<br>
- uint32_t widthInCU = (m_param->sourceWidth + g_maxCUSize - 1) >> g_maxLog2CUSize;<br>
- uint32_t heightInCU = (m_param->sourceHeight + g_maxCUSize - 1) >> g_maxLog2CUSize;<br>
+ uint32_t widthInCU = (m_param->sourceWidth + m_param->maxCUSize - 1) >> g_maxLog2CUSize;<br>
+ uint32_t heightInCU = (m_param->sourceHeight + m_param->maxCUSize - 1) >> g_maxLog2CUSize;<br>
Frame* curFrame;<br>
Frame* prevFrame = NULL;<br>
int32_t* frameCTU;<br>
@@ -1554,7 +1555,7 @@<br>
}<br>
<br>
x265_log(m_param, X265_LOG_INFO, "CU: " X265_LL " %dX%d CTUs compressed in %.3lf seconds, %.3lf CTUs per worker-second\n",<br>
- cuStats.totalCTUs, g_maxCUSize, g_maxCUSize,<br>
+ cuStats.totalCTUs, m_param->maxCUSize, m_param->maxCUSize,<br>
ELAPSED_SEC(totalWorkerTime),<br>
cuStats.totalCTUs / ELAPSED_SEC(totalWorkerTime));<br>
<br>
@@ -1981,8 +1982,8 @@<br>
sps->chromaFormatIdc = m_param->internalCsp;<br>
sps->picWidthInLumaSamples = m_param->sourceWidth;<br>
sps->picHeightInLumaSamples = m_param->sourceHeight;<br>
- sps->numCuInWidth = (m_param->sourceWidth + g_maxCUSize - 1) / g_maxCUSize;<br>
- sps->numCuInHeight = (m_param->sourceHeight + g_maxCUSize - 1) / g_maxCUSize;<br>
+ sps->numCuInWidth = (m_param->sourceWidth + m_param->maxCUSize - 1) / m_param->maxCUSize;<br>
+ sps->numCuInHeight = (m_param->sourceHeight + m_param->maxCUSize - 1) / m_param->maxCUSize;<br>
sps->numCUsInFrame = sps->numCuInWidth * sps->numCuInHeight;<br>
sps->numPartitions = NUM_4x4_PARTITIONS;<br>
sps->numPartInCUSize = 1 << g_unitSizeDepth;<br>
@@ -2212,7 +2213,7 @@<br>
p->lookaheadDepth = p->totalFrames;<br>
if (p->bIntraRefresh)<br>
{<br>
- int numCuInWidth = (m_param->sourceWidth + g_maxCUSize - 1) / g_maxCUSize;<br>
+ int numCuInWidth = (m_param->sourceWidth + m_param->maxCUSize - 1) / m_param->maxCUSize;<br>
if (p->maxNumReferences > 1)<br>
{<br>
x265_log(p, X265_LOG_WARNING, "Max References > 1 + intra-refresh is not supported , setting max num references = 1\n");<br>
@@ -2772,8 +2773,8 @@<br>
{<br>
analysis->analysisFramedata = NULL;<br>
analysis2PassFrameData *analysisFrameData = (analysis2PassFrameData*)<wbr>analysis->analysisFramedata;<br>
- uint32_t widthInCU = (m_param->sourceWidth + g_maxCUSize - 1) >> g_maxLog2CUSize;<br>
- uint32_t heightInCU = (m_param->sourceHeight + g_maxCUSize - 1) >> g_maxLog2CUSize;<br>
+ uint32_t widthInCU = (m_param->sourceWidth + m_param->maxCUSize - 1) >> g_maxLog2CUSize;<br>
+ uint32_t heightInCU = (m_param->sourceHeight + m_param->maxCUSize - 1) >> g_maxLog2CUSize;<br>
<br>
uint32_t numCUsInFrame = widthInCU * heightInCU;<br>
CHECKED_MALLOC_ZERO(<wbr>analysisFrameData, analysis2PassFrameData, 1);<br>
@@ -3074,8 +3075,8 @@<br>
}\<br>
<br>
uint32_t depthBytes = 0;<br>
- uint32_t widthInCU = (m_param->sourceWidth + g_maxCUSize - 1) >> g_maxLog2CUSize;<br>
- uint32_t heightInCU = (m_param->sourceHeight + g_maxCUSize - 1) >> g_maxLog2CUSize;<br>
+ uint32_t widthInCU = (m_param->sourceWidth + m_param->maxCUSize - 1) >> g_maxLog2CUSize;<br>
+ uint32_t heightInCU = (m_param->sourceHeight + m_param->maxCUSize - 1) >> g_maxLog2CUSize;<br>
uint32_t numCUsInFrame = widthInCU * heightInCU;<br>
<br>
int poc; uint32_t frameRecordSize;<br>
@@ -3384,8 +3385,8 @@<br>
}\<br>
<br>
uint32_t depthBytes = 0;<br>
- uint32_t widthInCU = (m_param->sourceWidth + g_maxCUSize - 1) >> g_maxLog2CUSize;<br>
- uint32_t heightInCU = (m_param->sourceHeight + g_maxCUSize - 1) >> g_maxLog2CUSize;<br>
+ uint32_t widthInCU = (m_param->sourceWidth + m_param->maxCUSize - 1) >> g_maxLog2CUSize;<br>
+ uint32_t heightInCU = (m_param->sourceHeight + m_param->maxCUSize - 1) >> g_maxLog2CUSize;<br>
uint32_t numCUsInFrame = widthInCU * heightInCU;<br>
analysis2PassFrameData* analysisFrameData = (analysis2PassFrameData*)<wbr>analysis2Pass-><wbr>analysisFramedata;<br>
<br>
diff -r 4436e1ca6f39 -r 68b27c44790d source/encoder/entropy.cpp<br>
--- a/source/encoder/entropy.cpp Tue Jun 20 16:38:20 2017 +0530<br>
+++ b/source/encoder/entropy.cpp Wed Jun 21 11:05:02 2017 +0530<br>
@@ -888,7 +888,7 @@<br>
uint32_t cuAddr = ctu.getSCUAddr() + absPartIdx;<br>
X265_CHECK(realEndAddress == slice->realEndAddress(slice-><wbr>m_endCUAddr), "real end address expected\n");<br>
<br>
- uint32_t granularityMask = g_maxCUSize - 1;<br>
+ uint32_t granularityMask = ctu.m_encData->m_param-><wbr>maxCUSize - 1;<br>
uint32_t cuSize = 1 << ctu.m_log2CUSize[absPartIdx];<br>
uint32_t rpelx = ctu.m_cuPelX + g_zscanToPelX[absPartIdx] + cuSize;<br>
uint32_t bpely = ctu.m_cuPelY + g_zscanToPelY[absPartIdx] + cuSize;<br>
diff -r 4436e1ca6f39 -r 68b27c44790d source/encoder/frameencoder.<wbr>cpp<br>
--- a/source/encoder/frameencoder.<wbr>cpp Tue Jun 20 16:38:20 2017 +0530<br>
+++ b/source/encoder/frameencoder.<wbr>cpp Wed Jun 21 11:05:02 2017 +0530<br>
@@ -124,7 +124,7 @@<br>
range += !!(m_param->searchMethod < 2); /* diamond/hex range check lag */<br>
range += NTAPS_LUMA / 2; /* subpel filter half-length */<br>
range += 2 + (MotionEstimate::<wbr>hpelIterationCount(m_param-><wbr>subpelRefine) + 1) / 2; /* subpel refine steps */<br>
- m_refLagRows = /*(m_param->maxSlices > 1 ? 1 : 0) +*/ 1 + ((range + g_maxCUSize - 1) / g_maxCUSize);<br>
+ m_refLagRows = /*(m_param->maxSlices > 1 ? 1 : 0) +*/ 1 + ((range + m_param->maxCUSize - 1) / m_param->maxCUSize);<br>
<br>
// NOTE: 2 times of numRows because both Encoder and Filter in same queue<br>
if (!WaveFront::init(m_numRows * 2))<br>
@@ -837,7 +837,7 @@<br>
}<br>
else if (m_param-><wbr>decodedPictureHashSEI == 3)<br>
{<br>
- uint32_t cuHeight = g_maxCUSize;<br>
+ uint32_t cuHeight = m_param->maxCUSize;<br>
<br>
m_checksum[0] = 0;<br>
<br>
@@ -1246,7 +1246,7 @@<br>
<br>
uint32_t maxBlockCols = (m_frame->m_fencPic->m_<wbr>picWidth + (16 - 1)) / 16;<br>
uint32_t maxBlockRows = (m_frame->m_fencPic->m_<wbr>picHeight + (16 - 1)) / 16;<br>
- uint32_t noOfBlocks = g_maxCUSize / 16;<br>
+ uint32_t noOfBlocks = m_param->maxCUSize / 16;<br>
const uint32_t bFirstRowInSlice = ((row == 0) || (m_rows[row - 1].sliceId != curRow.sliceId)) ? 1 : 0;<br>
const uint32_t bLastRowInSlice = ((row == m_numRows - 1) || (m_rows[row + 1].sliceId != curRow.sliceId)) ? 1 : 0;<br>
const uint32_t sliceId = curRow.sliceId;<br>
@@ -1325,8 +1325,8 @@<br>
// TODO: specially case handle on first and last row<br>
<br>
// Initialize restrict on MV range in slices<br>
- tld.analysis.m_sliceMinY = -(int16_t)(rowInSlice * g_maxCUSize * 4) + 3 * 4;<br>
- tld.analysis.m_sliceMaxY = (int16_t)((endRowInSlicePlus1 - 1 - row) * (g_maxCUSize * 4) - 4 * 4);<br>
+ tld.analysis.m_sliceMinY = -(int16_t)(rowInSlice * m_param->maxCUSize * 4) + 3 * 4;<br>
+ tld.analysis.m_sliceMaxY = (int16_t)((endRowInSlicePlus1 - 1 - row) * (m_param->maxCUSize * 4) - 4 * 4);<br>
<br>
// Handle single row slice<br>
if (tld.analysis.m_sliceMaxY < tld.analysis.m_sliceMinY)<br>
@@ -1482,7 +1482,7 @@<br>
{<br>
/* 1 << shift == number of 8x8 blocks at current depth */<br>
int shift = 2 * (g_maxCUDepth - depth);<br>
- int cuSize = g_maxCUSize >> depth;<br>
+ int cuSize = m_param->maxCUSize >> depth;<br>
<br>
if (cuSize == 8)<br>
curRow.rowStats.intra8x8Cnt += (int)(frameLog.cntIntra[depth] + frameLog.cntIntraNxN);<br>
diff -r 4436e1ca6f39 -r 68b27c44790d source/encoder/framefilter.cpp<br>
--- a/source/encoder/framefilter.<wbr>cpp Tue Jun 20 16:38:20 2017 +0530<br>
+++ b/source/encoder/framefilter.<wbr>cpp Wed Jun 21 11:05:02 2017 +0530<br>
@@ -185,8 +185,8 @@<br>
m_pad[0] = top->m_sps.conformanceWindow.<wbr>rightOffset;<br>
m_pad[1] = top->m_sps.conformanceWindow.<wbr>bottomOffset;<br>
m_saoRowDelay = m_param->bEnableLoopFilter ? 1 : 0;<br>
- m_lastHeight = (m_param->sourceHeight % g_maxCUSize) ? (m_param->sourceHeight % g_maxCUSize) : g_maxCUSize;<br>
- m_lastWidth = (m_param->sourceWidth % g_maxCUSize) ? (m_param->sourceWidth % g_maxCUSize) : g_maxCUSize;<br>
+ m_lastHeight = (m_param->sourceHeight % m_param->maxCUSize) ? (m_param->sourceHeight % m_param->maxCUSize) : m_param->maxCUSize;<br>
+ m_lastWidth = (m_param->sourceWidth % m_param->maxCUSize) ? (m_param->sourceWidth % m_param->maxCUSize) : m_param->maxCUSize;<br>
integralCompleted.set(0);<br>
<br>
if (m_param->bEnableSsim)<br>
@@ -214,7 +214,7 @@<br>
for(int row = 0; row < numRows; row++)<br>
{<br>
// Setting maximum bound information<br>
- m_parallelFilter[row].m_<wbr>rowHeight = (row == numRows - 1) ? m_lastHeight : g_maxCUSize;<br>
+ m_parallelFilter[row].m_<wbr>rowHeight = (row == numRows - 1) ? m_lastHeight : m_param->maxCUSize;<br>
m_parallelFilter[row].m_row = row;<br>
m_parallelFilter[row].m_<wbr>rowAddr = row * numCols;<br>
m_parallelFilter[row].m_<wbr>frameFilter = this;<br>
@@ -300,7 +300,7 @@<br>
void FrameFilter::ParallelFilter::<wbr>copySaoAboveRef(const CUData *ctu, PicYuv* reconPic, uint32_t cuAddr, int col)<br>
{<br>
// Copy SAO Top Reference Pixels<br>
- int ctuWidth = g_maxCUSize;<br>
+ int ctuWidth = ctu->m_encData->m_param-><wbr>maxCUSize;<br>
const pixel* recY = reconPic->getPlaneAddr(0, cuAddr) - (ctu->m_bFirstRowInSlice ? 0 : reconPic->m_stride);<br>
<br>
// Luma<br>
@@ -701,8 +701,8 @@<br>
intptr_t stride2 = m_frame->m_fencPic->m_stride;<br>
uint32_t bEnd = ((row) == (this->m_numRows - 1));<br>
uint32_t bStart = (row == 0);<br>
- uint32_t minPixY = row * g_maxCUSize - 4 * !bStart;<br>
- uint32_t maxPixY = X265_MIN((row + 1) * g_maxCUSize - 4 * !bEnd, (uint32_t)m_param-><wbr>sourceHeight);<br>
+ uint32_t minPixY = row * m_param->maxCUSize - 4 * !bStart;<br>
+ uint32_t maxPixY = X265_MIN((row + 1) * m_param->maxCUSize - 4 * !bEnd, (uint32_t)m_param-><wbr>sourceHeight);<br>
uint32_t ssim_cnt;<br>
x265_emms();<br>
<br>
@@ -768,7 +768,7 @@<br>
uint32_t width = reconPic->m_picWidth;<br>
uint32_t height = m_parallelFilter[row].<wbr>getCUHeight();<br>
intptr_t stride = reconPic->m_stride;<br>
- uint32_t cuHeight = g_maxCUSize;<br>
+ uint32_t cuHeight = m_param->maxCUSize;<br>
<br>
if (!row)<br>
m_frameEncoder->m_checksum[0] = 0;<br>
@@ -812,18 +812,18 @@<br>
}<br>
<br>
int stride = (int)m_frame->m_reconPic->m_<wbr>stride;<br>
- int padX = g_maxCUSize + 32;<br>
- int padY = g_maxCUSize + 16;<br>
+ int padX = m_param->maxCUSize + 32;<br>
+ int padY = m_param->maxCUSize + 16;<br>
int numCuInHeight = m_frame->m_encData->m_slice-><wbr>m_sps->numCuInHeight;<br>
- int maxHeight = numCuInHeight * g_maxCUSize;<br>
+ int maxHeight = numCuInHeight * m_param->maxCUSize;<br>
int startRow = 0;<br>
<br>
if (m_param->interlaceMode)<br>
- startRow = (row * g_maxCUSize >> 1);<br>
+ startRow = (row * m_param->maxCUSize >> 1);<br>
else<br>
- startRow = row * g_maxCUSize;<br>
+ startRow = row * m_param->maxCUSize;<br>
<br>
- int height = lastRow ? (maxHeight + g_maxCUSize * m_param->interlaceMode) : (((row + m_param->interlaceMode) * g_maxCUSize) + g_maxCUSize);<br>
+ int height = lastRow ? (maxHeight + m_param->maxCUSize * m_param->interlaceMode) : (((row + m_param->interlaceMode) * m_param->maxCUSize) + m_param->maxCUSize);<br>
<br>
if (!row)<br>
{<br>
diff -r 4436e1ca6f39 -r 68b27c44790d source/encoder/framefilter.h<br>
--- a/source/encoder/framefilter.h Tue Jun 20 16:38:20 2017 +0530<br>
+++ b/source/encoder/framefilter.h Wed Jun 21 11:05:02 2017 +0530<br>
@@ -123,7 +123,7 @@<br>
<br>
uint32_t getCUWidth(int colNum) const<br>
{<br>
- return (colNum == (int)m_numCols - 1) ? m_lastWidth : g_maxCUSize;<br>
+ return (colNum == (int)m_numCols - 1) ? m_lastWidth : m_param->maxCUSize;<br>
}<br>
<br>
void init(Encoder *top, FrameEncoder *frame, int numRows, uint32_t numCols);<br>
diff -r 4436e1ca6f39 -r 68b27c44790d source/encoder/reference.cpp<br>
--- a/source/encoder/reference.cpp Tue Jun 20 16:38:20 2017 +0530<br>
+++ b/source/encoder/reference.cpp Wed Jun 21 11:05:02 2017 +0530<br>
@@ -72,12 +72,12 @@<br>
<br>
if (wp)<br>
{<br>
- uint32_t numCUinHeight = (reconPic->m_picHeight + g_maxCUSize - 1) / g_maxCUSize;<br>
+ uint32_t numCUinHeight = (reconPic->m_picHeight + p.maxCUSize - 1) / p.maxCUSize;<br>
<br>
int marginX = reconPic->m_lumaMarginX;<br>
int marginY = reconPic->m_lumaMarginY;<br>
intptr_t stride = reconPic->m_stride;<br>
- int cuHeight = g_maxCUSize;<br>
+ int cuHeight = p.maxCUSize;<br>
<br>
for (int c = 0; c < (p.internalCsp != X265_CSP_I400 && recPic->m_picCsp != X265_CSP_I400 ? numInterpPlanes : 1); c++)<br>
{<br>
@@ -127,15 +127,15 @@<br>
int marginY = reconPic->m_lumaMarginY;<br>
intptr_t stride = reconPic->m_stride;<br>
int width = reconPic->m_picWidth;<br>
- int height = (finishedRows - numWeightedRows) * g_maxCUSize;<br>
+ int height = (finishedRows - numWeightedRows) * reconPic->m_param->maxCUSize;<br>
/* the last row may be partial height */<br>
if (finishedRows == maxNumRows - 1)<br>
{<br>
- const int leftRows = (reconPic->m_picHeight & (g_maxCUSize - 1));<br>
+ const int leftRows = (reconPic->m_picHeight & (reconPic->m_param->maxCUSize - 1));<br>
<br>
- height += leftRows ? leftRows : g_maxCUSize;<br>
+ height += leftRows ? leftRows : reconPic->m_param->maxCUSize;<br>
}<br>
- int cuHeight = g_maxCUSize;<br>
+ int cuHeight = reconPic->m_param->maxCUSize;<br>
<br>
for (int c = 0; c < numInterpPlanes; c++)<br>
{<br>
diff -r 4436e1ca6f39 -r 68b27c44790d source/encoder/sao.cpp<br>
--- a/source/encoder/sao.cpp Tue Jun 20 16:38:20 2017 +0530<br>
+++ b/source/encoder/sao.cpp Wed Jun 21 11:05:02 2017 +0530<br>
@@ -98,8 +98,8 @@<br>
m_hChromaShift = CHROMA_H_SHIFT(param-><wbr>internalCsp);<br>
m_vChromaShift = CHROMA_V_SHIFT(param-><wbr>internalCsp);<br>
<br>
- m_numCuInWidth = (m_param->sourceWidth + g_maxCUSize - 1) / g_maxCUSize;<br>
- m_numCuInHeight = (m_param->sourceHeight + g_maxCUSize - 1) / g_maxCUSize;<br>
+ m_numCuInWidth = (m_param->sourceWidth + m_param->maxCUSize - 1) / m_param->maxCUSize;<br>
+ m_numCuInHeight = (m_param->sourceHeight + m_param->maxCUSize - 1) / m_param->maxCUSize;<br>
<br>
const pixel maxY = (1 << X265_DEPTH) - 1;<br>
const pixel rangeExt = maxY >> 1;<br>
@@ -107,12 +107,12 @@<br>
<br>
for (int i = 0; i < (param->internalCsp != X265_CSP_I400 ? 3 : 1); i++)<br>
{<br>
- CHECKED_MALLOC(m_tmpL1[i], pixel, g_maxCUSize + 1);<br>
- CHECKED_MALLOC(m_tmpL2[i], pixel, g_maxCUSize + 1);<br>
+ CHECKED_MALLOC(m_tmpL1[i], pixel, m_param->maxCUSize + 1);<br>
+ CHECKED_MALLOC(m_tmpL2[i], pixel, m_param->maxCUSize + 1);<br>
<br>
// SAO asm code will read 1 pixel before and after, so pad by 2<br>
// NOTE: m_param->sourceWidth+2 enough, to avoid condition check in copySaoAboveRef(), I alloc more up to 63 bytes in here<br>
- CHECKED_MALLOC(m_tmpU[i], pixel, m_numCuInWidth * g_maxCUSize + 2 + 32);<br>
+ CHECKED_MALLOC(m_tmpU[i], pixel, m_numCuInWidth * m_param->maxCUSize + 2 + 32);<br>
m_tmpU[i] += 1;<br>
}<br>
<br>
@@ -279,8 +279,8 @@<br>
uint32_t picWidth = m_param->sourceWidth;<br>
uint32_t picHeight = m_param->sourceHeight;<br>
const CUData* cu = m_frame->m_encData->getPicCTU(<wbr>addr);<br>
- int ctuWidth = g_maxCUSize;<br>
- int ctuHeight = g_maxCUSize;<br>
+ int ctuWidth = m_param->maxCUSize;<br>
+ int ctuHeight = m_param->maxCUSize;<br>
uint32_t lpelx = cu->m_cuPelX;<br>
uint32_t tpely = cu->m_cuPelY;<br>
const uint32_t firstRowInSlice = cu->m_bFirstRowInSlice;<br>
@@ -573,8 +573,8 @@<br>
{<br>
PicYuv* reconPic = m_frame->m_reconPic;<br>
intptr_t stride = reconPic->m_stride;<br>
- int ctuWidth = g_maxCUSize;<br>
- int ctuHeight = g_maxCUSize;<br>
+ int ctuWidth = m_param->maxCUSize;<br>
+ int ctuHeight = m_param->maxCUSize;<br>
<br>
int addr = idxY * m_numCuInWidth + idxX;<br>
pixel* rec = reconPic->getLumaAddr(addr);<br>
@@ -633,8 +633,8 @@<br>
{<br>
PicYuv* reconPic = m_frame->m_reconPic;<br>
intptr_t stride = reconPic->m_strideC;<br>
- int ctuWidth = g_maxCUSize;<br>
- int ctuHeight = g_maxCUSize;<br>
+ int ctuWidth = m_param->maxCUSize;<br>
+ int ctuHeight = m_param->maxCUSize;<br>
<br>
{<br>
ctuWidth >>= m_hChromaShift;<br>
@@ -744,8 +744,8 @@<br>
intptr_t stride = plane ? reconPic->m_strideC : reconPic->m_stride;<br>
uint32_t picWidth = m_param->sourceWidth;<br>
uint32_t picHeight = m_param->sourceHeight;<br>
- int ctuWidth = g_maxCUSize;<br>
- int ctuHeight = g_maxCUSize;<br>
+ int ctuWidth = m_param->maxCUSize;<br>
+ int ctuHeight = m_param->maxCUSize;<br>
uint32_t lpelx = cu->m_cuPelX;<br>
uint32_t tpely = cu->m_cuPelY;<br>
const uint32_t firstRowInSlice = cu->m_bFirstRowInSlice;<br>
@@ -928,8 +928,8 @@<br>
intptr_t stride = reconPic->m_stride;<br>
uint32_t picWidth = m_param->sourceWidth;<br>
uint32_t picHeight = m_param->sourceHeight;<br>
- int ctuWidth = g_maxCUSize;<br>
- int ctuHeight = g_maxCUSize;<br>
+ int ctuWidth = m_param->maxCUSize;<br>
+ int ctuHeight = m_param->maxCUSize;<br>
uint32_t lpelx = cu->m_cuPelX;<br>
uint32_t tpely = cu->m_cuPelY;<br>
const uint32_t firstRowInSlice = cu->m_bFirstRowInSlice;<br>
diff -r 4436e1ca6f39 -r 68b27c44790d source/encoder/search.cpp<br>
--- a/source/encoder/search.cpp Tue Jun 20 16:38:20 2017 +0530<br>
+++ b/source/encoder/search.cpp Wed Jun 21 11:05:02 2017 +0530<br>
@@ -120,8 +120,8 @@<br>
CHECKED_MALLOC(m_rqt[i].<wbr>coeffRQT[0], coeff_t, sizeL + sizeC * 2);<br>
m_rqt[i].coeffRQT[1] = m_rqt[i].coeffRQT[0] + sizeL;<br>
m_rqt[i].coeffRQT[2] = m_rqt[i].coeffRQT[0] + sizeL + sizeC;<br>
- ok &= m_rqt[i].reconQtYuv.create(g_<wbr>maxCUSize, param.internalCsp);<br>
- ok &= m_rqt[i].resiQtYuv.create(g_<wbr>maxCUSize, param.internalCsp);<br>
+ ok &= m_rqt[i].reconQtYuv.create(<wbr>param.maxCUSize, param.internalCsp);<br>
+ ok &= m_rqt[i].resiQtYuv.create(<wbr>param.maxCUSize, param.internalCsp);<br>
}<br>
}<br>
else<br>
@@ -130,15 +130,15 @@<br>
{<br>
CHECKED_MALLOC(m_rqt[i].<wbr>coeffRQT[0], coeff_t, sizeL);<br>
m_rqt[i].coeffRQT[1] = m_rqt[i].coeffRQT[2] = NULL;<br>
- ok &= m_rqt[i].reconQtYuv.create(g_<wbr>maxCUSize, param.internalCsp);<br>
- ok &= m_rqt[i].resiQtYuv.create(g_<wbr>maxCUSize, param.internalCsp);<br>
+ ok &= m_rqt[i].reconQtYuv.create(<wbr>param.maxCUSize, param.internalCsp);<br>
+ ok &= m_rqt[i].resiQtYuv.create(<wbr>param.maxCUSize, param.internalCsp);<br>
}<br>
}<br>
<br>
/* the rest of these buffers are indexed per-depth */<br>
for (uint32_t i = 0; i <= g_maxCUDepth; i++)<br>
{<br>
- int cuSize = g_maxCUSize >> i;<br>
+ int cuSize = param.maxCUSize >> i;<br>
ok &= m_rqt[i].tmpResiYuv.create(<wbr>cuSize, param.internalCsp);<br>
ok &= m_rqt[i].tmpPredYuv.create(<wbr>cuSize, param.internalCsp);<br>
ok &= m_rqt[i].bidirPredYuv[0].<wbr>create(cuSize, param.internalCsp);<br>
@@ -2593,11 +2593,11 @@<br>
cu.clipMv(mvmax);<br>
<br>
if (cu.m_encData->m_param-><wbr>bIntraRefresh && m_slice->m_sliceType == P_SLICE &&<br>
- cu.m_cuPelX / g_maxCUSize < m_frame->m_encData->m_pir.<wbr>pirStartCol &&<br>
+ cu.m_cuPelX / m_param->maxCUSize < m_frame->m_encData->m_pir.<wbr>pirStartCol &&<br>
m_slice->m_refFrameList[0][0]-<wbr>>m_encData->m_pir.pirEndCol < m_slice->m_sps->numCuInWidth)<br>
{<br>
int safeX, maxSafeMv;<br>
- safeX = m_slice->m_refFrameList[0][0]-<wbr>>m_encData->m_pir.pirEndCol * g_maxCUSize - 3;<br>
+ safeX = m_slice->m_refFrameList[0][0]-<wbr>>m_encData->m_pir.pirEndCol * m_param->maxCUSize - 3;<br>
maxSafeMv = (safeX - cu.m_cuPelX) * 4;<br>
mvmax.x = X265_MIN(mvmax.x, maxSafeMv);<br>
mvmin.x = X265_MIN(mvmin.x, maxSafeMv);<br>
diff -r 4436e1ca6f39 -r 68b27c44790d source/encoder/slicetype.cpp<br>
--- a/source/encoder/slicetype.cpp Tue Jun 20 16:38:20 2017 +0530<br>
+++ b/source/encoder/slicetype.cpp Wed Jun 21 11:05:02 2017 +0530<br>
@@ -907,7 +907,7 @@<br>
curFrame->m_lowres.<wbr>lowresCostForRc = curFrame->m_lowres.<wbr>lowresCosts[b - p0][p1 - b];<br>
uint32_t lowresRow = 0, lowresCol = 0, lowresCuIdx = 0, sum = 0, intraSum = 0;<br>
uint32_t scale = m_param->maxCUSize / (2 * X265_LOWRES_CU_SIZE);<br>
- uint32_t numCuInHeight = (m_param->sourceHeight + g_maxCUSize - 1) / g_maxCUSize;<br>
+ uint32_t numCuInHeight = (m_param->sourceHeight + m_param->maxCUSize - 1) / m_param->maxCUSize;<br>
uint32_t widthInLowresCu = (uint32_t)m_8x8Width, heightInLowresCu = (uint32_t)m_8x8Height;<br>
double *qp_offset = 0;<br>
/* Factor in qpoffsets based on Aq/Cutree in CU costs */<br>
<br>
______________________________<wbr>_________________<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" rel="noreferrer" target="_blank">https://mailman.videolan.org/<wbr>listinfo/x265-devel</a><br>
</blockquote></div><br></div></div>