<div dir="ltr"><div>Sorry, in my zeal to push the Quant bug fix patch, I ended up pushing this test patch as well.<br><br></div>The new (or rather X265_MALLOC) should be inside Frame::create(). <br></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Aug 11, 2015 at 3:16 PM,  <span dir="ltr"><<a href="mailto:santhoshini@multicorewareinc.com" target="_blank">santhoshini@multicorewareinc.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=""># HG changeset patch<br>
# User Santhoshini Sekar<<a href="mailto:santhoshini@multicorewareinc.com">santhoshini@multicorewareinc.com</a>><br>
# Date 1438839704 -19800<br>
#      Thu Aug 06 11:11:44 2015 +0530<br>
</span># Node ID 8dcbdddb663d0d93ad32ac36c764146dcbd9e883<br>
# Parent  cbdefdfca87723342d21d90c41a93254553ed3d1<br>
<span class="">add API and implementation for Region of Interest(ROI)<br>
<br>
</span>diff -r cbdefdfca877 -r 8dcbdddb663d source/CMakeLists.txt<br>
--- a/source/CMakeLists.txt     Thu Aug 06 14:23:43 2015 +0530<br>
<span class="">+++ b/source/CMakeLists.txt     Thu Aug 06 11:11:44 2015 +0530<br>
@@ -30,7 +30,7 @@<br>
 mark_as_advanced(FPROFILE_USE FPROFILE_GENERATE NATIVE_BUILD)<br>
<br>
 # X265_BUILD must be incremented each time the public API is changed<br>
-set(X265_BUILD 68)<br>
+set(X265_BUILD 69)<br>
 configure_file("${PROJECT_SOURCE_DIR}/<a href="http://x265.def.in" rel="noreferrer" 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" rel="noreferrer" target="_blank">x265_config.h.in</a>"<br>
</span>diff -r cbdefdfca877 -r 8dcbdddb663d source/common/frame.cpp<br>
--- a/source/common/frame.cpp   Thu Aug 06 14:23:43 2015 +0530<br>
+++ b/source/common/frame.cpp   Thu Aug 06 11:11:44 2015 +0530<br>
@@ -36,6 +36,7 @@<br>
     m_countRefEncoders = 0;<br>
     m_encData = NULL;<br>
     m_reconPic = NULL;<br>
+    m_quantOffsets = NULL;<br>
     m_next = NULL;<br>
     m_prev = NULL;<br>
     m_param = NULL;<br>
@@ -100,5 +101,10 @@<br>
         m_reconPic = NULL;<br>
     }<br>
<br>
+    if (m_quantOffsets)<br>
+    {<br>
+        delete[] m_quantOffsets;<br>
+    }<br>
+<br>
     m_lowres.destroy();<br>
 }<br>
diff -r cbdefdfca877 -r 8dcbdddb663d source/common/frame.h<br>
--- a/source/common/frame.h     Thu Aug 06 14:23:43 2015 +0530<br>
<span class="">+++ b/source/common/frame.h     Thu Aug 06 11:11:44 2015 +0530<br>
@@ -59,6 +59,8 @@<br>
     bool                   m_lowresInit;         // lowres init complete (pre-analysis)<br>
     bool                   m_bChromaExtended;    // orig chroma planes motion extended for weight analysis<br>
<br>
+    float*                 m_quantOffsets;       // points to quantOffsets in x265_picture<br>
+<br>
     /* Frame Parallelism - notification between FrameEncoders of available motion reference rows */<br>
     ThreadSafeInteger      m_reconRowCount;      // count of CTU rows completely reconstructed and extended for motion reference<br>
     volatile uint32_t      m_countRefEncoders;   // count of FrameEncoder threads monitoring m_reconRowCount<br>
</span>diff -r cbdefdfca877 -r 8dcbdddb663d source/encoder/api.cpp<br>
--- a/source/encoder/api.cpp    Thu Aug 06 14:23:43 2015 +0530<br>
+++ b/source/encoder/api.cpp    Thu Aug 06 11:11:44 2015 +0530<br>
@@ -268,6 +268,7 @@<br>
     pic->bitDepth = param->internalBitDepth;<br>
     pic->colorSpace = param->internalCsp;<br>
     pic->forceqp = X265_QP_AUTO;<br>
+    pic->quantOffsets = NULL;<br>
     if (param->analysisMode)<br>
     {<br>
         uint32_t widthInCU       = (param->sourceWidth  + g_maxCUSize - 1) >> g_maxLog2CUSize;<br>
diff -r cbdefdfca877 -r 8dcbdddb663d source/encoder/encoder.cpp<br>
--- a/source/encoder/encoder.cpp        Thu Aug 06 14:23:43 2015 +0530<br>
<span class="">+++ b/source/encoder/encoder.cpp        Thu Aug 06 11:11:44 2015 +0530<br>
</span>@@ -407,6 +407,7 @@<br>
         }<br>
<br>
         Frame *inFrame;<br>
+        int cuCount;<br>
         if (m_dpb->m_freeList.empty())<br>
         {<br>
             inFrame = new Frame;<br>
@@ -441,6 +442,11 @@<br>
                         m_buOffsetY = inFrame->m_fencPic->m_buOffsetY;<br>
                     }<br>
                 }<br>
+                if (pic_in->quantOffsets != NULL)<br>
+                {<br>
+                    cuCount = inFrame->m_lowres.maxBlocksInRow * inFrame->m_lowres.maxBlocksInCol;<br>
+                    inFrame->m_quantOffsets = new float[cuCount];<br>
+                }<br>
             }<br>
             else<br>
             {<br>
@@ -465,6 +471,8 @@<br>
<span class="">         inFrame->m_pts       = pic_in->pts;<br>
         inFrame->m_forceqp   = pic_in->forceqp;<br>
         inFrame->m_param     = m_reconfigured ? m_latestParam : m_param;<br>
</span>+        if (pic_in->quantOffsets != NULL)<br>
+            memcpy(inFrame->m_quantOffsets, pic_in->quantOffsets, cuCount * sizeof(float));<br>
<span class=""><br>
         if (m_pocLast == 0)<br>
             m_firstPts = inFrame->m_pts;<br>
</span>diff -r cbdefdfca877 -r 8dcbdddb663d source/encoder/slicetype.cpp<br>
--- a/source/encoder/slicetype.cpp      Thu Aug 06 14:23:43 2015 +0530<br>
<div><div class="h5">+++ b/source/encoder/slicetype.cpp      Thu Aug 06 11:11:44 2015 +0530<br>
@@ -96,6 +96,7 @@<br>
     int maxRow = curFrame->m_fencPic->m_picHeight;<br>
     int blockCount = curFrame->m_lowres.maxBlocksInRow * curFrame->m_lowres.maxBlocksInCol;<br>
<br>
+    float* quantOffsets = curFrame->m_quantOffsets;<br>
     for (int y = 0; y < 3; y++)<br>
     {<br>
         curFrame->m_lowres.wp_ssd[y] = 0;<br>
@@ -113,10 +114,21 @@<br>
<br>
         if (param->rc.aqMode && param->rc.aqStrength == 0)<br>
         {<br>
-            memset(curFrame->m_lowres.qpCuTreeOffset, 0, cuCount * sizeof(double));<br>
-            memset(curFrame->m_lowres.qpAqOffset, 0, cuCount * sizeof(double));<br>
-            for (int cuxy = 0; cuxy < cuCount; cuxy++)<br>
-                curFrame->m_lowres.invQscaleFactor[cuxy] = 256;<br>
+            if (quantOffsets)<br>
+            {<br>
+                for (int cuxy = 0; cuxy < cuCount; cuxy++)<br>
+                {<br>
+                    curFrame->m_lowres.qpCuTreeOffset[cuxy] = curFrame->m_lowres.qpAqOffset[cuxy] = quantOffsets[cuxy];<br>
+                    curFrame->m_lowres.invQscaleFactor[cuxy] = x265_exp2fix8(curFrame->m_lowres.qpCuTreeOffset[cuxy]);<br>
+                }<br>
+            }<br>
+            else<br>
+            {<br>
+                memset(curFrame->m_lowres.qpCuTreeOffset, 0, cuCount * sizeof(double));<br>
+                memset(curFrame->m_lowres.qpAqOffset, 0, cuCount * sizeof(double));<br>
+                for (int cuxy = 0; cuxy < cuCount; cuxy++)<br>
+                    curFrame->m_lowres.invQscaleFactor[cuxy] = 256;<br>
+            }<br>
         }<br>
<br>
         /* Need variance data for weighted prediction */<br>
@@ -177,6 +189,8 @@<br>
                     uint32_t energy = acEnergyCu(curFrame, blockX, blockY, param->internalCsp);<br>
                     qp_adj = strength * (X265_LOG2(X265_MAX(energy, 1)) - (14.427f + 2 * (X265_DEPTH - 8)));<br>
                 }<br>
</div></div>+                if (quantOffsets != NULL)<br>
<span class="">+                    qp_adj += quantOffsets[blockXY];<br>
                 curFrame->m_lowres.qpAqOffset[blockXY] = qp_adj;<br>
                 curFrame->m_lowres.qpCuTreeOffset[blockXY] = qp_adj;<br>
                 curFrame->m_lowres.invQscaleFactor[blockXY] = x265_exp2fix8(qp_adj);<br>
</span>diff -r cbdefdfca877 -r 8dcbdddb663d source/x265.h<br>
--- a/source/x265.h     Thu Aug 06 14:23:43 2015 +0530<br>
<span class="">+++ b/source/x265.h     Thu Aug 06 11:11:44 2015 +0530<br>
</span>@@ -205,6 +205,13 @@<br>
<span class="im HOEnZb">      * this data structure */<br>
     x265_analysis_data analysisData;<br>
<br>
+    /* An array of quantizer offsets to be applied to this image during encoding.<br>
+     * These are added on top of the decisions made by rateControl.<br>
+     * Adaptive quantization must be enabled to use this feature. These quantizer<br>
+     * offsets should be given for each 16x16 block. Behavior if quant<br>
+     * offsets differ between encoding passes is undefined. */<br>
+    float            *quantOffsets;<br>
+<br>
</span><div class="HOEnZb"><div class="h5">     /* Frame level statistics */<br>
     x265_frame_stats frameData;<br>
<br>
_______________________________________________<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/listinfo/x265-devel</a><br>
</div></div></blockquote></div><br></div>