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 |
536 | 536 | { |
537 | 537 | public: |
538 | 538 | CUCtx() : isDQPCoded(false), isChromaQpAdjCoded(false), |
| 539 | #if FIX_ISSUE_91_DQP |
| 540 | isQPPredicted(false), |
| 541 | #endif |
539 | 542 | numNonZeroCoeffNonTs(0) {} |
540 | 543 | CUCtx(int _qp) : isDQPCoded(false), isChromaQpAdjCoded(false), |
| 544 | #if FIX_ISSUE_91_DQP |
| 545 | isQPPredicted(false), |
| 546 | #endif |
541 | 547 | numNonZeroCoeffNonTs(0), qp(_qp) {} |
542 | 548 | ~CUCtx() {} |
543 | 549 | public: |
544 | 550 | bool isDQPCoded; |
545 | 551 | 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 |
548 | 557 | }; |
549 | 558 | |
550 | 559 | class MergeCtx |
diff --git a/source/Lib/CommonLib/TypeDef.h b/source/Lib/CommonLib/TypeDef.h
index 9693ab6..23d9024 100644
a
|
b
|
|
54 | 54 | #define BMS_TOOLS 1 // Inclusion of BMS only tools (which include JEM tools) into compiled executable |
55 | 55 | #endif |
56 | 56 | |
| 57 | #define FIX_ISSUE_91_DQP 1 |
| 58 | #define FIX_NO_REUSE_FOR_DT 1 |
| 59 | |
57 | 60 | #if BMS_TOOLS |
58 | 61 | #define JEM_TOOLS 1 |
59 | 62 | #define JVET_K0076_CPR 1 // current picture referencing or intra block copy mode |
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 ) |
388 | 388 | return ( a + b + 1 ) >> 1; |
389 | 389 | } |
390 | 390 | |
| 391 | #if !FIX_ISSUE_91_DQP |
391 | 392 | bool CU::isQGStart( const CodingUnit& cu ) |
392 | 393 | { |
393 | 394 | const SPS &sps = *cu.cs->sps; |
… |
… |
bool CU::isQGStart( const CodingUnit& cu ) |
397 | 398 | ( cu.blocks[cu.chType].y % ( ( 1 << ( g_aucLog2[sps.getMaxCUHeight()] - pps.getMaxCuDQPDepth() ) ) >> getChannelTypeScaleY( cu.chType, cu.chromaFormat ) ) ) == 0; |
398 | 399 | } |
399 | 400 | |
| 401 | #endif |
400 | 402 | uint32_t CU::getNumPUs( const CodingUnit& cu ) |
401 | 403 | { |
402 | 404 | uint32_t cnt = 0; |
diff --git a/source/Lib/CommonLib/UnitTools.h b/source/Lib/CommonLib/UnitTools.h
index 31a007e..91ce937 100644
a
|
b
|
namespace CU |
87 | 87 | uint32_t getCtuAddr (const CodingUnit &cu); |
88 | 88 | |
89 | 89 | int predictQP (const CodingUnit& cu, const int prevQP ); |
| 90 | #if !FIX_ISSUE_91_DQP |
90 | 91 | bool isQGStart (const CodingUnit& cu); // check if start of a Quantization Group |
| 92 | #endif |
91 | 93 | |
92 | 94 | uint32_t getNumPUs (const CodingUnit& cu); |
93 | 95 | void addPUs ( CodingUnit& cu); |
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 |
964 | 964 | if( pps.getUseDQP() && partitioner.currDepth <= pps.getMaxCuDQPDepth() ) |
965 | 965 | { |
966 | 966 | cuCtx.isDQPCoded = false; |
| 967 | #if FIX_ISSUE_91_DQP |
| 968 | cuCtx.isQPPredicted = false; |
| 969 | #endif |
967 | 970 | } |
968 | 971 | if( cs.slice->getUseChromaQpAdj() && partitioner.currDepth <= pps.getPpsRangeExtension().getDiffCuChromaQpOffsetDepth() ) |
969 | 972 | { |
… |
… |
bool CABACReader::coding_tree( CodingStructure& cs, Partitioner& partitioner, CU |
1143 | 1146 | #endif |
1144 | 1147 | |
1145 | 1148 | // 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 |
1146 | 1156 | if( pps.getUseDQP() && !cuCtx.isDQPCoded && CU::isQGStart( cu ) ) |
1147 | 1157 | { |
1148 | 1158 | cuCtx.qp = CU::predictQP( cu, cuCtx.qp ); |
1149 | 1159 | } |
| 1160 | #endif |
1150 | 1161 | |
1151 | 1162 | cu.qp = cuCtx.qp; //NOTE: CU QP can be changed by deltaQP signaling at TU level |
1152 | 1163 | cu.chromaQpAdj = cs.chromaQpAdj; //NOTE: CU chroma QP adjustment can be changed by adjustment signaling at TU level |
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 |
1013 | 1013 | if( pps.getUseDQP() && partitioner.currDepth <= pps.getMaxCuDQPDepth() ) |
1014 | 1014 | { |
1015 | 1015 | cuCtx.isDQPCoded = false; |
| 1016 | #if FIX_ISSUE_91_DQP |
| 1017 | cuCtx.isQPPredicted = false; |
| 1018 | #endif |
1016 | 1019 | } |
1017 | 1020 | if( cs.slice->getUseChromaQpAdj() && partitioner.currDepth <= pps.getPpsRangeExtension().getDiffCuChromaQpOffsetDepth() ) |
1018 | 1021 | { |
… |
… |
void CABACWriter::coding_tree( const CodingStructure& cs, Partitioner& partition |
1159 | 1162 | } |
1160 | 1163 | |
1161 | 1164 | // 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 |
1162 | 1172 | if( pps.getUseDQP() && !cuCtx.isDQPCoded && CU::isQGStart( cu ) ) |
1163 | 1173 | { |
1164 | 1174 | cuCtx.qp = CU::predictQP( cu, cuCtx.qp ); |
1165 | 1175 | } |
| 1176 | #endif |
1166 | 1177 | |
1167 | 1178 | #if JVET_K0346 |
1168 | 1179 | if (!cs.slice->isIntra() && m_EncCu) |
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 |
2049 | 2049 | m_pcInterSearch->subBlockOBMC ( cu ); |
2050 | 2050 | #endif |
2051 | 2051 | |
| 2052 | #if FIX_ISSUE_91_DQP |
| 2053 | auto *oldTempCS = tempCS; |
| 2054 | #endif |
| 2055 | |
2052 | 2056 | xEncodeInterResidual(tempCS, bestCS, partitioner, encTestMode, 0 |
2053 | 2057 | #if JEM_TOOLS || JVET_K0357_AMVR |
2054 | 2058 | , NULL |
… |
… |
void EncCu::xCheckRDCostAffineMerge2Nx2N( CodingStructure *&tempCS, CodingStruct |
2060 | 2064 | |
2061 | 2065 | if( ! (encTestMode.lossless || hasNoResidual) ) |
2062 | 2066 | { |
| 2067 | #if FIX_ISSUE_91_DQP |
| 2068 | if( tempCS != oldTempCS ) |
| 2069 | { |
| 2070 | #endif |
2063 | 2071 | tempCS->initStructData( encTestMode.qp, encTestMode.lossless ); |
2064 | 2072 | tempCS->copyStructure( *bestCS, partitioner.chType ); |
2065 | 2073 | tempCS->getPredBuf().copyFrom( bestCS->getPredBuf() ); |
| 2074 | #if FIX_ISSUE_91_DQP |
| 2075 | } |
| 2076 | else |
| 2077 | { |
| 2078 | tempCS->clearTUs(); |
| 2079 | } |
| 2080 | #endif |
2066 | 2081 | |
2067 | 2082 | xEncodeInterResidual(tempCS, bestCS, partitioner, encTestMode, 1 |
2068 | 2083 | #if JEM_TOOLS || JVET_K0357_AMVR |
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 |
766 | 766 | |
767 | 767 | BestEncodingInfo& encInfo = *m_bestEncInfo[idx1][idx2][idx3][idx4]; |
768 | 768 | |
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 |
770 | 777 | #if JVET_K0076_CPR |
771 | 778 | || encInfo.cu.ibc |
772 | 779 | #endif |
… |
… |
bool BestEncInfoCache::setCsFrom( CodingStructure& cs, EncTestMode& testMode, co |
787 | 794 | |
788 | 795 | BestEncodingInfo& encInfo = *m_bestEncInfo[idx1][idx2][idx3][idx4]; |
789 | 796 | |
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 | ) |
791 | 806 | { |
792 | 807 | return false; |
793 | 808 | } |
diff --git a/source/Lib/EncoderLib/EncModeCtrl.h b/source/Lib/EncoderLib/EncModeCtrl.h
index 4b95630..6449314 100644
a
|
b
|
protected: |
280 | 280 | int m_lumaQPOffset; |
281 | 281 | #endif |
282 | 282 | bool m_fastDeltaQP; |
283 | | static_vector<ComprCUCtx, ( MAX_CU_DEPTH << 2 )> m_ComprCUCtxList; |
| 283 | std::vector<ComprCUCtx> m_ComprCUCtxList; |
284 | 284 | #if ENABLE_SPLIT_PARALLELISM |
285 | 285 | int m_runNextInParallel; |
286 | 286 | #endif |