diff --git a/cfg/encoder_intra_vtm.cfg b/cfg/encoder_intra_vtm.cfg index 87c05f8fb2f0dc88d43f77a1670e650a34b889bb..64a3c797bafa2662d2dca0b92c05cc7df9d6306f 100644 --- a/cfg/encoder_intra_vtm.cfg +++ b/cfg/encoder_intra_vtm.cfg @@ -51,9 +51,6 @@ TransformSkipFast : 1 # Fast Transform skipping (0: OFF, 1 TransformSkipLog2MaxSize : 5 SAOLcuBoundary : 0 # SAOLcuBoundary using non-deblocked pixels (0: OFF, 1: ON) -#============ Tiles / Slices ================ -EnablePicPartitioning : 0 # Enable picture partitioning (0: single tile, single slice, 1: multiple tiles/slices can be used) - #============ VTM settings ====================== SEIDecodedPictureHash : 0 CbQpOffset : 0 diff --git a/cfg/encoder_lowdelay_P_vtm.cfg b/cfg/encoder_lowdelay_P_vtm.cfg index c367d4f392d13a9c05d5fa67ae51da8b7af315ee..36f3b89d62011e09bd588cbc8af99ffa4b036718 100644 --- a/cfg/encoder_lowdelay_P_vtm.cfg +++ b/cfg/encoder_lowdelay_P_vtm.cfg @@ -68,9 +68,6 @@ TemporalFilter : 0 # Enable/disable GOP Based Temporal TemporalFilterFutureReference : 0 # Enable/disable reading future frames TemporalFilterStrengthFrame4 : 0.4 # Enable filter at every 4th frame with strength -#============ Tiles / Slices ================ -EnablePicPartitioning : 0 # Enable picture partitioning (0: single tile, single slice, 1: multiple tiles/slices can be used) - #============ Rate Control ====================== RateControl : 0 # Rate control: enable rate control TargetBitrate : 1000000 # Rate control: target bitrate, in bps diff --git a/cfg/encoder_lowdelay_vtm.cfg b/cfg/encoder_lowdelay_vtm.cfg index 251213b76cca00828a59fba24669afc23dd352b0..228ecb5ee6cbe92b70525ca7c6683a298c0a67f1 100644 --- a/cfg/encoder_lowdelay_vtm.cfg +++ b/cfg/encoder_lowdelay_vtm.cfg @@ -68,9 +68,6 @@ TemporalFilter : 0 # Enable/disable GOP Based Temporal TemporalFilterFutureReference : 0 # Enable/disable reading future frames TemporalFilterStrengthFrame4 : 0.4 # Enable filter at every 4th frame with strength -#============ Tiles / Slices ================ -EnablePicPartitioning : 0 # Enable picture partitioning (0: single tile, single slice, 1: multiple tiles/slices can be used) - #============ Rate Control ====================== RateControl : 0 # Rate control: enable rate control TargetBitrate : 1000000 # Rate control: target bitrate, in bps diff --git a/cfg/encoder_randomaccess_vtm.cfg b/cfg/encoder_randomaccess_vtm.cfg index 82b1bc4b82067ebb4cf528de0b294815ec288fd4..b50b5fd166d0f10f9ba2e5fc744d42d2fe716782 100644 --- a/cfg/encoder_randomaccess_vtm.cfg +++ b/cfg/encoder_randomaccess_vtm.cfg @@ -79,9 +79,6 @@ TemporalFilterFutureReference : 1 # Enable/disable reading future fram TemporalFilterStrengthFrame8 : 0.95 # Enable filter at every 8th frame with given strength TemporalFilterStrengthFrame16 : 1.5 # Enable filter at every 16th frame with given strength, longer intervals has higher priority -#============ Tiles / Slices ================ -EnablePicPartitioning : 0 # Enable picture partitioning (0: single tile, single slice, 1: multiple tiles/slices can be used) - #============ Rate Control ====================== RateControl : 0 # Rate control: enable rate control TargetBitrate : 1000000 # Rate control: target bitrate, in bps diff --git a/cfg/lossless/lossless.cfg b/cfg/lossless/lossless.cfg index bca758fcf2403f0b3abdce66250aff0b8676be69..2ab513b33ad737766719b20fe14442b1d902a339 100644 --- a/cfg/lossless/lossless.cfg +++ b/cfg/lossless/lossless.cfg @@ -20,3 +20,6 @@ BIO : 0 PROF : 0 Log2MaxTbSize : 5 InternalBitDepth : 0 +TSRCdisableLL : 1 +SliceLosslessArray : 1 + diff --git a/cfg/lossless/lossless_mixed.cfg b/cfg/lossless/lossless_mixed.cfg new file mode 100644 index 0000000000000000000000000000000000000000..c53046585f386a8ab9534772ba473b5e917d63fc --- /dev/null +++ b/cfg/lossless/lossless_mixed.cfg @@ -0,0 +1,46 @@ +CostMode : lossless +BDPCM : 1 +ChromaTS : 1 +BDPCM : 1 +DepQuant : 0 +RDOQ : 1 +RDOQTS : 1 +SBT : 0 +LMCSEnable : 0 +ISP : 0 +MTS : 0 +LFNST : 0 +JointCbCr : 0 +LoopFilterDisable : 0 +SAO : 1 +ALF : 1 +CCALF : 0 +DMVR : 0 +BIO : 0 +PROF : 0 +Log2MaxTbSize : 5 +InternalBitDepth : 0 +TSRCdisableLL : 1 + +# Configuration to achieve mixed-lossy lossless coding +QP : 55 # Quantization parameter for lossy slices +CbQpOffset : 0 +CrQpOffset : 0 +SliceLevelDblk : 1 +SliceLevelAlf : 1 +SliceLevelSao : 1 +SignHideFlag : 0 +SliceLosslessArray : 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 + +#============ Tiles / Slices ================ +EnablePicPartitioning : 1 # Enable picture partitioning (0: single tile, single slice, 1: multiple tiles/slices can be used) + +TileColumnWidthArray : 3 3 3 3 3 3 # Tile column widths in units of CTUs. Last column width will be repeated uniformly to cover any remaining picture width +TileRowHeightArray : 3 3 3 3 # Tile row heights in units of CTUs. Last row height will be repeated uniformly to cover any remaining picture height +RasterScanSlices : 0 # Raster-scan or rectangular slices (0: rectangular, 1: raster-scan) +RectSliceFixedWidth : 1 # Fixed rectangular slice width in units of tiles (0: disable this feature and use RectSlicePositions instead) +RectSliceFixedHeight : 1 # Fixed rectangular slice height in units of tiles (0: disable this feature and use RectSlicePositions instead) +DisableLoopFilterAcrossTiles : 1 # Loop filtering (DBLK/SAO/ALF) applied across tile boundaries or not (0: filter across tile boundaries 1: do not filter across tile boundaries) +DisableLoopFilterAcrossSlices : 1 # Loop filtering (DBLK/SAO/ALF) applied across slice boundaries or not (0: filter across slice boundaries 1: do not filter across slice boundaries) + + diff --git a/cfg/layers.cfg b/cfg/multi-layer/two_layers.cfg similarity index 100% rename from cfg/layers.cfg rename to cfg/multi-layer/two_layers.cfg diff --git a/cfg/nonCTC-SliceConfigExamples/encoder_randomaccess_vtm_RasterScanSlice.cfg b/cfg/nonCTC-SliceConfigExamples/encoder_randomaccess_vtm_RasterScanSlice.cfg deleted file mode 100644 index 1fdd36ba50c9325895e32c1fbde2cee3f43cdbca..0000000000000000000000000000000000000000 --- a/cfg/nonCTC-SliceConfigExamples/encoder_randomaccess_vtm_RasterScanSlice.cfg +++ /dev/null @@ -1,162 +0,0 @@ -#======== File I/O ===================== -BitstreamFile : str.bin -ReconFile : rec.yuv - -#======== Profile ================ -Profile : auto - -#======== Unit definition ================ -MaxCUWidth : 64 # Maximum coding unit width in pixel -MaxCUHeight : 64 # Maximum coding unit height in pixel - -#======== Coding Structure ============= -IntraPeriod : 32 # Period of I-Frame ( -1 = only first) -DecodingRefreshType : 1 # Random Accesss 0:none, 1:CRA, 2:IDR, 3:Recovery Point SEI -GOPSize : 16 # GOP Size (number of B slice = GOPSize-1) - -IntraQPOffset : -3 -LambdaFromQpEnable : 1 # see JCTVC-X0038 for suitable parameters for IntraQPOffset, QPoffset, QPOffsetModelOff, QPOffsetModelScale when enabled -# Type POC QPoffset QPOffsetModelOff QPOffsetModelScale CbQPoffset CrQPoffset QPfactor tcOffsetDiv2 betaOffsetDiv2 CbTcOffsetDiv2 CbBetaOffsetDiv2 CrTcOffsetDiv2 CrBetaOffsetDiv2 temporal_id #ref_pics_active_L0 #ref_pics_L0 reference_pictures_L0 #ref_pics_active_L1 #ref_pics_L1 reference_pictures_L1 -Frame1: B 16 1 0.0 0.0 0 0 1.0 0 0 0 0 0 0 0 2 3 16 32 24 2 2 16 32 -Frame2: B 8 1 -4.8848 0.2061 0 0 1.0 0 0 0 0 0 0 1 2 2 8 16 2 2 -8 8 -Frame3: B 4 4 -5.7476 0.2286 0 0 1.0 0 0 0 0 0 0 2 2 2 4 12 2 2 -4 -12 -Frame4: B 2 5 -5.90 0.2333 0 0 1.0 0 0 0 0 0 0 3 2 2 2 10 2 3 -2 -6 -14 -Frame5: B 1 6 -7.1444 0.3 0 0 1.0 0 0 0 0 0 0 4 2 2 1 -1 2 4 -1 -3 -7 -15 -Frame6: B 3 6 -7.1444 0.3 0 0 1.0 0 0 0 0 0 0 4 2 2 1 3 2 3 -1 -5 -13 -Frame7: B 6 5 -5.90 0.2333 0 0 1.0 0 0 0 0 0 0 3 2 2 2 6 2 2 -2 -10 -Frame8: B 5 6 -7.1444 0.3 0 0 1.0 0 0 0 0 0 0 4 2 2 1 5 2 3 -1 -3 -11 -Frame9: B 7 6 -7.1444 0.3 0 0 1.0 0 0 0 0 0 0 4 2 3 1 3 7 2 2 -1 -9 -Frame10: B 12 4 -5.7476 0.2286 0 0 1.0 0 0 0 0 0 0 2 2 2 4 12 2 2 -4 4 -Frame11: B 10 5 -5.90 0.2333 0 0 1.0 0 0 0 0 0 0 3 2 2 2 10 2 2 -2 -6 -Frame12: B 9 6 -7.1444 0.3 0 0 1.0 0 0 0 0 0 0 4 2 2 1 9 2 3 -1 -3 -7 -Frame13: B 11 6 -7.1444 0.3 0 0 1.0 0 0 0 0 0 0 4 2 3 1 3 11 2 2 -1 -5 -Frame14: B 14 5 -5.90 0.2333 0 0 1.0 0 0 0 0 0 0 3 2 3 2 6 14 2 2 -2 2 -Frame15: B 13 6 -7.1444 0.3 0 0 1.0 0 0 0 0 0 0 4 2 3 1 5 13 2 2 -1 -3 -Frame16: B 15 6 -7.1444 0.3 0 0 1.0 0 0 0 0 0 0 4 2 4 1 3 7 15 2 2 -1 1 - -#=========== Motion Search ============= -FastSearch : 1 # 0:Full search 1:TZ search -SearchRange : 384 # (0: Search range is a Full frame) -ASR : 1 # Adaptive motion search range -MinSearchWindow : 96 # Minimum motion search window size for the adaptive window ME -BipredSearchRange : 4 # Search range for bi-prediction refinement -HadamardME : 1 # Use of hadamard measure for fractional ME -FEN : 1 # Fast encoder decision -FDM : 1 # Fast Decision for Merge RD cost - -#======== Quantization ============= -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 -RDOQ : 1 # RDOQ -RDOQTS : 1 # RDOQ for transform skip - -#=========== Deblock Filter ============ -LoopFilterOffsetInPPS : 1 # Dbl params: 0=varying params in SliceHeader, param = base_param + GOP_offset_param; 1 (default) =constant params in PPS, param = base_param) -LoopFilterDisable : 0 # Disable deblocking filter (0=Filter, 1=No Filter) -LoopFilterBetaOffset_div2 : 0 # base_param: -12 ~ 12 -LoopFilterTcOffset_div2 : 0 # base_param: -12 ~ 12 -LoopFilterCbBetaOffset_div2 : 0 # base_param: -12 ~ 12 -LoopFilterCbTcOffset_div2 : 0 # base_param: -12 ~ 12 -LoopFilterCrBetaOffset_div2 : 0 # base_param: -12 ~ 12 -LoopFilterCrTcOffset_div2 : 0 # base_param: -12 ~ 12 -DeblockingFilterMetric : 0 # blockiness metric (automatically configures deblocking parameters in bitstream). Applies slice-level loop filter offsets (LoopFilterOffsetInPPS and LoopFilterDisable must be 0) - -#=========== Misc. ============ -InternalBitDepth : 10 # codec operating bit-depth - -#=========== Coding Tools ================= -SAO : 1 # Sample adaptive offset (0: OFF, 1: ON) -TransformSkip : 1 # Transform skipping (0: OFF, 1: ON) -TransformSkipFast : 1 # Fast Transform skipping (0: OFF, 1: ON) -TransformSkipLog2MaxSize : 5 -SAOLcuBoundary : 0 # SAOLcuBoundary using non-deblocked pixels (0: OFF, 1: ON) - -#============ Tiles / Slices ================ -EnablePicPartitioning : 1 # Enable picture partitioning (0: single tile, single slice, 1: multiple tiles/slices can be used) - -# Figure 4 - Section 6.3.1 - 12 tiles and 3 raster-scan slices -TileColumnWidthArray : 6 6 6 # Tile column widths in units of CTUs. Last column width will be repeated uniformly to cover any remaining picture width -TileRowHeightArray : 3 3 3 3 # Tile row heights in units of CTUs. Last row height will be repeated uniformly to cover any remaining picture height -RasterScanSlices : 1 # Raster-scan or rectangular slices (0: rectangular, 1: raster-scan) -RasterSliceSizes : 2 5 5 # Raster-scan slice sizes in units of tiles. Last slice size will be repeated uniformly to cover any remaining tiles in the picture -DisableLoopFilterAcrossTiles : 0 # Loop filtering (DBLK/SAO/ALF) applied across tile boundaries or not (0: filter across tile boundaries 1: do not filter across tile boundaries) -DisableLoopFilterAcrossSlices : 0 # Loop filtering (DBLK/SAO/ALF) applied across slice boundaries or not (0: filter across slice boundaries 1: do not filter across slice boundaries) - -#============ Rate Control ====================== -RateControl : 0 # Rate control: enable rate control -TargetBitrate : 1000000 # Rate control: target bitrate, in bps -KeepHierarchicalBit : 2 # Rate control: 0: equal bit allocation; 1: fixed ratio bit allocation; 2: adaptive ratio bit allocation -LCULevelRateControl : 1 # Rate control: 1: LCU level RC; 0: picture level RC -RCLCUSeparateModel : 1 # Rate control: use LCU level separate R-lambda model -InitialQP : 0 # Rate control: initial QP -RCForceIntraQP : 0 # Rate control: force intra QP to be equal to initial QP - -#============ VTM settings ====================== -LoopFilterTcOffset_div2 : 0 -SEIDecodedPictureHash : 0 -CbQpOffset : 1 -CrQpOffset : 1 - -ReWriteParamSets : 1 -#============ NEXT ==================== - -# General -CTUSize : 128 -LCTUFast : 1 - -DualITree : 1 # separate partitioning of luma and chroma channels for I-slices -MinQTLumaISlice : 8 -MinQTChromaISliceInChromaSamples: 4 # minimum QT size in chroma samples for chroma separate tree -MinQTNonISlice : 8 -MaxMTTHierarchyDepth : 3 -MaxMTTHierarchyDepthISliceL : 3 -MaxMTTHierarchyDepthISliceC : 3 - -MTS : 1 -MTSIntraMaxCand : 3 -MTSInterMaxCand : 4 -SBT : 1 -LFNST : 1 -ISP : 1 -MMVD : 1 -Affine : 1 -SubPuMvp : 1 -MaxNumMergeCand : 6 -LMChroma : 1 # use CCLM only -DepQuant : 1 -IMV : 1 -ALF : 1 -BCW : 1 -BcwFast : 1 -BIO : 1 -CIIP : 1 -Triangle : 1 -IBC : 0 # turned off in CTC -AllowDisFracMMVD : 1 -AffineAmvr : 1 -LMCSEnable : 1 # LMCS: 0: disable, 1:enable -LMCSSignalType : 0 # Input signal type: 0:SDR, 1:HDR-PQ, 2:HDR-HLG -LMCSUpdateCtrl : 0 # LMCS model update control: 0:RA, 1:AI, 2:LDB/LDP -MRL : 1 -MIP : 1 -DMVR : 1 -SMVD : 1 - -# Fast tools -PBIntraFast : 1 -ISPFast : 1 -FastMrg : 1 -AMaxBT : 1 -FastMIP : 0 -FastLFNST : 0 - -# Encoder optimization tools -AffineAmvrEncOpt : 1 -MmvdDisNum : 6 -### DO NOT ADD ANYTHING BELOW THIS LINE ### -### DO NOT DELETE THE EMPTY LINE BELOW ### - - - diff --git a/cfg/nonCTC-SliceConfigExamples/encoder_randomaccess_vtm_RectangularSliceFixedSize.cfg b/cfg/nonCTC-SliceConfigExamples/encoder_randomaccess_vtm_RectangularSliceFixedSize.cfg deleted file mode 100644 index 7182428dc4557e9df70e248b80d35a2b3fb18362..0000000000000000000000000000000000000000 --- a/cfg/nonCTC-SliceConfigExamples/encoder_randomaccess_vtm_RectangularSliceFixedSize.cfg +++ /dev/null @@ -1,163 +0,0 @@ -#======== File I/O ===================== -BitstreamFile : str.bin -ReconFile : rec.yuv - -#======== Profile ================ -Profile : auto - -#======== Unit definition ================ -MaxCUWidth : 64 # Maximum coding unit width in pixel -MaxCUHeight : 64 # Maximum coding unit height in pixel - -#======== Coding Structure ============= -IntraPeriod : 32 # Period of I-Frame ( -1 = only first) -DecodingRefreshType : 1 # Random Accesss 0:none, 1:CRA, 2:IDR, 3:Recovery Point SEI -GOPSize : 16 # GOP Size (number of B slice = GOPSize-1) - -IntraQPOffset : -3 -LambdaFromQpEnable : 1 # see JCTVC-X0038 for suitable parameters for IntraQPOffset, QPoffset, QPOffsetModelOff, QPOffsetModelScale when enabled -# Type POC QPoffset QPOffsetModelOff QPOffsetModelScale CbQPoffset CrQPoffset QPfactor tcOffsetDiv2 betaOffsetDiv2 CbTcOffsetDiv2 CbBetaOffsetDiv2 CrTcOffsetDiv2 CrBetaOffsetDiv2 temporal_id #ref_pics_active_L0 #ref_pics_L0 reference_pictures_L0 #ref_pics_active_L1 #ref_pics_L1 reference_pictures_L1 -Frame1: B 16 1 0.0 0.0 0 0 1.0 0 0 0 0 0 0 0 2 3 16 32 24 2 2 16 32 -Frame2: B 8 1 -4.8848 0.2061 0 0 1.0 0 0 0 0 0 0 1 2 2 8 16 2 2 -8 8 -Frame3: B 4 4 -5.7476 0.2286 0 0 1.0 0 0 0 0 0 0 2 2 2 4 12 2 2 -4 -12 -Frame4: B 2 5 -5.90 0.2333 0 0 1.0 0 0 0 0 0 0 3 2 2 2 10 2 3 -2 -6 -14 -Frame5: B 1 6 -7.1444 0.3 0 0 1.0 0 0 0 0 0 0 4 2 2 1 -1 2 4 -1 -3 -7 -15 -Frame6: B 3 6 -7.1444 0.3 0 0 1.0 0 0 0 0 0 0 4 2 2 1 3 2 3 -1 -5 -13 -Frame7: B 6 5 -5.90 0.2333 0 0 1.0 0 0 0 0 0 0 3 2 2 2 6 2 2 -2 -10 -Frame8: B 5 6 -7.1444 0.3 0 0 1.0 0 0 0 0 0 0 4 2 2 1 5 2 3 -1 -3 -11 -Frame9: B 7 6 -7.1444 0.3 0 0 1.0 0 0 0 0 0 0 4 2 3 1 3 7 2 2 -1 -9 -Frame10: B 12 4 -5.7476 0.2286 0 0 1.0 0 0 0 0 0 0 2 2 2 4 12 2 2 -4 4 -Frame11: B 10 5 -5.90 0.2333 0 0 1.0 0 0 0 0 0 0 3 2 2 2 10 2 2 -2 -6 -Frame12: B 9 6 -7.1444 0.3 0 0 1.0 0 0 0 0 0 0 4 2 2 1 9 2 3 -1 -3 -7 -Frame13: B 11 6 -7.1444 0.3 0 0 1.0 0 0 0 0 0 0 4 2 3 1 3 11 2 2 -1 -5 -Frame14: B 14 5 -5.90 0.2333 0 0 1.0 0 0 0 0 0 0 3 2 3 2 6 14 2 2 -2 2 -Frame15: B 13 6 -7.1444 0.3 0 0 1.0 0 0 0 0 0 0 4 2 3 1 5 13 2 2 -1 -3 -Frame16: B 15 6 -7.1444 0.3 0 0 1.0 0 0 0 0 0 0 4 2 4 1 3 7 15 2 2 -1 1 - -#=========== Motion Search ============= -FastSearch : 1 # 0:Full search 1:TZ search -SearchRange : 384 # (0: Search range is a Full frame) -ASR : 1 # Adaptive motion search range -MinSearchWindow : 96 # Minimum motion search window size for the adaptive window ME -BipredSearchRange : 4 # Search range for bi-prediction refinement -HadamardME : 1 # Use of hadamard measure for fractional ME -FEN : 1 # Fast encoder decision -FDM : 1 # Fast Decision for Merge RD cost - -#======== Quantization ============= -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 -RDOQ : 1 # RDOQ -RDOQTS : 1 # RDOQ for transform skip - -#=========== Deblock Filter ============ -LoopFilterOffsetInPPS : 1 # Dbl params: 0=varying params in SliceHeader, param = base_param + GOP_offset_param; 1 (default) =constant params in PPS, param = base_param) -LoopFilterDisable : 0 # Disable deblocking filter (0=Filter, 1=No Filter) -LoopFilterBetaOffset_div2 : 0 # base_param: -12 ~ 12 -LoopFilterTcOffset_div2 : 0 # base_param: -12 ~ 12 -LoopFilterCbBetaOffset_div2 : 0 # base_param: -12 ~ 12 -LoopFilterCbTcOffset_div2 : 0 # base_param: -12 ~ 12 -LoopFilterCrBetaOffset_div2 : 0 # base_param: -12 ~ 12 -LoopFilterCrTcOffset_div2 : 0 # base_param: -12 ~ 12 -DeblockingFilterMetric : 0 # blockiness metric (automatically configures deblocking parameters in bitstream). Applies slice-level loop filter offsets (LoopFilterOffsetInPPS and LoopFilterDisable must be 0) - -#=========== Misc. ============ -InternalBitDepth : 10 # codec operating bit-depth - -#=========== Coding Tools ================= -SAO : 1 # Sample adaptive offset (0: OFF, 1: ON) -TransformSkip : 1 # Transform skipping (0: OFF, 1: ON) -TransformSkipFast : 1 # Fast Transform skipping (0: OFF, 1: ON) -TransformSkipLog2MaxSize : 5 -SAOLcuBoundary : 0 # SAOLcuBoundary using non-deblocked pixels (0: OFF, 1: ON) - -#============ Tiles / Slices ================ -EnablePicPartitioning : 1 # Enable picture partitioning (0: single tile, single slice, 1: multiple tiles/slices can be used) - -# 24 tiles and 6 rectangular slices -TileColumnWidthArray : 3 3 3 3 3 3 # Tile column widths in units of CTUs. Last column width will be repeated uniformly to cover any remaining picture width -TileRowHeightArray : 3 3 3 3 # Tile row heights in units of CTUs. Last row height will be repeated uniformly to cover any remaining picture height -RasterScanSlices : 0 # Raster-scan or rectangular slices (0: rectangular, 1: raster-scan) -RectSliceFixedWidth : 2 # Fixed rectangular slice width in units of tiles (0: disable this feature and use RectSlicePositions instead) -RectSliceFixedHeight : 2 # Fixed rectangular slice height in units of tiles (0: disable this feature and use RectSlicePositions instead) -DisableLoopFilterAcrossTiles : 0 # Loop filtering (DBLK/SAO/ALF) applied across tile boundaries or not (0: filter across tile boundaries 1: do not filter across tile boundaries) -DisableLoopFilterAcrossSlices : 0 # Loop filtering (DBLK/SAO/ALF) applied across slice boundaries or not (0: filter across slice boundaries 1: do not filter across slice boundaries) - -#============ Rate Control ====================== -RateControl : 0 # Rate control: enable rate control -TargetBitrate : 1000000 # Rate control: target bitrate, in bps -KeepHierarchicalBit : 2 # Rate control: 0: equal bit allocation; 1: fixed ratio bit allocation; 2: adaptive ratio bit allocation -LCULevelRateControl : 1 # Rate control: 1: LCU level RC; 0: picture level RC -RCLCUSeparateModel : 1 # Rate control: use LCU level separate R-lambda model -InitialQP : 0 # Rate control: initial QP -RCForceIntraQP : 0 # Rate control: force intra QP to be equal to initial QP - -#============ VTM settings ====================== -LoopFilterTcOffset_div2 : 0 -SEIDecodedPictureHash : 0 -CbQpOffset : 1 -CrQpOffset : 1 - -ReWriteParamSets : 1 -#============ NEXT ==================== - -# General -CTUSize : 128 -LCTUFast : 1 - -DualITree : 1 # separate partitioning of luma and chroma channels for I-slices -MinQTLumaISlice : 8 -MinQTChromaISliceInChromaSamples: 4 # minimum QT size in chroma samples for chroma separate tree -MinQTNonISlice : 8 -MaxMTTHierarchyDepth : 3 -MaxMTTHierarchyDepthISliceL : 3 -MaxMTTHierarchyDepthISliceC : 3 - -MTS : 1 -MTSIntraMaxCand : 3 -MTSInterMaxCand : 4 -SBT : 1 -LFNST : 1 -ISP : 1 -MMVD : 1 -Affine : 1 -SubPuMvp : 1 -MaxNumMergeCand : 6 -LMChroma : 1 # use CCLM only -DepQuant : 1 -IMV : 1 -ALF : 1 -BCW : 1 -BcwFast : 1 -BIO : 1 -CIIP : 1 -Triangle : 1 -IBC : 0 # turned off in CTC -AllowDisFracMMVD : 1 -AffineAmvr : 1 -LMCSEnable : 1 # LMCS: 0: disable, 1:enable -LMCSSignalType : 0 # Input signal type: 0:SDR, 1:HDR-PQ, 2:HDR-HLG -LMCSUpdateCtrl : 0 # LMCS model update control: 0:RA, 1:AI, 2:LDB/LDP -MRL : 1 -MIP : 1 -DMVR : 1 -SMVD : 1 - -# Fast tools -PBIntraFast : 1 -ISPFast : 1 -FastMrg : 1 -AMaxBT : 1 -FastMIP : 0 -FastLFNST : 0 - -# Encoder optimization tools -AffineAmvrEncOpt : 1 -MmvdDisNum : 6 -### DO NOT ADD ANYTHING BELOW THIS LINE ### -### DO NOT DELETE THE EMPTY LINE BELOW ### - - - diff --git a/cfg/nonCTC-SliceConfigExamples/encoder_randomaccess_vtm_SingleTilePerSlice.cfg b/cfg/nonCTC-SliceConfigExamples/encoder_randomaccess_vtm_SingleTilePerSlice.cfg deleted file mode 100644 index c3a6a7e8ff1df900a666b8790297ec6be7df08d7..0000000000000000000000000000000000000000 --- a/cfg/nonCTC-SliceConfigExamples/encoder_randomaccess_vtm_SingleTilePerSlice.cfg +++ /dev/null @@ -1,160 +0,0 @@ -#======== File I/O ===================== -BitstreamFile : str.bin -ReconFile : rec.yuv - -#======== Profile ================ -Profile : auto - -#======== Unit definition ================ -MaxCUWidth : 64 # Maximum coding unit width in pixel -MaxCUHeight : 64 # Maximum coding unit height in pixel - -#======== Coding Structure ============= -IntraPeriod : 32 # Period of I-Frame ( -1 = only first) -DecodingRefreshType : 1 # Random Accesss 0:none, 1:CRA, 2:IDR, 3:Recovery Point SEI -GOPSize : 16 # GOP Size (number of B slice = GOPSize-1) - -IntraQPOffset : -3 -LambdaFromQpEnable : 1 # see JCTVC-X0038 for suitable parameters for IntraQPOffset, QPoffset, QPOffsetModelOff, QPOffsetModelScale when enabled -# Type POC QPoffset QPOffsetModelOff QPOffsetModelScale CbQPoffset CrQPoffset QPfactor tcOffsetDiv2 betaOffsetDiv2 CbTcOffsetDiv2 CbBetaOffsetDiv2 CrTcOffsetDiv2 CrBetaOffsetDiv2 temporal_id #ref_pics_active_L0 #ref_pics_L0 reference_pictures_L0 #ref_pics_active_L1 #ref_pics_L1 reference_pictures_L1 -Frame1: B 16 1 0.0 0.0 0 0 1.0 0 0 0 0 0 0 0 2 3 16 32 24 2 2 16 32 -Frame2: B 8 1 -4.8848 0.2061 0 0 1.0 0 0 0 0 0 0 1 2 2 8 16 2 2 -8 8 -Frame3: B 4 4 -5.7476 0.2286 0 0 1.0 0 0 0 0 0 0 2 2 2 4 12 2 2 -4 -12 -Frame4: B 2 5 -5.90 0.2333 0 0 1.0 0 0 0 0 0 0 3 2 2 2 10 2 3 -2 -6 -14 -Frame5: B 1 6 -7.1444 0.3 0 0 1.0 0 0 0 0 0 0 4 2 2 1 -1 2 4 -1 -3 -7 -15 -Frame6: B 3 6 -7.1444 0.3 0 0 1.0 0 0 0 0 0 0 4 2 2 1 3 2 3 -1 -5 -13 -Frame7: B 6 5 -5.90 0.2333 0 0 1.0 0 0 0 0 0 0 3 2 2 2 6 2 2 -2 -10 -Frame8: B 5 6 -7.1444 0.3 0 0 1.0 0 0 0 0 0 0 4 2 2 1 5 2 3 -1 -3 -11 -Frame9: B 7 6 -7.1444 0.3 0 0 1.0 0 0 0 0 0 0 4 2 3 1 3 7 2 2 -1 -9 -Frame10: B 12 4 -5.7476 0.2286 0 0 1.0 0 0 0 0 0 0 2 2 2 4 12 2 2 -4 4 -Frame11: B 10 5 -5.90 0.2333 0 0 1.0 0 0 0 0 0 0 3 2 2 2 10 2 2 -2 -6 -Frame12: B 9 6 -7.1444 0.3 0 0 1.0 0 0 0 0 0 0 4 2 2 1 9 2 3 -1 -3 -7 -Frame13: B 11 6 -7.1444 0.3 0 0 1.0 0 0 0 0 0 0 4 2 3 1 3 11 2 2 -1 -5 -Frame14: B 14 5 -5.90 0.2333 0 0 1.0 0 0 0 0 0 0 3 2 3 2 6 14 2 2 -2 2 -Frame15: B 13 6 -7.1444 0.3 0 0 1.0 0 0 0 0 0 0 4 2 3 1 5 13 2 2 -1 -3 -Frame16: B 15 6 -7.1444 0.3 0 0 1.0 0 0 0 0 0 0 4 2 4 1 3 7 15 2 2 -1 1 - -#=========== Motion Search ============= -FastSearch : 1 # 0:Full search 1:TZ search -SearchRange : 384 # (0: Search range is a Full frame) -ASR : 1 # Adaptive motion search range -MinSearchWindow : 96 # Minimum motion search window size for the adaptive window ME -BipredSearchRange : 4 # Search range for bi-prediction refinement -HadamardME : 1 # Use of hadamard measure for fractional ME -FEN : 1 # Fast encoder decision -FDM : 1 # Fast Decision for Merge RD cost - -#======== Quantization ============= -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 -RDOQ : 1 # RDOQ -RDOQTS : 1 # RDOQ for transform skip - -#=========== Deblock Filter ============ -LoopFilterOffsetInPPS : 1 # Dbl params: 0=varying params in SliceHeader, param = base_param + GOP_offset_param; 1 (default) =constant params in PPS, param = base_param) -LoopFilterDisable : 0 # Disable deblocking filter (0=Filter, 1=No Filter) -LoopFilterBetaOffset_div2 : 0 # base_param: -12 ~ 12 -LoopFilterTcOffset_div2 : 0 # base_param: -12 ~ 12 -LoopFilterCbBetaOffset_div2 : 0 # base_param: -12 ~ 12 -LoopFilterCbTcOffset_div2 : 0 # base_param: -12 ~ 12 -LoopFilterCrBetaOffset_div2 : 0 # base_param: -12 ~ 12 -LoopFilterCrTcOffset_div2 : 0 # base_param: -12 ~ 12 -DeblockingFilterMetric : 0 # blockiness metric (automatically configures deblocking parameters in bitstream). Applies slice-level loop filter offsets (LoopFilterOffsetInPPS and LoopFilterDisable must be 0) - -#=========== Misc. ============ -InternalBitDepth : 10 # codec operating bit-depth - -#=========== Coding Tools ================= -SAO : 1 # Sample adaptive offset (0: OFF, 1: ON) -TransformSkip : 1 # Transform skipping (0: OFF, 1: ON) -TransformSkipFast : 1 # Fast Transform skipping (0: OFF, 1: ON) -TransformSkipLog2MaxSize : 5 -SAOLcuBoundary : 0 # SAOLcuBoundary using non-deblocked pixels (0: OFF, 1: ON) - -#============ Tiles / Slices ================ -EnablePicPartitioning : 1 # Enable picture partitioning (0: single tile, single slice, 1: multiple tiles/slices can be used) -TileColumnWidthArray : 1 2 3 4 # Tile column widths in units of CTUs. Last column width will be repeated uniformly to cover any remaining picture width -TileRowHeightArray : 1 2 3 4 # Tile row heights in units of CTUs. Last row height will be repeated uniformly to cover any remaining picture height -RasterScanSlices : 1 # Raster-scan or rectangular slices (0: rectangular, 1: raster-scan) -RasterSliceSizes : 1 # Raster-scan slice sizes in units of tiles. Last slice size will be repeated uniformly to cover any remaining tiles in the picture -DisableLoopFilterAcrossTiles : 0 # Loop filtering (DBLK/SAO/ALF) applied across tile boundaries or not (0: filter across tile boundaries 1: do not filter across tile boundaries) -DisableLoopFilterAcrossSlices : 0 # Loop filtering (DBLK/SAO/ALF) applied across slice boundaries or not (0: filter across slice boundaries 1: do not filter across slice boundaries) - -#============ Rate Control ====================== -RateControl : 0 # Rate control: enable rate control -TargetBitrate : 1000000 # Rate control: target bitrate, in bps -KeepHierarchicalBit : 2 # Rate control: 0: equal bit allocation; 1: fixed ratio bit allocation; 2: adaptive ratio bit allocation -LCULevelRateControl : 1 # Rate control: 1: LCU level RC; 0: picture level RC -RCLCUSeparateModel : 1 # Rate control: use LCU level separate R-lambda model -InitialQP : 0 # Rate control: initial QP -RCForceIntraQP : 0 # Rate control: force intra QP to be equal to initial QP - -#============ VTM settings ====================== -LoopFilterTcOffset_div2 : 0 -SEIDecodedPictureHash : 0 -CbQpOffset : 1 -CrQpOffset : 1 - -ReWriteParamSets : 1 -#============ NEXT ==================== - -# General -CTUSize : 128 -LCTUFast : 1 - -DualITree : 1 # separate partitioning of luma and chroma channels for I-slices -MinQTLumaISlice : 8 -MinQTChromaISliceInChromaSamples: 4 # minimum QT size in chroma samples for chroma separate tree -MinQTNonISlice : 8 -MaxMTTHierarchyDepth : 3 -MaxMTTHierarchyDepthISliceL : 3 -MaxMTTHierarchyDepthISliceC : 3 - -MTS : 1 -MTSIntraMaxCand : 3 -MTSInterMaxCand : 4 -SBT : 1 -LFNST : 1 -ISP : 1 -MMVD : 1 -Affine : 1 -SubPuMvp : 1 -MaxNumMergeCand : 6 -LMChroma : 1 # use CCLM only -DepQuant : 1 -IMV : 1 -ALF : 1 -BCW : 1 -BcwFast : 1 -BIO : 1 -CIIP : 1 -Triangle : 1 -IBC : 0 # turned off in CTC -AllowDisFracMMVD : 1 -AffineAmvr : 1 -LMCSEnable : 1 # LMCS: 0: disable, 1:enable -LMCSSignalType : 0 # Input signal type: 0:SDR, 1:HDR-PQ, 2:HDR-HLG -LMCSUpdateCtrl : 0 # LMCS model update control: 0:RA, 1:AI, 2:LDB/LDP -MRL : 1 -MIP : 1 -DMVR : 1 -SMVD : 1 - -# Fast tools -PBIntraFast : 1 -ISPFast : 1 -FastMrg : 1 -AMaxBT : 1 -FastMIP : 0 -FastLFNST : 0 - -# Encoder optimization tools -AffineAmvrEncOpt : 1 -MmvdDisNum : 6 -### DO NOT ADD ANYTHING BELOW THIS LINE ### -### DO NOT DELETE THE EMPTY LINE BELOW ### - - - diff --git a/cfg/partitioning/raster_slice.cfg b/cfg/partitioning/raster_slice.cfg new file mode 100644 index 0000000000000000000000000000000000000000..11f9f2a5e7184716f3f1d38233929bcf1c32c703 --- /dev/null +++ b/cfg/partitioning/raster_slice.cfg @@ -0,0 +1,13 @@ +# example configuration file for raster scan slices +# to be used in combination with a CTC and sequence configuration file +# contains 12 tiles and 3 raster-scan slices + +#============ Tiles / Slices ================ +EnablePicPartitioning : 1 # Enable picture partitioning (0: single tile, single slice, 1: multiple tiles/slices can be used) + +TileColumnWidthArray : 6 6 6 # Tile column widths in units of CTUs. Last column width will be repeated uniformly to cover any remaining picture width +TileRowHeightArray : 3 3 3 3 # Tile row heights in units of CTUs. Last row height will be repeated uniformly to cover any remaining picture height +RasterScanSlices : 1 # Raster-scan or rectangular slices (0: rectangular, 1: raster-scan) +RasterSliceSizes : 2 5 5 # Raster-scan slice sizes in units of tiles. Last slice size will be repeated uniformly to cover any remaining tiles in the picture +DisableLoopFilterAcrossTiles : 0 # Loop filtering (DBLK/SAO/ALF) applied across tile boundaries or not (0: filter across tile boundaries 1: do not filter across tile boundaries) +DisableLoopFilterAcrossSlices : 0 # Loop filtering (DBLK/SAO/ALF) applied across slice boundaries or not (0: filter across slice boundaries 1: do not filter across slice boundaries) diff --git a/cfg/partitioning/raster_slice_1_slice_per_tile.cfg b/cfg/partitioning/raster_slice_1_slice_per_tile.cfg new file mode 100644 index 0000000000000000000000000000000000000000..d582ec990373c21c494a63478ae612885ade661e --- /dev/null +++ b/cfg/partitioning/raster_slice_1_slice_per_tile.cfg @@ -0,0 +1,11 @@ +# example configuration file for raster scan slices with a single slice per tile +# to be used in combination with a CTC and sequence configuration file + +#============ Tiles / Slices ================ +EnablePicPartitioning : 1 # Enable picture partitioning (0: single tile, single slice, 1: multiple tiles/slices can be used) +TileColumnWidthArray : 1 2 3 4 # Tile column widths in units of CTUs. Last column width will be repeated uniformly to cover any remaining picture width +TileRowHeightArray : 1 2 3 4 # Tile row heights in units of CTUs. Last row height will be repeated uniformly to cover any remaining picture height +RasterScanSlices : 1 # Raster-scan or rectangular slices (0: rectangular, 1: raster-scan) +RasterSliceSizes : 1 # Raster-scan slice sizes in units of tiles. Last slice size will be repeated uniformly to cover any remaining tiles in the picture +DisableLoopFilterAcrossTiles : 0 # Loop filtering (DBLK/SAO/ALF) applied across tile boundaries or not (0: filter across tile boundaries 1: do not filter across tile boundaries) +DisableLoopFilterAcrossSlices : 0 # Loop filtering (DBLK/SAO/ALF) applied across slice boundaries or not (0: filter across slice boundaries 1: do not filter across slice boundaries) diff --git a/cfg/nonCTC-SliceConfigExamples/encoder_rectangular_slice_classB.cfg b/cfg/partitioning/rect_slice_classB.cfg similarity index 88% rename from cfg/nonCTC-SliceConfigExamples/encoder_rectangular_slice_classB.cfg rename to cfg/partitioning/rect_slice_classB.cfg index 7081049c1b98a07566b8840f4758695791dda74c..4bbc818402a453a7050a03b6354be10f6a8977fb 100644 --- a/cfg/nonCTC-SliceConfigExamples/encoder_rectangular_slice_classB.cfg +++ b/cfg/partitioning/rect_slice_classB.cfg @@ -1,16 +1,13 @@ +# example configuration file for rectangular slices +# to be used in combination with a CTC and sequence configuration file +# contains 4 tiles and 4 rectangular slices + #============ Tiles / Slices ================ EnablePicPartitioning : 1 # Enable picture partitioning (0: single tile, single slice, 1: multiple tiles/slices can be used) -# Figure 6 - Section 6.3.1 - 4 tiles and 4 rectangular slices TileColumnWidthArray : 7 8 # Tile column widths in units of CTUs. Last column width will be repeated uniformly to cover any remaining picture width TileRowHeightArray : 4 5 # Tile row heights in units of CTUs. Last row height will be repeated uniformly to cover any remaining picture height RasterScanSlices : 0 # Raster-scan or rectangular slices (0: rectangular, 1: raster-scan) RectSlicePositions : 0 126 7 29 37 59 67 134 # Rectangular slice positions. List containing pairs of top-left CTU RS address followed by bottom-right CTU RS address DisableLoopFilterAcrossTiles : 0 # Loop filtering (DBLK/SAO/ALF) applied across tile boundaries or not (0: filter across tile boundaries 1: do not filter across tile boundaries) DisableLoopFilterAcrossSlices : 0 # Loop filtering (DBLK/SAO/ALF) applied across slice boundaries or not (0: filter across slice boundaries 1: do not filter across slice boundaries) - -### DO NOT ADD ANYTHING BELOW THIS LINE ### -### DO NOT DELETE THE EMPTY LINE BELOW ### - - - diff --git a/cfg/partitioning/rect_slice_fixed_size.cfg b/cfg/partitioning/rect_slice_fixed_size.cfg new file mode 100644 index 0000000000000000000000000000000000000000..9f00a45da9efb79352753084af33708a5f4cf24a --- /dev/null +++ b/cfg/partitioning/rect_slice_fixed_size.cfg @@ -0,0 +1,14 @@ +# example configuration file for rectangular slices +# to be used in combination with a CTC and sequence configuration file +# contains 24 tiles and 6 rectangular slices + +#============ Tiles / Slices ================ +EnablePicPartitioning : 1 # Enable picture partitioning (0: single tile, single slice, 1: multiple tiles/slices can be used) + +TileColumnWidthArray : 3 3 3 3 3 3 # Tile column widths in units of CTUs. Last column width will be repeated uniformly to cover any remaining picture width +TileRowHeightArray : 3 3 3 3 # Tile row heights in units of CTUs. Last row height will be repeated uniformly to cover any remaining picture height +RasterScanSlices : 0 # Raster-scan or rectangular slices (0: rectangular, 1: raster-scan) +RectSliceFixedWidth : 2 # Fixed rectangular slice width in units of tiles (0: disable this feature and use RectSlicePositions instead) +RectSliceFixedHeight : 2 # Fixed rectangular slice height in units of tiles (0: disable this feature and use RectSlicePositions instead) +DisableLoopFilterAcrossTiles : 0 # Loop filtering (DBLK/SAO/ALF) applied across tile boundaries or not (0: filter across tile boundaries 1: do not filter across tile boundaries) +DisableLoopFilterAcrossSlices : 0 # Loop filtering (DBLK/SAO/ALF) applied across slice boundaries or not (0: filter across slice boundaries 1: do not filter across slice boundaries) diff --git a/cfg/partitioning/rpr_no_subpic_single_slice_per_subpic.cfg b/cfg/partitioning/rpr_no_subpic_single_slice_per_subpic.cfg new file mode 100644 index 0000000000000000000000000000000000000000..f4b07d887469c4f7da56894d89b713968569935f --- /dev/null +++ b/cfg/partitioning/rpr_no_subpic_single_slice_per_subpic.cfg @@ -0,0 +1,20 @@ +# example config file for a corner test case: +# set single_slice_per_subpic_flag equal to 1, while subpicture_info_present_flag is equal to 0 +# requires special handling, when RPR is enabled (which is allowed because subpicture_info_present_flag is equal to 0) and tiles are present +# +# example command line: +# ./EncoderApp -c ../cfg/encoder_randomaccess_vtm.cfg -c ../cfg/per-sequence/RaceHorses.cfg -q 42 -f 5 --SEIDecodedPictureHash=1 -c ../cfg/partitioning/rpr_no_subpic_single_slice_per_subpic.cfg + + +ScalingRatioHor : 2.0 # enable horizontal scaling +ScalingRatioVer : 2.0 # enable vertical scaling +UpscaledOutput : 1 # upscale output + +EnablePicPartitioning : 1 # enable signalling of picture partitioning +SingleSlicePerSubpic : 1 # single_slice_per_subpic_flag equal to 1 +RasterScanSlices : 0 # rectangular slices + +TileColumnWidthArray : 2 # two tiles horizontally +TileRowHeightArray : 2 # two tiles vertically + +Level : 6 # level increase required for small tiles (because of subsampling) diff --git a/cfg/partitioning/subpicture_3_slice_2_tile.cfg b/cfg/partitioning/subpicture_3_slice_2_tile.cfg new file mode 100644 index 0000000000000000000000000000000000000000..bd0453de1ba5ca97d58022dc81b7c432a415bc00 --- /dev/null +++ b/cfg/partitioning/subpicture_3_slice_2_tile.cfg @@ -0,0 +1,38 @@ +# example cfg file, assuming an 832x480 input sequence with CTU size = 128x128, and split to 2 tiles, with two tile columns and one tile row. +# example 2 tiles, 3 subpictures in a 832x480 picture: +#---------- +#| | | +#| | | +#| |---| +#| | | +#| | | +#---------- +# | +# v +# vertically divided into 2 tile, the second tile include two subpicture/slices + +SubPicInfoPresentFlag : 1 # subpicture information present flag(0: OFF, 1: ON) +NumSubPics : 3 # number of subpictures in a picture +SubPicCtuTopLeftX : 0 4 4 # specifies horizontal position of top left CTU of i-th subpicture in unit of CtbSizeY +SubPicCtuTopLeftY : 0 0 2 # specifies vertical position of top left CTU of i-th subpicture in unit of CtbSizeY +SubPicWidth : 4 3 3 # specifies the width of the i-th subpicture in units of CtbSizeY +SubPicHeight : 4 2 2 # specifies the height of the i-th subpicture in units of CtbSizeY +SubPicTreatedAsPicFlag : 1 1 1 # equal to 1 specifies that the i-th subpicture of each coded picture in the CLVS is treated as a picture in the decoding process excluding in-loop filtering operations +LoopFilterAcrossSubpicEnabledFlag : 0 0 1 # equal to 1 specifies that in-loop filtering operations may be performed across the boundaries of the i-th subpicture in each coded picture in the CLVS +SubPicIdMappingExplicitlySignalledFlag : 0 # equal to 1 specifies that the subpicture ID mapping is explicitly signalled, either in the SPS or in the PPSs +SubPicIdMappingInSpsFlag : 0 # specifies that subpicture ID mapping is signalled in the SPS(0: OFF, 1: ON) +SubPicIdLen : 0 # the number of bits used to represent the syntax element sps_subpic_id[ i ] +SubPicId : 0 # subpicture ID of the i-th subpicture + + +#============ Tiles / Slices ================ +EnablePicPartitioning : 1 # Enable picture partitioning (0: single tile, single slice, 1: multiple tiles/slices can be used) + +TileColumnWidthArray : 4 # Tile column widths in units of CTUs. Last column width will be repeated uniformly to cover any remaining picture width +TileRowHeightArray : 4 # Tile row heights in units of CTUs. Last row height will be repeated uniformly to cover any remaining picture height +RasterScanSlices : 0 # Raster-scan or rectangular slices (0: rectangular, 1: raster-scan) +RectSliceFixedWidth : 0 # Fixed rectangular slice width in units of tiles (0: disable this feature and use RectSlicePositions instead) +RectSliceFixedHeight : 0 # Fixed rectangular slice height in units of tiles (0: disable this feature and use RectSlicePositions instead) +RectSlicePositions : 0 24 4 13 18 27 +DisableLoopFilterAcrossTiles : 0 # Loop filtering (DBLK/SAO/ALF) applied across tile boundaries or not (0: filter across tile boundaries 1: do not filter across tile boundaries) +DisableLoopFilterAcrossSlices : 0 # Loop filtering (DBLK/SAO/ALF) applied across slice boundaries or not (0: filter across slice boundaries 1: do not filter across slice boundaries) diff --git a/cfg/partitioning/subpicture_3_slice_2_tile_1_slice_per_subpic.cfg b/cfg/partitioning/subpicture_3_slice_2_tile_1_slice_per_subpic.cfg new file mode 100644 index 0000000000000000000000000000000000000000..4c405d69e64b12aa3c6156efa11849e0b92d77c6 --- /dev/null +++ b/cfg/partitioning/subpicture_3_slice_2_tile_1_slice_per_subpic.cfg @@ -0,0 +1,39 @@ +# example cfg file, assuming an 832x480 input sequence with CTU size = 128x128, and split to 2 tiles, with two tile columns and one tile row. +# example 2 tiles, 3 subpictures (and each subpicture is a slice) in a 832x480 picture: +#---------- +#| | | +#| | | +#| |---| +#| | | +#| | | +#---------- +# | +# v +# vertically divided into 2 tile, the second tile include two subpicture/slices + +SubPicInfoPresentFlag : 1 # subpicture information present flag(0: OFF, 1: ON) +NumSubPics : 3 # number of subpictures in a picture +SubPicCtuTopLeftX : 0 4 4 # specifies horizontal position of top left CTU of i-th subpicture in unit of CtbSizeY +SubPicCtuTopLeftY : 0 0 2 # specifies vertical position of top left CTU of i-th subpicture in unit of CtbSizeY +SubPicWidth : 4 3 3 # specifies the width of the i-th subpicture in units of CtbSizeY +SubPicHeight : 4 2 2 # specifies the height of the i-th subpicture in units of CtbSizeY +SubPicTreatedAsPicFlag : 1 1 1 # equal to 1 specifies that the i-th subpicture of each coded picture in the CLVS is treated as a picture in the decoding process excluding in-loop filtering operations +LoopFilterAcrossSubpicEnabledFlag : 0 0 0 # equal to 1 specifies that in-loop filtering operations may be performed across the boundaries of the i-th subpicture in each coded picture in the CLVS +SubPicIdMappingExplicitlySignalledFlag : 0 # equal to 1 specifies that the subpicture ID mapping is explicitly signalled, either in the SPS or in the PPSs +SubPicIdMappingInSpsFlag : 0 # specifies that subpicture ID mapping is signalled in the SPS(0: OFF, 1: ON) +SubPicIdLen : 0 # the number of bits used to represent the syntax element sps_subpic_id[ i ] +SubPicId : 0 # subpicture ID of the i-th subpicture + + +#============ Tiles / Slices ================ +EnablePicPartitioning : 1 # Enable picture partitioning (0: single tile, single slice, 1: multiple tiles/slices can be used) +SingleSlicePerSubpic : 1 + +TileColumnWidthArray : 4 # Tile column widths in units of CTUs. Last column width will be repeated uniformly to cover any remaining picture width +TileRowHeightArray : 4 # Tile row heights in units of CTUs. Last row height will be repeated uniformly to cover any remaining picture height +RasterScanSlices : 0 # Raster-scan or rectangular slices (0: rectangular, 1: raster-scan) +RectSliceFixedWidth : 0 # Fixed rectangular slice width in units of tiles (0: disable this feature and use RectSlicePositions instead) +RectSliceFixedHeight : 0 # Fixed rectangular slice height in units of tiles (0: disable this feature and use RectSlicePositions instead) +RectSlicePositions : 0 24 4 13 18 27 +DisableLoopFilterAcrossTiles : 0 # Loop filtering (DBLK/SAO/ALF) applied across tile boundaries or not (0: filter across tile boundaries 1: do not filter across tile boundaries) +DisableLoopFilterAcrossSlices : 0 # Loop filtering (DBLK/SAO/ALF) applied across slice boundaries or not (0: filter across slice boundaries 1: do not filter across slice boundaries) diff --git a/cfg/nonCTC-SliceConfigExamples/subpicture_4Slice2HorSubPic.cfg b/cfg/partitioning/subpicture_4_slice_2_hor_subpic.cfg similarity index 100% rename from cfg/nonCTC-SliceConfigExamples/subpicture_4Slice2HorSubPic.cfg rename to cfg/partitioning/subpicture_4_slice_2_hor_subpic.cfg diff --git a/cfg/partitioning/subpicture_4_slice_2_tiles_4_subpic.cfg b/cfg/partitioning/subpicture_4_slice_2_tiles_4_subpic.cfg new file mode 100644 index 0000000000000000000000000000000000000000..6f70f813f73c505a2afd9648be60172b396c948e --- /dev/null +++ b/cfg/partitioning/subpicture_4_slice_2_tiles_4_subpic.cfg @@ -0,0 +1,38 @@ +# example cfg file, assuming an 832x480 input sequence with CTU size = 128x128, and split to 2 tiles, with two tile columns and one tile row. +# example 2 tiles, 4 subpictures (and each subpicture is a slice) in a 832x480 picture: +#---------- +#| | | +#| | | +#|----|---| +#| | | +#| | | +#---------- +# | +# v +# vertically divided into 2 tile, each tile includes two subpictures/slices + +SubPicInfoPresentFlag : 1 # subpicture information present flag(0: OFF, 1: ON) +NumSubPics : 4 # number of subpictures in a picture +SubPicCtuTopLeftX : 0 0 4 4 # specifies horizontal position of top left CTU of i-th subpicture in unit of CtbSizeY +SubPicCtuTopLeftY : 0 2 0 2 # specifies vertical position of top left CTU of i-th subpicture in unit of CtbSizeY +SubPicWidth : 4 4 3 3 # specifies the width of the i-th subpicture in units of CtbSizeY +SubPicHeight : 2 2 2 2 # specifies the height of the i-th subpicture in units of CtbSizeY +SubPicTreatedAsPicFlag : 1 1 1 1 # equal to 1 specifies that the i-th subpicture of each coded picture in the CLVS is treated as a picture in the decoding process excluding in-loop filtering operations +LoopFilterAcrossSubpicEnabledFlag : 0 0 0 0 # equal to 1 specifies that in-loop filtering operations may be performed across the boundaries of the i-th subpicture in each coded picture in the CLVS +SubPicIdMappingExplicitlySignalledFlag : 0 # equal to 1 specifies that the subpicture ID mapping is explicitly signalled, either in the SPS or in the PPSs +SubPicIdMappingInSpsFlag : 0 # specifies that subpicture ID mapping is signalled in the SPS(0: OFF, 1: ON) +SubPicIdLen : 0 # the number of bits used to represent the syntax element sps_subpic_id[ i ] +SubPicId : 0 # subpicture ID of the i-th subpicture + + +#============ Tiles / Slices ================ +EnablePicPartitioning : 1 # Enable picture partitioning (0: single tile, single slice, 1: multiple tiles/slices can be used) + +TileColumnWidthArray : 4 # Tile column widths in units of CTUs. Last column width will be repeated uniformly to cover any remaining picture width +TileRowHeightArray : 4 # Tile row heights in units of CTUs. Last row height will be repeated uniformly to cover any remaining picture height +RasterScanSlices : 0 # Raster-scan or rectangular slices (0: rectangular, 1: raster-scan) +RectSliceFixedWidth : 0 # Fixed rectangular slice width in units of tiles (0: disable this feature and use RectSlicePositions instead) +RectSliceFixedHeight : 0 # Fixed rectangular slice height in units of tiles (0: disable this feature and use RectSlicePositions instead) +RectSlicePositions : 0 10 14 24 4 13 18 27 +DisableLoopFilterAcrossTiles : 1 # Loop filtering (DBLK/SAO/ALF) applied across tile boundaries or not (0: filter across tile boundaries 1: do not filter across tile boundaries) +DisableLoopFilterAcrossSlices : 1 # Loop filtering (DBLK/SAO/ALF) applied across slice boundaries or not (0: filter across slice boundaries 1: do not filter across slice boundaries) diff --git a/cfg/nonCTC-SliceConfigExamples/subpicture_4Slice2VerSubPic.cfg b/cfg/partitioning/subpicture_4_slice_2_ver_subpic.cfg similarity index 100% rename from cfg/nonCTC-SliceConfigExamples/subpicture_4Slice2VerSubPic.cfg rename to cfg/partitioning/subpicture_4_slice_2_ver_subpic.cfg diff --git a/cfg/nonCTC-SliceConfigExamples/TwoSubpictures_with_EightSlices.cfg b/cfg/partitioning/subpicture_8_slice_12_tile_2_subpic.cfg similarity index 97% rename from cfg/nonCTC-SliceConfigExamples/TwoSubpictures_with_EightSlices.cfg rename to cfg/partitioning/subpicture_8_slice_12_tile_2_subpic.cfg index 3371a0a7bc0afedc3fbda16f3a086b644ed770e6..8cf2372e596f1c682c08e55d1fd908d0c8305562 100644 --- a/cfg/nonCTC-SliceConfigExamples/TwoSubpictures_with_EightSlices.cfg +++ b/cfg/partitioning/subpicture_8_slice_12_tile_2_subpic.cfg @@ -1,8 +1,5 @@ # example cfg file, assuming an 1920x1080 input sequence with CTU size = 128x128, and split to 8 rectangular slices, 12 tiles and 2 subpictures -SourceWidth : 1920 -SourceHeight : 1080 - SubPicInfoPresentFlag : 1 # subpicture information present flag(0: OFF, 1: ON) NumSubPics : 2 # number of subpictures in a picture SubPicCtuTopLeftX : 0 11 # specifies horizontal position of top left CTU of i-th subpicture in unit of CtbSizeY diff --git a/cfg/per-class/formatRGB.cfg b/cfg/per-class/formatRGB.cfg index fe065ff2f0920a6d63e87687c136e6dbe9ccfc82..a761a1d399d7f31d22a14c54e53b6aa38a0683e9 100644 --- a/cfg/per-class/formatRGB.cfg +++ b/cfg/per-class/formatRGB.cfg @@ -1,2 +1,3 @@ ColorTransform : 1 -Log2MaxTbSize : 5 \ No newline at end of file +Log2MaxTbSize : 5 +DualITree: 0 \ No newline at end of file diff --git a/cfg/scaling_list/sample_scaling_list.cfg b/cfg/scaling_list/sample_scaling_list.cfg new file mode 100644 index 0000000000000000000000000000000000000000..1f343d579d57cf91d471c90f60e74fef3235ca25 --- /dev/null +++ b/cfg/scaling_list/sample_scaling_list.cfg @@ -0,0 +1,3 @@ +#============ Scaling List ====================== +ScalingList : 2 # Scaling list: 0: no scaling list, 2: scaling lists specified in ScalingListFile +ScalingListFile : sample_scaling_list_file.txt diff --git a/cfg/scaling_list/sample_scaling_list_file.txt b/cfg/scaling_list/sample_scaling_list_file.txt new file mode 100644 index 0000000000000000000000000000000000000000..c0b827a63193163b952ba897b9e972b09d1bc8fb --- /dev/null +++ b/cfg/scaling_list/sample_scaling_list_file.txt @@ -0,0 +1,304 @@ +# ScalingListFile +# The matrices in this sample file are inherited from JCTVC-H1104. + +INTRA2X2_LUMA = + 7,19 + 19,41 + +INTRA2X2_CHROMAU = + 7,19 + 19,41 + +INTRA2X2_CHROMAV = + 7,19 + 19,41 + +INTER2X2_LUMA = + 11,30 + 30,50 + +INTER2X2_CHROMAU = + 11,30 + 30,50 + +INTER2X2_CHROMAV = + 11,30 + 30,50 + +INTRA4X4_LUMA = + 7,12,19,26 +12,16,24,40 +19,24,41,50 +26,40,50,56 + +INTRA4X4_CHROMAU = + 7,12,19,26 +12,16,24,40 +19,24,41,50 +26,40,50,56 + +INTRA4X4_CHROMAV = + 7,12,19,26 +12,16,24,40 +19,24,41,50 +26,40,50,56 + +INTER4X4_LUMA = +11,18,30,43 +18,22,40,50 +30,40,50,52 +43,50,52,55 + +INTER4X4_CHROMAU = +11,18,30,43 +18,22,40,50 +30,40,50,52 +43,50,52,55 + +INTER4X4_CHROMAV = +11,18,30,43 +18,22,40,50 +30,40,50,52 +43,50,52,55 + +INTRA8X8_LUMA = + 6, 9,13,18,25,35,36,37 + 9,10,15,21,32,35,37,41 +13,15,18,23,35,55,58,59 +18,21,23,26,65,58,64,66 +25,32,35,65,66,66,67,70 +35,35,55,58,66,68,70,73 +36,37,58,64,67,70,76,80 +37,41,59,66,70,73,80,85 + +INTRA8X8_CHROMAU = + 6, 9,13,18,25,35,36,37 + 9,10,15,21,32,35,37,41 +13,15,18,23,35,55,58,59 +18,21,23,26,65,58,64,66 +25,32,35,65,66,66,67,70 +35,35,55,58,66,68,70,73 +36,37,58,64,67,70,76,80 +37,41,59,66,70,73,80,85 + +INTRA8X8_CHROMAV = + 6, 9,13,18,25,35,36,37 + 9,10,15,21,32,35,37,41 +13,15,18,23,35,55,58,59 +18,21,23,26,65,58,64,66 +25,32,35,65,66,66,67,70 +35,35,55,58,66,68,70,73 +36,37,58,64,67,70,76,80 +37,41,59,66,70,73,80,85 + +INTER8X8_LUMA = + 9,15,20,29,36,38,42,43 +15,17,22,29,39,43,45,46 +20,22,32,34,47,48,49,50 +29,29,34,44,50,51,52,53 +36,39,47,50,51,52,55,55 +38,43,48,51,52,53,56,58 +42,45,49,52,55,56,55,60 +43,46,50,53,55,58,60,63 + +INTER8X8_CHROMAU = + 9,15,20,29,36,38,42,43 +15,17,22,29,39,43,45,46 +20,22,32,34,47,48,49,50 +29,29,34,44,50,51,52,53 +36,39,47,50,51,52,55,55 +38,43,48,51,52,53,56,58 +42,45,49,52,55,56,55,60 +43,46,50,53,55,58,60,63 + +INTER8X8_CHROMAV = + 9,15,20,29,36,38,42,43 +15,17,22,29,39,43,45,46 +20,22,32,34,47,48,49,50 +29,29,34,44,50,51,52,53 +36,39,47,50,51,52,55,55 +38,43,48,51,52,53,56,58 +42,45,49,52,55,56,55,60 +43,46,50,53,55,58,60,63 + +INTRA16X16_LUMA = + 6, 9,13,18,25,35,36,37 + 9,10,15,21,32,35,37,41 +13,15,18,23,35,55,58,59 +18,21,23,26,65,58,64,66 +25,32,35,65,66,66,67,70 +35,35,55,58,66,68,70,73 +36,37,58,64,67,70,76,80 +37,41,59,66,70,73,80,85 + +INTRA16X16_LUMA_DC = +6 + +INTRA16X16_CHROMAU = + 7, 9,13,18,25,35,36,37 + 9,10,15,21,32,35,37,41 +13,15,18,23,35,55,58,59 +18,21,23,26,65,58,64,66 +25,32,35,65,66,66,67,70 +35,35,55,58,66,68,70,73 +36,37,58,64,67,70,76,80 +37,41,59,66,70,73,80,85 + +INTRA16X16_CHROMAU_DC = +6 + +INTRA16X16_CHROMAV = + 7, 9,13,18,25,35,36,37 + 9,10,15,21,32,35,37,41 +13,15,18,23,35,55,58,59 +18,21,23,26,65,58,64,66 +25,32,35,65,66,66,67,70 +35,35,55,58,66,68,70,73 +36,37,58,64,67,70,76,80 +37,41,59,66,70,73,80,85 + +INTRA16X16_CHROMAV_DC = +6 + +INTER16X16_LUMA = +11,15,20,29,36,38,42,43 +15,17,22,29,39,43,45,46 +20,22,32,34,47,48,49,50 +29,29,34,44,50,51,52,53 +36,39,47,50,51,52,55,55 +38,43,48,51,52,53,56,58 +42,45,49,52,55,56,55,60 +43,46,50,53,55,58,60,63 + +INTER16X16_LUMA_DC = +9 + +INTER16X16_CHROMAU = +11,15,20,29,36,38,42,43 +15,17,22,29,39,43,45,46 +20,22,32,34,47,48,49,50 +29,29,34,44,50,51,52,53 +36,39,47,50,51,52,55,55 +38,43,48,51,52,53,56,58 +42,45,49,52,55,56,55,60 +43,46,50,53,55,58,60,63 + +INTER16X16_CHROMAU_DC = +9 + +INTER16X16_CHROMAV = +11,15,20,29,36,38,42,43 +15,17,22,29,39,43,45,46 +20,22,32,34,47,48,49,50 +29,29,34,44,50,51,52,53 +36,39,47,50,51,52,55,55 +38,43,48,51,52,53,56,58 +42,45,49,52,55,56,55,60 +43,46,50,53,55,58,60,63 + +INTER16X16_CHROMAV_DC = +9 + +INTRA32X32_LUMA = + 7, 9,13,18,25,35,36,37 + 9,10,15,21,32,35,37,41 +13,15,18,23,35,55,58,59 +18,21,23,26,65,58,64,66 +25,32,35,65,66,66,67,70 +35,35,55,58,66,68,70,73 +36,37,58,64,67,70,76,80 +37,41,59,66,70,73,80,85 + +INTRA32X32_LUMA_DC = +6 + +INTRA32X32_CHROMAU = + 7, 9,13,18,25,35,36,37 + 9,10,15,21,32,35,37,41 +13,15,18,23,35,55,58,59 +18,21,23,26,65,58,64,66 +25,32,35,65,66,66,67,70 +35,35,55,58,66,68,70,73 +36,37,58,64,67,70,76,80 +37,41,59,66,70,73,80,85 + +INTRA32X32_CHROMAU_DC = +6 + +INTRA32X32_CHROMAV = + 7, 9,13,18,25,35,36,37 + 9,10,15,21,32,35,37,41 +13,15,18,23,35,55,58,59 +18,21,23,26,65,58,64,66 +25,32,35,65,66,66,67,70 +35,35,55,58,66,68,70,73 +36,37,58,64,67,70,76,80 +37,41,59,66,70,73,80,85 + +INTRA32X32_CHROMAV_DC = +6 + +INTER32X32_LUMA = +11,15,20,29,36,38,42,43 +15,17,22,29,39,43,45,46 +20,22,32,34,47,48,49,50 +29,29,34,44,50,51,52,53 +36,39,47,50,51,52,55,55 +38,43,48,51,52,53,56,58 +42,45,49,52,55,56,55,60 +43,46,50,53,55,58,60,63 + +INTER32X32_LUMA_DC = +9 + +INTER32X32_CHROMAU = +11,15,20,29,36,38,42,43 +15,17,22,29,39,43,45,46 +20,22,32,34,47,48,49,50 +29,29,34,44,50,51,52,53 +36,39,47,50,51,52,55,55 +38,43,48,51,52,53,56,58 +42,45,49,52,55,56,55,60 +43,46,50,53,55,58,60,63 + +INTER32X32_CHROMAU_DC = +9 + +INTER32X32_CHROMAV = +11,15,20,29,36,38,42,43 +15,17,22,29,39,43,45,46 +20,22,32,34,47,48,49,50 +29,29,34,44,50,51,52,53 +36,39,47,50,51,52,55,55 +38,43,48,51,52,53,56,58 +42,45,49,52,55,56,55,60 +43,46,50,53,55,58,60,63 + +INTER32X32_CHROMAV_DC = +9 + +INTRA64X64_LUMA = + 7, 9,13,18,25,35,36,37 + 9,10,15,21,32,35,37,41 +13,15,18,23,35,55,58,59 +18,21,23,26,65,58,64,66 +25,32,35,65,66,66,67,70 +35,35,55,58,66,68,70,73 +36,37,58,64,67,70,76,80 +37,41,59,66,70,73,80,85 + +INTRA64X64_LUMA_DC = +6 + +INTER64X64_LUMA = +11,15,20,29,36,38,42,43 +15,17,22,29,39,43,45,46 +20,22,32,34,47,48,49,50 +29,29,34,44,50,51,52,53 +36,39,47,50,51,52,55,55 +38,43,48,51,52,53,56,58 +42,45,49,52,55,56,55,60 +43,46,50,53,55,58,60,63 + +INTER64X64_LUMA_DC = +9 diff --git a/cfg/sei_vui/timing.cfg b/cfg/sei_vui/timing.cfg index 63f37a73919737867258e173f4c611176003d05d..12125434e73b93d404abd232b736306c0c1b7fee 100644 --- a/cfg/sei_vui/timing.cfg +++ b/cfg/sei_vui/timing.cfg @@ -1,4 +1,4 @@ SEIBufferingPeriod: 1 SEIPictureTiming: 1 -VuiParametersPresent: 1 +HrdParametersPresent: 1 RCCpbSize: 2000 diff --git a/cfg/sei_vui/vui_HD.cfg b/cfg/sei_vui/vui_HD.cfg index 6705b1da5f934e0d1d41b4d9bf627a1af0b97073..394aa6485089e30c08d76e44f576b7c69928b1fc 100644 --- a/cfg/sei_vui/vui_HD.cfg +++ b/cfg/sei_vui/vui_HD.cfg @@ -8,6 +8,8 @@ ColourPrimaries: 1 // the source colour primaries according TransferCharacteristics: 1 // transfer characteristics function according to Rec. ITU-T H.273 | ISO/IEC 23091-2 MatrixCoefficients: 1 // the formulae used in deriving luma and chroma signals acc. to Rec. ITU-T H.273 | ISO/IEC 23091-2 VideoFullRange: 0 // scaling and offset values applied according to Rec. ITU-T H.273 | ISO/IEC 23091-2 +ProgressiveSource: 1 // indicates if content is progressive +InterlacedSource: 0 // indicates if content is interlaced ChromaLocInfoPresent: 1 // enable presence of chroma location information ChromaSampleLocTypeTopField: 0 // the location of chroma sample top field ChromaSampleLocTypeBottomField: 0 // the location of chroma sample bottom field diff --git a/cfg/sei_vui/vui_UHD_PQ.cfg b/cfg/sei_vui/vui_UHD_PQ.cfg index 717815029e845436e2f792e9b0d6015c9014e610..ec337fe50a497f4c92a7220653252e20231c2f41 100644 --- a/cfg/sei_vui/vui_UHD_PQ.cfg +++ b/cfg/sei_vui/vui_UHD_PQ.cfg @@ -8,6 +8,8 @@ ColourPrimaries: 9 // the source colour primaries according TransferCharacteristics: 16 // transfer characteristics function according to Rec. ITU-T H.273 | ISO/IEC 23091-2 MatrixCoefficients: 9 // the formulae used in deriving luma and chroma signals acc. to Rec. ITU-T H.273 | ISO/IEC 23091-2 VideoFullRange: 0 // scaling and offset values applied according to Rec. ITU-T H.273 | ISO/IEC 23091-2 +ProgressiveSource: 1 // Indicates if content is progressive +InterlacedSource: 0 // Indicates if content is interlaced ChromaLocInfoPresent: 1 // enable presence of chroma location information ChromaSampleLocTypeTopField: 2 // the location of chroma sample top field ChromaSampleLocTypeBottomField: 2 // the location of chroma sample bottom field diff --git a/doc/software-manual.pdf b/doc/software-manual.pdf index 43f69204a6c9fc01cd4a17f3531bfeb2d6ae0cd2..f5e228c5d51fc520377531994ea111853b0cb95b 100644 Binary files a/doc/software-manual.pdf and b/doc/software-manual.pdf differ diff --git a/doc/software-manual.tex b/doc/software-manual.tex index 99f1f3b45244ff6027815d8c1f19af8777f9110a..400706a62a5387654fdfd0c49150cdfe07a41523 100644 --- a/doc/software-manual.tex +++ b/doc/software-manual.tex @@ -205,7 +205,7 @@ fontsize=\footnotesize} \maketitle \begin{abstract} This document is a user manual describing usage of the VTM reference software -for the VVC project. It applies to version 8.0 of the software. +for the VVC project. It applies to version 8.1 of the software. \end{abstract} \tableofcontents @@ -1028,34 +1028,34 @@ For --profile=main-RExt, specifies the value of general_one_picture_only_constra Specifies the value of general_lower_bit_constraint_flag to use for RExt profiles. \\ -\Option{ProgressiveSource} & +\Option{NonPackedSource} & %\ShortOption{\None} & \Default{false} & -Specifies the value of general_progressive_source_flag +Specifies the value of general_non_packed_constraint_flag \\ -\Option{InterlacedSource} & +\Option{NonProjectedConstraintFlag} & %\ShortOption{\None} & \Default{false} & -Specifies the value of general_interlaced_source_flag +Specifies the value of general_non_projected_constraint_flag \\ -\Option{NonPackedSource} & +\Option{NoResChangeInClvsConstraintFlag} & %\ShortOption{\None} & \Default{false} & -Specifies the value of general_non_packed_constraint_flag +Specifies the value of no_res_change_in_clvs_constraint_flag \\ -\Option{NonProjectedConstraintFlag} & +\Option{SingleLayerConstraintFlag} & %\ShortOption{\None} & \Default{false} & -Specifies the value of general_non_projected_constraint_flag +Specifies the value of single_layer_constraint_flag \\ -\Option{NoResChangeInClvsConstraintFlag} & +\Option{AllLayersIndependentConstraintFlag} & %\ShortOption{\None} & \Default{false} & -Specifies the value of no_res_change_in_clvs_constraint_flag +Specifies the value of all_layers_independent_constraint_flag \\ \Option{OneTilePerPicConstraintFlag} & @@ -1082,24 +1082,6 @@ Specifies the value of one_subpic_per_pic_constraint_flag Specifies the value of general_frame_only_constraint_flag \\ -\Option{SubPicInfoPresentFlag} & -%\ShortOption{\None} & -\Default{false} & -Specifies the value of subpicture subpic_info_present_flag -\\ - -\Option{SubPicIdMappingExplicitlySignalledFlag} & -%\ShortOption{\None} & -\Default{false} & -Specifies the value of subpicture subpic_id_mapping_explicitly_signalled_flag -\\ - -\Option{SubPicIdMappingInSpsFlag} & -%\ShortOption{\None} & -\Default{false} & -Specifies the value of subpicture subpic_id_mapping_in_sps_flag -\\ - \end{OptionTableNoShorthand} @@ -1185,6 +1167,13 @@ Specifies the level to signal in the i-th PTL of the VPS (with i an integer grea \Default{0} & Specifies the index of the PTL that applies to the i-th OLS (with i an integer greater than 0) \\ + +\Option{SamePicTimingInAllOLS} & +%\ShortOption{\None} & +\Default{1} & +Indicates that all OLSs are using the same (not nested) picture timing SEI message, i.e. picture timing SEI will not +be included in scalable nesting SEI messages (if scalable nesting SEI is enabled). +\\ \end{OptionTableNoShorthand} @@ -1953,6 +1942,18 @@ is output and the encoder stops. Specifies whether scaling matrices are to be applied to blocks coded with LFNST. \\ +\Option{DisableScalingMatrixForAlternativeColourSpace} & +%\ShortOption{\None} & +\Default{true} & +Specifies whether scaling matrices are disabled to blocks when the colour space is not equal to the designated colour space of scaling matrices. +\\ + +\Option{ScalingMatrixDesignatedColourSpace} & +%\ShortOption{\None} & +\Default{true} & +Indicates if the designated colour space of scaling matrices is equal to the original colour space. +\\ + \Option{MaxCUChromaQpAdjustmentDepth} & %\ShortOption{\None} & \Default{-1} & @@ -1991,6 +1992,12 @@ Tile row heights in units of CTUs. Last row height in list will be repeated unif Use raster-scan or rectangular slices (0: rectangular, 1: raster-scan). \\ +\Option{SingleSlicePerSubpic} & +%\ShortOption{\None} & +\Default{false} & +Enables slice layout derivation from subpicture layout. Requires more than one subpicture to be enabled. If enabled, all other slice layout parameters will be ignored. +\\ + \Option{RectSlicePositions} & %\ShortOption{\None} & \Default{\NotSet} & @@ -2048,19 +2055,93 @@ Allow signalling of entry points for WPP in slice header. Note that when a slice contains more than one tile, entry point offsets for tile are always present in the slice header. \\ +\Option{SliceLosslessArray} & +%\ShortOption{\None} & +\Default{0} & +Define pattern of lossless coding in unit of slices, 0 means lossy slice; 1 means lossless slice. Example: 1 1 0 0 means first 2 slices are lossless coded and rest of the slices are lossy coded. Default is all slices are lossy coded. +\\ + \end{OptionTableNoShorthand} %% -%% Slice/Sub-Picture coding parameters +%% Subpicture coding parameters %% -\begin{OptionTableNoShorthand}{Slice and Sub-Picture coding parameters}{tab:subpicture-coding} +\begin{OptionTableNoShorthand}{Subpicture coding parameters}{tab:subpicture-coding} -\Option{EnableSubPicPartitioning} & +\Option{SubPicInfoPresentFlag} & %\ShortOption{\None} & -\Default{1} & -Enable Sub Picture partitioning (0: single slice per sub-picture, 1: multiple slices per sub-picture can be used). +\Default{false} & +Enables conding of subpictures. \\ +\Option{NumSubPics} & +%\ShortOption{\None} & +\Default{0} & +Number of subpictures. Must be greater that zero, if SubPicInfoPresentFlag is enabled. +\\ + +\Option{SubPicCtuTopLeftX} & +%\ShortOption{\None} & +\Default{\None} & +Array of subpicture top left horizontal (x) coordinates. The number of entries must be equal to NumSubPics. +\\ + +\Option{SubPicCtuTopLeftY} & +%\ShortOption{\None} & +\Default{\None} & +Array of subpicture top left vertical (y) coordinates. The number of entries must be equal to NumSubPics. +\\ + +\Option{SubPicWidth} & +%\ShortOption{\None} & +\Default{\None} & +Array of subpicture widths. The number of entries must be equal to NumSubPics. +\\ + +\Option{SubPicHeight} & +%\ShortOption{\None} & +\Default{\None} & +Array of subpicture heights. The number of entries must be equal to NumSubPics. +\\ + +\Option{SubPicTreatedAsPicFlag} & +%\ShortOption{\None} & +\Default{\None} & +Setting of subpic_treated_as_pic_flag for each subpicture. If enabled subpicture boundaries will be treated as picture boundaries. The number of entries must be equal to NumSubPics. +\\ + +\Option{LoopFilterAcrossSubpicEnabledFlag} & +%\ShortOption{\None} & +\Default{\None} & +Enables loop filtering across subpicture boundaries for each subpicture. The number of entries must be equal to NumSubPics. +\\ + +\Option{SubPicIdMappingExplicitlySignalledFlag} & +%\ShortOption{\None} & +\Default{false} & +Enables explicit signalling of a subpicture ID map. If disabled, a default map will be derived. +\\ + +\Option{SubPicIdMappingInSpsFlag} & +%\ShortOption{\None} & +\Default{false} & +Specifies wheter to signal the subpicture ID map in SPS or PPS. If SubPicIdMappingInSpsFlag is enabled subpicture IDs are signalled in SPS, otherwise in PPS. +\\ + +\Option{SubPicIdLen} & +%\ShortOption{\None} & +\Default{0} & +Length of the subpicture IDs in bits. (1<<SubPicIdLen) must be bigger than the number of subpictures and the highes subpicture ID specifid in SubPicId. +If the value "0" is used, the encoder tries to determine the number of required bits from the number of subpictures or the highest subpicture ID. This mode should not be used, if merging of bistreams is intended. +\\ + +\Option{SubPicId} & +%\ShortOption{\None} & +\Default{\None} & +Array of subpicture IDs. The number of entries must be equal to NumSubPics. +\\ + + \end{OptionTableNoShorthand} %% @@ -2604,6 +2685,12 @@ Specifies location of a chroma sample relatively to the luma sample in vertical \end{tabular} \\ +\Option{TSRCdisableLL} & +%\ShortOption{\None} & +\Default{1} & +Enables or disables the use of Transform Skip Residual Coding for lossless compression. +\\ + \end{OptionTableNoShorthand} %% @@ -2797,6 +2884,14 @@ Indicates the black level and range of luma and chroma signals. 1 & Indicates that the luma and chroma signals are not to be scaled prior to display. \\ \end{tabular} \\ +\Option{ProgressiveSource} & +\Default{false} & +Specifies the value of general_progressive_source_flag +\\ +\Option{InterlacedSource} & +\Default{false} & +Specifies the value of general_interlaced_source_flag +\\ \Option{ChromaLocInfoPresent} & \Default{false} & Signals whether chroma_sample_loc_type_top_field and chroma_sample_loc_type_bottom_field are present. diff --git a/source/App/BitstreamExtractorApp/BitstreamExtractorApp.cpp b/source/App/BitstreamExtractorApp/BitstreamExtractorApp.cpp index 2bc0dc4a926c37436eb229daad10bd31fb9abc64..f7013fd8d3c0761038fcf5f90cd1c2fc62dd8a7f 100644 --- a/source/App/BitstreamExtractorApp/BitstreamExtractorApp.cpp +++ b/source/App/BitstreamExtractorApp/BitstreamExtractorApp.cpp @@ -46,9 +46,11 @@ #include "EncoderLib/AnnexBwrite.h" BitstreamExtractorApp::BitstreamExtractorApp() -#if JVET_P0118_OLS_EXTRACTION :m_vpsId(-1) +#if JVET_Q0394_TIMING_SEI +, m_removeTimingSEI (false) #endif + { } @@ -79,7 +81,6 @@ void BitstreamExtractorApp::xPrintVPSInfo (VPS *vps) } } -#if JVET_Q0397_SUB_PIC_EXTRACT void BitstreamExtractorApp::xPrintSubPicInfo (PPS *pps) { msg (VERBOSE, "Subpic Info: \n"); @@ -116,7 +117,7 @@ bool BitstreamExtractorApp::xCheckSliceSubpicture(InputNALUnit &nalu, int target slice.setTLayer(nalu.m_temporalId); m_hlSynaxReader.parseSliceHeader(&slice, &m_picHeader, &m_parameterSetManager, m_prevTid0Poc); - + PPS *pps = m_parameterSetManager.getPPS(m_picHeader.getPPSId()); CHECK (nullptr==pps, "referenced PPS not found"); SPS *sps = m_parameterSetManager.getSPS(pps->getSPSId()); @@ -132,7 +133,7 @@ bool BitstreamExtractorApp::xCheckSliceSubpicture(InputNALUnit &nalu, int target { THROW ("Subpicture signalling disbled, cannot extract."); } - + return true; } @@ -182,7 +183,7 @@ void BitstreamExtractorApp::xRewritePPS (PPS &targetPPS, const PPS &sourcePPS, S } } numTileCols=(int)tileColBd.size() - 1; - CHECK (numTileCols < 1, "After extraction there should be at least one tile horizonally.") + CHECK (numTileCols < 1, "After extraction there should be at least one tile horizonally."); tileColWidth.resize(numTileCols); for (int i=0; i<numTileCols; i++) { @@ -201,7 +202,34 @@ void BitstreamExtractorApp::xRewritePPS (PPS &targetPPS, const PPS &sourcePPS, S } } numTileRows=(int)tileRowBd.size() - 1; - CHECK (numTileRows < 1, "After extraction there should be at least one tile vertically.") + // if subpicture was part of a tile, top and/or bottom borders need to be added + // note: this can only happen with vertical slice splits of a tile + if (numTileRows < 1 ) + { + if (tileRowBd.size()==0) + { + tileRowBd.push_back(0); + tileRowBd.push_back(subPic.getSubPicHeightInCTUs()); + numTileRows+=2; + } + else + { + if (tileRowBd[0] == 0) + { + // top border exists, add bottom + tileRowBd.push_back(subPic.getSubPicHeightInCTUs()); + numTileRows++; + } + else + { + // bottom border exists, add top + const int row1 = tileRowBd[0]; + tileRowBd[0] = 0; + tileRowBd.push_back(row1); + numTileRows++; + } + } + } tileRowHeight.resize(numTileRows); for (int i=0; i<numTileRows; i++) { @@ -255,7 +283,6 @@ void BitstreamExtractorApp::xRewritePPS (PPS &targetPPS, const PPS &sourcePPS, S } -#endif void BitstreamExtractorApp::xWriteVPS(VPS *vps, std::ostream& out, int layerId, int temporalId) { @@ -384,9 +411,7 @@ uint32_t BitstreamExtractorApp::decode() // get VPS back vps = m_parameterSetManager.getVPS(vpsId); xPrintVPSInfo(vps); -#if JVET_P0118_OLS_EXTRACTION m_vpsId = vps->getVPSId(); -#endif // example: just write the parsed VPS back to the stream // *** add modifications here *** // only write, if not dropped earlier @@ -397,7 +422,6 @@ uint32_t BitstreamExtractorApp::decode() } } -#if JVET_P0118_OLS_EXTRACTION VPS *vps = nullptr; if (m_targetOlsIdx >= 0) { @@ -420,9 +444,11 @@ uint32_t BitstreamExtractorApp::decode() std::vector<int> LayerIdInOls = vps->getLayerIdsInOls(m_targetOlsIdx); bool isIncludedInTargetOls = std::find(LayerIdInOls.begin(), LayerIdInOls.end(), nalu.m_nuhLayerId) != LayerIdInOls.end(); writeInpuNalUnitToStream &= (isSpecialNalTypes || isIncludedInTargetOls); +#if JVET_Q0394_TIMING_SEI + m_removeTimingSEI = !vps->getGeneralHrdParameters()->getGeneralSamePicTimingInAllOlsFlag(); +#endif } } -#endif if( nalu.m_nalUnitType == NAL_UNIT_SPS ) { SPS* sps = new SPS(); @@ -439,7 +465,6 @@ uint32_t BitstreamExtractorApp::decode() // *** add modifications here *** // only write, if not dropped earlier // rewrite the SPS -#if JVET_Q0397_SUB_PIC_EXTRACT if (m_subPicId >= 0) { // we generally don't write SPS to the bitstream unless referred to by PPS @@ -447,7 +472,6 @@ uint32_t BitstreamExtractorApp::decode() xSetSPSUpdated(sps->getSPSId()); writeInpuNalUnitToStream = false; } -#endif if (writeInpuNalUnitToStream) { xWriteSPS(sps, bitstreamFileOut, nalu.m_nuhLayerId, nalu.m_temporalId); @@ -467,7 +491,6 @@ uint32_t BitstreamExtractorApp::decode() pps = m_parameterSetManager.getPPS(ppsId); msg (VERBOSE, "PPS Info: PPS ID = %d\n", pps->getPPSId()); -#if JVET_Q0397_SUB_PIC_EXTRACT SPS *sps = m_parameterSetManager.getSPS(pps->getSPSId()); if ( nullptr == sps) { @@ -481,7 +504,7 @@ uint32_t BitstreamExtractorApp::decode() { SubPic subPic; bool found = false; - + for (int i=0; i< pps->getNumSubPics() && !found; i++) { subPic = pps->getSubPic(i); @@ -509,7 +532,6 @@ uint32_t BitstreamExtractorApp::decode() writeInpuNalUnitToStream = false; } } -#endif // example: just write the parsed PPS back to the stream // *** add modifications here *** @@ -520,7 +542,6 @@ uint32_t BitstreamExtractorApp::decode() writeInpuNalUnitToStream = false; } } -#if JVET_Q0397_SUB_PIC_EXTRACT // when re-using code for slice header parsing, we need to store APSs if( ( nalu.m_nalUnitType == NAL_UNIT_PREFIX_APS ) || ( nalu.m_nalUnitType == NAL_UNIT_SUFFIX_APS )) { @@ -539,8 +560,6 @@ uint32_t BitstreamExtractorApp::decode() { xReadPicHeader(nalu); } -#endif -#if JVET_P0118_OLS_EXTRACTION if (m_targetOlsIdx>=0) { if (nalu.m_nalUnitType == NAL_UNIT_PREFIX_SEI) @@ -570,7 +589,11 @@ uint32_t BitstreamExtractorApp::decode() } } // remove unqualified timing related SEI +#if JVET_Q0394_TIMING_SEI + if (sei->payloadType() == SEI::BUFFERING_PERIOD || (m_removeTimingSEI && sei->payloadType() == SEI::PICTURE_TIMING ) || sei->payloadType() == SEI::DECODING_UNIT_INFO) +#else if (sei->payloadType() == SEI::BUFFERING_PERIOD || sei->payloadType() == SEI::PICTURE_TIMING || sei->payloadType() == SEI::DECODING_UNIT_INFO) +#endif { bool targetOlsIdxGreaterThanZero = m_targetOlsIdx > 0; writeInpuNalUnitToStream &= !targetOlsIdxGreaterThanZero; @@ -582,8 +605,6 @@ uint32_t BitstreamExtractorApp::decode() delete vps; } } -#endif -#if JVET_Q0397_SUB_PIC_EXTRACT if (m_subPicId>=0) { if ( nalu.isSlice() ) @@ -593,7 +614,6 @@ uint32_t BitstreamExtractorApp::decode() } } -#endif unitCnt++; if( writeInpuNalUnitToStream ) diff --git a/source/App/BitstreamExtractorApp/BitstreamExtractorApp.h b/source/App/BitstreamExtractorApp/BitstreamExtractorApp.h index 6adc782a1048e9533a8faceb7c706f33f2560e55..d8af800df5592321517d70fab75d6c94772b8e90 100644 --- a/source/App/BitstreamExtractorApp/BitstreamExtractorApp.h +++ b/source/App/BitstreamExtractorApp/BitstreamExtractorApp.h @@ -49,9 +49,7 @@ #include "VLCReader.h" #include "VLCWriter.h" -#if JVET_P0118_OLS_EXTRACTION #include "SEIread.h" -#endif class BitstreamExtractorApp : public BitstreamExtractorAppCfg { @@ -61,10 +59,9 @@ public: virtual ~BitstreamExtractorApp () {} uint32_t decode (); ///< main decoding function - + protected: void xPrintVPSInfo (VPS *vps); -#if JVET_Q0397_SUB_PIC_EXTRACT void xPrintSubPicInfo (PPS *pps); void xRewriteSPS (SPS &targetSPS, const SPS &sourceSPS, SubPic &subPic); void xRewritePPS (PPS &targetPPS, const PPS &sourcePPS, SubPic &subPic); @@ -75,8 +72,7 @@ protected: void xSetSPSUpdated(int spsId) { return m_updatedSPSList.push_back(spsId); } bool xIsSPSUpdate(int spsId) { return (std::find(m_updatedSPSList.begin(),m_updatedSPSList.end(), spsId) != m_updatedSPSList.end()); } void xClearSPSUpdated(int spsId) { m_updatedSPSList.erase(std::remove(m_updatedSPSList.begin(), m_updatedSPSList.end(), spsId)); }; -#endif - + void xWriteVPS(VPS *vps, std::ostream& out, int layerId, int temporalId); void xWriteSPS(SPS *sps, std::ostream& out, int layerId, int temporalId); void xWritePPS(PPS *pps, std::ostream& out, int layerId, int temporalId); @@ -84,18 +80,17 @@ protected: ParameterSetManager m_parameterSetManager; HLSyntaxReader m_hlSynaxReader; HLSWriter m_hlSyntaxWriter; -#if JVET_P0118_OLS_EXTRACTION SEIReader m_seiReader; int m_vpsId; +#if JVET_Q0394_TIMING_SEI + bool m_removeTimingSEI; #endif -#if JVET_Q0397_SUB_PIC_EXTRACT PicHeader m_picHeader; int m_prevTid0Poc; std::vector<int> m_updatedVPSList; std::vector<int> m_updatedSPSList; std::vector<int> m_updatedPPSList; -#endif }; #endif // __BITSTREAMEXTRACTORAPP__ diff --git a/source/App/BitstreamExtractorApp/BitstreamExtractorAppCfg.cpp b/source/App/BitstreamExtractorApp/BitstreamExtractorAppCfg.cpp index 51978d83270bf8332ef38352705859d4ae4c61eb..b438884f1bd4c5fc98fc043bc9f01f070daed7f4 100644 --- a/source/App/BitstreamExtractorApp/BitstreamExtractorAppCfg.cpp +++ b/source/App/BitstreamExtractorApp/BitstreamExtractorAppCfg.cpp @@ -109,7 +109,7 @@ namespace po = df::program_options_lite; } DTRACE_UPDATE( g_trace_ctx, std::make_pair( "final", 1 ) ); #endif - + g_verbosity = MsgLevel( verbosity ); if (err.is_errored) @@ -120,22 +120,7 @@ namespace po = df::program_options_lite; return false; } } -#if JVET_P0118_OLS_EXTRACTION CHECK(m_maxTemporalLayer < -1 || m_maxTemporalLayer > 6, "MaxTemporalLayer shall either be equal -1 (for diabled) or in the range of 0 to 6, inclusive"); -#else - if (m_targetOlsIdx != -1) - { - std::cerr << "Extraction by target output layer set index is not implemented yet"; - return false; - } -#endif -#if !JVET_Q0397_SUB_PIC_EXTRACT - if (m_subPicId != -1) - { - std::cerr << "Extraction by subpicture ID is not implemented yet"; - return false; - } -#endif if (m_bitstreamFileNameIn.empty()) { @@ -155,13 +140,8 @@ namespace po = df::program_options_lite; BitstreamExtractorAppCfg::BitstreamExtractorAppCfg() : m_bitstreamFileNameIn() , m_bitstreamFileNameOut() -#if JVET_P0118_OLS_EXTRACTION , m_maxTemporalLayer( 0 ) , m_targetOlsIdx( 0 ) -#else -, m_maxTemporalLayer( -1 ) -, m_targetOlsIdx( -1 ) -#endif , m_subPicId( -1 ) { } diff --git a/source/App/DecoderApp/DecApp.cpp b/source/App/DecoderApp/DecApp.cpp index 77787443a9030c819cfffa677bac52da21b8bddd..d288bb0206af302fdf06b9bf4f865cda125d0710 100644 --- a/source/App/DecoderApp/DecApp.cpp +++ b/source/App/DecoderApp/DecApp.cpp @@ -95,7 +95,6 @@ uint32_t DecApp::decode() } } -#if JVET_P2008_OUTPUT_LOG if (!m_oplFilename.empty() && m_oplFilename!="-") { m_oplFileStream.open(m_oplFilename.c_str(), std::ios::out); @@ -104,7 +103,6 @@ uint32_t DecApp::decode() EXIT( "Unable to open file "<< m_oplFilename.c_str() << " to write an opl-file for conformance testing (see JVET-P2008 for details)"); } } -#endif //JVET_P2008_OUTPUT_LOG // create & initialize internal classes xCreateDecLib(); @@ -122,11 +120,7 @@ uint32_t DecApp::decode() } // main decoder loop -#if JVET_P0125_EOS_LAYER_SPECIFIC bool loopFiltered[MAX_VPS_LAYERS] = { false }; -#else - bool loopFiltered = false; -#endif bool bPicSkipped = false; @@ -138,8 +132,8 @@ uint32_t DecApp::decode() // determine if next NAL unit will be the first one from a new picture bool bNewPicture = isNewPicture(&bitstreamFile, &bytestream); bool bNewAccessUnit = bNewPicture && isNewAccessUnit( bNewPicture, &bitstreamFile, &bytestream ); - if(!bNewPicture) - { + if(!bNewPicture) + { AnnexBStats stats = AnnexBStats(); // find next NAL unit in stream @@ -167,19 +161,13 @@ uint32_t DecApp::decode() } // parse NAL unit syntax if within target decoding layer -#if JVET_Q0814_DPB if( ( m_iMaxTemporalLayer < 0 || nalu.m_temporalId <= m_iMaxTemporalLayer ) && xIsNaluWithinTargetDecLayerIdSet( &nalu ) ) -#else - if ((m_iMaxTemporalLayer < 0 || nalu.m_temporalId <= m_iMaxTemporalLayer) && isNaluWithinTargetDecLayerIdSet(&nalu)) -#endif { -#if JVET_P0115_LAYER_TID_CONSTRAINT CHECK(nalu.m_temporalId > m_iMaxTemporalLayer, "bitstream shall not include any NAL unit with TemporalId greater than HighestTid"); if (m_targetDecLayerIdSet.size()) { CHECK(std::find(m_targetDecLayerIdSet.begin(), m_targetDecLayerIdSet.end(), nalu.m_nuhLayerId) == m_targetDecLayerIdSet.end(), "bitstream shall not contain any other layers than included in the OLS with OlsIdx"); } -#endif if (bPicSkipped) { if ((nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_TRAIL) || (nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_STSA) || (nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_RASL) || (nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_RADL) || (nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_IDR_W_RADL) || (nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_IDR_N_LP) || (nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_CRA) || (nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_GDR)) @@ -188,27 +176,17 @@ uint32_t DecApp::decode() { m_cDecLib.resetAccessUnitNals(); m_cDecLib.resetAccessUnitApsNals(); -#if JVET_P0101_POC_MULTILAYER m_cDecLib.resetAccessUnitPicInfo(); -#endif } bPicSkipped = false; } } -#if JVET_P0288_PIC_OUTPUT m_cDecLib.decode(nalu, m_iSkipFrame, m_iPOCLastDisplay, m_targetOlsIdx); -#else - m_cDecLib.decode(nalu, m_iSkipFrame, m_iPOCLastDisplay); -#endif if (nalu.m_nalUnitType == NAL_UNIT_VPS) { -#if JVET_Q0814_DPB m_cDecLib.deriveTargetOutputLayerSet( m_targetOlsIdx ); m_targetDecLayerIdSet = m_cDecLib.getVPS()->m_targetLayerIdSet; m_targetOutputLayerIdSet = m_cDecLib.getVPS()->m_targetOutputLayerIdSet; -#else - deriveOutputLayerSet(); -#endif } } else @@ -218,45 +196,23 @@ uint32_t DecApp::decode() } } -#if JVET_P0125_EOS_LAYER_SPECIFIC if ((bNewPicture || !bitstreamFile || nalu.m_nalUnitType == NAL_UNIT_EOS) && !m_cDecLib.getFirstSliceInSequence(nalu.m_nuhLayerId) && !bPicSkipped) -#else - if ((bNewPicture || !bitstreamFile || nalu.m_nalUnitType == NAL_UNIT_EOS) && !m_cDecLib.getFirstSliceInSequence() && !bPicSkipped) -#endif { -#if JVET_P0125_EOS_LAYER_SPECIFIC if (!loopFiltered[nalu.m_nuhLayerId] || bitstreamFile) -#else - if (!loopFiltered || bitstreamFile) -#endif { m_cDecLib.executeLoopFilters(); m_cDecLib.finishPicture( poc, pcListPic ); } -#if JVET_P0125_EOS_LAYER_SPECIFIC loopFiltered[nalu.m_nuhLayerId] = (nalu.m_nalUnitType == NAL_UNIT_EOS); -#else - loopFiltered = (nalu.m_nalUnitType == NAL_UNIT_EOS); -#endif if (nalu.m_nalUnitType == NAL_UNIT_EOS) { -#if JVET_P0125_EOS_LAYER_SPECIFIC m_cDecLib.setFirstSliceInSequence(true, nalu.m_nuhLayerId); -#else - m_cDecLib.setFirstSliceInSequence(true); -#endif } -#if JVET_P0978_RPL_RESTRICTIONS m_cDecLib.updateAssociatedIRAP(); -#endif } else if ( (bNewPicture || !bitstreamFile || nalu.m_nalUnitType == NAL_UNIT_EOS ) && -#if JVET_P0125_EOS_LAYER_SPECIFIC m_cDecLib.getFirstSliceInSequence(nalu.m_nuhLayerId)) -#else - m_cDecLib.getFirstSliceInSequence () ) -#endif { m_cDecLib.setFirstSliceInPicture (true); } @@ -280,11 +236,7 @@ uint32_t DecApp::decode() } std::string reconFileName = m_reconFileName; -#if JVET_Q0814_DPB if( m_reconFileName.compare( "/dev/null" ) && m_cDecLib.getVPS() != nullptr && m_cDecLib.getVPS()->getMaxLayers() > 1 && xIsNaluWithinTargetOutputLayerIdSet( &nalu ) ) -#else - if (m_reconFileName.compare("/dev/null") && (m_cDecLib.getVPS() != nullptr) && (m_cDecLib.getVPS()->getMaxLayers() > 1) && (isNaluWithinTargetOutputLayerIdSet(&nalu))) -#endif { size_t pos = reconFileName.find_last_of('.'); if (pos != string::npos) @@ -296,17 +248,10 @@ uint32_t DecApp::decode() reconFileName.append( std::to_string( nalu.m_nuhLayerId ) ); } } -#if JVET_Q0814_DPB if( ( m_cDecLib.getVPS() != nullptr && ( m_cDecLib.getVPS()->getMaxLayers() == 1 || xIsNaluWithinTargetOutputLayerIdSet( &nalu ) ) ) || m_cDecLib.getVPS() == nullptr ) { m_cVideoIOYuvReconFile[nalu.m_nuhLayerId].open( reconFileName, true, m_outputBitDepth, m_outputBitDepth, bitDepths.recon ); // write mode } -#else - if(((m_cDecLib.getVPS() != nullptr) && - ((m_cDecLib.getVPS()->getMaxLayers() == 1) || (isNaluWithinTargetOutputLayerIdSet(&nalu)))) || - (m_cDecLib.getVPS() == nullptr)) - m_cVideoIOYuvReconFile[nalu.m_nuhLayerId].open(reconFileName, true, m_outputBitDepth, m_outputBitDepth, bitDepths.recon); // write mode -#endif } // write reconstruction to file if( bNewPicture ) @@ -332,21 +277,22 @@ uint32_t DecApp::decode() m_cDecLib.resetPictureSeiNalus(); } #endif - if(bNewAccessUnit) +#if JVET_R0201_PREFIX_SUFFIX_APS_CLEANUP + if (bNewPicture || !bitstreamFile || nalu.m_nalUnitType == NAL_UNIT_EOS) + { + m_cDecLib.checkAPSInPictureUnit(); + m_cDecLib.resetPictureUnitNals(); + } +#endif + if(bNewAccessUnit) { -#if JVET_P0125_ASPECT_TID_LAYER_ID_NUH m_cDecLib.checkTidLayerIdInAccessUnit(); m_cDecLib.resetAccessUnitSeiTids(); -#endif -#if JVET_P0125_SEI_CONSTRAINTS m_cDecLib.checkSEIInAccessUnit(); m_cDecLib.resetAccessUnitSeiPayLoadTypes(); -#endif m_cDecLib.resetAccessUnitNals(); m_cDecLib.resetAccessUnitApsNals(); -#if JVET_P0101_POC_MULTILAYER m_cDecLib.resetAccessUnitPicInfo(); -#endif } } @@ -369,178 +315,6 @@ uint32_t DecApp::decode() return nRet; } -#if !JVET_Q0814_DPB -bool DecApp::deriveOutputLayerSet() -{ - int vps_max_layers_minus1 = m_cDecLib.getVPS()->getMaxLayers() - 1; - if(m_targetOlsIdx == - 1 || vps_max_layers_minus1 == 0) - { - m_targetDecLayerIdSet.clear(); - return true; - } - - int TotalNumOlss = 0; - int each_layer_is_an_ols_flag = m_cDecLib.getVPS()->getEachLayerIsAnOlsFlag(); - int ols_mode_idc = m_cDecLib.getVPS()->getOlsModeIdc(); - int num_output_layer_sets_minus1 = m_cDecLib.getVPS()->getNumOutputLayerSets() - 1; - int i = 0, j = 0, k = 0, r = 0; - int* NumOutputLayersInOls; - int* NumLayersInOls; - int** OutputLayerIdInOls; - int** OutputLayerIdx; - int** layerIncludedInOlsFlag; - int** LayerIdInOls; - int** dependencyFlag; - int** RefLayerIdx; - int* NumRefLayers; - - if (vps_max_layers_minus1 == 0) - TotalNumOlss = 1; - else if (each_layer_is_an_ols_flag || ols_mode_idc == 0 || ols_mode_idc == 1) - TotalNumOlss = vps_max_layers_minus1 + 1; - else if (ols_mode_idc == 2) - TotalNumOlss = num_output_layer_sets_minus1 + 1; - - NumOutputLayersInOls = new int[m_cDecLib.getVPS()->getNumOutputLayerSets()]; - NumLayersInOls = new int[m_cDecLib.getVPS()->getNumOutputLayerSets()]; - OutputLayerIdInOls = new int*[TotalNumOlss]; - OutputLayerIdx = new int*[TotalNumOlss]; - layerIncludedInOlsFlag = new int*[TotalNumOlss]; - LayerIdInOls = new int*[TotalNumOlss]; - - for (i = 0; i < TotalNumOlss; i++) - { - OutputLayerIdInOls[i] = new int[vps_max_layers_minus1 + 1]; - OutputLayerIdx[i] = new int[vps_max_layers_minus1 + 1]; - layerIncludedInOlsFlag[i] = new int[vps_max_layers_minus1 + 1]; - LayerIdInOls[i] = new int[vps_max_layers_minus1 + 1]; - } - - dependencyFlag = new int*[vps_max_layers_minus1 + 1]; - RefLayerIdx = new int*[vps_max_layers_minus1 + 1]; - NumRefLayers = new int[vps_max_layers_minus1 + 1]; - - for (i = 0; i <= vps_max_layers_minus1; i++) - { - dependencyFlag[i] = new int[vps_max_layers_minus1 + 1]; - RefLayerIdx[i] = new int[vps_max_layers_minus1 + 1]; - } - - for (i = 0; i <= vps_max_layers_minus1; i++) { - for (j = 0; j <= vps_max_layers_minus1; j++) { - dependencyFlag[i][j] = m_cDecLib.getVPS()->getDirectRefLayerFlag(i, j); - for (k = 0; k < i; k++) - if (m_cDecLib.getVPS()->getDirectRefLayerFlag(i, k) && dependencyFlag[k][j]) - dependencyFlag[i][j] = 1; - } - } - for (i = 0; i <= vps_max_layers_minus1; i++) - { - for (j = 0, r = 0; j <= vps_max_layers_minus1; j++) - { - if (dependencyFlag[i][j]) - RefLayerIdx[i][r++] = j; - } - NumRefLayers[i] = r; - } - - NumOutputLayersInOls[0] = 1; - OutputLayerIdInOls[0][0] = m_cDecLib.getVPS()->getLayerId(0); - for (i = 1; i < TotalNumOlss; i++) - { - if (each_layer_is_an_ols_flag || ols_mode_idc == 0) - { - NumOutputLayersInOls[i] = 1; - OutputLayerIdInOls[i][0] = m_cDecLib.getVPS()->getLayerId(i); - } - else if (ols_mode_idc == 1) { - NumOutputLayersInOls[i] = i + 1; - for (j = 0; j < NumOutputLayersInOls[i]; j++) - OutputLayerIdInOls[i][j] = m_cDecLib.getVPS()->getLayerId(j); - } - else if (ols_mode_idc == 2) { - for (j = 0; j <= vps_max_layers_minus1; j++) - { - layerIncludedInOlsFlag[i][j] = 0; - } - for (k = 0, j = 0; k <= vps_max_layers_minus1; k++) - { - if (m_cDecLib.getVPS()->getOlsOutputLayerFlag(i, k)) - { - layerIncludedInOlsFlag[i][k] = 1; - OutputLayerIdx[i][j] = k; - OutputLayerIdInOls[i][j++] = m_cDecLib.getVPS()->getLayerId(k); - } - } - NumOutputLayersInOls[i] = j; - for (j = 0; j < NumOutputLayersInOls[i]; j++) - { - int idx = OutputLayerIdx[i][j]; - for (k = 0; k < NumRefLayers[idx]; k++) - layerIncludedInOlsFlag[i][RefLayerIdx[idx][k]] = 1; - } - } - } - - m_targetOutputLayerIdSet.clear(); - for (i = 0; i < NumOutputLayersInOls[m_targetOlsIdx]; i++) - m_targetOutputLayerIdSet.push_back(OutputLayerIdInOls[m_targetOlsIdx][i]); - - NumLayersInOls[0] = 1; - LayerIdInOls[0][0] = m_cDecLib.getVPS()->getLayerId(0); - for (i = 1; i < TotalNumOlss; i++) - { - if (each_layer_is_an_ols_flag) - { - NumLayersInOls[i] = 1; - LayerIdInOls[i][0] = m_cDecLib.getVPS()->getLayerId(i); - } - else if (ols_mode_idc == 0 || ols_mode_idc == 1) - { - NumLayersInOls[i] = i + 1; - for (j = 0; j < NumLayersInOls[i]; j++) - LayerIdInOls[i][j] = m_cDecLib.getVPS()->getLayerId(j); - } - else if (ols_mode_idc == 2) - { - for (k = 0, j = 0; k <= vps_max_layers_minus1; k++) - if (layerIncludedInOlsFlag[i][k]) - LayerIdInOls[i][j++] = m_cDecLib.getVPS()->getLayerId(k); - NumLayersInOls[i] = j; - } - } - - m_targetDecLayerIdSet.clear(); - for (i = 0; i < NumLayersInOls[m_targetOlsIdx]; i++) - m_targetDecLayerIdSet.push_back(LayerIdInOls[m_targetOlsIdx][i]); - - delete[] NumOutputLayersInOls; - delete[] NumLayersInOls; - delete[] NumRefLayers; - - for (i = 0; i < TotalNumOlss; i++) - { - delete[] OutputLayerIdInOls[i]; - delete[] OutputLayerIdx[i]; - delete[] layerIncludedInOlsFlag[i]; - delete[] LayerIdInOls[i]; - } - delete[] OutputLayerIdInOls; - delete[] OutputLayerIdx; - delete[] layerIncludedInOlsFlag; - delete[] LayerIdInOls; - - for (i = 0; i <= vps_max_layers_minus1; i++) - { - delete[] dependencyFlag[i]; - delete[] RefLayerIdx[i]; - } - delete[] dependencyFlag; - delete[] RefLayerIdx; - - return true; -} -#endif /** - lookahead through next NAL units to determine if current NAL unit is the first NAL unit in a new picture @@ -582,11 +356,7 @@ bool DecApp::isNewPicture(ifstream *bitstreamFile, class InputByteStream *bytest // NUT that indicate the start of a new picture case NAL_UNIT_ACCESS_UNIT_DELIMITER: -#if JVET_Q0117_PARAMETER_SETS_CLEANUP case NAL_UNIT_DCI: -#else - case NAL_UNIT_DPS: -#endif case NAL_UNIT_VPS: case NAL_UNIT_SPS: case NAL_UNIT_PPS: @@ -595,11 +365,7 @@ bool DecApp::isNewPicture(ifstream *bitstreamFile, class InputByteStream *bytest finished = true; break; -#if JVET_Q0775_PH_IN_SH // NUT that may be the start of a new picture - check first bit in slice header -#else - // NUT that are not the start of a new picture -#endif case NAL_UNIT_CODED_SLICE_TRAIL: case NAL_UNIT_CODED_SLICE_STSA: case NAL_UNIT_CODED_SLICE_RASL: @@ -613,13 +379,11 @@ bool DecApp::isNewPicture(ifstream *bitstreamFile, class InputByteStream *bytest case NAL_UNIT_CODED_SLICE_GDR: case NAL_UNIT_RESERVED_IRAP_VCL_11: case NAL_UNIT_RESERVED_IRAP_VCL_12: -#if JVET_Q0775_PH_IN_SH ret = checkPictureHeaderInSliceHeaderFlag(nalu); finished = true; break; // NUT that are not the start of a new picture -#endif case NAL_UNIT_EOS: case NAL_UNIT_EOB: case NAL_UNIT_SUFFIX_APS: @@ -628,7 +392,7 @@ bool DecApp::isNewPicture(ifstream *bitstreamFile, class InputByteStream *bytest ret = false; finished = true; break; - + // NUT that might indicate the start of a new picture - keep looking case NAL_UNIT_PREFIX_APS: case NAL_UNIT_PREFIX_SEI: @@ -643,7 +407,7 @@ bool DecApp::isNewPicture(ifstream *bitstreamFile, class InputByteStream *bytest } } } - + // restore previous stream location - minus 3 due to the need for the annexB parser to read three extra bytes #if RExt__DECODER_DEBUG_BIT_STATISTICS bitstreamFile->clear(); @@ -668,7 +432,7 @@ bool DecApp::isNewAccessUnit( bool newPicture, ifstream *bitstreamFile, class In { bool ret = false; bool finished = false; - + // can only be the start of an AU if this is the start of a new picture if( newPicture == false ) { @@ -698,7 +462,7 @@ bool DecApp::isNewAccessUnit( bool newPicture, ifstream *bitstreamFile, class In // get next NAL unit type read(nalu); switch( nalu.m_nalUnitType ) { - + // AUD always indicates the start of a new access unit case NAL_UNIT_ACCESS_UNIT_DELIMITER: ret = true; @@ -714,10 +478,10 @@ bool DecApp::isNewAccessUnit( bool newPicture, ifstream *bitstreamFile, class In case NAL_UNIT_CODED_SLICE_IDR_N_LP: case NAL_UNIT_CODED_SLICE_CRA: case NAL_UNIT_CODED_SLICE_GDR: - ret = m_cDecLib.isSliceNaluFirstInAU( newPicture, nalu ); + ret = m_cDecLib.isSliceNaluFirstInAU( newPicture, nalu ); finished = true; break; - + // NUT that are not the start of a new access unit case NAL_UNIT_EOS: case NAL_UNIT_EOB: @@ -727,14 +491,14 @@ bool DecApp::isNewAccessUnit( bool newPicture, ifstream *bitstreamFile, class In ret = false; finished = true; break; - + // all other NUT - keep looking to find first VCL default: break; } } } - + // restore previous stream location #if RExt__DECODER_DEBUG_BIT_STATISTICS bitstreamFile->clear(); @@ -752,7 +516,6 @@ bool DecApp::isNewAccessUnit( bool newPicture, ifstream *bitstreamFile, class In return ret; } -#if JVET_P2008_OUTPUT_LOG void DecApp::writeLineToOutputLog(Picture * pcPic) { if (m_oplFileStream.is_open() && m_oplFileStream.good()) @@ -765,7 +528,6 @@ void DecApp::writeLineToOutputLog(Picture * pcPic) m_oplFileStream << std::setw(8) << pcPic->getPOC() << "," << std::setw(5) << pcPic->Y().width << "," << std::setw(5) << pcPic->Y().height << "," << hashToString(recon_digest, numChar) << "\n"; } } -#endif // JVET_P2008_OUTPUT_LOG // ==================================================================================================================== // Protected member functions @@ -792,9 +554,7 @@ void DecApp::xCreateDecLib() std::ostream &os=m_seiMessageFileStream.is_open() ? m_seiMessageFileStream : std::cout; m_cDecLib.setDecodedSEIMessageOutputStream(&os); } -#if JVET_O1143_SUBPIC_BOUNDARY m_cDecLib.m_targetSubPicIdx = this->m_targetSubPicIdx; -#endif m_cDecLib.initScalingList(); } @@ -831,7 +591,6 @@ void DecApp::xWriteOutput( PicList* pcListPic, uint32_t tId ) uint32_t maxDecPicBufferingHighestTid; uint32_t maxNrSublayers = activeSPS->getMaxTLayers(); -#if JVET_Q0814_DPB const VPS* referredVPS = pcListPic->front()->cs->vps; const int temporalId = ( m_iMaxTemporalLayer == -1 || m_iMaxTemporalLayer >= maxNrSublayers ) ? maxNrSublayers - 1 : m_iMaxTemporalLayer; @@ -845,18 +604,6 @@ void DecApp::xWriteOutput( PicList* pcListPic, uint32_t tId ) numReorderPicsHighestTid = referredVPS->getNumReorderPics( temporalId ); maxDecPicBufferingHighestTid = referredVPS->getMaxDecPicBuffering( temporalId ); } -#else - if(m_iMaxTemporalLayer == -1 || m_iMaxTemporalLayer >= maxNrSublayers) - { - numReorderPicsHighestTid = activeSPS->getNumReorderPics(maxNrSublayers-1); - maxDecPicBufferingHighestTid = activeSPS->getMaxDecPicBuffering(maxNrSublayers-1); - } - else - { - numReorderPicsHighestTid = activeSPS->getNumReorderPics(m_iMaxTemporalLayer); - maxDecPicBufferingHighestTid = activeSPS->getMaxDecPicBuffering(m_iMaxTemporalLayer); - } -#endif while (iterPic != pcListPic->end()) { @@ -918,10 +665,8 @@ void DecApp::xWriteOutput( PicList* pcListPic, uint32_t tId ) NUM_CHROMA_FORMAT, isTff ); } } -#if JVET_P2008_OUTPUT_LOG writeLineToOutputLog(pcPicTop); writeLineToOutputLog(pcPicBottom); -#endif // update POC of display order m_iPOCLastDisplay = pcPicBottom->getPOC(); @@ -980,9 +725,7 @@ void DecApp::xWriteOutput( PicList* pcListPic, uint32_t tId ) NUM_CHROMA_FORMAT, m_bClipOutputVideoToRec709Range ); } } -#if JVET_P2008_OUTPUT_LOG writeLineToOutputLog(pcPic); -#endif // update POC of display order m_iPOCLastDisplay = pcPic->getPOC(); @@ -1046,10 +789,8 @@ void DecApp::xFlushOutput( PicList* pcListPic, const int layerId ) conf.getWindowBottomOffset() * SPS::getWinUnitY( pcPicTop->cs->sps->getChromaFormatIdc() ), NUM_CHROMA_FORMAT, isTff ); } -#if JVET_P2008_OUTPUT_LOG writeLineToOutputLog(pcPicTop); writeLineToOutputLog(pcPicBottom); -#endif // update POC of display order m_iPOCLastDisplay = pcPicBottom->getPOC(); @@ -1117,9 +858,7 @@ void DecApp::xFlushOutput( PicList* pcListPic, const int layerId ) NUM_CHROMA_FORMAT, m_bClipOutputVideoToRec709Range ); } } -#if JVET_P2008_OUTPUT_LOG writeLineToOutputLog(pcPic); -#endif // update POC of display order m_iPOCLastDisplay = pcPic->getPOC(); @@ -1153,7 +892,6 @@ void DecApp::xFlushOutput( PicList* pcListPic, const int layerId ) /** \param nalu Input nalu to check whether its LayerId is within targetDecLayerIdSet */ -#if JVET_Q0814_DPB bool DecApp::xIsNaluWithinTargetDecLayerIdSet( const InputNALUnit* nalu ) const { if( !m_targetDecLayerIdSet.size() ) // By default, the set is empty, meaning all LayerIds are allowed @@ -1175,40 +913,5 @@ bool DecApp::xIsNaluWithinTargetOutputLayerIdSet( const InputNALUnit* nalu ) con return std::find( m_targetOutputLayerIdSet.begin(), m_targetOutputLayerIdSet.end(), nalu->m_nuhLayerId ) != m_targetOutputLayerIdSet.end(); } -#else -bool DecApp::isNaluWithinTargetDecLayerIdSet( InputNALUnit* nalu ) -{ - if ( m_targetDecLayerIdSet.size() == 0 ) // By default, the set is empty, meaning all LayerIds are allowed - { - return true; - } - for (std::vector<int>::iterator it = m_targetDecLayerIdSet.begin(); it != m_targetDecLayerIdSet.end(); it++) - { - if ( nalu->m_nuhLayerId == (*it) ) - { - return true; - } - } - return false; -} - -/** \param nalu Input nalu to check whether its LayerId is within targetOutputLayerIdSet - */ -bool DecApp::isNaluWithinTargetOutputLayerIdSet(InputNALUnit* nalu) -{ - if (m_targetOutputLayerIdSet.size() == 0) // By default, the set is empty, meaning all LayerIds are allowed - { - return true; - } - for (std::vector<int>::iterator it = m_targetOutputLayerIdSet.begin(); it != m_targetOutputLayerIdSet.end(); it++) - { - if (nalu->m_nuhLayerId == (*it)) - { - return true; - } - } - return false; -} -#endif //! \} diff --git a/source/App/DecoderApp/DecApp.h b/source/App/DecoderApp/DecApp.h index b3a9d9420d2556ac80b974379708a10fbb726276..3749288d084dd013b1e61a750bedf14533d63744 100644 --- a/source/App/DecoderApp/DecApp.h +++ b/source/App/DecoderApp/DecApp.h @@ -66,17 +66,13 @@ private: int m_iPOCLastDisplay; ///< last POC in display order std::ofstream m_seiMessageFileStream; ///< Used for outputing SEI messages. -#if JVET_P2008_OUTPUT_LOG std::ofstream m_oplFileStream; ///< Used to output log file for confomance testing -#endif //JVET_P2008_OUTPUT_LOG -#if JVET_Q0814_DPB private: bool xIsNaluWithinTargetDecLayerIdSet( const InputNALUnit* nalu ) const; ///< check whether given Nalu is within targetDecLayerIdSet bool xIsNaluWithinTargetOutputLayerIdSet( const InputNALUnit* nalu ) const; ///< check whether given Nalu is within targetOutputLayerIdSet -#endif public: DecApp(); @@ -89,17 +85,10 @@ private: void xDestroyDecLib (); ///< destroy internal classes void xWriteOutput ( PicList* pcListPic , uint32_t tId); ///< write YUV to file void xFlushOutput( PicList* pcListPic, const int layerId = NOT_VALID ); ///< flush all remaining decoded pictures to file -#if !JVET_Q0814_DPB - bool isNaluWithinTargetDecLayerIdSet ( InputNALUnit* nalu ); ///< check whether given Nalu is within targetDecLayerIdSet - bool isNaluWithinTargetOutputLayerIdSet(InputNALUnit* nalu); ///< check whether given Nalu is within targetOutputLayerIdSet - bool deriveOutputLayerSet(); ///< derive OLS and layer sets -#endif bool isNewPicture(ifstream *bitstreamFile, class InputByteStream *bytestream); ///< check if next NAL unit will be the first NAL unit from a new picture bool isNewAccessUnit(bool newPicture, ifstream *bitstreamFile, class InputByteStream *bytestream); ///< check if next NAL unit will be the first NAL unit from a new access unit -#if JVET_P2008_OUTPUT_LOG void writeLineToOutputLog(Picture * pcPic); -#endif // JVET_P2008_OUTPUT_LOG }; diff --git a/source/App/DecoderApp/DecAppCfg.cpp b/source/App/DecoderApp/DecAppCfg.cpp index f54530eea1c81be7487d62e76b1ef1c59aa30b3f..602f949ab9ca2c16c60df75d173484ec5206b59b 100644 --- a/source/App/DecoderApp/DecAppCfg.cpp +++ b/source/App/DecoderApp/DecAppCfg.cpp @@ -77,9 +77,7 @@ bool DecAppCfg::parseCfg( int argc, char* argv[] ) ("BitstreamFile,b", m_bitstreamFileName, string(""), "bitstream input file name") ("ReconFile,o", m_reconFileName, string(""), "reconstructed YUV output file name\n") -#if JVET_P2008_OUTPUT_LOG ("OplFile,-opl", m_oplFilename , string(""), "opl-file name without extension for conformance testing\n") -#endif //JVET_P2008_OUTPUT_LOG #if ENABLE_SIMD_OPT ("SIMD", ignore, string(""), "SIMD extension to use (SCALAR, SSE41, SSE42, AVX, AVX2, AVX512), default: the highest supported extension\n") @@ -117,9 +115,7 @@ bool DecAppCfg::parseCfg( int argc, char* argv[] ) "\t3: enable bit and tool statistic\n") #endif ("MCTSCheck", m_mctsCheck, false, "If enabled, the decoder checks for violations of mc_exact_sample_value_match_flag in Temporal MCTS ") -#if JVET_O1143_SUBPIC_BOUNDARY ("targetSubPicIdx", m_targetSubPicIdx, 0, "Specify which subpicture shall be written to output, using subpic index, 0: disabled, subpicIdx=m_targetSubPicIdx-1 \n" ) -#endif ( "UpscaledOutput", m_upscaledOutput, 0, "Upscaled output for RPR" ) ; @@ -227,9 +223,7 @@ bool DecAppCfg::parseCfg( int argc, char* argv[] ) DecAppCfg::DecAppCfg() : m_bitstreamFileName() , m_reconFileName() -#if JVET_P2008_OUTPUT_LOG , m_oplFilename() -#endif //JVET_P2008_OUTPUT_LOG , m_iSkipFrame(0) // m_outputBitDepth array initialised below diff --git a/source/App/DecoderApp/DecAppCfg.h b/source/App/DecoderApp/DecAppCfg.h index bd0b4d1cd5fe0496a91b253b1dbfebd0181b14bb..f28b07d77d951287f0e67544dc8cda3fd9bb9e02 100644 --- a/source/App/DecoderApp/DecAppCfg.h +++ b/source/App/DecoderApp/DecAppCfg.h @@ -59,15 +59,13 @@ protected: std::string m_bitstreamFileName; ///< input bitstream file name std::string m_reconFileName; ///< output reconstruction file name -#if JVET_P2008_OUTPUT_LOG std::string m_oplFilename; ///< filename to output conformance log. -#endif //JVET_P2008_OUTPUT_LOG int m_iSkipFrame; ///< counter for frames prior to the random access point to skip int m_outputBitDepth[MAX_NUM_CHANNEL_TYPE]; ///< bit depth used for writing output InputColourSpaceConversion m_outputColourSpaceConvert; int m_targetOlsIdx; ///< target output layer set - std::vector<int> m_targetOutputLayerIdSet; ///< set of LayerIds to be outputted + std::vector<int> m_targetOutputLayerIdSet; ///< set of LayerIds to be outputted int m_iMaxTemporalLayer; ///< maximum temporal layer to be decoded int m_decodedPictureHashSEIEnabled; ///< Checksum(3)/CRC(2)/MD5(1)/disable(0) acting on decoded picture hash SEI message bool m_decodedNoDisplaySEIEnabled; ///< Enable(true)/disable(false) writing only pictures that get displayed based on the no display SEI message @@ -75,7 +73,7 @@ protected: std::vector<int> m_targetDecLayerIdSet; ///< set of LayerIds to be included in the sub-bitstream extraction process. std::string m_outputDecodedSEIMessagesFilename; ///< filename to output decoded SEI messages to. If '-', then use stdout. If empty, do not output details. - + bool m_bClipOutputVideoToRec709Range; ///< If true, clip the output video to the Rec 709 range on saving. bool m_packedYUVMode; ///< If true, output 10-bit and 12-bit YUV data as 5-byte and 3-byte (respectively) packed YUV data std::string m_cacheCfgFile; ///< Config file of cache model @@ -83,9 +81,7 @@ protected: bool m_mctsCheck; int m_upscaledOutput; ////< Output upscaled (2), decoded but in full resolution buffer (1) or decoded cropped (0, default) picture for RPR. -#if JVET_O1143_SUBPIC_BOUNDARY int m_targetSubPicIdx; ///< Specify which subpicture shall be write to output, using subpicture index -#endif public: DecAppCfg(); virtual ~DecAppCfg(); diff --git a/source/App/EncoderApp/EncApp.cpp b/source/App/EncoderApp/EncApp.cpp index 9af6405cbd815d7996d351b263d8341887259a08..ee51cd13e37407f33cf5908822a7fc3fb38c528d 100644 --- a/source/App/EncoderApp/EncApp.cpp +++ b/source/App/EncoderApp/EncApp.cpp @@ -75,12 +75,8 @@ EncApp::~EncApp() void EncApp::xInitLibCfg() { -#if JVET_Q0814_DPB VPS& vps = *m_cEncLib.getVPS(); vps.m_targetOlsIdx = m_targetOlsIdx; -#else - VPS vps; -#endif vps.setMaxLayers( m_maxLayers ); @@ -175,7 +171,6 @@ void EncApp::xInitLibCfg() } } } -#if JVET_Q0786_PTL_only CHECK( m_numPtlsInVps == 0, "There has to be at least one PTL structure in the VPS." ); vps.setNumPtls ( m_numPtlsInVps ); vps.setPtPresentFlag (0, 1); @@ -183,7 +178,7 @@ void EncApp::xInitLibCfg() { if( i > 0 ) vps.setPtPresentFlag (i, 0); - vps.setPtlMaxTemporalId (i, vps.getMaxSubLayers() - 1); + vps.setPtlMaxTemporalId (i, vps.getMaxSubLayers() - 1); } for (int i = 0; i < vps.getNumOutputLayerSets(); i++) { @@ -205,11 +200,7 @@ void EncApp::xInitLibCfg() ptls[i].setLevelIdc (m_levelPtl[i]); } vps.setProfileTierLevel(ptls); -#endif vps.setVPSExtensionFlag ( false ); -#if !JVET_Q0814_DPB - m_cEncLib.setVPS(&vps); -#endif m_cEncLib.setProfile ( m_profile); m_cEncLib.setLevel ( m_levelTier, m_level); m_cEncLib.setNumSubProfile ( m_numSubProfile ); @@ -217,16 +208,20 @@ void EncApp::xInitLibCfg() { m_cEncLib.setSubProfile(i, m_subProfile[i]); } +#if !JVET_R0090_VUI m_cEncLib.setProgressiveSourceFlag ( m_progressiveSourceFlag); m_cEncLib.setInterlacedSourceFlag ( m_interlacedSourceFlag); +#endif m_cEncLib.setNonPackedConstraintFlag ( m_nonPackedConstraintFlag); -#if JVET_Q0114_CONSTRAINT_FLAGS m_cEncLib.setNonProjectedConstraintFlag ( m_nonProjectedConstraintFlag ); +#if JVET_R0286_GCI_CLEANUP + m_cEncLib.setSingleLayerConstraintFlag ( m_singleLayerConstraintFlag ); + m_cEncLib.setAllLayersIndependentConstraintFlag ( m_allLayersIndependentConstraintFlag ); +#endif m_cEncLib.setNoResChangeInClvsConstraintFlag ( m_noResChangeInClvsConstraintFlag ); m_cEncLib.setOneTilePerPicConstraintFlag ( m_oneTilePerPicConstraintFlag ); m_cEncLib.setOneSlicePerPicConstraintFlag ( m_oneSlicePerPicConstraintFlag ); m_cEncLib.setOneSubpicPerPicConstraintFlag ( m_oneSubpicPerPicConstraintFlag ); -#endif m_cEncLib.setFrameOnlyConstraintFlag ( m_frameOnlyConstraintFlag); m_cEncLib.setIntraConstraintFlag ( m_intraConstraintFlag ); @@ -257,9 +252,7 @@ void EncApp::xInitLibCfg() m_cEncLib.setNoPartitionConstraintsOverrideConstraintFlag ( !m_SplitConsOverrideEnabledFlag ); m_cEncLib.setNoSaoConstraintFlag ( !m_bUseSAO ); m_cEncLib.setNoAlfConstraintFlag ( !m_alf ); -#if JVET_Q0795_CCALF - m_cEncLib.setNoAlfConstraintFlag ( !m_ccalf ); -#endif + m_cEncLib.setNoCCAlfConstraintFlag ( !m_ccalf ); m_cEncLib.setNoRefWraparoundConstraintFlag ( m_bNoRefWraparoundConstraintFlag ); m_cEncLib.setNoTemporalMvpConstraintFlag ( m_TMVPModeId ? false : true ); m_cEncLib.setNoSbtmvpConstraintFlag ( m_SubPuMvpMode ? false : true ); @@ -274,18 +267,10 @@ void EncApp::xInitLibCfg() m_cEncLib.setNoIbcConstraintFlag ( m_IBCMode ? false : true ); m_cEncLib.setNoCiipConstraintFlag ( !m_ciip ); m_cEncLib.setNoFPelMmvdConstraintFlag ( !(m_MMVD && m_allowDisFracMMVD) ); -#if !JVET_Q0806 - m_cEncLib.setNoTriangleConstraintFlag ( !m_Triangle ); -#else m_cEncLib.setNoGeoConstraintFlag ( !m_Geo ); -#endif m_cEncLib.setNoLadfConstraintFlag ( !m_LadfEnabed ); m_cEncLib.setNoTransformSkipConstraintFlag ( !m_useTransformSkip ); -#if JVET_Q0089_SLICE_LOSSLESS_CODING_CHROMA_BDPCM m_cEncLib.setNoBDPCMConstraintFlag ( !m_useBDPCM ); -#else - m_cEncLib.setNoBDPCMConstraintFlag ( m_useBDPCM == 0 ); -#endif m_cEncLib.setNoJointCbCrConstraintFlag (!m_JointCbCrMode); m_cEncLib.setNoQpDeltaConstraintFlag ( m_bNoQpDeltaConstraintFlag ); m_cEncLib.setNoDepQuantConstraintFlag ( !m_depQuantEnabledFlag); @@ -298,6 +283,19 @@ void EncApp::xInitLibCfg() m_cEncLib.setNoCraConstraintFlag ( m_iDecodingRefreshType != 1 ); m_cEncLib.setNoGdrConstraintFlag ( false ); // Not yet possible to encode GDR using config parameters m_cEncLib.setNoApsConstraintFlag ( !m_alf && !m_lmcsEnabled && m_useScalingListId == SCALING_LIST_OFF); +#if JVET_R0286_GCI_CLEANUP + m_cEncLib.setNoMrlConstraintFlag ( !m_MRL ); + m_cEncLib.setNoIspConstraintFlag ( !m_ISP ); + m_cEncLib.setNoMipConstraintFlag ( !m_MIP ); + m_cEncLib.setNoLfnstConstraintFlag ( !m_LFNST ); + m_cEncLib.setNoMmvdConstraintFlag ( !m_MMVD ); + m_cEncLib.setNoSmvdConstraintFlag ( !m_SMVD ); + m_cEncLib.setNoProfConstraintFlag ( !m_PROF ); + m_cEncLib.setNoPaletteConstraintFlag ( m_PLTMode == 1 ? false : true ); + m_cEncLib.setNoActConstraintFlag ( !m_useColorTrans ); + m_cEncLib.setNoLmcsConstraintFlag ( !m_lmcsEnabled ); +#endif + //====== Coding Structure ======== m_cEncLib.setIntraPeriod ( m_iIntraPeriod ); @@ -333,9 +331,7 @@ void EncApp::xInitLibCfg() m_cEncLib.setPad ( m_aiPad ); m_cEncLib.setAccessUnitDelimiter ( m_AccessUnitDelimiter ); -#if JVET_Q0775_PH_IN_SH m_cEncLib.setEnablePictureHeaderInSliceHeader ( m_enablePictureHeaderInSliceHeader ); -#endif m_cEncLib.setMaxTempLayer ( m_maxTempLayer ); @@ -346,12 +342,10 @@ void EncApp::xInitLibCfg() m_cEncLib.setLoopFilterOffsetInPPS ( m_loopFilterOffsetInPPS ); m_cEncLib.setLoopFilterBetaOffset ( m_loopFilterBetaOffsetDiv2 ); m_cEncLib.setLoopFilterTcOffset ( m_loopFilterTcOffsetDiv2 ); -#if JVET_Q0121_DEBLOCKING_CONTROL_PARAMETERS m_cEncLib.setLoopFilterCbBetaOffset ( m_loopFilterCbBetaOffsetDiv2 ); m_cEncLib.setLoopFilterCbTcOffset ( m_loopFilterCbTcOffsetDiv2 ); m_cEncLib.setLoopFilterCrBetaOffset ( m_loopFilterCrBetaOffsetDiv2 ); m_cEncLib.setLoopFilterCrTcOffset ( m_loopFilterCrTcOffsetDiv2 ); -#endif #if W0038_DB_OPT m_cEncLib.setDeblockingFilterMetric ( m_deblockingFilterMetric ); #else @@ -416,54 +410,35 @@ void EncApp::xInitLibCfg() #endif m_cEncLib.setRDpenalty ( m_rdPenalty ); m_cEncLib.setCTUSize ( m_uiCTUSize ); -#if JVET_Q0119_CLEANUPS m_cEncLib.setSubPicInfoPresentFlag ( m_subPicInfoPresentFlag ); if(m_subPicInfoPresentFlag) -#else - m_cEncLib.setSubPicPresentFlag ( m_subPicPresentFlag ); - if(m_subPicPresentFlag) -#endif { m_cEncLib.setNumSubPics ( m_numSubPics ); - for (int i = 0; i < m_numSubPics; i++) + m_cEncLib.setSubPicCtuTopLeftX ( m_subPicCtuTopLeftX ); + m_cEncLib.setSubPicCtuTopLeftY ( m_subPicCtuTopLeftY ); + m_cEncLib.setSubPicWidth ( m_subPicWidth ); + m_cEncLib.setSubPicHeight ( m_subPicHeight ); + m_cEncLib.setSubPicTreatedAsPicFlag ( m_subPicTreatedAsPicFlag ); + m_cEncLib.setLoopFilterAcrossSubpicEnabledFlag ( m_loopFilterAcrossSubpicEnabledFlag ); + m_cEncLib.setSubPicIdMappingInSpsFlag ( m_subPicIdMappingInSpsFlag ); + m_cEncLib.setSubPicIdLen ( m_subPicIdLen ); + m_cEncLib.setSubPicIdMappingExplicitlySignalledFlag ( m_subPicIdMappingExplicitlySignalledFlag ); + if (m_subPicIdMappingExplicitlySignalledFlag) { - m_cEncLib.setSubPicCtuTopLeftX ( m_subPicCtuTopLeftX[i], i ); - m_cEncLib.setSubPicCtuTopLeftY ( m_subPicCtuTopLeftY[i], i ); - m_cEncLib.setSubPicWidth ( m_subPicWidth[i], i ); - m_cEncLib.setSubPicHeight ( m_subPicHeight[i], i ); - m_cEncLib.setSubPicTreatedAsPicFlag ( m_subPicTreatedAsPicFlag[i], i ); - m_cEncLib.setLoopFilterAcrossSubpicEnabledFlag ( m_loopFilterAcrossSubpicEnabledFlag[i], i ); + m_cEncLib.setSubPicId ( m_subPicId ); } } - -#if JVET_Q0119_CLEANUPS - m_cEncLib.setSubPicIdMappingExplicitlySignalledFlag ( m_subPicIdMappingExplicitlySignalledFlag ); - if (m_subPicIdMappingExplicitlySignalledFlag) - { - m_cEncLib.setSubPicIdMappingInSpsFlag ( m_subPicIdMappingInSpsFlag ); - if(m_subPicIdMappingInSpsFlag) -#else - m_cEncLib.setSubPicIdPresentFlag ( m_subPicIdPresentFlag ); - if (m_subPicIdPresentFlag) + else { - m_cEncLib.setSubPicIdSignallingPresentFlag ( m_subPicIdSignallingPresentFlag ); - if(m_subPicIdSignallingPresentFlag) -#endif - { - m_cEncLib.setSubPicIdLen ( m_subPicIdLen ); - for (int i = 0; i < m_numSubPics; i++) - { - m_cEncLib.setSubPicId ( m_subPicId[i], i ); - } - } + m_cEncLib.setNumSubPics ( 1 ); + m_cEncLib.setSubPicIdMappingExplicitlySignalledFlag ( false ); } + m_cEncLib.setUseSplitConsOverride ( m_SplitConsOverrideEnabledFlag ); m_cEncLib.setMinQTSizes ( m_uiMinQT ); m_cEncLib.setMaxMTTHierarchyDepth ( m_uiMaxMTTHierarchyDepth, m_uiMaxMTTHierarchyDepthI, m_uiMaxMTTHierarchyDepthIChroma ); -#if JVET_Q0330_BLOCK_PARTITION m_cEncLib.setMaxBTSizes ( m_uiMaxBT ); m_cEncLib.setMaxTTSizes ( m_uiMaxTT ); -#endif m_cEncLib.setDualITree ( m_dualTree ); m_cEncLib.setLFNST ( m_LFNST ); m_cEncLib.setUseFastLFNST ( m_useFastLFNST ); @@ -499,11 +474,7 @@ void EncApp::xInitLibCfg() } #endif m_cEncLib.setUseCiip ( m_ciip ); -#if !JVET_Q0806 - m_cEncLib.setUseTriangle ( m_Triangle ); -#else m_cEncLib.setUseGeo ( m_Geo ); -#endif m_cEncLib.setUseHashME ( m_HashME ); m_cEncLib.setAllowDisFracMMVD ( m_allowDisFracMMVD ); @@ -528,14 +499,10 @@ void EncApp::xInitLibCfg() m_cEncLib.setWrapAroundOffset ( m_wrapAroundOffset ); // ADD_NEW_TOOL : (encoder app) add setting of tool enabling flags and associated parameters here -#if JVET_Q0246_VIRTUAL_BOUNDARY_ENABLE_FLAG m_cEncLib.setVirtualBoundariesEnabledFlag ( m_virtualBoundariesEnabledFlag ); if( m_cEncLib.getVirtualBoundariesEnabledFlag() ) { m_cEncLib.setVirtualBoundariesPresentFlag ( m_virtualBoundariesPresentFlag ); -#else - m_cEncLib.setLoopFilterAcrossVirtualBoundariesDisabledFlag ( m_loopFilterAcrossVirtualBoundariesDisabledFlag ); -#endif m_cEncLib.setNumVerVirtualBoundaries ( m_numVerVirtualBoundaries ); m_cEncLib.setNumHorVirtualBoundaries ( m_numHorVirtualBoundaries ); for( unsigned i = 0; i < m_numVerVirtualBoundaries; i++ ) @@ -546,18 +513,11 @@ void EncApp::xInitLibCfg() { m_cEncLib.setVirtualBoundariesPosY ( m_virtualBoundariesPosY[ i ], i ); } -#if JVET_Q0246_VIRTUAL_BOUNDARY_ENABLE_FLAG } -#endif m_cEncLib.setMaxCUWidth ( m_uiCTUSize ); m_cEncLib.setMaxCUHeight ( m_uiCTUSize ); -#if JVET_Q0468_Q0469_MIN_LUMA_CB_AND_MIN_QT_FIX m_cEncLib.setLog2MinCodingBlockSize ( m_log2MinCuSize ); -#else - m_cEncLib.setMaxCodingDepth ( m_uiMaxCodingDepth ); - m_cEncLib.setLog2DiffMaxMinCodingBlockSize ( m_uiLog2DiffMaxMinCodingBlockSize ); -#endif m_cEncLib.setLog2MaxTbSize ( m_log2MaxTbSize ); m_cEncLib.setUseEncDbOpt(m_encDbOpt); m_cEncLib.setUseFastLCTU ( m_useFastLCTU ); @@ -578,14 +538,7 @@ void EncApp::xInitLibCfg() m_cEncLib.setUseMIP ( m_MIP ); m_cEncLib.setUseFastMIP ( m_useFastMIP ); m_cEncLib.setFastLocalDualTreeMode ( m_fastLocalDualTreeMode ); -#if !REMOVE_PPS_REXT - m_cEncLib.setCrossComponentPredictionEnabledFlag ( m_crossComponentPredictionEnabledFlag ); -#endif m_cEncLib.setUseReconBasedCrossCPredictionEstimate ( m_reconBasedCrossCPredictionEstimate ); -#if !JVET_Q0441_SAO_MOD_12_BIT - m_cEncLib.setLog2SaoOffsetScale ( CHANNEL_TYPE_LUMA , m_log2SaoOffsetScale[CHANNEL_TYPE_LUMA] ); - m_cEncLib.setLog2SaoOffsetScale ( CHANNEL_TYPE_CHROMA, m_log2SaoOffsetScale[CHANNEL_TYPE_CHROMA] ); -#endif m_cEncLib.setUseTransformSkip ( m_useTransformSkip ); m_cEncLib.setUseTransformSkipFast ( m_useTransformSkipFast ); m_cEncLib.setUseChromaTS ( m_useChromaTS && m_useTransformSkip); @@ -614,24 +567,17 @@ void EncApp::xInitLibCfg() m_cEncLib.setMaxNumMergeCand ( m_maxNumMergeCand ); m_cEncLib.setMaxNumAffineMergeCand ( m_maxNumAffineMergeCand ); -#if !JVET_Q0806 -#if JVET_Q0798_SPS_NUMBER_MERGE_CANDIDATE - m_cEncLib.setMaxNumGeoCand(m_maxNumGeoCand); -#else - m_cEncLib.setMaxNumTriangleCand ( m_maxNumTriangleCand ); -#endif -#else m_cEncLib.setMaxNumGeoCand ( m_maxNumGeoCand ); -#endif m_cEncLib.setMaxNumIBCMergeCand ( m_maxNumIBCMergeCand ); //====== Weighted Prediction ======== m_cEncLib.setUseWP ( m_useWeightedPred ); m_cEncLib.setWPBiPred ( m_useWeightedBiPred ); -#if JVET_Q0297_MER //====== Parallel Merge Estimation ======== m_cEncLib.setLog2ParallelMergeLevelMinus2(m_log2ParallelMergeLevel - 2); +#if JVET_R0110_MIXED_LOSSLESS + m_cEncLib.setSliceLosslessArray(m_sliceLosslessArray); #endif //====== Tiles and Slices ======== @@ -676,20 +622,18 @@ void EncApp::xInitLibCfg() m_cEncLib.setFrameFieldInfoSEIEnabled ( m_frameFieldInfoSEIEnabled ); m_cEncLib.setBpDeltasGOPStructure ( m_bpDeltasGOPStructure ); m_cEncLib.setDecodingUnitInfoSEIEnabled ( m_decodingUnitInfoSEIEnabled ); -#if JVET_P0190_SCALABLE_NESTING_SEI m_cEncLib.setScalableNestingSEIEnabled ( m_scalableNestingSEIEnabled ); -#endif m_cEncLib.setHrdParametersPresentFlag ( m_hrdParametersPresentFlag ); m_cEncLib.setFramePackingArrangementSEIEnabled ( m_framePackingSEIEnabled ); m_cEncLib.setFramePackingArrangementSEIType ( m_framePackingSEIType ); m_cEncLib.setFramePackingArrangementSEIId ( m_framePackingSEIId ); m_cEncLib.setFramePackingArrangementSEIQuincunx ( m_framePackingSEIQuincunx ); m_cEncLib.setFramePackingArrangementSEIInterpretation ( m_framePackingSEIInterpretation ); - m_cEncLib.setErpSEIEnabled ( m_erpSEIEnabled ); - m_cEncLib.setErpSEICancelFlag ( m_erpSEICancelFlag ); - m_cEncLib.setErpSEIPersistenceFlag ( m_erpSEIPersistenceFlag ); - m_cEncLib.setErpSEIGuardBandFlag ( m_erpSEIGuardBandFlag ); - m_cEncLib.setErpSEIGuardBandType ( m_erpSEIGuardBandType ); + m_cEncLib.setErpSEIEnabled ( m_erpSEIEnabled ); + m_cEncLib.setErpSEICancelFlag ( m_erpSEICancelFlag ); + m_cEncLib.setErpSEIPersistenceFlag ( m_erpSEIPersistenceFlag ); + m_cEncLib.setErpSEIGuardBandFlag ( m_erpSEIGuardBandFlag ); + m_cEncLib.setErpSEIGuardBandType ( m_erpSEIGuardBandType ); m_cEncLib.setErpSEILeftGuardBandWidth ( m_erpSEILeftGuardBandWidth ); m_cEncLib.setErpSEIRightGuardBandWidth ( m_erpSEIRightGuardBandWidth ); m_cEncLib.setSphereRotationSEIEnabled ( m_sphereRotationSEIEnabled ); @@ -698,16 +642,16 @@ void EncApp::xInitLibCfg() m_cEncLib.setSphereRotationSEIYaw ( m_sphereRotationSEIYaw ); m_cEncLib.setSphereRotationSEIPitch ( m_sphereRotationSEIPitch ); m_cEncLib.setSphereRotationSEIRoll ( m_sphereRotationSEIRoll ); - m_cEncLib.setOmniViewportSEIEnabled ( m_omniViewportSEIEnabled ); - m_cEncLib.setOmniViewportSEIId ( m_omniViewportSEIId ); - m_cEncLib.setOmniViewportSEICancelFlag ( m_omniViewportSEICancelFlag ); - m_cEncLib.setOmniViewportSEIPersistenceFlag ( m_omniViewportSEIPersistenceFlag ); - m_cEncLib.setOmniViewportSEICntMinus1 ( m_omniViewportSEICntMinus1 ); - m_cEncLib.setOmniViewportSEIAzimuthCentre ( m_omniViewportSEIAzimuthCentre ); - m_cEncLib.setOmniViewportSEIElevationCentre ( m_omniViewportSEIElevationCentre ); - m_cEncLib.setOmniViewportSEITiltCentre ( m_omniViewportSEITiltCentre ); - m_cEncLib.setOmniViewportSEIHorRange ( m_omniViewportSEIHorRange ); - m_cEncLib.setOmniViewportSEIVerRange ( m_omniViewportSEIVerRange ); + m_cEncLib.setOmniViewportSEIEnabled ( m_omniViewportSEIEnabled ); + m_cEncLib.setOmniViewportSEIId ( m_omniViewportSEIId ); + m_cEncLib.setOmniViewportSEICancelFlag ( m_omniViewportSEICancelFlag ); + m_cEncLib.setOmniViewportSEIPersistenceFlag ( m_omniViewportSEIPersistenceFlag ); + m_cEncLib.setOmniViewportSEICntMinus1 ( m_omniViewportSEICntMinus1 ); + m_cEncLib.setOmniViewportSEIAzimuthCentre ( m_omniViewportSEIAzimuthCentre ); + m_cEncLib.setOmniViewportSEIElevationCentre ( m_omniViewportSEIElevationCentre ); + m_cEncLib.setOmniViewportSEITiltCentre ( m_omniViewportSEITiltCentre ); + m_cEncLib.setOmniViewportSEIHorRange ( m_omniViewportSEIHorRange ); + m_cEncLib.setOmniViewportSEIVerRange ( m_omniViewportSEIVerRange ); m_cEncLib.setRwpSEIEnabled (m_rwpSEIEnabled); m_cEncLib.setRwpSEIRwpCancelFlag (m_rwpSEIRwpCancelFlag); m_cEncLib.setRwpSEIRwpPersistenceFlag (m_rwpSEIRwpPersistenceFlag); @@ -735,28 +679,20 @@ void EncApp::xInitLibCfg() m_cEncLib.setRwpSEIRwpGuardBandType (m_rwpSEIRwpGuardBandType); m_cEncLib.setGcmpSEIEnabled ( m_gcmpSEIEnabled ); m_cEncLib.setGcmpSEICancelFlag ( m_gcmpSEICancelFlag ); - m_cEncLib.setGcmpSEIPersistenceFlag ( m_gcmpSEIPersistenceFlag ); + m_cEncLib.setGcmpSEIPersistenceFlag ( m_gcmpSEIPersistenceFlag ); m_cEncLib.setGcmpSEIPackingType ( (uint8_t)m_gcmpSEIPackingType ); - m_cEncLib.setGcmpSEIMappingFunctionType ( (uint8_t)m_gcmpSEIMappingFunctionType ); + m_cEncLib.setGcmpSEIMappingFunctionType ( (uint8_t)m_gcmpSEIMappingFunctionType ); m_cEncLib.setGcmpSEIFaceIndex ( m_gcmpSEIFaceIndex ); m_cEncLib.setGcmpSEIFaceRotation ( m_gcmpSEIFaceRotation ); m_cEncLib.setGcmpSEIFunctionCoeffU ( m_gcmpSEIFunctionCoeffU ); m_cEncLib.setGcmpSEIFunctionUAffectedByVFlag ( m_gcmpSEIFunctionUAffectedByVFlag ); m_cEncLib.setGcmpSEIFunctionCoeffV ( m_gcmpSEIFunctionCoeffV ); - m_cEncLib.setGcmpSEIFunctionVAffectedByUFlag ( m_gcmpSEIFunctionVAffectedByUFlag ); + m_cEncLib.setGcmpSEIFunctionVAffectedByUFlag ( m_gcmpSEIFunctionVAffectedByUFlag ); m_cEncLib.setGcmpSEIGuardBandFlag ( m_gcmpSEIGuardBandFlag ); -#if JVET_Q0343_GCMP_GUARD_BAND_TYPE m_cEncLib.setGcmpSEIGuardBandType ( m_gcmpSEIGuardBandType ); m_cEncLib.setGcmpSEIGuardBandBoundaryExteriorFlag ( m_gcmpSEIGuardBandBoundaryExteriorFlag ); -#else - m_cEncLib.setGcmpSEIGuardBandBoundaryType ( m_gcmpSEIGuardBandBoundaryType ); -#endif m_cEncLib.setGcmpSEIGuardBandSamplesMinus1 ( (uint8_t)m_gcmpSEIGuardBandSamplesMinus1 ); -#if JVET_SUBPIC_LEVEL_CFG m_cEncLib.setSubpicureLevelInfoSEICfg (m_cfgSubpictureLevelInfoSEI); -#else - m_cEncLib.setSubpicureLevelInfoSEIEnabled (m_subpicureLevelInfoSEIEnabled); -#endif m_cEncLib.setSampleAspectRatioInfoSEIEnabled (m_sampleAspectRatioInfoSEIEnabled); m_cEncLib.setSariCancelFlag (m_sariCancelFlag); m_cEncLib.setSariPersistenceFlag (m_sariPersistenceFlag); @@ -808,39 +744,31 @@ void EncApp::xInitLibCfg() m_cEncLib.setCcvSEIMaxLuminanceValue (m_ccvSEIMaxLuminanceValue); m_cEncLib.setCcvSEIAvgLuminanceValue (m_ccvSEIAvgLuminanceValue); m_cEncLib.setEntropyCodingSyncEnabledFlag ( m_entropyCodingSyncEnabledFlag ); -#if JVET_Q0151_Q0205_ENTRYPOINTS +#if JVET_R0165_OPTIONAL_ENTRY_POINT + m_cEncLib.setEntryPointPresentFlag ( m_entryPointPresentFlag ); +#else m_cEncLib.setEntropyCodingSyncEntryPointPresentFlag ( m_entropyCodingSyncEntryPointPresentFlag ); #endif m_cEncLib.setTMVPModeId ( m_TMVPModeId ); m_cEncLib.setSliceLevelRpl ( m_sliceLevelRpl ); m_cEncLib.setSliceLevelDblk ( m_sliceLevelDblk ); m_cEncLib.setSliceLevelSao ( m_sliceLevelSao ); -#if JVET_Q0819_PH_CHANGES m_cEncLib.setSliceLevelWp ( m_sliceLevelWp ); m_cEncLib.setSliceLevelDeltaQp ( m_sliceLevelDeltaQp ); -#endif m_cEncLib.setSliceLevelAlf ( m_sliceLevelAlf ); -#if !JVET_Q0482_REMOVE_CONSTANT_PARAMS - m_cEncLib.setConstantSliceHeaderParamsEnabledFlag ( m_constantSliceHeaderParamsEnabledFlag ); - m_cEncLib.setPPSDepQuantEnabledIdc ( m_PPSDepQuantEnabledIdc ); - m_cEncLib.setPPSRefPicListSPSIdc0 ( m_PPSRefPicListSPSIdc0 ); - m_cEncLib.setPPSRefPicListSPSIdc1 ( m_PPSRefPicListSPSIdc1 ); - m_cEncLib.setPPSMvdL1ZeroIdc ( m_PPSMvdL1ZeroIdc ); - m_cEncLib.setPPSCollocatedFromL0Idc ( m_PPSCollocatedFromL0Idc ); - m_cEncLib.setPPSSixMinusMaxNumMergeCandPlus1 ( m_PPSSixMinusMaxNumMergeCandPlus1 ); -#endif -#if !JVET_Q0806 -#if !JVET_Q0482_REMOVE_CONSTANT_PARAMS - m_cEncLib.setPPSMaxNumMergeCandMinusMaxNumTriangleCandPlus1 ( m_PPSMaxNumMergeCandMinusMaxNumTriangleCandPlus1 ); -#endif -#else -#if !JVET_Q0482_REMOVE_CONSTANT_PARAMS - m_cEncLib.setPPSMaxNumMergeCandMinusMaxNumGeoCandPlus1 ( m_PPSMaxNumMergeCandMinusMaxNumGeoCandPlus1 ); -#endif -#endif m_cEncLib.setUseScalingListId ( m_useScalingListId ); m_cEncLib.setScalingListFileName ( m_scalingListFileName ); m_cEncLib.setDisableScalingMatrixForLfnstBlks ( m_disableScalingMatrixForLfnstBlks); +#if JVET_R0380_SCALING_MATRIX_DISABLE_YCC_OR_RGB + if ( m_cEncLib.getUseColorTrans() && m_cEncLib.getUseScalingListId() ) + { + m_cEncLib.setDisableScalingMatrixForAlternativeColourSpace(m_disableScalingMatrixForAlternativeColourSpace); + } + if ( m_cEncLib.getDisableScalingMatrixForAlternativeColourSpace() ) + { + m_cEncLib.setScalingMatrixDesignatedColourSpace(m_scalingMatrixDesignatedColourSpace); + } +#endif m_cEncLib.setDepQuantEnabledFlag ( m_depQuantEnabledFlag); m_cEncLib.setSignDataHidingEnabledFlag ( m_signDataHidingEnabledFlag); m_cEncLib.setUseRateCtrl ( m_RCEnableRateControl ); @@ -856,13 +784,15 @@ void EncApp::xInitLibCfg() m_cEncLib.setInitialCpbFullness ( m_RCInitialCpbFullness ); #endif m_cEncLib.setCostMode ( m_costMode ); +#if JVET_R0143_TSRCdisableLL + m_cEncLib.setTSRCdisableLL ( m_TSRCdisableLL ); +#endif m_cEncLib.setUseRecalculateQPAccordingToLambda ( m_recalculateQPAccordingToLambda ); -#if JVET_Q0117_PARAMETER_SETS_CLEANUP m_cEncLib.setDCIEnabled ( m_DCIEnabled ); -#else - m_cEncLib.setDecodingParameterSetEnabled ( m_decodingParameterSetEnabled ); -#endif m_cEncLib.setVuiParametersPresentFlag ( m_vuiParametersPresentFlag ); +#if JVET_Q0394_TIMING_SEI + m_cEncLib.setSamePicTimingInAllOLS (m_samePicTimingInAllOLS); +#endif m_cEncLib.setAspectRatioInfoPresentFlag ( m_aspectRatioInfoPresentFlag); m_cEncLib.setAspectRatioIdc ( m_aspectRatioIdc ); m_cEncLib.setSarWidth ( m_sarWidth ); @@ -871,6 +801,10 @@ void EncApp::xInitLibCfg() m_cEncLib.setColourPrimaries ( m_colourPrimaries ); m_cEncLib.setTransferCharacteristics ( m_transferCharacteristics ); m_cEncLib.setMatrixCoefficients ( m_matrixCoefficients ); +#if JVET_R0090_VUI + m_cEncLib.setProgressiveSourceFlag ( m_progressiveSourceFlag); + m_cEncLib.setInterlacedSourceFlag ( m_interlacedSourceFlag); +#endif m_cEncLib.setChromaLocInfoPresentFlag ( m_chromaLocInfoPresentFlag ); m_cEncLib.setChromaSampleLocTypeTopField ( m_chromaSampleLocTypeTopField ); m_cEncLib.setChromaSampleLocTypeBottomField ( m_chromaSampleLocTypeBottomField ); @@ -899,10 +833,8 @@ void EncApp::xInitLibCfg() m_cEncLib.setForceSingleSplitThread ( m_forceSplitSequential ); #endif m_cEncLib.setUseALF ( m_alf ); -#if JVET_Q0795_CCALF m_cEncLib.setUseCCALF ( m_ccalf ); m_cEncLib.setCCALFQpThreshold ( m_ccalfQpThreshold ); -#endif m_cEncLib.setLmcs ( m_lmcsEnabled ); m_cEncLib.setReshapeSignalType ( m_reshapeSignalType ); m_cEncLib.setReshapeIntraCMD ( m_intraCMD ); @@ -1261,11 +1193,7 @@ void EncApp::rateStatsAccum(const AccessUnit& au, const std::vector<uint32_t>& a case NAL_UNIT_CODED_SLICE_GDR: case NAL_UNIT_CODED_SLICE_RADL: case NAL_UNIT_CODED_SLICE_RASL: -#if JVET_Q0117_PARAMETER_SETS_CLEANUP case NAL_UNIT_DCI: -#else - case NAL_UNIT_DPS: -#endif case NAL_UNIT_VPS: case NAL_UNIT_SPS: case NAL_UNIT_PPS: diff --git a/source/App/EncoderApp/EncApp.h b/source/App/EncoderApp/EncApp.h index 2a42fbc8e1ff3e911ce2befd18479736a48a8de1..2597ef4f6c38061f13858211e25bcf15832409d2 100644 --- a/source/App/EncoderApp/EncApp.h +++ b/source/App/EncoderApp/EncApp.h @@ -118,11 +118,9 @@ public: #if JVET_O0756_CALCULATE_HDRMETRICS std::chrono::duration<long long, ratio<1, 1000000000>> getMetricTime() const { return m_metricTime; }; #endif -#if JVET_Q0172_CHROMA_FORMAT_BITDEPTH_CONSTRAINT VPS * getVPS() { return m_cEncLib.getVPS(); } int getChromaFormatIDC() const { return m_cEncLib.getChromaFormatIdc(); } int getBitDepth() const { return m_cEncLib.getBitDepth(CHANNEL_TYPE_LUMA); } -#endif };// END CLASS DEFINITION EncApp //! \} diff --git a/source/App/EncoderApp/EncAppCfg.cpp b/source/App/EncoderApp/EncAppCfg.cpp index d8e68e0b918d8104e8b0eac7caadc663f5a7c7c2..3b5e2bac74675eee35a125a402fa609db7ff98f5 100644 --- a/source/App/EncoderApp/EncAppCfg.cpp +++ b/source/App/EncoderApp/EncAppCfg.cpp @@ -83,13 +83,25 @@ EncAppCfg::EncAppCfg() , m_maxBitDepthConstraintIdc(0) , m_maxChromaFormatConstraintIdc(CHROMA_420) , m_bFrameConstraintFlag(false) +#if JVET_R0286_GCI_CLEANUP +, m_singleLayerConstraintFlag(false) +, m_allLayersIndependentConstraintFlag(false) +, m_noMrlConstraintFlag(false) +, m_noIspConstraintFlag(false) +, m_noMipConstraintFlag(false) +, m_noLfnstConstraintFlag(false) +, m_noMmvdConstraintFlag(false) +, m_noSmvdConstraintFlag(false) +, m_noProfConstraintFlag(false) +, m_noPaletteConstraintFlag(false) +, m_noActConstraintFlag(false) +, m_noLmcsConstraintFlag(false) +#endif , m_bNoQtbttDualTreeIntraConstraintFlag(false) , m_noPartitionConstraintsOverrideConstraintFlag(false) , m_bNoSaoConstraintFlag(false) , m_bNoAlfConstraintFlag(false) -#if JVET_Q0795_CCALF , m_noCCAlfConstraintFlag(false) -#endif , m_bNoRefWraparoundConstraintFlag(false) , m_bNoTemporalMvpConstraintFlag(false) , m_bNoSbtmvpConstraintFlag(false) @@ -104,11 +116,7 @@ EncAppCfg::EncAppCfg() , m_noIbcConstraintFlag(false) , m_bNoCiipConstraintFlag(false) , m_noFPelMmvdConstraintFlag(false) -#if !JVET_Q0806 -, m_bNoTriangleConstraintFlag(false) -#else , m_noGeoConstraintFlag(false) -#endif , m_bNoLadfConstraintFlag(false) , m_noTransformSkipConstraintFlag(false) , m_noBDPCMConstraintFlag(false) @@ -168,12 +176,10 @@ std::istringstream &operator>>(std::istringstream &in, GOPEntry &entry) //in in>>entry.m_QPFactor; in>>entry.m_tcOffsetDiv2; in>>entry.m_betaOffsetDiv2; -#if JVET_Q0121_DEBLOCKING_CONTROL_PARAMETERS in>>entry.m_CbTcOffsetDiv2; in>>entry.m_CbBetaOffsetDiv2; in>>entry.m_CrTcOffsetDiv2; in>>entry.m_CrBetaOffsetDiv2; -#endif in>>entry.m_temporalId; in >> entry.m_numRefPicsActive0; in >> entry.m_numRefPics0; @@ -396,74 +402,22 @@ static inline istream& operator >> (std::istream &in, SMultiValueInput<T> &value return values.readValues(in); } -template<> -uint32_t SMultiValueInput<uint32_t>::readValue(const char *&pStr, bool &bSuccess) -{ - char *eptr; - uint32_t val=strtoul(pStr, &eptr, 0); - pStr=eptr; - bSuccess=!(*eptr!=0 && !isspace(*eptr) && *eptr!=',') && !(val<minValIncl || val>maxValIncl); - return val; -} - -template<> -uint8_t SMultiValueInput<uint8_t>::readValue(const char *&pStr, bool &bSuccess) -{ - char *eptr; - uint32_t val = strtoul(pStr, &eptr, 0); - pStr = eptr; - bSuccess = !(*eptr != 0 && !isspace(*eptr) && *eptr != ',') && !(val<minValIncl || val>maxValIncl); - return val; -} - -template<> -int SMultiValueInput<int>::readValue(const char *&pStr, bool &bSuccess) -{ - char *eptr; - int val=strtol(pStr, &eptr, 0); - pStr=eptr; - bSuccess=!(*eptr!=0 && !isspace(*eptr) && *eptr!=',') && !(val<minValIncl || val>maxValIncl); - return val; -} - -template<> -double SMultiValueInput<double>::readValue(const char *&pStr, bool &bSuccess) -{ - char *eptr; - double val=strtod(pStr, &eptr); - pStr=eptr; - bSuccess=!(*eptr!=0 && !isspace(*eptr) && *eptr!=',') && !(val<minValIncl || val>maxValIncl); - return val; -} - -template<> -bool SMultiValueInput<bool>::readValue(const char *&pStr, bool &bSuccess) -{ - char *eptr; - int val=strtol(pStr, &eptr, 0); - pStr=eptr; - bSuccess=!(*eptr!=0 && !isspace(*eptr) && *eptr!=',') && !(val<int(minValIncl) || val>int(maxValIncl)); - return val!=0; -} - -template<> -Level::Name SMultiValueInput<Level::Name>::readValue(const char *&cStr, bool &success) +template <class T> +T SMultiValueInput<T>::readValue(const char *&pStr, bool &bSuccess) { - // first parse the value from the map, using iostreams - std::istringstream str (cStr); - Level::Name val = Level::NONE; - readStrToEnum(strToLevel, sizeof(strToLevel)/sizeof(*strToLevel), str, val); - - // now read a double to forward the string pointer ignoring the returned value - char *eptr; - strtod(cStr, &eptr); - cStr=eptr; - - success=!(*eptr!=0 && !isspace(*eptr) && *eptr!=',') && !((int)val<int(minValIncl) || (int)val>int(maxValIncl)); + T val=T(); + std::string s(pStr); + std::replace(s.begin(), s.end(), ',', ' '); // make comma separated into space separated + std::istringstream iss(s); + iss>>val; + bSuccess=!iss.fail() // check nothing has gone wrong + && !(val<minValIncl || val>maxValIncl) // check value is within range + && (int)iss.tellg() != 0 // check we've actually read something + && (iss.eof() || iss.peek()==' '); // check next character is a space, or eof + pStr+= (iss.eof() ? s.size() : (std::size_t)iss.tellg()); return val; } - template <class T> istream& SMultiValueInput<T>::readValues(std::istream &in) { @@ -552,7 +506,7 @@ static inline istream& operator >> (std::istream& in, std::map<T1, T2>& map) static uint32_t getMaxTileColsByLevel( Level::Name level ) { - switch( level ) + switch( level ) { case Level::LEVEL1: case Level::LEVEL2: @@ -579,7 +533,7 @@ static uint32_t getMaxTileColsByLevel( Level::Name level ) static uint32_t getMaxTileRowsByLevel( Level::Name level ) { - switch( level ) + switch( level ) { case Level::LEVEL1: case Level::LEVEL2: @@ -606,7 +560,7 @@ static uint32_t getMaxTileRowsByLevel( Level::Name level ) static uint32_t getMaxSlicesByLevel( Level::Name level ) { - switch( level ) + switch( level ) { case Level::LEVEL1: case Level::LEVEL2: @@ -654,9 +608,6 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] ) string inputColourSpaceConvert; string inputPathPrefix; ExtendedProfileName extendedProfile; -#if !JVET_Q0441_SAO_MOD_12_BIT - int saoOffsetBitShift[MAX_NUM_CHANNEL_TYPE]; -#endif // Multi-value input fields: // minval, maxval (incl), min_entries, max_entries (incl) [, default values, number of default values] SMultiValueInput<uint32_t> cfgTileColumnWidth (0, std::numeric_limits<uint32_t>::max(), 0, std::numeric_limits<uint32_t>::max()); @@ -669,7 +620,9 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] ) SMultiValueInput<double> cfg_adIntraLambdaModifier (0, std::numeric_limits<double>::max(), 0, MAX_TLAYER); ///< Lambda modifier for Intra pictures, one for each temporal layer. If size>temporalLayer, then use [temporalLayer], else if size>0, use [size()-1], else use m_adLambdaModifier. - +#if JVET_R0110_MIXED_LOSSLESS + SMultiValueInput<uint32_t> cfgSliceLosslessArray(0, std::numeric_limits<uint32_t>::max(), 0, std::numeric_limits<uint32_t>::max()); +#endif #if SHARP_LUMA_DELTA_QP const int defaultLumaLevelTodQp_QpChangePoints[] = {-3, -2, -1, 0, 1, 2, 3, 4, 5, 6}; const int defaultLumaLevelTodQp_LumaChangePoints[] = { 0, 301, 367, 434, 501, 567, 634, 701, 767, 834}; @@ -716,7 +669,7 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] ) SMultiValueInput<uint32_t> cfg_omniViewportSEIHorRange ( 1, 23592960, 0, 15); SMultiValueInput<uint32_t> cfg_omniViewportSEIVerRange ( 1, 11796480, 0, 15); SMultiValueInput<uint32_t> cfg_rwpSEIRwpTransformType (0, 7, 0, std::numeric_limits<uint8_t>::max()); - SMultiValueInput<bool> cfg_rwpSEIRwpGuardBandFlag (0, 1, 0, std::numeric_limits<uint8_t>::max()); + SMultiValueInput<bool> cfg_rwpSEIRwpGuardBandFlag (0, 1, 0, std::numeric_limits<uint8_t>::max()); SMultiValueInput<uint32_t> cfg_rwpSEIProjRegionWidth (0, std::numeric_limits<uint32_t>::max(), 0, std::numeric_limits<uint8_t>::max()); SMultiValueInput<uint32_t> cfg_rwpSEIProjRegionHeight (0, std::numeric_limits<uint32_t>::max(), 0, std::numeric_limits<uint8_t>::max()); SMultiValueInput<uint32_t> cfg_rwpSEIRwpSEIProjRegionTop (0, std::numeric_limits<uint32_t>::max(), 0, std::numeric_limits<uint8_t>::max()); @@ -751,14 +704,12 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] ) SMultiValueInput<uint32_t> cfg_subPicCtuTopLeftY(0, std::numeric_limits<uint32_t>::max(), 0, MAX_NUM_SUB_PICS); SMultiValueInput<uint32_t> cfg_subPicWidth(1, std::numeric_limits<uint32_t>::max(), 0, MAX_NUM_SUB_PICS); SMultiValueInput<uint32_t> cfg_subPicHeight(1, std::numeric_limits<uint32_t>::max(), 0, MAX_NUM_SUB_PICS); - SMultiValueInput<uint32_t> cfg_subPicTreatedAsPicFlag(0, 1, 0, MAX_NUM_SUB_PICS); - SMultiValueInput<uint32_t> cfg_loopFilterAcrossSubpicEnabledFlag(0, 1, 0, MAX_NUM_SUB_PICS); - SMultiValueInput<uint32_t> cfg_subPicId(0, std::numeric_limits<uint32_t>::max(), 0, MAX_NUM_SUB_PICS); + SMultiValueInput<bool> cfg_subPicTreatedAsPicFlag(0, 1, 0, MAX_NUM_SUB_PICS); + SMultiValueInput<bool> cfg_loopFilterAcrossSubpicEnabledFlag(0, 1, 0, MAX_NUM_SUB_PICS); + SMultiValueInput<uint32_t> cfg_subPicId(0, std::numeric_limits<uint16_t>::max(), 0, MAX_NUM_SUB_PICS); -#if JVET_SUBPIC_LEVEL_CFG SMultiValueInput<int> cfg_sliFractions(0, 100, 0, std::numeric_limits<int>::max()); SMultiValueInput<Level::Name> cfg_sliRefLevels(Level::NONE, Level::LEVEL8_5, 0, 8); -#endif int warnUnknowParameter = 0; @@ -821,9 +772,7 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] ) ("ConfWinTop", m_confWinTop, 0, "Top offset for window conformance mode 3") ("ConfWinBottom", m_confWinBottom, 0, "Bottom offset for window conformance mode 3") ("AccessUnitDelimiter", m_AccessUnitDelimiter, false, "Enable Access Unit Delimiter NALUs") -#if JVET_Q0775_PH_IN_SH ("EnablePictureHeaderInSliceHeader", m_enablePictureHeaderInSliceHeader, true, "Enable Picture Header in Slice Header") -#endif ("FrameRate,-fr", m_iFrameRate, 0, "Frame rate") ("FrameSkip,-fs", m_FrameSkip, 0u, "Number of frames to skip at start of input YUV") ("TemporalSubsampleRatio,-ts", m_temporalSubsampleRatio, 1u, "Temporal sub-sample ratio when reading input YUV") @@ -864,35 +813,29 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] ) ("Level", m_level, Level::NONE, "Level limit to be used, eg 5.1, or none") ("Tier", m_levelTier, Level::MAIN, "Tier to use for interpretation of --Level (main or high only)") ("SubProfile", cfg_SubProfile, cfg_SubProfile, "Sub-profile idc") -#if JVET_Q0117_PARAMETER_SETS_CLEANUP ("EnableDecodingCapabilityInformation", m_DCIEnabled, false, "Enables writing of Decoding Capability Information") -#else - ("EnableDecodingParameterSet", m_decodingParameterSetEnabled, false, "Enables writing of Decoding Parameter Set") -#endif ("MaxBitDepthConstraint", m_bitDepthConstraint, 0u, "Bit depth to use for profile-constraint for RExt profiles. 0=automatically choose based upon other parameters") ("MaxChromaFormatConstraint", tmpConstraintChromaFormat, 0, "Chroma-format to use for the profile-constraint for RExt profiles. 0=automatically choose based upon other parameters") ("IntraConstraintFlag", m_intraConstraintFlag, false, "Value of general_intra_constraint_flag to use for RExt profiles (not used if an explicit RExt sub-profile is specified)") +#if !JVET_R0090_VUI ("ProgressiveSource", m_progressiveSourceFlag, false, "Indicate that source is progressive") ("InterlacedSource", m_interlacedSourceFlag, false, "Indicate that source is interlaced") +#endif ("NonPackedSource", m_nonPackedConstraintFlag, false, "Indicate that source does not contain frame packing") -#if JVET_Q0114_CONSTRAINT_FLAGS ("NonProjectedConstraintFlag", m_nonProjectedConstraintFlag, false, "Indicate that the bitstream contains projection SEI messages") ("NoResChangeInClvsConstraintFlag", m_noResChangeInClvsConstraintFlag, false, "Indicate that the picture spatial resolution does not change within any CLVS referring to the SPS") +#if JVET_R0286_GCI_CLEANUP + ("SingleLayerConstraintFlag", m_singleLayerConstraintFlag, false, "Indicate that the bitstream contains only one layer") + ("AllLayersIndependentConstraintFlag", m_allLayersIndependentConstraintFlag, false, "Indicate that all layers are independent") +#endif ("OneTilePerPicConstraintFlag", m_oneTilePerPicConstraintFlag, false, "Indicate that each picture shall contain only one tile") ("OneSlicePerPicConstraintFlag", m_oneSlicePerPicConstraintFlag, false, "Indicate that each picture shall contain only one slice") ("OneSubpicPerPicConstraintFlag", m_oneSubpicPerPicConstraintFlag, false, "Indicate that each picture shall contain only one subpicture") -#endif ("FrameOnly", m_frameOnlyConstraintFlag, false, "Indicate that the bitstream contains only frames") ("CTUSize", m_uiCTUSize, 128u, "CTUSize (specifies the CTU size if QTBT is on) [default: 128]") -#if JVET_Q0468_Q0469_MIN_LUMA_CB_AND_MIN_QT_FIX ("Log2MinCuSize", m_log2MinCuSize, 2u, "Log2 min CU size") -#endif -#if JVET_Q0119_CLEANUPS ("SubPicInfoPresentFlag", m_subPicInfoPresentFlag, false, "equal to 1 specifies that subpicture parameters are present in in the SPS RBSP syntax") -#else - ("SubPicPresentFlag", m_subPicPresentFlag, false, "equal to 1 specifies that subpicture parameters are present in in the SPS RBSP syntax") -#endif ("NumSubPics", m_numSubPics, 0u, "specifies the number of subpictures") ("SubPicCtuTopLeftX", cfg_subPicCtuTopLeftX, cfg_subPicCtuTopLeftX, "specifies horizontal position of top left CTU of i-th subpicture in unit of CtbSizeY") ("SubPicCtuTopLeftY", cfg_subPicCtuTopLeftY, cfg_subPicCtuTopLeftY, "specifies vertical position of top left CTU of i-th subpicture in unit of CtbSizeY") @@ -900,15 +843,11 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] ) ("SubPicHeight", cfg_subPicHeight, cfg_subPicHeight, "specifies the height of the i-th subpicture in units of CtbSizeY") ("SubPicTreatedAsPicFlag", cfg_subPicTreatedAsPicFlag, cfg_subPicTreatedAsPicFlag, "equal to 1 specifies that the i-th subpicture of each coded picture in the CLVS is treated as a picture in the decoding process excluding in-loop filtering operations") ("LoopFilterAcrossSubpicEnabledFlag", cfg_loopFilterAcrossSubpicEnabledFlag, cfg_loopFilterAcrossSubpicEnabledFlag, "equal to 1 specifies that in-loop filtering operations may be performed across the boundaries of the i-th subpicture in each coded picture in the CLVS") -#if JVET_Q0119_CLEANUPS ("SubPicIdMappingExplicitlySignalledFlag", m_subPicIdMappingExplicitlySignalledFlag, false, "equal to 1 specifies that the subpicture ID mapping is explicitly signalled, either in the SPS or in the PPSs") ("SubPicIdMappingInSpsFlag", m_subPicIdMappingInSpsFlag, false, "equal to 1 specifies that subpicture ID mapping is signalled in the SPS") -#else - ("SubPicIdPresentFlag", m_subPicIdPresentFlag, false, "equal to 1 specifies that subpicture ID mapping is present in the SPS") - ("SubPicIdSignallingPresentFlag", m_subPicIdSignallingPresentFlag, false, "equal to 1 specifies that subpicture ID mapping is signalled in the SPS") -#endif ("SubPicIdLen", m_subPicIdLen, 0u, "specifies the number of bits used to represent the syntax element sps_subpic_id[ i ]. ") ("SubPicId", cfg_subPicId, cfg_subPicId, "specifies that subpicture ID of the i-th subpicture") + ("SingleSlicePerSubpic", m_singleSlicePerSubPicFlag, false, "Enables setting of a single slice per sub-picture (no explicit configuration required)") ("EnablePartitionConstraintsOverride", m_SplitConsOverrideEnabledFlag, true, "Enable partition constraints override") ("MinQTISlice", m_uiMinQT[0], 8u, "MinQTISlice") ("MinQTLumaISlice", m_uiMinQT[0], 8u, "MinQTLumaISlice") @@ -918,14 +857,12 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] ) ("MaxMTTHierarchyDepthI", m_uiMaxMTTHierarchyDepthI, 3u, "MaxMTTHierarchyDepthI") ("MaxMTTHierarchyDepthISliceL", m_uiMaxMTTHierarchyDepthI, 3u, "MaxMTTHierarchyDepthISliceL") ("MaxMTTHierarchyDepthISliceC", m_uiMaxMTTHierarchyDepthIChroma, 3u, "MaxMTTHierarchyDepthISliceC") -#if JVET_Q0330_BLOCK_PARTITION ("MaxBTLumaISlice", m_uiMaxBT[0], 32u, "MaxBTLumaISlice") ("MaxBTChromaISlice", m_uiMaxBT[2], 64u, "MaxBTChromaISlice") ("MaxBTNonISlice", m_uiMaxBT[1], 128u, "MaxBTNonISlice") ("MaxTTLumaISlice", m_uiMaxTT[0], 32u, "MaxTTLumaISlice") ("MaxTTChromaISlice", m_uiMaxTT[2], 32u, "MaxTTChromaISlice") ("MaxTTNonISlice", m_uiMaxTT[1], 64u, "MaxTTNonISlice") -#endif ("DualITree", m_dualTree, false, "Use separate QTBT trees for intra slice luma and chroma channel types") ( "LFNST", m_LFNST, false, "Enable LFNST (0:off, 1:on) [default: off]" ) ( "FastLFNST", m_useFastLFNST, false, "Fast methods for LFNST" ) @@ -970,11 +907,7 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] ) ("LadfIntervalLowerBound", cfg_LadfIntervalLowerBound, cfg_LadfIntervalLowerBound, "LADF lower bound for 2nd lowest interval") #endif ("CIIP", m_ciip, false, "Enable CIIP mode") -#if !JVET_Q0806 - ("Triangle", m_Triangle, false, "Enable triangular shape motion vector prediction (0:off, 1:on)") -#else ("Geo", m_Geo, false, "Enable geometric partitioning mode (0:off, 1:on)") -#endif ("HashME", m_HashME, false, "Enable hash motion estimation (0:off, 1:on)") ("AllowDisFracMMVD", m_allowDisFracMMVD, false, "Disable fractional MVD in MMVD mode adaptively") @@ -997,11 +930,7 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] ) ("WrapAroundOffset", m_wrapAroundOffset, 0u, "Offset in luma samples used for computing the horizontal wrap-around position") // ADD_NEW_TOOL : (encoder app) add parsing parameters here -#if JVET_Q0246_VIRTUAL_BOUNDARY_ENABLE_FLAG ( "VirtualBoundariesPresentInSPSFlag", m_virtualBoundariesPresentFlag, true, "Virtual Boundary position information is signalled in SPS or PH (1:SPS, 0:PH) [default: on]" ) -#else - ("LoopFilterAcrossVirtualBoundariesDisabledFlag", m_loopFilterAcrossVirtualBoundariesDisabledFlag, false, "Disable in-loop filtering operations across the virtual boundaries (0:off, 1:on) [default: off]") -#endif ("NumVerVirtualBoundaries", m_numVerVirtualBoundaries, 0u, "Number of vertical virtual boundaries (0-3, inclusive)") ("NumHorVirtualBoundaries", m_numHorVirtualBoundaries, 0u, "Number of horizontal virtual boundaries (0-3, inclusive)") ("VirtualBoundariesPosX", cfg_virtualBoundariesPosX, cfg_virtualBoundariesPosX, "Locations of the vertical virtual boundaries in units of luma samples") @@ -1036,9 +965,6 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] ) // todo: remove defaults from MaxCUSize ("MaxCUSize,s", m_uiMaxCUWidth, 64u, "Maximum CU size") ("MaxCUSize,s", m_uiMaxCUHeight, 64u, "Maximum CU size") -#if !JVET_Q0468_Q0469_MIN_LUMA_CB_AND_MIN_QT_FIX - ("MaxPartitionDepth,h", m_uiMaxCUDepth, 4u, "CU depth") -#endif ("Log2MaxTbSize", m_log2MaxTbSize, 6, "Maximum transform block size in logarithm base 2 (Default: 6)") @@ -1144,35 +1070,22 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] ) ("LoopFilterOffsetInPPS", m_loopFilterOffsetInPPS, true) ("LoopFilterBetaOffset_div2", m_loopFilterBetaOffsetDiv2, 0) ("LoopFilterTcOffset_div2", m_loopFilterTcOffsetDiv2, 0) -#if JVET_Q0121_DEBLOCKING_CONTROL_PARAMETERS ("LoopFilterCbBetaOffset_div2", m_loopFilterCbBetaOffsetDiv2, 0) ("LoopFilterCbTcOffset_div2", m_loopFilterCbTcOffsetDiv2, 0) ("LoopFilterCrBetaOffset_div2", m_loopFilterCrBetaOffsetDiv2, 0) ("LoopFilterCrTcOffset_div2", m_loopFilterCrTcOffsetDiv2, 0) -#endif #if W0038_DB_OPT ("DeblockingFilterMetric", m_deblockingFilterMetric, 0) #else ("DeblockingFilterMetric", m_DeblockingFilterMetric, false) #endif // Coding tools -#if !REMOVE_PPS_REXT - ("CrossComponentPrediction", m_crossComponentPredictionEnabledFlag, false, "Enable the use of cross-component prediction (not valid in V1 profiles)") -#endif ("ReconBasedCrossCPredictionEstimate", m_reconBasedCrossCPredictionEstimate, false, "When determining the alpha value for cross-component prediction, use the decoded residual rather than the pre-transform encoder-side residual") -#if !JVET_Q0441_SAO_MOD_12_BIT - ("SaoLumaOffsetBitShift", saoOffsetBitShift[CHANNEL_TYPE_LUMA], 0, "Specify the luma SAO bit-shift. If negative, automatically calculate a suitable value based upon bit depth and initial QP") - ("SaoChromaOffsetBitShift", saoOffsetBitShift[CHANNEL_TYPE_CHROMA], 0, "Specify the chroma SAO bit-shift. If negative, automatically calculate a suitable value based upon bit depth and initial QP") -#endif ("TransformSkip", m_useTransformSkip, false, "Intra transform skipping") ("TransformSkipFast", m_useTransformSkipFast, false, "Fast encoder search for transform skipping, winner takes it all mode.") ("TransformSkipLog2MaxSize", m_log2MaxTransformSkipBlockSize, 5U, "Specify transform-skip maximum size. Minimum 2, Maximum 5. (not valid in V1 profiles)") ("ChromaTS", m_useChromaTS, false, "Enable encoder search of chromaTS") -#if JVET_Q0089_SLICE_LOSSLESS_CODING_CHROMA_BDPCM ("BDPCM", m_useBDPCM, false, "BDPCM (0:off, 1:luma and chroma)") -#else - ("BDPCM", m_useBDPCM, 0, "BDPCM (0:off, 1:lumaonly, 2:lumachroma") -#endif ("ISPFast", m_useFastISP, false, "Fast encoder search for ISP") ("ImplicitResidualDPCM", m_rdpcmEnabledFlag[RDPCM_SIGNAL_IMPLICIT], false, "Enable implicitly signalled residual DPCM for intra (also known as sample-adaptive intra predict) (not valid in V1 profiles)") ("ExplicitResidualDPCM", m_rdpcmEnabledFlag[RDPCM_SIGNAL_EXPLICIT], false, "Enable explicitly signalled residual DPCM for inter (not valid in V1 profiles)") @@ -1188,6 +1101,9 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] ) ("SAOLcuBoundary", m_saoCtuBoundary, false, "0: right/bottom CTU boundary areas skipped from SAO parameter estimation, 1: non-deblocked pixels are used for those areas") ("SAOGreedyEnc", m_saoGreedyMergeEnc, false, "SAO greedy merge encoding algorithm") ("EnablePicPartitioning", m_picPartitionFlag, false, "Enable picture partitioning (0: single tile, single slice, 1: multiple tiles/slices can be used)") +#if JVET_R0110_MIXED_LOSSLESS + ("SliceLosslessArray", cfgSliceLosslessArray, cfgSliceLosslessArray, " Lossless slice array Last lossless flag in the list will be repeated uniformly to cover any remaining slice") +#endif ("TileColumnWidthArray", cfgTileColumnWidth, cfgTileColumnWidth, "Tile column widths in units of CTUs. Last column width in list will be repeated uniformly to cover any remaining picture width") ("TileRowHeightArray", cfgTileRowHeight, cfgTileRowHeight, "Tile row heights in units of CTUs. Last row height in list will be repeated uniformly to cover any remaining picture height") ("RasterScanSlices", m_rasterSliceFlag, false, "Indicates if using raster-scan or rectangular slices (0: rectangular, 1: raster-scan)") @@ -1197,7 +1113,6 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] ) ("RasterSliceSizes", cfgRasterSliceSize, cfgRasterSliceSize, "Raster-scan slice sizes in units of tiles. Last size in list will be repeated uniformly to cover any remaining tiles in the picture") ("DisableLoopFilterAcrossTiles", m_disableLFCrossTileBoundaryFlag, false, "Loop filtering applied across tile boundaries or not (0: filter across tile boundaries 1: do not filter across tile boundaries)") ("DisableLoopFilterAcrossSlices", m_disableLFCrossSliceBoundaryFlag, false, "Loop filtering applied across slice boundaries or not (0: filter across slice boundaries 1: do not filter across slice boundaries)") - ("EnableSubPicPartitioning", m_subPicPartitionFlag, true, "Enable Sub-Picture partitioning (0: single slice per sub-picture, 1: multiple slices per sub-picture can be used)") ("FastUDIUseMPMEnabled", m_bFastUDIUseMPMEnabled, true, "If enabled, adapt intra direction search, accounting for MPM") ("FastMEForGenBLowDelayEnabled", m_bFastMEForGenBLowDelayEnabled, true, "If enabled use a fast ME for generalised B Low Delay slices") ("UseBLambdaForNonKeyLowDelayPictures", m_bUseBLambdaForNonKeyLowDelayPictures, true, "Enables use of B-Lambda for non-key low-delay pictures") @@ -1205,29 +1120,25 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] ) ("WeightedPredP,-wpP", m_useWeightedPred, false, "Use weighted prediction in P slices") ("WeightedPredB,-wpB", m_useWeightedBiPred, false, "Use weighted (bidirectional) prediction in B slices") ("WeightedPredMethod,-wpM", tmpWeightedPredictionMethod, int(WP_PER_PICTURE_WITH_SIMPLE_DC_COMBINED_COMPONENT), "Weighted prediction method") -#if JVET_Q0297_MER ("Log2ParallelMergeLevel", m_log2ParallelMergeLevel, 2u, "Parallel merge estimation region") -#endif ("WaveFrontSynchro", m_entropyCodingSyncEnabledFlag, false, "0: entropy coding sync disabled; 1 entropy coding sync enabled") -#if JVET_Q0151_Q0205_ENTRYPOINTS +#if JVET_R0165_OPTIONAL_ENTRY_POINT + ("EntryPointsPresent", m_entryPointPresentFlag, true, "0: entry points is not present; 1 entry points may be present in slice header") +#else ("WaveFrontEntryPointsPresent", m_entropyCodingSyncEntryPointPresentFlag, false, "0: entry points for WPP is not present; 1 entry points for WPP may be present in slice header") #endif ("ScalingList", m_useScalingListId, SCALING_LIST_OFF, "0/off: no scaling list, 1/default: default scaling lists, 2/file: scaling lists specified in ScalingListFile") ("ScalingListFile", m_scalingListFileName, string(""), "Scaling list file name. Use an empty string to produce help.") ("DisableScalingMatrixForLFNST", m_disableScalingMatrixForLfnstBlks, true, "Disable scaling matrices, when enabled, for LFNST-coded blocks") +#if JVET_R0380_SCALING_MATRIX_DISABLE_YCC_OR_RGB + ("DisableScalingMatrixForAlternativeColourSpace", m_disableScalingMatrixForAlternativeColourSpace, false, "Disable scaling matrices when the colour space is not equal to the designated colour space of scaling matrix") + ("ScalingMatrixDesignatedColourSpace", m_scalingMatrixDesignatedColourSpace, true, "Indicates if the designated colour space of scaling matrices is equal to the original colour space") +#endif ("DepQuant", m_depQuantEnabledFlag, true, "Enable dependent quantization (Default: 1)" ) ("SignHideFlag,-SBH", m_signDataHidingEnabledFlag, false, "Enable sign hiding" ) ("MaxNumMergeCand", m_maxNumMergeCand, 5u, "Maximum number of merge candidates") ("MaxNumAffineMergeCand", m_maxNumAffineMergeCand, 5u, "Maximum number of affine merge candidates") -#if !JVET_Q0806 -#if JVET_Q0798_SPS_NUMBER_MERGE_CANDIDATE - ("MaxNumGeoCand", m_maxNumGeoCand, 5u, "Maximum number of geometric partitioning mode candidates") -#else - ("MaxNumTriangleCand", m_maxNumTriangleCand, 5u, "Maximum number of triangle candidates") -#endif -#else ("MaxNumGeoCand", m_maxNumGeoCand, 5u, "Maximum number of geometric partitioning mode candidates") -#endif ("MaxNumIBCMergeCand", m_maxNumIBCMergeCand, 6u, "Maximum number of IBC merge candidates") /* Misc. */ ("SEIDecodedPictureHash,-dph", tmpDecodedPictureHashSEIMappedType, 0, "Control generation of decode picture hash SEI messages\n" @@ -1236,18 +1147,12 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] ) "\t1: use MD5\n" "\t0: disable") ("TMVPMode", m_TMVPModeId, 1, "TMVP mode 0: TMVP disable for all slices. 1: TMVP enable for all slices (default) 2: TMVP enable for certain slices only") -#if !JVET_Q0482_REMOVE_CONSTANT_PARAMS - ("PPSorSliceMode", m_PPSorSliceMode, 0, "Enable signalling certain parameters either in PPS or per slice\n" - "\tmode 0: Always per slice (default), 1: RA settings, 2: LDB settings, 3: LDP settings") -#endif ("SliceLevelRpl", m_sliceLevelRpl, true, "Code reference picture lists in slice headers rather than picture header.") ("SliceLevelDblk", m_sliceLevelDblk, true, "Code deblocking filter parameters in slice headers rather than picture header.") ("SliceLevelSao", m_sliceLevelSao, true, "Code SAO parameters in slice headers rather than picture header.") ("SliceLevelAlf", m_sliceLevelAlf, true, "Code ALF parameters in slice headers rather than picture header.") -#if JVET_Q0819_PH_CHANGES ("SliceLevelWeightedPrediction", m_sliceLevelWp, true, "Code weighted prediction parameters in slice headers rather than picture header.") ("SliceLevelDeltaQp", m_sliceLevelDeltaQp, true, "Code delta Qp in slice headers rather than picture header.") -#endif ("FEN", tmpFastInterSearchMode, int(FASTINTERSEARCH_DISABLED), "fast encoder setting") ("ECU", m_bUseEarlyCU, false, "Early CU setting") ("FDM", m_useFastDecisionForMerge, true, "Fast decision for Merge RD Cost") @@ -1266,9 +1171,15 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] ) ( "RCInitialCpbFullness", m_RCInitialCpbFullness, 0.9, "Rate control: initial CPB fullness" ) #endif ("CostMode", m_costMode, COST_STANDARD_LOSSY, "Use alternative cost functions: choose between 'lossy', 'sequence_level_lossless', 'lossless' (which forces QP to " MACRO_TO_STRING(LOSSLESS_AND_MIXED_LOSSLESS_RD_COST_TEST_QP) ") and 'mixed_lossless_lossy' (which used QP'=" MACRO_TO_STRING(LOSSLESS_AND_MIXED_LOSSLESS_RD_COST_TEST_QP_PRIME) " for pre-estimates of transquant-bypass blocks).") +#if JVET_R0143_TSRCdisableLL + ("TSRCdisableLL", m_TSRCdisableLL, true, "Disable TSRC for lossless coding" ) +#endif ("RecalculateQPAccordingToLambda", m_recalculateQPAccordingToLambda, false, "Recalculate QP values according to lambda values. Do not suggest to be enabled in all intra case") ("HrdParametersPresent,-hrd", m_hrdParametersPresentFlag, false, "Enable generation of hrd_parameters()") ("VuiParametersPresent,-vui", m_vuiParametersPresentFlag, false, "Enable generation of vui_parameters()") +#if JVET_Q0394_TIMING_SEI + ("SamePicTimingInAllOLS", m_samePicTimingInAllOLS, true, "Indicates that the same picture timing SEI message is used in all OLS") +#endif ("AspectRatioInfoPresent", m_aspectRatioInfoPresentFlag, false, "Signals whether aspect_ratio_idc is present") ("AspectRatioIdc", m_aspectRatioIdc, 0, "aspect_ratio_idc") ("SarWidth", m_sarWidth, 0, "horizontal size of the sample aspect ratio") @@ -1277,6 +1188,10 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] ) ("ColourPrimaries", m_colourPrimaries, 2, "Indicates chromaticity coordinates of the source primaries") ("TransferCharacteristics", m_transferCharacteristics, 2, "Indicates the opto-electronic transfer characteristics of the source") ("MatrixCoefficients", m_matrixCoefficients, 2, "Describes the matrix coefficients used in deriving luma and chroma from RGB primaries") +#if JVET_R0090_VUI + ("ProgressiveSource", m_progressiveSourceFlag, false, "Indicate that source is progressive") + ("InterlacedSource", m_interlacedSourceFlag, false, "Indicate that source is interlaced") +#endif ("ChromaLocInfoPresent", m_chromaLocInfoPresentFlag, false, "Signals whether chroma_sample_loc_type_top_field and chroma_sample_loc_type_bottom_field are present") ("ChromaSampleLocTypeTopField", m_chromaSampleLocTypeTopField, 0, "Specifies the location of chroma samples for top field") ("ChromaSampleLocTypeBottomField", m_chromaSampleLocTypeBottomField, 0, "Specifies the location of chroma samples for bottom field") @@ -1288,9 +1203,7 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] ) ("SEIBufferingPeriod", m_bufferingPeriodSEIEnabled, false, "Control generation of buffering period SEI messages") ("SEIPictureTiming", m_pictureTimingSEIEnabled, false, "Control generation of picture timing SEI messages") ("SEIDecodingUnitInfo", m_decodingUnitInfoSEIEnabled, false, "Control generation of decoding unit information SEI message.") -#if JVET_P0190_SCALABLE_NESTING_SEI ("SEIScalableNesting", m_scalableNestingSEIEnabled, false, "Control generation of scalable nesting SEI messages") -#endif ("SEIFrameFieldInfo", m_frameFieldInfoSEIEnabled, false, "Control generation of frame field information SEI messages") ("SEIFramePacking", m_framePackingSEIEnabled, false, "Control generation of frame packing SEI messages") ("SEIFramePackingType", m_framePackingSEIType, 0, "Define frame packing arrangement\n" @@ -1373,22 +1286,14 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] ) ("SEIGcmpFunctionCoeffV", cfg_gcmpSEIFunctionCoeffV, cfg_gcmpSEIFunctionCoeffV, "Specifies the coefficient used in the cubemap mapping function of the v-axis of the i-th face") ("SEIGcmpFunctionVAffectedByUFlag", cfg_gcmpSEIFunctionVAffectedByUFlag, cfg_gcmpSEIFunctionVAffectedByUFlag, "Specifies whether the cubemap mapping function of the v-axis refers to the u position of the sample location") ("SEIGcmpGuardBandFlag", m_gcmpSEIGuardBandFlag, false, "Indicate the existence of guard band areas in the picture") -#if JVET_Q0343_GCMP_GUARD_BAND_TYPE ("SEIGcmpGuardBandType", m_gcmpSEIGuardBandType, 0u, "Indicate the type of the guard bands") ("SEIGcmpGuardBandBoundaryExteriorFlag", m_gcmpSEIGuardBandBoundaryExteriorFlag, false, "Indicate whether face boundaries contain guard bands") -#else - ("SEIGcmpGuardBandBoundaryType", m_gcmpSEIGuardBandBoundaryType, false, "Indicate which face boundaries contain guard bands") -#endif ("SEIGcmpGuardBandSamplesMinus1", m_gcmpSEIGuardBandSamplesMinus1, 0u, "Specifies the number of guard band samples minus1 used in the cubemap projected picture") -#if JVET_SUBPIC_LEVEL_CFG ("SEISubpicLevelInfoEnabled", m_cfgSubpictureLevelInfoSEI.m_enabled, false, "Control generation of Subpicture Level Information SEI messages") ("SEISubpicLevelInfoRefLevels", cfg_sliRefLevels, cfg_sliRefLevels, "List of reference levels for Subpicture Level Information SEI messages") ("SEISubpicLevelInfoExplicitFraction", m_cfgSubpictureLevelInfoSEI.m_explicitFraction, false, "Enable sending of explicit fractions in Subpicture Level Information SEI messages") ("SEISubpicLevelInfoNumSubpics", m_cfgSubpictureLevelInfoSEI.m_numSubpictures, 1, "Number of subpictures for Subpicture Level Information SEI messages") ("SEISubpicLevelInfoRefLevelFractions", cfg_sliFractions, cfg_sliFractions, "List of fractions for Subpicture Level Information SEI messages") -#else - ("SEISubpicureLevelInfo", m_subpicureLevelInfoSEIEnabled, false, "Control generation of Subpicture Level Information SEI messages") -#endif ("SEISampleAspectRatioInfo", m_sampleAspectRatioInfoSEIEnabled, false, "Control generation of Sample Aspect Ratio Information SEI messages") ("SEISARICancelFlag", m_sariCancelFlag, false, "Indicates that Sample Aspect Ratio Information SEI message cancels the persistence or follows") ("SEISARIPersistenceFlag", m_sariPersistenceFlag, true, "Specifies the persistence of the Sample Aspect Ratio Information SEI message") @@ -1461,19 +1366,15 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] ) ("DebugCTU", m_debugCTU, -1, "If DebugBitstream is present, load frames up to this POC from this bitstream. Starting with DebugPOC-frame at CTUline containin debug CTU.") ("EnsureWppBitEqual", m_ensureWppBitEqual, false, "Ensure the results are equal to results with WPP-style parallelism, even if WPP is off") ( "ALF", m_alf, true, "Adaptive Loop Filter\n" ) -#if JVET_Q0795_CCALF ( "CCALF", m_ccalf, true, "Cross-component Adaptive Loop Filter" ) ( "CCALFQpTh", m_ccalfQpThreshold, 37, "QP threshold above which encoder reduces CCALF usage") -#endif ( "ScalingRatioHor", m_scalingRatioHor, 1.0, "Scaling ratio in hor direction" ) ( "ScalingRatioVer", m_scalingRatioVer, 1.0, "Scaling ratio in ver direction" ) ( "FractionNumFrames", m_fractionOfFrames, 1.0, "Encode a fraction of the specified in FramesToBeEncoded frames" ) ( "SwitchPocPeriod", m_switchPocPeriod, 0, "Switch POC period for RPR" ) ( "UpscaledOutput", m_upscaledOutput, 0, "Output upscaled (2), decoded but in full resolution buffer (1) or decoded cropped (0, default) picture for RPR" ) ( "MaxLayers", m_maxLayers, 1, "Max number of layers" ) -#if JVET_Q0814_DPB ( "TargetOutputLayerSet,p", m_targetOlsIdx, -1, "Target output layer set index" ) -#endif ; opts.addOptions() ( "MaxSublayers", m_maxSublayers, 1, "Max number of Sublayers") @@ -1486,9 +1387,7 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] ) ( "OlsModeIdc", m_olsModeIdc, 0, "Output layer set mode") ( "NumOutputLayerSets", m_numOutputLayerSets, 1, "Number of output layer sets") ( "OlsOutputLayer%d", m_olsOutputLayerStr, string(""), MAX_VPS_LAYERS, "Output layer index of i-th OLS") -#if JVET_Q0786_PTL_only ( "NumPTLsInVPS", m_numPtlsInVps, 1, "Number of profile_tier_level structures in VPS" ) -#endif ; opts.addOptions() @@ -1509,7 +1408,6 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] ) opts.addOptions()(cOSS.str(), m_GOPList[i-1], GOPEntry()); } -#if JVET_Q0786_PTL_only for(int i = 0; i < MAX_NUM_OLSS; i++) { std::ostringstream cOSS1; @@ -1520,7 +1418,6 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] ) cOSS2<<"OlsPTLIdx"<<i; opts.addOptions()(cOSS2.str(), m_olsPtlIdx[i], 0); } -#endif po::setDefaults(opts); po::ErrorReporter err; @@ -1681,44 +1578,57 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] ) //number of fields to encode m_framesToBeEncoded *= 2; } -#if JVET_Q0119_CLEANUPS if ( m_subPicInfoPresentFlag ) -#else - if ( m_subPicPresentFlag ) -#endif { - CHECK( m_numSubPics > 255 || m_numSubPics < 1, "Number of subpicture must be within 1 to 255" ); + CHECK( m_numSubPics > MAX_NUM_SUB_PICS || m_numSubPics < 1, "Number of subpicture must be within 1 to 2^16" ); + CHECK( cfg_subPicCtuTopLeftX.values.size() != m_numSubPics, "Number of SubPicCtuTopLeftX values must be equal to NumSubPics"); + CHECK( cfg_subPicCtuTopLeftY.values.size() != m_numSubPics, "Number of SubPicCtuTopLeftY values must be equal to NumSubPics"); + CHECK( cfg_subPicWidth.values.size() != m_numSubPics, "Number of SubPicWidth values must be equal to NumSubPics"); + CHECK( cfg_subPicHeight.values.size() != m_numSubPics, "Number of SubPicHeight values must be equal to NumSubPics"); + CHECK( cfg_subPicTreatedAsPicFlag.values.size() != m_numSubPics, "Number of SubPicTreatedAsPicFlag values must be equal to NumSubPics"); + CHECK( cfg_loopFilterAcrossSubpicEnabledFlag.values.size() != m_numSubPics, "Number of LoopFilterAcrossSubpicEnabledFlag values must be equal to NumSubPics"); + if (m_subPicIdMappingExplicitlySignalledFlag) + { + CHECK( cfg_subPicId.values.size() != m_numSubPics, "Number of SubPicId values must be equal to NumSubPics"); + } m_subPicCtuTopLeftX = cfg_subPicCtuTopLeftX.values; m_subPicCtuTopLeftY = cfg_subPicCtuTopLeftY.values; m_subPicWidth = cfg_subPicWidth.values; m_subPicHeight = cfg_subPicHeight.values; m_subPicTreatedAsPicFlag = cfg_subPicTreatedAsPicFlag.values; m_loopFilterAcrossSubpicEnabledFlag = cfg_loopFilterAcrossSubpicEnabledFlag.values; - m_subPicId = cfg_subPicId.values; - for(int i = 0; i < m_numSubPics; i++) + if (m_subPicIdMappingExplicitlySignalledFlag) { - CHECK(m_subPicCtuTopLeftX[i] + m_subPicWidth[i] > (m_iSourceWidth + m_uiCTUSize - 1) / m_uiCTUSize, "subpicture must not exceed picture boundary"); - CHECK(m_subPicCtuTopLeftY[i] + m_subPicHeight[i] > (m_iSourceHeight + m_uiCTUSize - 1) / m_uiCTUSize, "subpicture must not exceed picture boundary"); + for (int i=0; i < m_numSubPics; i++) + { + m_subPicId[i] = cfg_subPicId.values[i]; + } } -#if JVET_Q0119_CLEANUPS - if (m_subPicIdMappingExplicitlySignalledFlag) + for(int i = 0; i < m_numSubPics; i++) { - if (m_subPicIdMappingInSpsFlag) -#else - if (m_subPicIdPresentFlag) + CHECK(m_subPicCtuTopLeftX[i] + m_subPicWidth[i] > (m_iSourceWidth + m_uiCTUSize - 1) / m_uiCTUSize, "Subpicture must not exceed picture boundary"); + CHECK(m_subPicCtuTopLeftY[i] + m_subPicHeight[i] > (m_iSourceHeight + m_uiCTUSize - 1) / m_uiCTUSize, "Subpicture must not exceed picture boundary"); + } + // automatically determine subpicture ID lenght in case it is not specified + if (m_subPicIdLen == 0) { - if (m_subPicIdSignallingPresentFlag) -#endif + if (m_subPicIdMappingExplicitlySignalledFlag) { - CHECK( m_subPicIdLen > 16, "sibpic ID length must not exceed 16 bits" ); + // use the heighest specified ID + auto maxIdVal = std::max_element(m_subPicId.begin(),m_subPicId.end()); + m_subPicIdLen = ceilLog2(*maxIdVal); + } + else + { + // use the number of subpictures + m_subPicIdLen = ceilLog2(m_numSubPics); } } -#if JVET_Q0043_RPR_and_Subpics + + CHECK( m_subPicIdLen > 16, "SubPicIdLen must not exceed 16 bits" ); CHECK( m_rprEnabled, "RPR and subpictures cannot be enabled together" ); -#endif } -#if JVET_SUBPIC_LEVEL_CFG if (m_cfgSubpictureLevelInfoSEI.m_enabled) { CHECK (m_numSubPics != m_cfgSubpictureLevelInfoSEI.m_numSubpictures, "NumSubPics must be equal to SEISubpicLevelInfoNumSubpics" ); @@ -1729,9 +1639,36 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] ) CHECK (cfg_sliRefLevels.values.size() * m_cfgSubpictureLevelInfoSEI.m_numSubpictures != cfg_sliFractions.values.size(), "Number of subpicture level fractions must be equal to the numer of subpictures times the number of reference levels."); } } + +#if JVET_R0110_MIXED_LOSSLESS + // store slice lossless array + const int maxSlicesPerPicture = 600; // the maximum number of slices per picture is 600 + m_sliceLosslessArray.resize(maxSlicesPerPicture); + if (cfgSliceLosslessArray.values.size() == 0) + { + // Default all slices are lossy + for (uint32_t i = 0; i < maxSlicesPerPicture; i++) + { + m_sliceLosslessArray[i] = 0; + } + } + else + { + for (uint32_t i = 0; i < cfgSliceLosslessArray.values.size(); i++) + { + m_sliceLosslessArray[i] = cfgSliceLosslessArray.values[i]; + } + for (uint32_t i = (uint32_t)cfgSliceLosslessArray.values.size(); i < maxSlicesPerPicture; i++) + { + if (cfgSliceLosslessArray.values.size() > 0) + m_sliceLosslessArray[i] = cfgSliceLosslessArray.values[cfgSliceLosslessArray.values.size() - 1]; + else + m_sliceLosslessArray[i] = 0; + } + } #endif - if( m_picPartitionFlag ) + if( m_picPartitionFlag ) { // store tile column widths m_tileColumnWidth.resize(cfgTileColumnWidth.values.size()); @@ -1748,7 +1685,7 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] ) } // store rectangular slice positions - if( !m_rasterSliceFlag ) + if( !m_rasterSliceFlag ) { m_rectSlicePos.resize(cfgRectSlicePos.values.size()); for(uint32_t i=0; i<cfgRectSlicePos.values.size(); i++) @@ -1758,7 +1695,7 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] ) } // store raster-scan slice sizes - else + else { m_rasterSliceSize.resize(cfgRasterSliceSize.values.size()); for(uint32_t i=0; i<cfgRasterSliceSize.values.size(); i++) @@ -1767,7 +1704,7 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] ) } } } - else + else { m_tileColumnWidth.clear(); m_tileRowHeight.clear(); @@ -1783,14 +1720,6 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] ) { m_subProfile[i] = cfg_SubProfile.values[i]; } - if (m_subPicPartitionFlag) - { - m_singleSlicePerSubPicFlag = false; - } - else - { - m_singleSlicePerSubPicFlag = true; - } /* rules for input, output and internal bitdepths as per help text */ if (m_MSBExtendedBitDepth[CHANNEL_TYPE_LUMA ] == 0) { @@ -1818,8 +1747,8 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] ) m_outputBitDepth [CHANNEL_TYPE_CHROMA] = m_outputBitDepth [CHANNEL_TYPE_LUMA ]; } -#if JVET_Q0151_Q0205_ENTRYPOINTS - if( !m_entropyCodingSyncEnabledFlag ) +#if !JVET_R0165_OPTIONAL_ENTRY_POINT + if( !m_entropyCodingSyncEnabledFlag ) { m_entropyCodingSyncEntryPointPresentFlag = false; } @@ -1871,16 +1800,9 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] ) m_inputColourSpaceConvert = stringToInputColourSpaceConvert(inputColourSpaceConvert, true); m_rgbFormat = (m_inputColourSpaceConvert == IPCOLOURSPACE_RGBtoGBR && m_chromaFormatIDC == CHROMA_444) ? true : false; -#if JVET_Q0468_Q0469_MIN_LUMA_CB_AND_MIN_QT_FIX -#if JVET_Q0260_CONFORMANCE_WINDOW_IN_SPS // Picture width and height must be multiples of 8 and minCuSize const int minResolutionMultiple = std::max(8, 1 << m_log2MinCuSize); CHECK(((m_iSourceWidth% minResolutionMultiple) || (m_iSourceHeight % minResolutionMultiple)) && m_conformanceWindowMode != 1, "Picture width or height is not a multiple of 8 or minCuSize, please use ConformanceMode 1!"); -#else - const int minCuSize = 1 << m_log2MinCuSize; - CHECK(((m_iSourceWidth % minCuSize ) || (m_iSourceHeight % minCuSize )) && m_conformanceWindowMode != 1, "Picture width or height is not a multiple of minCuSize, please use ConformanceMode 1!"); -#endif -#endif switch (m_conformanceWindowMode) { case 0: @@ -1893,16 +1815,6 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] ) case 1: { // automatic padding to minimum CU size -#if !JVET_Q0468_Q0469_MIN_LUMA_CB_AND_MIN_QT_FIX -#if JVET_Q0260_CONFORMANCE_WINDOW_IN_SPS - // Picture width and height must be multiples of 8 and minCuSize - int minCuSize = m_uiMaxCUHeight >> (m_uiMaxCUDepth - 1); - int minResolutionMultiple = std::max(8, minCuSize); -#else - int minCuSize = m_uiMaxCUHeight >> (m_uiMaxCUDepth - 1); -#endif -#endif -#if JVET_Q0260_CONFORMANCE_WINDOW_IN_SPS if (m_iSourceWidth % minResolutionMultiple) { m_aiPad[0] = m_confWinRight = ((m_iSourceWidth / minResolutionMultiple) + 1) * minResolutionMultiple - m_iSourceWidth; @@ -1911,16 +1823,6 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] ) if (m_iSourceHeight % minResolutionMultiple) { m_aiPad[1] = m_confWinBottom = ((m_iSourceHeight / minResolutionMultiple) + 1) * minResolutionMultiple - m_iSourceHeight; -#else - if (m_iSourceWidth % minCuSize) - { - m_aiPad[0] = m_confWinRight = ((m_iSourceWidth / minCuSize) + 1) * minCuSize - m_iSourceWidth; - m_iSourceWidth += m_confWinRight; - } - if (m_iSourceHeight % minCuSize) - { - m_aiPad[1] = m_confWinBottom = ((m_iSourceHeight / minCuSize) + 1) * minCuSize - m_iSourceHeight; -#endif m_iSourceHeight += m_confWinBottom; if ( m_isField ) { @@ -2014,26 +1916,6 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] ) } #endif -#if !JVET_Q0441_SAO_MOD_12_BIT - for(uint32_t ch=0; ch<MAX_NUM_CHANNEL_TYPE; ch++) - { - if (saoOffsetBitShift[ch]<0) - { - if (m_internalBitDepth[ch]>10) - { - m_log2SaoOffsetScale[ch]=uint32_t(Clip3<int>(0, m_internalBitDepth[ch]-10, int(m_internalBitDepth[ch]-10 + 0.165*m_iQP - 3.22 + 0.5) ) ); - } - else - { - m_log2SaoOffsetScale[ch]=0; - } - } - else - { - m_log2SaoOffsetScale[ch]=uint32_t(saoOffsetBitShift[ch]); - } - } -#endif #if SHARP_LUMA_DELTA_QP CHECK( lumaLevelToDeltaQPMode >= LUMALVL_TO_DQP_NUM_MODES, "Error in cfg" ); @@ -2057,18 +1939,37 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] ) if (m_useIdentityTableForNon420Chroma && m_chromaFormatIDC != CHROMA_420) { m_chromaQpMappingTableParams.m_sameCQPTableForAllChromaFlag = true; - cfg_qpInValCb.values = { 0 }; - cfg_qpInValCr.values = { 0 }; - cfg_qpInValCbCr.values = { 0 }; - cfg_qpOutValCb.values = { 0 }; - cfg_qpOutValCr.values = { 0 }; - cfg_qpOutValCbCr.values = { 0 }; + + cfg_qpInValCb.values = { 26 }; + cfg_qpInValCr.values = { 26 }; + cfg_qpInValCbCr.values = { 26 }; + cfg_qpOutValCb.values = { 26 }; + cfg_qpOutValCr.values = { 26 }; + cfg_qpOutValCbCr.values = { 26 }; } + + // Need to have at least 2 points in the set. Add second one if only one given + if (cfg_qpInValCb.values.size() == 1) + { + cfg_qpInValCb.values.push_back(cfg_qpInValCb.values[0] + 1); + cfg_qpOutValCb.values.push_back(cfg_qpOutValCb.values[0] + 1); + } + if (cfg_qpInValCr.values.size() == 1) + { + cfg_qpInValCr.values.push_back(cfg_qpInValCr.values[0] + 1); + cfg_qpOutValCr.values.push_back(cfg_qpOutValCr.values[0] + 1); + } + if (cfg_qpInValCbCr.values.size() == 1) + { + cfg_qpInValCbCr.values.push_back(cfg_qpInValCbCr.values[0] + 1); + cfg_qpOutValCbCr.values.push_back(cfg_qpOutValCbCr.values[0] + 1); + } + int qpBdOffsetC = 6 * (m_internalBitDepth[CHANNEL_TYPE_CHROMA] - 8); m_chromaQpMappingTableParams.m_deltaQpInValMinus1[0].resize(cfg_qpInValCb.values.size()); m_chromaQpMappingTableParams.m_deltaQpOutVal[0].resize(cfg_qpOutValCb.values.size()); - m_chromaQpMappingTableParams.m_numPtsInCQPTableMinus1[0] = (cfg_qpOutValCb.values.size() > 1) ? (int)cfg_qpOutValCb.values.size() - 2 : 0; - m_chromaQpMappingTableParams.m_qpTableStartMinus26[0] = (cfg_qpOutValCb.values.size() > 1) ? -26 + cfg_qpInValCb.values[0] : 0; + m_chromaQpMappingTableParams.m_numPtsInCQPTableMinus1[0] = (int) cfg_qpOutValCb.values.size() - 2; + m_chromaQpMappingTableParams.m_qpTableStartMinus26[0] = -26 + cfg_qpInValCb.values[0]; CHECK(m_chromaQpMappingTableParams.m_qpTableStartMinus26[0] < -26 - qpBdOffsetC || m_chromaQpMappingTableParams.m_qpTableStartMinus26[0] > 36, "qpTableStartMinus26[0] is out of valid range of -26 -qpBdOffsetC to 36, inclusive.") CHECK(cfg_qpInValCb.values[0] != cfg_qpOutValCb.values[0], "First qpInValCb value should be equal to first qpOutValCb value"); for (int i = 0; i < cfg_qpInValCb.values.size() - 1; i++) @@ -2082,8 +1983,8 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] ) { m_chromaQpMappingTableParams.m_deltaQpInValMinus1[1].resize(cfg_qpInValCr.values.size()); m_chromaQpMappingTableParams.m_deltaQpOutVal[1].resize(cfg_qpOutValCr.values.size()); - m_chromaQpMappingTableParams.m_numPtsInCQPTableMinus1[1] = (cfg_qpOutValCr.values.size() > 1) ? (int)cfg_qpOutValCr.values.size() - 2 : 0; - m_chromaQpMappingTableParams.m_qpTableStartMinus26[1] = (cfg_qpOutValCr.values.size() > 1) ? -26 + cfg_qpInValCr.values[0] : 0; + m_chromaQpMappingTableParams.m_numPtsInCQPTableMinus1[1] = (int) cfg_qpOutValCr.values.size() - 2; + m_chromaQpMappingTableParams.m_qpTableStartMinus26[1] = -26 + cfg_qpInValCr.values[0]; CHECK(m_chromaQpMappingTableParams.m_qpTableStartMinus26[1] < -26 - qpBdOffsetC || m_chromaQpMappingTableParams.m_qpTableStartMinus26[1] > 36, "qpTableStartMinus26[1] is out of valid range of -26 -qpBdOffsetC to 36, inclusive.") CHECK(cfg_qpInValCr.values[0] != cfg_qpOutValCr.values[0], "First qpInValCr value should be equal to first qpOutValCr value"); for (int i = 0; i < cfg_qpInValCr.values.size() - 1; i++) @@ -2095,8 +1996,8 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] ) } m_chromaQpMappingTableParams.m_deltaQpInValMinus1[2].resize(cfg_qpInValCbCr.values.size()); m_chromaQpMappingTableParams.m_deltaQpOutVal[2].resize(cfg_qpOutValCbCr.values.size()); - m_chromaQpMappingTableParams.m_numPtsInCQPTableMinus1[2] = (cfg_qpOutValCbCr.values.size() > 1) ? (int)cfg_qpOutValCbCr.values.size() - 2 : 0; - m_chromaQpMappingTableParams.m_qpTableStartMinus26[2] = (cfg_qpOutValCbCr.values.size() > 1) ? -26 + cfg_qpInValCbCr.values[0] : 0; + m_chromaQpMappingTableParams.m_numPtsInCQPTableMinus1[2] = (int) cfg_qpOutValCbCr.values.size() - 2; + m_chromaQpMappingTableParams.m_qpTableStartMinus26[2] = -26 + cfg_qpInValCbCr.values[0]; CHECK(m_chromaQpMappingTableParams.m_qpTableStartMinus26[2] < -26 - qpBdOffsetC || m_chromaQpMappingTableParams.m_qpTableStartMinus26[2] > 36, "qpTableStartMinus26[2] is out of valid range of -26 -qpBdOffsetC to 36, inclusive.") CHECK(cfg_qpInValCbCr.values[0] != cfg_qpInValCbCr.values[0], "First qpInValCbCr value should be equal to first qpOutValCbCr value"); for (int i = 0; i < cfg_qpInValCbCr.values.size() - 1; i++) @@ -2122,7 +2023,19 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] ) } #endif - + if (m_chromaFormatIDC != CHROMA_420) + { + if (!m_horCollocatedChromaFlag) + { + msg(WARNING, "\nWARNING: HorCollocatedChroma is forced to 1 for chroma formats other than 4:2:0\n"); + m_horCollocatedChromaFlag = true; + } + if (!m_verCollocatedChromaFlag) + { + msg(WARNING, "\nWARNING: VerCollocatedChroma is forced to 1 for chroma formats other than 4:2:0\n"); + m_verCollocatedChromaFlag = true; + } + } #if JVET_O0756_CONFIG_HDRMETRICS && !JVET_O0756_CALCULATE_HDRMETRICS if ( m_calculateHdrMetrics == true) { @@ -2131,23 +2044,16 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] ) } #endif -#if JVET_Q0246_VIRTUAL_BOUNDARY_ENABLE_FLAG m_virtualBoundariesEnabledFlag = 0; if( m_numVerVirtualBoundaries > 0 || m_numHorVirtualBoundaries > 0 ) m_virtualBoundariesEnabledFlag = 1; if( m_virtualBoundariesEnabledFlag ) { -#if JVET_Q0210_SUBPIC_VIRTUAL_BOUNDARY_CONSTRAINT CHECK( m_subPicInfoPresentFlag && m_virtualBoundariesPresentFlag != 1, "When subpicture signalling is present, the signalling of virtual boundaries, if present, shall be in the SPS" ); -#endif if( m_virtualBoundariesPresentFlag ) { -#else - if ( m_loopFilterAcrossVirtualBoundariesDisabledFlag ) - { -#endif CHECK( m_numVerVirtualBoundaries > 3, "Number of vertical virtual boundaries must be comprised between 0 and 3 included" ); CHECK( m_numHorVirtualBoundaries > 3, "Number of horizontal virtual boundaries must be comprised between 0 and 3 included" ); CHECK( m_numVerVirtualBoundaries != cfg_virtualBoundariesPosX.values.size(), "Size of VirtualBoundariesPosX must be equal to NumVerVirtualBoundaries"); @@ -2181,9 +2087,7 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] ) } } } -#if JVET_Q0246_VIRTUAL_BOUNDARY_ENABLE_FLAG } -#endif if ( m_alf ) { @@ -2282,7 +2186,7 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] ) m_rwpSEIPackedRegionWidth[i] = cfg_rwpSEIPackedRegionWidth.values[i]; m_rwpSEIPackedRegionHeight[i] = cfg_rwpSEIPackedRegionHeight.values[i]; m_rwpSEIPackedRegionTop[i] = cfg_rwpSEIPackedRegionTop.values[i]; - m_rwpSEIPackedRegionLeft[i] = cfg_rwpSEIPackedRegionLeft.values[i]; + m_rwpSEIPackedRegionLeft[i] = cfg_rwpSEIPackedRegionLeft.values[i]; if( m_rwpSEIRwpGuardBandFlag[i] ) { m_rwpSEIRwpLeftGuardBandWidth[i] = cfg_rwpSEIRwpLeftGuardBandWidth.values[i]; @@ -2386,26 +2290,17 @@ bool EncAppCfg::parseCfg( int argc, char* argv[] ) #endif #endif // ENABLE_QPA -#if JVET_AHG14_LOSSLESS_ENC_QP_FIX +#if JVET_R0110_MIXED_LOSSLESS + if (m_costMode == COST_LOSSLESS_CODING && m_sliceLosslessArray[0]) // if first slice is lossless +#else if( m_costMode == COST_LOSSLESS_CODING ) +#endif { m_iQP = LOSSLESS_AND_MIXED_LOSSLESS_RD_COST_TEST_QP - ( ( m_internalBitDepth[CHANNEL_TYPE_LUMA] - 8 ) * 6 ); } -#endif -#if !JVET_Q0468_Q0469_MIN_LUMA_CB_AND_MIN_QT_FIX - const int minCuSize = 1 << MIN_CU_LOG2; - m_uiMaxCodingDepth = 0; - while( ( m_uiCTUSize >> m_uiMaxCodingDepth ) > minCuSize ) - { - m_uiMaxCodingDepth++; - } - m_uiLog2DiffMaxMinCodingBlockSize = m_uiMaxCodingDepth; -#endif + m_uiMaxCUWidth = m_uiMaxCUHeight = m_uiCTUSize; -#if !JVET_Q0468_Q0469_MIN_LUMA_CB_AND_MIN_QT_FIX - m_uiMaxCUDepth = m_uiMaxCodingDepth; -#endif // check validity of input parameters if( xCheckParameter() ) @@ -2489,15 +2384,9 @@ bool EncAppCfg::xCheckParameter() if( m_wrapAround ) { -#if JVET_Q0468_Q0469_MIN_LUMA_CB_AND_MIN_QT_FIX const int minCUSize = 1 << m_log2MinCuSize; xConfirmPara(m_wrapAroundOffset <= m_uiCTUSize + minCUSize, "Wrap-around offset must be greater than CtbSizeY + MinCbSize"); xConfirmPara(m_wrapAroundOffset > m_iSourceWidth, "Wrap-around offset must not be greater than the source picture width"); -#else - xConfirmPara( m_wrapAroundOffset <= m_uiCTUSize + (m_uiMaxCUWidth >> m_uiLog2DiffMaxMinCodingBlockSize), "Wrap-around offset must be greater than CtbSizeY + MinCbSize" ); - xConfirmPara( m_wrapAroundOffset > m_iSourceWidth, "Wrap-around offset must not be greater than the source picture width" ); - int minCUSize = m_uiCTUSize >> m_uiLog2DiffMaxMinCodingBlockSize; -#endif xConfirmPara( m_wrapAroundOffset % minCUSize != 0, "Wrap-around offset must be an integer multiple of the specified minimum CU size" ); } @@ -2532,9 +2421,6 @@ bool EncAppCfg::xCheckParameter() xConfirmPara(m_internalBitDepth[CHANNEL_TYPE_CHROMA] != m_internalBitDepth[CHANNEL_TYPE_LUMA], "The internalBitDepth must be the same for luma and chroma"); if (m_profile==Profile::MAIN_10 || m_profile==Profile::MAIN_444_10) { -#if !REMOVE_PPS_REXT - xConfirmPara(m_crossComponentPredictionEnabledFlag==true, "CrossComponentPrediction must not be used for given profile."); -#endif xConfirmPara(m_log2MaxTransformSkipBlockSize>=6, "Transform Skip Log2 Max Size must be less or equal to 5 for given profile."); xConfirmPara(m_transformSkipRotationEnabledFlag==true, "UseResidualRotation must not be enabled for given profile."); xConfirmPara(m_transformSkipContextEnabledFlag==true, "UseSingleSignificanceMapContext must not be enabled for given profile."); @@ -2580,10 +2466,6 @@ bool EncAppCfg::xCheckParameter() xConfirmPara( (m_MSBExtendedBitDepth[CHANNEL_TYPE_LUMA ] < m_inputBitDepth[CHANNEL_TYPE_LUMA ]), "MSB-extended bit depth for luma channel (--MSBExtendedBitDepth) must be greater than or equal to input bit depth for luma channel (--InputBitDepth)" ); xConfirmPara( (m_MSBExtendedBitDepth[CHANNEL_TYPE_CHROMA] < m_inputBitDepth[CHANNEL_TYPE_CHROMA]), "MSB-extended bit depth for chroma channel (--MSBExtendedBitDepthC) must be greater than or equal to input bit depth for chroma channel (--InputBitDepthC)" ); -#if !JVET_Q0441_SAO_MOD_12_BIT - xConfirmPara( m_log2SaoOffsetScale[CHANNEL_TYPE_LUMA] > (m_internalBitDepth[CHANNEL_TYPE_LUMA ]<10?0:(m_internalBitDepth[CHANNEL_TYPE_LUMA ]-10)), "SaoLumaOffsetBitShift must be in the range of 0 to InternalBitDepth-10, inclusive"); - xConfirmPara( m_log2SaoOffsetScale[CHANNEL_TYPE_CHROMA] > (m_internalBitDepth[CHANNEL_TYPE_CHROMA]<10?0:(m_internalBitDepth[CHANNEL_TYPE_CHROMA]-10)), "SaoChromaOffsetBitShift must be in the range of 0 to InternalBitDepth-10, inclusive"); -#endif xConfirmPara( m_chromaFormatIDC >= NUM_CHROMA_FORMAT, "ChromaFormatIDC must be either 400, 420, 422 or 444" ); std::string sTempIPCSC="InputColourSpaceConvert must be empty, "+getListOfColourSpaceConverts(true); @@ -2616,16 +2498,6 @@ bool EncAppCfg::xCheckParameter() m_pictureTimingSEIEnabled = false; } -#if !REMOVE_PPS_REXT - if(m_crossComponentPredictionEnabledFlag && (m_chromaFormatIDC != CHROMA_444)) - { - msg( WARNING, "****************************************************************************\n"); - msg( WARNING, "** WARNING: Cross-component prediction is specified for 4:4:4 format only **\n"); - msg( WARNING, "****************************************************************************\n"); - - m_crossComponentPredictionEnabledFlag = false; - } -#endif xConfirmPara( m_bufferingPeriodSEIEnabled == true && m_RCCpbSize == 0, "RCCpbSize must be greater than zero, when buffering period SEI is enabled" ); xConfirmPara (m_log2MaxTransformSkipBlockSize < 2, "Transform Skip Log2 Max Size must be at least 2 (4x4)"); @@ -2651,17 +2523,12 @@ bool EncAppCfg::xCheckParameter() #else xConfirmPara( m_DeblockingFilterMetric && (m_bLoopFilterDisable || m_loopFilterOffsetInPPS), "If DeblockingFilterMetric is true then both LoopFilterDisable and LoopFilterOffsetInPPS must be 0"); #endif -#if JVET_Q0121_DEBLOCKING_CONTROL_PARAMETERS xConfirmPara( m_loopFilterBetaOffsetDiv2 < -12 || m_loopFilterBetaOffsetDiv2 > 12, "Loop Filter Beta Offset div. 2 exceeds supported range (-12 to 12" ); xConfirmPara( m_loopFilterTcOffsetDiv2 < -12 || m_loopFilterTcOffsetDiv2 > 12, "Loop Filter Tc Offset div. 2 exceeds supported range (-12 to 12)" ); xConfirmPara( m_loopFilterCbBetaOffsetDiv2 < -12 || m_loopFilterCbBetaOffsetDiv2 > 12, "Loop Filter Beta Offset div. 2 exceeds supported range (-12 to 12" ); xConfirmPara( m_loopFilterCbTcOffsetDiv2 < -12 || m_loopFilterCbTcOffsetDiv2 > 12, "Loop Filter Tc Offset div. 2 exceeds supported range (-12 to 12)" ); xConfirmPara( m_loopFilterCrBetaOffsetDiv2 < -12 || m_loopFilterCrBetaOffsetDiv2 > 12, "Loop Filter Beta Offset div. 2 exceeds supported range (-12 to 12" ); xConfirmPara( m_loopFilterCrTcOffsetDiv2 < -12 || m_loopFilterCrTcOffsetDiv2 > 12, "Loop Filter Tc Offset div. 2 exceeds supported range (-12 to 12)" ); -#else - xConfirmPara( m_loopFilterBetaOffsetDiv2 < -6 || m_loopFilterBetaOffsetDiv2 > 6, "Loop Filter Beta Offset div. 2 exceeds supported range (-6 to 6)" ); - xConfirmPara( m_loopFilterTcOffsetDiv2 < -6 || m_loopFilterTcOffsetDiv2 > 6, "Loop Filter Tc Offset div. 2 exceeds supported range (-6 to 6)" ); -#endif xConfirmPara( m_iSearchRange < 0 , "Search Range must be more than 0" ); xConfirmPara( m_bipredSearchRange < 0 , "Bi-prediction refinement search range must be more than 0" ); xConfirmPara( m_minSearchWindow < 0, "Minimum motion search window size for the adaptive window ME must be greater than or equal to 0" ); @@ -2715,7 +2582,6 @@ bool EncAppCfg::xCheckParameter() xConfirmPara( m_cbQpOffsetDualTree > 12, "Max. Chroma Cb QP Offset for dual tree is 12" ); xConfirmPara( m_crQpOffsetDualTree < -12, "Min. Chroma Cr QP Offset for dual tree is -12" ); xConfirmPara( m_crQpOffsetDualTree > 12, "Max. Chroma Cr QP Offset for dual tree is 12" ); -#if JVET_Q0438_MONOCHROME_BUGFIXES if (m_dualTree && (m_chromaFormatIDC == CHROMA_400)) { msg( WARNING, "****************************************************************************\n"); @@ -2730,7 +2596,6 @@ bool EncAppCfg::xCheckParameter() msg( WARNING, "****************************************************************************\n"); m_ccalf = false; } -#endif if (m_JointCbCrMode && (m_chromaFormatIDC == CHROMA_400)) { msg( WARNING, "****************************************************************************\n"); @@ -2750,13 +2615,17 @@ bool EncAppCfg::xCheckParameter() { xConfirmPara( m_iIntraPeriod > 0 && m_iIntraPeriod <= m_iGOPSize , "Intra period must be larger than GOP size for periodic IDR pictures"); } -#if !JVET_Q0468_Q0469_MIN_LUMA_CB_AND_MIN_QT_FIX - xConfirmPara( m_uiMaxCUDepth > MAX_CU_DEPTH, "MaxPartitionDepth exceeds predefined MAX_CU_DEPTH limit"); -#endif xConfirmPara( m_uiMaxCUWidth > MAX_CU_SIZE, "MaxCUWith exceeds predefined MAX_CU_SIZE limit"); -#if JVET_Q0468_Q0469_MIN_LUMA_CB_AND_MIN_QT_FIX const int minCuSize = 1 << m_log2MinCuSize; +#if JVET_R0347_MTT_SIZE_CONSTRAIN + xConfirmPara( m_uiMinQT[0] > 64, "Min Luma QT size in I slices should be smaller than or equal to 64"); + xConfirmPara( m_uiMinQT[1] > 64, "Min Luma QT size in non-I slices should be smaller than or equal to 64"); + xConfirmPara( m_uiMaxBT[2] > 64, "Maximum BT size for chroma block in I slice should be smaller than or equal to 64"); + xConfirmPara( m_uiMaxTT[0] > 64, "Maximum TT size for luma block in I slice should be smaller than or equal to 64"); + xConfirmPara( m_uiMaxTT[1] > 64, "Maximum TT size for luma block in non-I slice should be smaller than or equal to 64"); + xConfirmPara( m_uiMaxTT[2] > 64, "Maximum TT size for chroma block in I slice should be smaller than or equal to 64"); +#endif xConfirmPara( m_uiMinQT[0] < minCuSize, "Min Luma QT size in I slices should be larger than or equal to minCuSize"); xConfirmPara( m_uiMinQT[1] < minCuSize, "Min Luma QT size in non-I slices should be larger than or equal to minCuSize"); xConfirmPara((m_iSourceWidth % minCuSize ) || (m_iSourceHeight % minCuSize), "Picture width or height is not a multiple of minCuSize"); @@ -2764,43 +2633,27 @@ bool EncAppCfg::xCheckParameter() xConfirmPara( minDiff < 0 , "Min Chroma QT size in I slices is smaller than Min Luma CU size even considering color format"); xConfirmPara( (m_uiMinQT[2] << (int)getChannelTypeScaleX(CHANNEL_TYPE_CHROMA, m_chromaFormatIDC)) > std::min(64, (int)m_uiCTUSize), "Min Chroma QT size in I slices should be smaller than or equal to CTB size or CB size after implicit split of CTB"); -#else - xConfirmPara( m_uiMinQT[0] < 1<<MIN_CU_LOG2, "Minimum QT size should be larger than or equal to 4"); - xConfirmPara( m_uiMinQT[1] < 1<<MIN_CU_LOG2, "Minimum QT size should be larger than or equal to 4"); -#endif xConfirmPara( m_uiCTUSize < 32, "CTUSize must be greater than or equal to 32"); xConfirmPara( m_uiCTUSize > 128, "CTUSize must be less than or equal to 128"); xConfirmPara( m_uiCTUSize != 32 && m_uiCTUSize != 64 && m_uiCTUSize != 128, "CTUSize must be a power of 2 (32, 64, or 128)"); -#if !JVET_Q0468_Q0469_MIN_LUMA_CB_AND_MIN_QT_FIX - xConfirmPara( m_uiMaxCUDepth < 1, "MaxPartitionDepth must be greater than zero"); - xConfirmPara( (m_uiMaxCUWidth >> m_uiMaxCUDepth) < 4, "Minimum partition width size should be larger than or equal to 8"); - xConfirmPara( (m_uiMaxCUHeight >> m_uiMaxCUDepth) < 4, "Minimum partition height size should be larger than or equal to 8"); -#endif xConfirmPara( m_uiMaxCUWidth < 16, "Maximum partition width size should be larger than or equal to 16"); xConfirmPara( m_uiMaxCUHeight < 16, "Maximum partition height size should be larger than or equal to 16"); -#if JVET_Q0330_BLOCK_PARTITION xConfirmPara( m_uiMaxBT[0] < m_uiMinQT[0], "Maximum BT size for luma block in I slice should be larger than minimum QT size"); xConfirmPara( m_uiMaxBT[0] > m_uiCTUSize, "Maximum BT size for luma block in I slice should be smaller than or equal to CTUSize"); xConfirmPara( m_uiMaxBT[1] < m_uiMinQT[1], "Maximum BT size for luma block in non I slice should be larger than minimum QT size"); xConfirmPara( m_uiMaxBT[1] > m_uiCTUSize, "Maximum BT size for luma block in non I slice should be smaller than or equal to CTUSize"); - xConfirmPara( m_uiMaxBT[2] < (m_uiMinQT[2] << (int)getChannelTypeScaleX(CHANNEL_TYPE_CHROMA, m_chromaFormatIDC)), + xConfirmPara( m_uiMaxBT[2] < (m_uiMinQT[2] << (int)getChannelTypeScaleX(CHANNEL_TYPE_CHROMA, m_chromaFormatIDC)), "Maximum BT size for chroma block in I slice should be larger than minimum QT size"); xConfirmPara( m_uiMaxBT[2] > m_uiCTUSize, "Maximum BT size for chroma block in I slice should be smaller than or equal to CTUSize"); xConfirmPara( m_uiMaxTT[0] < m_uiMinQT[0], "Maximum TT size for luma block in I slice should be larger than minimum QT size"); xConfirmPara( m_uiMaxTT[0] > m_uiCTUSize, "Maximum TT size for luma block in I slice should be smaller than or equal to CTUSize"); xConfirmPara( m_uiMaxTT[1] < m_uiMinQT[1], "Maximum TT size for luma block in non I slice should be larger than minimum QT size"); xConfirmPara( m_uiMaxTT[1] > m_uiCTUSize, "Maximum TT size for luma block in non I slice should be smaller than or equal to CTUSize"); - xConfirmPara( m_uiMaxTT[2] < (m_uiMinQT[2] << (int)getChannelTypeScaleX(CHANNEL_TYPE_CHROMA, m_chromaFormatIDC)), + xConfirmPara( m_uiMaxTT[2] < (m_uiMinQT[2] << (int)getChannelTypeScaleX(CHANNEL_TYPE_CHROMA, m_chromaFormatIDC)), "Maximum TT size for chroma block in I slice should be larger than minimum QT size"); xConfirmPara( m_uiMaxTT[2] > m_uiCTUSize, "Maximum TT size for chroma block in I slice should be smaller than or equal to CTUSize"); -#endif -#if JVET_Q0468_Q0469_MIN_LUMA_CB_AND_MIN_QT_FIX xConfirmPara( (m_iSourceWidth % (std::max(8u, m_log2MinCuSize))) != 0, "Resulting coded frame width must be a multiple of Max(8, the minimum CU size)"); xConfirmPara( (m_iSourceHeight % (std::max(8u, m_log2MinCuSize))) != 0, "Resulting coded frame height must be a multiple of Max(8, the minimum CU size)"); -#else - xConfirmPara( (m_iSourceWidth % (std::max(8, int(m_uiMaxCUWidth >> (m_uiMaxCUDepth - 1))))) != 0, "Resulting coded frame width must be a multiple of Max(8, the minimum CU size)"); - xConfirmPara( (m_iSourceHeight % (std::max(8, int(m_uiMaxCUHeight >> (m_uiMaxCUDepth - 1))))) != 0, "Resulting coded frame height must be a multiple of Max(8, the minimum CU size)"); -#endif if (m_uiMaxMTTHierarchyDepthI == 0) { xConfirmPara(m_uiMaxBT[0] != m_uiMinQT[0], "MaxBTLumaISlice shall be equal to MinQTLumaISlice when MaxMTTHierarchyDepthISliceL is 0."); @@ -2820,24 +2673,16 @@ bool EncAppCfg::xCheckParameter() xConfirmPara( m_log2MaxTbSize < 5, "Log2MaxTbSize must be 5 or greater." ); xConfirmPara( m_maxNumMergeCand < 1, "MaxNumMergeCand must be 1 or greater."); xConfirmPara( m_maxNumMergeCand > MRG_MAX_NUM_CANDS, "MaxNumMergeCand must be no more than MRG_MAX_NUM_CANDS." ); -#if !JVET_Q0806 -#if JVET_Q0798_SPS_NUMBER_MERGE_CANDIDATE - xConfirmPara(m_maxNumGeoCand > TRIANGLE_MAX_NUM_UNI_CANDS, "MaxNumTriangleCand must be no more than TRIANGLE_MAX_NUM_UNI_CANDS."); - xConfirmPara(m_maxNumGeoCand > m_maxNumMergeCand, "MaxNumTriangleCand must be no more than MaxNumMergeCand."); - xConfirmPara(0 < m_maxNumGeoCand && m_maxNumGeoCand < 2, "MaxNumTriangleCand must be no less than 2 unless MaxNumTriangleCand is 0."); -#else - xConfirmPara( m_maxNumTriangleCand > TRIANGLE_MAX_NUM_UNI_CANDS, "MaxNumTriangleCand must be no more than TRIANGLE_MAX_NUM_UNI_CANDS." ); - xConfirmPara( m_maxNumTriangleCand > m_maxNumMergeCand, "MaxNumTriangleCand must be no more than MaxNumMergeCand." ); - xConfirmPara( 0 < m_maxNumTriangleCand && m_maxNumTriangleCand < 2, "MaxNumTriangleCand must be no less than 2 unless MaxNumTriangleCand is 0." ); -#endif -#else xConfirmPara( m_maxNumGeoCand > GEO_MAX_NUM_UNI_CANDS, "MaxNumGeoCand must be no more than GEO_MAX_NUM_UNI_CANDS." ); xConfirmPara( m_maxNumGeoCand > m_maxNumMergeCand, "MaxNumGeoCand must be no more than MaxNumMergeCand." ); xConfirmPara( 0 < m_maxNumGeoCand && m_maxNumGeoCand < 2, "MaxNumGeoCand must be no less than 2 unless MaxNumGeoCand is 0." ); -#endif xConfirmPara( m_maxNumIBCMergeCand < 1, "MaxNumIBCMergeCand must be 1 or greater." ); xConfirmPara( m_maxNumIBCMergeCand > IBC_MRG_MAX_NUM_CANDS, "MaxNumIBCMergeCand must be no more than IBC_MRG_MAX_NUM_CANDS." ); +#if JVET_R0371_MAX_NUM_SUB_BLK_MRG_CAND + xConfirmPara( m_maxNumAffineMergeCand < (m_SubPuMvpMode ? 1 : 0), "MaxNumAffineMergeCand must be greater or equal to SubPuMvp." ); +#else xConfirmPara( m_maxNumAffineMergeCand < 1, "MaxNumAffineMergeCand must be 1 or greater." ); +#endif xConfirmPara( m_maxNumAffineMergeCand > AFFINE_MRG_MAX_NUM_CANDS, "MaxNumAffineMergeCand must be no more than AFFINE_MRG_MAX_NUM_CANDS." ); if ( m_Affine == 0 ) { @@ -2857,12 +2702,10 @@ bool EncAppCfg::xCheckParameter() } -#if JVET_Q0795_CCALF if (!m_alf) { xConfirmPara( m_ccalf, "CCALF cannot be enabled when ALF is disabled" ); } -#endif xConfirmPara( m_iSourceWidth % SPS::getWinUnitX(m_chromaFormatIDC) != 0, "Picture width must be an integer multiple of the specified chroma subsampling"); @@ -2905,12 +2748,10 @@ bool EncAppCfg::xCheckParameter() m_GOPList[0].m_QPFactor = 1; m_GOPList[0].m_betaOffsetDiv2 = 0; m_GOPList[0].m_tcOffsetDiv2 = 0; -#if JVET_Q0121_DEBLOCKING_CONTROL_PARAMETERS m_GOPList[0].m_CbBetaOffsetDiv2 = 0; m_GOPList[0].m_CbTcOffsetDiv2 = 0; m_GOPList[0].m_CrBetaOffsetDiv2 = 0; m_GOPList[0].m_CrTcOffsetDiv2 = 0; -#endif m_GOPList[0].m_POC = 1; m_RPLList0[0] = RPLEntry(); m_RPLList1[0] = RPLEntry(); @@ -2953,17 +2794,12 @@ bool EncAppCfg::xCheckParameter() { for(int i=0; i<m_iGOPSize; i++) { -#if JVET_Q0121_DEBLOCKING_CONTROL_PARAMETERS xConfirmPara( (m_GOPList[i].m_betaOffsetDiv2 + m_loopFilterBetaOffsetDiv2) < -12 || (m_GOPList[i].m_betaOffsetDiv2 + m_loopFilterBetaOffsetDiv2) > 12, "Loop Filter Beta Offset div. 2 for one of the GOP entries exceeds supported range (-12 to 12)" ); xConfirmPara( (m_GOPList[i].m_tcOffsetDiv2 + m_loopFilterTcOffsetDiv2) < -12 || (m_GOPList[i].m_tcOffsetDiv2 + m_loopFilterTcOffsetDiv2) > 12, "Loop Filter Tc Offset div. 2 for one of the GOP entries exceeds supported range (-12 to 12)" ); xConfirmPara( (m_GOPList[i].m_CbBetaOffsetDiv2 + m_loopFilterCbBetaOffsetDiv2) < -12 || (m_GOPList[i].m_CbBetaOffsetDiv2 + m_loopFilterCbBetaOffsetDiv2) > 12, "Loop Filter Beta Offset div. 2 for one of the GOP entries exceeds supported range (-12 to 12)" ); xConfirmPara( (m_GOPList[i].m_CbTcOffsetDiv2 + m_loopFilterCbTcOffsetDiv2) < -12 || (m_GOPList[i].m_CbTcOffsetDiv2 + m_loopFilterCbTcOffsetDiv2) > 12, "Loop Filter Tc Offset div. 2 for one of the GOP entries exceeds supported range (-12 to 12)" ); xConfirmPara( (m_GOPList[i].m_CrBetaOffsetDiv2 + m_loopFilterCrBetaOffsetDiv2) < -12 || (m_GOPList[i].m_CrBetaOffsetDiv2 + m_loopFilterCrBetaOffsetDiv2) > 12, "Loop Filter Beta Offset div. 2 for one of the GOP entries exceeds supported range (-12 to 12)" ); xConfirmPara( (m_GOPList[i].m_CrTcOffsetDiv2 + m_loopFilterCrTcOffsetDiv2) < -12 || (m_GOPList[i].m_CrTcOffsetDiv2 + m_loopFilterCrTcOffsetDiv2) > 12, "Loop Filter Tc Offset div. 2 for one of the GOP entries exceeds supported range (-12 to 12)" ); -#else - xConfirmPara( (m_GOPList[i].m_betaOffsetDiv2 + m_loopFilterBetaOffsetDiv2) < -6 || (m_GOPList[i].m_betaOffsetDiv2 + m_loopFilterBetaOffsetDiv2) > 6, "Loop Filter Beta Offset div. 2 for one of the GOP entries exceeds supported range (-6 to 6)" ); - xConfirmPara( (m_GOPList[i].m_tcOffsetDiv2 + m_loopFilterTcOffsetDiv2) < -6 || (m_GOPList[i].m_tcOffsetDiv2 + m_loopFilterTcOffsetDiv2) > 6, "Loop Filter Tc Offset div. 2 for one of the GOP entries exceeds supported range (-6 to 6)" ); -#endif } } @@ -3305,23 +3141,23 @@ bool EncAppCfg::xCheckParameter() m_maxDecPicBuffering[MAX_TLAYER-1] = m_numReorderPics[MAX_TLAYER-1] + 1; } - if( m_picPartitionFlag ) + if( m_picPartitionFlag ) { PPS pps; uint32_t colIdx, rowIdx; uint32_t remSize; - + pps.setPicWidthInLumaSamples( m_iSourceWidth ); pps.setPicHeightInLumaSamples( m_iSourceHeight ); pps.setLog2CtuSize( floorLog2(m_uiCTUSize) ); // set default tile column if not provided - if( m_tileColumnWidth.size() == 0 ) + if( m_tileColumnWidth.size() == 0 ) { m_tileColumnWidth.push_back( pps.getPicWidthInCtu() ); } // set default tile row if not provided - if( m_tileRowHeight.size() == 0 ) + if( m_tileRowHeight.size() == 0 ) { m_tileRowHeight.push_back( pps.getPicHeightInCtu() ); } @@ -3348,7 +3184,7 @@ bool EncAppCfg::xCheckParameter() remSize -= m_tileColumnWidth[ colIdx ]; } m_tileColumnWidth.resize( colIdx ); - pps.setNumExpTileColumns( (uint32_t)m_tileColumnWidth.size() ); + pps.setNumExpTileColumns( (uint32_t)m_tileColumnWidth.size() ); remSize = pps.getPicHeightInCtu(); for( rowIdx=0; remSize > 0 && rowIdx<m_tileRowHeight.size(); rowIdx++ ) { @@ -3368,155 +3204,158 @@ bool EncAppCfg::xCheckParameter() // rectangular slices if( !m_rasterSliceFlag ) { - uint32_t sliceIdx; - bool needTileIdxDelta = false; - - // generate slice list for the simplified fixed-rectangular-slice-size config option - if( m_rectSliceFixedWidth > 0 && m_rectSliceFixedHeight > 0 ) + if (!m_singleSlicePerSubPicFlag) { - int tileIdx = 0; - m_rectSlicePos.clear(); - while( tileIdx < pps.getNumTiles() ) - { - uint32_t startTileX = tileIdx % pps.getNumTileColumns(); - uint32_t startTileY = tileIdx / pps.getNumTileColumns(); - uint32_t startCtuX = pps.getTileColumnBd( startTileX ); - uint32_t startCtuY = pps.getTileRowBd( startTileY ); - uint32_t stopCtuX = (startTileX + m_rectSliceFixedWidth) >= pps.getNumTileColumns() ? pps.getPicWidthInCtu() - 1 : pps.getTileColumnBd( startTileX + m_rectSliceFixedWidth ) - 1; - uint32_t stopCtuY = (startTileY + m_rectSliceFixedHeight) >= pps.getNumTileRows() ? pps.getPicHeightInCtu() - 1 : pps.getTileRowBd( startTileY + m_rectSliceFixedHeight ) - 1; - uint32_t stopTileX = pps.ctuToTileCol( stopCtuX ); - uint32_t stopTileY = pps.ctuToTileRow( stopCtuY ); - - // add rectangular slice to list - m_rectSlicePos.push_back( startCtuY * pps.getPicWidthInCtu() + startCtuX ); - m_rectSlicePos.push_back( stopCtuY * pps.getPicWidthInCtu() + stopCtuX ); - - // get slice size in tiles - uint32_t sliceWidth = stopTileX - startTileX + 1; - uint32_t sliceHeight = stopTileY - startTileY + 1; + uint32_t sliceIdx; + bool needTileIdxDelta = false; - // move to next tile in raster scan order - tileIdx += sliceWidth; - if( tileIdx % pps.getNumTileColumns() == 0 ) + // generate slice list for the simplified fixed-rectangular-slice-size config option + if( m_rectSliceFixedWidth > 0 && m_rectSliceFixedHeight > 0 ) + { + int tileIdx = 0; + m_rectSlicePos.clear(); + while( tileIdx < pps.getNumTiles() ) { - tileIdx += (sliceHeight - 1) * pps.getNumTileColumns(); + uint32_t startTileX = tileIdx % pps.getNumTileColumns(); + uint32_t startTileY = tileIdx / pps.getNumTileColumns(); + uint32_t startCtuX = pps.getTileColumnBd( startTileX ); + uint32_t startCtuY = pps.getTileRowBd( startTileY ); + uint32_t stopCtuX = (startTileX + m_rectSliceFixedWidth) >= pps.getNumTileColumns() ? pps.getPicWidthInCtu() - 1 : pps.getTileColumnBd( startTileX + m_rectSliceFixedWidth ) - 1; + uint32_t stopCtuY = (startTileY + m_rectSliceFixedHeight) >= pps.getNumTileRows() ? pps.getPicHeightInCtu() - 1 : pps.getTileRowBd( startTileY + m_rectSliceFixedHeight ) - 1; + uint32_t stopTileX = pps.ctuToTileCol( stopCtuX ); + uint32_t stopTileY = pps.ctuToTileRow( stopCtuY ); + + // add rectangular slice to list + m_rectSlicePos.push_back( startCtuY * pps.getPicWidthInCtu() + startCtuX ); + m_rectSlicePos.push_back( stopCtuY * pps.getPicWidthInCtu() + stopCtuX ); + + // get slice size in tiles + uint32_t sliceWidth = stopTileX - startTileX + 1; + uint32_t sliceHeight = stopTileY - startTileY + 1; + + // move to next tile in raster scan order + tileIdx += sliceWidth; + if( tileIdx % pps.getNumTileColumns() == 0 ) + { + tileIdx += (sliceHeight - 1) * pps.getNumTileColumns(); + } } } - } - xConfirmPara( m_rectSlicePos.size() & 1, "Odd number of rectangular slice positions provided. Rectangular slice positions must be specified in pairs of (top-left / bottom-right) raster-scan CTU addresses."); - - // set default slice size if not provided - if( m_rectSlicePos.size() == 0 ) - { - m_rectSlicePos.push_back( 0 ); - m_rectSlicePos.push_back( pps.getPicWidthInCtu() * pps.getPicHeightInCtu() - 1 ); - } - pps.setNumSlicesInPic( (uint32_t)(m_rectSlicePos.size() >> 1) ); - xConfirmPara(pps.getNumSlicesInPic() > getMaxSlicesByLevel( m_level ), "Number of rectangular slices exceeds maximum number allowed according to specified level"); - pps.initRectSlices(); + xConfirmPara( m_rectSlicePos.size() & 1, "Odd number of rectangular slice positions provided. Rectangular slice positions must be specified in pairs of (top-left / bottom-right) raster-scan CTU addresses."); - // set slice parameters from CTU addresses - for( sliceIdx = 0; sliceIdx < pps.getNumSlicesInPic(); sliceIdx++ ) - { - xConfirmPara( m_rectSlicePos[2*sliceIdx] >= pps.getPicWidthInCtu() * pps.getPicHeightInCtu(), "Rectangular slice position exceeds total number of CTU in picture."); - xConfirmPara( m_rectSlicePos[2*sliceIdx + 1] >= pps.getPicWidthInCtu() * pps.getPicHeightInCtu(), "Rectangular slice position exceeds total number of CTU in picture."); - - // map raster scan CTU address to X/Y position - uint32_t startCtuX = m_rectSlicePos[2*sliceIdx] % pps.getPicWidthInCtu(); - uint32_t startCtuY = m_rectSlicePos[2*sliceIdx] / pps.getPicWidthInCtu(); - uint32_t stopCtuX = m_rectSlicePos[2*sliceIdx + 1] % pps.getPicWidthInCtu(); - uint32_t stopCtuY = m_rectSlicePos[2*sliceIdx + 1] / pps.getPicWidthInCtu(); - - // get corresponding tile index - uint32_t startTileX = pps.ctuToTileCol( startCtuX ); - uint32_t startTileY = pps.ctuToTileRow( startCtuY ); - uint32_t stopTileX = pps.ctuToTileCol( stopCtuX ); - uint32_t stopTileY = pps.ctuToTileRow( stopCtuY ); - uint32_t tileIdx = startTileY * pps.getNumTileColumns() + startTileX; - - // get slice size in tiles - uint32_t sliceWidth = stopTileX - startTileX + 1; - uint32_t sliceHeight = stopTileY - startTileY + 1; - - // check for slice / tile alignment - xConfirmPara( startCtuX != pps.getTileColumnBd( startTileX ), "Rectangular slice position does not align with a left tile edge."); - xConfirmPara( stopCtuX != (pps.getTileColumnBd( stopTileX + 1 ) - 1), "Rectangular slice position does not align with a right tile edge."); - if( sliceWidth > 1 || sliceHeight > 1 ) + // set default slice size if not provided + if( m_rectSlicePos.size() == 0 ) { - xConfirmPara( startCtuY != pps.getTileRowBd( startTileY ), "Rectangular slice position does not align with a top tile edge."); - xConfirmPara( stopCtuY != (pps.getTileRowBd( stopTileY + 1 ) - 1), "Rectangular slice position does not align with a bottom tile edge."); + m_rectSlicePos.push_back( 0 ); + m_rectSlicePos.push_back( pps.getPicWidthInCtu() * pps.getPicHeightInCtu() - 1 ); } + pps.setNumSlicesInPic( (uint32_t)(m_rectSlicePos.size() >> 1) ); + xConfirmPara(pps.getNumSlicesInPic() > getMaxSlicesByLevel( m_level ), "Number of rectangular slices exceeds maximum number allowed according to specified level"); + pps.initRectSlices(); - // set slice size and tile index - pps.setSliceWidthInTiles( sliceIdx, sliceWidth ); - pps.setSliceHeightInTiles( sliceIdx, sliceHeight ); - pps.setSliceTileIdx( sliceIdx, tileIdx ); - if( sliceIdx > 0 && !needTileIdxDelta ) + // set slice parameters from CTU addresses + for( sliceIdx = 0; sliceIdx < pps.getNumSlicesInPic(); sliceIdx++ ) { - uint32_t lastTileIdx = pps.getSliceTileIdx( sliceIdx-1 ); - lastTileIdx += pps.getSliceWidthInTiles( sliceIdx-1 ); - if( lastTileIdx % pps.getNumTileColumns() == 0) + xConfirmPara( m_rectSlicePos[2*sliceIdx] >= pps.getPicWidthInCtu() * pps.getPicHeightInCtu(), "Rectangular slice position exceeds total number of CTU in picture."); + xConfirmPara( m_rectSlicePos[2*sliceIdx + 1] >= pps.getPicWidthInCtu() * pps.getPicHeightInCtu(), "Rectangular slice position exceeds total number of CTU in picture."); + + // map raster scan CTU address to X/Y position + uint32_t startCtuX = m_rectSlicePos[2*sliceIdx] % pps.getPicWidthInCtu(); + uint32_t startCtuY = m_rectSlicePos[2*sliceIdx] / pps.getPicWidthInCtu(); + uint32_t stopCtuX = m_rectSlicePos[2*sliceIdx + 1] % pps.getPicWidthInCtu(); + uint32_t stopCtuY = m_rectSlicePos[2*sliceIdx + 1] / pps.getPicWidthInCtu(); + + // get corresponding tile index + uint32_t startTileX = pps.ctuToTileCol( startCtuX ); + uint32_t startTileY = pps.ctuToTileRow( startCtuY ); + uint32_t stopTileX = pps.ctuToTileCol( stopCtuX ); + uint32_t stopTileY = pps.ctuToTileRow( stopCtuY ); + uint32_t tileIdx = startTileY * pps.getNumTileColumns() + startTileX; + + // get slice size in tiles + uint32_t sliceWidth = stopTileX - startTileX + 1; + uint32_t sliceHeight = stopTileY - startTileY + 1; + + // check for slice / tile alignment + xConfirmPara( startCtuX != pps.getTileColumnBd( startTileX ), "Rectangular slice position does not align with a left tile edge."); + xConfirmPara( stopCtuX != (pps.getTileColumnBd( stopTileX + 1 ) - 1), "Rectangular slice position does not align with a right tile edge."); + if( sliceWidth > 1 || sliceHeight > 1 ) { - lastTileIdx += (pps.getSliceHeightInTiles( sliceIdx-1 ) - 1) * pps.getNumTileColumns(); + xConfirmPara( startCtuY != pps.getTileRowBd( startTileY ), "Rectangular slice position does not align with a top tile edge."); + xConfirmPara( stopCtuY != (pps.getTileRowBd( stopTileY + 1 ) - 1), "Rectangular slice position does not align with a bottom tile edge."); } - if( lastTileIdx != tileIdx ) + + // set slice size and tile index + pps.setSliceWidthInTiles( sliceIdx, sliceWidth ); + pps.setSliceHeightInTiles( sliceIdx, sliceHeight ); + pps.setSliceTileIdx( sliceIdx, tileIdx ); + if( sliceIdx > 0 && !needTileIdxDelta ) { - needTileIdxDelta = true; + uint32_t lastTileIdx = pps.getSliceTileIdx( sliceIdx-1 ); + lastTileIdx += pps.getSliceWidthInTiles( sliceIdx-1 ); + if( lastTileIdx % pps.getNumTileColumns() == 0) + { + lastTileIdx += (pps.getSliceHeightInTiles( sliceIdx-1 ) - 1) * pps.getNumTileColumns(); + } + if( lastTileIdx != tileIdx ) + { + needTileIdxDelta = true; + } } - } - // special case for multiple slices within a single tile - if( sliceWidth == 1 && sliceHeight == 1 ) - { - uint32_t firstSliceIdx = sliceIdx; - uint32_t numSlicesInTile = 1; - pps.setSliceHeightInCtu( sliceIdx, stopCtuY - startCtuY + 1 ); - - while( sliceIdx < pps.getNumSlicesInPic()-1 ) + // special case for multiple slices within a single tile + if( sliceWidth == 1 && sliceHeight == 1 ) { - uint32_t nextTileIdx; - startCtuX = m_rectSlicePos[2*(sliceIdx+1)] % pps.getPicWidthInCtu(); - startCtuY = m_rectSlicePos[2*(sliceIdx+1)] / pps.getPicWidthInCtu(); - stopCtuX = m_rectSlicePos[2*(sliceIdx+1) + 1] % pps.getPicWidthInCtu(); - stopCtuY = m_rectSlicePos[2*(sliceIdx+1) + 1] / pps.getPicWidthInCtu(); - startTileX = pps.ctuToTileCol( startCtuX ); - startTileY = pps.ctuToTileRow( startCtuY ); - stopTileX = pps.ctuToTileCol( stopCtuX ); - stopTileY = pps.ctuToTileRow( stopCtuY ); - nextTileIdx = startTileY * pps.getNumTileColumns() + startTileX; - sliceWidth = stopTileX - startTileX + 1; - sliceHeight = stopTileY - startTileY + 1; - if(nextTileIdx != tileIdx || sliceWidth != 1 || sliceHeight != 1) + uint32_t firstSliceIdx = sliceIdx; + uint32_t numSlicesInTile = 1; + pps.setSliceHeightInCtu( sliceIdx, stopCtuY - startCtuY + 1 ); + + while( sliceIdx < pps.getNumSlicesInPic()-1 ) { - break; + uint32_t nextTileIdx; + startCtuX = m_rectSlicePos[2*(sliceIdx+1)] % pps.getPicWidthInCtu(); + startCtuY = m_rectSlicePos[2*(sliceIdx+1)] / pps.getPicWidthInCtu(); + stopCtuX = m_rectSlicePos[2*(sliceIdx+1) + 1] % pps.getPicWidthInCtu(); + stopCtuY = m_rectSlicePos[2*(sliceIdx+1) + 1] / pps.getPicWidthInCtu(); + startTileX = pps.ctuToTileCol( startCtuX ); + startTileY = pps.ctuToTileRow( startCtuY ); + stopTileX = pps.ctuToTileCol( stopCtuX ); + stopTileY = pps.ctuToTileRow( stopCtuY ); + nextTileIdx = startTileY * pps.getNumTileColumns() + startTileX; + sliceWidth = stopTileX - startTileX + 1; + sliceHeight = stopTileY - startTileY + 1; + if(nextTileIdx != tileIdx || sliceWidth != 1 || sliceHeight != 1) + { + break; + } + numSlicesInTile++; + sliceIdx++; + pps.setSliceWidthInTiles( sliceIdx, 1 ); + pps.setSliceHeightInTiles( sliceIdx, 1 ); + pps.setSliceTileIdx( sliceIdx, tileIdx ); + pps.setSliceHeightInCtu( sliceIdx, stopCtuY - startCtuY + 1 ); } - numSlicesInTile++; - sliceIdx++; - pps.setSliceWidthInTiles( sliceIdx, 1 ); - pps.setSliceHeightInTiles( sliceIdx, 1 ); - pps.setSliceTileIdx( sliceIdx, tileIdx ); - pps.setSliceHeightInCtu( sliceIdx, stopCtuY - startCtuY + 1 ); + pps.setNumSlicesInTile( firstSliceIdx, numSlicesInTile ); } - pps.setNumSlicesInTile( firstSliceIdx, numSlicesInTile ); } - } - pps.setTileIdxDeltaPresentFlag( needTileIdxDelta ); - m_tileIdxDeltaPresentFlag = needTileIdxDelta; - - // check rectangular slice mapping and full picture CTU coverage - pps.initRectSliceMap(); - - // store rectangular slice parameters from temporary PPS structure - m_numSlicesInPic = pps.getNumSlicesInPic(); - m_rectSlices.resize( pps.getNumSlicesInPic() ); - for( sliceIdx = 0; sliceIdx < pps.getNumSlicesInPic(); sliceIdx++ ) - { - m_rectSlices[sliceIdx].setSliceWidthInTiles( pps.getSliceWidthInTiles(sliceIdx) ); - m_rectSlices[sliceIdx].setSliceHeightInTiles( pps.getSliceHeightInTiles(sliceIdx) ); - m_rectSlices[sliceIdx].setNumSlicesInTile( pps.getNumSlicesInTile(sliceIdx) ); - m_rectSlices[sliceIdx].setSliceHeightInCtu( pps.getSliceHeightInCtu(sliceIdx) ); - m_rectSlices[sliceIdx].setTileIdx( pps.getSliceTileIdx(sliceIdx) ); + pps.setTileIdxDeltaPresentFlag( needTileIdxDelta ); + m_tileIdxDeltaPresentFlag = needTileIdxDelta; + + // check rectangular slice mapping and full picture CTU coverage + pps.initRectSliceMap(nullptr); + + // store rectangular slice parameters from temporary PPS structure + m_numSlicesInPic = pps.getNumSlicesInPic(); + m_rectSlices.resize( pps.getNumSlicesInPic() ); + for( sliceIdx = 0; sliceIdx < pps.getNumSlicesInPic(); sliceIdx++ ) + { + m_rectSlices[sliceIdx].setSliceWidthInTiles( pps.getSliceWidthInTiles(sliceIdx) ); + m_rectSlices[sliceIdx].setSliceHeightInTiles( pps.getSliceHeightInTiles(sliceIdx) ); + m_rectSlices[sliceIdx].setNumSlicesInTile( pps.getNumSlicesInTile(sliceIdx) ); + m_rectSlices[sliceIdx].setSliceHeightInCtu( pps.getSliceHeightInCtu(sliceIdx) ); + m_rectSlices[sliceIdx].setTileIdx( pps.getSliceTileIdx(sliceIdx) ); + } } } // raster-scan slices @@ -3526,7 +3365,7 @@ bool EncAppCfg::xCheckParameter() uint32_t remTiles = pps.getNumTiles(); // set default slice size if not provided - if( m_rasterSliceSize.size() == 0 ) + if( m_rasterSliceSize.size() == 0 ) { m_rasterSliceSize.push_back( remTiles ); } @@ -3550,12 +3389,12 @@ bool EncAppCfg::xCheckParameter() } // shrink list if too many sizes were provided m_rasterSliceSize.resize( listIdx ); - + m_numSlicesInPic = (uint32_t)m_rasterSliceSize.size(); xConfirmPara(m_rasterSliceSize.size() > getMaxSlicesByLevel( m_level ), "Number of raster-scan slices exceeds maximum number allowed according to specified level"); } } - else + else { m_numTileCols = 1; m_numTileRows = 1; @@ -3584,74 +3423,6 @@ bool EncAppCfg::xCheckParameter() m_BIO = false; } -#if !JVET_Q0482_REMOVE_CONSTANT_PARAMS - // If m_PPSorSliceFlag is equal to 1, for each PPS parameter below, - // 0: value is signaled in slice header - // >0: value is derived from PPS parameter as value - 1 - switch (m_PPSorSliceMode) - { - case 0: // All parameter values are signaled in slice header - m_constantSliceHeaderParamsEnabledFlag = 0; - m_PPSDepQuantEnabledIdc = 0; - m_PPSRefPicListSPSIdc0 = 0; - m_PPSRefPicListSPSIdc1 = 0; - m_PPSMvdL1ZeroIdc = 0; - m_PPSCollocatedFromL0Idc = 0; - m_PPSSixMinusMaxNumMergeCandPlus1 = 0; -#if !JVET_Q0806 - m_PPSMaxNumMergeCandMinusMaxNumTriangleCandPlus1 = 0; -#else - m_PPSMaxNumMergeCandMinusMaxNumGeoCandPlus1 = 0; -#endif - break; - case 1: // RA setting - m_constantSliceHeaderParamsEnabledFlag = 1; - m_PPSDepQuantEnabledIdc = (m_depQuantEnabledFlag ? 1 : 0) + 1; - m_PPSRefPicListSPSIdc0 = 0; - m_PPSRefPicListSPSIdc1 = 0; - m_PPSMvdL1ZeroIdc = 0; - m_PPSCollocatedFromL0Idc = 0; - m_PPSSixMinusMaxNumMergeCandPlus1 = 6 - m_maxNumMergeCand + 1; -#if !JVET_Q0806 - m_PPSMaxNumMergeCandMinusMaxNumTriangleCandPlus1 = m_maxNumMergeCand - m_maxNumTriangleCand + 1; -#else - m_PPSMaxNumMergeCandMinusMaxNumGeoCandPlus1 = m_maxNumMergeCand - m_maxNumGeoCand + 1; -#endif - break; - case 2: // LDB setting - m_constantSliceHeaderParamsEnabledFlag = 1; - m_PPSDepQuantEnabledIdc = (m_depQuantEnabledFlag ? 1 : 0) + 1; - m_PPSRefPicListSPSIdc0 = 2; - m_PPSRefPicListSPSIdc1 = 2; - m_PPSMvdL1ZeroIdc = 2; - m_PPSCollocatedFromL0Idc = 1; - m_PPSSixMinusMaxNumMergeCandPlus1 = 6 - m_maxNumMergeCand + 1; -#if !JVET_Q0806 - m_PPSMaxNumMergeCandMinusMaxNumTriangleCandPlus1 = m_maxNumMergeCand - m_maxNumTriangleCand + 1; -#else - m_PPSMaxNumMergeCandMinusMaxNumGeoCandPlus1 = m_maxNumMergeCand - m_maxNumGeoCand + 1; -#endif - break; - case 3: // LDP setting - m_constantSliceHeaderParamsEnabledFlag = 1; - m_PPSDepQuantEnabledIdc = (m_depQuantEnabledFlag ? 1 : 0) + 1; - m_PPSRefPicListSPSIdc0 = 2; - m_PPSRefPicListSPSIdc1 = 2; - m_PPSMvdL1ZeroIdc = 0; - m_PPSCollocatedFromL0Idc = 0; - m_PPSSixMinusMaxNumMergeCandPlus1 = 6 - m_maxNumMergeCand + 1; -#if !JVET_Q0806 - m_PPSMaxNumMergeCandMinusMaxNumTriangleCandPlus1 = 0; -#else - m_PPSMaxNumMergeCandMinusMaxNumGeoCandPlus1 = 0; -#endif - break; - default: - THROW("Invalid value for PPSorSliceMode"); - } - xConfirmPara(m_drapPeriod > 0 && m_PPSRefPicListSPSIdc0 > 0, "PPSRefPicListSPSIdc0 shall be 0 when DRAP is used. This can be fixed by setting PPSorSliceMode=0."); - xConfirmPara(m_drapPeriod > 0 && m_PPSRefPicListSPSIdc1 > 0, "PPSRefPicListSPSIdc1 shall be 0 when DRAP is used. This can be fixed by setting PPSorSliceMode=0."); -#endif xConfirmPara( m_sariAspectRatioIdc < 0 || m_sariAspectRatioIdc > 255, "SEISARISampleAspectRatioIdc must be in the range of 0 to 255"); @@ -3734,19 +3505,16 @@ bool EncAppCfg::xCheckParameter() xConfirmPara( m_gcmpSEIGuardBandSamplesMinus1 < 0 || m_gcmpSEIGuardBandSamplesMinus1 > 15, "SEIGcmpGuardBandSamplesMinus1 must be in the range of 0 to 15"); } } -#if JVET_Q0297_MER xConfirmPara(m_log2ParallelMergeLevel < 2, "Log2ParallelMergeLevel should be larger than or equal to 2"); -#endif + xConfirmPara(m_log2ParallelMergeLevel > m_uiCTUSize, "Log2ParallelMergeLevel should be less than or equal to CTU size"); #if U0033_ALTERNATIVE_TRANSFER_CHARACTERISTICS_SEI xConfirmPara(m_preferredTransferCharacteristics > 255, "transfer_characteristics_idc should not be greater than 255."); #endif xConfirmPara( unsigned(m_ImvMode) > 1, "ImvMode exceeds range (0 to 1)" ); -#if JVET_Q0444_AMVR_SIGNALLING if (m_AffineAmvr) { xConfirmPara(!m_ImvMode, "AffineAmvr cannot be used when IMV is disabled."); } -#endif xConfirmPara( m_decodeBitstreams[0] == m_bitstreamFileName, "Debug bitstream and the output bitstream cannot be equal.\n" ); xConfirmPara( m_decodeBitstreams[1] == m_bitstreamFileName, "Decode2 bitstream and the output bitstream cannot be equal.\n" ); xConfirmPara(unsigned(m_LMChroma) > 1, "LMMode exceeds range (0 to 1)"); @@ -3758,13 +3526,13 @@ bool EncAppCfg::xCheckParameter() check_failed |= m_ext360.verifyParameters(); #endif -#if !JVET_Q0089_SLICE_LOSSLESS_CODING_CHROMA_BDPCM - xConfirmPara(m_useBDPCM < 0 || m_useBDPCM > 2, "BDPCM must be in range 0..2"); -#endif -#if JVET_Q0820_ACT xConfirmPara(m_useColorTrans && (m_log2MaxTbSize == 6), "Log2MaxTbSize must be less than 6 when ACT is enabled, otherwise ACT needs to be disabled"); + +#if JVET_R0097_MAX_TRSIZE_CONDITIONALY_SIGNALING + xConfirmPara(m_uiCTUSize <= 32 && (m_log2MaxTbSize == 6), "Log2MaxTbSize must be less than 6 when CTU size is 32"); #endif + #undef xConfirmPara return check_failed; } @@ -3814,22 +3582,13 @@ void EncAppCfg::xPrintParameter() { msg( DETAILS, "Profile : %s\n", profileToString(m_profile) ); } -#if JVET_Q0468_Q0469_MIN_LUMA_CB_AND_MIN_QT_FIX msg(DETAILS, "CTU size / min CU size : %d / %d \n", m_uiMaxCUWidth, 1 << m_log2MinCuSize); -#else - msg( DETAILS, "CU size / depth / total-depth : %d / %d / %d\n", m_uiMaxCUWidth, m_uiMaxCUDepth, m_uiMaxCodingDepth ); -#endif -#if JVET_Q0119_CLEANUPS msg(DETAILS, "subpicture info present flag : %d\n", m_subPicInfoPresentFlag); if (m_subPicInfoPresentFlag) -#else - msg(DETAILS, "subpicture present flag : %d\n", m_subPicPresentFlag); - if (m_subPicPresentFlag) -#endif { msg(DETAILS, "number of subpictures : %d\n", m_numSubPics); - for (int i = 0; i < m_numSubPics; i++) + for (int i = 0; i < m_numSubPics; i++) { msg(DETAILS, "[%d]th subpictures location :[%d %d]\n", i, m_subPicCtuTopLeftX[i], m_subPicCtuTopLeftY[i]); msg(DETAILS, "[%d]th subpictures size :[%d %d]\n", i, m_subPicWidth[i], m_subPicHeight[i]); @@ -3839,18 +3598,11 @@ void EncAppCfg::xPrintParameter() } } -#if JVET_Q0119_CLEANUPS msg(DETAILS, "subpicture ID present flag : %d\n", m_subPicIdMappingExplicitlySignalledFlag); if (m_subPicIdMappingExplicitlySignalledFlag) { msg(DETAILS, "subpicture ID signalling present flag : %d\n", m_subPicIdMappingInSpsFlag); -#else - msg(DETAILS, "subpicture ID present flag : %d\n", m_subPicIdPresentFlag); - if (m_subPicIdPresentFlag) - { - msg(DETAILS, "subpicture ID signalling present flag : %d\n", m_subPicIdSignallingPresentFlag); -#endif - for (int i = 0; i < m_numSubPics; i++) + for (int i = 0; i < m_numSubPics; i++) { msg(DETAILS, "[%d]th subpictures ID length :%d\n", i, m_subPicIdLen); msg(DETAILS, "[%d]th subpictures ID :%d\n", i, m_subPicId[i]); @@ -3890,19 +3642,9 @@ void EncAppCfg::xPrintParameter() msg( DETAILS, "explicit_rdpcm_enabled_flag : %s\n", (m_rdpcmEnabledFlag[RDPCM_SIGNAL_EXPLICIT] ? "Enabled" : "Disabled") ); msg( DETAILS, "transform_skip_rotation_enabled_flag : %s\n", (m_transformSkipRotationEnabledFlag ? "Enabled" : "Disabled") ); msg( DETAILS, "transform_skip_context_enabled_flag : %s\n", (m_transformSkipContextEnabledFlag ? "Enabled" : "Disabled") ); -#if !REMOVE_PPS_REXT - msg( DETAILS, "cross_component_prediction_enabled_flag: %s\n", (m_crossComponentPredictionEnabledFlag ? (m_reconBasedCrossCPredictionEstimate ? "Enabled (reconstructed-residual-based estimate)" : "Enabled (encoder-side-residual-based estimate)") : "Disabled") ); -#endif msg( DETAILS, "high_precision_offsets_enabled_flag : %s\n", (m_highPrecisionOffsetsEnabledFlag ? "Enabled" : "Disabled") ); msg( DETAILS, "persistent_rice_adaptation_enabled_flag: %s\n", (m_persistentRiceAdaptationEnabledFlag ? "Enabled" : "Disabled") ); msg( DETAILS, "cabac_bypass_alignment_enabled_flag : %s\n", (m_cabacBypassAlignmentEnabledFlag ? "Enabled" : "Disabled") ); -#if !JVET_Q0441_SAO_MOD_12_BIT - if (m_bUseSAO) - { - msg( DETAILS, "log2_sao_offset_scale_luma : %d\n", m_log2SaoOffsetScale[CHANNEL_TYPE_LUMA] ); - msg( DETAILS, "log2_sao_offset_scale_chroma : %d\n", m_log2SaoOffsetScale[CHANNEL_TYPE_CHROMA] ); - } -#endif switch (m_costMode) { @@ -3936,15 +3678,7 @@ void EncAppCfg::xPrintParameter() msg( DETAILS, "Max Num Merge Candidates : %d\n", m_maxNumMergeCand ); msg( DETAILS, "Max Num Affine Merge Candidates : %d\n", m_maxNumAffineMergeCand ); -#if !JVET_Q0806 -#if JVET_Q0798_SPS_NUMBER_MERGE_CANDIDATE - msg(DETAILS, "Max Num Triangle Merge Candidates : %d\n", m_maxNumGeoCand); -#else - msg( DETAILS, "Max Num Triangle Merge Candidates : %d\n", m_maxNumTriangleCand ); -#endif -#else msg( DETAILS, "Max Num Geo Merge Candidates : %d\n", m_maxNumGeoCand ); -#endif msg( DETAILS, "Max Num IBC Merge Candidates : %d\n", m_maxNumIBCMergeCand ); msg( DETAILS, "\n"); @@ -3976,15 +3710,11 @@ void EncAppCfg::xPrintParameter() msg( VERBOSE, "MCTS:%d ", m_MCTSEncConstraint ); msg( VERBOSE, "SAO:%d ", (m_bUseSAO)?(1):(0)); msg( VERBOSE, "ALF:%d ", m_alf ? 1 : 0 ); -#if JVET_Q0795_CCALF msg( VERBOSE, "CCALF:%d ", m_ccalf ? 1 : 0 ); -#endif msg( VERBOSE, "WPP:%d ", (int)m_useWeightedPred); msg( VERBOSE, "WPB:%d ", (int)m_useWeightedBiPred); -#if JVET_Q0297_MER msg( VERBOSE, "PME:%d ", m_log2ParallelMergeLevel); -#endif const int iWaveFrontSubstreams = m_entropyCodingSyncEnabledFlag ? (m_iSourceHeight + m_uiMaxCUHeight - 1) / m_uiMaxCUHeight : 1; msg( VERBOSE, " WaveFrontSynchro:%d WaveFrontSubstreams:%d", m_entropyCodingSyncEnabledFlag?1:0, iWaveFrontSubstreams); msg( VERBOSE, " ScalingList:%d ", m_useScalingListId ); @@ -4021,11 +3751,7 @@ void EncAppCfg::xPrintParameter() msg( VERBOSE, "LADF:%d ", m_LadfEnabed ); #endif msg(VERBOSE, "CIIP:%d ", m_ciip); -#if !JVET_Q0806 - msg( VERBOSE, "Triangle:%d ", m_Triangle ); -#else msg( VERBOSE, "Geo:%d ", m_Geo ); -#endif m_allowDisFracMMVD = m_MMVD ? m_allowDisFracMMVD : false; if ( m_MMVD ) msg(VERBOSE, "AllowDisFracMMVD:%d ", m_allowDisFracMMVD); @@ -4036,15 +3762,8 @@ void EncAppCfg::xPrintParameter() msg(VERBOSE, "MmvdDisNum:%d ", m_MmvdDisNum); msg(VERBOSE, "JointCbCr:%d ", m_JointCbCrMode); } -#if JVET_Q0820_ACT m_useColorTrans = (m_chromaFormatIDC == CHROMA_444) ? m_useColorTrans : 0u; -#else - m_useColorTrans = (m_chromaFormatIDC == CHROMA_444 && m_costMode != COST_LOSSLESS_CODING) ? m_useColorTrans : 0u; -#endif msg(VERBOSE, "ACT:%d ", m_useColorTrans); -#if !JVET_Q0504_PLT_NON444 - m_PLTMode = ( m_chromaFormatIDC == CHROMA_444) ? m_PLTMode : 0u; -#endif msg(VERBOSE, "PLT:%d ", m_PLTMode); msg(VERBOSE, "IBC:%d ", m_IBCMode); msg( VERBOSE, "HashME:%d ", m_HashME ); @@ -4054,16 +3773,10 @@ void EncAppCfg::xPrintParameter() msg( VERBOSE, "WrapAroundOffset:%d ", m_wrapAroundOffset ); } // ADD_NEW_TOOL (add some output indicating the usage of tools) -#if JVET_Q0246_VIRTUAL_BOUNDARY_ENABLE_FLAG msg( VERBOSE, "VirtualBoundariesEnabledFlag:%d ", m_virtualBoundariesEnabledFlag ); msg( VERBOSE, "VirtualBoundariesPresentInSPSFlag:%d ", m_virtualBoundariesPresentFlag ); if( m_virtualBoundariesPresentFlag ) { -#else - msg(VERBOSE, "LoopFilterAcrossVirtualBoundaries:%d ", m_loopFilterAcrossVirtualBoundariesDisabledFlag); - if ( m_loopFilterAcrossVirtualBoundariesDisabledFlag ) - { -#endif msg(VERBOSE, "vertical virtual boundaries:["); for (unsigned i = 0; i < m_numVerVirtualBoundaries; i++) { diff --git a/source/App/EncoderApp/EncAppCfg.h b/source/App/EncoderApp/EncAppCfg.h index 9897961ac9b242f2a4c97c29678a00a296f59c07..0762b6d85bd86daff670ca9dcf6d1ce2328748e0 100644 --- a/source/App/EncoderApp/EncAppCfg.h +++ b/source/App/EncoderApp/EncAppCfg.h @@ -116,9 +116,7 @@ protected: int m_framesToBeEncoded; ///< number of encoded frames int m_aiPad[2]; ///< number of padded pixels for width and height bool m_AccessUnitDelimiter; ///< add Access Unit Delimiter NAL units -#if JVET_Q0775_PH_IN_SH bool m_enablePictureHeaderInSliceHeader; ///< Enable Picture Header in Slice Header -#endif InputColourSpaceConversion m_inputColourSpaceConvert; ///< colour space conversion to apply to input video bool m_snrInternalColourSpace; ///< if true, then no colour space conversion is applied for snr calculation, otherwise inverse of input is applied. bool m_outputInternalColourSpace; ///< if true, then no colour space conversion is applied for reconstructed video, otherwise inverse of input is applied. @@ -137,13 +135,25 @@ protected: uint32_t m_maxBitDepthConstraintIdc; uint32_t m_maxChromaFormatConstraintIdc; bool m_bFrameConstraintFlag; +#if JVET_R0286_GCI_CLEANUP + bool m_singleLayerConstraintFlag; + bool m_allLayersIndependentConstraintFlag; + bool m_noMrlConstraintFlag; + bool m_noIspConstraintFlag; + bool m_noMipConstraintFlag; + bool m_noLfnstConstraintFlag; + bool m_noMmvdConstraintFlag; + bool m_noSmvdConstraintFlag; + bool m_noProfConstraintFlag; + bool m_noPaletteConstraintFlag; + bool m_noActConstraintFlag; + bool m_noLmcsConstraintFlag; +#endif bool m_bNoQtbttDualTreeIntraConstraintFlag; bool m_noPartitionConstraintsOverrideConstraintFlag; bool m_bNoSaoConstraintFlag; bool m_bNoAlfConstraintFlag; -#if JVET_Q0795_CCALF bool m_noCCAlfConstraintFlag; -#endif bool m_bNoRefWraparoundConstraintFlag; bool m_bNoTemporalMvpConstraintFlag; bool m_bNoSbtmvpConstraintFlag; @@ -158,11 +168,7 @@ protected: bool m_noIbcConstraintFlag; bool m_bNoCiipConstraintFlag; bool m_noFPelMmvdConstraintFlag; -#if !JVET_Q0806 - bool m_bNoTriangleConstraintFlag; -#else bool m_noGeoConstraintFlag; -#endif bool m_bNoLadfConstraintFlag; bool m_noTransformSkipConstraintFlag; bool m_noBDPCMConstraintFlag; @@ -189,16 +195,16 @@ protected: uint32_t m_bitDepthConstraint; ChromaFormat m_chromaFormatConstraint; bool m_intraConstraintFlag; +#if !JVET_R0090_VUI bool m_progressiveSourceFlag; bool m_interlacedSourceFlag; +#endif bool m_nonPackedConstraintFlag; -#if JVET_Q0114_CONSTRAINT_FLAGS bool m_nonProjectedConstraintFlag; bool m_noResChangeInClvsConstraintFlag; bool m_oneTilePerPicConstraintFlag; bool m_oneSlicePerPicConstraintFlag; bool m_oneSubpicPerPicConstraintFlag; -#endif bool m_frameOnlyConstraintFlag; // coding structure @@ -213,20 +219,10 @@ protected: GOPEntry m_GOPList[MAX_GOP]; ///< the coding structure entries from the config file int m_numReorderPics[MAX_TLAYER]; ///< total number of reorder pictures int m_maxDecPicBuffering[MAX_TLAYER]; ///< total number of pictures in the decoded picture buffer -#if !REMOVE_PPS_REXT - bool m_crossComponentPredictionEnabledFlag; ///< flag enabling the use of cross-component prediction -#endif bool m_reconBasedCrossCPredictionEstimate; ///< causes the alpha calculation in encoder search to be based on the decoded residual rather than the pre-transform encoder-side residual -#if !JVET_Q0441_SAO_MOD_12_BIT - uint32_t m_log2SaoOffsetScale[MAX_NUM_CHANNEL_TYPE]; ///< number of bits for the upward bit shift operation on the decoded SAO offsets -#endif bool m_useTransformSkip; ///< flag for enabling intra transform skipping bool m_useTransformSkipFast; ///< flag for enabling fast intra transform skipping -#if JVET_Q0089_SLICE_LOSSLESS_CODING_CHROMA_BDPCM bool m_useBDPCM; -#else - int m_useBDPCM; -#endif uint32_t m_log2MaxTransformSkipBlockSize; ///< transform-skip maximum size (minimum of 2) bool m_transformSkipRotationEnabledFlag; ///< control flag for transform-skip/transquant-bypass residual rotation bool m_transformSkipContextEnabledFlag; ///< control flag for transform-skip/transquant-bypass single significance map context @@ -285,36 +281,25 @@ protected: // coding unit (CU) definition unsigned m_uiCTUSize; -#if JVET_Q0119_CLEANUPS bool m_subPicInfoPresentFlag; -#else - bool m_subPicPresentFlag; -#endif unsigned m_numSubPics; std::vector<uint32_t> m_subPicCtuTopLeftX; std::vector<uint32_t> m_subPicCtuTopLeftY; std::vector<uint32_t> m_subPicWidth; std::vector<uint32_t> m_subPicHeight; - std::vector<uint32_t> m_subPicTreatedAsPicFlag; - std::vector<uint32_t> m_loopFilterAcrossSubpicEnabledFlag; -#if JVET_Q0119_CLEANUPS + std::vector<bool> m_subPicTreatedAsPicFlag; + std::vector<bool> m_loopFilterAcrossSubpicEnabledFlag; bool m_subPicIdMappingExplicitlySignalledFlag; bool m_subPicIdMappingInSpsFlag; -#else - bool m_subPicIdPresentFlag; - bool m_subPicIdSignallingPresentFlag; -#endif unsigned m_subPicIdLen; - std::vector<uint32_t> m_subPicId; + std::vector<uint16_t> m_subPicId; bool m_SplitConsOverrideEnabledFlag; unsigned m_uiMinQT[3]; // 0: I slice luma; 1: P/B slice; 2: I slice chroma unsigned m_uiMaxMTTHierarchyDepth; unsigned m_uiMaxMTTHierarchyDepthI; unsigned m_uiMaxMTTHierarchyDepthIChroma; -#if JVET_Q0330_BLOCK_PARTITION unsigned m_uiMaxBT[3]; unsigned m_uiMaxTT[3]; -#endif bool m_dualTree; bool m_LFNST; bool m_useFastLFNST; @@ -344,11 +329,7 @@ protected: #endif bool m_ciip; -#if !JVET_Q0806 - bool m_Triangle; -#else bool m_Geo; -#endif bool m_HashME; bool m_allowDisFracMMVD; bool m_AffineAmvr; @@ -373,12 +354,8 @@ protected: unsigned m_wrapAroundOffset; // ADD_NEW_TOOL : (encoder app) add tool enabling flags and associated parameters here -#if JVET_Q0246_VIRTUAL_BOUNDARY_ENABLE_FLAG bool m_virtualBoundariesEnabledFlag; bool m_virtualBoundariesPresentFlag; -#else - bool m_loopFilterAcrossVirtualBoundariesDisabledFlag; -#endif unsigned m_numVerVirtualBoundaries; unsigned m_numHorVirtualBoundaries; std::vector<unsigned> m_virtualBoundariesPosX; @@ -394,13 +371,7 @@ protected: bool m_encDbOpt; unsigned m_uiMaxCUWidth; ///< max. CU width in pixel unsigned m_uiMaxCUHeight; ///< max. CU height in pixel -#if JVET_Q0468_Q0469_MIN_LUMA_CB_AND_MIN_QT_FIX unsigned m_log2MinCuSize; ///< min. CU size log2 -#else - unsigned m_uiMaxCUDepth; ///< max. CU depth (as specified by command line) - unsigned m_uiMaxCodingDepth; ///< max. total CU depth - includes depth of transform-block structure - unsigned m_uiLog2DiffMaxMinCodingBlockSize; ///< difference between largest and smallest CU depth -#endif bool m_useFastLCTU; bool m_usePbIntraFast; @@ -449,12 +420,10 @@ protected: bool m_loopFilterOffsetInPPS; ///< offset for deblocking filter in 0 = slice header, 1 = PPS int m_loopFilterBetaOffsetDiv2; ///< beta offset for deblocking filter int m_loopFilterTcOffsetDiv2; ///< tc offset for deblocking filter -#if JVET_Q0121_DEBLOCKING_CONTROL_PARAMETERS int m_loopFilterCbBetaOffsetDiv2; ///< beta offset for Cb deblocking filter int m_loopFilterCbTcOffsetDiv2; ///< tc offset for Cb deblocking filter int m_loopFilterCrBetaOffsetDiv2; ///< beta offset for Cr deblocking filter int m_loopFilterCrTcOffsetDiv2; ///< tc offset for Cr deblocking filter -#endif #if W0038_DB_OPT int m_deblockingFilterMetric; ///< blockiness metric in encoder #else @@ -485,6 +454,9 @@ protected: bool m_bUseCbfFastMode; ///< flag for using Cbf Fast PU Mode Decision bool m_useEarlySkipDetection; ///< flag for using Early SKIP Detection bool m_picPartitionFlag; ///< enable picture partitioning (0: single tile, single slice, 1: multiple tiles/slices can be used) +#if JVET_R0110_MIXED_LOSSLESS + std::vector<uint32_t> m_sliceLosslessArray; ///< Slice lossless array +#endif std::vector<uint32_t> m_tileColumnWidth; ///< tile column widths in units of CTUs (last column width will be repeated uniformly to cover any remaining picture width) std::vector<uint32_t> m_tileRowHeight; ///< tile row heights in units of CTUs (last row height will be repeated uniformly to cover any remaining picture height) bool m_rasterSliceFlag; ///< indicates if using raster-scan or rectangular slices (0: rectangular, 1: raster-scan) @@ -499,10 +471,11 @@ protected: std::vector<RectSlice> m_rectSlices; ///< derived list of rectangular slice signalling parameters uint32_t m_numTileCols; ///< derived number of tile columns uint32_t m_numTileRows; ///< derived number of tile rows - bool m_subPicPartitionFlag; bool m_singleSlicePerSubPicFlag; bool m_entropyCodingSyncEnabledFlag; -#if JVET_Q0151_Q0205_ENTRYPOINTS +#if JVET_R0165_OPTIONAL_ENTRY_POINT + bool m_entryPointPresentFlag; ///< flag for the presence of entry points +#else bool m_entropyCodingSyncEntryPointPresentFlag; ///< flag for the presence of entry points for WPP #endif @@ -515,9 +488,7 @@ protected: bool m_pictureTimingSEIEnabled; bool m_bpDeltasGOPStructure; bool m_decodingUnitInfoSEIEnabled; -#if JVET_P0190_SCALABLE_NESTING_SEI bool m_scalableNestingSEIEnabled; -#endif bool m_frameFieldInfoSEIEnabled; bool m_framePackingSEIEnabled; int m_framePackingSEIType; @@ -622,19 +593,11 @@ protected: std::vector<double> m_gcmpSEIFunctionCoeffV; std::vector<bool> m_gcmpSEIFunctionVAffectedByUFlag; bool m_gcmpSEIGuardBandFlag; -#if JVET_Q0343_GCMP_GUARD_BAND_TYPE uint32_t m_gcmpSEIGuardBandType; bool m_gcmpSEIGuardBandBoundaryExteriorFlag; -#else - bool m_gcmpSEIGuardBandBoundaryType; -#endif uint32_t m_gcmpSEIGuardBandSamplesMinus1; -#if JVET_SUBPIC_LEVEL_CFG EncCfgParam::CfgSEISubpictureLevel m_cfgSubpictureLevelInfoSEI; -#else - bool m_subpicureLevelInfoSEIEnabled; -#endif bool m_sampleAspectRatioInfoSEIEnabled; bool m_sariCancelFlag; @@ -650,47 +613,20 @@ protected: bool m_useWeightedBiPred; ///< Use of bi-directional weighted prediction in B slices WeightedPredictionMethod m_weightedPredictionMethod; -#if JVET_Q0297_MER uint32_t m_log2ParallelMergeLevel; ///< Parallel merge estimation region -#endif uint32_t m_maxNumMergeCand; ///< Max number of merge candidates uint32_t m_maxNumAffineMergeCand; ///< Max number of affine merge candidates -#if !JVET_Q0806 -#if JVET_Q0798_SPS_NUMBER_MERGE_CANDIDATE uint32_t m_maxNumGeoCand; -#else - uint32_t m_maxNumTriangleCand; -#endif -#else - uint32_t m_maxNumGeoCand; -#endif uint32_t m_maxNumIBCMergeCand; ///< Max number of IBC merge candidates bool m_sliceLevelRpl; ///< code reference picture lists in slice headers rather than picture header bool m_sliceLevelDblk; ///< code deblocking filter parameters in slice headers rather than picture header bool m_sliceLevelSao; ///< code SAO parameters in slice headers rather than picture header bool m_sliceLevelAlf; ///< code ALF parameters in slice headers rather than picture header -#if JVET_Q0819_PH_CHANGES bool m_sliceLevelWp; ///< code weighted prediction parameters in slice headers rather than picture header bool m_sliceLevelDeltaQp; ///< code delta in slice headers rather than picture header -#endif int m_TMVPModeId; -#if !JVET_Q0482_REMOVE_CONSTANT_PARAMS - int m_PPSorSliceMode; - bool m_constantSliceHeaderParamsEnabledFlag; - int m_PPSDepQuantEnabledIdc; - int m_PPSRefPicListSPSIdc0; - int m_PPSRefPicListSPSIdc1; - int m_PPSMvdL1ZeroIdc; - int m_PPSCollocatedFromL0Idc; - uint32_t m_PPSSixMinusMaxNumMergeCandPlus1; -#if !JVET_Q0806 - uint32_t m_PPSMaxNumMergeCandMinusMaxNumTriangleCandPlus1; -#else - uint32_t m_PPSMaxNumMergeCandMinusMaxNumGeoCandPlus1; -#endif -#endif bool m_depQuantEnabledFlag; bool m_signDataHidingEnabledFlag; bool m_RCEnableRateControl; ///< enable rate control or not @@ -708,17 +644,23 @@ protected: ScalingListMode m_useScalingListId; ///< using quantization matrix std::string m_scalingListFileName; ///< quantization matrix file name bool m_disableScalingMatrixForLfnstBlks; +#if JVET_R0380_SCALING_MATRIX_DISABLE_YCC_OR_RGB + bool m_disableScalingMatrixForAlternativeColourSpace; + bool m_scalingMatrixDesignatedColourSpace; +#endif CostMode m_costMode; ///< Cost mode to use +#if JVET_R0143_TSRCdisableLL + bool m_TSRCdisableLL; ///< disable TSRC for lossless +#endif bool m_recalculateQPAccordingToLambda; ///< recalculate QP value according to the lambda value -#if JVET_Q0117_PARAMETER_SETS_CLEANUP bool m_DCIEnabled; ///< enable Decoding Capability Information (DCI) -#else - bool m_decodingParameterSetEnabled; ///< enable decoding parameter set -#endif bool m_hrdParametersPresentFlag; ///< enable generation of HRD parameters bool m_vuiParametersPresentFlag; ///< enable generation of VUI parameters +#if JVET_Q0394_TIMING_SEI + bool m_samePicTimingInAllOLS; ///< same picture timing SEI message is used in all OLS +#endif bool m_aspectRatioInfoPresentFlag; ///< Signals whether aspect_ratio_idc is present int m_aspectRatioIdc; ///< aspect_ratio_idc int m_sarWidth; ///< horizontal size of the sample aspect ratio @@ -727,6 +669,10 @@ protected: int m_colourPrimaries; ///< Indicates chromaticity coordinates of the source primaries int m_transferCharacteristics; ///< Indicates the opto-electronic transfer characteristics of the source int m_matrixCoefficients; ///< Describes the matrix coefficients used in deriving luma and chroma from RGB primaries +#if JVET_R0090_VUI + bool m_progressiveSourceFlag; ///< Indicates if the content is progressive + bool m_interlacedSourceFlag; ///< Indicates if the content is interlaced +#endif bool m_chromaLocInfoPresentFlag; ///< Signals whether chroma_sample_loc_type_top_field and chroma_sample_loc_type_bottom_field are present int m_chromaSampleLocTypeTopField; ///< Specifies the location of chroma samples for top field int m_chromaSampleLocTypeBottomField; ///< Specifies the location of chroma samples for bottom field @@ -753,10 +699,8 @@ protected: bool m_forceDecodeBitstream1; bool m_alf; ///< Adaptive Loop Filter -#if JVET_Q0795_CCALF bool m_ccalf; int m_ccalfQpThreshold; -#endif double m_scalingRatioHor; double m_scalingRatioVer; @@ -770,9 +714,7 @@ protected: std::map<int, double> m_gopBasedTemporalFilterStrengths; ///< Filter strength per frame for the GOP-based Temporal Filter int m_maxLayers; -#if JVET_Q0814_DPB int m_targetOlsIdx; -#endif int m_layerId[MAX_VPS_LAYERS]; int m_layerIdx; @@ -786,11 +728,9 @@ protected: int m_numOutputLayerSets; std::string m_olsOutputLayerStr[MAX_VPS_LAYERS]; -#if JVET_Q0786_PTL_only int m_numPtlsInVps; Level::Name m_levelPtl[MAX_NUM_OLSS]; - int m_olsPtlIdx[MAX_NUM_OLSS]; -#endif + int m_olsPtlIdx[MAX_NUM_OLSS]; #if EXTENSION_360_VIDEO TExt360AppEncCfg m_ext360; diff --git a/source/App/EncoderApp/encmain.cpp b/source/App/EncoderApp/encmain.cpp index 16a02a429b29a67233b57d20a57e73d1f8a453f4..e10acfcbfb921dc36a017ef29793586a01e5cc5c 100644 --- a/source/App/EncoderApp/encmain.cpp +++ b/source/App/EncoderApp/encmain.cpp @@ -180,7 +180,6 @@ int main(int argc, char* argv[]) delete[] layerArgv; -#if JVET_Q0172_CHROMA_FORMAT_BITDEPTH_CONSTRAINT if (layerIdx > 1) { VPS* vps = pcEncApp[0]->getVPS(); @@ -201,7 +200,6 @@ int main(int argc, char* argv[]) } } } -#endif #if PRINT_MACRO_VALUES printMacroSettings(); diff --git a/source/App/Parcat/parcat.cpp b/source/App/Parcat/parcat.cpp index 01d70b297a219546593b3ac43f89fae40ff29da7..c0ed4807a180e8a9e1ff19feb9e825c7985251e0 100644 --- a/source/App/Parcat/parcat.cpp +++ b/source/App/Parcat/parcat.cpp @@ -48,15 +48,10 @@ class ParcatHLSyntaxReader : public VLCReader { public: -#if JVET_Q0819_PH_CHANGES void parsePictureHeaderUpToPoc ( ParameterSetManager *parameterSetManager ); bool parsePictureHeaderInSliceHeaderFlag ( ParameterSetManager *parameterSetManager ); -#else - void parseSliceHeaderUpToPoc ( ParameterSetManager *parameterSetManager ); -#endif }; -#if JVET_Q0819_PH_CHANGES bool ParcatHLSyntaxReader::parsePictureHeaderInSliceHeaderFlag(ParameterSetManager *parameterSetManager) { @@ -89,13 +84,6 @@ void ParcatHLSyntaxReader::parsePictureHeaderUpToPoc ( ParameterSetManager *para CHECK(sps == 0, "Invalid SPS"); return; } -#else -void ParcatHLSyntaxReader::parseSliceHeaderUpToPoc ( ParameterSetManager *parameterSetManager ) -{ - // POC is first syntax element in slice header - return; -} -#endif /** Find the beginning and end of a NAL (Network Abstraction Layer) unit in a byte buffer containing H264 bitstream data. @@ -230,12 +218,8 @@ std::vector<uint8_t> filter_segment(const std::vector<uint8_t> & v, int idx, int int bits_for_poc = 8; bool skip_next_sei = false; -#if JVET_Q0819_PH_CHANGES bool change_poc = false; bool first_idr_slice_after_ph_nal = false; -#else - bool first_slice_segment_in_pic_flag = false; -#endif while(find_nal_unit(p, sz, &nal_start, &nal_end) > 0) { @@ -282,28 +266,17 @@ std::vector<uint8_t> filter_segment(const std::vector<uint8_t> & v, int idx, int HLSReader.parsePPS( pps ); parameterSetManager.storePPS( pps, inp_nalu.getBitstream().getFifo() ); } -#if !JVET_Q0819_PH_CHANGES - if( inp_nalu.m_nalUnitType == NAL_UNIT_PH ) - { - first_slice_segment_in_pic_flag = true; - } -#endif if(nalu_type == NAL_UNIT_CODED_SLICE_IDR_W_RADL || nalu_type == NAL_UNIT_CODED_SLICE_IDR_N_LP) { poc = 0; new_poc = *poc_base + poc; -#if JVET_Q0819_PH_CHANGES if (first_idr_slice_after_ph_nal) { cnt--; } first_idr_slice_after_ph_nal = false; -#else - first_slice_segment_in_pic_flag = false; -#endif } -#if JVET_Q0819_PH_CHANGES if(inp_nalu.m_nalUnitType == NAL_UNIT_PH || (nalu_type < NAL_UNIT_CODED_SLICE_IDR_W_RADL) || (nalu_type > NAL_UNIT_CODED_SLICE_IDR_N_LP && nalu_type <= NAL_UNIT_RESERVED_IRAP_VCL_12) ) { parcatHLSReader.setBitstream( &inp_nalu.getBitstream() ); @@ -348,57 +321,14 @@ std::vector<uint8_t> filter_segment(const std::vector<uint8_t> & v, int idx, int change_poc = false; } } -#else - if((nalu_type < NAL_UNIT_CODED_SLICE_IDR_W_RADL) || (nalu_type > NAL_UNIT_CODED_SLICE_IDR_N_LP && nalu_type <= NAL_UNIT_RESERVED_IRAP_VCL_12) ) - { - parcatHLSReader.setBitstream( &inp_nalu.getBitstream() ); - - // beginning of slice header parsing, taken from VLCReader - parcatHLSReader.parseSliceHeaderUpToPoc( ¶meterSetManager ); - int num_bits_up_to_poc_lsb = parcatHLSReader.getBitstream()->getNumBitsRead(); - int offset = num_bits_up_to_poc_lsb; - - int byte_offset = offset / 8; - int hi_bits = offset % 8; - uint16_t data = (nalu[byte_offset] << 8) | nalu[byte_offset + 1]; - int low_bits = 16 - hi_bits - bits_for_poc; - poc_lsb = (data >> low_bits) & 0xff; - poc = poc_lsb; //calc_poc(poc_lsb, 0, bits_for_poc, nalu_type); - - new_poc = poc + *poc_base; - // int picOrderCntLSB = (pcSlice->getPOC()-pcSlice->getLastIDR()+(1<<pcSlice->getSPS()->getBitsForPOC())) & ((1<<pcSlice->getSPS()->getBitsForPOC())-1); - unsigned picOrderCntLSB = (new_poc - *last_idr_poc +(1 << bits_for_poc)) & ((1<<bits_for_poc)-1); - - int low = data & ((1 << low_bits) - 1); - int hi = data >> (16 - hi_bits); - data = (hi << (16 - hi_bits)) | (picOrderCntLSB << low_bits) | low; - - nalu[byte_offset] = data >> 8; - nalu[byte_offset + 1] = data & 0xff; - - if( first_slice_segment_in_pic_flag ) - { -#if ENABLE_TRACING - std::cout << "Changed poc " << poc << " to " << new_poc << std::endl; -#endif - ++cnt; - first_slice_segment_in_pic_flag = false; - } - } -#endif if(idx > 1 && (nalu_type == NAL_UNIT_CODED_SLICE_IDR_W_RADL || nalu_type == NAL_UNIT_CODED_SLICE_IDR_N_LP)) { skip_next_sei = true; idr_found = true; } -#if JVET_Q0117_PARAMETER_SETS_CLEANUP 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 - 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/CommonLib/AdaptiveLoopFilter.cpp b/source/Lib/CommonLib/AdaptiveLoopFilter.cpp index 332f2e13216b5d4509afd36013faf0745b8cf5a7..c82551538f0030392a409acbf836ab11adbc3c5d 100644 --- a/source/Lib/CommonLib/AdaptiveLoopFilter.cpp +++ b/source/Lib/CommonLib/AdaptiveLoopFilter.cpp @@ -63,9 +63,7 @@ AdaptiveLoopFilter::AdaptiveLoopFilter() } m_deriveClassificationBlk = deriveClassificationBlk; -#if JVET_Q0795_CCALF m_filterCcAlf = filterBlkCcAlf<CC_ALF>; -#endif m_filter5x5Blk = filterBlk<ALF_FILTER_5>; m_filter7x7Blk = filterBlk<ALF_FILTER_7>; @@ -83,13 +81,8 @@ bool AdaptiveLoopFilter::isCrossedByVirtualBoundaries( const CodingStructure& cs const PPS* pps = cs.pps; const PicHeader* picHeader = cs.picHeader; -#if JVET_Q0246_VIRTUAL_BOUNDARY_ENABLE_FLAG if( picHeader->getVirtualBoundariesPresentFlag() ) { -#else - if( picHeader->getLoopFilterAcrossVirtualBoundariesDisabledFlag() ) - { -#endif for( int i = 0; i < picHeader->getNumHorVirtualBoundaries(); i++ ) { if( picHeader->getVirtualBoundariesPosY(i) == yPos ) @@ -126,20 +119,16 @@ bool AdaptiveLoopFilter::isCrossedByVirtualBoundaries( const CodingStructure& cs int ctuSize = slice.getSPS()->getCTUSize(); const Position currCtuPos(xPos, yPos); const CodingUnit *currCtu = cs.getCU(currCtuPos, CHANNEL_TYPE_LUMA); -#if JVET_O1143_LPF_ACROSS_SUBPIC_BOUNDARY - SubPic curSubPic = slice.getPPS()->getSubPicFromPos(currCtuPos); + const SubPic& curSubPic = slice.getPPS()->getSubPicFromPos(currCtuPos); bool loopFilterAcrossSubPicEnabledFlag = curSubPic.getloopFilterAcrossEnabledFlag(); -#endif //top if (yPos >= ctuSize && clipTop == false) { const Position prevCtuPos(xPos, yPos - ctuSize); const CodingUnit *prevCtu = cs.getCU(prevCtuPos, CHANNEL_TYPE_LUMA); - if ((!pps->getLoopFilterAcrossSlicesEnabledFlag() && !CU::isSameSlice(*currCtu, *prevCtu)) || + if ((!pps->getLoopFilterAcrossSlicesEnabledFlag() && !CU::isSameSlice(*currCtu, *prevCtu)) || (!pps->getLoopFilterAcrossTilesEnabledFlag() && !CU::isSameTile(*currCtu, *prevCtu)) -#if JVET_O1143_LPF_ACROSS_SUBPIC_BOUNDARY || (!loopFilterAcrossSubPicEnabledFlag && !CU::isSameSubPic(*currCtu, *prevCtu)) -#endif ) { clipTop = true; @@ -151,11 +140,9 @@ bool AdaptiveLoopFilter::isCrossedByVirtualBoundaries( const CodingStructure& cs { const Position nextCtuPos(xPos, yPos + ctuSize); const CodingUnit *nextCtu = cs.getCU(nextCtuPos, CHANNEL_TYPE_LUMA); - if ((!pps->getLoopFilterAcrossSlicesEnabledFlag() && !CU::isSameSlice(*currCtu, *nextCtu)) || + if ((!pps->getLoopFilterAcrossSlicesEnabledFlag() && !CU::isSameSlice(*currCtu, *nextCtu)) || (!pps->getLoopFilterAcrossTilesEnabledFlag() && !CU::isSameTile(*currCtu, *nextCtu)) -#if JVET_O1143_LPF_ACROSS_SUBPIC_BOUNDARY || (!loopFilterAcrossSubPicEnabledFlag && !CU::isSameSubPic(*currCtu, *nextCtu)) -#endif ) { clipBottom = true; @@ -167,11 +154,9 @@ bool AdaptiveLoopFilter::isCrossedByVirtualBoundaries( const CodingStructure& cs { const Position prevCtuPos(xPos - ctuSize, yPos); const CodingUnit *prevCtu = cs.getCU(prevCtuPos, CHANNEL_TYPE_LUMA); - if ((!pps->getLoopFilterAcrossSlicesEnabledFlag() && !CU::isSameSlice(*currCtu, *prevCtu)) || + if ((!pps->getLoopFilterAcrossSlicesEnabledFlag() && !CU::isSameSlice(*currCtu, *prevCtu)) || (!pps->getLoopFilterAcrossTilesEnabledFlag() && !CU::isSameTile(*currCtu, *prevCtu)) -#if JVET_O1143_LPF_ACROSS_SUBPIC_BOUNDARY || (!loopFilterAcrossSubPicEnabledFlag && !CU::isSameSubPic(*currCtu, *prevCtu)) -#endif ) { clipLeft = true; @@ -183,11 +168,9 @@ bool AdaptiveLoopFilter::isCrossedByVirtualBoundaries( const CodingStructure& cs { const Position nextCtuPos(xPos + ctuSize, yPos); const CodingUnit *nextCtu = cs.getCU(nextCtuPos, CHANNEL_TYPE_LUMA); - if ((!pps->getLoopFilterAcrossSlicesEnabledFlag() && !CU::isSameSlice(*currCtu, *nextCtu)) || + if ((!pps->getLoopFilterAcrossSlicesEnabledFlag() && !CU::isSameSlice(*currCtu, *nextCtu)) || (!pps->getLoopFilterAcrossTilesEnabledFlag() && !CU::isSameTile(*currCtu, *nextCtu)) -#if JVET_O1143_LPF_ACROSS_SUBPIC_BOUNDARY || (!loopFilterAcrossSubPicEnabledFlag && !CU::isSameSubPic(*currCtu, *nextCtu)) -#endif ) { clipRight = true; @@ -313,7 +296,6 @@ const int AdaptiveLoopFilter::m_classToFilterMapping[NUM_FIXED_FILTER_SETS][MAX_ { 16, 31, 32, 15, 60, 30, 4, 17, 19, 25, 22, 20, 4, 53, 19, 21, 22, 46, 25, 55, 26, 48, 63, 58, 55 }, }; -#if JVET_Q0795_CCALF void AdaptiveLoopFilter::applyCcAlfFilter(CodingStructure &cs, ComponentID compID, const PelBuf &dstBuf, const PelUnitBuf &recYuvExt, uint8_t *filterControl, const short filterSet[MAX_NUM_CC_ALF_FILTERS][MAX_NUM_CC_ALF_CHROMA_COEFF], @@ -413,7 +395,6 @@ void AdaptiveLoopFilter::applyCcAlfFilter(CodingStructure &cs, ComponentID compI } } } -#endif void AdaptiveLoopFilter::ALFProcess(CodingStructure& cs) { @@ -463,9 +444,7 @@ void AdaptiveLoopFilter::ALFProcess(CodingStructure& cs) cs.slice = cu->slice; reconstructCoeffAPSs(cs, true, cu->slice->getTileGroupAlfEnabledFlag(COMPONENT_Cb) || cu->slice->getTileGroupAlfEnabledFlag(COMPONENT_Cr), false); alfCtuFilterIndex = cu->slice->getPic()->getAlfCtbFilterIndex(); -#if JVET_Q0795_CCALF m_ccAlfFilterParam = cu->slice->m_ccAlfFilterParam; -#endif } lastSliceIdx = cu->slice->getSliceID(); @@ -475,12 +454,10 @@ void AdaptiveLoopFilter::ALFProcess(CodingStructure& cs) for( int compIdx = 1; compIdx < MAX_NUM_COMPONENT; compIdx++ ) { ctuEnableFlag |= m_ctuEnableFlag[compIdx][ctuIdx] > 0; -#if JVET_Q0795_CCALF if (cu->slice->m_ccAlfFilterParam.ccAlfFilterEnabled[compIdx - 1]) { ctuEnableFlag |= m_ccAlfFilterControl[compIdx - 1][ctuIdx] > 0; } -#endif } int rasterSliceAlfPad = 0; if( ctuEnableFlag && isCrossedByVirtualBoundaries( cs, xPos, yPos, width, height, clipTop, clipBottom, clipLeft, clipRight, numHorVirBndry, numVerVirBndry, horVirBndryPos, verVirBndryPos, rasterSliceAlfPad ) ) @@ -556,7 +533,6 @@ void AdaptiveLoopFilter::ALFProcess(CodingStructure& cs) , m_alfVBChmaCTUHeight , m_alfVBChmaPos ); } -#if JVET_Q0795_CCALF if (cu->slice->m_ccAlfFilterParam.ccAlfFilterEnabled[compIdx - 1]) { const int filterIdx = m_ccAlfFilterControl[compIdx - 1][ctuIdx]; @@ -572,7 +548,6 @@ void AdaptiveLoopFilter::ALFProcess(CodingStructure& cs) m_alfVBLumaCTUHeight, m_alfVBLumaPos); } } -#endif } xStart = xEnd; @@ -621,7 +596,6 @@ void AdaptiveLoopFilter::ALFProcess(CodingStructure& cs) m_chromaClippFinal[alt_num], m_clpRngs.comp[compIdx], cs, m_alfVBChmaCTUHeight, m_alfVBChmaPos); } -#if JVET_Q0795_CCALF if (cu->slice->m_ccAlfFilterParam.ccAlfFilterEnabled[compIdx - 1]) { const int filterIdx = m_ccAlfFilterControl[compIdx - 1][ctuIdx]; @@ -637,7 +611,6 @@ void AdaptiveLoopFilter::ALFProcess(CodingStructure& cs) m_alfVBLumaCTUHeight, m_alfVBLumaPos); } } -#endif } } ctuIdx++; @@ -701,11 +674,7 @@ void AdaptiveLoopFilter::reconstructCoeff( AlfParam& alfParam, ChannelType chann for( int coeffIdx = 0; coeffIdx < numCoeffMinus1; ++coeffIdx ) { m_chromaCoeffFinal[altIdx][coeffIdx] = coeff[coeffIdx]; -#if JVET_Q0249_ALF_CHROMA_CLIPFLAG int clipIdx = alfParam.nonLinearFlag[channel] ? clipp[coeffIdx] : 0; -#else - int clipIdx = alfParam.nonLinearFlag[channel][altIdx] ? clipp[coeffIdx] : 0; -#endif m_chromaClippFinal[altIdx][coeffIdx] = isRdo ? clipIdx : m_alfClippingValues[channel][clipIdx]; } m_chromaCoeffFinal[altIdx][numCoeffMinus1] = factor; @@ -725,11 +694,7 @@ void AdaptiveLoopFilter::reconstructCoeff( AlfParam& alfParam, ChannelType chann m_clippFinal[classIdx* MAX_NUM_ALF_LUMA_COEFF + numCoeffMinus1] = isRdo ? 0 : m_alfClippingValues[channel][0]; for( int coeffIdx = 0; coeffIdx < numCoeffMinus1; ++coeffIdx ) { -#if JVET_Q0249_ALF_CHROMA_CLIPFLAG int clipIdx = alfParam.nonLinearFlag[channel] ? clipp[filterIdx * MAX_NUM_ALF_LUMA_COEFF + coeffIdx] : 0; -#else - int clipIdx = alfParam.nonLinearFlag[channel][altIdx] ? clipp[filterIdx * MAX_NUM_ALF_LUMA_COEFF + coeffIdx] : 0; -#endif CHECK(!(clipIdx >= 0 && clipIdx < MaxAlfNumClippingValues), "Bad clip idx in ALF"); m_clippFinal[classIdx * MAX_NUM_ALF_LUMA_COEFF + coeffIdx] = isRdo ? clipIdx : m_alfClippingValues[channel][clipIdx]; } @@ -754,10 +719,8 @@ void AdaptiveLoopFilter::create( const int picWidth, const int picHeight, const m_numCTUsInWidth = ( m_picWidth / m_maxCUWidth ) + ( ( m_picWidth % m_maxCUWidth ) ? 1 : 0 ); m_numCTUsInHeight = ( m_picHeight / m_maxCUHeight ) + ( ( m_picHeight % m_maxCUHeight ) ? 1 : 0 ); m_numCTUsInPic = m_numCTUsInHeight * m_numCTUsInWidth; -#if JVET_Q0795_CCALF m_filterShapesCcAlf[0].push_back(AlfFilterShape(size_CC_ALF)); m_filterShapesCcAlf[1].push_back(AlfFilterShape(size_CC_ALF)); -#endif m_filterShapes[CHANNEL_TYPE_LUMA].push_back( AlfFilterShape( 7 ) ); m_filterShapes[CHANNEL_TYPE_CHROMA].push_back( AlfFilterShape( 5 ) ); m_alfVBLumaPos = m_maxCUHeight - ALF_VB_POS_ABOVE_CTUROW_LUMA; @@ -767,34 +730,19 @@ void AdaptiveLoopFilter::create( const int picWidth, const int picHeight, const m_alfVBChmaCTUHeight = (m_maxCUHeight >> ((m_chromaFormat == CHROMA_420) ? 1 : 0)); static_assert( AlfNumClippingValues[CHANNEL_TYPE_LUMA] > 0, "AlfNumClippingValues[CHANNEL_TYPE_LUMA] must be at least one" ); -#if JVET_Q0495_NLALF_CLIP_CLEANUP m_alfClippingValues[CHANNEL_TYPE_LUMA][0] = 1 << m_inputBitDepth[CHANNEL_TYPE_LUMA]; int shiftLuma = m_inputBitDepth[CHANNEL_TYPE_LUMA] - 8; for (int i = 1; i < AlfNumClippingValues[CHANNEL_TYPE_LUMA]; ++i) { m_alfClippingValues[CHANNEL_TYPE_LUMA][i] = 1 << (7 - 2 * i + shiftLuma); } -#else - for( int i = 0; i < AlfNumClippingValues[CHANNEL_TYPE_LUMA]; ++i ) - { - m_alfClippingValues[CHANNEL_TYPE_LUMA][i] = (Pel)std::round( std::pow(2., double(m_inputBitDepth[CHANNEL_TYPE_LUMA] - 2.35*i)) ); - } -#endif static_assert( AlfNumClippingValues[CHANNEL_TYPE_CHROMA] > 0, "AlfNumClippingValues[CHANNEL_TYPE_CHROMA] must be at least one" ); -#if JVET_Q0495_NLALF_CLIP_CLEANUP m_alfClippingValues[CHANNEL_TYPE_CHROMA][0] = 1 << m_inputBitDepth[CHANNEL_TYPE_CHROMA]; int shiftChroma = m_inputBitDepth[CHANNEL_TYPE_CHROMA] - 8; for (int i = 1; i < AlfNumClippingValues[CHANNEL_TYPE_CHROMA]; ++i) { m_alfClippingValues[CHANNEL_TYPE_CHROMA][i] = 1 << (7 - 2 * i + shiftChroma); } -#else - m_alfClippingValues[CHANNEL_TYPE_CHROMA][0] = 1 << m_inputBitDepth[CHANNEL_TYPE_CHROMA]; - for( int i = 1; i < AlfNumClippingValues[CHANNEL_TYPE_CHROMA]; ++i ) - { - m_alfClippingValues[CHANNEL_TYPE_CHROMA][i] = (Pel)std::round( std::pow(2., double(m_inputBitDepth[CHANNEL_TYPE_CHROMA] - 2.35*i)) ); - } -#endif if (m_created) { return; @@ -837,10 +785,8 @@ void AdaptiveLoopFilter::create( const int picWidth, const int picHeight, const } m_created = true; -#if JVET_Q0795_CCALF m_ccAlfFilterControl[0] = new uint8_t[m_numCTUsInPic]; m_ccAlfFilterControl[1] = new uint8_t[m_numCTUsInPic]; -#endif } void AdaptiveLoopFilter::destroy() @@ -863,7 +809,6 @@ void AdaptiveLoopFilter::destroy() m_filterShapes[CHANNEL_TYPE_CHROMA].clear(); m_created = false; -#if JVET_Q0795_CCALF m_filterShapesCcAlf[0].clear(); m_filterShapesCcAlf[1].clear(); if ( m_ccAlfFilterControl[0] ) @@ -877,7 +822,6 @@ void AdaptiveLoopFilter::destroy() delete [] m_ccAlfFilterControl[1]; m_ccAlfFilterControl[1] = nullptr; } -#endif } void AdaptiveLoopFilter::deriveClassification( AlfClassifier** classifier, const CPelBuf& srcLuma, const Area& blkDst, const Area& blk ) @@ -1275,10 +1219,8 @@ void AdaptiveLoopFilter::filterBlk(AlfClassifier **classifier, const PelUnitBuf pImg3 = (yVb <= vbPos + 1) ? pImg1 : pImg3; pImg5 = (yVb <= vbPos + 2) ? pImg3 : pImg5; } -#if JVET_Q0150 bool isNearVBabove = yVb < vbPos && (yVb >= vbPos - 1); bool isNearVBbelow = yVb >= vbPos && (yVb <= vbPos); -#endif for( int jj = 0; jj < clsSizeX; jj++ ) { @@ -1314,18 +1256,18 @@ void AdaptiveLoopFilter::filterBlk(AlfClassifier **classifier, const PelUnitBuf sum += filterCoeff[4] * ( clipALF(filterClipp[4], curr, pImg0[+2], pImg0[-2]) ); sum += filterCoeff[5] * ( clipALF(filterClipp[5], curr, pImg0[+1], pImg0[-1]) ); } -#if JVET_Q0150 if (!(isNearVBabove || isNearVBbelow)) { sum = (sum + offset) >> shift; } else { - sum = (sum + offset) >> (shift + 3); - } +#if JVET_R0208_ALF_VB_ROUNDING_FIX + sum = (sum + (1 << ((shift + 3) - 1))) >> (shift + 3); #else - sum = ( sum + offset ) >> shift; + sum = (sum + offset) >> (shift + 3); #endif + } sum += curr; pRec1[jj] = ClipPel( sum, clpRng ); @@ -1353,7 +1295,6 @@ void AdaptiveLoopFilter::filterBlk(AlfClassifier **classifier, const PelUnitBuf } } -#if JVET_Q0795_CCALF template<AlfFilterType filtTypeCcAlf> void AdaptiveLoopFilter::filterBlkCcAlf(const PelBuf &dstBuf, const CPelUnitBuf &recSrc, const Area &blkDst, const Area &blkSrc, const ComponentID compId, const int16_t *filterCoeff, @@ -1404,6 +1345,12 @@ void AdaptiveLoopFilter::filterBlkCcAlf(const PelBuf &dstBuf, const CPelUnitBuf const Pel *srcCross = lumaPtr + col + row * lumaStride; int pos = ((startHeight + i + ii) << scaleY) & (vbCTUHeight - 1); +#if JVET_R0233_CCALF_LINE_BUFFER_REDUCTION + if (scaleY == 0 && (pos == vbPos || pos == vbPos + 1)) + { + continue; + } +#endif if (pos == (vbPos - 2) || pos == (vbPos + 1)) { offset3 = offset1; @@ -1444,4 +1391,3 @@ void AdaptiveLoopFilter::filterBlkCcAlf(const PelBuf &dstBuf, const CPelUnitBuf lumaPtr += lumaStride * clsSizeY << getComponentScaleY(compId, nChromaFormat); } } -#endif diff --git a/source/Lib/CommonLib/AdaptiveLoopFilter.h b/source/Lib/CommonLib/AdaptiveLoopFilter.h index 39d1731146ded03a37db884b96724846ba77b4ac..74c9bdbd022a4f0168fb3411ae45b627450f5d34 100644 --- a/source/Lib/CommonLib/AdaptiveLoopFilter.h +++ b/source/Lib/CommonLib/AdaptiveLoopFilter.h @@ -91,12 +91,10 @@ public: const CPelBuf &srcLuma, const Area &blkDst, const Area &blk, const int shift, const int vbCTUHeight, int vbPos); void deriveClassification( AlfClassifier** classifier, const CPelBuf& srcLuma, const Area& blkDst, const Area& blk ); -#if JVET_Q0795_CCALF template<AlfFilterType filtTypeCcAlf> static void filterBlkCcAlf(const PelBuf &dstBuf, const CPelUnitBuf &recSrc, const Area &blkDst, const Area &blkSrc, const ComponentID compId, const int16_t *filterCoeff, const ClpRngs &clpRngs, CodingStructure &cs, int vbCTUHeight, int vbPos); -#endif template<AlfFilterType filtType> static void filterBlk(AlfClassifier **classifier, const PelUnitBuf &recDst, const CPelUnitBuf &recSrc, @@ -107,7 +105,6 @@ public: const Area &blkDst, const Area &blk, const int shift, const int vbCTUHeight, int vbPos); -#if JVET_Q0795_CCALF void (*m_filterCcAlf)(const PelBuf &dstBuf, const CPelUnitBuf &recSrc, const Area &blkDst, const Area &blkSrc, const ComponentID compId, const int16_t *filterCoeff, const ClpRngs &clpRngs, CodingStructure &cs, int vbCTUHeight, int vbPos); @@ -117,7 +114,6 @@ public: const int selectedFilterIdx); CcAlfFilterParam &getCcAlfFilterParam() { return m_ccAlfFilterParam; } uint8_t* getCcAlfControlIdc(const ComponentID compID) { return m_ccAlfFilterControl[compID-1]; } -#endif void (*m_filter5x5Blk)(AlfClassifier **classifier, const PelUnitBuf &recDst, const CPelUnitBuf &recSrc, const Area &blkDst, const Area &blk, const ComponentID compId, const short *filterSet, const short *fClipSet, const ClpRng &clpRng, CodingStructure &cs, const int vbCTUHeight, @@ -135,11 +131,9 @@ public: protected: bool isCrossedByVirtualBoundaries( const CodingStructure& cs, const int xPos, const int yPos, const int width, const int height, bool& clipTop, bool& clipBottom, bool& clipLeft, bool& clipRight, int& numHorVirBndry, int& numVerVirBndry, int horVirBndryPos[], int verVirBndryPos[], int& rasterSliceAlfPad ); -#if JVET_Q0795_CCALF static constexpr int m_scaleBits = 7; // 8-bits CcAlfFilterParam m_ccAlfFilterParam; uint8_t* m_ccAlfFilterControl[2]; -#endif static const int m_classToFilterMapping[NUM_FIXED_FILTER_SETS][MAX_NUM_ALF_CLASSES]; static const int m_fixedFilterSetCoeff[ALF_FIXED_FILTER_NUM][MAX_NUM_ALF_LUMA_COEFF]; short m_fixedFilterSetCoeffDec[NUM_FIXED_FILTER_SETS][MAX_NUM_ALF_CLASSES * MAX_NUM_ALF_LUMA_COEFF]; @@ -150,9 +144,7 @@ protected: short m_chromaCoeffFinal[MAX_NUM_ALF_ALTERNATIVES_CHROMA][MAX_NUM_ALF_CHROMA_COEFF]; AlfParam* m_alfParamChroma; Pel m_alfClippingValues[MAX_NUM_CHANNEL_TYPE][MaxAlfNumClippingValues]; -#if JVET_Q0795_CCALF std::vector<AlfFilterShape> m_filterShapesCcAlf[2]; -#endif std::vector<AlfFilterShape> m_filterShapes[MAX_NUM_CHANNEL_TYPE]; AlfClassifier** m_classifier; short m_coeffFinal[MAX_NUM_ALF_CLASSES * MAX_NUM_ALF_LUMA_COEFF]; diff --git a/source/Lib/CommonLib/AlfParameters.h b/source/Lib/CommonLib/AlfParameters.h index 45fa9b275ddc919a153392eff223b38aa0d7c6d4..989952d81b69e9122709ab8e933846ea19f63ca1 100644 --- a/source/Lib/CommonLib/AlfParameters.h +++ b/source/Lib/CommonLib/AlfParameters.h @@ -48,16 +48,12 @@ enum AlfFilterType { ALF_FILTER_5, ALF_FILTER_7, -#if JVET_Q0795_CCALF CC_ALF, -#endif ALF_NUM_OF_FILTER_TYPES }; -#if JVET_Q0795_CCALF static const int size_CC_ALF = -1; -#endif struct AlfFilterShape { @@ -105,7 +101,6 @@ struct AlfFilterShape filterType = ALF_FILTER_7; } -#if JVET_Q0795_CCALF else if (size == size_CC_ALF) { size = 4; @@ -114,7 +109,6 @@ struct AlfFilterShape filterSize = 8; filterType = CC_ALF; } -#endif else { filterType = ALF_NUM_OF_FILTER_TYPES; @@ -133,11 +127,7 @@ struct AlfFilterShape struct AlfParam { bool enabledFlag[MAX_NUM_COMPONENT]; // alf_slice_enable_flag, alf_chroma_idc -#if JVET_Q0249_ALF_CHROMA_CLIPFLAG bool nonLinearFlag[MAX_NUM_CHANNEL_TYPE]; // alf_[luma/chroma]_clip_flag -#else - bool nonLinearFlag[MAX_NUM_CHANNEL_TYPE][MAX_NUM_ALF_ALTERNATIVES_CHROMA]; // alf_[luma/chroma]_clip_flag -#endif short lumaCoeff[MAX_NUM_ALF_CLASSES * MAX_NUM_ALF_LUMA_COEFF]; // alf_coeff_luma_delta[i][j] short lumaClipp[MAX_NUM_ALF_CLASSES * MAX_NUM_ALF_LUMA_COEFF]; // alf_clipp_luma_[i][j] int numAlternativesChroma; // alf_chroma_num_alts_minus_one + 1 @@ -249,7 +239,6 @@ struct AlfParam } }; -#if JVET_Q0795_CCALF struct CcAlfFilterParam { bool ccAlfFilterEnabled[2]; @@ -285,7 +274,6 @@ struct CcAlfFilterParam return *this; } }; -#endif //! \} #endif // end of #ifndef __ALFPARAMETERS__ diff --git a/source/Lib/CommonLib/Buffer.cpp b/source/Lib/CommonLib/Buffer.cpp index 7b59a40e88aaed51824cbecb6fa4f7aae3a9e1b4..b1ed883e4b4c5453dc2f053b157c7f6c688102fc 100644 --- a/source/Lib/CommonLib/Buffer.cpp +++ b/source/Lib/CommonLib/Buffer.cpp @@ -553,7 +553,6 @@ void AreaBuf<Pel>::copyClip( const AreaBuf<const Pel> &src, const ClpRng& clpRng } } -#if JVET_Q0806 template<> void AreaBuf<Pel>::roundToOutputBitdepth( const AreaBuf<const Pel> &src, const ClpRng& clpRng ) { @@ -565,7 +564,7 @@ void AreaBuf<Pel>::roundToOutputBitdepth( const AreaBuf<const Pel> &src, const C const int32_t clipbd = clpRng.bd; const int32_t shiftDefault = std::max<int>(2, (IF_INTERNAL_PREC - clipbd)); const int32_t offsetDefault = (1<<(shiftDefault-1)) + IF_INTERNAL_OFFS; - + if( width == 1 ) { THROW( "Blocks of width = 1 not supported" ); @@ -583,7 +582,6 @@ void AreaBuf<Pel>::roundToOutputBitdepth( const AreaBuf<const Pel> &src, const C #undef RND_INC } } -#endif template<> @@ -811,11 +809,7 @@ const CPelUnitBuf PelStorage::getBuf( const UnitArea &unit ) const } template<> -#if JVET_Q0820_ACT void UnitBuf<Pel>::colorSpaceConvert(const UnitBuf<Pel> &other, const bool forward, const ClpRng& clpRng) -#else -void UnitBuf<Pel>::colorSpaceConvert(const UnitBuf<Pel> &other, const bool forward) -#endif { const Pel* pOrg0 = bufs[COMPONENT_Y].buf; const Pel* pOrg1 = bufs[COMPONENT_Cb].buf; @@ -829,9 +823,7 @@ void UnitBuf<Pel>::colorSpaceConvert(const UnitBuf<Pel> &other, const bool forwa int width = bufs[COMPONENT_Y].width; int height = bufs[COMPONENT_Y].height; -#if JVET_Q0820_ACT int maxAbsclipBD = (1 << (clpRng.bd + 1)) - 1; -#endif int r, g, b; int y0, cg, co; @@ -849,21 +841,12 @@ void UnitBuf<Pel>::colorSpaceConvert(const UnitBuf<Pel> &other, const bool forwa g = pOrg0[x]; b = pOrg1[x]; -#if JVET_Q0820_ACT co = r - b; int t = b + (co >> 1); cg = g - t; pDst0[x] = t + (cg >> 1); pDst1[x] = cg; pDst2[x] = co; -#else - pDst0[x] = (g << 1) + r + b; - pDst1[x] = (g << 1) - r - b; - pDst2[x] = ((r - b) << 1); - pDst0[x] = (pDst0[x] + 2) >> 2; - pDst1[x] = (pDst1[x] + 2) >> 2; - pDst2[x] = (pDst2[x] + 2) >> 2; -#endif } pOrg0 += strideOrg; pOrg1 += strideOrg; @@ -883,7 +866,6 @@ void UnitBuf<Pel>::colorSpaceConvert(const UnitBuf<Pel> &other, const bool forwa cg = pOrg1[x]; co = pOrg2[x]; -#if JVET_Q0820_ACT y0 = Clip3((-maxAbsclipBD - 1), maxAbsclipBD, y0); cg = Clip3((-maxAbsclipBD - 1), maxAbsclipBD, cg); co = Clip3((-maxAbsclipBD - 1), maxAbsclipBD, co); @@ -892,11 +874,6 @@ void UnitBuf<Pel>::colorSpaceConvert(const UnitBuf<Pel> &other, const bool forwa pDst0[x] = cg + t; pDst1[x] = t - (co >> 1); pDst2[x] = co + pDst1[x]; -#else - pDst0[x] = (y0 + cg); - pDst1[x] = (y0 - cg - co); - pDst2[x] = (y0 - cg + co); -#endif } pOrg0 += strideOrg; diff --git a/source/Lib/CommonLib/Buffer.h b/source/Lib/CommonLib/Buffer.h index fa72565ba5dcf5e4ebeac4fd2bfaca4d7593accc..5719f521c8aec400bad6239d3207c1717a83ef8a 100644 --- a/source/Lib/CommonLib/Buffer.h +++ b/source/Lib/CommonLib/Buffer.h @@ -110,9 +110,7 @@ struct AreaBuf : public Size void memset ( const int val ); void copyFrom ( const AreaBuf<const T> &other ); -#if JVET_Q0806 void roundToOutputBitdepth(const AreaBuf<const T> &src, const ClpRng& clpRng); -#endif void reconstruct ( const AreaBuf<const T> &pred, const AreaBuf<const T> &resi, const ClpRng& clpRng); void copyClip ( const AreaBuf<const T> &src, const ClpRng& clpRng); @@ -767,9 +765,7 @@ struct UnitBuf void fill ( const T &val ); void copyFrom ( const UnitBuf<const T> &other, const bool lumaOnly = false, const bool chromaOnly = false ); -#if JVET_Q0806 void roundToOutputBitdepth(const UnitBuf<const T> &src, const ClpRngs& clpRngs); -#endif void reconstruct ( const UnitBuf<const T> &pred, const UnitBuf<const T> &resi, const ClpRngs& clpRngs ); void copyClip ( const UnitBuf<const T> &src, const ClpRngs& clpRngs, const bool lumaOnly = false, const bool chromaOnly = false ); void subtract ( const UnitBuf<const T> &other ); @@ -785,11 +781,7 @@ struct UnitBuf UnitBuf< T> subBuf (const UnitArea& subArea); const UnitBuf<const T> subBuf (const UnitArea& subArea) const; -#if JVET_Q0820_ACT void colorSpaceConvert(const UnitBuf<T> &other, const bool forward, const ClpRng& clpRng); -#else - void colorSpaceConvert(const UnitBuf<T> &other, const bool forward); -#endif }; typedef UnitBuf< Pel> PelUnitBuf; @@ -849,7 +841,6 @@ void UnitBuf<T>::copyClip(const UnitBuf<const T> &src, const ClpRngs &clpRngs, c } -#if JVET_Q0806 template<typename T> void UnitBuf<T>::roundToOutputBitdepth(const UnitBuf<const T> &src, const ClpRngs& clpRngs) { @@ -860,7 +851,6 @@ void UnitBuf<T>::roundToOutputBitdepth(const UnitBuf<const T> &src, const ClpRng bufs[i].roundToOutputBitdepth(src.bufs[i], clpRngs.comp[i]); } } -#endif template<typename T> void UnitBuf<T>::reconstruct(const UnitBuf<const T> &pred, const UnitBuf<const T> &resi, const ClpRngs& clpRngs) @@ -903,21 +893,13 @@ void UnitBuf<T>::addAvg(const UnitBuf<const T> &other1, const UnitBuf<const T> & } template<typename T> -#if JVET_Q0820_ACT void UnitBuf<T>::colorSpaceConvert(const UnitBuf<T> &other, const bool forward, const ClpRng& clpRng) -#else -void UnitBuf<T>::colorSpaceConvert(const UnitBuf<T> &other, const bool forward) -#endif { THROW("Type not supported"); } template<> -#if JVET_Q0820_ACT void UnitBuf<Pel>::colorSpaceConvert(const UnitBuf<Pel> &other, const bool forward, const ClpRng& clpRng); -#else -void UnitBuf<Pel>::colorSpaceConvert(const UnitBuf<Pel> &other, const bool forward); -#endif template<typename T> void UnitBuf<T>::extendSingleBorderPel() diff --git a/source/Lib/CommonLib/CodingStatistics.h b/source/Lib/CommonLib/CodingStatistics.h index 7c0ad7af7ecca5b2bb650e9045a49bdbe4acd933..1dac08f648ac76f7bbfd9af9ca7fe6582661cb59 100644 --- a/source/Lib/CommonLib/CodingStatistics.h +++ b/source/Lib/CommonLib/CodingStatistics.h @@ -112,19 +112,12 @@ enum CodingStatisticsType STATS__CABAC_BITS__BCW_IDX, STATS__CABAC_BITS__SBT_MODE, STATS__CABAC_BITS__MH_INTRA_FLAG, -#if !JVET_Q0806 - STATS__CABAC_BITS__TRIANGLE_FLAG, - STATS__CABAC_BITS__TRIANGLE_INDEX, -#else STATS__CABAC_BITS__GEO_FLAG, STATS__CABAC_BITS__GEO_INDEX, -#endif STATS__CABAC_BITS__MULTI_REF_LINE, STATS__CABAC_BITS__SYMMVD_FLAG, STATS__CABAC_BITS__BDPCM_MODE, -#if JVET_Q0795_CCALF STATS__CABAC_BITS__CROSS_COMPONENT_ALF_BLOCK_LEVEL_IDC, -#endif STATS__TOOL_TOTAL_FRAME,// This is a special case and is not included in the report. STATS__TOOL_AFF, STATS__TOOL_EMT, @@ -212,19 +205,12 @@ static inline const char* getName(CodingStatisticsType name) "CABAC_BITS__BCW_IDX", "CABAC_BITS__SBT_MODE", "CABAC_BITS__MH_INTRA_FLAG", -#if !JVET_Q0806 - "CABAC_BITS__TRIANGLE_FLAG", - "CABAC_BITS__TRIANGLE_INDEX", -#else "CABAC_BITS__GEO_FLAG", "CABAC_BITS__GEO_INDEX", -#endif "CABAC_BITS__MULTI_REF_LINE", "CABAC_BITS__SYMMVD_FLAG", "CABAC_BITS__BDPCM_MODE", -#if JVET_Q0795_CCALF "CABAC_BITS__CROSS_COMPONENT_ALF_BLOCK_LEVEL_IDC", -#endif "TOOL_FRAME", "TOOL_AFFINE", "TOOL_EMT", diff --git a/source/Lib/CommonLib/CodingStructure.cpp b/source/Lib/CommonLib/CodingStructure.cpp index adbec8ed09fddb2f5ea4241cf9c9a2aae5312b49..29a7f787f4666b8e7108224d07563fe9c53922ac 100644 --- a/source/Lib/CommonLib/CodingStructure.cpp +++ b/source/Lib/CommonLib/CodingStructure.cpp @@ -665,7 +665,7 @@ void CodingStructure::addEmptyTUs( Partitioner &partitioner ) if( split ) { - partitioner.splitCurrArea( TU_MAX_TR_SPLIT, *this ); + partitioner.splitCurrArea( TU_MAX_TR_SPLIT, *this ); do { addEmptyTUs( partitioner ); @@ -900,9 +900,7 @@ void CodingStructure::reorderPrevPLT(PLTBuf& prevPLT, uint8_t curPLTSize[MAX_NUM uint8_t tempCurPLTsize[MAX_NUM_CHANNEL_TYPE]; uint8_t stuffPLTsize[MAX_NUM_COMPONENT]; -#if JVET_Q0291_REDUCE_DUALTREE_PLT_SIZE uint32_t maxPredPltSize = jointPLT ? MAXPLTPREDSIZE : MAXPLTPREDSIZE_DUALTREE; -#endif for (int i = compBegin; i < (compBegin + numComp); i++) { @@ -918,11 +916,7 @@ void CodingStructure::reorderPrevPLT(PLTBuf& prevPLT, uint8_t curPLTSize[MAX_NUM if (ch > 1) break; for (int i = 0; i < prevPLT.curPLTSize[comID]; i++) { -#if JVET_Q0291_REDUCE_DUALTREE_PLT_SIZE if (tempCurPLTsize[comID] + stuffPLTsize[ch] >= maxPredPltSize) -#else - if (tempCurPLTsize[comID] + stuffPLTsize[ch] >= MAXPLTPREDSIZE) -#endif break; if (!reuseflag[comID][i]) @@ -946,13 +940,10 @@ void CodingStructure::reorderPrevPLT(PLTBuf& prevPLT, uint8_t curPLTSize[MAX_NUM ComponentID comID = jointPLT ? (ComponentID)compBegin : ((i > 0) ? COMPONENT_Cb : COMPONENT_Y); prevPLT.curPLTSize[comID] = curPLTSize[comID] + stuffPLTsize[comID]; memcpy(prevPLT.curPLT[i], stuffedPLT[i], prevPLT.curPLTSize[comID] * sizeof(Pel)); -#if JVET_Q0291_REDUCE_DUALTREE_PLT_SIZE CHECK(prevPLT.curPLTSize[comID] > maxPredPltSize, " Maximum palette predictor size exceed limit"); -#endif } } -#if JVET_Q0501_PALETTE_WPP_INIT_ABOVECTU void CodingStructure::setPrevPLT(PLTBuf predictor) { for (int comp = 0; comp < MAX_NUM_CHANNEL_TYPE; comp++) @@ -975,7 +966,6 @@ void CodingStructure::storePrevPLT(PLTBuf& predictor) memcpy(predictor.curPLT[comp], prevPLT.curPLT[comp], MAXPLTPREDSIZE * sizeof(Pel)); } } -#endif void CodingStructure::rebindPicBufs() { @@ -1008,11 +998,7 @@ void CodingStructure::createCoeffs(const bool isPLTused) if (isPLTused) { -#if JVET_Q0438_MONOCHROME_BUGFIXES for (unsigned i = 0; i < (isChromaEnabled(area.chromaFormat) ? 2 : 1); i++) -#else - for (unsigned i = 0; i < numCh - 1; i++) -#endif { unsigned _area = area.blocks[i].area(); @@ -1110,7 +1096,7 @@ void CodingStructure::initSubStructure( CodingStructure& subStruct, const Channe } } -void CodingStructure::useSubStructure( const CodingStructure& subStruct, const ChannelType chType, const UnitArea &subArea, const bool cpyPred /*= true*/, const bool cpyReco /*= true*/, const bool cpyOrgResi /*= true*/, const bool cpyResi /*= true*/ ) +void CodingStructure::useSubStructure( const CodingStructure& subStruct, const ChannelType chType, const UnitArea &subArea, const bool cpyPred /*= true*/, const bool cpyReco /*= true*/, const bool cpyOrgResi /*= true*/, const bool cpyResi /*= true*/, const bool updateCost /*= true*/ ) { UnitArea clippedArea = clipArea( subArea, *picture ); @@ -1146,10 +1132,13 @@ void CodingStructure::useSubStructure( const CodingStructure& subStruct, const C prevPLT = subStruct.prevPLT; - fracBits += subStruct.fracBits; - dist += subStruct.dist; - cost += subStruct.cost; - costDbOffset += subStruct.costDbOffset; + if ( updateCost ) + { + fracBits += subStruct.fracBits; + dist += subStruct.dist; + cost += subStruct.cost; + costDbOffset += subStruct.costDbOffset; + } if( parent ) { // allow this to be false at the top level @@ -1569,11 +1558,7 @@ const CodingUnit* CodingStructure::getCURestricted( const Position &pos, const C const CodingUnit* cu = getCU( pos, _chType ); // exists same slice and tile cu precedes curCu in encoding order // (thus, is either from parent CS in RD-search or its index is lower) -#if JVET_Q0151_Q0205_ENTRYPOINTS const bool wavefrontsEnabled = curCu.slice->getSPS()->getEntropyCodingSyncEnabledFlag(); -#else - const bool wavefrontsEnabled = curCu.slice->getPPS()->getEntropyCodingSyncEnabledFlag(); -#endif int ctuSizeBit = floorLog2(curCu.cs->sps->getMaxCUWidth()); int xNbY = pos.x << getChannelTypeScaleX( _chType, curCu.chromaFormat ); int xCurr = curCu.blocks[_chType].x << getChannelTypeScaleX( _chType, curCu.chromaFormat ); @@ -1591,11 +1576,7 @@ const CodingUnit* CodingStructure::getCURestricted( const Position &pos, const C const CodingUnit* CodingStructure::getCURestricted( const Position &pos, const Position curPos, const unsigned curSliceIdx, const unsigned curTileIdx, const ChannelType _chType ) const { const CodingUnit* cu = getCU( pos, _chType ); -#if JVET_Q0151_Q0205_ENTRYPOINTS const bool wavefrontsEnabled = this->slice->getSPS()->getEntropyCodingSyncEnabledFlag(); -#else - const bool wavefrontsEnabled = this->slice->getPPS()->getEntropyCodingSyncEnabledFlag(); -#endif int ctuSizeBit = floorLog2(this->sps->getMaxCUWidth()); int xNbY = pos.x << getChannelTypeScaleX( _chType, this->area.chromaFormat ); int xCurr = curPos.x << getChannelTypeScaleX( _chType, this->area.chromaFormat ); @@ -1608,11 +1589,7 @@ const PredictionUnit* CodingStructure::getPURestricted( const Position &pos, con const PredictionUnit* pu = getPU( pos, _chType ); // exists same slice and tile pu precedes curPu in encoding order // (thus, is either from parent CS in RD-search or its index is lower) -#if JVET_Q0151_Q0205_ENTRYPOINTS const bool wavefrontsEnabled = curPu.cu->slice->getSPS()->getEntropyCodingSyncEnabledFlag(); -#else - const bool wavefrontsEnabled = curPu.cu->slice->getPPS()->getEntropyCodingSyncEnabledFlag(); -#endif int ctuSizeBit = floorLog2(curPu.cs->sps->getMaxCUWidth()); int xNbY = pos.x << getChannelTypeScaleX( _chType, curPu.chromaFormat ); int xCurr = curPu.blocks[_chType].x << getChannelTypeScaleX( _chType, curPu.chromaFormat ); @@ -1632,11 +1609,7 @@ const TransformUnit* CodingStructure::getTURestricted( const Position &pos, cons const TransformUnit* tu = getTU( pos, _chType ); // exists same slice and tile tu precedes curTu in encoding order // (thus, is either from parent CS in RD-search or its index is lower) -#if JVET_Q0151_Q0205_ENTRYPOINTS const bool wavefrontsEnabled = curTu.cu->slice->getSPS()->getEntropyCodingSyncEnabledFlag(); -#else - const bool wavefrontsEnabled = curTu.cu->slice->getPPS()->getEntropyCodingSyncEnabledFlag(); -#endif int ctuSizeBit = floorLog2(curTu.cs->sps->getMaxCUWidth()); int xNbY = pos.x << getChannelTypeScaleX( _chType, curTu.chromaFormat ); int xCurr = curTu.blocks[_chType].x << getChannelTypeScaleX( _chType, curTu.chromaFormat ); diff --git a/source/Lib/CommonLib/CodingStructure.h b/source/Lib/CommonLib/CodingStructure.h index 1b2f9796635947b3e29fd5928add8ecb14146ce5..e7e71bc35f679d62889f21079063d7d8c49e5248 100644 --- a/source/Lib/CommonLib/CodingStructure.h +++ b/source/Lib/CommonLib/CodingStructure.h @@ -172,8 +172,8 @@ public: void initSubStructure( CodingStructure& cs, const ChannelType chType, const UnitArea &subArea, const bool &isTuEnc); void copyStructure (const CodingStructure& cs, const ChannelType chType, const bool copyTUs = false, const bool copyRecoBuffer = false); - void useSubStructure (const CodingStructure& cs, const ChannelType chType, const UnitArea &subArea, const bool cpyPred, const bool cpyReco, const bool cpyOrgResi, const bool cpyResi); - void useSubStructure (const CodingStructure& cs, const ChannelType chType, const bool cpyPred, const bool cpyReco, const bool cpyOrgResi, const bool cpyResi) { useSubStructure(cs, chType, cs.area, cpyPred, cpyReco, cpyOrgResi, cpyResi); } + void useSubStructure (const CodingStructure& cs, const ChannelType chType, const UnitArea &subArea, const bool cpyPred, const bool cpyReco, const bool cpyOrgResi, const bool cpyResi, const bool updateCost); + void useSubStructure (const CodingStructure& cs, const ChannelType chType, const bool cpyPred, const bool cpyReco, const bool cpyOrgResi, const bool cpyResi, const bool updateCost) { useSubStructure(cs, chType, cs.area, cpyPred, cpyReco, cpyOrgResi, cpyResi, updateCost); } void clearTUs(); void clearPUs(); @@ -203,10 +203,8 @@ public: PLTBuf prevPLT; void resetPrevPLT(PLTBuf& prevPLT); void reorderPrevPLT(PLTBuf& prevPLT, uint8_t curPLTSize[MAX_NUM_CHANNEL_TYPE], Pel curPLT[MAX_NUM_COMPONENT][MAXPLTSIZE], bool reuseflag[MAX_NUM_CHANNEL_TYPE][MAXPLTPREDSIZE], uint32_t compBegin, uint32_t numComp, bool jointPLT); -#if JVET_Q0501_PALETTE_WPP_INIT_ABOVECTU void setPrevPLT(PLTBuf predictor); void storePrevPLT(PLTBuf& predictor); -#endif private: // needed for TU encoding diff --git a/source/Lib/CommonLib/CommonDef.h b/source/Lib/CommonLib/CommonDef.h index 13997bbf055faa55fb887662e83358a009bd1c49..2fa1f4a5e5cef1c0495d936af19f835e8037dfd1 100644 --- a/source/Lib/CommonLib/CommonDef.h +++ b/source/Lib/CommonLib/CommonDef.h @@ -187,12 +187,10 @@ static const int MAX_NUM_ALF_CHROMA_COEFF = 7; static const int MAX_ALF_FILTER_LENGTH = 7; static const int MAX_NUM_ALF_COEFF = MAX_ALF_FILTER_LENGTH * MAX_ALF_FILTER_LENGTH / 2 + 1; static const int MAX_ALF_PADDING_SIZE = 4; -#if JVET_Q0795_CCALF #define MAX_NUM_CC_ALF_FILTERS 4 static constexpr int MAX_NUM_CC_ALF_CHROMA_COEFF = 8; static constexpr int CCALF_DYNAMIC_RANGE = 6; static constexpr int CCALF_BITS_PER_COEFF_LEVEL = 3; -#endif static const int ALF_FIXED_FILTER_NUM = 64; static const int ALF_CTB_MAX_NUM_APS = 8; @@ -287,7 +285,7 @@ static const int LUMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS_SIGNAL = 1 << MV static const int LUMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS = 1 << MV_FRACTIONAL_BITS_INTERNAL; static const int CHROMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS = 1 << (MV_FRACTIONAL_BITS_INTERNAL + 1); -static const int MAX_NUM_SUB_PICS = 255; +static const int MAX_NUM_SUB_PICS = (1 << 16); static const int MAX_NUM_LONG_TERM_REF_PICS = 33; static const int NUM_LONG_TERM_REF_PIC_SPS = 0; @@ -383,24 +381,10 @@ static const int DMVR_NUM_ITERATION = 2; //QTBT high level parameters //for I slice luma CTB configuration para. static const int MAX_BT_DEPTH = 4; ///< <=7 -#if !JVET_Q0330_BLOCK_PARTITION -static const int MAX_BT_SIZE = 32; ///< [1<<MIN_QT_SIZE, 1<<CTU_LOG2] - -static const int MAX_TT_SIZE = 32; ///< [1<<MIN_QT_SIZE, 1<<CTU_LOG2] -static const int MAX_TT_SIZE_C = 32; ///< [1<<MIN_QT_SIZE, 1<<CTU_LOG2] -#endif //for P/B slice CTU config. para. static const int MAX_BT_DEPTH_INTER = 4; ///< <=7 -#if !JVET_Q0330_BLOCK_PARTITION -static const int MAX_BT_SIZE_INTER = 128; ///< for initialization, [1<<MIN_BT_SIZE_INTER, 1<<CTU_LOG2] -#endif //for I slice chroma CTB configuration para. (in luma samples) static const int MAX_BT_DEPTH_C = 0; ///< <=7 -#if !JVET_Q0330_BLOCK_PARTITION -static const int MAX_BT_SIZE_C = 64; ///< [1<<MIN_QT_SIZE_C, 1<<CTU_LOG2], in luma samples - -static const int MAX_TT_SIZE_INTER = 64; ///< for initialization, [1<<MIN_CU_LOG2, 64] -#endif static const int MIN_DUALTREE_CHROMA_WIDTH = 4; static const int MIN_DUALTREE_CHROMA_SIZE = 16; static const SplitSeries SPLIT_BITS = 5; @@ -434,13 +418,6 @@ static const int MAX_LADF_INTERVALS = 5; /// max n static const int NTAPS_BILINEAR = 2; ///< Number of taps for bilinear filter static const int ATMVP_SUB_BLOCK_SIZE = 3; ///< sub-block size for ATMVP -#if !JVET_Q0806 -static const int TRIANGLE_MAX_NUM_UNI_CANDS = 6; -static const int TRIANGLE_MAX_NUM_CANDS_MEM = 7; -static const int TRIANGLE_MAX_NUM_CANDS = TRIANGLE_MAX_NUM_UNI_CANDS * (TRIANGLE_MAX_NUM_UNI_CANDS - 1) * 2; -static const int TRIANGLE_MAX_NUM_SATD_CANDS = 3; -static const int TRIANGLE_MIN_SIZE = 8 * 8; -#else static const int GEO_MAX_NUM_UNI_CANDS = 6; static const int GEO_MAX_NUM_CANDS = GEO_MAX_NUM_UNI_CANDS * (GEO_MAX_NUM_UNI_CANDS - 1); static const int GEO_MIN_CU_LOG2 = 3; @@ -456,7 +433,6 @@ static const int GEO_WEIGHT_MASK_SIZE = 3 * (GEO_MAX_CU_SIZE >> 3) * 2 + GEO_MAX static const int GEO_MV_MASK_SIZE = GEO_WEIGHT_MASK_SIZE >> 2; static const int GEO_MAX_TRY_WEIGHTED_SAD = 60; static const int GEO_MAX_TRY_WEIGHTED_SATD = 8; -#endif static const int SBT_MAX_SIZE = 64; ///< maximum CU size for using SBT static const int SBT_NUM_SL = 10; ///< maximum number of historical PU decision saved for a CU @@ -500,10 +476,8 @@ static const int NUM_TRELLIS_STATE = 3; static const double ENC_CHROMA_WEIGHTING = 0.8; static const int MAXPLTPREDSIZE = 63; static const int MAXPLTSIZE = 31; -#if JVET_Q0291_REDUCE_DUALTREE_PLT_SIZE static const int MAXPLTPREDSIZE_DUALTREE = 31; static const int MAXPLTSIZE_DUALTREE = 15; -#endif static const double PLT_CHROMA_WEIGHTING = 0.8; static const int PLT_ENCBITDEPTH = 8; static const int PLT_FAST_RATIO = 100; @@ -514,12 +488,7 @@ static const int ENC_PPS_ID_RPR = 3; static const int SCALE_RATIO_BITS = 14; static const int MAX_SCALING_RATIO = 2; // max downsampling ratio for RPR static const std::pair<int, int> SCALE_1X = std::pair<int, int>( 1 << SCALE_RATIO_BITS, 1 << SCALE_RATIO_BITS ); // scale ratio 1x -#if JVET_Q0820_ACT static const int DELTA_QP_ACT[4] = { -5, 1, 3, 1 }; -#else -static const int DELTA_QP_FOR_Y_Cg = -5; -static const int DELTA_QP_FOR_Co = -3; -#endif // ==================================================================================================================== // Macro functions @@ -739,10 +708,8 @@ static inline int ceilLog2(uint32_t x) #define PARL_PARAM0(DEF) #endif -#if JVET_Q0795_CCALF static const uint32_t CCALF_CANDS_COEFF_NR = 8; static const int CCALF_SMALL_TAB[CCALF_CANDS_COEFF_NR] = { 0, 1, 2, 4, 8, 16, 32, 64 }; -#endif //! \} diff --git a/source/Lib/CommonLib/ContextModelling.cpp b/source/Lib/CommonLib/ContextModelling.cpp index 6913c4d54f3075d930bc7a96a4922abc5a106e12..56562db081ac84639bbd339686f3edd932b4b099 100644 --- a/source/Lib/CommonLib/ContextModelling.cpp +++ b/source/Lib/CommonLib/ContextModelling.cpp @@ -320,19 +320,11 @@ unsigned DeriveCtx::CtxIBCFlag(const CodingUnit& cu) void MergeCtx::setMergeInfo( PredictionUnit& pu, int candIdx ) { CHECK( candIdx >= numValidMergeCand, "Merge candidate does not exist" ); -#if !JVET_Q0806 - pu.regularMergeFlag = !(pu.ciipFlag || pu.cu->triangle); -#else pu.regularMergeFlag = !(pu.ciipFlag || pu.cu->geoFlag); -#endif pu.mergeFlag = true; pu.mmvdMergeFlag = false; pu.interDir = interDirNeighbours[candIdx]; -#if !JVET_Q0806 - pu.cu->imv = (!pu.cu->triangle && useAltHpelIf[candIdx]) ? IMV_HPEL : 0; -#else pu.cu->imv = (!pu.cu->geoFlag && useAltHpelIf[candIdx]) ? IMV_HPEL : 0; -#endif pu.mergeIdx = candIdx; pu.mergeType = mrgTypeNeighbours[candIdx]; pu.mv [REF_PIC_LIST_0] = mvFieldNeighbours[(candIdx << 1) + 0].mv; @@ -555,7 +547,7 @@ unsigned DeriveCtx::CtxPltCopyFlag( const unsigned prevRunType, const unsigned d return ucCtxLut[dist]; } else - { + { return ucCtxLut[RUN_IDX_THRE]; } } diff --git a/source/Lib/CommonLib/ContextModelling.h b/source/Lib/CommonLib/ContextModelling.h index fa51ac28709c5bbf965a9024ae9c4fe63bd2dad1..b06839a3b40c685c0c86d6d845c75349129488a4 100644 --- a/source/Lib/CommonLib/ContextModelling.h +++ b/source/Lib/CommonLib/ContextModelling.h @@ -298,7 +298,7 @@ public: int deriveModCoeff(int rightPixel, int belowPixel, int absCoeff, int bdpcm = 0) { - + if (absCoeff == 0) return 0; int pred1, absBelow = abs(belowPixel), absRight = abs(rightPixel); @@ -324,7 +324,7 @@ public: int decDeriveModCoeff(int rightPixel, int belowPixel, int absCoeff) { - + if (absCoeff == 0) return 0; @@ -416,9 +416,7 @@ public: violatesLfnstConstrained[CHANNEL_TYPE_CHROMA] = false; lfnstLastScanPos = false; violatesMtsCoeffConstraint = false; -#if JVET_Q0516_MTS_SIGNALLING_DC_ONLY_COND mtsLastScanPos = false; -#endif } CUCtx(int _qp) : isDQPCoded(false), isChromaQpAdjCoded(false), qgStart(false), @@ -428,9 +426,7 @@ public: violatesLfnstConstrained[CHANNEL_TYPE_CHROMA] = false; lfnstLastScanPos = false; violatesMtsCoeffConstraint = false; -#if JVET_Q0516_MTS_SIGNALLING_DC_ONLY_COND mtsLastScanPos = false; -#endif } ~CUCtx() {} public: @@ -441,9 +437,7 @@ public: int8_t qp; // used as a previous(last) QP and for QP prediction bool violatesLfnstConstrained[MAX_NUM_CHANNEL_TYPE]; bool violatesMtsCoeffConstraint; -#if JVET_Q0516_MTS_SIGNALLING_DC_ONLY_COND bool mtsLastScanPos; -#endif }; class MergeCtx diff --git a/source/Lib/CommonLib/Contexts.cpp b/source/Lib/CommonLib/Contexts.cpp index 35ecc410b4fbba97d7b9156479ac8126e5e4a654..283e83855c65fa9dc53f49b39c269b1b2a5d5794 100644 --- a/source/Lib/CommonLib/Contexts.cpp +++ b/source/Lib/CommonLib/Contexts.cpp @@ -185,7 +185,6 @@ CtxSet ContextSetCfg::addCtxSet( std::initializer_list<std::initializer_list<uin std::vector<std::vector<uint8_t>> ContextSetCfg::sm_InitTables(NUMBER_OF_SLICE_TYPES + 1); // clang-format off -#if CABAC_RETRAIN const CtxSet ContextSetCfg::SplitFlag = ContextSetCfg::addCtxSet ({ { 18, 27, 15, 18, 28, 45, 19, 7, 23, }, @@ -420,17 +419,10 @@ const CtxSet ContextSetCfg::Mvd = ContextSetCfg::addCtxSet const CtxSet ContextSetCfg::BDPCMMode = ContextSetCfg::addCtxSet ({ -#if JVET_Q0110_Q0785_CHROMA_BDPCM_420 { 19, 21, 0, 28, }, { 40, 36, 0, 28, }, { 19, 35, 1, 35, }, { 4, 4, 1, 0, }, -#else - { 19, 28, }, - { 40, 36, }, - { 19, 35, }, - { 4, 4, }, -#endif }); const CtxSet ContextSetCfg::QtRootCbf = ContextSetCfg::addCtxSet @@ -832,7 +824,6 @@ const CtxSet ContextSetCfg::AlfUseTemporalFilt = ContextSetCfg::addCtxSet { 0, }, }); -#if JVET_Q0795_CCALF const CtxSet ContextSetCfg::CcAlfFilterControlFlag = ContextSetCfg::addCtxSet ({ { 25, 35, 37, 25, 28, 37, }, @@ -840,7 +831,6 @@ const CtxSet ContextSetCfg::CcAlfFilterControlFlag = ContextSetCfg::addCtxSet { 18, 29, 38, 18, 29, 38, }, { 4, 4, 4, 4, 2, 4, }, }); -#endif const CtxSet ContextSetCfg::CiipFlag = ContextSetCfg::addCtxSet ({ @@ -913,736 +903,6 @@ const CtxSet ContextSetCfg::TsResidualSign = ContextSetCfg::addCtxSet { 20, 17, 46, 28, 25, 46, }, { 1, 4, 4, 8, 8, 8, }, }); -#else -const CtxSet ContextSetCfg::SplitFlag = ContextSetCfg::addCtxSet -({ - { 18, 27, 15, 18, 28, 30, 19, 7, 23, }, - { 11, 35, 53, 12, 6, 30, 13, 15, 31, }, - { 19, 28, 38, 27, 29, 38, 28, 38, 31, }, - { 12, 13, 8, 8, 13, 12, 5, 9, 9, }, -}); - -const CtxSet ContextSetCfg::SplitQtFlag = ContextSetCfg::addCtxSet -({ - { 26, 36, 38, 33, 34, 21, }, - { 20, 14, 23, 18, 19, 6, }, - { 27, 6, 15, 25, 19, 22, }, - { 0, 8, 8, 12, 12, 9, }, -}); - -const CtxSet ContextSetCfg::SplitHvFlag = ContextSetCfg::addCtxSet -({ - { 43, 42, 37, 35, 44, }, - { 36, 35, 37, 27, 52, }, - { 43, 42, 29, 27, 44, }, - { 9, 8, 9, 8, 8, }, -}); - -const CtxSet ContextSetCfg::Split12Flag = ContextSetCfg::addCtxSet -({ - { 28, 29, 28, 29, }, - { 43, 37, 21, 22, }, - { 51, 45, 36, 45, }, - { 12, 13, 12, 13, }, -}); - -const CtxSet ContextSetCfg::ModeConsFlag = ContextSetCfg::addCtxSet -({ - { 25, 20, }, - { 25, 12, }, - { CNU, CNU, }, - { 1, 0, }, -}); - -const CtxSet ContextSetCfg::SkipFlag = ContextSetCfg::addCtxSet -({ - { 57, 60, 53, }, - { 57, 59, 45, }, - { 0, 26, 28, }, - { 5, 4, 8, }, -}); - -const CtxSet ContextSetCfg::MergeFlag = ContextSetCfg::addCtxSet -({ - { 6, }, - { 6, }, - { 26, }, - { 4, }, -}); - -const CtxSet ContextSetCfg::RegularMergeFlag = ContextSetCfg::addCtxSet -({ - { 46, 15, }, - { 38, 7, }, - { CNU, CNU, }, - { 5, 5, }, -}); - -const CtxSet ContextSetCfg::MergeIdx = ContextSetCfg::addCtxSet -({ - { 33, }, - { 35, }, - { 34, }, - { 4, }, -}); - -const CtxSet ContextSetCfg::MmvdFlag = ContextSetCfg::addCtxSet -({ - { 40, }, - { 26, }, - { CNU, }, - { 4, }, -}); - -const CtxSet ContextSetCfg::MmvdMergeIdx = ContextSetCfg::addCtxSet -({ - { 43, }, - { 43, }, - { CNU, }, - { 10, }, -}); - -const CtxSet ContextSetCfg::MmvdStepMvpIdx = ContextSetCfg::addCtxSet -({ - { 51, }, - { 60, }, - { CNU, }, - { 0, }, -}); - -const CtxSet ContextSetCfg::PredMode = ContextSetCfg::addCtxSet -({ - { 40, 35, }, - { 40, 35, }, - { CNU, CNU, }, - { 5, 1, }, -}); - -const CtxSet ContextSetCfg::MultiRefLineIdx = ContextSetCfg::addCtxSet -({ - { 25, 58, }, - { 25, 50, }, - { 25, 59, }, - { 6, 8, }, -}); - -const CtxSet ContextSetCfg::IntraLumaMpmFlag = ContextSetCfg::addCtxSet -({ - { 29, }, - { 36, }, - { 45, }, - { 6, }, -}); - -const CtxSet ContextSetCfg::IntraLumaPlanarFlag = ContextSetCfg::addCtxSet -({ - { 13, 6, }, - { 12, 20, }, - { 13, 28, }, - { 1, 5, }, -}); - -const CtxSet ContextSetCfg::CclmModeFlag = ContextSetCfg::addCtxSet -({ - { 26, }, - { 34, }, - { 59, }, - { 4, }, -}); - -const CtxSet ContextSetCfg::CclmModeIdx = ContextSetCfg::addCtxSet -({ - { 27, }, - { 27, }, - { 27, }, - { 9, }, -}); - -const CtxSet ContextSetCfg::IntraChromaPredMode = ContextSetCfg::addCtxSet -({ - { 25, }, - { 18, }, - { 34, }, - { 5, }, -}); - -const CtxSet ContextSetCfg::MipFlag = ContextSetCfg::addCtxSet -({ - { 56, 57, 50, 26, }, - { 41, 57, 58, 26, }, - { 33, 49, 42, 25, }, - { 9, 10, 9, 6, }, -}); - -const CtxSet ContextSetCfg::DeltaQP = ContextSetCfg::addCtxSet -({ - { CNU, CNU, }, - { CNU, CNU, }, - { CNU, CNU, }, - { DWS, DWS, }, -}); - -const CtxSet ContextSetCfg::InterDir = ContextSetCfg::addCtxSet -({ - { 14, 6, 5, 4, 3, 40, }, - { 7, 6, 5, 4, 11, 40, }, - { CNU, CNU, CNU, CNU, CNU, CNU, }, - { 0, 0, 1, 4, 1, 0, }, -}); - -const CtxSet ContextSetCfg::RefPic = ContextSetCfg::addCtxSet -({ - { 20, 20, }, - { 27, 35, }, - { CNU, CNU, }, - { 0, 4, }, -}); - -const CtxSet ContextSetCfg::SubblockMergeFlag = ContextSetCfg::addCtxSet -({ - { 40, 51, 45, }, - { 48, 57, 44, }, - { CNU, CNU, CNU, }, - { 4, 4, 4, }, -}); - -const CtxSet ContextSetCfg::AffineFlag = ContextSetCfg::addCtxSet -({ - { 12, 13, 6, }, - { 12, 13, 6, }, - { CNU, CNU, CNU, }, - { 4, 0, 0, }, -}); - -const CtxSet ContextSetCfg::AffineType = ContextSetCfg::addCtxSet -({ - { 35, }, - { 35, }, - { CNU, }, - { 4, }, -}); - -const CtxSet ContextSetCfg::AffMergeIdx = ContextSetCfg::addCtxSet -({ - { 4, }, - { 5, }, - { CNU, }, - { 0, }, -}); - -const CtxSet ContextSetCfg::BcwIdx = ContextSetCfg::addCtxSet -({ - { 5, }, - { 4, }, - { CNU, }, - { 0, }, -}); - -const CtxSet ContextSetCfg::Mvd = ContextSetCfg::addCtxSet -({ - { 51, 58, }, - { 44, 43, }, - { 14, 45, }, - { 9, 5, }, -}); - -const CtxSet ContextSetCfg::BDPCMMode = ContextSetCfg::addCtxSet -({ -#if JVET_Q0110_Q0785_CHROMA_BDPCM_420 - { 19, 28, 25, 51, }, - { 40, 36, 17, 28, }, - { 19, 35, 9, 44, }, - { 4, 4, 1, 1, }, -#else - { 19, 28, }, - { 40, 36, }, - { 19, 35, }, - { 4, 4, }, -#endif -}); - -const CtxSet ContextSetCfg::QtRootCbf = ContextSetCfg::addCtxSet -({ - { 12, }, - { 5, }, - { 6, }, - { 4, }, -}); - -const CtxSet ContextSetCfg::ACTFlag = ContextSetCfg::addCtxSet -({ - { CNU, }, - { CNU, }, - { CNU, }, - { DWS, }, - }); - -const CtxSet ContextSetCfg::QtCbf[] = -{ - ContextSetCfg::addCtxSet - ({ - { 15, 13, 5, 14, }, - { 23, 4, 20, 7, }, - { 7, 19, 5, 7, }, - { 5, 1, 8, 9, }, - }), - ContextSetCfg::addCtxSet - ({ - { 25, CNU, }, - { 25, CNU, }, - { 4, CNU, }, - { 5, DWS, }, - }), - ContextSetCfg::addCtxSet - ({ - { 9, 44, CNU, }, - { 25, 29, CNU, }, - { 33, 28, CNU, }, - { 2, 1, DWS, }, - }) -}; - -const CtxSet ContextSetCfg::SigCoeffGroup[] = -{ - ContextSetCfg::addCtxSet - ({ - { 25, 45, }, - { 25, 30, }, - { 18, 31, }, - { 8, 5, }, - }), - ContextSetCfg::addCtxSet - ({ - { 25, 45, }, - { 25, 52, }, - { 25, 7, }, - { 5, 8, }, - }) -}; - -const CtxSet ContextSetCfg::SigFlag[] = -{ - ContextSetCfg::addCtxSet - ({ - { 17, 41, 49, 36, 1, 49, 50, 37, 48, 51, 58, 45, }, - { 17, 41, 42, 29, 25, 49, 43, 37, 33, 51, 51, 30, }, - { 25, 19, 28, 14, 25, 20, 29, 30, 19, 37, 30, 38, }, - { 12, 9, 9, 10, 9, 9, 9, 10, 8, 8, 8, 10, }, - }), - ContextSetCfg::addCtxSet - ({ - { 9, 49, 42, 21, 48, 59, 59, 53, }, - { 17, 19, 20, 29, 41, 59, 60, 38, }, - { 25, 27, 28, 37, 49, 53, 53, 46, }, - { 9, 9, 9, 13, 4, 5, 8, 9, }, - }), - ContextSetCfg::addCtxSet - ({ - { 26, 45, 53, 46, 49, 54, 61, 39, 42, 39, 39, 39, }, - { 19, 38, 38, 46, 34, 54, 54, 39, 6, 39, 39, 39, }, - { 11, 38, 46, 54, 27, 39, 39, 39, 36, 39, 39, 39, }, - { 9, 13, 8, 8, 8, 8, 8, 5, 8, 0, 0, 0, }, - }), - ContextSetCfg::addCtxSet - ({ - { 34, 45, 38, 31, 58, 39, 39, 39, }, - { 35, 45, 53, 54, 44, 39, 39, 39, }, - { 19, 46, 38, 39, 52, 39, 39, 39, }, - { 8, 12, 8, 8, 4, 0, 0, 0, }, - }), - ContextSetCfg::addCtxSet - ({ - { 19, 54, 39, 39, 50, 39, 39, 39, 0, 39, 39, 39, }, - { 19, 39, 54, 39, 19, 39, 39, 39, 56, 39, 39, 39, }, - { 18, 39, 39, 39, 19, 39, 39, 39, 0, 39, 39, 39, }, - { 8, 8, 8, 8, 8, 0, 4, 4, 0, 0, 0, 0, }, - }), - ContextSetCfg::addCtxSet - ({ - { 34, 38, 54, 39, 41, 39, 39, 39, }, - { 34, 38, 62, 39, 26, 39, 39, 39, }, - { 26, 39, 39, 39, 19, 39, 39, 39, }, - { 8, 8, 8, 8, 4, 0, 0, 0, }, - }) -}; - -const CtxSet ContextSetCfg::ParFlag[] = -{ - ContextSetCfg::addCtxSet - ({ - { 33, 40, 25, 41, 26, 42, 25, 33, 26, 34, 27, 25, 41, 42, 42, 35, 33, 27, 35, 42, 43, }, - { 18, 17, 33, 18, 34, 42, 25, 33, 26, 42, 27, 25, 34, 42, 42, 35, 26, 27, 42, 20, 20, }, - { 33, 25, 18, 26, 34, 27, 25, 26, 19, 42, 35, 33, 19, 27, 35, 35, 34, 42, 20, 43, 20, }, - { 8, 9, 12, 13, 13, 13, 10, 13, 13, 13, 13, 13, 13, 13, 13, 13, 10, 13, 13, 13, 13, }, - }), - ContextSetCfg::addCtxSet - ({ - { 33, 25, 26, 19, 19, 27, 33, 42, 43, 35, 43, }, - { 25, 25, 26, 11, 19, 27, 33, 42, 50, 20, 43, }, - { 33, 25, 26, 42, 19, 27, 26, 50, 35, 20, 43, }, - { 9, 13, 12, 12, 13, 13, 13, 13, 13, 13, 13, }, - }) -}; - -const CtxSet ContextSetCfg::GtxFlag[] = -{ - ContextSetCfg::addCtxSet - ({ - { 25, 0, 0, 17, 25, 18, 0, 9, 25, 33, 19, 0, 25, 33, 26, 20, 25, 33, 34, 35, 29, }, - { 17, 0, 1, 17, 25, 18, 0, 9, 25, 33, 34, 9, 25, 18, 26, 20, 25, 18, 19, 27, 21, }, - { 25, 1, 40, 25, 33, 11, 17, 25, 25, 18, 4, 17, 33, 26, 19, 5, 33, 19, 20, 28, 22, }, - { 1, 5, 9, 9, 9, 6, 5, 9, 10, 10, 9, 9, 9, 9, 9, 9, 6, 8, 9, 9, 9, }, - }), - ContextSetCfg::addCtxSet - ({ - { 25, 1, 40, 33, 26, 4, 25, 33, 27, 36, 37, }, - { 17, 9, 25, 10, 3, 4, 17, 33, 19, 28, 29, }, - { 48, 9, 25, 18, 26, 35, 25, 26, 35, 28, 37, }, - { 1, 5, 8, 8, 8, 6, 6, 9, 8, 8, 10, }, - }), - ContextSetCfg::addCtxSet - ({ - { 0, 0, 33, 34, 35, 36, 25, 34, 35, 28, 29, 40, 42, 43, 36, 30, 56, 43, 44, 45, 38, }, - { 0, 17, 26, 19, 20, 21, 25, 34, 20, 28, 29, 33, 27, 28, 29, 22, 34, 28, 44, 37, 38, }, - { 25, 25, 11, 27, 20, 21, 18, 12, 28, 21, 22, 34, 28, 29, 29, 30, 28, 29, 45, 30, 23, }, - { 9, 5, 10, 13, 13, 10, 9, 10, 13, 13, 13, 9, 10, 10, 10, 13, 8, 9, 9, 10, 13, }, - }), - ContextSetCfg::addCtxSet - ({ - { 0, 40, 42, 20, 21, 29, 57, 52, 53, 38, 46, }, - { 0, 25, 27, 20, 13, 6, 57, 52, 30, 38, 31, }, - { 40, 33, 27, 28, 21, 37, 51, 37, 53, 38, 46, }, - { 9, 9, 10, 12, 12, 10, 5, 9, 9, 9, 12, }, - }) -}; - -const CtxSet ContextSetCfg::LastX[] = -{ - ContextSetCfg::addCtxSet - ({ - { 14, 6, 5, 7, 14, 4, 7, 7, 6, 12, 29, 7, 6, 6, 20, 28, 7, 13, 13, 20, }, - { 6, 13, 12, 6, 6, 4, 14, 14, 5, 12, 29, 14, 13, 5, 36, 28, 14, 13, 20, 19, }, - { 13, 5, 4, 6, 14, 4, 6, 14, 21, 11, 14, 7, 14, 13, 11, 21, 37, 37, 21, 50, }, - { 8, 5, 4, 5, 4, 4, 5, 4, 1, 0, 4, 1, 0, 0, 0, 1, 1, 0, 0, 0, }, - }), - ContextSetCfg::addCtxSet - ({ - { 11, 5, 3, }, - { 12, 4, 18, }, - { 12, 4, 3, }, - { 2, 1, 1, }, - }) -}; - -const CtxSet ContextSetCfg::LastY[] = -{ - ContextSetCfg::addCtxSet - ({ - { 13, 5, 5, 6, 6, 12, 14, 6, 5, 5, 14, 7, 5, 12, 21, 13, 7, 13, 12, 41, }, - { 5, 5, 12, 6, 6, 19, 6, 14, 5, 19, 29, 7, 13, 5, 36, 21, 7, 13, 5, 27, }, - { 13, 5, 4, 6, 6, 11, 14, 14, 5, 11, 14, 22, 14, 12, 3, 21, 37, 52, 28, 34, }, - { 8, 5, 8, 5, 5, 4, 5, 5, 4, 0, 5, 5, 1, 0, 0, 1, 4, 0, 0, 0, }, - }), - ContextSetCfg::addCtxSet - ({ - { 11, 5, 19, }, - { 11, 4, 18, }, - { 12, 4, 3, }, - { 6, 2, 2, }, - }) -}; - -const CtxSet ContextSetCfg::MVPIdx = ContextSetCfg::addCtxSet -({ - { 34, }, - { 34, }, - { 42, }, - { 12, }, -}); - -const CtxSet ContextSetCfg::SmvdFlag = ContextSetCfg::addCtxSet -({ - { 50, }, - { 28, }, - { CNU, }, - { 5, }, -}); - -const CtxSet ContextSetCfg::SaoMergeFlag = ContextSetCfg::addCtxSet -({ - { 10, }, - { 60, }, - { 52, }, - { 0, }, -}); - -const CtxSet ContextSetCfg::SaoTypeIdx = ContextSetCfg::addCtxSet -({ - { 10, }, - { 5, }, - { 5, }, - { 0, }, -}); - -const CtxSet ContextSetCfg::LFNSTIdx = ContextSetCfg::addCtxSet -({ - { 52, 37, 33, }, - { 45, 45, 18, }, - { CNU, 52, 33, }, - { 9, 9, 5, }, -}); - -const CtxSet ContextSetCfg::PLTFlag = ContextSetCfg::addCtxSet -({ - { CNU, }, - { CNU, }, - { CNU, }, - { DWS, }, -}); - -const CtxSet ContextSetCfg::RotationFlag = ContextSetCfg::addCtxSet -({ - { CNU, }, - { CNU, }, - { CNU, }, - { DWS, }, -}); - -const CtxSet ContextSetCfg::RunTypeFlag = ContextSetCfg::addCtxSet -({ - { CNU, }, - { CNU, }, - { CNU, }, - { DWS, }, -}); - -const CtxSet ContextSetCfg::IdxRunModel = ContextSetCfg::addCtxSet -({ - { CNU, CNU, CNU, CNU, CNU, }, - { CNU, CNU, CNU, CNU, CNU, }, - { CNU, CNU, CNU, CNU, CNU, }, - { DWS, DWS, DWS, DWS, DWS, }, -}); - -const CtxSet ContextSetCfg::CopyRunModel = ContextSetCfg::addCtxSet -({ - { CNU, CNU, CNU, }, - { CNU, CNU, CNU, }, - { CNU, CNU, CNU, }, - { DWS, DWS, DWS, }, -}); - -const CtxSet ContextSetCfg::RdpcmFlag = ContextSetCfg::addCtxSet -({ - { CNU, CNU, }, - { CNU, CNU, }, - { CNU, CNU, }, - { DWS, DWS, }, -}); - -const CtxSet ContextSetCfg::RdpcmDir = ContextSetCfg::addCtxSet -({ - { CNU, CNU, }, - { CNU, CNU, }, - { CNU, CNU, }, - { DWS, DWS, }, -}); - -const CtxSet ContextSetCfg::TransformSkipFlag = ContextSetCfg::addCtxSet -({ - { 25, 17, }, - { 25, 17, }, - { 25, 1, }, - { 1, 1, }, -}); - -const CtxSet ContextSetCfg::MTSIdx = ContextSetCfg::addCtxSet -({ - { 37, 25, 27, 0, }, - { 30, 40, 27, 0, }, - { 13, 0, 35, 0, }, - { 8, 0, 9, 0, }, -}); - -const CtxSet ContextSetCfg::ISPMode = ContextSetCfg::addCtxSet -({ - { 33, 43, }, - { 33, 36, }, - { 33, 43, }, - { 9, 2, }, -}); - -const CtxSet ContextSetCfg::SbtFlag = ContextSetCfg::addCtxSet -({ - { 49, 50, }, - { 49, 50, }, - { CNU, CNU, }, - { 1, 5, }, -}); - -const CtxSet ContextSetCfg::SbtQuadFlag = ContextSetCfg::addCtxSet -({ - { 42, }, - { 42, }, - { CNU, }, - { 10, }, -}); - -const CtxSet ContextSetCfg::SbtHorFlag = ContextSetCfg::addCtxSet -({ - { 35, 51, 27, }, - { 20, 43, 12, }, - { CNU, CNU, CNU, }, - { 8, 4, 1, }, -}); - -const CtxSet ContextSetCfg::SbtPosFlag = ContextSetCfg::addCtxSet -({ - { 28, }, - { 28, }, - { CNU, }, - { 13, }, -}); - -const CtxSet ContextSetCfg::CrossCompPred = ContextSetCfg::addCtxSet -({ - { CNU, CNU, CNU, CNU, CNU, CNU, CNU, CNU, CNU, CNU, }, - { CNU, CNU, CNU, CNU, CNU, CNU, CNU, CNU, CNU, CNU, }, - { CNU, CNU, CNU, CNU, CNU, CNU, CNU, CNU, CNU, CNU, }, - { DWS, DWS, DWS, DWS, DWS, DWS, DWS, DWS, DWS, DWS, }, -}); - -const CtxSet ContextSetCfg::ChromaQpAdjFlag = ContextSetCfg::addCtxSet -({ - { CNU, }, - { CNU, }, - { CNU, }, - { DWS, }, -}); - -const CtxSet ContextSetCfg::ChromaQpAdjIdc = ContextSetCfg::addCtxSet -({ - { CNU, }, - { CNU, }, - { CNU, }, - { DWS, }, -}); - -const CtxSet ContextSetCfg::ImvFlag = ContextSetCfg::addCtxSet -({ - { 51, 33, 50, 60, 45, }, - { 59, 48, 58, 60, 60, }, - { CNU, 34, CNU, CNU, CNU, }, - { 0, 5, 1, 0, 4, }, -}); - -const CtxSet ContextSetCfg::ctbAlfFlag = ContextSetCfg::addCtxSet -({ - { 26, 52, 46, 18, 61, 54, 18, 61, 54, }, - { 6, 23, 46, 12, 61, 54, 5, 46, 54, }, - { 39, 39, 39, 62, 39, 39, 31, 39, 39, }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, }, -}); - -const CtxSet ContextSetCfg::ctbAlfAlternative = ContextSetCfg::addCtxSet -({ - { 11, 11, }, - { 20, 12, }, - { 28, 28, }, - { 0, 0, }, -}); - - -const CtxSet ContextSetCfg::AlfUseTemporalFilt = ContextSetCfg::addCtxSet -({ - { 46, }, - { 53, }, - { 46, }, - { 0, }, -}); - -#if JVET_Q0795_CCALF -const CtxSet ContextSetCfg::CcAlfFilterControlFlag = ContextSetCfg::addCtxSet -({ - { 35, 35, 35, 35, 35, 35 }, - { 35, 35, 35, 35, 35, 35 }, - { 35, 35, 35, 35, 35, 35 }, - { DWS, DWS, DWS, DWS, DWS, DWS }, -}); -#endif - -const CtxSet ContextSetCfg::CiipFlag = ContextSetCfg::addCtxSet -({ - { 50, }, - { 50, }, - { CNU, }, - { 1, }, -}); - -const CtxSet ContextSetCfg::IBCFlag = ContextSetCfg::addCtxSet -({ - { 0, 43, 45, }, - { 0, 42, 37, }, - { 17, 42, 36, }, - { 1, 5, 8, }, -}); - -const CtxSet ContextSetCfg::JointCbCrFlag = ContextSetCfg::addCtxSet -({ - { 43, 51, 45, }, - { 35, 44, 45, }, - { 35, 29, 51, }, - { 1, 1, 0, }, -}); - -const CtxSet ContextSetCfg::TsSigCoeffGroup = ContextSetCfg::addCtxSet -({ - { 18, 35, 37, }, - { 18, 12, 29, }, - { 18, 20, 38, }, - { 5, 8, 8, }, -}); - -const CtxSet ContextSetCfg::TsSigFlag = ContextSetCfg::addCtxSet -({ - { 25, 50, 37, }, - { 40, 35, 44, }, - { 25, 28, 38, }, - { 13, 13, 8, }, -}); - -const CtxSet ContextSetCfg::TsParFlag = ContextSetCfg::addCtxSet -({ - { 11, }, - { 3, }, - { 11, }, - { 6, }, -}); - -const CtxSet ContextSetCfg::TsGtxFlag = ContextSetCfg::addCtxSet -({ - { CNU, 10, 4, 4, 5, }, - { CNU, 2, 3, 3, 11, }, - { CNU, 10, 3, 3, 3, }, - { DWS, 1, 1, 1, 1, }, -}); - -const CtxSet ContextSetCfg::TsLrg1Flag = ContextSetCfg::addCtxSet -({ - { 19, 11, 4, 6, }, - { 18, 11, 4, 28, }, - { 11, 5, 5, 6, }, - { 4, 2, 1, 6, }, -}); - -const CtxSet ContextSetCfg::TsResidualSign = ContextSetCfg::addCtxSet -({ - { 28, 25, 53, 28, 33, 30, }, - { 5, 10, 53, 35, 25, 53, }, - { 20, 17, 46, 20, 25, 46, }, - { 1, 4, 4, 8, 8, 8, }, -}); -#endif // clang-format on const unsigned ContextSetCfg::NumberOfContexts = (unsigned)ContextSetCfg::sm_InitTables[0].size(); diff --git a/source/Lib/CommonLib/Contexts.h b/source/Lib/CommonLib/Contexts.h index d17ce051c9c97dda638745f13f97ae85fb3c35a9..7759a98fdaee65c46fb7aa6f4db859aa4b2aa951 100644 --- a/source/Lib/CommonLib/Contexts.h +++ b/source/Lib/CommonLib/Contexts.h @@ -263,9 +263,7 @@ public: static const CtxSet ctbAlfFlag; static const CtxSet ctbAlfAlternative; static const CtxSet AlfUseTemporalFilt; -#if JVET_Q0795_CCALF static const CtxSet CcAlfFilterControlFlag; -#endif static const CtxSet CiipFlag; static const CtxSet SmvdFlag; static const CtxSet IBCFlag; diff --git a/source/Lib/CommonLib/CrossCompPrediction.cpp b/source/Lib/CommonLib/CrossCompPrediction.cpp index a334dae975719724430fc4244119a048d0bc1ee2..ba8b6e04d19837718420308e1c33450560a7df84 100644 --- a/source/Lib/CommonLib/CrossCompPrediction.cpp +++ b/source/Lib/CommonLib/CrossCompPrediction.cpp @@ -42,93 +42,3 @@ #include "CodingStructure.h" #include "Slice.h" -#if !REMOVE_PPS_REXT - -//! \ingroup CommonLib -//! \{ - -int8_t CrossComponentPrediction::xCalcCrossComponentPredictionAlpha( TransformUnit &tu, const ComponentID &compID, bool useRecoResidual ) -{ - const CPelBuf pResiL = useRecoResidual ? tu.cs->getResiBuf( tu.Y() ) : tu.cs->getOrgResiBuf( tu.Y() ); - const CPelBuf pResiC = tu.cs->getResiBuf( tu.blocks[compID] ); - - const int diffBitDepth = tu.cs->sps->getDifferentialLumaChromaBitDepth(); - - int8_t alpha = 0; - int SSxy = 0; - int SSxx = 0; - - for( uint32_t uiY = 0; uiY < pResiL.height; uiY++ ) - { - for( uint32_t uiX = 0; uiX < pResiL.width; uiX++ ) - { - const Pel scaledResiL = rightShift( pResiL.at( uiX, uiY ), diffBitDepth ); - SSxy += ( scaledResiL * pResiC.at( uiX, uiY ) ); - SSxx += ( scaledResiL * scaledResiL ); - } - } - - if( SSxx != 0 ) - { - double dAlpha = SSxy / double( SSxx ); - alpha = int8_t( Clip3<int>( -16, 16, ( int ) ( dAlpha * 16 ) ) ); - - static const int8_t alphaQuant[17] = { 0, 1, 1, 2, 2, 2, 4, 4, 4, 4, 4, 4, 8, 8, 8, 8, 8 }; - - alpha = ( alpha < 0 ) ? -alphaQuant[int( -alpha )] : alphaQuant[int( alpha )]; - } - - tu.compAlpha[compID] = alpha; - - return alpha; -} - - -void CrossComponentPrediction::crossComponentPrediction( TransformUnit &tu, - const ComponentID &compID, - const CPelBuf &piResiL, - const CPelBuf &piResiC, - PelBuf &piResiT, - const bool &reverse ) -{ - const int alpha = tu.compAlpha[compID]; - const int diffBitDepth = tu.cs->sps->getDifferentialLumaChromaBitDepth(); - -#if !RExt__HIGH_BIT_DEPTH_SUPPORT - ClpRng clpRng; //not limited by adaptive clipping - clpRng.min = std::numeric_limits<Pel>::min(); - clpRng.max = std::numeric_limits<Pel>::max(); -#endif - - for( int y = 0; y < piResiT.height; y++ ) - { - if( reverse ) - { - // A constraint is to be added to the HEVC Standard to limit the size of pResiL and pResiC at this point. - // The likely form of the constraint is to either restrict the values to CoeffMin to CoeffMax, - // or to be representable in a bitDepthY+4 or bitDepthC+4 signed integer. - // The result of the constraint is that for 8/10/12bit profiles, the input values - // can be represented within a 16-bit Pel-type. -#if RExt__HIGH_BIT_DEPTH_SUPPORT - for( int x = 0; x < piResiT.width; x++ ) - { - piResiT.at( x, y ) = piResiC.at( x, y ) + ( ( alpha * rightShift( piResiL.at( x, y ), diffBitDepth ) ) >> 3 ); - } -#else - for( int x = 0; x < piResiT.width; x++ ) - { - piResiT.at( x, y ) = ClipPel<int>( piResiC.at( x, y ) + ( ( alpha * rightShift<int>( int( piResiL.at( x, y ) ), diffBitDepth ) ) >> 3 ), clpRng ); - } -#endif - } - else - { - // Forward does not need clipping. Pel type should always be big enough. - for( int x = 0; x < piResiT.width; x++ ) - { - piResiT.at( x, y ) = piResiC.at( x, y ) - ( ( alpha * rightShift<int>( int( piResiL.at( x, y ) ), diffBitDepth ) ) >> 3 ); - } - } - } -} -#endif diff --git a/source/Lib/CommonLib/CrossCompPrediction.h b/source/Lib/CommonLib/CrossCompPrediction.h index 7ed591f1c3a7c337efe87989d85ef5e263521e22..dffddfda3f038e6e430ccf4897bf5764b068b7db 100644 --- a/source/Lib/CommonLib/CrossCompPrediction.h +++ b/source/Lib/CommonLib/CrossCompPrediction.h @@ -30,43 +30,3 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ -#if !REMOVE_PPS_REXT -/** \file Prediction.h - \brief prediction class (header) -*/ - -#ifndef __CROSSCOMPPREDICTION__ -#define __CROSSCOMPPREDICTION__ - - -// Include files -#include "Unit.h" -#include "Buffer.h" - -//! \ingroup CommonLib -//! \{ - -// ==================================================================================================================== -// Class definition -// ==================================================================================================================== - -class CrossComponentPrediction -{ -protected: - - int8_t xCalcCrossComponentPredictionAlpha( TransformUnit &tu, const ComponentID &compID, bool useRecoResidual ); - -public: - - static void crossComponentPrediction( TransformUnit &tu, - const ComponentID &compID, - const CPelBuf &piResiL, - const CPelBuf &piResiC, - PelBuf &piResiT, - const bool &reverse ); -}; - -//! \} - -#endif // __PREDICTION__ -#endif diff --git a/source/Lib/CommonLib/DepQuant.cpp b/source/Lib/CommonLib/DepQuant.cpp index 7d2903c8ddc10018c4bb52fc622379910b00c83d..45ec89bc63cfd47bd8effba28d76d44ae94023d3 100644 --- a/source/Lib/CommonLib/DepQuant.cpp +++ b/source/Lib/CommonLib/DepQuant.cpp @@ -1573,7 +1573,12 @@ DepQuant::~DepQuant() void DepQuant::quant( TransformUnit &tu, const ComponentID &compID, const CCoeffBuf &pSrc, TCoeff &uiAbsSum, const QpParam &cQP, const Ctx& ctx ) { - if ( tu.cs->picHeader->getDepQuantEnabledFlag() && (tu.mtsIdx[compID] != MTS_SKIP) ) + const bool useRegularResidualCoding = tu.cu->slice->getTSResidualCodingDisabledFlag() || tu.mtsIdx[compID] != MTS_SKIP; +#if JVET_R0271_SLICE_LEVEL_DQ_SDH_RRC + if( tu.cs->slice->getDepQuantEnabledFlag() && useRegularResidualCoding ) +#else + if( tu.cs->picHeader->getDepQuantEnabledFlag() && useRegularResidualCoding ) +#endif { //===== scaling matrix ==== const int qpDQ = cQP.Qp(tu.mtsIdx[compID] == MTS_SKIP) + 1; @@ -1586,16 +1591,13 @@ void DepQuant::quant( TransformUnit &tu, const ComponentID &compID, const CCoeff CHECK(scalingListType >= SCALING_LIST_NUM, "Invalid scaling list"); const uint32_t log2TrWidth = floorLog2(width); const uint32_t log2TrHeight = floorLog2(height); -#if JVET_Q0346_SCALING_LIST_USED_IN_SH const bool disableSMForLFNST = tu.cs->slice->getExplicitScalingListUsed() ? tu.cs->picHeader->getScalingListAPS()->getScalingList().getDisableScalingMatrixForLfnstBlks() : false; -#else - const bool disableSMForLFNST = tu.cs->picHeader->getScalingListPresentFlag() ? tu.cs->picHeader->getScalingListAPS()->getScalingList().getDisableScalingMatrixForLfnstBlks() : false; -#endif -#if JVET_Q0784_LFNST_COMBINATION const bool isLfnstApplied = tu.cu->lfnstIdx > 0 && (tu.cu->isSepTree() ? true : isLuma(compID)); - const bool enableScalingLists = getUseScalingList(width, height, (tu.mtsIdx[compID] == MTS_SKIP), isLfnstApplied, disableSMForLFNST); +#if JVET_R0380_SCALING_MATRIX_DISABLE_YCC_OR_RGB + const bool disableSMForACT = tu.cs->slice->getSPS()->getScalingMatrixForAlternativeColourSpaceDisabledFlag() && (tu.cs->slice->getSPS()->getScalingMatrixDesignatedColourSpaceFlag() == tu.cu->colorTransform); + const bool enableScalingLists = getUseScalingList(width, height, (tu.mtsIdx[compID] == MTS_SKIP), isLfnstApplied, disableSMForLFNST, disableSMForACT); #else - const bool enableScalingLists = getUseScalingList(width, height, (tu.mtsIdx[compID] == MTS_SKIP), tu.cu->lfnstIdx > 0, disableSMForLFNST); + const bool enableScalingLists = getUseScalingList(width, height, (tu.mtsIdx[compID] == MTS_SKIP), isLfnstApplied, disableSMForLFNST); #endif static_cast<DQIntern::DepQuant*>(p)->quant( tu, pSrc, compID, cQP, Quant::m_dLambda, ctx, uiAbsSum, enableScalingLists, Quant::getQuantCoeff(scalingListType, qpRem, log2TrWidth, log2TrHeight) ); } @@ -1607,7 +1609,12 @@ void DepQuant::quant( TransformUnit &tu, const ComponentID &compID, const CCoeff void DepQuant::dequant( const TransformUnit &tu, CoeffBuf &dstCoeff, const ComponentID &compID, const QpParam &cQP ) { - if( tu.cs->picHeader->getDepQuantEnabledFlag() && (tu.mtsIdx[compID] != MTS_SKIP)) + const bool useRegularResidualCoding = tu.cu->slice->getTSResidualCodingDisabledFlag() || tu.mtsIdx[compID] != MTS_SKIP; +#if JVET_R0271_SLICE_LEVEL_DQ_SDH_RRC + if( tu.cs->slice->getDepQuantEnabledFlag() && useRegularResidualCoding ) +#else + if( tu.cs->picHeader->getDepQuantEnabledFlag() && useRegularResidualCoding ) +#endif { const int qpDQ = cQP.Qp(tu.mtsIdx[compID] == MTS_SKIP) + 1; const int qpPer = qpDQ / 6; @@ -1619,16 +1626,13 @@ void DepQuant::dequant( const TransformUnit &tu, CoeffBuf &dstCoeff, const Compo CHECK(scalingListType >= SCALING_LIST_NUM, "Invalid scaling list"); const uint32_t log2TrWidth = floorLog2(width); const uint32_t log2TrHeight = floorLog2(height); -#if JVET_Q0346_SCALING_LIST_USED_IN_SH const bool disableSMForLFNST = tu.cs->slice->getExplicitScalingListUsed() ? tu.cs->picHeader->getScalingListAPS()->getScalingList().getDisableScalingMatrixForLfnstBlks() : false; -#else - const bool disableSMForLFNST = tu.cs->picHeader->getScalingListPresentFlag() ? tu.cs->picHeader->getScalingListAPS()->getScalingList().getDisableScalingMatrixForLfnstBlks() : false; -#endif -#if JVET_Q0784_LFNST_COMBINATION const bool isLfnstApplied = tu.cu->lfnstIdx > 0 && (tu.cu->isSepTree() ? true : isLuma(compID)); - const bool enableScalingLists = getUseScalingList(width, height, (tu.mtsIdx[compID] == MTS_SKIP), isLfnstApplied, disableSMForLFNST); +#if JVET_R0380_SCALING_MATRIX_DISABLE_YCC_OR_RGB + const bool disableSMForACT = tu.cs->slice->getSPS()->getScalingMatrixForAlternativeColourSpaceDisabledFlag() && (tu.cs->slice->getSPS()->getScalingMatrixDesignatedColourSpaceFlag() == tu.cu->colorTransform); + const bool enableScalingLists = getUseScalingList(width, height, (tu.mtsIdx[compID] == MTS_SKIP), isLfnstApplied, disableSMForLFNST, disableSMForACT); #else - const bool enableScalingLists = getUseScalingList(width, height, (tu.mtsIdx[compID] == MTS_SKIP), tu.cu->lfnstIdx > 0, disableSMForLFNST); + const bool enableScalingLists = getUseScalingList(width, height, (tu.mtsIdx[compID] == MTS_SKIP), isLfnstApplied, disableSMForLFNST); #endif static_cast<DQIntern::DepQuant*>(p)->dequant( tu, dstCoeff, compID, cQP, enableScalingLists, Quant::getDequantCoeff(scalingListType, qpRem, log2TrWidth, log2TrHeight) ); } diff --git a/source/Lib/CommonLib/HRD.cpp b/source/Lib/CommonLib/HRD.cpp index 14e4b8dfce55aae914a3bc60416357c659d6291a..fcd707c063c624e97f4a0630f0855e3c6b9ce49b 100644 --- a/source/Lib/CommonLib/HRD.cpp +++ b/source/Lib/CommonLib/HRD.cpp @@ -33,7 +33,6 @@ #include "HRD.h" -#if JVET_P0118_HRD_ASPECTS OlsHrdParams::OlsHrdParams() : m_fixedPicRateGeneralFlag(false) , m_fixedPicRateWithinCvsFlag(false) @@ -56,5 +55,4 @@ OlsHrdParams::OlsHrdParams() OlsHrdParams::~OlsHrdParams() { } -#endif diff --git a/source/Lib/CommonLib/HRD.h b/source/Lib/CommonLib/HRD.h index b2e7bd2970f74a0c138585338f2276fea87fc4aa..288ec5c6dc93fd7bf021ef6229195da8e5be9b0a 100644 --- a/source/Lib/CommonLib/HRD.h +++ b/source/Lib/CommonLib/HRD.h @@ -37,50 +37,6 @@ #include "Common.h" #include "SEI.h" -#if !JVET_P0118_HRD_ASPECTS -class TimingInfo -{ -protected: - bool m_timingInfoPresentFlag; - uint32_t m_numUnitsInTick; - uint32_t m_timeScale; - int m_numTicksPocDiffOneMinus1; - -public: - TimingInfo() - : m_timingInfoPresentFlag (false) - , m_numUnitsInTick (1001) - , m_timeScale (60000) - , m_numTicksPocDiffOneMinus1 (0) - {} - - void setTimingInfoPresentFlag( bool flag ) { m_timingInfoPresentFlag = flag; } - bool getTimingInfoPresentFlag( ) const { return m_timingInfoPresentFlag; } - - void setNumUnitsInTick( uint32_t value ) { m_numUnitsInTick = value; } - uint32_t getNumUnitsInTick( ) const { return m_numUnitsInTick; } - void setTimeScale( uint32_t value ) { m_timeScale = value; } - uint32_t getTimeScale( ) const { return m_timeScale; } - - void setNumTicksPocDiffOneMinus1(int x) { m_numTicksPocDiffOneMinus1 = x; } - int getNumTicksPocDiffOneMinus1( ) const { return m_numTicksPocDiffOneMinus1; } -}; - -struct HrdSubLayerInfo -{ - bool fixedPicRateFlag; - bool fixedPicRateWithinCvsFlag; - uint32_t picDurationInTcMinus1; - bool lowDelayHrdFlag; - uint32_t cpbCntMinus1; - uint32_t bitRateValueMinus1[MAX_CPB_CNT][2]; - uint32_t cpbSizeValue [MAX_CPB_CNT][2]; - uint32_t ducpbSizeValue [MAX_CPB_CNT][2]; - bool cbrFlag [MAX_CPB_CNT][2]; - uint32_t duBitRateValue [MAX_CPB_CNT][2]; -}; -#endif -#if JVET_P0118_HRD_ASPECTS class OlsHrdParams { private: @@ -118,67 +74,72 @@ public: void setCbrFlag(int cpbcnt, int nalOrVcl, bool value) { m_cbrFlag[cpbcnt][nalOrVcl] = value; } bool getCbrFlag(int cpbcnt, int nalOrVcl) const { return m_cbrFlag[cpbcnt][nalOrVcl]; } }; -#endif -#if JVET_P0118_HRD_ASPECTS class GeneralHrdParams -#else -class HRDParameters -#endif { private: -#if JVET_P0118_HRD_ASPECTS uint32_t m_numUnitsInTick; uint32_t m_timeScale; bool m_generalNalHrdParamsPresentFlag; bool m_generalVclHrdParamsPresentFlag; - bool m_generalSamPicTimingInAllOlsFlag; -#else - bool m_nalHrdParametersPresentFlag; - bool m_vclHrdParametersPresentFlag; -#endif + bool m_generalSamePicTimingInAllOlsFlag; uint32_t m_tickDivisorMinus2; bool m_generalDecodingUnitHrdParamsPresentFlag; uint32_t m_bitRateScale; uint32_t m_cpbSizeScale; uint32_t m_cpbSizeDuScale; -#if JVET_P0118_HRD_ASPECTS uint32_t m_hrdCpbCntMinus1; -#endif -#if !JVET_P0118_HRD_ASPECTS - HrdSubLayerInfo m_HRD[MAX_TLAYER]; -#endif public: -#if JVET_P0118_HRD_ASPECTS GeneralHrdParams() -#else - HRDParameters() -#endif -#if JVET_P0118_HRD_ASPECTS :m_generalNalHrdParamsPresentFlag(false) ,m_generalVclHrdParamsPresentFlag(false) - ,m_generalSamPicTimingInAllOlsFlag(true) -#else - :m_nalHrdParametersPresentFlag (false) - ,m_vclHrdParametersPresentFlag (false) -#endif + ,m_generalSamePicTimingInAllOlsFlag(true) ,m_tickDivisorMinus2 (0) ,m_generalDecodingUnitHrdParamsPresentFlag (false) ,m_bitRateScale (0) ,m_cpbSizeScale (0) ,m_cpbSizeDuScale (0) -#if JVET_P0118_HRD_ASPECTS ,m_hrdCpbCntMinus1(0) -#endif {} - -#if JVET_P0118_HRD_ASPECTS + bool operator==(const GeneralHrdParams& other) const + { + return (m_numUnitsInTick == other.m_numUnitsInTick + && m_timeScale == other.m_timeScale + && m_generalNalHrdParamsPresentFlag == other.m_generalNalHrdParamsPresentFlag + && m_generalVclHrdParamsPresentFlag == other.m_generalVclHrdParamsPresentFlag + && m_generalSamePicTimingInAllOlsFlag == other.m_generalSamePicTimingInAllOlsFlag + && m_generalDecodingUnitHrdParamsPresentFlag == other.m_generalDecodingUnitHrdParamsPresentFlag + && (m_generalDecodingUnitHrdParamsPresentFlag ? (m_tickDivisorMinus2 == other.m_tickDivisorMinus2): 1) + && m_bitRateScale == other.m_bitRateScale + && m_cpbSizeScale == other.m_cpbSizeScale + && (m_generalDecodingUnitHrdParamsPresentFlag ? (m_cpbSizeDuScale == other.m_cpbSizeDuScale) : 1) + && m_hrdCpbCntMinus1 == other.m_hrdCpbCntMinus1 + ); + } + + GeneralHrdParams& operator=(const GeneralHrdParams& input) + { + m_numUnitsInTick = input.m_numUnitsInTick; + m_timeScale = input.m_timeScale; + m_generalNalHrdParamsPresentFlag = input.m_generalNalHrdParamsPresentFlag; + m_generalVclHrdParamsPresentFlag = input.m_generalVclHrdParamsPresentFlag; + m_generalSamePicTimingInAllOlsFlag = input.m_generalSamePicTimingInAllOlsFlag; + m_generalDecodingUnitHrdParamsPresentFlag = input.m_generalDecodingUnitHrdParamsPresentFlag; + if (input.m_generalDecodingUnitHrdParamsPresentFlag) + { + m_tickDivisorMinus2 = input.m_tickDivisorMinus2; + } + m_bitRateScale = input.m_bitRateScale; + m_cpbSizeScale = input.m_cpbSizeScale; + if (input.m_generalDecodingUnitHrdParamsPresentFlag) + { + m_cpbSizeDuScale = input.m_cpbSizeDuScale; + } + m_hrdCpbCntMinus1 = input.m_hrdCpbCntMinus1; + return *this; + } virtual ~GeneralHrdParams() {} -#else - virtual ~HRDParameters() {} -#endif -#if JVET_P0118_HRD_ASPECTS void setNumUnitsInTick(uint32_t value) { m_numUnitsInTick = value; } uint32_t getNumUnitsInTick() const { return m_numUnitsInTick; } @@ -191,15 +152,8 @@ public: void setGeneralVclHrdParametersPresentFlag(bool flag) { m_generalVclHrdParamsPresentFlag = flag; } bool getGeneralVclHrdParametersPresentFlag() const { return m_generalVclHrdParamsPresentFlag; } - void setGeneralSamPicTimingInAllOlsFlag(bool flag) { m_generalSamPicTimingInAllOlsFlag = flag; } - bool getGeneralSamPicTimingInAllOlsFlag() const { return m_generalSamPicTimingInAllOlsFlag; } -#else - void setNalHrdParametersPresentFlag( bool flag ) { m_nalHrdParametersPresentFlag = flag; } - bool getNalHrdParametersPresentFlag( ) const { return m_nalHrdParametersPresentFlag; } - - void setVclHrdParametersPresentFlag( bool flag ) { m_vclHrdParametersPresentFlag = flag; } - bool getVclHrdParametersPresentFlag( ) const { return m_vclHrdParametersPresentFlag; } -#endif + void setGeneralSamePicTimingInAllOlsFlag(bool flag) { m_generalSamePicTimingInAllOlsFlag = flag; } + bool getGeneralSamePicTimingInAllOlsFlag() const { return m_generalSamePicTimingInAllOlsFlag; } void setTickDivisorMinus2( uint32_t value ) { m_tickDivisorMinus2 = value; } @@ -217,41 +171,9 @@ public: void setCpbSizeDuScale( uint32_t value ) { m_cpbSizeDuScale = value; } uint32_t getCpbSizeDuScale( ) const { return m_cpbSizeDuScale; } -#if JVET_P0118_HRD_ASPECTS void setHrdCpbCntMinus1(uint32_t value) { m_hrdCpbCntMinus1 = value; } uint32_t getHrdCpbCntMinus1() const { return m_hrdCpbCntMinus1; } -#endif - -#if !JVET_P0118_HRD_ASPECTS - void setFixedPicRateFlag( int layer, bool flag ) { m_HRD[layer].fixedPicRateFlag = flag; } - bool getFixedPicRateFlag( int layer ) const { return m_HRD[layer].fixedPicRateFlag; } - - void setFixedPicRateWithinCvsFlag( int layer, bool flag ) { m_HRD[layer].fixedPicRateWithinCvsFlag = flag; } - bool getFixedPicRateWithinCvsFlag( int layer ) const { return m_HRD[layer].fixedPicRateWithinCvsFlag; } - void setPicDurationInTcMinus1( int layer, uint32_t value ) { m_HRD[layer].picDurationInTcMinus1 = value; } - uint32_t getPicDurationInTcMinus1( int layer ) const { return m_HRD[layer].picDurationInTcMinus1; } - - void setLowDelayHrdFlag( int layer, bool flag ) { m_HRD[layer].lowDelayHrdFlag = flag; } - bool getLowDelayHrdFlag( int layer ) const { return m_HRD[layer].lowDelayHrdFlag; } - - void setCpbCntMinus1( int layer, uint32_t value ) { m_HRD[layer].cpbCntMinus1 = value; } - uint32_t getCpbCntMinus1( int layer ) const { return m_HRD[layer].cpbCntMinus1; } - - void setBitRateValueMinus1( int layer, int cpbcnt, int nalOrVcl, uint32_t value ) { m_HRD[layer].bitRateValueMinus1[cpbcnt][nalOrVcl] = value; } - uint32_t getBitRateValueMinus1( int layer, int cpbcnt, int nalOrVcl ) const { return m_HRD[layer].bitRateValueMinus1[cpbcnt][nalOrVcl]; } - - void setCpbSizeValueMinus1( int layer, int cpbcnt, int nalOrVcl, uint32_t value ) { m_HRD[layer].cpbSizeValue[cpbcnt][nalOrVcl] = value; } - uint32_t getCpbSizeValueMinus1( int layer, int cpbcnt, int nalOrVcl ) const { return m_HRD[layer].cpbSizeValue[cpbcnt][nalOrVcl]; } - void setDuCpbSizeValueMinus1( int layer, int cpbcnt, int nalOrVcl, uint32_t value ) { m_HRD[layer].ducpbSizeValue[cpbcnt][nalOrVcl] = value; } - uint32_t getDuCpbSizeValueMinus1( int layer, int cpbcnt, int nalOrVcl ) const { return m_HRD[layer].ducpbSizeValue[cpbcnt][nalOrVcl]; } - void setDuBitRateValueMinus1( int layer, int cpbcnt, int nalOrVcl, uint32_t value ) { m_HRD[layer].duBitRateValue[cpbcnt][nalOrVcl] = value; } - uint32_t getDuBitRateValueMinus1(int layer, int cpbcnt, int nalOrVcl ) const { return m_HRD[layer].duBitRateValue[cpbcnt][nalOrVcl]; } - void setCbrFlag( int layer, int cpbcnt, int nalOrVcl, bool value ) { m_HRD[layer].cbrFlag[cpbcnt][nalOrVcl] = value; } - bool getCbrFlag( int layer, int cpbcnt, int nalOrVcl ) const { return m_HRD[layer].cbrFlag[cpbcnt][nalOrVcl]; } - - bool getCpbDpbDelaysPresentFlag( ) const { return getNalHrdParametersPresentFlag() || getVclHrdParametersPresentFlag(); } -#endif }; class HRD @@ -259,14 +181,11 @@ class HRD public: HRD() :m_bufferingPeriodInitialized (false) -#if JVET_Q0818_PT_SEI , m_pictureTimingAvailable (false) -#endif {}; virtual ~HRD() {}; -#if JVET_P0118_HRD_ASPECTS void setGeneralHrdParameters(GeneralHrdParams &generalHrdParam) { m_generalHrdParams = generalHrdParam; } GeneralHrdParams getGeneralHrdParameters() const { return m_generalHrdParams; } const GeneralHrdParams& getGeneralHrdParameters() { return m_generalHrdParams; } @@ -276,38 +195,20 @@ public: OlsHrdParams* getOlsHrdParametersAddr() { return &m_olsHrdParams[0]; } const OlsHrdParams& getOlsHrdParameters() const { return m_olsHrdParams[0]; } -#else - void setHRDParameters(HRDParameters &hrdParam) { m_hrdParams=hrdParam; } - HRDParameters getHRDParameters() const { return m_hrdParams; } - const HRDParameters& getHRDParameters() { return m_hrdParams; } - - void setTimingInfo(TimingInfo &timingInfo) { m_timingInfo=timingInfo; } - TimingInfo getTimingInfo() const { return m_timingInfo; } - const TimingInfo& getTimingInfo() { return m_timingInfo; } -#endif void setBufferingPeriodSEI(const SEIBufferingPeriod* bp) { bp->copyTo(m_bufferingPeriodSEI); m_bufferingPeriodInitialized = true; } const SEIBufferingPeriod* getBufferingPeriodSEI() const { return m_bufferingPeriodInitialized ? &m_bufferingPeriodSEI : nullptr; } -#if JVET_Q0818_PT_SEI void setPictureTimingSEI(const SEIPictureTiming* pt) { pt->copyTo(m_pictureTimingSEI); m_pictureTimingAvailable = true; } const SEIPictureTiming* getPictureTimingSEI() const { return m_pictureTimingAvailable ? &m_pictureTimingSEI : nullptr; } -#endif protected: -#if JVET_P0118_HRD_ASPECTS GeneralHrdParams m_generalHrdParams; OlsHrdParams m_olsHrdParams[MAX_TLAYER]; -#else - HRDParameters m_hrdParams; - TimingInfo m_timingInfo; -#endif bool m_bufferingPeriodInitialized; SEIBufferingPeriod m_bufferingPeriodSEI; -#if JVET_Q0818_PT_SEI bool m_pictureTimingAvailable; SEIPictureTiming m_pictureTimingSEI; -#endif }; #endif //__HRD__ diff --git a/source/Lib/CommonLib/Hash.cpp b/source/Lib/CommonLib/Hash.cpp index 9750be390676f5f808744f2cd963a684d33b28aa..a6e7844e9a001c3d2de86a4234b13c86e2e70944 100644 --- a/source/Lib/CommonLib/Hash.cpp +++ b/source/Lib/CommonLib/Hash.cpp @@ -377,17 +377,11 @@ void TComHash::getPixelsIn1DCharArrayByBlock2x2(const PelUnitBuf &curPicBuf, uns if (bitDepths.recon[CHANNEL_TYPE_LUMA] == 8 && bitDepths.recon[CHANNEL_TYPE_CHROMA] == 8) { -#if JVET_Q0438_MONOCHROME_BUGFIXES Pel* curPel[MAX_NUM_COMPONENT]={nullptr}; int stride[MAX_NUM_COMPONENT]={0}; const int maxComponent=includeAllComponent?MAX_NUM_COMPONENT:1; for (int id = 0; id < maxComponent; id++) -#else - Pel* curPel[3]; - int stride[3]; - for (int id = 0; id < 3; id++) -#endif { ComponentID compID = ComponentID(id); stride[id] = (curPicBuf).get(compID).stride; @@ -418,19 +412,12 @@ void TComHash::getPixelsIn1DCharArrayByBlock2x2(const PelUnitBuf &curPicBuf, uns else { int shift = bitDepths.recon[CHANNEL_TYPE_LUMA] - 8; -#if JVET_Q0438_MONOCHROME_BUGFIXES int shiftc = includeAllComponent ? (bitDepths.recon[CHANNEL_TYPE_CHROMA] - 8) : 0; Pel* curPel[MAX_NUM_COMPONENT]={nullptr}; int stride[MAX_NUM_COMPONENT]={0}; const int maxComponent=includeAllComponent?MAX_NUM_COMPONENT:1; for (int id = 0; id < maxComponent; id++) -#else - int shiftc = bitDepths.recon[CHANNEL_TYPE_CHROMA] - 8; - Pel* curPel[3]; - int stride[3]; - for (int id = 0; id < 3; id++) -#endif { ComponentID compID = ComponentID(id); stride[id] = (curPicBuf).get(compID).stride; diff --git a/source/Lib/CommonLib/InterPrediction.cpp b/source/Lib/CommonLib/InterPrediction.cpp index 53885e0f85cbb5b8bfae87bb8e57b825357250c2..537fa61ec7ed18174428ef6ff823c696b8fd1dc4 100644 --- a/source/Lib/CommonLib/InterPrediction.cpp +++ b/source/Lib/CommonLib/InterPrediction.cpp @@ -126,12 +126,8 @@ void InterPrediction::destroy() } } -#if !JVET_Q0806 - m_triangleBuf.destroy(); -#else m_geoPartBuf[0].destroy(); m_geoPartBuf[1].destroy(); -#endif m_colorTransResiBuf[0].destroy(); m_colorTransResiBuf[1].destroy(); m_colorTransResiBuf[2].destroy(); @@ -197,12 +193,8 @@ void InterPrediction::init( RdCost* pcRdCost, ChromaFormat chromaFormatIDC, cons } } -#if !JVET_Q0806 - m_triangleBuf.create(UnitArea(chromaFormatIDC, Area(0, 0, MAX_CU_SIZE, MAX_CU_SIZE))); -#else m_geoPartBuf[0].create(UnitArea(chromaFormatIDC, Area(0, 0, MAX_CU_SIZE, MAX_CU_SIZE))); m_geoPartBuf[1].create(UnitArea(chromaFormatIDC, Area(0, 0, MAX_CU_SIZE, MAX_CU_SIZE))); -#endif m_colorTransResiBuf[0].create(UnitArea(chromaFormatIDC, Area(0, 0, MAX_CU_SIZE, MAX_CU_SIZE))); m_colorTransResiBuf[1].create(UnitArea(chromaFormatIDC, Area(0, 0, MAX_CU_SIZE, MAX_CU_SIZE))); m_colorTransResiBuf[2].create(UnitArea(chromaFormatIDC, Area(0, 0, MAX_CU_SIZE, MAX_CU_SIZE))); @@ -313,11 +305,7 @@ void InterPrediction::xSubPuMC( PredictionUnit& pu, PelUnitBuf& predBuf, const R int fstStep = (!verMC ? puHeight : puWidth); int secStep = (!verMC ? puWidth : puHeight); -#if JVET_Q0487_SCALING_WINDOW_ISSUES bool scaled = pu.cu->slice->getRefPic( REF_PIC_LIST_0, 0 )->isRefScaled( pu.cs->pps ) || ( pu.cs->slice->getSliceType() == B_SLICE ? pu.cu->slice->getRefPic( REF_PIC_LIST_1, 0 )->isRefScaled( pu.cs->pps ) : false ); -#else - bool scaled = pu.cu->slice->getScalingRatio( REF_PIC_LIST_0, 0 ) != SCALE_1X || ( pu.cs->slice->getSliceType() == B_SLICE ? pu.cu->slice->getScalingRatio( REF_PIC_LIST_1, 0 ) != SCALE_1X : false ); -#endif m_subPuMC = true; @@ -484,11 +472,7 @@ void InterPrediction::xPredInterUni(const PredictionUnit& pu, const RefPicList& if( !pu.cu->affine ) { -#if JVET_Q0487_SCALING_WINDOW_ISSUES if( !isIBC && pu.cu->slice->getRefPic( eRefPicList, iRefIdx )->isRefScaled( pu.cs->pps ) == false ) -#else - if( pu.cu->slice->getScalingRatio( eRefPicList, iRefIdx ) == SCALE_1X ) -#endif { if( !sps.getWrapAroundEnabledFlag() ) { @@ -549,11 +533,7 @@ void InterPrediction::xPredInterBi(PredictionUnit &pu, PelUnitBuf &pcYuvPred, co } else { -#if JVET_Q0128_DMVR_BDOF_ENABLING_CONDITION const bool biocheck0 = !((wp0[COMPONENT_Y].bPresentFlag || wp0[COMPONENT_Cb].bPresentFlag || wp0[COMPONENT_Cr].bPresentFlag || wp1[COMPONENT_Y].bPresentFlag || wp1[COMPONENT_Cb].bPresentFlag || wp1[COMPONENT_Cr].bPresentFlag) && slice.getSliceType() == B_SLICE); -#else - const bool biocheck0 = !((wp0[COMPONENT_Y].bPresentFlag || wp1[COMPONENT_Y].bPresentFlag) && slice.getSliceType() == B_SLICE); -#endif const bool biocheck1 = !(pps.getUseWP() && slice.getSliceType() == P_SLICE); if (biocheck0 && biocheck1 @@ -586,16 +566,10 @@ void InterPrediction::xPredInterBi(PredictionUnit &pu, PelUnitBuf &pcYuvPred, co bool dmvrApplied = false; dmvrApplied = (pu.mvRefine) && PU::checkDMVRCondition(pu); -#if JVET_Q0487_SCALING_WINDOW_ISSUES - bool refIsScaled = ( refIdx0 < 0 ? false : pu.cu->slice->getRefPic( REF_PIC_LIST_0, refIdx0 )->isRefScaled( pu.cs->pps ) ) || + bool refIsScaled = ( refIdx0 < 0 ? false : pu.cu->slice->getRefPic( REF_PIC_LIST_0, refIdx0 )->isRefScaled( pu.cs->pps ) ) || ( refIdx1 < 0 ? false : pu.cu->slice->getRefPic( REF_PIC_LIST_1, refIdx1 )->isRefScaled( pu.cs->pps ) ); dmvrApplied = dmvrApplied && !refIsScaled; bioApplied = bioApplied && !refIsScaled; -#else - bool samePicSize = ( refIdx0 < 0 ? true : pu.cu->slice->getScalingRatio( REF_PIC_LIST_0, refIdx0 ) == SCALE_1X ) && ( refIdx1 < 0 ? true : pu.cu->slice->getScalingRatio( REF_PIC_LIST_1, refIdx1 ) == SCALE_1X ); - dmvrApplied = dmvrApplied && samePicSize; - bioApplied = bioApplied && samePicSize; -#endif for (uint32_t refList = 0; refList < NUM_REF_PIC_LIST_01; refList++) { @@ -639,11 +613,7 @@ void InterPrediction::xPredInterBi(PredictionUnit &pu, PelUnitBuf &pcYuvPred, co } else { -#if !JVET_Q0806 - xPredInterUni( pu, eRefPicList, pcMbBuf, pu.cu->triangle -#else xPredInterUni(pu, eRefPicList, pcMbBuf, pu.cu->geoFlag -#endif , bioApplied , luma, chroma ); @@ -658,21 +628,13 @@ void InterPrediction::xPredInterBi(PredictionUnit &pu, PelUnitBuf &pcYuvPred, co CPelUnitBuf(pu.chromaFormat, PelBuf(m_acYuvPred[1][0], pcYuvPred.Y()), PelBuf(m_acYuvPred[1][1], pcYuvPred.Cb()), PelBuf(m_acYuvPred[1][2], pcYuvPred.Cr())) ); const bool lumaOnly = luma && !chroma; const bool chromaOnly = !luma && chroma; -#if !JVET_Q0806 - if( !pu.cu->triangle && (!dmvrApplied) && (!bioApplied) && pps.getWPBiPred() && slice.getSliceType() == B_SLICE && pu.cu->BcwIdx==BCW_DEFAULT) -#else if( !pu.cu->geoFlag && (!dmvrApplied) && (!bioApplied) && pps.getWPBiPred() && slice.getSliceType() == B_SLICE && pu.cu->BcwIdx == BCW_DEFAULT) -#endif { xWeightedPredictionBi( pu, srcPred0, srcPred1, pcYuvPred, m_maxCompIDToPred, lumaOnly, chromaOnly ); if (yuvPredTmp) yuvPredTmp->copyFrom(pcYuvPred); } -#if !JVET_Q0806 - else if( !pu.cu->triangle && pps.getUseWP() && slice.getSliceType() == P_SLICE ) -#else else if( !pu.cu->geoFlag && pps.getUseWP() && slice.getSliceType() == P_SLICE ) -#endif { xWeightedPredictionUni( pu, srcPred0, REF_PIC_LIST_0, pcYuvPred, -1, m_maxCompIDToPred, lumaOnly, chromaOnly ); if (yuvPredTmp) @@ -933,12 +895,6 @@ void InterPrediction::xPredAffineBlk(const ComponentID &compID, const Prediction int iMvScaleHor = mvLT.getHor() << iBit; int iMvScaleVer = mvLT.getVer() << iBit; const SPS &sps = *pu.cs->sps; - const int iMvShift = 4; - const int iOffset = 8; - const int iHorMax = ( pu.cs->pps->getPicWidthInLumaSamples() + iOffset - pu.Y().x - 1 ) << iMvShift; - const int iHorMin = ( -(int)pu.cs->pcv->maxCUWidth - iOffset - (int)pu.Y().x + 1 ) << iMvShift; - const int iVerMax = ( pu.cs->pps->getPicHeightInLumaSamples() + iOffset - pu.Y().y - 1 ) << iMvShift; - const int iVerMin = ( -(int)pu.cs->pcv->maxCUHeight - iOffset - (int)pu.Y().y + 1 ) << iMvShift; const int vFilterSize = isLuma(compID) ? NTAPS_LUMA : NTAPS_CHROMA; @@ -952,12 +908,7 @@ void InterPrediction::xPredAffineBlk(const ComponentID &compID, const Prediction enablePROF &= !subblkMVSpreadOverLimit; const int profThres = 1 << (iBit + (m_isBi ? 1 : 0)); enablePROF &= !m_encOnly || pu.cu->slice->getCheckLDC() || iDMvHorX > profThres || iDMvHorY > profThres || iDMvVerX > profThres || iDMvVerY > profThres || iDMvHorX < -profThres || iDMvHorY < -profThres || iDMvVerX < -profThres || iDMvVerY < -profThres; -#if JVET_Q0487_SCALING_WINDOW_ISSUES enablePROF &= (refPic->isRefScaled( pu.cs->pps ) == false); -#else - enablePROF &= pu.cs->pps->getPicWidthInLumaSamples() == refPic->getPicWidthInLumaSamples() && pu.cs->pps->getPicHeightInLumaSamples() == refPic->getPicHeightInLumaSamples(); - enablePROF &= scalingRatio == SCALE_1X; -#endif bool isLast = enablePROF ? false : !bi; @@ -1128,14 +1079,11 @@ void InterPrediction::xPredAffineBlk(const ComponentID &compID, const Prediction { wrapRef = false; m_storedMv[h / AFFINE_MIN_BLOCK_SIZE * MVBUFFER_SIZE + w / AFFINE_MIN_BLOCK_SIZE].set(iMvScaleTmpHor, iMvScaleTmpVer); -#if JVET_Q0487_SCALING_WINDOW_ISSUES if( refPic->isRefScaled( pu.cs->pps ) == false ) -#else - if( scalingRatio == SCALE_1X ) -#endif { - iMvScaleTmpHor = std::min<int>(iHorMax, std::max<int>(iHorMin, iMvScaleTmpHor)); - iMvScaleTmpVer = std::min<int>(iVerMax, std::max<int>(iVerMin, iMvScaleTmpVer)); + clipMv(tmpMv, pu.lumaPos(), pu.lumaSize(), *pu.cs->sps, *pu.cs->pps); + iMvScaleTmpHor = tmpMv.getHor(); + iMvScaleTmpVer = tmpMv.getVer(); } } } @@ -1151,14 +1099,9 @@ void InterPrediction::xPredAffineBlk(const ComponentID &compID, const Prediction else { wrapRef = false; -#if JVET_Q0487_SCALING_WINDOW_ISSUES if( refPic->isRefScaled( pu.cs->pps ) == false ) -#else - if( scalingRatio == SCALE_1X ) -#endif { - curMv.hor = std::min<int>(iHorMax, std::max<int>(iHorMin, curMv.hor)); - curMv.ver = std::min<int>(iVerMax, std::max<int>(iVerMin, curMv.ver)); + clipMv(curMv, pu.lumaPos(), pu.lumaSize(), *pu.cs->sps, *pu.cs->pps); } } iMvScaleTmpHor = curMv.hor; @@ -1426,55 +1369,21 @@ void InterPrediction::xWeightedAverage(const PredictionUnit& pu, const CPelUnitB yuvDstTmp->bufs[0].copyFrom(pcYuvDst.bufs[0]); } } -#if JVET_Q0128_DMVR_BDOF_ENABLING_CONDITION if (!bioApplied && (lumaOnly || chromaOnly)) { pcYuvDst.addAvg(pcYuvSrc0, pcYuvSrc1, clpRngs, chromaOnly, lumaOnly); } else pcYuvDst.addAvg(pcYuvSrc0, pcYuvSrc1, clpRngs, bioApplied); -#else - if (pu.cs->pps->getWPBiPred()) - { - const int iRefIdx0 = pu.refIdx[0]; - const int iRefIdx1 = pu.refIdx[1]; - WPScalingParam *pwp0; - WPScalingParam *pwp1; - getWpScaling(pu.cu->slice, iRefIdx0, iRefIdx1, pwp0, pwp1); - if (!bioApplied) - { - if (!chromaOnly) - addWeightBiComponent(pcYuvSrc0, pcYuvSrc1, pu.cu->slice->clpRngs(), pwp0, pwp1, pcYuvDst, true, COMPONENT_Y); - } - if (!lumaOnly) - { - addWeightBiComponent(pcYuvSrc0, pcYuvSrc1, pu.cu->slice->clpRngs(), pwp0, pwp1, pcYuvDst, true, COMPONENT_Cb); - addWeightBiComponent(pcYuvSrc0, pcYuvSrc1, pu.cu->slice->clpRngs(), pwp0, pwp1, pcYuvDst, true, COMPONENT_Cr); - } - } - else - { - if (!bioApplied && (lumaOnly || chromaOnly)) - { - pcYuvDst.addAvg(pcYuvSrc0, pcYuvSrc1, clpRngs, chromaOnly, lumaOnly); - } - else - pcYuvDst.addAvg(pcYuvSrc0, pcYuvSrc1, clpRngs, bioApplied); - } -#endif if (yuvDstTmp) { if (bioApplied) { -#if JVET_Q0438_MONOCHROME_BUGFIXES if (isChromaEnabled(yuvDstTmp->chromaFormat)) { -#endif yuvDstTmp->bufs[1].copyFrom(pcYuvDst.bufs[1]); yuvDstTmp->bufs[2].copyFrom(pcYuvDst.bufs[2]); -#if JVET_Q0438_MONOCHROME_BUGFIXES } -#endif } else yuvDstTmp->copyFrom(pcYuvDst, lumaOnly, chromaOnly); @@ -1482,38 +1391,22 @@ void InterPrediction::xWeightedAverage(const PredictionUnit& pu, const CPelUnitB } else if( iRefIdx0 >= 0 && iRefIdx1 < 0 ) { -#if !JVET_Q0806 - if( pu.cu->triangle ) - { - pcYuvDst.copyFrom( pcYuvSrc0 ); - } - else -#else if( pu.cu->geoFlag ) { pcYuvDst.copyFrom( pcYuvSrc0 ); } else -#endif pcYuvDst.copyClip( pcYuvSrc0, clpRngs, lumaOnly, chromaOnly ); if (yuvDstTmp) yuvDstTmp->copyFrom( pcYuvDst, lumaOnly, chromaOnly ); } else if( iRefIdx0 < 0 && iRefIdx1 >= 0 ) { -#if !JVET_Q0806 - if( pu.cu->triangle ) - { - pcYuvDst.copyFrom( pcYuvSrc1 ); - } - else -#else if( pu.cu->geoFlag ) { pcYuvDst.copyFrom( pcYuvSrc1 ); } else -#endif pcYuvDst.copyClip( pcYuvSrc1, clpRngs, lumaOnly, chromaOnly ); if (yuvDstTmp) yuvDstTmp->copyFrom(pcYuvDst, lumaOnly, chromaOnly); @@ -1526,11 +1419,9 @@ void InterPrediction::motionCompensation( PredictionUnit &pu, PelUnitBuf &predBu , PelUnitBuf* predBufWOBIO /*= NULL*/ ) { -#if JVET_Q0438_MONOCHROME_BUGFIXES // Note: there appears to be an interaction with weighted prediction that // makes the code follow different paths if chroma is on or off (in the encoder). // Therefore for 4:0:0, "chroma" is not changed to false. -#endif CHECK(predBufWOBIO && pu.ciipFlag, "the case should not happen!"); if (!pu.cs->pcv->isEncoder) @@ -1569,7 +1460,7 @@ void InterPrediction::motionCompensation( PredictionUnit &pu, PelUnitBuf &predBu , false , luma, chroma ); - xWeightedPredictionUni( pu, predBuf, eRefPicList, predBuf, -1, m_maxCompIDToPred + xWeightedPredictionUni( pu, predBuf, eRefPicList, predBuf, -1, m_maxCompIDToPred , (luma && !chroma), (!luma && chroma) ); } @@ -1602,11 +1493,7 @@ void InterPrediction::motionCompensation( PredictionUnit &pu, PelUnitBuf &predBu } else { -#if JVET_Q0128_DMVR_BDOF_ENABLING_CONDITION const bool biocheck0 = !((wp0[COMPONENT_Y].bPresentFlag || wp0[COMPONENT_Cb].bPresentFlag || wp0[COMPONENT_Cr].bPresentFlag || wp1[COMPONENT_Y].bPresentFlag || wp1[COMPONENT_Cb].bPresentFlag || wp1[COMPONENT_Cr].bPresentFlag) && slice.getSliceType() == B_SLICE); -#else - const bool biocheck0 = !((wp0[COMPONENT_Y].bPresentFlag || wp1[COMPONENT_Y].bPresentFlag) && slice.getSliceType() == B_SLICE); -#endif const bool biocheck1 = !(pps.getUseWP() && slice.getSliceType() == P_SLICE); if (biocheck0 && biocheck1 @@ -1639,13 +1526,9 @@ void InterPrediction::motionCompensation( PredictionUnit &pu, PelUnitBuf &predBu } } -#if JVET_Q0487_SCALING_WINDOW_ISSUES - bool refIsScaled = ( refIdx0 < 0 ? false : pu.cu->slice->getRefPic( REF_PIC_LIST_0, refIdx0 )->isRefScaled( pu.cs->pps ) ) || + bool refIsScaled = ( refIdx0 < 0 ? false : pu.cu->slice->getRefPic( REF_PIC_LIST_0, refIdx0 )->isRefScaled( pu.cs->pps ) ) || ( refIdx1 < 0 ? false : pu.cu->slice->getRefPic( REF_PIC_LIST_1, refIdx1 )->isRefScaled( pu.cs->pps ) ); bioApplied = refIsScaled ? false : bioApplied; -#else - bioApplied = ( ( refIdx0 < 0 ? true : pu.cu->slice->getScalingRatio( REF_PIC_LIST_0, refIdx0 ) == SCALE_1X ) && ( refIdx1 < 0 ? true : pu.cu->slice->getScalingRatio( REF_PIC_LIST_1, refIdx1 ) == SCALE_1X ) ) ? bioApplied : false; -#endif bool dmvrApplied = false; dmvrApplied = (pu.mvRefine) && PU::checkDMVRCondition(pu); if ((pu.lumaSize().width > MAX_BDOF_APPLICATION_REGION || pu.lumaSize().height > MAX_BDOF_APPLICATION_REGION) && pu.mergeType != MRG_TYPE_SUBPU_ATMVP && (bioApplied && !dmvrApplied)) @@ -1705,66 +1588,6 @@ int InterPrediction::rightShiftMSB(int numer, int denom) return numer >> floorLog2(denom); } -#if !JVET_Q0806 -void InterPrediction::motionCompensation4Triangle( CodingUnit &cu, MergeCtx &triangleMrgCtx, const bool splitDir, const uint8_t candIdx0, const uint8_t candIdx1 ) -{ - for( auto &pu : CU::traversePUs( cu ) ) - { - const UnitArea localUnitArea( cu.cs->area.chromaFormat, Area( 0, 0, pu.lwidth(), pu.lheight() ) ); - PelUnitBuf tmpTriangleBuf = m_triangleBuf.getBuf( localUnitArea ); - PelUnitBuf predBuf = cu.cs->getPredBuf( pu ); - - triangleMrgCtx.setMergeInfo( pu, candIdx0 ); - PU::spanMotionInfo( pu ); - motionCompensation( pu, tmpTriangleBuf ); - - { - if( g_mctsDecCheckEnabled && !MCTSHelper::checkMvBufferForMCTSConstraint( pu, true ) ) - { - printf( "DECODER_TRIANGLE_PU: pu motion vector across tile boundaries (%d,%d,%d,%d)\n", pu.lx(), pu.ly(), pu.lwidth(), pu.lheight() ); - } - } - - triangleMrgCtx.setMergeInfo( pu, candIdx1 ); - PU::spanMotionInfo( pu ); - motionCompensation( pu, predBuf ); - - { - if( g_mctsDecCheckEnabled && !MCTSHelper::checkMvBufferForMCTSConstraint( pu, true ) ) - { - printf( "DECODER_TRIANGLE_PU: pu motion vector across tile boundaries (%d,%d,%d,%d)\n", pu.lx(), pu.ly(), pu.lwidth(), pu.lheight() ); - } - } - weightedTriangleBlk( pu, splitDir, MAX_NUM_CHANNEL_TYPE, predBuf, tmpTriangleBuf, predBuf ); - } -} - -void InterPrediction::weightedTriangleBlk( PredictionUnit &pu, const bool splitDir, int32_t channel, PelUnitBuf& predDst, PelUnitBuf& predSrc0, PelUnitBuf& predSrc1 ) -{ - if( channel == CHANNEL_TYPE_LUMA ) - { - m_if.weightedTriangleBlk( pu, pu.lumaSize().width, pu.lumaSize().height, COMPONENT_Y, splitDir, predDst, predSrc0, predSrc1 ); - } - else if( channel == CHANNEL_TYPE_CHROMA ) - { - m_if.weightedTriangleBlk( pu, pu.chromaSize().width, pu.chromaSize().height, COMPONENT_Cb, splitDir, predDst, predSrc0, predSrc1 ); - m_if.weightedTriangleBlk( pu, pu.chromaSize().width, pu.chromaSize().height, COMPONENT_Cr, splitDir, predDst, predSrc0, predSrc1 ); - } - else - { - m_if.weightedTriangleBlk( pu, pu.lumaSize().width, pu.lumaSize().height, COMPONENT_Y, splitDir, predDst, predSrc0, predSrc1 ); -#if JVET_Q0438_MONOCHROME_BUGFIXES - if (isChromaEnabled(pu.chromaFormat)) - { -#endif - m_if.weightedTriangleBlk( pu, pu.chromaSize().width, pu.chromaSize().height, COMPONENT_Cb, splitDir, predDst, predSrc0, predSrc1 ); - m_if.weightedTriangleBlk( pu, pu.chromaSize().width, pu.chromaSize().height, COMPONENT_Cr, splitDir, predDst, predSrc0, predSrc1 ); -#if JVET_Q0438_MONOCHROME_BUGFIXES - } -#endif - } -} -#else void InterPrediction::motionCompensationGeo( CodingUnit &cu, MergeCtx &geoMrgCtx ) { const uint8_t splitDir = cu.firstPU->geoSplitDir; @@ -1784,7 +1607,7 @@ void InterPrediction::motionCompensationGeo( CodingUnit &cu, MergeCtx &geoMrgCtx { printf( "DECODER_GEO_PU: pu motion vector across tile boundaries (%d,%d,%d,%d)\n", pu.lx(), pu.ly(), pu.lwidth(), pu.lheight() ); } - + geoMrgCtx.setMergeInfo( pu, candIdx1 ); PU::spanMotionInfo( pu ); motionCompensation(pu, tmpGeoBuf1, REF_PIC_LIST_X, true, isChromaEnabled(pu.chromaFormat)); // TODO: check 4:0:0 interaction with weighted prediction. @@ -1810,18 +1633,13 @@ void InterPrediction::weightedGeoBlk( PredictionUnit &pu, const uint8_t splitDir else { m_if.weightedGeoBlk( pu, pu.lumaSize().width, pu.lumaSize().height, COMPONENT_Y, splitDir, predDst, predSrc0, predSrc1 ); -#if JVET_Q0438_MONOCHROME_BUGFIXES if (isChromaEnabled(pu.chromaFormat)) { -#endif m_if.weightedGeoBlk( pu, pu.chromaSize().width, pu.chromaSize().height, COMPONENT_Cb, splitDir, predDst, predSrc0, predSrc1 ); m_if.weightedGeoBlk( pu, pu.chromaSize().width, pu.chromaSize().height, COMPONENT_Cr, splitDir, predDst, predSrc0, predSrc1 ); -#if JVET_Q0438_MONOCHROME_BUGFIXES } -#endif } } -#endif void InterPrediction::xPrefetch(PredictionUnit& pu, PelUnitBuf &pcPad, RefPicList refId, bool forLuma) { @@ -1874,11 +1692,7 @@ void InterPrediction::xPad(PredictionUnit& pu, PelUnitBuf &pcPad, RefPicList ref int offset = 0, width, height; int padsize; Mv cMv; -#if JVET_Q0438_MONOCHROME_BUGFIXES for (int compID = 0; compID < getNumberValidComponents(pu.chromaFormat); compID++) -#else - for (int compID = 0; compID < MAX_NUM_COMPONENT; compID++) -#endif { int filtersize = (compID == (COMPONENT_Y)) ? NTAPS_LUMA : NTAPS_CHROMA; width = pcPad.bufs[compID].width; @@ -2027,7 +1841,7 @@ void InterPrediction::xFinalPaddedMCForDMVR(PredictionUnit& pu, PelUnitBuf &pcYu m_iRefListIdx = refId; const Picture* refPic = pu.cu->slice->getRefPic( refId, pu.refIdx[refId] )->unscaledPic; Mv cMvClipped = cMv; - if( !pu.cs->sps->getWrapAroundEnabledFlag() ) + if( !pu.cs->sps->getWrapAroundEnabledFlag() ) { clipMv( cMvClipped, pu.lumaPos(), pu.lumaSize(), *pu.cs->sps, *pu.cs->pps ); } @@ -2041,11 +1855,7 @@ void InterPrediction::xFinalPaddedMCForDMVR(PredictionUnit& pu, PelUnitBuf &pcYu pu.lx(), pu.ly(), pu.lwidth(), pu.lheight(), startMv.getHor(), startMv.getVer(), tileArea.topLeft().x, tileArea.topLeft().y, tileArea.bottomRight().x, tileArea.bottomRight().y ); THROW( "MCTS constraint failed!" ); } -#if JVET_Q0438_MONOCHROME_BUGFIXES for (int compID = 0; compID < getNumberValidComponents(pu.chromaFormat); compID++) -#else - for (int compID = 0; compID < MAX_NUM_COMPONENT; compID++) -#endif { Pel *srcBufPelPtr = NULL; int pcPadstride = 0; @@ -2328,26 +2138,18 @@ void InterPrediction::xProcessDMVR(PredictionUnit& pu, PelUnitBuf &pcYuvDst, con if (pu.mvdL0SubPu[num] != Mv(0, 0)) { blockMoved = true; -#if JVET_Q0438_MONOCHROME_BUGFIXES if (isChromaEnabled(pu.chromaFormat)) { -#endif xPrefetch(subPu, m_cYuvRefBuffDMVRL0, REF_PIC_LIST_0, 0); xPrefetch(subPu, m_cYuvRefBuffDMVRL1, REF_PIC_LIST_1, 0); -#if JVET_Q0438_MONOCHROME_BUGFIXES } -#endif xPad(subPu, m_cYuvRefBuffDMVRL0, REF_PIC_LIST_0); xPad(subPu, m_cYuvRefBuffDMVRL1, REF_PIC_LIST_1); } -#if JVET_Q0438_MONOCHROME_BUGFIXES int dstStride[MAX_NUM_COMPONENT] = { pcYuvDst.bufs[COMPONENT_Y].stride, isChromaEnabled(pu.chromaFormat) ? pcYuvDst.bufs[COMPONENT_Cb].stride : 0, isChromaEnabled(pu.chromaFormat) ? pcYuvDst.bufs[COMPONENT_Cr].stride : 0}; -#else - int dstStride[MAX_NUM_COMPONENT] = { pcYuvDst.bufs[COMPONENT_Y].stride, pcYuvDst.bufs[COMPONENT_Cb].stride, pcYuvDst.bufs[COMPONENT_Cr].stride }; -#endif subPu.mv[0] = mergeMv[REF_PIC_LIST_0] + pu.mvdL0SubPu[num]; subPu.mv[1] = mergeMv[REF_PIC_LIST_1] - pu.mvdL0SubPu[num]; @@ -2360,16 +2162,12 @@ void InterPrediction::xProcessDMVR(PredictionUnit& pu, PelUnitBuf &pcYuvDst, con subPredBuf.bufs[COMPONENT_Y].buf = pcYuvDst.bufs[COMPONENT_Y].buf + xStart + yStart * dstStride[COMPONENT_Y]; -#if JVET_Q0438_MONOCHROME_BUGFIXES if (isChromaEnabled(pu.chromaFormat)) { -#endif subPredBuf.bufs[COMPONENT_Cb].buf = pcYuvDst.bufs[COMPONENT_Cb].buf + (xStart >> scaleX) + ((yStart >> scaleY) * dstStride[COMPONENT_Cb]); subPredBuf.bufs[COMPONENT_Cr].buf = pcYuvDst.bufs[COMPONENT_Cr].buf + (xStart >> scaleX) + ((yStart >> scaleY) * dstStride[COMPONENT_Cr]); -#if JVET_Q0438_MONOCHROME_BUGFIXES } -#endif xWeightedAverage(subPu, srcPred0, srcPred1, subPredBuf, subPu.cu->slice->getSPS()->getBitDepths(), subPu.cu->slice->clpRngs(), bioAppliedType[num]); num++; } @@ -2501,11 +2299,7 @@ bool InterPrediction::xPredInterBlkRPR( const std::pair<int, int>& scalingRatio, int height = blk.height; CPelBuf refBuf; -#if JVET_Q0487_SCALING_WINDOW_ISSUES const bool scaled = refPic->isRefScaled( &pps ); -#else - const bool scaled = scalingRatio != SCALE_1X; -#endif if( scaled ) { @@ -2515,7 +2309,7 @@ bool InterPrediction::xPredInterBlkRPR( const std::pair<int, int>& scalingRatio, int xFilter = filterIndex; int yFilter = filterIndex; - const int rprThreshold1 = ( 1 << SCALE_RATIO_BITS ) * 5 / 4; + const int rprThreshold1 = ( 1 << SCALE_RATIO_BITS ) * 5 / 4; const int rprThreshold2 = ( 1 << SCALE_RATIO_BITS ) * 7 / 4; if( filterIndex == 0 ) { @@ -2537,7 +2331,6 @@ bool InterPrediction::xPredInterBlkRPR( const std::pair<int, int>& scalingRatio, yFilter = 3; } } -#if JVET_Q0517_RPR_AFFINE_DS if (filterIndex == 2) { if (isLuma(compID)) @@ -2581,7 +2374,6 @@ bool InterPrediction::xPredInterBlkRPR( const std::pair<int, int>& scalingRatio, } } } -#endif const int posShift = SCALE_RATIO_BITS - 4; int stepX = ( scalingRatio.first + 8 ) >> 4; @@ -2591,30 +2383,17 @@ bool InterPrediction::xPredInterBlkRPR( const std::pair<int, int>& scalingRatio, int offX = 1 << ( posShift - shiftHor - 1 ); int offY = 1 << ( posShift - shiftVer - 1 ); -#if JVET_Q0487_SCALING_WINDOW_ISSUES const int64_t posX = ( ( blk.pos().x << ::getComponentScaleX( compID, chFmt ) ) - ( pps.getScalingWindow().getWindowLeftOffset() * SPS::getWinUnitX( chFmt ) ) ) >> ::getComponentScaleX( compID, chFmt ); const int64_t posY = ( ( blk.pos().y << ::getComponentScaleY( compID, chFmt ) ) - ( pps.getScalingWindow().getWindowTopOffset() * SPS::getWinUnitY( chFmt ) ) ) >> ::getComponentScaleY( compID, chFmt ); -#else - const int64_t posX = ( ( blk.pos().x << ::getComponentScaleX( compID, chFmt ) ) - pps.getScalingWindow().getWindowLeftOffset() ) >> ::getComponentScaleX( compID, chFmt ); - const int64_t posY = ( ( blk.pos().y << ::getComponentScaleY( compID, chFmt ) ) - pps.getScalingWindow().getWindowTopOffset() ) >> ::getComponentScaleY( compID, chFmt ); -#endif int addX = isLuma( compID ) ? 0 : int( 1 - refPic->cs->sps->getHorCollocatedChromaFlag() ) * 8 * ( scalingRatio.first - SCALE_1X.first ); int addY = isLuma( compID ) ? 0 : int( 1 - refPic->cs->sps->getVerCollocatedChromaFlag() ) * 8 * ( scalingRatio.second - SCALE_1X.second ); x0Int = ( ( posX << ( 4 + ::getComponentScaleX( compID, chFmt ) ) ) + mv.getHor() ) * (int64_t)scalingRatio.first + addX; -#if JVET_Q0487_SCALING_WINDOW_ISSUES x0Int = SIGN( x0Int ) * ( ( llabs( x0Int ) + ( (long long)1 << ( 7 + ::getComponentScaleX( compID, chFmt ) ) ) ) >> ( 8 + ::getComponentScaleX( compID, chFmt ) ) ) + ( ( refPic->getScalingWindow().getWindowLeftOffset() * SPS::getWinUnitX( chFmt ) ) << ( ( posShift - ::getComponentScaleX( compID, chFmt ) ) ) ); -#else - x0Int = SIGN( x0Int ) * ( ( llabs( x0Int ) + ( (long long)1 << ( 7 + ::getComponentScaleX( compID, chFmt ) ) ) ) >> ( 8 + ::getComponentScaleX( compID, chFmt ) ) ) + ( refPic->getScalingWindow().getWindowLeftOffset() << ( ( posShift - ::getComponentScaleX( compID, chFmt ) ) ) ); -#endif y0Int = ( ( posY << ( 4 + ::getComponentScaleY( compID, chFmt ) ) ) + mv.getVer() ) * (int64_t)scalingRatio.second + addY; -#if JVET_Q0487_SCALING_WINDOW_ISSUES y0Int = SIGN( y0Int ) * ( ( llabs( y0Int ) + ( (long long)1 << ( 7 + ::getComponentScaleY( compID, chFmt ) ) ) ) >> ( 8 + ::getComponentScaleY( compID, chFmt ) ) ) + ( ( refPic->getScalingWindow().getWindowTopOffset() * SPS::getWinUnitY( chFmt ) ) << ( ( posShift - ::getComponentScaleY( compID, chFmt ) ) ) ); -#else - y0Int = SIGN( y0Int ) * ( ( llabs( y0Int ) + ( (long long)1 << ( 7 + ::getComponentScaleY( compID, chFmt ) ) ) ) >> ( 8 + ::getComponentScaleY( compID, chFmt ) ) ) + ( refPic->getScalingWindow().getWindowTopOffset() << ( ( posShift - ::getComponentScaleY( compID, chFmt ) ) ) ); -#endif const int extSize = isLuma( compID ) ? 1 : 2; int vFilterSize = isLuma( compID ) ? NTAPS_LUMA : NTAPS_CHROMA; @@ -2624,7 +2403,7 @@ bool InterPrediction::xPredInterBlkRPR( const std::pair<int, int>& scalingRatio, int xInt0 = ( (int32_t)x0Int + offX ) >> posShift; xInt0 = std::min( std::max( -(NTAPS_LUMA / 2), xInt0 ), ( refPicWidth >> ::getComponentScaleX( compID, chFmt ) ) + (NTAPS_LUMA / 2) ); - + int refHeight = ((((int32_t)y0Int + (height-1) * stepY) + offY ) >> posShift) - ((((int32_t)y0Int + 0 * stepY) + offY ) >> posShift) + 1; refHeight = std::max<int>( 1, refHeight ); @@ -2647,11 +2426,7 @@ bool InterPrediction::xPredInterBlkRPR( const std::pair<int, int>& scalingRatio, refBuf = refPic->getRecoBuf( CompArea( compID, chFmt, offset, Size( 1, refHeight ) ), wrapRef ); Pel* tempBuf = buffer + col; -#if JVET_Q0449_RPR_NO_SMOOTHING m_if.filterHor( compID, (Pel*)refBuf.buf - ( ( vFilterSize >> 1 ) - 1 ) * refBuf.stride, refBuf.stride, tempBuf, tmpStride, 1, refHeight + vFilterSize - 1 + extSize, xFrac, false, chFmt, clpRng, xFilter, false, useAltHpelIf && scalingRatio.first == 1 << SCALE_RATIO_BITS ); -#else - m_if.filterHor( compID, (Pel*)refBuf.buf - ( ( vFilterSize >> 1 ) - 1 ) * refBuf.stride, refBuf.stride, tempBuf, tmpStride, 1, refHeight + vFilterSize - 1 + extSize, xFrac, false, chFmt, clpRng, xFilter, false, useAltHpelIf ); -#endif } for( row = 0; row < height; row++ ) @@ -2666,11 +2441,7 @@ bool InterPrediction::xPredInterBlkRPR( const std::pair<int, int>& scalingRatio, Pel* tempBuf = buffer + ( yInt - yInt0 ) * tmpStride; JVET_J0090_SET_CACHE_ENABLE( false ); -#if JVET_Q0449_RPR_NO_SMOOTHING m_if.filterVer( compID, tempBuf + ( ( vFilterSize >> 1 ) - 1 ) * tmpStride, tmpStride, dst + row * dstStride, dstStride, width, 1, yFrac, false, rndRes, chFmt, clpRng, yFilter, false, useAltHpelIf && scalingRatio.second == 1 << SCALE_RATIO_BITS ); -#else - m_if.filterVer( compID, tempBuf + ( ( vFilterSize >> 1 ) - 1 ) * tmpStride, tmpStride, dst + row * dstStride, dstStride, width, 1, yFrac, false, rndRes, chFmt, clpRng, yFilter, false, useAltHpelIf ); -#endif JVET_J0090_SET_CACHE_ENABLE( true ); } } diff --git a/source/Lib/CommonLib/InterPrediction.h b/source/Lib/CommonLib/InterPrediction.h index a7455d46186a691fddb8ec20d96a67a12b29a729..6b67d430fbef514b8b34903db31209e541b9368c 100644 --- a/source/Lib/CommonLib/InterPrediction.h +++ b/source/Lib/CommonLib/InterPrediction.h @@ -81,11 +81,7 @@ protected: RdCost* m_pcRdCost; int m_iRefListIdx; -#if !JVET_Q0806 - PelStorage m_triangleBuf; -#else PelStorage m_geoPartBuf[2]; -#endif Mv* m_storedMv; /*buffers for bilinear Filter data for DMVR refinement*/ Pel* m_cYuvPredTempDMVRL0; @@ -142,9 +138,6 @@ protected: void xCalcBlkGradient (int sx, int sy, int *arraysGx2, int *arraysGxGy, int *arraysGxdI, int *arraysGy2, int *arraysGydI, int &sGx2, int &sGy2, int &sGxGy, int &sGxdI, int &sGydI, int width, int height, int unitSize); void xWeightedAverage ( const PredictionUnit& pu, const CPelUnitBuf& pcYuvSrc0, const CPelUnitBuf& pcYuvSrc1, PelUnitBuf& pcYuvDst, const BitDepths& clipBitDepths, const ClpRngs& clpRngs, const bool& bioApplied, const bool lumaOnly = false, const bool chromaOnly = false, PelUnitBuf* yuvDstTmp = NULL ); void xPredAffineBlk ( const ComponentID& compID, const PredictionUnit& pu, const Picture* refPic, const Mv* _mv, PelUnitBuf& dstPic, const bool& bi, const ClpRng& clpRng, const bool genChromaMv = false, const std::pair<int, int> scalingRatio = SCALE_1X ); -#if !JVET_Q0806 - void xWeightedTriangleBlk ( const PredictionUnit &pu, const uint32_t width, const uint32_t height, const ComponentID compIdx, const bool splitDir, PelUnitBuf& predDst, PelUnitBuf& predSrc0, PelUnitBuf& predSrc1 ); -#endif static bool xCheckIdenticalMotion( const PredictionUnit& pu ); @@ -177,13 +170,8 @@ public: , const bool luma = true, const bool chroma = true ); -#if !JVET_Q0806 - void motionCompensation4Triangle( CodingUnit &cu, MergeCtx &triangleMrgCtx, const bool splitDir, const uint8_t candIdx0, const uint8_t candIdx1 ); - void weightedTriangleBlk ( PredictionUnit &pu, const bool splitDir, int32_t channel, PelUnitBuf& predDst, PelUnitBuf& predSrc0, PelUnitBuf& predSrc1 ); -#else void motionCompensationGeo(CodingUnit &cu, MergeCtx &GeoMrgCtx); void weightedGeoBlk(PredictionUnit &pu, const uint8_t splitDir, int32_t channel, PelUnitBuf& predDst, PelUnitBuf& predSrc0, PelUnitBuf& predSrc1); -#endif void xPrefetch(PredictionUnit& pu, PelUnitBuf &pcPad, RefPicList refId, bool forLuma); void xPad(PredictionUnit& pu, PelUnitBuf &pcPad, RefPicList refId); void xFinalPaddedMCForDMVR(PredictionUnit& pu, PelUnitBuf &pcYuvSrc0, PelUnitBuf &pcYuvSrc1, PelUnitBuf &pcPad0, PelUnitBuf &pcPad1, const bool bioApplied diff --git a/source/Lib/CommonLib/InterpolationFilter.cpp b/source/Lib/CommonLib/InterpolationFilter.cpp index 5fb66c384000e6eb3a174233326180ed17e118c3..ba76ca68f389d381cec220441db1f715b1f6e6f5 100644 --- a/source/Lib/CommonLib/InterpolationFilter.cpp +++ b/source/Lib/CommonLib/InterpolationFilter.cpp @@ -136,7 +136,6 @@ const TFilterCoeff InterpolationFilter::m_lumaFilterRPR2[LUMA_INTERPOLATION_FILT { -2, -4, 5, 21, 29, 19, 0, -4 } }; -#if JVET_Q0517_RPR_AFFINE_DS // 1.5x const TFilterCoeff InterpolationFilter::m_affineLumaFilterRPR1[LUMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS][NTAPS_LUMA] = { @@ -178,7 +177,6 @@ const TFilterCoeff InterpolationFilter::m_affineLumaFilterRPR2[LUMA_INTERPOLATIO { 0, -6, 6, 22, 29, 18, -5, 0 }, { 0, -6, 5, 21, 29, 19, -4, 0 } }; -#endif const TFilterCoeff InterpolationFilter::m_lumaAltHpelIFilter[NTAPS_LUMA] = { 0, 3, 9, 20, 20, 9, 3, 0 }; const TFilterCoeff InterpolationFilter::m_chromaFilter[CHROMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS][NTAPS_CHROMA] = @@ -371,11 +369,7 @@ InterpolationFilter::InterpolationFilter() m_filterCopy[1][0] = filterCopy<true, false>; m_filterCopy[1][1] = filterCopy<true, true>; -#if !JVET_Q0806 - m_weightedTriangleBlk = xWeightedTriangleBlk; -#else m_weightedGeoBlk = xWeightedGeoBlk; -#endif } @@ -765,7 +759,6 @@ void InterpolationFilter::filterHor(const ComponentID compID, Pel const *src, in { filterHor<NTAPS_LUMA>( clpRng, src, srcStride, dst, dstStride, width, height, isLast, m_lumaFilterRPR2[frac], biMCForDMVR ); } -#if JVET_Q0517_RPR_AFFINE_DS else if (nFilterIdx == 5) { filterHor<NTAPS_LUMA>(clpRng, src, srcStride, dst, dstStride, width, height, isLast, m_affineLumaFilterRPR1[frac], biMCForDMVR); @@ -774,7 +767,6 @@ void InterpolationFilter::filterHor(const ComponentID compID, Pel const *src, in { filterHor<NTAPS_LUMA>(clpRng, src, srcStride, dst, dstStride, width, height, isLast, m_affineLumaFilterRPR2[frac], biMCForDMVR); } -#endif else if( frac == 8 && useAltHpelIf ) { filterHor<NTAPS_LUMA>( clpRng, src, srcStride, dst, dstStride, width, height, isLast, m_lumaAltHpelIFilter, biMCForDMVR ); @@ -850,7 +842,6 @@ void InterpolationFilter::filterVer(const ComponentID compID, Pel const *src, in { filterVer<NTAPS_LUMA>( clpRng, src, srcStride, dst, dstStride, width, height, isFirst, isLast, m_lumaFilterRPR2[frac], biMCForDMVR ); } -#if JVET_Q0517_RPR_AFFINE_DS else if (nFilterIdx == 5) { filterVer<NTAPS_LUMA>(clpRng, src, srcStride, dst, dstStride, width, height, isFirst, isLast, m_affineLumaFilterRPR1[frac], biMCForDMVR); @@ -859,7 +850,6 @@ void InterpolationFilter::filterVer(const ComponentID compID, Pel const *src, in { filterVer<NTAPS_LUMA>(clpRng, src, srcStride, dst, dstStride, width, height, isFirst, isLast, m_affineLumaFilterRPR2[frac], biMCForDMVR); } -#endif else if( frac == 8 && useAltHpelIf ) { filterVer<NTAPS_LUMA>( clpRng, src, srcStride, dst, dstStride, width, height, isFirst, isLast, m_lumaAltHpelIFilter, biMCForDMVR ); @@ -892,103 +882,6 @@ void InterpolationFilter::filterVer(const ComponentID compID, Pel const *src, in } } -#if !JVET_Q0806 -void InterpolationFilter::xWeightedTriangleBlk( const PredictionUnit &pu, const uint32_t width, const uint32_t height, const ComponentID compIdx, const bool splitDir, PelUnitBuf& predDst, PelUnitBuf& predSrc0, PelUnitBuf& predSrc1 ) -{ - Pel* dst = predDst .get(compIdx).buf; - Pel* src0 = predSrc0.get(compIdx).buf; - Pel* src1 = predSrc1.get(compIdx).buf; - int32_t strideDst = predDst .get(compIdx).stride - width; - int32_t strideSrc0 = predSrc0.get(compIdx).stride - width; - int32_t strideSrc1 = predSrc1.get(compIdx).stride - width; - - const char log2WeightBase = 3; - const ClpRng clipRng = pu.cu->slice->clpRngs().comp[compIdx]; - const int32_t clipbd = clipRng.bd; - const int32_t shiftDefault = std::max<int>(2, (IF_INTERNAL_PREC - clipbd)); - const int32_t offsetDefault = (1<<(shiftDefault-1)) + IF_INTERNAL_OFFS; - const int32_t shiftWeighted = std::max<int>(2, (IF_INTERNAL_PREC - clipbd)) + log2WeightBase; - const int32_t offsetWeighted = (1 << (shiftWeighted - 1)) + (IF_INTERNAL_OFFS << log2WeightBase); - int32_t stepX = 1 << getComponentScaleX(compIdx, pu.chromaFormat); - int32_t stepY = 1 << getComponentScaleY(compIdx, pu.chromaFormat); - - int32_t widthY = width << getComponentScaleX(compIdx, pu.chromaFormat); - int32_t heightY = height << getComponentScaleY(compIdx, pu.chromaFormat); - - int32_t ratioWH = (widthY > heightY) ? (widthY / heightY) : 1; - int32_t ratioHW = (widthY > heightY) ? 1 : (heightY / widthY); - - int32_t weightedLength = 7; - int32_t weightedStartPos = (splitDir == 0) ? (0 - (weightedLength >> 1) * ratioWH) : (widthY - ((weightedLength + 1) >> 1) * ratioWH); - int32_t weightedEndPos = weightedStartPos + weightedLength * ratioWH - 1; - int32_t weightedPosoffset = ( splitDir == 0 ) ? ratioWH : -ratioWH; - - Pel tmpPelWeighted; - int32_t weightIdx; - int32_t x, y, tmpX, tmpY, tmpWeightedStart, tmpWeightedEnd; - for (y = 0; y < heightY; y += ratioHW) - { - if (y % stepY != 0) - { - weightedStartPos += weightedPosoffset; - weightedEndPos += weightedPosoffset; - continue; - } - for (tmpY = ratioHW; tmpY > 0; tmpY -= stepY) - { - for (x = 0; x < weightedStartPos; x += stepX) - { - *dst++ = ClipPel( rightShift( (splitDir == 0 ? *src1 : *src0) + offsetDefault, shiftDefault), clipRng ); - src0++; - src1++; - } - - tmpWeightedStart = std::max((int32_t)0, weightedStartPos); - tmpWeightedEnd = std::min(weightedEndPos, (int32_t)(widthY - 1)); - weightIdx = 1; - if( weightedStartPos < 0 ) - { - weightIdx += abs(weightedStartPos) / ratioWH; - } - for( x = tmpWeightedStart; x <= tmpWeightedEnd; x+= ratioWH ) - { - if (x % stepX != 0) - { - weightIdx++; - continue; - } - - for (tmpX = ratioWH; tmpX > 0; tmpX -= stepX) - { - tmpPelWeighted = Clip3(1, 7, weightIdx); - tmpPelWeighted = splitDir ? ( 8 - tmpPelWeighted ) : tmpPelWeighted; - *dst++ = ClipPel( rightShift( (tmpPelWeighted*(*src0++) + ((8 - tmpPelWeighted) * (*src1++)) + offsetWeighted), shiftWeighted ), clipRng ); - } - weightIdx ++; - } - - int32_t start = ((weightedEndPos + 1) % stepX != 0) ? (weightedEndPos + 2) : (weightedEndPos + 1); - for (x = start; x < widthY; x += stepX) - { - *dst++ = ClipPel( rightShift( (splitDir == 0 ? *src0 : *src1) + offsetDefault, shiftDefault ), clipRng ); - src0++; - src1++; - } - - dst += strideDst; - src0 += strideSrc0; - src1 += strideSrc1; - } - weightedStartPos += weightedPosoffset; - weightedEndPos += weightedPosoffset; - } -} - -void InterpolationFilter::weightedTriangleBlk(const PredictionUnit &pu, const uint32_t width, const uint32_t height, const ComponentID compIdx, const bool splitDir, PelUnitBuf& predDst, PelUnitBuf& predSrc0, PelUnitBuf& predSrc1) -{ - m_weightedTriangleBlk(pu, width, height, compIdx, splitDir, predDst, predSrc0, predSrc1); -} -#else void InterpolationFilter::weightedGeoBlk(const PredictionUnit &pu, const uint32_t width, const uint32_t height, const ComponentID compIdx, const uint8_t splitDir, PelUnitBuf& predDst, PelUnitBuf& predSrc0, PelUnitBuf& predSrc1) { m_weightedGeoBlk(pu, width, height, compIdx, splitDir, predDst, predSrc0, predSrc1); @@ -1046,7 +939,6 @@ void InterpolationFilter::xWeightedGeoBlk(const PredictionUnit &pu, const uint32 weight += stepY; } } -#endif /** * \brief turn on SIMD fuc diff --git a/source/Lib/CommonLib/InterpolationFilter.h b/source/Lib/CommonLib/InterpolationFilter.h index c166395af7ec59bb1e37dad27a2c3436d81e0a96..58a811c38de9c75975c2044e23d90bc07a197b9f 100644 --- a/source/Lib/CommonLib/InterpolationFilter.h +++ b/source/Lib/CommonLib/InterpolationFilter.h @@ -63,10 +63,8 @@ public: static const TFilterCoeff m_lumaFilterRPR2[LUMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS][NTAPS_LUMA]; ///< Luma filter taps 2x static const TFilterCoeff m_chromaFilterRPR1[CHROMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS][NTAPS_CHROMA]; ///< Chroma filter taps 1.5x static const TFilterCoeff m_chromaFilterRPR2[CHROMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS][NTAPS_CHROMA]; ///< Chroma filter taps 2x -#if JVET_Q0517_RPR_AFFINE_DS static const TFilterCoeff m_affineLumaFilterRPR1[LUMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS][NTAPS_LUMA]; ///< Luma filter taps 1.5x static const TFilterCoeff m_affineLumaFilterRPR2[LUMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS][NTAPS_LUMA]; ///< Luma filter taps 2x -#endif private: static const TFilterCoeff m_lumaAltHpelIFilter[NTAPS_LUMA]; ///< Luma filter taps static const TFilterCoeff m_bilinearFilter[LUMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS][NTAPS_BILINEAR]; ///< bilinear filter taps @@ -83,13 +81,8 @@ public: template<int N> void filterVer(const ClpRng& clpRng, Pel const* src, int srcStride, Pel *dst, int dstStride, int width, int height, bool isFirst, bool isLast, TFilterCoeff const *coeff, bool biMCForDMVR); -#if !JVET_Q0806 - static void xWeightedTriangleBlk(const PredictionUnit &pu, const uint32_t width, const uint32_t height, const ComponentID compIdx, const bool splitDir, PelUnitBuf& predDst, PelUnitBuf& predSrc0, PelUnitBuf& predSrc1); - void weightedTriangleBlk(const PredictionUnit &pu, const uint32_t width, const uint32_t height, const ComponentID compIdx, const bool splitDir, PelUnitBuf& predDst, PelUnitBuf& predSrc0, PelUnitBuf& predSrc1); -#else static void xWeightedGeoBlk(const PredictionUnit &pu, const uint32_t width, const uint32_t height, const ComponentID compIdx, const uint8_t splitDir, PelUnitBuf& predDst, PelUnitBuf& predSrc0, PelUnitBuf& predSrc1); void weightedGeoBlk(const PredictionUnit &pu, const uint32_t width, const uint32_t height, const ComponentID compIdx, const uint8_t splitDir, PelUnitBuf& predDst, PelUnitBuf& predSrc0, PelUnitBuf& predSrc1); -#endif protected: #if JVET_J0090_MEMORY_BANDWITH_MEASURE static CacheModel* m_cacheModel; @@ -100,11 +93,7 @@ public: void( *m_filterHor[3][2][2] )( const ClpRng& clpRng, Pel const *src, int srcStride, Pel *dst, int dstStride, int width, int height, TFilterCoeff const *coeff, bool biMCForDMVR); void( *m_filterVer[3][2][2] )( const ClpRng& clpRng, Pel const *src, int srcStride, Pel *dst, int dstStride, int width, int height, TFilterCoeff const *coeff, bool biMCForDMVR); void( *m_filterCopy[2][2] ) ( const ClpRng& clpRng, Pel const *src, int srcStride, Pel *dst, int dstStride, int width, int height, bool biMCForDMVR); -#if !JVET_Q0806 - void( *m_weightedTriangleBlk )(const PredictionUnit &pu, const uint32_t width, const uint32_t height, const ComponentID compIdx, const bool splitDir, PelUnitBuf& predDst, PelUnitBuf& predSrc0, PelUnitBuf& predSrc1); -#else void( *m_weightedGeoBlk )(const PredictionUnit &pu, const uint32_t width, const uint32_t height, const ComponentID compIdx, const uint8_t splitDir, PelUnitBuf& predDst, PelUnitBuf& predSrc0, PelUnitBuf& predSrc1); -#endif void initInterpolationFilter( bool enable ); #ifdef TARGET_SIMD_X86 diff --git a/source/Lib/CommonLib/IntraPrediction.cpp b/source/Lib/CommonLib/IntraPrediction.cpp index 3bb4c1b3924c5341522eaf47dd9a861d6e7712fb..1b148e41e9a2fab085284a5bf5ebf042ca27a8af 100644 --- a/source/Lib/CommonLib/IntraPrediction.cpp +++ b/source/Lib/CommonLib/IntraPrediction.cpp @@ -217,6 +217,9 @@ void IntraPrediction::predIntraAng( const ComponentID compId, PelBuf &piPred, co const int iWidth = piPred.width; const int iHeight = piPred.height; CHECK(iWidth == 2, "Width of 2 is not supported"); +#if JVET_R0350_MIP_CHROMA_444_SINGLETREE + CHECK(PU::isMIP(pu, toChannelType(compId)), "We should not get here for MIP."); +#endif const uint32_t uiDirMode = isLuma( compId ) && pu.cu->bdpcmMode ? BDPCM_IDX : !isLuma(compId) && pu.cu->bdpcmModeChroma ? BDPCM_IDX : PU::getFinalIntraMode(pu, channelType); CHECK( floorLog2(iWidth) < 2 && pu.cs->pcv->noChroma2x2, "Size not allowed" ); @@ -365,11 +368,7 @@ void IntraPrediction::initPredIntraParams(const PredictionUnit & pu, const CompA m_ipaParam.multiRefIndex = isLuma (chType) ? pu.multiRefIdx : 0 ; m_ipaParam.refFilterFlag = false; m_ipaParam.interpolationFlag = false; -#if JVET_Q0293_REMOVAL_PDPC_CHROMA_NX2 m_ipaParam.applyPDPC = (puSize.width >= MIN_TB_SIZEY && puSize.height >= MIN_TB_SIZEY) && m_ipaParam.multiRefIndex == 0; -#else - m_ipaParam.applyPDPC = ((puSize.width >= MIN_TB_SIZEY && puSize.height >= MIN_TB_SIZEY) || !isLuma(compId)) && m_ipaParam.multiRefIndex == 0; -#endif const int intraPredAngleMode = (m_ipaParam.isModeVer) ? predMode - VER_IDX : -(predMode - HOR_IDX); @@ -743,12 +742,10 @@ void IntraPrediction::geneIntrainterPred(const CodingUnit &cu) initIntraPatternChType(cu, pu->Y()); predIntraAng(COMPONENT_Y, cu.cs->getPredBuf(*pu).Y(), *pu); -#if JVET_Q0438_MONOCHROME_BUGFIXES int maxCompID = 1; if (isChromaEnabled(pu->chromaFormat)) { maxCompID = MAX_NUM_COMPONENT; -#endif if (pu->chromaSize().width > 2) { initIntraPatternChType(cu, pu->Cb()); @@ -757,7 +754,6 @@ void IntraPrediction::geneIntrainterPred(const CodingUnit &cu) initIntraPatternChType(cu, pu->Cr()); predIntraAng(COMPONENT_Cr, cu.cs->getPredBuf(*pu).Cr(), *pu); } -#if JVET_Q0438_MONOCHROME_BUGFIXES } for (int currCompID = 0; currCompID < maxCompID; currCompID++) { @@ -765,12 +761,6 @@ void IntraPrediction::geneIntrainterPred(const CodingUnit &cu) { continue; } -#else - for (int currCompID = 0; currCompID < 3; currCompID++) - { - if (pu->chromaSize().width <= 2 && currCompID > 0) - continue; -#endif ComponentID currCompID2 = (ComponentID)currCompID; PelBuf tmpBuf = currCompID == 0 ? cu.cs->getPredBuf(*pu).Y() : (currCompID == 1 ? cu.cs->getPredBuf(*pu).Cb() : cu.cs->getPredBuf(*pu).Cr()); switchBuffer(*pu, currCompID2, tmpBuf, getPredictorPtr2(currCompID2, 0)); @@ -1360,7 +1350,6 @@ void IntraPrediction::xGetLumaRecPixels(const PredictionUnit &pu, CompArea chrom int logSubHeightC = getChannelTypeScaleY(CHANNEL_TYPE_CHROMA, pu.chromaFormat); int iRecStride2 = iRecStride << logSubHeightC; - const int mult = 1 << logSubWidthC ; const CodingUnit& lumaCU = isChroma( pu.chType ) ? *pu.cs->picture->cs->getCU( lumaArea.pos(), CH_L ) : *pu.cu; const CodingUnit& cu = *pu.cu; @@ -1395,24 +1384,24 @@ void IntraPrediction::xGetLumaRecPixels(const PredictionUnit &pu, CompArea chrom int avaiLeftBelowUnits = 0; bool bNeighborFlags[4 * MAX_NUM_PART_IDXS_IN_CTU_WIDTH + 1]; memset(bNeighborFlags, 0, totalUnits); - bool bAboveAvaillable, bLeftAvaillable; + bool aboveIsAvailable, leftIsAvailable; int availlableUnit = isLeftAvailable( isChroma( pu.chType ) ? cu : lumaCU, toChannelType( area.compID ), area.pos(), iLeftUnits, iUnitHeight, ( bNeighborFlags + iLeftUnits + leftBelowUnits - 1 ) ); - bLeftAvaillable = availlableUnit == iTUHeightInUnits; + leftIsAvailable = availlableUnit == iTUHeightInUnits; availlableUnit = isAboveAvailable( isChroma( pu.chType ) ? cu : lumaCU, toChannelType( area.compID ), area.pos(), iAboveUnits, iUnitWidth, ( bNeighborFlags + iLeftUnits + leftBelowUnits + 1 ) ); - bAboveAvaillable = availlableUnit == iTUWidthInUnits; + aboveIsAvailable = availlableUnit == iTUWidthInUnits; - if (bLeftAvaillable) // if left is not available, then the below left is not available + if (leftIsAvailable) // if left is not available, then the below left is not available { avaiLeftBelowUnits = isBelowLeftAvailable(isChroma(pu.chType) ? cu : lumaCU, toChannelType(area.compID), area.bottomLeftComp(area.compID), leftBelowUnits, iUnitHeight, (bNeighborFlags + leftBelowUnits - 1)); } - if (bAboveAvaillable) // if above is not available, then the above right is not available. + if (aboveIsAvailable) // if above is not available, then the above right is not available. { avaiAboveRightUnits = isAboveRightAvailable(isChroma(pu.chType) ? cu : lumaCU, toChannelType(area.compID), area.topRightComp(area.compID), aboveRightUnits, iUnitWidth, (bNeighborFlags + iLeftUnits + leftBelowUnits + iAboveUnits + 1)); } @@ -1420,40 +1409,9 @@ void IntraPrediction::xGetLumaRecPixels(const PredictionUnit &pu, CompArea chrom Pel* pDst = nullptr; Pel const* piSrc = nullptr; - bool isFirstRowOfCtu = ( lumaArea.y & ((pu.cs->sps)->getCTUSize() - 1) ) == 0; - const int strOffset = (CHROMA_444 == pu.chromaFormat) ? 0 : iRecStride; -#if !JVET_Q0500_CCLM_REF_PADDING - int c0_2tap = 1, c1_2tap = 1, offset_2tap = 1, shift_2tap = 1; //sum = 2 -#endif - int c0_3tap = 2, c1_3tap = 1, c2_3tap = 1, offset_3tap = 2, shift_3tap = 2; //sum = 4 - int c0_5tap = 1, c1_5tap = 4, c2_5tap = 1, c3_5tap = 1, c4_5tap = 1, offset_5tap = 4, shift_5tap = 3; //sum = 8 - int c0_6tap = 2, c1_6tap = 1, c2_6tap = 1, c3_6tap = 2, c4_6tap = 1, c5_6tap = 1, offset_6tap = 4, shift_6tap = 3; //sum = 8 + bool isFirstRowOfCtu = (lumaArea.y & ((pu.cs->sps)->getCTUSize() - 1)) == 0; - switch (pu.chromaFormat) - { - case CHROMA_422: //overwrite filter coefficient values for 422 -#if !JVET_Q0500_CCLM_REF_PADDING - c0_2tap = 1, c1_2tap = 0, offset_2tap = 0, shift_2tap = 0; //sum = 1 -#endif - c0_3tap = 2, c1_3tap = 1, c2_3tap = 1, offset_3tap = 2, shift_3tap = 2; //sum = 4 - c0_5tap = 0, c1_5tap = 1, c2_5tap = 0, c3_5tap = 0, c4_5tap = 0, offset_5tap = 0, shift_5tap = 0; //sum = 1 - c0_6tap = 2, c1_6tap = 1, c2_6tap = 1, c3_6tap = 0, c4_6tap = 0, c5_6tap = 0, offset_6tap = 2, shift_6tap = 2; //sum = 4 - break; - - case CHROMA_444: //overwrite filter coefficient values for 422 -#if !JVET_Q0500_CCLM_REF_PADDING - c0_2tap = 1, c1_2tap = 0, offset_2tap = 0, shift_2tap = 0; //sum = 1 -#endif - c0_3tap = 1, c1_3tap = 0, c2_3tap = 0, offset_3tap = 0, shift_3tap = 0; //sum = 1 - c0_5tap = 0, c1_5tap = 1, c2_5tap = 0, c3_5tap = 0, c4_5tap = 0, offset_5tap = 0, shift_5tap = 0; //sum = 1 - c0_6tap = 1, c1_6tap = 0, c2_6tap = 0, c3_6tap = 0, c4_6tap = 0, c5_6tap = 0, offset_6tap = 0, shift_6tap = 0; //sum = 1 - break; - - default: - break; - } - - if( bAboveAvaillable ) + if (aboveIsAvailable) { pDst = pDst0 - iDstStride; int addedAboveRight = 0; @@ -1463,75 +1421,58 @@ void IntraPrediction::xGetLumaRecPixels(const PredictionUnit &pu, CompArea chrom } for (int i = 0; i < uiCWidth + addedAboveRight; i++) { - if (isFirstRowOfCtu) + const bool leftPadding = i == 0 && !leftIsAvailable; + if (pu.chromaFormat == CHROMA_444) { piSrc = pRecSrc0 - iRecStride; + pDst[i] = piSrc[i]; + } + else if (isFirstRowOfCtu) + { + piSrc = pRecSrc0 - iRecStride; + pDst[i] = (piSrc[2 * i] * 2 + piSrc[2 * i - (leftPadding ? 0 : 1)] + piSrc[2 * i + 1] + 2) >> 2; + } + else if (pu.chromaFormat == CHROMA_422) + { + piSrc = pRecSrc0 - iRecStride2; - if ((i == 0 && !bLeftAvaillable) || (i == uiCWidth + addedAboveRight - 1 + logSubWidthC)) - { -#if JVET_Q0500_CCLM_REF_PADDING - pDst[i] = (piSrc[mult * i] * c0_3tap + piSrc[mult * i] * c1_3tap + piSrc[mult * i + 1] * c2_3tap + offset_3tap) >> shift_3tap; -#else - pDst[i] = piSrc[mult * i]; -#endif - } - else - { - pDst[i] = (piSrc[mult * i] * c0_3tap + piSrc[mult * i - 1] * c1_3tap + piSrc[mult * i + 1] * c2_3tap + offset_3tap) >> shift_3tap; - } + int s = 2; + s += piSrc[2 * i] * 2; + s += piSrc[2 * i - (leftPadding ? 0 : 1)]; + s += piSrc[2 * i + 1]; + pDst[i] = s >> 2; } - else if( pu.cs->sps->getCclmCollocatedChromaFlag() ) + else if (pu.cs->sps->getCclmCollocatedChromaFlag()) { piSrc = pRecSrc0 - iRecStride2; - if ((i == 0 && !bLeftAvaillable) || (i == uiCWidth + addedAboveRight - 1 + logSubWidthC)) - { -#if JVET_Q0500_CCLM_REF_PADDING - pDst[i] = (piSrc[mult * i - strOffset] * c0_5tap - + piSrc[mult * i] * c1_5tap + piSrc[mult * i] * c2_5tap + piSrc[mult * i + 1] * c3_5tap - + piSrc[mult * i + strOffset] * c4_5tap - + offset_5tap) >> shift_5tap; -#else - pDst[i] = (piSrc[mult * i] * c0_3tap + piSrc[mult * i - strOffset] * c1_3tap + piSrc[mult * i + strOffset] * c2_3tap + offset_3tap) >> shift_3tap; -#endif - } - else - { - pDst[i] = (piSrc[mult * i - strOffset] * c0_5tap - + piSrc[mult * i] * c1_5tap + piSrc[mult * i - 1] * c2_5tap + piSrc[mult * i + 1] * c3_5tap - + piSrc[mult * i + strOffset] * c4_5tap - + offset_5tap) >> shift_5tap; - } + int s = 4; + s += piSrc[2 * i - iRecStride]; + s += piSrc[2 * i] * 4; + s += piSrc[2 * i - (leftPadding ? 0 : 1)]; + s += piSrc[2 * i + 1]; + s += piSrc[2 * i + iRecStride]; + pDst[i] = s >> 3; } else { piSrc = pRecSrc0 - iRecStride2; - - if ((i == 0 && !bLeftAvaillable) || (i == uiCWidth + addedAboveRight - 1 + logSubWidthC)) - { -#if JVET_Q0500_CCLM_REF_PADDING - pDst[i] = ((piSrc[mult * i] * c0_6tap + piSrc[mult * i] * c1_6tap + piSrc[mult * i + 1] * c2_6tap) - + (piSrc[mult * i + strOffset] * c3_6tap + piSrc[mult * i + strOffset] * c4_6tap + piSrc[mult * i + 1 + strOffset] * c5_6tap) - + offset_6tap) >> shift_6tap; -#else - pDst[i] = (piSrc[mult * i] * c0_2tap + piSrc[mult * i + strOffset] * c1_2tap + offset_2tap) >> shift_2tap; -#endif - } - else - { - pDst[i] = ((piSrc[mult * i] * c0_6tap + piSrc[mult * i - 1] * c1_6tap + piSrc[mult * i + 1] * c2_6tap) - + (piSrc[mult * i + strOffset] * c3_6tap + piSrc[mult * i - 1 + strOffset] * c4_6tap + piSrc[mult * i + 1 + strOffset] * c5_6tap) - + offset_6tap) >> shift_6tap; - } + int s = 4; + s += piSrc[2 * i] * 2; + s += piSrc[2 * i + 1]; + s += piSrc[2 * i - (leftPadding ? 0 : 1)]; + s += piSrc[2 * i + iRecStride] * 2; + s += piSrc[2 * i + 1 + iRecStride]; + s += piSrc[2 * i + iRecStride - (leftPadding ? 0 : 1)]; + pDst[i] = s >> 3; } } } - if( bLeftAvaillable ) + if (leftIsAvailable) { pDst = pDst0 - 1; - - piSrc = pRecSrc0 - 2 - logSubWidthC; + piSrc = pRecSrc0 - 1 - logSubWidthC; int addedLeftBelow = 0; if ((curChromaMode == MDLM_L_IDX) || (curChromaMode == MDLM_T_IDX)) @@ -1541,32 +1482,40 @@ void IntraPrediction::xGetLumaRecPixels(const PredictionUnit &pu, CompArea chrom for (int j = 0; j < uiCHeight + addedLeftBelow; j++) { - if( pu.cs->sps->getCclmCollocatedChromaFlag() ) + if (pu.chromaFormat == CHROMA_444) { - if ((j == 0 && !bAboveAvaillable) || (j == uiCHeight + addedLeftBelow - 1 + logSubWidthC)) - { -#if JVET_Q0500_CCLM_REF_PADDING - pDst[0] = ( piSrc[1 ] * c0_5tap - + piSrc[1 ] * c1_5tap + piSrc[0] * c2_5tap + piSrc[2] * c3_5tap - + piSrc[1 + strOffset] * c4_5tap - + offset_5tap ) >> shift_5tap; -#else - pDst[0] = ( piSrc[1] * c0_3tap + piSrc[0] * c1_3tap + piSrc[2] * c2_3tap + offset_3tap) >> shift_3tap; -#endif - } - else - { - pDst[0] = ( piSrc[1 - strOffset] * c0_5tap - + piSrc[1 ] * c1_5tap + piSrc[0] * c2_5tap + piSrc[2] * c3_5tap - + piSrc[1 + strOffset] * c4_5tap - + offset_5tap ) >> shift_5tap; - } + pDst[0] = piSrc[0]; + } + else if (pu.chromaFormat == CHROMA_422) + { + int s = 2; + s += piSrc[0] * 2; + s += piSrc[-1]; + s += piSrc[1]; + pDst[0] = s >> 2; + } + else if (pu.cs->sps->getCclmCollocatedChromaFlag()) + { + const bool abovePadding = j == 0 && !aboveIsAvailable; + + int s = 4; + s += piSrc[-(abovePadding ? 0 : iRecStride)]; + s += piSrc[0] * 4; + s += piSrc[-1]; + s += piSrc[1]; + s += piSrc[iRecStride]; + pDst[0] = s >> 3; } else { - pDst[0] = ((piSrc[1] * c0_6tap + piSrc[0] * c1_6tap + piSrc[2] * c2_6tap) - + (piSrc[1 + strOffset] * c3_6tap + piSrc[strOffset] * c4_6tap + piSrc[2 + strOffset] * c5_6tap) - + offset_6tap) >> shift_6tap; + int s = 4; + s += piSrc[0] * 2; + s += piSrc[1]; + s += piSrc[-1]; + s += piSrc[iRecStride] * 2; + s += piSrc[iRecStride + 1]; + s += piSrc[iRecStride - 1]; + pDst[0] = s >> 3; } piSrc += iRecStride2; @@ -1579,87 +1528,46 @@ void IntraPrediction::xGetLumaRecPixels(const PredictionUnit &pu, CompArea chrom { for( int i = 0; i < uiCWidth; i++ ) { - if( pu.cs->sps->getCclmCollocatedChromaFlag() ) + if (pu.chromaFormat == CHROMA_444) { - if( i == 0 && !bLeftAvaillable ) - { - if ( j == 0 && !bAboveAvaillable ) - { -#if JVET_Q0500_CCLM_REF_PADDING - pDst0[i] = (pRecSrc0[mult * i] * c0_5tap - + pRecSrc0[mult * i] * c1_5tap + pRecSrc0[mult * i] * c2_5tap + pRecSrc0[mult * i + 1] * c3_5tap - + pRecSrc0[mult * i + strOffset] * c4_5tap - + offset_5tap) >> shift_5tap; -#else - pDst0[i] = pRecSrc0[mult * i]; -#endif - } - else - { -#if JVET_Q0500_CCLM_REF_PADDING - pDst0[i] = (pRecSrc0[mult * i - strOffset] * c0_5tap - + pRecSrc0[mult * i] * c1_5tap + pRecSrc0[mult * i] * c2_5tap + pRecSrc0[mult * i + 1] * c3_5tap - + pRecSrc0[mult * i + strOffset] * c4_5tap - + offset_5tap) >> shift_5tap; -#else - pDst0[i] = (pRecSrc0[mult * i] * c0_3tap + pRecSrc0[mult * i - strOffset] * c1_3tap + pRecSrc0[mult * i + strOffset] * c2_3tap + offset_3tap) >> shift_3tap; -#endif - } - } - else if ( j == 0 && !bAboveAvaillable ) - { -#if JVET_Q0500_CCLM_REF_PADDING - pDst0[i] = (pRecSrc0[mult * i] * c0_5tap - + pRecSrc0[mult * i] * c1_5tap + pRecSrc0[mult * i - 1] * c2_5tap + pRecSrc0[mult * i + 1] * c3_5tap - + pRecSrc0[mult * i + strOffset] * c4_5tap - + offset_5tap) >> shift_5tap; -#else - pDst0[i] = (pRecSrc0[mult * i] * c0_3tap + pRecSrc0[mult * i - 1] * c1_3tap + pRecSrc0[mult * i + 1] * c2_3tap + offset_3tap) >> shift_3tap; -#endif - } - else - { - pDst0[i] = (pRecSrc0[mult * i - strOffset] * c0_5tap - + pRecSrc0[mult * i] * c1_5tap + pRecSrc0[mult * i - 1] * c2_5tap + pRecSrc0[mult * i + 1] * c3_5tap - + pRecSrc0[mult * i + strOffset] * c4_5tap - + offset_5tap) >> shift_5tap; - } + pDst0[i] = pRecSrc0[i]; } - else + else if (pu.chromaFormat == CHROMA_422) { + const bool leftPadding = i == 0 && !leftIsAvailable; - if ((i == 0 && !bLeftAvaillable) || (i == uiCWidth - 1 + logSubWidthC)) - { -#if JVET_Q0500_CCLM_REF_PADDING - int s = offset_6tap; - s += pRecSrc0[mult * i] * c0_6tap; - s += pRecSrc0[mult * i + 1] * c1_6tap; - s += pRecSrc0[mult * i] * c2_6tap; - if (pu.chromaFormat == CHROMA_420) - { - s += pRecSrc0[mult * i + strOffset] * c3_6tap; - s += pRecSrc0[mult * i + 1 + strOffset] * c4_6tap; - s += pRecSrc0[mult * i + strOffset] * c5_6tap; - } - pDst0[i] = s >> shift_6tap; -#else - pDst0[i] = (pRecSrc0[mult * i] * c0_2tap + pRecSrc0[mult * i + strOffset] * c1_2tap + offset_2tap) >> shift_2tap; -#endif - } - else - { - int s = offset_6tap; - s += pRecSrc0[mult * i] * c0_6tap; - s += pRecSrc0[mult * i + 1] * c1_6tap; - s += pRecSrc0[mult * i - 1] * c2_6tap; - if (pu.chromaFormat == CHROMA_420) - { - s += pRecSrc0[mult * i + strOffset] * c3_6tap; - s += pRecSrc0[mult * i + 1 + strOffset] * c4_6tap; - s += pRecSrc0[mult * i - 1 + strOffset] * c5_6tap; - } - pDst0[i] = s >> shift_6tap; - } + int s = 2; + s += pRecSrc0[2 * i] * 2; + s += pRecSrc0[2 * i - (leftPadding ? 0 : 1)]; + s += pRecSrc0[2 * i + 1]; + pDst0[i] = s >> 2; + } + else if (pu.cs->sps->getCclmCollocatedChromaFlag()) + { + const bool leftPadding = i == 0 && !leftIsAvailable; + const bool abovePadding = j == 0 && !aboveIsAvailable; + + int s = 4; + s += pRecSrc0[2 * i - (abovePadding ? 0 : iRecStride)]; + s += pRecSrc0[2 * i] * 4; + s += pRecSrc0[2 * i - (leftPadding ? 0 : 1)]; + s += pRecSrc0[2 * i + 1]; + s += pRecSrc0[2 * i + iRecStride]; + pDst0[i] = s >> 3; + } + else + { + CHECK(pu.chromaFormat != CHROMA_420, "Chroma format must be 4:2:0 for vertical filtering"); + const bool leftPadding = i == 0 && !leftIsAvailable; + + int s = 4; + s += pRecSrc0[2 * i] * 2; + s += pRecSrc0[2 * i + 1]; + s += pRecSrc0[2 * i - (leftPadding ? 0 : 1)]; + s += pRecSrc0[2 * i + iRecStride] * 2; + s += pRecSrc0[2 * i + 1 + iRecStride]; + s += pRecSrc0[2 * i + iRecStride - (leftPadding ? 0 : 1)]; + pDst0[i] = s >> 3; } } @@ -1890,24 +1798,62 @@ void IntraPrediction::initIntraMip( const PredictionUnit &pu, const CompArea &ar // prepare input (boundary) data for prediction CHECK( m_ipaParam.refFilterFlag, "ERROR: unfiltered refs expected for MIP" ); +#if JVET_R0350_MIP_CHROMA_444_SINGLETREE + Pel *ptrSrc = getPredictorPtr(area.compID); + const int srcStride = m_refBufferStride[area.compID]; + const int srcHStride = 2; + + m_matrixIntraPred.prepareInputForPred(CPelBuf(ptrSrc, srcStride, srcHStride), area, + pu.cu->slice->getSPS()->getBitDepth(toChannelType(area.compID)), area.compID); +#else Pel *ptrSrc = getPredictorPtr( COMPONENT_Y ); const int srcStride = m_refBufferStride[COMPONENT_Y]; const int srcHStride = 2; m_matrixIntraPred.prepareInputForPred( CPelBuf( ptrSrc, srcStride, srcHStride ), area, pu.cu->slice->getSPS()->getBitDepth( CHANNEL_TYPE_LUMA ) ); +#endif } void IntraPrediction::predIntraMip( const ComponentID compId, PelBuf &piPred, const PredictionUnit &pu ) { +#if !JVET_R0350_MIP_CHROMA_444_SINGLETREE CHECK( compId != COMPONENT_Y, "Error: chroma not supported" ); +#endif CHECK( piPred.width > MIP_MAX_WIDTH || piPred.height > MIP_MAX_HEIGHT, "Error: block size not supported for MIP" ); CHECK( piPred.width != (1 << floorLog2(piPred.width)) || piPred.height != (1 << floorLog2(piPred.height)), "Error: expecting blocks of size 2^M x 2^N" ); // generate mode-specific prediction +#if JVET_R0350_MIP_CHROMA_444_SINGLETREE + uint32_t modeIdx = MAX_NUM_MIP_MODE; + bool transposeFlag = false; + if (compId == COMPONENT_Y) + { + modeIdx = pu.intraDir[CHANNEL_TYPE_LUMA]; + transposeFlag = pu.mipTransposedFlag; + } + else + { + const PredictionUnit &coLocatedLumaPU = PU::getCoLocatedLumaPU(pu); + + CHECK(pu.intraDir[CHANNEL_TYPE_CHROMA] != DM_CHROMA_IDX, "Error: MIP is only supported for chroma with DM_CHROMA."); + CHECK(!coLocatedLumaPU.cu->mipFlag, "Error: Co-located luma CU should use MIP."); + + modeIdx = coLocatedLumaPU.intraDir[CHANNEL_TYPE_LUMA]; + transposeFlag = coLocatedLumaPU.mipTransposedFlag; + } + const int bitDepth = pu.cu->slice->getSPS()->getBitDepth(toChannelType(compId)); + + CHECK(modeIdx >= getNumModesMip(piPred), "Error: Wrong MIP mode index"); +#else const int bitDepth = pu.cu->slice->getSPS()->getBitDepth( CHANNEL_TYPE_LUMA ); +#endif static_vector<int, MIP_MAX_WIDTH* MIP_MAX_HEIGHT> predMip( piPred.width * piPred.height ); +#if JVET_R0350_MIP_CHROMA_444_SINGLETREE + m_matrixIntraPred.predBlock(predMip.data(), modeIdx, transposeFlag, bitDepth, compId); +#else m_matrixIntraPred.predBlock( predMip.data(), pu.intraDir[CHANNEL_TYPE_LUMA], pu.mipTransposedFlag, bitDepth ); +#endif for( int y = 0; y < piPred.height; y++ ) { @@ -1943,10 +1889,8 @@ void IntraPrediction::reorderPLT(CodingStructure& cs, Partitioner& partitioner, for (curidx = 0; curidx < cu.curPLTSize[compBegin]; curidx++) { -#if JVET_Q0504_PLT_NON444 if( curPLTpred[curidx] ) continue; -#endif bool matchTmp = true; for (int comp = compBegin; comp < (compBegin + numComp); comp++) { @@ -1963,7 +1907,6 @@ void IntraPrediction::reorderPLT(CodingStructure& cs, Partitioner& partitioner, { cu.reuseflag[compBegin][predidx] = true; curPLTpred[curidx] = true; -#if JVET_Q0504_PLT_NON444 if( cu.isLocalSepTree() ) { cu.reuseflag[COMPONENT_Y][predidx] = true; @@ -1974,14 +1917,11 @@ void IntraPrediction::reorderPLT(CodingStructure& cs, Partitioner& partitioner, } else { -#endif for (int comp = compBegin; comp < (compBegin + numComp); comp++) { curPLTtmp[comp][reusePLTSizetmp] = cs.prevPLT.curPLT[comp][predidx]; } -#if JVET_Q0504_PLT_NON444 } -#endif reusePLTSizetmp++; pltSizetmp++; } @@ -1991,7 +1931,6 @@ void IntraPrediction::reorderPLT(CodingStructure& cs, Partitioner& partitioner, { if (!curPLTpred[curidx]) { -#if JVET_Q0504_PLT_NON444 if( cu.isLocalSepTree() ) { for( int comp = compBegin; comp < (compBegin + numComp); comp++ ) @@ -2010,21 +1949,17 @@ void IntraPrediction::reorderPLT(CodingStructure& cs, Partitioner& partitioner, } else { -#endif for (int comp = compBegin; comp < (compBegin + numComp); comp++) { curPLTtmp[comp][pltSizetmp] = cu.curPLT[comp][curidx]; } -#if JVET_Q0504_PLT_NON444 } -#endif pltSizetmp++; } } assert(pltSizetmp == cu.curPLTSize[compBegin]); for (int curidx = 0; curidx < cu.curPLTSize[compBegin]; curidx++) { -#if JVET_Q0504_PLT_NON444 if( cu.isLocalSepTree() ) { for( int comp = COMPONENT_Y; comp < MAX_NUM_COMPONENT; comp++ ) @@ -2034,14 +1969,11 @@ void IntraPrediction::reorderPLT(CodingStructure& cs, Partitioner& partitioner, } else { -#endif for (int comp = compBegin; comp < (compBegin + numComp); comp++) { cu.curPLT[comp][curidx] = curPLTtmp[comp][curidx]; } -#if JVET_Q0504_PLT_NON444 } -#endif } } //! \} diff --git a/source/Lib/CommonLib/LoopFilter.cpp b/source/Lib/CommonLib/LoopFilter.cpp index 97335e5e3d238344423b98b98e1462f0322c4542..46d300d50d7be5c6d3ec34f9926d54ce9ecbe185 100644 --- a/source/Lib/CommonLib/LoopFilter.cpp +++ b/source/Lib/CommonLib/LoopFilter.cpp @@ -81,30 +81,14 @@ inline static uint32_t getRasterIdx(const Position& pos, const PreCalcValues& pc // ==================================================================================================================== // utility functions // ==================================================================================================================== -#if JVET_O1143_LPF_ACROSS_SUBPIC_BOUNDARY static bool isAvailableLeft( const CodingUnit& cu, const CodingUnit& cu2, const bool bEnforceSliceRestriction, const bool bEnforceTileRestriction, const bool bEnforceSubPicRestriction) -#else -static bool isAvailableLeft( const CodingUnit& cu, const CodingUnit& cu2, const bool bEnforceSliceRestriction, const bool bEnforceTileRestriction) -#endif { -#if JVET_O1143_LPF_ACROSS_SUBPIC_BOUNDARY return ((!bEnforceSliceRestriction || CU::isSameSlice(cu, cu2)) && (!bEnforceTileRestriction || CU::isSameTile(cu, cu2)) && (!bEnforceSubPicRestriction || CU::isSameSubPic(cu, cu2))); -#else - return ((!bEnforceSliceRestriction || CU::isSameSlice(cu, cu2)) && (!bEnforceTileRestriction || CU::isSameTile(cu, cu2))); -#endif } -#if JVET_O1143_LPF_ACROSS_SUBPIC_BOUNDARY static bool isAvailableAbove( const CodingUnit& cu, const CodingUnit& cu2, const bool bEnforceSliceRestriction, const bool bEnforceTileRestriction, const bool bEnforceSubPicRestriction) -#else -static bool isAvailableAbove( const CodingUnit& cu, const CodingUnit& cu2, const bool bEnforceSliceRestriction, const bool bEnforceTileRestriction) -#endif { -#if JVET_O1143_LPF_ACROSS_SUBPIC_BOUNDARY return ( !bEnforceSliceRestriction || CU::isSameSlice( cu, cu2 ) ) && ( !bEnforceTileRestriction || CU::isSameTile( cu, cu2 ) ) && (!bEnforceSubPicRestriction || CU::isSameSubPic(cu, cu2)); -#else - return ( !bEnforceSliceRestriction || CU::isSameSlice( cu, cu2 ) ) && ( !bEnforceTileRestriction || CU::isSameTile( cu, cu2 ) ) ; -#endif } @@ -345,7 +329,7 @@ void LoopFilter::xDeblockCU( CodingUnit& cu, const DeblockEdgeDir edgeDir ) { edgeIdx.push_back( ( edgeDir == EDGE_HOR ) ? ( currTU.blocks[cu.chType].y - cu.blocks[cu.chType].y ) / 4 : ( currTU.blocks[cu.chType].x - cu.blocks[cu.chType].x ) / 4 ); } - else + else { edgeIdx.push_back( ( edgeDir == EDGE_HOR ) ? (( currTU.blocks[cu.chType].y - cu.blocks[cu.chType].y ) << ::getComponentScaleY(COMPONENT_Cb, cu.chromaFormat)) / 4 : (( currTU.blocks[cu.chType].x - cu.blocks[cu.chType].x ) << ::getComponentScaleX(COMPONENT_Cb, cu.chromaFormat)) / 4 ); } @@ -450,11 +434,7 @@ void LoopFilter::xDeblockCU( CodingUnit& cu, const DeblockEdgeDir edgeDir ) xEdgeFilterLuma( cu, edgeDir, edge ); } -#if JVET_Q0438_MONOCHROME_BUGFIXES if ( pcv.chrFormat != CHROMA_400 && cu.blocks[COMPONENT_Cb].valid() ) -#else - if ( cu.blocks[COMPONENT_Cb].valid() && pcv.chrFormat != CHROMA_400 ) -#endif { if ( !cu.ispMode || edge == 0 ) { @@ -467,13 +447,8 @@ void LoopFilter::xDeblockCU( CodingUnit& cu, const DeblockEdgeDir edgeDir ) inline bool LoopFilter::isCrossedByVirtualBoundaries(const int xPos, const int yPos, const int width, const int height, int& numHorVirBndry, int& numVerVirBndry, int horVirBndryPos[], int verVirBndryPos[], const PicHeader* picHeader ) { numHorVirBndry = 0; numVerVirBndry = 0; -#if JVET_Q0246_VIRTUAL_BOUNDARY_ENABLE_FLAG if( picHeader->getVirtualBoundariesPresentFlag() ) { -#else - if (picHeader->getLoopFilterAcrossVirtualBoundariesDisabledFlag()) - { -#endif for (int i = 0; i < picHeader->getNumHorVirtualBoundaries(); i++) { if (yPos <= picHeader->getVirtualBoundariesPosY(i) && picHeader->getVirtualBoundariesPosY(i) < yPos + height) @@ -519,11 +494,7 @@ void LoopFilter::xSetMaxFilterLengthPQFromTransformSizes( const DeblockEdgeDir e if ( edgeDir == EDGE_HOR ) { -#if JVET_Q0438_MONOCHROME_BUGFIXES for ( int cIdx = 0; cIdx < ::getNumberValidComponents(tuQ.chromaFormat); cIdx++ ) // per component -#else - for ( int cIdx = 0; cIdx < MAX_NUM_COMPONENT; cIdx++ ) // per component -#endif { const ComponentID comp = ComponentID(cIdx); const ChannelType ch = toChannelType(comp); @@ -568,11 +539,7 @@ void LoopFilter::xSetMaxFilterLengthPQFromTransformSizes( const DeblockEdgeDir e } if ( edgeDir == EDGE_VER ) { -#if JVET_Q0438_MONOCHROME_BUGFIXES for ( int cIdx = 0; cIdx < ::getNumberValidComponents(tuQ.chromaFormat); cIdx++ ) // per component -#else - for ( int cIdx = 0; cIdx < MAX_NUM_COMPONENT; cIdx++ ) // per component -#endif { const ComponentID comp = ComponentID(cIdx); const ChannelType ch = toChannelType(comp); @@ -709,11 +676,11 @@ void LoopFilter::xSetEdgefilterMultiple( const CodingUnit& cu, for( int ui = 0; ui < uiNumElem; ui++ ) { m_aapbEdgeFilter[edgeDir][uiBsIdx] = bValue; - if ( m_aapucBS[edgeDir][uiBsIdx] && bValue ) + if ( m_aapucBS[edgeDir][uiBsIdx] && bValue ) { m_aapucBS[edgeDir][uiBsIdx] = 3; // both the TU and PU edge } - else + else { if( ! EdgeIdx ) { @@ -738,24 +705,10 @@ void LoopFilter::xSetLoopfilterParam( const CodingUnit& cu ) m_stLFCUParam.internalEdge = true; -#if JVET_Q0371_DEBLOCKING_CLEANUP - m_stLFCUParam.leftEdge = (0 < pos.x) && isAvailableLeft(cu, *cu.cs->getCU(pos.offset(-1, 0), cu.chType), !pps.getLoopFilterAcrossSlicesEnabledFlag(), !pps.getLoopFilterAcrossTilesEnabledFlag(), + m_stLFCUParam.leftEdge = (0 < pos.x) && isAvailableLeft(cu, *cu.cs->getCU(pos.offset(-1, 0), cu.chType), !pps.getLoopFilterAcrossSlicesEnabledFlag(), !pps.getLoopFilterAcrossTilesEnabledFlag(), !( pps.getSubPicFromCU(cu).getloopFilterAcrossEnabledFlag() && pps.getSubPicFromCU(*cu.cs->getCU(pos.offset(-1, 0), cu.chType)).getloopFilterAcrossEnabledFlag())); - m_stLFCUParam.topEdge = (0 < pos.y) && isAvailableAbove(cu, *cu.cs->getCU(pos.offset(0, -1), cu.chType), !pps.getLoopFilterAcrossSlicesEnabledFlag(), !pps.getLoopFilterAcrossTilesEnabledFlag(), + m_stLFCUParam.topEdge = (0 < pos.y) && isAvailableAbove(cu, *cu.cs->getCU(pos.offset(0, -1), cu.chType), !pps.getLoopFilterAcrossSlicesEnabledFlag(), !pps.getLoopFilterAcrossTilesEnabledFlag(), !( pps.getSubPicFromCU(cu).getloopFilterAcrossEnabledFlag() && pps.getSubPicFromCU(*cu.cs->getCU(pos.offset(0, -1), cu.chType)).getloopFilterAcrossEnabledFlag())); -#else -#if JVET_O1143_LPF_ACROSS_SUBPIC_BOUNDARY - m_stLFCUParam.leftEdge = ( 0 < pos.x ) && isAvailableLeft ( cu, *cu.cs->getCU( pos.offset( -1, 0 ), cu.chType ), !pps.getLoopFilterAcrossSlicesEnabledFlag(), !pps.getLoopFilterAcrossTilesEnabledFlag(), !pps.getSubPicFromCU(cu).getloopFilterAcrossEnabledFlag() ); -#else - m_stLFCUParam.leftEdge = ( 0 < pos.x ) && isAvailableLeft ( cu, *cu.cs->getCU( pos.offset( -1, 0 ), cu.chType ), !pps.getLoopFilterAcrossSlicesEnabledFlag(), !pps.getLoopFilterAcrossTilesEnabledFlag()); -#endif - -#if JVET_O1143_LPF_ACROSS_SUBPIC_BOUNDARY - m_stLFCUParam.topEdge = ( 0 < pos.y ) && isAvailableAbove( cu, *cu.cs->getCU( pos.offset( 0, -1 ), cu.chType ), !pps.getLoopFilterAcrossSlicesEnabledFlag(), !pps.getLoopFilterAcrossTilesEnabledFlag(), !pps.getSubPicFromCU(cu).getloopFilterAcrossEnabledFlag() ); -#else - m_stLFCUParam.topEdge = ( 0 < pos.y ) && isAvailableAbove( cu, *cu.cs->getCU( pos.offset( 0, -1 ), cu.chType ), !pps.getLoopFilterAcrossSlicesEnabledFlag(), !pps.getLoopFilterAcrossTilesEnabledFlag()); -#endif -#endif } unsigned LoopFilter::xGetBoundaryStrengthSingle ( const CodingUnit& cu, const DeblockEdgeDir edgeDir, const Position& localPos, const ChannelType chType ) const @@ -770,7 +723,7 @@ unsigned LoopFilter::xGetBoundaryStrengthSingle ( const CodingUnit& cu, const De const Position posP = ( edgeDir == EDGE_VER ) ? posQ.offset( -1, 0 ) : posQ.offset( 0, -1 ); const CodingUnit& cuQ = cu; - const CodingUnit& cuP = (chType == CHANNEL_TYPE_CHROMA && cuQ.chType == CHANNEL_TYPE_LUMA) ? + const CodingUnit& cuP = (chType == CHANNEL_TYPE_CHROMA && cuQ.chType == CHANNEL_TYPE_LUMA) ? *cu.cs->getCU(recalcPosition( cu.chromaFormat, CHANNEL_TYPE_LUMA, CHANNEL_TYPE_CHROMA, posP), CHANNEL_TYPE_CHROMA) : *cu.cs->getCU( posP, cu.chType ); @@ -778,12 +731,12 @@ unsigned LoopFilter::xGetBoundaryStrengthSingle ( const CodingUnit& cu, const De //-- Set BS for Intra MB : BS = 4 or 3 if( ( MODE_INTRA == cuP.predMode ) || ( MODE_INTRA == cuQ.predMode ) ) { - if( chType == CHANNEL_TYPE_LUMA ) + if( chType == CHANNEL_TYPE_LUMA ) { int bsY = (MODE_INTRA == cuP.predMode && cuP.bdpcmMode) && (MODE_INTRA == cuQ.predMode && cuQ.bdpcmMode) ? 0 : 2; return BsSet(bsY, COMPONENT_Y); } - else + else { int bsC = (MODE_INTRA == cuP.predMode && cuP.bdpcmModeChroma) && (MODE_INTRA == cuQ.predMode && cuQ.bdpcmModeChroma) ? 0 : 2; return (BsSet(bsC, COMPONENT_Cb) + BsSet(bsC, COMPONENT_Cr)); @@ -803,7 +756,7 @@ unsigned LoopFilter::xGetBoundaryStrengthSingle ( const CodingUnit& cu, const De { return BsSet(2, COMPONENT_Y); } - else + else { return BsSet(2, COMPONENT_Cb) + BsSet(2, COMPONENT_Cr); } @@ -819,12 +772,10 @@ unsigned LoopFilter::xGetBoundaryStrengthSingle ( const CodingUnit& cu, const De tmpBs += BsSet(1, COMPONENT_Y); } } - else + else { -#if JVET_Q0438_MONOCHROME_BUGFIXES if (pcv.chrFormat != CHROMA_400) { -#endif // U if (m_aapucBS[edgeDir][rasterIdx] && (TU::getCbf(tuQ, COMPONENT_Cb) || TU::getCbf(tuP, COMPONENT_Cb) || tuQ.jointCbCr || tuP.jointCbCr)) { @@ -835,9 +786,7 @@ unsigned LoopFilter::xGetBoundaryStrengthSingle ( const CodingUnit& cu, const De { tmpBs += BsSet(1, COMPONENT_Cr); } -#if JVET_Q0438_MONOCHROME_BUGFIXES } -#endif } if (BsGet(tmpBs, COMPONENT_Y) == 1) { @@ -855,6 +804,16 @@ unsigned LoopFilter::xGetBoundaryStrengthSingle ( const CodingUnit& cu, const De // and now the pred if ( m_aapucBS[edgeDir][rasterIdx] != 0 && m_aapucBS[edgeDir][rasterIdx] != 3 ) return tmpBs; +#if JVET_R0437_BS_DERIVATION + if( chType == CHANNEL_TYPE_CHROMA ) + { + return tmpBs; + } + if( cuP.predMode != cuQ.predMode && chType == CHANNEL_TYPE_LUMA ) + { + return BsSet(1, COMPONENT_Y); + } +#endif const Position& lumaPosQ = Position{ localPos.x, localPos.y }; const Position lumaPosP = ( edgeDir == EDGE_VER ) ? lumaPosQ.offset( -1, 0 ) : lumaPosQ.offset( 0, -1 ); const MotionInfo& miQ = cuQ.cs->getMotionInfo( lumaPosQ ); @@ -1036,16 +995,8 @@ void LoopFilter::xEdgeFilterLuma( const CodingUnit& cu, const DeblockEdgeDir edg // Derive neighboring PU index if (edgeDir == EDGE_VER) { -#if JVET_Q0371_DEBLOCKING_CLEANUP - if (!isAvailableLeft(cu, cuP, !pps.getLoopFilterAcrossSlicesEnabledFlag(), !pps.getLoopFilterAcrossTilesEnabledFlag(), + if (!isAvailableLeft(cu, cuP, !pps.getLoopFilterAcrossSlicesEnabledFlag(), !pps.getLoopFilterAcrossTilesEnabledFlag(), !( pps.getSubPicFromCU(cu).getloopFilterAcrossEnabledFlag() && pps.getSubPicFromCU(cuP).getloopFilterAcrossEnabledFlag()))) -#else -#if JVET_O1143_LPF_ACROSS_SUBPIC_BOUNDARY - if (!isAvailableLeft(cu, cuP, !pps.getLoopFilterAcrossSlicesEnabledFlag(), !pps.getLoopFilterAcrossTilesEnabledFlag(), !pps.getSubPicFromCU(cu).getloopFilterAcrossEnabledFlag())) -#else - if (!isAvailableLeft(cu, cuP, !pps.getLoopFilterAcrossSlicesEnabledFlag(), !pps.getLoopFilterAcrossTilesEnabledFlag())) -#endif -#endif { m_aapucBS[edgeDir][uiBsAbsIdx] = uiBs = 0; continue; @@ -1053,16 +1004,8 @@ void LoopFilter::xEdgeFilterLuma( const CodingUnit& cu, const DeblockEdgeDir edg } else // (iDir == EDGE_HOR) { -#if JVET_Q0371_DEBLOCKING_CLEANUP - if (!isAvailableAbove(cu, cuP, !pps.getLoopFilterAcrossSlicesEnabledFlag(), !pps.getLoopFilterAcrossTilesEnabledFlag(), + if (!isAvailableAbove(cu, cuP, !pps.getLoopFilterAcrossSlicesEnabledFlag(), !pps.getLoopFilterAcrossTilesEnabledFlag(), !( pps.getSubPicFromCU(cu).getloopFilterAcrossEnabledFlag() && pps.getSubPicFromCU(cuP).getloopFilterAcrossEnabledFlag()))) -#else -#if JVET_O1143_LPF_ACROSS_SUBPIC_BOUNDARY - if (!isAvailableAbove(cu, cuP, !pps.getLoopFilterAcrossSlicesEnabledFlag(), !pps.getLoopFilterAcrossTilesEnabledFlag(), !pps.getSubPicFromCU(cu).getloopFilterAcrossEnabledFlag())) -#else - if (!isAvailableAbove(cu, cuP, !pps.getLoopFilterAcrossSlicesEnabledFlag(), !pps.getLoopFilterAcrossTilesEnabledFlag())) -#endif -#endif { m_aapucBS[edgeDir][uiBsAbsIdx] = uiBs = 0; continue; @@ -1108,7 +1051,11 @@ void LoopFilter::xEdgeFilterLuma( const CodingUnit& cu, const DeblockEdgeDir edg const int iIndexTC = Clip3(0, MAX_QP + DEFAULT_INTRA_TC_OFFSET, int(iQP + DEFAULT_INTRA_TC_OFFSET*(uiBs - 1) + (tcOffsetDiv2 << 1))); const int iIndexB = Clip3(0, MAX_QP, iQP + (betaOffsetDiv2 << 1)); +#if JVET_R0130_TC_DERIVATION_BUGFIX + const int iTc = bitDepthLuma < 10 ? ((sm_tcTable[iIndexTC] + (1 << (9 - bitDepthLuma))) >> (10 - bitDepthLuma)) : ((sm_tcTable[iIndexTC]) << (bitDepthLuma - 10)); +#else const int iTc = bitDepthLuma < 10 ? ((sm_tcTable[iIndexTC] + 2) >> (10 - bitDepthLuma)) : ((sm_tcTable[iIndexTC]) << (bitDepthLuma - 10)); +#endif const int iBeta = sm_betaTable[iIndexB ] * iBitdepthScale; const int iSideThreshold = ( iBeta + ( iBeta >> 1 ) ) >> 3; const int iThrCut = iTc * 10; @@ -1245,13 +1192,8 @@ void LoopFilter::xEdgeFilterChroma(const CodingUnit& cu, const DeblockEdgeDir ed bool bPartPNoFilter = false; bool bPartQNoFilter = false; -#if JVET_Q0121_DEBLOCKING_CONTROL_PARAMETERS const int tcOffsetDiv2[2] = { slice.getDeblockingFilterCbTcOffsetDiv2(), slice.getDeblockingFilterCrTcOffsetDiv2() }; const int betaOffsetDiv2[2] = { slice.getDeblockingFilterCbBetaOffsetDiv2(), slice.getDeblockingFilterCrBetaOffsetDiv2() }; -#else - const int tcOffsetDiv2 = slice.getDeblockingFilterTcOffsetDiv2(); - const int betaOffsetDiv2 = slice.getDeblockingFilterBetaOffsetDiv2(); -#endif // Vertical Position unsigned uiEdgeNumInCtuVert = rasterIdx % pcv.partsInCtuWidth + iEdge; @@ -1322,29 +1264,13 @@ void LoopFilter::xEdgeFilterChroma(const CodingUnit& cu, const DeblockEdgeDir ed if (edgeDir == EDGE_VER) { -#if JVET_Q0371_DEBLOCKING_CLEANUP - CHECK(!isAvailableLeft(cu, cuP, !pps.getLoopFilterAcrossSlicesEnabledFlag(), !pps.getLoopFilterAcrossTilesEnabledFlag(), + CHECK(!isAvailableLeft(cu, cuP, !pps.getLoopFilterAcrossSlicesEnabledFlag(), !pps.getLoopFilterAcrossTilesEnabledFlag(), !( pps.getSubPicFromCU(cu).getloopFilterAcrossEnabledFlag() && pps.getSubPicFromCU(cuP).getloopFilterAcrossEnabledFlag())), "Neighbour not available"); -#else -#if JVET_O1143_LPF_ACROSS_SUBPIC_BOUNDARY - CHECK(!isAvailableLeft(cu, cuP, !pps.getLoopFilterAcrossSlicesEnabledFlag(), !pps.getLoopFilterAcrossTilesEnabledFlag(), !pps.getSubPicFromCU(cu).getloopFilterAcrossEnabledFlag()), "Neighbour not available"); -#else - CHECK(!isAvailableLeft(cu, cuP, !pps.getLoopFilterAcrossSlicesEnabledFlag(), !pps.getLoopFilterAcrossTilesEnabledFlag()), "Neighbour not available"); -#endif -#endif } else // (iDir == EDGE_HOR) { -#if JVET_Q0371_DEBLOCKING_CLEANUP - CHECK(!isAvailableAbove(cu, cuP, !pps.getLoopFilterAcrossSlicesEnabledFlag(), !pps.getLoopFilterAcrossTilesEnabledFlag(), + CHECK(!isAvailableAbove(cu, cuP, !pps.getLoopFilterAcrossSlicesEnabledFlag(), !pps.getLoopFilterAcrossTilesEnabledFlag(), !( pps.getSubPicFromCU(cu).getloopFilterAcrossEnabledFlag() && pps.getSubPicFromCU(cuP).getloopFilterAcrossEnabledFlag())), "Neighbour not available"); -#else -#if JVET_O1143_LPF_ACROSS_SUBPIC_BOUNDARY - CHECK(!isAvailableAbove(cu, cuP, !pps.getLoopFilterAcrossSlicesEnabledFlag(), !pps.getLoopFilterAcrossTilesEnabledFlag(), !pps.getSubPicFromCU(cu).getloopFilterAcrossEnabledFlag()), "Neighbour not available"); -#else - CHECK(!isAvailableAbove(cu, cuP, !pps.getLoopFilterAcrossSlicesEnabledFlag(), !pps.getLoopFilterAcrossTilesEnabledFlag()), "Neighbour not available"); -#endif -#endif } bPartPNoFilter = bPartQNoFilter = false; @@ -1379,33 +1305,25 @@ void LoopFilter::xEdgeFilterChroma(const CodingUnit& cu, const DeblockEdgeDir ed const TransformUnit& tuQ = *cuQ.cs->getTU(recalcPosition( cu.chromaFormat, CHANNEL_TYPE_LUMA, CHANNEL_TYPE_CHROMA, pos), CHANNEL_TYPE_CHROMA); const TransformUnit& tuP = *cuP.cs->getTU(recalcPosition( cu.chromaFormat, CHANNEL_TYPE_LUMA, CHANNEL_TYPE_CHROMA, (edgeDir == EDGE_VER) ? pos.offset(-1, 0) : pos.offset(0, -1)), CHANNEL_TYPE_CHROMA); -#if JVET_Q0820_ACT const QpParam cQP(tuP, ComponentID(chromaIdx + 1), -MAX_INT, false); const QpParam cQQ(tuQ, ComponentID(chromaIdx + 1), -MAX_INT, false); -#else - const QpParam cQP(tuP, ComponentID(chromaIdx + 1)); - const QpParam cQQ(tuQ, ComponentID(chromaIdx + 1)); -#endif const int qpBdOffset = tuP.cs->sps->getQpBDOffset(toChannelType(ComponentID(chromaIdx + 1))); int baseQp_P = cQP.Qp(0) - qpBdOffset; int baseQp_Q = cQQ.Qp(0) - qpBdOffset; int iQP = ((baseQp_Q + baseQp_P + 1) >> 1); -#if JVET_Q0121_DEBLOCKING_CONTROL_PARAMETERS const int iIndexTC = Clip3<int>(0, MAX_QP + DEFAULT_INTRA_TC_OFFSET, iQP + DEFAULT_INTRA_TC_OFFSET * (bS[chromaIdx] - 1) + (tcOffsetDiv2[chromaIdx] << 1)); +#if JVET_R0130_TC_DERIVATION_BUGFIX + const int bitDepthChroma = sps.getBitDepth(CHANNEL_TYPE_CHROMA); + const int iTc = bitDepthChroma < 10 ? ((sm_tcTable[iIndexTC] + (1 << (9 - bitDepthChroma))) >> (10 - bitDepthChroma)) : ((sm_tcTable[iIndexTC]) << (bitDepthChroma - 10)); #else - const int iIndexTC = Clip3<int>(0, MAX_QP + DEFAULT_INTRA_TC_OFFSET, iQP + DEFAULT_INTRA_TC_OFFSET * (bS[chromaIdx] - 1) + (tcOffsetDiv2 << 1)); -#endif const int iTc = sps.getBitDepth(CHANNEL_TYPE_CHROMA) < 10 ? ((sm_tcTable[iIndexTC] + 2) >> (10 - sps.getBitDepth(CHANNEL_TYPE_CHROMA))) : ((sm_tcTable[iIndexTC]) << (sps.getBitDepth(CHANNEL_TYPE_CHROMA) - 10)); +#endif bool useLongFilter = false; if (largeBoundary) { -#if JVET_Q0121_DEBLOCKING_CONTROL_PARAMETERS const int indexB = Clip3<int>(0, MAX_QP, iQP + (betaOffsetDiv2[chromaIdx] << 1)); -#else - const int indexB = Clip3<int>(0, MAX_QP, iQP + (betaOffsetDiv2 << 1)); -#endif const int beta = sm_betaTable[indexB] * iBitdepthScale; const int dp0 = xCalcDP(piTmpSrcChroma + iSrcStep*(iIdx*uiLoopLength + 0), iOffset, isChromaHorCTBBoundary); @@ -1742,7 +1660,6 @@ inline bool LoopFilter::xUseStrongFiltering(Pel* piSrc, const int iOffset, const { Pel mP4; Pel m11; -#if JVET_Q0054 if (sidePisLarge) { if (maxFilterLengthP == 7) @@ -1776,34 +1693,6 @@ inline bool LoopFilter::xUseStrongFiltering(Pel* piSrc, const int iOffset, const sq3 = (sq3 + abs(m11 - m7) + 1) >> 1; } return ((sp3 + sq3) < (beta*3 >> 5)) && (d < (beta >> 4)) && (abs(m3 - m4) < ((tc * 5 + 1) >> 1)); -#else - if (maxFilterLengthP == 5) - { - mP4 = piSrc[-iOffset * 6]; - } - else - { - mP4 = piSrc[-iOffset * 8]; - } - if (maxFilterLengthQ == 5) - { - m11 = piSrc[iOffset * 5]; - } - else - { - m11 = piSrc[iOffset * 7]; - } - - if (sidePisLarge) - { - sp3 = (sp3 + abs(m0 - mP4) + 1) >> 1; - } - if (sideQisLarge) - { - sq3 = (sq3 + abs(m11 - m7) + 1) >> 1; - } - return ((sp3 + sq3) < (beta*3 >> 5)) && (d < (beta >> 2)) && (abs(m3 - m4) < ((tc * 5 + 1) >> 1)); -#endif } else return ( ( d_strong < ( beta >> 3 ) ) && ( d < ( beta >> 2 ) ) && ( abs( m3 - m4 ) < ( ( tc * 5 + 1 ) >> 1 ) ) ); diff --git a/source/Lib/CommonLib/MCTS.cpp b/source/Lib/CommonLib/MCTS.cpp index 6af615f59d214e42dd0af09f52e0bafc94eb3df1..b0795736dcb039e78d8a37a4ae5fd080995dbdd6 100644 --- a/source/Lib/CommonLib/MCTS.cpp +++ b/source/Lib/CommonLib/MCTS.cpp @@ -97,9 +97,9 @@ Area MCTSHelper::getTileArea( const CodingStructure* cs, const int ctuAddr ) const uint32_t tileIdx = pps->getTileIdx( (uint32_t)ctuAddr ); const uint32_t tileX = tileIdx % pps->getNumTileColumns(); const uint32_t tileY = tileIdx / pps->getNumTileColumns(); - + const int tileWidthtInCtus = pps->getTileColumnWidth( tileX ); - const int tileHeightInCtus = pps->getTileRowHeight ( tileY ); + const int tileHeightInCtus = pps->getTileRowHeight ( tileY ); const int tileXPosInCtus = pps->getTileColumnBd( tileX ); const int tileYPosInCtus = pps->getTileRowBd( tileY ); diff --git a/source/Lib/CommonLib/MatrixIntraPrediction.cpp b/source/Lib/CommonLib/MatrixIntraPrediction.cpp index af6adae25633456c844c2b326f7b96c4badb8d7d..cad260400e7365aaf2d963a2f85c34f251dd934e 100644 --- a/source/Lib/CommonLib/MatrixIntraPrediction.cpp +++ b/source/Lib/CommonLib/MatrixIntraPrediction.cpp @@ -43,6 +43,9 @@ MatrixIntraPrediction::MatrixIntraPrediction(): +#if JVET_R0350_MIP_CHROMA_444_SINGLETREE + m_component(MAX_NUM_COMPONENT), +#endif m_reducedBoundary (MIP_MAX_INPUT_SIZE), m_reducedBoundaryTransposed(MIP_MAX_INPUT_SIZE), m_inputOffset ( 0 ), @@ -58,9 +61,16 @@ MatrixIntraPrediction::MatrixIntraPrediction(): { } +#if JVET_R0350_MIP_CHROMA_444_SINGLETREE +void MatrixIntraPrediction::prepareInputForPred(const CPelBuf &pSrc, const Area &block, const int bitDepth, + const ComponentID compId) +{ + m_component = compId; +#else void MatrixIntraPrediction::prepareInputForPred(const CPelBuf &pSrc, const Area& block, const int bitDepth) { +#endif // Step 1: Save block size and calculate dependent values initPredBlockParams(block); @@ -105,13 +115,8 @@ void MatrixIntraPrediction::prepareInputForPred(const CPelBuf &pSrc, const Area& m_inputOffsetTransp = m_reducedBoundaryTransposed[0]; const bool hasFirstCol = (m_sizeId < 2); -#if JVET_Q0446_MIP_CONST_SHIFT_OFFSET m_reducedBoundary [0] = hasFirstCol ? ((1 << (bitDepth - 1)) - m_inputOffset ) : 0; // first column of matrix not needed for large blocks m_reducedBoundaryTransposed[0] = hasFirstCol ? ((1 << (bitDepth - 1)) - m_inputOffsetTransp) : 0; -#else - m_reducedBoundary [0] = hasFirstCol ? (m_inputOffset - (1 << (bitDepth - 1))) : 0; // first column of matrix not needed for large blocks - m_reducedBoundaryTransposed[0] = hasFirstCol ? (m_inputOffsetTransp - (1 << (bitDepth - 1))) : 0; -#endif for (int i = 1; i < inputSize; i++) { m_reducedBoundary [i] -= m_inputOffset; @@ -119,26 +124,24 @@ void MatrixIntraPrediction::prepareInputForPred(const CPelBuf &pSrc, const Area& } } +#if JVET_R0350_MIP_CHROMA_444_SINGLETREE +void MatrixIntraPrediction::predBlock(int *const result, const int modeIdx, const bool transpose, const int bitDepth, + const ComponentID compId) +{ + CHECK(m_component != compId, "Boundary has not been prepared for this component."); + +#else void MatrixIntraPrediction::predBlock(int* const result, const int modeIdx, const bool transpose, const int bitDepth) { +#endif const bool needUpsampling = ( m_upsmpFactorHor > 1 ) || ( m_upsmpFactorVer > 1 ); -#if JVET_Q0446_MIP_CONST_SHIFT_OFFSET const uint8_t* matrix = getMatrixData(modeIdx); -#else - const uint8_t* matrix; - int shiftMatrix = 0, offsetMatrix = 0; - getMatrixData(matrix, shiftMatrix, offsetMatrix, modeIdx); -#endif static_vector<int, MIP_MAX_REDUCED_OUTPUT_SAMPLES> bufReducedPred( m_reducedPredSize * m_reducedPredSize ); int* const reducedPred = needUpsampling ? bufReducedPred.data() : result; const int* const reducedBoundary = transpose ? m_reducedBoundaryTransposed.data() : m_reducedBoundary.data(); -#if JVET_Q0446_MIP_CONST_SHIFT_OFFSET computeReducedPred(reducedPred, reducedBoundary, matrix, transpose, bitDepth); -#else - computeReducedPred( reducedPred, reducedBoundary, matrix, shiftMatrix, offsetMatrix, transpose, bitDepth ); -#endif if( needUpsampling ) { predictionUpsampling( result, reducedPred ); @@ -275,47 +278,22 @@ void MatrixIntraPrediction::predictionUpsampling( int* const dst, const int* con } } -#if JVET_Q0446_MIP_CONST_SHIFT_OFFSET const uint8_t* MatrixIntraPrediction::getMatrixData(const int modeIdx) const -#else -void MatrixIntraPrediction::getMatrixData(const uint8_t*& matrix, int &shiftMatrix, int &offsetMatrix, const int modeIdx) const -#endif { switch( m_sizeId ) { -#if JVET_Q0446_MIP_CONST_SHIFT_OFFSET case 0: return &mipMatrix4x4[modeIdx][0][0]; case 1: return &mipMatrix8x8[modeIdx][0][0]; case 2: return &mipMatrix16x16[modeIdx][0][0]; -#else - case 0: matrix = &mipMatrix4x4 [modeIdx][0][0]; - shiftMatrix = mipShiftMatrix4x4 [modeIdx]; - offsetMatrix = mipOffsetMatrix4x4[modeIdx]; - break; - - case 1: matrix = &mipMatrix8x8 [modeIdx][0][0]; - shiftMatrix = mipShiftMatrix8x8 [modeIdx]; - offsetMatrix = mipOffsetMatrix8x8[modeIdx]; - break; - - case 2: matrix = &mipMatrix16x16 [modeIdx][0][0]; - shiftMatrix = mipShiftMatrix16x16 [modeIdx]; - offsetMatrix = mipOffsetMatrix16x16[modeIdx]; - break; -#endif default: THROW( "Invalid mipSizeId" ); } } -void MatrixIntraPrediction::computeReducedPred( int*const result, const int* const input, -#if JVET_Q0446_MIP_CONST_SHIFT_OFFSET +void MatrixIntraPrediction::computeReducedPred( int*const result, const int* const input, const uint8_t* matrix, -#else - const uint8_t*matrix, const int shiftMatrix, const int offsetMatrix, -#endif const bool transpose, const int bitDepth ) { const int inputSize = 2 * m_reducedBdrySize; @@ -326,11 +304,7 @@ void MatrixIntraPrediction::computeReducedPred( int*const result, const int* con int sum = 0; for( int i = 0; i < inputSize; i++ ) { sum += input[i]; } -#if JVET_Q0446_MIP_CONST_SHIFT_OFFSET const int offset = (1 << (MIP_SHIFT_MATRIX - 1)) - MIP_OFFSET_MATRIX * sum; -#else - const int offset = (1 << (shiftMatrix - 1)) - offsetMatrix * sum; -#endif CHECK( inputSize != 4 * (inputSize >> 2), "Error, input size not divisible by four" ); const uint8_t *weight = matrix; @@ -354,11 +328,7 @@ void MatrixIntraPrediction::computeReducedPred( int*const result, const int* con tmp2 += input[i + 2] * weight[i + 2]; tmp3 += input[i + 3] * weight[i + 3]; } -#if JVET_Q0446_MIP_CONST_SHIFT_OFFSET resPtr[posRes++] = ClipBD<int>(((tmp0 + tmp1 + tmp2 + tmp3 + offset) >> MIP_SHIFT_MATRIX) + inputOffset, bitDepth); -#else - resPtr[posRes++] = ClipBD<int>( ((tmp0 + tmp1 + tmp2 + tmp3 + offset) >> shiftMatrix) + inputOffset, bitDepth ); -#endif weight += inputSize; } diff --git a/source/Lib/CommonLib/MatrixIntraPrediction.h b/source/Lib/CommonLib/MatrixIntraPrediction.h index 2452150d3f6fa46c020f2fd704e64554292cbf1c..2b69661e3bdd16e67bc2878a72fc80eb885bf794 100644 --- a/source/Lib/CommonLib/MatrixIntraPrediction.h +++ b/source/Lib/CommonLib/MatrixIntraPrediction.h @@ -50,10 +50,20 @@ class MatrixIntraPrediction public: MatrixIntraPrediction(); +#if JVET_R0350_MIP_CHROMA_444_SINGLETREE + void prepareInputForPred(const CPelBuf &pSrc, const Area &block, const int bitDepth, const ComponentID compId); + void predBlock(int *const result, const int modeIdx, const bool transpose, const int bitDepth, + const ComponentID compId); +#else void prepareInputForPred(const CPelBuf &pSrc, const Area& block, const int bitDepth); void predBlock(int* const result, const int modeIdx, const bool transpose, const int bitDepth); +#endif private: +#if JVET_R0350_MIP_CHROMA_444_SINGLETREE + ComponentID m_component; + +#endif static_vector<int, MIP_MAX_INPUT_SIZE> m_reducedBoundary; // downsampled boundary of a block static_vector<int, MIP_MAX_INPUT_SIZE> m_reducedBoundaryTransposed; // downsampled, transposed boundary of a block int m_inputOffset; @@ -80,19 +90,11 @@ public: const SizeType bndryStep, const unsigned int upsmpFactor ); -#if JVET_Q0446_MIP_CONST_SHIFT_OFFSET const uint8_t* getMatrixData(const int modeIdx) const; -#else - void getMatrixData(const uint8_t*& matrix, int &shiftMatrix, int &offsetMatrix, const int modeIdx) const; -#endif - void computeReducedPred( int*const result, const int* const input, -#if JVET_Q0446_MIP_CONST_SHIFT_OFFSET + void computeReducedPred( int*const result, const int* const input, const uint8_t* matrix, -#else - const uint8_t*matrix, const int shiftMatrix, const int offsetMatrix, -#endif const bool transpose, const int bitDepth ); }; diff --git a/source/Lib/CommonLib/MipData.h b/source/Lib/CommonLib/MipData.h index 7200a9f85234c563ecd95bdb1de60e1d6d203656..bc7ea3e6222c9254e9c5ddd1ef900d13c814bca0 100644 --- a/source/Lib/CommonLib/MipData.h +++ b/source/Lib/CommonLib/MipData.h @@ -35,7 +35,6 @@ \brief weight and bias data for matrix-based intra prediction (MIP) */ -#if JVET_Q0446_MIP_CONST_SHIFT_OFFSET static const uint8_t MIP_SHIFT_MATRIX = 6; static const uint8_t MIP_OFFSET_MATRIX = 32; @@ -878,862 +877,3 @@ ALIGN_DATA(MEMORY_ALIGN_DEF_SIZE, const uint8_t mipMatrix16x16[6][64][7]) = { 62, 49, 35, 33, 34, 34, 33} } }; -#else -ALIGN_DATA(MEMORY_ALIGN_DEF_SIZE, const uint8_t mipMatrix4x4[16][16][4]) = -{ - { - { 5, 16, 51, 2}, - { 5, 22, 18, 36}, - { 5, 15, 5, 55}, - { 5, 10, 6, 59}, - { 4, 6, 12, 59}, - { 5, 3, 4, 66}, - { 7, 0, 5, 67}, - { 8, 1, 7, 65}, - { 6, 2, 3, 67}, - { 7, 1, 5, 66}, - { 9, 1, 6, 66}, - { 10, 2, 6, 66}, - { 7, 3, 5, 64}, - { 9, 2, 6, 64}, - { 10, 2, 6, 65}, - { 10, 3, 7, 64} - }, - { - { 28, 27, 58, 26}, - { 28, 27, 52, 27}, - { 29, 39, 43, 28}, - { 28, 70, 38, 27}, - { 28, 28, 61, 28}, - { 28, 27, 62, 26}, - { 29, 30, 60, 25}, - { 25, 61, 49, 23}, - { 29, 28, 35, 54}, - { 29, 28, 42, 47}, - { 28, 26, 50, 36}, - { 16, 42, 46, 19}, - { 28, 28, 23, 64}, - { 29, 28, 24, 64}, - { 25, 24, 23, 58}, - { 0, 19, 21, 31} - }, - { - { 28, 27, 39, 26}, - { 29, 32, 29, 27}, - { 29, 60, 31, 27}, - { 27, 68, 31, 26}, - { 28, 27, 51, 27}, - { 28, 39, 39, 26}, - { 26, 64, 33, 28}, - { 21, 64, 27, 35}, - { 27, 28, 38, 50}, - { 19, 44, 31, 51}, - { 10, 57, 22, 54}, - { 7, 53, 16, 58}, - { 19, 31, 12, 72}, - { 6, 47, 14, 64}, - { 0, 50, 15, 60}, - { 2, 48, 15, 60} - }, - { - { 42, 40, 64, 45}, - { 43, 41, 44, 52}, - { 43, 67, 34, 49}, - { 41, 76, 38, 45}, - { 42, 41, 50, 67}, - { 41, 39, 42, 71}, - { 38, 52, 33, 63}, - { 31, 70, 31, 47}, - { 40, 41, 39, 76}, - { 31, 36, 38, 74}, - { 17, 30, 35, 69}, - { 9, 47, 30, 50}, - { 32, 37, 37, 75}, - { 15, 29, 36, 68}, - { 3, 22, 37, 62}, - { 0, 26, 38, 52} - }, - { - { 57, 53, 73, 55}, - { 58, 75, 61, 55}, - { 55, 91, 53, 63}, - { 45, 87, 43, 74}, - { 58, 60, 80, 63}, - { 51, 71, 62, 73}, - { 30, 65, 48, 77}, - { 14, 50, 47, 73}, - { 50, 56, 53, 89}, - { 20, 43, 50, 77}, - { 2, 32, 53, 67}, - { 2, 30, 54, 65}, - { 26, 41, 47, 82}, - { 2, 28, 53, 65}, - { 0, 27, 55, 63}, - { 3, 29, 55, 64} - }, - { - { 23, 19, 88, 8}, - { 23, 44, 61, 25}, - { 22, 64, 24, 52}, - { 21, 56, 0, 71}, - { 21, 25, 53, 61}, - { 20, 26, 31, 80}, - { 20, 22, 21, 88}, - { 19, 20, 17, 88}, - { 20, 22, 19, 89}, - { 19, 21, 19, 89}, - { 18, 20, 20, 88}, - { 17, 19, 20, 86}, - { 19, 20, 20, 87}, - { 18, 21, 21, 86}, - { 16, 21, 21, 85}, - { 13, 19, 21, 83} - }, - { - { 9, 0, 11, 6}, - { 9, 19, 11, 8}, - { 9, 70, 11, 8}, - { 9, 76, 12, 8}, - { 9, 0, 12, 6}, - { 9, 19, 11, 7}, - { 9, 70, 11, 9}, - { 9, 76, 12, 9}, - { 9, 0, 12, 6}, - { 9, 20, 12, 7}, - { 9, 70, 12, 9}, - { 9, 75, 12, 9}, - { 9, 1, 11, 8}, - { 9, 20, 12, 8}, - { 9, 70, 12, 8}, - { 9, 75, 11, 9} - }, - { - { 6, 3, 61, 7}, - { 7, 0, 34, 7}, - { 7, 13, 5, 6}, - { 6, 56, 1, 4}, - { 6, 7, 74, 5}, - { 6, 4, 70, 6}, - { 6, 0, 51, 6}, - { 6, 8, 19, 5}, - { 7, 7, 55, 23}, - { 7, 7, 71, 8}, - { 6, 5, 74, 5}, - { 6, 3, 59, 7}, - { 5, 5, 3, 74}, - { 6, 6, 36, 41}, - { 7, 7, 62, 15}, - { 6, 7, 66, 10} - }, - { - { 35, 26, 78, 28}, - { 34, 39, 35, 33}, - { 34, 96, 32, 35}, - { 35, 102, 35, 35}, - { 31, 30, 107, 25}, - { 29, 34, 66, 24}, - { 31, 93, 32, 31}, - { 35, 101, 34, 35}, - { 31, 31, 64, 72}, - { 19, 28, 86, 30}, - { 18, 85, 47, 20}, - { 31, 99, 34, 33}, - { 32, 32, 27, 106}, - { 12, 26, 52, 71}, - { 0, 72, 60, 19}, - { 20, 93, 37, 26} - }, - { - { 10, 6, 60, 0}, - { 7, 14, 39, 4}, - { 4, 65, 21, 11}, - { 1, 80, 12, 16}, - { 10, 11, 52, 46}, - { 6, 9, 36, 57}, - { 2, 18, 20, 65}, - { 0, 23, 11, 65}, - { 13, 13, 13, 80}, - { 12, 13, 12, 80}, - { 12, 12, 13, 80}, - { 11, 12, 14, 79}, - { 15, 14, 12, 79}, - { 15, 14, 13, 79}, - { 16, 16, 15, 78}, - { 16, 16, 17, 76} - }, - { - { 50, 48, 85, 42}, - { 47, 44, 59, 44}, - { 43, 52, 51, 43}, - { 14, 107, 51, 29}, - { 51, 49, 92, 77}, - { 47, 44, 70, 81}, - { 35, 32, 47, 79}, - { 0, 47, 35, 60}, - { 50, 49, 49, 116}, - { 49, 47, 49, 117}, - { 45, 41, 49, 115}, - { 30, 32, 47, 106}, - { 50, 49, 46, 117}, - { 49, 49, 48, 115}, - { 50, 48, 49, 115}, - { 47, 45, 50, 113} - }, - { - { 67, 65, 96, 61}, - { 66, 65, 90, 62}, - { 68, 83, 79, 64}, - { 59, 102, 70, 61}, - { 67, 67, 93, 74}, - { 68, 67, 93, 74}, - { 64, 75, 88, 69}, - { 30, 85, 69, 49}, - { 67, 67, 68, 97}, - { 68, 67, 68, 98}, - { 43, 60, 69, 80}, - { 4, 68, 65, 40}, - { 66, 66, 63, 101}, - { 62, 63, 62, 99}, - { 22, 49, 60, 76}, - { 0, 65, 64, 41} - }, - { - { 27, 18, 53, 22}, - { 26, 35, 22, 28}, - { 27, 90, 27, 27}, - { 28, 97, 29, 28}, - { 22, 19, 80, 29}, - { 15, 24, 42, 22}, - { 17, 72, 27, 20}, - { 22, 89, 28, 23}, - { 19, 22, 40, 82}, - { 6, 13, 36, 68}, - { 0, 19, 14, 53}, - { 8, 33, 10, 38}, - { 22, 26, 24, 95}, - { 13, 19, 25, 91}, - { 6, 14, 22, 87}, - { 4, 14, 13, 79} - }, - { - { 50, 48, 80, 49}, - { 50, 45, 73, 49}, - { 50, 48, 62, 49}, - { 49, 61, 54, 48}, - { 50, 50, 84, 48}, - { 50, 49, 84, 48}, - { 50, 48, 82, 49}, - { 50, 47, 76, 49}, - { 50, 50, 69, 64}, - { 51, 50, 77, 56}, - { 48, 48, 82, 50}, - { 37, 43, 81, 45}, - { 49, 48, 44, 87}, - { 40, 43, 50, 78}, - { 17, 32, 58, 58}, - { 0, 27, 64, 44} - }, - { - { 29, 26, 37, 36}, - { 24, 42, 16, 40}, - { 25, 62, 35, 28}, - { 28, 54, 51, 22}, - { 24, 29, 22, 52}, - { 9, 44, 21, 31}, - { 16, 50, 54, 14}, - { 27, 40, 65, 19}, - { 17, 36, 21, 49}, - { 0, 40, 41, 10}, - { 15, 37, 65, 9}, - { 28, 34, 66, 21}, - { 16, 41, 36, 33}, - { 6, 37, 54, 3}, - { 19, 32, 64, 12}, - { 28, 33, 62, 24} - }, - { - { 19, 20, 50, 19}, - { 19, 21, 49, 20}, - { 19, 27, 47, 19}, - { 19, 34, 43, 19}, - { 19, 22, 54, 18}, - { 19, 22, 55, 18}, - { 19, 22, 55, 18}, - { 19, 22, 53, 18}, - { 21, 22, 45, 27}, - { 19, 22, 47, 24}, - { 18, 21, 48, 23}, - { 18, 21, 47, 24}, - { 9, 14, 2, 65}, - { 3, 12, 2, 62}, - { 0, 11, 4, 59}, - { 0, 12, 6, 57} - } -}; - -ALIGN_DATA(MEMORY_ALIGN_DEF_SIZE, const uint8_t mipOffsetMatrix4x4[16]) = -{ 1, 28, 28, 42, 56, 22, 9, 6, 35, 14, 50, 66, 29, 50, 31, 19}; - -ALIGN_DATA(MEMORY_ALIGN_DEF_SIZE, const uint8_t mipShiftMatrix4x4[16]) = -{ 6, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 5, 6, 5, 5, 5}; - -ALIGN_DATA(MEMORY_ALIGN_DEF_SIZE, const uint8_t mipMatrix8x8[8][16][8]) = -{ - { - { 18, 77, 44, 26, 0, 17, 18, 19}, - { 19, 70, 83, 26, 16, 13, 16, 17}, - { 20, 40, 98, 36, 16, 16, 15, 16}, - { 20, 29, 75, 68, 15, 17, 16, 16}, - { 19, 82, 61, 29, 14, 10, 12, 22}, - { 21, 59, 88, 30, 17, 13, 14, 17}, - { 23, 46, 93, 36, 16, 17, 14, 16}, - { 23, 33, 96, 43, 16, 18, 15, 17}, - { 19, 82, 64, 30, 16, 17, 8, 17}, - { 22, 61, 89, 29, 17, 17, 12, 15}, - { 24, 44, 94, 38, 17, 17, 15, 16}, - { 25, 34, 90, 47, 16, 19, 15, 17}, - { 19, 77, 61, 30, 15, 17, 20, 10}, - { 22, 63, 83, 30, 17, 16, 18, 10}, - { 24, 44, 89, 39, 17, 18, 16, 16}, - { 24, 35, 82, 50, 16, 19, 16, 17} - }, - { - { 14, 15, 10, 12, 99, 11, 12, 13}, - { 12, 61, 6, 9, 32, 8, 14, 13}, - { 12, 104, 54, 2, 9, 17, 11, 14}, - { 12, 24, 110, 33, 11, 18, 10, 14}, - { 14, 14, 15, 11, 69, 102, 6, 12}, - { 13, 13, 11, 10, 105, 30, 5, 14}, - { 12, 45, 6, 8, 55, 5, 13, 12}, - { 12, 72, 38, 6, 18, 14, 12, 13}, - { 14, 12, 18, 10, 2, 77, 102, 3}, - { 13, 12, 19, 8, 41, 122, 22, 7}, - { 13, 4, 18, 8, 97, 60, 0, 13}, - { 12, 16, 18, 9, 73, 17, 11, 12}, - { 14, 12, 19, 9, 10, 8, 67, 98}, - { 13, 12, 20, 8, 4, 57, 104, 20}, - { 13, 10, 22, 7, 29, 109, 37, 12}, - { 12, 5, 24, 9, 66, 70, 12, 17} - }, - { - { 23, 42, 18, 23, 18, 41, 20, 23}, - { 23, 86, 33, 20, 20, 33, 21, 23}, - { 23, 18, 90, 25, 22, 32, 20, 23}, - { 23, 25, 12, 94, 22, 33, 21, 23}, - { 23, 36, 21, 23, 0, 79, 31, 21}, - { 23, 68, 29, 21, 0, 67, 29, 21}, - { 23, 29, 70, 24, 5, 58, 28, 21}, - { 23, 22, 21, 78, 11, 50, 29, 22}, - { 22, 28, 23, 23, 18, 9, 97, 25}, - { 21, 35, 25, 22, 16, 8, 99, 22}, - { 19, 30, 36, 22, 15, 6, 100, 21}, - { 18, 22, 22, 45, 16, 5, 92, 23}, - { 19, 24, 23, 21, 20, 28, 4, 101}, - { 16, 23, 23, 20, 18, 28, 6, 99}, - { 11, 24, 22, 18, 16, 28, 8, 97}, - { 8, 21, 21, 23, 16, 25, 11, 93} - }, - { - { 45, 61, 48, 48, 60, 81, 44, 44}, - { 45, 46, 72, 53, 41, 84, 46, 43}, - { 45, 42, 60, 78, 38, 76, 50, 43}, - { 44, 46, 43, 94, 39, 63, 55, 45}, - { 44, 44, 53, 51, 43, 83, 68, 44}, - { 45, 33, 59, 63, 39, 68, 77, 44}, - { 44, 43, 42, 79, 38, 54, 85, 46}, - { 41, 46, 40, 82, 39, 44, 80, 52}, - { 44, 41, 49, 52, 43, 39, 98, 60}, - { 41, 40, 46, 63, 43, 33, 92, 66}, - { 34, 43, 39, 70, 41, 30, 80, 75}, - { 26, 40, 41, 68, 35, 36, 62, 83}, - { 39, 42, 45, 52, 41, 43, 35, 117}, - { 26, 44, 41, 56, 38, 44, 30, 115}, - { 8, 36, 44, 53, 28, 51, 23, 108}, - { 0, 26, 48, 51, 22, 56, 21, 103} - }, - { - { 10, 15, 10, 11, 79, 18, 7, 10}, - { 10, 18, 15, 10, 79, 14, 8, 10}, - { 10, 15, 24, 13, 72, 12, 8, 9}, - { 10, 12, 8, 40, 59, 13, 8, 9}, - { 10, 10, 11, 10, 0, 80, 17, 7}, - { 10, 9, 11, 11, 4, 82, 12, 6}, - { 9, 11, 11, 11, 9, 81, 10, 6}, - { 9, 10, 12, 15, 15, 72, 12, 6}, - { 10, 11, 10, 10, 12, 2, 77, 14}, - { 10, 12, 11, 11, 11, 8, 76, 10}, - { 9, 11, 12, 11, 9, 15, 73, 7}, - { 9, 11, 11, 14, 9, 24, 63, 8}, - { 10, 11, 10, 11, 8, 12, 1, 82}, - { 10, 12, 11, 11, 9, 10, 8, 76}, - { 10, 11, 12, 12, 10, 7, 17, 69}, - { 9, 11, 10, 15, 10, 8, 25, 60} - }, - { - { 14, 34, 30, 13, 20, 58, 8, 14}, - { 13, 1, 44, 32, 7, 32, 33, 13}, - { 13, 12, 2, 56, 11, 11, 36, 33}, - { 12, 17, 5, 38, 13, 7, 23, 58}, - { 13, 7, 20, 22, 10, 21, 65, 18}, - { 11, 10, 6, 29, 13, 5, 39, 56}, - { 9, 17, 4, 20, 13, 9, 12, 83}, - { 8, 14, 15, 11, 12, 13, 9, 85}, - { 12, 14, 9, 19, 15, 7, 23, 74}, - { 8, 15, 10, 14, 13, 13, 0, 93}, - { 6, 14, 15, 9, 11, 15, 0, 93}, - { 6, 14, 16, 9, 10, 15, 5, 87}, - { 11, 14, 12, 15, 13, 15, 2, 89}, - { 8, 13, 15, 12, 11, 15, 3, 88}, - { 6, 14, 15, 11, 11, 16, 4, 87}, - { 6, 14, 15, 12, 11, 16, 6, 83} - }, - { - { 10, 6, 9, 11, 70, 11, 8, 9}, - { 9, 8, 6, 11, 49, 4, 10, 8}, - { 9, 38, 4, 11, 25, 6, 11, 8}, - { 9, 41, 22, 14, 15, 9, 11, 8}, - { 9, 8, 9, 11, 21, 68, 11, 7}, - { 9, 6, 7, 11, 49, 49, 4, 8}, - { 8, 9, 4, 11, 64, 23, 6, 8}, - { 9, 16, 7, 9, 52, 11, 11, 7}, - { 9, 10, 8, 10, 7, 19, 73, 5}, - { 8, 9, 7, 11, 4, 50, 51, 0}, - { 8, 9, 7, 11, 15, 66, 24, 3}, - { 9, 10, 6, 12, 33, 53, 14, 6}, - { 8, 9, 8, 10, 11, 5, 21, 67}, - { 7, 10, 6, 11, 11, 1, 55, 37}, - { 7, 11, 6, 11, 8, 13, 69, 15}, - { 8, 12, 6, 12, 11, 31, 52, 9} - }, - { - { 26, 43, 21, 27, 21, 46, 23, 26}, - { 26, 66, 67, 19, 25, 27, 28, 26}, - { 27, 18, 64, 63, 27, 27, 27, 27}, - { 28, 28, 16, 101, 28, 27, 27, 28}, - { 25, 42, 27, 24, 0, 81, 39, 21}, - { 25, 39, 84, 23, 23, 32, 28, 25}, - { 27, 22, 40, 84, 28, 25, 27, 27}, - { 29, 28, 15, 102, 28, 28, 27, 28}, - { 24, 34, 37, 22, 21, 19, 87, 30}, - { 25, 22, 82, 38, 25, 29, 33, 25}, - { 28, 26, 27, 95, 27, 28, 25, 27}, - { 30, 27, 17, 101, 28, 28, 27, 28}, - { 24, 24, 42, 27, 27, 27, 12, 95}, - { 26, 19, 64, 55, 29, 28, 23, 39}, - { 29, 28, 26, 94, 27, 28, 27, 26}, - { 30, 28, 20, 98, 28, 28, 27, 30} - } -}; - -ALIGN_DATA(MEMORY_ALIGN_DEF_SIZE, const short mipOffsetMatrix8x8[8]) = -{ 15, 14, 23, 45, 10, 14, 10, 27}; - -ALIGN_DATA(MEMORY_ALIGN_DEF_SIZE, const short mipShiftMatrix8x8[8]) = -{ 7, 7, 6, 6, 6, 6, 6, 6}; - -ALIGN_DATA(MEMORY_ALIGN_DEF_SIZE, const uint8_t mipMatrix16x16[6][64][7]) = -{ - { - { 22, 13, 15, 50, 16, 17, 14}, - { 55, 5, 15, 25, 22, 16, 14}, - { 83, 7, 14, 18, 22, 17, 14}, - { 58, 47, 7, 15, 21, 17, 15}, - { 15, 81, 9, 12, 20, 18, 14}, - { 5, 61, 38, 12, 19, 18, 14}, - { 14, 20, 73, 13, 17, 18, 15}, - { 18, 4, 84, 16, 16, 19, 16}, - { 30, 12, 15, 57, 36, 15, 14}, - { 54, 8, 14, 44, 33, 18, 13}, - { 69, 14, 12, 29, 32, 20, 12}, - { 48, 46, 8, 18, 30, 22, 13}, - { 17, 68, 14, 11, 26, 24, 13}, - { 10, 47, 43, 10, 22, 24, 13}, - { 16, 16, 70, 12, 18, 24, 14}, - { 20, 6, 77, 15, 16, 24, 16}, - { 24, 15, 15, 28, 67, 15, 15}, - { 38, 14, 14, 34, 52, 23, 13}, - { 46, 21, 13, 29, 45, 27, 11}, - { 36, 38, 13, 19, 38, 31, 11}, - { 21, 46, 22, 13, 31, 34, 11}, - { 18, 32, 43, 10, 26, 34, 12}, - { 21, 13, 62, 11, 21, 33, 14}, - { 22, 7, 66, 13, 18, 31, 17}, - { 18, 17, 15, 12, 58, 40, 12}, - { 22, 19, 15, 18, 50, 42, 12}, - { 24, 23, 15, 19, 44, 45, 11}, - { 25, 27, 19, 16, 37, 47, 11}, - { 24, 26, 27, 13, 31, 48, 12}, - { 25, 18, 39, 11, 27, 46, 13}, - { 25, 12, 48, 10, 23, 43, 16}, - { 25, 11, 51, 11, 20, 40, 19}, - { 16, 17, 16, 14, 24, 71, 13}, - { 14, 19, 16, 15, 27, 67, 14}, - { 14, 20, 17, 15, 26, 66, 13}, - { 18, 18, 21, 15, 24, 65, 13}, - { 24, 14, 27, 15, 22, 64, 14}, - { 27, 12, 31, 13, 20, 61, 16}, - { 27, 13, 35, 12, 19, 56, 19}, - { 26, 14, 37, 12, 18, 50, 23}, - { 15, 16, 16, 17, 8, 68, 31}, - { 13, 17, 17, 16, 8, 72, 26}, - { 13, 17, 18, 17, 8, 74, 23}, - { 16, 14, 21, 17, 8, 73, 22}, - { 21, 11, 24, 17, 9, 72, 22}, - { 25, 11, 24, 16, 9, 69, 24}, - { 26, 14, 25, 15, 10, 64, 26}, - { 25, 15, 28, 14, 12, 56, 30}, - { 14, 15, 16, 16, 9, 37, 62}, - { 14, 15, 17, 18, 4, 52, 51}, - { 15, 14, 18, 19, 1, 60, 44}, - { 17, 13, 19, 20, 0, 64, 41}, - { 20, 11, 20, 19, 1, 63, 40}, - { 22, 12, 20, 18, 3, 61, 40}, - { 23, 14, 20, 17, 5, 58, 40}, - { 23, 15, 22, 16, 8, 52, 42}, - { 16, 14, 17, 16, 12, 15, 81}, - { 17, 13, 17, 17, 6, 29, 71}, - { 18, 13, 18, 19, 3, 38, 64}, - { 18, 13, 18, 19, 1, 44, 60}, - { 19, 13, 17, 20, 2, 45, 58}, - { 20, 14, 17, 19, 3, 45, 56}, - { 21, 14, 18, 18, 5, 45, 55}, - { 22, 15, 19, 18, 7, 43, 53} - }, - { - { 42, 21, 26, 96, 39, 29, 20}, - { 42, 32, 28, 49, 66, 35, 21}, - { 30, 41, 30, 29, 73, 40, 23}, - { 23, 42, 35, 23, 72, 42, 26}, - { 25, 34, 44, 22, 68, 46, 26}, - { 26, 32, 49, 22, 65, 47, 25}, - { 24, 33, 53, 21, 62, 47, 25}, - { 22, 30, 62, 21, 57, 47, 25}, - { 27, 25, 27, 46, 97, 33, 22}, - { 11, 31, 31, 22, 94, 53, 22}, - { 0, 29, 35, 16, 89, 60, 26}, - { 6, 17, 41, 15, 86, 62, 28}, - { 20, 4, 42, 16, 84, 63, 28}, - { 26, 8, 35, 17, 84, 61, 28}, - { 23, 24, 25, 18, 83, 60, 27}, - { 21, 31, 27, 19, 77, 58, 28}, - { 16, 22, 27, 14, 107, 48, 24}, - { 11, 21, 32, 13, 84, 70, 26}, - { 11, 17, 36, 14, 77, 73, 29}, - { 13, 15, 35, 15, 77, 71, 31}, - { 16, 14, 34, 15, 80, 68, 30}, - { 17, 16, 31, 15, 84, 64, 30}, - { 19, 19, 29, 16, 85, 61, 29}, - { 19, 23, 30, 18, 81, 60, 29}, - { 17, 18, 28, 14, 81, 76, 24}, - { 15, 17, 31, 15, 71, 77, 33}, - { 15, 16, 33, 14, 70, 74, 36}, - { 15, 17, 32, 14, 73, 71, 36}, - { 15, 18, 32, 13, 77, 67, 36}, - { 15, 18, 32, 13, 81, 65, 34}, - { 16, 17, 32, 13, 82, 64, 32}, - { 18, 19, 32, 15, 78, 63, 32}, - { 18, 17, 28, 18, 52, 97, 31}, - { 16, 16, 31, 15, 64, 76, 41}, - { 14, 17, 31, 14, 66, 72, 43}, - { 15, 17, 32, 13, 70, 70, 42}, - { 16, 18, 33, 11, 72, 70, 38}, - { 16, 18, 33, 11, 74, 71, 35}, - { 17, 17, 34, 13, 73, 72, 32}, - { 18, 19, 33, 14, 70, 72, 32}, - { 17, 19, 26, 16, 39, 87, 55}, - { 14, 19, 29, 13, 57, 78, 49}, - { 15, 18, 31, 12, 61, 76, 45}, - { 15, 18, 32, 13, 63, 76, 42}, - { 16, 17, 33, 13, 63, 79, 38}, - { 17, 15, 35, 13, 62, 82, 34}, - { 18, 15, 36, 13, 62, 82, 33}, - { 19, 18, 34, 15, 59, 81, 33}, - { 17, 19, 25, 15, 34, 59, 89}, - { 14, 19, 29, 13, 47, 80, 56}, - { 14, 19, 31, 12, 54, 84, 44}, - { 16, 18, 32, 13, 57, 83, 41}, - { 17, 17, 33, 14, 55, 85, 38}, - { 18, 15, 35, 14, 53, 87, 36}, - { 19, 14, 36, 15, 53, 86, 35}, - { 20, 17, 36, 17, 52, 81, 37}, - { 19, 19, 26, 17, 32, 42, 105}, - { 17, 19, 28, 15, 40, 75, 65}, - { 16, 19, 30, 14, 45, 84, 49}, - { 17, 18, 32, 14, 50, 83, 45}, - { 18, 17, 33, 16, 50, 82, 43}, - { 19, 16, 35, 16, 49, 84, 40}, - { 20, 15, 38, 17, 48, 83, 40}, - { 21, 17, 38, 18, 48, 78, 41} - }, - { - { 52, 46, 46, 55, 50, 46, 47}, - { 65, 45, 45, 42, 52, 47, 47}, - { 74, 48, 45, 40, 51, 48, 47}, - { 67, 61, 44, 39, 50, 48, 48}, - { 52, 74, 45, 39, 48, 48, 49}, - { 44, 75, 53, 39, 47, 48, 50}, - { 44, 57, 71, 40, 46, 46, 51}, - { 50, 31, 92, 42, 45, 41, 55}, - { 55, 45, 45, 48, 61, 48, 46}, - { 65, 46, 45, 36, 57, 53, 46}, - { 72, 50, 44, 31, 54, 54, 48}, - { 66, 61, 44, 31, 51, 54, 49}, - { 54, 73, 45, 32, 48, 52, 52}, - { 45, 76, 52, 33, 46, 49, 55}, - { 45, 59, 70, 36, 44, 44, 59}, - { 50, 30, 93, 40, 43, 37, 64}, - { 54, 46, 45, 39, 66, 53, 46}, - { 65, 46, 45, 31, 57, 60, 47}, - { 71, 50, 44, 26, 52, 61, 50}, - { 67, 60, 44, 26, 48, 58, 53}, - { 56, 72, 45, 27, 45, 53, 58}, - { 47, 76, 51, 29, 43, 47, 63}, - { 46, 59, 69, 33, 41, 39, 69}, - { 51, 29, 93, 37, 40, 30, 76}, - { 53, 46, 46, 35, 60, 64, 47}, - { 64, 47, 45, 27, 53, 65, 50}, - { 71, 50, 45, 22, 49, 62, 55}, - { 68, 59, 44, 22, 46, 57, 61}, - { 58, 71, 45, 24, 43, 50, 67}, - { 48, 76, 51, 27, 41, 41, 74}, - { 46, 59, 69, 32, 39, 31, 82}, - { 51, 30, 93, 36, 38, 21, 88}, - { 52, 46, 46, 35, 51, 71, 50}, - { 63, 47, 45, 24, 51, 63, 58}, - { 70, 51, 45, 19, 49, 56, 65}, - { 68, 59, 44, 19, 45, 50, 72}, - { 58, 71, 45, 22, 42, 41, 80}, - { 48, 76, 51, 26, 39, 31, 88}, - { 46, 59, 69, 30, 37, 21, 95}, - { 51, 30, 93, 34, 36, 13, 100}, - { 52, 46, 46, 35, 47, 65, 61}, - { 62, 47, 45, 24, 49, 56, 69}, - { 69, 51, 45, 19, 47, 47, 77}, - { 68, 60, 44, 19, 44, 38, 85}, - { 59, 71, 45, 22, 40, 29, 94}, - { 49, 75, 51, 25, 37, 19, 102}, - { 47, 59, 69, 28, 35, 11, 108}, - { 52, 31, 93, 33, 34, 6, 110}, - { 52, 47, 46, 36, 46, 50, 77}, - { 61, 48, 45, 26, 46, 42, 84}, - { 67, 52, 45, 21, 44, 34, 92}, - { 66, 60, 44, 21, 41, 26, 100}, - { 59, 70, 46, 22, 38, 17, 108}, - { 50, 73, 53, 25, 35, 10, 114}, - { 48, 57, 70, 28, 33, 3, 118}, - { 52, 31, 92, 32, 32, 1, 118}, - { 52, 47, 46, 38, 45, 32, 93}, - { 59, 49, 46, 30, 43, 27, 99}, - { 65, 53, 46, 25, 41, 21, 106}, - { 64, 60, 46, 23, 38, 15, 111}, - { 58, 67, 48, 24, 36, 9, 117}, - { 51, 68, 56, 25, 34, 4, 121}, - { 49, 55, 72, 27, 32, 0, 123}, - { 52, 32, 92, 31, 30, 0, 123} - }, - { - { 18, 16, 16, 71, 13, 16, 16}, - { 36, 14, 16, 63, 18, 15, 17}, - { 64, 11, 16, 60, 20, 13, 17}, - { 64, 30, 13, 55, 22, 13, 17}, - { 33, 63, 9, 50, 25, 12, 18}, - { 15, 64, 24, 44, 27, 11, 18}, - { 19, 27, 59, 38, 30, 10, 18}, - { 24, 0, 81, 32, 31, 12, 18}, - { 22, 16, 16, 65, 46, 10, 17}, - { 25, 17, 16, 63, 50, 8, 18}, - { 35, 16, 16, 58, 54, 6, 19}, - { 41, 19, 16, 53, 58, 6, 19}, - { 36, 30, 15, 48, 62, 5, 19}, - { 28, 35, 20, 43, 63, 6, 19}, - { 26, 24, 35, 37, 62, 8, 18}, - { 26, 10, 50, 31, 59, 11, 19}, - { 18, 17, 16, 22, 81, 10, 18}, - { 18, 18, 16, 22, 81, 12, 19}, - { 19, 18, 16, 21, 81, 13, 19}, - { 22, 16, 17, 20, 80, 15, 18}, - { 25, 16, 17, 20, 77, 20, 17}, - { 26, 19, 17, 20, 73, 25, 16}, - { 25, 19, 20, 20, 68, 29, 16}, - { 24, 16, 27, 21, 60, 31, 17}, - { 16, 17, 16, 9, 59, 45, 14}, - { 16, 17, 16, 10, 55, 49, 14}, - { 16, 17, 16, 12, 50, 54, 14}, - { 17, 16, 16, 13, 45, 59, 13}, - { 19, 15, 16, 15, 39, 63, 13}, - { 21, 16, 16, 17, 35, 66, 14}, - { 22, 17, 16, 18, 33, 65, 16}, - { 22, 17, 19, 18, 33, 59, 21}, - { 17, 16, 16, 15, 20, 78, 16}, - { 17, 16, 16, 16, 18, 77, 19}, - { 17, 16, 15, 17, 15, 77, 22}, - { 17, 16, 15, 17, 13, 76, 24}, - { 18, 16, 15, 18, 11, 75, 27}, - { 18, 16, 15, 19, 11, 71, 31}, - { 19, 17, 15, 19, 13, 65, 35}, - { 19, 17, 16, 18, 16, 57, 39}, - { 17, 16, 16, 18, 9, 61, 42}, - { 17, 16, 15, 18, 10, 55, 47}, - { 18, 16, 15, 18, 9, 51, 52}, - { 18, 17, 15, 18, 9, 47, 56}, - { 18, 17, 15, 18, 10, 43, 60}, - { 18, 17, 14, 18, 11, 39, 63}, - { 18, 18, 14, 17, 12, 36, 65}, - { 19, 17, 15, 18, 13, 35, 65}, - { 16, 16, 15, 16, 14, 24, 75}, - { 17, 17, 15, 17, 14, 21, 78}, - { 17, 17, 15, 17, 14, 19, 80}, - { 18, 17, 15, 17, 13, 17, 82}, - { 18, 18, 14, 17, 13, 16, 84}, - { 18, 18, 15, 17, 13, 15, 84}, - { 19, 17, 15, 17, 13, 16, 84}, - { 19, 17, 16, 17, 14, 18, 81}, - { 16, 16, 16, 16, 16, 8, 89}, - { 17, 16, 16, 16, 16, 8, 89}, - { 18, 17, 15, 16, 15, 8, 90}, - { 18, 18, 15, 16, 15, 8, 90}, - { 19, 18, 15, 17, 15, 8, 90}, - { 19, 18, 15, 17, 15, 7, 90}, - { 19, 17, 16, 17, 14, 8, 90}, - { 19, 17, 17, 17, 15, 10, 87} - }, - { - { 29, 12, 13, 53, 18, 11, 15}, - { 56, 12, 13, 24, 32, 7, 16}, - { 54, 32, 12, 12, 33, 11, 15}, - { 21, 61, 15, 8, 27, 18, 13}, - { 5, 54, 36, 8, 20, 22, 13}, - { 10, 21, 64, 9, 15, 24, 16}, - { 16, 2, 75, 11, 11, 23, 23}, - { 16, 2, 68, 12, 9, 19, 33}, - { 29, 16, 14, 41, 56, 2, 17}, - { 28, 29, 15, 18, 56, 10, 15}, - { 14, 42, 21, 7, 42, 24, 13}, - { 6, 36, 37, 7, 25, 35, 14}, - { 11, 14, 55, 10, 13, 37, 21}, - { 16, 0, 61, 11, 8, 33, 31}, - { 16, 0, 56, 11, 6, 26, 43}, - { 15, 6, 46, 12, 7, 20, 53}, - { 13, 22, 16, 9, 73, 17, 14}, - { 8, 28, 22, 9, 46, 40, 11}, - { 6, 23, 32, 11, 21, 53, 15}, - { 11, 9, 43, 13, 9, 50, 27}, - { 16, 0, 46, 14, 4, 40, 42}, - { 17, 2, 41, 14, 5, 28, 55}, - { 15, 7, 34, 13, 6, 20, 65}, - { 14, 11, 29, 12, 9, 15, 69}, - { 10, 18, 19, 8, 35, 62, 9}, - { 9, 16, 25, 15, 13, 67, 18}, - { 12, 9, 32, 17, 4, 54, 36}, - { 15, 5, 34, 17, 4, 36, 53}, - { 16, 4, 31, 15, 7, 22, 67}, - { 16, 8, 27, 15, 9, 14, 75}, - { 14, 12, 22, 13, 10, 11, 79}, - { 12, 14, 21, 12, 12, 10, 78}, - { 12, 13, 19, 16, 6, 73, 23}, - { 13, 10, 24, 17, 4, 49, 46}, - { 14, 7, 26, 17, 7, 27, 65}, - { 15, 7, 25, 16, 10, 13, 77}, - { 15, 9, 22, 15, 12, 7, 83}, - { 14, 12, 19, 14, 13, 5, 85}, - { 13, 14, 18, 13, 13, 5, 85}, - { 12, 14, 18, 12, 14, 7, 82}, - { 14, 12, 19, 16, 7, 40, 56}, - { 14, 9, 22, 15, 11, 17, 74}, - { 14, 8, 22, 15, 13, 6, 84}, - { 14, 9, 21, 15, 14, 2, 87}, - { 13, 11, 18, 14, 14, 2, 88}, - { 13, 13, 17, 14, 15, 2, 88}, - { 12, 14, 16, 13, 16, 3, 87}, - { 12, 15, 16, 12, 15, 6, 83}, - { 14, 11, 18, 14, 14, 10, 81}, - { 14, 9, 19, 14, 15, 3, 87}, - { 14, 10, 19, 14, 15, 0, 90}, - { 13, 11, 17, 14, 15, 0, 90}, - { 13, 12, 17, 14, 15, 1, 89}, - { 13, 14, 16, 13, 16, 2, 88}, - { 12, 15, 15, 12, 16, 3, 86}, - { 12, 14, 16, 13, 16, 6, 83}, - { 13, 11, 17, 14, 16, 2, 87}, - { 14, 11, 18, 14, 16, 1, 88}, - { 14, 11, 17, 14, 15, 2, 88}, - { 13, 13, 17, 14, 15, 3, 87}, - { 13, 13, 17, 14, 15, 3, 86}, - { 13, 14, 16, 13, 16, 4, 85}, - { 12, 15, 16, 12, 16, 5, 83}, - { 12, 15, 16, 13, 15, 7, 81} - }, - { - { 11, 11, 11, 53, 9, 12, 11}, - { 18, 10, 10, 32, 13, 10, 11}, - { 40, 8, 11, 20, 13, 11, 11}, - { 56, 14, 9, 16, 13, 12, 10}, - { 47, 37, 6, 13, 12, 12, 10}, - { 23, 60, 10, 12, 13, 11, 11}, - { 10, 50, 33, 11, 12, 11, 11}, - { 13, 15, 66, 12, 12, 11, 11}, - { 15, 11, 11, 62, 26, 9, 10}, - { 13, 12, 10, 57, 17, 11, 10}, - { 17, 12, 10, 43, 15, 11, 10}, - { 34, 8, 11, 30, 14, 12, 10}, - { 49, 12, 10, 22, 13, 12, 10}, - { 45, 31, 7, 17, 13, 12, 10}, - { 28, 49, 11, 14, 13, 12, 10}, - { 17, 41, 31, 13, 13, 11, 10}, - { 14, 11, 11, 33, 59, 6, 11}, - { 13, 11, 11, 48, 42, 8, 10}, - { 12, 12, 11, 51, 30, 9, 10}, - { 18, 10, 11, 45, 22, 11, 10}, - { 31, 8, 11, 37, 17, 12, 10}, - { 41, 13, 10, 28, 15, 12, 9}, - { 39, 27, 8, 21, 15, 12, 10}, - { 29, 36, 15, 17, 15, 12, 10}, - { 11, 12, 11, 11, 63, 26, 8}, - { 12, 11, 11, 23, 61, 16, 10}, - { 12, 12, 11, 34, 53, 10, 10}, - { 13, 12, 11, 41, 43, 9, 10}, - { 18, 10, 11, 42, 33, 9, 10}, - { 27, 9, 11, 37, 26, 10, 10}, - { 33, 14, 10, 31, 22, 11, 10}, - { 32, 23, 12, 24, 20, 11, 10}, - { 11, 12, 11, 10, 32, 61, 5}, - { 11, 12, 11, 11, 49, 42, 6}, - { 11, 12, 11, 17, 58, 26, 8}, - { 11, 12, 11, 25, 58, 16, 9}, - { 13, 11, 11, 32, 52, 11, 9}, - { 17, 10, 11, 35, 43, 10, 10}, - { 23, 11, 10, 34, 35, 10, 10}, - { 27, 15, 11, 29, 29, 12, 9}, - { 11, 12, 11, 13, 9, 70, 17}, - { 11, 11, 11, 12, 23, 65, 10}, - { 11, 12, 10, 12, 38, 53, 6}, - { 11, 12, 10, 14, 51, 37, 7}, - { 11, 11, 11, 20, 56, 24, 8}, - { 12, 11, 11, 26, 53, 17, 9}, - { 16, 11, 11, 30, 47, 14, 9}, - { 20, 13, 11, 30, 38, 14, 10}, - { 11, 11, 10, 13, 9, 35, 52}, - { 11, 11, 10, 13, 11, 51, 34}, - { 11, 11, 10, 13, 20, 57, 20}, - { 11, 12, 10, 13, 33, 52, 12}, - { 10, 12, 10, 14, 44, 42, 10}, - { 11, 12, 10, 18, 49, 32, 9}, - { 12, 12, 11, 23, 49, 24, 10}, - { 15, 13, 11, 25, 43, 21, 10}, - { 11, 11, 11, 11, 16, 0, 81}, - { 10, 12, 10, 12, 16, 16, 65}, - { 11, 11, 10, 13, 17, 33, 47}, - { 11, 12, 10, 13, 22, 43, 31}, - { 11, 12, 10, 13, 29, 45, 21}, - { 11, 12, 11, 15, 37, 40, 16}, - { 11, 12, 11, 18, 41, 34, 14}, - { 12, 13, 12, 20, 40, 28, 14} - } -}; - -ALIGN_DATA(MEMORY_ALIGN_DEF_SIZE, const uint8_t mipOffsetMatrix16x16[6]) = -{ 15, 19, 46, 16, 14, 11}; - -ALIGN_DATA(MEMORY_ALIGN_DEF_SIZE, const uint8_t mipShiftMatrix16x16[6]) = -{ 6, 7, 5, 6, 6, 6}; -#endif \ No newline at end of file diff --git a/source/Lib/CommonLib/Mv.cpp b/source/Lib/CommonLib/Mv.cpp index e95ee8f1a9337a0e78a132d8a8c36d79c19daaa6..b4d7bef7a1f33ba048792c2e7a374ea553a05740 100644 --- a/source/Lib/CommonLib/Mv.cpp +++ b/source/Lib/CommonLib/Mv.cpp @@ -66,9 +66,8 @@ void clipMv( Mv& rcMv, const Position& pos, const struct Size& size, const SPS& int iVerMax = ( pps.getPicHeightInLumaSamples() + iOffset - (int)pos.y - 1 ) << iMvShift; int iVerMin = ( -( int ) sps.getMaxCUHeight() - iOffset - ( int ) pos.y + 1 ) << iMvShift; -#if JVET_O1143_MV_ACROSS_SUBPIC_BOUNDARY - SubPic curSubPic = pps.getSubPicFromPos(pos); - if (curSubPic.getTreatedAsPicFlag()) + const SubPic& curSubPic = pps.getSubPicFromPos(pos); + if (curSubPic.getTreatedAsPicFlag()) { iHorMax = ((curSubPic.getSubPicRight() + 1) + iOffset - (int)pos.x - 1 ) << iMvShift; iHorMin = (-(int)sps.getMaxCUWidth() - iOffset - ((int)pos.x - curSubPic.getSubPicLeft()) + 1) << iMvShift; @@ -76,7 +75,6 @@ void clipMv( Mv& rcMv, const Position& pos, const struct Size& size, const SPS& iVerMax = ((curSubPic.getSubPicBottom() + 1) + iOffset - (int)pos.y - 1) << iMvShift; iVerMin = (-(int)sps.getMaxCUHeight() - iOffset - ((int)pos.y - curSubPic.getSubPicTop()) + 1) << iMvShift; } -#endif rcMv.setHor( std::min( iHorMax, std::max( iHorMin, rcMv.getHor() ) ) ); rcMv.setVer( std::min( iVerMax, std::max( iVerMin, rcMv.getVer() ) ) ); } diff --git a/source/Lib/CommonLib/NAL.h b/source/Lib/CommonLib/NAL.h index 9e167bc790e85c3c2fc1cf49af324a887f54442c..f1605ce725c92e8e4d338817bd38a5c2a3155495 100644 --- a/source/Lib/CommonLib/NAL.h +++ b/source/Lib/CommonLib/NAL.h @@ -101,6 +101,24 @@ struct NALUnit || m_nalUnitType == NAL_UNIT_SUFFIX_SEI; } +#if JVET_R0201_PREFIX_SUFFIX_APS_CLEANUP + bool isVcl() + { + return isVclNalUnitType(m_nalUnitType); + } + + static bool isVclNalUnitType(NalUnitType t) + { + return t == NAL_UNIT_CODED_SLICE_TRAIL + || t == NAL_UNIT_CODED_SLICE_STSA + || t == NAL_UNIT_CODED_SLICE_RADL + || t == NAL_UNIT_CODED_SLICE_RASL + || t == NAL_UNIT_CODED_SLICE_IDR_W_RADL + || t == NAL_UNIT_CODED_SLICE_IDR_N_LP + || t == NAL_UNIT_CODED_SLICE_CRA + || t == NAL_UNIT_CODED_SLICE_GDR; + } +#else bool isVcl() { return m_nalUnitType == NAL_UNIT_CODED_SLICE_TRAIL @@ -112,6 +130,7 @@ struct NALUnit || m_nalUnitType == NAL_UNIT_CODED_SLICE_CRA || m_nalUnitType == NAL_UNIT_CODED_SLICE_GDR; } +#endif }; struct OutputNALUnit; diff --git a/source/Lib/CommonLib/ParameterSetManager.cpp b/source/Lib/CommonLib/ParameterSetManager.cpp index e1760f7dec2964fc160f556e327d7888e2784a75..c57d580ee0ab51062b6c94f6825c7dd3dbbd6003 100644 --- a/source/Lib/CommonLib/ParameterSetManager.cpp +++ b/source/Lib/CommonLib/ParameterSetManager.cpp @@ -38,13 +38,7 @@ ParameterSetManager::ParameterSetManager() : m_spsMap(MAX_NUM_SPS) , m_ppsMap(MAX_NUM_PPS) , m_apsMap(MAX_NUM_APS * MAX_NUM_APS_TYPE) -#if !JVET_Q0117_PARAMETER_SETS_CLEANUP -, m_dpsMap(MAX_NUM_DPS) -#endif , m_vpsMap(MAX_NUM_VPS) -#if !JVET_Q0117_PARAMETER_SETS_CLEANUP -, m_activeDPSId(-1) -#endif , m_activeSPSId(-1) , m_activeVPSId(-1) { @@ -63,47 +57,11 @@ bool ParameterSetManager::activatePPS(int ppsId, bool isIRAP) if (pps) { int spsId = pps->getSPSId(); -#if !ENABLING_MULTI_SPS - if (!isIRAP && (spsId != m_activeSPSId )) - { - msg( WARNING, "Warning: tried to activate a PPS referring to an inactive SPS at non-IDR."); - } - else -#endif { SPS *sps = m_spsMap.getPS(spsId); if (sps) { -#if !JVET_Q0117_PARAMETER_SETS_CLEANUP - int dpsId = sps->getDecodingParameterSetId(); - if ((m_activeDPSId!=-1) && (dpsId != m_activeDPSId )) - { - msg( WARNING, "Warning: tried to activate a DPS with different ID than the currently active DPS. This should not happen within the same bitstream!"); - } - else - { - if (dpsId != 0) - { - DPS *dps =m_dpsMap.getPS(dpsId); - if (dps) - { - m_activeDPSId = dpsId; - m_dpsMap.setActive(dpsId); - } - else - { - msg( WARNING, "Warning: tried to activate a PPS that refers to a non-existing DPS."); - } - } - else - { - // set zero as active DPS ID (special reserved value, no actual DPS) - m_activeDPSId = dpsId; - m_dpsMap.setActive(dpsId); - } - } -#endif int vpsId = sps->getVPSId(); if(vpsId != 0) { @@ -146,9 +104,6 @@ bool ParameterSetManager::activatePPS(int ppsId, bool isIRAP) // Failed to activate if reach here. m_activeSPSId=-1; -#if !JVET_Q0117_PARAMETER_SETS_CLEANUP - m_activeDPSId=-1; -#endif return false; } diff --git a/source/Lib/CommonLib/ParameterSetManager.h b/source/Lib/CommonLib/ParameterSetManager.h index 697f52b0c1381bcfcf2247f24da020948beb2e50..9f51cbb336974bff085b3e86e6dbaaadc2d83583 100644 --- a/source/Lib/CommonLib/ParameterSetManager.h +++ b/source/Lib/CommonLib/ParameterSetManager.h @@ -131,13 +131,27 @@ public: void checkAuApsContent( APS *aps, std::vector<int>& accessUnitApsNals ) { - int apsId = ( aps->getAPSId() << NUM_APS_TYPE_LEN ) + (int)aps->getAPSType(); + int apsId = aps->getAPSId() + MAX_NUM_APS * aps->getAPSType(); if( std::find( accessUnitApsNals.begin(), accessUnitApsNals.end(), apsId ) != accessUnitApsNals.end() ) { CHECK( m_paramsetMap.find( apsId ) == m_paramsetMap.end(), "APS does not exist" ); APS* existedAPS = m_paramsetMap[apsId].parameterSet; - +#if JVET_R0201_PREFIX_SUFFIX_APS_CLEANUP + bool sameNalUnitType = aps->getHasPrefixNalUnitType() == existedAPS->getHasPrefixNalUnitType(); + if( aps->getAPSType() == LMCS_APS ) + { + CHECK( sameNalUnitType && aps->getReshaperAPSInfo() != existedAPS->getReshaperAPSInfo(), "All APS NAL units with a particular value of nal_unit_type, a particular value of aps_adaptation_parameter_set_id, and a particular value of aps_params_type within a PU shall have the same content" ); + } + else if( aps->getAPSType() == ALF_APS ) + { + CHECK( sameNalUnitType && aps->getAlfAPSParam() != existedAPS->getAlfAPSParam(), "All APS NAL units with a particular value of nal_unit_type, a particular value of aps_adaptation_parameter_set_id, and a particular value of aps_params_type within a PU shall have the same content" ); + } + else if( aps->getAPSType() == SCALING_LIST_APS ) + { + CHECK( sameNalUnitType && aps->getScalingList() != existedAPS->getScalingList(), "All APS NAL units with a particular value of nal_unit_type, a particular value of aps_adaptation_parameter_set_id, and a particular value of aps_params_type within a PU shall have the same content" ); + } +#else if( aps->getAPSType() == LMCS_APS ) { CHECK( aps->getReshaperAPSInfo() != existedAPS->getReshaperAPSInfo(), "All APS NAL units with a particular value of adaptation_parameter_set_id and a particular value of aps_params_type within an access unit shall have the same content" ); @@ -150,6 +164,7 @@ public: { CHECK( aps->getScalingList() != existedAPS->getScalingList(), "All APS NAL units with a particular value of adaptation_parameter_set_id and a particular value of aps_params_type within an access unit shall have the same content" ); } +#endif else { CHECK( true, "Wrong APS type" ); @@ -227,14 +242,6 @@ public: void storeVPS(VPS *vps, const std::vector<uint8_t> &naluData) { m_vpsMap.storePS(vps->getVPSId(), vps, &naluData); } VPS* getVPS( int vpsId ) { return m_vpsMap.getPS( vpsId ); }; -#if !JVET_Q0117_PARAMETER_SETS_CLEANUP - void storeDPS(DPS *dps, const std::vector<uint8_t> &naluData) { m_dpsMap.storePS( dps->getDecodingParameterSetId(), dps, &naluData); }; - // get pointer to existing video parameter set - DPS* getDPS(int dpsId) { return m_dpsMap.getPS(dpsId); }; - bool getDPSChangedFlag(int dpsId) const { return m_dpsMap.getChangedFlag(dpsId); } - void clearDPSChangedFlag(int dpsId) { m_dpsMap.clearChangedFlag(dpsId); } - DPS* getFirstDPS() { return m_dpsMap.getFirstPS(); }; -#endif // store sequence parameter set and take ownership of it // warning: sps object cannot be used after storing (repeated parameter sets are directly deleted) void storeSPS(SPS *sps, const std::vector<uint8_t> &naluData) { m_spsMap.storePS( sps->getSPSId(), sps, &naluData); }; @@ -268,24 +275,15 @@ public: APS* getFirstAPS() { return m_apsMap.getFirstPS(); }; bool activateAPS(int apsId, int apsType); const SPS* getActiveSPS()const { return m_spsMap.getPS(m_activeSPSId); }; -#if !JVET_Q0117_PARAMETER_SETS_CLEANUP - const DPS* getActiveDPS()const { return m_dpsMap.getPS(m_activeDPSId); }; -#endif void checkAuApsContent( APS *aps, std::vector<int>& accessUnitApsNals ) { m_apsMap.checkAuApsContent( aps, accessUnitApsNals ); } protected: ParameterSetMap<SPS> m_spsMap; ParameterSetMap<PPS> m_ppsMap; ParameterSetMap<APS> m_apsMap; -#if !JVET_Q0117_PARAMETER_SETS_CLEANUP - ParameterSetMap<DPS> m_dpsMap; -#endif ParameterSetMap<VPS> m_vpsMap; APS* m_apss[ALF_CTB_MAX_NUM_APS]; -#if !JVET_Q0117_PARAMETER_SETS_CLEANUP - int m_activeDPSId; // -1 for nothing active -#endif int m_activeSPSId; // -1 for nothing active int m_activeVPSId; // -1 for nothing active }; diff --git a/source/Lib/CommonLib/Picture.cpp b/source/Lib/CommonLib/Picture.cpp index a74e5ed1e1ecf3e74d1116d80786b94552234ab6..5a73072f8e955a38ccc2e94e080b8104d02c4e76 100644 --- a/source/Lib/CommonLib/Picture.cpp +++ b/source/Lib/CommonLib/Picture.cpp @@ -173,9 +173,7 @@ int Scheduler::getNumPicInstances() const Picture::Picture() { cs = nullptr; -#if JVET_O1143_MV_ACROSS_SUBPIC_BOUNDARY m_isSubPicBorderSaved = false; -#endif m_bIsBorderExtended = false; usedByCurr = false; longTerm = false; @@ -725,19 +723,13 @@ void Picture::rescalePicture( const std::pair<int, int> scalingRatio, const PelBuf& afterScale = afterScaling.get( compID ); sampleRateConv( scalingRatio, std::pair<int, int>( ::getComponentScaleX( compID, chromaFormatIDC ), ::getComponentScaleY( compID, chromaFormatIDC ) ), -#if JVET_Q0487_SCALING_WINDOW_ISSUES - beforeScale, scalingWindowBefore.getWindowLeftOffset() * SPS::getWinUnitX( chromaFormatIDC ), scalingWindowBefore.getWindowTopOffset() * SPS::getWinUnitY( chromaFormatIDC ), - afterScale, scalingWindowAfter.getWindowLeftOffset() * SPS::getWinUnitX( chromaFormatIDC ), scalingWindowAfter.getWindowTopOffset() * SPS::getWinUnitY( chromaFormatIDC ), -#else - beforeScale, scalingWindowBefore.getWindowLeftOffset(), scalingWindowBefore.getWindowTopOffset(), - afterScale, scalingWindowAfter.getWindowLeftOffset(), scalingWindowAfter.getWindowTopOffset(), -#endif + beforeScale, scalingWindowBefore.getWindowLeftOffset() * SPS::getWinUnitX( chromaFormatIDC ), scalingWindowBefore.getWindowTopOffset() * SPS::getWinUnitY( chromaFormatIDC ), + afterScale, scalingWindowAfter.getWindowLeftOffset() * SPS::getWinUnitX( chromaFormatIDC ), scalingWindowAfter.getWindowTopOffset() * SPS::getWinUnitY( chromaFormatIDC ), bitDepths.recon[toChannelType(compID)], downsampling || useLumaFilter ? true : isLuma( compID ), downsampling, isLuma( compID ) ? 1 : horCollocatedChromaFlag, isLuma( compID ) ? 1 : verCollocatedChromaFlag ); } } -#if JVET_O1143_MV_ACROSS_SUBPIC_BOUNDARY void Picture::saveSubPicBorder(int POC, int subPicX0, int subPicY0, int subPicWidth, int subPicHeight) { @@ -757,7 +749,7 @@ void Picture::saveSubPicBorder(int POC, int subPicX0, int subPicY0, int subPicWi m_bufSubPicLeft.create(unitAreaLeftRight); m_bufSubPicRight.create(unitAreaLeftRight); - for (int comp = 0; comp < getNumberValidComponents(cs->area.chromaFormat); comp++) + for (int comp = 0; comp < getNumberValidComponents(cs->area.chromaFormat); comp++) { ComponentID compID = ComponentID(comp); @@ -790,7 +782,7 @@ void Picture::saveSubPicBorder(int POC, int subPicX0, int subPicY0, int subPicWi // 3.2.3 copy to recon picture to back up buffer Pel *srcLeft = src - xmargin; Pel *srcRight = src + width; - for (int y = 0; y < height; y++) + for (int y = 0; y < height; y++) { ::memcpy(dstLeft + y * dBufLeft.stride, srcLeft + y * s.stride, sizeof(Pel) * xmargin); ::memcpy(dstRight + y * dBufRight.stride, srcRight + y * s.stride, sizeof(Pel) * xmargin); @@ -807,7 +799,7 @@ void Picture::saveSubPicBorder(int POC, int subPicX0, int subPicY0, int subPicWi // 3.3.3 copy to recon picture to back up buffer Pel *srcTop = src - xmargin - ymargin * s.stride; Pel *srcBottom = src - xmargin + height * s.stride; - for (int y = 0; y < ymargin; y++) + for (int y = 0; y < ymargin; y++) { ::memcpy(dstTop + y * dBufTop.stride, srcTop + y * s.stride, sizeof(Pel) * (2 * xmargin + width)); ::memcpy(dstBottom + y * dBufBottom.stride, srcBottom + y * s.stride, sizeof(Pel) * (2 * xmargin + width)); @@ -818,7 +810,7 @@ void Picture::saveSubPicBorder(int POC, int subPicX0, int subPicY0, int subPicWi void Picture::extendSubPicBorder(int POC, int subPicX0, int subPicY0, int subPicWidth, int subPicHeight) { - for (int comp = 0; comp < getNumberValidComponents(cs->area.chromaFormat); comp++) + for (int comp = 0; comp < getNumberValidComponents(cs->area.chromaFormat); comp++) { ComponentID compID = ComponentID(comp); @@ -845,9 +837,9 @@ void Picture::extendSubPicBorder(int POC, int subPicX0, int subPicY0, int subPic Pel *srcLeft = src + 0; Pel *srcRight = src + width - 1; - for (int y = 0; y < height; y++) + for (int y = 0; y < height; y++) { - for (int x = 0; x < xmargin; x++) + for (int x = 0; x < xmargin; x++) { dstLeft[x] = *srcLeft; dstRight[x] = *srcRight; @@ -859,7 +851,7 @@ void Picture::extendSubPicBorder(int POC, int subPicX0, int subPicY0, int subPic } } - // 4.2 apply padding on bottom + // 4.2 apply padding on bottom Pel *srcBottom = src + s.stride * (height - 1) - xmargin; Pel *dstBottom = srcBottom + s.stride; for (int y = 0; y < ymargin; y++) @@ -878,12 +870,12 @@ void Picture::extendSubPicBorder(int POC, int subPicX0, int subPicY0, int subPic ::memcpy(dstTop, srcTop, sizeof(Pel)*(2 * xmargin + width)); dstTop -= s.stride; } - } // end of for + } // end of for } void Picture::restoreSubPicBorder(int POC, int subPicX0, int subPicY0, int subPicWidth, int subPicHeight) { - for (int comp = 0; comp < getNumberValidComponents(cs->area.chromaFormat); comp++) + for (int comp = 0; comp < getNumberValidComponents(cs->area.chromaFormat); comp++) { ComponentID compID = ComponentID(comp); @@ -915,7 +907,7 @@ void Picture::restoreSubPicBorder(int POC, int subPicX0, int subPicY0, int subPi Pel *srcLeft = src - xmargin; Pel *srcRight = src + width; - for (int y = 0; y < height; y++) + for (int y = 0; y < height; y++) { // the destination and source position is reversed on purpose ::memcpy(srcLeft + y * s.stride, dstLeft + y * dBufLeft.stride, sizeof(Pel) * xmargin); @@ -935,7 +927,7 @@ void Picture::restoreSubPicBorder(int POC, int subPicX0, int subPicY0, int subPi Pel *srcTop = src - xmargin - ymargin * s.stride; Pel *srcBottom = src - xmargin + height * s.stride; - for (int y = 0; y < ymargin; y++) + for (int y = 0; y < ymargin; y++) { ::memcpy(srcTop + y * s.stride, dstTop + y * dBufTop.stride, sizeof(Pel) * (2 * xmargin + width)); ::memcpy(srcBottom + y * s.stride, dstBottom + y * dBufBottom.stride, sizeof(Pel) * (2 * xmargin + width)); @@ -948,7 +940,6 @@ void Picture::restoreSubPicBorder(int POC, int subPicX0, int subPicY0, int subPi m_bufSubPicLeft.destroy(); m_bufSubPicRight.destroy(); } -#endif void Picture::extendPicBorder() { diff --git a/source/Lib/CommonLib/Picture.h b/source/Lib/CommonLib/Picture.h index 28440c240626ce1880758f88f1e6558ad81d45dd..b705491e9172a33b3182838fdc5967e2622031dd 100644 --- a/source/Lib/CommonLib/Picture.h +++ b/source/Lib/CommonLib/Picture.h @@ -148,15 +148,18 @@ struct Picture : public UnitArea void finalInit( const VPS* vps, const SPS& sps, const PPS& pps, PicHeader *picHeader, APS** alfApss, APS* lmcsAps, APS* scalingListAps ); int getPOC() const { return poc; } -#if JVET_P0978_RPL_RESTRICTIONS int getDecodingOrderNumber() const { return m_decodingOrderNumber; } void setDecodingOrderNumber(const int val) { m_decodingOrderNumber = val; } NalUnitType getPictureType() const { return m_pictureType; } void setPictureType(const NalUnitType val) { m_pictureType = val; } -#endif void setBorderExtension( bool bFlag) { m_bIsBorderExtended = bFlag;} Pel* getOrigin( const PictureType &type, const ComponentID compID ) const; +#if JVET_R0110_MIXED_LOSSLESS + void setLossyQPValue(int i) { m_lossyQP = i; } + int getLossyQPValue() const { return m_lossyQP; } +#endif + int getSpliceIdx(uint32_t idx) const { return m_spliceIdx[idx]; } void setSpliceIdx(uint32_t idx, int poc) { m_spliceIdx[idx] = poc; } void createSpliceIdx(int nums); @@ -167,8 +170,8 @@ struct Picture : public UnitArea const int bitDepth, const bool useLumaFilter, const bool downsampling, const bool horCollocatedPositionFlag, const bool verCollocatedPositionFlag ); - static void rescalePicture( const std::pair<int, int> scalingRatio, - const CPelUnitBuf& beforeScaling, const Window& scalingWindowBefore, + static void rescalePicture( const std::pair<int, int> scalingRatio, + const CPelUnitBuf& beforeScaling, const Window& scalingWindowBefore, const PelUnitBuf& afterScaling, const Window& scalingWindowAfter, const ChromaFormat chromaFormatIDC, const BitDepths& bitDepths, const bool useLumaFilter, const bool downsampling, const bool horCollocatedChromaFlag, const bool verCollocatedChromaFlag ); @@ -176,13 +179,10 @@ struct Picture : public UnitArea private: Window m_conformanceWindow; Window m_scalingWindow; -#if JVET_P0978_RPL_RESTRICTIONS int m_decodingOrderNumber; NalUnitType m_pictureType; -#endif public: -#if JVET_O1143_MV_ACROSS_SUBPIC_BOUNDARY bool m_isSubPicBorderSaved; PelStorage m_bufSubPicAbove; @@ -196,7 +196,6 @@ public: bool getSubPicSaved() { return m_isSubPicBorderSaved; } void setSubPicSaved(bool bVal) { m_isSubPicBorderSaved = bVal; } -#endif bool m_bIsBorderExtended; bool referenced; bool reconstructed; @@ -217,9 +216,15 @@ public: int* m_spliceIdx; int m_ctuNums; - +#if JVET_R0110_MIXED_LOSSLESS + int m_lossyQP; +#endif bool interLayerRefPicFlag; +#if JVET_R0276_REORDERED_SUBPICS + std::vector<int> subPicIDs; +#endif + #if ENABLE_SPLIT_PARALLELISM PelStorage m_bufs[PARL_SPLIT_MAX_NUM_JOBS][NUM_PIC_TYPES]; #else @@ -242,14 +247,12 @@ public: const Window& getConformanceWindow() const { return m_conformanceWindow; } Window& getScalingWindow() { return m_scalingWindow; } const Window& getScalingWindow() const { return m_scalingWindow; } -#if JVET_Q0487_SCALING_WINDOW_ISSUES bool isRefScaled( const PPS* pps ) const { return unscaledPic->getPicWidthInLumaSamples() != pps->getPicWidthInLumaSamples() || unscaledPic->getPicHeightInLumaSamples() != pps->getPicHeightInLumaSamples() || getScalingWindow().getWindowLeftOffset() != pps->getScalingWindow().getWindowLeftOffset() || getScalingWindow().getWindowRightOffset() != pps->getScalingWindow().getWindowRightOffset() || getScalingWindow().getWindowTopOffset() != pps->getScalingWindow().getWindowTopOffset() || getScalingWindow().getWindowBottomOffset() != pps->getScalingWindow().getWindowBottomOffset(); } -#endif void allocateNewSlice(); Slice *swapSliceObject(Slice * p, uint32_t i); @@ -324,10 +327,8 @@ public: int calcAndPrintHashStatus(const CPelUnitBuf& pic, const class SEIDecodedPictureHash* pictureHashSEI, const BitDepths &bitDepths, const MsgLevel msgl); -#if JVET_P2008_OUTPUT_LOG uint32_t calcMD5(const CPelUnitBuf& pic, PictureHash &digest, const BitDepths &bitDepths); std::string hashToString(const PictureHash &digest, int numChar); -#endif // JVET_P2008_OUTPUT_LOG typedef std::list<Picture*> PicList; diff --git a/source/Lib/CommonLib/ProfileLevelTier.cpp b/source/Lib/CommonLib/ProfileLevelTier.cpp index e6faf212bef7557e0424e6b5ee9edb3d7dbc049b..0d47501d59c1c73f6fc358e92246812de66dd032 100644 --- a/source/Lib/CommonLib/ProfileLevelTier.cpp +++ b/source/Lib/CommonLib/ProfileLevelTier.cpp @@ -126,7 +126,6 @@ uint64_t ProfileLevelTierFeatures::getCpbSizeInBits() const return (m_pLevelTier!=0 && m_pProfile!=0) ? uint64_t(m_pProfile->cpbVclFactor) * m_pLevelTier->maxCpb[m_tier?1:0] : uint64_t(0); } -#if JVET_Q0814_DPB uint32_t ProfileLevelTierFeatures::getMaxDpbSize( uint32_t picSizeMaxInSamplesY ) const { const uint32_t maxDpbPicBuf = 8; @@ -147,4 +146,3 @@ uint32_t ProfileLevelTierFeatures::getMaxDpbSize( uint32_t picSizeMaxInSamplesY return maxDpbSize; } -#endif \ No newline at end of file diff --git a/source/Lib/CommonLib/ProfileLevelTier.h b/source/Lib/CommonLib/ProfileLevelTier.h index dfb9d4596896a6417e53717be3d1735308f096d0..2d99c311f2bc4db0654b52ccf75f2d41bcd84247 100644 --- a/source/Lib/CommonLib/ProfileLevelTier.h +++ b/source/Lib/CommonLib/ProfileLevelTier.h @@ -95,9 +95,7 @@ class ProfileLevelTierFeatures Level::Tier getTier() const { return m_tier; } uint64_t getCpbSizeInBits() const; double getMinCr() const; -#if JVET_Q0814_DPB uint32_t getMaxDpbSize( uint32_t picSizeMaxInSamplesY ) const; -#endif }; diff --git a/source/Lib/CommonLib/Quant.cpp b/source/Lib/CommonLib/Quant.cpp index 87fa5aa7c0524a99e863fdb29d878a3f77924668..0bc59f1e2f95c98bbd1c038a79cbdeb021fc0dca 100644 --- a/source/Lib/CommonLib/Quant.cpp +++ b/source/Lib/CommonLib/Quant.cpp @@ -65,14 +65,16 @@ QpParam::QpParam(const int qpy, const ComponentID compID, const int qpBdOffset, +#if JVET_R0045_TS_MIN_QP_CLEANUP + const int internalMinusInputBitDepth, +#else const int minQpPrimeTsMinus4, +#endif const int chromaQPOffset, const ChromaFormat chFmt, const int dqp , const SPS *sps -#if JVET_Q0820_ACT , const bool applyACTQpoffset -#endif ) { int baseQp; @@ -87,12 +89,10 @@ QpParam::QpParam(const int qpy, baseQp = Clip3(-qpBdOffset, MAX_QP, baseQp + chromaQPOffset) + qpBdOffset; } -#if JVET_Q0820_ACT if (applyACTQpoffset) { baseQp += DELTA_QP_ACT[compID]; } -#endif baseQp = Clip3( 0, MAX_QP+qpBdOffset, baseQp + dqp ); Qps[0] =baseQp; @@ -100,18 +100,18 @@ QpParam::QpParam(const int qpy, rems[0]=baseQp%6; int baseQpTS = baseQp; +#if JVET_R0045_TS_MIN_QP_CLEANUP + baseQpTS = std::max(baseQpTS, 4 + 6 * internalMinusInputBitDepth); +#else baseQpTS = std::max(baseQpTS, 4 + minQpPrimeTsMinus4); +#endif Qps[1] = baseQpTS; pers[1] = baseQpTS / 6; rems[1] = baseQpTS % 6; } -#if JVET_Q0820_ACT QpParam::QpParam(const TransformUnit& tu, const ComponentID &compIDX, const int QP /*= -MAX_INT*/, const bool allowACTQpoffset /*= true*/) -#else -QpParam::QpParam(const TransformUnit& tu, const ComponentID &compIDX, const int QP /*= -MAX_INT*/) -#endif { int chromaQpOffset = 0; ComponentID compID = MAP_CHROMA(compIDX); @@ -129,11 +129,11 @@ QpParam::QpParam(const TransformUnit& tu, const ComponentID &compIDX, const int int dqp = 0; const bool useJQP = isChroma(compID) && (abs(TU::getICTMode(tu)) == 2); -#if JVET_Q0820_ACT bool applyACTQpoffset = tu.cu->colorTransform && allowACTQpoffset; - *this = QpParam(QP <= -MAX_INT ? tu.cu->qp : QP, useJQP ? JOINT_CbCr : compID, tu.cs->sps->getQpBDOffset(toChannelType(compID)), tu.cs->sps->getMinQpPrimeTsMinus4(toChannelType(compID)), chromaQpOffset, tu.chromaFormat, dqp, tu.cs->sps, applyACTQpoffset); +#if JVET_R0045_TS_MIN_QP_CLEANUP + *this = QpParam(QP <= -MAX_INT ? tu.cu->qp : QP, useJQP ? JOINT_CbCr : compID, tu.cs->sps->getQpBDOffset(toChannelType(compID)), tu.cs->sps->getInternalMinusInputBitDepth(toChannelType(compID)), chromaQpOffset, tu.chromaFormat, dqp, tu.cs->sps, applyACTQpoffset); #else - *this = QpParam(QP <= -MAX_INT ? tu.cu->qp : QP, useJQP ? JOINT_CbCr : compID, tu.cs->sps->getQpBDOffset(toChannelType(compID)), tu.cs->sps->getMinQpPrimeTsMinus4(toChannelType(compID)), chromaQpOffset, tu.chromaFormat, dqp, tu.cs->sps); + *this = QpParam(QP <= -MAX_INT ? tu.cu->qp : QP, useJQP ? JOINT_CbCr : compID, tu.cs->sps->getQpBDOffset(toChannelType(compID)), tu.cs->sps->getMinQpPrimeTsMinus4(toChannelType(compID)), chromaQpOffset, tu.chromaFormat, dqp, tu.cs->sps, applyACTQpoffset); #endif } @@ -381,16 +381,13 @@ void Quant::dequant(const TransformUnit &tu, const TCoeff transformMinimum = -(1 << maxLog2TrDynamicRange); const TCoeff transformMaximum = (1 << maxLog2TrDynamicRange) - 1; const bool isTransformSkip = (tu.mtsIdx[compID] == MTS_SKIP); -#if JVET_Q0346_SCALING_LIST_USED_IN_SH const bool disableSMForLFNST = tu.cs->slice->getExplicitScalingListUsed() ? tu.cs->picHeader->getScalingListAPS()->getScalingList().getDisableScalingMatrixForLfnstBlks() : false; -#else - const bool disableSMForLFNST = tu.cs->picHeader->getScalingListPresentFlag() ? tu.cs->picHeader->getScalingListAPS()->getScalingList().getDisableScalingMatrixForLfnstBlks() : false; -#endif -#if JVET_Q0784_LFNST_COMBINATION const bool isLfnstApplied = tu.cu->lfnstIdx > 0 && (tu.cu->isSepTree() ? true : isLuma(compID)); - const bool enableScalingLists = getUseScalingList(uiWidth, uiHeight, isTransformSkip, isLfnstApplied, disableSMForLFNST); +#if JVET_R0380_SCALING_MATRIX_DISABLE_YCC_OR_RGB + const bool disableSMForACT = tu.cs->slice->getSPS()->getScalingMatrixForAlternativeColourSpaceDisabledFlag() && (tu.cs->slice->getSPS()->getScalingMatrixDesignatedColourSpaceFlag() == tu.cu->colorTransform); + const bool enableScalingLists = getUseScalingList(uiWidth, uiHeight, isTransformSkip, isLfnstApplied, disableSMForLFNST, disableSMForACT); #else - const bool enableScalingLists = getUseScalingList(uiWidth, uiHeight, isTransformSkip, tu.cu->lfnstIdx > 0, disableSMForLFNST); + const bool enableScalingLists = getUseScalingList(uiWidth, uiHeight, isTransformSkip, isLfnstApplied, disableSMForLFNST); #endif const int scalingListType = getScalingListType(tu.cu->predMode, compID); const int channelBitDepth = sps->getBitDepth(toChannelType(compID)); @@ -545,25 +542,30 @@ void Quant::setScalingList(ScalingList *scalingList, const int maxLog2TrDynamicR { for(uint32_t list = 0; list < SCALING_LIST_NUM; list++) { +#if JVET_R0166_SCALING_LISTS_CHROMA_444 + if (size == SCALING_LIST_2x2 && list < 4) // skip 2x2 luma +#else if ((size == SCALING_LIST_2x2 && list < 4) || (size == SCALING_LIST_64x64 && list % (SCALING_LIST_NUM / SCALING_LIST_PRED_MODES) != 0)) // skip 2x2 luma +#endif continue; -#if JVET_Q0505_CHROAM_QM_SIGNALING_400 +#if JVET_R0166_SCALING_LISTS_CHROMA_444 + scalingListId = g_scalingListId[size][list]; +#endif if (scalingList->getChromaScalingListPresentFlag() || scalingList->isLumaScalingList(scalingListId)) { -#endif for(int qp = minimumQp; qp < maximumQp; qp++) { xSetScalingListEnc(scalingList, list, size, qp, scalingListId); xSetScalingListDec(*scalingList, list, size, qp, scalingListId); } -#if JVET_Q0505_CHROAM_QM_SIGNALING_400 } else // chroma QMs in 400 { scalingList->processDefaultMatrix(scalingListId); } -#endif +#if !JVET_R0166_SCALING_LISTS_CHROMA_444 scalingListId++; +#endif } } //based on square result and apply downsample technology @@ -575,9 +577,15 @@ void Quant::setScalingList(ScalingList *scalingList, const int maxLog2TrDynamicR for (uint32_t list = 0; list < SCALING_LIST_NUM; list++) //9 { int largerSide = (sizew > sizeh) ? sizew : sizeh; +#if !JVET_R0166_SCALING_LISTS_CHROMA_444 if (largerSide == SCALING_LIST_64x64 && list % (SCALING_LIST_NUM / SCALING_LIST_PRED_MODES) != 0) continue; +#endif if (largerSide < SCALING_LIST_4x4) printf("Rectangle Error !\n"); +#if JVET_R0166_SCALING_LISTS_CHROMA_444 + recScalingListId = g_scalingListId[largerSide][list]; +#else recScalingListId = SCALING_LIST_NUM * (largerSide - 2) + 2 + (list / ((largerSide == SCALING_LIST_64x64) ? 3 : 1)); +#endif for (int qp = minimumQp; qp < maximumQp; qp++) { xSetRecScalingListEnc(scalingList, list, sizew, sizeh, qp, recScalingListId); @@ -602,13 +610,22 @@ void Quant::setScalingListDec(const ScalingList &scalingList) { for(uint32_t list = 0; list < SCALING_LIST_NUM; list++) { +#if JVET_R0166_SCALING_LISTS_CHROMA_444 + if (size == SCALING_LIST_2x2 && list < 4) // skip 2x2 luma +#else if ((size == SCALING_LIST_2x2 && list < 4) || (size == SCALING_LIST_64x64 && list % (SCALING_LIST_NUM / SCALING_LIST_PRED_MODES) != 0)) // skip 2x2 luma +#endif continue; +#if JVET_R0166_SCALING_LISTS_CHROMA_444 + scalingListId = g_scalingListId[size][list]; +#endif for(int qp = minimumQp; qp < maximumQp; qp++) { xSetScalingListDec(scalingList, list, size, qp, scalingListId); } +#if !JVET_R0166_SCALING_LISTS_CHROMA_444 scalingListId++; +#endif } } //based on square result and apply downsample technology @@ -621,9 +638,15 @@ void Quant::setScalingListDec(const ScalingList &scalingList) for (uint32_t list = 0; list < SCALING_LIST_NUM; list++) //9 { int largerSide = (sizew > sizeh) ? sizew : sizeh; +#if !JVET_R0166_SCALING_LISTS_CHROMA_444 if (largerSide == SCALING_LIST_64x64 && list % (SCALING_LIST_NUM / SCALING_LIST_PRED_MODES) != 0) continue; +#endif if (largerSide < SCALING_LIST_4x4) printf("Rectangle Error !\n"); +#if JVET_R0166_SCALING_LISTS_CHROMA_444 + recScalingListId = g_scalingListId[largerSide][list]; +#else recScalingListId = SCALING_LIST_NUM * (largerSide - 2) + 2 + (list / ((largerSide == SCALING_LIST_64x64) ? 3 : 1)); +#endif for (int qp = minimumQp; qp < maximumQp; qp++) { xSetRecScalingListDec(scalingList, list, sizew, sizeh, qp, recScalingListId); @@ -991,8 +1014,11 @@ void Quant::quant(TransformUnit &tu, const ComponentID &compID, const CCoeffBuf const int maxLog2TrDynamicRange = sps.getMaxLog2TrDynamicRange(toChannelType(compID)); { +#if JVET_R0271_SLICE_LEVEL_DQ_SDH_RRC + CoeffCodingContext cctx(tu, compID, tu.cs->slice->getSignDataHidingEnabledFlag()); +#else CoeffCodingContext cctx(tu, compID, tu.cs->picHeader->getSignDataHidingEnabledFlag()); - +#endif const TCoeff entropyCodingMinimum = -(1 << maxLog2TrDynamicRange); const TCoeff entropyCodingMaximum = (1 << maxLog2TrDynamicRange) - 1; @@ -1002,16 +1028,13 @@ void Quant::quant(TransformUnit &tu, const ComponentID &compID, const CCoeffBuf const uint32_t uiLog2TrWidth = floorLog2(uiWidth); const uint32_t uiLog2TrHeight = floorLog2(uiHeight); int *piQuantCoeff = getQuantCoeff(scalingListType, cQP.rem(useTransformSkip), uiLog2TrWidth, uiLog2TrHeight); -#if JVET_Q0346_SCALING_LIST_USED_IN_SH const bool disableSMForLFNST = tu.cs->slice->getExplicitScalingListUsed() ? tu.cs->picHeader->getScalingListAPS()->getScalingList().getDisableScalingMatrixForLfnstBlks() : false; -#else - const bool disableSMForLFNST = tu.cs->picHeader->getScalingListPresentFlag() ? tu.cs->picHeader->getScalingListAPS()->getScalingList().getDisableScalingMatrixForLfnstBlks() : false; -#endif -#if JVET_Q0784_LFNST_COMBINATION const bool isLfnstApplied = tu.cu->lfnstIdx > 0 && (tu.cu->isSepTree() ? true : isLuma(compID)); - const bool enableScalingLists = getUseScalingList(uiWidth, uiHeight, useTransformSkip, isLfnstApplied, disableSMForLFNST); +#if JVET_R0380_SCALING_MATRIX_DISABLE_YCC_OR_RGB + const bool disableSMForACT = tu.cs->slice->getSPS()->getScalingMatrixForAlternativeColourSpaceDisabledFlag() && (tu.cs->slice->getSPS()->getScalingMatrixDesignatedColourSpaceFlag() == tu.cu->colorTransform); + const bool enableScalingLists = getUseScalingList(uiWidth, uiHeight, useTransformSkip, isLfnstApplied, disableSMForLFNST, disableSMForACT); #else - const bool enableScalingLists = getUseScalingList(uiWidth, uiHeight, useTransformSkip, tu.cu->lfnstIdx > 0, disableSMForLFNST); + const bool enableScalingLists = getUseScalingList(uiWidth, uiHeight, useTransformSkip, isLfnstApplied, disableSMForLFNST); #endif // for blocks that where width*height != 4^N, the effective scaling applied during transformation cannot be @@ -1035,8 +1058,12 @@ void Quant::quant(TransformUnit &tu, const ComponentID &compID, const CCoeffBuf const uint32_t lfnstIdx = tu.cu->lfnstIdx; const int maxNumberOfCoeffs = lfnstIdx > 0 ? ((( uiWidth == 4 && uiHeight == 4 ) || ( uiWidth == 8 && uiHeight == 8) ) ? 8 : 16) : piQCoef.area(); memset( piQCoef.buf, 0, sizeof(TCoeff) * piQCoef.area() ); - for (int uiBlockPos = 0; uiBlockPos < maxNumberOfCoeffs; uiBlockPos++ ) + + const ScanElement* scan = g_scanOrder[SCAN_GROUPED_4x4][SCAN_DIAG][gp_sizeIdxInfo->idxFrom(uiWidth)][gp_sizeIdxInfo->idxFrom(uiHeight)]; + + for (int uiScanPos = 0; uiScanPos < maxNumberOfCoeffs; uiScanPos++) { + const int uiBlockPos = scan[uiScanPos].idx; const TCoeff iLevel = piCoef.buf[uiBlockPos]; const TCoeff iSign = (iLevel < 0 ? -1: 1); @@ -1085,16 +1112,13 @@ bool Quant::xNeedRDOQ(TransformUnit &tu, const ComponentID &compID, const CCoeff const uint32_t uiLog2TrHeight = floorLog2(uiHeight); int *piQuantCoeff = getQuantCoeff(scalingListType, cQP.rem(useTransformSkip), uiLog2TrWidth, uiLog2TrHeight); -#if JVET_Q0346_SCALING_LIST_USED_IN_SH const bool disableSMForLFNST = tu.cs->slice->getExplicitScalingListUsed() ? tu.cs->picHeader->getScalingListAPS()->getScalingList().getDisableScalingMatrixForLfnstBlks() : false; -#else - const bool disableSMForLFNST = tu.cs->picHeader->getScalingListPresentFlag() ? tu.cs->picHeader->getScalingListAPS()->getScalingList().getDisableScalingMatrixForLfnstBlks() : false; -#endif -#if JVET_Q0784_LFNST_COMBINATION const bool isLfnstApplied = tu.cu->lfnstIdx > 0 && (tu.cu->isSepTree() ? true : isLuma(compID)); - const bool enableScalingLists = getUseScalingList(uiWidth, uiHeight, (useTransformSkip != 0), isLfnstApplied, disableSMForLFNST); +#if JVET_R0380_SCALING_MATRIX_DISABLE_YCC_OR_RGB + const bool disableSMForACT = tu.cs->slice->getSPS()->getScalingMatrixForAlternativeColourSpaceDisabledFlag() && (tu.cs->slice->getSPS()->getScalingMatrixDesignatedColourSpaceFlag() == tu.cu->colorTransform); + const bool enableScalingLists = getUseScalingList(uiWidth, uiHeight, (useTransformSkip != 0), isLfnstApplied, disableSMForLFNST, disableSMForACT); #else - const bool enableScalingLists = getUseScalingList(uiWidth, uiHeight, (useTransformSkip != 0), tu.cu->lfnstIdx > 0, disableSMForLFNST); + const bool enableScalingLists = getUseScalingList(uiWidth, uiHeight, (useTransformSkip != 0), isLfnstApplied, disableSMForLFNST); #endif /* for 422 chroma blocks, the effective scaling applied during transformation is not a power of 2, hence it cannot be @@ -1144,16 +1168,13 @@ void Quant::transformSkipQuantOneSample(TransformUnit &tu, const ComponentID &co const int channelBitDepth = sps.getBitDepth(toChannelType(compID)); const int iTransformShift = getTransformShift(channelBitDepth, rect.size(), maxLog2TrDynamicRange); const int scalingListType = getScalingListType(tu.cu->predMode, compID); -#if JVET_Q0346_SCALING_LIST_USED_IN_SH const bool disableSMForLFNST = tu.cs->slice->getExplicitScalingListUsed() ? tu.cs->picHeader->getScalingListAPS()->getScalingList().getDisableScalingMatrixForLfnstBlks() : false; -#else - const bool disableSMForLFNST = tu.cs->picHeader->getScalingListPresentFlag() ? tu.cs->picHeader->getScalingListAPS()->getScalingList().getDisableScalingMatrixForLfnstBlks() : false; -#endif -#if JVET_Q0784_LFNST_COMBINATION const bool isLfnstApplied = tu.cu->lfnstIdx > 0 && (tu.cu->isSepTree() ? true : isLuma(compID)); - const bool enableScalingLists = getUseScalingList(uiWidth, uiHeight, true, isLfnstApplied, disableSMForLFNST); +#if JVET_R0380_SCALING_MATRIX_DISABLE_YCC_OR_RGB + const bool disableSMForACT = tu.cs->slice->getSPS()->getScalingMatrixForAlternativeColourSpaceDisabledFlag() && (tu.cs->slice->getSPS()->getScalingMatrixDesignatedColourSpaceFlag() == tu.cu->colorTransform); + const bool enableScalingLists = getUseScalingList(uiWidth, uiHeight, true, isLfnstApplied, disableSMForLFNST, disableSMForACT); #else - const bool enableScalingLists = getUseScalingList(uiWidth, uiHeight, true, tu.cu->lfnstIdx > 0, disableSMForLFNST); + const bool enableScalingLists = getUseScalingList(uiWidth, uiHeight, true, isLfnstApplied, disableSMForLFNST); #endif const bool useTransformSkip = (tu.mtsIdx[compID] == MTS_SKIP); const int defaultQuantisationCoefficient = g_quantScales[0][cQP.rem(useTransformSkip)]; @@ -1212,16 +1233,13 @@ void Quant::invTrSkipDeQuantOneSample(TransformUnit &tu, const ComponentID &comp const int channelBitDepth = sps.getBitDepth(toChannelType(compID)); const int iTransformShift = getTransformShift(channelBitDepth, rect.size(), maxLog2TrDynamicRange); const int scalingListType = getScalingListType(tu.cu->predMode, compID); -#if JVET_Q0346_SCALING_LIST_USED_IN_SH const bool disableSMForLFNST = tu.cs->slice->getExplicitScalingListUsed() ? tu.cs->picHeader->getScalingListAPS()->getScalingList().getDisableScalingMatrixForLfnstBlks() : false; -#else - const bool disableSMForLFNST = tu.cs->picHeader->getScalingListPresentFlag() ? tu.cs->picHeader->getScalingListAPS()->getScalingList().getDisableScalingMatrixForLfnstBlks() : false; -#endif -#if JVET_Q0784_LFNST_COMBINATION const bool isLfnstApplied = tu.cu->lfnstIdx > 0 && (tu.cu->isSepTree() ? true : isLuma(compID)); - const bool enableScalingLists = getUseScalingList(uiWidth, uiHeight, true, isLfnstApplied, disableSMForLFNST); +#if JVET_R0380_SCALING_MATRIX_DISABLE_YCC_OR_RGB + const bool disableSMForACT = tu.cs->slice->getSPS()->getScalingMatrixForAlternativeColourSpaceDisabledFlag() && (tu.cs->slice->getSPS()->getScalingMatrixDesignatedColourSpaceFlag() == tu.cu->colorTransform); + const bool enableScalingLists = getUseScalingList(uiWidth, uiHeight, true, isLfnstApplied, disableSMForLFNST, disableSMForACT); #else - const bool enableScalingLists = getUseScalingList(uiWidth, uiHeight, true, tu.cu->lfnstIdx > 0, disableSMForLFNST); + const bool enableScalingLists = getUseScalingList(uiWidth, uiHeight, true, isLfnstApplied, disableSMForLFNST); #endif CHECK(scalingListType >= SCALING_LIST_NUM, "Invalid scaling list"); @@ -1302,11 +1320,7 @@ void Quant::lambdaAdjustColorTrans(bool forward) for (uint8_t component = 0; component < MAX_NUM_COMPONENT; component++) { ComponentID compID = (ComponentID)component; -#if JVET_Q0820_ACT int delta_QP = DELTA_QP_ACT[compID]; -#else - int delta_QP = (compID == COMPONENT_Cr ? DELTA_QP_FOR_Co : DELTA_QP_FOR_Y_Cg); -#endif double lamdbaAdjustRate = pow(2.0, delta_QP / 3.0); m_lambdasStore[0][component] = m_lambdas[component]; @@ -1314,7 +1328,7 @@ void Quant::lambdaAdjustColorTrans(bool forward) } m_resetStore = false; } - + if (forward) { CHECK(m_pairCheck == 1, "lambda has been already adjusted"); diff --git a/source/Lib/CommonLib/Quant.h b/source/Lib/CommonLib/Quant.h index c5c638a8acabe25cacce59033d5ca8627acc4e05..0a1b5570e451f273fd7a01d7a58e07ffbf45b930 100644 --- a/source/Lib/CommonLib/Quant.h +++ b/source/Lib/CommonLib/Quant.h @@ -77,23 +77,21 @@ private: QpParam(const int qpy, const ComponentID compID, const int qpBdOffset, +#if JVET_R0045_TS_MIN_QP_CLEANUP + const int internalMinusInputBitDepth, +#else const int minQpPrimeTsMinus4, +#endif const int chromaQPOffset, const ChromaFormat chFmt, const int dqp , const SPS *sps -#if JVET_Q0820_ACT , const bool applyACTQpoffset -#endif ); public: -#if JVET_Q0820_ACT QpParam(const TransformUnit& tu, const ComponentID &compID, const int QP = -MAX_INT, const bool allowACTQpoffset = true); -#else - QpParam(const TransformUnit& tu, const ComponentID &compID, const int QP = -MAX_INT); -#endif int Qp ( const bool ts ) const { return Qps [ts?1:0]; } int per( const bool ts ) const { return pers[ts?1:0]; } @@ -136,9 +134,17 @@ public: int* getDequantCoeff ( uint32_t list, int qp, uint32_t sizeX, uint32_t sizeY ) { return m_dequantCoef [sizeX][sizeY][list][qp]; }; //!< get DeQuant Coefficent void setUseScalingList ( bool bUseScalingList){ m_scalingListEnabledFlag = bUseScalingList; }; - bool getUseScalingList(const uint32_t width, const uint32_t height, const bool isTransformSkip, const bool lfnstApplied, const bool disableScalingMatrixForLFNSTBlks) - { +#if JVET_R0380_SCALING_MATRIX_DISABLE_YCC_OR_RGB + bool getUseScalingList(const uint32_t width, const uint32_t height, const bool isTransformSkip, const bool lfnstApplied, const bool disableScalingMatrixForLFNSTBlks, const bool disableSMforACT) +#else + bool getUseScalingList(const uint32_t width, const uint32_t height, const bool isTransformSkip, const bool lfnstApplied, const bool disableScalingMatrixForLFNSTBlks) +#endif + { +#if JVET_R0380_SCALING_MATRIX_DISABLE_YCC_OR_RGB + return (m_scalingListEnabledFlag && !isTransformSkip && (!lfnstApplied || !disableScalingMatrixForLFNSTBlks) && !disableSMforACT); +#else return (m_scalingListEnabledFlag && !isTransformSkip && (!lfnstApplied || !disableScalingMatrixForLFNSTBlks)); +#endif } void setScalingListDec ( const ScalingList &scalingList); void processScalingListEnc ( int *coeff, int *quantcoeff, int qpMod6, uint32_t height, uint32_t width, uint32_t ratio, int sizuNum, uint32_t dc); diff --git a/source/Lib/CommonLib/QuantRDOQ.cpp b/source/Lib/CommonLib/QuantRDOQ.cpp index a811c59b29f0ee05db5adef222ffabcdbed06a9d..9b4d0543a9c0ec6f595345f10f2e010b924d98cc 100644 --- a/source/Lib/CommonLib/QuantRDOQ.cpp +++ b/source/Lib/CommonLib/QuantRDOQ.cpp @@ -527,6 +527,11 @@ void QuantRDOQ::quant(TransformUnit &tu, const ComponentID &compID, const CCoeff useRDOQ &= uiHeight > 2; } +#if JVET_R0110_MIXED_LOSSLESS + if (tu.cs->slice->isLossless()) + useRDOQ = false; +#endif + if (useRDOQ && (isLuma(compID) || RDOQ_CHROMA)) { #if T0196_SELECTIVE_RDOQ @@ -629,16 +634,13 @@ void QuantRDOQ::xRateDistOptQuant(TransformUnit &tu, const ComponentID &compID, const bool isTransformSkip = (tu.mtsIdx[compID] == MTS_SKIP); const double *const pdErrScale = xGetErrScaleCoeffSL(scalingListType, uiLog2BlockWidth, uiLog2BlockHeight, cQP.rem(isTransformSkip)); const int *const piQCoef = getQuantCoeff(scalingListType, cQP.rem(isTransformSkip), uiLog2BlockWidth, uiLog2BlockHeight); -#if JVET_Q0346_SCALING_LIST_USED_IN_SH const bool disableSMForLFNST = tu.cs->slice->getExplicitScalingListUsed() ? tu.cs->picHeader->getScalingListAPS()->getScalingList().getDisableScalingMatrixForLfnstBlks() : false; -#else - const bool disableSMForLFNST = tu.cs->picHeader->getScalingListPresentFlag() ? tu.cs->picHeader->getScalingListAPS()->getScalingList().getDisableScalingMatrixForLfnstBlks() : false; -#endif -#if JVET_Q0784_LFNST_COMBINATION const bool isLfnstApplied = tu.cu->lfnstIdx > 0 && (tu.cu->isSepTree() ? true : isLuma(compID)); - const bool enableScalingLists = getUseScalingList(uiWidth, uiHeight, isTransformSkip, isLfnstApplied, disableSMForLFNST); +#if JVET_R0380_SCALING_MATRIX_DISABLE_YCC_OR_RGB + const bool disableSMForACT = tu.cs->slice->getSPS()->getScalingMatrixForAlternativeColourSpaceDisabledFlag() && (tu.cs->slice->getSPS()->getScalingMatrixDesignatedColourSpaceFlag() == tu.cu->colorTransform); + const bool enableScalingLists = getUseScalingList(uiWidth, uiHeight, isTransformSkip, isLfnstApplied, disableSMForLFNST, disableSMForACT); #else - const bool enableScalingLists = getUseScalingList(uiWidth, uiHeight, isTransformSkip, tu.cu->lfnstIdx > 0, disableSMForLFNST); + const bool enableScalingLists = getUseScalingList(uiWidth, uiHeight, isTransformSkip, isLfnstApplied, disableSMForLFNST); #endif const int defaultQuantisationCoefficient = g_quantScales[ needSqrtAdjustment ?1:0][cQP.rem(isTransformSkip)]; const double defaultErrorScale = xGetErrScaleCoeffNoScalingList(scalingListType, uiLog2BlockWidth, uiLog2BlockHeight, cQP.rem(isTransformSkip)); @@ -647,8 +649,12 @@ void QuantRDOQ::xRateDistOptQuant(TransformUnit &tu, const ComponentID &compID, const TCoeff entropyCodingMinimum = -(1 << maxLog2TrDynamicRange); const TCoeff entropyCodingMaximum = (1 << maxLog2TrDynamicRange) - 1; - + +#if JVET_R0271_SLICE_LEVEL_DQ_SDH_RRC + CoeffCodingContext cctx(tu, compID, tu.cs->slice->getSignDataHidingEnabledFlag()); +#else CoeffCodingContext cctx(tu, compID, tu.cs->picHeader->getSignDataHidingEnabledFlag()); +#endif const int iCGSizeM1 = (1 << cctx.log2CGSize()) - 1; int iCGLastScanPos = -1; @@ -1233,7 +1239,11 @@ void QuantRDOQ::xRateDistOptQuantTS( TransformUnit &tu, const ComponentID &compI uint32_t coeffLevels[3]; double coeffLevelError[4]; +#if JVET_R0271_SLICE_LEVEL_DQ_SDH_RRC + CoeffCodingContext cctx( tu, compID, tu.cs->slice->getSignDataHidingEnabledFlag() ); +#else CoeffCodingContext cctx( tu, compID, tu.cs->picHeader->getSignDataHidingEnabledFlag() ); +#endif const int sbSizeM1 = ( 1 << cctx.log2CGSize() ) - 1; double baseCost = 0; uint32_t goRiceParam = 0; @@ -1458,7 +1468,11 @@ void QuantRDOQ::forwardRDPCM( TransformUnit &tu, const ComponentID &compID, cons uint32_t coeffLevels[3]; double coeffLevelError[4]; +#if JVET_R0271_SLICE_LEVEL_DQ_SDH_RRC + CoeffCodingContext cctx(tu, compID, tu.cs->slice->getSignDataHidingEnabledFlag()); +#else CoeffCodingContext cctx(tu, compID, tu.cs->picHeader->getSignDataHidingEnabledFlag()); +#endif const int sbSizeM1 = (1 << cctx.log2CGSize()) - 1; double baseCost = 0; uint32_t goRiceParam = 0; @@ -1709,7 +1723,7 @@ inline uint32_t QuantRDOQ::xGetCodedLevelTSPred(double& rd64CodedCost dErr = double(levelDouble - (Intermediate_Int(absLevel) << qBits)); coeffLevelError[errorInd] = dErr * dErr * errorScale; int modAbsLevel = absLevel; - if (cctx.numCtxBins() >= 4) + if (cctx.numCtxBins() >= 4) { modAbsLevel = cctx.deriveModCoeff(rightPixel, belowPixel, absLevel, m_bdpcm); } @@ -1743,11 +1757,11 @@ inline int QuantRDOQ::xGetICRateTS( const uint32_t absLevel, const bool useLimitedPrefixLength, const int maxLog2TrDynamicRange ) const { - - - if (cctx.numCtxBins() < 4) // Full by-pass coding + + + if (cctx.numCtxBins() < 4) // Full by-pass coding { - int rate = absLevel ? (1 << SCALE_BITS) : 0; // 1 bit to signal sign of non-zero + int rate = absLevel ? (1 << SCALE_BITS) : 0; // 1 bit to signal sign of non-zero uint32_t symbol = absLevel; @@ -1854,8 +1868,8 @@ inline int QuantRDOQ::xGetICRateTS( const uint32_t absLevel, } - - + + int rate = fracBitsSign.intBits[sign]; if (absLevel) diff --git a/source/Lib/CommonLib/RdCost.cpp b/source/Lib/CommonLib/RdCost.cpp index 5a68bee8aee8913ad2830b7874efbbb97c8db157..4f4cdb5850559216f6475ebbfb0b61f0813a535c 100644 --- a/source/Lib/CommonLib/RdCost.cpp +++ b/source/Lib/CommonLib/RdCost.cpp @@ -65,12 +65,14 @@ double RdCost::calcRdCost( uint64_t fracBits, Distortion distortion, bool useUna double RdCost::calcRdCost( uint64_t fracBits, Distortion distortion ) #endif { -#if JVET_AHG14_LOSSLESS - if( m_costMode == COST_LOSSLESS_CODING && 0 != distortion ) +#if JVET_R0110_MIXED_LOSSLESS + if (m_costMode == COST_LOSSLESS_CODING && 0 != distortion && m_isLosslessRDCost) +#else + if( m_costMode == COST_LOSSLESS_CODING && 0 != distortion) +#endif { return MAX_DOUBLE; } -#endif #if WCG_EXT return ( useUnadjustedLambda ? m_DistScaleUnadjusted : m_DistScale ) * double( distortion ) + double( fracBits ); #else @@ -92,11 +94,7 @@ void RdCost::lambdaAdjustColorTrans(bool forward, ComponentID componentID) for (uint8_t component = 0; component < MAX_NUM_COMPONENT; component++) { ComponentID compID = (ComponentID)component; -#if JVET_Q0820_ACT int delta_QP = DELTA_QP_ACT[compID]; -#else - int delta_QP = (compID == COMPONENT_Cr ? DELTA_QP_FOR_Co : DELTA_QP_FOR_Y_Cg); -#endif double lamdbaAdjustRate = pow(2.0, delta_QP / 3.0); m_lambdaStore[0][component] = m_dLambda; @@ -107,7 +105,7 @@ void RdCost::lambdaAdjustColorTrans(bool forward, ComponentID componentID) } m_resetStore = false; } - + if (forward) { CHECK(m_pairCheck == 1, "lambda has been already adjusted"); @@ -205,9 +203,7 @@ void RdCost::init() m_afpDistortFunc[DF_SAD_INTERMEDIATE_BITDEPTH] = RdCost::xGetSAD; -#if JVET_Q0806 m_afpDistortFunc[DF_SAD_WITH_MASK] = RdCost::xGetSADwMask; -#endif #if ENABLE_SIMD_OPT_DIST #ifdef TARGET_SIMD_X86 @@ -322,7 +318,6 @@ void RdCost::setDistParam( DistParam &rcDP, const CPelBuf &org, const Pel* piRef rcDP.subShift = 1; } } -#if JVET_Q0806 else if( subShiftMode == 3 ) { if (rcDP.org.height > 8 ) @@ -330,7 +325,6 @@ void RdCost::setDistParam( DistParam &rcDP, const CPelBuf &org, const Pel* piRef rcDP.subShift = 1; } } -#endif } void RdCost::setDistParam( DistParam &rcDP, const CPelBuf &org, const CPelBuf &cur, int bitDepth, ComponentID compID, bool useHadamard ) @@ -2161,7 +2155,11 @@ Distortion RdCost::xCalcHADs2x2( const Pel *piOrg, const Pel *piCur, int iStride m[2] = diff[0] - diff[2]; m[3] = diff[1] - diff[3]; +#if JVET_R0164_MEAN_SCALED_SATD + satd += abs(m[0] + m[1]) >> 2; +#else satd += abs(m[0] + m[1]); +#endif satd += abs(m[0] - m[1]); satd += abs(m[2] + m[3]); satd += abs(m[2] - m[3]); @@ -2260,7 +2258,12 @@ Distortion RdCost::xCalcHADs4x4( const Pel *piOrg, const Pel *piCur, int iStride { satd += abs(d[k]); } - satd = ((satd+1)>>1); + +#if JVET_R0164_MEAN_SCALED_SATD + satd -= abs(d[0]); + satd += abs(d[0]) >> 2; +#endif + satd = ((satd+1)>>1); return satd; } @@ -2357,7 +2360,11 @@ Distortion RdCost::xCalcHADs8x8( const Pel *piOrg, const Pel *piCur, int iStride } } - sad=((sad+2)>>2); +#if JVET_R0164_MEAN_SCALED_SATD + sad -= abs(m2[0][0]); + sad += abs(m2[0][0]) >> 2; +#endif + sad = ((sad+2)>>2); return sad; } @@ -2503,7 +2510,11 @@ Distortion RdCost::xCalcHADs16x8( const Pel *piOrg, const Pel *piCur, int iStrid } } - sad = ( int ) ( sad / sqrt( 16.0 * 8 ) * 2 ); +#if JVET_R0164_MEAN_SCALED_SATD + sad -= abs(m2[0][0]); + sad += abs(m2[0][0]) >> 2; +#endif + sad = ( int ) ( sad / sqrt( 16.0 * 8 ) * 2 ); return sad; } @@ -2640,7 +2651,11 @@ Distortion RdCost::xCalcHADs8x16( const Pel *piOrg, const Pel *piCur, int iStrid } } - sad = ( int ) ( sad / sqrt( 16.0 * 8 ) * 2 ); +#if JVET_R0164_MEAN_SCALED_SATD + sad -= abs(m2[0][0]); + sad += abs(m2[0][0]) >> 2; +#endif + sad = ( int ) ( sad / sqrt( 16.0 * 8 ) * 2 ); return sad; } @@ -2713,7 +2728,11 @@ Distortion RdCost::xCalcHADs4x8( const Pel *piOrg, const Pel *piCur, int iStride } } - sad = ( int ) ( sad / sqrt( 4.0 * 8 ) * 2 ); +#if JVET_R0164_MEAN_SCALED_SATD + sad -= abs(m2[0][0]); + sad += abs(m2[0][0]) >> 2; +#endif + sad = ( int ) ( sad / sqrt( 4.0 * 8 ) * 2 ); return sad; } @@ -2792,7 +2811,11 @@ Distortion RdCost::xCalcHADs8x4( const Pel *piOrg, const Pel *piCur, int iStride } } - sad = ( int ) ( sad / sqrt( 4.0 * 8 ) * 2 ); +#if JVET_R0164_MEAN_SCALED_SATD + sad -= abs(m2[0][0]); + sad += abs(m2[0][0]) >> 2; +#endif + sad = ( int ) ( sad / sqrt( 4.0 * 8 ) * 2 ); return sad; } @@ -3466,7 +3489,6 @@ Distortion RdCost::xGetMRHADs( const DistParam &rcDtParam ) return m_afpDistortFunc[DF_HAD]( modDistParam ); } -#if JVET_Q0806 void RdCost::setDistParam( DistParam &rcDP, const CPelBuf &org, const Pel* piRefY, int iRefStride, const Pel* mask, int iMaskStride, int stepX, int iMaskStride2, int bitDepth, ComponentID compID) { rcDP.bitDepth = bitDepth; @@ -3529,5 +3551,4 @@ Distortion RdCost::xGetSADwMask( const DistParam& rcDtParam ) sum <<= subShift; return (sum >> distortionShift ); } -#endif //! \} diff --git a/source/Lib/CommonLib/RdCost.h b/source/Lib/CommonLib/RdCost.h index 7d10e131abeee507b6dd52fb589a2d843f2c060b..3cf776c1af231d0e9d420c53ef414b7acdf49116 100644 --- a/source/Lib/CommonLib/RdCost.h +++ b/source/Lib/CommonLib/RdCost.h @@ -72,12 +72,10 @@ public: #if WCG_EXT CPelBuf orgLuma; #endif -#if JVET_Q0806 const Pel* mask; int maskStride; int stepX; int maskStride2; -#endif int step; FpDistFunc distFunc; int bitDepth; @@ -96,13 +94,11 @@ public: int cShiftX; int cShiftY; DistParam() : - org(), cur(), -#if JVET_Q0806 + org(), cur(), mask( nullptr ), maskStride( 0 ), stepX(0), maskStride2(0), -#endif step( 1 ), bitDepth( 0 ), useMR( false ), applyWeight( false ), isBiPred( false ), wpCur( nullptr ), compID( MAX_NUM_COMPONENT ), maximumDistortionForEarlyExit( std::numeric_limits<Distortion>::max() ), subShift( 0 ) , cShiftX(-1), cShiftY(-1) { } @@ -118,6 +114,10 @@ private: CostMode m_costMode; double m_distortionWeight[MAX_NUM_COMPONENT]; // only chroma values are used. double m_dLambda; +#if JVET_R0110_MIXED_LOSSLESS + bool m_isLosslessRDCost; +#endif + #if WCG_EXT double m_dLambda_unadjusted; // TODO: check is necessary double m_DistScaleUnadjusted; @@ -168,6 +168,9 @@ public: #endif void setCostMode(CostMode m) { m_costMode = m; } +#if JVET_R0110_MIXED_LOSSLESS + void setLosslessRDCost(bool m) { m_isLosslessRDCost = m; } +#endif // Distortion Functions void init(); @@ -180,9 +183,7 @@ public: void setDistParam( DistParam &rcDP, const CPelBuf &org, const Pel* piRefY , int iRefStride, int bitDepth, ComponentID compID, int subShiftMode = 0, int step = 1, bool useHadamard = false ); void setDistParam( DistParam &rcDP, const CPelBuf &org, const CPelBuf &cur, int bitDepth, ComponentID compID, bool useHadamard = false ); void setDistParam( DistParam &rcDP, const Pel* pOrg, const Pel* piRefY, int iOrgStride, int iRefStride, int bitDepth, ComponentID compID, int width, int height, int subShiftMode = 0, int step = 1, bool useHadamard = false, bool bioApplied = false ); -#if JVET_Q0806 void setDistParam( DistParam &rcDP, const CPelBuf &org, const Pel* piRefY, int iRefStride, const Pel* mask, int iMaskStride, int stepX, int iMaskStride2, int bitDepth, ComponentID compID); -#endif double getMotionLambda ( ) { return m_dLambdaMotionSAD; } void selectMotionLambda ( ) { m_motionLambda = getMotionLambda( ); } @@ -367,9 +368,7 @@ private: static Distortion xGetSAD48 ( const DistParam& pcDtParam ); static Distortion xGetSAD_full ( const DistParam& pcDtParam ); -#if JVET_Q0806 static Distortion xGetSADwMask ( const DistParam& pcDtParam ); -#endif static Distortion xGetMRSAD ( const DistParam& pcDtParam ); static Distortion xGetMRSAD4 ( const DistParam& pcDtParam ); @@ -409,11 +408,9 @@ private: template<X86_VEXT vext> static Distortion xGetHADs_SIMD ( const DistParam& pcDtParam ); -#if JVET_Q0806 template< X86_VEXT vext > static Distortion xGetSADwMask_SIMD( const DistParam& pcDtParam ); #endif -#endif public: @@ -423,9 +420,7 @@ public: Distortion getDistPart( const CPelBuf &org, const CPelBuf &cur, int bitDepth, const ComponentID compID, DFunc eDFunc ); #endif -#if JVET_Q0806 Distortion getDistPart(const CPelBuf &org, const CPelBuf &cur, const Pel* mask, int bitDepth, const ComponentID compID, DFunc eDFunc); -#endif };// END CLASS DEFINITION RdCost //! \} diff --git a/source/Lib/CommonLib/Reshape.cpp b/source/Lib/CommonLib/Reshape.cpp index 4d6ac24644cca6d38c6a471c10d8c092ebb6a3fb..06b777cae51aef1ea0b24c50afe58c94919179f9 100644 --- a/source/Lib/CommonLib/Reshape.cpp +++ b/source/Lib/CommonLib/Reshape.cpp @@ -95,8 +95,12 @@ void Reshape::destroy() */ int Reshape::calculateChromaAdj(Pel avgLuma) { +#if JVET_R0330_CRS_CLIP_REM + int iAdj = m_chromaAdjHelpLUT[getPWLIdxInv(avgLuma)]; +#else int lumaIdx = Clip3<int>(0, (1<<m_lumaBD) - 1, avgLuma); int iAdj = m_chromaAdjHelpLUT[getPWLIdxInv(lumaIdx)]; +#endif return(iAdj); } @@ -181,16 +185,28 @@ int Reshape::calculateChromaAdjVpduNei(TransformUnit &tu, const CompArea &areaY } if (pelnum == numNeighbor) { +#if JVET_R0330_CRS_CLIP_REM + lumaValue = (recLuma + (1 << (numNeighborLog - 1))) >> numNeighborLog; +#else lumaValue = ClipPel((recLuma + (1 << (numNeighborLog - 1))) >> numNeighborLog, tu.cs->slice->clpRng(COMPONENT_Y)); +#endif } else if (pelnum == (numNeighbor << 1)) { +#if JVET_R0330_CRS_CLIP_REM + lumaValue = (recLuma + (1 << numNeighborLog)) >> (numNeighborLog + 1); +#else lumaValue = ClipPel((recLuma + (1 << numNeighborLog)) >> (numNeighborLog + 1), tu.cs->slice->clpRng(COMPONENT_Y)); +#endif } else { CHECK(pelnum != 0, ""); +#if JVET_R0330_CRS_CLIP_REM + lumaValue = valueDC; +#else lumaValue = ClipPel(valueDC, tu.cs->slice->clpRng(COMPONENT_Y)); +#endif } chromaScale = calculateChromaAdj(lumaValue); setChromaScale(chromaScale); diff --git a/source/Lib/CommonLib/Rom.cpp b/source/Lib/CommonLib/Rom.cpp index 8ec4e5f855a20ce8279cf8a02073b87a0c59faaf..61814be666379ee943c954d3de7396fa1b460d50 100644 --- a/source/Lib/CommonLib/Rom.cpp +++ b/source/Lib/CommonLib/Rom.cpp @@ -70,11 +70,7 @@ const char* nalUnitTypeToString(NalUnitType type) case NAL_UNIT_CODED_SLICE_IDR_N_LP: return "IDR_N_LP"; case NAL_UNIT_CODED_SLICE_CRA: return "CRA"; case NAL_UNIT_CODED_SLICE_GDR: return "GDR"; -#if JVET_Q0117_PARAMETER_SETS_CLEANUP case NAL_UNIT_DCI: return "DCI"; -#else - case NAL_UNIT_DPS: return "DPS"; -#endif case NAL_UNIT_VPS: return "VPS"; case NAL_UNIT_SPS: return "SPS"; case NAL_UNIT_PPS: return "PPS"; @@ -407,57 +403,10 @@ void initROM() } } -#if !JVET_Q0806 - for( int idxH = MAX_CU_DEPTH - MIN_CU_LOG2; idxH >= 0; --idxH ) - { - for( int idxW = MAX_CU_DEPTH - MIN_CU_LOG2; idxW >= 0; --idxW ) - { - int numW = 1 << idxW; - int numH = 1 << idxH; - int ratioW = std::max( 0, idxW - idxH ); - int ratioH = std::max( 0, idxH - idxW ); - int sum = std::max( (numW >> ratioW), (numH >> ratioH) ) - 1; - for( int y = 0; y < numH; y++ ) - { - int idxY = y >> ratioH; - for( int x = 0; x < numW; x++ ) - { - int idxX = x >> ratioW; - g_triangleMvStorage[TRIANGLE_DIR_135][idxH][idxW][y][x] = (idxX == idxY) ? 2 : (idxX > idxY ? 0 : 1); - g_triangleMvStorage[TRIANGLE_DIR_45][idxH][idxW][y][x] = (idxX + idxY == sum) ? 2 : (idxX + idxY > sum ? 1 : 0); - } - } - } - } - - for (int idxH = 0; idxH < MAX_CU_DEPTH - MIN_CU_LOG2 + 2; ++idxH) - { - for (int idxW = 0; idxW < MAX_CU_DEPTH - MIN_CU_LOG2 + 2; ++idxW) - { - const int nCbH = 1 << (idxH + 1); - const int nCbW = 1 << (idxW + 1); - const int nCbR = (nCbW > nCbH) ? nCbW / nCbH : nCbH / nCbW; - - // let SIMD can read at least 64-bit when at last row - g_triangleWeights[0][idxH][idxW] = new int16_t[nCbH * nCbW + 4]; - g_triangleWeights[1][idxH][idxW] = new int16_t[nCbH * nCbW + 4]; - for (int y = 0; y < nCbH; y++) - { - for (int x = 0; x < nCbW; x++) - { - g_triangleWeights[0][idxH][idxW][y*nCbW + x] = (nCbW > nCbH) ? Clip3(0, 8, x / nCbR - y + 4) : Clip3(0, 8, x - y / nCbR + 4); - g_triangleWeights[1][idxH][idxW][y*nCbW + x] = (nCbW > nCbH) ? Clip3(0, 8, nCbH - 1 - x / nCbR - y + 4) : Clip3(0, 8, nCbW - 1 - x - y / nCbR + 4); - } - } - } - } -#else initGeoTemplate(); -#endif ::memset(g_isReusedUniMVsFilled, 0, sizeof(g_isReusedUniMVsFilled)); -#if JVET_Q0503_Q0712_PLT_ENCODER_IMPROV_BUGFIX for (int qp = 0; qp < 57; qp++) { int qpRem = (qp + 12) % 6; @@ -467,7 +416,6 @@ void initROM() double threshQP = ((double)(1 << quantiserRightShift)) / quantiserScale; g_paletteQuant[qp] = (int)(threshQP*0.16 + 0.5); } -#endif } void destroyROM() @@ -493,18 +441,6 @@ void destroyROM() delete gp_sizeIdxInfo; gp_sizeIdxInfo = nullptr; -#if !JVET_Q0806 - for (int idxH = 0; idxH < MAX_CU_DEPTH - MIN_CU_LOG2 + 2; ++idxH) - { - for (int idxW = 0; idxW < MAX_CU_DEPTH - MIN_CU_LOG2 + 2; ++idxW) - { - delete[] g_triangleWeights[0][idxH][idxW]; - delete[] g_triangleWeights[1][idxH][idxW]; - g_triangleWeights[0][idxH][idxW] = nullptr; - g_triangleWeights[1][idxH][idxW] = nullptr; - } - } -#else for( int modeIdx = 0; modeIdx < GEO_NUM_PARTITION_MODE; modeIdx++ ) { delete[] g_GeoParams[modeIdx]; @@ -518,7 +454,6 @@ void destroyROM() g_globalGeoWeights [i] = nullptr; g_globalGeoEncSADmask[i] = nullptr; } -#endif } // ==================================================================================================================== @@ -743,24 +678,28 @@ const int g_quantInterDefault8x8[8 * 8] = const uint32_t g_scalingListSize [SCALING_LIST_SIZE_NUM] = { 1, 4, 16, 64, 256, 1024, 4096, 16384 }; const uint32_t g_scalingListSizeX[SCALING_LIST_SIZE_NUM] = { 1, 2, 4, 8, 16, 32, 64, 128 }; - -#if !JVET_Q0806 -uint8_t g_triangleMvStorage[TRIANGLE_DIR_NUM][MAX_CU_DEPTH - MIN_CU_LOG2 + 1][MAX_CU_DEPTH - MIN_CU_LOG2 + 1][MAX_CU_SIZE >> MIN_CU_LOG2][MAX_CU_SIZE >> MIN_CU_LOG2]; -int16_t *g_triangleWeights[TRIANGLE_DIR_NUM][MAX_CU_DEPTH - MIN_CU_LOG2 + 2][MAX_CU_DEPTH - MIN_CU_LOG2 + 2]; +#if JVET_R0166_SCALING_LISTS_CHROMA_444 +const uint32_t g_scalingListId[SCALING_LIST_SIZE_NUM][SCALING_LIST_NUM] = +{ + { 0, 0, 0, 0, 0, 0}, // SCALING_LIST_1x1 + { 0, 0, 0, 0, 0, 1}, // SCALING_LIST_2x2 + { 2, 3, 4, 5, 6, 7}, // SCALING_LIST_4x4 + { 8, 9, 10, 11, 12, 13}, // SCALING_LIST_8x8 + { 14, 15, 16, 17, 18, 19}, // SCALING_LIST_16x16 + { 20, 21, 22, 23, 24, 25}, // SCALING_LIST_32x32 + { 26, 21, 22, 27, 24, 25}, // SCALING_LIST_64x64 + { 0, 0, 0, 0, 0, 0}, // SCALING_LIST_128x128 +}; #endif + Mv g_reusedUniMVs[32][32][8][8][2][33]; bool g_isReusedUniMVsFilled[32][32][8][8]; -#if JVET_Q0503_Q0712_PLT_ENCODER_IMPROV_BUGFIX uint16_t g_paletteQuant[57]; -#else -const uint8_t g_paletteQuant[52] = { 0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 7, 7, 8, 9, 9, 10, 11, 12, 13, 14, 15, 16, 17, 19, 21, 22, 24, 23, 25, 26, 28, 29, 31, 32, 34, 36, 37, 39, 41, 42, 45 }; -#endif uint8_t g_paletteRunTopLut [5] = { 0, 1, 1, 2, 2 }; uint8_t g_paletteRunLeftLut[5] = { 0, 1, 2, 3, 4 }; -#if JVET_Q0806 void initGeoTemplate() { g_GeoParams = new int16_t*[GEO_NUM_PARTITION_MODE]; @@ -785,7 +724,7 @@ void initGeoTemplate() continue; g_globalGeoWeights[g_angle2mask[angleIdx]] = new int16_t[GEO_WEIGHT_MASK_SIZE * GEO_WEIGHT_MASK_SIZE]; g_globalGeoEncSADmask[g_angle2mask[angleIdx]] = new int16_t[GEO_WEIGHT_MASK_SIZE * GEO_WEIGHT_MASK_SIZE]; - + int distanceX = angleIdx; int distanceY = (distanceX + (GEO_NUM_ANGLES >> 2)) % GEO_NUM_ANGLES; int16_t rho = (g_Dis[distanceX] << (GEO_MAX_CU_LOG2+1)) + (g_Dis[distanceY] << (GEO_MAX_CU_LOG2 + 1)); @@ -841,5 +780,4 @@ int16_t g_weightOffset [GEO_NUM_PARTITION_MODE][GEO_NUM_CU_SIZE][GEO_NUM int8_t g_angle2mask[GEO_NUM_ANGLES] = { 0, -1, 1, 2, 3, 4, -1, -1, 5, -1, -1, 4, 3, 2, 1, -1, 0, -1, 1, 2, 3, 4, -1, -1, 5, -1, -1, 4, 3, 2, 1, -1 }; int8_t g_Dis[GEO_NUM_ANGLES] = { 8, 8, 8, 8, 4, 4, 2, 1, 0, -1, -2, -4, -4, -8, -8, -8, -8, -8, -8, -8, -4, -4, -2, -1, 0, 1, 2, 4, 4, 8, 8, 8 }; int8_t g_angle2mirror[GEO_NUM_ANGLES] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 2 }; -#endif //! \} diff --git a/source/Lib/CommonLib/Rom.h b/source/Lib/CommonLib/Rom.h index ecdbdd9bc79e9645352fc21264fa241d8685064a..54e7a3b1cfd855773b8cb85c5e3faad4a7819836 100644 --- a/source/Lib/CommonLib/Rom.h +++ b/source/Lib/CommonLib/Rom.h @@ -176,6 +176,9 @@ extern const int g_quantInterDefault8x8[8*8]; extern const uint32_t g_scalingListSize [SCALING_LIST_SIZE_NUM]; extern const uint32_t g_scalingListSizeX[SCALING_LIST_SIZE_NUM]; +#if JVET_R0166_SCALING_LISTS_CHROMA_444 +extern const uint32_t g_scalingListId[SCALING_LIST_SIZE_NUM][SCALING_LIST_NUM]; +#endif extern MsgLevel g_verbosity; @@ -205,11 +208,6 @@ constexpr uint8_t g_tbMax[257] = { 0, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, //! \} -#if !JVET_Q0806 -extern uint8_t g_triangleMvStorage[TRIANGLE_DIR_NUM][MAX_CU_DEPTH - MIN_CU_LOG2 + 1][MAX_CU_DEPTH - MIN_CU_LOG2 + 1][MAX_CU_SIZE >> MIN_CU_LOG2][MAX_CU_SIZE >> MIN_CU_LOG2]; -// 7-tap/3-tap, direction, 2/4/8/16/32/64/128 -extern int16_t *g_triangleWeights[TRIANGLE_DIR_NUM][MAX_CU_DEPTH - MIN_CU_LOG2 + 2][MAX_CU_DEPTH - MIN_CU_LOG2 + 2]; -#endif extern bool g_mctsDecCheckEnabled; @@ -217,17 +215,12 @@ class Mv; extern Mv g_reusedUniMVs[32][32][8][8][2][33]; extern bool g_isReusedUniMVsFilled[32][32][8][8]; -#if JVET_Q0503_Q0712_PLT_ENCODER_IMPROV_BUGFIX extern uint16_t g_paletteQuant[57]; -#else -extern const uint8_t g_paletteQuant[52]; -#endif extern uint8_t g_paletteRunTopLut[5]; extern uint8_t g_paletteRunLeftLut[5]; const int g_IBCBufferSize = 256 * 128; -#if JVET_Q0806 void initGeoTemplate(); extern int16_t** g_GeoParams; extern int16_t* g_globalGeoWeights [GEO_NUM_PRESTORED_MASK]; @@ -236,6 +229,5 @@ extern int16_t g_weightOffset [GEO_NUM_PARTITION_MODE][GEO_NUM_CU_SIZE][ extern int8_t g_angle2mask [GEO_NUM_ANGLES]; extern int8_t g_Dis[GEO_NUM_ANGLES]; extern int8_t g_angle2mirror[GEO_NUM_ANGLES]; -#endif #endif //__TCOMROM__ diff --git a/source/Lib/CommonLib/SEI.cpp b/source/Lib/CommonLib/SEI.cpp index c0b86e0903f43070291af133844d6e3e8b179b7f..6b3d7148b72f3d0557e1cc7f643b314b4ed89de6 100644 --- a/source/Lib/CommonLib/SEI.cpp +++ b/source/Lib/CommonLib/SEI.cpp @@ -119,6 +119,10 @@ void SEIBufferingPeriod::copyTo (SEIBufferingPeriod& target) const target.m_sublayerInitialCpbRemovalDelayPresentFlag = m_sublayerInitialCpbRemovalDelayPresentFlag; target.m_concatenationFlag = m_concatenationFlag; target.m_maxInitialRemovalDelayForConcatenation = m_maxInitialRemovalDelayForConcatenation; +#if JVET_R0094_DPB_TID_OFFSET + target.m_sublayerDpbOutputOffsetsPresentFlag = m_sublayerDpbOutputOffsetsPresentFlag; + ::memcpy(target.m_dpbOutputTidOffset, m_dpbOutputTidOffset, sizeof(m_dpbOutputTidOffset)); +#endif target.m_altCpbParamsPresentFlag = m_altCpbParamsPresentFlag; } @@ -137,10 +141,21 @@ void SEIPictureTiming::copyTo (SEIPictureTiming& target) const target.m_numNalusInDuMinus1 = m_numNalusInDuMinus1; target.m_duCpbRemovalDelayMinus1 = m_duCpbRemovalDelayMinus1; target.m_cpbAltTimingInfoPresentFlag = m_cpbAltTimingInfoPresentFlag; +#if JVET_R0413_HRD_TIMING_INFORMATION + target.m_nalCpbAltInitialRemovalDelayDelta = m_nalCpbAltInitialRemovalDelayDelta; + target.m_nalCpbAltInitialRemovalOffsetDelta = m_nalCpbAltInitialRemovalOffsetDelta; + target.m_nalCpbDelayOffset = m_nalCpbDelayOffset; + target.m_nalCpbDelayOffset = m_nalCpbDelayOffset; + target.m_vclCpbAltInitialRemovalDelayDelta = m_vclCpbAltInitialRemovalDelayDelta; + target.m_vclCpbAltInitialRemovalOffsetDelta = m_vclCpbAltInitialRemovalOffsetDelta; + target.m_vclCpbDelayOffset = m_vclCpbDelayOffset; + target.m_vclCpbDelayOffset = m_vclCpbDelayOffset; +#else target.m_cpbAltInitialCpbRemovalDelayDelta = m_cpbAltInitialCpbRemovalDelayDelta; target.m_cpbAltInitialCpbRemovalOffsetDelta = m_cpbAltInitialCpbRemovalOffsetDelta; target.m_cpbDelayOffset = m_cpbDelayOffset; target.m_dpbDelayOffset = m_dpbDelayOffset; +#endif } // Static member @@ -156,9 +171,7 @@ const char *SEI::getSEIMessageString(SEI::PayloadType payloadType) case SEI::FILM_GRAIN_CHARACTERISTICS: return "Film grain characteristics"; // not currently decoded case SEI::FRAME_PACKING: return "Frame packing arrangement"; case SEI::DECODING_UNIT_INFO: return "Decoding unit information"; -#if JVET_P0190_SCALABLE_NESTING_SEI case SEI::SCALABLE_NESTING: return "Scalable nesting"; -#endif case SEI::DECODED_PICTURE_HASH: return "Decoded picture hash"; case SEI::DEPENDENT_RAP_INDICATION: return "Dependent RAP indication"; case SEI::MASTERING_DISPLAY_COLOUR_VOLUME: return "Mastering display colour volume"; diff --git a/source/Lib/CommonLib/SEI.h b/source/Lib/CommonLib/SEI.h index 2e7e2d92c2d7896c83ace8eb49aa67c86e3e49af..90451739bea8673b2993244fb9e0c0791c6bd19b 100644 --- a/source/Lib/CommonLib/SEI.h +++ b/source/Lib/CommonLib/SEI.h @@ -63,9 +63,7 @@ public: FRAME_PACKING = 45, DECODING_UNIT_INFO = 130, DECODED_PICTURE_HASH = 132, -#if JVET_P0190_SCALABLE_NESTING_SEI SCALABLE_NESTING = 133, -#endif MASTERING_DISPLAY_COLOUR_VOLUME = 137, DEPENDENT_RAP_INDICATION = 145, EQUIRECTANGULAR_PROJECTION = 150, @@ -143,7 +141,7 @@ public: bool m_omniViewportCancelFlag; bool m_omniViewportPersistenceFlag; uint8_t m_omniViewportCntMinus1; - std::vector<OmniViewport> m_omniViewportRegions; + std::vector<OmniViewport> m_omniViewportRegions; }; class SEIRegionWisePacking : public SEI @@ -197,12 +195,8 @@ public: std::vector<uint8_t> m_gcmpFunctionCoeffV; std::vector<bool> m_gcmpFunctionVAffectedByUFlag; bool m_gcmpGuardBandFlag; -#if JVET_Q0343_GCMP_GUARD_BAND_TYPE uint8_t m_gcmpGuardBandType; bool m_gcmpGuardBandBoundaryExteriorFlag; -#else - bool m_gcmpGuardBandBoundaryType; -#endif uint8_t m_gcmpGuardBandSamplesMinus1; }; @@ -283,18 +277,22 @@ public: , m_bpMaxSubLayers (0) , m_bpDecodingUnitHrdParamsPresentFlag (false) , m_decodingUnitCpbParamsInPicTimingSeiFlag (false) -#if JVET_Q0221 , m_decodingUnitDpbDuParamsInPicTimingSeiFlag(false) -#endif , m_sublayerInitialCpbRemovalDelayPresentFlag(false) , m_additionalConcatenationInfoPresentFlag (false) , m_maxInitialRemovalDelayForConcatenation (0) +#if JVET_R0094_DPB_TID_OFFSET + , m_sublayerDpbOutputOffsetsPresentFlag (false) +#endif , m_altCpbParamsPresentFlag (false) , m_useAltCpbParamsFlag (false) { ::memset(m_initialCpbRemovalDelay, 0, sizeof(m_initialCpbRemovalDelay)); ::memset(m_initialCpbRemovalOffset, 0, sizeof(m_initialCpbRemovalOffset)); ::memset(m_cpbRemovalDelayDelta, 0, sizeof(m_cpbRemovalDelayDelta)); +#if JVET_R0094_DPB_TID_OFFSET + ::memset(m_dpbOutputTidOffset, 0, sizeof(m_dpbOutputTidOffset)); +#endif } virtual ~SEIBufferingPeriod() {} @@ -320,12 +318,14 @@ public: uint32_t m_cpbRemovalDelayDelta [15]; bool m_bpDecodingUnitHrdParamsPresentFlag; bool m_decodingUnitCpbParamsInPicTimingSeiFlag; -#if JVET_Q0221 bool m_decodingUnitDpbDuParamsInPicTimingSeiFlag; -#endif bool m_sublayerInitialCpbRemovalDelayPresentFlag; bool m_additionalConcatenationInfoPresentFlag; uint32_t m_maxInitialRemovalDelayForConcatenation; +#if JVET_R0094_DPB_TID_OFFSET + bool m_sublayerDpbOutputOffsetsPresentFlag; + uint32_t m_dpbOutputTidOffset [MAX_TLAYER]; +#endif bool m_altCpbParamsPresentFlag; bool m_useAltCpbParamsFlag; }; @@ -342,13 +342,7 @@ public: , m_numDecodingUnitsMinus1 (0) , m_duCommonCpbRemovalDelayFlag (false) , m_cpbAltTimingInfoPresentFlag (false) -#if !JVET_Q0219_SIGNAL_ALT_BUFFER_DELAY_PARMS - , m_cpbDelayOffset(0) - , m_dpbDelayOffset(0) -#endif -#if JVET_Q0818_PT_SEI , m_ptDisplayElementalPeriodsMinus1(0) -#endif { ::memset(m_ptSubLayerDelaysPresentFlag, 0, sizeof(m_ptSubLayerDelaysPresentFlag)); ::memset(m_duCommonCpbRemovalDelayMinus1, 0, sizeof(m_duCommonCpbRemovalDelayMinus1)); @@ -373,20 +367,22 @@ public: std::vector<uint32_t> m_numNalusInDuMinus1; std::vector<uint32_t> m_duCpbRemovalDelayMinus1; bool m_cpbAltTimingInfoPresentFlag; -#if JVET_Q0219_SIGNAL_ALT_BUFFER_DELAY_PARMS +#if JVET_R0413_HRD_TIMING_INFORMATION + std::vector<std::vector<uint32_t>> m_nalCpbAltInitialRemovalDelayDelta; + std::vector<std::vector<uint32_t>> m_nalCpbAltInitialRemovalOffsetDelta; + std::vector<uint32_t> m_nalCpbDelayOffset; + std::vector<uint32_t> m_nalDpbDelayOffset; + std::vector<std::vector<uint32_t>> m_vclCpbAltInitialRemovalDelayDelta; + std::vector<std::vector<uint32_t>> m_vclCpbAltInitialRemovalOffsetDelta; + std::vector<uint32_t> m_vclCpbDelayOffset; + std::vector<uint32_t> m_vclDpbDelayOffset; +#else std::vector<std::vector<uint32_t>> m_cpbAltInitialCpbRemovalDelayDelta; std::vector<std::vector<uint32_t>> m_cpbAltInitialCpbRemovalOffsetDelta; std::vector<uint32_t> m_cpbDelayOffset; std::vector<uint32_t> m_dpbDelayOffset; -#else - std::vector<uint32_t> m_cpbAltInitialCpbRemovalDelayDelta; - std::vector<uint32_t> m_cpbAltInitialCpbRemovalOffsetDelta; - uint32_t m_cpbDelayOffset; - uint32_t m_dpbDelayOffset; #endif -#if JVET_Q0818_PT_SEI int m_ptDisplayElementalPeriodsMinus1; -#endif }; class SEIDecodingUnitInfo : public SEI @@ -490,7 +486,6 @@ SEIMessages extractSeisByType(SEIMessages &seiList, SEI::PayloadType seiType); /// delete list of SEI messages (freeing the referenced objects) void deleteSEIs (SEIMessages &seiList); -#if JVET_P0190_SCALABLE_NESTING_SEI class SEIScalableNesting : public SEI { public: @@ -513,7 +508,6 @@ public: SEIMessages m_nestedSEIs; }; -#endif #if ENABLE_TRACING @@ -521,7 +515,7 @@ void xTraceSEIHeader(); void xTraceSEIMessageType( SEI::PayloadType payloadType ); #endif -#if U0033_ALTERNATIVE_TRANSFER_CHARACTERISTICS_SEI +#if U0033_ALTERNATIVE_TRANSFER_CHARACTERISTICS_SEI class SEIAlternativeTransferCharacteristics : public SEI { public: @@ -638,27 +632,15 @@ class SEISubpicureLevelInfo : public SEI public: PayloadType payloadType() const { return SUBPICTURE_LEVEL_INFO; } SEISubpicureLevelInfo() -#if !JVET_Q0630_SUBPIC_LEVEL - : m_sliSeqParameterSetId(0) - , m_numRefLevels(0) -#else : m_numRefLevels(0) -#endif , m_explicitFractionPresentFlag (false) -#if JVET_Q0630_SUBPIC_LEVEL , m_numSubpics(0) -#endif {} virtual ~SEISubpicureLevelInfo() {} -#if !JVET_Q0630_SUBPIC_LEVEL - int m_sliSeqParameterSetId; -#endif int m_numRefLevels; bool m_explicitFractionPresentFlag; -#if JVET_Q0630_SUBPIC_LEVEL int m_numSubpics; -#endif std::vector<Level::Name> m_refLevelIdc; std::vector<std::vector<int>> m_refLevelFraction; }; diff --git a/source/Lib/CommonLib/SampleAdaptiveOffset.cpp b/source/Lib/CommonLib/SampleAdaptiveOffset.cpp index e149aa2c8e19d93819defc7a54a3a6a271a491ca..a34b44676ae08a1e7ef54515f7498e84c8ce5fd4 100644 --- a/source/Lib/CommonLib/SampleAdaptiveOffset.cpp +++ b/source/Lib/CommonLib/SampleAdaptiveOffset.cpp @@ -727,9 +727,8 @@ void SampleAdaptiveOffset::deriveLoopFilterBoundaryAvailibility(CodingStructure& isBelowRightAvail = (!isBelowRightAvail) ? false : CU::isSameTile(*cuCurr, *cuBelowRight); } -#if JVET_O1143_LPF_ACROSS_SUBPIC_BOUNDARY // check cross subpic flags - SubPic curSubPic = cs.pps->getSubPicFromCU(*cuCurr); + const SubPic& curSubPic = cs.pps->getSubPicFromCU(*cuCurr); if (!curSubPic.getloopFilterAcrossEnabledFlag()) { isLeftAvail = (!isLeftAvail) ? false : CU::isSameSubPic(*cuCurr, *cuLeft); @@ -741,19 +740,13 @@ void SampleAdaptiveOffset::deriveLoopFilterBoundaryAvailibility(CodingStructure& isBelowLeftAvail = (!isBelowLeftAvail) ? false : CU::isSameSubPic(*cuCurr, *cuBelowLeft); isBelowRightAvail = (!isBelowRightAvail) ? false : CU::isSameSubPic(*cuCurr, *cuBelowRight); } -#endif } bool SampleAdaptiveOffset::isCrossedByVirtualBoundaries(const int xPos, const int yPos, const int width, const int height, int& numHorVirBndry, int& numVerVirBndry, int horVirBndryPos[], int verVirBndryPos[], const PicHeader* picHeader ) { numHorVirBndry = 0; numVerVirBndry = 0; -#if JVET_Q0246_VIRTUAL_BOUNDARY_ENABLE_FLAG if( picHeader->getVirtualBoundariesPresentFlag() ) { -#else - if (picHeader->getLoopFilterAcrossVirtualBoundariesDisabledFlag()) - { -#endif for (int i = 0; i < picHeader->getNumHorVirtualBoundaries(); i++) { if (yPos <= picHeader->getVirtualBoundariesPosY(i) && picHeader->getVirtualBoundariesPosY(i) <= yPos + height) diff --git a/source/Lib/CommonLib/Slice.cpp b/source/Lib/CommonLib/Slice.cpp index b0af03c8aed706f02666100b8bb197f4a1bdd92c..2443284859c665809e12cc1d147d2cae0ac09816 100644 --- a/source/Lib/CommonLib/Slice.cpp +++ b/source/Lib/CommonLib/Slice.cpp @@ -53,52 +53,37 @@ Slice::Slice() , m_iAssociatedIRAPType ( NAL_UNIT_INVALID ) , m_rpl0Idx ( -1 ) , m_rpl1Idx ( -1 ) -#if JVET_Q0155_COLOUR_ID , m_colourPlaneId ( 0 ) -#endif , m_eNalUnitType ( NAL_UNIT_CODED_SLICE_IDR_W_RADL ) -#if JVET_Q0775_PH_IN_SH , m_pictureHeaderInSliceHeader ( false ) -#endif , m_eSliceType ( I_SLICE ) , m_iSliceQp ( 0 ) , m_ChromaQpAdjEnabled ( false ) -#if JVET_Q0346_LMCS_ENABLE_IN_SH , m_lmcsEnabledFlag ( 0 ) -#endif -#if JVET_Q0346_SCALING_LIST_USED_IN_SH , m_explicitScalingListUsed ( 0 ) -#endif , m_deblockingFilterDisable ( false ) , m_deblockingFilterOverrideFlag ( false ) , m_deblockingFilterBetaOffsetDiv2( 0 ) , m_deblockingFilterTcOffsetDiv2 ( 0 ) -#if JVET_Q0121_DEBLOCKING_CONTROL_PARAMETERS , m_deblockingFilterCbBetaOffsetDiv2( 0 ) , m_deblockingFilterCbTcOffsetDiv2 ( 0 ) , m_deblockingFilterCrBetaOffsetDiv2( 0 ) , m_deblockingFilterCrTcOffsetDiv2 ( 0 ) +#if JVET_R0271_SLICE_LEVEL_DQ_SDH_RRC +, m_depQuantEnabledFlag ( false ) +, m_signDataHidingEnabledFlag ( false ) #endif -#if JVET_Q0089_SLICE_LOSSLESS_CODING_CHROMA_BDPCM , m_tsResidualCodingDisabledFlag ( false ) -#endif , m_pendingRasInit ( false ) , m_bCheckLDC ( false ) , m_biDirPred ( false ) , m_iSliceQpDelta ( 0 ) , m_iDepth ( 0 ) -#if !JVET_Q0117_PARAMETER_SETS_CLEANUP -, m_dps ( nullptr ) -#endif , m_pcSPS ( NULL ) , m_pcPPS ( NULL ) , m_pcPic ( NULL ) , m_pcPicHeader ( NULL ) , m_colFromL0Flag ( true ) -#if !SPS_ID_CHECK -, m_noIncorrectPicOutputFlag ( false ) -, m_handleCraAsCvsStartFlag ( false ) -#endif , m_colRefIdx ( 0 ) , m_uiTLayer ( 0 ) , m_bTLayerSwitchingFlag ( false ) @@ -153,12 +138,10 @@ Slice::Slice() } memset(m_alfApss, 0, sizeof(m_alfApss)); -#if JVET_Q0795_CCALF m_ccAlfFilterParam.reset(); resetTileGroupAlfEnabledFlag(); resetTileGroupCcAlCbfEnabledFlag(); resetTileGroupCcAlCrfEnabledFlag(); -#endif m_sliceMap.initSliceMap(); } @@ -176,16 +159,10 @@ void Slice::initSlice() m_aiNumRefIdx[i] = 0; } m_colFromL0Flag = true; -#if JVET_Q0155_COLOUR_ID m_colourPlaneId = 0; -#endif m_colRefIdx = 0; -#if JVET_Q0346_LMCS_ENABLE_IN_SH m_lmcsEnabledFlag = 0; -#endif -#if JVET_Q0346_SCALING_LIST_USED_IN_SH m_explicitScalingListUsed = 0; -#endif initEqualRef(); m_bCheckLDC = false; @@ -210,22 +187,16 @@ void Slice::initSlice() m_isDRAP = false; m_latestDRAPPOC = MAX_INT; resetTileGroupAlfEnabledFlag(); -#if JVET_Q0795_CCALF m_ccAlfFilterParam.reset(); m_tileGroupCcAlfCbEnabledFlag = 0; m_tileGroupCcAlfCrEnabledFlag = 0; m_tileGroupCcAlfCbApsId = -1; m_tileGroupCcAlfCrApsId = -1; -#endif } void Slice::inheritFromPicHeader( PicHeader *picHeader, const PPS *pps, const SPS *sps ) -{ -#if JVET_Q0819_PH_CHANGES +{ if (pps->getRplInfoInPhFlag()) -#else - if(picHeader->getPicRplPresentFlag()) -#endif { setRPL0idx( picHeader->getRPL0idx() ); *getLocalRPL0() = *picHeader->getLocalRPL0(); @@ -237,7 +208,7 @@ void Slice::inheritFromPicHeader( PicHeader *picHeader, const PPS *pps, const SP { setRPL0(getLocalRPL0()); } - + setRPL1idx( picHeader->getRPL1idx() ); *getLocalRPL1() = *picHeader->getLocalRPL1(); if(getRPL1idx() != -1) @@ -253,12 +224,10 @@ void Slice::inheritFromPicHeader( PicHeader *picHeader, const PPS *pps, const SP setDeblockingFilterDisable( picHeader->getDeblockingFilterDisable() ); setDeblockingFilterBetaOffsetDiv2( picHeader->getDeblockingFilterBetaOffsetDiv2() ); setDeblockingFilterTcOffsetDiv2( picHeader->getDeblockingFilterTcOffsetDiv2() ); -#if JVET_Q0121_DEBLOCKING_CONTROL_PARAMETERS setDeblockingFilterCbBetaOffsetDiv2( picHeader->getDeblockingFilterCbBetaOffsetDiv2() ); setDeblockingFilterCbTcOffsetDiv2( picHeader->getDeblockingFilterCbTcOffsetDiv2() ); setDeblockingFilterCrBetaOffsetDiv2( picHeader->getDeblockingFilterCrBetaOffsetDiv2() ); setDeblockingFilterCrTcOffsetDiv2( picHeader->getDeblockingFilterCrTcOffsetDiv2() ); -#endif setSaoEnabledFlag(CHANNEL_TYPE_LUMA, picHeader->getSaoEnabledFlag(CHANNEL_TYPE_LUMA)); setSaoEnabledFlag(CHANNEL_TYPE_CHROMA, picHeader->getSaoEnabledFlag(CHANNEL_TYPE_CHROMA)); @@ -269,18 +238,15 @@ void Slice::inheritFromPicHeader( PicHeader *picHeader, const PPS *pps, const SP setTileGroupNumAps(picHeader->getNumAlfAps()); setAlfAPSs(picHeader->getAlfAPSs()); setTileGroupApsIdChroma(picHeader->getAlfApsIdChroma()); -#if JVET_Q0795_CCALF setTileGroupCcAlfCbEnabledFlag(picHeader->getCcAlfEnabledFlag(COMPONENT_Cb)); setTileGroupCcAlfCrEnabledFlag(picHeader->getCcAlfEnabledFlag(COMPONENT_Cr)); setTileGroupCcAlfCbApsId(picHeader->getCcAlfCbApsId()); setTileGroupCcAlfCrApsId(picHeader->getCcAlfCrApsId()); m_ccAlfFilterParam.ccAlfFilterEnabled[COMPONENT_Cb - 1] = picHeader->getCcAlfEnabledFlag(COMPONENT_Cb); m_ccAlfFilterParam.ccAlfFilterEnabled[COMPONENT_Cr - 1] = picHeader->getCcAlfEnabledFlag(COMPONENT_Cr); -#endif } -#if JVET_Q0151_Q0205_ENTRYPOINTS -void Slice::setNumSubstream(const SPS* sps, const PPS* pps) +void Slice::setNumSubstream(const SPS* sps, const PPS* pps) { uint32_t ctuAddr, ctuX, ctuY; m_numSubstream = 0; @@ -301,31 +267,33 @@ void Slice::setNumSubstream(const SPS* sps, const PPS* pps) } void Slice::setNumEntryPoints(const SPS *sps, const PPS *pps) -#else -void Slice::setNumEntryPoints( const PPS *pps ) -#endif { uint32_t ctuAddr, ctuX, ctuY; -#if JVET_Q0151_Q0205_ENTRYPOINTS uint32_t prevCtuAddr, prevCtuX, prevCtuY; -#endif m_numEntryPoints = 0; +#if JVET_R0165_OPTIONAL_ENTRY_POINT + if (!sps->getEntryPointsPresentFlag()) + { + return; + } +#endif + // count the number of CTUs that align with either the start of a tile, or with an entropy coding sync point // ignore the first CTU since it doesn't count as an entry point - for( uint32_t i = 1; i < m_sliceMap.getNumCtuInSlice(); i++ ) + for( uint32_t i = 1; i < m_sliceMap.getNumCtuInSlice(); i++ ) { ctuAddr = m_sliceMap.getCtuAddrInSlice( i ); ctuX = ( ctuAddr % pps->getPicWidthInCtu() ); ctuY = ( ctuAddr / pps->getPicWidthInCtu() ); -#if JVET_Q0151_Q0205_ENTRYPOINTS prevCtuAddr = m_sliceMap.getCtuAddrInSlice(i - 1); prevCtuX = (prevCtuAddr % pps->getPicWidthInCtu()); prevCtuY = (prevCtuAddr / pps->getPicWidthInCtu()); - if (pps->ctuToTileRowBd(ctuY) != pps->ctuToTileRowBd(prevCtuY) || pps->ctuToTileColBd(ctuX) != pps->ctuToTileColBd(prevCtuX) || (ctuY != prevCtuY && sps->getEntropyCodingSyncEntryPointsPresentFlag())) +#if JVET_R0165_OPTIONAL_ENTRY_POINT + if (pps->ctuToTileRowBd(ctuY) != pps->ctuToTileRowBd(prevCtuY) || pps->ctuToTileColBd(ctuX) != pps->ctuToTileColBd(prevCtuX) || (ctuY != prevCtuY && sps->getEntropyCodingSyncEnabledFlag())) #else - if( pps->ctuIsTileColBd( ctuX ) && (pps->ctuIsTileRowBd( ctuY ) || pps->getEntropyCodingSyncEnabledFlag() ) ) + if (pps->ctuToTileRowBd(ctuY) != pps->ctuToTileRowBd(prevCtuY) || pps->ctuToTileColBd(ctuX) != pps->ctuToTileColBd(prevCtuX) || (ctuY != prevCtuY && sps->getEntropyCodingSyncEntryPointsPresentFlag())) #endif { m_numEntryPoints++; @@ -503,9 +471,9 @@ void Slice::constructRefPicList(PicList& rcListPic) { CHECK( m_pRPL0->getInterLayerRefPicIdx( ii ) == NOT_VALID, "Wrong ILRP index" ); - int refLayerIdx = m_pcPic->cs->vps->getDirectRefLayerIdx( layerIdx, m_pRPL0->getInterLayerRefPicIdx( ii ) ); + int refLayerId = m_pcPic->cs->vps->getLayerId( m_pcPic->cs->vps->getDirectRefLayerIdx( layerIdx, m_pRPL0->getInterLayerRefPicIdx( ii ) ) ); - pcRefPic = xGetRefPic( rcListPic, getPOC(), refLayerIdx ); + pcRefPic = xGetRefPic( rcListPic, getPOC(), refLayerId ); pcRefPic->longTerm = true; } else @@ -539,9 +507,9 @@ void Slice::constructRefPicList(PicList& rcListPic) { CHECK( m_pRPL1->getInterLayerRefPicIdx( ii ) == NOT_VALID, "Wrong ILRP index" ); - int refLayerIdx = m_pcPic->cs->vps->getDirectRefLayerIdx( layerIdx, m_pRPL1->getInterLayerRefPicIdx( ii ) ); + int refLayerId = m_pcPic->cs->vps->getLayerId( m_pcPic->cs->vps->getDirectRefLayerIdx( layerIdx, m_pRPL1->getInterLayerRefPicIdx( ii ) ) ); - pcRefPic = xGetRefPic( rcListPic, getPOC(), refLayerIdx ); + pcRefPic = xGetRefPic( rcListPic, getPOC(), refLayerId ); pcRefPic->longTerm = true; } else @@ -606,11 +574,7 @@ void Slice::checkColRefIdx(uint32_t curSliceSegmentIdx, const Picture* pic) } } -#if JVET_P0978_RPL_RESTRICTIONS void Slice::checkCRA(const ReferencePictureList* pRPL0, const ReferencePictureList* pRPL1, const int pocCRA, PicList& rcListPic) -#else -void Slice::checkCRA(const ReferencePictureList *pRPL0, const ReferencePictureList *pRPL1, int& pocCRA, NalUnitType& associatedIRAPType, PicList& rcListPic) -#endif { if (pocCRA < MAX_UINT && getPOC() > pocCRA) { @@ -653,21 +617,8 @@ void Slice::checkCRA(const ReferencePictureList *pRPL0, const ReferencePictureLi } } } -#if !JVET_P0978_RPL_RESTRICTIONS - if (getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL || getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP) // IDR picture found - { - pocCRA = getPOC(); - associatedIRAPType = getNalUnitType(); - } - else if (getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA) // CRA picture found - { - pocCRA = getPOC(); - associatedIRAPType = getNalUnitType(); - } -#endif } -#if JVET_P0978_RPL_RESTRICTIONS void Slice::checkRPL(const ReferencePictureList* pRPL0, const ReferencePictureList* pRPL1, const int associatedIRAPDecodingOrderNumber, PicList& rcListPic) { Picture* pcRefPic; @@ -682,11 +633,7 @@ void Slice::checkRPL(const ReferencePictureList* pRPL0, const ReferencePictureLi int numActiveEntriesL0 = getNumRefIdx(REF_PIC_LIST_0); int numActiveEntriesL1 = getNumRefIdx(REF_PIC_LIST_1); -#if JVET_Q0042_VUI bool fieldSeqFlag = getSPS()->getFieldSeqFlag(); -#else - bool fieldSeqFlag = getSPS()->getVuiParameters() && getSPS()->getVuiParameters()->getFieldSeqFlag(); -#endif int currentPictureIsTrailing = 0; if (getPic()->getDecodingOrderNumber() > associatedIRAPDecodingOrderNumber) @@ -715,16 +662,28 @@ void Slice::checkRPL(const ReferencePictureList* pRPL0, const ReferencePictureLi } else { - pcRefPic = xGetLongTermRefPic(rcListPic, pRPL0->getRefPicIdentifier(i), pRPL0->getDeltaPocMSBPresentFlag(i), m_pcPic->layerId); + int pocBits = getSPS()->getBitsForPOC(); + int pocMask = (1 << pocBits) - 1; + int ltrpPoc = pRPL0->getRefPicIdentifier(i) & pocMask; + if(pRPL0->getDeltaPocMSBPresentFlag(i)) + { + ltrpPoc += getPOC() - pRPL0->getDeltaPocMSBCycleLT(i) * (pocMask + 1) - (getPOC() & pocMask); + } + pcRefPic = xGetLongTermRefPic(rcListPic, ltrpPoc, pRPL0->getDeltaPocMSBPresentFlag(i), m_pcPic->layerId); refPicPOC = pcRefPic->getPOC(); } refPicDecodingOrderNumber = pcRefPic->getDecodingOrderNumber(); - // Checking this: "When the current picture is a CRA picture, there shall be no entry in RefPicList[0] or RefPicList[1] - // that precedes, in output order or decoding order, any preceding IRAP picture in decoding order (when present)" + // Checking this: "When the current picture follows an IRAP picture having the same value of nuh_layer_id in both decoding order + // and output order, there shall be no picture referred to by an active entry in RefPicList[ 0 ] or RefPicList[ 1 ] that + // precedes that IRAP picture in output order or decoding order." +#if JVET_R0267_IDR_RPL + if (m_eNalUnitType == NAL_UNIT_CODED_SLICE_CRA || m_eNalUnitType == NAL_UNIT_CODED_SLICE_IDR_W_RADL || m_eNalUnitType == NAL_UNIT_CODED_SLICE_IDR_N_LP ) +#else if (m_eNalUnitType == NAL_UNIT_CODED_SLICE_CRA) +#endif { - CHECK(refPicPOC < irapPOC || refPicDecodingOrderNumber < associatedIRAPDecodingOrderNumber, "CRA picture detected that violate the rule that no entry in RefPicList[] shall precede, in output order or decoding order, any preceding IRAP picture in decoding order (when present)."); + CHECK(refPicPOC < irapPOC || refPicDecodingOrderNumber < associatedIRAPDecodingOrderNumber, "IRAP picture detected that violate the rule that no entry in RefPicList[] shall precede, in output order or decoding order, any preceding IRAP picture in decoding order (when present)."); } // Checking this: "When the current picture is a trailing picture that follows in both decoding orderand output order one @@ -732,7 +691,7 @@ void Slice::checkRPL(const ReferencePictureList* pRPL0, const ReferencePictureLi // entry in RefPicList[0] or RefPicList[1] that precedes the associated IRAP picture in output order or decoding order" // Note that when not in field coding, we know that all leading pictures of an IRAP precedes all trailing pictures of the // same IRAP picture. - if (currentPictureIsTrailing && !fieldSeqFlag) // + if (currentPictureIsTrailing && !fieldSeqFlag) // { CHECK(refPicPOC < irapPOC || refPicDecodingOrderNumber < associatedIRAPDecodingOrderNumber, "Trailing picture detected that follows one or more leading pictures, if any, and violates the rule that no entry in RefPicList[] shall precede the associated IRAP picture in output order or decoding order."); } @@ -764,7 +723,14 @@ void Slice::checkRPL(const ReferencePictureList* pRPL0, const ReferencePictureLi } else { - pcRefPic = xGetLongTermRefPic(rcListPic, pRPL0->getRefPicIdentifier(i), pRPL0->getDeltaPocMSBPresentFlag(i), m_pcPic->layerId); + int pocBits = getSPS()->getBitsForPOC(); + int pocMask = (1 << pocBits) - 1; + int ltrpPoc = pRPL1->getRefPicIdentifier(i) & pocMask; + if(pRPL1->getDeltaPocMSBPresentFlag(i)) + { + ltrpPoc += getPOC() - pRPL1->getDeltaPocMSBCycleLT(i) * (pocMask + 1) - (getPOC() & pocMask); + } + pcRefPic = xGetLongTermRefPic(rcListPic, ltrpPoc, pRPL1->getDeltaPocMSBPresentFlag(i), m_pcPic->layerId); refPicPOC = pcRefPic->getPOC(); } refPicDecodingOrderNumber = pcRefPic->getDecodingOrderNumber(); @@ -791,7 +757,6 @@ void Slice::checkRPL(const ReferencePictureList* pRPL0, const ReferencePictureLi } } } -#endif void Slice::checkSTSA(PicList& rcListPic) @@ -804,18 +769,10 @@ void Slice::checkSTSA(PicList& rcListPic) { pcRefPic = m_apcRefPicList[REF_PIC_LIST_0][ii]; -#if JVET_Q0156_STSA if( m_eNalUnitType == NAL_UNIT_CODED_SLICE_STSA && pcRefPic->layerId == m_pcPic->layerId ) { CHECK( pcRefPic->layer == m_uiTLayer, "When the current picture is an STSA picture and nuh_layer_id equal to that of the current picture, there shall be no active entry in the RPL that has TemporalId equal to that of the current picture" ); } -#else - // Checking this: "When the current picture is an STSA picture, there shall be no active entry in RefPicList[ 0 ] or RefPicList[ 1 ] that has TemporalId equal to that of the current picture" - if (getNalUnitType() == NAL_UNIT_CODED_SLICE_STSA) - { - CHECK(pcRefPic->layer == m_uiTLayer, "When the current picture is an STSA picture, there shall be no active entry in the RPL that has TemporalId equal to that of the current picture"); - } -#endif // Checking this: "When the current picture is a picture that follows, in decoding order, an STSA picture that has TemporalId equal to that of the current picture, there shall be no // picture that has TemporalId equal to that of the current picture included as an active entry in RefPicList[ 0 ] or RefPicList[ 1 ] that precedes the STSA picture in decoding order." @@ -827,18 +784,10 @@ void Slice::checkSTSA(PicList& rcListPic) { pcRefPic = m_apcRefPicList[REF_PIC_LIST_1][ii]; -#if JVET_Q0156_STSA if( m_eNalUnitType == NAL_UNIT_CODED_SLICE_STSA && pcRefPic->layerId == m_pcPic->layerId ) { CHECK( pcRefPic->layer == m_uiTLayer, "When the current picture is an STSA picture and nuh_layer_id equal to that of the current picture, there shall be no active entry in the RPL that has TemporalId equal to that of the current picture" ); } -#else - // Checking this: "When the current picture is an STSA picture, there shall be no active entry in RefPicList[ 0 ] or RefPicList[ 1 ] that has TemporalId equal to that of the current picture" - if (getNalUnitType() == NAL_UNIT_CODED_SLICE_STSA) - { - CHECK(pcRefPic->layer == m_uiTLayer, "When the current picture is an STSA picture, there shall be no active entry in the RPL that has TemporalId equal to that of the current picture"); - } -#endif // Checking this: "When the current picture is a picture that follows, in decoding order, an STSA picture that has TemporalId equal to that of the current picture, there shall be no // picture that has TemporalId equal to that of the current picture included as an active entry in RefPicList[ 0 ] or RefPicList[ 1 ] that precedes the STSA picture in decoding order." @@ -974,15 +923,15 @@ void Slice::copySliceInfo(Slice *pSrc, bool cpyAlmostAll) m_deblockingFilterOverrideFlag = pSrc->m_deblockingFilterOverrideFlag; m_deblockingFilterBetaOffsetDiv2 = pSrc->m_deblockingFilterBetaOffsetDiv2; m_deblockingFilterTcOffsetDiv2 = pSrc->m_deblockingFilterTcOffsetDiv2; -#if JVET_Q0121_DEBLOCKING_CONTROL_PARAMETERS m_deblockingFilterCbBetaOffsetDiv2 = pSrc->m_deblockingFilterCbBetaOffsetDiv2; m_deblockingFilterCbTcOffsetDiv2 = pSrc->m_deblockingFilterCbTcOffsetDiv2; m_deblockingFilterCrBetaOffsetDiv2 = pSrc->m_deblockingFilterCrBetaOffsetDiv2; m_deblockingFilterCrTcOffsetDiv2 = pSrc->m_deblockingFilterCrTcOffsetDiv2; +#if JVET_R0271_SLICE_LEVEL_DQ_SDH_RRC + m_depQuantEnabledFlag = pSrc->m_depQuantEnabledFlag; + m_signDataHidingEnabledFlag = pSrc->m_signDataHidingEnabledFlag; #endif -#if JVET_Q0089_SLICE_LOSSLESS_CODING_CHROMA_BDPCM m_tsResidualCodingDisabledFlag = pSrc->m_tsResidualCodingDisabledFlag; -#endif for (i = 0; i < NUM_REF_PIC_LIST_01; i++) { @@ -1050,12 +999,8 @@ void Slice::copySliceInfo(Slice *pSrc, bool cpyAlmostAll) m_independentSliceIdx = pSrc->m_independentSliceIdx; m_nextSlice = pSrc->m_nextSlice; m_clpRngs = pSrc->m_clpRngs; -#if JVET_Q0346_LMCS_ENABLE_IN_SH m_lmcsEnabledFlag = pSrc->m_lmcsEnabledFlag; -#endif -#if JVET_Q0346_SCALING_LIST_USED_IN_SH m_explicitScalingListUsed = pSrc->m_explicitScalingListUsed; -#endif m_pendingRasInit = pSrc->m_pendingRasInit; @@ -1079,6 +1024,9 @@ void Slice::copySliceInfo(Slice *pSrc, bool cpyAlmostAll) m_tileGroupLumaApsId = pSrc->m_tileGroupLumaApsId; m_tileGroupChromaApsId = pSrc->m_tileGroupChromaApsId; m_disableSATDForRd = pSrc->m_disableSATDForRd; +#if JVET_R0110_MIXED_LOSSLESS + m_isLossless = pSrc->m_isLossless; +#endif if( cpyAlmostAll ) m_encCABACTableIdx = pSrc->m_encCABACTableIdx; for( int i = 0; i < NUM_REF_PIC_LIST_01; i ++ ) @@ -1088,7 +1036,6 @@ void Slice::copySliceInfo(Slice *pSrc, bool cpyAlmostAll) m_scalingRatio[i][j] = pSrc->m_scalingRatio[i][j]; } } -#if JVET_Q0795_CCALF m_ccAlfFilterParam = pSrc->m_ccAlfFilterParam; m_ccAlfFilterControl[0] = pSrc->m_ccAlfFilterControl[0]; m_ccAlfFilterControl[1] = pSrc->m_ccAlfFilterControl[1]; @@ -1096,7 +1043,6 @@ void Slice::copySliceInfo(Slice *pSrc, bool cpyAlmostAll) m_tileGroupCcAlfCrEnabledFlag = pSrc->m_tileGroupCcAlfCrEnabledFlag; m_tileGroupCcAlfCbApsId = pSrc->m_tileGroupCcAlfCbApsId; m_tileGroupCcAlfCrApsId = pSrc->m_tileGroupCcAlfCrApsId; -#endif } @@ -1140,18 +1086,13 @@ bool Slice::isStepwiseTemporalLayerSwitchingPointCandidate(PicList& rcListPic) c } -#if JVET_Q0751_MIXED_NAL_UNIT_TYPES void Slice::checkLeadingPictureRestrictions(PicList& rcListPic, const PPS& pps) const -#else -void Slice::checkLeadingPictureRestrictions(PicList& rcListPic) const -#endif { int nalUnitType = this->getNalUnitType(); // When a picture is a leading picture, it shall be a RADL or RASL picture. if(this->getAssociatedIRAPPOC() > this->getPOC()) { -#if JVET_Q0751_MIXED_NAL_UNIT_TYPES //check this only when mixed_nalu_types_in_pic_flag is equal to 0 if (pps.getMixedNaluTypesInPicFlag() == 0) { @@ -1163,31 +1104,17 @@ void Slice::checkLeadingPictureRestrictions(PicList& rcListPic) const nalUnitType != NAL_UNIT_CODED_SLICE_RADL, "Invalid NAL unit type"); } } -#else - // Do not check IRAP pictures since they may get a POC lower than their associated IRAP - if (nalUnitType < NAL_UNIT_CODED_SLICE_IDR_W_RADL || - nalUnitType > NAL_UNIT_CODED_SLICE_CRA) - { - CHECK(nalUnitType != NAL_UNIT_CODED_SLICE_RASL && - nalUnitType != NAL_UNIT_CODED_SLICE_RADL, "Invalid NAL unit type"); - } -#endif } // When a picture is a trailing picture, it shall not be a RADL or RASL picture. if(this->getAssociatedIRAPPOC() < this->getPOC()) { -#if JVET_Q0751_MIXED_NAL_UNIT_TYPES //check this only when mixed_nalu_types_in_pic_flag is equal to 0 if (pps.getMixedNaluTypesInPicFlag() == 0) { CHECK(nalUnitType == NAL_UNIT_CODED_SLICE_RASL || nalUnitType == NAL_UNIT_CODED_SLICE_RADL, "Invalid NAL unit type"); } -#else - CHECK(nalUnitType == NAL_UNIT_CODED_SLICE_RASL || - nalUnitType == NAL_UNIT_CODED_SLICE_RADL, "Invalid NAL unit type"); -#endif } @@ -1265,11 +1192,7 @@ void Slice::checkLeadingPictureRestrictions(PicList& rcListPic) const { numLeadingPicsFound++; int limitNonLP = 0; -#if JVET_Q0042_VUI if (pcSlice->getSPS()->getFieldSeqFlag()) -#else - if (pcSlice->getSPS()->getVuiParameters() && pcSlice->getSPS()->getVuiParameters()->getFieldSeqFlag()) -#endif limitNonLP = 1; CHECK(pcPic->poc > this->getAssociatedIRAPPOC() && numLeadingPicsFound > limitNonLP, "Invalid POC"); } @@ -1312,18 +1235,10 @@ void Slice::checkLeadingPictureRestrictions(PicList& rcListPic) const //Function for applying picture marking based on the Reference Picture List -#if JVET_Q0751_MIXED_NAL_UNIT_TYPES void Slice::applyReferencePictureListBasedMarking( PicList& rcListPic, const ReferencePictureList *pRPL0, const ReferencePictureList *pRPL1, const int layerId, const PPS& pps ) const -#else -void Slice::applyReferencePictureListBasedMarking( PicList& rcListPic, const ReferencePictureList *pRPL0, const ReferencePictureList *pRPL1, const int layerId ) const -#endif { int i, isReference; -#if JVET_Q0751_MIXED_NAL_UNIT_TYPES checkLeadingPictureRestrictions(rcListPic, pps); -#else - checkLeadingPictureRestrictions(rcListPic); -#endif bool isNeedToCheck = (this->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP || this->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL) ? false : true; @@ -1334,7 +1249,7 @@ void Slice::applyReferencePictureListBasedMarking( PicList& rcListPic, const Ref { continue; } - + int isAvailable = 0; PicList::iterator iterPic = rcListPic.begin(); while (iterPic != rcListPic.end()) @@ -1400,7 +1315,7 @@ void Slice::applyReferencePictureListBasedMarking( PicList& rcListPic, const Ref { continue; } - + int isAvailable = 0; PicList::iterator iterPic = rcListPic.begin(); while (iterPic != rcListPic.end()) @@ -2025,26 +1940,24 @@ VPS::VPS() , m_vpsEachLayerIsAnOlsFlag (1) , m_vpsOlsModeIdc (0) , m_vpsNumOutputLayerSets (1) -#if JVET_Q0786_PTL_only , m_vpsNumPtls (1) -#endif , m_vpsExtensionFlag() -#if JVET_P0118_HRD_ASPECTS , m_vpsGeneralHrdParamsPresentFlag(false) , m_vpsSublayerCpbParamsPresentFlag(false) , m_numOlsHrdParamsMinus1(0) -#endif -#if JVET_Q0814_DPB , m_totalNumOLSs( 0 ) +#if JVET_R0191_ASPECT3 + , m_numMultiLayeredOlss( 0 ) +#endif , m_numDpbParams( 0 ) , m_sublayerDpbParamsPresentFlag( false ) , m_targetOlsIdx( -1 ) -#endif { for (int i = 0; i < MAX_VPS_LAYERS; i++) { m_vpsLayerId[i] = 0; m_vpsIndependentLayerFlag[i] = true; + m_generalLayerIdx[i] = 0; for (int j = 0; j < MAX_VPS_LAYERS; j++) { m_vpsDirectRefLayerFlag[i][j] = 0; @@ -2058,18 +1971,14 @@ VPS::VPS() { m_vpsOlsOutputLayerFlag[i][j] = 0; } -#if JVET_Q0786_PTL_only if(i == 0) m_ptPresentFlag[i] = 1; else m_ptPresentFlag[i] = 0; m_ptlMaxTemporalId[i] = m_vpsMaxSubLayers - 1; m_olsPtlIdx[i] = 0; -#endif -#if JVET_P0118_HRD_ASPECTS m_hrdMaxTid[i] = m_vpsMaxSubLayers - 1; m_olsHrdIdx[i] = 0; -#endif } } @@ -2077,7 +1986,6 @@ VPS::~VPS() { } -#if JVET_Q0814_DPB void VPS::deriveOutputLayerSets() { if( m_uiMaxLayers == 1 ) @@ -2105,10 +2013,8 @@ void VPS::deriveOutputLayerSets() std::vector<std::vector<int>> layerIncludedInOlsFlag( m_totalNumOLSs, std::vector<int>( m_uiMaxLayers, 0 ) ); std::vector<std::vector<int>> dependencyFlag( m_uiMaxLayers, std::vector<int>( m_uiMaxLayers, NOT_VALID ) ); std::vector<std::vector<int>> refLayerIdx( m_uiMaxLayers, std::vector<int>( m_uiMaxLayers, NOT_VALID ) ); -#if JVET_Q0118_CLEANUPS std::vector<int> layerUsedAsRefLayerFlag( m_uiMaxLayers, 0 ); std::vector<int> layerUsedAsOutputLayerFlag( m_uiMaxLayers, NOT_VALID ); -#endif for( int i = 0; i < m_uiMaxLayers; i++ ) { @@ -2125,12 +2031,10 @@ void VPS::deriveOutputLayerSets() dependencyFlag[i][j] = 1; } } -#if JVET_Q0118_CLEANUPS if (m_vpsDirectRefLayerFlag[i][j]) { layerUsedAsRefLayerFlag[j] = 1; } -#endif if( dependencyFlag[i][j] ) { @@ -2143,7 +2047,6 @@ void VPS::deriveOutputLayerSets() m_numOutputLayersInOls[0] = 1; m_outputLayerIdInOls[0][0] = m_vpsLayerId[0]; -#if JVET_Q0118_CLEANUPS layerUsedAsOutputLayerFlag[0] = 1; for (int i = 1; i < m_uiMaxLayers; i++) { @@ -2156,7 +2059,6 @@ void VPS::deriveOutputLayerSets() layerUsedAsOutputLayerFlag[i] = 0; } } -#endif for( int i = 1; i < m_totalNumOLSs; i++ ) { @@ -2182,9 +2084,7 @@ void VPS::deriveOutputLayerSets() if( m_vpsOlsOutputLayerFlag[i][k] ) { layerIncludedInOlsFlag[i][k] = 1; -#if JVET_Q0118_CLEANUPS layerUsedAsOutputLayerFlag[k] = 1; -#endif outputLayerIdx[i][j] = k; m_outputLayerIdInOls[i][j++] = m_vpsLayerId[k]; } @@ -2201,16 +2101,16 @@ void VPS::deriveOutputLayerSets() } } } -#if JVET_Q0118_CLEANUPS for (int i = 0; i < m_uiMaxLayers; i++) { CHECK(layerUsedAsRefLayerFlag[i] == 0 && layerUsedAsOutputLayerFlag[i] == 0, "There shall be no layer that is neither an output layer nor a direct reference layer"); } -#endif m_numLayersInOls[0] = 1; m_layerIdInOls[0][0] = m_vpsLayerId[0]; - +#if JVET_R0191_ASPECT3 + m_numMultiLayeredOlss = 0; +#endif for( int i = 1; i < m_totalNumOLSs; i++ ) { if( m_vpsEachLayerIsAnOlsFlag ) @@ -2239,6 +2139,13 @@ void VPS::deriveOutputLayerSets() m_numLayersInOls[i] = j; } +#if JVET_R0191_ASPECT3 + if( m_numLayersInOls[i] > 1 ) + { + m_multiLayerOlsIdx[i] = m_numMultiLayeredOlss; + m_numMultiLayeredOlss++; + } +#endif } } @@ -2258,7 +2165,6 @@ void VPS::deriveTargetOutputLayerSet( int targetOlsIdx ) m_targetLayerIdSet.push_back( m_layerIdInOls[m_targetOlsIdx][i] ); } } -#endif // ------------------------------------------------------------------------------------------------ // Picture Header @@ -2270,36 +2176,18 @@ PicHeader::PicHeader() , m_gdrPicFlag ( 0 ) , m_noOutputOfPriorPicsFlag ( 0 ) , m_recoveryPocCnt ( 0 ) -#if SPS_ID_CHECK , m_noOutputBeforeRecoveryFlag ( false ) , m_handleCraAsCvsStartFlag ( false ) , m_handleGdrAsCvsStartFlag ( false ) -#endif , m_spsId ( -1 ) , m_ppsId ( -1 ) -#if JVET_P0116_POC_MSB , m_pocMsbPresentFlag ( 0 ) , m_pocMsbVal ( 0 ) -#endif -#if !JVET_Q0119_CLEANUPS -, m_subPicIdSignallingPresentFlag ( 0 ) -, m_subPicIdLen ( 0 ) -#endif -#if JVET_Q0246_VIRTUAL_BOUNDARY_ENABLE_FLAG , m_virtualBoundariesEnabledFlag ( 0 ) , m_virtualBoundariesPresentFlag ( 0 ) -#else -, m_loopFilterAcrossVirtualBoundariesDisabledFlag ( 0 ) -#endif , m_numVerVirtualBoundaries ( 0 ) , m_numHorVirtualBoundaries ( 0 ) -#if !JVET_Q0155_COLOUR_ID -, m_colourPlaneId ( 0 ) -#endif , m_picOutputFlag ( true ) -#if !JVET_Q0819_PH_CHANGES -, m_picRplPresentFlag ( 0 ) -#endif , m_pRPL0 ( 0 ) , m_pRPL1 ( 0 ) , m_rpl0Idx ( 0 ) @@ -2310,70 +2198,40 @@ PicHeader::PicHeader() , m_cuChromaQpOffsetSubdivIntra ( 0 ) , m_cuChromaQpOffsetSubdivInter ( 0 ) , m_enableTMVPFlag ( true ) -#if JVET_Q0482_REMOVE_CONSTANT_PARAMS , m_picColFromL0Flag ( true ) -#endif , m_mvdL1ZeroFlag ( 0 ) -#if !JVET_Q0798_SPS_NUMBER_MERGE_CANDIDATE -, m_maxNumMergeCand ( MRG_MAX_NUM_CANDS ) -#endif , m_maxNumAffineMergeCand ( AFFINE_MRG_MAX_NUM_CANDS ) , m_disFracMMVD ( 0 ) , m_disBdofFlag ( 0 ) , m_disDmvrFlag ( 0 ) , m_disProfFlag ( 0 ) -#if !JVET_Q0798_SPS_NUMBER_MERGE_CANDIDATE -#if !JVET_Q0806 -, m_maxNumTriangleCand ( 0 ) -#else -, m_maxNumGeoCand ( 0 ) -#endif -, m_maxNumIBCMergeCand ( IBC_MRG_MAX_NUM_CANDS ) -#endif , m_jointCbCrSignFlag ( 0 ) -#if JVET_Q0819_PH_CHANGES , m_qpDelta ( 0 ) -#else -, m_saoEnabledPresentFlag ( 0 ) -, m_alfEnabledPresentFlag ( 0 ) -#endif , m_numAlfAps ( 0 ) , m_alfApsId ( 0 ) , m_alfChromaApsId ( 0 ) +#if !JVET_R0271_SLICE_LEVEL_DQ_SDH_RRC , m_depQuantEnabledFlag ( 0 ) , m_signDataHidingEnabledFlag ( 0 ) -#if !JVET_Q0819_PH_CHANGES -, m_deblockingFilterOverridePresentFlag ( 0 ) #endif , m_deblockingFilterOverrideFlag ( 0 ) , m_deblockingFilterDisable ( 0 ) , m_deblockingFilterBetaOffsetDiv2 ( 0 ) , m_deblockingFilterTcOffsetDiv2 ( 0 ) -#if JVET_Q0121_DEBLOCKING_CONTROL_PARAMETERS , m_deblockingFilterCbBetaOffsetDiv2 ( 0 ) , m_deblockingFilterCbTcOffsetDiv2 ( 0 ) , m_deblockingFilterCrBetaOffsetDiv2 ( 0 ) , m_deblockingFilterCrTcOffsetDiv2 ( 0 ) -#endif , m_lmcsEnabledFlag ( 0 ) , m_lmcsApsId ( -1 ) , m_lmcsAps ( nullptr ) , m_lmcsChromaResidualScaleFlag ( 0 ) -#if JVET_Q0346_SCALING_LIST_USED_IN_SH , m_explicitScalingListEnabledFlag ( 0 ) -#else -, m_scalingListPresentFlag ( 0 ) -#endif , m_scalingListApsId ( -1 ) , m_scalingListAps ( nullptr ) -#if JVET_Q0819_PH_CHANGES , m_numL0Weights ( 0 ) , m_numL1Weights ( 0 ) -#endif { -#if !JVET_Q0119_CLEANUPS - memset(m_subPicId, 0, sizeof(m_subPicId)); -#endif memset(m_virtualBoundariesPosX, 0, sizeof(m_virtualBoundariesPosX)); memset(m_virtualBoundariesPosY, 0, sizeof(m_virtualBoundariesPosY)); memset(m_saoEnabledFlag, 0, sizeof(m_saoEnabledFlag)); @@ -2396,6 +2254,8 @@ PicHeader::PicHeader() m_localRPL1.setNumberOfInterLayerPictures( 0 ); m_alfApsId.resize(0); + + resetWpScaling(); } PicHeader::~PicHeader() @@ -2415,29 +2275,13 @@ void PicHeader::initPicHeader() m_recoveryPocCnt = 0; m_spsId = -1; m_ppsId = -1; -#if JVET_P0116_POC_MSB m_pocMsbPresentFlag = 0; m_pocMsbVal = 0; -#endif -#if !JVET_Q0119_CLEANUPS - m_subPicIdSignallingPresentFlag = 0; - m_subPicIdLen = 0; -#endif -#if JVET_Q0246_VIRTUAL_BOUNDARY_ENABLE_FLAG m_virtualBoundariesEnabledFlag = 0; m_virtualBoundariesPresentFlag = 0; -#else - m_loopFilterAcrossVirtualBoundariesDisabledFlag = 0; -#endif m_numVerVirtualBoundaries = 0; m_numHorVirtualBoundaries = 0; -#if !JVET_Q0155_COLOUR_ID - m_colourPlaneId = 0; -#endif m_picOutputFlag = true; -#if !JVET_Q0819_PH_CHANGES - m_picRplPresentFlag = 0; -#endif m_pRPL0 = 0; m_pRPL1 = 0; m_rpl0Idx = 0; @@ -2448,68 +2292,38 @@ void PicHeader::initPicHeader() m_cuChromaQpOffsetSubdivIntra = 0; m_cuChromaQpOffsetSubdivInter = 0; m_enableTMVPFlag = true; -#if JVET_Q0482_REMOVE_CONSTANT_PARAMS m_picColFromL0Flag = true; -#endif m_mvdL1ZeroFlag = 0; -#if !JVET_Q0798_SPS_NUMBER_MERGE_CANDIDATE - m_maxNumMergeCand = MRG_MAX_NUM_CANDS; -#endif m_maxNumAffineMergeCand = AFFINE_MRG_MAX_NUM_CANDS; m_disFracMMVD = 0; m_disBdofFlag = 0; m_disDmvrFlag = 0; m_disProfFlag = 0; -#if !JVET_Q0798_SPS_NUMBER_MERGE_CANDIDATE -#if !JVET_Q0806 - m_maxNumTriangleCand = 0; -#else - m_maxNumGeoCand = 0; -#endif - m_maxNumIBCMergeCand = IBC_MRG_MAX_NUM_CANDS; -#endif m_jointCbCrSignFlag = 0; -#if JVET_Q0819_PH_CHANGES m_qpDelta = 0; -#else - m_saoEnabledPresentFlag = 0; - m_alfEnabledPresentFlag = 0; -#endif m_numAlfAps = 0; m_alfChromaApsId = 0; +#if !JVET_R0271_SLICE_LEVEL_DQ_SDH_RRC m_depQuantEnabledFlag = 0; m_signDataHidingEnabledFlag = 0; -#if !JVET_Q0819_PH_CHANGES - m_deblockingFilterOverridePresentFlag = 0; #endif m_deblockingFilterOverrideFlag = 0; m_deblockingFilterDisable = 0; m_deblockingFilterBetaOffsetDiv2 = 0; m_deblockingFilterTcOffsetDiv2 = 0; -#if JVET_Q0121_DEBLOCKING_CONTROL_PARAMETERS m_deblockingFilterCbBetaOffsetDiv2 = 0; m_deblockingFilterCbTcOffsetDiv2 = 0; m_deblockingFilterCrBetaOffsetDiv2 = 0; m_deblockingFilterCrTcOffsetDiv2 = 0; -#endif m_lmcsEnabledFlag = 0; m_lmcsApsId = -1; m_lmcsAps = nullptr; m_lmcsChromaResidualScaleFlag = 0; -#if JVET_Q0346_SCALING_LIST_USED_IN_SH m_explicitScalingListEnabledFlag = 0; -#else - m_scalingListPresentFlag = 0; -#endif m_scalingListApsId = -1; m_scalingListAps = nullptr; -#if JVET_Q0819_PH_CHANGES m_numL0Weights = 0; m_numL1Weights = 0; -#endif -#if !JVET_Q0119_CLEANUPS - memset(m_subPicId, 0, sizeof(m_subPicId)); -#endif memset(m_virtualBoundariesPosX, 0, sizeof(m_virtualBoundariesPosX)); memset(m_virtualBoundariesPosY, 0, sizeof(m_virtualBoundariesPosY)); memset(m_saoEnabledFlag, 0, sizeof(m_saoEnabledFlag)); @@ -2532,13 +2346,29 @@ void PicHeader::initPicHeader() m_alfApsId.resize(0); } -#if JVET_Q0819_PH_CHANGES void PicHeader::getWpScaling(RefPicList e, int iRefIdx, WPScalingParam *&wp) const { CHECK(e >= NUM_REF_PIC_LIST_01, "Invalid picture reference list"); wp = (WPScalingParam *) m_weightPredTable[e][iRefIdx]; } -#endif + +void PicHeader::resetWpScaling() +{ + for ( int e=0 ; e<NUM_REF_PIC_LIST_01 ; e++ ) + { + for ( int i=0 ; i<MAX_NUM_REF ; i++ ) + { + for ( int yuv=0 ; yuv<MAX_NUM_COMPONENT ; yuv++ ) + { + WPScalingParam *pwp = &(m_weightPredTable[e][i][yuv]); + pwp->bPresentFlag = false; + pwp->uiLog2WeightDenom = 0; + pwp->iWeight = 1; + pwp->iOffset = 0; + } + } + } +} // ------------------------------------------------------------------------------------------------ // Sequence parameter set (SPS) @@ -2562,9 +2392,6 @@ SPSRExt::SPSRExt() SPS::SPS() : m_SPSId ( 0) -#if !JVET_Q0117_PARAMETER_SETS_CLEANUP -, m_decodingParameterSetId ( 0 ) -#endif , m_VPSId ( 0 ) , m_affineAmvrEnabledFlag ( false ) , m_DMVR ( false ) @@ -2574,48 +2401,27 @@ SPS::SPS() , m_chromaFormatIdc (CHROMA_420) , m_separateColourPlaneFlag ( 0 ) , m_uiMaxTLayers ( 1) -#if JVET_P0117_PTL_SCALABILITY , m_ptlDpbHrdParamsPresentFlag (1) , m_SubLayerDpbParamsFlag (0) -#endif // Structure , m_maxWidthInLumaSamples (352) , m_maxHeightInLumaSamples (288) -#if JVET_Q0119_CLEANUPS -, m_subPicInfoPresentFlag (0) -#else -, m_subPicPresentFlag (0) -#endif +, m_subPicInfoPresentFlag (false) , m_numSubPics(1) -#if JVET_Q0119_CLEANUPS +#if JVET_R0156_ASPECT4_SPS_CLEANUP +, m_independentSubPicsFlag (false) +#endif , m_subPicIdMappingExplicitlySignalledFlag ( false ) , m_subPicIdMappingInSpsFlag ( false ) -#else -, m_subPicIdPresentFlag(0) -, m_subPicIdSignallingPresentFlag(0) -#endif , m_subPicIdLen(16) -#if JVET_Q0468_Q0469_MIN_LUMA_CB_AND_MIN_QT_FIX , m_log2MinCodingBlockSize ( 2) -#else -, m_log2MinCodingBlockSize ( 0) -, m_log2DiffMaxMinCodingBlockSize(0) -#endif , m_CTUSize(0) , m_minQT{ 0, 0, 0 } , m_maxMTTHierarchyDepth{ MAX_BT_DEPTH, MAX_BT_DEPTH_INTER, MAX_BT_DEPTH_C } -#if JVET_Q0330_BLOCK_PARTITION , m_maxBTSize{ 0, 0, 0 } , m_maxTTSize{ 0, 0, 0 } -#else -, m_maxBTSize{ MAX_BT_SIZE, MAX_BT_SIZE_INTER, MAX_BT_SIZE_C } -, m_maxTTSize{ MAX_TT_SIZE, MAX_TT_SIZE_INTER, MAX_TT_SIZE_C } -#endif , m_uiMaxCUWidth ( 32) , m_uiMaxCUHeight ( 32) -#if !JVET_Q0468_Q0469_MIN_LUMA_CB_AND_MIN_QT_FIX -, m_uiMaxCodingDepth ( 3) -#endif , m_numRPL0 ( 0 ) , m_numRPL1 ( 0 ) , m_rpl1CopyFromRpl0Flag ( false ) @@ -2624,17 +2430,13 @@ SPS::SPS() , m_bLongTermRefsPresent (false) // Tool list , m_transformSkipEnabledFlag (false) -#if JVET_Q0183_SPS_TRANSFORM_SKIP_MODE_CONTROL , m_log2MaxTransformSkipBlockSize (2) -#endif -#if JVET_Q0089_SLICE_LOSSLESS_CODING_CHROMA_BDPCM , m_BDPCMEnabledFlag (false) -#else -, m_BDPCMEnabled (0) -#endif , m_JointCbCrEnabledFlag (false) -#if JVET_Q0151_Q0205_ENTRYPOINTS , m_entropyCodingSyncEnabledFlag(false) +#if JVET_R0165_OPTIONAL_ENTRY_POINT +, m_entryPointPresentFlag(false) +#else , m_entropyCodingSyncEntryPointPresentFlag(false) #endif , m_sbtmvpEnabledFlag (false) @@ -2644,14 +2446,10 @@ SPS::SPS() , m_DmvrControlPresentFlag ( false ) , m_ProfControlPresentFlag ( false ) , m_uiBitsForPOC ( 8) -#if JVET_P0116_POC_MSB , m_pocMsbFlag ( false ) , m_pocMsbLen ( 1 ) -#endif -#if JVET_Q0400_EXTRA_BITS , m_numExtraPHBitsBytes ( 0 ) , m_numExtraSHBitsBytes ( 0 ) -#endif , m_numLongTermRefPicSPS ( 0) , m_log2MaxTbSize ( 6) @@ -2661,22 +2459,12 @@ SPS::SPS() , m_saoEnabledFlag (false) , m_bTemporalIdNestingFlag (false) , m_scalingListEnabledFlag (false) -#if JVET_Q0246_VIRTUAL_BOUNDARY_ENABLE_FLAG , m_virtualBoundariesEnabledFlag( 0 ) , m_virtualBoundariesPresentFlag( 0 ) -#else -, m_loopFilterAcrossVirtualBoundariesDisabledFlag(0) -#endif , m_numVerVirtualBoundaries(0) , m_numHorVirtualBoundaries(0) -#if JVET_P0118_HRD_ASPECTS , m_generalHrdParametersPresentFlag(false) -#else -, m_hrdParametersPresentFlag (false) -#endif -#if JVET_Q0042_VUI , m_fieldSeqFlag (false) -#endif , m_vuiParametersPresentFlag (false) , m_vuiParameters () , m_wrapAroundEnabledFlag (false) @@ -2695,11 +2483,7 @@ SPS::SPS() , m_AffineType ( false ) , m_PROF ( false ) , m_ciip ( false ) -#if !JVET_Q0806 -, m_Triangle ( false ) -#else , m_Geo ( false ) -#endif #if LUMA_ADAPTIVE_DEBLOCKING_FILTER_QP_OFFSET , m_LadfEnabled ( false ) , m_LadfNumIntervals ( 0 ) @@ -2711,11 +2495,13 @@ SPS::SPS() , m_GDREnabledFlag ( true ) , m_SubLayerCbpParametersPresentFlag ( true ) , m_rprEnabledFlag ( false ) -#if JVET_Q0798_SPS_NUMBER_MERGE_CANDIDATE , m_maxNumMergeCand(MRG_MAX_NUM_CANDS) , m_maxNumAffineMergeCand(AFFINE_MRG_MAX_NUM_CANDS) , m_maxNumIBCMergeCand(IBC_MRG_MAX_NUM_CANDS) , m_maxNumGeoCand(0) +#if JVET_R0380_SCALING_MATRIX_DISABLE_YCC_OR_RGB +, m_scalingMatrixAlternativeColourSpaceDisabledFlag( false ) +, m_scalingMatrixDesignatedColourSpaceFlag( true ) #endif { for(int ch=0; ch<MAX_NUM_CHANNEL_TYPE; ch++) @@ -2735,15 +2521,7 @@ SPS::SPS() ::memset(m_usedByCurrPicLtSPSFlag, 0, sizeof(m_usedByCurrPicLtSPSFlag)); ::memset(m_virtualBoundariesPosX, 0, sizeof(m_virtualBoundariesPosX)); ::memset(m_virtualBoundariesPosY, 0, sizeof(m_virtualBoundariesPosY)); -#if JVET_Q0179_SCALING_WINDOW_SIZE_CONSTRAINT ::memset(m_ppsValidFlag, 0, sizeof(m_ppsValidFlag)); -#endif - ::memset(m_subPicCtuTopLeftX, 0, sizeof(m_subPicCtuTopLeftX)); - ::memset(m_subPicCtuTopLeftY, 0, sizeof(m_subPicCtuTopLeftY)); - ::memset(m_SubPicWidth, 0, sizeof(m_SubPicWidth)); - ::memset(m_SubPicHeight, 0, sizeof(m_SubPicHeight)); - ::memset(m_subPicTreatedAsPicFlag, 0, sizeof(m_subPicTreatedAsPicFlag)); - ::memset(m_loopFilterAcrossSubpicEnabledFlag, 0, sizeof(m_loopFilterAcrossSubpicEnabledFlag)); } SPS::~SPS() @@ -2854,7 +2632,6 @@ RectSlice::~RectSlice() { } -#if JVET_O1143_SUBPIC_BOUNDARY SubPic::SubPic() : m_subPicID (0) , m_numCTUsInSubPic (0) @@ -2878,24 +2655,8 @@ SubPic::~SubPic() { m_ctuAddrInSubPic.clear(); } -#endif -#if !REMOVE_PPS_REXT -PPSRExt::PPSRExt() -: m_crossComponentPredictionEnabledFlag(false) -#if JVET_Q0441_SAO_MOD_12_BIT -{ -#else -// m_log2SaoOffsetScale initialized below -{ - for(int ch=0; ch<MAX_NUM_CHANNEL_TYPE; ch++) - { - m_log2SaoOffsetScale[ch] = 0; - } -#endif -} -#endif - + PPS::PPS() : m_PPSId (0) , m_SPSId (0) @@ -2910,11 +2671,7 @@ PPS::PPS() , m_numRefIdxL1DefaultActive (1) , m_rpl1IdxPresentFlag (false) , m_numSubPics (1) -#if JVET_Q0119_CLEANUPS , m_subPicIdMappingInPpsFlag (0) -#else -, m_subPicIdSignallingPresentFlag (0) -#endif , m_subPicIdLen (16) , m_noPicPartitionFlag (1) , m_log2CtuSize (0) @@ -2923,52 +2680,25 @@ PPS::PPS() , m_picHeightInCtu (0) , m_numTileCols (1) , m_numTileRows (1) -, m_rectSliceFlag (1) - , m_singleSlicePerSubPicFlag (0) +, m_rectSliceFlag (1) +, m_singleSlicePerSubPicFlag (0) , m_numSlicesInPic (1) , m_tileIdxDeltaPresentFlag (0) , m_loopFilterAcrossTilesEnabledFlag (1) , m_loopFilterAcrossSlicesEnabledFlag(0) -#if !JVET_Q0183_SPS_TRANSFORM_SKIP_MODE_CONTROL - , m_log2MaxTransformSkipBlockSize (2) -#endif -#if !JVET_Q0151_Q0205_ENTRYPOINTS -, m_entropyCodingSyncEnabledFlag (false) -#endif -#if !JVET_Q0482_REMOVE_CONSTANT_PARAMS -, m_constantSliceHeaderParamsEnabledFlag (false) -, m_PPSDepQuantEnabledIdc (0) -, m_PPSRefPicListSPSIdc0 (0) -, m_PPSRefPicListSPSIdc1 (0) -, m_PPSMvdL1ZeroIdc (0) -, m_PPSCollocatedFromL0Idc (0) -, m_PPSSixMinusMaxNumMergeCandPlus1 (0) -#if !JVET_Q0806 -, m_PPSMaxNumMergeCandMinusMaxNumTriangleCandPlus1 (0) -#else -, m_PPSMaxNumMergeCandMinusMaxNumGeoCandPlus1 (0) -#endif -#endif , m_cabacInitPresentFlag (false) , m_pictureHeaderExtensionPresentFlag(0) , m_sliceHeaderExtensionPresentFlag (false) , m_listsModificationPresentFlag (0) -#if JVET_Q0819_PH_CHANGES , m_rplInfoInPhFlag (0) , m_dbfInfoInPhFlag (0) , m_saoInfoInPhFlag (0) , m_alfInfoInPhFlag (0) , m_wpInfoInPhFlag (0) , m_qpDeltaInfoInPhFlag (0) -#endif -#if SPS_ID_CHECK , m_mixedNaluTypesInPicFlag ( false ) -#endif , m_picWidthInLumaSamples(352) , m_picHeightInLumaSamples( 288 ) -#if !REMOVE_PPS_REXT -, m_ppsRangeExtension () -#endif , pcv (NULL) { m_ChromaQpAdjTableIncludingNullEntry[0].u.comp.CbOffset = 0; // Array includes entry [0] for the null offset used when cu_chroma_qp_offset_flag=0. This is initialised here and never subsequently changed. @@ -2983,9 +2713,7 @@ PPS::PPS() m_ctuToSubPicIdx.clear(); m_rectSlices.clear(); m_sliceMap.clear(); -#if JVET_O1143_SUBPIC_BOUNDARY m_subPics.clear(); -#endif } PPS::~PPS() @@ -3000,9 +2728,7 @@ PPS::~PPS() m_rectSlices.clear(); m_sliceMap.clear(); -#if JVET_O1143_SUBPIC_BOUNDARY m_subPics.clear(); -#endif delete pcv; } @@ -3034,7 +2760,7 @@ void PPS::initTiles() { int colIdx, rowIdx; int ctuX, ctuY; - + // check explicit tile column sizes uint32_t remainingWidthInCtu = m_picWidthInCtu; for( colIdx = 0; colIdx < m_numExpTileCols; colIdx++ ) @@ -3045,7 +2771,7 @@ void PPS::initTiles() // divide remaining picture width into uniform tile columns uint32_t uniformTileColWidth = m_tileColWidth[colIdx-1]; - while( remainingWidthInCtu > 0 ) + while( remainingWidthInCtu > 0 ) { CHECK(colIdx >= MAX_TILE_COLS, "Number of tile columns exceeds valid range"); uniformTileColWidth = std::min(remainingWidthInCtu, uniformTileColWidth); @@ -3054,7 +2780,7 @@ void PPS::initTiles() colIdx++; } m_numTileCols = colIdx; - + // check explicit tile row sizes uint32_t remainingHeightInCtu = m_picHeightInCtu; for( rowIdx = 0; rowIdx < m_numExpTileRows; rowIdx++ ) @@ -3062,10 +2788,10 @@ void PPS::initTiles() CHECK(m_tileRowHeight[rowIdx] > remainingHeightInCtu, "Tile row height exceeds picture height"); remainingHeightInCtu -= m_tileRowHeight[rowIdx]; } - + // divide remaining picture height into uniform tile rows uint32_t uniformTileRowHeight = m_tileRowHeight[rowIdx - 1]; - while( remainingHeightInCtu > 0 ) + while( remainingHeightInCtu > 0 ) { CHECK(rowIdx >= MAX_TILE_ROWS, "Number of tile rows exceeds valid range"); uniformTileRowHeight = std::min(remainingHeightInCtu, uniformTileRowHeight); @@ -3081,7 +2807,7 @@ void PPS::initTiles() { m_tileColBd.push_back( m_tileColBd[ colIdx ] + m_tileColWidth[ colIdx ] ); } - + // set top row bounaries m_tileRowBd.push_back( 0 ); for( rowIdx = 0; rowIdx < m_numTileRows; rowIdx++ ) @@ -3091,7 +2817,7 @@ void PPS::initTiles() // set mapping between horizontal CTU address and tile column index colIdx = 0; - for( ctuX = 0; ctuX <= m_picWidthInCtu; ctuX++ ) + for( ctuX = 0; ctuX <= m_picWidthInCtu; ctuX++ ) { if( ctuX == m_tileColBd[ colIdx + 1 ] ) { @@ -3099,10 +2825,10 @@ void PPS::initTiles() } m_ctuToTileCol.push_back( colIdx ); } - + // set mapping between vertical CTU address and tile row index rowIdx = 0; - for( ctuY = 0; ctuY <= m_picHeightInCtu; ctuY++ ) + for( ctuY = 0; ctuY <= m_picHeightInCtu; ctuY++ ) { if( ctuY == m_tileRowBd[ rowIdx + 1 ] ) { @@ -3116,7 +2842,7 @@ void PPS::initTiles() - initialize memory for rectangular slice parameters */ void PPS::initRectSlices() -{ +{ CHECK(m_numSlicesInPic > MAX_SLICES, "Number of slices in picture exceeds valid range"); m_rectSlices.resize(m_numSlicesInPic); } @@ -3124,89 +2850,174 @@ void PPS::initRectSlices() /** - initialize mapping between rectangular slices and CTUs */ -void PPS::initRectSliceMap() +void PPS::initRectSliceMap(const SPS *sps) { uint32_t ctuY; uint32_t tileX, tileY; - - // allocate new memory for slice list - CHECK(m_numSlicesInPic > MAX_SLICES, "Number of slices in picture exceeds valid range"); - m_sliceMap.resize( m_numSlicesInPic ); -#if JVET_Q0817 - if( getSingleSlicePerSubPicFlag() ) - { -#else - if ((getNumSubPics() > 0) && getSingleSlicePerSubPicFlag()) + + if (sps) { -#endif - for (uint32_t i = 0; i <= getNumSubPics() - 1; i++) + m_ctuToSubPicIdx.resize(getPicWidthInCtu() * getPicHeightInCtu()); + if (sps->getNumSubPics() > 1) { - m_sliceMap[i].initSliceMap(); + for (int i = 0; i <= sps->getNumSubPics() - 1; i++) + { + for (int y = sps->getSubPicCtuTopLeftY(i); y < sps->getSubPicCtuTopLeftY(i) + sps->getSubPicHeight(i); y++) + { + for (int x = sps->getSubPicCtuTopLeftX(i); x < sps->getSubPicCtuTopLeftX(i) + sps->getSubPicWidth(i); x++) + { + m_ctuToSubPicIdx[ x+ y * getPicWidthInCtu()] = i; + } + } + } } - uint32_t picSizeInCtu = getPicWidthInCtu() * getPicHeightInCtu(); - uint32_t sliceIdx; - for (uint32_t i = 0; i < picSizeInCtu; i++) + else { - sliceIdx = getCtuToSubPicIdx(i); - m_sliceMap[sliceIdx].pushToCtuAddrInSlice(i); + for (int i = 0; i < getPicWidthInCtu() * getPicHeightInCtu(); i++) + { + m_ctuToSubPicIdx[i] = 0; + } } } - else - { - // generate CTU maps for all rectangular slices in picture - for( uint32_t i = 0; i < m_numSlicesInPic; i++ ) + + if( getSingleSlicePerSubPicFlag() ) { - m_sliceMap[ i ].initSliceMap(); + CHECK (sps==nullptr, "RectSliceMap can only be initialized for slice_per_sub_pic_flag with a valid SPS"); + m_numSlicesInPic = sps->getNumSubPics(); + + // allocate new memory for slice list + CHECK(m_numSlicesInPic > MAX_SLICES, "Number of slices in picture exceeds valid range"); + m_sliceMap.resize( m_numSlicesInPic ); - // get position of first tile in slice - tileX = m_rectSlices[ i ].getTileIdx() % m_numTileCols; - tileY = m_rectSlices[ i ].getTileIdx() / m_numTileCols; - - // infer slice size for last slice in picture - if( i == m_numSlicesInPic-1 ) + if (sps->getNumSubPics() > 1) { - m_rectSlices[ i ].setSliceWidthInTiles ( m_numTileCols - tileX ); - m_rectSlices[ i ].setSliceHeightInTiles( m_numTileRows - tileY ); - m_rectSlices[ i ].setNumSlicesInTile( 1 ); - } + // Q2001 v15 equation 29 + std::vector<uint32_t> subpicWidthInTiles; + std::vector<uint32_t> subpicHeightInTiles; + std::vector<uint32_t> subpicHeightLessThanOneTileFlag; + subpicWidthInTiles.resize(sps->getNumSubPics()); + subpicHeightInTiles.resize(sps->getNumSubPics()); + subpicHeightLessThanOneTileFlag.resize(sps->getNumSubPics()); + for (uint32_t i = 0; i <sps->getNumSubPics(); i++) + { + uint32_t leftX = sps->getSubPicCtuTopLeftX(i); + uint32_t rightX = leftX + sps->getSubPicWidth(i) - 1; + subpicWidthInTiles[i] = m_ctuToTileCol[rightX] + 1 - m_ctuToTileCol[leftX]; - // set slice index - m_sliceMap[ i ].setSliceID(i); - - // complete tiles within a single slice case - if( m_rectSlices[ i ].getSliceWidthInTiles( ) > 1 || m_rectSlices[ i ].getSliceHeightInTiles( ) > 1) + uint32_t topY = sps->getSubPicCtuTopLeftY(i); + uint32_t bottomY = topY + sps->getSubPicHeight(i) - 1; + subpicHeightInTiles[i] = m_ctuToTileRow[bottomY] + 1 - m_ctuToTileRow[topY]; + + if (subpicHeightInTiles[i] == 1 && sps->getSubPicHeight(i) < m_tileRowHeight[m_ctuToTileRow[topY]] ) + { + subpicHeightLessThanOneTileFlag[i] = 1; + } + else + { + subpicHeightLessThanOneTileFlag[i] = 0; + } + } + + for( int i = 0; i < m_numSlicesInPic; i++ ) + { + CHECK(m_numSlicesInPic != sps->getNumSubPics(), "in single slice per subpic mode, number of slice and subpic shall be equal"); + m_sliceMap[ i ].initSliceMap(); + if (subpicHeightLessThanOneTileFlag[i]) + { + m_sliceMap[i].addCtusToSlice(sps->getSubPicCtuTopLeftX(i), sps->getSubPicCtuTopLeftX(i) + sps->getSubPicWidth(i), + sps->getSubPicCtuTopLeftY(i), sps->getSubPicCtuTopLeftY(i) + sps->getSubPicHeight(i), m_picWidthInCtu); + } + else + { + tileX = m_ctuToTileCol[sps->getSubPicCtuTopLeftX(i)]; + tileY = m_ctuToTileRow[sps->getSubPicCtuTopLeftY(i)]; + for (uint32_t j = 0; j< subpicHeightInTiles[i]; j++) + { + for (uint32_t k = 0; k < subpicWidthInTiles[i]; k++) + { + m_sliceMap[i].addCtusToSlice(getTileColumnBd(tileX + k), getTileColumnBd(tileX + k + 1), getTileRowBd(tileY + j), getTileRowBd(tileY + j + 1), m_picWidthInCtu); + } + } + } + } + subpicWidthInTiles.clear(); + subpicHeightInTiles.clear(); + subpicHeightLessThanOneTileFlag.clear(); + } + else { - for( uint32_t j = 0; j < m_rectSlices[ i ].getSliceHeightInTiles( ); j++ ) + m_sliceMap[0].initSliceMap(); + for (int tileY=0; tileY<m_numTileRows; tileY++) { - for( uint32_t k = 0; k < m_rectSlices[ i ].getSliceWidthInTiles( ); k++ ) + for (int tileX=0; tileX<m_numTileCols; tileX++) { - m_sliceMap[ i ].addCtusToSlice( getTileColumnBd(tileX + k), getTileColumnBd(tileX + k +1), - getTileRowBd(tileY + j), getTileRowBd(tileY + j +1), m_picWidthInCtu); + m_sliceMap[0].addCtusToSlice(getTileColumnBd(tileX), getTileColumnBd(tileX + 1), + getTileRowBd(tileY), getTileRowBd(tileY + 1), m_picWidthInCtu); } } + m_sliceMap[0].setSliceID(0); } - // multiple slices within a single tile case - else + } + else + { + // allocate new memory for slice list + CHECK(m_numSlicesInPic > MAX_SLICES, "Number of slices in picture exceeds valid range"); + m_sliceMap.resize( m_numSlicesInPic ); + // generate CTU maps for all rectangular slices in picture + for( uint32_t i = 0; i < m_numSlicesInPic; i++ ) { - uint32_t numSlicesInTile = m_rectSlices[ i ].getNumSlicesInTile( ); + m_sliceMap[ i ].initSliceMap(); + + // get position of first tile in slice + tileX = m_rectSlices[ i ].getTileIdx() % m_numTileCols; + tileY = m_rectSlices[ i ].getTileIdx() / m_numTileCols; - ctuY = getTileRowBd( tileY ); - for( uint32_t j = 0; j < numSlicesInTile-1; j++ ) + // infer slice size for last slice in picture + if( i == m_numSlicesInPic-1 ) { - m_sliceMap[ i ].addCtusToSlice( getTileColumnBd(tileX), getTileColumnBd(tileX+1), - ctuY, ctuY + m_rectSlices[ i ].getSliceHeightInCtu(), m_picWidthInCtu); - ctuY += m_rectSlices[ i ].getSliceHeightInCtu(); - i++; - m_sliceMap[ i ].setSliceID(i); + m_rectSlices[ i ].setSliceWidthInTiles ( m_numTileCols - tileX ); + m_rectSlices[ i ].setSliceHeightInTiles( m_numTileRows - tileY ); + m_rectSlices[ i ].setNumSlicesInTile( 1 ); } - // infer slice height for last slice in tile - CHECK( ctuY >= getTileRowBd( tileY + 1 ), "Invalid rectangular slice signalling"); - m_rectSlices[ i ].setSliceHeightInCtu( getTileRowBd( tileY + 1 ) - ctuY ); - m_sliceMap[ i ].addCtusToSlice( getTileColumnBd(tileX), getTileColumnBd(tileX+1), - ctuY, getTileRowBd( tileY + 1 ), m_picWidthInCtu); - } - } + // set slice index + m_sliceMap[ i ].setSliceID(i); + + // complete tiles within a single slice case + if( m_rectSlices[ i ].getSliceWidthInTiles( ) > 1 || m_rectSlices[ i ].getSliceHeightInTiles( ) > 1) + { + for( uint32_t j = 0; j < m_rectSlices[ i ].getSliceHeightInTiles( ); j++ ) + { + for( uint32_t k = 0; k < m_rectSlices[ i ].getSliceWidthInTiles( ); k++ ) + { + m_sliceMap[ i ].addCtusToSlice( getTileColumnBd(tileX + k), getTileColumnBd(tileX + k +1), + getTileRowBd(tileY + j), getTileRowBd(tileY + j +1), m_picWidthInCtu); + } + } + } + // multiple slices within a single tile case + else + { + uint32_t numSlicesInTile = m_rectSlices[ i ].getNumSlicesInTile( ); + + ctuY = getTileRowBd( tileY ); + for( uint32_t j = 0; j < numSlicesInTile-1; j++ ) + { + m_sliceMap[ i ].addCtusToSlice( getTileColumnBd(tileX), getTileColumnBd(tileX+1), + ctuY, ctuY + m_rectSlices[ i ].getSliceHeightInCtu(), m_picWidthInCtu); + ctuY += m_rectSlices[ i ].getSliceHeightInCtu(); + i++; + m_sliceMap[ i ].initSliceMap(); + m_sliceMap[ i ].setSliceID(i); + } + + // infer slice height for last slice in tile + CHECK( ctuY >= getTileRowBd( tileY + 1 ), "Invalid rectangular slice signalling"); + m_rectSlices[ i ].setSliceHeightInCtu( getTileRowBd( tileY + 1 ) - ctuY ); + m_sliceMap[ i ].addCtusToSlice( getTileColumnBd(tileX), getTileColumnBd(tileX+1), + ctuY, getTileRowBd( tileY + 1 ), m_picWidthInCtu); + } + } } // check for valid rectangular slice map checkSliceMap(); @@ -3215,7 +3026,6 @@ void PPS::initRectSliceMap() /** - initialize mapping between subpicture and CTUs */ -#if JVET_O1143_SUBPIC_BOUNDARY void PPS::initSubPic(const SPS &sps) { if (getSubPicIdMappingInPpsFlag()) @@ -3241,7 +3051,6 @@ void PPS::initSubPic(const SPS &sps) for (int i=0; i< getNumSubPics(); i++) { m_subPics[i].setSubPicIdx(i); -#if JVET_Q0044_SLICE_IDX_WITH_SUBPICS if(sps.getSubPicIdMappingExplicitlySignalledFlag()) { if(m_subPicIdMappingInPpsFlag) @@ -3257,48 +3066,47 @@ void PPS::initSubPic(const SPS &sps) { m_subPics[i].setSubPicID(i); } -#endif m_subPics[i].setSubPicCtuTopLeftX(sps.getSubPicCtuTopLeftX(i)); m_subPics[i].setSubPicCtuTopLeftY(sps.getSubPicCtuTopLeftY(i)); m_subPics[i].setSubPicWidthInCTUs(sps.getSubPicWidth(i)); m_subPics[i].setSubPicHeightInCTUs(sps.getSubPicHeight(i)); - + uint32_t firstCTU = sps.getSubPicCtuTopLeftY(i) * m_picWidthInCtu + sps.getSubPicCtuTopLeftX(i); - m_subPics[i].setFirstCTUInSubPic(firstCTU); + m_subPics[i].setFirstCTUInSubPic(firstCTU); uint32_t lastCTU = (sps.getSubPicCtuTopLeftY(i) + sps.getSubPicHeight(i) - 1) * m_picWidthInCtu + sps.getSubPicCtuTopLeftX(i) + sps.getSubPicWidth(i) - 1; m_subPics[i].setLastCTUInSubPic(lastCTU); - + uint32_t left = sps.getSubPicCtuTopLeftX(i) * m_ctuSize; m_subPics[i].setSubPicLeft(left); - + uint32_t right = std::min(m_picWidthInLumaSamples - 1, (sps.getSubPicCtuTopLeftX(i) + sps.getSubPicWidth(i)) * m_ctuSize - 1); m_subPics[i].setSubPicRight(right); - + m_subPics[i].setSubPicWidthInLumaSample(right - left + 1); uint32_t top = sps.getSubPicCtuTopLeftY(i) * m_ctuSize; m_subPics[i].setSubPicTop(top); - + uint32_t bottom = std::min(m_picHeightInLumaSamples - 1, (sps.getSubPicCtuTopLeftY(i) + sps.getSubPicHeight(i)) * m_ctuSize - 1); m_subPics[i].setSubPicHeightInLumaSample(bottom - top + 1); m_subPics[i].setSubPicBottom(bottom); - + m_subPics[i].clearCTUAddrList(); - + if (m_numSlicesInPic == 1) { CHECK(getNumSubPics() != 1, "only one slice in picture, but number of subpic is not one"); m_subPics[i].addAllCtusInPicToSubPic(0, getPicWidthInCtu(), 0, getPicHeightInCtu(), getPicWidthInCtu()); -#if JVET_Q0044_SLICE_IDX_WITH_SUBPICS m_subPics[i].setNumSlicesInSubPic(1); -#endif } else { -#if JVET_Q0044_SLICE_IDX_WITH_SUBPICS int numSlicesInSubPic = 0; +#if R0091_CONSTRAINT_SLICE_ORDER + int idxLastSliceInSubpic = -1; + int idxFirstSliceAfterSubpic = m_numSlicesInPic; #endif for (int j = 0; j < m_numSlicesInPic; j++) { @@ -3308,25 +3116,33 @@ void PPS::initSubPic(const SPS &sps) if (ctu_x >= sps.getSubPicCtuTopLeftX(i) && ctu_x < (sps.getSubPicCtuTopLeftX(i) + sps.getSubPicWidth(i)) && ctu_y >= sps.getSubPicCtuTopLeftY(i) && - ctu_y < (sps.getSubPicCtuTopLeftY(i) + sps.getSubPicHeight(i))) + ctu_y < (sps.getSubPicCtuTopLeftY(i) + sps.getSubPicHeight(i))) { // add ctus in a slice to the subpicture it belongs to m_subPics[i].addCTUsToSubPic(m_sliceMap[j].getCtuAddrList()); -#if JVET_Q0044_SLICE_IDX_WITH_SUBPICS numSlicesInSubPic++; +#if R0091_CONSTRAINT_SLICE_ORDER + idxLastSliceInSubpic = j; #endif } +#if R0091_CONSTRAINT_SLICE_ORDER + else if (idxFirstSliceAfterSubpic == m_numSlicesInPic && idxLastSliceInSubpic != -1) + { + idxFirstSliceAfterSubpic = j; + } +#endif } -#if JVET_Q0044_SLICE_IDX_WITH_SUBPICS - m_subPics[i].setNumSlicesInSubPic(numSlicesInSubPic); +#if R0091_CONSTRAINT_SLICE_ORDER + CHECK( idxFirstSliceAfterSubpic < idxLastSliceInSubpic, "The signalling order of slices shall follow the coding order" ); #endif + m_subPics[i].setNumSlicesInSubPic(numSlicesInSubPic); } m_subPics[i].setTreatedAsPicFlag(sps.getSubPicTreatedAsPicFlag(i)); m_subPics[i].setloopFilterAcrossEnabledFlag(sps.getLoopFilterAcrossSubpicEnabledFlag(i)); } } -SubPic PPS::getSubPicFromPos(const Position& pos) const +const SubPic& PPS::getSubPicFromPos(const Position& pos) const { for (int i = 0; i< m_numSubPics; i++) { @@ -3338,14 +3154,12 @@ SubPic PPS::getSubPicFromPos(const Position& pos) const return m_subPics[0]; } -SubPic PPS::getSubPicFromCU(const CodingUnit& cu) const +const SubPic& PPS::getSubPicFromCU(const CodingUnit& cu) const { const Position lumaPos = cu.Y().valid() ? cu.Y().pos() : recalcPosition(cu.chromaFormat, cu.chType, CHANNEL_TYPE_LUMA, cu.blocks[cu.chType].pos()); return getSubPicFromPos(lumaPos); } -#endif -#if JVET_Q0044_SLICE_IDX_WITH_SUBPICS uint32_t PPS::getSubPicIdxFromSubPicId( uint32_t subPicId ) const { for (int i = 0; i < m_numSubPics; i++) @@ -3357,7 +3171,6 @@ uint32_t PPS::getSubPicIdxFromSubPicId( uint32_t subPicId ) const } return 0; } -#endif void PPS::initRasterSliceMap( std::vector<uint32_t> numTilesInSlice ) { @@ -3368,7 +3181,7 @@ void PPS::initRasterSliceMap( std::vector<uint32_t> numTilesInSlice ) CHECK(m_numSlicesInPic > MAX_SLICES, "Number of slices in picture exceeds valid range"); m_sliceMap.resize( m_numSlicesInPic ); - for( uint32_t sliceIdx = 0; sliceIdx < numTilesInSlice.size(); sliceIdx++ ) + for( uint32_t sliceIdx = 0; sliceIdx < numTilesInSlice.size(); sliceIdx++ ) { m_sliceMap[sliceIdx].initSliceMap(); m_sliceMap[sliceIdx].setSliceID( tileIdx ); @@ -3380,7 +3193,7 @@ void PPS::initRasterSliceMap( std::vector<uint32_t> numTilesInSlice ) CHECK(tileY >= getNumTileRows(), "Number of tiles in slice exceeds the remaining number of tiles in picture"); m_sliceMap[sliceIdx].addCtusToSlice(getTileColumnBd(tileX), getTileColumnBd(tileX + 1), - getTileRowBd(tileY), getTileRowBd(tileY + 1), + getTileRowBd(tileY), getTileRowBd(tileY + 1), getPicWidthInCtu()); tileIdx++; } @@ -3402,10 +3215,10 @@ void PPS::checkSliceMap() { sliceList = m_sliceMap[ i ].getCtuAddrList(); ctuList.insert( ctuList.end(), sliceList.begin(), sliceList.end() ); - } + } CHECK( ctuList.size() < picSizeInCtu, "Slice map contains too few CTUs"); CHECK( ctuList.size() > picSizeInCtu, "Slice map contains too many CTUs"); - std::sort( ctuList.begin(), ctuList.end() ); + std::sort( ctuList.begin(), ctuList.end() ); for( i = 1; i < ctuList.size(); i++ ) { CHECK( ctuList[i] > ctuList[i-1]+1, "CTU missing in slice map"); @@ -3523,9 +3336,7 @@ void ReferencePictureList::printRefPicInfo() const ScalingList::ScalingList() { m_disableScalingMatrixForLfnstBlks = true; -#if JVET_Q0505_CHROAM_QM_SIGNALING_400 m_chromaScalingListPresentFlag = true; -#endif for (uint32_t scalingListId = 0; scalingListId < 28; scalingListId++) { int matrixSize = (scalingListId < SCALING_LIST_1D_START_4x4) ? 2 : (scalingListId < SCALING_LIST_1D_START_8x8) ? 4 : 8; @@ -3979,12 +3790,10 @@ void ScalingList::checkDcOfMatrix() } } -#if JVET_Q0505_CHROAM_QM_SIGNALING_400 bool ScalingList::isLumaScalingList( int scalingListId) const { return (scalingListId % MAX_NUM_COMPONENT == SCALING_LIST_1D_START_4x4 || scalingListId == SCALING_LIST_1D_START_64x64 + 1); } -#endif uint32_t PreCalcValues::getValIdx( const Slice &slice, const ChannelType chType ) const { @@ -3993,7 +3802,7 @@ uint32_t PreCalcValues::getValIdx( const Slice &slice, const ChannelType chType uint32_t PreCalcValues::getMaxBtDepth( const Slice &slice, const ChannelType chType ) const { - if ( slice.getPicHeader()->getSplitConsOverrideFlag() ) + if ( slice.getPicHeader()->getSplitConsOverrideFlag() ) return slice.getPicHeader()->getMaxMTTHierarchyDepth( slice.getSliceType(), ISingleTree ? CHANNEL_TYPE_LUMA : chType); else return maxBtDepth[getValIdx( slice, chType )]; @@ -4039,7 +3848,7 @@ void Slice::scaleRefPicList( Picture *scaledRefPic[ ], PicHeader *picHeader, APS const PPS* pps = getPPS(); bool refPicIsSameRes = false; - + // this is needed for IBC m_pcPic->unscaledPic = m_pcPic; @@ -4066,11 +3875,7 @@ void Slice::scaleRefPicList( Picture *scaledRefPic[ ], PicHeader *picHeader, APS CU::getRprScaling( sps, pps, m_apcRefPicList[refList][rIdx], xScale, yScale ); m_scalingRatio[refList][rIdx] = std::pair<int, int>( xScale, yScale ); -#if JVET_Q0487_SCALING_WINDOW_ISSUES if( m_apcRefPicList[refList][rIdx]->isRefScaled( pps ) == false ) -#else - if( m_scalingRatio[refList][rIdx] == SCALE_1X && pps->getPicWidthInLumaSamples() == m_apcRefPicList[refList][rIdx]->getPicWidthInLumaSamples() && pps->getPicHeightInLumaSamples() == m_apcRefPicList[refList][rIdx]->getPicHeightInLumaSamples() ) -#endif { refPicIsSameRes = true; } @@ -4082,10 +3887,12 @@ void Slice::scaleRefPicList( Picture *scaledRefPic[ ], PicHeader *picHeader, APS else { int poc = m_apcRefPicList[refList][rIdx]->getPOC(); + int layerId = m_apcRefPicList[refList][rIdx]->layerId; + // check whether the reference picture has already been scaled for( i = 0; i < MAX_NUM_REF; i++ ) { - if( scaledRefPic[i] != nullptr && scaledRefPic[i]->poc == poc ) + if( scaledRefPic[i] != nullptr && scaledRefPic[i]->poc == poc && scaledRefPic[i]->layerId == layerId ) { break; } @@ -4120,9 +3927,9 @@ void Slice::scaleRefPicList( Picture *scaledRefPic[ ], PicHeader *picHeader, APS scaledRefPic[j]->finalInit( m_pcPic->cs->vps, *sps, *pps, picHeader, apss, lmcsAps, scalingListAps ); - scaledRefPic[j]->poc = -1; + scaledRefPic[j]->poc = NOT_VALID; - scaledRefPic[j]->create( sps->getChromaFormatIdc(), Size( pps->getPicWidthInLumaSamples(), pps->getPicHeightInLumaSamples() ), sps->getMaxCUWidth(), sps->getMaxCUWidth() + 16, isDecoder, m_pcPic->layerId ); + scaledRefPic[j]->create( sps->getChromaFormatIdc(), Size( pps->getPicWidthInLumaSamples(), pps->getPicHeightInLumaSamples() ), sps->getMaxCUWidth(), sps->getMaxCUWidth() + 16, isDecoder, layerId ); } scaledRefPic[j]->poc = poc; @@ -4130,9 +3937,9 @@ void Slice::scaleRefPicList( Picture *scaledRefPic[ ], PicHeader *picHeader, APS // rescale the reference picture const bool downsampling = m_apcRefPicList[refList][rIdx]->getRecoBuf().Y().width >= scaledRefPic[j]->getRecoBuf().Y().width && m_apcRefPicList[refList][rIdx]->getRecoBuf().Y().height >= scaledRefPic[j]->getRecoBuf().Y().height; - Picture::rescalePicture( m_scalingRatio[refList][rIdx], - m_apcRefPicList[refList][rIdx]->getRecoBuf(), m_apcRefPicList[refList][rIdx]->slices[0]->getPPS()->getScalingWindow(), - scaledRefPic[j]->getRecoBuf(), pps->getScalingWindow(), + Picture::rescalePicture( m_scalingRatio[refList][rIdx], + m_apcRefPicList[refList][rIdx]->getRecoBuf(), m_apcRefPicList[refList][rIdx]->slices[0]->getPPS()->getScalingWindow(), + scaledRefPic[j]->getRecoBuf(), pps->getScalingWindow(), sps->getChromaFormatIdc(), sps->getBitDepths(), true, downsampling, sps->getHorCollocatedChromaFlag(), sps->getVerCollocatedChromaFlag() ); scaledRefPic[j]->extendPicBorder(); @@ -4164,7 +3971,7 @@ void Slice::scaleRefPicList( Picture *scaledRefPic[ ], PicHeader *picHeader, APS m_apcRefPicList[refList][rIdx]->unscaledPic = m_savedRefPicList[refList][rIdx]; } } - + //Make sure that TMVP is disabled when there are no reference pictures with the same resolution if(!refPicIsSameRes) { @@ -4212,11 +4019,12 @@ bool Slice::checkRPR() return false; } -#if JVET_Q0117_PARAMETER_SETS_CLEANUP bool operator == (const ConstraintInfo& op1, const ConstraintInfo& op2) { +#if !JVET_R0090_VUI if( op1.m_progressiveSourceFlag != op2.m_progressiveSourceFlag ) return false; if( op1.m_interlacedSourceFlag != op2.m_interlacedSourceFlag ) return false; +#endif if( op1.m_nonPackedConstraintFlag != op2.m_nonPackedConstraintFlag ) return false; if( op1.m_frameOnlyConstraintFlag != op2.m_frameOnlyConstraintFlag ) return false; if( op1.m_intraOnlyConstraintFlag != op2.m_intraOnlyConstraintFlag ) return false; @@ -4224,13 +4032,27 @@ bool operator == (const ConstraintInfo& op1, const ConstraintInfo& o if( op1.m_maxChromaFormatConstraintIdc != op2.m_maxChromaFormatConstraintIdc ) return false; if( op1.m_onePictureOnlyConstraintFlag != op2.m_onePictureOnlyConstraintFlag ) return false; if( op1.m_lowerBitRateConstraintFlag != op2.m_lowerBitRateConstraintFlag ) return false; + +#if JVET_R0286_GCI_CLEANUP + if (op1.m_singleLayerConstraintFlag != op2.m_singleLayerConstraintFlag ) return false; + if (op1.m_allLayersIndependentConstraintFlag != op2.m_allLayersIndependentConstraintFlag ) return false; + if (op1.m_noMrlConstraintFlag != op2.m_noMrlConstraintFlag ) return false; + if (op1.m_noIspConstraintFlag != op2.m_noIspConstraintFlag ) return false; + if (op1.m_noMipConstraintFlag != op2.m_noMipConstraintFlag ) return false; + if (op1.m_noLfnstConstraintFlag != op2.m_noLfnstConstraintFlag ) return false; + if (op1.m_noMmvdConstraintFlag != op2.m_noMmvdConstraintFlag ) return false; + if (op1.m_noSmvdConstraintFlag != op2.m_noSmvdConstraintFlag ) return false; + if (op1.m_noProfConstraintFlag != op2.m_noProfConstraintFlag ) return false; + if (op1.m_noPaletteConstraintFlag != op2.m_noPaletteConstraintFlag ) return false; + if (op1.m_noActConstraintFlag != op2.m_noActConstraintFlag ) return false; + if (op1.m_noLmcsConstraintFlag != op2.m_noLmcsConstraintFlag ) return false; +#endif + if( op1.m_noQtbttDualTreeIntraConstraintFlag != op2.m_noQtbttDualTreeIntraConstraintFlag ) return false; if( op1.m_noPartitionConstraintsOverrideConstraintFlag != op2.m_noPartitionConstraintsOverrideConstraintFlag ) return false; if( op1.m_noSaoConstraintFlag != op2.m_noSaoConstraintFlag ) return false; if( op1.m_noAlfConstraintFlag != op2.m_noAlfConstraintFlag ) return false; -#if JVET_Q0795_CCALF if( op1.m_noCCAlfConstraintFlag != op2.m_noCCAlfConstraintFlag ) return false; -#endif if( op1.m_noRefWraparoundConstraintFlag != op2.m_noRefWraparoundConstraintFlag ) return false; if( op1.m_noTemporalMvpConstraintFlag != op2.m_noTemporalMvpConstraintFlag ) return false; if( op1.m_noSbtmvpConstraintFlag != op2.m_noSbtmvpConstraintFlag ) return false; @@ -4245,9 +4067,6 @@ bool operator == (const ConstraintInfo& op1, const ConstraintInfo& o if( op1.m_noIbcConstraintFlag != op2.m_noIbcConstraintFlag ) return false; if( op1.m_noCiipConstraintFlag != op2.m_noCiipConstraintFlag ) return false; if( op1.m_noFPelMmvdConstraintFlag != op2.m_noFPelMmvdConstraintFlag ) return false; -#if !JVET_Q0806 - if( op1.m_noTriangleConstraintFlag != op2.m_noTriangleConstraintFlag ) return false; -#endif if( op1.m_noLadfConstraintFlag != op2.m_noLadfConstraintFlag ) return false; if( op1.m_noTransformSkipConstraintFlag != op2.m_noTransformSkipConstraintFlag ) return false; if( op1.m_noBDPCMConstraintFlag != op2.m_noBDPCMConstraintFlag ) return false; @@ -4299,7 +4118,6 @@ bool operator != (const ProfileTierLevel& op1, const ProfileTierLeve { return !(op1 == op2); } -#endif #if ENABLE_TRACING void xTraceVPSHeader() @@ -4307,17 +4125,10 @@ void xTraceVPSHeader() DTRACE( g_trace_ctx, D_HEADER, "=========== Video Parameter Set ===========\n" ); } -#if !JVET_Q0117_PARAMETER_SETS_CLEANUP -void xTraceDPSHeader() -{ - DTRACE( g_trace_ctx, D_HEADER, "=========== Decoding Parameter Set ===========\n" ); -} -#else void xTraceDCIHeader() { DTRACE( g_trace_ctx, D_HEADER, "=========== Decoding Capability Information ===========\n" ); } -#endif void xTraceSPSHeader() { diff --git a/source/Lib/CommonLib/Slice.h b/source/Lib/CommonLib/Slice.h index 1a2c77057748d37273abbedfaa729b25a2ecd4b3..9f12a3307a9eddae225f2f58000a1ed647adc5dc 100644 --- a/source/Lib/CommonLib/Slice.h +++ b/source/Lib/CommonLib/Slice.h @@ -71,14 +71,12 @@ typedef std::list<Picture*> PicList; // Class definition // ==================================================================================================================== -#if JVET_Q0814_DPB struct DpbParameters { int m_maxDecPicBuffering[MAX_TLAYER] = { 0 }; int m_numReorderPics[MAX_TLAYER] = { 0 }; int m_maxLatencyIncreasePlus1[MAX_TLAYER] = { 0 }; }; -#endif class ReferencePictureList { @@ -173,7 +171,7 @@ public: void setRefMatrixId(uint32_t scalingListId, uint32_t u) { m_refMatrixId[scalingListId] = u; } //!< set reference matrix ID uint32_t getRefMatrixId(uint32_t scalingListId) const { return m_refMatrixId[scalingListId]; } //!< get reference matrix ID - + static const int* getScalingListDefaultAddress(uint32_t scalinListId); //!< get default matrix coefficient void processDefaultMatrix(uint32_t scalinListId); @@ -191,11 +189,9 @@ public: void codeScalingList(int* scalingList, int scalingListDC, int scalinListId, int& bitsCost); void setScalingListPreditorModeFlag(uint32_t scalingListId, bool bIsPred) { m_scalingListPreditorModeFlag[scalingListId] = bIsPred; } bool getScalingListPreditorModeFlag(uint32_t scalingListId) const { return m_scalingListPreditorModeFlag[scalingListId]; } -#if JVET_Q0505_CHROAM_QM_SIGNALING_400 bool getChromaScalingListPresentFlag() const {return m_chromaScalingListPresentFlag;} void setChromaScalingListPresentFlag( bool flag) { m_chromaScalingListPresentFlag = flag;} bool isLumaScalingList( int scalingListId) const; -#endif void checkDcOfMatrix(); bool xParseScalingList(const std::string &fileName); void setDefaultScalingList(); @@ -236,23 +232,21 @@ private: uint32_t m_refMatrixId [30]; //!< RefMatrixID bool m_scalingListPreditorModeFlag [30]; //!< reference list index std::vector<int> m_scalingListCoef [30]; //!< quantization matrix -#if JVET_Q0505_CHROAM_QM_SIGNALING_400 bool m_chromaScalingListPresentFlag; -#endif }; class ConstraintInfo { +#if !JVET_R0090_VUI bool m_progressiveSourceFlag; bool m_interlacedSourceFlag; +#endif bool m_nonPackedConstraintFlag; -#if JVET_Q0114_CONSTRAINT_FLAGS bool m_nonProjectedConstraintFlag; bool m_noResChangeInClvsConstraintFlag; bool m_oneTilePerPicConstraintFlag; bool m_oneSlicePerPicConstraintFlag; bool m_oneSubpicPerPicConstraintFlag; -#endif bool m_frameOnlyConstraintFlag; bool m_intraOnlyConstraintFlag; uint32_t m_maxBitDepthConstraintIdc; @@ -260,13 +254,26 @@ class ConstraintInfo bool m_onePictureOnlyConstraintFlag; bool m_lowerBitRateConstraintFlag; +#if JVET_R0286_GCI_CLEANUP + bool m_singleLayerConstraintFlag; + bool m_allLayersIndependentConstraintFlag; + bool m_noMrlConstraintFlag; + bool m_noIspConstraintFlag; + bool m_noMipConstraintFlag; + bool m_noLfnstConstraintFlag; + bool m_noMmvdConstraintFlag; + bool m_noSmvdConstraintFlag; + bool m_noProfConstraintFlag; + bool m_noPaletteConstraintFlag; + bool m_noActConstraintFlag; + bool m_noLmcsConstraintFlag; +#endif + bool m_noQtbttDualTreeIntraConstraintFlag; bool m_noPartitionConstraintsOverrideConstraintFlag; bool m_noSaoConstraintFlag; bool m_noAlfConstraintFlag; -#if JVET_Q0795_CCALF bool m_noCCAlfConstraintFlag; -#endif bool m_noRefWraparoundConstraintFlag; bool m_noTemporalMvpConstraintFlag; bool m_noSbtmvpConstraintFlag; @@ -281,11 +288,7 @@ class ConstraintInfo bool m_noIbcConstraintFlag; bool m_noCiipConstraintFlag; bool m_noFPelMmvdConstraintFlag; -#if !JVET_Q0806 - bool m_noTriangleConstraintFlag; -#else bool m_noGeoConstraintFlag; -#endif bool m_noLadfConstraintFlag; bool m_noTransformSkipConstraintFlag; bool m_noBDPCMConstraintFlag; @@ -293,9 +296,7 @@ class ConstraintInfo bool m_noQpDeltaConstraintFlag; bool m_noDepQuantConstraintFlag; bool m_noSignDataHidingConstraintFlag; -#if JVET_P0124_MIXED_NALU bool m_noMixedNaluTypesInPicConstraintFlag; -#endif bool m_noTrailConstraintFlag; bool m_noStsaConstraintFlag; bool m_noRaslConstraintFlag; @@ -307,29 +308,45 @@ class ConstraintInfo public: ConstraintInfo() +#if !JVET_R0090_VUI : m_progressiveSourceFlag (false) , m_interlacedSourceFlag (false) , m_nonPackedConstraintFlag (false) -#if JVET_Q0114_CONSTRAINT_FLAGS +#else + : m_nonPackedConstraintFlag (false) +#endif , m_nonProjectedConstraintFlag(false) , m_noResChangeInClvsConstraintFlag(false) , m_oneTilePerPicConstraintFlag(false) , m_oneSlicePerPicConstraintFlag(false) , m_oneSubpicPerPicConstraintFlag(false) -#endif , m_frameOnlyConstraintFlag (false) , m_intraOnlyConstraintFlag (false) , m_maxBitDepthConstraintIdc ( 0) , m_maxChromaFormatConstraintIdc(CHROMA_420) , m_onePictureOnlyConstraintFlag (false) , m_lowerBitRateConstraintFlag (false ) + +#if JVET_R0286_GCI_CLEANUP + , m_singleLayerConstraintFlag(false) + , m_allLayersIndependentConstraintFlag(false) + , m_noMrlConstraintFlag(false) + , m_noIspConstraintFlag(false) + , m_noMipConstraintFlag(false) + , m_noLfnstConstraintFlag(false) + , m_noMmvdConstraintFlag(false) + , m_noSmvdConstraintFlag(false) + , m_noProfConstraintFlag(false) + , m_noPaletteConstraintFlag(false) + , m_noActConstraintFlag(false) + , m_noLmcsConstraintFlag(false) +#endif + , m_noQtbttDualTreeIntraConstraintFlag(false) , m_noPartitionConstraintsOverrideConstraintFlag(false) , m_noSaoConstraintFlag (false) , m_noAlfConstraintFlag (false) -#if JVET_Q0795_CCALF , m_noCCAlfConstraintFlag (false) -#endif , m_noRefWraparoundConstraintFlag(false) , m_noTemporalMvpConstraintFlag(false) , m_noSbtmvpConstraintFlag (false) @@ -344,11 +361,7 @@ public: , m_noIbcConstraintFlag (false) , m_noCiipConstraintFlag (false) , m_noFPelMmvdConstraintFlag (false) -#if !JVET_Q0806 - , m_noTriangleConstraintFlag (false) -#else , m_noGeoConstraintFlag (false) -#endif , m_noLadfConstraintFlag (false) , m_noTransformSkipConstraintFlag(false) , m_noBDPCMConstraintFlag (false) @@ -356,9 +369,7 @@ public: , m_noQpDeltaConstraintFlag (false) , m_noDepQuantConstraintFlag (false) , m_noSignDataHidingConstraintFlag(false) -#if JVET_P0124_MIXED_NALU , m_noMixedNaluTypesInPicConstraintFlag(false) -#endif , m_noTrailConstraintFlag (false) , m_noStsaConstraintFlag (false) , m_noRaslConstraintFlag (false) @@ -369,11 +380,13 @@ public: , m_noApsConstraintFlag (false) {} +#if !JVET_R0090_VUI bool getProgressiveSourceFlag() const { return m_progressiveSourceFlag; } void setProgressiveSourceFlag(bool b) { m_progressiveSourceFlag = b; } bool getInterlacedSourceFlag() const { return m_interlacedSourceFlag; } void setInterlacedSourceFlag(bool b) { m_interlacedSourceFlag = b; } +#endif bool getNonPackedConstraintFlag() const { return m_nonPackedConstraintFlag; } void setNonPackedConstraintFlag(bool b) { m_nonPackedConstraintFlag = b; } @@ -387,7 +400,6 @@ public: ChromaFormat getMaxChromaFormatConstraintIdc() const { return m_maxChromaFormatConstraintIdc; } void setMaxChromaFormatConstraintIdc(ChromaFormat fmt) { m_maxChromaFormatConstraintIdc = fmt; } -#if JVET_Q0114_CONSTRAINT_FLAGS bool getNonProjectedConstraintFlag() const { return m_nonProjectedConstraintFlag; } void setNonProjectedConstraintFlag(bool b) { m_nonProjectedConstraintFlag = b; } @@ -402,7 +414,6 @@ public: bool getOneSubpicPerPicConstraintFlag() const { return m_oneSubpicPerPicConstraintFlag; } void setOneSubpicPerPicConstraintFlag(bool b) { m_oneSubpicPerPicConstraintFlag = b; } -#endif bool getIntraOnlyConstraintFlag() const { return m_intraOnlyConstraintFlag; } void setIntraOnlyConstraintFlag(bool b) { m_intraOnlyConstraintFlag = b; } @@ -413,6 +424,33 @@ public: bool getLowerBitRateConstraintFlag() const { return m_lowerBitRateConstraintFlag; } void setLowerBitRateConstraintFlag(bool b) { m_lowerBitRateConstraintFlag = b; } +#if JVET_R0286_GCI_CLEANUP + bool getSingleLayerConstraintFlag() const { return m_singleLayerConstraintFlag; } + void setSingleLayerConstraintFlag(bool b) { m_singleLayerConstraintFlag = b; } + bool getAllLayersIndependentConstraintFlag() const { return m_allLayersIndependentConstraintFlag; } + void setAllLayersIndependentConstraintFlag(bool b) { m_allLayersIndependentConstraintFlag = b; } + bool getNoMrlConstraintFlag() const { return m_noMrlConstraintFlag; } + void setNoMrlConstraintFlag(bool b) { m_noMrlConstraintFlag = b; } + bool getNoIspConstraintFlag() const { return m_noIspConstraintFlag; } + void setNoIspConstraintFlag(bool b) { m_noIspConstraintFlag = b; } + bool getNoMipConstraintFlag() const { return m_noMipConstraintFlag; } + void setNoMipConstraintFlag(bool b) { m_noMipConstraintFlag = b; } + bool getNoLfnstConstraintFlag() const { return m_noLfnstConstraintFlag; } + void setNoLfnstConstraintFlag(bool b) { m_noLfnstConstraintFlag = b; } + bool getNoMmvdConstraintFlag() const { return m_noMmvdConstraintFlag; } + void setNoMmvdConstraintFlag(bool b) { m_noMmvdConstraintFlag = b; } + bool getNoSmvdConstraintFlag() const { return m_noSmvdConstraintFlag; } + void setNoSmvdConstraintFlag(bool b) { m_noSmvdConstraintFlag = b; } + bool getNoProfConstraintFlag() const { return m_noProfConstraintFlag; } + void setNoProfConstraintFlag(bool b) { m_noProfConstraintFlag = b; } + bool getNoPaletteConstraintFlag() const { return m_noPaletteConstraintFlag; } + void setNoPaletteConstraintFlag(bool b) { m_noPaletteConstraintFlag = b; } + bool getNoActConstraintFlag() const { return m_noActConstraintFlag; } + void setNoActConstraintFlag(bool b) { m_noActConstraintFlag = b; } + bool getNoLmcsConstraintFlag() const { return m_noLmcsConstraintFlag; } + void setNoLmcsConstraintFlag(bool b) { m_noLmcsConstraintFlag = b; } +#endif + bool getNoQtbttDualTreeIntraConstraintFlag() const { return m_noQtbttDualTreeIntraConstraintFlag; } void setNoQtbttDualTreeIntraConstraintFlag(bool bVal) { m_noQtbttDualTreeIntraConstraintFlag = bVal; } bool getNoPartitionConstraintsOverrideConstraintFlag() const { return m_noPartitionConstraintsOverrideConstraintFlag; } @@ -421,10 +459,8 @@ public: void setNoSaoConstraintFlag(bool bVal) { m_noSaoConstraintFlag = bVal; } bool getNoAlfConstraintFlag() const { return m_noAlfConstraintFlag; } void setNoAlfConstraintFlag(bool bVal) { m_noAlfConstraintFlag = bVal; } -#if JVET_Q0795_CCALF bool getNoCCAlfConstraintFlag() const { return m_noCCAlfConstraintFlag; } void setNoCCAlfConstraintFlag(bool val) { m_noCCAlfConstraintFlag = val; } -#endif bool getNoJointCbCrConstraintFlag() const { return m_noJointCbCrConstraintFlag; } void setNoJointCbCrConstraintFlag(bool bVal) { m_noJointCbCrConstraintFlag = bVal; } bool getNoRefWraparoundConstraintFlag() const { return m_noRefWraparoundConstraintFlag; } @@ -455,13 +491,8 @@ public: void setNoCiipConstraintFlag(bool bVal) { m_noCiipConstraintFlag = bVal; } bool getNoFPelMmvdConstraintFlag() const { return m_noFPelMmvdConstraintFlag; } void setNoFPelMmvdConstraintFlag(bool bVal) { m_noFPelMmvdConstraintFlag = bVal; } -#if !JVET_Q0806 - bool getNoTriangleConstraintFlag() const { return m_noTriangleConstraintFlag; } - void setNoTriangleConstraintFlag(bool bVal) { m_noTriangleConstraintFlag = bVal; } -#else bool getNoGeoConstraintFlag() const { return m_noGeoConstraintFlag; } void setNoGeoConstraintFlag(bool bVal) { m_noGeoConstraintFlag = bVal; } -#endif bool getNoLadfConstraintFlag() const { return m_noLadfConstraintFlag; } void setNoLadfConstraintFlag(bool bVal) { m_noLadfConstraintFlag = bVal; } bool getNoTransformSkipConstraintFlag() const { return m_noTransformSkipConstraintFlag; } @@ -474,10 +505,8 @@ public: void setNoDepQuantConstraintFlag(bool bVal) { m_noDepQuantConstraintFlag = bVal; } bool getNoSignDataHidingConstraintFlag() const { return m_noSignDataHidingConstraintFlag; } void setNoSignDataHidingConstraintFlag(bool bVal) { m_noSignDataHidingConstraintFlag = bVal; } -#if JVET_P0124_MIXED_NALU bool getNoMixedNaluTypesInPicConstraintFlag() const { return m_noMixedNaluTypesInPicConstraintFlag; } void setNoMixedNaluTypesInPicConstraintFlag(bool bVal) { m_noMixedNaluTypesInPicConstraintFlag = bVal; } -#endif bool getNoTrailConstraintFlag() const { return m_noTrailConstraintFlag; } void setNoTrailConstraintFlag(bool bVal) { m_noTrailConstraintFlag = bVal; } bool getNoStsaConstraintFlag() const { return m_noStsaConstraintFlag; } @@ -495,10 +524,8 @@ public: bool getNoApsConstraintFlag() const { return m_noApsConstraintFlag; } void setNoApsConstraintFlag(bool bVal) { m_noApsConstraintFlag = bVal; } -#if JVET_Q0117_PARAMETER_SETS_CLEANUP friend bool operator == (const ConstraintInfo& op1, const ConstraintInfo& op2); friend bool operator != (const ConstraintInfo& op1, const ConstraintInfo& op2); -#endif }; class ProfileTierLevel @@ -540,10 +567,8 @@ public: Level::Name getSubLayerLevelIdc(int i) const { return m_subLayerLevelIdc[i]; } void setSubLayerLevelIdc(int i, Level::Name x) { m_subLayerLevelIdc[i] = x; } -#if JVET_Q0117_PARAMETER_SETS_CLEANUP friend bool operator == (const ProfileTierLevel& op1, const ProfileTierLevel& op2); friend bool operator != (const ProfileTierLevel& op1, const ProfileTierLevel& op2); -#endif }; @@ -702,7 +727,7 @@ public: uint32_t getCtuAddrInSlice( int idx ) const { CHECK(idx >= m_ctuAddrInSlice.size(), "CTU index exceeds number of CTUs in slice."); return m_ctuAddrInSlice[idx]; } void pushToCtuAddrInSlice( uint32_t u ) { m_ctuAddrInSlice.push_back(u); m_numCtuInSlice++;} - void initSliceMap() + void initSliceMap() { m_sliceID = 0; m_numTilesInSlice = 0; @@ -710,12 +735,12 @@ public: m_ctuAddrInSlice.clear(); } - void addCtusToSlice( uint32_t startX, uint32_t stopX, uint32_t startY, uint32_t stopY, uint32_t picWidthInCtbsY ) + void addCtusToSlice( uint32_t startX, uint32_t stopX, uint32_t startY, uint32_t stopY, uint32_t picWidthInCtbsY ) { CHECK( startX >= stopX || startY >= stopY, "Invalid slice definition"); - for( uint32_t ctbY = startY; ctbY < stopY; ctbY++ ) + for( uint32_t ctbY = startY; ctbY < stopY; ctbY++ ) { - for( uint32_t ctbX = startX; ctbX < stopX; ctbX++ ) + for( uint32_t ctbX = startX; ctbX < stopX; ctbX++ ) { m_ctuAddrInSlice.push_back( ctbY * picWidthInCtbsY + ctbX ); m_numCtuInSlice++; @@ -732,11 +757,11 @@ private: uint32_t m_sliceHeightInTiles; //!< slice height in units of tiles uint32_t m_numSlicesInTile; //!< number of slices in current tile for the special case of multiple slices inside a single tile uint32_t m_sliceHeightInCtu; //!< slice height in units of CTUs for the special case of multiple slices inside a single tile - + public: RectSlice(); virtual ~RectSlice(); - + void setSliceWidthInTiles( uint32_t u ) { m_sliceWidthInTiles = u; } uint32_t getSliceWidthInTiles( ) const { return m_sliceWidthInTiles; } void setSliceHeightInTiles( uint32_t u ) { m_sliceHeightInTiles = u; } @@ -750,7 +775,6 @@ public: }; -#if JVET_O1143_SUBPIC_BOUNDARY class SubPic { private: @@ -765,7 +789,7 @@ private: uint32_t m_subPicHeightInLumaSample; //!< the height of subpicture in units of luma sample uint32_t m_firstCtuInSubPic; //!< the raster scan index of the first CTU in a subpicture uint32_t m_lastCtuInSubPic; //!< the raster scan index of the last CTU in a subpicture - uint32_t m_subPicLeft; //!< the position of left boundary + uint32_t m_subPicLeft; //!< the position of left boundary uint32_t m_subPicRight; //!< the position of right boundary uint32_t m_subPicTop; //!< the position of top boundary uint32_t m_subPicBottom; //!< the position of bottom boundary @@ -773,10 +797,8 @@ private: bool m_treatedAsPicFlag; //!< whether the subpicture is treated as a picture in the decoding process excluding in-loop filtering operations bool m_loopFilterAcrossSubPicEnabledFlag; //!< whether in-loop filtering operations may be performed across the boundaries of the subpicture -#if JVET_Q0044_SLICE_IDX_WITH_SUBPICS uint32_t m_numSlicesInSubPic; //!< Number of slices contained in this subpicture -#endif - + public: SubPic(); virtual ~SubPic(); @@ -818,7 +840,7 @@ public: void addCTUsToSubPic(std::vector<uint32_t> ctuAddrInSlice) { for (auto ctu:ctuAddrInSlice) - m_ctuAddrInSubPic.push_back(ctu); + m_ctuAddrInSubPic.push_back(ctu); } void addAllCtusInPicToSubPic(uint32_t startX, uint32_t stopX, uint32_t startY, uint32_t stopY, uint32_t picWidthInCtbsY) { @@ -842,7 +864,6 @@ public: bool isFirstCTUinSubPic(uint32_t ctuAddr) { return ctuAddr == m_firstCtuInSubPic; } bool isLastCTUinSubPic(uint32_t ctuAddr) { return ctuAddr == m_lastCtuInSubPic; } -#if JVET_Q0044_SLICE_IDX_WITH_SUBPICS void setNumSlicesInSubPic( uint32_t val ) { m_numSlicesInSubPic = val; } uint32_t getNumSlicesInSubPic() const { return m_numSlicesInSubPic; } bool containsCtu(const Position& pos) const @@ -850,8 +871,6 @@ public: return pos.x >= m_subPicCtuTopLeftX && pos.x < m_subPicCtuTopLeftX + m_subPicWidth && pos.y >= m_subPicCtuTopLeftY && pos.y < m_subPicCtuTopLeftY + m_subPicHeight; } -#endif -#if JVET_Q0397_SUB_PIC_EXTRACT bool containsCtu(int ctuAddr) const { for (auto & addr : m_ctuAddrInSubPic) @@ -863,11 +882,8 @@ public: } return false; } - #endif }; -#endif -#if JVET_Q0117_PARAMETER_SETS_CLEANUP // Rename DPS to DCI (decoding_capability_information) class DCI { private: @@ -894,33 +910,6 @@ public: return true; } }; -#else -class DPS -{ -private: - int m_decodingParameterSetId; - int m_maxSubLayersMinus1; - std::vector<ProfileTierLevel> m_profileTierLevel; - -public: - DPS() - : m_decodingParameterSetId(-1) - , m_maxSubLayersMinus1 (0) - {}; - - virtual ~DPS() {}; - - int getDecodingParameterSetId() const { return m_decodingParameterSetId; } - void setDecodingParameterSetId(int val) { m_decodingParameterSetId = val; } - int getMaxSubLayersMinus1() const { return m_maxSubLayersMinus1; } - void setMaxSubLayersMinus1(int val) { m_maxSubLayersMinus1 = val; } - - size_t getNumPTLs() const { return m_profileTierLevel.size(); } - void setProfileTierLevel(const std::vector<ProfileTierLevel> &val) { m_profileTierLevel = val; } - const ProfileTierLevel& getProfileTierLevel(int idx) const { return m_profileTierLevel[idx]; } -}; - -#endif class VPS @@ -942,34 +931,31 @@ private: uint32_t m_directRefLayerIdx[MAX_VPS_LAYERS][MAX_VPS_LAYERS]; uint32_t m_generalLayerIdx[MAX_VPS_LAYERS]; -#if JVET_Q0786_PTL_only uint32_t m_vpsNumPtls; bool m_ptPresentFlag[MAX_NUM_OLSS]; uint32_t m_ptlMaxTemporalId[MAX_NUM_OLSS]; std::vector<ProfileTierLevel> m_vpsProfileTierLevel; uint32_t m_olsPtlIdx[MAX_NUM_OLSS]; -#endif - // stores index ( ilrp_idx within 0 .. NumDirectRefLayers ) of the dependent reference layers + // stores index ( ilrp_idx within 0 .. NumDirectRefLayers ) of the dependent reference layers uint32_t m_interLayerRefIdx[MAX_VPS_LAYERS][MAX_VPS_LAYERS]; bool m_vpsExtensionFlag; -#if JVET_P0118_HRD_ASPECTS bool m_vpsGeneralHrdParamsPresentFlag; bool m_vpsSublayerCpbParamsPresentFlag; uint32_t m_numOlsHrdParamsMinus1; uint32_t m_hrdMaxTid[MAX_NUM_OLSS]; uint32_t m_olsHrdIdx[MAX_NUM_OLSS]; GeneralHrdParams m_generalHrdParams; -#endif -#if JVET_Q0814_DPB std::vector<Size> m_olsDpbPicSize; std::vector<int> m_olsDpbParamsIdx; std::vector<std::vector<int>> m_outputLayerIdInOls; public: -#if JVET_P0118_HRD_ASPECTS std::vector<std::vector<OlsHrdParams>> m_olsHrdParams; -#endif int m_totalNumOLSs; +#if JVET_R0191_ASPECT3 + int m_numMultiLayeredOlss; + uint32_t m_multiLayerOlsIdx[MAX_NUM_OLSS]; +#endif int m_numDpbParams; std::vector<DpbParameters> m_dpbParameters; bool m_sublayerDpbParamsPresentFlag; @@ -980,10 +966,6 @@ public: std::vector<int> m_numOutputLayersInOls; std::vector<int> m_numLayersInOls; std::vector<std::vector<int>> m_layerIdInOls; -#elif JVET_P0288_PIC_OUTPUT -public: - int m_targetOlsIdx; -#endif public: VPS(); @@ -1034,7 +1016,6 @@ public: bool getOlsOutputLayerFlag(uint32_t ols, uint32_t layer) const { return m_vpsOlsOutputLayerFlag[ols][layer]; } void setOlsOutputLayerFlag(uint32_t ols, uint32_t layer, bool t) { m_vpsOlsOutputLayerFlag[ols][layer] = t; } -#if JVET_Q0786_PTL_only uint32_t getNumPtls() const { return m_vpsNumPtls; } void setNumPtls(uint32_t val) { m_vpsNumPtls = val; } @@ -1049,11 +1030,9 @@ public: uint32_t getOlsPtlIdx(int idx) const { return m_olsPtlIdx[idx]; } void setOlsPtlIdx(int idx, uint32_t val) { m_olsPtlIdx[idx] = val; } -#endif bool getVPSExtensionFlag() const { return m_vpsExtensionFlag; } void setVPSExtensionFlag(bool t) { m_vpsExtensionFlag = t; } -#if JVET_P0118_HRD_ASPECTS bool getVPSGeneralHrdParamsPresentFlag() const { return m_vpsGeneralHrdParamsPresentFlag; } void setVPSGeneralHrdParamsPresentFlag(bool t) { m_vpsGeneralHrdParamsPresentFlag = t; } bool getVPSSublayerCpbParamsPresentFlag() const { return m_vpsSublayerCpbParamsPresentFlag; } @@ -1064,23 +1043,22 @@ public: uint32_t getHrdMaxTid(int olsIdx) const { return m_hrdMaxTid[olsIdx]; } void setHrdMaxTid(int olsIdx, uint32_t val) { m_hrdMaxTid[olsIdx] = val; } uint32_t getOlsHrdIdx(int olsIdx) const { return m_olsHrdIdx[olsIdx]; } - void setOlsHrdIdx(int olsIdx, uint32_t val) { m_olsHrdIdx[olsIdx] = val; } + void setOlsHrdIdx(int olsIdx, uint32_t val) { m_olsHrdIdx[olsIdx] = val; } OlsHrdParams* getOlsHrdParameters(int olsIdx) { return &m_olsHrdParams[olsIdx][0]; } const OlsHrdParams* getOlsHrdParameters(int olsIdx) const { return &m_olsHrdParams[olsIdx][0]; } GeneralHrdParams* getGeneralHrdParameters() { return &m_generalHrdParams; } const GeneralHrdParams* getGeneralHrdParameters() const { return &m_generalHrdParams; } -#endif -#if JVET_P0288_PIC_OUTPUT int getTargetOlsIdx() { return m_targetOlsIdx; } void setTargetOlsIdx(uint32_t t) { m_targetOlsIdx = t; } -#endif -#if JVET_Q0814_DPB int getMaxDecPicBuffering( int temporalId ) const { return m_dpbParameters[m_olsDpbParamsIdx[m_targetOlsIdx]].m_maxDecPicBuffering[temporalId]; } int getNumReorderPics( int temporalId ) const { return m_dpbParameters[m_olsDpbParamsIdx[m_targetOlsIdx]].m_numReorderPics[temporalId]; } int getTotalNumOLSs() const { return m_totalNumOLSs; } +#if JVET_R0191_ASPECT3 + int getNumMultiLayeredOlss() const { return m_numMultiLayeredOlss; } +#endif Size getOlsDpbPicSize( int olsIdx ) const { return m_olsDpbPicSize[olsIdx]; } void setOlsDpbPicSize( int olsIdx, Size size ) { m_olsDpbPicSize[olsIdx] = size; } void setOlsDpbPicWidth( int olsIdx, int width ) { m_olsDpbPicSize[olsIdx].width = width; } @@ -1088,21 +1066,16 @@ public: int getOlsDpbParamsIdx( int olsIdx ) const { return m_olsDpbParamsIdx[olsIdx]; } void setOlsDpbParamsIdx( int olsIdx, int paramIdx ) { m_olsDpbParamsIdx[olsIdx] = paramIdx; } - + void deriveOutputLayerSets(); void deriveTargetOutputLayerSet( int targetOlsIdx ); -#endif -#if JVET_P0125_SEI_CONSTRAINTS void setNumLayersInOls(int olsIdx, int numLayers) { m_numLayersInOls[olsIdx] = numLayers; } int getNumLayersInOls(int olsIdx) const { return m_numLayersInOls[olsIdx]; } void setLayerIdInOls (int olsIdx, int layerIdx, int layerId) { m_layerIdInOls[olsIdx][layerIdx] = layerId; } uint32_t getLayerIdInOls (int olsIdx, int layerIdx) const { return m_layerIdInOls[olsIdx][layerIdx] ; } -#endif -#if JVET_P0118_OLS_EXTRACTION std::vector<int> getLayerIdsInOls(int targetOlsIdx) { return m_layerIdInOls[targetOlsIdx]; } -#endif }; class Window @@ -1124,21 +1097,21 @@ public: bool getWindowEnabledFlag() const { return m_enabledFlag; } int getWindowLeftOffset() const { return m_enabledFlag ? m_winLeftOffset : 0; } - void setWindowLeftOffset(int val) { m_winLeftOffset = val; m_enabledFlag = true; } + void setWindowLeftOffset(int val) { m_winLeftOffset = val; m_enabledFlag |= (val!=0); } int getWindowRightOffset() const { return m_enabledFlag ? m_winRightOffset : 0; } - void setWindowRightOffset(int val) { m_winRightOffset = val; m_enabledFlag = true; } + void setWindowRightOffset(int val) { m_winRightOffset = val; m_enabledFlag |= (val!=0); } int getWindowTopOffset() const { return m_enabledFlag ? m_winTopOffset : 0; } - void setWindowTopOffset(int val) { m_winTopOffset = val; m_enabledFlag = true; } + void setWindowTopOffset(int val) { m_winTopOffset = val; m_enabledFlag |= (val!=0); } int getWindowBottomOffset() const { return m_enabledFlag ? m_winBottomOffset: 0; } - void setWindowBottomOffset(int val) { m_winBottomOffset = val; m_enabledFlag = true; } + void setWindowBottomOffset(int val) { m_winBottomOffset = val; m_enabledFlag |= (val!=0); } - void setWindow(int offsetLeft, int offsetLRight, int offsetLTop, int offsetLBottom) + void setWindow(int offsetLeft, int offsetRight, int offsetTop, int offsetBottom) { - m_enabledFlag = true; + m_enabledFlag = (offsetLeft || offsetRight || offsetTop || offsetBottom); m_winLeftOffset = offsetLeft; - m_winRightOffset = offsetLRight; - m_winTopOffset = offsetLTop; - m_winBottomOffset = offsetLBottom; + m_winRightOffset = offsetRight; + m_winTopOffset = offsetTop; + m_winBottomOffset = offsetBottom; } }; @@ -1155,8 +1128,9 @@ private: int m_colourPrimaries; int m_transferCharacteristics; int m_matrixCoefficients; -#if !JVET_Q0042_VUI - bool m_fieldSeqFlag; +#if JVET_R0090_VUI + bool m_progressiveSourceFlag; + bool m_interlacedSourceFlag; #endif bool m_chromaLocInfoPresentFlag; int m_chromaSampleLocTypeTopField; @@ -1177,8 +1151,9 @@ public: , m_colourPrimaries (2) , m_transferCharacteristics (2) , m_matrixCoefficients (2) -#if !JVET_Q0042_VUI - , m_fieldSeqFlag (false) +#if JVET_R0090_VUI + , m_progressiveSourceFlag (false) + , m_interlacedSourceFlag (false) #endif , m_chromaLocInfoPresentFlag (false) , m_chromaSampleLocTypeTopField (0) @@ -1217,9 +1192,12 @@ public: int getMatrixCoefficients() const { return m_matrixCoefficients; } void setMatrixCoefficients(int i) { m_matrixCoefficients = i; } -#if !JVET_Q0042_VUI - bool getFieldSeqFlag() const { return m_fieldSeqFlag; } - void setFieldSeqFlag(bool i) { m_fieldSeqFlag = i; } +#if JVET_R0090_VUI + bool getProgressiveSourceFlag() const { return m_progressiveSourceFlag; } + void setProgressiveSourceFlag(bool b) { m_progressiveSourceFlag = b; } + + bool getInterlacedSourceFlag() const { return m_interlacedSourceFlag; } + void setInterlacedSourceFlag(bool b) { m_interlacedSourceFlag = b; } #endif bool getChromaLocInfoPresentFlag() const { return m_chromaLocInfoPresentFlag; } @@ -1306,9 +1284,6 @@ class SPS { private: int m_SPSId; -#if !JVET_Q0117_PARAMETER_SETS_CLEANUP - int m_decodingParameterSetId; -#endif int m_VPSId; bool m_affineAmvrEnabledFlag; @@ -1321,43 +1296,30 @@ private: uint32_t m_uiMaxTLayers; // maximum number of temporal layers -#if JVET_P0117_PTL_SCALABILITY bool m_ptlDpbHrdParamsPresentFlag; bool m_SubLayerDpbParamsFlag; -#endif // Structure uint32_t m_maxWidthInLumaSamples; uint32_t m_maxHeightInLumaSamples; -#if JVET_Q0260_CONFORMANCE_WINDOW_IN_SPS Window m_conformanceWindow; -#endif -#if JVET_Q0119_CLEANUPS bool m_subPicInfoPresentFlag; // indicates the presence of sub-picture info -#else - bool m_subPicPresentFlag; // indicates the presence of sub-pictures -#endif - uint8_t m_numSubPics; //!< number of sub-pictures used - uint32_t m_subPicCtuTopLeftX[MAX_NUM_SUB_PICS]; - uint32_t m_subPicCtuTopLeftY[MAX_NUM_SUB_PICS]; - uint32_t m_SubPicWidth[MAX_NUM_SUB_PICS]; - uint32_t m_SubPicHeight[MAX_NUM_SUB_PICS]; - bool m_subPicTreatedAsPicFlag[MAX_NUM_SUB_PICS]; - bool m_loopFilterAcrossSubpicEnabledFlag[MAX_NUM_SUB_PICS]; -#if JVET_Q0119_CLEANUPS + uint32_t m_numSubPics; //!< number of sub-pictures used +#if JVET_R0156_ASPECT4_SPS_CLEANUP + bool m_independentSubPicsFlag; +#endif + std::vector<uint32_t> m_subPicCtuTopLeftX; + std::vector<uint32_t> m_subPicCtuTopLeftY; + std::vector<uint32_t> m_subPicWidth; + std::vector<uint32_t> m_subPicHeight; + std::vector<bool> m_subPicTreatedAsPicFlag; + std::vector<bool> m_loopFilterAcrossSubpicEnabledFlag; bool m_subPicIdMappingExplicitlySignalledFlag; bool m_subPicIdMappingInSpsFlag; -#else - bool m_subPicIdPresentFlag; //!< indicates the presence of sub-picture IDs - bool m_subPicIdSignallingPresentFlag; //!< indicates the presence of sub-picture ID signalling in the SPS -#endif uint32_t m_subPicIdLen; //!< sub-picture ID length in bits - uint8_t m_subPicId[MAX_NUM_SUB_PICS]; //!< sub-picture ID for each sub-picture in the sequence + std::vector<uint16_t> m_subPicId; //!< sub-picture ID for each sub-picture in the sequence int m_log2MinCodingBlockSize; -#if !JVET_Q0468_Q0469_MIN_LUMA_CB_AND_MIN_QT_FIX - int m_log2DiffMaxMinCodingBlockSize; -#endif unsigned m_CTUSize; unsigned m_partitionOverrideEnalbed; // enable partition constraints override function unsigned m_minQT[3]; // 0: I slice luma; 1: P/B slice; 2: I slice chroma @@ -1368,9 +1330,6 @@ private: unsigned m_dualITree; uint32_t m_uiMaxCUWidth; uint32_t m_uiMaxCUHeight; -#if !JVET_Q0468_Q0469_MIN_LUMA_CB_AND_MIN_QT_FIX - uint32_t m_uiMaxCodingDepth; ///< Total CU depth, relative to the smallest possible transform block size. -#endif RPLList m_RPLList0; RPLList m_RPLList1; @@ -1387,23 +1346,23 @@ private: // Tool list bool m_transformSkipEnabledFlag; -#if JVET_Q0183_SPS_TRANSFORM_SKIP_MODE_CONTROL int m_log2MaxTransformSkipBlockSize; -#endif -#if JVET_Q0089_SLICE_LOSSLESS_CODING_CHROMA_BDPCM bool m_BDPCMEnabledFlag; -#else - int m_BDPCMEnabled; -#endif bool m_JointCbCrEnabledFlag; // Parameter BitDepths m_bitDepths; -#if JVET_Q0151_Q0205_ENTRYPOINTS bool m_entropyCodingSyncEnabledFlag; //!< Flag for enabling WPP +#if JVET_R0165_OPTIONAL_ENTRY_POINT + bool m_entryPointPresentFlag; //!< Flag for indicating the presence of entry points +#else bool m_entropyCodingSyncEntryPointPresentFlag; //!< Flag for indicating the presence of WPP entry points - #endif +#endif int m_qpBDOffset[MAX_NUM_CHANNEL_TYPE]; +#if JVET_R0045_TS_MIN_QP_CLEANUP + int m_internalMinusInputBitDepth[MAX_NUM_CHANNEL_TYPE]; // max(0, internal bitdepth - input bitdepth); } +#else int m_minQpMinus4[MAX_NUM_CHANNEL_TYPE]; // QP_internal - QP_input; +#endif bool m_sbtmvpEnabledFlag; bool m_bdofEnabledFlag; @@ -1412,16 +1371,12 @@ private: bool m_DmvrControlPresentFlag; bool m_ProfControlPresentFlag; uint32_t m_uiBitsForPOC; -#if JVET_P0116_POC_MSB bool m_pocMsbFlag; uint32_t m_pocMsbLen; -#endif -#if JVET_Q0400_EXTRA_BITS int m_numExtraPHBitsBytes; int m_numExtraSHBitsBytes; std::vector<bool> m_extraPHBitPresentFlag; std::vector<bool> m_extraSHBitPresentFlag; -#endif uint32_t m_numLongTermRefPicSPS; uint32_t m_ltRefPicPocLsbSps[MAX_NUM_LONG_TERM_REF_PICS]; bool m_usedByCurrPicLtSPSFlag[MAX_NUM_LONG_TERM_REF_PICS]; @@ -1434,12 +1389,10 @@ private: bool m_bTemporalIdNestingFlag; // temporal_id_nesting_flag bool m_scalingListEnabledFlag; -#if JVET_Q0246_VIRTUAL_BOUNDARY_ENABLE_FLAG + bool m_depQuantEnabledFlag; //!< dependent quantization enabled flag + bool m_signDataHidingEnabledFlag; //!< sign data hiding enabled flag bool m_virtualBoundariesEnabledFlag; //!< Enable virtual boundaries tool bool m_virtualBoundariesPresentFlag; //!< disable loop filtering across virtual boundaries -#else - bool m_loopFilterAcrossVirtualBoundariesDisabledFlag; //!< disable loop filtering across virtual boundaries -#endif unsigned m_numVerVirtualBoundaries; //!< number of vertical virtual boundaries unsigned m_numHorVirtualBoundaries; //!< number of horizontal virtual boundaries unsigned m_virtualBoundariesPosX[3]; //!< horizontal position of each vertical virtual boundary @@ -1448,24 +1401,11 @@ private: uint32_t m_uiMaxLatencyIncreasePlus1[MAX_TLAYER]; -#if !JVET_P0118_HRD_ASPECTS - TimingInfo m_timingInfo; -#endif -#if JVET_P0118_HRD_ASPECTS bool m_generalHrdParametersPresentFlag; -#else - bool m_hrdParametersPresentFlag; -#endif -#if JVET_P0118_HRD_ASPECTS GeneralHrdParams m_generalHrdParams; OlsHrdParams m_olsHrdParams[MAX_TLAYER]; -#else - HRDParameters m_hrdParameters; -#endif -#if JVET_Q0042_VUI bool m_fieldSeqFlag; -#endif bool m_vuiParametersPresentFlag; VUI m_vuiParameters; @@ -1476,9 +1416,7 @@ private: ProfileTierLevel m_profileTierLevel; bool m_alfEnabledFlag; -#if JVET_Q0795_CCALF bool m_ccalfEnabledFlag; -#endif bool m_wrapAroundEnabledFlag; unsigned m_wrapAroundOffset; unsigned m_IBCFlag; @@ -1500,11 +1438,7 @@ private: bool m_PROF; bool m_bcw; // bool m_ciip; -#if !JVET_Q0806 - bool m_Triangle; -#else bool m_Geo; -#endif #if LUMA_ADAPTIVE_DEBLOCKING_FILTER_QP_OFFSET bool m_LadfEnabled; int m_LadfNumIntervals; @@ -1520,18 +1454,16 @@ private: bool m_rprEnabledFlag; bool m_interLayerPresentFlag; -#if JVET_Q0297_MER uint32_t m_log2ParallelMergeLevelMinus2; -#endif -#if JVET_Q0179_SCALING_WINDOW_SIZE_CONSTRAINT bool m_ppsValidFlag[64]; Size m_scalingWindowSizeInPPS[64]; -#endif -#if JVET_Q0798_SPS_NUMBER_MERGE_CANDIDATE uint32_t m_maxNumMergeCand; uint32_t m_maxNumAffineMergeCand; uint32_t m_maxNumIBCMergeCand; uint32_t m_maxNumGeoCand; +#if JVET_R0380_SCALING_MATRIX_DISABLE_YCC_OR_RGB + bool m_scalingMatrixAlternativeColourSpaceDisabledFlag; + bool m_scalingMatrixDesignatedColourSpaceFlag; #endif public: @@ -1540,10 +1472,6 @@ public: int getSPSId() const { return m_SPSId; } void setSPSId(int i) { m_SPSId = i; } -#if !JVET_Q0117_PARAMETER_SETS_CLEANUP - void setDecodingParameterSetId(int val) { m_decodingParameterSetId = val; } - int getDecodingParameterSetId() const { return m_decodingParameterSetId; } -#endif int getVPSId() const { return m_VPSId; } void setVPSId(int i) { m_VPSId = i; } @@ -1560,49 +1488,58 @@ public: uint32_t getMaxPicWidthInLumaSamples() const { return m_maxWidthInLumaSamples; } void setMaxPicHeightInLumaSamples( uint32_t u ) { m_maxHeightInLumaSamples = u; } uint32_t getMaxPicHeightInLumaSamples() const { return m_maxHeightInLumaSamples; } -#if JVET_Q0260_CONFORMANCE_WINDOW_IN_SPS Window& getConformanceWindow() { return m_conformanceWindow; } const Window& getConformanceWindow() const { return m_conformanceWindow; } void setConformanceWindow( Window& conformanceWindow ) { m_conformanceWindow = conformanceWindow; } -#endif -#if JVET_Q0119_CLEANUPS - void setSubPicInfoPresentFlag(bool b) { m_subPicInfoPresentFlag = b; } - bool getSubPicInfoPresentFlag() const { return m_subPicInfoPresentFlag; } -#else - void setSubPicPresentFlag(bool b) { m_subPicPresentFlag = b; } - bool getSubPicPresentFlag() const { return m_subPicPresentFlag; } -#endif + void setSubPicInfoPresentFlag(bool b) { m_subPicInfoPresentFlag = b; } + bool getSubPicInfoPresentFlag() const { return m_subPicInfoPresentFlag; } + + void setNumSubPics( uint32_t u ) { CHECK( u >= MAX_NUM_SUB_PICS, "Maximum number of subpictures exceeded" ); + m_numSubPics = u; + m_subPicCtuTopLeftX.resize(m_numSubPics); + m_subPicCtuTopLeftY.resize(m_numSubPics); + m_subPicWidth.resize(m_numSubPics); + m_subPicHeight.resize(m_numSubPics); + m_subPicTreatedAsPicFlag.resize(m_numSubPics); + m_loopFilterAcrossSubpicEnabledFlag.resize(m_numSubPics); + m_subPicId.resize(m_numSubPics); + } + #if JVET_R0156_ASPECT4_SPS_CLEANUP + void setIndependentSubPicsFlag(bool b) { m_independentSubPicsFlag = b; } + bool getIndependentSubPicsFlag() const { return m_independentSubPicsFlag; } +#endif + uint32_t getNumSubPics( ) const { return m_numSubPics; } + void setSubPicCtuTopLeftX( int i, uint32_t u ) { m_subPicCtuTopLeftX[i] = u; } + uint32_t getSubPicCtuTopLeftX( int i ) const { return m_subPicCtuTopLeftX[i]; } + void setSubPicCtuTopLeftY( int i, uint32_t u ) { m_subPicCtuTopLeftY[i] = u; } + uint32_t getSubPicCtuTopLeftY( int i ) const { return m_subPicCtuTopLeftY[i]; } + void setSubPicWidth( int i, uint32_t u ) { m_subPicWidth[i] = u; } + uint32_t getSubPicWidth( int i ) const { return m_subPicWidth[i]; } + void setSubPicHeight( int i, uint32_t u ) { m_subPicHeight[i] = u; } + uint32_t getSubPicHeight( int i ) const { return m_subPicHeight[i]; } + void setSubPicTreatedAsPicFlag( int i, bool u ) { m_subPicTreatedAsPicFlag[i] = u; } + bool getSubPicTreatedAsPicFlag( int i ) const { return m_subPicTreatedAsPicFlag[i]; } + void setLoopFilterAcrossSubpicEnabledFlag( int i, bool u ) { m_loopFilterAcrossSubpicEnabledFlag[i] = u; } + bool getLoopFilterAcrossSubpicEnabledFlag( int i ) const { return m_loopFilterAcrossSubpicEnabledFlag[i]; } + + void setSubPicCtuTopLeftX (const std::vector<uint32_t> &v) { CHECK(v.size()!=m_numSubPics, "number of vector entries must be equal to numSubPics") ;m_subPicCtuTopLeftX = v; } + void setSubPicCtuTopLeftY (const std::vector<uint32_t> &v) { CHECK(v.size()!=m_numSubPics, "number of vector entries must be equal to numSubPics") ;m_subPicCtuTopLeftY = v; } + void setSubPicWidth (const std::vector<uint32_t> &v) { CHECK(v.size()!=m_numSubPics, "number of vector entries must be equal to numSubPics") ;m_subPicWidth = v; } + void setSubPicHeight (const std::vector<uint32_t> &v) { CHECK(v.size()!=m_numSubPics, "number of vector entries must be equal to numSubPics") ;m_subPicHeight = v; } + void setSubPicTreatedAsPicFlag (const std::vector<bool> &v) { CHECK(v.size()!=m_numSubPics, "number of vector entries must be equal to numSubPics") ;m_subPicTreatedAsPicFlag = v; } + void setLoopFilterAcrossSubpicEnabledFlag (const std::vector<bool> &v) { CHECK(v.size()!=m_numSubPics, "number of vector entries must be equal to numSubPics") ;m_loopFilterAcrossSubpicEnabledFlag = v; } + - void setNumSubPics( uint8_t u ) { m_numSubPics = u; } - uint8_t getNumSubPics( ) const { return m_numSubPics; } - void setSubPicCtuTopLeftX( int i, uint32_t u ) { CHECK( i >= MAX_NUM_SUB_PICS, "Sub-picture index exceeds valid range" ); m_subPicCtuTopLeftX[i] = u; } - uint32_t getSubPicCtuTopLeftX( int i ) const { CHECK( i >= MAX_NUM_SUB_PICS, "Sub-picture index exceeds valid range" ); return m_subPicCtuTopLeftX[i]; } - void setSubPicCtuTopLeftY( int i, uint32_t u ) { CHECK( i >= MAX_NUM_SUB_PICS, "Sub-picture index exceeds valid range" ); m_subPicCtuTopLeftY[i] = u; } - uint32_t getSubPicCtuTopLeftY( int i ) const { CHECK( i >= MAX_NUM_SUB_PICS, "Sub-picture index exceeds valid range" ); return m_subPicCtuTopLeftY[i]; } - void setSubPicWidth( int i, uint32_t u ) { CHECK( i >= MAX_NUM_SUB_PICS, "Sub-picture index exceeds valid range" ); m_SubPicWidth[i] = u; } - uint32_t getSubPicWidth( int i ) const { CHECK( i >= MAX_NUM_SUB_PICS, "Sub-picture index exceeds valid range" ); return m_SubPicWidth[i]; } - void setSubPicHeight( int i, uint32_t u ) { CHECK( i >= MAX_NUM_SUB_PICS, "Sub-picture index exceeds valid range" ); m_SubPicHeight[i] = u; } - uint32_t getSubPicHeight( int i ) const { CHECK( i >= MAX_NUM_SUB_PICS, "Sub-picture index exceeds valid range" ); return m_SubPicHeight[i]; } - void setSubPicTreatedAsPicFlag( int i, bool u ) { CHECK( i >= MAX_NUM_SUB_PICS, "Sub-picture index exceeds valid range" ); m_subPicTreatedAsPicFlag[i] = u; } - bool getSubPicTreatedAsPicFlag( int i ) const { CHECK( i >= MAX_NUM_SUB_PICS, "Sub-picture index exceeds valid range" ); return m_subPicTreatedAsPicFlag[i]; } - void setLoopFilterAcrossSubpicEnabledFlag( int i, bool u ) { CHECK( i >= MAX_NUM_SUB_PICS, "Sub-picture index exceeds valid range" ); m_loopFilterAcrossSubpicEnabledFlag[i] = u; } - bool getLoopFilterAcrossSubpicEnabledFlag( int i ) const { CHECK( i >= MAX_NUM_SUB_PICS, "Sub-picture index exceeds valid range" ); return m_loopFilterAcrossSubpicEnabledFlag[i]; } -#if JVET_Q0119_CLEANUPS void setSubPicIdMappingExplicitlySignalledFlag( bool b ) { m_subPicIdMappingExplicitlySignalledFlag = b; } bool getSubPicIdMappingExplicitlySignalledFlag() const { return m_subPicIdMappingExplicitlySignalledFlag; } void setSubPicIdMappingInSpsFlag( bool b ) { m_subPicIdMappingInSpsFlag = b; } bool getSubPicIdMappingInSpsFlag() const { return m_subPicIdMappingInSpsFlag; } -#else - void setSubPicIdPresentFlag( bool b ) { m_subPicIdPresentFlag = b; } - bool getSubPicIdPresentFlag() const { return m_subPicIdPresentFlag; } - void setSubPicIdSignallingPresentFlag( bool b ) { m_subPicIdSignallingPresentFlag = b; } - bool getSubPicIdSignallingPresentFlag() const { return m_subPicIdSignallingPresentFlag; } -#endif void setSubPicIdLen( uint32_t u ) { m_subPicIdLen = u; } uint32_t getSubPicIdLen() const { return m_subPicIdLen; } - void setSubPicId( int i, uint8_t u ) { CHECK( i >= MAX_NUM_SUB_PICS, "Sub-picture index exceeds valid range" ); m_subPicId[i] = u; } - uint8_t getSubPicId( int i ) const { CHECK( i >= MAX_NUM_SUB_PICS, "Sub-picture index exceeds valid range" ); return m_subPicId[i]; } + void setSubPicId( int i, uint16_t u ) { m_subPicId[i] = u; } + uint16_t getSubPicId( int i ) const { return m_subPicId[i]; } + void setSubPicId(const std::vector<uint16_t> &v) { CHECK(v.size()!=m_numSubPics, "number of vector entries must be equal to numSubPics") ; m_subPicId = v; } uint32_t getNumLongTermRefPicSPS() const { return m_numLongTermRefPicSPS; } void setNumLongTermRefPicSPS(uint32_t val) { m_numLongTermRefPicSPS = val; } @@ -1615,10 +1552,6 @@ public: int getLog2MinCodingBlockSize() const { return m_log2MinCodingBlockSize; } void setLog2MinCodingBlockSize(int val) { m_log2MinCodingBlockSize = val; } -#if !JVET_Q0468_Q0469_MIN_LUMA_CB_AND_MIN_QT_FIX - int getLog2DiffMaxMinCodingBlockSize() const { return m_log2DiffMaxMinCodingBlockSize; } - void setLog2DiffMaxMinCodingBlockSize(int val) { m_log2DiffMaxMinCodingBlockSize = val; } -#endif void setCTUSize(unsigned ctuSize) { m_CTUSize = ctuSize; } unsigned getCTUSize() const { return m_CTUSize; } void setSplitConsOverrideEnabledFlag(bool b) { m_partitionOverrideEnalbed = b; } @@ -1661,32 +1594,18 @@ public: uint32_t getMaxCUWidth() const { return m_uiMaxCUWidth; } void setMaxCUHeight( uint32_t u ) { m_uiMaxCUHeight = u; } uint32_t getMaxCUHeight() const { return m_uiMaxCUHeight; } -#if !JVET_Q0468_Q0469_MIN_LUMA_CB_AND_MIN_QT_FIX - void setMaxCodingDepth( uint32_t u ) { m_uiMaxCodingDepth = u; } - uint32_t getMaxCodingDepth() const { return m_uiMaxCodingDepth; } -#endif bool getTransformSkipEnabledFlag() const { return m_transformSkipEnabledFlag; } void setTransformSkipEnabledFlag( bool b ) { m_transformSkipEnabledFlag = b; } -#if JVET_Q0183_SPS_TRANSFORM_SKIP_MODE_CONTROL uint32_t getLog2MaxTransformSkipBlockSize() const { return m_log2MaxTransformSkipBlockSize; } void setLog2MaxTransformSkipBlockSize(uint32_t u) { m_log2MaxTransformSkipBlockSize = u; } -#endif -#if JVET_Q0089_SLICE_LOSSLESS_CODING_CHROMA_BDPCM bool getBDPCMEnabledFlag() const { return m_BDPCMEnabledFlag; } void setBDPCMEnabledFlag( bool b ) { m_BDPCMEnabledFlag = b; } -#else - int getBDPCMEnabled() const { return m_BDPCMEnabled; } - void setBDPCMEnabled(int val) { m_BDPCMEnabled = val; } -#endif void setBitsForPOC( uint32_t u ) { m_uiBitsForPOC = u; } uint32_t getBitsForPOC() const { return m_uiBitsForPOC; } -#if JVET_P0116_POC_MSB void setPocMsbFlag(bool b) { m_pocMsbFlag = b; } bool getPocMsbFlag() const { return m_pocMsbFlag; } void setPocMsbLen(uint32_t u) { m_pocMsbLen = u; } uint32_t getPocMsbLen() const { return m_pocMsbLen; } -#endif -#if JVET_Q0400_EXTRA_BITS void setNumExtraPHBitsBytes(int i) { m_numExtraPHBitsBytes = i; } int getNumExtraPHBitsBytes() const { return m_numExtraPHBitsBytes; } void setNumExtraSHBitsBytes(int i) { m_numExtraSHBitsBytes = i; } @@ -1695,7 +1614,6 @@ public: const std::vector<bool> getExtraPHBitPresentFlags() const { return m_extraPHBitPresentFlag; } void setExtraSHBitPresentFlags(const std::vector<bool> &b) { m_extraSHBitPresentFlag = b; } const std::vector<bool> getExtraSHBitPresentFlags() const { return m_extraSHBitPresentFlag; } -#endif void setNumReorderPics(int i, uint32_t tlayer) { m_numReorderPics[tlayer] = i; } int getNumReorderPics(uint32_t tlayer) const { return m_numReorderPics[tlayer]; } void createRPLList0(int numRPL); @@ -1726,9 +1644,12 @@ public: void setBitDepth(ChannelType type, int u ) { m_bitDepths.recon[type] = u; } const BitDepths& getBitDepths() const { return m_bitDepths; } -#if JVET_Q0151_Q0205_ENTRYPOINTS bool getEntropyCodingSyncEnabledFlag() const { return m_entropyCodingSyncEnabledFlag; } void setEntropyCodingSyncEnabledFlag(bool val) { m_entropyCodingSyncEnabledFlag = val; } +#if JVET_R0165_OPTIONAL_ENTRY_POINT + bool getEntryPointsPresentFlag() const { return m_entryPointPresentFlag; } + void setEntryPointsPresentFlag(bool val) { m_entryPointPresentFlag = val; } +#else bool getEntropyCodingSyncEntryPointsPresentFlag() const { return m_entropyCodingSyncEntryPointPresentFlag; } void setEntropyCodingSyncEntryPointsPresentFlag(bool val) { m_entropyCodingSyncEntryPointPresentFlag = val; } #endif @@ -1737,18 +1658,21 @@ public: int getDifferentialLumaChromaBitDepth() const { return int(m_bitDepths.recon[CHANNEL_TYPE_LUMA]) - int(m_bitDepths.recon[CHANNEL_TYPE_CHROMA]); } int getQpBDOffset(ChannelType type) const { return m_qpBDOffset[type]; } void setQpBDOffset(ChannelType type, int i) { m_qpBDOffset[type] = i; } +#if JVET_R0045_TS_MIN_QP_CLEANUP + int getInternalMinusInputBitDepth(ChannelType type) const { return m_internalMinusInputBitDepth[type]; } + void setInternalMinusInputBitDepth(ChannelType type, int i) { m_internalMinusInputBitDepth[type] = i; } +#else int getMinQpPrimeTsMinus4(ChannelType type) const { return m_minQpMinus4[type]; } void setMinQpPrimeTsMinus4(ChannelType type, int i) { m_minQpMinus4[type] = i; } +#endif void setSAOEnabledFlag(bool bVal) { m_saoEnabledFlag = bVal; } bool getSAOEnabledFlag() const { return m_saoEnabledFlag; } bool getALFEnabledFlag() const { return m_alfEnabledFlag; } void setALFEnabledFlag( bool b ) { m_alfEnabledFlag = b; } -#if JVET_Q0795_CCALF bool getCCALFEnabledFlag() const { return m_ccalfEnabledFlag; } void setCCALFEnabledFlag( bool b ) { m_ccalfEnabledFlag = b; } -#endif void setJointCbCrEnabledFlag(bool bVal) { m_JointCbCrEnabledFlag = bVal; } bool getJointCbCrEnabledFlag() const { return m_JointCbCrEnabledFlag; } @@ -1775,26 +1699,23 @@ void setCCALFEnabledFlag( bool b ) uint32_t getMaxTLayers() const { return m_uiMaxTLayers; } void setMaxTLayers( uint32_t uiMaxTLayers ) { CHECK( uiMaxTLayers > MAX_TLAYER, "Invalid number T-layers" ); m_uiMaxTLayers = uiMaxTLayers; } -#if JVET_P0117_PTL_SCALABILITY bool getPtlDpbHrdParamsPresentFlag() const { return m_ptlDpbHrdParamsPresentFlag; } void setPtlDpbHrdParamsPresentFlag(bool b) { m_ptlDpbHrdParamsPresentFlag = b; } bool getSubLayerDpbParamsFlag() const { return m_SubLayerDpbParamsFlag; } void setSubLayerDpbParamsFlag(bool b) { m_SubLayerDpbParamsFlag = b; } -#endif bool getTemporalIdNestingFlag() const { return m_bTemporalIdNestingFlag; } void setTemporalIdNestingFlag( bool bValue ) { m_bTemporalIdNestingFlag = bValue; } bool getScalingListFlag() const { return m_scalingListEnabledFlag; } void setScalingListFlag( bool b ) { m_scalingListEnabledFlag = b; } -#if JVET_Q0246_VIRTUAL_BOUNDARY_ENABLE_FLAG + void setDepQuantEnabledFlag(bool b) { m_depQuantEnabledFlag = b; } + bool getDepQuantEnabledFlag() const { return m_depQuantEnabledFlag; } + void setSignDataHidingEnabledFlag(bool b) { m_signDataHidingEnabledFlag = b; } + bool getSignDataHidingEnabledFlag() const { return m_signDataHidingEnabledFlag; } void setVirtualBoundariesEnabledFlag( bool b ) { m_virtualBoundariesEnabledFlag = b; } bool getVirtualBoundariesEnabledFlag() const { return m_virtualBoundariesEnabledFlag; } void setVirtualBoundariesPresentFlag( bool b ) { m_virtualBoundariesPresentFlag = b; } bool getVirtualBoundariesPresentFlag() const { return m_virtualBoundariesPresentFlag; } -#else - void setLoopFilterAcrossVirtualBoundariesDisabledFlag(bool b) { m_loopFilterAcrossVirtualBoundariesDisabledFlag = b; } - bool getLoopFilterAcrossVirtualBoundariesDisabledFlag() const { return m_loopFilterAcrossVirtualBoundariesDisabledFlag; } -#endif void setNumVerVirtualBoundaries(unsigned u) { m_numVerVirtualBoundaries = u; } unsigned getNumVerVirtualBoundaries() const { return m_numVerVirtualBoundaries; } void setNumHorVirtualBoundaries(unsigned u) { m_numHorVirtualBoundaries = u; } @@ -1807,7 +1728,6 @@ void setCCALFEnabledFlag( bool b ) void setMaxDecPicBuffering( uint32_t ui, uint32_t tlayer ) { CHECK(tlayer >= MAX_TLAYER, "Invalid T-layer"); m_uiMaxDecPicBuffering[tlayer] = ui; } uint32_t getMaxLatencyIncreasePlus1(uint32_t tlayer) const { return m_uiMaxLatencyIncreasePlus1[tlayer]; } void setMaxLatencyIncreasePlus1( uint32_t ui , uint32_t tlayer) { m_uiMaxLatencyIncreasePlus1[tlayer] = ui; } -#if JVET_Q0798_SPS_NUMBER_MERGE_CANDIDATE uint32_t getMaxNumMergeCand() const { return m_maxNumMergeCand; } void setMaxNumMergeCand(uint32_t u) { m_maxNumMergeCand = u; } uint32_t getMaxNumAffineMergeCand() const { return m_maxNumAffineMergeCand; } @@ -1816,34 +1736,17 @@ void setCCALFEnabledFlag( bool b ) void setMaxNumIBCMergeCand(uint32_t u) { m_maxNumIBCMergeCand = u; } uint32_t getMaxNumGeoCand() const { return m_maxNumGeoCand; } void setMaxNumGeoCand(uint32_t u) { m_maxNumGeoCand = u; } -#endif void setAffineAmvrEnabledFlag( bool val ) { m_affineAmvrEnabledFlag = val; } bool getAffineAmvrEnabledFlag() const { return m_affineAmvrEnabledFlag; } -#if !JVET_P0118_HRD_ASPECTS - TimingInfo* getTimingInfo() { return &m_timingInfo; } - const TimingInfo* getTimingInfo() const { return &m_timingInfo; } -#endif -#if JVET_P0118_HRD_ASPECTS bool getGeneralHrdParametersPresentFlag() const { return m_generalHrdParametersPresentFlag; } void setGeneralHrdParametersPresentFlag(bool b) { m_generalHrdParametersPresentFlag = b; } -#else - bool getHrdParametersPresentFlag() const { return m_hrdParametersPresentFlag; } - void setHrdParametersPresentFlag(bool b) { m_hrdParametersPresentFlag = b; } -#endif -#if JVET_P0118_HRD_ASPECTS OlsHrdParams* getOlsHrdParameters() { return &m_olsHrdParams[0]; } const OlsHrdParams* getOlsHrdParameters() const { return &m_olsHrdParams[0]; } GeneralHrdParams* getGeneralHrdParameters() { return &m_generalHrdParams; } const GeneralHrdParams* getGeneralHrdParameters() const { return &m_generalHrdParams; } -#else - HRDParameters* getHrdParameters() { return &m_hrdParameters; } - const HRDParameters* getHrdParameters() const { return &m_hrdParameters; } -#endif -#if JVET_Q0042_VUI bool getFieldSeqFlag() const { return m_fieldSeqFlag; } void setFieldSeqFlag(bool i) { m_fieldSeqFlag = i; } -#endif bool getVuiParametersPresentFlag() const { return m_vuiParametersPresentFlag; } void setVuiParametersPresentFlag(bool b) { m_vuiParametersPresentFlag = b; } VUI* getVuiParameters() { return &m_vuiParameters; } @@ -1912,13 +1815,8 @@ void setCCALFEnabledFlag( bool b ) void setUseCiip ( bool b ) { m_ciip = b; } bool getUseCiip () const { return m_ciip; } -#if !JVET_Q0806 - void setUseTriangle ( bool b ) { m_Triangle = b; } - bool getUseTriangle () const { return m_Triangle; } -#else void setUseGeo ( bool b ) { m_Geo = b; } bool getUseGeo () const { return m_Geo; } -#endif void setUseMRL ( bool b ) { m_MRL = b; } bool getUseMRL () const { return m_MRL; } void setUseMIP ( bool b ) { m_MIP = b; } @@ -1942,56 +1840,20 @@ void setCCALFEnabledFlag( bool b ) bool getInterLayerPresentFlag() const { return m_interLayerPresentFlag; } void setInterLayerPresentFlag( bool b ) { m_interLayerPresentFlag = b; } -#if JVET_Q0297_MER uint32_t getLog2ParallelMergeLevelMinus2() const { return m_log2ParallelMergeLevelMinus2; } void setLog2ParallelMergeLevelMinus2(uint32_t mrgLevel) { m_log2ParallelMergeLevelMinus2 = mrgLevel; } -#endif -#if JVET_Q0179_SCALING_WINDOW_SIZE_CONSTRAINT void setPPSValidFlag(int i, bool b) { m_ppsValidFlag[i] = b; } bool getPPSValidFlag(int i) { return m_ppsValidFlag[i]; } void setScalingWindowSizeInPPS(int i, int scWidth, int scHeight) { m_scalingWindowSizeInPPS[i].width = scWidth; m_scalingWindowSizeInPPS[i].height = scHeight;} const Size& getScalingWindowSizeInPPS(int i) { return m_scalingWindowSizeInPPS[i]; } +#if JVET_R0380_SCALING_MATRIX_DISABLE_YCC_OR_RGB + void setScalingMatrixForAlternativeColourSpaceDisabledFlag(bool b) { m_scalingMatrixAlternativeColourSpaceDisabledFlag = b; } + bool getScalingMatrixForAlternativeColourSpaceDisabledFlag() const { return m_scalingMatrixAlternativeColourSpaceDisabledFlag; } + void setScalingMatrixDesignatedColourSpaceFlag(bool b) { m_scalingMatrixDesignatedColourSpaceFlag = b; } + bool getScalingMatrixDesignatedColourSpaceFlag() const { return m_scalingMatrixDesignatedColourSpaceFlag; } #endif }; -#if !REMOVE_PPS_REXT -/// Reference Picture Lists class - - -/// PPS RExt class -class PPSRExt // TODO: remove -{ -private: - bool m_crossComponentPredictionEnabledFlag; - -#if !JVET_Q0441_SAO_MOD_12_BIT - uint32_t m_log2SaoOffsetScale[MAX_NUM_CHANNEL_TYPE]; -#endif - -public: - PPSRExt(); - - bool settingsDifferFromDefaults(const bool bTransformSkipEnabledFlag) const - { -#if JVET_Q0441_SAO_MOD_12_BIT - return (getCrossComponentPredictionEnabledFlag() ); -#else - return (getCrossComponentPredictionEnabledFlag() ) - || (getLog2SaoOffsetScale(CHANNEL_TYPE_LUMA) !=0 ) - || (getLog2SaoOffsetScale(CHANNEL_TYPE_CHROMA) !=0 ); -#endif - } - - bool getCrossComponentPredictionEnabledFlag() const { return m_crossComponentPredictionEnabledFlag; } - void setCrossComponentPredictionEnabledFlag(bool value) { m_crossComponentPredictionEnabledFlag = value; } - -#if !JVET_Q0441_SAO_MOD_12_BIT - // Now: getPpsRangeExtension().getLog2SaoOffsetScale and getPpsRangeExtension().setLog2SaoOffsetScale - uint32_t getLog2SaoOffsetScale(ChannelType type) const { return m_log2SaoOffsetScale[type]; } - void setLog2SaoOffsetScale(ChannelType type, uint32_t uiBitShift) { m_log2SaoOffsetScale[type] = uiBitShift; } -#endif -}; -#endif /// PPS class class PPS @@ -2001,9 +1863,7 @@ private: int m_SPSId; // seq_parameter_set_id int m_picInitQPMinus26; bool m_useDQP; -#if JVET_Q0420_PPS_CHROMA_TOOL_FLAG bool m_usePPSChromaTool; -#endif bool m_bSliceChromaQpFlag; // slicelevel_chroma_qp_flag int m_layerId; @@ -2028,14 +1888,10 @@ private: bool m_bUseWeightPred; //!< Use of Weighting Prediction (P_SLICE) bool m_useWeightedBiPred; //!< Use of Weighting Bi-Prediction (B_SLICE) bool m_OutputFlagPresentFlag; //!< Indicates the presence of output_flag in slice header - uint8_t m_numSubPics; //!< number of sub-pictures used - must match SPS -#if JVET_Q0119_CLEANUPS + uint32_t m_numSubPics; //!< number of sub-pictures used - must match SPS bool m_subPicIdMappingInPpsFlag; -#else - bool m_subPicIdSignallingPresentFlag; //!< indicates the presence of sub-picture ID signalling in the PPS -#endif uint32_t m_subPicIdLen; //!< sub-picture ID length in bits - uint8_t m_subPicId[MAX_NUM_SUB_PICS]; //!< sub-picture ID for each sub-picture in the sequence + std::vector<uint16_t> m_subPicId; //!< sub-picture ID for each sub-picture in the sequence bool m_noPicPartitionFlag; //!< no picture partitioning flag - single slice, single tile uint8_t m_log2CtuSize; //!< log2 of the CTU size - required to match corresponding value in SPS uint8_t m_ctuSize; //!< CTU size @@ -2048,42 +1904,20 @@ private: std::vector<uint32_t> m_tileColWidth; //!< tile column widths in units of CTUs std::vector<uint32_t> m_tileRowHeight; //!< tile row heights in units of CTUs std::vector<uint32_t> m_tileColBd; //!< tile column left-boundaries in units of CTUs - std::vector<uint32_t> m_tileRowBd; //!< tile row top-boundaries in units of CTUs + std::vector<uint32_t> m_tileRowBd; //!< tile row top-boundaries in units of CTUs std::vector<uint32_t> m_ctuToTileCol; //!< mapping between CTU horizontal address and tile column index std::vector<uint32_t> m_ctuToTileRow; //!< mapping between CTU vertical address and tile row index - bool m_rectSliceFlag; //!< rectangular slice flag + bool m_rectSliceFlag; //!< rectangular slice flag bool m_singleSlicePerSubPicFlag; //!< single slice per sub-picture flag std::vector<uint32_t> m_ctuToSubPicIdx; //!< mapping between CTU and Sub-picture index uint32_t m_numSlicesInPic; //!< number of rectangular slices in the picture (raster-scan slice specified at slice level) bool m_tileIdxDeltaPresentFlag; //!< tile index delta present flag std::vector<RectSlice> m_rectSlices; //!< list of rectangular slice signalling parameters std::vector<SliceMap> m_sliceMap; //!< list of CTU maps for each slice in the picture -#if JVET_O1143_SUBPIC_BOUNDARY std::vector<SubPic> m_subPics; //!< list of subpictures in the picture -#endif bool m_loopFilterAcrossTilesEnabledFlag; //!< loop filtering applied across tiles flag bool m_loopFilterAcrossSlicesEnabledFlag; //!< loop filtering applied across slices flag -#if !JVET_Q0183_SPS_TRANSFORM_SKIP_MODE_CONTROL - int m_log2MaxTransformSkipBlockSize; -#endif -#if !JVET_Q0151_Q0205_ENTRYPOINTS - bool m_entropyCodingSyncEnabledFlag; //!< Indicates the presence of wavefronts -#endif -#if !JVET_Q0482_REMOVE_CONSTANT_PARAMS - bool m_constantSliceHeaderParamsEnabledFlag; - int m_PPSDepQuantEnabledIdc; - int m_PPSRefPicListSPSIdc0; - int m_PPSRefPicListSPSIdc1; - int m_PPSMvdL1ZeroIdc; - int m_PPSCollocatedFromL0Idc; - uint32_t m_PPSSixMinusMaxNumMergeCandPlus1; -#if !JVET_Q0806 - uint32_t m_PPSMaxNumMergeCandMinusMaxNumTriangleCandPlus1; -#else - uint32_t m_PPSMaxNumMergeCandMinusMaxNumGeoCandPlus1; -#endif -#endif bool m_cabacInitPresentFlag; @@ -2094,35 +1928,26 @@ private: bool m_ppsDeblockingFilterDisabledFlag; int m_deblockingFilterBetaOffsetDiv2; //< beta offset for deblocking filter int m_deblockingFilterTcOffsetDiv2; //< tc offset for deblocking filter -#if JVET_Q0121_DEBLOCKING_CONTROL_PARAMETERS int m_deblockingFilterCbBetaOffsetDiv2; //< beta offset for Cb deblocking filter int m_deblockingFilterCbTcOffsetDiv2; //< tc offset for Cb deblocking filter int m_deblockingFilterCrBetaOffsetDiv2; //< beta offset for Cr deblocking filter int m_deblockingFilterCrTcOffsetDiv2; //< tc offset for Cr deblocking filter -#endif bool m_listsModificationPresentFlag; -#if JVET_Q0819_PH_CHANGES bool m_rplInfoInPhFlag; bool m_dbfInfoInPhFlag; bool m_saoInfoInPhFlag; bool m_alfInfoInPhFlag; bool m_wpInfoInPhFlag; bool m_qpDeltaInfoInPhFlag; -#endif -#if SPS_ID_CHECK bool m_mixedNaluTypesInPicFlag; -#endif uint32_t m_picWidthInLumaSamples; uint32_t m_picHeightInLumaSamples; Window m_conformanceWindow; Window m_scalingWindow; -#if !REMOVE_PPS_REXT - PPSRExt m_ppsRangeExtension; -#endif - + public: PreCalcValues *pcv; @@ -2144,16 +1969,14 @@ public: void setPicInitQPMinus26( int i ) { m_picInitQPMinus26 = i; } bool getUseDQP() const { return m_useDQP; } void setUseDQP( bool b ) { m_useDQP = b; } -#if JVET_Q0420_PPS_CHROMA_TOOL_FLAG bool getPPSChromaToolFlag() const { return m_usePPSChromaTool; } void setPPSChromaToolFlag(bool b) { m_usePPSChromaTool = b; } -#endif bool getSliceChromaQpFlag() const { return m_bSliceChromaQpFlag; } void setSliceChromaQpFlag( bool b ) { m_bSliceChromaQpFlag = b; } bool getJointCbCrQpOffsetPresentFlag() const { return m_chromaJointCbCrQpOffsetPresentFlag; } - void setJointCbCrQpOffsetPresentFlag(bool b) { m_chromaJointCbCrQpOffsetPresentFlag = b; } + void setJointCbCrQpOffsetPresentFlag(bool b) { m_chromaJointCbCrQpOffsetPresentFlag = b; } void setQpOffset(ComponentID compID, int i ) { @@ -2213,31 +2036,28 @@ public: void setOutputFlagPresentFlag( bool b ) { m_OutputFlagPresentFlag = b; } bool getOutputFlagPresentFlag() const { return m_OutputFlagPresentFlag; } - void setNumSubPics( uint8_t u ) { m_numSubPics = u; } - uint8_t getNumSubPics( ) const { return m_numSubPics; } -#if JVET_Q0119_CLEANUPS + void setNumSubPics(uint32_t u ) { CHECK( u >= MAX_NUM_SUB_PICS, "Maximum number of subpictures exceeded" ); + m_numSubPics = u; + m_subPicId.resize(m_numSubPics); + } + uint32_t getNumSubPics( ) const { return m_numSubPics; } void setSubPicIdMappingInPpsFlag( bool b ) { m_subPicIdMappingInPpsFlag = b; } bool getSubPicIdMappingInPpsFlag() const { return m_subPicIdMappingInPpsFlag; } -#else - void setSubPicIdSignallingPresentFlag( bool b ) { m_subPicIdSignallingPresentFlag = b; } - bool getSubPicIdSignallingPresentFlag() const { return m_subPicIdSignallingPresentFlag; } -#endif void setSubPicIdLen( uint32_t u ) { m_subPicIdLen = u; } uint32_t getSubPicIdLen() const { return m_subPicIdLen; } - void setSubPicId( int i, uint8_t u ) { CHECK( i >= MAX_NUM_SUB_PICS, "Sub-picture index exceeds valid range" ); m_subPicId[i] = u; } - uint8_t getSubPicId( int i ) const { CHECK( i >= MAX_NUM_SUB_PICS, "Sub-picture index exceeds valid range" ); return m_subPicId[i]; } -#if JVET_Q0044_SLICE_IDX_WITH_SUBPICS + void setSubPicId( int i, uint16_t u ) { m_subPicId[i] = u; } + void setSubPicId(const std::vector<uint16_t> &v) { CHECK(v.size()!=m_numSubPics, "number of vector entries must be equal to numSubPics") ; m_subPicId = v; } + uint16_t getSubPicId( int i ) const { return m_subPicId[i]; } uint32_t getSubPicIdxFromSubPicId( uint32_t subPicId ) const; -#endif void setNoPicPartitionFlag( bool b ) { m_noPicPartitionFlag = b; } bool getNoPicPartitionFlag( ) const { return m_noPicPartitionFlag; } - void setLog2CtuSize( uint8_t u ) { m_log2CtuSize = u; m_ctuSize = 1 << m_log2CtuSize; - m_picWidthInCtu = (m_picWidthInLumaSamples + m_ctuSize - 1) / m_ctuSize; + void setLog2CtuSize( uint8_t u ) { m_log2CtuSize = u; m_ctuSize = 1 << m_log2CtuSize; + m_picWidthInCtu = (m_picWidthInLumaSamples + m_ctuSize - 1) / m_ctuSize; m_picHeightInCtu = (m_picHeightInLumaSamples + m_ctuSize - 1) / m_ctuSize; } uint8_t getLog2CtuSize( ) const { return m_log2CtuSize; } uint8_t getCtuSize( ) const { return m_ctuSize; } - uint8_t getPicWidthInCtu( ) const { return m_picWidthInCtu; } - uint8_t getPicHeightInCtu( ) const { return m_picHeightInCtu; } + uint32_t getPicWidthInCtu( ) const { return m_picWidthInCtu; } + uint32_t getPicHeightInCtu( ) const { return m_picHeightInCtu; } void setNumExpTileColumns( uint32_t u ) { m_numExpTileCols = u; } uint32_t getNumExpTileColumns( ) const { return m_numExpTileCols; } void setNumExpTileRows( uint32_t u ) { m_numExpTileRows = u; } @@ -2252,7 +2072,7 @@ public: void addTileColumnWidth( uint32_t u ) { CHECK( m_tileColWidth.size() >= MAX_TILE_COLS, "Number of tile columns exceeds valid range" ); m_tileColWidth.push_back(u); } void addTileRowHeight( uint32_t u ) { CHECK( m_tileRowHeight.size() >= MAX_TILE_ROWS, "Number of tile rows exceeds valid range" ); m_tileRowHeight.push_back(u); } uint32_t getTileColumnWidth( int idx ) const { CHECK( idx >= m_tileColWidth.size(), "Tile column index exceeds valid range" ); return m_tileColWidth[idx]; } - uint32_t getTileRowHeight( int idx ) const { CHECK( idx >= m_tileRowHeight.size(), "Tile row index exceeds valid range" ); return m_tileRowHeight[idx]; } + uint32_t getTileRowHeight( int idx ) const { CHECK( idx >= m_tileRowHeight.size(), "Tile row index exceeds valid range" ); return m_tileRowHeight[idx]; } uint32_t getTileColumnBd( int idx ) const { CHECK( idx >= m_tileColBd.size(), "Tile column index exceeds valid range" ); return m_tileColBd[idx]; } uint32_t getTileRowBd( int idx ) const { CHECK( idx >= m_tileRowBd.size(), "Tile row index exceeds valid range" ); return m_tileRowBd[idx]; } uint32_t ctuToTileCol( int ctuX ) const { CHECK( ctuX >= m_ctuToTileCol.size(), "CTU address index exceeds valid range" ); return m_ctuToTileCol[ctuX]; } @@ -2268,11 +2088,7 @@ public: bool getRectSliceFlag( ) const { return m_rectSliceFlag; } void setSingleSlicePerSubPicFlag( bool b ) { m_singleSlicePerSubPicFlag = b; } bool getSingleSlicePerSubPicFlag( ) const { return m_singleSlicePerSubPicFlag; } -#if JVET_Q0817 uint32_t getCtuToSubPicIdx( int idx ) const { CHECK( idx >= m_ctuToSubPicIdx.size(), "CTU address index exceeds valid range" ); CHECK( getNumSubPics() < 1, "Number of subpicture cannot be 0" ); return m_ctuToSubPicIdx[ idx ]; } -#else - uint32_t getCtuToSubPicIdx( int idx ) const { CHECK( idx >= m_ctuToSubPicIdx.size(), "CTU address index exceeds valid range" ); return m_ctuToSubPicIdx[idx]; } -#endif void setNumSlicesInPic( uint32_t u ) { CHECK( u > MAX_SLICES, "Number of slices in picture exceeds valid range" ); m_numSlicesInPic = u; } uint32_t getNumSlicesInPic( ) const { return m_numSlicesInPic; } void setTileIdxDeltaPresentFlag( bool b ) { m_tileIdxDeltaPresentFlag = b; } @@ -2295,53 +2111,17 @@ public: void resetTileSliceInfo(); void initTiles(); void initRectSlices(); - void initRectSliceMap(); -#if JVET_O1143_SUBPIC_BOUNDARY + void initRectSliceMap(const SPS *sps); std::vector<SubPic> getSubPics() const {return m_subPics; }; -#if JVET_Q0044_SLICE_IDX_WITH_SUBPICS SubPic getSubPic(uint32_t idx) const { return m_subPics[idx]; } -#endif void initSubPic(const SPS &sps); - SubPic getSubPicFromPos(const Position& pos) const; - SubPic getSubPicFromCU (const CodingUnit& cu) const; -#endif + const SubPic& getSubPicFromPos(const Position& pos) const; + const SubPic& getSubPicFromCU (const CodingUnit& cu) const; void initRasterSliceMap( std::vector<uint32_t> sizes ); - void checkSliceMap(); + void checkSliceMap(); SliceMap getSliceMap( int idx ) const { CHECK( idx >= m_numSlicesInPic, "Slice index exceeds valid range" ); return m_sliceMap[idx]; } -#if !JVET_Q0183_SPS_TRANSFORM_SKIP_MODE_CONTROL - uint32_t getLog2MaxTransformSkipBlockSize() const { return m_log2MaxTransformSkipBlockSize; } - void setLog2MaxTransformSkipBlockSize(uint32_t u) { m_log2MaxTransformSkipBlockSize = u; } -#endif -#if !JVET_Q0151_Q0205_ENTRYPOINTS - bool getEntropyCodingSyncEnabledFlag() const { return m_entropyCodingSyncEnabledFlag; } - void setEntropyCodingSyncEnabledFlag(bool val) { m_entropyCodingSyncEnabledFlag = val; } -#endif -#if !JVET_Q0482_REMOVE_CONSTANT_PARAMS - bool getConstantSliceHeaderParamsEnabledFlag() const { return m_constantSliceHeaderParamsEnabledFlag; } - void setConstantSliceHeaderParamsEnabledFlag(bool b) { m_constantSliceHeaderParamsEnabledFlag = b; } - int getPPSDepQuantEnabledIdc() const { return m_PPSDepQuantEnabledIdc; } - void setPPSDepQuantEnabledIdc(int u) { m_PPSDepQuantEnabledIdc = u; } - int getPPSRefPicListSPSIdc( bool b ) const { return b==1 ? m_PPSRefPicListSPSIdc1: m_PPSRefPicListSPSIdc0; } - int getPPSRefPicListSPSIdc0() const { return m_PPSRefPicListSPSIdc0; } - void setPPSRefPicListSPSIdc0(int u) { m_PPSRefPicListSPSIdc0 = u; } - int getPPSRefPicListSPSIdc1() const { return m_PPSRefPicListSPSIdc1; } - void setPPSRefPicListSPSIdc1(int u) { m_PPSRefPicListSPSIdc1 = u; } - int getPPSMvdL1ZeroIdc() const { return m_PPSMvdL1ZeroIdc; } - void setPPSMvdL1ZeroIdc(int u) { m_PPSMvdL1ZeroIdc = u; } - int getPPSCollocatedFromL0Idc() const { return m_PPSCollocatedFromL0Idc; } - void setPPSCollocatedFromL0Idc(int u) { m_PPSCollocatedFromL0Idc = u; } - uint32_t getPPSSixMinusMaxNumMergeCandPlus1() const { return m_PPSSixMinusMaxNumMergeCandPlus1; } - void setPPSSixMinusMaxNumMergeCandPlus1(uint32_t u) { m_PPSSixMinusMaxNumMergeCandPlus1 = u; } -#if !JVET_Q0806 - uint32_t getPPSMaxNumMergeCandMinusMaxNumTriangleCandPlus1() const { return m_PPSMaxNumMergeCandMinusMaxNumTriangleCandPlus1; } - void setPPSMaxNumMergeCandMinusMaxNumTriangleCandPlus1(uint32_t u) { m_PPSMaxNumMergeCandMinusMaxNumTriangleCandPlus1 = u; } -#else - uint32_t getPPSMaxNumMergeCandMinusMaxNumGeoCandPlus1() const { return m_PPSMaxNumMergeCandMinusMaxNumGeoCandPlus1; } - void setPPSMaxNumMergeCandMinusMaxNumGeoCandPlus1(uint32_t u) { m_PPSMaxNumMergeCandMinusMaxNumGeoCandPlus1 = u; } -#endif -#endif void setCabacInitPresentFlag( bool flag ) { m_cabacInitPresentFlag = flag; } bool getCabacInitPresentFlag() const { return m_cabacInitPresentFlag; } @@ -2355,7 +2135,6 @@ public: int getDeblockingFilterBetaOffsetDiv2() const { return m_deblockingFilterBetaOffsetDiv2; } //!< get beta offset for deblocking filter void setDeblockingFilterTcOffsetDiv2(int val) { m_deblockingFilterTcOffsetDiv2 = val; } //!< set tc offset for deblocking filter int getDeblockingFilterTcOffsetDiv2() const { return m_deblockingFilterTcOffsetDiv2; } //!< get tc offset for deblocking filter -#if JVET_Q0121_DEBLOCKING_CONTROL_PARAMETERS void setDeblockingFilterCbBetaOffsetDiv2(int val) { m_deblockingFilterCbBetaOffsetDiv2 = val; } //!< set beta offset for Cb deblocking filter int getDeblockingFilterCbBetaOffsetDiv2() const { return m_deblockingFilterCbBetaOffsetDiv2; } //!< get beta offset for Cb deblocking filter void setDeblockingFilterCbTcOffsetDiv2(int val) { m_deblockingFilterCbTcOffsetDiv2 = val; } //!< set tc offset for Cb deblocking filter @@ -2364,7 +2143,6 @@ public: int getDeblockingFilterCrBetaOffsetDiv2() const { return m_deblockingFilterCrBetaOffsetDiv2; } //!< get beta offset for Cr deblocking filter void setDeblockingFilterCrTcOffsetDiv2(int val) { m_deblockingFilterCrTcOffsetDiv2 = val; } //!< set tc offset for Cr deblocking filter int getDeblockingFilterCrTcOffsetDiv2() const { return m_deblockingFilterCrTcOffsetDiv2; } //!< get tc offset for Cr deblocking filter -#endif bool getListsModificationPresentFlag() const { return m_listsModificationPresentFlag; } void setListsModificationPresentFlag( bool b ) { m_listsModificationPresentFlag = b; } bool getPictureHeaderExtensionPresentFlag() const { return m_pictureHeaderExtensionPresentFlag; } @@ -2372,7 +2150,6 @@ public: bool getSliceHeaderExtensionPresentFlag() const { return m_sliceHeaderExtensionPresentFlag; } void setSliceHeaderExtensionPresentFlag(bool val) { m_sliceHeaderExtensionPresentFlag = val; } -#if JVET_Q0819_PH_CHANGES void setRplInfoInPhFlag(bool flag) { m_rplInfoInPhFlag = flag; } bool getRplInfoInPhFlag() const { return m_rplInfoInPhFlag; } void setDbfInfoInPhFlag(bool flag) { m_dbfInfoInPhFlag = flag; } @@ -2385,12 +2162,7 @@ public: bool getWpInfoInPhFlag() const { return m_wpInfoInPhFlag; } void setQpDeltaInfoInPhFlag(bool flag) { m_qpDeltaInfoInPhFlag = flag; } bool getQpDeltaInfoInPhFlag() const { return m_qpDeltaInfoInPhFlag; } -#endif -#if !REMOVE_PPS_REXT - const PPSRExt& getPpsRangeExtension() const { return m_ppsRangeExtension; } - PPSRExt& getPpsRangeExtension() { return m_ppsRangeExtension; } -#endif void setPicWidthInLumaSamples( uint32_t u ) { m_picWidthInLumaSamples = u; } uint32_t getPicWidthInLumaSamples() const { return m_picWidthInLumaSamples; } @@ -2405,10 +2177,8 @@ public: const Window& getScalingWindow() const { return m_scalingWindow; } void setScalingWindow( Window& scalingWindow ) { m_scalingWindow = scalingWindow; } -#if SPS_ID_CHECK int getMixedNaluTypesInPicFlag() const { return m_mixedNaluTypesInPicFlag; } void setMixedNaluTypesInPicFlag( const bool flag ) { m_mixedNaluTypesInPicFlag = flag; } -#endif }; class APS @@ -2421,8 +2191,9 @@ private: AlfParam m_alfAPSParam; SliceReshapeInfo m_reshapeAPSInfo; ScalingList m_scalingListApsInfo; -#if JVET_Q0795_CCALF CcAlfFilterParam m_ccAlfAPSParam; +#if JVET_R0201_PREFIX_SUFFIX_APS_CLEANUP + bool m_hasPrefixNalUnitType; #endif public: @@ -2446,11 +2217,14 @@ public: SliceReshapeInfo& getReshaperAPSInfo() { return m_reshapeAPSInfo; } void setScalingList( ScalingList& scalingListAPSInfo ) { m_scalingListApsInfo = scalingListAPSInfo; } ScalingList& getScalingList() { return m_scalingListApsInfo; } -#if JVET_Q0795_CCALF void setCcAlfAPSParam(CcAlfFilterParam& ccAlfAPSParam) { m_ccAlfAPSParam = ccAlfAPSParam; } CcAlfFilterParam& getCcAlfAPSParam() { return m_ccAlfAPSParam; } +#if JVET_R0201_PREFIX_SUFFIX_APS_CLEANUP + void setHasPrefixNalUnitType( bool b ) { m_hasPrefixNalUnitType = b; } + bool getHasPrefixNalUnitType() const { return m_hasPrefixNalUnitType; } #endif }; + struct WPScalingParam { // Explicit weighted prediction parameters parsed in slice header, @@ -2480,47 +2254,26 @@ class PicHeader private: bool m_valid; //!< picture header is valid yet or not Picture* m_pcPic; //!< pointer to picture structure -#if JVET_Q0819_PH_CHANGES int m_pocLsb; //!< least significant bits of picture order count -#endif bool m_nonReferencePictureFlag; //!< non-reference picture flag bool m_gdrOrIrapPicFlag; //!< gdr or irap picture flag bool m_gdrPicFlag; //!< gradual decoding refresh picture flag bool m_noOutputOfPriorPicsFlag; //!< no output of prior pictures flag uint32_t m_recoveryPocCnt; //!< recovery POC count -#if SPS_ID_CHECK bool m_noOutputBeforeRecoveryFlag; //!< NoOutputBeforeRecoveryFlag bool m_handleCraAsCvsStartFlag; //!< HandleCraAsCvsStartFlag bool m_handleGdrAsCvsStartFlag; //!< HandleGdrAsCvsStartFlag -#endif int m_spsId; //!< sequence parameter set ID int m_ppsId; //!< picture parameter set ID -#if JVET_P0116_POC_MSB bool m_pocMsbPresentFlag; //!< ph_poc_msb_present_flag int m_pocMsbVal; //!< poc_msb_val -#endif -#if !JVET_Q0119_CLEANUPS - bool m_subPicIdSignallingPresentFlag; //!< indicates the presence of sub-picture ID signalling in the SPS - uint32_t m_subPicIdLen; //!< sub-picture ID length in bits - uint8_t m_subPicId[MAX_NUM_SUB_PICS]; //!< sub-picture ID for each sub-picture in the sequence -#endif -#if JVET_Q0246_VIRTUAL_BOUNDARY_ENABLE_FLAG bool m_virtualBoundariesEnabledFlag; //!< loop filtering across virtual boundaries disabled bool m_virtualBoundariesPresentFlag; //!< loop filtering across virtual boundaries disabled -#else - bool m_loopFilterAcrossVirtualBoundariesDisabledFlag; //!< loop filtering across virtual boundaries disabled -#endif unsigned m_numVerVirtualBoundaries; //!< number of vertical virtual boundaries unsigned m_numHorVirtualBoundaries; //!< number of horizontal virtual boundaries unsigned m_virtualBoundariesPosX[3]; //!< horizontal virtual boundary positions unsigned m_virtualBoundariesPosY[3]; //!< vertical virtual boundary positions -#if !JVET_Q0155_COLOUR_ID - unsigned m_colourPlaneId; //!< 4:4:4 colour plane ID -#endif bool m_picOutputFlag; //!< picture output flag -#if !JVET_Q0819_PH_CHANGES - bool m_picRplPresentFlag; //!< reference lists present in picture header or not -#endif const ReferencePictureList *m_pRPL0; //!< pointer to RPL for L0, either in the SPS or the local RPS in the picture header const ReferencePictureList* m_pRPL1; //!< pointer to RPL for L1, either in the SPS or the local RPS in the picture header @@ -2528,85 +2281,52 @@ private: ReferencePictureList m_localRPL1; //!< RPL for L1 when present in picture header int m_rpl0Idx; //!< index of used RPL in the SPS or -1 for local RPL in the picture header int m_rpl1Idx; //!< index of used RPL in the SPS or -1 for local RPL in the picture header -#if JVET_Q0819_PH_CHANGES bool m_picInterSliceAllowedFlag; //!< inter slice allowed flag in PH bool m_picIntraSliceAllowedFlag; //!< intra slice allowed flag in PH -#endif - bool m_splitConsOverrideFlag; //!< partitioning constraint override flag + bool m_splitConsOverrideFlag; //!< partitioning constraint override flag uint32_t m_cuQpDeltaSubdivIntra; //!< CU QP delta maximum subdivision for intra slices - uint32_t m_cuQpDeltaSubdivInter; //!< CU QP delta maximum subdivision for inter slices - uint32_t m_cuChromaQpOffsetSubdivIntra; //!< CU chroma QP offset maximum subdivision for intra slices - uint32_t m_cuChromaQpOffsetSubdivInter; //!< CU chroma QP offset maximum subdivision for inter slices + uint32_t m_cuQpDeltaSubdivInter; //!< CU QP delta maximum subdivision for inter slices + uint32_t m_cuChromaQpOffsetSubdivIntra; //!< CU chroma QP offset maximum subdivision for intra slices + uint32_t m_cuChromaQpOffsetSubdivInter; //!< CU chroma QP offset maximum subdivision for inter slices bool m_enableTMVPFlag; //!< enable temporal motion vector prediction -#if JVET_Q0482_REMOVE_CONSTANT_PARAMS bool m_picColFromL0Flag; //!< syntax element collocated_from_l0_flag -#endif -#if JVET_Q0259_COLLOCATED_PIC_IN_PH uint32_t m_colRefIdx; -#endif - bool m_mvdL1ZeroFlag; //!< L1 MVD set to zero flag -#if !JVET_Q0798_SPS_NUMBER_MERGE_CANDIDATE - uint32_t m_maxNumMergeCand; //!< max number of merge candidates -#endif + bool m_mvdL1ZeroFlag; //!< L1 MVD set to zero flag uint32_t m_maxNumAffineMergeCand; //!< max number of sub-block merge candidates bool m_disFracMMVD; //!< fractional MMVD offsets disabled flag bool m_disBdofFlag; //!< picture level BDOF disable flag bool m_disDmvrFlag; //!< picture level DMVR disable flag bool m_disProfFlag; //!< picture level PROF disable flag -#if !JVET_Q0798_SPS_NUMBER_MERGE_CANDIDATE -#if !JVET_Q0806 - uint32_t m_maxNumTriangleCand; //!< max number of triangle merge candidates -#else - uint32_t m_maxNumGeoCand; //!< max number of geometric merge candidates -#endif - uint32_t m_maxNumIBCMergeCand; //!< max number of IBC merge candidates -#endif - bool m_jointCbCrSignFlag; //!< joint Cb/Cr residual sign flag -#if JVET_Q0819_PH_CHANGES + bool m_jointCbCrSignFlag; //!< joint Cb/Cr residual sign flag int m_qpDelta; //!< value of Qp delta -#else - bool m_saoEnabledPresentFlag; //!< sao enabled flags present in the picture header -#endif bool m_saoEnabledFlag[MAX_NUM_CHANNEL_TYPE]; //!< sao enabled flags for each channel -#if !JVET_Q0819_PH_CHANGES - bool m_alfEnabledPresentFlag; //!< alf enabled flags present in the picture header -#endif bool m_alfEnabledFlag[MAX_NUM_COMPONENT]; //!< alf enabled flags for each component int m_numAlfAps; //!< number of alf aps active for the picture std::vector<int> m_alfApsId; //!< list of alf aps for the picture int m_alfChromaApsId; //!< chroma alf aps ID -#if JVET_Q0358_ALF_NALU_TID_CONSTRAINT +#if !JVET_R0225_SEPERATE_FLAGS_ALF_CHROMA int m_alfChromaIdc; //!< alf chroma idc #endif -#if JVET_Q0795_CCALF bool m_ccalfEnabledFlag[MAX_NUM_COMPONENT]; int m_ccalfCbApsId; int m_ccalfCrApsId; -#endif +#if !JVET_R0271_SLICE_LEVEL_DQ_SDH_RRC bool m_depQuantEnabledFlag; //!< dependent quantization enabled flag bool m_signDataHidingEnabledFlag; //!< sign data hiding enabled flag -#if !JVET_Q0819_PH_CHANGES - bool m_deblockingFilterOverridePresentFlag; //!< deblocking filter override controls present in picture header #endif bool m_deblockingFilterOverrideFlag; //!< deblocking filter override controls enabled bool m_deblockingFilterDisable; //!< deblocking filter disabled flag int m_deblockingFilterBetaOffsetDiv2; //!< beta offset for deblocking filter int m_deblockingFilterTcOffsetDiv2; //!< tc offset for deblocking filter -#if JVET_Q0121_DEBLOCKING_CONTROL_PARAMETERS int m_deblockingFilterCbBetaOffsetDiv2; //!< beta offset for deblocking filter int m_deblockingFilterCbTcOffsetDiv2; //!< tc offset for deblocking filter int m_deblockingFilterCrBetaOffsetDiv2; //!< beta offset for deblocking filter int m_deblockingFilterCrTcOffsetDiv2; //!< tc offset for deblocking filter -#endif bool m_lmcsEnabledFlag; //!< lmcs enabled flag int m_lmcsApsId; //!< lmcs APS ID APS* m_lmcsAps; //!< lmcs APS - bool m_lmcsChromaResidualScaleFlag; //!< lmcs chroma residual scale flag -#if JVET_Q0346_SCALING_LIST_USED_IN_SH + bool m_lmcsChromaResidualScaleFlag; //!< lmcs chroma residual scale flag bool m_explicitScalingListEnabledFlag; //!< explicit quantization scaling list enabled -#else - bool m_scalingListPresentFlag; //!< quantization scaling lists present -#endif int m_scalingListApsId; //!< quantization scaling list APS ID APS* m_scalingListAps; //!< quantization scaling list APS unsigned m_minQT[3]; //!< minimum quad-tree size 0: I slice luma; 1: P/B slice; 2: I slice chroma @@ -2614,11 +2334,9 @@ private: unsigned m_maxBTSize[3]; //!< maximum BT size unsigned m_maxTTSize[3]; //!< maximum TT size -#if JVET_Q0819_PH_CHANGES WPScalingParam m_weightPredTable[NUM_REF_PIC_LIST_01][MAX_NUM_REF][MAX_NUM_COMPONENT]; // [REF_PIC_LIST_0 or REF_PIC_LIST_1][refIdx][0:Y, 1:U, 2:V] int m_numL0Weights; //!< number of weights for L0 list int m_numL1Weights; //!< number of weights for L1 list -#endif public: PicHeader(); @@ -2629,10 +2347,8 @@ public: void setPic( Picture* p ) { m_pcPic = p; } Picture* getPic() { return m_pcPic; } const Picture* getPic() const { return m_pcPic; } -#if JVET_Q0819_PH_CHANGES void setPocLsb(int i) { m_pocLsb = i; } int getPocLsb() { return m_pocLsb; } -#endif void setNonReferencePictureFlag( bool b ) { m_nonReferencePictureFlag = b; } bool getNonReferencePictureFlag() const { return m_nonReferencePictureFlag; } void setGdrOrIrapPicFlag( bool b ) { m_gdrOrIrapPicFlag = b; } @@ -2647,27 +2363,12 @@ public: uint32_t getSPSId() const { return m_spsId; } void setPPSId( uint32_t u ) { m_ppsId = u; } uint32_t getPPSId() const { return m_ppsId; } -#if JVET_P0116_POC_MSB void setPocMsbPresentFlag(bool b) { m_pocMsbPresentFlag = b; } bool getPocMsbPresentFlag() const { return m_pocMsbPresentFlag; } void setPocMsbVal(int i) { m_pocMsbVal = i; } int getPocMsbVal() { return m_pocMsbVal; } -#endif -#if !JVET_Q0119_CLEANUPS - void setSubPicIdSignallingPresentFlag( bool b ) { m_subPicIdSignallingPresentFlag = b; } - bool getSubPicIdSignallingPresentFlag() const { return m_subPicIdSignallingPresentFlag; } - void setSubPicIdLen( uint32_t u ) { m_subPicIdLen = u; } - uint32_t getSubPicIdLen() const { return m_subPicIdLen; } - void setSubPicId( int i, uint8_t u ) { CHECK( i >= MAX_NUM_SUB_PICS, "Sub-pic index exceeds valid range" ); m_subPicId[i] = u; } - uint8_t getSubPicId( int i ) const { CHECK( i >= MAX_NUM_SUB_PICS, "Sub-pic index exceeds valid range" ); return m_subPicId[i]; } -#endif -#if JVET_Q0246_VIRTUAL_BOUNDARY_ENABLE_FLAG void setVirtualBoundariesPresentFlag( bool b ) { m_virtualBoundariesPresentFlag = b; } bool getVirtualBoundariesPresentFlag() const { return m_virtualBoundariesPresentFlag; } -#else - void setLoopFilterAcrossVirtualBoundariesDisabledFlag(bool b) { m_loopFilterAcrossVirtualBoundariesDisabledFlag = b; } - bool getLoopFilterAcrossVirtualBoundariesDisabledFlag() const { return m_loopFilterAcrossVirtualBoundariesDisabledFlag; } -#endif void setNumVerVirtualBoundaries(unsigned u) { m_numVerVirtualBoundaries = u; } unsigned getNumVerVirtualBoundaries() const { return m_numVerVirtualBoundaries; } void setNumHorVirtualBoundaries(unsigned u) { m_numHorVirtualBoundaries = u; } @@ -2676,16 +2377,8 @@ public: unsigned getVirtualBoundariesPosX(unsigned idx) const { CHECK( idx >= 3, "boundary index exceeds valid range" ); return m_virtualBoundariesPosX[idx];} void setVirtualBoundariesPosY(unsigned u, unsigned idx) { CHECK( idx >= 3, "boundary index exceeds valid range" ); m_virtualBoundariesPosY[idx] = u; } unsigned getVirtualBoundariesPosY(unsigned idx) const { CHECK( idx >= 3, "boundary index exceeds valid range" ); return m_virtualBoundariesPosY[idx];} -#if !JVET_Q0155_COLOUR_ID - void setColourPlaneId(unsigned u) { m_colourPlaneId = u; } - unsigned getColourPlaneId() const { return m_colourPlaneId; } -#endif void setPicOutputFlag( bool b ) { m_picOutputFlag = b; } bool getPicOutputFlag() const { return m_picOutputFlag; } -#if !JVET_Q0819_PH_CHANGES - void setPicRplPresentFlag( bool b ) { m_picRplPresentFlag = b; } - bool getPicRplPresentFlag() const { return m_picRplPresentFlag; } -#endif void setRPL( bool b, const ReferencePictureList *pcRPL) { if(b==1) { m_pRPL1 = pcRPL; } else { m_pRPL0 = pcRPL; } } const ReferencePictureList* getRPL( bool b ) { return b==1 ? m_pRPL1 : m_pRPL0; } ReferencePictureList* getLocalRPL( bool b ) { return b==1 ? &m_localRPL1 : &m_localRPL0; } @@ -2701,14 +2394,12 @@ public: void setRPL1idx(int rplIdx) { m_rpl1Idx = rplIdx; } int getRPL0idx() const { return m_rpl0Idx; } int getRPL1idx() const { return m_rpl1Idx; } -#if JVET_Q0819_PH_CHANGES void setPicInterSliceAllowedFlag(bool b) { m_picInterSliceAllowedFlag = b; } bool getPicInterSliceAllowedFlag() const { return m_picInterSliceAllowedFlag; } void setPicIntraSliceAllowedFlag(bool b) { m_picIntraSliceAllowedFlag = b; } bool getPicIntraSliceAllowedFlag() const { return m_picIntraSliceAllowedFlag; } -#endif void setSplitConsOverrideFlag( bool b ) { m_splitConsOverrideFlag = b; } - bool getSplitConsOverrideFlag() const { return m_splitConsOverrideFlag; } + bool getSplitConsOverrideFlag() const { return m_splitConsOverrideFlag; } void setCuQpDeltaSubdivIntra( uint32_t u ) { m_cuQpDeltaSubdivIntra = u; } uint32_t getCuQpDeltaSubdivIntra() const { return m_cuQpDeltaSubdivIntra; } void setCuQpDeltaSubdivInter( uint32_t u ) { m_cuQpDeltaSubdivInter = u; } @@ -2719,67 +2410,38 @@ public: uint32_t getCuChromaQpOffsetSubdivInter() const { return m_cuChromaQpOffsetSubdivInter; } void setEnableTMVPFlag( bool b ) { m_enableTMVPFlag = b; } bool getEnableTMVPFlag() const { return m_enableTMVPFlag; } -#if JVET_Q0482_REMOVE_CONSTANT_PARAMS void setPicColFromL0Flag(bool val) { m_picColFromL0Flag = val; } bool getPicColFromL0Flag() const { return m_picColFromL0Flag; } -#endif -#if JVET_Q0259_COLLOCATED_PIC_IN_PH void setColRefIdx( uint32_t refIdx) { m_colRefIdx = refIdx; } uint32_t getColRefIdx() { return m_colRefIdx; } -#endif void setMvdL1ZeroFlag( bool b ) { m_mvdL1ZeroFlag = b; } - bool getMvdL1ZeroFlag() const { return m_mvdL1ZeroFlag; } -#if !JVET_Q0798_SPS_NUMBER_MERGE_CANDIDATE - void setMaxNumMergeCand(uint32_t val ) { m_maxNumMergeCand = val; } - uint32_t getMaxNumMergeCand() const { return m_maxNumMergeCand; } -#endif + bool getMvdL1ZeroFlag() const { return m_mvdL1ZeroFlag; } void setMaxNumAffineMergeCand( uint32_t val ) { m_maxNumAffineMergeCand = val; } uint32_t getMaxNumAffineMergeCand() const { return m_maxNumAffineMergeCand; } void setDisFracMMVD( bool val ) { m_disFracMMVD = val; } - bool getDisFracMMVD() const { return m_disFracMMVD; } + bool getDisFracMMVD() const { return m_disFracMMVD; } void setDisBdofFlag( bool val ) { m_disBdofFlag = val; } bool getDisBdofFlag() const { return m_disBdofFlag; } void setDisDmvrFlag( bool val ) { m_disDmvrFlag = val; } bool getDisDmvrFlag() const { return m_disDmvrFlag; } void setDisProfFlag( bool val ) { m_disProfFlag = val; } bool getDisProfFlag() const { return m_disProfFlag; } -#if !JVET_Q0798_SPS_NUMBER_MERGE_CANDIDATE -#if !JVET_Q0806 - void setMaxNumTriangleCand(uint32_t b) { m_maxNumTriangleCand = b; } - uint32_t getMaxNumTriangleCand() const { return m_maxNumTriangleCand; } -#else - void setMaxNumGeoCand(uint32_t b) { m_maxNumGeoCand = b; } - uint32_t getMaxNumGeoCand() const { return m_maxNumGeoCand; } -#endif - void setMaxNumIBCMergeCand( uint32_t b ) { m_maxNumIBCMergeCand = b; } - uint32_t getMaxNumIBCMergeCand() const { return m_maxNumIBCMergeCand; } -#endif void setJointCbCrSignFlag( bool b ) { m_jointCbCrSignFlag = b; } bool getJointCbCrSignFlag() const { return m_jointCbCrSignFlag; } -#if JVET_Q0819_PH_CHANGES void setQpDelta(int b) { m_qpDelta = b; } int getQpDelta() const { return m_qpDelta; } -#else - void setSaoEnabledPresentFlag( bool b ) { m_saoEnabledPresentFlag = b; } - bool getSaoEnabledPresentFlag() const { return m_saoEnabledPresentFlag; } -#endif void setSaoEnabledFlag(ChannelType chType, bool b) { m_saoEnabledFlag[chType] = b; } - bool getSaoEnabledFlag(ChannelType chType) const { return m_saoEnabledFlag[chType]; } -#if !JVET_Q0819_PH_CHANGES - void setAlfEnabledPresentFlag( bool b ) { m_alfEnabledPresentFlag = b; } - bool getAlfEnabledPresentFlag() const { return m_alfEnabledPresentFlag; } -#endif + bool getSaoEnabledFlag(ChannelType chType) const { return m_saoEnabledFlag[chType]; } void setAlfEnabledFlag(ComponentID compId, bool b) { m_alfEnabledFlag[compId] = b; } bool getAlfEnabledFlag(ComponentID compId) const { return m_alfEnabledFlag[compId]; } void setNumAlfAps(int i) { m_numAlfAps = i; } int getNumAlfAps() const { return m_numAlfAps; } void setAlfApsIdChroma(int i) { m_alfChromaApsId = i; } int getAlfApsIdChroma() const { return m_alfChromaApsId; } -#if JVET_Q0358_ALF_NALU_TID_CONSTRAINT +#if !JVET_R0225_SEPERATE_FLAGS_ALF_CHROMA void setAlfChromaIdc(int i) { m_alfChromaIdc = i; } int getAlfChromaIdc() const { return m_alfChromaIdc; } #endif -#if JVET_Q0795_CCALF void setCcAlfEnabledFlag(ComponentID compId, bool b) { m_ccalfEnabledFlag[compId] = b; } bool getCcAlfEnabledFlag(ComponentID compId) const { return m_ccalfEnabledFlag[compId]; } @@ -2787,24 +2449,20 @@ public: int getCcAlfCbApsId() const { return m_ccalfCbApsId; } void setCcAlfCrApsId(int i) { m_ccalfCrApsId = i; } int getCcAlfCrApsId() const { return m_ccalfCrApsId; } -#endif +#if !JVET_R0271_SLICE_LEVEL_DQ_SDH_RRC void setDepQuantEnabledFlag( bool b ) { m_depQuantEnabledFlag = b; } bool getDepQuantEnabledFlag() const { return m_depQuantEnabledFlag; } void setSignDataHidingEnabledFlag( bool b ) { m_signDataHidingEnabledFlag = b; } bool getSignDataHidingEnabledFlag() const { return m_signDataHidingEnabledFlag; } -#if !JVET_Q0819_PH_CHANGES - void setDeblockingFilterOverridePresentFlag( bool b ) { m_deblockingFilterOverridePresentFlag = b; } - bool getDeblockingFilterOverridePresentFlag() const { return m_deblockingFilterOverridePresentFlag; } #endif void setDeblockingFilterOverrideFlag( bool b ) { m_deblockingFilterOverrideFlag = b; } - bool getDeblockingFilterOverrideFlag() const { return m_deblockingFilterOverrideFlag; } - void setDeblockingFilterDisable( bool b ) { m_deblockingFilterDisable= b; } + bool getDeblockingFilterOverrideFlag() const { return m_deblockingFilterOverrideFlag; } + void setDeblockingFilterDisable( bool b ) { m_deblockingFilterDisable= b; } bool getDeblockingFilterDisable() const { return m_deblockingFilterDisable; } - void setDeblockingFilterBetaOffsetDiv2( int i ) { m_deblockingFilterBetaOffsetDiv2 = i; } + void setDeblockingFilterBetaOffsetDiv2( int i ) { m_deblockingFilterBetaOffsetDiv2 = i; } int getDeblockingFilterBetaOffsetDiv2()const { return m_deblockingFilterBetaOffsetDiv2; } - void setDeblockingFilterTcOffsetDiv2( int i ) { m_deblockingFilterTcOffsetDiv2 = i; } - int getDeblockingFilterTcOffsetDiv2() const { return m_deblockingFilterTcOffsetDiv2; } -#if JVET_Q0121_DEBLOCKING_CONTROL_PARAMETERS + void setDeblockingFilterTcOffsetDiv2( int i ) { m_deblockingFilterTcOffsetDiv2 = i; } + int getDeblockingFilterTcOffsetDiv2() const { return m_deblockingFilterTcOffsetDiv2; } void setDeblockingFilterCbBetaOffsetDiv2( int i ) { m_deblockingFilterCbBetaOffsetDiv2 = i; } int getDeblockingFilterCbBetaOffsetDiv2()const { return m_deblockingFilterCbBetaOffsetDiv2; } void setDeblockingFilterCbTcOffsetDiv2( int i ) { m_deblockingFilterCbTcOffsetDiv2 = i; } @@ -2813,7 +2471,6 @@ public: int getDeblockingFilterCrBetaOffsetDiv2()const { return m_deblockingFilterCrBetaOffsetDiv2; } void setDeblockingFilterCrTcOffsetDiv2( int i ) { m_deblockingFilterCrTcOffsetDiv2 = i; } int getDeblockingFilterCrTcOffsetDiv2() const { return m_deblockingFilterCrTcOffsetDiv2; } -#endif void setLmcsEnabledFlag(bool b) { m_lmcsEnabledFlag = b; } bool getLmcsEnabledFlag() { return m_lmcsEnabledFlag; } const bool getLmcsEnabledFlag() const { return m_lmcsEnabledFlag; } @@ -2828,21 +2485,15 @@ public: APS* getScalingListAPS() const { return m_scalingListAps; } void setScalingListAPSId( int id ) { m_scalingListApsId = id; } int getScalingListAPSId() const { return m_scalingListApsId; } -#if JVET_Q0346_SCALING_LIST_USED_IN_SH void setExplicitScalingListEnabledFlag( bool b ) { m_explicitScalingListEnabledFlag = b; } bool getExplicitScalingListEnabledFlag() { return m_explicitScalingListEnabledFlag; } const bool getExplicitScalingListEnabledFlag() const { return m_explicitScalingListEnabledFlag; } -#else - void setScalingListPresentFlag( bool b ) { m_scalingListPresentFlag = b; } - bool getScalingListPresentFlag() { return m_scalingListPresentFlag; } - const bool getScalingListPresentFlag() const { return m_scalingListPresentFlag; } -#endif unsigned* getMinQTSizes() const { return (unsigned *)m_minQT; } unsigned* getMaxMTTHierarchyDepths() const { return (unsigned *)m_maxMTTHierarchyDepth; } unsigned* getMaxBTSizes() const { return (unsigned *)m_maxBTSize; } unsigned* getMaxTTSizes() const { return (unsigned *)m_maxTTSize; } - + void setMinQTSize(unsigned idx, unsigned minQT) { m_minQT[idx] = minQT; } void setMaxMTTHierarchyDepth(unsigned idx, unsigned maxMTT) { m_maxMTTHierarchyDepth[idx] = maxMTT; } void setMaxBTSize(unsigned idx, unsigned maxBT) { m_maxBTSize[idx] = maxBT; } @@ -2852,7 +2503,7 @@ public: void setMaxMTTHierarchyDepths(unsigned* maxMTT) { m_maxMTTHierarchyDepth[0] = maxMTT[0]; m_maxMTTHierarchyDepth[1] = maxMTT[1]; m_maxMTTHierarchyDepth[2] = maxMTT[2]; } void setMaxBTSizes(unsigned* maxBT) { m_maxBTSize[0] = maxBT[0]; m_maxBTSize[1] = maxBT[1]; m_maxBTSize[2] = maxBT[2]; } void setMaxTTSizes(unsigned* maxTT) { m_maxTTSize[0] = maxTT[0]; m_maxTTSize[1] = maxTT[1]; m_maxTTSize[2] = maxTT[2]; } - + unsigned getMinQTSize(SliceType slicetype, ChannelType chType = CHANNEL_TYPE_LUMA) const { return slicetype == I_SLICE ? (chType == CHANNEL_TYPE_LUMA ? m_minQT[0] : m_minQT[2]) : m_minQT[1]; } unsigned getMaxMTTHierarchyDepth(SliceType slicetype, @@ -2861,7 +2512,7 @@ public: ChannelType chType = CHANNEL_TYPE_LUMA) const { return slicetype == I_SLICE ? (chType == CHANNEL_TYPE_LUMA ? m_maxBTSize[0] : m_maxBTSize[2]) : m_maxBTSize[1]; } unsigned getMaxTTSize(SliceType slicetype, ChannelType chType = CHANNEL_TYPE_LUMA) const { return slicetype == I_SLICE ? (chType == CHANNEL_TYPE_LUMA ? m_maxTTSize[0] : m_maxTTSize[2]) : m_maxTTSize[1]; } - + void setAlfAPSs(std::vector<int> apsIDs) { m_alfApsId.resize(m_numAlfAps); for (int i = 0; i < m_numAlfAps; i++) { @@ -2871,27 +2522,24 @@ public: std::vector<int> getAlfAPSs() const { return m_alfApsId; } -#if JVET_Q0819_PH_CHANGES void setWpScaling(WPScalingParam *wp) { memcpy(m_weightPredTable, wp, sizeof(WPScalingParam) * NUM_REF_PIC_LIST_01 * MAX_NUM_REF * MAX_NUM_COMPONENT); } void getWpScaling(RefPicList e, int iRefIdx, WPScalingParam *&wp) const; WPScalingParam* getWpScalingAll() { return (WPScalingParam *) m_weightPredTable; } + void resetWpScaling(); void setNumL0Weights(int b) { m_numL0Weights = b; } int getNumL0Weights() { return m_numL0Weights; } void setNumL1Weights(int b) { m_numL1Weights = b; } int getNumL1Weights() { return m_numL1Weights; } -#endif -#if SPS_ID_CHECK void setNoOutputBeforeRecoveryFlag( bool val ) { m_noOutputBeforeRecoveryFlag = val; } bool getNoOutputBeforeRecoveryFlag() const { return m_noOutputBeforeRecoveryFlag; } void setHandleCraAsCvsStartFlag( bool val ) { m_handleCraAsCvsStartFlag = val; } bool getHandleCraAsCvsStartFlag() const { return m_handleCraAsCvsStartFlag; } void setHandleGdrAsCvsStartFlag( bool val ) { m_handleGdrAsCvsStartFlag = val; } bool getHandleGdrAsCvsStartFlag() const { return m_handleGdrAsCvsStartFlag; } -#endif }; /// slice header class @@ -2915,39 +2563,29 @@ private: ReferencePictureList m_localRPL1; //< RPL for L1 when present in slice header int m_rpl0Idx; //< index of used RPL in the SPS or -1 for local RPL in the slice header int m_rpl1Idx; //< index of used RPL in the SPS or -1 for local RPL in the slice header -#if JVET_Q0155_COLOUR_ID int m_colourPlaneId; //!< 4:4:4 colour plane ID -#endif NalUnitType m_eNalUnitType; ///< Nal unit type for the slice -#if JVET_Q0775_PH_IN_SH bool m_pictureHeaderInSliceHeader; -#endif -#if JVET_Q0118_CLEANUPS uint32_t m_nuhLayerId; ///< Nal unit layer id -#endif SliceType m_eSliceType; int m_iSliceQp; int m_iSliceQpBase; bool m_ChromaQpAdjEnabled; -#if JVET_Q0346_LMCS_ENABLE_IN_SH bool m_lmcsEnabledFlag; -#endif -#if JVET_Q0346_SCALING_LIST_USED_IN_SH bool m_explicitScalingListUsed; -#endif bool m_deblockingFilterDisable; bool m_deblockingFilterOverrideFlag; //< offsets for deblocking filter inherit from PPS int m_deblockingFilterBetaOffsetDiv2; //< beta offset for deblocking filter int m_deblockingFilterTcOffsetDiv2; //< tc offset for deblocking filter -#if JVET_Q0121_DEBLOCKING_CONTROL_PARAMETERS int m_deblockingFilterCbBetaOffsetDiv2; //< beta offset for deblocking filter int m_deblockingFilterCbTcOffsetDiv2; //< tc offset for deblocking filter int m_deblockingFilterCrBetaOffsetDiv2; //< beta offset for deblocking filter int m_deblockingFilterCrTcOffsetDiv2; //< tc offset for deblocking filter +#if JVET_R0271_SLICE_LEVEL_DQ_SDH_RRC + bool m_depQuantEnabledFlag; //!< dependent quantization enabled flag + bool m_signDataHidingEnabledFlag; //!< sign data hiding enabled flag #endif -#if JVET_Q0089_SLICE_LOSSLESS_CODING_CHROMA_BDPCM bool m_tsResidualCodingDisabledFlag; -#endif int m_list1IdxToList0Idx[MAX_NUM_REF]; int m_aiNumRefIdx [NUM_REF_PIC_LIST_01]; // for multiple reference of current slice bool m_pendingRasInit; @@ -2970,9 +2608,6 @@ private: // access channel -#if !JVET_Q0117_PARAMETER_SETS_CLEANUP - const DPS* m_dps; -#endif const VPS* m_pcVPS; const SPS* m_pcSPS; const PPS* m_pcPPS; @@ -2980,10 +2615,6 @@ private: const PicHeader* m_pcPicHeader; //!< pointer to picture header structure bool m_colFromL0Flag; // collocated picture from List0 flag -#if !SPS_ID_CHECK - bool m_noIncorrectPicOutputFlag; - bool m_handleCraAsCvsStartFlag; -#endif uint32_t m_colRefIdx; double m_lambdas[MAX_NUM_COMPONENT]; @@ -3006,36 +2637,35 @@ private: ClpRngs m_clpRngs; std::vector<uint32_t> m_substreamSizes; uint32_t m_numEntryPoints; -#if JVET_Q0151_Q0205_ENTRYPOINTS uint32_t m_numSubstream; -#endif bool m_cabacInitFlag; uint32_t m_sliceSubPicId; - - + + SliceType m_encCABACTableIdx; // Used to transmit table selection across slices. clock_t m_iProcessingStartTime; double m_dProcessingTime; - + int m_rpPicOrderCntVal; APS* m_alfApss[ALF_CTB_MAX_NUM_APS]; bool m_tileGroupAlfEnabledFlag[MAX_NUM_COMPONENT]; int m_tileGroupNumAps; std::vector<int> m_tileGroupLumaApsId; int m_tileGroupChromaApsId; -#if JVET_Q0795_CCALF bool m_tileGroupCcAlfCbEnabledFlag; bool m_tileGroupCcAlfCrEnabledFlag; int m_tileGroupCcAlfCbApsId; int m_tileGroupCcAlfCrApsId; -#endif bool m_disableSATDForRd; +#if JVET_R0110_MIXED_LOSSLESS + bool m_isLossless; +#endif public: Slice(); virtual ~Slice(); @@ -3045,10 +2675,6 @@ public: const PicHeader* getPicHeader() const { return m_pcPicHeader; } int getRefIdx4MVPair( RefPicList eCurRefPicList, int nCurRefIdx ); -#if !JVET_Q0117_PARAMETER_SETS_CLEANUP - void setDPS( DPS* dps ) { m_dps = dps; } - const DPS* getDPS() const { return m_dps; } -#endif void setSPS( const SPS* pcSPS ) { m_pcSPS = pcSPS; } const SPS* getSPS() const { return m_pcSPS; } @@ -3089,34 +2715,24 @@ public: bool getDeblockingFilterOverrideFlag() const { return m_deblockingFilterOverrideFlag; } int getDeblockingFilterBetaOffsetDiv2()const { return m_deblockingFilterBetaOffsetDiv2; } int getDeblockingFilterTcOffsetDiv2() const { return m_deblockingFilterTcOffsetDiv2; } -#if JVET_Q0121_DEBLOCKING_CONTROL_PARAMETERS int getDeblockingFilterCbBetaOffsetDiv2()const { return m_deblockingFilterCbBetaOffsetDiv2; } int getDeblockingFilterCbTcOffsetDiv2() const { return m_deblockingFilterCbTcOffsetDiv2; } int getDeblockingFilterCrBetaOffsetDiv2()const { return m_deblockingFilterCrBetaOffsetDiv2; } int getDeblockingFilterCrTcOffsetDiv2() const { return m_deblockingFilterCrTcOffsetDiv2; } -#endif bool getPendingRasInit() const { return m_pendingRasInit; } void setPendingRasInit( bool val ) { m_pendingRasInit = val; } -#if JVET_Q0346_LMCS_ENABLE_IN_SH void setLmcsEnabledFlag(bool b) { m_lmcsEnabledFlag = b; } bool getLmcsEnabledFlag() { return m_lmcsEnabledFlag; } const bool getLmcsEnabledFlag() const { return m_lmcsEnabledFlag; } -#endif -#if JVET_Q0346_SCALING_LIST_USED_IN_SH void setExplicitScalingListUsed(bool b) { m_explicitScalingListUsed = b; } bool getExplicitScalingListUsed() { return m_explicitScalingListUsed; } -#endif int getNumRefIdx( RefPicList e ) const { return m_aiNumRefIdx[e]; } Picture* getPic() { return m_pcPic; } const Picture* getPic() const { return m_pcPic; } -#if JVET_O1143_MV_ACROSS_SUBPIC_BOUNDARY Picture* getRefPic( RefPicList e, int iRefIdx) const { return m_apcRefPicList[e][iRefIdx]; } -#else - const Picture* getRefPic( RefPicList e, int iRefIdx) const { return m_apcRefPicList[e][iRefIdx]; } -#endif int getRefPOC( RefPicList e, int iRefIdx) const { return m_aiRefPOCList[e][iRefIdx]; } int getDepth() const { return m_iDepth; } bool getColFromL0Flag() const { return m_colFromL0Flag; } @@ -3127,33 +2743,21 @@ public: bool getCheckLDC() const { return m_bCheckLDC; } int getList1IdxToList0Idx( int list1Idx ) const { return m_list1IdxToList0Idx[list1Idx]; } void setPOC( int i ) { m_iPOC = i; } -#if JVET_Q0775_PH_IN_SH bool getPictureHeaderInSliceHeader() const { return m_pictureHeaderInSliceHeader; } void setPictureHeaderInSliceHeader( bool e ) { m_pictureHeaderInSliceHeader = e; } -#endif void setNalUnitType( NalUnitType e ) { m_eNalUnitType = e; } NalUnitType getNalUnitType() const { return m_eNalUnitType; } -#if JVET_Q0118_CLEANUPS void setNalUnitLayerId( uint32_t i ) { m_nuhLayerId = i; } uint32_t getNalUnitLayerId() const { return m_nuhLayerId; } -#endif bool getRapPicFlag() const; bool getIdrPicFlag() const { return getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL || getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP; } bool isIRAP() const { return (getNalUnitType() >= NAL_UNIT_CODED_SLICE_IDR_W_RADL) && (getNalUnitType() <= NAL_UNIT_CODED_SLICE_CRA); } -#if SPS_ID_CHECK // CLVSS PU is either an IRAP PU with NoOutputBeforeRecoveryFlag equal to 1 or a GDR PU with NoOutputBeforeRecoveryFlag equal to 1. bool isClvssPu() const { return m_eNalUnitType >= NAL_UNIT_CODED_SLICE_IDR_W_RADL && m_eNalUnitType <= NAL_UNIT_CODED_SLICE_GDR && !m_pcPPS->getMixedNaluTypesInPicFlag() && m_pcPicHeader->getNoOutputBeforeRecoveryFlag(); } -#endif bool isIDRorBLA() const { return (getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL) || (getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP); } -#if JVET_P0978_RPL_RESTRICTIONS void checkCRA(const ReferencePictureList* pRPL0, const ReferencePictureList* pRPL1, const int pocCRA, PicList& rcListPic); -#else - void checkCRA(const ReferencePictureList *pRPL0, const ReferencePictureList *pRPL1, int& pocCRA, NalUnitType& associatedIRAPType, PicList& rcListPic); -#endif void checkSTSA(PicList& rcListPic); -#if JVET_P0978_RPL_RESTRICTIONS void checkRPL(const ReferencePictureList* pRPL0, const ReferencePictureList* pRPL1, const int associatedIRAPDecodingOrderNumber, PicList& rcListPic); -#endif void decodingRefreshMarking(int& pocCRA, bool& bRefreshPending, PicList& rcListPic, const bool bEfficientFieldIRAPEnabled); void setSliceType( SliceType e ) { m_eSliceType = e; } void setSliceQp( int i ) { m_iSliceQp = i; } @@ -3164,16 +2768,18 @@ public: void setDeblockingFilterOverrideFlag( bool b ) { m_deblockingFilterOverrideFlag = b; } void setDeblockingFilterBetaOffsetDiv2( int i ) { m_deblockingFilterBetaOffsetDiv2 = i; } void setDeblockingFilterTcOffsetDiv2( int i ) { m_deblockingFilterTcOffsetDiv2 = i; } -#if JVET_Q0121_DEBLOCKING_CONTROL_PARAMETERS void setDeblockingFilterCbBetaOffsetDiv2( int i ) { m_deblockingFilterCbBetaOffsetDiv2 = i; } void setDeblockingFilterCbTcOffsetDiv2( int i ) { m_deblockingFilterCbTcOffsetDiv2 = i; } void setDeblockingFilterCrBetaOffsetDiv2( int i ) { m_deblockingFilterCrBetaOffsetDiv2 = i; } void setDeblockingFilterCrTcOffsetDiv2( int i ) { m_deblockingFilterCrTcOffsetDiv2 = i; } +#if JVET_R0271_SLICE_LEVEL_DQ_SDH_RRC + void setDepQuantEnabledFlag( bool b ) { m_depQuantEnabledFlag = b; } + bool getDepQuantEnabledFlag() const { return m_depQuantEnabledFlag; } + void setSignDataHidingEnabledFlag( bool b ) { m_signDataHidingEnabledFlag = b; } + bool getSignDataHidingEnabledFlag() const { return m_signDataHidingEnabledFlag; } #endif -#if JVET_Q0089_SLICE_LOSSLESS_CODING_CHROMA_BDPCM void setTSResidualCodingDisabledFlag(bool b) { m_tsResidualCodingDisabledFlag = b; } bool getTSResidualCodingDisabledFlag() const { return m_tsResidualCodingDisabledFlag; } -#endif void setNumRefIdx( RefPicList e, int i ) { m_aiNumRefIdx[e] = i; } void setPic( Picture* p ) { m_pcPic = p; } @@ -3206,10 +2812,8 @@ public: bool isPocRestrictedByDRAP( int poc, bool precedingDRAPinDecodingOrder ); bool isPOCInRefPicList( const ReferencePictureList *rpl, int poc ); void checkConformanceForDRAP( uint32_t temporalId ); -#if JVET_Q0155_COLOUR_ID void setColourPlaneId( int id ) { m_colourPlaneId = id; } int getColourPlaneId() const { return m_colourPlaneId; } -#endif void setLambdas( const double lambdas[MAX_NUM_COMPONENT] ) { for (int component = 0; component < MAX_NUM_COMPONENT; component++) m_lambdas[component] = lambdas[component]; } const double* getLambdas() const { return m_lambdas; } @@ -3244,27 +2848,12 @@ public: uint32_t getTLayer() const { return m_uiTLayer; } void setTLayer( uint32_t uiTLayer ) { m_uiTLayer = uiTLayer; } -#if JVET_Q0751_MIXED_NAL_UNIT_TYPES void checkLeadingPictureRestrictions( PicList& rcListPic, const PPS& pps) const; -#else - void checkLeadingPictureRestrictions( PicList& rcListPic ) const; -#endif int checkThatAllRefPicsAreAvailable(PicList& rcListPic, const ReferencePictureList* pRPL, int rplIdx, bool printErrors, int* refPicIndex, int numActiveRefPics) const; -#if JVET_Q0751_MIXED_NAL_UNIT_TYPES void applyReferencePictureListBasedMarking( PicList& rcListPic, const ReferencePictureList *pRPL0, const ReferencePictureList *pRPL1, const int layerId, const PPS& pps ) const; -#else - void applyReferencePictureListBasedMarking( PicList& rcListPic, const ReferencePictureList *pRPL0, const ReferencePictureList *pRPL1, const int layerId ) const; -#endif bool isTemporalLayerSwitchingPoint( PicList& rcListPic ) const; bool isStepwiseTemporalLayerSwitchingPointCandidate( PicList& rcListPic ) const; int checkThatAllRefPicsAreAvailable(PicList& rcListPic, const ReferencePictureList *pRPL, int rplIdx, bool printErrors) const; -#if !SPS_ID_CHECK - void setNoIncorrectPicOutputFlag(bool val) { m_noIncorrectPicOutputFlag = val; } - bool getNoIncorrectPicOutputFlag() const { return m_noIncorrectPicOutputFlag; } - - void setHandleCraAsCvsStartFlag( bool val ) { m_handleCraAsCvsStartFlag = val; } - bool getHandleCraAsCvsStartFlag() const { return m_handleCraAsCvsStartFlag; } -#endif void setNumTilesInSlice( uint32_t u ) { m_sliceMap.setNumTilesInSlice( u ); } uint32_t getNumTilesInSlice() const { return m_sliceMap.getNumTilesInSlice(); } @@ -3275,8 +2864,8 @@ public: uint32_t getNumCtuInSlice() const { return m_sliceMap.getNumCtuInSlice(); } uint32_t getCtuAddrInSlice( int idx ) const { return m_sliceMap.getCtuAddrInSlice( idx ); } void initSliceMap() { m_sliceMap.initSliceMap(); } - void addCtusToSlice( uint32_t startX, uint32_t stopX, - uint32_t startY, uint32_t stopY, + void addCtusToSlice( uint32_t startX, uint32_t stopX, + uint32_t startY, uint32_t stopY, uint32_t picWidthInCtbsY ) { m_sliceMap.addCtusToSlice(startX, stopX, startY, stopY, picWidthInCtbsY); } void setIndependentSliceIdx( uint32_t i) { m_independentSliceIdx = i; } uint32_t getIndependentSliceIdx() const { return m_independentSliceIdx; } @@ -3293,13 +2882,11 @@ public: { memcpy(m_weightPredTable, wp, sizeof(WPScalingParam)*NUM_REF_PIC_LIST_01*MAX_NUM_REF*MAX_NUM_COMPONENT); } -#if JVET_Q0819_PH_CHANGES void setWpScaling(WPScalingParam *wp) { memcpy(m_weightPredTable, wp, sizeof(WPScalingParam) * NUM_REF_PIC_LIST_01 * MAX_NUM_REF * MAX_NUM_COMPONENT); } WPScalingParam * getWpScalingAll() { return (WPScalingParam *) m_weightPredTable; } -#endif void getWpScaling( RefPicList e, int iRefIdx, WPScalingParam *&wp) const; void resetWpScaling(); @@ -3314,11 +2901,9 @@ public: uint32_t getNumberOfSubstreamSizes( ) { return (uint32_t) m_substreamSizes.size(); } void addSubstreamSize( uint32_t size ) { m_substreamSizes.push_back(size); } uint32_t getSubstreamSize( uint32_t idx ) { CHECK(idx>=getNumberOfSubstreamSizes(),"Invalid index"); return m_substreamSizes[idx]; } -#if JVET_Q0151_Q0205_ENTRYPOINTS void resetNumberOfSubstream() { m_numSubstream = 0; } uint32_t getNumberOfSubstream() { return (uint32_t) m_numSubstream; } void increaseNumberOfSubstream() { m_numSubstream++; } -#endif void setCabacInitFlag( bool val ) { m_cabacInitFlag = val; } //!< set CABAC initial flag bool getCabacInitFlag() const { return m_cabacInitFlag; } //!< get CABAC initial flag @@ -3356,7 +2941,6 @@ public: m_tileGroupLumaApsId[i] = ApsIDs[i]; } } -#if JVET_Q0795_CCALF void resetTileGroupCcAlCbfEnabledFlag() { m_tileGroupCcAlfCbEnabledFlag = 0; } void resetTileGroupCcAlCrfEnabledFlag() { m_tileGroupCcAlfCrEnabledFlag = 0; } @@ -3369,35 +2953,28 @@ public: bool getTileGroupCcAlfCrEnabledFlag() { return m_tileGroupCcAlfCrEnabledFlag; } int getTileGroupCcAlfCbApsId() { return m_tileGroupCcAlfCbApsId; } int getTileGroupCcAlfCrApsId() { return m_tileGroupCcAlfCrApsId; } -#endif void setDisableSATDForRD(bool b) { m_disableSATDForRd = b; } bool getDisableSATDForRD() { return m_disableSATDForRd; } +#if JVET_R0110_MIXED_LOSSLESS + void setLossless(bool b) { m_isLossless = b; } + bool isLossless() const { return m_isLossless; } +#endif void scaleRefPicList( Picture *scaledRefPic[ ], PicHeader *picHeader, APS** apss, APS* lmcsAps, APS* scalingListAps, const bool isDecoder ); void freeScaledRefPicList( Picture *scaledRefPic[] ); bool checkRPR(); const std::pair<int, int>& getScalingRatio( const RefPicList refPicList, const int refIdx ) const { CHECK( refIdx < 0, "Invalid reference index" ); return m_scalingRatio[refPicList][refIdx]; } -#if JVET_Q0151_Q0205_ENTRYPOINTS void setNumSubstream( const SPS *sps, const PPS *pps ); void setNumEntryPoints( const SPS *sps, const PPS *pps ); -#else - void setNumEntryPoints( const PPS *pps ); -#endif uint32_t getNumEntryPoints( ) const { return m_numEntryPoints; } -#if JVET_Q0795_CCALF CcAlfFilterParam m_ccAlfFilterParam; uint8_t* m_ccAlfFilterControl[2]; -#endif protected: Picture* xGetRefPic( PicList& rcListPic, int poc, const int layerId ); Picture* xGetLongTermRefPic( PicList& rcListPic, int poc, bool pocHasMsb, const int layerId ); public: -#if JVET_Q0504_PLT_NON444 std::unordered_map< Position, std::unordered_map< Size, double> > m_mapPltCost[2]; -#else - std::unordered_map< Position, std::unordered_map< Size, double> > m_mapPltCost; -#endif private: };// END CLASS DEFINITION Slice @@ -3414,34 +2991,19 @@ public: , maxCUHeightMask ( maxCUHeight - 1 ) , maxCUWidthLog2 ( floorLog2( maxCUWidth ) ) , maxCUHeightLog2 ( floorLog2( maxCUHeight ) ) -#if JVET_Q0468_Q0469_MIN_LUMA_CB_AND_MIN_QT_FIX , minCUWidth ( 1 << MIN_CU_LOG2 ) , minCUHeight ( 1 << MIN_CU_LOG2 ) -#else - , minCUWidth ( sps.getMaxCUWidth() >> sps.getMaxCodingDepth() ) - , minCUHeight ( sps.getMaxCUHeight() >> sps.getMaxCodingDepth() ) -#endif , minCUWidthLog2 ( floorLog2( minCUWidth ) ) , minCUHeightLog2 ( floorLog2( minCUHeight ) ) -#if JVET_Q0468_Q0469_MIN_LUMA_CB_AND_MIN_QT_FIX , partsInCtuWidth ( maxCUWidth >> MIN_CU_LOG2) , partsInCtuHeight ( maxCUHeight >> MIN_CU_LOG2) , partsInCtu ( partsInCtuWidth * partsInCtuHeight ) -#else - , partsInCtuWidth ( 1 << sps.getMaxCodingDepth() ) - , partsInCtuHeight ( 1 << sps.getMaxCodingDepth() ) - , partsInCtu ( 1 << (sps.getMaxCodingDepth() << 1) ) -#endif , widthInCtus ( (pps.getPicWidthInLumaSamples () + sps.getMaxCUWidth () - 1) / sps.getMaxCUWidth () ) , heightInCtus ( (pps.getPicHeightInLumaSamples() + sps.getMaxCUHeight() - 1) / sps.getMaxCUHeight() ) , sizeInCtus ( widthInCtus * heightInCtus ) , lumaWidth ( pps.getPicWidthInLumaSamples() ) , lumaHeight ( pps.getPicHeightInLumaSamples() ) -#if JVET_Q0468_Q0469_MIN_LUMA_CB_AND_MIN_QT_FIX , fastDeltaQPCuMaxSize( Clip3(1u << sps.getLog2MinCodingBlockSize(), sps.getMaxCUHeight(), 32u) ) -#else - , fastDeltaQPCuMaxSize( Clip3(sps.getMaxCUHeight() >> (sps.getLog2DiffMaxMinCodingBlockSize()), sps.getMaxCUHeight(), 32u) ) -#endif , noChroma2x2 ( false ) , isEncoder ( _isEncoder ) , ISingleTree ( !sps.getUseDualITree() ) @@ -3500,11 +3062,7 @@ public: #if ENABLE_TRACING void xTraceVPSHeader(); -#if !JVET_Q0117_PARAMETER_SETS_CLEANUP -void xTraceDPSHeader(); -#else void xTraceDCIHeader(); -#endif void xTraceSPSHeader(); void xTracePPSHeader(); void xTraceAPSHeader(); diff --git a/source/Lib/CommonLib/TrQuant.cpp b/source/Lib/CommonLib/TrQuant.cpp index 02e7b138adb67827bb22873e0e34df7c99566684..3bb4af85d2e1eb3f4356c46213b518c0bcc49b73 100644 --- a/source/Lib/CommonLib/TrQuant.cpp +++ b/source/Lib/CommonLib/TrQuant.cpp @@ -313,11 +313,7 @@ void TrQuant::xInvLfnst( const TransformUnit &tu, const ComponentID compID ) const uint32_t width = area.width; const uint32_t height = area.height; const uint32_t lfnstIdx = tu.cu->lfnstIdx; -#if JVET_Q0784_LFNST_COMBINATION if( lfnstIdx && tu.mtsIdx[compID] != MTS_SKIP && (tu.cu->isSepTree() ? true : isLuma(compID)) ) -#else - if (lfnstIdx && tu.mtsIdx[compID] != MTS_SKIP && width >= 4 && height >= 4) -#endif { const bool whge3 = width >= 8 && height >= 8; const ScanElement * scan = whge3 ? g_coefTopLeftDiagScan8x8[ gp_sizeIdxInfo->idxFrom( width ) ] : g_scanOrder[ SCAN_GROUPED_4x4 ][ SCAN_DIAG ][ gp_sizeIdxInfo->idxFrom( width ) ][ gp_sizeIdxInfo->idxFrom( height ) ]; @@ -408,11 +404,7 @@ void TrQuant::xFwdLfnst( const TransformUnit &tu, const ComponentID compID, cons const uint32_t width = area.width; const uint32_t height = area.height; const uint32_t lfnstIdx = tu.cu->lfnstIdx; -#if JVET_Q0784_LFNST_COMBINATION if( lfnstIdx && tu.mtsIdx[compID] != MTS_SKIP && (tu.cu->isSepTree() ? true : isLuma(compID)) ) -#else - if( lfnstIdx && tu.mtsIdx[compID] != MTS_SKIP && width >= 4 && height >= 4) -#endif { const bool whge3 = width >= 8 && height >= 8; const ScanElement * scan = whge3 ? g_coefTopLeftDiagScan8x8[ gp_sizeIdxInfo->idxFrom( width ) ] : g_scanOrder[ SCAN_GROUPED_4x4 ][ SCAN_DIAG ][ gp_sizeIdxInfo->idxFrom( width ) ][ gp_sizeIdxInfo->idxFrom( height ) ]; diff --git a/source/Lib/CommonLib/TypeDef.h b/source/Lib/CommonLib/TypeDef.h index 9f23764b14661e75eac2aceaf45984cefcee246c..b329cfbe2f07e6c22502e4a4e497979f3bf97f57 100644 --- a/source/Lib/CommonLib/TypeDef.h +++ b/source/Lib/CommonLib/TypeDef.h @@ -50,277 +50,143 @@ #include <assert.h> #include <cassert> -#define JVET_Q0488_SEI_REPETITION_CONSTRAINT 1 // JVET-Q0488: SEI repetition constraint - -#define JVET_Q0237_STSA_TID_ZERO_DEPLAYER 1 // JVET-Q0237: STSA picture with TemporalId equal to 0 in a dependent layer - -#define JVET_Q0798_SPS_NUMBER_MERGE_CANDIDATE 1 // JVET-Q0798: signal the number of merge candidates in SPS - -#define JVET_Q0157_SUBPICTURE_REORDERING_CONSTRAINT 1 //JVET-Q0157: subpicture reordering constraint - -#define JVET_P0118_HRD_ASPECTS 1 //JVET-P0118: HRD aspects - -#define JVET_Q0371_DEBLOCKING_CLEANUP 1 //JVET_Q0371: cleanup on deblocking across subpicture boundaries - -#define JVET_Q0289_BUGFIX_RECT_SLICE_FLAG 1 //JVET-Q0289: If NumTilesInPic is equal to 1, don't signal the rect_slice_flag and infer its value to be 1. - -#define CABAC_RETRAIN 1 // CABAC retraining based on VTM8rc1 - -#define JVET_Q0210_SUBPIC_VIRTUAL_BOUNDARY_CONSTRAINT 1 // JVET-Q0210 (aspect 7): when subpicture signalling is present, virtual boundaries if present shall be in the SPS. - -#define JVET_Q0246_VIRTUAL_BOUNDARY_ENABLE_FLAG 1 // JVET-Q0246: virtual boundary enable flag in the SPS. - -#define JVET_Q0244 1 // JVET-Q0244 Aspect 3: Signal the slice width(height) in tiles when the number of tile columns(rows) is greater than 1. - -#define JVET_Q0355_DCI_LEVEL_IDC_CONSTRAINT 1 // JVET-Q0355: max level signaled in the DCI shall not be less than the level signaled in the SPS - -#define JVET_P0115_LAYER_TID_CONSTRAINT 1 // JVET-P0115: bitstream shall not contain any other layers than included in the OLS with OlsIdx and shall not include any NAL unit with TemporalId greater than HighestTid - -#define JVET_Q0359_TILE_SIZE_CONSTRAINT 1 // JVET-Q0359: sum of the explicit signaled tile size shall less than or equal to pic size - -#define JVET_Q0044_SLICE_IDX_WITH_SUBPICS 1 // JVET-Q0044: slice index with subpictures - -#define JVET_P0125_ASPECT_TID_LAYER_ID_NUH 1 // JVET-P0125: Aspects of constraints on TemporalId and nuh_layer_id -#define JVET_P0125_SEI_CONSTRAINTS 1 // JVET-P0125: 4th aspect: SEI constraints - -#define JVET_Q0471_CHROMA_QT_SPLIT 1 // JVET-Q0471: Chroma QT split - -#define JVET_P0117_PTL_SCALABILITY 1 // JVET-P0117: sps_ptl_dpb_hrd_params_present_flag related syntax change, others in JVET-Q0786 - -#define JVET_Q0358_ALF_NALU_TID_CONSTRAINT 1 // JVET-Q0358: TemporalId constraint between ALF_APS NALU and the pic associated with PH - -#define JVET_Q0118_CLEANUPS 1 // JVET-Q0118: AHG8/AHG9: Scalability HLS cleanups - -#define JVET_Q0416_WRAPAROUND_OFFSET 1 //JVET-Q0416: subtract CtbSizeY / MinCbSizeY + 2 from wraparound offset before signaling - -#define JVET_P0125_EOS_LAYER_SPECIFIC 1 // JVET-P0125: Specify EOS NAL units to be layer specific - -#define JVET_Q0482_REMOVE_CONSTANT_PARAMS 1 // JVET-Q0482: Remove constant slice header parameter settings in PPS - -#if JVET_Q0482_REMOVE_CONSTANT_PARAMS -#define JVET_Q0259_COLLOCATED_PIC_IN_PH 1 // JVET-Q0259 aspect 5: Include collocated pic in PH when TMVP enabled and rpl_info_in_ph_flag is 1 -#endif - -#define JVET_Q0505_CHROAM_QM_SIGNALING_400 1 //JVET-Q0505: Cleanup of chroma quantization matrix signaling for 400 color format - -#define JVET_Q0786_PTL_only 1 // JVET-Q0786: modifications to VPS syntax - PTL part only (signal PTL for single layer OLSs) - -#define JVET_P0116_POC_MSB 1 // JVET-P0116: use POC MSB cycle signalling for independent layers,to support of mixed IRAP and non-IRAP pictures within an AU - -#define JVET_P0978_RPL_RESTRICTIONS 1 // JVET-P0978: A set of RPL-related bitstream conformance restrictions - -#define JVET_Q0468_Q0469_MIN_LUMA_CB_AND_MIN_QT_FIX 1 // JVET-Q0468: add support of min Luma coding block size; JVET-Q0469: fix for signaling of Intra Chroma Min QT size - -#define JVET_Q0260_CONFORMANCE_WINDOW_IN_SPS 1 // JVET-Q0260: Conformance cropping window in the SPS that applies to the max picture size - -#define JVET_Q0210_UEK_REMOVAL 1 // JVET-Q0210 Aspect 8: Replace uek signalling in alf_data with ue(v). - -#define JVET_Q0449_RPR_NO_SMOOTHING 1 // JVET-Q0449: Disable smoothing half-sample interpolation filter in conjunction with RPR - -#define JVET_Q0493_PLT_ENCODER_LOSSLESS 1 // JVET-Q0493: Palette encoder improvements for lossless coding - -#define JVET_Q0629_REMOVAL_PLT_4X4 1 // JVET-Q0629: Removal of 4x4 blocks in palette mode - -#define JVET_Q0291_REDUCE_DUALTREE_PLT_SIZE 1 // JVET-Q0291: reduce palette size of dual tree from 31 to 15 and palette predictor size of dual tree from 63 to 31 - -#define JVET_Q0330_BLOCK_PARTITION 1 // JVET-Q0330: fix the block partitioning at picture boundary - -#define JVET_Q0417_CONSTRAINT_SPS_VB_PRESENT_FLAG 1 // JVET_Q0417: a constraint on the value of sps_virtual_boundaries_present_flag based on res_change_in_clvs_allowed_flag +//########### place macros to be removed in next cycle below this line ############### -#define JVET_Q0179_SCALING_WINDOW_SIZE_CONSTRAINT 1 // JVET-Q0179: Scaling window size constraint for constraining worst case memory bandwidth - -#define JVET_Q0257_SCALING_WINDOW_CONSTRAINT 1 // JVET-Q0257: Constraint expression to limit actual scaling ratios rather than the picture sizes - -#define JVET_P2008_OUTPUT_LOG 1 // Output log file for conformance tests - -#define JVET_P0097_REMOVE_VPS_DEP_NONSCALABLE_LAYER 1 // Removing dependencies on VPS from the decoding process of a non-scalable bitstream - -#define JVET_Q0420_PPS_CHROMA_TOOL_FLAG 1 // JVET-Q0420: add pps_chroma_tool_offsets_present_flag in PPS - -#define JVET_Q0172_CHROMA_FORMAT_BITDEPTH_CONSTRAINT 1 // JVET-Q0172: Disallow differing chroma format and different bit depths for cross-layer prediction. - -#define JVET_Q0491_PLT_ESCAPE 1 // JVET-Q0491: Palette escape binarization - -#define JVET_Q414_CONSTRAINT_ON_GDR_PIC_FLAG 1 //JVET-Q0414: when gdr_enabled_flag is equal to 0, gdr_pic_flag shall be 0 - -#define JVET_Q0817 1 // JVET_Q0817: Remove the constraint on single_slice_per_subpic_flag - -#define JVET_Q0413_SKIP_LAST_SUBPIC_SIG 1 //JVET-Q0413 modification 2: skip the width and height signaling of last subpicture - -#define JVET_Q0169_SUBPIC_LEN_CONFORM 1 // JVET-Q0169: add bitstream conformance check on subpic length +#define JVET_Q0488_SEI_REPETITION_CONSTRAINT 1 // JVET-Q0488: SEI repetition constraint -#define JVET_Q0504_PLT_NON444 1 // JVET-Q0504: enable palette mode for non 444 color format +#define JVET_R0055_HANDLING_NON_EXISTENT_QM 1 // JVET-R0055: infer chroma scaling lists to be all 16 in 4:0:0 by copy mode flag -#define JVET_Q0183_SPS_TRANSFORM_SKIP_MODE_CONTROL 1 // JVET-Q0183: Signal the max block size in SPS and conditionally signal min_qp_prime_ts_minus4 +#define JVET_R0097_MAX_TRSIZE_CONDITIONALY_SIGNALING 1 // JVET-R0097: Aspect 1, If the luma CTB size is not larger than 32, sps_max_luma_transform_size_64_flag is not signalled and inferred to be 0 -#define JVET_Q0089_SLICE_LOSSLESS_CODING_CHROMA_BDPCM 1 // JVET-Q0089: RRC slice-level switch for lossless coding and one SPS flag for luma and chroma BDPCM. +#define JVET_R0483_SH_TSRC_DISABLED_FLAG_CLEANUP 1 // JVET-R0483 Comb 4: R0049 + R0271, only R0049 method 3 aspect (Skip signaling sh_ts_residual_coding_disabled_flag when sps_transform_skip_enabled_flag = 0, also proposed in R0068, R0097, R0142, R0153) as R0271 has its own macro -#define JVET_Q0816 1 // JVET_Q0816: Omit the signalling of subpic layout when there is only one subpicture +#define JVET_R0380_SCALING_MATRIX_DISABLE_YCC_OR_RGB 1 // JVET-R0380 solution3-3: Disable scaling matrix for blocks coded in alternative colour space. -#define JVET_Q0438_MONOCHROME_BUGFIXES 1 // JVET-Q0438: Monochrome bug fixes +#define R0091_CONSTRAINT_SLICE_ORDER 1 // JVET-R0091: constraint slice signalling order to be the same as slice coding order -#define JVET_Q0441_SAO_MOD_12_BIT 1 // JVET-Q0441: SAO modification for 12 bit. Also removes old HEVC RExt SAO modification, which was broken. +#define JVET_R0161_CONDITION_SIGNAL_PTL_IDX 1 // JVET_R0161 proposal 2: skip PTL index signaling when number of signaled PTL structure is equal to number of OLSs -#define JVET_Q0043_RPR_and_Subpics 1 // JVET-Q0043: Disallow for both RPR and subpics to be used together +#define JVET_R0165_OPTIONAL_ENTRY_POINT 1 // JVET-R0165: Optional entry point offset -#define JVET_Q0818_PT_SEI 1 // JVET-Q0818: add display_elemental_periods_minus1 to picture timing SEI message +#define JVET_R0166_SCALING_LISTS_CHROMA_444 1 // JVET-R0166: Scaling list for Chroma 444 -#define JVET_Q0343_GCMP_GUARD_BAND_TYPE 1 // JVET-Q0343: Add gcmp_guard_band_type to generalized cubemap projection SEI message and rename boundary guard band +#define JVET_R0191_ASPECT3 1 // JVET-R0191#3: Modify the upper range of vps_num_dpb_params and num_ols_hrd_params_minus1 to be total number of OLSs minus the number of single-layer OLSs + // Constrain that each PTL, DPB, and HRD params in VPS are referred to at least once -#define JVET_Q0110_Q0785_CHROMA_BDPCM_420 1 // JVET-Q0110/Q0785: Enable chroma BDPCM for 420, separate contexts for chroma BDPCM and bug-fixes. +#define R0324_PH_SYNTAX_CONDITION_MODIFY 1 // JVET-R0324 add conditions on PH syntax to conder whether current pic is bi-predictive picture -#define JVET_Q0042_VUI 1 // Modifications to VUI syntax +#define JVET_R0278_CONSTRAINT 1 // JVET-R0278: ph_inter_slice_allowed_flag constraint -#define JVET_Q0512_ENC_CHROMA_TS_ACT 1 // JVET-Q0512: encoder-side improvement on enabling chroma transform-skip for ACT +#define JVET_R0276_REORDERED_SUBPICS 1 // JVET-R0276: reference picture constraint for reordered sub-pictures -#define JVET_P0101_POC_MULTILAYER 1 // POC derivation for pictures in dependent layers +#define JVET_R0130_TC_DERIVATION_BUGFIX 1 // JVET-R0130: Cleanup of tC derivation for deblocking filter -#define JVET_Q0446_MIP_CONST_SHIFT_OFFSET 1 // JVET-Q0446: MIP with constant shift and offset +#define JVET_R0334_PLT_CLEANUP 1 // JVET-R0334: Disable chroma palette for local dual tree -#define JVET_Q0265 1 // JVET-Q0265: Cleanup for monochrome and independently coded color planes +#define JVET_R0286_GCI_CLEANUP 1 // JVET-R0286: Sensibility constraints and general constraints on tools -#define JVET_Q0447_WP_PARAM_ESTIM 1 // JVET-Q0447: Add search iterations for method 2,3 and 4 +#define JVET_R0090_VUI 1 // JVET-R0090: Fix parsing dependencies in VUI syntax -#define JVET_Q0119_CLEANUPS 1 // JVET-Q0119: AHG12: Cleanups on signalling of subpictures, tiles, and rectangular slices +#define JVET_R0205 1 // JVET-R0205: Condition presence of inter_layer_ref_pics_present_flag on sps_video_parameter_set_id -#define JVET_Q0114_CONSTRAINT_FLAGS 1 // JVET-Q0114: AHG9: A few more general constraints flags +#define JVET_R0277_RPL 1 // JVET-R0277: Modified condition for sh_num_ref_idx_active_override_flag, inference for sh_collocated_from_l0_flag equal to 1 for P-slices -#define JVET_Q0820_ACT 1 // JVET-Q0820: ACT bug fixes and reversible ACT transform +#define JVET_R0275_SPS_PTL_DBP_HRD 1 // JVET-R0275: Modified constraint for sps_ptl_dpb_hrd_params_present_flag -#define JVET_Q0814_DPB 1 // JVET-Q0814: DPB capacity is based on picture units regardless of the resoltuion -#define ENABLING_MULTI_SPS 1 // Bug fix to enable multiple SPS -#define SPS_ID_CHECK 1 // add SPS id check to be the same within CLVS, related to mixed_nalu_types_in_pic_flag -#define JVET_P0124_MIXED_NALU 1 // JVET-P0124/P0095/P0222: MIxed IRAP/non-IRAP VCL NAL units within a picture -#define JVET_Q0117_PARAMETER_SETS_CLEANUP 1 // JVET-Q0117: cleanups on parameter sets +#define JVET_R0186_CLEANUP 1 // JVET-R0186 aspect 1: Signal the pps_no_pic_partition_flag ahead in the PPS. -#define JVET_Q0751_MIXED_NAL_UNIT_TYPES 1 // JVET-Q0751: Constraints and properties of mixed nal unit types +#define JVET_R0225_SEPERATE_FLAGS_ALF_CHROMA 1 // Use two separate flags (one for Cb, one for Cr) to replace ph_alf_chroma_idc in PH and sh_alf_chroma_idc in SH -#define JVET_Q0353_ACT_SW_FIX 1 // JVET-Q0353: Bug fix of ACT +#define JVET_R0266_DESC 1 // JVET-R0266: change the signalling of the PPS ID from ue(v) to u(6); Code virtual boundary positions using ue(v) -#define JVET_P0288_PIC_OUTPUT 1 // JVET-P0288: Set the value of PictureOutputFlag +#define JVET_R0094_DPB_TID_OFFSET 1 // JVET-R0094: DPB output temporal ID offsets -#define JVET_Q0695_CHROMA_TS_JCCR 1 // JVET-Q0695: Enabling the RD checking of chroma transform-skip mode for JCCR at encoder -#define JVET_Q0500_CCLM_REF_PADDING 1 // JVET-Q0500: Reference samples padding for CCLM +#define JVET_R0437_BS_DERIVATION 1 // JVET-R0437: fix the bS derivation for palette mode -#define JVET_Q0128_DMVR_BDOF_ENABLING_CONDITION 1 // JVET-Q0128: Cleanup of enabling condition for DMVR and BDOF +#define JVET_R0110_MIXED_LOSSLESS 1 // JVET-R0110: Slice level mixed lossy/lossless coding: encoder only method -#define JVET_Q0784_LFNST_COMBINATION 1 // lfnst signaling, latency reduction and a bugfix for scaling from Q0106, Q0686, Q0133 +#define JVET_R0267_IDR_RPL 1 // JVET-R0267: Add RPL constraint for IDR picture -#define JVET_Q0501_PALETTE_WPP_INIT_ABOVECTU 1 // JVET-Q0501: Initialize palette predictor from above CTU row in WPP +#define JVET_R0330_CRS_CLIP_REM 1 // JVET-R0330: Remove redundant clipping in chroma residual scaling factor derivation -#define JVET_Q0503_Q0712_PLT_ENCODER_IMPROV_BUGFIX 1 // JVET-Q0503/Q0712: Platte encoder improvement/bugfix +#define JVET_R0059_RPL_CLEANUP 1 // JVET-R0059 aspect 2: Condition the signalling of ltrp_in_header_flag[ listIdx ][ rplsIdx ]. -#define JVET_Q0819_PH_CHANGES 1 // JVET-Q0819: Combination of PH related syntax changes +#define JVET_R0202_WHEN_PH_IN_SH_INFO_FLAGS_EQUAL_0 1 // JVET-R0202 When sh_picture_header_in_slice_header_flag is equal to 1, rpl_info_in_ph_flag, dbf_info_in_ph_flag, sao_info_in_ph_flag, wp_info_in_ph_flag, qp_delta_info_in_ph_flag shall be be equal to 0 -#define JVET_Q0481_PARTITION_CONSTRAINTS_ORDER 1 // JVET-Q0481: Ordering of partition constraints syntax elements in the SPS +#define JVET_R0201_PREFIX_SUFFIX_APS_CLEANUP 1 // JVET-R0201 Cleanups on Prefix and Suffix APS -#define JVET_Q0155_COLOUR_ID 1 // JVET-Q0155: move colour_plane_id from PH to SH +#define JVET_R0202_WHEN_PH_IN_SH_NO_SUBPIC_SEPARATE_COLOR 1 // JVET-R0202 Add constraints when sh_picture_header_in_slice_header_flag equal to 1 sps_subpic_info_present_flag and separate_colour_plane_flag shall be equal to 0 -#define JVET_Q0444_AMVR_SIGNALLING 1 // JVET-Q0444: Conditional signaling of sps_affine_amvr_enabled_flag based on sps_amvr_enabled_flag +#define JVET_R0247_PPS_LP_FTR_ACROSS_SLICES_FLAG_CLEANUP 1 // JVET-R0247: Skip pps_loop_filter_across_slices_enabled_flag when the picture contains one slice -#define JVET_Q0147_JCCR_SIGNALLING 1 // JVET-Q0147: Conditional signaling of sps_joint_cbcr_enabled_flag based on ChromaArrayType +#define JVET_R0327_ONE_PASS_CCALF 1 // JVET-R0327: One-pass CCALF -#define JVET_Q0346_LMCS_ENABLE_IN_SH 1 // JVET-Q0346 aspect 1: LMCS enabled flag in SH +#define JVET_R0200_MOVE_LMCS_AND_SCALING_LIST_SE 1 // JVET-R0200 Move the SH flags slice_lmcs_enabled_flag and slice_explicit_scaling_list_used_flag to be just after the ALF parameters -#if JVET_Q0819_PH_CHANGES -#define JVET_Q0346_SCALING_LIST_USED_IN_SH 1 // JVET-Q0346 aspect 2: Scaling list used flag in SH +#if JVET_R0200_MOVE_LMCS_AND_SCALING_LIST_SE +#define JVET_R0098_LMCS_AND_SCALING_LISTS_FOR_PH_IN_SH 1 // JVET-R0098: Only signall LMCS and explicit scaling list enable flags in SH when PH is not in SH #endif -#define JVET_Q0267_RESET_CHROMA_QP_OFFSET 1 // JVET-Q0267: Reset chroma QP offsets at the start of each chroma QP offset group - -#define JVET_Q0293_REMOVAL_PDPC_CHROMA_NX2 1 // JVET-Q0293: Removal of chroma Nx2 blocks in PDPC +#define JVET_R0388_DBF_CLEANUP 1 // JVET-R0388: Cleanups on deblocking signalling -#define JVET_Q0121_DEBLOCKING_CONTROL_PARAMETERS 1 // JVET-Q0121: Add deblocking control parameters for Cb and Cr and extend the parameter ranges +#define JVET_R0114_NEGATIVE_SCALING_WINDOW_OFFSETS 1 // JVET-R0114: Allow negative scaling window offsets -#define JVET_Q0517_RPR_AFFINE_DS 1 // JVET-Q0517: affine down-sampling filters for RPR +#define JVET_R0071_SPS_PPS_CELANUP 1 // JVET-R0071 item 2-4: cleanups on subpicture signalling (item 1 has been ported in JVET_R0156_ASPECT4) -#define JVET_Q0151_Q0205_ENTRYPOINTS 1 // JVET-Q0151 & JVET-Q0205: Make mandatory the tile offsets signalling and move the entropy_coding_sync_enabled_flag entry_point_offsets_present_flag syntax elements to the SPS from the PPS +#define JVET_R0271_SLICE_LEVEL_DQ_SDH_RRC 1 // JVET-R0271/R0155: Slice level DQ and SDH granularity for mixed lossy/lossless. -#define JVET_Q0203_MULTI_SLICE_IN_TILE 1 // JVET-Q0203: Signalling of multiple rectangular slices within a tile +#define JVET_R0143_TSRCdisableLL 1 // JVET-R0143: disable TSRC for lossless coding -#define JVET_O1143_SUBPIC_BOUNDARY 1 // treat subpicture boundary as picture boundary +#define JVET_R0371_MAX_NUM_SUB_BLK_MRG_CAND 1 // JVET-R0371: set the range of max number of subblock based merge candidate to 0 to 5 - sps_sbtmvp_enabled_flag. -#if JVET_O1143_SUBPIC_BOUNDARY -#define JVET_O1143_LPF_ACROSS_SUBPIC_BOUNDARY 1 -#define JVET_O1143_MV_ACROSS_SUBPIC_BOUNDARY 1 -#endif +#define JVET_R0113_AND_JVET_R0106_PPS_CLEANUP 1 // JVET-R0113 and JVET-R0106: Cleanup in Picture Parameter Set -#define JVET_Q0495_NLALF_CLIP_CLEANUP 1 // JVET-Q0495: Cleanup of clipping table for NL-ALF +#define JVET_R0233_CCALF_LINE_BUFFER_REDUCTION 1 // JVET-R0233 method 2: Line buffer reduction for CCALF -#define JVET_Q0156_STSA 1 // JVET-Q0156: Enable inter-layer prediction for STSA pictures +#define JVET_Q0471_CHROMA_QT_SPLIT 0 // JVET-Q0471: Chroma QT split, reverted by JVET-R0131 +#define JVET_R0208_ALF_VB_ROUNDING_FIX 1 // JVET-R0208: Rounding offset fix for ALF virtual boundary processing +#define JVET_R0232_CCALF_APS_CONSTRAINT 1 // JVET-R0232 section 3.2: APS contraint for CCALF +#define JVET_R0210_NUMTILESINSLICE_SIGNALLING 1 // JVET-R0210 section 3.3: Don't signal NumTilesInSlice syntax element when numTilesInPic - slice_address is 1. -#define JVET_Q0249_ALF_CHROMA_CLIPFLAG 1 // JVET-Q0249: Cleanup of chroma clipping flags for ALF -#define JVET_Q0150 1 // fix for ALF virtual horizontal CTU boundary processing -#define JVET_Q0054 1 // fix for long luma deblocking decision -#define JVET_Q0795_CCALF 1 // Cross-component ALF -#define JVET_Q0297_MER 1 // JVET_Q0297: Merge estimation region -#define JVET_Q0483_CLIP_TMVP 1 // JVET-Q0483: Clip TMVP when no scaling is applied -#define JVET_Q0516_MTS_SIGNALLING_DC_ONLY_COND 1 // JVET-Q0516/Q0685: disable MTS when there is only DC coefficient -#define JVET_Q0806 1 // Geo related adoptions (JVET-Q0059, JVET-Q0077, JVET-Q0123, JVET-Q0188, JVET-Q0242_GEO, JVET-Q0309, JVET-Q0365 and JVET-Q0370) +#define JVET_R0156_ASPECT4_SPS_CLEANUP 1 // JVET-R0071 #1, R0156 #4, R0284 #1: Condition sps_independent_subpics_flag on "sps_num_subpics_minus1 > 0" -#define JVET_Q0055_MTS_SIGNALLING 1 // JVET-Q0055: Check for transform coefficients outside the 16x16 area -#define JVET_Q0480_RASTER_RECT_SLICES 1 // JVET-Q0480: Eliminate redundant slice height syntax when in raster rectangular slice mode (tile_idx_delta_present_flag == 0) +#define JVET_R0156_ASPECT3_SPS_CLEANUP 1 // Condition sps_sublayer_dpb_params_flag on sps_ptl_dpb_hrd_params_present_flag, in addition to sps_max_sublayer_minus1, JVET-R0156 proposal 3, JVET-R0170, JVET-R0222 proposal 2 -#define JVET_Q0775_PH_IN_SH 1 // JVET-Q0755: Allow picture header in slice header -#define JVET_Q0433_MODIFIED_CHROMA_DIST_WEIGHT 1 // modification of chroma distortion weight (as agreed during presentation of JVET-Q0433) +#define JVET_R0350_MIP_CHROMA_444_SINGLETREE 1 // JVET-R0350: MIP for chroma in case of 4:4:4 format and single tree -#define JVET_P0188_MINCR 1 // JVET-P0188: Add MinCR checking in encoder. -#define JVET_Q0436_CABAC_ZERO_WORD 1 // JVET-Q0436: Add modified CABAC zero word insertion in encoder. +#define JVET_R0347_MTT_SIZE_CONSTRAIN 1 // JVET-R0347: Set upper limit of minQtSize and maxTtSize to 64, set upper limit of maxBtSize to 64 in chroma-tree -#define JVET_Q0487_SCALING_WINDOW_ISSUES 1 // JVET-Q0487: Fix scaling window issues when scaling ratio is 1:1 +#define JVET_R0045_TS_MIN_QP_CLEANUP 1 // JVET-R0045: Cleanup for signalling of minimum QP of transform skip -#define JVET_Q0787_SUBPIC 1 // JVET-Q0787: fix subpicture location signalling +#define JVET_Q0394_TIMING_SEI 1 // JVET_Q0394: Picture timing for OLSs -#define JVET_Q0400_EXTRA_BITS 1 // JVET-Q0400: reserved bits for future extensions +#define JVET_R0100 1 // JVET-R0100: Proposal 1 DUI Signalling and inference -#define JVET_AHG14_LOSSLESS 1 -#define JVET_AHG14_LOSSLESS_ENC_QP_FIX 1 && JVET_AHG14_LOSSLESS - -#define JVET_M0497_MATRIX_MULT 0 // 0: Fast method; 1: Matrix multiplication +#define JVET_R0413_HRD_TIMING_INFORMATION 1 // JVET-R0413: HRD timing parameters signalling -#define JVET_Q0221 1 // JVET-Q0221: Decoding unit parameter signalling +//########### place macros to be be kept below this line ############### -#define JVET_Q0216 1 // JVET-Q0216: modification to picture timing SEI message +#define JVET_R0164_MEAN_SCALED_SATD 1 // JVET-R0164: Use a mean scaled version of SATD in encoder decisions -#define JVET_Q0218_PROPOSAL3 1 // JVET-Q0218_PROPOSAL3: fix missing inference rule for single_slice_per_subpic_flag +#define JVET_M0497_MATRIX_MULT 0 // 0: Fast method; 1: Matrix multiplication #define APPLY_SBT_SL_ON_MTS 1 // apply save & load fast algorithm on inter MTS when SBT is on -#define REMOVE_PPS_REXT 1 // remove RExt PPS extension - -#define JVET_P0118_OLS_EXTRACTION 1 // OLS based sub-bitstream extraction - -#define JVET_Q0397_SUB_PIC_EXTRACT 1 // subpicture extraction - -#define JVET_Q0218_PROPOSAL1 1 // JVET-Q0218_PROPOSAL1: Conditionally signal tile_idx_delta_present_flag - -#define JVET_Q0219_SIGNAL_ALT_BUFFER_DELAY_PARMS 1 // JVET-Q0219: Signal alternative buffering delay parameters - -#define JVET_Q0399_SCALING_INFERENCE 1 // JVET-Q0399 infer scaling window to conformance window, if not present - -#define JVET_Q0630_SUBPIC_LEVEL 1 // JVET-Q0630 parsing dependency fix for subpicture level info SEI - -#define JVET_SUBPIC_LEVEL_CFG 1 // improved configuration of subpicture level info SEI - typedef std::pair<int, bool> TrMode; typedef std::pair<int, int> TrCost; // clang-format off -#define REUSE_CU_RESULTS 1 +#define REUSE_CU_RESULTS 1 #if REUSE_CU_RESULTS #define REUSE_CU_RESULTS_WITH_MULTIPLE_TUS 1 #endif // clang-format on -#define JVET_P0190_SCALABLE_NESTING_SEI 1 // JVET-P0190 scalable nesting sei message - -#define JVET_Q0222_SUBPICTURE_SIGNALLING 1 // JVET-Q0222_Proposal1: Inference rule to signal horizontal and vertical position of the top left CTU of 0-th subpicture - #ifndef JVET_J0090_MEMORY_BANDWITH_MEASURE #define JVET_J0090_MEMORY_BANDWITH_MEASURE 0 #endif @@ -515,14 +381,6 @@ typedef uint64_t Distortion; ///< distortion measurement // Enumeration // ==================================================================================================================== -#if !JVET_Q0089_SLICE_LOSSLESS_CODING_CHROMA_BDPCM -enum BDPCMControl -{ - BDPCM_INACTIVE = 0, - BDPCM_LUMAONLY = 1, - BDPCM_LUMACHROMA = 2, -}; -#endif enum ApsType { @@ -623,11 +481,7 @@ enum SliceType NUMBER_OF_SLICE_TYPES = 3 }; -#if JVET_Q0265 /// chroma formats (according to how the monochrome or the color planes are intended to be coded) -#else -/// chroma formats (according to semantics of chroma_format_idc) -#endif enum ChromaFormat { CHROMA_400 = 0, @@ -803,12 +657,8 @@ enum DFunc DF_SAD_INTERMEDIATE_BITDEPTH = 63, -#if JVET_Q0806 DF_SAD_WITH_MASK = 64, DF_TOTAL_FUNCTIONS = 65 -#else - DF_TOTAL_FUNCTIONS = 64 -#endif }; /// motion vector predictor direction used in AMVP @@ -1044,11 +894,7 @@ enum NalUnitType NAL_UNIT_RESERVED_IRAP_VCL_11, NAL_UNIT_RESERVED_IRAP_VCL_12, -#if JVET_Q0117_PARAMETER_SETS_CLEANUP NAL_UNIT_DCI, // 13 -#else - NAL_UNIT_DPS, // 13 -#endif NAL_UNIT_VPS, // 14 NAL_UNIT_SPS, // 15 NAL_UNIT_PPS, // 16 @@ -1089,14 +935,6 @@ enum MergeType NUM_MRG_TYPE // 5 }; -#if !JVET_Q0806 -enum TriangleSplit -{ - TRIANGLE_DIR_135 = 0, - TRIANGLE_DIR_45, - TRIANGLE_DIR_NUM -}; -#endif ////////////////////////////////////////////////////////////////////////// // Encoder modes to try out diff --git a/source/Lib/CommonLib/Unit.cpp b/source/Lib/CommonLib/Unit.cpp index 03b0cf861927dee870906902dcbbf9d0c7194968..39b239117ff3a97a927accc82d5291389dab82a7 100644 --- a/source/Lib/CommonLib/Unit.cpp +++ b/source/Lib/CommonLib/Unit.cpp @@ -266,11 +266,7 @@ CodingUnit& CodingUnit::operator=( const CodingUnit& other ) affine = other.affine; affineType = other.affineType; colorTransform = other.colorTransform; -#if !JVET_Q0806 - triangle = other.triangle; -#else geoFlag = other.geoFlag; -#endif bdpcmMode = other.bdpcmMode; bdpcmModeChroma = other.bdpcmModeChroma; qp = other.qp; @@ -330,11 +326,7 @@ void CodingUnit::initData() affine = false; affineType = 0; colorTransform = false; -#if !JVET_Q0806 - triangle = false; -#else geoFlag = false; -#endif bdpcmMode = 0; bdpcmModeChroma = 0; qp = 0; @@ -378,12 +370,10 @@ const bool CodingUnit::isSepTree() const return treeType != TREE_D || CS::isDualITree( *cs ); } -#if JVET_Q0504_PLT_NON444 const bool CodingUnit::isLocalSepTree() const { return treeType != TREE_D && !CS::isDualITree(*cs); } -#endif const bool CodingUnit::checkCCLMAllowed() const { @@ -473,12 +463,6 @@ const uint8_t CodingUnit::checkAllowedSbt() const { return 0; } -#if !JVET_Q0806 - if( triangle ) - { - return 0; - } -#endif uint8_t sbtAllowed = 0; int cuWidth = lwidth(); @@ -545,15 +529,9 @@ void PredictionUnit::initData() mergeFlag = false; regularMergeFlag = false; mergeIdx = MAX_UCHAR; -#if !JVET_Q0806 - triangleSplitDir = MAX_UCHAR; - triangleMergeIdx0 = MAX_UCHAR; - triangleMergeIdx1 = MAX_UCHAR; -#else geoSplitDir = MAX_UCHAR; geoMergeIdx0 = MAX_UCHAR; geoMergeIdx1 = MAX_UCHAR; -#endif mmvdMergeFlag = false; mmvdMergeIdx = MAX_UINT; interDir = MAX_UCHAR; @@ -602,15 +580,9 @@ PredictionUnit& PredictionUnit::operator=(const InterPredictionData& predData) mergeFlag = predData.mergeFlag; regularMergeFlag = predData.regularMergeFlag; mergeIdx = predData.mergeIdx; -#if !JVET_Q0806 - triangleSplitDir = predData.triangleSplitDir ; - triangleMergeIdx0 = predData.triangleMergeIdx0 ; - triangleMergeIdx1 = predData.triangleMergeIdx1 ; -#else geoSplitDir = predData.geoSplitDir; geoMergeIdx0 = predData.geoMergeIdx0; geoMergeIdx1 = predData.geoMergeIdx1; -#endif mmvdMergeFlag = predData.mmvdMergeFlag; mmvdMergeIdx = predData.mmvdMergeIdx; interDir = predData.interDir; @@ -654,15 +626,9 @@ PredictionUnit& PredictionUnit::operator=( const PredictionUnit& other ) mergeFlag = other.mergeFlag; regularMergeFlag = other.regularMergeFlag; mergeIdx = other.mergeIdx; -#if !JVET_Q0806 - triangleSplitDir = other.triangleSplitDir ; - triangleMergeIdx0 = other.triangleMergeIdx0 ; - triangleMergeIdx1 = other.triangleMergeIdx1 ; -#else geoSplitDir = other.geoSplitDir; geoMergeIdx0 = other.geoMergeIdx0; geoMergeIdx1 = other.geoMergeIdx1; -#endif mmvdMergeFlag = other.mmvdMergeFlag; mmvdMergeIdx = other.mmvdMergeIdx; interDir = other.interDir; @@ -771,9 +737,6 @@ void TransformUnit::initData() { cbf[i] = 0; rdpcm[i] = NUMBER_OF_RDPCM_MODES; -#if !REMOVE_PPS_REXT - compAlpha[i] = 0; -#endif mtsIdx[i] = MTS_DCT2_DCT2; } depth = 0; @@ -791,12 +754,8 @@ void TransformUnit::init(TCoeff **coeffs, Pel **pcmbuf, bool **runType) m_pcmbuf[i] = pcmbuf[i]; } -#if JVET_Q0438_MONOCHROME_BUGFIXES // numBlocks is either 1 for 4:0:0, or 3 otherwise. It would perhaps be better to loop over getNumberValidChannels(*cs->pcv.chrFormat) for m_runType. for (uint32_t i = 0; i < std::max<uint32_t>(2, numBlocks)-1; i++) -#else - for (uint32_t i = 0; i < numBlocks - 1; i++) -#endif { m_runType[i] = runType[i]; } @@ -821,9 +780,6 @@ TransformUnit& TransformUnit::operator=(const TransformUnit& other) } cbf[i] = other.cbf[i]; rdpcm[i] = other.rdpcm[i]; -#if !REMOVE_PPS_REXT - compAlpha[i] = other.compAlpha[i]; -#endif mtsIdx[i] = other.mtsIdx[i]; } depth = other.depth; @@ -849,9 +805,6 @@ void TransformUnit::copyComponentFrom(const TransformUnit& other, const Componen cbf[i] = other.cbf[i]; rdpcm[i] = other.rdpcm[i]; -#if !REMOVE_PPS_REXT - compAlpha[i] = other.compAlpha[i]; -#endif depth = other.depth; mtsIdx[i] = other.mtsIdx[i]; noResidual = other.noResidual; diff --git a/source/Lib/CommonLib/Unit.h b/source/Lib/CommonLib/Unit.h index c867c38725db9ba2f95abcea75fc0cb637b7e4c7..e4e562d3b86c119f4ed3bf9c44bb929c5da9e0a7 100644 --- a/source/Lib/CommonLib/Unit.h +++ b/source/Lib/CommonLib/Unit.h @@ -271,11 +271,7 @@ struct UnitAreaRelative : public UnitArea class SPS; class VPS; -#if JVET_Q0117_PARAMETER_SETS_CLEANUP class DCI; -#else -class DPS; -#endif class PPS; class Slice; @@ -313,11 +309,7 @@ struct CodingUnit : public UnitArea bool affine; int affineType; bool colorTransform; -#if !JVET_Q0806 - bool triangle; -#else bool geoFlag; -#endif int bdpcmMode; int bdpcmModeChroma; uint8_t imv; @@ -371,9 +363,7 @@ struct CodingUnit : public UnitArea const uint8_t checkAllowedSbt() const; const bool checkCCLMAllowed() const; const bool isSepTree() const; -#if JVET_Q0504_PLT_NON444 const bool isLocalSepTree() const; -#endif const bool isConsInter() const { return modeType == MODE_TYPE_INTER; } const bool isConsIntra() const { return modeType == MODE_TYPE_INTRA; } }; @@ -394,15 +384,9 @@ struct InterPredictionData bool mergeFlag; bool regularMergeFlag; uint8_t mergeIdx; -#if !JVET_Q0806 - uint8_t triangleSplitDir; - uint8_t triangleMergeIdx0; - uint8_t triangleMergeIdx1; -#else uint8_t geoSplitDir; uint8_t geoMergeIdx0; uint8_t geoMergeIdx1; -#endif bool mmvdMergeFlag; uint32_t mmvdMergeIdx; uint8_t interDir; @@ -475,9 +459,6 @@ struct TransformUnit : public UnitArea uint8_t jointCbCr; uint8_t cbf [ MAX_NUM_TBLOCKS ]; RDPCMMode rdpcm [ MAX_NUM_TBLOCKS ]; -#if !REMOVE_PPS_REXT - int8_t compAlpha [ MAX_NUM_TBLOCKS ]; -#endif TransformUnit() : chType( CH_L ) { } TransformUnit(const UnitArea& unit); diff --git a/source/Lib/CommonLib/UnitPartitioner.cpp b/source/Lib/CommonLib/UnitPartitioner.cpp index 81b0469a7bc569c40e085d023226caf0b65ca793..86f96d47be83d9e84ec76ae0d480a3a8a5ea7499 100644 --- a/source/Lib/CommonLib/UnitPartitioner.cpp +++ b/source/Lib/CommonLib/UnitPartitioner.cpp @@ -130,6 +130,13 @@ bool Partitioner::isSepTree( const CodingStructure &cs ) return treeType != TREE_D || CS::isDualITree( cs ); } +#if JVET_R0334_PLT_CLEANUP +bool Partitioner::isLocalSepTree(const CodingStructure &cs) +{ + return treeType != TREE_D && !CS::isDualITree(cs); +} +#endif + void Partitioner::setCUData( CodingUnit& cu ) { cu.depth = currDepth; @@ -253,11 +260,7 @@ void QTBTPartitioner::initCtu( const UnitArea& ctuArea, const ChannelType _chTyp currQtDepth = 0; currSubdiv = 0; currQgPos = ctuArea.lumaPos(); -#if JVET_Q0438_MONOCHROME_BUGFIXES currQgChromaPos = ctuArea.chromaFormat != CHROMA_400 ? ctuArea.chromaPos() : Position(); -#else - currQgChromaPos = ctuArea.chromaPos(); -#endif currImplicitBtDepth = 0; chType = _chType; @@ -378,11 +381,7 @@ void QTBTPartitioner::canSplit( const CodingStructure &cs, bool& canNo, bool& ca // the minimal and maximal sizes are given in luma samples const CompArea& area = currArea().Y(); -#if JVET_Q0438_MONOCHROME_BUGFIXES const CompArea *areaC = (chType == CHANNEL_TYPE_CHROMA) ? &(currArea().Cb()) : nullptr; -#else - const CompArea& areaC = currArea().Cb(); -#endif PartLevel& level = m_partStack.back(); const PartSplit lastSplit = level.split; @@ -398,11 +397,7 @@ void QTBTPartitioner::canSplit( const CodingStructure &cs, bool& canNo, bool& ca if( area.width <= minQtSize ) canQt = false; #endif -#if JVET_Q0438_MONOCHROME_BUGFIXES if( areaC && areaC->width <= MIN_DUALTREE_CHROMA_WIDTH ) canQt = false; -#else - if( chType == CHANNEL_TYPE_CHROMA && areaC.width <= MIN_DUALTREE_CHROMA_WIDTH ) canQt = false; -#endif if( treeType == TREE_C ) { canQt = canBh = canTh = canBv = canTv = false; @@ -414,14 +409,8 @@ void QTBTPartitioner::canSplit( const CodingStructure &cs, bool& canNo, bool& ca canBh = implicitSplit == CU_HORZ_SPLIT; canBv = implicitSplit == CU_VERT_SPLIT; -#if JVET_Q0438_MONOCHROME_BUGFIXES if (areaC && areaC->width == 4) canBv = false; -#else - if (chType == CHANNEL_TYPE_CHROMA && areaC.width == 4) canBv = false; -#endif -#if JVET_Q0330_BLOCK_PARTITION if( !canBh && !canBv && !canQt ) canQt = true; -#endif return; } @@ -457,35 +446,19 @@ void QTBTPartitioner::canSplit( const CodingStructure &cs, bool& canNo, bool& ca // specific check for BT splits if( area.height <= minBtSize ) canBh = false; if( area.width > MAX_TB_SIZEY && area.height <= MAX_TB_SIZEY ) canBh = false; -#if JVET_Q0438_MONOCHROME_BUGFIXES if( areaC && areaC->width * areaC->height <= MIN_DUALTREE_CHROMA_SIZE ) canBh = false; -#else - if( chType == CHANNEL_TYPE_CHROMA && areaC.width * areaC.height <= MIN_DUALTREE_CHROMA_SIZE ) canBh = false; -#endif if( area.width <= minBtSize ) canBv = false; if( area.width <= MAX_TB_SIZEY && area.height > MAX_TB_SIZEY ) canBv = false; -#if JVET_Q0438_MONOCHROME_BUGFIXES if (areaC && (areaC->width * areaC->height <= MIN_DUALTREE_CHROMA_SIZE || areaC->width == 4)) canBv = false; -#else - if (chType == CHANNEL_TYPE_CHROMA && (areaC.width * areaC.height <= MIN_DUALTREE_CHROMA_SIZE || areaC.width == 4)) canBv = false; -#endif if( modeType == MODE_TYPE_INTER && area.width * area.height == 32 ) canBv = canBh = false; if( area.height <= 2 * minTtSize || area.height > maxTtSize || area.width > maxTtSize ) canTh = false; if( area.width > MAX_TB_SIZEY || area.height > MAX_TB_SIZEY ) canTh = false; -#if JVET_Q0438_MONOCHROME_BUGFIXES if( areaC && areaC->width * areaC->height <= MIN_DUALTREE_CHROMA_SIZE*2 ) canTh = false; -#else - if( chType == CHANNEL_TYPE_CHROMA && areaC.width * areaC.height <= MIN_DUALTREE_CHROMA_SIZE*2 ) canTh = false; -#endif if( area.width <= 2 * minTtSize || area.width > maxTtSize || area.height > maxTtSize ) canTv = false; if( area.width > MAX_TB_SIZEY || area.height > MAX_TB_SIZEY ) canTv = false; -#if JVET_Q0438_MONOCHROME_BUGFIXES if (areaC && (areaC->width * areaC->height <= MIN_DUALTREE_CHROMA_SIZE * 2 || areaC->width == 8)) canTv = false; -#else - if (chType == CHANNEL_TYPE_CHROMA && (areaC.width * areaC.height <= MIN_DUALTREE_CHROMA_SIZE * 2 || areaC.width == 8)) canTv = false; -#endif if( modeType == MODE_TYPE_INTER && area.width * area.height == 64 ) canTv = canTh = false; } @@ -564,11 +537,7 @@ PartSplit QTBTPartitioner::getImplicitSplit( const CodingStructure &cs ) const CompArea& area = currArea().Y(); const unsigned maxBtSize = cs.pcv->getMaxBtSize( *cs.slice, chType ); -#if JVET_Q0330_BLOCK_PARTITION const bool isBtAllowed = area.width <= maxBtSize && area.height <= maxBtSize && currMtDepth < (cs.pcv->getMaxBtDepth(*cs.slice, chType) + currImplicitBtDepth); -#else - const bool isBtAllowed = area.width <= maxBtSize && area.height <= maxBtSize; -#endif const unsigned minQtSize = cs.pcv->getMinQtSize( *cs.slice, chType ); #if JVET_Q0471_CHROMA_QT_SPLIT // minQtSize is in luma samples unit @@ -582,19 +551,11 @@ PartSplit QTBTPartitioner::getImplicitSplit( const CodingStructure &cs ) { split = CU_QUAD_SPLIT; } -#if JVET_Q0330_BLOCK_PARTITION else if( !isBlInPic && isBtAllowed && area.width <= MAX_TB_SIZEY ) -#else - else if( !isBlInPic && isBtAllowed ) -#endif { split = CU_HORZ_SPLIT; } -#if JVET_Q0330_BLOCK_PARTITION else if( !isTrInPic && isBtAllowed && area.height <= MAX_TB_SIZEY ) -#else - else if( !isTrInPic && isBtAllowed ) -#endif { split = CU_VERT_SPLIT; } @@ -606,17 +567,10 @@ PartSplit QTBTPartitioner::getImplicitSplit( const CodingStructure &cs ) { split = CU_QUAD_SPLIT; } -#if JVET_Q0330_BLOCK_PARTITION if( (!isBlInPic || !isTrInPic) && split == CU_DONT_SPLIT ) { split = CU_QUAD_SPLIT; } -#else - if ((!isBlInPic || !isTrInPic) && (currArea().Y().width > MAX_TB_SIZEY || currArea().Y().height > MAX_TB_SIZEY)) - { - split = CU_QUAD_SPLIT; - } -#endif } m_partStack.back().checkdIfImplicit = true; @@ -638,11 +592,7 @@ void QTBTPartitioner::exitCurrSplit() currSubdiv--; if( currQgEnable() ) currQgPos = currArea().lumaPos(); -#if JVET_Q0438_MONOCHROME_BUGFIXES if( currArea().chromaFormat != CHROMA_400 && currQgChromaEnable() ) -#else - if( currQgChromaEnable() ) -#endif currQgChromaPos = currArea().chromaPos(); #if _DEBUG m_currArea = m_partStack.back().parts[m_partStack.back().idx]; @@ -861,22 +811,12 @@ Partitioning PartitionerImpl::getCUSubPartitions( const UnitArea &cuArea, const } else { -#if JVET_Q0468_Q0469_MIN_LUMA_CB_AND_MIN_QT_FIX const uint32_t minCUSize = 1 << cs.sps->getLog2MinCodingBlockSize(); -#else - const uint32_t minCUSize = ( cs.sps->getMaxCUWidth() >> cs.sps->getMaxCodingDepth() ); -#endif bool canSplit = cuArea.lumaSize().width > minCUSize && cuArea.lumaSize().height > minCUSize; Partitioning ret; -#if !JVET_Q0468_Q0469_MIN_LUMA_CB_AND_MIN_QT_FIX - if( cs.slice->getSliceType() == I_SLICE ) - { - canSplit &= cuArea.lumaSize().width > cs.pcv->minCUWidth && cuArea.lumaSize().height > cs.pcv->minCUHeight; - } -#endif if( canSplit ) { @@ -1076,11 +1016,7 @@ void PartitionerImpl::getTUIntraSubPartitions( Partitioning &sub, const UnitArea THROW( "Unknown TU sub-partitioning" ); } //we only partition luma, so there is going to be only one chroma tu at the end (unless it is dual tree, in which case there won't be any chroma components) -#if JVET_Q0438_MONOCHROME_BUGFIXES uint32_t partitionsWithoutChroma = (cs.area.chromaFormat == CHROMA_400) ? 0 : (isDualTree ? nPartitions : nPartitions - 1); -#else - uint32_t partitionsWithoutChroma = isDualTree ? nPartitions : nPartitions - 1; -#endif for( uint32_t i = 0; i < partitionsWithoutChroma; i++ ) { CompArea& blkCb = sub[i].blocks[COMPONENT_Cb]; diff --git a/source/Lib/CommonLib/UnitPartitioner.h b/source/Lib/CommonLib/UnitPartitioner.h index 590947759772b858bdbf5e3a047afbd3021aca77..cb1b39041e61348bc5b070c8c592b85af2861eb1 100644 --- a/source/Lib/CommonLib/UnitPartitioner.h +++ b/source/Lib/CommonLib/UnitPartitioner.h @@ -155,6 +155,9 @@ public: virtual bool isSplitImplicit ( const PartSplit split, const CodingStructure &cs ) = 0; virtual PartSplit getImplicitSplit ( const CodingStructure &cs ) = 0; bool isSepTree ( const CodingStructure &cs ); +#if JVET_R0334_PLT_CLEANUP + bool isLocalSepTree ( const CodingStructure &cs ); +#endif bool isConsInter () { return modeType == MODE_TYPE_INTER; } bool isConsIntra () { return modeType == MODE_TYPE_INTRA; } }; diff --git a/source/Lib/CommonLib/UnitTools.cpp b/source/Lib/CommonLib/UnitTools.cpp index 9f8cefa828b0587bbebf2455eb208ee50447e1b5..444ff8b32792f2a02f88064bb05665a2f3ff07b7 100644 --- a/source/Lib/CommonLib/UnitTools.cpp +++ b/source/Lib/CommonLib/UnitTools.cpp @@ -103,49 +103,36 @@ void CS::setRefinedMotionField(CodingStructure &cs) bool CU::getRprScaling( const SPS* sps, const PPS* curPPS, Picture* refPic, int& xScale, int& yScale ) { const Window& curScalingWindow = curPPS->getScalingWindow(); -#if JVET_Q0487_SCALING_WINDOW_ISSUES int curPicWidth = curPPS->getPicWidthInLumaSamples() - SPS::getWinUnitX( sps->getChromaFormatIdc() ) * (curScalingWindow.getWindowLeftOffset() + curScalingWindow.getWindowRightOffset()); int curPicHeight = curPPS->getPicHeightInLumaSamples() - SPS::getWinUnitY( sps->getChromaFormatIdc() ) * (curScalingWindow.getWindowTopOffset() + curScalingWindow.getWindowBottomOffset()); -#else - int curPicWidth = curPPS->getPicWidthInLumaSamples() - curScalingWindow.getWindowLeftOffset() - curScalingWindow.getWindowRightOffset(); - int curPicHeight = curPPS->getPicHeightInLumaSamples() - curScalingWindow.getWindowTopOffset() - curScalingWindow.getWindowBottomOffset(); -#endif const Window& refScalingWindow = refPic->getScalingWindow(); -#if JVET_Q0487_SCALING_WINDOW_ISSUES int refPicWidth = refPic->getPicWidthInLumaSamples() - SPS::getWinUnitX( sps->getChromaFormatIdc() ) * (refScalingWindow.getWindowLeftOffset() + refScalingWindow.getWindowRightOffset()); int refPicHeight = refPic->getPicHeightInLumaSamples() - SPS::getWinUnitY( sps->getChromaFormatIdc() ) * (refScalingWindow.getWindowTopOffset() + refScalingWindow.getWindowBottomOffset()); -#else - int refPicWidth = refPic->getPicWidthInLumaSamples() - refScalingWindow.getWindowLeftOffset() - refScalingWindow.getWindowRightOffset(); - int refPicHeight = refPic->getPicHeightInLumaSamples() - refScalingWindow.getWindowTopOffset() - refScalingWindow.getWindowBottomOffset(); -#endif xScale = ( ( refPicWidth << SCALE_RATIO_BITS ) + ( curPicWidth >> 1 ) ) / curPicWidth; yScale = ( ( refPicHeight << SCALE_RATIO_BITS ) + ( curPicHeight >> 1 ) ) / curPicHeight; -#if JVET_Q0179_SCALING_WINDOW_SIZE_CONSTRAINT int curSeqMaxPicWidthY = sps->getMaxPicWidthInLumaSamples(); // pic_width_max_in_luma_samples int curSeqMaxPicHeightY = sps->getMaxPicHeightInLumaSamples(); // pic_height_max_in_luma_samples int curPicWidthY = curPPS->getPicWidthInLumaSamples(); // pic_width_in_luma_samples - int curPicHeightY = curPPS->getPicHeightInLumaSamples(); // pic_height_in_luma_samples + int curPicHeightY = curPPS->getPicHeightInLumaSamples(); // pic_height_in_luma_samples int max8MinCbSizeY = std::max((int)8, (1<<sps->getLog2MinCodingBlockSize())); // Max(8, MinCbSizeY) CHECK((curPicWidth * curSeqMaxPicWidthY) < refPicWidth * (curPicWidthY - max8MinCbSizeY), "(curPicWidth * curSeqMaxPicWidthY) should be greater than or equal to refPicWidth * (curPicWidthY - max8MinCbSizeY))"); CHECK((curPicHeight * curSeqMaxPicHeightY) < refPicHeight * (curPicHeightY - max8MinCbSizeY), "(curPicHeight * curSeqMaxPicHeightY) should be greater than or equal to refPicHeight * (curPicHeightY - max8MinCbSizeY))"); -#endif -#if JVET_Q0257_SCALING_WINDOW_CONSTRAINT CHECK(curPicWidth * 2 < refPicWidth, "curPicWidth * 2 shall be greater than or equal to refPicWidth"); CHECK(curPicHeight * 2 < refPicHeight, "curPicHeight * 2 shall be greater than or equal to refPicHeight"); CHECK(curPicWidth > refPicWidth * 8, "curPicWidth shall be less than or equal to refPicWidth * 8"); CHECK(curPicHeight > refPicHeight * 8, "curPicHeight shall be less than or equal to refPicHeight * 8"); + +#if JVET_R0114_NEGATIVE_SCALING_WINDOW_OFFSETS + CHECK(SPS::getWinUnitX(sps->getChromaFormatIdc()) * (abs(curScalingWindow.getWindowLeftOffset()) + abs(curScalingWindow.getWindowRightOffset())) > curPPS->getPicWidthInLumaSamples(), "The value of SubWidthC * ( Abs(pps_scaling_win_left_offset) + Abs(pps_scaling_win_right_offset) ) shall be less than pic_width_in_luma_samples"); + CHECK(SPS::getWinUnitY(sps->getChromaFormatIdc()) * (abs(curScalingWindow.getWindowTopOffset()) + abs(curScalingWindow.getWindowBottomOffset())) > curPPS->getPicHeightInLumaSamples(), "The value of SubHeightC * ( Abs(pps_scaling_win_top_offset) + Abs(pps_scaling_win_bottom_offset) ) shall be less than pic_height_in_luma_samples"); #endif -#if JVET_Q0487_SCALING_WINDOW_ISSUES return refPic->isRefScaled( curPPS ); -#else - return refPicWidth != curPicWidth || refPicHeight != curPicHeight; -#endif } bool CU::isIntra(const CodingUnit &cu) @@ -190,12 +177,10 @@ bool CU::isSameSliceAndTile(const CodingUnit& cu, const CodingUnit& cu2) return ( cu.slice->getIndependentSliceIdx() == cu2.slice->getIndependentSliceIdx() ) && ( cu.tileIdx == cu2.tileIdx ); } -#if JVET_O1143_SUBPIC_BOUNDARY bool CU::isSameSubPic(const CodingUnit& cu, const CodingUnit& cu2) { return (cu.slice->getPPS()->getSubPicFromCU(cu).getSubPicIdx() == cu2.slice->getPPS()->getSubPicFromCU(cu2).getSubPicIdx()) ; } -#endif bool CU::isSameCtu(const CodingUnit& cu, const CodingUnit& cu2) { @@ -231,8 +216,8 @@ int CU::predictQP( const CodingUnit& cu, const int prevQP ) uint32_t tileXPosInCtus = cu.slice->getPPS()->getTileColumnBd( tileColIdx ); if( ctuXPosInCtus == tileXPosInCtus && !( cu.blocks[cu.chType].x & ( cs.pcv->maxCUWidthMask >> getChannelTypeScaleX( cu.chType, cu.chromaFormat ) ) ) && - !( cu.blocks[cu.chType].y & ( cs.pcv->maxCUHeightMask >> getChannelTypeScaleY( cu.chType, cu.chromaFormat ) ) ) && - ( cs.getCU( cu.blocks[cu.chType].pos().offset( 0, -1 ), cu.chType) != NULL ) && + !( cu.blocks[cu.chType].y & ( cs.pcv->maxCUHeightMask >> getChannelTypeScaleY( cu.chType, cu.chromaFormat ) ) ) && + ( cs.getCU( cu.blocks[cu.chType].pos().offset( 0, -1 ), cu.chType) != NULL ) && CU::isSameSliceAndTile( *cs.getCU( cu.blocks[cu.chType].pos().offset( 0, -1 ), cu.chType), cu ) ) { return ( ( cs.getCU( cu.blocks[cu.chType].pos().offset( 0, -1 ), cu.chType ) )->qp ); @@ -269,24 +254,18 @@ void CU::saveMotionInHMVP( const CodingUnit& cu, const bool isToBeDone ) { const PredictionUnit& pu = *cu.firstPU; -#if !JVET_Q0806 - if (!cu.triangle && !cu.affine && !isToBeDone ) -#else if (!cu.geoFlag && !cu.affine && !isToBeDone) -#endif { MotionInfo mi = pu.getMotionInfo(); mi.BcwIdx = (mi.interDir == 3) ? cu.BcwIdx : BCW_DEFAULT; -#if JVET_Q0297_MER const unsigned log2ParallelMergeLevel = (pu.cs->sps->getLog2ParallelMergeLevelMinus2() + 2); const unsigned xBr = pu.cu->Y().width + pu.cu->Y().x; const unsigned yBr = pu.cu->Y().height + pu.cu->Y().y; bool enableHmvp = ((xBr >> log2ParallelMergeLevel) > (pu.cu->Y().x >> log2ParallelMergeLevel)) && ((yBr >> log2ParallelMergeLevel) > (pu.cu->Y().y >> log2ParallelMergeLevel)); bool enableInsertion = CU::isIBC(cu) || enableHmvp; if (enableInsertion) -#endif cu.cs->addMiToLut(CU::isIBC(cu) ? cu.cs->motionLut.lutIbc : cu.cs->motionLut.lut, mi); } } @@ -579,9 +558,27 @@ int PU::getIntraMPMs( const PredictionUnit &pu, unsigned* mpm, const ChannelType bool PU::isMIP(const PredictionUnit &pu, const ChannelType &chType) { +#if JVET_R0350_MIP_CHROMA_444_SINGLETREE + if (chType == CHANNEL_TYPE_LUMA) + { + // Default case if chType is omitted. + return pu.cu->mipFlag; + } + else + { + return isDMChromaMIP(pu) && (pu.intraDir[CHANNEL_TYPE_CHROMA] == DM_CHROMA_IDX); + } +#else return (chType == CHANNEL_TYPE_LUMA && pu.cu->mipFlag); +#endif } +#if JVET_R0350_MIP_CHROMA_444_SINGLETREE +bool PU::isDMChromaMIP(const PredictionUnit &pu) +{ + return !pu.cu->isSepTree() && (pu.chromaFormat == CHROMA_444) && getCoLocatedLumaPU(pu).cu->mipFlag; +} +#endif uint32_t PU::getIntraDirLuma( const PredictionUnit &pu ) { @@ -608,6 +605,14 @@ void PU::getIntraChromaCandModes( const PredictionUnit &pu, unsigned modeList[NU modeList[6] = MDLM_T_IDX; modeList[7] = DM_CHROMA_IDX; +#if JVET_R0350_MIP_CHROMA_444_SINGLETREE + // If Direct Mode is MIP, mode cannot be already in the list. + if (isDMChromaMIP(pu)) + { + return; + } + +#endif const uint32_t lumaMode = getCoLocatedIntraLumaMode(pu); for( int i = 0; i < 4; i++ ) { @@ -664,6 +669,23 @@ uint32_t PU::getFinalIntraMode( const PredictionUnit &pu, const ChannelType &chT return uiIntraMode; } +#if JVET_R0350_MIP_CHROMA_444_SINGLETREE +const PredictionUnit &PU::getCoLocatedLumaPU(const PredictionUnit &pu) +{ + Position topLeftPos = pu.blocks[pu.chType].lumaPos(); + Position refPos = topLeftPos.offset(pu.blocks[pu.chType].lumaSize().width >> 1, + pu.blocks[pu.chType].lumaSize().height >> 1); + const PredictionUnit &lumaPU = pu.cu->isSepTree() ? *pu.cs->picture->cs->getPU(refPos, CHANNEL_TYPE_LUMA) + : *pu.cs->getPU(topLeftPos, CHANNEL_TYPE_LUMA); + + return lumaPU; +} + +uint32_t PU::getCoLocatedIntraLumaMode(const PredictionUnit &pu) +{ + return PU::getIntraDirLuma(PU::getCoLocatedLumaPU(pu)); +} +#else uint32_t PU::getCoLocatedIntraLumaMode( const PredictionUnit &pu ) { Position topLeftPos = pu.blocks[pu.chType].lumaPos(); @@ -672,6 +694,7 @@ uint32_t PU::getCoLocatedIntraLumaMode( const PredictionUnit &pu ) return PU::getIntraDirLuma( lumaPU ); } +#endif int PU::getWideAngIntraMode( const TransformUnit &tu, const uint32_t dirMode, const ComponentID compID ) { @@ -680,11 +703,9 @@ int PU::getWideAngIntraMode( const TransformUnit &tu, const uint32_t dirMode, co return ( int ) dirMode; } - CodingStructure& cs = *tu.cs; - const CompArea& area = tu.blocks[ compID ]; - PelBuf pred = cs.getPredBuf( area ); - int width = int( pred.width ); - int height = int( pred.height ); + const CompArea& area = tu.cu->ispMode && isLuma(compID) ? tu.cu->blocks[compID] : tu.blocks[ compID ]; + int width = area.width; + int height = area.height; int modeShift[ ] = { 0, 6, 10, 12, 14, 15 }; int deltaSize = abs( floorLog2( width ) - floorLog2( height ) ); int predMode = dirMode; @@ -755,12 +776,7 @@ bool PU::addMergeHMVPCand(const CodingStructure &cs, MergeCtx& mrgCtx, const int void PU::getIBCMergeCandidates(const PredictionUnit &pu, MergeCtx& mrgCtx, const int& mrgCandIdx) { const CodingStructure &cs = *pu.cs; -#if JVET_Q0798_SPS_NUMBER_MERGE_CANDIDATE const uint32_t maxNumMergeCand = pu.cs->sps->getMaxNumIBCMergeCand(); -#else - const Slice &slice = *pu.cs->slice; - const uint32_t maxNumMergeCand = slice.getPicHeader()->getMaxNumIBCMergeCand(); -#endif for (uint32_t ui = 0; ui < maxNumMergeCand; ++ui) { mrgCtx.BcwIdx[ui] = BCW_DEFAULT; @@ -784,11 +800,7 @@ void PU::getIBCMergeCandidates(const PredictionUnit &pu, MergeCtx& mrgCtx, const //left const PredictionUnit* puLeft = cs.getPURestricted(posLB.offset(-1, 0), pu, pu.chType); bool isGt4x4 = pu.lwidth() * pu.lheight() > 16; -#if JVET_Q0297_MER const bool isAvailableA1 = puLeft && pu.cu != puLeft->cu && CU::isIBC(*puLeft->cu); -#else - const bool isAvailableA1 = puLeft && isDiffMER(pu, *puLeft) && pu.cu != puLeft->cu && CU::isIBC(*puLeft->cu); -#endif if (isGt4x4 && isAvailableA1) { miLeft = puLeft->getMotionInfo(posLB.offset(-1, 0)); @@ -812,11 +824,7 @@ void PU::getIBCMergeCandidates(const PredictionUnit &pu, MergeCtx& mrgCtx, const // above const PredictionUnit *puAbove = cs.getPURestricted(posRT.offset(0, -1), pu, pu.chType); -#if JVET_Q0297_MER bool isAvailableB1 = puAbove && pu.cu != puAbove->cu && CU::isIBC(*puAbove->cu); -#else - bool isAvailableB1 = puAbove && isDiffMER(pu, *puAbove) && pu.cu != puAbove->cu && CU::isIBC(*puAbove->cu); -#endif if (isGt4x4 && isAvailableB1) { miAbove = puAbove->getMotionInfo(posRT.offset(0, -1)); @@ -874,16 +882,10 @@ void PU::getInterMergeCandidates( const PredictionUnit &pu, MergeCtx& mrgCtx, int mmvdList, const int& mrgCandIdx ) { -#if JVET_Q0297_MER const unsigned plevel = pu.cs->sps->getLog2ParallelMergeLevelMinus2() + 2; -#endif const CodingStructure &cs = *pu.cs; const Slice &slice = *pu.cs->slice; -#if JVET_Q0798_SPS_NUMBER_MERGE_CANDIDATE const uint32_t maxNumMergeCand = pu.cs->sps->getMaxNumMergeCand(); -#else - const uint32_t maxNumMergeCand = slice.getPicHeader()->getMaxNumMergeCand(); -#endif for (uint32_t ui = 0; ui < maxNumMergeCand; ++ui) { mrgCtx.BcwIdx[ui] = BCW_DEFAULT; @@ -907,11 +909,7 @@ void PU::getInterMergeCandidates( const PredictionUnit &pu, MergeCtx& mrgCtx, // above const PredictionUnit *puAbove = cs.getPURestricted(posRT.offset(0, -1), pu, pu.chType); -#if JVET_Q0297_MER bool isAvailableB1 = puAbove && isDiffMER(pu.lumaPos(), posRT.offset(0, -1), plevel) && pu.cu != puAbove->cu && CU::isInter(*puAbove->cu); -#else - bool isAvailableB1 = puAbove && isDiffMER(pu, *puAbove) && pu.cu != puAbove->cu && CU::isInter(*puAbove->cu); -#endif if (isAvailableB1) { @@ -945,11 +943,7 @@ void PU::getInterMergeCandidates( const PredictionUnit &pu, MergeCtx& mrgCtx, //left const PredictionUnit* puLeft = cs.getPURestricted(posLB.offset(-1, 0), pu, pu.chType); -#if JVET_Q0297_MER const bool isAvailableA1 = puLeft && isDiffMER(pu.lumaPos(), posLB.offset(-1, 0), plevel) && pu.cu != puLeft->cu && CU::isInter(*puLeft->cu); -#else - const bool isAvailableA1 = puLeft && isDiffMER(pu, *puLeft) && pu.cu != puLeft->cu && CU::isInter(*puLeft->cu); -#endif if (isAvailableA1) { @@ -986,11 +980,7 @@ void PU::getInterMergeCandidates( const PredictionUnit &pu, MergeCtx& mrgCtx, // above right const PredictionUnit *puAboveRight = cs.getPURestricted( posRT.offset( 1, -1 ), pu, pu.chType ); -#if JVET_Q0297_MER bool isAvailableB0 = puAboveRight && isDiffMER( pu.lumaPos(), posRT.offset(1, -1), plevel) && CU::isInter( *puAboveRight->cu ); -#else - bool isAvailableB0 = puAboveRight && isDiffMER( pu, *puAboveRight ) && CU::isInter( *puAboveRight->cu ); -#endif if( isAvailableB0 ) { @@ -1028,11 +1018,7 @@ void PU::getInterMergeCandidates( const PredictionUnit &pu, MergeCtx& mrgCtx, //left bottom const PredictionUnit *puLeftBottom = cs.getPURestricted( posLB.offset( -1, 1 ), pu, pu.chType ); -#if JVET_Q0297_MER bool isAvailableA0 = puLeftBottom && isDiffMER( pu.lumaPos(), posLB.offset(-1, 1), plevel) && CU::isInter( *puLeftBottom->cu ); -#else - bool isAvailableA0 = puLeftBottom && isDiffMER( pu, *puLeftBottom ) && CU::isInter( *puLeftBottom->cu ); -#endif if( isAvailableA0 ) { @@ -1073,11 +1059,7 @@ void PU::getInterMergeCandidates( const PredictionUnit &pu, MergeCtx& mrgCtx, { const PredictionUnit *puAboveLeft = cs.getPURestricted( posLT.offset( -1, -1 ), pu, pu.chType ); -#if JVET_Q0297_MER bool isAvailableB2 = puAboveLeft && isDiffMER( pu.lumaPos(), posLT.offset(-1, -1), plevel ) && CU::isInter( *puAboveLeft->cu ); -#else - bool isAvailableB2 = puAboveLeft && isDiffMER( pu, *puAboveLeft ) && CU::isInter( *puAboveLeft->cu ); -#endif if( isAvailableB2 ) { @@ -1123,18 +1105,14 @@ void PU::getInterMergeCandidates( const PredictionUnit &pu, MergeCtx& mrgCtx, Position posC0; Position posC1 = pu.Y().center(); bool C0Avail = false; -#if JVET_O1143_MV_ACROSS_SUBPIC_BOUNDARY bool boundaryCond = ((posRB.x + pcv.minCUWidth) < pcv.lumaWidth) && ((posRB.y + pcv.minCUHeight) < pcv.lumaHeight); - SubPic curSubPic = pu.cs->slice->getPPS()->getSubPicFromPos(pu.lumaPos()); + const SubPic& curSubPic = pu.cs->slice->getPPS()->getSubPicFromPos(pu.lumaPos()); if (curSubPic.getTreatedAsPicFlag()) { boundaryCond = ((posRB.x + pcv.minCUWidth) <= curSubPic.getSubPicRight() && (posRB.y + pcv.minCUHeight) <= curSubPic.getSubPicBottom()); - } + } if (boundaryCond) -#else - if (((posRB.x + pcv.minCUWidth) < pcv.lumaWidth) && ((posRB.y + pcv.minCUHeight) < pcv.lumaHeight)) -#endif { int posYInCtu = posRB.y & pcv.maxCUHeightMask; if (posYInCtu + 4 < pcv.maxCUHeight) @@ -1332,17 +1310,9 @@ bool PU::checkDMVRCondition(const PredictionUnit& pu) && (pu.lwidth() >= 8) && ((pu.lheight() * pu.lwidth()) >= 128) && (pu.cu->BcwIdx == BCW_DEFAULT) -#if JVET_Q0128_DMVR_BDOF_ENABLING_CONDITION && ((!wp0[COMPONENT_Y].bPresentFlag) && (!wp0[COMPONENT_Cb].bPresentFlag) && (!wp0[COMPONENT_Cr].bPresentFlag) && (!wp1[COMPONENT_Y].bPresentFlag) && (!wp1[COMPONENT_Cb].bPresentFlag) && (!wp1[COMPONENT_Cr].bPresentFlag)) -#else - && ((!wp0[COMPONENT_Y].bPresentFlag) && (!wp1[COMPONENT_Y].bPresentFlag)) -#endif -#if JVET_Q0487_SCALING_WINDOW_ISSUES && ( refIdx0 < 0 ? true : (pu.cu->slice->getRefPic( REF_PIC_LIST_0, refIdx0 )->isRefScaled( pu.cs->pps ) == false) ) && ( refIdx1 < 0 ? true : (pu.cu->slice->getRefPic( REF_PIC_LIST_1, refIdx1 )->isRefScaled( pu.cs->pps ) == false) ) -#else - && ( refIdx0 < 0 ? true : pu.cu->slice->getScalingRatio( REF_PIC_LIST_0, refIdx0 ) == SCALE_1X ) && ( refIdx1 < 0 ? true : pu.cu->slice->getScalingRatio( REF_PIC_LIST_1, refIdx1 ) == SCALE_1X ) -#endif ; } else @@ -1467,15 +1437,13 @@ bool PU::getColocatedMVP(const PredictionUnit &pu, const RefPicList &eRefPicList return false; } -#if JVET_O1143_MV_ACROSS_SUBPIC_BOUNDARY // Check the position of colocated block is within a subpicture - SubPic curSubPic = pu.cs->slice->getPPS()->getSubPicFromPos(pu.lumaPos()); + const SubPic &curSubPic = pu.cs->slice->getPPS()->getSubPicFromPos(pu.lumaPos()); if (curSubPic.getTreatedAsPicFlag()) { if (!curSubPic.isContainingPos(pos)) return false; } -#endif RefPicList eColRefPicList = slice.getCheckLDC() ? eRefPicList : RefPicList(slice.getColFromL0Flag()); const MotionInfo& mi = pColPic->cs->getMotionInfo( pos ); @@ -1549,9 +1517,7 @@ bool PU::getColocatedMVP(const PredictionUnit &pu, const RefPicList &eRefPicList if (bIsCurrRefLongTerm /*|| bIsColRefLongTerm*/) { rcMv = cColMv; -#if JVET_Q0483_CLIP_TMVP rcMv.clipToStorageBitDepth(); -#endif } else { @@ -1564,9 +1530,7 @@ bool PU::getColocatedMVP(const PredictionUnit &pu, const RefPicList &eRefPicList if (distscale == 4096) { rcMv = cColMv; -#if JVET_Q0483_CLIP_TMVP rcMv.clipToStorageBitDepth(); -#endif } else { @@ -1577,7 +1541,6 @@ bool PU::getColocatedMVP(const PredictionUnit &pu, const RefPicList &eRefPicList return true; } -#if JVET_Q0297_MER bool PU::isDiffMER(const Position &pos1, const Position &pos2, const unsigned plevel) { const unsigned xN = pos1.x; @@ -1597,27 +1560,6 @@ bool PU::isDiffMER(const Position &pos1, const Position &pos2, const unsigned pl return false; } -#else -bool PU::isDiffMER(const PredictionUnit &pu1, const PredictionUnit &pu2) -{ - const unsigned xN = pu1.lumaPos().x; - const unsigned yN = pu1.lumaPos().y; - const unsigned xP = pu2.lumaPos().x; - const unsigned yP = pu2.lumaPos().y; - - if ((xN >> 2) != (xP >> 2)) - { - return true; - } - - if ((yN >> 2) != (yP >> 2)) - { - return true; - } - - return false; -} -#endif bool PU::isAddNeighborMv(const Mv& currMv, Mv* neighborMvs, int numNeighborMv) { @@ -1860,18 +1802,14 @@ void PU::fillMvpCand(PredictionUnit &pu, const RefPicList &eRefPicList, const in Position posC1 = pu.Y().center(); Mv cColMv; -#if JVET_O1143_MV_ACROSS_SUBPIC_BOUNDARY bool boundaryCond = ((posRB.x + pcv.minCUWidth) < pcv.lumaWidth) && ((posRB.y + pcv.minCUHeight) < pcv.lumaHeight); - SubPic curSubPic = pu.cs->slice->getPPS()->getSubPicFromPos(pu.lumaPos()); + const SubPic &curSubPic = pu.cs->slice->getPPS()->getSubPicFromPos(pu.lumaPos()); if (curSubPic.getTreatedAsPicFlag()) { boundaryCond = ((posRB.x + pcv.minCUWidth) <= curSubPic.getSubPicRight() && (posRB.y + pcv.minCUHeight) <= curSubPic.getSubPicBottom()); - } + } if (boundaryCond) -#else - if( ( ( posRB.x + pcv.minCUWidth ) < pcv.lumaWidth ) && ( ( posRB.y + pcv.minCUHeight ) < pcv.lumaHeight ) ) -#endif { int posYInCtu = posRB.y & pcv.maxCUHeightMask; if (posYInCtu + 4 < pcv.maxCUHeight) @@ -2186,18 +2124,14 @@ void PU::fillAffineMvpCand(PredictionUnit &pu, const RefPicList &eRefPicList, co bool C0Avail = false; Position posC1 = pu.Y().center(); Mv cColMv; -#if JVET_O1143_MV_ACROSS_SUBPIC_BOUNDARY bool boundaryCond = ((posRB.x + pcv.minCUWidth) < pcv.lumaWidth) && ((posRB.y + pcv.minCUHeight) < pcv.lumaHeight); - SubPic curSubPic = pu.cs->slice->getPPS()->getSubPicFromPos(pu.lumaPos()); + const SubPic &curSubPic = pu.cs->slice->getPPS()->getSubPicFromPos(pu.lumaPos()); if (curSubPic.getTreatedAsPicFlag()) { boundaryCond = ((posRB.x + pcv.minCUWidth) <= curSubPic.getSubPicRight() && (posRB.y + pcv.minCUHeight) <= curSubPic.getSubPicBottom()); } if (boundaryCond) -#else - if ( ((posRB.x + pcv.minCUWidth) < pcv.lumaWidth) && ((posRB.y + pcv.minCUHeight) < pcv.lumaHeight) ) -#endif { int posYInCtu = posRB.y & pcv.maxCUHeightMask; if (posYInCtu + 4 < pcv.maxCUHeight) @@ -2489,16 +2423,12 @@ const int getAvailableAffineNeighboursForLeftPredictor( const PredictionUnit &pu { const Position posLB = pu.Y().bottomLeft(); int num = 0; -#if JVET_Q0297_MER const unsigned plevel = pu.cs->sps->getLog2ParallelMergeLevelMinus2() + 2; -#endif const PredictionUnit *puLeftBottom = pu.cs->getPURestricted( posLB.offset( -1, 1 ), pu, pu.chType ); if ( puLeftBottom && puLeftBottom->cu->affine && puLeftBottom->mergeType == MRG_TYPE_DEFAULT_N -#if JVET_Q0297_MER && PU::isDiffMER(pu.lumaPos(), posLB.offset(-1, 1), plevel) -#endif ) { npu[num++] = puLeftBottom; @@ -2508,9 +2438,7 @@ const int getAvailableAffineNeighboursForLeftPredictor( const PredictionUnit &pu const PredictionUnit* puLeft = pu.cs->getPURestricted( posLB.offset( -1, 0 ), pu, pu.chType ); if ( puLeft && puLeft->cu->affine && puLeft->mergeType == MRG_TYPE_DEFAULT_N -#if JVET_Q0297_MER && PU::isDiffMER(pu.lumaPos(), posLB.offset(-1, 0), plevel) -#endif ) { npu[num++] = puLeft; @@ -2524,17 +2452,13 @@ const int getAvailableAffineNeighboursForAbovePredictor( const PredictionUnit &p { const Position posLT = pu.Y().topLeft(); const Position posRT = pu.Y().topRight(); -#if JVET_Q0297_MER const unsigned plevel = pu.cs->sps->getLog2ParallelMergeLevelMinus2() + 2; -#endif int num = numAffNeighLeft; const PredictionUnit* puAboveRight = pu.cs->getPURestricted( posRT.offset( 1, -1 ), pu, pu.chType ); if ( puAboveRight && puAboveRight->cu->affine && puAboveRight->mergeType == MRG_TYPE_DEFAULT_N -#if JVET_Q0297_MER && PU::isDiffMER(pu.lumaPos(), posRT.offset(1, -1), plevel) -#endif ) { npu[num++] = puAboveRight; @@ -2544,9 +2468,7 @@ const int getAvailableAffineNeighboursForAbovePredictor( const PredictionUnit &p const PredictionUnit* puAbove = pu.cs->getPURestricted( posRT.offset( 0, -1 ), pu, pu.chType ); if ( puAbove && puAbove->cu->affine && puAbove->mergeType == MRG_TYPE_DEFAULT_N -#if JVET_Q0297_MER && PU::isDiffMER(pu.lumaPos(), posRT.offset(0, -1), plevel) -#endif ) { npu[num++] = puAbove; @@ -2556,9 +2478,7 @@ const int getAvailableAffineNeighboursForAbovePredictor( const PredictionUnit &p const PredictionUnit *puAboveLeft = pu.cs->getPURestricted( posLT.offset( -1, -1 ), pu, pu.chType ); if ( puAboveLeft && puAboveLeft->cu->affine && puAboveLeft->mergeType == MRG_TYPE_DEFAULT_N -#if JVET_Q0297_MER && PU::isDiffMER(pu.lumaPos(), posLT.offset(-1, -1), plevel) -#endif ) { npu[num++] = puAboveLeft; @@ -2573,9 +2493,7 @@ void PU::getAffineMergeCand( const PredictionUnit &pu, AffineMergeCtx& affMrgCtx const CodingStructure &cs = *pu.cs; const Slice &slice = *pu.cs->slice; const uint32_t maxNumAffineMergeCand = slice.getPicHeader()->getMaxNumAffineMergeCand(); -#if JVET_Q0297_MER const unsigned plevel = pu.cs->sps->getLog2ParallelMergeLevelMinus2() + 2; -#endif for ( int i = 0; i < maxNumAffineMergeCand; i++ ) { @@ -2610,11 +2528,7 @@ void PU::getAffineMergeCand( const PredictionUnit &pu, AffineMergeCtx& affMrgCtx //left const PredictionUnit* puLeft = cs.getPURestricted( posCurLB.offset( -1, 0 ), pu, pu.chType ); -#if JVET_Q0297_MER const bool isAvailableA1 = puLeft && isDiffMER(pu.lumaPos(), posCurLB.offset(-1, 0), plevel) && pu.cu != puLeft->cu && CU::isInter( *puLeft->cu ); -#else - const bool isAvailableA1 = puLeft && isDiffMER( pu, *puLeft ) && pu.cu != puLeft->cu && CU::isInter( *puLeft->cu ); -#endif if ( isAvailableA1 ) { miLeft = puLeft->getMotionInfo( posCurLB.offset( -1, 0 ) ); @@ -2723,9 +2637,7 @@ void PU::getAffineMergeCand( const PredictionUnit &pu, AffineMergeCtx& affMrgCtx const PredictionUnit* puNeigh = cs.getPURestricted( pos, pu, pu.chType ); if ( puNeigh && CU::isInter( *puNeigh->cu ) -#if JVET_Q0297_MER && PU::isDiffMER(pu.lumaPos(), pos, plevel) -#endif ) { isAvailable[0] = true; @@ -2744,9 +2656,7 @@ void PU::getAffineMergeCand( const PredictionUnit &pu, AffineMergeCtx& affMrgCtx if ( puNeigh && CU::isInter( *puNeigh->cu ) -#if JVET_Q0297_MER && PU::isDiffMER(pu.lumaPos(), pos, plevel) -#endif ) { isAvailable[1] = true; @@ -2765,9 +2675,7 @@ void PU::getAffineMergeCand( const PredictionUnit &pu, AffineMergeCtx& affMrgCtx if ( puNeigh && CU::isInter( *puNeigh->cu ) -#if JVET_Q0297_MER && PU::isDiffMER(pu.lumaPos(), pos, plevel) -#endif ) { isAvailable[2] = true; @@ -2787,18 +2695,14 @@ void PU::getAffineMergeCand( const PredictionUnit &pu, AffineMergeCtx& affMrgCtx Position posC0; bool C0Avail = false; -#if JVET_O1143_MV_ACROSS_SUBPIC_BOUNDARY bool boundaryCond = ((posRB.x + pcv.minCUWidth) < pcv.lumaWidth) && ((posRB.y + pcv.minCUHeight) < pcv.lumaHeight); - SubPic curSubPic = pu.cs->slice->getPPS()->getSubPicFromPos(pu.lumaPos()); + const SubPic &curSubPic = pu.cs->slice->getPPS()->getSubPicFromPos(pu.lumaPos()); if (curSubPic.getTreatedAsPicFlag()) { boundaryCond = ((posRB.x + pcv.minCUWidth) <= curSubPic.getSubPicRight() && (posRB.y + pcv.minCUHeight) <= curSubPic.getSubPicBottom()); } if (boundaryCond) -#else - if ( ((posRB.x + pcv.minCUWidth) < pcv.lumaWidth) && ((posRB.y + pcv.minCUHeight) < pcv.lumaHeight) ) -#endif { int posYInCtu = posRB.y & pcv.maxCUHeightMask; if (posYInCtu + 4 < pcv.maxCUHeight) @@ -2988,9 +2892,8 @@ void clipColPos(int& posX, int& posY, const PredictionUnit& pu) int log2CtuSize = floorLog2(pu.cs->sps->getCTUSize()); int ctuX = ((puPos.x >> log2CtuSize) << log2CtuSize); int ctuY = ((puPos.y >> log2CtuSize) << log2CtuSize); -#if JVET_O1143_MV_ACROSS_SUBPIC_BOUNDARY int horMax; - SubPic curSubPic = pu.cu->slice->getPPS()->getSubPicFromPos(puPos); + const SubPic &curSubPic = pu.cu->slice->getPPS()->getSubPicFromPos(puPos); if (curSubPic.getTreatedAsPicFlag()) { horMax = std::min((int)curSubPic.getSubPicRight(), ctuX + (int)pu.cs->sps->getCTUSize() + 3); @@ -2999,9 +2902,6 @@ void clipColPos(int& posX, int& posY, const PredictionUnit& pu) { horMax = std::min((int)pu.cs->pps->getPicWidthInLumaSamples() - 1, ctuX + (int)pu.cs->sps->getCTUSize() + 3); } -#else - int horMax = std::min( (int)pu.cs->pps->getPicWidthInLumaSamples() - 1, ctuX + (int)pu.cs->sps->getCTUSize() + 3 ); -#endif int horMin = std::max((int)0, ctuX); int verMax = std::min( (int)pu.cs->pps->getPicHeightInLumaSamples() - 1, ctuY + (int)pu.cs->sps->getCTUSize() - 1 ); int verMin = std::max((int)0, ctuY); @@ -3337,179 +3237,12 @@ void PU::restrictBiPredMergeCandsOne(PredictionUnit &pu) } } -#if !JVET_Q0806 -void PU::getTriangleMergeCandidates( const PredictionUnit &pu, MergeCtx& triangleMrgCtx ) -{ - MergeCtx tmpMergeCtx; - -#if JVET_Q0798_SPS_NUMBER_MERGE_CANDIDATE - const uint32_t maxNumMergeCand = pu.cs->sps->getMaxNumMergeCand(); -#else - const Slice &slice = *pu.cs->slice; - const uint32_t maxNumMergeCand = slice.getPicHeader()->getMaxNumMergeCand(); -#endif - - triangleMrgCtx.numValidMergeCand = 0; - - for (int32_t i = 0; i < TRIANGLE_MAX_NUM_UNI_CANDS; i++) - { - triangleMrgCtx.BcwIdx[i] = BCW_DEFAULT; - triangleMrgCtx.interDirNeighbours[i] = 0; - triangleMrgCtx.mrgTypeNeighbours[i] = MRG_TYPE_DEFAULT_N; - triangleMrgCtx.mvFieldNeighbours[(i << 1)].refIdx = NOT_VALID; - triangleMrgCtx.mvFieldNeighbours[(i << 1) + 1].refIdx = NOT_VALID; - triangleMrgCtx.mvFieldNeighbours[(i << 1)].mv = Mv(); - triangleMrgCtx.mvFieldNeighbours[(i << 1) + 1].mv = Mv(); - triangleMrgCtx.useAltHpelIf[i] = false; - } - - PU::getInterMergeCandidates(pu, tmpMergeCtx, 0); - - for (int32_t i = 0; i < maxNumMergeCand; i++) - { - int parity = i & 1; - if (tmpMergeCtx.interDirNeighbours[i] & (0x01 + parity)) - { - triangleMrgCtx.interDirNeighbours[triangleMrgCtx.numValidMergeCand] = 1 + parity; - triangleMrgCtx.mrgTypeNeighbours[triangleMrgCtx.numValidMergeCand] = MRG_TYPE_DEFAULT_N; - triangleMrgCtx.mvFieldNeighbours[(triangleMrgCtx.numValidMergeCand << 1) + !parity].mv = Mv(0, 0); - triangleMrgCtx.mvFieldNeighbours[(triangleMrgCtx.numValidMergeCand << 1) + parity].mv = tmpMergeCtx.mvFieldNeighbours[(i << 1) + parity].mv; - triangleMrgCtx.mvFieldNeighbours[(triangleMrgCtx.numValidMergeCand << 1) + !parity].refIdx = -1; - triangleMrgCtx.mvFieldNeighbours[(triangleMrgCtx.numValidMergeCand << 1) + parity].refIdx = tmpMergeCtx.mvFieldNeighbours[(i << 1) + parity].refIdx; - triangleMrgCtx.numValidMergeCand++; - if (triangleMrgCtx.numValidMergeCand == TRIANGLE_MAX_NUM_UNI_CANDS) - { - return; - } - continue; - } - - if (tmpMergeCtx.interDirNeighbours[i] & (0x02 - parity)) - { - triangleMrgCtx.interDirNeighbours[triangleMrgCtx.numValidMergeCand] = 2 - parity; - triangleMrgCtx.mrgTypeNeighbours[triangleMrgCtx.numValidMergeCand] = MRG_TYPE_DEFAULT_N; - triangleMrgCtx.mvFieldNeighbours[(triangleMrgCtx.numValidMergeCand << 1) + !parity].mv = tmpMergeCtx.mvFieldNeighbours[(i << 1) + !parity].mv; - triangleMrgCtx.mvFieldNeighbours[(triangleMrgCtx.numValidMergeCand << 1) + parity].mv = Mv(0, 0); - triangleMrgCtx.mvFieldNeighbours[(triangleMrgCtx.numValidMergeCand << 1) + !parity].refIdx = tmpMergeCtx.mvFieldNeighbours[(i << 1) + !parity].refIdx; - triangleMrgCtx.mvFieldNeighbours[(triangleMrgCtx.numValidMergeCand << 1) + parity].refIdx = -1; - triangleMrgCtx.numValidMergeCand++; - if (triangleMrgCtx.numValidMergeCand == TRIANGLE_MAX_NUM_UNI_CANDS) - { - return; - } - } - } -} - -void PU::spanTriangleMotionInfo( PredictionUnit &pu, MergeCtx &triangleMrgCtx, const bool splitDir, const uint8_t candIdx0, const uint8_t candIdx1 ) -{ - pu.triangleSplitDir = splitDir; - pu.triangleMergeIdx0 = candIdx0; - pu.triangleMergeIdx1 = candIdx1; - MotionBuf mb = pu.getMotionBuf(); - - MotionInfo biMv; - biMv.isInter = true; - biMv.sliceIdx = pu.cs->slice->getIndependentSliceIdx(); - - if( triangleMrgCtx.interDirNeighbours[candIdx0] == 1 && triangleMrgCtx.interDirNeighbours[candIdx1] == 2 ) - { - biMv.interDir = 3; - biMv.mv[0] = triangleMrgCtx.mvFieldNeighbours[ candIdx0 << 1 ].mv; - biMv.mv[1] = triangleMrgCtx.mvFieldNeighbours[(candIdx1 << 1) + 1].mv; - biMv.refIdx[0] = triangleMrgCtx.mvFieldNeighbours[ candIdx0 << 1 ].refIdx; - biMv.refIdx[1] = triangleMrgCtx.mvFieldNeighbours[(candIdx1 << 1) + 1].refIdx; - } - else if( triangleMrgCtx.interDirNeighbours[candIdx0] == 2 && triangleMrgCtx.interDirNeighbours[candIdx1] == 1 ) - { - biMv.interDir = 3; - biMv.mv[0] = triangleMrgCtx.mvFieldNeighbours[ candIdx1 << 1 ].mv; - biMv.mv[1] = triangleMrgCtx.mvFieldNeighbours[(candIdx0 << 1) + 1].mv; - biMv.refIdx[0] = triangleMrgCtx.mvFieldNeighbours[ candIdx1 << 1 ].refIdx; - biMv.refIdx[1] = triangleMrgCtx.mvFieldNeighbours[(candIdx0 << 1) + 1].refIdx; - } - else if( triangleMrgCtx.interDirNeighbours[candIdx0] == 1 && triangleMrgCtx.interDirNeighbours[candIdx1] == 1 ) - { - biMv.interDir = 1; - biMv.mv[0] = triangleMrgCtx.mvFieldNeighbours[candIdx1 << 1].mv; - biMv.mv[1] = Mv(0, 0); - biMv.refIdx[0] = triangleMrgCtx.mvFieldNeighbours[candIdx1 << 1].refIdx; - biMv.refIdx[1] = -1; - } - else if( triangleMrgCtx.interDirNeighbours[candIdx0] == 2 && triangleMrgCtx.interDirNeighbours[candIdx1] == 2 ) - { - biMv.interDir = 2; - biMv.mv[0] = Mv(0, 0); - biMv.mv[1] = triangleMrgCtx.mvFieldNeighbours[(candIdx1 << 1) + 1].mv; - biMv.refIdx[0] = -1; - biMv.refIdx[1] = triangleMrgCtx.mvFieldNeighbours[(candIdx1 << 1) + 1].refIdx; - } - - int32_t idxW = (int32_t)(floorLog2(pu.lwidth() ) - MIN_CU_LOG2); - int32_t idxH = (int32_t)(floorLog2(pu.lheight()) - MIN_CU_LOG2); - for( int32_t y = 0; y < mb.height; y++ ) - { - for( int32_t x = 0; x < mb.width; x++ ) - { - if( g_triangleMvStorage[splitDir][idxH][idxW][y][x] == 2 ) - { - mb.at( x, y ).isInter = true; - mb.at( x, y ).interDir = biMv.interDir; - mb.at( x, y ).refIdx[0] = biMv.refIdx[0]; - mb.at( x, y ).refIdx[1] = biMv.refIdx[1]; - mb.at( x, y ).mv [0] = biMv.mv [0]; - mb.at( x, y ).mv [1] = biMv.mv [1]; - mb.at( x, y ).sliceIdx = biMv.sliceIdx; - } - else if( g_triangleMvStorage[splitDir][idxH][idxW][y][x] == 0 ) - { - mb.at( x, y ).isInter = true; - mb.at( x, y ).interDir = triangleMrgCtx.interDirNeighbours[candIdx0]; - mb.at( x, y ).refIdx[0] = triangleMrgCtx.mvFieldNeighbours[ candIdx0 << 1 ].refIdx; - mb.at( x, y ).refIdx[1] = triangleMrgCtx.mvFieldNeighbours[(candIdx0 << 1) + 1].refIdx; - mb.at( x, y ).mv [0] = triangleMrgCtx.mvFieldNeighbours[ candIdx0 << 1 ].mv; - mb.at( x, y ).mv [1] = triangleMrgCtx.mvFieldNeighbours[(candIdx0 << 1) + 1].mv; - mb.at( x, y ).sliceIdx = biMv.sliceIdx; - } - else - { - mb.at( x, y ).isInter = true; - mb.at( x, y ).interDir = triangleMrgCtx.interDirNeighbours[candIdx1]; - mb.at( x, y ).refIdx[0] = triangleMrgCtx.mvFieldNeighbours[ candIdx1 << 1 ].refIdx; - mb.at( x, y ).refIdx[1] = triangleMrgCtx.mvFieldNeighbours[(candIdx1 << 1) + 1].refIdx; - mb.at( x, y ).mv [0] = triangleMrgCtx.mvFieldNeighbours[ candIdx1 << 1 ].mv; - mb.at( x, y ).mv [1] = triangleMrgCtx.mvFieldNeighbours[(candIdx1 << 1) + 1].mv; - mb.at( x, y ).sliceIdx = biMv.sliceIdx; - } - } - } -} - -int32_t PU::mappingRefPic( const PredictionUnit &pu, int32_t refPicPoc, bool targetRefPicList ) -{ - int32_t numRefIdx = pu.cs->slice->getNumRefIdx( (RefPicList)targetRefPicList ); - - for( int32_t i = 0; i < numRefIdx; i++ ) - { - if( pu.cs->slice->getRefPOC( (RefPicList)targetRefPicList, i ) == refPicPoc ) - { - return i; - } - } - return -1; -} -#else void PU::getGeoMergeCandidates( const PredictionUnit &pu, MergeCtx& geoMrgCtx ) { MergeCtx tmpMergeCtx; -#if JVET_Q0798_SPS_NUMBER_MERGE_CANDIDATE const uint32_t maxNumMergeCand = pu.cs->sps->getMaxNumMergeCand(); -#else - const Slice &slice = *pu.cs->slice; - const uint32_t maxNumMergeCand = slice.getPicHeader()->getMaxNumMergeCand(); -#endif geoMrgCtx.numValidMergeCand = 0; for (int32_t i = 0; i < GEO_MAX_NUM_UNI_CANDS; i++) @@ -3662,7 +3395,6 @@ void PU::spanGeoMotionInfo( PredictionUnit &pu, MergeCtx &geoMrgCtx, const uint8 } } } -#endif bool CU::hasSubCUNonZeroMVd( const CodingUnit& cu ) { @@ -3984,37 +3716,20 @@ uint8_t CU::deriveBcwIdx( uint8_t bcwLO, uint8_t bcwL1 ) bool CU::bdpcmAllowed( const CodingUnit& cu, const ComponentID compID ) { -#if JVET_Q0183_SPS_TRANSFORM_SKIP_MODE_CONTROL SizeType transformSkipMaxSize = 1 << cu.cs->sps->getLog2MaxTransformSkipBlockSize(); -#else - SizeType transformSkipMaxSize = 1 << cu.cs->pps->getLog2MaxTransformSkipBlockSize(); -#endif -#if JVET_Q0089_SLICE_LOSSLESS_CODING_CHROMA_BDPCM bool bdpcmAllowed = cu.cs->sps->getBDPCMEnabledFlag(); -#else - bool bdpcmAllowed = cu.cs->sps->getBDPCMEnabled(); - bdpcmAllowed &= (isLuma(compID) || cu.cs->sps->getBDPCMEnabled() == BDPCM_LUMACHROMA); -#endif bdpcmAllowed &= CU::isIntra( cu ); if (isLuma(compID)) bdpcmAllowed &= (cu.lwidth() <= transformSkipMaxSize && cu.lheight() <= transformSkipMaxSize); else -#if JVET_Q0353_ACT_SW_FIX bdpcmAllowed &= (cu.chromaSize().width <= transformSkipMaxSize && cu.chromaSize().height <= transformSkipMaxSize) && !cu.colorTransform; -#else - bdpcmAllowed &= (cu.chromaSize().width <= transformSkipMaxSize && cu.chromaSize().height <= transformSkipMaxSize); -#endif return bdpcmAllowed; } bool CU::isMTSAllowed(const CodingUnit &cu, const ComponentID compID) { -#if JVET_Q0183_SPS_TRANSFORM_SKIP_MODE_CONTROL SizeType tsMaxSize = 1 << cu.cs->sps->getLog2MaxTransformSkipBlockSize(); -#else - SizeType tsMaxSize = 1 << cu.cs->pps->getLog2MaxTransformSkipBlockSize(); -#endif const int maxSize = CU::isIntra( cu ) ? MTS_INTRA_MAX_CU_SIZE : MTS_INTER_MAX_CU_SIZE; const int cuWidth = cu.blocks[0].lumaSize().width; const int cuHeight = cu.blocks[0].lumaSize().height; @@ -4057,11 +3772,7 @@ void TU::setCbfAtDepth(TransformUnit &tu, const ComponentID &compID, const unsig bool TU::isTSAllowed(const TransformUnit &tu, const ComponentID compID) { -#if JVET_Q0183_SPS_TRANSFORM_SKIP_MODE_CONTROL const int maxSize = tu.cs->sps->getLog2MaxTransformSkipBlockSize(); -#else - const int maxSize = tu.cs->pps->getLog2MaxTransformSkipBlockSize(); -#endif bool tsAllowed = tu.cs->sps->getTransformSkipEnabledFlag(); tsAllowed &= ( !tu.cu->ispMode || !isLuma(compID) ); @@ -4084,13 +3795,6 @@ int TU::getICTMode( const TransformUnit& tu, int jointCbCr ) return g_ictModes[ tu.cs->picHeader->getJointCbCrSignFlag() ][ jointCbCr ]; } -#if !REMOVE_PPS_REXT -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))))); -} -#endif bool TU::needsSqrt2Scale( const TransformUnit &tu, const ComponentID &compID ) { diff --git a/source/Lib/CommonLib/UnitTools.h b/source/Lib/CommonLib/UnitTools.h index b51a96028f762c7ff856958c71e1e19a8a92fdc5..9f6f0cfcf1d7e37d33dad8e88193c3586526a5da 100644 --- a/source/Lib/CommonLib/UnitTools.h +++ b/source/Lib/CommonLib/UnitTools.h @@ -66,9 +66,7 @@ namespace CU bool isSameSlice (const CodingUnit &cu, const CodingUnit &cu2); bool isSameTile (const CodingUnit &cu, const CodingUnit &cu2); bool isSameSliceAndTile (const CodingUnit &cu, const CodingUnit &cu2); -#if JVET_O1143_SUBPIC_BOUNDARY bool isSameSubPic (const CodingUnit &cu, const CodingUnit &cu2); -#endif bool isLastSubCUOfCtu (const CodingUnit &cu); uint32_t getCtuAddr (const CodingUnit &cu); int predictQP (const CodingUnit& cu, const int prevQP ); @@ -131,8 +129,14 @@ namespace PU int getLMSymbolList(const PredictionUnit &pu, int *modeList); int getIntraMPMs(const PredictionUnit &pu, unsigned *mpm, const ChannelType &channelType = CHANNEL_TYPE_LUMA); bool isMIP (const PredictionUnit &pu, const ChannelType &chType = CHANNEL_TYPE_LUMA); +#if JVET_R0350_MIP_CHROMA_444_SINGLETREE + bool isDMChromaMIP (const PredictionUnit &pu); +#endif uint32_t getIntraDirLuma (const PredictionUnit &pu); void getIntraChromaCandModes (const PredictionUnit &pu, unsigned modeList[NUM_CHROMA_MODE]); +#if JVET_R0350_MIP_CHROMA_444_SINGLETREE + const PredictionUnit &getCoLocatedLumaPU(const PredictionUnit &pu); +#endif uint32_t getFinalIntraMode (const PredictionUnit &pu, const ChannelType &chType); uint32_t getCoLocatedIntraLumaMode (const PredictionUnit &pu); int getWideAngIntraMode ( const TransformUnit &tu, const uint32_t dirMode, const ComponentID compID ); @@ -142,11 +146,7 @@ namespace PU void getIBCMergeCandidates (const PredictionUnit &pu, MergeCtx& mrgCtx, const int& mrgCandIdx = -1); void getInterMMVDMergeCandidates(const PredictionUnit &pu, MergeCtx& mrgCtx, const int& mrgCandIdx = -1); int getDistScaleFactor(const int &currPOC, const int &currRefPOC, const int &colPOC, const int &colRefPOC); -#if JVET_Q0297_MER bool isDiffMER (const Position &pos1, const Position &pos2, const unsigned plevel); -#else - bool isDiffMER (const PredictionUnit &pu, const PredictionUnit &pu2); -#endif bool getColocatedMVP (const PredictionUnit &pu, const RefPicList &eRefPicList, const Position &pos, Mv& rcMv, const int &refIdx, bool sbFlag); void fillMvpCand ( PredictionUnit &pu, const RefPicList &eRefPicList, const int &refIdx, AMVPInfo &amvpInfo ); void fillIBCMvpCand (PredictionUnit &pu, AMVPInfo &amvpInfo); @@ -175,14 +175,8 @@ namespace PU bool isLMCMode ( unsigned mode); bool isLMCModeEnabled (const PredictionUnit &pu, unsigned mode); bool isChromaIntraModeCrossCheckMode(const PredictionUnit &pu); -#if !JVET_Q0806 - void getTriangleMergeCandidates (const PredictionUnit &pu, MergeCtx &triangleMrgCtx); - void spanTriangleMotionInfo ( PredictionUnit &pu, MergeCtx &triangleMrgCtx, const bool splitDir, const uint8_t candIdx0, const uint8_t candIdx1); - int32_t mappingRefPic (const PredictionUnit &pu, int32_t refPicPoc, bool targetRefPicList); -#else void getGeoMergeCandidates (const PredictionUnit &pu, MergeCtx &GeoMrgCtx); void spanGeoMotionInfo ( PredictionUnit &pu, MergeCtx &GeoMrgCtx, const uint8_t splitDir, const uint8_t candIdx0, const uint8_t candIdx1); -#endif bool isAddNeighborMv (const Mv& currMv, Mv* neighborMvs, int numNeighborMv); void getIbcMVPsEncOnly(PredictionUnit &pu, Mv* mvPred, int& nbPred); bool getDerivedBV(PredictionUnit &pu, const Mv& currentMv, Mv& derivedMv); @@ -199,9 +193,6 @@ namespace TU bool getCbfAtDepth (const TransformUnit &tu, const ComponentID &compID, const unsigned &depth); void setCbfAtDepth ( TransformUnit &tu, const ComponentID &compID, const unsigned &depth, const bool &cbf); bool isTSAllowed (const TransformUnit &tu, const ComponentID compID); -#if !REMOVE_PPS_REXT - bool hasCrossCompPredInfo (const TransformUnit &tu, const ComponentID &compID); -#endif bool needsSqrt2Scale ( const TransformUnit &tu, const ComponentID &compID ); bool needsBlockSizeTrafoScale ( const TransformUnit &tu, const ComponentID &compID ); diff --git a/source/Lib/CommonLib/WeightPrediction.h b/source/Lib/CommonLib/WeightPrediction.h index 4cc91597c8251dda3cffd509d6b87a0cdc36ac4e..3b4596964e36c308486aec9bd483af7595d14d2a 100644 --- a/source/Lib/CommonLib/WeightPrediction.h +++ b/source/Lib/CommonLib/WeightPrediction.h @@ -69,7 +69,7 @@ public: const WPScalingParam *const wp1, PelUnitBuf &rpcYuvDst, const bool bRoundLuma = true, - const ComponentID maxNumComp = MAX_NUM_COMPONENT + const ComponentID maxNumComp = MAX_NUM_COMPONENT , bool lumaOnly = false , bool chromaOnly = false ); @@ -106,7 +106,7 @@ public: const CPelUnitBuf &pcYuvSrc0, const CPelUnitBuf &pcYuvSrc1, PelUnitBuf &pcYuvDst, - const ComponentID maxNumComp = MAX_NUM_COMPONENT + const ComponentID maxNumComp = MAX_NUM_COMPONENT , bool lumaOnly = false , bool chromaOnly = false ); diff --git a/source/Lib/CommonLib/dtrace_blockstatistics.cpp b/source/Lib/CommonLib/dtrace_blockstatistics.cpp index 9a4130a11a652eb1ed15146b0ffece3a6c9f3643..377bb674903028a85eb62b71cb825d19a235bd52 100644 --- a/source/Lib/CommonLib/dtrace_blockstatistics.cpp +++ b/source/Lib/CommonLib/dtrace_blockstatistics.cpp @@ -42,9 +42,7 @@ #include "CommonLib/Picture.h" #include "CommonLib/UnitTools.h" //#include "CommonLib/CodingStructure.h" -#if JVET_Q0806 #include <queue> -#endif #define BLOCK_STATS_POLYGON_MIN_POINTS 3 #define BLOCK_STATS_POLYGON_MAX_POINTS 5 @@ -226,7 +224,7 @@ void CDTrace::dtrace_block_vector(int k, const TransformUnit &tu, std::string st { const CodingStructure& cs = *tu.cs; #if BLOCK_STATS_AS_CSV - dtrace<false>(k, "BlockStat;%d;%4d;%4d;%2d;%2d;%s;%4d;%4d\n", cs.picture->poc, pu.lx(), pu.ly(), pu.lwidth(), pu.lheight(), stat_type.c_str(), val_x, val_y); + dtrace<false>(k, "BlockStat;%d;%4d;%4d;%2d;%2d;%s;%4d;%4d\n", cs.picture->poc, tu.lx(), tu.ly(), tu.lwidth(), tu.lheight(), stat_type.c_str(), val_x, val_y); #else dtrace<false>(k, "BlockStat: POC %d @(%4d,%4d) [%2dx%2d] %s={%4d,%4d}\n", cs.picture->poc, tu.lx(), tu.ly(), tu.lwidth(), tu.lheight(), stat_type.c_str(), val_x, val_y); #endif @@ -275,95 +273,6 @@ void CDTrace::dtrace_polygon_vector(int k, int poc, const std::vector<Position> dtrace<false>(k, "BlockStat: POC %d @[%s] %s={%4d,%4d}\n", poc, polygonDescription.c_str(), stat_type.c_str(), val_x, val_y); } -#if !JVET_Q0806 -void retrieveTriangularMvInfo(const PredictionUnit& pu, MotionInfo& mi0, MotionInfo& mi1) -{ - int triangleDir = pu.triangleSplitDir; - CMotionBuf mb = pu.getMotionBuf(); - bool foundMv[2] = { false, false }; - bool foundBi = false; - int32_t idxW = (int32_t)(floorLog2(pu.lwidth() ) - MIN_CU_LOG2); - int32_t idxH = (int32_t)(floorLog2(pu.lheight()) - MIN_CU_LOG2); - for (int32_t y = 0; y < mb.height; y++) - { - for (int32_t x = 0; x < mb.width; x++) - { - if (g_triangleMvStorage[triangleDir][idxH][idxW][y][x] == 0 && foundMv[0] == false) - { - mi0.mv[0] = mb.at(x, y).mv[0]; - mi0.mv[1] = mb.at(x, y).mv[1]; - mi0.refIdx[0] = mb.at(x, y).refIdx[0]; - mi0.refIdx[1] = mb.at(x, y).refIdx[1]; - foundMv[0] = true; - } - if (g_triangleMvStorage[triangleDir][idxH][idxW][y][x] == 1 && foundMv[1] == false) - { - mi1.mv[0] = mb.at(x, y).mv[0]; - mi1.mv[1] = mb.at(x, y).mv[1]; - mi1.refIdx[0] = mb.at(x, y).refIdx[0]; - mi1.refIdx[1] = mb.at(x, y).refIdx[1]; - foundMv[1] = true; - } - if (g_triangleMvStorage[triangleDir][idxH][idxW][y][x] == 2 && foundMv[0] == false && foundMv[1] == false) - { - mi0.mv[0] = Mv(0, 0); - mi0.mv[1] = Mv(0, 0); - mi1.mv[0] = Mv(0, 0); - mi1.mv[1] = Mv(0, 0); - mi0.refIdx[0] = -1; - mi0.refIdx[1] = -1; - mi1.refIdx[0] = -1; - mi1.refIdx[1] = -1; - if (mb.at(x, y).interDir == 3) - { - mi0.mv[0] = mb.at(x, y).mv[0]; - mi1.mv[0] = mb.at(x, y).mv[1]; - mi0.refIdx[0] = mb.at(x, y).refIdx[0]; - mi1.refIdx[0] = mb.at(x, y).refIdx[1]; - foundBi = true; - } - } - if ((foundMv[0] == true && foundMv[1] == true) || foundBi == true) - return; - } - } -} -void retrieveTrianglePolygon(const PredictionUnit& pu, std::vector<Position>& triangle0, std::vector<Position>& triangle1, Position& S, Position& E) -{ - TriangleSplit triangleDir = TriangleSplit(pu.triangleSplitDir); - Position TL = pu.Y().topLeft(); - Position TR = pu.Y().topRight(); TR = TR.offset(1, 0); - Position BL = pu.Y().bottomLeft(); BL = BL.offset(0, 1); - Position BR = pu.Y().bottomRight(); BR = BR.offset(1, 1); - - if (triangleDir == TRIANGLE_DIR_135) - { - S = Position(0, 0); - E = Position(pu.Y().width, pu.Y().height); - triangle0.push_back(TL); - triangle0.push_back(TR); - triangle0.push_back(BR); - triangle1.push_back(TL); - triangle1.push_back(BL); - triangle1.push_back(BR); - } - else if (triangleDir == TRIANGLE_DIR_45) - { - S = Position(0, pu.Y().height); - E = Position(pu.Y().width, 0); - triangle0.push_back(TL); - triangle0.push_back(TR); - triangle0.push_back(BL); - triangle1.push_back(TR); - triangle1.push_back(BL); - triangle1.push_back(BR); - } - else - { - CHECK(triangleDir != TRIANGLE_DIR_45 && triangleDir != TRIANGLE_DIR_135, "Unknown triangle type"); - } -} -#else void retrieveGeoPolygons(const CodingUnit& cu, std::vector<Position> (&geoPartitions)[2], Position (&linePositions)[2]) { // adapted code from interpolation filter to find geo partition polygons like this: @@ -542,7 +451,6 @@ void storeGeoMergeCtx(MergeCtx geoMergeCtx) { geoMergeCtxtsOfCurrentCtu.push(geoMergeCtx); } -#endif void writeBlockStatisticsHeader(const SPS *sps) { @@ -678,11 +586,7 @@ void writeAllData(const CodingStructure& cs, const UnitArea& ctuArea) DTRACE_BLOCK_SCALAR(g_trace_ctx, D_BLOCK_STATISTICS_ALL, pu, GetBlockStatisticName(BlockStatistic::MVPIdxL1), pu.mvpIdx[REF_PIC_LIST_1]); DTRACE_BLOCK_SCALAR(g_trace_ctx, D_BLOCK_STATISTICS_ALL, pu, GetBlockStatisticName(BlockStatistic::RefIdxL1), pu.refIdx[REF_PIC_LIST_1]); } -#if !JVET_Q0806 - if (!pu.cu->affine && !pu.cu->triangle) -#else if (!pu.cu->affine && !pu.cu->geoFlag) -#endif { if (pu.interDir != 2 /* PRED_L1 */) { @@ -707,29 +611,6 @@ void writeAllData(const CodingStructure& cs, const UnitArea& ctuArea) DTRACE_BLOCK_VECTOR(g_trace_ctx, D_BLOCK_STATISTICS_ALL, pu, GetBlockStatisticName(BlockStatistic::MVL1), mv.hor, mv.ver); } } -#if !JVET_Q0806 - else if (pu.cu->triangle) - { - MotionInfo mi[2]; - std::vector<Position> triangleCorners[2]; - Position S, E; - retrieveTrianglePolygon(pu, triangleCorners[0], triangleCorners[1], S, E); - DTRACE_LINE(g_trace_ctx, D_BLOCK_STATISTICS_ALL, cu, GetBlockStatisticName(BlockStatistic::TrianglePartitioning), S.x, S.y, E.x, E.y); - retrieveTriangularMvInfo(pu, mi[0], mi[1]); - for (int triangleIdx = 0; triangleIdx < 2; triangleIdx++) - { - for (int refIdx = 0; refIdx < 2; refIdx++) - { - mi[triangleIdx].mv[refIdx].hor = mi[triangleIdx].mv[refIdx].hor >= 0 ? (mi[triangleIdx].mv[refIdx].hor + nOffset) >> nShift : -((-mi[triangleIdx].mv[refIdx].hor + nOffset) >> nShift); - mi[triangleIdx].mv[refIdx].ver = mi[triangleIdx].mv[refIdx].ver >= 0 ? (mi[triangleIdx].mv[refIdx].ver + nOffset) >> nShift : -((-mi[triangleIdx].mv[refIdx].ver + nOffset) >> nShift); - if (mi[triangleIdx].refIdx[refIdx] != -1) - { - DTRACE_POLYGON_VECTOR(g_trace_ctx, D_BLOCK_STATISTICS_ALL, pu.cu->slice->getPOC(), triangleCorners[triangleIdx], GetBlockStatisticName(refIdx==0?BlockStatistic::TriangleMVL0:BlockStatistic::TriangleMVL1), mi[triangleIdx].mv[refIdx].hor, mi[triangleIdx].mv[refIdx].ver); - } - } - } - } -#endif else if (pu.cu->affine) { if (pu.interDir != 2 /* PRED_L1 */) @@ -841,7 +722,6 @@ void writeAllData(const CodingStructure& cs, const UnitArea& ctuArea) } } -#if JVET_Q0806 if (cu.geoFlag) { const uint8_t candIdx0 = cu.firstPU->geoMergeIdx0; @@ -908,7 +788,6 @@ void writeAllData(const CodingStructure& cs, const UnitArea& ctuArea) } } } -#endif DTRACE_BLOCK_SCALAR(g_trace_ctx, D_BLOCK_STATISTICS_ALL, cu, GetBlockStatisticName(BlockStatistic::SMVDFlag), cu.smvdMode); DTRACE_BLOCK_SCALAR(g_trace_ctx, D_BLOCK_STATISTICS_ALL, cu, GetBlockStatisticName(BlockStatistic::IMVMode), cu.imv); @@ -968,20 +847,6 @@ void writeAllData(const CodingStructure& cs, const UnitArea& ctuArea) DTRACE_BLOCK_SCALAR(g_trace_ctx, D_BLOCK_STATISTICS_ALL, tu, GetBlockStatisticName(BlockStatistic::JointCbCr), tu.jointCbCr); } -#if !REMOVE_PPS_REXT - bool lumaOnly = ( cu.chromaFormat == CHROMA_400 || !tu.blocks[COMPONENT_Cb].valid() ); - if( !lumaOnly ) - { - if( TU::hasCrossCompPredInfo( tu, COMPONENT_Cb ) ) - { - DTRACE_BLOCK_SCALAR(g_trace_ctx, D_BLOCK_STATISTICS_ALL, tu, GetBlockStatisticName(BlockStatistic::CompAlphaCb), tu.compAlpha[COMPONENT_Cb] ); - } - if( TU::hasCrossCompPredInfo( tu, COMPONENT_Cr ) ) - { - DTRACE_BLOCK_SCALAR(g_trace_ctx, D_BLOCK_STATISTICS_ALL, tu, GetBlockStatisticName(BlockStatistic::CompAlphaCr), tu.compAlpha[COMPONENT_Cr] ); - } - } -#endif if( !(cu.chromaFormat == CHROMA_400 || (cu.isSepTree() && cu.chType == CHANNEL_TYPE_LUMA)) ) { DTRACE_BLOCK_SCALAR_CHROMA(g_trace_ctx, D_BLOCK_STATISTICS_ALL, tu, GetBlockStatisticName(BlockStatistic::Cbf_Cb), tu.cbf[COMPONENT_Cb]); @@ -993,9 +858,7 @@ void writeAllData(const CodingStructure& cs, const UnitArea& ctuArea) } } -#if JVET_Q0806 CHECK(geoMergeCtxtsOfCurrentCtu.size() != 0, "Did not use all pushed back geo merge contexts. Should not be possible!"); -#endif } void writeAllCodedData(const CodingStructure & cs, const UnitArea & ctuArea) @@ -1126,11 +989,7 @@ void writeAllCodedData(const CodingStructure & cs, const UnitArea & ctuArea) DTRACE_BLOCK_SCALAR(g_trace_ctx, D_BLOCK_STATISTICS_CODED, pu, GetBlockStatisticName(BlockStatistic::MVPIdxL1), pu.mvpIdx[REF_PIC_LIST_1]); DTRACE_BLOCK_SCALAR(g_trace_ctx, D_BLOCK_STATISTICS_CODED, pu, GetBlockStatisticName(BlockStatistic::RefIdxL1), pu.refIdx[REF_PIC_LIST_1]); } -#if !JVET_Q0806 - if (!pu.cu->affine && !pu.cu->triangle) -#else if (!pu.cu->affine && !pu.cu->geoFlag) -#endif { if (pu.interDir != 2 /* PRED_L1 */) { @@ -1155,29 +1014,6 @@ void writeAllCodedData(const CodingStructure & cs, const UnitArea & ctuArea) DTRACE_BLOCK_VECTOR(g_trace_ctx, D_BLOCK_STATISTICS_CODED, pu, GetBlockStatisticName(BlockStatistic::MVL1), mv.hor, mv.ver); } } -#if !JVET_Q0806 - else if (pu.cu->triangle) - { - MotionInfo mi[2]; - std::vector<Position> triangleCorners[2]; - Position S, E; - retrieveTrianglePolygon(pu, triangleCorners[0], triangleCorners[1], S, E); - DTRACE_LINE(g_trace_ctx, D_BLOCK_STATISTICS_CODED, cu, GetBlockStatisticName(BlockStatistic::TrianglePartitioning), S.x, S.y, E.x, E.y); - retrieveTriangularMvInfo(pu, mi[0], mi[1]); - for (int triangleIdx = 0; triangleIdx < 2; triangleIdx++) - { - for (int refIdx = 0; refIdx < 2; refIdx++) - { - mi[triangleIdx].mv[refIdx].hor = mi[triangleIdx].mv[refIdx].hor >= 0 ? (mi[triangleIdx].mv[refIdx].hor + nOffset) >> nShift : -((-mi[triangleIdx].mv[refIdx].hor + nOffset) >> nShift); - mi[triangleIdx].mv[refIdx].ver = mi[triangleIdx].mv[refIdx].ver >= 0 ? (mi[triangleIdx].mv[refIdx].ver + nOffset) >> nShift : -((-mi[triangleIdx].mv[refIdx].ver + nOffset) >> nShift); - if (mi[triangleIdx].refIdx[refIdx] != -1) - { - DTRACE_POLYGON_VECTOR(g_trace_ctx, D_BLOCK_STATISTICS_CODED, pu.cu->slice->getPOC(), triangleCorners[triangleIdx], GetBlockStatisticName(refIdx==0?BlockStatistic::TriangleMVL0:BlockStatistic::TriangleMVL1), mi[triangleIdx].mv[refIdx].hor, mi[triangleIdx].mv[refIdx].ver); - } - } - } - } -#endif else { if (pu.interDir != 2 /* PRED_L1 */) diff --git a/source/Lib/CommonLib/dtrace_blockstatistics.h b/source/Lib/CommonLib/dtrace_blockstatistics.h index a900eec517a7625e704218939fc3615456ba07b2..4637d8be743bedb69c3fb541ea64ace50d081010 100644 --- a/source/Lib/CommonLib/dtrace_blockstatistics.h +++ b/source/Lib/CommonLib/dtrace_blockstatistics.h @@ -72,10 +72,6 @@ enum class BlockStatistic { IndependentSliceIdx, LFNSTIdx, JointCbCr, -#if !REMOVE_PPS_REXT - CompAlphaCb, - CompAlphaCr, -#endif RDPCM_Y, RDPCM_Cb, RDPCM_Cr, @@ -120,15 +116,9 @@ enum class BlockStatistic { MMVDMergeIdx, CiipFlag, SMVDFlag, -#if !JVET_Q0806 - TrianglePartitioning, - TriangleMVL0, //<< currently only uni-prediction enabled - TriangleMVL1, //<< currently only uni-prediction enabled -#else GeoPartitioning, GeoMVL0, //<< currently only uni-prediction enabled GeoMVL1, //<< currently only uni-prediction enabled -#endif BCWIndex, // for dual tree // general @@ -177,10 +167,6 @@ static const std::map<BlockStatistic, std::tuple<std::string, BlockStatisticType { BlockStatistic::IndependentSliceIdx, std::tuple<std::string, BlockStatisticType, std::string>{"IndependentSliceIdx", BlockStatisticType::Integer, ""}}, { BlockStatistic::LFNSTIdx, std::tuple<std::string, BlockStatisticType, std::string>{"LFNSTIdx", BlockStatisticType::Integer, "[0, 3]"}}, { BlockStatistic::JointCbCr, std::tuple<std::string, BlockStatisticType, std::string>{"JointCbCr", BlockStatisticType::Flag, ""}}, -#if !REMOVE_PPS_REXT - { BlockStatistic::CompAlphaCb, std::tuple<std::string, BlockStatisticType, std::string>{"CompAlphaCb", BlockStatisticType::Integer, ""}}, - { BlockStatistic::CompAlphaCr, std::tuple<std::string, BlockStatisticType, std::string>{"CompAlphaCr", BlockStatisticType::Integer, ""}}, -#endif { BlockStatistic::RDPCM_Y, std::tuple<std::string, BlockStatisticType, std::string>{"RDPCM_Y", BlockStatisticType::Integer, "[0, " + std::to_string(NUMBER_OF_RDPCM_MODES) + "]"}}, { BlockStatistic::RDPCM_Cb, std::tuple<std::string, BlockStatisticType, std::string>{"RDPCM_Cb", BlockStatisticType::Integer, "[0, " + std::to_string(NUMBER_OF_RDPCM_MODES) + "]"}}, { BlockStatistic::RDPCM_Cr, std::tuple<std::string, BlockStatisticType, std::string>{"RDPCM_Cr", BlockStatisticType::Integer, "[0, " + std::to_string(NUMBER_OF_RDPCM_MODES) + "]"}}, @@ -222,15 +208,9 @@ static const std::map<BlockStatistic, std::tuple<std::string, BlockStatisticType { BlockStatistic::MMVDMergeIdx, std::tuple<std::string, BlockStatisticType, std::string>{"MMVDMergeIdx", BlockStatisticType::Integer, "[0, 1]"}}, { BlockStatistic::CiipFlag, std::tuple<std::string, BlockStatisticType, std::string>{"CiipFlag", BlockStatisticType::Flag, ""}}, { BlockStatistic::SMVDFlag, std::tuple<std::string, BlockStatisticType, std::string>{"SMVDFlag", BlockStatisticType::Flag, ""}}, -#if !JVET_Q0806 - { BlockStatistic::TrianglePartitioning, std::tuple<std::string, BlockStatisticType, std::string>{"TrianglePartitioning", BlockStatisticType::Line, ""}}, - { BlockStatistic::TriangleMVL0, std::tuple<std::string, BlockStatisticType, std::string>{"TriangleMVL0", BlockStatisticType::VectorPolygon, "Scale: 4"}}, - { BlockStatistic::TriangleMVL1, std::tuple<std::string, BlockStatisticType, std::string>{"TriangleMVL1", BlockStatisticType::VectorPolygon, "Scale: 4"}}, -#else { BlockStatistic::GeoPartitioning, std::tuple<std::string, BlockStatisticType, std::string>{"GeoPartitioning", BlockStatisticType::Line, ""} }, { BlockStatistic::GeoMVL0, std::tuple<std::string, BlockStatisticType, std::string>{"GeoMVL0", BlockStatisticType::VectorPolygon, "Scale: 4"} }, { BlockStatistic::GeoMVL1, std::tuple<std::string, BlockStatisticType, std::string>{"GeoMVL1", BlockStatisticType::VectorPolygon, "Scale: 4"} }, -#endif { BlockStatistic::BCWIndex, std::tuple<std::string, BlockStatisticType, std::string>{"BCWIndex", BlockStatisticType::Integer, "[0, 4]"} }, // for dual tree { BlockStatistic::Depth_Chroma, std::tuple<std::string, BlockStatisticType, std::string>{"Depth_Chroma", BlockStatisticType::Integer, "[0, 10]"}}, // todo: actual limits? @@ -252,10 +232,8 @@ void writeBlockStatisticsHeader(const SPS *sps); void getAndStoreBlockStatistics(const CodingStructure& cs, const UnitArea& ctuArea); void writeAllData(const CodingStructure& cs, const UnitArea& ctuArea); void writeAllCodedData(const CodingStructure& cs, const UnitArea& ctuArea); -#if JVET_Q0806 class MergeCtx; void storeGeoMergeCtx(MergeCtx geoMergeCtx); #endif -#endif #endif // _DTRACE_BLOCKSTATISTICS_H_ diff --git a/source/Lib/CommonLib/version.h b/source/Lib/CommonLib/version.h index 43dcd0abf1ed15ac62871902d91009cf756aaaa9..908c57ea0e948777d395bed7ebb2fb9d258df0fc 100644 --- a/source/Lib/CommonLib/version.h +++ b/source/Lib/CommonLib/version.h @@ -1,3 +1,3 @@ #if ! defined( VTM_VERSION ) -#define VTM_VERSION "8.0" +#define VTM_VERSION "8.2" #endif diff --git a/source/Lib/CommonLib/x86/AdaptiveLoopFilterX86.h b/source/Lib/CommonLib/x86/AdaptiveLoopFilterX86.h index 30858585761678f3c87cdbb9c4bcc51b3e572a7b..12c44a2f87d0d8046c0e10fa31ff4dbbf4ef7467 100644 --- a/source/Lib/CommonLib/x86/AdaptiveLoopFilterX86.h +++ b/source/Lib/CommonLib/x86/AdaptiveLoopFilterX86.h @@ -313,6 +313,9 @@ static void simdFilter5x5Blk(AlfClassifier **classifier, const PelUnitBuf &recDs constexpr int SHIFT = AdaptiveLoopFilter::m_NUM_BITS - 1; constexpr int ROUND = 1 << (SHIFT - 1); +#if JVET_R0208_ALF_VB_ROUNDING_FIX + const __m128i mmOffset1 = _mm_set1_epi32((1 << ((SHIFT + 3) - 1)) - ROUND); +#endif const size_t width = blk.width; const size_t height = blk.height; @@ -416,7 +419,6 @@ static void simdFilter5x5Blk(AlfClassifier **classifier, const PelUnitBuf &recDs process2coeffs(0, pImg3 + 0, pImg4 + 0, pImg1 + 1, pImg2 - 1); process2coeffs(1, pImg1 + 0, pImg2 + 0, pImg1 - 1, pImg2 + 1); process2coeffs(2, pImg0 + 2, pImg0 - 2, pImg0 + 1, pImg0 - 1); -#if JVET_Q0150 bool isNearVBabove = yVb < vbPos && (yVb >= vbPos - 1); bool isNearVBbelow = yVb >= vbPos && (yVb <= vbPos); if (!(isNearVBabove || isNearVBbelow)) @@ -426,13 +428,14 @@ static void simdFilter5x5Blk(AlfClassifier **classifier, const PelUnitBuf &recDs } else { +#if JVET_R0208_ALF_VB_ROUNDING_FIX + accumA = _mm_srai_epi32(_mm_add_epi32(accumA, mmOffset1), SHIFT + 3); + accumB = _mm_srai_epi32(_mm_add_epi32(accumB, mmOffset1), SHIFT + 3); +#else accumA = _mm_srai_epi32(accumA, SHIFT + 3); accumB = _mm_srai_epi32(accumB, SHIFT + 3); - } -#else - accumA = _mm_srai_epi32(accumA, SHIFT); - accumB = _mm_srai_epi32(accumB, SHIFT); #endif + } accumA = _mm_packs_epi32(accumA, accumB); accumA = _mm_add_epi16(accumA, cur); accumA = _mm_min_epi16(mmMax, _mm_max_epi16(accumA, mmMin)); @@ -512,6 +515,9 @@ static void simdFilter7x7Blk(AlfClassifier **classifier, const PelUnitBuf &recDs Pel * dst = dstBuffer.buf + blkDst.y * dstStride + blkDst.x; const __m128i mmOffset = _mm_set1_epi32(ROUND); +#if JVET_R0208_ALF_VB_ROUNDING_FIX + const __m128i mmOffset1 = _mm_set1_epi32((1 << ((SHIFT + 3) - 1)) - ROUND); +#endif const __m128i mmMin = _mm_set1_epi16( clpRng.min ); const __m128i mmMax = _mm_set1_epi16( clpRng.max ); @@ -651,7 +657,6 @@ static void simdFilter7x7Blk(AlfClassifier **classifier, const PelUnitBuf &recDs process2coeffs(5, pImg0 + 2, pImg0 - 2, pImg0 + 1, pImg0 - 1); -#if JVET_Q0150 bool isNearVBabove = yVb < vbPos && (yVb >= vbPos - 1); bool isNearVBbelow = yVb >= vbPos && (yVb <= vbPos); if (!(isNearVBabove || isNearVBbelow)) @@ -661,13 +666,14 @@ static void simdFilter7x7Blk(AlfClassifier **classifier, const PelUnitBuf &recDs } else { +#if JVET_R0208_ALF_VB_ROUNDING_FIX + accumA = _mm_srai_epi32(_mm_add_epi32(accumA, mmOffset1), SHIFT + 3); + accumB = _mm_srai_epi32(_mm_add_epi32(accumB, mmOffset1), SHIFT + 3); +#else accumA = _mm_srai_epi32(accumA, SHIFT + 3); accumB = _mm_srai_epi32(accumB, SHIFT + 3); +#endif } -#else - accumA = _mm_srai_epi32(accumA, SHIFT); - accumB = _mm_srai_epi32(accumB, SHIFT); -#endif accumA = _mm_packs_epi32(accumA, accumB); accumA = _mm_add_epi16(accumA, cur); accumA = _mm_min_epi16(mmMax, _mm_max_epi16(accumA, mmMin)); diff --git a/source/Lib/CommonLib/x86/InterpolationFilterX86.h b/source/Lib/CommonLib/x86/InterpolationFilterX86.h index 81608d2a4da059975fd7a81eeb09170b82b0dcc5..c4e093f85baf3f6f1203cab80530e16b5766da1c 100644 --- a/source/Lib/CommonLib/x86/InterpolationFilterX86.h +++ b/source/Lib/CommonLib/x86/InterpolationFilterX86.h @@ -1327,130 +1327,6 @@ static void simdFilter( const ClpRng& clpRng, Pel const *src, int srcStride, Pel } } -#if !JVET_Q0806 -template< X86_VEXT vext > -void xWeightedTriangleBlk_SSE(const PredictionUnit &pu, const uint32_t width, const uint32_t height, const ComponentID compIdx, const bool splitDir, PelUnitBuf& predDst, PelUnitBuf& predSrc0, PelUnitBuf& predSrc1) -{ - Pel* dst = predDst.get(compIdx).buf; - Pel* src0 = predSrc0.get(compIdx).buf; - Pel* src1 = predSrc1.get(compIdx).buf; - int32_t strideDst = predDst.get(compIdx).stride; - int32_t strideSrc0 = predSrc0.get(compIdx).stride; - int32_t strideSrc1 = predSrc1.get(compIdx).stride; - - int32_t chromaScaleX = getComponentScaleX(compIdx, pu.chromaFormat); - int32_t chromaScaleY = getComponentScaleY(compIdx, pu.chromaFormat); - int8_t log2WidthY = floorLog2(width << chromaScaleX) - 1; - int8_t log2HeightY = floorLog2(height << chromaScaleY) - 1; - const char log2WeightBase = 3; - const ClpRng clpRng = pu.cu->slice->clpRngs().comp[compIdx]; - const int32_t shiftWeighted = std::max<int>(2, (IF_INTERNAL_PREC - clpRng.bd)) + log2WeightBase; - const int32_t offsetWeighted = (1 << (shiftWeighted - 1)) + (IF_INTERNAL_OFFS << log2WeightBase); - int16_t *weight = g_triangleWeights[splitDir][log2HeightY][log2WidthY]; - int16_t stepY = width << (chromaScaleX + chromaScaleY); - - const __m128i mmEight = _mm_set1_epi16(8); - const __m128i mmOffset = _mm_set1_epi32(offsetWeighted); - const __m128i mmShift = _mm_cvtsi32_si128(shiftWeighted); - const __m128i mmMin = _mm_set1_epi16(clpRng.min); - const __m128i mmMax = _mm_set1_epi16(clpRng.max); - - if (width == 2) - { - const __m128i mask = _mm_set_epi16( (short) 0x8080, (short) 0x8080, (short) 0x8080, (short) 0x8080, (short) 0x8080, (short) 0x8080, 0x0504, 0x0100 ); - for (int y = 0; y < height; y++) - { - __m128i s0 = _mm_cvtsi32_si128(*(uint32_t *) src0); - __m128i s1 = _mm_cvtsi32_si128(*(uint32_t *) src1); - __m128i w0 = _mm_loadl_epi64((__m128i *) (weight)); - if (chromaScaleX == 1) - { - w0 = _mm_shuffle_epi8(w0, mask); - } - __m128i w1 = _mm_sub_epi16(mmEight, w0); - s0 = _mm_unpacklo_epi16(s0, s1); - w0 = _mm_unpacklo_epi16(w0, w1); - s0 = _mm_add_epi32(_mm_madd_epi16(s0, w0), mmOffset); - s0 = _mm_sra_epi32(s0, mmShift); - s0 = _mm_packs_epi32(s0, s0); - s0 = _mm_min_epi16(mmMax, _mm_max_epi16(s0, mmMin)); - - *(uint32_t *) dst = _mm_cvtsi128_si32(s0); - dst += strideDst; - src0 += strideSrc0; - src1 += strideSrc1; - weight += stepY; - } - } - else if(width == 4) - { - const __m128i mask = _mm_set_epi16( (short) 0x8080, (short) 0x8080, (short) 0x8080, (short) 0x8080, 0x0D0C, 0x0908, 0x0504, 0x0100 ); - for (int y = 0; y < height; y++) - { - __m128i s0 = _mm_loadl_epi64((__m128i *) (src0)); - __m128i s1 = _mm_loadl_epi64((__m128i *) (src1)); - __m128i w0 = _mm_loadu_si128((__m128i *) (weight)); - if (chromaScaleX == 1) - { - w0 = _mm_shuffle_epi8(w0, mask); - } - __m128i w1 = _mm_sub_epi16(mmEight, w0); - s0 = _mm_unpacklo_epi16(s0, s1); - w0 = _mm_unpacklo_epi16(w0, w1); - s0 = _mm_add_epi32(_mm_madd_epi16(s0, w0), mmOffset); - s0 = _mm_sra_epi32(s0, mmShift); - s0 = _mm_packs_epi32(s0, s0); - s0 = _mm_min_epi16(mmMax, _mm_max_epi16(s0, mmMin)); - _mm_storel_epi64((__m128i *) (dst), s0); - dst += strideDst; - src0 += strideSrc0; - src1 += strideSrc1; - weight += stepY; - } - } - else - { - const __m128i mask1 = _mm_set_epi16( 0x0D0C, 0x0908, 0x0504, 0x0100, (short) 0x8080, (short) 0x8080, (short) 0x8080, (short) 0x8080 ); - const __m128i mask2 = _mm_set_epi16( (short) 0x8080, (short) 0x8080, (short) 0x8080, (short) 0x8080, 0x0D0C, 0x0908, 0x0504, 0x0100 ); - for (int y = 0; y < height; y++) - { - for (int x = 0; x < width; x += 8) - { - __m128i s0 = _mm_loadu_si128((__m128i *) (src0 + x)); - __m128i s1 = _mm_loadu_si128((__m128i *) (src1 + x)); - - __m128i w0 = _mm_loadu_si128((__m128i *) (weight + (x << chromaScaleX))); - if (chromaScaleX == 1) - { - __m128i w01 = _mm_loadu_si128((__m128i *) (weight + (x << chromaScaleX) + 8)); - w0 = _mm_shuffle_epi8(w0, mask1); - w01 = _mm_shuffle_epi8(w01, mask2); - w0 = _mm_alignr_epi8(w01, w0, 8); - } - __m128i w1 = _mm_sub_epi16(mmEight, w0); - - __m128i s0tmp = _mm_unpacklo_epi16(s0, s1); - __m128i w0tmp = _mm_unpacklo_epi16(w0, w1); - s0tmp = _mm_add_epi32(_mm_madd_epi16(s0tmp, w0tmp), mmOffset); - s0tmp = _mm_sra_epi32(s0tmp, mmShift); - - s0 = _mm_unpackhi_epi16(s0, s1); - w0 = _mm_unpackhi_epi16(w0, w1); - s0 = _mm_add_epi32(_mm_madd_epi16(s0, w0), mmOffset); - s0 = _mm_sra_epi32(s0, mmShift); - - s0 = _mm_packs_epi32(s0tmp, s0); - s0 = _mm_min_epi16(mmMax, _mm_max_epi16(s0, mmMin)); - _mm_storeu_si128((__m128i *) (dst + x), s0); - } - dst += strideDst; - src0 += strideSrc0; - src1 += strideSrc1; - weight += stepY; - } - } -} -#else template< X86_VEXT vext > void xWeightedGeoBlk_SSE(const PredictionUnit &pu, const uint32_t width, const uint32_t height, const ComponentID compIdx, const uint8_t splitDir, PelUnitBuf& predDst, PelUnitBuf& predSrc0, PelUnitBuf& predSrc1) { @@ -1670,7 +1546,6 @@ void xWeightedGeoBlk_SSE(const PredictionUnit &pu, const uint32_t width, const u } } } -#endif template <X86_VEXT vext> void InterpolationFilter::_initInterpolationFilterX86() @@ -1711,11 +1586,7 @@ void InterpolationFilter::_initInterpolationFilterX86() m_filterCopy[1][0] = simdFilterCopy<vext, true, false>; m_filterCopy[1][1] = simdFilterCopy<vext, true, true>; -#if !JVET_Q0806 - m_weightedTriangleBlk = xWeightedTriangleBlk_SSE<vext>; -#else m_weightedGeoBlk = xWeightedGeoBlk_SSE<vext>; -#endif } template void InterpolationFilter::_initInterpolationFilterX86<SIMDX86>(); diff --git a/source/Lib/CommonLib/x86/RdCostX86.h b/source/Lib/CommonLib/x86/RdCostX86.h index b11df9504448ceb4db9fd248851b1c38ff52736d..a41f090aec0e2223bcab752a138762df74de2673 100644 --- a/source/Lib/CommonLib/x86/RdCostX86.h +++ b/source/Lib/CommonLib/x86/RdCostX86.h @@ -523,6 +523,9 @@ static uint32_t xCalcHAD4x4_SSE( const Torg *piOrg, const Tcur *piCur, const int // abs __m128i Sum = _mm_abs_epi16( r0 ); +#if JVET_R0164_MEAN_SCALED_SATD + uint32_t absDc = _mm_cvtsi128_si32( Sum ) & 0x0000ffff; +#endif Sum = _mm_add_epi16( Sum, _mm_abs_epi16( r2 ) ); Sum = _mm_add_epi16( Sum, _mm_abs_epi16( r3 ) ); Sum = _mm_add_epi16( Sum, _mm_abs_epi16( r5 ) ); @@ -534,7 +537,11 @@ static uint32_t xCalcHAD4x4_SSE( const Torg *piOrg, const Tcur *piCur, const int uint32_t sad = _mm_cvtsi128_si32( Sum ); - sad = ( ( sad + 1 ) >> 1 ); +#if JVET_R0164_MEAN_SCALED_SATD + sad -= absDc; + sad += absDc >> 2; +#endif + sad = ( ( sad + 1 ) >> 1 ); return sad; } @@ -663,7 +670,12 @@ static uint32_t xCalcHAD8x8_SSE( const Torg *piOrg, const Tcur *piCur, const int iSum = _mm_hadd_epi32( iSum, iSum ); uint32_t sad = _mm_cvtsi128_si32( iSum ); - sad = ( ( sad + 2 ) >> 2 ); +#if JVET_R0164_MEAN_SCALED_SATD + uint32_t absDc = _mm_cvtsi128_si32( n1[0][0] ); + sad -= absDc; + sad += absDc >> 2; +#endif + sad = ( ( sad + 2 ) >> 2 ); return sad; } @@ -725,6 +737,9 @@ static uint32_t xCalcHAD16x8_SSE( const Torg *piOrg, const Tcur *piCur, const in // 4 x 8x4 blocks // 0 1 // 2 3 +#if JVET_R0164_MEAN_SCALED_SATD + uint32_t absDc = 0; +#endif // transpose and do horizontal in two steps for( int l = 0; l < 2; l++ ) @@ -841,6 +856,11 @@ static uint32_t xCalcHAD16x8_SSE( const Torg *piOrg, const Tcur *piCur, const in n1[14] = _mm_abs_epi32( _mm_add_epi32( n2[14], n2[15] ) ); n1[15] = _mm_abs_epi32( _mm_sub_epi32( n2[14], n2[15] ) ); +#if JVET_R0164_MEAN_SCALED_SATD + if (l == 0) + absDc = _mm_cvtsi128_si32( n1[0] ); +#endif + // sum up n1[0] = _mm_add_epi32( n1[0], n1[1] ); n1[2] = _mm_add_epi32( n1[2], n1[3] ); @@ -868,7 +888,11 @@ static uint32_t xCalcHAD16x8_SSE( const Torg *piOrg, const Tcur *piCur, const in uint32_t sad = _mm_cvtsi128_si32( iSum ); - sad = (uint32_t)(sad / sqrt(16.0 * 8) * 2); +#if JVET_R0164_MEAN_SCALED_SATD + sad -= absDc; + sad += absDc >> 2; +#endif + sad = (uint32_t)(sad / sqrt(16.0 * 8) * 2); return sad; } @@ -984,6 +1008,10 @@ static uint32_t xCalcHAD8x16_SSE( const Torg *piOrg, const Tcur *piCur, const in } } +#if JVET_R0164_MEAN_SCALED_SATD + uint32_t absDc = 0; +#endif + for( int l = 0; l < 2; l++ ) { int off = l * 8; @@ -1028,6 +1056,11 @@ static uint32_t xCalcHAD8x16_SSE( const Torg *piOrg, const Tcur *piCur, const in n1[i][5] = _mm_abs_epi32( _mm_sub_epi32( n2[i][4], n2[i][5] ) ); n1[i][6] = _mm_abs_epi32( _mm_add_epi32( n2[i][6], n2[i][7] ) ); n1[i][7] = _mm_abs_epi32( _mm_sub_epi32( n2[i][6], n2[i][7] ) ); + +#if JVET_R0164_MEAN_SCALED_SATD + if ( l + i == 0 ) + absDc = _mm_cvtsi128_si32( n1[i][0] ); +#endif } for( int i = 0; i < 8; i++ ) @@ -1050,7 +1083,11 @@ static uint32_t xCalcHAD8x16_SSE( const Torg *piOrg, const Tcur *piCur, const in uint32_t sad = _mm_cvtsi128_si32( iSum ); - sad = (uint32_t)(sad / sqrt(16.0 * 8) * 2); +#if JVET_R0164_MEAN_SCALED_SATD + sad -= absDc; + sad += absDc >> 2; +#endif + sad = (uint32_t)(sad / sqrt(16.0 * 8) * 2); return sad; } @@ -1177,6 +1214,9 @@ static uint32_t xCalcHAD8x4_SSE( const Torg *piOrg, const Tcur *piCur, const int } } +#if JVET_R0164_MEAN_SCALED_SATD + uint32_t absDc = _mm_cvtsi128_si32( m1[0] ); +#endif m1[0] = _mm_add_epi32( m1[0], m1[1] ); m1[1] = _mm_add_epi32( m1[2], m1[3] ); @@ -1193,7 +1233,11 @@ static uint32_t xCalcHAD8x4_SSE( const Torg *piOrg, const Tcur *piCur, const int uint32_t sad = _mm_cvtsi128_si32( iSum ); //sad = ((sad + 2) >> 2); - sad = (uint32_t)(sad / sqrt(4.0 * 8) * 2); +#if JVET_R0164_MEAN_SCALED_SATD + sad -= absDc; + sad += absDc >> 2; +#endif + sad = (uint32_t)(sad / sqrt(4.0 * 8) * 2); return sad; } @@ -1261,6 +1305,10 @@ static uint32_t xCalcHAD4x8_SSE( const Torg *piOrg, const Tcur *piCur, const int m2[3] = _mm_unpackhi_epi64( m1[1], m1[3] ); } +#if JVET_R0164_MEAN_SCALED_SATD + uint32_t absDc = 0; +#endif + if( iBitDepth >= 10 /*sizeof( Torg ) > 1 || sizeof( Tcur ) > 1*/ ) { __m128i n1[4][2]; @@ -1288,6 +1336,10 @@ static uint32_t xCalcHAD4x8_SSE( const Torg *piOrg, const Tcur *piCur, const int { m1[i] = _mm_add_epi32( n1[i][0], n1[i][1] ); } + +#if JVET_R0164_MEAN_SCALED_SATD + absDc = _mm_cvtsi128_si32( n1[0][0] ); +#endif } else { @@ -1310,6 +1362,10 @@ static uint32_t xCalcHAD4x8_SSE( const Torg *piOrg, const Tcur *piCur, const int ma2 = _mm_unpackhi_epi16( m2[i], vzero ); m1[i] = _mm_add_epi32( ma1, ma2 ); } + +#if JVET_R0164_MEAN_SCALED_SATD + absDc = _mm_cvtsi128_si32( m2[0] ) & 0x0000ffff; +#endif } m1[0] = _mm_add_epi32( m1[0], m1[1] ); @@ -1323,7 +1379,11 @@ static uint32_t xCalcHAD4x8_SSE( const Torg *piOrg, const Tcur *piCur, const int uint32_t sad = _mm_cvtsi128_si32( iSum ); //sad = ((sad + 2) >> 2); - sad = (uint32_t)(sad / sqrt(4.0 * 8) * 2); +#if JVET_R0164_MEAN_SCALED_SATD + sad -= absDc; + sad += absDc >> 2; +#endif + sad = (uint32_t)(sad / sqrt(4.0 * 8) * 2); return sad; } @@ -1462,6 +1522,11 @@ static uint32_t xCalcHAD16x16_AVX2( const Torg *piOrg, const Tcur *piCur, const m2[i][7] = _mm256_abs_epi32( _mm256_sub_epi32( m1[i][6], m1[i][7] ) ); } +#if JVET_R0164_MEAN_SCALED_SATD + uint32_t absDc0 = _mm_cvtsi128_si32( _mm256_castsi256_si128( m2[0][0] ) ); + uint32_t absDc1 = _mm_cvtsi128_si32( _mm256_castsi256_si128( _mm256_permute2x128_si256( m2[0][0], m2[0][0], 0x11 ) ) ); +#endif + for( int i = 0; i < 8; i++ ) { m1[0][i] = _mm256_add_epi32( m2[0][i], m2[1][i] ); @@ -1481,12 +1546,20 @@ static uint32_t xCalcHAD16x16_AVX2( const Torg *piOrg, const Tcur *piCur, const iSum = _mm256_hadd_epi32( iSum, iSum ); uint32_t tmp; - tmp = _mm_cvtsi128_si32( _mm256_castsi256_si128( iSum ) ); - tmp = ( ( tmp + 2 ) >> 2 ); + tmp = _mm_cvtsi128_si32( _mm256_castsi256_si128( iSum ) ); +#if JVET_R0164_MEAN_SCALED_SATD + tmp -= absDc0; + tmp += absDc0 >> 2; +#endif + tmp = ( ( tmp + 2 ) >> 2 ); sad += tmp; - tmp = _mm_cvtsi128_si32( _mm256_castsi256_si128( _mm256_permute2x128_si256( iSum, iSum, 0x11 ) ) ); - tmp = ( ( tmp + 2 ) >> 2 ); + tmp = _mm_cvtsi128_si32( _mm256_castsi256_si128( _mm256_permute2x128_si256( iSum, iSum, 0x11 ) ) ); +#if JVET_R0164_MEAN_SCALED_SATD + tmp -= absDc1; + tmp += absDc1 >> 2; +#endif + tmp = ( ( tmp + 2 ) >> 2 ); sad += tmp; } @@ -1700,6 +1773,10 @@ static uint32_t xCalcHAD16x8_AVX2( const Torg *piOrg, const Tcur *piCur, const i m1[15] = _mm256_abs_epi32( _mm256_sub_epi32( m2[14], m2[15] ) ); } +#if JVET_R0164_MEAN_SCALED_SATD + uint32_t absDc = _mm_cvtsi128_si32( _mm256_castsi256_si128( m1[0] ) ); +#endif + // sum up m1[ 0] = _mm256_add_epi32( m1[ 0], m1[ 1] ); m1[ 2] = _mm256_add_epi32( m1[ 2], m1[ 3] ); @@ -1723,9 +1800,12 @@ static uint32_t xCalcHAD16x8_AVX2( const Torg *piOrg, const Tcur *piCur, const i iSum = _mm256_hadd_epi32( iSum, iSum ); iSum = _mm256_add_epi32( iSum, _mm256_permute2x128_si256( iSum, iSum, 0x11 ) ); - sad = _mm_cvtsi128_si32( _mm256_castsi256_si128( iSum ) ); - - sad = (uint32_t)(sad / sqrt(16.0 * 8) * 2); + sad = _mm_cvtsi128_si32( _mm256_castsi256_si128( iSum ) ); +#if JVET_R0164_MEAN_SCALED_SATD + sad -= absDc; + sad += absDc >> 2; +#endif + sad = (uint32_t)(sad / sqrt(16.0 * 8) * 2); } #endif //USE_AVX2 @@ -1911,6 +1991,10 @@ static uint32_t xCalcHAD8x16_AVX2( const Pel* piOrg, const Pel* piCur, const int m1[6] = _mm256_abs_epi32( _mm256_add_epi32( m2[6], m2[7] ) ); m1[7] = _mm256_abs_epi32( _mm256_sub_epi32( m2[6], m2[7] ) ); +#if JVET_R0164_MEAN_SCALED_SATD + int absDc = _mm_cvtsi128_si32( _mm256_castsi256_si128( m1[0] ) ); +#endif + m1[0 + 8] = _mm256_add_epi32( m2[0 + 8], m2[4 + 8] ); m1[1 + 8] = _mm256_add_epi32( m2[1 + 8], m2[5 + 8] ); m1[2 + 8] = _mm256_add_epi32( m2[2 + 8], m2[6 + 8] ); @@ -1965,7 +2049,11 @@ static uint32_t xCalcHAD8x16_AVX2( const Pel* piOrg, const Pel* piCur, const int int sad2 = _mm_cvtsi128_si32( _mm256_castsi256_si128( iSum ) ); - sad = (uint32_t)(sad2 / sqrt(16.0 * 8) * 2); +#if JVET_R0164_MEAN_SCALED_SATD + sad2 -= absDc; + sad2 += absDc >> 2; +#endif + sad = (uint32_t)(sad2 / sqrt(16.0 * 8) * 2); } #endif //USE_AVX2 @@ -1973,7 +2061,6 @@ static uint32_t xCalcHAD8x16_AVX2( const Pel* piOrg, const Pel* piCur, const int return (sad); } -#if JVET_Q0806 template< X86_VEXT vext > Distortion RdCost::xGetSADwMask_SIMD( const DistParam &rcDtParam ) { @@ -2063,7 +2150,6 @@ Distortion RdCost::xGetSADwMask_SIMD( const DistParam &rcDtParam ) return sum >> DISTORTION_PRECISION_ADJUSTMENT(rcDtParam.bitDepth); } -#endif template<X86_VEXT vext> Distortion RdCost::xGetHADs_SIMD( const DistParam &rcDtParam ) @@ -2242,9 +2328,7 @@ void RdCost::_initRdCostX86() m_afpDistortFunc[DF_SAD_INTERMEDIATE_BITDEPTH] = RdCost::xGetSAD_IBD_SIMD<vext>; -#if JVET_Q0806 m_afpDistortFunc[DF_SAD_WITH_MASK] = xGetSADwMask_SIMD<vext>; -#endif } template void RdCost::_initRdCostX86<SIMDX86>(); diff --git a/source/Lib/DecoderLib/CABACReader.cpp b/source/Lib/DecoderLib/CABACReader.cpp index 34474fbc0af5a5788a4efc87a907491b336decd7..248ca9e3d81c50a5e84a9c1be09465ac9d436f9e 100644 --- a/source/Lib/DecoderLib/CABACReader.cpp +++ b/source/Lib/DecoderLib/CABACReader.cpp @@ -194,7 +194,6 @@ void CABACReader::coding_tree_unit( CodingStructure& cs, const UnitArea& area, i } } } -#if JVET_Q0795_CCALF if (cs.sps->getCCALFEnabledFlag()) { for ( int compIdx = 1; compIdx < getNumberValidComponents( cs.pcv->chrFormat ); compIdx++ ) @@ -212,7 +211,6 @@ void CABACReader::coding_tree_unit( CodingStructure& cs, const UnitArea& area, i } } } -#endif if ( CS::isDualITree(cs) && cs.pcv->chrFormat != CHROMA_400 && cs.pcv->maxCUWidth > 64 ) @@ -270,7 +268,6 @@ void CABACReader::readAlfCtuFilterIndex(CodingStructure& cs, unsigned ctuRsAddr) } alfCtbFilterSetIndex[ctuRsAddr] = filtIndex; } -#if JVET_Q0795_CCALF void CABACReader::ccAlfFilterControlIdc(CodingStructure &cs, const ComponentID compID, const int curIdx, uint8_t *filterControlIdc, Position lumaPos, int filterCount) { @@ -307,7 +304,6 @@ void CABACReader::ccAlfFilterControlIdc(CodingStructure &cs, const ComponentID c DTRACE(g_trace_ctx, D_SYNTAX, "ccAlfFilterControlIdc() compID=%d pos=(%d,%d) ctxt=%d, filterCount=%d, idcVal=%d\n", compID, lumaPos.x, lumaPos.y, ctxt, filterCount, idcVal); } -#endif //================================================================================ // clause 7.3.8.3 @@ -481,9 +477,7 @@ void CABACReader::coding_tree( CodingStructure& cs, Partitioner& partitioner, CU if( cs.slice->getUseChromaQpAdj() && partitioner.currQgChromaEnable() ) { cuCtx.isChromaQpAdjCoded = false; -#if JVET_Q0267_RESET_CHROMA_QP_OFFSET cs.chromaQpAdj = 0; -#endif } // Reset delta QP coding flag and ChromaQPAdjustemt coding flag @@ -497,9 +491,7 @@ void CABACReader::coding_tree( CodingStructure& cs, Partitioner& partitioner, CU if (cs.slice->getUseChromaQpAdj() && pPartitionerChroma->currQgChromaEnable()) { pCuCtxChroma->isChromaQpAdjCoded = false; -#if JVET_Q0267_RESET_CHROMA_QP_OFFSET cs.chromaQpAdj = 0; -#endif } } @@ -671,7 +663,6 @@ void CABACReader::coding_tree( CodingStructure& cs, Partitioner& partitioner, CU bool jointPLT = false; if (cu.isSepTree()) { -#if JVET_Q0504_PLT_NON444 if( cu.isLocalSepTree() ) { compBegin = COMPONENT_Y; @@ -680,7 +671,6 @@ void CABACReader::coding_tree( CodingStructure& cs, Partitioner& partitioner, CU } else { -#endif if (isLuma(partitioner.chType)) { compBegin = COMPONENT_Y; @@ -691,18 +681,12 @@ void CABACReader::coding_tree( CodingStructure& cs, Partitioner& partitioner, CU compBegin = COMPONENT_Cb; numComp = 2; } -#if JVET_Q0504_PLT_NON444 } -#endif } else { compBegin = COMPONENT_Y; -#if JVET_Q0504_PLT_NON444 numComp = (cu.chromaFormat != CHROMA_400) ? 3 : 1; -#else - numComp = 3; -#endif jointPLT = true; } if (CU::isPLT(cu)) @@ -871,7 +855,6 @@ void CABACReader::coding_unit( CodingUnit &cu, Partitioner &partitioner, CUCtx& } else { -#if JVET_Q0504_PLT_NON444 if( cu.chromaFormat != CHROMA_400 ) { cu_palette_info(cu, COMPONENT_Y, 3, cuCtx); @@ -880,18 +863,10 @@ void CABACReader::coding_unit( CodingUnit &cu, Partitioner &partitioner, CUCtx& { cu_palette_info(cu, COMPONENT_Y, 1, cuCtx); } -#else - cu_palette_info(cu, COMPONENT_Y, 3, cuCtx); -#endif } end_of_ctu(cu, cuCtx); return; } -#if !JVET_Q0110_Q0785_CHROMA_BDPCM_420 - bdpcm_mode( cu, ComponentID( partitioner.chType ) ); - if (!CS::isDualITree(*cu.cs) && isLuma(partitioner.chType)) - bdpcm_mode(cu, ComponentID(CHANNEL_TYPE_CHROMA)); -#endif // --> create PUs @@ -1087,11 +1062,7 @@ void CABACReader::pred_mode( CodingUnit& cu ) cu.predMode = MODE_IBC; } } -#if JVET_Q0629_REMOVAL_PLT_4X4 if (!CU::isIBC(cu) && cu.cs->slice->getSPS()->getPLTMode() && cu.lwidth() <= 64 && cu.lheight() <= 64 && (cu.lumaSize().width * cu.lumaSize().height > 16) ) -#else - if (!CU::isIBC(cu) && cu.cs->slice->getSPS()->getPLTMode() && cu.lwidth() <= 64 && cu.lheight() <= 64) -#endif { if (m_BinDecoder.decodeBin(Ctx::PLTFlag(0))) { @@ -1104,11 +1075,7 @@ void CABACReader::pred_mode( CodingUnit& cu ) if (m_BinDecoder.decodeBin(Ctx::PredMode(DeriveCtx::CtxPredModeFlag(cu)))) { cu.predMode = MODE_INTRA; -#if JVET_Q0629_REMOVAL_PLT_4X4 if (cu.cs->slice->getSPS()->getPLTMode() && cu.lwidth() <= 64 && cu.lheight() <= 64 && (cu.lumaSize().width * cu.lumaSize().height > 16) ) -#else - if (cu.cs->slice->getSPS()->getPLTMode() && cu.lwidth() <= 64 && cu.lheight() <= 64) -#endif { if (m_BinDecoder.decodeBin(Ctx::PLTFlag(0))) { @@ -1141,11 +1108,11 @@ void CABACReader::pred_mode( CodingUnit& cu ) if ( cu.cs->slice->isIntra() || (cu.lwidth() == 4 && cu.lheight() == 4) || cu.isConsIntra() ) { cu.predMode = MODE_INTRA; -#if JVET_Q0629_REMOVAL_PLT_4X4 - if (cu.cs->slice->getSPS()->getPLTMode() && cu.lwidth() <= 64 && cu.lheight() <= 64 && ( ( (!isLuma(cu.chType)) && (cu.chromaSize().width * cu.chromaSize().height > 16) ) || ((isLuma(cu.chType)) && ((cu.lumaSize().width * cu.lumaSize().height) > 16 ) ) ) ) +#if JVET_R0334_PLT_CLEANUP + if (cu.cs->slice->getSPS()->getPLTMode() && cu.lwidth() <= 64 && cu.lheight() <= 64 && ( ( (!isLuma(cu.chType)) && (cu.chromaSize().width * cu.chromaSize().height > 16) ) || ((isLuma(cu.chType)) && ((cu.lumaSize().width * cu.lumaSize().height) > 16 ) ) ) && (!cu.isLocalSepTree() || isLuma(cu.chType) ) ) #else - if (cu.cs->slice->getSPS()->getPLTMode() && cu.lwidth() <= 64 && cu.lheight() <= 64) -#endif + if (cu.cs->slice->getSPS()->getPLTMode() && cu.lwidth() <= 64 && cu.lheight() <= 64 && ( ( (!isLuma(cu.chType)) && (cu.chromaSize().width * cu.chromaSize().height > 16) ) || ((isLuma(cu.chType)) && ((cu.lumaSize().width * cu.lumaSize().height) > 16 ) ) ) ) +#endif { if (m_BinDecoder.decodeBin(Ctx::PLTFlag(0))) { @@ -1156,11 +1123,11 @@ void CABACReader::pred_mode( CodingUnit& cu ) else { cu.predMode = m_BinDecoder.decodeBin(Ctx::PredMode(DeriveCtx::CtxPredModeFlag(cu))) ? MODE_INTRA : MODE_INTER; -#if JVET_Q0629_REMOVAL_PLT_4X4 - if (CU::isIntra(cu) && cu.cs->slice->getSPS()->getPLTMode() && cu.lwidth() <= 64 && ( ( (!isLuma(cu.chType)) && (cu.chromaSize().width * cu.chromaSize().height > 16) ) || ((isLuma(cu.chType)) && ((cu.lumaSize().width * cu.lumaSize().height) > 16 ) ) ) ) +#if JVET_R0334_PLT_CLEANUP + if (CU::isIntra(cu) && cu.cs->slice->getSPS()->getPLTMode() && cu.lwidth() <= 64 && ( ( (!isLuma(cu.chType)) && (cu.chromaSize().width * cu.chromaSize().height > 16) ) || ((isLuma(cu.chType)) && ((cu.lumaSize().width * cu.lumaSize().height) > 16 ) ) ) && (!cu.isLocalSepTree() || isLuma(cu.chType) ) ) #else - if (CU::isIntra(cu) && cu.cs->slice->getSPS()->getPLTMode() && cu.lwidth() <= 64 && cu.lheight() <= 64) -#endif + if (CU::isIntra(cu) && cu.cs->slice->getSPS()->getPLTMode() && cu.lwidth() <= 64 && ( ( (!isLuma(cu.chType)) && (cu.chromaSize().width * cu.chromaSize().height > 16) ) || ((isLuma(cu.chType)) && ((cu.lumaSize().width * cu.lumaSize().height) > 16 ) ) ) ) +#endif { if (m_BinDecoder.decodeBin(Ctx::PLTFlag(0))) { @@ -1191,19 +1158,11 @@ void CABACReader::bdpcm_mode( CodingUnit& cu, const ComponentID compID ) RExt__DECODER_DEBUG_BIT_STATISTICS_CREATE_SET_SIZE2( STATS__CABAC_BITS__BDPCM_MODE, cu.block(compID).lumaSize(), compID ); int bdpcmMode; -#if JVET_Q0110_Q0785_CHROMA_BDPCM_420 unsigned ctxId = isLuma( compID ) ? 0 : 2; bdpcmMode = m_BinDecoder.decodeBin( Ctx::BDPCMMode(ctxId) ); -#else - bdpcmMode = m_BinDecoder.decodeBin(Ctx::BDPCMMode(0)); -#endif if (bdpcmMode) { -#if JVET_Q0110_Q0785_CHROMA_BDPCM_420 bdpcmMode += m_BinDecoder.decodeBin( Ctx::BDPCMMode(ctxId+1) ); -#else - bdpcmMode += m_BinDecoder.decodeBin(Ctx::BDPCMMode(1)); -#endif } if (isLuma(compID)) { @@ -1227,19 +1186,15 @@ void CABACReader::cu_pred_data( CodingUnit &cu ) { if( CU::isIntra( cu ) ) { -#if JVET_Q0110_Q0785_CHROMA_BDPCM_420 if( cu.Y().valid() ) { bdpcm_mode(cu, COMPONENT_Y ); } -#endif intra_luma_pred_modes( cu ); -#if JVET_Q0110_Q0785_CHROMA_BDPCM_420 if( ( !cu.Y().valid() || (!cu.isSepTree() && cu.Y().valid() ) ) && isChromaEnabled(cu.chromaFormat) ) { bdpcm_mode(cu, ComponentID(CHANNEL_TYPE_CHROMA)); - } -#endif + } intra_chroma_pred_modes( cu ); return; } @@ -1480,13 +1435,11 @@ void CABACReader::intra_chroma_pred_modes( CodingUnit& cu ) return; } -#if JVET_Q0110_Q0785_CHROMA_BDPCM_420 if( cu.bdpcmModeChroma ) { cu.firstPU->intraDir[1] = cu.bdpcmModeChroma == 2 ? VER_IDX : HOR_IDX; return; } -#endif PredictionUnit *pu = cu.firstPU; { @@ -1524,15 +1477,6 @@ void CABACReader::intra_chroma_pred_mode(PredictionUnit& pu) } // LM chroma mode -#if !JVET_Q0110_Q0785_CHROMA_BDPCM_420 - if (pu.cu->bdpcmModeChroma) - { - unsigned chromaCandModes[NUM_CHROMA_MODE]; - PU::getIntraChromaCandModes(pu, chromaCandModes); - pu.intraDir[1] = chromaCandModes[0]; - return; - } -#endif if (pu.cs->sps->getUseLMChroma() && pu.cu->checkCCLMAllowed()) { @@ -1595,9 +1539,7 @@ void CABACReader::cu_residual( CodingUnit& cu, Partitioner &partitioner, CUCtx& cuCtx.violatesLfnstConstrained[CHANNEL_TYPE_CHROMA] = false; cuCtx.lfnstLastScanPos = false; cuCtx.violatesMtsCoeffConstraint = false; -#if JVET_Q0516_MTS_SIGNALLING_DC_ONLY_COND cuCtx.mtsLastScanPos = false; -#endif ChromaCbfs chromaCbfs; if( cu.ispMode && isLuma( partitioner.chType ) ) @@ -1718,30 +1660,21 @@ void CABACReader::cu_palette_info(CodingUnit& cu, ComponentID compBegin, uint32_ TransformUnit& tu = *cu.firstTU; int curPLTidx = 0; -#if JVET_Q0504_PLT_NON444 if( cu.isLocalSepTree() ) cu.cs->prevPLT.curPLTSize[compBegin] = cu.cs->prevPLT.curPLTSize[COMPONENT_Y]; -#endif cu.lastPLTSize[compBegin] = cu.cs->prevPLT.curPLTSize[compBegin]; -#if JVET_Q0291_REDUCE_DUALTREE_PLT_SIZE int maxPltSize = cu.isSepTree() ? MAXPLTSIZE_DUALTREE : MAXPLTSIZE; -#endif if (cu.lastPLTSize[compBegin]) { -#if JVET_Q0291_REDUCE_DUALTREE_PLT_SIZE xDecodePLTPredIndicator(cu, maxPltSize, compBegin); -#else - xDecodePLTPredIndicator(cu, MAXPLTSIZE, compBegin); -#endif } for (int idx = 0; idx < cu.lastPLTSize[compBegin]; idx++) { if (cu.reuseflag[compBegin][idx]) { -#if JVET_Q0504_PLT_NON444 if( cu.isLocalSepTree() ) { for( int comp = COMPONENT_Y; comp < MAX_NUM_COMPONENT; comp++ ) @@ -1751,33 +1684,24 @@ void CABACReader::cu_palette_info(CodingUnit& cu, ComponentID compBegin, uint32_ } else { -#endif for (int comp = compBegin; comp < (compBegin + numComp); comp++) { cu.curPLT[comp][curPLTidx] = cu.cs->prevPLT.curPLT[comp][idx]; } -#if JVET_Q0504_PLT_NON444 } -#endif curPLTidx++; } } uint32_t recievedPLTnum = 0; -#if JVET_Q0291_REDUCE_DUALTREE_PLT_SIZE if (curPLTidx < maxPltSize) -#else - if (curPLTidx < MAXPLTSIZE) -#endif { recievedPLTnum = exp_golomb_eqprob(0); } cu.curPLTSize[compBegin] = curPLTidx + recievedPLTnum; -#if JVET_Q0504_PLT_NON444 if( cu.isLocalSepTree() ) cu.curPLTSize[COMPONENT_Y] = cu.curPLTSize[compBegin]; -#endif for (int comp = compBegin; comp < (compBegin + numComp); comp++) { for (int idx = curPLTidx; idx < cu.curPLTSize[compBegin]; idx++) @@ -1785,7 +1709,6 @@ void CABACReader::cu_palette_info(CodingUnit& cu, ComponentID compBegin, uint32_ ComponentID compID = (ComponentID)comp; const int channelBitDepth = sps.getBitDepth(toChannelType(compID)); cu.curPLT[compID][idx] = m_BinDecoder.decodeBinsEP(channelBitDepth); -#if JVET_Q0504_PLT_NON444 if( cu.isLocalSepTree() ) { if( isLuma( cu.chType ) ) @@ -1798,7 +1721,6 @@ void CABACReader::cu_palette_info(CodingUnit& cu, ComponentID compBegin, uint32_ cu.curPLT[COMPONENT_Y][idx] = 1 << (cu.cs->sps->getBitDepth(CHANNEL_TYPE_LUMA) - 1); } } -#endif } } cu.useEscape[compBegin] = true; @@ -1844,9 +1766,7 @@ void CABACReader::cu_palette_info(CodingUnit& cu, ComponentID compBegin, uint32_ { cuPaletteSubblockInfo(cu, compBegin, numComp, subSetId, prevRunPos, prevRunType); } -#if JVET_Q0291_REDUCE_DUALTREE_PLT_SIZE CHECK(cu.curPLTSize[compBegin] > maxPltSize, " Current palette size is larger than maximum palette size"); -#endif } void CABACReader::cuPaletteSubblockInfo(CodingUnit& cu, ComponentID compBegin, uint32_t numComp, int subSetId, uint32_t& prevRunPos, unsigned& prevRunType) { @@ -1979,11 +1899,7 @@ void CABACReader::cuPaletteSubblockInfo(CodingUnit& cu, ComponentID compBegin, u PLTescapeBuf escapeValue = tu.getescapeValue((ComponentID)comp); if (compID == COMPONENT_Y || compBegin != COMPONENT_Y) { -#if JVET_Q0491_PLT_ESCAPE escapeValue.at(posx, posy) = exp_golomb_eqprob(5); -#else - escapeValue.at(posx, posy) = exp_golomb_eqprob(3); -#endif assert(escapeValue.at(posx, posy) < (1 << (cu.cs->sps->getBitDepth(toChannelType((ComponentID)comp)) + 1))); DTRACE(g_trace_ctx, D_SYNTAX, "plt_escape_val() value=%d etype=%d sp=%d\n", escapeValue.at(posx, posy), comp, curPos); } @@ -1991,11 +1907,7 @@ void CABACReader::cuPaletteSubblockInfo(CodingUnit& cu, ComponentID compBegin, u { uint32_t posxC = posx >> scaleX; uint32_t posyC = posy >> scaleY; -#if JVET_Q0491_PLT_ESCAPE escapeValue.at(posxC, posyC) = exp_golomb_eqprob(5); -#else - escapeValue.at(posxC, posyC) = exp_golomb_eqprob(3); -#endif assert(escapeValue.at(posxC, posyC) < (1 << (cu.cs->sps->getBitDepth(toChannelType(compID)) + 1))); DTRACE(g_trace_ctx, D_SYNTAX, "plt_escape_val() value=%d etype=%d sp=%d\n", escapeValue.at(posx, posy), comp, curPos); } @@ -2031,10 +1943,8 @@ void CABACReader::xDecodePLTPredIndicator(CodingUnit& cu, uint32_t maxPLTSize, C idx += symbol - 1; } cu.reuseflag[compBegin][idx] = 1; -#if JVET_Q0504_PLT_NON444 if( cu.isLocalSepTree() ) cu.reuseflag[COMPONENT_Y][idx] = 1; -#endif numPltPredicted++; idx++; } @@ -2121,11 +2031,7 @@ void CABACReader::prediction_unit( PredictionUnit& pu, MergeCtx& mrgCtx ) pu.cu->affine = false; pu.refIdx[REF_PIC_LIST_0] = MAX_NUM_REF; mvd_coding(pu.mvd[REF_PIC_LIST_0]); -#if JVET_Q0798_SPS_NUMBER_MERGE_CANDIDATE if (pu.cs->sps->getMaxNumIBCMergeCand() == 1) -#else - if ( pu.cu->slice->getPicHeader()->getMaxNumIBCMergeCand() == 1 ) -#endif { pu.mvpIdx[REF_PIC_LIST_0] = 0; } @@ -2299,29 +2205,13 @@ void CABACReader::merge_data( PredictionUnit& pu ) RExt__DECODER_DEBUG_BIT_STATISTICS_CREATE_SET( STATS__CABAC_BITS__MERGE_FLAG ); -#if JVET_Q0806 const bool ciipAvailable = pu.cs->sps->getUseCiip() && !pu.cu->skip && pu.cu->lwidth() < MAX_CU_SIZE && pu.cu->lheight() < MAX_CU_SIZE && pu.cu->lwidth() * pu.cu->lheight() >= 64; - const bool geoAvailable = pu.cu->cs->slice->getSPS()->getUseGeo() && pu.cu->cs->slice->isInterB() && -#if JVET_Q0798_SPS_NUMBER_MERGE_CANDIDATE + const bool geoAvailable = pu.cu->cs->slice->getSPS()->getUseGeo() && pu.cu->cs->slice->isInterB() && pu.cs->sps->getMaxNumGeoCand() > 1 -#else - pu.cu->cs->picHeader->getMaxNumGeoCand() > 1 -#endif && pu.cu->lwidth() >= GEO_MIN_CU_SIZE && pu.cu->lheight() >= GEO_MIN_CU_SIZE && pu.cu->lwidth() <= GEO_MAX_CU_SIZE && pu.cu->lheight() <= GEO_MAX_CU_SIZE && pu.cu->lwidth() < 8 * pu.cu->lheight() && pu.cu->lheight() < 8 * pu.cu->lwidth(); if (geoAvailable || ciipAvailable) -#else - const bool triangleAvailable = pu.cu->cs->slice->getSPS()->getUseTriangle() && pu.cu->cs->slice->isInterB() && -#if JVET_Q0798_SPS_NUMBER_MERGE_CANDIDATE - pu.cs->sps->getMaxNumGeoCand() > 1; -#else - pu.cu->cs->picHeader->getMaxNumTriangleCand() > 1; -#endif - const bool ciipAvailable = pu.cs->sps->getUseCiip() && !pu.cu->skip && pu.cu->lwidth() < MAX_CU_SIZE && pu.cu->lheight() < MAX_CU_SIZE; - if (pu.cu->lwidth() * pu.cu->lheight() >= 64 - && (triangleAvailable || ciipAvailable)) -#endif { cu.firstPU->regularMergeFlag = m_BinDecoder.decodeBin(Ctx::RegularMergeFlag(cu.skip ? 0 : 1)); } @@ -2348,29 +2238,6 @@ void CABACReader::merge_data( PredictionUnit& pu ) { pu.mmvdMergeFlag = false; pu.cu->mmvdSkip = false; -#if !JVET_Q0806 - if (triangleAvailable && ciipAvailable) - { - Ciip_flag(pu); - } - else if (ciipAvailable) - { - pu.ciipFlag = true; - } - else - { - pu.ciipFlag = false; - } - if (pu.ciipFlag) - { - pu.intraDir[0] = PLANAR_IDX; - pu.intraDir[1] = DM_CHROMA_IDX; - } - else - { - pu.cu->triangle = true; - } -#else if (geoAvailable && ciipAvailable) { Ciip_flag(pu); @@ -2392,7 +2259,6 @@ void CABACReader::merge_data( PredictionUnit& pu ) { pu.cu->geoFlag = true; } -#endif } } if (pu.mmvdMergeFlag || pu.cu->mmvdSkip) @@ -2432,67 +2298,16 @@ void CABACReader::merge_idx( PredictionUnit& pu ) } else { -#if JVET_Q0798_SPS_NUMBER_MERGE_CANDIDATE int numCandminus1 = int(pu.cs->sps->getMaxNumMergeCand()) - 1; -#else - int numCandminus1 = int( pu.cs->picHeader->getMaxNumMergeCand() ) - 1; -#endif pu.mergeIdx = 0; -#if !JVET_Q0806 - if( pu.cu->triangle ) - { - RExt__DECODER_DEBUG_BIT_STATISTICS_CREATE_SET( STATS__CABAC_BITS__TRIANGLE_INDEX ); - bool splitDir; - uint8_t candIdx0; - uint8_t candIdx1; - splitDir = m_BinDecoder.decodeBinEP(); - auto decodeOneIdx = [this](int numCandminus1) -> uint8_t - { - uint8_t decIdx = 0; - if( numCandminus1 > 0 ) - { - if( this->m_BinDecoder.decodeBin( Ctx::MergeIdx() ) ) - { - decIdx++; - for( ; decIdx < numCandminus1; decIdx++ ) - { - if( !this->m_BinDecoder.decodeBinEP() ) - break; - } - } - } - return decIdx; - }; -#if JVET_Q0798_SPS_NUMBER_MERGE_CANDIDATE - const int maxNumTriangleCand = pu.cs->sps->getMaxNumGeoCand(); -#else - const int maxNumTriangleCand = pu.cs->picHeader->getMaxNumTriangleCand(); -#endif - CHECK(maxNumTriangleCand < 2, "Incorrect max number of triangle candidates"); - candIdx0 = decodeOneIdx(maxNumTriangleCand - 1); - candIdx1 = decodeOneIdx(maxNumTriangleCand - 2); - candIdx1 += candIdx1 >= candIdx0 ? 1 : 0; - DTRACE( g_trace_ctx, D_SYNTAX, "merge_idx() triangle_split_dir=%d\n", splitDir ); - DTRACE( g_trace_ctx, D_SYNTAX, "merge_idx() triangle_idx0=%d\n", candIdx0 ); - DTRACE( g_trace_ctx, D_SYNTAX, "merge_idx() triangle_idx1=%d\n", candIdx1 ); - pu.triangleSplitDir = splitDir; - pu.triangleMergeIdx0 = candIdx0; - pu.triangleMergeIdx1 = candIdx1; - return; - } -#else if( pu.cu->geoFlag ) { RExt__DECODER_DEBUG_BIT_STATISTICS_CREATE_SET( STATS__CABAC_BITS__GEO_INDEX ); uint32_t splitDir = 0; xReadTruncBinCode(splitDir, GEO_NUM_PARTITION_MODE); pu.geoSplitDir = splitDir; -#if JVET_Q0798_SPS_NUMBER_MERGE_CANDIDATE const int maxNumGeoCand = pu.cs->sps->getMaxNumGeoCand(); -#else - const int maxNumGeoCand = pu.cs->picHeader->getMaxNumGeoCand(); -#endif CHECK(maxNumGeoCand < 2, "Incorrect max number of geo candidates"); CHECK(pu.cu->lheight() > 64 || pu.cu->lwidth() > 64, "Incorrect block size of geo flag"); int numCandminus2 = maxNumGeoCand - 2; @@ -2518,15 +2333,10 @@ void CABACReader::merge_idx( PredictionUnit& pu ) DTRACE( g_trace_ctx, D_SYNTAX, "merge_idx() geo_idx1=%d\n", mergeCand1 ); return; } -#endif if (pu.cu->predMode == MODE_IBC) { -#if JVET_Q0798_SPS_NUMBER_MERGE_CANDIDATE numCandminus1 = int(pu.cs->sps->getMaxNumIBCMergeCand()) - 1; -#else - numCandminus1 = int(pu.cs->picHeader->getMaxNumIBCMergeCand()) - 1; -#endif } if( numCandminus1 > 0 ) { @@ -2551,11 +2361,7 @@ void CABACReader::mmvd_merge_idx(PredictionUnit& pu) RExt__DECODER_DEBUG_BIT_STATISTICS_CREATE_SET(STATS__CABAC_BITS__MERGE_INDEX); int var0 = 0; -#if JVET_Q0798_SPS_NUMBER_MERGE_CANDIDATE if (pu.cs->sps->getMaxNumMergeCand() > 1) -#else - if (pu.cs->picHeader->getMaxNumMergeCand() > 1) -#endif { static_assert(MMVD_BASE_MV_NUM == 2, ""); var0 = m_BinDecoder.decodeBin(Ctx::MmvdMergeIdx()); @@ -2998,12 +2804,6 @@ void CABACReader::transform_unit( TransformUnit& tu, CUCtx& cuCtx, Partitioner& { for( ComponentID compID = COMPONENT_Cb; compID <= COMPONENT_Cr; compID = ComponentID( compID + 1 ) ) { -#if !REMOVE_PPS_REXT - if( TU::hasCrossCompPredInfo( tu, compID ) ) - { - cross_comp_pred( tu, compID ); - } -#endif if( tu.cbf[ compID ] ) { residual_coding( tu, compID, cuCtx ); @@ -3092,18 +2892,18 @@ void CABACReader::residual_coding( TransformUnit& tu, ComponentID compID, CUCtx& ts_flag ( tu, compID ); explicit_rdpcm_mode( tu, compID ); -#if JVET_Q0089_SLICE_LOSSLESS_CODING_CHROMA_BDPCM if( tu.mtsIdx[compID] == MTS_SKIP && !tu.cs->slice->getTSResidualCodingDisabledFlag() ) -#else - if (tu.mtsIdx[compID] == MTS_SKIP) -#endif { residual_codingTS( tu, compID ); return; } // determine sign hiding +#if JVET_R0271_SLICE_LEVEL_DQ_SDH_RRC + bool signHiding = ( cu.cs->slice->getSignDataHidingEnabledFlag() && tu.rdpcm[compID] == RDPCM_OFF ); +#else bool signHiding = ( cu.cs->picHeader->getSignDataHidingEnabledFlag() && tu.rdpcm[compID] == RDPCM_OFF ); +#endif if( signHiding && CU::isIntra(cu) && CU::isRDPCMEnabled(cu) && tu.mtsIdx[compID] == MTS_SKIP ) { const ChannelType chType = toChannelType( compID ); @@ -3130,21 +2930,17 @@ void CABACReader::residual_coding( TransformUnit& tu, ComponentID compID, CUCtx& const int lfnstLastScanPosTh = isLuma( compID ) ? LFNST_LAST_SIG_LUMA : LFNST_LAST_SIG_CHROMA; cuCtx.lfnstLastScanPos |= cctx.scanPosLast() >= lfnstLastScanPosTh; } -#if !JVET_Q0055_MTS_SIGNALLING - if( isLuma(compID) && ( cctx.posX(cctx.scanPosLast()) >= 16 || cctx.posY(cctx.scanPosLast()) >= 16 ) ) - { - cuCtx.violatesMtsCoeffConstraint = true; - } -#endif -#if JVET_Q0516_MTS_SIGNALLING_DC_ONLY_COND if (isLuma(compID) && tu.mtsIdx[compID] != MTS_SKIP) { cuCtx.mtsLastScanPos |= cctx.scanPosLast() >= 1; } -#endif // parse subblocks +#if JVET_R0271_SLICE_LEVEL_DQ_SDH_RRC + const int stateTransTab = ( tu.cs->slice->getDepQuantEnabledFlag() ? 32040 : 0 ); +#else const int stateTransTab = ( tu.cs->picHeader->getDepQuantEnabledFlag() ? 32040 : 0 ); +#endif int state = 0; int ctxBinSampleRatio = (compID == COMPONENT_Y) ? MAX_TU_LEVEL_CTX_CODED_BIN_CONSTRAINT_LUMA : MAX_TU_LEVEL_CTX_CODED_BIN_CONSTRAINT_CHROMA; @@ -3163,12 +2959,10 @@ void CABACReader::residual_coding( TransformUnit& tu, ComponentID compID, CUCtx& } residual_coding_subblock( cctx, coeff, stateTransTab, state ); -#if JVET_Q0055_MTS_SIGNALLING if ( isLuma(compID) && cctx.isSigGroup() && ( cctx.cgPosY() > 3 || cctx.cgPosX() > 3 ) ) { cuCtx.violatesMtsCoeffConstraint = true; } -#endif } } @@ -3183,9 +2977,9 @@ void CABACReader::ts_flag( TransformUnit& tu, ComponentID compID ) RExt__DECODER_DEBUG_BIT_STATISTICS_CREATE_SET_SIZE2( STATS__CABAC_BITS__MTS_FLAGS, tu.blocks[compID], compID ); tsFlag = m_BinDecoder.decodeBin( Ctx::TransformSkipFlag( ctxIdx ) ); } - + tu.mtsIdx[compID] = tsFlag ? MTS_SKIP : MTS_DCT2_DCT2; - + DTRACE(g_trace_ctx, D_SYNTAX, "ts_flag() etype=%d pos=(%d,%d) mtsIdx=%d\n", COMPONENT_Y, tu.cu->lx(), tu.cu->ly(), tsFlag); } @@ -3195,16 +2989,12 @@ void CABACReader::mts_idx( CodingUnit& cu, CUCtx& cuCtx ) int mtsIdx = tu.mtsIdx[COMPONENT_Y]; // Transform skip flag has already been decoded if( CU::isMTSAllowed( cu, COMPONENT_Y ) && !cuCtx.violatesMtsCoeffConstraint && -#if JVET_Q0516_MTS_SIGNALLING_DC_ONLY_COND cuCtx.mtsLastScanPos && cu.lfnstIdx == 0 && mtsIdx != MTS_SKIP) -#else - cu.lfnstIdx == 0 && mtsIdx != MTS_SKIP && TU::getCbf(tu, COMPONENT_Y) ) -#endif { RExt__DECODER_DEBUG_BIT_STATISTICS_CREATE_SET_SIZE2( STATS__CABAC_BITS__MTS_FLAGS, tu.blocks[COMPONENT_Y], COMPONENT_Y ); int ctxIdx = 0; int symbol = m_BinDecoder.decodeBin( Ctx::MTSIdx(ctxIdx)); - + if( symbol ) { ctxIdx = 1; @@ -3213,7 +3003,7 @@ void CABACReader::mts_idx( CodingUnit& cu, CUCtx& cuCtx ) { symbol = m_BinDecoder.decodeBin( Ctx::MTSIdx(ctxIdx)); mtsIdx += symbol; - + if( !symbol ) { break; @@ -3221,12 +3011,12 @@ void CABACReader::mts_idx( CodingUnit& cu, CUCtx& cuCtx ) } } } - + tu.mtsIdx[COMPONENT_Y] = mtsIdx; - + DTRACE(g_trace_ctx, D_SYNTAX, "mts_idx() etype=%d pos=(%d,%d) mtsIdx=%d\n", COMPONENT_Y, tu.cu->lx(), tu.cu->ly(), mtsIdx); } - + void CABACReader::isp_mode( CodingUnit& cu ) { if( !CU::isIntra( cu ) || !isLuma( cu.chType ) || cu.firstPU->multiRefIdx || !cu.cs->sps->getUseISP() || cu.bdpcmMode || !CU::canUseISP( cu, getFirstComponentOfChannel( cu.chType ) ) || cu.colorTransform ) @@ -3291,7 +3081,6 @@ void CABACReader::residual_lfnst_mode( CodingUnit& cu, CUCtx& cuCtx ) const bool lumaFlag = cu.isSepTree() ? ( isLuma( cu.chType ) ? true : false ) : true; const bool chromaFlag = cu.isSepTree() ? ( isChroma( cu.chType ) ? true : false ) : true; bool nonZeroCoeffNonTsCorner8x8 = ( lumaFlag && cuCtx.violatesLfnstConstrained[CHANNEL_TYPE_LUMA] ) || (chromaFlag && cuCtx.violatesLfnstConstrained[CHANNEL_TYPE_CHROMA] ); -#if JVET_Q0784_LFNST_COMBINATION bool isTrSkip = false; for (auto &currTU : CU::traverseTUs(cu)) { @@ -3305,9 +3094,6 @@ void CABACReader::residual_lfnst_mode( CodingUnit& cu, CUCtx& cuCtx ) } } } -#else - const bool isTrSkip = TU::getCbf(*cu.firstTU, COMPONENT_Y) && cu.firstTU->mtsIdx[COMPONENT_Y] == MTS_SKIP; -#endif if ((!cuCtx.lfnstLastScanPos && !cu.ispMode) || nonZeroCoeffNonTsCorner8x8 || isTrSkip) { cu.lfnstIdx = 0; @@ -3756,40 +3542,6 @@ void CABACReader::residual_coding_subblockTS( CoeffCodingContext& cctx, TCoeff* } } -#if !REMOVE_PPS_REXT -//================================================================================ -// clause 7.3.8.12 -//-------------------------------------------------------------------------------- -// void cross_comp_pred( tu, compID ) -//================================================================================ - -void CABACReader::cross_comp_pred( TransformUnit& tu, ComponentID compID ) -{ - RExt__DECODER_DEBUG_BIT_STATISTICS_CREATE_SET_SIZE2(STATS__CABAC_BITS__CROSS_COMPONENT_PREDICTION, tu.blocks[compID], compID); - - signed char alpha = 0; - unsigned ctxBase = ( compID == COMPONENT_Cr ? 5 : 0 ); - unsigned symbol = m_BinDecoder.decodeBin( Ctx::CrossCompPred(ctxBase) ); - if( symbol ) - { - // Cross-component prediction alpha is non-zero. - symbol = m_BinDecoder.decodeBin( Ctx::CrossCompPred(ctxBase+1) ); - if( symbol ) - { - // alpha is 2 (symbol=1), 4(symbol=2) or 8(symbol=3). - // Read up to two more bits - symbol += unary_max_symbol( Ctx::CrossCompPred(ctxBase+2), Ctx::CrossCompPred(ctxBase+3), 2 ); - } - alpha = ( 1 << symbol ); - if( m_BinDecoder.decodeBin( Ctx::CrossCompPred(ctxBase+4) ) ) - { - alpha = -alpha; - } - } - DTRACE( g_trace_ctx, D_SYNTAX, "cross_comp_pred() etype=%d pos=(%d,%d) alpha=%d\n", compID, tu.blocks[compID].x, tu.blocks[compID].y, tu.compAlpha[compID] ); - tu.compAlpha[compID] = alpha; -} -#endif //================================================================================ diff --git a/source/Lib/DecoderLib/CABACReader.h b/source/Lib/DecoderLib/CABACReader.h index 8d0b2bf0b32d09612aaf2511931c2c260b4d0b9b..a85e9a6c1a852a8a7912beb17de1b4f7beabdd4f 100644 --- a/source/Lib/DecoderLib/CABACReader.h +++ b/source/Lib/DecoderLib/CABACReader.h @@ -70,10 +70,8 @@ public: void readAlfCtuFilterIndex(CodingStructure& cs, unsigned ctuRsAddr); -#if JVET_Q0795_CCALF void ccAlfFilterControlIdc(CodingStructure &cs, const ComponentID compID, const int curIdx, uint8_t *filterControlIdc, Position lumaPos, int filterCount); -#endif // coding (quad)tree (clause 7.3.8.4) void coding_tree ( CodingStructure& cs, Partitioner& pm, CUCtx& cuCtx, Partitioner* pPartitionerChroma = nullptr, CUCtx* pCuCtxChroma = nullptr); @@ -144,10 +142,6 @@ public: void residual_coding_subblockTS( CoeffCodingContext& cctx, TCoeff* coeff ); void joint_cb_cr ( TransformUnit& tu, const int cbfMask ); -#if !REMOVE_PPS_REXT - // cross component prediction (clause 7.3.8.12) - void cross_comp_pred ( TransformUnit& tu, ComponentID compID ); -#endif private: unsigned unary_max_symbol ( unsigned ctxId0, unsigned ctxIdN, unsigned maxSymbol ); diff --git a/source/Lib/DecoderLib/DecCu.cpp b/source/Lib/DecoderLib/DecCu.cpp index 92def10ee1afc9f061951d6d3fc9f2cdb2bbfa7d..7101c99c4de57becddacdd3bc1ea1564f3c5cdcc 100644 --- a/source/Lib/DecoderLib/DecCu.cpp +++ b/source/Lib/DecoderLib/DecCu.cpp @@ -122,7 +122,7 @@ void DecCu::decompressCtu( CodingStructure& cs, const UnitArea& ctuArea ) const int vSize = cs.slice->getSPS()->getMaxCUHeight() > 64 ? 64 : cs.slice->getSPS()->getMaxCUHeight(); if((currCU.Y().x % vSize) == 0 && (currCU.Y().y % vSize) == 0) { - for(int x = currCU.Y().x; x < currCU.Y().y + currCU.Y().width; x += vSize) + for(int x = currCU.Y().x; x < currCU.Y().x + currCU.Y().width; x += vSize) { for(int y = currCU.Y().y; y < currCU.Y().y + currCU.Y().height; y += vSize) { @@ -134,7 +134,7 @@ void DecCu::decompressCtu( CodingStructure& cs, const UnitArea& ctuArea ) if (currCU.predMode != MODE_INTRA && currCU.predMode != MODE_PLT && currCU.Y().valid()) { xDeriveCUMV(currCU); -#if JVET_Q0806 && K0149_BLOCK_STATISTICS +#if K0149_BLOCK_STATISTICS if(currCU.geoFlag) { storeGeoMergeCtx(m_geoMrgCtx); @@ -241,11 +241,7 @@ void DecCu::xIntraRecBlk( TransformUnit& tu, const ComponentID compID ) } } const Slice &slice = *cs.slice; -#if JVET_Q0346_LMCS_ENABLE_IN_SH bool flag = slice.getLmcsEnabledFlag() && (slice.isIntra() || (!slice.isIntra() && m_pcReshape->getCTUFlag())); -#else - bool flag = slice.getPicHeader()->getLmcsEnabledFlag() && (slice.isIntra() || (!slice.isIntra() && m_pcReshape->getCTUFlag())); -#endif if (flag && slice.getPicHeader()->getLmcsChromaResidualScaleFlag() && (compID != COMPONENT_Y) && (tu.cbf[COMPONENT_Cb] || tu.cbf[COMPONENT_Cr])) { const Area area = tu.Y().valid() ? tu.Y() : Area(recalcPosition(tu.chromaFormat, tu.chType, CHANNEL_TYPE_LUMA, tu.blocks[tu.chType].pos()), recalcSize(tu.chromaFormat, tu.chType, CHANNEL_TYPE_LUMA, tu.blocks[tu.chType].size())); @@ -291,12 +287,6 @@ void DecCu::xIntraRecBlk( TransformUnit& tu, const ComponentID compID ) { piResi.scaleSignal(tu.getChromaAdj(), 0, tu.cu->cs->slice->clpRng(compID)); } -#if !REMOVE_PPS_REXT - if( isChroma(compID) && tu.compAlpha[compID] != 0 ) - { - CrossComponentPrediction::crossComponentPrediction( tu, compID, cs.getResiBuf( tu.Y() ), piResi, piResi, true ); - } -#endif if( !tu.cu->ispMode || !isLuma( compID ) ) { @@ -311,11 +301,7 @@ void DecCu::xIntraRecBlk( TransformUnit& tu, const ComponentID compID ) CompArea tmpArea(COMPONENT_Y, area.chromaFormat, Position(0, 0), area.size()); PelBuf tmpPred; #endif -#if JVET_Q0346_LMCS_ENABLE_IN_SH if (slice.getLmcsEnabledFlag() && (m_pcReshape->getCTUFlag() || slice.isIntra()) && compID == COMPONENT_Y) -#else - if (slice.getPicHeader()->getLmcsEnabledFlag() && (m_pcReshape->getCTUFlag() || slice.isIntra()) && compID == COMPONENT_Y) -#endif { #if REUSE_CU_RESULTS { @@ -332,11 +318,7 @@ void DecCu::xIntraRecBlk( TransformUnit& tu, const ComponentID compID ) #if !KEEP_PRED_AND_RESI_SIGNALS pReco.copyFrom( piPred ); #endif -#if JVET_Q0346_LMCS_ENABLE_IN_SH if (slice.getLmcsEnabledFlag() && (m_pcReshape->getCTUFlag() || slice.isIntra()) && compID == COMPONENT_Y) -#else - if (slice.getPicHeader()->getLmcsEnabledFlag() && (m_pcReshape->getCTUFlag() || slice.isIntra()) && compID == COMPONENT_Y) -#endif { #if REUSE_CU_RESULTS { @@ -364,11 +346,7 @@ void DecCu::xIntraRecACTBlk(TransformUnit& tu) CHECK(tu.cu->ispMode, "adaptive color transform cannot be applied to ISP"); CHECK(pu.intraDir[CHANNEL_TYPE_CHROMA] != DM_CHROMA_IDX, "chroma should use DM mode for adaptive color transform"); -#if JVET_Q0346_LMCS_ENABLE_IN_SH bool flag = slice.getLmcsEnabledFlag() && (slice.isIntra() || (!slice.isIntra() && m_pcReshape->getCTUFlag())); -#else - bool flag = slice.getPicHeader()->getLmcsEnabledFlag() && (slice.isIntra() || (!slice.isIntra() && m_pcReshape->getCTUFlag())); -#endif if (flag && slice.getPicHeader()->getLmcsChromaResidualScaleFlag() && (tu.cbf[COMPONENT_Cb] || tu.cbf[COMPONENT_Cr])) { const Area area = tu.Y().valid() ? tu.Y() : Area(recalcPosition(tu.chromaFormat, tu.chType, CHANNEL_TYPE_LUMA, tu.blocks[tu.chType].pos()), recalcSize(tu.chromaFormat, tu.chType, CHANNEL_TYPE_LUMA, tu.blocks[tu.chType].size())); @@ -398,14 +376,6 @@ void DecCu::xIntraRecACTBlk(TransformUnit& tu) PelBuf piResi = cs.getResiBuf(area); QpParam cQP(tu, compID); -#if !JVET_Q0820_ACT - for (int qpIdx = 0; qpIdx < 2; qpIdx++) - { - cQP.Qps[qpIdx] = cQP.Qps[qpIdx] + (compID == COMPONENT_Cr ? DELTA_QP_FOR_Co : DELTA_QP_FOR_Y_Cg); - cQP.pers[qpIdx] = cQP.Qps[qpIdx] / 6; - cQP.rems[qpIdx] = cQP.Qps[qpIdx] % 6; - } -#endif if (tu.jointCbCr && isChroma(compID)) { @@ -419,14 +389,6 @@ void DecCu::xIntraRecACTBlk(TransformUnit& tu) else { QpParam qpCr(tu, COMPONENT_Cr); -#if !JVET_Q0820_ACT - for (int qpIdx = 0; qpIdx < 2; qpIdx++) - { - qpCr.Qps[qpIdx] = qpCr.Qps[qpIdx] + DELTA_QP_FOR_Co; - qpCr.pers[qpIdx] = qpCr.Qps[qpIdx] / 6; - qpCr.rems[qpIdx] = qpCr.Qps[qpIdx] % 6; - } -#endif m_pcTrQuant->invTransformNxN(tu, COMPONENT_Cr, resiCr, qpCr); } @@ -454,11 +416,7 @@ void DecCu::xIntraRecACTBlk(TransformUnit& tu) cs.setDecomp(area); } -#if JVET_Q0820_ACT cs.getResiBuf(tu).colorSpaceConvert(cs.getResiBuf(tu), false, tu.cu->cs->slice->clpRng(COMPONENT_Y)); -#else - cs.getResiBuf(tu).colorSpaceConvert(cs.getResiBuf(tu), false); -#endif for (int i = 0; i < getNumberValidComponents(tu.chromaFormat); i++) { @@ -470,11 +428,7 @@ void DecCu::xIntraRecACTBlk(TransformUnit& tu) PelBuf piReco = cs.getRecoBuf(area); PelBuf tmpPred; -#if JVET_Q0346_LMCS_ENABLE_IN_SH if (slice.getLmcsEnabledFlag() && (m_pcReshape->getCTUFlag() || slice.isIntra()) && compID == COMPONENT_Y) -#else - if (slice.getPicHeader()->getLmcsEnabledFlag() && (m_pcReshape->getCTUFlag() || slice.isIntra()) && compID == COMPONENT_Y) -#endif { CompArea tmpArea(COMPONENT_Y, area.chromaFormat, Position(0, 0), area.size()); tmpPred = m_tmpStorageLCU->getBuf(tmpArea); @@ -484,11 +438,7 @@ void DecCu::xIntraRecACTBlk(TransformUnit& tu) piPred.reconstruct(piPred, piResi, tu.cu->cs->slice->clpRng(compID)); piReco.copyFrom(piPred); -#if JVET_Q0346_LMCS_ENABLE_IN_SH if (slice.getLmcsEnabledFlag() && (m_pcReshape->getCTUFlag() || slice.isIntra()) && compID == COMPONENT_Y) -#else - if (slice.getPicHeader()->getLmcsEnabledFlag() && (m_pcReshape->getCTUFlag() || slice.isIntra()) && compID == COMPONENT_Y) -#endif { piPred.copyFrom(tmpPred); } @@ -519,7 +469,6 @@ void DecCu::xReconIntraQT( CodingUnit &cu ) } else { -#if JVET_Q0504_PLT_NON444 if( cu.chromaFormat != CHROMA_400 ) { xReconPLT(cu, COMPONENT_Y, 3); @@ -528,9 +477,6 @@ void DecCu::xReconIntraQT( CodingUnit &cu ) { xReconPLT(cu, COMPONENT_Y, 1); } -#else - xReconPLT(cu, COMPONENT_Y, 3); -#endif } return; } @@ -692,44 +638,23 @@ void DecCu::xFillPCMBuffer(CodingUnit &cu) void DecCu::xReconInter(CodingUnit &cu) { -#if !JVET_Q0806 - if( cu.triangle ) - { - const bool splitDir = cu.firstPU->triangleSplitDir; - const uint8_t candIdx0 = cu.firstPU->triangleMergeIdx0; - const uint8_t candIdx1 = cu.firstPU->triangleMergeIdx1; - m_pcInterPred->motionCompensation4Triangle( cu, m_triangleMrgCtx, splitDir, candIdx0, candIdx1 ); - PU::spanTriangleMotionInfo( *cu.firstPU, m_triangleMrgCtx, splitDir, candIdx0, candIdx1 ); - } - else -#else if( cu.geoFlag ) { m_pcInterPred->motionCompensationGeo( cu, m_geoMrgCtx ); PU::spanGeoMotionInfo( *cu.firstPU, m_geoMrgCtx, cu.firstPU->geoSplitDir, cu.firstPU->geoMergeIdx0, cu.firstPU->geoMergeIdx1 ); } else -#endif { m_pcIntraPred->geneIntrainterPred(cu); // inter prediction CHECK(CU::isIBC(cu) && cu.firstPU->ciipFlag, "IBC and Ciip cannot be used together"); CHECK(CU::isIBC(cu) && cu.affine, "IBC and Affine cannot be used together"); -#if !JVET_Q0806 - CHECK(CU::isIBC(cu) && cu.triangle, "IBC and triangle cannot be used together"); -#else CHECK(CU::isIBC(cu) && cu.geoFlag, "IBC and geo cannot be used together"); -#endif CHECK(CU::isIBC(cu) && cu.firstPU->mmvdMergeFlag, "IBC and MMVD cannot be used together"); const bool luma = cu.Y().valid(); -#if JVET_Q0438_MONOCHROME_BUGFIXES const bool chroma = isChromaEnabled(cu.chromaFormat) && cu.Cb().valid(); if (luma && (chroma || !isChromaEnabled(cu.chromaFormat))) -#else - const bool chroma = cu.Cb().valid(); - if (luma && chroma) -#endif { m_pcInterPred->motionCompensation(cu); } @@ -746,20 +671,12 @@ void DecCu::xReconInter(CodingUnit &cu) if (cu.firstPU->ciipFlag) { -#if JVET_Q0346_LMCS_ENABLE_IN_SH if (cu.cs->slice->getLmcsEnabledFlag() && m_pcReshape->getCTUFlag()) -#else - if (cu.cs->picHeader->getLmcsEnabledFlag() && m_pcReshape->getCTUFlag()) -#endif { cu.cs->getPredBuf(*cu.firstPU).Y().rspSignal(m_pcReshape->getFwdLUT()); } m_pcIntraPred->geneWeightedPred(COMPONENT_Y, cu.cs->getPredBuf(*cu.firstPU).Y(), *cu.firstPU, m_pcIntraPred->getPredictorPtr2(COMPONENT_Y, 0)); -#if JVET_Q0438_MONOCHROME_BUGFIXES if (isChromaEnabled(cu.chromaFormat) && cu.chromaSize().width > 2) -#else - if (cu.chromaSize().width > 2) -#endif { m_pcIntraPred->geneWeightedPred(COMPONENT_Cb, cu.cs->getPredBuf(*cu.firstPU).Cb(), *cu.firstPU, m_pcIntraPred->getPredictorPtr2(COMPONENT_Cb, 0)); m_pcIntraPred->geneWeightedPred(COMPONENT_Cr, cu.cs->getPredBuf(*cu.firstPU).Cr(), *cu.firstPU, m_pcIntraPred->getPredictorPtr2(COMPONENT_Cr, 0)); @@ -779,22 +696,14 @@ void DecCu::xReconInter(CodingUnit &cu) { if (cu.colorTransform) { -#if JVET_Q0820_ACT cs.getResiBuf(cu).colorSpaceConvert(cs.getResiBuf(cu), false, cu.cs->slice->clpRng(COMPONENT_Y)); -#else - cs.getResiBuf(cu).colorSpaceConvert(cs.getResiBuf(cu), false); -#endif } #if REUSE_CU_RESULTS const CompArea &area = cu.blocks[COMPONENT_Y]; CompArea tmpArea(COMPONENT_Y, area.chromaFormat, Position(0, 0), area.size()); PelBuf tmpPred; #endif -#if JVET_Q0346_LMCS_ENABLE_IN_SH if (cs.slice->getLmcsEnabledFlag() && m_pcReshape->getCTUFlag()) -#else - if (cs.picHeader->getLmcsEnabledFlag() && m_pcReshape->getCTUFlag()) -#endif { #if REUSE_CU_RESULTS if (cs.pcv->isEncoder) @@ -812,11 +721,7 @@ void DecCu::xReconInter(CodingUnit &cu) cs.getResiBuf( cu ).reconstruct( cs.getPredBuf( cu ), cs.getResiBuf( cu ), cs.slice->clpRngs() ); cs.getRecoBuf( cu ).copyFrom ( cs.getResiBuf( cu ) ); #endif -#if JVET_Q0346_LMCS_ENABLE_IN_SH if (cs.slice->getLmcsEnabledFlag() && m_pcReshape->getCTUFlag()) -#else - if (cs.picHeader->getLmcsEnabledFlag() && m_pcReshape->getCTUFlag()) -#endif { #if REUSE_CU_RESULTS if (cs.pcv->isEncoder) @@ -829,11 +734,7 @@ void DecCu::xReconInter(CodingUnit &cu) else { cs.getRecoBuf(cu).copyClip(cs.getPredBuf(cu), cs.slice->clpRngs()); -#if JVET_Q0346_LMCS_ENABLE_IN_SH if (cs.slice->getLmcsEnabledFlag() && m_pcReshape->getCTUFlag() && !cu.firstPU->ciipFlag && !CU::isIBC(cu)) -#else - if (cs.picHeader->getLmcsEnabledFlag() && m_pcReshape->getCTUFlag() && !cu.firstPU->ciipFlag && !CU::isIBC(cu)) -#endif { cs.getRecoBuf(cu).get(COMPONENT_Y).rspSignal(m_pcReshape->getFwdLUT()); } @@ -857,17 +758,6 @@ void DecCu::xDecodeInterTU( TransformUnit & currTU, const ComponentID compID ) PelBuf resiBuf = cs.getResiBuf(area); QpParam cQP(currTU, compID); -#if !JVET_Q0820_ACT - if (currTU.cu->colorTransform) - { - for (int qpIdx = 0; qpIdx < 2; qpIdx++) - { - cQP.Qps[qpIdx] = cQP.Qps[qpIdx] + (compID == COMPONENT_Cr ? DELTA_QP_FOR_Co : DELTA_QP_FOR_Y_Cg); - cQP.pers[qpIdx] = cQP.Qps[qpIdx] / 6; - cQP.rems[qpIdx] = cQP.Qps[qpIdx] % 6; - } - } -#endif if( currTU.jointCbCr && isChroma(compID) ) { @@ -881,17 +771,6 @@ void DecCu::xDecodeInterTU( TransformUnit & currTU, const ComponentID compID ) else { QpParam qpCr(currTU, COMPONENT_Cr); -#if !JVET_Q0820_ACT - if (currTU.cu->colorTransform) - { - for (int qpIdx = 0; qpIdx < 2; qpIdx++) - { - qpCr.Qps[qpIdx] = qpCr.Qps[qpIdx] + DELTA_QP_FOR_Co; - qpCr.pers[qpIdx] = qpCr.Qps[qpIdx] / 6; - qpCr.rems[qpIdx] = qpCr.Qps[qpIdx] % 6; - } - } -#endif m_pcTrQuant->invTransformNxN( currTU, COMPONENT_Cr, resiCr, qpCr ); } m_pcTrQuant->invTransformICT( currTU, resiBuf, resiCr ); @@ -909,22 +788,11 @@ void DecCu::xDecodeInterTU( TransformUnit & currTU, const ComponentID compID ) //===== reconstruction ===== const Slice &slice = *cs.slice; -#if JVET_Q0346_LMCS_ENABLE_IN_SH if (slice.getLmcsEnabledFlag() && isChroma(compID) && (TU::getCbf(currTU, compID) || currTU.jointCbCr) && slice.getPicHeader()->getLmcsChromaResidualScaleFlag() && currTU.blocks[compID].width * currTU.blocks[compID].height > 4) -#else - if (slice.getPicHeader()->getLmcsEnabledFlag() && isChroma(compID) && (TU::getCbf(currTU, compID) || currTU.jointCbCr) - && slice.getPicHeader()->getLmcsChromaResidualScaleFlag() && currTU.blocks[compID].width * currTU.blocks[compID].height > 4) -#endif { resiBuf.scaleSignal(currTU.getChromaAdj(), 0, currTU.cu->cs->slice->clpRng(compID)); } -#if !REMOVE_PPS_REXT - if( isChroma( compID ) && currTU.compAlpha[compID] != 0 ) - { - CrossComponentPrediction::crossComponentPrediction( currTU, compID, cs.getResiBuf( currTU.Y() ), resiBuf, resiBuf, true ); - } -#endif } void DecCu::xDecodeInterTexture(CodingUnit &cu) @@ -944,11 +812,7 @@ void DecCu::xDecodeInterTexture(CodingUnit &cu) { CodingStructure &cs = *cu.cs; const Slice &slice = *cs.slice; -#if JVET_Q0346_LMCS_ENABLE_IN_SH if (slice.getLmcsEnabledFlag() && slice.getPicHeader()->getLmcsChromaResidualScaleFlag() && (compID == COMPONENT_Y) && (currTU.cbf[COMPONENT_Cb] || currTU.cbf[COMPONENT_Cr])) -#else - if (slice.getPicHeader()->getLmcsEnabledFlag() && slice.getPicHeader()->getLmcsChromaResidualScaleFlag() && (compID == COMPONENT_Y) && (currTU.cbf[COMPONENT_Cb] || currTU.cbf[COMPONENT_Cr])) -#endif { const CompArea &areaY = currTU.blocks[COMPONENT_Y]; int adj = m_pcReshape->calculateChromaAdjVpduNei(currTU, areaY); @@ -996,19 +860,11 @@ void DecCu::xDeriveCUMV( CodingUnit &cu ) else { { -#if !JVET_Q0806 - if( pu.cu->triangle ) - { - PU::getTriangleMergeCandidates( pu, m_triangleMrgCtx ); - } - else -#else if( pu.cu->geoFlag ) { PU::getGeoMergeCandidates( pu, m_geoMrgCtx ); } else -#endif { if( pu.cu->affine ) { @@ -1123,11 +979,7 @@ void DecCu::xDeriveCUMV( CodingUnit &cu ) { mvd.changeIbcPrecAmvr2Internal(pu.cu->imv); } -#if JVET_Q0798_SPS_NUMBER_MERGE_CANDIDATE if (pu.cs->sps->getMaxNumIBCMergeCand() == 1) -#else - if ( pu.cu->slice->getPicHeader()->getMaxNumIBCMergeCand() == 1 ) -#endif { CHECK( pu.mvpIdx[REF_PIC_LIST_0], "mvpIdx for IBC mode should be 0" ); } @@ -1156,15 +1008,6 @@ void DecCu::xDeriveCUMV( CodingUnit &cu ) PU::spanMotionInfo( pu, mrgCtx ); } } -#if !JVET_Q0806 - if( !cu.triangle ) - { - if( g_mctsDecCheckEnabled && !MCTSHelper::checkMvBufferForMCTSConstraint( pu, true ) ) - { - printf( "DECODER: pu motion vector across tile boundaries (%d,%d,%d,%d)\n", pu.lx(), pu.ly(), pu.lwidth(), pu.lheight() ); - } - } -#else if( !cu.geoFlag ) { if( g_mctsDecCheckEnabled && !MCTSHelper::checkMvBufferForMCTSConstraint( pu, true ) ) @@ -1172,7 +1015,6 @@ void DecCu::xDeriveCUMV( CodingUnit &cu ) printf( "DECODER: pu motion vector across tile boundaries (%d,%d,%d,%d)\n", pu.lx(), pu.ly(), pu.lwidth(), pu.lheight() ); } } -#endif if (CU::isIBC(cu)) { const int cuPelX = pu.Y().x; diff --git a/source/Lib/DecoderLib/DecCu.h b/source/Lib/DecoderLib/DecCu.h index c6932f3e91866433cec7aacf29e3530e6b0c01ed..8789afadb46e306d9c6cadc7108d2fd949a7d613 100644 --- a/source/Lib/DecoderLib/DecCu.h +++ b/source/Lib/DecoderLib/DecCu.h @@ -98,11 +98,7 @@ private: MotionInfo m_SubPuMiBuf[(MAX_CU_SIZE * MAX_CU_SIZE) >> (MIN_CU_LOG2 << 1)]; -#if !JVET_Q0806 - MergeCtx m_triangleMrgCtx; -#else MergeCtx m_geoMrgCtx; -#endif }; //! \} diff --git a/source/Lib/DecoderLib/DecLib.cpp b/source/Lib/DecoderLib/DecLib.cpp index e3df97357b0b1a6ebee965a9604e90e9b51f6afe..77eb7ba29f1c23d7a5fb70eb5144c7730c351469 100644 --- a/source/Lib/DecoderLib/DecLib.cpp +++ b/source/Lib/DecoderLib/DecLib.cpp @@ -44,9 +44,7 @@ #include "CommonLib/UnitTools.h" #include <fstream> -#if JVET_Q0751_MIXED_NAL_UNIT_TYPES #include <set> -#endif #include <stdio.h> #include <fcntl.h> #include "AnnexBread.h" @@ -65,11 +63,7 @@ bool tryDecodePicture( Picture* pcEncPic, const int expectedPoc, const std::stri PicList* pcListPic = NULL; static bool bFirstCall = true; /* TODO: MT */ -#if JVET_P0125_EOS_LAYER_SPECIFIC static bool loopFiltered[MAX_VPS_LAYERS] = { false }; /* TODO: MT */ -#else - static bool loopFiltered = false; /* TODO: MT */ -#endif static int iPOCLastDisplay = -MAX_INT; /* TODO: MT */ static std::ifstream* bitstreamFile = nullptr; /* TODO: MT */ @@ -137,11 +131,7 @@ bool tryDecodePicture( Picture* pcEncPic, const int expectedPoc, const std::stri read( nalu ); int iSkipFrame = 0; -#if JVET_P0288_PIC_OUTPUT bNewPicture = pcDecLib->decode(nalu, iSkipFrame, iPOCLastDisplay, 0); -#else - bNewPicture = pcDecLib->decode(nalu, iSkipFrame, iPOCLastDisplay); -#endif if( bNewPicture ) { bitstreamFile->clear(); @@ -154,17 +144,9 @@ bool tryDecodePicture( Picture* pcEncPic, const int expectedPoc, const std::stri } } -#if JVET_P0125_EOS_LAYER_SPECIFIC if ((bNewPicture || !*bitstreamFile || nalu.m_nalUnitType == NAL_UNIT_EOS) && !pcDecLib->getFirstSliceInSequence(nalu.m_nuhLayerId)) -#else - if( ( bNewPicture || !*bitstreamFile || nalu.m_nalUnitType == NAL_UNIT_EOS ) && !pcDecLib->getFirstSliceInSequence() ) -#endif { -#if JVET_P0125_EOS_LAYER_SPECIFIC if (!loopFiltered[nalu.m_nuhLayerId] || *bitstreamFile) -#else - if( !loopFiltered || *bitstreamFile ) -#endif { pcDecLib->finishPictureLight( poc, pcListPic ); @@ -242,12 +224,10 @@ bool tryDecodePicture( Picture* pcEncPic, const int expectedPoc, const std::stri pcEncPic->slices[i]->setTileGroupAlfEnabledFlag(COMPONENT_Y, pic->slices[i]->getTileGroupAlfEnabledFlag(COMPONENT_Y)); pcEncPic->slices[i]->setTileGroupAlfEnabledFlag(COMPONENT_Cb, pic->slices[i]->getTileGroupAlfEnabledFlag(COMPONENT_Cb)); pcEncPic->slices[i]->setTileGroupAlfEnabledFlag(COMPONENT_Cr, pic->slices[i]->getTileGroupAlfEnabledFlag(COMPONENT_Cr)); -#if JVET_Q0795_CCALF pcEncPic->slices[i]->setTileGroupCcAlfCbApsId(pic->slices[i]->getTileGroupCcAlfCbApsId()); pcEncPic->slices[i]->setTileGroupCcAlfCbEnabledFlag(pic->slices[i]->getTileGroupCcAlfCbEnabledFlag()); pcEncPic->slices[i]->setTileGroupCcAlfCrApsId(pic->slices[i]->getTileGroupCcAlfCrApsId()); pcEncPic->slices[i]->setTileGroupCcAlfCrEnabledFlag(pic->slices[i]->getTileGroupCcAlfCrEnabledFlag()); -#endif } } @@ -288,7 +268,6 @@ bool tryDecodePicture( Picture* pcEncPic, const int expectedPoc, const std::stri uint32_t maxNrSublayers = activeSPS->getMaxTLayers(); uint32_t numReorderPicsHighestTid = activeSPS->getNumReorderPics(maxNrSublayers-1); uint32_t maxDecPicBufferingHighestTid = activeSPS->getMaxDecPicBuffering(maxNrSublayers-1); -#if JVET_Q0814_DPB const VPS* referredVPS = pcListPic->front()->cs->vps; if( referredVPS != nullptr && referredVPS->m_numLayersInOls[referredVPS->m_targetOlsIdx] > 1 ) @@ -296,7 +275,6 @@ bool tryDecodePicture( Picture* pcEncPic, const int expectedPoc, const std::stri numReorderPicsHighestTid = referredVPS->getNumReorderPics( maxNrSublayers - 1 ); maxDecPicBufferingHighestTid = referredVPS->getMaxDecPicBuffering( maxNrSublayers - 1 ); } -#endif while (iterPic != pcListPic->end()) { @@ -359,26 +337,14 @@ bool tryDecodePicture( Picture* pcEncPic, const int expectedPoc, const std::stri } -#if JVET_P0125_EOS_LAYER_SPECIFIC loopFiltered[nalu.m_nuhLayerId] = (nalu.m_nalUnitType == NAL_UNIT_EOS); -#else - loopFiltered = ( nalu.m_nalUnitType == NAL_UNIT_EOS ); -#endif if( nalu.m_nalUnitType == NAL_UNIT_EOS ) { -#if JVET_P0125_EOS_LAYER_SPECIFIC pcDecLib->setFirstSliceInSequence(true, nalu.m_nuhLayerId); -#else - pcDecLib->setFirstSliceInSequence( true ); -#endif } } -#if JVET_P0125_EOS_LAYER_SPECIFIC else if ((bNewPicture || !*bitstreamFile || nalu.m_nalUnitType == NAL_UNIT_EOS) && pcDecLib->getFirstSliceInSequence(nalu.m_nuhLayerId)) -#else - else if( ( bNewPicture || !*bitstreamFile || nalu.m_nalUnitType == NAL_UNIT_EOS ) && pcDecLib->getFirstSliceInSequence() ) -#endif { pcDecLib->setFirstSliceInPicture( true ); } @@ -396,14 +362,10 @@ bool tryDecodePicture( Picture* pcEncPic, const int expectedPoc, const std::stri pcDecLib = nullptr; } bFirstCall = true; -#if JVET_P0125_EOS_LAYER_SPECIFIC for (int i = 0; i < MAX_VPS_LAYERS; i++) { loopFiltered[i] = false; } -#else - loopFiltered = false; -#endif iPOCLastDisplay = -MAX_INT; if( bytestream ) @@ -428,11 +390,11 @@ bool tryDecodePicture( Picture* pcEncPic, const int expectedPoc, const std::stri DecLib::DecLib() : m_iMaxRefPicNum(0) + , m_isFirstGeneralHrd(true) + , m_prevGeneralHrdParams() , m_associatedIRAPType(NAL_UNIT_INVALID) -#if JVET_P0978_RPL_RESTRICTIONS , m_associatedIRAPDecodingOrderNumber(0) , m_decodingOrderCounter(0) -#endif , m_pocCRA(0) , m_pocRandomAccess(MAX_INT) , m_lastRasPoc(MAX_INT) @@ -459,21 +421,13 @@ DecLib::DecLib() , m_prevPOC(MAX_INT) , m_prevTid0POC(0) , m_bFirstSliceInPicture(true) -#if JVET_P0125_EOS_LAYER_SPECIFIC , m_firstSliceInSequence{ true } -#else - , m_bFirstSliceInSequence(true) -#endif , m_firstSliceInBitstream(true) , m_prevSliceSkipped(false) , m_skippedPOC(0) , m_lastPOCNoOutputPriorPics(-1) , m_isNoOutputPriorPics(false) -#if SPS_ID_CHECK , m_lastNoOutputBeforeRecoveryFlag( false ) -#else - , m_lastNoIncorrectPicOutputFlag(false) -#endif , m_sliceLmcsApsId(-1) , m_pDecodedSEIOutputStream(NULL) , m_decodedPictureHashSEIEnabled(false) @@ -483,17 +437,9 @@ DecLib::DecLib() , m_debugPOC( -1 ) , m_debugCTU( -1 ) , m_vps( nullptr ) -#if !JVET_Q0346_SCALING_LIST_USED_IN_SH - , m_scalingListUpdateFlag(true) - , m_PreScalingListAPSId(-1) -#endif -#if JVET_Q0044_SLICE_IDX_WITH_SUBPICS , m_maxDecSubPicIdx(0) , m_maxDecSliceAddrInSubPic(-1) -#endif -#if JVET_Q0117_PARAMETER_SETS_CLEANUP , m_dci(NULL) -#endif { #if ENABLE_SIMD_OPT_BUFFER g_pelBufOP.initPelBufOpsX86(); @@ -521,13 +467,11 @@ void DecLib::destroy() delete m_apcSlicePilot; m_apcSlicePilot = NULL; -#if JVET_Q0117_PARAMETER_SETS_CLEANUP if( m_dci ) { delete m_dci; m_dci = NULL; } -#endif m_cSliceDecoder.destroy(); } @@ -574,11 +518,7 @@ void DecLib::deletePicBuffer ( ) Picture* DecLib::xGetNewPicBuffer( const SPS &sps, const PPS &pps, const uint32_t temporalLayer, const int layerId ) { Picture * pcPic = nullptr; -#if JVET_Q0814_DPB m_iMaxRefPicNum = ( m_vps == nullptr || m_vps->m_numLayersInOls[m_vps->m_targetOlsIdx] == 1 ) ? sps.getMaxDecPicBuffering( temporalLayer ) : m_vps->getMaxDecPicBuffering( temporalLayer ); // m_uiMaxDecPicBuffering has the space for the picture currently being decoded -#else - m_iMaxRefPicNum = sps.getMaxDecPicBuffering(temporalLayer); // m_uiMaxDecPicBuffering has the space for the picture currently being decoded -#endif if (m_cListPic.size() < (uint32_t)m_iMaxRefPicNum) { pcPic = new Picture(); @@ -679,16 +619,13 @@ void DecLib::executeLoopFilters() if( cs.sps->getALFEnabledFlag() ) { -#if JVET_Q0795_CCALF m_cALF.getCcAlfFilterParam() = cs.slice->m_ccAlfFilterParam; -#endif // ALF decodes the differentially coded coefficients and stores them in the parameters structure. // Code could be restructured to do directly after parsing. So far we just pass a fresh non-const // copy in case the APS gets used more than once. m_cALF.ALFProcess(cs); } -#if JVET_O1143_SUBPIC_BOUNDARY for (int i = 0; i < cs.pps->getNumSubPics() && m_targetSubPicIdx; i++) { // keep target subpic samples untouched, for other subpics mask their output sample value to 0 @@ -710,9 +647,8 @@ void DecLib::executeLoopFilters() cs.getRecoBuf().Cr().at(col>>1, row>>1) = 0; } } - } + } } -#endif m_pcPic->cs->slice->stopProcessingTimer(); } @@ -788,7 +724,7 @@ void DecLib::finishPicture(int& poc, PicList*& rpcListPic, MsgLevel msgl ) if( pcSlice->getRefPOC( RefPicList( iRefList ), iRefIndex ) == pcSlice->getPOC() ) { msg( msgl, ".%d", pcSlice->getRefPic( RefPicList( iRefList ), iRefIndex )->layerId ); - } + } } msg( msgl, "] "); } @@ -819,10 +755,8 @@ void DecLib::finishPicture(int& poc, PicList*& rpcListPic, MsgLevel msgl ) poc = pcSlice->getPOC(); rpcListPic = &m_cListPic; m_bFirstSliceInPicture = true; // TODO: immer true? hier ist irgendwas faul -#if JVET_Q0044_SLICE_IDX_WITH_SUBPICS m_maxDecSubPicIdx = 0; m_maxDecSliceAddrInSubPic = -1; -#endif m_pcPic->destroyTempBuffers(); m_pcPic->cs->destroyCoeffs(); @@ -936,7 +870,6 @@ void DecLib::xCreateUnavailablePicture(int iUnavailablePoc, bool longTermFlag, c } } -#if JVET_P0125_ASPECT_TID_LAYER_ID_NUH void DecLib::checkTidLayerIdInAccessUnit() { int firstPicTid = m_accessUnitPicInfo.begin()->m_temporalId; @@ -977,8 +910,6 @@ void DecLib::checkTidLayerIdInAccessUnit() CHECK(!isFdNaluLayerIdSameAsVclNaluLayerId, "The nuh_layer_id of a filler data NAL unit shall be equal to the nuh_layer_id of associated VCL NAL unit"); } -#endif -#if JVET_P0125_SEI_CONSTRAINTS void DecLib::checkSEIInAccessUnit() { for (auto &sei : m_accessUnitSeiPayLoadTypes) @@ -999,13 +930,12 @@ void DecLib::checkSEIInAccessUnit() } } CHECK(!inZeroOls, "non-scalable-nested timing related SEI shall apply only to the 0-th OLS"); - + int layerId = m_vps->getLayerId(0); CHECK(nuhLayerId != layerId, "the nuh_layer_id of non-scalable-nested timing related SEI shall be equal to vps_layer_id[0]"); } } } -#endif #if JVET_Q0488_SEI_REPETITION_CONSTRAINT #define SEI_REPETITION_CONSTRAINT_LIST_SIZE 21 @@ -1140,14 +1070,7 @@ bool DecLib::isSliceNaluFirstInAU( bool newPicture, InputNALUnit &nalu ) return false; } -#if !JVET_Q0819_PH_CHANGES - // check for valid picture header - if(m_picHeader.isValid() == false) - { - return false; - } -#endif - + // check for layer ID less than or equal to previous picture's layer ID if( nalu.m_nuhLayerId <= m_prevLayerID ) { @@ -1156,20 +1079,43 @@ bool DecLib::isSliceNaluFirstInAU( bool newPicture, InputNALUnit &nalu ) // get slice POC m_apcSlicePilot->setPicHeader( &m_picHeader ); - m_apcSlicePilot->initSlice(); + m_apcSlicePilot->initSlice(); m_HLSReader.setBitstream( &nalu.getBitstream() ); -#if JVET_Q0819_PH_CHANGES m_HLSReader.getSlicePoc( m_apcSlicePilot, &m_picHeader, &m_parameterSetManager, m_prevTid0POC ); -#else - m_HLSReader.parseSliceHeaderToPoc( m_apcSlicePilot, &m_picHeader, &m_parameterSetManager, m_prevTid0POC ); -#endif // check for different POC return (m_apcSlicePilot->getPOC() != m_prevPOC); } +#if JVET_R0201_PREFIX_SUFFIX_APS_CLEANUP +void DecLib::checkAPSInPictureUnit() +{ + bool firstVCLFound = false; + bool suffixAPSFound = false; + for (auto &nalu : m_pictureUnitNals) + { + if (NALUnit::isVclNalUnitType(nalu)) + { + firstVCLFound = true; + CHECK( suffixAPSFound, "When any suffix APS NAL units are present in a PU, they shall follow the last VCL unit of the PU" ); + } + else if (nalu == NAL_UNIT_PREFIX_APS) + { + CHECK( firstVCLFound, "When any prefix APS NAL units are present in a PU, they shall precede the first VCL unit of the PU"); + } + else if (nalu == NAL_UNIT_SUFFIX_APS) + { + suffixAPSFound = true; + } + } +} +#endif + void activateAPS(PicHeader* picHeader, Slice* pSlice, ParameterSetManager& parameterSetManager, APS** apss, APS* lmcsAPS, APS* scalingListAPS) { +#if JVET_R0232_CCALF_APS_CONSTRAINT + const SPS *sps = parameterSetManager.getSPS(picHeader->getSPSId()); +#endif //luma APSs if (pSlice->getTileGroupAlfEnabledFlag(COMPONENT_Y)) { @@ -1188,6 +1134,10 @@ void activateAPS(PicHeader* picHeader, Slice* pSlice, ParameterSetManager& param CHECK( aps->getTemporalId() > pSlice->getTLayer(), "TemporalId shall be less than or equal to the TemporalId of the coded slice NAL unit" ); //ToDO: APS NAL unit containing the APS RBSP shall have nuh_layer_id either equal to the nuh_layer_id of a coded slice NAL unit that referrs it, or equal to the nuh_layer_id of a direct dependent layer of the layer containing a coded slice NAL unit that referrs it. + +#if JVET_R0232_CCALF_APS_CONSTRAINT + CHECK(((sps->getCCALFEnabledFlag() == false) && (aps->getCcAlfAPSParam().newCcAlfFilter[0] || aps->getCcAlfAPSParam().newCcAlfFilter[1])), "When sps_ccalf_enabled_flag is 0, the values of alf_cc_cb_filter_signal_flag and alf_cc_cr_filter_signal_flag shall be equal to 0"); +#endif } } } @@ -1206,10 +1156,13 @@ void activateAPS(PicHeader* picHeader, Slice* pSlice, ParameterSetManager& param CHECK( aps->getTemporalId() > pSlice->getTLayer(), "TemporalId shall be less than or equal to the TemporalId of the coded slice NAL unit" ); //ToDO: APS NAL unit containing the APS RBSP shall have nuh_layer_id either equal to the nuh_layer_id of a coded slice NAL unit that referrs it, or equal to the nuh_layer_id of a direct dependent layer of the layer containing a coded slice NAL unit that referrs it. + +#if JVET_R0232_CCALF_APS_CONSTRAINT + CHECK(((sps->getCCALFEnabledFlag() == false) && (aps->getCcAlfAPSParam().newCcAlfFilter[0] || aps->getCcAlfAPSParam().newCcAlfFilter[1])), "When sps_ccalf_enabled_flag is 0, the values of alf_cc_cb_filter_signal_flag and alf_cc_cr_filter_signal_flag shall be equal to 0"); +#endif } } -#if JVET_Q0795_CCALF CcAlfFilterParam &filterParam = pSlice->m_ccAlfFilterParam; // cleanup before copying for ( int filterIdx = 0; filterIdx < MAX_NUM_CC_ALF_FILTERS; filterIdx++ ) @@ -1267,7 +1220,6 @@ void activateAPS(PicHeader* picHeader, Slice* pSlice, ParameterSetManager& param } } } -#endif if (picHeader->getLmcsEnabledFlag() && lmcsAPS == nullptr) { @@ -1287,11 +1239,7 @@ void activateAPS(PicHeader* picHeader, Slice* pSlice, ParameterSetManager& param } picHeader->setLmcsAPS(lmcsAPS); -#if JVET_Q0346_SCALING_LIST_USED_IN_SH if( picHeader->getExplicitScalingListEnabledFlag() && scalingListAPS == nullptr) -#else - if( picHeader->getScalingListPresentFlag() && scalingListAPS == nullptr) -#endif { scalingListAPS = parameterSetManager.getAPS( picHeader->getScalingListAPSId(), SCALING_LIST_APS ); CHECK( scalingListAPS == nullptr, "No SCALING LIST APS present" ); @@ -1324,10 +1272,11 @@ void DecLib::xActivateParameterSets( const int layerId ) const VPS *vps = sps->getVPSId() ? m_parameterSetManager.getVPS( sps->getVPSId() ) : nullptr; - if (NULL == pps->pcv) + if( nullptr != pps->pcv ) { - m_parameterSetManager.getPPS( m_picHeader.getPPSId() )->pcv = new PreCalcValues( *sps, *pps, false ); + delete m_parameterSetManager.getPPS( m_picHeader.getPPSId() )->pcv; } + m_parameterSetManager.getPPS( m_picHeader.getPPSId() )->pcv = new PreCalcValues( *sps, *pps, false ); m_parameterSetManager.clearSPSChangedFlag(sps->getSPSId()); m_parameterSetManager.clearPPSChangedFlag(pps->getPPSId()); @@ -1335,11 +1284,7 @@ void DecLib::xActivateParameterSets( const int layerId ) { THROW("Parameter set activation failed!"); } - -#if JVET_O1143_SUBPIC_BOUNDARY && !JVET_Q0044_SLICE_IDX_WITH_SUBPICS - PPS* nonconstPPS = m_parameterSetManager.getPPS(m_picHeader.getPPSId()); - nonconstPPS->initSubPic(*sps); -#endif + m_parameterSetManager.getApsMap()->clear(); for (int i = 0; i < ALF_CTB_MAX_NUM_APS; i++) @@ -1366,11 +1311,7 @@ void DecLib::xActivateParameterSets( const int layerId ) // Get a new picture buffer. This will also set up m_pcPic, and therefore give us a SPS and PPS pointer that we can use. m_pcPic = xGetNewPicBuffer( *sps, *pps, m_apcSlicePilot->getTLayer(), layerId ); -#if JVET_Q0751_MIXED_NAL_UNIT_TYPES m_apcSlicePilot->applyReferencePictureListBasedMarking( m_cListPic, m_apcSlicePilot->getRPL0(), m_apcSlicePilot->getRPL1(), layerId, *pps); -#else - m_apcSlicePilot->applyReferencePictureListBasedMarking( m_cListPic, m_apcSlicePilot->getRPL0(), m_apcSlicePilot->getRPL1(), layerId ); -#endif m_pcPic->finalInit( vps, *sps, *pps, &m_picHeader, apss, lmcsAPS, scalinglistAPS ); m_pcPic->createTempBuffers( m_pcPic->cs->pps->pcv->maxCUWidth ); m_pcPic->cs->createCoeffs((bool)m_pcPic->cs->sps->getPLTMode()); @@ -1400,9 +1341,7 @@ void DecLib::xActivateParameterSets( const int layerId ) m_pcPic->cs->pcv = pps->pcv; // Initialise the various objects for the new set of settings -#if JVET_Q0468_Q0469_MIN_LUMA_CB_AND_MIN_QT_FIX const int maxDepth = floorLog2(sps->getMaxCUWidth()) - pps->pcv->minCUWidthLog2; -#if JVET_Q0441_SAO_MOD_12_BIT const uint32_t log2SaoOffsetScaleLuma = (uint32_t) std::max(0, sps->getBitDepth(CHANNEL_TYPE_LUMA ) - MAX_SAO_TRUNCATED_BITDEPTH); const uint32_t log2SaoOffsetScaleChroma = (uint32_t) std::max(0, sps->getBitDepth(CHANNEL_TYPE_CHROMA) - MAX_SAO_TRUNCATED_BITDEPTH); m_cSAO.create( pps->getPicWidthInLumaSamples(), pps->getPicHeightInLumaSamples(), @@ -1410,24 +1349,7 @@ void DecLib::xActivateParameterSets( const int layerId ) sps->getMaxCUWidth(), sps->getMaxCUHeight(), maxDepth, log2SaoOffsetScaleLuma, log2SaoOffsetScaleChroma ); -#else - m_cSAO.create(pps->getPicWidthInLumaSamples(), pps->getPicHeightInLumaSamples(), sps->getChromaFormatIdc(), sps->getMaxCUWidth(), sps->getMaxCUHeight(), maxDepth, pps->getPpsRangeExtension().getLog2SaoOffsetScale(CHANNEL_TYPE_LUMA), pps->getPpsRangeExtension().getLog2SaoOffsetScale(CHANNEL_TYPE_CHROMA)); -#endif m_cLoopFilter.create(maxDepth); -#else -#if JVET_Q0441_SAO_MOD_12_BIT - const uint32_t log2SaoOffsetScaleLuma = (uint32_t) std::max(0, sps->getBitDepth(CHANNEL_TYPE_LUMA ) - MAX_SAO_TRUNCATED_BITDEPTH); - const uint32_t log2SaoOffsetScaleChroma = (uint32_t) std::max(0, sps->getBitDepth(CHANNEL_TYPE_CHROMA) - MAX_SAO_TRUNCATED_BITDEPTH); - m_cSAO.create( pps->getPicWidthInLumaSamples(), pps->getPicHeightInLumaSamples(), - sps->getChromaFormatIdc(), - sps->getMaxCUWidth(), sps->getMaxCUHeight(), - sps->getMaxCodingDepth(), - log2SaoOffsetScaleLuma, log2SaoOffsetScaleChroma ); -#else - m_cSAO.create( pps->getPicWidthInLumaSamples(), pps->getPicHeightInLumaSamples(), sps->getChromaFormatIdc(), sps->getMaxCUWidth(), sps->getMaxCUHeight(), sps->getMaxCodingDepth(), pps->getPpsRangeExtension().getLog2SaoOffsetScale( CHANNEL_TYPE_LUMA ), pps->getPpsRangeExtension().getLog2SaoOffsetScale( CHANNEL_TYPE_CHROMA ) ); -#endif - m_cLoopFilter.create( sps->getMaxCodingDepth() ); -#endif m_cIntraPred.init( sps->getChromaFormatIdc(), sps->getBitDepth( CHANNEL_TYPE_LUMA ) ); m_cInterPred.init( &m_cRdCost, sps->getChromaFormatIdc(), sps->getMaxCUHeight() ); if (sps->getUseLmcs()) @@ -1473,17 +1395,11 @@ void DecLib::xActivateParameterSets( const int layerId ) if( sps->getALFEnabledFlag() ) { -#if JVET_Q0468_Q0469_MIN_LUMA_CB_AND_MIN_QT_FIX const int maxDepth = floorLog2(sps->getMaxCUWidth()) - sps->getLog2MinCodingBlockSize(); m_cALF.create( pps->getPicWidthInLumaSamples(), pps->getPicHeightInLumaSamples(), sps->getChromaFormatIdc(), sps->getMaxCUWidth(), sps->getMaxCUHeight(), maxDepth, sps->getBitDepths().recon); -#else - m_cALF.create( pps->getPicWidthInLumaSamples(), pps->getPicHeightInLumaSamples(), sps->getChromaFormatIdc(), sps->getMaxCUWidth(), sps->getMaxCUHeight(), sps->getMaxCodingDepth(), sps->getBitDepths().recon ); -#endif } -#if JVET_Q0795_CCALF pSlice->m_ccAlfFilterControl[0] = m_cALF.getCcAlfControlIdc(COMPONENT_Cb); pSlice->m_ccAlfFilterControl[1] = m_cALF.getCcAlfControlIdc(COMPONENT_Cr); -#endif } else { @@ -1556,18 +1472,26 @@ void DecLib::xActivateParameterSets( const int layerId ) } xCheckParameterSetConstraints(layerId); } - void DecLib::xCheckParameterSetConstraints(const int layerId) { // Conformance checks Slice *slice = m_pcPic->slices[m_uiSliceSegmentIdx]; const SPS *sps = slice->getSPS(); const PPS *pps = slice->getPPS(); -#if JVET_Q0814_DPB const VPS *vps = slice->getVPS(); -#endif - -#if SPS_ID_CHECK + if (((vps!=nullptr)&&(vps->getVPSGeneralHrdParamsPresentFlag()))||(sps->getGeneralHrdParametersPresentFlag())) + { + if (((vps != nullptr) && (vps->getVPSGeneralHrdParamsPresentFlag())) && (sps->getGeneralHrdParametersPresentFlag())) + { + CHECK(!(*vps->getGeneralHrdParameters() == *sps->getGeneralHrdParameters()), "It is a requirement of bitstream conformance that the content of the general_hrd_parameters( ) syntax structure present in any VPSs or SPSs in the bitstream shall be identical"); + } + if (!m_isFirstGeneralHrd) + { + CHECK(!(m_prevGeneralHrdParams == (sps->getGeneralHrdParametersPresentFlag() ? *sps->getGeneralHrdParameters() : *vps->getGeneralHrdParameters())), "It is a requirement of bitstream conformance that the content of the general_hrd_parameters( ) syntax structure present in any VPSs or SPSs in the bitstream shall be identical"); + } + m_prevGeneralHrdParams = (sps->getGeneralHrdParametersPresentFlag() ? *sps->getGeneralHrdParameters() : *vps->getGeneralHrdParameters()); + } + m_isFirstGeneralHrd = false; static std::unordered_map<int, int> m_clvssSPSid; if( slice->isClvssPu() && m_bFirstSliceInPicture ) @@ -1576,11 +1500,8 @@ void DecLib::xCheckParameterSetConstraints(const int layerId) } CHECK( m_clvssSPSid[layerId] != pps->getSPSId(), "The value of pps_seq_parameter_set_id shall be the same in all PPSs that are referred to by coded pictures in a CLVS" ); -#endif -#if JVET_Q414_CONSTRAINT_ON_GDR_PIC_FLAG CHECK(sps->getGDREnabledFlag() == false && m_picHeader.getGdrPicFlag(), "When gdr_enabled_flag is equal to 0, the value of gdr_pic_flag shall be equal to 0 "); -#endif if( !sps->getUseWP() ) { CHECK( pps->getUseWP(), "When sps_weighted_pred_flag is equal to 0, the value of pps_weighted_pred_flag shall be equal to 0." ); @@ -1591,64 +1512,32 @@ void DecLib::xCheckParameterSetConstraints(const int layerId) CHECK( pps->getWPBiPred(), "When sps_weighted_bipred_flag is equal to 0, the value of pps_weighted_bipred_flag shall be equal to 0." ); } -#if JVET_Q0468_Q0469_MIN_LUMA_CB_AND_MIN_QT_FIX const int minCuSize = 1 << sps->getLog2MinCodingBlockSize(); CHECK( ( pps->getPicWidthInLumaSamples() % ( std::max( 8, minCuSize) ) ) != 0, "Coded frame width must be a multiple of Max(8, the minimum unit size)" ); CHECK( ( pps->getPicHeightInLumaSamples() % ( std::max( 8, minCuSize) ) ) != 0, "Coded frame height must be a multiple of Max(8, the minimum unit size)" ); -#else - CHECK( ( pps->getPicWidthInLumaSamples() % ( std::max( 8, int( sps->getMaxCUWidth() >> ( sps->getMaxCodingDepth() - 1 ) ) ) ) ) != 0, "Coded frame width must be a multiple of Max(8, the minimum unit size)" ); - CHECK( ( pps->getPicHeightInLumaSamples() % ( std::max( 8, int( sps->getMaxCUHeight() >> ( sps->getMaxCodingDepth() - 1 ) ) ) ) ) != 0, "Coded frame height must be a multiple of Max(8, the minimum unit size)" ); -#endif -#if JVET_Q0043_RPR_and_Subpics - if( !sps->getRprEnabledFlag() ) + if( !sps->getRprEnabledFlag() ) { CHECK( pps->getPicWidthInLumaSamples() != sps->getMaxPicWidthInLumaSamples(), "When res_change_in_clvs_allowed_flag equal to 0, the value of pic_width_in_luma_samples shall be equal to pic_width_max_in_luma_samples." ); CHECK( pps->getPicHeightInLumaSamples() != sps->getMaxPicHeightInLumaSamples(), "When res_change_in_clvs_allowed_flag equal to 0, the value of pic_height_in_luma_samples shall be equal to pic_height_max_in_luma_samples." ); } if( sps->getRprEnabledFlag() ) { -#if JVET_Q0119_CLEANUPS CHECK( sps->getSubPicInfoPresentFlag() != 0, "When res_change_in_clvs_allowed_flag is equal to 1, the value of subpic_info_present_flag shall be equal to 0." ); -#else - CHECK( sps->getSubPicPresentFlag() != 0, "When res_change_in_clvs_allowed_flag is equal to 1, the value of subpic_info_present_flag shall be equal to 0." ); -#endif - } -#if !JVET_Q0399_SCALING_INFERENCE - CHECK( !sps->getRprEnabledFlag() && pps->getScalingWindow().getWindowEnabledFlag(), "When res_change_in_clvs_allowed_flag is equal to 0, the value of scaling_window_flag shall be equal to 0." ); -#endif -#else - if( !sps->getRprEnabledFlag() && sps->getSubPicPresentFlag() ) - { - CHECK( pps->getPicWidthInLumaSamples() != sps->getMaxPicWidthInLumaSamples(), "When subpics_present_flag is equal to 1 or ref_pic_resampling_enabled_flag equal to 0, the value of pic_width_in_luma_samples shall be equal to pic_width_max_in_luma_samples." ); - CHECK( pps->getPicHeightInLumaSamples() != sps->getMaxPicHeightInLumaSamples(), "When subpics_present_flag is equal to 1 or ref_pic_resampling_enabled_flag equal to 0, the value of pic_height_in_luma_samples shall be equal to pic_height_max_in_luma_samples." ); } -#if !JVET_Q0399_SCALING_INFERENCE - CHECK( !sps->getRprEnabledFlag() && pps->getScalingWindow().getWindowEnabledFlag(), "When ref_pic_resampling_enabled_flag is equal to 0, the value of scaling_window_flag shall be equal to 0." ); -#endif -#endif -#if JVET_Q0417_CONSTRAINT_SPS_VB_PRESENT_FLAG -#if JVET_Q0246_VIRTUAL_BOUNDARY_ENABLE_FLAG - CHECK( sps->getRprEnabledFlag() && sps->getVirtualBoundariesEnabledFlag(), "when the value of res_change_in_clvs_allowed_flag is equal to 1, the value of sps_virtual_boundaries_present_flag shall be equal to 0" ); -#else - CHECK(sps->getRprEnabledFlag() && sps->getLoopFilterAcrossVirtualBoundariesDisabledFlag(), "when the value of res_change_in_clvs_allowed_flag is equal to 1, the value of sps_virtual_boundaries_present_flag shall be equal to 0"); -#endif -#endif + CHECK( sps->getRprEnabledFlag() && sps->getVirtualBoundariesPresentFlag(), "when the value of res_change_in_clvs_allowed_flag is equal to 1, the value of sps_virtual_boundaries_present_flag shall be equal to 0" ); if( sps->getCTUSize() + 2 * ( 1 << sps->getLog2MinCodingBlockSize() ) > pps->getPicWidthInLumaSamples() ) { CHECK( sps->getWrapAroundEnabledFlag(), "Wraparound shall be disabled when the value of ( CtbSizeY / MinCbSizeY + 1) is less than or equal to ( pic_width_in_luma_samples / MinCbSizeY - 1 )" ); } -#if JVET_Q0814_DPB if( vps != nullptr && vps->m_numOutputLayersInOls[vps->m_targetOlsIdx] > 1 ) { CHECK( sps->getMaxPicWidthInLumaSamples() > vps->getOlsDpbPicSize( vps->m_targetOlsIdx ).width, "pic_width_max_in_luma_samples shall be less than or equal to the value of ols_dpb_pic_width[ i ]" ); CHECK( sps->getMaxPicHeightInLumaSamples() > vps->getOlsDpbPicSize( vps->m_targetOlsIdx ).height, "pic_height_max_in_luma_samples shall be less than or equal to the value of ols_dpb_pic_height[ i ]" ); } -#endif -#if JVET_Q0172_CHROMA_FORMAT_BITDEPTH_CONSTRAINT static std::unordered_map<int, int> m_layerChromaFormat; static std::unordered_map<int, int> m_layerBitDepth; @@ -1658,11 +1547,7 @@ void DecLib::xCheckParameterSetConstraints(const int layerId) int curLayerChromaFormat = sps->getChromaFormatIdc(); int curLayerBitDepth = sps->getBitDepth(CHANNEL_TYPE_LUMA); -#if SPS_ID_CHECK if( slice->isClvssPu() && m_bFirstSliceInPicture ) -#else - if (m_layerBitDepth[curLayerIdx] == 0) -#endif { m_layerChromaFormat[curLayerIdx] = curLayerChromaFormat; m_layerBitDepth[curLayerIdx] = curLayerBitDepth; @@ -1684,9 +1569,7 @@ void DecLib::xCheckParameterSetConstraints(const int layerId) } } } -#endif -#if JVET_Q0114_CONSTRAINT_FLAGS if (sps->getProfileTierLevel()->getConstraintInfo()->getOneTilePerPicConstraintFlag()) { CHECK(pps->getNumTiles() != 1, "When one_tile_per_pic_constraint_flag is equal to 1, each picture shall contain only one tile"); @@ -1695,9 +1578,7 @@ void DecLib::xCheckParameterSetConstraints(const int layerId) { CHECK( pps->getNumSlicesInPic() != 1, "When one_slice_per_pic_constraint_flag is equal to 1, each picture shall contain only one slice"); } -#endif -#if JVET_Q0260_CONFORMANCE_WINDOW_IN_SPS if (sps->getMaxPicWidthInLumaSamples() == pps->getPicWidthInLumaSamples() && sps->getMaxPicHeightInLumaSamples() == pps->getPicHeightInLumaSamples()) { @@ -1708,8 +1589,6 @@ void DecLib::xCheckParameterSetConstraints(const int layerId) CHECK(spsConfWin.getWindowTopOffset() != ppsConfWin.getWindowTopOffset(), "When picture size is equal to maximum picutre size, conformance window top offset in SPS and PPS shall be equal"); CHECK(spsConfWin.getWindowBottomOffset() != ppsConfWin.getWindowBottomOffset(), "When picture size is equal to maximum picutre size, conformance window bottom offset in SPS and PPS shall be equal"); } -#endif -#if JVET_Q0355_DCI_LEVEL_IDC_CONSTRAINT int levelIdcSps = int(sps->getProfileTierLevel()->getLevelIdc()); int maxLevelIdxDci = 0; if (m_dci) @@ -1723,13 +1602,12 @@ void DecLib::xCheckParameterSetConstraints(const int layerId) } CHECK(levelIdcSps > maxLevelIdxDci, "max level signaled in the DCI shall not be less than the level signaled in the SPS"); } -#endif -#if JVET_Q0157_SUBPICTURE_REORDERING_CONSTRAINT +#if !JVET_R0276_REORDERED_SUBPICS // When the current picture is not the first picture of the CLVS, if the value of SubpicId[ i ] is not equal to the value of SubpicId[ i ] of previous picture in decoding order in the same layer, // the nal_unit_type for all coded slice NAL units of the the subpicture with subpicture index i shall be in the range of IDR_W_RADL to CRA_NUT, inclusive. if( sps->getSubPicInfoPresentFlag() ) - { + { static std::unordered_map<int, std::vector<int>> previousSubPicIds; if( m_firstSliceInSequence[layerId] ) @@ -1762,12 +1640,28 @@ void DecLib::xCheckParameterSetConstraints(const int layerId) // store PPS ID to have sub-picture info for the next pictures when last rectangular slice in the picture is encountered if( slice->getSliceID() + 1 == pps->getNumSlicesInPic() ) { + previousSubPicIds[layerId].clear(); for( int subPicIdx = 0; subPicIdx < sps->getNumSubPics(); subPicIdx++ ) { previousSubPicIds[layerId].push_back( pps->getSubPic( subPicIdx ).getSubPicID() ); } } - } + } + } +#endif + +#if JVET_R0278_CONSTRAINT + if( slice->getPicHeader()->getGdrOrIrapPicFlag() && !slice->getPicHeader()->getGdrPicFlag() && ( !vps || vps->getIndependentLayerFlag( vps->getGeneralLayerIdx( layerId ) ) ) ) + { + CHECK( slice->getPicHeader()->getPicInterSliceAllowedFlag(), + "When gdr_or_irap_pic_flag is equal to 1 and gdr_pic_flag is equal to 0 and vps_independent_layer_flag[ GeneralLayerIdx[ nuh_layer_id ] ] is equal to 1, ph_inter_slice_allowed_flag shall be equal to 0" ); + } +#endif + +#if JVET_R0275_SPS_PTL_DBP_HRD + if( sps->getVPSId() && vps->m_numLayersInOls[vps->m_targetOlsIdx] == 1 ) + { + CHECK( !sps->getPtlDpbHrdParamsPresentFlag(), "When sps_video_parameter_set_id is greater than 0 and there is an OLS that contains only one layer with nuh_layer_id equal to the nuh_layer_id of the SPS, the value of sps_ptl_dpb_hrd_params_present_flag shall be equal to 1" ); } #endif } @@ -1790,17 +1684,11 @@ void DecLib::xParsePrefixSEImessages() while (!m_prefixSEINALUs.empty()) { InputNALUnit &nalu=*m_prefixSEINALUs.front(); -#if JVET_P0125_ASPECT_TID_LAYER_ID_NUH m_accessUnitSeiTids.push_back(nalu.m_temporalId); -#endif -#if JVET_P0125_SEI_CONSTRAINTS const SPS *sps = m_parameterSetManager.getActiveSPS(); const VPS *vps = m_parameterSetManager.getVPS(sps->getVPSId()); m_seiReader.parseSEImessage( &(nalu.getBitstream()), m_SEIs, nalu.m_nalUnitType, nalu.m_nuhLayerId, nalu.m_temporalId, vps, sps, m_HRD, m_pDecodedSEIOutputStream ); m_accessUnitSeiPayLoadTypes.push_back(std::tuple<NalUnitType, int, SEI::PayloadType>(nalu.m_nalUnitType, nalu.m_nuhLayerId, m_SEIs.back()->payloadType())); -#else - m_seiReader.parseSEImessage( &(nalu.getBitstream()), m_SEIs, nalu.m_nalUnitType, nalu.m_temporalId, m_parameterSetManager.getActiveSPS(), m_HRD, m_pDecodedSEIOutputStream ); -#endif delete m_prefixSEINALUs.front(); m_prefixSEINALUs.pop_front(); } @@ -1809,22 +1697,12 @@ void DecLib::xParsePrefixSEImessages() void DecLib::xDecodePicHeader( InputNALUnit& nalu ) { m_HLSReader.setBitstream( &nalu.getBitstream() ); -#if JVET_Q0775_PH_IN_SH m_HLSReader.parsePictureHeader( &m_picHeader, &m_parameterSetManager, true ); -#else - m_HLSReader.parsePictureHeader( &m_picHeader, &m_parameterSetManager); -#endif m_picHeader.setValid(); } bool DecLib::xDecodeSlice(InputNALUnit &nalu, int &iSkipFrame, int iPOCLastDisplay ) { -#if !JVET_Q0775_PH_IN_SH - if(m_picHeader.isValid() == false) - { - return false; - } -#endif m_apcSlicePilot->setPicHeader( &m_picHeader ); m_apcSlicePilot->initSlice(); // the slice pilot is an object to prepare for a new slice // it is not associated with picture, sps or pps structures. @@ -1842,28 +1720,17 @@ bool DecLib::xDecodeSlice(InputNALUnit &nalu, int &iSkipFrame, int iPOCLastDispl } m_apcSlicePilot->setNalUnitType(nalu.m_nalUnitType); -#if JVET_Q0118_CLEANUPS m_apcSlicePilot->setNalUnitLayerId(nalu.m_nuhLayerId); -#endif m_apcSlicePilot->setTLayer(nalu.m_temporalId); for( auto& naluTemporalId : m_accessUnitNals ) { -#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 - && 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" ); @@ -1876,29 +1743,22 @@ bool DecLib::xDecodeSlice(InputNALUnit &nalu, int &iSkipFrame, int iPOCLastDispl } m_HLSReader.setBitstream( &nalu.getBitstream() ); -#if JVET_Q0795_CCALF m_apcSlicePilot->m_ccAlfFilterParam = m_cALF.getCcAlfFilterParam(); -#endif m_HLSReader.parseSliceHeader( m_apcSlicePilot, &m_picHeader, &m_parameterSetManager, m_prevTid0POC ); -#if JVET_P0101_POC_MULTILAYER || JVET_P0097_REMOVE_VPS_DEP_NONSCALABLE_LAYER PPS *pps = m_parameterSetManager.getPPS(m_picHeader.getPPSId()); CHECK(pps == 0, "No PPS present"); SPS *sps = m_parameterSetManager.getSPS(pps->getSPSId()); CHECK(sps == 0, "No SPS present"); VPS *vps = m_parameterSetManager.getVPS(sps->getVPSId()); -#endif -#if JVET_Q0237_STSA_TID_ZERO_DEPLAYER - if (nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_STSA && vps != nullptr && (vps->getIndependentLayerFlag(nalu.m_nuhLayerId) == 1)) + if (nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_STSA && vps != nullptr && (vps->getIndependentLayerFlag(vps->getGeneralLayerIdx(nalu.m_nuhLayerId)) == 1)) { CHECK(nalu.m_temporalId == 0, "TemporalID of STSA picture shall not be zero in independent layers"); } -#endif -#if JVET_Q0044_SLICE_IDX_WITH_SUBPICS int currSubPicIdx = pps->getSubPicIdxFromSubPicId( m_apcSlicePilot->getSliceSubPicId() ); int currSliceAddr = m_apcSlicePilot->getSliceID(); for(int sp = 0; sp < currSubPicIdx; sp++) @@ -1913,31 +1773,23 @@ bool DecLib::xDecodeSlice(InputNALUnit &nalu, int &iSkipFrame, int iPOCLastDispl } if( currSubPicIdx > m_maxDecSubPicIdx ) { - m_maxDecSubPicIdx = currSubPicIdx; + m_maxDecSubPicIdx = currSubPicIdx; m_maxDecSliceAddrInSubPic = currSliceAddr; } -#endif -#if JVET_P0097_REMOVE_VPS_DEP_NONSCALABLE_LAYER if ((sps->getVPSId() == 0) && (m_prevLayerID != MAX_INT)) { CHECK(m_prevLayerID != nalu.m_nuhLayerId, "All VCL NAL unit in the CVS shall have the same value of nuh_layer_id " "when sps_video_parameter_set_id is equal to 0"); } -#endif -#if JVET_P0101_POC_MULTILAYER CHECK((sps->getVPSId() > 0) && (vps == 0), "Invalid VPS"); - if (vps != nullptr && (vps->getIndependentLayerFlag(nalu.m_nuhLayerId) == 0)) + if (vps != nullptr && (vps->getIndependentLayerFlag(nalu.m_nuhLayerId) == 0)) { bool pocIsSet = false; for(auto auNALit=m_accessUnitPicInfo.begin(); auNALit != m_accessUnitPicInfo.end();auNALit++) - { + { for (int iRefIdx = 0; iRefIdx < m_apcSlicePilot->getNumRefIdx(REF_PIC_LIST_0) && !pocIsSet; iRefIdx++) { -#if JVET_Q0819_PH_CHANGES if (m_apcSlicePilot->getRefPic(REF_PIC_LIST_0, iRefIdx) && m_apcSlicePilot->getRefPic(REF_PIC_LIST_0, iRefIdx)->getPOC() == (*auNALit).m_POC) -#else - if (m_apcSlicePilot->getRefPic(REF_PIC_LIST_0, iRefIdx)->getPOC() == (*auNALit).m_POC) -#endif { m_apcSlicePilot->setPOC(m_apcSlicePilot->getRefPic(REF_PIC_LIST_0, iRefIdx)->getPOC()); pocIsSet = true; @@ -1945,11 +1797,7 @@ bool DecLib::xDecodeSlice(InputNALUnit &nalu, int &iSkipFrame, int iPOCLastDispl } for (int iRefIdx = 0; iRefIdx < m_apcSlicePilot->getNumRefIdx(REF_PIC_LIST_1) && !pocIsSet; iRefIdx++) { -#if JVET_Q0819_PH_CHANGES if (m_apcSlicePilot->getRefPic(REF_PIC_LIST_1, iRefIdx) && m_apcSlicePilot->getRefPic(REF_PIC_LIST_1, iRefIdx)->getPOC() == (*auNALit).m_POC) -#else - if (m_apcSlicePilot->getRefPic(REF_PIC_LIST_1, iRefIdx)->getPOC() == (*auNALit).m_POC) -#endif { m_apcSlicePilot->setPOC(m_apcSlicePilot->getRefPic(REF_PIC_LIST_1, iRefIdx)->getPOC()); pocIsSet = true; @@ -1957,7 +1805,6 @@ bool DecLib::xDecodeSlice(InputNALUnit &nalu, int &iSkipFrame, int iPOCLastDispl } } } -#endif // update independent slice index uint32_t uiIndependentSliceIdx = 0; @@ -1969,12 +1816,6 @@ bool DecLib::xDecodeSlice(InputNALUnit &nalu, int &iSkipFrame, int iPOCLastDispl m_apcSlicePilot->setIndependentSliceIdx(uiIndependentSliceIdx); #if K0149_BLOCK_STATISTICS -#if !JVET_P0101_POC_MULTILAYER - PPS *pps = m_parameterSetManager.getPPS(m_picHeader.getPPSId()); - CHECK(pps == 0, "No PPS present"); - SPS *sps = m_parameterSetManager.getSPS(pps->getSPSId()); - CHECK(sps == 0, "No SPS present"); -#endif writeBlockStatisticsHeader(sps); #endif @@ -1994,7 +1835,6 @@ bool DecLib::xDecodeSlice(InputNALUnit &nalu, int &iSkipFrame, int iPOCLastDispl m_apcSlicePilot->setAssociatedIRAPPOC(m_pocCRA); m_apcSlicePilot->setAssociatedIRAPType(m_associatedIRAPType); -#if SPS_ID_CHECK if( m_apcSlicePilot->getRapPicFlag() || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_GDR ) { // Derive NoOutputBeforeRecoveryFlag @@ -2017,41 +1857,12 @@ bool DecLib::xDecodeSlice(InputNALUnit &nalu, int &iSkipFrame, int iPOCLastDispl m_picHeader.setNoOutputBeforeRecoveryFlag( m_picHeader.getHandleGdrAsCvsStartFlag() ); } } -#else - //For inference of NoOutputOfPriorPicsFlag - if (m_apcSlicePilot->getRapPicFlag() || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_GDR) - { -#if JVET_P0125_EOS_LAYER_SPECIFIC - if ((m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA && m_bFirstSliceInSequence[nalu.m_nuhLayerId]) || - (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA && m_apcSlicePilot->getHandleCraAsCvsStartFlag()) || - (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_GDR && m_bFirstSliceInSequence[nalu.m_nuhLayerId])) -#else - if ((m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA && m_bFirstSliceInSequence) || - (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA && m_apcSlicePilot->getHandleCraAsCvsStartFlag()) || - (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_GDR && m_bFirstSliceInSequence)) -#endif - { - m_apcSlicePilot->setNoIncorrectPicOutputFlag(true); - } -#endif //the inference for NoOutputOfPriorPicsFlag -#if SPS_ID_CHECK if( !m_firstSliceInBitstream && m_picHeader.getNoOutputBeforeRecoveryFlag() ) { m_picHeader.setNoOutputOfPriorPicsFlag( true ); } -#else - if( !m_firstSliceInBitstream && - ( m_apcSlicePilot->getRapPicFlag() || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_GDR ) && - m_apcSlicePilot->getNoIncorrectPicOutputFlag()) - { - if (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_GDR) - { - m_picHeader.setNoOutputOfPriorPicsFlag(true); - } - } -#endif else { m_picHeader.setNoOutputOfPriorPicsFlag(false); @@ -2059,13 +1870,8 @@ bool DecLib::xDecodeSlice(InputNALUnit &nalu, int &iSkipFrame, int iPOCLastDispl if (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_GDR) { -#if SPS_ID_CHECK m_lastNoOutputBeforeRecoveryFlag = m_picHeader.getNoOutputBeforeRecoveryFlag(); -#else - m_lastNoIncorrectPicOutputFlag = m_apcSlicePilot->getNoIncorrectPicOutputFlag(); -#endif } -#if SPS_ID_CHECK if( m_picHeader.getNoOutputOfPriorPicsFlag() ) { @@ -2077,37 +1883,16 @@ bool DecLib::xDecodeSlice(InputNALUnit &nalu, int &iSkipFrame, int iPOCLastDispl m_isNoOutputPriorPics = false; } } -#else - } - if ((m_apcSlicePilot->getRapPicFlag() || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_GDR) && m_picHeader.getNoOutputOfPriorPicsFlag()) - { - m_lastPOCNoOutputPriorPics = m_apcSlicePilot->getPOC(); - m_isNoOutputPriorPics = true; - } - else - { - m_isNoOutputPriorPics = false; - } -#endif //For inference of PicOutputFlag -#if SPS_ID_CHECK if( !pps->getMixedNaluTypesInPicFlag() && ( m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL ) ) -#else - if (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL) -#endif { -#if SPS_ID_CHECK if( m_lastNoOutputBeforeRecoveryFlag ) -#else - if (m_lastNoIncorrectPicOutputFlag) -#endif { m_picHeader.setPicOutputFlag(false); } } -#if JVET_P0288_PIC_OUTPUT { PPS *pps = m_parameterSetManager.getPPS(m_picHeader.getPPSId()); CHECK(pps == 0, "No PPS present"); @@ -2123,35 +1908,21 @@ bool DecLib::xDecodeSlice(InputNALUnit &nalu, int &iSkipFrame, int iPOCLastDispl } } } -#endif -#if SPS_ID_CHECK //Reset POC MSB when CRA or GDR has NoOutputBeforeRecoveryFlag equal to 1 if( !pps->getMixedNaluTypesInPicFlag() && ( m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_GDR ) && m_lastNoOutputBeforeRecoveryFlag ) -#else - if( ( m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_GDR ) && - m_lastNoIncorrectPicOutputFlag) //Reset POC MSB when CRA or GDR has NoIncorrectPicOutputFlag equal to 1 -#endif { -#if !JVET_P0101_POC_MULTILAYER - PPS *pps = m_parameterSetManager.getPPS(m_picHeader.getPPSId()); - CHECK(pps == 0, "No PPS present"); - SPS *sps = m_parameterSetManager.getSPS(pps->getSPSId()); - CHECK(sps == 0, "No SPS present"); -#endif int iMaxPOClsb = 1 << sps->getBitsForPOC(); m_apcSlicePilot->setPOC( m_apcSlicePilot->getPOC() & (iMaxPOClsb - 1) ); xUpdatePreviousTid0POC(m_apcSlicePilot); } -#if JVET_P0101_POC_MULTILAYER AccessUnitPicInfo picInfo; picInfo.m_nalUnitType = nalu.m_nalUnitType; picInfo.m_nuhLayerId = nalu.m_nuhLayerId; picInfo.m_temporalId = nalu.m_temporalId; picInfo.m_POC = m_apcSlicePilot->getPOC(); m_accessUnitPicInfo.push_back(picInfo); -#endif // Skip pictures due to random access @@ -2167,11 +1938,7 @@ bool DecLib::xDecodeSlice(InputNALUnit &nalu, int &iSkipFrame, int iPOCLastDispl m_prevSliceSkipped = false; //we should only get a different poc for a new picture (with CTU address==0) -#if JVET_P0125_EOS_LAYER_SPECIFIC if (m_apcSlicePilot->getPOC() != m_prevPOC && !m_firstSliceInSequence[nalu.m_nuhLayerId] && (m_apcSlicePilot->getFirstCtuRsAddrInSlice() != 0)) -#else - if(m_apcSlicePilot->getPOC() != m_prevPOC && !m_bFirstSliceInSequence && (m_apcSlicePilot->getFirstCtuRsAddrInSlice() != 0)) -#endif { msg( WARNING, "Warning, the first slice of a picture might have been lost!\n"); } @@ -2199,11 +1966,7 @@ bool DecLib::xDecodeSlice(InputNALUnit &nalu, int &iSkipFrame, int iPOCLastDispl int refPicIndex; while ((lostPoc = m_apcSlicePilot->checkThatAllRefPicsAreAvailable(m_cListPic, m_apcSlicePilot->getRPL0(), 0, true, &refPicIndex, m_apcSlicePilot->getNumRefIdx(REF_PIC_LIST_0))) > 0) { -#if SPS_ID_CHECK if( !pps->getMixedNaluTypesInPicFlag() && ( m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_GDR || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA ) && m_picHeader.getNoOutputBeforeRecoveryFlag() ) -#else - if ( ( (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_GDR) || (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA) ) && m_apcSlicePilot->getNoIncorrectPicOutputFlag() ) -#endif { if (m_apcSlicePilot->getRPL0()->isInterLayerRefPic(refPicIndex) == 0) { @@ -2217,11 +1980,7 @@ bool DecLib::xDecodeSlice(InputNALUnit &nalu, int &iSkipFrame, int iPOCLastDispl } while ((lostPoc = m_apcSlicePilot->checkThatAllRefPicsAreAvailable(m_cListPic, m_apcSlicePilot->getRPL1(), 0, true, &refPicIndex, m_apcSlicePilot->getNumRefIdx(REF_PIC_LIST_1))) > 0) { -#if SPS_ID_CHECK if( !pps->getMixedNaluTypesInPicFlag() && ( m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_GDR || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA ) && m_picHeader.getNoOutputBeforeRecoveryFlag() ) -#else - if (((m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_GDR) || (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA)) && m_apcSlicePilot->getNoIncorrectPicOutputFlag()) -#endif { if (m_apcSlicePilot->getRPL1()->isInterLayerRefPic(refPicIndex) == 0) { @@ -2245,11 +2004,7 @@ bool DecLib::xDecodeSlice(InputNALUnit &nalu, int &iSkipFrame, int iPOCLastDispl // actual decoding starts here xActivateParameterSets( nalu.m_nuhLayerId ); -#if JVET_P0125_EOS_LAYER_SPECIFIC m_firstSliceInSequence[nalu.m_nuhLayerId] = false; -#else - m_bFirstSliceInSequence = false; -#endif m_firstSliceInBitstream = false; Slice* pcSlice = m_pcPic->slices[m_uiSliceSegmentIdx]; @@ -2262,7 +2017,6 @@ bool DecLib::xDecodeSlice(InputNALUnit &nalu, int &iSkipFrame, int iPOCLastDispl m_pcPic->subLayerNonReferencePictureDueToSTSA = false; -#if JVET_P0978_RPL_RESTRICTIONS if (m_bFirstSliceInPicture) { m_pcPic->setDecodingOrderNumber(m_decodingOrderCounter); @@ -2270,17 +2024,57 @@ bool DecLib::xDecodeSlice(InputNALUnit &nalu, int &iSkipFrame, int iPOCLastDispl m_pcPic->setPictureType(nalu.m_nalUnitType); } pcSlice->checkCRA(pcSlice->getRPL0(), pcSlice->getRPL1(), m_pocCRA, m_cListPic); -#else - pcSlice->checkCRA(pcSlice->getRPL0(), pcSlice->getRPL1(), m_pocCRA, m_associatedIRAPType, m_cListPic); -#endif pcSlice->constructRefPicList(m_cListPic); -#if JVET_P0978_RPL_RESTRICTIONS pcSlice->checkRPL(pcSlice->getRPL0(), pcSlice->getRPL1(), m_associatedIRAPDecodingOrderNumber, m_cListPic); -#endif pcSlice->checkSTSA(m_cListPic); pcSlice->scaleRefPicList( scaledRefPic, m_pcPic->cs->picHeader, m_parameterSetManager.getAPSs(), m_picHeader.getLmcsAPS(), m_picHeader.getScalingListAPS(), true ); +#if JVET_R0276_REORDERED_SUBPICS + // For each value of i in the range of 0 to sps_num_subpics_minus1, inclusive, when the value of SubpicIdVal[ i ] of a current picture is not equal to the value of SubpicIdVal[ i ] of a reference picture, + // the active entries of the RPLs of the coded slices in the i-th subpicture of the current picture shall not include that reference picture. + + if( sps->getSubPicInfoPresentFlag() ) + { + // store sub-picture IDs with a picture + if( m_bFirstSliceInPicture ) + { + pcSlice->getPic()->subPicIDs.clear(); + for( int subPicIdx = 0; subPicIdx < sps->getNumSubPics(); subPicIdx++ ) + { + pcSlice->getPic()->subPicIDs.push_back( pps->getSubPic( subPicIdx ).getSubPicID() ); + } + } + + if( !pcSlice->isIntra() ) + { + int currentSubPicIdx = NOT_VALID; + + // derive sub-picture index for a slice + for( int subPicIdx = 0; subPicIdx < sps->getNumSubPics(); subPicIdx++ ) + { + if( pps->getSubPic( subPicIdx ).getSubPicID() == pcSlice->getSliceSubPicId() ) + { + currentSubPicIdx = subPicIdx; + break; + } + } + + CHECK( currentSubPicIdx == NOT_VALID, "Sub-picture was not found" ); + + // check collocated sub-picture ID of each active reference picture + for( int refPicList = 0; refPicList < NUM_REF_PIC_LIST_01; refPicList++ ) + { + for( int refIdx = 0; refIdx < pcSlice->getNumRefIdx( RefPicList( refPicList ) ); refIdx++ ) + { + CHECK( currentSubPicIdx >= pcSlice->getRefPic( RefPicList( refPicList ), refIdx )->subPicIDs.size(), "Number of sub-pictures in a reference picture is less then the current slice sub-picture index" ); + CHECK( pcSlice->getRefPic( RefPicList( refPicList ), refIdx )->subPicIDs[currentSubPicIdx] != pcSlice->getSliceSubPicId(), "A picture with different sub-picture ID of the collocated sub-picture cannot be used as an active reference picture" ); + } + } + } + } +#endif + if (!pcSlice->isIntra()) { bool bLowDelay = true; @@ -2393,7 +2187,6 @@ bool DecLib::xDecodeSlice(InputNALUnit &nalu, int &iSkipFrame, int iPOCLastDispl //--------------- pcSlice->setRefPOCList(); -#if JVET_P0124_MIXED_NALU NalUnitInfo naluInfo; naluInfo.m_nalUnitType = nalu.m_nalUnitType; naluInfo.m_nuhLayerId = nalu.m_nuhLayerId; @@ -2401,7 +2194,6 @@ bool DecLib::xDecodeSlice(InputNALUnit &nalu, int &iSkipFrame, int iPOCLastDispl naluInfo.m_POC = pcSlice->getPOC(); xCheckMixedNalUnit(pcSlice, sps, nalu); m_nalUnitInfo[naluInfo.m_nuhLayerId].push_back(naluInfo); -#endif SEIMessages drapSEIs = getSeisByType(m_pcPic->SEIs, SEI::DEPENDENT_RAP_INDICATION ); if (!drapSEIs.empty()) { @@ -2413,7 +2205,6 @@ bool DecLib::xDecodeSlice(InputNALUnit &nalu, int &iSkipFrame, int iPOCLastDispl Quant *quant = m_cTrQuant.getQuant(); -#if JVET_Q0346_SCALING_LIST_USED_IN_SH if (pcSlice->getExplicitScalingListUsed()) { APS* scalingListAPS = pcSlice->getPicHeader()->getScalingListAPS(); @@ -2421,29 +2212,6 @@ bool DecLib::xDecodeSlice(InputNALUnit &nalu, int &iSkipFrame, int iPOCLastDispl quant->setScalingListDec(scalingList); quant->setUseScalingList(true); } -#else - if( pcSlice->getSPS()->getScalingListFlag() ) - { - ScalingList scalingList; - if( pcSlice->getPicHeader()->getScalingListPresentFlag() ) - { - APS* scalingListAPS = pcSlice->getPicHeader()->getScalingListAPS(); - scalingList = scalingListAPS->getScalingList(); - } - else - { - scalingList.setDefaultScalingList(); - } - int scalingListAPSId = pcSlice->getPicHeader()->getScalingListAPSId(); - if (getScalingListUpdateFlag() || (scalingListAPSId != getPreScalingListAPSId())) - { - quant->setScalingListDec(scalingList); - setScalingListUpdateFlag(false); - setPreScalingListAPSId(scalingListAPSId); - } - quant->setUseScalingList( true ); - } -#endif else { quant->setUseScalingList( false ); @@ -2453,11 +2221,7 @@ bool DecLib::xDecodeSlice(InputNALUnit &nalu, int &iSkipFrame, int iPOCLastDispl { if (m_bFirstSliceInPicture) m_sliceLmcsApsId = -1; -#if JVET_Q0346_LMCS_ENABLE_IN_SH if (pcSlice->getLmcsEnabledFlag()) -#else - if (pcSlice->getPicHeader()->getLmcsEnabledFlag()) -#endif { APS* lmcsAPS = pcSlice->getPicHeader()->getLmcsAPS(); if (m_sliceLmcsApsId == -1) @@ -2475,11 +2239,7 @@ bool DecLib::xDecodeSlice(InputNALUnit &nalu, int &iSkipFrame, int iPOCLastDispl memcpy(tInfo.reshaperModelBinCWDelta, sInfo.reshaperModelBinCWDelta, sizeof(int)*(PIC_CODE_CW_BINS)); tInfo.maxNbitsNeededDeltaCW = sInfo.maxNbitsNeededDeltaCW; tInfo.chrResScalingOffset = sInfo.chrResScalingOffset; -#if JVET_Q0346_LMCS_ENABLE_IN_SH tInfo.setUseSliceReshaper(pcSlice->getLmcsEnabledFlag()); -#else - tInfo.setUseSliceReshaper(pcSlice->getPicHeader()->getLmcsEnabledFlag()); -#endif tInfo.setSliceReshapeChromaAdj(pcSlice->getPicHeader()->getLmcsChromaResidualScaleFlag()); tInfo.setSliceReshapeModelPresentFlag(true); } @@ -2490,11 +2250,7 @@ bool DecLib::xDecodeSlice(InputNALUnit &nalu, int &iSkipFrame, int iPOCLastDispl tInfo.setSliceReshapeChromaAdj(false); tInfo.setSliceReshapeModelPresentFlag(false); } -#if JVET_Q0346_LMCS_ENABLE_IN_SH if (pcSlice->getLmcsEnabledFlag()) -#else - if (pcSlice->getPicHeader()->getLmcsEnabledFlag()) -#endif { m_cReshaper.constructReshaper(); } @@ -2539,7 +2295,6 @@ bool DecLib::xDecodeSlice(InputNALUnit &nalu, int &iSkipFrame, int iPOCLastDispl return false; } -#if JVET_P0978_RPL_RESTRICTIONS void DecLib::updateAssociatedIRAP() { const NalUnitType pictureType = m_pcPic->getPictureType(); @@ -2550,7 +2305,6 @@ void DecLib::updateAssociatedIRAP() m_associatedIRAPType = pictureType; } } -#endif void DecLib::xDecodeVPS( InputNALUnit& nalu ) { @@ -2563,7 +2317,6 @@ void DecLib::xDecodeVPS( InputNALUnit& nalu ) m_parameterSetManager.storeVPS( m_vps, nalu.getBitstream().getFifo()); } -#if JVET_Q0117_PARAMETER_SETS_CLEANUP void DecLib::xDecodeDCI(InputNALUnit& nalu) { m_HLSReader.setBitstream(&nalu.getBitstream()); @@ -2581,18 +2334,6 @@ void DecLib::xDecodeDCI(InputNALUnit& nalu) CHECK( !m_dci->IsIndenticalDCI(dupDCI), "Two signaled DCIs are different"); } } -#else -void DecLib::xDecodeDPS( InputNALUnit& nalu ) -{ - DPS* dps = new DPS(); - m_HLSReader.setBitstream( &nalu.getBitstream() ); - - CHECK( nalu.m_temporalId, "The value of TemporalId of DPS NAL units shall be equal to 0" ); - - m_HLSReader.parseDPS( dps ); - m_parameterSetManager.storeDPS( dps, nalu.getBitstream().getFifo() ); -} -#endif void DecLib::xDecodeSPS( InputNALUnit& nalu ) { @@ -2623,46 +2364,33 @@ void DecLib::xDecodeAPS(InputNALUnit& nalu) m_HLSReader.parseAPS(aps); aps->setTemporalId(nalu.m_temporalId); aps->setLayerId( nalu.m_nuhLayerId ); - m_parameterSetManager.checkAuApsContent( aps, m_accessUnitApsNals ); -#if !JVET_Q0346_SCALING_LIST_USED_IN_SH - if (aps->getAPSType() == SCALING_LIST_APS) - { - setScalingListUpdateFlag(true); - } +#if JVET_R0201_PREFIX_SUFFIX_APS_CLEANUP + aps->setHasPrefixNalUnitType( nalu.m_nalUnitType == NAL_UNIT_PREFIX_APS ); #endif + m_parameterSetManager.checkAuApsContent( aps, m_accessUnitApsNals ); // aps will be deleted if it was already stored (and did not changed), // thus, storing it must be last action. m_parameterSetManager.storeAPS(aps, nalu.getBitstream().getFifo()); } -#if JVET_P0288_PIC_OUTPUT bool DecLib::decode(InputNALUnit& nalu, int& iSkipFrame, int& iPOCLastDisplay, int iTargetOlsIdx) -#else -bool DecLib::decode(InputNALUnit& nalu, int& iSkipFrame, int& iPOCLastDisplay) -#endif { bool ret; // ignore all NAL units of layers > 0 m_accessUnitNals.push_back( std::pair<NalUnitType, int>( nalu.m_nalUnitType, nalu.m_temporalId ) ); - +#if JVET_R0201_PREFIX_SUFFIX_APS_CLEANUP + m_pictureUnitNals.push_back( nalu.m_nalUnitType ); +#endif switch (nalu.m_nalUnitType) { case NAL_UNIT_VPS: xDecodeVPS( nalu ); -#if JVET_P0288_PIC_OUTPUT m_vps->m_targetOlsIdx = iTargetOlsIdx; -#endif return false; -#if JVET_Q0117_PARAMETER_SETS_CLEANUP case NAL_UNIT_DCI: xDecodeDCI( nalu ); return false; -#else - case NAL_UNIT_DPS: - xDecodeDPS( nalu ); - return false; -#endif case NAL_UNIT_SPS: xDecodeSPS( nalu ); return false; @@ -2694,17 +2422,11 @@ bool DecLib::decode(InputNALUnit& nalu, int& iSkipFrame, int& iPOCLastDisplay) #if JVET_Q0488_SEI_REPETITION_CONSTRAINT m_pictureSeiNalus.push_back(new InputNALUnit(nalu)); #endif -#if JVET_P0125_ASPECT_TID_LAYER_ID_NUH m_accessUnitSeiTids.push_back(nalu.m_temporalId); -#endif -#if JVET_P0125_SEI_CONSTRAINTS const SPS *sps = m_parameterSetManager.getActiveSPS(); const VPS *vps = m_parameterSetManager.getVPS(sps->getVPSId()); m_seiReader.parseSEImessage( &(nalu.getBitstream()), m_pcPic->SEIs, nalu.m_nalUnitType, nalu.m_nuhLayerId, nalu.m_temporalId, vps, sps, m_HRD, m_pDecodedSEIOutputStream ); m_accessUnitSeiPayLoadTypes.push_back(std::tuple<NalUnitType, int, SEI::PayloadType>(nalu.m_nalUnitType, nalu.m_nuhLayerId, m_pcPic->SEIs.back()->payloadType())); -#else - m_seiReader.parseSEImessage( &(nalu.getBitstream()), m_pcPic->SEIs, nalu.m_nalUnitType, nalu.m_temporalId, m_parameterSetManager.getActiveSPS(), m_HRD, m_pDecodedSEIOutputStream ); -#endif } else { @@ -2826,18 +2548,6 @@ void DecLib::checkNalUnitConstraints( uint32_t naluType ) xCheckNalUnitConstraintFlags( cInfo, naluType ); } -#if !JVET_Q0117_PARAMETER_SETS_CLEANUP - if (m_parameterSetManager.getActiveDPS() != NULL) - { - const DPS *dps = m_parameterSetManager.getActiveDPS(); - for (int i=0; i< dps->getNumPTLs(); i++) - { - ProfileTierLevel ptl = dps->getProfileTierLevel(i); - const ConstraintInfo *cInfo = ptl.getConstraintInfo(); - xCheckNalUnitConstraintFlags( cInfo, naluType ); - } - } -#endif } void DecLib::xCheckNalUnitConstraintFlags( const ConstraintInfo *cInfo, uint32_t naluType ) { @@ -2865,7 +2575,6 @@ void DecLib::xCheckNalUnitConstraintFlags( const ConstraintInfo *cInfo, uint32_t "Non-conforming bitstream. no_aps_constraint_flag is equal to 1 but bitstream contains NAL unit of type APS_SUFFIX_NUT."); } } -#if JVET_P0124_MIXED_NALU void DecLib::xCheckMixedNalUnit(Slice* pcSlice, SPS *sps, InputNALUnit &nalu) { if (pcSlice->getPPS()->getMixedNaluTypesInPicFlag()) @@ -2877,7 +2586,7 @@ void DecLib::xCheckMixedNalUnit(Slice* pcSlice, SPS *sps, InputNALUnit &nalu) const unsigned ctuYPosInCtus = ctuRsAddr / pcSlice->getPPS()->getPicWidthInCtu(); const unsigned maxCUSize = sps->getMaxCUWidth(); Position pos(ctuXPosInCtus*maxCUSize, ctuYPosInCtus*maxCUSize); - SubPic curSubPic = pcSlice->getPPS()->getSubPicFromPos(pos); + const SubPic &curSubPic = pcSlice->getPPS()->getSubPicFromPos(pos); // check subpicture constraints if ((pcSlice->getNalUnitType() >= NAL_UNIT_CODED_SLICE_IDR_W_RADL) && (pcSlice->getNalUnitType() <= NAL_UNIT_CODED_SLICE_CRA)) @@ -2903,12 +2612,8 @@ void DecLib::xCheckMixedNalUnit(Slice* pcSlice, SPS *sps, InputNALUnit &nalu) break; } } -#if JVET_Q0751_MIXED_NAL_UNIT_TYPES if (latestIRAPNalUnit != nullptr && ((latestIRAPNalUnit->m_nalUnitType >= NAL_UNIT_CODED_SLICE_IDR_W_RADL && latestIRAPNalUnit->m_nalUnitType <= NAL_UNIT_CODED_SLICE_IDR_N_LP) || (latestIRAPNalUnit->m_nalUnitType == NAL_UNIT_CODED_SLICE_CRA && pcSlice->getPOC() > latestIRAPNalUnit->m_POC))) -#else - if (latestIRAPNalUnit != nullptr) -#endif { // clear the nalu unit before the latest IRAP slice m_nalUnitInfo[nalu.m_nuhLayerId].erase(m_nalUnitInfo[nalu.m_nuhLayerId].begin(), m_nalUnitInfo[nalu.m_nuhLayerId].begin() + naluIdx); @@ -2953,7 +2658,6 @@ void DecLib::xCheckMixedNalUnit(Slice* pcSlice, SPS *sps, InputNALUnit &nalu) // if this is the last slice of the picture, check whether the nalu type of the slices meet the nal unit type constraints if (pcSlice->getPPS()->getNumSlicesInPic() == (m_uiSliceSegmentIdx + 1)) { -#if JVET_Q0751_MIXED_NAL_UNIT_TYPES std::set<NalUnitType> firstSet = { NAL_UNIT_CODED_SLICE_STSA, NAL_UNIT_CODED_SLICE_RADL, NAL_UNIT_CODED_SLICE_RASL, NAL_UNIT_CODED_SLICE_IDR_W_RADL, NAL_UNIT_CODED_SLICE_IDR_N_LP, NAL_UNIT_CODED_SLICE_CRA }; std::set<NalUnitType> secondSet = { NAL_UNIT_CODED_SLICE_TRAIL, NAL_UNIT_CODED_SLICE_RADL, NAL_UNIT_CODED_SLICE_RASL }; @@ -3017,28 +2721,6 @@ void DecLib::xCheckMixedNalUnit(Slice* pcSlice, SPS *sps, InputNALUnit &nalu) } CHECK(!allNalsOK || !foundNalInOtherSet, "disallowed mix of nal unit types"); } -#else - int num1stSetSlice = 0; - int num2ndSetSlice = 0; - int num3rdSetSlice = 0; - for (int i = 0; i < pcSlice->getPPS()->getNumSlicesInPic(); i++) - { - NalUnitType naluType = pcSlice->getNalUnitType(); - if (naluType >= NAL_UNIT_CODED_SLICE_IDR_W_RADL && naluType <= NAL_UNIT_CODED_SLICE_CRA) - { - num1stSetSlice++; - } - else if ((naluType >= NAL_UNIT_CODED_SLICE_TRAIL && naluType <= NAL_UNIT_RESERVED_VCL_6) || naluType == NAL_UNIT_CODED_SLICE_GDR) - { - num2ndSetSlice++; - } - else - { - num3rdSetSlice++; - } - } - CHECK((num1stSetSlice + num2ndSetSlice) != pcSlice->getPPS()->getNumSlicesInPic() || num3rdSetSlice != 0, "mixed nal unit picture contain more than two nal unit types"); -#endif } } else // all slices shall have the same nal unit type @@ -3053,5 +2735,4 @@ void DecLib::xCheckMixedNalUnit(Slice* pcSlice, SPS *sps, InputNALUnit &nalu) CHECK(!sameNalUnitType, "mixed_nalu_types_in_pic_flag is zero, but have different nal unit types"); } } -#endif //! \} diff --git a/source/Lib/DecoderLib/DecLib.h b/source/Lib/DecoderLib/DecLib.h index 13d0f56280a3b337371c2e9580fc75378c1bc35a..f7a1b0cf268c4f6c69563f6a1ff7aee37ae57a9e 100644 --- a/source/Lib/DecoderLib/DecLib.h +++ b/source/Lib/DecoderLib/DecLib.h @@ -69,12 +69,12 @@ class DecLib { private: int m_iMaxRefPicNum; + bool m_isFirstGeneralHrd; + GeneralHrdParams m_prevGeneralHrdParams; NalUnitType m_associatedIRAPType; ///< NAL unit type of the associated IRAP picture -#if JVET_P0978_RPL_RESTRICTIONS int m_associatedIRAPDecodingOrderNumber; ///< Decoding order number of the associated IRAP picture int m_decodingOrderCounter; -#endif int m_pocCRA; ///< POC number of the latest CRA picture int m_pocRandomAccess; ///< POC number of the random access point (the first IDR or CRA picture) int m_lastRasPoc; @@ -115,11 +115,7 @@ private: int m_prevPOC; int m_prevTid0POC; bool m_bFirstSliceInPicture; -#if JVET_P0125_EOS_LAYER_SPECIFIC bool m_firstSliceInSequence[MAX_VPS_LAYERS]; -#else - bool m_bFirstSliceInSequence; -#endif bool m_firstSliceInBitstream; bool m_prevSliceSkipped; int m_skippedPOC; @@ -139,7 +135,6 @@ private: int m_debugCTU; std::vector<std::pair<NalUnitType, int>> m_accessUnitNals; - #if JVET_P0101_POC_MULTILAYER struct AccessUnitPicInfo { NalUnitType m_nalUnitType; ///< nal_unit_type @@ -148,47 +143,35 @@ private: int m_POC; }; std::vector<AccessUnitPicInfo> m_accessUnitPicInfo; - #endif -#if JVET_P0124_MIXED_NALU struct NalUnitInfo { NalUnitType m_nalUnitType; ///< nal_unit_type uint32_t m_nuhLayerId; ///< nuh_layer_id uint32_t m_firstCTUinSlice; /// the first CTU in slice, specified with raster scan order ctu address - int m_POC; /// the picture order + int m_POC; /// the picture order }; std::vector<NalUnitInfo> m_nalUnitInfo[MAX_VPS_LAYERS]; -#endif std::vector<int> m_accessUnitApsNals; -#if JVET_P0125_ASPECT_TID_LAYER_ID_NUH std::vector<int> m_accessUnitSeiTids; -#endif -#if JVET_P0125_SEI_CONSTRAINTS // NAL unit type, layer ID, and SEI payloadType std::vector<std::tuple<NalUnitType, int, SEI::PayloadType>> m_accessUnitSeiPayLoadTypes; + +#if JVET_R0201_PREFIX_SUFFIX_APS_CLEANUP + std::vector<NalUnitType> m_pictureUnitNals; #endif #if JVET_Q0488_SEI_REPETITION_CONSTRAINT std::list<InputNALUnit*> m_pictureSeiNalus; #endif + VPS* m_vps; -#if !JVET_Q0346_SCALING_LIST_USED_IN_SH - bool m_scalingListUpdateFlag; - int m_PreScalingListAPSId; -#endif -#if JVET_Q0044_SLICE_IDX_WITH_SUBPICS int m_maxDecSubPicIdx; int m_maxDecSliceAddrInSubPic; -#endif -#if JVET_O1143_SUBPIC_BOUNDARY public: int m_targetSubPicIdx; -#endif -#if JVET_Q0117_PARAMETER_SETS_CLEANUP DCI* m_dci; -#endif public: DecLib(); virtual ~DecLib(); @@ -203,11 +186,7 @@ public: const std::string& cacheCfgFileName #endif ); -#if JVET_P0288_PIC_OUTPUT bool decode(InputNALUnit& nalu, int& iSkipFrame, int& iPOCLastDisplay, int iTargetOlsIdx); -#else - bool decode(InputNALUnit& nalu, int& iSkipFrame, int& iPOCLastDisplay); -#endif void deletePicBuffer(); void executeLoopFilters(); @@ -215,22 +194,15 @@ public: void finishPictureLight(int& poc, PicList*& rpcListPic ); void checkNoOutputPriorPics (PicList* rpcListPic); void checkNalUnitConstraints( uint32_t naluType ); -#if JVET_P0978_RPL_RESTRICTIONS void updateAssociatedIRAP(); -#endif bool getNoOutputPriorPicsFlag () const { return m_isNoOutputPriorPics; } void setNoOutputPriorPicsFlag (bool val) { m_isNoOutputPriorPics = val; } void setFirstSliceInPicture (bool val) { m_bFirstSliceInPicture = val; } bool getFirstSliceInPicture () const { return m_bFirstSliceInPicture; } -#if JVET_P0125_EOS_LAYER_SPECIFIC bool getFirstSliceInSequence(int layerId) const { return m_firstSliceInSequence[layerId]; } void setFirstSliceInSequence(bool val, int layerId) { m_firstSliceInSequence[layerId] = val; } -#else - bool getFirstSliceInSequence () const { return m_bFirstSliceInSequence; } - void setFirstSliceInSequence (bool val) { m_bFirstSliceInSequence = val; } -#endif void setDecodedSEIMessageOutputStream(std::ostream *pOpStream) { m_pDecodedSEIOutputStream = pOpStream; } uint32_t getNumberOfChecksumErrorsDetected() const { return m_numberOfChecksumErrorsDetected; } @@ -239,39 +211,30 @@ public: int getDebugPOC( ) const { return m_debugPOC; }; void setDebugPOC( int debugPOC ) { m_debugPOC = debugPOC; }; void resetAccessUnitNals() { m_accessUnitNals.clear(); } -#if JVET_P0101_POC_MULTILAYER void resetAccessUnitPicInfo() { m_accessUnitPicInfo.clear(); } -#endif void resetAccessUnitApsNals() { m_accessUnitApsNals.clear(); } -#if JVET_P0125_ASPECT_TID_LAYER_ID_NUH void resetAccessUnitSeiTids() { m_accessUnitSeiTids.clear(); } void checkTidLayerIdInAccessUnit(); -#endif -#if JVET_P0125_SEI_CONSTRAINTS void resetAccessUnitSeiPayLoadTypes() { m_accessUnitSeiPayLoadTypes.clear(); } void checkSEIInAccessUnit(); -#endif #if JVET_Q0488_SEI_REPETITION_CONSTRAINT void checkSeiInPictureUnit(); void resetPictureSeiNalus(); #endif bool isSliceNaluFirstInAU( bool newPicture, InputNALUnit &nalu ); +#if JVET_R0201_PREFIX_SUFFIX_APS_CLEANUP + void checkAPSInPictureUnit(); + void resetPictureUnitNals() { m_pictureUnitNals.clear(); } +#endif + const VPS* getVPS() { return m_vps; } -#if JVET_Q0814_DPB void deriveTargetOutputLayerSet( const int targetOlsIdx ) { if( m_vps != nullptr ) m_vps->deriveTargetOutputLayerSet( targetOlsIdx ); } -#endif void initScalingList() { m_cTrQuantScalingList.init(nullptr, MAX_TB_SIZEY, false, false, false, false); } -#if !JVET_Q0346_SCALING_LIST_USED_IN_SH - bool getScalingListUpdateFlag() { return m_scalingListUpdateFlag; } - void setScalingListUpdateFlag(bool b) { m_scalingListUpdateFlag = b; } - int getPreScalingListAPSId() { return m_PreScalingListAPSId; } - void setPreScalingListAPSId(int id) { m_PreScalingListAPSId = id; } -#endif protected: void xUpdateRasInit(Slice* slice); @@ -284,11 +247,7 @@ protected: void xDecodePicHeader( InputNALUnit& nalu ); bool xDecodeSlice(InputNALUnit &nalu, int &iSkipFrame, int iPOCLastDisplay); void xDecodeVPS( InputNALUnit& nalu ); -#if JVET_Q0117_PARAMETER_SETS_CLEANUP void xDecodeDCI( InputNALUnit& nalu ); -#else - void xDecodeDPS( InputNALUnit& nalu ); -#endif void xDecodeSPS( InputNALUnit& nalu ); void xDecodePPS( InputNALUnit& nalu ); void xDecodeAPS(InputNALUnit& nalu); @@ -297,9 +256,7 @@ protected: void xParsePrefixSEIsForUnknownVCLNal(); void xCheckNalUnitConstraintFlags( const ConstraintInfo *cInfo, uint32_t naluType ); -#if JVET_P0124_MIXED_NALU void xCheckMixedNalUnit(Slice* pcSlice, SPS *sps, InputNALUnit &nalu); -#endif };// END CLASS DEFINITION DecLib diff --git a/source/Lib/DecoderLib/DecSlice.cpp b/source/Lib/DecoderLib/DecSlice.cpp index 42418bb80697e847ce6113863f2d9272922500b5..eb7926794a351db85788a15d095aef20880cd4c8 100644 --- a/source/Lib/DecoderLib/DecSlice.cpp +++ b/source/Lib/DecoderLib/DecSlice.cpp @@ -114,11 +114,11 @@ void DecSlice::decompressSlice( Slice* slice, InputBitstream* bitstream, int deb } const unsigned widthInCtus = cs.pcv->widthInCtus; -#if JVET_Q0151_Q0205_ENTRYPOINTS const bool wavefrontsEnabled = cs.sps->getEntropyCodingSyncEnabledFlag(); - const bool wavefrontsEntryPointPresent = cs.sps->getEntropyCodingSyncEntryPointsPresentFlag(); +#if JVET_R0165_OPTIONAL_ENTRY_POINT + const bool entryPointPresent = cs.sps->getEntryPointsPresentFlag(); #else - const bool wavefrontsEnabled = cs.pps->getEntropyCodingSyncEnabledFlag(); + const bool wavefrontsEntryPointPresent = cs.sps->getEntropyCodingSyncEntryPointsPresentFlag(); #endif cabacReader.initBitstream( ppcSubstreams[0] ); @@ -137,7 +137,7 @@ void DecSlice::decompressSlice( Slice* slice, InputBitstream* bitstream, int deb { const unsigned ctuRsAddr = slice->getCtuAddrInSlice(ctuIdx); const unsigned ctuXPosInCtus = ctuRsAddr % widthInCtus; - const unsigned ctuYPosInCtus = ctuRsAddr / widthInCtus; + const unsigned ctuYPosInCtus = ctuRsAddr / widthInCtus; const unsigned tileColIdx = slice->getPPS()->ctuToTileCol( ctuXPosInCtus ); const unsigned tileRowIdx = slice->getPPS()->ctuToTileRow( ctuYPosInCtus ); const unsigned tileXPosInCtus = slice->getPPS()->getTileColumnBd( tileColIdx ); @@ -148,8 +148,7 @@ void DecSlice::decompressSlice( Slice* slice, InputBitstream* bitstream, int deb const unsigned maxCUSize = sps->getMaxCUWidth(); Position pos( ctuXPosInCtus*maxCUSize, ctuYPosInCtus*maxCUSize) ; UnitArea ctuArea(cs.area.chromaFormat, Area( pos.x, pos.y, maxCUSize, maxCUSize ) ); -#if JVET_O1143_MV_ACROSS_SUBPIC_BOUNDARY - SubPic curSubPic = slice->getPPS()->getSubPicFromPos(pos); + const SubPic &curSubPic = slice->getPPS()->getSubPicFromPos(pos); // padding/restore at slice level if (slice->getPPS()->getNumSubPics()>=2 && curSubPic.getTreatedAsPicFlag() && ctuIdx==0) { @@ -157,13 +156,13 @@ void DecSlice::decompressSlice( Slice* slice, InputBitstream* bitstream, int deb int subPicY = (int)curSubPic.getSubPicTop(); int subPicWidth = (int)curSubPic.getSubPicWidthInLumaSample(); int subPicHeight = (int)curSubPic.getSubPicHeightInLumaSample(); - for (int rlist = REF_PIC_LIST_0; rlist < NUM_REF_PIC_LIST_01; rlist++) + for (int rlist = REF_PIC_LIST_0; rlist < NUM_REF_PIC_LIST_01; rlist++) { int n = slice->getNumRefIdx((RefPicList)rlist); - for (int idx = 0; idx < n; idx++) + for (int idx = 0; idx < n; idx++) { Picture *refPic = slice->getRefPic((RefPicList)rlist, idx); - if (!refPic->getSubPicSaved()) + if (!refPic->getSubPicSaved()) { refPic->saveSubPicBorder(refPic->getPOC(), subPicX, subPicY, subPicWidth, subPicHeight); refPic->extendSubPicBorder(refPic->getPOC(), subPicX, subPicY, subPicWidth, subPicHeight); @@ -172,7 +171,6 @@ void DecSlice::decompressSlice( Slice* slice, InputBitstream* bitstream, int deb } } } -#endif DTRACE_UPDATE( g_trace_ctx, std::make_pair( "ctu", ctuRsAddr ) ); @@ -200,9 +198,7 @@ void DecSlice::decompressSlice( Slice* slice, InputBitstream* bitstream, int deb { // Top is available, so use it. cabacReader.getCtx() = m_entropyCodingSyncContextState; -#if JVET_Q0501_PALETTE_WPP_INIT_ABOVECTU cs.setPrevPLT(m_palettePredictorSyncState); -#endif } pic->m_prevQP[0] = pic->m_prevQP[1] = slice->getSliceQp(); } @@ -236,9 +232,7 @@ void DecSlice::decompressSlice( Slice* slice, InputBitstream* bitstream, int deb if( ctuXPosInCtus == tileXPosInCtus && wavefrontsEnabled ) { m_entropyCodingSyncContextState = cabacReader.getCtx(); -#if JVET_Q0501_PALETTE_WPP_INIT_ABOVECTU cs.storePrevPLT(m_palettePredictorSyncState); -#endif } @@ -257,23 +251,19 @@ void DecSlice::decompressSlice( Slice* slice, InputBitstream* bitstream, int deb // (end of slice-segment, end of tile, end of wavefront-CTU-row) unsigned binVal = cabacReader.terminating_bit(); CHECK( !binVal, "Expecting a terminating bit" ); -#if JVET_Q0151_Q0205_ENTRYPOINTS +#if JVET_R0165_OPTIONAL_ENTRY_POINT + if( entryPointPresent ) +#else bool isLastTileCtu = (ctuXPosInCtus + 1 == tileXPosInCtus + tileColWidth) && (ctuYPosInCtus + 1 == tileYPosInCtus + tileRowHeight); - if( isLastTileCtu || wavefrontsEntryPointPresent ) + if( isLastTileCtu || wavefrontsEntryPointPresent ) +#endif { #if DECODER_CHECK_SUBSTREAM_AND_SLICE_TRAILING_BYTES cabacReader.remaining_bytes( true ); #endif subStrmId++; } -#else -#if DECODER_CHECK_SUBSTREAM_AND_SLICE_TRAILING_BYTES - cabacReader.remaining_bytes( true ); -#endif - subStrmId++; -#endif } -#if JVET_O1143_MV_ACROSS_SUBPIC_BOUNDARY if (slice->getPPS()->getNumSubPics() >= 2 && curSubPic.getTreatedAsPicFlag() && ctuIdx == (slice->getNumCtuInSlice() - 1)) // for last Ctu in the slice { @@ -281,13 +271,13 @@ void DecSlice::decompressSlice( Slice* slice, InputBitstream* bitstream, int deb int subPicY = (int)curSubPic.getSubPicTop(); int subPicWidth = (int)curSubPic.getSubPicWidthInLumaSample(); int subPicHeight = (int)curSubPic.getSubPicHeightInLumaSample(); - for (int rlist = REF_PIC_LIST_0; rlist < NUM_REF_PIC_LIST_01; rlist++) + for (int rlist = REF_PIC_LIST_0; rlist < NUM_REF_PIC_LIST_01; rlist++) { int n = slice->getNumRefIdx((RefPicList)rlist); - for (int idx = 0; idx < n; idx++) + for (int idx = 0; idx < n; idx++) { Picture *refPic = slice->getRefPic((RefPicList)rlist, idx); - if (refPic->getSubPicSaved()) + if (refPic->getSubPicSaved()) { refPic->restoreSubPicBorder(refPic->getPOC(), subPicX, subPicY, subPicWidth, subPicHeight); refPic->setSubPicSaved(false); @@ -295,7 +285,6 @@ void DecSlice::decompressSlice( Slice* slice, InputBitstream* bitstream, int deb } } } -#endif } // deallocate all created substreams, including internal buffers. diff --git a/source/Lib/DecoderLib/DecSlice.h b/source/Lib/DecoderLib/DecSlice.h index cd918ed76d3fe28fab725c5efd40965359a4af74..56cc1da07e3c4330a08d298017e8ed94221b9d6c 100644 --- a/source/Lib/DecoderLib/DecSlice.h +++ b/source/Lib/DecoderLib/DecSlice.h @@ -63,9 +63,7 @@ private: DecCu* m_pcCuDecoder; Ctx m_entropyCodingSyncContextState; ///< context storage for state of contexts at the wavefront/WPP/entropy-coding-sync second CTU of tile-row -#if JVET_Q0501_PALETTE_WPP_INIT_ABOVECTU PLTBuf m_palettePredictorSyncState; /// palette predictor storage at wavefront/WPP -#endif public: DecSlice(); diff --git a/source/Lib/DecoderLib/NALread.cpp b/source/Lib/DecoderLib/NALread.cpp index 819bcc25180de163afd088f8e2ff0f93e26f2484..a1cbcf760166c542dd07b02cefde7f61eda32e6a 100644 --- a/source/Lib/DecoderLib/NALread.cpp +++ b/source/Lib/DecoderLib/NALread.cpp @@ -150,7 +150,7 @@ void readNalUnitHeader(InputNALUnit& nalu) else { CHECK(nalu.m_nalUnitType == NAL_UNIT_CODED_SLICE_STSA - , "When NAL unit type is equal to STSA_NUT, TemporalId shall not be equal to 0"); + , "When NAL unit type is equal to STSA_NUT, TemporalId shall not be equal to 0"); } } } @@ -167,12 +167,10 @@ void read(InputNALUnit& nalu) bitstream.resetToStart(); readNalUnitHeader(nalu); } -#if JVET_Q0775_PH_IN_SH bool checkPictureHeaderInSliceHeaderFlag(InputNALUnit& nalu) { InputBitstream& bitstream = nalu.getBitstream(); CHECK(bitstream.getByteLocation() != 2, "The picture_header_in_slice_header_flag is the first bit after the NAL unit header"); return (bool)bitstream.read(1); } -#endif //! \} diff --git a/source/Lib/DecoderLib/NALread.h b/source/Lib/DecoderLib/NALread.h index f807fbed75608d03e84197ae2f75534585c8d47b..4a8647b47a9796aafbb7edb89ab04808c726837f 100644 --- a/source/Lib/DecoderLib/NALread.h +++ b/source/Lib/DecoderLib/NALread.h @@ -67,9 +67,7 @@ class InputNALUnit : public NALUnit void read(InputNALUnit& nalu); void readNalUnitHeader(InputNALUnit& nalu); -#if JVET_Q0775_PH_IN_SH bool checkPictureHeaderInSliceHeaderFlag(InputNALUnit & nalu); -#endif //! \} #endif diff --git a/source/Lib/DecoderLib/SEIread.cpp b/source/Lib/DecoderLib/SEIread.cpp index 21d429643540883e8e9fd12bf7fea196a84fae43..65056ae9fdf13c03c878e5a5aac42c6e7aeb8090 100644 --- a/source/Lib/DecoderLib/SEIread.cpp +++ b/source/Lib/DecoderLib/SEIread.cpp @@ -115,22 +115,14 @@ static inline void output_sei_message_header(SEI &sei, std::ostream *pDecodedMes * unmarshal a single SEI message from bitstream bs */ // note: for independent parsing no parameter set should not be required here -#if JVET_P0125_SEI_CONSTRAINTS void SEIReader::parseSEImessage(InputBitstream* bs, SEIMessages& seis, const NalUnitType nalUnitType, const uint32_t nuh_layer_id, const uint32_t temporalId, const VPS *vps, const SPS *sps, HRD &hrd, std::ostream *pDecodedMessageOutputStream) -#else -void SEIReader::parseSEImessage(InputBitstream* bs, SEIMessages& seis, const NalUnitType nalUnitType, const uint32_t temporalId, const SPS *sps, HRD &hrd, std::ostream *pDecodedMessageOutputStream) -#endif { setBitstream(bs); CHECK(m_pcBitstream->getNumBitsUntilByteAligned(), "Bitstream not aligned"); do { -#if JVET_P0125_SEI_CONSTRAINTS xReadSEImessage(seis, nalUnitType, nuh_layer_id, temporalId, vps, sps, hrd, pDecodedMessageOutputStream); -#else - xReadSEImessage(seis, nalUnitType, temporalId, sps, hrd, pDecodedMessageOutputStream); -#endif /* SEI messages are an integer number of bytes, something has failed * in the parsing if bitstream not byte-aligned */ @@ -141,11 +133,7 @@ void SEIReader::parseSEImessage(InputBitstream* bs, SEIMessages& seis, const Nal xReadRbspTrailingBits(); } -#if JVET_P0125_SEI_CONSTRAINTS void SEIReader::xReadSEImessage(SEIMessages& seis, const NalUnitType nalUnitType, const uint32_t nuh_layer_id, const uint32_t temporalId, const VPS *vps, const SPS *sps, HRD &hrd, std::ostream *pDecodedMessageOutputStream) -#else -void SEIReader::xReadSEImessage(SEIMessages& seis, const NalUnitType nalUnitType, const uint32_t temporalId, const SPS *sps, HRD &hrd, std::ostream *pDecodedMessageOutputStream) -#endif { #if ENABLE_TRACING xTraceSEIHeader(); @@ -181,9 +169,7 @@ void SEIReader::xReadSEImessage(SEIMessages& seis, const NalUnitType nalUnitType SEI *sei = NULL; const SEIBufferingPeriod *bp = NULL; -#if JVET_Q0818_PT_SEI const SEIPictureTiming *pt = NULL; -#endif if(nalUnitType == NAL_UNIT_PREFIX_SEI) { @@ -221,30 +207,18 @@ void SEIReader::xReadSEImessage(SEIMessages& seis, const NalUnitType nalUnitType { sei = new SEIPictureTiming; xParseSEIPictureTiming((SEIPictureTiming&)*sei, payloadSize, temporalId, *bp, pDecodedMessageOutputStream); -#if JVET_Q0818_PT_SEI hrd.setPictureTimingSEI( (SEIPictureTiming*) sei ); -#endif } } break; -#if JVET_P0190_SCALABLE_NESTING_SEI case SEI::SCALABLE_NESTING: sei = new SEIScalableNesting; -#if JVET_P0125_SEI_CONSTRAINTS xParseSEIScalableNesting((SEIScalableNesting&)*sei, nalUnitType, nuh_layer_id, payloadSize, vps, sps, pDecodedMessageOutputStream); -#else - xParseSEIScalableNesting((SEIScalableNesting&)*sei, nalUnitType, payloadSize, sps, pDecodedMessageOutputStream); -#endif break; -#endif case SEI::FRAME_FIELD_INFO: sei = new SEIFrameFieldInfo; -#if JVET_Q0818_PT_SEI pt = hrd.getPictureTimingSEI(); xParseSEIFrameFieldinfo((SEIFrameFieldInfo&) *sei, *pt, payloadSize, pDecodedMessageOutputStream); -#else - xParseSEIFrameFieldinfo((SEIFrameFieldInfo&) *sei, payloadSize, pDecodedMessageOutputStream); -#endif break; case SEI::DEPENDENT_RAP_INDICATION: sei = new SEIDependentRAPIndication; @@ -286,11 +260,7 @@ void SEIReader::xReadSEImessage(SEIMessages& seis, const NalUnitType nalUnitType break; case SEI::SUBPICTURE_LEVEL_INFO: sei = new SEISubpicureLevelInfo; -#if JVET_Q0630_SUBPIC_LEVEL xParseSEISubpictureLevelInfo((SEISubpicureLevelInfo&) *sei, payloadSize, pDecodedMessageOutputStream); -#else - xParseSEISubpictureLevelInfo((SEISubpicureLevelInfo&) *sei, sps, payloadSize, pDecodedMessageOutputStream); -#endif break; case SEI::SAMPLE_ASPECT_RATIO_INFO: sei = new SEISampleAspectRatioInfo; @@ -487,12 +457,7 @@ void SEIReader::xParseSEIDecodedPictureHash(SEIDecodedPictureHash& sei, uint32_t } -#if JVET_P0190_SCALABLE_NESTING_SEI -#if JVET_P0125_SEI_CONSTRAINTS void SEIReader::xParseSEIScalableNesting(SEIScalableNesting& sei, const NalUnitType nalUnitType, const uint32_t nuh_layer_id, uint32_t payloadSize, const VPS *vps, const SPS *sps, std::ostream *pDecodedMessageOutputStream) -#else -void SEIReader::xParseSEIScalableNesting(SEIScalableNesting& sei, const NalUnitType nalUnitType, uint32_t payloadSize, const SPS *sps, std::ostream *pDecodedMessageOutputStream) -#endif { uint32_t uiCode; SEIMessages seis; @@ -506,7 +471,6 @@ void SEIReader::xParseSEIScalableNesting(SEIScalableNesting& sei, const NalUnitT { sei_read_uvlc(pDecodedMessageOutputStream, uiCode, "nesting_ols_idx_delta_minus1[i]"); sei.m_nestingOlsIdxDeltaMinus1[i] = uiCode; } -#if JVET_P0125_SEI_CONSTRAINTS for (uint32_t i = 0; i <= sei.m_nestingNumOlssMinus1; i++) { if (i == 0) @@ -518,20 +482,22 @@ void SEIReader::xParseSEIScalableNesting(SEIScalableNesting& sei, const NalUnitT sei.m_nestingOlsIdx[i] = sei.m_nestingOlsIdxDeltaMinus1[i] + sei.m_nestingOlsIdxDeltaMinus1[i - 1] + 1; } } - uint32_t lowestLayerId = MAX_UINT; - for (uint32_t olsIdxForSEI = 0; olsIdxForSEI <= sei.m_nestingNumOlssMinus1; olsIdxForSEI++) + if (vps && vps->getVPSId() != 0) { - int olsIdx = sei.m_nestingOlsIdx[olsIdxForSEI]; - for (int layerIdx = 0; layerIdx < vps->getNumLayersInOls(olsIdx); layerIdx++) + uint32_t lowestLayerId = MAX_UINT; + for (uint32_t olsIdxForSEI = 0; olsIdxForSEI <= sei.m_nestingNumOlssMinus1; olsIdxForSEI++) { - if (lowestLayerId > vps->getLayerIdInOls(olsIdx, layerIdx)) + int olsIdx = sei.m_nestingOlsIdx[olsIdxForSEI]; + for (int layerIdx = 0; layerIdx < vps->getNumLayersInOls(olsIdx); layerIdx++) { - lowestLayerId = vps->getLayerIdInOls(olsIdx, layerIdx); + if (lowestLayerId > vps->getLayerIdInOls(olsIdx, layerIdx)) + { + lowestLayerId = vps->getLayerIdInOls(olsIdx, layerIdx); + } } } + CHECK(lowestLayerId!= nuh_layer_id, "nuh_layer_id is not equal to the lowest layer among Olss that the scalable SEI applies"); } - CHECK(lowestLayerId!= nuh_layer_id, "nuh_layer_id is not equal to the lowest layer among Olss that the scalable SEI applies"); -#endif } else { @@ -553,7 +519,6 @@ void SEIReader::xParseSEIScalableNesting(SEIScalableNesting& sei, const NalUnitT sei_read_flag(pDecodedMessageOutputStream, code, "nesting_zero_bit"); } -#if JVET_P0125_SEI_CONSTRAINTS bool containBPorPTorDUI = false; bool containNoBPorPTorDUI = false; for (auto nestedsei : sei.m_nestedSEIs) @@ -568,16 +533,11 @@ void SEIReader::xParseSEIScalableNesting(SEIScalableNesting& sei, const NalUnitT } } CHECK(containBPorPTorDUI && containNoBPorPTorDUI, "nested SEI cannot have timing-related SEI and none-timing-related SEI at the same time"); -#endif // read nested SEI messages do { HRD hrd; -#if JVET_P0125_SEI_CONSTRAINTS xReadSEImessage(sei.m_nestedSEIs, nalUnitType, nuh_layer_id, 0, vps, sps, hrd, pDecodedMessageOutputStream); -#else - xReadSEImessage(sei.m_nestedSEIs, nalUnitType, 0, sps, hrd, pDecodedMessageOutputStream); -#endif } while (m_pcBitstream->getNumBitsLeft() > 8); if (pDecodedMessageOutputStream) @@ -585,7 +545,7 @@ void SEIReader::xParseSEIScalableNesting(SEIScalableNesting& sei, const NalUnitT (*pDecodedMessageOutputStream) << "End of scalable nesting SEI message\n"; } } -#endif + void SEIReader::xParseSEIDecodingUnitInfo(SEIDecodingUnitInfo& sei, uint32_t payloadSize, const SEIBufferingPeriod& bp, const uint32_t temporalId, std::ostream *pDecodedMessageOutputStream) { uint32_t val; @@ -595,10 +555,24 @@ void SEIReader::xParseSEIDecodingUnitInfo(SEIDecodingUnitInfo& sei, uint32_t pay if(!bp.m_decodingUnitCpbParamsInPicTimingSeiFlag) { - for( int i = temporalId; i < bp.m_bpMaxSubLayers - 1; i ++ ) +#if JVET_R0100 + for (int i = temporalId; i <= bp.m_bpMaxSubLayers - 1; i++) + { + if (i < (bp.m_bpMaxSubLayers - 1)) + { + sei_read_flag( pDecodedMessageOutputStream, val, "dui_sub_layer_delays_present_flag[i]" ); + sei.m_duiSubLayerDelaysPresentFlag[i] = val; + } + else + { + sei.m_duiSubLayerDelaysPresentFlag[i] = 1; + } +#else + for ( int i = temporalId; i < bp.m_bpMaxSubLayers - 1; i++) { sei_read_flag( pDecodedMessageOutputStream, val, "dui_sub_layer_delays_present_flag[i]" ); sei.m_duiSubLayerDelaysPresentFlag[i] = val; +#endif if( sei.m_duiSubLayerDelaysPresentFlag[i] ) { sei_read_code( pDecodedMessageOutputStream, bp.getDuCpbRemovalDelayIncrementLength(), val, "du_spt_cpb_removal_delay_increment[i]"); @@ -617,7 +591,6 @@ void SEIReader::xParseSEIDecodingUnitInfo(SEIDecodingUnitInfo& sei, uint32_t pay sei.m_duSptCpbRemovalDelayIncrement[i] = 0; } } -#if JVET_Q0221 if (bp.m_decodingUnitDpbDuParamsInPicTimingSeiFlag) { sei_read_flag(pDecodedMessageOutputStream, val, "dpb_output_du_delay_present_flag"); sei.m_dpbOutputDuDelayPresentFlag = (val != 0); @@ -626,9 +599,6 @@ void SEIReader::xParseSEIDecodingUnitInfo(SEIDecodingUnitInfo& sei, uint32_t pay { sei.m_dpbOutputDuDelayPresentFlag = false; } -#else - sei_read_flag(pDecodedMessageOutputStream, val, "dpb_output_du_delay_present_flag"); sei.m_dpbOutputDuDelayPresentFlag = (val != 0); -#endif if(sei.m_dpbOutputDuDelayPresentFlag) { sei_read_code( pDecodedMessageOutputStream, bp.getDpbOutputDelayDuLength(), val, "pic_spt_dpb_output_du_delay"); @@ -657,17 +627,13 @@ void SEIReader::xParseSEIBufferingPeriod(SEIBufferingPeriod& sei, uint32_t paylo sei_read_code( pDecodedMessageOutputStream, 5, code, "du_cpb_removal_delay_increment_length_minus1" ); sei.m_duCpbRemovalDelayIncrementLength = code + 1; sei_read_code( pDecodedMessageOutputStream, 5, code, "dpb_output_delay_du_length_minus1" ); sei.m_dpbOutputDelayDuLength = code + 1; sei_read_flag( pDecodedMessageOutputStream, code, "decoding_unit_cpb_params_in_pic_timing_sei_flag" ); sei.m_decodingUnitCpbParamsInPicTimingSeiFlag = code; -#if JVET_Q0221 sei_read_flag(pDecodedMessageOutputStream, code, "decoding_unit_dpb_du_params_in_pic_timing_sei_flag"); sei.m_decodingUnitDpbDuParamsInPicTimingSeiFlag = code; -#endif } else { sei.m_duCpbRemovalDelayIncrementLength = 24; sei.m_dpbOutputDelayDuLength = 24; -#if JVET_Q0221 sei.m_decodingUnitDpbDuParamsInPicTimingSeiFlag = false; -#endif } sei_read_flag( pDecodedMessageOutputStream, code, "concatenation_flag"); @@ -713,6 +679,19 @@ void SEIReader::xParseSEIBufferingPeriod(SEIBufferingPeriod& sei, uint32_t paylo } } } +#if JVET_R0094_DPB_TID_OFFSET + sei_read_flag( pDecodedMessageOutputStream, code, "sublayer_dpb_output_offsets_present_flag" ); + sei.m_sublayerDpbOutputOffsetsPresentFlag = code; + if(sei.m_sublayerDpbOutputOffsetsPresentFlag) + { + for(int i = 0; i < sei.m_bpMaxSubLayers - 1; i++) + { + sei_read_uvlc( pDecodedMessageOutputStream, code, "dpb_output_tid_offset[i]" ); + sei.m_dpbOutputTidOffset[i] = code; + } + sei.m_dpbOutputTidOffset[sei.m_bpMaxSubLayers-1] = 0; + } +#endif if (sei.m_altCpbParamsPresentFlag) { sei_read_flag(pDecodedMessageOutputStream, code, "use_alt_cpb_params_flag"); sei.m_useAltCpbParamsFlag = code; @@ -729,12 +708,66 @@ void SEIReader::xParseSEIPictureTiming(SEIPictureTiming& sei, uint32_t payloadSi sei_read_code( pDecodedMessageOutputStream, bp.m_cpbRemovalDelayLength, symbol, "cpb_removal_delay_minus1[bp_max_sub_layers_minus1]" ); sei.m_auCpbRemovalDelay[bp.m_bpMaxSubLayers - 1] = symbol + 1; - if( bp.m_altCpbParamsPresentFlag ) + if( bp.m_altCpbParamsPresentFlag ) { sei_read_flag( pDecodedMessageOutputStream, symbol, "cpb_alt_timing_info_present_flag" ); sei.m_cpbAltTimingInfoPresentFlag = symbol; - if( sei.m_cpbAltTimingInfoPresentFlag ) + if( sei.m_cpbAltTimingInfoPresentFlag ) { -#if JVET_Q0219_SIGNAL_ALT_BUFFER_DELAY_PARMS +#if JVET_R0413_HRD_TIMING_INFORMATION + if (bp.m_bpNalCpbParamsPresentFlag) + { + sei.m_nalCpbAltInitialRemovalDelayDelta.resize(bp.m_bpMaxSubLayers); + sei.m_nalCpbAltInitialRemovalOffsetDelta.resize(bp.m_bpMaxSubLayers); + sei.m_nalCpbDelayOffset.resize(bp.m_bpMaxSubLayers); + sei.m_nalDpbDelayOffset.resize(bp.m_bpMaxSubLayers); + for (int i = (bp.m_sublayerInitialCpbRemovalDelayPresentFlag ? 0 : bp.m_bpMaxSubLayers - 1); + i <= bp.m_bpMaxSubLayers - 1; ++i) + { + sei.m_nalCpbAltInitialRemovalDelayDelta[i].resize(bp.m_bpCpbCnt); + sei.m_nalCpbAltInitialRemovalOffsetDelta[i].resize(bp.m_bpCpbCnt); + for (int j = 0; j < bp.m_bpCpbCnt; j++) + { + sei_read_code(pDecodedMessageOutputStream, bp.m_initialCpbRemovalDelayLength, symbol, + "nal_cpb_alt_initial_cpb_removal_delay_delta[ i ][ j ]"); + sei.m_nalCpbAltInitialRemovalDelayDelta[i][j] = symbol; + sei_read_code(pDecodedMessageOutputStream, bp.m_initialCpbRemovalDelayLength, symbol, + "nal_cpb_alt_initial_cpb_removal_offset_delta[ i ][ j ]"); + sei.m_nalCpbAltInitialRemovalOffsetDelta[i][j] = symbol; + } + sei_read_code(pDecodedMessageOutputStream, bp.m_initialCpbRemovalDelayLength, sei.m_nalCpbDelayOffset[i], + "nal_cpb_delay_offset[ i ]"); + sei_read_code(pDecodedMessageOutputStream, bp.m_initialCpbRemovalDelayLength, sei.m_nalDpbDelayOffset[i], + "nal_dpb_delay_offset[ i ]"); + } + } + + if (bp.m_bpVclCpbParamsPresentFlag) + { + sei.m_vclCpbAltInitialRemovalDelayDelta.resize(bp.m_bpMaxSubLayers); + sei.m_vclCpbAltInitialRemovalOffsetDelta.resize(bp.m_bpMaxSubLayers); + sei.m_vclCpbDelayOffset.resize(bp.m_bpMaxSubLayers); + sei.m_vclDpbDelayOffset.resize(bp.m_bpMaxSubLayers); + for (int i = (bp.m_sublayerInitialCpbRemovalDelayPresentFlag ? 0 : bp.m_bpMaxSubLayers - 1); + i <= bp.m_bpMaxSubLayers - 1; ++i) + { + sei.m_vclCpbAltInitialRemovalDelayDelta[i].resize(bp.m_bpCpbCnt); + sei.m_vclCpbAltInitialRemovalOffsetDelta[i].resize(bp.m_bpCpbCnt); + for (int j = 0; j < bp.m_bpCpbCnt; j++) + { + sei_read_code(pDecodedMessageOutputStream, bp.m_initialCpbRemovalDelayLength, symbol, + "vcl_cpb_alt_initial_cpb_removal_delay_delta[ i ][ j ]"); + sei.m_vclCpbAltInitialRemovalDelayDelta[i][j] = symbol; + sei_read_code(pDecodedMessageOutputStream, bp.m_initialCpbRemovalDelayLength, symbol, + "vcl_cpb_alt_initial_cpb_removal_offset_delta[ i ][ j ]"); + sei.m_vclCpbAltInitialRemovalOffsetDelta[i][j] = symbol; + } + sei_read_code(pDecodedMessageOutputStream, bp.m_initialCpbRemovalDelayLength, sei.m_vclCpbDelayOffset[i], + "vcl_cpb_delay_offset[ i ]"); + sei_read_code(pDecodedMessageOutputStream, bp.m_initialCpbRemovalDelayLength, sei.m_vclDpbDelayOffset[i], + "vcl_dpb_delay_offset[ i ]"); + } + } +#else sei.m_cpbAltInitialCpbRemovalDelayDelta.resize(bp.m_bpMaxSubLayers); sei.m_cpbAltInitialCpbRemovalOffsetDelta.resize(bp.m_bpMaxSubLayers); sei.m_cpbDelayOffset.resize(bp.m_bpMaxSubLayers); @@ -758,33 +791,37 @@ void SEIReader::xParseSEIPictureTiming(SEIPictureTiming& sei, uint32_t payloadSi sei_read_code(pDecodedMessageOutputStream, bp.m_initialCpbRemovalDelayLength, sei.m_dpbDelayOffset[i], "dpb_delay_offset[ i ]"); } -#else - sei.m_cpbAltInitialCpbRemovalDelayDelta.resize(bp.m_bpCpbCnt); - sei.m_cpbAltInitialCpbRemovalOffsetDelta.resize(bp.m_bpCpbCnt); - for (int i = 0; i < bp.m_bpCpbCnt; i++) - { - sei_read_code(pDecodedMessageOutputStream, bp.m_initialCpbRemovalDelayLength, symbol, - "cpb_alt_initial_cpb_removal_delay_delta[ i ]"); - sei.m_cpbAltInitialCpbRemovalDelayDelta[i] = symbol; - sei_read_code(pDecodedMessageOutputStream, bp.m_initialCpbRemovalDelayLength, symbol, - "cpb_alt_initial_cpb_removal_offset_delta[ i ]"); - sei.m_cpbAltInitialCpbRemovalOffsetDelta[i] = symbol; - } - sei_read_code(pDecodedMessageOutputStream, bp.m_initialCpbRemovalDelayLength, sei.m_cpbDelayOffset, - "cpb_delay_offset"); - sei_read_code(pDecodedMessageOutputStream, bp.m_initialCpbRemovalDelayLength, sei.m_dpbDelayOffset, - "dpb_delay_offset"); #endif } } else { sei.m_cpbAltTimingInfoPresentFlag = false; -#if JVET_Q0219_SIGNAL_ALT_BUFFER_DELAY_PARMS +#if JVET_R0413_HRD_TIMING_INFORMATION + sei.m_nalCpbAltInitialRemovalDelayDelta.resize(bp.m_bpMaxSubLayers); + sei.m_nalCpbAltInitialRemovalOffsetDelta.resize(bp.m_bpMaxSubLayers); + sei.m_nalCpbDelayOffset.resize(bp.m_bpMaxSubLayers, 0); + sei.m_nalDpbDelayOffset.resize(bp.m_bpMaxSubLayers, 0); + for (int i = (bp.m_sublayerInitialCpbRemovalDelayPresentFlag ? 0 : bp.m_bpMaxSubLayers - 1); + i <= bp.m_bpMaxSubLayers - 1; ++i) + { + sei.m_nalCpbAltInitialRemovalDelayDelta[i].resize(bp.m_bpCpbCnt, 0); + sei.m_nalCpbAltInitialRemovalOffsetDelta[i].resize(bp.m_bpCpbCnt, 0); + } + + sei.m_vclCpbAltInitialRemovalDelayDelta.resize(bp.m_bpMaxSubLayers); + sei.m_vclCpbAltInitialRemovalOffsetDelta.resize(bp.m_bpMaxSubLayers); + sei.m_vclCpbDelayOffset.resize(bp.m_bpMaxSubLayers, 0); + sei.m_vclDpbDelayOffset.resize(bp.m_bpMaxSubLayers, 0); + for (int i = (bp.m_sublayerInitialCpbRemovalDelayPresentFlag ? 0 : bp.m_bpMaxSubLayers - 1); + i <= bp.m_bpMaxSubLayers - 1; ++i) + { + sei.m_vclCpbAltInitialRemovalDelayDelta[i].resize(bp.m_bpCpbCnt, 0); + sei.m_vclCpbAltInitialRemovalOffsetDelta[i].resize(bp.m_bpCpbCnt, 0); + } +#else sei.m_cpbDelayOffset.resize(bp.m_bpMaxSubLayers, 0); sei.m_dpbDelayOffset.resize(bp.m_bpMaxSubLayers, 0); -#else - sei.m_cpbDelayOffset = sei.m_dpbDelayOffset = 0; #endif } @@ -804,7 +841,6 @@ void SEIReader::xParseSEIPictureTiming(SEIPictureTiming& sei, uint32_t payloadSi } if( sei.m_cpbRemovalDelayDeltaEnabledFlag[ i ] ) { -#if JVET_Q0216 if ((bp.m_numCpbRemovalDelayDeltas - 1) > 0) { sei_read_code(pDecodedMessageOutputStream, ceilLog2(bp.m_numCpbRemovalDelayDeltas), symbol, "cpb_removal_delay_delta_idx[i]"); @@ -814,10 +850,6 @@ void SEIReader::xParseSEIPictureTiming(SEIPictureTiming& sei, uint32_t payloadSi { sei.m_cpbRemovalDelayDeltaIdx[i] = 0; } -#else - sei_read_code(pDecodedMessageOutputStream, ceilLog2(bp.m_numCpbRemovalDelayDeltas), symbol, "cpb_removal_delay_delta_idx[i]"); - sei.m_cpbRemovalDelayDeltaIdx[i] = symbol; -#endif } else { @@ -828,11 +860,7 @@ void SEIReader::xParseSEIPictureTiming(SEIPictureTiming& sei, uint32_t payloadSi } sei_read_code( pDecodedMessageOutputStream, bp.m_dpbOutputDelayLength, symbol, "dpb_output_delay" ); sei.m_picDpbOutputDelay = symbol; -#if JVET_Q0221 if ( bp.m_bpDecodingUnitHrdParamsPresentFlag && bp.m_decodingUnitDpbDuParamsInPicTimingSeiFlag ) -#else - if (bp.m_bpDecodingUnitHrdParamsPresentFlag) -#endif { sei_read_code( pDecodedMessageOutputStream, bp.getDpbOutputDelayDuLength(), symbol, "pic_dpb_output_du_delay" ); sei.m_picDpbOutputDuDelay = symbol; @@ -874,17 +902,11 @@ void SEIReader::xParseSEIPictureTiming(SEIPictureTiming& sei, uint32_t payloadSi } } } -#if JVET_Q0818_PT_SEI sei_read_uvlc( pDecodedMessageOutputStream, symbol, "pt_display_elemental_periods_minus1" ); sei.m_ptDisplayElementalPeriodsMinus1 = symbol; -#endif } -#if JVET_Q0818_PT_SEI void SEIReader::xParseSEIFrameFieldinfo(SEIFrameFieldInfo& sei, const SEIPictureTiming& pt, uint32_t payloadSize, std::ostream *pDecodedMessageOutputStream) -#else -void SEIReader::xParseSEIFrameFieldinfo(SEIFrameFieldInfo& sei, uint32_t payloadSize, std::ostream *pDecodedMessageOutputStream) -#endif { output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); @@ -914,10 +936,8 @@ void SEIReader::xParseSEIFrameFieldinfo(SEIFrameFieldInfo& sei, uint32_t payload } sei_read_uvlc( pDecodedMessageOutputStream, symbol, "display_elemental_periods_minus1" ); sei.m_displayElementalPeriodsMinus1 = symbol; -#if JVET_Q0818_PT_SEI if( pt.m_ptDisplayElementalPeriodsMinus1 != sei.m_displayElementalPeriodsMinus1 ) msg( WARNING, "Warning: display_elemental_periods_minus1 is different in picture timing and frame field information SEI messages!"); -#endif } sei_read_code( pDecodedMessageOutputStream, 2, symbol, "source_scan_type" ); sei.m_sourceScanType = symbol; @@ -1178,7 +1198,7 @@ void SEIReader::xParseSEIOmniViewport(SEIOmniViewport& sei, uint32_t payloadSize if (!sei.m_omniViewportCancelFlag) { uint32_t numRegions; - sei_read_flag( pDecodedMessageOutputStream, code, "omni_viewport_persistence_flag" ); sei.m_omniViewportPersistenceFlag = code; + sei_read_flag( pDecodedMessageOutputStream, code, "omni_viewport_persistence_flag" ); sei.m_omniViewportPersistenceFlag = code; sei_read_code( pDecodedMessageOutputStream, 4, numRegions, "omni_viewport_cnt_minus1" ); numRegions++; sei.m_omniViewportRegions.resize(numRegions); for(uint32_t region=0; region<numRegions; region++) @@ -1189,7 +1209,7 @@ void SEIReader::xParseSEIOmniViewport(SEIOmniViewport& sei, uint32_t payloadSize sei_read_scode( pDecodedMessageOutputStream, 32, scode, "omni_viewport_tilt_centre" ); viewport.tiltCentre = code; sei_read_code( pDecodedMessageOutputStream, 32, code, "omni_viewport_hor_range" ); viewport.horRange = code; sei_read_code( pDecodedMessageOutputStream, 32, code, "omni_viewport_ver_range" ); viewport.verRange = code; - } + } } else { @@ -1300,39 +1320,19 @@ void SEIReader::xParseSEIGeneralizedCubemapProjection(SEIGeneralizedCubemapProje sei_read_flag( pDecodedMessageOutputStream, val, "gcmp_guard_band_flag" ); sei.m_gcmpGuardBandFlag = val; if (sei.m_gcmpGuardBandFlag) { -#if JVET_Q0343_GCMP_GUARD_BAND_TYPE sei_read_code( pDecodedMessageOutputStream, 3, val, "gcmp_guard_band_type" ); sei.m_gcmpGuardBandType = val; sei_read_flag( pDecodedMessageOutputStream, val, "gcmp_guard_band_boundary_exterior_flag" ); sei.m_gcmpGuardBandBoundaryExteriorFlag = val; sei_read_code( pDecodedMessageOutputStream, 4, val, "gcmp_guard_band_samples_minus1" ); sei.m_gcmpGuardBandSamplesMinus1 = val; -#else - sei_read_flag( pDecodedMessageOutputStream, val, "gcmp_guard_band_boundary_type" ); sei.m_gcmpGuardBandBoundaryType = val; - sei_read_code( pDecodedMessageOutputStream, 4, val, "gcmp_guard_band_samples_minus1" ); sei.m_gcmpGuardBandSamplesMinus1 = val; -#endif } } } -#if JVET_Q0630_SUBPIC_LEVEL void SEIReader::xParseSEISubpictureLevelInfo(SEISubpicureLevelInfo& sei, uint32_t payloadSize, std::ostream *pDecodedMessageOutputStream) -#else -void SEIReader::xParseSEISubpictureLevelInfo(SEISubpicureLevelInfo& sei, const SPS *sps, uint32_t payloadSize, std::ostream *pDecodedMessageOutputStream) -#endif { output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); -#if !JVET_Q0630_SUBPIC_LEVEL - if (sps == nullptr) - { - fprintf (stderr, "no SPS available, not parsing Subpicture level information SEI"); - return; - } -#endif uint32_t val; -#if !JVET_Q0630_SUBPIC_LEVEL - sei_read_code( pDecodedMessageOutputStream, 4, val, "sli_seq_parameter_set_id" ); sei.m_sliSeqParameterSetId = val; -#endif sei_read_code( pDecodedMessageOutputStream, 3, val, "num_ref_levels_minus1" ); sei.m_numRefLevels = val + 1; sei_read_flag( pDecodedMessageOutputStream, val, "explicit_fraction_present_flag" ); sei.m_explicitFractionPresentFlag = val; -#if JVET_Q0630_SUBPIC_LEVEL if (sei.m_explicitFractionPresentFlag) { sei_read_uvlc(pDecodedMessageOutputStream, val, "sli_num_subpics_minus1"); sei.m_numSubpics = val + 1; @@ -1341,7 +1341,6 @@ void SEIReader::xParseSEISubpictureLevelInfo(SEISubpicureLevelInfo& sei, const S sei_read_flag( pDecodedMessageOutputStream, val, "sli_alignment_zero_bit" ); CHECK (val != 0, "sli_alignment_zero_bit not equal to zero" ); } } -#endif sei.m_refLevelIdc.resize(sei.m_numRefLevels); if (sei.m_explicitFractionPresentFlag) @@ -1349,21 +1348,14 @@ void SEIReader::xParseSEISubpictureLevelInfo(SEISubpicureLevelInfo& sei, const S sei.m_refLevelFraction.resize(sei.m_numRefLevels); } - for( int i = 0; i < sei.m_numRefLevels; i++ ) + for( int i = 0; i < sei.m_numRefLevels; i++ ) { sei_read_code( pDecodedMessageOutputStream, 8, val, "ref_level_idc[i]" ); sei.m_refLevelIdc[i] = (Level::Name) val; if( sei.m_explicitFractionPresentFlag ) { -#if !JVET_Q0630_SUBPIC_LEVEL - int numSubPics = sps->getNumSubPics(); - sei.m_refLevelFraction[i].resize(numSubPics); - - for( int j = 0; j < numSubPics; j++ ) -#else sei.m_refLevelFraction[i].resize(sei.m_numSubpics); for( int j = 0; j < sei.m_numSubpics; j++ ) -#endif { sei_read_code( pDecodedMessageOutputStream, 8, val, "ref_level_fraction_minus1[i][j]" ); sei.m_refLevelFraction[i][j]= val; } @@ -1382,7 +1374,7 @@ void SEIReader::xParseSEISampleAspectRatioInfo(SEISampleAspectRatioInfo& sei, ui sei_read_flag( pDecodedMessageOutputStream, val, "sari_persistence_flag" ); sei.m_sariPersistenceFlag = val; sei_read_code( pDecodedMessageOutputStream, 8, val, "sari_aspect_ratio_idc" ); sei.m_sariAspectRatioIdc = val; if (sei.m_sariAspectRatioIdc == 255) - { + { sei_read_code( pDecodedMessageOutputStream, 16, val, "sari_sar_width" ); sei.m_sariSarWidth = val; sei_read_code( pDecodedMessageOutputStream, 16, val, "sari_sar_height" ); sei.m_sariSarHeight = val; } diff --git a/source/Lib/DecoderLib/SEIread.h b/source/Lib/DecoderLib/SEIread.h index 287c6a287a4ff297b82641f36d25ac84099e688e..00ca7647ccb440052368539dd9141c6aa24330c0 100644 --- a/source/Lib/DecoderLib/SEIread.h +++ b/source/Lib/DecoderLib/SEIread.h @@ -55,35 +55,17 @@ class SEIReader: public VLCReader public: SEIReader() {}; virtual ~SEIReader() {}; -#if JVET_P0125_SEI_CONSTRAINTS void parseSEImessage(InputBitstream* bs, SEIMessages& seis, const NalUnitType nalUnitType, const uint32_t nuh_layer_id, const uint32_t temporalId,const VPS *vps, const SPS *sps, HRD &hrd, std::ostream *pDecodedMessageOutputStream); -#else - void parseSEImessage(InputBitstream* bs, SEIMessages& seis, const NalUnitType nalUnitType, const uint32_t temporalId, const SPS *sps, HRD &hrd, std::ostream *pDecodedMessageOutputStream); -#endif protected: -#if JVET_P0125_SEI_CONSTRAINTS void xReadSEImessage (SEIMessages& seis, const NalUnitType nalUnitType, const uint32_t nuh_layer_id, const uint32_t temporalId, const VPS *vps, const SPS *sps, HRD &hrd, std::ostream *pDecodedMessageOutputStream); -#else - void xReadSEImessage (SEIMessages& seis, const NalUnitType nalUnitType, const uint32_t temporalId, const SPS *sps, HRD &hrd, std::ostream *pDecodedMessageOutputStream); -#endif void xParseSEIuserDataUnregistered (SEIuserDataUnregistered &sei, uint32_t payloadSize, std::ostream *pDecodedMessageOutputStream); void xParseSEIDecodingUnitInfo (SEIDecodingUnitInfo& sei, uint32_t payloadSize, const SEIBufferingPeriod& bp, const uint32_t temporalId, std::ostream *pDecodedMessageOutputStream); void xParseSEIDecodedPictureHash (SEIDecodedPictureHash& sei, uint32_t payloadSize, std::ostream *pDecodedMessageOutputStream); void xParseSEIBufferingPeriod (SEIBufferingPeriod& sei, uint32_t payloadSize, std::ostream *pDecodedMessageOutputStream); void xParseSEIPictureTiming (SEIPictureTiming& sei, uint32_t payloadSize, const uint32_t temporalId, const SEIBufferingPeriod& bp, std::ostream *pDecodedMessageOutputStream); -#if JVET_P0190_SCALABLE_NESTING_SEI -#if JVET_P0125_SEI_CONSTRAINTS void xParseSEIScalableNesting (SEIScalableNesting& sei, const NalUnitType nalUnitType, const uint32_t nuh_layer_id, uint32_t payloadSize, const VPS *vps, const SPS *sps, std::ostream *pDecodedMessageOutputStream); -#else - void xParseSEIScalableNesting (SEIScalableNesting& sei, const NalUnitType nalUnitType, uint32_t payloadSize, const SPS *sps, std::ostream *pDecodedMessageOutputStream); -#endif -#endif -#if JVET_Q0818_PT_SEI void xParseSEIFrameFieldinfo (SEIFrameFieldInfo& sei, const SEIPictureTiming& pt, uint32_t payloadSize, std::ostream *pDecodedMessageOutputStream); -#else - void xParseSEIFrameFieldinfo (SEIFrameFieldInfo& sei, uint32_t payloadSize, std::ostream *pDecodedMessageOutputStream); -#endif void xParseSEIDependentRAPIndication (SEIDependentRAPIndication& sei, uint32_t payLoadSize, std::ostream *pDecodedMessageOutputStream); void xParseSEIFramePacking (SEIFramePacking& sei, uint32_t payloadSize, std::ostream *pDecodedMessageOutputStream); void xParseSEIMasteringDisplayColourVolume (SEIMasteringDisplayColourVolume& sei, uint32_t payloadSize, std::ostream *pDecodedMessageOutputStream); @@ -95,11 +77,7 @@ protected: void xParseSEIOmniViewport (SEIOmniViewport& sei, uint32_t payloadSize, std::ostream *pDecodedMessageOutputStream); void xParseSEIRegionWisePacking (SEIRegionWisePacking& sei, uint32_t payloadSize, std::ostream *pDecodedMessageOutputStream); void xParseSEIGeneralizedCubemapProjection (SEIGeneralizedCubemapProjection &sei, uint32_t payloadSize, std::ostream *pDecodedMessageOutputStream); -#if JVET_Q0630_SUBPIC_LEVEL void xParseSEISubpictureLevelInfo (SEISubpicureLevelInfo& sei, uint32_t payloadSize, std::ostream *pDecodedMessageOutputStream); -#else - void xParseSEISubpictureLevelInfo (SEISubpicureLevelInfo& sei, const SPS *sps, uint32_t payloadSize, std::ostream *pDecodedMessageOutputStream); -#endif void xParseSEISampleAspectRatioInfo (SEISampleAspectRatioInfo& sei, uint32_t payloadSize, std::ostream *pDecodedMessageOutputStream); void xParseSEIUserDataRegistered (SEIUserDataRegistered& sei, uint32_t payloadSize, std::ostream *pDecodedMessageOutputStream); void xParseSEIFilmGrainCharacteristics (SEIFilmGrainCharacteristics& sei, uint32_t payloadSize, std::ostream *pDecodedMessageOutputStream); diff --git a/source/Lib/DecoderLib/VLCReader.cpp b/source/Lib/DecoderLib/VLCReader.cpp index c2fc987af58a328e328326f3b4482998063659ff..5daf1da72123363fe32be28105d9694061543da0 100644 --- a/source/Lib/DecoderLib/VLCReader.cpp +++ b/source/Lib/DecoderLib/VLCReader.cpp @@ -282,10 +282,6 @@ void FDReader::parseFillerData(InputBitstream* bs, uint32_t &fdSize) // ==================================================================================================================== HLSyntaxReader::HLSyntaxReader() -#if JVET_P0118_HRD_ASPECTS - : m_isFirstGeneralHrd(true) - , m_prevGeneralHrdParams(NULL) -#endif { } @@ -319,7 +315,11 @@ void HLSyntaxReader::copyRefPicList(SPS* sps, ReferencePictureList* source_rpl, } } +#if JVET_R0059_RPL_CLEANUP +void HLSyntaxReader::parseRefPicList(SPS* sps, ReferencePictureList* rpl, int rplIdx) +#else void HLSyntaxReader::parseRefPicList(SPS* sps, ReferencePictureList* rpl) +#endif { uint32_t code; READ_UVLC(code, "num_ref_entries[ listIdx ][ rplsIdx ]"); @@ -328,11 +328,21 @@ void HLSyntaxReader::parseRefPicList(SPS* sps, ReferencePictureList* rpl) uint32_t numLtrp = 0; uint32_t numIlrp = 0; +#if JVET_R0059_RPL_CLEANUP + if (sps->getLongTermRefsPresent() && rplIdx != -1) +#else if (sps->getLongTermRefsPresent()) +#endif { READ_FLAG(code, "ltrp_in_slice_header_flag[ listIdx ][ rplsIdx ]"); rpl->setLtrpInSliceHeaderFlag(code); } +#if JVET_R0059_RPL_CLEANUP + else if(sps->getLongTermRefsPresent()) + { + rpl->setLtrpInSliceHeaderFlag( 1 ); + } +#endif bool isLongTerm; int prevDelta = MAX_INT; @@ -371,7 +381,7 @@ void HLSyntaxReader::parseRefPicList(SPS* sps, ReferencePictureList* rpl) if (!isLongTerm) { READ_UVLC(code, "abs_delta_poc_st[ listIdx ][ rplsIdx ][ i ]"); - if( !sps->getUseWP() && !sps->getUseWPBiPred() ) + if ((!sps->getUseWP() && !sps->getUseWPBiPred()) || (ii == 0)) { code++; } @@ -417,21 +427,21 @@ void HLSyntaxReader::parsePPS( PPS* pcPPS ) uint32_t uiCode; int iCode; - +#if JVET_R0266_DESC + READ_CODE(6, uiCode, "pps_pic_parameter_set_id"); +#else READ_UVLC( uiCode, "pps_pic_parameter_set_id"); +#endif CHECK(uiCode > 63, "PPS id exceeds boundary (63)"); pcPPS->setPPSId (uiCode); READ_CODE(4, uiCode, "pps_seq_parameter_set_id"); pcPPS->setSPSId (uiCode); -#if SPS_ID_CHECK READ_FLAG( uiCode, "mixed_nalu_types_in_pic_flag" ); pcPPS->setMixedNaluTypesInPicFlag( uiCode == 1 ); -#endif READ_UVLC( uiCode, "pic_width_in_luma_samples" ); pcPPS->setPicWidthInLumaSamples( uiCode ); READ_UVLC( uiCode, "pic_height_in_luma_samples" ); pcPPS->setPicHeightInLumaSamples( uiCode ); -#if JVET_Q0260_CONFORMANCE_WINDOW_IN_SPS READ_FLAG(uiCode, "pps_conformance_window_flag"); if (uiCode != 0) { @@ -441,27 +451,22 @@ void HLSyntaxReader::parsePPS( PPS* pcPPS ) READ_UVLC(uiCode, "pps_conf_win_top_offset"); conf.setWindowTopOffset(uiCode); READ_UVLC(uiCode, "pps_conf_win_bottom_offset"); conf.setWindowBottomOffset(uiCode); } -#else - READ_FLAG( uiCode, "conformance_window_flag" ); - if( uiCode != 0 ) - { - Window &conf = pcPPS->getConformanceWindow(); - READ_UVLC( uiCode, "conf_win_left_offset" ); conf.setWindowLeftOffset( uiCode ); - READ_UVLC( uiCode, "conf_win_right_offset" ); conf.setWindowRightOffset( uiCode ); - READ_UVLC( uiCode, "conf_win_top_offset" ); conf.setWindowTopOffset( uiCode ); - READ_UVLC( uiCode, "conf_win_bottom_offset" ); conf.setWindowBottomOffset( uiCode ); - } -#endif READ_FLAG( uiCode, "scaling_window_flag" ); if( uiCode != 0 ) { Window &scalingWindow = pcPPS->getScalingWindow(); +#if JVET_R0114_NEGATIVE_SCALING_WINDOW_OFFSETS + READ_SVLC( iCode, "pps_scaling_win_left_offset" ); scalingWindow.setWindowLeftOffset( iCode ); + READ_SVLC( iCode, "pps_scaling_win_right_offset" ); scalingWindow.setWindowRightOffset( iCode ); + READ_SVLC( iCode, "pps_scaling_win_top_offset" ); scalingWindow.setWindowTopOffset( iCode ); + READ_SVLC( iCode, "pps_scaling_win_bottom_offset" ); scalingWindow.setWindowBottomOffset( iCode ); +#else READ_UVLC( uiCode, "scaling_win_left_offset" ); scalingWindow.setWindowLeftOffset( uiCode ); READ_UVLC( uiCode, "scaling_win_right_offset" ); scalingWindow.setWindowRightOffset( uiCode ); READ_UVLC( uiCode, "scaling_win_top_offset" ); scalingWindow.setWindowTopOffset( uiCode ); READ_UVLC( uiCode, "scaling_win_bottom_offset" ); scalingWindow.setWindowBottomOffset( uiCode ); +#endif } -#if JVET_Q0399_SCALING_INFERENCE else { Window &scalingWindow = pcPPS->getScalingWindow(); @@ -471,41 +476,41 @@ void HLSyntaxReader::parsePPS( PPS* pcPPS ) scalingWindow.setWindowTopOffset( conf.getWindowTopOffset() ); scalingWindow.setWindowBottomOffset( conf.getWindowBottomOffset() ); } -#endif READ_FLAG( uiCode, "output_flag_present_flag" ); pcPPS->setOutputFlagPresentFlag( uiCode==1 ); -#if JVET_Q0119_CLEANUPS +#if JVET_R0186_CLEANUP + READ_FLAG( uiCode, "pps_no_pic_partition_flag"); pcPPS->setNoPicPartitionFlag(uiCode == 1); +#endif READ_FLAG( uiCode, "subpic_id_mapping_in_pps_flag" ); pcPPS->setSubPicIdMappingInPpsFlag( uiCode != 0 ); if( pcPPS->getSubPicIdMappingInPpsFlag() ) -#else - READ_FLAG(uiCode, "pps_subpic_id_signalling_present_flag"); pcPPS->setSubPicIdSignallingPresentFlag( uiCode != 0 ); - if( pcPPS->getSubPicIdSignallingPresentFlag() ) -#endif { +#if JVET_R0186_CLEANUP + if( !pcPPS->getNoPicPartitionFlag() ) + { + READ_UVLC(uiCode, "pps_num_subpics_minus1"); pcPPS->setNumSubPics(uiCode + 1); + } + else + { + pcPPS->setNumSubPics(1); + } +#else READ_UVLC( uiCode, "pps_num_subpics_minus1" ); pcPPS->setNumSubPics( uiCode + 1 ); +#endif CHECK( uiCode > MAX_NUM_SUB_PICS-1, "Number of sub-pictures exceeds limit"); READ_UVLC( uiCode, "pps_subpic_id_len_minus1" ); pcPPS->setSubPicIdLen( uiCode + 1 ); CHECK( uiCode > 15, "Invalid pps_subpic_id_len_minus1 signalled"); -#if JVET_Q0169_SUBPIC_LEN_CONFORM CHECK((1 << pcPPS->getSubPicIdLen()) < pcPPS->getNumSubPics(), "pps_subpic_id_len exceeds valid range"); -#endif for( int picIdx = 0; picIdx < pcPPS->getNumSubPics( ); picIdx++ ) { READ_CODE( pcPPS->getSubPicIdLen( ), uiCode, "pps_subpic_id[i]" ); pcPPS->setSubPicId( picIdx, uiCode ); } } - else - { - for( int picIdx = 0; picIdx < MAX_NUM_SUB_PICS; picIdx++ ) - { - pcPPS->setSubPicId( picIdx, picIdx ); - } - } - +#if !JVET_R0186_CLEANUP READ_FLAG( uiCode, "no_pic_partition_flag" ); pcPPS->setNoPicPartitionFlag( uiCode == 1 ); +#endif if(!pcPPS->getNoPicPartitionFlag()) { int colIdx, rowIdx; @@ -514,53 +519,49 @@ void HLSyntaxReader::parsePPS( PPS* pcPPS ) // CTU size - required to match size in SPS READ_CODE(2, uiCode, "pps_log2_ctu_size_minus5"); pcPPS->setLog2CtuSize(uiCode + 5); CHECK(uiCode > 2, "pps_log2_ctu_size_minus5 must be less than or equal to 2"); - + // number of explicit tile columns/rows READ_UVLC( uiCode, "num_exp_tile_columns_minus1" ); pcPPS->setNumExpTileColumns( uiCode + 1 ); READ_UVLC( uiCode, "num_exp_tile_rows_minus1" ); pcPPS->setNumExpTileRows( uiCode + 1 ); CHECK(pcPPS->getNumExpTileColumns() > MAX_TILE_COLS, "Number of explicit tile columns exceeds valid range"); CHECK(pcPPS->getNumExpTileRows() > MAX_TILE_ROWS, "Number of explicit tile rows exceeds valid range"); - + // tile sizes for( colIdx = 0; colIdx < pcPPS->getNumExpTileColumns(); colIdx++ ) { READ_UVLC( uiCode, "tile_column_width_minus1[i]" ); pcPPS->addTileColumnWidth( uiCode + 1 ); -#if JVET_Q0359_TILE_SIZE_CONSTRAINT CHECK(uiCode > (pcPPS->getPicWidthInCtu()-1), "The value of tile_column_width_minus1[i] shall be in the range of 0 to PicWidthInCtbY-1, inclusive"); -#endif } for( rowIdx = 0; rowIdx < pcPPS->getNumExpTileRows(); rowIdx++ ) { READ_UVLC( uiCode, "tile_row_height_minus1[i]" ); pcPPS->addTileRowHeight( uiCode + 1 ); -#if JVET_Q0359_TILE_SIZE_CONSTRAINT CHECK(uiCode > (pcPPS->getPicHeightInCtu() - 1), "The value of tile_row_height_minus shall be in the range of 0 to PicHeightInCtbY-1, inclusive"); -#endif } pcPPS->initTiles(); // rectangular slice signalling -#if JVET_Q0289_BUGFIX_RECT_SLICE_FLAG if (pcPPS->getNumTiles() > 1) { +#if JVET_R0113_AND_JVET_R0106_PPS_CLEANUP + READ_CODE(1, uiCode, "pps_loop_filter_across_tiles_enabled_flag"); pcPPS->setLoopFilterAcrossTilesEnabledFlag(uiCode == 1); +#endif READ_CODE(1, uiCode, "rect_slice_flag"); } else { +#if JVET_R0113_AND_JVET_R0106_PPS_CLEANUP + pcPPS->setLoopFilterAcrossTilesEnabledFlag(true); +#endif uiCode = 1; } pcPPS->setRectSliceFlag(uiCode == 1); -#else - READ_CODE(1, uiCode, "rect_slice_flag"); pcPPS->setRectSliceFlag( uiCode == 1 ); -#endif - if (pcPPS->getRectSliceFlag()) + if (pcPPS->getRectSliceFlag()) { READ_FLAG(uiCode, "single_slice_per_subpic_flag"); pcPPS->setSingleSlicePerSubPicFlag(uiCode == 1); } -#if JVET_Q0218_PROPOSAL3 else { pcPPS->setSingleSlicePerSubPicFlag(0); } -#endif if (pcPPS->getRectSliceFlag() & !(pcPPS->getSingleSlicePerSubPicFlag())) { int32_t tileIdx = 0; @@ -568,7 +569,6 @@ void HLSyntaxReader::parsePPS( PPS* pcPPS ) READ_UVLC( uiCode, "num_slices_in_pic_minus1" ); pcPPS->setNumSlicesInPic( uiCode + 1 ); CHECK(pcPPS->getNumSlicesInPic() > MAX_SLICES, "Number of slices in picture exceeds valid range"); -#if JVET_Q0218_PROPOSAL1 if ((pcPPS->getNumSlicesInPic() - 1) > 0) { READ_CODE(1, uiCode, "tile_idx_delta_present_flag"); @@ -578,52 +578,35 @@ void HLSyntaxReader::parsePPS( PPS* pcPPS ) { pcPPS->setTileIdxDeltaPresentFlag(0); } -#else - READ_CODE(1, uiCode, "tile_idx_delta_present_flag"); - pcPPS->setTileIdxDeltaPresentFlag(uiCode == 1); -#endif pcPPS->initRectSlices(); - + // read rectangular slice parameters for( int i = 0; i < pcPPS->getNumSlicesInPic()-1; i++ ) { pcPPS->setSliceTileIdx( i, tileIdx ); // complete tiles within a single slice -#if JVET_Q0244 uiCode = 0; if( pcPPS->getNumTileColumns() > 1 ) { READ_UVLC( uiCode, "slice_width_in_tiles_minus1[i]" ); } pcPPS->setSliceWidthInTiles ( i, uiCode + 1 ); -#else - READ_UVLC( uiCode, "slice_width_in_tiles_minus1[i]" ); pcPPS->setSliceWidthInTiles ( i, uiCode + 1 ); -#endif -#if JVET_Q0480_RASTER_RECT_SLICES if( pcPPS->getTileIdxDeltaPresentFlag() || ( (tileIdx % pcPPS->getNumTileColumns()) == 0 ) ) { -#if JVET_Q0244 uiCode = 0; if( pcPPS->getNumTileRows() > 1 ) { READ_UVLC( uiCode, "slice_height_in_tiles_minus1[i]" ); } pcPPS->setSliceHeightInTiles( i, uiCode + 1 ); -#else - READ_UVLC( uiCode, "slice_height_in_tiles_minus1[i]" ); pcPPS->setSliceHeightInTiles( i, uiCode + 1 ); -#endif } - else + else { pcPPS->setSliceHeightInTiles( i, pcPPS->getSliceHeightInTiles(i-1) ); } -#else - READ_UVLC( uiCode, "slice_height_in_tiles_minus1[i]" ); pcPPS->setSliceHeightInTiles( i, uiCode + 1 ); -#endif // multiple slices within a single tile special case -#if JVET_Q0203_MULTI_SLICE_IN_TILE if( pcPPS->getSliceWidthInTiles(i) == 1 && pcPPS->getSliceHeightInTiles(i) == 1 ) { if( pcPPS->getTileRowHeight(tileIdx / pcPPS->getNumTileColumns()) > 1 ) @@ -675,27 +658,11 @@ void HLSyntaxReader::parsePPS( PPS* pcPPS ) pcPPS->setSliceHeightInCtu(i, pcPPS->getTileRowHeight(tileIdx / pcPPS->getNumTileColumns())); } } -#else - if( pcPPS->getSliceWidthInTiles( i ) == 1 && pcPPS->getSliceHeightInTiles( i ) == 1 ) - { - READ_UVLC( uiCode, "num_slices_in_tile_minus1[i]" ); pcPPS->setNumSlicesInTile( i, uiCode + 1 ); - uint32_t numSlicesInTile = pcPPS->getNumSlicesInTile( i ); - for( int j = 0; j < numSlicesInTile-1; j++ ) - { - READ_UVLC( uiCode, "slice_height_in_ctu_minus1[i]" ); pcPPS->setSliceHeightInCtu( i, uiCode + 1 ); - i++; - pcPPS->setSliceWidthInTiles ( i, 1 ); - pcPPS->setSliceHeightInTiles( i, 1 ); - pcPPS->setNumSlicesInTile ( i, numSlicesInTile ); - pcPPS->setSliceTileIdx ( i, tileIdx ); - } - } -#endif // tile index offset to start of next slice if( i < pcPPS->getNumSlicesInPic()-1 ) { - if( pcPPS->getTileIdxDeltaPresentFlag() ) + if( pcPPS->getTileIdxDeltaPresentFlag() ) { int32_t tileIdxDelta; READ_SVLC( tileIdxDelta, "tile_idx_delta[i]" ); @@ -713,19 +680,32 @@ void HLSyntaxReader::parsePPS( PPS* pcPPS ) } } pcPPS->setSliceTileIdx(pcPPS->getNumSlicesInPic()-1, tileIdx ); - - // initialize mapping between rectangular slices and CTUs - pcPPS->initRectSliceMap(); } +#if !JVET_R0113_AND_JVET_R0106_PPS_CLEANUP // loop filtering across slice/tile controls READ_CODE(1, uiCode, "loop_filter_across_tiles_enabled_flag"); pcPPS->setLoopFilterAcrossTilesEnabledFlag( uiCode == 1 ); - READ_CODE(1, uiCode, "loop_filter_across_slices_enabled_flag"); pcPPS->setLoopFilterAcrossSlicesEnabledFlag( uiCode == 1 ); +#endif +#if JVET_R0247_PPS_LP_FTR_ACROSS_SLICES_FLAG_CLEANUP + if (pcPPS->getRectSliceFlag() == 0 || pcPPS->getSingleSlicePerSubPicFlag() || pcPPS->getNumSlicesInPic() > 1) + { +#endif + READ_CODE(1, uiCode, "loop_filter_across_slices_enabled_flag"); pcPPS->setLoopFilterAcrossSlicesEnabledFlag( uiCode == 1 ); +#if JVET_R0247_PPS_LP_FTR_ACROSS_SLICES_FLAG_CLEANUP + } + else + { + pcPPS->setLoopFilterAcrossSlicesEnabledFlag( false ); + } +#endif + } +#if JVET_R0071_SPS_PPS_CELANUP + else + { + pcPPS->setSingleSlicePerSubPicFlag(1); } - -#if !JVET_Q0151_Q0205_ENTRYPOINTS - READ_FLAG(uiCode, "entropy_coding_sync_enabled_flag"); pcPPS->setEntropyCodingSyncEnabledFlag(uiCode == 1); #endif + READ_FLAG( uiCode, "cabac_init_present_flag" ); pcPPS->setCabacInitPresentFlag( uiCode ? true : false ); READ_UVLC(uiCode, "num_ref_idx_l0_default_active_minus1"); @@ -741,17 +721,11 @@ void HLSyntaxReader::parsePPS( PPS* pcPPS ) READ_SVLC(iCode, "init_qp_minus26" ); pcPPS->setPicInitQPMinus26(iCode); -#if !JVET_Q0183_SPS_TRANSFORM_SKIP_MODE_CONTROL - READ_UVLC(uiCode, "log2_transform_skip_max_size_minus2"); - pcPPS->setLog2MaxTransformSkipBlockSize(uiCode + 2); -#endif READ_FLAG( uiCode, "cu_qp_delta_enabled_flag" ); pcPPS->setUseDQP( uiCode ? true : false ); -#if JVET_Q0420_PPS_CHROMA_TOOL_FLAG READ_FLAG(uiCode, "pps_chroma_tool_offsets_present_flag"); pcPPS->setPPSChromaToolFlag(uiCode ? true : false); if (pcPPS->getPPSChromaToolFlag()) { -#endif READ_SVLC( iCode, "pps_cb_qp_offset"); pcPPS->setQpOffset(COMPONENT_Cb, iCode); CHECK( pcPPS->getQpOffset(COMPONENT_Cb) < -12, "Invalid Cb QP offset" ); @@ -817,7 +791,6 @@ void HLSyntaxReader::parsePPS( PPS* pcPPS ) } CHECK(pcPPS->getChromaQpOffsetListLen() != tableSizeMinus1 + 1, "Invalid chroma QP offset list length"); } -#if JVET_Q0420_PPS_CHROMA_TOOL_FLAG } else { @@ -827,7 +800,6 @@ void HLSyntaxReader::parsePPS( PPS* pcPPS ) pcPPS->setSliceChromaQpFlag(0); pcPPS->clearChromaQpOffsetList(); } -#endif READ_FLAG( uiCode, "weighted_pred_flag" ); // Use of Weighting Prediction (P_SLICE) pcPPS->setUseWP( uiCode==1 ); @@ -839,9 +811,19 @@ void HLSyntaxReader::parsePPS( PPS* pcPPS ) { READ_FLAG( uiCode, "deblocking_filter_override_enabled_flag" ); pcPPS->setDeblockingFilterOverrideEnabledFlag( uiCode ? true : false ); READ_FLAG( uiCode, "pps_deblocking_filter_disabled_flag" ); pcPPS->setPPSDeblockingFilterDisabledFlag(uiCode ? true : false ); +#if JVET_R0113_AND_JVET_R0106_PPS_CLEANUP + if (!pcPPS->getNoPicPartitionFlag() && pcPPS->getDeblockingFilterOverrideEnabledFlag()) + { + READ_FLAG(uiCode, "pps_dbf_info_in_ph_flag"); + pcPPS->setDbfInfoInPhFlag(uiCode ? true : false); + } + else + { + pcPPS->setDbfInfoInPhFlag(false); + } +#endif if(!pcPPS->getPPSDeblockingFilterDisabledFlag()) { -#if JVET_Q0121_DEBLOCKING_CONTROL_PARAMETERS READ_SVLC( iCode, "pps_beta_offset_div2" ); pcPPS->setDeblockingFilterBetaOffsetDiv2( iCode ); CHECK( pcPPS->getDeblockingFilterBetaOffsetDiv2() < -12 || pcPPS->getDeblockingFilterBetaOffsetDiv2() > 12, "Invalid deblocking filter configuration" ); @@ -865,18 +847,41 @@ void HLSyntaxReader::parsePPS( PPS* pcPPS ) READ_SVLC( iCode, "pps_cr_tc_offset_div2"); pcPPS->setDeblockingFilterCrTcOffsetDiv2( iCode ); CHECK( pcPPS->getDeblockingFilterCrTcOffsetDiv2() < -12 || pcPPS->getDeblockingFilterCrTcOffsetDiv2() > 12, "Invalid deblocking filter configuration" ); -#else - READ_SVLC ( iCode, "pps_beta_offset_div2" ); pcPPS->setDeblockingFilterBetaOffsetDiv2( iCode ); - READ_SVLC ( iCode, "pps_tc_offset_div2" ); pcPPS->setDeblockingFilterTcOffsetDiv2( iCode ); -#endif } } else { pcPPS->setDeblockingFilterOverrideEnabledFlag(false); +#if JVET_R0113_AND_JVET_R0106_PPS_CLEANUP + pcPPS->setDbfInfoInPhFlag(false); +#endif } -#if JVET_Q0819_PH_CHANGES +#if JVET_R0113_AND_JVET_R0106_PPS_CLEANUP + if (!pcPPS->getNoPicPartitionFlag()) + { + READ_FLAG(uiCode, "pps_rpl_info_in_ph_flag"); pcPPS->setRplInfoInPhFlag(uiCode ? true : false); + READ_FLAG(uiCode, "pps_sao_info_in_ph_flag"); pcPPS->setSaoInfoInPhFlag(uiCode ? true : false); + READ_FLAG(uiCode, "pps_alf_info_in_ph_flag"); pcPPS->setAlfInfoInPhFlag(uiCode ? true : false); + if ((pcPPS->getUseWP() || pcPPS->getWPBiPred()) && pcPPS->getRplInfoInPhFlag()) + { + READ_FLAG(uiCode, "pps_wp_info_in_ph_flag"); pcPPS->setWpInfoInPhFlag(uiCode ? true : false); + } + else + { + pcPPS->setWpInfoInPhFlag(false); + } + READ_FLAG(uiCode, "pps_qp_delta_info_in_ph_flag"); pcPPS->setQpDeltaInfoInPhFlag(uiCode ? true : false); + } + else + { + pcPPS->setRplInfoInPhFlag(false); + pcPPS->setSaoInfoInPhFlag(false); + pcPPS->setAlfInfoInPhFlag(false); + pcPPS->setWpInfoInPhFlag(false); + pcPPS->setQpDeltaInfoInPhFlag(false); + } +#else READ_FLAG(uiCode, "rpl_info_in_ph_flag"); pcPPS->setRplInfoInPhFlag(uiCode ? true : false); if( pcPPS->getDeblockingFilterOverrideEnabledFlag() ) { @@ -896,37 +901,6 @@ void HLSyntaxReader::parsePPS( PPS* pcPPS ) READ_FLAG(uiCode, "qp_delta_info_in_ph_flag"); pcPPS->setQpDeltaInfoInPhFlag(uiCode ? true : false); #endif -#if !JVET_Q0482_REMOVE_CONSTANT_PARAMS - READ_FLAG( uiCode, "constant_slice_header_params_enabled_flag"); pcPPS->setConstantSliceHeaderParamsEnabledFlag(uiCode); - if ( pcPPS->getConstantSliceHeaderParamsEnabledFlag() ) { - READ_CODE( 2, uiCode, "pps_dep_quant_enabled_idc"); pcPPS->setPPSDepQuantEnabledIdc(uiCode); - READ_CODE( 2, uiCode, "pps_ref_pic_list_sps_idc[0]"); pcPPS->setPPSRefPicListSPSIdc0(uiCode); - READ_CODE( 2, uiCode, "pps_ref_pic_list_sps_idc[1]"); pcPPS->setPPSRefPicListSPSIdc1(uiCode); - READ_CODE( 2, uiCode, "pps_mvd_l1_zero_idc"); pcPPS->setPPSMvdL1ZeroIdc(uiCode); - READ_CODE( 2, uiCode, "pps_collocated_from_l0_idc"); pcPPS->setPPSCollocatedFromL0Idc(uiCode); - READ_UVLC( uiCode, "pps_six_minus_max_num_merge_cand_plus1"); pcPPS->setPPSSixMinusMaxNumMergeCandPlus1(uiCode); -#if !JVET_Q0806 - READ_UVLC( uiCode, "pps_max_num_merge_cand_minus_max_num_triangle_cand_plus1");pcPPS->setPPSMaxNumMergeCandMinusMaxNumTriangleCandPlus1(uiCode); -#else - READ_UVLC(uiCode, "pps_max_num_merge_cand_minus_max_num_gpm_cand_plus1"); pcPPS->setPPSMaxNumMergeCandMinusMaxNumGeoCandPlus1(uiCode); -#endif - } - else - { - pcPPS->setPPSDepQuantEnabledIdc(0); - pcPPS->setPPSRefPicListSPSIdc0(0); - pcPPS->setPPSRefPicListSPSIdc1(0); - pcPPS->setPPSMvdL1ZeroIdc(0); - pcPPS->setPPSCollocatedFromL0Idc(0); - pcPPS->setPPSSixMinusMaxNumMergeCandPlus1(0); -#if !JVET_Q0806 - pcPPS->setPPSMaxNumMergeCandMinusMaxNumTriangleCandPlus1(0); -#else - pcPPS->setPPSMaxNumMergeCandMinusMaxNumGeoCandPlus1(0); -#endif - } -#endif - READ_FLAG( uiCode, "picture_header_extension_present_flag"); pcPPS->setPictureHeaderExtensionPresentFlag(uiCode); @@ -937,63 +911,10 @@ void HLSyntaxReader::parsePPS( PPS* pcPPS ) READ_FLAG( uiCode, "pps_extension_present_flag"); if (uiCode) { -#if !REMOVE_PPS_REXT -#if ENABLE_TRACING || RExt__DECODER_DEBUG_BIT_STATISTICS - static const char *syntaxStrings[]={ "pps_range_extension_flag", - "pps_multilayer_extension_flag", - "pps_extension_6bits[0]", - "pps_extension_6bits[1]", - "pps_extension_6bits[2]", - "pps_extension_6bits[3]", - "pps_extension_6bits[4]", - "pps_extension_6bits[5]" }; -#endif - - bool pps_extension_flags[NUM_PPS_EXTENSION_FLAGS]; - for(int i=0; i<NUM_PPS_EXTENSION_FLAGS; i++) - { - READ_FLAG( uiCode, syntaxStrings[i] ); - pps_extension_flags[i] = uiCode!=0; - } - - bool bSkipTrailingExtensionBits=false; - for(int i=0; i<NUM_PPS_EXTENSION_FLAGS; i++) // loop used so that the order is determined by the enum. - { - if (pps_extension_flags[i]) - { - switch (PPSExtensionFlagIndex(i)) - { - case PPS_EXT__REXT: - { - PPSRExt &ppsRangeExtension = pcPPS->getPpsRangeExtension(); - CHECK(bSkipTrailingExtensionBits, "Invalid state"); - - READ_FLAG( uiCode, "cross_component_prediction_enabled_flag"); - ppsRangeExtension.setCrossComponentPredictionEnabledFlag(uiCode != 0); -#if !JVET_Q0441_SAO_MOD_12_BIT - READ_UVLC( uiCode, "log2_sao_offset_scale_luma"); - ppsRangeExtension.setLog2SaoOffsetScale(CHANNEL_TYPE_LUMA, uiCode); - READ_UVLC( uiCode, "log2_sao_offset_scale_chroma"); - ppsRangeExtension.setLog2SaoOffsetScale(CHANNEL_TYPE_CHROMA, uiCode); -#endif - } - break; - default: - bSkipTrailingExtensionBits=true; - break; - } - } - } - if (bSkipTrailingExtensionBits) - { -#endif while ( xMoreRbspData() ) { READ_FLAG( uiCode, "pps_extension_data_flag"); } -#if !REMOVE_PPS_REXT - } -#endif } xReadRbspTrailingBits(); } @@ -1046,7 +967,6 @@ void HLSyntaxReader::parseAlfAps( APS* aps ) READ_FLAG(code, "alf_chroma_new_filter"); param.newFilterFlag[CHANNEL_TYPE_CHROMA] = code; -#if JVET_Q0795_CCALF CcAlfFilterParam ccAlfParam = aps->getCcAlfAPSParam(); READ_FLAG(code, "alf_cc_cb_filter_signal_flag"); ccAlfParam.newCcAlfFilter[COMPONENT_Cb - 1] = code; @@ -1056,16 +976,11 @@ void HLSyntaxReader::parseAlfAps( APS* aps ) && ccAlfParam.newCcAlfFilter[COMPONENT_Cb - 1] == 0 && ccAlfParam.newCcAlfFilter[COMPONENT_Cr - 1] == 0, "bitstream conformance error: one of alf_luma_filter_signal_flag, alf_chroma_filter_signal_flag, " "alf_cross_component_cb_filter_signal_flag, and alf_cross_component_cr_filter_signal_flag shall be nonzero"); -#endif if (param.newFilterFlag[CHANNEL_TYPE_LUMA]) { READ_FLAG(code, "alf_luma_clip"); -#if JVET_Q0249_ALF_CHROMA_CLIPFLAG param.nonLinearFlag[CHANNEL_TYPE_LUMA] = code ? true : false; -#else - param.nonLinearFlag[CHANNEL_TYPE_LUMA][0] = code ? true : false; -#endif READ_UVLC(code, "alf_luma_num_filters_signalled_minus1"); param.numLumaFilters = code + 1; if (param.numLumaFilters > 1) @@ -1085,10 +1000,8 @@ void HLSyntaxReader::parseAlfAps( APS* aps ) } if (param.newFilterFlag[CHANNEL_TYPE_CHROMA]) { -#if JVET_Q0249_ALF_CHROMA_CLIPFLAG READ_FLAG(code, "alf_nonlinear_enable_flag_chroma"); param.nonLinearFlag[CHANNEL_TYPE_CHROMA] = code ? true : false; -#endif if( MAX_NUM_ALF_ALTERNATIVES_CHROMA > 1 ) READ_UVLC( code, "alf_chroma_num_alts_minus1" ); @@ -1099,15 +1012,10 @@ void HLSyntaxReader::parseAlfAps( APS* aps ) for( int altIdx=0; altIdx < param.numAlternativesChroma; ++altIdx ) { -#if !JVET_Q0249_ALF_CHROMA_CLIPFLAG - READ_FLAG(code, "alf_nonlinear_enable_flag_chroma"); - param.nonLinearFlag[CHANNEL_TYPE_CHROMA][altIdx] = code ? true : false; -#endif alfFilter( param, true, altIdx ); } } -#if JVET_Q0795_CCALF for (int ccIdx = 0; ccIdx < 2; ccIdx++) { if (ccAlfParam.newCcAlfFilter[ccIdx]) @@ -1160,7 +1068,6 @@ void HLSyntaxReader::parseAlfAps( APS* aps ) } } aps->setCcAlfAPSParam(ccAlfParam); -#endif aps->setAlfAPSParam(param); } @@ -1204,7 +1111,6 @@ void HLSyntaxReader::parseScalingListAps( APS* aps ) parseScalingList( &info ); } -#if JVET_Q0042_VUI void HLSyntaxReader::parseVUI(VUI* pcVUI, SPS *pcSPS) { #if ENABLE_TRACING @@ -1214,6 +1120,10 @@ void HLSyntaxReader::parseVUI(VUI* pcVUI, SPS *pcSPS) uint32_t symbol; +#if JVET_R0090_VUI + READ_FLAG(symbol, "vui_general_progressive_source_flag" ); pcVUI->setProgressiveSourceFlag(symbol ? true : false); + READ_FLAG(symbol, "vui_general_interlaced_source_flag" ); pcVUI->setInterlacedSourceFlag(symbol ? true : false); +#endif READ_FLAG( symbol, "vui_aspect_ratio_info_present_flag"); pcVUI->setAspectRatioInfoPresentFlag(symbol); if (pcVUI->getAspectRatioInfoPresentFlag()) { @@ -1244,12 +1154,16 @@ void HLSyntaxReader::parseVUI(VUI* pcVUI, SPS *pcSPS) READ_FLAG( symbol, "vui_chroma_loc_info_present_flag"); pcVUI->setChromaLocInfoPresentFlag(symbol); if (pcVUI->getChromaLocInfoPresentFlag()) { - if(pcSPS->getProfileTierLevel()->getConstraintInfo()->getProgressiveSourceFlag() && +#if JVET_R0090_VUI + if(pcVUI->getProgressiveSourceFlag() && !pcVUI->getInterlacedSourceFlag()) +#else + if(pcSPS->getProfileTierLevel()->getConstraintInfo()->getProgressiveSourceFlag() && !pcSPS->getProfileTierLevel()->getConstraintInfo()->getInterlacedSourceFlag()) +#endif { READ_UVLC( symbol, "vui_chroma_sample_loc_type" ); pcVUI->setChromaSampleLocType(symbol); } - else + else { READ_UVLC( symbol, "vui_chroma_sample_loc_type_top_field" ); pcVUI->setChromaSampleLocTypeTopField(symbol); READ_UVLC( symbol, "vui_chroma_sample_loc_type_bottom_field" ); pcVUI->setChromaSampleLocTypeBottomField(symbol); @@ -1257,62 +1171,7 @@ void HLSyntaxReader::parseVUI(VUI* pcVUI, SPS *pcSPS) } } -#else -void HLSyntaxReader::parseVUI(VUI* pcVUI, SPS *pcSPS) -{ -#if ENABLE_TRACING - DTRACE( g_trace_ctx, D_HEADER, "----------- vui_parameters -----------\n"); -#endif - - - uint32_t symbol; - - READ_FLAG( symbol, "aspect_ratio_info_present_flag"); pcVUI->setAspectRatioInfoPresentFlag(symbol); - if (pcVUI->getAspectRatioInfoPresentFlag()) - { - READ_FLAG( symbol, "aspect_ratio_constant_flag"); pcVUI->setAspectRatioConstantFlag(symbol); - READ_CODE(8, symbol, "aspect_ratio_idc"); pcVUI->setAspectRatioIdc(symbol); - if (pcVUI->getAspectRatioIdc() == 255) - { - READ_CODE(16, symbol, "sar_width"); pcVUI->setSarWidth(symbol); - READ_CODE(16, symbol, "sar_height"); pcVUI->setSarHeight(symbol); - } - } - - READ_FLAG( symbol, "colour_description_present_flag"); pcVUI->setColourDescriptionPresentFlag(symbol); - if (pcVUI->getColourDescriptionPresentFlag()) - { - READ_CODE(8, symbol, "colour_primaries"); pcVUI->setColourPrimaries(symbol); - READ_CODE(8, symbol, "transfer_characteristics"); pcVUI->setTransferCharacteristics(symbol); - READ_CODE(8, symbol, "matrix_coeffs"); pcVUI->setMatrixCoefficients(symbol); - READ_FLAG( symbol, "video_full_range_flag"); pcVUI->setVideoFullRangeFlag(symbol); - } - - READ_FLAG( symbol, "field_seq_flag"); pcVUI->setFieldSeqFlag(symbol); - - READ_FLAG( symbol, "chroma_loc_info_present_flag"); pcVUI->setChromaLocInfoPresentFlag(symbol); - if (pcVUI->getChromaLocInfoPresentFlag()) - { - if(pcVUI->getFieldSeqFlag()) - { - READ_UVLC( symbol, "chroma_sample_loc_type_top_field" ); pcVUI->setChromaSampleLocTypeTopField(symbol); - READ_UVLC( symbol, "chroma_sample_loc_type_bottom_field" ); pcVUI->setChromaSampleLocTypeBottomField(symbol); - } - else - { - READ_UVLC( symbol, "chroma_sample_loc_type" ); pcVUI->setChromaSampleLocType(symbol); - } - } - - READ_FLAG( symbol, "overscan_info_present_flag"); pcVUI->setOverscanInfoPresentFlag(symbol); - if (pcVUI->getOverscanInfoPresentFlag()) - { - READ_FLAG( symbol, "overscan_appropriate_flag"); pcVUI->setOverscanAppropriateFlag(symbol); - } -} -#endif -#if JVET_P0118_HRD_ASPECTS void HLSyntaxReader::parseGeneralHrdParameters(GeneralHrdParams *hrd) { uint32_t symbol; @@ -1321,7 +1180,7 @@ void HLSyntaxReader::parseGeneralHrdParameters(GeneralHrdParams *hrd) READ_FLAG(symbol, "general_nal_hrd_parameters_present_flag"); hrd->setGeneralNalHrdParametersPresentFlag(symbol == 1 ? true : false); READ_FLAG(symbol, "general_vcl_hrd_parameters_present_flag"); hrd->setGeneralVclHrdParametersPresentFlag(symbol == 1 ? true : false); CHECK((hrd->getGeneralNalHrdParametersPresentFlag() == 0) && (hrd->getGeneralVclHrdParametersPresentFlag() == 0), "general_nal_hrd_params_present_flag and general_vcl_hrd_params_present_flag in each general_hrd_parameters( ) syntax structure shall not be both equal to 0."); - READ_FLAG(symbol, "general_same_pic_timing_in_all_ols_flag"); hrd->setGeneralSamPicTimingInAllOlsFlag(symbol == 1 ? true : false); + READ_FLAG(symbol, "general_same_pic_timing_in_all_ols_flag"); hrd->setGeneralSamePicTimingInAllOlsFlag(symbol == 1 ? true : false); READ_FLAG(symbol, "general_decoding_unit_hrd_params_present_flag"); hrd->setGeneralDecodingUnitHrdParamsPresentFlag(symbol == 1 ? true : false); if (hrd->getGeneralDecodingUnitHrdParamsPresentFlag()) { @@ -1335,61 +1194,13 @@ void HLSyntaxReader::parseGeneralHrdParameters(GeneralHrdParams *hrd) } READ_UVLC(symbol, "hrd_cpb_cnt_minus1"); hrd->setHrdCpbCntMinus1(symbol); CHECK(symbol > 31,"The value of hrd_cpb_cnt_minus1 shall be in the range of 0 to 31, inclusive"); - if (!m_isFirstGeneralHrd) - { - checkGeneralHrdParametersIdentical(hrd); - } - m_prevGeneralHrdParams = hrd; - m_isFirstGeneralHrd = false; -} -void HLSyntaxReader::checkGeneralHrdParametersIdentical(GeneralHrdParams *generalHrd) -{ - bool isIdentical = true; - if ( (generalHrd->getNumUnitsInTick()!= m_prevGeneralHrdParams->getNumUnitsInTick()) - || (generalHrd->getTimeScale()!= m_prevGeneralHrdParams->getTimeScale()) - || (generalHrd->getGeneralNalHrdParametersPresentFlag()!= m_prevGeneralHrdParams->getGeneralNalHrdParametersPresentFlag()) - || (generalHrd->getGeneralVclHrdParametersPresentFlag()!= m_prevGeneralHrdParams->getGeneralVclHrdParametersPresentFlag()) - || (generalHrd->getGeneralSamPicTimingInAllOlsFlag()!= m_prevGeneralHrdParams->getGeneralSamPicTimingInAllOlsFlag()) - || (generalHrd->getGeneralDecodingUnitHrdParamsPresentFlag()!= m_prevGeneralHrdParams->getGeneralDecodingUnitHrdParamsPresentFlag()) - || (generalHrd->getTickDivisorMinus2()!= m_prevGeneralHrdParams->getTickDivisorMinus2()) - || (generalHrd->getBitRateScale()!= m_prevGeneralHrdParams->getBitRateScale()) - || (generalHrd->getCpbSizeScale()!= m_prevGeneralHrdParams->getCpbSizeScale()) - || (generalHrd->getCpbSizeDuScale()!= m_prevGeneralHrdParams->getCpbSizeDuScale()) - || (generalHrd->getHrdCpbCntMinus1()!= m_prevGeneralHrdParams->getHrdCpbCntMinus1()) - ) - { - isIdentical = false; - } - CHECK(!isIdentical, "It is a requirement of bitstream conformance that the content of the general_hrd_parameters( ) syntax structure present in any VPSs or SPSs in the bitstream shall be identical"); } -#endif -#if JVET_P0118_HRD_ASPECTS void HLSyntaxReader::parseOlsHrdParameters(GeneralHrdParams * generalHrd, OlsHrdParams *olsHrd, uint32_t firstSubLayer, uint32_t maxNumSubLayersMinus1) { uint32_t symbol; -#else -void HLSyntaxReader::parseHrdParameters(HRDParameters *hrd, uint32_t firstSubLayer, uint32_t maxNumSubLayersMinus1) -{ - uint32_t symbol; - READ_FLAG( symbol, "general_nal_hrd_parameters_present_flag" ); hrd->setNalHrdParametersPresentFlag( symbol == 1 ? true : false ); - READ_FLAG( symbol, "general_vcl_hrd_parameters_present_flag" ); hrd->setVclHrdParametersPresentFlag( symbol == 1 ? true : false ); - READ_FLAG( symbol, "general_decoding_unit_hrd_params_present_flag" ); hrd->setGeneralDecodingUnitHrdParamsPresentFlag( symbol == 1 ? true : false ); - - if( hrd->getGeneralDecodingUnitHrdParamsPresentFlag() ) - { - READ_CODE( 8, symbol, "tick_divisor_minus2" ); hrd->setTickDivisorMinus2( symbol ); - } - READ_CODE( 4, symbol, "bit_rate_scale" ); hrd->setBitRateScale( symbol ); - READ_CODE( 4, symbol, "cpb_size_scale" ); hrd->setCpbSizeScale( symbol ); - if( hrd->getGeneralDecodingUnitHrdParamsPresentFlag() ) - { - READ_CODE( 4, symbol, "cpb_size_du_scale" ); hrd->setCpbSizeDuScale( symbol ); - } -#endif for( int i = firstSubLayer; i <= maxNumSubLayersMinus1; i ++ ) { -#if JVET_P0118_HRD_ASPECTS OlsHrdParams *hrd = &(olsHrd[i]); READ_FLAG(symbol, "fixed_pic_rate_general_flag"); hrd->setFixedPicRateGeneralFlag(symbol == 1 ? true : false); if (!hrd->getFixedPicRateGeneralFlag()) @@ -1411,69 +1222,27 @@ void HLSyntaxReader::parseHrdParameters(HRDParameters *hrd, uint32_t firstSubLay { READ_FLAG(symbol, "low_delay_hrd_flag"); hrd->setLowDelayHrdFlag(symbol == 1 ? true : false); } -#else - READ_FLAG( symbol, "fixed_pic_rate_general_flag" ); hrd->setFixedPicRateFlag( i, symbol == 1 ? true : false ); - if( !hrd->getFixedPicRateFlag( i ) ) - { - READ_FLAG( symbol, "fixed_pic_rate_within_cvs_flag" ); hrd->setFixedPicRateWithinCvsFlag( i, symbol == 1 ? true : false ); - } - else - { - hrd->setFixedPicRateWithinCvsFlag( i, true ); - } - - hrd->setLowDelayHrdFlag( i, false ); // Inferred to be 0 when not present - hrd->setCpbCntMinus1 ( i, 0 ); // Inferred to be 0 when not present - - if( hrd->getFixedPicRateWithinCvsFlag( i ) ) - { - READ_UVLC( symbol, "elemental_duration_in_tc_minus1" ); hrd->setPicDurationInTcMinus1( i, symbol ); - } - else - { - READ_FLAG( symbol, "low_delay_hrd_flag" ); hrd->setLowDelayHrdFlag( i, symbol == 1 ? true : false ); - } - if (!hrd->getLowDelayHrdFlag( i )) - { - READ_UVLC( symbol, "cpb_cnt_minus1" ); hrd->setCpbCntMinus1( i, symbol ); - } -#endif for( int nalOrVcl = 0; nalOrVcl < 2; nalOrVcl ++ ) { -#if JVET_P0118_HRD_ASPECTS if (((nalOrVcl == 0) && (generalHrd->getGeneralNalHrdParametersPresentFlag())) || ((nalOrVcl == 1) && (generalHrd->getGeneralVclHrdParametersPresentFlag()))) { for (int j = 0; j <= (generalHrd->getHrdCpbCntMinus1()); j++) { READ_UVLC(symbol, "bit_rate_value_minus1"); hrd->setBitRateValueMinus1(j, nalOrVcl, symbol); READ_UVLC(symbol, "cpb_size_value_minus1"); hrd->setCpbSizeValueMinus1(j, nalOrVcl, symbol); -#else - if( ( ( nalOrVcl == 0 ) && ( hrd->getNalHrdParametersPresentFlag() ) ) || - ( ( nalOrVcl == 1 ) && ( hrd->getVclHrdParametersPresentFlag() ) ) ) - { - for( int j = 0; j <= ( hrd->getCpbCntMinus1( i ) ); j ++ ) - { - READ_UVLC( symbol, "bit_rate_value_minus1" ); hrd->setBitRateValueMinus1( i, j, nalOrVcl, symbol ); - READ_UVLC( symbol, "cpb_size_value_minus1" ); hrd->setCpbSizeValueMinus1( i, j, nalOrVcl, symbol ); -#endif -#if JVET_P0118_HRD_ASPECTS if (generalHrd->getGeneralDecodingUnitHrdParamsPresentFlag()) { READ_UVLC(symbol, "bit_rate_du_value_minus1"); hrd->setDuBitRateValueMinus1(j, nalOrVcl, symbol); READ_UVLC(symbol, "cpb_size_du_value_minus1"); hrd->setDuCpbSizeValueMinus1(j, nalOrVcl, symbol); } READ_FLAG(symbol, "cbr_flag"); hrd->setCbrFlag(j, nalOrVcl, symbol == 1 ? true : false); -#else - READ_FLAG( symbol, "cbr_flag" ); hrd->setCbrFlag( i, j, nalOrVcl, symbol == 1 ? true : false ); -#endif } } } } for (int i = 0; i < firstSubLayer; i++) { -#if JVET_P0118_HRD_ASPECTS OlsHrdParams* hrdHighestTLayer = &(olsHrd[maxNumSubLayersMinus1]); OlsHrdParams* hrdTemp = &(olsHrd[i]); bool tempFlag = hrdHighestTLayer->getFixedPicRateGeneralFlag(); @@ -1482,21 +1251,12 @@ void HLSyntaxReader::parseHrdParameters(HRDParameters *hrd, uint32_t firstSubLay hrdTemp->setFixedPicRateWithinCvsFlag(tempFlag); uint32_t tempElementDurationInTcMinus1 = hrdHighestTLayer->getElementDurationInTcMinus1(); hrdTemp->setElementDurationInTcMinus1(tempElementDurationInTcMinus1); -#endif for (int nalOrVcl = 0; nalOrVcl < 2; nalOrVcl++) { -#if JVET_P0118_HRD_ASPECTS if (((nalOrVcl == 0) && (generalHrd->getGeneralNalHrdParametersPresentFlag())) || ((nalOrVcl == 1) && (generalHrd->getGeneralVclHrdParametersPresentFlag()))) { for (int j = 0; j <= (generalHrd->getHrdCpbCntMinus1()); j++) -#else - if( ( ( nalOrVcl == 0 ) && ( hrd->getNalHrdParametersPresentFlag() ) ) || - ( ( nalOrVcl == 1 ) && ( hrd->getVclHrdParametersPresentFlag() ) ) ) - { - for (int j = 0; j <= (hrd->getCpbCntMinus1(i)); j++) -#endif { -#if JVET_P0118_HRD_ASPECTS uint32_t bitRate = hrdHighestTLayer->getBitRateValueMinus1(j, nalOrVcl); hrdTemp->setBitRateValueMinus1(j, nalOrVcl, bitRate); uint32_t cpbSize = hrdHighestTLayer->getCpbSizeValueMinus1(j, nalOrVcl); @@ -1510,21 +1270,12 @@ void HLSyntaxReader::parseHrdParameters(HRDParameters *hrd, uint32_t firstSubLay } bool flag = hrdHighestTLayer->getCbrFlag(j, nalOrVcl); hrdTemp->setCbrFlag(j, nalOrVcl, flag); -#else - uint32_t bitRate = hrd->getBitRateValueMinus1(maxNumSubLayersMinus1, j, nalOrVcl); - hrd->setBitRateValueMinus1(i, j, nalOrVcl, bitRate); - uint32_t cpbSize = hrd->getCpbSizeValueMinus1(maxNumSubLayersMinus1, j, nalOrVcl); - hrd->setCpbSizeValueMinus1(i, j, nalOrVcl, cpbSize); - bool flag = hrd->getCbrFlag(maxNumSubLayersMinus1, j, nalOrVcl); - hrd->setCbrFlag(i, j, nalOrVcl, flag); -#endif } } } } } -#if JVET_P0117_PTL_SCALABILITY void HLSyntaxReader::dpb_parameters(int maxSubLayersMinus1, bool subLayerInfoFlag, SPS *pcSPS) { uint32_t code; @@ -1538,21 +1289,19 @@ void HLSyntaxReader::dpb_parameters(int maxSubLayersMinus1, bool subLayerInfoFla pcSPS->setMaxLatencyIncreasePlus1(code, i); } } -#endif -#if JVET_Q0400_EXTRA_BITS void HLSyntaxReader::parseExtraPHBitsStruct( SPS *sps, int numBytes ) { uint32_t symbol; std::vector<bool> presentFlags; presentFlags.resize ( 8 * numBytes ); - + for (int i=0; i < 8*numBytes; i++) { READ_FLAG(symbol, "extra_ph_bit_present_flag[ i ]"); presentFlags[i] = symbol; } - + sps->setExtraPHBitPresentFlags(presentFlags); } @@ -1561,16 +1310,15 @@ void HLSyntaxReader::parseExtraSHBitsStruct( SPS *sps, int numBytes ) uint32_t symbol; std::vector<bool> presentFlags; presentFlags.resize ( 8 * numBytes ); - + for (int i=0; i < 8*numBytes; i++) { READ_FLAG(symbol, "extra_sh_bit_present_flag[ i ]"); presentFlags[i] = symbol; } - + sps->setExtraSHBitPresentFlags(presentFlags); } -#endif void HLSyntaxReader::parseSPS(SPS* pcSPS) { @@ -1580,67 +1328,47 @@ void HLSyntaxReader::parseSPS(SPS* pcSPS) xTraceSPSHeader (); #endif -#if JVET_Q0117_PARAMETER_SETS_CLEANUP READ_CODE(4, uiCode, "sps_seq_parameter_set_id"); pcSPS->setSPSId(uiCode); -#else - READ_CODE( 4, uiCode, "sps_decoding_parameter_set_id"); pcSPS->setDecodingParameterSetId( uiCode ); -#endif READ_CODE( 4, uiCode, "sps_video_parameter_set_id" ); pcSPS->setVPSId( uiCode ); READ_CODE(3, uiCode, "sps_max_sub_layers_minus1"); pcSPS->setMaxTLayers (uiCode + 1); CHECK(uiCode > 6, "Invalid maximum number of T-layer signalled"); -#if JVET_P0117_PTL_SCALABILITY READ_CODE(4, uiCode, "sps_reserved_zero_4bits"); CHECK(uiCode != 0, "sps_reserved_zero_4bits not equal to zero"); READ_FLAG(uiCode, "sps_ptl_dpb_hrd_params_present_flag"); pcSPS->setPtlDpbHrdParamsPresentFlag(uiCode); -#else - READ_CODE(5, uiCode, "sps_reserved_zero_5bits"); - CHECK(uiCode != 0, "sps_reserved_zero_5bits not equal to zero"); + +#if JVET_R0275_SPS_PTL_DBP_HRD + if( !pcSPS->getVPSId() ) + { + CHECK( !pcSPS->getPtlDpbHrdParamsPresentFlag(), "When sps_video_parameter_set_id is equal to 0, the value of sps_ptl_dpb_hrd_params_present_flag shall be equal to 1" ); + } #endif - -#if JVET_P0117_PTL_SCALABILITY + if (pcSPS->getPtlDpbHrdParamsPresentFlag()) { -#endif -#if JVET_Q0786_PTL_only parseProfileTierLevel(pcSPS->getProfileTierLevel(), true, pcSPS->getMaxTLayers() - 1); -#else - parseProfileTierLevel(pcSPS->getProfileTierLevel(), pcSPS->getMaxTLayers() - 1); -#endif -#if JVET_P0117_PTL_SCALABILITY } -#endif READ_FLAG(uiCode, "gdr_enabled_flag"); pcSPS->setGDREnabledFlag(uiCode); -#if !JVET_Q0117_PARAMETER_SETS_CLEANUP - READ_CODE(4, uiCode, "sps_seq_parameter_set_id"); pcSPS->setSPSId(uiCode); -#endif READ_CODE(2, uiCode, "chroma_format_idc"); pcSPS->setChromaFormatIdc( ChromaFormat(uiCode) ); if( pcSPS->getChromaFormatIdc() == CHROMA_444 ) { - READ_FLAG( uiCode, "separate_colour_plane_flag"); CHECK(uiCode != 0, "Invalid code"); + READ_FLAG( uiCode, "separate_colour_plane_flag"); CHECK(uiCode != 0, "separate_colour_plane_flag shall be equal to 0"); pcSPS->setSeparateColourPlaneFlag( uiCode != 0 ); } -#if JVET_Q0043_RPR_and_Subpics READ_FLAG( uiCode, "res_change_in_clvs_allowed_flag" ); pcSPS->setRprEnabledFlag( uiCode ); -#else - READ_FLAG( uiCode, "ref_pic_resampling_enabled_flag" ); pcSPS->setRprEnabledFlag( uiCode ); -#endif -#if JVET_Q0114_CONSTRAINT_FLAGS if (pcSPS->getProfileTierLevel()->getConstraintInfo()->getNoResChangeInClvsConstraintFlag()) { CHECK(uiCode != 0, "When no_res_change_in_clvs_constraint_flag is equal to 1, res_change_in_clvs_allowed_flag shall be equal to 0"); } -#endif READ_UVLC( uiCode, "pic_width_max_in_luma_samples" ); pcSPS->setMaxPicWidthInLumaSamples( uiCode ); READ_UVLC( uiCode, "pic_height_max_in_luma_samples" ); pcSPS->setMaxPicHeightInLumaSamples( uiCode ); -#if JVET_Q0260_CONFORMANCE_WINDOW_IN_SPS READ_FLAG(uiCode, "sps_conformance_window_flag"); if (uiCode != 0) { @@ -1650,71 +1378,52 @@ void HLSyntaxReader::parseSPS(SPS* pcSPS) READ_UVLC(uiCode, "sps_conf_win_top_offset"); conf.setWindowTopOffset(uiCode); READ_UVLC(uiCode, "sps_conf_win_bottom_offset"); conf.setWindowBottomOffset(uiCode); } -#endif -#if JVET_Q0265 const uint32_t chromaArrayType = (int) pcSPS->getSeparateColourPlaneFlag() ? 0 : pcSPS->getChromaFormatIdc(); -#endif READ_CODE(2, uiCode, "sps_log2_ctu_size_minus5"); pcSPS->setCTUSize(1 << (uiCode + 5)); CHECK(uiCode > 2, "sps_log2_ctu_size_minus5 must be less than or equal to 2"); unsigned ctbLog2SizeY = uiCode + 5; -#if !JVET_Q0468_Q0469_MIN_LUMA_CB_AND_MIN_QT_FIX - pcSPS->setMaxCodingDepth(uiCode+3); - pcSPS->setLog2DiffMaxMinCodingBlockSize(uiCode+3); -#endif pcSPS->setMaxCUWidth(pcSPS->getCTUSize()); pcSPS->setMaxCUHeight(pcSPS->getCTUSize()); -#if JVET_Q0043_RPR_and_Subpics | JVET_Q0119_CLEANUPS -#if JVET_Q0119_CLEANUPS READ_FLAG( uiCode, "subpic_info_present_flag" ); pcSPS->setSubPicInfoPresentFlag(uiCode); -#else - READ_FLAG( uiCode, "subpic_info_present_flag" ); pcSPS->setSubPicPresentFlag(uiCode); -#endif -#else - READ_FLAG( uiCode, "subpics_present_flag" ); pcSPS->setSubPicPresentFlag(uiCode); -#endif -#if JVET_Q0119_CLEANUPS if (pcSPS->getSubPicInfoPresentFlag()) -#else - if (pcSPS->getSubPicPresentFlag()) -#endif { -#if JVET_Q0119_CLEANUPS READ_UVLC(uiCode, "sps_num_subpics_minus1"); pcSPS->setNumSubPics(uiCode + 1); CHECK(uiCode > (pcSPS->getMaxPicWidthInLumaSamples() / (1 << pcSPS->getCTUSize())) * (pcSPS->getMaxPicHeightInLumaSamples() / (1 << pcSPS->getCTUSize())) - 1, "Invalid sps_num_subpics_minus1 value"); -#else - READ_CODE(8, uiCode, "sps_num_subpics_minus1"); pcSPS->setNumSubPics(uiCode + 1); -#endif -#if JVET_Q0114_CONSTRAINT_FLAGS if (pcSPS->getProfileTierLevel()->getConstraintInfo()->getOneSubpicPerPicConstraintFlag()) { CHECK(uiCode != 0, "When one_subpic_per_pic_constraint_flag is equal to 1, each picture shall contain only one subpicture"); } -#endif -#if JVET_Q0816 if( pcSPS->getNumSubPics() == 1 ) { pcSPS->setSubPicCtuTopLeftX( 0, 0 ); pcSPS->setSubPicCtuTopLeftY( 0, 0 ); pcSPS->setSubPicWidth( 0, ( pcSPS->getMaxPicWidthInLumaSamples() + pcSPS->getCTUSize() - 1 ) >> floorLog2( pcSPS->getCTUSize() ) ); pcSPS->setSubPicHeight( 0, ( pcSPS->getMaxPicHeightInLumaSamples() + pcSPS->getCTUSize() - 1 ) >> floorLog2( pcSPS->getCTUSize() ) ); + +#if JVET_R0156_ASPECT4_SPS_CLEANUP + pcSPS->setIndependentSubPicsFlag(1); +#endif + +#if JVET_R0071_SPS_PPS_CELANUP + pcSPS->setSubPicTreatedAsPicFlag(0, 1); + pcSPS->setLoopFilterAcrossSubpicEnabledFlag(0, 0); +#else pcSPS->setSubPicTreatedAsPicFlag( 0, 0 ); pcSPS->setLoopFilterAcrossSubpicEnabledFlag( 0, 1 ); +#endif } else { +#if JVET_R0156_ASPECT4_SPS_CLEANUP + READ_FLAG(uiCode, "sps_independent_subpics_flag"); pcSPS->setIndependentSubPicsFlag(uiCode != 0); #endif for (int picIdx = 0; picIdx < pcSPS->getNumSubPics(); picIdx++) { -#if JVET_Q0787_SUBPIC -#if JVET_Q0222_SUBPICTURE_SIGNALLING if ((picIdx > 0) && (pcSPS->getMaxPicWidthInLumaSamples() > pcSPS->getCTUSize())) -#else - if (pcSPS->getMaxPicWidthInLumaSamples() > pcSPS->getCTUSize()) -#endif { READ_CODE(ceilLog2((pcSPS->getMaxPicWidthInLumaSamples() + pcSPS->getCTUSize() - 1) / pcSPS->getCTUSize()), uiCode, "subpic_ctu_top_left_x[ i ]"); pcSPS->setSubPicCtuTopLeftX(picIdx, uiCode); @@ -1723,11 +1432,7 @@ void HLSyntaxReader::parseSPS(SPS* pcSPS) { pcSPS->setSubPicCtuTopLeftX(picIdx, 0); } -#if JVET_Q0222_SUBPICTURE_SIGNALLING if ((picIdx > 0) && (pcSPS->getMaxPicHeightInLumaSamples() > pcSPS->getCTUSize())) -#else - if (pcSPS->getMaxPicHeightInLumaSamples() > pcSPS->getCTUSize()) -#endif { READ_CODE(ceilLog2((pcSPS->getMaxPicHeightInLumaSamples() + pcSPS->getCTUSize() - 1) / pcSPS->getCTUSize()), uiCode, "subpic_ctu_top_left_y[ i ]"); pcSPS->setSubPicCtuTopLeftY(picIdx, uiCode); @@ -1736,75 +1441,41 @@ void HLSyntaxReader::parseSPS(SPS* pcSPS) { pcSPS->setSubPicCtuTopLeftY(picIdx, 0); } -#if JVET_Q0413_SKIP_LAST_SUBPIC_SIG if (picIdx <pcSPS->getNumSubPics()-1 && pcSPS->getMaxPicWidthInLumaSamples() > pcSPS->getCTUSize()) -#else - if (pcSPS->getMaxPicWidthInLumaSamples() > pcSPS->getCTUSize()) -#endif { READ_CODE(ceilLog2((pcSPS->getMaxPicWidthInLumaSamples() + pcSPS->getCTUSize() - 1) / pcSPS->getCTUSize()), uiCode, "subpic_width_minus1[ i ]"); pcSPS->setSubPicWidth(picIdx, uiCode + 1); } else { -#if JVET_Q0413_SKIP_LAST_SUBPIC_SIG pcSPS->setSubPicWidth(picIdx, (pcSPS->getMaxPicWidthInLumaSamples() + pcSPS->getCTUSize() - 1) /pcSPS->getCTUSize() - pcSPS->getSubPicCtuTopLeftX(picIdx)); -#else - pcSPS->setSubPicWidth(picIdx, 1); -#endif } -#if JVET_Q0413_SKIP_LAST_SUBPIC_SIG if (picIdx <pcSPS->getNumSubPics() - 1 && pcSPS->getMaxPicHeightInLumaSamples() > pcSPS->getCTUSize()) -#else - if (pcSPS->getMaxPicHeightInLumaSamples() > pcSPS->getCTUSize()) -#endif { READ_CODE(ceilLog2((pcSPS->getMaxPicHeightInLumaSamples() + pcSPS->getCTUSize() - 1) / pcSPS->getCTUSize()), uiCode, "subpic_height_minus1[ i ]"); pcSPS->setSubPicHeight(picIdx, uiCode + 1); } else { -#if JVET_Q0413_SKIP_LAST_SUBPIC_SIG pcSPS->setSubPicHeight(picIdx, (pcSPS->getMaxPicHeightInLumaSamples() + pcSPS->getCTUSize() - 1) /pcSPS->getCTUSize() - pcSPS->getSubPicCtuTopLeftY(picIdx)); -#else - pcSPS->setSubPicHeight(picIdx, 1); -#endif } -#else -#if JVET_Q0222_SUBPICTURE_SIGNALLING - if (picIdx > 0) +#if JVET_R0156_ASPECT4_SPS_CLEANUP + if (!pcSPS->getIndependentSubPicsFlag()) { #endif - READ_CODE(std::max(1, ceilLog2(((pcSPS->getMaxPicWidthInLumaSamples() + pcSPS->getCTUSize() - 1) >> floorLog2(pcSPS->getCTUSize())))), uiCode, "subpic_ctu_top_left_x[ i ]"); - pcSPS->setSubPicCtuTopLeftX(picIdx, uiCode); - READ_CODE(std::max(1, ceilLog2(((pcSPS->getMaxPicHeightInLumaSamples() + pcSPS->getCTUSize() - 1) >> floorLog2(pcSPS->getCTUSize())))), uiCode, "subpic_ctu_top_left_y[ i ]"); - pcSPS->setSubPicCtuTopLeftY(picIdx, uiCode); -#if JVET_Q0222_SUBPICTURE_SIGNALLING - } - else - { - pcSPS->setSubPicCtuTopLeftX(picIdx, 0); - pcSPS->setSubPicCtuTopLeftY(picIdx, 0); + READ_FLAG(uiCode, "subpic_treated_as_pic_flag[ i ]"); + pcSPS->setSubPicTreatedAsPicFlag(picIdx, uiCode); + READ_FLAG(uiCode, "loop_filter_across_subpic_enabled_flag[ i ]"); + pcSPS->setLoopFilterAcrossSubpicEnabledFlag(picIdx, uiCode); +#if JVET_R0156_ASPECT4_SPS_CLEANUP } #endif - READ_CODE(std::max(1, ceilLog2(((pcSPS->getMaxPicWidthInLumaSamples() + pcSPS->getCTUSize() - 1) >> floorLog2(pcSPS->getCTUSize())))), uiCode, "subpic_width_minus1[ i ]"); - pcSPS->setSubPicWidth(picIdx, uiCode + 1); - READ_CODE(std::max(1, ceilLog2(((pcSPS->getMaxPicHeightInLumaSamples() + pcSPS->getCTUSize() - 1) >> floorLog2(pcSPS->getCTUSize())))), uiCode, "subpic_height_minus1[ i ]"); - pcSPS->setSubPicHeight(picIdx, uiCode + 1); -#endif - READ_FLAG(uiCode, "subpic_treated_as_pic_flag[ i ]"); - pcSPS->setSubPicTreatedAsPicFlag(picIdx, uiCode); - READ_FLAG(uiCode, "loop_filter_across_subpic_enabled_flag[ i ]"); - pcSPS->setLoopFilterAcrossSubpicEnabledFlag(picIdx, uiCode); } -#if JVET_Q0816 } -#endif -#if JVET_Q0119_CLEANUPS READ_UVLC( uiCode, "sps_subpic_id_len_minus1" ); pcSPS->setSubPicIdLen( uiCode + 1 ); CHECK( uiCode > 15, "Invalid sps_subpic_id_len_minus1 value" ); - CHECK( (1 << (uiCode + 1)) < pcSPS->getNumSubPics() + 1, "Invalid sps_subpic_id_len_minus1 value" ); + CHECK( (1 << (uiCode + 1)) < pcSPS->getNumSubPics(), "Invalid sps_subpic_id_len_minus1 value" ); READ_FLAG( uiCode, "subpic_id_mapping_explicitly_signalled_flag" ); pcSPS->setSubPicIdMappingExplicitlySignalledFlag( uiCode != 0 ); if (pcSPS->getSubPicIdMappingExplicitlySignalledFlag()) { @@ -1817,13 +1488,10 @@ void HLSyntaxReader::parseSPS(SPS* pcSPS) } } } -#endif } else { -#if JVET_Q0119_CLEANUPS pcSPS->setSubPicIdMappingExplicitlySignalledFlag(0); -#endif pcSPS->setNumSubPics(1); pcSPS->setSubPicCtuTopLeftX(0, 0); pcSPS->setSubPicCtuTopLeftY(0, 0); @@ -1831,28 +1499,7 @@ void HLSyntaxReader::parseSPS(SPS* pcSPS) pcSPS->setSubPicHeight(0, (pcSPS->getMaxPicHeightInLumaSamples() + pcSPS->getCTUSize() - 1) >> floorLog2(pcSPS->getCTUSize())); } -#if !JVET_Q0119_CLEANUPS - READ_FLAG(uiCode, "sps_subpic_id_present_flag"); pcSPS->setSubPicIdPresentFlag( uiCode != 0 ); - if( pcSPS->getSubPicIdPresentFlag() ) - { - READ_FLAG(uiCode, "sps_subpic_id_signalling_present_flag"); pcSPS->setSubPicIdSignallingPresentFlag( uiCode != 0 ); - if( pcSPS->getSubPicIdSignallingPresentFlag() ) - { - READ_UVLC( uiCode, "sps_subpic_id_len_minus1" ); pcSPS->setSubPicIdLen( uiCode + 1 ); - CHECK( uiCode > 15, "Invalid sps_subpic_id_len_minus1 signalled"); -#if JVET_Q0169_SUBPIC_LEN_CONFORM - CHECK((1 << pcSPS->getSubPicIdLen()) < pcSPS->getNumSubPics(), "sps_subpic_id_len exceeds valid range"); -#endif - for( int picIdx = 0; picIdx < pcSPS->getNumSubPics( ); picIdx++ ) - { - READ_CODE( pcSPS->getSubPicIdLen( ), uiCode, "sps_subpic_id[i]" ); pcSPS->setSubPicId( picIdx, uiCode ); - } - } - } - if( pcSPS->getSubPicIdPresentFlag() == false || pcSPS->getSubPicIdSignallingPresentFlag() == false ) -#else if( !pcSPS->getSubPicIdMappingExplicitlySignalledFlag() || !pcSPS->getSubPicIdMappingInSpsFlag() ) -#endif { for( int picIdx = 0; picIdx < pcSPS->getNumSubPics( ); picIdx++ ) { @@ -1866,16 +1513,12 @@ void HLSyntaxReader::parseSPS(SPS* pcSPS) pcSPS->setBitDepth(CHANNEL_TYPE_CHROMA, 8 + uiCode); pcSPS->setQpBDOffset(CHANNEL_TYPE_LUMA, (int) (6*uiCode) ); pcSPS->setQpBDOffset(CHANNEL_TYPE_CHROMA, (int) (6*uiCode) ); -#if !JVET_Q0183_SPS_TRANSFORM_SKIP_MODE_CONTROL - READ_UVLC( uiCode, "min_qp_prime_ts_minus4" ); - pcSPS->setMinQpPrimeTsMinus4(CHANNEL_TYPE_LUMA, uiCode); - CHECK(uiCode > 48, "Invalid min_qp_prime_ts_minus4 signalled"); - pcSPS->setMinQpPrimeTsMinus4(CHANNEL_TYPE_CHROMA, uiCode); -#endif -#if JVET_Q0151_Q0205_ENTRYPOINTS READ_FLAG( uiCode, "sps_entropy_coding_sync_enabled_flag" ); pcSPS->setEntropyCodingSyncEnabledFlag(uiCode == 1); - if (pcSPS->getEntropyCodingSyncEnabledFlag()) +#if JVET_R0165_OPTIONAL_ENTRY_POINT + READ_FLAG(uiCode, "sps_entry_point_offsets_present_flag"); pcSPS->setEntryPointsPresentFlag(uiCode == 1); +#else + if (pcSPS->getEntropyCodingSyncEnabledFlag()) { READ_FLAG(uiCode, "sps_wpp_entry_point_offsets_present_flag"); pcSPS->setEntropyCodingSyncEntryPointsPresentFlag(uiCode == 1); } @@ -1885,71 +1528,52 @@ void HLSyntaxReader::parseSPS(SPS* pcSPS) READ_FLAG( uiCode, "sps_weighted_bipred_flag" ); pcSPS->setUseWPBiPred( uiCode ? true : false ); READ_CODE(4, uiCode, "log2_max_pic_order_cnt_lsb_minus4"); pcSPS->setBitsForPOC( 4 + uiCode ); - CHECK(uiCode > 12, "Invalid code"); + CHECK(uiCode > 12, "log2_max_pic_order_cnt_lsb_minus4 shall be in the range of 0 to 12"); -#if JVET_P0116_POC_MSB READ_FLAG(uiCode, "sps_poc_msb_flag"); pcSPS->setPocMsbFlag(uiCode ? true : false); if (pcSPS->getPocMsbFlag()) { READ_UVLC(uiCode, "poc_msb_len_minus1"); pcSPS->setPocMsbLen(1 + uiCode); CHECK(uiCode > (32 - ( pcSPS->getBitsForPOC() - 4 )- 5), "The value of poc_msb_len_minus1 shall be in the range of 0 to 32 - log2_max_pic_order_cnt_lsb_minus4 - 5, inclusive"); } -#endif -#if JVET_Q0400_EXTRA_BITS // extra bits are for future extensions, we will read, but ignore them, // unless a meaning is specified in the spec READ_CODE(2, uiCode, "num_extra_ph_bits_bytes"); pcSPS->setNumExtraPHBitsBytes(uiCode); parseExtraPHBitsStruct( pcSPS, uiCode ); READ_CODE(2, uiCode, "num_extra_sh_bits_bytes"); pcSPS->setNumExtraSHBitsBytes(uiCode); parseExtraSHBitsStruct( pcSPS, uiCode ); -#endif -#if JVET_P0117_PTL_SCALABILITY +#if !JVET_R0156_ASPECT3_SPS_CLEANUP if (pcSPS->getMaxTLayers() - 1 > 0) { READ_FLAG(uiCode, "sps_sublayer_dpb_params_flag"); pcSPS->setSubLayerDpbParamsFlag(uiCode ? true : false); - } + } +#endif if (pcSPS->getPtlDpbHrdParamsPresentFlag()) { +#if JVET_R0156_ASPECT3_SPS_CLEANUP + if (pcSPS->getMaxTLayers() - 1 > 0) + { + READ_FLAG(uiCode, "sps_sublayer_dpb_params_flag"); pcSPS->setSubLayerDpbParamsFlag(uiCode ? true : false); + } +#endif dpb_parameters(pcSPS->getMaxTLayers() - 1, pcSPS->getSubLayerDpbParamsFlag(), pcSPS); } -#else - // KJS: Marakech decision: sub-layers added back - uint32_t subLayerOrderingInfoPresentFlag; - if (pcSPS->getMaxTLayers() > 1) + + READ_FLAG(uiCode, "long_term_ref_pics_flag"); pcSPS->setLongTermRefsPresent(uiCode); +#if JVET_R0205 + if (pcSPS->getVPSId() > 0) { - READ_FLAG(subLayerOrderingInfoPresentFlag, "sps_sub_layer_ordering_info_present_flag"); + READ_FLAG( uiCode, "sps_inter_layer_ref_pics_present_flag" ); pcSPS->setInterLayerPresentFlag( uiCode ); } else { - subLayerOrderingInfoPresentFlag = 0; - } - - for(uint32_t i=0; i <= pcSPS->getMaxTLayers()-1; i++) - { - READ_UVLC ( uiCode, "sps_max_dec_pic_buffering_minus1[i]"); - pcSPS->setMaxDecPicBuffering( uiCode + 1, i); - READ_UVLC ( uiCode, "sps_max_num_reorder_pics[i]" ); - pcSPS->setNumReorderPics(uiCode, i); - READ_UVLC ( uiCode, "sps_max_latency_increase_plus1[i]"); - pcSPS->setMaxLatencyIncreasePlus1( uiCode, i ); - - if (!subLayerOrderingInfoPresentFlag) - { - for (i++; i <= pcSPS->getMaxTLayers()-1; i++) - { - pcSPS->setMaxDecPicBuffering(pcSPS->getMaxDecPicBuffering(0), i); - pcSPS->setNumReorderPics(pcSPS->getNumReorderPics(0), i); - pcSPS->setMaxLatencyIncreasePlus1(pcSPS->getMaxLatencyIncreasePlus1(0), i); - } - break; - } + pcSPS->setInterLayerPresentFlag(0); } -#endif - - READ_FLAG(uiCode, "long_term_ref_pics_flag"); pcSPS->setLongTermRefsPresent(uiCode); +#else READ_FLAG( uiCode, "inter_layer_ref_pics_present_flag" ); pcSPS->setInterLayerPresentFlag( uiCode ); +#endif READ_FLAG( uiCode, "sps_idr_rpl_present_flag" ); pcSPS->setIDRRefParamListPresent( (bool) uiCode ); READ_FLAG(uiCode, "rpl1_copy_from_rpl0_flag"); pcSPS->setRPL1CopyFromRPL0Flag(uiCode); @@ -1963,7 +1587,11 @@ void HLSyntaxReader::parseSPS(SPS* pcSPS) for (uint32_t ii = 0; ii < numberOfRPL; ii++) { rpl = rplList->getReferencePictureList(ii); +#if JVET_R0059_RPL_CLEANUP + parseRefPicList(pcSPS, rpl, ii); +#else parseRefPicList(pcSPS, rpl); +#endif } //Read candidate for List1 @@ -1976,7 +1604,11 @@ void HLSyntaxReader::parseSPS(SPS* pcSPS) for (uint32_t ii = 0; ii < numberOfRPL; ii++) { rpl = rplList->getReferencePictureList(ii); +#if JVET_R0059_RPL_CLEANUP + parseRefPicList(pcSPS, rpl, ii); +#else parseRefPicList(pcSPS, rpl); +#endif } } else @@ -1994,7 +1626,7 @@ void HLSyntaxReader::parseSPS(SPS* pcSPS) unsigned maxBTSize[3] = { 0, 0, 0 }; unsigned maxTTSize[3] = { 0, 0, 0 }; - if( pcSPS->getChromaFormatIdc() != CHROMA_400 ) + if( pcSPS->getChromaFormatIdc() != CHROMA_400 ) { READ_FLAG(uiCode, "qtbtt_dual_tree_intra_flag"); pcSPS->setUseDualITree(uiCode); } @@ -2009,25 +1641,17 @@ void HLSyntaxReader::parseSPS(SPS* pcSPS) CHECK(uiCode > ctbLog2SizeY - 2, "Invalid log2_min_luma_coding_block_size_minus2 signalled"); CHECK(log2MinCUSize > std::min(6, (int)(ctbLog2SizeY)), "log2_min_luma_coding_block_size_minus2 shall be in the range of 0 to min (4, log2_ctu_size - 2)"); -#if JVET_Q0468_Q0469_MIN_LUMA_CB_AND_MIN_QT_FIX const int minCuSize = 1 << pcSPS->getLog2MinCodingBlockSize(); CHECK( ( pcSPS->getMaxPicWidthInLumaSamples() % ( std::max( 8, minCuSize ) ) ) != 0, "Coded frame width must be a multiple of Max(8, the minimum unit size)" ); CHECK( ( pcSPS->getMaxPicHeightInLumaSamples() % ( std::max( 8, minCuSize ) ) ) != 0, "Coded frame height must be a multiple of Max(8, the minimum unit size)" ); -#else - CHECK( ( pcSPS->getMaxPicWidthInLumaSamples() % ( std::max( 8, int( pcSPS->getMaxCUWidth() >> ( pcSPS->getMaxCodingDepth() - 1 ) ) ) ) ) != 0, "Coded frame width must be a multiple of Max(8, the minimum unit size)" ); - CHECK( ( pcSPS->getMaxPicHeightInLumaSamples() % ( std::max( 8, int( pcSPS->getMaxCUHeight() >> ( pcSPS->getMaxCodingDepth() - 1 ) ) ) ) ) != 0, "Coded frame height must be a multiple of Max(8, the minimum unit size)" ); -#endif READ_FLAG(uiCode, "partition_constraints_override_enabled_flag"); pcSPS->setSplitConsOverrideEnabledFlag(uiCode); READ_UVLC(uiCode, "sps_log2_diff_min_qt_min_cb_intra_slice_luma"); unsigned minQtLog2SizeIntraY = uiCode + pcSPS->getLog2MinCodingBlockSize(); minQT[0] = 1 << minQtLog2SizeIntraY; -#if !JVET_Q0481_PARTITION_CONSTRAINTS_ORDER - READ_UVLC(uiCode, "sps_log2_diff_min_qt_min_cb_inter_slice"); - unsigned minQtLog2SizeInterY = uiCode + pcSPS->getLog2MinCodingBlockSize(); - minQT[1] = 1 << minQtLog2SizeInterY; - READ_UVLC(uiCode, "sps_max_mtt_hierarchy_depth_inter_slice"); maxBTD[1] = uiCode; - CHECK(uiCode > 2*(ctbLog2SizeY - log2MinCUSize), "sps_max_mtt_hierarchy_depth_inter_slice shall be in the range 0 to 2*(ctbLog2SizeY - log2MinCUSize)"); +#if JVET_R0347_MTT_SIZE_CONSTRAIN + CHECK(minQT[0] > 64, "The value of sps_log2_diff_min_qt_min_cb_intra_slice_luma shall be in the range of 0 to min(6,CtbLog2SizeY) - MinCbLog2Size"); + CHECK(minQT[0] > (1<<ctbLog2SizeY), "The value of sps_log2_diff_min_qt_min_cb_intra_slice_luma shall be in the range of 0 to min(6,CtbLog2SizeY) - MinCbLog2Size"); #endif READ_UVLC(uiCode, "sps_max_mtt_hierarchy_depth_intra_slice_luma"); maxBTD[0] = uiCode; CHECK(uiCode > 2 * (ctbLog2SizeY - log2MinCUSize), "sps_max_mtt_hierarchy_depth_intra_slice_luma shall be in the range 0 to 2*(ctbLog2SizeY - log2MinCUSize)"); @@ -2036,24 +1660,28 @@ void HLSyntaxReader::parseSPS(SPS* pcSPS) if (maxBTD[0] != 0) { READ_UVLC(uiCode, "sps_log2_diff_max_bt_min_qt_intra_slice_luma"); maxBTSize[0] <<= uiCode; - CHECK(uiCode > ctbLog2SizeY - minQtLog2SizeIntraY, "Invalid code"); + CHECK(uiCode > ctbLog2SizeY - minQtLog2SizeIntraY, "The value of sps_log2_diff_max_bt_min_qt_intra_slice_luma shall be in the range of 0 to CtbLog2SizeY - MinQtLog2SizeIntraY"); READ_UVLC(uiCode, "sps_log2_diff_max_tt_min_qt_intra_slice_luma"); maxTTSize[0] <<= uiCode; - CHECK(uiCode > ctbLog2SizeY - minQtLog2SizeIntraY, "Invalid code"); + CHECK(uiCode > ctbLog2SizeY - minQtLog2SizeIntraY, "The value of sps_log2_diff_max_tt_min_qt_intra_slice_luma shall be in the range of 0 to CtbLog2SizeY - MinQtLog2SizeIntraY"); +#if JVET_R0347_MTT_SIZE_CONSTRAIN + CHECK(maxTTSize[0] > 64, "The value of sps_log2_diff_max_tt_min_qt_intra_slice_luma shall be in the range of 0 to min(6,CtbLog2SizeY) - MinQtLog2SizeIntraY"); +#endif } -#if JVET_Q0481_PARTITION_CONSTRAINTS_ORDER READ_UVLC(uiCode, "sps_log2_diff_min_qt_min_cb_inter_slice"); unsigned minQtLog2SizeInterY = uiCode + pcSPS->getLog2MinCodingBlockSize(); minQT[1] = 1 << minQtLog2SizeInterY; READ_UVLC(uiCode, "sps_max_mtt_hierarchy_depth_inter_slice"); maxBTD[1] = uiCode; CHECK(uiCode > 2*(ctbLog2SizeY - log2MinCUSize), "sps_max_mtt_hierarchy_depth_inter_slice shall be in the range 0 to 2*(ctbLog2SizeY - log2MinCUSize)"); -#endif maxTTSize[1] = maxBTSize[1] = minQT[1]; if (maxBTD[1] != 0) { READ_UVLC(uiCode, "sps_log2_diff_max_bt_min_qt_inter_slice"); maxBTSize[1] <<= uiCode; - CHECK(uiCode > ctbLog2SizeY - minQtLog2SizeInterY, "Invalid code"); + CHECK(uiCode > ctbLog2SizeY - minQtLog2SizeInterY, "The value of sps_log2_diff_max_bt_min_qt_inter_slice shall be in the range of 0 to CtbLog2SizeY - MinQtLog2SizeInterY"); READ_UVLC(uiCode, "sps_log2_diff_max_tt_min_qt_inter_slice"); maxTTSize[1] <<= uiCode; - CHECK(uiCode > ctbLog2SizeY - minQtLog2SizeInterY, "Invalid code"); + CHECK(uiCode > ctbLog2SizeY - minQtLog2SizeInterY, "The value of sps_log2_diff_max_tt_min_qt_inter_slice shall be in the range of 0 to CtbLog2SizeY - MinQtLog2SizeInterY"); +#if JVET_R0347_MTT_SIZE_CONSTRAIN + CHECK(maxTTSize[1] > 64, "The value of sps_log2_diff_max_tt_min_qt_inter_slice shall be in the range of 0 to min(6,CtbLog2SizeY) - MinQtLog2SizeInterY"); +#endif } if (pcSPS->getUseDualITree()) { @@ -2065,6 +1693,10 @@ void HLSyntaxReader::parseSPS(SPS* pcSPS) { READ_UVLC(uiCode, "sps_log2_diff_max_bt_min_qt_intra_slice_chroma"); maxBTSize[2] <<= uiCode; READ_UVLC(uiCode, "sps_log2_diff_max_tt_min_qt_intra_slice_chroma"); maxTTSize[2] <<= uiCode; +#if JVET_R0347_MTT_SIZE_CONSTRAIN + CHECK(maxTTSize[2] > 64, "The value of sps_log2_diff_max_tt_min_qt_intra_slice_chroma shall be in the range of 0 to min(6,CtbLog2SizeY) - MinQtLog2SizeIntraChroma"); + CHECK(maxBTSize[2] > 64, "The value of sps_log2_diff_max_bt_min_qt_intra_slice_chroma shall be in the range of 0 to min(6,CtbLog2SizeY) - MinQtLog2SizeIntraChroma"); +#endif } } @@ -2073,22 +1705,21 @@ void HLSyntaxReader::parseSPS(SPS* pcSPS) pcSPS->setMaxBTSize(maxBTSize[1], maxBTSize[0], maxBTSize[2]); pcSPS->setMaxTTSize(maxTTSize[1], maxTTSize[0], maxTTSize[2]); +#if JVET_R0097_MAX_TRSIZE_CONDITIONALY_SIGNALING + if (pcSPS->getCTUSize() > 32) { +#endif + READ_FLAG(uiCode, "sps_max_luma_transform_size_64_flag"); pcSPS->setLog2MaxTbSize((uiCode ? 1 : 0) + 5); +#if JVET_R0097_MAX_TRSIZE_CONDITIONALY_SIGNALING + } + else + { + pcSPS->setLog2MaxTbSize(5); + } +#endif - READ_FLAG( uiCode, "sps_max_luma_transform_size_64_flag"); pcSPS->setLog2MaxTbSize( (uiCode ? 1 : 0) + 5 ); - -#if JVET_Q0147_JCCR_SIGNALLING -#if JVET_Q0265 if (chromaArrayType != CHROMA_400) -#else - if (pcSPS->getChromaFormatIdc() != CHROMA_400) -#endif { READ_FLAG(uiCode, "sps_joint_cbcr_enabled_flag"); pcSPS->setJointCbCrEnabledFlag(uiCode ? true : false); -#else - READ_FLAG(uiCode, "sps_joint_cbcr_enabled_flag"); pcSPS->setJointCbCrEnabledFlag(uiCode ? true : false); - if (pcSPS->getChromaFormatIdc() != CHROMA_400) - { -#endif ChromaQpMappingTableParams chromaQpMappingTableParams; READ_FLAG(uiCode, "same_qp_table_for_chroma"); chromaQpMappingTableParams.setSameCQPTableForAllChromaFlag(uiCode); int numQpTables = chromaQpMappingTableParams.getSameCQPTableForAllChromaFlag() ? 1 : (pcSPS->getJointCbCrEnabledFlag() ? 3 : 2); @@ -2116,7 +1747,6 @@ void HLSyntaxReader::parseSPS(SPS* pcSPS) READ_FLAG( uiCode, "sps_sao_enabled_flag" ); pcSPS->setSAOEnabledFlag ( uiCode ? true : false ); READ_FLAG( uiCode, "sps_alf_enabled_flag" ); pcSPS->setALFEnabledFlag ( uiCode ? true : false ); -#if JVET_Q0795_CCALF if (pcSPS->getALFEnabledFlag() && pcSPS->getChromaFormatIdc() != CHROMA_400) { READ_FLAG( uiCode, "sps_ccalf_enabled_flag" ); pcSPS->setCCALFEnabledFlag ( uiCode ? true : false ); @@ -2125,41 +1755,20 @@ void HLSyntaxReader::parseSPS(SPS* pcSPS) { pcSPS->setCCALFEnabledFlag(false); } -#endif READ_FLAG(uiCode, "sps_transform_skip_enabled_flag"); pcSPS->setTransformSkipEnabledFlag(uiCode ? true : false); if (pcSPS->getTransformSkipEnabledFlag()) { -#if JVET_Q0183_SPS_TRANSFORM_SKIP_MODE_CONTROL READ_UVLC(uiCode, "log2_transform_skip_max_size_minus2"); pcSPS->setLog2MaxTransformSkipBlockSize(uiCode + 2); -#endif -#if JVET_Q0089_SLICE_LOSSLESS_CODING_CHROMA_BDPCM READ_FLAG(uiCode, "sps_bdpcm_enabled_flag"); pcSPS->setBDPCMEnabledFlag(uiCode ? true : false); -#else - READ_FLAG(uiCode, "sps_bdpcm_enabled_flag"); -#if JVET_Q0110_Q0785_CHROMA_BDPCM_420 - if( uiCode ) -#else - if (uiCode && pcSPS->getChromaFormatIdc() == CHROMA_444 ) -#endif - { - READ_FLAG(uiCode, "sps_bdpcm_enabled_chroma_flag"); - uiCode++; - } - pcSPS->setBDPCMEnabled(uiCode); -#endif } READ_FLAG(uiCode, "sps_ref_wraparound_enabled_flag"); pcSPS->setWrapAroundEnabledFlag( uiCode ? true : false ); if (pcSPS->getWrapAroundEnabledFlag()) { -#if JVET_Q0416_WRAPAROUND_OFFSET READ_UVLC(uiCode, "sps_ref_wraparound_offset"); pcSPS->setWrapAroundOffset((uiCode + 2 + pcSPS->getCTUSize() / (1 << pcSPS->getLog2MinCodingBlockSize()))*(1 << pcSPS->getLog2MinCodingBlockSize())); -#else - READ_UVLC(uiCode, "sps_ref_wraparound_offset_minus1"); pcSPS->setWrapAroundOffset( (uiCode+1)*(1 << pcSPS->getLog2MinCodingBlockSize())); -#endif } READ_FLAG( uiCode, "sps_temporal_mvp_enabled_flag" ); pcSPS->setSPSTemporalMVPEnabledFlag(uiCode); @@ -2196,7 +1805,7 @@ void HLSyntaxReader::parseSPS(SPS* pcSPS) READ_FLAG(uiCode, "sps_isp_enabled_flag"); pcSPS->setUseISP( uiCode != 0 ); READ_FLAG(uiCode, "sps_mrl_enabled_flag"); pcSPS->setUseMRL( uiCode != 0 ); READ_FLAG(uiCode, "sps_mip_enabled_flag"); pcSPS->setUseMIP( uiCode != 0 ); - if( pcSPS->getChromaFormatIdc() != CHROMA_400) + if( pcSPS->getChromaFormatIdc() != CHROMA_400) { READ_FLAG( uiCode, "sps_cclm_enabled_flag" ); pcSPS->setUseLMChroma( uiCode != 0 ); } @@ -2209,6 +1818,11 @@ void HLSyntaxReader::parseSPS(SPS* pcSPS) READ_FLAG( uiCode, "sps_chroma_horizontal_collocated_flag" ); pcSPS->setHorCollocatedChromaFlag( uiCode != 0 ); READ_FLAG( uiCode, "sps_chroma_vertical_collocated_flag" ); pcSPS->setVerCollocatedChromaFlag( uiCode != 0 ); } + else + { + pcSPS->setHorCollocatedChromaFlag(true); + pcSPS->setVerCollocatedChromaFlag(true); + } READ_FLAG( uiCode, "sps_mts_enabled_flag" ); pcSPS->setUseMTS ( uiCode != 0 ); if ( pcSPS->getUseMTS() ) @@ -2216,29 +1830,26 @@ void HLSyntaxReader::parseSPS(SPS* pcSPS) READ_FLAG( uiCode, "sps_explicit_mts_intra_enabled_flag" ); pcSPS->setUseIntraMTS ( uiCode != 0 ); READ_FLAG( uiCode, "sps_explicit_mts_inter_enabled_flag" ); pcSPS->setUseInterMTS ( uiCode != 0 ); } -#if JVET_Q0798_SPS_NUMBER_MERGE_CANDIDATE READ_UVLC(uiCode, "six_minus_max_num_merge_cand"); CHECK(MRG_MAX_NUM_CANDS <= uiCode, "Incorrrect max number of merge candidates!"); pcSPS->setMaxNumMergeCand(MRG_MAX_NUM_CANDS - uiCode); -#endif READ_FLAG(uiCode, "sps_sbt_enabled_flag"); pcSPS->setUseSBT ( uiCode != 0 ); READ_FLAG( uiCode, "sps_affine_enabled_flag" ); pcSPS->setUseAffine ( uiCode != 0 ); if ( pcSPS->getUseAffine() ) { -#if JVET_Q0798_SPS_NUMBER_MERGE_CANDIDATE READ_UVLC(uiCode, "five_minus_max_num_subblock_merge_cand"); +#if JVET_R0371_MAX_NUM_SUB_BLK_MRG_CAND + CHECK(uiCode > 5 - (pcSPS->getSBTMVPEnabledFlag() ? 1 : 0), "The value of five_minus_max_num_subblock_merge_cand shall be in the range of 0 to 5 - sps_sbtmvp_enabled_flag"); + CHECK(AFFINE_MRG_MAX_NUM_CANDS < uiCode, "The value of five_minus_max_num_subblock_merge_cand shall be in the range of 0 to 5 - sps_sbtmvp_enabled_flag"); +#else CHECK(AFFINE_MRG_MAX_NUM_CANDS < uiCode, "Incorrrect max number of affine merge candidates!"); - pcSPS->setMaxNumAffineMergeCand(AFFINE_MRG_MAX_NUM_CANDS - uiCode); #endif + pcSPS->setMaxNumAffineMergeCand(AFFINE_MRG_MAX_NUM_CANDS - uiCode); READ_FLAG( uiCode, "sps_affine_type_flag" ); pcSPS->setUseAffineType ( uiCode != 0 ); -#if JVET_Q0444_AMVR_SIGNALLING if( pcSPS->getAMVREnabledFlag()) { -#endif READ_FLAG( uiCode, "sps_affine_amvr_enabled_flag" ); pcSPS->setAffineAmvrEnabledFlag ( uiCode != 0 ); -#if JVET_Q0444_AMVR_SIGNALLING } -#endif READ_FLAG( uiCode, "sps_affine_prof_enabled_flag" ); pcSPS->setUsePROF ( uiCode != 0 ); if (pcSPS->getUsePROF()) { @@ -2248,38 +1859,8 @@ void HLSyntaxReader::parseSPS(SPS* pcSPS) pcSPS->setProfControlPresentFlag( false ); } } -#if !JVET_Q0820_ACT -#if JVET_Q0265 - if (chromaArrayType == CHROMA_444) -#else - if (pcSPS->getChromaFormatIdc() == CHROMA_444) -#endif - { - READ_FLAG(uiCode, "sps_act_enabled_flag"); pcSPS->setUseColorTrans(uiCode != 0); - } - else - { - pcSPS->setUseColorTrans(false); - } -#endif -#if JVET_Q0504_PLT_NON444 READ_FLAG( uiCode, "sps_palette_enabled_flag"); pcSPS->setPLTMode ( uiCode != 0 ); -#else - if (pcSPS->getChromaFormatIdc() == CHROMA_444) - { - READ_FLAG( uiCode, "sps_palette_enabled_flag"); pcSPS->setPLTMode ( uiCode != 0 ); - } - else - { - pcSPS->setPLTMode(false); - } -#endif -#if JVET_Q0820_ACT -#if JVET_Q0265 if (chromaArrayType == CHROMA_444 && pcSPS->getLog2MaxTbSize() != 6) -#else - if (pcSPS->getChromaFormatIdc() == CHROMA_444 && pcSPS->getLog2MaxTbSize() != 6) -#endif { READ_FLAG(uiCode, "sps_act_enabled_flag"); pcSPS->setUseColorTrans(uiCode != 0); } @@ -2287,19 +1868,22 @@ void HLSyntaxReader::parseSPS(SPS* pcSPS) { pcSPS->setUseColorTrans(false); } -#endif -#if JVET_Q0183_SPS_TRANSFORM_SKIP_MODE_CONTROL if (pcSPS->getTransformSkipEnabledFlag() || pcSPS->getPLTMode()) { +#if JVET_R0045_TS_MIN_QP_CLEANUP + READ_UVLC(uiCode, "sps_internal_bit_depth_minus_input_bit_depth"); + pcSPS->setInternalMinusInputBitDepth(CHANNEL_TYPE_LUMA, uiCode); + CHECK(uiCode > 8, "Invalid sps_internal_bit_depth_minus_input_bit_depth signalled"); + pcSPS->setInternalMinusInputBitDepth(CHANNEL_TYPE_CHROMA, uiCode); +#else READ_UVLC(uiCode, "min_qp_prime_ts_minus4"); pcSPS->setMinQpPrimeTsMinus4(CHANNEL_TYPE_LUMA, uiCode); CHECK(uiCode > 48, "Invalid min_qp_prime_ts_minus4 signalled"); pcSPS->setMinQpPrimeTsMinus4(CHANNEL_TYPE_CHROMA, uiCode); - } #endif + } READ_FLAG( uiCode, "sps_bcw_enabled_flag" ); pcSPS->setUseBcw( uiCode != 0 ); READ_FLAG(uiCode, "sps_ibc_enabled_flag"); pcSPS->setIBCFlag(uiCode); -#if JVET_Q0798_SPS_NUMBER_MERGE_CANDIDATE if (pcSPS->getIBCFlag()) { READ_UVLC(uiCode, "six_minus_max_num_ibc_merge_cand"); @@ -2308,7 +1892,6 @@ void HLSyntaxReader::parseSPS(SPS* pcSPS) } else pcSPS->setMaxNumIBCMergeCand(0); -#endif // KJS: sps_ciip_enabled_flag READ_FLAG( uiCode, "sps_ciip_enabled_flag" ); pcSPS->setUseCiip ( uiCode != 0 ); @@ -2317,31 +1900,6 @@ void HLSyntaxReader::parseSPS(SPS* pcSPS) READ_FLAG( uiCode, "sps_fpel_mmvd_enabled_flag" ); pcSPS->setFpelMmvdEnabledFlag ( uiCode != 0 ); } -#if !JVET_Q0806 -#if JVET_Q0798_SPS_NUMBER_MERGE_CANDIDATE - if (pcSPS->getMaxNumMergeCand() >= 2) - { - READ_FLAG(uiCode, "triangle_flag"); - pcSPS->setUseTriangle(uiCode != 0); - if (pcSPS->getUseTriangle() && pcSPS->getMaxNumMergeCand() >= 3) - { - READ_UVLC(uiCode, "max_num_merge_cand_minus_max_num_gpm_cand"); - CHECK(pcSPS->getMaxNumMergeCand() < uiCode, "Incorrrect max number of Triangle candidates!"); - pcSPS->setMaxNumGeoCand((uint32_t)(pcSPS->getMaxNumMergeCand() - uiCode)); - } - else if (pcSPS->getUseTriangle()) - pcSPS->setMaxNumGeoCand(2); - } - else - { - pcSPS->setUseTriangle(0); - pcSPS->setMaxNumGeoCand(0); - } -#else - READ_FLAG( uiCode, "triangle_flag" ); pcSPS->setUseTriangle ( uiCode != 0 ); -#endif -#else -#if JVET_Q0798_SPS_NUMBER_MERGE_CANDIDATE if (pcSPS->getMaxNumMergeCand() >= 2) { READ_FLAG(uiCode, "sps_gpm_enabled_flag"); @@ -2360,10 +1918,6 @@ void HLSyntaxReader::parseSPS(SPS* pcSPS) pcSPS->setUseGeo(0); pcSPS->setMaxNumGeoCand(0); } -#else - READ_FLAG( uiCode, "sps_gpm_enabled_flag" ); pcSPS->setUseGeo ( uiCode != 0 ); -#endif -#endif READ_FLAG(uiCode, "sps_lmcs_enable_flag"); pcSPS->setUseLmcs(uiCode == 1); READ_FLAG( uiCode, "sps_lfnst_enabled_flag" ); pcSPS->setUseLFNST( uiCode != 0 ); @@ -2383,38 +1937,53 @@ void HLSyntaxReader::parseSPS(SPS* pcSPS) } #endif -#if JVET_Q0297_MER READ_UVLC(uiCode, "log2_parallel_merge_level_minus2"); + CHECK(uiCode + 2 > ctbLog2SizeY, "The value of log2_parallel_merge_level_minus2 shall be in the range of 0 to ctbLog2SizeY - 2"); pcSPS->setLog2ParallelMergeLevelMinus2(uiCode); -#endif -#if JVET_Q0346_SCALING_LIST_USED_IN_SH READ_FLAG(uiCode, "sps_explicit_scaling_list_enabled_flag"); pcSPS->setScalingListFlag(uiCode); -#else - READ_FLAG( uiCode, "sps_scaling_list_enabled_flag" ); pcSPS->setScalingListFlag ( uiCode ); +#if JVET_R0380_SCALING_MATRIX_DISABLE_YCC_OR_RGB + if (pcSPS->getUseColorTrans() && pcSPS->getScalingListFlag()) + { + READ_FLAG(uiCode, "sps_scaling_matrix_for_alternative_colour_space_disabled_flag"); pcSPS->setScalingMatrixForAlternativeColourSpaceDisabledFlag(uiCode); + } + if (pcSPS->getScalingMatrixForAlternativeColourSpaceDisabledFlag()) + { + READ_FLAG(uiCode, "sps_scaling_matrix_designated_colour_space_flag"); pcSPS->setScalingMatrixDesignatedColourSpaceFlag(uiCode); + } #endif - -#if JVET_Q0246_VIRTUAL_BOUNDARY_ENABLE_FLAG + READ_FLAG(uiCode, "sps_dep_quant_enabled_flag"); pcSPS->setDepQuantEnabledFlag(uiCode); + if (!pcSPS->getDepQuantEnabledFlag()) + { + READ_FLAG(uiCode, "sps_sign_data_hiding_enabled_flag"); pcSPS->setSignDataHidingEnabledFlag(uiCode); + } + else + { + pcSPS->setSignDataHidingEnabledFlag(false); + } READ_FLAG( uiCode, "sps_virtual_boundaries_enabled_flag" ); pcSPS->setVirtualBoundariesEnabledFlag( uiCode != 0 ); if( pcSPS->getVirtualBoundariesEnabledFlag() ) { READ_FLAG( uiCode, "sps_loop_filter_across_virtual_boundaries_present_flag" ); pcSPS->setVirtualBoundariesPresentFlag( uiCode != 0 ); if( pcSPS->getVirtualBoundariesPresentFlag() ) { -#else - READ_FLAG( uiCode, "sps_loop_filter_across_virtual_boundaries_disabled_present_flag" ); pcSPS->setLoopFilterAcrossVirtualBoundariesDisabledFlag( uiCode != 0 ); - if( pcSPS->getLoopFilterAcrossVirtualBoundariesDisabledFlag() ) - { -#endif READ_CODE( 2, uiCode, "sps_num_ver_virtual_boundaries"); pcSPS->setNumVerVirtualBoundaries( uiCode ); for( unsigned i = 0; i < pcSPS->getNumVerVirtualBoundaries(); i++ ) { +#if JVET_R0266_DESC + READ_UVLC(uiCode, "sps_virtual_boundaries_pos_x"); pcSPS->setVirtualBoundariesPosX(uiCode << 3, i); +#else READ_CODE(13, uiCode, "sps_virtual_boundaries_pos_x"); pcSPS->setVirtualBoundariesPosX(uiCode << 3, i); +#endif } READ_CODE( 2, uiCode, "sps_num_hor_virtual_boundaries"); pcSPS->setNumHorVirtualBoundaries( uiCode ); for( unsigned i = 0; i < pcSPS->getNumHorVirtualBoundaries(); i++ ) { +#if JVET_R0266_DESC + READ_UVLC(uiCode, "sps_virtual_boundaries_pos_y"); pcSPS->setVirtualBoundariesPosY(uiCode << 3, i); +#else READ_CODE(13, uiCode, "sps_virtual_boundaries_pos_y"); pcSPS->setVirtualBoundariesPosY(uiCode << 3, i); +#endif } } else @@ -2422,36 +1991,14 @@ void HLSyntaxReader::parseSPS(SPS* pcSPS) pcSPS->setNumVerVirtualBoundaries( 0 ); pcSPS->setNumHorVirtualBoundaries( 0 ); } -#if JVET_Q0246_VIRTUAL_BOUNDARY_ENABLE_FLAG } -#endif -#if JVET_P0117_PTL_SCALABILITY if (pcSPS->getPtlDpbHrdParamsPresentFlag()) { -#endif -#if !JVET_P0118_HRD_ASPECTS - TimingInfo *timingInfo = pcSPS->getTimingInfo(); -#endif -#if JVET_P0118_HRD_ASPECTS READ_FLAG(uiCode, "sps_general_hrd_params_present_flag"); pcSPS->setGeneralHrdParametersPresentFlag(uiCode); -#else - READ_FLAG( uiCode, "general_hrd_parameters_present_flag"); pcSPS->setHrdParametersPresentFlag(uiCode); -#endif -#if JVET_P0118_HRD_ASPECTS if (pcSPS->getGeneralHrdParametersPresentFlag()) -#else - if( pcSPS->getHrdParametersPresentFlag() ) -#endif { -#if !JVET_P0118_HRD_ASPECTS - READ_CODE( 32, uiCode, "num_units_in_tick"); timingInfo->setNumUnitsInTick (uiCode); - READ_CODE( 32, uiCode, "time_scale"); timingInfo->setTimeScale (uiCode); -#endif -#if JVET_P0118_HRD_ASPECTS parseGeneralHrdParameters(pcSPS->getGeneralHrdParameters()); -#endif -#if JVET_P0118_HRD_ASPECTS if ((pcSPS->getMaxTLayers()-1) > 0) { READ_FLAG(uiCode, "sps_sublayer_cpb_params_present_flag"); pcSPS->setSubLayerParametersPresentFlag(uiCode); @@ -2463,25 +2010,10 @@ void HLSyntaxReader::parseSPS(SPS* pcSPS) uint32_t firstSubLayer = pcSPS->getSubLayerParametersPresentFlag() ? 0 : (pcSPS->getMaxTLayers() - 1); parseOlsHrdParameters(pcSPS->getGeneralHrdParameters(),pcSPS->getOlsHrdParameters(), firstSubLayer, pcSPS->getMaxTLayers() - 1); -#else - READ_FLAG( uiCode, "sub_layer_cpb_parameters_present_flag"); pcSPS->setSubLayerParametersPresentFlag(uiCode); - if (pcSPS->getSubLayerParametersPresentFlag()) - { - parseHrdParameters(pcSPS->getHrdParameters(), 0, pcSPS->getMaxTLayers() - 1); - } - else - { - parseHrdParameters(pcSPS->getHrdParameters(), pcSPS->getMaxTLayers() - 1, pcSPS->getMaxTLayers() - 1); - } -#endif } -#if JVET_P0117_PTL_SCALABILITY } -#endif -#if JVET_Q0042_VUI READ_FLAG( uiCode, "field_seq_flag"); pcSPS->setFieldSeqFlag(uiCode); -#endif READ_FLAG( uiCode, "vui_parameters_present_flag" ); pcSPS->setVuiParametersPresentFlag(uiCode); @@ -2552,7 +2084,6 @@ void HLSyntaxReader::parseSPS(SPS* pcSPS) xReadRbspTrailingBits(); } -#if JVET_Q0117_PARAMETER_SETS_CLEANUP void HLSyntaxReader::parseDCI(DCI* dci) { #if ENABLE_TRACING @@ -2571,11 +2102,7 @@ void HLSyntaxReader::parseDCI(DCI* dci) ptls.resize(numPTLs); for (int i = 0; i < numPTLs; i++) { -#if JVET_Q0786_PTL_only parseProfileTierLevel(&ptls[i], true, 0); -#else - parseProfileTierLevel(&ptls[i], 0); -#endif } dci->setProfileTierLevel(ptls); @@ -2589,48 +2116,6 @@ void HLSyntaxReader::parseDCI(DCI* dci) } xReadRbspTrailingBits(); } -#else -void HLSyntaxReader::parseDPS(DPS* dps) -{ -#if ENABLE_TRACING - xTraceDPSHeader (); -#endif - uint32_t symbol; - - READ_CODE( 4, symbol, "dps_decoding_parameter_set_id" ); - CHECK(symbol == 0, "dps_decoding_parameter_set_id equal to zero is reserved and should not be use in a bitstream"); - dps->setDecodingParameterSetId( symbol ); - - READ_CODE( 3, symbol, "dps_max_sub_layers_minus1" ); dps->setMaxSubLayersMinus1( symbol ); - READ_CODE( 5, symbol, "dps_reserved_zero_5bits" ); CHECK(symbol != 0, "dps_reserved_zero_5bits must be equal to zero"); - - uint32_t numPTLs; - READ_CODE( 4, numPTLs, "dps_num_ptls_minus1" ); - numPTLs += 1; - - std::vector<ProfileTierLevel> ptls; - ptls.resize(numPTLs); - for (int i=0; i<numPTLs; i++) - { -#if JVET_Q0786_PTL_only - parseProfileTierLevel(&ptls[i], true, 0); -#else - parseProfileTierLevel(&ptls[i], dps->getMaxSubLayersMinus1()); -#endif - } - dps->setProfileTierLevel(ptls); - - READ_FLAG( symbol, "dps_extension_flag" ); - if (symbol) - { - while ( xMoreRbspData() ) - { - READ_FLAG( symbol, "dps_extension_data_flag"); - } - } - xReadRbspTrailingBits(); -} -#endif void HLSyntaxReader::parseVPS(VPS* pcVPS) { @@ -2639,16 +2124,16 @@ void HLSyntaxReader::parseVPS(VPS* pcVPS) #endif uint32_t uiCode; - READ_CODE(4, uiCode, "vps_video_parameter_set_id"); + READ_CODE(4, uiCode, "vps_video_parameter_set_id"); CHECK( uiCode == 0, "vps_video_parameter_set_id equal to zero is reserved and shall not be used in a bitstream" ); pcVPS->setVPSId(uiCode); - READ_CODE(6, uiCode, "vps_max_layers_minus1"); pcVPS->setMaxLayers(uiCode + 1); CHECK(uiCode + 1 > MAX_VPS_LAYERS, "Invalid code"); + READ_CODE(6, uiCode, "vps_max_layers_minus1"); pcVPS->setMaxLayers(uiCode + 1); CHECK(uiCode + 1 > MAX_VPS_LAYERS, "Signalled number of layers larger than MAX_VPS_LAYERS."); if (pcVPS->getMaxLayers() - 1 == 0) { pcVPS->setEachLayerIsAnOlsFlag(1); } - READ_CODE(3, uiCode, "vps_max_sublayers_minus1"); pcVPS->setMaxSubLayers(uiCode + 1); CHECK(uiCode + 1 > MAX_VPS_SUBLAYERS, "Invalid code"); + READ_CODE(3, uiCode, "vps_max_sublayers_minus1"); pcVPS->setMaxSubLayers(uiCode + 1); CHECK(uiCode + 1 > MAX_VPS_SUBLAYERS, "Signalled number of sublayers larger than MAX_VPS_SUBLAYERS."); if( pcVPS->getMaxLayers() > 1 && pcVPS->getMaxSubLayers() > 1) { READ_FLAG(uiCode, "vps_all_layers_same_num_sublayers_flag"); pcVPS->setAllLayersSameNumSublayersFlag(uiCode); @@ -2705,7 +2190,7 @@ void HLSyntaxReader::parseVPS(VPS* pcVPS) { if (!pcVPS->getAllIndependentLayersFlag()) { - READ_CODE(2, uiCode, "ols_mode_idc"); pcVPS->setOlsModeIdc(uiCode); CHECK(uiCode > MAX_VPS_OLS_MODE_IDC, "Invalid code"); + READ_CODE(2, uiCode, "ols_mode_idc"); pcVPS->setOlsModeIdc(uiCode); CHECK(uiCode > MAX_VPS_OLS_MODE_IDC, "ols_mode_idc shall be in the rage of 0 to 2"); } if (pcVPS->getOlsModeIdc() == 2) { @@ -2721,21 +2206,25 @@ void HLSyntaxReader::parseVPS(VPS* pcVPS) } } -#if JVET_Q0786_PTL_only pcVPS->deriveOutputLayerSets(); READ_CODE(8, uiCode, "vps_num_ptls_minus1"); pcVPS->setNumPtls(uiCode + 1); +#if JVET_R0191_ASPECT3 + CHECK( uiCode >= pcVPS->getTotalNumOLSs(),"The value of vps_num_ptls_minus1 shall be less than TotalNumOlss"); + std::vector<bool> isPTLReferred( pcVPS->getNumPtls(), false); +#endif + for (int i = 0; i < pcVPS->getNumPtls(); i++) { if(i > 0) { - READ_FLAG(uiCode, "pt_present_flag"); + READ_FLAG(uiCode, "pt_present_flag"); pcVPS->setPtPresentFlag(i, uiCode); } else pcVPS->setPtPresentFlag(0, 1); if(pcVPS->getMaxSubLayers() > 1 && !pcVPS->getAllLayersSameNumSublayersFlag()) { - READ_CODE(3, uiCode, "ptl_max_temporal_id"); + READ_CODE(3, uiCode, "ptl_max_temporal_id"); pcVPS->setPtlMaxTemporalId(i, uiCode); } else if(pcVPS->getMaxSubLayers() > 1) @@ -2760,22 +2249,44 @@ void HLSyntaxReader::parseVPS(VPS* pcVPS) pcVPS->setProfileTierLevel(ptls); for (int i = 0; i < pcVPS->getTotalNumOLSs(); i++) { +#if JVET_R0161_CONDITION_SIGNAL_PTL_IDX + if (pcVPS->getNumPtls() > 1 && pcVPS->getNumPtls() != pcVPS->getTotalNumOLSs()) +#else if(pcVPS->getNumPtls() > 1) +#endif { READ_CODE(8, uiCode, "ols_ptl_idx"); pcVPS->setOlsPtlIdx(i, uiCode); } +#if JVET_R0161_CONDITION_SIGNAL_PTL_IDX + else if (pcVPS->getNumPtls() == pcVPS->getTotalNumOLSs()) + { + pcVPS->setOlsPtlIdx(i, i); + } +#endif else pcVPS->setOlsPtlIdx(i, 0); +#if JVET_R0191_ASPECT3 + isPTLReferred[pcVPS->getOlsPtlIdx(i)] = true; +#endif + } +#if JVET_R0191_ASPECT3 + for( int i = 0; i < pcVPS->getNumPtls(); i++ ) + { + CHECK( !isPTLReferred[i],"Each profile_tier_level( ) syntax structure in the VPS shall be referred to by at least one value of vps_ols_ptl_idx[ i ] for i in the range of 0 to TotalNumOlss ? 1, inclusive"); } #endif -#if JVET_Q0814_DPB if( !pcVPS->getAllIndependentLayersFlag() ) { READ_UVLC( uiCode, "vps_num_dpb_params" ); pcVPS->m_numDpbParams = uiCode; } +#if JVET_R0191_ASPECT3 + CHECK( pcVPS->m_numDpbParams > pcVPS->getNumMultiLayeredOlss(),"The value of vps_num_dpb_params_minus1 shall be in the range of 0 to NumMultiLayerOlss ? 1, inclusive"); + std::vector<bool> isDPBParamReferred(pcVPS->m_numDpbParams, false); +#endif + if( pcVPS->m_numDpbParams > 0 && pcVPS->getMaxSubLayers() > 1 ) { READ_FLAG( uiCode, "vps_sublayer_dpb_params_present_flag" ); pcVPS->m_sublayerDpbParamsPresentFlag = uiCode; @@ -2823,9 +2334,6 @@ void HLSyntaxReader::parseVPS(VPS* pcVPS) } } -#if !JVET_Q0786_PTL_only - pcVPS->deriveOutputLayerSets(); -#endif for( int i = 0; i < pcVPS->getTotalNumOLSs(); i++ ) { @@ -2837,10 +2345,21 @@ void HLSyntaxReader::parseVPS(VPS* pcVPS) { READ_UVLC( uiCode, "ols_dpb_params_idx[i]" ); pcVPS->setOlsDpbParamsIdx( i, uiCode ); } +#if JVET_R0191_ASPECT3 + else + { + pcVPS->setOlsDpbParamsIdx( i, 0 ); + } + isDPBParamReferred[pcVPS->getOlsDpbParamsIdx(i)] = true; +#endif } } +#if JVET_R0191_ASPECT3 + for( int i = 0; i < pcVPS->m_numDpbParams; i++ ) + { + CHECK( !isDPBParamReferred[i],"Each dpb_parameters( ) syntax structure in the VPS shall be referred to by at least one value of vps_ols_dpb_params_idx[i] for i in the range of 0 to NumMultiLayerOlss ? 1, inclusive"); + } #endif -#if JVET_P0118_HRD_ASPECTS if (!pcVPS->getEachLayerIsAnOlsFlag()) { READ_FLAG(uiCode, "vps_general_hrd_params_present_flag"); pcVPS->setVPSGeneralHrdParamsPresentFlag(uiCode); @@ -2858,7 +2377,12 @@ void HLSyntaxReader::parseVPS(VPS* pcVPS) } READ_UVLC(uiCode, "num_ols_hrd_params_minus1"); pcVPS->setNumOlsHrdParamsMinus1(uiCode); +#if JVET_R0191_ASPECT3 + CHECK( uiCode >= pcVPS->getNumMultiLayeredOlss(),"The value of vps_num_ols_hrd_params_minus1 shall be in the range of 0 to NumMultiLayerOlss ? 1, inclusive"); + std::vector<bool> isHRDParamReferred( uiCode + 1, false); +#else CHECK(uiCode >= pcVPS->getTotalNumOLSs(),"The value of num_ols_hrd_params_minus1 shall be in the range of 0 to TotalNumOlss - 1, inclusive"); +#endif pcVPS->m_olsHrdParams.clear(); pcVPS->m_olsHrdParams.resize(pcVPS->getNumOlsHrdParamsMinus1(), std::vector<OlsHrdParams>(pcVPS->getMaxSubLayers())); for (int i = 0; i <= pcVPS->getNumOlsHrdParamsMinus1(); i++) @@ -2877,7 +2401,7 @@ void HLSyntaxReader::parseVPS(VPS* pcVPS) { pcVPS->setHrdMaxTid(i, pcVPS->getMaxSubLayers()- 1); } - + } uint32_t firstSublayer = pcVPS->getVPSSublayerCpbParamsPresentFlag() ? 0 : pcVPS->getHrdMaxTid(i); parseOlsHrdParameters(pcVPS->getGeneralHrdParameters(),pcVPS->getOlsHrdParameters(i), firstSublayer, pcVPS->getHrdMaxTid(i)); @@ -2900,9 +2424,17 @@ void HLSyntaxReader::parseVPS(VPS* pcVPS) { pcVPS->setOlsHrdIdx(i, 0); } +#if JVET_R0191_ASPECT3 + isHRDParamReferred[pcVPS->getOlsHrdIdx(i)] = true; +#endif + } +#if JVET_R0191_ASPECT3 + for( int i = 0; i <= pcVPS->getNumOlsHrdParamsMinus1(); i++ ) + { + CHECK( !isHRDParamReferred[i], "Each ols_hrd_parameters( ) syntax structure in the VPS shall be referred to by at least one value of vps_ols_hrd_idx[ i ] for i in the range of 1 to NumMultiLayerOlss ? 1, inclusive"); } - } #endif + } READ_FLAG(uiCode, "vps_extension_flag"); if (uiCode) @@ -2916,22 +2448,17 @@ void HLSyntaxReader::parseVPS(VPS* pcVPS) xReadRbspTrailingBits(); } -#if JVET_Q0775_PH_IN_SH void HLSyntaxReader::parsePictureHeader( PicHeader* picHeader, ParameterSetManager *parameterSetManager, bool readRbspTrailingBits ) -#else -void HLSyntaxReader::parsePictureHeader( PicHeader* picHeader, ParameterSetManager *parameterSetManager ) -#endif { - uint32_t uiCode; + uint32_t uiCode; int iCode; PPS* pps = NULL; SPS* sps = NULL; - + #if ENABLE_TRACING xTracePictureHeader(); #endif -#if JVET_Q0819_PH_CHANGES READ_FLAG(uiCode, "gdr_or_irap_pic_flag"); picHeader->setGdrOrIrapPicFlag(uiCode != 0); if (picHeader->getGdrOrIrapPicFlag()) { @@ -2947,12 +2474,7 @@ void HLSyntaxReader::parsePictureHeader( PicHeader* picHeader, ParameterSetManag picHeader->setPicIntraSliceAllowedFlag(true); } CHECK(picHeader->getPicInterSliceAllowedFlag() == 0 && picHeader->getPicIntraSliceAllowedFlag() == 0, "Invalid picture without intra or inter slice"); -#endif READ_FLAG(uiCode, "non_reference_picture_flag"); picHeader->setNonReferencePictureFlag( uiCode != 0 ); -#if !JVET_Q0819_PH_CHANGES - READ_FLAG(uiCode, "gdr_pic_flag"); picHeader->setGdrPicFlag( uiCode != 0 ); -#endif -#if JVET_Q0819_PH_CHANGES // parameter sets READ_UVLC(uiCode, "ph_pic_parameter_set_id"); picHeader->setPPSId(uiCode); @@ -2967,19 +2489,15 @@ void HLSyntaxReader::parsePictureHeader( PicHeader* picHeader, ParameterSetManag { READ_FLAG(uiCode, "no_output_of_prior_pics_flag"); picHeader->setNoOutputOfPriorPicsFlag(uiCode != 0); } -#else - READ_FLAG(uiCode, "no_output_of_prior_pics_flag"); picHeader->setNoOutputOfPriorPicsFlag( uiCode != 0 ); -#endif - if( picHeader->getGdrPicFlag() ) + if( picHeader->getGdrPicFlag() ) { READ_UVLC(uiCode, "recovery_poc_cnt"); picHeader->setRecoveryPocCnt( uiCode ); } - else + else { picHeader->setRecoveryPocCnt( 0 ); } - -#if JVET_Q0400_EXTRA_BITS + std::vector<bool> phExtraBitsPresent = sps->getExtraPHBitPresentFlags(); for (int i=0; i< sps->getNumExtraPHBitsBytes() * 8; i++) { @@ -2989,9 +2507,7 @@ void HLSyntaxReader::parsePictureHeader( PicHeader* picHeader, ParameterSetManag READ_FLAG(uiCode, "ph_extra_bit[ i ]"); } } -#endif - -#if JVET_P0116_POC_MSB + if (sps->getPocMsbFlag()) { READ_FLAG(uiCode, "ph_poc_msb_present_flag"); picHeader->setPocMsbPresentFlag(uiCode != 0); @@ -3001,40 +2517,24 @@ void HLSyntaxReader::parsePictureHeader( PicHeader* picHeader, ParameterSetManag picHeader->setPocMsbVal(uiCode); } } -#endif -#if !JVET_Q0819_PH_CHANGES - // parameter sets - READ_UVLC(uiCode, "ph_pic_parameter_set_id"); - picHeader->setPPSId( uiCode ); - pps = parameterSetManager->getPPS(picHeader->getPPSId()); - CHECK(pps==0, "Invalid PPS"); - picHeader->setSPSId( pps->getSPSId() ); - sps = parameterSetManager->getSPS(picHeader->getSPSId()); - CHECK(sps==0, "Invalid SPS"); -#endif -#if JVET_Q0819_PH_CHANGES // alf enable flags and aps IDs -#if JVET_Q0795_CCALF picHeader->setCcAlfEnabledFlag(COMPONENT_Cb, false); picHeader->setCcAlfEnabledFlag(COMPONENT_Cr, false); -#endif if (sps->getALFEnabledFlag()) { -#if JVET_Q0819_PH_CHANGES if (pps->getAlfInfoInPhFlag()) -#else - READ_FLAG(uiCode, "pic_alf_enabled_present_flag"); - picHeader->setAlfEnabledPresentFlag(uiCode != 0); - - if (picHeader->getAlfEnabledPresentFlag()) -#endif { READ_FLAG(uiCode, "ph_alf_enabled_flag"); picHeader->setAlfEnabledFlag(COMPONENT_Y, uiCode); +#if JVET_R0225_SEPERATE_FLAGS_ALF_CHROMA + int alfCbEnabledFlag = 0; + int alfCrEnabledFlag = 0; +#else int alfChromaIdc = 0; +#endif if (uiCode) { READ_CODE(3, uiCode, "ph_num_alf_aps_ids_luma"); @@ -3051,22 +2551,33 @@ void HLSyntaxReader::parsePictureHeader( PicHeader* picHeader, ParameterSetManag if (sps->getChromaFormatIdc() != CHROMA_400) { +#if JVET_R0225_SEPERATE_FLAGS_ALF_CHROMA + READ_CODE(1, uiCode, "ph_alf_cb_enabled_flag"); alfCbEnabledFlag = uiCode; + READ_CODE(1, uiCode, "ph_alf_cr_enabled_flag"); alfCrEnabledFlag = uiCode; +#else READ_CODE(2, uiCode, "ph_alf_chroma_idc"); alfChromaIdc = uiCode; +#endif } else { +#if JVET_R0225_SEPERATE_FLAGS_ALF_CHROMA + alfCbEnabledFlag = 0; + alfCrEnabledFlag = 0; +#else alfChromaIdc = 0; +#endif } -#if JVET_Q0358_ALF_NALU_TID_CONSTRAINT +#if JVET_R0225_SEPERATE_FLAGS_ALF_CHROMA + if (alfCbEnabledFlag || alfCrEnabledFlag) +#else picHeader->setAlfChromaIdc(alfChromaIdc); -#endif if (alfChromaIdc) +#endif { READ_CODE(3, uiCode, "ph_alf_aps_id_chroma"); picHeader->setAlfApsIdChroma(uiCode); } -#if JVET_Q0795_CCALF if (sps->getCCALFEnabledFlag()) { READ_FLAG(uiCode, "ph_cc_alf_cb_enabled_flag"); @@ -3089,14 +2600,18 @@ void HLSyntaxReader::parsePictureHeader( PicHeader* picHeader, ParameterSetManag picHeader->setCcAlfCrApsId(uiCode); } } -#endif } else { picHeader->setNumAlfAps(0); } +#if JVET_R0225_SEPERATE_FLAGS_ALF_CHROMA + picHeader->setAlfEnabledFlag(COMPONENT_Cb, alfCbEnabledFlag); + picHeader->setAlfEnabledFlag(COMPONENT_Cr, alfCrEnabledFlag); +#else picHeader->setAlfEnabledFlag(COMPONENT_Cb, alfChromaIdc & 1); picHeader->setAlfEnabledFlag(COMPONENT_Cr, alfChromaIdc >> 1); +#endif } else { @@ -3141,15 +2656,9 @@ void HLSyntaxReader::parsePictureHeader( PicHeader* picHeader, ParameterSetManag // quantization scaling lists if (sps->getScalingListFlag()) { -#if JVET_Q0346_SCALING_LIST_USED_IN_SH READ_FLAG(uiCode, "ph_explicit_scaling_list_enabled_flag"); picHeader->setExplicitScalingListEnabledFlag(uiCode); if (picHeader->getExplicitScalingListEnabledFlag()) -#else - READ_FLAG(uiCode, "ph_scaling_list_present_flag"); - picHeader->setScalingListPresentFlag(uiCode); - if (picHeader->getScalingListPresentFlag()) -#endif { READ_CODE(3, uiCode, "ph_scaling_list_aps_id"); picHeader->setScalingListAPSId(uiCode); @@ -3157,15 +2666,11 @@ void HLSyntaxReader::parsePictureHeader( PicHeader* picHeader, ParameterSetManag } else { -#if JVET_Q0346_SCALING_LIST_USED_IN_SH picHeader->setExplicitScalingListEnabledFlag(false); -#else - picHeader->setScalingListPresentFlag(false); -#endif } -#endif - + // initialize tile/slice info for no partitioning case + if( pps->getNoPicPartitionFlag() ) { pps->resetTileSliceInfo(); @@ -3180,92 +2685,47 @@ void HLSyntaxReader::parsePictureHeader( PicHeader* picHeader, ParameterSetManag pps->initRectSlices( ); pps->setTileIdxDeltaPresentFlag( 0 ); pps->setSliceTileIdx( 0, 0 ); - pps->initRectSliceMap( ); -#if JVET_O1143_SUBPIC_BOUNDARY + pps->initRectSliceMap(sps); // when no Pic partition, number of sub picture shall be less than 2 CHECK(pps->getNumSubPics()>=2, "error, no picture partitions, but have equal to or more than 2 sub pictures"); -#endif } - else + else { CHECK(pps->getCtuSize() != sps->getCTUSize(), "PPS CTU size does not match CTU size in SPS"); + if (pps->getRectSliceFlag()) + { + pps->initRectSliceMap(sps); + } } -#if JVET_Q0044_SLICE_IDX_WITH_SUBPICS pps->initSubPic(*sps); -#endif -#if !JVET_Q0119_CLEANUPS - // sub-picture IDs - if( sps->getSubPicIdPresentFlag() ) - { - if( sps->getSubPicIdSignallingPresentFlag() ) - { - for( int picIdx = 0; picIdx < sps->getNumSubPics( ); picIdx++ ) - { - picHeader->setSubPicId( picIdx, sps->getSubPicId( picIdx ) ); - } - } - else - { - READ_FLAG(uiCode, "ph_subpic_id_signalling_present_flag"); picHeader->setSubPicIdSignallingPresentFlag( uiCode != 0 ); - if( picHeader->getSubPicIdSignallingPresentFlag() ) - { - READ_UVLC( uiCode, "ph_subpic_id_len_minus1" ); picHeader->setSubPicIdLen( uiCode + 1 ); - CHECK( uiCode > 15, "Invalid ph_subpic_id_len_minus1 signalled"); -#if JVET_Q0169_SUBPIC_LEN_CONFORM - CHECK((1 << picHeader->getSubPicIdLen()) < sps->getNumSubPics(), "ph_subpic_id_len exceeds valid range"); -#endif - for( int picIdx = 0; picIdx < sps->getNumSubPics( ); picIdx++ ) - { - READ_CODE( picHeader->getSubPicIdLen( ), uiCode, "ph_subpic_id[i]" ); picHeader->setSubPicId( picIdx, uiCode ); - } - } - else - { - for( int picIdx = 0; picIdx < sps->getNumSubPics( ); picIdx++ ) - { - picHeader->setSubPicId( picIdx, pps->getSubPicId( picIdx ) ); - } - } - } - } - else - { - for( int picIdx = 0; picIdx < sps->getNumSubPics( ); picIdx++ ) - { - picHeader->setSubPicId( picIdx, picIdx ); - } - } -#endif // virtual boundaries -#if JVET_Q0246_VIRTUAL_BOUNDARY_ENABLE_FLAG if( sps->getVirtualBoundariesEnabledFlag() && !sps->getVirtualBoundariesPresentFlag() ) { READ_FLAG( uiCode, "ph_virtual_boundaries_present_flag" ); picHeader->setVirtualBoundariesPresentFlag( uiCode != 0 ); -#if JVET_Q0210_SUBPIC_VIRTUAL_BOUNDARY_CONSTRAINT CHECK( sps->getSubPicInfoPresentFlag() && picHeader->getVirtualBoundariesPresentFlag(), "When the subpicture info is present, the signalling of the virtual boundary position, if present, shall be in SPS" ); -#endif if( picHeader->getVirtualBoundariesPresentFlag() ) { -#else - if( !sps->getLoopFilterAcrossVirtualBoundariesDisabledFlag() ) - { - READ_FLAG( uiCode, "ph_loop_filter_across_virtual_boundaries_disabled_present_flag" ); picHeader->setLoopFilterAcrossVirtualBoundariesDisabledFlag( uiCode != 0 ); - if( picHeader->getLoopFilterAcrossVirtualBoundariesDisabledFlag() ) - { -#endif READ_CODE( 2, uiCode, "ph_num_ver_virtual_boundaries"); picHeader->setNumVerVirtualBoundaries( uiCode ); for( unsigned i = 0; i < picHeader->getNumVerVirtualBoundaries(); i++ ) { +#if JVET_R0266_DESC + READ_UVLC(uiCode, "ph_virtual_boundaries_pos_x"); picHeader->setVirtualBoundariesPosX(uiCode << 3, i); +#else READ_CODE(13, uiCode, "ph_virtual_boundaries_pos_x"); picHeader->setVirtualBoundariesPosX(uiCode << 3, i); +#endif } READ_CODE( 2, uiCode, "ph_num_hor_virtual_boundaries"); picHeader->setNumHorVirtualBoundaries( uiCode ); for( unsigned i = 0; i < picHeader->getNumHorVirtualBoundaries(); i++ ) { +#if JVET_R0266_DESC + READ_UVLC(uiCode, "ph_virtual_boundaries_pos_y"); picHeader->setVirtualBoundariesPosY(uiCode << 3, i); +#else READ_CODE(13, uiCode, "ph_virtual_boundaries_pos_y"); picHeader->setVirtualBoundariesPosY(uiCode << 3, i); +#endif } } else @@ -3276,69 +2736,40 @@ void HLSyntaxReader::parsePictureHeader( PicHeader* picHeader, ParameterSetManag } else { -#if JVET_Q0246_VIRTUAL_BOUNDARY_ENABLE_FLAG picHeader->setVirtualBoundariesPresentFlag( sps->getVirtualBoundariesPresentFlag() ); if( picHeader->getVirtualBoundariesPresentFlag() ) { -#else - picHeader->setLoopFilterAcrossVirtualBoundariesDisabledFlag( sps->getLoopFilterAcrossVirtualBoundariesDisabledFlag() ); -#endif picHeader->setNumVerVirtualBoundaries( sps->getNumVerVirtualBoundaries() ); picHeader->setNumHorVirtualBoundaries( sps->getNumHorVirtualBoundaries() ); - for( unsigned i = 0; i < 3; i++ ) + for( unsigned i = 0; i < 3; i++ ) { picHeader->setVirtualBoundariesPosX( sps->getVirtualBoundariesPosX(i), i ); picHeader->setVirtualBoundariesPosY( sps->getVirtualBoundariesPosY(i), i ); } -#if JVET_Q0246_VIRTUAL_BOUNDARY_ENABLE_FLAG } -#endif - } - -#if !JVET_Q0155_COLOUR_ID - // 4:4:4 colour plane ID - if( sps->getSeparateColourPlaneFlag() ) - { - READ_CODE( 2, uiCode, "colour_plane_id" ); picHeader->setColourPlaneId( uiCode ); - CHECK(uiCode > 2, "colour_plane_id exceeds valid range"); } - else - { - picHeader->setColourPlaneId( 0 ); - } -#endif + // picture output flag if( pps->getOutputFlagPresentFlag() ) { READ_FLAG( uiCode, "pic_output_flag" ); picHeader->setPicOutputFlag( uiCode != 0 ); } - else + else { picHeader->setPicOutputFlag( true ); } // reference picture lists -#if JVET_Q0819_PH_CHANGES if (pps->getRplInfoInPhFlag()) -#else - READ_FLAG(uiCode, "pic_rpl_present_flag"); - picHeader->setPicRplPresentFlag(uiCode != 0); - if( picHeader->getPicRplPresentFlag() ) -#endif { bool rplSpsFlag0 = 0; // List0 and List1 - for(int listIdx = 0; listIdx < 2; listIdx++) - { -#if JVET_Q0482_REMOVE_CONSTANT_PARAMS + for(int listIdx = 0; listIdx < 2; listIdx++) + { if (sps->getNumRPL(listIdx) > 0 && (listIdx == 0 || (listIdx == 1 && pps->getRpl1IdxPresentFlag()))) -#else - if (sps->getNumRPL(listIdx) > 0 && !pps->getPPSRefPicListSPSIdc(listIdx) && - (listIdx == 0 || (listIdx == 1 && pps->getRpl1IdxPresentFlag()))) -#endif { READ_FLAG(uiCode, "rpl_sps_flag[i]"); } @@ -3346,12 +2777,6 @@ void HLSyntaxReader::parsePictureHeader( PicHeader* picHeader, ParameterSetManag { uiCode = 0; } -#if !JVET_Q0482_REMOVE_CONSTANT_PARAMS - else if (pps->getRpl1IdxPresentFlag()) - { - uiCode = pps->getPPSRefPicListSPSIdc(listIdx) - 1; - } -#endif else { uiCode = rplSpsFlag0; @@ -3367,7 +2792,11 @@ void HLSyntaxReader::parsePictureHeader( PicHeader* picHeader, ParameterSetManag { ReferencePictureList* rpl = picHeader->getLocalRPL( listIdx ); (*rpl) = ReferencePictureList(); +#if JVET_R0059_RPL_CLEANUP + parseRefPicList(sps, rpl, -1); +#else parseRefPicList(sps, rpl); +#endif picHeader->setRPLIdx(listIdx, -1); picHeader->setRPL(listIdx, rpl); } @@ -3449,7 +2878,6 @@ void HLSyntaxReader::parsePictureHeader( PicHeader* picHeader, ParameterSetManag if (sps->getSplitConsOverrideEnabledFlag()) { READ_FLAG(uiCode, "partition_constraints_override_flag"); picHeader->setSplitConsOverrideFlag( uiCode != 0 ); -#if JVET_Q0819_PH_CHANGES } else { @@ -3464,24 +2892,13 @@ void HLSyntaxReader::parsePictureHeader( PicHeader* picHeader, ParameterSetManag if (picHeader->getPicIntraSliceAllowedFlag()) { -#endif if (picHeader->getSplitConsOverrideFlag()) { -#if !JVET_Q0819_PH_CHANGES - unsigned minQT[3] = { 0, 0, 0 }; - unsigned maxBTD[3] = { 0, 0, 0 }; - unsigned maxBTSize[3] = { 0, 0, 0 }; - unsigned maxTTSize[3] = { 0, 0, 0 }; - unsigned ctbLog2SizeY = floorLog2(sps->getCTUSize()); -#endif READ_UVLC(uiCode, "ph_log2_diff_min_qt_min_cb_intra_slice_luma"); unsigned minQtLog2SizeIntraY = uiCode + sps->getLog2MinCodingBlockSize(); minQT[0] = 1 << minQtLog2SizeIntraY; -#if !JVET_Q0819_PH_CHANGES - READ_UVLC(uiCode, "ph_log2_diff_min_qt_min_cb_inter_slice"); - unsigned minQtLog2SizeInterY = uiCode + sps->getLog2MinCodingBlockSize(); - minQT[1] = 1 << minQtLog2SizeInterY; - READ_UVLC(uiCode, "ph_max_mtt_hierarchy_depth_inter_slice"); maxBTD[1] = uiCode; +#if JVET_R0347_MTT_SIZE_CONSTRAIN + CHECK(minQT[0] > 64, "The value of ph_log2_diff_min_qt_min_cb_intra_slice_luma shall be in the range of 0 to min(6,CtbLog2SizeY) - MinCbLog2Size"); #endif READ_UVLC(uiCode, "ph_max_mtt_hierarchy_depth_intra_slice_luma"); maxBTD[0] = uiCode; @@ -3489,92 +2906,55 @@ void HLSyntaxReader::parsePictureHeader( PicHeader* picHeader, ParameterSetManag if (maxBTD[0] != 0) { READ_UVLC(uiCode, "ph_log2_diff_max_bt_min_qt_intra_slice_luma"); maxBTSize[0] <<= uiCode; - CHECK(uiCode > ctbLog2SizeY - minQtLog2SizeIntraY, "Invalid code"); + CHECK(uiCode > ctbLog2SizeY - minQtLog2SizeIntraY, "The value of ph_log2_diff_max_bt_min_qt_intra_slice_luma shall be in the range of 0 to CtbLog2SizeY - MinQtLog2SizeIntraY"); READ_UVLC(uiCode, "ph_log2_diff_max_tt_min_qt_intra_slice_luma"); maxTTSize[0] <<= uiCode; - CHECK(uiCode > ctbLog2SizeY - minQtLog2SizeIntraY, "Invalid code"); + CHECK(uiCode > ctbLog2SizeY - minQtLog2SizeIntraY, "The value of ph_log2_diff_max_tt_min_qt_intra_slice_luma shall be in the range of 0 to CtbLog2SizeY - MinQtLog2SizeIntraY"); +#if JVET_R0347_MTT_SIZE_CONSTRAIN + CHECK(maxTTSize[0] > 64, "The value of ph_log2_diff_max_tt_min_qt_intra_slice_luma shall be in the range of 0 to min(6,CtbLog2SizeY) - MinQtLog2SizeIntraY"); +#endif } -#if !JVET_Q0819_PH_CHANGES - maxTTSize[1] = maxBTSize[1] = minQT[1]; - if (maxBTD[1] != 0) - { - READ_UVLC(uiCode, "ph_log2_diff_max_bt_min_qt_inter_slice"); maxBTSize[1] <<= uiCode; - CHECK(uiCode > ctbLog2SizeY - minQtLog2SizeInterY, "Invalid code"); - READ_UVLC(uiCode, "ph_log2_diff_max_tt_min_qt_inter_slice"); maxTTSize[1] <<= uiCode; - CHECK(uiCode > ctbLog2SizeY - minQtLog2SizeInterY, "Invalid code"); - } -#endif if (sps->getUseDualITree()) { READ_UVLC(uiCode, "ph_log2_diff_min_qt_min_cb_intra_slice_chroma"); minQT[2] = 1 << (uiCode + sps->getLog2MinCodingBlockSize()); +#if JVET_R0347_MTT_SIZE_CONSTRAIN + CHECK(minQT[2] > 64, "The value of ph_log2_diff_min_qt_min_cb_intra_slice_chroma shall be in the range of 0 to min(6,CtbLog2SizeY) - MinCbLog2Size"); +#endif READ_UVLC(uiCode, "ph_max_mtt_hierarchy_depth_intra_slice_chroma"); maxBTD[2] = uiCode; maxTTSize[2] = maxBTSize[2] = minQT[2]; if (maxBTD[2] != 0) { READ_UVLC(uiCode, "ph_log2_diff_max_bt_min_qt_intra_slice_chroma"); maxBTSize[2] <<= uiCode; READ_UVLC(uiCode, "ph_log2_diff_max_tt_min_qt_intra_slice_chroma"); maxTTSize[2] <<= uiCode; +#if JVET_R0347_MTT_SIZE_CONSTRAIN + CHECK(maxBTSize[2] > 64, "The value of ph_log2_diff_max_bt_min_qt_intra_slice_chroma shall be in the range of 0 to min(6,CtbLog2SizeY) - MinQtLog2SizeIntraChroma"); + CHECK(maxTTSize[2] > 64, "The value of ph_log2_diff_max_tt_min_qt_intra_slice_chroma shall be in the range of 0 to min(6,CtbLog2SizeY) - MinQtLog2SizeIntraChroma"); +#endif } } -#if !JVET_Q0819_PH_CHANGES - picHeader->setMinQTSizes(minQT); - picHeader->setMaxMTTHierarchyDepths(maxBTD); - picHeader->setMaxBTSizes(maxBTSize); - picHeader->setMaxTTSizes(maxTTSize); -#endif } } -#if !JVET_Q0819_PH_CHANGES - else - { - picHeader->setSplitConsOverrideFlag(0); - } -#endif -#if !JVET_Q0819_PH_CHANGES - // inherit constraint values from SPS - if (!sps->getSplitConsOverrideEnabledFlag() || !picHeader->getSplitConsOverrideFlag()) - { - picHeader->setMinQTSizes(sps->getMinQTSizes()); - picHeader->setMaxMTTHierarchyDepths(sps->getMaxMTTHierarchyDepths()); - picHeader->setMaxBTSizes(sps->getMaxBTSizes()); - picHeader->setMaxTTSizes(sps->getMaxTTSizes()); - } -#endif -#if JVET_Q0819_PH_CHANGES if (picHeader->getPicIntraSliceAllowedFlag()) { -#endif // delta quantization and chrom and chroma offset if (pps->getUseDQP()) { READ_UVLC( uiCode, "ph_cu_qp_delta_subdiv_intra_slice" ); picHeader->setCuQpDeltaSubdivIntra( uiCode ); -#if !JVET_Q0819_PH_CHANGES - READ_UVLC( uiCode, "ph_cu_qp_delta_subdiv_inter_slice" ); picHeader->setCuQpDeltaSubdivInter( uiCode ); -#endif } - else + else { picHeader->setCuQpDeltaSubdivIntra( 0 ); -#if !JVET_Q0819_PH_CHANGES - picHeader->setCuQpDeltaSubdivInter( 0 ); -#endif } if (pps->getCuChromaQpOffsetListEnabledFlag()) { READ_UVLC( uiCode, "ph_cu_chroma_qp_offset_subdiv_intra_slice" ); picHeader->setCuChromaQpOffsetSubdivIntra( uiCode ); -#if !JVET_Q0819_PH_CHANGES - READ_UVLC( uiCode, "ph_cu_chroma_qp_offset_subdiv_inter_slice" ); picHeader->setCuChromaQpOffsetSubdivInter( uiCode ); -#endif } - else + else { picHeader->setCuChromaQpOffsetSubdivIntra( 0 ); -#if !JVET_Q0819_PH_CHANGES - picHeader->setCuChromaQpOffsetSubdivInter( 0 ); -#endif } -#if JVET_Q0819_PH_CHANGES } @@ -3585,15 +2965,22 @@ void HLSyntaxReader::parsePictureHeader( PicHeader* picHeader, ParameterSetManag READ_UVLC(uiCode, "ph_log2_diff_min_qt_min_cb_inter_slice"); unsigned minQtLog2SizeInterY = uiCode + sps->getLog2MinCodingBlockSize(); minQT[1] = 1 << minQtLog2SizeInterY; +#if JVET_R0347_MTT_SIZE_CONSTRAIN + CHECK(minQT[1] > 64, "The value of ph_log2_diff_min_qt_min_cb_inter_slice shall be in the range of 0 to min(6, CtbLog2SizeY) - MinCbLog2SizeY."); + CHECK(minQT[1] > (1<<ctbLog2SizeY), "The value of ph_log2_diff_min_qt_min_cb_inter_slice shall be in the range of 0 to min(6, CtbLog2SizeY) - MinCbLog2SizeY"); +#endif READ_UVLC(uiCode, "ph_max_mtt_hierarchy_depth_inter_slice"); maxBTD[1] = uiCode; maxTTSize[1] = maxBTSize[1] = minQT[1]; if (maxBTD[1] != 0) { READ_UVLC(uiCode, "ph_log2_diff_max_bt_min_qt_inter_slice"); maxBTSize[1] <<= uiCode; - CHECK(uiCode > ctbLog2SizeY - minQtLog2SizeInterY, "Invalid code"); + CHECK(uiCode > ctbLog2SizeY - minQtLog2SizeInterY, "The value of ph_log2_diff_max_bt_min_qt_inter_slice shall be in the range of 0 to CtbLog2SizeY - MinQtLog2SizeInterY"); READ_UVLC(uiCode, "ph_log2_diff_max_tt_min_qt_inter_slice"); maxTTSize[1] <<= uiCode; - CHECK(uiCode > ctbLog2SizeY - minQtLog2SizeInterY, "Invalid code"); + CHECK(uiCode > ctbLog2SizeY - minQtLog2SizeInterY, "The value of ph_log2_diff_max_tt_min_qt_inter_slice shall be in the range of 0 to CtbLog2SizeY - MinQtLog2SizeInterY"); +#if JVET_R0347_MTT_SIZE_CONSTRAIN + CHECK(maxTTSize[1] > 64, "The value of ph_log2_diff_max_tt_min_qt_inter_slice shall be in the range of 0 to min(6,CtbLog2SizeY) - MinQtLog2SizeInterY."); +#endif } } // delta quantization and chrom and chroma offset @@ -3614,7 +3001,6 @@ void HLSyntaxReader::parsePictureHeader( PicHeader* picHeader, ParameterSetManag picHeader->setCuChromaQpOffsetSubdivInter(0); } -#endif // temporal motion vector prediction if (sps->getSPSTemporalMVPEnabledFlag()) { @@ -3626,12 +3012,22 @@ void HLSyntaxReader::parsePictureHeader( PicHeader* picHeader, ParameterSetManag picHeader->setEnableTMVPFlag(false); } -#if JVET_Q0482_REMOVE_CONSTANT_PARAMS if (picHeader->getEnableTMVPFlag() && pps->getRplInfoInPhFlag()) { +#if R0324_PH_SYNTAX_CONDITION_MODIFY + if (picHeader->getRPL(1)->getNumRefEntries() > 0) + { + READ_CODE(1, uiCode, "ph_collocated_from_l0_flag"); + picHeader->setPicColFromL0Flag(uiCode); + } + else + { + picHeader->setPicColFromL0Flag(1); + } +#else READ_CODE( 1, uiCode, "ph_collocated_from_l0_flag"); picHeader->setPicColFromL0Flag(uiCode); -#if JVET_Q0259_COLLOCATED_PIC_IN_PH +#endif if ((picHeader->getPicColFromL0Flag() == 1 && picHeader->getRPL(0)->getNumRefEntries() > 1) || (picHeader->getPicColFromL0Flag() == 0 && picHeader->getRPL(1)->getNumRefEntries() > 1)) { @@ -3642,56 +3038,32 @@ void HLSyntaxReader::parsePictureHeader( PicHeader* picHeader, ParameterSetManag { picHeader->setColRefIdx(0); } -#endif } else { picHeader->setPicColFromL0Flag(0); } -#endif // mvd L1 zero flag -#if !JVET_Q0482_REMOVE_CONSTANT_PARAMS - if (!pps->getPPSMvdL1ZeroIdc()) +#if R0324_PH_SYNTAX_CONDITION_MODIFY + if (!pps->getRplInfoInPhFlag() || picHeader->getRPL(1)->getNumRefEntries() > 0) { - READ_FLAG(uiCode, "mvd_l1_zero_flag"); + READ_FLAG(uiCode, "pic_mvd_l1_zero_flag"); } else { - uiCode = pps->getPPSMvdL1ZeroIdc() - 1; + uiCode = 1; } #else READ_FLAG(uiCode, "mvd_l1_zero_flag"); #endif picHeader->setMvdL1ZeroFlag( uiCode != 0 ); - + // merge candidate list size -#if !JVET_Q0798_SPS_NUMBER_MERGE_CANDIDATE -#if !JVET_Q0482_REMOVE_CONSTANT_PARAMS - if (!pps->getPPSSixMinusMaxNumMergeCandPlus1()) - { - READ_UVLC(uiCode, "pic_six_minus_max_num_merge_cand"); - } - else - { - uiCode = pps->getPPSSixMinusMaxNumMergeCandPlus1() - 1; - } -#else - READ_UVLC(uiCode, "pic_six_minus_max_num_merge_cand"); -#endif - CHECK(MRG_MAX_NUM_CANDS <= uiCode, "Incorrrect max number of merge candidates!"); - picHeader->setMaxNumMergeCand(MRG_MAX_NUM_CANDS - uiCode); -#endif // subblock merge candidate list size if ( sps->getUseAffine() ) { -#if JVET_Q0798_SPS_NUMBER_MERGE_CANDIDATE picHeader->setMaxNumAffineMergeCand(sps->getMaxNumAffineMergeCand()); -#else - READ_UVLC(uiCode, "pic_five_minus_max_num_subblock_merge_cand"); - CHECK(AFFINE_MRG_MAX_NUM_CANDS < uiCode, "Incorrrect max number of affine merge candidates!"); - picHeader->setMaxNumAffineMergeCand( AFFINE_MRG_MAX_NUM_CANDS - uiCode ); -#endif } else { @@ -3708,25 +3080,55 @@ void HLSyntaxReader::parsePictureHeader( PicHeader* picHeader, ParameterSetManag { picHeader->setDisFracMMVD(false); } - + // picture level BDOF disable flags +#if R0324_PH_SYNTAX_CONDITION_MODIFY + if (sps->getBdofControlPresentFlag() && (!pps->getRplInfoInPhFlag() || picHeader->getRPL(1)->getNumRefEntries() > 0)) +#else if (sps->getBdofControlPresentFlag()) +#endif { READ_FLAG(uiCode, "ph_disable_bdof_flag"); picHeader->setDisBdofFlag(uiCode != 0); } else { +#if R0324_PH_SYNTAX_CONDITION_MODIFY + if (sps->getBdofControlPresentFlag() == 0) + { + picHeader->setDisBdofFlag(1 - (int)(sps->getBDOFEnabledFlag())); + } + else + { + picHeader->setDisBdofFlag(1); + } +#else picHeader->setDisBdofFlag(0); +#endif } // picture level DMVR disable flags +#if R0324_PH_SYNTAX_CONDITION_MODIFY + if (sps->getDmvrControlPresentFlag() && (!pps->getRplInfoInPhFlag() || picHeader->getRPL(1)->getNumRefEntries() > 0)) +#else if (sps->getDmvrControlPresentFlag()) +#endif { READ_FLAG(uiCode, "ph_disable_dmvr_flag"); picHeader->setDisDmvrFlag(uiCode != 0); } else { +#if R0324_PH_SYNTAX_CONDITION_MODIFY + if (sps->getDmvrControlPresentFlag() == 0) + { + picHeader->setDisDmvrFlag(1 - (int)(sps->getUseDMVR())); + } + else + { + picHeader->setDisDmvrFlag(1); + } +#else picHeader->setDisDmvrFlag(0); +#endif } // picture level PROF disable flags @@ -3739,62 +3141,10 @@ void HLSyntaxReader::parsePictureHeader( PicHeader* picHeader, ParameterSetManag picHeader->setDisProfFlag(0); } -#if JVET_Q0819_PH_CHANGES if( (pps->getUseWP() || pps->getWPBiPred()) && pps->getWpInfoInPhFlag() ) { parsePredWeightTable(picHeader, sps); } -#endif -#if !JVET_Q0798_SPS_NUMBER_MERGE_CANDIDATE -#if !JVET_Q0806 - // triangle merge candidate list size - if (sps->getUseTriangle() && picHeader->getMaxNumMergeCand() >= 2) - { -#if !JVET_Q0482_REMOVE_CONSTANT_PARAMS - if (!pps->getPPSMaxNumMergeCandMinusMaxNumTriangleCandPlus1()) - { - READ_UVLC(uiCode, "pic_max_num_merge_cand_minus_max_num_triangle_cand"); - } - else - { - uiCode = pps->getPPSMaxNumMergeCandMinusMaxNumTriangleCandPlus1() - 1; - } -#else - READ_UVLC(uiCode, "pic_max_num_merge_cand_minus_max_num_triangle_cand"); -#endif - CHECK(picHeader->getMaxNumMergeCand() < uiCode, "Incorrrect max number of triangle candidates!"); - picHeader->setMaxNumTriangleCand((uint32_t)(picHeader->getMaxNumMergeCand() - uiCode)); - } - else - { - picHeader->setMaxNumTriangleCand(0); - } -#else - // geometric merge candidate list size - if (sps->getUseGeo() && picHeader->getMaxNumMergeCand() >= 2) - { -#if !JVET_Q0482_REMOVE_CONSTANT_PARAMS - if (!pps->getPPSMaxNumMergeCandMinusMaxNumGeoCandPlus1()) - { - READ_UVLC(uiCode, "pic_max_num_merge_cand_minus_max_num_gpm_cand"); - } - else - { - uiCode = pps->getPPSMaxNumMergeCandMinusMaxNumGeoCandPlus1() - 1; - } -#else - READ_UVLC(uiCode, "pic_max_num_merge_cand_minus_max_num_gpm_cand"); -#endif - CHECK(picHeader->getMaxNumMergeCand() < uiCode, "Incorrrect max number of gpm candidates!"); - picHeader->setMaxNumGeoCand((uint32_t)(picHeader->getMaxNumMergeCand() - uiCode)); - } - else - { - picHeader->setMaxNumGeoCand(0); - } -#endif -#endif -#if JVET_Q0819_PH_CHANGES } // inherit constraint values from SPS if (!sps->getSplitConsOverrideEnabledFlag() || !picHeader->getSplitConsOverrideFlag()) @@ -3811,28 +3161,13 @@ void HLSyntaxReader::parsePictureHeader( PicHeader* picHeader, ParameterSetManag picHeader->setMaxBTSizes(maxBTSize); picHeader->setMaxTTSizes(maxTTSize); } -#endif // ibc merge candidate list size -#if !JVET_Q0798_SPS_NUMBER_MERGE_CANDIDATE - if (sps->getIBCFlag()) - { - READ_UVLC(uiCode, "pic_six_minus_max_num_ibc_merge_cand"); - CHECK(IBC_MRG_MAX_NUM_CANDS <= uiCode, "Incorrrect max number of IBC merge candidates!"); - picHeader->setMaxNumIBCMergeCand(IBC_MRG_MAX_NUM_CANDS - uiCode); - } - else - { - picHeader->setMaxNumIBCMergeCand(0); - } -#endif -#if JVET_Q0819_PH_CHANGES if (pps->getQpDeltaInfoInPhFlag()) { int iCode = 0; READ_SVLC(iCode, "ph_qp_delta"); picHeader->setQpDelta(iCode); } -#endif // joint Cb/Cr sign flag if (sps->getJointCbCrEnabledFlag()) @@ -3848,153 +3183,44 @@ void HLSyntaxReader::parsePictureHeader( PicHeader* picHeader, ParameterSetManag // sao enable flags if(sps->getSAOEnabledFlag()) { -#if JVET_Q0819_PH_CHANGES if (pps->getSaoInfoInPhFlag()) -#else - READ_FLAG(uiCode, "pic_sao_enabled_present_flag"); - picHeader->setSaoEnabledPresentFlag(uiCode != 0); - - if (picHeader->getSaoEnabledPresentFlag()) -#endif - { -#if JVET_Q0819_PH_CHANGES + { READ_FLAG(uiCode, "ph_sao_luma_enabled_flag"); -#else - READ_FLAG(uiCode, "slice_sao_luma_flag"); -#endif picHeader->setSaoEnabledFlag(CHANNEL_TYPE_LUMA, uiCode != 0); if (sps->getChromaFormatIdc() != CHROMA_400) { -#if JVET_Q0819_PH_CHANGES READ_FLAG(uiCode, "ph_sao_chroma_enabled_flag"); -#else - READ_FLAG(uiCode, "slice_sao_chroma_flag"); -#endif picHeader->setSaoEnabledFlag(CHANNEL_TYPE_CHROMA, uiCode != 0); } } - else + else { picHeader->setSaoEnabledFlag(CHANNEL_TYPE_LUMA, true); picHeader->setSaoEnabledFlag(CHANNEL_TYPE_CHROMA, sps->getChromaFormatIdc() != CHROMA_400); } } - else + else { picHeader->setSaoEnabledFlag(CHANNEL_TYPE_LUMA, false); picHeader->setSaoEnabledFlag(CHANNEL_TYPE_CHROMA, false); } -#if !JVET_Q0819_PH_CHANGES - // alf enable flags and aps IDs -#if JVET_Q0795_CCALF - picHeader->setCcAlfEnabledFlag(COMPONENT_Cb, false); - picHeader->setCcAlfEnabledFlag(COMPONENT_Cr, false); -#endif - if( sps->getALFEnabledFlag() ) - { - READ_FLAG(uiCode, "pic_alf_enabled_present_flag"); - picHeader->setAlfEnabledPresentFlag(uiCode != 0); - - if (picHeader->getAlfEnabledPresentFlag()) - { - READ_FLAG(uiCode, "pic_alf_enabled_flag"); - picHeader->setAlfEnabledFlag(COMPONENT_Y, uiCode); - - int alfChromaIdc = 0; - if (uiCode) - { - READ_CODE(3, uiCode, "pic_num_alf_aps_ids_luma"); - int numAps = uiCode; - picHeader->setNumAlfAps(numAps); - - std::vector<int> apsId(numAps, -1); - for (int i = 0; i < numAps; i++) - { - READ_CODE(3, uiCode, "pic_alf_aps_id_luma"); - apsId[i] = uiCode; - } - picHeader->setAlfAPSs(apsId); - - if (sps->getChromaFormatIdc() != CHROMA_400) - { - READ_CODE(2, uiCode, "pic_alf_chroma_idc"); - alfChromaIdc = uiCode; - } - else - { - alfChromaIdc = 0; - } - if (alfChromaIdc) - { - READ_CODE(3, uiCode, "pic_alf_aps_id_chroma"); - picHeader->setAlfApsIdChroma(uiCode); - } -#if JVET_Q0795_CCALF - if (sps->getCCALFEnabledFlag()) - { - READ_FLAG(uiCode, "ph_cc_alf_cb_enabled_flag"); - picHeader->setCcAlfEnabledFlag(COMPONENT_Cb, uiCode != 0); - picHeader->setCcAlfCbApsId(-1); - if (picHeader->getCcAlfEnabledFlag(COMPONENT_Cb)) - { - // parse APS ID - READ_CODE(3, uiCode, "ph_cc_alf_cb_aps_id"); - picHeader->setCcAlfCbApsId(uiCode); - } - // Cr - READ_FLAG(uiCode, "ph_cc_alf_cr_enabled_flag"); - picHeader->setCcAlfEnabledFlag(COMPONENT_Cr, uiCode != 0); - picHeader->setCcAlfCrApsId(-1); - if (picHeader->getCcAlfEnabledFlag(COMPONENT_Cr)) - { - // parse APS ID - READ_CODE(3, uiCode, "ph_cc_alf_cr_aps_id"); - picHeader->setCcAlfCrApsId(uiCode); - } - } -#endif - } - else - { - picHeader->setNumAlfAps(0); - } - picHeader->setAlfEnabledFlag(COMPONENT_Cb, alfChromaIdc & 1); - picHeader->setAlfEnabledFlag(COMPONENT_Cr, alfChromaIdc >> 1); - } - else - { - picHeader->setAlfEnabledFlag(COMPONENT_Y, true); - picHeader->setAlfEnabledFlag(COMPONENT_Cb, true); - picHeader->setAlfEnabledFlag(COMPONENT_Cr, true); - } - } - else - { - picHeader->setAlfEnabledFlag(COMPONENT_Y, false); - picHeader->setAlfEnabledFlag(COMPONENT_Cb, false); - picHeader->setAlfEnabledFlag(COMPONENT_Cr, false); - } -#endif +#if !JVET_R0271_SLICE_LEVEL_DQ_SDH_RRC // dependent quantization -#if !JVET_Q0482_REMOVE_CONSTANT_PARAMS - if (!pps->getPPSDepQuantEnabledIdc()) + if (sps->getDepQuantEnabledFlag()) { READ_FLAG(uiCode, "ph_dep_quant_enabled_flag"); + picHeader->setDepQuantEnabledFlag(uiCode != 0); } else { - uiCode = pps->getPPSDepQuantEnabledIdc() - 1; + picHeader->setDepQuantEnabledFlag(false); } -#else - READ_FLAG(uiCode, "ph_dep_quant_enabled_flag"); -#endif - picHeader->setDepQuantEnabledFlag( uiCode != 0 ); // sign data hiding - if( !picHeader->getDepQuantEnabledFlag() ) + if (sps->getSignDataHidingEnabledFlag() && !picHeader->getDepQuantEnabledFlag()) { READ_FLAG( uiCode, "pic_sign_data_hiding_enabled_flag" ); picHeader->setSignDataHidingEnabledFlag( uiCode != 0 ); @@ -4003,20 +3229,14 @@ void HLSyntaxReader::parsePictureHeader( PicHeader* picHeader, ParameterSetManag { picHeader->setSignDataHidingEnabledFlag(false); } +#endif // deblocking filter controls if (pps->getDeblockingFilterControlPresentFlag()) { if(pps->getDeblockingFilterOverrideEnabledFlag()) { -#if JVET_Q0819_PH_CHANGES if (pps->getDbfInfoInPhFlag()) -#else - READ_FLAG(uiCode, "ph_deblocking_filter_override_present_flag"); - picHeader->setDeblockingFilterOverridePresentFlag(uiCode != 0); - - if( picHeader->getDeblockingFilterOverridePresentFlag() ) -#endif { READ_FLAG ( uiCode, "ph_deblocking_filter_override_flag" ); picHeader->setDeblockingFilterOverrideFlag(uiCode != 0); @@ -4028,17 +3248,24 @@ void HLSyntaxReader::parsePictureHeader( PicHeader* picHeader, ParameterSetManag } else { -#if !JVET_Q0819_PH_CHANGES - picHeader->setDeblockingFilterOverridePresentFlag(false); -#endif picHeader->setDeblockingFilterOverrideFlag(false); } if(picHeader->getDeblockingFilterOverrideFlag()) { -#if JVET_Q0121_DEBLOCKING_CONTROL_PARAMETERS - READ_FLAG( uiCode, "ph_deblocking_filter_disabled_flag" ); - picHeader->setDeblockingFilterDisable(uiCode != 0); +#if JVET_R0388_DBF_CLEANUP + if (!pps->getPPSDeblockingFilterDisabledFlag()) + { +#endif + READ_FLAG(uiCode, "ph_deblocking_filter_disabled_flag"); + picHeader->setDeblockingFilterDisable(uiCode != 0); +#if JVET_R0388_DBF_CLEANUP + } + else + { + picHeader->setDeblockingFilterDisable(false); + } +#endif if (!picHeader->getDeblockingFilterDisable()) { READ_SVLC( iCode, "ph_beta_offset_div2" ); @@ -4071,34 +3298,16 @@ void HLSyntaxReader::parsePictureHeader( PicHeader* picHeader, ParameterSetManag CHECK( picHeader->getDeblockingFilterCrTcOffsetDiv2() < -12 || picHeader->getDeblockingFilterCrTcOffsetDiv2() > 12, "Invalid deblocking filter configuration"); } -#else - READ_FLAG ( uiCode, "pic_deblocking_filter_disabled_flag" ); - picHeader->setDeblockingFilterDisable(uiCode != 0); - if(!picHeader->getDeblockingFilterDisable()) - { - READ_SVLC( iCode, "pic_beta_offset_div2" ); - picHeader->setDeblockingFilterBetaOffsetDiv2(iCode); - CHECK( picHeader->getDeblockingFilterBetaOffsetDiv2() < -6 && - picHeader->getDeblockingFilterBetaOffsetDiv2() > 6, "Invalid deblocking filter configuration"); - - READ_SVLC( iCode, "pic_tc_offset_div2" ); - picHeader->setDeblockingFilterTcOffsetDiv2(iCode); - CHECK (picHeader->getDeblockingFilterTcOffsetDiv2() < -6 && - picHeader->getDeblockingFilterTcOffsetDiv2() > 6, "Invalid deblocking filter configuration"); - } -#endif } else { picHeader->setDeblockingFilterDisable ( pps->getPPSDeblockingFilterDisabledFlag() ); picHeader->setDeblockingFilterBetaOffsetDiv2( pps->getDeblockingFilterBetaOffsetDiv2() ); picHeader->setDeblockingFilterTcOffsetDiv2 ( pps->getDeblockingFilterTcOffsetDiv2() ); -#if JVET_Q0121_DEBLOCKING_CONTROL_PARAMETERS picHeader->setDeblockingFilterCbBetaOffsetDiv2( pps->getDeblockingFilterCbBetaOffsetDiv2() ); picHeader->setDeblockingFilterCbTcOffsetDiv2 ( pps->getDeblockingFilterCbTcOffsetDiv2() ); picHeader->setDeblockingFilterCrBetaOffsetDiv2( pps->getDeblockingFilterCrBetaOffsetDiv2() ); picHeader->setDeblockingFilterCrTcOffsetDiv2 ( pps->getDeblockingFilterCrTcOffsetDiv2() ); -#endif } } else @@ -4106,59 +3315,12 @@ void HLSyntaxReader::parsePictureHeader( PicHeader* picHeader, ParameterSetManag picHeader->setDeblockingFilterDisable ( false ); picHeader->setDeblockingFilterBetaOffsetDiv2( 0 ); picHeader->setDeblockingFilterTcOffsetDiv2 ( 0 ); -#if JVET_Q0121_DEBLOCKING_CONTROL_PARAMETERS picHeader->setDeblockingFilterCbBetaOffsetDiv2( 0 ); picHeader->setDeblockingFilterCbTcOffsetDiv2 ( 0 ); picHeader->setDeblockingFilterCrBetaOffsetDiv2(0); picHeader->setDeblockingFilterCrTcOffsetDiv2(0); -#endif - } - -#if !JVET_Q0819_PH_CHANGES - // luma mapping / chroma scaling controls - if (sps->getUseLmcs()) - { - READ_FLAG(uiCode, "ph_lmcs_enabled_flag"); - picHeader->setLmcsEnabledFlag(uiCode != 0); - - if (picHeader->getLmcsEnabledFlag()) - { - READ_CODE(2, uiCode, "ph_lmcs_aps_id"); - picHeader->setLmcsAPSId(uiCode); - - if (sps->getChromaFormatIdc() != CHROMA_400) - { - READ_FLAG(uiCode, "ph_chroma_residual_scale_flag"); - picHeader->setLmcsChromaResidualScaleFlag(uiCode != 0); - } - else - { - picHeader->setLmcsChromaResidualScaleFlag(false); - } - } - } - else - { - picHeader->setLmcsEnabledFlag(false); - picHeader->setLmcsChromaResidualScaleFlag(false); } - // quantization scaling lists - if( sps->getScalingListFlag() ) - { - READ_FLAG( uiCode, "pic_scaling_list_present_flag" ); - picHeader->setScalingListPresentFlag( uiCode ); - if( picHeader->getScalingListPresentFlag() ) - { - READ_CODE( 3, uiCode, "pic_scaling_list_aps_id" ); - picHeader->setScalingListAPSId( uiCode ); - } - } - else - { - picHeader->setScalingListPresentFlag( false ); - } -#endif // picture header extension if(pps->getPictureHeaderExtensionPresentFlag()) @@ -4171,17 +3333,12 @@ void HLSyntaxReader::parsePictureHeader( PicHeader* picHeader, ParameterSetManag } } -#if JVET_Q0775_PH_IN_SH if( readRbspTrailingBits ) { xReadRbspTrailingBits(); } -#else - xReadRbspTrailingBits(); -#endif } -#if JVET_Q0358_ALF_NALU_TID_CONSTRAINT void HLSyntaxReader::checkAlfNaluTidAndPicTid(Slice* pcSlice, PicHeader* picHeader, ParameterSetManager *parameterSetManager) { SPS* sps = parameterSetManager->getSPS(picHeader->getSPSId()); @@ -4199,7 +3356,11 @@ void HLSyntaxReader::checkAlfNaluTidAndPicTid(Slice* pcSlice, PicHeader* picHea CHECK(aps->getTemporalId() > curPicTid, "The TemporalId of the APS NAL unit having aps_params_type equal to ALF_APS and adaptation_parameter_set_id equal to ph_alf_aps_id_luma[ i ] shall be less than or equal to the TemporalId of the picture associated with the PH."); } //chroma +#if JVET_R0225_SEPERATE_FLAGS_ALF_CHROMA + if (picHeader->getAlfEnabledFlag(COMPONENT_Cb) || picHeader->getAlfEnabledFlag(COMPONENT_Cr)) +#else if (picHeader->getAlfChromaIdc()) +#endif { int chromaAlfApsId = picHeader->getAlfApsIdChroma(); aps = parameterSetManager->getAPS(chromaAlfApsId, ALF_APS); @@ -4207,7 +3368,6 @@ void HLSyntaxReader::checkAlfNaluTidAndPicTid(Slice* pcSlice, PicHeader* picHea } } } -#endif void HLSyntaxReader::parseSliceHeader (Slice* pcSlice, PicHeader* picHeader, ParameterSetManager *parameterSetManager, const int prevTid0POC) { uint32_t uiCode; @@ -4218,7 +3378,6 @@ void HLSyntaxReader::parseSliceHeader (Slice* pcSlice, PicHeader* picHeader, Par #endif PPS* pps = NULL; SPS* sps = NULL; -#if JVET_Q0775_PH_IN_SH READ_FLAG(uiCode, "picture_header_in_slice_header_flag"); if (uiCode) { @@ -4226,37 +3385,38 @@ void HLSyntaxReader::parseSliceHeader (Slice* pcSlice, PicHeader* picHeader, Par parsePictureHeader(picHeader, parameterSetManager, false); picHeader->setValid(); } -#endif CHECK(picHeader==0, "Invalid Picture Header"); CHECK(picHeader->isValid()==false, "Invalid Picture Header"); -#if JVET_Q0358_ALF_NALU_TID_CONSTRAINT checkAlfNaluTidAndPicTid(pcSlice, picHeader, parameterSetManager); -#endif pps = parameterSetManager->getPPS( picHeader->getPPSId() ); //!KS: need to add error handling code here, if PPS is not available CHECK(pps==0, "Invalid PPS"); sps = parameterSetManager->getSPS(pps->getSPSId()); //!KS: need to add error handling code here, if SPS is not available CHECK(sps==0, "Invalid SPS"); +#if JVET_R0202_WHEN_PH_IN_SH_INFO_FLAGS_EQUAL_0 + CHECK(pcSlice->getPictureHeaderInSliceHeader() && pps->getRplInfoInPhFlag() == 1, "When sh_picture_header_in_slice_header_flag is equal to 1, rpl_info_in_ph_flag shall be equal to 0"); + CHECK(pcSlice->getPictureHeaderInSliceHeader() && pps->getDbfInfoInPhFlag() == 1, "When sh_picture_header_in_slice_header_flag is equal to 1, dbf_info_in_ph_flag shall be equal to 0"); + CHECK(pcSlice->getPictureHeaderInSliceHeader() && pps->getSaoInfoInPhFlag() == 1, "When sh_picture_header_in_slice_header_flag is equal to 1, sao_info_in_ph_flag shall be equal to 0"); + CHECK(pcSlice->getPictureHeaderInSliceHeader() && pps->getWpInfoInPhFlag() == 1, "When sh_picture_header_in_slice_header_flag is equal to 1, wp_info_in_ph_flag shall be equal to 0"); + CHECK(pcSlice->getPictureHeaderInSliceHeader() && pps->getQpDeltaInfoInPhFlag() == 1, "When sh_picture_header_in_slice_header_flag is equal to 1, qp_delta_info_in_ph_flag shall be equal to 0"); +#endif +#if JVET_R0202_WHEN_PH_IN_SH_NO_SUBPIC_SEPARATE_COLOR + CHECK(pcSlice->getPictureHeaderInSliceHeader() && sps->getSubPicInfoPresentFlag() == 1, "When sps_subpic_info_present_flag is equal to 1, the value of sh_picture_header_in_slice_header_flag shall be equal to 0"); + CHECK(pcSlice->getPictureHeaderInSliceHeader() && sps->getSeparateColourPlaneFlag() == 1, "when separate_colour_plane_flag is equal to 1, the value of picture_header_in_slice_header_flag shall be equal to 0"); +#endif const ChromaFormat chFmt = sps->getChromaFormatIdc(); const uint32_t numValidComp=getNumberValidComponents(chFmt); const bool bChroma=(chFmt!=CHROMA_400); // picture order count -#if JVET_Q0819_PH_CHANGES uiCode = picHeader->getPocLsb(); -#else - READ_CODE(sps->getBitsForPOC(), uiCode, "slice_pic_order_cnt_lsb"); -#endif -#if JVET_P0116_POC_MSB int iPOClsb = uiCode; int iMaxPOClsb = 1 << sps->getBitsForPOC(); int iPOCmsb; -#endif if (pcSlice->getIdrPicFlag()) { -#if JVET_P0116_POC_MSB if (picHeader->getPocMsbPresentFlag()) { iPOCmsb = picHeader->getPocMsbVal()*iMaxPOClsb; @@ -4266,32 +3426,18 @@ void HLSyntaxReader::parseSliceHeader (Slice* pcSlice, PicHeader* picHeader, Par iPOCmsb = 0; } pcSlice->setPOC(iPOCmsb + iPOClsb); -#else - pcSlice->setPOC(uiCode); -#endif } else { -#if !JVET_P0116_POC_MSB - int iPOClsb = uiCode; -#endif int iPrevPOC = prevTid0POC; -#if !JVET_P0116_POC_MSB - int iMaxPOClsb = 1 << sps->getBitsForPOC(); -#endif int iPrevPOClsb = iPrevPOC & (iMaxPOClsb - 1); int iPrevPOCmsb = iPrevPOC - iPrevPOClsb; -#if !JVET_P0116_POC_MSB - int iPOCmsb; -#endif -#if JVET_P0116_POC_MSB if (picHeader->getPocMsbPresentFlag()) { iPOCmsb = picHeader->getPocMsbVal()*iMaxPOClsb; } else { -#endif if ((iPOClsb < iPrevPOClsb) && ((iPrevPOClsb - iPOClsb) >= (iMaxPOClsb / 2))) { iPOCmsb = iPrevPOCmsb + iMaxPOClsb; @@ -4304,46 +3450,47 @@ void HLSyntaxReader::parseSliceHeader (Slice* pcSlice, PicHeader* picHeader, Par { iPOCmsb = iPrevPOCmsb; } -#if JVET_P0116_POC_MSB } -#endif pcSlice->setPOC(iPOCmsb + iPOClsb); } -#if JVET_Q0119_CLEANUPS if (sps->getSubPicInfoPresentFlag()) -#else - if (sps->getSubPicPresentFlag()) -#endif { uint32_t bitsSubPicId; bitsSubPicId = sps->getSubPicIdLen(); READ_CODE(bitsSubPicId, uiCode, "slice_subpic_id"); pcSlice->setSliceSubPicId(uiCode); } -#if JVET_Q0119_CLEANUPS else { pcSlice->setSliceSubPicId(0); } -#endif // raster scan slices - if(pps->getRectSliceFlag() == 0) + if(pps->getRectSliceFlag() == 0) { uint32_t sliceAddr, numTilesInSlice; // slice address is the raster scan tile index of first tile in slice - if( pps->getNumTiles() > 1 ) - { + if( pps->getNumTiles() > 1 ) + { int bitsSliceAddress = ceilLog2(pps->getNumTiles()); READ_CODE(bitsSliceAddress, uiCode, "slice_address"); sliceAddr = uiCode; - READ_UVLC(uiCode, "num_tiles_in_slice_minus1"); numTilesInSlice = uiCode + 1; -#if JVET_Q0114_CONSTRAINT_FLAGS +#if JVET_R0210_NUMTILESINSLICE_SIGNALLING + if (((int)pps->getNumTiles() - (int)sliceAddr) > 1) + { +#endif + READ_UVLC(uiCode, "num_tiles_in_slice_minus1"); numTilesInSlice = uiCode + 1; +#if JVET_R0210_NUMTILESINSLICE_SIGNALLING + } + else + { + numTilesInSlice = 1; + } +#endif if (!pps->getRectSliceFlag() && sps->getProfileTierLevel()->getConstraintInfo()->getOneSlicePerPicConstraintFlag()) { CHECK(pps->getNumTiles() != uiCode + 1, "When rect_slice_flag is equal to 0 and one_slice_per_pic_constraint_flag equal to 1, the value of num_tiles_in_slice_minus1 present in each slice header shall be equal to NumTilesInPic - 1"); } -#endif } else { sliceAddr = 0; @@ -4352,7 +3499,7 @@ void HLSyntaxReader::parseSliceHeader (Slice* pcSlice, PicHeader* picHeader, Par CHECK(sliceAddr >= pps->getNumTiles(), "Invalid slice address"); pcSlice->initSliceMap(); pcSlice->setSliceID(sliceAddr); - + for( uint32_t tileIdx = sliceAddr; tileIdx < sliceAddr + numTilesInSlice; tileIdx++ ) { uint32_t tileX = tileIdx % pps->getNumTileColumns(); @@ -4364,24 +3511,16 @@ void HLSyntaxReader::parseSliceHeader (Slice* pcSlice, PicHeader* picHeader, Par } } // rectangular slices - else + else { uint32_t sliceAddr; // slice address is the index of the slice within the current sub-picture -#if JVET_Q0044_SLICE_IDX_WITH_SUBPICS uint32_t currSubPicIdx = pps->getSubPicIdxFromSubPicId( pcSlice->getSliceSubPicId() ); SubPic currSubPic = pps->getSubPic(currSubPicIdx); if( currSubPic.getNumSlicesInSubPic() > 1 ) -#else - if( pps->getNumSlicesInPic() > 1 ) -#endif { -#if JVET_Q0044_SLICE_IDX_WITH_SUBPICS - int bitsSliceAddress = ceilLog2(currSubPic.getNumSlicesInSubPic()); -#else - int bitsSliceAddress = ceilLog2(pps->getNumSlicesInPic()); // change to NumSlicesInSubPic when available -#endif + int bitsSliceAddress = ceilLog2(currSubPic.getNumSlicesInSubPic()); READ_CODE(bitsSliceAddress, uiCode, "slice_address"); sliceAddr = uiCode; CHECK(sliceAddr >= pps->getNumSlicesInPic(), "Invalid slice address"); } @@ -4389,7 +3528,6 @@ void HLSyntaxReader::parseSliceHeader (Slice* pcSlice, PicHeader* picHeader, Par { sliceAddr = 0; } -#if JVET_Q0044_SLICE_IDX_WITH_SUBPICS uint32_t picLevelSliceIdx = sliceAddr; for(int subpic = 0; subpic < currSubPicIdx; subpic++) { @@ -4397,13 +3535,8 @@ void HLSyntaxReader::parseSliceHeader (Slice* pcSlice, PicHeader* picHeader, Par } pcSlice->setSliceMap( pps->getSliceMap(picLevelSliceIdx) ); pcSlice->setSliceID(picLevelSliceIdx); -#else - pcSlice->setSliceMap( pps->getSliceMap(sliceAddr) ); - pcSlice->setSliceID(sliceAddr); -#endif } -#if JVET_Q0400_EXTRA_BITS std::vector<bool> shExtraBitsPresent = sps->getExtraSHBitPresentFlags(); for (int i=0; i< sps->getNumExtraSHBitsBytes() * 8; i++) { @@ -4413,22 +3546,15 @@ void HLSyntaxReader::parseSliceHeader (Slice* pcSlice, PicHeader* picHeader, Par READ_FLAG(uiCode, "sh_extra_bit[ i ]"); } } -#endif -#if JVET_Q0819_PH_CHANGES if (picHeader->getPicInterSliceAllowedFlag()) { -#endif READ_UVLC ( uiCode, "slice_type" ); pcSlice->setSliceType((SliceType)uiCode); -#if JVET_Q0118_CLEANUPS VPS *vps = parameterSetManager->getVPS(sps->getVPSId()); - CHECK(vps==0, "Invalid VPS"); - if (pcSlice->isIRAP() && vps->getIndependentLayerFlag(vps->getGeneralLayerIdx(pcSlice->getNalUnitLayerId())) == 1) + if (pcSlice->isIRAP() && (sps->getVPSId() == 0 || vps->getIndependentLayerFlag(vps->getGeneralLayerIdx(pcSlice->getNalUnitLayerId())) == 1)) { CHECK(uiCode != 2, "When nal_unit_type is in the range of IDR_W_RADL to CRA_NUT, inclusive, and vps_independent_layer_flag[ GeneralLayerIdx[ nuh_layer_id ] ] is equal to 1, slice_type shall be equal to 2"); } -#endif -#if JVET_Q0819_PH_CHANGES } else { @@ -4438,9 +3564,7 @@ void HLSyntaxReader::parseSliceHeader (Slice* pcSlice, PicHeader* picHeader, Par { CHECK(pcSlice->getSliceType() == I_SLICE, "when ph_intra_slice_allowed_flag = 0, no I_Slice is allowed"); } -#endif -#if JVET_Q0819_PH_CHANGES // inherit values from picture header // set default values in case slice overrides are disabled pcSlice->inheritFromPicHeader(picHeader, pps, sps); @@ -4449,7 +3573,13 @@ void HLSyntaxReader::parseSliceHeader (Slice* pcSlice, PicHeader* picHeader, Par { READ_FLAG(uiCode, "slice_alf_enabled_flag"); pcSlice->setTileGroupAlfEnabledFlag(COMPONENT_Y, uiCode); +#if JVET_R0225_SEPERATE_FLAGS_ALF_CHROMA + int alfCbEnabledFlag = 0; + int alfCrEnabledFlag = 0; +#else int alfChromaIdc = 0; +#endif + if (uiCode) { READ_CODE(3, uiCode, "slice_num_alf_aps_ids_luma"); @@ -4469,13 +3599,27 @@ void HLSyntaxReader::parseSliceHeader (Slice* pcSlice, PicHeader* picHeader, Par pcSlice->setAlfAPSs(apsId); if (bChroma) { +#if JVET_R0225_SEPERATE_FLAGS_ALF_CHROMA + READ_CODE(1, uiCode, "slice_alf_cb_enabled_flag"); alfCbEnabledFlag = uiCode; + READ_CODE(1, uiCode, "slice_alf_cr_enabled_flag"); alfCrEnabledFlag = uiCode; +#else READ_CODE(2, uiCode, "slice_alf_chroma_idc"); alfChromaIdc = uiCode; +#endif } else { +#if JVET_R0225_SEPERATE_FLAGS_ALF_CHROMA + alfCbEnabledFlag = 0; + alfCrEnabledFlag = 0; +#else alfChromaIdc = 0; +#endif } +#if JVET_R0225_SEPERATE_FLAGS_ALF_CHROMA + if (alfCbEnabledFlag || alfCrEnabledFlag) +#else if (alfChromaIdc) +#endif { READ_CODE(3, uiCode, "slice_alf_aps_id_chroma"); pcSlice->setTileGroupApsIdChroma(uiCode); @@ -4488,10 +3632,14 @@ void HLSyntaxReader::parseSliceHeader (Slice* pcSlice, PicHeader* picHeader, Par { pcSlice->setTileGroupNumAps(0); } +#if JVET_R0225_SEPERATE_FLAGS_ALF_CHROMA + pcSlice->setTileGroupAlfEnabledFlag(COMPONENT_Cb, alfCbEnabledFlag); + pcSlice->setTileGroupAlfEnabledFlag(COMPONENT_Cr, alfCrEnabledFlag); +#else pcSlice->setTileGroupAlfEnabledFlag(COMPONENT_Cb, alfChromaIdc & 1); pcSlice->setTileGroupAlfEnabledFlag(COMPONENT_Cr, alfChromaIdc >> 1); +#endif -#if JVET_Q0795_CCALF CcAlfFilterParam &filterParam = pcSlice->m_ccAlfFilterParam; if (sps->getCCALFEnabledFlag() && pcSlice->getTileGroupAlfEnabledFlag(COMPONENT_Y)) { @@ -4524,11 +3672,44 @@ void HLSyntaxReader::parseSliceHeader (Slice* pcSlice, PicHeader* picHeader, Par pcSlice->setTileGroupCcAlfCbApsId(-1); pcSlice->setTileGroupCcAlfCrApsId(-1); } + } +#if JVET_R0200_MOVE_LMCS_AND_SCALING_LIST_SE +#if JVET_R0098_LMCS_AND_SCALING_LISTS_FOR_PH_IN_SH + if (picHeader->getLmcsEnabledFlag() && !pcSlice->getPictureHeaderInSliceHeader()) +#else + if (picHeader->getLmcsEnabledFlag()) +#endif + { + READ_FLAG(uiCode, "slice_lmcs_enabled_flag"); + pcSlice->setLmcsEnabledFlag(uiCode); + } + else + { +#if JVET_R0098_LMCS_AND_SCALING_LISTS_FOR_PH_IN_SH + pcSlice->setLmcsEnabledFlag(pcSlice->getPictureHeaderInSliceHeader() ? picHeader->getLmcsEnabledFlag() : false); +#else + pcSlice->setLmcsEnabledFlag(false); +#endif + } +#if JVET_R0098_LMCS_AND_SCALING_LISTS_FOR_PH_IN_SH + if (picHeader->getExplicitScalingListEnabledFlag() && !pcSlice->getPictureHeaderInSliceHeader()) +#else + if (picHeader->getExplicitScalingListEnabledFlag()) +#endif + { + READ_FLAG(uiCode, "slice_explicit_scaling_list_used_flag"); + pcSlice->setExplicitScalingListUsed(uiCode); + } + else + { +#if JVET_R0098_LMCS_AND_SCALING_LISTS_FOR_PH_IN_SH + pcSlice->setExplicitScalingListUsed(pcSlice->getPictureHeaderInSliceHeader() ? picHeader->getExplicitScalingListEnabledFlag() : false); +#else + pcSlice->setExplicitScalingListUsed(false); #endif } #endif -#if JVET_Q0155_COLOUR_ID // 4:4:4 colour plane ID if( sps->getSeparateColourPlaneFlag() ) { @@ -4539,19 +3720,9 @@ void HLSyntaxReader::parseSliceHeader (Slice* pcSlice, PicHeader* picHeader, Par { pcSlice->setColourPlaneId( 0 ); } -#endif -#if !JVET_Q0819_PH_CHANGES - // inherit values from picture header - // set default values in case slice overrides are disabled - pcSlice->inheritFromPicHeader( picHeader, pps, sps ); -#endif -#if JVET_Q0819_PH_CHANGES if( pps->getRplInfoInPhFlag() ) -#else - if (picHeader->getPicRplPresentFlag()) -#endif { pcSlice->setRPL0(picHeader->getRPL0()); pcSlice->setRPL1(picHeader->getRPL1()); @@ -4574,18 +3745,7 @@ void HLSyntaxReader::parseSliceHeader (Slice* pcSlice, PicHeader* picHeader, Par if (sps->getNumRPL0() > 0) { -#if !JVET_Q0482_REMOVE_CONSTANT_PARAMS - if (!pps->getPPSRefPicListSPSIdc0()) - { - READ_FLAG(uiCode, "ref_pic_list_sps_flag[0]"); - } - else - { - uiCode = pps->getPPSRefPicListSPSIdc0() - 1; - } -#else READ_FLAG(uiCode, "ref_pic_list_sps_flag[0]"); -#endif } else { @@ -4598,7 +3758,11 @@ void HLSyntaxReader::parseSliceHeader (Slice* pcSlice, PicHeader* picHeader, Par { ReferencePictureList* rpl0 = pcSlice->getLocalRPL0(); (*rpl0) = ReferencePictureList(); +#if JVET_R0059_RPL_CLEANUP + parseRefPicList(sps, rpl0, -1); +#else parseRefPicList(sps, rpl0); +#endif pcSlice->setRPL0idx(-1); pcSlice->setRPL0(rpl0); } @@ -4666,11 +3830,7 @@ void HLSyntaxReader::parseSliceHeader (Slice* pcSlice, PicHeader* picHeader, Par } //Read L1 related syntax elements -#if JVET_Q0482_REMOVE_CONSTANT_PARAMS if (sps->getNumRPL(1) > 0 && pps->getRpl1IdxPresentFlag()) -#else - if (sps->getNumRPL(1) > 0 && pps->getRpl1IdxPresentFlag() && !pps->getPPSRefPicListSPSIdc(1)) -#endif { READ_FLAG(uiCode, "ref_pic_list_sps_flag[1]"); } @@ -4678,12 +3838,6 @@ void HLSyntaxReader::parseSliceHeader (Slice* pcSlice, PicHeader* picHeader, Par { uiCode = 0; } -#if !JVET_Q0482_REMOVE_CONSTANT_PARAMS - else if (pps->getRpl1IdxPresentFlag()) - { - uiCode = pps->getPPSRefPicListSPSIdc(1) - 1; - } -#endif else { uiCode = rplSpsFlag0; @@ -4714,7 +3868,11 @@ void HLSyntaxReader::parseSliceHeader (Slice* pcSlice, PicHeader* picHeader, Par { ReferencePictureList* rpl1 = pcSlice->getLocalRPL1(); (*rpl1) = ReferencePictureList(); +#if JVET_R0059_RPL_CLEANUP + parseRefPicList(sps, rpl1, -1); +#else parseRefPicList(sps, rpl1); +#endif pcSlice->setRPL1idx(-1); pcSlice->setRPL1(rpl1); } @@ -4768,17 +3926,15 @@ void HLSyntaxReader::parseSliceHeader (Slice* pcSlice, PicHeader* picHeader, Par } } -#if JVET_Q0819_PH_CHANGES if( !pps->getRplInfoInPhFlag() && pcSlice->getIdrPicFlag() && !(sps->getIDRRefParamListPresent()) ) -#else - if (!picHeader->getPicRplPresentFlag() && pcSlice->getIdrPicFlag() && !(sps->getIDRRefParamListPresent())) -#endif { pcSlice->setNumRefIdx(REF_PIC_LIST_0, 0); pcSlice->setNumRefIdx(REF_PIC_LIST_1, 0); } +#if !JVET_R0277_RPL else { +#endif if ((!pcSlice->isIntra() && pcSlice->getRPL0()->getNumRefEntries() > 1) || (pcSlice->isInterB() && pcSlice->getRPL1()->getNumRefEntries() > 1) ) { @@ -4844,7 +4000,9 @@ void HLSyntaxReader::parseSliceHeader (Slice* pcSlice, PicHeader* picHeader, Par pcSlice->setNumRefIdx( REF_PIC_LIST_0, pcSlice->isIntra() ? 0 : 1 ); pcSlice->setNumRefIdx( REF_PIC_LIST_1, pcSlice->isInterB() ? 1 : 0 ); } +#if !JVET_R0277_RPL } +#endif if (pcSlice->isInterP() || pcSlice->isInterB()) { @@ -4864,31 +4022,32 @@ void HLSyntaxReader::parseSliceHeader (Slice* pcSlice, PicHeader* picHeader, Par if ( picHeader->getEnableTMVPFlag() ) { -#if JVET_Q0482_REMOVE_CONSTANT_PARAMS +#if JVET_R0277_RPL + if( pcSlice->getSliceType() == P_SLICE ) + { + pcSlice->setColFromL0Flag( true ); + } + else if( !pps->getRplInfoInPhFlag() && pcSlice->getSliceType() == B_SLICE ) + { + READ_FLAG( uiCode, "collocated_from_l0_flag" ); + pcSlice->setColFromL0Flag( uiCode ); + } + else + { + pcSlice->setColFromL0Flag( picHeader->getPicColFromL0Flag() ); + } +#else if ( !pps->getRplInfoInPhFlag()) { -#endif if ( pcSlice->getSliceType() == B_SLICE ) { -#if !JVET_Q0482_REMOVE_CONSTANT_PARAMS - if (!pps->getPPSCollocatedFromL0Idc()) - { - READ_FLAG(uiCode, "collocated_from_l0_flag"); - } - else - { - uiCode = pps->getPPSCollocatedFromL0Idc() - 1; - } -#else READ_FLAG(uiCode, "collocated_from_l0_flag"); -#endif pcSlice->setColFromL0Flag(uiCode); } else { pcSlice->setColFromL0Flag( 1 ); } -#if JVET_Q0482_REMOVE_CONSTANT_PARAMS } else { @@ -4896,10 +4055,8 @@ void HLSyntaxReader::parseSliceHeader (Slice* pcSlice, PicHeader* picHeader, Par } #endif -#if JVET_Q0259_COLLOCATED_PIC_IN_PH if (!pps->getRplInfoInPhFlag()) { -#endif if ( pcSlice->getSliceType() != I_SLICE && ((pcSlice->getColFromL0Flag() == 1 && pcSlice->getNumRefIdx(REF_PIC_LIST_0) > 1)|| (pcSlice->getColFromL0Flag() == 0 && pcSlice->getNumRefIdx(REF_PIC_LIST_1) > 1))) @@ -4912,17 +4069,14 @@ void HLSyntaxReader::parseSliceHeader (Slice* pcSlice, PicHeader* picHeader, Par pcSlice->setColRefIdx(0); } -#if JVET_Q0259_COLLOCATED_PIC_IN_PH } else { pcSlice->setColRefIdx(picHeader->getColRefIdx()); } -#endif } if ( (pps->getUseWP() && pcSlice->getSliceType()==P_SLICE) || (pps->getWPBiPred() && pcSlice->getSliceType()==B_SLICE) ) { -#if JVET_Q0819_PH_CHANGES if (pps->getWpInfoInPhFlag()) { CHECK(pcSlice->getNumRefIdx(REF_PIC_LIST_0) > picHeader->getNumL0Weights(), "ERROR: Number of active reference picture L0 is greater than the number of weighted prediction signalled in Picture Header"); @@ -4933,9 +4087,6 @@ void HLSyntaxReader::parseSliceHeader (Slice* pcSlice, PicHeader* picHeader, Par { parsePredWeightTable(pcSlice, sps); } -#else - parsePredWeightTable(pcSlice, sps); -#endif pcSlice->initWpScaling(sps); } else @@ -4954,7 +4105,6 @@ void HLSyntaxReader::parseSliceHeader (Slice* pcSlice, PicHeader* picHeader, Par } } -#if JVET_Q0819_PH_CHANGES int qpDelta = 0; if (pps->getQpDeltaInfoInPhFlag()) { @@ -4966,10 +4116,6 @@ void HLSyntaxReader::parseSliceHeader (Slice* pcSlice, PicHeader* picHeader, Par qpDelta = iCode; } pcSlice->setSliceQp(26 + pps->getPicInitQPMinus26() + qpDelta); -#else - READ_SVLC( iCode, "slice_qp_delta" ); - pcSlice->setSliceQp (26 + pps->getPicInitQPMinus26() + iCode); -#endif pcSlice->setSliceQpBase(pcSlice->getSliceQp()); CHECK( pcSlice->getSliceQp() < -sps->getQpBDOffset(CHANNEL_TYPE_LUMA), "Invalid slice QP delta" ); @@ -5016,11 +4162,7 @@ void HLSyntaxReader::parseSliceHeader (Slice* pcSlice, PicHeader* picHeader, Par pcSlice->setUseChromaQpAdj(false); } -#if JVET_Q0819_PH_CHANGES if (sps->getSAOEnabledFlag() && !pps->getSaoInfoInPhFlag()) -#else - if (sps->getSAOEnabledFlag() && !picHeader->getSaoEnabledPresentFlag()) -#endif { READ_FLAG(uiCode, "slice_sao_luma_flag"); pcSlice->setSaoEnabledFlag(CHANNEL_TYPE_LUMA, (bool)uiCode); @@ -5030,99 +4172,10 @@ void HLSyntaxReader::parseSliceHeader (Slice* pcSlice, PicHeader* picHeader, Par } } -#if !JVET_Q0819_PH_CHANGES -#if JVET_Q0819_PH_CHANGES - if (sps->getALFEnabledFlag() && !pps->getAlfInfoInPhFlag()) -#else - if (sps->getALFEnabledFlag() && !picHeader->getAlfEnabledPresentFlag()) -#endif - { - READ_FLAG(uiCode, "slice_alf_enabled_flag"); - pcSlice->setTileGroupAlfEnabledFlag(COMPONENT_Y, uiCode); - int alfChromaIdc = 0; - if (uiCode) - { - READ_CODE(3, uiCode, "slice_num_alf_aps_ids_luma"); - int numAps = uiCode; - pcSlice->setTileGroupNumAps(numAps); - std::vector<int> apsId(numAps, -1); - for (int i = 0; i < numAps; i++) - { - READ_CODE(3, uiCode, "slice_alf_aps_id_luma"); - apsId[i] = uiCode; - APS* APStoCheckLuma = parameterSetManager->getAPS(apsId[i], ALF_APS); - CHECK(APStoCheckLuma->getAlfAPSParam().newFilterFlag[CHANNEL_TYPE_LUMA] != 1, "bitstream conformance error, alf_luma_filter_signal_flag shall be equal to 1"); - } - - - pcSlice->setAlfAPSs(apsId); - if (bChroma) - { - READ_CODE(2, uiCode, "slice_alf_chroma_idc"); alfChromaIdc = uiCode; - } - else - { - alfChromaIdc = 0; - } - if (alfChromaIdc) - { - READ_CODE(3, uiCode, "slice_alf_aps_id_chroma"); - pcSlice->setTileGroupApsIdChroma(uiCode); - APS* APStoCheckChroma = parameterSetManager->getAPS(uiCode, ALF_APS); - CHECK(APStoCheckChroma->getAlfAPSParam().newFilterFlag[CHANNEL_TYPE_CHROMA] != 1, "bitstream conformance error, alf_chroma_filter_signal_flag shall be equal to 1"); - } - } - else - { - pcSlice->setTileGroupNumAps(0); - } - pcSlice->setTileGroupAlfEnabledFlag(COMPONENT_Cb, alfChromaIdc & 1); - pcSlice->setTileGroupAlfEnabledFlag(COMPONENT_Cr, alfChromaIdc >> 1); - -#if JVET_Q0795_CCALF - CcAlfFilterParam &filterParam = pcSlice->m_ccAlfFilterParam; - if (sps->getCCALFEnabledFlag() && pcSlice->getTileGroupAlfEnabledFlag(COMPONENT_Y)) - { - READ_FLAG(uiCode, "slice_cc_alf_cb_enabled_flag"); - pcSlice->setTileGroupCcAlfCbEnabledFlag(uiCode); - filterParam.ccAlfFilterEnabled[COMPONENT_Cb - 1] = (uiCode == 1) ? true : false; - pcSlice->setTileGroupCcAlfCbApsId(-1); - if (filterParam.ccAlfFilterEnabled[COMPONENT_Cb - 1]) - { - // parse APS ID - READ_CODE(3, uiCode, "slice_cc_alf_cb_aps_id"); - pcSlice->setTileGroupCcAlfCbApsId(uiCode); - } - // Cr - READ_FLAG(uiCode, "slice_cc_alf_cr_enabled_flag"); - pcSlice->setTileGroupCcAlfCrEnabledFlag(uiCode); - filterParam.ccAlfFilterEnabled[COMPONENT_Cr - 1] = (uiCode == 1) ? true : false; - pcSlice->setTileGroupCcAlfCrApsId(-1); - if (filterParam.ccAlfFilterEnabled[COMPONENT_Cr - 1]) - { - // parse APS ID - READ_CODE(3, uiCode, "slice_cc_alf_cr_aps_id"); - pcSlice->setTileGroupCcAlfCrApsId(uiCode); - } - } - else - { - filterParam.ccAlfFilterEnabled[COMPONENT_Cb - 1] = false; - filterParam.ccAlfFilterEnabled[COMPONENT_Cr - 1] = false; - pcSlice->setTileGroupCcAlfCbApsId(-1); - pcSlice->setTileGroupCcAlfCrApsId(-1); - } -#endif - } -#endif if (pps->getDeblockingFilterControlPresentFlag()) { -#if JVET_Q0819_PH_CHANGES if (pps->getDeblockingFilterOverrideEnabledFlag() && !pps->getDbfInfoInPhFlag()) -#else - if (pps->getDeblockingFilterOverrideEnabledFlag() && !picHeader->getDeblockingFilterOverridePresentFlag()) -#endif { READ_FLAG ( uiCode, "slice_deblocking_filter_override_flag" ); pcSlice->setDeblockingFilterOverrideFlag(uiCode ? true : false); } @@ -5132,10 +4185,20 @@ void HLSyntaxReader::parseSliceHeader (Slice* pcSlice, PicHeader* picHeader, Par } if(pcSlice->getDeblockingFilterOverrideFlag()) { - READ_FLAG ( uiCode, "slice_deblocking_filter_disabled_flag" ); pcSlice->setDeblockingFilterDisable(uiCode ? 1 : 0); +#if JVET_R0388_DBF_CLEANUP + if (!pps->getPPSDeblockingFilterDisabledFlag()) + { +#endif + READ_FLAG(uiCode, "slice_deblocking_filter_disabled_flag"); pcSlice->setDeblockingFilterDisable(uiCode ? 1 : 0); +#if JVET_R0388_DBF_CLEANUP + } + else + { + pcSlice->setDeblockingFilterDisable(false); + } +#endif if(!pcSlice->getDeblockingFilterDisable()) { -#if JVET_Q0121_DEBLOCKING_CONTROL_PARAMETERS READ_SVLC( iCode, "slice_beta_offset_div2" ); pcSlice->setDeblockingFilterBetaOffsetDiv2( iCode ); CHECK( pcSlice->getDeblockingFilterBetaOffsetDiv2() < -12 || pcSlice->getDeblockingFilterBetaOffsetDiv2() > 12, "Invalid deblocking filter configuration"); @@ -5156,14 +4219,6 @@ void HLSyntaxReader::parseSliceHeader (Slice* pcSlice, PicHeader* picHeader, Par READ_SVLC( iCode, "slice_cr_tc_offset_div2" ); pcSlice->setDeblockingFilterCrTcOffsetDiv2( iCode ); CHECK( pcSlice->getDeblockingFilterCrTcOffsetDiv2() < -12 || pcSlice->getDeblockingFilterCrTcOffsetDiv2() > 12, "Invalid deblocking filter configuration"); -#else - READ_SVLC( iCode, "slice_beta_offset_div2" ); pcSlice->setDeblockingFilterBetaOffsetDiv2(iCode); - CHECK( pcSlice->getDeblockingFilterBetaOffsetDiv2() < -6 && - pcSlice->getDeblockingFilterBetaOffsetDiv2() > 6, "Invalid deblocking filter configuration"); - READ_SVLC( iCode, "slice_tc_offset_div2" ); pcSlice->setDeblockingFilterTcOffsetDiv2(iCode); - CHECK (pcSlice->getDeblockingFilterTcOffsetDiv2() < -6 && - pcSlice->getDeblockingFilterTcOffsetDiv2() > 6, "Invalid deblocking filter configuration"); -#endif } } else @@ -5171,12 +4226,10 @@ void HLSyntaxReader::parseSliceHeader (Slice* pcSlice, PicHeader* picHeader, Par pcSlice->setDeblockingFilterDisable ( picHeader->getDeblockingFilterDisable() ); pcSlice->setDeblockingFilterBetaOffsetDiv2( picHeader->getDeblockingFilterBetaOffsetDiv2() ); pcSlice->setDeblockingFilterTcOffsetDiv2 ( picHeader->getDeblockingFilterTcOffsetDiv2() ); -#if JVET_Q0121_DEBLOCKING_CONTROL_PARAMETERS pcSlice->setDeblockingFilterCbBetaOffsetDiv2( picHeader->getDeblockingFilterCbBetaOffsetDiv2() ); pcSlice->setDeblockingFilterCbTcOffsetDiv2 ( picHeader->getDeblockingFilterCbTcOffsetDiv2() ); pcSlice->setDeblockingFilterCrBetaOffsetDiv2(picHeader->getDeblockingFilterCrBetaOffsetDiv2()); pcSlice->setDeblockingFilterCrTcOffsetDiv2(picHeader->getDeblockingFilterCrTcOffsetDiv2()); -#endif } } else @@ -5184,20 +4237,55 @@ void HLSyntaxReader::parseSliceHeader (Slice* pcSlice, PicHeader* picHeader, Par pcSlice->setDeblockingFilterDisable ( false ); pcSlice->setDeblockingFilterBetaOffsetDiv2( 0 ); pcSlice->setDeblockingFilterTcOffsetDiv2 ( 0 ); -#if JVET_Q0121_DEBLOCKING_CONTROL_PARAMETERS pcSlice->setDeblockingFilterCbBetaOffsetDiv2( 0 ); pcSlice->setDeblockingFilterCbTcOffsetDiv2 ( 0 ); pcSlice->setDeblockingFilterCrBetaOffsetDiv2( 0 ); pcSlice->setDeblockingFilterCrTcOffsetDiv2 ( 0 ); -#endif } -#if JVET_Q0089_SLICE_LOSSLESS_CODING_CHROMA_BDPCM +#if JVET_R0271_SLICE_LEVEL_DQ_SDH_RRC + // dependent quantization + if( sps->getDepQuantEnabledFlag() ) + { + READ_FLAG(uiCode, "slice_dep_quant_enabled_flag"); + pcSlice->setDepQuantEnabledFlag(uiCode != 0); + } + else + { + pcSlice->setDepQuantEnabledFlag(false); + } + + // sign data hiding + if( sps->getSignDataHidingEnabledFlag() && !pcSlice->getDepQuantEnabledFlag() ) + { + READ_FLAG( uiCode, "slice_sign_data_hiding_enabled_flag" ); + pcSlice->setSignDataHidingEnabledFlag( uiCode != 0 ); + } + else + { + pcSlice->setSignDataHidingEnabledFlag(false); + } + + // signal TS residual coding disabled flag +#if JVET_R0483_SH_TSRC_DISABLED_FLAG_CLEANUP + if (sps->getTransformSkipEnabledFlag() && !pcSlice->getDepQuantEnabledFlag() && !pcSlice->getSignDataHidingEnabledFlag()) +#else + if( !pcSlice->getDepQuantEnabledFlag() && !pcSlice->getSignDataHidingEnabledFlag() ) +#endif + { + READ_FLAG(uiCode, "slice_ts_residual_coding_disabled_flag"); + pcSlice->setTSResidualCodingDisabledFlag( uiCode != 0 ); + } + else + { + pcSlice->setTSResidualCodingDisabledFlag( false ); + } +#else READ_FLAG(uiCode, "slice_ts_residual_coding_disabled_flag"); pcSlice->setTSResidualCodingDisabledFlag(uiCode != 0); #endif -#if JVET_Q0346_LMCS_ENABLE_IN_SH +#if !JVET_R0200_MOVE_LMCS_AND_SCALING_LIST_SE if (picHeader->getLmcsEnabledFlag()) { READ_FLAG(uiCode, "slice_lmcs_enabled_flag"); @@ -5207,8 +4295,6 @@ void HLSyntaxReader::parseSliceHeader (Slice* pcSlice, PicHeader* picHeader, Par { pcSlice->setLmcsEnabledFlag(false); } -#endif -#if JVET_Q0346_SCALING_LIST_USED_IN_SH if (picHeader->getExplicitScalingListEnabledFlag()) { READ_FLAG(uiCode, "slice_explicit_scaling_list_used_flag"); @@ -5237,14 +4323,10 @@ void HLSyntaxReader::parseSliceHeader (Slice* pcSlice, PicHeader* picHeader, Par std::vector<uint32_t> entryPointOffset; -#if JVET_Q0151_Q0205_ENTRYPOINTS pcSlice->resetNumberOfSubstream(); pcSlice->setNumSubstream(sps, pps); pcSlice->setNumEntryPoints( sps, pps ); -#else - pcSlice->setNumEntryPoints( pps ); -#endif if( pcSlice->getNumEntryPoints() > 0 ) { uint32_t offsetLenMinus1; @@ -5302,16 +4384,10 @@ void HLSyntaxReader::parseSliceHeader (Slice* pcSlice, PicHeader* picHeader, Par return; } -#if JVET_Q0819_PH_CHANGES void HLSyntaxReader::getSlicePoc(Slice* pcSlice, PicHeader* picHeader, ParameterSetManager *parameterSetManager, const int prevTid0POC) -#else -void HLSyntaxReader::parseSliceHeaderToPoc (Slice* pcSlice, PicHeader* picHeader, ParameterSetManager *parameterSetManager, const int prevTid0POC) -#endif { uint32_t uiCode; -#if JVET_Q0819_PH_CHANGES uint32_t pocLsb; -#endif PPS* pps = NULL; SPS* sps = NULL; @@ -5324,7 +4400,6 @@ void HLSyntaxReader::parseSliceHeaderToPoc (Slice* pcSlice, PicHeader* picHeader //!KS: need to add error handling code here, if SPS is not available CHECK(sps==0, "Invalid SPS"); -#if JVET_Q0819_PH_CHANGES READ_FLAG(uiCode, "picture_header_in_slice_header_flag"); if (uiCode == 0) { @@ -5348,20 +4423,10 @@ void HLSyntaxReader::parseSliceHeaderToPoc (Slice* pcSlice, PicHeader* picHeader // picture order count READ_CODE(sps->getBitsForPOC(), pocLsb, "ph_pic_order_cnt_lsb"); } -#else - // picture order count - READ_CODE(sps->getBitsForPOC(), uiCode, "slice_pic_order_cnt_lsb"); -#endif -#if JVET_P0116_POC_MSB -#if !JVET_Q0819_PH_CHANGES - int pocLsb = uiCode; -#endif int maxPocLsb = 1 << sps->getBitsForPOC(); int pocMsb; -#endif if (pcSlice->getIdrPicFlag()) { -#if JVET_P0116_POC_MSB if (picHeader->getPocMsbPresentFlag()) { pocMsb = picHeader->getPocMsbVal()*maxPocLsb; @@ -5371,38 +4436,18 @@ void HLSyntaxReader::parseSliceHeaderToPoc (Slice* pcSlice, PicHeader* picHeader pocMsb = 0; } pcSlice->setPOC(pocMsb + pocLsb); -#else -#if JVET_Q0819_PH_CHANGES - pcSlice->setPOC(pocLsb); -#else - pcSlice->setPOC(uiCode); -#endif -#endif } else { -#if !JVET_P0116_POC_MSB -#if !JVET_Q0819_PH_CHANGES - int pocLsb = uiCode; -#endif -#endif int prevPoc = prevTid0POC; -#if !JVET_P0116_POC_MSB - int maxPocLsb = 1 << sps->getBitsForPOC(); -#endif int prevPocLsb = prevPoc & (maxPocLsb - 1); int prevPocMsb = prevPoc - prevPocLsb; -#if !JVET_P0116_POC_MSB - int pocMsb; -#endif -#if JVET_P0116_POC_MSB if (picHeader->getPocMsbPresentFlag()) { pocMsb = picHeader->getPocMsbVal()*maxPocLsb; } else { -#endif if ((pocLsb < prevPocLsb) && ((prevPocLsb - pocLsb) >= (maxPocLsb / 2))) { pocMsb = prevPocMsb + maxPocLsb; @@ -5415,9 +4460,7 @@ void HLSyntaxReader::parseSliceHeaderToPoc (Slice* pcSlice, PicHeader* picHeader { pocMsb = prevPocMsb; } -#if JVET_P0116_POC_MSB } -#endif pcSlice->setPOC(pocMsb + pocLsb); } } @@ -5425,18 +4468,25 @@ void HLSyntaxReader::parseSliceHeaderToPoc (Slice* pcSlice, PicHeader* picHeader void HLSyntaxReader::parseConstraintInfo(ConstraintInfo *cinfo) { uint32_t symbol; +#if !JVET_R0090_VUI READ_FLAG(symbol, "general_progressive_source_flag" ); cinfo->setProgressiveSourceFlag(symbol ? true : false); READ_FLAG(symbol, "general_interlaced_source_flag" ); cinfo->setInterlacedSourceFlag(symbol ? true : false); +#endif READ_FLAG(symbol, "general_non_packed_constraint_flag" ); cinfo->setNonPackedConstraintFlag(symbol ? true : false); READ_FLAG(symbol, "general_frame_only_constraint_flag" ); cinfo->setFrameOnlyConstraintFlag(symbol ? true : false); -#if JVET_Q0114_CONSTRAINT_FLAGS READ_FLAG(symbol, "general_non_projected_constraint_flag" ); cinfo->setNonProjectedConstraintFlag(symbol ? true : false); -#endif READ_FLAG(symbol, "intra_only_constraint_flag" ); cinfo->setIntraOnlyConstraintFlag(symbol ? true : false); READ_CODE(4, symbol, "max_bitdepth_constraint_idc" ); cinfo->setMaxBitDepthConstraintIdc(symbol); READ_CODE(2, symbol, "max_chroma_format_constraint_idc" ); cinfo->setMaxChromaFormatConstraintIdc((ChromaFormat)symbol); -#if JVET_Q0114_CONSTRAINT_FLAGS +#if JVET_R0286_GCI_CLEANUP + READ_FLAG(symbol, "single_layer_constraint_flag"); cinfo->setSingleLayerConstraintFlag(symbol ? true : false); + READ_FLAG(symbol, "all_layers_independent_constraint_flag"); cinfo->setAllLayersIndependentConstraintFlag(symbol ? true : false); + if (cinfo->getSingleLayerConstraintFlag()) + { + CHECK(symbol == 0, "When single_layer_constraint_flag is equal to 1, the value of all_layers_independent_ constraint_flag shall be equal to 1"); + } +#endif READ_FLAG(symbol, "no_res_change_in_clvs_constraint_flag" ); cinfo->setNoResChangeInClvsConstraintFlag(symbol ? true : false); READ_FLAG(symbol, "one_tile_per_pic_constraint_flag" ); cinfo->setOneTilePerPicConstraintFlag(symbol ? true : false); READ_FLAG(symbol, "one_slice_per_pic_constraint_flag" ); cinfo->setOneSlicePerPicConstraintFlag(symbol ? true : false); @@ -5445,45 +4495,145 @@ void HLSyntaxReader::parseConstraintInfo(ConstraintInfo *cinfo) { CHECK(symbol == 0, "When one_slice_per_pic_constraint_flag is equal to 1, the value of one_subpic_per_pic_constraint_flag shall be equal to 1"); } -#endif READ_FLAG(symbol, "no_qtbtt_dual_tree_intra_constraint_flag" ); cinfo->setNoQtbttDualTreeIntraConstraintFlag(symbol > 0 ? true : false); +#if JVET_R0286_GCI_CLEANUP + if (cinfo->getMaxChromaFormatConstraintIdc() == 0) + { + CHECK(symbol == 0, "When max_chroma_format_constraint_idc is equal to 0, the value of no_qtbtt_dual_tree_intra_constraint_flag shall be equal to 1"); + } +#endif READ_FLAG(symbol, "no_partition_constraints_override_constraint_flag"); cinfo->setNoPartitionConstraintsOverrideConstraintFlag(symbol > 0 ? true : false); READ_FLAG(symbol, "no_sao_constraint_flag"); cinfo->setNoSaoConstraintFlag(symbol > 0 ? true : false); READ_FLAG(symbol, "no_alf_constraint_flag"); cinfo->setNoAlfConstraintFlag(symbol > 0 ? true : false); -#if JVET_Q0795_CCALF READ_FLAG(symbol, "no_ccalf_constraint_flag"); cinfo->setNoCCAlfConstraintFlag(symbol > 0 ? true : false); +#if JVET_R0286_GCI_CLEANUP + if (cinfo->getMaxChromaFormatConstraintIdc() == 0) + { + CHECK(symbol == 0, "When max_chroma_format_constraint_idc is equal to 0, the value of no_ccalf_constraint_flag shall be equal to 1"); + } #endif READ_FLAG(symbol, "no_joint_cbcr_constraint_flag"); cinfo->setNoJointCbCrConstraintFlag(symbol > 0 ? true : false); - +#if JVET_R0286_GCI_CLEANUP + if (cinfo->getMaxChromaFormatConstraintIdc() == 0) + { + CHECK(symbol == 0, "When max_chroma_format_constraint_idc is equal to 0, the value of no_joint_cbcr_constraint_flag shall be equal to 1"); + } + READ_FLAG(symbol, "no_mrl_constraint_flag"); cinfo->setNoMrlConstraintFlag(symbol > 0 ? true : false); + READ_FLAG(symbol, "no_isp_constraint_flag"); cinfo->setNoIspConstraintFlag(symbol > 0 ? true : false); + READ_FLAG(symbol, "no_mip_constraint_flag"); cinfo->setNoMipConstraintFlag(symbol > 0 ? true : false); +#endif READ_FLAG(symbol, "no_ref_wraparound_constraint_flag"); cinfo->setNoRefWraparoundConstraintFlag(symbol > 0 ? true : false); +#if JVET_R0286_GCI_CLEANUP + if (cinfo->getIntraOnlyConstraintFlag() == 1) + { + CHECK(symbol == 0, "When intra_only_constraint_flag is equal to 1, the value of no_ref_wraparound_constraint_flag shall be equal to 1"); + } +#endif READ_FLAG(symbol, "no_temporal_mvp_constraint_flag"); cinfo->setNoTemporalMvpConstraintFlag(symbol > 0 ? true : false); +#if JVET_R0286_GCI_CLEANUP + if (cinfo->getIntraOnlyConstraintFlag() == 1) + { + CHECK(symbol == 0, "When intra_only_constraint_flag is equal to 1, the value of no_temporal_mvp_constraint_flag shall be equal to 1"); + } +#endif READ_FLAG(symbol, "no_sbtmvp_constraint_flag"); cinfo->setNoSbtmvpConstraintFlag(symbol > 0 ? true : false); +#if JVET_R0286_GCI_CLEANUP + if (cinfo->getIntraOnlyConstraintFlag() == 1) + { + CHECK(symbol == 0, "When intra_only_constraint_flag is equal to 1, the value of no_sbtmvp_constraint_flag shall be equal to 1"); + } +#endif READ_FLAG(symbol, "no_amvr_constraint_flag"); cinfo->setNoAmvrConstraintFlag(symbol > 0 ? true : false); +#if JVET_R0286_GCI_CLEANUP + if (cinfo->getIntraOnlyConstraintFlag() == 1) + { + CHECK(symbol == 0, "When intra_only_constraint_flag is equal to 1, the value of no_amvr_constraint_flag shall be equal to 1"); + } +#endif READ_FLAG(symbol, "no_bdof_constraint_flag"); cinfo->setNoBdofConstraintFlag(symbol > 0 ? true : false); +#if JVET_R0286_GCI_CLEANUP + if (cinfo->getIntraOnlyConstraintFlag() == 1) + { + CHECK(symbol == 0, "When intra_only_constraint_flag is equal to 1, the value of no_bdof_constraint_flag shall be equal to 1"); + } +#endif READ_FLAG(symbol, "no_dmvr_constraint_flag"); cinfo->setNoDmvrConstraintFlag(symbol > 0 ? true : false); +#if JVET_R0286_GCI_CLEANUP + if (cinfo->getIntraOnlyConstraintFlag() == 1) + { + CHECK(symbol == 0, "When intra_only_constraint_flag is equal to 1, the value of no_dmvr_constraint_flag shall be equal to 1"); + } +#endif READ_FLAG(symbol, "no_cclm_constraint_flag"); cinfo->setNoCclmConstraintFlag(symbol > 0 ? true : false); +#if JVET_R0286_GCI_CLEANUP + if (cinfo->getMaxChromaFormatConstraintIdc() == 0) + { + CHECK(symbol == 0, "When max_chroma_format_constraint_idc is equal to 0, the value of no_cclm_constraint_flag shall be equal to 1"); + } +#endif READ_FLAG(symbol, "no_mts_constraint_flag"); cinfo->setNoMtsConstraintFlag(symbol > 0 ? true : false); READ_FLAG(symbol, "no_sbt_constraint_flag"); cinfo->setNoSbtConstraintFlag(symbol > 0 ? true : false); +#if JVET_R0286_GCI_CLEANUP + READ_FLAG(symbol, "no_lfnst_constraint_flag"); cinfo->setNoLfnstConstraintFlag(symbol > 0 ? true : false); +#endif READ_FLAG(symbol, "no_affine_motion_constraint_flag"); cinfo->setNoAffineMotionConstraintFlag(symbol > 0 ? true : false); +#if JVET_R0286_GCI_CLEANUP + if (cinfo->getIntraOnlyConstraintFlag() == 1) + { + CHECK(symbol == 0, "When intra_only_constraint_flag is equal to 1, the value of no_affine_motion_constraint_flag shall be equal to 1"); + } + READ_FLAG(symbol, "no_mmvd_constraint_flag"); cinfo->setNoMmvdConstraintFlag(symbol > 0 ? true : false); + if (cinfo->getIntraOnlyConstraintFlag() == 1) + { + CHECK(symbol == 0, "When intra_only_constraint_flag is equal to 1, the value of no_mmvd_constraint_flag shall be equal to 1"); + } + READ_FLAG(symbol, "no_smvd_constraint_flag"); cinfo->setNoSmvdConstraintFlag(symbol > 0 ? true : false); + if (cinfo->getIntraOnlyConstraintFlag() == 1) + { + CHECK(symbol == 0, "When intra_only_constraint_flag is equal to 1, the value of no_smvd_constraint_flag shall be equal to 1"); + } + READ_FLAG(symbol, "no_prof_constraint_flag"); cinfo->setNoProfConstraintFlag(symbol > 0 ? true : false); + if (cinfo->getIntraOnlyConstraintFlag() == 1) + { + CHECK(symbol == 0, "When intra_only_constraint_flag is equal to 1, the value of no_prof_constraint_flag shall be equal to 1"); + } +#endif READ_FLAG(symbol, "no_bcw_constraint_flag"); cinfo->setNoBcwConstraintFlag(symbol > 0 ? true : false); +#if JVET_R0286_GCI_CLEANUP + if (cinfo->getIntraOnlyConstraintFlag() == 1) + { + CHECK(symbol == 0, "When intra_only_constraint_flag is equal to 1, the value of no_bcw_constraint_flag shall be equal to 1"); + } +#endif READ_FLAG(symbol, "no_ibc_constraint_flag"); cinfo->setNoIbcConstraintFlag(symbol > 0 ? true : false); READ_FLAG(symbol, "no_ciip_constraint_flag"); cinfo->setNoCiipConstraintFlag(symbol > 0 ? true : false); +#if JVET_R0286_GCI_CLEANUP + if (cinfo->getIntraOnlyConstraintFlag() == 1) + { + CHECK(symbol == 0, "When intra_only_constraint_flag is equal to 1, the value of no_ciip_constraint_flag shall be equal to 1"); + } +#endif READ_FLAG(symbol, "no_fpel_mmvd_constraint_flag"); cinfo->setNoFPelMmvdConstraintFlag(symbol > 0 ? true : false); -#if !JVET_Q0806 - READ_FLAG(symbol, "no_triangle_constraint_flag"); cinfo->setNoTriangleConstraintFlag(symbol > 0 ? true : false); -#else READ_FLAG(symbol, "no_gpm_constraint_flag"); cinfo->setNoGeoConstraintFlag(symbol > 0 ? true : false); +#if JVET_R0286_GCI_CLEANUP + if (cinfo->getIntraOnlyConstraintFlag() == 1) + { + CHECK(symbol == 0, "When intra_only_constraint_flag is equal to 1, the value of no_gpm_constraint_flag shall be equal to 1"); + } #endif READ_FLAG(symbol, "no_ladf_constraint_flag"); cinfo->setNoLadfConstraintFlag(symbol > 0 ? true : false); READ_FLAG(symbol, "no_transform_skip_constraint_flag"); cinfo->setNoTransformSkipConstraintFlag(symbol > 0 ? true : false); READ_FLAG(symbol, "no_bdpcm_constraint_flag"); cinfo->setNoBDPCMConstraintFlag(symbol > 0 ? true : false); +#if JVET_R0286_GCI_CLEANUP + READ_FLAG(symbol, "no_palette_constraint_flag"); cinfo->setNoPaletteConstraintFlag(symbol > 0 ? true : false); + READ_FLAG(symbol, "no_act_constraint_flag"); cinfo->setNoActConstraintFlag(symbol > 0 ? true : false); + READ_FLAG(symbol, "no_lmcs_constraint_flag"); cinfo->setNoLmcsConstraintFlag(symbol > 0 ? true : false); +#endif READ_FLAG(symbol, "no_qp_delta_constraint_flag"); cinfo->setNoQpDeltaConstraintFlag(symbol > 0 ? true : false); READ_FLAG(symbol, "no_dep_quant_constraint_flag"); cinfo->setNoDepQuantConstraintFlag(symbol > 0 ? true : false); READ_FLAG(symbol, "no_sign_data_hiding_constraint_flag"); cinfo->setNoSignDataHidingConstraintFlag(symbol > 0 ? true : false); -#if JVET_P0124_MIXED_NALU READ_FLAG(symbol, "no_mixed_nalu_types_in_pic_constraint_flag"); cinfo->setNoMixedNaluTypesInPicConstraintFlag(symbol > 0 ? true : false); -#endif READ_FLAG(symbol, "no_trail_constraint_flag"); cinfo->setNoTrailConstraintFlag(symbol > 0 ? true : false); READ_FLAG(symbol, "no_stsa_constraint_flag"); cinfo->setNoStsaConstraintFlag(symbol > 0 ? true : false); READ_FLAG(symbol, "no_rasl_constraint_flag"); cinfo->setNoRaslConstraintFlag(symbol > 0 ? true : false); @@ -5495,30 +4645,18 @@ void HLSyntaxReader::parseConstraintInfo(ConstraintInfo *cinfo) } -#if JVET_Q0786_PTL_only void HLSyntaxReader::parseProfileTierLevel(ProfileTierLevel *ptl, bool profileTierPresentFlag, int maxNumSubLayersMinus1) -#else -void HLSyntaxReader::parseProfileTierLevel(ProfileTierLevel *ptl, int maxNumSubLayersMinus1) -#endif { uint32_t symbol; -#if JVET_Q0786_PTL_only if(profileTierPresentFlag) { READ_CODE(7 , symbol, "general_profile_idc" ); ptl->setProfileIdc (Profile::Name(symbol)); READ_FLAG( symbol, "general_tier_flag" ); ptl->setTierFlag (symbol ? Level::HIGH : Level::MAIN); parseConstraintInfo( ptl->getConstraintInfo() ); } -#else - READ_CODE(7 , symbol, "general_profile_idc" ); ptl->setProfileIdc (Profile::Name(symbol)); - READ_FLAG( symbol, "general_tier_flag" ); ptl->setTierFlag (symbol ? Level::HIGH : Level::MAIN); - - parseConstraintInfo( ptl->getConstraintInfo() ); -#endif READ_CODE( 8, symbol, "general_level_idc" ); ptl->setLevelIdc( Level::Name( symbol ) ); -#if JVET_Q0786_PTL_only if(profileTierPresentFlag) { READ_CODE(8, symbol, "num_sub_profiles"); @@ -5529,15 +4667,6 @@ void HLSyntaxReader::parseProfileTierLevel(ProfileTierLevel *ptl, int maxNumSubL READ_CODE(32, symbol, "general_sub_profile_idc[i]"); ptl->setSubProfileIdc(i, symbol); } } -#else - READ_CODE(8, symbol, "num_sub_profiles"); - uint8_t numSubProfiles = symbol; - ptl->setNumSubProfile( numSubProfiles ); - for (int i = 0; i < numSubProfiles; i++) - { - READ_CODE(32, symbol, "general_sub_profile_idc[i]"); ptl->setSubProfileIdc(i, symbol); - } -#endif for (int i = 0; i < maxNumSubLayersMinus1; i++) { @@ -5624,12 +4753,12 @@ void HLSyntaxReader::parsePredWeightTable( Slice* pcSlice, const SPS *sps ) int iDeltaDenom; // decode delta_luma_log2_weight_denom : READ_UVLC( uiLog2WeightDenomLuma, "luma_log2_weight_denom" ); - CHECK( uiLog2WeightDenomLuma > 7, "Invalid code" ); + CHECK( uiLog2WeightDenomLuma > 7, "The value of luma_log2_weight_denom shall be in the range of 0 to 7" ); if( bChroma ) { READ_SVLC( iDeltaDenom, "delta_chroma_log2_weight_denom" ); - CHECK((iDeltaDenom + (int)uiLog2WeightDenomLuma)<0, "Invalid code"); - CHECK((iDeltaDenom + (int)uiLog2WeightDenomLuma)>7, "Invalid code"); + CHECK((iDeltaDenom + (int)uiLog2WeightDenomLuma)<0, "luma_log2_weight_denom + delta_chroma_log2_weight_denom shall be in the range of 0 to 7"); + CHECK((iDeltaDenom + (int)uiLog2WeightDenomLuma)>7, "luma_log2_weight_denom + delta_chroma_log2_weight_denom shall be in the range of 0 to 7"); uiLog2WeightDenomChroma = (uint32_t)(iDeltaDenom + uiLog2WeightDenomLuma); } @@ -5681,13 +4810,13 @@ void HLSyntaxReader::parsePredWeightTable( Slice* pcSlice, const SPS *sps ) { int iDeltaWeight; READ_SVLC( iDeltaWeight, iNumRef==0?"delta_luma_weight_l0[i]":"delta_luma_weight_l1[i]" ); - CHECK( iDeltaWeight < -128, "Invalid code" ); - CHECK( iDeltaWeight > 127, "Invalid code" ); + CHECK( iDeltaWeight < -128, "delta_luma_weight_lx shall be in the rage of -128 to 127" ); + CHECK( iDeltaWeight > 127, "delta_luma_weight_lx shall be in the rage of -128 to 127" ); wp[COMPONENT_Y].iWeight = (iDeltaWeight + (1<<wp[COMPONENT_Y].uiLog2WeightDenom)); READ_SVLC( wp[COMPONENT_Y].iOffset, iNumRef==0?"luma_offset_l0[i]":"luma_offset_l1[i]" ); const int range=sps->getSpsRangeExtension().getHighPrecisionOffsetsEnabledFlag() ? (1<<sps->getBitDepth(CHANNEL_TYPE_LUMA))/2 : 128; - if( wp[0].iOffset < -range ) { THROW("Offset out of range"); } - if( wp[0].iOffset >= range ) { THROW("Offset out of range"); } + CHECK ( wp[0].iOffset < -range , "luma_offset_lx shall be in the rage of -128 to 127"); + CHECK ( wp[0].iOffset >= range , "luma_offset_lx shall be in the rage of -128 to 127"); } else { @@ -5703,14 +4832,14 @@ void HLSyntaxReader::parsePredWeightTable( Slice* pcSlice, const SPS *sps ) { int iDeltaWeight; READ_SVLC( iDeltaWeight, iNumRef==0?"delta_chroma_weight_l0[i]":"delta_chroma_weight_l1[i]" ); - CHECK( iDeltaWeight < -128, "Invalid code" ); - CHECK( iDeltaWeight > 127, "Invalid code" ); + CHECK( iDeltaWeight < -128, "delta_chroma_weight_lx shall be in the rage of -128 to 127" ); + CHECK( iDeltaWeight > 127, "delta_chroma_weight_lx shall be in the rage of -128 to 127" ); wp[j].iWeight = (iDeltaWeight + (1<<wp[j].uiLog2WeightDenom)); int iDeltaChroma; READ_SVLC( iDeltaChroma, iNumRef==0?"delta_chroma_offset_l0[i]":"delta_chroma_offset_l1[i]" ); - CHECK( iDeltaChroma < -4*range, "Invalid code" ); - CHECK( iDeltaChroma >= 4*range, "Invalid code" ); + CHECK( iDeltaChroma < -4*range, "delta_chroma_offset_lx shall be in the range of -4 * 128 to 4 * 127" ); + CHECK( iDeltaChroma >= 4*range, "delta_chroma_offset_lx shall be in the range of -4 * 128 to 4 * 127" ); int pred = ( range - ( ( range*wp[j].iWeight)>>(wp[j].uiLog2WeightDenom) ) ); wp[j].iOffset = Clip3(-range, range-1, (iDeltaChroma + pred) ); } @@ -5738,7 +4867,6 @@ void HLSyntaxReader::parsePredWeightTable( Slice* pcSlice, const SPS *sps ) CHECK(uiTotalSignalledWeightFlags>24, "Too many weight flag signalled"); } -#if JVET_Q0819_PH_CHANGES void HLSyntaxReader::parsePredWeightTable(PicHeader *picHeader, const SPS *sps) { WPScalingParam * wp; @@ -5751,12 +4879,12 @@ void HLSyntaxReader::parsePredWeightTable(PicHeader *picHeader, const SPS *sps) int deltaDenom; READ_UVLC(log2WeightDenomLuma, "luma_log2_weight_denom"); - CHECK(log2WeightDenomLuma > 7, "Invalid code"); + CHECK(log2WeightDenomLuma > 7, "The value of luma_log2_weight_denom shall be in the range of 0 to 7"); if (chroma) { READ_SVLC(deltaDenom, "delta_chroma_log2_weight_denom"); - CHECK((deltaDenom + (int) log2WeightDenomLuma) < 0, "Invalid code"); - CHECK((deltaDenom + (int) log2WeightDenomLuma) > 7, "Invalid code"); + CHECK((deltaDenom + (int) log2WeightDenomLuma) < 0, "luma_log2_weight_denom + delta_chroma_log2_weight_denom shall be in the range of 0 to 7"); + CHECK((deltaDenom + (int) log2WeightDenomLuma) > 7, "luma_log2_weight_denom + delta_chroma_log2_weight_denom shall be in the range of 0 to 7"); log2WeightDenomChroma = (uint32_t)(deltaDenom + log2WeightDenomLuma); } @@ -5814,19 +4942,13 @@ void HLSyntaxReader::parsePredWeightTable(PicHeader *picHeader, const SPS *sps) { int deltaWeight; READ_SVLC(deltaWeight, numRef == 0 ? "delta_luma_weight_l0[i]" : "delta_luma_weight_l1[i]"); - CHECK(deltaWeight < -128, "Invalid code"); - CHECK(deltaWeight > 127, "Invalid code"); + CHECK(deltaWeight < -128, "delta_luma_weight_lx shall be in the rage of -128 to 127"); + CHECK(deltaWeight > 127, "delta_luma_weight_lx shall be in the rage of -128 to 127"); wp[COMPONENT_Y].iWeight = (deltaWeight + (1 << wp[COMPONENT_Y].uiLog2WeightDenom)); READ_SVLC(wp[COMPONENT_Y].iOffset, numRef == 0 ? "luma_offset_l0[i]" : "luma_offset_l1[i]"); const int range = sps->getSpsRangeExtension().getHighPrecisionOffsetsEnabledFlag() ? (1 << sps->getBitDepth(CHANNEL_TYPE_LUMA)) / 2 : 128; - if (wp[0].iOffset < -range) - { - THROW("Offset out of range"); - } - if (wp[0].iOffset >= range) - { - THROW("Offset out of range"); - } + CHECK ( wp[0].iOffset < -range , "luma_offset_lx shall be in the rage of -128 to 127"); + CHECK ( wp[0].iOffset >= range , "luma_offset_lx shall be in the rage of -128 to 127"); } else { @@ -5842,14 +4964,14 @@ void HLSyntaxReader::parsePredWeightTable(PicHeader *picHeader, const SPS *sps) { int deltaWeight; READ_SVLC(deltaWeight, numRef == 0 ? "delta_chroma_weight_l0[i]" : "delta_chroma_weight_l1[i]"); - CHECK(deltaWeight < -128, "Invalid code"); - CHECK(deltaWeight > 127, "Invalid code"); + CHECK( deltaWeight < -128, "delta_chroma_weight_lx shall be in the rage of -128 to 127" ); + CHECK( deltaWeight > 127, "delta_chroma_weight_lx shall be in the rage of -128 to 127" ); wp[j].iWeight = (deltaWeight + (1 << wp[j].uiLog2WeightDenom)); int deltaChroma; READ_SVLC(deltaChroma, numRef == 0 ? "delta_chroma_offset_l0[i]" : "delta_chroma_offset_l1[i]"); - CHECK(deltaChroma < -4 * range, "Invalid code"); - CHECK(deltaChroma >= 4 * range, "Invalid code"); + CHECK( deltaChroma < -4*range, "delta_chroma_offset_lx shall be in the range of -4 * 128 to 4 * 127" ); + CHECK( deltaChroma >= 4*range, "delta_chroma_offset_lx shall be in the range of -4 * 128 to 4 * 127" ); int pred = (range - ((range * wp[j].iWeight) >> (wp[j].uiLog2WeightDenom))); wp[j].iOffset = Clip3(-range, range - 1, (deltaChroma + pred)); } @@ -5876,14 +4998,24 @@ void HLSyntaxReader::parsePredWeightTable(PicHeader *picHeader, const SPS *sps) if (numRef == 0) { +#if R0324_PH_SYNTAX_CONDITION_MODIFY + if (picHeader->getRPL(1)->getNumRefEntries() > 0) + { + READ_UVLC(numLxWeights, "num_l1_weights"); + } + else + { + numLxWeights = 0; + } +#else READ_UVLC(numLxWeights, "num_l1_weights"); +#endif moreSyntaxToBeParsed = (numLxWeights == 0) ? false : true; picHeader->setNumL1Weights(numLxWeights); } } CHECK(totalSignalledWeightFlags > 24, "Too many weight flag signalled"); } -#endif /** decode quantization matrix * \param scalingList quantization matrix information @@ -5893,16 +5025,12 @@ void HLSyntaxReader::parseScalingList(ScalingList* scalingList) uint32_t code; bool scalingListCopyModeFlag; READ_FLAG(code, "scaling_matrix_for_lfnst_disabled_flag"); scalingList->setDisableScalingMatrixForLfnstBlks(code ? true : false); -#if JVET_Q0505_CHROAM_QM_SIGNALING_400 READ_FLAG(code, "scaling_list_chroma_present_flag"); scalingList->setChromaScalingListPresentFlag(code ? true : false); -#endif for (int scalingListId = 0; scalingListId < 28; scalingListId++) { -#if JVET_Q0505_CHROAM_QM_SIGNALING_400 if(scalingList->getChromaScalingListPresentFlag()|| scalingList->isLumaScalingList(scalingListId)) { -#endif READ_FLAG(code, "scaling_list_copy_mode_flag"); scalingListCopyModeFlag = (code) ? true : false; scalingList->setScalingListCopyModeFlag(scalingListId, scalingListCopyModeFlag); @@ -5918,7 +5046,7 @@ void HLSyntaxReader::parseScalingList(ScalingList* scalingList) { READ_UVLC(code, "scaling_list_pred_matrix_id_delta"); scalingList->setRefMatrixId(scalingListId, (uint32_t)((int)(scalingListId)-(code))); - } + } else if (scalingListCopyModeFlag || scalingList->getScalingListPreditorModeFlag(scalingListId)) { scalingList->setRefMatrixId(scalingListId, (uint32_t)((int)(scalingListId))); @@ -5937,14 +5065,23 @@ void HLSyntaxReader::parseScalingList(ScalingList* scalingList) { decodeScalingList(scalingList, scalingListId, scalingList->getScalingListPreditorModeFlag(scalingListId)); } -#if JVET_Q0505_CHROAM_QM_SIGNALING_400 } else { +#if JVET_R0055_HANDLING_NON_EXISTENT_QM + scalingListCopyModeFlag = true; + scalingList->setScalingListCopyModeFlag(scalingListId, scalingListCopyModeFlag); + scalingList->setRefMatrixId(scalingListId, (uint32_t)((int)(scalingListId))); + if (scalingListId >= SCALING_LIST_1D_START_16x16) + { + scalingList->setScalingListDC(scalingListId, 16); + } + scalingList->processRefMatrix(scalingListId, scalingList->getRefMatrixId(scalingListId)); +#else scalingList->processDefaultMatrix(scalingListId); - } #endif } + } return; } @@ -5990,7 +5127,7 @@ void HLSyntaxReader::decodeScalingList(ScalingList *scalingList, uint32_t scalin continue; } READ_SVLC( data, "scaling_list_delta_coef"); - nextCoef += data; + nextCoef += data; predCoef = (isPredictor) ? srcPred[scan[i].idx] : 0; dst[scan[i].idx] = (nextCoef + predCoef + 256) & 255; } @@ -6025,40 +5162,6 @@ bool HLSyntaxReader::xMoreRbspData() return (cnt>0); } -#if !JVET_Q0210_UEK_REMOVAL -int HLSyntaxReader::alfGolombDecode( const int k, const bool signed_val ) -{ - int numLeadingBits = -1; - uint32_t b = 0; - for (; !b; numLeadingBits++) - { -#if RExt__DECODER_DEBUG_BIT_STATISTICS - xReadFlag( b, "" ); -#else - READ_FLAG( b, "alf_coeff_abs_prefix"); -#endif - } - - int symbol = ( ( 1 << numLeadingBits ) - 1 ) << k; - if ( numLeadingBits + k > 0) - { - uint32_t bins; - READ_CODE( numLeadingBits + k, bins, "alf_coeff_abs_suffix" ); - symbol += bins; - } - - if ( signed_val && symbol != 0 ) - { -#if RExt__DECODER_DEBUG_BIT_STATISTICS - xReadFlag( b, "" ); -#else - READ_FLAG( b, "alf_coeff_sign" ); -#endif - symbol = ( b ) ? -symbol : symbol; - } - return symbol; -} -#endif void HLSyntaxReader::alfFilter( AlfParam& alfParam, const bool isChroma, const int altIdx ) { @@ -6077,7 +5180,6 @@ void HLSyntaxReader::alfFilter( AlfParam& alfParam, const bool isChroma, const i for( int i = 0; i < alfShape.numCoeff - 1; i++ ) { -#if JVET_Q0210_UEK_REMOVAL READ_UVLC( code, isChroma ? "alf_chroma_coeff_abs" : "alf_luma_coeff_abs" ); coeff[ ind * MAX_NUM_ALF_LUMA_COEFF + i ] = code; if( coeff[ ind * MAX_NUM_ALF_LUMA_COEFF + i ] != 0 ) @@ -6085,9 +5187,6 @@ void HLSyntaxReader::alfFilter( AlfParam& alfParam, const bool isChroma, const i READ_FLAG( code, isChroma ? "alf_chroma_coeff_sign" : "alf_luma_coeff_sign" ); coeff[ ind * MAX_NUM_ALF_LUMA_COEFF + i ] = ( code ) ? -coeff[ ind * MAX_NUM_ALF_LUMA_COEFF + i ] : coeff[ ind * MAX_NUM_ALF_LUMA_COEFF + i ]; } -#else - coeff[ind * MAX_NUM_ALF_LUMA_COEFF + i] = alfGolombDecode( 3 ); -#endif CHECK( isChroma && ( coeff[ind * MAX_NUM_ALF_LUMA_COEFF + i] > 127 || coeff[ind * MAX_NUM_ALF_LUMA_COEFF + i] < -128 ) , "AlfCoeffC shall be in the range of -128 to 127, inclusive" ); @@ -6095,11 +5194,7 @@ void HLSyntaxReader::alfFilter( AlfParam& alfParam, const bool isChroma, const i } // Clipping values coding -#if JVET_Q0249_ALF_CHROMA_CLIPFLAG if ( alfParam.nonLinearFlag[isChroma] ) -#else - if ( alfParam.nonLinearFlag[isChroma][altIdx] ) -#endif { // Filter coefficients diff --git a/source/Lib/DecoderLib/VLCReader.h b/source/Lib/DecoderLib/VLCReader.h index 53be7eb0b49b89dd2fa9eec94ebedd5ead9a9716..720e4dfe37c3b8c7e94fd9ac6395ec5e0460940e 100644 --- a/source/Lib/DecoderLib/VLCReader.h +++ b/source/Lib/DecoderLib/VLCReader.h @@ -146,27 +146,22 @@ public: class HLSyntaxReader : public VLCReader { -#if JVET_P0118_HRD_ASPECTS -private: - bool m_isFirstGeneralHrd; - GeneralHrdParams* m_prevGeneralHrdParams; -#endif public: HLSyntaxReader(); virtual ~HLSyntaxReader(); protected: void copyRefPicList(SPS* pcSPS, ReferencePictureList* source_rpl, ReferencePictureList* dest_rpl); +#if JVET_R0059_RPL_CLEANUP + void parseRefPicList(SPS* pcSPS, ReferencePictureList* rpl, int rplIdx); +#else void parseRefPicList(SPS* pcSPS, ReferencePictureList* rpl); +#endif public: void setBitstream ( InputBitstream* p ) { m_pcBitstream = p; } void parseVPS ( VPS* pcVPS ); -#if JVET_Q0117_PARAMETER_SETS_CLEANUP void parseDCI ( DCI* dci ); -#else - void parseDPS ( DPS* dps ); -#endif void parseSPS ( SPS* pcSPS ); void parsePPS ( PPS* pcPPS ); void parseAPS ( APS* pcAPS ); @@ -175,59 +170,27 @@ public: void parseScalingListAps ( APS* pcAPS ); void parseVUI ( VUI* pcVUI, SPS* pcSPS ); void parseConstraintInfo (ConstraintInfo *cinfo); -#if JVET_Q0786_PTL_only void parseProfileTierLevel(ProfileTierLevel *ptl, bool profileTierPresentFlag, int maxNumSubLayersMinus1); -#else - void parseProfileTierLevel ( ProfileTierLevel *ptl, int maxNumSubLayersMinus1); -#endif -#if JVET_P0118_HRD_ASPECTS - void checkGeneralHrdParametersIdentical(GeneralHrdParams *generalHr); void parseOlsHrdParameters(GeneralHrdParams* generalHrd, OlsHrdParams *olsHrd, uint32_t firstSubLayer, uint32_t tempLevelHigh); -#else - void parseHrdParameters ( HRDParameters *hrd, uint32_t firstSubLayer, uint32_t tempLevelHigh ); -#endif -#if JVET_P0118_HRD_ASPECTS void parseGeneralHrdParameters(GeneralHrdParams *generalHrd); -#endif -#if JVET_Q0775_PH_IN_SH void parsePictureHeader ( PicHeader* picHeader, ParameterSetManager *parameterSetManager, bool readRbspTrailingBits ); -#else - void parsePictureHeader ( PicHeader* picHeader, ParameterSetManager *parameterSetManager ); -#endif -#if JVET_Q0358_ALF_NALU_TID_CONSTRAINT void checkAlfNaluTidAndPicTid(Slice* pcSlice, PicHeader* picHeader, ParameterSetManager *parameterSetManager); -#endif void parseSliceHeader ( Slice* pcSlice, PicHeader* picHeader, ParameterSetManager *parameterSetManager, const int prevTid0POC ); -#if JVET_Q0819_PH_CHANGES void getSlicePoc ( Slice* pcSlice, PicHeader* picHeader, ParameterSetManager *parameterSetManager, const int prevTid0POC ); -#else - void parseSliceHeaderToPoc ( Slice* pcSlice, PicHeader* picHeader, ParameterSetManager *parameterSetManager, const int prevTid0POC ); -#endif void parseTerminatingBit ( uint32_t& ruiBit ); void parseRemainingBytes ( bool noTrailingBytesExpected ); void parsePredWeightTable( Slice* pcSlice, const SPS *sps ); -#if JVET_Q0819_PH_CHANGES void parsePredWeightTable ( PicHeader *picHeader, const SPS *sps ); -#endif void parseScalingList ( ScalingList* scalingList ); void decodeScalingList ( ScalingList *scalingList, uint32_t scalingListId, bool isPredictor); void parseReshaper ( SliceReshapeInfo& sliceReshaperInfo, const SPS* pcSPS, const bool isIntra ); void alfFilter( AlfParam& alfParam, const bool isChroma, const int altIdx ); -#if JVET_Q0795_CCALF void ccAlfFilter( Slice *pcSlice ); -#endif -#if JVET_P0117_PTL_SCALABILITY void dpb_parameters(int maxSubLayersMinus1, bool subLayerInfoFlag, SPS *pcSPS); -#endif -#if JVET_Q0400_EXTRA_BITS void parseExtraPHBitsStruct( SPS *sps, int numBytes ); void parseExtraSHBitsStruct( SPS *sps, int numBytes ); -#endif private: -#if !JVET_Q0210_UEK_REMOVAL - int alfGolombDecode( const int k, const bool signed_val=true ); -#endif protected: bool xMoreRbspData(); diff --git a/source/Lib/EncoderLib/AnnexBwrite.h b/source/Lib/EncoderLib/AnnexBwrite.h index 8be7da54117f6ba3baea3dbe5cb8255701acaad7..15668d4a80c0eb4214129fb2582cb95361a45d7b 100644 --- a/source/Lib/EncoderLib/AnnexBwrite.h +++ b/source/Lib/EncoderLib/AnnexBwrite.h @@ -60,11 +60,7 @@ static std::vector<uint32_t> writeAnnexB(std::ostream& out, const AccessUnit& au static const uint8_t start_code_prefix[] = {0,0,0,1}; -#if JVET_Q0117_PARAMETER_SETS_CLEANUP 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 - 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 { /* From AVC, When any of the following conditions are fulfilled, the diff --git a/source/Lib/EncoderLib/BinEncoder.cpp b/source/Lib/EncoderLib/BinEncoder.cpp index 2d94f7765b9e05b77433864d532126729e987c18..9636d2f78cafefaf4a87a9963b1faf838bf7d3b1 100644 --- a/source/Lib/EncoderLib/BinEncoder.cpp +++ b/source/Lib/EncoderLib/BinEncoder.cpp @@ -215,7 +215,7 @@ void BinEncoderBase::encodeRemAbsEP(unsigned bins, unsigned goRicePar, unsigned encodeBinsEP((1 << length) - 2, length); encodeBinsEP(bins & bitMask, goRicePar); } - else + else { const unsigned maxPrefixLength = 32 - cutoff - maxLog2TrDynamicRange; unsigned prefixLength = 0; @@ -419,7 +419,7 @@ void BitEstimatorBase::encodeRemAbsEP(unsigned bins, unsigned goRicePar, unsigne { m_EstFracBits += BinProbModelBase::estFracBitsEP((bins >> goRicePar) + 1 + goRicePar); } - else + else { const unsigned maxPrefixLength = 32 - cutoff - maxLog2TrDynamicRange; unsigned prefixLength = 0; diff --git a/source/Lib/EncoderLib/CABACWriter.cpp b/source/Lib/EncoderLib/CABACWriter.cpp index c777dae6acf5cba19183840c8d6541389f495540..83fbe97187157b03b6dd64f8aefefc5a4032a2e9 100644 --- a/source/Lib/EncoderLib/CABACWriter.cpp +++ b/source/Lib/EncoderLib/CABACWriter.cpp @@ -187,7 +187,6 @@ void CABACWriter::coding_tree_unit( CodingStructure& cs, const UnitArea& area, i } } -#if JVET_Q0795_CCALF if ( !skipAlf ) { for ( int compIdx = 1; compIdx < getNumberValidComponents( cs.pcv->chrFormat ); compIdx++ ) @@ -205,7 +204,6 @@ void CABACWriter::coding_tree_unit( CodingStructure& cs, const UnitArea& area, i } } } -#endif if ( CS::isDualITree(cs) && cs.pcv->chrFormat != CHROMA_400 && cs.pcv->maxCUWidth > 64 ) { @@ -500,10 +498,8 @@ void CABACWriter::coding_tree(const CodingStructure& cs, Partitioner& partitione partitioner.exitCurrSplit(); if( chromaNotSplit ) { -#if JVET_Q0438_MONOCHROME_BUGFIXES if (isChromaEnabled(cs.pcv->chrFormat)) { -#endif CHECK( partitioner.chType != CHANNEL_TYPE_LUMA, "must be luma status" ); partitioner.chType = CHANNEL_TYPE_CHROMA; partitioner.treeType = TREE_C; @@ -512,9 +508,7 @@ void CABACWriter::coding_tree(const CodingStructure& cs, Partitioner& partitione { coding_tree( cs, partitioner, cuCtx ); } -#if JVET_Q0438_MONOCHROME_BUGFIXES } -#endif //recover partitioner.chType = CHANNEL_TYPE_LUMA; @@ -693,7 +687,6 @@ void CABACWriter::coding_unit( const CodingUnit& cu, Partitioner& partitioner, C } else { -#if JVET_Q0504_PLT_NON444 if( cu.chromaFormat != CHROMA_400 ) { cu_palette_info(cu, COMPONENT_Y, 3, cuCtx); @@ -702,22 +695,10 @@ void CABACWriter::coding_unit( const CodingUnit& cu, Partitioner& partitioner, C { cu_palette_info(cu, COMPONENT_Y, 1, cuCtx); } -#else - cu_palette_info(cu, COMPONENT_Y, 3, cuCtx); -#endif } end_of_ctu(cu, cuCtx); return; } -#if !JVET_Q0110_Q0785_CHROMA_BDPCM_420 - bdpcm_mode( cu, ComponentID( partitioner.chType ) ); -#if JVET_Q0438_MONOCHROME_BUGFIXES - if (!CS::isDualITree(cs) && isLuma(partitioner.chType) && isChromaEnabled(cu.chromaFormat)) -#else - if (!CS::isDualITree(cs) && isLuma(partitioner.chType)) -#endif - bdpcm_mode(cu, ComponentID(CHANNEL_TYPE_CHROMA)); -#endif // prediction data ( intra prediction modes / reference indexes + motion vectors ) cu_pred_data( cu ); @@ -787,11 +768,7 @@ void CABACWriter::pred_mode( const CodingUnit& cu ) unsigned ctxidx = DeriveCtx::CtxIBCFlag(cu); m_BinEncoder.encodeBin(CU::isIBC(cu), Ctx::IBCFlag(ctxidx)); } -#if JVET_Q0629_REMOVAL_PLT_4X4 - if (!CU::isIBC(cu) && cu.cs->slice->getSPS()->getPLTMode() && cu.lwidth() <= 64 && cu.lheight() <= 64 && (cu.lumaSize().width * cu.lumaSize().height > 16) ) -#else - if (!CU::isIBC(cu) && cu.cs->slice->getSPS()->getPLTMode() && cu.lwidth() <= 64 && cu.lheight() <= 64) -#endif + if (!CU::isIBC(cu) && cu.cs->slice->getSPS()->getPLTMode() && cu.lwidth() <= 64 && cu.lheight() <= 64 && (cu.lumaSize().width * cu.lumaSize().height > 16) ) { m_BinEncoder.encodeBin(CU::isPLT(cu), Ctx::PLTFlag(0)); } @@ -805,11 +782,7 @@ void CABACWriter::pred_mode( const CodingUnit& cu ) m_BinEncoder.encodeBin((CU::isIntra(cu) || CU::isPLT(cu)), Ctx::PredMode(DeriveCtx::CtxPredModeFlag(cu))); if (CU::isIntra(cu) || CU::isPLT(cu)) { -#if JVET_Q0629_REMOVAL_PLT_4X4 - if (cu.cs->slice->getSPS()->getPLTMode() && cu.lwidth() <= 64 && cu.lheight() <= 64 && (cu.lumaSize().width * cu.lumaSize().height > 16) ) -#else - if (cu.cs->slice->getSPS()->getPLTMode() && cu.lwidth() <= 64 && cu.lheight() <= 64) -#endif + if (cu.cs->slice->getSPS()->getPLTMode() && cu.lwidth() <= 64 && cu.lheight() <= 64 && (cu.lumaSize().width * cu.lumaSize().height > 16) ) m_BinEncoder.encodeBin(CU::isPLT(cu), Ctx::PLTFlag(0)); } else @@ -832,20 +805,20 @@ void CABACWriter::pred_mode( const CodingUnit& cu ) if ( cu.cs->slice->isIntra() || ( cu.lwidth() == 4 && cu.lheight() == 4 ) || cu.isConsIntra() ) { -#if JVET_Q0629_REMOVAL_PLT_4X4 - if (cu.cs->slice->getSPS()->getPLTMode() && cu.lwidth() <= 64 && cu.lheight() <= 64 && ( ( (!isLuma(cu.chType)) && (cu.chromaSize().width * cu.chromaSize().height > 16) ) || ((isLuma(cu.chType)) && ((cu.lumaSize().width * cu.lumaSize().height) > 16 ) ) ) ) +#if JVET_R0334_PLT_CLEANUP + if (cu.cs->slice->getSPS()->getPLTMode() && cu.lwidth() <= 64 && cu.lheight() <= 64 && ( ( (!isLuma(cu.chType)) && (cu.chromaSize().width * cu.chromaSize().height > 16) ) || ((isLuma(cu.chType)) && ((cu.lumaSize().width * cu.lumaSize().height) > 16 ) ) ) && (!cu.isLocalSepTree() || isLuma(cu.chType) ) ) #else - if (cu.cs->slice->getSPS()->getPLTMode() && cu.lwidth() <= 64 && cu.lheight() <= 64) -#endif + if (cu.cs->slice->getSPS()->getPLTMode() && cu.lwidth() <= 64 && cu.lheight() <= 64 && ( ( (!isLuma(cu.chType)) && (cu.chromaSize().width * cu.chromaSize().height > 16) ) || ((isLuma(cu.chType)) && ((cu.lumaSize().width * cu.lumaSize().height) > 16 ) ) ) ) +#endif m_BinEncoder.encodeBin((CU::isPLT(cu)), Ctx::PLTFlag(0)); return; } m_BinEncoder.encodeBin((CU::isIntra(cu) || CU::isPLT(cu)), Ctx::PredMode(DeriveCtx::CtxPredModeFlag(cu))); -#if JVET_Q0629_REMOVAL_PLT_4X4 +#if JVET_R0334_PLT_CLEANUP + if ((CU::isIntra(cu) || CU::isPLT(cu)) && cu.cs->slice->getSPS()->getPLTMode() && cu.lwidth() <= 64 && cu.lheight() <= 64 && ( ( (!isLuma(cu.chType)) && (cu.chromaSize().width * cu.chromaSize().height > 16) ) || ((isLuma(cu.chType)) && ((cu.lumaSize().width * cu.lumaSize().height) > 16 ) ) ) && (!cu.isLocalSepTree() || isLuma(cu.chType) ) ) +#else if ((CU::isIntra(cu) || CU::isPLT(cu)) && cu.cs->slice->getSPS()->getPLTMode() && cu.lwidth() <= 64 && cu.lheight() <= 64 && ( ( (!isLuma(cu.chType)) && (cu.chromaSize().width * cu.chromaSize().height > 16) ) || ((isLuma(cu.chType)) && ((cu.lumaSize().width * cu.lumaSize().height) > 16 ) ) ) ) -#else - if ((CU::isIntra(cu) || CU::isPLT(cu)) && cu.cs->slice->getSPS()->getPLTMode() && cu.lwidth() <= 64 && cu.lheight() <= 64) -#endif +#endif { m_BinEncoder.encodeBin((CU::isPLT(cu)), Ctx::PLTFlag(0)); } @@ -853,29 +826,17 @@ void CABACWriter::pred_mode( const CodingUnit& cu ) } void CABACWriter::bdpcm_mode( const CodingUnit& cu, const ComponentID compID ) { -#if JVET_Q0089_SLICE_LOSSLESS_CODING_CHROMA_BDPCM if( !cu.cs->sps->getBDPCMEnabledFlag() ) return; -#else - if( cu.cs->sps->getBDPCMEnabled() == 0 ) return; -#endif if( !CU::bdpcmAllowed( cu, compID ) ) return; int bdpcmMode = isLuma(compID) ? cu.bdpcmMode : cu.bdpcmModeChroma; -#if JVET_Q0110_Q0785_CHROMA_BDPCM_420 - unsigned ctxId = isLuma(compID) ? 0 : 2; + unsigned ctxId = isLuma(compID) ? 0 : 2; m_BinEncoder.encodeBin(bdpcmMode > 0 ? 1 : 0, Ctx::BDPCMMode(ctxId)); -#else - m_BinEncoder.encodeBin(bdpcmMode > 0 ? 1 : 0, Ctx::BDPCMMode(0)); -#endif if (bdpcmMode) { -#if JVET_Q0110_Q0785_CHROMA_BDPCM_420 m_BinEncoder.encodeBin(bdpcmMode > 1 ? 1 : 0, Ctx::BDPCMMode(ctxId+1)); -#else - m_BinEncoder.encodeBin(bdpcmMode > 1 ? 1 : 0, Ctx::BDPCMMode(1)); -#endif } if (isLuma(compID)) { @@ -892,20 +853,16 @@ void CABACWriter::cu_pred_data( const CodingUnit& cu ) { if( CU::isIntra( cu ) ) { -#if JVET_Q0110_Q0785_CHROMA_BDPCM_420 if( cu.Y().valid() ) { bdpcm_mode( cu, COMPONENT_Y ); } -#endif intra_luma_pred_modes ( cu ); -#if JVET_Q0110_Q0785_CHROMA_BDPCM_420 if( ( !cu.Y().valid() || ( !cu.isSepTree() && cu.Y().valid() ) ) && isChromaEnabled(cu.chromaFormat) ) { bdpcm_mode( cu, ComponentID(CHANNEL_TYPE_CHROMA) ); - } -#endif + } intra_chroma_pred_modes( cu ); return; } @@ -1270,13 +1227,11 @@ void CABACWriter::intra_chroma_pred_modes( const CodingUnit& cu ) return; } -#if JVET_Q0110_Q0785_CHROMA_BDPCM_420 if( cu.bdpcmModeChroma ) { cu.firstPU->intraDir[1] = cu.bdpcmModeChroma == 2 ? VER_IDX : HOR_IDX; return; } -#endif const PredictionUnit* pu = cu.firstPU; intra_chroma_pred_mode( *pu ); @@ -1310,12 +1265,6 @@ void CABACWriter::intra_chroma_lmc_mode(const PredictionUnit& pu) void CABACWriter::intra_chroma_pred_mode(const PredictionUnit& pu) { -#if !JVET_Q0110_Q0785_CHROMA_BDPCM_420 - if (pu.cu->bdpcmModeChroma) - { - return; - } -#endif const unsigned intraDir = pu.intraDir[1]; if (pu.cu->colorTransform) @@ -1390,9 +1339,7 @@ void CABACWriter::cu_residual( const CodingUnit& cu, Partitioner& partitioner, C cuCtx.violatesLfnstConstrained[CHANNEL_TYPE_CHROMA] = false; cuCtx.lfnstLastScanPos = false; cuCtx.violatesMtsCoeffConstraint = false; -#if JVET_Q0516_MTS_SIGNALLING_DC_ONLY_COND cuCtx.mtsLastScanPos = false; -#endif if( cu.ispMode && isLuma( partitioner.chType ) ) { @@ -1510,18 +1457,12 @@ void CABACWriter::cu_palette_info(const CodingUnit& cu, ComponentID compBegin, u TransformUnit& tu = *cu.firstTU; uint32_t indexMaxSize = cu.useEscape[compBegin] ? (cu.curPLTSize[compBegin] + 1) : cu.curPLTSize[compBegin]; -#if JVET_Q0291_REDUCE_DUALTREE_PLT_SIZE int maxPltSize = cu.isSepTree() ? MAXPLTSIZE_DUALTREE : MAXPLTSIZE; -#endif if (cu.lastPLTSize[compBegin]) { - -#if JVET_Q0291_REDUCE_DUALTREE_PLT_SIZE + xEncodePLTPredIndicator(cu, maxPltSize, compBegin); -#else - xEncodePLTPredIndicator(cu, MAXPLTSIZE, compBegin); -#endif } uint32_t reusedPLTnum = 0; @@ -1530,11 +1471,7 @@ void CABACWriter::cu_palette_info(const CodingUnit& cu, ComponentID compBegin, u if (cu.reuseflag[compBegin][idx]) reusedPLTnum++; } -#if JVET_Q0291_REDUCE_DUALTREE_PLT_SIZE if (reusedPLTnum < maxPltSize) -#else - if (reusedPLTnum < MAXPLTSIZE) -#endif { exp_golomb_eqprob(cu.curPLTSize[compBegin] - reusedPLTnum, 0); } @@ -1588,9 +1525,7 @@ void CABACWriter::cu_palette_info(const CodingUnit& cu, ComponentID compBegin, u { cuPaletteSubblockInfo(cu, compBegin, numComp, subSetId, prevRunPos, prevRunType); } -#if JVET_Q0291_REDUCE_DUALTREE_PLT_SIZE CHECK(cu.curPLTSize[compBegin] > maxPltSize, " Current palette size is larger than maximum palette size"); -#endif } void CABACWriter::cuPaletteSubblockInfo(const CodingUnit& cu, ComponentID compBegin, uint32_t numComp, int subSetId, uint32_t& prevRunPos, unsigned& prevRunType) { @@ -1625,7 +1560,7 @@ void CABACWriter::cuPaletteSubblockInfo(const CodingUnit& cu, ComponentID compBe || ((runType.at(posx, posy) == PLT_RUN_INDEX) && (curPLTIdx.at(posx, posy) != curPLTIdx.at(posxprev, posyprev)))); const CtxSet& ctxSet = (prevRunType == PLT_RUN_INDEX)? Ctx::IdxRunModel: Ctx::CopyRunModel; - if ( curPos > 0 ) + if ( curPos > 0 ) { int dist = curPos - prevRunPos - 1; const unsigned ctxId = DeriveCtx::CtxPltCopyFlag(prevRunType, dist); @@ -1685,22 +1620,14 @@ void CABACWriter::cuPaletteSubblockInfo(const CodingUnit& cu, ComponentID compBe PLTescapeBuf escapeValue = tu.getescapeValue((ComponentID)comp); if (compID == COMPONENT_Y || compBegin != COMPONENT_Y) { -#if JVET_Q0491_PLT_ESCAPE exp_golomb_eqprob((unsigned)escapeValue.at(posx, posy), 5); -#else - exp_golomb_eqprob((unsigned)escapeValue.at(posx, posy), 3); -#endif DTRACE(g_trace_ctx, D_SYNTAX, "plt_escape_val() value=%d etype=%d sp=%d\n", escapeValue.at(posx, posy), comp, curPos); } if (compBegin == COMPONENT_Y && compID != COMPONENT_Y && posy % (1 << scaleY) == 0 && posx % (1 << scaleX) == 0) { uint32_t posxC = posx >> scaleX; uint32_t posyC = posy >> scaleY; -#if JVET_Q0491_PLT_ESCAPE exp_golomb_eqprob((unsigned)escapeValue.at(posxC, posyC), 5); -#else - exp_golomb_eqprob((unsigned)escapeValue.at(posxC, posyC), 3); -#endif DTRACE(g_trace_ctx, D_SYNTAX, "plt_escape_val() value=%d etype=%d sp=%d\n", escapeValue.at(posx, posy), comp, curPos); } } @@ -1843,11 +1770,7 @@ void CABACWriter::prediction_unit( const PredictionUnit& pu ) Mv mvd = pu.mvd[REF_PIC_LIST_0]; mvd.changeIbcPrecInternal2Amvr(pu.cu->imv); mvd_coding(mvd, 0); // already changed to signaling precision -#if JVET_Q0798_SPS_NUMBER_MERGE_CANDIDATE if (pu.cs->sps->getMaxNumIBCMergeCand() == 1) -#else - if ( pu.cu->slice->getPicHeader()->getMaxNumIBCMergeCand() == 1 ) -#endif { CHECK( pu.mvpIdx[REF_PIC_LIST_0], "mvpIdx for IBC mode should be 0" ); } @@ -1986,29 +1909,13 @@ void CABACWriter::merge_data(const PredictionUnit& pu) merge_idx(pu); return; } -#if JVET_Q0806 const bool ciipAvailable = pu.cs->sps->getUseCiip() && !pu.cu->skip && pu.cu->lwidth() < MAX_CU_SIZE && pu.cu->lheight() < MAX_CU_SIZE && pu.cu->lwidth() * pu.cu->lheight() >= 64; - const bool geoAvailable = pu.cu->cs->slice->getSPS()->getUseGeo() && pu.cu->cs->slice->isInterB() && -#if JVET_Q0798_SPS_NUMBER_MERGE_CANDIDATE + const bool geoAvailable = pu.cu->cs->slice->getSPS()->getUseGeo() && pu.cu->cs->slice->isInterB() && pu.cs->sps->getMaxNumGeoCand() > 1 -#else - pu.cu->cs->picHeader->getMaxNumGeoCand() > 1 -#endif && pu.cu->lwidth() >= GEO_MIN_CU_SIZE && pu.cu->lheight() >= GEO_MIN_CU_SIZE && pu.cu->lwidth() <= GEO_MAX_CU_SIZE && pu.cu->lheight() <= GEO_MAX_CU_SIZE && pu.cu->lwidth() < 8 * pu.cu->lheight() && pu.cu->lheight() < 8 * pu.cu->lwidth(); if (geoAvailable || ciipAvailable) -#else - const bool triangleAvailable = pu.cu->cs->slice->getSPS()->getUseTriangle() && pu.cu->cs->slice->isInterB() && -#if JVET_Q0798_SPS_NUMBER_MERGE_CANDIDATE - pu.cs->sps->getMaxNumGeoCand() > 1; -#else - pu.cu->cs->picHeader->getMaxNumTriangleCand() > 1; -#endif - const bool ciipAvailable = pu.cs->sps->getUseCiip() && !pu.cu->skip && pu.cu->lwidth() < MAX_CU_SIZE && pu.cu->lheight() < MAX_CU_SIZE; - if (pu.cu->lwidth() * pu.cu->lheight() >= 64 - && (triangleAvailable || ciipAvailable)) -#endif { m_BinEncoder.encodeBin(pu.regularMergeFlag, Ctx::RegularMergeFlag(pu.cu->skip ? 0 : 1)); } @@ -2030,17 +1937,10 @@ void CABACWriter::merge_data(const PredictionUnit& pu) } else { -#if !JVET_Q0806 - if (triangleAvailable && ciipAvailable) - { - Ciip_flag(pu); - } -#else if (geoAvailable && ciipAvailable) { Ciip_flag(pu); } -#endif merge_idx(pu); } } @@ -2141,55 +2041,6 @@ void CABACWriter::merge_idx( const PredictionUnit& pu ) } else { -#if !JVET_Q0806 - if( pu.cu->triangle ) - { - bool splitDir = pu.triangleSplitDir; - uint8_t candIdx0 = pu.triangleMergeIdx0; - uint8_t candIdx1 = pu.triangleMergeIdx1; - DTRACE( g_trace_ctx, D_SYNTAX, "merge_idx() triangle_split_dir=%d\n", splitDir ); - DTRACE( g_trace_ctx, D_SYNTAX, "merge_idx() triangle_idx0=%d\n", candIdx0 ); - DTRACE( g_trace_ctx, D_SYNTAX, "merge_idx() triangle_idx1=%d\n", candIdx1 ); - candIdx1 -= candIdx1 < candIdx0 ? 0 : 1; - auto encodeOneIdx = [this](uint8_t mrgIdx, int numCandminus1) - { - if (numCandminus1 == 0) - { - CHECK(mrgIdx, "Incorrect index!"); - return; - } - if(mrgIdx == 0) - { - this->m_BinEncoder.encodeBin( 0, Ctx::MergeIdx() ); - return; - } - else - { - this->m_BinEncoder.encodeBin( 1, Ctx::MergeIdx() ); - for( unsigned idx = 1; idx < numCandminus1; idx++ ) - { - this->m_BinEncoder.encodeBinEP( mrgIdx == idx ? 0 : 1 ); - if( mrgIdx == idx ) - { - break; - } - } - } - }; - m_BinEncoder.encodeBinEP(splitDir); -#if JVET_Q0798_SPS_NUMBER_MERGE_CANDIDATE - const int maxNumTriangleCand = pu.cs->sps->getMaxNumGeoCand(); -#else - const int maxNumTriangleCand = pu.cs->picHeader->getMaxNumTriangleCand(); -#endif - CHECK(maxNumTriangleCand < 2, "Incorrect max number of triangle candidates"); - CHECK(candIdx0 >= maxNumTriangleCand, "Incorrect candIdx0"); - CHECK(candIdx1 >= maxNumTriangleCand, "Incorrect candIdx1"); - encodeOneIdx(candIdx0, maxNumTriangleCand - 1); - encodeOneIdx(candIdx1, maxNumTriangleCand - 2); - return; - } -#else if( pu.cu->geoFlag ) { uint8_t splitDir = pu.geoSplitDir; @@ -2200,11 +2051,7 @@ void CABACWriter::merge_idx( const PredictionUnit& pu ) DTRACE( g_trace_ctx, D_SYNTAX, "merge_idx() geo_idx1=%d\n", candIdx1 ); xWriteTruncBinCode(splitDir, GEO_NUM_PARTITION_MODE); candIdx1 -= candIdx1 < candIdx0 ? 0 : 1; -#if JVET_Q0798_SPS_NUMBER_MERGE_CANDIDATE const int maxNumGeoCand = pu.cs->sps->getMaxNumGeoCand(); -#else - const int maxNumGeoCand = pu.cs->picHeader->getMaxNumGeoCand(); -#endif CHECK(maxNumGeoCand < 2, "Incorrect max number of geo candidates"); CHECK(candIdx0 >= maxNumGeoCand, "Incorrect candIdx0"); CHECK(candIdx1 >= maxNumGeoCand, "Incorrect candIdx1"); @@ -2224,18 +2071,11 @@ void CABACWriter::merge_idx( const PredictionUnit& pu ) } return; } -#endif int numCandminus1; if (pu.cu->predMode == MODE_IBC) -#if JVET_Q0798_SPS_NUMBER_MERGE_CANDIDATE numCandminus1 = int(pu.cs->sps->getMaxNumIBCMergeCand()) - 1; else numCandminus1 = int(pu.cs->sps->getMaxNumMergeCand()) - 1; -#else - numCandminus1 = int(pu.cs->picHeader->getMaxNumIBCMergeCand()) - 1; - else - numCandminus1 = int(pu.cs->picHeader->getMaxNumMergeCand()) - 1; -#endif if( numCandminus1 > 0 ) { if( pu.mergeIdx == 0 ) @@ -2267,11 +2107,7 @@ void CABACWriter::mmvd_merge_idx(const PredictionUnit& pu) var0 = mvpIdx / MMVD_MAX_REFINE_NUM; var1 = (mvpIdx - (var0 * MMVD_MAX_REFINE_NUM)) / 4; var2 = mvpIdx - (var0 * MMVD_MAX_REFINE_NUM) - var1 * 4; -#if JVET_Q0798_SPS_NUMBER_MERGE_CANDIDATE if (pu.cs->sps->getMaxNumMergeCand() > 1) -#else - if (pu.cs->picHeader->getMaxNumMergeCand() > 1) -#endif { static_assert(MMVD_BASE_MV_NUM == 2, ""); assert(var0 < 2); @@ -2581,21 +2417,14 @@ void CABACWriter::transform_unit( const TransformUnit& tu, CUCtx& cuCtx, Partiti const CodingUnit& cu = *tu.cu; const UnitArea& area = partitioner.currArea(); const unsigned trDepth = partitioner.currTrDepth; -#if !JVET_Q0438_MONOCHROME_BUGFIXES - const bool chromaCbfISP = area.blocks[COMPONENT_Cb].valid() && cu.ispMode; -#endif ChromaCbfs chromaCbfs; CHECK(tu.depth != trDepth, " transform unit should be not be futher partitioned"); // cbf_cb & cbf_cr -#if JVET_Q0438_MONOCHROME_BUGFIXES if (area.chromaFormat != CHROMA_400) { const bool chromaCbfISP = area.blocks[COMPONENT_Cb].valid() && cu.ispMode; if (area.blocks[COMPONENT_Cb].valid() && (!cu.isSepTree() || partitioner.chType == CHANNEL_TYPE_CHROMA) && (!cu.ispMode || chromaCbfISP)) -#else - if (area.chromaFormat != CHROMA_400 && area.blocks[COMPONENT_Cb].valid() && (!cu.isSepTree() || partitioner.chType == CHANNEL_TYPE_CHROMA) && (!cu.ispMode || chromaCbfISP)) -#endif { { unsigned cbfDepth = chromaCbfISP ? trDepth - 1 : trDepth; @@ -2618,13 +2447,11 @@ void CABACWriter::transform_unit( const TransformUnit& tu, CUCtx& cuCtx, Partiti { chromaCbfs = ChromaCbfs(false); } -#if JVET_Q0438_MONOCHROME_BUGFIXES } else if (cu.isSepTree()) { chromaCbfs = ChromaCbfs(false); } -#endif if (!isChroma(partitioner.chType)) { @@ -2725,12 +2552,6 @@ void CABACWriter::transform_unit( const TransformUnit& tu, CUCtx& cuCtx, Partiti { for( ComponentID compID = COMPONENT_Cb; compID <= COMPONENT_Cr; compID = ComponentID( compID + 1 ) ) { -#if !REMOVE_PPS_REXT - if( TU::hasCrossCompPredInfo( tu, compID ) ) - { - cross_comp_pred( tu, compID ); - } -#endif if( cbf[ compID ] ) { residual_coding( tu, compID, &cuCtx ); @@ -2821,18 +2642,18 @@ void CABACWriter::residual_coding( const TransformUnit& tu, ComponentID compID, ts_flag ( tu, compID ); explicit_rdpcm_mode( tu, compID ); -#if JVET_Q0089_SLICE_LOSSLESS_CODING_CHROMA_BDPCM if( tu.mtsIdx[compID] == MTS_SKIP && !tu.cs->slice->getTSResidualCodingDisabledFlag() ) -#else - if (tu.mtsIdx[compID] == MTS_SKIP) -#endif { residual_codingTS( tu, compID ); return; } // determine sign hiding +#if JVET_R0271_SLICE_LEVEL_DQ_SDH_RRC + bool signHiding = ( cu.cs->slice->getSignDataHidingEnabledFlag() && tu.rdpcm[compID] == RDPCM_OFF ); +#else bool signHiding = ( cu.cs->picHeader->getSignDataHidingEnabledFlag() && tu.rdpcm[compID] == RDPCM_OFF ); +#endif if( signHiding && CU::isIntra(cu) && CU::isRDPCMEnabled(cu) && tu.mtsIdx[compID] == MTS_SKIP) { const ChannelType chType = toChannelType( compID ); @@ -2872,25 +2693,21 @@ void CABACWriter::residual_coding( const TransformUnit& tu, ComponentID compID, const int lfnstLastScanPosTh = isLuma( compID ) ? LFNST_LAST_SIG_LUMA : LFNST_LAST_SIG_CHROMA; cuCtx->lfnstLastScanPos |= cctx.scanPosLast() >= lfnstLastScanPosTh; } -#if !JVET_Q0055_MTS_SIGNALLING - if( cuCtx && isLuma(compID) && ( cctx.posX(cctx.scanPosLast()) >= 16 || cctx.posY(cctx.scanPosLast()) >= 16 ) ) - { - cuCtx->violatesMtsCoeffConstraint = true; - } -#endif -#if JVET_Q0516_MTS_SIGNALLING_DC_ONLY_COND if (cuCtx && isLuma(compID) && tu.mtsIdx[compID] != MTS_SKIP) { cuCtx->mtsLastScanPos |= cctx.scanPosLast() >= 1; } -#endif // code last coeff position last_sig_coeff( cctx, tu, compID ); // code subblocks +#if JVET_R0271_SLICE_LEVEL_DQ_SDH_RRC + const int stateTab = ( tu.cs->slice->getDepQuantEnabledFlag() ? 32040 : 0 ); +#else const int stateTab = ( tu.cs->picHeader->getDepQuantEnabledFlag() ? 32040 : 0 ); +#endif int state = 0; int ctxBinSampleRatio = (compID == COMPONENT_Y) ? MAX_TU_LEVEL_CTX_CODED_BIN_CONSTRAINT_LUMA : MAX_TU_LEVEL_CTX_CODED_BIN_CONSTRAINT_CHROMA; @@ -2909,13 +2726,11 @@ void CABACWriter::residual_coding( const TransformUnit& tu, ComponentID compID, } } residual_coding_subblock( cctx, coeff, stateTab, state ); - -#if JVET_Q0055_MTS_SIGNALLING + if ( cuCtx && isLuma(compID) && cctx.isSigGroup() && ( cctx.cgPosY() > 3 || cctx.cgPosX() > 3 ) ) { cuCtx->violatesMtsCoeffConstraint = true; } -#endif } } @@ -2923,7 +2738,7 @@ void CABACWriter::ts_flag( const TransformUnit& tu, ComponentID compID ) { int tsFlag = tu.mtsIdx[compID] == MTS_SKIP ? 1 : 0; int ctxIdx = isLuma(compID) ? 0 : 1; - + if( TU::isTSAllowed ( tu, compID ) ) { m_BinEncoder.encodeBin( tsFlag, Ctx::TransformSkipFlag(ctxIdx)); @@ -2935,19 +2750,15 @@ void CABACWriter::mts_idx( const CodingUnit& cu, CUCtx* cuCtx ) { TransformUnit &tu = *cu.firstTU; int mtsIdx = tu.mtsIdx[COMPONENT_Y]; - - if( CU::isMTSAllowed( cu, COMPONENT_Y ) && cuCtx && !cuCtx->violatesMtsCoeffConstraint && -#if JVET_Q0516_MTS_SIGNALLING_DC_ONLY_COND + + if( CU::isMTSAllowed( cu, COMPONENT_Y ) && cuCtx && !cuCtx->violatesMtsCoeffConstraint && cuCtx->mtsLastScanPos && cu.lfnstIdx == 0 && mtsIdx != MTS_SKIP) -#else - cu.lfnstIdx == 0 && mtsIdx != MTS_SKIP && TU::getCbf(tu, COMPONENT_Y) ) -#endif { int symbol = mtsIdx != MTS_DCT2_DCT2 ? 1 : 0; int ctxIdx = 0; - + m_BinEncoder.encodeBin( symbol, Ctx::MTSIdx(ctxIdx)); - + if( symbol ) { ctxIdx = 1; @@ -2955,7 +2766,7 @@ void CABACWriter::mts_idx( const CodingUnit& cu, CUCtx* cuCtx ) { symbol = mtsIdx > i + MTS_DST7_DST7 ? 1 : 0; m_BinEncoder.encodeBin( symbol, Ctx::MTSIdx(ctxIdx)); - + if( !symbol ) { break; @@ -3024,7 +2835,6 @@ void CABACWriter::residual_lfnst_mode( const CodingUnit& cu, CUCtx& cuCtx ) const bool lumaFlag = cu.isSepTree() ? ( isLuma( cu.chType ) ? true : false ) : true; const bool chromaFlag = cu.isSepTree() ? ( isChroma( cu.chType ) ? true : false ) : true; bool nonZeroCoeffNonTsCorner8x8 = ( lumaFlag && cuCtx.violatesLfnstConstrained[CHANNEL_TYPE_LUMA] ) || (chromaFlag && cuCtx.violatesLfnstConstrained[CHANNEL_TYPE_CHROMA] ); -#if JVET_Q0784_LFNST_COMBINATION bool isTrSkip = false; for (auto &currTU : CU::traverseTUs(cu)) { @@ -3038,9 +2848,6 @@ void CABACWriter::residual_lfnst_mode( const CodingUnit& cu, CUCtx& cuCtx ) } } } -#else - const bool isTrSkip = TU::getCbf(*cu.firstTU, COMPONENT_Y) && cu.firstTU->mtsIdx[COMPONENT_Y] == MTS_SKIP; -#endif if( (!cuCtx.lfnstLastScanPos && !cu.ispMode) || nonZeroCoeffNonTsCorner8x8 || isTrSkip ) { return; @@ -3411,47 +3218,6 @@ void CABACWriter::residual_coding_subblockTS( CoeffCodingContext& cctx, const TC -#if !REMOVE_PPS_REXT -//================================================================================ -// clause 7.3.8.12 -//-------------------------------------------------------------------------------- -// void cross_comp_pred( tu, compID ) -//================================================================================ - -void CABACWriter::cross_comp_pred( const TransformUnit& tu, ComponentID compID ) -{ - CHECK(!( !isLuma( compID ) ), "Unspecified error"); - signed char alpha = tu.compAlpha[compID]; - unsigned ctxBase = ( compID == COMPONENT_Cr ? 5 : 0 ); - if( alpha == 0 ) - { - m_BinEncoder.encodeBin( 0, Ctx::CrossCompPred( ctxBase ) ); - DTRACE( g_trace_ctx, D_SYNTAX, "cross_comp_pred() etype=%d pos=(%d,%d) alpha=%d\n", compID, tu.blocks[compID].x, tu.blocks[compID].y, tu.compAlpha[compID] ); - return; - } - - static const unsigned log2AbsAlphaMinus1Table[8] = { 0, 1, 1, 2, 2, 2, 3, 3 }; - unsigned sign = ( alpha < 0 ); - if( sign ) - { - alpha = -alpha; - } - CHECK(!( alpha <= 8 ), "Unspecified error"); - m_BinEncoder.encodeBin( 1, Ctx::CrossCompPred(ctxBase) ); - if( alpha > 1) - { - m_BinEncoder.encodeBin( 1, Ctx::CrossCompPred(ctxBase+1) ); - unary_max_symbol( log2AbsAlphaMinus1Table[alpha-1]-1, Ctx::CrossCompPred(ctxBase+2), Ctx::CrossCompPred(ctxBase+3), 2 ); - } - else - { - m_BinEncoder.encodeBin( 0, Ctx::CrossCompPred(ctxBase+1) ); - } - m_BinEncoder.encodeBin( sign, Ctx::CrossCompPred(ctxBase+4) ); - - DTRACE( g_trace_ctx, D_SYNTAX, "cross_comp_pred() etype=%d pos=(%d,%d) alpha=%d\n", compID, tu.blocks[compID].x, tu.blocks[compID].y, tu.compAlpha[compID] ); -} -#endif @@ -3571,7 +3337,6 @@ void CABACWriter::codeAlfCtuEnableFlag( CodingStructure& cs, uint32_t ctuRsAddr, } } -#if JVET_Q0795_CCALF void CABACWriter::codeCcAlfFilterControlIdc(uint8_t idcVal, CodingStructure &cs, const ComponentID compID, const int curIdx, const uint8_t *filterControlIdc, Position lumaPos, const int filterCount) @@ -3612,7 +3377,6 @@ void CABACWriter::codeCcAlfFilterControlIdc(uint8_t idcVal, CodingStructure &cs, } DTRACE( g_trace_ctx, D_SYNTAX, "ccAlfFilterControlIdc() compID=%d pos=(%d,%d) ctxt=%d, filterCount=%d, idcVal=%d\n", compID, lumaPos.x, lumaPos.y, ctxt, filterCount, idcVal ); } -#endif void CABACWriter::code_unary_fixed( unsigned symbol, unsigned ctxId, unsigned unary_max, unsigned fixed ) { diff --git a/source/Lib/EncoderLib/CABACWriter.h b/source/Lib/EncoderLib/CABACWriter.h index cd8dc1ae6a53ba593573f93963f9c82767a9efcc..7f05fa9e84089b9419c9b9e29c3cbbbb7b02866d 100644 --- a/source/Lib/EncoderLib/CABACWriter.h +++ b/source/Lib/EncoderLib/CABACWriter.h @@ -153,11 +153,7 @@ public: void residual_coding_subblockTS( CoeffCodingContext& cctx, const TCoeff* coeff ); void joint_cb_cr ( const TransformUnit& tu, const int cbfMask ); -#if !REMOVE_PPS_REXT - // cross component prediction (clause 7.3.8.12) - void cross_comp_pred ( const TransformUnit& tu, ComponentID compID ); -#endif - + void codeAlfCtuEnableFlags ( CodingStructure& cs, ChannelType channel, AlfParam* alfParam); void codeAlfCtuEnableFlags ( CodingStructure& cs, ComponentID compID, AlfParam* alfParam); void codeAlfCtuEnableFlag ( CodingStructure& cs, uint32_t ctuRsAddr, const int compIdx, AlfParam* alfParam ); @@ -166,10 +162,8 @@ public: void codeAlfCtuAlternatives ( CodingStructure& cs, ChannelType channel, AlfParam* alfParam); void codeAlfCtuAlternatives ( CodingStructure& cs, ComponentID compID, AlfParam* alfParam); void codeAlfCtuAlternative ( CodingStructure& cs, uint32_t ctuRsAddr, const int compIdx, const AlfParam* alfParam = NULL ); -#if JVET_Q0795_CCALF void codeCcAlfFilterControlIdc(uint8_t idcVal, CodingStructure &cs, const ComponentID compID, const int curIdx, const uint8_t *filterControlIdc, Position lumaPos, const int filterCount); -#endif private: void unary_max_symbol ( unsigned symbol, unsigned ctxId0, unsigned ctxIdN, unsigned maxSymbol ); diff --git a/source/Lib/EncoderLib/EncAdaptiveLoopFilter.cpp b/source/Lib/EncoderLib/EncAdaptiveLoopFilter.cpp index 59a22d89f9d80f005e2f2e012a7e5709fc82aeaf..d5876a6f687d204b83a5d82d0c8aca847a318974 100644 --- a/source/Lib/EncoderLib/EncAdaptiveLoopFilter.cpp +++ b/source/Lib/EncoderLib/EncAdaptiveLoopFilter.cpp @@ -42,7 +42,6 @@ #define AlfCtx(c) SubCtx( Ctx::Alf, c) std::vector<double> EncAdaptiveLoopFilter::m_lumaLevelToWeightPLUT; -#if JVET_Q0795_CCALF #include <algorithm> #if MAX_NUM_CC_ALF_FILTERS>1 @@ -54,7 +53,6 @@ struct FilterIdxCount bool compareCounts(FilterIdxCount a, FilterIdxCount b) { return a.count > b.count; } #endif -#endif void AlfCovariance::getClipMax(const AlfFilterShape& alfShape, int *clip_max) const { @@ -255,8 +253,7 @@ double AlfCovariance::calcErrorForCoeffs( const int *clip, const int *coeff, con return error / factor; } -#if JVET_Q0795_CCALF -double AlfCovariance::calcErrorForCcAlfCoeffs(const int* coeff, const int numCoeff, const int bitDepth) const +double AlfCovariance::calcErrorForCcAlfCoeffs(const int16_t *coeff, const int numCoeff, const int bitDepth) const { double factor = 1 << (bitDepth - 1); double error = 0; @@ -274,7 +271,6 @@ double AlfCovariance::calcErrorForCcAlfCoeffs(const int* coeff, const int numCoe return error / factor; } -#endif double AlfCovariance::calculateError( const int *clip, const double *coeff, const int numCoeff ) const { @@ -453,12 +449,10 @@ EncAdaptiveLoopFilter::EncAdaptiveLoopFilter( int& apsIdStart ) m_alfWSSD = 0; -#if JVET_Q0795_CCALF m_alfCovarianceCcAlf[0] = nullptr; m_alfCovarianceCcAlf[1] = nullptr; m_alfCovarianceFrameCcAlf[0] = nullptr; m_alfCovarianceFrameCcAlf[1] = nullptr; -#endif } void EncAdaptiveLoopFilter::create( const EncCfg* encCfg, const int picWidth, const int picHeight, const ChromaFormat chromaFormatIDC, const int maxCUWidth, const int maxCUHeight, const int maxCUDepth, const int inputBitDepth[MAX_NUM_CHANNEL_TYPE], const int internalBitDepth[MAX_NUM_CHANNEL_TYPE] ) @@ -541,7 +535,6 @@ void EncAdaptiveLoopFilter::create( const EncCfg* encCfg, const int picWidth, co } m_alfCtbFilterSetIndexTmp.resize(m_numCTUsInPic); memset(m_clipDefaultEnc, 0, sizeof(m_clipDefaultEnc)); -#if JVET_Q0795_CCALF m_apsIdCcAlfStart[0] = (int) MAX_NUM_APS; m_apsIdCcAlfStart[1] = (int) MAX_NUM_APS; for( int compIdx = 1; compIdx < MAX_NUM_COMPONENT; compIdx++ ) @@ -569,11 +562,13 @@ void EncAdaptiveLoopFilter::create( const EncCfg* encCfg, const int picWidth, co } } m_trainingCovControl = new uint8_t[m_numCTUsInPic]; +#if !JVET_R0327_ONE_PASS_CCALF m_unfilteredDistortion = new uint64_t *[1]; for (int i = 0; i < 1; i++) { m_unfilteredDistortion[i] = new uint64_t[m_numCTUsInPic]; } +#endif for ( int i = 0; i < MAX_NUM_CC_ALF_FILTERS; i++ ) { m_trainingDistortion[i] = new uint64_t[m_numCTUsInPic]; @@ -585,7 +580,6 @@ void EncAdaptiveLoopFilter::create( const EncCfg* encCfg, const int picWidth, co m_buf = new PelBuf( m_bufOrigin, picWidth >> getComponentScaleX(COMPONENT_Cb,chromaFormatIDC), picWidth >> getComponentScaleX(COMPONENT_Cb,chromaFormatIDC), picHeight >> getComponentScaleY(COMPONENT_Cb,chromaFormatIDC) ); m_lumaSwingGreaterThanThresholdCount = new uint64_t[m_numCTUsInPic]; m_chromaSampleCountNearMidPoint = new uint64_t[m_numCTUsInPic]; -#endif } void EncAdaptiveLoopFilter::destroy() @@ -710,7 +704,6 @@ void EncAdaptiveLoopFilter::destroy() m_ctbDistortionUnfilter[comp] = nullptr; } -#if JVET_Q0795_CCALF for (int compIdx = 1; compIdx < MAX_NUM_COMPONENT; compIdx++) { int numFilters = MAX_NUM_CC_ALF_FILTERS; @@ -753,6 +746,7 @@ void EncAdaptiveLoopFilter::destroy() m_trainingCovControl = nullptr; } +#if !JVET_R0327_ONE_PASS_CCALF for (int i = 0; i < 1; i++) { if (m_unfilteredDistortion[i]) @@ -763,6 +757,7 @@ void EncAdaptiveLoopFilter::destroy() } delete[] m_unfilteredDistortion; m_unfilteredDistortion = nullptr; +#endif for ( int i = 0; i < MAX_NUM_CC_ALF_FILTERS; i++ ) { @@ -807,7 +802,6 @@ void EncAdaptiveLoopFilter::destroy() delete[] m_chromaSampleCountNearMidPoint; m_chromaSampleCountNearMidPoint = nullptr; } -#endif AdaptiveLoopFilter::destroy(); } @@ -821,7 +815,6 @@ void EncAdaptiveLoopFilter::initCABACEstimator( CABACEncoder* cabacEncoder, CtxC m_CABACEstimator->resetBits(); } -#if JVET_Q0795_CCALF void EncAdaptiveLoopFilter::xSetupCcAlfAPS( CodingStructure &cs ) { if (m_ccAlfFilterParam.ccAlfFilterEnabled[COMPONENT_Cb - 1]) @@ -889,11 +882,13 @@ void EncAdaptiveLoopFilter::xSetupCcAlfAPS( CodingStructure &cs ) cs.slice->setTileGroupCcAlfCrEnabledFlag(false); } } -#endif void EncAdaptiveLoopFilter::ALFProcess(CodingStructure& cs, const double *lambdas #if ENABLE_QPA , const double lambdaChromaWeight +#endif +#if JVET_R0110_MIXED_LOSSLESS + , Picture* pcPic, uint32_t numSliceSegments #endif ) { @@ -913,9 +908,7 @@ void EncAdaptiveLoopFilter::ALFProcess(CodingStructure& cs, const double *lambda if (alfAPS) { alfAPS->getAlfAPSParam().reset(); -#if JVET_Q0795_CCALF alfAPS->getCcAlfAPSParam().reset(); -#endif alfAPS = nullptr; } } @@ -924,9 +917,7 @@ void EncAdaptiveLoopFilter::ALFProcess(CodingStructure& cs, const double *lambda alfParam.reset(); const TempCtx ctxStart(m_CtxCache, AlfCtx(m_CABACEstimator->getCtx())); -#if JVET_Q0795_CCALF const TempCtx ctxStartCcAlf(m_CtxCache, SubCtx(Ctx::CcAlfFilterControlFlag, m_CABACEstimator->getCtx())); -#endif // set available filter shapes alfParam.filterShapes = m_filterShapes; @@ -1041,9 +1032,7 @@ void EncAdaptiveLoopFilter::ALFProcess(CodingStructure& cs, const double *lambda ); // derive filter (chroma) -#if JVET_Q0438_MONOCHROME_BUGFIXES if (isChromaEnabled(cs.pcv->chrFormat)) -#endif { alfEncoder( cs, alfParam, orgYuv, recYuv, cs.getRecoBuf(), CHANNEL_TYPE_CHROMA #if ENABLE_QPA @@ -1063,9 +1052,24 @@ void EncAdaptiveLoopFilter::ALFProcess(CodingStructure& cs, const double *lambda #endif ); +#if JVET_R0110_MIXED_LOSSLESS + for (int s = 0; s < numSliceSegments; s++) + { + if (pcPic->slices[s]->isLossless()) + { + for (uint32_t ctuIdx = 0; ctuIdx < pcPic->slices[s]->getNumCtuInSlice(); ctuIdx++) + { + uint32_t ctuRsAddr = pcPic->slices[s]->getCtuAddrInSlice(ctuIdx); + m_ctuEnableFlag[COMPONENT_Y][ctuRsAddr] = 0; + m_ctuEnableFlag[COMPONENT_Cb][ctuRsAddr] = 0; + m_ctuEnableFlag[COMPONENT_Cr][ctuRsAddr] = 0; + } + } + } +#endif + alfReconstructor(cs, recYuv); -#if JVET_Q0795_CCALF // Do not transmit CC ALF if it is unchanged if (cs.slice->getTileGroupAlfEnabledFlag(COMPONENT_Y)) { @@ -1096,6 +1100,13 @@ void EncAdaptiveLoopFilter::ALFProcess(CodingStructure& cs, const double *lambda m_tempBuf.get(COMPONENT_Cr).copyFrom(cs.getRecoBuf().get(COMPONENT_Cr)); recYuv = m_tempBuf.getBuf(cs.area); recYuv.extendBorderPel(MAX_ALF_FILTER_LENGTH >> 1); + +#if JVET_R0327_ONE_PASS_CCALF + deriveStatsForCcAlfFiltering(orgYuv, recYuv, COMPONENT_Cb, m_numCTUsInWidth, (0 + 1), cs); + deriveStatsForCcAlfFiltering(orgYuv, recYuv, COMPONENT_Cr, m_numCTUsInWidth, (0 + 1), cs); + initDistortionCcalf(); +#endif + m_CABACEstimator->getCtx() = SubCtx(Ctx::CcAlfFilterControlFlag, ctxStartCcAlf); deriveCcAlfFilter(cs, COMPONENT_Cb, orgYuv, recYuv, cs.getRecoBuf()); m_CABACEstimator->getCtx() = SubCtx(Ctx::CcAlfFilterControlFlag, ctxStartCcAlf); @@ -1112,7 +1123,6 @@ void EncAdaptiveLoopFilter::ALFProcess(CodingStructure& cs, const double *lambda m_ccAlfFilterParam.ccAlfCoeff[compIdx - 1], -1); } } -#endif } double EncAdaptiveLoopFilter::deriveCtbAlfEnableFlags( CodingStructure& cs, const int iShapeIdx, ChannelType channel, @@ -1274,15 +1284,9 @@ void EncAdaptiveLoopFilter::alfEncoder( CodingStructure& cs, AlfParam& alfParam, setCtuAlternativeChroma( m_ctuAlternativeTmp, 0 ); } -#if JVET_Q0249_ALF_CHROMA_CLIPFLAG const int nonLinearFlagMax = ( isLuma( channel ) ? m_encCfg->getUseNonLinearAlfLuma() : m_encCfg->getUseNonLinearAlfChroma()) // For Chroma non linear flag is check for each alternative filter ? 2 : 1; -#else - const int nonLinearFlagMax = - ( isLuma( channel ) ? m_encCfg->getUseNonLinearAlfLuma() : 0 ) // For Chroma non linear flag is check for each alternative filter - ? 2 : 1; -#endif for( int nonLinearFlag = 0; nonLinearFlag < nonLinearFlagMax; nonLinearFlag++ ) { @@ -1292,12 +1296,7 @@ void EncAdaptiveLoopFilter::alfEncoder( CodingStructure& cs, AlfParam& alfParam, m_alfParamTemp.numAlternativesChroma = numAlternatives; //2. all CTUs are on setEnableFlag( m_alfParamTemp, channel, true ); -#if JVET_Q0249_ALF_CHROMA_CLIPFLAG m_alfParamTemp.nonLinearFlag[channel] = nonLinearFlag; -#else - if (isLuma(channel)) - m_alfParamTemp.nonLinearFlag[channel][0] = nonLinearFlag; -#endif m_CABACEstimator->getCtx() = AlfCtx( ctxStart ); setCtuEnableFlag( m_ctuEnableFlag, channel, 1 ); // all alternatives are on @@ -1377,11 +1376,7 @@ void EncAdaptiveLoopFilter::copyAlfParam( AlfParam& alfParamDst, AlfParam& alfPa alfParamDst.enabledFlag[COMPONENT_Cb] = alfParamSrc.enabledFlag[COMPONENT_Cb]; alfParamDst.enabledFlag[COMPONENT_Cr] = alfParamSrc.enabledFlag[COMPONENT_Cr]; alfParamDst.numAlternativesChroma = alfParamSrc.numAlternativesChroma; -#if JVET_Q0249_ALF_CHROMA_CLIPFLAG alfParamDst.nonLinearFlag[CHANNEL_TYPE_CHROMA] = alfParamSrc.nonLinearFlag[CHANNEL_TYPE_CHROMA]; -#else - memcpy( alfParamDst.nonLinearFlag[CHANNEL_TYPE_CHROMA], alfParamSrc.nonLinearFlag[CHANNEL_TYPE_CHROMA], sizeof( alfParamDst.nonLinearFlag[CHANNEL_TYPE_CHROMA] ) ); -#endif memcpy( alfParamDst.chromaCoeff, alfParamSrc.chromaCoeff, sizeof( alfParamDst.chromaCoeff ) ); memcpy( alfParamDst.chromaClipp, alfParamSrc.chromaClipp, sizeof( alfParamDst.chromaClipp ) ); } @@ -1401,11 +1396,7 @@ double EncAdaptiveLoopFilter::getFilterCoeffAndCost( CodingStructure& cs, double //get filter coeff if( isLuma( channel ) ) { -#if JVET_Q0249_ALF_CHROMA_CLIPFLAG std::fill_n(m_alfClipMerged[iShapeIdx][0][0], MAX_NUM_ALF_LUMA_COEFF*MAX_NUM_ALF_CLASSES*MAX_NUM_ALF_CLASSES, m_alfParamTemp.nonLinearFlag[channel] ? AlfNumClippingValues[CHANNEL_TYPE_LUMA] / 2 : 0); -#else - std::fill_n(m_alfClipMerged[iShapeIdx][0][0], MAX_NUM_ALF_LUMA_COEFF*MAX_NUM_ALF_CLASSES*MAX_NUM_ALF_CLASSES, m_alfParamTemp.nonLinearFlag[channel][0] ? AlfNumClippingValues[CHANNEL_TYPE_LUMA] / 2 : 0); -#endif // Reset Merge Tmp Cov m_alfCovarianceMerged[iShapeIdx][MAX_NUM_ALF_CLASSES].reset(AlfNumClippingValues[channel]); m_alfCovarianceMerged[iShapeIdx][MAX_NUM_ALF_CLASSES + 1].reset(AlfNumClippingValues[channel]); @@ -1426,15 +1417,11 @@ double EncAdaptiveLoopFilter::getFilterCoeffAndCost( CodingStructure& cs, double for( int nonLinearFlag = 0; nonLinearFlag < nonLinearFlagMax; nonLinearFlag++ ) { -#if JVET_Q0249_ALF_CHROMA_CLIPFLAG int currentNonLinearFlag = m_alfParamTemp.nonLinearFlag[channel] ? 1 : 0; if (nonLinearFlag != currentNonLinearFlag) { continue; } -#else - m_alfParamTemp.nonLinearFlag[channel][altIdx] = nonLinearFlag; -#endif std::fill_n(m_filterClippSet[altIdx], MAX_NUM_ALF_CHROMA_COEFF, nonLinearFlag ? AlfNumClippingValues[CHANNEL_TYPE_CHROMA] / 2 : 0 ); double dist = m_alfCovarianceFrame[channel][iShapeIdx][altIdx].pixAcc + deriveCoeffQuant( m_filterClippSet[altIdx], m_filterCoeffSet[altIdx], m_alfCovarianceFrame[channel][iShapeIdx][altIdx], alfFilterShape, m_NUM_BITS, nonLinearFlag ); @@ -1458,11 +1445,7 @@ double EncAdaptiveLoopFilter::getFilterCoeffAndCost( CodingStructure& cs, double m_alfParamTemp = bestSliceParam; } uiCoeffBits += lengthUvlc( m_alfParamTemp.numAlternativesChroma-1 ); -#if JVET_Q0249_ALF_CHROMA_CLIPFLAG uiCoeffBits++; -#else - uiCoeffBits += m_alfParamTemp.numAlternativesChroma; // non-linear flags -#endif } if (onlyFilterCost) { @@ -1494,19 +1477,11 @@ int EncAdaptiveLoopFilter::getChromaCoeffRate( AlfParam& alfParam, int altIdx ) // Filter coefficients for( int i = 0; i < alfShape.numCoeff - 1; i++ ) { -#if JVET_Q0210_UEK_REMOVAL iBits += lengthUvlc( abs( alfParam.chromaCoeff[ altIdx ][ i ] ) ); // alf_coeff_chroma[altIdx][i] if( ( alfParam.chromaCoeff[ altIdx ][ i ] ) != 0 ) iBits += 1; -#else - iBits += lengthGolomb( alfParam.chromaCoeff[ altIdx ][ i ], 3 ); // alf_coeff_chroma[altIdx][i] -#endif } -#if JVET_Q0249_ALF_CHROMA_CLIPFLAG if( m_alfParamTemp.nonLinearFlag[CHANNEL_TYPE_CHROMA] ) -#else - if( m_alfParamTemp.nonLinearFlag[CHANNEL_TYPE_CHROMA][altIdx] ) -#endif { for (int i = 0; i < alfShape.numCoeff - 1; i++) { @@ -1560,8 +1535,8 @@ double EncAdaptiveLoopFilter::mergeFiltersAndCost( AlfParam& alfParam, AlfFilter { int numFiltersBest = 0; int numFilters = MAX_NUM_ALF_CLASSES; - static bool codedVarBins[MAX_NUM_ALF_CLASSES]; - static double errorForce0CoeffTab[MAX_NUM_ALF_CLASSES][2]; + bool codedVarBins[MAX_NUM_ALF_CLASSES]; + double errorForce0CoeffTab[MAX_NUM_ALF_CLASSES][2]; double cost, cost0, dist, distForce0, costMin = MAX_DOUBLE; int coeffBits, coeffBitsForce0; @@ -1667,32 +1642,20 @@ int EncAdaptiveLoopFilter::getCostFilterCoeffForce0( AlfFilterShape& alfShape, i { for( int i = 0; i < alfShape.numCoeff - 1; i++ ) { -#if JVET_Q0210_UEK_REMOVAL len += lengthUvlc( abs( pDiffQFilterCoeffIntPP[ ind ][ i ] ) ); // alf_coeff_luma_delta[i][j] if( ( abs( pDiffQFilterCoeffIntPP[ ind ][ i ] ) != 0 ) ) len += 1; -#else - len += lengthGolomb( abs( pDiffQFilterCoeffIntPP[ ind ][ i ] ), 3 ); // alf_coeff_luma_delta[i][j] -#endif } } else { for (int i = 0; i < alfShape.numCoeff - 1; i++) { -#if JVET_Q0210_UEK_REMOVAL len += lengthUvlc( 0 ); // alf_coeff_luma_delta[i][j] -#else - len += lengthGolomb( 0, 3 ); // alf_coeff_luma_delta[i][j] -#endif } } } -#if JVET_Q0249_ALF_CHROMA_CLIPFLAG if( m_alfParamTemp.nonLinearFlag[CHANNEL_TYPE_LUMA] ) -#else - if( m_alfParamTemp.nonLinearFlag[CHANNEL_TYPE_LUMA][0] ) -#endif { for (int ind = 0; ind < numFilters; ++ind) { @@ -1743,13 +1706,9 @@ int EncAdaptiveLoopFilter::lengthFilterCoeffs( AlfFilterShape& alfShape, const i { for( int i = 0; i < alfShape.numCoeff - 1; i++ ) { -#if JVET_Q0210_UEK_REMOVAL bitCnt += lengthUvlc( abs( FilterCoeff[ ind ][ i ] ) ); if( abs( FilterCoeff[ ind ][ i ] ) != 0 ) bitCnt += 1; -#else - bitCnt += lengthGolomb( abs( FilterCoeff[ ind ][ i ] ), 3 ); -#endif } } return bitCnt; @@ -1758,37 +1717,25 @@ int EncAdaptiveLoopFilter::lengthFilterCoeffs( AlfFilterShape& alfShape, const i double EncAdaptiveLoopFilter::getDistForce0( AlfFilterShape& alfShape, const int numFilters, double errorTabForce0Coeff[MAX_NUM_ALF_CLASSES][2], bool* codedVarBins ) { - static int bitsVarBin[MAX_NUM_ALF_CLASSES]; + int bitsVarBin[MAX_NUM_ALF_CLASSES]; for( int ind = 0; ind < numFilters; ++ind ) { bitsVarBin[ind] = 0; for( int i = 0; i < alfShape.numCoeff - 1; i++ ) { -#if JVET_Q0210_UEK_REMOVAL bitsVarBin[ ind ] += lengthUvlc( abs( m_filterCoeffSet[ ind ][ i ] ) ); if( abs( m_filterCoeffSet[ ind ][ i ] ) != 0 ) bitsVarBin[ ind ] += 1; -#else - bitsVarBin[ ind ] += lengthGolomb( abs( m_filterCoeffSet[ ind ][ i ] ), 3 ); -#endif } } - static int zeroBitsVarBin = 0; + int zeroBitsVarBin = 0; for (int i = 0; i < alfShape.numCoeff - 1; i++) { -#if JVET_Q0210_UEK_REMOVAL zeroBitsVarBin += lengthUvlc( 0 ); -#else - zeroBitsVarBin += lengthGolomb( 0, 3 ); -#endif } -#if JVET_Q0249_ALF_CHROMA_CLIPFLAG if( m_alfParamTemp.nonLinearFlag[CHANNEL_TYPE_LUMA] ) -#else - if( m_alfParamTemp.nonLinearFlag[CHANNEL_TYPE_LUMA][0] ) -#endif { for (int ind = 0; ind < numFilters; ++ind) { @@ -1837,25 +1784,6 @@ int EncAdaptiveLoopFilter::lengthUvlc( int uiCode ) return ( uiLength >> 1 ) + ( ( uiLength + 1 ) >> 1 ); } -#if !JVET_Q0210_UEK_REMOVAL -int EncAdaptiveLoopFilter::lengthGolomb( int coeffVal, int k, bool signed_coeff ) -{ - int numBins = 0; - unsigned int symbol = abs( coeffVal ); - while( symbol >= ( unsigned int ) ( 1 << k ) ) - { - numBins++; - symbol -= 1 << k; - k++; - } - numBins += ( k + 1 ); - if( signed_coeff && coeffVal != 0 ) - { - numBins++; - } - return numBins; -} -#endif double EncAdaptiveLoopFilter::deriveFilterCoeffs( AlfCovariance* cov, AlfCovariance* covMerged, int clipMerged[MAX_NUM_ALF_CLASSES][MAX_NUM_ALF_CLASSES][MAX_NUM_ALF_LUMA_COEFF], AlfFilterShape& alfShape, short* filterIndices, int numFilters, double errorTabForce0Coeff[MAX_NUM_ALF_CLASSES][2], AlfParam& alfParam ) { @@ -1896,8 +1824,8 @@ double EncAdaptiveLoopFilter::deriveCoeffQuant( int *filterClipp, int *filterCoe const int max_value = factor - 1; const int min_value = -factor + 1; -const int numCoeff = shape.numCoeff; - static double filterCoeff[MAX_NUM_ALF_LUMA_COEFF]; + const int numCoeff = shape.numCoeff; + double filterCoeff[MAX_NUM_ALF_LUMA_COEFF]; cov.optimizeFilter( shape, filterClipp, filterCoeff, optimizeClip ); roundFiltCoeff( filterCoeffQuant, filterCoeff, numCoeff, factor ); @@ -1955,8 +1883,8 @@ void EncAdaptiveLoopFilter::roundFiltCoeff( int *filterCoeffQuant, double *filte } } -#if JVET_Q0795_CCALF -void EncAdaptiveLoopFilter::roundFiltCoeffCCALF( int *filterCoeffQuant, double *filterCoeff, const int numCoeff, const int factor ) +void EncAdaptiveLoopFilter::roundFiltCoeffCCALF(int16_t *filterCoeffQuant, double *filterCoeff, const int numCoeff, + const int factor) { for( int i = 0; i < numCoeff; i++ ) { @@ -1976,17 +1904,16 @@ void EncAdaptiveLoopFilter::roundFiltCoeffCCALF( int *filterCoeffQuant, double * filterCoeffQuant[i] = CCALF_SMALL_TAB[best_index] * sign; } } -#endif void EncAdaptiveLoopFilter::mergeClasses( const AlfFilterShape& alfShape, AlfCovariance* cov, AlfCovariance* covMerged, int clipMerged[MAX_NUM_ALF_CLASSES][MAX_NUM_ALF_CLASSES][MAX_NUM_ALF_LUMA_COEFF], const int numClasses, short filterIndices[MAX_NUM_ALF_CLASSES][MAX_NUM_ALF_CLASSES] ) { - static int tmpClip[MAX_NUM_ALF_LUMA_COEFF]; - static int bestMergeClip[MAX_NUM_ALF_LUMA_COEFF]; - static double err[MAX_NUM_ALF_CLASSES]; - static double bestMergeErr; - static bool availableClass[MAX_NUM_ALF_CLASSES]; - static uint8_t indexList[MAX_NUM_ALF_CLASSES]; - static uint8_t indexListTemp[MAX_NUM_ALF_CLASSES]; + int tmpClip[MAX_NUM_ALF_LUMA_COEFF]; + int bestMergeClip[MAX_NUM_ALF_LUMA_COEFF]; + double err[MAX_NUM_ALF_CLASSES]; + double bestMergeErr = std::numeric_limits<double>::max(); + bool availableClass[MAX_NUM_ALF_CLASSES]; + uint8_t indexList[MAX_NUM_ALF_CLASSES]; + uint8_t indexListTemp[MAX_NUM_ALF_CLASSES]; int numRemaining = numClasses; memset( filterIndices, 0, sizeof( short ) * MAX_NUM_ALF_CLASSES * MAX_NUM_ALF_CLASSES ); @@ -1997,33 +1924,20 @@ void EncAdaptiveLoopFilter::mergeClasses( const AlfFilterShape& alfShape, AlfCov indexList[i] = i; availableClass[i] = true; covMerged[i] = cov[i]; -#if JVET_Q0249_ALF_CHROMA_CLIPFLAG covMerged[i].numBins = m_alfParamTemp.nonLinearFlag[CHANNEL_TYPE_LUMA] ? AlfNumClippingValues[COMPONENT_Y] : 1; -#else - covMerged[i].numBins = m_alfParamTemp.nonLinearFlag[CHANNEL_TYPE_LUMA][0] ? AlfNumClippingValues[COMPONENT_Y] : 1; -#endif } // Try merging different covariance matrices // temporal AlfCovariance structure is allocated as the last element in covMerged array, the size of covMerged is MAX_NUM_ALF_CLASSES + 1 AlfCovariance& tmpCov = covMerged[MAX_NUM_ALF_CLASSES]; -#if JVET_Q0249_ALF_CHROMA_CLIPFLAG tmpCov.numBins = m_alfParamTemp.nonLinearFlag[CHANNEL_TYPE_LUMA] ? AlfNumClippingValues[COMPONENT_Y] : 1; -#else - tmpCov.numBins = m_alfParamTemp.nonLinearFlag[CHANNEL_TYPE_LUMA][0] ? AlfNumClippingValues[COMPONENT_Y] : 1; -#endif // init Clip for( int i = 0; i < numClasses; i++ ) { -#if JVET_Q0249_ALF_CHROMA_CLIPFLAG std::fill_n(clipMerged[numRemaining-1][i], MAX_NUM_ALF_LUMA_COEFF, m_alfParamTemp.nonLinearFlag[CHANNEL_TYPE_LUMA] ? AlfNumClippingValues[CHANNEL_TYPE_LUMA] / 2 : 0); if ( m_alfParamTemp.nonLinearFlag[CHANNEL_TYPE_LUMA] ) -#else - std::fill_n(clipMerged[numRemaining-1][i], MAX_NUM_ALF_LUMA_COEFF, m_alfParamTemp.nonLinearFlag[CHANNEL_TYPE_LUMA][0] ? AlfNumClippingValues[CHANNEL_TYPE_LUMA] / 2 : 0); - if ( m_alfParamTemp.nonLinearFlag[CHANNEL_TYPE_LUMA][0] ) -#endif { err[i] = covMerged[i].optimizeFilterClip( alfShape, clipMerged[numRemaining-1][i] ); } @@ -2054,11 +1968,7 @@ void EncAdaptiveLoopFilter::mergeClasses( const AlfFilterShape& alfShape, AlfCov { tmpClip[l] = (clipMerged[numRemaining-1][i][l] + clipMerged[numRemaining-1][j][l] + 1 ) >> 1; } -#if JVET_Q0249_ALF_CHROMA_CLIPFLAG double errorMerged = m_alfParamTemp.nonLinearFlag[CHANNEL_TYPE_LUMA] ? tmpCov.optimizeFilterClip(alfShape, tmpClip) : tmpCov.calculateError(tmpClip); -#else - double errorMerged = m_alfParamTemp.nonLinearFlag[CHANNEL_TYPE_LUMA][0] ? tmpCov.optimizeFilterClip( alfShape, tmpClip ) : tmpCov.calculateError( tmpClip ); -#endif double error = errorMerged - error1 - error2; if( error < errorMin ) @@ -2345,7 +2255,7 @@ void EncAdaptiveLoopFilter::getBlkStats(AlfCovariance* alfCovariance, const AlfF { - static int ELocal[MAX_NUM_ALF_LUMA_COEFF][MaxAlfNumClippingValues]; + int ELocal[MAX_NUM_ALF_LUMA_COEFF][MaxAlfNumClippingValues]; const int numBins = AlfNumClippingValues[channel]; int transposeIdx = 0; @@ -2659,6 +2569,20 @@ void EncAdaptiveLoopFilter::initDistortion() } } } + +#if JVET_R0327_ONE_PASS_CCALF +void EncAdaptiveLoopFilter::initDistortionCcalf() +{ + for (int comp = 1; comp < MAX_NUM_COMPONENT; comp++) + { + for (int ctbIdx = 0; ctbIdx < m_numCTUsInPic; ctbIdx++) + { + m_ctbDistortionUnfilter[comp][ctbIdx] = m_alfCovarianceCcAlf[comp - 1][0][0][ctbIdx].pixAcc; + } + } +} +#endif + void EncAdaptiveLoopFilter::alfEncoderCtb(CodingStructure& cs, AlfParam& alfParamNewFilters #if ENABLE_QPA , const double lambdaChromaWeight @@ -2755,11 +2679,7 @@ void EncAdaptiveLoopFilter::alfEncoderCtb(CodingStructure& cs, AlfParam& alfPar { int bitNL[2] = { 0, 0 }; double errNL[2] = { 0.0, 0.0 }; -#if JVET_Q0249_ALF_CHROMA_CLIPFLAG m_alfParamTemp.nonLinearFlag[CHANNEL_TYPE_LUMA] = 1; -#else - m_alfParamTemp.nonLinearFlag[CHANNEL_TYPE_LUMA][0] = 1; -#endif if (m_encCfg->getUseNonLinearAlfLuma()) { errNL[1] = getFilterCoeffAndCost(cs, 0, CHANNEL_TYPE_LUMA, true, 0, bitNL[1], true); @@ -2769,11 +2689,7 @@ void EncAdaptiveLoopFilter::alfEncoderCtb(CodingStructure& cs, AlfParam& alfPar { errNL[1] = MAX_DOUBLE; } -#if JVET_Q0249_ALF_CHROMA_CLIPFLAG m_alfParamTemp.nonLinearFlag[CHANNEL_TYPE_LUMA] = 0; -#else - m_alfParamTemp.nonLinearFlag[CHANNEL_TYPE_LUMA][0] = 0; -#endif errNL[0] = getFilterCoeffAndCost(cs, 0, CHANNEL_TYPE_LUMA, true, 0, bitNL[0], true); int bitsNewFilterTempLuma = bitNL[0]; @@ -2912,10 +2828,8 @@ void EncAdaptiveLoopFilter::alfEncoderCtb(CodingStructure& cs, AlfParam& alfPar }// for (int numTemporalAps = 0; numTemporalAps < apsIds.size(); numTemporalAps++) }//for (int useNewFilter = 0; useNewFilter <= 1; useNewFilter++) -#if JVET_Q0795_CCALF cs.slice->setTileGroupCcAlfCbApsId(newApsId); cs.slice->setTileGroupCcAlfCrApsId(newApsId); -#endif if (costOff <= costMin) { @@ -2959,10 +2873,8 @@ void EncAdaptiveLoopFilter::alfEncoderCtb(CodingStructure& cs, AlfParam& alfPar } //chroma -#if JVET_Q0438_MONOCHROME_BUGFIXES if (isChromaEnabled(cs.pcv->chrFormat)) { -#endif m_alfParamTemp = alfParamNewFiltersBest; if( m_alfParamTemp.numAlternativesChroma < 1 ) { @@ -3119,13 +3031,11 @@ void EncAdaptiveLoopFilter::alfEncoderCtb(CodingStructure& cs, AlfParam& alfPar } } -#if JVET_Q0795_CCALF if (newApsIdChroma >= 0) { cs.slice->setTileGroupCcAlfCbApsId(newApsIdChroma); cs.slice->setTileGroupCcAlfCrApsId(newApsIdChroma); } -#endif if (costOff < costMin) { cs.slice->setTileGroupAlfEnabledFlag(COMPONENT_Cb, false); @@ -3152,12 +3062,7 @@ void EncAdaptiveLoopFilter::alfEncoderCtb(CodingStructure& cs, AlfParam& alfPar newAPS->getAlfAPSParam().newFilterFlag[CHANNEL_TYPE_LUMA] = false; } newAPS->getAlfAPSParam().numAlternativesChroma = alfParamNewFilters.numAlternativesChroma; -#if JVET_Q0249_ALF_CHROMA_CLIPFLAG newAPS->getAlfAPSParam().nonLinearFlag[CHANNEL_TYPE_CHROMA] = alfParamNewFilters.nonLinearFlag[CHANNEL_TYPE_CHROMA]; -#else - for( int altIdx = 0; altIdx < MAX_NUM_ALF_ALTERNATIVES_CHROMA; ++altIdx ) - newAPS->getAlfAPSParam().nonLinearFlag[CHANNEL_TYPE_CHROMA][altIdx] = alfParamNewFilters.nonLinearFlag[CHANNEL_TYPE_CHROMA][altIdx]; -#endif newAPS->setTemporalId( cs.slice->getTLayer() ); for (int altIdx = 0; altIdx < MAX_NUM_ALF_ALTERNATIVES_CHROMA; ++altIdx ) for (int i = 0; i < MAX_NUM_ALF_CHROMA_COEFF; i++) @@ -3170,9 +3075,7 @@ void EncAdaptiveLoopFilter::alfEncoderCtb(CodingStructure& cs, AlfParam& alfPar } apss[cs.slice->getTileGroupApsIdChroma()] = m_apsMap->getPS((cs.slice->getTileGroupApsIdChroma() << NUM_APS_TYPE_LEN) + ALF_APS); } -#if JVET_Q0438_MONOCHROME_BUGFIXES } -#endif } void EncAdaptiveLoopFilter::alfReconstructor(CodingStructure& cs, const PelUnitBuf& recExtBuf) @@ -3366,7 +3269,6 @@ int EncAdaptiveLoopFilter::getMaxNumAlternativesChroma( ) return std::min<int>( m_numCTUsInPic * 2, m_encCfg->getMaxNumAlfAlternativesChroma() ); } -#if JVET_Q0795_CCALF int EncAdaptiveLoopFilter::getCoeffRateCcAlf(short chromaCoeff[MAX_NUM_CC_ALF_FILTERS][MAX_NUM_CC_ALF_CHROMA_COEFF], bool filterEnabled[MAX_NUM_CC_ALF_FILTERS], uint8_t filterCount, ComponentID compID) { int bits = 0; @@ -3406,8 +3308,10 @@ void EncAdaptiveLoopFilter::deriveCcAlfFilterCoeff( ComponentID compID, const Pe using TE = double[MAX_NUM_ALF_LUMA_COEFF][MAX_NUM_ALF_LUMA_COEFF]; using Ty = double[MAX_NUM_ALF_LUMA_COEFF]; - static double filterCoeffDbl[MAX_NUM_CC_ALF_CHROMA_COEFF]; - static int filterCoeffInt[MAX_NUM_CC_ALF_CHROMA_COEFF]; + double filterCoeffDbl[MAX_NUM_CC_ALF_CHROMA_COEFF]; + int16_t filterCoeffInt[MAX_NUM_CC_ALF_CHROMA_COEFF]; + + std::fill_n(filterCoeffInt, MAX_NUM_CC_ALF_CHROMA_COEFF, 0); TE kE; Ty ky; @@ -3488,7 +3392,7 @@ void EncAdaptiveLoopFilter::deriveCcAlfFilterCoeff( ComponentID compID, const Pe } } - +#if !JVET_R0327_ONE_PASS_CCALF void EncAdaptiveLoopFilter::computeLog2BlockSizeDistortion(const Pel *org, int orgStride, const Pel *dec, int decStride, int height, int width, uint64_t *distortionBuf, int distortionBufStride, int log2BlockWidth, @@ -3523,7 +3427,21 @@ void EncAdaptiveLoopFilter::computeLog2BlockSizeDistortion(const Pel *org, int o dec += (decStride << log2BlockHeight); } } +#endif +#if JVET_R0327_ONE_PASS_CCALF +void EncAdaptiveLoopFilter::determineControlIdcValues(CodingStructure &cs, const ComponentID compID, const PelBuf *buf, + const int ctuWidthC, const int ctuHeightC, const int picWidthC, + const int picHeightC, double **unfilteredDistortion, + uint64_t *trainingDistortion[MAX_NUM_CC_ALF_FILTERS], + uint64_t *lumaSwingGreaterThanThresholdCount, + uint64_t *chromaSampleCountNearMidPoint, + bool reuseTemporalFilterCoeff, uint8_t *trainingCovControl, + uint8_t *filterControl, uint64_t &curTotalDistortion, + double &curTotalRate, bool filterEnabled[MAX_NUM_CC_ALF_FILTERS], + uint8_t mapFilterIdxToFilterIdc[MAX_NUM_CC_ALF_FILTERS + 1], + uint8_t &ccAlfFilterCount) +#else void EncAdaptiveLoopFilter::determineControlIdcValues(CodingStructure &cs, const ComponentID compID, const PelBuf *buf, const int ctuWidthC, const int ctuHeightC, const int picWidthC, const int picHeightC, uint64_t **unfilteredDistortion, @@ -3535,6 +3453,7 @@ void EncAdaptiveLoopFilter::determineControlIdcValues(CodingStructure &cs, const double &curTotalRate, bool filterEnabled[MAX_NUM_CC_ALF_FILTERS], uint8_t mapFilterIdxToFilterIdc[MAX_NUM_CC_ALF_FILTERS + 1], uint8_t &ccAlfFilterCount) +#endif { bool curFilterEnabled[MAX_NUM_CC_ALF_FILTERS]; std::fill_n(curFilterEnabled, MAX_NUM_CC_ALF_FILTERS, false); @@ -3587,7 +3506,11 @@ void EncAdaptiveLoopFilter::determineControlIdcValues(CodingStructure &cs, const if (filterIdx == MAX_NUM_CC_ALF_FILTERS) { +#if JVET_R0327_ONE_PASS_CCALF + ssd = (uint64_t)unfilteredDistortion[compID][ctuIdx]; // restore saved distortion computation +#else ssd = unfilteredDistortion[0][ctuIdx]; // restore saved distortion computation +#endif } else { @@ -3709,6 +3632,36 @@ std::vector<int> EncAdaptiveLoopFilter::getAvailableCcAlfApsIds(CodingStructure& return result; } +#if JVET_R0327_ONE_PASS_CCALF +void EncAdaptiveLoopFilter::getFrameStatsCcalf(ComponentID compIdx, int filterIdc) +{ + int ctuRsAddr = 0; + const int filterIdx = filterIdc - 1; + + // init Frame stats buffers + for (int shape = 0; shape != m_filterShapesCcAlf[compIdx - 1].size(); shape++) + { + m_alfCovarianceFrameCcAlf[compIdx - 1][shape][filterIdx].reset(); + } + + for (int yPos = 0; yPos < m_picHeight; yPos += m_maxCUHeight) + { + for (int xPos = 0; xPos < m_picWidth; xPos += m_maxCUWidth) + { + if (m_trainingCovControl[ctuRsAddr] == filterIdc) + { + for (int shape = 0; shape != m_filterShapesCcAlf[compIdx - 1].size(); shape++) + { + m_alfCovarianceFrameCcAlf[compIdx - 1][shape][filterIdx] += + m_alfCovarianceCcAlf[compIdx - 1][shape][0][ctuRsAddr]; + } + } + ctuRsAddr++; + } + } +} +#endif + void EncAdaptiveLoopFilter::deriveCcAlfFilter( CodingStructure& cs, ComponentID compID, const PelUnitBuf& orgYuv, const PelUnitBuf& tempDecYuvBuf, const PelUnitBuf& dstYuv ) { if (!cs.slice->getTileGroupAlfEnabledFlag(COMPONENT_Y)) @@ -3761,21 +3714,31 @@ void EncAdaptiveLoopFilter::deriveCcAlfFilter( CodingStructure& cs, ComponentID const TempCtx ctxStartCcAlfFilterControlFlag ( m_CtxCache, SubCtx( Ctx::CcAlfFilterControlFlag, m_CABACEstimator->getCtx() ) ); // compute cost of not filtering +#if !JVET_R0327_ONE_PASS_CCALF const Pel *org = orgYuv.get( compID ).bufAt(0,0); const Pel *unfiltered = dstYuv.get( compID ).bufAt(0,0); const int orgStride = orgYuv.get( compID ).stride; const int unfilteredStride = dstYuv.get( compID ).stride; const Pel *filtered = m_buf->bufAt(0,0); const int filteredStride = m_buf->stride; +#endif uint64_t unfilteredDistortion = 0; +#if JVET_R0327_ONE_PASS_CCALF + for (int ctbIdx = 0; ctbIdx < m_numCTUsInPic; ctbIdx++) + { + unfilteredDistortion += (uint64_t)m_alfCovarianceCcAlf[compID - 1][0][0][ctbIdx].pixAcc; + } +#else computeLog2BlockSizeDistortion(org, orgStride, unfiltered, unfilteredStride, m_buf->height, m_buf->width, m_unfilteredDistortion[0], m_numCTUsInWidth, cs.pcv->maxCUWidthLog2 - scaleX, cs.pcv->maxCUHeightLog2 - scaleY, unfilteredDistortion); +#endif + double bestUnfilteredTotalCost = 1 * m_lambda[compID] + unfilteredDistortion; // 1 bit is for gating flag - static bool ccAlfFilterIdxEnabled[MAX_NUM_CC_ALF_FILTERS]; - static short ccAlfFilterCoeff[MAX_NUM_CC_ALF_FILTERS][MAX_NUM_CC_ALF_CHROMA_COEFF]; - static uint8_t ccAlfFilterCount = MAX_NUM_CC_ALF_FILTERS; + bool ccAlfFilterIdxEnabled[MAX_NUM_CC_ALF_FILTERS]; + short ccAlfFilterCoeff[MAX_NUM_CC_ALF_FILTERS][MAX_NUM_CC_ALF_CHROMA_COEFF]; + uint8_t ccAlfFilterCount = MAX_NUM_CC_ALF_FILTERS; double bestFilteredTotalCost = MAX_DOUBLE; bool bestreuseTemporalFilterCoeff = false; std::vector<int> apsIds = getAvailableCcAlfApsIds(cs, compID); @@ -3858,9 +3821,29 @@ void EncAdaptiveLoopFilter::deriveCcAlfFilter( CodingStructure& cs, ComponentID { if (!referencingExistingAps) { +#if JVET_R0327_ONE_PASS_CCALF + getFrameStatsCcalf(compID, (filterIdx + 1)); +#else deriveStatsForCcAlfFiltering(orgYuv, tempDecYuvBuf, compID, m_numCTUsInWidth, (filterIdx + 1), cs); +#endif deriveCcAlfFilterCoeff(compID, dstYuv, tempDecYuvBuf, ccAlfFilterCoeff, filterIdx); } +#if JVET_R0327_ONE_PASS_CCALF + const int numCoeff = m_filterShapesCcAlf[compID - 1][0].numCoeff - 1; + int log2BlockWidth = cs.pcv->maxCUWidthLog2 - scaleX; + int log2BlockHeight = cs.pcv->maxCUHeightLog2 - scaleY; + for (int y = 0; y < m_buf->height; y += (1 << log2BlockHeight)) + { + for (int x = 0; x < m_buf->width; x += (1 << log2BlockWidth)) + { + int ctuIdx = (y >> log2BlockHeight) * m_numCTUsInWidth + (x >> log2BlockWidth); + m_trainingDistortion[filterIdx][ctuIdx] = + int(m_ctbDistortionUnfilter[compID][ctuIdx] + + m_alfCovarianceCcAlf[compID - 1][0][0][ctuIdx].calcErrorForCcAlfCoeffs( + ccAlfFilterCoeff[filterIdx], numCoeff, m_scaleBits + 1)); + } + } +#else m_buf->copyFrom(dstYuv.get(compID)); applyCcAlfFilter(cs, compID, *m_buf, tempDecYuvBuf, nullptr, ccAlfFilterCoeff, filterIdx); @@ -3868,6 +3851,7 @@ void EncAdaptiveLoopFilter::deriveCcAlfFilter( CodingStructure& cs, ComponentID computeLog2BlockSizeDistortion( org, orgStride, filtered, filteredStride, m_buf->height, m_buf->width, m_trainingDistortion[filterIdx], m_numCTUsInWidth, cs.pcv->maxCUWidthLog2 - scaleX, cs.pcv->maxCUHeightLog2 - scaleY, distortion); +#endif } } @@ -3875,6 +3859,15 @@ void EncAdaptiveLoopFilter::deriveCcAlfFilter( CodingStructure& cs, ComponentID uint64_t curTotalDistortion = 0; double curTotalRate = 0; +#if JVET_R0327_ONE_PASS_CCALF + determineControlIdcValues(cs, compID, m_buf, ctuWidthC, ctuHeightC, picWidthC, picHeightC, + m_ctbDistortionUnfilter, m_trainingDistortion, + m_lumaSwingGreaterThanThresholdCount, + m_chromaSampleCountNearMidPoint, + (referencingExistingAps == true), + m_trainingCovControl, m_filterControl, curTotalDistortion, curTotalRate, + ccAlfFilterIdxEnabled, mapFilterIdxToFilterIdc, ccAlfFilterCount); +#else determineControlIdcValues(cs, compID, m_buf, ctuWidthC, ctuHeightC, picWidthC, picHeightC, m_unfilteredDistortion, m_trainingDistortion, m_lumaSwingGreaterThanThresholdCount, @@ -3882,6 +3875,7 @@ void EncAdaptiveLoopFilter::deriveCcAlfFilter( CodingStructure& cs, ComponentID (referencingExistingAps == true), m_trainingCovControl, m_filterControl, curTotalDistortion, curTotalRate, ccAlfFilterIdxEnabled, mapFilterIdxToFilterIdc, ccAlfFilterCount); +#endif // compute coefficient coding bit cost if (ccAlfFilterCount > 0) @@ -4041,7 +4035,9 @@ void EncAdaptiveLoopFilter::deriveStatsForCcAlfFiltering(const PelUnitBuf &orgYu { for (int xPos = 0; xPos < m_picWidth; xPos += m_maxCUWidth) { +#if !JVET_R0327_ONE_PASS_CCALF if (m_trainingCovControl[ctuRsAddr] == filterIdc) +#endif { const int width = (xPos + m_maxCUWidth > m_picWidth) ? (m_picWidth - xPos) : m_maxCUWidth; const int height = (yPos + m_maxCUHeight > m_picHeight) ? (m_picHeight - yPos) : m_maxCUHeight; @@ -4154,8 +4150,13 @@ void EncAdaptiveLoopFilter::getBlkStatsCcAlf(AlfCovariance &alfCovariance, const for (int i = 0; i < compArea.height; i++) { - int vbDistance = ((i << getComponentScaleX(compID, m_chromaFormat)) % vbCTUHeight) - vbPos; + int vbDistance = ((i << getComponentScaleY(compID, m_chromaFormat)) % vbCTUHeight) - vbPos; +#if JVET_R0233_CCALF_LINE_BUFFER_REDUCTION + const bool skipThisRow = getComponentScaleY(compID, m_chromaFormat) == 0 && (vbDistance == 0 || vbDistance == 1); + for (int j = 0; j < compArea.width && (!skipThisRow); j++) +#else for (int j = 0; j < compArea.width; j++) +#endif { std::memset(ELocal, 0, sizeof(ELocal)); @@ -4360,4 +4361,3 @@ void EncAdaptiveLoopFilter::countChromaSampleValueNearMidPoint(const Pel* chroma chroma += (chromaStride << log2BlockHeight); } } -#endif diff --git a/source/Lib/EncoderLib/EncAdaptiveLoopFilter.h b/source/Lib/EncoderLib/EncAdaptiveLoopFilter.h index 2f10736366dd0dd5b41996e34ef7d130958e9a76..0aa905998a26b7fd914ff40314fd22b8c69118e4 100644 --- a/source/Lib/EncoderLib/EncAdaptiveLoopFilter.h +++ b/source/Lib/EncoderLib/EncAdaptiveLoopFilter.h @@ -203,24 +203,17 @@ struct AlfCovariance double calculateError( const int *clip, const double *coeff ) const { return calculateError(clip, coeff, numCoeff); } double calculateError( const int *clip, const double *coeff, const int numCoeff ) const; double calcErrorForCoeffs( const int *clip, const int *coeff, const int numCoeff, const int bitDepth ) const; -#if JVET_Q0795_CCALF - double calcErrorForCcAlfCoeffs(const int* coeff, const int numCoeff, const int bitDepth) const; -#endif + double calcErrorForCcAlfCoeffs(const int16_t *coeff, const int numCoeff, const int bitDepth) const; void getClipMax(const AlfFilterShape& alfShape, int *clip_max) const; void reduceClipCost(const AlfFilterShape& alfShape, int *clip) const; -#if JVET_Q0795_CCALF int gnsSolveByChol( TE LHS, double* rhs, double *x, int numEq ) const; -#endif private: // Cholesky decomposition int gnsSolveByChol( const int *clip, double *x, int numEq ) const; -#if !JVET_Q0795_CCALF - int gnsSolveByChol( TE LHS, double* rhs, double *x, int numEq ) const; -#endif void gnsBacksubstitution( TE R, double* z, int size, double* A ) const; void gnsTransposeBacksubstitution( TE U, double* rhs, double* x, int order ) const; int gnsCholeskyDec( TE inpMatr, TE outMatr, int numEq ) const; @@ -241,10 +234,8 @@ private: uint8_t* m_ctuEnableFlagTmp[MAX_NUM_COMPONENT]; uint8_t* m_ctuEnableFlagTmp2[MAX_NUM_COMPONENT]; uint8_t* m_ctuAlternativeTmp[MAX_NUM_COMPONENT]; -#if JVET_Q0795_CCALF - AlfCovariance*** m_alfCovarianceCcAlf[2]; // [compIdx-1][shapeIdx][ctbAddr][filterIdx] + AlfCovariance*** m_alfCovarianceCcAlf[2]; // [compIdx-1][shapeIdx][filterIdx][ctbAddr] AlfCovariance** m_alfCovarianceFrameCcAlf[2]; // [compIdx-1][shapeIdx][filterIdx] -#endif //for RDO AlfParam m_alfParamTemp; @@ -269,7 +260,6 @@ private: int m_filterTmp[MAX_NUM_ALF_LUMA_COEFF]; int m_clipTmp[MAX_NUM_ALF_LUMA_COEFF]; -#if JVET_Q0795_CCALF int m_apsIdCcAlfStart[2]; short m_bestFilterCoeffSet[MAX_NUM_CC_ALF_FILTERS][MAX_NUM_CC_ALF_CHROMA_COEFF]; @@ -278,7 +268,9 @@ private: uint8_t* m_trainingCovControl; Pel* m_bufOrigin; PelBuf* m_buf; +#if !JVET_R0327_ONE_PASS_CCALF uint64_t** m_unfilteredDistortion; // for different block size +#endif uint64_t* m_trainingDistortion[MAX_NUM_CC_ALF_FILTERS]; // for current block size uint64_t* m_lumaSwingGreaterThanThresholdCount; uint64_t* m_chromaSampleCountNearMidPoint; @@ -286,7 +278,6 @@ private: uint8_t* m_bestFilterControl; // best saved filter control int m_reuseApsId[2]; bool m_limitCcAlf; -#endif public: EncAdaptiveLoopFilter( int& apsIdStart ); @@ -302,17 +293,15 @@ public: void ALFProcess(CodingStructure& cs, const double *lambdas #if ENABLE_QPA , const double lambdaChromaWeight +#endif +#if JVET_R0110_MIXED_LOSSLESS + , Picture* pcPic, uint32_t numSliceSegments #endif ); -#if JVET_Q0795_CCALF int getNewCcAlfApsId(CodingStructure &cs, int cIdx); -#endif void initCABACEstimator( CABACEncoder* cabacEncoder, CtxCache* ctxCache, Slice* pcSlice, ParameterSetMap<APS>* apsMap ); void create( const EncCfg* encCfg, const int picWidth, const int picHeight, const ChromaFormat chromaFormatIDC, const int maxCUWidth, const int maxCUHeight, const int maxCUDepth, const int inputBitDepth[MAX_NUM_CHANNEL_TYPE], const int internalBitDepth[MAX_NUM_CHANNEL_TYPE] ); void destroy(); -#if !JVET_Q0210_UEK_REMOVAL - static int lengthGolomb( int coeffVal, int k, bool signed_coeff = true ); -#endif void setApsIdStart( int i) { m_apsIdStart = i; } private: @@ -330,14 +319,12 @@ private: void deriveStatsForFiltering( PelUnitBuf& orgYuv, PelUnitBuf& recYuv, CodingStructure& cs ); void getBlkStats(AlfCovariance* alfCovariace, const AlfFilterShape& shape, AlfClassifier** classifier, Pel* org, const int orgStride, Pel* rec, const int recStride, const CompArea& areaDst, const CompArea& area, const ChannelType channel, int vbCTUHeight, int vbPos); void calcCovariance(int ELocal[MAX_NUM_ALF_LUMA_COEFF][MaxAlfNumClippingValues], const Pel *rec, const int stride, const AlfFilterShape& shape, const int transposeIdx, const ChannelType channel, int vbDistance); -#if JVET_Q0795_CCALF void deriveStatsForCcAlfFiltering(const PelUnitBuf &orgYuv, const PelUnitBuf &recYuv, const int compIdx, const int maskStride, const uint8_t filterIdc, CodingStructure &cs); void getBlkStatsCcAlf(AlfCovariance &alfCovariance, const AlfFilterShape &shape, const PelUnitBuf &orgYuv, const PelUnitBuf &recYuv, const UnitArea &areaDst, const UnitArea &area, const ComponentID compID, const int yPos); void calcCovarianceCcAlf(int ELocal[MAX_NUM_CC_ALF_CHROMA_COEFF][1], const Pel* rec, const int stride, const AlfFilterShape& shape, int vbDistance); -#endif void mergeClasses(const AlfFilterShape& alfShape, AlfCovariance* cov, AlfCovariance* covMerged, int clipMerged[MAX_NUM_ALF_CLASSES][MAX_NUM_ALF_CLASSES][MAX_NUM_ALF_LUMA_COEFF], const int numClasses, short filterIndices[MAX_NUM_ALF_CLASSES][MAX_NUM_ALF_CLASSES]); @@ -351,9 +338,7 @@ private: #endif const int numClasses, const int numCoeff, double& distUnfilter ); void roundFiltCoeff( int *filterCoeffQuant, double *filterCoeff, const int numCoeff, const int factor ); -#if JVET_Q0795_CCALF - void roundFiltCoeffCCALF( int *filterCoeffQuant, double *filterCoeff, const int numCoeff, const int factor ); -#endif + void roundFiltCoeffCCALF(int16_t *filterCoeffQuant, double *filterCoeff, const int numCoeff, const int factor); double getDistCoeffForce0( bool* codedVarBins, double errorForce0CoeffTab[MAX_NUM_ALF_CLASSES][2], int* bitsVarBin, int zeroBitsVarBin, const int numFilters); int lengthUvlc( int uiCode ); @@ -378,12 +363,25 @@ private: void setCtuAlternativeChroma( uint8_t* ctuAlts[MAX_NUM_COMPONENT], uint8_t val ); void copyCtuAlternativeChroma( uint8_t* ctuAltsDst[MAX_NUM_COMPONENT], uint8_t* ctuAltsSrc[MAX_NUM_COMPONENT] ); int getMaxNumAlternativesChroma( ); -#if JVET_Q0795_CCALF int getCoeffRateCcAlf(short chromaCoeff[MAX_NUM_CC_ALF_FILTERS][MAX_NUM_CC_ALF_CHROMA_COEFF], bool filterEnabled[MAX_NUM_CC_ALF_FILTERS], uint8_t filterCount, ComponentID compID); void deriveCcAlfFilterCoeff( ComponentID compID, const PelUnitBuf& recYuv, const PelUnitBuf& recYuvExt, short filterCoeff[MAX_NUM_CC_ALF_FILTERS][MAX_NUM_CC_ALF_CHROMA_COEFF], const uint8_t filterIdx ); +#if !JVET_R0327_ONE_PASS_CCALF void computeLog2BlockSizeDistortion(const Pel *org, int orgStride, const Pel *dec, int decStride, int height, int width, uint64_t *distortionBuf, int distortionBufStride, int log2BlockWidth, int log2BlockHeight, uint64_t &totalDistortion); +#endif +#if JVET_R0327_ONE_PASS_CCALF + void determineControlIdcValues(CodingStructure &cs, const ComponentID compID, const PelBuf *buf, const int ctuWidthC, + const int ctuHeightC, const int picWidthC, const int picHeightC, + double **unfilteredDistortion, uint64_t *trainingDistortion[MAX_NUM_CC_ALF_FILTERS], + uint64_t *lumaSwingGreaterThanThresholdCount, + uint64_t *chromaSampleCountNearMidPoint, + bool reuseFilterCoeff, uint8_t *trainingCovControl, uint8_t *filterControl, + uint64_t &curTotalDistortion, double &curTotalRate, + bool filterEnabled[MAX_NUM_CC_ALF_FILTERS], + uint8_t mapFilterIdxToFilterIdc[MAX_NUM_CC_ALF_FILTERS + 1], + uint8_t &ccAlfFilterCount); +#else void determineControlIdcValues(CodingStructure &cs, const ComponentID compID, const PelBuf *buf, const int ctuWidthC, const int ctuHeightC, const int picWidthC, const int picHeightC, uint64_t **unfilteredDistortion, uint64_t *trainingDistortion[MAX_NUM_CC_ALF_FILTERS], @@ -394,11 +392,15 @@ private: bool filterEnabled[MAX_NUM_CC_ALF_FILTERS], uint8_t mapFilterIdxToFilterIdc[MAX_NUM_CC_ALF_FILTERS + 1], uint8_t &ccAlfFilterCount); +#endif void deriveCcAlfFilter( CodingStructure& cs, ComponentID compID, const PelUnitBuf& orgYuv, const PelUnitBuf& tempDecYuvBuf, const PelUnitBuf& dstYuv ); std::vector<int> getAvailableCcAlfApsIds(CodingStructure& cs, ComponentID compID); void xSetupCcAlfAPS( CodingStructure& cs ); void countLumaSwingGreaterThanThreshold(const Pel* luma, int lumaStride, int height, int width, int log2BlockWidth, int log2BlockHeight, uint64_t* lumaSwingGreaterThanThresholdCount, int lumaCountStride); void countChromaSampleValueNearMidPoint(const Pel* chroma, int chromaStride, int height, int width, int log2BlockWidth, int log2BlockHeight, uint64_t* chromaSampleCountNearMidPoint, int chromaSampleCountNearMidPointStride); +#if JVET_R0327_ONE_PASS_CCALF + void getFrameStatsCcalf(ComponentID compIdx, int filterIdc); + void initDistortionCcalf(); #endif }; diff --git a/source/Lib/EncoderLib/EncCfg.h b/source/Lib/EncoderLib/EncCfg.h index d8969e265f84e266bcef581b936d189576da8283..0ec6d88d8c8111eabd34e2f3e27b5c2e8c63c2ac 100644 --- a/source/Lib/EncoderLib/EncCfg.h +++ b/source/Lib/EncoderLib/EncCfg.h @@ -68,12 +68,10 @@ struct GOPEntry double m_QPFactor; int m_tcOffsetDiv2; int m_betaOffsetDiv2; -#if JVET_Q0121_DEBLOCKING_CONTROL_PARAMETERS int m_CbTcOffsetDiv2; int m_CbBetaOffsetDiv2; int m_CrTcOffsetDiv2; int m_CrBetaOffsetDiv2; -#endif int m_temporalId; bool m_refPic; int8_t m_sliceType; @@ -99,12 +97,10 @@ struct GOPEntry , m_QPFactor(0) , m_tcOffsetDiv2(0) , m_betaOffsetDiv2(0) -#if JVET_Q0121_DEBLOCKING_CONTROL_PARAMETERS , m_CbTcOffsetDiv2(0) , m_CbBetaOffsetDiv2(0) , m_CrTcOffsetDiv2(0) , m_CrBetaOffsetDiv2(0) -#endif , m_temporalId(0) , m_refPic(false) , m_sliceType('P') @@ -181,13 +177,27 @@ protected: uint32_t m_maxBitDepthConstraintIdc; uint32_t m_maxChromaFormatConstraintIdc; bool m_bFrameConstraintFlag; + +#if JVET_R0286_GCI_CLEANUP + bool m_singleLayerConstraintFlag; + bool m_allLayersIndependentConstraintFlag; + bool m_noMrlConstraintFlag; + bool m_noIspConstraintFlag; + bool m_noMipConstraintFlag; + bool m_noLfnstConstraintFlag; + bool m_noMmvdConstraintFlag; + bool m_noSmvdConstraintFlag; + bool m_noProfConstraintFlag; + bool m_noPaletteConstraintFlag; + bool m_noActConstraintFlag; + bool m_noLmcsConstraintFlag; +#endif + bool m_bNoQtbttDualTreeIntraConstraintFlag; bool m_noPartitionConstraintsOverrideConstraintFlag; bool m_bNoSaoConstraintFlag; bool m_bNoAlfConstraintFlag; -#if JVET_Q0795_CCALF bool m_noCCAlfConstraintFlag; -#endif bool m_bNoRefWraparoundConstraintFlag; bool m_bNoTemporalMvpConstraintFlag; bool m_bNoSbtmvpConstraintFlag; @@ -202,11 +212,7 @@ protected: bool m_noIbcConstraintFlag; bool m_bNoCiipConstraintFlag; bool m_noFPelMmvdConstraintFlag; -#if !JVET_Q0806 - bool m_bNoTriangleConstraintFlag; -#else bool m_noGeoConstraintFlag; -#endif bool m_bNoLadfConstraintFlag; bool m_noTransformSkipConstraintFlag; bool m_noBDPCMConstraintFlag; @@ -229,16 +235,16 @@ protected: Level::Name m_level; std::vector<uint32_t> m_subProfile; uint8_t m_numSubProfile; +#if !JVET_R0090_VUI bool m_progressiveSourceFlag; bool m_interlacedSourceFlag; +#endif bool m_nonPackedConstraintFlag; -#if JVET_Q0114_CONSTRAINT_FLAGS bool m_nonProjectedConstraintFlag; bool m_noResChangeInClvsConstraintFlag; bool m_oneTilePerPicConstraintFlag; bool m_oneSlicePerPicConstraintFlag; bool m_oneSubpicPerPicConstraintFlag; -#endif bool m_frameOnlyConstraintFlag; bool m_intraConstraintFlag; @@ -266,54 +272,36 @@ protected: int m_aiPad[2]; bool m_AccessUnitDelimiter; ///< add Access Unit Delimiter NAL units -#if JVET_Q0775_PH_IN_SH bool m_enablePictureHeaderInSliceHeader; ///< Enable Picture Header in Slice Header -#endif int m_iMaxRefPicNum; ///< this is used to mimic the sliding mechanism used by the decoder // TODO: We need to have a common sliding mechanism used by both the encoder and decoder int m_maxTempLayer; ///< Max temporal layer unsigned m_CTUSize; -#if JVET_Q0119_CLEANUPS bool m_subPicInfoPresentFlag; -#else - bool m_subPicPresentFlag; -#endif - unsigned m_numSubPics; - uint32_t m_subPicCtuTopLeftX[MAX_NUM_SUB_PICS]; - uint32_t m_subPicCtuTopLeftY[MAX_NUM_SUB_PICS]; - uint32_t m_subPicWidth[MAX_NUM_SUB_PICS]; - uint32_t m_subPicHeight[MAX_NUM_SUB_PICS]; - uint32_t m_subPicTreatedAsPicFlag[MAX_NUM_SUB_PICS]; - uint32_t m_loopFilterAcrossSubpicEnabledFlag[MAX_NUM_SUB_PICS]; -#if JVET_Q0119_CLEANUPS + uint32_t m_numSubPics; + std::vector<uint32_t> m_subPicCtuTopLeftX; + std::vector<uint32_t> m_subPicCtuTopLeftY; + std::vector<uint32_t> m_subPicWidth; + std::vector<uint32_t> m_subPicHeight; + std::vector<bool> m_subPicTreatedAsPicFlag; + std::vector<bool> m_loopFilterAcrossSubpicEnabledFlag; bool m_subPicIdMappingExplicitlySignalledFlag; bool m_subPicIdMappingInSpsFlag; -#else - bool m_subPicIdPresentFlag; - bool m_subPicIdSignallingPresentFlag; -#endif unsigned m_subPicIdLen; - uint32_t m_subPicId[MAX_NUM_SUB_PICS]; + std::vector<uint16_t> m_subPicId; bool m_useSplitConsOverride; unsigned m_uiMinQT[3]; //0: I slice; 1: P/B slice, 2: I slice chroma -#if JVET_Q0330_BLOCK_PARTITION unsigned m_uiMaxBT[3]; //0: I slice; 1: P/B slice, 2: I slice chroma unsigned m_uiMaxTT[3]; //0: I slice; 1: P/B slice, 2: I slice chroma -#endif unsigned m_uiMaxMTTHierarchyDepth; unsigned m_uiMaxMTTHierarchyDepthI; unsigned m_uiMaxMTTHierarchyDepthIChroma; bool m_dualITree; unsigned m_maxCUWidth; unsigned m_maxCUHeight; -#if JVET_Q0468_Q0469_MIN_LUMA_CB_AND_MIN_QT_FIX unsigned m_log2MinCUSize; -#else - unsigned m_maxTotalCUDepth; - unsigned m_log2DiffMaxMinCodingBlockSize; -#endif int m_LMChroma; bool m_horCollocatedChromaFlag; @@ -346,11 +334,7 @@ protected: #endif bool m_ciip; -#if !JVET_Q0806 - bool m_Triangle; -#else bool m_Geo; -#endif bool m_allowDisFracMMVD; bool m_AffineAmvr; bool m_HashME; @@ -374,12 +358,8 @@ protected: unsigned m_wrapAroundOffset; // ADD_NEW_TOOL : (encoder lib) add tool enabling flags and associated parameters here -#if JVET_Q0246_VIRTUAL_BOUNDARY_ENABLE_FLAG bool m_virtualBoundariesEnabledFlag; bool m_virtualBoundariesPresentFlag; -#else - bool m_loopFilterAcrossVirtualBoundariesDisabledFlag; -#endif unsigned m_numVerVirtualBoundaries; unsigned m_numHorVirtualBoundaries; unsigned m_virtualBoundariesPosX[3]; @@ -410,12 +390,10 @@ protected: bool m_loopFilterOffsetInPPS; int m_loopFilterBetaOffsetDiv2; int m_loopFilterTcOffsetDiv2; -#if JVET_Q0121_DEBLOCKING_CONTROL_PARAMETERS int m_loopFilterCbBetaOffsetDiv2; int m_loopFilterCbTcOffsetDiv2; int m_loopFilterCrBetaOffsetDiv2; int m_loopFilterCrTcOffsetDiv2; -#endif #if W0038_DB_OPT int m_deblockingFilterMetric; #else @@ -485,21 +463,11 @@ protected: bool m_useFastDecisionForMerge; bool m_bUseCbfFastMode; bool m_useEarlySkipDetection; -#if !REMOVE_PPS_REXT - bool m_crossComponentPredictionEnabledFlag; -#endif bool m_reconBasedCrossCPredictionEstimate; -#if !JVET_Q0441_SAO_MOD_12_BIT - uint32_t m_log2SaoOffsetScale[MAX_NUM_CHANNEL_TYPE]; -#endif bool m_useTransformSkip; bool m_useTransformSkipFast; bool m_useChromaTS; -#if JVET_Q0089_SLICE_LOSSLESS_CODING_CHROMA_BDPCM bool m_useBDPCM; -#else - int m_useBDPCM; -#endif uint32_t m_log2MaxTransformSkipBlockSize; bool m_transformSkipRotationEnabledFlag; bool m_transformSkipContextEnabledFlag; @@ -520,6 +488,9 @@ protected: bool m_bUseBLambdaForNonKeyLowDelayPictures; bool m_gopBasedTemporalFilterEnabled; bool m_noPicPartitionFlag; ///< no picture partitioning flag (single tile, single slice) +#if JVET_R0110_MIXED_LOSSLESS + std::vector<uint32_t> m_sliceLosslessArray; ///< Slice lossless array +#endif std::vector<uint32_t> m_tileColumnWidth; ///< tile column widths in units of CTUs (last column width will be repeated uniformly to cover any remaining picture width) std::vector<uint32_t> m_tileRowHeight; ///< tile row heights in units of CTUs (last row height will be repeated uniformly to cover any remaining picture height) bool m_rectSliceFlag; ///< indicates if using rectangular or raster-scan slices @@ -534,11 +505,12 @@ protected: //====== Sub-picture and Slices ======== bool m_singleSlicePerSubPicFlag; bool m_entropyCodingSyncEnabledFlag; -#if JVET_Q0151_Q0205_ENTRYPOINTS +#if JVET_R0165_OPTIONAL_ENTRY_POINT + bool m_entryPointPresentFlag; ///< flag for the presence of entry points +#else bool m_entropyCodingSyncEntryPointPresentFlag; ///< flag for the presence of entry points for WPP #endif - HashType m_decodedPictureHashSEIType; bool m_bufferingPeriodSEIEnabled; bool m_pictureTimingSEIEnabled; @@ -552,9 +524,7 @@ protected: bool m_bpDeltasGOPStructure; bool m_decodingUnitInfoSEIEnabled; -#if JVET_P0190_SCALABLE_NESTING_SEI bool m_scalableNestingSEIEnabled; -#endif bool m_erpSEIEnabled; bool m_erpSEICancelFlag; @@ -616,18 +586,10 @@ protected: std::vector<double> m_gcmpSEIFunctionCoeffV; std::vector<bool> m_gcmpSEIFunctionVAffectedByUFlag; bool m_gcmpSEIGuardBandFlag; -#if JVET_Q0343_GCMP_GUARD_BAND_TYPE uint8_t m_gcmpSEIGuardBandType; bool m_gcmpSEIGuardBandBoundaryExteriorFlag; -#else - bool m_gcmpSEIGuardBandBoundaryType; -#endif uint8_t m_gcmpSEIGuardBandSamplesMinus1; -#if JVET_SUBPIC_LEVEL_CFG EncCfgParam::CfgSEISubpictureLevel m_cfgSubpictureLevelInfoSEI; -#else - bool m_subpicureLevelInfoSEIEnabled; -#endif bool m_sampleAspectRatioInfoSEIEnabled; bool m_sariCancelFlag; bool m_sariPersistenceFlag; @@ -675,31 +637,23 @@ protected: bool m_useWeightedPred; //< Use of Weighting Prediction (P_SLICE) bool m_useWeightedBiPred; //< Use of Bi-directional Weighting Prediction (B_SLICE) WeightedPredictionMethod m_weightedPredictionMethod; -#if JVET_Q0297_MER uint32_t m_log2ParallelMergeLevelMinus2; ///< Parallel merge estimation region -#endif uint32_t m_maxNumMergeCand; ///< Maximum number of merge candidates uint32_t m_maxNumAffineMergeCand; ///< Maximum number of affine merge candidates -#if !JVET_Q0806 -#if JVET_Q0798_SPS_NUMBER_MERGE_CANDIDATE uint32_t m_maxNumGeoCand; -#else - uint32_t m_maxNumTriangleCand; -#endif -#else - uint32_t m_maxNumGeoCand; -#endif uint32_t m_maxNumIBCMergeCand; ///< Max number of IBC merge candidates ScalingListMode m_useScalingListId; ///< Using quantization matrix i.e. 0=off, 1=default, 2=file. std::string m_scalingListFileName; ///< quantization matrix file name +#if JVET_R0380_SCALING_MATRIX_DISABLE_YCC_OR_RGB + bool m_disableScalingMatrixForAlternativeColourSpace; + bool m_scalingMatrixDesignatedColourSpace; +#endif bool m_sliceLevelRpl; ///< code reference picture lists in slice headers rather than picture header bool m_sliceLevelDblk; ///< code deblocking filter parameters in slice headers rather than picture header bool m_sliceLevelSao; ///< code SAO parameters in slice headers rather than picture header bool m_sliceLevelAlf; ///< code ALF parameters in slice headers rather than picture header -#if JVET_Q0819_PH_CHANGES bool m_sliceLevelWp; ///< code weighted prediction parameters in slice headers rather than picture header bool m_sliceLevelDeltaQp; ///< code delta in slice headers rather than picture header -#endif bool m_disableScalingMatrixForLfnstBlks; int m_TMVPModeId; bool m_constantSliceHeaderParamsEnabledFlag; @@ -709,11 +663,7 @@ protected: int m_PPSMvdL1ZeroIdc; int m_PPSCollocatedFromL0Idc; uint32_t m_PPSSixMinusMaxNumMergeCandPlus1; -#if !JVET_Q0806 - uint32_t m_PPSMaxNumMergeCandMinusMaxNumTriangleCandPlus1; -#else uint32_t m_PPSMaxNumMergeCandMinusMaxNumGeoCandPlus1; -#endif bool m_DepQuantEnabledFlag; bool m_SignDataHidingEnabledFlag; bool m_RCEnableRateControl; @@ -729,22 +679,19 @@ protected: double m_RCInitialCpbFullness; #endif CostMode m_costMode; ///< The cost function to use, primarily when considering lossless coding. - -#if !JVET_Q0814_DPB - VPS m_cVPS; +#if JVET_R0143_TSRCdisableLL + bool m_TSRCdisableLL; ///< Disable TSRC for lossless #endif -#if JVET_Q0117_PARAMETER_SETS_CLEANUP DCI m_dci; bool m_DCIEnabled; ///< enable Decoding Capability Information (DCI) -#else - DPS m_dps; - bool m_decodingParameterSetEnabled; ///< enable decoding parameter set -#endif bool m_recalculateQPAccordingToLambda; ///< recalculate QP value according to the lambda value bool m_hrdParametersPresentFlag; ///< enable generation of HRD parameters bool m_vuiParametersPresentFlag; ///< enable generation of VUI parameters +#if JVET_Q0394_TIMING_SEI + bool m_samePicTimingInAllOLS; ///< same picture timing SEI message is used in all OLS +#endif bool m_aspectRatioInfoPresentFlag; ///< Signals whether aspect_ratio_idc is present int m_aspectRatioIdc; ///< aspect_ratio_idc int m_sarWidth; ///< horizontal size of the sample aspect ratio @@ -753,6 +700,10 @@ protected: int m_colourPrimaries; ///< Indicates chromaticity coordinates of the source primaries int m_transferCharacteristics; ///< Indicates the opto-electronic transfer characteristics of the source int m_matrixCoefficients; ///< Describes the matrix coefficients used in deriving luma and chroma from RGB primaries +#if JVET_R0090_VUI + bool m_progressiveSourceFlag; ///< Indicates if the content is progressive + bool m_interlacedSourceFlag; ///< Indicates if the content is interlaced +#endif bool m_chromaLocInfoPresentFlag; ///< Signals whether chroma_sample_loc_type_top_field and chroma_sample_loc_type_bottom_field are present int m_chromaSampleLocTypeTopField; ///< Specifies the location of chroma samples for top field int m_chromaSampleLocTypeBottomField; ///< Specifies the location of chroma samples for bottom field @@ -786,10 +737,8 @@ protected: #endif bool m_alf; ///< Adaptive Loop Filter -#if JVET_Q0795_CCALF bool m_ccalf; int m_ccalfQpThreshold; -#endif #if JVET_O0756_CALCULATE_HDRMETRICS double m_whitePointDeltaE[hdrtoolslib::NB_REF_WHITE]; double m_maxSampleValue; @@ -831,6 +780,34 @@ public: void setMaxChromaFormatConstraintIdc(uint32_t u) { m_maxChromaFormatConstraintIdc = u; } bool getFrameConstraintFlag() const { return m_bFrameConstraintFlag; } void setFrameConstraintFlag(bool bVal) { m_bFrameConstraintFlag = bVal; } + +#if JVET_R0286_GCI_CLEANUP + bool getSingleLayerConstraintFlag() const { return m_singleLayerConstraintFlag; } + void setSingleLayerConstraintFlag(bool bVal) { m_singleLayerConstraintFlag = bVal; } + bool getAllLayersIndependentConstraintFlag() const { return m_allLayersIndependentConstraintFlag; } + void setAllLayersIndependentConstraintFlag(bool bVal) { m_allLayersIndependentConstraintFlag = bVal; } + bool getNoMrlConstraintFlag() const { return m_noMrlConstraintFlag; } + void setNoMrlConstraintFlag(bool bVal) { m_noMrlConstraintFlag = bVal; } + bool getNoIspConstraintFlag() const { return m_noIspConstraintFlag; } + void setNoIspConstraintFlag(bool bVal) { m_noIspConstraintFlag = bVal; } + bool getNoMipConstraintFlag() const { return m_noMipConstraintFlag; } + void setNoMipConstraintFlag(bool bVal) { m_noMipConstraintFlag = bVal; } + bool getNoLfnstConstraintFlag() const { return m_noLfnstConstraintFlag; } + void setNoLfnstConstraintFlag(bool bVal) { m_noLfnstConstraintFlag = bVal; } + bool getNoMmvdConstraintFlag() const { return m_noMmvdConstraintFlag; } + void setNoMmvdConstraintFlag(bool bVal) { m_noMmvdConstraintFlag = bVal; } + bool getNoSmvdConstraintFlag() const { return m_noSmvdConstraintFlag; } + void setNoSmvdConstraintFlag(bool bVal) { m_noSmvdConstraintFlag = bVal; } + bool getNoProfConstraintFlag() const { return m_noProfConstraintFlag; } + void setNoProfConstraintFlag(bool bVal) { m_noProfConstraintFlag = bVal; } + bool getNoPaletteConstraintFlag() const { return m_noPaletteConstraintFlag; } + void setNoPaletteConstraintFlag(bool bVal) { m_noPaletteConstraintFlag = bVal; } + bool getNoActConstraintFlag() const { return m_noActConstraintFlag; } + void setNoActConstraintFlag(bool bVal) { m_noActConstraintFlag = bVal; } + bool getNoLmcsConstraintFlag() const { return m_noLmcsConstraintFlag; } + void setNoLmcsConstraintFlag(bool bVal) { m_noLmcsConstraintFlag = bVal; } +#endif + bool getNoQtbttDualTreeIntraConstraintFlag() const { return m_bNoQtbttDualTreeIntraConstraintFlag; } void setNoQtbttDualTreeIntraConstraintFlag(bool bVal) { m_bNoQtbttDualTreeIntraConstraintFlag = bVal; } bool getNoPartitionConstraintsOverrideConstraintFlag() const { return m_noPartitionConstraintsOverrideConstraintFlag; } @@ -839,10 +816,8 @@ public: void setNoSaoConstraintFlag(bool bVal) { m_bNoSaoConstraintFlag = bVal; } bool getNoAlfConstraintFlag() const { return m_bNoAlfConstraintFlag; } void setNoAlfConstraintFlag(bool bVal) { m_bNoAlfConstraintFlag = bVal; } -#if JVET_Q0795_CCALF bool getNoCCAlfConstraintFlag() const { return m_noCCAlfConstraintFlag; } void setNoCCAlfConstraintFlag(bool bVal) { m_noCCAlfConstraintFlag = bVal; } -#endif bool getNoRefWraparoundConstraintFlag() const { return m_bNoRefWraparoundConstraintFlag; } void setNoRefWraparoundConstraintFlag(bool bVal) { m_bNoRefWraparoundConstraintFlag = bVal; } bool getNoTemporalMvpConstraintFlag() const { return m_bNoTemporalMvpConstraintFlag; } @@ -871,13 +846,8 @@ public: void setNoCiipConstraintFlag(bool bVal) { m_bNoCiipConstraintFlag = bVal; } bool getNoFPelMmvdConstraintFlag() const { return m_noFPelMmvdConstraintFlag; } void setNoFPelMmvdConstraintFlag(bool bVal) { m_noFPelMmvdConstraintFlag = bVal; } -#if !JVET_Q0806 - bool getNoTriangleConstraintFlag() const { return m_bNoTriangleConstraintFlag; } - void setNoTriangleConstraintFlag(bool bVal) { m_bNoTriangleConstraintFlag = bVal; } -#else bool getNoGeoConstraintFlag() const { return m_noGeoConstraintFlag; } void setNoGeoConstraintFlag(bool bVal) { m_noGeoConstraintFlag = bVal; } -#endif bool getNoLadfConstraintFlag() const { return m_bNoLadfConstraintFlag; } void setNoLadfConstraintFlag(bool bVal) { m_bNoLadfConstraintFlag = bVal; } bool getNoTransformSkipConstraintFlag() const { return m_noTransformSkipConstraintFlag; } @@ -987,10 +957,8 @@ public: void setCTUSize ( unsigned u ) { m_CTUSize = u; } void setMinQTSizes ( unsigned* minQT) { m_uiMinQT[0] = minQT[0]; m_uiMinQT[1] = minQT[1]; m_uiMinQT[2] = minQT[2]; } -#if JVET_Q0330_BLOCK_PARTITION void setMaxBTSizes ( unsigned* maxBT) { m_uiMaxBT[0] = maxBT[0]; m_uiMaxBT[1] = maxBT[1]; m_uiMaxBT[2] = maxBT[2]; } void setMaxTTSizes ( unsigned* maxTT) { m_uiMaxTT[0] = maxTT[0]; m_uiMaxTT[1] = maxTT[1]; m_uiMaxTT[2] = maxTT[2]; } -#endif void setMaxMTTHierarchyDepth ( unsigned uiMaxMTTHierarchyDepth, unsigned uiMaxMTTHierarchyDepthI, unsigned uiMaxMTTHierarchyDepthIChroma ) { m_uiMaxMTTHierarchyDepth = uiMaxMTTHierarchyDepth; m_uiMaxMTTHierarchyDepthI = uiMaxMTTHierarchyDepthI; m_uiMaxMTTHierarchyDepthIChroma = uiMaxMTTHierarchyDepthIChroma; } unsigned getMaxMTTHierarchyDepth () const { return m_uiMaxMTTHierarchyDepth; } @@ -1001,34 +969,38 @@ public: bool getUseSplitConsOverride () const { return m_useSplitConsOverride; } void setDualITree ( bool b ) { m_dualITree = b; } bool getDualITree () const { return m_dualITree; } -#if JVET_Q0119_CLEANUPS void setSubPicInfoPresentFlag (bool b) { m_subPicInfoPresentFlag = b; } -#else - void setSubPicPresentFlag (bool b) { m_subPicPresentFlag = b; } -#endif - void setNumSubPics (uint32_t u) { m_numSubPics = u; } + void setNumSubPics ( uint32_t u ) { CHECK( u >= MAX_NUM_SUB_PICS, "Maximum number of subpictures exceeded" ); + m_numSubPics = u; + m_subPicCtuTopLeftX.resize(m_numSubPics); + m_subPicCtuTopLeftY.resize(m_numSubPics); + m_subPicWidth.resize(m_numSubPics); + m_subPicHeight.resize(m_numSubPics); + m_subPicTreatedAsPicFlag.resize(m_numSubPics); + m_loopFilterAcrossSubpicEnabledFlag.resize(m_numSubPics); + m_subPicId.resize(m_numSubPics); + } void setSubPicCtuTopLeftX (uint32_t u, int i) { m_subPicCtuTopLeftX[i] = u; } void setSubPicCtuTopLeftY (uint32_t u, int i) { m_subPicCtuTopLeftY[i] = u; } void setSubPicWidth (uint32_t u, int i) { m_subPicWidth[i] = u; } void setSubPicHeight (uint32_t u, int i) { m_subPicHeight[i] = u; } void setSubPicTreatedAsPicFlag (bool b, int i) { m_subPicTreatedAsPicFlag[i] = b; } - void setLoopFilterAcrossSubpicEnabledFlag (uint32_t u, int i) { m_loopFilterAcrossSubpicEnabledFlag[i] = u; } + void setLoopFilterAcrossSubpicEnabledFlag (bool b, int i) { m_loopFilterAcrossSubpicEnabledFlag[i] = b; } + + void setSubPicCtuTopLeftX (const std::vector<uint32_t> &v) { CHECK(v.size()!=m_numSubPics, "number of vector entries must be equal to numSubPics") ;m_subPicCtuTopLeftX = v; } + void setSubPicCtuTopLeftY (const std::vector<uint32_t> &v) { CHECK(v.size()!=m_numSubPics, "number of vector entries must be equal to numSubPics") ;m_subPicCtuTopLeftY = v; } + void setSubPicWidth (const std::vector<uint32_t> &v) { CHECK(v.size()!=m_numSubPics, "number of vector entries must be equal to numSubPics") ;m_subPicWidth = v; } + void setSubPicHeight (const std::vector<uint32_t> &v) { CHECK(v.size()!=m_numSubPics, "number of vector entries must be equal to numSubPics") ;m_subPicHeight = v; } + void setSubPicTreatedAsPicFlag (const std::vector<bool> &v) { CHECK(v.size()!=m_numSubPics, "number of vector entries must be equal to numSubPics") ;m_subPicTreatedAsPicFlag = v; } + void setLoopFilterAcrossSubpicEnabledFlag (const std::vector<bool> &v) { CHECK(v.size()!=m_numSubPics, "number of vector entries must be equal to numSubPics") ;m_loopFilterAcrossSubpicEnabledFlag = v; } -#if JVET_Q0119_CLEANUPS void setSubPicIdMappingExplicitlySignalledFlag (bool b) { m_subPicIdMappingExplicitlySignalledFlag = b; } void setSubPicIdMappingInSpsFlag (bool b) { m_subPicIdMappingInSpsFlag = b; } -#else - void setSubPicIdPresentFlag (bool b) { m_subPicIdPresentFlag = b; } - void setSubPicIdSignallingPresentFlag (bool b) { m_subPicIdSignallingPresentFlag = b; } -#endif void setSubPicIdLen (uint32_t u) { m_subPicIdLen = u; } void setSubPicId (uint32_t b, int i) { m_subPicId[i] = b; } + void setSubPicId (const std::vector<uint16_t> &v) { CHECK(v.size()!=m_numSubPics, "number of vector entries must be equal to numSubPics"); m_subPicId = v; } -#if JVET_Q0119_CLEANUPS bool getSubPicInfoPresentFlag () { return m_subPicInfoPresentFlag; } -#else - bool getSubPicPresentFlag () { return m_subPicPresentFlag; } -#endif uint32_t getNumSubPics () { return m_numSubPics; } uint32_t getSubPicCtuTopLeftX (int i) { return m_subPicCtuTopLeftX[i]; } uint32_t getSubPicCtuTopLeftY (int i) { return m_subPicCtuTopLeftY[i]; } @@ -1036,13 +1008,8 @@ public: uint32_t getSubPicHeight (int i) { return m_subPicHeight[i]; } bool getSubPicTreatedAsPicFlag (int i) { return m_subPicTreatedAsPicFlag[i]; } uint32_t getLoopFilterAcrossSubpicEnabledFlag (int i) { return m_loopFilterAcrossSubpicEnabledFlag[i]; } -#if JVET_Q0119_CLEANUPS bool getSubPicIdMappingExplicitlySignalledFlag () { return m_subPicIdMappingExplicitlySignalledFlag; } bool getSubPicIdMappingInSpsFlag () { return m_subPicIdMappingInSpsFlag; } -#else - bool getSubPicIdPresentFlag () { return m_subPicIdPresentFlag; } - bool getSubPicIdSignallingPresentFlag () { return m_subPicIdSignallingPresentFlag; } -#endif uint32_t getSubPicIdLen () { return m_subPicIdLen; } uint32_t getSubPicId (int i) { return m_subPicId[i]; } void setLFNST ( bool b ) { m_LFNST = b; } @@ -1108,13 +1075,8 @@ public: void setUseCiip ( bool b ) { m_ciip = b; } bool getUseCiip () const { return m_ciip; } -#if !JVET_Q0806 - void setUseTriangle ( bool b ) { m_Triangle = b; } - bool getUseTriangle () const { return m_Triangle; } -#else void setUseGeo ( bool b ) { m_Geo = b; } bool getUseGeo () const { return m_Geo; } -#endif void setAllowDisFracMMVD ( bool b ) { m_allowDisFracMMVD = b; } bool getAllowDisFracMMVD () const { return m_allowDisFracMMVD; } void setUseHashME ( bool b ) { m_HashME = b; } @@ -1158,15 +1120,10 @@ public: unsigned getWrapAroundOffset () const { return m_wrapAroundOffset; } // ADD_NEW_TOOL : (encoder lib) add access functions here -#if JVET_Q0246_VIRTUAL_BOUNDARY_ENABLE_FLAG void setVirtualBoundariesEnabledFlag( bool b ) { m_virtualBoundariesEnabledFlag = b; } bool getVirtualBoundariesEnabledFlag() const { return m_virtualBoundariesEnabledFlag; } void setVirtualBoundariesPresentFlag( bool b ) { m_virtualBoundariesPresentFlag = b; } bool getVirtualBoundariesPresentFlag() const { return m_virtualBoundariesPresentFlag; } -#else - void setLoopFilterAcrossVirtualBoundariesDisabledFlag( bool b ) { m_loopFilterAcrossVirtualBoundariesDisabledFlag = b; } - bool getLoopFilterAcrossVirtualBoundariesDisabledFlag() const { return m_loopFilterAcrossVirtualBoundariesDisabledFlag; } -#endif void setNumVerVirtualBoundaries ( unsigned u ) { m_numVerVirtualBoundaries = u; } unsigned getNumVerVirtualBoundaries () const { return m_numVerVirtualBoundaries; } void setNumHorVirtualBoundaries ( unsigned u ) { m_numHorVirtualBoundaries = u; } @@ -1191,14 +1148,8 @@ public: uint32_t getMaxCUWidth () const { return m_maxCUWidth; } void setMaxCUHeight ( uint32_t u ) { m_maxCUHeight = u; } uint32_t getMaxCUHeight () const { return m_maxCUHeight; } -#if JVET_Q0468_Q0469_MIN_LUMA_CB_AND_MIN_QT_FIX void setLog2MinCodingBlockSize ( int n ) { m_log2MinCUSize = n; } int getLog2MinCodingBlockSize () const { return m_log2MinCUSize;} -#else - void setMaxCodingDepth ( uint32_t u ) { m_maxTotalCUDepth = u; } - uint32_t getMaxCodingDepth () const { return m_maxTotalCUDepth; } - void setLog2DiffMaxMinCodingBlockSize( uint32_t u ) { m_log2DiffMaxMinCodingBlockSize = u; } -#endif void setUseEncDbOpt ( bool n ) { m_encDbOpt = n; } bool getUseEncDbOpt () const { return m_encDbOpt; } @@ -1237,12 +1188,10 @@ public: void setLoopFilterOffsetInPPS ( bool b ) { m_loopFilterOffsetInPPS = b; } void setLoopFilterBetaOffset ( int i ) { m_loopFilterBetaOffsetDiv2 = i; } void setLoopFilterTcOffset ( int i ) { m_loopFilterTcOffsetDiv2 = i; } -#if JVET_Q0121_DEBLOCKING_CONTROL_PARAMETERS void setLoopFilterCbBetaOffset ( int i ) { m_loopFilterCbBetaOffsetDiv2 = i; } void setLoopFilterCbTcOffset ( int i ) { m_loopFilterCbTcOffsetDiv2 = i; } void setLoopFilterCrBetaOffset ( int i ) { m_loopFilterCrBetaOffsetDiv2 = i; } void setLoopFilterCrTcOffset ( int i ) { m_loopFilterCrTcOffsetDiv2 = i; } -#endif #if W0038_DB_OPT void setDeblockingFilterMetric ( int i ) { m_deblockingFilterMetric = i; } #else @@ -1345,22 +1294,18 @@ public: bool getAccessUnitDelimiter() const { return m_AccessUnitDelimiter; } void setAccessUnitDelimiter(bool val){ m_AccessUnitDelimiter = val; } -#if JVET_Q0775_PH_IN_SH bool getEnablePictureHeaderInSliceHeader() const { return m_enablePictureHeaderInSliceHeader; } void setEnablePictureHeaderInSliceHeader(bool val) { m_enablePictureHeaderInSliceHeader = val; } -#endif //==== Loop/Deblock Filter ======== bool getLoopFilterDisable () { return m_bLoopFilterDisable; } bool getLoopFilterOffsetInPPS () { return m_loopFilterOffsetInPPS; } int getLoopFilterBetaOffset () { return m_loopFilterBetaOffsetDiv2; } int getLoopFilterTcOffset () { return m_loopFilterTcOffsetDiv2; } -#if JVET_Q0121_DEBLOCKING_CONTROL_PARAMETERS int getLoopFilterCbBetaOffset () { return m_loopFilterCbBetaOffsetDiv2; } int getLoopFilterCbTcOffset () { return m_loopFilterCbTcOffsetDiv2; } int getLoopFilterCrBetaOffset () { return m_loopFilterCrBetaOffsetDiv2; } int getLoopFilterCrTcOffset () { return m_loopFilterCrTcOffsetDiv2; } -#endif #if W0038_DB_OPT int getDeblockingFilterMetric () { return m_deblockingFilterMetric; } #else @@ -1431,15 +1376,8 @@ public: void setGopBasedTemporalFilterEnabled(bool flag) { m_gopBasedTemporalFilterEnabled = flag; } bool getGopBasedTemporalFilterEnabled() { return m_gopBasedTemporalFilterEnabled; } -#if !REMOVE_PPS_REXT - bool getCrossComponentPredictionEnabledFlag () const { return m_crossComponentPredictionEnabledFlag; } - void setCrossComponentPredictionEnabledFlag (const bool value) { m_crossComponentPredictionEnabledFlag = value; } -#endif bool getUseReconBasedCrossCPredictionEstimate () const { return m_reconBasedCrossCPredictionEstimate; } void setUseReconBasedCrossCPredictionEstimate (const bool value) { m_reconBasedCrossCPredictionEstimate = value; } -#if !JVET_Q0441_SAO_MOD_12_BIT - void setLog2SaoOffsetScale(ChannelType type, uint32_t uiBitShift) { m_log2SaoOffsetScale[type] = uiBitShift; } -#endif bool getUseTransformSkip () { return m_useTransformSkip; } void setUseTransformSkip ( bool b ) { m_useTransformSkip = b; } @@ -1449,13 +1387,8 @@ public: void setTransformSkipContextEnabledFlag (const bool value) { m_transformSkipContextEnabledFlag = value; } bool getUseChromaTS () { return m_useChromaTS; } void setUseChromaTS (bool b) { m_useChromaTS = b; } -#if JVET_Q0089_SLICE_LOSSLESS_CODING_CHROMA_BDPCM bool getUseBDPCM () { return m_useBDPCM; } void setUseBDPCM ( bool b ) { m_useBDPCM = b; } -#else - int getUseBDPCM () { return m_useBDPCM; } - void setUseBDPCM ( int b ) { m_useBDPCM = b; } -#endif bool getUseJointCbCr () { return m_JointCbCrMode; } void setUseJointCbCr (bool b) { m_JointCbCrMode = b; } bool getPersistentRiceAdaptationEnabledFlag () const { return m_persistentRiceAdaptationEnabledFlag; } @@ -1476,7 +1409,10 @@ public: const int* getdQPs () const { return m_aidQP; } uint32_t getDeltaQpRD () const { return m_uiDeltaQpRD; } bool getFastDeltaQp () const { return m_bFastDeltaQP; } - +#if JVET_R0110_MIXED_LOSSLESS + void setSliceLosslessArray(std::vector<uint32_t> sliceLosslessArray) { m_sliceLosslessArray = sliceLosslessArray; } + const std::vector<uint32_t>* getSliceLosslessArray() const { return &m_sliceLosslessArray; } +#endif //====== Tiles and Slices ======== void setNoPicPartitionFlag( bool b ) { m_noPicPartitionFlag = b; } bool getNoPicPartitionFlag() { return m_noPicPartitionFlag; } @@ -1519,7 +1455,9 @@ public: bool getSaoGreedyMergeEnc () { return m_saoGreedyMergeEnc; } void setEntropyCodingSyncEnabledFlag(bool b) { m_entropyCodingSyncEnabledFlag = b; } bool getEntropyCodingSyncEnabledFlag() const { return m_entropyCodingSyncEnabledFlag; } -#if JVET_Q0151_Q0205_ENTRYPOINTS +#if JVET_R0165_OPTIONAL_ENTRY_POINT + void setEntryPointPresentFlag(bool b) { m_entryPointPresentFlag = b; } +#else void setEntropyCodingSyncEntryPointPresentFlag(bool b) { m_entropyCodingSyncEntryPointPresentFlag = b; } #endif void setDecodedPictureHashSEIType(HashType m) { m_decodedPictureHashSEIType = m; } @@ -1546,10 +1484,8 @@ public: bool getBpDeltasGOPStructure() const { return m_bpDeltasGOPStructure; } void setDecodingUnitInfoSEIEnabled(bool b) { m_decodingUnitInfoSEIEnabled = b; } bool getDecodingUnitInfoSEIEnabled() const { return m_decodingUnitInfoSEIEnabled; } -#if JVET_P0190_SCALABLE_NESTING_SEI void setScalableNestingSEIEnabled(bool b) { m_scalableNestingSEIEnabled = b; } bool getScalableNestingSEIEnabled() const { return m_scalableNestingSEIEnabled; } -#endif void setErpSEIEnabled(bool b) { m_erpSEIEnabled = b; } bool getErpSEIEnabled() { return m_erpSEIEnabled; } @@ -1595,7 +1531,7 @@ public: int getOmniViewportSEITiltCentre(int idx) { return m_omniViewportSEITiltCentre[idx]; } void setOmniViewportSEIHorRange(const std::vector<uint32_t>& vi) { m_omniViewportSEIHorRange = vi; } uint32_t getOmniViewportSEIHorRange(int idx) { return m_omniViewportSEIHorRange[idx]; } - void setOmniViewportSEIVerRange(const std::vector<uint32_t>& vi) { m_omniViewportSEIVerRange = vi; } + void setOmniViewportSEIVerRange(const std::vector<uint32_t>& vi) { m_omniViewportSEIVerRange = vi; } uint32_t getOmniViewportSEIVerRange(int idx) { return m_omniViewportSEIVerRange[idx]; } void setRwpSEIEnabled(bool b) { m_rwpSEIEnabled = b; } bool getRwpSEIEnabled() { return m_rwpSEIEnabled; } @@ -1671,24 +1607,14 @@ public: bool getGcmpSEIFunctionVAffectedByUFlag(int idx) const { return m_gcmpSEIFunctionVAffectedByUFlag[idx]; } void setGcmpSEIGuardBandFlag(bool b) { m_gcmpSEIGuardBandFlag = b; } bool getGcmpSEIGuardBandFlag() { return m_gcmpSEIGuardBandFlag; } -#if JVET_Q0343_GCMP_GUARD_BAND_TYPE void setGcmpSEIGuardBandType(uint8_t u) { m_gcmpSEIGuardBandType = u; } uint8_t getGcmpSEIGuardBandType() { return m_gcmpSEIGuardBandType; } void setGcmpSEIGuardBandBoundaryExteriorFlag(bool b) { m_gcmpSEIGuardBandBoundaryExteriorFlag = b; } bool getGcmpSEIGuardBandBoundaryExteriorFlag() { return m_gcmpSEIGuardBandBoundaryExteriorFlag; } -#else - void setGcmpSEIGuardBandBoundaryType(bool b) { m_gcmpSEIGuardBandBoundaryType = b; } - bool getGcmpSEIGuardBandBoundaryType() { return m_gcmpSEIGuardBandBoundaryType; } -#endif void setGcmpSEIGuardBandSamplesMinus1( uint8_t u ) { m_gcmpSEIGuardBandSamplesMinus1 = u; } uint8_t getGcmpSEIGuardBandSamplesMinus1() { return m_gcmpSEIGuardBandSamplesMinus1; } -#if JVET_SUBPIC_LEVEL_CFG const EncCfgParam::CfgSEISubpictureLevel getSubpicureLevelInfoSEICfg() const { return m_cfgSubpictureLevelInfoSEI; } void setSubpicureLevelInfoSEICfg(EncCfgParam::CfgSEISubpictureLevel cfg) { m_cfgSubpictureLevelInfoSEI = cfg; } -#else - bool getSubpicureLevelInfoSEIEnabled() const { return m_subpicureLevelInfoSEIEnabled; } - void setSubpicureLevelInfoSEIEnabled(bool val) { m_subpicureLevelInfoSEIEnabled = val; } -#endif bool getSampleAspectRatioInfoSEIEnabled() const { return m_sampleAspectRatioInfoSEIEnabled; } void setSampleAspectRatioInfoSEIEnabled(const bool val) { m_sampleAspectRatioInfoSEIEnabled = val; } bool getSariCancelFlag() const { return m_sariCancelFlag; } @@ -1773,32 +1699,26 @@ public: void setWPBiPred ( bool b ) { m_useWeightedBiPred = b; } bool getUseWP () { return m_useWeightedPred; } bool getWPBiPred () { return m_useWeightedBiPred; } -#if JVET_Q0297_MER void setLog2ParallelMergeLevelMinus2(uint32_t u) { m_log2ParallelMergeLevelMinus2 = u; } uint32_t getLog2ParallelMergeLevelMinus2() { return m_log2ParallelMergeLevelMinus2; } -#endif void setMaxNumMergeCand ( uint32_t u ) { m_maxNumMergeCand = u; } uint32_t getMaxNumMergeCand () { return m_maxNumMergeCand; } void setMaxNumAffineMergeCand ( uint32_t u ) { m_maxNumAffineMergeCand = u; } uint32_t getMaxNumAffineMergeCand () { return m_maxNumAffineMergeCand; } -#if !JVET_Q0806 -#if JVET_Q0798_SPS_NUMBER_MERGE_CANDIDATE - void setMaxNumGeoCand(uint32_t u) { m_maxNumGeoCand = u; } - uint32_t getMaxNumGeoCand() { return m_maxNumGeoCand; } -#else - void setMaxNumTriangleCand ( uint32_t u ) { m_maxNumTriangleCand = u; } - uint32_t getMaxNumTriangleCand () { return m_maxNumTriangleCand; } -#endif -#else void setMaxNumGeoCand ( uint32_t u ) { m_maxNumGeoCand = u; } uint32_t getMaxNumGeoCand () { return m_maxNumGeoCand; } -#endif void setMaxNumIBCMergeCand ( uint32_t u ) { m_maxNumIBCMergeCand = u; } uint32_t getMaxNumIBCMergeCand () { return m_maxNumIBCMergeCand; } void setUseScalingListId ( ScalingListMode u ) { m_useScalingListId = u; } ScalingListMode getUseScalingListId () { return m_useScalingListId; } void setScalingListFileName ( const std::string &s ) { m_scalingListFileName = s; } const std::string& getScalingListFileName () const { return m_scalingListFileName; } +#if JVET_R0380_SCALING_MATRIX_DISABLE_YCC_OR_RGB + void setDisableScalingMatrixForAlternativeColourSpace(bool b) { m_disableScalingMatrixForAlternativeColourSpace = b; } + bool getDisableScalingMatrixForAlternativeColourSpace() { return m_disableScalingMatrixForAlternativeColourSpace; } + void setScalingMatrixDesignatedColourSpace (bool b) { m_scalingMatrixDesignatedColourSpace = b; } + bool getScalingMatrixDesignatedColourSpace () { return m_scalingMatrixDesignatedColourSpace; } +#endif void setSliceLevelRpl ( bool b ) { m_sliceLevelRpl = b; } bool getSliceLevelRpl () { return m_sliceLevelRpl; } void setSliceLevelDblk ( bool b ) { m_sliceLevelDblk = b; } @@ -1807,39 +1727,14 @@ public: bool getSliceLevelSao () { return m_sliceLevelSao; } void setSliceLevelAlf ( bool b ) { m_sliceLevelAlf = b; } bool getSliceLevelAlf () { return m_sliceLevelAlf; } -#if JVET_Q0819_PH_CHANGES void setSliceLevelWp(bool b) { m_sliceLevelWp = b; } bool getSliceLevelWp() { return m_sliceLevelWp; } void setSliceLevelDeltaQp(bool b) { m_sliceLevelDeltaQp = b; } bool getSliceLevelDeltaQp() { return m_sliceLevelDeltaQp; } -#endif void setDisableScalingMatrixForLfnstBlks(bool u) { m_disableScalingMatrixForLfnstBlks = u; } bool getDisableScalingMatrixForLfnstBlks() const { return m_disableScalingMatrixForLfnstBlks; } void setTMVPModeId ( int u ) { m_TMVPModeId = u; } int getTMVPModeId () { return m_TMVPModeId; } -#if !JVET_Q0482_REMOVE_CONSTANT_PARAMS - void setConstantSliceHeaderParamsEnabledFlag ( bool u ) { m_constantSliceHeaderParamsEnabledFlag = u; } - bool getConstantSliceHeaderParamsEnabledFlag () { return m_constantSliceHeaderParamsEnabledFlag; } - void setPPSDepQuantEnabledIdc ( int u ) { m_PPSDepQuantEnabledIdc = u; } - int getPPSDepQuantEnabledIdc () { return m_PPSDepQuantEnabledIdc; } - void setPPSRefPicListSPSIdc0 ( int u ) { m_PPSRefPicListSPSIdc0 = u; } - int getPPSRefPicListSPSIdc0 () { return m_PPSRefPicListSPSIdc0; } - void setPPSRefPicListSPSIdc1 ( int u ) { m_PPSRefPicListSPSIdc1 = u; } - int getPPSRefPicListSPSIdc1 () { return m_PPSRefPicListSPSIdc1; } - void setPPSMvdL1ZeroIdc ( int u ) { m_PPSMvdL1ZeroIdc = u; } - int getPPSMvdL1ZeroIdc () { return m_PPSMvdL1ZeroIdc; } - void setPPSCollocatedFromL0Idc ( int u ) { m_PPSCollocatedFromL0Idc = u; } - int getPPSCollocatedFromL0Idc () { return m_PPSCollocatedFromL0Idc; } - void setPPSSixMinusMaxNumMergeCandPlus1 ( uint32_t u ) { m_PPSSixMinusMaxNumMergeCandPlus1 = u; } - uint32_t getPPSSixMinusMaxNumMergeCandPlus1 () { return m_PPSSixMinusMaxNumMergeCandPlus1; } -#if !JVET_Q0806 - void setPPSMaxNumMergeCandMinusMaxNumTriangleCandPlus1 ( uint32_t u ) { m_PPSMaxNumMergeCandMinusMaxNumTriangleCandPlus1 = u; } - uint32_t getPPSMaxNumMergeCandMinusMaxNumTriangleCandPlus1 () { return m_PPSMaxNumMergeCandMinusMaxNumTriangleCandPlus1; } -#else - void setPPSMaxNumMergeCandMinusMaxNumGeoCandPlus1 ( uint32_t u ) { m_PPSMaxNumMergeCandMinusMaxNumGeoCandPlus1 = u; } - uint32_t getPPSMaxNumMergeCandMinusMaxNumGeoCandPlus1 () { return m_PPSMaxNumMergeCandMinusMaxNumGeoCandPlus1; } -#endif -#endif WeightedPredictionMethod getWeightedPredictionMethod() const { return m_weightedPredictionMethod; } void setWeightedPredictionMethod( WeightedPredictionMethod m ) { m_weightedPredictionMethod = m; } void setDepQuantEnabledFlag( bool b ) { m_DepQuantEnabledFlag = b; } @@ -1870,20 +1765,13 @@ public: #endif CostMode getCostMode( ) const { return m_costMode; } void setCostMode(CostMode m ) { m_costMode = m; } - -#if !JVET_Q0814_DPB - void setVPS(VPS *p) { m_cVPS = *p; } - VPS * getVPS() { return &m_cVPS; } +#if JVET_R0143_TSRCdisableLL + bool getTSRCdisableLL () { return m_TSRCdisableLL; } + void setTSRCdisableLL ( bool b ) { m_TSRCdisableLL = b; } #endif - -#if JVET_Q0117_PARAMETER_SETS_CLEANUP void setDCI(DCI *p) { m_dci = *p; } DCI* getDCI() { return &m_dci; } -#else - void setDPS(DPS *p) { m_dps = *p; } - DPS* getDPS() { return &m_dps; } -#endif void setUseRecalculateQPAccordingToLambda (bool b) { m_recalculateQPAccordingToLambda = b; } bool getUseRecalculateQPAccordingToLambda () { return m_recalculateQPAccordingToLambda; } @@ -1894,17 +1782,16 @@ public: bool getHarmonizeGopFirstFieldCoupleEnabled( ) const { return m_bHarmonizeGopFirstFieldCoupleEnabled; } -#if JVET_Q0117_PARAMETER_SETS_CLEANUP bool getDCIEnabled() { return m_DCIEnabled; } void setDCIEnabled(bool i) { m_DCIEnabled = i; } -#else - bool getDecodingParameterSetEnabled() { return m_decodingParameterSetEnabled; } - void setDecodingParameterSetEnabled(bool i) { m_decodingParameterSetEnabled = i; } -#endif bool getHrdParametersPresentFlag() { return m_hrdParametersPresentFlag; } void setHrdParametersPresentFlag(bool i) { m_hrdParametersPresentFlag = i; } bool getVuiParametersPresentFlag() { return m_vuiParametersPresentFlag; } void setVuiParametersPresentFlag(bool i) { m_vuiParametersPresentFlag = i; } +#if JVET_Q0394_TIMING_SEI + bool getSamePicTimingInAllOLS() const { return m_samePicTimingInAllOLS; } + void setSamePicTimingInAllOLS(bool b) { m_samePicTimingInAllOLS = b; } +#endif bool getAspectRatioInfoPresentFlag() { return m_aspectRatioInfoPresentFlag; } void setAspectRatioInfoPresentFlag(bool i) { m_aspectRatioInfoPresentFlag = i; } int getAspectRatioIdc() { return m_aspectRatioIdc; } @@ -1945,22 +1832,20 @@ public: bool getNonPackedConstraintFlag() const { return m_nonPackedConstraintFlag; } void setNonPackedConstraintFlag(bool b) { m_nonPackedConstraintFlag = b; } -#if JVET_Q0114_CONSTRAINT_FLAGS bool getNonProjectedConstraintFlag() const { return m_nonProjectedConstraintFlag; } void setNonProjectedConstraintFlag(bool b) { m_nonProjectedConstraintFlag = b; } - + bool getNoResChangeInClvsConstraintFlag() const { return m_noResChangeInClvsConstraintFlag; } void setNoResChangeInClvsConstraintFlag(bool b) { m_noResChangeInClvsConstraintFlag = b; } - + bool getOneTilePerPicConstraintFlag() const { return m_oneTilePerPicConstraintFlag; } void setOneTilePerPicConstraintFlag(bool b) { m_oneTilePerPicConstraintFlag = b; } - + bool getOneSlicePerPicConstraintFlag() const { return m_oneSlicePerPicConstraintFlag; } void setOneSlicePerPicConstraintFlag(bool b) { m_oneSlicePerPicConstraintFlag = b; } - + bool getOneSubpicPerPicConstraintFlag() const { return m_oneSubpicPerPicConstraintFlag; } void setOneSubpicPerPicConstraintFlag(bool b) { m_oneSubpicPerPicConstraintFlag = b; } -#endif bool getFrameOnlyConstraintFlag() const { return m_frameOnlyConstraintFlag; } void setFrameOnlyConstraintFlag(bool b) { m_frameOnlyConstraintFlag = b; } @@ -2008,12 +1893,10 @@ public: #endif void setUseALF( bool b ) { m_alf = b; } bool getUseALF() const { return m_alf; } -#if JVET_Q0795_CCALF void setUseCCALF( bool b ) { m_ccalf = b; } bool getUseCCALF() const { return m_ccalf; } void setCCALFQpThreshold( int b ) { m_ccalfQpThreshold = b; } int getCCALFQpThreshold() const { return m_ccalfQpThreshold; } -#endif #if JVET_O0756_CALCULATE_HDRMETRICS void setWhitePointDeltaE( uint32_t index, double value ) { m_whitePointDeltaE[ index ] = value; } double getWhitePointDeltaE( uint32_t index ) const { return m_whitePointDeltaE[ index ]; } diff --git a/source/Lib/EncoderLib/EncCfgParam.h b/source/Lib/EncoderLib/EncCfgParam.h index fb1671afd23d0dbaa8a3992fd0f5692c6ba9c9b4..13e5f839e0312c0d8ecbcab9a233aa56531163a8 100644 --- a/source/Lib/EncoderLib/EncCfgParam.h +++ b/source/Lib/EncoderLib/EncCfgParam.h @@ -44,7 +44,6 @@ namespace EncCfgParam { -#if JVET_SUBPIC_LEVEL_CFG class CfgSEISubpictureLevel { public: @@ -63,7 +62,6 @@ public: int m_numSubpictures; std::vector<int> m_fractions; }; -#endif } diff --git a/source/Lib/EncoderLib/EncCu.cpp b/source/Lib/EncoderLib/EncCu.cpp index a402f18d9d26864ffcd945c0b959d3184540ad00..6c0bc92b03ca434977420da575e9644851da8022 100644 --- a/source/Lib/EncoderLib/EncCu.cpp +++ b/source/Lib/EncoderLib/EncCu.cpp @@ -59,20 +59,6 @@ //! \{ // ==================================================================================================================== -#if !JVET_Q0806 -EncCu::EncCu() : m_triangleModeTest -{ - TriangleMotionInfo( 0, 1, 0 ), TriangleMotionInfo( 1, 0, 1 ), TriangleMotionInfo( 1, 0, 2 ), TriangleMotionInfo( 0, 0, 1 ), TriangleMotionInfo( 0, 2, 0 ), - TriangleMotionInfo( 1, 0, 3 ), TriangleMotionInfo( 1, 0, 4 ), TriangleMotionInfo( 1, 1, 0 ), TriangleMotionInfo( 0, 3, 0 ), TriangleMotionInfo( 0, 4, 0 ), - TriangleMotionInfo( 0, 0, 2 ), TriangleMotionInfo( 0, 1, 2 ), TriangleMotionInfo( 1, 1, 2 ), TriangleMotionInfo( 0, 0, 4 ), TriangleMotionInfo( 0, 0, 3 ), - TriangleMotionInfo( 0, 1, 3 ), TriangleMotionInfo( 0, 1, 4 ), TriangleMotionInfo( 1, 1, 4 ), TriangleMotionInfo( 1, 1, 3 ), TriangleMotionInfo( 1, 2, 1 ), - TriangleMotionInfo( 1, 2, 0 ), TriangleMotionInfo( 0, 2, 1 ), TriangleMotionInfo( 0, 4, 3 ), TriangleMotionInfo( 1, 3, 0 ), TriangleMotionInfo( 1, 3, 2 ), - TriangleMotionInfo( 1, 3, 4 ), TriangleMotionInfo( 1, 4, 0 ), TriangleMotionInfo( 1, 3, 1 ), TriangleMotionInfo( 1, 2, 3 ), TriangleMotionInfo( 1, 4, 1 ), - TriangleMotionInfo( 0, 4, 1 ), TriangleMotionInfo( 0, 2, 3 ), TriangleMotionInfo( 1, 4, 2 ), TriangleMotionInfo( 0, 3, 2 ), TriangleMotionInfo( 1, 4, 3 ), - TriangleMotionInfo( 0, 3, 1 ), TriangleMotionInfo( 0, 2, 4 ), TriangleMotionInfo( 1, 2, 4 ), TriangleMotionInfo( 0, 4, 2 ), TriangleMotionInfo( 0, 3, 4 ), -} -{} -#else EncCu::EncCu() : m_GeoModeTest { GeoMotionInfo(0, 1), GeoMotionInfo(1, 0),GeoMotionInfo(0, 2), GeoMotionInfo(1, 2), GeoMotionInfo(2, 0), @@ -83,7 +69,6 @@ EncCu::EncCu() : m_GeoModeTest GeoMotionInfo(5, 0), GeoMotionInfo(5, 1),GeoMotionInfo(5, 2), GeoMotionInfo(5, 3), GeoMotionInfo(5, 4) } {} -#endif void EncCu::create( EncCfg* encCfg ) { @@ -151,53 +136,10 @@ void EncCu::create( EncCfg* encCfg ) m_acRealMergeBuffer[ui].create(chromaFormat, Area(0, 0, uiMaxWidth, uiMaxHeight)); m_acMergeTmpBuffer[ui].create(chromaFormat, Area(0, 0, uiMaxWidth, uiMaxHeight)); } -#if !JVET_Q0806 -#if JVET_Q0798_SPS_NUMBER_MERGE_CANDIDATE - const unsigned maxNumTriangleCand = encCfg->getMaxNumGeoCand(); -#else - const unsigned maxNumTriangleCand = encCfg->getMaxNumTriangleCand(); -#endif - for (unsigned i = 0; i < maxNumTriangleCand; i++) - { - for (unsigned j = 0; j < maxNumTriangleCand; j++) - { - if (i == j) - continue; - uint8_t idxBits0 = i + (i == maxNumTriangleCand - 1 ? 0 : 1); - uint8_t candIdx1Enc = j - (j > i ? 1 : 0); - uint8_t idxBits1 = candIdx1Enc + (candIdx1Enc == maxNumTriangleCand - 2 ? 0 : 1); - m_triangleIdxBins[1][i][j] = m_triangleIdxBins[0][i][j] = 1 + idxBits0 + idxBits1; - } - } - if (maxNumTriangleCand != 5) - { - // update the table - int index = 0; - for (unsigned i = 0; i < maxNumTriangleCand; i++) - { - for (unsigned j = 0; j < maxNumTriangleCand; j++) - { - if (i == j) - continue; - for (unsigned dir = 0; dir < 2; dir++, index++) - { - m_triangleModeTest[index].m_splitDir = dir; - m_triangleModeTest[index].m_candIdx0 = i; - m_triangleModeTest[index].m_candIdx1 = j; - } - } - } - } - for( unsigned ui = 0; ui < TRIANGLE_MAX_NUM_CANDS; ui++ ) - { - m_acTriangleWeightedBuffer[ui].create( chromaFormat, Area( 0, 0, uiMaxWidth, uiMaxHeight ) ); - } -#else for( unsigned ui = 0; ui < GEO_MAX_TRY_WEIGHTED_SAD; ui++ ) { m_acGeoWeightedBuffer[ui].create( chromaFormat, Area( 0, 0, uiMaxWidth, uiMaxHeight ) ); } -#endif m_CtxBuffer.resize( maxDepth ); m_CurrCtx = 0; @@ -261,17 +203,10 @@ void EncCu::destroy() m_acRealMergeBuffer[ui].destroy(); m_acMergeTmpBuffer[ui].destroy(); } -#if !JVET_Q0806 - for( unsigned ui = 0; ui < TRIANGLE_MAX_NUM_CANDS; ui++ ) - { - m_acTriangleWeightedBuffer[ui].destroy(); - } -#else for (unsigned ui = 0; ui < GEO_MAX_TRY_WEIGHTED_SAD; ui++) { m_acGeoWeightedBuffer[ui].destroy(); } -#endif } @@ -301,10 +236,8 @@ void EncCu::init( EncLib* pcEncLib, const SPS& sps PARL_PARAM( const int tId ) ) m_dataId = tId; #endif m_pcLoopFilter = pcEncLib->getLoopFilter(); -#if JVET_Q0806 m_GeoCostList.init(GEO_NUM_PARTITION_MODE, m_pcEncCfg->getMaxNumGeoCand()); m_AFFBestSATDCost = MAX_DOUBLE; -#endif DecCu::init( m_pcTrQuant, m_pcIntraSearch, m_pcInterSearch ); @@ -325,12 +258,8 @@ void EncCu::compressCtu( CodingStructure& cs, const UnitArea& area, const unsign m_modeCtrl->initCTUEncoding( *cs.slice ); cs.treeType = TREE_D; -#if JVET_Q0504_PLT_NON444 cs.slice->m_mapPltCost[0].clear(); cs.slice->m_mapPltCost[1].clear(); -#else - cs.slice->m_mapPltCost.clear(); -#endif #if ENABLE_SPLIT_PARALLELISM if( m_pcEncCfg->getNumSplitThreads() > 1 ) { @@ -404,16 +333,12 @@ void EncCu::compressCtu( CodingStructure& cs, const UnitArea& area, const unsign tempCS->prevQP[CH_L] = bestCS->prevQP[CH_L] = prevQP[CH_L]; xCompressCU(tempCS, bestCS, partitioner); -#if JVET_Q0504_PLT_NON444 cs.slice->m_mapPltCost[0].clear(); cs.slice->m_mapPltCost[1].clear(); -#else - cs.slice->m_mapPltCost.clear(); -#endif // all signals were already copied during compression if the CTU was split - at this point only the structures are copied to the top level CS const bool copyUnsplitCTUSignals = bestCS->cus.size() == 1; cs.useSubStructure(*bestCS, partitioner.chType, CS::getArea(*bestCS, area, partitioner.chType), copyUnsplitCTUSignals, - false, false, copyUnsplitCTUSignals); + false, false, copyUnsplitCTUSignals, true); if (CS::isDualITree (cs) && isChromaEnabled (cs.pcv->chrFormat)) { @@ -431,7 +356,7 @@ void EncCu::compressCtu( CodingStructure& cs, const UnitArea& area, const unsign const bool copyUnsplitCTUSignals = bestCS->cus.size() == 1; cs.useSubStructure(*bestCS, partitioner.chType, CS::getArea(*bestCS, area, partitioner.chType), - copyUnsplitCTUSignals, false, false, copyUnsplitCTUSignals); + copyUnsplitCTUSignals, false, false, copyUnsplitCTUSignals, true); } if (m_pcEncCfg->getUseRateCtrl()) @@ -624,7 +549,6 @@ void EncCu::xCompressCU( CodingStructure*& tempCS, CodingStructure*& bestCS, Par bool jointPLT = false; if (partitioner.isSepTree( *tempCS )) { -#if JVET_Q0504_PLT_NON444 if( !CS::isDualITree(*tempCS) && partitioner.treeType != TREE_D ) { compBegin = COMPONENT_Y; @@ -633,7 +557,6 @@ void EncCu::xCompressCU( CodingStructure*& tempCS, CodingStructure*& bestCS, Par } else { -#endif if (isLuma(partitioner.chType)) { compBegin = COMPONENT_Y; @@ -644,23 +567,17 @@ void EncCu::xCompressCU( CodingStructure*& tempCS, CodingStructure*& bestCS, Par compBegin = COMPONENT_Cb; numComp = 2; } -#if JVET_Q0504_PLT_NON444 } -#endif } else { compBegin = COMPONENT_Y; -#if JVET_Q0504_PLT_NON444 numComp = (tempCS->area.chromaFormat != CHROMA_400) ? 3 : 1; -#else - numComp = 3; -#endif jointPLT = true; } SplitSeries splitmode = -1; uint8_t bestLastPLTSize[MAX_NUM_CHANNEL_TYPE]; - Pel bestLastPLT[MAX_NUM_COMPONENT][MAXPLTPREDSIZE]; // store LastPLT for + Pel bestLastPLT[MAX_NUM_COMPONENT][MAXPLTPREDSIZE]; // store LastPLT for uint8_t curLastPLTSize[MAX_NUM_CHANNEL_TYPE]; Pel curLastPLT[MAX_NUM_COMPONENT][MAXPLTPREDSIZE]; // store LastPLT if no partition for (int i = compBegin; i < (compBegin + numComp); i++) @@ -710,19 +627,11 @@ void EncCu::xCompressCU( CodingStructure*& tempCS, CodingStructure*& bestCS, Par { // TODO M0133 : double check encoder decisions with respect to chroma QG detection and actual encode int lgMinCuSize = sps.getLog2MinCodingBlockSize() + -#if JVET_Q0468_Q0469_MIN_LUMA_CB_AND_MIN_QT_FIX std::max<int>(0, floorLog2(sps.getCTUSize()) - sps.getLog2MinCodingBlockSize() - int(slice.getCuChromaQpOffsetSubdiv() / 2)); -#else - std::max<int>( 0, sps.getLog2DiffMaxMinCodingBlockSize() - int( slice.getCuChromaQpOffsetSubdiv()/2 ) ); -#endif -#if JVET_Q0267_RESET_CHROMA_QP_OFFSET - if( partitioner.currQgChromaEnable() ) + if( partitioner.currQgChromaEnable() ) { m_cuChromaQpOffsetIdxPlus1 = ( ( uiLPelX >> lgMinCuSize ) + ( uiTPelY >> lgMinCuSize ) ) % ( pps.getChromaQpOffsetListLen() + 1 ); } -#else - m_cuChromaQpOffsetIdxPlus1 = ( ( uiLPelX >> lgMinCuSize ) + ( uiTPelY >> lgMinCuSize ) ) % ( pps.getChromaQpOffsetListLen() + 1 ); -#endif } if( !m_modeCtrl->anyMode() ) @@ -856,29 +765,24 @@ void EncCu::xCompressCU( CodingStructure*& tempCS, CodingStructure*& bestCS, Par if (cu) cu->mmvdSkip = cu->skip == false ? false : cu->mmvdSkip; } -#if !JVET_Q0806 - else if( currTestMode.type == ETM_MERGE_TRIANGLE ) - { - xCheckRDCostMergeTriangle2Nx2N( tempCS, bestCS, partitioner, currTestMode ); - } -#else else if( currTestMode.type == ETM_MERGE_GEO ) { xCheckRDCostMergeGeo2Nx2N( tempCS, bestCS, partitioner, currTestMode ); } -#endif else if( currTestMode.type == ETM_INTRA ) { if (slice.getSPS()->getUseColorTrans() && !CS::isDualITree(*tempCS)) { bool skipSecColorSpace = false; skipSecColorSpace = xCheckRDCostIntra(tempCS, bestCS, partitioner, currTestMode, (m_pcEncCfg->getRGBFormatFlag() ? true : false)); -#if JVET_Q0820_ACT +#if JVET_R0110_MIXED_LOSSLESS + if ((m_pcEncCfg->getCostMode() == COST_LOSSLESS_CODING && slice.isLossless()) && !m_pcEncCfg->getRGBFormatFlag()) +#else if ((m_pcEncCfg->getCostMode() == COST_LOSSLESS_CODING) && !m_pcEncCfg->getRGBFormatFlag()) +#endif { skipSecColorSpace = true; } -#endif if (!skipSecColorSpace && !tempCS->firstColorSpaceTestOnly) { xCheckRDCostIntra(tempCS, bestCS, partitioner, currTestMode, (m_pcEncCfg->getRGBFormatFlag() ? false : true)); @@ -1276,7 +1180,7 @@ void EncCu::copyState( EncCu* other, Partitioner& partitioner, const UnitArea& c bool keepResi = KEEP_PRED_AND_RESI_SIGNALS; bool keepPred = true; - dst->useSubStructure( *src, partitioner.chType, currArea, keepPred, true, keepResi, keepResi ); + dst->useSubStructure( *src, partitioner.chType, currArea, keepPred, true, keepResi, keepResi, true ); dst->cost = src->cost; dst->dist = src->dist; @@ -1431,7 +1335,7 @@ void EncCu::xCheckModeSplit(CodingStructure *&tempCS, CodingStructure *&bestCS, } bool keepResi = KEEP_PRED_AND_RESI_SIGNALS; - tempCS->useSubStructure( *bestSubCS, partitioner.chType, CS::getArea( *tempCS, subCUArea, partitioner.chType ), KEEP_PRED_AND_RESI_SIGNALS, true, keepResi, keepResi ); + tempCS->useSubStructure( *bestSubCS, partitioner.chType, CS::getArea( *tempCS, subCUArea, partitioner.chType ), KEEP_PRED_AND_RESI_SIGNALS, true, keepResi, keepResi, true ); if( partitioner.currQgEnable() ) { @@ -1545,12 +1449,10 @@ void EncCu::xCheckModeSplit(CodingStructure *&tempCS, CodingStructure *&bestCS, assert( tempCS->treeType == TREE_L ); uint32_t numCuPuTu[6]; tempCS->picture->cs->getNumCuPuTuOffset( numCuPuTu ); - tempCS->picture->cs->useSubStructure( *tempCS, partitioner.chType, CS::getArea( *tempCS, partitioner.currArea(), partitioner.chType ), false, true, false, false ); + tempCS->picture->cs->useSubStructure( *tempCS, partitioner.chType, CS::getArea( *tempCS, partitioner.currArea(), partitioner.chType ), false, true, false, false, false ); -#if JVET_Q0438_MONOCHROME_BUGFIXES if (isChromaEnabled(tempCS->pcv->chrFormat)) { -#endif partitioner.chType = CHANNEL_TYPE_CHROMA; tempCS->treeType = partitioner.treeType = TREE_C; @@ -1569,21 +1471,16 @@ void EncCu::xCheckModeSplit(CodingStructure *&tempCS, CodingStructure *&bestCS, bool keepResi = KEEP_PRED_AND_RESI_SIGNALS; //bestCSChroma->treeType = tempCSChroma->treeType = TREE_C; CHECK( bestCSChroma->treeType != TREE_C || tempCSChroma->treeType != TREE_C, "wrong treeType for chroma CS" ); - tempCS->useSubStructure( *bestCSChroma, partitioner.chType, CS::getArea( *bestCSChroma, partitioner.currArea(), partitioner.chType ), KEEP_PRED_AND_RESI_SIGNALS, true, keepResi, true ); + tempCS->useSubStructure( *bestCSChroma, partitioner.chType, CS::getArea( *bestCSChroma, partitioner.currArea(), partitioner.chType ), KEEP_PRED_AND_RESI_SIGNALS, true, keepResi, true, true ); //release tmp resource tempCSChroma->releaseIntermediateData(); bestCSChroma->releaseIntermediateData(); //tempCS->picture->cs->releaseIntermediateData(); -#if JVET_Q0438_MONOCHROME_BUGFIXES m_CurrCtx--; } -#endif tempCS->picture->cs->clearCuPuTuIdxMap( partitioner.currArea(), numCuPuTu[0], numCuPuTu[1], numCuPuTu[2], numCuPuTu + 3 ); -#if !JVET_Q0438_MONOCHROME_BUGFIXES - m_CurrCtx--; -#endif //recover luma tree status partitioner.chType = CHANNEL_TYPE_LUMA; @@ -1880,15 +1777,6 @@ bool EncCu::xCheckRDCostIntra(CodingStructure *&tempCS, CodingStructure *&bestCS m_CABACEstimator->pred_mode ( cu ); m_CABACEstimator->adaptive_color_transform(cu); m_CABACEstimator->cu_pred_data ( cu ); -#if !JVET_Q0110_Q0785_CHROMA_BDPCM_420 - m_CABACEstimator->bdpcm_mode ( cu, ComponentID(partitioner.chType) ); -#if JVET_Q0438_MONOCHROME_BUGFIXES - if (!CS::isDualITree(*cu.cs) && isLuma(partitioner.chType) && isChromaEnabled(cu.chromaFormat)) -#else - if (!CS::isDualITree(*cu.cs) && isLuma(partitioner.chType)) -#endif - m_CABACEstimator->bdpcm_mode(cu, ComponentID(CHANNEL_TYPE_CHROMA)); -#endif // Encode Coefficients CUCtx cuCtx; @@ -1904,34 +1792,26 @@ bool EncCu::xCheckRDCostIntra(CodingStructure *&tempCS, CodingStructure *&bestCS xEncodeDontSplit( *tempCS, partitioner ); xCheckDQP( *tempCS, partitioner ); -#if JVET_Q0267_RESET_CHROMA_QP_OFFSET xCheckChromaQPOffset( *tempCS, partitioner ); -#endif // Check if low frequency non-separable transform (LFNST) is too expensive if( lfnstIdx && !cuCtx.lfnstLastScanPos && !cu.ispMode ) { -#if JVET_Q0438_MONOCHROME_BUGFIXES bool cbfAtZeroDepth = cu.isSepTree() ? cu.rootCbf : (tempCS->area.chromaFormat != CHROMA_400 && std::min( cu.firstTU->blocks[ 1 ].width, cu.firstTU->blocks[ 1 ].height ) < 4) ? TU::getCbfAtDepth( *cu.firstTU, COMPONENT_Y, 0 ) : cu.rootCbf; -#else - bool cbfAtZeroDepth = cu.isSepTree() ? cu.rootCbf : std::min( cu.firstTU->blocks[ 1 ].width, cu.firstTU->blocks[ 1 ].height ) < 4 ? TU::getCbfAtDepth( *cu.firstTU, COMPONENT_Y, 0 ) : cu.rootCbf; -#endif if( cbfAtZeroDepth ) { tempCS->cost = MAX_DOUBLE; } } -#if JVET_Q0516_MTS_SIGNALLING_DC_ONLY_COND if (isLuma(partitioner.chType) && cu.firstTU->mtsIdx[COMPONENT_Y] > MTS_SKIP) { CHECK(!cuCtx.mtsLastScanPos, "MTS is disallowed to only contain DC coefficient"); } -#endif if( mtsFlag == 0 && lfnstIdx == 0 ) { @@ -2060,13 +1940,17 @@ bool EncCu::xCheckRDCostIntra(CodingStructure *&tempCS, CodingStructure *&bestCS void EncCu::xCheckPLT(CodingStructure *&tempCS, CodingStructure *&bestCS, Partitioner &partitioner, const EncTestMode& encTestMode) { -#if JVET_Q0629_REMOVAL_PLT_4X4 +#if JVET_R0334_PLT_CLEANUP + if (((partitioner.currArea().lumaSize().width * partitioner.currArea().lumaSize().height <= 16) && (isLuma(partitioner.chType)) ) + || ((partitioner.currArea().chromaSize().width * partitioner.currArea().chromaSize().height <= 16) && (!isLuma(partitioner.chType)) && partitioner.isSepTree(*tempCS) ) + || (partitioner.isLocalSepTree(*tempCS) && (!isLuma(partitioner.chType)) ) ) +#else if (((partitioner.currArea().lumaSize().width * partitioner.currArea().lumaSize().height <= 16) && (isLuma(partitioner.chType)) ) || ((partitioner.currArea().chromaSize().width * partitioner.currArea().chromaSize().height <= 16) && (!isLuma(partitioner.chType)) && partitioner.isSepTree(*tempCS) ) ) +#endif { return; } -#endif tempCS->initStructData(encTestMode.qp); CodingUnit &cu = tempCS->addCU(CS::getArea(*tempCS, tempCS->area, partitioner.chType), partitioner.chType); partitioner.setCUData(cu); @@ -2097,7 +1981,6 @@ void EncCu::xCheckPLT(CodingStructure *&tempCS, CodingStructure *&bestCS, Partit } else { -#if JVET_Q0504_PLT_NON444 if( cu.chromaFormat != CHROMA_400 ) { m_pcIntraSearch->PLTSearch(*tempCS, partitioner, COMPONENT_Y, 3); @@ -2106,9 +1989,6 @@ void EncCu::xCheckPLT(CodingStructure *&tempCS, CodingStructure *&bestCS, Partit { m_pcIntraSearch->PLTSearch(*tempCS, partitioner, COMPONENT_Y, 1); } -#else - m_pcIntraSearch->PLTSearch(*tempCS, partitioner, COMPONENT_Y, 3); -#endif } @@ -2138,7 +2018,6 @@ void EncCu::xCheckPLT(CodingStructure *&tempCS, CodingStructure *&bestCS, Partit } else { -#if JVET_Q0504_PLT_NON444 if( cu.chromaFormat != CHROMA_400 ) { m_CABACEstimator->cu_palette_info(cu, COMPONENT_Y, 3, cuCtx); @@ -2147,27 +2026,18 @@ void EncCu::xCheckPLT(CodingStructure *&tempCS, CodingStructure *&bestCS, Partit { m_CABACEstimator->cu_palette_info(cu, COMPONENT_Y, 1, cuCtx); } -#else - m_CABACEstimator->cu_palette_info(cu, COMPONENT_Y, 3, cuCtx); -#endif } tempCS->fracBits = m_CABACEstimator->getEstFracBits(); tempCS->cost = m_pcRdCost->calcRdCost(tempCS->fracBits, tempCS->dist); xEncodeDontSplit(*tempCS, partitioner); xCheckDQP(*tempCS, partitioner); -#if JVET_Q0267_RESET_CHROMA_QP_OFFSET xCheckChromaQPOffset( *tempCS, partitioner ); -#endif xCalDebCost(*tempCS, partitioner); tempCS->useDbCost = m_pcEncCfg->getUseEncDbOpt(); const Area currCuArea = cu.block(getFirstComponentOfChannel(partitioner.chType)); -#if JVET_Q0504_PLT_NON444 cu.slice->m_mapPltCost[isChroma(partitioner.chType)][currCuArea.pos()][currCuArea.size()] = tempCS->cost; -#else - cu.slice->m_mapPltCost[currCuArea.pos()][currCuArea.size()] = tempCS->cost; -#endif #if WCG_EXT DTRACE_MODE_COST(*tempCS, m_pcRdCost->getLambda(true)); #else @@ -2249,7 +2119,6 @@ void EncCu::xCheckDQP( CodingStructure& cs, Partitioner& partitioner, bool bKeep } } -#if JVET_Q0267_RESET_CHROMA_QP_OFFSET void EncCu::xCheckChromaQPOffset( CodingStructure& cs, Partitioner& partitioner ) { // doesn't apply if CU chroma QP offset is disabled @@ -2265,13 +2134,13 @@ void EncCu::xCheckChromaQPOffset( CodingStructure& cs, Partitioner& partitioner } // not needed after the first coded TU in the chroma QG - if( !partitioner.currQgChromaEnable() ) + if( !partitioner.currQgChromaEnable() ) { return; } - + CodingUnit& cu = *cs.getCU( partitioner.chType ); - + // check if chroma is coded or not bool hasResidual = false; for( const TransformUnit &tu : CU::traverseTUs(cu) ) @@ -2304,7 +2173,6 @@ void EncCu::xCheckChromaQPOffset( CodingStructure& cs, Partitioner& partitioner } } -#endif void EncCu::xFillPCMBuffer( CodingUnit &cu ) { const ChromaFormat format = cu.chromaFormat; @@ -2320,11 +2188,7 @@ void EncCu::xFillPCMBuffer( CodingUnit &cu ) const CPelBuf source = tu.cs->getOrgBuf( compArea ); PelBuf destination = tu.getPcmbuf( compID ); -#if JVET_Q0346_LMCS_ENABLE_IN_SH if (tu.cs->slice->getLmcsEnabledFlag() && m_pcReshape->getCTUFlag() && compID == COMPONENT_Y) -#else - if (tu.cs->picHeader->getLmcsEnabledFlag() && m_pcReshape->getCTUFlag() && compID == COMPONENT_Y) -#endif { CompArea tmpArea(COMPONENT_Y, compArea.chromaFormat, Position(0, 0), compArea.size()); PelBuf tempOrgBuf = m_tmpStorageLCU->getBuf(tmpArea); @@ -2448,7 +2312,7 @@ void EncCu::xCheckRDCostMerge2Nx2N( CodingStructure *&tempCS, CodingStructure *& static_vector<ModeInfo, MRG_MAX_NUM_CANDS + MMVD_ADD_NUM> RdModeList; bool mrgTempBufSet = false; - const int candNum = MRG_MAX_NUM_CANDS + (tempCS->sps->getUseMMVD() ? MMVD_ADD_NUM : 0); + const int candNum = mergeCtx.numValidMergeCand + (tempCS->sps->getUseMMVD() ? std::min<int>(MMVD_BASE_MV_NUM, mergeCtx.numValidMergeCand) * MMVD_MAX_REFINE_NUM : 0); for (int i = 0; i < candNum; i++) { @@ -2528,11 +2392,7 @@ void EncCu::xCheckRDCostMerge2Nx2N( CodingStructure *&tempCS, CodingStructure *& cu.tileIdx = tempCS->pps->getTileIdx( tempCS->area.lumaPos() ); cu.skip = false; cu.mmvdSkip = false; -#if !JVET_Q0806 - cu.triangle = false; -#else cu.geoFlag = false; -#endif //cu.affine cu.predMode = MODE_INTER; //cu.LICFlag @@ -2635,32 +2495,20 @@ void EncCu::xCheckRDCostMerge2Nx2N( CodingStructure *&tempCS, CodingStructure *& m_pcIntraSearch->switchBuffer(pu, COMPONENT_Y, pu.cs->getPredBuf(pu).Y(), m_pcIntraSearch->getPredictorPtr2(COMPONENT_Y, intraCnt)); } pu.cs->getPredBuf(pu).copyFrom(acMergeTmpBuffer[mergeCand]); -#if JVET_Q0346_LMCS_ENABLE_IN_SH if (pu.cs->slice->getLmcsEnabledFlag() && m_pcReshape->getCTUFlag()) -#else - if (pu.cs->picHeader->getLmcsEnabledFlag() && m_pcReshape->getCTUFlag()) -#endif { pu.cs->getPredBuf(pu).Y().rspSignal(m_pcReshape->getFwdLUT()); } m_pcIntraSearch->geneWeightedPred(COMPONENT_Y, pu.cs->getPredBuf(pu).Y(), pu, m_pcIntraSearch->getPredictorPtr2(COMPONENT_Y, intraCnt)); // calculate cost -#if JVET_Q0346_LMCS_ENABLE_IN_SH if (pu.cs->slice->getLmcsEnabledFlag() && m_pcReshape->getCTUFlag()) -#else - if (pu.cs->picHeader->getLmcsEnabledFlag() && m_pcReshape->getCTUFlag()) -#endif { pu.cs->getPredBuf(pu).Y().rspSignal(m_pcReshape->getInvLUT()); } distParam.cur = pu.cs->getPredBuf(pu).Y(); Distortion sadValue = distParam.distFunc(distParam); -#if JVET_Q0346_LMCS_ENABLE_IN_SH if (pu.cs->slice->getLmcsEnabledFlag() && m_pcReshape->getCTUFlag()) -#else - if (pu.cs->picHeader->getLmcsEnabledFlag() && m_pcReshape->getCTUFlag()) -#endif { pu.cs->getPredBuf(pu).Y().rspSignal(m_pcReshape->getFwdLUT()); } @@ -2732,11 +2580,7 @@ void EncCu::xCheckRDCostMerge2Nx2N( CodingStructure *&tempCS, CodingStructure *& setMergeBestSATDCost( candCostList[0] ); -#if JVET_Q0438_MONOCHROME_BUGFIXES if (isIntrainterEnabled && isChromaEnabled(pu.cs->pcv->chrFormat)) -#else - if (isIntrainterEnabled) -#endif { pu.ciipFlag = true; for (uint32_t mergeCnt = 0; mergeCnt < uiNumMrgSATDCand; mergeCnt++) @@ -2807,11 +2651,7 @@ void EncCu::xCheckRDCostMerge2Nx2N( CodingStructure *&tempCS, CodingStructure *& cu.tileIdx = tempCS->pps->getTileIdx( tempCS->area.lumaPos() ); cu.skip = false; cu.mmvdSkip = false; -#if !JVET_Q0806 - cu.triangle = false; -#else cu.geoFlag = false; -#endif //cu.affine cu.predMode = MODE_INTER; //cu.LICFlag @@ -2876,19 +2716,13 @@ void EncCu::xCheckRDCostMerge2Nx2N( CodingStructure *&tempCS, CodingStructure *& uint32_t bufIdx = 0; PelBuf tmpBuf = tempCS->getPredBuf(pu).Y(); tmpBuf.copyFrom(acMergeTmpBuffer[uiMergeCand].Y()); -#if JVET_Q0346_LMCS_ENABLE_IN_SH if (pu.cs->slice->getLmcsEnabledFlag() && m_pcReshape->getCTUFlag()) -#else - if (pu.cs->picHeader->getLmcsEnabledFlag() && m_pcReshape->getCTUFlag()) -#endif { tmpBuf.rspSignal(m_pcReshape->getFwdLUT()); } m_pcIntraSearch->geneWeightedPred(COMPONENT_Y, tmpBuf, pu, m_pcIntraSearch->getPredictorPtr2(COMPONENT_Y, bufIdx)); -#if JVET_Q0438_MONOCHROME_BUGFIXES if (isChromaEnabled(pu.chromaFormat)) { -#endif if (pu.chromaSize().width > 2) { tmpBuf = tempCS->getPredBuf(pu).Cb(); @@ -2905,9 +2739,7 @@ void EncCu::xCheckRDCostMerge2Nx2N( CodingStructure *&tempCS, CodingStructure *& tmpBuf = tempCS->getPredBuf(pu).Cr(); tmpBuf.copyFrom(acMergeTmpBuffer[uiMergeCand].Cr()); } -#if JVET_Q0438_MONOCHROME_BUGFIXES } -#endif } else { @@ -2984,246 +2816,6 @@ void EncCu::xCheckRDCostMerge2Nx2N( CodingStructure *&tempCS, CodingStructure *& } } -#if !JVET_Q0806 -void EncCu::xCheckRDCostMergeTriangle2Nx2N( CodingStructure *&tempCS, CodingStructure *&bestCS, Partitioner &partitioner, const EncTestMode& encTestMode ) -{ - const Slice &slice = *tempCS->slice; - const SPS &sps = *tempCS->sps; -#if JVET_Q0798_SPS_NUMBER_MERGE_CANDIDATE - if (sps.getMaxNumGeoCand() < 2) -#else - if (slice.getPicHeader()->getMaxNumTriangleCand() < 2) -#endif - return; - - CHECK( slice.getSliceType() != B_SLICE, "Triangle mode is only applied to B-slices" ); - - tempCS->initStructData( encTestMode.qp ); - - bool trianglecandHasNoResidual[TRIANGLE_MAX_NUM_CANDS]; - for( int mergeCand = 0; mergeCand < TRIANGLE_MAX_NUM_CANDS; mergeCand++ ) - { - trianglecandHasNoResidual[mergeCand] = false; - } - - bool bestIsSkip = false; - uint8_t numTriangleCandidate = TRIANGLE_MAX_NUM_CANDS; - uint8_t triangleNumMrgSATDCand = TRIANGLE_MAX_NUM_SATD_CANDS; - PelUnitBuf triangleBuffer[TRIANGLE_MAX_NUM_UNI_CANDS]; - PelUnitBuf triangleWeightedBuffer[TRIANGLE_MAX_NUM_CANDS]; - static_vector<uint8_t, TRIANGLE_MAX_NUM_CANDS> triangleRdModeList; - static_vector<double, TRIANGLE_MAX_NUM_CANDS> tianglecandCostList; -#if JVET_Q0798_SPS_NUMBER_MERGE_CANDIDATE - uint8_t numTriangleCandComb = sps.getMaxNumGeoCand() * (sps.getMaxNumGeoCand() - 1) * 2; -#else - uint8_t numTriangleCandComb = slice.getPicHeader()->getMaxNumTriangleCand() * (slice.getPicHeader()->getMaxNumTriangleCand() - 1) * 2; -#endif - - DistParam distParam; - const bool useHadamard = !tempCS->slice->getDisableSATDForRD(); - m_pcRdCost->setDistParam( distParam, tempCS->getOrgBuf().Y(), m_acMergeBuffer[0].Y(), sps.getBitDepth( CHANNEL_TYPE_LUMA ), COMPONENT_Y, useHadamard ); - - const UnitArea localUnitArea( tempCS->area.chromaFormat, Area( 0, 0, tempCS->area.Y().width, tempCS->area.Y().height) ); - - const double sqrtLambdaForFirstPass = m_pcRdCost->getMotionLambda( ); - - MergeCtx triangleMrgCtx; - { - CodingUnit cu( tempCS->area ); - cu.cs = tempCS; - cu.predMode = MODE_INTER; - cu.slice = tempCS->slice; - cu.tileIdx = tempCS->pps->getTileIdx( tempCS->area.lumaPos() ); - cu.triangle = true; - cu.mmvdSkip = false; - cu.BcwIdx = BCW_DEFAULT; - - PredictionUnit pu( tempCS->area ); - pu.cu = &cu; - pu.cs = tempCS; - pu.regularMergeFlag = false; - - PU::getTriangleMergeCandidates( pu, triangleMrgCtx ); -#if JVET_Q0798_SPS_NUMBER_MERGE_CANDIDATE - const uint8_t maxNumTriangleCand = pu.cs->sps->getMaxNumGeoCand(); -#else - const uint8_t maxNumTriangleCand = pu.cs->picHeader->getMaxNumTriangleCand(); -#endif - for (uint8_t mergeCand = 0; mergeCand < maxNumTriangleCand; mergeCand++) - { - triangleBuffer[mergeCand] = m_acMergeBuffer[mergeCand].getBuf(localUnitArea); - triangleMrgCtx.setMergeInfo( pu, mergeCand ); - PU::spanMotionInfo( pu, triangleMrgCtx ); - - if( m_pcEncCfg->getMCTSEncConstraint() && ( !( MCTSHelper::checkMvBufferForMCTSConstraint( pu ) ) ) ) - { - // Do not use this mode - tempCS->initStructData( encTestMode.qp ); - return; - } - m_pcInterSearch->motionCompensation( pu, triangleBuffer[mergeCand] ); - } - } - - triangleNumMrgSATDCand = min(triangleNumMrgSATDCand, numTriangleCandComb); - { - CodingUnit &cu = tempCS->addCU( tempCS->area, partitioner.chType ); - - partitioner.setCUData( cu ); - cu.slice = tempCS->slice; - cu.tileIdx = tempCS->pps->getTileIdx( tempCS->area.lumaPos() ); - cu.skip = false; - cu.predMode = MODE_INTER; - cu.chromaQpAdj = m_cuChromaQpOffsetIdxPlus1; - cu.qp = encTestMode.qp; - cu.triangle = true; - cu.mmvdSkip = false; - cu.BcwIdx = BCW_DEFAULT; - - PredictionUnit &pu = tempCS->addPU( cu, partitioner.chType ); - - if( abs(floorLog2(cu.lwidth()) - floorLog2(cu.lheight())) >= 2 ) - { - numTriangleCandidate = 30; - } - else - { - numTriangleCandidate = TRIANGLE_MAX_NUM_CANDS; - } - - numTriangleCandidate = min(numTriangleCandidate, numTriangleCandComb); - - for( uint8_t mergeCand = 0; mergeCand < numTriangleCandidate; mergeCand++ ) - { - bool splitDir = m_triangleModeTest[mergeCand].m_splitDir; - uint8_t candIdx0 = m_triangleModeTest[mergeCand].m_candIdx0; - uint8_t candIdx1 = m_triangleModeTest[mergeCand].m_candIdx1; - - pu.triangleSplitDir = splitDir; - pu.triangleMergeIdx0 = candIdx0; - pu.triangleMergeIdx1 = candIdx1; - pu.mergeFlag = true; - pu.regularMergeFlag = false; - triangleWeightedBuffer[mergeCand] = m_acTriangleWeightedBuffer[mergeCand].getBuf( localUnitArea ); - triangleBuffer[candIdx0] = m_acMergeBuffer[candIdx0].getBuf( localUnitArea ); - triangleBuffer[candIdx1] = m_acMergeBuffer[candIdx1].getBuf( localUnitArea ); - - m_pcInterSearch->weightedTriangleBlk( pu, splitDir, CHANNEL_TYPE_LUMA, triangleWeightedBuffer[mergeCand], triangleBuffer[candIdx0], triangleBuffer[candIdx1] ); - distParam.cur = triangleWeightedBuffer[mergeCand].Y(); - - Distortion uiSad = distParam.distFunc( distParam ); - - uint32_t uiBitsCand = m_triangleIdxBins[splitDir][candIdx0][candIdx1]; - - double cost = (double)uiSad + (double)uiBitsCand * sqrtLambdaForFirstPass; - - updateCandList( mergeCand, cost, triangleRdModeList, tianglecandCostList - , triangleNumMrgSATDCand ); - } - - // limit number of candidates using SATD-costs - for( uint8_t i = 0; i < triangleNumMrgSATDCand; i++ ) - { - if( tianglecandCostList[i] > MRG_FAST_RATIO * tianglecandCostList[0] || tianglecandCostList[i] > getMergeBestSATDCost() ) - { - triangleNumMrgSATDCand = i; - break; - } - } - - // perform chroma weighting process -#if JVET_Q0438_MONOCHROME_BUGFIXES - if (isChromaEnabled(pu.chromaFormat)) - { -#endif - for( uint8_t i = 0; i < triangleNumMrgSATDCand; i++ ) - { - uint8_t mergeCand = triangleRdModeList[i]; - bool splitDir = m_triangleModeTest[mergeCand].m_splitDir; - uint8_t candIdx0 = m_triangleModeTest[mergeCand].m_candIdx0; - uint8_t candIdx1 = m_triangleModeTest[mergeCand].m_candIdx1; - - pu.triangleSplitDir = splitDir; - pu.triangleMergeIdx0 = candIdx0; - pu.triangleMergeIdx1 = candIdx1; - pu.mergeFlag = true; - pu.regularMergeFlag = false; - m_pcInterSearch->weightedTriangleBlk( pu, splitDir, CHANNEL_TYPE_CHROMA, triangleWeightedBuffer[mergeCand], triangleBuffer[candIdx0], triangleBuffer[candIdx1] ); - } -#if JVET_Q0438_MONOCHROME_BUGFIXES - } -#endif - - tempCS->initStructData( encTestMode.qp ); - } - - triangleNumMrgSATDCand = min(triangleNumMrgSATDCand, (uint8_t)triangleRdModeList.size()); - - m_bestModeUpdated = tempCS->useDbCost = bestCS->useDbCost = false; - { - uint8_t iteration; - uint8_t iterationBegin = 0; - iteration = 2; - for (uint8_t noResidualPass = iterationBegin; noResidualPass < iteration; ++noResidualPass) - { - for( uint8_t mrgHADIdx = 0; mrgHADIdx < triangleNumMrgSATDCand; mrgHADIdx++ ) - { - uint8_t mergeCand = triangleRdModeList[mrgHADIdx]; - - if ( ( (noResidualPass != 0) && trianglecandHasNoResidual[mergeCand] ) - || ( (noResidualPass == 0) && bestIsSkip ) ) - { - continue; - } - - bool splitDir = m_triangleModeTest[mergeCand].m_splitDir; - uint8_t candIdx0 = m_triangleModeTest[mergeCand].m_candIdx0; - uint8_t candIdx1 = m_triangleModeTest[mergeCand].m_candIdx1; - - CodingUnit &cu = tempCS->addCU(tempCS->area, partitioner.chType); - - partitioner.setCUData(cu); - cu.slice = tempCS->slice; - cu.tileIdx = tempCS->pps->getTileIdx( tempCS->area.lumaPos() ); - cu.skip = false; - cu.predMode = MODE_INTER; - cu.chromaQpAdj = m_cuChromaQpOffsetIdxPlus1; - cu.qp = encTestMode.qp; - cu.triangle = true; - cu.mmvdSkip = false; - cu.BcwIdx = BCW_DEFAULT; - PredictionUnit &pu = tempCS->addPU(cu, partitioner.chType); - - pu.triangleSplitDir = splitDir; - pu.triangleMergeIdx0 = candIdx0; - pu.triangleMergeIdx1 = candIdx1; - pu.mergeFlag = true; - pu.regularMergeFlag = false; - PU::spanTriangleMotionInfo(pu, triangleMrgCtx, splitDir, candIdx0, candIdx1 ); - - if( m_pcEncCfg->getMCTSEncConstraint() && ( !( MCTSHelper::checkMvBufferForMCTSConstraint( *cu.firstPU ) ) ) ) - { - // Do not use this mode - tempCS->initStructData( encTestMode.qp ); - return; - } - tempCS->getPredBuf().copyFrom( triangleWeightedBuffer[mergeCand] ); - xEncodeInterResidual( tempCS, bestCS, partitioner, encTestMode, noResidualPass, ( noResidualPass == 0 ? &trianglecandHasNoResidual[mergeCand] : NULL ) ); - - if (m_pcEncCfg->getUseFastDecisionForMerge() && !bestIsSkip) - { - bestIsSkip = bestCS->getCU(partitioner.chType)->rootCbf == 0; - } - tempCS->initStructData(encTestMode.qp); - }// end loop mrgHADIdx - } - } - if ( m_bestModeUpdated && bestCS->cost != MAX_DOUBLE ) - { - xCalDebCost( *bestCS, partitioner ); - } -} -#else void EncCu::xCheckRDCostMergeGeo2Nx2N(CodingStructure *&tempCS, CodingStructure *&bestCS, Partitioner &pm, const EncTestMode& encTestMode) { const Slice &slice = *tempCS->slice; @@ -3270,11 +2862,7 @@ void EncCu::xCheckRDCostMergeGeo2Nx2N(CodingStructure *&tempCS, CodingStructure const UnitArea localUnitArea(tempCS->area.chromaFormat, Area(0, 0, tempCS->area.Y().width, tempCS->area.Y().height)); const double sqrtLambdaForFirstPass = m_pcRdCost->getMotionLambda(); -#if JVET_Q0798_SPS_NUMBER_MERGE_CANDIDATE uint8_t maxNumMergeCandidates = cu.cs->sps->getMaxNumGeoCand(); -#else - uint8_t maxNumMergeCandidates = cu.cs->picHeader->getMaxNumGeoCand(); -#endif DistParam distParamWholeBlk; m_pcRdCost->setDistParam(distParamWholeBlk, tempCS->getOrgBuf().Y(), m_acMergeBuffer[0].Y().buf, m_acMergeBuffer[0].Y().stride, sps.getBitDepth(CHANNEL_TYPE_LUMA), COMPONENT_Y); Distortion bestWholeBlkSad = MAX_UINT64; @@ -3506,7 +3094,6 @@ void EncCu::xCheckRDCostMergeGeo2Nx2N(CodingStructure *&tempCS, CodingStructure xCalDebCost(*bestCS, pm); } } -#endif void EncCu::xCheckRDCostAffineMerge2Nx2N( CodingStructure *&tempCS, CodingStructure *&bestCS, Partitioner &partitioner, const EncTestMode& encTestMode ) { @@ -3528,10 +3115,14 @@ void EncCu::xCheckRDCostAffineMerge2Nx2N( CodingStructure *&tempCS, CodingStruct AffineMergeCtx affineMergeCtx; const SPS &sps = *tempCS->sps; +#if JVET_R0371_MAX_NUM_SUB_BLK_MRG_CAND + if (sps.getMaxNumAffineMergeCand() == 0) + { + return; + } +#endif -#if JVET_Q0806 setAFFBestSATDCost(MAX_DOUBLE); -#endif MergeCtx mrgCtx; if ( sps.getSBTMVPEnabledFlag() ) @@ -3672,9 +3263,7 @@ void EncCu::xCheckRDCostAffineMerge2Nx2N( CodingStructure *&tempCS, CodingStruct } tempCS->initStructData( encTestMode.qp ); -#if JVET_Q0806 setAFFBestSATDCost(candCostList[0]); -#endif } else @@ -3828,11 +3417,7 @@ void EncCu::xCheckRDCostIBCModeMerge2Nx2N(CodingStructure *&tempCS, CodingStruct cu.mmvdSkip = false; pu.mmvdMergeFlag = false; pu.regularMergeFlag = false; -#if !JVET_Q0806 - cu.triangle = false; -#else cu.geoFlag = false; -#endif PU::getIBCMergeCandidates(pu, mergeCtx); } @@ -3866,11 +3451,7 @@ void EncCu::xCheckRDCostIBCModeMerge2Nx2N(CodingStructure *&tempCS, CodingStruct cu.chromaQpAdj = m_cuChromaQpOffsetIdxPlus1; cu.qp = encTestMode.qp; cu.mmvdSkip = false; -#if !JVET_Q0806 - cu.triangle = false; -#else cu.geoFlag = false; -#endif DistParam distParam; const bool bUseHadamard = !cu.slice->getDisableSATDForRD(); PredictionUnit &pu = tempCS->addPU(cu, partitioner.chType); //tempCS->addPU(cu); @@ -3879,11 +3460,7 @@ void EncCu::xCheckRDCostIBCModeMerge2Nx2N(CodingStructure *&tempCS, CodingStruct Picture* refPic = pu.cu->slice->getPic(); const CPelBuf refBuf = refPic->getRecoBuf(pu.blocks[COMPONENT_Y]); const Pel* piRefSrch = refBuf.buf; -#if JVET_Q0346_LMCS_ENABLE_IN_SH if (tempCS->slice->getLmcsEnabledFlag() && m_pcReshape->getCTUFlag()) -#else - if (tempCS->picHeader->getLmcsEnabledFlag() && m_pcReshape->getCTUFlag() ) -#endif { const CompArea &area = cu.blocks[COMPONENT_Y]; CompArea tmpArea(COMPONENT_Y, area.chromaFormat, Position(0, 0), area.size()); @@ -3921,11 +3498,7 @@ void EncCu::xCheckRDCostIBCModeMerge2Nx2N(CodingStructure *&tempCS, CodingStruct Distortion sad = distParam.distFunc(distParam); unsigned int bitsCand = mergeCand + 1; -#if JVET_Q0798_SPS_NUMBER_MERGE_CANDIDATE if (mergeCand == tempCS->sps->getMaxNumMergeCand() - 1) -#else - if (mergeCand == tempCS->picHeader->getMaxNumMergeCand() - 1) -#endif { bitsCand--; } @@ -3995,11 +3568,7 @@ void EncCu::xCheckRDCostIBCModeMerge2Nx2N(CodingStructure *&tempCS, CodingStruct cu.mmvdSkip = false; pu.mmvdMergeFlag = false; pu.regularMergeFlag = false; -#if !JVET_Q0806 - cu.triangle = false; -#else cu.geoFlag = false; -#endif mergeCtx.setMergeInfo(pu, mergeCand); PU::spanMotionInfo(pu, mergeCtx); @@ -4027,9 +3596,7 @@ void EncCu::xCheckRDCostIBCModeMerge2Nx2N(CodingStructure *&tempCS, CodingStruct xCheckDQP(*tempCS, partitioner); } #endif -#if JVET_Q0267_RESET_CHROMA_QP_OFFSET xCheckChromaQPOffset( *tempCS, partitioner ); -#endif DTRACE_MODE_COST(*tempCS, m_pcRdCost->getLambda()); @@ -4121,9 +3688,7 @@ void EncCu::xCheckRDCostIBCMode(CodingStructure *&tempCS, CodingStructure *&best xCheckDQP(*tempCS, partitioner); } #endif -#if JVET_Q0267_RESET_CHROMA_QP_OFFSET xCheckChromaQPOffset( *tempCS, partitioner ); -#endif tempCS->useDbCost = m_pcEncCfg->getUseEncDbOpt(); if ( m_bestModeUpdated ) @@ -4522,11 +4087,7 @@ void EncCu::xCalDebCost( CodingStructure &cs, Partitioner &partitioner, bool cal //Copy current CU's reco to Deblock Pic Buffer const CompArea& curCompArea = currCsArea.block( compId ); picDbBuf.getBuf( curCompArea ).copyFrom( cs.getRecoBuf( curCompArea ) ); -#if JVET_Q0346_LMCS_ENABLE_IN_SH if (cs.slice->getLmcsEnabledFlag() && m_pcReshape->getSliceReshaperInfo().getUseSliceReshaper() && isLuma(compId)) -#else - if (cs.picHeader->getLmcsEnabledFlag() && m_pcReshape->getSliceReshaperInfo().getUseSliceReshaper() && isLuma(compId)) -#endif { picDbBuf.getBuf( curCompArea ).rspSignal( m_pcReshape->getInvLUT() ); } @@ -4536,11 +4097,7 @@ void EncCu::xCalDebCost( CodingStructure &cs, Partitioner &partitioner, bool cal { const CompArea& compArea = areaLeft.block(compId); picDbBuf.getBuf( compArea ).copyFrom( cs.picture->getRecoBuf( compArea ) ); -#if JVET_Q0346_LMCS_ENABLE_IN_SH if (cs.slice->getLmcsEnabledFlag() && m_pcReshape->getSliceReshaperInfo().getUseSliceReshaper() && isLuma(compId)) -#else - if (cs.picHeader->getLmcsEnabledFlag() && m_pcReshape->getSliceReshaperInfo().getUseSliceReshaper() && isLuma(compId)) -#endif { picDbBuf.getBuf( compArea ).rspSignal( m_pcReshape->getInvLUT() ); } @@ -4550,11 +4107,7 @@ void EncCu::xCalDebCost( CodingStructure &cs, Partitioner &partitioner, bool cal { const CompArea& compArea = areaTop.block( compId ); picDbBuf.getBuf( compArea ).copyFrom( cs.picture->getRecoBuf( compArea ) ); -#if JVET_Q0346_LMCS_ENABLE_IN_SH if (cs.slice->getLmcsEnabledFlag() && m_pcReshape->getSliceReshaperInfo().getUseSliceReshaper() && isLuma(compId)) -#else - if (cs.picHeader->getLmcsEnabledFlag() && m_pcReshape->getSliceReshaperInfo().getUseSliceReshaper() && isLuma(compId)) -#endif { picDbBuf.getBuf( compArea ).rspSignal( m_pcReshape->getInvLUT() ); } @@ -4625,13 +4178,8 @@ Distortion EncCu::getDistortionDb( CodingStructure &cs, CPelBuf org, CPelBuf rec #if WCG_EXT m_pcRdCost->setChromaFormat(cs.sps->getChromaFormatIdc()); CPelBuf orgLuma = cs.picture->getOrigBuf( cs.area.blocks[COMPONENT_Y] ); -#if JVET_Q0346_LMCS_ENABLE_IN_SH if (m_pcEncCfg->getLumaLevelToDeltaQPMapping().isEnabled() || ( m_pcEncCfg->getLmcs() && (cs.slice->getLmcsEnabledFlag() && m_pcReshape->getCTUFlag()))) -#else - if ( m_pcEncCfg->getLumaLevelToDeltaQPMapping().isEnabled() || ( - m_pcEncCfg->getLmcs() && (cs.picHeader->getLmcsEnabledFlag() && m_pcReshape->getCTUFlag()))) -#endif { if ( compID == COMPONENT_Y && !afterDb && !m_pcEncCfg->getLumaLevelToDeltaQPMapping().isEnabled()) { @@ -4646,11 +4194,7 @@ Distortion EncCu::getDistortionDb( CodingStructure &cs, CPelBuf org, CPelBuf rec dist += m_pcRdCost->getDistPart( org, reco, cs.sps->getBitDepth( toChannelType( compID ) ), compID, DF_SSE_WTD, &orgLuma ); } } -#if JVET_Q0346_LMCS_ENABLE_IN_SH else if (m_pcEncCfg->getLmcs() && cs.slice->getLmcsEnabledFlag() && cs.slice->isIntra()) //intra slice -#else - else if (m_pcEncCfg->getLmcs() && cs.picHeader->getLmcsEnabledFlag() && cs.slice->isIntra()) //intra slice -#endif { if ( compID == COMPONENT_Y && afterDb ) { @@ -4858,9 +4402,7 @@ void EncCu::xEncodeInterResidual( CodingStructure *&tempCS xEncodeDontSplit( *tempCS, partitioner ); xCheckDQP( *tempCS, partitioner ); -#if JVET_Q0267_RESET_CHROMA_QP_OFFSET xCheckChromaQPOffset( *tempCS, partitioner ); -#endif if( NULL != bestHasNonResi && (bestCostInternal > tempCS->cost) ) @@ -5009,9 +4551,7 @@ void EncCu::xEncodeInterResidual( CodingStructure *&tempCS xEncodeDontSplit( *tempCS, partitioner ); xCheckDQP( *tempCS, partitioner ); -#if JVET_Q0267_RESET_CHROMA_QP_OFFSET xCheckChromaQPOffset( *tempCS, partitioner ); -#endif if( NULL != bestHasNonResi && ( bestCostInternal > tempCS->cost ) ) { @@ -5143,13 +4683,8 @@ void EncCu::xReuseCachedResult( CodingStructure *&tempCS, CodingStructure *&best CPelBuf org = tempCS->getOrgBuf ( compID ); #if WCG_EXT -#if JVET_Q0346_LMCS_ENABLE_IN_SH if (m_pcEncCfg->getLumaLevelToDeltaQPMapping().isEnabled() || ( m_pcEncCfg->getLmcs() && (tempCS->slice->getLmcsEnabledFlag() && m_pcReshape->getCTUFlag()))) -#else - if (m_pcEncCfg->getLumaLevelToDeltaQPMapping().isEnabled() || ( - m_pcEncCfg->getLmcs() && (tempCS->picHeader->getLmcsEnabledFlag() && m_pcReshape->getCTUFlag()))) -#endif { const CPelBuf orgLuma = tempCS->getOrgBuf(tempCS->area.blocks[COMPONENT_Y]); if (compID == COMPONENT_Y && !(m_pcEncCfg->getLumaLevelToDeltaQPMapping().isEnabled())) @@ -5185,9 +4720,7 @@ void EncCu::xReuseCachedResult( CodingStructure *&tempCS, CodingStructure *&best xEncodeDontSplit( *tempCS, partitioner ); xCheckDQP ( *tempCS, partitioner ); -#if JVET_Q0267_RESET_CHROMA_QP_OFFSET xCheckChromaQPOffset( *tempCS, partitioner ); -#endif xCheckBestMode ( tempCS, bestCS, partitioner, cachedMode ); } else diff --git a/source/Lib/EncoderLib/EncCu.h b/source/Lib/EncoderLib/EncCu.h index 91e22c548f69522b0dbbf969aa59974df7ff86d8..07d4848fa5423df234e300b69f652635cbd80326 100644 --- a/source/Lib/EncoderLib/EncCu.h +++ b/source/Lib/EncoderLib/EncCu.h @@ -67,17 +67,6 @@ class EncSlice; // ==================================================================================================================== /// CU encoder class -#if !JVET_Q0806 -struct TriangleMotionInfo -{ - uint8_t m_splitDir; - uint8_t m_candIdx0; - uint8_t m_candIdx1; - - TriangleMotionInfo ( uint8_t splitDir, uint8_t candIdx0, uint8_t candIdx1 ): m_splitDir(splitDir), m_candIdx0(candIdx0), m_candIdx1(candIdx1) { } - TriangleMotionInfo() { m_splitDir = m_candIdx0 = m_candIdx1 = 0; } -}; -#else struct GeoMergeCombo { int splitDir; @@ -121,7 +110,7 @@ class FastGeoCostList { public: FastGeoCostList() { numGeoTemplatesInitialized = 0; }; - ~FastGeoCostList() + ~FastGeoCostList() { for (int partIdx = 0; partIdx < 2; partIdx++) { @@ -156,7 +145,6 @@ public: } int numGeoTemplatesInitialized; }; -#endif class EncCu : DecCu @@ -203,13 +191,9 @@ private: PelStorage m_acMergeBuffer[MMVD_MRG_MAX_RD_BUF_NUM]; PelStorage m_acRealMergeBuffer[MRG_MAX_NUM_CANDS]; PelStorage m_acMergeTmpBuffer[MRG_MAX_NUM_CANDS]; -#if !JVET_Q0806 - PelStorage m_acTriangleWeightedBuffer[TRIANGLE_MAX_NUM_CANDS]; // to store weighted prediction pixles -#else PelStorage m_acGeoWeightedBuffer[GEO_MAX_TRY_WEIGHTED_SAD]; // to store weighted prediction pixles FastGeoCostList m_GeoCostList; double m_AFFBestSATDCost; -#endif double m_mergeBestSATDCost; MotionInfo m_SubPuMiBuf [( MAX_CU_SIZE * MAX_CU_SIZE ) >> ( MIN_CU_LOG2 << 1 )]; @@ -220,12 +204,7 @@ private: #endif int m_bestBcwIdx[2]; double m_bestBcwCost[2]; -#if !JVET_Q0806 - TriangleMotionInfo m_triangleModeTest[TRIANGLE_MAX_NUM_CANDS]; - uint8_t m_triangleIdxBins[2][TRIANGLE_MAX_NUM_UNI_CANDS][TRIANGLE_MAX_NUM_UNI_CANDS]; -#else GeoMotionInfo m_GeoModeTest[GEO_MAX_NUM_CANDS]; -#endif #if SHARP_LUMA_DELTA_QP || ENABLE_QPA_SUB_CTU void updateLambda ( Slice* slice, const int dQP, #if WCG_EXT && ER_CHROMA_QP_WCG_PPS @@ -255,10 +234,8 @@ public: void setMergeBestSATDCost(double cost) { m_mergeBestSATDCost = cost; } double getMergeBestSATDCost() { return m_mergeBestSATDCost; } -#if JVET_Q0806 void setAFFBestSATDCost(double cost) { m_AFFBestSATDCost = cost; } double getAFFBestSATDCost() { return m_AFFBestSATDCost; } -#endif IbcHashMap& getIbcHashMap() { return m_ibcHashMap; } EncCfg* getEncCfg() const { return m_pcEncCfg; } @@ -284,9 +261,7 @@ protected: bool xCheckRDCostIntra(CodingStructure *&tempCS, CodingStructure *&bestCS, Partitioner &pm, const EncTestMode& encTestMode, bool adaptiveColorTrans); void xCheckDQP ( CodingStructure& cs, Partitioner& partitioner, bool bKeepCtx = false); -#if JVET_Q0267_RESET_CHROMA_QP_OFFSET void xCheckChromaQPOffset ( CodingStructure& cs, Partitioner& partitioner); -#endif void xFillPCMBuffer ( CodingUnit &cu); void xCheckRDCostHashInter ( CodingStructure *&tempCS, CodingStructure *&bestCS, Partitioner &pm, const EncTestMode& encTestMode ); @@ -298,11 +273,7 @@ protected: void xCheckRDCostMerge2Nx2N ( CodingStructure *&tempCS, CodingStructure *&bestCS, Partitioner &pm, const EncTestMode& encTestMode ); -#if !JVET_Q0806 - void xCheckRDCostMergeTriangle2Nx2N( CodingStructure *&tempCS, CodingStructure *&bestCS, Partitioner &pm, const EncTestMode& encTestMode ); -#else void xCheckRDCostMergeGeo2Nx2N(CodingStructure *&tempCS, CodingStructure *&bestCS, Partitioner &pm, const EncTestMode& encTestMode); -#endif void xEncodeInterResidual( CodingStructure *&tempCS , CodingStructure *&bestCS diff --git a/source/Lib/EncoderLib/EncGOP.cpp b/source/Lib/EncoderLib/EncGOP.cpp index 770838aa12d4b1162337abd4f58d43a6ff65264f..813605db2abcd00823ea1cf9cae4ea9e69bc334e 100644 --- a/source/Lib/EncoderLib/EncGOP.cpp +++ b/source/Lib/EncoderLib/EncGOP.cpp @@ -55,9 +55,7 @@ #include "CommonLib/UnitTools.h" #include "CommonLib/dtrace_codingstruct.h" #include "CommonLib/dtrace_buffer.h" -#if JVET_Q0436_CABAC_ZERO_WORD || JVET_P0188_MINCR #include "CommonLib/ProfileLevelTier.h" -#endif #include "DecoderLib/DecLib.h" @@ -317,7 +315,6 @@ int EncGOP::xWriteVPS (AccessUnit &accessUnit, const VPS *vps) accessUnit.push_back(new NALUnitEBSP(nalu)); return (int)(accessUnit.back()->m_nalUnitData.str().size()) * 8; } -#if JVET_Q0117_PARAMETER_SETS_CLEANUP int EncGOP::xWriteDCI(AccessUnit& accessUnit, const DCI* dci) { OutputNALUnit nalu(NAL_UNIT_DCI); @@ -327,24 +324,6 @@ int EncGOP::xWriteDCI(AccessUnit& accessUnit, const DCI* dci) accessUnit.push_back(new NALUnitEBSP(nalu)); return (int)(accessUnit.back()->m_nalUnitData.str().size()) * 8; } -#else -int EncGOP::xWriteDPS (AccessUnit &accessUnit, const DPS *dps) -{ - if (dps->getDecodingParameterSetId() !=0) - { - OutputNALUnit nalu(NAL_UNIT_DPS); - m_HLSWriter->setBitstream( &nalu.m_Bitstream ); - CHECK( nalu.m_temporalId, "The value of TemporalId of DPS NAL units shall be equal to 0" ); - m_HLSWriter->codeDPS( dps ); - accessUnit.push_back(new NALUnitEBSP(nalu)); - return (int)(accessUnit.back()->m_nalUnitData.str().size()) * 8; - } - else - { - return 0; - } -} -#endif int EncGOP::xWriteSPS( AccessUnit &accessUnit, const SPS *sps, const int layerId ) { @@ -382,43 +361,23 @@ int EncGOP::xWriteAPS( AccessUnit &accessUnit, APS *aps, const int layerId, cons return (int)(accessUnit.back()->m_nalUnitData.str().size()) * 8; } -#if ENABLING_MULTI_SPS int EncGOP::xWriteParameterSets(AccessUnit &accessUnit, Slice *slice, const bool bSeqFirst, const int layerIdx) -#else -int EncGOP::xWriteParameterSets(AccessUnit &accessUnit, Slice *slice, const bool bSeqFirst) -#endif { int actualTotalBits = 0; if( bSeqFirst ) { -#if ENABLING_MULTI_SPS if (layerIdx == 0) { -#if JVET_Q0117_PARAMETER_SETS_CLEANUP if (m_pcCfg->getDCIEnabled()) { actualTotalBits += xWriteDCI(accessUnit, m_pcEncLib->getDCI()); } -#else - actualTotalBits += xWriteDPS(accessUnit, m_pcEncLib->getDPS()); -#endif if (slice->getSPS()->getVPSId() != 0) { actualTotalBits += xWriteVPS(accessUnit, m_pcEncLib->getVPS()); } } -#else - if (slice->getSPS()->getVPSId() != 0) - { - actualTotalBits += xWriteVPS(accessUnit, m_pcEncLib->getVPS()); - } -#if JVET_Q0117_PARAMETER_SETS_CLEANUP - actualTotalBits += xWriteDCI( accessUnit, m_pcEncLib->getDCI() ); -#else - actualTotalBits += xWriteDPS( accessUnit, m_pcEncLib->getDPS() ); -#endif -#endif if( m_pcEncLib->SPSNeedsWriting( slice->getSPS()->getSPSId() ) ) // Note this assumes that all changes to the SPS are made at the EncLib level prior to picture creation (EncLib::xGetNewPicBuffer). { CHECK( !( bSeqFirst ), "Unspecified error" ); // Implementations that use more than 1 SPS need to be aware of activation issues. @@ -440,11 +399,7 @@ int EncGOP::xWritePicHeader( AccessUnit &accessUnit, PicHeader *picHeader ) m_HLSWriter->setBitstream( &nalu.m_Bitstream ); nalu.m_temporalId = accessUnit.temporalId; nalu.m_nuhLayerId = m_pcEncLib->getLayerId(); -#if JVET_Q0775_PH_IN_SH m_HLSWriter->codePictureHeader( picHeader, true ); -#else - m_HLSWriter->codePictureHeader( picHeader ); -#endif accessUnit.push_back(new NALUnitEBSP(nalu)); return (int)(accessUnit.back()->m_nalUnitData.str().size()) * 8; } @@ -519,7 +474,6 @@ void EncGOP::xWriteLeadingSEIOrdered (SEIMessages& seiMessages, SEIMessages& duI { AccessUnit::iterator itNalu = accessUnit.begin(); -#if JVET_Q0117_PARAMETER_SETS_CLEANUP while ((itNalu != accessUnit.end()) && ((*itNalu)->m_nalUnitType == NAL_UNIT_ACCESS_UNIT_DELIMITER || (*itNalu)->m_nalUnitType == NAL_UNIT_VPS @@ -527,15 +481,6 @@ void EncGOP::xWriteLeadingSEIOrdered (SEIMessages& seiMessages, SEIMessages& duI || (*itNalu)->m_nalUnitType == NAL_UNIT_SPS || (*itNalu)->m_nalUnitType == NAL_UNIT_PPS )) -#else - 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++; } @@ -573,7 +518,6 @@ void EncGOP::xWriteLeadingSEIOrdered (SEIMessages& seiMessages, SEIMessages& duI xClearSEIs(currentMessages, !testWrite); } -#if JVET_P0190_SCALABLE_NESTING_SEI if (m_pcCfg->getScalableNestingSEIEnabled()) { // Scalable nesting SEI must always be the following DU info @@ -581,7 +525,6 @@ void EncGOP::xWriteLeadingSEIOrdered (SEIMessages& seiMessages, SEIMessages& duI xWriteSEISeparately(NAL_UNIT_PREFIX_SEI, currentMessages, accessUnit, itNalu, temporalId, sps); xClearSEIs(currentMessages, !testWrite); } -#endif // And finally everything else one by one @@ -714,11 +657,7 @@ void EncGOP::xCreateIRAPLeadingSEIMessages (SEIMessages& seiMessages, const SPS m_seiEncoder.initSEIGcmp(sei); seiMessages.push_back(sei); } -#if JVET_SUBPIC_LEVEL_CFG if (m_pcCfg->getSubpicureLevelInfoSEICfg().m_enabled) -#else - if (m_pcCfg->getSubpicureLevelInfoSEIEnabled()) -#endif { SEISubpicureLevelInfo *seiSubpicureLevelInfo = new SEISubpicureLevelInfo; m_seiEncoder.initSEISubpictureLevelInfo(seiSubpicureLevelInfo, sps); @@ -774,14 +713,8 @@ void EncGOP::xCreateIRAPLeadingSEIMessages (SEIMessages& seiMessages, const SPS void EncGOP::xCreatePerPictureSEIMessages (int picInGOP, SEIMessages& seiMessages, SEIMessages& nestedSeiMessages, Slice *slice) { if ((m_pcCfg->getBufferingPeriodSEIEnabled()) && (slice->isIRAP() || slice->getNalUnitType() == NAL_UNIT_CODED_SLICE_GDR) && -#if JVET_P0125_SEI_CONSTRAINTS - slice->getNalUnitLayerId()==slice->getVPS()->getLayerId(0) && -#endif -#if JVET_P0118_HRD_ASPECTS + slice->getNalUnitLayerId()==slice->getVPS()->getLayerId(0) && (slice->getSPS()->getGeneralHrdParametersPresentFlag())) -#else - ( slice->getSPS()->getHrdParametersPresentFlag() ) ) -#endif { SEIBufferingPeriod *bufferingPeriodSEI = new SEIBufferingPeriod(); bool noLeadingPictures = ( (slice->getNalUnitType()!= NAL_UNIT_CODED_SLICE_IDR_W_RADL) && (slice->getNalUnitType()!= NAL_UNIT_CODED_SLICE_CRA) )?(true):(false); @@ -790,14 +723,12 @@ void EncGOP::xCreatePerPictureSEIMessages (int picInGOP, SEIMessages& seiMessage seiMessages.push_back(bufferingPeriodSEI); m_bufferingPeriodSEIPresentInAU = true; -#if JVET_P0190_SCALABLE_NESTING_SEI if (m_pcCfg->getScalableNestingSEIEnabled()) { SEIBufferingPeriod *bufferingPeriodSEIcopy = new SEIBufferingPeriod(); bufferingPeriodSEI->copyTo(*bufferingPeriodSEIcopy); nestedSeiMessages.push_back(bufferingPeriodSEIcopy); } -#endif } @@ -810,7 +741,6 @@ void EncGOP::xCreatePerPictureSEIMessages (int picInGOP, SEIMessages& seiMessage } -#if JVET_P0190_SCALABLE_NESTING_SEI void EncGOP::xCreateScalableNestingSEI(SEIMessages& seiMessages, SEIMessages& nestedSeiMessages) { SEIMessages tmpMessages; @@ -820,12 +750,11 @@ void EncGOP::xCreateScalableNestingSEI(SEIMessages& seiMessages, SEIMessages& ne nestedSeiMessages.pop_front(); tmpMessages.push_back(sei); SEIScalableNesting *nestingSEI = new SEIScalableNesting(); - m_seiEncoder.initSEIScalableNesting(nestingSEI, tmpMessages); + m_seiEncoder.initSEIScalableNesting(nestingSEI, tmpMessages); seiMessages.push_back(nestingSEI); tmpMessages.clear(); } } -#endif void EncGOP::xCreateFrameFieldInfoSEI (SEIMessages& seiMessages, Slice *slice, bool isField) @@ -854,18 +783,10 @@ void EncGOP::xCreatePictureTimingSEI (int IRAPGOPid, SEIMessages& seiMessages, return; } -#if JVET_P0118_HRD_ASPECTS const GeneralHrdParams *hrd = slice->getSPS()->getGeneralHrdParameters(); -#else - const HRDParameters *hrd = slice->getSPS()->getHrdParameters(); -#endif // update decoding unit parameters -#if JVET_P0125_SEI_CONSTRAINTS if ((m_pcCfg->getPictureTimingSEIEnabled() || m_pcCfg->getDecodingUnitInfoSEIEnabled()) && slice->getNalUnitLayerId() == slice->getVPS()->getLayerId(0)) -#else - if( ( m_pcCfg->getPictureTimingSEIEnabled() || m_pcCfg->getDecodingUnitInfoSEIEnabled() ) ) -#endif { int picSptDpbOutputDuDelay = 0; SEIPictureTiming *pictureTimingSEI = new SEIPictureTiming(); @@ -1078,14 +999,16 @@ void EncGOP::xCreatePictureTimingSEI (int IRAPGOPid, SEIMessages& seiMessages, { seiMessages.push_back(pictureTimingSEI); -#if JVET_P0190_SCALABLE_NESTING_SEI - if (m_pcCfg->getScalableNestingSEIEnabled()) +#if JVET_Q0394_TIMING_SEI + if (m_pcCfg->getScalableNestingSEIEnabled() && !m_pcCfg->getSamePicTimingInAllOLS()) +#else + if (m_pcCfg->getScalableNestingSEIEnabled()) +#endif { SEIPictureTiming *pictureTimingSEIcopy = new SEIPictureTiming(); pictureTimingSEI->copyTo(*pictureTimingSEIcopy); nestedSeiMessages.push_back(pictureTimingSEIcopy); } -#endif } if( m_pcCfg->getDecodingUnitInfoSEIEnabled() && hrd->getGeneralDecodingUnitHrdParamsPresentFlag() ) @@ -1153,11 +1076,7 @@ void EncGOP::xUpdateTimingSEI(SEIPictureTiming *pictureTimingSEI, std::deque<DUD { return; } -#if JVET_P0118_HRD_ASPECTS const GeneralHrdParams *hrd = sps->getGeneralHrdParameters(); -#else - const HRDParameters *hrd = sps->getHrdParameters(); -#endif if( hrd->getGeneralDecodingUnitHrdParamsPresentFlag() ) { int i; @@ -1188,11 +1107,7 @@ void EncGOP::xUpdateTimingSEI(SEIPictureTiming *pictureTimingSEI, std::deque<DUD for( i = ( numDU - 2 ); i >= 0; i -- ) { -#if JVET_P0118_HRD_ASPECTS ui64Tmp = (((duData[numDU - 1].accumBitsDU - duData[i].accumBitsDU) * (sps->getGeneralHrdParameters()->getTimeScale() / sps->getGeneralHrdParameters()->getNumUnitsInTick()) * (hrd->getTickDivisorMinus2() + 2)) / (m_pcCfg->getTargetBitrate())); -#else - ui64Tmp = ( ( ( duData[numDU - 1].accumBitsDU - duData[i].accumBitsDU ) * ( sps->getTimingInfo()->getTimeScale() / sps->getTimingInfo()->getNumUnitsInTick() ) * ( hrd->getTickDivisorMinus2() + 2 ) ) / ( m_pcCfg->getTargetBitrate() ) ); -#endif if( (uint32_t)ui64Tmp > maxDiff ) { tmp ++; @@ -1204,11 +1119,7 @@ void EncGOP::xUpdateTimingSEI(SEIPictureTiming *pictureTimingSEI, std::deque<DUD for( i = ( numDU - 2 ); i >= 0; i -- ) { flag = 0; -#if JVET_P0118_HRD_ASPECTS ui64Tmp = (((duData[numDU - 1].accumBitsDU - duData[i].accumBitsDU) * (sps->getGeneralHrdParameters()->getTimeScale() / sps->getGeneralHrdParameters()->getNumUnitsInTick()) * (hrd->getTickDivisorMinus2() + 2)) / (m_pcCfg->getTargetBitrate())); -#else - ui64Tmp = ( ( ( duData[numDU - 1].accumBitsDU - duData[i].accumBitsDU ) * ( sps->getTimingInfo()->getTimeScale() / sps->getTimingInfo()->getNumUnitsInTick() ) * ( hrd->getTickDivisorMinus2() + 2 ) ) / ( m_pcCfg->getTargetBitrate() ) ); -#endif if( (uint32_t)ui64Tmp > maxDiff ) { @@ -1257,13 +1168,12 @@ void EncGOP::xUpdateDuInfoSEI(SEIMessages &duInfoSeiMessages, SEIPictureTiming * } } -#if JVET_P0188_MINCR static void validateMinCrRequirements(const ProfileLevelTierFeatures &plt, std::size_t numBytesInVclNalUnits, const Picture *pPic, const EncCfg *pCfg) { // numBytesInVclNalUnits shall be less than or equal to - // FormatCapabilityFactor * MaxLumaSr * framePeriod ÷ MinCr, - // ( = FormatCapabilityFactor * MaxLumaSr ÷ (MinCr * frameRate), + // FormatCapabilityFactor * MaxLumaSr * framePeriod / MinCr, + // ( = FormatCapabilityFactor * MaxLumaSr / (MinCr * frameRate), if (plt.getLevelTierFeatures() && plt.getProfileFeatures() && plt.getLevelTierFeatures()->level!=Level::LEVEL8_5) { const uint32_t formatCapabilityFactorx1000 = plt.getProfileFeatures()->formatCapabilityFactorx1000; @@ -1283,9 +1193,7 @@ validateMinCrRequirements(const ProfileLevelTierFeatures &plt, std::size_t numBy } } } -#endif -#if JVET_Q0436_CABAC_ZERO_WORD static void cabac_zero_word_padding(const Slice *const pcSlice, const Picture *const pcPic, @@ -1294,42 +1202,25 @@ cabac_zero_word_padding(const Slice *const pcSlice, std::ostringstream &nalUnitData, const bool cabacZeroWordPaddingEnabled, const ProfileLevelTierFeatures &plt) -#else -static void -cabac_zero_word_padding(Slice *const pcSlice, Picture *const pcPic, const std::size_t binCountsInNalUnits, const std::size_t numBytesInVclNalUnits, std::ostringstream &nalUnitData, const bool cabacZeroWordPaddingEnabled) -#endif { const SPS &sps=*(pcSlice->getSPS()); const ChromaFormat format = sps.getChromaFormatIdc(); const int log2subWidthCxsubHeightC = (::getComponentScaleX(COMPONENT_Cb, format)+::getComponentScaleY(COMPONENT_Cb, format)); -#if JVET_Q0468_Q0469_MIN_LUMA_CB_AND_MIN_QT_FIX const int minCuWidth = 1 << pcSlice->getSPS()->getLog2MinCodingBlockSize(); const int minCuHeight = 1 << pcSlice->getSPS()->getLog2MinCodingBlockSize(); -#else - const int minCuWidth = pcPic->cs->pcv->minCUWidth; - const int minCuHeight = pcPic->cs->pcv->minCUHeight; -#endif const int paddedWidth = ( ( pcSlice->getPPS()->getPicWidthInLumaSamples() + minCuWidth - 1 ) / minCuWidth ) * minCuWidth; const int paddedHeight = ( ( pcSlice->getPPS()->getPicHeightInLumaSamples() + minCuHeight - 1 ) / minCuHeight ) * minCuHeight; const int rawBits = paddedWidth * paddedHeight * (sps.getBitDepth(CHANNEL_TYPE_LUMA) + ((2*sps.getBitDepth(CHANNEL_TYPE_CHROMA))>>log2subWidthCxsubHeightC)); -#if JVET_Q0436_CABAC_ZERO_WORD const int vclByteScaleFactor_x3 = ( 32 + 4 * (plt.getTier()==Level::HIGH ? 1 : 0) ); const std::size_t threshold = (vclByteScaleFactor_x3*numBytesInVclNalUnits/3) + (rawBits/32); // "The value of BinCountsInPicNalUnits shall be less than or equal to vclByteScaleFactor * NumBytesInPicVclNalUnits + ( RawMinCuBits * PicSizeInMinCbsY ) / 32." // binCountsInNalUnits <= vclByteScaleFactor_x3 * numBytesInVclNalUnits / 3 + rawBits / 32. // If it is currently not, then add cabac_zero_words to increase numBytesInVclNalUnits. -#else - const std::size_t threshold = (32/3)*numBytesInVclNalUnits + (rawBits/32); -#endif if (binCountsInNalUnits >= threshold) { // need to add additional cabac zero words (each one accounts for 3 bytes (=00 00 03)) to increase numBytesInVclNalUnits -#if JVET_Q0436_CABAC_ZERO_WORD const std::size_t targetNumBytesInVclNalUnits = ((binCountsInNalUnits - (rawBits/32))*3+vclByteScaleFactor_x3-1)/vclByteScaleFactor_x3; -#else - const std::size_t targetNumBytesInVclNalUnits = ((binCountsInNalUnits - (rawBits/32))*3+31)/32; -#endif if (targetNumBytesInVclNalUnits>numBytesInVclNalUnits) // It should be! { @@ -1814,8 +1705,7 @@ void EncGOP::xPicInitRateControl(int &estimatedBits, int gopId, double &lambda, } else if ( frameLevel == 0 ) // intra case, but use the model { - m_pcSliceEncoder->calCostSliceI(pic); // TODO: This only analyses the first slice segment - what about the others? - + m_pcSliceEncoder->calCostPictureI(pic); if ( m_pcCfg->getIntraPeriod() != 1 ) // do not refine allocated bits for all intra case { int bits = m_pcRateCtrl->getRCSeq()->getLeftAverageBits(); @@ -1922,13 +1812,6 @@ void EncGOP::xPicInitLMCS(Picture *pic, PicHeader *picHeader, Slice *slice) m_pcReshaper->setCTUFlag(false); - //reshape original signal - if (m_pcReshaper->getSliceReshaperInfo().getUseSliceReshaper()) - { - pic->getOrigBuf(COMPONENT_Y).rspSignal(m_pcReshaper->getFwdLUT()); - m_pcReshaper->setSrcReshaped(true); - m_pcReshaper->setRecReshaped(true); - } } else { @@ -1963,9 +1846,7 @@ void EncGOP::xPicInitLMCS(Picture *pic, PicHeader *picHeader, Slice *slice) //set all necessary information in LMCS APS and picture header picHeader->setLmcsEnabledFlag(m_pcReshaper->getSliceReshaperInfo().getUseSliceReshaper()); -#if JVET_Q0346_LMCS_ENABLE_IN_SH slice->setLmcsEnabledFlag(m_pcReshaper->getSliceReshaperInfo().getUseSliceReshaper()); -#endif picHeader->setLmcsChromaResidualScaleFlag(m_pcReshaper->getSliceReshaperInfo().getSliceReshapeChromaAdj() == 1); if (m_pcReshaper->getSliceReshaperInfo().getSliceReshapeModelPresentFlag()) { @@ -2115,11 +1996,9 @@ void EncGOP::compressGOP( int iPOCLast, int iNumPicRcvd, PicList& rcListPic, picHeader->setSPSId( pcPic->cs->pps->getSPSId() ); picHeader->setPPSId( pcPic->cs->pps->getPPSId() ); picHeader->setSplitConsOverrideFlag(false); -#if JVET_Q0819_PH_CHANGES // initial two flags to be false picHeader->setPicInterSliceAllowedFlag(false); picHeader->setPicIntraSliceAllowedFlag(false); -#endif #if ER_CHROMA_QP_WCG_PPS // th this is a hot fix for the choma qp control if( m_pcEncLib->getWCGChromaQPControl().isEnabled() && m_pcEncLib->getSwitchPOC() != -1 ) @@ -2141,11 +2020,7 @@ void EncGOP::compressGOP( int iPOCLast, int iNumPicRcvd, PicList& rcListPic, const int maxCUWidth = pcPic->cs->sps->getMaxCUWidth(); const int maxCUHeight = pcPic->cs->sps->getMaxCUHeight(); const ChromaFormat chromaFormatIDC = pcPic->cs->sps->getChromaFormatIdc(); -#if JVET_Q0468_Q0469_MIN_LUMA_CB_AND_MIN_QT_FIX const int maxTotalCUDepth = floorLog2(maxCUWidth) - pcPic->cs->sps->getLog2MinCodingBlockSize(); -#else - const int maxTotalCUDepth = pcPic->cs->sps->getMaxCodingDepth(); -#endif m_pcSliceEncoder->create( picWidth, picHeight, chromaFormatIDC, maxCUWidth, maxCUHeight, maxTotalCUDepth ); @@ -2187,7 +2062,6 @@ void EncGOP::compressGOP( int iPOCLast, int iNumPicRcvd, PicList& rcListPic, // Set the nal unit type pcSlice->setNalUnitType(getNalUnitType(pocCurr, m_iLastIDR, isField)); -#if JVET_Q0819_PH_CHANGES // set two flags according to slice type presented in the picture if (pcSlice->getSliceType() != I_SLICE) { @@ -2198,7 +2072,6 @@ void EncGOP::compressGOP( int iPOCLast, int iNumPicRcvd, PicList& rcListPic, picHeader->setPicIntraSliceAllowedFlag(true); } picHeader->setGdrOrIrapPicFlag(picHeader->getGdrPicFlag() || pcSlice->isIRAP()); -#endif if (m_pcCfg->getEfficientFieldIRAPEnabled()) { @@ -2297,11 +2170,7 @@ void EncGOP::compressGOP( int iPOCLast, int iNumPicRcvd, PicList& rcListPic, xCreateExplicitReferencePictureSetFromReference( pcSlice, rcListPic, pcSlice->getRPL0(), pcSlice->getRPL1() ); } -#if JVET_Q0751_MIXED_NAL_UNIT_TYPES pcSlice->applyReferencePictureListBasedMarking( rcListPic, pcSlice->getRPL0(), pcSlice->getRPL1(), pcSlice->getPic()->layerId, *(pcSlice->getPPS())); -#else - pcSlice->applyReferencePictureListBasedMarking( rcListPic, pcSlice->getRPL0(), pcSlice->getRPL1(), pcSlice->getPic()->layerId ); -#endif if(pcSlice->getTLayer() > 0 && !(pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_RADL // Check if not a leading picture @@ -2312,12 +2181,6 @@ void EncGOP::compressGOP( int iPOCLast, int iNumPicRcvd, PicList& rcListPic, { bool isSTSA=true; -#if !JVET_Q0156_STSA - if( !m_pcEncLib->getVPS()->getAllIndependentLayersFlag() && m_pcEncLib->getVPS()->getGeneralLayerIdx( m_pcEncLib->getLayerId() ) ) - { - isSTSA = false; - } -#endif for(int ii=0;(ii<m_pcCfg->getGOPSize() && isSTSA==true);ii++) { @@ -2387,7 +2250,7 @@ void EncGOP::compressGOP( int iPOCLast, int iNumPicRcvd, PicList& rcListPic, } // Set reference list pcSlice->constructRefPicList(rcListPic); - + xPicInitHashME( pcPic, pcSlice->getPPS(), rcListPic ); if( m_pcCfg->getUseAMaxBT() ) @@ -2406,23 +2269,23 @@ void EncGOP::compressGOP( int iPOCLast, int iNumPicRcvd, PicList& rcListPic, if( refLayer >= 0 && m_uiNumBlk[refLayer] != 0 ) { -#if JVET_Q0330_BLOCK_PARTITION - const int MAX_BT_SIZE_INTER = 128; -#endif picHeader->setSplitConsOverrideFlag(true); double dBlkSize = sqrt( ( double ) m_uiBlkSize[refLayer] / m_uiNumBlk[refLayer] ); - if( dBlkSize < AMAXBT_TH32 || pcPic->cs->sps->getCTUSize()==32 ) + unsigned int newMaxBtSize = picHeader->getMaxBTSize(pcSlice->getSliceType(), CHANNEL_TYPE_LUMA); + if( dBlkSize < AMAXBT_TH32 ) { - picHeader->setMaxBTSize( 1, 32 > MAX_BT_SIZE_INTER ? MAX_BT_SIZE_INTER : 32 ); + newMaxBtSize = 32; } - else if( dBlkSize < AMAXBT_TH64 || pcPic->cs->sps->getCTUSize()==64 ) + else if( dBlkSize < AMAXBT_TH64 ) { - picHeader->setMaxBTSize( 1, 64 > MAX_BT_SIZE_INTER ? MAX_BT_SIZE_INTER : 64 ); + newMaxBtSize = 64; } else { - picHeader->setMaxBTSize( 1, 128 > MAX_BT_SIZE_INTER ? MAX_BT_SIZE_INTER : 128 ); + newMaxBtSize = 128; } + newMaxBtSize = Clip3(picHeader->getMinQTSize(pcSlice->getSliceType()), pcPic->cs->sps->getCTUSize(), newMaxBtSize); + picHeader->setMaxBTSize(1, newMaxBtSize); m_uiBlkSize[refLayer] = 0; m_uiNumBlk [refLayer] = 0; @@ -2528,16 +2391,7 @@ void EncGOP::compressGOP( int iPOCLast, int iNumPicRcvd, PicList& rcListPic, for( int refIdx = 0; refIdx < pcSlice->getNumRefIdx( REF_PIC_LIST_0 ); refIdx++ ) { -#if JVET_Q0487_SCALING_WINDOW_ISSUES if( pcSlice->getRefPic( REF_PIC_LIST_0, refIdx )->isRefScaled( pcSlice->getPPS() ) == false ) -#else - int refPicWidth = pcSlice->getRefPic( REF_PIC_LIST_0, refIdx )->unscaledPic->cs->pps->getPicWidthInLumaSamples(); - int refPicHeight = pcSlice->getRefPic( REF_PIC_LIST_0, refIdx )->unscaledPic->cs->pps->getPicHeightInLumaSamples(); - int curPicWidth = pcSlice->getPPS()->getPicWidthInLumaSamples(); - int curPicHeight = pcSlice->getPPS()->getPicHeightInLumaSamples(); - - if( refPicWidth == curPicWidth && refPicHeight == curPicHeight ) -#endif { colRefIdxL0 = refIdx; break; @@ -2548,16 +2402,7 @@ void EncGOP::compressGOP( int iPOCLast, int iNumPicRcvd, PicList& rcListPic, { for( int refIdx = 0; refIdx < pcSlice->getNumRefIdx( REF_PIC_LIST_1 ); refIdx++ ) { -#if JVET_Q0487_SCALING_WINDOW_ISSUES if( pcSlice->getRefPic( REF_PIC_LIST_1, refIdx )->isRefScaled( pcSlice->getPPS() ) == false ) -#else - int refPicWidth = pcSlice->getRefPic( REF_PIC_LIST_1, refIdx )->unscaledPic->cs->pps->getPicWidthInLumaSamples(); - int refPicHeight = pcSlice->getRefPic( REF_PIC_LIST_1, refIdx )->unscaledPic->cs->pps->getPicHeightInLumaSamples(); - int curPicWidth = pcSlice->getPPS()->getPicWidthInLumaSamples(); - int curPicHeight = pcSlice->getPPS()->getPicHeightInLumaSamples(); - - if( refPicWidth == curPicWidth && refPicHeight == curPicHeight ) -#endif { colRefIdxL1 = refIdx; break; @@ -2580,36 +2425,24 @@ void EncGOP::compressGOP( int iPOCLast, int iNumPicRcvd, PicList& rcListPic, } const uint32_t uiColFromL0 = refPicL0->slices[0]->getSliceQp() > refPicL1->slices[0]->getSliceQp(); -#if JVET_Q0482_REMOVE_CONSTANT_PARAMS picHeader->setPicColFromL0Flag( uiColFromL0 ); -#endif pcSlice->setColFromL0Flag( uiColFromL0 ); pcSlice->setColRefIdx( uiColFromL0 ? colRefIdxL0 : colRefIdxL1 ); -#if JVET_Q0259_COLLOCATED_PIC_IN_PH picHeader->setColRefIdx( uiColFromL0 ? colRefIdxL0 : colRefIdxL1 ); -#endif } else if( colRefIdxL0 < 0 && colRefIdxL1 >= 0 ) { -#if JVET_Q0482_REMOVE_CONSTANT_PARAMS picHeader->setPicColFromL0Flag( false ); -#endif pcSlice->setColFromL0Flag( false ); pcSlice->setColRefIdx( colRefIdxL1 ); -#if JVET_Q0259_COLLOCATED_PIC_IN_PH picHeader->setColRefIdx( colRefIdxL1 ); -#endif } else if( colRefIdxL0 >= 0 && colRefIdxL1 < 0 ) { -#if JVET_Q0482_REMOVE_CONSTANT_PARAMS picHeader->setPicColFromL0Flag( true ); -#endif pcSlice->setColFromL0Flag( true ); pcSlice->setColRefIdx( colRefIdxL0 ); -#if JVET_Q0259_COLLOCATED_PIC_IN_PH picHeader->setColRefIdx( colRefIdxL0 ); -#endif } else { @@ -2748,11 +2581,7 @@ void EncGOP::compressGOP( int iPOCLast, int iNumPicRcvd, PicList& rcListPic, // Allocate some coders, now the number of tiles are known. const uint32_t numberOfCtusInFrame = pcPic->cs->pcv->sizeInCtus; const int numSubstreamsColumns = pcSlice->getPPS()->getNumTileColumns(); -#if JVET_Q0151_Q0205_ENTRYPOINTS const int numSubstreamRows = pcSlice->getSPS()->getEntropyCodingSyncEnabledFlag() ? pcPic->cs->pcv->heightInCtus : (pcSlice->getPPS()->getNumTileRows()); -#else - const int numSubstreamRows = pcSlice->getPPS()->getEntropyCodingSyncEnabledFlag() ? pcPic->cs->pcv->heightInCtus : (pcSlice->getPPS()->getNumTileRows()); -#endif const int numSubstreams = std::max<int> (numSubstreamRows * numSubstreamsColumns, (int) pcPic->cs->pps->getNumSlicesInPic()); std::vector<OutputBitstream> substreamsOut(numSubstreams); @@ -2808,12 +2637,8 @@ void EncGOP::compressGOP( int iPOCLast, int iNumPicRcvd, PicList& rcListPic, if( pcSlice->getSPS()->getScalingListFlag() && m_pcCfg->getUseScalingListId() == SCALING_LIST_FILE_READ ) { -#if JVET_Q0346_SCALING_LIST_USED_IN_SH picHeader->setExplicitScalingListEnabledFlag( true ); pcSlice->setExplicitScalingListUsed( true ); -#else - picHeader->setScalingListPresentFlag( true ); -#endif int apsId = std::min<int>( 7, m_pcEncLib->getVPS() == nullptr ? 0 : m_pcEncLib->getVPS()->getGeneralLayerIdx( m_pcEncLib->getLayerId() ) ); picHeader->setScalingListAPSId( apsId ); @@ -2826,7 +2651,7 @@ void EncGOP::compressGOP( int iPOCLast, int iNumPicRcvd, PicList& rcListPic, pcPic->cs->picHeader->setPic(pcPic); pcPic->cs->picHeader->setValid(); - if(pcPic->cs->sps->getFpelMmvdEnabledFlag()) + if(pcPic->cs->sps->getFpelMmvdEnabledFlag()) { // cannot set ph_fpel_mmvd_enabled_flag at slice level - need new picture-level version of checkDisFracMmvd algorithm? // m_pcSliceEncoder->checkDisFracMmvd( pcPic, 0, numberOfCtusInFrame ); @@ -2841,11 +2666,13 @@ void EncGOP::compressGOP( int iPOCLast, int iNumPicRcvd, PicList& rcListPic, // now compress (trial encode) the various slice segments (slices, and dependent slices) { DTRACE_UPDATE( g_trace_ctx, ( std::make_pair( "poc", pocCurr ) ) ); +#if JVET_R0110_MIXED_LOSSLESS + const std::vector<uint32_t> sliceLosslessArray = *(m_pcCfg->getSliceLosslessArray()); +#endif for(uint32_t sliceIdx = 0; sliceIdx < pcPic->cs->pps->getNumSlicesInPic(); sliceIdx++ ) { pcSlice->setSliceMap( pcPic->cs->pps->getSliceMap( sliceIdx ) ); -#if JVET_Q0044_SLICE_IDX_WITH_SUBPICS if( pcPic->cs->pps->getRectSliceFlag() ) { Position firstCtu; @@ -2864,7 +2691,36 @@ void EncGOP::compressGOP( int iPOCLast, int iNumPicRcvd, PicList& rcListPic, pcSlice->setSliceSubPicId( pcPic->cs->pps->getSubPic( subPicIdx ).getSubPicID() ); } + if (pcPic->cs->sps->getUseLmcs()) + { + pcSlice->setLmcsEnabledFlag(picHeader->getLmcsEnabledFlag()); + if (pcSlice->getSliceType() == I_SLICE) + { + //reshape original signal + if (pcSlice->getLmcsEnabledFlag()) + { + pcPic->getOrigBuf(COMPONENT_Y).rspSignal(m_pcReshaper->getFwdLUT()); + m_pcReshaper->setSrcReshaped(true); + m_pcReshaper->setRecReshaped(true); + } + else + { + pcPic->getOrigBuf().copyFrom(pcPic->getTrueOrigBuf()); + m_pcReshaper->setSrcReshaped(false); + m_pcReshaper->setRecReshaped(false); + } + } + } + +#if JVET_R0110_MIXED_LOSSLESS + bool isLossless = false; + if (m_pcCfg->getCostMode() == COST_LOSSLESS_CODING) + { + isLossless = (sliceLosslessArray[sliceIdx] != 0); + } + m_pcSliceEncoder->setLosslessSlice(pcPic, isLossless); #endif + m_pcSliceEncoder->precompressSlice( pcPic ); m_pcSliceEncoder->compressSlice ( pcPic, false, false ); @@ -2889,20 +2745,29 @@ void EncGOP::compressGOP( int iPOCLast, int iNumPicRcvd, PicList& rcListPic, CodingStructure& cs = *pcPic->cs; pcSlice = pcPic->slices[0]; - if (pcSlice->getSPS()->getUseLmcs() && m_pcReshaper->getSliceReshaperInfo().getUseSliceReshaper()) + if (cs.sps->getUseLmcs() && m_pcReshaper->getSliceReshaperInfo().getUseSliceReshaper()) { picHeader->setLmcsEnabledFlag(true); -#if JVET_Q0346_LMCS_ENABLE_IN_SH - pcSlice->setLmcsEnabledFlag(true); -#endif - int apsId = std::min<int>( 3, m_pcEncLib->getVPS() == nullptr ? 0 : m_pcEncLib->getVPS()->getGeneralLayerIdx( m_pcEncLib->getLayerId() ) ); - + int apsId = std::min<int>(3, m_pcEncLib->getVPS() == nullptr ? 0 : m_pcEncLib->getVPS()->getGeneralLayerIdx(m_pcEncLib->getLayerId())); picHeader->setLmcsAPSId(apsId); - CHECK((m_pcReshaper->getRecReshaped() == false), "Rec picture is not reshaped!"); - pcPic->getRecoBuf(COMPONENT_Y).rspSignal(m_pcReshaper->getInvLUT()); - m_pcReshaper->setRecReshaped(false); - pcPic->getOrigBuf().copyFrom(pcPic->getTrueOrigBuf()); + const PreCalcValues& pcv = *cs.pcv; + for (uint32_t yPos = 0; yPos < pcv.lumaHeight; yPos += pcv.maxCUHeight) + { + for (uint32_t xPos = 0; xPos < pcv.lumaWidth; xPos += pcv.maxCUWidth) + { + const CodingUnit* cu = cs.getCU(Position(xPos, yPos), CHANNEL_TYPE_LUMA); + if (cu->slice->getLmcsEnabledFlag()) + { + const uint32_t width = (xPos + pcv.maxCUWidth > pcv.lumaWidth) ? (pcv.lumaWidth - xPos) : pcv.maxCUWidth; + const uint32_t height = (yPos + pcv.maxCUHeight > pcv.lumaHeight) ? (pcv.lumaHeight - yPos) : pcv.maxCUHeight; + const UnitArea area(cs.area.chromaFormat, Area(xPos, yPos, width, height)); + cs.getRecoBuf(area).get(COMPONENT_Y).rspSignal(m_pcReshaper->getInvLUT()); + } + } + } + m_pcReshaper->setRecReshaped(false); + pcPic->getOrigBuf().copyFrom(pcPic->getTrueOrigBuf()); } // create SAO object based on the picture size @@ -2911,13 +2776,8 @@ void EncGOP::compressGOP( int iPOCLast, int iNumPicRcvd, PicList& rcListPic, const uint32_t widthInCtus = ( picWidth + maxCUWidth - 1 ) / maxCUWidth; const uint32_t heightInCtus = ( picHeight + maxCUHeight - 1 ) / maxCUHeight; const uint32_t numCtuInFrame = widthInCtus * heightInCtus; -#if JVET_Q0441_SAO_MOD_12_BIT const uint32_t log2SaoOffsetScaleLuma = (uint32_t) std::max(0, pcSlice->getSPS()->getBitDepth(CHANNEL_TYPE_LUMA ) - MAX_SAO_TRUNCATED_BITDEPTH); const uint32_t log2SaoOffsetScaleChroma = (uint32_t) std::max(0, pcSlice->getSPS()->getBitDepth(CHANNEL_TYPE_CHROMA) - MAX_SAO_TRUNCATED_BITDEPTH); -#else - const uint32_t log2SaoOffsetScaleLuma = pcPic->cs->slice->getPPS()->getPpsRangeExtension().getLog2SaoOffsetScale( CHANNEL_TYPE_LUMA ); - const uint32_t log2SaoOffsetScaleChroma = pcPic->cs->slice->getPPS()->getPpsRangeExtension().getLog2SaoOffsetScale( CHANNEL_TYPE_CHROMA ); -#endif m_pcSAO->create( picWidth, picHeight, chromaFormatIDC, maxCUWidth, maxCUHeight, maxTotalCUDepth, log2SaoOffsetScaleLuma, log2SaoOffsetScaleChroma ); m_pcSAO->destroyEncData(); @@ -2927,12 +2787,8 @@ void EncGOP::compressGOP( int iPOCLast, int iNumPicRcvd, PicList& rcListPic, if( pcSlice->getSPS()->getScalingListFlag() && m_pcCfg->getUseScalingListId() == SCALING_LIST_FILE_READ ) { -#if JVET_Q0346_SCALING_LIST_USED_IN_SH picHeader->setExplicitScalingListEnabledFlag(true); pcSlice->setExplicitScalingListUsed(true); -#else - picHeader->setScalingListPresentFlag(true); -#endif int apsId = 0; picHeader->setScalingListAPSId( apsId ); } @@ -2959,13 +2815,21 @@ void EncGOP::compressGOP( int iPOCLast, int iNumPicRcvd, PicList& rcListPic, } #endif } - +#if JVET_R0110_MIXED_LOSSLESS + if (m_pcCfg->getCostMode() == COST_LOSSLESS_CODING) + { + for (int s = 0; s < uiNumSliceSegments; s++) + { + if (pcPic->slices[s]->isLossless()) + { + pcPic->slices[s]->setDeblockingFilterDisable(true); + } + } + } +#endif m_pcLoopFilter->loopFilterPic( cs ); CS::setRefinedMotionField(cs); -#if !JVET_Q0795_CCALF - DTRACE_UPDATE( g_trace_ctx, ( std::make_pair( "final", 1 ) ) ); -#endif if( pcSlice->getSPS()->getSAOEnabledFlag() ) { @@ -2978,11 +2842,26 @@ void EncGOP::compressGOP( int iPOCLast, int iNumPicRcvd, PicList& rcListPic, #endif m_pcCfg->getTestSAODisableAtPictureLevel(), m_pcCfg->getSaoEncodingRate(), m_pcCfg->getSaoEncodingRateChroma(), m_pcCfg->getSaoCtuBoundary(), m_pcCfg->getSaoGreedyMergeEnc() ); //assign SAO slice header - for(int s=0; s< uiNumSliceSegments; s++) + for (int s = 0; s < uiNumSliceSegments; s++) { - pcPic->slices[s]->setSaoEnabledFlag(CHANNEL_TYPE_LUMA, sliceEnabled[COMPONENT_Y]); - CHECK(!(sliceEnabled[COMPONENT_Cb] == sliceEnabled[COMPONENT_Cr]), "Unspecified error"); - pcPic->slices[s]->setSaoEnabledFlag(CHANNEL_TYPE_CHROMA, sliceEnabled[COMPONENT_Cb]); + +#if JVET_R0110_MIXED_LOSSLESS + if (pcPic->slices[s]->isLossless() && m_pcCfg->getCostMode() == COST_LOSSLESS_CODING) + { + pcPic->slices[s]->setSaoEnabledFlag(CHANNEL_TYPE_LUMA, false); + pcPic->slices[s]->setSaoEnabledFlag(CHANNEL_TYPE_CHROMA, false); + } + else + { +#endif + pcPic->slices[s]->setSaoEnabledFlag(CHANNEL_TYPE_LUMA, sliceEnabled[COMPONENT_Y]); + CHECK(!(sliceEnabled[COMPONENT_Cb] == sliceEnabled[COMPONENT_Cr]), "Unspecified error"); + pcPic->slices[s]->setSaoEnabledFlag(CHANNEL_TYPE_CHROMA, sliceEnabled[COMPONENT_Cb]); + +#if JVET_R0110_MIXED_LOSSLESS + } +#endif + } } @@ -2999,15 +2878,35 @@ void EncGOP::compressGOP( int iPOCLast, int iNumPicRcvd, PicList& rcListPic, m_pcALF->ALFProcess(cs, pcSlice->getLambdas() #if ENABLE_QPA , (m_pcCfg->getUsePerceptQPA() && !m_pcCfg->getUseRateCtrl() && pcSlice->getPPS()->getUseDQP() ? m_pcEncLib->getRdCost(PARL_PARAM0(0))->getChromaWeight() : 0.0) +#endif +#if JVET_R0110_MIXED_LOSSLESS + , pcPic, uiNumSliceSegments #endif ); //assign ALF slice header for (int s = 0; s < uiNumSliceSegments; s++) { - pcPic->slices[s]->setTileGroupAlfEnabledFlag(COMPONENT_Y, cs.slice->getTileGroupAlfEnabledFlag(COMPONENT_Y)); - pcPic->slices[s]->setTileGroupAlfEnabledFlag(COMPONENT_Cb, cs.slice->getTileGroupAlfEnabledFlag(COMPONENT_Cb)); - pcPic->slices[s]->setTileGroupAlfEnabledFlag(COMPONENT_Cr, cs.slice->getTileGroupAlfEnabledFlag(COMPONENT_Cr)); +#if JVET_R0110_MIXED_LOSSLESS + //For the first slice, even if it is lossless, slice level ALF is not disabled and ALF-APS is signaled so that the later lossy slices can use APS of the first slice. + //However, if the first slice is lossless, the ALF process is disabled for all of the CTUs ( m_ctuEnableFlag == 0) of that slice which is implemented in the function void EncAdaptiveLoopFilter::ALFProcess. + + if (pcPic->slices[s]->isLossless() && s && m_pcCfg->getCostMode() == COST_LOSSLESS_CODING) + { + pcPic->slices[s]->setTileGroupAlfEnabledFlag(COMPONENT_Y, false); + pcPic->slices[s]->setTileGroupAlfEnabledFlag(COMPONENT_Cb, false); + pcPic->slices[s]->setTileGroupAlfEnabledFlag(COMPONENT_Cr, false); + } + else + { +#endif + pcPic->slices[s]->setTileGroupAlfEnabledFlag(COMPONENT_Y, cs.slice->getTileGroupAlfEnabledFlag(COMPONENT_Y)); + pcPic->slices[s]->setTileGroupAlfEnabledFlag(COMPONENT_Cb, cs.slice->getTileGroupAlfEnabledFlag(COMPONENT_Cb)); + pcPic->slices[s]->setTileGroupAlfEnabledFlag(COMPONENT_Cr, cs.slice->getTileGroupAlfEnabledFlag(COMPONENT_Cr)); + +#if JVET_R0110_MIXED_LOSSLESS + } +#endif if (pcPic->slices[s]->getTileGroupAlfEnabledFlag(COMPONENT_Y)) { pcPic->slices[s]->setTileGroupNumAps(cs.slice->getTileGroupNumAps()); @@ -3019,15 +2918,11 @@ void EncGOP::compressGOP( int iPOCLast, int iNumPicRcvd, PicList& rcListPic, } pcPic->slices[s]->setAlfAPSs(cs.slice->getAlfAPSs()); pcPic->slices[s]->setTileGroupApsIdChroma(cs.slice->getTileGroupApsIdChroma()); -#if JVET_Q0795_CCALF pcPic->slices[s]->setTileGroupCcAlfCbApsId(cs.slice->getTileGroupCcAlfCbApsId()); pcPic->slices[s]->setTileGroupCcAlfCrApsId(cs.slice->getTileGroupCcAlfCrApsId()); -#endif } } -#if JVET_Q0795_CCALF DTRACE_UPDATE( g_trace_ctx, ( std::make_pair( "final", 1 ) ) ); -#endif if (m_pcCfg->getUseCompositeRef() && getPrepareLTRef()) { updateCompositeReference(pcSlice, rcListPic, pocCurr); @@ -3084,11 +2979,7 @@ void EncGOP::compressGOP( int iPOCLast, int iNumPicRcvd, PicList& rcListPic, int layerIdx = m_pcEncLib->getVPS() == nullptr ? 0 : m_pcEncLib->getVPS()->getGeneralLayerIdx( m_pcEncLib->getLayerId() ); // it is assumed that layerIdx equal to 0 is always present -#if ENABLING_MULTI_SPS actualTotalBits += xWriteParameterSets(accessUnit, pcSlice, writePS, layerIdx); -#else - actualTotalBits += xWriteParameterSets(accessUnit, pcSlice, writePS && !layerIdx); -#endif if (writePS) { // create prefix SEI messages at the beginning of the sequence @@ -3136,11 +3027,7 @@ void EncGOP::compressGOP( int iPOCLast, int iNumPicRcvd, PicList& rcListPic, } } -#if JVET_Q0795_CCALF if (pcSlice->getSPS()->getALFEnabledFlag() && (pcSlice->getTileGroupAlfEnabledFlag(COMPONENT_Y) || pcSlice->getTileGroupCcAlfCbEnabledFlag() || pcSlice->getTileGroupCcAlfCrEnabledFlag())) -#else - if (pcSlice->getSPS()->getALFEnabledFlag() && pcSlice->getTileGroupAlfEnabledFlag(COMPONENT_Y)) -#endif { for (int apsId = 0; apsId < ALF_CTB_MAX_NUM_APS; apsId++) { @@ -3155,7 +3042,6 @@ void EncGOP::compressGOP( int iPOCLast, int iNumPicRcvd, PicList& rcListPic, *apsMap->allocatePS(apsId) = *aps; //allocate and cpy m_pcALF->setApsIdStart( apsId ); } -#if JVET_Q0795_CCALF else if (pcSlice->getTileGroupCcAlfCbEnabledFlag() && !aps && apsId == pcSlice->getTileGroupCcAlfCbApsId()) { writeAPS = true; @@ -3166,17 +3052,12 @@ void EncGOP::compressGOP( int iPOCLast, int iNumPicRcvd, PicList& rcListPic, writeAPS = true; aps = apsMap->getPS((pcSlice->getTileGroupCcAlfCrApsId() << NUM_APS_TYPE_LEN) + ALF_APS); } -#endif if (writeAPS ) { actualTotalBits += xWriteAPS( accessUnit, aps, m_pcEncLib->getLayerId(), true ); apsMap->clearChangedFlag((apsId << NUM_APS_TYPE_LEN) + ALF_APS); -#if JVET_Q0795_CCALF CHECK(aps != pcSlice->getAlfAPSs()[apsId] && apsId != pcSlice->getTileGroupCcAlfCbApsId() && apsId != pcSlice->getTileGroupCcAlfCrApsId(), "Wrong APS pointer in compressGOP"); -#else - CHECK(aps != pcSlice->getAlfAPSs()[apsId], "Wrong APS pointer in compressGOP"); -#endif } } } @@ -3204,28 +3085,16 @@ void EncGOP::compressGOP( int iPOCLast, int iNumPicRcvd, PicList& rcListPic, pcSlice->setRPL0idx(pcPic->slices[0]->getRPL0idx()); pcSlice->setRPL1idx(pcPic->slices[0]->getRPL1idx()); -#if SPS_ID_CHECK picHeader->setNoOutputBeforeRecoveryFlag( false ); -#else - pcSlice->setNoIncorrectPicOutputFlag(false); -#endif if (pcSlice->isIRAP()) { if (pcSlice->getNalUnitType() >= NAL_UNIT_CODED_SLICE_IDR_W_RADL && pcSlice->getNalUnitType() <= NAL_UNIT_CODED_SLICE_IDR_N_LP) { -#if SPS_ID_CHECK picHeader->setNoOutputBeforeRecoveryFlag( true ); -#else - pcSlice->setNoIncorrectPicOutputFlag(true); -#endif } //the inference for NoOutputPriorPicsFlag // KJS: This cannot happen at the encoder -#if SPS_ID_CHECK if( !m_bFirst && ( pcSlice->isIRAP() || pcSlice->getNalUnitType() >= NAL_UNIT_CODED_SLICE_GDR ) && picHeader->getNoOutputBeforeRecoveryFlag() ) -#else - if (!m_bFirst && (pcSlice->isIRAP() || pcSlice->getNalUnitType() >= NAL_UNIT_CODED_SLICE_GDR) && pcSlice->getNoIncorrectPicOutputFlag()) -#endif { if (pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA || pcSlice->getNalUnitType() >= NAL_UNIT_CODED_SLICE_GDR) { @@ -3235,14 +3104,11 @@ void EncGOP::compressGOP( int iPOCLast, int iNumPicRcvd, PicList& rcListPic, } // code picture header before first slice - if(sliceSegmentIdxCount == 0) + if(sliceSegmentIdxCount == 0) { // code RPL in picture header or slice headers if( !m_pcCfg->getSliceLevelRpl() && (!pcSlice->getIdrPicFlag() || pcSlice->getSPS()->getIDRRefParamListPresent()) ) { -#if !JVET_Q0819_PH_CHANGES - picHeader->setPicRplPresentFlag(true); -#endif picHeader->setRPL0idx(pcSlice->getRPL0idx()); picHeader->setRPL1idx(pcSlice->getRPL1idx()); picHeader->setRPL0(pcSlice->getRPL0()); @@ -3250,86 +3116,47 @@ void EncGOP::compressGOP( int iPOCLast, int iNumPicRcvd, PicList& rcListPic, *picHeader->getLocalRPL0() = *pcSlice->getLocalRPL0(); *picHeader->getLocalRPL1() = *pcSlice->getLocalRPL1(); } -#if !JVET_Q0819_PH_CHANGES - else { - picHeader->setPicRplPresentFlag(false); - } -#endif - + // code DBLK in picture header or slice headers if( !m_pcCfg->getSliceLevelDblk() ) { -#if !JVET_Q0819_PH_CHANGES - picHeader->setDeblockingFilterOverridePresentFlag(true); -#endif picHeader->setDeblockingFilterOverrideFlag ( pcSlice->getDeblockingFilterOverrideFlag() ); - picHeader->setDeblockingFilterDisable ( pcSlice->getDeblockingFilterDisable() ); - picHeader->setDeblockingFilterBetaOffsetDiv2 ( pcSlice->getDeblockingFilterBetaOffsetDiv2() ); + picHeader->setDeblockingFilterDisable ( pcSlice->getDeblockingFilterDisable() ); + picHeader->setDeblockingFilterBetaOffsetDiv2 ( pcSlice->getDeblockingFilterBetaOffsetDiv2() ); picHeader->setDeblockingFilterTcOffsetDiv2 ( pcSlice->getDeblockingFilterTcOffsetDiv2() ); -#if JVET_Q0121_DEBLOCKING_CONTROL_PARAMETERS picHeader->setDeblockingFilterCbBetaOffsetDiv2( pcSlice->getDeblockingFilterCbBetaOffsetDiv2() ); picHeader->setDeblockingFilterCbTcOffsetDiv2 ( pcSlice->getDeblockingFilterCbTcOffsetDiv2() ); picHeader->setDeblockingFilterCrBetaOffsetDiv2( pcSlice->getDeblockingFilterCrBetaOffsetDiv2() ); picHeader->setDeblockingFilterCrTcOffsetDiv2 ( pcSlice->getDeblockingFilterCrTcOffsetDiv2() ); -#endif - } -#if !JVET_Q0819_PH_CHANGES - else - { - picHeader->setDeblockingFilterOverridePresentFlag( false ); } -#endif -#if JVET_Q0819_PH_CHANGES if (!m_pcCfg->getSliceLevelDeltaQp()) { picHeader->setQpDelta(pcSlice->getSliceQp() - (pcSlice->getPPS()->getPicInitQPMinus26() + 26)); } -#endif // code SAO parameters in picture header or slice headers if( !m_pcCfg->getSliceLevelSao() ) { -#if !JVET_Q0819_PH_CHANGES - picHeader->setSaoEnabledPresentFlag(true); -#endif picHeader->setSaoEnabledFlag(CHANNEL_TYPE_LUMA, pcSlice->getSaoEnabledFlag(CHANNEL_TYPE_LUMA )); picHeader->setSaoEnabledFlag(CHANNEL_TYPE_CHROMA, pcSlice->getSaoEnabledFlag(CHANNEL_TYPE_CHROMA)); } -#if !JVET_Q0819_PH_CHANGES - else - { - picHeader->setSaoEnabledPresentFlag( false ); - } -#endif - + // code ALF parameters in picture header or slice headers if( !m_pcCfg->getSliceLevelAlf() ) { -#if !JVET_Q0819_PH_CHANGES - picHeader->setAlfEnabledPresentFlag(true); -#endif picHeader->setAlfEnabledFlag(COMPONENT_Y, pcSlice->getTileGroupAlfEnabledFlag(COMPONENT_Y ) ); picHeader->setAlfEnabledFlag(COMPONENT_Cb, pcSlice->getTileGroupAlfEnabledFlag(COMPONENT_Cb) ); - picHeader->setAlfEnabledFlag(COMPONENT_Cr, pcSlice->getTileGroupAlfEnabledFlag(COMPONENT_Cr) ); + picHeader->setAlfEnabledFlag(COMPONENT_Cr, pcSlice->getTileGroupAlfEnabledFlag(COMPONENT_Cr) ); picHeader->setNumAlfAps(pcSlice->getTileGroupNumAps()); picHeader->setAlfAPSs(pcSlice->getTileGroupApsIdLuma()); picHeader->setAlfApsIdChroma(pcSlice->getTileGroupApsIdChroma()); -#if JVET_Q0795_CCALF picHeader->setCcAlfEnabledFlag(COMPONENT_Cb, pcSlice->getTileGroupCcAlfCbEnabledFlag()); picHeader->setCcAlfEnabledFlag(COMPONENT_Cr, pcSlice->getTileGroupCcAlfCrEnabledFlag()); picHeader->setCcAlfCbApsId(pcSlice->getTileGroupCcAlfCbApsId()); picHeader->setCcAlfCrApsId(pcSlice->getTileGroupCcAlfCrApsId()); -#endif } -#if !JVET_Q0819_PH_CHANGES - else - { - picHeader->setAlfEnabledPresentFlag( false ); - } -#endif -#if JVET_Q0819_PH_CHANGES // code WP parameters in picture header or slice headers if (!m_pcCfg->getSliceLevelWp()) { @@ -3337,11 +3164,9 @@ void EncGOP::compressGOP( int iPOCLast, int iNumPicRcvd, PicList& rcListPic, picHeader->setNumL0Weights(pcSlice->getNumRefIdx(REF_PIC_LIST_0)); picHeader->setNumL0Weights(pcSlice->getNumRefIdx(REF_PIC_LIST_1)); } -#endif pcPic->cs->picHeader->setPic(pcPic); pcPic->cs->picHeader->setValid(); -#if JVET_Q0775_PH_IN_SH if (pcPic->cs->pps->getNumSlicesInPic() > 1 || !m_pcCfg->getEnablePictureHeaderInSliceHeader()) { pcSlice->setPictureHeaderInSliceHeader(false); @@ -3351,9 +3176,6 @@ void EncGOP::compressGOP( int iPOCLast, int iNumPicRcvd, PicList& rcListPic, { pcSlice->setPictureHeaderInSliceHeader(true); } -#else - actualTotalBits += xWritePicHeader(accessUnit, pcPic->cs->picHeader); -#endif } pcSlice->setPicHeader( pcPic->cs->picHeader ); @@ -3368,20 +3190,16 @@ void EncGOP::compressGOP( int iPOCLast, int iNumPicRcvd, PicList& rcListPic, tmpBitsBeforeWriting = m_HLSWriter->getNumberOfWrittenBits(); -#if JVET_Q0795_CCALF pcSlice->m_ccAlfFilterParam = m_pcALF->getCcAlfFilterParam(); pcSlice->m_ccAlfFilterControl[0] = m_pcALF->getCcAlfControlIdc(COMPONENT_Cb); pcSlice->m_ccAlfFilterControl[1] = m_pcALF->getCcAlfControlIdc(COMPONENT_Cr); -#endif m_HLSWriter->codeSliceHeader( pcSlice ); actualHeadBits += ( m_HLSWriter->getNumberOfWrittenBits() - tmpBitsBeforeWriting ); pcSlice->setFinalized(true); -#if JVET_Q0151_Q0205_ENTRYPOINTS pcSlice->resetNumberOfSubstream( ); pcSlice->setNumSubstream( pcSlice->getSPS(), pcSlice->getPPS() ); -#endif pcSlice->clearSubstreamSizes( ); { uint32_t numBinsCoded = 0; @@ -3397,11 +3215,7 @@ void EncGOP::compressGOP( int iPOCLast, int iNumPicRcvd, PicList& rcListPic, // Append substreams... OutputBitstream *pcOut = pcBitstreamRedirect; -#if JVET_Q0151_Q0205_ENTRYPOINTS const int numSubstreamsToCode = pcSlice->getNumberOfSubstream() + 1; -#else - const int numSubstreamsToCode = pcSlice->getNumberOfSubstreamSizes()+1; -#endif for ( uint32_t ui = 0 ; ui < numSubstreamsToCode; ui++ ) { @@ -3425,15 +3239,9 @@ void EncGOP::compressGOP( int iPOCLast, int iNumPicRcvd, PicList& rcListPic, } if( ( m_pcCfg->getPictureTimingSEIEnabled() || m_pcCfg->getDecodingUnitInfoSEIEnabled() ) && -#if JVET_P0118_HRD_ASPECTS ((pcSlice->getSPS()->getGeneralHrdParameters()->getGeneralNalHrdParametersPresentFlag()) || (pcSlice->getSPS()->getGeneralHrdParameters()->getGeneralVclHrdParametersPresentFlag())) && (pcSlice->getSPS()->getGeneralHrdParameters()->getGeneralDecodingUnitHrdParamsPresentFlag())) -#else - ( ( pcSlice->getSPS()->getHrdParameters()->getNalHrdParametersPresentFlag() ) - || ( pcSlice->getSPS()->getHrdParameters()->getVclHrdParametersPresentFlag() ) ) && - ( pcSlice->getSPS()->getHrdParameters()->getGeneralDecodingUnitHrdParamsPresentFlag() ) ) -#endif { uint32_t numNalus = 0; uint32_t numRBSPBytes = 0; @@ -3448,26 +3256,14 @@ void EncGOP::compressGOP( int iPOCLast, int iNumPicRcvd, PicList& rcListPic, } } // end iteration over slices -#if JVET_Q0436_CABAC_ZERO_WORD || JVET_P0188_MINCR { // Check picture level encoding constraints/requirements ProfileLevelTierFeatures profileLevelTierFeatures; profileLevelTierFeatures.extractPTLInformation(*(pcSlice->getSPS())); -#endif -#if JVET_P0188_MINCR validateMinCrRequirements(profileLevelTierFeatures, numBytesInVclNalUnits, pcPic, m_pcCfg); -#endif -#if JVET_Q0436_CABAC_ZERO_WORD // cabac_zero_words processing cabac_zero_word_padding(pcSlice, pcPic, binCountsInNalUnits, numBytesInVclNalUnits, accessUnit.back()->m_nalUnitData, m_pcCfg->getCabacZeroWordPaddingEnabled(), profileLevelTierFeatures); -#else - - // cabac_zero_words processing - cabac_zero_word_padding(pcSlice, pcPic, binCountsInNalUnits, numBytesInVclNalUnits, accessUnit.back()->m_nalUnitData, m_pcCfg->getCabacZeroWordPaddingEnabled()); -#endif -#if JVET_Q0436_CABAC_ZERO_WORD || JVET_P0188_MINCR } -#endif //-- For time output for each slice auto elapsed = std::chrono::steady_clock::now() - beforeTime; @@ -3524,12 +3320,10 @@ void EncGOP::compressGOP( int iPOCLast, int iNumPicRcvd, PicList& rcListPic, xCreateFrameFieldInfoSEI( leadingSeiMessages, pcSlice, isField ); xCreatePictureTimingSEI( m_pcCfg->getEfficientFieldIRAPEnabled() ? effFieldIRAPMap.GetIRAPGOPid() : 0, leadingSeiMessages, nestedSeiMessages, duInfoSeiMessages, pcSlice, isField, duData ); -#if JVET_P0190_SCALABLE_NESTING_SEI if (m_pcCfg->getScalableNestingSEIEnabled()) { xCreateScalableNestingSEI(leadingSeiMessages, nestedSeiMessages); } -#endif xWriteLeadingSEIMessages( leadingSeiMessages, duInfoSeiMessages, accessUnit, pcSlice->getTLayer(), pcSlice->getSPS(), duData ); xWriteDuSEIMessages( duInfoSeiMessages, accessUnit, pcSlice->getTLayer(), pcSlice->getSPS(), duData ); @@ -4223,11 +4017,7 @@ 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 JVET_Q0117_PARAMETER_SETS_CLEANUP 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 - 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 { numRBSPBytes += 4; } @@ -4422,7 +4212,7 @@ void EncGOP::xCalculateAddPSNR(Picture* pcPic, PelUnitBuf cPicD, const AccessUni for( int iRefIndex = 0; iRefIndex < pcSlice->getNumRefIdx( RefPicList( iRefList ) ); iRefIndex++ ) { const std::pair<int, int>& scaleRatio = pcSlice->getScalingRatio( RefPicList( iRefList ), iRefIndex ); - + if( pcPic->cs->picHeader->getEnableTMVPFlag() && pcSlice->getColFromL0Flag() == bool(1 - iRefList) && pcSlice->getColRefIdx() == iRefIndex ) { if( scaleRatio.first != 1 << SCALE_RATIO_BITS || scaleRatio.second != 1 << SCALE_RATIO_BITS ) @@ -5104,12 +4894,10 @@ void EncGOP::applyDeblockingFilterMetric( Picture* pcPic, uint32_t uiNumSlices ) pcLocalSlice->setDeblockingFilterDisable ( false); pcLocalSlice->setDeblockingFilterBetaOffsetDiv2 ( offset ); pcLocalSlice->setDeblockingFilterTcOffsetDiv2 ( offset ); -#if JVET_Q0121_DEBLOCKING_CONTROL_PARAMETERS pcLocalSlice->setDeblockingFilterCbBetaOffsetDiv2 ( offset ); pcLocalSlice->setDeblockingFilterCbTcOffsetDiv2 ( offset ); pcLocalSlice->setDeblockingFilterCrBetaOffsetDiv2 ( offset ); pcLocalSlice->setDeblockingFilterCrTcOffsetDiv2 ( offset ); -#endif } } else @@ -5122,12 +4910,10 @@ void EncGOP::applyDeblockingFilterMetric( Picture* pcPic, uint32_t uiNumSlices ) pcLocalSlice->setDeblockingFilterDisable ( pcPPS->getPPSDeblockingFilterDisabledFlag() ); pcLocalSlice->setDeblockingFilterBetaOffsetDiv2( pcPPS->getDeblockingFilterBetaOffsetDiv2() ); pcLocalSlice->setDeblockingFilterTcOffsetDiv2 ( pcPPS->getDeblockingFilterTcOffsetDiv2() ); -#if JVET_Q0121_DEBLOCKING_CONTROL_PARAMETERS pcLocalSlice->setDeblockingFilterCbBetaOffsetDiv2 ( pcPPS->getDeblockingFilterCbBetaOffsetDiv2() ); pcLocalSlice->setDeblockingFilterCbTcOffsetDiv2 ( pcPPS->getDeblockingFilterCbTcOffsetDiv2() ); pcLocalSlice->setDeblockingFilterCrBetaOffsetDiv2 ( pcPPS->getDeblockingFilterCrBetaOffsetDiv2() ); pcLocalSlice->setDeblockingFilterCrTcOffsetDiv2 ( pcPPS->getDeblockingFilterCrTcOffsetDiv2() ); -#endif } } } @@ -5189,12 +4975,10 @@ void EncGOP::applyDeblockingFilterParameterSelection( Picture* pcPic, const uint pcSlice->setDeblockingFilterDisable ( false); pcSlice->setDeblockingFilterBetaOffsetDiv2( betaOffsetDiv2 ); pcSlice->setDeblockingFilterTcOffsetDiv2 ( tcOffsetDiv2 ); -#if JVET_Q0121_DEBLOCKING_CONTROL_PARAMETERS pcSlice->setDeblockingFilterCbBetaOffsetDiv2( betaOffsetDiv2 ); pcSlice->setDeblockingFilterCbTcOffsetDiv2 ( tcOffsetDiv2 ); pcSlice->setDeblockingFilterCrBetaOffsetDiv2( betaOffsetDiv2 ); pcSlice->setDeblockingFilterCrTcOffsetDiv2 ( tcOffsetDiv2 ); -#endif } // restore reconstruction @@ -5253,12 +5037,10 @@ void EncGOP::applyDeblockingFilterParameterSelection( Picture* pcPic, const uint pcSlice->setDeblockingFilterDisable ( pcPPS->getPPSDeblockingFilterDisabledFlag() ); pcSlice->setDeblockingFilterBetaOffsetDiv2 ( pcPPS->getDeblockingFilterBetaOffsetDiv2() ); pcSlice->setDeblockingFilterTcOffsetDiv2 ( pcPPS->getDeblockingFilterTcOffsetDiv2() ); -#if JVET_Q0121_DEBLOCKING_CONTROL_PARAMETERS pcSlice->setDeblockingFilterCbBetaOffsetDiv2 ( pcPPS->getDeblockingFilterBetaOffsetDiv2() ); pcSlice->setDeblockingFilterCbTcOffsetDiv2 ( pcPPS->getDeblockingFilterTcOffsetDiv2() ); pcSlice->setDeblockingFilterCrBetaOffsetDiv2 ( pcPPS->getDeblockingFilterBetaOffsetDiv2() ); pcSlice->setDeblockingFilterCrTcOffsetDiv2 ( pcPPS->getDeblockingFilterTcOffsetDiv2() ); -#endif } } else @@ -5270,12 +5052,10 @@ void EncGOP::applyDeblockingFilterParameterSelection( Picture* pcPic, const uint pcSlice->setDeblockingFilterDisable ( false ); pcSlice->setDeblockingFilterBetaOffsetDiv2 ( betaOffsetDiv2Best); pcSlice->setDeblockingFilterTcOffsetDiv2 ( tcOffsetDiv2Best); -#if JVET_Q0121_DEBLOCKING_CONTROL_PARAMETERS pcSlice->setDeblockingFilterCbBetaOffsetDiv2 ( betaOffsetDiv2Best); pcSlice->setDeblockingFilterCbTcOffsetDiv2 ( tcOffsetDiv2Best); pcSlice->setDeblockingFilterCrBetaOffsetDiv2 ( betaOffsetDiv2Best); pcSlice->setDeblockingFilterCrTcOffsetDiv2 ( tcOffsetDiv2Best); -#endif } } } @@ -5345,17 +5125,17 @@ void EncGOP::xCreateExplicitReferencePictureSetFromReference( Slice* slice, PicL // loop through all pictures in the reference picture buffer PicList::iterator iterPic = rcListPic.begin(); - while( iterPic != rcListPic.end() ) + while( iterPic != rcListPic.end() && ii < numOfRefPic ) { rpcPic = *( iterPic++ ); int refLayerIdx = vps->getGeneralLayerIdx( rpcPic->layerId ); if( rpcPic->referenced && rpcPic->getPOC() == pic->getPOC() && vps->getDirectRefLayerFlag( layerIdx, refLayerIdx ) ) - { + { pLocalRPL0->setRefPicIdentifier( refPicIdxL0, 0, true, true, vps->getInterLayerRefIdc( layerIdx, refLayerIdx ) ); refPicIdxL0++; numOfILRPL0++; - break; + ii++; } } } @@ -5417,7 +5197,7 @@ void EncGOP::xCreateExplicitReferencePictureSetFromReference( Slice* slice, PicL isAvailable = true; break; } - } + } } if( isAvailable ) @@ -5430,7 +5210,7 @@ void EncGOP::xCreateExplicitReferencePictureSetFromReference( Slice* slice, PicL } } - + // inter-layer reference pictures are added to the end of the reference picture list if( layerIdx && vps && !vps->getAllIndependentLayersFlag() ) { @@ -5441,7 +5221,7 @@ void EncGOP::xCreateExplicitReferencePictureSetFromReference( Slice* slice, PicL // loop through all pictures in the reference picture buffer PicList::iterator iterPic = rcListPic.begin(); - while( iterPic != rcListPic.end() ) + while( iterPic != rcListPic.end() && ii < numOfRefPic ) { rpcPic = *( iterPic++ ); int refLayerIdx = vps->getGeneralLayerIdx( rpcPic->layerId ); @@ -5451,7 +5231,7 @@ void EncGOP::xCreateExplicitReferencePictureSetFromReference( Slice* slice, PicL pLocalRPL1->setRefPicIdentifier( refPicIdxL1, 0, true, true, vps->getInterLayerRefIdc( layerIdx, refLayerIdx ) ); refPicIdxL1++; numOfILRPL1++; - break; + ii++; } } } @@ -5501,7 +5281,11 @@ void EncGOP::xCreateExplicitReferencePictureSetFromReference( Slice* slice, PicL int numPics = numOfLTRPL0 + numOfSTRPL0; pLocalRPL0->setNumberOfActivePictures( ( numPics < rpl0->getNumberOfActivePictures() ? numPics : rpl0->getNumberOfActivePictures() ) + numOfILRPL0 ); +#if JVET_R0059_RPL_CLEANUP + pLocalRPL0->setLtrpInSliceHeaderFlag( 1 ); +#else pLocalRPL0->setLtrpInSliceHeaderFlag( rpl0->getLtrpInSliceHeaderFlag() ); +#endif slice->setRPL0idx( -1 ); slice->setRPL0( pLocalRPL0 ); @@ -5545,7 +5329,11 @@ void EncGOP::xCreateExplicitReferencePictureSetFromReference( Slice* slice, PicL numPics = numOfLTRPL1 + numOfSTRPL1; pLocalRPL1->setNumberOfActivePictures( ( isDisallowMixedRefPic ? numPics : ( numPics < rpl1->getNumberOfActivePictures() ? numPics : rpl1->getNumberOfActivePictures() ) ) + numOfILRPL1 ); +#if JVET_R0059_RPL_CLEANUP + pLocalRPL1->setLtrpInSliceHeaderFlag( 1 ); +#else pLocalRPL1->setLtrpInSliceHeaderFlag( rpl1->getLtrpInSliceHeaderFlag() ); +#endif slice->setRPL1idx( -1 ); slice->setRPL1( pLocalRPL1 ); } diff --git a/source/Lib/EncoderLib/EncGOP.h b/source/Lib/EncoderLib/EncGOP.h index 7c3d28d5cdcb03ade8249aaa49ef74d9568992a4..5a4c51ef8a2f9eac32da5419349f076cc9636ae7 100644 --- a/source/Lib/EncoderLib/EncGOP.h +++ b/source/Lib/EncoderLib/EncGOP.h @@ -306,9 +306,7 @@ protected: void xUpdateDuData(AccessUnit &testAU, std::deque<DUData> &duData); void xUpdateTimingSEI(SEIPictureTiming *pictureTimingSEI, std::deque<DUData> &duData, const SPS *sps); void xUpdateDuInfoSEI(SEIMessages &duInfoSeiMessages, SEIPictureTiming *pictureTimingSEI, int maxSubLayers); -#if JVET_P0190_SCALABLE_NESTING_SEI void xCreateScalableNestingSEI(SEIMessages& seiMessages, SEIMessages& nestedSeiMessages); -#endif void xWriteSEI (NalUnitType naluType, SEIMessages& seiMessages, AccessUnit &accessUnit, AccessUnit::iterator &auPos, int temporalId, const SPS *sps); void xWriteSEISeparately (NalUnitType naluType, SEIMessages& seiMessages, AccessUnit &accessUnit, AccessUnit::iterator &auPos, int temporalId, const SPS *sps); void xClearSEIs(SEIMessages& seiMessages, bool deleteMessages); @@ -318,19 +316,11 @@ protected: void xWriteDuSEIMessages (SEIMessages& duInfoSeiMessages, AccessUnit &accessUnit, int temporalId, const SPS *sps, std::deque<DUData> &duData); int xWriteVPS (AccessUnit &accessUnit, const VPS *vps); -#if JVET_Q0117_PARAMETER_SETS_CLEANUP int xWriteDCI (AccessUnit &accessUnit, const DCI *dci); -#else - int xWriteDPS (AccessUnit &accessUnit, const DPS *dps); -#endif int xWriteSPS( AccessUnit &accessUnit, const SPS *sps, const int layerId = 0 ); int xWritePPS( AccessUnit &accessUnit, const PPS *pps, const int layerId = 0 ); int xWriteAPS( AccessUnit &accessUnit, APS *aps, const int layerId, const bool isPrefixNUT ); -#if ENABLING_MULTI_SPS int xWriteParameterSets(AccessUnit &accessUnit, Slice *slice, const bool bSeqFirst, const int layerIdx); -#else - int xWriteParameterSets(AccessUnit &accessUnit, Slice *slice, const bool bSeqFirst); -#endif int xWritePicHeader( AccessUnit &accessUnit, PicHeader *picHeader ); void applyDeblockingFilterMetric( Picture* pcPic, uint32_t uiNumSlices ); diff --git a/source/Lib/EncoderLib/EncHRD.cpp b/source/Lib/EncoderLib/EncHRD.cpp index 088bea04d65939f268f5c1db3c8ab530a4e447e6..c28dc0d4c473e7e1f728ddafd27293bb6de19139 100644 --- a/source/Lib/EncoderLib/EncHRD.cpp +++ b/source/Lib/EncoderLib/EncHRD.cpp @@ -55,7 +55,6 @@ int EncHRD::xCalcScale(int x) } #endif -#if JVET_P0118_HRD_ASPECTS void EncHRD::initHRDParameters(EncCfg* encCfg) { bool useSubCpbParams = encCfg->getNoPicPartitionFlag() == false; @@ -109,8 +108,11 @@ void EncHRD::initHRDParameters(EncCfg* encCfg) m_generalHrdParams.setGeneralNalHrdParametersPresentFlag(rateCnt); m_generalHrdParams.setGeneralVclHrdParametersPresentFlag(rateCnt); - useSubCpbParams &= (m_generalHrdParams.getGeneralNalHrdParametersPresentFlag() || m_generalHrdParams.getGeneralVclHrdParametersPresentFlag()); +#if JVET_Q0394_TIMING_SEI + m_generalHrdParams.setGeneralSamePicTimingInAllOlsFlag(encCfg->getSamePicTimingInAllOLS()); +#endif + useSubCpbParams &= (m_generalHrdParams.getGeneralNalHrdParametersPresentFlag() || m_generalHrdParams.getGeneralVclHrdParametersPresentFlag()); m_generalHrdParams.setGeneralDecodingUnitHrdParamsPresentFlag(useSubCpbParams); if (m_generalHrdParams.getGeneralDecodingUnitHrdParamsPresentFlag()) @@ -152,7 +154,7 @@ void EncHRD::initHRDParameters(EncCfg* encCfg) uint32_t duBitRateValue = 0; OlsHrdParams* olsHrdParams = getOlsHrdParametersAddr(); - for (i = 0; i < MAX_TLAYER; i++) + for (i = 0; i < MAX_TLAYER; i++) { OlsHrdParams curOlsHrdParams = olsHrdParams[i]; @@ -192,138 +194,4 @@ void EncHRD::initHRDParameters(EncCfg* encCfg) } } } -#else -void EncHRD::initHRDParameters (EncCfg* encCfg) -{ - bool useSubCpbParams = encCfg->getNoPicPartitionFlag() == false; - int bitRate = encCfg->getTargetBitrate(); -# if U0132_TARGET_BITS_SATURATION - int cpbSize = encCfg->getCpbSize(); - CHECK(!(cpbSize!=0), "Unspecified error"); // CPB size may not be equal to zero. ToDo: have a better default and check for level constraints - if( !encCfg->getHrdParametersPresentFlag() && !encCfg->getCpbSaturationEnabled() ) -#else - if( !encCfg->getHrdParametersPresentFlag() ) -#endif - { - return; - } - - m_timingInfo.setTimingInfoPresentFlag( true ); - switch( encCfg->getFrameRate() ) - { - case 24: - m_timingInfo.setNumUnitsInTick( 1125000 ); m_timingInfo.setTimeScale ( 27000000 ); - break; - case 25: - m_timingInfo.setNumUnitsInTick( 1080000 ); m_timingInfo.setTimeScale ( 27000000 ); - break; - case 30: - m_timingInfo.setNumUnitsInTick( 900900 ); m_timingInfo.setTimeScale ( 27000000 ); - break; - case 50: - m_timingInfo.setNumUnitsInTick( 540000 ); m_timingInfo.setTimeScale ( 27000000 ); - break; - case 60: - m_timingInfo.setNumUnitsInTick( 450450 ); m_timingInfo.setTimeScale ( 27000000 ); - break; - default: - m_timingInfo.setNumUnitsInTick( 1001 ); m_timingInfo.setTimeScale ( 60000 ); - break; - } - - if (encCfg->getTemporalSubsampleRatio()>1) - { - uint32_t temporalSubsampleRatio = encCfg->getTemporalSubsampleRatio(); - if ( double(m_timingInfo.getNumUnitsInTick()) * temporalSubsampleRatio > std::numeric_limits<uint32_t>::max() ) - { - m_timingInfo.setTimeScale( m_timingInfo.getTimeScale() / temporalSubsampleRatio ); - } - else - { - m_timingInfo.setNumUnitsInTick( m_timingInfo.getNumUnitsInTick() * temporalSubsampleRatio ); - } - } - bool rateCnt = ( bitRate > 0 ); - m_hrdParams.setNalHrdParametersPresentFlag( rateCnt ); - m_hrdParams.setVclHrdParametersPresentFlag( rateCnt ); - useSubCpbParams &= ( m_hrdParams.getNalHrdParametersPresentFlag() || m_hrdParams.getVclHrdParametersPresentFlag() ); - m_hrdParams.setGeneralDecodingUnitHrdParamsPresentFlag( useSubCpbParams ); - - if( m_hrdParams.getGeneralDecodingUnitHrdParamsPresentFlag() ) - { - m_hrdParams.setTickDivisorMinus2( 100 - 2 ); - } - -#if U0132_TARGET_BITS_SATURATION - if (xCalcScale(bitRate) <= 6) - { - m_hrdParams.setBitRateScale(0); - } - else - { - m_hrdParams.setBitRateScale(xCalcScale(bitRate) - 6); - } - - if (xCalcScale(cpbSize) <= 4) - { - m_hrdParams.setCpbSizeScale(0); - } - else - { - m_hrdParams.setCpbSizeScale(xCalcScale(cpbSize) - 4); - } -#else - m_hrdParams.setBitRateScale( 4 ); // in units of 2^( 6 + 4 ) = 1,024 bps - m_hrdParams.setCpbSizeScale( 6 ); // in units of 2^( 4 + 6 ) = 1,024 bit -#endif - - m_hrdParams.setCpbSizeDuScale( 6 ); // in units of 2^( 4 + 6 ) = 1,024 bit - - - // Note: parameters for all temporal layers are initialized with the same values - int i, j; - uint32_t bitrateValue, cpbSizeValue; - uint32_t duCpbSizeValue; - uint32_t duBitRateValue = 0; - - for( i = 0; i < MAX_TLAYER; i ++ ) - { - m_hrdParams.setFixedPicRateFlag( i, 1 ); - m_hrdParams.setPicDurationInTcMinus1( i, 0 ); - m_hrdParams.setLowDelayHrdFlag( i, 0 ); - m_hrdParams.setCpbCntMinus1( i, 0 ); - - //! \todo check for possible PTL violations - // BitRate[ i ] = ( bit_rate_value_minus1[ i ] + 1 ) * 2^( 6 + bit_rate_scale ) - bitrateValue = bitRate / (1 << (6 + m_hrdParams.getBitRateScale()) ); // bitRate is in bits, so it needs to be scaled down - // CpbSize[ i ] = ( cpb_size_value_minus1[ i ] + 1 ) * 2^( 4 + cpb_size_scale ) -#if U0132_TARGET_BITS_SATURATION - cpbSizeValue = cpbSize / (1 << (4 + m_hrdParams.getCpbSizeScale()) ); // using bitRate results in 1 second CPB size -#else - cpbSizeValue = bitRate / (1 << (4 + m_hrdParams.getCpbSizeScale()) ); // using bitRate results in 1 second CPB size -#endif - - - // DU CPB size could be smaller (i.e. bitrateValue / number of DUs), but we don't know - // in how many DUs the slice segment settings will result - duCpbSizeValue = bitrateValue; - duBitRateValue = cpbSizeValue; - - for( j = 0; j < ( m_hrdParams.getCpbCntMinus1( i ) + 1 ); j ++ ) - { - m_hrdParams.setBitRateValueMinus1( i, j, 0, ( bitrateValue - 1 ) ); - m_hrdParams.setCpbSizeValueMinus1( i, j, 0, ( cpbSizeValue - 1 ) ); - m_hrdParams.setDuCpbSizeValueMinus1( i, j, 0, ( duCpbSizeValue - 1 ) ); - m_hrdParams.setDuBitRateValueMinus1( i, j, 0, ( duBitRateValue - 1 ) ); - m_hrdParams.setCbrFlag( i, j, 0, false ); - - m_hrdParams.setBitRateValueMinus1( i, j, 1, ( bitrateValue - 1) ); - m_hrdParams.setCpbSizeValueMinus1( i, j, 1, ( cpbSizeValue - 1 ) ); - m_hrdParams.setDuCpbSizeValueMinus1( i, j, 1, ( duCpbSizeValue - 1 ) ); - m_hrdParams.setDuBitRateValueMinus1( i, j, 1, ( duBitRateValue - 1 ) ); - m_hrdParams.setCbrFlag( i, j, 1, false ); - } - } -} -#endif diff --git a/source/Lib/EncoderLib/EncLib.cpp b/source/Lib/EncoderLib/EncLib.cpp index 1c08f782fa99b9eb416a4b18e54492dcf3e8ad43..f45be9524f29c52435611b0537e0d062977efc09 100644 --- a/source/Lib/EncoderLib/EncLib.cpp +++ b/source/Lib/EncoderLib/EncLib.cpp @@ -47,9 +47,7 @@ #include <omp.h> #endif #include "EncLibCommon.h" -#if JVET_Q0814_DPB #include "CommonLib/ProfileLevelTier.h" -#endif //! \ingroup EncoderLib //! \{ @@ -71,9 +69,7 @@ EncLib::EncLib( EncLibCommon* encLibCommon ) , m_lmcsAPS(nullptr) , m_scalinglistAPS( nullptr ) , m_doPlt( true ) -#if JVET_Q0814_DPB , m_vps( encLibCommon->getVPS() ) -#endif { m_iPOCLast = -1; m_iNumPicRcvd = 0; @@ -131,11 +127,7 @@ void EncLib::create( const int layerId ) m_cInterSearch.cacheAssign( &m_cacheModel ); #endif -#if JVET_Q0468_Q0469_MIN_LUMA_CB_AND_MIN_QT_FIX m_cLoopFilter.create(floorLog2(m_maxCUWidth) - MIN_CU_LOG2); -#else - m_cLoopFilter.create( m_maxTotalCUDepth ); -#endif if (!m_bLoopFilterDisable && m_encDbOpt) { @@ -221,32 +213,17 @@ void EncLib::init( bool isFieldCoding, AUWriterIf* auWriterIf ) { m_AUWriterIf = auWriterIf; -#if ENABLING_MULTI_SPS - SPS &sps0 = *(m_spsMap.allocatePS(m_layerId)); // NOTE: implementations that use more than 1 SPS need to be aware of activation issues. -#else - SPS &sps0 = *(m_spsMap.allocatePS(0)); // NOTE: implementations that use more than 1 SPS need to be aware of activation issues. -#endif - PPS &pps0 = *( m_ppsMap.allocatePS( m_layerId ) ); + SPS &sps0 = *(m_spsMap.allocatePS( m_vps->getGeneralLayerIdx( m_layerId ) )); // NOTE: implementations that use more than 1 SPS need to be aware of activation issues. + PPS &pps0 = *( m_ppsMap.allocatePS( m_vps->getGeneralLayerIdx( m_layerId ) ) ); APS &aps0 = *( m_apsMap.allocatePS( SCALING_LIST_APS ) ); aps0.setAPSId( 0 ); aps0.setAPSType( SCALING_LIST_APS ); // initialize SPS -#if JVET_Q0814_DPB xInitSPS( sps0 ); xInitVPS( sps0 ); -#else - xInitSPS( sps0, m_cVPS ); - xInitVPS(m_cVPS, sps0); -#endif -#if JVET_Q0117_PARAMETER_SETS_CLEANUP xInitDCI(m_dci, sps0); -#else - int dpsId = getDecodingParameterSetEnabled() ? 1 : 0; - xInitDPS(m_dps, sps0, dpsId); - sps0.setDecodingParameterSetId(m_dps.getDecodingParameterSetId()); -#endif #if ENABLE_SPLIT_PARALLELISM if( omp_get_dynamic() ) { @@ -263,11 +240,7 @@ void EncLib::init( bool isFieldCoding, AUWriterIf* auWriterIf ) #if U0132_TARGET_BITS_SATURATION if (m_RCCpbSaturationEnabled) { -#if JVET_P0118_HRD_ASPECTS m_cRateCtrl.initHrdParam(sps0.getGeneralHrdParameters(), sps0.getOlsHrdParameters(), m_iFrameRate, m_RCInitialCpbFullness); -#else - m_cRateCtrl.initHrdParam(sps0.getHrdParameters(), m_iFrameRate, m_RCInitialCpbFullness); -#endif } #endif #if ENABLE_SPLIT_PARALLELISM @@ -291,24 +264,12 @@ void EncLib::init( bool isFieldCoding, AUWriterIf* auWriterIf ) { PPS &pps = *( m_ppsMap.allocatePS( ENC_PPS_ID_RPR ) ); Window& inputScalingWindow = pps0.getScalingWindow(); -#if JVET_Q0487_SCALING_WINDOW_ISSUES int scaledWidth = int( ( pps0.getPicWidthInLumaSamples() - SPS::getWinUnitX( sps0.getChromaFormatIdc() ) * ( inputScalingWindow.getWindowLeftOffset() + inputScalingWindow.getWindowRightOffset() ) ) / m_scalingRatioHor ); -#else - int scaledWidth = int( ( pps0.getPicWidthInLumaSamples() - inputScalingWindow.getWindowLeftOffset() - inputScalingWindow.getWindowRightOffset() ) / m_scalingRatioHor ); -#endif -#if JVET_Q0468_Q0469_MIN_LUMA_CB_AND_MIN_QT_FIX int minSizeUnit = std::max(8, 1 << sps0.getLog2MinCodingBlockSize()); -#else - int minSizeUnit = std::max(8, (int)(sps0.getMaxCUHeight() >> (sps0.getMaxCodingDepth() - 1))); -#endif int temp = scaledWidth / minSizeUnit; int width = ( scaledWidth - ( temp * minSizeUnit) > 0 ? temp + 1 : temp ) * minSizeUnit; -#if JVET_Q0487_SCALING_WINDOW_ISSUES int scaledHeight = int( ( pps0.getPicHeightInLumaSamples() - SPS::getWinUnitY( sps0.getChromaFormatIdc() ) * ( inputScalingWindow.getWindowTopOffset() + inputScalingWindow.getWindowBottomOffset() ) ) / m_scalingRatioVer ); -#else - int scaledHeight = int( ( pps0.getPicHeightInLumaSamples() - inputScalingWindow.getWindowTopOffset() - inputScalingWindow.getWindowBottomOffset() ) / m_scalingRatioVer ); -#endif temp = scaledHeight / minSizeUnit; int height = ( scaledHeight - ( temp * minSizeUnit) > 0 ? temp + 1 : temp ) * minSizeUnit; @@ -320,14 +281,9 @@ void EncLib::init( bool isFieldCoding, AUWriterIf* auWriterIf ) pps.setConformanceWindow( conformanceWindow ); Window scalingWindow; -#if JVET_Q0487_SCALING_WINDOW_ISSUES scalingWindow.setWindow( 0, ( width - scaledWidth ) / SPS::getWinUnitX( sps0.getChromaFormatIdc() ), 0, ( height - scaledHeight ) / SPS::getWinUnitY( sps0.getChromaFormatIdc() ) ); -#else - scalingWindow.setWindow( 0, width - scaledWidth, 0, height - scaledHeight ); -#endif pps.setScalingWindow( scalingWindow ); -#if JVET_Q0179_SCALING_WINDOW_SIZE_CONSTRAINT //register the width/height of the current pic into reference SPS if (!sps0.getPPSValidFlag(pps.getPPSId())) { @@ -337,7 +293,7 @@ void EncLib::init( bool isFieldCoding, AUWriterIf* auWriterIf ) int curSeqMaxPicWidthY = sps0.getMaxPicWidthInLumaSamples(); // pic_width_max_in_luma_samples int curSeqMaxPicHeightY = sps0.getMaxPicHeightInLumaSamples(); // pic_height_max_in_luma_samples int curPicWidthY = width; // pic_width_in_luma_samples - int curPicHeightY = height; // pic_height_in_luma_samples + int curPicHeightY = height; // pic_height_in_luma_samples int max8MinCbSizeY = std::max((int)8, (1 << sps0.getLog2MinCodingBlockSize())); // Max(8, MinCbSizeY) //Warning message of potential scaling window size violation for (int i = 0; i < 64; i++) @@ -350,7 +306,6 @@ void EncLib::init( bool isFieldCoding, AUWriterIf* auWriterIf ) printf("Potential violation: (curScaledHeight * curSeqMaxPicHeightY) should be greater than or equal to refScaledHeight * (curPicHeightY - max(8, MinCbSizeY)\n"); } } -#endif // disable picture partitioning for scaled RPR pictures (slice/tile config only provided for the original resolution) m_noPicPartitionFlag = true; @@ -406,11 +361,7 @@ void EncLib::init( bool isFieldCoding, AUWriterIf* auWriterIf ) &m_cTrQuant[jId], &m_cRdCost[jId], cabacEstimator, -#if JVET_Q0468_Q0469_MIN_LUMA_CB_AND_MIN_QT_FIX getCtxCache( jId ), m_maxCUWidth, m_maxCUHeight, floorLog2(m_maxCUWidth) - m_log2MinCUSize -#else - getCtxCache( jId ), m_maxCUWidth, m_maxCUHeight, m_maxTotalCUDepth -#endif , &m_cReshaper[jId] , sps0.getBitDepth(CHANNEL_TYPE_LUMA) ); @@ -420,11 +371,7 @@ void EncLib::init( bool isFieldCoding, AUWriterIf* auWriterIf ) m_bipredSearchRange, m_motionEstimationSearchMethod, getUseCompositeRef(), -#if JVET_Q0468_Q0469_MIN_LUMA_CB_AND_MIN_QT_FIX m_maxCUWidth, m_maxCUHeight, floorLog2(m_maxCUWidth) - m_log2MinCUSize, &m_cRdCost[jId], cabacEstimator, getCtxCache( jId ) -#else - m_maxCUWidth, m_maxCUHeight, m_maxTotalCUDepth, &m_cRdCost[jId], cabacEstimator, getCtxCache( jId ) -#endif , &m_cReshaper[jId] ); @@ -451,11 +398,7 @@ void EncLib::init( bool isFieldCoding, AUWriterIf* auWriterIf ) &m_cTrQuant, &m_cRdCost, cabacEstimator, -#if JVET_Q0468_Q0469_MIN_LUMA_CB_AND_MIN_QT_FIX getCtxCache(), m_maxCUWidth, m_maxCUHeight, floorLog2(m_maxCUWidth) - m_log2MinCUSize -#else - getCtxCache(), m_maxCUWidth, m_maxCUHeight, m_maxTotalCUDepth -#endif , &m_cReshaper , sps0.getBitDepth(CHANNEL_TYPE_LUMA) ); @@ -465,11 +408,7 @@ void EncLib::init( bool isFieldCoding, AUWriterIf* auWriterIf ) m_bipredSearchRange, m_motionEstimationSearchMethod, getUseCompositeRef(), -#if JVET_Q0468_Q0469_MIN_LUMA_CB_AND_MIN_QT_FIX m_maxCUWidth, m_maxCUHeight, floorLog2(m_maxCUWidth) - m_log2MinCUSize, &m_cRdCost, cabacEstimator, getCtxCache() -#else - m_maxCUWidth, m_maxCUHeight, m_maxTotalCUDepth, &m_cRdCost, cabacEstimator, getCtxCache() -#endif , &m_cReshaper ); @@ -499,11 +438,7 @@ void EncLib::init( bool isFieldCoding, AUWriterIf* auWriterIf ) Picture *picBg = new Picture; picBg->create( sps0.getChromaFormatIdc(), Size( pps0.getPicWidthInLumaSamples(), pps0.getPicHeightInLumaSamples() ), sps0.getMaxCUWidth(), sps0.getMaxCUWidth() + 16, false, m_layerId ); picBg->getRecoBuf().fill(0); -#if JVET_Q0814_DPB picBg->finalInit( m_vps, sps0, pps0, &m_picHeader, m_apss, m_lmcsAPS, m_scalinglistAPS ); -#else - picBg->finalInit( &m_cVPS, sps0, pps0, &m_picHeader, m_apss, m_lmcsAPS, m_scalinglistAPS ); -#endif picBg->allocateNewSlice(); picBg->createSpliceIdx(pps0.pcv->sizeInCtus); m_cGOPEncoder.setPicBg(picBg); @@ -560,9 +495,7 @@ void EncLib::xInitScalingLists( SPS &sps, APS &aps ) { setUseScalingListId( SCALING_LIST_DEFAULT ); } -#if JVET_Q0505_CHROAM_QM_SIGNALING_400 aps.getScalingList().setChromaScalingListPresentFlag((sps.getChromaFormatIdc()!=CHROMA_400)); -#endif quant->setScalingList( &( aps.getScalingList() ), maxLog2TrDynamicRange, sps.getBitDepths() ); quant->setUseScalingList(true); #if ENABLE_SPLIT_PARALLELISM @@ -583,14 +516,10 @@ void EncLib::xInitScalingLists( SPS &sps, APS &aps ) // Prepare delta's: for (uint32_t scalingListId = 0; scalingListId < 28; scalingListId++) { -#if JVET_Q0505_CHROAM_QM_SIGNALING_400 if (aps.getScalingList().getChromaScalingListPresentFlag()||aps.getScalingList().isLumaScalingList(scalingListId)) { -#endif aps.getScalingList().checkPredMode(scalingListId); -#if JVET_Q0505_CHROAM_QM_SIGNALING_400 } -#endif } } } @@ -640,11 +569,7 @@ bool EncLib::encodePrep( bool flush, PelStorage* pcPicYuvOrg, PelStorage* cPicYu const SPS *sps = m_spsMap.getPS( pps->getSPSId() ); picCurr->M_BUFS( 0, PIC_ORIGINAL ).copyFrom( m_cGOPEncoder.getPicBg()->getRecoBuf() ); -#if JVET_Q0814_DPB picCurr->finalInit( m_vps, *sps, *pps, &m_picHeader, m_apss, m_lmcsAPS, m_scalinglistAPS ); -#else - picCurr->finalInit( &m_cVPS, *sps, *pps, &m_picHeader, m_apss, m_lmcsAPS, m_scalinglistAPS ); -#endif picCurr->poc = m_iPOCLast - 1; m_iPOCLast -= 2; if( getUseAdaptiveQP() ) @@ -700,13 +625,9 @@ bool EncLib::encodePrep( bool flush, PelStorage* pcPicYuvOrg, PelStorage* cPicYu } } -#if JVET_Q0814_DPB if( m_vps->getMaxLayers() > 1 ) -#else - if( m_cVPS.getMaxLayers() > 1 ) -#endif { - ppsID = m_layerId; + ppsID = m_vps->getGeneralLayerIdx( m_layerId ); } xGetNewPicBuffer( rcListPicYuvRecOut, pcPicCurr, ppsID ); @@ -728,22 +649,12 @@ bool EncLib::encodePrep( bool flush, PelStorage* pcPicYuvOrg, PelStorage* cPicYu const PPS *refPPS = m_ppsMap.getPS( 0 ); const Window& curScalingWindow = pPPS->getScalingWindow(); -#if JVET_Q0487_SCALING_WINDOW_ISSUES int curPicWidth = pPPS->getPicWidthInLumaSamples() - SPS::getWinUnitX( pSPS->getChromaFormatIdc() ) * ( curScalingWindow.getWindowLeftOffset() + curScalingWindow.getWindowRightOffset() ); int curPicHeight = pPPS->getPicHeightInLumaSamples() - SPS::getWinUnitY( pSPS->getChromaFormatIdc() ) * ( curScalingWindow.getWindowTopOffset() + curScalingWindow.getWindowBottomOffset() ); -#else - int curPicWidth = pPPS->getPicWidthInLumaSamples() - curScalingWindow.getWindowLeftOffset() - curScalingWindow.getWindowRightOffset(); - int curPicHeight = pPPS->getPicHeightInLumaSamples() - curScalingWindow.getWindowTopOffset() - curScalingWindow.getWindowBottomOffset(); -#endif const Window& refScalingWindow = refPPS->getScalingWindow(); -#if JVET_Q0487_SCALING_WINDOW_ISSUES int refPicWidth = refPPS->getPicWidthInLumaSamples() - SPS::getWinUnitX( pSPS->getChromaFormatIdc() ) * ( refScalingWindow.getWindowLeftOffset() + refScalingWindow.getWindowRightOffset() ); int refPicHeight = refPPS->getPicHeightInLumaSamples() - SPS::getWinUnitY( pSPS->getChromaFormatIdc() ) * ( refScalingWindow.getWindowTopOffset() + refScalingWindow.getWindowBottomOffset() ); -#else - int refPicWidth = refPPS->getPicWidthInLumaSamples() - refScalingWindow.getWindowLeftOffset() - refScalingWindow.getWindowRightOffset(); - int refPicHeight = refPPS->getPicHeightInLumaSamples() - refScalingWindow.getWindowTopOffset() - refScalingWindow.getWindowBottomOffset(); -#endif int xScale = ( ( refPicWidth << SCALE_RATIO_BITS ) + ( curPicWidth >> 1 ) ) / curPicWidth; int yScale = ( ( refPicHeight << SCALE_RATIO_BITS ) + ( curPicHeight >> 1 ) ) / curPicHeight; @@ -760,11 +671,7 @@ bool EncLib::encodePrep( bool flush, PelStorage* pcPicYuvOrg, PelStorage* cPicYu pcPicCurr->M_BUFS( 0, PIC_TRUE_ORIGINAL ).swap( *cPicYuvTrueOrg ); } -#if JVET_Q0814_DPB pcPicCurr->finalInit( m_vps, *pSPS, *pPPS, &m_picHeader, m_apss, m_lmcsAPS, m_scalinglistAPS ); -#else - pcPicCurr->finalInit( &m_cVPS, *pSPS, *pPPS, &m_picHeader, m_apss, m_lmcsAPS, m_scalinglistAPS ); -#endif pcPicCurr->poc = m_iPOCLast; @@ -806,7 +713,7 @@ bool EncLib::encodePrep( bool flush, PelStorage* pcPicYuvOrg, PelStorage* cPicYu */ bool EncLib::encode( const InputColourSpaceConversion snrCSC, std::list<PelUnitBuf*>& rcListPicYuvRecOut, int& iNumEncoded ) -{ +{ // compress GOP m_cGOPEncoder.compressGOP( m_iPOCLast, m_iNumPicRcvd, m_cListPic, rcListPicYuvRecOut, false, false, snrCSC, m_printFrameMSE, false, m_picIdInGOP ); @@ -899,11 +806,7 @@ bool EncLib::encodePrep( bool flush, PelStorage* pcPicYuvOrg, PelStorage* pcPicY const PPS *pPPS = ( ppsID < 0 ) ? m_ppsMap.getFirstPS() : m_ppsMap.getPS( ppsID ); const SPS *pSPS = m_spsMap.getPS( pPPS->getSPSId() ); -#if JVET_Q0814_DPB pcField->finalInit( m_vps, *pSPS, *pPPS, &m_picHeader, m_apss, m_lmcsAPS, m_scalinglistAPS ); -#else - pcField->finalInit( &m_cVPS, *pSPS, *pPPS, &m_picHeader, m_apss, m_lmcsAPS, m_scalinglistAPS ); -#endif pcField->poc = m_iPOCLast; pcField->reconstructed = false; @@ -947,7 +850,7 @@ bool EncLib::encode( const InputColourSpaceConversion snrCSC, std::list<PelUnitB m_picIdInGOP++; } - + // go over all pictures in a GOP excluding first top field and first bottom field if( m_picIdInGOP != m_iGOPSize && m_iPOCLast > 1 ) { @@ -957,7 +860,7 @@ bool EncLib::encode( const InputColourSpaceConversion snrCSC, std::list<PelUnitB iNumEncoded += m_iNumPicRcvd; m_uiNumAllPicCoded += m_iNumPicRcvd; m_iNumPicRcvd = 0; - + return false; } @@ -991,13 +894,9 @@ void EncLib::xGetNewPicBuffer ( std::list<PelUnitBuf*>& rcListPicYuvRecOut, Pict Slice::sortPicList(m_cListPic); // use an entry in the buffered list if the maximum number that need buffering has been reached: -#if JVET_Q0814_DPB int maxDecPicBuffering = ( m_vps == nullptr || m_vps->m_numLayersInOls[m_vps->m_targetOlsIdx] == 1 ) ? sps.getMaxDecPicBuffering( MAX_TLAYER - 1 ) : m_vps->getMaxDecPicBuffering( MAX_TLAYER - 1 ); if( m_cListPic.size() >= (uint32_t)( m_iGOPSize + maxDecPicBuffering + 2 ) ) -#else - if( m_cListPic.size() >= (uint32_t)( m_iGOPSize + getMaxDecPicBuffering( MAX_TLAYER - 1 ) + 2 ) ) -#endif { PicList::iterator iterPic = m_cListPic.begin(); int iSize = int( m_cListPic.size() ); @@ -1059,19 +958,13 @@ void EncLib::xGetNewPicBuffer ( std::list<PelUnitBuf*>& rcListPicYuvRecOut, Pict m_iNumPicRcvd++; } -#if JVET_Q0814_DPB void EncLib::xInitVPS( const SPS& sps ) { // The SPS must have already been set up. // set the VPS profile information. -#if !JVET_Q0786_PTL_only - m_vps->setMaxSubLayers( sps.getMaxTLayers() ); -#endif -#if JVET_P0118_HRD_ASPECTS m_vps->m_olsHrdParams.clear(); m_vps->m_olsHrdParams.resize(m_vps->getNumOlsHrdParamsMinus1(), std::vector<OlsHrdParams>(m_vps->getMaxSubLayers())); -#endif ProfileLevelTierFeatures profileLevelTierFeatures; profileLevelTierFeatures.extractPTLInformation( sps ); @@ -1147,18 +1040,7 @@ void EncLib::xInitVPS( const SPS& sps ) } } } -#else -void EncLib::xInitVPS(VPS& vps, const SPS& sps) -{ - // The SPS must have already been set up. - // set the VPS profile information. -#if !JVET_Q0786_PTL_only - vps.setMaxSubLayers(sps.getMaxTLayers()); -#endif -} -#endif -#if JVET_Q0117_PARAMETER_SETS_CLEANUP void EncLib::xInitDCI(DCI& dci, const SPS& sps) { dci.setMaxSubLayersMinus1(sps.getMaxTLayers() - 1); @@ -1167,49 +1049,44 @@ void EncLib::xInitDCI(DCI& dci, const SPS& sps) ptls[0] = *sps.getProfileTierLevel(); dci.setProfileTierLevel(ptls); } -#else -void EncLib::xInitDPS(DPS &dps, const SPS &sps, const int dpsId) -{ - // The SPS must have already been set up. - // set the DPS profile information. - dps.setDecodingParameterSetId(dpsId); - dps.setMaxSubLayersMinus1(sps.getMaxTLayers()-1); - std::vector<ProfileTierLevel> ptls; - ptls.resize(1); - ptls[0] = *sps.getProfileTierLevel(); - dps.setProfileTierLevel(ptls); -} -#endif -#if JVET_Q0814_DPB void EncLib::xInitSPS( SPS& sps ) -#else -void EncLib::xInitSPS( SPS& sps, VPS& vps ) -#endif { ProfileTierLevel* profileTierLevel = sps.getProfileTierLevel(); ConstraintInfo* cinfo = profileTierLevel->getConstraintInfo(); +#if !JVET_R0090_VUI cinfo->setProgressiveSourceFlag (m_progressiveSourceFlag); cinfo->setInterlacedSourceFlag (m_interlacedSourceFlag); +#endif cinfo->setNonPackedConstraintFlag (m_nonPackedConstraintFlag); -#if JVET_Q0114_CONSTRAINT_FLAGS cinfo->setNonProjectedConstraintFlag(m_nonProjectedConstraintFlag); cinfo->setNoResChangeInClvsConstraintFlag(m_noResChangeInClvsConstraintFlag); cinfo->setOneTilePerPicConstraintFlag(m_oneTilePerPicConstraintFlag); cinfo->setOneSlicePerPicConstraintFlag(m_oneSlicePerPicConstraintFlag); cinfo->setOneSubpicPerPicConstraintFlag(m_oneSubpicPerPicConstraintFlag); -#endif cinfo->setFrameOnlyConstraintFlag (m_frameOnlyConstraintFlag); cinfo->setIntraOnlyConstraintFlag (m_intraConstraintFlag); cinfo->setMaxBitDepthConstraintIdc (m_maxBitDepthConstraintIdc); cinfo->setMaxChromaFormatConstraintIdc((ChromaFormat)m_maxChromaFormatConstraintIdc); +#if JVET_R0286_GCI_CLEANUP + cinfo->setSingleLayerConstraintFlag (m_singleLayerConstraintFlag); + cinfo->setAllLayersIndependentConstraintFlag (m_allLayersIndependentConstraintFlag); + cinfo->setNoMrlConstraintFlag (m_noMrlConstraintFlag); + cinfo->setNoIspConstraintFlag (m_noIspConstraintFlag); + cinfo->setNoMipConstraintFlag (m_noMipConstraintFlag); + cinfo->setNoLfnstConstraintFlag (m_noLfnstConstraintFlag); + cinfo->setNoMmvdConstraintFlag (m_noMmvdConstraintFlag); + cinfo->setNoSmvdConstraintFlag (m_noSmvdConstraintFlag); + cinfo->setNoProfConstraintFlag (m_noProfConstraintFlag); + cinfo->setNoPaletteConstraintFlag (m_noPaletteConstraintFlag); + cinfo->setNoActConstraintFlag (m_noActConstraintFlag); + cinfo->setNoLmcsConstraintFlag (m_noLmcsConstraintFlag); +#endif cinfo->setNoQtbttDualTreeIntraConstraintFlag(m_bNoQtbttDualTreeIntraConstraintFlag); cinfo->setNoPartitionConstraintsOverrideConstraintFlag(m_noPartitionConstraintsOverrideConstraintFlag); cinfo->setNoSaoConstraintFlag(m_bNoSaoConstraintFlag); cinfo->setNoAlfConstraintFlag(m_bNoAlfConstraintFlag); -#if JVET_Q0795_CCALF cinfo->setNoCCAlfConstraintFlag(m_noCCAlfConstraintFlag); -#endif cinfo->setNoRefWraparoundConstraintFlag(m_bNoRefWraparoundConstraintFlag); cinfo->setNoTemporalMvpConstraintFlag(m_bNoTemporalMvpConstraintFlag); cinfo->setNoSbtmvpConstraintFlag(m_bNoSbtmvpConstraintFlag); @@ -1224,11 +1101,7 @@ void EncLib::xInitSPS( SPS& sps, VPS& vps ) cinfo->setNoIbcConstraintFlag(m_noIbcConstraintFlag); cinfo->setNoCiipConstraintFlag(m_bNoCiipConstraintFlag); cinfo->setNoFPelMmvdConstraintFlag(m_noFPelMmvdConstraintFlag); -#if !JVET_Q0806 - cinfo->setNoTriangleConstraintFlag(m_bNoTriangleConstraintFlag); -#else cinfo->setNoGeoConstraintFlag(m_noGeoConstraintFlag); -#endif cinfo->setNoLadfConstraintFlag(m_bNoLadfConstraintFlag); cinfo->setNoTransformSkipConstraintFlag(m_noTransformSkipConstraintFlag); cinfo->setNoBDPCMConstraintFlag(m_noBDPCMConstraintFlag); @@ -1256,11 +1129,7 @@ void EncLib::xInitSPS( SPS& sps, VPS& vps ) /* XXX: should Main be marked as compatible with still picture? */ /* XXX: may be a good idea to refactor the above into a function * that chooses the actual compatibility based upon options */ -#if JVET_Q0814_DPB sps.setVPSId( m_vps->getVPSId() ); -#else - sps.setVPSId(m_cVPS.getVPSId()); -#endif sps.setMaxPicWidthInLumaSamples( m_iSourceWidth ); sps.setMaxPicHeightInLumaSamples( m_iSourceHeight ); if (m_rprEnabled) @@ -1279,67 +1148,31 @@ void EncLib::xInitSPS( SPS& sps, VPS& vps ) sps.setMaxPicWidthInLumaSamples( maxPicWidth ); sps.setMaxPicHeightInLumaSamples( maxPicHeight ); } -#if JVET_Q0260_CONFORMANCE_WINDOW_IN_SPS sps.setConformanceWindow( m_conformanceWindow ); -#endif sps.setMaxCUWidth ( m_maxCUWidth ); sps.setMaxCUHeight ( m_maxCUHeight ); -#if JVET_Q0468_Q0469_MIN_LUMA_CB_AND_MIN_QT_FIX sps.setLog2MinCodingBlockSize ( m_log2MinCUSize ); -#else - sps.setMaxCodingDepth ( m_maxTotalCUDepth ); -#endif sps.setChromaFormatIdc ( m_chromaFormatIDC ); -#if !JVET_Q0468_Q0469_MIN_LUMA_CB_AND_MIN_QT_FIX - sps.setLog2DiffMaxMinCodingBlockSize(m_log2DiffMaxMinCodingBlockSize); -#endif sps.setCTUSize ( m_CTUSize ); sps.setSplitConsOverrideEnabledFlag ( m_useSplitConsOverride ); -#if JVET_Q0468_Q0469_MIN_LUMA_CB_AND_MIN_QT_FIX // convert the Intra Chroma minQT setting from chroma unit to luma unit m_uiMinQT[2] <<= getChannelTypeScaleX(CHANNEL_TYPE_CHROMA, m_chromaFormatIDC); -#endif sps.setMinQTSizes ( m_uiMinQT ); sps.setMaxMTTHierarchyDepth ( m_uiMaxMTTHierarchyDepth, m_uiMaxMTTHierarchyDepthI, m_uiMaxMTTHierarchyDepthIChroma ); -#if JVET_Q0330_BLOCK_PARTITION sps.setMaxBTSize( m_uiMaxBT[1], m_uiMaxBT[0], m_uiMaxBT[2] ); sps.setMaxTTSize( m_uiMaxTT[1], m_uiMaxTT[0], m_uiMaxTT[2] ); -#else - unsigned maxBtSize[3], maxTtSize[3]; - memcpy(maxBtSize, m_uiMinQT, sizeof(maxBtSize)); - memcpy(maxTtSize, m_uiMinQT, sizeof(maxTtSize)); - if (m_uiMaxMTTHierarchyDepth) - { - maxBtSize[1] = std::min(m_CTUSize, (unsigned)MAX_BT_SIZE_INTER); - maxTtSize[1] = std::min(m_CTUSize, (unsigned)MAX_TT_SIZE_INTER); - } - if (m_uiMaxMTTHierarchyDepthI) - { - maxBtSize[0] = std::min(m_CTUSize, (unsigned)MAX_BT_SIZE); - maxTtSize[0] = std::min(m_CTUSize, (unsigned)MAX_TT_SIZE); - } - if (m_uiMaxMTTHierarchyDepthIChroma) - { - maxBtSize[2] = std::min(m_CTUSize, (unsigned)MAX_BT_SIZE_C); - maxTtSize[2] = std::min(m_CTUSize, (unsigned)MAX_TT_SIZE_C); - } - sps.setMaxBTSize ( maxBtSize[1], maxBtSize[0], maxBtSize[2] ); - sps.setMaxTTSize ( maxTtSize[1], maxTtSize[0], maxTtSize[2] ); -#endif sps.setIDRRefParamListPresent ( m_idrRefParamList ); sps.setUseDualITree ( m_dualITree ); sps.setUseLFNST ( m_LFNST ); sps.setSBTMVPEnabledFlag ( m_SubPuMvpMode ); sps.setAMVREnabledFlag ( m_ImvMode != IMV_OFF ); sps.setBDOFEnabledFlag ( m_BIO ); -#if JVET_Q0798_SPS_NUMBER_MERGE_CANDIDATE sps.setMaxNumMergeCand(getMaxNumMergeCand()); sps.setMaxNumAffineMergeCand(getMaxNumAffineMergeCand()); sps.setMaxNumIBCMergeCand(getMaxNumIBCMergeCand()); sps.setMaxNumGeoCand(getMaxNumGeoCand()); -#endif sps.setUseAffine ( m_Affine ); sps.setUseAffineType ( m_AffineType ); sps.setUsePROF ( m_PROF ); @@ -1367,11 +1200,7 @@ void EncLib::xInitSPS( SPS& sps, VPS& vps ) #endif sps.setUseCiip ( m_ciip ); -#if !JVET_Q0806 - sps.setUseTriangle ( m_Triangle ); -#else sps.setUseGeo ( m_Geo ); -#endif sps.setUseMMVD ( m_MMVD ); sps.setFpelMmvdEnabledFlag (( m_MMVD ) ? m_allowDisFracMMVD : false); sps.setBdofControlPresentFlag(m_BIO); @@ -1389,33 +1218,14 @@ void EncLib::xInitSPS( SPS& sps, VPS& vps ) sps.setUseLmcs ( m_lmcsEnabled ); sps.setUseMRL ( m_MRL ); sps.setUseMIP ( m_MIP ); -#if JVET_Q0468_Q0469_MIN_LUMA_CB_AND_MIN_QT_FIX CHECK(m_log2MinCUSize > std::min(6, floorLog2(sps.getMaxCUWidth())), "log2_min_luma_coding_block_size_minus2 shall be in the range of 0 to min (4, log2_ctu_size - 2)"); -#else - int minCUSize = sps.getMaxCUWidth() >> sps.getLog2DiffMaxMinCodingBlockSize(); - int log2MinCUSize = 0; - while(minCUSize > 1) - { - minCUSize >>= 1; - log2MinCUSize++; - } - - sps.setLog2MinCodingBlockSize(log2MinCUSize); - CHECK(log2MinCUSize > std::min(6, floorLog2(sps.getMaxCUWidth())), "log2_min_luma_coding_block_size_minus2 shall be in the range of 0 to min (4, log2_ctu_size - 2)"); -#endif CHECK(m_uiMaxMTTHierarchyDepth > 2 * (floorLog2(sps.getCTUSize()) - sps.getLog2MinCodingBlockSize()), "sps_max_mtt_hierarchy_depth_inter_slice shall be in the range 0 to 2*(ctbLog2SizeY - log2MinCUSize)"); CHECK(m_uiMaxMTTHierarchyDepthI > 2 * (floorLog2(sps.getCTUSize()) - sps.getLog2MinCodingBlockSize()), "sps_max_mtt_hierarchy_depth_intra_slice_luma shall be in the range 0 to 2*(ctbLog2SizeY - log2MinCUSize)"); CHECK(m_uiMaxMTTHierarchyDepthIChroma > 2 * (floorLog2(sps.getCTUSize()) - sps.getLog2MinCodingBlockSize()), "sps_max_mtt_hierarchy_depth_intra_slice_chroma shall be in the range 0 to 2*(ctbLog2SizeY - log2MinCUSize)"); sps.setTransformSkipEnabledFlag(m_useTransformSkip); -#if JVET_Q0183_SPS_TRANSFORM_SKIP_MODE_CONTROL sps.setLog2MaxTransformSkipBlockSize(m_log2MaxTransformSkipBlockSize); -#endif -#if JVET_Q0089_SLICE_LOSSLESS_CODING_CHROMA_BDPCM sps.setBDPCMEnabledFlag(m_useBDPCM); -#else - sps.setBDPCMEnabled(m_useBDPCM); -#endif sps.setSPSTemporalMVPEnabledFlag((getTMVPModeId() == 2 || getTMVPModeId() == 1)); @@ -1425,11 +1235,17 @@ void EncLib::xInitSPS( SPS& sps, VPS& vps ) { sps.setBitDepth (ChannelType(channelType), m_bitDepth[channelType] ); sps.setQpBDOffset (ChannelType(channelType), (6 * (m_bitDepth[channelType] - 8))); +#if JVET_R0045_TS_MIN_QP_CLEANUP + sps.setInternalMinusInputBitDepth(ChannelType(channelType), max(0, (m_bitDepth[channelType] - m_inputBitDepth[channelType]))); +#else sps.setMinQpPrimeTsMinus4(ChannelType(channelType), max(0, 6 * (m_bitDepth[channelType] - m_inputBitDepth[channelType]))); +#endif } -#if JVET_Q0151_Q0205_ENTRYPOINTS sps.setEntropyCodingSyncEnabledFlag( m_entropyCodingSyncEnabledFlag ); +#if JVET_R0165_OPTIONAL_ENTRY_POINT + sps.setEntryPointsPresentFlag( m_entryPointPresentFlag ); +#else sps.setEntropyCodingSyncEntryPointsPresentFlag( m_entropyCodingSyncEntryPointPresentFlag ); #endif @@ -1448,13 +1264,13 @@ void EncLib::xInitSPS( SPS& sps, VPS& vps ) } sps.setScalingListFlag ( (m_useScalingListId == SCALING_LIST_OFF) ? 0 : 1 ); +#if JVET_R0380_SCALING_MATRIX_DISABLE_YCC_OR_RGB + sps.setScalingMatrixForAlternativeColourSpaceDisabledFlag( m_disableScalingMatrixForAlternativeColourSpace ); + sps.setScalingMatrixDesignatedColourSpaceFlag( m_scalingMatrixDesignatedColourSpace ); +#endif sps.setALFEnabledFlag( m_alf ); -#if JVET_Q0795_CCALF sps.setCCALFEnabledFlag( m_ccalf ); -#endif -#if JVET_Q0042_VUI sps.setFieldSeqFlag(false); -#endif sps.setVuiParametersPresentFlag(getVuiParametersPresentFlag()); if (sps.getVuiParametersPresentFlag()) @@ -1469,8 +1285,9 @@ void EncLib::xInitSPS( SPS& sps, VPS& vps ) pcVUI->setColourPrimaries(getColourPrimaries()); pcVUI->setTransferCharacteristics(getTransferCharacteristics()); pcVUI->setMatrixCoefficients(getMatrixCoefficients()); -#if !JVET_Q0042_VUI - pcVUI->setFieldSeqFlag(false); +#if JVET_R0090_VUI + pcVUI->setProgressiveSourceFlag (getProgressiveSourceFlag()); + pcVUI->setInterlacedSourceFlag (getInterlacedSourceFlag()); #endif pcVUI->setChromaLocInfoPresentFlag(getChromaLocInfoPresentFlag()); pcVUI->setChromaSampleLocTypeTopField(getChromaSampleLocTypeTopField()); @@ -1503,11 +1320,7 @@ void EncLib::xInitSPS( SPS& sps, VPS& vps ) } if( getBufferingPeriodSEIEnabled() || getPictureTimingSEIEnabled() || getDecodingUnitInfoSEIEnabled() ) { -#if JVET_P0118_HRD_ASPECTS sps.setGeneralHrdParametersPresentFlag(true); -#else - sps.setHrdParametersPresentFlag( true ); -#endif } // Set up SPS range extension settings @@ -1523,26 +1336,27 @@ void EncLib::xInitSPS( SPS& sps, VPS& vps ) sps.getSpsRangeExtension().setPersistentRiceAdaptationEnabledFlag(m_persistentRiceAdaptationEnabledFlag); sps.getSpsRangeExtension().setCabacBypassAlignmentEnabledFlag(m_cabacBypassAlignmentEnabledFlag); -#if JVET_Q0119_CLEANUPS sps.setSubPicInfoPresentFlag(m_subPicInfoPresentFlag); if (m_subPicInfoPresentFlag) -#else - sps.setSubPicPresentFlag(m_subPicPresentFlag); - if (m_subPicPresentFlag) -#endif { sps.setNumSubPics(m_numSubPics); - for (int i = 0; i < m_numSubPics; i++) - { - sps.setSubPicCtuTopLeftX(i, m_subPicCtuTopLeftX[i] ); - sps.setSubPicCtuTopLeftY(i, m_subPicCtuTopLeftY[i]); - sps.setSubPicWidth(i, m_subPicWidth[i]); - sps.setSubPicHeight(i, m_subPicHeight[i]); - sps.setSubPicTreatedAsPicFlag(i, m_subPicTreatedAsPicFlag[i]); - sps.setLoopFilterAcrossSubpicEnabledFlag(i, m_loopFilterAcrossSubpicEnabledFlag[i]); + sps.setSubPicCtuTopLeftX(m_subPicCtuTopLeftX); + sps.setSubPicCtuTopLeftY(m_subPicCtuTopLeftY); + sps.setSubPicWidth(m_subPicWidth); + sps.setSubPicHeight(m_subPicHeight); + sps.setSubPicTreatedAsPicFlag(m_subPicTreatedAsPicFlag); + sps.setLoopFilterAcrossSubpicEnabledFlag(m_loopFilterAcrossSubpicEnabledFlag); + sps.setSubPicIdLen(m_subPicIdLen); + sps.setSubPicIdMappingExplicitlySignalledFlag(m_subPicIdMappingExplicitlySignalledFlag); + if (m_subPicIdMappingExplicitlySignalledFlag) + { + sps.setSubPicIdMappingInSpsFlag(m_subPicIdMappingInSpsFlag); + if (m_subPicIdMappingInSpsFlag) + { + sps.setSubPicId(m_subPicId); + } } } -#if JVET_Q0044_SLICE_IDX_WITH_SUBPICS else //In that case, there is only one subpicture that contains the whole picture { sps.setNumSubPics(1); @@ -1552,49 +1366,23 @@ void EncLib::xInitSPS( SPS& sps, VPS& vps ) sps.setSubPicHeight(0, m_iSourceHeight); sps.setSubPicTreatedAsPicFlag(0, 1); sps.setLoopFilterAcrossSubpicEnabledFlag(0, 0); + sps.setSubPicIdLen(0); + sps.setSubPicIdMappingExplicitlySignalledFlag(false); } -#endif -#if JVET_Q0119_CLEANUPS - sps.setSubPicIdMappingExplicitlySignalledFlag(m_subPicIdMappingExplicitlySignalledFlag); - if (m_subPicIdMappingExplicitlySignalledFlag) + sps.setDepQuantEnabledFlag( m_DepQuantEnabledFlag ); + if (!sps.getDepQuantEnabledFlag()) { - sps.setSubPicIdMappingInSpsFlag(m_subPicIdMappingInSpsFlag); - if (m_subPicIdMappingInSpsFlag) - { - sps.setSubPicIdLen(m_subPicIdLen); - for (int i = 0; i < m_numSubPics; i++) - { - sps.setSubPicId(i, m_subPicId[i]); - } - } + sps.setSignDataHidingEnabledFlag( m_SignDataHidingEnabledFlag ); } -#else - sps.setSubPicIdPresentFlag(m_subPicIdPresentFlag); - if (m_subPicIdPresentFlag) - { - sps.setSubPicIdSignallingPresentFlag(m_subPicIdSignallingPresentFlag); - if (m_subPicIdSignallingPresentFlag) - { - sps.setSubPicIdLen(m_subPicIdLen); - for (int i = 0; i < m_numSubPics; i++) + else { - sps.setSubPicId(i, m_subPicId[i]); - } - } + sps.setSignDataHidingEnabledFlag(false); } -#endif - -#if JVET_Q0246_VIRTUAL_BOUNDARY_ENABLE_FLAG sps.setVirtualBoundariesEnabledFlag( m_virtualBoundariesEnabledFlag ); if( sps.getVirtualBoundariesEnabledFlag() ) { sps.setVirtualBoundariesPresentFlag( m_virtualBoundariesPresentFlag ); -#if JVET_Q0210_SUBPIC_VIRTUAL_BOUNDARY_CONSTRAINT CHECK( sps.getSubPicInfoPresentFlag() && sps.getVirtualBoundariesPresentFlag() != 1, "When subpicture signalling if present, the signalling of virtual boundaries, is present, shall be in the SPS" ); -#endif -#else - sps.setLoopFilterAcrossVirtualBoundariesDisabledFlag( m_loopFilterAcrossVirtualBoundariesDisabledFlag ); -#endif sps.setNumVerVirtualBoundaries ( m_numVerVirtualBoundaries ); sps.setNumHorVirtualBoundaries ( m_numHorVirtualBoundaries ); for( unsigned int i = 0; i < m_numVerVirtualBoundaries; i++ ) @@ -1605,104 +1393,36 @@ void EncLib::xInitSPS( SPS& sps, VPS& vps ) { sps.setVirtualBoundariesPosY ( m_virtualBoundariesPosY[i], i ); } -#if JVET_Q0246_VIRTUAL_BOUNDARY_ENABLE_FLAG } -#endif -#if JVET_Q0814_DPB -#if ENABLING_MULTI_SPS sps.setInterLayerPresentFlag( m_layerId > 0 && m_vps->getMaxLayers() > 1 && !m_vps->getAllIndependentLayersFlag() && !m_vps->getIndependentLayerFlag( m_vps->getGeneralLayerIdx( m_layerId ) ) ); CHECK( m_vps->getIndependentLayerFlag( m_vps->getGeneralLayerIdx( m_layerId ) ) && sps.getInterLayerPresentFlag(), " When vps_independent_layer_flag[GeneralLayerIdx[nuh_layer_id ]] is equal to 1, the value of inter_layer_ref_pics_present_flag shall be equal to 0." ); -#else - sps.setInterLayerPresentFlag( m_vps->getMaxLayers() > 1 && !m_vps->getAllIndependentLayersFlag() ); - - for( int i = 0; i < m_vps->getMaxLayers(); ++i ) - { -#if JVET_Q0786_PTL_only - //Bug fix to make the decoder run with configfile layers.cfg - if(m_vps->getIndependentLayerFlag(i) == 1) - sps.setInterLayerPresentFlag(0); -#endif - CHECK((m_vps->getIndependentLayerFlag(i) == 1) && (sps.getInterLayerPresentFlag() != 0), " When vps_independent_layer_flag[GeneralLayerIdx[nuh_layer_id ]] is equal to 1, the value of inter_layer_ref_pics_present_flag shall be equal to 0."); - } -#endif -#else -#if ENABLING_MULTI_SPS - sps.setInterLayerPresentFlag( m_layerId > 0 && vps.getMaxLayers() > 1 && !vps.getAllIndependentLayersFlag() && !vps.getIndependentLayerFlag( vps.getGeneralLayerIdx( m_layerId ) ) ); - CHECK( vps.getIndependentLayerFlag( vps.getGeneralLayerIdx( m_layerId ) ) && sps.getInterLayerPresentFlag(), " When vps_independent_layer_flag[GeneralLayerIdx[nuh_layer_id ]] is equal to 1, the value of inter_layer_ref_pics_present_flag shall be equal to 0." ); -#else - sps.setInterLayerPresentFlag( vps.getMaxLayers() > 1 && !vps.getAllIndependentLayersFlag() ); - for (unsigned int i = 0; i < vps.getMaxLayers(); ++i) - { -#if JVET_Q0786_PTL_only - //Bug fix to make the decoder run with configfile layers.cfg - if(vps.getIndependentLayerFlag(i) == 1) - sps.setInterLayerPresentFlag(0); -#endif - CHECK((vps.getIndependentLayerFlag(i) == 1) && (sps.getInterLayerPresentFlag() != 0), " When vps_independent_layer_flag[GeneralLayerIdx[nuh_layer_id ]] is equal to 1, the value of inter_layer_ref_pics_present_flag shall be equal to 0."); - } -#endif -#endif sps.setRprEnabledFlag( m_rprEnabled || sps.getInterLayerPresentFlag() ); -#if JVET_Q0297_MER sps.setLog2ParallelMergeLevelMinus2( m_log2ParallelMergeLevelMinus2 ); -#endif -#if JVET_Q0417_CONSTRAINT_SPS_VB_PRESENT_FLAG -#if JVET_Q0246_VIRTUAL_BOUNDARY_ENABLE_FLAG CHECK( sps.getRprEnabledFlag() && sps.getVirtualBoundariesEnabledFlag(), "when the value of res_change_in_clvs_allowed_flag is equal to 1, the value of sps_virtual_boundaries_present_flag shall be equal to 0" ); -#else - CHECK(sps.getRprEnabledFlag() && sps.getLoopFilterAcrossVirtualBoundariesDisabledFlag(), "when the value of res_change_in_clvs_allowed_flag is equal to 1, the value of sps_virtual_boundaries_present_flag shall be equal to 0"); -#endif -#endif } void EncLib::xInitHrdParameters(SPS &sps) { m_encHRD.initHRDParameters((EncCfg*) this); -#if JVET_P0118_HRD_ASPECTS GeneralHrdParams *generalHrdParams = sps.getGeneralHrdParameters(); *generalHrdParams = m_encHRD.getGeneralHrdParameters(); OlsHrdParams *olsHrdParams = sps.getOlsHrdParameters(); *olsHrdParams = m_encHRD.getOlsHrdParameters(); -#else - HRDParameters *hrdParams = sps.getHrdParameters(); - *hrdParams = m_encHRD.getHRDParameters(); - - TimingInfo *timingInfo = sps.getTimingInfo(); - *timingInfo = m_encHRD.getTimingInfo(); -#endif } void EncLib::xInitPPS(PPS &pps, const SPS &sps) { // pps ID already initialised. pps.setSPSId(sps.getSPSId()); -#if !JVET_Q0482_REMOVE_CONSTANT_PARAMS - pps.setConstantSliceHeaderParamsEnabledFlag(getConstantSliceHeaderParamsEnabledFlag()); - pps.setPPSDepQuantEnabledIdc(getPPSDepQuantEnabledIdc()); - pps.setPPSRefPicListSPSIdc0(getPPSRefPicListSPSIdc0()); - pps.setPPSRefPicListSPSIdc1(getPPSRefPicListSPSIdc1()); - pps.setPPSMvdL1ZeroIdc(getPPSMvdL1ZeroIdc()); - pps.setPPSCollocatedFromL0Idc(getPPSCollocatedFromL0Idc()); - pps.setPPSSixMinusMaxNumMergeCandPlus1(getPPSSixMinusMaxNumMergeCandPlus1()); -#if !JVET_Q0806 - pps.setPPSMaxNumMergeCandMinusMaxNumTriangleCandPlus1(getPPSMaxNumMergeCandMinusMaxNumTriangleCandPlus1()); -#else - pps.setPPSMaxNumMergeCandMinusMaxNumGeoCandPlus1(getPPSMaxNumMergeCandMinusMaxNumGeoCandPlus1()); -#endif -#endif pps.setNumSubPics(sps.getNumSubPics()); -#if JVET_Q0119_CLEANUPS pps.setSubPicIdMappingInPpsFlag(false); -#else - pps.setSubPicIdSignallingPresentFlag(false); -#endif pps.setSubPicIdLen(sps.getSubPicIdLen()); for(int picIdx=0; picIdx<pps.getNumSubPics(); picIdx++) { @@ -1721,12 +1441,10 @@ void EncLib::xInitPPS(PPS &pps, const SPS &sps) bUseDQP = true; } #endif -#if JVET_Q0420_PPS_CHROMA_TOOL_FLAG if (sps.getChromaFormatIdc() != CHROMA_400) { pps.setPPSChromaToolFlag (true); } -#endif #if ENABLE_QPA if (getUsePerceptQPA() && !bUseDQP) { @@ -1764,13 +1482,6 @@ void EncLib::xInitPPS(PPS &pps, const SPS &sps) { pps.clearChromaQpOffsetList(); } -#if !REMOVE_PPS_REXT - pps.getPpsRangeExtension().setCrossComponentPredictionEnabledFlag(m_crossComponentPredictionEnabledFlag); -#if !JVET_Q0441_SAO_MOD_12_BIT - pps.getPpsRangeExtension().setLog2SaoOffsetScale(CHANNEL_TYPE_LUMA, m_log2SaoOffsetScale[CHANNEL_TYPE_LUMA ]); - pps.getPpsRangeExtension().setLog2SaoOffsetScale(CHANNEL_TYPE_CHROMA, m_log2SaoOffsetScale[CHANNEL_TYPE_CHROMA]); -#endif -#endif { int baseQp = 26; if( 16 == getGOPSize() ) @@ -1855,9 +1566,6 @@ void EncLib::xInitPPS(PPS &pps, const SPS &sps) pps.setSliceChromaQpFlag(m_chromaCbQpOffsetDualTree != 0 || m_chromaCrQpOffsetDualTree != 0 || m_chromaCbCrQpOffsetDualTree != 0); } -#if !JVET_Q0151_Q0205_ENTRYPOINTS - pps.setEntropyCodingSyncEnabledFlag(m_entropyCodingSyncEnabledFlag); -#endif pps.setNoPicPartitionFlag( m_noPicPartitionFlag ); if( m_noPicPartitionFlag == false ) @@ -1869,20 +1577,19 @@ void EncLib::xInitPPS(PPS &pps, const SPS &sps) pps.setTileRowHeights( m_tileRowHeight ); pps.initTiles(); pps.setRectSliceFlag( m_rectSliceFlag ); - if( m_rectSliceFlag ) + if( m_rectSliceFlag ) { + pps.setSingleSlicePerSubPicFlag(m_singleSlicePerSubPicFlag); pps.setNumSlicesInPic( m_numSlicesInPic ); pps.setTileIdxDeltaPresentFlag( m_tileIdxDeltaPresentFlag ); pps.setRectSlices( m_rectSlices ); - pps.initRectSliceMap( ); -#if JVET_O1143_SUBPIC_BOUNDARY - pps.initSubPic(sps); -#endif + pps.initRectSliceMap(&sps); } else { pps.initRasterSliceMap( m_rasterSliceSize ); } + pps.initSubPic(sps); pps.setLoopFilterAcrossTilesEnabledFlag( m_bLFCrossTileBoundaryFlag ); pps.setLoopFilterAcrossSlicesEnabledFlag( m_bLFCrossSliceBoundaryFlag ); } @@ -1899,10 +1606,8 @@ void EncLib::xInitPPS(PPS &pps, const SPS &sps) pps.initRectSlices( ); pps.setTileIdxDeltaPresentFlag( 0 ); pps.setSliceTileIdx( 0, 0 ); - pps.initRectSliceMap( ); -#if JVET_O1143_SUBPIC_BOUNDARY + pps.initRectSliceMap( &sps ); pps.initSubPic(sps); -#endif pps.setLoopFilterAcrossTilesEnabledFlag( true ); pps.setLoopFilterAcrossSlicesEnabledFlag( true ); } @@ -1926,27 +1631,22 @@ void EncLib::xInitPPS(PPS &pps, const SPS &sps) { pps.setDeblockingFilterBetaOffsetDiv2( getLoopFilterBetaOffset() ); pps.setDeblockingFilterTcOffsetDiv2( getLoopFilterTcOffset() ); -#if JVET_Q0121_DEBLOCKING_CONTROL_PARAMETERS pps.setDeblockingFilterCbBetaOffsetDiv2( getLoopFilterCbBetaOffset() ); pps.setDeblockingFilterCbTcOffsetDiv2( getLoopFilterCbTcOffset() ); pps.setDeblockingFilterCrBetaOffsetDiv2( getLoopFilterCrBetaOffset() ); pps.setDeblockingFilterCrTcOffsetDiv2( getLoopFilterCrTcOffset() ); -#endif } else { pps.setDeblockingFilterBetaOffsetDiv2(0); pps.setDeblockingFilterTcOffsetDiv2(0); -#if JVET_Q0121_DEBLOCKING_CONTROL_PARAMETERS pps.setDeblockingFilterCbBetaOffsetDiv2(0); pps.setDeblockingFilterCbTcOffsetDiv2(0); pps.setDeblockingFilterCrBetaOffsetDiv2(0); pps.setDeblockingFilterCrTcOffsetDiv2(0); -#endif } // deblockingFilterControlPresentFlag is true if any of the settings differ from the inferred values: -#if JVET_Q0121_DEBLOCKING_CONTROL_PARAMETERS const bool deblockingFilterControlPresentFlag = pps.getDeblockingFilterOverrideEnabledFlag() || pps.getPPSDeblockingFilterDisabledFlag() || pps.getDeblockingFilterBetaOffsetDiv2() != 0 || @@ -1955,12 +1655,6 @@ void EncLib::xInitPPS(PPS &pps, const SPS &sps) pps.getDeblockingFilterCbTcOffsetDiv2() != 0 || pps.getDeblockingFilterCrBetaOffsetDiv2() != 0 || pps.getDeblockingFilterCrTcOffsetDiv2() != 0; -#else - const bool deblockingFilterControlPresentFlag = pps.getDeblockingFilterOverrideEnabledFlag() || - pps.getPPSDeblockingFilterDisabledFlag() || - pps.getDeblockingFilterBetaOffsetDiv2() != 0 || - pps.getDeblockingFilterTcOffsetDiv2() != 0; -#endif pps.setDeblockingFilterControlPresentFlag(deblockingFilterControlPresentFlag); @@ -1992,19 +1686,14 @@ void EncLib::xInitPPS(PPS &pps, const SPS &sps) CHECK(!(bestPos <= 15), "Unspecified error"); pps.setNumRefIdxL0DefaultActive(bestPos); pps.setNumRefIdxL1DefaultActive(bestPos); -#if !JVET_Q0183_SPS_TRANSFORM_SKIP_MODE_CONTROL - pps.setLog2MaxTransformSkipBlockSize(m_log2MaxTransformSkipBlockSize); -#endif pps.setPictureHeaderExtensionPresentFlag(false); -#if JVET_Q0819_PH_CHANGES pps.setRplInfoInPhFlag(getSliceLevelRpl() ? false : true); pps.setDbfInfoInPhFlag(getSliceLevelDblk() ? false : true); pps.setSaoInfoInPhFlag(getSliceLevelSao() ? false : true); pps.setAlfInfoInPhFlag(getSliceLevelAlf() ? false : true); pps.setWpInfoInPhFlag(getSliceLevelWp() ? false : true); pps.setQpDeltaInfoInPhFlag(getSliceLevelDeltaQp() ? false : true); -#endif pps.pcv = new PreCalcValues( sps, pps, true ); pps.setRpl1IdxPresentFlag(sps.getRPL1IdxPresentFlag()); @@ -2017,21 +1706,10 @@ void EncLib::xInitPicHeader(PicHeader &picHeader, const SPS &sps, const PPS &pps // parameter sets picHeader.setSPSId( sps.getSPSId() ); - picHeader.setPPSId( pps.getPPSId() ); - + picHeader.setPPSId( pps.getPPSId() ); + // merge list sizes -#if JVET_Q0798_SPS_NUMBER_MERGE_CANDIDATE picHeader.setMaxNumAffineMergeCand(getMaxNumAffineMergeCand()); -#else - picHeader.setMaxNumMergeCand ( getMaxNumMergeCand() ); - picHeader.setMaxNumAffineMergeCand( getMaxNumAffineMergeCand() ); -#if !JVET_Q0806 - picHeader.setMaxNumTriangleCand ( getMaxNumTriangleCand() ); -#else - picHeader.setMaxNumGeoCand ( getMaxNumGeoCand() ); -#endif - picHeader.setMaxNumIBCMergeCand ( getMaxNumIBCMergeCand() ); -#endif // copy partitioning constraints from SPS picHeader.setSplitConsOverrideFlag(false); picHeader.setMinQTSizes( sps.getMinQTSizes() ); @@ -2039,10 +1717,11 @@ void EncLib::xInitPicHeader(PicHeader &picHeader, const SPS &sps, const PPS &pps picHeader.setMaxBTSizes( sps.getMaxBTSizes() ); picHeader.setMaxTTSizes( sps.getMaxTTSizes() ); +#if !JVET_R0271_SLICE_LEVEL_DQ_SDH_RRC // quantization - picHeader.setDepQuantEnabledFlag( getDepQuantEnabledFlag() ); - picHeader.setSignDataHidingEnabledFlag( getSignDataHidingEnabledFlag() ); - + picHeader.setDepQuantEnabledFlag( sps.getDepQuantEnabledFlag() ); + picHeader.setSignDataHidingEnabledFlag( sps.getSignDataHidingEnabledFlag() ); +#endif bool bUseDQP = (getCuQpDeltaSubdiv() > 0)? true : false; if( (getMaxDeltaQP() != 0 )|| getUseAdaptiveQP() ) @@ -2095,37 +1774,23 @@ void EncLib::xInitPicHeader(PicHeader &picHeader, const SPS &sps, const PPS &pps picHeader.setCuChromaQpOffsetSubdivIntra(0); picHeader.setCuChromaQpOffsetSubdivInter(0); } - -#if !JVET_Q0119_CLEANUPS - // sub-pictures - picHeader.setSubPicIdSignallingPresentFlag(sps.getSubPicIdSignallingPresentFlag()); - picHeader.setSubPicIdLen(sps.getSubPicIdLen()); - for(i=0; i<sps.getNumSubPics(); i++) { - picHeader.setSubPicId(i, sps.getSubPicId(i)); - } -#endif + // virtual boundaries -#if JVET_Q0246_VIRTUAL_BOUNDARY_ENABLE_FLAG if( sps.getVirtualBoundariesEnabledFlag() ) { picHeader.setVirtualBoundariesPresentFlag( sps.getVirtualBoundariesPresentFlag() ); -#else - picHeader.setLoopFilterAcrossVirtualBoundariesDisabledFlag(sps.getLoopFilterAcrossVirtualBoundariesDisabledFlag()); -#endif picHeader.setNumVerVirtualBoundaries(sps.getNumVerVirtualBoundaries()); picHeader.setNumHorVirtualBoundaries(sps.getNumHorVirtualBoundaries()); for(i=0; i<3; i++) { picHeader.setVirtualBoundariesPosX(sps.getVirtualBoundariesPosX(i), i); picHeader.setVirtualBoundariesPosY(sps.getVirtualBoundariesPosY(i), i); } -#if JVET_Q0246_VIRTUAL_BOUNDARY_ENABLE_FLAG } -#endif // gradual decoder refresh flag picHeader.setGdrPicFlag(false); - + // BDOF / DMVR / PROF picHeader.setDisBdofFlag(false); picHeader.setDisDmvrFlag(false); @@ -2473,15 +2138,7 @@ int EncCfg::getQPForPicture(const uint32_t gopIndex, const Slice *pSlice) const if (getCostMode()==COST_LOSSLESS_CODING) { -#if JVET_AHG14_LOSSLESS -#if JVET_AHG14_LOSSLESS_ENC_QP_FIX qp = getBaseQP(); -#else - qp = LOSSLESS_AND_MIXED_LOSSLESS_RD_COST_TEST_QP - ( ( pSlice->getSPS()->getBitDepth( CHANNEL_TYPE_LUMA ) - 8 ) * 6 ); -#endif -#else - qp=LOSSLESS_AND_MIXED_LOSSLESS_RD_COST_TEST_QP; -#endif } else { diff --git a/source/Lib/EncoderLib/EncLib.h b/source/Lib/EncoderLib/EncLib.h index 5a8ba8c87c69b6cddf24cb276fc09c1e8d184f2e..3a2e28cd411067aec421ece8953f45abee848d0f 100644 --- a/source/Lib/EncoderLib/EncLib.h +++ b/source/Lib/EncoderLib/EncLib.h @@ -155,32 +155,19 @@ private: #endif int m_picIdInGOP; -#if JVET_Q0814_DPB VPS* m_vps; -#endif public: SPS* getSPS( int spsId ) { return m_spsMap.getPS( spsId ); }; APS** getApss() { return m_apss; } Ctx m_entropyCodingSyncContextState; ///< leave in addition to vector for compatibility -#if JVET_Q0501_PALETTE_WPP_INIT_ABOVECTU PLTBuf m_palettePredictorSyncState; -#endif protected: void xGetNewPicBuffer ( std::list<PelUnitBuf*>& rcListPicYuvRecOut, Picture*& rpcPic, int ppsId ); ///< get picture buffer which will be processed. If ppsId<0, then the ppsMap will be queried for the first match. -#if JVET_Q0117_PARAMETER_SETS_CLEANUP 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 -#if JVET_Q0814_DPB void xInitVPS( const SPS& sps ); ///< initialize VPS from encoder options void xInitSPS( SPS& sps ); ///< initialize SPS from encoder options -#else - void xInitVPS(VPS& vps, const SPS& sps); ///< initialize VPS from encoder options - void xInitSPS ( SPS& sps, VPS& vps ); ///< initialize SPS from encoder options -#endif void xInitPPS (PPS &pps, const SPS &sps); ///< initialize PPS from encoder options void xInitPicHeader (PicHeader &picHeader, const SPS &sps, const PPS &pps); ///< initialize Picture Header from encoder options void xInitAPS (APS &aps); ///< initialize APS from encoder options @@ -299,9 +286,7 @@ public: void printSummary( bool isField ) { m_cGOPEncoder.printOutSummary( m_uiNumAllPicCoded, isField, m_printMSEBasedSequencePSNR, m_printSequenceMSE, m_printHexPsnr, m_rprEnabled, m_spsMap.getFirstPS()->getBitDepths() ); } int getLayerId() const { return m_layerId; } -#if JVET_Q0814_DPB VPS* getVPS() { return m_vps; } -#endif }; //! \} diff --git a/source/Lib/EncoderLib/EncLibCommon.h b/source/Lib/EncoderLib/EncLibCommon.h index a422beda396f3fbf0fad974f1f5a35b649708645..996ddc93af5071311528055c2163982d71f6b6b2 100644 --- a/source/Lib/EncoderLib/EncLibCommon.h +++ b/source/Lib/EncoderLib/EncLibCommon.h @@ -49,9 +49,7 @@ private: ParameterSetMap<PPS> m_ppsMap; ///< PPS, it is shared across all layers ParameterSetMap<APS> m_apsMap; ///< APS, it is shared across all layers PicList m_cListPic; ///< DPB, it is shared across all layers -#if JVET_Q0814_DPB VPS m_vps; -#endif public: EncLibCommon(); @@ -62,8 +60,6 @@ public: ParameterSetMap<SPS>& getSpsMap() { return m_spsMap; } ParameterSetMap<PPS>& getPpsMap() { return m_ppsMap; } ParameterSetMap<APS>& getApsMap() { return m_apsMap; } -#if JVET_Q0814_DPB VPS* getVPS() { return &m_vps; } -#endif }; diff --git a/source/Lib/EncoderLib/EncModeCtrl.cpp b/source/Lib/EncoderLib/EncModeCtrl.cpp index da6b06b25d2b640503010a03f7c7bef938353bef..fbfddcc9f13a8f4e736494a2b0da9db4408b1ee4 100644 --- a/source/Lib/EncoderLib/EncModeCtrl.cpp +++ b/source/Lib/EncoderLib/EncModeCtrl.cpp @@ -1324,20 +1324,12 @@ void EncModeCtrlMTnoRQT::initCULevel( Partitioner &partitioner, const CodingStru // add intra modes if( tryIntraRdo ) { -#if JVET_Q0504_PLT_NON444 if (cs.slice->getSPS()->getPLTMode() && (partitioner.treeType != TREE_D || cs.slice->isIRAP() || (cs.area.lwidth() == 4 && cs.area.lheight() == 4)) && getPltEnc()) -#else - if (cs.slice->getSPS()->getPLTMode() && ( cs.slice->isIRAP() || (cs.area.lwidth() == 4 && cs.area.lheight() == 4) ) && getPltEnc() ) -#endif { m_ComprCUCtxList.back().testModes.push_back({ ETM_PALETTE, ETO_STANDARD, qp }); } m_ComprCUCtxList.back().testModes.push_back( { ETM_INTRA, ETO_STANDARD, qp } ); -#if JVET_Q0504_PLT_NON444 if (cs.slice->getSPS()->getPLTMode() && partitioner.treeType == TREE_D && !cs.slice->isIRAP() && !(cs.area.lwidth() == 4 && cs.area.lheight() == 4) && getPltEnc()) -#else - if (cs.slice->getSPS()->getPLTMode() && !cs.slice->isIRAP() && !(cs.area.lwidth() == 4 && cs.area.lheight() == 4) && getPltEnc() ) -#endif { m_ComprCUCtxList.back().testModes.push_back({ ETM_PALETTE, ETO_STANDARD, qp }); } @@ -1372,17 +1364,10 @@ void EncModeCtrlMTnoRQT::initCULevel( Partitioner &partitioner, const CodingStru // add inter modes if( m_pcEncCfg->getUseEarlySkipDetection() ) { -#if !JVET_Q0806 - if( cs.sps->getUseTriangle() && cs.slice->isInterB() ) - { - m_ComprCUCtxList.back().testModes.push_back( { ETM_MERGE_TRIANGLE, ETO_STANDARD, qp } ); - } -#else if( cs.sps->getUseGeo() && cs.slice->isInterB() ) { m_ComprCUCtxList.back().testModes.push_back( { ETM_MERGE_GEO, ETO_STANDARD, qp } ); } -#endif m_ComprCUCtxList.back().testModes.push_back( { ETM_MERGE_SKIP, ETO_STANDARD, qp } ); if ( cs.sps->getUseAffine() || cs.sps->getSBTMVPEnabledFlag() ) { @@ -1393,17 +1378,10 @@ void EncModeCtrlMTnoRQT::initCULevel( Partitioner &partitioner, const CodingStru else { m_ComprCUCtxList.back().testModes.push_back( { ETM_INTER_ME, ETO_STANDARD, qp } ); -#if !JVET_Q0806 - if( cs.sps->getUseTriangle() && cs.slice->isInterB() ) - { - m_ComprCUCtxList.back().testModes.push_back( { ETM_MERGE_TRIANGLE, ETO_STANDARD, qp } ); - } -#else if( cs.sps->getUseGeo() && cs.slice->isInterB() ) { m_ComprCUCtxList.back().testModes.push_back( { ETM_MERGE_GEO, ETO_STANDARD, qp } ); } -#endif m_ComprCUCtxList.back().testModes.push_back( { ETM_MERGE_SKIP, ETO_STANDARD, qp } ); if ( cs.sps->getUseAffine() || cs.sps->getSBTMVPEnabledFlag() ) { @@ -1441,11 +1419,7 @@ bool EncModeCtrlMTnoRQT::tryMode( const EncTestMode& encTestmode, const CodingSt ComprCUCtx& cuECtx = m_ComprCUCtxList.back(); // Fast checks, partitioning depended -#if !JVET_Q0806 - if (cuECtx.isHashPerfectMatch && encTestmode.type != ETM_MERGE_SKIP && encTestmode.type != ETM_INTER_ME && encTestmode.type != ETM_AFFINE && encTestmode.type != ETM_MERGE_TRIANGLE) -#else if (cuECtx.isHashPerfectMatch && encTestmode.type != ETM_MERGE_SKIP && encTestmode.type != ETM_INTER_ME && encTestmode.type != ETM_AFFINE && encTestmode.type != ETM_MERGE_GEO) -#endif { return false; } @@ -1522,7 +1496,7 @@ bool EncModeCtrlMTnoRQT::tryMode( const EncTestMode& encTestmode, const CodingSt if( m_pcEncCfg->getUseFastLCTU() && partitioner.currArea().lumaSize().area() > 4096 ) { - return false; + return (m_pcEncCfg->getDualITree() == 0 && m_pcEncCfg->getMaxMTTHierarchyDepthI() == 0 && cs.sps->getMinQTSize(cs.slice->getSliceType(), partitioner.chType) > 64); } if (CS::isDualITree(cs) && (partitioner.currArea().lumaSize().width > 64 || partitioner.currArea().lumaSize().height > 64)) @@ -1578,11 +1552,7 @@ bool EncModeCtrlMTnoRQT::tryMode( const EncTestMode& encTestmode, const CodingSt } } } -#if JVET_Q0504_PLT_NON444 if (bestMode.type == ETM_PALETTE && !slice.isIRAP() && partitioner.treeType == TREE_D && !(partitioner.currArea().lumaSize().width == 4 && partitioner.currArea().lumaSize().height == 4)) // inter slice -#else - if (bestMode.type == ETM_PALETTE && !slice.isIRAP() && !( partitioner.currArea().lumaSize().width == 4 && partitioner.currArea().lumaSize().height == 4) ) // inter slice -#endif { return false; } @@ -1598,24 +1568,23 @@ bool EncModeCtrlMTnoRQT::tryMode( const EncTestMode& encTestmode, const CodingSt } else if (encTestmode.type == ETM_PALETTE) { -#if JVET_Q0629_REMOVAL_PLT_4X4 +#if JVET_R0334_PLT_CLEANUP if (partitioner.currArea().lumaSize().width > 64 || partitioner.currArea().lumaSize().height > 64 || ((partitioner.currArea().lumaSize().width * partitioner.currArea().lumaSize().height <= 16) && (isLuma(partitioner.chType)) ) - || ((partitioner.currArea().chromaSize().width * partitioner.currArea().chromaSize().height <= 16) && (!isLuma(partitioner.chType)) && partitioner.isSepTree(cs) ) ) + || ((partitioner.currArea().chromaSize().width * partitioner.currArea().chromaSize().height <= 16) && (!isLuma(partitioner.chType)) && partitioner.isSepTree(cs) ) + || (partitioner.isLocalSepTree(cs) && (!isLuma(partitioner.chType)) ) ) #else - if (partitioner.currArea().lumaSize().width > 64 || partitioner.currArea().lumaSize().height > 64) -#endif + if (partitioner.currArea().lumaSize().width > 64 || partitioner.currArea().lumaSize().height > 64 + || ((partitioner.currArea().lumaSize().width * partitioner.currArea().lumaSize().height <= 16) && (isLuma(partitioner.chType)) ) + || ((partitioner.currArea().chromaSize().width * partitioner.currArea().chromaSize().height <= 16) && (!isLuma(partitioner.chType)) && partitioner.isSepTree(cs) ) ) +#endif { return false; } const Area curr_cu = CS::getArea(cs, cs.area, partitioner.chType).blocks[getFirstComponentOfChannel(partitioner.chType)]; try { -#if JVET_Q0504_PLT_NON444 double stored_cost = slice.m_mapPltCost[isChroma(partitioner.chType)].at(curr_cu.pos()).at(curr_cu.size()); -#else - double stored_cost = slice.m_mapPltCost.at(curr_cu.pos()).at(curr_cu.size()); -#endif if (bestMode.type != ETM_INVALID && stored_cost > cuECtx.bestCS->cost) { return false; @@ -1680,20 +1649,13 @@ bool EncModeCtrlMTnoRQT::tryMode( const EncTestMode& encTestmode, const CodingSt { return false; } -#if !JVET_Q0806 - if( encTestmode.type == ETM_MERGE_TRIANGLE && ( partitioner.currArea().lumaSize().area() < TRIANGLE_MIN_SIZE || relatedCU.isIntra ) ) - { - return false; - } -#else - if( encTestmode.type == ETM_MERGE_GEO && ( partitioner.currArea().lwidth() < GEO_MIN_CU_SIZE || partitioner.currArea().lheight() < GEO_MIN_CU_SIZE + if( encTestmode.type == ETM_MERGE_GEO && ( partitioner.currArea().lwidth() < GEO_MIN_CU_SIZE || partitioner.currArea().lheight() < GEO_MIN_CU_SIZE || partitioner.currArea().lwidth() > GEO_MAX_CU_SIZE || partitioner.currArea().lheight() > GEO_MAX_CU_SIZE || partitioner.currArea().lwidth() >= 8 * partitioner.currArea().lheight() || partitioner.currArea().lheight() >= 8 * partitioner.currArea().lwidth() ) ) { return false; } -#endif return true; } else if( isModeSplit( encTestmode ) ) @@ -1880,7 +1842,6 @@ bool EncModeCtrlMTnoRQT::tryMode( const EncTestMode& encTestmode, const CodingSt } if( split == CU_QUAD_SPLIT ) cuECtx.set( DID_QUAD_SPLIT, true ); -#if JVET_Q0297_MER if (cs.sps->getLog2ParallelMergeLevelMinus2()) { const CompArea& area = partitioner.currArea().Y(); @@ -1893,7 +1854,6 @@ bool EncModeCtrlMTnoRQT::tryMode( const EncTestMode& encTestmode, const CodingSt if (area.width <= 2 * size && split == CU_TRIV_SPLIT) return false; } } -#endif return true; } else diff --git a/source/Lib/EncoderLib/EncModeCtrl.h b/source/Lib/EncoderLib/EncModeCtrl.h index f2b75071dabfb5cdf9ebb21cc73bd6ba0ae26506..0eb7a332980179db841f56498c0982c03568c451 100644 --- a/source/Lib/EncoderLib/EncModeCtrl.h +++ b/source/Lib/EncoderLib/EncModeCtrl.h @@ -59,11 +59,7 @@ enum EncTestModeType ETM_MERGE_SKIP, ETM_INTER_ME, ETM_AFFINE, -#if !JVET_Q0806 - ETM_MERGE_TRIANGLE, -#else ETM_MERGE_GEO, -#endif ETM_INTRA, ETM_PALETTE, ETM_SPLIT_QT, @@ -142,11 +138,7 @@ inline bool isModeInter( const EncTestMode& encTestmode ) // perhaps remove return ( encTestmode.type == ETM_INTER_ME || encTestmode.type == ETM_MERGE_SKIP || encTestmode.type == ETM_AFFINE -#if !JVET_Q0806 - || encTestmode.type == ETM_MERGE_TRIANGLE -#else || encTestmode.type == ETM_MERGE_GEO -#endif || encTestmode.type == ETM_HASH_INTER ); } diff --git a/source/Lib/EncoderLib/EncReshape.cpp b/source/Lib/EncoderLib/EncReshape.cpp index 2660ff0c45c24f95fe217ed793aa7266279a9bf3..471c92393d1d1b7bce57b1e44047faa6fd9c1116 100644 --- a/source/Lib/EncoderLib/EncReshape.cpp +++ b/source/Lib/EncoderLib/EncReshape.cpp @@ -366,18 +366,8 @@ void EncReshape::calcSeqStats(Picture *pcPic, SeqInfo &stats) } picY = pcPic->getOrigBuf(COMPONENT_Y); -#if JVET_Q0438_MONOCHROME_BUGFIXES double avgY = 0.0; double varY = 0.0; -#else - PelBuf picU = pcPic->getOrigBuf(COMPONENT_Cb); - PelBuf picV = pcPic->getOrigBuf(COMPONENT_Cr); - const int widthC = picU.width; - const int heightC = picU.height; - const int strideC = picU.stride; - double avgY = 0.0, avgU = 0.0, avgV = 0.0; - double varY = 0.0, varU = 0.0, varV = 0.0; -#endif for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) @@ -387,7 +377,6 @@ void EncReshape::calcSeqStats(Picture *pcPic, SeqInfo &stats) } picY.buf += stride; } -#if JVET_Q0438_MONOCHROME_BUGFIXES avgY = avgY / (width * height); varY = varY / (width * height) - avgY * avgY; @@ -400,7 +389,6 @@ void EncReshape::calcSeqStats(Picture *pcPic, SeqInfo &stats) const int strideC = picU.stride; double avgU = 0.0, avgV = 0.0; double varU = 0.0, varV = 0.0; -#endif for (int y = 0; y < heightC; y++) { for (int x = 0; x < widthC; x++) @@ -413,14 +401,8 @@ void EncReshape::calcSeqStats(Picture *pcPic, SeqInfo &stats) picU.buf += strideC; picV.buf += strideC; } -#if !JVET_Q0438_MONOCHROME_BUGFIXES - avgY = avgY / (width * height); -#endif avgU = avgU / (widthC * heightC); avgV = avgV / (widthC * heightC); -#if !JVET_Q0438_MONOCHROME_BUGFIXES - varY = varY / (width * height) - avgY * avgY; -#endif varU = varU / (widthC * heightC) - avgU * avgU; varV = varV / (widthC * heightC) - avgV * avgV; if (varY > 0) @@ -428,9 +410,7 @@ void EncReshape::calcSeqStats(Picture *pcPic, SeqInfo &stats) stats.ratioStdU = sqrt(varU) / sqrt(varY); stats.ratioStdV = sqrt(varV) / sqrt(varY); } -#if JVET_Q0438_MONOCHROME_BUGFIXES } -#endif } void EncReshape::preAnalyzerLMCS(Picture *pcPic, const uint32_t signalType, const SliceType sliceType, const ReshapeCW& reshapeCW) { diff --git a/source/Lib/EncoderLib/EncSampleAdaptiveOffset.cpp b/source/Lib/EncoderLib/EncSampleAdaptiveOffset.cpp index 44e214ff819d20d2b6a28fbe354fe48ca805ea44..03fa92b61acbc85a28b5917554e3f8b265a6efcf 100644 --- a/source/Lib/EncoderLib/EncSampleAdaptiveOffset.cpp +++ b/source/Lib/EncoderLib/EncSampleAdaptiveOffset.cpp @@ -1556,7 +1556,7 @@ void EncSampleAdaptiveOffset::deriveLoopFilterBoundaryAvailibility(CodingStructu isAboveAvail = (cuAbove == NULL) ? false : CU::isSameTile(*cuCurr, *cuAbove); isAboveLeftAvail = (cuAboveLeft == NULL) ? false : CU::isSameTile(*cuCurr, *cuAboveLeft); } - else + else { isLeftAvail = (cuLeft != NULL); isAboveAvail = (cuAbove != NULL); @@ -1570,15 +1570,13 @@ void EncSampleAdaptiveOffset::deriveLoopFilterBoundaryAvailibility(CodingStructu isAboveLeftAvail = (!isAboveLeftAvail) ? false : CU::isSameTile(*cuCurr, *cuAboveLeft); } -#if JVET_O1143_LPF_ACROSS_SUBPIC_BOUNDARY - SubPic curSubPic = cs.pps->getSubPicFromCU(*cuCurr); + const SubPic& curSubPic = cs.pps->getSubPicFromCU(*cuCurr); if (!curSubPic.getloopFilterAcrossEnabledFlag()) { isLeftAvail = (!isLeftAvail) ? false : CU::isSameSubPic(*cuCurr, *cuLeft); isAboveAvail = (!isAboveAvail) ? false : CU::isSameSubPic(*cuCurr, *cuAbove); isAboveLeftAvail = (!isAboveLeftAvail) ? false : CU::isSameSubPic(*cuCurr, *cuAboveLeft); } -#endif } //! \} diff --git a/source/Lib/EncoderLib/EncSlice.cpp b/source/Lib/EncoderLib/EncSlice.cpp index a7d4ff101af1d26fe4eb5a3f66992da7b515b1ae..c821cdbe78ee9a95f5181fc9cca78ee8d70ea6cf 100644 --- a/source/Lib/EncoderLib/EncSlice.cpp +++ b/source/Lib/EncoderLib/EncSlice.cpp @@ -117,11 +117,7 @@ EncSlice::setUpLambda( Slice* slice, const double dLambda, int iQP) int chromaQPOffset = slice->getPPS()->getQpOffset( compID ) + slice->getSliceChromaQpDelta( compID ); int qpc = slice->getSPS()->getMappedChromaQpValue(compID, iQP) + chromaQPOffset; double tmpWeight = pow( 2.0, ( iQP - qpc ) / 3.0 ); // takes into account of the chroma qp mapping and chroma qp Offset -#if JVET_Q0433_MODIFIED_CHROMA_DIST_WEIGHT if( m_pcCfg->getDepQuantEnabledFlag() ) -#else - if( m_pcCfg->getDepQuantEnabledFlag() && !( m_pcCfg->getLFNST() ) ) -#endif { tmpWeight *= ( m_pcCfg->getGOPSize() >= 8 ? pow( 2.0, 0.1/3.0 ) : pow( 2.0, 0.2/3.0 ) ); // increase chroma weight for dependent quantization (in order to reduce bit rate shift from chroma to luma) } @@ -343,8 +339,36 @@ void EncSlice::initEncSlice(Picture* pcPic, const int pocLast, const int pocCurr picHeader->setPicOutputFlag(true); } rpcSlice->setPOC( pocCurr ); -#if JVET_Q0089_SLICE_LOSSLESS_CODING_CHROMA_BDPCM + +#if JVET_R0271_SLICE_LEVEL_DQ_SDH_RRC + if( m_pcCfg->getCostMode() != COST_LOSSLESS_CODING ) + { + rpcSlice->setDepQuantEnabledFlag( m_pcCfg->getDepQuantEnabledFlag() ); + rpcSlice->setSignDataHidingEnabledFlag( m_pcCfg->getSignDataHidingEnabledFlag() ); + rpcSlice->setTSResidualCodingDisabledFlag( false ); + + CHECK( (m_pcCfg->getDepQuantEnabledFlag() || m_pcCfg->getSignDataHidingEnabledFlag() ) + && rpcSlice->getTSResidualCodingDisabledFlag() , "TSRC cannot be bypassed if either DQ or SDH are enabled at slice level."); + } + else + { + rpcSlice->setDepQuantEnabledFlag( false ); //should be disabled for lossless + rpcSlice->setSignDataHidingEnabledFlag( false ); //should be disabled for lossless +#if JVET_R0143_TSRCdisableLL + if( m_pcCfg->getTSRCdisableLL() ) + { + rpcSlice->setTSResidualCodingDisabledFlag( true ); + } +#else + rpcSlice->setTSResidualCodingDisabledFlag( true ); +#endif + } +#else +#if JVET_R0143_TSRCdisableLL + if( ( m_pcCfg->getCostMode() == COST_LOSSLESS_CODING ) && m_pcCfg->getTSRCdisableLL() ) +#else if( m_pcCfg->getCostMode() == COST_LOSSLESS_CODING ) +#endif { rpcSlice->setTSResidualCodingDisabledFlag(true); } @@ -604,6 +628,9 @@ void EncSlice::initEncSlice(Picture* pcPic, const int pocLast, const int pocCurr rpcSlice->setSliceQp ( iQP ); rpcSlice->setSliceQpDelta ( 0 ); +#if JVET_R0110_MIXED_LOSSLESS + pcPic->setLossyQPValue(iQP); +#endif #if !W0038_CQP_ADJ rpcSlice->setSliceChromaQpDelta( COMPONENT_Cb, 0 ); rpcSlice->setSliceChromaQpDelta( COMPONENT_Cr, 0 ); @@ -619,12 +646,10 @@ void EncSlice::initEncSlice(Picture* pcPic, const int pocLast, const int pocCurr rpcSlice->setDeblockingFilterDisable(false); rpcSlice->setDeblockingFilterBetaOffsetDiv2( 0 ); rpcSlice->setDeblockingFilterTcOffsetDiv2( 0 ); -#if JVET_Q0121_DEBLOCKING_CONTROL_PARAMETERS rpcSlice->setDeblockingFilterCbBetaOffsetDiv2( 0 ); rpcSlice->setDeblockingFilterCbTcOffsetDiv2( 0 ); rpcSlice->setDeblockingFilterCrBetaOffsetDiv2( 0 ); rpcSlice->setDeblockingFilterCrTcOffsetDiv2( 0 ); -#endif } else if (rpcSlice->getPPS()->getDeblockingFilterControlPresentFlag()) { @@ -636,23 +661,19 @@ void EncSlice::initEncSlice(Picture* pcPic, const int pocLast, const int pocCurr { rpcSlice->setDeblockingFilterBetaOffsetDiv2( m_pcCfg->getGOPEntry(iGOPid).m_betaOffsetDiv2 + m_pcCfg->getLoopFilterBetaOffset() ); rpcSlice->setDeblockingFilterTcOffsetDiv2( m_pcCfg->getGOPEntry(iGOPid).m_tcOffsetDiv2 + m_pcCfg->getLoopFilterTcOffset() ); -#if JVET_Q0121_DEBLOCKING_CONTROL_PARAMETERS rpcSlice->setDeblockingFilterCbBetaOffsetDiv2( m_pcCfg->getGOPEntry(iGOPid).m_CbBetaOffsetDiv2 + m_pcCfg->getLoopFilterCbBetaOffset() ); rpcSlice->setDeblockingFilterCbTcOffsetDiv2( m_pcCfg->getGOPEntry(iGOPid).m_CbTcOffsetDiv2 + m_pcCfg->getLoopFilterCbTcOffset() ); rpcSlice->setDeblockingFilterCrBetaOffsetDiv2( m_pcCfg->getGOPEntry(iGOPid).m_CrBetaOffsetDiv2 + m_pcCfg->getLoopFilterCrBetaOffset() ); rpcSlice->setDeblockingFilterCrTcOffsetDiv2( m_pcCfg->getGOPEntry(iGOPid).m_CrTcOffsetDiv2 + m_pcCfg->getLoopFilterCrTcOffset() ); -#endif } else { rpcSlice->setDeblockingFilterBetaOffsetDiv2( m_pcCfg->getLoopFilterBetaOffset() ); rpcSlice->setDeblockingFilterTcOffsetDiv2( m_pcCfg->getLoopFilterTcOffset() ); -#if JVET_Q0121_DEBLOCKING_CONTROL_PARAMETERS rpcSlice->setDeblockingFilterCbBetaOffsetDiv2( m_pcCfg->getLoopFilterCbBetaOffset() ); rpcSlice->setDeblockingFilterCbTcOffsetDiv2( m_pcCfg->getLoopFilterCbTcOffset() ); rpcSlice->setDeblockingFilterCrBetaOffsetDiv2( m_pcCfg->getLoopFilterCrBetaOffset() ); rpcSlice->setDeblockingFilterCrTcOffsetDiv2( m_pcCfg->getLoopFilterCrTcOffset() ); -#endif } } } @@ -662,12 +683,10 @@ void EncSlice::initEncSlice(Picture* pcPic, const int pocLast, const int pocCurr rpcSlice->setDeblockingFilterDisable( false ); rpcSlice->setDeblockingFilterBetaOffsetDiv2( 0 ); rpcSlice->setDeblockingFilterTcOffsetDiv2( 0 ); -#if JVET_Q0121_DEBLOCKING_CONTROL_PARAMETERS rpcSlice->setDeblockingFilterCbBetaOffsetDiv2( 0 ); rpcSlice->setDeblockingFilterCbTcOffsetDiv2( 0 ); rpcSlice->setDeblockingFilterCrBetaOffsetDiv2( 0 ); rpcSlice->setDeblockingFilterCrTcOffsetDiv2( 0 ); -#endif } pcPic->layer = temporalId; @@ -1119,6 +1138,36 @@ void EncSlice::setSearchRange( Slice* pcSlice ) } } +#if JVET_R0110_MIXED_LOSSLESS +void EncSlice::setLosslessSlice(Picture* pcPic, bool islossless) +{ + Slice* slice = pcPic->slices[getSliceSegmentIdx()]; + slice->setLossless(islossless); + + if (m_pcCfg->getCostMode() == COST_LOSSLESS_CODING) + { + if (islossless) + { + int losslessQp = LOSSLESS_AND_MIXED_LOSSLESS_RD_COST_TEST_QP - ((slice->getSPS()->getBitDepth(CHANNEL_TYPE_LUMA) - 8) * 6); + slice->setSliceQp(losslessQp); // update the slice/base QPs + +#if JVET_R0143_TSRCdisableLL + slice->setTSResidualCodingDisabledFlag(m_pcCfg->getTSRCdisableLL() ? true : false); +#else + slice->setTSResidualCodingDisabledFlag(true); +#endif + + } + else + { + slice->setSliceQp(pcPic->getLossyQPValue()); + slice->setTSResidualCodingDisabledFlag(false); + } + } +} +#endif + + /** Multi-loop slice encoding for different slice QP @@ -1219,6 +1268,30 @@ void EncSlice::calCostSliceI(Picture* pcPic) // TODO: this only analyses the fir m_pcRateCtrl->getRCPic()->setTotalIntraCost(iSumHadSlice); } +void EncSlice::calCostPictureI(Picture* picture) +{ + double sumHadPicture = 0; + Slice * const slice = picture->slices[getSliceSegmentIdx()]; + const PreCalcValues& pcv = *picture->cs->pcv; + const SPS &sps = *(slice->getSPS()); + const int shift = sps.getBitDepth(CHANNEL_TYPE_LUMA) - 8; + const int offset = (shift>0) ? (1 << (shift - 1)) : 0; + + for (uint32_t ctuIdx = 0; ctuIdx < picture->m_ctuNums; ctuIdx++) + { + Position pos((ctuIdx % pcv.widthInCtus) * pcv.maxCUWidth, (ctuIdx / pcv.widthInCtus) * pcv.maxCUHeight); + + const int height = std::min(pcv.maxCUHeight, pcv.lumaHeight - pos.y); + const int width = std::min(pcv.maxCUWidth, pcv.lumaWidth - pos.x); + const CompArea blk(COMPONENT_Y, pcv.chrFormat, pos, Size(width, height)); + int sumHad = m_pcCuEncoder->updateCtuDataISlice(picture->getOrigBuf(blk)); + + (m_pcRateCtrl->getRCPic()->getLCU(ctuIdx)).m_costIntra = (sumHad + offset) >> shift; + sumHadPicture += (m_pcRateCtrl->getRCPic()->getLCU(ctuIdx)).m_costIntra; + } + m_pcRateCtrl->getRCPic()->setTotalIntraCost(sumHadPicture); +} + /** \param pcPic picture class */ void EncSlice::compressSlice( Picture* pcPic, const bool bCompressEntireSlice, const bool bFastDeltaQP ) @@ -1425,6 +1498,9 @@ void EncSlice::encodeCtus( Picture* pcPic, const bool bCompressEntireSlice, cons RdCost* pRdCost = pEncLib->getRdCost( PARL_PARAM0( dataId ) ); EncCfg* pCfg = pEncLib; RateCtrl* pRateCtrl = pEncLib->getRateCtrl(); +#if JVET_R0110_MIXED_LOSSLESS + pRdCost->setLosslessRDCost(pcSlice->isLossless()); +#endif #if RDOQ_CHROMA_LAMBDA pTrQuant ->setLambdas( pcSlice->getLambdas() ); #else @@ -1475,8 +1551,7 @@ void EncSlice::encodeCtus( Picture* pcPic, const bool bCompressEntireSlice, cons cs.motionLut.lutIbc.resize(0); } -#if JVET_O1143_MV_ACROSS_SUBPIC_BOUNDARY - SubPic curSubPic = pcSlice->getPPS()->getSubPicFromPos(pos); + const SubPic &curSubPic = pcSlice->getPPS()->getSubPicFromPos(pos); // padding/restore at slice level if (pcSlice->getPPS()->getNumSubPics() >= 2 && curSubPic.getTreatedAsPicFlag() && ctuIdx == 0) { @@ -1485,13 +1560,13 @@ void EncSlice::encodeCtus( Picture* pcPic, const bool bCompressEntireSlice, cons int subPicWidth = (int)curSubPic.getSubPicWidthInLumaSample(); int subPicHeight = (int)curSubPic.getSubPicHeightInLumaSample(); - for (int rlist = REF_PIC_LIST_0; rlist < NUM_REF_PIC_LIST_01; rlist++) + for (int rlist = REF_PIC_LIST_0; rlist < NUM_REF_PIC_LIST_01; rlist++) { int n = pcSlice->getNumRefIdx((RefPicList)rlist); - for (int idx = 0; idx < n; idx++) + for (int idx = 0; idx < n; idx++) { Picture *refPic = pcSlice->getRefPic((RefPicList)rlist, idx); - if (!refPic->getSubPicSaved()) + if (!refPic->getSubPicSaved()) { refPic->saveSubPicBorder(refPic->getPOC(), subPicX, subPicY, subPicWidth, subPicHeight); refPic->extendSubPicBorder(refPic->getPOC(), subPicX, subPicY, subPicWidth, subPicHeight); @@ -1500,7 +1575,6 @@ void EncSlice::encodeCtus( Picture* pcPic, const bool bCompressEntireSlice, cons } } } -#endif if (cs.pps->ctuIsTileColBd( ctuXPosInCtus ) && cs.pps->ctuIsTileRowBd( ctuYPosInCtus )) { pCABACWriter->initCtxModels( *pcSlice ); @@ -1516,9 +1590,7 @@ void EncSlice::encodeCtus( Picture* pcPic, const bool bCompressEntireSlice, cons { // Top is available, we use it. pCABACWriter->getCtx() = pEncLib->m_entropyCodingSyncContextState; -#if JVET_Q0501_PALETTE_WPP_INIT_ABOVECTU cs.setPrevPLT(pEncLib->m_palettePredictorSyncState); -#endif } prevQP[0] = prevQP[1] = pcSlice->getSliceQp(); } @@ -1641,9 +1713,7 @@ void EncSlice::encodeCtus( Picture* pcPic, const bool bCompressEntireSlice, cons if( cs.pps->ctuIsTileColBd( ctuXPosInCtus ) && pEncLib->getEntropyCodingSyncEnabledFlag() ) { pEncLib->m_entropyCodingSyncContextState = pCABACWriter->getCtx(); -#if JVET_Q0501_PALETTE_WPP_INIT_ABOVECTU cs.storePrevPLT(pEncLib->m_palettePredictorSyncState); -#endif } int actualBits = int(cs.fracBits >> SCALE_BITS); @@ -1697,8 +1767,7 @@ void EncSlice::encodeCtus( Picture* pcPic, const bool bCompressEntireSlice, cons m_uiPicTotalBits += actualBits; m_uiPicDist = cs.dist; -#if JVET_O1143_MV_ACROSS_SUBPIC_BOUNDARY - // for last Ctu in the slice + // for last Ctu in the slice if (pcSlice->getPPS()->getNumSubPics() >= 2 && curSubPic.getTreatedAsPicFlag() && ctuIdx == (pcSlice->getNumCtuInSlice() - 1)) { @@ -1707,13 +1776,13 @@ void EncSlice::encodeCtus( Picture* pcPic, const bool bCompressEntireSlice, cons int subPicWidth = (int)curSubPic.getSubPicWidthInLumaSample(); int subPicHeight = (int)curSubPic.getSubPicHeightInLumaSample(); - for (int rlist = REF_PIC_LIST_0; rlist < NUM_REF_PIC_LIST_01; rlist++) + for (int rlist = REF_PIC_LIST_0; rlist < NUM_REF_PIC_LIST_01; rlist++) { int n = pcSlice->getNumRefIdx((RefPicList)rlist); - for (int idx = 0; idx < n; idx++) + for (int idx = 0; idx < n; idx++) { Picture *refPic = pcSlice->getRefPic((RefPicList)rlist, idx); - if (refPic->getSubPicSaved()) + if (refPic->getSubPicSaved()) { refPic->restoreSubPicBorder(refPic->getPOC(), subPicX, subPicY, subPicWidth, subPicHeight); refPic->setSubPicSaved(false); @@ -1721,7 +1790,6 @@ void EncSlice::encodeCtus( Picture* pcPic, const bool bCompressEntireSlice, cons } } } -#endif } // this is wpp exclusive section @@ -1735,14 +1803,14 @@ void EncSlice::encodeSlice ( Picture* pcPic, OutputBitstream* pcSubstreams, ui { Slice *const pcSlice = pcPic->slices[getSliceSegmentIdx()]; -#if JVET_Q0151_Q0205_ENTRYPOINTS const bool wavefrontsEnabled = pcSlice->getSPS()->getEntropyCodingSyncEnabledFlag(); +#if JVET_R0165_OPTIONAL_ENTRY_POINT + const bool entryPointsPresentFlag = pcSlice->getSPS()->getEntryPointsPresentFlag(); +#else const bool wavefrontsEntryPointsFlag = (wavefrontsEnabled) ? pcSlice->getSPS()->getEntropyCodingSyncEntryPointsPresentFlag() : false; +#endif uint32_t substreamSize = 0; pcSlice->resetNumberOfSubstream(); -#else - const bool wavefrontsEnabled = pcSlice->getPPS()->getEntropyCodingSyncEnabledFlag(); -#endif // setup coding structure @@ -1793,9 +1861,7 @@ void EncSlice::encodeSlice ( Picture* pcPic, OutputBitstream* pcSubstreams, ui { // Top is available, so use it. m_CABACWriter->getCtx() = m_entropyCodingSyncContextState; -#if JVET_Q0501_PALETTE_WPP_INIT_ABOVECTU cs.setPrevPLT(m_palettePredictorSyncState); -#endif } } @@ -1811,9 +1877,7 @@ void EncSlice::encodeSlice ( Picture* pcPic, OutputBitstream* pcSubstreams, ui if( cs.pps->ctuIsTileColBd( ctuXPosInCtus ) && wavefrontsEnabled ) { m_entropyCodingSyncContextState = m_CABACWriter->getCtx(); -#if JVET_Q0501_PALETTE_WPP_INIT_ABOVECTU cs.storePrevPLT(m_palettePredictorSyncState); -#endif } // terminate the sub-stream, if required (end of slice-segment, end of tile, end of wavefront-CTU-row): @@ -1830,17 +1894,17 @@ void EncSlice::encodeSlice ( Picture* pcPic, OutputBitstream* pcSubstreams, ui if (!isLastCTUsinSlice) //Byte alignment only when it is not the last substream in the slice { // write sub-stream size -#if JVET_Q0151_Q0205_ENTRYPOINTS substreamSize += (pcSubstreams[uiSubStrm].getNumberOfWrittenBits() >> 3) + pcSubstreams[uiSubStrm].countStartCodeEmulations(); pcSlice->increaseNumberOfSubstream(); +#if JVET_R0165_OPTIONAL_ENTRY_POINT + if( entryPointsPresentFlag ) +#else if( isLastCTUinTile || (isLastCTUinWPP && wavefrontsEntryPointsFlag) ) +#endif { pcSlice->addSubstreamSize(substreamSize); substreamSize = 0; } -#else - pcSlice->addSubstreamSize((pcSubstreams[uiSubStrm].getNumberOfWrittenBits() >> 3) + pcSubstreams[uiSubStrm].countStartCodeEmulations()); -#endif } uiSubStrm++; } diff --git a/source/Lib/EncoderLib/EncSlice.h b/source/Lib/EncoderLib/EncSlice.h index 6c633aa055bdf8f82315e8157820725cf9b059c0..be28672cc3f1eb065b7569a2070b3370029b2968 100644 --- a/source/Lib/EncoderLib/EncSlice.h +++ b/source/Lib/EncoderLib/EncSlice.h @@ -92,9 +92,7 @@ private: uint32_t m_uiSliceSegmentIdx; Ctx m_entropyCodingSyncContextState; ///< context storage for state of contexts at the wavefront/WPP/entropy-coding-sync second CTU of tile-row SliceType m_encCABACTableIdx; -#if JVET_Q0501_PALETTE_WPP_INIT_ABOVECTU PLTBuf m_palettePredictorSyncState; -#endif #if SHARP_LUMA_DELTA_QP || ENABLE_QPA_SUB_CTU int m_gopID; #endif @@ -130,7 +128,10 @@ public: void precompressSlice ( Picture* pcPic ); ///< precompress slice for multi-loop slice-level QP opt. void compressSlice ( Picture* pcPic, const bool bCompressEntireSlice, const bool bFastDeltaQP ); ///< analysis stage of slice void calCostSliceI ( Picture* pcPic ); - + void calCostPictureI ( Picture* picture ); +#if JVET_R0110_MIXED_LOSSLESS + void setLosslessSlice(Picture* pcPic, bool b); ///< Set if the slice is lossless or not +#endif void encodeSlice ( Picture* pcPic, OutputBitstream* pcSubstreams, uint32_t &numBinsCoded ); void encodeCtus ( Picture* pcPic, const bool bCompressEntireSlice, const bool bFastDeltaQP, EncLib* pcEncLib ); void checkDisFracMmvd ( Picture* pcPic, uint32_t startCtuTsAddr, uint32_t boundingCtuTsAddr ); diff --git a/source/Lib/EncoderLib/InterSearch.cpp b/source/Lib/EncoderLib/InterSearch.cpp index 35ba55a6bbea9871b2b734bc7d61baa88f6b6448..7940ab788ad7ec8bf086ca90011d0e405d34a468 100644 --- a/source/Lib/EncoderLib/InterSearch.cpp +++ b/source/Lib/EncoderLib/InterSearch.cpp @@ -809,15 +809,10 @@ int InterSearch::xIBCSearchMVChromaRefine(PredictionUnit& pu, ) { -#if JVET_Q0438_MONOCHROME_BUGFIXES if ( (!isChromaEnabled(pu.chromaFormat)) || (!pu.Cb().valid()) ) { return 0; } -#else - if (!pu.Cb().valid()) - return 0; -#endif int bestCandIdx = 0; Distortion sadBest = std::numeric_limits<Distortion>::max(); @@ -1269,11 +1264,7 @@ void InterSearch::xIBCEstimation(PredictionUnit& pu, PelUnitBuf& origBuf, CPelBuf* pcPatternKey = &tmpPattern; PelBuf tmpOrgLuma; -#if JVET_Q0346_LMCS_ENABLE_IN_SH if ((pu.cs->slice->getLmcsEnabledFlag() && m_pcReshape->getCTUFlag())) -#else - if ((pu.cs->picHeader->getLmcsEnabledFlag() && m_pcReshape->getCTUFlag())) -#endif { const CompArea &area = pu.blocks[COMPONENT_Y]; CompArea tmpArea(COMPONENT_Y, area.chromaFormat, Position(0, 0), area.size()); @@ -1464,11 +1455,7 @@ bool InterSearch::predIBCSearch(CodingUnit& cu, Partitioner& partitioner, const int bvpIdxBest = 0; cMv.setZero(); Distortion cost = 0; -#if JVET_Q0798_SPS_NUMBER_MERGE_CANDIDATE if (pu.cs->sps->getMaxNumIBCMergeCand() == 1) -#else - if ( pu.cu->slice->getPicHeader()->getMaxNumIBCMergeCand() == 1 ) -#endif { iBvpNum = 1; cMvPred[1] = cMvPred[0]; @@ -6171,12 +6158,6 @@ void InterSearch::xEncodeInterResidualQT(CodingStructure &cs, Partitioner &parti const int cbfMask = ( TU::getCbf( currTU, COMPONENT_Cb ) ? 2 : 0) + ( TU::getCbf( currTU, COMPONENT_Cr ) ? 1 : 0 ); m_CABACEstimator->joint_cb_cr( currTU, cbfMask ); } -#if !REMOVE_PPS_REXT - if( TU::hasCrossCompPredInfo( currTU, compID ) ) - { - m_CABACEstimator->cross_comp_pred( currTU, compID ); - } -#endif if( TU::getCbf( currTU, compID ) ) { m_CABACEstimator->residual_coding( currTU, compID ); @@ -6491,9 +6472,6 @@ void InterSearch::xEstimateInterResidualQT(CodingStructure &cs, Partitioner &par Distortion uiSingleDist = 0; Distortion uiSingleDistComp [3] = { 0, 0, 0 }; uint64_t uiSingleFracBits[3] = { 0, 0, 0 }; -#if !REMOVE_PPS_REXT - TCoeff uiAbsSum [3] = { 0, 0, 0 }; -#endif const TempCtx ctxStart ( m_CtxCache, m_CABACEstimator->getCtx() ); TempCtx ctxBest ( m_CtxCache ); @@ -6509,11 +6487,7 @@ void InterSearch::xEstimateInterResidualQT(CodingStructure &cs, Partitioner &par const UnitArea relativeUnitArea(tu.chromaFormat, Area(tuPos, tu.Y().size())); const Slice &slice = *cs.slice; -#if JVET_Q0346_LMCS_ENABLE_IN_SH if (slice.getLmcsEnabledFlag() && slice.getPicHeader()->getLmcsChromaResidualScaleFlag() && !(CS::isDualITree(cs) && slice.isIntra() && tu.cu->predMode == MODE_IBC)) -#else - if (slice.getPicHeader()->getLmcsEnabledFlag() && slice.getPicHeader()->getLmcsChromaResidualScaleFlag() && !(CS::isDualITree(cs) && slice.isIntra() && tu.cu->predMode==MODE_IBC )) -#endif { const CompArea &areaY = tu.blocks[COMPONENT_Y]; int adj = m_pcReshape->calculateChromaAdjVpduNei(tu, areaY); @@ -6553,38 +6527,25 @@ void InterSearch::xEstimateInterResidualQT(CodingStructure &cs, Partitioner &par continue; } -#if !REMOVE_PPS_REXT - const bool isCrossCPredictionAvailable = TU::hasCrossCompPredInfo( tu, compID ); -#endif - -#if !REMOVE_PPS_REXT - int8_t preCalcAlpha = 0; - const CPelBuf lumaResi = csFull->getResiBuf(tu.Y()); - if (isCrossCPredictionAvailable) - { - csFull->getResiBuf( compArea ).copyFrom( cs.getOrgResiBuf( compArea ) ); - preCalcAlpha = xCalcCrossComponentPredictionAlpha( tu, compID, m_pcEncCfg->getUseReconBasedCrossCPredictionEstimate() ); - } -#endif const bool tsAllowed = TU::isTSAllowed(tu, compID) && (isLuma(compID) || (isChroma(compID) && m_pcEncCfg->getUseChromaTS())); const bool mtsAllowed = CU::isMTSAllowed( *tu.cu, compID ); - + uint8_t nNumTransformCands = 1 + ( tsAllowed ? 1 : 0 ) + ( mtsAllowed ? 4 : 0 ); // DCT + TS + 4 MTS = 6 tests std::vector<TrMode> trModes; -#if JVET_Q0820_ACT +#if JVET_R0110_MIXED_LOSSLESS + if (m_pcEncCfg->getCostMode() == COST_LOSSLESS_CODING && slice.isLossless()) +#else if (m_pcEncCfg->getCostMode() == COST_LOSSLESS_CODING) +#endif { nNumTransformCands = 0; } else { -#endif trModes.push_back( TrMode( 0, true ) ); //DCT2 nNumTransformCands = 1; -#if JVET_Q0820_ACT } -#endif //for a SBT-no-residual TU, the RDO process should be called once, in order to get the RD cost if( tsAllowed && !tu.noResidual ) { @@ -6613,42 +6574,20 @@ void InterSearch::xEstimateInterResidualQT(CodingStructure &cs, Partitioner &par #endif } } - -#if JVET_Q0820_ACT +#if JVET_R0110_MIXED_LOSSLESS + if (colorTransFlag && (m_pcEncCfg->getCostMode() != COST_LOSSLESS_CODING || !slice.isLossless())) +#else if (colorTransFlag && (m_pcEncCfg->getCostMode() != COST_LOSSLESS_CODING)) -#else - if (colorTransFlag) #endif { m_pcTrQuant->lambdaAdjustColorTrans(true); m_pcRdCost->lambdaAdjustColorTrans(true, compID); } -#if !REMOVE_PPS_REXT - const int crossCPredictionModesToTest = preCalcAlpha != 0 ? 2 : 1; -#endif const int numTransformCandidates = nNumTransformCands; -#if !JVET_Q0695_CHROMA_TS_JCCR - const bool isOneMode = crossCPredictionModesToTest == 1 && numTransformCandidates == 1; - - bool isLastBest = isOneMode; -#endif for( int transformMode = 0; transformMode < numTransformCandidates; transformMode++ ) { -#if !REMOVE_PPS_REXT - for( int crossCPredictionModeId = 0; crossCPredictionModeId < crossCPredictionModesToTest; crossCPredictionModeId++ ) - { - const bool isFirstMode = transformMode == 0 && crossCPredictionModeId == 0; -#if !JVET_Q0695_CHROMA_TS_JCCR - const bool isLastMode = ( transformMode + 1 ) == numTransformCandidates && ( crossCPredictionModeId + 1 ) == crossCPredictionModesToTest; -#endif - const bool bUseCrossCPrediction = crossCPredictionModeId != 0; -#else const bool isFirstMode = transformMode == 0; -#if !JVET_Q0695_CHROMA_TS_JCCR - const bool isLastMode = ( transformMode + 1 ) == numTransformCandidates; -#endif -#endif // copy the original residual into the residual buffer csFull->getResiBuf(compArea).copyFrom(cs.getOrgResiBuf(compArea)); @@ -6656,10 +6595,12 @@ void InterSearch::xEstimateInterResidualQT(CodingStructure &cs, Partitioner &par m_CABACEstimator->resetBits(); { -#if JVET_AHG14_LOSSLESS - if( !( m_pcEncCfg->getCostMode() == COST_LOSSLESS_CODING ) ) - { +#if JVET_R0110_MIXED_LOSSLESS + if (!(m_pcEncCfg->getCostMode() == COST_LOSSLESS_CODING && slice.isLossless())) +#else + if( !( m_pcEncCfg->getCostMode() == COST_LOSSLESS_CODING) ) #endif + { if (bestTU.mtsIdx[compID] == MTS_SKIP && m_pcEncCfg->getUseTransformSkipFast()) { continue; @@ -6668,35 +6609,15 @@ void InterSearch::xEstimateInterResidualQT(CodingStructure &cs, Partitioner &par { continue; } -#if JVET_AHG14_LOSSLESS } -#endif tu.mtsIdx[compID] = trModes[transformMode].first; } -#if !REMOVE_PPS_REXT - tu.compAlpha[compID] = bUseCrossCPrediction ? preCalcAlpha : 0; -#endif QpParam cQP(tu, compID); // note: uses tu.transformSkip[compID] -#if !JVET_Q0820_ACT - if (colorTransFlag) - { - for (int qpIdx = 0; qpIdx < 2; qpIdx++) - { - cQP.Qps[qpIdx] = cQP.Qps[qpIdx] + (compID == COMPONENT_Cr ? DELTA_QP_FOR_Co : DELTA_QP_FOR_Y_Cg); - cQP.pers[qpIdx] = cQP.Qps[qpIdx] / 6; - cQP.rems[qpIdx] = cQP.Qps[qpIdx] % 6; - } - } -#endif #if RDOQ_CHROMA_LAMBDA m_pcTrQuant->selectLambda(compID); #endif -#if JVET_Q0346_LMCS_ENABLE_IN_SH if (slice.getLmcsEnabledFlag() && isChroma(compID) && slice.getPicHeader()->getLmcsChromaResidualScaleFlag()) -#else - if (slice.getPicHeader()->getLmcsEnabledFlag() && isChroma(compID) && slice.getPicHeader()->getLmcsChromaResidualScaleFlag()) -#endif { double cRescale = (double)(1 << CSCALE_FP_PREC) / (double)(tu.getChromaAdj()); m_pcTrQuant->setLambda(m_pcTrQuant->getLambda() / (cRescale*cRescale)); @@ -6714,18 +6635,7 @@ void InterSearch::xEstimateInterResidualQT(CodingStructure &cs, Partitioner &par Distortion nonCoeffDist = 0; double nonCoeffCost = 0; -#if !REMOVE_PPS_REXT - if (bUseCrossCPrediction) - { - PelBuf resiBuf = csFull->getResiBuf( compArea ); - crossComponentPrediction( tu, compID, lumaResi, resiBuf, resiBuf, false ); - } -#endif -#if JVET_Q0346_LMCS_ENABLE_IN_SH if (slice.getLmcsEnabledFlag() && isChroma(compID) && slice.getPicHeader()->getLmcsChromaResidualScaleFlag() && tu.blocks[compID].width * tu.blocks[compID].height > 4) -#else - if (slice.getPicHeader()->getLmcsEnabledFlag() && isChroma(compID) && slice.getPicHeader()->getLmcsChromaResidualScaleFlag() && tu.blocks[compID].width*tu.blocks[compID].height > 4) -#endif { PelBuf resiBuf = csFull->getResiBuf(compArea); resiBuf.scaleSignal(tu.getChromaAdj(), 1, tu.cu->cs->slice->clpRng(compID)); @@ -6737,14 +6647,14 @@ void InterSearch::xEstimateInterResidualQT(CodingStructure &cs, Partitioner &par m_pcTrQuant->transformNxN( tu, compID, cQP, &trModes, m_pcEncCfg->getMTSInterMaxCand() ); tu.mtsIdx[compID] = trModes[0].first; } -#if JVET_AHG14_LOSSLESS +#if JVET_R0110_MIXED_LOSSLESS + if (!(m_pcEncCfg->getCostMode() == COST_LOSSLESS_CODING && slice.isLossless() && tu.mtsIdx[compID] == 0)) +#else if( !( m_pcEncCfg->getCostMode() == COST_LOSSLESS_CODING && tu.mtsIdx[compID] == 0 ) ) +#endif { m_pcTrQuant->transformNxN( tu, compID, cQP, currAbsSum, m_CABACEstimator->getCtx(), true ); } -#else - m_pcTrQuant->transformNxN( tu, compID, cQP, currAbsSum, m_CABACEstimator->getCtx(), true ); -#endif } else { @@ -6756,15 +6666,6 @@ void InterSearch::xEstimateInterResidualQT(CodingStructure &cs, Partitioner &par const CPelBuf zeroBuf(m_pTempPel, compArea); const CPelBuf orgResi = csFull->getOrgResiBuf( compArea ); -#if !REMOVE_PPS_REXT - if (bUseCrossCPrediction) - { - PelBuf resi = csFull->getResiBuf( compArea ); - crossComponentPrediction( tu, compID, lumaResi, zeroBuf, resi, true ); - nonCoeffDist = m_pcRdCost->getDistPart( orgResi, resi, channelBitDepth, compID, DF_SSE ); - } - else -#endif { nonCoeffDist = m_pcRdCost->getDistPart( zeroBuf, orgResi, channelBitDepth, compID, DF_SSE ); // initialized with zero residual distortion } @@ -6774,12 +6675,6 @@ void InterSearch::xEstimateInterResidualQT(CodingStructure &cs, Partitioner &par const bool prevCbf = ( compID == COMPONENT_Cr ? tu.cbf[COMPONENT_Cb] : false ); m_CABACEstimator->cbf_comp( *csFull, false, compArea, currDepth, prevCbf ); -#if !REMOVE_PPS_REXT - if( isCrossCPredictionAvailable ) - { - m_CABACEstimator->cross_comp_pred( tu, compID ); - } -#endif } nonCoeffFracBits = m_CABACEstimator->getEstFracBits(); @@ -6804,13 +6699,14 @@ void InterSearch::xEstimateInterResidualQT(CodingStructure &cs, Partitioner &par { *puiZeroDist += nonCoeffDist; // initialized with zero residual distortion } - -#if JVET_AHG14_LOSSLESS +#if JVET_R0110_MIXED_LOSSLESS + if (m_pcEncCfg->getCostMode() == COST_LOSSLESS_CODING && slice.isLossless() && tu.mtsIdx[compID] == 0) +#else if( m_pcEncCfg->getCostMode() == COST_LOSSLESS_CODING && tu.mtsIdx[compID] == 0 ) +#endif { currAbsSum = 0; } -#endif if (currAbsSum > 0) //if non-zero coefficients are present, a residual needs to be derived for further prediction { @@ -6828,13 +6724,6 @@ void InterSearch::xEstimateInterResidualQT(CodingStructure &cs, Partitioner &par m_CABACEstimator->joint_cb_cr( tu, cbfMask ); } -#if !REMOVE_PPS_REXT - if( isCrossCPredictionAvailable ) - { - m_CABACEstimator->cross_comp_pred( tu, compID ); - } -#endif -#if JVET_Q0516_MTS_SIGNALLING_DC_ONLY_COND CUCtx cuCtx; cuCtx.isDQPCoded = true; cuCtx.isChromaQpAdjCoded = true; @@ -6847,9 +6736,6 @@ void InterSearch::xEstimateInterResidualQT(CodingStructure &cs, Partitioner &par } else { -#else - m_CABACEstimator->residual_coding(tu, compID); -#endif currCompFracBits = m_CABACEstimator->getEstFracBits(); @@ -6857,21 +6743,11 @@ void InterSearch::xEstimateInterResidualQT(CodingStructure &cs, Partitioner &par CPelBuf orgResiBuf = csFull->getOrgResiBuf(compArea); m_pcTrQuant->invTransformNxN(tu, compID, resiBuf, cQP); -#if JVET_Q0346_LMCS_ENABLE_IN_SH if (slice.getLmcsEnabledFlag() && isChroma(compID) && slice.getPicHeader()->getLmcsChromaResidualScaleFlag() && tu.blocks[compID].width * tu.blocks[compID].height > 4) -#else - if (slice.getPicHeader()->getLmcsEnabledFlag() && isChroma(compID) && slice.getPicHeader()->getLmcsChromaResidualScaleFlag() && tu.blocks[compID].width*tu.blocks[compID].height > 4) -#endif { resiBuf.scaleSignal(tu.getChromaAdj(), 0, tu.cu->cs->slice->clpRng(compID)); } -#if !REMOVE_PPS_REXT - if (bUseCrossCPrediction) - { - crossComponentPrediction(tu, compID, lumaResi, resiBuf, resiBuf, true); - } -#endif currCompDist = m_pcRdCost->getDistPart(orgResiBuf, resiBuf, channelBitDepth, compID, DF_SSE); #if WCG_EXT @@ -6879,15 +6755,9 @@ void InterSearch::xEstimateInterResidualQT(CodingStructure &cs, Partitioner &par #else currCompCost = m_pcRdCost->calcRdCost(currCompFracBits, currCompDist); #endif -#if JVET_Q0516_MTS_SIGNALLING_DC_ONLY_COND } -#endif } -#if !REMOVE_PPS_REXT - else if( transformMode > 0 && !bUseCrossCPrediction ) -#else else if( transformMode > 0 ) -#endif { currCompCost = MAX_DOUBLE; } @@ -6916,61 +6786,26 @@ void InterSearch::xEstimateInterResidualQT(CodingStructure &cs, Partitioner &par currCompCost = nonCoeffCost; } -#if !REMOVE_PPS_REXT - uiAbsSum[compID] = currAbsSum; -#endif uiSingleDistComp[compID] = currCompDist; uiSingleFracBits[compID] = currCompFracBits; minCost[compID] = currCompCost; -#if !REMOVE_PPS_REXT - if (uiAbsSum[compID] == 0) - { - if (bUseCrossCPrediction) - { - const CPelBuf zeroBuf( m_pTempPel, compArea ); - PelBuf resiBuf = csFull->getResiBuf( compArea ); - - crossComponentPrediction( tu, compID, lumaResi, zeroBuf, resiBuf, true ); - } - } -#endif -#if !JVET_Q0695_CHROMA_TS_JCCR - if( !isLastMode || (compID != COMPONENT_Y && !tu.noResidual) ) - { -#endif bestTU.copyComponentFrom( tu, compID ); saveCS.getResiBuf( compArea ).copyFrom( csFull->getResiBuf( compArea ) ); -#if !JVET_Q0695_CHROMA_TS_JCCR - } - - isLastBest = isLastMode; -#endif } if( tu.noResidual ) { CHECK( currCompFracBits > 0 || currAbsSum, "currCompFracBits > 0 when tu noResidual" ); } -#if !REMOVE_PPS_REXT - } -#endif } -#if !JVET_Q0695_CHROMA_TS_JCCR - if( !isLastBest ) - { -#endif // copy component tu.copyComponentFrom( bestTU, compID ); csFull->getResiBuf( compArea ).copyFrom( saveCS.getResiBuf( compArea ) ); -#if !JVET_Q0695_CHROMA_TS_JCCR - } -#endif - -#if JVET_Q0820_ACT - if (colorTransFlag && (m_pcEncCfg->getCostMode() != COST_LOSSLESS_CODING)) +#if JVET_R0110_MIXED_LOSSLESS + if (colorTransFlag && (m_pcEncCfg->getCostMode() != COST_LOSSLESS_CODING || !slice.isLossless())) #else - if (colorTransFlag) + if (colorTransFlag && (m_pcEncCfg->getCostMode() != COST_LOSSLESS_CODING)) #endif { m_pcTrQuant->lambdaAdjustColorTrans(false); @@ -6983,11 +6818,7 @@ void InterSearch::xEstimateInterResidualQT(CodingStructure &cs, Partitioner &par { PelUnitBuf orgResidual = orgResi->subBuf(relativeUnitArea); PelUnitBuf invColorTransResidual = m_colorTransResiBuf[2].getBuf(relativeUnitArea); -#if JVET_Q0820_ACT csFull->getResiBuf(currArea).colorSpaceConvert(invColorTransResidual, false, slice.clpRng(COMPONENT_Y)); -#else - csFull->getResiBuf(currArea).colorSpaceConvert(invColorTransResidual, false); -#endif for (uint32_t c = 0; c < numTBlocks; c++) { @@ -6997,16 +6828,11 @@ void InterSearch::xEstimateInterResidualQT(CodingStructure &cs, Partitioner &par } } -#if JVET_Q0438_MONOCHROME_BUGFIXES if ( chroma && isChromaEnabled(tu.chromaFormat) && tu.blocks[COMPONENT_Cb].valid() ) -#else - if ( chroma && tu.blocks[COMPONENT_Cb].valid() ) -#endif { const CompArea& cbArea = tu.blocks[COMPONENT_Cb]; const CompArea& crArea = tu.blocks[COMPONENT_Cr]; bool checkJointCbCr = (sps.getJointCbCrEnabledFlag()) && (!tu.noResidual) && (TU::getCbf(tu, COMPONENT_Cb) || TU::getCbf(tu, COMPONENT_Cr)); -#if JVET_Q0695_CHROMA_TS_JCCR bool checkDCTOnly = (TU::getCbf(tu, COMPONENT_Cb) && tu.mtsIdx[COMPONENT_Cb] == MTS_DCT2_DCT2 && !TU::getCbf(tu, COMPONENT_Cr)) || (TU::getCbf(tu, COMPONENT_Cr) && tu.mtsIdx[COMPONENT_Cr] == MTS_DCT2_DCT2 && !TU::getCbf(tu, COMPONENT_Cb)) || (TU::getCbf(tu, COMPONENT_Cb) && tu.mtsIdx[COMPONENT_Cb] == MTS_DCT2_DCT2 && TU::getCbf(tu, COMPONENT_Cr) && tu.mtsIdx[COMPONENT_Cr] == MTS_DCT2_DCT2); @@ -7014,23 +6840,14 @@ void InterSearch::xEstimateInterResidualQT(CodingStructure &cs, Partitioner &par bool checkTSOnly = (TU::getCbf(tu, COMPONENT_Cb) && tu.mtsIdx[COMPONENT_Cb] == MTS_SKIP && !TU::getCbf(tu, COMPONENT_Cr)) || (TU::getCbf(tu, COMPONENT_Cr) && tu.mtsIdx[COMPONENT_Cr] == MTS_SKIP && !TU::getCbf(tu, COMPONENT_Cb)) || (TU::getCbf(tu, COMPONENT_Cb) && tu.mtsIdx[COMPONENT_Cb] == MTS_SKIP && TU::getCbf(tu, COMPONENT_Cr) && tu.mtsIdx[COMPONENT_Cr] == MTS_SKIP); -#endif const int channelBitDepth = sps.getBitDepth(toChannelType(COMPONENT_Cb)); -#if JVET_Q0346_LMCS_ENABLE_IN_SH bool reshape = slice.getLmcsEnabledFlag() && slice.getPicHeader()->getLmcsChromaResidualScaleFlag() && tu.blocks[COMPONENT_Cb].width * tu.blocks[COMPONENT_Cb].height > 4; -#else - bool reshape = slice.getPicHeader()->getLmcsEnabledFlag() && slice.getPicHeader()->getLmcsChromaResidualScaleFlag() - && tu.blocks[COMPONENT_Cb].width * tu.blocks[COMPONENT_Cb].height > 4; -#endif double minCostCbCr = minCost[COMPONENT_Cb] + minCost[COMPONENT_Cr]; if (colorTransFlag) { minCostCbCr += minCost[COMPONENT_Y]; // ACT should consider three-component cost } -#if !JVET_Q0695_CHROMA_TS_JCCR - bool isLastBest = false; -#endif CompStorage orgResiCb[4], orgResiCr[4]; // 0:std, 1-3:jointCbCr std::vector<int> jointCbfMasksToTest; @@ -7050,7 +6867,6 @@ void InterSearch::xEstimateInterResidualQT(CodingStructure &cs, Partitioner &par for (int cbfMask: jointCbfMasksToTest) { -#if JVET_Q0695_CHROMA_TS_JCCR ComponentID codeCompId = (cbfMask >> 1 ? COMPONENT_Cb : COMPONENT_Cr); ComponentID otherCompId = (codeCompId == COMPONENT_Cr ? COMPONENT_Cb : COMPONENT_Cr); bool tsAllowed = TU::isTSAllowed(tu, codeCompId) && (m_pcEncCfg->getUseChromaTS()); @@ -7081,7 +6897,6 @@ void InterSearch::xEstimateInterResidualQT(CodingStructure &cs, Partitioner &par { continue; } -#endif TCoeff currAbsSum = 0; uint64_t currCompFracBits = 0; Distortion currCompDistCb = 0; @@ -7089,26 +6904,14 @@ void InterSearch::xEstimateInterResidualQT(CodingStructure &cs, Partitioner &par double currCompCost = 0; tu.jointCbCr = (uint8_t) cbfMask; -#if !REMOVE_PPS_REXT - tu.compAlpha[COMPONENT_Cb] = tu.compAlpha[COMPONENT_Cr] = 0; -#endif // encoder bugfix: initialize mtsIdx for chroma under JointCbCrMode. -#if JVET_Q0695_CHROMA_TS_JCCR tu.mtsIdx[codeCompId] = trModes[modeId].first; tu.mtsIdx[otherCompId] = MTS_DCT2_DCT2; -#else - tu.mtsIdx[COMPONENT_Cb] = tu.mtsIdx[COMPONENT_Cr] = MTS_DCT2_DCT2; -#endif int codedCbfMask = 0; -#if !JVET_Q0695_CHROMA_TS_JCCR - ComponentID codeCompId = (tu.jointCbCr >> 1 ? COMPONENT_Cb : COMPONENT_Cr); - ComponentID otherCompId = (codeCompId == COMPONENT_Cr ? COMPONENT_Cb : COMPONENT_Cr); -#endif - -#if JVET_Q0820_ACT - if (colorTransFlag && (m_pcEncCfg->getCostMode() != COST_LOSSLESS_CODING)) +#if JVET_R0110_MIXED_LOSSLESS + if (colorTransFlag && (m_pcEncCfg->getCostMode() != COST_LOSSLESS_CODING || !slice.isLossless())) #else - if (colorTransFlag) + if (colorTransFlag && (m_pcEncCfg->getCostMode() != COST_LOSSLESS_CODING)) #endif { m_pcTrQuant->lambdaAdjustColorTrans(true); @@ -7143,24 +6946,12 @@ void InterSearch::xEstimateInterResidualQT(CodingStructure &cs, Partitioner &par Distortion currCompDistY = MAX_UINT64; QpParam qpCbCr(tu, codeCompId); -#if !JVET_Q0820_ACT - if (colorTransFlag) - { - for (int qpIdx = 0; qpIdx < 2; qpIdx++) - { - qpCbCr.Qps[qpIdx] = qpCbCr.Qps[qpIdx] + (codeCompId == COMPONENT_Cr ? DELTA_QP_FOR_Co : DELTA_QP_FOR_Y_Cg); - qpCbCr.pers[qpIdx] = qpCbCr.Qps[qpIdx] / 6; - qpCbCr.rems[qpIdx] = qpCbCr.Qps[qpIdx] % 6; - } - } -#endif tu.getCoeffs(otherCompId).fill(0); // do we need that? TU::setCbfAtDepth(tu, otherCompId, tu.depth, false); PelBuf &codeResi = (codeCompId == COMPONENT_Cr ? crResi : cbResi); TCoeff compAbsSum = 0; -#if JVET_Q0695_CHROMA_TS_JCCR if (numTransformCands > 1) { if (modeId == 0) @@ -7172,7 +6963,6 @@ void InterSearch::xEstimateInterResidualQT(CodingStructure &cs, Partitioner &par m_pcTrQuant->transformNxN(tu, codeCompId, qpCbCr, compAbsSum, m_CABACEstimator->getCtx(), true); } else -#endif m_pcTrQuant->transformNxN(tu, codeCompId, qpCbCr, compAbsSum, m_CABACEstimator->getCtx()); if (compAbsSum > 0) { @@ -7195,12 +6985,10 @@ void InterSearch::xEstimateInterResidualQT(CodingStructure &cs, Partitioner &par } currAbsSum = codedCbfMask; -#if JVET_Q0695_CHROMA_TS_JCCR if (!tu.mtsIdx[codeCompId]) { cbfDCT2 = (currAbsSum > 0); } -#endif if (currAbsSum > 0) { m_CABACEstimator->cbf_comp(cs, codedCbfMask >> 1, cbArea, currDepth, false); @@ -7223,11 +7011,7 @@ void InterSearch::xEstimateInterResidualQT(CodingStructure &cs, Partitioner &par { PelUnitBuf orgResidual = orgResi->subBuf(relativeUnitArea); PelUnitBuf invColorTransResidual = m_colorTransResiBuf[2].getBuf(relativeUnitArea); -#if JVET_Q0820_ACT csFull->getResiBuf(currArea).colorSpaceConvert(invColorTransResidual, false, slice.clpRng(COMPONENT_Y)); -#else - csFull->getResiBuf(currArea).colorSpaceConvert(invColorTransResidual, false); -#endif currCompDistY = m_pcRdCost->getDistPart(orgResidual.bufs[COMPONENT_Y], invColorTransResidual.bufs[COMPONENT_Y], sps.getBitDepth(toChannelType(COMPONENT_Y)), COMPONENT_Y, DF_SSE); currCompDistCb = m_pcRdCost->getDistPart(orgResidual.bufs[COMPONENT_Cb], invColorTransResidual.bufs[COMPONENT_Cb], sps.getBitDepth(toChannelType(COMPONENT_Cb)), COMPONENT_Cb, DF_SSE); @@ -7251,10 +7035,6 @@ void InterSearch::xEstimateInterResidualQT(CodingStructure &cs, Partitioner &par // evaluate if( currCompCost < minCostCbCr ) { -#if !REMOVE_PPS_REXT - uiAbsSum[COMPONENT_Cb] = currAbsSum; - uiAbsSum[COMPONENT_Cr] = currAbsSum; -#endif uiSingleDistComp[COMPONENT_Cb] = currCompDistCb; uiSingleDistComp[COMPONENT_Cr] = currCompDistCr; if (colorTransFlag) @@ -7262,10 +7042,6 @@ void InterSearch::xEstimateInterResidualQT(CodingStructure &cs, Partitioner &par uiSingleDistComp[COMPONENT_Y] = currCompDistY; } minCostCbCr = currCompCost; -#if !JVET_Q0695_CHROMA_TS_JCCR - isLastBest = (cbfMask == jointCbfMasksToTest.back()); - if (!isLastBest) -#endif { bestTU.copyComponentFrom(tu, COMPONENT_Cb); bestTU.copyComponentFrom(tu, COMPONENT_Cr); @@ -7274,49 +7050,29 @@ void InterSearch::xEstimateInterResidualQT(CodingStructure &cs, Partitioner &par } } -#if !JVET_Q0695_CHROMA_TS_JCCR - if( !isLastBest ) - { - // copy component - tu.copyComponentFrom( bestTU, COMPONENT_Cb ); - tu.copyComponentFrom( bestTU, COMPONENT_Cr ); - csFull->getResiBuf( cbArea ).copyFrom( saveCS.getResiBuf( cbArea ) ); - csFull->getResiBuf( crArea ).copyFrom( saveCS.getResiBuf( crArea ) ); - } -#endif - -#if JVET_Q0820_ACT - if (colorTransFlag && (m_pcEncCfg->getCostMode() != COST_LOSSLESS_CODING)) +#if JVET_R0110_MIXED_LOSSLESS + if (colorTransFlag && (m_pcEncCfg->getCostMode() != COST_LOSSLESS_CODING || !slice.isLossless())) #else - if (colorTransFlag) + if (colorTransFlag && (m_pcEncCfg->getCostMode() != COST_LOSSLESS_CODING)) #endif { m_pcTrQuant->lambdaAdjustColorTrans(false); } -#if JVET_Q0695_CHROMA_TS_JCCR } -#endif } -#if JVET_Q0695_CHROMA_TS_JCCR // copy component tu.copyComponentFrom(bestTU, COMPONENT_Cb); tu.copyComponentFrom(bestTU, COMPONENT_Cr); csFull->getResiBuf(cbArea).copyFrom(saveCS.getResiBuf(cbArea)); csFull->getResiBuf(crArea).copyFrom(saveCS.getResiBuf(crArea)); -#endif } m_CABACEstimator->getCtx() = ctxStart; m_CABACEstimator->resetBits(); if( !tu.noResidual ) { -#if JVET_Q0438_MONOCHROME_BUGFIXES static const ComponentID cbf_getComp[MAX_NUM_COMPONENT] = { COMPONENT_Cb, COMPONENT_Cr, COMPONENT_Y }; for( unsigned c = isChromaEnabled(tu.chromaFormat)?0 : 2; c < MAX_NUM_COMPONENT; c++) -#else - static const ComponentID cbf_getComp[3] = { COMPONENT_Cb, COMPONENT_Cr, COMPONENT_Y }; - for( unsigned c = 0; c < numTBlocks; c++) -#endif { const ComponentID compID = cbf_getComp[c]; if (compID == COMPONENT_Y && !luma) @@ -7345,12 +7101,6 @@ void InterSearch::xEstimateInterResidualQT(CodingStructure &cs, Partitioner &par const int cbfMask = ( TU::getCbf( tu, COMPONENT_Cb ) ? 2 : 0 ) + ( TU::getCbf( tu, COMPONENT_Cr ) ? 1 : 0 ); m_CABACEstimator->joint_cb_cr(tu, cbfMask); } -#if !REMOVE_PPS_REXT - if( cs.pps->getPpsRangeExtension().getCrossComponentPredictionEnabledFlag() && isChroma(compID) && uiAbsSum[COMPONENT_Y] ) - { - m_CABACEstimator->cross_comp_pred( tu, compID ); - } -#endif if( TU::getCbf( tu, compID ) ) { m_CABACEstimator->residual_coding( tu, compID ); @@ -7459,7 +7209,7 @@ void InterSearch::xEstimateInterResidualQT(CodingStructure &cs, Partitioner &par if( bCheckFull && anyCbfSet && csSplit->cost < csFull->cost ) { - cs.useSubStructure( *csSplit, partitioner.chType, currArea, false, false, false, true ); + cs.useSubStructure( *csSplit, partitioner.chType, currArea, false, false, false, true, true ); cs.cost = csSplit->cost; } } @@ -7503,11 +7253,7 @@ void InterSearch::encodeResAndCalcRdInterCU(CodingStructure &cs, Partitioner &pa cs.getResiBuf().fill(0); { cs.getRecoBuf().copyFrom(cs.getPredBuf() ); -#if JVET_Q0346_LMCS_ENABLE_IN_SH if (m_pcEncCfg->getLmcs() && (cs.slice->getLmcsEnabledFlag() && m_pcReshape->getCTUFlag()) && !cu.firstPU->ciipFlag && !CU::isIBC(cu)) -#else - if (m_pcEncCfg->getLmcs() && (cs.picHeader->getLmcsEnabledFlag() && m_pcReshape->getCTUFlag()) && !cu.firstPU->ciipFlag && !CU::isIBC(cu)) -#endif { cs.getRecoBuf().Y().rspSignal(m_pcReshape->getFwdLUT()); } @@ -7528,13 +7274,8 @@ void InterSearch::encodeResAndCalcRdInterCU(CodingStructure &cs, Partitioner &pa CPelBuf reco = cs.getRecoBuf (compID); CPelBuf org = cs.getOrgBuf (compID); #if WCG_EXT -#if JVET_Q0346_LMCS_ENABLE_IN_SH if (m_pcEncCfg->getLumaLevelToDeltaQPMapping().isEnabled() || ( m_pcEncCfg->getLmcs() && (cs.slice->getLmcsEnabledFlag() && m_pcReshape->getCTUFlag()))) -#else - if (m_pcEncCfg->getLumaLevelToDeltaQPMapping().isEnabled() || ( - m_pcEncCfg->getLmcs() && (cs.picHeader->getLmcsEnabledFlag() && m_pcReshape->getCTUFlag())) ) -#endif { const CPelBuf orgLuma = cs.getOrgBuf( cs.area.blocks[COMPONENT_Y] ); if (compID == COMPONENT_Y && !(m_pcEncCfg->getLumaLevelToDeltaQPMapping().isEnabled())) @@ -7572,11 +7313,7 @@ void InterSearch::encodeResAndCalcRdInterCU(CodingStructure &cs, Partitioner &pa if (luma) { cs.getResiBuf().bufs[0].copyFrom(cs.getOrgBuf().bufs[0]); -#if JVET_Q0346_LMCS_ENABLE_IN_SH if (cs.slice->getLmcsEnabledFlag() && m_pcReshape->getCTUFlag()) -#else - if (cs.picHeader->getLmcsEnabledFlag() && m_pcReshape->getCTUFlag()) -#endif { const CompArea &areaY = cu.Y(); CompArea tmpArea(COMPONENT_Y, areaY.chromaFormat, Position(0, 0), areaY.size()); @@ -7591,11 +7328,7 @@ void InterSearch::encodeResAndCalcRdInterCU(CodingStructure &cs, Partitioner &pa else cs.getResiBuf().bufs[0].subtract(cs.getPredBuf().bufs[0]); } -#if JVET_Q0438_MONOCHROME_BUGFIXES if (chroma && isChromaEnabled(cs.pcv->chrFormat)) -#else - if (chroma) -#endif { cs.getResiBuf().bufs[1].copyFrom(cs.getOrgBuf().bufs[1]); cs.getResiBuf().bufs[2].copyFrom(cs.getOrgBuf().bufs[2]); @@ -7628,11 +7361,7 @@ void InterSearch::encodeResAndCalcRdInterCU(CodingStructure &cs, Partitioner &pa orgResidual.copyFrom(cs.getResiBuf()); if (colorTransAllowed) { -#if JVET_Q0820_ACT cs.getResiBuf().colorSpaceConvert(colorTransResidual, true, cu.cs->slice->clpRng(COMPONENT_Y)); -#else - cs.getResiBuf().colorSpaceConvert(colorTransResidual, true); -#endif } const TempCtx ctxStart(m_CtxCache, m_CABACEstimator->getCtx()); @@ -7726,11 +7455,7 @@ void InterSearch::encodeResAndCalcRdInterCU(CodingStructure &cs, Partitioner &pa { cs.getOrgResiBuf().bufs[0].copyFrom(orgResidual.bufs[0]); } -#if JVET_Q0438_MONOCHROME_BUGFIXES if (chroma && isChromaEnabled(cs.pcv->chrFormat)) -#else - if (chroma) -#endif { cs.getOrgResiBuf().bufs[1].copyFrom(orgResidual.bufs[1]); cs.getOrgResiBuf().bufs[2].copyFrom(orgResidual.bufs[2]); @@ -7786,11 +7511,7 @@ void InterSearch::encodeResAndCalcRdInterCU(CodingStructure &cs, Partitioner &pa bestIter = iter; if (cu.rootCbf && cu.colorTransform) { -#if JVET_Q0820_ACT cs.getResiBuf(curUnitArea).colorSpaceConvert(cs.getResiBuf(curUnitArea), false, cu.cs->slice->clpRng(COMPONENT_Y)); -#else - cs.getResiBuf(curUnitArea).colorSpaceConvert(cs.getResiBuf(curUnitArea), false); -#endif } if (iter != (numAllowedColorSpace - 1)) @@ -7837,11 +7558,7 @@ void InterSearch::encodeResAndCalcRdInterCU(CodingStructure &cs, Partitioner &pa { cs.getResiBuf().bufs[0].fill(0); // Clear the residual image, if we didn't code it. } -#if JVET_Q0438_MONOCHROME_BUGFIXES if (chroma && isChromaEnabled(cs.pcv->chrFormat)) -#else - if (chroma) -#endif { cs.getResiBuf().bufs[1].fill(0); // Clear the residual image, if we didn't code it. cs.getResiBuf().bufs[2].fill(0); // Clear the residual image, if we didn't code it. @@ -7850,11 +7567,7 @@ void InterSearch::encodeResAndCalcRdInterCU(CodingStructure &cs, Partitioner &pa if (luma) { -#if JVET_Q0346_LMCS_ENABLE_IN_SH if (cu.rootCbf && cs.slice->getLmcsEnabledFlag() && m_pcReshape->getCTUFlag()) -#else - if (cu.rootCbf && cs.picHeader->getLmcsEnabledFlag() && m_pcReshape->getCTUFlag()) -#endif { const CompArea &areaY = cu.Y(); CompArea tmpArea(COMPONENT_Y, areaY.chromaFormat, Position(0, 0), areaY.size()); @@ -7869,21 +7582,13 @@ void InterSearch::encodeResAndCalcRdInterCU(CodingStructure &cs, Partitioner &pa else { cs.getRecoBuf().bufs[0].reconstruct(cs.getPredBuf().bufs[0], cs.getResiBuf().bufs[0], cs.slice->clpRngs().comp[0]); -#if JVET_Q0346_LMCS_ENABLE_IN_SH if (cs.slice->getLmcsEnabledFlag() && m_pcReshape->getCTUFlag() && !cu.firstPU->ciipFlag && !CU::isIBC(cu)) -#else - if (cs.picHeader->getLmcsEnabledFlag() && m_pcReshape->getCTUFlag() && !cu.firstPU->ciipFlag && !CU::isIBC(cu)) -#endif { cs.getRecoBuf().bufs[0].rspSignal(m_pcReshape->getFwdLUT()); } } } -#if JVET_Q0438_MONOCHROME_BUGFIXES if (chroma && isChromaEnabled(cs.pcv->chrFormat)) -#else - if (chroma) -#endif { cs.getRecoBuf().bufs[1].reconstruct(cs.getPredBuf().bufs[1], cs.getResiBuf().bufs[1], cs.slice->clpRngs().comp[1]); cs.getRecoBuf().bufs[2].reconstruct(cs.getPredBuf().bufs[2], cs.getResiBuf().bufs[2], cs.slice->clpRngs().comp[2]); @@ -7903,13 +7608,8 @@ void InterSearch::encodeResAndCalcRdInterCU(CodingStructure &cs, Partitioner &pa CPelBuf org = cs.getOrgBuf (compID); #if WCG_EXT -#if JVET_Q0346_LMCS_ENABLE_IN_SH if (m_pcEncCfg->getLumaLevelToDeltaQPMapping().isEnabled() || ( m_pcEncCfg->getLmcs() && (cs.slice->getLmcsEnabledFlag() && m_pcReshape->getCTUFlag()))) -#else - if (m_pcEncCfg->getLumaLevelToDeltaQPMapping().isEnabled() || ( - m_pcEncCfg->getLmcs() && (cs.picHeader->getLmcsEnabledFlag() && m_pcReshape->getCTUFlag()))) -#endif { const CPelBuf orgLuma = cs.getOrgBuf( cs.area.blocks[COMPONENT_Y] ); if (compID == COMPONENT_Y && !(m_pcEncCfg->getLumaLevelToDeltaQPMapping().isEnabled()) ) @@ -8071,9 +7771,8 @@ void InterSearch::xClipMv( Mv& rcMv, const Position& pos, const struct Size& siz int verMax = ( pps.getPicHeightInLumaSamples() + offset - (int)pos.y - 1 ) << mvShift; int verMin = ( -( int ) sps.getMaxCUHeight() - offset - ( int ) pos.y + 1 ) << mvShift; -#if JVET_O1143_MV_ACROSS_SUBPIC_BOUNDARY - SubPic curSubPic = pps.getSubPicFromPos(pos); - if (curSubPic.getTreatedAsPicFlag()) + const SubPic &curSubPic = pps.getSubPicFromPos(pos); + if (curSubPic.getTreatedAsPicFlag()) { horMax = ((curSubPic.getSubPicRight() + 1) + offset - (int)pos.x - 1) << mvShift; horMin = (-(int)sps.getMaxCUWidth() - offset - ((int)pos.x - curSubPic.getSubPicLeft()) + 1) << mvShift; @@ -8081,7 +7780,6 @@ void InterSearch::xClipMv( Mv& rcMv, const Position& pos, const struct Size& siz verMax = ((curSubPic.getSubPicBottom() + 1) + offset - (int)pos.y - 1) << mvShift; verMin = (-(int)sps.getMaxCUHeight() - offset - ((int)pos.y - curSubPic.getSubPicTop()) + 1) << mvShift; } -#endif if( sps.getWrapAroundEnabledFlag() ) { int horMax = ( pps.getPicWidthInLumaSamples() + sps.getMaxCUWidth() - size.width + offset - (int)pos.x - 1 ) << mvShift; diff --git a/source/Lib/EncoderLib/InterSearch.h b/source/Lib/EncoderLib/InterSearch.h index f3506532e46be81d22dfae00c6a252668c6af723..126832e4bb3b55d1e06ce8c0cb916bd35d94147a 100644 --- a/source/Lib/EncoderLib/InterSearch.h +++ b/source/Lib/EncoderLib/InterSearch.h @@ -97,11 +97,7 @@ typedef struct } EncAffineMotion; /// encoder search class -#if !REMOVE_PPS_REXT -class InterSearch : public InterPrediction, CrossComponentPrediction, AffineGradientSearch -#else class InterSearch : public InterPrediction, AffineGradientSearch -#endif { private: EncModeCtrl *m_modeCtrl; diff --git a/source/Lib/EncoderLib/IntraSearch.cpp b/source/Lib/EncoderLib/IntraSearch.cpp index b3051403b5c95d3b05fbb4d6b18dda1099ac2fa3..aabab7610bc5334fae7edc84ea2342cf9ac22c01 100644 --- a/source/Lib/EncoderLib/IntraSearch.cpp +++ b/source/Lib/EncoderLib/IntraSearch.cpp @@ -387,9 +387,6 @@ bool IntraSearch::estIntraPredLumaQT(CodingUnit &cu, Partitioner &partitioner, c const TempCtx ctxStartMrlIdx ( m_CtxCache, SubCtx( Ctx::MultiRefLineIdx, m_CABACEstimator->getCtx() ) ); CHECK( !cu.firstPU, "CU has no PUs" ); -#if !REMOVE_PPS_REXT - const bool keepResi = cs.pps->getPpsRangeExtension().getCrossComponentPredictionEnabledFlag() || KEEP_PRED_AND_RESI_SIGNALS; -#endif // variables for saving fast intra modes scan results across multiple LFNST passes bool LFNSTLoadFlag = sps.getUseLFNST() && cu.lfnstIdx != 0; bool LFNSTSaveFlag = sps.getUseLFNST() && cu.lfnstIdx == 0; @@ -449,11 +446,7 @@ bool IntraSearch::estIntraPredLumaQT(CodingUnit &cu, Partitioner &partitioner, c } } -#if JVET_Q0089_SLICE_LOSSLESS_CODING_CHROMA_BDPCM const bool testBDPCM = sps.getBDPCMEnabledFlag() && CU::bdpcmAllowed(cu, ComponentID(partitioner.chType)) && cu.mtsFlag == 0 && cu.lfnstIdx == 0; -#else - const bool testBDPCM = (sps.getBDPCMEnabled()!=0) && CU::bdpcmAllowed(cu, ComponentID(partitioner.chType)) && cu.mtsFlag == 0 && cu.lfnstIdx == 0; -#endif static_vector<ModeInfo, FAST_UDI_MAX_RDMODE_NUM> uiHadModeList; static_vector<double, FAST_UDI_MAX_RDMODE_NUM> CandCostList; static_vector<double, FAST_UDI_MAX_RDMODE_NUM> CandHadList; @@ -519,11 +512,7 @@ bool IntraSearch::estIntraPredLumaQT(CodingUnit &cu, Partitioner &partitioner, c DistParam distParamSad; DistParam distParamHad; -#if JVET_Q0346_LMCS_ENABLE_IN_SH if (cu.slice->getLmcsEnabledFlag() && m_pcReshape->getCTUFlag()) -#else - if (cu.slice->getPicHeader()->getLmcsEnabledFlag() && m_pcReshape->getCTUFlag()) -#endif { CompArea tmpArea(COMPONENT_Y, area.chromaFormat, Position(0, 0), area.size()); PelBuf tmpOrg = m_tmpStorageLCU.getBuf(tmpArea); @@ -1201,21 +1190,12 @@ bool IntraSearch::estIntraPredLumaQT(CodingUnit &cu, Partitioner &partitioner, c { if (cu.colorTransform) { -#if !REMOVE_PPS_REXT - cs.useSubStructure(*csBest, partitioner.chType, pu, true, true, keepResi, keepResi); -#else - cs.useSubStructure(*csBest, partitioner.chType, pu, true, true, KEEP_PRED_AND_RESI_SIGNALS, KEEP_PRED_AND_RESI_SIGNALS); -#endif + cs.useSubStructure(*csBest, partitioner.chType, pu, true, true, KEEP_PRED_AND_RESI_SIGNALS, KEEP_PRED_AND_RESI_SIGNALS, true); } else { -#if !REMOVE_PPS_REXT - cs.useSubStructure(*csBest, partitioner.chType, pu.singleChan(CHANNEL_TYPE_LUMA), true, true, keepResi, - keepResi); -#else cs.useSubStructure(*csBest, partitioner.chType, pu.singleChan(CHANNEL_TYPE_LUMA), true, true, KEEP_PRED_AND_RESI_SIGNALS, - KEEP_PRED_AND_RESI_SIGNALS); -#endif + KEEP_PRED_AND_RESI_SIGNALS, true); } } csBest->releaseIntermediateData(); @@ -1439,19 +1419,17 @@ void IntraSearch::estIntraPredChromaQT( CodingUnit &cu, Partitioner &partitioner testBDPCM = testBDPCM && CU::bdpcmAllowed(cu, COMPONENT_Cb) && cu.ispMode == 0 && cu.mtsFlag == 0 && cu.lfnstIdx == 0; for (int32_t uiMode = uiMinMode - (2 * int(testBDPCM)); uiMode < uiMaxMode; uiMode++) { - int chromaIntraMode = chromaCandModes[uiMode]; + int chromaIntraMode; if (uiMode < 0) { cu.bdpcmModeChroma = -uiMode; -#if JVET_Q0110_Q0785_CHROMA_BDPCM_420 chromaIntraMode = cu.bdpcmModeChroma == 2 ? chromaCandModes[1] : chromaCandModes[2]; -#else - chromaIntraMode = chromaCandModes[0]; -#endif } else { + chromaIntraMode = chromaCandModes[uiMode]; + cu.bdpcmModeChroma = 0; if( PU::isLMCMode( chromaIntraMode ) && ! PU::isLMCModeEnabled( pu, chromaIntraMode ) ) { @@ -1578,43 +1556,26 @@ void IntraSearch::PLTSearch(CodingStructure &cs, Partitioner& partitioner, Compo TransformUnit &tu = *cs.getTU(partitioner.chType); uint32_t height = cu.block(compBegin).height; uint32_t width = cu.block(compBegin).width; -#if JVET_Q0346_LMCS_ENABLE_IN_SH if (m_pcEncCfg->getLmcs() && (cs.slice->getLmcsEnabledFlag() && m_pcReshape->getCTUFlag())) -#else - if (m_pcEncCfg->getLmcs() && (cs.picHeader->getLmcsEnabledFlag() && m_pcReshape->getCTUFlag())) -#endif { cs.getPredBuf().copyFrom(cs.getOrgBuf()); cs.getPredBuf().Y().rspSignal(m_pcReshape->getFwdLUT()); } -#if JVET_Q0504_PLT_NON444 if( cu.isLocalSepTree() ) cs.prevPLT.curPLTSize[compBegin] = cs.prevPLT.curPLTSize[COMPONENT_Y]; -#endif cu.lastPLTSize[compBegin] = cs.prevPLT.curPLTSize[compBegin]; //derive palette derivePLTLossy(cs, partitioner, compBegin, numComp); reorderPLT(cs, partitioner, compBegin, numComp); -#if JVET_Q0503_Q0712_PLT_ENCODER_IMPROV_BUGFIX bool idxExist[MAXPLTSIZE + 1] = { false }; -#endif - preCalcPLTIndexRD(cs, partitioner, compBegin, numComp); // Pre-calculate distortions for each pixel + preCalcPLTIndexRD(cs, partitioner, compBegin, numComp); // Pre-calculate distortions for each pixel double rdCost = MAX_DOUBLE; -#if JVET_Q0503_Q0712_PLT_ENCODER_IMPROV_BUGFIX deriveIndexMap(cs, partitioner, compBegin, numComp, PLT_SCAN_HORTRAV, rdCost, idxExist); // Optimize palette index map (horizontal scan) -#else - deriveIndexMap(cs, partitioner, compBegin, numComp, PLT_SCAN_HORTRAV, rdCost); // Optimize palette index map (horizontal scan) -#endif if ((cu.curPLTSize[compBegin] + cu.useEscape[compBegin]) > 1) { -#if JVET_Q0503_Q0712_PLT_ENCODER_IMPROV_BUGFIX deriveIndexMap(cs, partitioner, compBegin, numComp, PLT_SCAN_VERTRAV, rdCost, idxExist); // Optimize palette index map (vertical scan) -#else - deriveIndexMap(cs, partitioner, compBegin, numComp, PLT_SCAN_VERTRAV, rdCost); // Optimize palette index map (vertical scan) -#endif } -#if JVET_Q0503_Q0712_PLT_ENCODER_IMPROV_BUGFIX // Remove unused palette entries uint8_t newPLTSize = 0; int idxMapping[MAXPLTSIZE + 1]; @@ -1633,7 +1594,6 @@ void IntraSearch::PLTSearch(CodingStructure &cs, Partitioner& partitioner, Compo Pel curPLTtmp[MAX_NUM_COMPONENT][MAXPLTSIZE]; int reuseFlagIdx = 0, curPLTtmpIdx = 0, reuseEntrySize = 0; memset(cu.reuseflag[compBegin], false, sizeof(bool) * MAXPLTPREDSIZE); -#if JVET_Q0504_PLT_NON444 int compBeginTmp = compBegin; int numCompTmp = numComp; if( cu.isLocalSepTree() ) @@ -1642,16 +1602,11 @@ void IntraSearch::PLTSearch(CodingStructure &cs, Partitioner& partitioner, Compo compBeginTmp = COMPONENT_Y; numCompTmp = (cu.chromaFormat != CHROMA_400) ? 3 : 1; } -#endif for (int curIdx = 0; curIdx < cu.curPLTSize[compBegin]; curIdx++) { if (idxExist[curIdx]) { -#if JVET_Q0504_PLT_NON444 for (int comp = compBeginTmp; comp < (compBeginTmp + numCompTmp); comp++) -#else - for (int comp = compBegin; comp < (compBegin + numComp); comp++) -#endif curPLTtmp[comp][curPLTtmpIdx] = cu.curPLT[comp][curIdx]; // Update reuse flags @@ -1674,10 +1629,8 @@ void IntraSearch::PLTSearch(CodingStructure &cs, Partitioner& partitioner, Compo if (match) { cu.reuseflag[compBegin][reuseFlagIdx] = true; -#if JVET_Q0504_PLT_NON444 if( cu.isLocalSepTree() ) cu.reuseflag[COMPONENT_Y][reuseFlagIdx] = true; -#endif reuseEntrySize++; } } @@ -1687,16 +1640,11 @@ void IntraSearch::PLTSearch(CodingStructure &cs, Partitioner& partitioner, Compo cu.reusePLTSize[compBegin] = reuseEntrySize; // update palette table cu.curPLTSize[compBegin] = newPLTSize; -#if JVET_Q0504_PLT_NON444 if( cu.isLocalSepTree() ) cu.curPLTSize[COMPONENT_Y] = newPLTSize; for (int comp = compBeginTmp; comp < (compBeginTmp + numCompTmp); comp++) -#else - for (int comp = compBegin; comp < (compBegin + numComp); comp++) -#endif memcpy( cu.curPLT[comp], curPLTtmp[comp], sizeof(Pel)*cu.curPLTSize[compBegin]); } -#endif cu.useRotation[compBegin] = m_bestScanRotationMode; int indexMaxSize = cu.useEscape[compBegin] ? (cu.curPLTSize[compBegin] + 1) : cu.curPLTSize[compBegin]; if (indexMaxSize <= 1) @@ -1709,9 +1657,7 @@ void IntraSearch::PLTSearch(CodingStructure &cs, Partitioner& partitioner, Compo { for (uint32_t x = 0; x < width; x++) { -#if JVET_Q0503_Q0712_PLT_ENCODER_IMPROV_BUGFIX curPLTIdx.at(x, y) = idxMapping[curPLTIdx.at(x, y)]; -#endif if (curPLTIdx.at(x, y) == cu.curPLTSize[compBegin]) { calcPixelPred(cs, partitioner, y, x, compBegin, numComp); @@ -1750,13 +1696,8 @@ void IntraSearch::PLTSearch(CodingStructure &cs, Partitioner& partitioner, Compo CPelBuf reco = cs.getRecoBuf(compID); CPelBuf org = cs.getOrgBuf(compID); #if WCG_EXT -#if JVET_Q0346_LMCS_ENABLE_IN_SH if (m_pcEncCfg->getLumaLevelToDeltaQPMapping().isEnabled() || ( m_pcEncCfg->getLmcs() && (cs.slice->getLmcsEnabledFlag() && m_pcReshape->getCTUFlag()))) -#else - if (m_pcEncCfg->getLumaLevelToDeltaQPMapping().isEnabled() || ( - m_pcEncCfg->getLmcs() && (cs.picHeader->getLmcsEnabledFlag() && m_pcReshape->getCTUFlag()))) -#endif { const CPelBuf orgLuma = cs.getOrgBuf(cs.area.blocks[COMPONENT_Y]); @@ -1825,7 +1766,9 @@ void IntraSearch::preCalcPLTIndexRD(CodingStructure& cs, Partitioner& partitione CodingUnit &cu = *cs.getCU(partitioner.chType); uint32_t height = cu.block(compBegin).height; uint32_t width = cu.block(compBegin).width; -#if JVET_Q0493_PLT_ENCODER_LOSSLESS +#if JVET_R0110_MIXED_LOSSLESS + bool lossless = (m_pcEncCfg->getCostMode() == COST_LOSSLESS_CODING && cs.slice->isLossless()); +#else bool lossless = (m_pcEncCfg->getCostMode() == COST_LOSSLESS_CODING); #endif @@ -1833,11 +1776,7 @@ void IntraSearch::preCalcPLTIndexRD(CodingStructure& cs, Partitioner& partitione for (int comp = compBegin; comp < (compBegin + numComp); comp++) { CompArea area = cu.blocks[comp]; -#if JVET_Q0346_LMCS_ENABLE_IN_SH if (m_pcEncCfg->getLmcs() && (cs.slice->getLmcsEnabledFlag() && m_pcReshape->getCTUFlag())) -#else - if (m_pcEncCfg->getLmcs() && (cs.picHeader->getLmcsEnabledFlag() && m_pcReshape->getCTUFlag())) -#endif { orgBuf[comp] = cs.getPredBuf(area); } @@ -1868,16 +1807,13 @@ void IntraSearch::preCalcPLTIndexRD(CodingStructure& cs, Partitioner& partitione uint8_t pltIdx = 0; double minError = MAX_DOUBLE; uint8_t bestIdx = 0; -#if JVET_Q0493_PLT_ENCODER_LOSSLESS for (uint8_t z = 0; z < cu.curPLTSize[compBegin]; z++) { m_indexError[z][rasPos] = minError; } -#endif while (pltIdx < cu.curPLTSize[compBegin]) { uint64_t sqrtError = 0; -#if JVET_Q0493_PLT_ENCODER_LOSSLESS if (lossless) { for (int comp = compBegin; comp < (discardChroma ? 1 : (compBegin + numComp)); comp++) @@ -1894,7 +1830,6 @@ void IntraSearch::preCalcPLTIndexRD(CodingStructure& cs, Partitioner& partitione } else { -#endif for (int comp = compBegin; comp < (discardChroma ? 1 : (compBegin + numComp)); comp++) { int64_t tmpErr = int64_t(curPel[comp] - cu.curPLT[comp][pltIdx]); @@ -1913,32 +1848,24 @@ void IntraSearch::preCalcPLTIndexRD(CodingStructure& cs, Partitioner& partitione minError = (double)sqrtError; bestIdx = pltIdx; } -#if JVET_Q0493_PLT_ENCODER_LOSSLESS } -#endif pltIdx++; } Pel paPixelValue[3], paRecoValue[3]; -#if JVET_Q0493_PLT_ENCODER_LOSSLESS if (!lossless) { -#endif calcPixelPredRD(cs, partitioner, curPel, paPixelValue, paRecoValue, compBegin, numComp); -#if JVET_Q0493_PLT_ENCODER_LOSSLESS } -#endif uint64_t error = 0, rate = 0; for (int comp = compBegin; comp < (discardChroma ? 1 : (compBegin + numComp)); comp++) { -#if JVET_Q0493_PLT_ENCODER_LOSSLESS if (lossless) { rate += m_escapeNumBins[curPel[comp]]; } else { -#endif int64_t tmpErr = int64_t(curPel[comp] - paRecoValue[comp]); if (isChroma((ComponentID)comp)) { @@ -1949,13 +1876,11 @@ void IntraSearch::preCalcPLTIndexRD(CodingStructure& cs, Partitioner& partitione error += tmpErr*tmpErr; } rate += m_escapeNumBins[paPixelValue[comp]]; // encode quantized escape color -#if JVET_Q0493_PLT_ENCODER_LOSSLESS } -#endif } double rdCost = (double)error + m_pcRdCost->getLambda()*(double)rate; m_indexError[cu.curPLTSize[compBegin]][rasPos] = rdCost; - if (rdCost < minError) + if (rdCost < minError) { minError = rdCost; bestIdx = (uint8_t)cu.curPLTSize[compBegin]; @@ -1965,11 +1890,7 @@ void IntraSearch::preCalcPLTIndexRD(CodingStructure& cs, Partitioner& partitione } } -#if JVET_Q0503_Q0712_PLT_ENCODER_IMPROV_BUGFIX void IntraSearch::deriveIndexMap(CodingStructure& cs, Partitioner& partitioner, ComponentID compBegin, uint32_t numComp, PLTScanMode pltScanMode, double& dMinCost, bool* idxExist) -#else -void IntraSearch::deriveIndexMap(CodingStructure& cs, Partitioner& partitioner, ComponentID compBegin, uint32_t numComp, PLTScanMode pltScanMode, double& dMinCost) -#endif { CodingUnit &cu = *cs.getCU(partitioner.chType); TransformUnit &tu = *cs.getTU(partitioner.chType); @@ -2092,16 +2013,12 @@ void IntraSearch::deriveIndexMap(CodingStructure& cs, Partitioner& partitioner, { cu.useEscape[compBegin] = m_bestEscape; m_bestScanRotationMode = pltScanMode; -#if JVET_Q0503_Q0712_PLT_ENCODER_IMPROV_BUGFIX memset(idxExist, false, sizeof(bool) * (MAXPLTSIZE + 1)); -#endif for (int pos = 0; pos < (width*height); pos++) { runIndex[pos] = checkIndexTable[pos]; runType[pos] = checkRunTable[pos]; -#if JVET_Q0503_Q0712_PLT_ENCODER_IMPROV_BUGFIX idxExist[checkIndexTable[pos]] = true; -#endif } dMinCost = sumRdCost; } @@ -2143,12 +2060,12 @@ bool IntraSearch::deriveSubblockIndexMap( aboveScanPos = -1; // first column/row: above row is not valid } -// Trellis stats: +// Trellis stats: // 1st state: same as previous scanned sample // 2nd state: Copy_Above mode -// 3rd state: Index mode +// 3rd state: Index mode // Loop of current state - for ( int curState = 0; curState < NUM_TRELLIS_STATE; curState++ ) + for ( int curState = 0; curState < NUM_TRELLIS_STATE; curState++ ) { double minRdCost = MAX_DOUBLE; int minState = 0; // best prevState @@ -2168,14 +2085,14 @@ bool IntraSearch::deriveSubblockIndexMap( { runType = PLT_RUN_COPY; } - else if ( curState == 2 ) // 3rd state: Index mode + else if ( curState == 2 ) // 3rd state: Index mode { runType = PLT_RUN_INDEX; runIndex = m_minErrorIndexMap[currRasterPos]; } // Loop of previous state - for ( int stateID = 0; stateID < NUM_TRELLIS_STATE; stateID++ ) + for ( int stateID = 0; stateID < NUM_TRELLIS_STATE; stateID++ ) { if ( m_stateCostRDOQ[refId][stateID] == MAX_DOUBLE ) { @@ -2197,7 +2114,7 @@ bool IntraSearch::deriveSubblockIndexMap( double rdCost = m_stateCostRDOQ[refId][stateID]; if ( rdCost >= minRdCost ) continue; -// Calculate Rd cost +// Calculate Rd cost bool prevCodedRunType = m_prevRunTypeRDOQ[refId][stateID]; int prevCodedPos = m_prevRunPosRDOQ [refId][stateID]; const BinFracBits* fracBitsPt = (m_prevRunTypeRDOQ[refId][stateID] == PLT_RUN_INDEX) ? fracBitsPltIndexINDEX : fracBitsPltIndexCOPY; @@ -2265,32 +2182,16 @@ double IntraSearch::rateDistOptPLT( rdCost = MAX_DOUBLE; return rdCost; } -#if JVET_Q0503_Q0712_PLT_ENCODER_IMPROV_BUGFIX rdCost += m_pcRdCost->getLambda()*(m_truncBinBits[(runIndex > refIndex) ? runIndex - 1 : runIndex][(scanPos == 0) ? (indexMaxValue + 1) : indexMaxValue] << SCALE_BITS); -#else - rdCost += m_pcRdCost->getLambda()*m_truncBinBits[(runIndex > refIndex) ? runIndex - 1 : runIndex][(scanPos == 0) ? (indexMaxValue + 1) : indexMaxValue]; -#endif } -#if JVET_Q0503_Q0712_PLT_ENCODER_IMPROV_BUGFIX rdCost += m_indexError[runIndex][m_scanOrder[scanPos].idx] * (1 << SCALE_BITS); -#else - rdCost += m_indexError[runIndex][m_scanOrder[scanPos].idx]; -#endif if (scanPos > 0) { -#if JVET_Q0503_Q0712_PLT_ENCODER_IMPROV_BUGFIX rdCost += m_pcRdCost->getLambda()*( identityFlag ? (IndexfracBits[(dist < RUN_IDX_THRE) ? dist : RUN_IDX_THRE].intBits[1]) : (IndexfracBits[(dist < RUN_IDX_THRE) ? dist : RUN_IDX_THRE].intBits[0] ) ); -#else - rdCost += m_pcRdCost->getLambda()*( identityFlag ? (IndexfracBits[(dist < RUN_IDX_THRE) ? dist : RUN_IDX_THRE].intBits[1] >> SCALE_BITS) : (IndexfracBits[(dist < RUN_IDX_THRE) ? dist : RUN_IDX_THRE].intBits[0] >> SCALE_BITS)); -#endif } if ( !identityFlag && scanPos >= width && prevRunType != PLT_RUN_COPY ) { -#if JVET_Q0503_Q0712_PLT_ENCODER_IMPROV_BUGFIX rdCost += m_pcRdCost->getLambda()*TypefracBits.intBits[runType]; -#else - rdCost += m_pcRdCost->getLambda()*(TypefracBits.intBits[runType] >> SCALE_BITS); -#endif } if (!identityFlag || scanPos == 0) { @@ -2366,18 +2267,16 @@ void IntraSearch::initTBCTable(int bitDepth) memset(m_escapeNumBins, 0, sizeof(uint16_t)*m_symbolSize); for (uint32_t i = 0; i < m_symbolSize; i++) { -#if JVET_Q0491_PLT_ESCAPE m_escapeNumBins[i] = getEpExGolombNumBins(i, 5); -#else - m_escapeNumBins[i] = getEpExGolombNumBins(i, 3); -#endif } } void IntraSearch::calcPixelPred(CodingStructure& cs, Partitioner& partitioner, uint32_t yPos, uint32_t xPos, ComponentID compBegin, uint32_t numComp) { CodingUnit &cu = *cs.getCU(partitioner.chType); TransformUnit &tu = *cs.getTU(partitioner.chType); -#if JVET_Q0493_PLT_ENCODER_LOSSLESS +#if JVET_R0110_MIXED_LOSSLESS + bool lossless = (m_pcEncCfg->getCostMode() == COST_LOSSLESS_CODING && cs.slice->isLossless()); +#else bool lossless = (m_pcEncCfg->getCostMode() == COST_LOSSLESS_CODING); #endif @@ -2385,11 +2284,7 @@ void IntraSearch::calcPixelPred(CodingStructure& cs, Partitioner& partitioner, u for (int comp = compBegin; comp < (compBegin + numComp); comp++) { CompArea area = cu.blocks[comp]; -#if JVET_Q0346_LMCS_ENABLE_IN_SH if (m_pcEncCfg->getLmcs() && (cs.slice->getLmcsEnabledFlag() && m_pcReshape->getCTUFlag())) -#else - if (m_pcEncCfg->getLmcs() && (cs.picHeader->getLmcsEnabledFlag() && m_pcReshape->getCTUFlag())) -#endif { orgBuf[comp] = cs.getPredBuf(area); } @@ -2407,10 +2302,8 @@ void IntraSearch::calcPixelPred(CodingStructure& cs, Partitioner& partitioner, u int rightShiftOffset[3]; int invquantiserRightShift[3]; int add[3]; -#if JVET_Q0493_PLT_ENCODER_LOSSLESS if (!lossless) { -#endif for (uint32_t ch = compBegin; ch < (compBegin + numComp); ch++) { QpParam cQP(tu, ComponentID(ch)); @@ -2423,9 +2316,7 @@ void IntraSearch::calcPixelPred(CodingStructure& cs, Partitioner& partitioner, u invquantiserRightShift[ch] = IQUANT_SHIFT; add[ch] = 1 << (invquantiserRightShift[ch] - 1); } -#if JVET_Q0493_PLT_ENCODER_LOSSLESS } -#endif uint32_t scaleX = getComponentScaleX(COMPONENT_Cb, cs.sps->getChromaFormatIdc()); uint32_t scaleY = getComponentScaleY(COMPONENT_Cb, cs.sps->getChromaFormatIdc()); @@ -2437,7 +2328,6 @@ void IntraSearch::calcPixelPred(CodingStructure& cs, Partitioner& partitioner, u PLTescapeBuf escapeValue = tu.getescapeValue((ComponentID)ch); if (compBegin != COMPONENT_Y || ch == 0) { -#if JVET_Q0493_PLT_ENCODER_LOSSLESS if (lossless) { escapeValue.at(xPos, yPos) = orgBuf[ch].at(xPos, yPos); @@ -2445,20 +2335,16 @@ void IntraSearch::calcPixelPred(CodingStructure& cs, Partitioner& partitioner, u } else { -#endif escapeValue.at(xPos, yPos) = TCoeff(std::max<int>(0, ((orgBuf[ch].at(xPos, yPos) * quantiserScale[ch] + rightShiftOffset[ch]) >> quantiserRightShift[ch]))); assert(escapeValue.at(xPos, yPos) < (1 << (channelBitDepth + 1))); recBuf.at(xPos, yPos) = (((escapeValue.at(xPos, yPos)*g_invQuantScales[0][qpRem[ch]]) << qpPer[ch]) + add[ch]) >> invquantiserRightShift[ch]; recBuf.at(xPos, yPos) = Pel(ClipBD<int>(recBuf.at(xPos, yPos), channelBitDepth));//to be checked -#if JVET_Q0493_PLT_ENCODER_LOSSLESS } -#endif } else if (compBegin == COMPONENT_Y && ch > 0 && yPos % (1 << scaleY) == 0 && xPos % (1 << scaleX) == 0) { uint32_t yPosC = yPos >> scaleY; uint32_t xPosC = xPos >> scaleX; -#if JVET_Q0493_PLT_ENCODER_LOSSLESS if (lossless) { escapeValue.at(xPosC, yPosC) = orgBuf[ch].at(xPosC, yPosC); @@ -2466,14 +2352,11 @@ void IntraSearch::calcPixelPred(CodingStructure& cs, Partitioner& partitioner, u } else { -#endif escapeValue.at(xPosC, yPosC) = TCoeff(std::max<int>(0, ((orgBuf[ch].at(xPosC, yPosC) * quantiserScale[ch] + rightShiftOffset[ch]) >> quantiserRightShift[ch]))); assert(escapeValue.at(xPosC, yPosC) < (1 << (channelBitDepth + 1))); recBuf.at(xPosC, yPosC) = (((escapeValue.at(xPosC, yPosC)*g_invQuantScales[0][qpRem[ch]]) << qpPer[ch]) + add[ch]) >> invquantiserRightShift[ch]; recBuf.at(xPosC, yPosC) = Pel(ClipBD<int>(recBuf.at(xPosC, yPosC), channelBitDepth));//to be checked -#if JVET_Q0493_PLT_ENCODER_LOSSLESS } -#endif } } } @@ -2482,8 +2365,11 @@ void IntraSearch::derivePLTLossy(CodingStructure& cs, Partitioner& partitioner, CodingUnit &cu = *cs.getCU(partitioner.chType); const int channelBitDepth_L = cs.sps->getBitDepth(CHANNEL_TYPE_LUMA); const int channelBitDepth_C = cs.sps->getBitDepth(CHANNEL_TYPE_CHROMA); -#if JVET_Q0493_PLT_ENCODER_LOSSLESS +#if JVET_R0110_MIXED_LOSSLESS + bool lossless = (m_pcEncCfg->getCostMode() == COST_LOSSLESS_CODING && cs.slice->isLossless()); +#else bool lossless = (m_pcEncCfg->getCostMode() == COST_LOSSLESS_CODING); +#endif int pcmShiftRight_L = (channelBitDepth_L - PLT_ENCBITDEPTH); int pcmShiftRight_C = (channelBitDepth_C - PLT_ENCBITDEPTH); if (lossless) @@ -2491,14 +2377,8 @@ void IntraSearch::derivePLTLossy(CodingStructure& cs, Partitioner& partitioner, pcmShiftRight_L = 0; pcmShiftRight_C = 0; } -#else - const int pcmShiftRight_L = (channelBitDepth_L - PLT_ENCBITDEPTH); - const int pcmShiftRight_C = (channelBitDepth_C - PLT_ENCBITDEPTH); -#endif -#if JVET_Q0291_REDUCE_DUALTREE_PLT_SIZE int maxPltSize = cu.isSepTree() ? MAXPLTSIZE_DUALTREE : MAXPLTSIZE; -#endif uint32_t height = cu.block(compBegin).height; uint32_t width = cu.block(compBegin).width; @@ -2507,11 +2387,7 @@ void IntraSearch::derivePLTLossy(CodingStructure& cs, Partitioner& partitioner, for (int comp = compBegin; comp < (compBegin + numComp); comp++) { CompArea area = cu.blocks[comp]; -#if JVET_Q0346_LMCS_ENABLE_IN_SH if (m_pcEncCfg->getLmcs() && (cs.slice->getLmcsEnabledFlag() && m_pcReshape->getCTUFlag())) -#else - if (m_pcEncCfg->getLmcs() && (cs.picHeader->getLmcsEnabledFlag() && m_pcReshape->getCTUFlag())) -#endif { orgBuf[comp] = cs.getPredBuf(area); } @@ -2521,36 +2397,25 @@ void IntraSearch::derivePLTLossy(CodingStructure& cs, Partitioner& partitioner, } } -#if JVET_Q0503_Q0712_PLT_ENCODER_IMPROV_BUGFIX TransformUnit &tu = *cs.getTU(partitioner.chType); QpParam cQP(tu, compBegin); int qp = cQP.Qp(true) - 12; qp = (qp < 0) ? 0 : ((qp > 56) ? 56 : qp); int errorLimit = g_paletteQuant[qp]; -#else - int errorLimit = g_paletteQuant[cu.qp]; -#endif -#if JVET_Q0493_PLT_ENCODER_LOSSLESS if (lossless) { errorLimit = 0; } -#endif uint32_t totalSize = height*width; SortingElement *pelList = new SortingElement[totalSize]; SortingElement element; SortingElement *pelListSort = new SortingElement[MAXPLTSIZE + 1]; -#if JVET_Q0291_REDUCE_DUALTREE_PLT_SIZE uint32_t dictMaxSize = maxPltSize; -#else - uint32_t dictMaxSize = MAXPLTSIZE; -#endif uint32_t idx = 0; int last = -1; uint32_t scaleX = getComponentScaleX(COMPONENT_Cb, cs.sps->getChromaFormatIdc()); uint32_t scaleY = getComponentScaleY(COMPONENT_Cb, cs.sps->getChromaFormatIdc()); -#if JVET_Q0504_PLT_NON444 for (uint32_t y = 0; y < height; y++) { for (uint32_t x = 0; x < width; x++) @@ -2566,14 +2431,13 @@ void IntraSearch::derivePLTLossy(CodingStructure& cs, Partitioner& partitioner, ComponentID tmpCompBegin = compBegin; int tmpNumComp = numComp; - if( cs.sps->getChromaFormatIdc() != CHROMA_444 && - numComp == 3 && + if( cs.sps->getChromaFormatIdc() != CHROMA_444 && + numComp == 3 && (x != ((x >> scaleX) << scaleX) || (y != ((y >> scaleY) << scaleY))) ) { tmpCompBegin = COMPONENT_Y; tmpNumComp = 1; } -#if JVET_Q0493_PLT_ENCODER_LOSSLESS int besti = last, bestSAD = (last == -1) ? MAX_UINT : pelList[last].getSAD(element, cs.sps->getBitDepths(), tmpCompBegin, tmpNumComp, lossless); if (lossless) { @@ -2593,18 +2457,11 @@ void IntraSearch::derivePLTLossy(CodingStructure& cs, Partitioner& partitioner, } else { -#else - int besti = last, bestSAD = (last == -1) ? MAX_UINT : pelList[last].getSAD(element, cs.sps->getBitDepths(), tmpCompBegin, tmpNumComp); -#endif if( bestSAD ) { for (int i = idx - 1; i >= 0; i--) { -#if JVET_Q0493_PLT_ENCODER_LOSSLESS uint32_t sad = pelList[i].getSAD(element, cs.sps->getBitDepths(), tmpCompBegin, tmpNumComp, lossless); -#else - uint32_t sad = pelList[i].getSAD(element, cs.sps->getBitDepths(), tmpCompBegin, tmpNumComp); -#endif if (sad < bestSAD) { bestSAD = sad; @@ -2613,12 +2470,8 @@ void IntraSearch::derivePLTLossy(CodingStructure& cs, Partitioner& partitioner, } } } -#if JVET_Q0493_PLT_ENCODER_LOSSLESS } if (besti >= 0 && pelList[besti].almostEqualData(element, errorLimit, cs.sps->getBitDepths(), tmpCompBegin, tmpNumComp, lossless)) -#else - if (besti >= 0 && pelList[besti].almostEqualData(element, errorLimit, cs.sps->getBitDepths(), tmpCompBegin, tmpNumComp)) -#endif { pelList[besti].addElement(element, tmpCompBegin, tmpNumComp); last = besti; @@ -2661,90 +2514,13 @@ void IntraSearch::derivePLTLossy(CodingStructure& cs, Partitioner& partitioner, } } } -#else - for (uint32_t y = 0; y < height; y++) - { - for (uint32_t x = 0; x < width; x++) - { - uint32_t org[3], pX, pY; - for (int comp = compBegin; comp < (compBegin + numComp); comp++) - { - pX = (comp > 0 && compBegin == COMPONENT_Y) ? (x >> scaleX) : x; - pY = (comp > 0 && compBegin == COMPONENT_Y) ? (y >> scaleY) : y; - org[comp] = orgBuf[comp].at(pX, pY); - } - element.setAll(org, compBegin, numComp); -#if JVET_Q0493_PLT_ENCODER_LOSSLESS - int besti = last, bestSAD = (last == -1) ? MAX_UINT : pelList[last].getSAD(element, cs.sps->getBitDepths(), compBegin, numComp, lossless); - if (lossless) - { - if (bestSAD) - { - for (int i = idx - 1; i >= 0; i--) - { - uint32_t sad = pelList[i].getSAD(element, cs.sps->getBitDepths(), compBegin, numComp, lossless); - if (sad == 0) - { - bestSAD = sad; - besti = i; - break; - } - } - } - } - else - { -#else - int besti = last, bestSAD = (last == -1) ? MAX_UINT : pelList[last].getSAD(element, cs.sps->getBitDepths(), compBegin, numComp); -#endif - if (bestSAD) - { - for (int i = idx - 1; i >= 0; i--) - { -#if JVET_Q0493_PLT_ENCODER_LOSSLESS - uint32_t sad = pelList[i].getSAD(element, cs.sps->getBitDepths(), compBegin, numComp, lossless); -#else - uint32_t sad = pelList[i].getSAD(element, cs.sps->getBitDepths(), compBegin, numComp); -#endif - if (sad < bestSAD) - { - bestSAD = sad; - besti = i; - if (!sad) break; - } - } - } -#if JVET_Q0493_PLT_ENCODER_LOSSLESS - } - if (besti >= 0 && pelList[besti].almostEqualData(element, errorLimit, cs.sps->getBitDepths(), compBegin, numComp, lossless)) -#else - if (besti >= 0 && pelList[besti].almostEqualData(element, errorLimit, cs.sps->getBitDepths(), compBegin, numComp)) -#endif - { - pelList[besti].addElement(element, compBegin, numComp); - last = besti; - } - else - { - pelList[idx].copyDataFrom(element, compBegin, numComp); - pelList[idx].setCnt(1); - last = idx; - idx++; - } - } - } -#endif for (int i = 0; i < dictMaxSize; i++) { -#if JVET_Q0504_PLT_NON444 pelListSort[i].setCnt(0, COMPONENT_Y); pelListSort[i].setCnt(0, COMPONENT_Cb); pelListSort[i].setCnt(0, COMPONENT_Cr); pelListSort[i].setCnt(0, MAX_NUM_COMPONENT); -#else - pelListSort[i].setCnt(0); -#endif pelListSort[i].resetAll(compBegin, numComp); } @@ -2752,27 +2528,15 @@ void IntraSearch::derivePLTLossy(CodingStructure& cs, Partitioner& partitioner, dictMaxSize = 1; for (int i = 0; i < idx; i++) { -#if JVET_Q0504_PLT_NON444 if( pelList[i].getCnt(MAX_NUM_COMPONENT) > pelListSort[dictMaxSize - 1].getCnt(MAX_NUM_COMPONENT) ) -#else - if (pelList[i].getCnt() > pelListSort[dictMaxSize - 1].getCnt()) -#endif { int j; for (j = dictMaxSize; j > 0; j--) { -#if JVET_Q0504_PLT_NON444 if (pelList[i].getCnt(MAX_NUM_COMPONENT) > pelListSort[j - 1].getCnt(MAX_NUM_COMPONENT)) -#else - if (pelList[i].getCnt() > pelListSort[j - 1].getCnt() ) -#endif { pelListSort[j].copyAllFrom(pelListSort[j - 1], compBegin, numComp); -#if JVET_Q0291_REDUCE_DUALTREE_PLT_SIZE dictMaxSize = std::min(dictMaxSize + 1, (uint32_t)maxPltSize); -#else - dictMaxSize = std::min(dictMaxSize + 1, (uint32_t)MAXPLTSIZE); -#endif } else { @@ -2791,17 +2555,10 @@ void IntraSearch::derivePLTLossy(CodingStructure& cs, Partitioner& partitioner, } const int plt_lambda_shift = (compBegin > 0) ? pcmShiftRight_C : pcmShiftRight_L; double bitCost = m_pcRdCost->getLambda() / (double) (1 << (2 * plt_lambda_shift)) * numColorBits; -#if JVET_Q0503_Q0712_PLT_ENCODER_IMPROV_BUGFIX bool reuseflag[MAXPLTPREDSIZE] = { false }; int run; double reuseflagCost; -#endif -#if JVET_Q0504_PLT_NON444 -#if JVET_Q0291_REDUCE_DUALTREE_PLT_SIZE for (int i = 0; i < maxPltSize; i++) -#else - for( int i = 0; i < MAXPLTSIZE; i++ ) -#endif { if( pelListSort[i].getCnt(MAX_NUM_COMPONENT) ) { @@ -2854,7 +2611,6 @@ void IntraSearch::derivePLTLossy(CodingStructure& cs, Partitioner& partitioner, cost += (err * err) / (1 << (2 * pcmShiftRight_L)) * pelListSort[i].getCnt(comp); } } -#if JVET_Q0503_Q0712_PLT_ENCODER_IMPROV_BUGFIX run = 0; for (int t2 = t; t2 >= 0; t2--) { @@ -2869,7 +2625,6 @@ void IntraSearch::derivePLTLossy(CodingStructure& cs, Partitioner& partitioner, } reuseflagCost = m_pcRdCost->getLambda() / (double)(1 << (2 * plt_lambda_shift)) * getEpExGolombNumBins(run ? run + 1 : run, 0); cost += reuseflagCost; -#endif if( cost < bestCost ) { @@ -2883,9 +2638,7 @@ void IntraSearch::derivePLTLossy(CodingStructure& cs, Partitioner& partitioner, { cu.curPLT[comp][paletteSize] = cs.prevPLT.curPLT[comp][best]; } -#if JVET_Q0503_Q0712_PLT_ENCODER_IMPROV_BUGFIX reuseflag[best] = true; -#endif } } @@ -2933,124 +2686,9 @@ void IntraSearch::derivePLTLossy(CodingStructure& cs, Partitioner& partitioner, break; } } -#else -#if JVET_Q0291_REDUCE_DUALTREE_PLT_SIZE -for (int i = 0; i < maxPltSize; i++) -#else - for (int i = 0; i < MAXPLTSIZE; i++) -#endif - { - if (pelListSort[i].getCnt()) - { - int half = pelListSort[i].getCnt() >> 1; - for (int comp = compBegin; comp < (compBegin + numComp); comp++) - { - cu.curPLT[comp][paletteSize] = (pelListSort[i].getSumData(comp) + half) / pelListSort[i].getCnt(); - } - - int best = -1; - if (errorLimit) - { - double pal[MAX_NUM_COMPONENT], err = 0.0, bestCost = 0.0; - for (int comp = compBegin; comp < (compBegin + numComp); comp++) - { - pal[comp] = pelListSort[i].getSumData(comp) / (double)pelListSort[i].getCnt(); - err = pal[comp] - cu.curPLT[comp][paletteSize]; - if (isChroma((ComponentID) comp)) - { - bestCost += (err * err * PLT_CHROMA_WEIGHTING) / (1 << (2 * pcmShiftRight_C)); - } - else - { - bestCost += (err * err) / (1 << (2 * pcmShiftRight_L)); - } - } - bestCost = bestCost * pelListSort[i].getCnt() + bitCost; - - for (int t = 0; t < cs.prevPLT.curPLTSize[compBegin]; t++) - { - double cost = 0.0; - for (int comp = compBegin; comp < (compBegin + numComp); comp++) - { - err = pal[comp] - cs.prevPLT.curPLT[comp][t]; - if (isChroma((ComponentID) comp)) - { - cost += (err * err * PLT_CHROMA_WEIGHTING) / (1 << (2 * pcmShiftRight_C)); - } - else - { - cost += (err * err) / (1 << (2 * pcmShiftRight_L)); - } - } - cost *= pelListSort[i].getCnt(); -#if JVET_Q0503_Q0712_PLT_ENCODER_IMPROV_BUGFIX - run = 0; - for (int t2 = t-1; t2 >= 0; t2--) - { - if (!reuseflag[t2]) - { - run++; - } - else - { - break; - } - } - reuseflagCost = m_pcRdCost->getLambda() / (double)(1 << (2 * plt_lambda_shift)) * getEpExGolombNumBins(run ? run + 1 : run, 0); - cost += reuseflagCost; -#endif - if (cost < bestCost) - { - best = t; - bestCost = cost; - } - } - if (best != -1) - { - for (int comp = compBegin; comp < (compBegin + numComp); comp++) - { - cu.curPLT[comp][paletteSize] = cs.prevPLT.curPLT[comp][best]; - } -#if JVET_Q0503_Q0712_PLT_ENCODER_IMPROV_BUGFIX - reuseflag[best] = true; -#endif - } - } - - bool duplicate = false; - if (pelListSort[i].getCnt() == 1 && best == -1) - { - duplicate = true; - } - else - { - for (int t = 0; t<paletteSize; t++) - { - bool duplicateTmp = true; - for (int comp = compBegin; comp < (compBegin + numComp); comp++) - { - duplicateTmp = duplicateTmp && (cu.curPLT[comp][paletteSize] == cu.curPLT[comp][t]); - } - if (duplicateTmp) - { - duplicate = true; - break; - } - } - } - if (!duplicate) paletteSize++; - } - else - { - break; - } - } -#endif cu.curPLTSize[compBegin] = paletteSize; -#if JVET_Q0504_PLT_NON444 if( cu.isLocalSepTree() ) cu.curPLTSize[COMPONENT_Y] = paletteSize; -#endif delete[] pelList; delete[] pelListSort; @@ -3081,15 +2719,6 @@ void IntraSearch::xEncIntraHeader( CodingStructure &cs, Partitioner &partitioner { return; } -#if !JVET_Q0110_Q0785_CHROMA_BDPCM_420 - m_CABACEstimator->bdpcm_mode ( cu, ComponentID(partitioner.chType) ); -#if JVET_Q0438_MONOCHROME_BUGFIXES - if (!CS::isDualITree(cs) && isLuma(partitioner.chType) && isChromaEnabled(cu.chromaFormat)) -#else - if (!CS::isDualITree(cs) && isLuma(partitioner.chType)) -#endif - m_CABACEstimator->bdpcm_mode(cu, ComponentID(CHANNEL_TYPE_CHROMA)); -#endif } PredictionUnit &pu = *cs.getPU(partitioner.currArea().lumaPos(), partitioner.chType); @@ -3099,9 +2728,7 @@ void IntraSearch::xEncIntraHeader( CodingStructure &cs, Partitioner &partitioner { if ( !cu.Y().valid()) m_CABACEstimator->pred_mode( cu ); -#if JVET_Q0110_Q0785_CHROMA_BDPCM_420 m_CABACEstimator->bdpcm_mode( cu, COMPONENT_Y ); -#endif m_CABACEstimator->intra_luma_pred_mode( pu ); } } @@ -3114,9 +2741,7 @@ void IntraSearch::xEncIntraHeader( CodingStructure &cs, Partitioner &partitioner if( isFirst ) { -#if JVET_Q0110_Q0785_CHROMA_BDPCM_420 m_CABACEstimator->bdpcm_mode( cu, ComponentID(CHANNEL_TYPE_CHROMA) ); -#endif m_CABACEstimator->intra_chroma_pred_mode( pu ); } } @@ -3132,9 +2757,6 @@ void IntraSearch::xEncSubdivCbfQT( CodingStructure &cs, Partitioner &partitioner const bool subdiv = currTU.depth > currDepth; ComponentID compID = partitioner.chType == CHANNEL_TYPE_LUMA ? COMPONENT_Y : COMPONENT_Cb; -#if !JVET_Q0438_MONOCHROME_BUGFIXES - const bool chromaCbfISP = currArea.blocks[COMPONENT_Cb].valid() && currCU.ispMode && !subdiv; -#endif if( partitioner.canSplit( TU_MAX_TR_SPLIT, cs ) ) { @@ -3145,14 +2767,10 @@ void IntraSearch::xEncSubdivCbfQT( CodingStructure &cs, Partitioner &partitioner CHECK( subdiv && !currCU.ispMode && isLuma( compID ), "No TU subdivision is allowed with QTBT" ); } -#if JVET_Q0438_MONOCHROME_BUGFIXES if (bChroma) { const bool chromaCbfISP = currArea.blocks[COMPONENT_Cb].valid() && currCU.ispMode && !subdiv; if ( !currCU.ispMode || chromaCbfISP ) -#else - if( bChroma && ( !currCU.ispMode || chromaCbfISP ) ) -#endif { const uint32_t numberValidComponents = getNumberValidComponents(currArea.chromaFormat); const uint32_t cbfDepth = ( chromaCbfISP ? currDepth - 1 : currDepth ); @@ -3169,9 +2787,7 @@ void IntraSearch::xEncSubdivCbfQT( CodingStructure &cs, Partitioner &partitioner } } } -#if JVET_Q0438_MONOCHROME_BUGFIXES } -#endif if (subdiv) { @@ -3271,12 +2887,6 @@ void IntraSearch::xEncCoeffQT( CodingStructure &cs, Partitioner &partitioner, co const int cbfMask = ( TU::getCbf( currTU, COMPONENT_Cb ) ? 2 : 0 ) + ( TU::getCbf( currTU, COMPONENT_Cr ) ? 1 : 0 ); m_CABACEstimator->joint_cb_cr( currTU, cbfMask ); } -#if !REMOVE_PPS_REXT - if( TU::hasCrossCompPredInfo( currTU, compID ) ) - { - m_CABACEstimator->cross_comp_pred( currTU, compID ); - } -#endif if( TU::getCbf( currTU, compID ) ) { if( isLuma(compID) ) @@ -3338,12 +2948,6 @@ uint64_t IntraSearch::xGetIntraFracBitsQTSingleChromaComponent( CodingStructure const bool prevCbf = ( compID == COMPONENT_Cr ? TU::getCbfAtDepth( currTU, COMPONENT_Cb, partitioner.currTrDepth ) : false ); m_CABACEstimator->cbf_comp( cs, TU::getCbfAtDepth( currTU, compID, partitioner.currTrDepth ), currArea.blocks[compID], partitioner.currTrDepth - 1, prevCbf ); //coeffs coding and cross comp coding -#if !REMOVE_PPS_REXT - if( TU::hasCrossCompPredInfo( currTU, compID ) ) - { - m_CABACEstimator->cross_comp_pred( currTU, compID ); - } -#endif if( TU::getCbf( currTU, compID ) ) { m_CABACEstimator->residual_coding( currTU, compID ); @@ -3356,12 +2960,6 @@ uint64_t IntraSearch::xGetIntraFracBitsQTSingleChromaComponent( CodingStructure uint64_t IntraSearch::xGetIntraFracBitsQTChroma(TransformUnit& currTU, const ComponentID &compID) { m_CABACEstimator->resetBits(); -#if !REMOVE_PPS_REXT - if( TU::hasCrossCompPredInfo( currTU, compID ) ) - { - m_CABACEstimator->cross_comp_pred( currTU, compID ); - } -#endif // Include Cbf and jointCbCr flags here as we make decisions across components CodingStructure &cs = *currTU.cs; @@ -3400,11 +2998,7 @@ uint64_t IntraSearch::xGetIntraFracBitsQTChroma(TransformUnit& currTU, const Com return fracBits; } -#if !REMOVE_PPS_REXT -void IntraSearch::xIntraCodingTUBlock(TransformUnit &tu, const ComponentID &compID, const bool &checkCrossCPrediction, Distortion& ruiDist, const int &default0Save1Load2, uint32_t* numSig, std::vector<TrMode>* trModes, const bool loadTr) -#else void IntraSearch::xIntraCodingTUBlock(TransformUnit &tu, const ComponentID &compID, Distortion& ruiDist, const int &default0Save1Load2, uint32_t* numSig, std::vector<TrMode>* trModes, const bool loadTr) -#endif { if (!tu.blocks[compID].valid()) { @@ -3416,9 +3010,6 @@ void IntraSearch::xIntraCodingTUBlock(TransformUnit &tu, const ComponentID &comp const CompArea &area = tu.blocks[compID]; const SPS &sps = *cs.sps; -#if !REMOVE_PPS_REXT - const PPS &pps = *cs.pps; -#endif const ChannelType chType = toChannelType(compID); const int bitDepth = sps.getBitDepth(chType); @@ -3426,29 +3017,18 @@ void IntraSearch::xIntraCodingTUBlock(TransformUnit &tu, const ComponentID &comp PelBuf piOrg = cs.getOrgBuf (area); PelBuf piPred = cs.getPredBuf (area); PelBuf piResi = cs.getResiBuf (area); -#if !REMOVE_PPS_REXT - PelBuf piOrgResi = cs.getOrgResiBuf(area); -#endif PelBuf piReco = cs.getRecoBuf (area); const PredictionUnit &pu = *cs.getPU(area.pos(), chType); const uint32_t uiChFinalMode = PU::getFinalIntraMode(pu, chType); -#if !REMOVE_PPS_REXT - const bool bUseCrossCPrediction = pps.getPpsRangeExtension().getCrossComponentPredictionEnabledFlag() && isChroma( compID ) && PU::isChromaIntraModeCrossCheckMode( pu ) && checkCrossCPrediction; - const bool ccUseRecoResi = m_pcEncCfg->getUseReconBasedCrossCPredictionEstimate(); -#endif //===== init availability pattern ===== CHECK( tu.jointCbCr && compID == COMPONENT_Cr, "wrong combination of compID and jointCbCr" ); bool jointCbCr = tu.jointCbCr && compID == COMPONENT_Cb; -#if JVET_Q0695_CHROMA_TS_JCCR || JVET_Q0820_ACT if (compID == COMPONENT_Y) -#else - if (compID == COMPONENT_Y || (isChroma(compID) && tu.cu->bdpcmModeChroma)) -#endif { PelBuf sharedPredTS( m_pSharedPredTransformSkip[compID], area ); if( default0Save1Load2 != 2 ) @@ -3522,20 +3102,12 @@ void IntraSearch::xIntraCodingTUBlock(TransformUnit &tu, const ComponentID &comp //DTRACE_PEL_BUF( D_PRED, piPred, tu, tu.cu->predMode, COMPONENT_Y ); const Slice &slice = *cs.slice; -#if JVET_Q0346_LMCS_ENABLE_IN_SH bool flag = slice.getLmcsEnabledFlag() && (slice.isIntra() || (!slice.isIntra() && m_pcReshape->getCTUFlag())); -#else - bool flag = slice.getPicHeader()->getLmcsEnabledFlag() && (slice.isIntra() || (!slice.isIntra() && m_pcReshape->getCTUFlag())); -#endif if (isLuma(compID)) { //===== get residual signal ===== piResi.copyFrom( piOrg ); -#if JVET_Q0346_LMCS_ENABLE_IN_SH if (slice.getLmcsEnabledFlag() && m_pcReshape->getCTUFlag() && compID == COMPONENT_Y) -#else - if (slice.getPicHeader()->getLmcsEnabledFlag() && m_pcReshape->getCTUFlag() && compID == COMPONENT_Y) -#endif { CompArea tmpArea(COMPONENT_Y, area.chromaFormat, Position(0, 0), area.size()); PelBuf tmpPred = m_tmpStorageLCU.getBuf(tmpArea); @@ -3548,21 +3120,6 @@ void IntraSearch::xIntraCodingTUBlock(TransformUnit &tu, const ComponentID &comp piResi.subtract( piPred ); } -#if !REMOVE_PPS_REXT - if (pps.getPpsRangeExtension().getCrossComponentPredictionEnabledFlag() && isLuma(compID)) - { - piOrgResi.copyFrom (piResi); - } - - if (bUseCrossCPrediction) - { - if (xCalcCrossComponentPredictionAlpha(tu, compID, ccUseRecoResi) == 0) - { - return; - } - CrossComponentPrediction::crossComponentPrediction(tu, compID, cs.getResiBuf(tu.Y()), piResi, piResi, false); - } -#endif } //===== transform and quantization ===== @@ -3584,7 +3141,6 @@ void IntraSearch::xIntraCodingTUBlock(TransformUnit &tu, const ComponentID &comp m_pcTrQuant->setLambda(m_pcTrQuant->getLambda() / (cResScale*cResScale)); } -#if JVET_Q0438_MONOCHROME_BUGFIXES PelBuf crOrg; PelBuf crPred; PelBuf crResi; @@ -3598,13 +3154,6 @@ void IntraSearch::xIntraCodingTUBlock(TransformUnit &tu, const ComponentID &comp crResi = cs.getResiBuf ( crArea ); crReco = cs.getRecoBuf ( crArea ); } -#else - const CompArea &crArea = tu.blocks [ COMPONENT_Cr ]; - PelBuf crOrg = cs.getOrgBuf ( crArea ); - PelBuf crPred = cs.getPredBuf ( crArea ); - PelBuf crResi = cs.getResiBuf ( crArea ); - PelBuf crReco = cs.getRecoBuf ( crArea ); -#endif if ( jointCbCr ) { @@ -3625,14 +3174,14 @@ void IntraSearch::xIntraCodingTUBlock(TransformUnit &tu, const ComponentID &comp m_pcTrQuant->transformNxN(tu, compID, cQP, trModes, m_pcEncCfg->getMTSIntraMaxCand()); tu.mtsIdx[compID] = trModes->at(0).first; } -#if JVET_AHG14_LOSSLESS +#if JVET_R0110_MIXED_LOSSLESS + if (!(m_pcEncCfg->getCostMode() == COST_LOSSLESS_CODING && slice.isLossless() && tu.mtsIdx[compID] == 0) || tu.cu->bdpcmMode != 0) +#else if( !( m_pcEncCfg->getCostMode() == COST_LOSSLESS_CODING && tu.mtsIdx[compID] == 0 ) || tu.cu->bdpcmMode != 0 ) +#endif { m_pcTrQuant->transformNxN(tu, compID, cQP, uiAbsSum, m_CABACEstimator->getCtx(), loadTr); } -#else - m_pcTrQuant->transformNxN(tu, compID, cQP, uiAbsSum, m_CABACEstimator->getCtx(), loadTr); -#endif DTRACE( g_trace_ctx, D_TU_ABS_SUM, "%d: comp=%d, abssum=%d\n", DTRACE_GET_COUNTER( g_trace_ctx, D_TU_ABS_SUM ), compID, uiAbsSum ); @@ -3643,15 +3192,16 @@ void IntraSearch::xIntraCodingTUBlock(TransformUnit &tu, const ComponentID &comp ruiDist = MAX_INT; return; } - -#if JVET_AHG14_LOSSLESS +#if JVET_R0110_MIXED_LOSSLESS + if ((m_pcEncCfg->getCostMode() == COST_LOSSLESS_CODING && slice.isLossless() && tu.mtsIdx[compID] == 0) && 0 == tu.cu->bdpcmMode) +#else if( ( m_pcEncCfg->getCostMode() == COST_LOSSLESS_CODING && tu.mtsIdx[compID] == 0 ) && 0 == tu.cu->bdpcmMode ) +#endif { uiAbsSum = 0; tu.getCoeffs( compID ).fill( 0 ); TU::setCbfAtDepth( tu, compID, tu.depth, 0 ); } -#endif //--- inverse transform --- if (uiAbsSum > 0) @@ -3680,36 +3230,32 @@ void IntraSearch::xIntraCodingTUBlock(TransformUnit &tu, const ComponentID &comp if (trModes) { -#if JVET_Q0695_CHROMA_TS_JCCR m_pcTrQuant->transformNxN(tu, codeCompId, qpCbCr, trModes, m_pcEncCfg->getMTSIntraMaxCand()); tu.mtsIdx[codeCompId] = trModes->at(0).first; if (tu.jointCbCr) { tu.mtsIdx[(codeCompId == COMPONENT_Cr) ? COMPONENT_Cb : COMPONENT_Cr] = MTS_DCT2_DCT2; } -#else - m_pcTrQuant->transformNxN(tu, compID, qpCbCr, trModes, m_pcEncCfg->getMTSIntraMaxCand()); - tu.mtsIdx[compID] = trModes->at(0).first; -#endif } // encoder bugfix: Set loadTr to aovid redundant transform process -#if JVET_AHG14_LOSSLESS +#if JVET_R0110_MIXED_LOSSLESS + if (!(m_pcEncCfg->getCostMode() == COST_LOSSLESS_CODING && slice.isLossless() && tu.mtsIdx[compID] == 0) || tu.cu->bdpcmModeChroma != 0) +#else if (!(m_pcEncCfg->getCostMode() == COST_LOSSLESS_CODING && tu.mtsIdx[compID] == 0) || tu.cu->bdpcmModeChroma != 0) +#endif { m_pcTrQuant->transformNxN(tu, codeCompId, qpCbCr, uiAbsSum, m_CABACEstimator->getCtx(), loadTr); } +#if JVET_R0110_MIXED_LOSSLESS + if ((m_pcEncCfg->getCostMode() == COST_LOSSLESS_CODING && slice.isLossless() && tu.mtsIdx[compID] == 0) && 0 == tu.cu->bdpcmModeChroma) #else - m_pcTrQuant->transformNxN(tu, codeCompId, qpCbCr, uiAbsSum, m_CABACEstimator->getCtx(), loadTr); -#endif - -#if JVET_AHG14_LOSSLESS if ((m_pcEncCfg->getCostMode() == COST_LOSSLESS_CODING && tu.mtsIdx[compID] == 0) && 0 == tu.cu->bdpcmModeChroma) +#endif { uiAbsSum = 0; tu.getCoeffs(compID).fill(0); TU::setCbfAtDepth(tu, compID, tu.depth, 0); } -#endif DTRACE( g_trace_ctx, D_TU_ABS_SUM, "%d: comp=%d, abssum=%d\n", DTRACE_GET_COUNTER( g_trace_ctx, D_TU_ABS_SUM ), codeCompId, uiAbsSum ); if( uiAbsSum > 0 ) @@ -3748,22 +3294,8 @@ void IntraSearch::xIntraCodingTUBlock(TransformUnit &tu, const ComponentID &comp crResi.scaleSignal(tu.getChromaAdj(), 0, tu.cu->cs->slice->clpRng(COMPONENT_Cr)); } } -#if !REMOVE_PPS_REXT - if (bUseCrossCPrediction) - { - CrossComponentPrediction::crossComponentPrediction(tu, compID, cs.getResiBuf(tu.Y()), piResi, piResi, true); - if( jointCbCr ) - { - CrossComponentPrediction::crossComponentPrediction(tu, COMPONENT_Cr, cs.getResiBuf(tu.Y()), crResi, crResi, true); - } - } -#endif -#if JVET_Q0346_LMCS_ENABLE_IN_SH if (slice.getLmcsEnabledFlag() && m_pcReshape->getCTUFlag() && compID == COMPONENT_Y) -#else - if (slice.getPicHeader()->getLmcsEnabledFlag() && m_pcReshape->getCTUFlag() && compID == COMPONENT_Y) -#endif { CompArea tmpArea(COMPONENT_Y, area.chromaFormat, Position(0,0), area.size()); PelBuf tmpPred = m_tmpStorageLCU.getBuf(tmpArea); @@ -3782,13 +3314,8 @@ void IntraSearch::xIntraCodingTUBlock(TransformUnit &tu, const ComponentID &comp //===== update distortion ===== #if WCG_EXT -#if JVET_Q0346_LMCS_ENABLE_IN_SH if (m_pcEncCfg->getLumaLevelToDeltaQPMapping().isEnabled() || (m_pcEncCfg->getLmcs() && slice.getLmcsEnabledFlag() && (m_pcReshape->getCTUFlag() || (isChroma(compID) && m_pcEncCfg->getReshapeIntraCMD())))) -#else - if (m_pcEncCfg->getLumaLevelToDeltaQPMapping().isEnabled() || (m_pcEncCfg->getLmcs() - && slice.getPicHeader()->getLmcsEnabledFlag() && (m_pcReshape->getCTUFlag() || (isChroma(compID) && m_pcEncCfg->getReshapeIntraCMD())))) -#endif { const CPelBuf orgLuma = cs.getOrgBuf( cs.area.blocks[COMPONENT_Y] ); if (compID == COMPONENT_Y && !(m_pcEncCfg->getLumaLevelToDeltaQPMapping().isEnabled())) @@ -3842,10 +3369,11 @@ void IntraSearch::xIntraCodingACTTUBlock(TransformUnit &tu, const ComponentID &c bool jointCbCr = tu.jointCbCr && compID == COMPONENT_Cb; m_pcRdCost->setChromaFormat(cs.sps->getChromaFormatIdc()); - -#if JVET_Q0820_ACT +#if JVET_R0110_MIXED_LOSSLESS + if (m_pcEncCfg->getCostMode() != COST_LOSSLESS_CODING || !slice.isLossless()) +#else if (m_pcEncCfg->getCostMode() != COST_LOSSLESS_CODING) -#endif +#endif m_pcTrQuant->lambdaAdjustColorTrans(true); if (jointCbCr) @@ -3858,11 +3386,7 @@ void IntraSearch::xIntraCodingACTTUBlock(TransformUnit &tu, const ComponentID &c m_pcTrQuant->selectLambda(compID); } -#if JVET_Q0346_LMCS_ENABLE_IN_SH bool flag = slice.getLmcsEnabledFlag() && (slice.isIntra() || (!slice.isIntra() && m_pcReshape->getCTUFlag())) && (tu.blocks[compID].width*tu.blocks[compID].height > 4); -#else - bool flag = slice.getPicHeader()->getLmcsEnabledFlag() && (slice.isIntra() || (!slice.isIntra() && m_pcReshape->getCTUFlag())) && (tu.blocks[compID].width*tu.blocks[compID].height > 4); -#endif if (flag && isChroma(compID) && slice.getPicHeader()->getLmcsChromaResidualScaleFlag()) { int cResScaleInv = tu.getChromaAdj(); @@ -3885,32 +3409,28 @@ void IntraSearch::xIntraCodingACTTUBlock(TransformUnit &tu, const ComponentID &c if (isLuma(compID)) { QpParam cQP(tu, compID); -#if !JVET_Q0820_ACT - for (int qpIdx = 0; qpIdx < 2; qpIdx++) - { - cQP.Qps[qpIdx] = cQP.Qps[qpIdx] + (compID == COMPONENT_Cr ? DELTA_QP_FOR_Co : DELTA_QP_FOR_Y_Cg); - cQP.pers[qpIdx] = cQP.Qps[qpIdx] / 6; - cQP.rems[qpIdx] = cQP.Qps[qpIdx] % 6; - } -#endif if (trModes) { m_pcTrQuant->transformNxN(tu, compID, cQP, trModes, m_pcEncCfg->getMTSIntraMaxCand()); tu.mtsIdx[compID] = trModes->at(0).first; } -#if JVET_Q0820_ACT +#if JVET_R0110_MIXED_LOSSLESS + if (!(m_pcEncCfg->getCostMode() == COST_LOSSLESS_CODING && slice.isLossless() && tu.mtsIdx[compID] == 0) || tu.cu->bdpcmMode != 0) +#else if (!(m_pcEncCfg->getCostMode() == COST_LOSSLESS_CODING && tu.mtsIdx[compID] == 0) || tu.cu->bdpcmMode != 0) -#endif +#endif m_pcTrQuant->transformNxN(tu, compID, cQP, uiAbsSum, m_CABACEstimator->getCtx(), loadTr); -#if JVET_Q0820_ACT +#if JVET_R0110_MIXED_LOSSLESS + if ((m_pcEncCfg->getCostMode() == COST_LOSSLESS_CODING && slice.isLossless() && tu.mtsIdx[compID] == 0) && tu.cu->bdpcmMode == 0) +#else if ((m_pcEncCfg->getCostMode() == COST_LOSSLESS_CODING && tu.mtsIdx[compID] == 0) && tu.cu->bdpcmMode == 0) +#endif { uiAbsSum = 0; tu.getCoeffs(compID).fill(0); TU::setCbfAtDepth(tu, compID, tu.depth, 0); } -#endif if (uiAbsSum > 0) { @@ -3926,14 +3446,6 @@ void IntraSearch::xIntraCodingACTTUBlock(TransformUnit &tu, const ComponentID &c int codedCbfMask = 0; ComponentID codeCompId = (tu.jointCbCr ? (tu.jointCbCr >> 1 ? COMPONENT_Cb : COMPONENT_Cr) : compID); QpParam qpCbCr(tu, codeCompId); -#if !JVET_Q0820_ACT - for (int qpIdx = 0; qpIdx < 2; qpIdx++) - { - qpCbCr.Qps[qpIdx] = qpCbCr.Qps[qpIdx] + (codeCompId == COMPONENT_Cr ? DELTA_QP_FOR_Co : DELTA_QP_FOR_Y_Cg); - qpCbCr.pers[qpIdx] = qpCbCr.Qps[qpIdx] / 6; - qpCbCr.rems[qpIdx] = qpCbCr.Qps[qpIdx] % 6; - } -#endif if (tu.jointCbCr) { @@ -3944,7 +3456,6 @@ void IntraSearch::xIntraCodingACTTUBlock(TransformUnit &tu, const ComponentID &c PelBuf& codeResi = (codeCompId == COMPONENT_Cr ? crResi : piResi); uiAbsSum = 0; -#if JVET_Q0820_ACT if (trModes) { m_pcTrQuant->transformNxN(tu, codeCompId, qpCbCr, trModes, m_pcEncCfg->getMTSIntraMaxCand()); @@ -3954,13 +3465,14 @@ void IntraSearch::xIntraCodingACTTUBlock(TransformUnit &tu, const ComponentID &c tu.mtsIdx[(codeCompId == COMPONENT_Cr) ? COMPONENT_Cb : COMPONENT_Cr] = MTS_DCT2_DCT2; } } +#if JVET_R0110_MIXED_LOSSLESS + if (!(m_pcEncCfg->getCostMode() == COST_LOSSLESS_CODING && slice.isLossless() && tu.mtsIdx[codeCompId] == 0) || tu.cu->bdpcmModeChroma != 0) +#else if (!(m_pcEncCfg->getCostMode() == COST_LOSSLESS_CODING && tu.mtsIdx[codeCompId] == 0) || tu.cu->bdpcmModeChroma != 0) +#endif { m_pcTrQuant->transformNxN(tu, codeCompId, qpCbCr, uiAbsSum, m_CABACEstimator->getCtx(), loadTr); } -#else - m_pcTrQuant->transformNxN(tu, codeCompId, qpCbCr, uiAbsSum, m_CABACEstimator->getCtx()); -#endif if (uiAbsSum > 0) { m_pcTrQuant->invTransformNxN(tu, codeCompId, codeResi, qpCbCr); @@ -3981,9 +3493,11 @@ void IntraSearch::xIntraCodingACTTUBlock(TransformUnit &tu, const ComponentID &c if (tu.jointCbCr != codedCbfMask) { ruiDist = std::numeric_limits<Distortion>::max(); -#if JVET_Q0820_ACT +#if JVET_R0110_MIXED_LOSSLESS + if (m_pcEncCfg->getCostMode() != COST_LOSSLESS_CODING || !slice.isLossless()) +#else if (m_pcEncCfg->getCostMode() != COST_LOSSLESS_CODING) -#endif +#endif m_pcTrQuant->lambdaAdjustColorTrans(false); return; } @@ -4000,10 +3514,11 @@ void IntraSearch::xIntraCodingACTTUBlock(TransformUnit &tu, const ComponentID &c crResi.scaleSignal(tu.getChromaAdj(), 0, slice.clpRng(COMPONENT_Cr)); } } - -#if JVET_Q0820_ACT +#if JVET_R0110_MIXED_LOSSLESS + if (m_pcEncCfg->getCostMode() != COST_LOSSLESS_CODING || !slice.isLossless()) +#else if (m_pcEncCfg->getCostMode() != COST_LOSSLESS_CODING) -#endif +#endif m_pcTrQuant->lambdaAdjustColorTrans(false); ruiDist += m_pcRdCost->getDistPart(piOrgResi, piResi, sps.getBitDepth(toChannelType(compID)), compID, DF_SSE); @@ -4040,11 +3555,7 @@ bool IntraSearch::xIntraCodingLumaISP(CodingStructure& cs, Partitioner& partitio tu.depth = partitioner.currTrDepth; // Encode TU -#if !REMOVE_PPS_REXT - xIntraCodingTUBlock(tu, COMPONENT_Y, false, singleDistTmpLuma, 0, &numSig); -#else xIntraCodingTUBlock(tu, COMPONENT_Y, singleDistTmpLuma, 0, &numSig); -#endif if (singleDistTmpLuma == MAX_INT) // all zero CBF skip { earlySkipISP = true; @@ -4137,14 +3648,13 @@ bool IntraSearch::xRecurIntraCodingLumaQT( CodingStructure &cs, Partitioner &par bool earlySkipISP = false; uint32_t currDepth = partitioner.currTrDepth; const SPS &sps = *cs.sps; -#if !REMOVE_PPS_REXT - const PPS &pps = *cs.pps; - const bool keepResi = pps.getPpsRangeExtension().getCrossComponentPredictionEnabledFlag() || KEEP_PRED_AND_RESI_SIGNALS; -#endif bool bCheckFull = true; bool bCheckSplit = false; bCheckFull = !partitioner.canSplit( TU_MAX_TR_SPLIT, cs ); bCheckSplit = partitioner.canSplit( TU_MAX_TR_SPLIT, cs ); +#if JVET_R0110_MIXED_LOSSLESS + const Slice &slice = *cs.slice; +#endif if( cu.ispMode ) { @@ -4208,9 +3718,11 @@ bool IntraSearch::xRecurIntraCodingLumaQT( CodingStructure &cs, Partitioner &par else { nNumTransformCands = 1 + ( tsAllowed ? 1 : 0 ) + ( mtsAllowed ? 4 : 0 ); // DCT + TS + 4 MTS = 6 tests - -#if JVET_Q0820_ACT +#if JVET_R0110_MIXED_LOSSLESS + if (m_pcEncCfg->getCostMode() == COST_LOSSLESS_CODING && slice.isLossless()) +#else if (m_pcEncCfg->getCostMode() == COST_LOSSLESS_CODING) +#endif { nNumTransformCands = 1; CHECK(!tsAllowed && !cu.bdpcmMode, "transform skip should be enabled for LS"); @@ -4225,7 +3737,6 @@ bool IntraSearch::xRecurIntraCodingLumaQT( CodingStructure &cs, Partitioner &par } else { -#endif trModes.push_back( TrMode( 0, true ) ); //DCT2 if( tsAllowed ) { @@ -4238,9 +3749,7 @@ bool IntraSearch::xRecurIntraCodingLumaQT( CodingStructure &cs, Partitioner &par trModes.push_back( TrMode( i, true ) ); } } -#if JVET_Q0820_ACT } -#endif } CHECK( !tu.Y().valid(), "Invalid TU" ); @@ -4291,10 +3800,12 @@ bool IntraSearch::xRecurIntraCodingLumaQT( CodingStructure &cs, Partitioner &par } else { -#if JVET_AHG14_LOSSLESS - if( !( m_pcEncCfg->getCostMode() == COST_LOSSLESS_CODING ) ) - { +#if JVET_R0110_MIXED_LOSSLESS + if (!(m_pcEncCfg->getCostMode() == COST_LOSSLESS_CODING && slice.isLossless())) +#else + if( !( m_pcEncCfg->getCostMode() == COST_LOSSLESS_CODING) ) #endif + { if( !cbfDCT2 || ( m_pcEncCfg->getUseTransformSkipFast() && bestModeId[ COMPONENT_Y ] == MTS_SKIP)) { break; @@ -4308,9 +3819,7 @@ bool IntraSearch::xRecurIntraCodingLumaQT( CodingStructure &cs, Partitioner &par { continue; } -#if JVET_AHG14_LOSSLESS } -#endif tu.mtsIdx[COMPONENT_Y] = trModes[modeId].first; } @@ -4378,11 +3887,7 @@ bool IntraSearch::xRecurIntraCodingLumaQT( CodingStructure &cs, Partitioner &par if( !cu.mtsFlag && checkTransformSkip ) { -#if !REMOVE_PPS_REXT - xIntraCodingTUBlock( tu, COMPONENT_Y, false, singleDistTmpLuma, default0Save1Load2, &numSig, modeId == 0 ? &trModes : nullptr, true ); -#else xIntraCodingTUBlock( tu, COMPONENT_Y, singleDistTmpLuma, default0Save1Load2, &numSig, modeId == 0 ? &trModes : nullptr, true ); -#endif if( modeId == 0 ) { for( int i = 0; i < 2; i++ ) @@ -4396,22 +3901,14 @@ bool IntraSearch::xRecurIntraCodingLumaQT( CodingStructure &cs, Partitioner &par } else { -#if !REMOVE_PPS_REXT - xIntraCodingTUBlock( tu, COMPONENT_Y, false, singleDistTmpLuma, default0Save1Load2, &numSig ); -#else xIntraCodingTUBlock( tu, COMPONENT_Y, singleDistTmpLuma, default0Save1Load2, &numSig ); -#endif } } else { if( nNumTransformCands > 1 ) { -#if !REMOVE_PPS_REXT - xIntraCodingTUBlock( tu, COMPONENT_Y, false, singleDistTmpLuma, default0Save1Load2, &numSig, modeId == 0 ? &trModes : nullptr, true ); -#else xIntraCodingTUBlock( tu, COMPONENT_Y, singleDistTmpLuma, default0Save1Load2, &numSig, modeId == 0 ? &trModes : nullptr, true ); -#endif if( modeId == 0 ) { for( int i = 0; i < nNumTransformCands; i++ ) @@ -4425,32 +3922,26 @@ bool IntraSearch::xRecurIntraCodingLumaQT( CodingStructure &cs, Partitioner &par } else { -#if !REMOVE_PPS_REXT - xIntraCodingTUBlock( tu, COMPONENT_Y, false, singleDistTmpLuma, default0Save1Load2, &numSig ); -#else xIntraCodingTUBlock( tu, COMPONENT_Y, singleDistTmpLuma, default0Save1Load2, &numSig ); -#endif } } -#if JVET_Q0516_MTS_SIGNALLING_DC_ONLY_COND cuCtx.mtsLastScanPos = false; -#endif //----- determine rate and r-d cost ----- if( ( sps.getUseLFNST() ? ( modeId == lastCheckId && modeId != 0 && checkTransformSkip ) : ( trModes[ modeId ].first != 0 ) ) && !TU::getCbfAtDepth( tu, COMPONENT_Y, currDepth ) ) { //In order not to code TS flag when cbf is zero, the case for TS with cbf being zero is forbidden. -#if JVET_Q0820_ACT +#if JVET_R0110_MIXED_LOSSLESS + if (m_pcEncCfg->getCostMode() != COST_LOSSLESS_CODING || !slice.isLossless()) +#else if (m_pcEncCfg->getCostMode() != COST_LOSSLESS_CODING) -#endif +#endif singleCostTmp = MAX_DOUBLE; -#if JVET_Q0820_ACT else { singleTmpFracBits = xGetIntraFracBitsQT(*csFull, partitioner, true, false, subTuCounter, ispType, &cuCtx); singleCostTmp = m_pcRdCost->calcRdCost(singleTmpFracBits, singleDistTmpLuma); } -#endif } else { @@ -4462,7 +3953,6 @@ bool IntraSearch::xRecurIntraCodingLumaQT( CodingStructure &cs, Partitioner &par { singleTmpFracBits = xGetIntraFracBitsQT( *csFull, partitioner, true, false, subTuCounter, ispType, &cuCtx ); } -#if JVET_Q0516_MTS_SIGNALLING_DC_ONLY_COND if (tu.mtsIdx[COMPONENT_Y] > MTS_SKIP) { if (!cuCtx.mtsLastScanPos) @@ -4475,7 +3965,6 @@ bool IntraSearch::xRecurIntraCodingLumaQT( CodingStructure &cs, Partitioner &par } } else -#endif singleCostTmp = m_pcRdCost->calcRdCost( singleTmpFracBits, singleDistTmpLuma ); } @@ -4511,11 +4000,7 @@ bool IntraSearch::xRecurIntraCodingLumaQT( CodingStructure &cs, Partitioner &par saveCS.getPredBuf( tu.Y() ).copyFrom( csFull->getPredBuf( tu.Y() ) ); saveCS.getRecoBuf( tu.Y() ).copyFrom( csFull->getRecoBuf( tu.Y() ) ); -#if !REMOVE_PPS_REXT - if( keepResi ) -#else if( KEEP_PRED_AND_RESI_SIGNALS ) -#endif { saveCS.getResiBuf ( tu.Y() ).copyFrom( csFull->getResiBuf ( tu.Y() ) ); saveCS.getOrgResiBuf( tu.Y() ).copyFrom( csFull->getOrgResiBuf( tu.Y() ) ); @@ -4544,11 +4029,7 @@ bool IntraSearch::xRecurIntraCodingLumaQT( CodingStructure &cs, Partitioner &par csFull->getPredBuf( tu.Y() ).copyFrom( saveCS.getPredBuf( tu.Y() ) ); csFull->getRecoBuf( tu.Y() ).copyFrom( saveCS.getRecoBuf( tu.Y() ) ); -#if !REMOVE_PPS_REXT - if( keepResi ) -#else if( KEEP_PRED_AND_RESI_SIGNALS ) -#endif { csFull->getResiBuf ( tu.Y() ).copyFrom( saveCS.getResiBuf ( tu.Y() ) ); csFull->getOrgResiBuf( tu.Y() ).copyFrom( saveCS.getOrgResiBuf( tu.Y() ) ); @@ -4661,9 +4142,7 @@ bool IntraSearch::xRecurIntraCodingLumaQT( CodingStructure &cs, Partitioner &par cuCtx.violatesLfnstConstrained[CHANNEL_TYPE_CHROMA] = false; cuCtx.lfnstLastScanPos = false; cuCtx.violatesMtsCoeffConstraint = false; -#if JVET_Q0516_MTS_SIGNALLING_DC_ONLY_COND cuCtx.mtsLastScanPos = false; -#endif //----- determine rate and r-d cost ----- csSplit->fracBits = xGetIntraFracBitsQT( *csSplit, partitioner, true, false, cu.ispMode ? 0 : -1, ispType, &cuCtx ); @@ -4766,11 +4245,7 @@ bool IntraSearch::xRecurIntraCodingACTQT(CodingStructure &cs, Partitioner &parti } piResi.copyFrom(piOrg); -#if JVET_Q0346_LMCS_ENABLE_IN_SH if (slice.getLmcsEnabledFlag() && m_pcReshape->getCTUFlag() && compID == COMPONENT_Y) -#else - if (slice.getPicHeader()->getLmcsEnabledFlag() && m_pcReshape->getCTUFlag() && compID == COMPONENT_Y) -#endif { CompArea tmpArea(COMPONENT_Y, area.chromaFormat, Position(0, 0), area.size()); PelBuf tmpPred = m_tmpStorageLCU.getBuf(tmpArea); @@ -4782,13 +4257,9 @@ bool IntraSearch::xRecurIntraCodingACTQT(CodingStructure &cs, Partitioner &parti piResi.subtract(piPred); } -#if JVET_Q0820_ACT resiBuf.colorSpaceConvert(orgResiBuf, true, cs.slice->clpRng(COMPONENT_Y)); -#else - resiBuf.colorSpaceConvert(orgResiBuf, true); -#endif - // 2. luma residual optimization + // 2. luma residual optimization double dSingleCostLuma = MAX_DOUBLE; bool checkTransformSkip = sps.getTransformSkipEnabledFlag(); int bestLumaModeId = 0; @@ -4813,8 +4284,11 @@ bool IntraSearch::xRecurIntraCodingACTQT(CodingStructure &cs, Partitioner &parti } else { -#if JVET_Q0820_ACT +#if JVET_R0110_MIXED_LOSSLESS + if (m_pcEncCfg->getCostMode() == COST_LOSSLESS_CODING && slice.isLossless()) +#else if (m_pcEncCfg->getCostMode() == COST_LOSSLESS_CODING) +#endif { nNumTransformCands = 1; CHECK(!tsAllowed && !cu.bdpcmMode, "transform skip should be enabled for LS"); @@ -4829,7 +4303,6 @@ bool IntraSearch::xRecurIntraCodingACTQT(CodingStructure &cs, Partitioner &parti } else { -#endif nNumTransformCands = 1 + (tsAllowed ? 1 : 0) + (mtsAllowed ? 4 : 0); // DCT + TS + 4 MTS = 6 tests trModes.push_back(TrMode(0, true)); //DCT2 @@ -4844,9 +4317,7 @@ bool IntraSearch::xRecurIntraCodingACTQT(CodingStructure &cs, Partitioner &parti trModes.push_back(TrMode(i, true)); } } -#if JVET_Q0820_ACT } -#endif } CodingStructure &saveLumaCS = *m_pSaveCS[0]; @@ -4870,16 +4341,16 @@ bool IntraSearch::xRecurIntraCodingACTQT(CodingStructure &cs, Partitioner &parti bool cbfBestMode = false; bool cbfBestModeValid = false; bool cbfDCT2 = true; - -#if JVET_Q0820_ACT +#if JVET_R0110_MIXED_LOSSLESS + if (m_pcEncCfg->getCostMode() != COST_LOSSLESS_CODING || !slice.isLossless()) +#else if (m_pcEncCfg->getCostMode() != COST_LOSSLESS_CODING) #endif m_pcRdCost->lambdaAdjustColorTrans(true, COMPONENT_Y); - -#if JVET_Q0820_ACT - for (int modeId = firstCheckId; modeId <= ((m_pcEncCfg->getCostMode() == COST_LOSSLESS_CODING) ? (nNumTransformCands - 1) : lastCheckId); modeId++) +#if JVET_R0110_MIXED_LOSSLESS + for (int modeId = firstCheckId; modeId <= ((m_pcEncCfg->getCostMode() == COST_LOSSLESS_CODING && slice.isLossless()) ? (nNumTransformCands - 1) : lastCheckId); modeId++) #else - for (int modeId = firstCheckId; modeId <= lastCheckId; modeId++) + for (int modeId = firstCheckId; modeId <= ((m_pcEncCfg->getCostMode() == COST_LOSSLESS_CODING) ? (nNumTransformCands - 1) : lastCheckId); modeId++) #endif { uint8_t transformIndex = modeId; @@ -4901,10 +4372,12 @@ bool IntraSearch::xRecurIntraCodingACTQT(CodingStructure &cs, Partitioner &parti } else { -#if JVET_AHG14_LOSSLESS +#if JVET_R0110_MIXED_LOSSLESS + if (!(m_pcEncCfg->getCostMode() == COST_LOSSLESS_CODING && slice.isLossless())) +#else if (!(m_pcEncCfg->getCostMode() == COST_LOSSLESS_CODING)) - { #endif + { if (!cbfDCT2 || (m_pcEncCfg->getUseTransformSkipFast() && bestLumaModeId == 1)) { break; @@ -4913,9 +4386,7 @@ bool IntraSearch::xRecurIntraCodingACTQT(CodingStructure &cs, Partitioner &parti { continue; } -#if JVET_AHG14_LOSSLESS } -#endif tu.mtsIdx[COMPONENT_Y] = trModes[modeId].first; } @@ -4992,32 +4463,29 @@ bool IntraSearch::xRecurIntraCodingACTQT(CodingStructure &cs, Partitioner &parti } } -#if JVET_Q0516_MTS_SIGNALLING_DC_ONLY_COND CUCtx cuCtx; cuCtx.isDQPCoded = true; cuCtx.isChromaQpAdjCoded = true; -#endif //----- determine rate and r-d cost ----- if ((sps.getUseLFNST() ? (modeId == lastCheckId && modeId != 0 && checkTransformSkip) : (trModes[modeId].first != 0)) && !TU::getCbfAtDepth(tu, COMPONENT_Y, currDepth)) { //In order not to code TS flag when cbf is zero, the case for TS with cbf being zero is forbidden. -#if JVET_Q0820_ACT +#if JVET_R0110_MIXED_LOSSLESS + if (m_pcEncCfg->getCostMode() != COST_LOSSLESS_CODING || !slice.isLossless()) +#else if (m_pcEncCfg->getCostMode() != COST_LOSSLESS_CODING) #endif singleCostTmp = MAX_DOUBLE; -#if JVET_Q0820_ACT else { singleTmpFracBits = xGetIntraFracBitsQT(*csFull, partitioner, true, false, -1, TU_NO_ISP); singleCostTmp = m_pcRdCost->calcRdCost(singleTmpFracBits, singleDistTmpLuma, false); } -#endif } else { -#if JVET_Q0516_MTS_SIGNALLING_DC_ONLY_COND singleTmpFracBits = xGetIntraFracBitsQT(*csFull, partitioner, true, false, -1, TU_NO_ISP, &cuCtx); - + if (tu.mtsIdx[COMPONENT_Y] > MTS_SKIP) { if (!cuCtx.mtsLastScanPos) @@ -5026,22 +4494,11 @@ bool IntraSearch::xRecurIntraCodingACTQT(CodingStructure &cs, Partitioner &parti } else { -#if JVET_Q0820_ACT singleCostTmp = m_pcRdCost->calcRdCost(singleTmpFracBits, singleDistTmpLuma, false); -#else - singleCostTmp = m_pcRdCost->calcRdCost(singleTmpFracBits, singleDistTmpLuma); -#endif } } else -#else - singleTmpFracBits = xGetIntraFracBitsQT(*csFull, partitioner, true, false, -1, TU_NO_ISP); -#endif -#if JVET_Q0820_ACT singleCostTmp = m_pcRdCost->calcRdCost(singleTmpFracBits, singleDistTmpLuma, false); -#else - singleCostTmp = m_pcRdCost->calcRdCost(singleTmpFracBits, singleDistTmpLuma); -#endif } if (singleCostTmp < dSingleCostLuma) @@ -5072,8 +4529,9 @@ bool IntraSearch::xRecurIntraCodingACTQT(CodingStructure &cs, Partitioner &parti } } } - -#if JVET_Q0820_ACT +#if JVET_R0110_MIXED_LOSSLESS + if (m_pcEncCfg->getCostMode() != COST_LOSSLESS_CODING || !slice.isLossless()) +#else if (m_pcEncCfg->getCostMode() != COST_LOSSLESS_CODING) #endif m_pcRdCost->lambdaAdjustColorTrans(false, COMPONENT_Y); @@ -5112,17 +4570,9 @@ bool IntraSearch::xRecurIntraCodingACTQT(CodingStructure &cs, Partitioner &parti CompArea& cbArea = tu.blocks[COMPONENT_Cb]; CompArea& crArea = tu.blocks[COMPONENT_Cr]; -#if !JVET_Q0820_ACT - ctxStart = m_CABACEstimator->getCtx(); - m_CABACEstimator->resetBits(); -#endif tu.jointCbCr = 0; -#if JVET_Q0346_LMCS_ENABLE_IN_SH bool doReshaping = (slice.getLmcsEnabledFlag() && slice.getPicHeader()->getLmcsChromaResidualScaleFlag() && (slice.isIntra() || m_pcReshape->getCTUFlag()) && (cbArea.width * cbArea.height > 4)); -#else - bool doReshaping = (slice.getPicHeader()->getLmcsEnabledFlag() && slice.getPicHeader()->getLmcsChromaResidualScaleFlag() && (slice.isIntra() || m_pcReshape->getCTUFlag()) && (cbArea.width * cbArea.height > 4)); -#endif if (doReshaping) { const Area area = tu.Y().valid() ? tu.Y() : Area(recalcPosition(tu.chromaFormat, tu.chType, CHANNEL_TYPE_LUMA, tu.blocks[tu.chType].pos()), recalcSize(tu.chromaFormat, tu.chType, CHANNEL_TYPE_LUMA, tu.blocks[tu.chType].size())); @@ -5150,20 +4600,18 @@ bool IntraSearch::xRecurIntraCodingACTQT(CodingStructure &cs, Partitioner &parti for (uint32_t c = COMPONENT_Cb; c < ::getNumberValidTBlocks(*csFull->pcv); c++) { const ComponentID compID = ComponentID(c); -#if JVET_Q0820_ACT double dSingleBestCostChroma = MAX_DOUBLE; int bestModeId = -1; -#if JVET_Q0784_LFNST_COMBINATION bool tsAllowed = TU::isTSAllowed(tu, compID) && (m_pcEncCfg->getUseChromaTS()) && !cu.lfnstIdx; -#else - bool tsAllowed = TU::isTSAllowed(tu, compID) && (m_pcEncCfg->getUseChromaTS()); -#endif uint8_t numTransformCands = 1 + (tsAllowed ? 1 : 0); // DCT + TS = 2 tests bool cbfDCT2 = true; trModes.clear(); - +#if JVET_R0110_MIXED_LOSSLESS + if (m_pcEncCfg->getCostMode() == COST_LOSSLESS_CODING && slice.isLossless()) +#else if (m_pcEncCfg->getCostMode() == COST_LOSSLESS_CODING) +#endif { numTransformCands = 1; CHECK(!tsAllowed && !cu.bdpcmModeChroma, "transform skip should be enabled for LS"); @@ -5184,8 +4632,11 @@ bool IntraSearch::xRecurIntraCodingACTQT(CodingStructure &cs, Partitioner &parti trModes.push_back(TrMode(1, true)); // TS } } - +#if JVET_R0110_MIXED_LOSSLESS + if (m_pcEncCfg->getCostMode() != COST_LOSSLESS_CODING || !slice.isLossless()) +#else if (m_pcEncCfg->getCostMode() != COST_LOSSLESS_CODING) +#endif m_pcRdCost->lambdaAdjustColorTrans(true, compID); TempCtx ctxBegin(m_CtxCache); @@ -5193,7 +4644,11 @@ bool IntraSearch::xRecurIntraCodingACTQT(CodingStructure &cs, Partitioner &parti for (int modeId = 0; modeId < numTransformCands; modeId++) { +#if JVET_R0110_MIXED_LOSSLESS + if (m_pcEncCfg->getCostMode() != COST_LOSSLESS_CODING || !slice.isLossless()) +#else if (m_pcEncCfg->getCostMode() != COST_LOSSLESS_CODING) +#endif { if (modeId && !cbfDCT2) { @@ -5211,17 +4666,13 @@ bool IntraSearch::xRecurIntraCodingACTQT(CodingStructure &cs, Partitioner &parti } tu.mtsIdx[compID] = trModes[modeId].first; -#endif Distortion singleDistChroma = 0; -#if JVET_Q0820_ACT if (numTransformCands > 1) { xIntraCodingACTTUBlock(tu, compID, singleDistChroma, modeId == 0 ? &trModes : nullptr, true); } else -#endif xIntraCodingACTTUBlock(tu, compID, singleDistChroma); -#if JVET_Q0820_ACT if (!tu.mtsIdx[compID]) { cbfDCT2 = TU::getCbfAtDepth(tu, compID, currDepth); @@ -5247,23 +4698,19 @@ bool IntraSearch::xRecurIntraCodingACTQT(CodingStructure &cs, Partitioner &parti tu.copyComponentFrom(*tmpTU, compID); m_CABACEstimator->getCtx() = ctxBest; } - - if (m_pcEncCfg->getCostMode() != COST_LOSSLESS_CODING) - m_pcRdCost->lambdaAdjustColorTrans(false, compID); +#if JVET_R0110_MIXED_LOSSLESS + if (m_pcEncCfg->getCostMode() != COST_LOSSLESS_CODING || !slice.isLossless()) #else - xGetIntraFracBitsQTChroma(tu, compID); + if (m_pcEncCfg->getCostMode() != COST_LOSSLESS_CODING) #endif + m_pcRdCost->lambdaAdjustColorTrans(false, compID); } Position tuPos = tu.Y(); tuPos.relativeTo(cu.Y()); const UnitArea relativeUnitArea(tu.chromaFormat, Area(tuPos, tu.Y().size())); PelUnitBuf invColorTransResidual = m_colorTransResiBuf.getBuf(relativeUnitArea); -#if JVET_Q0820_ACT csFull->getResiBuf(tu).colorSpaceConvert(invColorTransResidual, false, cs.slice->clpRng(COMPONENT_Y)); -#else - csFull->getResiBuf(tu).colorSpaceConvert(invColorTransResidual, false); -#endif Distortion totalDist = 0; for (uint32_t c = COMPONENT_Y; c < ::getNumberValidTBlocks(*csFull->pcv); c++) @@ -5277,13 +4724,8 @@ bool IntraSearch::xRecurIntraCodingACTQT(CodingStructure &cs, Partitioner &parti piReco.reconstruct(piPred, piResi, cs.slice->clpRng(compID)); -#if JVET_Q0346_LMCS_ENABLE_IN_SH if (m_pcEncCfg->getLumaLevelToDeltaQPMapping().isEnabled() || (m_pcEncCfg->getLmcs() & slice.getLmcsEnabledFlag() && (m_pcReshape->getCTUFlag() || (isChroma(compID) && m_pcEncCfg->getReshapeIntraCMD())))) -#else - if (m_pcEncCfg->getLumaLevelToDeltaQPMapping().isEnabled() || (m_pcEncCfg->getLmcs() - & slice.getPicHeader()->getLmcsEnabledFlag() && (m_pcReshape->getCTUFlag() || (isChroma(compID) && m_pcEncCfg->getReshapeIntraCMD())))) -#endif { const CPelBuf orgLuma = csFull->getOrgBuf(csFull->area.blocks[COMPONENT_Y]); if (compID == COMPONENT_Y && !(m_pcEncCfg->getLumaLevelToDeltaQPMapping().isEnabled())) @@ -5331,27 +4773,16 @@ bool IntraSearch::xRecurIntraCodingACTQT(CodingStructure &cs, Partitioner &parti for (int cbfMask : jointCbfMasksToTest) { -#if !JVET_Q0512_ENC_CHROMA_TS_ACT - m_CABACEstimator->getCtx() = ctxStart; - m_CABACEstimator->resetBits(); - - Distortion distTmp = 0; -#endif tu.jointCbCr = (uint8_t)cbfMask; -#if JVET_Q0512_ENC_CHROMA_TS_ACT ComponentID codeCompId = ((cbfMask >> 1) ? COMPONENT_Cb : COMPONENT_Cr); ComponentID otherCompId = ((codeCompId == COMPONENT_Cb) ? COMPONENT_Cr : COMPONENT_Cb); -#if JVET_Q0784_LFNST_COMBINATION bool tsAllowed = TU::isTSAllowed(tu, codeCompId) && (m_pcEncCfg->getUseChromaTS()) && !cu.lfnstIdx; -#else - bool tsAllowed = TU::isTSAllowed(tu, codeCompId) && (m_pcEncCfg->getUseChromaTS()); -#endif uint8_t numTransformCands = 1 + (tsAllowed ? 1 : 0); // DCT + TS = 2 tests bool cbfDCT2 = true; trModes.clear(); - trModes.push_back(TrMode(0, true)); // DCT2 + trModes.push_back(TrMode(0, true)); // DCT2 if (tsAllowed) { trModes.push_back(TrMode(1, true));//TS @@ -5371,33 +4802,24 @@ bool IntraSearch::xRecurIntraCodingACTQT(CodingStructure &cs, Partitioner &parti tu.mtsIdx[codeCompId] = trModes[modeId].first; tu.mtsIdx[otherCompId] = MTS_DCT2_DCT2; m_CABACEstimator->getCtx() = ctxStart; -#endif csFull->getResiBuf(cbArea).copyFrom(orgResiCb[cbfMask]); csFull->getResiBuf(crArea).copyFrom(orgResiCr[cbfMask]); -#if JVET_Q0512_ENC_CHROMA_TS_ACT if (nNumTransformCands > 1) { xIntraCodingACTTUBlock(tu, COMPONENT_Cb, distTmp, modeId == 0 ? &trModes : nullptr, true); } else -#endif xIntraCodingACTTUBlock(tu, COMPONENT_Cb, distTmp); double costTmp = std::numeric_limits<double>::max(); uint64_t bitsTmp = 0; if (distTmp < std::numeric_limits<Distortion>::max()) { -#if JVET_Q0512_ENC_CHROMA_TS_ACT if (!tu.mtsIdx[codeCompId]) { cbfDCT2 = true; } -#endif -#if JVET_Q0820_ACT csFull->getResiBuf(tu).colorSpaceConvert(invColorTransResidual, false, csFull->slice->clpRng(COMPONENT_Y)); -#else - csFull->getResiBuf(tu).colorSpaceConvert(invColorTransResidual, false); -#endif distTmp = 0; for (uint32_t c = COMPONENT_Y; c < ::getNumberValidTBlocks(*csFull->pcv); c++) { @@ -5409,13 +4831,8 @@ bool IntraSearch::xRecurIntraCodingACTQT(CodingStructure &cs, Partitioner &parti PelBuf piResi = invColorTransResidual.bufs[compID]; piReco.reconstruct(piPred, piResi, cs.slice->clpRng(compID)); -#if JVET_Q0346_LMCS_ENABLE_IN_SH if (m_pcEncCfg->getLumaLevelToDeltaQPMapping().isEnabled() || (m_pcEncCfg->getLmcs() & slice.getLmcsEnabledFlag() && (m_pcReshape->getCTUFlag() || (isChroma(compID) && m_pcEncCfg->getReshapeIntraCMD())))) -#else - if (m_pcEncCfg->getLumaLevelToDeltaQPMapping().isEnabled() || (m_pcEncCfg->getLmcs() - & slice.getPicHeader()->getLmcsEnabledFlag() && (m_pcReshape->getCTUFlag() || (isChroma(compID) && m_pcEncCfg->getReshapeIntraCMD())))) -#endif { const CPelBuf orgLuma = csFull->getOrgBuf(csFull->area.blocks[COMPONENT_Y]); if (compID == COMPONENT_Y && !(m_pcEncCfg->getLumaLevelToDeltaQPMapping().isEnabled())) @@ -5440,12 +4857,10 @@ bool IntraSearch::xRecurIntraCodingACTQT(CodingStructure &cs, Partitioner &parti bitsTmp = xGetIntraFracBitsQT(*csFull, partitioner, true, true, -1, TU_NO_ISP); costTmp = m_pcRdCost->calcRdCost(bitsTmp, distTmp); } -#if JVET_Q0512_ENC_CHROMA_TS_ACT else if (!tu.mtsIdx[codeCompId]) { cbfDCT2 = false; } -#endif if (costTmp < bestCostJointCbCr) { @@ -5453,11 +4868,7 @@ bool IntraSearch::xRecurIntraCodingACTQT(CodingStructure &cs, Partitioner &parti bestDistJointCbCr = distTmp; bestBitsJointCbCr = bitsTmp; bestJointCbCr = tu.jointCbCr; -#if JVET_Q0512_ENC_CHROMA_TS_ACT lastIsBest = (cbfMask == jointCbfMasksToTest.back() && modeId == (numTransformCands - 1)); -#else - lastIsBest = (cbfMask == jointCbfMasksToTest.back()); -#endif // store data if (!lastIsBest) @@ -5471,9 +4882,7 @@ bool IntraSearch::xRecurIntraCodingACTQT(CodingStructure &cs, Partitioner &parti ctxBest = m_CABACEstimator->getCtx(); } } -#if JVET_Q0512_ENC_CHROMA_TS_ACT } -#endif } if (!lastIsBest) @@ -5572,16 +4981,15 @@ ChromaCbfs IntraSearch::xRecurIntraChromaCodingQT( CodingStructure &cs, Partitio UnitArea currArea = partitioner.currArea(); const bool keepResi = cs.sps->getUseLMChroma() || KEEP_PRED_AND_RESI_SIGNALS; if( !currArea.Cb().valid() ) return ChromaCbfs( false ); - +#if JVET_R0110_MIXED_LOSSLESS + const Slice &slice = *cs.slice; +#endif TransformUnit &currTU = *cs.getTU( currArea.chromaPos(), CHANNEL_TYPE_CHROMA ); const PredictionUnit &pu = *cs.getPU( currArea.chromaPos(), CHANNEL_TYPE_CHROMA ); bool lumaUsesISP = false; uint32_t currDepth = partitioner.currTrDepth; -#if !REMOVE_PPS_REXT - const PPS &pps = *cs.pps; -#endif ChromaCbfs cbfs ( false ); if (currDepth == currTU.depth) @@ -5646,6 +5054,16 @@ ChromaCbfs IntraSearch::xRecurIntraChromaCodingQT( CodingStructure &cs, Partitio predIntraChromaLM( COMPONENT_Cb, piPredCb, pu, cbArea, predMode ); predIntraChromaLM( COMPONENT_Cr, piPredCr, pu, crArea, predMode ); } +#if JVET_R0350_MIP_CHROMA_444_SINGLETREE + else if (PU::isMIP(pu, CHANNEL_TYPE_CHROMA)) + { + initIntraMip(pu, cbArea); + predIntraMip(COMPONENT_Cb, piPredCb, pu); + + initIntraMip(pu, crArea); + predIntraMip(COMPONENT_Cr, piPredCr, pu); + } +#endif else { predIntraAng( COMPONENT_Cb, piPredCb, pu); @@ -5662,13 +5080,8 @@ ChromaCbfs IntraSearch::xRecurIntraChromaCodingQT( CodingStructure &cs, Partitio resiCr.subtract( piPredCr ); //----- get reshape parameter ---- -#if JVET_Q0346_LMCS_ENABLE_IN_SH bool doReshaping = ( cs.slice->getLmcsEnabledFlag() && cs.picHeader->getLmcsChromaResidualScaleFlag() && (cs.slice->isIntra() || m_pcReshape->getCTUFlag()) && (cbArea.width * cbArea.height > 4) ); -#else - bool doReshaping = ( cs.picHeader->getLmcsEnabledFlag() && cs.picHeader->getLmcsChromaResidualScaleFlag() - && (cs.slice->isIntra() || m_pcReshape->getCTUFlag()) && (cbArea.width * cbArea.height > 4) ); -#endif if( doReshaping ) { const Area area = currTU.Y().valid() ? currTU.Y() : Area(recalcPosition(currTU.chromaFormat, currTU.chType, CHANNEL_TYPE_LUMA, currTU.blocks[currTU.chType].pos()), recalcSize(currTU.chromaFormat, currTU.chType, CHANNEL_TYPE_LUMA, currTU.blocks[currTU.chType].size())); @@ -5678,40 +5091,6 @@ ChromaCbfs IntraSearch::xRecurIntraChromaCodingQT( CodingStructure &cs, Partitio } //----- get cross component prediction parameters ----- -#if !REMOVE_PPS_REXT - bool checkCrossComponentPrediction = PU::isChromaIntraModeCrossCheckMode( pu ) && pps.getPpsRangeExtension().getCrossComponentPredictionEnabledFlag() && TU::getCbf( currTU, COMPONENT_Y ); - int compAlpha[MAX_NUM_COMPONENT] = { 0, 0, 0 }; - if( checkCrossComponentPrediction ) - { - compAlpha[COMPONENT_Cb] = xCalcCrossComponentPredictionAlpha( currTU, COMPONENT_Cb, m_pcEncCfg->getUseReconBasedCrossCPredictionEstimate() ); - compAlpha[COMPONENT_Cr] = xCalcCrossComponentPredictionAlpha( currTU, COMPONENT_Cr, m_pcEncCfg->getUseReconBasedCrossCPredictionEstimate() ); - if( compAlpha[COMPONENT_Cb] == 0 && compAlpha[COMPONENT_Cr] == 0 ) - { - checkCrossComponentPrediction = false; - } - } - //===== store original residual signals (std and crossCompPred) ===== - CompStorage orgResiCb[5], orgResiCr[5]; // 0:std, 1-3:jointCbCr (placeholder at this stage), 4:crossComp - for( int k = 0; k < (checkCrossComponentPrediction?5:1); k+=4 ) - { - orgResiCb[k].create( cbArea ); - orgResiCr[k].create( crArea ); - if( k >= 4 ) { - CrossComponentPrediction::crossComponentPrediction( currTU, COMPONENT_Cb, cs.getResiBuf(currTU.Y()), resiCb, orgResiCb[k], false); - CrossComponentPrediction::crossComponentPrediction( currTU, COMPONENT_Cr, cs.getResiBuf(currTU.Y()), resiCr, orgResiCr[k], false); - } else - { - orgResiCb[k].copyFrom( resiCb ); - orgResiCr[k].copyFrom( resiCr ); - } - if( doReshaping ) - { - int cResScaleInv = currTU.getChromaAdj(); - orgResiCb[k].scaleSignal( cResScaleInv, 1, currTU.cu->cs->slice->clpRng(COMPONENT_Cb) ); - orgResiCr[k].scaleSignal( cResScaleInv, 1, currTU.cu->cs->slice->clpRng(COMPONENT_Cr) ); - } - } -#else //===== store original residual signals ===== CompStorage orgResiCb[4], orgResiCr[4]; // 0:std, 1-3:jointCbCr (placeholder at this stage) orgResiCb[0].create( cbArea ); @@ -5724,7 +5103,6 @@ ChromaCbfs IntraSearch::xRecurIntraChromaCodingQT( CodingStructure &cs, Partitio orgResiCb[0].scaleSignal( cResScaleInv, 1, currTU.cu->cs->slice->clpRng(COMPONENT_Cb) ); orgResiCr[0].scaleSignal( cResScaleInv, 1, currTU.cu->cs->slice->clpRng(COMPONENT_Cr) ); } -#endif for( uint32_t c = COMPONENT_Cb; c < numTBlocks; c++) { @@ -5735,18 +5113,14 @@ ChromaCbfs IntraSearch::xRecurIntraChromaCodingQT( CodingStructure &cs, Partitio int bestModeId = 0; Distortion singleDistCTmp = 0; double singleCostTmp = 0; -#if !REMOVE_PPS_REXT - const int crossCPredictionModesToTest = checkCrossComponentPrediction ? 2 : 1; -#endif -#if JVET_Q0784_LFNST_COMBINATION const bool tsAllowed = TU::isTSAllowed(currTU, compID) && m_pcEncCfg->getUseChromaTS() && !currTU.cu->lfnstIdx; -#else - const bool tsAllowed = TU::isTSAllowed(currTU, compID) && (m_pcEncCfg->getUseChromaTS()); -#endif uint8_t nNumTransformCands = 1 + (tsAllowed ? 1 : 0); // DCT + TS = 2 tests std::vector<TrMode> trModes; -#if JVET_Q0820_ACT +#if JVET_R0110_MIXED_LOSSLESS + if (m_pcEncCfg->getCostMode() == COST_LOSSLESS_CODING && slice.isLossless()) +#else if (m_pcEncCfg->getCostMode() == COST_LOSSLESS_CODING) +#endif { nNumTransformCands = 1; CHECK(!tsAllowed && !currTU.cu->bdpcmModeChroma, "transform skip should be enabled for LS"); @@ -5761,24 +5135,17 @@ ChromaCbfs IntraSearch::xRecurIntraChromaCodingQT( CodingStructure &cs, Partitio } else { -#endif trModes.push_back(TrMode(0, true)); // DCT2 if (tsAllowed) { trModes.push_back(TrMode(1, true));//TS } -#if JVET_Q0820_ACT } -#endif CHECK(!currTU.Cb().valid(), "Invalid TU"); - -#if !REMOVE_PPS_REXT - const int totalModesToTest = crossCPredictionModesToTest * nNumTransformCands; -#else + const int totalModesToTest = nNumTransformCands; -#endif bool cbfDCT2 = true; const bool isOneMode = false; maxModesTested = totalModesToTest > maxModesTested ? totalModesToTest : maxModesTested; @@ -5794,28 +5161,20 @@ ChromaCbfs IntraSearch::xRecurIntraChromaCodingQT( CodingStructure &cs, Partitio for (int modeId = 0; modeId < nNumTransformCands; modeId++) { -#if !REMOVE_PPS_REXT - for (int crossCPredictionModeId = 0; crossCPredictionModeId < crossCPredictionModesToTest; crossCPredictionModeId++) - { - resiCb.copyFrom( orgResiCb[4*crossCPredictionModeId] ); - resiCr.copyFrom( orgResiCr[4*crossCPredictionModeId] ); - - currTU.compAlpha [compID] = ( crossCPredictionModeId ? compAlpha[compID] : 0 ); -#else resiCb.copyFrom( orgResiCb[0] ); resiCr.copyFrom( orgResiCr[0] ); -#endif currTU.mtsIdx[compID] = currTU.cu->bdpcmModeChroma ? MTS_SKIP : trModes[modeId].first; currModeId++; const bool isFirstMode = (currModeId == 1); const bool isLastMode = false; // Always store output to saveCS and tmpTU - -#if JVET_AHG14_LOSSLESS - if( !( m_pcEncCfg->getCostMode() == COST_LOSSLESS_CODING ) ) - { +#if JVET_R0110_MIXED_LOSSLESS + if (!(m_pcEncCfg->getCostMode() == COST_LOSSLESS_CODING && slice.isLossless())) +#else + if( !( m_pcEncCfg->getCostMode() == COST_LOSSLESS_CODING) ) #endif + { //if DCT2's cbf==0, skip ts search if (!cbfDCT2 && trModes[modeId].first == MTS_SKIP) { @@ -5825,9 +5184,7 @@ ChromaCbfs IntraSearch::xRecurIntraChromaCodingQT( CodingStructure &cs, Partitio { continue; } -#if JVET_AHG14_LOSSLESS } -#endif if (!isFirstMode) // if not first mode to be tested { @@ -5838,38 +5195,26 @@ ChromaCbfs IntraSearch::xRecurIntraChromaCodingQT( CodingStructure &cs, Partitio if (nNumTransformCands > 1) { -#if !REMOVE_PPS_REXT - xIntraCodingTUBlock(currTU, compID, crossCPredictionModeId != 0, singleDistCTmp, default0Save1Load2, nullptr, modeId == 0 ? &trModes : nullptr, true); -#else xIntraCodingTUBlock(currTU, compID, singleDistCTmp, default0Save1Load2, nullptr, modeId == 0 ? &trModes : nullptr, true); -#endif } else { -#if !REMOVE_PPS_REXT - xIntraCodingTUBlock(currTU, compID, crossCPredictionModeId != 0, singleDistCTmp, default0Save1Load2); -#else xIntraCodingTUBlock(currTU, compID, singleDistCTmp, default0Save1Load2); -#endif } -#if !REMOVE_PPS_REXT - if (((crossCPredictionModeId == 1) && (currTU.compAlpha[compID] == 0)) || ((currTU.mtsIdx[compID] == MTS_SKIP && !currTU.cu->bdpcmModeChroma) && !TU::getCbf(currTU, compID))) //In order not to code TS flag when cbf is zero, the case for TS with cbf being zero is forbidden. -#else if (((currTU.mtsIdx[compID] == MTS_SKIP && !currTU.cu->bdpcmModeChroma) && !TU::getCbf(currTU, compID))) //In order not to code TS flag when cbf is zero, the case for TS with cbf being zero is forbidden. -#endif { -#if JVET_Q0820_ACT +#if JVET_R0110_MIXED_LOSSLESS + if (m_pcEncCfg->getCostMode() != COST_LOSSLESS_CODING || !slice.isLossless()) +#else if (m_pcEncCfg->getCostMode() != COST_LOSSLESS_CODING) -#endif +#endif singleCostTmp = MAX_DOUBLE; -#if JVET_Q0820_ACT else { uint64_t fracBitsTmp = xGetIntraFracBitsQTChroma(currTU, compID); singleCostTmp = m_pcRdCost->calcRdCost(fracBitsTmp, singleDistCTmp); } -#endif } else if( lumaUsesISP && bestCostSoFar != MAX_DOUBLE && c == COMPONENT_Cb ) { @@ -5925,9 +5270,6 @@ ChromaCbfs IntraSearch::xRecurIntraChromaCodingQT( CodingStructure &cs, Partitio ctxBest = m_CABACEstimator->getCtx(); } } -#if !REMOVE_PPS_REXT - } -#endif } if( lumaUsesISP && dSingleCost > bestCostSoFar && c == COMPONENT_Cb ) @@ -5941,10 +5283,10 @@ ChromaCbfs IntraSearch::xRecurIntraChromaCodingQT( CodingStructure &cs, Partitio } // Done with one component of separate coding of Cr and Cb, just switch to the best Cb contexts if Cr coding is still to be done -#if JVET_Q0820_ACT - if ((c == COMPONENT_Cb && bestModeId < totalModesToTest) || (c == COMPONENT_Cb && m_pcEncCfg->getCostMode() == COST_LOSSLESS_CODING)) +#if JVET_R0110_MIXED_LOSSLESS + if ((c == COMPONENT_Cb && bestModeId < totalModesToTest) || (c == COMPONENT_Cb && m_pcEncCfg->getCostMode() == COST_LOSSLESS_CODING && slice.isLossless())) #else - if ( c == COMPONENT_Cb && bestModeId < totalModesToTest) + if ((c == COMPONENT_Cb && bestModeId < totalModesToTest) || (c == COMPONENT_Cb && m_pcEncCfg->getCostMode() == COST_LOSSLESS_CODING)) #endif { m_CABACEstimator->getCtx() = ctxBest; @@ -5959,15 +5301,11 @@ ChromaCbfs IntraSearch::xRecurIntraChromaCodingQT( CodingStructure &cs, Partitio double bestCostCbCr = bestCostCb + bestCostCr; Distortion bestDistCbCr = bestDistCb + bestDistCr; int bestJointCbCr = 0; -#if !JVET_Q0695_CHROMA_TS_JCCR - bool lastIsBest = false; -#endif std::vector<int> jointCbfMasksToTest; if ( cs.sps->getJointCbCrEnabledFlag() && (TU::getCbf(tmpTU, COMPONENT_Cb) || TU::getCbf(tmpTU, COMPONENT_Cr))) { jointCbfMasksToTest = m_pcTrQuant->selectICTCandidates(currTU, orgResiCb, orgResiCr); } -#if JVET_Q0695_CHROMA_TS_JCCR bool checkDCTOnly = (TU::getCbf(tmpTU, COMPONENT_Cb) && tmpTU.mtsIdx[COMPONENT_Cb] == MTS_DCT2_DCT2 && !TU::getCbf(tmpTU, COMPONENT_Cr)) || (TU::getCbf(tmpTU, COMPONENT_Cr) && tmpTU.mtsIdx[COMPONENT_Cr] == MTS_DCT2_DCT2 && !TU::getCbf(tmpTU, COMPONENT_Cb)) || (TU::getCbf(tmpTU, COMPONENT_Cb) && tmpTU.mtsIdx[COMPONENT_Cb] == MTS_DCT2_DCT2 && TU::getCbf(tmpTU, COMPONENT_Cr) && tmpTU.mtsIdx[COMPONENT_Cr] == MTS_DCT2_DCT2); @@ -5980,26 +5318,13 @@ ChromaCbfs IntraSearch::xRecurIntraChromaCodingQT( CodingStructure &cs, Partitio { CHECK(!checkTSOnly || checkDCTOnly, "bdpcm only allows transform skip"); } -#endif for( int cbfMask : jointCbfMasksToTest ) { -#if !JVET_Q0695_CHROMA_TS_JCCR - Distortion distTmp = 0; -#endif currTU.jointCbCr = (uint8_t)cbfMask; -#if !REMOVE_PPS_REXT - currTU.compAlpha[COMPONENT_Cb] = 0; - currTU.compAlpha[COMPONENT_Cr] = 0; -#endif -#if JVET_Q0695_CHROMA_TS_JCCR ComponentID codeCompId = ((currTU.jointCbCr >> 1) ? COMPONENT_Cb : COMPONENT_Cr); ComponentID otherCompId = ((codeCompId == COMPONENT_Cb) ? COMPONENT_Cr : COMPONENT_Cb); -#if JVET_Q0784_LFNST_COMBINATION bool tsAllowed = TU::isTSAllowed(currTU, codeCompId) && (m_pcEncCfg->getUseChromaTS()) && !currTU.cu->lfnstIdx; -#else - bool tsAllowed = TU::isTSAllowed(currTU, codeCompId) && (m_pcEncCfg->getUseChromaTS()); -#endif uint8_t numTransformCands = 1 + (tsAllowed ? 1 : 0); // DCT + TS = 2 tests bool cbfDCT2 = true; @@ -6011,7 +5336,7 @@ ChromaCbfs IntraSearch::xRecurIntraChromaCodingQT( CodingStructure &cs, Partitio if (!checkTSOnly || currTU.cu->bdpcmModeChroma) { - trModes.push_back(TrMode(0, true)); // DCT2 + trModes.push_back(TrMode(0, true)); // DCT2 } if (tsAllowed && !checkDCTOnly) { @@ -6030,48 +5355,30 @@ ChromaCbfs IntraSearch::xRecurIntraChromaCodingQT( CodingStructure &cs, Partitio Distortion distTmp = 0; currTU.mtsIdx[codeCompId] = currTU.cu->bdpcmModeChroma ? MTS_SKIP : trModes[modeId].first; currTU.mtsIdx[otherCompId] = MTS_DCT2_DCT2; -#else - // encoder bugfix: initialize mtsIdx for chroma under JointCbCrMode. - currTU.mtsIdx[COMPONENT_Cb] = currTU.mtsIdx[COMPONENT_Cr] = MTS_DCT2_DCT2; -#endif m_CABACEstimator->getCtx() = ctxStartTU; resiCb.copyFrom( orgResiCb[cbfMask] ); resiCr.copyFrom( orgResiCr[cbfMask] ); -#if JVET_Q0695_CHROMA_TS_JCCR if (numTransformCands > 1) { -#if !REMOVE_PPS_REXT - xIntraCodingTUBlock(currTU, COMPONENT_Cb, false, distTmp, 0, nullptr, modeId == 0 ? &trModes : nullptr, true); -#else xIntraCodingTUBlock(currTU, COMPONENT_Cb, distTmp, 0, nullptr, modeId == 0 ? &trModes : nullptr, true); -#endif } else -#endif -#if !REMOVE_PPS_REXT - xIntraCodingTUBlock( currTU, COMPONENT_Cb, false, distTmp, 0 ); -#else xIntraCodingTUBlock( currTU, COMPONENT_Cb, distTmp, 0 ); -#endif double costTmp = std::numeric_limits<double>::max(); if( distTmp < std::numeric_limits<Distortion>::max() ) { uint64_t bits = xGetIntraFracBitsQTChroma( currTU, COMPONENT_Cb ); costTmp = m_pcRdCost->calcRdCost( bits, distTmp ); -#if JVET_Q0695_CHROMA_TS_JCCR if (!currTU.mtsIdx[codeCompId]) { cbfDCT2 = true; } -#endif } -#if JVET_Q0695_CHROMA_TS_JCCR else if (!currTU.mtsIdx[codeCompId]) { cbfDCT2 = false; } -#endif if( costTmp < bestCostCbCr ) { @@ -6080,9 +5387,6 @@ ChromaCbfs IntraSearch::xRecurIntraChromaCodingQT( CodingStructure &cs, Partitio bestJointCbCr = currTU.jointCbCr; // store data -#if !JVET_Q0695_CHROMA_TS_JCCR - if( cbfMask != jointCbfMasksToTest.back() ) -#endif { #if KEEP_PRED_AND_RESI_SIGNALS saveCS.getOrgResiBuf(cbArea).copyFrom(cs.getOrgResiBuf(cbArea)); @@ -6103,22 +5407,11 @@ ChromaCbfs IntraSearch::xRecurIntraChromaCodingQT( CodingStructure &cs, Partitio ctxBest = m_CABACEstimator->getCtx(); } -#if !JVET_Q0695_CHROMA_TS_JCCR - else - { - lastIsBest = true; - } -#endif } -#if JVET_Q0695_CHROMA_TS_JCCR } -#endif } // Retrieve the best CU data (unless it was the very last one tested) -#if !JVET_Q0695_CHROMA_TS_JCCR - if ( !( maxModesTested == 1 && jointCbfMasksToTest.empty() ) && !lastIsBest ) -#endif { #if KEEP_PRED_AND_RESI_SIGNALS cs.getPredBuf (cbArea).copyFrom(saveCS.getPredBuf (cbArea)); @@ -6414,7 +5707,7 @@ void IntraSearch::xGetNextISPMode(ModeInfo& modeInfo, const ModeInfo* lastMode, int maxNumSubPartitions = ispTestedModes.numTotalParts[nextISPcandSplitType - 1]; - // We try to break the split here for lfnst > 0 according to the first mode + // We try to break the split here for lfnst > 0 according to the first mode if (curIspLfnstIdx > 0 && ispTestedModes.numTestedModes[nextISPcandSplitType - 1] == 1) { int firstModeThisSplit = ispTestedModes.getTestedIntraMode(nextISPcandSplitType, 0); @@ -6442,7 +5735,7 @@ void IntraSearch::xGetNextISPMode(ModeInfo& modeInfo, const ModeInfo* lastMode, } } - // We try to break the split here for lfnst = 0 or all lfnst indices according to the first two modes + // We try to break the split here for lfnst = 0 or all lfnst indices according to the first two modes if (curIspLfnstIdx == 0 && ispTestedModes.numTestedModes[nextISPcandSplitType - 1] == 2) { // Split stop criteria after checking the performance of previously tested intra modes @@ -6483,7 +5776,7 @@ void IntraSearch::xGetNextISPMode(ModeInfo& modeInfo, const ModeInfo* lastMode, if (!stopThisSplit) { - // 2) One split type may be discarded by comparing the number of sub-partitions of the best angle modes of both splits + // 2) One split type may be discarded by comparing the number of sub-partitions of the best angle modes of both splits ISPType otherSplit = nextISPcandSplitType == HOR_INTRA_SUBPARTITIONS ? VER_INTRA_SUBPARTITIONS : HOR_INTRA_SUBPARTITIONS; int numSubPartsBestMode2OtherSplit = mode2 != -1 ? ispTestedModes.getNumCompletedSubParts(otherSplit, mode2) : -1; if (numSubPartsBestMode2OtherSplit != -1 && numSubPartsBestMode2 != -1 && ispTestedModes.bestSplitSoFar != nextISPcandSplitType) @@ -6625,7 +5918,7 @@ void IntraSearch::xFindAlreadyTestedNearbyIntraModes(int lfnstIdx, int currentIn } } - //The mode has not been checked for another lfnstIdx value, so now we look for a similar mode within a window using the same lfnstIdx + //The mode has not been checked for another lfnstIdx value, so now we look for a similar mode within a window using the same lfnstIdx for (int k = 1; k <= windowSize; k++) { int off = currentIntraMode - 2 - k; @@ -6701,7 +5994,7 @@ bool IntraSearch::xSortISPCandList(double bestCostSoFar, double bestNonISPCost, ModeInfo refMode = origHadList.at(0); auto* destListPtr = &m_ispCandListHor; - //List creation + //List creation if (m_pcEncCfg->getUseFastISP() && bestISPModeInRelCU != -1) //RelCU intra mode { @@ -6909,7 +6202,7 @@ bool IntraSearch::updateISPStatusFromRelCU( double bestNonISPCostCurrCu, ModeInf void IntraSearch::xFinishISPModes() { - //Continue to the next lfnst index + //Continue to the next lfnst index m_curIspLfnstIdx++; if (m_curIspLfnstIdx < NUM_LFNST_NUM_PER_SET) diff --git a/source/Lib/EncoderLib/IntraSearch.h b/source/Lib/EncoderLib/IntraSearch.h index 3a4ba0b4b3a0800933c07549edc327ad1cc8aacb..51a12a1a448a9ef8abf3c3dbf97dc40aa1ba7ce6 100644 --- a/source/Lib/EncoderLib/IntraSearch.h +++ b/source/Lib/EncoderLib/IntraSearch.h @@ -72,33 +72,20 @@ public: return cnt > other.cnt; } SortingElement() { -#if JVET_Q0504_PLT_NON444 cnt[0] = cnt[1] = cnt[2] = cnt[3] = 0; shift[0] = shift[1] = shift[2] = 0; lastCnt[0] = lastCnt[1] = lastCnt[2] = 0; -#else - cnt = shift = lastCnt = 0; -#endif data[0] = data[1] = data[2] = 0; sumData[0] = sumData[1] = sumData[2] = 0; } -#if JVET_Q0504_PLT_NON444 uint32_t getCnt(int idx) const { return cnt[idx]; } void setCnt(uint32_t val, int idx) { cnt[idx] = val; } -#else - uint32_t getCnt() const { return cnt; } - void setCnt(uint32_t val) { cnt = val; } -#endif int getSumData (int id) const { return sumData[id]; } void resetAll(ComponentID compBegin, uint32_t numComp) { -#if JVET_Q0504_PLT_NON444 shift[0] = shift[1] = shift[2] = 0; lastCnt[0] = lastCnt[1] = lastCnt[2] = 0; -#else - shift = lastCnt = 0; -#endif for (int ch = compBegin; ch < (compBegin + numComp); ch++) { data[ch] = 0; @@ -112,16 +99,11 @@ public: data[ch] = ui[ch]; } } -#if JVET_Q0493_PLT_ENCODER_LOSSLESS bool almostEqualData(SortingElement element, int errorLimit, const BitDepths& bitDepths, ComponentID compBegin, uint32_t numComp, bool lossless) -#else - bool almostEqualData(SortingElement element, int errorLimit, const BitDepths& bitDepths, ComponentID compBegin, uint32_t numComp) -#endif { bool almostEqual = true; for (int comp = compBegin; comp < (compBegin + numComp); comp++) { -#if JVET_Q0493_PLT_ENCODER_LOSSLESS if (lossless) { if ((std::abs(data[comp] - element.data[comp])) > errorLimit) @@ -132,7 +114,6 @@ public: } else { -#endif uint32_t absError = 0; if (isChroma((ComponentID) comp)) { @@ -147,34 +128,24 @@ public: almostEqual = false; break; } -#if JVET_Q0493_PLT_ENCODER_LOSSLESS } -#endif } return almostEqual; } -#if JVET_Q0493_PLT_ENCODER_LOSSLESS uint32_t getSAD(SortingElement element, const BitDepths &bitDepths, ComponentID compBegin, uint32_t numComp, bool lossless) -#else - uint32_t getSAD(SortingElement element, const BitDepths& bitDepths, ComponentID compBegin, uint32_t numComp) -#endif { uint32_t sumAd = 0; for (int comp = compBegin; comp < (compBegin + numComp); comp++) { ChannelType chType = (comp > 0) ? CHANNEL_TYPE_CHROMA : CHANNEL_TYPE_LUMA; -#if JVET_Q0493_PLT_ENCODER_LOSSLESS if (lossless) { sumAd += (std::abs(data[comp] - element.data[comp])); } else { -#endif sumAd += (std::abs(data[comp] - element.data[comp]) >> (bitDepths.recon[chType] - PLT_ENCBITDEPTH)); -#if JVET_Q0493_PLT_ENCODER_LOSSLESS } -#endif } return sumAd; } @@ -184,37 +155,22 @@ public: { data[comp] = element.data[comp]; sumData[comp] = data[comp]; -#if JVET_Q0504_PLT_NON444 - shift[comp] = 0; + shift[comp] = 0; lastCnt[comp] = 1; -#endif } -#if !JVET_Q0504_PLT_NON444 - shift = 0; lastCnt = 1; -#endif } void copyAllFrom(SortingElement element, ComponentID compBegin, uint32_t numComp) { copyDataFrom(element, compBegin, numComp); -#if !JVET_Q0504_PLT_NON444 - cnt = element.cnt; -#endif for (int comp = compBegin; comp < (compBegin + numComp); comp++) { sumData[comp] = element.sumData[comp]; -#if JVET_Q0504_PLT_NON444 cnt[comp] = element.cnt[comp]; shift[comp] = element.shift[comp]; lastCnt[comp] = element.lastCnt[comp]; -#endif } -#if JVET_Q0504_PLT_NON444 cnt[MAX_NUM_COMPONENT] = element.cnt[MAX_NUM_COMPONENT]; -#else - lastCnt = element.lastCnt; shift = element.shift; -#endif } -#if JVET_Q0504_PLT_NON444 void addElement(const SortingElement& element, ComponentID compBegin, uint32_t numComp) { for (int i = compBegin; i<(compBegin + numComp); i++) @@ -230,41 +186,12 @@ public: } } } -#else - void addElement(const SortingElement& element, ComponentID compBegin, uint32_t numComp) - { - cnt++; - for (int i = compBegin; i<(compBegin + numComp); i++) - { - sumData[i] += element.data[i]; - } - if (cnt>1 && cnt == 2 * lastCnt) - { - uint32_t rnd = 1 << shift; - shift++; - for (int i = compBegin; i<(compBegin + numComp); i++) - { - data[i] = (sumData[i] + rnd) >> shift; - } - lastCnt = cnt; - } - } -#endif private: -#if JVET_Q0504_PLT_NON444 uint32_t cnt[MAX_NUM_COMPONENT+1]; int shift[3], lastCnt[3], data[3], sumData[3]; -#else - uint32_t cnt; - int shift, lastCnt, data[3], sumData[3]; -#endif }; /// encoder search class -#if !REMOVE_PPS_REXT -class IntraSearch : public IntraPrediction, CrossComponentPrediction -#else class IntraSearch : public IntraPrediction -#endif { private: EncModeCtrl *m_modeCtrl; @@ -464,7 +391,7 @@ protected: uint16_t* m_escapeNumBins; bool m_bestEscape; double* m_indexError[MAXPLTSIZE + 1]; - uint8_t* m_minErrorIndexMap; // store the best index in terms of distortion for each pixel + uint8_t* m_minErrorIndexMap; // store the best index in terms of distortion for each pixel uint8_t m_indexMapRDOQ [2][NUM_TRELLIS_STATE][2 * MAX_CU_BLKSIZE_PLT]; bool m_runMapRDOQ [2][NUM_TRELLIS_STATE][2 * MAX_CU_BLKSIZE_PLT]; uint8_t* m_statePtRDOQ [NUM_TRELLIS_STATE]; @@ -533,11 +460,7 @@ protected: uint64_t xGetIntraFracBitsQTChroma(TransformUnit& tu, const ComponentID &compID); void xEncCoeffQT ( CodingStructure &cs, Partitioner& pm, const ComponentID compID, const int subTuIdx = -1, const PartSplit ispType = TU_NO_ISP, CUCtx * cuCtx = nullptr ); -#if !REMOVE_PPS_REXT - void xIntraCodingTUBlock (TransformUnit &tu, const ComponentID &compID, const bool &checkCrossCPrediction, Distortion& ruiDist, const int &default0Save1Load2 = 0, uint32_t* numSig = nullptr, std::vector<TrMode>* trModes=nullptr, const bool loadTr=false ); -#else void xIntraCodingTUBlock (TransformUnit &tu, const ComponentID &compID, Distortion& ruiDist, const int &default0Save1Load2 = 0, uint32_t* numSig = nullptr, std::vector<TrMode>* trModes=nullptr, const bool loadTr=false ); -#endif void xIntraCodingACTTUBlock(TransformUnit &tu, const ComponentID &compID, Distortion& ruiDist, std::vector<TrMode>* trModes = nullptr, const bool loadTr = false); ChromaCbfs xRecurIntraChromaCodingQT( CodingStructure &cs, Partitioner& pm, const double bestCostSoFar = MAX_DOUBLE, const PartSplit ispType = TU_NO_ISP ); @@ -551,11 +474,7 @@ protected: void calcPixelPred ( CodingStructure& cs, Partitioner& partitioner, uint32_t yPos, uint32_t xPos, ComponentID compBegin, uint32_t numComp); void preCalcPLTIndexRD (CodingStructure& cs, Partitioner& partitioner, ComponentID compBegin, uint32_t numComp); void calcPixelPredRD (CodingStructure& cs, Partitioner& partitioner, Pel* orgBuf, Pel* pixelValue, Pel* recoValue, ComponentID compBegin, uint32_t numComp); -#if JVET_Q0503_Q0712_PLT_ENCODER_IMPROV_BUGFIX void deriveIndexMap (CodingStructure& cs, Partitioner& partitioner, ComponentID compBegin, uint32_t numComp, PLTScanMode pltScanMode, double& dCost, bool* idxExist); -#else - void deriveIndexMap (CodingStructure& cs, Partitioner& partitioner, ComponentID compBegin, uint32_t numComp, PLTScanMode pltScanMode, double& dCost); -#endif bool deriveSubblockIndexMap(CodingStructure& cs, Partitioner& partitioner, ComponentID compBegin, PLTScanMode pltScanMode, int minSubPos, int maxSubPos, const BinFracBits& fracBitsPltRunType, const BinFracBits* fracBitsPltIndexINDEX, const BinFracBits* fracBitsPltIndexCOPY, const double minCost, bool useRotate); double rateDistOptPLT (bool RunType, uint8_t RunIndex, bool prevRunType, uint8_t prevRunIndex, uint8_t aboveRunIndex, bool& prevCodedRunType, int& prevCodedRunPos, int scanPos, uint32_t width, int dist, int indexMaxValue, const BinFracBits* IndexfracBits, const BinFracBits& TypefracBits); void initTBCTable (int bitDepth); diff --git a/source/Lib/EncoderLib/RateCtrl.cpp b/source/Lib/EncoderLib/RateCtrl.cpp index 51e5535e45949221993ea830d7feae174aa6b92e..38ce50ac957edde264fef1ed4f1f28a2406c7432 100644 --- a/source/Lib/EncoderLib/RateCtrl.cpp +++ b/source/Lib/EncoderLib/RateCtrl.cpp @@ -319,6 +319,11 @@ void EncRCGOP::create( EncRCSeq* encRCSeq, int numPic ) { destroy(); int targetBits = xEstGOPTargetBits( encRCSeq, numPic ); + int bitdepth_luma_scale = + 2 * (encRCSeq->getbitDepth() - 8 + - DISTORTION_PRECISION_ADJUSTMENT(encRCSeq->getbitDepth())); + m_minEstLambda = 0.1; + m_maxEstLambda = 10000.0 * pow(2.0, bitdepth_luma_scale); if ( encRCSeq->getAdaptiveBits() > 0 && encRCSeq->getLastLambda() > 0.1 ) { @@ -328,7 +333,7 @@ void EncRCGOP::create( EncRCSeq* encRCSeq, int numPic ) double* equaCoeffA = new double[encRCSeq->getGOPSize()]; double* equaCoeffB = new double[encRCSeq->getGOPSize()]; - if ( encRCSeq->getAdaptiveBits() == 1 ) // for GOP size =4, low delay case + if ( encRCSeq->getAdaptiveBits() == 1 && encRCSeq->getGOPSize() == 4) // for GOP size =4, low delay case { if ( encRCSeq->getLastLambda() < 120.0 ) { @@ -345,6 +350,31 @@ void EncRCGOP::create( EncRCSeq* encRCSeq, int numPic ) lambdaRatio[3] = 1.0; } } + else if (encRCSeq->getAdaptiveBits() == 1 && encRCSeq->getGOPSize() == 8) // for GOP size =8, low delay case + { + if (encRCSeq->getLastLambda() < 120.0) + { + lambdaRatio[1] = 0.725 * log(encRCSeq->getLastLambda()) + 0.5793; + lambdaRatio[3] = 0.725 * log(encRCSeq->getLastLambda()) + 0.5793; + lambdaRatio[5] = 0.725 * log(encRCSeq->getLastLambda()) + 0.5793; + lambdaRatio[0] = 1.3 * lambdaRatio[1]; + lambdaRatio[2] = 1.3 * lambdaRatio[1]; + lambdaRatio[4] = 1.3 * lambdaRatio[1]; + lambdaRatio[6] = 1.3 * lambdaRatio[1]; + lambdaRatio[7] = 1.0; + } + else + { + lambdaRatio[0] = 5.0; + lambdaRatio[1] = 4.0; + lambdaRatio[2] = 5.0; + lambdaRatio[3] = 4.0; + lambdaRatio[4] = 5.0; + lambdaRatio[5] = 4.0; + lambdaRatio[6] = 5.0; + lambdaRatio[7] = 1.0; + } + } else if ( encRCSeq->getAdaptiveBits() == 2 ) // for GOP size = 8, random access case { if ( encRCSeq->getLastLambda() < 90.0 ) @@ -449,6 +479,10 @@ void EncRCGOP::create( EncRCSeq* encRCSeq, int numPic ) lambdaRatio[15] = lambdaLev5 / lambdaLev1; } } + else + { + msg( WARNING, "Warning: Current rate control does not support this coding configuration." ); + } xCalEquaCoeff( encRCSeq, lambdaRatio, equaCoeffA, equaCoeffB, encRCSeq->getGOPSize() ); basicLambda = xSolveEqua(encRCSeq, targetBpp, equaCoeffA, equaCoeffB, encRCSeq->getGOPSize()); @@ -478,11 +512,7 @@ void EncRCGOP::create( EncRCSeq* encRCSeq, int numPic ) m_targetBits = targetBits; m_picLeft = m_numPic; m_bitsLeft = m_targetBits; - int bitdepth_luma_scale = - 2 * (encRCSeq->getbitDepth() - 8 - - DISTORTION_PRECISION_ADJUSTMENT(encRCSeq->getbitDepth())); - m_minEstLambda = 0.1; - m_maxEstLambda = 10000.0 * pow(2.0, bitdepth_luma_scale); + } void EncRCGOP::xCalEquaCoeff( EncRCSeq* encRCSeq, double* lambdaRatio, double* equaCoeffA, double* equaCoeffB, int GOPSize ) @@ -1351,7 +1381,7 @@ double EncRCPic::clipRcAlpha(const int bitdepth, const double alpha) int bitdepth_luma_scale = 2 * (bitdepth - 8 - - DISTORTION_PRECISION_ADJUSTMENT(m_encRCSeq->getbitDepth())); + - DISTORTION_PRECISION_ADJUSTMENT(bitdepth)); return Clip3(g_RCAlphaMinValue, g_RCAlphaMaxValue * pow(2.0, bitdepth_luma_scale), alpha); } @@ -1566,6 +1596,58 @@ void RateCtrl::init(int totalFrames, int targetBitrate, int frameRate, int GOPSi adaptiveBit = 1; } } + else if (GOPSize == 8 && isLowdelay) + { + if (bpp > 0.2) + { + bitsRatio[0] = 2; + bitsRatio[1] = 3; + bitsRatio[2] = 2; + bitsRatio[3] = 3; + bitsRatio[4] = 2; + bitsRatio[5] = 3; + bitsRatio[6] = 2; + bitsRatio[7] = 6; + } + else if (bpp > 0.1) + { + bitsRatio[0] = 2; + bitsRatio[1] = 3; + bitsRatio[2] = 2; + bitsRatio[3] = 3; + bitsRatio[4] = 2; + bitsRatio[5] = 3; + bitsRatio[6] = 2; + bitsRatio[7] = 10; + } + else if (bpp > 0.05) + { + bitsRatio[0] = 2; + bitsRatio[1] = 3; + bitsRatio[2] = 2; + bitsRatio[3] = 3; + bitsRatio[4] = 2; + bitsRatio[5] = 3; + bitsRatio[6] = 2; + bitsRatio[7] = 12; + } + else + { + bitsRatio[0] = 2; + bitsRatio[1] = 3; + bitsRatio[2] = 2; + bitsRatio[3] = 3; + bitsRatio[4] = 2; + bitsRatio[5] = 3; + bitsRatio[6] = 2; + bitsRatio[7] = 14; + } + + if (keepHierBits == 2) + { + adaptiveBit = 1; + } + } else if ( GOPSize == 8 && !isLowdelay ) { if ( bpp > 0.2 ) @@ -1727,6 +1809,17 @@ void RateCtrl::init(int totalFrames, int targetBitrate, int frameRate, int GOPSi GOPID2Level[2] = 3; GOPID2Level[3] = 1; } + if (GOPSize == 8 && isLowdelay) + { + GOPID2Level[0] = 3; + GOPID2Level[1] = 2; + GOPID2Level[2] = 3; + GOPID2Level[3] = 2; + GOPID2Level[4] = 3; + GOPID2Level[5] = 2; + GOPID2Level[6] = 3; + GOPID2Level[7] = 1; + } else if ( GOPSize == 8 && !isLowdelay ) { GOPID2Level[0] = 1; @@ -1843,7 +1936,6 @@ int RateCtrl::updateCpbState(int actualBits) return cpbState; } -#if JVET_P0118_HRD_ASPECTS void RateCtrl::initHrdParam(const GeneralHrdParams* generalHrd, const OlsHrdParams* olsHrd, int iFrameRate, double fInitialCpbFullness) { m_CpbSaturationEnabled = true; @@ -1852,16 +1944,6 @@ void RateCtrl::initHrdParam(const GeneralHrdParams* generalHrd, const OlsHrdPara m_bufferingRate = (uint32_t)(((olsHrd->getBitRateValueMinus1(0, 0) + 1) << (6 + generalHrd->getBitRateScale())) / iFrameRate); msg(NOTICE, "\nHRD - [Initial CPB state %6d] [CPB Size %6d] [Buffering Rate %6d]\n", m_cpbState, m_cpbSize, m_bufferingRate); } -#else -void RateCtrl::initHrdParam(const HRDParameters* pcHrd, int iFrameRate, double fInitialCpbFullness) -{ - m_CpbSaturationEnabled = true; - m_cpbSize = (pcHrd->getCpbSizeValueMinus1(0, 0, 0) + 1) << (4 + pcHrd->getCpbSizeScale()); - m_cpbState = (uint32_t)(m_cpbSize*fInitialCpbFullness); - m_bufferingRate = (uint32_t)(((pcHrd->getBitRateValueMinus1(0, 0, 0) + 1) << (6 + pcHrd->getBitRateScale())) / iFrameRate); - msg( NOTICE, "\nHRD - [Initial CPB state %6d] [CPB Size %6d] [Buffering Rate %6d]\n", m_cpbState, m_cpbSize, m_bufferingRate); -} -#endif #endif void RateCtrl::destroyRCGOP() diff --git a/source/Lib/EncoderLib/RateCtrl.h b/source/Lib/EncoderLib/RateCtrl.h index 48d5da9c0343cf0ad23de976d80f94f1e7cc5a0e..078c27125017676e874ff296bd96a84bc2c640a5 100644 --- a/source/Lib/EncoderLib/RateCtrl.h +++ b/source/Lib/EncoderLib/RateCtrl.h @@ -354,11 +354,7 @@ public: uint32_t getCpbSize() { return m_cpbSize; } uint32_t getBufferingRate() { return m_bufferingRate; } int updateCpbState(int actualBits); -#if JVET_P0118_HRD_ASPECTS void initHrdParam(const GeneralHrdParams* generalHrd, const OlsHrdParams* olsHrd, int iFrameRate, double fInitialCpbFullness); -#else - void initHrdParam(const HRDParameters* pcHrd, int iFrameRate, double fInitialCpbFullness); -#endif #endif private: diff --git a/source/Lib/EncoderLib/SEIEncoder.cpp b/source/Lib/EncoderLib/SEIEncoder.cpp index ddbcee89a9432e7941828d5a05dc440974840df9..cd9d018061664191efbcfa771286445ede4892b9 100644 --- a/source/Lib/EncoderLib/SEIEncoder.cpp +++ b/source/Lib/EncoderLib/SEIEncoder.cpp @@ -179,10 +179,25 @@ void SEIEncoder::initSEIBufferingPeriod(SEIBufferingPeriod *bufferingPeriodSEI, break; } } +#if JVET_R0094_DPB_TID_OFFSET + bufferingPeriodSEI->m_sublayerDpbOutputOffsetsPresentFlag = true; + for(int i = 0; i < bufferingPeriodSEI->m_bpMaxSubLayers; i++) + { + bufferingPeriodSEI->m_dpbOutputTidOffset[i] = m_pcCfg->getNumReorderPics(i) * static_cast<int>(pow(2, static_cast<double>(bufferingPeriodSEI->m_bpMaxSubLayers-1-i))); + if(bufferingPeriodSEI->m_dpbOutputTidOffset[i] >= m_pcCfg->getNumReorderPics(bufferingPeriodSEI->m_bpMaxSubLayers-1)) + { + bufferingPeriodSEI->m_dpbOutputTidOffset[i] -= m_pcCfg->getNumReorderPics(bufferingPeriodSEI->m_bpMaxSubLayers-1); + } + else + { + bufferingPeriodSEI->m_dpbOutputTidOffset[i] = 0; + } + } +#endif // A commercial encoder should track the buffer state for all layers and sub-layers // to ensure CPB conformance. Such tracking is required for calculating alternative // CPB parameters. - // Unfortunately VTM does not have such tracking. Thus we cannot encode alternative + // Unfortunately VTM does not have such tracking. Thus we cannot encode alternative // CPB parameters here. bufferingPeriodSEI->m_altCpbParamsPresentFlag = false; bufferingPeriodSEI->m_useAltCpbParamsFlag = false; @@ -275,7 +290,7 @@ void SEIEncoder::initSEIRegionWisePacking(SEIRegionWisePacking *seiRegionWisePac seiRegionWisePacking->m_rwpTopGuardBandHeight.resize(seiRegionWisePacking->m_numPackedRegions); seiRegionWisePacking->m_rwpBottomGuardBandHeight.resize(seiRegionWisePacking->m_numPackedRegions); seiRegionWisePacking->m_rwpGuardBandNotUsedForPredFlag.resize(seiRegionWisePacking->m_numPackedRegions); - seiRegionWisePacking->m_rwpGuardBandType.resize(4*seiRegionWisePacking->m_numPackedRegions); + seiRegionWisePacking->m_rwpGuardBandType.resize(4*seiRegionWisePacking->m_numPackedRegions); for( int i=0; i < seiRegionWisePacking->m_numPackedRegions; i++ ) { seiRegionWisePacking->m_rwpTransformType[i] = m_pcCfg->getRwpSEIRwpTransformType(i); @@ -341,14 +356,9 @@ void SEIEncoder::initSEIGcmp(SEIGeneralizedCubemapProjection* seiGeneralizedCube seiGeneralizedCubemapProjection->m_gcmpGuardBandFlag = m_pcCfg->getGcmpSEIGuardBandFlag(); if (seiGeneralizedCubemapProjection->m_gcmpGuardBandFlag) { -#if JVET_Q0343_GCMP_GUARD_BAND_TYPE seiGeneralizedCubemapProjection->m_gcmpGuardBandType = m_pcCfg->getGcmpSEIGuardBandType(); seiGeneralizedCubemapProjection->m_gcmpGuardBandBoundaryExteriorFlag = m_pcCfg->getGcmpSEIGuardBandBoundaryExteriorFlag(); seiGeneralizedCubemapProjection->m_gcmpGuardBandSamplesMinus1 = m_pcCfg->getGcmpSEIGuardBandSamplesMinus1(); -#else - seiGeneralizedCubemapProjection->m_gcmpGuardBandBoundaryType = m_pcCfg->getGcmpSEIGuardBandBoundaryType(); - seiGeneralizedCubemapProjection->m_gcmpGuardBandSamplesMinus1 = m_pcCfg->getGcmpSEIGuardBandSamplesMinus1(); -#endif } } } @@ -376,19 +386,18 @@ void SEIEncoder::initSEISampleAspectRatioInfo(SEISampleAspectRatioInfo* seiSampl } } -#if JVET_P0190_SCALABLE_NESTING_SEI //! initialize scalable nesting SEI message. //! Note: The SEI message structures input into this function will become part of the scalable nesting SEI and will be //! automatically freed, when the nesting SEI is disposed. -void SEIEncoder::initSEIScalableNesting(SEIScalableNesting *scalableNestingSEI, SEIMessages &nestedSEIs) +void SEIEncoder::initSEIScalableNesting(SEIScalableNesting *scalableNestingSEI, SEIMessages &nestedSEIs) { CHECK(!(m_isInitialized), "Unspecified error"); CHECK(!(scalableNestingSEI != NULL), "Unspecified error"); scalableNestingSEI->m_nestingOlsFlag = 1; // by If the nested SEI messages are picture buffering SEI messages, picture timing SEI messages or sub-picture timing SEI messages, nesting_ols_flag shall be equal to 1, by default case - scalableNestingSEI->m_nestingNumOlssMinus1 = 1; // by default the nesting scalable SEI message applies to two OLSs. + scalableNestingSEI->m_nestingNumOlssMinus1 = 1; // by default the nesting scalable SEI message applies to two OLSs. for (int i = 0; i <= scalableNestingSEI->m_nestingNumOlssMinus1; i++) { - scalableNestingSEI->m_nestingOlsIdxDeltaMinus1[i] = 0; // first ols to which nesting SEI applies is + scalableNestingSEI->m_nestingOlsIdxDeltaMinus1[i] = 0; // first ols to which nesting SEI applies is } for (int i = 0; i <= scalableNestingSEI->m_nestingNumOlssMinus1; i++) { @@ -412,7 +421,6 @@ void SEIEncoder::initSEIScalableNesting(SEIScalableNesting *scalableNestingSEI, scalableNestingSEI->m_nestedSEIs.push_back((*it)); } } -#endif //! calculate hashes for entire reconstructed picture @@ -621,7 +629,6 @@ void SEIEncoder::initSEIContentColourVolume(SEIContentColourVolume *seiContentCo } void SEIEncoder::initSEISubpictureLevelInfo(SEISubpicureLevelInfo *sei, const SPS *sps) { -#if JVET_SUBPIC_LEVEL_CFG const EncCfgParam::CfgSEISubpictureLevel &cfgSubPicLevel = m_pcCfg->getSubpicureLevelInfoSEICfg(); sei->m_numRefLevels = (int) cfgSubPicLevel.m_refLevels.size(); @@ -641,23 +648,6 @@ void SEIEncoder::initSEISubpictureLevelInfo(SEISubpicureLevelInfo *sei, const SP } } } -#else - // subpicture level information should be specified via config file - // unfortunately the implementation of subpictures is still not available - // TODO: implement config file parameters and intialization - fprintf(stderr, "SEISubpicureLevelInfo depends on subpictures! Initializing to dummy values!\n"); - -#if !JVET_Q0630_SUBPIC_LEVEL - sei->m_sliSeqParameterSetId = sps->getSPSId(); -#else - sei->m_numSubpics = sps->getNumSubPics(); -#endif - sei->m_numRefLevels = 2; - sei->m_refLevelIdc.resize(2); - sei->m_refLevelIdc[0] = Level::LEVEL4; - sei->m_refLevelIdc[1] = Level::LEVEL8_5; - sei->m_explicitFractionPresentFlag = false; -#endif } diff --git a/source/Lib/EncoderLib/SEIEncoder.h b/source/Lib/EncoderLib/SEIEncoder.h index 1ffb088916fcd07e5e3371de07de776c14b0efe4..0506df6ed80780459998d77bf78c9cc72d8c17dd 100644 --- a/source/Lib/EncoderLib/SEIEncoder.h +++ b/source/Lib/EncoderLib/SEIEncoder.h @@ -71,9 +71,7 @@ public: #if U0033_ALTERNATIVE_TRANSFER_CHARACTERISTICS_SEI void initSEIAlternativeTransferCharacteristics(SEIAlternativeTransferCharacteristics *sei); #endif -#if JVET_P0190_SCALABLE_NESTING_SEI void initSEIScalableNesting(SEIScalableNesting *sei, SEIMessages &nestedSEIs); -#endif // trailing SEIs void initDecodedPictureHashSEI(SEIDecodedPictureHash *sei, PelUnitBuf& pic, std::string &rHashString, const BitDepths &bitDepths); void initSEIErp(SEIEquirectangularProjection *sei); diff --git a/source/Lib/EncoderLib/SEIwrite.cpp b/source/Lib/EncoderLib/SEIwrite.cpp index c6020968afed2dc7d65ac95198e59e4078b28a6f..09ae4a7696d49394101f92ef2f40137abb2a3a9f 100644 --- a/source/Lib/EncoderLib/SEIwrite.cpp +++ b/source/Lib/EncoderLib/SEIwrite.cpp @@ -54,11 +54,9 @@ void SEIWriter::xWriteSEIpayloadData(OutputBitstream &bs, const SEI& sei, const CHECK (bp == nullptr, "Buffering Period need to be initialized in HRD to allow writing of Decoding Unit Information SEI"); xWriteSEIDecodingUnitInfo(*static_cast<const SEIDecodingUnitInfo*>(& sei), *bp, temporalId); break; -#if JVET_P0190_SCALABLE_NESTING_SEI case SEI::SCALABLE_NESTING: xWriteSEIScalableNesting(bs, *static_cast<const SEIScalableNesting*>(&sei), sps); break; -#endif case SEI::DECODED_PICTURE_HASH: xWriteSEIDecodedPictureHash(*static_cast<const SEIDecodedPictureHash*>(&sei)); break; @@ -121,11 +119,7 @@ void SEIWriter::xWriteSEIpayloadData(OutputBitstream &bs, const SEI& sei, const xWriteSEIContentColourVolume(*static_cast<const SEIContentColourVolume*>(&sei)); break; case SEI::SUBPICTURE_LEVEL_INFO: -#if JVET_Q0630_SUBPIC_LEVEL xWriteSEISubpictureLevelInfo(*static_cast<const SEISubpicureLevelInfo*>(&sei)); -#else - xWriteSEISubpictureLevelInfo(*static_cast<const SEISubpicureLevelInfo*>(&sei), sps); -#endif break; case SEI::SAMPLE_ASPECT_RATIO_INFO: xWriteSEISampleAspectRatioInfo(*static_cast<const SEISampleAspectRatioInfo*>(&sei)); @@ -244,21 +238,27 @@ void SEIWriter::xWriteSEIDecodingUnitInfo(const SEIDecodingUnitInfo& sei, const WRITE_UVLC(sei.m_decodingUnitIdx, "decoding_unit_idx"); if( !bp.m_decodingUnitCpbParamsInPicTimingSeiFlag ) { - for( int i = temporalId; i < bp.m_bpMaxSubLayers - 1; i ++ ) +#if JVET_R0100 + for (int i = temporalId; i <= bp.m_bpMaxSubLayers - 1; i++) { - WRITE_FLAG( sei.m_duiSubLayerDelaysPresentFlag[i], "dui_sub_layer_delays_present_flag[i]" ); + if (i < bp.m_bpMaxSubLayers - 1) + { +#else + for (int i = temporalId; i < bp.m_bpMaxSubLayers - 1; i++) + { +#endif + WRITE_FLAG(sei.m_duiSubLayerDelaysPresentFlag[i], "dui_sub_layer_delays_present_flag[i]"); +#if JVET_R0100 + } +#endif if( sei.m_duiSubLayerDelaysPresentFlag[i] ) WRITE_CODE( sei.m_duSptCpbRemovalDelayIncrement[i], bp.getDuCpbRemovalDelayIncrementLength(), "du_spt_cpb_removal_delay_increment[i]"); } } -#if JVET_Q0221 if (bp.m_decodingUnitDpbDuParamsInPicTimingSeiFlag) { WRITE_FLAG(sei.m_dpbOutputDuDelayPresentFlag, "dpb_output_du_delay_present_flag"); } -#else - WRITE_FLAG( sei.m_dpbOutputDuDelayPresentFlag, "dpb_output_du_delay_present_flag"); -#endif if(sei.m_dpbOutputDuDelayPresentFlag) { WRITE_CODE(sei.m_picSptDpbOutputDuDelay, bp.getDpbOutputDelayDuLength(), "pic_spt_dpb_output_du_delay"); @@ -285,9 +285,7 @@ void SEIWriter::xWriteSEIBufferingPeriod(const SEIBufferingPeriod& sei) CHECK (sei.m_dpbOutputDelayDuLength < 1, "sei.m_dpbOutputDelayDuLength must be > 0"); WRITE_CODE( sei.m_dpbOutputDelayDuLength - 1, 5, "dpb_output_delay_du_length_minus1" ); WRITE_FLAG( sei.m_decodingUnitCpbParamsInPicTimingSeiFlag, "decoding_unit_cpb_params_in_pic_timing_sei_flag" ); -#if JVET_Q0221 WRITE_FLAG(sei.m_decodingUnitDpbDuParamsInPicTimingSeiFlag, "decoding_unit_dpb_du_params_in_pic_timing_sei_flag"); -#endif } WRITE_FLAG( sei.m_concatenationFlag, "concatenation_flag"); @@ -330,6 +328,16 @@ void SEIWriter::xWriteSEIBufferingPeriod(const SEIBufferingPeriod& sei) } } } +#if JVET_R0094_DPB_TID_OFFSET + WRITE_FLAG(sei.m_sublayerDpbOutputOffsetsPresentFlag, "sublayer_dpb_output_offsets_present_flag"); + if(sei.m_sublayerDpbOutputOffsetsPresentFlag) + { + for(int i = 0; i < sei.m_bpMaxSubLayers - 1; i++) + { + WRITE_UVLC( sei.m_dpbOutputTidOffset[i], "dpb_output_tid_offset[i]" ); + } + } +#endif if (sei.m_altCpbParamsPresentFlag) { WRITE_FLAG(sei.m_useAltCpbParamsFlag, "use_alt_cpb_params_flag"); @@ -339,14 +347,47 @@ void SEIWriter::xWriteSEIBufferingPeriod(const SEIBufferingPeriod& sei) void SEIWriter::xWriteSEIPictureTiming(const SEIPictureTiming& sei, const SEIBufferingPeriod &bp, const uint32_t temporalId) { - + WRITE_CODE( sei.m_auCpbRemovalDelay[bp.m_bpMaxSubLayers - 1] - 1, bp.m_cpbRemovalDelayLength, "cpb_removal_delay_minus1[bp_max_sub_layers_minus1]" ); - if( bp.m_altCpbParamsPresentFlag ) + if( bp.m_altCpbParamsPresentFlag ) { WRITE_FLAG( sei.m_cpbAltTimingInfoPresentFlag, "cpb_alt_timing_info_present_flag" ); - if( sei.m_cpbAltTimingInfoPresentFlag ) + if( sei.m_cpbAltTimingInfoPresentFlag ) { -#if JVET_Q0219_SIGNAL_ALT_BUFFER_DELAY_PARMS +#if JVET_R0413_HRD_TIMING_INFORMATION + if (bp.m_bpNalCpbParamsPresentFlag) + { + for (int i = (bp.m_sublayerInitialCpbRemovalDelayPresentFlag ? 0 : bp.m_bpMaxSubLayers - 1); i <= bp.m_bpMaxSubLayers - 1; ++i) + { + for (int j = 0; j < bp.m_bpCpbCnt; j++) + { + WRITE_CODE(sei.m_nalCpbAltInitialRemovalDelayDelta[i][j], bp.m_initialCpbRemovalDelayLength, + "nal_cpb_alt_initial_cpb_removal_delay_delta[ i ][ j ]"); + WRITE_CODE(sei.m_nalCpbAltInitialRemovalOffsetDelta[i][j], bp.m_initialCpbRemovalDelayLength, + "nal_cpb_alt_initial_cpb_removal_offset_delta[ i ][ j ]"); + } + WRITE_CODE(sei.m_nalCpbDelayOffset[i], bp.m_initialCpbRemovalDelayLength, "nal_cpb_delay_offset[ i ]"); + WRITE_CODE(sei.m_nalDpbDelayOffset[i], bp.m_initialCpbRemovalDelayLength, "nal_dpb_delay_offset[ i ]"); + } + } + + if (bp.m_bpVclCpbParamsPresentFlag) + { + for (int i = (bp.m_sublayerInitialCpbRemovalDelayPresentFlag ? 0 : bp.m_bpMaxSubLayers - 1); + i <= bp.m_bpMaxSubLayers - 1; ++i) + { + for (int j = 0; j < bp.m_bpCpbCnt; j++) + { + WRITE_CODE(sei.m_vclCpbAltInitialRemovalDelayDelta[i][j], bp.m_initialCpbRemovalDelayLength, + "vcl_cpb_alt_initial_cpb_removal_delay_delta[ i ][ j ]"); + WRITE_CODE(sei.m_vclCpbAltInitialRemovalOffsetDelta[i][j], bp.m_initialCpbRemovalDelayLength, + "vcl_cpb_alt_initial_cpb_removal_offset_delta[ i ][ j ]"); + } + WRITE_CODE(sei.m_vclCpbDelayOffset[i], bp.m_initialCpbRemovalDelayLength, "vcl_cpb_delay_offset[ i ]"); + WRITE_CODE(sei.m_vclDpbDelayOffset[i], bp.m_initialCpbRemovalDelayLength, "vcl_dpb_delay_offset[ i ]"); + } + } +#else for (int i = (bp.m_sublayerInitialCpbRemovalDelayPresentFlag ? 0 : bp.m_bpMaxSubLayers - 1); i <= bp.m_bpMaxSubLayers - 1; ++i) { @@ -360,16 +401,6 @@ void SEIWriter::xWriteSEIPictureTiming(const SEIPictureTiming& sei, const SEIBuf WRITE_CODE(sei.m_cpbDelayOffset[i], bp.m_initialCpbRemovalDelayLength, "cpb_delay_offset[ i ]"); WRITE_CODE(sei.m_dpbDelayOffset[i], bp.m_initialCpbRemovalDelayLength, "dpb_delay_offset[ i ]"); } -#else - for (int i = 0; i < bp.m_bpCpbCnt; i++) - { - WRITE_CODE(sei.m_cpbAltInitialCpbRemovalDelayDelta[i], bp.m_initialCpbRemovalDelayLength, - "cpb_alt_initial_cpb_removal_delay_delta[ i ]"); - WRITE_CODE(sei.m_cpbAltInitialCpbRemovalOffsetDelta[i], bp.m_initialCpbRemovalDelayLength, - "cpb_alt_initial_cpb_removal_offset_delta[ i ]"); - } - WRITE_CODE(sei.m_cpbDelayOffset, bp.m_initialCpbRemovalDelayLength, "cpb_delay_offset"); - WRITE_CODE(sei.m_dpbDelayOffset, bp.m_initialCpbRemovalDelayLength, "dpb_delay_offset"); #endif } } @@ -384,14 +415,10 @@ void SEIWriter::xWriteSEIPictureTiming(const SEIPictureTiming& sei, const SEIBuf } if( sei.m_cpbRemovalDelayDeltaEnabledFlag[i] ) { -#if JVET_Q0216 if ((bp.m_numCpbRemovalDelayDeltas - 1) > 0) { WRITE_CODE(sei.m_cpbRemovalDelayDeltaIdx[i], ceilLog2(bp.m_numCpbRemovalDelayDeltas), "cpb_removal_delay_delta_idx[i]"); } -#else - WRITE_CODE(sei.m_cpbRemovalDelayDeltaIdx[i], ceilLog2(bp.m_numCpbRemovalDelayDeltas), "cpb_removal_delay_delta_idx[i]"); -#endif } else { @@ -400,11 +427,7 @@ void SEIWriter::xWriteSEIPictureTiming(const SEIPictureTiming& sei, const SEIBuf } } WRITE_CODE( sei.m_picDpbOutputDelay, bp.m_dpbOutputDelayLength, "dpb_output_delay" ); -#if JVET_Q0221 if (bp.m_bpDecodingUnitHrdParamsPresentFlag && bp.m_decodingUnitDpbDuParamsInPicTimingSeiFlag) -#else - if (bp.m_bpDecodingUnitHrdParamsPresentFlag) -#endif { WRITE_CODE( sei.m_picDpbOutputDuDelay, bp.m_dpbOutputDelayDuLength, "pic_dpb_output_du_delay" ); @@ -434,9 +457,7 @@ void SEIWriter::xWriteSEIPictureTiming(const SEIPictureTiming& sei, const SEIBuf } } } -#if JVET_Q0818_PT_SEI WRITE_UVLC( sei.m_ptDisplayElementalPeriodsMinus1, "pt_display_elemental_periods_minus1" ); -#endif } void SEIWriter::xWriteSEIFrameFieldInfo(const SEIFrameFieldInfo& sei) @@ -469,7 +490,6 @@ void SEIWriter::xWriteSEIDependentRAPIndication(const SEIDependentRAPIndication& // intentionally empty } -#if JVET_P0190_SCALABLE_NESTING_SEI void SEIWriter::xWriteSEIScalableNesting(OutputBitstream& bs, const SEIScalableNesting& sei, const SPS *sps) { WRITE_FLAG(sei.m_nestingOlsFlag, "nesting_ols_flag"); @@ -504,7 +524,6 @@ void SEIWriter::xWriteSEIScalableNesting(OutputBitstream& bs, const SEIScalableN HRD hrd; writeSEImessages(bs, sei.m_nestedSEIs, sps, hrd, true, 0); } -#endif void SEIWriter::xWriteSEIFramePacking(const SEIFramePacking& sei) { @@ -588,9 +607,9 @@ void SEIWriter::xWriteSEIEquirectangularProjection(const SEIEquirectangularProje WRITE_CODE( 0, 2, "erp_reserved_zero_2bits" ); if ( sei.m_erpGuardBandFlag == 1) { - WRITE_CODE( sei.m_erpGuardBandType, 3, "erp_guard_band_type" ); - WRITE_CODE( sei.m_erpLeftGuardBandWidth, 8, "erp_left_guard_band_width" ); - WRITE_CODE( sei.m_erpRightGuardBandWidth, 8, "erp_right_guard_band_width" ); + WRITE_CODE( sei.m_erpGuardBandType, 3, "erp_guard_band_type" ); + WRITE_CODE( sei.m_erpLeftGuardBandWidth, 8, "erp_left_guard_band_width" ); + WRITE_CODE( sei.m_erpRightGuardBandWidth, 8, "erp_right_guard_band_width" ); } } } @@ -602,9 +621,9 @@ void SEIWriter::xWriteSEISphereRotation(const SEISphereRotation &sei) { WRITE_FLAG( sei.m_sphereRotationPersistenceFlag, "sphere_rotation_persistence_flag" ); WRITE_CODE( 0, 6, "sphere_rotation_reserved_zero_6bits" ); - WRITE_SCODE(sei.m_sphereRotationYaw, 32, "sphere_rotation_yaw" ); - WRITE_SCODE(sei.m_sphereRotationPitch, 32, "sphere_rotation_pitch" ); - WRITE_SCODE(sei.m_sphereRotationRoll, 32, "sphere_rotation_roll" ); + WRITE_SCODE(sei.m_sphereRotationYaw, 32, "sphere_rotation_yaw" ); + WRITE_SCODE(sei.m_sphereRotationPitch, 32, "sphere_rotation_pitch" ); + WRITE_SCODE(sei.m_sphereRotationRoll, 32, "sphere_rotation_roll" ); } } @@ -620,9 +639,9 @@ void SEIWriter::xWriteSEIOmniViewport(const SEIOmniViewport &sei) for(uint32_t region=0; region<numRegions; region++) { const SEIOmniViewport::OmniViewport &viewport=sei.m_omniViewportRegions[region]; - WRITE_SCODE( viewport.azimuthCentre, 32, "omni_viewport_azimuth_centre" ); - WRITE_SCODE( viewport.elevationCentre, 32, "omni_viewport_elevation_centre" ); - WRITE_SCODE( viewport.tiltCentre, 32, "omni_viewport_tilt_center" ); + WRITE_SCODE( viewport.azimuthCentre, 32, "omni_viewport_azimuth_centre" ); + WRITE_SCODE( viewport.elevationCentre, 32, "omni_viewport_elevation_centre" ); + WRITE_SCODE( viewport.tiltCentre, 32, "omni_viewport_tilt_center" ); WRITE_CODE( viewport.horRange, 32, "omni_viewport_hor_range[i]" ); WRITE_CODE( viewport.verRange, 32, "omni_viewport_ver_range[i]" ); } @@ -643,7 +662,7 @@ void SEIWriter::xWriteSEIRegionWisePacking(const SEIRegionWisePacking &sei) WRITE_CODE( (uint32_t)sei.m_packedPictureWidth, 16, "packed_picture_width" ); WRITE_CODE( (uint32_t)sei.m_packedPictureHeight, 16, "packed_picture_height" ); for( int i=0; i < sei.m_numPackedRegions; i++ ) - { + { WRITE_CODE( 0, 4, "rwp_reserved_zero_4bits" ); WRITE_CODE( (uint32_t)sei.m_rwpTransformType[i], 3, "rwp_tTransform_type" ); WRITE_FLAG( sei.m_rwpGuardBandFlag[i], "rwp_guard_band_flag" ); @@ -678,44 +697,33 @@ void SEIWriter::xWriteSEIGeneralizedCubemapProjection(const SEIGeneralizedCubema if (!sei.m_gcmpCancelFlag) { WRITE_FLAG( sei.m_gcmpPersistenceFlag, "gcmp_persistence_flag" ); - WRITE_CODE( sei.m_gcmpPackingType, 3, "gcmp_packing_type" ); + WRITE_CODE( sei.m_gcmpPackingType, 3, "gcmp_packing_type" ); WRITE_CODE( sei.m_gcmpMappingFunctionType, 2, "gcmp_mapping_function_type" ); int numFace = sei.m_gcmpPackingType == 4 || sei.m_gcmpPackingType == 5 ? 5 : 6; for (int i = 0; i < numFace; i++) { - WRITE_CODE( sei.m_gcmpFaceIndex[i], 3, "gcmp_face_index" ); - WRITE_CODE( sei.m_gcmpFaceRotation[i], 2, "gcmp_face_rotation" ); + WRITE_CODE( sei.m_gcmpFaceIndex[i], 3, "gcmp_face_index" ); + WRITE_CODE( sei.m_gcmpFaceRotation[i], 2, "gcmp_face_rotation" ); if (sei.m_gcmpMappingFunctionType == 2) { - WRITE_CODE( sei.m_gcmpFunctionCoeffU[i], 7, "gcmp_function_coeff_u" ); + WRITE_CODE( sei.m_gcmpFunctionCoeffU[i], 7, "gcmp_function_coeff_u" ); WRITE_FLAG( sei.m_gcmpFunctionUAffectedByVFlag[i], "gcmp_function_u_affected_by_v_flag" ); - WRITE_CODE( sei.m_gcmpFunctionCoeffV[i], 7, "gcmp_function_coeff_v" ); + WRITE_CODE( sei.m_gcmpFunctionCoeffV[i], 7, "gcmp_function_coeff_v" ); WRITE_FLAG( sei.m_gcmpFunctionVAffectedByUFlag[i], "gcmp_function_v_affected_by_u_flag" ); } } WRITE_FLAG( sei.m_gcmpGuardBandFlag, "gcmp_guard_band_flag" ); if (sei.m_gcmpGuardBandFlag) { -#if JVET_Q0343_GCMP_GUARD_BAND_TYPE WRITE_CODE( sei.m_gcmpGuardBandType, 3, "gcmp_guard_band_type" ); WRITE_FLAG( sei.m_gcmpGuardBandBoundaryExteriorFlag, "gcmp_guard_band_boundary_exterior_flag" ); -#else - WRITE_FLAG( sei.m_gcmpGuardBandBoundaryType, "gcmp_guard_band_boundary_type" ); -#endif - WRITE_CODE( sei.m_gcmpGuardBandSamplesMinus1, 4, "gcmp_guard_band_samples_minus1" ); + WRITE_CODE( sei.m_gcmpGuardBandSamplesMinus1, 4, "gcmp_guard_band_samples_minus1" ); } } } -#if JVET_Q0630_SUBPIC_LEVEL void SEIWriter::xWriteSEISubpictureLevelInfo(const SEISubpicureLevelInfo &sei) -#else -void SEIWriter::xWriteSEISubpictureLevelInfo(const SEISubpicureLevelInfo &sei, const SPS* sps) -#endif { -#if !JVET_Q0630_SUBPIC_LEVEL - WRITE_CODE( (uint32_t)sei.m_sliSeqParameterSetId, 4, "sli_seq_parameter_set_id"); -#endif CHECK(sei.m_numRefLevels < 1, "SEISubpicureLevelInfo: numRefLevels must be greater than zero"); CHECK(sei.m_numRefLevels != (int)sei.m_refLevelIdc.size(), "SEISubpicureLevelInfo: numRefLevels must be equal to the number of levels"); if (sei.m_explicitFractionPresentFlag) @@ -724,7 +732,6 @@ void SEIWriter::xWriteSEISubpictureLevelInfo(const SEISubpicureLevelInfo &sei, c } WRITE_CODE( (uint32_t)sei.m_numRefLevels - 1, 3, "num_ref_levels_minus1"); WRITE_FLAG( sei.m_explicitFractionPresentFlag, "explicit_fraction_present_flag"); -#if JVET_Q0630_SUBPIC_LEVEL if (sei.m_explicitFractionPresentFlag) { WRITE_UVLC( sei.m_numSubpics -1 , "sli_num_subpics_minus1"); @@ -733,20 +740,14 @@ void SEIWriter::xWriteSEISubpictureLevelInfo(const SEISubpicureLevelInfo &sei, c WRITE_FLAG( 0, "sli_alignment_zero_bit"); } } -#endif for (int i=0; i<sei.m_numRefLevels; i++) { WRITE_CODE( (uint32_t)sei.m_refLevelIdc[i], 8, "ref_level_idc[i]"); if (sei.m_explicitFractionPresentFlag) { -#if !JVET_Q0630_SUBPIC_LEVEL - CHECK(sps->getNumSubPics() != (int)sei.m_refLevelFraction[i].size(), "SEISubpicureLevelInfo: number of fractions differs from number of subpictures"); - for (int j = 0; j < sps->getNumSubPics(); j++) -#else CHECK(sei.m_numSubpics != (int)sei.m_refLevelFraction[i].size(), "SEISubpicureLevelInfo: number of fractions differs from number of subpictures"); for (int j = 0; j < sei.m_numSubpics; j++) -#endif { WRITE_CODE( (uint32_t)sei.m_refLevelFraction[i][j], 8, "ref_level_fraction_minus1[i][j]"); } @@ -818,7 +819,7 @@ void SEIWriter::xWriteSEIFilmGrainCharacteristics(const SEIFilmGrainCharacterist assert(numIntensityIntervals <= 256); assert(numModelValues <= 256); WRITE_CODE(numIntensityIntervals - 1, 8, "num_intensity_intervals_minus1[c]"); - WRITE_CODE(numModelValues - 1, 8, "num_model_values_minus1[c]"); + WRITE_CODE(numModelValues - 1, 3, "num_model_values_minus1[c]"); for (uint32_t interval = 0; interval<numIntensityIntervals; interval++) { const SEIFilmGrainCharacteristics::CompModelIntensityValues &cmiv = cm.intensityValues[interval]; diff --git a/source/Lib/EncoderLib/SEIwrite.h b/source/Lib/EncoderLib/SEIwrite.h index fe174dbda888accb199b08e3c40002f8775467e1..54315c0d1e7365c82f4ad6a41449385366a8beaf 100644 --- a/source/Lib/EncoderLib/SEIwrite.h +++ b/source/Lib/EncoderLib/SEIwrite.h @@ -59,9 +59,7 @@ protected: void xWriteSEIPictureTiming(const SEIPictureTiming& sei, const SEIBufferingPeriod& bp, const uint32_t temporalId); void xWriteSEIFrameFieldInfo(const SEIFrameFieldInfo& sei); void xWriteSEIDependentRAPIndication(const SEIDependentRAPIndication& sei); -#if JVET_P0190_SCALABLE_NESTING_SEI void xWriteSEIScalableNesting(OutputBitstream& bs, const SEIScalableNesting& sei, const SPS *sps); -#endif void xWriteSEIFramePacking(const SEIFramePacking& sei); void xWriteSEIMasteringDisplayColourVolume( const SEIMasteringDisplayColourVolume& sei); #if U0033_ALTERNATIVE_TRANSFER_CHARACTERISTICS_SEI @@ -72,11 +70,7 @@ protected: void xWriteSEIOmniViewport (const SEIOmniViewport& sei); void xWriteSEIRegionWisePacking (const SEIRegionWisePacking &sei); void xWriteSEIGeneralizedCubemapProjection (const SEIGeneralizedCubemapProjection &sei); -#if JVET_Q0630_SUBPIC_LEVEL void xWriteSEISubpictureLevelInfo (const SEISubpicureLevelInfo &sei); -#else - void xWriteSEISubpictureLevelInfo (const SEISubpicureLevelInfo &sei, const SPS* sps); -#endif void xWriteSEISampleAspectRatioInfo (const SEISampleAspectRatioInfo &sei); void xWriteSEIUserDataRegistered(const SEIUserDataRegistered& sei); diff --git a/source/Lib/EncoderLib/VLCWriter.cpp b/source/Lib/EncoderLib/VLCWriter.cpp index 9b2029ca76158f3d2387ea061b9ca1de4ddca50e..4b9e10b6559fff4d3d20fc2c8e58a23a76f3c568 100644 --- a/source/Lib/EncoderLib/VLCWriter.cpp +++ b/source/Lib/EncoderLib/VLCWriter.cpp @@ -179,12 +179,20 @@ void AUDWriter::codeAUD(OutputBitstream& bs, const int pictureType) xWriteRbspTrailingBits(); } -void HLSWriter::xCodeRefPicList( const ReferencePictureList* rpl, bool isLongTermPresent, uint32_t ltLsbBitsCount, const bool isForbiddenZeroDeltaPoc ) +#if JVET_R0059_RPL_CLEANUP +void HLSWriter::xCodeRefPicList( const ReferencePictureList* rpl, bool isLongTermPresent, uint32_t ltLsbBitsCount, const bool isForbiddenZeroDeltaPoc, int rplIdx) +#else +void HLSWriter::xCodeRefPicList( const ReferencePictureList* rpl, bool isLongTermPresent, uint32_t ltLsbBitsCount, const bool isForbiddenZeroDeltaPoc) +#endif { uint32_t numRefPic = rpl->getNumberOfShorttermPictures() + rpl->getNumberOfLongtermPictures() + rpl->getNumberOfInterLayerPictures(); WRITE_UVLC( numRefPic, "num_ref_entries[ listIdx ][ rplsIdx ]" ); +#if JVET_R0059_RPL_CLEANUP + if (isLongTermPresent && rplIdx != -1) +#else if (isLongTermPresent) +#endif { WRITE_FLAG(rpl->getLtrpInSliceHeaderFlag(), "ltrp_in_slice_header_flag[ listIdx ][ rplsIdx ]"); } @@ -224,9 +232,9 @@ void HLSWriter::xCodeRefPicList( const ReferencePictureList* rpl, bool isLongTer prevDelta = rpl->getRefPicIdentifier(ii); } unsigned int absDeltaValue = (deltaValue < 0) ? 0 - deltaValue : deltaValue; - if( isForbiddenZeroDeltaPoc ) + if (isForbiddenZeroDeltaPoc || ii == 0) { - CHECK( !absDeltaValue, "Zero delta POC is not used without WP" ); + CHECK(!absDeltaValue, "Zero delta POC is not used without WP or is the 0-th entry"); WRITE_UVLC( absDeltaValue - 1, "abs_delta_poc_st[ listIdx ][ rplsIdx ][ i ]" ); } else @@ -247,18 +255,18 @@ void HLSWriter::codePPS( const PPS* pcPPS ) #if ENABLE_TRACING xTracePPSHeader (); #endif - +#if JVET_R0266_DESC + WRITE_CODE( pcPPS->getPPSId(), 6, "pps_pic_parameter_set_id" ); +#else WRITE_UVLC( pcPPS->getPPSId(), "pps_pic_parameter_set_id" ); +#endif WRITE_CODE( pcPPS->getSPSId(), 4, "pps_seq_parameter_set_id" ); -#if SPS_ID_CHECK WRITE_FLAG( pcPPS->getMixedNaluTypesInPicFlag() ? 1 : 0, "mixed_nalu_types_in_pic_flag" ); -#endif WRITE_UVLC( pcPPS->getPicWidthInLumaSamples(), "pic_width_in_luma_samples" ); WRITE_UVLC( pcPPS->getPicHeightInLumaSamples(), "pic_height_in_luma_samples" ); Window conf = pcPPS->getConformanceWindow(); -#if JVET_Q0260_CONFORMANCE_WINDOW_IN_SPS WRITE_FLAG(conf.getWindowEnabledFlag(), "pps_conformance_window_flag"); if (conf.getWindowEnabledFlag()) { @@ -267,61 +275,63 @@ void HLSWriter::codePPS( const PPS* pcPPS ) WRITE_UVLC(conf.getWindowTopOffset(), "pps_conf_win_top_offset"); WRITE_UVLC(conf.getWindowBottomOffset(), "pps_conf_win_bottom_offset"); } -#else - WRITE_FLAG( conf.getWindowEnabledFlag(), "conformance_window_flag" ); - if( conf.getWindowEnabledFlag() ) - { - WRITE_UVLC( conf.getWindowLeftOffset(), "conf_win_left_offset" ); - WRITE_UVLC( conf.getWindowRightOffset(), "conf_win_right_offset" ); - WRITE_UVLC( conf.getWindowTopOffset(), "conf_win_top_offset" ); - WRITE_UVLC( conf.getWindowBottomOffset(), "conf_win_bottom_offset" ); - } -#endif Window scalingWindow = pcPPS->getScalingWindow(); WRITE_FLAG( scalingWindow.getWindowEnabledFlag(), "scaling_window_flag" ); if( scalingWindow.getWindowEnabledFlag() ) { +#if JVET_R0114_NEGATIVE_SCALING_WINDOW_OFFSETS + WRITE_SVLC( scalingWindow.getWindowLeftOffset(), "pps_scaling_win_left_offset" ); + WRITE_SVLC( scalingWindow.getWindowRightOffset(), "pps_scaling_win_right_offset" ); + WRITE_SVLC( scalingWindow.getWindowTopOffset(), "pps_scaling_win_top_offset" ); + WRITE_SVLC( scalingWindow.getWindowBottomOffset(), "pps_scaling_win_bottom_offset" ); +#else WRITE_UVLC( scalingWindow.getWindowLeftOffset(), "scaling_win_left_offset" ); WRITE_UVLC( scalingWindow.getWindowRightOffset(), "scaling_win_right_offset" ); WRITE_UVLC( scalingWindow.getWindowTopOffset(), "scaling_win_top_offset" ); WRITE_UVLC( scalingWindow.getWindowBottomOffset(), "scaling_win_bottom_offset" ); +#endif } WRITE_FLAG( pcPPS->getOutputFlagPresentFlag() ? 1 : 0, "output_flag_present_flag" ); -#if JVET_Q0119_CLEANUPS +#if JVET_R0186_CLEANUP + WRITE_FLAG( pcPPS->getNoPicPartitionFlag() ? 1 : 0, "pps_no_pic_partition_flag" ); +#endif WRITE_FLAG( pcPPS->getSubPicIdMappingInPpsFlag() ? 1 : 0, "subpic_id_mapping_in_pps_flag" ); if( pcPPS->getSubPicIdMappingInPpsFlag() ) -#else - WRITE_FLAG(pcPPS->getSubPicIdSignallingPresentFlag(), "pps_subpic_id_signalling_present_flag"); - if( pcPPS->getSubPicIdSignallingPresentFlag() ) -#endif { + CHECK(pcPPS->getNumSubPics() < 1, "PPS: NumSubPics cannot be less than 1"); +#if JVET_R0186_CLEANUP + if( !pcPPS->getNoPicPartitionFlag() ) + { + WRITE_UVLC(pcPPS->getNumSubPics() - 1, "pps_num_subpics_minus1"); + } +#else WRITE_UVLC( pcPPS->getNumSubPics() - 1, "pps_num_subpics_minus1" ); - +#endif + CHECK(pcPPS->getSubPicIdLen() < 1, "PPS: SubPicIdLen cannot be less than 1"); WRITE_UVLC( pcPPS->getSubPicIdLen() - 1, "pps_subpic_id_len_minus1" ); -#if JVET_Q0169_SUBPIC_LEN_CONFORM CHECK((1 << pcPPS->getSubPicIdLen()) < pcPPS->getNumSubPics(), "pps_subpic_id_len exceeds valid range"); -#endif for( int picIdx = 0; picIdx < pcPPS->getNumSubPics( ); picIdx++ ) { WRITE_CODE( pcPPS->getSubPicId(picIdx), pcPPS->getSubPicIdLen( ), "pps_subpic_id[i]" ); } } - +#if !JVET_R0186_CLEANUP WRITE_FLAG( pcPPS->getNoPicPartitionFlag( ) ? 1 : 0, "no_pic_partition_flag" ); +#endif if( !pcPPS->getNoPicPartitionFlag() ) { int colIdx, rowIdx; // CTU size - required to match size in SPS WRITE_CODE( pcPPS->getLog2CtuSize() - 5, 2, "pps_log2_ctu_size_minus5" ); - + // number of explicit tile columns/rows WRITE_UVLC( pcPPS->getNumExpTileColumns() - 1, "num_exp_tile_columns_minus1" ); WRITE_UVLC( pcPPS->getNumExpTileRows() - 1, "num_exp_tile_rows_minus1" ); - + // tile sizes for( colIdx = 0; colIdx < pcPPS->getNumExpTileColumns(); colIdx++ ) { @@ -331,62 +341,44 @@ void HLSWriter::codePPS( const PPS* pcPPS ) { WRITE_UVLC( pcPPS->getTileRowHeight( rowIdx ) - 1, "tile_row_height_minus1[i]" ); } - + // rectangular slice signalling -#if JVET_Q0289_BUGFIX_RECT_SLICE_FLAG if (pcPPS->getNumTiles() > 1) { +#if JVET_R0113_AND_JVET_R0106_PPS_CLEANUP + WRITE_FLAG(pcPPS->getLoopFilterAcrossTilesEnabledFlag(), "pps_loop_filter_across_tiles_enabled_flag"); +#endif WRITE_FLAG(pcPPS->getRectSliceFlag() ? 1 : 0, "rect_slice_flag"); } -#else - WRITE_FLAG( pcPPS->getRectSliceFlag( ) ? 1 : 0, "rect_slice_flag"); -#endif if (pcPPS->getRectSliceFlag()) { WRITE_FLAG(pcPPS->getSingleSlicePerSubPicFlag( ) ? 1 : 0, "single_slice_per_subpic_flag"); } if (pcPPS->getRectSliceFlag() & !(pcPPS->getSingleSlicePerSubPicFlag())) - { + { WRITE_UVLC( pcPPS->getNumSlicesInPic( ) - 1, "num_slices_in_pic_minus1" ); -#if JVET_Q0218_PROPOSAL1 if ((pcPPS->getNumSlicesInPic() - 1) > 0) { WRITE_FLAG(pcPPS->getTileIdxDeltaPresentFlag() ? 1 : 0, "tile_idx_delta_present_flag"); } -#else - WRITE_FLAG(pcPPS->getTileIdxDeltaPresentFlag() ? 1 : 0, "tile_idx_delta_present_flag"); -#endif - + // write rectangular slice parameters for( int i = 0; i < pcPPS->getNumSlicesInPic()-1; i++ ) { // complete tiles within a single slice -#if JVET_Q0244 if( pcPPS->getNumTileColumns() > 1 ) { -#endif WRITE_UVLC( pcPPS->getSliceWidthInTiles( i ) - 1, "slice_width_in_tiles_minus1[i]" ); -#if JVET_Q0244 } -#endif -#if JVET_Q0480_RASTER_RECT_SLICES if( pcPPS->getTileIdxDeltaPresentFlag() || ( (pcPPS->getSliceTileIdx( i ) % pcPPS->getNumTileColumns()) == 0 ) ) { -#if JVET_Q0244 if( pcPPS->getNumTileRows() > 1 ) { -#endif WRITE_UVLC( pcPPS->getSliceHeightInTiles( i ) - 1, "slice_height_in_tiles_minus1[i]" ); -#if JVET_Q0244 } -#endif } -#else - WRITE_UVLC( pcPPS->getSliceHeightInTiles( i ) - 1, "slice_height_in_tiles_minus1[i]" ); -#endif // multiple slices within a single tile special case -#if JVET_Q0203_MULTI_SLICE_IN_TILE if( pcPPS->getSliceWidthInTiles(i) == 1 && pcPPS->getSliceHeightInTiles(i) == 1 && pcPPS->getTileRowHeight(pcPPS->getSliceTileIdx(i) / pcPPS->getNumTileColumns()) > 1 ) { uint32_t numExpSliceInTile = pcPPS->getNumSlicesInTile(i) - 1; @@ -407,23 +399,11 @@ void HLSWriter::codePPS( const PPS* pcPPS ) } i += (pcPPS->getNumSlicesInTile(i) - 1); } -#else - if( pcPPS->getSliceWidthInTiles( i ) == 1 && pcPPS->getSliceHeightInTiles( i ) == 1 ) - { - WRITE_UVLC( pcPPS->getNumSlicesInTile( i ) - 1, "num_slices_in_tile_minus1[i]" ); - uint32_t numSlicesInTile = pcPPS->getNumSlicesInTile( i ); - for( int j = 0; j < numSlicesInTile-1; j++ ) - { - WRITE_UVLC( pcPPS->getSliceHeightInCtu( i ) - 1, "slice_height_in_ctu_minus1[i]" ); - i++; - } - } -#endif // tile index offset to start of next slice - if( i < pcPPS->getNumSlicesInPic()-1 ) + if( i < pcPPS->getNumSlicesInPic()-1 ) { - if( pcPPS->getTileIdxDeltaPresentFlag() ) + if( pcPPS->getTileIdxDeltaPresentFlag() ) { int32_t tileIdxDelta = pcPPS->getSliceTileIdx( i + 1 ) - pcPPS->getSliceTileIdx( i ); WRITE_SVLC( tileIdxDelta, "tile_idx_delta[i]" ); @@ -432,14 +412,20 @@ void HLSWriter::codePPS( const PPS* pcPPS ) } } +#if !JVET_R0113_AND_JVET_R0106_PPS_CLEANUP // loop filtering across slice/tile controls WRITE_FLAG( pcPPS->getLoopFilterAcrossTilesEnabledFlag(), "loop_filter_across_tiles_enabled_flag"); +#endif +#if JVET_R0247_PPS_LP_FTR_ACROSS_SLICES_FLAG_CLEANUP + if (pcPPS->getRectSliceFlag() == 0 || pcPPS->getSingleSlicePerSubPicFlag() || pcPPS->getNumSlicesInPic() > 1) + { +#endif WRITE_FLAG( pcPPS->getLoopFilterAcrossSlicesEnabledFlag(), "loop_filter_across_slices_enabled_flag"); +#if JVET_R0247_PPS_LP_FTR_ACROSS_SLICES_FLAG_CLEANUP + } +#endif } -#if !JVET_Q0151_Q0205_ENTRYPOINTS - WRITE_FLAG( pcPPS->getEntropyCodingSyncEnabledFlag() ? 1 : 0, "entropy_coding_sync_enabled_flag" ); -#endif WRITE_FLAG( pcPPS->getCabacInitPresentFlag() ? 1 : 0, "cabac_init_present_flag" ); WRITE_UVLC( pcPPS->getNumRefIdxL0DefaultActive()-1, "num_ref_idx_l0_default_active_minus1"); WRITE_UVLC( pcPPS->getNumRefIdxL1DefaultActive()-1, "num_ref_idx_l1_default_active_minus1"); @@ -447,15 +433,10 @@ void HLSWriter::codePPS( const PPS* pcPPS ) WRITE_SVLC( pcPPS->getPicInitQPMinus26(), "init_qp_minus26"); -#if !JVET_Q0183_SPS_TRANSFORM_SKIP_MODE_CONTROL - WRITE_UVLC( pcPPS->getLog2MaxTransformSkipBlockSize() - 2, "log2_transform_skip_max_size_minus2"); -#endif WRITE_FLAG( pcPPS->getUseDQP() ? 1 : 0, "cu_qp_delta_enabled_flag" ); -#if JVET_Q0420_PPS_CHROMA_TOOL_FLAG WRITE_FLAG(pcPPS->getPPSChromaToolFlag() ? 1 : 0, "pps_chroma_tool_offsets_present_flag"); if (pcPPS->getPPSChromaToolFlag()) { -#endif WRITE_SVLC( pcPPS->getQpOffset(COMPONENT_Cb), "pps_cb_qp_offset" ); WRITE_SVLC( pcPPS->getQpOffset(COMPONENT_Cr), "pps_cr_qp_offset" ); WRITE_FLAG(pcPPS->getJointCbCrQpOffsetPresentFlag() ? 1 : 0, "pps_joint_cbcr_qp_offset_present_flag"); @@ -481,9 +462,7 @@ void HLSWriter::codePPS( const PPS* pcPPS ) } } } -#if JVET_Q0420_PPS_CHROMA_TOOL_FLAG } -#endif WRITE_FLAG( pcPPS->getUseWP() ? 1 : 0, "weighted_pred_flag" ); // Use of Weighting Prediction (P_SLICE) WRITE_FLAG( pcPPS->getWPBiPred() ? 1 : 0, "weighted_bipred_flag" ); // Use of Weighting Bi-Prediction (B_SLICE) @@ -493,20 +472,36 @@ void HLSWriter::codePPS( const PPS* pcPPS ) { WRITE_FLAG( pcPPS->getDeblockingFilterOverrideEnabledFlag() ? 1 : 0, "deblocking_filter_override_enabled_flag" ); WRITE_FLAG( pcPPS->getPPSDeblockingFilterDisabledFlag() ? 1 : 0, "pps_deblocking_filter_disabled_flag" ); +#if JVET_R0113_AND_JVET_R0106_PPS_CLEANUP + if (!pcPPS->getNoPicPartitionFlag() && pcPPS->getDeblockingFilterOverrideEnabledFlag()) + { + WRITE_FLAG(pcPPS->getDbfInfoInPhFlag() ? 1 : 0, "pps_dbf_info_in_ph_flag"); + } +#endif if(!pcPPS->getPPSDeblockingFilterDisabledFlag()) { WRITE_SVLC( pcPPS->getDeblockingFilterBetaOffsetDiv2(), "pps_beta_offset_div2" ); WRITE_SVLC( pcPPS->getDeblockingFilterTcOffsetDiv2(), "pps_tc_offset_div2" ); -#if JVET_Q0121_DEBLOCKING_CONTROL_PARAMETERS WRITE_SVLC( pcPPS->getDeblockingFilterCbBetaOffsetDiv2(), "pps_cb_beta_offset_div2" ); WRITE_SVLC( pcPPS->getDeblockingFilterCbTcOffsetDiv2(), "pps_cb_tc_offset_div2" ); WRITE_SVLC( pcPPS->getDeblockingFilterCrBetaOffsetDiv2(), "pps_cr_beta_offset_div2" ); WRITE_SVLC( pcPPS->getDeblockingFilterCrTcOffsetDiv2(), "pps_cr_tc_offset_div2" ); -#endif } } -#if JVET_Q0819_PH_CHANGES +#if JVET_R0113_AND_JVET_R0106_PPS_CLEANUP + if (!pcPPS->getNoPicPartitionFlag()) + { + WRITE_FLAG(pcPPS->getRplInfoInPhFlag() ? 1 : 0, "pps_rpl_info_in_ph_flag"); + WRITE_FLAG(pcPPS->getSaoInfoInPhFlag() ? 1 : 0, "pps_sao_info_in_ph_flag"); + WRITE_FLAG(pcPPS->getAlfInfoInPhFlag() ? 1 : 0, "pps_alf_info_in_ph_flag"); + if ((pcPPS->getUseWP() || pcPPS->getWPBiPred()) && pcPPS->getRplInfoInPhFlag()) + { + WRITE_FLAG(pcPPS->getWpInfoInPhFlag() ? 1 : 0, "pps_wp_info_in_ph_flag"); + } + WRITE_FLAG(pcPPS->getQpDeltaInfoInPhFlag() ? 1 : 0, "pps_qp_delta_info_in_ph_flag"); + } +#else WRITE_FLAG(pcPPS->getRplInfoInPhFlag() ? 1 : 0, "rpl_info_in_ph_flag"); if (pcPPS->getDeblockingFilterOverrideEnabledFlag()) { @@ -521,24 +516,6 @@ void HLSWriter::codePPS( const PPS* pcPPS ) WRITE_FLAG(pcPPS->getQpDeltaInfoInPhFlag() ? 1 : 0, "qp_delta_info_in_ph_flag"); #endif -#if !JVET_Q0482_REMOVE_CONSTANT_PARAMS - WRITE_FLAG( pcPPS->getConstantSliceHeaderParamsEnabledFlag(), "constant_slice_header_params_enabled_flag"); - if ( pcPPS->getConstantSliceHeaderParamsEnabledFlag() ) { - WRITE_CODE( pcPPS->getPPSDepQuantEnabledIdc(), 2, "pps_dep_quant_enabled_idc"); - WRITE_CODE( pcPPS->getPPSRefPicListSPSIdc0(), 2, "pps_ref_pic_list_sps_idc[0]"); - WRITE_CODE( pcPPS->getPPSRefPicListSPSIdc1(), 2, "pps_ref_pic_list_sps_idc[1]"); - WRITE_CODE( pcPPS->getPPSMvdL1ZeroIdc(), 2, "pps_mvd_l1_zero_idc"); - WRITE_CODE( pcPPS->getPPSCollocatedFromL0Idc(), 2, "pps_collocated_from_l0_idc"); - WRITE_UVLC( pcPPS->getPPSSixMinusMaxNumMergeCandPlus1(), "pps_six_minus_max_num_merge_cand_plus1"); -#if !JVET_Q0806 - WRITE_UVLC( pcPPS->getPPSMaxNumMergeCandMinusMaxNumTriangleCandPlus1(), "pps_max_num_merge_cand_minus_max_num_triangle_cand_plus1"); -#else - WRITE_UVLC(pcPPS->getPPSMaxNumMergeCandMinusMaxNumGeoCandPlus1(), "pps_max_num_merge_cand_minus_max_num_gpm_cand_plus1"); -#endif - } -#endif - - WRITE_FLAG( pcPPS->getPictureHeaderExtensionPresentFlag() ? 1 : 0, "picture_header_extension_present_flag"); WRITE_FLAG( pcPPS->getSliceHeaderExtensionPresentFlag() ? 1 : 0, "slice_header_extension_present_flag"); @@ -549,52 +526,10 @@ void HLSWriter::codePPS( const PPS* pcPPS ) if (pps_extension_present_flag) { -#if !REMOVE_PPS_REXT -#if ENABLE_TRACING /*|| RExt__DECODER_DEBUG_BIT_STATISTICS*/ - static const char *syntaxStrings[]={ "pps_range_extension_flag", - "pps_multilayer_extension_flag", - "pps_extension_6bits[0]", - "pps_extension_6bits[1]", - "pps_extension_6bits[2]", - "pps_extension_6bits[3]", - "pps_extension_6bits[4]", - "pps_extension_6bits[5]" }; -#endif - - for(int i=0; i<NUM_PPS_EXTENSION_FLAGS; i++) - { - WRITE_FLAG( pps_extension_flags[i]?1:0, syntaxStrings[i] ); - } - - for(int i=0; i<NUM_PPS_EXTENSION_FLAGS; i++) // loop used so that the order is determined by the enum. - { - if (pps_extension_flags[i]) - { - switch (PPSExtensionFlagIndex(i)) - { - case PPS_EXT__REXT: - { - const PPSRExt &ppsRangeExtension = pcPPS->getPpsRangeExtension(); - - WRITE_FLAG((ppsRangeExtension.getCrossComponentPredictionEnabledFlag() ? 1 : 0), "cross_component_prediction_enabled_flag" ); -#if !JVET_Q0441_SAO_MOD_12_BIT - WRITE_UVLC( ppsRangeExtension.getLog2SaoOffsetScale(CHANNEL_TYPE_LUMA), "log2_sao_offset_scale_luma" ); - WRITE_UVLC( ppsRangeExtension.getLog2SaoOffsetScale(CHANNEL_TYPE_CHROMA), "log2_sao_offset_scale_chroma" ); -#endif - } - break; - default: - CHECK(pps_extension_flags[i]==false, "Unknown PPS extension signalled"); // Should never get here with an active PPS extension flag. - break; - } // switch - } // if flag present - } // loop over PPS flags -#else for(int i=0; i<NUM_PPS_EXTENSION_FLAGS; i++) { WRITE_FLAG( pps_extension_flags[i]?1:0, "pps_extension_data_flag" ); } -#endif } // pps_extension_present_flag is non-zero xWriteRbspTrailingBits(); } @@ -631,19 +566,13 @@ void HLSWriter::codeAlfAps( APS* pcAPS ) WRITE_FLAG(param.newFilterFlag[CHANNEL_TYPE_LUMA], "alf_luma_new_filter"); WRITE_FLAG(param.newFilterFlag[CHANNEL_TYPE_CHROMA], "alf_chroma_new_filter"); -#if JVET_Q0795_CCALF CcAlfFilterParam paramCcAlf = pcAPS->getCcAlfAPSParam(); WRITE_FLAG(paramCcAlf.newCcAlfFilter[COMPONENT_Cb - 1], "alf_cc_cb_filter_signal_flag"); WRITE_FLAG(paramCcAlf.newCcAlfFilter[COMPONENT_Cr - 1], "alf_cc_cr_filter_signal_flag"); -#endif if (param.newFilterFlag[CHANNEL_TYPE_LUMA]) { -#if JVET_Q0249_ALF_CHROMA_CLIPFLAG WRITE_FLAG( param.nonLinearFlag[CHANNEL_TYPE_LUMA], "alf_luma_clip" ); -#else - WRITE_FLAG( param.nonLinearFlag[CHANNEL_TYPE_LUMA][0], "alf_luma_clip" ); -#endif WRITE_UVLC(param.numLumaFilters - 1, "alf_luma_num_filters_signalled_minus1"); if (param.numLumaFilters > 1) @@ -659,20 +588,14 @@ void HLSWriter::codeAlfAps( APS* pcAPS ) } if (param.newFilterFlag[CHANNEL_TYPE_CHROMA]) { -#if JVET_Q0249_ALF_CHROMA_CLIPFLAG WRITE_FLAG(param.nonLinearFlag[CHANNEL_TYPE_CHROMA], "alf_nonlinear_enable_flag_chroma"); -#endif if( MAX_NUM_ALF_ALTERNATIVES_CHROMA > 1 ) WRITE_UVLC( param.numAlternativesChroma - 1, "alf_chroma_num_alts_minus1" ); for( int altIdx=0; altIdx < param.numAlternativesChroma; ++altIdx ) { -#if !JVET_Q0249_ALF_CHROMA_CLIPFLAG - WRITE_FLAG( param.nonLinearFlag[CHANNEL_TYPE_CHROMA][altIdx], "alf_nonlinear_enable_flag_chroma" ); -#endif alfFilter(param, true, altIdx); } } -#if JVET_Q0795_CCALF for (int ccIdx = 0; ccIdx < 2; ccIdx++) { if (paramCcAlf.newCcAlfFilter[ccIdx]) @@ -717,7 +640,6 @@ void HLSWriter::codeAlfAps( APS* pcAPS ) } } } -#endif } void HLSWriter::codeLmcsAps( APS* pcAPS ) @@ -755,7 +677,6 @@ void HLSWriter::codeScalingListAps( APS* pcAPS ) codeScalingList( param ); } -#if JVET_Q0042_VUI void HLSWriter::codeVUI( const VUI *pcVUI, const SPS* pcSPS ) { #if ENABLE_TRACING @@ -763,6 +684,10 @@ void HLSWriter::codeVUI( const VUI *pcVUI, const SPS* pcSPS ) #endif +#if JVET_R0090_VUI + WRITE_FLAG(pcVUI->getProgressiveSourceFlag(), "vui_general_progressive_source_flag" ); + WRITE_FLAG(pcVUI->getInterlacedSourceFlag(), "vui_general_interlaced_source_flag" ); +#endif WRITE_FLAG(pcVUI->getAspectRatioInfoPresentFlag(), "vui_aspect_ratio_info_present_flag"); if (pcVUI->getAspectRatioInfoPresentFlag()) { @@ -790,75 +715,30 @@ void HLSWriter::codeVUI( const VUI *pcVUI, const SPS* pcSPS ) WRITE_FLAG(pcVUI->getChromaLocInfoPresentFlag(), "vui_chroma_loc_info_present_flag"); if (pcVUI->getChromaLocInfoPresentFlag()) { +#if JVET_R0090_VUI + if(pcVUI->getProgressiveSourceFlag() && !pcVUI->getInterlacedSourceFlag()) +#else if(pcSPS->getProfileTierLevel()->getConstraintInfo()->getProgressiveSourceFlag() && !pcSPS->getProfileTierLevel()->getConstraintInfo()->getInterlacedSourceFlag()) +#endif { WRITE_UVLC(pcVUI->getChromaSampleLocType(), "vui_chroma_sample_loc_type"); } - else + else { WRITE_UVLC(pcVUI->getChromaSampleLocTypeTopField(), "vui_chroma_sample_loc_type_top_field"); WRITE_UVLC(pcVUI->getChromaSampleLocTypeBottomField(), "vui_chroma_sample_loc_type_bottom_field"); } } } -#else -void HLSWriter::codeVUI( const VUI *pcVUI, const SPS* pcSPS ) -{ -#if ENABLE_TRACING - DTRACE( g_trace_ctx, D_HEADER, "----------- vui_parameters -----------\n"); -#endif - - - WRITE_FLAG(pcVUI->getAspectRatioInfoPresentFlag(), "aspect_ratio_info_present_flag"); - if (pcVUI->getAspectRatioInfoPresentFlag()) - { - WRITE_FLAG(pcVUI->getAspectRatioConstantFlag(), "aspect_ratio_constant_flag"); - WRITE_CODE(pcVUI->getAspectRatioIdc(), 8, "aspect_ratio_idc" ); - if (pcVUI->getAspectRatioIdc() == 255) - { - WRITE_CODE(pcVUI->getSarWidth(), 16, "sar_width"); - WRITE_CODE(pcVUI->getSarHeight(), 16, "sar_height"); - } - } - WRITE_FLAG(pcVUI->getColourDescriptionPresentFlag(), "colour_description_present_flag"); - if (pcVUI->getColourDescriptionPresentFlag()) - { - WRITE_CODE(pcVUI->getColourPrimaries(), 8, "colour_primaries"); - WRITE_CODE(pcVUI->getTransferCharacteristics(), 8, "transfer_characteristics"); - WRITE_CODE(pcVUI->getMatrixCoefficients(), 8, "matrix_coeffs"); - WRITE_FLAG(pcVUI->getVideoFullRangeFlag(), "video_full_range_flag"); - } - WRITE_FLAG(pcVUI->getFieldSeqFlag(), "field_seq_flag"); - WRITE_FLAG(pcVUI->getChromaLocInfoPresentFlag(), "chroma_loc_info_present_flag"); - if (pcVUI->getChromaLocInfoPresentFlag()) - { - if(pcVUI->getFieldSeqFlag()) - { - WRITE_UVLC(pcVUI->getChromaSampleLocTypeTopField(), "chroma_sample_loc_type_top_field"); - WRITE_UVLC(pcVUI->getChromaSampleLocTypeBottomField(), "chroma_sample_loc_type_bottom_field"); - } - else - { - WRITE_UVLC(pcVUI->getChromaSampleLocType(), "chroma_sample_loc_type"); - } - } - WRITE_FLAG(pcVUI->getOverscanInfoPresentFlag(), "overscan_info_present_flag"); - if (pcVUI->getOverscanInfoPresentFlag()) - { - WRITE_FLAG(pcVUI->getOverscanAppropriateFlag(), "overscan_appropriate_flag"); - } -} -#endif -#if JVET_P0118_HRD_ASPECTS void HLSWriter::codeGeneralHrdparameters(const GeneralHrdParams * hrd) { WRITE_CODE(hrd->getNumUnitsInTick(), 32, "num_units_in_tick"); WRITE_CODE(hrd->getTimeScale(), 32, "time_scale"); WRITE_FLAG(hrd->getGeneralNalHrdParametersPresentFlag() ? 1 : 0, "general_nal_hrd_parameters_present_flag"); WRITE_FLAG(hrd->getGeneralVclHrdParametersPresentFlag() ? 1 : 0, "general_vcl_hrd_parameters_present_flag"); - WRITE_FLAG(hrd->getGeneralSamPicTimingInAllOlsFlag() ? 1 : 0, "general_same_pic_timing_in_all_ols_flag"); + WRITE_FLAG(hrd->getGeneralSamePicTimingInAllOlsFlag() ? 1 : 0, "general_same_pic_timing_in_all_ols_flag"); WRITE_FLAG(hrd->getGeneralDecodingUnitHrdParamsPresentFlag() ? 1 : 0, "general_decoding_unit_hrd_params_present_flag"); if (hrd->getGeneralDecodingUnitHrdParamsPresentFlag()) { @@ -872,31 +752,11 @@ void HLSWriter::codeGeneralHrdparameters(const GeneralHrdParams * hrd) } WRITE_UVLC(hrd->getHrdCpbCntMinus1(), "hrd_cpb_cnt_minus1"); } -#endif -#if JVET_P0118_HRD_ASPECTS void HLSWriter::codeOlsHrdParameters(const GeneralHrdParams * generalHrd, const OlsHrdParams *olsHrd, const uint32_t firstSubLayer, const uint32_t maxNumSubLayersMinus1) { -#else -void HLSWriter::codeHrdParameters( const HRDParameters *hrd, const uint32_t firstSubLayer, const uint32_t maxNumSubLayersMinus1) -{ - WRITE_FLAG( hrd->getNalHrdParametersPresentFlag() ? 1 : 0 , "general_nal_hrd_parameters_present_flag" ); - WRITE_FLAG( hrd->getVclHrdParametersPresentFlag() ? 1 : 0 , "general_vcl_hrd_parameters_present_flag" ); - WRITE_FLAG( hrd->getGeneralDecodingUnitHrdParamsPresentFlag() ? 1 : 0, "general_decoding_unit_hrd_params_present_flag" ); - if( hrd->getGeneralDecodingUnitHrdParamsPresentFlag() ) - { - WRITE_CODE( hrd->getTickDivisorMinus2(), 8, "tick_divisor_minus2" ); - } - WRITE_CODE( hrd->getBitRateScale(), 4, "bit_rate_scale" ); - WRITE_CODE( hrd->getCpbSizeScale(), 4, "cpb_size_scale" ); - if( hrd->getGeneralDecodingUnitHrdParamsPresentFlag() ) - { - WRITE_CODE( hrd->getCpbSizeDuScale(), 4, "cpb_size_du_scale" ); - } -#endif for( int i = firstSubLayer; i <= maxNumSubLayersMinus1; i ++ ) { -#if JVET_P0118_HRD_ASPECTS const OlsHrdParams *hrd = &(olsHrd[i]); WRITE_FLAG(hrd->getFixedPicRateGeneralFlag() ? 1 : 0, "fixed_pic_rate_general_flag"); @@ -912,42 +772,13 @@ void HLSWriter::codeHrdParameters( const HRDParameters *hrd, const uint32_t firs { WRITE_FLAG(hrd->getLowDelayHrdFlag() ? 1 : 0, "low_delay_hrd_flag"); } -#else - WRITE_FLAG( hrd->getFixedPicRateFlag( i ) ? 1 : 0, "fixed_pic_rate_general_flag"); - bool fixedPixRateWithinCvsFlag = true; - if( !hrd->getFixedPicRateFlag( i ) ) - { - fixedPixRateWithinCvsFlag = hrd->getFixedPicRateWithinCvsFlag( i ); - WRITE_FLAG( hrd->getFixedPicRateWithinCvsFlag( i ) ? 1 : 0, "fixed_pic_rate_within_cvs_flag"); - } - if( fixedPixRateWithinCvsFlag ) - { - WRITE_UVLC( hrd->getPicDurationInTcMinus1( i ), "elemental_duration_in_tc_minus1"); - } - else - { - WRITE_FLAG( hrd->getLowDelayHrdFlag( i ) ? 1 : 0, "low_delay_hrd_flag"); - } - if (!hrd->getLowDelayHrdFlag( i )) - { - WRITE_UVLC( hrd->getCpbCntMinus1( i ), "cpb_cnt_minus1"); - } -#endif for( int nalOrVcl = 0; nalOrVcl < 2; nalOrVcl ++ ) { -#if JVET_P0118_HRD_ASPECTS if (((nalOrVcl == 0) && (generalHrd->getGeneralNalHrdParametersPresentFlag())) || ((nalOrVcl == 1) && (generalHrd->getGeneralVclHrdParametersPresentFlag()))) { for (int j = 0; j <= (generalHrd->getHrdCpbCntMinus1()); j++) -#else - if( ( ( nalOrVcl == 0 ) && ( hrd->getNalHrdParametersPresentFlag() ) ) || - ( ( nalOrVcl == 1 ) && ( hrd->getVclHrdParametersPresentFlag() ) ) ) - { - for( int j = 0; j <= ( hrd->getCpbCntMinus1( i ) ); j ++ ) -#endif { -#if JVET_P0118_HRD_ASPECTS WRITE_UVLC(hrd->getBitRateValueMinus1(j, nalOrVcl), "bit_rate_value_minus1"); WRITE_UVLC(hrd->getCpbSizeValueMinus1(j, nalOrVcl), "cpb_size_value_minus1"); if (generalHrd->getGeneralDecodingUnitHrdParamsPresentFlag()) @@ -956,18 +787,12 @@ void HLSWriter::codeHrdParameters( const HRDParameters *hrd, const uint32_t firs WRITE_UVLC(hrd->getDuCpbSizeValueMinus1(j, nalOrVcl), "cpb_size_du_value_minus1"); } WRITE_FLAG(hrd->getCbrFlag(j, nalOrVcl) ? 1 : 0, "cbr_flag"); -#else - WRITE_UVLC( hrd->getBitRateValueMinus1( i, j, nalOrVcl ), "bit_rate_value_minus1"); - WRITE_UVLC( hrd->getCpbSizeValueMinus1( i, j, nalOrVcl ), "cpb_size_value_minus1"); - WRITE_FLAG( hrd->getCbrFlag( i, j, nalOrVcl ) ? 1 : 0, "cbr_flag"); -#endif } } } } } -#if JVET_P0117_PTL_SCALABILITY void HLSWriter::dpb_parameters(int maxSubLayersMinus1, bool subLayerInfoFlag, const SPS *pcSPS) { for (uint32_t i = (subLayerInfoFlag ? 0 : maxSubLayersMinus1); i <= maxSubLayersMinus1; i++) @@ -977,50 +802,36 @@ void HLSWriter::dpb_parameters(int maxSubLayersMinus1, bool subLayerInfoFlag, co WRITE_UVLC(pcSPS->getMaxLatencyIncreasePlus1(i), "max_latency_increase_plus1[i]"); } } -#endif void HLSWriter::codeSPS( const SPS* pcSPS ) { #if ENABLE_TRACING xTraceSPSHeader (); #endif -#if JVET_Q0117_PARAMETER_SETS_CLEANUP WRITE_CODE(pcSPS->getSPSId(), 4, "sps_seq_parameter_set_id"); -#else - WRITE_CODE( pcSPS->getDecodingParameterSetId (), 4, "sps_decoding_parameter_set_id" ); -#endif WRITE_CODE( pcSPS->getVPSId(), 4, "sps_video_parameter_set_id" ); CHECK(pcSPS->getMaxTLayers() == 0, "Maximum number of temporal sub-layers is '0'"); WRITE_CODE(pcSPS->getMaxTLayers() - 1, 3, "sps_max_sub_layers_minus1"); -#if JVET_P0117_PTL_SCALABILITY WRITE_CODE(0, 4, "sps_reserved_zero_4bits"); WRITE_FLAG(pcSPS->getPtlDpbHrdParamsPresentFlag(), "sps_ptl_dpb_hrd_params_present_flag"); -#else - WRITE_CODE(0, 5, "sps_reserved_zero_5bits"); + +#if JVET_R0275_SPS_PTL_DBP_HRD + if( !pcSPS->getVPSId() ) + { + CHECK( !pcSPS->getPtlDpbHrdParamsPresentFlag(), "When sps_video_parameter_set_id is equal to 0, the value of sps_ptl_dpb_hrd_params_present_flag shall be equal to 1" ); + } #endif -#if JVET_P0117_PTL_SCALABILITY if (pcSPS->getPtlDpbHrdParamsPresentFlag()) { -#endif -#if JVET_Q0786_PTL_only codeProfileTierLevel(pcSPS->getProfileTierLevel(), true, pcSPS->getMaxTLayers() - 1); -#else - codeProfileTierLevel(pcSPS->getProfileTierLevel(), pcSPS->getMaxTLayers() - 1); -#endif -#if JVET_P0117_PTL_SCALABILITY } -#endif - + WRITE_FLAG(pcSPS->getGDREnabledFlag(), "gdr_enabled_flag"); -#if !JVET_Q0117_PARAMETER_SETS_CLEANUP - WRITE_CODE( pcSPS->getSPSId (), 4, "sps_seq_parameter_set_id" ); -#endif WRITE_CODE(int(pcSPS->getChromaFormatIdc ()), 2, "chroma_format_idc"); const ChromaFormat format = pcSPS->getChromaFormatIdc(); -#if JVET_Q0265 const uint32_t separate_colour_plane_flag = pcSPS->getSeparateColourPlaneFlag(); if( format == CHROMA_444 ) { @@ -1029,22 +840,11 @@ void HLSWriter::codeSPS( const SPS* pcSPS ) } const uint32_t chromaArrayType = separate_colour_plane_flag ? 0 : format; -#else - if( format == CHROMA_444 ) - { - WRITE_FLAG( 0, "separate_colour_plane_flag"); - } -#endif -#if JVET_Q0043_RPR_and_Subpics WRITE_FLAG( pcSPS->getRprEnabledFlag(), "res_change_in_clvs_allowed_flag" ); -#else - WRITE_FLAG( pcSPS->getRprEnabledFlag(), "ref_pic_resampling_enabled_flag" ); -#endif WRITE_UVLC( pcSPS->getMaxPicWidthInLumaSamples(), "pic_width_max_in_luma_samples" ); WRITE_UVLC( pcSPS->getMaxPicHeightInLumaSamples(), "pic_height_max_in_luma_samples" ); -#if JVET_Q0260_CONFORMANCE_WINDOW_IN_SPS Window conf = pcSPS->getConformanceWindow(); WRITE_FLAG(conf.getWindowEnabledFlag(), "sps_conformance_window_flag"); if (conf.getWindowEnabledFlag()) @@ -1055,89 +855,50 @@ void HLSWriter::codeSPS( const SPS* pcSPS ) WRITE_UVLC(conf.getWindowBottomOffset(), "sps_conf_win_bottom_offset"); } -#endif WRITE_CODE(floorLog2(pcSPS->getCTUSize()) - 5, 2, "sps_log2_ctu_size_minus5"); -#if JVET_Q0043_RPR_and_Subpics | JVET_Q0119_CLEANUPS -#if JVET_Q0119_CLEANUPS WRITE_FLAG(pcSPS->getSubPicInfoPresentFlag(), "subpic_info_present_flag"); -#else - WRITE_FLAG(pcSPS->getSubPicPresentFlag(), "subpic_info_present_flag"); -#endif -#else - WRITE_FLAG(pcSPS->getSubPicPresentFlag(), "subpics_present_flag"); -#endif -#if JVET_Q0119_CLEANUPS + if (pcSPS->getSubPicInfoPresentFlag()) -#else - if(pcSPS->getSubPicPresentFlag()) -#endif { -#if JVET_Q0119_CLEANUPS + CHECK(pcSPS->getNumSubPics() < 1, "SPS: NumSubPics cannot be less than 1"); WRITE_UVLC(pcSPS->getNumSubPics() - 1, "sps_num_subpics_minus1"); -#else - WRITE_CODE(pcSPS->getNumSubPics() - 1, 8, "sps_num_subpics_minus1"); -#endif -#if JVET_Q0816 if( pcSPS->getNumSubPics() > 1 ) { +#if JVET_R0156_ASPECT4_SPS_CLEANUP + WRITE_FLAG(pcSPS->getIndependentSubPicsFlag(), "sps_independent_subpics_flag"); #endif for (int picIdx = 0; picIdx < pcSPS->getNumSubPics(); picIdx++) { -#if JVET_Q0787_SUBPIC -#if JVET_Q0222_SUBPICTURE_SIGNALLING if ((picIdx > 0) && (pcSPS->getMaxPicWidthInLumaSamples() > pcSPS->getCTUSize())) -#else - if (pcSPS->getMaxPicWidthInLumaSamples() > pcSPS->getCTUSize()) -#endif { WRITE_CODE( pcSPS->getSubPicCtuTopLeftX(picIdx), ceilLog2(( pcSPS->getMaxPicWidthInLumaSamples() + pcSPS->getCTUSize() - 1) / pcSPS->getCTUSize()), "subpic_ctu_top_left_x[ i ]" ); } -#if JVET_Q0222_SUBPICTURE_SIGNALLING if ((picIdx > 0) && (pcSPS->getMaxPicHeightInLumaSamples() > pcSPS->getCTUSize())) -#else - if (pcSPS->getMaxPicHeightInLumaSamples() > pcSPS->getCTUSize()) -#endif { WRITE_CODE( pcSPS->getSubPicCtuTopLeftY(picIdx), ceilLog2(( pcSPS->getMaxPicHeightInLumaSamples() + pcSPS->getCTUSize() - 1) / pcSPS->getCTUSize()), "subpic_ctu_top_left_y[ i ]" ); } -#if JVET_Q0413_SKIP_LAST_SUBPIC_SIG if (picIdx<pcSPS->getNumSubPics()-1 && pcSPS->getMaxPicWidthInLumaSamples() > pcSPS->getCTUSize()) -#else - if (pcSPS->getMaxPicWidthInLumaSamples() > pcSPS->getCTUSize()) -#endif { WRITE_CODE( pcSPS->getSubPicWidth(picIdx) - 1, ceilLog2(( pcSPS->getMaxPicWidthInLumaSamples() + pcSPS->getCTUSize() - 1) / pcSPS->getCTUSize()), "subpic_width_minus1[ i ]" ); } -#if JVET_Q0413_SKIP_LAST_SUBPIC_SIG if (picIdx<pcSPS->getNumSubPics() - 1 && pcSPS->getMaxPicHeightInLumaSamples() > pcSPS->getCTUSize()) -#else - if (pcSPS->getMaxPicHeightInLumaSamples() > pcSPS->getCTUSize()) -#endif { WRITE_CODE( pcSPS->getSubPicHeight(picIdx) - 1, ceilLog2(( pcSPS->getMaxPicHeightInLumaSamples() + pcSPS->getCTUSize() - 1) / pcSPS->getCTUSize()), "subpic_height_minus1[ i ]" ); } -#else -#if JVET_Q0222_SUBPICTURE_SIGNALLING - if (picIdx > 0) +#if JVET_R0156_ASPECT4_SPS_CLEANUP + if (!pcSPS->getIndependentSubPicsFlag()) { #endif - WRITE_CODE( pcSPS->getSubPicCtuTopLeftX(picIdx), std::max(1, ceilLog2((( pcSPS->getMaxPicWidthInLumaSamples() + pcSPS->getCTUSize() - 1) >> floorLog2( pcSPS->getCTUSize())))), "subpic_ctu_top_left_x[ i ]" ); - WRITE_CODE( pcSPS->getSubPicCtuTopLeftY(picIdx), std::max(1, ceilLog2((( pcSPS->getMaxPicHeightInLumaSamples() + pcSPS->getCTUSize() - 1) >> floorLog2( pcSPS->getCTUSize())))), "subpic_ctu_top_left_y[ i ]" ); -#if JVET_Q0222_SUBPICTURE_SIGNALLING + WRITE_FLAG( pcSPS->getSubPicTreatedAsPicFlag(picIdx), "subpic_treated_as_pic_flag[ i ]" ); + WRITE_FLAG( pcSPS->getLoopFilterAcrossSubpicEnabledFlag(picIdx), "loop_filter_across_subpic_enabled_flag[ i ]" ); +#if JVET_R0156_ASPECT4_SPS_CLEANUP } #endif - WRITE_CODE( pcSPS->getSubPicWidth(picIdx) - 1, std::max(1, ceilLog2((( pcSPS->getMaxPicWidthInLumaSamples() + pcSPS->getCTUSize() - 1) >> floorLog2( pcSPS->getCTUSize())))), "subpic_width_minus1[ i ]" ); - WRITE_CODE( pcSPS->getSubPicHeight(picIdx) - 1, std::max(1, ceilLog2((( pcSPS->getMaxPicHeightInLumaSamples() + pcSPS->getCTUSize() - 1) >> floorLog2( pcSPS->getCTUSize())))), "subpic_height_minus1[ i ]" ); -#endif - WRITE_FLAG( pcSPS->getSubPicTreatedAsPicFlag(picIdx), "subpic_treated_as_pic_flag[ i ]" ); - WRITE_FLAG( pcSPS->getLoopFilterAcrossSubpicEnabledFlag(picIdx), "loop_filter_across_subpic_enabled_flag[ i ]" ); } -#if JVET_Q0816 } -#endif -#if JVET_Q0119_CLEANUPS + CHECK(pcSPS->getSubPicIdLen() < 1, "SPS: SubPicIdLen cannot be less than 1"); WRITE_UVLC(pcSPS->getSubPicIdLen() - 1, "sps_subpic_id_len_minus1"); WRITE_FLAG(pcSPS->getSubPicIdMappingExplicitlySignalledFlag(), "subpic_id_mapping_explicitly_signalled_flag"); if (pcSPS->getSubPicIdMappingExplicitlySignalledFlag()) @@ -1152,34 +913,13 @@ void HLSWriter::codeSPS( const SPS* pcSPS ) } } } -#else - } - - WRITE_FLAG( pcSPS->getSubPicIdPresentFlag(), "sps_subpic_id_present_flag"); - if( pcSPS->getSubPicIdPresentFlag() ) - { - WRITE_FLAG(pcSPS->getSubPicIdSignallingPresentFlag(), "sps_subpic_id_signalling_present_flag"); - if( pcSPS->getSubPicIdSignallingPresentFlag() ) - { - WRITE_UVLC( pcSPS->getSubPicIdLen( ) - 1, "sps_subpic_id_len_minus1" ); -#if JVET_Q0169_SUBPIC_LEN_CONFORM - CHECK((1 << pcSPS->getSubPicIdLen()) < pcSPS->getNumSubPics(), "sps_subpic_id_len exceeds valid range"); -#endif - for( int picIdx = 0; picIdx < pcSPS->getNumSubPics( ); picIdx++ ) - { - WRITE_CODE( pcSPS->getSubPicId(picIdx), pcSPS->getSubPicIdLen( ), "sps_subpic_id[i]" ); - } - } - } -#endif WRITE_UVLC( pcSPS->getBitDepth(CHANNEL_TYPE_LUMA) - 8, "bit_depth_minus8" ); -#if !JVET_Q0183_SPS_TRANSFORM_SKIP_MODE_CONTROL - WRITE_UVLC( pcSPS->getMinQpPrimeTsMinus4(CHANNEL_TYPE_LUMA), "min_qp_prime_ts_minus4" ); -#endif -#if JVET_Q0151_Q0205_ENTRYPOINTS WRITE_FLAG( pcSPS->getEntropyCodingSyncEnabledFlag() ? 1 : 0, "sps_entropy_coding_sync_enabled_flag" ); - if (pcSPS->getEntropyCodingSyncEnabledFlag()) +#if JVET_R0165_OPTIONAL_ENTRY_POINT + WRITE_FLAG( pcSPS->getEntryPointsPresentFlag() ? 1 : 0, "sps_entry_point_offsets_present_flag" ); +#else + if (pcSPS->getEntropyCodingSyncEnabledFlag()) { WRITE_FLAG( pcSPS->getEntropyCodingSyncEntryPointsPresentFlag() ? 1 : 0, "sps_wpp_entry_point_offsets_present_flag" ); } @@ -1190,49 +930,41 @@ void HLSWriter::codeSPS( const SPS* pcSPS ) WRITE_CODE(pcSPS->getBitsForPOC()-4, 4, "log2_max_pic_order_cnt_lsb_minus4"); -#if JVET_P0116_POC_MSB WRITE_FLAG(pcSPS->getPocMsbFlag() ? 1 : 0, "sps_poc_msb_flag"); if (pcSPS->getPocMsbFlag()) { WRITE_UVLC(pcSPS->getPocMsbLen() - 1, "poc_msb_len_minus1"); } -#endif -#if JVET_Q0400_EXTRA_BITS // extra bits are for future extensions, so these are currently hard coded to not being sent WRITE_CODE(0, 2, "num_extra_ph_bits_bytes"); // extra_ph_bits_struct( num_extra_ph_bits_bytes ) WRITE_CODE(0, 2, "num_extra_sh_bits_bytes"); // extra_sh_bits_struct( num_extra_sh_bits_bytes ) -#endif -#if JVET_P0117_PTL_SCALABILITY +#if !JVET_R0156_ASPECT3_SPS_CLEANUP if (pcSPS->getMaxTLayers() - 1 > 0) WRITE_FLAG(pcSPS->getSubLayerDpbParamsFlag(), "sps_sublayer_dpb_params_flag"); +#endif if (pcSPS->getPtlDpbHrdParamsPresentFlag()) { - dpb_parameters(pcSPS->getMaxTLayers() - 1, pcSPS->getSubLayerDpbParamsFlag(), pcSPS); - } -#else - // KJS: Marakech decision: sub-layers added back - const bool subLayerOrderingInfoPresentFlag = 1; - if (pcSPS->getMaxTLayers() > 1) - { - WRITE_FLAG(subLayerOrderingInfoPresentFlag, "sps_sub_layer_ordering_info_present_flag"); - } - for(uint32_t i=0; i <= pcSPS->getMaxTLayers()-1; i++) - { - WRITE_UVLC( pcSPS->getMaxDecPicBuffering(i) - 1, "sps_max_dec_pic_buffering_minus1[i]" ); - WRITE_UVLC( pcSPS->getNumReorderPics(i), "sps_max_num_reorder_pics[i]" ); - WRITE_UVLC( pcSPS->getMaxLatencyIncreasePlus1(i), "sps_max_latency_increase_plus1[i]" ); - if (!subLayerOrderingInfoPresentFlag) +#if JVET_R0156_ASPECT3_SPS_CLEANUP + if (pcSPS->getMaxTLayers() - 1 > 0) { - break; + WRITE_FLAG(pcSPS->getSubLayerDpbParamsFlag(), "sps_sublayer_dpb_params_flag"); } - } #endif + dpb_parameters(pcSPS->getMaxTLayers() - 1, pcSPS->getSubLayerDpbParamsFlag(), pcSPS); + } CHECK( pcSPS->getMaxCUWidth() != pcSPS->getMaxCUHeight(), "Rectangular CTUs not supported" ); WRITE_FLAG(pcSPS->getLongTermRefsPresent() ? 1 : 0, "long_term_ref_pics_flag"); +#if JVET_R0205 + if( pcSPS->getVPSId() > 0 ) + { + WRITE_FLAG( pcSPS->getInterLayerPresentFlag() ? 1 : 0, "sps_inter_layer_ref_pics_present_flag" ); + } +#else WRITE_FLAG( pcSPS->getInterLayerPresentFlag() ? 1 : 0, "inter_layer_ref_pics_present_flag" ); +#endif WRITE_FLAG(pcSPS->getIDRRefParamListPresent() ? 1 : 0, "sps_idr_rpl_present_flag" ); WRITE_FLAG(pcSPS->getRPL1CopyFromRPL0Flag() ? 1 : 0, "rpl1_copy_from_rpl0_flag"); @@ -1245,7 +977,11 @@ void HLSWriter::codeSPS( const SPS* pcSPS ) for (int ii = 0; ii < numberOfRPL; ii++) { const ReferencePictureList* rpl = rplList0->getReferencePictureList(ii); - xCodeRefPicList( rpl, pcSPS->getLongTermRefsPresent(), pcSPS->getBitsForPOC(), !pcSPS->getUseWP() && !pcSPS->getUseWPBiPred() ); +#if JVET_R0059_RPL_CLEANUP + xCodeRefPicList(rpl, pcSPS->getLongTermRefsPresent(), pcSPS->getBitsForPOC(), !pcSPS->getUseWP() && !pcSPS->getUseWPBiPred(), ii); +#else + xCodeRefPicList( rpl, pcSPS->getLongTermRefsPresent(), pcSPS->getBitsForPOC(), !pcSPS->getUseWP() && !pcSPS->getUseWPBiPred()); +#endif } //Write candidate for List1 @@ -1256,30 +992,28 @@ void HLSWriter::codeSPS( const SPS* pcSPS ) for (int ii = 0; ii < numberOfRPL; ii++) { const ReferencePictureList* rpl = rplList1->getReferencePictureList(ii); - xCodeRefPicList( rpl, pcSPS->getLongTermRefsPresent(), pcSPS->getBitsForPOC(), !pcSPS->getUseWP() && !pcSPS->getUseWPBiPred() ); +#if JVET_R0059_RPL_CLEANUP + xCodeRefPicList(rpl, pcSPS->getLongTermRefsPresent(), pcSPS->getBitsForPOC(), !pcSPS->getUseWP() && !pcSPS->getUseWPBiPred(), ii); +#else + xCodeRefPicList( rpl, pcSPS->getLongTermRefsPresent(), pcSPS->getBitsForPOC(), !pcSPS->getUseWP() && !pcSPS->getUseWPBiPred()); +#endif } } - if( pcSPS->getChromaFormatIdc() != CHROMA_400 ) + if( pcSPS->getChromaFormatIdc() != CHROMA_400 ) { WRITE_FLAG(pcSPS->getUseDualITree(), "qtbtt_dual_tree_intra_flag"); } WRITE_UVLC(pcSPS->getLog2MinCodingBlockSize() - 2, "log2_min_luma_coding_block_size_minus2"); WRITE_FLAG(pcSPS->getSplitConsOverrideEnabledFlag(), "partition_constraints_override_enabled_flag"); WRITE_UVLC(floorLog2(pcSPS->getMinQTSize(I_SLICE)) - pcSPS->getLog2MinCodingBlockSize(), "sps_log2_diff_min_qt_min_cb_intra_slice_luma"); -#if !JVET_Q0481_PARTITION_CONSTRAINTS_ORDER - WRITE_UVLC(floorLog2(pcSPS->getMinQTSize(B_SLICE)) - pcSPS->getLog2MinCodingBlockSize(), "sps_log2_diff_min_qt_min_cb_inter_slice"); - WRITE_UVLC(pcSPS->getMaxMTTHierarchyDepth(), "sps_max_mtt_hierarchy_depth_inter_slice"); -#endif WRITE_UVLC(pcSPS->getMaxMTTHierarchyDepthI(), "sps_max_mtt_hierarchy_depth_intra_slice_luma"); if (pcSPS->getMaxMTTHierarchyDepthI() != 0) { WRITE_UVLC(floorLog2(pcSPS->getMaxBTSizeI()) - floorLog2(pcSPS->getMinQTSize(I_SLICE)), "sps_log2_diff_max_bt_min_qt_intra_slice_luma"); WRITE_UVLC(floorLog2(pcSPS->getMaxTTSizeI()) - floorLog2(pcSPS->getMinQTSize(I_SLICE)), "sps_log2_diff_max_tt_min_qt_intra_slice_luma"); } -#if JVET_Q0481_PARTITION_CONSTRAINTS_ORDER WRITE_UVLC(floorLog2(pcSPS->getMinQTSize(B_SLICE)) - pcSPS->getLog2MinCodingBlockSize(), "sps_log2_diff_min_qt_min_cb_inter_slice"); WRITE_UVLC(pcSPS->getMaxMTTHierarchyDepth(), "sps_max_mtt_hierarchy_depth_inter_slice"); -#endif if (pcSPS->getMaxMTTHierarchyDepth() != 0) { WRITE_UVLC(floorLog2(pcSPS->getMaxBTSize()) - floorLog2(pcSPS->getMinQTSize(B_SLICE)), "sps_log2_diff_max_bt_min_qt_inter_slice"); @@ -1295,22 +1029,14 @@ void HLSWriter::codeSPS( const SPS* pcSPS ) WRITE_UVLC(floorLog2(pcSPS->getMaxTTSizeIChroma()) - floorLog2(pcSPS->getMinQTSize(I_SLICE, CHANNEL_TYPE_CHROMA)), "sps_log2_diff_max_tt_min_qt_intra_slice_chroma"); } } +#if JVET_R0097_MAX_TRSIZE_CONDITIONALY_SIGNALING + if (pcSPS->getCTUSize() > 32) +#endif + WRITE_FLAG( (pcSPS->getLog2MaxTbSize() - 5) ? 1 : 0, "sps_max_luma_transform_size_64_flag" ); - WRITE_FLAG( (pcSPS->getLog2MaxTbSize() - 5) ? 1 : 0, "sps_max_luma_transform_size_64_flag" ); - -#if JVET_Q0147_JCCR_SIGNALLING -#if JVET_Q0265 if (chromaArrayType != CHROMA_400) -#else - if (pcSPS->getChromaFormatIdc() != CHROMA_400) -#endif { WRITE_FLAG(pcSPS->getJointCbCrEnabledFlag(), "sps_joint_cbcr_enabled_flag"); -#else - WRITE_FLAG(pcSPS->getJointCbCrEnabledFlag(), "sps_joint_cbcr_enabled_flag"); - if (pcSPS->getChromaFormatIdc() != CHROMA_400) - { -#endif const ChromaQpMappingTable& chromaQpMappingTable = pcSPS->getChromaQpMappingTable(); WRITE_FLAG(chromaQpMappingTable.getSameCQPTableForAllChromaFlag(), "same_qp_table_for_chroma"); int numQpTables = chromaQpMappingTable.getSameCQPTableForAllChromaFlag() ? 1 : (pcSPS->getJointCbCrEnabledFlag() ? 3 : 2); @@ -1331,56 +1057,26 @@ void HLSWriter::codeSPS( const SPS* pcSPS ) WRITE_FLAG( pcSPS->getSAOEnabledFlag(), "sps_sao_enabled_flag"); WRITE_FLAG( pcSPS->getALFEnabledFlag(), "sps_alf_enabled_flag" ); -#if JVET_Q0795_CCALF if (pcSPS->getALFEnabledFlag() && pcSPS->getChromaFormatIdc() != CHROMA_400) { WRITE_FLAG( pcSPS->getCCALFEnabledFlag(), "sps_ccalf_enabled_flag" ); } -#endif WRITE_FLAG(pcSPS->getTransformSkipEnabledFlag() ? 1 : 0, "sps_transform_skip_enabled_flag"); if (pcSPS->getTransformSkipEnabledFlag()) { -#if JVET_Q0183_SPS_TRANSFORM_SKIP_MODE_CONTROL WRITE_UVLC(pcSPS->getLog2MaxTransformSkipBlockSize() - 2, "log2_transform_skip_max_size_minus2"); -#endif -#if JVET_Q0089_SLICE_LOSSLESS_CODING_CHROMA_BDPCM WRITE_FLAG(pcSPS->getBDPCMEnabledFlag() ? 1 : 0, "sps_bdpcm_enabled_flag"); -#else - WRITE_FLAG(pcSPS->getBDPCMEnabled() ? 1 : 0, "sps_bdpcm_enabled_flag"); -#if JVET_Q0110_Q0785_CHROMA_BDPCM_420 - if( pcSPS->getBDPCMEnabled() ) -#else - if (pcSPS->getBDPCMEnabled() && pcSPS->getChromaFormatIdc() == CHROMA_444) -#endif - { - WRITE_FLAG(pcSPS->getBDPCMEnabled() == BDPCM_LUMACHROMA ? 1 : 0, "sps_bdpcm_enabled_chroma_flag"); - } -#if !JVET_Q0110_Q0785_CHROMA_BDPCM_420 - else - { - CHECK(pcSPS->getBDPCMEnabled() == BDPCM_LUMACHROMA, "BDPCM for chroma can be used for 444 only.") - } -#endif -#endif } else { -#if JVET_Q0089_SLICE_LOSSLESS_CODING_CHROMA_BDPCM CHECK(pcSPS->getBDPCMEnabledFlag(), "BDPCM cannot be used when transform skip is disabled"); -#else - CHECK(pcSPS->getBDPCMEnabled()!=0, "BDPCM cannot be used when transform skip is disabled"); -#endif } WRITE_FLAG( pcSPS->getWrapAroundEnabledFlag() ? 1 : 0, "sps_ref_wraparound_enabled_flag" ); if( pcSPS->getWrapAroundEnabledFlag() ) { -#if JVET_Q0416_WRAPAROUND_OFFSET WRITE_UVLC((pcSPS->getWrapAroundOffset() / (1 << pcSPS->getLog2MinCodingBlockSize())) - 2 - pcSPS->getCTUSize()/(1<<pcSPS->getLog2MinCodingBlockSize()), "sps_ref_wraparound_offset"); -#else - WRITE_UVLC( (pcSPS->getWrapAroundOffset()/(1 << pcSPS->getLog2MinCodingBlockSize()))-1, "sps_ref_wraparound_offset_minus1" ); -#endif } WRITE_FLAG( pcSPS->getSPSTemporalMVPEnabledFlag() ? 1 : 0, "sps_temporal_mvp_enabled_flag" ); @@ -1407,7 +1103,7 @@ void HLSWriter::codeSPS( const SPS* pcSPS ) WRITE_FLAG( pcSPS->getUseISP() ? 1 : 0, "sps_isp_enabled_flag"); WRITE_FLAG( pcSPS->getUseMRL() ? 1 : 0, "sps_mrl_enabled_flag"); WRITE_FLAG( pcSPS->getUseMIP() ? 1 : 0, "sps_mip_enabled_flag"); - if( pcSPS->getChromaFormatIdc() != CHROMA_400) + if( pcSPS->getChromaFormatIdc() != CHROMA_400) { WRITE_FLAG( pcSPS->getUseLMChroma() ? 1 : 0, "sps_cclm_enabled_flag"); } @@ -1416,6 +1112,11 @@ void HLSWriter::codeSPS( const SPS* pcSPS ) WRITE_FLAG( pcSPS->getHorCollocatedChromaFlag() ? 1 : 0, "sps_chroma_horizontal_collocated_flag" ); WRITE_FLAG( pcSPS->getVerCollocatedChromaFlag() ? 1 : 0, "sps_chroma_vertical_collocated_flag" ); } + else + { + CHECK(pcSPS->getHorCollocatedChromaFlag() != 1, "Invalid value for horizontal collocated chroma flag"); + CHECK(pcSPS->getVerCollocatedChromaFlag() != 1, "Invalid value for vertical collocated chroma flag"); + } WRITE_FLAG( pcSPS->getUseMTS() ? 1 : 0, "sps_mts_enabled_flag" ); if ( pcSPS->getUseMTS() ) @@ -1423,67 +1124,44 @@ void HLSWriter::codeSPS( const SPS* pcSPS ) WRITE_FLAG( pcSPS->getUseIntraMTS() ? 1 : 0, "sps_explicit_mts_intra_enabled_flag" ); WRITE_FLAG( pcSPS->getUseInterMTS() ? 1 : 0, "sps_explicit_mts_inter_enabled_flag" ); } -#if JVET_Q0798_SPS_NUMBER_MERGE_CANDIDATE CHECK(pcSPS->getMaxNumMergeCand() > MRG_MAX_NUM_CANDS, "More merge candidates signalled than supported"); WRITE_UVLC(MRG_MAX_NUM_CANDS - pcSPS->getMaxNumMergeCand(), "six_minus_max_num_merge_cand"); -#endif WRITE_FLAG( pcSPS->getUseSBT() ? 1 : 0, "sps_sbt_enabled_flag"); WRITE_FLAG( pcSPS->getUseAffine() ? 1 : 0, "sps_affine_enabled_flag" ); if ( pcSPS->getUseAffine() ) { -#if JVET_Q0798_SPS_NUMBER_MERGE_CANDIDATE WRITE_UVLC(AFFINE_MRG_MAX_NUM_CANDS - pcSPS->getMaxNumAffineMergeCand(), "five_minus_max_num_subblock_merge_cand"); -#endif WRITE_FLAG( pcSPS->getUseAffineType() ? 1 : 0, "sps_affine_type_flag" ); -#if JVET_Q0444_AMVR_SIGNALLING if (pcSPS->getAMVREnabledFlag()) { -#endif WRITE_FLAG( pcSPS->getAffineAmvrEnabledFlag() ? 1 : 0, "sps_affine_amvr_enabled_flag" ); -#if JVET_Q0444_AMVR_SIGNALLING } -#endif WRITE_FLAG( pcSPS->getUsePROF() ? 1 : 0, "sps_affine_prof_enabled_flag" ); if (pcSPS->getUsePROF()) { WRITE_FLAG(pcSPS->getProfControlPresentFlag() ? 1 : 0, "sps_prof_pic_present_flag" ); } } -#if !JVET_Q0820_ACT - if (pcSPS->getChromaFormatIdc() == CHROMA_444) - { - WRITE_FLAG(pcSPS->getUseColorTrans() ? 1 : 0, "sps_act_enabled_flag"); - } -#endif -#if JVET_Q0504_PLT_NON444 WRITE_FLAG(pcSPS->getPLTMode() ? 1 : 0, "sps_palette_enabled_flag" ); -#else - if (pcSPS->getChromaFormatIdc() == CHROMA_444) - { - WRITE_FLAG(pcSPS->getPLTMode() ? 1 : 0, "sps_palette_enabled_flag" ); - } -#endif -#if JVET_Q0820_ACT if (pcSPS->getChromaFormatIdc() == CHROMA_444 && pcSPS->getLog2MaxTbSize() != 6) { WRITE_FLAG(pcSPS->getUseColorTrans() ? 1 : 0, "sps_act_enabled_flag"); } -#endif -#if JVET_Q0183_SPS_TRANSFORM_SKIP_MODE_CONTROL if (pcSPS->getTransformSkipEnabledFlag() || pcSPS->getPLTMode()) { +#if JVET_R0045_TS_MIN_QP_CLEANUP + WRITE_UVLC(pcSPS->getInternalMinusInputBitDepth(CHANNEL_TYPE_LUMA), "sps_internal_bit_depth_minus_input_bit_depth"); +#else WRITE_UVLC(pcSPS->getMinQpPrimeTsMinus4(CHANNEL_TYPE_LUMA), "min_qp_prime_ts_minus4"); - } #endif + } WRITE_FLAG( pcSPS->getUseBcw() ? 1 : 0, "sps_bcw_enabled_flag" ); WRITE_FLAG(pcSPS->getIBCFlag() ? 1 : 0, "sps_ibc_enabled_flag"); -#if JVET_Q0798_SPS_NUMBER_MERGE_CANDIDATE if (pcSPS->getIBCFlag()) { CHECK(pcSPS->getMaxNumIBCMergeCand() > IBC_MRG_MAX_NUM_CANDS, "More IBC merge candidates signalled than supported"); WRITE_UVLC(IBC_MRG_MAX_NUM_CANDS - pcSPS->getMaxNumIBCMergeCand(), "six_minus_max_num_ibc_merge_cand"); } -#endif // KJS: sps_ciip_enabled_flag WRITE_FLAG( pcSPS->getUseCiip() ? 1 : 0, "sps_ciip_enabled_flag" ); @@ -1492,22 +1170,6 @@ void HLSWriter::codeSPS( const SPS* pcSPS ) WRITE_FLAG( pcSPS->getFpelMmvdEnabledFlag() ? 1 : 0, "sps_fpel_mmvd_enabled_flag" ); } -#if !JVET_Q0806 -#if JVET_Q0798_SPS_NUMBER_MERGE_CANDIDATE - if (pcSPS->getMaxNumMergeCand() >= 2) - { - WRITE_FLAG(pcSPS->getUseTriangle() ? 1 : 0, "sps_triangle_enabled_flag"); - if (pcSPS->getUseTriangle() && pcSPS->getMaxNumMergeCand() >= 3) - { - CHECK(pcSPS->getMaxNumMergeCand() < pcSPS->getMaxNumGeoCand(), "Incorrrect max number of Triangle candidates!"); - WRITE_UVLC(pcSPS->getMaxNumMergeCand() - pcSPS->getMaxNumGeoCand(), "max_num_merge_cand_minus_max_num_gpm_cand"); - } - } -#else - WRITE_FLAG( pcSPS->getUseTriangle() ? 1: 0, "sps_triangle_enabled_flag" ); -#endif -#else -#if JVET_Q0798_SPS_NUMBER_MERGE_CANDIDATE if (pcSPS->getMaxNumMergeCand() >= 2) { WRITE_FLAG(pcSPS->getUseGeo() ? 1 : 0, "sps_gpm_enabled_flag"); @@ -1517,10 +1179,6 @@ void HLSWriter::codeSPS( const SPS* pcSPS ) WRITE_UVLC(pcSPS->getMaxNumMergeCand() - pcSPS->getMaxNumGeoCand(), "max_num_merge_cand_minus_max_num_gpm_cand"); } } -#else - WRITE_FLAG( pcSPS->getUseGeo() ? 1: 0, "sps_gpm_enabled_flag" ); -#endif -#endif WRITE_FLAG(pcSPS->getUseLmcs() ? 1 : 0, "sps_lmcs_enable_flag"); WRITE_FLAG( pcSPS->getUseLFNST() ? 1 : 0, "sps_lfnst_enabled_flag" ); @@ -1537,96 +1195,70 @@ void HLSWriter::codeSPS( const SPS* pcSPS ) } } #endif -#if JVET_Q0297_MER WRITE_UVLC(pcSPS->getLog2ParallelMergeLevelMinus2(), "log2_parallel_merge_level_minus2"); -#endif // KJS: reference picture sets to be replaced // KJS: remove scaling lists? WRITE_FLAG( pcSPS->getScalingListFlag() ? 1 : 0, "sps_scaling_list_enabled_flag" ); - -#if JVET_Q0246_VIRTUAL_BOUNDARY_ENABLE_FLAG +#if JVET_R0380_SCALING_MATRIX_DISABLE_YCC_OR_RGB + if (pcSPS->getUseColorTrans() && pcSPS->getScalingListFlag()) + { + WRITE_FLAG(pcSPS->getScalingMatrixForAlternativeColourSpaceDisabledFlag(), "sps_scaling_matrix_for_alternative_colour_space_disabled_flag"); + } + if (pcSPS->getScalingMatrixForAlternativeColourSpaceDisabledFlag()) + { + WRITE_FLAG(pcSPS->getScalingMatrixDesignatedColourSpaceFlag(), "sps_scaling_matrix_designated_colour_space_flag"); + } +#endif + WRITE_FLAG(pcSPS->getDepQuantEnabledFlag(), "sps_dep_quant_enabled_flag"); + if (!pcSPS->getDepQuantEnabledFlag()) + { + WRITE_FLAG(pcSPS->getSignDataHidingEnabledFlag(), "sps_sign_data_hiding_enabled_flag"); + } WRITE_FLAG( pcSPS->getVirtualBoundariesEnabledFlag(), "sps_virtual_boundaries_enabled_flag" ); if( pcSPS->getVirtualBoundariesEnabledFlag() ) { WRITE_FLAG( pcSPS->getVirtualBoundariesPresentFlag(), "sps_loop_filter_across_virtual_boundaries_present_flag" ); if( pcSPS->getVirtualBoundariesPresentFlag() ) { -#else - WRITE_FLAG( pcSPS->getLoopFilterAcrossVirtualBoundariesDisabledFlag(), "sps_loop_filter_across_virtual_boundaries_disabled_present_flag" ); - if( pcSPS->getLoopFilterAcrossVirtualBoundariesDisabledFlag() ) - { -#endif WRITE_CODE( pcSPS->getNumVerVirtualBoundaries(), 2, "sps_num_ver_virtual_boundaries"); for( unsigned i = 0; i < pcSPS->getNumVerVirtualBoundaries(); i++ ) { +#if JVET_R0266_DESC + WRITE_UVLC((pcSPS->getVirtualBoundariesPosX(i)>>3), "sps_virtual_boundaries_pos_x"); +#else WRITE_CODE((pcSPS->getVirtualBoundariesPosX(i)>>3), 13, "sps_virtual_boundaries_pos_x"); +#endif } WRITE_CODE(pcSPS->getNumHorVirtualBoundaries(), 2, "sps_num_hor_virtual_boundaries"); for( unsigned i = 0; i < pcSPS->getNumHorVirtualBoundaries(); i++ ) { +#if JVET_R0266_DESC + WRITE_UVLC((pcSPS->getVirtualBoundariesPosY(i)>>3), "sps_virtual_boundaries_pos_y"); +#else WRITE_CODE((pcSPS->getVirtualBoundariesPosY(i)>>3), 13, "sps_virtual_boundaries_pos_y"); +#endif } } -#if JVET_Q0246_VIRTUAL_BOUNDARY_ENABLE_FLAG } -#endif -#if JVET_P0117_PTL_SCALABILITY if (pcSPS->getPtlDpbHrdParamsPresentFlag()) { -#endif -#if !JVET_P0118_HRD_ASPECTS - const TimingInfo *timingInfo = pcSPS->getTimingInfo(); -#endif -#if JVET_P0118_HRD_ASPECTS WRITE_FLAG(pcSPS->getGeneralHrdParametersPresentFlag(), "sps_general_hrd_parameters_present_flag"); -#else - WRITE_FLAG(pcSPS->getHrdParametersPresentFlag(), "general_hrd_parameters_present_flag"); -#endif -#if JVET_P0118_HRD_ASPECTS if (pcSPS->getGeneralHrdParametersPresentFlag()) -#else - if( pcSPS->getHrdParametersPresentFlag() ) -#endif { -#if !JVET_P0118_HRD_ASPECTS - WRITE_CODE(timingInfo->getNumUnitsInTick(), 32, "num_units_in_tick"); - WRITE_CODE(timingInfo->getTimeScale(), 32, "time_scale"); -#endif -#if JVET_P0118_HRD_ASPECTS codeGeneralHrdparameters(pcSPS->getGeneralHrdParameters()); -#endif -#if JVET_P0118_HRD_ASPECTS if ((pcSPS->getMaxTLayers() - 1) > 0) { WRITE_FLAG(pcSPS->getSubLayerParametersPresentFlag(), "sps_sublayer_cpb_params_present_flag"); } uint32_t firstSubLayer = pcSPS->getSubLayerParametersPresentFlag() ? 0 : (pcSPS->getMaxTLayers() - 1); -#else - WRITE_FLAG(pcSPS->getSubLayerParametersPresentFlag(), "sub_layer_cpb_parameters_present_flag"); -#endif -#if JVET_P0118_HRD_ASPECTS codeOlsHrdParameters(pcSPS->getGeneralHrdParameters(), pcSPS->getOlsHrdParameters(), firstSubLayer, pcSPS->getMaxTLayers() - 1); -#else - if (pcSPS->getSubLayerParametersPresentFlag()) - { - codeHrdParameters(pcSPS->getHrdParameters(), 0, pcSPS->getMaxTLayers() - 1); - } - else - { - codeHrdParameters(pcSPS->getHrdParameters(), pcSPS->getMaxTLayers() - 1, pcSPS->getMaxTLayers() - 1); - } -#endif } -#if JVET_P0117_PTL_SCALABILITY } -#endif -#if JVET_Q0042_VUI WRITE_FLAG(pcSPS->getFieldSeqFlag(), "field_seq_flag"); -#endif WRITE_FLAG( pcSPS->getVuiParametersPresentFlag(), "vui_parameters_present_flag" ); if (pcSPS->getVuiParametersPresentFlag()) { @@ -1695,7 +1327,6 @@ void HLSWriter::codeSPS( const SPS* pcSPS ) } xWriteRbspTrailingBits(); } -#if JVET_Q0117_PARAMETER_SETS_CLEANUP void HLSWriter::codeDCI(const DCI* dci) { #if ENABLE_TRACING @@ -1711,43 +1342,12 @@ void HLSWriter::codeDCI(const DCI* dci) for (int i = 0; i < numPTLs; i++) { ProfileTierLevel ptl = dci->getProfileTierLevel(i); -#if JVET_Q0786_PTL_only codeProfileTierLevel(&ptl, true, 0); -#else - codeProfileTierLevel(&ptl, 0); -#endif } WRITE_FLAG(0, "dci_extension_flag"); xWriteRbspTrailingBits(); } -#else -void HLSWriter::codeDPS( const DPS* dps ) -{ -#if ENABLE_TRACING - xTraceDPSHeader(); -#endif - WRITE_CODE( dps->getDecodingParameterSetId(), 4, "dps_decoding_parameter_set_id" ); - WRITE_CODE( dps->getMaxSubLayersMinus1(), 3, "dps_max_sub_layers_minus1" ); - WRITE_CODE( 0, 5, "dps_reserved_zero_5bits" ); - uint32_t numPTLs = (uint32_t) dps->getNumPTLs(); - CHECK (numPTLs<1, "At least one PTL must be available in DPS"); - - WRITE_CODE( numPTLs - 1, 4, "dps_num_ptls_minus1" ); - - for (int i=0; i< numPTLs; i++) - { - ProfileTierLevel ptl = dps->getProfileTierLevel(i); -#if JVET_Q0786_PTL_only - codeProfileTierLevel( &ptl, true, 0 ); -#else - codeProfileTierLevel( &ptl, dps->getMaxSubLayersMinus1() ); -#endif - } - WRITE_FLAG( 0, "dps_extension_flag" ); - xWriteRbspTrailingBits(); -} -#endif void HLSWriter::codeVPS(const VPS* pcVPS) { #if ENABLE_TRACING @@ -1756,7 +1356,7 @@ void HLSWriter::codeVPS(const VPS* pcVPS) WRITE_CODE(pcVPS->getVPSId(), 4, "vps_video_parameter_set_id"); WRITE_CODE(pcVPS->getMaxLayers() - 1, 6, "vps_max_layers_minus1"); WRITE_CODE(pcVPS->getMaxSubLayers() - 1, 3, "vps_max_sublayers_minus1"); - if (pcVPS->getMaxLayers() > 1 && pcVPS->getMaxSubLayers() > 1) + if (pcVPS->getMaxLayers() > 1 && pcVPS->getMaxSubLayers() > 1) { WRITE_FLAG(pcVPS->getAllLayersSameNumSublayersFlag(), "vps_all_layers_same_num_sublayers_flag"); } @@ -1781,11 +1381,11 @@ void HLSWriter::codeVPS(const VPS* pcVPS) } if( pcVPS->getMaxLayers() > 1 ) { - if (pcVPS->getAllIndependentLayersFlag()) + if (pcVPS->getAllIndependentLayersFlag()) { WRITE_FLAG(pcVPS->getEachLayerIsAnOlsFlag(), "each_layer_is_an_ols_flag"); } - if (!pcVPS->getEachLayerIsAnOlsFlag()) + if (!pcVPS->getEachLayerIsAnOlsFlag()) { if (!pcVPS->getAllIndependentLayersFlag()) { WRITE_CODE(pcVPS->getOlsModeIdc(), 2, "ols_mode_idc"); @@ -1804,15 +1404,14 @@ void HLSWriter::codeVPS(const VPS* pcVPS) } } -#if JVET_Q0786_PTL_only int totalNumOlss = pcVPS->getTotalNumOLSs(); WRITE_CODE(pcVPS->getNumPtls() - 1, 8, "vps_num_ptls_minus1"); for (int i = 0; i < pcVPS->getNumPtls(); i++) { if(i > 0) - WRITE_FLAG(pcVPS->getPtPresentFlag(i), "pt_present_flag"); + WRITE_FLAG(pcVPS->getPtPresentFlag(i), "pt_present_flag"); if(pcVPS->getMaxSubLayers() > 1 && !pcVPS->getAllLayersSameNumSublayersFlag()) - WRITE_CODE(pcVPS->getPtlMaxTemporalId(i) ,3, "ptl_max_temporal_id"); + WRITE_CODE(pcVPS->getPtlMaxTemporalId(i) ,3, "ptl_max_temporal_id"); } int cnt = 0; while (m_pcBitIf->getNumBitsUntilByteAligned()) @@ -1827,12 +1426,14 @@ void HLSWriter::codeVPS(const VPS* pcVPS) } for (int i = 0; i < totalNumOlss; i++) { +#if JVET_R0161_CONDITION_SIGNAL_PTL_IDX + if (pcVPS->getNumPtls() > 1 && pcVPS->getNumPtls() != pcVPS->getTotalNumOLSs()) +#else if(pcVPS->getNumPtls() > 1) +#endif WRITE_CODE(pcVPS->getOlsPtlIdx(i), 8, "ols_ptl_idx"); } -#endif -#if JVET_Q0814_DPB if( !pcVPS->getAllIndependentLayersFlag() ) { WRITE_UVLC( pcVPS->m_numDpbParams, "vps_num_dpb_params" ); @@ -1881,8 +1482,6 @@ void HLSWriter::codeVPS(const VPS* pcVPS) } } } -#endif -#if JVET_P0118_HRD_ASPECTS if (!pcVPS->getEachLayerIsAnOlsFlag()) { WRITE_FLAG(pcVPS->getVPSGeneralHrdParamsPresentFlag(), "vps_general_hrd_params_present_flag"); @@ -1915,7 +1514,6 @@ void HLSWriter::codeVPS(const VPS* pcVPS) } } } -#endif WRITE_FLAG(0, "vps_extension_flag"); @@ -1923,11 +1521,7 @@ void HLSWriter::codeVPS(const VPS* pcVPS) xWriteRbspTrailingBits(); } -#if JVET_Q0775_PH_IN_SH void HLSWriter::codePictureHeader( PicHeader* picHeader, bool writeRbspTrailingBits ) -#else -void HLSWriter::codePictureHeader( PicHeader* picHeader ) -#endif { const PPS* pps = NULL; const SPS* sps = NULL; @@ -1937,7 +1531,6 @@ void HLSWriter::codePictureHeader( PicHeader* picHeader ) #endif CodingStructure& cs = *picHeader->getPic()->cs; -#if JVET_Q0819_PH_CHANGES WRITE_FLAG(picHeader->getGdrOrIrapPicFlag(), "gdr_or_irap_pic_flag"); if (picHeader->getGdrOrIrapPicFlag()) { @@ -1949,12 +1542,7 @@ void HLSWriter::codePictureHeader( PicHeader* picHeader ) { WRITE_FLAG(picHeader->getPicIntraSliceAllowedFlag(), "ph_intra_slice_allowed_flag"); } -#endif WRITE_FLAG(picHeader->getNonReferencePictureFlag(), "non_reference_picture_flag"); -#if !JVET_Q0819_PH_CHANGES - WRITE_FLAG(picHeader->getGdrPicFlag(), "gdr_pic_flag"); -#endif -#if JVET_Q0819_PH_CHANGES // parameter sets WRITE_UVLC(picHeader->getPPSId(), "ph_pic_parameter_set_id"); pps = cs.slice->getPPS(); @@ -1968,25 +1556,19 @@ void HLSWriter::codePictureHeader( PicHeader* picHeader ) { WRITE_FLAG(picHeader->getNoOutputOfPriorPicsFlag(), "no_output_of_prior_pics_flag"); } -#else - WRITE_FLAG(picHeader->getNoOutputOfPriorPicsFlag(), "no_output_of_prior_pics_flag"); -#endif - if( picHeader->getGdrPicFlag() ) + if( picHeader->getGdrPicFlag() ) { WRITE_UVLC(picHeader->getRecoveryPocCnt(), "recovery_poc_cnt"); } - else + else { picHeader->setRecoveryPocCnt( 0 ); } -#if JVET_Q0400_EXTRA_BITS // PH extra bits are not written in the reference encoder // as these bits are reserved for future extensions // for( i = 0; i < NumExtraPhBits; i++ ) // ph_extra_bit[ i ] -#endif - -#if JVET_P0116_POC_MSB + if (sps->getPocMsbFlag()) { WRITE_FLAG(picHeader->getPocMsbPresentFlag(), "ph_poc_msb_present_flag"); @@ -1995,27 +1577,12 @@ void HLSWriter::codePictureHeader( PicHeader* picHeader ) WRITE_CODE(picHeader->getPocMsbVal(), sps->getPocMsbLen(), "poc_msb_val"); } } -#endif -#if !JVET_Q0819_PH_CHANGES - // parameter sets - WRITE_UVLC(picHeader->getPPSId(), "ph_pic_parameter_set_id"); - pps = cs.slice->getPPS(); - CHECK(pps==0, "Invalid PPS"); - sps = cs.slice->getSPS(); - CHECK(sps==0, "Invalid SPS"); -#endif -#if JVET_Q0819_PH_CHANGES // alf enable flags and aps IDs if( sps->getALFEnabledFlag() ) { -#if JVET_Q0819_PH_CHANGES if (pps->getAlfInfoInPhFlag()) -#else - WRITE_FLAG(picHeader->getAlfEnabledPresentFlag(), "pic_alf_enabled_present_flag"); - if (picHeader->getAlfEnabledPresentFlag()) -#endif { WRITE_FLAG(picHeader->getAlfEnabledFlag(COMPONENT_Y), "ph_alf_enabled_flag"); if (picHeader->getAlfEnabledFlag(COMPONENT_Y)) @@ -2030,13 +1597,17 @@ void HLSWriter::codePictureHeader( PicHeader* picHeader ) const int alfChromaIdc = picHeader->getAlfEnabledFlag(COMPONENT_Cb) + picHeader->getAlfEnabledFlag(COMPONENT_Cr) * 2 ; if (sps->getChromaFormatIdc() != CHROMA_400) { +#if JVET_R0225_SEPERATE_FLAGS_ALF_CHROMA + WRITE_CODE(picHeader->getAlfEnabledFlag(COMPONENT_Cb), 1, "ph_alf_cb_enabled_flag"); + WRITE_CODE(picHeader->getAlfEnabledFlag(COMPONENT_Cr), 1, "ph_alf_cr_enabled_flag"); +#else WRITE_CODE(alfChromaIdc, 2, "ph_alf_chroma_idc"); +#endif } if (alfChromaIdc) { WRITE_CODE(picHeader->getAlfApsIdChroma(), 3, "ph_alf_aps_id_chroma"); } -#if JVET_Q0795_CCALF if (sps->getCCALFEnabledFlag()) { WRITE_FLAG(picHeader->getCcAlfEnabledFlag(COMPONENT_Cb), "ph_cc_alf_cb_enabled_flag"); @@ -2050,7 +1621,6 @@ void HLSWriter::codePictureHeader( PicHeader* picHeader ) WRITE_CODE(picHeader->getCcAlfCrApsId(), 3, "ph_cc_alf_cr_aps_id"); } } -#endif } } else @@ -2058,10 +1628,8 @@ void HLSWriter::codePictureHeader( PicHeader* picHeader ) picHeader->setAlfEnabledFlag(COMPONENT_Y, true); picHeader->setAlfEnabledFlag(COMPONENT_Cb, true); picHeader->setAlfEnabledFlag(COMPONENT_Cr, true); -#if JVET_Q0795_CCALF picHeader->setCcAlfEnabledFlag(COMPONENT_Cb, sps->getCCALFEnabledFlag()); picHeader->setCcAlfEnabledFlag(COMPONENT_Cr, sps->getCCALFEnabledFlag()); -#endif } } else @@ -2069,10 +1637,8 @@ void HLSWriter::codePictureHeader( PicHeader* picHeader ) picHeader->setAlfEnabledFlag(COMPONENT_Y, false); picHeader->setAlfEnabledFlag(COMPONENT_Cb, false); picHeader->setAlfEnabledFlag(COMPONENT_Cr, false); -#if JVET_Q0795_CCALF picHeader->setCcAlfEnabledFlag(COMPONENT_Cb, false); picHeader->setCcAlfEnabledFlag(COMPONENT_Cr, false); -#endif } // luma mapping / chroma scaling controls @@ -2101,168 +1667,85 @@ void HLSWriter::codePictureHeader( PicHeader* picHeader ) // quantization scaling lists if( sps->getScalingListFlag() ) { -#if JVET_Q0346_SCALING_LIST_USED_IN_SH WRITE_FLAG( picHeader->getExplicitScalingListEnabledFlag(), "ph_scaling_list_present_flag" ); if( picHeader->getExplicitScalingListEnabledFlag() ) -#else - WRITE_FLAG( picHeader->getScalingListPresentFlag(), "ph_scaling_list_present_flag" ); - if( picHeader->getScalingListPresentFlag() ) -#endif { WRITE_CODE( picHeader->getScalingListAPSId(), 3, "ph_scaling_list_aps_id" ); } } else { -#if JVET_Q0346_SCALING_LIST_USED_IN_SH picHeader->setExplicitScalingListEnabledFlag( false ); -#else - picHeader->setScalingListPresentFlag( false ); -#endif } -#endif - -#if !JVET_Q0119_CLEANUPS - // sub-picture IDs - if( sps->getSubPicIdPresentFlag() ) - { - if( sps->getSubPicIdSignallingPresentFlag() ) - { - for( int picIdx = 0; picIdx < sps->getNumSubPics( ); picIdx++ ) - { - picHeader->setSubPicId( picIdx, sps->getSubPicId( picIdx ) ); - } - } - else - { - WRITE_FLAG(picHeader->getSubPicIdSignallingPresentFlag(), "ph_subpic_id_signalling_present_flag"); - if( picHeader->getSubPicIdSignallingPresentFlag() ) - { - WRITE_UVLC( picHeader->getSubPicIdLen() - 1, "ph_subpic_id_len_minus1" ); -#if JVET_Q0169_SUBPIC_LEN_CONFORM - CHECK((1 << picHeader->getSubPicIdLen()) < sps->getNumSubPics(), "ph_subpic_id_len exceeds valid range"); -#endif - for( int picIdx = 0; picIdx < sps->getNumSubPics( ); picIdx++ ) - { - WRITE_CODE(picHeader->getSubPicId(picIdx), picHeader->getSubPicIdLen( ), "ph_subpic_id[i]" ); - } - } - else - { - for( int picIdx = 0; picIdx < pps->getNumSubPics( ); picIdx++ ) - { - picHeader->setSubPicId( picIdx, pps->getSubPicId( picIdx ) ); - } - } - } - } - else - { - for( int picIdx = 0; picIdx < sps->getNumSubPics( ); picIdx++ ) - { - picHeader->setSubPicId( picIdx, picIdx ); - } - } -#endif + // virtual boundaries -#if JVET_Q0246_VIRTUAL_BOUNDARY_ENABLE_FLAG if( sps->getVirtualBoundariesEnabledFlag() && !sps->getVirtualBoundariesPresentFlag() ) { WRITE_FLAG( picHeader->getVirtualBoundariesPresentFlag(), "ph_virtual_boundaries_present_flag" ); if( picHeader->getVirtualBoundariesPresentFlag() ) { -#else - if( !sps->getLoopFilterAcrossVirtualBoundariesDisabledFlag() ) - { - WRITE_FLAG( picHeader->getLoopFilterAcrossVirtualBoundariesDisabledFlag(), "ph_loop_filter_across_virtual_boundaries_disabled_present_flag" ); - if( picHeader->getLoopFilterAcrossVirtualBoundariesDisabledFlag() ) - { -#endif WRITE_CODE(picHeader->getNumVerVirtualBoundaries(), 2, "ph_num_ver_virtual_boundaries"); for( unsigned i = 0; i < picHeader->getNumVerVirtualBoundaries(); i++ ) { +#if JVET_R0266_DESC + WRITE_UVLC(picHeader->getVirtualBoundariesPosX(i) >> 3, "ph_virtual_boundaries_pos_x"); +#else WRITE_CODE(picHeader->getVirtualBoundariesPosX(i) >> 3, 13, "ph_virtual_boundaries_pos_x"); +#endif } WRITE_CODE(picHeader->getNumHorVirtualBoundaries(), 2, "ph_num_hor_virtual_boundaries"); for( unsigned i = 0; i < picHeader->getNumHorVirtualBoundaries(); i++ ) { +#if JVET_R0266_DESC + WRITE_UVLC(picHeader->getVirtualBoundariesPosY(i)>>3, "ph_virtual_boundaries_pos_y"); +#else WRITE_CODE(picHeader->getVirtualBoundariesPosY(i)>>3, 13, "ph_virtual_boundaries_pos_y"); +#endif } } else { -#if JVET_Q0246_VIRTUAL_BOUNDARY_ENABLE_FLAG picHeader->setVirtualBoundariesPresentFlag( 0 ); -#else - picHeader->setLoopFilterAcrossVirtualBoundariesDisabledFlag( 0 ); -#endif picHeader->setNumVerVirtualBoundaries( 0 ); picHeader->setNumHorVirtualBoundaries( 0 ); } } else { -#if JVET_Q0246_VIRTUAL_BOUNDARY_ENABLE_FLAG picHeader->setVirtualBoundariesPresentFlag( sps->getVirtualBoundariesPresentFlag() ); if( picHeader->getVirtualBoundariesPresentFlag() ) { -#else - picHeader->setLoopFilterAcrossVirtualBoundariesDisabledFlag( sps->getLoopFilterAcrossVirtualBoundariesDisabledFlag() ); -#endif picHeader->setNumVerVirtualBoundaries( sps->getNumVerVirtualBoundaries() ); picHeader->setNumHorVirtualBoundaries( sps->getNumHorVirtualBoundaries() ); - for( unsigned i = 0; i < 3; i++ ) + for( unsigned i = 0; i < 3; i++ ) { picHeader->setVirtualBoundariesPosX( sps->getVirtualBoundariesPosX(i), i ); picHeader->setVirtualBoundariesPosY( sps->getVirtualBoundariesPosY(i), i ); } -#if JVET_Q0246_VIRTUAL_BOUNDARY_ENABLE_FLAG } -#endif - } - -#if !JVET_Q0155_COLOUR_ID - // 4:4:4 colour plane ID - if( sps->getSeparateColourPlaneFlag() ) - { - WRITE_CODE( picHeader->getColourPlaneId(), 2, "colour_plane_id" ); } - else - { - picHeader->setColourPlaneId( 0 ); - } -#endif - + + // picture output flag if( pps->getOutputFlagPresentFlag() ) { WRITE_FLAG( picHeader->getPicOutputFlag(), "pic_output_flag" ); } - else + else { picHeader->setPicOutputFlag(true); } // reference picture lists -#if JVET_Q0819_PH_CHANGES if (pps->getRplInfoInPhFlag()) -#else - WRITE_FLAG(picHeader->getPicRplPresentFlag(), "pic_rpl_present_flag"); - if( picHeader->getPicRplPresentFlag() ) -#endif { // List0 and List1 - for(int listIdx = 0; listIdx < 2; listIdx++) - { -#if JVET_Q0482_REMOVE_CONSTANT_PARAMS + for(int listIdx = 0; listIdx < 2; listIdx++) + { if(sps->getNumRPL(listIdx) > 0 && (listIdx == 0 || (listIdx == 1 && pps->getRpl1IdxPresentFlag()))) -#else - if(sps->getNumRPL(listIdx) > 0 && !pps->getPPSRefPicListSPSIdc(listIdx) && - (listIdx == 0 || (listIdx == 1 && pps->getRpl1IdxPresentFlag()))) -#endif { WRITE_FLAG(picHeader->getRPLIdx(listIdx) != -1 ? 1 : 0, "rpl_sps_flag[i]"); } @@ -2297,7 +1780,11 @@ void HLSWriter::codePictureHeader( PicHeader* picHeader ) // explicit RPL in picture header else { - xCodeRefPicList( picHeader->getRPL(listIdx), sps->getLongTermRefsPresent(), sps->getBitsForPOC(), !sps->getUseWP() && !sps->getUseWPBiPred() ); +#if JVET_R0059_RPL_CLEANUP + xCodeRefPicList( picHeader->getRPL(listIdx), sps->getLongTermRefsPresent(), sps->getBitsForPOC(), !sps->getUseWP() && !sps->getUseWPBiPred(), -1); +#else + xCodeRefPicList( picHeader->getRPL(listIdx), sps->getLongTermRefsPresent(), sps->getBitsForPOC(), !sps->getUseWP() && !sps->getUseWPBiPred()); +#endif } // POC MSB cycle signalling for LTRP @@ -2308,7 +1795,7 @@ void HLSWriter::codePictureHeader( PicHeader* picHeader ) if (picHeader->getRPL(listIdx)->isRefPicLongterm(i)) { if (picHeader->getRPL(listIdx)->getLtrpInSliceHeaderFlag()) - { + { WRITE_CODE(picHeader->getRPL(listIdx)->getRefPicIdentifier(i), sps->getBitsForPOC(), "poc_lsb_lt[listIdx][rplsIdx][j]"); } @@ -2327,7 +1814,6 @@ void HLSWriter::codePictureHeader( PicHeader* picHeader ) if (sps->getSplitConsOverrideEnabledFlag()) { WRITE_FLAG(picHeader->getSplitConsOverrideFlag(), "partition_constraints_override_flag"); -#if JVET_Q0819_PH_CHANGES } else { @@ -2336,14 +1822,9 @@ void HLSWriter::codePictureHeader( PicHeader* picHeader ) // Q0781, two-flags if (picHeader->getPicIntraSliceAllowedFlag()) { -#endif if (picHeader->getSplitConsOverrideFlag()) { WRITE_UVLC(floorLog2(picHeader->getMinQTSize(I_SLICE)) - sps->getLog2MinCodingBlockSize(), "ph_log2_diff_min_qt_min_cb_intra_slice_luma"); -#if !JVET_Q0819_PH_CHANGES - WRITE_UVLC(floorLog2(picHeader->getMinQTSize(P_SLICE)) - sps->getLog2MinCodingBlockSize(), "ph_log2_diff_min_qt_min_cb_inter_slice"); - WRITE_UVLC(picHeader->getMaxMTTHierarchyDepth(P_SLICE), "ph_max_mtt_hierarchy_depth_inter_slice"); -#endif WRITE_UVLC(picHeader->getMaxMTTHierarchyDepth(I_SLICE), "ph_max_mtt_hierarchy_depth_intra_slice_luma"); if (picHeader->getMaxMTTHierarchyDepth(I_SLICE) != 0) { @@ -2351,13 +1832,6 @@ void HLSWriter::codePictureHeader( PicHeader* picHeader ) WRITE_UVLC(floorLog2(picHeader->getMaxTTSize(I_SLICE)) - floorLog2(picHeader->getMinQTSize(I_SLICE)), "ph_log2_diff_max_tt_min_qt_intra_slice_luma"); } -#if !JVET_Q0819_PH_CHANGES - if (picHeader->getMaxMTTHierarchyDepth(P_SLICE) != 0) - { - WRITE_UVLC(floorLog2(picHeader->getMaxBTSize(P_SLICE)) - floorLog2(picHeader->getMinQTSize(P_SLICE)), "ph_log2_diff_max_bt_min_qt_inter_slice"); - WRITE_UVLC(floorLog2(picHeader->getMaxTTSize(P_SLICE)) - floorLog2(picHeader->getMinQTSize(P_SLICE)), "ph_log2_diff_max_tt_min_qt_inter_slice"); - } -#endif if (sps->getUseDualITree()) { WRITE_UVLC(floorLog2(picHeader->getMinQTSize(I_SLICE, CHANNEL_TYPE_CHROMA)) - sps->getLog2MinCodingBlockSize(), "ph_log2_diff_min_qt_min_cb_intra_slice_chroma"); @@ -2370,55 +1844,25 @@ void HLSWriter::codePictureHeader( PicHeader* picHeader ) } } } -#if !JVET_Q0819_PH_CHANGES - else - { - picHeader->setSplitConsOverrideFlag(0); - } - - // inherit constraint values from SPS - if (!sps->getSplitConsOverrideEnabledFlag() || !picHeader->getSplitConsOverrideFlag()) - { - picHeader->setMinQTSizes(sps->getMinQTSizes()); - picHeader->setMaxMTTHierarchyDepths(sps->getMaxMTTHierarchyDepths()); - picHeader->setMaxBTSizes(sps->getMaxBTSizes()); - picHeader->setMaxTTSizes(sps->getMaxTTSizes()); - } -#endif -#if JVET_Q0819_PH_CHANGES if (picHeader->getPicIntraSliceAllowedFlag()) { -#endif // delta quantization and chrom and chroma offset if (pps->getUseDQP()) { WRITE_UVLC( picHeader->getCuQpDeltaSubdivIntra(), "ph_cu_qp_delta_subdiv_intra_slice" ); -#if !JVET_Q0819_PH_CHANGES - WRITE_UVLC( picHeader->getCuQpDeltaSubdivInter(), "ph_cu_qp_delta_subdiv_inter_slice" ); -#endif } - else + else { picHeader->setCuQpDeltaSubdivIntra( 0 ); -#if !JVET_Q0819_PH_CHANGES - picHeader->setCuQpDeltaSubdivInter( 0 ); -#endif } if (pps->getCuChromaQpOffsetListEnabledFlag()) { WRITE_UVLC( picHeader->getCuChromaQpOffsetSubdivIntra(), "ph_cu_chroma_qp_offset_subdiv_intra_slice" ); -#if !JVET_Q0819_PH_CHANGES - WRITE_UVLC( picHeader->getCuChromaQpOffsetSubdivInter(), "ph_cu_chroma_qp_offset_subdiv_inter_slice" ); -#endif } - else + else { picHeader->setCuChromaQpOffsetSubdivIntra( 0 ); -#if !JVET_Q0819_PH_CHANGES - picHeader->setCuChromaQpOffsetSubdivInter( 0 ); -#endif } -#if JVET_Q0819_PH_CHANGES } @@ -2452,22 +1896,26 @@ void HLSWriter::codePictureHeader( PicHeader* picHeader ) { picHeader->setCuChromaQpOffsetSubdivInter(0); } -#endif // temporal motion vector prediction if (sps->getSPSTemporalMVPEnabledFlag()) { WRITE_FLAG( picHeader->getEnableTMVPFlag(), "ph_temporal_mvp_enabled_flag" ); -#if JVET_Q0259_COLLOCATED_PIC_IN_PH if (picHeader->getEnableTMVPFlag() && pps->getRplInfoInPhFlag()) { +#if R0324_PH_SYNTAX_CONDITION_MODIFY + if (picHeader->getRPL(1)->getNumRefEntries() > 0) + { + WRITE_CODE(picHeader->getPicColFromL0Flag(), 1, "ph_collocated_from_l0_flag"); + } +#else WRITE_CODE(picHeader->getPicColFromL0Flag(), 1, "ph_collocated_from_l0_flag"); +#endif if ((picHeader->getPicColFromL0Flag() && picHeader->getRPL(0)->getNumRefEntries() > 1) || (!picHeader->getPicColFromL0Flag() && picHeader->getRPL(1)->getNumRefEntries() > 1)) { WRITE_UVLC(picHeader->getColRefIdx(), "ph_collocated_ref_idx"); } } -#endif } else { @@ -2475,50 +1923,19 @@ void HLSWriter::codePictureHeader( PicHeader* picHeader ) } // mvd L1 zero flag -#if !JVET_Q0482_REMOVE_CONSTANT_PARAMS - if (!pps->getPPSMvdL1ZeroIdc()) - { - WRITE_FLAG(picHeader->getMvdL1ZeroFlag(), "mvd_l1_zero_flag"); - } - else +#if R0324_PH_SYNTAX_CONDITION_MODIFY + if (!pps->getRplInfoInPhFlag() || picHeader->getRPL(1)->getNumRefEntries() > 0) { - picHeader->setMvdL1ZeroFlag( pps->getPPSMvdL1ZeroIdc() - 1 ); + WRITE_FLAG(picHeader->getMvdL1ZeroFlag(), "pic_mvd_l1_zero_flag"); } #else -#if !JVET_Q0259_COLLOCATED_PIC_IN_PH - if (picHeader->getEnableTMVPFlag() && pps->getRplInfoInPhFlag()) - { - WRITE_CODE(picHeader->getPicColFromL0Flag(), 1, "pic_collocated_from_l0_flag"); - } -#endif WRITE_FLAG(picHeader->getMvdL1ZeroFlag(), "mvd_l1_zero_flag"); #endif - // merge candidate list size -#if !JVET_Q0482_REMOVE_CONSTANT_PARAMS - if (!pps->getPPSSixMinusMaxNumMergeCandPlus1()) - { -#endif -#if !JVET_Q0798_SPS_NUMBER_MERGE_CANDIDATE - CHECK(picHeader->getMaxNumMergeCand() > MRG_MAX_NUM_CANDS, "More merge candidates signalled than supported"); - WRITE_UVLC(MRG_MAX_NUM_CANDS - picHeader->getMaxNumMergeCand(), "pic_six_minus_max_num_merge_cand"); -#endif -#if !JVET_Q0482_REMOVE_CONSTANT_PARAMS - } - else - { - picHeader->setMaxNumMergeCand(MRG_MAX_NUM_CANDS - (pps->getPPSSixMinusMaxNumMergeCandPlus1() - 1)); - } -#endif // subblock merge candidate list size if ( sps->getUseAffine() ) { -#if JVET_Q0798_SPS_NUMBER_MERGE_CANDIDATE picHeader->setMaxNumAffineMergeCand(sps->getMaxNumAffineMergeCand()); -#else - CHECK( picHeader->getMaxNumAffineMergeCand() > AFFINE_MRG_MAX_NUM_CANDS, "More affine merge candidates signalled than supported" ); - WRITE_UVLC(AFFINE_MRG_MAX_NUM_CANDS - picHeader->getMaxNumAffineMergeCand(), "pic_five_minus_max_num_subblock_merge_cand"); -#endif } else { @@ -2534,9 +1951,13 @@ void HLSWriter::codePictureHeader( PicHeader* picHeader ) { picHeader->setDisFracMMVD(false); } - + // picture level BDOF disable flags +#if R0324_PH_SYNTAX_CONDITION_MODIFY + if (sps->getBdofControlPresentFlag() && (!pps->getRplInfoInPhFlag() || picHeader->getRPL(1)->getNumRefEntries() > 0)) +#else if (sps->getBdofControlPresentFlag()) +#endif { WRITE_FLAG(picHeader->getDisBdofFlag(), "ph_disable_bdof_flag"); } @@ -2546,7 +1967,11 @@ void HLSWriter::codePictureHeader( PicHeader* picHeader ) } // picture level DMVR disable flags +#if R0324_PH_SYNTAX_CONDITION_MODIFY + if (sps->getDmvrControlPresentFlag() && (!pps->getRplInfoInPhFlag() || picHeader->getRPL(1)->getNumRefEntries() > 0)) +#else if (sps->getDmvrControlPresentFlag()) +#endif { WRITE_FLAG(picHeader->getDisDmvrFlag(), "ph_disable_dmvr_flag"); } @@ -2565,49 +1990,10 @@ void HLSWriter::codePictureHeader( PicHeader* picHeader ) picHeader->setDisProfFlag(0); } -#if JVET_Q0819_PH_CHANGES if ((pps->getUseWP() || pps->getWPBiPred()) && pps->getWpInfoInPhFlag()) { xCodePredWeightTable(picHeader, sps); } -#endif -#if !JVET_Q0798_SPS_NUMBER_MERGE_CANDIDATE -#if !JVET_Q0806 - // triangle merge candidate list size - if (sps->getUseTriangle() && picHeader->getMaxNumMergeCand() >= 2) - { - if (!pps->getPPSMaxNumMergeCandMinusMaxNumTriangleCandPlus1()) - { - CHECK(picHeader->getMaxNumMergeCand() < picHeader->getMaxNumTriangleCand(), "Incorrrect max number of triangle candidates!"); - WRITE_UVLC(picHeader->getMaxNumMergeCand() - picHeader->getMaxNumTriangleCand(), "pic_max_num_merge_cand_minus_max_num_triangle_cand"); - } - else - { - picHeader->setMaxNumTriangleCand((uint32_t)(picHeader->getMaxNumMergeCand() - (pps->getPPSMaxNumMergeCandMinusMaxNumTriangleCandPlus1() - 1))); - } - } - -#else - // geometric merge candidate list size - if (sps->getUseGeo() && picHeader->getMaxNumMergeCand() >= 2) - { -#if !JVET_Q0482_REMOVE_CONSTANT_PARAMS - if (!pps->getPPSMaxNumMergeCandMinusMaxNumGeoCandPlus1()) - { -#endif - CHECK(picHeader->getMaxNumMergeCand() < picHeader->getMaxNumGeoCand(), "Incorrrect max number of gpm candidates!"); - WRITE_UVLC(picHeader->getMaxNumMergeCand() - picHeader->getMaxNumGeoCand(), "pic_max_num_merge_cand_minus_max_num_gpm_cand"); -#if !JVET_Q0482_REMOVE_CONSTANT_PARAMS - } - else - { - picHeader->setMaxNumGeoCand((uint32_t)(picHeader->getMaxNumMergeCand() - (pps->getPPSMaxNumMergeCandMinusMaxNumGeoCandPlus1() - 1))); - } -#endif - } -#endif -#endif -#if JVET_Q0819_PH_CHANGES } // inherit constraint values from SPS if (!sps->getSplitConsOverrideEnabledFlag() || !picHeader->getSplitConsOverrideFlag()) @@ -2617,153 +2003,58 @@ void HLSWriter::codePictureHeader( PicHeader* picHeader ) picHeader->setMaxBTSizes(sps->getMaxBTSizes()); picHeader->setMaxTTSizes(sps->getMaxTTSizes()); } -#endif // ibc merge candidate list size -#if !JVET_Q0798_SPS_NUMBER_MERGE_CANDIDATE - if (sps->getIBCFlag()) - { - CHECK( picHeader->getMaxNumIBCMergeCand() > IBC_MRG_MAX_NUM_CANDS, "More IBC merge candidates signalled than supported" ); - WRITE_UVLC(IBC_MRG_MAX_NUM_CANDS - picHeader->getMaxNumIBCMergeCand(), "pic_six_minus_max_num_ibc_merge_cand"); - } -#endif -#if JVET_Q0819_PH_CHANGES if (pps->getQpDeltaInfoInPhFlag()) { WRITE_SVLC(picHeader->getQpDelta(), "ph_qp_delta"); } -#endif // joint Cb/Cr sign flag - if (sps->getJointCbCrEnabledFlag()) - { - WRITE_FLAG( picHeader->getJointCbCrSignFlag(), "ph_joint_cbcr_sign_flag" ); - } - else - { - picHeader->setJointCbCrSignFlag(false); - } - - // sao enable flags - if(sps->getSAOEnabledFlag()) - { -#if JVET_Q0819_PH_CHANGES - if (pps->getSaoInfoInPhFlag()) -#else - WRITE_FLAG(picHeader->getSaoEnabledPresentFlag(), "pic_sao_enabled_present_flag"); - if (picHeader->getSaoEnabledPresentFlag()) -#endif - { -#if JVET_Q0819_PH_CHANGES - WRITE_FLAG(picHeader->getSaoEnabledFlag(CHANNEL_TYPE_LUMA), "ph_sao_luma_enabled_flag"); -#else - WRITE_FLAG(picHeader->getSaoEnabledFlag(CHANNEL_TYPE_LUMA), "slice_sao_luma_flag"); -#endif - if (sps->getChromaFormatIdc() != CHROMA_400) - { -#if JVET_Q0819_PH_CHANGES - WRITE_FLAG(picHeader->getSaoEnabledFlag(CHANNEL_TYPE_CHROMA), "ph_sao_chroma_enabled_flag"); -#else - WRITE_FLAG(picHeader->getSaoEnabledFlag(CHANNEL_TYPE_CHROMA), "slice_sao_chroma_flag"); -#endif - } - } - else - { - picHeader->setSaoEnabledFlag(CHANNEL_TYPE_LUMA, true); - picHeader->setSaoEnabledFlag(CHANNEL_TYPE_CHROMA, true); - } - } - else - { - picHeader->setSaoEnabledFlag(CHANNEL_TYPE_LUMA, false); - picHeader->setSaoEnabledFlag(CHANNEL_TYPE_CHROMA, false); - } - -#if !JVET_Q0819_PH_CHANGES - // alf enable flags and aps IDs - if( sps->getALFEnabledFlag() ) - { -#if JVET_Q0819_PH_CHANGES - if (pps->getAlfInfoInPhFlag()) -#else - WRITE_FLAG(picHeader->getAlfEnabledPresentFlag(), "pic_alf_enabled_present_flag"); - if (picHeader->getAlfEnabledPresentFlag()) -#endif - { - WRITE_FLAG(picHeader->getAlfEnabledFlag(COMPONENT_Y), "pic_alf_enabled_flag"); - if (picHeader->getAlfEnabledFlag(COMPONENT_Y)) - { - WRITE_CODE(picHeader->getNumAlfAps(), 3, "pic_num_alf_aps_ids_luma"); - const std::vector<int>& apsId = picHeader->getAlfAPSs(); - for (int i = 0; i < picHeader->getNumAlfAps(); i++) - { - WRITE_CODE(apsId[i], 3, "pic_alf_aps_id_luma"); - } - - const int alfChromaIdc = picHeader->getAlfEnabledFlag(COMPONENT_Cb) + picHeader->getAlfEnabledFlag(COMPONENT_Cr) * 2 ; - if (sps->getChromaFormatIdc() != CHROMA_400) - { - WRITE_CODE(alfChromaIdc, 2, "pic_alf_chroma_idc"); - } - if (alfChromaIdc) - { - WRITE_CODE(picHeader->getAlfApsIdChroma(), 3, "pic_alf_aps_id_chroma"); - } -#if JVET_Q0795_CCALF - if (sps->getCCALFEnabledFlag()) - { - WRITE_FLAG(picHeader->getCcAlfEnabledFlag(COMPONENT_Cb), "ph_cc_alf_cb_enabled_flag"); - if (picHeader->getCcAlfEnabledFlag(COMPONENT_Cb)) - { - WRITE_CODE(picHeader->getCcAlfCbApsId(), 3, "ph_cc_alf_cb_aps_id"); - } - WRITE_FLAG(picHeader->getCcAlfEnabledFlag(COMPONENT_Cr), "ph_cc_alf_cr_enabled_flag"); - if (picHeader->getCcAlfEnabledFlag(COMPONENT_Cr)) - { - WRITE_CODE(picHeader->getCcAlfCrApsId(), 3, "ph_cc_alf_cr_aps_id"); - } - } -#endif + if (sps->getJointCbCrEnabledFlag()) + { + WRITE_FLAG( picHeader->getJointCbCrSignFlag(), "ph_joint_cbcr_sign_flag" ); + } + else + { + picHeader->setJointCbCrSignFlag(false); + } + + // sao enable flags + if(sps->getSAOEnabledFlag()) + { + if (pps->getSaoInfoInPhFlag()) + { + WRITE_FLAG(picHeader->getSaoEnabledFlag(CHANNEL_TYPE_LUMA), "ph_sao_luma_enabled_flag"); + if (sps->getChromaFormatIdc() != CHROMA_400) + { + WRITE_FLAG(picHeader->getSaoEnabledFlag(CHANNEL_TYPE_CHROMA), "ph_sao_chroma_enabled_flag"); } } - else + else { - picHeader->setAlfEnabledFlag(COMPONENT_Y, true); - picHeader->setAlfEnabledFlag(COMPONENT_Cb, true); - picHeader->setAlfEnabledFlag(COMPONENT_Cr, true); -#if JVET_Q0795_CCALF - picHeader->setCcAlfEnabledFlag(COMPONENT_Cb, sps->getCCALFEnabledFlag()); - picHeader->setCcAlfEnabledFlag(COMPONENT_Cr, sps->getCCALFEnabledFlag()); -#endif + picHeader->setSaoEnabledFlag(CHANNEL_TYPE_LUMA, true); + picHeader->setSaoEnabledFlag(CHANNEL_TYPE_CHROMA, true); } } - else + else { - picHeader->setAlfEnabledFlag(COMPONENT_Y, false); - picHeader->setAlfEnabledFlag(COMPONENT_Cb, false); - picHeader->setAlfEnabledFlag(COMPONENT_Cr, false); -#if JVET_Q0795_CCALF - picHeader->setCcAlfEnabledFlag(COMPONENT_Cb, false); - picHeader->setCcAlfEnabledFlag(COMPONENT_Cr, false); -#endif + picHeader->setSaoEnabledFlag(CHANNEL_TYPE_LUMA, false); + picHeader->setSaoEnabledFlag(CHANNEL_TYPE_CHROMA, false); } -#endif + +#if !JVET_R0271_SLICE_LEVEL_DQ_SDH_RRC // dependent quantization -#if !JVET_Q0482_REMOVE_CONSTANT_PARAMS - if (!pps->getPPSDepQuantEnabledIdc()) + if (sps->getDepQuantEnabledFlag()) { WRITE_FLAG(picHeader->getDepQuantEnabledFlag(), "ph_dep_quant_enabled_flag"); } else { - picHeader->setDepQuantEnabledFlag( pps->getPPSDepQuantEnabledIdc() - 1 ); + picHeader->setDepQuantEnabledFlag(false); } -#else - WRITE_FLAG(picHeader->getDepQuantEnabledFlag(), "ph_dep_quant_enabled_flag"); -#endif // sign data hiding - if( !picHeader->getDepQuantEnabledFlag() ) + if (sps->getSignDataHidingEnabledFlag() && !picHeader->getDepQuantEnabledFlag()) { WRITE_FLAG( picHeader->getSignDataHidingEnabledFlag(), "pic_sign_data_hiding_enabled_flag" ); } @@ -2771,67 +2062,56 @@ void HLSWriter::codePictureHeader( PicHeader* picHeader ) { picHeader->setSignDataHidingEnabledFlag(false); } +#endif // deblocking filter controls if (pps->getDeblockingFilterControlPresentFlag()) { if(pps->getDeblockingFilterOverrideEnabledFlag()) - { -#if JVET_Q0819_PH_CHANGES + { if (pps->getDbfInfoInPhFlag()) -#else - WRITE_FLAG(picHeader->getDeblockingFilterOverridePresentFlag(), "pic_deblocking_filter_override_present_flag"); - if( picHeader->getDeblockingFilterOverridePresentFlag() ) -#endif { WRITE_FLAG ( picHeader->getDeblockingFilterOverrideFlag(), "ph_deblocking_filter_override_flag" ); } else - { + { picHeader->setDeblockingFilterOverrideFlag(false); } } else { -#if !JVET_Q0819_PH_CHANGES - picHeader->setDeblockingFilterOverridePresentFlag(false); -#endif picHeader->setDeblockingFilterOverrideFlag(false); } if(picHeader->getDeblockingFilterOverrideFlag()) { -#if JVET_Q0121_DEBLOCKING_CONTROL_PARAMETERS - WRITE_FLAG( picHeader->getDeblockingFilterDisable(), "ph_deblocking_filter_disabled_flag" ); +#if JVET_R0388_DBF_CLEANUP + if (!pps->getPPSDeblockingFilterDisabledFlag()) + { +#endif + WRITE_FLAG(picHeader->getDeblockingFilterDisable(), "ph_deblocking_filter_disabled_flag"); +#if JVET_R0388_DBF_CLEANUP + } +#endif if( !picHeader->getDeblockingFilterDisable() ) { WRITE_SVLC( picHeader->getDeblockingFilterBetaOffsetDiv2(), "ph_beta_offset_div2" ); WRITE_SVLC( picHeader->getDeblockingFilterTcOffsetDiv2(), "ph_tc_offset_div2" ); - WRITE_SVLC( picHeader->getDeblockingFilterBetaOffsetDiv2(), "ph_cb_beta_offset_div2" ); - WRITE_SVLC( picHeader->getDeblockingFilterTcOffsetDiv2(), "ph_cb_tc_offset_div2" ); - WRITE_SVLC( picHeader->getDeblockingFilterBetaOffsetDiv2(), "ph_cr_beta_offset_div2" ); - WRITE_SVLC( picHeader->getDeblockingFilterTcOffsetDiv2(), "ph_cr_tc_offset_div2" ); - } -#else - WRITE_FLAG ( picHeader->getDeblockingFilterDisable(), "pic_deblocking_filter_disabled_flag" ); - if(!picHeader->getDeblockingFilterDisable()) - { - WRITE_SVLC( picHeader->getDeblockingFilterBetaOffsetDiv2(), "pic_beta_offset_div2" ); - WRITE_SVLC( picHeader->getDeblockingFilterTcOffsetDiv2(), "pic_tc_offset_div2" ); + WRITE_SVLC( picHeader->getDeblockingFilterCbBetaOffsetDiv2(), "ph_cb_beta_offset_div2" ); + WRITE_SVLC( picHeader->getDeblockingFilterCbTcOffsetDiv2(), "ph_cb_tc_offset_div2" ); + WRITE_SVLC( picHeader->getDeblockingFilterCrBetaOffsetDiv2(), "ph_cr_beta_offset_div2" ); + WRITE_SVLC( picHeader->getDeblockingFilterCrTcOffsetDiv2(), "ph_cr_tc_offset_div2" ); } -#endif } else { picHeader->setDeblockingFilterDisable ( pps->getPPSDeblockingFilterDisabledFlag() ); picHeader->setDeblockingFilterBetaOffsetDiv2( pps->getDeblockingFilterBetaOffsetDiv2() ); picHeader->setDeblockingFilterTcOffsetDiv2 ( pps->getDeblockingFilterTcOffsetDiv2() ); -#if JVET_Q0121_DEBLOCKING_CONTROL_PARAMETERS picHeader->setDeblockingFilterCbBetaOffsetDiv2( pps->getDeblockingFilterCbBetaOffsetDiv2() ); picHeader->setDeblockingFilterCbTcOffsetDiv2 ( pps->getDeblockingFilterCbTcOffsetDiv2() ); picHeader->setDeblockingFilterCrBetaOffsetDiv2( pps->getDeblockingFilterCrBetaOffsetDiv2() ); picHeader->setDeblockingFilterCrTcOffsetDiv2 ( pps->getDeblockingFilterCrTcOffsetDiv2() ); -#endif } } else @@ -2839,67 +2119,23 @@ void HLSWriter::codePictureHeader( PicHeader* picHeader ) picHeader->setDeblockingFilterDisable ( false ); picHeader->setDeblockingFilterBetaOffsetDiv2( 0 ); picHeader->setDeblockingFilterTcOffsetDiv2 ( 0 ); -#if JVET_Q0121_DEBLOCKING_CONTROL_PARAMETERS picHeader->setDeblockingFilterCbBetaOffsetDiv2( 0 ); picHeader->setDeblockingFilterCbTcOffsetDiv2 ( 0 ); picHeader->setDeblockingFilterCrBetaOffsetDiv2( 0 ); picHeader->setDeblockingFilterCrTcOffsetDiv2 ( 0 ); -#endif - } - -#if !JVET_Q0819_PH_CHANGES - // luma mapping / chroma scaling controls - if (sps->getUseLmcs()) - { - WRITE_FLAG(picHeader->getLmcsEnabledFlag(), "ph_lmcs_enabled_flag"); - if (picHeader->getLmcsEnabledFlag()) - { - WRITE_CODE(picHeader->getLmcsAPSId(), 2, "ph_lmcs_aps_id"); - if (sps->getChromaFormatIdc() != CHROMA_400) - { - WRITE_FLAG(picHeader->getLmcsChromaResidualScaleFlag(), "ph_chroma_residual_scale_flag"); - } - else - { - picHeader->setLmcsChromaResidualScaleFlag(false); - } - } - } - else - { - picHeader->setLmcsEnabledFlag(false); - picHeader->setLmcsChromaResidualScaleFlag(false); } - // quantization scaling lists - if( sps->getScalingListFlag() ) - { - WRITE_FLAG( picHeader->getScalingListPresentFlag(), "pic_scaling_list_present_flag" ); - if( picHeader->getScalingListPresentFlag() ) - { - WRITE_CODE( picHeader->getScalingListAPSId(), 3, "pic_scaling_list_aps_id" ); - } - } - else - { - picHeader->setScalingListPresentFlag( false ); - } -#endif // picture header extension if(pps->getPictureHeaderExtensionPresentFlag()) { WRITE_UVLC(0,"ph_extension_length"); } - -#if JVET_Q0775_PH_IN_SH + if ( writeRbspTrailingBits ) { xWriteRbspTrailingBits(); } -#else - xWriteRbspTrailingBits(); -#endif } void HLSWriter::codeSliceHeader ( Slice* pcSlice ) @@ -2909,32 +2145,17 @@ void HLSWriter::codeSliceHeader ( Slice* pcSlice ) #endif CodingStructure& cs = *pcSlice->getPic()->cs; -#if JVET_Q0775_PH_IN_SH PicHeader *picHeader = cs.picHeader; -#else - const PicHeader *picHeader = cs.picHeader; -#endif const ChromaFormat format = pcSlice->getSPS()->getChromaFormatIdc(); const uint32_t numberValidComponents = getNumberValidComponents(format); const bool chromaEnabled = isChromaEnabled(format); -#if JVET_Q0775_PH_IN_SH WRITE_FLAG(pcSlice->getPictureHeaderInSliceHeader() ? 1 : 0, "picture_header_in_slice_header_flag"); if (pcSlice->getPictureHeaderInSliceHeader()) { codePictureHeader(picHeader, false); } -#endif -#if !JVET_Q0819_PH_CHANGES - int pocBits = pcSlice->getSPS()->getBitsForPOC(); - int pocMask = (1 << pocBits) - 1; - WRITE_CODE(pcSlice->getPOC() & pocMask, pocBits, "slice_pic_order_cnt_lsb"); -#endif -#if JVET_Q0119_CLEANUPS if (pcSlice->getSPS()->getSubPicInfoPresentFlag()) -#else - if (pcSlice->getSPS()->getSubPicPresentFlag()) -#endif { uint32_t bitsSubPicId; bitsSubPicId = pcSlice->getSPS()->getSubPicIdLen(); @@ -2942,24 +2163,30 @@ void HLSWriter::codeSliceHeader ( Slice* pcSlice ) } // raster scan slices - if( pcSlice->getPPS()->getRectSliceFlag() == 0 ) + if( pcSlice->getPPS()->getRectSliceFlag() == 0 ) { // slice address is the raster scan tile index of first tile in slice - if( pcSlice->getPPS()->getNumTiles() > 1 ) - { + if( pcSlice->getPPS()->getNumTiles() > 1 ) + { int bitsSliceAddress = ceilLog2(pcSlice->getPPS()->getNumTiles()); WRITE_CODE( pcSlice->getSliceID(), bitsSliceAddress, "slice_address"); - WRITE_UVLC( pcSlice->getNumTilesInSlice() - 1, "num_tiles_in_slice_minus1"); +#if JVET_R0210_NUMTILESINSLICE_SIGNALLING + if ((int)pcSlice->getPPS()->getNumTiles() - (int)pcSlice->getSliceID() > 1) + { +#endif + WRITE_UVLC(pcSlice->getNumTilesInSlice() - 1, "num_tiles_in_slice_minus1"); +#if JVET_R0210_NUMTILESINSLICE_SIGNALLING + } +#endif } } // rectangular slices - else + else { // slice address is the index of the slice within the current sub-picture -#if JVET_Q0044_SLICE_IDX_WITH_SUBPICS uint32_t currSubPicIdx = pcSlice->getPPS()->getSubPicIdxFromSubPicId( pcSlice->getSliceSubPicId() ); SubPic currSubPic = pcSlice->getPPS()->getSubPic(currSubPicIdx); - if( currSubPic.getNumSlicesInSubPic() > 1 ) + if( currSubPic.getNumSlicesInSubPic() > 1 ) { int numSlicesInPreviousSubPics = 0; for(int sp = 0; sp < currSubPicIdx; sp++) @@ -2969,29 +2196,17 @@ void HLSWriter::codeSliceHeader ( Slice* pcSlice ) int bitsSliceAddress = ceilLog2(currSubPic.getNumSlicesInSubPic()); WRITE_CODE( pcSlice->getSliceID() - numSlicesInPreviousSubPics, bitsSliceAddress, "slice_address"); } -#else - if( pcSlice->getPPS()->getNumSlicesInPic() > 1 ) - { - int bitsSliceAddress = ceilLog2(pcSlice->getPPS()->getNumSlicesInPic()); // change to NumSlicesInSubPic when available - WRITE_CODE( pcSlice->getSliceID(), bitsSliceAddress, "slice_address"); - } -#endif } -#if JVET_Q0819_PH_CHANGES if (picHeader->getPicInterSliceAllowedFlag()) { -#endif WRITE_UVLC(pcSlice->getSliceType(), "slice_type"); -#if JVET_Q0819_PH_CHANGES } if (!picHeader->getPicIntraSliceAllowedFlag()) { CHECK(pcSlice->getSliceType() == I_SLICE, "when ph_intra_slice_allowed_flag = 0, no I_Slice is allowed"); } -#endif -#if JVET_Q0819_PH_CHANGES if (pcSlice->getSPS()->getALFEnabledFlag() && !pcSlice->getPPS()->getAlfInfoInPhFlag()) { const int alfEnabled = pcSlice->getTileGroupAlfEnabledFlag(COMPONENT_Y); @@ -3009,14 +2224,18 @@ void HLSWriter::codeSliceHeader ( Slice* pcSlice ) const int alfChromaIdc = pcSlice->getTileGroupAlfEnabledFlag(COMPONENT_Cb) + pcSlice->getTileGroupAlfEnabledFlag(COMPONENT_Cr) * 2; if (chromaEnabled) { +#if JVET_R0225_SEPERATE_FLAGS_ALF_CHROMA + WRITE_CODE(pcSlice->getTileGroupAlfEnabledFlag(COMPONENT_Cb), 1, "slice_alf_cb_enabled_flag"); + WRITE_CODE(pcSlice->getTileGroupAlfEnabledFlag(COMPONENT_Cr), 1, "slice_alf_cr_enabled_flag"); +#else WRITE_CODE(alfChromaIdc, 2, "slice_alf_chroma_idc"); +#endif } if (alfChromaIdc) { WRITE_CODE(pcSlice->getTileGroupApsIdChroma(), 3, "slice_alf_aps_id_chroma"); } -#if JVET_Q0795_CCALF if (pcSlice->getSPS()->getCCALFEnabledFlag()) { CcAlfFilterParam &filterParam = pcSlice->m_ccAlfFilterParam; @@ -3034,36 +2253,40 @@ void HLSWriter::codeSliceHeader ( Slice* pcSlice ) WRITE_CODE(pcSlice->getTileGroupCcAlfCrApsId(), 3, "slice_cc_alf_cr_aps_id"); } } -#endif } } + +#if JVET_R0200_MOVE_LMCS_AND_SCALING_LIST_SE +#if JVET_R0098_LMCS_AND_SCALING_LISTS_FOR_PH_IN_SH + if (picHeader->getLmcsEnabledFlag() && !pcSlice->getPictureHeaderInSliceHeader()) +#else + if (picHeader->getLmcsEnabledFlag()) +#endif + { + WRITE_FLAG(pcSlice->getLmcsEnabledFlag(), "slice_lmcs_enabled_flag"); + } +#if JVET_R0098_LMCS_AND_SCALING_LISTS_FOR_PH_IN_SH + if (picHeader->getExplicitScalingListEnabledFlag() && !pcSlice->getPictureHeaderInSliceHeader()) +#else + if (picHeader->getExplicitScalingListEnabledFlag()) +#endif + { + WRITE_FLAG(pcSlice->getExplicitScalingListUsed(), "slice_explicit_scaling_list_used_flag"); + } #endif -#if JVET_Q0155_COLOUR_ID // 4:4:4 colour plane ID if( pcSlice->getSPS()->getSeparateColourPlaneFlag() ) { WRITE_CODE( pcSlice->getColourPlaneId(), 2, "colour_plane_id" ); } -#endif -#if JVET_Q0819_PH_CHANGES if( !pcSlice->getPPS()->getRplInfoInPhFlag() && (!pcSlice->getIdrPicFlag() || pcSlice->getSPS()->getIDRRefParamListPresent())) -#else - if( !picHeader->getPicRplPresentFlag() && (!pcSlice->getIdrPicFlag() || pcSlice->getSPS()->getIDRRefParamListPresent()) ) -#endif { //Write L0 related syntax elements if (pcSlice->getSPS()->getNumRPL0() > 0) { -#if !JVET_Q0482_REMOVE_CONSTANT_PARAMS - if (!pcSlice->getPPS()->getPPSRefPicListSPSIdc0()) - { -#endif WRITE_FLAG(pcSlice->getRPL0idx() != -1 ? 1 : 0, "ref_pic_list_sps_flag[0]"); -#if !JVET_Q0482_REMOVE_CONSTANT_PARAMS - } -#endif } if (pcSlice->getRPL0idx() != -1) { @@ -3079,7 +2302,11 @@ void HLSWriter::codeSliceHeader ( Slice* pcSlice ) } else { //write local RPL0 - xCodeRefPicList( pcSlice->getRPL0(), pcSlice->getSPS()->getLongTermRefsPresent(), pcSlice->getSPS()->getBitsForPOC(), !pcSlice->getSPS()->getUseWP() && !pcSlice->getSPS()->getUseWPBiPred() ); +#if JVET_R0059_RPL_CLEANUP + xCodeRefPicList( pcSlice->getRPL0(), pcSlice->getSPS()->getLongTermRefsPresent(), pcSlice->getSPS()->getBitsForPOC(), !pcSlice->getSPS()->getUseWP() && !pcSlice->getSPS()->getUseWPBiPred(), -1); +#else + xCodeRefPicList( pcSlice->getRPL0(), pcSlice->getSPS()->getLongTermRefsPresent(), pcSlice->getSPS()->getBitsForPOC(), !pcSlice->getSPS()->getUseWP() && !pcSlice->getSPS()->getUseWPBiPred()); +#endif } //Deal POC Msb cycle signalling for LTRP if (pcSlice->getRPL0()->getNumberOfLongtermPictures()) @@ -3103,11 +2330,7 @@ void HLSWriter::codeSliceHeader ( Slice* pcSlice ) } //Write L1 related syntax elements -#if JVET_Q0482_REMOVE_CONSTANT_PARAMS if (pcSlice->getSPS()->getNumRPL1() > 0 && pcSlice->getPPS()->getRpl1IdxPresentFlag()) -#else - if (pcSlice->getSPS()->getNumRPL1() > 0 && pcSlice->getPPS()->getRpl1IdxPresentFlag() && !pcSlice->getPPS()->getPPSRefPicListSPSIdc1()) -#endif { WRITE_FLAG(pcSlice->getRPL1idx() != -1 ? 1 : 0, "ref_pic_list_sps_flag[1]"); } @@ -3144,7 +2367,11 @@ void HLSWriter::codeSliceHeader ( Slice* pcSlice ) } else { //write local RPL1 - xCodeRefPicList( pcSlice->getRPL1(), pcSlice->getSPS()->getLongTermRefsPresent(), pcSlice->getSPS()->getBitsForPOC(), !pcSlice->getSPS()->getUseWP() && !pcSlice->getSPS()->getUseWPBiPred() ); +#if JVET_R0059_RPL_CLEANUP + xCodeRefPicList( pcSlice->getRPL1(), pcSlice->getSPS()->getLongTermRefsPresent(), pcSlice->getSPS()->getBitsForPOC(), !pcSlice->getSPS()->getUseWP() && !pcSlice->getSPS()->getUseWPBiPred(), -1); +#else + xCodeRefPicList( pcSlice->getRPL1(), pcSlice->getSPS()->getLongTermRefsPresent(), pcSlice->getSPS()->getBitsForPOC(), !pcSlice->getSPS()->getUseWP() && !pcSlice->getSPS()->getUseWPBiPred()); +#endif } //Deal POC Msb cycle signalling for LTRP if (pcSlice->getRPL1()->getNumberOfLongtermPictures()) @@ -3168,12 +2395,10 @@ void HLSWriter::codeSliceHeader ( Slice* pcSlice ) } } -#if JVET_Q0819_PH_CHANGES +#if !JVET_R0277_RPL if( pcSlice->getPPS()->getRplInfoInPhFlag() || !pcSlice->getIdrPicFlag()|| pcSlice->getSPS()->getIDRRefParamListPresent() ) -#else - if( picHeader->getPicRplPresentFlag() || !pcSlice->getIdrPicFlag() || pcSlice->getSPS()->getIDRRefParamListPresent() ) -#endif { +#endif //check if numrefidxes match the defaults. If not, override if ((!pcSlice->isIntra() && pcSlice->getRPL0()->getNumRefEntries() > 1) || @@ -3214,7 +2439,9 @@ void HLSWriter::codeSliceHeader ( Slice* pcSlice ) pcSlice->setNumRefIdx( REF_PIC_LIST_0, pcSlice->isIntra() ? 0 : 1 ); pcSlice->setNumRefIdx( REF_PIC_LIST_1, pcSlice->isInterB() ? 1 : 0 ); } +#if !JVET_R0277_RPL } +#endif if( !pcSlice->isIntra() ) @@ -3228,13 +2455,8 @@ void HLSWriter::codeSliceHeader ( Slice* pcSlice ) WRITE_FLAG( encCabacInitFlag ? 1 : 0, "cabac_init_flag" ); } } -#if JVET_Q0259_COLLOCATED_PIC_IN_PH if (pcSlice->getPicHeader()->getEnableTMVPFlag() && !pcSlice->getPPS()->getRplInfoInPhFlag()) -#else - if( pcSlice->getPicHeader()->getEnableTMVPFlag() ) -#endif { -#if JVET_Q0482_REMOVE_CONSTANT_PARAMS if(!pcSlice->getPPS()->getRplInfoInPhFlag()) { if (pcSlice->getSliceType() == B_SLICE) @@ -3242,15 +2464,6 @@ void HLSWriter::codeSliceHeader ( Slice* pcSlice ) WRITE_FLAG(pcSlice->getColFromL0Flag(), "collocated_from_l0_flag"); } } -#else - if( pcSlice->getSliceType() == B_SLICE ) - { - if (!pcSlice->getPPS()->getPPSCollocatedFromL0Idc()) - { - WRITE_FLAG( pcSlice->getColFromL0Flag(), "collocated_from_l0_flag" ); - } - } -#endif if( pcSlice->getSliceType() != I_SLICE && ( ( pcSlice->getColFromL0Flag() == 1 && pcSlice->getNumRefIdx( REF_PIC_LIST_0 ) > 1 ) || @@ -3262,26 +2475,17 @@ void HLSWriter::codeSliceHeader ( Slice* pcSlice ) if( ( pcSlice->getPPS()->getUseWP() && pcSlice->getSliceType() == P_SLICE ) || ( pcSlice->getPPS()->getWPBiPred() && pcSlice->getSliceType() == B_SLICE ) ) { -#if JVET_Q0819_PH_CHANGES if( !pcSlice->getPPS()->getWpInfoInPhFlag() ) { xCodePredWeightTable(pcSlice); } -#else - xCodePredWeightTable(pcSlice); -#endif } -#if JVET_Q0819_PH_CHANGES if (!pcSlice->getPPS()->getQpDeltaInfoInPhFlag()) { WRITE_SVLC(pcSlice->getSliceQp() - (pcSlice->getPPS()->getPicInitQPMinus26() + 26), "slice_qp_delta"); } -#else - int iCode = pcSlice->getSliceQp() - (pcSlice->getPPS()->getPicInitQPMinus26() + 26); - WRITE_SVLC( iCode, "slice_qp_delta" ); -#endif if (pcSlice->getPPS()->getSliceChromaQpFlag()) { if (numberValidComponents > COMPONENT_Cb) @@ -3304,11 +2508,7 @@ void HLSWriter::codeSliceHeader ( Slice* pcSlice ) WRITE_FLAG(pcSlice->getUseChromaQpAdj(), "cu_chroma_qp_offset_enabled_flag"); } -#if JVET_Q0819_PH_CHANGES if (pcSlice->getSPS()->getSAOEnabledFlag() && !pcSlice->getPPS()->getSaoInfoInPhFlag()) -#else - if (pcSlice->getSPS()->getSAOEnabledFlag() && !picHeader->getSaoEnabledPresentFlag()) -#endif { WRITE_FLAG( pcSlice->getSaoEnabledFlag( CHANNEL_TYPE_LUMA ), "slice_sao_luma_flag" ); if( chromaEnabled ) @@ -3317,69 +2517,12 @@ void HLSWriter::codeSliceHeader ( Slice* pcSlice ) } } -#if !JVET_Q0819_PH_CHANGES -#if JVET_Q0819_PH_CHANGES - if (pcSlice->getSPS()->getALFEnabledFlag() && !pcSlice->getPPS()->getAlfInfoInPhFlag()) -#else - if (pcSlice->getSPS()->getALFEnabledFlag() && !picHeader->getAlfEnabledPresentFlag()) -#endif - { - const int alfEnabled = pcSlice->getTileGroupAlfEnabledFlag(COMPONENT_Y); - WRITE_FLAG(alfEnabled, "slice_alf_enabled_flag"); - - if (alfEnabled) - { - WRITE_CODE(pcSlice->getTileGroupNumAps(), 3, "slice_num_alf_aps_ids_luma"); - const std::vector<int>& apsId = pcSlice->getTileGroupApsIdLuma(); - for (int i = 0; i < pcSlice->getTileGroupNumAps(); i++) - { - WRITE_CODE(apsId[i], 3, "slice_alf_aps_id_luma"); - } - - const int alfChromaIdc = pcSlice->getTileGroupAlfEnabledFlag(COMPONENT_Cb) + pcSlice->getTileGroupAlfEnabledFlag(COMPONENT_Cr) * 2 ; - if (chromaEnabled) - { - WRITE_CODE(alfChromaIdc, 2, "slice_alf_chroma_idc"); - } - if (alfChromaIdc) - { - WRITE_CODE(pcSlice->getTileGroupApsIdChroma(), 3, "slice_alf_aps_id_chroma"); - } - -#if JVET_Q0795_CCALF - if (pcSlice->getSPS()->getCCALFEnabledFlag()) - { - CcAlfFilterParam &filterParam = pcSlice->m_ccAlfFilterParam; - WRITE_FLAG(filterParam.ccAlfFilterEnabled[COMPONENT_Cb - 1] ? 1 : 0, "slice_cc_alf_cb_enabled_flag"); - if (filterParam.ccAlfFilterEnabled[COMPONENT_Cb - 1]) - { - // write CC ALF Cb APS ID - WRITE_CODE(pcSlice->getTileGroupCcAlfCbApsId(), 3, "slice_cc_alf_cb_aps_id"); - } - // Cr - WRITE_FLAG(filterParam.ccAlfFilterEnabled[COMPONENT_Cr - 1] ? 1 : 0, "slice_cc_alf_cr_enabled_flag"); - if (filterParam.ccAlfFilterEnabled[COMPONENT_Cr - 1]) - { - // write CC ALF Cr APS ID - WRITE_CODE(pcSlice->getTileGroupCcAlfCrApsId(), 3, "slice_cc_alf_cr_aps_id"); - } - } -#endif - } - } -#endif if (pcSlice->getPPS()->getDeblockingFilterControlPresentFlag()) { -#if JVET_Q0819_PH_CHANGES if( pcSlice->getPPS()->getDeblockingFilterOverrideEnabledFlag() && !pcSlice->getPPS()->getDbfInfoInPhFlag() ) { WRITE_FLAG(pcSlice->getDeblockingFilterOverrideFlag(), "slice_deblocking_filter_override_flag"); -#else - if (pcSlice->getPPS()->getDeblockingFilterOverrideEnabledFlag() && !picHeader->getDeblockingFilterOverridePresentFlag()) - { - WRITE_FLAG(pcSlice->getDeblockingFilterOverrideFlag(), "deblocking_filter_override_flag"); -#endif } else { @@ -3387,17 +2530,22 @@ void HLSWriter::codeSliceHeader ( Slice* pcSlice ) } if (pcSlice->getDeblockingFilterOverrideFlag()) { - WRITE_FLAG(pcSlice->getDeblockingFilterDisable(), "slice_deblocking_filter_disabled_flag"); +#if JVET_R0388_DBF_CLEANUP + if (!pcSlice->getPPS()->getPPSDeblockingFilterDisabledFlag()) + { +#endif + WRITE_FLAG(pcSlice->getDeblockingFilterDisable(), "slice_deblocking_filter_disabled_flag"); +#if JVET_R0388_DBF_CLEANUP + } +#endif if(!pcSlice->getDeblockingFilterDisable()) { WRITE_SVLC (pcSlice->getDeblockingFilterBetaOffsetDiv2(), "slice_beta_offset_div2"); WRITE_SVLC (pcSlice->getDeblockingFilterTcOffsetDiv2(), "slice_tc_offset_div2"); -#if JVET_Q0121_DEBLOCKING_CONTROL_PARAMETERS WRITE_SVLC (pcSlice->getDeblockingFilterCbBetaOffsetDiv2(), "slice_cb_beta_offset_div2"); WRITE_SVLC (pcSlice->getDeblockingFilterCbTcOffsetDiv2(), "slice_cb_tc_offset_div2"); WRITE_SVLC (pcSlice->getDeblockingFilterCrBetaOffsetDiv2(), "slice_cr_beta_offset_div2"); WRITE_SVLC (pcSlice->getDeblockingFilterCrTcOffsetDiv2(), "slice_cr_tc_offset_div2"); -#endif } } else @@ -3405,12 +2553,10 @@ void HLSWriter::codeSliceHeader ( Slice* pcSlice ) pcSlice->setDeblockingFilterDisable ( picHeader->getDeblockingFilterDisable() ); pcSlice->setDeblockingFilterBetaOffsetDiv2( picHeader->getDeblockingFilterBetaOffsetDiv2() ); pcSlice->setDeblockingFilterTcOffsetDiv2 ( picHeader->getDeblockingFilterTcOffsetDiv2() ); -#if JVET_Q0121_DEBLOCKING_CONTROL_PARAMETERS pcSlice->setDeblockingFilterCbBetaOffsetDiv2( picHeader->getDeblockingFilterCbBetaOffsetDiv2() ); pcSlice->setDeblockingFilterCbTcOffsetDiv2 ( picHeader->getDeblockingFilterCbTcOffsetDiv2() ); pcSlice->setDeblockingFilterCrBetaOffsetDiv2( picHeader->getDeblockingFilterCrBetaOffsetDiv2() ); pcSlice->setDeblockingFilterCrTcOffsetDiv2 ( picHeader->getDeblockingFilterCrTcOffsetDiv2() ); -#endif } } else @@ -3418,26 +2564,52 @@ void HLSWriter::codeSliceHeader ( Slice* pcSlice ) pcSlice->setDeblockingFilterDisable ( false ); pcSlice->setDeblockingFilterBetaOffsetDiv2( 0 ); pcSlice->setDeblockingFilterTcOffsetDiv2 ( 0 ); -#if JVET_Q0121_DEBLOCKING_CONTROL_PARAMETERS pcSlice->setDeblockingFilterCbBetaOffsetDiv2( 0 ); pcSlice->setDeblockingFilterCbTcOffsetDiv2 ( 0 ); pcSlice->setDeblockingFilterCrBetaOffsetDiv2( 0 ); pcSlice->setDeblockingFilterCrTcOffsetDiv2 ( 0 ); -#endif } -#if JVET_Q0089_SLICE_LOSSLESS_CODING_CHROMA_BDPCM +#if JVET_R0271_SLICE_LEVEL_DQ_SDH_RRC + // dependent quantization + if( pcSlice->getSPS()->getDepQuantEnabledFlag() ) + { + WRITE_FLAG(pcSlice->getDepQuantEnabledFlag(), "slice_dep_quant_enabled_flag"); + } + else + { + pcSlice->setDepQuantEnabledFlag(false); + } + + // sign data hiding + if( pcSlice->getSPS()->getSignDataHidingEnabledFlag() && !pcSlice->getDepQuantEnabledFlag() ) + { + WRITE_FLAG(pcSlice->getSignDataHidingEnabledFlag(), "slice_sign_data_hiding_enabled_flag" ); + } + else + { + pcSlice->setSignDataHidingEnabledFlag(false); + } + + // signal TS residual coding disabled flag +#if JVET_R0483_SH_TSRC_DISABLED_FLAG_CLEANUP + if (pcSlice->getSPS()->getTransformSkipEnabledFlag() && !pcSlice->getDepQuantEnabledFlag() && !pcSlice->getSignDataHidingEnabledFlag()) +#else + if( !pcSlice->getDepQuantEnabledFlag() && !pcSlice->getSignDataHidingEnabledFlag() ) +#endif + { + WRITE_FLAG(pcSlice->getTSResidualCodingDisabledFlag() ? 1 : 0, "slice_ts_residual_coding_disabled_flag"); + } +#else WRITE_FLAG(pcSlice->getTSResidualCodingDisabledFlag() ? 1 : 0, "slice_ts_residual_coding_disabled_flag"); #endif -#if JVET_Q0346_LMCS_ENABLE_IN_SH +#if !JVET_R0200_MOVE_LMCS_AND_SCALING_LIST_SE if (picHeader->getLmcsEnabledFlag()) { WRITE_FLAG(pcSlice->getLmcsEnabledFlag(), "slice_lmcs_enabled_flag"); } -#endif -#if JVET_Q0346_SCALING_LIST_USED_IN_SH if (picHeader->getExplicitScalingListEnabledFlag()) { WRITE_FLAG(pcSlice->getExplicitScalingListUsed(), "slice_explicit_scaling_list_used_flag"); @@ -3453,32 +2625,37 @@ void HLSWriter::codeSliceHeader ( Slice* pcSlice ) void HLSWriter::codeConstraintInfo ( const ConstraintInfo* cinfo ) { +#if !JVET_R0090_VUI WRITE_FLAG(cinfo->getProgressiveSourceFlag(), "general_progressive_source_flag" ); WRITE_FLAG(cinfo->getInterlacedSourceFlag(), "general_interlaced_source_flag" ); +#endif WRITE_FLAG(cinfo->getNonPackedConstraintFlag(), "general_non_packed_constraint_flag" ); WRITE_FLAG(cinfo->getFrameOnlyConstraintFlag(), "general_frame_only_constraint_flag" ); -#if JVET_Q0114_CONSTRAINT_FLAGS WRITE_FLAG(cinfo->getNonProjectedConstraintFlag(), "general_non_projected_constraint_flag"); -#endif WRITE_FLAG(cinfo->getIntraOnlyConstraintFlag(), "intra_only_constraint_flag" ); WRITE_CODE(cinfo->getMaxBitDepthConstraintIdc(), 4, "max_bitdepth_constraint_idc" ); WRITE_CODE(cinfo->getMaxChromaFormatConstraintIdc(), 2, "max_chroma_format_constraint_idc" ); -#if JVET_Q0114_CONSTRAINT_FLAGS +#if JVET_R0286_GCI_CLEANUP + WRITE_FLAG(cinfo->getSingleLayerConstraintFlag(), "single_layer_constraint_flag"); + WRITE_FLAG(cinfo->getAllLayersIndependentConstraintFlag(), "all_layers_independent_constraint_flag"); +#endif WRITE_FLAG(cinfo->getNoResChangeInClvsConstraintFlag(), "no_res_change_in_clvs_constraint_flag"); WRITE_FLAG(cinfo->getOneTilePerPicConstraintFlag(), "one_tile_per_pic_constraint_flag"); WRITE_FLAG(cinfo->getOneSlicePerPicConstraintFlag(), "one_slice_per_pic_constraint_flag"); WRITE_FLAG(cinfo->getOneSubpicPerPicConstraintFlag(), "one_subpic_per_pic_constraint_flag"); -#endif WRITE_FLAG(cinfo->getNoQtbttDualTreeIntraConstraintFlag() ? 1 : 0, "no_qtbtt_dual_tree_intra_constraint_flag"); WRITE_FLAG(cinfo->getNoPartitionConstraintsOverrideConstraintFlag() ? 1 : 0, "no_partition_constraints_override_constraint_flag"); WRITE_FLAG(cinfo->getNoSaoConstraintFlag() ? 1 : 0, "no_sao_constraint_flag"); WRITE_FLAG(cinfo->getNoAlfConstraintFlag() ? 1 : 0, "no_alf_constraint_flag"); -#if JVET_Q0795_CCALF WRITE_FLAG(cinfo->getNoCCAlfConstraintFlag() ? 1 : 0, "no_ccalf_constraint_flag"); -#endif WRITE_FLAG(cinfo->getNoJointCbCrConstraintFlag() ? 1 : 0, "no_joint_cbcr_constraint_flag"); +#if JVET_R0286_GCI_CLEANUP + WRITE_FLAG(cinfo->getNoMrlConstraintFlag() ? 1 : 0, "no_mrl_constraint_flag"); + WRITE_FLAG(cinfo->getNoIspConstraintFlag() ? 1 : 0, "no_isp_constraint_flag"); + WRITE_FLAG(cinfo->getNoMipConstraintFlag() ? 1 : 0, "no_mip_constraint_flag"); +#endif WRITE_FLAG(cinfo->getNoRefWraparoundConstraintFlag() ? 1 : 0, "no_ref_wraparound_constraint_flag"); WRITE_FLAG(cinfo->getNoTemporalMvpConstraintFlag() ? 1 : 0, "no_temporal_mvp_constraint_flag"); WRITE_FLAG(cinfo->getNoSbtmvpConstraintFlag() ? 1 : 0, "no_sbtmvp_constraint_flag"); @@ -3488,25 +2665,32 @@ void HLSWriter::codeConstraintInfo ( const ConstraintInfo* cinfo ) WRITE_FLAG(cinfo->getNoCclmConstraintFlag() ? 1 : 0, "no_cclm_constraint_flag"); WRITE_FLAG(cinfo->getNoMtsConstraintFlag() ? 1 : 0, "no_mts_constraint_flag"); WRITE_FLAG(cinfo->getNoSbtConstraintFlag() ? 1 : 0, "no_sbt_constraint_flag"); +#if JVET_R0286_GCI_CLEANUP + WRITE_FLAG(cinfo->getNoLfnstConstraintFlag() ? 1 : 0, "no_lfnst_constraint_flag"); +#endif WRITE_FLAG(cinfo->getNoAffineMotionConstraintFlag() ? 1 : 0, "no_affine_motion_constraint_flag"); +#if JVET_R0286_GCI_CLEANUP + WRITE_FLAG(cinfo->getNoMmvdConstraintFlag() ? 1 : 0, "no_mmvd_constraint_flag"); + WRITE_FLAG(cinfo->getNoSmvdConstraintFlag() ? 1 : 0, "no_smvd_constraint_flag"); + WRITE_FLAG(cinfo->getNoProfConstraintFlag() ? 1 : 0, "no_prof_constraint_flag"); +#endif WRITE_FLAG(cinfo->getNoBcwConstraintFlag() ? 1 : 0, "no_bcw_constraint_flag"); WRITE_FLAG(cinfo->getNoIbcConstraintFlag() ? 1 : 0, "no_ibc_constraint_flag"); WRITE_FLAG(cinfo->getNoCiipConstraintFlag() ? 1 : 0, "no_ciip_constraint_flag"); WRITE_FLAG(cinfo->getNoFPelMmvdConstraintFlag() ? 1 : 0, "no_fpel_mmvd_constraint_flag"); -#if !JVET_Q0806 - WRITE_FLAG(cinfo->getNoTriangleConstraintFlag() ? 1 : 0, "no_triangle_constraint_flag"); -#else WRITE_FLAG(cinfo->getNoGeoConstraintFlag() ? 1 : 0, "no_gpm_constraint_flag"); -#endif WRITE_FLAG(cinfo->getNoLadfConstraintFlag() ? 1 : 0, "no_ladf_constraint_flag"); WRITE_FLAG(cinfo->getNoTransformSkipConstraintFlag() ? 1 : 0, "no_transform_skip_constraint_flag"); WRITE_FLAG(cinfo->getNoBDPCMConstraintFlag() ? 1 : 0, "no_bdpcm_constraint_flag"); +#if JVET_R0286_GCI_CLEANUP + WRITE_FLAG(cinfo->getNoPaletteConstraintFlag() ? 1 : 0, "no_palette_constraint_flag"); + WRITE_FLAG(cinfo->getNoActConstraintFlag() ? 1 : 0, "no_act_constraint_flag"); + WRITE_FLAG(cinfo->getNoLmcsConstraintFlag() ? 1 : 0, "no_lmcs_constraint_flag"); +#endif WRITE_FLAG(cinfo->getNoQpDeltaConstraintFlag() ? 1 : 0, "no_qp_delta_constraint_flag"); WRITE_FLAG(cinfo->getNoDepQuantConstraintFlag() ? 1 : 0, "no_dep_quant_constraint_flag"); WRITE_FLAG(cinfo->getNoSignDataHidingConstraintFlag() ? 1 : 0, "no_sign_data_hiding_constraint_flag"); -#if JVET_P0124_MIXED_NALU WRITE_FLAG(cinfo->getNoMixedNaluTypesInPicConstraintFlag() ? 1 : 0, "no_mixed_nalu_types_in_pic_constraint_flag"); -#endif WRITE_FLAG(cinfo->getNoTrailConstraintFlag() ? 1 : 0, "no_trail_constraint_flag"); WRITE_FLAG(cinfo->getNoStsaConstraintFlag() ? 1 : 0, "no_stsa_constraint_flag"); WRITE_FLAG(cinfo->getNoRaslConstraintFlag() ? 1 : 0, "no_rasl_constraint_flag"); @@ -3517,29 +2701,17 @@ void HLSWriter::codeConstraintInfo ( const ConstraintInfo* cinfo ) WRITE_FLAG(cinfo->getNoApsConstraintFlag() ? 1 : 0, "no_aps_constraint_flag"); } -#if JVET_Q0786_PTL_only void HLSWriter::codeProfileTierLevel ( const ProfileTierLevel* ptl, bool profileTierPresentFlag, int maxNumSubLayersMinus1 ) -#else -void HLSWriter::codeProfileTierLevel ( const ProfileTierLevel* ptl, int maxNumSubLayersMinus1 ) -#endif { -#if JVET_Q0786_PTL_only if(profileTierPresentFlag) { WRITE_CODE( int(ptl->getProfileIdc()), 7 , "general_profile_idc" ); WRITE_FLAG( ptl->getTierFlag()==Level::HIGH, "general_tier_flag" ); codeConstraintInfo( ptl->getConstraintInfo() ); } -#else - WRITE_CODE( int(ptl->getProfileIdc()), 7 , "general_profile_idc" ); - WRITE_FLAG( ptl->getTierFlag()==Level::HIGH, "general_tier_flag" ); - - codeConstraintInfo( ptl->getConstraintInfo() ); -#endif WRITE_CODE( int( ptl->getLevelIdc() ), 8, "general_level_idc" ); -#if JVET_Q0786_PTL_only if(profileTierPresentFlag) { WRITE_CODE(ptl->getNumSubProfile(), 8, "num_sub_profiles"); @@ -3548,13 +2720,6 @@ void HLSWriter::codeProfileTierLevel ( const ProfileTierLevel* ptl, int maxN WRITE_CODE(ptl->getSubProfileIdc(i) , 32, "general_sub_profile_idc[i]"); } } -#else - WRITE_CODE(ptl->getNumSubProfile(), 8, "num_sub_profiles"); - for (int i = 0; i < ptl->getNumSubProfile(); i++) - { - WRITE_CODE(ptl->getSubProfileIdc(i) , 32, "general_sub_profile_idc[i]"); - } -#endif for (int i = 0; i < maxNumSubLayersMinus1; i++) { @@ -3584,11 +2749,7 @@ void HLSWriter::codeProfileTierLevel ( const ProfileTierLevel* ptl, int maxN */ void HLSWriter::codeTilesWPPEntryPoint( Slice* pSlice ) { -#if JVET_Q0151_Q0205_ENTRYPOINTS pSlice->setNumEntryPoints( pSlice->getSPS(), pSlice->getPPS() ); -#else - pSlice->setNumEntryPoints( pSlice->getPPS() ); -#endif if( pSlice->getNumEntryPoints() == 0 ) { return; @@ -3709,7 +2870,6 @@ void HLSWriter::xCodePredWeightTable( Slice* pcSlice ) } } -#if JVET_Q0819_PH_CHANGES void HLSWriter::xCodePredWeightTable(PicHeader *picHeader, const SPS *sps) { WPScalingParam * wp; @@ -3787,12 +2947,17 @@ void HLSWriter::xCodePredWeightTable(PicHeader *picHeader, const SPS *sps) if (numRef == 0) { numLxWeights = picHeader->getNumL1Weights(); +#if R0324_PH_SYNTAX_CONDITION_MODIFY + if (picHeader->getRPL(1)->getNumRefEntries() > 0) + { + WRITE_UVLC(numLxWeights, "num_l1_weights"); + } +#endif moreSyntaxToBeParsed = (numLxWeights == 0) ? false : true; } } CHECK(totalSignalledWeightFlags > 24, "Too many signalled weight flags"); } -#endif /** code quantization matrix * \param scalingList quantization matrix information @@ -3800,16 +2965,12 @@ void HLSWriter::xCodePredWeightTable(PicHeader *picHeader, const SPS *sps) void HLSWriter::codeScalingList( const ScalingList &scalingList ) { //for each size - WRITE_FLAG(scalingList.getDisableScalingMatrixForLfnstBlks(), "scaling_matrix_for_lfnst_disabled_flag"); -#if JVET_Q0505_CHROAM_QM_SIGNALING_400 + WRITE_FLAG(scalingList.getDisableScalingMatrixForLfnstBlks(), "scaling_matrix_for_lfnst_disabled_flag"); WRITE_FLAG(scalingList.getChromaScalingListPresentFlag(), "scaling_list_chroma_present_flag"); -#endif for (uint32_t scalingListId = 0; scalingListId < 28; scalingListId++) { -#if JVET_Q0505_CHROAM_QM_SIGNALING_400 if(scalingList.getChromaScalingListPresentFlag()|| scalingList.isLumaScalingList(scalingListId)) { -#endif bool scalingListCopyModeFlag = scalingList.getScalingListCopyModeFlag(scalingListId); WRITE_FLAG(scalingListCopyModeFlag, "scaling_list_copy_mode_flag"); //copy mode if (!scalingListCopyModeFlag)// Copy Mode @@ -3825,9 +2986,7 @@ void HLSWriter::codeScalingList( const ScalingList &scalingList ) //DPCM xCodeScalingList(&scalingList, scalingListId, scalingList.getScalingListPreditorModeFlag(scalingListId)); } -#if JVET_Q0505_CHROAM_QM_SIGNALING_400 } -#endif } return; } @@ -3901,28 +3060,6 @@ bool HLSWriter::xFindMatchingLTRP(Slice* pcSlice, uint32_t *ltrpsIndex, int ltrp return false; } -#if !JVET_Q0210_UEK_REMOVAL -void HLSWriter::alfGolombEncode( int coeff, int k, const bool signed_coeff ) -{ - unsigned int symbol = abs( coeff ); - while ( symbol >= (unsigned int)( 1 << k ) ) - { - symbol -= 1 << k; - k++; - WRITE_FLAG( 0, "alf_coeff_abs_prefix" ); - } - WRITE_FLAG( 1, "alf_coeff_abs_prefix" ); - - if ( k > 0 ) - { - WRITE_CODE( symbol, k, "alf_coeff_abs_suffix" ); - } - if ( signed_coeff && coeff != 0 ) - { - WRITE_FLAG( (coeff < 0) ? 1 : 0, "alf_coeff_sign" ); - } -} -#endif void HLSWriter::alfFilter( const AlfParam& alfParam, const bool isChroma, const int altIdx ) { @@ -3939,24 +3076,16 @@ void HLSWriter::alfFilter( const AlfParam& alfParam, const bool isChroma, const for( int i = 0; i < alfShape.numCoeff - 1; i++ ) { -#if JVET_Q0210_UEK_REMOVAL WRITE_UVLC( abs(coeff[ ind* MAX_NUM_ALF_LUMA_COEFF + i ]), isChroma ? "alf_chroma_coeff_abs" : "alf_luma_coeff_abs" ); //alf_coeff_chroma[i], alf_coeff_luma_delta[i][j] if( abs( coeff[ ind* MAX_NUM_ALF_LUMA_COEFF + i ] ) != 0 ) { WRITE_FLAG( ( coeff[ ind* MAX_NUM_ALF_LUMA_COEFF + i ] < 0 ) ? 1 : 0, isChroma ? "alf_chroma_coeff_sign" : "alf_luma_coeff_sign" ); } -#else - alfGolombEncode( coeff[ind* MAX_NUM_ALF_LUMA_COEFF + i], 3 ); // alf_coeff_chroma[i], alf_coeff_luma_delta[i][j] -#endif } } // Clipping values coding -#if JVET_Q0249_ALF_CHROMA_CLIPFLAG if( alfParam.nonLinearFlag[isChroma] ) -#else - if( alfParam.nonLinearFlag[isChroma][altIdx] ) -#endif { for (int ind = 0; ind < numFilters; ++ind) { diff --git a/source/Lib/EncoderLib/VLCWriter.h b/source/Lib/EncoderLib/VLCWriter.h index 1be9d96c7308fc602108da20754efa0c1480bff0..dddc1dac5e8f842268f18b1056239cfc9b38beff 100644 --- a/source/Lib/EncoderLib/VLCWriter.h +++ b/source/Lib/EncoderLib/VLCWriter.h @@ -113,12 +113,14 @@ public: virtual ~HLSWriter() {} private: - void xCodeRefPicList( const ReferencePictureList* rpl, bool isLongTermPresent, uint32_t ltLsbBitsCount, const bool isForbiddenZeroDeltaPoc ); +#if JVET_R0059_RPL_CLEANUP + void xCodeRefPicList( const ReferencePictureList* rpl, bool isLongTermPresent, uint32_t ltLsbBitsCount, const bool isForbiddenZeroDeltaPoc, int rplIdx); +#else + void xCodeRefPicList( const ReferencePictureList* rpl, bool isLongTermPresent, uint32_t ltLsbBitsCount, const bool isForbiddenZeroDeltaPoc); +#endif bool xFindMatchingLTRP ( Slice* pcSlice, uint32_t *ltrpsIndex, int ltrpPOC, bool usedFlag ); void xCodePredWeightTable ( Slice* pcSlice ); -#if JVET_Q0819_PH_CHANGES void xCodePredWeightTable ( PicHeader *picHeader, const SPS *sps ); -#endif void xCodeScalingList ( const ScalingList* scalingList, uint32_t scalinListId, bool isPredictor); public: void setBitstream ( OutputBitstream* p ) { m_pcBitIf = p; } @@ -131,43 +133,20 @@ public: void codeLmcsAps ( APS* pcAPS ); void codeScalingListAps ( APS* pcAPS ); void codeVPS ( const VPS* pcVPS ); -#if JVET_Q0117_PARAMETER_SETS_CLEANUP void codeDCI ( const DCI* dci ); -#else - void codeDPS ( const DPS* dps ); -#endif -#if JVET_Q0775_PH_IN_SH void codePictureHeader ( PicHeader* picHeader, bool writeRbspTrailingBits ); -#else - void codePictureHeader ( PicHeader* picHeader ); -#endif void codeSliceHeader ( Slice* pcSlice ); void codeConstraintInfo ( const ConstraintInfo* cinfo ); -#if JVET_Q0786_PTL_only void codeProfileTierLevel ( const ProfileTierLevel* ptl, bool profileTierPresentFlag, int maxNumSubLayersMinus1 ); -#else - void codeProfileTierLevel ( const ProfileTierLevel* ptl, int maxNumSubLayersMinus1 ); -#endif -#if JVET_P0118_HRD_ASPECTS void codeOlsHrdParameters(const GeneralHrdParams * generalHrd, const OlsHrdParams *olsHrd , const uint32_t firstSubLayer, const uint32_t maxNumSubLayersMinus1); -#else - void codeHrdParameters ( const HRDParameters *hrd, const uint32_t firstSubLayer, const uint32_t maxNumSubLayersMinus1); -#endif -#if JVET_P0118_HRD_ASPECTS void codeGeneralHrdparameters(const GeneralHrdParams *hrd); -#endif void codeTilesWPPEntryPoint ( Slice* pSlice ); void codeScalingList ( const ScalingList &scalingList ); void alfFilter( const AlfParam& alfParam, const bool isChroma, const int altIdx ); -#if JVET_P0117_PTL_SCALABILITY void dpb_parameters(int maxSubLayersMinus1, bool subLayerInfoFlag, const SPS *pcSPS); -#endif private: -#if !JVET_Q0210_UEK_REMOVAL - void alfGolombEncode( const int coeff, const int k, const bool signed_coeff=true ); -#endif }; //! \} diff --git a/source/Lib/EncoderLib/WeightPredAnalysis.cpp b/source/Lib/EncoderLib/WeightPredAnalysis.cpp index 454be151796ba9dc67a0220e4883c5b5858d1636..c3dcee32888fede40414437e3e98019b6256151b 100644 --- a/source/Lib/EncoderLib/WeightPredAnalysis.cpp +++ b/source/Lib/EncoderLib/WeightPredAnalysis.cpp @@ -98,24 +98,6 @@ void xCalcHistogram(const Pel *pPel, } } -#if !JVET_Q0447_WP_PARAM_ESTIM -static -Distortion xCalcHistDistortion (const std::vector<int> &histogram0, - const std::vector<int> &histogram1) -{ - Distortion distortion = 0; - CHECK(histogram0.size()!=histogram1.size(), "Different histogram sizes"); - const int numElements=int(histogram0.size()); - - // Scan histograms to compute histogram distortion - for (int i = 0; i <= numElements; i++) - { - distortion += (Distortion)(abs(histogram0[i] - histogram1[i])); - } - - return distortion; -} -#endif static void xScaleHistogram(const std::vector<int> &histogramInput, @@ -146,7 +128,6 @@ void xScaleHistogram(const std::vector<int> &histogramInput, } } -#if JVET_Q0447_WP_PARAM_ESTIM static Distortion xCalcHistCumulDistortion(const std::vector<int>& histogram0, const std::vector<int>& histogram1) @@ -166,7 +147,6 @@ Distortion xCalcHistCumulDistortion(const std::vector<int>& histogram0, return distortion; } -#endif static Distortion xSearchHistogram(const std::vector<int> &histogramSource, @@ -202,11 +182,7 @@ Distortion xSearchHistogram(const std::vector<int> &histogramSource, searchOffset++) { xScaleHistogram(histogramRef, outputHistogram, bitDepth, log2Denom, searchWeight, searchOffset, bHighPrecision); -#if JVET_Q0447_WP_PARAM_ESTIM const Distortion distortion = xCalcHistCumulDistortion(histogramSource, outputHistogram); -#else - const Distortion distortion = xCalcHistDistortion(histogramSource, outputHistogram); -#endif if (distortion < minDistortion) { @@ -225,11 +201,7 @@ Distortion xSearchHistogram(const std::vector<int> &histogramSource, const int deltaOffset = Clip3( -4*maxOffset, 4*maxOffset-1, (searchOffset - pred) ); // signed 10bit (if !bHighPrecision) const int clippedOffset = Clip3( -1*maxOffset, 1*maxOffset-1, (deltaOffset + pred) ); // signed 8bit (if !bHighPrecision) xScaleHistogram(histogramRef, outputHistogram, bitDepth, log2Denom, searchWeight, clippedOffset, bHighPrecision); -#if JVET_Q0447_WP_PARAM_ESTIM const Distortion distortion = xCalcHistCumulDistortion(histogramSource, outputHistogram); -#else - const Distortion distortion = xCalcHistDistortion(histogramSource, outputHistogram); -#endif if (distortion < minDistortion) { @@ -542,7 +514,6 @@ bool WeightPredAnalysis::xSelectWPHistExtClip(Slice *const slice, const int log2 int offsetDef = 0; // calculate SAD costs with/without wp for luma -#if JVET_Q0447_WP_PARAM_ESTIM std::vector<int> histogramOrg; std::vector<int> histogramRef; uint64_t SADnoWP = std::numeric_limits<uint64_t>::max(); @@ -559,12 +530,8 @@ bool WeightPredAnalysis::xSelectWPHistExtClip(Slice *const slice, const int log2 { SADnoWP = (uint64_t)xCalcSADvalueWPOptionalClip(bitDepth, pOrg, pRef, width, height, orgStride, refStride, log2Denom, defaultWeight, 0, useHighPrecision, bClipInitialSADWP); } -#else - const int64_t SADnoWP = xCalcSADvalueWPOptionalClip(bitDepth, pOrg, pRef, width, height, orgStride, refStride, log2Denom, defaultWeight, 0, useHighPrecision, bClipInitialSADWP); -#endif if (SADnoWP > 0) { -#if JVET_Q0447_WP_PARAM_ESTIM uint64_t SADWP = std::numeric_limits<uint64_t>::max(); if (bUseHistogram && compID == COMPONENT_Y) { @@ -576,31 +543,18 @@ bool WeightPredAnalysis::xSelectWPHistExtClip(Slice *const slice, const int log2 { SADWP = (uint64_t)xCalcSADvalueWPOptionalClip(bitDepth, pOrg, pRef, width, height, orgStride, refStride, log2Denom, weight, offset, useHighPrecision, bClipInitialSADWP); } -#else - const int64_t SADWP = xCalcSADvalueWPOptionalClip(bitDepth, pOrg, pRef, width, height, orgStride, refStride, log2Denom, weight, offset, useHighPrecision, bClipInitialSADWP); -#endif const double dRatioSAD = (double)SADWP / (double)SADnoWP; double dRatioSr0SAD = std::numeric_limits<double>::max(); double dRatioSrSAD = std::numeric_limits<double>::max(); if (bUseHistogram) { -#if !JVET_Q0447_WP_PARAM_ESTIM - std::vector<int> histogramOrg;// = pPic->getHistogram(compID); - std::vector<int> histogramRef;// = slice->getRefPic(eRefPicList, refIdxTemp)->getPicYuvRec()->getHistogram(compID); -#endif std::vector<int> searchedHistogram; -#if !JVET_Q0447_WP_PARAM_ESTIM - // Compute histograms - xCalcHistogram(pOrg, histogramOrg, width, height, orgStride, 1 << bitDepth); - xCalcHistogram(pRef, histogramRef, width, height, refStride, 1 << bitDepth); -#endif // Do a histogram search around DC WP parameters; resulting distortion and 'searchedHistogram' is discarded xSearchHistogram(histogramOrg, histogramRef, searchedHistogram, bitDepth, log2Denom, weight, offset, useHighPrecision, compID); // calculate updated WP SAD -#if JVET_Q0447_WP_PARAM_ESTIM uint64_t SADSrWP = std::numeric_limits<uint64_t>::max(); if (bUseHistogram && compID == COMPONENT_Y) { @@ -612,9 +566,6 @@ bool WeightPredAnalysis::xSelectWPHistExtClip(Slice *const slice, const int log2 { SADSrWP = (uint64_t)xCalcSADvalueWP(bitDepth, pOrg, pRef, width, height, orgStride, refStride, log2Denom, weight, offset, useHighPrecision); } -#else - const int64_t SADSrWP = xCalcSADvalueWP(bitDepth, pOrg, pRef, width, height, orgStride, refStride, log2Denom, weight, offset, useHighPrecision); -#endif dRatioSrSAD = (double)SADSrWP / (double)SADnoWP; if (bDoEnhancement) @@ -622,7 +573,6 @@ bool WeightPredAnalysis::xSelectWPHistExtClip(Slice *const slice, const int log2 // Do the same around the default ones; resulting distortion and 'searchedHistogram' is discarded xSearchHistogram(histogramOrg, histogramRef, searchedHistogram, bitDepth, log2Denom, weightDef, offsetDef, useHighPrecision, compID); // calculate updated WP SAD -#if JVET_Q0447_WP_PARAM_ESTIM uint64_t SADSr0WP = std::numeric_limits<uint64_t>::max(); if (bUseHistogram && compID == COMPONENT_Y) { @@ -634,9 +584,6 @@ bool WeightPredAnalysis::xSelectWPHistExtClip(Slice *const slice, const int log2 { SADSr0WP = (uint64_t)xCalcSADvalueWP(bitDepth, pOrg, pRef, width, height, orgStride, refStride, log2Denom, weightDef, offsetDef, useHighPrecision); } -#else - const int64_t SADSr0WP = xCalcSADvalueWP(bitDepth, pOrg, pRef, width, height, orgStride, refStride, log2Denom, weightDef, offsetDef, useHighPrecision); -#endif dRatioSr0SAD = (double)SADSr0WP / (double)SADnoWP; } } diff --git a/source/Lib/Utilities/VideoIOYuv.cpp b/source/Lib/Utilities/VideoIOYuv.cpp index 0385c0dfb29627ccdc422b2e282092a6f8a895e1..a8b9b77183d936def0ac7dd5a35b5efe49822550 100644 --- a/source/Lib/Utilities/VideoIOYuv.cpp +++ b/source/Lib/Utilities/VideoIOYuv.cpp @@ -915,12 +915,8 @@ bool VideoIOYuv::read ( PelUnitBuf& pic, PelUnitBuf& picOrg, const InputColourSp const bool b709Compliance=(bClipToRec709) && (m_bitdepthShift[chType] < 0 && desired_bitdepth >= 8); /* ITU-R BT.709 compliant clipping for converting say 10b to 8b */ const Pel minval = b709Compliance? (( 1 << (desired_bitdepth - 8)) ) : 0; const Pel maxval = b709Compliance? ((0xff << (desired_bitdepth - 8)) -1) : (1 << desired_bitdepth) - 1; -#if JVET_Q0438_MONOCHROME_BUGFIXES const bool processComponent = (size_t)compID < picOrg.bufs.size(); Pel* const dst = processComponent ? picOrg.get(compID).bufAt(0,0) : nullptr; -#else - Pel* const dst = picOrg.get(compID).bufAt(0,0); -#endif #if EXTENSION_360_VIDEO const uint32_t stride444 = picOrg.get(compID).stride; #endif @@ -929,7 +925,6 @@ bool VideoIOYuv::read ( PelUnitBuf& pic, PelUnitBuf& picOrg, const InputColourSp return false; } -#if JVET_Q0438_MONOCHROME_BUGFIXES if (processComponent) { if (! verifyPlane( dst, stride444, width444, height444, pad_h444, pad_v444, compID, format, m_fileBitdepth[chType]) ) @@ -938,17 +933,6 @@ bool VideoIOYuv::read ( PelUnitBuf& pic, PelUnitBuf& picOrg, const InputColourSp } scalePlane( picOrg.get(compID), m_bitdepthShift[chType], minval, maxval); } -#else - if (! verifyPlane( dst, stride444, width444, height444, pad_h444, pad_v444, compID, format, m_fileBitdepth[chType]) ) - { - EXIT("Source image contains values outside the specified bit range!"); - } - - if( (size_t)compID < picOrg.bufs.size() ) - { - scalePlane( picOrg.get(compID), m_bitdepthShift[chType], minval, maxval); - } -#endif } #if EXTENSION_360_VIDEO @@ -1263,22 +1247,12 @@ bool VideoIOYuv::writeUpscaledPicture( const SPS& sps, const PPS& pps, const CPe PelStorage upscaledPic; upscaledPic.create( chromaFormatIDC, Area( Position(), Size( sps.getMaxPicWidthInLumaSamples(), sps.getMaxPicHeightInLumaSamples() ) ) ); -#if JVET_Q0487_SCALING_WINDOW_ISSUES int curPicWidth = sps.getMaxPicWidthInLumaSamples() - SPS::getWinUnitX( sps.getChromaFormatIdc() ) * ( afterScaleWindowFullResolution.getWindowLeftOffset() + afterScaleWindowFullResolution.getWindowRightOffset() ); int curPicHeight = sps.getMaxPicHeightInLumaSamples() - SPS::getWinUnitY( sps.getChromaFormatIdc() ) * ( afterScaleWindowFullResolution.getWindowTopOffset() + afterScaleWindowFullResolution.getWindowBottomOffset() ); -#else - int curPicWidth = sps.getMaxPicWidthInLumaSamples() - afterScaleWindowFullResolution.getWindowLeftOffset() - afterScaleWindowFullResolution.getWindowRightOffset(); - int curPicHeight = sps.getMaxPicHeightInLumaSamples() - afterScaleWindowFullResolution.getWindowTopOffset() - afterScaleWindowFullResolution.getWindowBottomOffset(); -#endif const Window& beforeScalingWindow = pps.getScalingWindow(); -#if JVET_Q0487_SCALING_WINDOW_ISSUES int refPicWidth = pps.getPicWidthInLumaSamples() - SPS::getWinUnitX( sps.getChromaFormatIdc() ) * ( beforeScalingWindow.getWindowLeftOffset() + beforeScalingWindow.getWindowRightOffset() ); int refPicHeight = pps.getPicHeightInLumaSamples() - SPS::getWinUnitY( sps.getChromaFormatIdc() ) * ( beforeScalingWindow.getWindowTopOffset() + beforeScalingWindow.getWindowBottomOffset() ); -#else - int refPicWidth = pps.getPicWidthInLumaSamples() - beforeScalingWindow.getWindowLeftOffset() - beforeScalingWindow.getWindowRightOffset(); - int refPicHeight = pps.getPicHeightInLumaSamples() - beforeScalingWindow.getWindowTopOffset() - beforeScalingWindow.getWindowBottomOffset(); -#endif int xScale = ( ( refPicWidth << SCALE_RATIO_BITS ) + ( curPicWidth >> 1 ) ) / curPicWidth; int yScale = ( ( refPicHeight << SCALE_RATIO_BITS ) + ( curPicHeight >> 1 ) ) / curPicHeight;