From 0f15cb982f58a530373738fc67f61e37911d2046 Mon Sep 17 00:00:00 2001
From: zhangkai <zhangkai.video@bytedance.com>
Date: Tue, 28 Jan 2020 11:20:52 -0800
Subject: [PATCH] Fix issues raised by the SW coordinators

---
 cfg/encoder_randomaccess_vtm.cfg    |  6 +++++-
 cfg/per-sequence/BasketballPass.cfg |  6 +++---
 doc/software-manual.tex             | 10 ++--------
 source/App/EncoderApp/EncAppCfg.h   |  2 +-
 source/App/Parcat/parcat.cpp        | 10 ++++------
 source/Lib/DecoderLib/DecLib.cpp    | 10 ++++++++--
 source/Lib/EncoderLib/AnnexBwrite.h |  8 ++++----
 source/Lib/EncoderLib/EncCfg.h      |  2 +-
 source/Lib/EncoderLib/EncGOP.cpp    | 28 ++++++++++++++++------------
 source/Lib/EncoderLib/EncLib.h      |  2 +-
 10 files changed, 45 insertions(+), 39 deletions(-)

diff --git a/cfg/encoder_randomaccess_vtm.cfg b/cfg/encoder_randomaccess_vtm.cfg
index 7676e21f1..b11046f7a 100644
--- a/cfg/encoder_randomaccess_vtm.cfg
+++ b/cfg/encoder_randomaccess_vtm.cfg
@@ -45,7 +45,7 @@ FEN                           : 1           # Fast encoder decision
 FDM                           : 1           # Fast Decision for Merge RD cost
 
 #======== Quantization =============
-QP                            : 42          # Quantization parameter(0-51)
+QP                            : 32          # Quantization parameter(0-51)
 MaxDeltaQP                    : 0           # CU-based multi-QP optimization
 MaxCuDQPSubdiv                : 0           # Maximum subdiv for CU luma Qp adjustment
 DeltaQpRD                     : 0           # Slice-based multi-QP optimization
@@ -96,8 +96,12 @@ RCForceIntraQP                      : 0                # Rate control: force int
 SEIDecodedPictureHash               : 0
 =======
 LoopFilterTcOffset_div2             : 0
+<<<<<<< HEAD
 SEIDecodedPictureHash               : 1
 >>>>>>> f765570c... Commit Q0117. HLS clenup: DPS is changed to DCI
+=======
+SEIDecodedPictureHash               : 0
+>>>>>>> a03006cc... Fix issues raised by the SW coordinators
 CbQpOffset                          : 0
 CrQpOffset                          : 0
 SameCQPTablesForAllChroma           : 1
diff --git a/cfg/per-sequence/BasketballPass.cfg b/cfg/per-sequence/BasketballPass.cfg
index 1f8fa9011..c6b756c94 100644
--- a/cfg/per-sequence/BasketballPass.cfg
+++ b/cfg/per-sequence/BasketballPass.cfg
@@ -1,11 +1,11 @@
 #======== File I/O ===============
-InputFile                     : D:\sequences/BasketballPass_416x240_50.yuv
+InputFile                     : BasketballPass_416x240_50.yuv
 InputBitDepth                 : 8           # Input bitdepth
 InputChromaFormat             : 420         # Ratio of luminance to chrominance samples
 FrameRate                     : 50          # Frame Rate per second
 FrameSkip                     : 0           # Number of frames to be skipped in input
 SourceWidth                   : 416         # Input  frame width
 SourceHeight                  : 240         # Input  frame height
-FramesToBeEncoded             : 1         # Number of frames to be coded
-EnableDecodingCapabilityInformation : 1
+FramesToBeEncoded             : 500         # Number of frames to be coded
+
 Level                         : 2.1
diff --git a/doc/software-manual.tex b/doc/software-manual.tex
index f7f7a8236..956db0542 100644
--- a/doc/software-manual.tex
+++ b/doc/software-manual.tex
@@ -992,10 +992,10 @@ NB: There is currently only limited validation that the encoder configuration co
 Indicates interoperability metadata registered as specified by X Recommendation ITU-T T.35.
 \\
 
-\Option{EnableDecodingParameterSet} &
+\Option{EnableDecodingCapabilityInformation} &
 %\ShortOption{\None} &
 \Default{false} &
-Enables writing of a decoding parameter set. If disabled, no parameter set will be written and the specical reserved ID zero will be used in the SPS indicating no constraint.
+Enables writing of a decoding capability information (DCI). If disabled, no DCI will be written.
 \\
 
 \Option{MaxBitDepthConstraint} &
@@ -1473,12 +1473,6 @@ $}
 \end{displaymath}
 \\
 
-\Option{Log2ParallelMergeLevel} &
-%\ShortOption{\None} &
-\Default{2} &
-Defines the SPS-derived Log2ParallelMergeLevel variable.
-\\
-
 \Option{MaxNumMergeCand} &
 %\ShortOption{\None} &
 \Default{5} &
diff --git a/source/App/EncoderApp/EncAppCfg.h b/source/App/EncoderApp/EncAppCfg.h
index 525389d6c..e90d1a48f 100644
--- a/source/App/EncoderApp/EncAppCfg.h
+++ b/source/App/EncoderApp/EncAppCfg.h
@@ -698,7 +698,7 @@ protected:
 #endif
 
 #if JVET_Q0117_PARAMETER_SETS_CLEANUP
-  bool      m_DCIEnabled;                                     ///< enable DCI
+  bool      m_DCIEnabled;                                     ///< enable Decoding Capability Information (DCI)
 #else
   bool      m_decodingParameterSetEnabled;                   ///< enable decoding parameter set
 #endif
diff --git a/source/App/Parcat/parcat.cpp b/source/App/Parcat/parcat.cpp
index 87f8a6e62..964c97e6b 100644
--- a/source/App/Parcat/parcat.cpp
+++ b/source/App/Parcat/parcat.cpp
@@ -392,15 +392,13 @@ std::vector<uint8_t> filter_segment(const std::vector<uint8_t> & v, int idx, int
       skip_next_sei = true;
       idr_found = true;
     }
-
-    if( ( idx > 1 && ( nalu_type == NAL_UNIT_CODED_SLICE_IDR_W_RADL || nalu_type == NAL_UNIT_CODED_SLICE_IDR_N_LP ) ) || ( ( idx > 1 && !idr_found ) 
 #if JVET_Q0117_PARAMETER_SETS_CLEANUP
-      && ( nalu_type == NAL_UNIT_DCI
+    if ((idx > 1 && (nalu_type == NAL_UNIT_CODED_SLICE_IDR_W_RADL || nalu_type == NAL_UNIT_CODED_SLICE_IDR_N_LP)) || ((idx > 1 && !idr_found) && (nalu_type == NAL_UNIT_DCI || nalu_type == NAL_UNIT_VPS || nalu_type == NAL_UNIT_SPS || nalu_type == NAL_UNIT_PPS || nalu_type == NAL_UNIT_PREFIX_APS || nalu_type == NAL_UNIT_SUFFIX_APS || nalu_type == NAL_UNIT_PH || nalu_type == NAL_UNIT_ACCESS_UNIT_DELIMITER))
+      || (nalu_type == NAL_UNIT_SUFFIX_SEI && skip_next_sei))
 #else
-      && ( nalu_type == NAL_UNIT_DPS
-#endif
-        || nalu_type == NAL_UNIT_VPS || nalu_type == NAL_UNIT_SPS || nalu_type == NAL_UNIT_PPS || nalu_type == NAL_UNIT_PREFIX_APS || nalu_type == NAL_UNIT_SUFFIX_APS || nalu_type == NAL_UNIT_PH || nalu_type == NAL_UNIT_ACCESS_UNIT_DELIMITER ) )
+    if ((idx > 1 && (nalu_type == NAL_UNIT_CODED_SLICE_IDR_W_RADL || nalu_type == NAL_UNIT_CODED_SLICE_IDR_N_LP)) || ((idx > 1 && !idr_found) && (nalu_type == NAL_UNIT_DPS || nalu_type == NAL_UNIT_VPS || nalu_type == NAL_UNIT_SPS || nalu_type == NAL_UNIT_PPS || nalu_type == NAL_UNIT_PREFIX_APS || nalu_type == NAL_UNIT_SUFFIX_APS || nalu_type == NAL_UNIT_PH || nalu_type == NAL_UNIT_ACCESS_UNIT_DELIMITER))
       || (nalu_type == NAL_UNIT_SUFFIX_SEI && skip_next_sei))
+#endif
     {
     }
     else
diff --git a/source/Lib/DecoderLib/DecLib.cpp b/source/Lib/DecoderLib/DecLib.cpp
index cffd19296..a2d4bff36 100644
--- a/source/Lib/DecoderLib/DecLib.cpp
+++ b/source/Lib/DecoderLib/DecLib.cpp
@@ -1573,16 +1573,22 @@ bool DecLib::xDecodeSlice(InputNALUnit &nalu, int &iSkipFrame, int iPOCLastDispl
 
   for( auto& naluTemporalId : m_accessUnitNals )
   {
-    if( 
 #if JVET_Q0117_PARAMETER_SETS_CLEANUP
+    if (
       naluTemporalId.first != NAL_UNIT_DCI
+      && naluTemporalId.first != NAL_UNIT_VPS
+      && naluTemporalId.first != NAL_UNIT_SPS
+      && naluTemporalId.first != NAL_UNIT_EOS
+      && naluTemporalId.first != NAL_UNIT_EOB)
 #else
+    if (
       naluTemporalId.first != NAL_UNIT_DPS
-#endif
       && naluTemporalId.first != NAL_UNIT_VPS
       && naluTemporalId.first != NAL_UNIT_SPS
       && naluTemporalId.first != NAL_UNIT_EOS
       && naluTemporalId.first != NAL_UNIT_EOB )
+#endif
+
     {
       CHECK( naluTemporalId.second < nalu.m_temporalId, "TemporalId shall be greater than or equal to the TemporalId of the layer access unit containing the NAL unit" );
     }
diff --git a/source/Lib/EncoderLib/AnnexBwrite.h b/source/Lib/EncoderLib/AnnexBwrite.h
index dff2f5b23..8be7da541 100644
--- a/source/Lib/EncoderLib/AnnexBwrite.h
+++ b/source/Lib/EncoderLib/AnnexBwrite.h
@@ -59,13 +59,13 @@ static std::vector<uint32_t> writeAnnexB(std::ostream& out, const AccessUnit& au
     uint32_t size = 0; /* size of annexB unit in bytes */
 
     static const uint8_t start_code_prefix[] = {0,0,0,1};
-    if (it == au.begin() 
+
 #if JVET_Q0117_PARAMETER_SETS_CLEANUP
-      || nalu.m_nalUnitType == NAL_UNIT_DCI
+      if (it == au.begin() || nalu.m_nalUnitType == NAL_UNIT_DCI || nalu.m_nalUnitType == NAL_UNIT_SPS || nalu.m_nalUnitType == NAL_UNIT_VPS || nalu.m_nalUnitType == NAL_UNIT_PPS)
 #else
-      || nalu.m_nalUnitType == NAL_UNIT_DPS
+      if (it == au.begin() || nalu.m_nalUnitType == NAL_UNIT_DPS || nalu.m_nalUnitType == NAL_UNIT_SPS || nalu.m_nalUnitType == NAL_UNIT_VPS || nalu.m_nalUnitType == NAL_UNIT_PPS)
 #endif
-      || nalu.m_nalUnitType == NAL_UNIT_SPS || nalu.m_nalUnitType == NAL_UNIT_VPS || nalu.m_nalUnitType == NAL_UNIT_PPS)
+
     {
       /* From AVC, When any of the following conditions are fulfilled, the
        * zero_byte syntax element shall be present:
diff --git a/source/Lib/EncoderLib/EncCfg.h b/source/Lib/EncoderLib/EncCfg.h
index 13f08cb8c..b2ceb4759 100644
--- a/source/Lib/EncoderLib/EncCfg.h
+++ b/source/Lib/EncoderLib/EncCfg.h
@@ -723,7 +723,7 @@ protected:
 >>>>>>> f765570c... Commit Q0117. HLS clenup: DPS is changed to DCI
 #if JVET_Q0117_PARAMETER_SETS_CLEANUP
   DCI       m_dci;
-  bool      m_DCIEnabled;                                     ///< enable DCI
+  bool      m_DCIEnabled;                                     ///< enable Decoding Capability Information (DCI)
 #else
 <<<<<<< HEAD
 >>>>>>> effa8e16... Commit Q0117. HLS clenup: DPS is changed to DCI
diff --git a/source/Lib/EncoderLib/EncGOP.cpp b/source/Lib/EncoderLib/EncGOP.cpp
index 2fde5d20c..2b72176d5 100644
--- a/source/Lib/EncoderLib/EncGOP.cpp
+++ b/source/Lib/EncoderLib/EncGOP.cpp
@@ -518,17 +518,23 @@ void EncGOP::xWriteLeadingSEIOrdered (SEIMessages& seiMessages, SEIMessages& duI
 {
   AccessUnit::iterator itNalu = accessUnit.begin();
 
-  while ( (itNalu!=accessUnit.end())&&
-    ( (*itNalu)->m_nalUnitType==NAL_UNIT_ACCESS_UNIT_DELIMITER
-    || (*itNalu)->m_nalUnitType==NAL_UNIT_VPS
 #if JVET_Q0117_PARAMETER_SETS_CLEANUP
-    || (*itNalu)->m_nalUnitType==NAL_UNIT_DCI
+  while ((itNalu != accessUnit.end()) &&
+    ((*itNalu)->m_nalUnitType == NAL_UNIT_ACCESS_UNIT_DELIMITER
+      || (*itNalu)->m_nalUnitType == NAL_UNIT_VPS
+      || (*itNalu)->m_nalUnitType == NAL_UNIT_DCI
+      || (*itNalu)->m_nalUnitType == NAL_UNIT_SPS
+      || (*itNalu)->m_nalUnitType == NAL_UNIT_PPS
+      ))
 #else
-    || (*itNalu)->m_nalUnitType==NAL_UNIT_DPS
+  while ((itNalu != accessUnit.end()) &&
+    ((*itNalu)->m_nalUnitType == NAL_UNIT_ACCESS_UNIT_DELIMITER
+      || (*itNalu)->m_nalUnitType == NAL_UNIT_VPS
+      || (*itNalu)->m_nalUnitType == NAL_UNIT_DPS
+      || (*itNalu)->m_nalUnitType == NAL_UNIT_SPS
+      || (*itNalu)->m_nalUnitType == NAL_UNIT_PPS
+      ))
 #endif
-    || (*itNalu)->m_nalUnitType==NAL_UNIT_SPS
-    || (*itNalu)->m_nalUnitType==NAL_UNIT_PPS
-    ))
   {
     itNalu++;
   }
@@ -4246,13 +4252,11 @@ void EncGOP::xCalculateAddPSNR(Picture* pcPic, PelUnitBuf cPicD, const AccessUni
     if( ( *it )->m_nalUnitType != NAL_UNIT_PREFIX_SEI && ( *it )->m_nalUnitType != NAL_UNIT_SUFFIX_SEI )
     {
       numRBSPBytes += numRBSPBytes_nal;
-      if (it == accessUnit.begin() || (*it)->m_nalUnitType == NAL_UNIT_VPS 
 #if JVET_Q0117_PARAMETER_SETS_CLEANUP
-        || (*it)->m_nalUnitType == NAL_UNIT_DCI
+      if (it == accessUnit.begin() || (*it)->m_nalUnitType == NAL_UNIT_VPS || (*it)->m_nalUnitType == NAL_UNIT_DCI || (*it)->m_nalUnitType == NAL_UNIT_SPS || (*it)->m_nalUnitType == NAL_UNIT_PPS)
 #else
-        || (*it)->m_nalUnitType == NAL_UNIT_DPS 
+      if (it == accessUnit.begin() || (*it)->m_nalUnitType == NAL_UNIT_VPS || (*it)->m_nalUnitType == NAL_UNIT_DPS || (*it)->m_nalUnitType == NAL_UNIT_SPS || (*it)->m_nalUnitType == NAL_UNIT_PPS)
 #endif
-        || (*it)->m_nalUnitType == NAL_UNIT_SPS || (*it)->m_nalUnitType == NAL_UNIT_PPS)
       {
         numRBSPBytes += 4;
       }
diff --git a/source/Lib/EncoderLib/EncLib.h b/source/Lib/EncoderLib/EncLib.h
index 8538855cc..f60f7b6fc 100644
--- a/source/Lib/EncoderLib/EncLib.h
+++ b/source/Lib/EncoderLib/EncLib.h
@@ -180,7 +180,7 @@ protected:
   void  xInitVPS(VPS& vps, const SPS& sps); ///< initialize VPS from encoder options
 
 #if JVET_Q0117_PARAMETER_SETS_CLEANUP
-  void  xInitDCI(DCI& dci, const SPS& sps); ///< initialize DPS from encoder options
+  void  xInitDCI(DCI& dci, const SPS& sps); ///< initialize Decoding Capability Information (DCI) from encoder options
 #else
   void  xInitDPS          (DPS &dps, const SPS &sps, const int dpsId); ///< initialize DPS from encoder options
 #endif
-- 
GitLab