<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Sep 30, 2013 at 2:05 AM, <span dir="ltr"><<a href="mailto:deepthidevaki@multicorewareinc.com" target="_blank">deepthidevaki@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 Deepthi Devaki <<a href="mailto:deepthidevaki@multicorewareinc.com">deepthidevaki@multicorewareinc.com</a>><br>
# Date 1380523193 -19800<br>
# Node ID bb238e8b36007aad896884009c720d26df8775c5<br>
# Parent 55edc34e253c14d3eccb83a7d1db43774349ff9a<br>
Bidir ME: new logic adapted from x264<br>
<br>
L0 and L1 MVs from unidir ME used for bidir MV. bidir cost is calculated from the average of references. Performance/PSNR with new bidir with commandline<br>
x265.exe FourPeople_1280x720_60.y4m -f 100 --b-adapt 0 -b 3 --ref 1 --hash 1 -o four.hevc -r recon.yuv<br>
New: (2.24 fps), 515.16 kb/s, Global PSNR: 39.704<br>
Orig: (2.05 fps), 519.47 kb/s, Global PSNR: 39.711<br>
<br>
diff -r 55edc34e253c -r bb238e8b3600 source/Lib/TLibEncoder/TEncSearch.cpp<br>
--- a/source/Lib/TLibEncoder/TEncSearch.cpp Sat Sep 28 22:54:44 2013 -0500<br>
+++ b/source/Lib/TLibEncoder/TEncSearch.cpp Mon Sep 30 12:09:53 2013 +0530<br>
@@ -2289,7 +2289,7 @@<br>
* \param bUseRes<br>
* \returns void<br>
*/<br>
-void TEncSearch::predInterSearch(TComDataCU* cu, TComYuv* fencYuv, TComYuv* predYuv, bool bUseMRG)<br>
+void TEncSearch::predInterSearch(TComDataCU* cu, TComYuv* /*fencYuv*/, TComYuv* predYuv, bool bUseMRG)<br>
{<br>
m_predYuv[0].clear();<br>
m_predYuv[1].clear();<br>
@@ -2317,7 +2317,6 @@<br>
<br>
UInt partAddr;<br>
int roiWidth, roiHeight;<br>
- int refStart, refEnd;<br>
<br>
PartSize partSize = cu->getPartitionSize(0);<br>
int bestBiPRefIdxL1 = 0;<br>
@@ -2483,8 +2482,6 @@<br>
// Bi-directional prediction<br>
if ((cu->getSlice()->isInterB()) && (cu->isBipredRestriction(partIdx) == false))<br>
{<br>
- UInt motBits[2];<br>
-<br>
mvBidir[0] = mv[0];<br>
mvBidir[1] = mv[1];<br>
refIdxBidir[0] = refIdx[0];<br>
@@ -2492,112 +2489,17 @@<br>
<br>
::memcpy(mvPredBi, mvPred, sizeof(mvPred));<br>
::memcpy(mvpIdxBi, mvpIdx, sizeof(mvpIdx));<br>
-<br>
- if (cu->getSlice()->getMvdL1ZeroFlag())<br>
- {<br>
- xCopyAMVPInfo(&amvpInfo[1][bestBiPRefIdxL1], cu->getCUMvField(REF_PIC_LIST_1)->getAMVPInfo());<br>
- cu->setMVPIdxSubParts(bestBiPMvpL1, REF_PIC_LIST_1, partAddr, partIdx, cu->getDepth(partAddr));<br>
- mvpIdxBi[1][bestBiPRefIdxL1] = bestBiPMvpL1;<br>
- mvPredBi[1][bestBiPRefIdxL1] = cu->getCUMvField(REF_PIC_LIST_1)->getAMVPInfo()->m_mvCand[bestBiPMvpL1];<br>
-<br>
- mvBidir[1] = mvPredBi[1][bestBiPRefIdxL1];<br>
- refIdxBidir[1] = bestBiPRefIdxL1;<br>
- cu->getCUMvField(REF_PIC_LIST_1)->setAllMv(mvBidir[1], partSize, partAddr, 0, partIdx);<br>
- cu->getCUMvField(REF_PIC_LIST_1)->setAllRefIdx(refIdxBidir[1], partSize, partAddr, 0, partIdx);<br>
- motionCompensation(cu, &m_predYuv[1], REF_PIC_LIST_1, partIdx);<br>
-<br>
- motBits[0] = bits[0] - mbBits[0];<br>
- motBits[1] = mbBits[1];<br>
-<br>
- if (cu->getSlice()->getNumRefIdx(REF_PIC_LIST_1) > 1)<br>
- {<br>
- motBits[1] += bestBiPRefIdxL1 + 1;<br>
- if (bestBiPRefIdxL1 == cu->getSlice()->getNumRefIdx(REF_PIC_LIST_1) - 1) motBits[1]--;<br>
- }<br>
-<br>
- motBits[1] += m_mvpIdxCost[mvpIdxBi[1][bestBiPRefIdxL1]][AMVP_MAX_NUM_CANDS];<br>
-<br>
- bits[2] = mbBits[2] + motBits[0] + motBits[1];<br>
-<br>
- mvTemp[1][bestBiPRefIdxL1] = mvBidir[1];<br>
- }<br>
- else<br>
- {<br>
- motBits[0] = bits[0] - mbBits[0];<br>
- motBits[1] = bits[1] - mbBits[1];<br>
- bits[2] = mbBits[2] + motBits[0] + motBits[1];<br>
- }<br>
-<br>
- int refList = 0;<br>
- if (listCost[0] <= listCost[1])<br>
- {<br>
- refList = 1;<br>
- }<br>
- else<br>
- {<br>
- refList = 0;<br>
- }<br>
- if (!cu->getSlice()->getMvdL1ZeroFlag())<br>
- {<br>
- cu->getCUMvField(RefPicList(1 - refList))->setAllMv(mv[1 - refList], partSize, partAddr, 0, partIdx);<br>
- cu->getCUMvField(RefPicList(1 - refList))->setAllRefIdx(refIdx[1 - refList], partSize, partAddr, 0, partIdx);<br>
- motionCompensation(cu, &m_predYuv[1 - refList], RefPicList(1 - refList), partIdx);<br>
- }<br>
- RefPicList picList = (refList ? REF_PIC_LIST_1 : REF_PIC_LIST_0);<br>
-<br>
- if (cu->getSlice()->getMvdL1ZeroFlag())<br>
- {<br>
- refList = 0;<br>
- picList = REF_PIC_LIST_0;<br>
- }<br>
-<br>
- bool bChanged = false;<br>
-<br>
- refStart = 0;<br>
- refEnd = cu->getSlice()->getNumRefIdx(picList) - 1;<br>
-<br>
- for (int refIdxTmp = refStart; refIdxTmp <= refEnd; refIdxTmp++)<br>
- {<br>
- bitsTemp = mbBits[2] + motBits[1 - refList];<br>
- if (cu->getSlice()->getNumRefIdx(picList) > 1)<br>
- {<br>
- bitsTemp += refIdxTmp + 1;<br>
- if (refIdxTmp == cu->getSlice()->getNumRefIdx(picList) - 1) bitsTemp--;<br>
- }<br>
- bitsTemp += m_mvpIdxCost[mvpIdxBi[refList][refIdxTmp]][AMVP_MAX_NUM_CANDS];<br>
- // call bidir ME<br>
- xMotionEstimation(cu, fencYuv, partIdx, picList, &mvPredBi[refList][refIdxTmp], refIdxTmp, mvTemp[refList][refIdxTmp],<br>
- bitsTemp, costTemp);<br>
- xCopyAMVPInfo(&amvpInfo[refList][refIdxTmp], cu->getCUMvField(picList)->getAMVPInfo());<br>
- xCheckBestMVP(cu, picList, mvTemp[refList][refIdxTmp], mvPredBi[refList][refIdxTmp], mvpIdxBi[refList][refIdxTmp],<br>
- bitsTemp, costTemp);<br>
-<br>
- if (costTemp < costbi)<br>
- {<br>
- bChanged = true;<br>
-<br>
- mvBidir[refList] = mvTemp[refList][refIdxTmp];<br>
- refIdxBidir[refList] = refIdxTmp;<br>
-<br>
- costbi = costTemp;<br>
- motBits[refList] = bitsTemp - mbBits[2] - motBits[1 - refList];<br>
- bits[2] = bitsTemp;<br>
- }<br>
- } // for loop-refIdxTmp<br>
-<br>
- if (!bChanged)<br>
- {<br>
- if (costbi <= listCost[0] && costbi <= listCost[1])<br>
- {<br>
- xCopyAMVPInfo(&amvpInfo[0][refIdxBidir[0]], cu->getCUMvField(REF_PIC_LIST_0)->getAMVPInfo());<br>
- xCheckBestMVP(cu, REF_PIC_LIST_0, mvBidir[0], mvPredBi[0][refIdxBidir[0]], mvpIdxBi[0][refIdxBidir[0]], bits[2], costbi);<br>
- if (!cu->getSlice()->getMvdL1ZeroFlag())<br>
- {<br>
- xCopyAMVPInfo(&amvpInfo[1][refIdxBidir[1]], cu->getCUMvField(REF_PIC_LIST_1)->getAMVPInfo());<br>
- xCheckBestMVP(cu, REF_PIC_LIST_1, mvBidir[1], mvPredBi[1][refIdxBidir[1]], mvpIdxBi[1][refIdxBidir[1]], bits[2], costbi);<br>
- }<br>
- }<br>
- }<br>
+<br>
+ pixel *ref0,*ref1;<br>
+ ref0 = cu->getSlice()->m_mref[REF_PIC_LIST_0][refIdx[0]]->fpelPlane + (pu - fenc->getLumaAddr()) + (mv[0].x >> 2) + (mv[0].y >> 2) * fenc->getStride();<br>
+ ref1 = cu->getSlice()->m_mref[REF_PIC_LIST_1][refIdx[1]]->fpelPlane + (pu - fenc->getLumaAddr()) + (mv[1].x >> 2) + (mv[1].y >> 2) * fenc->getStride();<br>
+<br>
+ pixel avg[MAX_CU_SIZE * MAX_CU_SIZE];<br>
+<br>
+ int partEnum = PartitionFromSizes(roiWidth, roiHeight);<br>
+ primitives.pixelavg_pp[partEnum](avg, roiWidth, ref0, ref1, fenc->getStride(), fenc->getStride());<br>
+ int satdCost = primitives.satd[partEnum](pu, fenc->getStride(), avg, roiWidth);<br>
+ costbi = satdCost + m_rdCost->getCost(bits[0]) + m_rdCost->getCost(bits[1]);<br>
} // if (B_SLICE)<br>
} //end if bTestNormalMC<br>
<br>
diff -r 55edc34e253c -r bb238e8b3600 source/common/pixel.cpp<br>
--- a/source/common/pixel.cpp Sat Sep 28 22:54:44 2013 -0500<br>
+++ b/source/common/pixel.cpp Mon Sep 30 12:09:53 2013 +0530<br>
@@ -578,6 +578,21 @@<br>
}<br>
}<br>
<br>
+template<int lx, int ly><br>
+void pixelavg_pp(pixel* dst, intptr_t dstride, pixel* src0, pixel* src1, intptr_t sstride0, intptr_t sstride1)<br>
+{<br>
+ for( int y = 0; y < ly; y++ )<br></blockquote><div><br></div><div>white-space</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+ {<br>
+ for( int x = 0; x < lx; x++ )<br>
+ {<br>
+ dst[x] = ( src0[x] + src1[x] + 1 ) >> 1;<br>
+ }<br>
+ src0 += sstride0;<br>
+ src1 += sstride1;<br>
+ dst += dstride;<br>
+ }<br>
+}<br></blockquote><div><br></div><div>lowres QPEL should be modified to use this (once we have an ASM/SIMD version)</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+<br>
void scale1D_128to64(pixel *dst, pixel *src, intptr_t /*stride*/)<br>
{<br>
int x;<br>
@@ -647,6 +662,7 @@<br>
SET_FUNC_PRIMITIVE_TABLE_C2(sad)<br>
SET_FUNC_PRIMITIVE_TABLE_C2(sad_x3)<br>
SET_FUNC_PRIMITIVE_TABLE_C2(sad_x4)<br>
+ SET_FUNC_PRIMITIVE_TABLE_C2(pixelavg_pp)<br>
<br>
// satd<br>
p.satd[PARTITION_4x4] = satd_4x4;<br>
diff -r 55edc34e253c -r bb238e8b3600 source/common/primitives.h<br>
--- a/source/common/primitives.h Sat Sep 28 22:54:44 2013 -0500<br>
+++ b/source/common/primitives.h Mon Sep 30 12:09:53 2013 +0530<br>
@@ -196,6 +196,7 @@<br>
typedef void (*pixelsub_sp_t)(int bx, int by, short *dst, intptr_t dstride, pixel *src0, pixel *src1, intptr_t sstride0, intptr_t sstride1);<br>
typedef void (*pixeladd_ss_t)(int bx, int by, short *dst, intptr_t dstride, short *src0, short *src1, intptr_t sstride0, intptr_t sstride1);<br>
typedef void (*pixeladd_pp_t)(int bx, int by, pixel *dst, intptr_t dstride, pixel *src0, pixel *src1, intptr_t sstride0, intptr_t sstride1);<br>
+typedef void (*pixelavg_pp_t)(pixel *dst, intptr_t dstride, pixel *src0, pixel *src1, intptr_t sstride0, intptr_t sstride1);<br>
typedef void (*blockfil_s_t)(short *dst, intptr_t dstride, short val);<br>
<br>
typedef void (*intra_dc_t)(pixel* above, pixel* left, pixel* dst, intptr_t dstStride, int width, int bFilter);<br>
@@ -290,6 +291,7 @@<br>
pixelsub_sp_t pixelsub_sp;<br>
pixeladd_ss_t pixeladd_ss;<br>
pixeladd_pp_t pixeladd_pp;<br>
+ pixelavg_pp_t pixelavg_pp[NUM_PARTITIONS];<br>
<br>
filterVwghtd_t filterVwghtd;<br>
filterHwghtd_t filterHwghtd;<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><br clear="all"><div><br></div>-- <br>Steve Borho
</div></div>