[x265] [PATCH 1 of 2] framepp: move compressMV into loop
Min Chen
chenm003 at 163.com
Thu Sep 5 14:17:18 CEST 2013
# HG changeset patch
# User Min Chen <chenm003 at 163.com>
# Date 1378383401 -28800
# Node ID b121e96290e2aff38a0e757e10d1f443a4d3202a
# Parent bce4dbc57e094c489504d3e23a3b66c625d214cc
framepp: move compressMV into loop
diff -r bce4dbc57e09 -r b121e96290e2 source/Lib/TLibCommon/TComDataCU.cpp
--- a/source/Lib/TLibCommon/TComDataCU.cpp Thu Sep 05 14:57:16 2013 +0530
+++ b/source/Lib/TLibCommon/TComDataCU.cpp Thu Sep 05 20:16:41 2013 +0800
@@ -66,6 +66,7 @@
m_skipFlag = NULL;
m_partSizes = NULL;
m_predModes = NULL;
+ m_cmv_predModes = NULL;
m_cuTransquantBypass = NULL;
m_width = NULL;
m_height = NULL;
@@ -122,6 +123,7 @@
m_partSizes = new char[numPartition];
memset(m_partSizes, SIZE_NONE, numPartition * sizeof(*m_partSizes));
m_predModes = new char[numPartition];
+ m_cmv_predModes = new char[numPartition];
m_cuTransquantBypass = new bool[numPartition];
m_bMergeFlags = (bool*)X265_MALLOC(bool, numPartition);
@@ -175,6 +177,7 @@
if (m_skipFlag) { delete[] m_skipFlag; m_skipFlag = NULL; }
if (m_partSizes) { delete[] m_partSizes; m_partSizes = NULL; }
if (m_predModes) { delete[] m_predModes; m_predModes = NULL; }
+ if (m_cmv_predModes) { delete[] m_cmv_predModes; m_cmv_predModes = NULL; }
if (m_cuTransquantBypass) { delete[] m_cuTransquantBypass; m_cuTransquantBypass = NULL; }
if (m_cbf[0]) { X265_FREE(m_cbf[0]); m_cbf[0] = NULL; }
if (m_cbf[1]) { X265_FREE(m_cbf[1]); m_cbf[1] = NULL; }
@@ -3022,18 +3025,18 @@
curRefPOC = m_slice->getRefPic(picList, outRefIdx)->getPOC();
colPOC = colCU->getSlice()->getPOC();
- if (colCU->isIntra(absPartAddr))
+ if (colCU->isIntra_cmv(absPartAddr))
{
return false;
}
colRefPicList = getSlice()->getCheckLDC() ? picList : RefPicList(getSlice()->getColFromL0Flag());
- int colRefIdx = colCU->getCUMvField(RefPicList(colRefPicList))->getRefIdx(absPartAddr);
+ int colRefIdx = colCU->getCUMvField(RefPicList(colRefPicList))->getRefIdx_cmv(absPartAddr);
if (colRefIdx < 0)
{
colRefPicList = RefPicList(1 - colRefPicList);
- colRefIdx = colCU->getCUMvField(RefPicList(colRefPicList))->getRefIdx(absPartAddr);
+ colRefIdx = colCU->getCUMvField(RefPicList(colRefPicList))->getRefIdx_cmv(absPartAddr);
if (colRefIdx < 0)
{
@@ -3043,7 +3046,7 @@
// Scale the vector.
colRefPOC = colCU->getSlice()->getRefPOC(colRefPicList, colRefIdx);
- colmv = colCU->getCUMvField(colRefPicList)->getMv(absPartAddr);
+ colmv = colCU->getCUMvField(colRefPicList)->getMv_cmv(absPartAddr);
curRefPOC = m_slice->getRefPic(picList, outRefIdx)->getPOC();
bool bIsCurrRefLongTerm = m_slice->getRefPic(picList, outRefIdx)->getIsLongTerm();
@@ -3118,8 +3121,9 @@
if (scaleFactor > 0)
{
- m_cuMvField[0].compress(m_predModes, scaleFactor);
- m_cuMvField[1].compress(m_predModes, scaleFactor);
+ memcpy(m_cmv_predModes, m_predModes, m_numPartitions * sizeof(m_predModes[0]));
+ m_cuMvField[0].compress(m_cmv_predModes, scaleFactor);
+ m_cuMvField[1].compress(m_cmv_predModes, scaleFactor);
}
}
diff -r bce4dbc57e09 -r b121e96290e2 source/Lib/TLibCommon/TComDataCU.h
--- a/source/Lib/TLibCommon/TComDataCU.h Thu Sep 05 14:57:16 2013 +0530
+++ b/source/Lib/TLibCommon/TComDataCU.h Thu Sep 05 20:16:41 2013 +0800
@@ -133,6 +133,7 @@
bool* m_skipFlag; ///< array of skip flags
char* m_partSizes; ///< array of partition sizes
char* m_predModes; ///< array of prediction modes
+ char* m_cmv_predModes; ///< array of prediction modes
bool* m_cuTransquantBypass; ///< array of cu_transquant_bypass flags
char* m_qp; ///< array of QP values
UChar* m_trIdx; ///< array of transform indices
@@ -512,6 +513,7 @@
// -------------------------------------------------------------------------------------------------------------------
bool isIntra(UInt partIdx) { return m_predModes[partIdx] == MODE_INTRA; }
+ bool isIntra_cmv(UInt partIdx) { return m_cmv_predModes[partIdx] == MODE_INTRA; }
bool isSkipped(UInt partIdx); ///< SKIP (no residual)
bool isBipredRestriction(UInt puIdx);
diff -r bce4dbc57e09 -r b121e96290e2 source/Lib/TLibCommon/TComMotionInfo.cpp
--- a/source/Lib/TLibCommon/TComMotionInfo.cpp Thu Sep 05 14:57:16 2013 +0530
+++ b/source/Lib/TLibCommon/TComMotionInfo.cpp Thu Sep 05 20:16:41 2013 +0800
@@ -59,10 +59,16 @@
assert(m_mvd == NULL);
assert(m_refIdx == NULL);
+ assert(m_cmv_mv == NULL);
+ assert(m_cmv_refIdx == NULL);
+
m_mv = new MV[numPartition];
m_mvd = new MV[numPartition];
m_refIdx = new char[numPartition];
+ m_cmv_mv = new MV[numPartition];
+ m_cmv_refIdx = new char[numPartition];
+
m_numPartitions = numPartition;
}
@@ -72,14 +78,23 @@
assert(m_mvd != NULL);
assert(m_refIdx != NULL);
+ assert(m_cmv_mv != NULL);
+ assert(m_cmv_refIdx != NULL);
+
delete[] m_mv;
delete[] m_mvd;
delete[] m_refIdx;
+ delete[] m_cmv_mv;
+ delete[] m_cmv_refIdx;
+
m_mv = NULL;
m_mvd = NULL;
m_refIdx = NULL;
+ m_cmv_mv = NULL;
+ m_cmv_refIdx = NULL;
+
m_numPartitions = 0;
}
@@ -349,11 +364,10 @@
int refIdx = m_refIdx[partIdx];
for (int i = 0; i < N; i++)
{
- m_mv[partIdx + i] = mv;
+ m_cmv_mv[partIdx + i] = mv;
predMode[partIdx + i] = mode;
- m_refIdx[partIdx + i] = refIdx;
+ m_cmv_refIdx[partIdx + i] = refIdx;
}
}
}
-
//! \}
diff -r bce4dbc57e09 -r b121e96290e2 source/Lib/TLibCommon/TComMotionInfo.h
--- a/source/Lib/TLibCommon/TComMotionInfo.h Thu Sep 05 14:57:16 2013 +0530
+++ b/source/Lib/TLibCommon/TComMotionInfo.h Thu Sep 05 20:16:41 2013 +0800
@@ -92,12 +92,15 @@
UInt m_numPartitions;
AMVPInfo m_cAMVPInfo;
+ MV* m_cmv_mv;
+ char* m_cmv_refIdx;
+
template<typename T>
void setAll(T *p, T const & val, PartSize cuMode, int partAddr, UInt depth, int partIdx);
public:
- TComCUMvField() : m_mv(NULL), m_mvd(NULL), m_refIdx(NULL), m_numPartitions(0) {}
+ TComCUMvField() : m_mv(NULL), m_mvd(NULL), m_refIdx(NULL), m_numPartitions(0), m_cmv_mv(NULL), m_cmv_refIdx(NULL) {}
~TComCUMvField() {}
@@ -123,10 +126,12 @@
// ------------------------------------------------------------------------------------------------------------------
const MV & getMv(int idx) const { return m_mv[idx]; }
+ const MV & getMv_cmv(int idx) const { return m_cmv_mv[idx]; }
const MV & getMvd(int idx) const { return m_mvd[idx]; }
int getRefIdx(int idx) const { return m_refIdx[idx]; }
+ int getRefIdx_cmv(int idx) const { return m_cmv_refIdx[idx]; }
AMVPInfo* getAMVPInfo() { return &m_cAMVPInfo; }
diff -r bce4dbc57e09 -r b121e96290e2 source/encoder/frameencoder.cpp
--- a/source/encoder/frameencoder.cpp Thu Sep 05 14:57:16 2013 +0530
+++ b/source/encoder/frameencoder.cpp Thu Sep 05 20:16:41 2013 +0800
@@ -620,7 +620,9 @@
m_frameFilter.end();
m_pic->destroyNonDBFilterInfo();
}
- m_pic->compressMotion();
+
+ // TODO: merge into compress loop, need some time to verify, remove later
+ //m_pic->compressMotion();
/* Decrement referenced frame reference counts, allow them to be recycled */
for (int l = 0; l < numPredDir; l++)
diff -r bce4dbc57e09 -r b121e96290e2 source/encoder/framefilter.cpp
--- a/source/encoder/framefilter.cpp Thu Sep 05 14:57:16 2013 +0530
+++ b/source/encoder/framefilter.cpp Thu Sep 05 20:16:41 2013 +0800
@@ -222,6 +222,18 @@
}
}
+ // CompressMV for reference
+ if (row > 0)
+ {
+ for (UInt col = 0; col < numCols; col++)
+ {
+ const uint32_t cuAddr = lineStartCUAddr - numCols + col;
+ TComDataCU* cu = m_pic->getCU(cuAddr);
+
+ cu->compressMV();
+ }
+ }
+
// this row of CTUs has been encoded
// TODO: extend margins for motion reference
@@ -295,7 +307,14 @@
}
}
- m_completionEvent.trigger();
+ // CompressMV
+ for (UInt col = 0; col < numCols; col++)
+ {
+ const uint32_t cuAddr = lineStartCUAddr + col;
+ TComDataCU* cu = m_pic->getCU(cuAddr);
+
+ cu->compressMV();
+ }
// TODO: Remove when we confirm below code is right
//recon->xExtendPicCompBorder(recon->getLumaAddr(), recon->getStride(), recon->getWidth(), recon->getHeight(), recon->m_lumaMarginX, recon->m_lumaMarginY);
@@ -333,5 +352,7 @@
{
m_pic->m_reconRowWait.trigger();
}
+
+ m_completionEvent.trigger();
}
}
More information about the x265-devel
mailing list