<div dir="ltr">Thanks for the patch.<div>Pushed to Release_3.2 with indentation fixes.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Oct 1, 2019 at 6:42 PM Joel Galí <<a href="mailto:joelgalid@gmail.com">joelgalid@gmail.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"><div><div>Hi,</div><div><br></div><div>AQ mode 4 commit (21db162) causes slowdown even if not used aq-mode 4. Some code related to AQ mode 4 is executed always. </div><div><br></div><div>Slowdown is aprox. 10% !! on my system encoding 1080p 8-bit using --aq-mode 3 and preset medium.</div><div><br></div><div>More info: </div><div><a href="https://forum.doom9.org/showthread.php?p=1885998#post1885998" target="_blank">https://forum.doom9.org/showthread.php?p=1885998#post1885998</a></div></div><div><br></div>changeset:   12565:e39ec6f83fe5<br>tag:         tip<br>user:        <a href="mailto:joelgalid@gmail.com" target="_blank">joelgalid@gmail.com</a><br>date:        Mon Sep 30 18:23:41 2019 +0200<br>summary:     Fix: AQ mode 4 commit (21db162) introduces slowdown even is not used AQ mode 4.<br><br>diff -r fdd69a766881 -r e39ec6f83fe5 source/encoder/slicetype.cpp<br>--- a/source/encoder/slicetype.cpp Wed Sep 25 17:58:14 2019 +0530<br>+++ b/source/encoder/slicetype.cpp Mon Sep 30 18:23:41 2019 +0200<br>@@ -480,17 +480,24 @@<br>             {<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>+ pixel *edgePic = NULL;<br>+ pixel *gaussianPic = NULL;<br>+ pixel *thetaPic = NULL;<br>+<br>+ if (param->rc.aqMode == X265_AQ_EDGE)<br>+ {<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>+ edgePic = X265_MALLOC(pixel, stride * (maxHeight + (curFrame->m_fencPic->m_lumaMarginY * 2)));<br>+ gaussianPic = X265_MALLOC(pixel, stride * (maxHeight + (curFrame->m_fencPic->m_lumaMarginY * 2)));<br>+ 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>+ edgeFilter(curFrame, edgePic, gaussianPic, thetaPic, stride, maxRow, maxCol);<br>+ }                  <br> <br>                 int blockXY = 0, inclinedEdge = 0;<br>                 double avg_adj_pow2 = 0, avg_adj = 0, qp_adj = 0;<br>@@ -507,8 +514,8 @@<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>+                                pixel *edgeImage = edgePic + curFrame->m_fencPic->m_lumaMarginY * curFrame->m_fencPic->m_stride + curFrame->m_fencPic->m_lumaMarginX;<br>+                                pixel *edgeTheta = thetaPic + curFrame->m_fencPic->m_lumaMarginY * curFrame->m_fencPic->m_stride + curFrame->m_fencPic->m_lumaMarginX;<br>                                 edgeDensity = edgeDensityCu(curFrame, edgeImage, edgeTheta, avgAngle, blockX, blockY, param->rc.qgSize);<br>                                 if (edgeDensity)<br>                                 {<br>@@ -541,10 +548,14 @@<br>                 }<br>                 else<br>                     strength = param->rc.aqStrength * 1.0397f;<br>-<br>-                X265_FREE(edgePic);<br>-                X265_FREE(gaussianPic);<br>-                X265_FREE(thetaPic);<br>+<br>+ if (param->rc.aqMode == X265_AQ_EDGE)<br>+ {<br>+ X265_FREE(edgePic);<br>+ X265_FREE(gaussianPic);<br>+ X265_FREE(thetaPic);<br>+ }<br>+<br>                 blockXY = 0;<br>                 for (int blockY = 0; blockY < maxRow; blockY += loopIncr)<br>                 {<div></div><div><br></div><div><br></div><div>Regards,</div><div>Joel</div></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="gmail_signature"><div dir="ltr"><font face="georgia, serif">Regards,</font><div><font face="georgia, serif">Aruna</font></div></div></div>