Ticket #91: DQP_and_REUSE_DT_fix.patch

File DQP_and_REUSE_DT_fix.patch, 9.6 KB (added by adamjw, 6 years ago)

This patch now allows the fixed version of REUSE_CU to work for intra slices with dual tree.

  • source/Lib/CommonLib/ContextModelling.h

     source/Lib/CommonLib/ContextModelling.h | 13 +++++++++++--
     source/Lib/CommonLib/TypeDef.h          |  3 +++
     source/Lib/CommonLib/UnitTools.cpp      |  2 ++
     source/Lib/CommonLib/UnitTools.h        |  2 ++
     source/Lib/DecoderLib/CABACReader.cpp   | 11 +++++++++++
     source/Lib/EncoderLib/CABACWriter.cpp   | 11 +++++++++++
     source/Lib/EncoderLib/EncCu.cpp         | 15 +++++++++++++++
     source/Lib/EncoderLib/EncModeCtrl.cpp   | 19 +++++++++++++++++--
     source/Lib/EncoderLib/EncModeCtrl.h     |  2 +-
     9 files changed, 73 insertions(+), 5 deletions(-)
    
    diff --git a/source/Lib/CommonLib/ContextModelling.h b/source/Lib/CommonLib/ContextModelling.h
    index fbb48aa..8e88f06 100644
    a b class CUCtx 
    536536{
    537537public:
    538538  CUCtx()              : isDQPCoded(false), isChromaQpAdjCoded(false),
     539#if FIX_ISSUE_91_DQP
     540                         isQPPredicted(false),
     541#endif
    539542                         numNonZeroCoeffNonTs(0) {}
    540543  CUCtx(int _qp)       : isDQPCoded(false), isChromaQpAdjCoded(false),
     544#if FIX_ISSUE_91_DQP
     545                         isQPPredicted(false),
     546#endif
    541547                         numNonZeroCoeffNonTs(0), qp(_qp) {}
    542548  ~CUCtx() {}
    543549public:
    544550  bool      isDQPCoded;
    545551  bool      isChromaQpAdjCoded;
    546   uint32_t      numNonZeroCoeffNonTs;
    547   int8_t     qp;                   // used as a previous(last) QP and for QP prediction
     552#if FIX_ISSUE_91_DQP
     553  bool      isQPPredicted;
     554#endif
     555  uint32_t  numNonZeroCoeffNonTs;
     556  int8_t    qp;                   // used as a previous(last) QP and for QP prediction
    548557};
    549558
    550559class MergeCtx
  • source/Lib/CommonLib/TypeDef.h

    diff --git a/source/Lib/CommonLib/TypeDef.h b/source/Lib/CommonLib/TypeDef.h
    index 9693ab6..23d9024 100644
    a b  
    5454#define BMS_TOOLS                                         1 // Inclusion of BMS only tools (which include JEM tools) into compiled executable
    5555#endif
    5656
     57#define FIX_ISSUE_91_DQP                                  1
     58#define FIX_NO_REUSE_FOR_DT                               1
     59
    5760#if BMS_TOOLS
    5861#define JEM_TOOLS                                         1
    5962#define JVET_K0076_CPR                                    1 // current picture referencing or intra block copy mode
  • source/Lib/CommonLib/UnitTools.cpp

    diff --git a/source/Lib/CommonLib/UnitTools.cpp b/source/Lib/CommonLib/UnitTools.cpp
    index 2726185..c984ee1 100644
    a b int CU::predictQP( const CodingUnit& cu, const int prevQP ) 
    388388  return ( a + b + 1 ) >> 1;
    389389}
    390390
     391#if !FIX_ISSUE_91_DQP
    391392bool CU::isQGStart( const CodingUnit& cu )
    392393{
    393394  const SPS &sps = *cu.cs->sps;
    bool CU::isQGStart( const CodingUnit& cu ) 
    397398         ( cu.blocks[cu.chType].y % ( ( 1 << ( g_aucLog2[sps.getMaxCUHeight()] - pps.getMaxCuDQPDepth() ) ) >> getChannelTypeScaleY( cu.chType, cu.chromaFormat ) ) ) == 0;
    398399}
    399400
     401#endif
    400402uint32_t CU::getNumPUs( const CodingUnit& cu )
    401403{
    402404  uint32_t cnt = 0;
  • source/Lib/CommonLib/UnitTools.h

    diff --git a/source/Lib/CommonLib/UnitTools.h b/source/Lib/CommonLib/UnitTools.h
    index 31a007e..91ce937 100644
    a b namespace CU 
    8787  uint32_t getCtuAddr                     (const CodingUnit &cu);
    8888
    8989  int  predictQP                      (const CodingUnit& cu, const int prevQP );
     90#if !FIX_ISSUE_91_DQP
    9091  bool isQGStart                      (const CodingUnit& cu); // check if start of a Quantization Group
     92#endif
    9193
    9294  uint32_t getNumPUs                      (const CodingUnit& cu);
    9395  void addPUs                         (      CodingUnit& cu);
  • source/Lib/DecoderLib/CABACReader.cpp

    diff --git a/source/Lib/DecoderLib/CABACReader.cpp b/source/Lib/DecoderLib/CABACReader.cpp
    index 7b32fb3..b9bed4a 100644
    a b bool CABACReader::coding_tree( CodingStructure& cs, Partitioner& partitioner, CU 
    964964  if( pps.getUseDQP() && partitioner.currDepth <= pps.getMaxCuDQPDepth() )
    965965  {
    966966    cuCtx.isDQPCoded          = false;
     967#if FIX_ISSUE_91_DQP
     968    cuCtx.isQPPredicted       = false;
     969#endif
    967970  }
    968971  if( cs.slice->getUseChromaQpAdj() && partitioner.currDepth <= pps.getPpsRangeExtension().getDiffCuChromaQpOffsetDepth() )
    969972  {
    bool CABACReader::coding_tree( CodingStructure& cs, Partitioner& partitioner, CU 
    11431146#endif
    11441147
    11451148  // Predict QP on start of quantization group
     1149#if FIX_ISSUE_91_DQP
     1150  if( pps.getUseDQP() && !cuCtx.isDQPCoded && !cuCtx.isQPPredicted )
     1151  {
     1152    cuCtx.qp = CU::predictQP( cu, cuCtx.qp );
     1153    cuCtx.isQPPredicted = true;
     1154  }
     1155#else
    11461156  if( pps.getUseDQP() && !cuCtx.isDQPCoded && CU::isQGStart( cu ) )
    11471157  {
    11481158    cuCtx.qp = CU::predictQP( cu, cuCtx.qp );
    11491159  }
     1160#endif
    11501161
    11511162  cu.qp          = cuCtx.qp;        //NOTE: CU QP can be changed by deltaQP signaling at TU level
    11521163  cu.chromaQpAdj = cs.chromaQpAdj;  //NOTE: CU chroma QP adjustment can be changed by adjustment signaling at TU level
  • source/Lib/EncoderLib/CABACWriter.cpp

    diff --git a/source/Lib/EncoderLib/CABACWriter.cpp b/source/Lib/EncoderLib/CABACWriter.cpp
    index a4d9a7a..1dca54b 100644
    a b void CABACWriter::coding_tree( const CodingStructure& cs, Partitioner& partition 
    10131013  if( pps.getUseDQP() && partitioner.currDepth <= pps.getMaxCuDQPDepth() )
    10141014  {
    10151015    cuCtx.isDQPCoded          = false;
     1016#if FIX_ISSUE_91_DQP
     1017    cuCtx.isQPPredicted       = false;
     1018#endif
    10161019  }
    10171020  if( cs.slice->getUseChromaQpAdj() && partitioner.currDepth <= pps.getPpsRangeExtension().getDiffCuChromaQpOffsetDepth() )
    10181021  {
    void CABACWriter::coding_tree( const CodingStructure& cs, Partitioner& partition 
    11591162  }
    11601163
    11611164  // Predict QP on start of quantization group
     1165#if FIX_ISSUE_91_DQP
     1166  if( pps.getUseDQP() && !cuCtx.isDQPCoded && !cuCtx.isQPPredicted )
     1167  {
     1168    cuCtx.qp = CU::predictQP( cu, cuCtx.qp );
     1169    cuCtx.isQPPredicted = true;
     1170  }
     1171#else
    11621172  if( pps.getUseDQP() && !cuCtx.isDQPCoded && CU::isQGStart( cu ) )
    11631173  {
    11641174    cuCtx.qp = CU::predictQP( cu, cuCtx.qp );
    11651175  }
     1176#endif
    11661177
    11671178#if JVET_K0346
    11681179  if (!cs.slice->isIntra() && m_EncCu)
  • source/Lib/EncoderLib/EncCu.cpp

    diff --git a/source/Lib/EncoderLib/EncCu.cpp b/source/Lib/EncoderLib/EncCu.cpp
    index 51a115e..b379155 100644
    a b void EncCu::xCheckRDCostAffineMerge2Nx2N( CodingStructure *&tempCS, CodingStruct 
    20492049  m_pcInterSearch->subBlockOBMC      ( cu );
    20502050#endif
    20512051
     2052#if FIX_ISSUE_91_DQP
     2053  auto *oldTempCS = tempCS;
     2054#endif
     2055
    20522056  xEncodeInterResidual(tempCS, bestCS, partitioner, encTestMode, 0
    20532057#if JEM_TOOLS || JVET_K0357_AMVR
    20542058    , NULL
    void EncCu::xCheckRDCostAffineMerge2Nx2N( CodingStructure *&tempCS, CodingStruct 
    20602064
    20612065  if( ! (encTestMode.lossless || hasNoResidual) )
    20622066  {
     2067#if FIX_ISSUE_91_DQP
     2068    if( tempCS != oldTempCS )
     2069    {
     2070#endif
    20632071    tempCS->initStructData( encTestMode.qp, encTestMode.lossless );
    20642072    tempCS->copyStructure( *bestCS, partitioner.chType );
    20652073    tempCS->getPredBuf().copyFrom( bestCS->getPredBuf() );
     2074#if FIX_ISSUE_91_DQP
     2075    }
     2076    else
     2077    {
     2078      tempCS->clearTUs();
     2079    }
     2080#endif
    20662081
    20672082    xEncodeInterResidual(tempCS, bestCS, partitioner, encTestMode, 1
    20682083#if JEM_TOOLS || JVET_K0357_AMVR
  • source/Lib/EncoderLib/EncModeCtrl.cpp

    diff --git a/source/Lib/EncoderLib/EncModeCtrl.cpp b/source/Lib/EncoderLib/EncModeCtrl.cpp
    index a593e4e..44273df 100644
    a b bool BestEncInfoCache::isValid( const CodingStructure& cs, const Partitioner& pa 
    766766
    767767  BestEncodingInfo& encInfo = *m_bestEncInfo[idx1][idx2][idx3][idx4];
    768768
    769   if( cs.picture->poc != encInfo.poc || CS::getArea( cs, cs.area, partitioner.chType ) != encInfo.cu || !isTheSameNbHood( encInfo.cu, partitioner )
     769#if FIX_NO_REUSE_FOR_DT
     770  if( cs.picture->poc != encInfo.poc || CS::getArea( cs, cs.area, partitioner.chType ) != encInfo.cu || !isTheSameNbHood( encInfo.cu, partitioner )
     771#else
     772  if( cs.picture->poc != encInfo.poc || CS::getArea( cs, cs.area, partitioner.chType ) != CS::getArea( cs, encInfo.cu, partitioner.chType ) || !isTheSameNbHood( encInfo.cu, partitioner )
     773#endif
     774#if FIX_ISSUE_91_DQP
     775    || partitioner.currDepth <= cs.pps->getMaxCuDQPDepth() || cs.currQP[partitioner.chType] != encInfo.cu.qp
     776#endif
    770777#if JVET_K0076_CPR
    771778    || encInfo.cu.ibc
    772779#endif
    bool BestEncInfoCache::setCsFrom( CodingStructure& cs, EncTestMode& testMode, co 
    787794
    788795  BestEncodingInfo& encInfo = *m_bestEncInfo[idx1][idx2][idx3][idx4];
    789796
    790   if( cs.picture->poc != encInfo.poc || CS::getArea( cs, cs.area, partitioner.chType ) != encInfo.cu || !isTheSameNbHood( encInfo.cu, partitioner ) )
     797#if FIX_NO_REUSE_FOR_DT
     798  if( cs.picture->poc != encInfo.poc || CS::getArea( cs, cs.area, partitioner.chType ) != encInfo.cu || !isTheSameNbHood( encInfo.cu, partitioner )
     799#else
     800  if( cs.picture->poc != encInfo.poc || CS::getArea( cs, cs.area, partitioner.chType ) != CS::getArea( cs, encInfo.cu, partitioner.chType ) || !isTheSameNbHood( encInfo.cu, partitioner )
     801#endif
     802#if FIX_ISSUE_91_DQP
     803    || partitioner.currDepth <= cs.pps->getMaxCuDQPDepth() || encInfo.cu.qp != cs.currQP[partitioner.chType]
     804#endif
     805    )
    791806  {
    792807    return false;
    793808  }
  • source/Lib/EncoderLib/EncModeCtrl.h

    diff --git a/source/Lib/EncoderLib/EncModeCtrl.h b/source/Lib/EncoderLib/EncModeCtrl.h
    index 4b95630..6449314 100644
    a b protected: 
    280280  int                   m_lumaQPOffset;
    281281#endif
    282282  bool                  m_fastDeltaQP;
    283   static_vector<ComprCUCtx, ( MAX_CU_DEPTH << 2 )> m_ComprCUCtxList;
     283  std::vector<ComprCUCtx> m_ComprCUCtxList;
    284284#if ENABLE_SPLIT_PARALLELISM
    285285  int                   m_runNextInParallel;
    286286#endif