[x265] revert getSigCtxInc() to 0.7
Steve Borho
steve at borho.org
Mon Mar 10 18:53:33 CET 2014
On Mon, Mar 10, 2014 at 3:11 AM, Satoshi Nakagawa <nakagawa424 at oki.com> wrote:
> # HG changeset patch
> # User Satoshi Nakagawa <nakagawa424 at oki.com>
> # Date 1394438812 -32400
> # Mon Mar 10 17:06:52 2014 +0900
> # Node ID d1d80d6baa3fa2db76ec769e461201ae68405f27
> # Parent 82a66870fc8b35519cbd7cb4f803740aba98b98b
> revert getSigCtxInc() to 0.7
Is this backing out some of your previous changes? If so, why?
> diff -r 82a66870fc8b -r d1d80d6baa3f source/Lib/TLibCommon/TComTrQuant.cpp
> --- a/source/Lib/TLibCommon/TComTrQuant.cpp Sun Mar 09 21:49:30 2014 -0500
> +++ b/source/Lib/TLibCommon/TComTrQuant.cpp Mon Mar 10 17:06:52 2014 +0900
> @@ -488,6 +488,7 @@
> {
> //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 @@
>
> //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 @@
> }
> 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::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 @@
> 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 82a66870fc8b -r d1d80d6baa3f source/Lib/TLibCommon/TComTrQuant.h
> --- a/source/Lib/TLibCommon/TComTrQuant.h Sun Mar 09 21:49:30 2014 -0500
> +++ b/source/Lib/TLibCommon/TComTrQuant.h Mon Mar 10 17:06:52 2014 +0900
> @@ -159,7 +159,7 @@
> 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 82a66870fc8b -r d1d80d6baa3f source/Lib/TLibCommon/TypeDef.h
> --- a/source/Lib/TLibCommon/TypeDef.h Sun Mar 09 21:49:30 2014 -0500
> +++ b/source/Lib/TLibCommon/TypeDef.h Mon Mar 10 17:06:52 2014 +0900
> @@ -176,6 +176,8 @@
> 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 82a66870fc8b -r d1d80d6baa3f source/Lib/TLibEncoder/TEncSbac.cpp
> --- a/source/Lib/TLibEncoder/TEncSbac.cpp Sun Mar 09 21:49:30 2014 -0500
> +++ b/source/Lib/TLibEncoder/TEncSbac.cpp Mon Mar 10 17:06:52 2014 +0900
> @@ -2185,7 +2185,7 @@
> 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)
> _______________________________________________
> x265-devel mailing list
> x265-devel at videolan.org
> https://mailman.videolan.org/listinfo/x265-devel
--
Steve Borho
More information about the x265-devel
mailing list