<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Dec 21, 2017 at 2:02 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"># HG changeset patch<br>
# User Santhoshini Sekar <<a href="mailto:santhoshini@multicorewareinc.com">santhoshini@multicorewareinc.<wbr>com</a>><br>
# Date 1513677810 -19800<br>
# Tue Dec 19 15:33:30 2017 +0530<br>
# Node ID 61b2cbf1f0e4b19d5ec0d0d8675ad1<wbr>0a0befc0f1<br>
# Parent 57eaef9abfd8204b568498d4a37a23<wbr>391e790d44<br>
fix bugs in analysis-reuse-level=7 and refine-mv-type=AVC<br>
<br>
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.<wbr>initSubCU(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.<wbr>initSubCU(parentCTU, cuGeom, qp);<br>
md.pred[PRED_MERGE].cu.<wbr>initSubCU(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[(<wbr>mbIndex * 16) + cuOffset];<br>
-<br>
+ (interData)->sadCost[cuPos + cuOffset] = (srcInterData)->sadCost[(<wbr>mbIndex * 16) + cuOffset];<br>
(interData)->interDir[cuPos + cuOffset] = (srcInterData)->interDir[(<wbr>mbIndex * 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][(<wbr>mbIndex * 16) + cuOffset];<br>
memcpy(&(interData)->mv[k][<wbr>cuPos + cuOffset], &(srcInterData)->mv[k][(<wbr>mbIndex * 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.<wbr>interData)->mv[k][(mbIndex * 16) + cuOffset].x;<br>
- int mv_y = ((analysis_inter_data *)curFrame->m_analysisData.<wbr>interData)->mv[k][(mbIndex * 16) + cuOffset].y;<br>
+ int mv_x = (interData)->mv[k][cuPos + cuOffset].x;<br>
+ int mv_y = (interData)->mv[k][cuPos + cuOffset].y;<br>
if ((mv_x*mv_x + mv_y*mv_y) <= MVTHRESHOLD)<br>
memset(&curFrame->m_<wbr>analysisData.modeFlag[k][cuPos + cuOffset], 1, bytes);<br>
}<br>
@@ -640,9 +640,10 @@<br>
if (m_param->analysisReuseLevel > 4)<br>
{<br>
memset(&(currInterData)-><wbr>partSize[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)-><wbr>partSize[d]];<br>
+ for (int pu = 0; pu < numPU; pu++)<br>
{<br>
+ if (pu) d++;<br>
(currInterData)->mergeFlag[<wbr>count + pu] = (interData)->mergeFlag[d];<br>
if (m_param->analysisReuseLevel >= 7)<br>
{<br>
@@ -654,8 +655,8 @@<br>
memcpy(&(currInterData)->mv[i]<wbr>[count + pu], &(interData)->mv[i][d], sizeof(MV));<br>
if (m_param->analysisReuseLevel == 7 && numPU == PU_2Nx2N && m_param->num4x4Partitions <= 16)<br>
{<br>
- int mv_x = ((analysis_inter_data *)curFrame->m_analysisData.<wbr>interData)->mv[i][count + pu].x;<br>
- int mv_y = ((analysis_inter_data *)curFrame->m_analysisData.<wbr>interData)->mv[i][count + pu].y;<br>
+ int mv_x = (currInterData)->mv[i][count + pu].x;<br>
+ int mv_y = (currInterData)->mv[i][count + pu].y;<br>
if ((mv_x*mv_x + mv_y*mv_y) <= MVTHRESHOLD)<br>
memset(&curFrame->m_<wbr>analysisData.modeFlag[i][count + pu], 1, bytes);<br>
}<br>
@@ -3061,12 +3062,13 @@<br>
if (m_param->analysisReuseLevel >= 7)<br>
{<br>
CHECKED_MALLOC(interData-><wbr>interDir, uint8_t, analysis->numPartitions * analysis->numCUsInFrame);<br>
+ CHECKED_MALLOC(interData-><wbr>sadCost, int64_t, analysis->numPartitions * analysis->numCUsInFrame);<br>
for (int dir = 0; dir < numDir; dir++)<br>
{<br>
CHECKED_MALLOC(interData-><wbr>mvpIdx[dir], uint8_t, analysis->numPartitions * analysis->numCUsInFrame);<br>
CHECKED_MALLOC(interData-><wbr>refIdx[dir], int8_t, analysis->numPartitions * analysis->numCUsInFrame);<br>
CHECKED_MALLOC(interData->mv[<wbr>dir], MV, analysis->numPartitions * analysis->numCUsInFrame);<br>
- CHECKED_MALLOC(analysis-><wbr>modeFlag[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>
<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 class="gmail_extra">Pushed.</div></div>