[x265] [PATCH] optimize c1c2 context set update logic in rdoQuant
Min Chen
chenm003 at 163.com
Thu Apr 9 14:26:30 CEST 2015
# HG changeset patch
# User Min Chen <chenm003 at 163.com>
# Date 1428582384 -28800
# Node ID 766b8a5f174e20b943387ef8897d21f3ef27eb5f
# Parent 7f2d92923de47e7e40f04ff27ed70074b0dca9d3
optimize c1c2 context set update logic in rdoQuant
---
source/common/quant.cpp | 31 ++++++++++++-------------------
1 files changed, 12 insertions(+), 19 deletions(-)
diff -r 7f2d92923de4 -r 766b8a5f174e source/common/quant.cpp
--- a/source/common/quant.cpp Wed Apr 08 14:51:00 2015 -0500
+++ b/source/common/quant.cpp Thu Apr 09 20:26:24 2015 +0800
@@ -559,11 +559,6 @@
uint64_t sigCoeffGroupFlag64 = 0;
uint32_t ctxSet = 0;
- int c1 = 1;
- int c2 = 0;
- uint32_t goRiceParam = 0;
- uint32_t c1Idx = 0;
- uint32_t c2Idx = 0;
int cgLastScanPos = -1;
int lastScanPos = -1;
const uint32_t cgSize = (1 << MLS_CG_SIZE); /* 4x4 num coef = 16 */
@@ -599,6 +594,11 @@
const int patternSigCtx = calcPatternSigCtx(sigCoeffGroupFlag64, cgPosX, cgPosY, cgBlkPos, cgStride);
+ int c1 = 1;
+ int c2 = 0;
+ uint32_t goRiceParam = 0;
+ uint32_t c1Idx = 0;
+ uint32_t c2Idx = 0;
/* iterate over coefficients in each group in reverse scan order */
for (int scanPosinCG = cgSize - 1; scanPosinCG >= 0; scanPosinCG--)
{
@@ -800,20 +800,6 @@
}
else if ((c1 < 3) && (c1 > 0) && level)
c1++;
-
- /* context set update */
- if (!(scanPos % SCAN_SET_SIZE) && scanPos)
- {
- c2 = 0;
- goRiceParam = 0;
-
- c1Idx = 0;
- c2Idx = 0;
- ctxSet = (scanPos == SCAN_SET_SIZE || !bIsLuma) ? 0 : 2;
- X265_CHECK(c1 >= 0, "c1 is negative\n");
- ctxSet -= ((int32_t)(c1 - 1) >> 31);
- c1 = 1;
- }
}
cgRdStats.sigCost += costSig[scanPos];
@@ -829,6 +815,13 @@
}
} /* end for (scanPosinCG) */
+ /* context set update */
+ {
+ ctxSet = (cgScanPos == 1 || !bIsLuma) ? 0 : 2;
+ X265_CHECK(c1 >= 0, "c1 is negative\n");
+ ctxSet -= ((int32_t)(c1 - 1) >> 31);
+ }
+
costCoeffGroupSig[cgScanPos] = 0;
if (cgLastScanPos < 0)
More information about the x265-devel
mailing list