[x265-commits] [x265] checked: convert a pile of asserts() into optional runtim...
Steve Borho
steve at borho.org
Wed May 14 11:33:04 CEST 2014
details: http://hg.videolan.org/x265/rev/190a21bd77a3
branches:
changeset: 6855:190a21bd77a3
user: Steve Borho <steve at borho.org>
date: Wed May 14 14:06:27 2014 +0530
description:
checked: convert a pile of asserts() into optional runtime checks
Subject: [x265] TEncSearch: remove unused (and shadowed) variable
details: http://hg.videolan.org/x265/rev/8ae4d97f3913
branches:
changeset: 6856:8ae4d97f3913
user: Steve Borho <steve at borho.org>
date: Wed May 14 14:06:41 2014 +0530
description:
TEncSearch: remove unused (and shadowed) variable
Subject: [x265] cleanup clear()
details: http://hg.videolan.org/x265/rev/890b34705c95
branches:
changeset: 6857:890b34705c95
user: Satoshi Nakagawa <nakagawa424 at oki.com>
date: Wed May 14 14:13:08 2014 +0900
description:
cleanup clear()
diffstat:
source/Lib/TLibEncoder/TEncCu.cpp | 2 -
source/Lib/TLibEncoder/TEncSbac.cpp | 20 ++--
source/Lib/TLibEncoder/TEncSearch.cpp | 164 +++++++++++++++------------------
source/common/cpu.cpp | 2 +-
source/common/dct.cpp | 14 +-
source/common/piclist.cpp | 6 +-
source/common/pixel.cpp | 10 +-
source/common/primitives.h | 4 +-
source/common/threadpool.cpp | 6 +-
source/common/vec/dct-sse41.cpp | 2 +-
source/common/wavefront.cpp | 4 +-
source/encoder/compress.cpp | 10 +-
source/encoder/dpb.cpp | 6 +-
source/encoder/frameencoder.cpp | 4 +-
source/encoder/framefilter.cpp | 8 +-
source/encoder/motion.cpp | 4 +-
source/output/y4m.cpp | 7 +-
source/output/yuv.cpp | 4 +-
18 files changed, 132 insertions(+), 145 deletions(-)
diffs (truncated from 1078 to 300 lines):
diff -r a4d0d5679c28 -r 890b34705c95 source/Lib/TLibEncoder/TEncCu.cpp
--- a/source/Lib/TLibEncoder/TEncCu.cpp Sun May 11 17:32:37 2014 +0900
+++ b/source/Lib/TLibEncoder/TEncCu.cpp Wed May 14 14:13:08 2014 +0900
@@ -1354,8 +1354,6 @@ void TEncCu::xCheckRDCostInter(TComDataC
outTempCU->setPredModeSubParts(MODE_INTER, 0, depth);
outTempCU->setCUTransquantBypassSubParts(m_CUTransquantBypassFlagValue, 0, depth);
- m_tmpRecoYuv[depth]->clear(); // TODO: Are either of these clears necessary?
- m_tmpResiYuv[depth]->clear();
if (m_search->predInterSearch(outTempCU, m_tmpPredYuv[depth], bUseMRG, true))
{
m_search->encodeResAndCalcRdInterCU(outTempCU, m_origYuv[depth], m_tmpPredYuv[depth], m_tmpResiYuv[depth], m_bestResiYuv[depth], m_tmpRecoYuv[depth], false, true);
diff -r a4d0d5679c28 -r 890b34705c95 source/Lib/TLibEncoder/TEncSbac.cpp
--- a/source/Lib/TLibEncoder/TEncSbac.cpp Sun May 11 17:32:37 2014 +0900
+++ b/source/Lib/TLibEncoder/TEncSbac.cpp Wed May 14 14:13:08 2014 +0900
@@ -289,7 +289,7 @@ void TEncSbac::codeVPS(TComVPS* vps)
WRITE_CODE(0, 6, "vps_reserved_zero_6bits");
WRITE_CODE(vps->getMaxTLayers() - 1, 3, "vps_max_sub_layers_minus1");
WRITE_FLAG(vps->getTemporalNestingFlag(), "vps_temporal_id_nesting_flag");
- assert(vps->getMaxTLayers() > 1 || vps->getTemporalNestingFlag());
+ X265_CHECK(vps->getMaxTLayers() > 1 || vps->getTemporalNestingFlag(), "layer flags not matchin\n");
WRITE_CODE(0xffff, 16, "vps_reserved_ffff_16bits");
codePTL(vps->getPTL(), true, vps->getMaxTLayers() - 1);
WRITE_FLAG(true, "vps_sub_layer_ordering_info_present_flag");
@@ -300,8 +300,8 @@ void TEncSbac::codeVPS(TComVPS* vps)
WRITE_UVLC(vps->getMaxLatencyIncrease(i), "vps_max_latency_increase_plus1[i]");
}
- assert(vps->getNumHrdParameters() <= MAX_VPS_NUM_HRD_PARAMETERS);
- assert(vps->getMaxNuhReservedZeroLayerId() < MAX_VPS_NUH_RESERVED_ZERO_LAYER_ID_PLUS1);
+ X265_CHECK(vps->getNumHrdParameters() <= MAX_VPS_NUM_HRD_PARAMETERS, "invalid HRD param\n");
+ X265_CHECK(vps->getMaxNuhReservedZeroLayerId() < MAX_VPS_NUH_RESERVED_ZERO_LAYER_ID_PLUS1, "invalid layer\n");
WRITE_CODE(vps->getMaxNuhReservedZeroLayerId(), 6, "vps_max_nuh_reserved_zero_layer_id");
vps->setMaxOpSets(1);
WRITE_UVLC(vps->getMaxOpSets() - 1, "vps_max_op_sets_minus1");
@@ -471,7 +471,7 @@ void TEncSbac::codeSPS(TComSPS* sps)
WRITE_FLAG(sps->getPCMFilterDisableFlag() ? 1 : 0, "pcm_loop_filter_disable_flag");
}
- assert(sps->getMaxTLayers() > 0);
+ X265_CHECK(sps->getMaxTLayers() > 0, "max layers must be positive\n");
TComRPSList* rpsList = sps->getRPSList();
TComReferencePictureSet* rps;
@@ -879,7 +879,7 @@ void TEncSbac::xCodePredWeightTable(TCom
}
}
- assert(totalSignalledWeightFlags <= 24);
+ X265_CHECK(totalSignalledWeightFlags <= 24, "total weights must be <= 24\n");
}
}
@@ -1011,7 +1011,7 @@ void TEncSbac::codeSliceHeader(TComSlice
{
for (int i = 0; i < slice->getPPS()->getNumExtraSliceHeaderBits(); i++)
{
- assert(!!"slice_reserved_undetermined_flag[]");
+ X265_CHECK(0, "slice_reserved_undetermined_flag[]");
WRITE_FLAG(0, "slice_reserved_undetermined_flag[]");
}
@@ -1043,7 +1043,7 @@ void TEncSbac::codeSliceHeader(TComSlice
{
for (int picIdx = 0; picIdx < rps->getNumberOfPictures(); picIdx++)
{
- assert(!rps->getUsed(picIdx));
+ X265_CHECK(!rps->getUsed(picIdx), "pic unused failure\n");
}
}
@@ -1134,7 +1134,7 @@ void TEncSbac::codeSliceHeader(TComSlice
else
{
int differenceInDeltaMSB = rps->getDeltaPocMSBCycleLT(i) - prevDeltaMSB;
- assert(differenceInDeltaMSB >= 0);
+ X265_CHECK(differenceInDeltaMSB >= 0, "delta MSB must be positive\n");
WRITE_UVLC(differenceInDeltaMSB, "delta_poc_msb_cycle_lt[i]");
}
prevLSB = rps->getPocLSBLT(i);
@@ -1219,7 +1219,7 @@ void TEncSbac::codeSliceHeader(TComSlice
{
xCodePredWeightTable(slice);
}
- assert(slice->getMaxNumMergeCand() <= MRG_MAX_NUM_CANDS);
+ X265_CHECK(slice->getMaxNumMergeCand() <= MRG_MAX_NUM_CANDS, "too many merge candidates\n");
if (!slice->isIntra())
{
WRITE_UVLC(MRG_MAX_NUM_CANDS - slice->getMaxNumMergeCand(), "five_minus_max_num_merge_cand");
@@ -1299,7 +1299,7 @@ void TEncSbac::codeTilesWPPEntryPoint(T
while (maxOffset >= (1u << (offsetLenMinus1 + 1)))
{
offsetLenMinus1++;
- assert(offsetLenMinus1 + 1 < 32);
+ X265_CHECK(offsetLenMinus1 + 1 < 32, "offsetLenMinus1 is too large\n");
}
WRITE_UVLC(numEntryPointOffsets, "num_entry_point_offsets");
diff -r a4d0d5679c28 -r 890b34705c95 source/Lib/TLibEncoder/TEncSearch.cpp
--- a/source/Lib/TLibEncoder/TEncSearch.cpp Sun May 11 17:32:37 2014 +0900
+++ b/source/Lib/TLibEncoder/TEncSearch.cpp Wed May 14 14:13:08 2014 +0900
@@ -164,23 +164,23 @@ void TEncSearch::xEncSubdivCbfQT(TComDat
if (cu->getPredictionMode(0) == MODE_INTRA && cu->getPartitionSize(0) == SIZE_NxN && trDepth == 0)
{
- assert(subdiv);
+ X265_CHECK(subdiv, "subdivision not present\n");
}
else if (trSizeLog2 > cu->getSlice()->getSPS()->getQuadtreeTULog2MaxSize())
{
- assert(subdiv);
+ X265_CHECK(subdiv, "subdivision not present\n");
}
else if (trSizeLog2 == cu->getSlice()->getSPS()->getQuadtreeTULog2MinSize())
{
- assert(!subdiv);
+ X265_CHECK(!subdiv, "subdivision present\n");
}
else if (trSizeLog2 == cu->getQuadtreeTULog2MinSizeInCU(absPartIdx))
{
- assert(!subdiv);
+ X265_CHECK(!subdiv, "subdivision present\n");
}
else
{
- assert(trSizeLog2 > cu->getQuadtreeTULog2MinSizeInCU(absPartIdx));
+ X265_CHECK(trSizeLog2 > cu->getQuadtreeTULog2MinSizeInCU(absPartIdx), "transform size too small\n");
if (bLuma)
{
m_entropyCoder->encodeTransformSubdivFlag(subdiv, 5 - trSizeLog2);
@@ -244,7 +244,7 @@ void TEncSearch::xEncCoeffQT(TComDataCU*
int chFmt = cu->getChromaFormat();
if ((ttype != TEXT_LUMA) && (trSizeLog2 == 2) && !(chFmt == CHROMA_444))
{
- assert(trDepth > 0);
+ X265_CHECK(trDepth > 0, "transform size too small\n");
trDepth--;
uint32_t qpdiv = cu->getPic()->getNumPartInCU() >> ((cu->getDepth(0) + trDepth) << 1);
bool bFirstQ = ((absPartIdx % qpdiv) == 0);
@@ -272,7 +272,7 @@ void TEncSearch::xEncCoeffQT(TComDataCU*
break;
case TEXT_CHROMA_V: coeff = m_qtTempCoeffCr[qtLayer];
break;
- default: assert(0);
+ default: X265_CHECK(0, "invalid texture type\n");
}
coeff += coeffOffset;
@@ -322,7 +322,7 @@ void TEncSearch::xEncIntraHeader(TComDat
uint32_t qtNumParts = cu->getTotalNumPart() >> 2;
if (trDepth == 0)
{
- assert(absPartIdx == 0);
+ X265_CHECK(absPartIdx == 0, "unexpected absPartIdx %d\n", absPartIdx);
for (uint32_t part = 0; part < 4; part++)
{
m_entropyCoder->encodeIntraDirModeLuma(cu, part * qtNumParts);
@@ -347,7 +347,7 @@ void TEncSearch::xEncIntraHeader(TComDat
else
{
uint32_t qtNumParts = cu->getTotalNumPart() >> 2;
- assert(trDepth > 0);
+ X265_CHECK(trDepth > 0, "unexpected trDepth %d\n", trDepth);
if ((absPartIdx % qtNumParts) == 0)
m_entropyCoder->encodeIntraDirModeChroma(cu, absPartIdx);
}
@@ -410,7 +410,7 @@ void TEncSearch::xIntraCodingLumaBlk(TCo
int16_t* reconQt = m_qtTempShortYuv[qtLayer].getLumaAddr(absPartIdx);
- assert(m_qtTempShortYuv[qtLayer].m_width == MAX_CU_SIZE);
+ X265_CHECK(m_qtTempShortYuv[qtLayer].m_width == MAX_CU_SIZE, "width is not max CU size\n");
uint32_t zorder = cu->getZorderIdxInCU() + absPartIdx;
pixel* reconIPred = cu->getPic()->getPicYuvRec()->getLumaAddr(cu->getAddr(), zorder);
@@ -427,9 +427,9 @@ void TEncSearch::xIntraCodingLumaBlk(TCo
}
//===== get residual signal =====
- assert(!((uint32_t)(size_t)fenc & (tuSize - 1)));
- assert(!((uint32_t)(size_t)pred & (tuSize - 1)));
- assert(!((uint32_t)(size_t)residual & (tuSize - 1)));
+ X265_CHECK(!((uint32_t)(size_t)fenc & (tuSize - 1)), "fenc alignment check fail\n");
+ X265_CHECK(!((uint32_t)(size_t)pred & (tuSize - 1)), "pred alignment check fail\n");
+ X265_CHECK(!((uint32_t)(size_t)residual & (tuSize - 1)), "residual alignment check fail\n");
primitives.calcresidual[(int)g_convertToBit[tuSize]](fenc, pred, residual, stride);
//===== transform and quantization =====
@@ -458,7 +458,7 @@ void TEncSearch::xIntraCodingLumaBlk(TCo
if (absSum)
{
int scalingListType = 0 + TEXT_LUMA;
- assert(scalingListType < 6);
+ X265_CHECK(scalingListType < 6, "scalingListType is too large %d\n", scalingListType);
m_trQuant->invtransformNxN(cu->getCUTransquantBypass(absPartIdx), cu->getLumaIntraDir(absPartIdx), residual, stride, coeff, tuSize, scalingListType, useTransformSkip, lastPos);
}
else
@@ -468,7 +468,7 @@ void TEncSearch::xIntraCodingLumaBlk(TCo
primitives.blockfill_s[size](resiTmp, stride, 0);
}
- assert(tuSize <= 32);
+ X265_CHECK(tuSize <= 32, "tuSize is too large %d\n", tuSize);
//===== reconstruction =====
primitives.calcrecon[size](pred, residual, reconQt, reconIPred, stride, MAX_CU_SIZE, reconIPredStride);
//===== update distortion =====
@@ -494,7 +494,7 @@ void TEncSearch::xIntraCodingChromaBlk(T
if ((trSizeLog2 == 2) && !(chFmt == CHROMA_444))
{
- assert(trDepth > 0);
+ X265_CHECK(trDepth > 0, "trDepth should be non-zero\n");
trDepth--;
uint32_t qpdiv = cu->getPic()->getNumPartInCU() >> ((cu->getDepth(0) + trDepth) << 1);
bool bFirstQ = ((absPartIdx % qpdiv) == 0);
@@ -542,9 +542,9 @@ void TEncSearch::xIntraCodingChromaBlk(T
}
//===== get residual signal =====
- assert(!((uint32_t)(size_t)fenc & (tuSize - 1)));
- assert(!((uint32_t)(size_t)pred & (tuSize - 1)));
- assert(!((uint32_t)(size_t)residual & (tuSize - 1)));
+ X265_CHECK(!((uint32_t)(size_t)fenc & (tuSize - 1)), "fenc alignment check fail\n");
+ X265_CHECK(!((uint32_t)(size_t)pred & (tuSize - 1)), "pred alignment check fail\n");
+ X265_CHECK(!((uint32_t)(size_t)residual & (tuSize - 1)), "residual alignment check fail\n");
int size = g_convertToBit[tuSize];
primitives.calcresidual[size](fenc, pred, residual, stride);
@@ -581,7 +581,7 @@ void TEncSearch::xIntraCodingChromaBlk(T
if (absSum)
{
int scalingListType = 0 + ttype;
- assert(scalingListType < 6);
+ X265_CHECK(scalingListType < 6, "scalingListType invalid %d\n", scalingListType);
m_trQuant->invtransformNxN(cu->getCUTransquantBypass(absPartIdx), REG_DCT, residual, stride, coeff, tuSize, scalingListType, useTransformSkipChroma, lastPos);
}
else
@@ -592,8 +592,8 @@ void TEncSearch::xIntraCodingChromaBlk(T
}
}
- assert(((intptr_t)residual & (tuSize - 1)) == 0);
- assert(tuSize <= 32);
+ X265_CHECK(((intptr_t)residual & (tuSize - 1)) == 0, "residual alignment check failure\n");
+ X265_CHECK(tuSize <= 32, "tuSize invalud\n");
//===== reconstruction =====
primitives.calcrecon[size](pred, residual, reconQt, reconIPred, stride, reconQtStride, reconIPredStride);
//===== update distortion =====
@@ -810,7 +810,7 @@ void TEncSearch::xRecurIntraCodingQT(TCo
uint32_t qtLayer = cu->getSlice()->getSPS()->getQuadtreeTULog2MaxSize() - trSizeLog2;
uint32_t zorder = cu->getZorderIdxInCU() + absPartIdx;
int16_t* src = m_qtTempShortYuv[qtLayer].getLumaAddr(absPartIdx);
- assert(m_qtTempShortYuv[qtLayer].m_width == MAX_CU_SIZE);
+ X265_CHECK(m_qtTempShortYuv[qtLayer].m_width == MAX_CU_SIZE, "width is not max CU size\n");
pixel* dst = cu->getPic()->getPicYuvRec()->getLumaAddr(cu->getAddr(), zorder);
uint32_t dststride = cu->getPic()->getPicYuvRec()->getStride();
primitives.blockcpy_ps(width, height, dst, dststride, src, MAX_CU_SIZE);
@@ -873,9 +873,9 @@ void TEncSearch::residualTransformQuantI
predIntraLumaAng(lumaPredMode, pred, stride, tuSize);
//===== get residual signal =====
- assert(!((uint32_t)(size_t)fenc & (tuSize - 1)));
- assert(!((uint32_t)(size_t)pred & (tuSize - 1)));
- assert(!((uint32_t)(size_t)residual & (tuSize - 1)));
+ X265_CHECK(!((uint32_t)(size_t)fenc & (tuSize - 1)), "fenc alignment failure\n");
+ X265_CHECK(!((uint32_t)(size_t)pred & (tuSize - 1)), "pred alignment failure\n");
+ X265_CHECK(!((uint32_t)(size_t)residual & (tuSize - 1)), "residual alignment failure\n");
primitives.calcresidual[(int)g_convertToBit[tuSize]](fenc, pred, residual, stride);
//===== transform and quantization =====
@@ -895,7 +895,7 @@ void TEncSearch::residualTransformQuantI
if (absSum)
{
int scalingListType = 0 + TEXT_LUMA;
- assert(scalingListType < 6);
+ X265_CHECK(scalingListType < 6, "scalingListType %d\n", scalingListType);
m_trQuant->invtransformNxN(cu->getCUTransquantBypass(absPartIdx), cu->getLumaIntraDir(absPartIdx), residual, stride, coeff, tuSize, scalingListType, useTransformSkip, lastPos);
}
else
@@ -906,7 +906,7 @@ void TEncSearch::residualTransformQuantI
}
//Generate Recon
- assert(tuSize <= 32);
+ X265_CHECK(tuSize <= 32, "tuSize is too large\n");
int part = partitionFromSizes(tuSize, tuSize);
primitives.luma_add_ps[part](recon, stride, pred, residual, stride, stride);
primitives.blockcpy_pp(tuSize, tuSize, reconIPred, reconIPredStride, recon, stride);
@@ -1008,7 +1008,7 @@ void TEncSearch::xLoadIntraResultQT(TCom
uint32_t reconIPredStride = cu->getPic()->getPicYuvRec()->getStride();
int16_t* reconQt = m_qtTempShortYuv[qtlayer].getLumaAddr(absPartIdx);
primitives.blockcpy_ps(trSize, trSize, reconIPred, reconIPredStride, reconQt, MAX_CU_SIZE);
- assert(m_qtTempShortYuv[qtlayer].m_width == MAX_CU_SIZE);
+ X265_CHECK(m_qtTempShortYuv[qtlayer].m_width == MAX_CU_SIZE, "width is not max CU size\n");
}
void TEncSearch::xStoreIntraResultChromaQT(TComDataCU* cu, uint32_t trDepth, uint32_t absPartIdx, uint32_t stateU0V1Both2, const bool splitIntoSubTUs)
@@ -1025,7 +1025,7 @@ void TEncSearch::xStoreIntraResultChroma
bool bChromaSame = false;
if (trSizeLog2 == 2 && !(chFmt == CHROMA_444))
More information about the x265-commits
mailing list