[x265-commits] [x265] vbv: bug fix - down shifting of satdcost for 10 bit depth.
Aarthi at videolan.org
Aarthi at videolan.org
Tue Mar 11 22:23:59 CET 2014
details: http://hg.videolan.org/x265/rev/7832cb8323dd
branches:
changeset: 6460:7832cb8323dd
user: Aarthi Thirumalai
date: Tue Mar 11 18:36:31 2014 +0530
description:
vbv: bug fix - down shifting of satdcost for 10 bit depth.
Subject: [x265] vbv: use row wise IntraSatdCost to predict vbv intra frame bits.
details: http://hg.videolan.org/x265/rev/380c4bf5ff75
branches: stable
changeset: 6461:380c4bf5ff75
user: Aarthi Thirumalai
date: Tue Mar 11 00:17:53 2014 +0530
description:
vbv: use row wise IntraSatdCost to predict vbv intra frame bits.
If P/B slice is predominatly intra coded, use intra SatdCost to predict the row
bits in vbv.
Subject: [x265] vbv: bug fixes - move row Predictors, frameSizeEstimated to Frame Encoder scope.
details: http://hg.videolan.org/x265/rev/1b84d0748a08
branches: stable
changeset: 6462:1b84d0748a08
user: Aarthi Thirumalai
date: Tue Mar 11 01:05:50 2014 +0530
description:
vbv: bug fixes - move row Predictors, frameSizeEstimated to Frame Encoder scope.
Improves quality and controls buffer underflow when Frame parallelism is enabled.
Subject: [x265] rc: move qp2qscale and qscale2qp function to common
details: http://hg.videolan.org/x265/rev/561adb9b21f6
branches: stable
changeset: 6463:561adb9b21f6
user: Aarthi Thirumalai
date: Tue Mar 11 01:16:28 2014 +0530
description:
rc: move qp2qscale and qscale2qp function to common
Subject: [x265] vbv: bug fix - down shifting of satdcost for 10 bit depth.
details: http://hg.videolan.org/x265/rev/c06ee069df5e
branches: stable
changeset: 6464:c06ee069df5e
user: Aarthi Thirumalai
date: Tue Mar 11 18:36:31 2014 +0530
description:
vbv: bug fix - down shifting of satdcost for 10 bit depth.
Subject: [x265] revert getSigCtxInc() to 0.7, this version was faster
details: http://hg.videolan.org/x265/rev/87638be9bc6b
branches:
changeset: 6465:87638be9bc6b
user: Satoshi Nakagawa <nakagawa424 at oki.com>
date: Mon Mar 10 17:06:52 2014 +0900
description:
revert getSigCtxInc() to 0.7, this version was faster
Subject: [x265] TEncSearch: dehungarians and other nits
details: http://hg.videolan.org/x265/rev/83d649aaf7ce
branches:
changeset: 6466:83d649aaf7ce
user: Steve Borho <steve at borho.org>
date: Tue Mar 11 15:42:47 2014 -0500
description:
TEncSearch: dehungarians and other nits
Subject: [x265] Merge with stable
details: http://hg.videolan.org/x265/rev/bbd35c26c4e4
branches:
changeset: 6467:bbd35c26c4e4
user: Steve Borho <steve at borho.org>
date: Tue Mar 11 15:57:36 2014 -0500
description:
Merge with stable
diffstat:
source/Lib/TLibCommon/TComTrQuant.cpp | 111 +++++++++++++++------------------
source/Lib/TLibCommon/TComTrQuant.h | 2 +-
source/Lib/TLibCommon/TypeDef.h | 2 +
source/Lib/TLibEncoder/TEncSbac.cpp | 2 +-
source/Lib/TLibEncoder/TEncSearch.cpp | 43 ++++++------
source/encoder/ratecontrol.cpp | 17 +++-
6 files changed, 85 insertions(+), 92 deletions(-)
diffs (truncated from 349 to 300 lines):
diff -r e40524d079b4 -r bbd35c26c4e4 source/Lib/TLibCommon/TComTrQuant.cpp
--- a/source/Lib/TLibCommon/TComTrQuant.cpp Mon Mar 10 23:03:05 2014 -0500
+++ b/source/Lib/TLibCommon/TComTrQuant.cpp Tue Mar 11 15:57:36 2014 -0500
@@ -488,6 +488,7 @@ void TComTrQuant::getTUEntropyCodingPara
{
//set the group layout
const uint32_t log2TrSizeCG = log2TrSize - MLS_CG_LOG2_SIZE;
+ result.log2TrSize = log2TrSize;
result.log2TrSizeCG = log2TrSizeCG;
//set the scan orders
@@ -497,6 +498,7 @@ void TComTrQuant::getTUEntropyCodingPara
//set the significance map context selection parameters
TextType ctype = ttype == TEXT_LUMA ? TEXT_LUMA : TEXT_CHROMA;
+ result.ctype = ctype;
if (log2TrSize == 2)
{
result.firstSignificanceMapContext = significanceMapContextSetStart[ctype][CONTEXT_TYPE_4x4];
@@ -625,7 +627,7 @@ uint32_t TComTrQuant::xRateDistOptQuant(
}
else
{
- uint16_t ctxSig = getSigCtxInc(patternSigCtx, codingParameters, scanPos, log2TrSize, ttype);
+ uint16_t ctxSig = getSigCtxInc(patternSigCtx, codingParameters, blkPos);
level = xGetCodedLevel(costCoeff[scanPos], costCoeff0[scanPos], costSig[scanPos],
levelDouble, maxAbsLevel, ctxSig, oneCtx, absCtx, goRiceParam,
c1Idx, c2Idx, qbits, scaleFactor, 0);
@@ -1026,9 +1028,7 @@ int TComTrQuant::calcPatternSigCtx(const
*/
int TComTrQuant::getSigCtxInc(int patternSigCtx,
const TUEntropyCodingParameters &codingParameters,
- const int scanPosition,
- const int log2TrSize,
- const TextType ttype)
+ const int blkPos)
{
static const int ctxIndMap[16] =
{
@@ -1037,73 +1037,60 @@ int TComTrQuant::getSigCtxInc(int
6, 6, 8, 8,
7, 7, 8, 8
};
- const uint32_t rasterPosition = codingParameters.scan[scanPosition];
- const uint32_t posY = rasterPosition >> log2TrSize;
- const uint32_t posX = rasterPosition - (posY << log2TrSize);
- if ((posX + posY) == 0) return 0; //special case for the DC context variable
+ if (blkPos == 0) return 0; //special case for the DC context variable
- int offset = MAX_INT;
-
+ const int log2TrSize = codingParameters.log2TrSize;
if (log2TrSize == 2) //4x4
{
- offset = ctxIndMap[(4 * posY) + posX];
+ return ctxIndMap[blkPos];
}
- else
+
+ const uint32_t posY = blkPos >> log2TrSize;
+ const uint32_t posX = blkPos - (posY << log2TrSize);
+
+ int posXinSubset = posX & 3;
+ int posYinSubset = posY & 3;
+
+ // NOTE: [patternSigCtx][posXinSubset][posYinSubset]
+ static const uint8_t table_cnt[4][4][4] =
{
- int cnt = 0;
+ // patternSigCtx = 0
+ {
+ { 2, 1, 1, 0 },
+ { 1, 1, 0, 0 },
+ { 1, 0, 0, 0 },
+ { 0, 0, 0, 0 },
+ },
+ // patternSigCtx = 1
+ {
+ { 2, 1, 0, 0 },
+ { 2, 1, 0, 0 },
+ { 2, 1, 0, 0 },
+ { 2, 1, 0, 0 },
+ },
+ // patternSigCtx = 2
+ {
+ { 2, 2, 2, 2 },
+ { 1, 1, 1, 1 },
+ { 0, 0, 0, 0 },
+ { 0, 0, 0, 0 },
+ },
+ // patternSigCtx = 3
+ {
+ { 2, 2, 2, 2 },
+ { 2, 2, 2, 2 },
+ { 2, 2, 2, 2 },
+ { 2, 2, 2, 2 },
+ }
+ };
- switch (patternSigCtx)
- {
- case 0: //neither neighbouring group is significant
- {
- const int posXinSubset = posX & ((1 << MLS_CG_LOG2_SIZE) - 1);
- const int posYinSubset = posY & ((1 << MLS_CG_LOG2_SIZE) - 1);
- const int posTotalInSubset = posXinSubset + posYinSubset;
+ int cnt = table_cnt[patternSigCtx][posXinSubset][posYinSubset];
+ int offset = codingParameters.firstSignificanceMapContext;
- //first N coefficients in scan order use 2; the next few use 1; the rest use 0.
- const uint32_t context1Threshold = NEIGHBOURHOOD_00_CONTEXT_1_THRESHOLD_4x4;
- const uint32_t context2Threshold = NEIGHBOURHOOD_00_CONTEXT_2_THRESHOLD_4x4;
+ offset += cnt;
- cnt = (posTotalInSubset >= context1Threshold) ? 0 : ((posTotalInSubset >= context2Threshold) ? 1 : 2);
- }
- break;
-
- case 1: //right group is significant, below is not
- {
- const int posYinSubset = posY & ((1 << MLS_CG_LOG2_SIZE) - 1);
- const int groupHeight = 1 << MLS_CG_LOG2_SIZE;
-
- cnt = (posYinSubset >= (groupHeight >> 1)) ? 0 : ((posYinSubset >= (groupHeight >> 2)) ? 1 : 2); //top quarter uses 2; second-from-top quarter uses 1; bottom half uses 0
- }
- break;
-
- case 2: //below group is significant, right is not
- {
- const int posXinSubset = posX & ((1 << MLS_CG_LOG2_SIZE) - 1);
- const int groupWidth = 1 << MLS_CG_LOG2_SIZE;
-
- cnt = (posXinSubset >= (groupWidth >> 1)) ? 0 : ((posXinSubset >= (groupWidth >> 2)) ? 1 : 2); //left quarter uses 2; second-from-left quarter uses 1; right half uses 0
- }
- break;
-
- case 3: //both neighbouring groups are significant
- {
- cnt = 2;
- }
- break;
-
- default:
- x265_log(NULL, X265_LOG_ERROR, "TComTrQuant: ERROR - Invalid patternSigCtx");
- exit(1);
- break;
- }
-
- const bool notFirstGroup = ((posX >> MLS_CG_LOG2_SIZE) + (posY >> MLS_CG_LOG2_SIZE)) > 0;
- TextType ctype = ttype == TEXT_LUMA ? TEXT_LUMA : TEXT_CHROMA;
- offset = (notFirstGroup ? notFirstGroupNeighbourhoodContextOffset[ctype] : 0) + cnt;
- }
- return codingParameters.firstSignificanceMapContext + offset;
+ return (codingParameters.ctype == TEXT_LUMA && (posX | posY) >= 4) ? 3 + offset : offset;
}
/** Get the best level in RD sense
diff -r e40524d079b4 -r bbd35c26c4e4 source/Lib/TLibCommon/TComTrQuant.h
--- a/source/Lib/TLibCommon/TComTrQuant.h Mon Mar 10 23:03:05 2014 -0500
+++ b/source/Lib/TLibCommon/TComTrQuant.h Tue Mar 11 15:57:36 2014 -0500
@@ -159,7 +159,7 @@ public:
void processScalingListEnc(int32_t *coeff, int32_t *quantcoeff, int quantScales, uint32_t height, uint32_t width, uint32_t ratio, int sizuNum, uint32_t dc);
void processScalingListDec(int32_t *coeff, int32_t *dequantcoeff, int invQuantScales, uint32_t height, uint32_t width, uint32_t ratio, int sizuNum, uint32_t dc);
static int calcPatternSigCtx(const uint32_t* sigCoeffGroupFlag, uint32_t cgPosX, uint32_t cgPosY, uint32_t log2TrSizeCG);
- static int getSigCtxInc(int patternSigCtx, const TUEntropyCodingParameters &codingParameters, const int scanPosition, const int log2TrSize, const TextType ttype);
+ static int getSigCtxInc(int patternSigCtx, const TUEntropyCodingParameters &codingParameters, const int blkPos);
static uint32_t getSigCoeffGroupCtxInc(const uint32_t* sigCoeffGroupFlag, uint32_t cgPosX, uint32_t cgPosY, const uint32_t log2TrSizeCG);
static void getTUEntropyCodingParameters(TComDataCU* cu, TUEntropyCodingParameters &result, uint32_t absPartIdx, uint32_t log2TrSize, TextType ttype);
estBitsSbacStruct* m_estBitsSbac;
diff -r e40524d079b4 -r bbd35c26c4e4 source/Lib/TLibCommon/TypeDef.h
--- a/source/Lib/TLibCommon/TypeDef.h Mon Mar 10 23:03:05 2014 -0500
+++ b/source/Lib/TLibCommon/TypeDef.h Tue Mar 11 15:57:36 2014 -0500
@@ -176,6 +176,8 @@ struct TUEntropyCodingParameters
const uint32_t *scan;
const uint32_t *scanCG;
COEFF_SCAN_TYPE scanType;
+ TextType ctype;
+ uint32_t log2TrSize;
uint32_t log2TrSizeCG;
uint32_t firstSignificanceMapContext;
};
diff -r e40524d079b4 -r bbd35c26c4e4 source/Lib/TLibEncoder/TEncSbac.cpp
--- a/source/Lib/TLibEncoder/TEncSbac.cpp Mon Mar 10 23:03:05 2014 -0500
+++ b/source/Lib/TLibEncoder/TEncSbac.cpp Tue Mar 11 15:57:36 2014 -0500
@@ -2164,7 +2164,7 @@ void TEncSbac::codeCoeffNxN(TComDataCU*
sig = (coeff[blkPos] != 0);
if (scanPosSig > subPos || subSet == 0 || numNonZero)
{
- ctxSig = TComTrQuant::getSigCtxInc(patternSigCtx, codingParameters, scanPosSig, log2TrSize, ttype);
+ ctxSig = TComTrQuant::getSigCtxInc(patternSigCtx, codingParameters, blkPos);
m_binIf->encodeBin(sig, baseCtx[ctxSig]);
}
if (sig)
diff -r e40524d079b4 -r bbd35c26c4e4 source/Lib/TLibEncoder/TEncSearch.cpp
--- a/source/Lib/TLibEncoder/TEncSearch.cpp Mon Mar 10 23:03:05 2014 -0500
+++ b/source/Lib/TLibEncoder/TEncSearch.cpp Tue Mar 11 15:57:36 2014 -0500
@@ -2882,9 +2882,9 @@ void TEncSearch::residualTransformQuantI
const bool bCheckSplit = (trSizeLog2 > cu->getQuadtreeTULog2MinSizeInCU(absPartIdx));
assert(bCheckFull || bCheckSplit);
- bool bCodeChroma = true;
- uint32_t trModeC = trMode;
- uint32_t trSizeCLog2 = trSizeLog2 - 1;
+ bool bCodeChroma = true;
+ uint32_t trModeC = trMode;
+ uint32_t trSizeCLog2 = trSizeLog2 - 1;
if (trSizeLog2 == 2)
{
trSizeCLog2++;
@@ -3073,8 +3073,8 @@ void TEncSearch::xEstimateResidualQT(TCo
const bool bCheckSplit = (trSizeLog2 > cu->getQuadtreeTULog2MinSizeInCU(absPartIdx));
assert(bCheckFull || bCheckSplit);
- bool bCodeChroma = true;
- uint32_t trModeC = trMode;
+ bool bCodeChroma = true;
+ uint32_t trModeC = trMode;
if ((trSizeLog2 == 2) && !(chFmt == CHROMA_444))
{
trSizeCLog2++;
@@ -3753,14 +3753,13 @@ void TEncSearch::xEncodeResidualQT(TComD
{
//Luma
const uint32_t numCoeffPerAbsPartIdxIncrement = cu->getSlice()->getSPS()->getMaxCUSize() * cu->getSlice()->getSPS()->getMaxCUSize() >> (cu->getSlice()->getSPS()->getMaxCUDepth() << 1);
- //assert( 16 == uiNumCoeffPerAbsPartIdxIncrement ); // check
const uint32_t qtlayer = cu->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() - trSizeLog2;
TCoeff *coeffCurY = m_qtTempCoeffY[qtlayer] + numCoeffPerAbsPartIdxIncrement * absPartIdx;
//Chroma
TCoeff *coeffCurU = m_qtTempCoeffCb[qtlayer] + (numCoeffPerAbsPartIdxIncrement * absPartIdx >> (m_hChromaShift + m_vChromaShift));
TCoeff *coeffCurV = m_qtTempCoeffCr[qtlayer] + (numCoeffPerAbsPartIdxIncrement * absPartIdx >> (m_hChromaShift + m_vChromaShift));
- bool bCodeChroma = true;
+ bool bCodeChroma = true;
if ((trSizeLog2 == 2) && !(chFmt == CHROMA_444))
{
trSizeCLog2++;
@@ -3817,15 +3816,15 @@ void TEncSearch::xSetResidualQTData(TCom
uint32_t trSizeCLog2 = g_convertToBit[(cu->getSlice()->getSPS()->getMaxCUSize() >> cu->getHorzChromaShift()) >> depth] + 2;
const uint32_t qtlayer = cu->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() - trSizeLog2;
- bool bCodeChroma = true;
+ bool bCodeChroma = true;
bool bChromaSame = false;
- uint32_t trModeC = trMode;
+ uint32_t trModeC = trMode;
if ((trSizeLog2 == 2) && !(chFmt == CHROMA_444))
{
trSizeCLog2++;
trModeC--;
uint32_t qpdiv = cu->getPic()->getNumPartInCU() >> ((cu->getDepth(0) + trModeC) << 1);
- bCodeChroma = ((absPartIdx % qpdiv) == 0);
+ bCodeChroma = ((absPartIdx % qpdiv) == 0);
bChromaSame = true;
}
@@ -3842,20 +3841,20 @@ void TEncSearch::xSetResidualQTData(TCom
}
else
{
- uint32_t uiNumCoeffPerAbsPartIdxIncrement = cu->getSlice()->getSPS()->getMaxCUSize() * cu->getSlice()->getSPS()->getMaxCUSize() >> (cu->getSlice()->getSPS()->getMaxCUDepth() << 1);
- uint32_t uiNumCoeffY = (1 << (trSizeLog2 << 1));
- TCoeff* pcCoeffSrcY = m_qtTempCoeffY[qtlayer] + uiNumCoeffPerAbsPartIdxIncrement * absPartIdx;
- TCoeff* pcCoeffDstY = cu->getCoeffY() + uiNumCoeffPerAbsPartIdxIncrement * absPartIdx;
- ::memcpy(pcCoeffDstY, pcCoeffSrcY, sizeof(TCoeff) * uiNumCoeffY);
+ uint32_t numCoeffPerAbsPartIdxIncrement = cu->getSlice()->getSPS()->getMaxCUSize() * cu->getSlice()->getSPS()->getMaxCUSize() >> (cu->getSlice()->getSPS()->getMaxCUDepth() << 1);
+ uint32_t numCoeffY = (1 << (trSizeLog2 << 1));
+ TCoeff* coeffSrcY = m_qtTempCoeffY[qtlayer] + numCoeffPerAbsPartIdxIncrement * absPartIdx;
+ TCoeff* coeffDstY = cu->getCoeffY() + numCoeffPerAbsPartIdxIncrement * absPartIdx;
+ ::memcpy(coeffDstY, coeffSrcY, sizeof(TCoeff) * numCoeffY);
if (bCodeChroma)
{
- uint32_t uiNumCoeffC = (1 << (trSizeCLog2 << 1));
- TCoeff* pcCoeffSrcU = m_qtTempCoeffCb[qtlayer] + (uiNumCoeffPerAbsPartIdxIncrement * absPartIdx >> (m_hChromaShift + m_vChromaShift));
- TCoeff* pcCoeffSrcV = m_qtTempCoeffCr[qtlayer] + (uiNumCoeffPerAbsPartIdxIncrement * absPartIdx >> (m_hChromaShift + m_vChromaShift));
- TCoeff* pcCoeffDstU = cu->getCoeffCb() + (uiNumCoeffPerAbsPartIdxIncrement * absPartIdx >> (m_hChromaShift + m_vChromaShift));
- TCoeff* pcCoeffDstV = cu->getCoeffCr() + (uiNumCoeffPerAbsPartIdxIncrement * absPartIdx >> (m_hChromaShift + m_vChromaShift));
- ::memcpy(pcCoeffDstU, pcCoeffSrcU, sizeof(TCoeff) * uiNumCoeffC);
- ::memcpy(pcCoeffDstV, pcCoeffSrcV, sizeof(TCoeff) * uiNumCoeffC);
+ uint32_t numCoeffC = (1 << (trSizeCLog2 << 1));
+ TCoeff* coeffSrcU = m_qtTempCoeffCb[qtlayer] + (numCoeffPerAbsPartIdxIncrement * absPartIdx >> (m_hChromaShift + m_vChromaShift));
+ TCoeff* coeffSrcV = m_qtTempCoeffCr[qtlayer] + (numCoeffPerAbsPartIdxIncrement * absPartIdx >> (m_hChromaShift + m_vChromaShift));
+ TCoeff* coeffDstU = cu->getCoeffCb() + (numCoeffPerAbsPartIdxIncrement * absPartIdx >> (m_hChromaShift + m_vChromaShift));
+ TCoeff* coeffDstV = cu->getCoeffCr() + (numCoeffPerAbsPartIdxIncrement * absPartIdx >> (m_hChromaShift + m_vChromaShift));
+ ::memcpy(coeffDstU, coeffSrcU, sizeof(TCoeff) * numCoeffC);
+ ::memcpy(coeffDstV, coeffSrcV, sizeof(TCoeff) * numCoeffC);
}
}
}
diff -r e40524d079b4 -r bbd35c26c4e4 source/encoder/ratecontrol.cpp
--- a/source/encoder/ratecontrol.cpp Mon Mar 10 23:03:05 2014 -0500
+++ b/source/encoder/ratecontrol.cpp Tue Mar 11 15:57:36 2014 -0500
@@ -670,7 +670,7 @@ double RateControl::clipQscale(TComPic*
totalDuration += frameDuration;
bufferFillCur += vbvMaxRate * frameDuration;
int type = pic->m_lowres.plannedType[j];
- int64_t satd = pic->m_lowres.plannedSatd[j];
+ int64_t satd = pic->m_lowres.plannedSatd[j] >> (X265_DEPTH - 8);
if (type == X265_TYPE_AUTO)
break;
More information about the x265-commits
mailing list