<div dir="ltr"># HG changeset patch<br># User Akil Ayyappan<<a href="mailto:akil@multicorewareinc.com" target="_blank">akil@multicorewareinc.com</a>><br># Date 1562928744 -19800<br># Fri Jul 12 16:22:24 2019 +0530<br># Node ID 62f3bd2fedbaa2f888f1bc9e4423df751c4ab944<br># Parent 147fb92c5ed50365a69959e6832b1d8368f0ea87<br>AQ: New AQ mode with Variance and Edge information<br><br>diff -r 147fb92c5ed5 -r 62f3bd2fedba doc/reST/cli.rst<br>--- a/doc/reST/cli.rst Mon Jul 08 10:39:27 2019 +0530<br>+++ b/doc/reST/cli.rst Fri Jul 12 16:22:24 2019 +0530<br>@@ -1,3 +1,4 @@<br>+<br> *********************<br> Command Line Options<br> *********************<br>@@ -1645,7 +1646,7 @@<br> ignored. Slower presets will generally achieve better compression<br> efficiency (and generate smaller bitstreams). Default disabled.<br> <br>-.. option:: --aq-mode <0|1|2|3><br>+.. option:: --aq-mode <0|1|2|3|4><br> <br> Adaptive Quantization operating mode. Raise or lower per-block<br> quantization based on complexity analysis of the source image. The<br>@@ -1659,6 +1660,7 @@<br> 3. AQ enabled with auto-variance and bias to dark scenes. This is <br> recommended for 8-bit encodes or low-bitrate 10-bit encodes, to <br> prevent color banding/blocking. <br>+ 4. AQ enabled with auto-variance and edge information.<br> <br> .. option:: --aq-strength <float><br> <br>diff -r 147fb92c5ed5 -r 62f3bd2fedba source/CMakeLists.txt<br>--- a/source/CMakeLists.txt Mon Jul 08 10:39:27 2019 +0530<br>+++ b/source/CMakeLists.txt Fri Jul 12 16:22:24 2019 +0530<br>@@ -29,7 +29,7 @@<br> option(STATIC_LINK_CRT "Statically link C runtime for release builds" OFF)<br> mark_as_advanced(FPROFILE_USE FPROFILE_GENERATE NATIVE_BUILD)<br> # X265_BUILD must be incremented each time the public API is changed<br>-set(X265_BUILD 177)<br>+set(X265_BUILD 178)<br> configure_file("${PROJECT_SOURCE_DIR}/<a href="http://x265.def.in" target="_blank">x265.def.in</a>"<br> "${PROJECT_BINARY_DIR}/x265.def")<br> configure_file("${PROJECT_SOURCE_DIR}/<a href="http://x265_config.h.in" target="_blank">x265_config.h.in</a>"<br>diff -r 147fb92c5ed5 -r 62f3bd2fedba source/common/lowres.cpp<br>--- a/source/common/lowres.cpp Mon Jul 08 10:39:27 2019 +0530<br>+++ b/source/common/lowres.cpp Fri Jul 12 16:22:24 2019 +0530<br>@@ -80,6 +80,7 @@<br> CHECKED_MALLOC_ZERO(qpCuTreeOffset, double, cuCountFullRes);<br> if (qgSize == 8)<br> CHECKED_MALLOC_ZERO(invQscaleFactor8x8, int, cuCount);<br>+ CHECKED_MALLOC_ZERO(edgeInclined, int, cuCountFullRes);<br> }<br> <br> if (origPic->m_param->bAQMotion)<br>@@ -231,6 +232,7 @@<br> X265_FREE(qpCuTreeOffset);<br> X265_FREE(propagateCost);<br> X265_FREE(invQscaleFactor8x8);<br>+ X265_FREE(edgeInclined);<br> X265_FREE(qpAqMotionOffset);<br> X265_FREE(blockVariance);<br> if (maxAQDepth > 0)<br>diff -r 147fb92c5ed5 -r 62f3bd2fedba source/common/lowres.h<br>--- a/source/common/lowres.h Mon Jul 08 10:39:27 2019 +0530<br>+++ b/source/common/lowres.h Fri Jul 12 16:22:24 2019 +0530<br>@@ -220,6 +220,8 @@<br> uint64_t wp_ssd[3]; // This is different than SSDY, this is sum(pixel^2) - sum(pixel)^2 for entire frame<br> uint64_t wp_sum[3];<br> double frameVariance;<br>+ int* edgeInclined;<br>+<br> <br> /* cutree intermediate data */<br> PicQPAdaptationLayer* pAQLayer;<br>diff -r 147fb92c5ed5 -r 62f3bd2fedba source/common/param.cpp<br>--- a/source/common/param.cpp Mon Jul 08 10:39:27 2019 +0530<br>+++ b/source/common/param.cpp Fri Jul 12 16:22:24 2019 +0530<br>@@ -1546,7 +1546,7 @@<br> "Lookahead depth must be less than 256");<br> CHECK(param->lookaheadSlices > 16 || param->lookaheadSlices < 0,<br> "Lookahead slices must between 0 and 16");<br>- CHECK(param->rc.aqMode < X265_AQ_NONE || X265_AQ_AUTO_VARIANCE_BIASED < param->rc.aqMode,<br>+ CHECK(param->rc.aqMode < X265_AQ_NONE || X265_AQ_EDGE < param->rc.aqMode,<br> "Aq-Mode is out of range");<br> CHECK(param->rc.aqStrength < 0 || param->rc.aqStrength > 3,<br> "Aq-Strength is out of range");<br>diff -r 147fb92c5ed5 -r 62f3bd2fedba source/encoder/slicetype.cpp<br>--- a/source/encoder/slicetype.cpp Mon Jul 08 10:39:27 2019 +0530<br>+++ b/source/encoder/slicetype.cpp Fri Jul 12 16:22:24 2019 +0530<br>@@ -85,6 +85,140 @@<br> <br> } // end anonymous namespace<br> <br>+void edgeFilter(Frame *curFrame, pixel *pic1, pixel *pic2, pixel *pic3, intptr_t stride, int height, int width)<br>+{<br>+ pixel *src = (pixel*)curFrame->m_fencPic->m_picOrg[0];<br>+ pixel *edgePic = pic1 + curFrame->m_fencPic->m_lumaMarginY * stride + curFrame->m_fencPic->m_lumaMarginX;<br>+ pixel *refPic = pic2 + curFrame->m_fencPic->m_lumaMarginY * stride + curFrame->m_fencPic->m_lumaMarginX;<br>+ pixel *edgeTheta = pic3 + curFrame->m_fencPic->m_lumaMarginY * stride + curFrame->m_fencPic->m_lumaMarginX;<br>+<br>+ for (int i = 0; i < height; i++)<br>+ {<br>+ memcpy(edgePic, src, width * sizeof(pixel));<br>+ memcpy(refPic, src, width * sizeof(pixel));<br>+ src += stride;<br>+ edgePic += stride;<br>+ refPic += stride;<br>+ }<br>+<br>+ //Applying Gaussian filter on the picture<br>+ src = (pixel*)curFrame->m_fencPic->m_picOrg[0];<br>+ refPic = pic2 + curFrame->m_fencPic->m_lumaMarginY * stride + curFrame->m_fencPic->m_lumaMarginX;<br>+ pixel pixelValue = 0;<br>+<br>+ for (int rowNum = 0; rowNum < height; rowNum++)<br>+ {<br>+ for (int colNum = 0; colNum < width; colNum++)<br>+ {<br>+ if ((rowNum >= 2) && (colNum >= 2) && (rowNum != height - 2) && (colNum != width - 2)) //Ignoring the border pixels of the picture<br>+ {<br>+ /* 5x5 Gaussian filter<br>+ [2 4 5 4 2]<br>+ 1 [4 9 12 9 4]<br>+ --- [5 12 15 12 5]<br>+ 159 [4 9 12 9 4]<br>+ [2 4 5 4 2]*/<br>+<br>+ const intptr_t rowOne = (rowNum - 2)*stride, colOne = colNum - 2;<br>+ const intptr_t rowTwo = (rowNum - 1)*stride, colTwo = colNum - 1;<br>+ const intptr_t rowThree = rowNum * stride, colThree = colNum;<br>+ const intptr_t rowFour = (rowNum + 1)*stride, colFour = colNum + 1;<br>+ const intptr_t rowFive = (rowNum + 2)*stride, colFive = colNum + 2;<br>+ const intptr_t index = (rowNum*stride) + colNum;<br>+<br>+ pixelValue = ((2 * src[rowOne + colOne] + 4 * src[rowOne + colTwo] + 5 * src[rowOne + colThree] + 4 * src[rowOne + colFour] + 2 * src[rowOne + colFive] +<br>+ 4 * src[rowTwo + colOne] + 9 * src[rowTwo + colTwo] + 12 * src[rowTwo + colThree] + 9 * src[rowTwo + colFour] + 4 * src[rowTwo + colFive] +<br>+ 5 * src[rowThree + colOne] + 12 * src[rowThree + colTwo] + 15 * src[rowThree + colThree] + 12 * src[rowThree + colFour] + 5 * src[rowThree + colFive] +<br>+ 4 * src[rowFour + colOne] + 9 * src[rowFour + colTwo] + 12 * src[rowFour + colThree] + 9 * src[rowFour + colFour] + 4 * src[rowFour + colFive] +<br>+ 2 * src[rowFive + colOne] + 4 * src[rowFive + colTwo] + 5 * src[rowFive + colThree] + 4 * src[rowFive + colFour] + 2 * src[rowFive + colFive]) / 159);<br>+ refPic[index] = pixelValue;<br>+ }<br>+ }<br>+ }<br>+<br>+#if HIGH_BIT_DEPTH //10-bit build<br>+ float_t threshold = 1023;<br>+ pixel whitePixel = 1023;<br>+#else<br>+ float_t threshold = 255;<br>+ pixel whitePixel = 255;<br>+#endif<br>+#define PI 3.14159265 <br>+<br>+ float_t gradientH = 0, gradientV = 0, radians = 0, theta = 0;<br>+ float_t gradientMagnitude = 0;<br>+ pixel blackPixel = 0;<br>+ edgePic = pic1 + curFrame->m_fencPic->m_lumaMarginY * stride + curFrame->m_fencPic->m_lumaMarginX;<br>+ //Applying Sobel filter on the gaussian filtered picture<br>+ for (int rowNum = 0; rowNum < height; rowNum++)<br>+ {<br>+ for (int colNum = 0; colNum < width; colNum++)<br>+ {<br>+ edgeTheta[(rowNum*stride) + colNum] = 0;<br>+ if ((rowNum != 0) && (colNum != 0) && (rowNum != height - 1) && (colNum != width - 1)) //Ignoring the border pixels of the picture<br>+ {<br>+ /*Horizontal and vertical gradients<br>+ [ -3 0 3 ] [-3 -10 -3 ]<br>+ gH = [ -10 0 10] gV = [ 0 0 0 ]<br>+ [ -3 0 3 ] [ 3 10 3 ]*/<br>+<br>+ const intptr_t rowOne = (rowNum - 1)*stride, colOne = colNum -1;<br>+ const intptr_t rowTwo = rowNum * stride, colTwo = colNum;<br>+ const intptr_t rowThree = (rowNum + 1)*stride, colThree = colNum + 1;<br>+ const intptr_t index = (rowNum*stride) + colNum;<br>+<br>+ gradientH = (float_t)(-3 * refPic[rowOne + colOne] + 3 * refPic[rowOne + colThree] - 10 * refPic[rowTwo + colOne] + 10 * refPic[rowTwo + colThree] - 3 * refPic[rowThree + colOne] + 3 * refPic[rowThree + colThree]);<br>+ gradientV = (float_t)(-3 * refPic[rowOne + colOne] - 10 * refPic[rowOne + colTwo] - 3 * refPic[rowOne + colThree] + 3 * refPic[rowThree + colOne] + 10 * refPic[rowThree + colTwo] + 3 * refPic[rowThree + colThree]);<br>+<br>+ gradientMagnitude = sqrtf(gradientH * gradientH + gradientV * gradientV);<br>+ radians = atan2(gradientV, gradientH);<br>+ theta = (float_t)((radians * 180) / PI);<br>+ if (theta < 0)<br>+ theta = 180 + theta;<br>+ edgeTheta[(rowNum*stride) + colNum] = (pixel)theta;<br>+<br>+ edgePic[index] = gradientMagnitude >= threshold ? whitePixel : blackPixel;<br>+ }<br>+ }<br>+ }<br>+}<br>+<br>+//Find the angle of a block by averaging the pixel angles <br>+inline void findAvgAngle(const pixel* block, intptr_t stride, uint32_t size, uint32_t &angle)<br>+{<br>+ int sum = 0;<br>+ for (uint32_t y = 0; y < size; y++)<br>+ {<br>+ for (uint32_t x = 0; x < size; x++)<br>+ {<br>+ sum += block[x];<br>+ }<br>+ block += stride;<br>+ }<br>+ angle = sum / (size*size);<br>+}<br>+<br>+uint32_t LookaheadTLD::edgeDensityCu(Frame* curFrame,pixel *edgeImage, pixel *edgeTheta, uint32_t &avgAngle, uint32_t blockX, uint32_t blockY, uint32_t qgSize)<br>+{<br>+ intptr_t srcStride = curFrame->m_fencPic->m_stride;<br>+ intptr_t blockOffsetLuma = blockX + (blockY * srcStride);<br>+ int plane = 0; // Sobel filter is applied only on Y component<br>+ uint32_t var;<br>+<br>+ if (qgSize == 8)<br>+ {<br>+ findAvgAngle(edgeTheta + blockOffsetLuma, srcStride, qgSize, avgAngle);<br>+ var = acEnergyVar(curFrame, <a href="http://primitives.cu" target="_blank">primitives.cu</a>[BLOCK_8x8].var(edgeImage + blockOffsetLuma, srcStride), 6, plane);<br>+ }<br>+ else<br>+ {<br>+ findAvgAngle(edgeTheta + blockOffsetLuma, srcStride, 16, avgAngle);<br>+ var = acEnergyVar(curFrame, <a href="http://primitives.cu" target="_blank">primitives.cu</a>[BLOCK_16x16].var(edgeImage + blockOffsetLuma, srcStride), 8, plane);<br>+ }<br>+ x265_emms();<br>+ return var;<br>+}<br>+<br> /* Find the total AC energy of each block in all planes */<br> uint32_t LookaheadTLD::acEnergyCu(Frame* curFrame, uint32_t blockX, uint32_t blockY, int csp, uint32_t qgSize)<br> {<br>@@ -342,20 +476,55 @@<br> }<br> else<br> {<br>- int blockXY = 0;<br>+#define AQ_EDGE_BIAS 0.5<br>+#define EDGE_INCLINATION 45<br>+ uint32_t numCuInHeight = (maxRow + param->maxCUSize - 1) / param->maxCUSize;<br>+ int maxHeight = numCuInHeight * param->maxCUSize;<br>+ intptr_t stride = curFrame->m_fencPic->m_stride;<br>+ pixel *edgePic = X265_MALLOC(pixel, stride * (maxHeight + (curFrame->m_fencPic->m_lumaMarginY * 2)));<br>+ pixel *gaussianPic = X265_MALLOC(pixel, stride * (maxHeight + (curFrame->m_fencPic->m_lumaMarginY * 2)));<br>+ pixel *thetaPic = X265_MALLOC(pixel, stride * (maxHeight + (curFrame->m_fencPic->m_lumaMarginY * 2)));<br>+ memset(edgePic, 0, stride * (maxHeight + (curFrame->m_fencPic->m_lumaMarginY * 2)) * sizeof(pixel));<br>+ memset(gaussianPic, 0, stride * (maxHeight + (curFrame->m_fencPic->m_lumaMarginY * 2)) * sizeof(pixel));<br>+ memset(thetaPic, 0, stride * (maxHeight + (curFrame->m_fencPic->m_lumaMarginY * 2)) * sizeof(pixel));<br>+ if (param->rc.aqMode == X265_AQ_EDGE)<br>+ edgeFilter(curFrame, edgePic, gaussianPic, thetaPic, stride, maxRow, maxCol);<br>+<br>+ int blockXY = 0, inclinedEdge = 0;<br> double avg_adj_pow2 = 0, avg_adj = 0, qp_adj = 0;<br> double bias_strength = 0.f;<br> double strength = 0.f;<br>- if (param->rc.aqMode == X265_AQ_AUTO_VARIANCE || param->rc.aqMode == X265_AQ_AUTO_VARIANCE_BIASED)<br>+ if (param->rc.aqMode == X265_AQ_AUTO_VARIANCE || param->rc.aqMode == X265_AQ_AUTO_VARIANCE_BIASED || param->rc.aqMode == X265_AQ_EDGE)<br> {<br> double bit_depth_correction = 1.f / (1 << (2 * (X265_DEPTH - 8)));<br>-<br> for (int blockY = 0; blockY < maxRow; blockY += loopIncr)<br> {<br> for (int blockX = 0; blockX < maxCol; blockX += loopIncr)<br> {<br>- uint32_t energy = acEnergyCu(curFrame, blockX, blockY, param->internalCsp, param->rc.qgSize);<br>- qp_adj = pow(energy * bit_depth_correction + 1, 0.1);<br>+ uint32_t energy, edgeDensity, avgAngle;<br>+ energy = acEnergyCu(curFrame, blockX, blockY, param->internalCsp, param->rc.qgSize);<br>+ if (param->rc.aqMode == X265_AQ_EDGE)<br>+ {<br>+ pixel *edgeImage = edgePic + curFrame->m_fencPic->m_lumaMarginY * stride + curFrame->m_fencPic->m_lumaMarginX;<br>+ pixel *edgeTheta = thetaPic + curFrame->m_fencPic->m_lumaMarginY * stride + curFrame->m_fencPic->m_lumaMarginX;<br>+ edgeDensity = edgeDensityCu(curFrame, edgeImage, edgeTheta, avgAngle, blockX, blockY, param->rc.qgSize);<br>+ if (edgeDensity)<br>+ {<br>+ qp_adj = pow(edgeDensity * bit_depth_correction + 1, 0.1);<br>+ //Increasing the QP of a block if its edge orientation lies around the multiples of 45 degree<br>+ if ((avgAngle >= EDGE_INCLINATION - 15 && avgAngle <= EDGE_INCLINATION + 15) || (avgAngle >= EDGE_INCLINATION + 75 && avgAngle <= EDGE_INCLINATION + 105))<br>+ curFrame->m_lowres.edgeInclined[blockXY] = 1;<br>+ else<br>+ curFrame->m_lowres.edgeInclined[blockXY] = 0;<br>+ }<br>+ else<br>+ {<br>+ qp_adj = pow(energy * bit_depth_correction + 1, 0.1);<br>+ curFrame->m_lowres.edgeInclined[blockXY] = 0;<br>+ }<br>+ }<br>+ else<br>+ qp_adj = pow(energy * bit_depth_correction + 1, 0.1);<br> curFrame->m_lowres.qpCuTreeOffset[blockXY] = qp_adj;<br> avg_adj += qp_adj;<br> avg_adj_pow2 += qp_adj * qp_adj;<br>@@ -371,6 +540,9 @@<br> else<br> strength = param->rc.aqStrength * 1.0397f;<br> <br>+ X265_FREE(edgePic);<br>+ X265_FREE(gaussianPic);<br>+ X265_FREE(thetaPic);<br> blockXY = 0;<br> for (int blockY = 0; blockY < maxRow; blockY += loopIncr)<br> {<br>@@ -386,6 +558,15 @@<br> qp_adj = curFrame->m_lowres.qpCuTreeOffset[blockXY];<br> qp_adj = strength * (qp_adj - avg_adj);<br> }<br>+ else if (param->rc.aqMode == X265_AQ_EDGE)<br>+ {<br>+ inclinedEdge = curFrame->m_lowres.edgeInclined[blockXY];<br>+ qp_adj = curFrame->m_lowres.qpCuTreeOffset[blockXY];<br>+ if(inclinedEdge && (qp_adj - avg_adj > 0))<br>+ qp_adj = ((strength + AQ_EDGE_BIAS) * (qp_adj - avg_adj));<br>+ else<br>+ qp_adj = strength * (qp_adj - avg_adj);<br>+ }<br> else<br> {<br> uint32_t energy = acEnergyCu(curFrame, blockX, blockY, param->internalCsp, param->rc.qgSize);<br>diff -r 147fb92c5ed5 -r 62f3bd2fedba source/encoder/slicetype.h<br>--- a/source/encoder/slicetype.h Mon Jul 08 10:39:27 2019 +0530<br>+++ b/source/encoder/slicetype.h Fri Jul 12 16:22:24 2019 +0530<br>@@ -92,6 +92,7 @@<br> protected:<br> <br> uint32_t acEnergyCu(Frame* curFrame, uint32_t blockX, uint32_t blockY, int csp, uint32_t qgSize);<br>+ uint32_t edgeDensityCu(Frame*curFrame, pixel *edgeImage, pixel *edgeTheta, uint32_t &avgAngle, uint32_t blockX, uint32_t blockY, uint32_t qgSize);<br> uint32_t lumaSumCu(Frame* curFrame, uint32_t blockX, uint32_t blockY, uint32_t qgSize);<br> uint32_t weightCostLuma(Lowres& fenc, Lowres& ref, WeightParam& wp);<br> bool allocWeightedRef(Lowres& fenc);<br>diff -r 147fb92c5ed5 -r 62f3bd2fedba source/test/regression-tests.txt<br>--- a/source/test/regression-tests.txt Mon Jul 08 10:39:27 2019 +0530<br>+++ b/source/test/regression-tests.txt Fri Jul 12 16:22:24 2019 +0530<br>@@ -154,6 +154,7 @@<br> BasketballDrive_1920x1080_50.y4m, --preset medium --no-open-gop --keyint 50 --min-keyint 50 --radl 2 --vbv-maxrate 5000 --vbv-bufsize 5000<br> big_buck_bunny_360p24.y4m, --bitrate 500 --fades<br> 720p50_parkrun_ter.y4m,--preset medium --bitrate 400 --hme<br>+ducks_take_off_420_1_720p50.y4m,--preset medium --aq-mode 4 --crf 22 --no-cutree<br> <br> # Main12 intraCost overflow bug test<br> 720p50_parkrun_ter.y4m,--preset medium<br>diff -r 147fb92c5ed5 -r 62f3bd2fedba source/x265.h<br>--- a/source/x265.h Mon Jul 08 10:39:27 2019 +0530<br>+++ b/source/x265.h Fri Jul 12 16:22:24 2019 +0530<br>@@ -561,6 +561,7 @@<br> #define X265_AQ_VARIANCE 1<br> #define X265_AQ_AUTO_VARIANCE 2<br> #define X265_AQ_AUTO_VARIANCE_BIASED 3<br>+#define X265_AQ_EDGE 4<br> #define x265_ADAPT_RD_STRENGTH 4<br> #define X265_REFINE_INTER_LEVELS 3<br> /* NOTE! For this release only X265_CSP_I420 and X265_CSP_I444 are supported */<br>diff -r 147fb92c5ed5 -r 62f3bd2fedba source/x265cli.h<br>--- a/source/x265cli.h Mon Jul 08 10:39:27 2019 +0530<br>+++ b/source/x265cli.h Fri Jul 12 16:22:24 2019 +0530<br>@@ -554,7 +554,7 @@<br> " - 0 : Disabled.\n"<br> " - 1 : Store/Load ctu distortion to/from the file specified in analysis-save/load.\n"<br> " Default 0 - Disabled\n");<br>- H0(" --aq-mode <integer> Mode for Adaptive Quantization - 0:none 1:uniform AQ 2:auto variance 3:auto variance with bias to dark scenes. Default %d\n", param->rc.aqMode);<br>+ H0(" --aq-mode <integer> Mode for Adaptive Quantization - 0:none 1:uniform AQ 2:auto variance 3:auto variance with bias to dark scenes 4:auto variance with edge information. Default %d\n", param->rc.aqMode);<br> H0(" --[no-]hevc-aq Mode for HEVC Adaptive Quantization. Default %s\n", OPT(param->rc.hevcAq));<br> H0(" --aq-strength <float> Reduces blocking and blurring in flat and textured areas (0 to 3.0). Default %.2f\n", param->rc.aqStrength);<br> H0(" --qp-adaptation-range <float> Delta QP range by QP adaptation based on a psycho-visual model (1.0 to 6.0). Default %.2f\n", param->rc.qpAdaptationRange);<br><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Jul 15, 2019 at 11:53 AM chen <<a href="mailto:chenm003@163.com" target="_blank">chenm003@163.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="line-height:1.7;color:rgb(0,0,0);font-size:14px;font-family:Arial"><div>Thank you.</div><div><br></div><div>for constant, I explain a little more</div><div>we may declare</div><div>const intptr_t row_n2 = (rowNum - 2)*stride;</div><div><br></div><div>Now,</div><div><br></div><div>src[(rowNum - 2)*stride + (colNum - 2)]</div><div>src[(rowNum - 2)*stride + (colNum - 1)] </div><div><br></div><div>==></div><div><br></div><div>src[row_n2 + (colNum - 2)]</div><div style="zoom:1"></div><div id="m_449985950136898507gmail-m_2502422499546212048divNeteaseMailCard"></div><div>src[row_n2 + (colNum - 1)]</div><div><br></div><div>a little better to read.</div><div><br></div>At 2019-07-15 13:58:53, "Akil" <<a href="mailto:akil@multicorewareinc.com" target="_blank">akil@multicorewareinc.com</a>> wrote:<br> <blockquote id="m_449985950136898507gmail-m_2502422499546212048isReplyContent" style="padding-left:1ex;margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204)"><div dir="ltr">Thanks for your suggestions, Chen. Have added the matrix in comments. That should make the code more readable. Regarding the last point, I think <span style="color:rgb(0,0,0);font-family:Arial;font-size:14px">(rowNum+X)*stride cannot be replaced by a constant since it tends to change every time.</span></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Jul 12, 2019 at 7:27 AM chen <<a href="mailto:chenm003@163.com" target="_blank">chenm003@163.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="line-height:1.7;color:rgb(0,0,0);font-size:14px;font-family:Arial"><blockquote id="m_449985950136898507gmail-m_2502422499546212048gmail-m_-6498159105604045950isReplyContent" style="padding-left:1ex;margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204)"><div class="gmail_quote"><div dir="ltr" class="gmail_attr"><br>On Wed, Jul 10, 2019 at 3:41 PM Akil <<a href="mailto:akil@multicorewareinc.com" target="_blank">akil@multicorewareinc.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"># HG changeset patch<br># User Akil Ayyappan<<a href="mailto:akil@multicorewareinc.com" target="_blank">akil@multicorewareinc.com</a>><br># Date 1561035091 -19800<br># Thu Jun 20 18:21:31 2019 +0530<br># Node ID d25c33cc2b748401c5e908af445a0a110e26c3cf<br># Parent 4f6dde51a5db4f9229bddb60db176f16ac98f505<br>AQ: New AQ mode with Variance and Edge information<br><br><br>+ //Applying Gaussian filter on the picture<br>+ src = (pixel*)curFrame->m_fencPic->m_picOrg[0];<br>+ refPic = pic2 + curFrame->m_fencPic->m_lumaMarginY * stride + curFrame->m_fencPic->m_lumaMarginX;<br>+ pixel pixelValue = 0;<br>+ for (int rowNum = 0; rowNum < height; rowNum++)<br>+ {<br>+ for (int colNum = 0; colNum < width; colNum++)<br>+ {<br>+ if ((rowNum >= 2) && (colNum >= 2) && (rowNum != height - 2) && (colNum != width - 2)) //Ignoring the border pixels of the picture<br>+ {<br>+ pixelValue = ((2 * src[(rowNum - 2)*stride + (colNum - 2)] + 4 * src[(rowNum - 2)*stride + (colNum - 1)] + 5 * src[(rowNum - 2)*stride + (colNum)] + 4 * src[(rowNum - 2)*stride + (colNum + 1)] + 2 * src[(rowNum - 2)*stride + (colNum + 2)] +<br>+ 4 * src[(rowNum - 1)*stride + (colNum - 2)] + 9 * src[(rowNum - 1)*stride + (colNum - 1)] + 12 * src[(rowNum - 1)*stride + (colNum)] + 9 * src[(rowNum - 1)*stride + (colNum + 1)] + 4 * src[(rowNum - 1)*stride + (colNum + 2)] +<br>+ 5 * src[(rowNum)*stride + (colNum - 2)] + 12 * src[(rowNum)*stride + (colNum - 1)] + 15 * src[(rowNum)*stride + (colNum)] + 12 * src[(rowNum)*stride + (colNum + 1)] + 5 * src[(rowNum)*stride + (colNum + 2)] +<br>+ 4 * src[(rowNum + 1)*stride + (colNum - 2)] + 9 * src[(rowNum + 1)*stride + (colNum - 1)] + 12 * src[(rowNum + 1)*stride + (colNum)] + 9 * src[(rowNum + 1)*stride + (colNum + 1)] + 4 * src[(rowNum + 1)*stride + (colNum + 2)] +<br>+ 2 * src[(rowNum + 2)*stride + (colNum - 2)] + 4 * src[(rowNum + 2)*stride + (colNum - 1)] + 5 * src[(rowNum + 2)*stride + (colNum)] + 4 * src[(rowNum + 2)*stride + (colNum + 1)] + 2 * src[(rowNum + 2)*stride + (colNum + 2)]) / 159);<br>+ refPic[(rowNum*stride) + colNum] = pixelValue;<br>+ }<br>+ }<br>+ }<br></div><div dir="ltr"><br></div><div dir="ltr">Could you please modify a little?</div><div dir="ltr">Ident or give coif matrix as comment, it will be more readable</div><div dir="ltr">moreover, (rowNum+X)*stride can be replace by constant, it does not affect compiled code performance but help human read code.</div><div dir="ltr"><br></div></blockquote></div>
</blockquote></div>_______________________________________________<br>
x265-devel mailing list<br>
<a href="mailto:x265-devel@videolan.org" target="_blank">x265-devel@videolan.org</a><br>
<a href="https://mailman.videolan.org/listinfo/x265-devel" rel="noreferrer" target="_blank">https://mailman.videolan.org/listinfo/x265-devel</a><br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="m_449985950136898507gmail-m_2502422499546212048gmail_signature"><div dir="ltr"><i><b>Regards,</b></i><div><i><b>Akil R</b></i></div></div></div>
</blockquote></div>_______________________________________________<br>
x265-devel mailing list<br>
<a href="mailto:x265-devel@videolan.org" target="_blank">x265-devel@videolan.org</a><br>
<a href="https://mailman.videolan.org/listinfo/x265-devel" rel="noreferrer" target="_blank">https://mailman.videolan.org/listinfo/x265-devel</a><br>
</blockquote></div></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail-m_449985950136898507gmail_signature"><div dir="ltr"><i><b>Regards,</b></i><div><i><b>Akil R</b></i></div></div></div>