<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Dec 21, 2017 at 12:03 PM, Ashok Kumar Mishra <span dir="ltr"><<a href="mailto:ashok@multicorewareinc.com" target="_blank">ashok@multicorewareinc.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="h5">On Thu, Dec 21, 2017 at 9:03 AM,  <span dir="ltr"><<a href="mailto:santhoshini@multicorewareinc.com" target="_blank">santhoshini@multicorewareinc.<wbr>com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="m_1427280303482462853gmail-im m_1427280303482462853gmail-HOEnZb"># HG changeset patch<br>
# User Santhoshini Sekar <<a href="mailto:santhoshini@multicorewareinc.com" target="_blank">santhoshini@multicorewareinc.<wbr>com</a>><br>
# Date 1513677810 -19800<br>
#      Tue Dec 19 15:33:30 2017 +0530<br>
# Node ID 32a2cd5926ed3bc64fc5665f3ecc20<wbr>e9b371cee2<br>
# Parent  57eaef9abfd8204b568498d4a37a23<wbr>391e790d44<br>
fix bugs in analysis-reuse-level=7 and refine-mv-type=AVC<br>
<br>
</span><div class="m_1427280303482462853gmail-HOEnZb"><div class="m_1427280303482462853gmail-h5">diff --git a/source/encoder/analysis.cpp b/source/encoder/analysis.cpp<br>
--- a/source/encoder/analysis.cpp<br>
+++ b/source/encoder/analysis.cpp<br>
@@ -280,7 +280,7 @@<br>
             /* generate residual for entire CTU at once and copy to reconPic */<br>
             encodeResidue(ctu, cuGeom);<br>
         }<br>
-        else if ((m_param->analysisReuseMode == X265_ANALYSIS_LOAD && m_param->analysisReuseLevel == 10) || ((m_param->bMVType == AVC_INFO) && m_param->analysisReuseLevel >= 7))<br>
+        else if ((m_param->analysisReuseMode == X265_ANALYSIS_LOAD && m_param->analysisReuseLevel == 10) || ((m_param->bMVType == AVC_INFO) && m_param->analysisReuseLevel >= 7 && ctu.m_numPartitions <= 16))<br>
         {<br>
             analysis_inter_data* interDataCTU = (analysis_inter_data*)m_frame-<wbr>>m_analysisData.interData;<br>
             int posCTU = ctu.m_cuAddr * numPartition;<br>
@@ -461,7 +461,7 @@<br>
     int lambdaQP = lqp;<br>
<br>
     bool doQPRefine = (bDecidedDepth && depth <= m_slice->m_pps->maxCuDQPDepth) || (!bDecidedDepth && depth == m_slice->m_pps->maxCuDQPDepth)<wbr>;<br>
-    if (m_param->analysisReuseLevel == 10)<br>
+    if (m_param->analysisReuseLevel >= 7)<br>
         doQPRefine = false;<br>
<br>
     if (doQPRefine)<br>
@@ -1307,7 +1307,7 @@<br>
         }<br>
<br>
         /* Step 1. Evaluate Merge/Skip candidates for likely early-outs, if skip mode was not set above */<br>
-        if ((mightNotSplit && depth >= minDepth && !md.bestMode && !bCtuInfoCheck) || (m_param->bMVType && (m_modeFlag[0] || m_modeFlag[1]))) /* TODO: Re-evaluate if analysis load/save still works */<br>
+        if ((mightNotSplit && depth >= minDepth && !md.bestMode && !bCtuInfoCheck) || (m_param->bMVType && m_param->analysisReuseLevel == 7 && (m_modeFlag[0] || m_modeFlag[1]))) /* TODO: Re-evaluate if analysis load/save still works */<br>
         {<br>
             /* Compute Merge Cost */<br>
             md.pred[PRED_MERGE].cu.initSu<wbr>bCU(parentCTU, cuGeom, qp);<br>
@@ -1318,7 +1318,7 @@<br>
                 && md.bestMode && md.bestMode->cu.isSkipped(0); // TODO: sa8d threshold per depth<br>
         }<br>
<br>
-        if (md.bestMode && m_param->bEnableRecursionSkip && !bCtuInfoCheck && !(m_param->bMVType && (m_modeFlag[0] || m_modeFlag[1])))<br>
+        if (md.bestMode && m_param->bEnableRecursionSkip && !bCtuInfoCheck && !(m_param->bMVType && m_param->analysisReuseLevel == 7 && (m_modeFlag[0] || m_modeFlag[1])))<br>
         {<br>
             skipRecursion = md.bestMode->cu.isSkipped(0);<br>
             if (mightSplit && depth >= minDepth && !skipRecursion)<br>
@@ -1330,7 +1330,7 @@<br>
             }<br>
         }<br>
<br>
-        if (m_param->bMVType && md.bestMode && cuGeom.numPartitions <= 16)<br>
+        if (m_param->bMVType && md.bestMode && cuGeom.numPartitions <= 16 && m_param->analysisReuseLevel == 7)<br>
             skipRecursion = true;<br>
<br>
         /* Step 2. Evaluate each of the 4 split sub-blocks in series */<br>
@@ -1389,8 +1389,19 @@<br>
         }<br>
<br>
         /* If analysis mode is simple do not Evaluate other modes */<br>
-        if ((m_param->bMVType && cuGeom.numPartitions <= 16) && (m_slice->m_sliceType == P_SLICE || m_slice->m_sliceType == B_SLICE))<br>
-            mightNotSplit = !(m_checkMergeAndSkipOnly[0] || (m_checkMergeAndSkipOnly[0] && m_checkMergeAndSkipOnly[1]));<br>
+        if (m_param->bMVType && m_param->analysisReuseLevel == 7)<br>
+        {<br>
+            if (m_slice->m_sliceType == P_SLICE)<br>
+            {<br>
+                if (m_checkMergeAndSkipOnly[0])<br>
+                    skipModes = true;<br>
+            }<br>
+            else<br>
+            {<br>
+                if (m_checkMergeAndSkipOnly[0] && m_checkMergeAndSkipOnly[1])<br>
+                    skipModes = true;<br>
+            }<br>
+        }<br>
<br>
         /* Split CUs<br>
          *   0  1<br>
@@ -2001,7 +2012,7 @@<br>
<br>
         /* Step 1. Evaluate Merge/Skip candidates for likely early-outs */<br>
         if ((mightNotSplit && !md.bestMode && !bCtuInfoCheck) ||<br>
-            (m_param->bMVType && (m_modeFlag[0] || m_modeFlag[1])))<br>
+            (m_param->bMVType && m_param->analysisReuseLevel == 7 && (m_modeFlag[0] || m_modeFlag[1])))<br>
         {<br>
             md.pred[PRED_SKIP].cu.initSub<wbr>CU(parentCTU, cuGeom, qp);<br>
             md.pred[PRED_MERGE].cu.initSu<wbr>bCU(parentCTU, cuGeom, qp);<br>
@@ -2017,7 +2028,7 @@<br>
                 skipRecursion = md.bestMode && !md.bestMode->cu.getQtRootCbf(<wbr>0);<br>
         }<br>
<br>
-        if (m_param->bMVType && md.bestMode && cuGeom.numPartitions <= 16)<br>
+        if (m_param->bMVType && md.bestMode && cuGeom.numPartitions <= 16 && m_param->analysisReuseLevel == 7)<br>
             skipRecursion = true;<br>
<br>
         // estimate split cost<br>
@@ -2073,8 +2084,19 @@<br>
         }<br>
<br>
         /* If analysis mode is simple do not Evaluate other modes */<br>
-        if ((m_param->bMVType && cuGeom.numPartitions <= 16) && (m_slice->m_sliceType == P_SLICE || m_slice->m_sliceType == B_SLICE))<br>
-            mightNotSplit = !(m_checkMergeAndSkipOnly[0] || (m_checkMergeAndSkipOnly[0] && m_checkMergeAndSkipOnly[1]));<br>
+        if (m_param->bMVType && m_param->analysisReuseLevel == 7)<br>
+        {<br>
+            if (m_slice->m_sliceType == P_SLICE)<br>
+            {<br>
+                if (m_checkMergeAndSkipOnly[0])<br>
+                    skipModes = true;<br>
+            }<br>
+            else<br>
+            {<br>
+                if (m_checkMergeAndSkipOnly[0] && m_checkMergeAndSkipOnly[1])<br>
+                    skipModes = true;<br>
+            }<br>
+        }<br>
<br>
         /* Split CUs<br>
          *   0  1<br>
diff --git a/source/encoder/encoder.cpp b/source/encoder/encoder.cpp<br>
--- a/source/encoder/encoder.cpp<br>
+++ b/source/encoder/encoder.cpp<br>
@@ -562,7 +562,7 @@<br>
                     {<br>
                         int cuOffset = cuI * bytes + pu;<br>
                         (interData)->mergeFlag[cuPos + cuOffset] = (srcInterData)->mergeFlag[(mbI<wbr>ndex * 16) + cuOffset];<br>
-<br>
+                        (interData)->sadCost[cuPos + cuOffset] = (srcInterData)->sadCost[(mbInd<wbr>ex * 16) + cuOffset];<br>
                         (interData)->interDir[cuPos + cuOffset] = (srcInterData)->interDir[(mbIn<wbr>dex * 16) + cuOffset];<br>
                         for (uint32_t k = 0; k < numDir; k++)<br>
                         {<br>
@@ -570,10 +570,10 @@<br>
                             (interData)->refIdx[k][cuPos + cuOffset] = (srcInterData)->refIdx[k][(mbI<wbr>ndex * 16) + cuOffset];<br>
                             memcpy(&(interData)->mv[k][cu<wbr>Pos + cuOffset], &(srcInterData)->mv[k][(mbInde<wbr>x * 16) + cuOffset], sizeof(MV));<br>
                             if (m_param->analysisReuseLevel == 7 && numPU == PU_2Nx2N &&<br>
-                                ((srcInterData)->depth[cuPos + cuOffset] == (m_param->maxCUSize >> 5)))<br>
+                                ((interData)->depth[cuPos + cuOffset] == (m_param->maxCUSize >> 5)))<br>
                             {<br>
-                                int mv_x = ((analysis_inter_data *)curFrame->m_analysisData.int<wbr>erData)->mv[k][(mbIndex * 16) + cuOffset].x;<br>
-                                int mv_y = ((analysis_inter_data *)curFrame->m_analysisData.int<wbr>erData)->mv[k][(mbIndex * 16) + cuOffset].y;<br>
+                                int mv_x = ((analysis_inter_data *)curFrame->m_analysisData.int<wbr>erData)->mv[k][cuPos + cuOffset].x;<br>
+                                int mv_y = ((analysis_inter_data *)curFrame->m_analysisData.int<wbr>erData)->mv[k][cuPos + cuOffset].y;<br></div></div></blockquote><div><br></div></div></div><div>Always use local pointer analysis_inter_data * interData above.</div></div></div></div></blockquote><div>ok, I'll change this everywhere.  </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span class=""><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="m_1427280303482462853gmail-HOEnZb"><div class="m_1427280303482462853gmail-h5">
                                 if ((mv_x*mv_x + mv_y*mv_y) <= MVTHRESHOLD)<br>
                                     memset(&curFrame->m_analysisD<wbr>ata.modeFlag[k][cuPos + cuOffset], 1, bytes);<br>
                             }<br>
@@ -640,9 +640,10 @@<br>
                     if (m_param->analysisReuseLevel > 4)<br>
                     {<br>
                         memset(&(currInterData)->part<wbr>Size[count], (interData)->partSize[d], bytes);<br>
-                        int numPU = nbPartsTable[(currInterData)-><wbr>partSize[d]];<br>
-                        for (int pu = 0; pu < numPU; pu++, d++)<br>
+                        int numPU = nbPartsTable[(interData)->part<wbr>Size[d]];<br>
+                        for (int pu = 0; pu < numPU; pu++)<br>
                         {<br>
+                            if (pu) d++;<br></div></div></blockquote><div><br></div></span><div>Can be written as</div><span class=""><div><span style="color:rgb(80,0,80)">for (int pu = 0; pu < numPU; pu++, d++)</span></div></span></div></div></div></blockquote><div>this is logically wrong because 'd' should be incremented only when pu is non-zero. But incrementing 'd' in the for loop always increments d.</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span class=""><div><br></div><div> <br></div></span><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="m_1427280303482462853gmail-HOEnZb"><div class="m_1427280303482462853gmail-h5">
                             (currInterData)->mergeFlag[co<wbr>unt + pu] = (interData)->mergeFlag[d];<span class=""><br>
                             if (m_param->analysisReuseLevel >= 7)<br>
                             {<br>
@@ -3061,12 +3062,13 @@<br>
         if (m_param->analysisReuseLevel >= 7)<br>
         {<br>
             CHECKED_MALLOC(interData->int<wbr>erDir, uint8_t, analysis->numPartitions * analysis->numCUsInFrame);<br>
+            CHECKED_MALLOC(interData->sadC<wbr>ost, int64_t, analysis->numPartitions * analysis->numCUsInFrame);<br>
             for (int dir = 0; dir < numDir; dir++)<br>
             {<br>
                 CHECKED_MALLOC(interData->mvp<wbr>Idx[dir], uint8_t, analysis->numPartitions * analysis->numCUsInFrame);<br>
                 CHECKED_MALLOC(interData->ref<wbr>Idx[dir], int8_t, analysis->numPartitions * analysis->numCUsInFrame);<br>
                 CHECKED_MALLOC(interData->mv[<wbr>dir], MV, analysis->numPartitions * analysis->numCUsInFrame);<br>
-                CHECKED_MALLOC(analysis->modeF<wbr>lag[dir], uint8_t, analysis->numPartitions * analysis->numCUsInFrame);<br>
+                CHECKED_MALLOC_ZERO(analysis-><wbr>modeFlag[dir], uint8_t, analysis->numPartitions * analysis->numCUsInFrame);<br>
             }<br>
<br>
             /* Allocate intra in inter */<br>
</span></div></div><br>______________________________<wbr>_________________<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/l<wbr>istinfo/x265-devel</a><br>
<br></blockquote></div><br></div></div>
<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>
<br></blockquote></div><br></div></div>