<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Mar 5, 2018 at 3:27 PM, <span dir="ltr"><<a href="mailto:bhavna@multicorewareinc.com" target="_blank">bhavna@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 1516860441 -19800<br>
# Thu Jan 25 11:37:21 2018 +0530<br>
# Node ID a12d4abf477016158397064730afa1<wbr>60a067c3e9<br>
# Parent 55eb3992299530de882829de0d3c0f<wbr>ea6d58b70d<br>
use MV from analysis-save encode as MVP in load mode for refine-inter levels<br>
<br>
diff -r 55eb39922995 -r a12d4abf4770 source/encoder/analysis.cpp<br>
--- a/source/encoder/analysis.cpp Wed Feb 28 11:09:18 2018 +0530<br>
+++ b/source/encoder/analysis.cpp Thu Jan 25 11:37:21 2018 +0530<br>
@@ -2455,7 +2455,7 @@<br>
}<br>
if (!mode.cu.m_mergeFlag[pu.<wbr>puAbsPartIdx])<br>
{<br>
- if (m_param->mvRefine)<br>
+ if (m_param->mvRefine || m_param->interRefine == 1)<br>
m_me.setSourcePU(*mode.<wbr>fencYuv, pu.ctuAddr, pu.cuAbsPartIdx, pu.puAbsPartIdx, pu.width, pu.height, m_param->searchMethod, m_param->subpelRefine, false);<br>
//AMVP<br>
MV mvc[(MD_ABOVE_LEFT + 1) * 2 + 2];<br>
@@ -2465,15 +2465,20 @@<br>
int ref = mode.cu.m_refIdx[list][pu.<wbr>puAbsPartIdx];<br>
if (ref == -1)<br>
continue;<br>
- mode.cu.getPMV(mode.<wbr>interNeighbours, list, ref, mode.amvpCand[list][ref], mvc);<br>
- MV mvp = mode.amvpCand[list][ref][mode.<wbr>cu.m_mvpIdx[list][pu.<wbr>puAbsPartIdx]];<br>
- if (m_param->mvRefine)<br>
+ MV mvp;<br>
+<br>
+ int numMvc = mode.cu.getPMV(mode.<wbr>interNeighbours, list, ref, mode.amvpCand[list][ref], mvc);<br>
+ if (m_param->interRefine != 1)<br>
+ mvp = mode.amvpCand[list][ref][mode.<wbr>cu.m_mvpIdx[list][pu.<wbr>puAbsPartIdx]];<br>
+ else<br>
+ mvp = interDataCTU->mv[list][cuIdx + part];<br>
+ if (m_param->mvRefine || m_param->interRefine == 1)<br>
{<br>
MV outmv;<br>
- searchMV(mode, pu, list, ref, outmv);<br>
+ searchMV(mode, pu, list, ref, outmv, mvp, numMvc, mvc);<br>
mode.cu.setPUMv(list, outmv, pu.puAbsPartIdx, part);<br>
}<br>
- mode.cu.m_mvd[list][pu.<wbr>puAbsPartIdx] = mode.cu.m_mv[list][pu.<wbr>puAbsPartIdx] - mvp;<br>
+ mode.cu.m_mvd[list][pu.<wbr>puAbsPartIdx] = mode.cu.m_mv[list][pu.<wbr>puAbsPartIdx] - mode.amvpCand[list][ref][mode.<wbr>cu.m_mvpIdx[list][pu.<wbr>puAbsPartIdx]]/*mvp*/;<br>
}<br>
}<br>
else if(m_param->scaleFactor)<br>
diff -r 55eb39922995 -r a12d4abf4770 source/encoder/encoder.cpp<br>
--- a/source/encoder/encoder.cpp Wed Feb 28 11:09:18 2018 +0530<br>
+++ b/source/encoder/encoder.cpp Thu Jan 25 11:37:21 2018 +0530<br>
@@ -3096,9 +3096,8 @@<br>
if (m_param->analysisReuseLevel > 4)<br>
{<br>
CHECKED_MALLOC(interData-><wbr>partSize, uint8_t, analysis->numPartitions * analysis->numCUsInFrame);<br>
- CHECKED_MALLOC(interData-><wbr>mergeFlag, uint8_t, analysis->numPartitions * analysis->numCUsInFrame);<br>
+ CHECKED_MALLOC_ZERO(interData-<wbr>>mergeFlag, uint8_t, analysis->numPartitions * analysis->numCUsInFrame);<br>
}<br>
-<br>
if (m_param->analysisReuseLevel >= 7)<br>
{<br>
CHECKED_MALLOC(interData-><wbr>interDir, uint8_t, analysis->numPartitions * analysis->numCUsInFrame);<br>
diff -r 55eb39922995 -r a12d4abf4770 source/encoder/search.cpp<br>
--- a/source/encoder/search.cpp Wed Feb 28 11:09:18 2018 +0530<br>
+++ b/source/encoder/search.cpp Thu Jan 25 11:37:21 2018 +0530<br>
@@ -2107,18 +2107,24 @@<br>
bestME[list].mvCost = mvCost;<br>
}<br>
}<br>
-<br>
-void Search::searchMV(Mode& interMode, const PredictionUnit& pu, int list, int ref, MV& outmv)<br>
+void Search::searchMV(Mode& interMode, const PredictionUnit& pu, int list, int ref, MV& outmv, MV mvp, int numMvc, MV* mvc)<br>
{<br>
CUData& cu = interMode.cu;<br>
const Slice *slice = m_slice;<br>
- MV mv = cu.m_mv[list][pu.puAbsPartIdx]<wbr>;<br>
+ MV mv;<br>
+ if (m_param->interRefine == 1)<br>
+ mv = mvp;<br>
+ else<br>
+ mv = cu.m_mv[list][pu.puAbsPartIdx]<wbr>;<br>
cu.clipMv(mv);<br>
MV mvmin, mvmax;<br>
setSearchRange(cu, mv, m_param->searchRange, mvmin, mvmax);<br>
- m_me.refineMV(&slice->m_mref[<wbr>list][ref], mvmin, mvmax, mv, outmv);<br>
+ if (m_param->interRefine == 1)<br>
+ m_me.motionEstimate(&m_slice-><wbr>m_mref[list][ref], mvmin, mvmax, mv, numMvc, mvc, m_param->searchRange, outmv, m_param->maxSlices,<br>
+ m_param-><wbr>bSourceReferenceEstimation ? m_slice->m_refFrameList[list][<wbr>ref]->m_fencPic->getLumaAddr(<wbr>0) : 0);<br>
+ else<br>
+ m_me.refineMV(&slice->m_mref[<wbr>list][ref], mvmin, mvmax, mv, outmv);<br>
}<br>
-<br>
/* find the best inter prediction for each PU of specified mode */<br>
void Search::predInterSearch(Mode& interMode, const CUGeom& cuGeom, bool bChromaMC, uint32_t refMasks[2])<br>
{<br>
@@ -2138,20 +2144,29 @@<br>
int totalmebits = 0;<br>
MV mvzero(0, 0);<br>
Yuv& tmpPredYuv = m_rqt[cuGeom.depth].<wbr>tmpPredYuv;<br>
-<br>
MergeData merge;<br>
memset(&merge, 0, sizeof(merge));<br>
-<br>
+ bool useAsMVP = false;<br>
for (int puIdx = 0; puIdx < numPart; puIdx++)<br>
{<br>
MotionData* bestME = interMode.bestME[puIdx];<br>
PredictionUnit pu(cu, cuGeom, puIdx);<br>
-<br>
m_me.setSourcePU(*interMode.<wbr>fencYuv, pu.ctuAddr, pu.cuAbsPartIdx, pu.puAbsPartIdx, pu.width, pu.height, m_param->searchMethod, m_param->subpelRefine, bChromaMC);<br>
-<br>
+ useAsMVP = false;<br>
+ analysis_inter_data* interDataCTU = NULL;<br>
+ int cuIdx;<br>
+ cuIdx = (interMode.cu.m_cuAddr * m_param->num4x4Partitions) + cuGeom.absPartIdx;<br>
+ if (m_param->analysisReuseLevel == 10 && m_param->interRefine > 1)<br>
+ {<br>
+ interDataCTU = (analysis_inter_data*)m_frame-<wbr>>m_analysisData.interData;<br>
+ if ((cu.m_predMode[pu.<wbr>puAbsPartIdx] == interDataCTU->modes[cuIdx + pu.puAbsPartIdx])<br>
+ && (cu.m_partSize[pu.<wbr>puAbsPartIdx] == interDataCTU->partSize[cuIdx + pu.puAbsPartIdx])<br>
+ && !(interDataCTU->mergeFlag[<wbr>cuIdx + puIdx])<br>
+ && (cu.m_cuDepth[0] == interDataCTU->depth[cuIdx]))<br>
+ useAsMVP = true;<br>
+ }<br>
/* find best cost merge candidate. note: 2Nx2N merge and bidir are handled as separate modes */<br>
uint32_t mrgCost = numPart == 1 ? MAX_UINT : mergeEstimation(cu, cuGeom, pu, puIdx, merge);<br>
-<br>
bestME[0].cost = MAX_UINT;<br>
bestME[1].cost = MAX_UINT;<br>
<br>
@@ -2159,26 +2174,37 @@<br>
bool bDoUnidir = true;<br>
<br>
cu.getNeighbourMV(puIdx, pu.puAbsPartIdx, interMode.interNeighbours);<br>
-<br>
/* Uni-directional prediction */<br>
if ((m_param->analysisLoad && m_param->analysisReuseLevel > 1 && m_param->analysisReuseLevel != 10)<br>
- || (m_param-><wbr>analysisMultiPassRefine && m_param->rc.bStatRead) || (m_param->bMVType == AVC_INFO))<br>
+ || (m_param-><wbr>analysisMultiPassRefine && m_param->rc.bStatRead) || (m_param->bMVType == AVC_INFO) || (useAsMVP))<br>
{<br>
for (int list = 0; list < numPredDir; list++)<br>
{<br>
- int ref = bestME[list].ref;<br>
+<br>
+ int ref = -1;<br>
+ if (useAsMVP)<br>
+ ref = interDataCTU->refIdx[list][<wbr>cuIdx + puIdx];<br>
+<br>
+ else<br>
+ ref = bestME[list].ref;<br>
if (ref < 0)<br>
+ {<br>
continue;<br>
-<br>
+ }<br>
uint32_t bits = m_listSelBits[list] + MVP_IDX_BITS;<br>
bits += getTUBits(ref, numRefIdx[list]);<br>
<br>
int numMvc = cu.getPMV(interMode.<wbr>interNeighbours, list, ref, interMode.amvpCand[list][ref], mvc);<br>
-<br>
const MV* amvp = interMode.amvpCand[list][ref];<br>
int mvpIdx = selectMVP(cu, pu, amvp, list, ref);<br>
- MV mvmin, mvmax, outmv, mvp = amvp[mvpIdx];<br>
-<br>
+ MV mvmin, mvmax, outmv, mvp;<br>
+ if (useAsMVP)<br>
+ {<br>
+ mvp = interDataCTU->mv[list][cuIdx + puIdx];<br>
+ mvpIdx = interDataCTU->mvpIdx[list][<wbr>cuIdx + puIdx];<br>
+ }<br>
+ else<br>
+ mvp = amvp[mvpIdx];<br>
if (m_param->searchMethod == X265_SEA)<br>
{<br>
int puX = puIdx & 1;<br>
@@ -2198,9 +2224,8 @@<br>
bits += m_me.bitcost(outmv);<br>
uint32_t mvCost = m_me.mvcost(outmv);<br>
uint32_t cost = (satdCost - mvCost) + m_rdCost.getCost(bits);<br>
-<br>
/* Refine MVP selection, updates: mvpIdx, bits, cost */<br>
- if (!m_param-><wbr>analysisMultiPassRefine)<br>
+ if (!(m_param-><wbr>analysisMultiPassRefine || useAsMVP))<br>
mvp = checkBestMVP(amvp, outmv, mvpIdx, bits, cost);<br>
else<br>
{<br>
@@ -2225,6 +2250,7 @@<br>
bestME[list].cost = cost;<br>
bestME[list].bits = bits;<br>
bestME[list].mvCost = mvCost;<br>
+ bestME[list].ref = ref;<br>
}<br>
bDoUnidir = false;<br>
}<br>
diff -r 55eb39922995 -r a12d4abf4770 source/encoder/search.h<br>
--- a/source/encoder/search.h Wed Feb 28 11:09:18 2018 +0530<br>
+++ b/source/encoder/search.h Thu Jan 25 11:37:21 2018 +0530<br>
@@ -310,8 +310,7 @@<br>
<br>
// estimation inter prediction (non-skip)<br>
void predInterSearch(Mode& interMode, const CUGeom& cuGeom, bool bChromaMC, uint32_t masks[2]);<br>
-<br>
- void searchMV(Mode& interMode, const PredictionUnit& pu, int list, int ref, MV& outmv);<br>
+ void searchMV(Mode& interMode, const PredictionUnit& pu, int list, int ref, MV& outmv, MV mvp, int numMvc, MV* mvc);<br>
// encode residual and compute rd-cost for inter mode<br>
void encodeResAndCalcRdInterCU(<wbr>Mode& interMode, const CUGeom& cuGeom);<br>
void encodeResAndCalcRdSkipCU(Mode& interMode);<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"><br></div><div class="gmail_extra">Pushed.</div></div>