[x265] [PATCH 5 of 6] reduce conditional operators in rdoQuant
Min Chen
chenm003 at 163.com
Thu Sep 10 00:33:44 CEST 2015
# HG changeset patch
# User Min Chen <chenm003 at 163.com>
# Date 1441837045 18000
# Node ID 41afa68a2c9c9e591c2e95264e2edc987df45d62
# Parent 5731695ca0c1c8e2c71bdf3cc3aa2b7fe13ea786
reduce conditional operators in rdoQuant
---
source/common/quant.cpp | 23 +++++++----------------
1 files changed, 7 insertions(+), 16 deletions(-)
diff -r 5731695ca0c1 -r 41afa68a2c9c source/common/quant.cpp
--- a/source/common/quant.cpp Wed Sep 09 17:17:22 2015 -0500
+++ b/source/common/quant.cpp Wed Sep 09 17:17:25 2015 -0500
@@ -1244,7 +1244,7 @@
if (cu.m_slice->m_pps->bSignHideEnabled && numSig >= 2)
{
const int realLastScanPos = (bestLastIdx - 1) >> LOG2_SCAN_SET_SIZE;
- int lastCG = true;
+ int lastCG = 1;
for (int subSet = realLastScanPos; subSet >= 0; subSet--)
{
int subPos = subSet << LOG2_SCAN_SET_SIZE;
@@ -1297,27 +1297,18 @@
/* if decrementing would make the coeff 0, we can include the
* significant coeff flag cost savings */
d = abs(signCoef) - UNQUANT(absLevel - 1);
- bool isOne = abs(dstCoeff[blkPos]) == 1;
+ int isOne = (abs(dstCoeff[blkPos]) == 1);
int downBits = rateIncDown[blkPos] - (isOne ? (IEP_RATE + sigRateDelta[blkPos]) : 0);
int64_t costDown = DELTARDCOST(d, downBits);
- if (lastCG && lastNZPosInCG == n && isOne)
- costDown -= 4 * IEP_RATE;
+ costDown -= (lastCG & (n == lastNZPosInCG) & isOne) * 4 * IEP_RATE;
+ curCost = ((n == firstNZPosInCG) & isOne) ? MAX_INT64 : costDown;
+ curChange = 2 * (costUp < costDown) - 1;
if (costUp < costDown)
- {
curCost = costUp;
- curChange = 1;
- }
- else
- {
- curChange = -1;
- if (n == firstNZPosInCG && isOne)
- curCost = MAX_INT64;
- else
- curCost = costDown;
- }
}
+ //else if ((n < firstNZPosInCG) & (signbit != ((uint32_t)signCoef >> 31)))
else if (n < firstNZPosInCG && signbit != (signCoef >= 0 ? 0 : 1U))
{
/* don't try to make a new coded coeff before the first coeff if its
@@ -1357,7 +1348,7 @@
}
}
- lastCG = false;
+ lastCG = 0;
}
}
More information about the x265-devel
mailing list