Commit de934118 authored by Yu-Chen Sun's avatar Yu-Chen Sun
Browse files

L0209-PCM mode with dual tree partition

parent ae9412fc
...@@ -78,6 +78,8 @@ ...@@ -78,6 +78,8 @@
#define JVET_L0265_AFF_MINIMUM4X4 1 //Affine 4x4 chroma subblock #define JVET_L0265_AFF_MINIMUM4X4 1 //Affine 4x4 chroma subblock
#define JVET_L0111 1 // Max Tx size for skip #define JVET_L0111 1 // Max Tx size for skip
#define JVET_L0553_PCM 1 // PCM mode
#define JVET_L0553_FIX_INITQP 1 #define JVET_L0553_FIX_INITQP 1
#define JVET_L0053_L0272_DM 1 // use center position of luma block to derive DM #define JVET_L0053_L0272_DM 1 // use center position of luma block to derive DM
......
...@@ -715,7 +715,11 @@ bool CABACReader::coding_unit( CodingUnit &cu, Partitioner &partitioner, CUCtx& ...@@ -715,7 +715,11 @@ bool CABACReader::coding_unit( CodingUnit &cu, Partitioner &partitioner, CUCtx&
// pcm samples // pcm samples
if( CU::isIntra(cu) && cu.partSize == SIZE_2Nx2N ) if( CU::isIntra(cu) && cu.partSize == SIZE_2Nx2N )
{ {
#if JVET_L0553_PCM
pcm_flag( cu, partitioner );
#else
pcm_flag( cu ); pcm_flag( cu );
#endif
if( cu.ipcm ) if( cu.ipcm )
{ {
TransformUnit& tu = cs.addTU( cu, partitioner.chType ); TransformUnit& tu = cs.addTU( cu, partitioner.chType );
...@@ -818,11 +822,19 @@ void CABACReader::pred_mode( CodingUnit& cu ) ...@@ -818,11 +822,19 @@ void CABACReader::pred_mode( CodingUnit& cu )
} }
} }
#if JVET_L0553_PCM
void CABACReader::pcm_flag( CodingUnit& cu, Partitioner &partitioner )
#else
void CABACReader::pcm_flag( CodingUnit& cu ) void CABACReader::pcm_flag( CodingUnit& cu )
#endif
{ {
const SPS& sps = *cu.cs->sps; const SPS& sps = *cu.cs->sps;
#if JVET_L0553_PCM
if( !sps.getUsePCM() || partitioner.currArea().lwidth() > (1 << sps.getPCMLog2MaxSize()) || partitioner.currArea().lwidth() < (1 << sps.getPCMLog2MinSize())
|| partitioner.currArea().lheight() > (1 << sps.getPCMLog2MaxSize()) || partitioner.currArea().lheight() < (1 << sps.getPCMLog2MinSize()) )
#else
if( !sps.getUsePCM() || cu.lumaSize().width > (1 << sps.getPCMLog2MaxSize()) || cu.lumaSize().width < (1 << sps.getPCMLog2MinSize()) ) if( !sps.getUsePCM() || cu.lumaSize().width > (1 << sps.getPCMLog2MaxSize()) || cu.lumaSize().width < (1 << sps.getPCMLog2MinSize()) )
#endif
{ {
cu.ipcm = false; cu.ipcm = false;
return; return;
...@@ -1888,10 +1900,24 @@ void CABACReader::pcm_samples( TransformUnit& tu ) ...@@ -1888,10 +1900,24 @@ void CABACReader::pcm_samples( TransformUnit& tu )
{ {
CHECK( !tu.cu->ipcm, "pcm mode expected" ); CHECK( !tu.cu->ipcm, "pcm mode expected" );
#if JVET_L0553_PCM
const CodingStructure *cs = tu.cs;
const ChannelType chType = tu.chType;
#endif
const SPS& sps = *tu.cu->cs->sps; const SPS& sps = *tu.cu->cs->sps;
#if !JVET_L0553_PCM
const ComponentID maxCompId = ( tu.chromaFormat == CHROMA_400 ? COMPONENT_Y : COMPONENT_Cr ); const ComponentID maxCompId = ( tu.chromaFormat == CHROMA_400 ? COMPONENT_Y : COMPONENT_Cr );
#endif
tu.depth = 0; tu.depth = 0;
#if JVET_L0553_PCM
ComponentID compStr = (CS::isDualITree(*cs) && !isLuma(chType)) ? COMPONENT_Cb: COMPONENT_Y;
ComponentID compEnd = (CS::isDualITree(*cs) && isLuma(chType)) ? COMPONENT_Y : COMPONENT_Cr;
for( ComponentID compID = compStr; compID <= compEnd; compID = ComponentID(compID+1) )
#else
for( ComponentID compID = COMPONENT_Y; compID <= maxCompId; compID = ComponentID(compID+1) ) for( ComponentID compID = COMPONENT_Y; compID <= maxCompId; compID = ComponentID(compID+1) )
#endif
{ {
PelBuf samples = tu.getPcmbuf( compID ); PelBuf samples = tu.getPcmbuf( compID );
const unsigned sampleBits = sps.getPCMBitDepth( toChannelType(compID) ); const unsigned sampleBits = sps.getPCMBitDepth( toChannelType(compID) );
......
...@@ -78,7 +78,11 @@ public: ...@@ -78,7 +78,11 @@ public:
void cu_transquant_bypass_flag ( CodingUnit& cu ); void cu_transquant_bypass_flag ( CodingUnit& cu );
void cu_skip_flag ( CodingUnit& cu ); void cu_skip_flag ( CodingUnit& cu );
void pred_mode ( CodingUnit& cu ); void pred_mode ( CodingUnit& cu );
#if JVET_L0553_PCM
void pcm_flag ( CodingUnit& cu, Partitioner& pm );
#else
void pcm_flag ( CodingUnit& cu ); void pcm_flag ( CodingUnit& cu );
#endif
void cu_pred_data ( CodingUnit& cu ); void cu_pred_data ( CodingUnit& cu );
#if JVET_L0646_GBI #if JVET_L0646_GBI
void cu_gbi_flag ( CodingUnit& cu ); void cu_gbi_flag ( CodingUnit& cu );
......
...@@ -260,9 +260,20 @@ void DecCu::xDecodePCMTexture(TransformUnit &tu, const ComponentID compID) ...@@ -260,9 +260,20 @@ void DecCu::xDecodePCMTexture(TransformUnit &tu, const ComponentID compID)
*/ */
void DecCu::xReconPCM(TransformUnit &tu) void DecCu::xReconPCM(TransformUnit &tu)
{ {
#if JVET_L0553_PCM
const CodingStructure *cs = tu.cs;
const ChannelType chType = tu.chType;
ComponentID compStr = (CS::isDualITree(*cs) && !isLuma(chType)) ? COMPONENT_Cb: COMPONENT_Y;
ComponentID compEnd = (CS::isDualITree(*cs) && isLuma(chType)) ? COMPONENT_Y : COMPONENT_Cr;
for( ComponentID compID = compStr; compID <= compEnd; compID = ComponentID(compID+1) )
#else
for (uint32_t ch = 0; ch < tu.blocks.size(); ch++) for (uint32_t ch = 0; ch < tu.blocks.size(); ch++)
#endif
{ {
#if !JVET_L0553_PCM
ComponentID compID = ComponentID(ch); ComponentID compID = ComponentID(ch);
#endif
xDecodePCMTexture(tu, compID); xDecodePCMTexture(tu, compID);
} }
......
...@@ -641,7 +641,11 @@ void CABACWriter::coding_unit( const CodingUnit& cu, Partitioner& partitioner, C ...@@ -641,7 +641,11 @@ void CABACWriter::coding_unit( const CodingUnit& cu, Partitioner& partitioner, C
// pcm samples // pcm samples
if( CU::isIntra(cu) && cu.partSize == SIZE_2Nx2N ) if( CU::isIntra(cu) && cu.partSize == SIZE_2Nx2N )
{ {
#if JVET_L0553_PCM
pcm_data( cu, partitioner );
#else
pcm_data( cu ); pcm_data( cu );
#endif
if( cu.ipcm ) if( cu.ipcm )
{ {
end_of_ctu( cu, cuCtx ); end_of_ctu( cu, cuCtx );
...@@ -691,9 +695,17 @@ void CABACWriter::pred_mode( const CodingUnit& cu ) ...@@ -691,9 +695,17 @@ void CABACWriter::pred_mode( const CodingUnit& cu )
m_BinEncoder.encodeBin( ( CU::isIntra( cu ) ), Ctx::PredMode() ); m_BinEncoder.encodeBin( ( CU::isIntra( cu ) ), Ctx::PredMode() );
} }
#if JVET_L0553_PCM
void CABACWriter::pcm_data( const CodingUnit& cu, Partitioner& partitioner )
#else
void CABACWriter::pcm_data( const CodingUnit& cu ) void CABACWriter::pcm_data( const CodingUnit& cu )
#endif
{ {
#if JVET_L0553_PCM
pcm_flag( cu, partitioner );
#else
pcm_flag( cu ); pcm_flag( cu );
#endif
if( cu.ipcm ) if( cu.ipcm )
{ {
m_BinEncoder.pcmAlignBits(); m_BinEncoder.pcmAlignBits();
...@@ -701,11 +713,19 @@ void CABACWriter::pcm_data( const CodingUnit& cu ) ...@@ -701,11 +713,19 @@ void CABACWriter::pcm_data( const CodingUnit& cu )
} }
} }
#if JVET_L0553_PCM
void CABACWriter::pcm_flag( const CodingUnit& cu, Partitioner& partitioner )
#else
void CABACWriter::pcm_flag( const CodingUnit& cu ) void CABACWriter::pcm_flag( const CodingUnit& cu )
#endif
{ {
const SPS& sps = *cu.cs->sps; const SPS& sps = *cu.cs->sps;
#if JVET_L0553_PCM
if( !sps.getUsePCM() || partitioner.currArea().lwidth() > (1 << sps.getPCMLog2MaxSize()) || partitioner.currArea().lwidth() < (1 << sps.getPCMLog2MinSize())
|| partitioner.currArea().lheight() > (1 << sps.getPCMLog2MaxSize()) || partitioner.currArea().lheight() < (1 << sps.getPCMLog2MinSize()) )
#else
if( !sps.getUsePCM() || cu.lumaSize().width > (1 << sps.getPCMLog2MaxSize()) || cu.lumaSize().width < (1 << sps.getPCMLog2MinSize()) ) if( !sps.getUsePCM() || cu.lumaSize().width > (1 << sps.getPCMLog2MaxSize()) || cu.lumaSize().width < (1 << sps.getPCMLog2MinSize()) )
#endif
{ {
return; return;
} }
...@@ -1836,8 +1856,18 @@ void CABACWriter::pcm_samples( const TransformUnit& tu ) ...@@ -1836,8 +1856,18 @@ void CABACWriter::pcm_samples( const TransformUnit& tu )
CHECK( !tu.cu->ipcm, "pcm mode expected" ); CHECK( !tu.cu->ipcm, "pcm mode expected" );
const SPS& sps = *tu.cu->cs->sps; const SPS& sps = *tu.cu->cs->sps;
#if JVET_L0553_PCM
const CodingStructure *cs = tu.cs;
const ChannelType chType = tu.chType;
ComponentID compStr = (CS::isDualITree(*cs) && !isLuma(chType)) ? COMPONENT_Cb: COMPONENT_Y;
ComponentID compEnd = (CS::isDualITree(*cs) && isLuma(chType)) ? COMPONENT_Y : COMPONENT_Cr;
for( ComponentID compID = compStr; compID <= compEnd; compID = ComponentID(compID+1) )
#else
const ComponentID maxCompId = ( tu.chromaFormat == CHROMA_400 ? COMPONENT_Y : COMPONENT_Cr ); const ComponentID maxCompId = ( tu.chromaFormat == CHROMA_400 ? COMPONENT_Y : COMPONENT_Cr );
for( ComponentID compID = COMPONENT_Y; compID <= maxCompId; compID = ComponentID(compID+1) ) for( ComponentID compID = COMPONENT_Y; compID <= maxCompId; compID = ComponentID(compID+1) )
#endif
{ {
const CPelBuf samples = tu.getPcmbuf( compID ); const CPelBuf samples = tu.getPcmbuf( compID );
const unsigned sampleBits = sps.getPCMBitDepth( toChannelType(compID) ); const unsigned sampleBits = sps.getPCMBitDepth( toChannelType(compID) );
......
...@@ -90,8 +90,13 @@ public: ...@@ -90,8 +90,13 @@ public:
void cu_transquant_bypass_flag ( const CodingUnit& cu ); void cu_transquant_bypass_flag ( const CodingUnit& cu );
void cu_skip_flag ( const CodingUnit& cu ); void cu_skip_flag ( const CodingUnit& cu );
void pred_mode ( const CodingUnit& cu ); void pred_mode ( const CodingUnit& cu );
#if JVET_L0553_PCM
void pcm_data ( const CodingUnit& cu, Partitioner& pm );
void pcm_flag ( const CodingUnit& cu, Partitioner& pm );
#else
void pcm_data ( const CodingUnit& cu ); void pcm_data ( const CodingUnit& cu );
void pcm_flag ( const CodingUnit& cu ); void pcm_flag ( const CodingUnit& cu );
#endif
void cu_pred_data ( const CodingUnit& cu ); void cu_pred_data ( const CodingUnit& cu );
#if JVET_L0646_GBI #if JVET_L0646_GBI
void cu_gbi_flag ( const CodingUnit& cu ); void cu_gbi_flag ( const CodingUnit& cu );
......
...@@ -1507,8 +1507,11 @@ void EncCu::xCheckRDCostIntra( CodingStructure *&tempCS, CodingStructure *&bestC ...@@ -1507,8 +1507,11 @@ void EncCu::xCheckRDCostIntra( CodingStructure *&tempCS, CodingStructure *&bestC
m_CABACEstimator->extend_ref_line( cu ); m_CABACEstimator->extend_ref_line( cu );
#endif #endif
m_CABACEstimator->cu_pred_data ( cu ); m_CABACEstimator->cu_pred_data ( cu );
#if JVET_L0553_PCM
m_CABACEstimator->pcm_data ( cu, partitioner );
#else
m_CABACEstimator->pcm_data ( cu ); m_CABACEstimator->pcm_data ( cu );
#endif
// Encode Coefficients // Encode Coefficients
CUCtx cuCtx; CUCtx cuCtx;
...@@ -1554,7 +1557,11 @@ void EncCu::xCheckIntraPCM(CodingStructure *&tempCS, CodingStructure *&bestCS, P ...@@ -1554,7 +1557,11 @@ void EncCu::xCheckIntraPCM(CodingStructure *&tempCS, CodingStructure *&bestCS, P
{ {
tempCS->initStructData( encTestMode.qp, encTestMode.lossless ); tempCS->initStructData( encTestMode.qp, encTestMode.lossless );
#if JVET_L0553_PCM
CodingUnit &cu = tempCS->addCU( CS::getArea( *tempCS, tempCS->area, partitioner.chType ), partitioner.chType );
#else
CodingUnit &cu = tempCS->addCU( tempCS->area, partitioner.chType ); CodingUnit &cu = tempCS->addCU( tempCS->area, partitioner.chType );
#endif
partitioner.setCUData( cu ); partitioner.setCUData( cu );
cu.slice = tempCS->slice; cu.slice = tempCS->slice;
...@@ -1572,9 +1579,15 @@ void EncCu::xCheckIntraPCM(CodingStructure *&tempCS, CodingStructure *&bestCS, P ...@@ -1572,9 +1579,15 @@ void EncCu::xCheckIntraPCM(CodingStructure *&tempCS, CodingStructure *&bestCS, P
cu.qp = encTestMode.qp; cu.qp = encTestMode.qp;
cu.ipcm = true; cu.ipcm = true;
#if JVET_L0553_PCM
tempCS->addPU( CS::getArea( *tempCS, tempCS->area, partitioner.chType ), partitioner.chType );
tempCS->addTU( CS::getArea( *tempCS, tempCS->area, partitioner.chType ), partitioner.chType );
#else
tempCS->addPU(tempCS->area, partitioner.chType); tempCS->addPU(tempCS->area, partitioner.chType);
tempCS->addTU( tempCS->area, partitioner.chType ); tempCS->addTU( tempCS->area, partitioner.chType );
#endif
m_pcIntraSearch->IPCMSearch(*tempCS, partitioner); m_pcIntraSearch->IPCMSearch(*tempCS, partitioner);
...@@ -1596,7 +1609,11 @@ void EncCu::xCheckIntraPCM(CodingStructure *&tempCS, CodingStructure *&bestCS, P ...@@ -1596,7 +1609,11 @@ void EncCu::xCheckIntraPCM(CodingStructure *&tempCS, CodingStructure *&bestCS, P
m_CABACEstimator->cu_skip_flag ( cu ); m_CABACEstimator->cu_skip_flag ( cu );
} }
m_CABACEstimator->pred_mode ( cu ); m_CABACEstimator->pred_mode ( cu );
#if JVET_L0553_PCM
m_CABACEstimator->pcm_data ( cu, partitioner );
#else
m_CABACEstimator->pcm_data ( cu ); m_CABACEstimator->pcm_data ( cu );
#endif
tempCS->fracBits = m_CABACEstimator->getEstFracBits(); tempCS->fracBits = m_CABACEstimator->getEstFracBits();
......
...@@ -1031,9 +1031,17 @@ void IntraSearch::estIntraPredChromaQT(CodingUnit &cu, Partitioner &partitioner) ...@@ -1031,9 +1031,17 @@ void IntraSearch::estIntraPredChromaQT(CodingUnit &cu, Partitioner &partitioner)
void IntraSearch::IPCMSearch(CodingStructure &cs, Partitioner& partitioner) void IntraSearch::IPCMSearch(CodingStructure &cs, Partitioner& partitioner)
{ {
#if JVET_L0553_PCM
ComponentID compStr = (CS::isDualITree(cs) && !isLuma(partitioner.chType)) ? COMPONENT_Cb: COMPONENT_Y;
ComponentID compEnd = (CS::isDualITree(cs) && isLuma(partitioner.chType)) ? COMPONENT_Y : COMPONENT_Cr;
for( ComponentID compID = compStr; compID <= compEnd; compID = ComponentID(compID+1) )
#else
for (uint32_t ch = 0; ch < getNumberValidTBlocks( *cs.pcv ); ch++) for (uint32_t ch = 0; ch < getNumberValidTBlocks( *cs.pcv ); ch++)
#endif
{ {
#if !JVET_L0553_PCM
const ComponentID compID = ComponentID(ch); const ComponentID compID = ComponentID(ch);
#endif
xEncPCM(cs, partitioner, compID); xEncPCM(cs, partitioner, compID);
} }
...@@ -1047,7 +1055,9 @@ void IntraSearch::IPCMSearch(CodingStructure &cs, Partitioner& partitioner) ...@@ -1047,7 +1055,9 @@ void IntraSearch::IPCMSearch(CodingStructure &cs, Partitioner& partitioner)
cs.cost = 0; cs.cost = 0;
cs.setDecomp(cs.area); cs.setDecomp(cs.area);
#if !JVET_L0553_PCM
cs.picture->getRecoBuf(cs.area).copyFrom(cs.getRecoBuf()); cs.picture->getRecoBuf(cs.area).copyFrom(cs.getRecoBuf());
#endif
} }
void IntraSearch::xEncPCM(CodingStructure &cs, Partitioner& partitioner, const ComponentID &compID) void IntraSearch::xEncPCM(CodingStructure &cs, Partitioner& partitioner, const ComponentID &compID)
...@@ -1111,7 +1121,11 @@ void IntraSearch::xEncIntraHeader(CodingStructure &cs, Partitioner &partitioner, ...@@ -1111,7 +1121,11 @@ void IntraSearch::xEncIntraHeader(CodingStructure &cs, Partitioner &partitioner,
#endif #endif
if( CU::isIntra(cu) && cu.partSize == SIZE_2Nx2N ) if( CU::isIntra(cu) && cu.partSize == SIZE_2Nx2N )
{ {
#if JVET_L0553_PCM
m_CABACEstimator->pcm_data( cu, partitioner );
#else
m_CABACEstimator->pcm_data( cu ); m_CABACEstimator->pcm_data( cu );
#endif
if( cu.ipcm ) if( cu.ipcm )
{ {
return; return;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment