diff --git a/source/Lib/CommonLib/DepQuant.cpp b/source/Lib/CommonLib/DepQuant.cpp index 3ee9c10cf289bfbd8644ae70b7161282269896dd..17b2a2911b5a9708b182249111b5100a7b2ecd7d 100644 --- a/source/Lib/CommonLib/DepQuant.cpp +++ b/source/Lib/CommonLib/DepQuant.cpp @@ -1855,39 +1855,7 @@ namespace DQIntern { CHECKD( tu.cs->sps->getSpsRangeExtension().getExtendedPrecisionProcessingFlag(), "ext precision is not supported" ); #if SIGN_PREDICTION - CoeffBuf signBuff = tu.getCoeffSigns(compID); -#if JVET_Y0141_SIGN_PRED_IMPROVE - IdxBuf signScanIdxBuff = tu.getCoeffSignsScanIdx( compID ); -#endif - uint32_t uiWidth = tu.blocks[compID].width; - uint32_t uiHeight = tu.blocks[compID].height; - - if ( tu.cs->sps->getNumPredSigns() > 0 && uiHeight >= 4 && uiWidth >= 4) - { - TCoeff *coeff = signBuff.buf; -#if JVET_Y0141_SIGN_PRED_IMPROVE - uint32_t spArea = tu.cs->sps->getSignPredArea(); - unsigned int *coeffIdx = signScanIdxBuff.buf; - uint32_t spWidth = std::min(uiWidth, spArea); - uint32_t spHeight = std::min(uiHeight, spArea); - CHECK(TrQuant::SIGN_PRED_BYPASS, "SIGN_PRED_BYPASS should be equal to 0"); - for (uint32_t y = 0; y < spHeight; y++) -#else - for (uint32_t y = 0; y < SIGN_PRED_FREQ_RANGE; y++) -#endif - { -#if JVET_Y0141_SIGN_PRED_IMPROVE - memset(coeff, 0, sizeof(TCoeff) * spWidth); - memset( coeffIdx, 0, sizeof( unsigned int ) * spWidth ); -#else - coeff[0] = TrQuant::SIGN_PRED_BYPASS; - coeff[1] = TrQuant::SIGN_PRED_BYPASS; - coeff[2] = TrQuant::SIGN_PRED_BYPASS; - coeff[3] = TrQuant::SIGN_PRED_BYPASS; -#endif - coeff += signBuff.stride; - } - } + tu.initSignBuffers( compID ); #endif //===== reset / pre-init ===== diff --git a/source/Lib/CommonLib/Unit.cpp b/source/Lib/CommonLib/Unit.cpp index cb7507a43d697c4a729cf97aff2b3a58a7418832..2d63d65fcf505f106c96f9dc6072f5e4d1b2be84 100644 --- a/source/Lib/CommonLib/Unit.cpp +++ b/source/Lib/CommonLib/Unit.cpp @@ -1422,3 +1422,42 @@ bool TransformUnit::checkLFNSTApplied(ComponentID compID) #endif int TransformUnit::getChromaAdj() const { return m_chromaResScaleInv; } void TransformUnit::setChromaAdj(int i) { m_chromaResScaleInv = i; } + +#if SIGN_PREDICTION +void TransformUnit::initSignBuffers( const ComponentID compID ) +{ + uint32_t uiWidth = blocks[compID].width; + uint32_t uiHeight = blocks[compID].height; + + if( cs->sps->getNumPredSigns() > 0 && uiHeight >= 4 && uiWidth >= 4 ) + { + CoeffBuf signBuff = getCoeffSigns( compID ); + TCoeff *coeff = signBuff.buf; +#if JVET_Y0141_SIGN_PRED_IMPROVE + IdxBuf signScanIdxBuff = getCoeffSignsScanIdx( compID ); + uint32_t spArea = std::max( cs->sps->getSignPredArea(), SIGN_PRED_FREQ_RANGE ); + unsigned int *coeffIdx = signScanIdxBuff.buf; + uint32_t spWidth = std::min( uiWidth, spArea ); + uint32_t spHeight = std::min( uiHeight, spArea ); + CHECK( TrQuant::SIGN_PRED_BYPASS, "SIGN_PRED_BYPASS should be equal to 0" ); + + for( uint32_t y = 0; y < spHeight; y++ ) +#else + for( uint32_t y = 0; y < SIGN_PRED_FREQ_RANGE; y++ ) +#endif + { +#if JVET_Y0141_SIGN_PRED_IMPROVE + memset( coeff, 0, sizeof( TCoeff ) * spWidth ); + memset( coeffIdx, 0, sizeof( unsigned int ) * spWidth ); + coeffIdx += signScanIdxBuff.stride; +#else + coeff[0] = TrQuant::SIGN_PRED_BYPASS; + coeff[1] = TrQuant::SIGN_PRED_BYPASS; + coeff[2] = TrQuant::SIGN_PRED_BYPASS; + coeff[3] = TrQuant::SIGN_PRED_BYPASS; +#endif + coeff += signBuff.stride; + } + } +} +#endif \ No newline at end of file diff --git a/source/Lib/CommonLib/Unit.h b/source/Lib/CommonLib/Unit.h index 66f9521870f16c614e31a4d5a66d11962168cd0b..e3ba3f5c7b1765e7dc772728fd4ed9a3fe458f50 100644 --- a/source/Lib/CommonLib/Unit.h +++ b/source/Lib/CommonLib/Unit.h @@ -685,6 +685,10 @@ struct TransformUnit : public UnitArea bool cacheUsed; #endif +#if SIGN_PREDICTION + void initSignBuffers( const ComponentID compID ); +#endif + private: TCoeff *m_coeffs[ MAX_NUM_TBLOCKS ]; #if SIGN_PREDICTION diff --git a/source/Lib/DecoderLib/CABACReader.cpp b/source/Lib/DecoderLib/CABACReader.cpp index 6e830aeb79154d94af5eaffa6271df1f45fd564f..46b41e08f9c39643c72ced188146cdc09e17d5cf 100644 --- a/source/Lib/DecoderLib/CABACReader.cpp +++ b/source/Lib/DecoderLib/CABACReader.cpp @@ -5708,34 +5708,7 @@ void CABACReader::residual_coding( TransformUnit& tu, ComponentID compID, CUCtx& #if SIGN_PREDICTION CoeffBuf signBuff = tu.getCoeffSigns(compID); - uint32_t uiWidth = tu.blocks[compID].width; - uint32_t uiHeight = tu.blocks[compID].height; - - //if (sps.getNumPredSigns() > 0 && uiHeight >= 4 && uiWidth >= 4) - if ( tu.cs->sps->getNumPredSigns() > 0 && uiHeight >= 4 && uiWidth >= 4) - { - TCoeff *signs = signBuff.buf; -#if JVET_Y0141_SIGN_PRED_IMPROVE - uint32_t spArea = tu.cs->sps->getSignPredArea(); - uint32_t spWidth = std::min(uiWidth, spArea); - uint32_t spHeight = std::min(uiHeight, spArea); - CHECK(TrQuant::SIGN_PRED_BYPASS, "SIGN_PRED_BYPASS should be equal to 0"); - for (uint32_t y = 0; y < spHeight; y++) -#else - for (uint32_t y = 0; y < SIGN_PRED_FREQ_RANGE; y++) -#endif - { -#if JVET_Y0141_SIGN_PRED_IMPROVE - memset(signs, 0, sizeof(TCoeff) * spWidth); -#else - signs[0] = TrQuant::SIGN_PRED_BYPASS; - signs[1] = TrQuant::SIGN_PRED_BYPASS; - signs[2] = TrQuant::SIGN_PRED_BYPASS; - signs[3] = TrQuant::SIGN_PRED_BYPASS; -#endif - signs += signBuff.stride; - } - } + tu.initSignBuffers( compID ); #endif // parse subblocks