<div dir="ltr">Can you please regenerate this patch at the current tip?</div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Mar 28, 2016 at 9:21 AM,  <span dir="ltr"><<a href="mailto:sagar@multicorewareinc.com" target="_blank">sagar@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 Sagar Kotecha<<a href="mailto:sagar@multicorewareinc.com">sagar@multicorewareinc.com</a>><br>
# Date 1458817615 -19800<br>
#      Thu Mar 24 16:36:55 2016 +0530<br>
# Node ID 5bccf2596d8a1d66a6a9d460e65b1b9b93c2d112<br>
# Parent  2de6cb99313a03c3577934ac5e2e116f7ba6cd10<br>
analysis: skip rect/amp in analysis load mode<br>
<br>
Avoid doing rect/amp analysis in load mode if the save mode has not chosen it as the best partition<br>
<br>
diff -r 2de6cb99313a -r 5bccf2596d8a source/common/framedata.h<br>
--- a/source/common/framedata.h Mon Mar 21 13:50:14 2016 +0530<br>
+++ b/source/common/framedata.h Thu Mar 24 16:36:55 2016 +0530<br>
@@ -172,6 +172,8 @@<br>
     int32_t*    ref;<br>
     uint8_t*    depth;<br>
     uint8_t*    modes;<br>
+    uint8_t*    partSize;<br>
+    uint8_t*    mergeFlag;<br>
 };<br>
 }<br>
 #endif // ifndef X265_FRAMEDATA_H<br>
diff -r 2de6cb99313a -r 5bccf2596d8a source/encoder/analysis.cpp<br>
--- a/source/encoder/analysis.cpp       Mon Mar 21 13:50:14 2016 +0530<br>
+++ b/source/encoder/analysis.cpp       Thu Mar 24 16:36:55 2016 +0530<br>
@@ -149,6 +149,8 @@<br>
         m_reuseRef = &m_reuseInterDataCTU->ref[ctu.m_cuAddr * X265_MAX_PRED_MODE_PER_CTU * numPredDir];<br>
         m_reuseDepth = &m_reuseInterDataCTU->depth[ctu.m_cuAddr * ctu.m_numPartitions];<br>
         m_reuseModes = &m_reuseInterDataCTU->modes[ctu.m_cuAddr * ctu.m_numPartitions];<br>
+        m_reusePartSize = &m_reuseInterDataCTU->partSize[ctu.m_cuAddr * ctu.m_numPartitions];<br>
+        m_reuseMergeFlag = &m_reuseInterDataCTU->mergeFlag[ctu.m_cuAddr * ctu.m_numPartitions];<br>
         if (m_param->analysisMode == X265_ANALYSIS_SAVE)<br>
             for (int i = 0; i < X265_MAX_PRED_MODE_PER_CTU * numPredDir; i++)<br>
                 m_reuseRef[i] = -1;<br>
@@ -885,6 +887,8 @@<br>
     uint32_t minDepth = topSkipMinDepth(parentCTU, cuGeom);<br>
     bool earlyskip = false;<br>
     bool splitIntra = true;<br>
+    bool skipRectAmp = false;<br>
+    bool chooseMerge = false;<br>
<br>
     SplitData splitData[4];<br>
     splitData[0].initSplitCUData();<br>
@@ -903,15 +907,26 @@<br>
     bool foundSkip = false;<br>
     if (m_param->analysisMode == X265_ANALYSIS_LOAD)<br>
     {<br>
-        if (mightNotSplit && depth == m_reuseDepth[cuGeom.absPartIdx] && m_reuseModes[cuGeom.absPartIdx] == MODE_SKIP)<br>
+        if (mightNotSplit && depth == m_reuseDepth[cuGeom.absPartIdx])<br>
         {<br>
-            md.pred[PRED_MERGE].cu.initSubCU(parentCTU, cuGeom, qp);<br>
-            md.pred[PRED_SKIP].cu.initSubCU(parentCTU, cuGeom, qp);<br>
-            checkMerge2Nx2N_rd0_4(md.pred[PRED_SKIP], md.pred[PRED_MERGE], cuGeom);<br>
+            if (m_reuseModes[cuGeom.absPartIdx] == MODE_SKIP)<br>
+            {<br>
+                md.pred[PRED_MERGE].cu.initSubCU(parentCTU, cuGeom, qp);<br>
+                md.pred[PRED_SKIP].cu.initSubCU(parentCTU, cuGeom, qp);<br>
+                checkMerge2Nx2N_rd0_4(md.pred[PRED_SKIP], md.pred[PRED_MERGE], cuGeom);<br>
<br>
-            foundSkip = true;<br>
-            if (m_param->rdLevel)<br>
-                earlyskip = md.bestMode && m_param->bEnableEarlySkip;<br>
+                foundSkip = true;<br>
+                if (m_param->rdLevel)<br>
+                    earlyskip = md.bestMode && m_param->bEnableEarlySkip;<br>
+            }<br>
+            if (m_reusePartSize[cuGeom.absPartIdx] == SIZE_2Nx2N)<br>
+            {<br>
+                if (m_reuseModes[cuGeom.absPartIdx] != MODE_INTRA  && m_reuseModes[cuGeom.absPartIdx] != 4)<br>
+                {<br>
+                    skipRectAmp = true && !!md.bestMode;<br>
+                    chooseMerge = !!m_reuseMergeFlag[cuGeom.absPartIdx] && !!md.bestMode;<br>
+                }<br>
+            }<br>
         }<br>
     }<br>
<br>
@@ -1017,158 +1032,161 @@<br>
             }<br>
<br>
             Mode *bestInter = &md.pred[PRED_2Nx2N];<br>
-            if (m_param->bEnableRectInter)<br>
+            if (!skipRectAmp)<br>
             {<br>
-                uint64_t splitCost = splitData[0].sa8dCost + splitData[1].sa8dCost + splitData[2].sa8dCost + splitData[3].sa8dCost;<br>
-                uint32_t threshold_2NxN, threshold_Nx2N;<br>
+                if (m_param->bEnableRectInter)<br>
+                {<br>
+                    uint64_t splitCost = splitData[0].sa8dCost + splitData[1].sa8dCost + splitData[2].sa8dCost + splitData[3].sa8dCost;<br>
+                    uint32_t threshold_2NxN, threshold_Nx2N;<br>
<br>
-                if (m_slice->m_sliceType == P_SLICE)<br>
-                {<br>
-                    threshold_2NxN = splitData[0].mvCost[0] + splitData[1].mvCost[0];<br>
-                    threshold_Nx2N = splitData[0].mvCost[0] + splitData[2].mvCost[0];<br>
-                }<br>
-                else<br>
-                {<br>
-                    threshold_2NxN = (splitData[0].mvCost[0] + splitData[1].mvCost[0]<br>
-                                    + splitData[0].mvCost[1] + splitData[1].mvCost[1] + 1) >> 1;<br>
-                    threshold_Nx2N = (splitData[0].mvCost[0] + splitData[2].mvCost[0]<br>
-                                    + splitData[0].mvCost[1] + splitData[2].mvCost[1] + 1) >> 1;<br>
+                    if (m_slice->m_sliceType == P_SLICE)<br>
+                    {<br>
+                        threshold_2NxN = splitData[0].mvCost[0] + splitData[1].mvCost[0];<br>
+                        threshold_Nx2N = splitData[0].mvCost[0] + splitData[2].mvCost[0];<br>
+                    }<br>
+                    else<br>
+                    {<br>
+                        threshold_2NxN = (splitData[0].mvCost[0] + splitData[1].mvCost[0]<br>
+                                       + splitData[0].mvCost[1] + splitData[1].mvCost[1] + 1) >> 1;<br>
+                        threshold_Nx2N = (splitData[0].mvCost[0] + splitData[2].mvCost[0]<br>
+                                       + splitData[0].mvCost[1] + splitData[2].mvCost[1] + 1) >> 1;<br>
+                    }<br>
+<br>
+                    int try_2NxN_first = threshold_2NxN < threshold_Nx2N;<br>
+                    if (try_2NxN_first && splitCost < md.pred[PRED_2Nx2N].sa8dCost + threshold_2NxN)<br>
+                    {<br>
+                        refMasks[0] = splitData[0].splitRefs | splitData[1].splitRefs; /* top */<br>
+                        refMasks[1] = splitData[2].splitRefs | splitData[3].splitRefs; /* bot */<br>
+                        md.pred[PRED_2NxN].cu.initSubCU(parentCTU, cuGeom, qp);<br>
+                        checkInter_rd0_4(md.pred[PRED_2NxN], cuGeom, SIZE_2NxN, refMasks);<br>
+                        if (md.pred[PRED_2NxN].sa8dCost < bestInter->sa8dCost)<br>
+                            bestInter = &md.pred[PRED_2NxN];<br>
+                    }<br>
+<br>
+                    if (splitCost < md.pred[PRED_2Nx2N].sa8dCost + threshold_Nx2N)<br>
+                    {<br>
+                        refMasks[0] = splitData[0].splitRefs | splitData[2].splitRefs; /* left */<br>
+                        refMasks[1] = splitData[1].splitRefs | splitData[3].splitRefs; /* right */<br>
+                        md.pred[PRED_Nx2N].cu.initSubCU(parentCTU, cuGeom, qp);<br>
+                        checkInter_rd0_4(md.pred[PRED_Nx2N], cuGeom, SIZE_Nx2N, refMasks);<br>
+                        if (md.pred[PRED_Nx2N].sa8dCost < bestInter->sa8dCost)<br>
+                            bestInter = &md.pred[PRED_Nx2N];<br>
+                    }<br>
+<br>
+                    if (!try_2NxN_first && splitCost < md.pred[PRED_2Nx2N].sa8dCost + threshold_2NxN)<br>
+                    {<br>
+                        refMasks[0] = splitData[0].splitRefs | splitData[1].splitRefs; /* top */<br>
+                        refMasks[1] = splitData[2].splitRefs | splitData[3].splitRefs; /* bot */<br>
+                        md.pred[PRED_2NxN].cu.initSubCU(parentCTU, cuGeom, qp);<br>
+                        checkInter_rd0_4(md.pred[PRED_2NxN], cuGeom, SIZE_2NxN, refMasks);<br>
+                        if (md.pred[PRED_2NxN].sa8dCost < bestInter->sa8dCost)<br>
+                            bestInter = &md.pred[PRED_2NxN];<br>
+                    }<br>
                 }<br>
<br>
-                int try_2NxN_first = threshold_2NxN < threshold_Nx2N;<br>
-                if (try_2NxN_first && splitCost < md.pred[PRED_2Nx2N].sa8dCost + threshold_2NxN)<br>
+                if (m_slice->m_sps->maxAMPDepth > depth)<br>
                 {<br>
-                    refMasks[0] = splitData[0].splitRefs | splitData[1].splitRefs; /* top */<br>
-                    refMasks[1] = splitData[2].splitRefs | splitData[3].splitRefs; /* bot */<br>
-                    md.pred[PRED_2NxN].cu.initSubCU(parentCTU, cuGeom, qp);<br>
-                    checkInter_rd0_4(md.pred[PRED_2NxN], cuGeom, SIZE_2NxN, refMasks);<br>
-                    if (md.pred[PRED_2NxN].sa8dCost < bestInter->sa8dCost)<br>
-                        bestInter = &md.pred[PRED_2NxN];<br>
-                }<br>
+                    uint64_t splitCost = splitData[0].sa8dCost + splitData[1].sa8dCost + splitData[2].sa8dCost + splitData[3].sa8dCost;<br>
+                    uint32_t threshold_2NxnU, threshold_2NxnD, threshold_nLx2N, threshold_nRx2N;<br>
<br>
-                if (splitCost < md.pred[PRED_2Nx2N].sa8dCost + threshold_Nx2N)<br>
-                {<br>
-                    refMasks[0] = splitData[0].splitRefs | splitData[2].splitRefs; /* left */<br>
-                    refMasks[1] = splitData[1].splitRefs | splitData[3].splitRefs; /* right */<br>
-                    md.pred[PRED_Nx2N].cu.initSubCU(parentCTU, cuGeom, qp);<br>
-                    checkInter_rd0_4(md.pred[PRED_Nx2N], cuGeom, SIZE_Nx2N, refMasks);<br>
-                    if (md.pred[PRED_Nx2N].sa8dCost < bestInter->sa8dCost)<br>
-                        bestInter = &md.pred[PRED_Nx2N];<br>
-                }<br>
+                    if (m_slice->m_sliceType == P_SLICE)<br>
+                    {<br>
+                        threshold_2NxnU = splitData[0].mvCost[0] + splitData[1].mvCost[0];<br>
+                        threshold_2NxnD = splitData[2].mvCost[0] + splitData[3].mvCost[0];<br>
<br>
-                if (!try_2NxN_first && splitCost < md.pred[PRED_2Nx2N].sa8dCost + threshold_2NxN)<br>
-                {<br>
-                    refMasks[0] = splitData[0].splitRefs | splitData[1].splitRefs; /* top */<br>
-                    refMasks[1] = splitData[2].splitRefs | splitData[3].splitRefs; /* bot */<br>
-                    md.pred[PRED_2NxN].cu.initSubCU(parentCTU, cuGeom, qp);<br>
-                    checkInter_rd0_4(md.pred[PRED_2NxN], cuGeom, SIZE_2NxN, refMasks);<br>
-                    if (md.pred[PRED_2NxN].sa8dCost < bestInter->sa8dCost)<br>
-                        bestInter = &md.pred[PRED_2NxN];<br>
-                }<br>
-            }<br>
+                        threshold_nLx2N = splitData[0].mvCost[0] + splitData[2].mvCost[0];<br>
+                        threshold_nRx2N = splitData[1].mvCost[0] + splitData[3].mvCost[0];<br>
+                    }<br>
+                    else<br>
+                    {<br>
+                        threshold_2NxnU = (splitData[0].mvCost[0] + splitData[1].mvCost[0]<br>
+                                         + splitData[0].mvCost[1] + splitData[1].mvCost[1] + 1) >> 1;<br>
+                        threshold_2NxnD = (splitData[2].mvCost[0] + splitData[3].mvCost[0]<br>
+                                         + splitData[2].mvCost[1] + splitData[3].mvCost[1] + 1) >> 1;<br>
<br>
-            if (m_slice->m_sps->maxAMPDepth > depth)<br>
-            {<br>
-                uint64_t splitCost = splitData[0].sa8dCost + splitData[1].sa8dCost + splitData[2].sa8dCost + splitData[3].sa8dCost;<br>
-                uint32_t threshold_2NxnU, threshold_2NxnD, threshold_nLx2N, threshold_nRx2N;<br>
-<br>
-                if (m_slice->m_sliceType == P_SLICE)<br>
-                {<br>
-                    threshold_2NxnU = splitData[0].mvCost[0] + splitData[1].mvCost[0];<br>
-                    threshold_2NxnD = splitData[2].mvCost[0] + splitData[3].mvCost[0];<br>
-<br>
-                    threshold_nLx2N = splitData[0].mvCost[0] + splitData[2].mvCost[0];<br>
-                    threshold_nRx2N = splitData[1].mvCost[0] + splitData[3].mvCost[0];<br>
-                }<br>
-                else<br>
-                {<br>
-                    threshold_2NxnU = (splitData[0].mvCost[0] + splitData[1].mvCost[0]<br>
-                                       + splitData[0].mvCost[1] + splitData[1].mvCost[1] + 1) >> 1;<br>
-                    threshold_2NxnD = (splitData[2].mvCost[0] + splitData[3].mvCost[0]<br>
-                                       + splitData[2].mvCost[1] + splitData[3].mvCost[1] + 1) >> 1;<br>
-<br>
-                    threshold_nLx2N = (splitData[0].mvCost[0] + splitData[2].mvCost[0]<br>
-                                       + splitData[0].mvCost[1] + splitData[2].mvCost[1] + 1) >> 1;<br>
-                    threshold_nRx2N = (splitData[1].mvCost[0] + splitData[3].mvCost[0]<br>
-                                       + splitData[1].mvCost[1] + splitData[3].mvCost[1] + 1) >> 1;<br>
-                }<br>
-<br>
-                bool bHor = false, bVer = false;<br>
-                if (bestInter->cu.m_partSize[0] == SIZE_2NxN)<br>
-                    bHor = true;<br>
-                else if (bestInter->cu.m_partSize[0] == SIZE_Nx2N)<br>
-                    bVer = true;<br>
-                else if (bestInter->cu.m_partSize[0] == SIZE_2Nx2N &&<br>
-                         md.bestMode && md.bestMode->cu.getQtRootCbf(0))<br>
-                {<br>
-                    bHor = true;<br>
-                    bVer = true;<br>
-                }<br>
-<br>
-                if (bHor)<br>
-                {<br>
-                    int try_2NxnD_first = threshold_2NxnD < threshold_2NxnU;<br>
-                    if (try_2NxnD_first && splitCost < md.pred[PRED_2Nx2N].sa8dCost + threshold_2NxnD)<br>
-                    {<br>
-                        refMasks[0] = allSplitRefs;                                    /* 75% top */<br>
-                        refMasks[1] = splitData[2].splitRefs | splitData[3].splitRefs; /* 25% bot */<br>
-                        md.pred[PRED_2NxnD].cu.initSubCU(parentCTU, cuGeom, qp);<br>
-                        checkInter_rd0_4(md.pred[PRED_2NxnD], cuGeom, SIZE_2NxnD, refMasks);<br>
-                        if (md.pred[PRED_2NxnD].sa8dCost < bestInter->sa8dCost)<br>
-                            bestInter = &md.pred[PRED_2NxnD];<br>
+                        threshold_nLx2N = (splitData[0].mvCost[0] + splitData[2].mvCost[0]<br>
+                                        + splitData[0].mvCost[1] + splitData[2].mvCost[1] + 1) >> 1;<br>
+                        threshold_nRx2N = (splitData[1].mvCost[0] + splitData[3].mvCost[0]<br>
+                                        + splitData[1].mvCost[1] + splitData[3].mvCost[1] + 1) >> 1;<br>
                     }<br>
<br>
-                    if (splitCost < md.pred[PRED_2Nx2N].sa8dCost + threshold_2NxnU)<br>
+                    bool bHor = false, bVer = false;<br>
+                    if (bestInter->cu.m_partSize[0] == SIZE_2NxN)<br>
+                        bHor = true;<br>
+                    else if (bestInter->cu.m_partSize[0] == SIZE_Nx2N)<br>
+                        bVer = true;<br>
+                    else if (bestInter->cu.m_partSize[0] == SIZE_2Nx2N &&<br>
+                        md.bestMode && md.bestMode->cu.getQtRootCbf(0))<br>
                     {<br>
-                        refMasks[0] = splitData[0].splitRefs | splitData[1].splitRefs; /* 25% top */<br>
-                        refMasks[1] = allSplitRefs;                                    /* 75% bot */<br>
-                        md.pred[PRED_2NxnU].cu.initSubCU(parentCTU, cuGeom, qp);<br>
-                        checkInter_rd0_4(md.pred[PRED_2NxnU], cuGeom, SIZE_2NxnU, refMasks);<br>
-                        if (md.pred[PRED_2NxnU].sa8dCost < bestInter->sa8dCost)<br>
-                            bestInter = &md.pred[PRED_2NxnU];<br>
+                        bHor = true;<br>
+                        bVer = true;<br>
                     }<br>
<br>
-                    if (!try_2NxnD_first && splitCost < md.pred[PRED_2Nx2N].sa8dCost + threshold_2NxnD)<br>
+                    if (bHor)<br>
                     {<br>
-                        refMasks[0] = allSplitRefs;                                    /* 75% top */<br>
-                        refMasks[1] = splitData[2].splitRefs | splitData[3].splitRefs; /* 25% bot */<br>
-                        md.pred[PRED_2NxnD].cu.initSubCU(parentCTU, cuGeom, qp);<br>
-                        checkInter_rd0_4(md.pred[PRED_2NxnD], cuGeom, SIZE_2NxnD, refMasks);<br>
-                        if (md.pred[PRED_2NxnD].sa8dCost < bestInter->sa8dCost)<br>
-                            bestInter = &md.pred[PRED_2NxnD];<br>
+                        int try_2NxnD_first = threshold_2NxnD < threshold_2NxnU;<br>
+                        if (try_2NxnD_first && splitCost < md.pred[PRED_2Nx2N].sa8dCost + threshold_2NxnD)<br>
+                        {<br>
+                            refMasks[0] = allSplitRefs;                                    /* 75% top */<br>
+                            refMasks[1] = splitData[2].splitRefs | splitData[3].splitRefs; /* 25% bot */<br>
+                            md.pred[PRED_2NxnD].cu.initSubCU(parentCTU, cuGeom, qp);<br>
+                            checkInter_rd0_4(md.pred[PRED_2NxnD], cuGeom, SIZE_2NxnD, refMasks);<br>
+                            if (md.pred[PRED_2NxnD].sa8dCost < bestInter->sa8dCost)<br>
+                                bestInter = &md.pred[PRED_2NxnD];<br>
+                        }<br>
+<br>
+                        if (splitCost < md.pred[PRED_2Nx2N].sa8dCost + threshold_2NxnU)<br>
+                        {<br>
+                            refMasks[0] = splitData[0].splitRefs | splitData[1].splitRefs; /* 25% top */<br>
+                            refMasks[1] = allSplitRefs;                                    /* 75% bot */<br>
+                            md.pred[PRED_2NxnU].cu.initSubCU(parentCTU, cuGeom, qp);<br>
+                            checkInter_rd0_4(md.pred[PRED_2NxnU], cuGeom, SIZE_2NxnU, refMasks);<br>
+                            if (md.pred[PRED_2NxnU].sa8dCost < bestInter->sa8dCost)<br>
+                                bestInter = &md.pred[PRED_2NxnU];<br>
+                        }<br>
+<br>
+                        if (!try_2NxnD_first && splitCost < md.pred[PRED_2Nx2N].sa8dCost + threshold_2NxnD)<br>
+                        {<br>
+                            refMasks[0] = allSplitRefs;                                    /* 75% top */<br>
+                            refMasks[1] = splitData[2].splitRefs | splitData[3].splitRefs; /* 25% bot */<br>
+                            md.pred[PRED_2NxnD].cu.initSubCU(parentCTU, cuGeom, qp);<br>
+                            checkInter_rd0_4(md.pred[PRED_2NxnD], cuGeom, SIZE_2NxnD, refMasks);<br>
+                            if (md.pred[PRED_2NxnD].sa8dCost < bestInter->sa8dCost)<br>
+                                bestInter = &md.pred[PRED_2NxnD];<br>
+                        }<br>
                     }<br>
-                }<br>
-                if (bVer)<br>
-                {<br>
-                    int try_nRx2N_first = threshold_nRx2N < threshold_nLx2N;<br>
-                    if (try_nRx2N_first && splitCost < md.pred[PRED_2Nx2N].sa8dCost + threshold_nRx2N)<br>
+                    if (bVer)<br>
                     {<br>
-                        refMasks[0] = allSplitRefs;                                    /* 75% left  */<br>
-                        refMasks[1] = splitData[1].splitRefs | splitData[3].splitRefs; /* 25% right */<br>
-                        md.pred[PRED_nRx2N].cu.initSubCU(parentCTU, cuGeom, qp);<br>
-                        checkInter_rd0_4(md.pred[PRED_nRx2N], cuGeom, SIZE_nRx2N, refMasks);<br>
-                        if (md.pred[PRED_nRx2N].sa8dCost < bestInter->sa8dCost)<br>
-                            bestInter = &md.pred[PRED_nRx2N];<br>
-                    }<br>
+                        int try_nRx2N_first = threshold_nRx2N < threshold_nLx2N;<br>
+                        if (try_nRx2N_first && splitCost < md.pred[PRED_2Nx2N].sa8dCost + threshold_nRx2N)<br>
+                        {<br>
+                            refMasks[0] = allSplitRefs;                                    /* 75% left  */<br>
+                            refMasks[1] = splitData[1].splitRefs | splitData[3].splitRefs; /* 25% right */<br>
+                            md.pred[PRED_nRx2N].cu.initSubCU(parentCTU, cuGeom, qp);<br>
+                            checkInter_rd0_4(md.pred[PRED_nRx2N], cuGeom, SIZE_nRx2N, refMasks);<br>
+                            if (md.pred[PRED_nRx2N].sa8dCost < bestInter->sa8dCost)<br>
+                                bestInter = &md.pred[PRED_nRx2N];<br>
+                        }<br>
<br>
-                    if (splitCost < md.pred[PRED_2Nx2N].sa8dCost + threshold_nLx2N)<br>
-                    {<br>
-                        refMasks[0] = splitData[0].splitRefs | splitData[2].splitRefs; /* 25% left  */<br>
-                        refMasks[1] = allSplitRefs;                                    /* 75% right */<br>
-                        md.pred[PRED_nLx2N].cu.initSubCU(parentCTU, cuGeom, qp);<br>
-                        checkInter_rd0_4(md.pred[PRED_nLx2N], cuGeom, SIZE_nLx2N, refMasks);<br>
-                        if (md.pred[PRED_nLx2N].sa8dCost < bestInter->sa8dCost)<br>
-                            bestInter = &md.pred[PRED_nLx2N];<br>
-                    }<br>
+                        if (splitCost < md.pred[PRED_2Nx2N].sa8dCost + threshold_nLx2N)<br>
+                        {<br>
+                            refMasks[0] = splitData[0].splitRefs | splitData[2].splitRefs; /* 25% left  */<br>
+                            refMasks[1] = allSplitRefs;                                    /* 75% right */<br>
+                            md.pred[PRED_nLx2N].cu.initSubCU(parentCTU, cuGeom, qp);<br>
+                            checkInter_rd0_4(md.pred[PRED_nLx2N], cuGeom, SIZE_nLx2N, refMasks);<br>
+                            if (md.pred[PRED_nLx2N].sa8dCost < bestInter->sa8dCost)<br>
+                                bestInter = &md.pred[PRED_nLx2N];<br>
+                        }<br>
<br>
-                    if (!try_nRx2N_first && splitCost < md.pred[PRED_2Nx2N].sa8dCost + threshold_nRx2N)<br>
-                    {<br>
-                        refMasks[0] = allSplitRefs;                                    /* 75% left  */<br>
-                        refMasks[1] = splitData[1].splitRefs | splitData[3].splitRefs; /* 25% right */<br>
-                        md.pred[PRED_nRx2N].cu.initSubCU(parentCTU, cuGeom, qp);<br>
-                        checkInter_rd0_4(md.pred[PRED_nRx2N], cuGeom, SIZE_nRx2N, refMasks);<br>
-                        if (md.pred[PRED_nRx2N].sa8dCost < bestInter->sa8dCost)<br>
-                            bestInter = &md.pred[PRED_nRx2N];<br>
+                        if (!try_nRx2N_first && splitCost < md.pred[PRED_2Nx2N].sa8dCost + threshold_nRx2N)<br>
+                        {<br>
+                            refMasks[0] = allSplitRefs;                                    /* 75% left  */<br>
+                            refMasks[1] = splitData[1].splitRefs | splitData[3].splitRefs; /* 25% right */<br>
+                            md.pred[PRED_nRx2N].cu.initSubCU(parentCTU, cuGeom, qp);<br>
+                            checkInter_rd0_4(md.pred[PRED_nRx2N], cuGeom, SIZE_nRx2N, refMasks);<br>
+                            if (md.pred[PRED_nRx2N].sa8dCost < bestInter->sa8dCost)<br>
+                                bestInter = &md.pred[PRED_nRx2N];<br>
+                        }<br>
                     }<br>
                 }<br>
             }<br>
@@ -1185,15 +1203,19 @@<br>
                         motionCompensation(bestInter->cu, pu, bestInter->predYuv, false, true);<br>
                     }<br>
                 }<br>
-                encodeResAndCalcRdInterCU(*bestInter, cuGeom);<br>
-                checkBestMode(*bestInter, depth);<br>
<br>
-                /* If BIDIR is available and within 17/16 of best inter option, choose by RDO */<br>
-                if (m_slice->m_sliceType == B_SLICE && md.pred[PRED_BIDIR].sa8dCost != MAX_INT64 &&<br>
-                    md.pred[PRED_BIDIR].sa8dCost * 16 <= bestInter->sa8dCost * 17)<br>
+                if (!chooseMerge)<br>
                 {<br>
-                    encodeResAndCalcRdInterCU(md.pred[PRED_BIDIR], cuGeom);<br>
-                    checkBestMode(md.pred[PRED_BIDIR], depth);<br>
+                    encodeResAndCalcRdInterCU(*bestInter, cuGeom);<br>
+                    checkBestMode(*bestInter, depth);<br>
+<br>
+                    /* If BIDIR is available and within 17/16 of best inter option, choose by RDO */<br>
+                    if (m_slice->m_sliceType == B_SLICE && md.pred[PRED_BIDIR].sa8dCost != MAX_INT64 &&<br>
+                        md.pred[PRED_BIDIR].sa8dCost * 16 <= bestInter->sa8dCost * 17)<br>
+                    {<br>
+                        encodeResAndCalcRdInterCU(md.pred[PRED_BIDIR], cuGeom);<br>
+                        checkBestMode(md.pred[PRED_BIDIR], depth);<br>
+                    }<br>
                 }<br>
<br>
                 if ((bTryIntra && md.bestMode->cu.getQtRootCbf(0)) ||<br>
@@ -1378,6 +1400,7 @@<br>
     bool foundSkip = false;<br>
     bool earlyskip = false;<br>
     bool splitIntra = true;<br>
+    bool skipRectAmp = false;<br>
<br>
     // avoid uninitialize value in below reference<br>
     if (m_param->limitModes)<br>
@@ -1389,14 +1412,19 @@<br>
<br>
     if (m_param->analysisMode == X265_ANALYSIS_LOAD)<br>
     {<br>
-        if (mightNotSplit && depth == m_reuseDepth[cuGeom.absPartIdx] && m_reuseModes[cuGeom.absPartIdx] == MODE_SKIP)<br>
+        if (mightNotSplit && depth == m_reuseDepth[cuGeom.absPartIdx])<br>
         {<br>
-            md.pred[PRED_SKIP].cu.initSubCU(parentCTU, cuGeom, qp);<br>
-            md.pred[PRED_MERGE].cu.initSubCU(parentCTU, cuGeom, qp);<br>
-            checkMerge2Nx2N_rd5_6(md.pred[PRED_SKIP], md.pred[PRED_MERGE], cuGeom);<br>
+            if (m_reuseModes[cuGeom.absPartIdx] == MODE_SKIP)<br>
+            {<br>
+                md.pred[PRED_SKIP].cu.initSubCU(parentCTU, cuGeom, qp);<br>
+                md.pred[PRED_MERGE].cu.initSubCU(parentCTU, cuGeom, qp);<br>
+                checkMerge2Nx2N_rd5_6(md.pred[PRED_SKIP], md.pred[PRED_MERGE], cuGeom);<br>
<br>
-            foundSkip = true;<br>
-            earlyskip = !!m_param->bEnableEarlySkip;<br>
+                foundSkip = true;<br>
+                earlyskip = !!m_param->bEnableEarlySkip;<br>
+            }<br>
+            if (m_reusePartSize[cuGeom.absPartIdx] == SIZE_2Nx2N)<br>
+                skipRectAmp = true && !!md.bestMode;<br>
         }<br>
     }<br>
<br>
@@ -1502,150 +1530,153 @@<br>
                 }<br>
             }<br>
<br>
-            if (m_param->bEnableRectInter)<br>
+            if (!skipRectAmp)<br>
             {<br>
-                uint64_t splitCost = splitData[0].sa8dCost + splitData[1].sa8dCost + splitData[2].sa8dCost + splitData[3].sa8dCost;<br>
-                uint32_t threshold_2NxN, threshold_Nx2N;<br>
+                if (m_param->bEnableRectInter)<br>
+                {<br>
+                    uint64_t splitCost = splitData[0].sa8dCost + splitData[1].sa8dCost + splitData[2].sa8dCost + splitData[3].sa8dCost;<br>
+                    uint32_t threshold_2NxN, threshold_Nx2N;<br>
<br>
-                if (m_slice->m_sliceType == P_SLICE)<br>
-                {<br>
-                    threshold_2NxN = splitData[0].mvCost[0] + splitData[1].mvCost[0];<br>
-                    threshold_Nx2N = splitData[0].mvCost[0] + splitData[2].mvCost[0];<br>
-                }<br>
-                else<br>
-                {<br>
-                    threshold_2NxN = (splitData[0].mvCost[0] + splitData[1].mvCost[0]<br>
-                                    + splitData[0].mvCost[1] + splitData[1].mvCost[1] + 1) >> 1;<br>
-                    threshold_Nx2N = (splitData[0].mvCost[0] + splitData[2].mvCost[0]<br>
-                                    + splitData[0].mvCost[1] + splitData[2].mvCost[1] + 1) >> 1;<br>
-                }<br>
-<br>
-                int try_2NxN_first = threshold_2NxN < threshold_Nx2N;<br>
-                if (try_2NxN_first && splitCost < md.bestMode->rdCost + threshold_2NxN)<br>
-                {<br>
-                    refMasks[0] = splitData[0].splitRefs | splitData[1].splitRefs; /* top */<br>
-                    refMasks[1] = splitData[2].splitRefs | splitData[3].splitRefs; /* bot */<br>
-                    md.pred[PRED_2NxN].cu.initSubCU(parentCTU, cuGeom, qp);<br>
-                    checkInter_rd5_6(md.pred[PRED_2NxN], cuGeom, SIZE_2NxN, refMasks);<br>
-                    checkBestMode(md.pred[PRED_2NxN], cuGeom.depth);<br>
-                }<br>
-<br>
-                if (splitCost < md.bestMode->rdCost + threshold_Nx2N)<br>
-                {<br>
-                    refMasks[0] = splitData[0].splitRefs | splitData[2].splitRefs; /* left */<br>
-                    refMasks[1] = splitData[1].splitRefs | splitData[3].splitRefs; /* right */<br>
-                    md.pred[PRED_Nx2N].cu.initSubCU(parentCTU, cuGeom, qp);<br>
-                    checkInter_rd5_6(md.pred[PRED_Nx2N], cuGeom, SIZE_Nx2N, refMasks);<br>
-                    checkBestMode(md.pred[PRED_Nx2N], cuGeom.depth);<br>
-                }<br>
-<br>
-                if (!try_2NxN_first && splitCost < md.bestMode->rdCost + threshold_2NxN)<br>
-                {<br>
-                    refMasks[0] = splitData[0].splitRefs | splitData[1].splitRefs; /* top */<br>
-                    refMasks[1] = splitData[2].splitRefs | splitData[3].splitRefs; /* bot */<br>
-                    md.pred[PRED_2NxN].cu.initSubCU(parentCTU, cuGeom, qp);<br>
-                    checkInter_rd5_6(md.pred[PRED_2NxN], cuGeom, SIZE_2NxN, refMasks);<br>
-                    checkBestMode(md.pred[PRED_2NxN], cuGeom.depth);<br>
-                }<br>
-            }<br>
-<br>
-            // Try AMP (SIZE_2NxnU, SIZE_2NxnD, SIZE_nLx2N, SIZE_nRx2N)<br>
-            if (m_slice->m_sps->maxAMPDepth > depth)<br>
-            {<br>
-                uint64_t splitCost = splitData[0].sa8dCost + splitData[1].sa8dCost + splitData[2].sa8dCost + splitData[3].sa8dCost;<br>
-                uint32_t threshold_2NxnU, threshold_2NxnD, threshold_nLx2N, threshold_nRx2N;<br>
-<br>
-                if (m_slice->m_sliceType == P_SLICE)<br>
-                {<br>
-                    threshold_2NxnU = splitData[0].mvCost[0] + splitData[1].mvCost[0];<br>
-                    threshold_2NxnD = splitData[2].mvCost[0] + splitData[3].mvCost[0];<br>
-<br>
-                    threshold_nLx2N = splitData[0].mvCost[0] + splitData[2].mvCost[0];<br>
-                    threshold_nRx2N = splitData[1].mvCost[0] + splitData[3].mvCost[0];<br>
-                }<br>
-                else<br>
-                {<br>
-                    threshold_2NxnU = (splitData[0].mvCost[0] + splitData[1].mvCost[0]<br>
+                    if (m_slice->m_sliceType == P_SLICE)<br>
+                    {<br>
+                        threshold_2NxN = splitData[0].mvCost[0] + splitData[1].mvCost[0];<br>
+                        threshold_Nx2N = splitData[0].mvCost[0] + splitData[2].mvCost[0];<br>
+                    }<br>
+                    else<br>
+                    {<br>
+                        threshold_2NxN = (splitData[0].mvCost[0] + splitData[1].mvCost[0]<br>
                                        + splitData[0].mvCost[1] + splitData[1].mvCost[1] + 1) >> 1;<br>
-                    threshold_2NxnD = (splitData[2].mvCost[0] + splitData[3].mvCost[0]<br>
-                                       + splitData[2].mvCost[1] + splitData[3].mvCost[1] + 1) >> 1;<br>
-<br>
-                    threshold_nLx2N = (splitData[0].mvCost[0] + splitData[2].mvCost[0]<br>
+                        threshold_Nx2N = (splitData[0].mvCost[0] + splitData[2].mvCost[0]<br>
                                        + splitData[0].mvCost[1] + splitData[2].mvCost[1] + 1) >> 1;<br>
-                    threshold_nRx2N = (splitData[1].mvCost[0] + splitData[3].mvCost[0]<br>
-                                       + splitData[1].mvCost[1] + splitData[3].mvCost[1] + 1) >> 1;<br>
-                }<br>
-<br>
-                bool bHor = false, bVer = false;<br>
-                if (md.bestMode->cu.m_partSize[0] == SIZE_2NxN)<br>
-                    bHor = true;<br>
-                else if (md.bestMode->cu.m_partSize[0] == SIZE_Nx2N)<br>
-                    bVer = true;<br>
-                else if (md.bestMode->cu.m_partSize[0] == SIZE_2Nx2N && !md.bestMode->cu.m_mergeFlag[0])<br>
-                {<br>
-                    bHor = true;<br>
-                    bVer = true;<br>
-                }<br>
-<br>
-                if (bHor)<br>
-                {<br>
-                    int try_2NxnD_first = threshold_2NxnD < threshold_2NxnU;<br>
-                    if (try_2NxnD_first && splitCost < md.bestMode->rdCost + threshold_2NxnD)<br>
-                    {<br>
-                        refMasks[0] = allSplitRefs;                                    /* 75% top */<br>
-                        refMasks[1] = splitData[2].splitRefs | splitData[3].splitRefs; /* 25% bot */<br>
-                        md.pred[PRED_2NxnD].cu.initSubCU(parentCTU, cuGeom, qp);<br>
-                        checkInter_rd5_6(md.pred[PRED_2NxnD], cuGeom, SIZE_2NxnD, refMasks);<br>
-                        checkBestMode(md.pred[PRED_2NxnD], cuGeom.depth);<br>
                     }<br>
<br>
-                    if (splitCost < md.bestMode->rdCost + threshold_2NxnU)<br>
+                    int try_2NxN_first = threshold_2NxN < threshold_Nx2N;<br>
+                    if (try_2NxN_first && splitCost < md.bestMode->rdCost + threshold_2NxN)<br>
                     {<br>
-                        refMasks[0] = splitData[0].splitRefs | splitData[1].splitRefs; /* 25% top */<br>
-                        refMasks[1] = allSplitRefs;                                    /* 75% bot */<br>
-                        md.pred[PRED_2NxnU].cu.initSubCU(parentCTU, cuGeom, qp);<br>
-                        checkInter_rd5_6(md.pred[PRED_2NxnU], cuGeom, SIZE_2NxnU, refMasks);<br>
-                        checkBestMode(md.pred[PRED_2NxnU], cuGeom.depth);<br>
+                        refMasks[0] = splitData[0].splitRefs | splitData[1].splitRefs; /* top */<br>
+                        refMasks[1] = splitData[2].splitRefs | splitData[3].splitRefs; /* bot */<br>
+                        md.pred[PRED_2NxN].cu.initSubCU(parentCTU, cuGeom, qp);<br>
+                        checkInter_rd5_6(md.pred[PRED_2NxN], cuGeom, SIZE_2NxN, refMasks);<br>
+                        checkBestMode(md.pred[PRED_2NxN], cuGeom.depth);<br>
                     }<br>
<br>
-                    if (!try_2NxnD_first && splitCost < md.bestMode->rdCost + threshold_2NxnD)<br>
+                    if (splitCost < md.bestMode->rdCost + threshold_Nx2N)<br>
                     {<br>
-                        refMasks[0] = allSplitRefs;                                    /* 75% top */<br>
-                        refMasks[1] = splitData[2].splitRefs | splitData[3].splitRefs; /* 25% bot */<br>
-                        md.pred[PRED_2NxnD].cu.initSubCU(parentCTU, cuGeom, qp);<br>
-                        checkInter_rd5_6(md.pred[PRED_2NxnD], cuGeom, SIZE_2NxnD, refMasks);<br>
-                        checkBestMode(md.pred[PRED_2NxnD], cuGeom.depth);<br>
+                        refMasks[0] = splitData[0].splitRefs | splitData[2].splitRefs; /* left */<br>
+                        refMasks[1] = splitData[1].splitRefs | splitData[3].splitRefs; /* right */<br>
+                        md.pred[PRED_Nx2N].cu.initSubCU(parentCTU, cuGeom, qp);<br>
+                        checkInter_rd5_6(md.pred[PRED_Nx2N], cuGeom, SIZE_Nx2N, refMasks);<br>
+                        checkBestMode(md.pred[PRED_Nx2N], cuGeom.depth);<br>
+                    }<br>
+<br>
+                    if (!try_2NxN_first && splitCost < md.bestMode->rdCost + threshold_2NxN)<br>
+                    {<br>
+                        refMasks[0] = splitData[0].splitRefs | splitData[1].splitRefs; /* top */<br>
+                        refMasks[1] = splitData[2].splitRefs | splitData[3].splitRefs; /* bot */<br>
+                        md.pred[PRED_2NxN].cu.initSubCU(parentCTU, cuGeom, qp);<br>
+                        checkInter_rd5_6(md.pred[PRED_2NxN], cuGeom, SIZE_2NxN, refMasks);<br>
+                        checkBestMode(md.pred[PRED_2NxN], cuGeom.depth);<br>
                     }<br>
                 }<br>
<br>
-                if (bVer)<br>
+                // Try AMP (SIZE_2NxnU, SIZE_2NxnD, SIZE_nLx2N, SIZE_nRx2N)<br>
+                if (m_slice->m_sps->maxAMPDepth > depth)<br>
                 {<br>
-                    int try_nRx2N_first = threshold_nRx2N < threshold_nLx2N;<br>
-                    if (try_nRx2N_first && splitCost < md.bestMode->rdCost + threshold_nRx2N)<br>
+                    uint64_t splitCost = splitData[0].sa8dCost + splitData[1].sa8dCost + splitData[2].sa8dCost + splitData[3].sa8dCost;<br>
+                    uint32_t threshold_2NxnU, threshold_2NxnD, threshold_nLx2N, threshold_nRx2N;<br>
+<br>
+                    if (m_slice->m_sliceType == P_SLICE)<br>
                     {<br>
-                        refMasks[0] = allSplitRefs;                                    /* 75% left  */<br>
-                        refMasks[1] = splitData[1].splitRefs | splitData[3].splitRefs; /* 25% right */<br>
-                        md.pred[PRED_nRx2N].cu.initSubCU(parentCTU, cuGeom, qp);<br>
-                        checkInter_rd5_6(md.pred[PRED_nRx2N], cuGeom, SIZE_nRx2N, refMasks);<br>
-                        checkBestMode(md.pred[PRED_nRx2N], cuGeom.depth);<br>
+                        threshold_2NxnU = splitData[0].mvCost[0] + splitData[1].mvCost[0];<br>
+                        threshold_2NxnD = splitData[2].mvCost[0] + splitData[3].mvCost[0];<br>
+<br>
+                        threshold_nLx2N = splitData[0].mvCost[0] + splitData[2].mvCost[0];<br>
+                        threshold_nRx2N = splitData[1].mvCost[0] + splitData[3].mvCost[0];<br>
+                    }<br>
+                    else<br>
+                    {<br>
+                        threshold_2NxnU = (splitData[0].mvCost[0] + splitData[1].mvCost[0]<br>
+                                        + splitData[0].mvCost[1] + splitData[1].mvCost[1] + 1) >> 1;<br>
+                        threshold_2NxnD = (splitData[2].mvCost[0] + splitData[3].mvCost[0]<br>
+                                        + splitData[2].mvCost[1] + splitData[3].mvCost[1] + 1) >> 1;<br>
+<br>
+                        threshold_nLx2N = (splitData[0].mvCost[0] + splitData[2].mvCost[0]<br>
+                                        + splitData[0].mvCost[1] + splitData[2].mvCost[1] + 1) >> 1;<br>
+                        threshold_nRx2N = (splitData[1].mvCost[0] + splitData[3].mvCost[0]<br>
+                                        + splitData[1].mvCost[1] + splitData[3].mvCost[1] + 1) >> 1;<br>
                     }<br>
<br>
-                    if (splitCost < md.bestMode->rdCost + threshold_nLx2N)<br>
+                    bool bHor = false, bVer = false;<br>
+                    if (md.bestMode->cu.m_partSize[0] == SIZE_2NxN)<br>
+                        bHor = true;<br>
+                    else if (md.bestMode->cu.m_partSize[0] == SIZE_Nx2N)<br>
+                        bVer = true;<br>
+                    else if (md.bestMode->cu.m_partSize[0] == SIZE_2Nx2N && !md.bestMode->cu.m_mergeFlag[0])<br>
                     {<br>
-                        refMasks[0] = splitData[0].splitRefs | splitData[2].splitRefs; /* 25% left  */<br>
-                        refMasks[1] = allSplitRefs;                                    /* 75% right */<br>
-                        md.pred[PRED_nLx2N].cu.initSubCU(parentCTU, cuGeom, qp);<br>
-                        checkInter_rd5_6(md.pred[PRED_nLx2N], cuGeom, SIZE_nLx2N, refMasks);<br>
-                        checkBestMode(md.pred[PRED_nLx2N], cuGeom.depth);<br>
+                        bHor = true;<br>
+                        bVer = true;<br>
                     }<br>
<br>
-                    if (!try_nRx2N_first && splitCost < md.bestMode->rdCost + threshold_nRx2N)<br>
+                    if (bHor)<br>
                     {<br>
-                        refMasks[0] = allSplitRefs;                                    /* 75% left  */<br>
-                        refMasks[1] = splitData[1].splitRefs | splitData[3].splitRefs; /* 25% right */<br>
-                        md.pred[PRED_nRx2N].cu.initSubCU(parentCTU, cuGeom, qp);<br>
-                        checkInter_rd5_6(md.pred[PRED_nRx2N], cuGeom, SIZE_nRx2N, refMasks);<br>
-                        checkBestMode(md.pred[PRED_nRx2N], cuGeom.depth);<br>
+                        int try_2NxnD_first = threshold_2NxnD < threshold_2NxnU;<br>
+                        if (try_2NxnD_first && splitCost < md.bestMode->rdCost + threshold_2NxnD)<br>
+                        {<br>
+                            refMasks[0] = allSplitRefs;                                    /* 75% top */<br>
+                            refMasks[1] = splitData[2].splitRefs | splitData[3].splitRefs; /* 25% bot */<br>
+                            md.pred[PRED_2NxnD].cu.initSubCU(parentCTU, cuGeom, qp);<br>
+                            checkInter_rd5_6(md.pred[PRED_2NxnD], cuGeom, SIZE_2NxnD, refMasks);<br>
+                            checkBestMode(md.pred[PRED_2NxnD], cuGeom.depth);<br>
+                        }<br>
+<br>
+                        if (splitCost < md.bestMode->rdCost + threshold_2NxnU)<br>
+                        {<br>
+                            refMasks[0] = splitData[0].splitRefs | splitData[1].splitRefs; /* 25% top */<br>
+                            refMasks[1] = allSplitRefs;                                    /* 75% bot */<br>
+                            md.pred[PRED_2NxnU].cu.initSubCU(parentCTU, cuGeom, qp);<br>
+                            checkInter_rd5_6(md.pred[PRED_2NxnU], cuGeom, SIZE_2NxnU, refMasks);<br>
+                            checkBestMode(md.pred[PRED_2NxnU], cuGeom.depth);<br>
+                        }<br>
+<br>
+                        if (!try_2NxnD_first && splitCost < md.bestMode->rdCost + threshold_2NxnD)<br>
+                        {<br>
+                            refMasks[0] = allSplitRefs;                                    /* 75% top */<br>
+                            refMasks[1] = splitData[2].splitRefs | splitData[3].splitRefs; /* 25% bot */<br>
+                            md.pred[PRED_2NxnD].cu.initSubCU(parentCTU, cuGeom, qp);<br>
+                            checkInter_rd5_6(md.pred[PRED_2NxnD], cuGeom, SIZE_2NxnD, refMasks);<br>
+                            checkBestMode(md.pred[PRED_2NxnD], cuGeom.depth);<br>
+                        }<br>
+                    }<br>
+<br>
+                    if (bVer)<br>
+                    {<br>
+                        int try_nRx2N_first = threshold_nRx2N < threshold_nLx2N;<br>
+                        if (try_nRx2N_first && splitCost < md.bestMode->rdCost + threshold_nRx2N)<br>
+                        {<br>
+                            refMasks[0] = allSplitRefs;                                    /* 75% left  */<br>
+                            refMasks[1] = splitData[1].splitRefs | splitData[3].splitRefs; /* 25% right */<br>
+                            md.pred[PRED_nRx2N].cu.initSubCU(parentCTU, cuGeom, qp);<br>
+                            checkInter_rd5_6(md.pred[PRED_nRx2N], cuGeom, SIZE_nRx2N, refMasks);<br>
+                            checkBestMode(md.pred[PRED_nRx2N], cuGeom.depth);<br>
+                        }<br>
+<br>
+                        if (splitCost < md.bestMode->rdCost + threshold_nLx2N)<br>
+                        {<br>
+                            refMasks[0] = splitData[0].splitRefs | splitData[2].splitRefs; /* 25% left  */<br>
+                            refMasks[1] = allSplitRefs;                                    /* 75% right */<br>
+                            md.pred[PRED_nLx2N].cu.initSubCU(parentCTU, cuGeom, qp);<br>
+                            checkInter_rd5_6(md.pred[PRED_nLx2N], cuGeom, SIZE_nLx2N, refMasks);<br>
+                            checkBestMode(md.pred[PRED_nLx2N], cuGeom.depth);<br>
+                        }<br>
+<br>
+                        if (!try_nRx2N_first && splitCost < md.bestMode->rdCost + threshold_nRx2N)<br>
+                        {<br>
+                            refMasks[0] = allSplitRefs;                                    /* 75% left  */<br>
+                            refMasks[1] = splitData[1].splitRefs | splitData[3].splitRefs; /* 25% right */<br>
+                            md.pred[PRED_nRx2N].cu.initSubCU(parentCTU, cuGeom, qp);<br>
+                            checkInter_rd5_6(md.pred[PRED_nRx2N], cuGeom, SIZE_nRx2N, refMasks);<br>
+                            checkBestMode(md.pred[PRED_nRx2N], cuGeom.depth);<br>
+                        }<br>
                     }<br>
                 }<br>
             }<br>
diff -r 2de6cb99313a -r 5bccf2596d8a source/encoder/analysis.h<br>
--- a/source/encoder/analysis.h Mon Mar 21 13:50:14 2016 +0530<br>
+++ b/source/encoder/analysis.h Thu Mar 24 16:36:55 2016 +0530<br>
@@ -122,6 +122,8 @@<br>
     int32_t*             m_reuseRef;<br>
     uint8_t*             m_reuseDepth;<br>
     uint8_t*             m_reuseModes;<br>
+    uint8_t*             m_reusePartSize;<br>
+    uint8_t*             m_reuseMergeFlag;<br>
<br>
     uint32_t m_splitRefIdx[4];<br>
     uint64_t* cacheCost;<br>
diff -r 2de6cb99313a -r 5bccf2596d8a source/encoder/encoder.cpp<br>
--- a/source/encoder/encoder.cpp        Mon Mar 21 13:50:14 2016 +0530<br>
+++ b/source/encoder/encoder.cpp        Thu Mar 24 16:36:55 2016 +0530<br>
@@ -1918,6 +1918,8 @@<br>
         CHECKED_MALLOC_ZERO(interData->ref, int32_t, analysis->numCUsInFrame * X265_MAX_PRED_MODE_PER_CTU * numDir);<br>
         CHECKED_MALLOC(interData->depth, uint8_t, analysis->numPartitions * analysis->numCUsInFrame);<br>
         CHECKED_MALLOC(interData->modes, uint8_t, analysis->numPartitions * analysis->numCUsInFrame);<br>
+        CHECKED_MALLOC(interData->partSize, uint8_t, analysis->numPartitions * analysis->numCUsInFrame);<br>
+        CHECKED_MALLOC(interData->mergeFlag, uint8_t, analysis->numPartitions * analysis->numCUsInFrame);<br>
         CHECKED_MALLOC_ZERO(interData->wt, WeightParam, 3 * numDir);<br>
         analysis->interData = interData;<br>
     }<br>
@@ -1943,6 +1945,8 @@<br>
         X265_FREE(((analysis_inter_data*)analysis->interData)->ref);<br>
         X265_FREE(((analysis_inter_data*)analysis->interData)->depth);<br>
         X265_FREE(((analysis_inter_data*)analysis->interData)->modes);<br>
+        X265_FREE(((analysis_inter_data*)analysis->interData)->mergeFlag);<br>
+        X265_FREE(((analysis_inter_data*)analysis->interData)->partSize);<br>
         X265_FREE(((analysis_inter_data*)analysis->interData)->wt);<br>
         X265_FREE(analysis->interData);<br>
     }<br>
@@ -2029,13 +2033,15 @@<br>
<br>
     else<br>
     {<br>
-        uint8_t *tempBuf = NULL, *depthBuf = NULL, *modeBuf = NULL;<br>
+        uint8_t *tempBuf = NULL, *depthBuf = NULL, *modeBuf = NULL, *partSize = NULL, *mergeFlag = NULL;<br>
<br>
-        tempBuf = X265_MALLOC(uint8_t, depthBytes * 2);<br>
-        X265_FREAD(tempBuf, sizeof(uint8_t), depthBytes * 2, m_analysisFile);<br>
+        tempBuf = X265_MALLOC(uint8_t, depthBytes * 4);<br>
+        X265_FREAD(tempBuf, sizeof(uint8_t), depthBytes * 4, m_analysisFile);<br>
<br>
         depthBuf = tempBuf;<br>
-        modeBuf  = tempBuf + depthBytes;<br>
+        modeBuf = tempBuf + depthBytes;<br>
+        partSize = modeBuf + depthBytes;<br>
+        mergeFlag = partSize + depthBytes;<br>
<br>
         size_t count = 0;<br>
         for (uint32_t d = 0; d < depthBytes; d++)<br>
@@ -2043,13 +2049,15 @@<br>
             int bytes = analysis->numPartitions >> (depthBuf[d] * 2);<br>
             memset(&((analysis_inter_data *)analysis->interData)->depth[count], depthBuf[d], bytes);<br>
             memset(&((analysis_inter_data *)analysis->interData)->modes[count], modeBuf[d], bytes);<br>
+            memset(&((analysis_inter_data *)analysis->interData)->partSize[count], partSize[d], bytes);<br>
+            memset(&((analysis_inter_data *)analysis->interData)->mergeFlag[count], mergeFlag[d], bytes);<br>
             count += bytes;<br>
         }<br>
-<br>
+<br>
         X265_FREE(tempBuf);<br>
-<br>
+<br>
         int numDir = analysis->sliceType == X265_TYPE_P ? 1 : 2;<br>
-        X265_FREAD(((analysis_inter_data *)analysis->interData)->ref, sizeof(int32_t), analysis->numCUsInFrame * X265_MAX_PRED_MODE_PER_CTU * numDir, m_analysisFile);<br>
+        X265_FREAD(((analysis_inter_data *)analysis->interData)->ref, sizeof(int32_t), analysis->numCUsInFrame * X265_MAX_PRED_MODE_PER_CTU * numDir, m_analysisFile);<br>
         uint32_t numPlanes = m_param->internalCsp == X265_CSP_I400 ? 1 : 3;<br>
         X265_FREAD(((analysis_inter_data *)analysis->interData)->wt, sizeof(WeightParam), numPlanes * numDir, m_analysisFile);<br>
         consumedBytes += frameRecordSize;<br>
@@ -2105,6 +2113,8 @@<br>
         {<br>
             uint8_t depth = 0;<br>
             uint8_t predMode = 0;<br>
+            uint8_t partSize = 0;<br>
+            uint8_t mergeFlag = 0;<br>
<br>
             CUData* ctu = curEncData.getPicCTU(cuAddr);<br>
             analysis_inter_data* interDataCTU = (analysis_inter_data*)analysis->interData;<br>
@@ -2115,8 +2125,17 @@<br>
                 interDataCTU->depth[depthBytes] = depth;<br>
<br>
                 predMode = ctu->m_predMode[absPartIdx];<br>
+                if (ctu->m_refIdx[1][absPartIdx] != -1)<br>
+                    predMode = 4; // used as indiacator if the block is coded as bidir<br>
+<br>
                 interDataCTU->modes[depthBytes] = predMode;<br>
<br>
+                partSize = ctu->m_partSize[absPartIdx];<br>
+                interDataCTU->partSize[depthBytes] = partSize;<br>
+<br>
+                mergeFlag = ctu->m_mergeFlag[absPartIdx];<br>
+                interDataCTU->mergeFlag[depthBytes] = mergeFlag;<br>
+<br>
                 absPartIdx += ctu->m_numPartitions >> (depth * 2);<br>
             }<br>
         }<br>
@@ -2130,9 +2149,9 @@<br>
     else<br>
     {<br>
         int numDir = (analysis->sliceType == X265_TYPE_P) ? 1 : 2;<br>
-        analysis->frameRecordSize += depthBytes * 2;<br>
-        analysis->frameRecordSize += sizeof(MV) * analysis->numCUsInFrame * X265_MAX_PRED_MODE_PER_CTU * numDir;<br>
-        analysis->frameRecordSize += sizeof(WeightParam) * 3 * numDir;<br>
+        analysis->frameRecordSize += depthBytes * 4;<br>
+        analysis->frameRecordSize += sizeof(int32_t)* analysis->numCUsInFrame * X265_MAX_PRED_MODE_PER_CTU * numDir;<br>
+        analysis->frameRecordSize += sizeof(WeightParam)* 3 * numDir;<br>
     }<br>
     X265_FWRITE(&analysis->frameRecordSize, sizeof(uint32_t), 1, m_analysisFile);<br>
     X265_FWRITE(&depthBytes, sizeof(uint32_t), 1, m_analysisFile);<br>
@@ -2155,6 +2174,8 @@<br>
         int numDir = analysis->sliceType == X265_TYPE_P ? 1 : 2;<br>
         X265_FWRITE(((analysis_inter_data*)analysis->interData)->depth, sizeof(uint8_t), depthBytes, m_analysisFile);<br>
         X265_FWRITE(((analysis_inter_data*)analysis->interData)->modes, sizeof(uint8_t), depthBytes, m_analysisFile);<br>
+        X265_FWRITE(((analysis_inter_data*)analysis->interData)->partSize, sizeof(uint8_t), depthBytes, m_analysisFile);<br>
+        X265_FWRITE(((analysis_inter_data*)analysis->interData)->mergeFlag, sizeof(uint8_t), depthBytes, m_analysisFile);<br>
         X265_FWRITE(((analysis_inter_data*)analysis->interData)->ref, sizeof(int32_t), analysis->numCUsInFrame * X265_MAX_PRED_MODE_PER_CTU * numDir, m_analysisFile);<br>
         uint32_t numPlanes = m_param->internalCsp == X265_CSP_I400 ? 1 : 3;<br>
         X265_FWRITE(((analysis_inter_data*)analysis->interData)->wt, sizeof(WeightParam), numPlanes * numDir, m_analysisFile);<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>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><div><div>Deepthi Nandakumar<br></div>Engineering Manager, x265<br></div>Multicoreware, Inc<br></div></div>
</div>