Newer
Older

Karsten Suehring
committed
bool TU::getCbfAtDepth(const TransformUnit &tu, const ComponentID &compID, const unsigned &depth)
{
if( !tu.blocks[compID].valid() )
CHECK( tu.cbf[compID] != 0, "cbf must be 0 if the component is not available" );

Karsten Suehring
committed
return ((tu.cbf[compID] >> depth) & 1) == 1;
}
void TU::setCbfAtDepth(TransformUnit &tu, const ComponentID &compID, const unsigned &depth, const bool &cbf)
{
// first clear the CBF at the depth
tu.cbf[compID] &= ~(1 << depth);
// then set the CBF
tu.cbf[compID] |= ((cbf ? 1 : 0) << depth);
}
bool TU::isTSAllowed(const TransformUnit &tu, const ComponentID compID)
{
Shih-Ta Hsiang
committed
const int maxSize = tu.cs->sps->getLog2MaxTransformSkipBlockSize();
bool tsAllowed = tu.cs->sps->getTransformSkipEnabledFlag();
tsAllowed &= ( !tu.cu->ispMode || !isLuma(compID) );
SizeType transformSkipMaxSize = 1 << maxSize;
tsAllowed &= !(tu.cu->bdpcmMode && isLuma(compID));
tsAllowed &= !(tu.cu->bdpcmModeChroma && isChroma(compID));
tsAllowed &= tu.blocks[compID].width <= transformSkipMaxSize && tu.blocks[compID].height <= transformSkipMaxSize;
tsAllowed &= !tu.cu->sbtInfo;

Karsten Suehring
committed
int TU::getICTMode( const TransformUnit& tu, int jointCbCr )
{
if( jointCbCr < 0 )
{
jointCbCr = tu.jointCbCr;
}
return g_ictModes[ tu.cs->picHeader->getJointCbCrSignFlag() ][ jointCbCr ];

Karsten Suehring
committed
#if !REMOVE_PPS_REXT

Karsten Suehring
committed
bool TU::hasCrossCompPredInfo( const TransformUnit &tu, const ComponentID &compID )
{
return (isChroma(compID) && tu.cs->pps->getPpsRangeExtension().getCrossComponentPredictionEnabledFlag() && TU::getCbf(tu, COMPONENT_Y) &&
(!CU::isIntra(*tu.cu) || PU::isChromaIntraModeCrossCheckMode(*tu.cs->getPU(tu.blocks[compID].pos(), toChannelType(compID)))));

Karsten Suehring
committed
}

Karsten Suehring
committed
#endif
bool TU::needsSqrt2Scale( const TransformUnit &tu, const ComponentID &compID )
{
const Size &size=tu.blocks[compID];
const bool isTransformSkip = (tu.mtsIdx[compID] == MTS_SKIP);
return (!isTransformSkip) && (((floorLog2(size.width) + floorLog2(size.height)) & 1) == 1);

Karsten Suehring
committed
bool TU::needsBlockSizeTrafoScale( const TransformUnit &tu, const ComponentID &compID )
{
return needsSqrt2Scale( tu, compID ) || isNonLog2BlockSize( tu.blocks[compID] );
}

Karsten Suehring
committed
TransformUnit* TU::getPrevTU( const TransformUnit &tu, const ComponentID compID )
{
TransformUnit* prevTU = tu.prev;

Karsten Suehring
committed
if( prevTU != nullptr && ( prevTU->cu != tu.cu || !prevTU->blocks[compID].valid() ) )
{
prevTU = nullptr;
}
return prevTU;
}
bool TU::getPrevTuCbfAtDepth( const TransformUnit ¤tTu, const ComponentID compID, const int trDepth )
{
const TransformUnit* prevTU = getPrevTU( currentTu, compID );
return ( prevTU != nullptr ) ? TU::getCbfAtDepth( *prevTU, compID, trDepth ) : false;
}

Karsten Suehring
committed
// other tools
uint32_t getCtuAddr( const Position& pos, const PreCalcValues& pcv )
{
return ( pos.x >> pcv.maxCUWidthLog2 ) + ( pos.y >> pcv.maxCUHeightLog2 ) * pcv.widthInCtus;
}
int getNumModesMip(const Size& block)
{
switch( getMipSizeId(block) )
{
case 0: return 16;
case 1: return 8;
case 2: return 6;
default: THROW( "Invalid mipSizeId" );
}
int getMipSizeId(const Size& block)
{
if( block.width == 4 && block.height == 4 )
{
return 0;
}
Philipp Merkle
committed
else if( block.width == 4 || block.height == 4 || (block.width == 8 && block.height == 8) )
{
return 1;
}
else
{
return 2;
}
}
bool allowLfnstWithMip(const Size& block)
{
if (block.width >= 16 && block.height >= 16)
{
return true;
}
return false;
}

Karsten Suehring
committed