<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Sat, Feb 8, 2014 at 7:59 AM, Satoshi Nakagawa <span dir="ltr"><<a href="mailto:nakagawa424@oki.com" target="_blank">nakagawa424@oki.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">further cleanup for getInterMergeCandidates()<br>
<br>
# HG changeset patch<br>
# User Satoshi Nakagawa <<a href="mailto:nakagawa424@oki.com">nakagawa424@oki.com</a>><br>
# Date 1391867438 -32400<br>
# Sat Feb 08 22:50:38 2014 +0900<br>
# Branch mrg<br>
# Node ID e74cb7ea8645e073c3102b70f023073e80bbb524<br>
# Parent fa9f7b56d4d870f5ebef47bb1007995c2d71ce1a<br>
improve getInterMergeCandidates()<br></blockquote><div><br></div><div>queued, along with the previous patch, thanks.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
diff -r fa9f7b56d4d8 -r e74cb7ea8645 source/Lib/TLibCommon/TComDataCU.cpp<br>
--- a/source/Lib/TLibCommon/TComDataCU.cpp Fri Feb 07 21:37:17 2014 +0530<br>
+++ b/source/Lib/TLibCommon/TComDataCU.cpp Sat Feb 08 22:50:38 2014 +0900<br>
@@ -1914,19 +1914,19 @@<br>
* \param numValidMergeCand<br>
*/<br>
void TComDataCU::getInterMergeCandidates(uint32_t absPartIdx, uint32_t puIdx, TComMvField* mvFieldNeighbours, UChar* interDirNeighbours,<br>
- int& numValidMergeCand, int mrgCandIdx)<br>
+ int& numValidMergeCand)<br>
{<br>
uint32_t absPartAddr = m_absIdxInLCU + absPartIdx;<br>
- bool abCandIsInter[MRG_MAX_NUM_CANDS];<br>
-<br>
- for (uint32_t i = 0; i < getSlice()->getMaxNumMergeCand(); ++i)<br>
+ const uint32_t maxNumMergeCand = getSlice()->getMaxNumMergeCand();<br>
+ const bool isInterB = getSlice()->isInterB();<br>
+<br>
+ for (uint32_t i = 0; i < maxNumMergeCand; ++i)<br>
{<br>
- abCandIsInter[i] = false;<br>
mvFieldNeighbours[(i << 1)].refIdx = NOT_VALID;<br>
mvFieldNeighbours[(i << 1) + 1].refIdx = NOT_VALID;<br>
}<br>
<br>
- numValidMergeCand = getSlice()->getMaxNumMergeCand();<br>
+ numValidMergeCand = maxNumMergeCand;<br>
// compute the location of the current PU<br>
int xP, yP, nPSW, nPSH;<br>
this->getPartPosition(puIdx, xP, yP, nPSW, nPSH);<br>
@@ -1935,7 +1935,6 @@<br>
<br>
uint32_t partIdxLT, partIdxRT, partIdxLB;<br>
PartSize curPS = getPartitionSize(absPartIdx);<br>
- deriveLeftRightTopIdxGeneral(absPartIdx, puIdx, partIdxLT, partIdxRT);<br>
deriveLeftBottomIdxGeneral(absPartIdx, puIdx, partIdxLB);<br>
<br>
//left<br>
@@ -1948,27 +1947,24 @@<br>
!cuLeft->isIntra(leftPartIdx);<br>
if (isAvailableA1)<br>
{<br>
- abCandIsInter[count] = true;<br>
// get Inter Dir<br>
interDirNeighbours[count] = cuLeft->getInterDir(leftPartIdx);<br>
// get Mv from Left<br>
cuLeft->getMvField(cuLeft, leftPartIdx, REF_PIC_LIST_0, mvFieldNeighbours[count << 1]);<br>
- if (getSlice()->isInterB())<br>
+ if (isInterB)<br>
{<br>
cuLeft->getMvField(cuLeft, leftPartIdx, REF_PIC_LIST_1, mvFieldNeighbours[(count << 1) + 1]);<br>
}<br>
- if (mrgCandIdx == count)<br>
+ count++;<br>
+ // early termination<br>
+ if (count == maxNumMergeCand)<br>
{<br>
return;<br>
}<br>
- count++;<br>
}<br>
<br>
- // early termination<br>
- if (count == getSlice()->getMaxNumMergeCand())<br>
- {<br>
- return;<br>
- }<br>
+ deriveLeftRightTopIdxGeneral(absPartIdx, puIdx, partIdxLT, partIdxRT);<br>
+<br>
// above<br>
uint32_t abovePartIdx = 0;<br>
TComDataCU* cuAbove = 0;<br>
@@ -1979,25 +1975,20 @@<br>
!cuAbove->isIntra(abovePartIdx);<br>
if (isAvailableB1 && (!isAvailableA1 || !cuLeft->hasEqualMotion(leftPartIdx, cuAbove, abovePartIdx)))<br>
{<br>
- abCandIsInter[count] = true;<br>
// get Inter Dir<br>
interDirNeighbours[count] = cuAbove->getInterDir(abovePartIdx);<br>
// get Mv from Left<br>
cuAbove->getMvField(cuAbove, abovePartIdx, REF_PIC_LIST_0, mvFieldNeighbours[count << 1]);<br>
- if (getSlice()->isInterB())<br>
+ if (isInterB)<br>
{<br>
cuAbove->getMvField(cuAbove, abovePartIdx, REF_PIC_LIST_1, mvFieldNeighbours[(count << 1) + 1]);<br>
}<br>
- if (mrgCandIdx == count)<br>
+ count++;<br>
+ // early termination<br>
+ if (count == maxNumMergeCand)<br>
{<br>
return;<br>
}<br>
- count++;<br>
- }<br>
- // early termination<br>
- if (count == getSlice()->getMaxNumMergeCand())<br>
- {<br>
- return;<br>
}<br>
<br>
// above right<br>
@@ -2009,25 +2000,20 @@<br>
!cuAboveRight->isIntra(aboveRightPartIdx);<br>
if (isAvailableB0 && (!isAvailableB1 || !cuAbove->hasEqualMotion(abovePartIdx, cuAboveRight, aboveRightPartIdx)))<br>
{<br>
- abCandIsInter[count] = true;<br>
// get Inter Dir<br>
interDirNeighbours[count] = cuAboveRight->getInterDir(aboveRightPartIdx);<br>
// get Mv from Left<br>
cuAboveRight->getMvField(cuAboveRight, aboveRightPartIdx, REF_PIC_LIST_0, mvFieldNeighbours[count << 1]);<br>
- if (getSlice()->isInterB())<br>
+ if (isInterB)<br>
{<br>
cuAboveRight->getMvField(cuAboveRight, aboveRightPartIdx, REF_PIC_LIST_1, mvFieldNeighbours[(count << 1) + 1]);<br>
}<br>
- if (mrgCandIdx == count)<br>
+ count++;<br>
+ // early termination<br>
+ if (count == maxNumMergeCand)<br>
{<br>
return;<br>
}<br>
- count++;<br>
- }<br>
- // early termination<br>
- if (count == getSlice()->getMaxNumMergeCand())<br>
- {<br>
- return;<br>
}<br>
<br>
//left bottom<br>
@@ -2039,26 +2025,22 @@<br>
!cuLeftBottom->isIntra(leftBottomPartIdx);<br>
if (isAvailableA0 && (!isAvailableA1 || !cuLeft->hasEqualMotion(leftPartIdx, cuLeftBottom, leftBottomPartIdx)))<br>
{<br>
- abCandIsInter[count] = true;<br>
// get Inter Dir<br>
interDirNeighbours[count] = cuLeftBottom->getInterDir(leftBottomPartIdx);<br>
// get Mv from Left<br>
cuLeftBottom->getMvField(cuLeftBottom, leftBottomPartIdx, REF_PIC_LIST_0, mvFieldNeighbours[count << 1]);<br>
- if (getSlice()->isInterB())<br>
+ if (isInterB)<br>
{<br>
cuLeftBottom->getMvField(cuLeftBottom, leftBottomPartIdx, REF_PIC_LIST_1, mvFieldNeighbours[(count << 1) + 1]);<br>
}<br>
- if (mrgCandIdx == count)<br>
+ count++;<br>
+ // early termination<br>
+ if (count == maxNumMergeCand)<br>
{<br>
return;<br>
}<br>
- count++;<br>
}<br>
- // early termination<br>
- if (count == getSlice()->getMaxNumMergeCand())<br>
- {<br>
- return;<br>
- }<br>
+<br>
// above left<br>
if (count < 4)<br>
{<br>
@@ -2071,32 +2053,26 @@<br>
if (isAvailableB2 && (!isAvailableA1 || !cuLeft->hasEqualMotion(leftPartIdx, cuAboveLeft, aboveLeftPartIdx))<br>
&& (!isAvailableB1 || !cuAbove->hasEqualMotion(abovePartIdx, cuAboveLeft, aboveLeftPartIdx)))<br>
{<br>
- abCandIsInter[count] = true;<br>
// get Inter Dir<br>
interDirNeighbours[count] = cuAboveLeft->getInterDir(aboveLeftPartIdx);<br>
// get Mv from Left<br>
cuAboveLeft->getMvField(cuAboveLeft, aboveLeftPartIdx, REF_PIC_LIST_0, mvFieldNeighbours[count << 1]);<br>
- if (getSlice()->isInterB())<br>
+ if (isInterB)<br>
{<br>
cuAboveLeft->getMvField(cuAboveLeft, aboveLeftPartIdx, REF_PIC_LIST_1, mvFieldNeighbours[(count << 1) + 1]);<br>
}<br>
- if (mrgCandIdx == count)<br>
+ count++;<br>
+ // early termination<br>
+ if (count == maxNumMergeCand)<br>
{<br>
return;<br>
}<br>
- count++;<br>
}<br>
}<br>
- // early termination<br>
- if (count == getSlice()->getMaxNumMergeCand())<br>
- {<br>
- return;<br>
- }<br>
if (getSlice()->getEnableTMVPFlag())<br>
{<br>
//>> MTK colocated-RightBottom<br>
uint32_t partIdxRB;<br>
- int lcuIdx;<br>
<br>
deriveRightBottomIdx(puIdx, partIdxRB);<br>
<br>
@@ -2105,14 +2081,13 @@<br>
<br>
MV colmv;<br>
int refIdx;<br>
+ int lcuIdx = -1;<br>
<br>
if ((m_pic->getCU(m_cuAddr)->getCUPelX() + g_rasterToPelX[uiAbsPartIdxTmp] + m_pic->getMinCUWidth()) >= m_slice->getSPS()->getPicWidthInLumaSamples()) // image boundary check<br>
{<br>
- lcuIdx = -1;<br>
}<br>
else if ((m_pic->getCU(m_cuAddr)->getCUPelY() + g_rasterToPelY[uiAbsPartIdxTmp] + m_pic->getMinCUHeight()) >= m_slice->getSPS()->getPicHeightInLumaSamples())<br>
{<br>
- lcuIdx = -1;<br>
}<br>
else<br>
{<br>
@@ -2125,7 +2100,6 @@<br>
else if (uiAbsPartIdxTmp % numPartInCUWidth < numPartInCUWidth - 1) // is not at the last column of LCU But is last row of LCU<br>
{<br>
absPartAddr = g_rasterToZscan[(uiAbsPartIdxTmp + numPartInCUWidth + 1) % m_pic->getNumPartInCU()];<br>
- lcuIdx = -1;<br>
}<br>
else if (uiAbsPartIdxTmp / numPartInCUWidth < m_pic->getNumPartInHeight() - 1) // is not at the last row of LCU But is last column of LCU<br>
{<br>
@@ -2135,7 +2109,6 @@<br>
else //is the right bottom corner of LCU<br>
{<br>
absPartAddr = 0;<br>
- lcuIdx = -1;<br>
}<br>
}<br>
<br>
@@ -2157,7 +2130,7 @@<br>
mvFieldNeighbours[2 * arrayAddr].setMvField(colmv, refIdx);<br>
}<br>
<br>
- if (getSlice()->isInterB())<br>
+ if (isInterB)<br>
{<br>
bExistMV = lcuIdx >= 0 && xGetColMVP(REF_PIC_LIST_1, lcuIdx, absPartAddr, colmv, refIdx);<br>
if (bExistMV == false)<br>
@@ -2174,70 +2147,63 @@<br>
if (dir != 0)<br>
{<br>
interDirNeighbours[arrayAddr] = dir;<br>
- abCandIsInter[arrayAddr] = true;<br>
-<br>
- if (mrgCandIdx == count)<br>
+<br>
+ count++;<br>
+ // early termination<br>
+ if (count == maxNumMergeCand)<br>
{<br>
return;<br>
}<br>
- count++;<br>
}<br>
}<br>
- // early termination<br>
- if (count == getSlice()->getMaxNumMergeCand())<br>
+<br>
+ uint32_t arrayAddr = count;<br>
+<br>
+ if (isInterB)<br>
{<br>
- return;<br>
- }<br>
- uint32_t arrayAddr = count;<br>
- uint32_t cutoff = arrayAddr;<br>
-<br>
- if (getSlice()->isInterB())<br>
- {<br>
- // TODO: TComRom??<br>
- uint32_t priorityList0[12] = { 0, 1, 0, 2, 1, 2, 0, 3, 1, 3, 2, 3 };<br>
- uint32_t priorityList1[12] = { 1, 0, 2, 0, 2, 1, 3, 0, 3, 1, 3, 2 };<br>
-<br>
- for (int idx = 0; idx < cutoff * (cutoff - 1) && arrayAddr != getSlice()->getMaxNumMergeCand(); idx++)<br>
+ const int cutoff = count * (count - 1);<br>
+ uint32_t priorityList0 = 0xEDC984; // { 0, 1, 0, 2, 1, 2, 0, 3, 1, 3, 2, 3 }<br>
+ uint32_t priorityList1 = 0xB73621; // { 1, 0, 2, 0, 2, 1, 3, 0, 3, 1, 3, 2 }<br>
+<br>
+ for (int idx = 0; idx < cutoff; idx++)<br>
{<br>
- int i = priorityList0[idx];<br>
- int j = priorityList1[idx];<br>
- if (abCandIsInter[i] && abCandIsInter[j] && (interDirNeighbours[i] & 0x1) && (interDirNeighbours[j] & 0x2))<br>
+ int i = priorityList0 & 3;<br>
+ int j = priorityList1 & 3;<br>
+ priorityList0 >>= 2;<br>
+ priorityList1 >>= 2;<br>
+<br>
+ if ((interDirNeighbours[i] & 0x1) && (interDirNeighbours[j] & 0x2))<br>
{<br>
- abCandIsInter[arrayAddr] = true;<br>
- interDirNeighbours[arrayAddr] = 3;<br>
-<br>
// get Mv from cand[i] and cand[j]<br>
- mvFieldNeighbours[arrayAddr << 1].setMvField(mvFieldNeighbours[i << 1].mv, mvFieldNeighbours[i << 1].refIdx);<br>
- mvFieldNeighbours[(arrayAddr << 1) + 1].setMvField(mvFieldNeighbours[(j << 1) + 1].mv, mvFieldNeighbours[(j << 1) + 1].refIdx);<br>
-<br>
- int refPOCL0 = m_slice->getRefPOC(REF_PIC_LIST_0, mvFieldNeighbours[(arrayAddr << 1)].refIdx);<br>
- int refPOCL1 = m_slice->getRefPOC(REF_PIC_LIST_1, mvFieldNeighbours[(arrayAddr << 1) + 1].refIdx);<br>
- if (refPOCL0 == refPOCL1 && mvFieldNeighbours[(arrayAddr << 1)].mv == mvFieldNeighbours[(arrayAddr << 1) + 1].mv)<br>
+ int refIdxL0 = mvFieldNeighbours[i << 1].refIdx;<br>
+ int refIdxL1 = mvFieldNeighbours[(j << 1) + 1].refIdx;<br>
+ int refPOCL0 = m_slice->getRefPOC(REF_PIC_LIST_0, refIdxL0);<br>
+ int refPOCL1 = m_slice->getRefPOC(REF_PIC_LIST_1, refIdxL1);<br>
+ if (!(refPOCL0 == refPOCL1 && mvFieldNeighbours[i << 1].mv == mvFieldNeighbours[(j << 1) + 1].mv))<br>
{<br>
- abCandIsInter[arrayAddr] = false;<br>
- }<br>
- else<br>
- {<br>
+ mvFieldNeighbours[arrayAddr << 1].setMvField(mvFieldNeighbours[i << 1].mv, refIdxL0);<br>
+ mvFieldNeighbours[(arrayAddr << 1) + 1].setMvField(mvFieldNeighbours[(j << 1) + 1].mv, refIdxL1);<br>
+ interDirNeighbours[arrayAddr] = 3;<br>
+<br>
arrayAddr++;<br>
+ // early termination<br>
+ if (arrayAddr == maxNumMergeCand)<br>
+ {<br>
+ return;<br>
+ }<br>
}<br>
}<br>
}<br>
}<br>
- // early termination<br>
- if (arrayAddr == getSlice()->getMaxNumMergeCand())<br>
- {<br>
- return;<br>
- }<br>
- int numRefIdx = (getSlice()->isInterB()) ? X265_MIN(m_slice->getNumRefIdx(REF_PIC_LIST_0), m_slice->getNumRefIdx(REF_PIC_LIST_1)) : m_slice->getNumRefIdx(REF_PIC_LIST_0);<br>
+ int numRefIdx = (isInterB) ? X265_MIN(m_slice->getNumRefIdx(REF_PIC_LIST_0), m_slice->getNumRefIdx(REF_PIC_LIST_1)) : m_slice->getNumRefIdx(REF_PIC_LIST_0);<br>
int r = 0;<br>
int refcnt = 0;<br>
- while (arrayAddr < getSlice()->getMaxNumMergeCand())<br>
+ while (arrayAddr < maxNumMergeCand)<br>
{<br>
- abCandIsInter[arrayAddr] = true;<br>
interDirNeighbours[arrayAddr] = 1;<br>
mvFieldNeighbours[arrayAddr << 1].setMvField(MV(0, 0), r);<br>
<br>
- if (getSlice()->isInterB())<br>
+ if (isInterB)<br>
{<br>
interDirNeighbours[arrayAddr] = 3;<br>
mvFieldNeighbours[(arrayAddr << 1) + 1].setMvField(MV(0, 0), r);<br>
@@ -2253,8 +2219,6 @@<br>
++refcnt;<br>
}<br>
}<br>
-<br>
- numValidMergeCand = arrayAddr;<br>
}<br>
<br>
/** Check whether the current PU and a spatial neighboring PU are in a same ME region.<br>
diff -r fa9f7b56d4d8 -r e74cb7ea8645 source/Lib/TLibCommon/TComDataCU.h<br>
--- a/source/Lib/TLibCommon/TComDataCU.h Fri Feb 07 21:37:17 2014 +0530<br>
+++ b/source/Lib/TLibCommon/TComDataCU.h Sat Feb 08 22:50:38 2014 +0900<br>
@@ -435,7 +435,7 @@<br>
void deriveLeftBottomIdxAdi(uint32_t& partIdxLB, uint32_t partOffset, uint32_t partDepth);<br>
<br>
bool hasEqualMotion(uint32_t absPartIdx, TComDataCU* candCU, uint32_t candAbsPartIdx);<br>
- void getInterMergeCandidates(uint32_t absPartIdx, uint32_t puIdx, TComMvField* mFieldNeighbours, UChar* interDirNeighbours, int& numValidMergeCand, int mrgCandIdx = -1);<br>
+ void getInterMergeCandidates(uint32_t absPartIdx, uint32_t puIdx, TComMvField* mFieldNeighbours, UChar* interDirNeighbours, int& numValidMergeCand);<br>
void deriveLeftRightTopIdxGeneral(uint32_t absPartIdx, uint32_t partIdx, uint32_t& partIdxLT, uint32_t& partIdxRT);<br>
void deriveLeftBottomIdxGeneral(uint32_t absPartIdx, uint32_t partIdx, uint32_t& partIdxLB);<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
From: chen <<a href="mailto:chenm003@163.com">chenm003@163.com</a>><br>
Subject: Re: [x265] add static const for local tables<br>
Date: Fri, 7 Feb 2014 14:30:25 +0800 (CST)<br>
<br>
> diff --git a/source/Lib/TLibCommon/TComDataCU.cpp b/source/Lib/TLibCommon/TComDataCU.cpp<br>
> index 8b2636c..452a464 100644<br>
> --- a/source/Lib/TLibCommon/TComDataCU.cpp<br>
> +++ b/source/Lib/TLibCommon/TComDataCU.cpp<br>
> @@ -2194,13 +2194,16 @@ void TComDataCU::getInterMergeCandidates(uint32_t absPartIdx, uint32_t puIdx, TC<br>
> if (getSlice()->isInterB())<br>
> {<br>
> // TODO: TComRom??<br>
> - uint32_t priorityList0[12] = { 0, 1, 0, 2, 1, 2, 0, 3, 1, 3, 2, 3 };<br>
> - uint32_t priorityList1[12] = { 1, 0, 2, 0, 2, 1, 3, 0, 3, 1, 3, 2 };<br>
> + uint32_t priorityList0 = 0xEDC984; // { 0, 1, 0, 2, 1, 2, 0, 3, 1, 3, 2, 3 }<br>
> + uint32_t priorityList1 = 0xB73621; // { 1, 0, 2, 0, 2, 1, 3, 0, 3, 1, 3, 2 }<br>
> for (int idx = 0; idx < cutoff * (cutoff - 1) && arrayAddr != getSlice()->getMaxNumMergeCand(); idx<br>
> {<br>
> - int i = priorityList0[idx];<br>
> - int j = priorityList1[idx];<br>
> + int i = priorityList0 & 3;<br>
> + int j = priorityList1 & 3;<br>
> + priorityList0 >>= 2;<br>
> + priorityList1 >>= 2;<br>
> +<br>
> if (abCandIsInter[i] && abCandIsInter[j] && (interDirNeighbours[i] & 0x1) && (interDirNeighbour<br>
> {<br>
> abCandIsInter[arrayAddr] = true;<br>
><br>
> At 2014-02-07 08:44:02,"Satoshi Nakagawa" <<a href="mailto:nakagawa424@oki.com">nakagawa424@oki.com</a>> wrote:<br>
>># HG changeset patch<br>
>># User Satoshi Nakagawa <<a href="mailto:nakagawa424@oki.com">nakagawa424@oki.com</a>><br>
>># Date 1391733642 -32400<br>
>># Fri Feb 07 09:40:42 2014 +0900<br>
>># Node ID 0564ff2d14d17ec46ea27d5cb20a770c1b80144f<br>
>># Parent 40bec5582eca28ec0bc896e4e9412d580e42f4e4<br>
>>add static const for local tables<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>