<div dir="ltr">Ran the smoke test on this, the results were mixed - on some commandlines, the encode efficiency benefits were really good though. <br><br><div><div><div><div class="gmail_extra"><div class="gmail_quote">On Thu, May 14, 2015 at 10:53 AM, <span dir="ltr"><<a href="mailto:gopu@multicorewareinc.com" target="_blank">gopu@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 Gopu Govindaswamy <<a href="mailto:gopu@multicorewareinc.com">gopu@multicorewareinc.com</a>><br>
# Date 1431581025 -19800<br>
# Thu May 14 10:53:45 2015 +0530<br>
# Node ID def132fbcf33352b18a31015dfefff79e95d21d7<br>
# Parent 479087422e29a672d6e9bc8d0cd2a65649d71fe2<br>
search: add lowres MV into search mv candidate list for search ME(CHANGESOUTPUT)<br>
<br>
Add one more mv (lowres MV) into MV candidates list and this extra candidates<br>
applicable only for depth 2, the lowres MV's are calculated 16x16 blocks<br>
<br>
diff -r 479087422e29 -r def132fbcf33 source/encoder/search.cpp<br>
--- a/source/encoder/search.cpp Wed May 13 16:52:59 2015 -0700<br>
+++ b/source/encoder/search.cpp Thu May 14 10:53:45 2015 +0530<br>
@@ -1930,9 +1930,9 @@<br>
do<br>
{<br>
if (meId < m_slice->m_numRefIdx[0])<br>
- slave.singleMotionEstimation(*this, pme.mode, pme.pu, pme.puIdx, 0, meId);<br>
+ slave.singleMotionEstimation(*this, pme.mode, pme.cuGeom, pme.pu, pme.puIdx, 0, meId);<br>
else<br>
- slave.singleMotionEstimation(*this, pme.mode, pme.pu, pme.puIdx, 1, meId - m_slice->m_numRefIdx[0]);<br>
+ slave.singleMotionEstimation(*this, pme.mode, pme.cuGeom, pme.pu, pme.puIdx, 1, meId - m_slice->m_numRefIdx[0]);<br>
<br>
meId = -1;<br>
pme.m_lock.acquire();<br>
@@ -1943,20 +1943,25 @@<br>
while (meId >= 0);<br>
}<br>
<br>
-void Search::singleMotionEstimation(Search& master, Mode& interMode, const PredictionUnit& pu, int part, int list, int ref)<br>
+void Search::singleMotionEstimation(Search& master, Mode& interMode, const CUGeom& cuGeom, const PredictionUnit& pu, int part, int list, int ref)<br>
{<br>
uint32_t bits = master.m_listSelBits[list] + MVP_IDX_BITS;<br>
bits += getTUBits(ref, m_slice->m_numRefIdx[list]);<br>
<br>
MotionData* bestME = interMode.bestME[part];<br>
<br>
- MV mvc[(MD_ABOVE_LEFT + 1) * 2 + 1];<br>
+ // 12 mv candidates including lowresMV<br>
+ MV mvc[(MD_ABOVE_LEFT + 1) * 2 + 2];<br>
int numMvc = interMode.cu.getPMV(interMode.interNeighbours, list, ref, interMode.amvpCand[list][ref], mvc);<br>
<br>
const MV* amvp = interMode.amvpCand[list][ref];<br>
int mvpIdx = selectMVP(interMode.cu, pu, amvp, list, ref);<br>
MV mvmin, mvmax, outmv, mvp = amvp[mvpIdx];<br>
<br>
+ MV lmv = getLowresMV(interMode.cu, cuGeom, list, ref);<br>
+ if (lmv.notZero())<br>
+ mvc[numMvc++] = lmv;<br>
+<br>
setSearchRange(interMode.cu, mvp, m_param->searchRange, mvmin, mvmax);<br>
<br>
int satdCost = m_me.motionEstimate(&m_slice->m_mref[list][ref], mvmin, mvmax, mvp, numMvc, mvc, m_param->searchRange, outmv);<br>
@@ -1990,7 +1995,8 @@<br>
CUData& cu = interMode.cu;<br>
Yuv* predYuv = &interMode.predYuv;<br>
<br>
- MV mvc[(MD_ABOVE_LEFT + 1) * 2 + 1];<br>
+ // 12 mv candidates including lowresMV<br>
+ MV mvc[(MD_ABOVE_LEFT + 1) * 2 + 2];<br>
<br>
const Slice *slice = m_slice;<br>
int numPart = cu.getNumPartInter();<br>
@@ -2039,6 +2045,10 @@<br>
int mvpIdx = selectMVP(cu, pu, amvp, list, ref);<br>
MV mvmin, mvmax, outmv, mvp = amvp[mvpIdx];<br>
<br>
+ MV lmv = getLowresMV(cu, cuGeom, list, ref);<br>
+ if (lmv.notZero())<br>
+ mvc[numMvc++] = lmv;<br>
+<br>
setSearchRange(cu, mvp, m_param->searchRange, mvmin, mvmax);<br>
int satdCost = m_me.motionEstimate(&slice->m_mref[list][ref], mvmin, mvmax, mvp, numMvc, mvc, m_param->searchRange, outmv);<br>
<br>
@@ -2070,7 +2080,7 @@<br>
{<br>
processPME(pme, *this);<br>
<br>
- singleMotionEstimation(*this, interMode, pu, puIdx, 0, 0); /* L0-0 */<br>
+ singleMotionEstimation(*this, interMode, cuGeom, pu, puIdx, 0, 0); /* L0-0 */<br>
<br>
bDoUnidir = false;<br>
<br>
@@ -2096,6 +2106,10 @@<br>
int mvpIdx = selectMVP(cu, pu, amvp, list, ref);<br>
MV mvmin, mvmax, outmv, mvp = amvp[mvpIdx];<br>
<br>
+ MV lmv = getLowresMV(cu, cuGeom, list, ref);<br>
+ if (lmv.notZero())<br>
+ mvc[numMvc++] = lmv;<br>
+<br>
setSearchRange(cu, mvp, m_param->searchRange, mvmin, mvmax);<br>
int satdCost = m_me.motionEstimate(&slice->m_mref[list][ref], mvmin, mvmax, mvp, numMvc, mvc, m_param->searchRange, outmv);<br>
<br>
@@ -3444,3 +3458,31 @@<br>
cu.setQPSubParts(cu.getRefQP(0), 0, cuGeom.depth);<br>
}<br>
}<br>
+<br>
+MV Search::getLowresMV(const CUData& cu, const CUGeom& cuGeom, int list, int ref)<br>
+{<br>
+ MV lmv = 0;<br>
+ if (g_maxCUSize >> cuGeom.depth == 16)<br>
+ {<br>
+ int curPoc = m_slice->m_poc;<br>
+ int refPoc = m_slice->m_refPicList[list][ref]->m_poc;<br>
+ int diffPoc = abs(curPoc - refPoc);<br>
+<br>
+ if (diffPoc <= m_param->bframes + 1)<br>
+ {<br>
+ MV *mv = m_frame->m_lowres.lowresMvs[list][diffPoc - 1];<br>
+ uint32_t block_x = cu.m_cuPelX + g_zscanToPelX[cuGeom.absPartIdx];<br>
+ uint32_t block_y = cu.m_cuPelY + g_zscanToPelY[cuGeom.absPartIdx];<br>
+<br>
+ /* number of blocks per row in lowres*/<br>
+ uint32_t stride = ((m_param->sourceWidth / 2) + X265_LOWRES_CU_SIZE - 1) >> X265_LOWRES_CU_BITS;<br>
+<br>
+ uint32_t idx = ((block_y / 16) * stride) + (block_x / 16);<br>
+ /* check whether this motion search was performed by lookahead */<br>
+ if (mv[0].x != 0x7FFF)<br>
+ lmv = mv[idx];<br></blockquote><div><br></div><div>The only change I made was to move this check up. <br><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+ }<br>
+ }<br>
+<br>
+ return lmv;<br>
+}<br>
diff -r 479087422e29 -r def132fbcf33 source/encoder/search.h<br>
--- a/source/encoder/search.h Wed May 13 16:52:59 2015 -0700<br>
+++ b/source/encoder/search.h Thu May 14 10:53:45 2015 +0530<br>
@@ -319,6 +319,8 @@<br>
void checkDQP(Mode& mode, const CUGeom& cuGeom);<br>
void checkDQPForSplitPred(Mode& mode, const CUGeom& cuGeom);<br>
<br>
+ MV getLowresMV(const CUData& cu, const CUGeom& cuGeom, int list, int ref);<br>
+<br>
class PME : public BondedTaskGroup<br>
{<br>
public:<br>
@@ -339,7 +341,7 @@<br>
};<br>
<br>
void processPME(PME& pme, Search& slave);<br>
- void singleMotionEstimation(Search& master, Mode& interMode, const PredictionUnit& pu, int part, int list, int ref);<br>
+ void singleMotionEstimation(Search& master, Mode& interMode, const CUGeom& cuGeom, const PredictionUnit& pu, int part, int list, int ref);<br>
<br>
protected:<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" target="_blank">https://mailman.videolan.org/listinfo/x265-devel</a><br>
</blockquote></div><br></div></div></div></div></div>