Changeset 906 in SHVCSoftware


Ignore:
Timestamp:
15 Oct 2014, 07:25:10 (10 years ago)
Author:
seregin
Message:

merge SHM-dev

Location:
trunk
Files:
86 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/cfg

  • trunk/cfg/encoder_intra_he10.cfg

    r588 r906  
    8484
    8585#============ WaveFront ================
    86 WaveFrontSynchro                    : 0                # 0:  No WaveFront synchronisation (WaveFrontSubstreams must be 1 in this case).
     86#WaveFrontSynchro                    : 0                # 0:  No WaveFront synchronisation (WaveFrontSubstreams must be 1 in this case).
    8787                                                       # >0: WaveFront synchronises with the LCU above and to the right by this many LCUs.
    8888
  • trunk/cfg/encoder_intra_main.cfg

    r595 r906  
    8888
    8989#============ WaveFront ================
    90 WaveFrontSynchro                    : 0                # 0:  No WaveFront synchronisation (WaveFrontSubstreams must be 1 in this case).
     90#WaveFrontSynchro                    : 0                # 0:  No WaveFront synchronisation (WaveFrontSubstreams must be 1 in this case).
    9191                                                       # >0: WaveFront synchronises with the LCU above and to the right by this many LCUs.
    9292
  • trunk/cfg/encoder_intra_main10.cfg

    r595 r906  
    8888
    8989#============ WaveFront ================
    90 WaveFrontSynchro                    : 0                # 0:  No WaveFront synchronisation (WaveFrontSubstreams must be 1 in this case).
     90#WaveFrontSynchro                    : 0                # 0:  No WaveFront synchronisation (WaveFrontSubstreams must be 1 in this case).
    9191                                                       # >0: WaveFront synchronises with the LCU above and to the right by this many LCUs.
    9292
  • trunk/cfg/encoder_lowdelay_P_he10.cfg

    r588 r906  
    8989
    9090#============ WaveFront ================
    91 WaveFrontSynchro                    : 0                # 0:  No WaveFront synchronisation (WaveFrontSubstreams must be 1 in this case).
     91#WaveFrontSynchro                    : 0                # 0:  No WaveFront synchronisation (WaveFrontSubstreams must be 1 in this case).
    9292                                                       # >0: WaveFront synchronises with the LCU above and to the right by this many LCUs.
    9393
  • trunk/cfg/encoder_lowdelay_P_main.cfg

    r595 r906  
    9393
    9494#============ WaveFront ================
    95 WaveFrontSynchro                    : 0                # 0:  No WaveFront synchronisation (WaveFrontSubstreams must be 1 in this case).
     95#WaveFrontSynchro                    : 0                # 0:  No WaveFront synchronisation (WaveFrontSubstreams must be 1 in this case).
    9696                                                       # >0: WaveFront synchronises with the LCU above and to the right by this many LCUs.
    9797
  • trunk/cfg/encoder_lowdelay_P_main10.cfg

    r595 r906  
    9393
    9494#============ WaveFront ================
    95 WaveFrontSynchro                    : 0                # 0:  No WaveFront synchronisation (WaveFrontSubstreams must be 1 in this case).
     95#WaveFrontSynchro                    : 0                # 0:  No WaveFront synchronisation (WaveFrontSubstreams must be 1 in this case).
    9696                                                       # >0: WaveFront synchronises with the LCU above and to the right by this many LCUs.
    9797
  • trunk/cfg/encoder_lowdelay_he10.cfg

    r595 r906  
    8989
    9090#============ WaveFront ================
    91 WaveFrontSynchro                    : 0                # 0:  No WaveFront synchronisation (WaveFrontSubstreams must be 1 in this case).
     91#WaveFrontSynchro                    : 0                # 0:  No WaveFront synchronisation (WaveFrontSubstreams must be 1 in this case).
    9292                                                       # >0: WaveFront synchronises with the LCU above and to the right by this many LCUs.
    9393
  • trunk/cfg/encoder_lowdelay_main.cfg

    r595 r906  
    9393
    9494#============ WaveFront ================
    95 WaveFrontSynchro                    : 0                # 0:  No WaveFront synchronisation (WaveFrontSubstreams must be 1 in this case).
     95#WaveFrontSynchro                    : 0                # 0:  No WaveFront synchronisation (WaveFrontSubstreams must be 1 in this case).
    9696                                                       # >0: WaveFront synchronises with the LCU above and to the right by this many LCUs.
    9797
  • trunk/cfg/encoder_lowdelay_main10.cfg

    r595 r906  
    9393
    9494#============ WaveFront ================
    95 WaveFrontSynchro                    : 0                # 0:  No WaveFront synchronisation (WaveFrontSubstreams must be 1 in this case).
     95#WaveFrontSynchro                    : 0                # 0:  No WaveFront synchronisation (WaveFrontSubstreams must be 1 in this case).
    9696                                                       # >0: WaveFront synchronises with the LCU above and to the right by this many LCUs.
    9797
  • trunk/cfg/encoder_randomaccess_he10.cfg

    r588 r906  
    9494
    9595#============ WaveFront ================
    96 WaveFrontSynchro                    : 0                # 0:  No WaveFront synchronisation (WaveFrontSubstreams must be 1 in this case).
     96#WaveFrontSynchro                    : 0                # 0:  No WaveFront synchronisation (WaveFrontSubstreams must be 1 in this case).
    9797                                                       # >0: WaveFront synchronises with the LCU above and to the right by this many LCUs.
    9898
  • trunk/cfg/encoder_randomaccess_main.cfg

    r595 r906  
    9797
    9898#============ WaveFront ================
    99 WaveFrontSynchro                    : 0                # 0:  No WaveFront synchronisation (WaveFrontSubstreams must be 1 in this case).
     99#WaveFrontSynchro                    : 0                # 0:  No WaveFront synchronisation (WaveFrontSubstreams must be 1 in this case).
    100100                                                       # >0: WaveFront synchronises with the LCU above and to the right by this many LCUs.
    101101
  • trunk/cfg/encoder_randomaccess_main10.cfg

    r595 r906  
    9797
    9898#============ WaveFront ================
    99 WaveFrontSynchro                    : 0                # 0:  No WaveFront synchronisation (WaveFrontSubstreams must be 1 in this case).
     99#WaveFrontSynchro                    : 0                # 0:  No WaveFront synchronisation (WaveFrontSubstreams must be 1 in this case).
    100100                                                       # >0: WaveFront synchronises with the LCU above and to the right by this many LCUs.
    101101
  • trunk/cfg/layers.cfg

    r815 r906  
    11NumLayers                     : 2
    2 AvcBase                       : 0
     2NonHEVCBase                   : 0
    33ScalabilityMask1              : 0           # Multiview
    44ScalabilityMask2              : 1           # Scalable
     
    2323RCForceIntraQP0               : 0           # Rate control: force intra QP to be equal to initial QP for layer 0
    2424
     25#============ WaveFront ================
     26WaveFrontSynchro0             : 0           # 0:  No WaveFront synchronisation (WaveFrontSubstreams must be 1 in this case).
     27                                            # >0: WaveFront synchronises with the LCU above and to the right by this many LCUs.
    2528
    2629#============= LAYER 1 ==================
     
    4245RCForceIntraQP1               : 0           # Rate control: force intra QP to be equal to initial QP for layer 1
    4346
     47#============ WaveFront ================
     48WaveFrontSynchro1             : 0           # 0:  No WaveFront synchronisation (WaveFrontSubstreams must be 1 in this case).
     49                                            # >0: WaveFront synchronises with the LCU above and to the right by this many LCUs.
    4450
    45 NumLayerSets                  : 1
    46 NumLayerInIdList0             : 2
    47 LayerSetLayerIdList0          : 0 1
     51NumLayerSets                  : 2           # Include default layer set, value of 0 not allowed
     52NumLayerInIdList1             : 2           # 0-th layer set is default, need not specify LayerSetLayerIdList0 or NumLayerInIdList0
     53LayerSetLayerIdList1          : 0 1
    4854
    4955NumAddLayerSets               : 0
     56NumOutputLayerSets            : 2           # Include defualt OLS, value of 0 not allowed
     57DefaultTargetOutputLayerIdc   : 1
     58NumLayersInOutputLayerSet     : 1           # The number of layers in the 0-th OLS should not be specified,
     59# ListOfOutputLayers0 need not be specified
     60ListOfOutputLayers1               : 1
  • trunk/cfg/layers_avcbase.cfg

    r713 r906  
    11NumLayers                     : 2
    2 AvcBase                       : 1
     2NonHEVCBase                   : 1
    33ScalabilityMask1              : 0           # Multiview
    44ScalabilityMask2              : 1           # Scalable
     
    2020RCForceIntraQP0               : 0           # Rate control: force intra QP to be equal to initial QP for layer 0
    2121
     22#============ WaveFront ================
     23WaveFrontSynchro0             : 0           # 0:  No WaveFront synchronisation (WaveFrontSubstreams must be 1 in this case).
     24                                            # >0: WaveFront synchronises with the LCU above and to the right by this many LCUs.
    2225
    2326#============= LAYER 1 ==================
     
    3841InitialQP1                    : 0           # Rate control: initial QP for layer 1
    3942RCForceIntraQP1               : 0           # Rate control: force intra QP to be equal to initial QP for layer 1
     43
     44WaveFrontSynchro1             : 0           # 0:  No WaveFront synchronisation (WaveFrontSubstreams must be 1 in this case).
     45                                            # >0: WaveFront synchronises with the LCU above and to the right by this many LCUs.
     46
     47NumLayerSets                  : 2           # Include default layer set, value of 0 not allowed
     48NumLayerInIdList1             : 2           # 0-th layer set is default, need not specify LayerSetLayerIdList0 or NumLayerInIdList0
     49LayerSetLayerIdList1          : 0 1
     50
     51NumAddLayerSets               : 0
     52NumOutputLayerSets            : 2           # Include defualt OLS, value of 0 not allowed
     53DefaultTargetOutputLayerIdc   : 1
     54NumLayersInOutputLayerSet     : 1           # The number of layers in the 0-th OLS should not be specified,
     55# ListOfOutputLayers0 need not be specified
     56ListOfOutputLayers1               : 1
  • trunk/cfg/per-sequence-svc-avcbase/BQTerrace-2x.cfg

    r752 r906  
    2222IntraPeriod1                  : 64          # Period of I-Frame ( -1 = only first)
    2323ConformanceMode1              : 1           # conformance mode
    24 NumScaledRefLayerOffsets1     : 1           # Number of scaled entry offsets for this layer
    25 ScaledRefLayerId1             : 0           # Scaled reference layer ID
    26 ScaledRefLayerBottomOffset1   : -4          # offset for spatial alignment of the base and enhancement layers
     24NumScaledRefLayerOffsets1        : 1        # Number of reference location offset parameters
     25ScaledRefLayerId1                : 0        # List of ref layer id (i-th entry for i-th ref loc offset parameters)
     26ScaledRefLayerOffsetPresentFlag1 : 0        # List of scaled ref layer offset present flags
     27RefRegionOffsetPresentFlag1      : 1        # List of ref region offset present flags
     28RefRegionBottomOffset1           : 2        # List of ref region bottom offsets
     29ResamplePhaseSetPresentFlag1     : 0        # List of resample phase set present flags
    2730QP1                           : 20
     31
  • trunk/cfg/per-sequence-svc-avcbase/BQTerrace-SNR.cfg

    r595 r906  
    2222IntraPeriod1                  : 64          # Period of I-Frame ( -1 = only first)
    2323ConformanceMode1              : 1           # conformance mode
    24 NumScaledRefLayerOffsets1     : 1           # Number of scaled entry offsets for this layer
    25 ScaledRefLayerId1             : 0           # Scaled reference layer ID
    26 ScaledRefLayerBottomOffset1   : -4          # offset for spatial alignment of the base and enhancement layers
     24NumScaledRefLayerOffsets1        : 1        # Number of reference location offset parameters
     25ScaledRefLayerId1                : 0        # List of ref layer id (i-th entry for i-th ref loc offset parameters)
     26ScaledRefLayerOffsetPresentFlag1 : 0        # List of scaled ref layer offset present flags
     27RefRegionOffsetPresentFlag1      : 1        # List of ref region offset present flags
     28RefRegionBottomOffset1           : 4        # List of ref region bottom offsets
     29ResamplePhaseSetPresentFlag1     : 0        # List of resample phase set present flags
    2730QP1                           : 20
  • trunk/cfg/per-sequence-svc-avcbase/BasketballDrive-2x.cfg

    r752 r906  
    2222IntraPeriod1                  : 48          # Period of I-Frame ( -1 = only first)
    2323ConformanceMode1              : 1           # conformance mode
    24 NumScaledRefLayerOffsets1     : 1           # Number of scaled entry offsets for this layer
    25 ScaledRefLayerId1             : 0           # Scaled reference layer ID
    26 ScaledRefLayerBottomOffset1   : -4          # offset for spatial alignment of the base and enhancement layers
     24NumScaledRefLayerOffsets1        : 1        # Number of reference location offset parameters
     25ScaledRefLayerId1                : 0        # List of ref layer id (i-th entry for i-th ref loc offset parameters)
     26ScaledRefLayerOffsetPresentFlag1 : 0        # List of scaled ref layer offset present flags
     27RefRegionOffsetPresentFlag1      : 1        # List of ref region offset present flags
     28RefRegionBottomOffset1           : 2        # List of ref region bottom offsets
     29ResamplePhaseSetPresentFlag1     : 0        # List of resample phase set present flags
    2730QP1                           : 20
     31
  • trunk/cfg/per-sequence-svc-avcbase/BasketballDrive-SNR.cfg

    r595 r906  
    2222IntraPeriod1                  : 48          # Period of I-Frame ( -1 = only first)
    2323ConformanceMode1              : 1           # conformance mode
    24 NumScaledRefLayerOffsets1     : 1           # Number of scaled entry offsets for this layer
    25 ScaledRefLayerId1             : 0           # Scaled reference layer ID
    26 ScaledRefLayerBottomOffset1   : -4          # offset for spatial alignment of the base and enhancement layers
     24NumScaledRefLayerOffsets1        : 1        # Number of reference location offset parameters
     25ScaledRefLayerId1                : 0        # List of ref layer id (i-th entry for i-th ref loc offset parameters)
     26ScaledRefLayerOffsetPresentFlag1 : 0        # List of scaled ref layer offset present flags
     27RefRegionOffsetPresentFlag1      : 1        # List of ref region offset present flags
     28RefRegionBottomOffset1           : 4        # List of ref region bottom offsets
     29ResamplePhaseSetPresentFlag1     : 0        # List of resample phase set present flags
    2730QP1                           : 20
  • trunk/cfg/per-sequence-svc-avcbase/Cactus-2x.cfg

    r752 r906  
    2222IntraPeriod1                  : 48          # Period of I-Frame ( -1 = only first)
    2323ConformanceMode1              : 1           # conformance mode
    24 NumScaledRefLayerOffsets1     : 1           # Number of scaled entry offsets for this layer
    25 ScaledRefLayerId1             : 0           # Scaled reference layer ID
    26 ScaledRefLayerBottomOffset1   : -4          # offset for spatial alignment of the base and enhancement layers
     24NumScaledRefLayerOffsets1        : 1        # Number of reference location offset parameters
     25ScaledRefLayerId1                : 0        # List of ref layer id (i-th entry for i-th ref loc offset parameters)
     26ScaledRefLayerOffsetPresentFlag1 : 0        # List of scaled ref layer offset present flags
     27RefRegionOffsetPresentFlag1      : 1        # List of ref region offset present flags
     28RefRegionBottomOffset1           : 2        # List of ref region bottom offsets
     29ResamplePhaseSetPresentFlag1     : 0        # List of resample phase set present flags
    2730QP1                           : 20
     31
  • trunk/cfg/per-sequence-svc-avcbase/Cactus-SNR.cfg

    r595 r906  
    2222IntraPeriod1                  : 48          # Period of I-Frame ( -1 = only first)
    2323ConformanceMode1              : 1           # conformance mode
    24 NumScaledRefLayerOffsets1     : 1           # Number of scaled entry offsets for this layer
    25 ScaledRefLayerId1             : 0           # Scaled reference layer ID
    26 ScaledRefLayerBottomOffset1   : -4          # offset for spatial alignment of the base and enhancement layers
     24NumScaledRefLayerOffsets1        : 1        # Number of reference location offset parameters
     25ScaledRefLayerId1                : 0        # List of ref layer id (i-th entry for i-th ref loc offset parameters)
     26ScaledRefLayerOffsetPresentFlag1 : 0        # List of scaled ref layer offset present flags
     27RefRegionOffsetPresentFlag1      : 1        # List of ref region offset present flags
     28RefRegionBottomOffset1           : 4        # List of ref region bottom offsets
     29ResamplePhaseSetPresentFlag1     : 0        # List of resample phase set present flags
    2730QP1                           : 20
  • trunk/cfg/per-sequence-svc-avcbase/Kimono-2x.cfg

    r752 r906  
    2222IntraPeriod1                  : 24          # Period of I-Frame ( -1 = only first)
    2323ConformanceMode1              : 1           # conformance mode
    24 NumScaledRefLayerOffsets1     : 1           # Number of scaled entry offsets for this layer
    25 ScaledRefLayerId1             : 0           # Scaled reference layer ID
    26 ScaledRefLayerBottomOffset1   : -4          # offset for spatial alignment of the base and enhancement layers
     24NumScaledRefLayerOffsets1        : 1        # Number of reference location offset parameters
     25ScaledRefLayerId1                : 0        # List of ref layer id (i-th entry for i-th ref loc offset parameters)
     26ScaledRefLayerOffsetPresentFlag1 : 0        # List of scaled ref layer offset present flags
     27RefRegionOffsetPresentFlag1      : 1        # List of ref region offset present flags
     28RefRegionBottomOffset1           : 2        # List of ref region bottom offsets
     29ResamplePhaseSetPresentFlag1     : 0        # List of resample phase set present flags
    2730QP1                           : 20
  • trunk/cfg/per-sequence-svc-avcbase/Kimono-SNR.cfg

    r595 r906  
    2222IntraPeriod1                  : 24          # Period of I-Frame ( -1 = only first)
    2323ConformanceMode1              : 1           # conformance mode
    24 NumScaledRefLayerOffsets1     : 1           # Number of scaled entry offsets for this layer
    25 ScaledRefLayerId1             : 0           # Scaled reference layer ID
    26 ScaledRefLayerBottomOffset1   : -4          # offset for spatial alignment of the base and enhancement layers
     24NumScaledRefLayerOffsets1        : 1        # Number of reference location offset parameters
     25ScaledRefLayerId1                : 0        # List of ref layer id (i-th entry for i-th ref loc offset parameters)
     26ScaledRefLayerOffsetPresentFlag1 : 0        # List of scaled ref layer offset present flags
     27RefRegionOffsetPresentFlag1      : 1        # List of ref region offset present flags
     28RefRegionBottomOffset1           : 4        # List of ref region bottom offsets
     29ResamplePhaseSetPresentFlag1     : 0        # List of resample phase set present flags
    2730QP1                           : 20
  • trunk/cfg/per-sequence-svc-avcbase/ParkScene-2x.cfg

    r752 r906  
    2222IntraPeriod1                  : 24          # Period of I-Frame ( -1 = only first)
    2323ConformanceMode1              : 1           # conformance mode
    24 NumScaledRefLayerOffsets1     : 1           # Number of scaled entry offsets for this layer
    25 ScaledRefLayerId1             : 0           # Scaled reference layer ID
    26 ScaledRefLayerBottomOffset1   : -4          # offset for spatial alignment of the base and enhancement layers
     24NumScaledRefLayerOffsets1        : 1        # Number of reference location offset parameters
     25ScaledRefLayerId1                : 0        # List of ref layer id (i-th entry for i-th ref loc offset parameters)
     26ScaledRefLayerOffsetPresentFlag1 : 0        # List of scaled ref layer offset present flags
     27RefRegionOffsetPresentFlag1      : 1        # List of ref region offset present flags
     28RefRegionBottomOffset1           : 2        # List of ref region bottom offsets
     29ResamplePhaseSetPresentFlag1     : 0        # List of resample phase set present flags
    2730QP1                           : 20
  • trunk/cfg/per-sequence-svc-avcbase/ParkScene-SNR.cfg

    r595 r906  
    2222IntraPeriod1                  : 24          # Period of I-Frame ( -1 = only first)
    2323ConformanceMode1              : 1           # conformance mode
    24 NumScaledRefLayerOffsets1     : 1           # Number of scaled entry offsets for this layer
    25 ScaledRefLayerId1             : 0           # Scaled reference layer ID
    26 ScaledRefLayerBottomOffset1   : -4          # offset for spatial alignment of the base and enhancement layers
     24NumScaledRefLayerOffsets1        : 1        # Number of reference location offset parameters
     25ScaledRefLayerId1                : 0        # List of ref layer id (i-th entry for i-th ref loc offset parameters)
     26ScaledRefLayerOffsetPresentFlag1 : 0        # List of scaled ref layer offset present flags
     27RefRegionOffsetPresentFlag1      : 1        # List of ref region offset present flags
     28RefRegionBottomOffset1           : 4        # List of ref region bottom offsets
     29ResamplePhaseSetPresentFlag1     : 0        # List of resample phase set present flags
    2730QP1                           : 20
  • trunk/cfg/per-sequence-svc/BQTerrace-2x.cfg

    r713 r906  
    2424ConformanceMode1              : 1           # conformance mode
    2525QP1                           : 20
     26
     27#============= Reference location offset parameters ==================
     28NumScaledRefLayerOffsets1        : 1        # Number of reference location offset parameters
     29ScaledRefLayerId1                : 0        # List of ref layer id (i-th entry for i-th ref loc offset parameters)
     30ScaledRefLayerOffsetPresentFlag1 : 0        # List of scaled ref layer offset present flags
     31RefRegionOffsetPresentFlag1      : 1        # List of ref region offset present flags
     32RefRegionBottomOffset1           : 2        # List of ref region bottom offsets
     33ResamplePhaseSetPresentFlag1     : 0        # List of resample phase set present flags
  • trunk/cfg/per-sequence-svc/BasketballDrive-2x.cfg

    r713 r906  
    2424ConformanceMode1              : 1           # conformance mode
    2525QP1                           : 20
     26
     27#============= Reference location offset parameters ==================
     28NumScaledRefLayerOffsets1        : 1        # Number of reference location offset parameters
     29ScaledRefLayerId1                : 0        # List of ref layer id (i-th entry for i-th ref loc offset parameters)
     30ScaledRefLayerOffsetPresentFlag1 : 0        # List of scaled ref layer offset present flags
     31RefRegionOffsetPresentFlag1      : 1        # List of ref region offset present flags
     32RefRegionBottomOffset1           : 2        # List of ref region bottom offsets
     33ResamplePhaseSetPresentFlag1     : 0        # List of resample phase set present flags
  • trunk/cfg/per-sequence-svc/Cactus-2x.cfg

    r713 r906  
    2424ConformanceMode1              : 1           # conformance mode
    2525QP1                           : 20
     26
     27#============= Reference location offset parameters ==================
     28NumScaledRefLayerOffsets1        : 1        # Number of reference location offset parameters
     29ScaledRefLayerId1                : 0        # List of ref layer id (i-th entry for i-th ref loc offset parameters)
     30ScaledRefLayerOffsetPresentFlag1 : 0        # List of scaled ref layer offset present flags
     31RefRegionOffsetPresentFlag1      : 1        # List of ref region offset present flags
     32RefRegionBottomOffset1           : 2        # List of ref region bottom offsets
     33ResamplePhaseSetPresentFlag1     : 0        # List of resample phase set present flags
  • trunk/cfg/per-sequence-svc/Kimono-2x.cfg

    r713 r906  
    2424ConformanceMode1              : 1           # conformance mode
    2525QP1                           : 20
     26
     27#============= Reference location offset parameters ==================
     28NumScaledRefLayerOffsets1        : 1        # Number of reference location offset parameters
     29ScaledRefLayerId1                : 0        # List of ref layer id (i-th entry for i-th ref loc offset parameters)
     30ScaledRefLayerOffsetPresentFlag1 : 0        # List of scaled ref layer offset present flags
     31RefRegionOffsetPresentFlag1      : 1        # List of ref region offset present flags
     32RefRegionBottomOffset1           : 2        # List of ref region bottom offsets
     33ResamplePhaseSetPresentFlag1     : 0        # List of resample phase set present flags
  • trunk/cfg/per-sequence-svc/ParkScene-2x.cfg

    r713 r906  
    2424ConformanceMode1              : 1           # conformance mode
    2525QP1                           : 20
     26
     27#============= Reference location offset parameters ==================
     28NumScaledRefLayerOffsets1        : 1        # Number of reference location offset parameters
     29ScaledRefLayerId1                : 0        # List of ref layer id (i-th entry for i-th ref loc offset parameters)
     30ScaledRefLayerOffsetPresentFlag1 : 0        # List of scaled ref layer offset present flags
     31RefRegionOffsetPresentFlag1      : 1        # List of ref region offset present flags
     32RefRegionBottomOffset1           : 2        # List of ref region bottom offsets
     33ResamplePhaseSetPresentFlag1     : 0        # List of resample phase set present flags
  • trunk/source

  • trunk/source/App/TAppDecoder/TAppDecCfg.cpp

    r815 r906  
    7878  string cfg_ReconFile;
    7979#endif
    80 #if AVC_SYNTAX || SYNTAX_OUTPUT
    81   string cfg_BLSyntaxFile;
    82 #endif
     80
    8381  string cfg_TargetDecLayerIdSetFile;
    8482
     
    9694  ("BLSourceHeight,-hgt",   m_iBLSourceHeight,       0, "BL source picture height")
    9795#endif
    98 #if AVC_SYNTAX
    99   ("BLSyntaxFile,-ibs",    cfg_BLSyntaxFile,  string(""), "BL syntax input file name") 
    100 #endif
    10196#endif
    10297#else
    10398  ("ReconFile,o",     cfg_ReconFile,     string(""), "reconstructed YUV output file name\n"
    10499                                                     "YUV writing is skipped if omitted")
    105 #endif
    106 #if SYNTAX_OUTPUT
    107   ("BLSyntaxFile,-ibs",    cfg_BLSyntaxFile,  string(""), "BL syntax input file name")
    108   ("BLSourceWidth,-wdt",    m_iBLSourceWidth,        0, "BL source picture width")
    109   ("BLSourceHeight,-hgt",   m_iBLSourceHeight,       0, "BL source picture height")
    110   ("BLFrames,-fr",          m_iBLFrames,       0, "BL number of frames")
    111100#endif
    112101  ("SkipFrames,s", m_iSkipFrame, 0, "number of frames to skip before random access")
     
    126115  ("TarDecLayerIdSetFile,l", cfg_TargetDecLayerIdSetFile, string(""), "targetDecLayerIdSet file name. The file should include white space separated LayerId values to be decoded. Omitting the option or a value of -1 in the file decodes all layers.")
    127116  ("RespectDefDispWindow,w", m_respectDefDispWindow, 0, "Only output content inside the default display window\n")
     117#if Q0074_COLOUR_REMAPPING_SEI
     118  ("SEIColourRemappingInfo", m_colourRemapSEIEnabled, false, "Control handling of Colour Remapping Information SEI messages\n"
     119                                              "\t1: apply colour remapping on decoded pictures if available in the bitstream\n"
     120                                              "\t0: ignore SEI message")
     121#endif
    128122  ;
    129123  po::setDefaults(opts);
     
    163157#else
    164158  m_pchReconFile = cfg_ReconFile.empty() ? NULL : strdup(cfg_ReconFile.c_str());
    165 #endif
    166 #if AVC_SYNTAX || SYNTAX_OUTPUT
    167   m_pchBLSyntaxFile = cfg_BLSyntaxFile.empty() ? NULL : strdup(cfg_BLSyntaxFile.c_str());
    168159#endif
    169160
  • trunk/source/App/TAppDecoder/TAppDecCfg.h

    r713 r906  
    6969  Int           m_iMaxTemporalLayer;                  ///< maximum temporal layer to be decoded
    7070  Int           m_decodedPictureHashSEIEnabled;       ///< Checksum(3)/CRC(2)/MD5(1)/disable(0) acting on decoded picture hash SEI message
     71#if Q0074_COLOUR_REMAPPING_SEI
     72  Bool          m_colourRemapSEIEnabled;              ///< Enable the Colour Remapping Information SEI message if available (remapping decoded pictures)
     73#endif
    7174
    7275#if SVC_EXTENSION
     
    7881  Int           m_iBLSourceHeight;
    7982#endif
    80 #if AVC_SYNTAX
    81   Char*         m_pchBLSyntaxFile;                     ///< input BL syntax file name 
    8283#endif
    83 #endif
    84 #endif
    85 
    86 #if SYNTAX_OUTPUT
    87   Char*         m_pchBLSyntaxFile;                     ///< input BL syntax file name
    88 #if !REPN_FORMAT_IN_VPS
    89   Int           m_iBLSourceWidth;
    90   Int           m_iBLSourceHeight;
    91 #endif
    92   Int           m_iBLFrames;
    9384#endif
    9485
     
    110101  , m_iMaxTemporalLayer(-1)
    111102  , m_decodedPictureHashSEIEnabled(0)
     103#if Q0074_COLOUR_REMAPPING_SEI
     104  , m_colourRemapSEIEnabled(0)
     105#endif
    112106#if SVC_EXTENSION
    113107  , m_tgtLayerId(0)
     
    115109  , m_iBLSourceWidth(0)
    116110  , m_iBLSourceHeight(0)
    117 #endif
    118 #if SYNTAX_OUTPUT
    119   , m_iBLSourceWidth(0)
    120   , m_iBLSourceHeight(0)
    121   , m_iBLFrames(0)
    122111#endif
    123112#endif
  • trunk/source/App/TAppDecoder/TAppDecTop.cpp

    r815 r906  
    102102  }
    103103#endif
    104 #if AVC_SYNTAX || SYNTAX_OUTPUT
    105   if( m_pchBLSyntaxFile )
    106   {
    107     free ( m_pchBLSyntaxFile );
    108     m_pchBLSyntaxFile = NULL;
    109   }
    110 #endif
    111104}
    112105
     
    163156  }
    164157  TComList<TComPic*> *cListPic = m_acTDecTop[0].getListPic();
    165 #if AVC_SYNTAX || !REPN_FORMAT_IN_VPS
    166   m_acTDecTop[0].setBLsize( m_iBLSourceWidth, m_iBLSourceHeight );
    167 #endif
    168158  m_acTDecTop[0].setBLReconFile( &streamYUV );
    169159  pcBLPic.setLayerId( 0 );
    170160  cListPic->pushBack( &pcBLPic );
    171 #if AVC_SYNTAX
    172   fstream streamSyntaxFile;
    173   if( m_pchBLSyntaxFile )
    174   {
    175     streamSyntaxFile.open( m_pchBLSyntaxFile, fstream::in | fstream::binary );
    176   }
    177   m_acTDecTop[0].setBLSyntaxFile( &streamSyntaxFile );
    178 #endif
    179161#endif
    180162
     
    363345    streamYUV.close();
    364346  }
    365 #if AVC_SYNTAX
    366   if( streamSyntaxFile.is_open() )
    367   {
    368     streamSyntaxFile.close();
    369   }
    370 #endif
    371347  pcBLPic.destroy();
    372348
     
    405381  Bool openedReconFile = false; // reconstruction file not yet opened. (must be performed after SPS is seen)
    406382  Bool loopFiltered = false;
    407 
    408 #if SYNTAX_OUTPUT
    409   if( !m_pchBLSyntaxFile )
    410   {
    411     printf( "Wrong base layer syntax file\n" );
    412     exit(EXIT_FAILURE);
    413   }
    414   fstream streamSyntaxFile( m_pchBLSyntaxFile, fstream::out | fstream::binary );
    415   if( !streamSyntaxFile.good() )
    416   {
    417     printf( "Base layer syntax input reading error\n" );
    418     exit(EXIT_FAILURE);
    419   }
    420   m_cTDecTop.setBLSyntaxFile( &streamSyntaxFile );
    421 
    422   for( Int i = m_iBLFrames * m_iBLSourceWidth * m_iBLSourceHeight * SYNTAX_BYTES / 16; i >= 0; i-- )
    423   {
    424     streamSyntaxFile.put( 0 );
    425   }
    426   streamSyntaxFile.seekp( 0 );
    427 #endif
    428383
    429384  while (!!bitstreamFile)
     
    543498  }
    544499
    545 #if SYNTAX_OUTPUT
    546   if( streamSyntaxFile.is_open() )
    547   {
    548     streamSyntaxFile.close();
    549   }
    550 #endif
    551 
    552500  xFlushOutput( pcListPic );
    553501  // delete buffers
     
    620568    m_acTDecTop[layer].init();
    621569    m_acTDecTop[layer].setDecodedPictureHashSEIEnabled(m_decodedPictureHashSEIEnabled);
     570#if Q0074_COLOUR_REMAPPING_SEI
     571    m_acTDecTop[layer].setColourRemappingInfoSEIEnabled(m_colourRemapSEIEnabled);
     572#endif
    622573    m_acTDecTop[layer].setNumLayer( m_tgtLayerId + 1 );
    623574#if OUTPUT_LAYER_SET_INDEX
     
    625576#endif
    626577  }
    627 
    628578#else
    629579  m_cTDecTop.init();
    630580  m_cTDecTop.setDecodedPictureHashSEIEnabled(m_decodedPictureHashSEIEnabled);
     581#if Q0074_COLOUR_REMAPPING_SEI
     582  m_cTDecTop.setColourRemappingInfoSEIEnabled(m_colourRemapSEIEnabled);
     583#endif
    631584#endif
    632585}
     
    727680          TComPicYuv* pPicCYuvRecTop = pcPicTop->getPicYuvRec();
    728681          TComPicYuv* pPicCYuvRecBot = pcPicBottom->getPicYuvRec();
    729 #if Q0074_SEI_COLOR_MAPPING
    730           if( m_acTDecTop[layerId].m_ColorMapping->getColorMappingFlag() )
    731           {
    732             pPicCYuvRecTop = m_acTDecTop[layerId].m_ColorMapping->getColorMapping( pPicCYuvRecTop, 0, layerId );
    733             pPicCYuvRecBot = m_acTDecTop[layerId].m_ColorMapping->getColorMapping( pPicCYuvRecBot, 1, layerId );
    734           }
    735 #endif
    736682#if REPN_FORMAT_IN_VPS
    737683          UInt chromaFormatIdc = pcPic->getSlice(0)->getChromaFormatIdc();
     
    762708          TComPicYuv* pPicCYuvRecTop = pcPicTop->getPicYuvRec();
    763709          TComPicYuv* pPicCYuvRecBot = pcPicBottom->getPicYuvRec();
    764 #if Q0074_SEI_COLOR_MAPPING
    765           if ( m_cTDecTop.m_ColorMapping->getColorMappingFlag() )
    766           {
    767             pPicCYuvRecTop = m_cTDecTop.m_ColorMapping->getColorMapping( pPicCYuvRecTop, 0 );
    768             pPicCYuvRecBot = m_cTDecTop.m_ColorMapping->getColorMapping( pPicCYuvRecBot, 1 );
    769           }
    770 #endif
    771710          m_cTVideoIOYuvReconFile.write( pPicCYuvRecTop, pPicCYuvRecBot,
    772711            conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(),
     
    843782          const Window &defDisp = m_respectDefDispWindow ? pcPic->getDefDisplayWindow() : Window();
    844783          TComPicYuv* pPicCYuvRec = pcPic->getPicYuvRec();
    845 #if Q0074_SEI_COLOR_MAPPING
    846           if ( m_acTDecTop[layerId].m_ColorMapping->getColorMappingFlag() )
    847           {
    848             pPicCYuvRec = m_acTDecTop[layerId].m_ColorMapping->getColorMapping( pPicCYuvRec, 0, layerId );
    849           }
    850 #endif
    851 
    852784#if REPN_FORMAT_IN_VPS
    853785          UInt chromaFormatIdc = pcPic->getSlice(0)->getChromaFormatIdc();
     
    873805        if ( m_pchReconFile )
    874806        {
    875 #if SYNTAX_OUTPUT
    876           TComPicYuv* pPicCYuvRec = pcPic->getPicYuvRec();
    877 #if Q0074_SEI_COLOR_MAPPING
    878           if( m_acTDecTop[layerIdx].m_ColorMapping->getColorMappingFlag() )
    879           {
    880             pPicCYuvRec = m_acTDecTop[layerIdx].m_ColorMapping->getColorMapping( pPicCYuvRec, 0, layerIdx );
    881           }
    882 #endif
    883807          const Window &conf = pcPic->getConformanceWindow();
    884808          const Window &defDisp = m_respectDefDispWindow ? pcPic->getDefDisplayWindow() : Window();
    885           m_cTVideoIOYuvReconFile.write( pPicCYuvRec,
    886             conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(),
    887             conf.getWindowRightOffset() + defDisp.getWindowRightOffset(),
    888             conf.getWindowTopOffset() + defDisp.getWindowTopOffset(),
    889             conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset() );
    890 #endif
     809          m_cTVideoIOYuvReconFile.write( pcPic->getPicYuvRec(),
     810                                        conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(),
     811                                        conf.getWindowRightOffset() + defDisp.getWindowRightOffset(),
     812                                        conf.getWindowTopOffset() + defDisp.getWindowTopOffset(),
     813                                        conf.getWindowBottomOffset() + defDisp.getWindowBottomOffset() );
    891814        }
    892815
     
    959882          TComPicYuv* pPicCYuvRecTop = pcPicTop->getPicYuvRec();
    960883          TComPicYuv* pPicCYuvRecBot = pcPicBottom->getPicYuvRec();
    961 #if Q0074_SEI_COLOR_MAPPING
    962           if( m_acTDecTop[layerId].m_ColorMapping->getColorMappingFlag() )
    963           {
    964             pPicCYuvRecTop = m_acTDecTop[layerId].m_ColorMapping->getColorMapping( pPicCYuvRecTop, 0, layerId );
    965             pPicCYuvRecBot = m_acTDecTop[layerId].m_ColorMapping->getColorMapping( pPicCYuvRecBot, 1, layerId );
    966           }
    967 #endif
    968884#if REPN_FORMAT_IN_VPS
    969885          UInt chromaFormatIdc = pcPic->getSlice(0)->getChromaFormatIdc();
     
    994910          TComPicYuv* pPicCYuvRecTop = pcPicTop->getPicYuvRec();
    995911          TComPicYuv* pPicCYuvRecBot = pcPicBottom->getPicYuvRec();
    996 #if Q0074_SEI_COLOR_MAPPING
    997           if( m_cTDecTop.m_ColorMapping->getColorMappingFlag() )
    998           {
    999             pPicCYuvRecTop = m_cTDecTop.m_ColorMapping->getColorMapping( pPicCYuvRecTop, 0 );
    1000             pPicCYuvRecBot = m_cTDecTop.m_ColorMapping->getColorMapping( pPicCYuvRecBot, 1 );
    1001           }
    1002 #endif
    1003912          m_cTVideoIOYuvReconFile.write( pPicCYuvRecTop, pPicCYuvRecBot,
    1004913            conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(),
     
    1078987          const Window &defDisp = m_respectDefDispWindow ? pcPic->getDefDisplayWindow() : Window();
    1079988          TComPicYuv* pPicCYuvRec = pcPic->getPicYuvRec();
    1080 #if Q0074_SEI_COLOR_MAPPING
    1081           if( m_acTDecTop[layerId].m_ColorMapping->getColorMappingFlag() )
    1082           {
    1083             pPicCYuvRec = m_acTDecTop[layerId].m_ColorMapping->getColorMapping( pPicCYuvRec, 0, layerId );
    1084           }
    1085 #endif
    1086989#if REPN_FORMAT_IN_VPS
    1087990          UInt chromaFormatIdc = pcPic->getSlice(0)->getChromaFormatIdc();
     
    11101013          const Window &defDisp = m_respectDefDispWindow ? pcPic->getDefDisplayWindow() : Window();
    11111014          TComPicYuv* pPicCYuvRec = pcPic->getPicYuvRec();
    1112 #if Q0074_SEI_COLOR_MAPPING
    1113           if( m_cTDecTop.m_ColorMapping->getColorMappingFlag() )
    1114           {
    1115             pPicCYuvRec = m_cTDecTop.m_ColorMapping->getColorMapping( pPicCYuvRec );
    1116           }
    1117 #endif
    11181015          m_cTVideoIOYuvReconFile.write( pPicCYuvRec,
    11191016            conf.getWindowLeftOffset() + defDisp.getWindowLeftOffset(),
     
    11981095#endif
    11991096    TComPicYuv* pPicCYuvRec = pic->getPicYuvRec();
    1200 #if Q0074_SEI_COLOR_MAPPING
    1201     pPicCYuvRec = m_acTDecTop[layerIdx].m_ColorMapping->getColorMapping( pPicCYuvRec, 0, layerIdx );
    1202 #endif
    12031097    m_acTVideoIOYuvReconFile[layerIdx].write( pPicCYuvRec,
    12041098      conf.getWindowLeftOffset()  * xScal + defDisp.getWindowLeftOffset(),
     
    12211115    pic->getPicYuvRec()->setBorderExtension( false );
    12221116
     1117#if RESOLUTION_BASED_DPB
    12231118    dpbStatus.m_numPicsInLayer[layerIdx]--;
     1119#endif
     1120    dpbStatus.m_numPicsInSubDpb[layerIdx]--;
    12241121  }
    12251122}
     
    12851182  for(Int i = 0; i < MAX_LAYERS; i++)
    12861183  {
    1287     m_acTDecTop[i].getListPic()->clear();
     1184    markAllPicturesAsErased(i);
    12881185  }
    12891186}
     
    12911188Void TAppDecTop::markAllPicturesAsErased(Int layerIdx)
    12921189{
     1190  TComList<TComPic*>::iterator  iterPic = m_acTDecTop[layerIdx].getListPic()->begin();
     1191  Int iSize = Int( m_acTDecTop[layerIdx].getListPic()->size() );
     1192 
     1193  for (Int i = 0; i < iSize; i++ )
     1194  {
     1195    TComPic* pcPic = *(iterPic++);
     1196
     1197    if( pcPic )
     1198    {
     1199      pcPic->destroy();
     1200
     1201      // pcPic is statically created for the external (AVC) base layer, no need to delete it
     1202#if VPS_AVC_BL_FLAG_REMOVAL
     1203      if( !m_acTDecTop[layerIdx].getParameterSetManager()->getActiveVPS()->getNonHEVCBaseLayerFlag() || layerIdx )
     1204#else
     1205      if( !m_acTDecTop[layerIdx].getParameterSetManager()->getActiveVPS()->getAvcBaseLayerFlag() || layerIdx )
     1206#endif
     1207      {
     1208        delete pcPic;
     1209        pcPic = NULL;
     1210      }
     1211    }
     1212  }
     1213
    12931214  m_acTDecTop[layerIdx].getListPic()->clear();
    12941215}
     
    14341355      maxDpbLimit.m_maxLatencyPictures = sps->getMaxLatencyIncrease( highestTId ) + sps->getNumReorderPics( highestTId ) - 1;
    14351356    }
     1357#if RESOLUTION_BASED_DPB
    14361358    maxDpbLimit.m_numPicsInLayer[0] = sps->getMaxDecPicBuffering( highestTId );
     1359#endif
    14371360    maxDpbLimit.m_numPicsInSubDpb[0] = sps->getMaxDecPicBuffering( highestTId );
    14381361  }
     
    15821505          if( pic->getSlice(0)->isReferenced() || pic->getOutputMark() )
    15831506          {
     1507#if RESOLUTION_BASED_DPB
    15841508            dpbStatus.m_numPicsInLayer[i]++;  // Count pictures that are "used for reference" or "needed for output"
     1509#else
     1510            dpbStatus.m_numPicsInSubDpb[i]++;  // Count pictures that are "used for reference" or "needed for output"
     1511#endif
    15851512          }
    15861513#if POC_RESET_IDC_DECODER
     
    16071534#if RESOLUTION_BASED_DPB
    16081535    dpbStatus.m_numPicsInSubDpb[vps->getSubDpbAssigned(targetLsIdx,i)] += dpbStatus.m_numPicsInLayer[i];
    1609 #else
    16101536    dpbStatus.m_numPicsInSubDpb[i] += dpbStatus.m_numPicsInLayer[i];
    16111537#endif
  • trunk/source/App/TAppDecoder/TAppDecTop.h

    r815 r906  
    135135  Int m_numAUsNotDisplayed;
    136136  Int m_numPicsNotDisplayedInLayer[MAX_LAYERS];
     137#if RESOLUTION_BASED_DPB
    137138  Int m_numPicsInLayer[MAX_LAYERS];   // Pictures marked as used_for_reference or needed for output in the layer
     139#endif
    138140  Int m_numPicsInSubDpb[MAX_LAYERS];  // Pictures marked as used_for_reference or needed for output in the sub-DPB
    139141  Bool m_maxLatencyIncrease;
     
    152154    m_maxLatencyIncrease  = false;
    153155    m_maxLatencyPictures  = 0;
     156#if RESOLUTION_BASED_DPB
    154157    ::memset( m_numPicsInLayer,  0, sizeof(m_numPicsInLayer)  );
     158#endif
    155159    ::memset( m_numPicsInSubDpb, 0, sizeof(m_numPicsInSubDpb) );
    156160    ::memset(m_numPicsNotDisplayedInLayer, 0, sizeof(m_numPicsNotDisplayedInLayer) );
  • trunk/source/App/TAppEncoder/TAppEncCfg.cpp

    r815 r906  
    6767: m_pBitstreamFile()
    6868#if AVC_BASE
     69#if VPS_AVC_BL_FLAG_REMOVAL
     70, m_nonHEVCBaseLayerFlag(0)
     71#else
    6972, m_avcBaseLayerFlag(0)
    7073#endif
     74#endif
    7175, m_maxTidRefPresentFlag(1)
    72 , m_pColumnWidth()
    73 , m_pRowHeight()
     76#if OUTPUT_LAYER_SETS_CONFIG
     77, m_defaultTargetOutputLayerIdc (-1)
     78, m_numOutputLayerSets          (-1)
     79#endif
    7480, m_scalingListFile()
    7581, m_elRapSliceBEnabled(0)
     
    8793, m_pchReconFile()
    8894, m_pchdQPFile()
    89 , m_pColumnWidth()
    90 , m_pRowHeight()
    9195, m_scalingListFile()
    9296{
     
    9599  m_codedPivotValue = NULL;
    96100  m_targetPivotValue = NULL;
     101#if Q0074_COLOUR_REMAPPING_SEI
     102  for( Int c=0 ; c<3 ; c++)
     103  {
     104    m_colourRemapSEIPreLutCodedValue[c]   = NULL;
     105    m_colourRemapSEIPreLutTargetValue[c]  = NULL;
     106    m_colourRemapSEIPostLutCodedValue[c]  = NULL;
     107    m_colourRemapSEIPostLutTargetValue[c] = NULL;
     108  }
     109#endif
    97110}
    98111#endif
     
    101114{
    102115#if SVC_EXTENSION
    103   free(m_pBitstreamFile);
     116  if( m_pBitstreamFile )
     117  {
     118    free(m_pBitstreamFile);
     119    m_pBitstreamFile = NULL;
     120  }
    104121#else 
    105122  if ( m_aidQP )
     
    128145  free(m_pchReconFile);
    129146  free(m_pchdQPFile);
    130 #endif
    131   free(m_pColumnWidth);
    132   free(m_pRowHeight);
     147#if Q0074_COLOUR_REMAPPING_SEI
     148  for( Int c=0 ; c<3 ; c++)
     149  {
     150    if ( m_colourRemapSEIPreLutCodedValue[c] )
     151    {
     152      delete[] m_colourRemapSEIPreLutCodedValue[c];
     153    }
     154    if ( m_colourRemapSEIPreLutTargetValue[c] )
     155    {
     156      delete[] m_colourRemapSEIPreLutTargetValue[c];
     157    }
     158    if ( m_colourRemapSEIPostLutCodedValue[c] )
     159    {
     160      delete[] m_colourRemapSEIPostLutCodedValue[c];
     161    }
     162    if ( m_colourRemapSEIPostLutTargetValue[c] )
     163    {
     164      delete[] m_colourRemapSEIPostLutTargetValue[c];
     165    }
     166  }
     167#endif
     168#endif
    133169  free(m_scalingListFile);
    134170}
     
    337373  string* cfg_ReconFile      [MAX_LAYERS];
    338374  Double* cfg_fQP            [MAX_LAYERS];
    339 #if Q0074_SEI_COLOR_MAPPING
    340   string* cfg_seiColorMappingFile[MAX_LAYERS];
    341 #endif
    342 
    343375#if REPN_FORMAT_IN_VPS
    344376  Int*    cfg_repFormatIdx  [MAX_LAYERS];
     
    386418  string    cfg_scaledRefLayerBottomOffset [MAX_LAYERS];
    387419  Int*      cfg_numScaledRefLayerOffsets[MAX_LAYERS];
     420#if REF_REGION_OFFSET
     421  string    cfg_scaledRefLayerOffsetPresentFlag [MAX_LAYERS];
     422  string    cfg_refRegionOffsetPresentFlag      [MAX_LAYERS];
     423  string    cfg_refRegionLeftOffset   [MAX_LAYERS];
     424  string    cfg_refRegionTopOffset    [MAX_LAYERS];
     425  string    cfg_refRegionRightOffset  [MAX_LAYERS];
     426  string    cfg_refRegionBottomOffset [MAX_LAYERS];
     427#endif
     428#if R0209_GENERIC_PHASE
     429  string    cfg_resamplePhaseSetPresentFlag [MAX_LAYERS];
     430  string    cfg_phaseHorLuma   [MAX_LAYERS];
     431  string    cfg_phaseVerLuma   [MAX_LAYERS];
     432  string    cfg_phaseHorChroma [MAX_LAYERS];
     433  string    cfg_phaseVerChroma [MAX_LAYERS];
     434#else
    388435#if P0312_VERT_PHASE_ADJ
    389436  string    cfg_vertPhasePositionEnableFlag[MAX_LAYERS];
     437#endif
    390438#endif
    391439
     
    397445  string*    cfg_scaledRefLayerRightOffsetPtr  [MAX_LAYERS];
    398446  string*    cfg_scaledRefLayerBottomOffsetPtr [MAX_LAYERS];
     447#if REF_REGION_OFFSET
     448  string*    cfg_scaledRefLayerOffsetPresentFlagPtr [MAX_LAYERS];
     449  string*    cfg_refRegionOffsetPresentFlagPtr      [MAX_LAYERS];
     450  string*    cfg_refRegionLeftOffsetPtr   [MAX_LAYERS];
     451  string*    cfg_refRegionTopOffsetPtr    [MAX_LAYERS];
     452  string*    cfg_refRegionRightOffsetPtr  [MAX_LAYERS];
     453  string*    cfg_refRegionBottomOffsetPtr [MAX_LAYERS];
     454#endif
     455#if R0209_GENERIC_PHASE
     456  string*    cfg_resamplePhaseSetPresentFlagPtr [MAX_LAYERS];
     457  string*    cfg_phaseHorLumaPtr   [MAX_LAYERS];
     458  string*    cfg_phaseVerLumaPtr   [MAX_LAYERS];
     459  string*    cfg_phaseHorChromaPtr [MAX_LAYERS];
     460  string*    cfg_phaseVerChromaPtr [MAX_LAYERS];
     461#endif
    399462#if P0312_VERT_PHASE_ADJ
    400463  string*    cfg_vertPhasePositionEnableFlagPtr[MAX_LAYERS];
     
    419482#endif
    420483  Int*    cfg_maxTidIlRefPicsPlus1[MAX_LAYERS];
     484#if Q0074_COLOUR_REMAPPING_SEI
     485  string* cfg_colourRemapSEIFile[MAX_LAYERS];
     486#endif
     487  Int*    cfg_waveFrontSynchro[MAX_LAYERS];
     488
    421489  for(UInt layer = 0; layer < MAX_LAYERS; layer++)
    422490  {
     
    424492    cfg_ReconFile[layer]    = &m_acLayerCfg[layer].m_cReconFile;
    425493    cfg_fQP[layer]          = &m_acLayerCfg[layer].m_fQP;
     494#if Q0074_COLOUR_REMAPPING_SEI
     495    cfg_colourRemapSEIFile[layer] = &m_acLayerCfg[layer].m_colourRemapSEIFile;
     496#endif
    426497#if REPN_FORMAT_IN_VPS
    427498    cfg_repFormatIdx[layer] = &m_acLayerCfg[layer].m_repFormatIdx;
     
    432503    cfg_IntraPeriod[layer]  = &m_acLayerCfg[layer].m_iIntraPeriod;
    433504    cfg_conformanceMode[layer] = &m_acLayerCfg[layer].m_conformanceMode;
    434 #if Q0074_SEI_COLOR_MAPPING
    435     cfg_seiColorMappingFile[layer] = &m_acLayerCfg[layer].m_cSeiColorMappingFile;
    436 #endif
    437505#if LAYER_CTB
    438506    // coding unit (CU) definition
     
    457525#endif
    458526    cfg_numScaledRefLayerOffsets [layer] = &m_acLayerCfg[layer].m_numScaledRefLayerOffsets;
     527    cfg_waveFrontSynchro[layer]  = &m_acLayerCfg[layer].m_waveFrontSynchro;
    459528    for(Int i = 0; i < MAX_LAYERS; i++)
    460529    {
     
    468537#if P0312_VERT_PHASE_ADJ
    469538      cfg_vertPhasePositionEnableFlagPtr[layer] = &cfg_vertPhasePositionEnableFlag[layer];
     539#endif
     540#if REF_REGION_OFFSET
     541      cfg_scaledRefLayerOffsetPresentFlagPtr [layer] = &cfg_scaledRefLayerOffsetPresentFlag [layer];
     542      cfg_refRegionOffsetPresentFlagPtr      [layer] = &cfg_refRegionOffsetPresentFlag      [layer];
     543      cfg_refRegionLeftOffsetPtr  [layer] = &cfg_refRegionLeftOffset  [layer];
     544      cfg_refRegionTopOffsetPtr   [layer] = &cfg_refRegionTopOffset   [layer];
     545      cfg_refRegionRightOffsetPtr [layer] = &cfg_refRegionRightOffset [layer];
     546      cfg_refRegionBottomOffsetPtr[layer] = &cfg_refRegionBottomOffset[layer];
     547#endif
     548#if R0209_GENERIC_PHASE
     549      cfg_resamplePhaseSetPresentFlagPtr [layer] = &cfg_resamplePhaseSetPresentFlag [layer];
     550      cfg_phaseHorLumaPtr   [layer] = &cfg_phaseHorLuma   [layer];
     551      cfg_phaseVerLumaPtr   [layer] = &cfg_phaseVerLuma   [layer];
     552      cfg_phaseHorChromaPtr [layer] = &cfg_phaseHorChroma [layer];
     553      cfg_phaseVerChromaPtr [layer] = &cfg_phaseVerChroma [layer];
    470554#endif
    471555    }
     
    507591  }
    508592#endif
     593#if OUTPUT_LAYER_SETS_CONFIG
     594  string* cfg_numLayersInOutputLayerSet = new string;
     595  string* cfg_listOfOutputLayers     = new string[MAX_VPS_OUTPUT_LAYER_SETS_PLUS1];
     596  string* cfg_outputLayerSetIdx      = new string;
     597#endif
    509598#if AVC_BASE
    510599  string  cfg_BLInputFile;
    511 #endif
    512 #if AVC_SYNTAX
    513   string  cfg_BLSyntaxFile;
    514600#endif
    515601#if N0383_IL_CONSTRAINED_TILE_SETS_SEI
     
    521607  string cfg_ReconFile;
    522608  string cfg_dQPFile;
     609#if Q0074_COLOUR_REMAPPING_SEI
     610  string cfg_colourRemapSEIFile;
     611#endif
    523612#endif //SVC_EXTENSION
    524   string cfg_ColumnWidth;
    525   string cfg_RowHeight;
     613  string cfgColumnWidth;
     614  string cfgRowHeight;
    526615  string cfg_ScalingListFile;
    527616  string cfg_startOfCodedInterval;
     
    532621  string cfg_kneeSEIOutputKneePointValue;
    533622#endif
     623
    534624  po::Options opts;
    535625  opts.addOptions()
     
    562652  ("NumLayers",               m_numLayers, 1, "Number of layers to code")
    563653#if Q0078_ADD_LAYER_SETS
     654#if OUTPUT_LAYER_SETS_CONFIG
     655  ("NumLayerSets",            m_numLayerSets, 1, "Number of layer sets")
     656#else
    564657  ("NumLayerSets",            m_numLayerSets, 0, "Number of layer sets")
     658#endif
    565659  ("NumLayerInIdList%d",      cfg_numLayerInIdList, 0, MAX_VPS_LAYER_ID_PLUS1, "Number of layers in the set")
    566660  ("LayerSetLayerIdList%d",   cfg_layerSetLayerIdListPtr, string(""), MAX_VPS_LAYER_ID_PLUS1, "Layer IDs for the set")
     
    568662  ("NumHighestLayerIdx%d",    cfg_numHighestLayerIdx, 0, MAX_VPS_LAYER_ID_PLUS1, "Number of highest layer idx")
    569663  ("HighestLayerIdx%d",       cfg_highestLayerIdxPtr, string(""), MAX_VPS_LAYER_ID_PLUS1, "Highest layer idx for an additional layer set")
     664#endif
     665#if OUTPUT_LAYER_SETS_CONFIG
     666  ("DefaultTargetOutputLayerIdc",    m_defaultTargetOutputLayerIdc, 1, "Default target output layers. 0: All layers are output layer, 1: Only highest layer is output layer, 2 or 3: No default output layers")
     667  ("NumOutputLayerSets",            m_numOutputLayerSets, 1, "Number of output layer sets excluding the 0-th output layer set")
     668  ("NumLayersInOutputLayerSet",   cfg_numLayersInOutputLayerSet, string(""), 1 , "List containing number of output layers in the output layer sets")
     669  ("ListOfOutputLayers%d",          cfg_listOfOutputLayers, string(""), MAX_VPS_LAYER_ID_PLUS1, "Layer IDs for the set, in terms of layer ID in the output layer set Range: [0..NumLayersInOutputLayerSet-1]")
     670  ("OutputLayerSetIdx",            cfg_outputLayerSetIdx, string(""), 1, "Corresponding layer set index, only for non-default output layer sets")
    570671#endif
    571672#if AUXILIARY_PICTURES
     
    602703  ("ScaledRefLayerBottomOffset%d", cfg_scaledRefLayerBottomOffsetPtr,string(""), MAX_LAYERS, "Vertical offset of bottom-right luma sample of scaled base layer picture with respect to"
    603704  " bottom-right luma sample of the EL picture, in units of two luma samples")
     705#if REF_REGION_OFFSET
     706  ("ScaledRefLayerOffsetPresentFlag%d",      cfg_scaledRefLayerOffsetPresentFlagPtr,     string(""), MAX_LAYERS, "presense flag of scaled reference layer offsets")
     707  ("RefRegionOffsetPresentFlag%d",           cfg_refRegionOffsetPresentFlagPtr,          string(""), MAX_LAYERS, "presense flag of reference region offsets")
     708  ("RefRegionLeftOffset%d",   cfg_refRegionLeftOffsetPtr,  string(""), MAX_LAYERS, "Horizontal offset of top-left luma sample of ref region with respect to"
     709                                                                 " top-left luma sample of the BL picture, in units of two luma samples")
     710  ("RefRegionTopOffset%d",    cfg_refRegionTopOffsetPtr,   string(""), MAX_LAYERS,   "Vertical offset of top-left luma sample of ref region with respect to"
     711                                                                 " top-left luma sample of the BL picture, in units of two luma samples")
     712  ("RefRegionRightOffset%d",  cfg_refRegionRightOffsetPtr, string(""), MAX_LAYERS, "Horizontal offset of bottom-right luma sample of ref region with respect to"
     713                                                                 " bottom-right luma sample of the BL picture, in units of two luma samples")
     714  ("RefRegionBottomOffset%d", cfg_refRegionBottomOffsetPtr,string(""), MAX_LAYERS, "Vertical offset of bottom-right luma sample of ref region with respect to"
     715                                                                 " bottom-right luma sample of the BL picture, in units of two luma samples")
     716#endif
     717#if R0209_GENERIC_PHASE
     718  ("ResamplePhaseSetPresentFlag%d",  cfg_resamplePhaseSetPresentFlagPtr, string(""), MAX_LAYERS, "presense flag of resample phase set")
     719  ("PhaseHorLuma%d",   cfg_phaseHorLumaPtr,   string(""), MAX_LAYERS, "luma shift in the horizontal direction used in resampling proces")
     720  ("PhaseVerLuma%d",   cfg_phaseVerLumaPtr,   string(""), MAX_LAYERS, "luma shift in the vertical   direction used in resampling proces")
     721  ("PhaseHorChroma%d", cfg_phaseHorChromaPtr, string(""), MAX_LAYERS, "chroma shift in the horizontal direction used in resampling proces")
     722  ("PhaseVerChroma%d", cfg_phaseVerChromaPtr, string(""), MAX_LAYERS, "chroma shift in the vertical   direction used in resampling proces")
     723#endif
    604724#if P0312_VERT_PHASE_ADJ
    605725  ("VertPhasePositionEnableFlag%d", cfg_vertPhasePositionEnableFlagPtr,string(""), MAX_LAYERS, "VertPhasePositionEnableFlag for layer %d")
     726#endif
     727#if Q0074_COLOUR_REMAPPING_SEI
     728  ("SEIColourRemappingInfoFile%d", cfg_colourRemapSEIFile, string(""), MAX_LAYERS, "Colour Remapping Information SEI parameters file name for layer %d")
    606729#endif
    607730#if O0194_DIFFERENT_BITDEPTH_EL_BL
     
    627750#endif
    628751#if AVC_BASE
     752#if VPS_AVC_BL_FLAG_REMOVAL
     753  ("NonHEVCBase,-nonhevc",            m_nonHEVCBaseLayerFlag,     0, "BL is available but not internal")
     754#else
    629755  ("AvcBase,-avc",            m_avcBaseLayerFlag,     0, "avc_base_layer_flag")
     756#endif
    630757  ("InputBLFile,-ibl",        cfg_BLInputFile,     string(""), "Base layer rec YUV input file name")
    631 #if AVC_SYNTAX
    632   ("InputBLSyntaxFile,-ibs",  cfg_BLSyntaxFile,     string(""), "Base layer syntax input file name")
    633 #endif
    634758#endif
    635759  ("EnableElRapB,-use-rap-b",  m_elRapSliceBEnabled, 0, "Set ILP over base-layer I picture to B picture (default is P picture)")
    636 #if Q0074_SEI_COLOR_MAPPING
    637   ("SEIColorMappingFile%d", cfg_seiColorMappingFile, string(""), MAX_LAYERS, "File Containing SEI Color Mapping data")
    638 #endif
    639760#else //SVC_EXTENSION
    640761  ("InputFile,i",           cfg_InputFile,     string(""), "Original YUV input file name")
     
    654775  ("ChromaFormatIDC,-cf",   tmpChromaFormat,                             0, "ChromaFormatIDC (400|420|422|444 or set 0 (default) for same as InputChromaFormat)")
    655776#endif
    656   ("ConformanceMode",       m_conformanceMode,     0, "Window conformance mode (0: no window, 1:automatic padding, 2:padding, 3:conformance")
    657   ("HorizontalPadding,-pdx",m_aiPad[0],            0, "Horizontal source padding for conformance window mode 2")
    658   ("VerticalPadding,-pdy",  m_aiPad[1],            0, "Vertical source padding for conformance window mode 2")
    659   ("ConfLeft",              m_confLeft,            0, "Left offset for window conformance mode 3")
    660   ("ConfRight",             m_confRight,           0, "Right offset for window conformance mode 3")
    661   ("ConfTop",               m_confTop,             0, "Top offset for window conformance mode 3")
    662   ("ConfBottom",            m_confBottom,          0, "Bottom offset for window conformance mode 3")
     777  ("ConformanceMode",       m_conformanceWindowMode,  0, "Deprecated alias of ConformanceWindowMode")
     778  ("ConformanceWindowMode", m_conformanceWindowMode,  0, "Window conformance mode (0: no window, 1:automatic padding, 2:padding, 3:conformance")
     779  ("HorizontalPadding,-pdx",m_aiPad[0],               0, "Horizontal source padding for conformance window mode 2")
     780  ("VerticalPadding,-pdy",  m_aiPad[1],               0, "Vertical source padding for conformance window mode 2")
     781  ("ConfLeft",              m_confWinLeft,            0, "Deprecated alias of ConfWinLeft")
     782  ("ConfRight",             m_confWinRight,           0, "Deprecated alias of ConfWinRight")
     783  ("ConfTop",               m_confWinTop,             0, "Deprecated alias of ConfWinTop")
     784  ("ConfBottom",            m_confWinBottom,          0, "Deprecated alias of ConfWinBottom")
     785  ("ConfWinLeft",           m_confWinLeft,            0, "Left offset for window conformance mode 3")
     786  ("ConfWinRight",          m_confWinRight,           0, "Right offset for window conformance mode 3")
     787  ("ConfWinTop",            m_confWinTop,             0, "Top offset for window conformance mode 3")
     788  ("ConfWinBottom",         m_confWinBottom,          0, "Bottom offset for window conformance mode 3")
    663789  ("FrameRate,-fr",         m_iFrameRate,          0, "Frame rate")
     790#if Q0074_COLOUR_REMAPPING_SEI
     791  ("SEIColourRemappingInfoFile", cfg_colourRemapSEIFile, string(""), "Colour Remapping Information SEI parameters file name")
     792#endif
    664793#endif //SVC_EXTENSION
    665794  ("FrameSkip,-fs",         m_FrameSkip,          0u, "Number of frames to skip at start of input YUV")
     
    821950  ("WeightedPredB,-wpB",          m_useWeightedBiPred,             false,      "Use weighted (bidirectional) prediction in B slices")
    822951  ("Log2ParallelMergeLevel",      m_log2ParallelMergeLevel,     2u,          "Parallel merge estimation region")
    823   ("UniformSpacingIdc",           m_iUniformSpacingIdr,            0,          "Indicates if the column and row boundaries are distributed uniformly")
    824   ("NumTileColumnsMinus1",        m_iNumColumnsMinus1,             0,          "Number of columns in a picture minus 1")
    825   ("ColumnWidthArray",            cfg_ColumnWidth,                 string(""), "Array containing ColumnWidth values in units of LCU")
    826   ("NumTileRowsMinus1",           m_iNumRowsMinus1,                0,          "Number of rows in a picture minus 1")
    827   ("RowHeightArray",              cfg_RowHeight,                   string(""), "Array containing RowHeight values in units of LCU")
     952
     953  //deprecated copies of renamed tile parameters
     954  ("UniformSpacingIdc",           m_tileUniformSpacingFlag,        false,      "deprecated alias of TileUniformSpacing")
     955  ("ColumnWidthArray",            cfgColumnWidth,                  string(""), "deprecated alias of TileColumnWidthArray")
     956  ("RowHeightArray",              cfgRowHeight,                    string(""), "deprecated alias of TileRowHeightArray")
     957
     958  ("TileUniformSpacing",          m_tileUniformSpacingFlag,        false,      "Indicates that tile columns and rows are distributed uniformly")
     959  ("NumTileColumnsMinus1",        m_numTileColumnsMinus1,          0,          "Number of tile columns in a picture minus 1")
     960  ("NumTileRowsMinus1",           m_numTileRowsMinus1,             0,          "Number of rows in a picture minus 1")
     961  ("TileColumnWidthArray",        cfgColumnWidth,                  string(""), "Array containing tile column width values in units of LCU")
     962  ("TileRowHeightArray",          cfgRowHeight,                    string(""), "Array containing tile row height values in units of LCU")
    828963  ("LFCrossTileBoundaryFlag",      m_bLFCrossTileBoundaryFlag,             true,          "1: cross-tile-boundary loop filtering. 0:non-cross-tile-boundary loop filtering")
     964#if SVC_EXTENSION
     965  ("WaveFrontSynchro%d",          cfg_waveFrontSynchro,             0,  MAX_LAYERS,          "0: no synchro; 1 synchro with TR; 2 TRR etc")
     966#else
    829967  ("WaveFrontSynchro",            m_iWaveFrontSynchro,             0,          "0: no synchro; 1 synchro with TR; 2 TRR etc")
     968#endif
    830969  ("ScalingList",                 m_useScalingListId,              0,          "0: no scaling list, 1: default scaling lists, 2: scaling lists specified in ScalingListFile")
    831970  ("ScalingListFile",             cfg_ScalingListFile,             string(""), "Scaling list file name")
     
    8841023  ("ColourDescriptionPresent",       m_colourDescriptionPresentFlag,       false, "Signals whether colour_primaries, transfer_characteristics and matrix_coefficients are present")
    8851024  ("ColourPrimaries",                m_colourPrimaries,                        2, "Indicates chromaticity coordinates of the source primaries")
    886   ("TransferCharateristics",         m_transferCharacteristics,                2, "Indicates the opto-electronic transfer characteristics of the source")
     1025  ("TransferCharacteristics",        m_transferCharacteristics,                2, "Indicates the opto-electronic transfer characteristics of the source")
    8871026  ("MatrixCoefficients",             m_matrixCoefficients,                     2, "Describes the matrix coefficients used in deriving luma and chroma from RGB primaries")
    8881027  ("ChromaLocInfoPresent",           m_chromaLocInfoPresentFlag,           false, "Signals whether chroma_sample_loc_type_top_field and chroma_sample_loc_type_bottom_field are present")
     
    10041143  ("CGSMaxYPartNumLog",  m_nCGSMaxYPartNumLog2 , 2, "max Y part number ")
    10051144  ("CGSLUTBit",     m_nCGSLUTBit , 12, "bit depth of CGS LUT")
     1145#if R0151_CGS_3D_ASYMLUT_IMPROVE
     1146  ("CGSAdaptC",     m_nCGSAdaptiveChroma , 1, "adaptive chroma partition (only for the case of two chroma partitions)")
     1147#endif
     1148#if R0179_ENC_OPT_3DLUT_SIZE
     1149  ("CGSSizeRDO",     m_nCGSLutSizeRDO , 0, "RDOpt selection of best table size (effective when large maximum table size such as 8x8x8 is used)")
     1150#endif
    10061151#endif
    10071152#if Q0108_TSA_STSA
     
    10891234#if SVC_EXTENSION
    10901235#if AVC_BASE
     1236#if VPS_AVC_BL_FLAG_REMOVAL
     1237  if( m_nonHEVCBaseLayerFlag )
     1238#else
    10911239  if( m_avcBaseLayerFlag )
     1240#endif
    10921241  {
    10931242    *cfg_InputFile[0] = cfg_BLInputFile;
     
    10951244#endif
    10961245  m_pBitstreamFile = cfg_BitstreamFile.empty() ? NULL : strdup(cfg_BitstreamFile.c_str());
    1097 #if AVC_SYNTAX
    1098   m_BLSyntaxFile = cfg_BLSyntaxFile.empty() ? NULL : strdup(cfg_BLSyntaxFile.c_str());
    1099 #endif
    11001246#else //SVC_EXTENSION
    11011247  m_pchInputFile = cfg_InputFile.empty() ? NULL : strdup(cfg_InputFile.c_str());
     
    11031249  m_pchReconFile = cfg_ReconFile.empty() ? NULL : strdup(cfg_ReconFile.c_str());
    11041250  m_pchdQPFile = cfg_dQPFile.empty() ? NULL : strdup(cfg_dQPFile.c_str());
    1105 #endif //SVC_EXTENSION
    1106 
    1107   Char* pColumnWidth = cfg_ColumnWidth.empty() ? NULL: strdup(cfg_ColumnWidth.c_str());
    1108   Char* pRowHeight = cfg_RowHeight.empty() ? NULL : strdup(cfg_RowHeight.c_str());
    1109   if( m_iUniformSpacingIdr == 0 && m_iNumColumnsMinus1 > 0 )
    1110   {
    1111     char *columnWidth;
     1251#if Q0074_COLOUR_REMAPPING_SEI
     1252  m_colourRemapSEIFile = cfg_colourRemapSEIFile.empty() ? NULL : strdup(cfg_colourRemapSEIFile.c_str());
     1253#endif
     1254#endif //SVC_EXTENSION
     1255
     1256
     1257  Char* pColumnWidth = cfgColumnWidth.empty() ? NULL: strdup(cfgColumnWidth.c_str());
     1258  Char* pRowHeight = cfgRowHeight.empty() ? NULL : strdup(cfgRowHeight.c_str());
     1259
     1260  if( !m_tileUniformSpacingFlag && m_numTileColumnsMinus1 > 0 )
     1261  {
     1262    char *str;
    11121263    int  i=0;
    1113     m_pColumnWidth = new UInt[m_iNumColumnsMinus1];
    1114     columnWidth = strtok(pColumnWidth, " ,-");
    1115     while(columnWidth!=NULL)
    1116     {
    1117       if( i>=m_iNumColumnsMinus1 )
     1264    m_tileColumnWidth.resize( m_numTileColumnsMinus1 );
     1265    str = strtok(pColumnWidth, " ,-");
     1266    while(str!=NULL)
     1267    {
     1268      if( i >= m_numTileColumnsMinus1 )
    11181269      {
    11191270        printf( "The number of columns whose width are defined is larger than the allowed number of columns.\n" );
    11201271        exit( EXIT_FAILURE );
    11211272      }
    1122       *( m_pColumnWidth + i ) = atoi( columnWidth );
    1123       columnWidth = strtok(NULL, " ,-");
     1273      m_tileColumnWidth[i] = atoi( str );
     1274      str = strtok(NULL, " ,-");
    11241275      i++;
    11251276    }
    1126     if( i<m_iNumColumnsMinus1 )
     1277    if( i < m_numTileColumnsMinus1 )
    11271278    {
    11281279      printf( "The width of some columns is not defined.\n" );
     
    11321283  else
    11331284  {
    1134     m_pColumnWidth = NULL;
    1135   }
    1136 
    1137   if( m_iUniformSpacingIdr == 0 && m_iNumRowsMinus1 > 0 )
    1138   {
    1139     char *rowHeight;
     1285    m_tileColumnWidth.clear();
     1286  }
     1287
     1288  if( !m_tileUniformSpacingFlag && m_numTileRowsMinus1 > 0 )
     1289  {
     1290    char *str;
    11401291    int  i=0;
    1141     m_pRowHeight = new UInt[m_iNumRowsMinus1];
    1142     rowHeight = strtok(pRowHeight, " ,-");
    1143     while(rowHeight!=NULL)
    1144     {
    1145       if( i>=m_iNumRowsMinus1 )
     1292    m_tileRowHeight.resize(m_numTileRowsMinus1);
     1293    str = strtok(pRowHeight, " ,-");
     1294    while(str!=NULL)
     1295    {
     1296      if( i>=m_numTileRowsMinus1 )
    11461297      {
    11471298        printf( "The number of rows whose height are defined is larger than the allowed number of rows.\n" );
    11481299        exit( EXIT_FAILURE );
    11491300      }
    1150       *( m_pRowHeight + i ) = atoi( rowHeight );
    1151       rowHeight = strtok(NULL, " ,-");
     1301      m_tileRowHeight[i] = atoi( str );
     1302      str = strtok(NULL, " ,-");
    11521303      i++;
    11531304    }
    1154     if( i<m_iNumRowsMinus1 )
     1305    if( i < m_numTileRowsMinus1 )
    11551306    {
    11561307      printf( "The height of some rows is not defined.\n" );
     
    11601311  else
    11611312  {
    1162     m_pRowHeight = NULL;
     1313    m_tileRowHeight.clear();
    11631314  }
    11641315#if SVC_EXTENSION
     1316  if( pColumnWidth )
     1317  {
     1318    free( pColumnWidth );
     1319    pColumnWidth = NULL;
     1320  }
     1321
     1322  if( pRowHeight )
     1323  {
     1324    free( pRowHeight );
     1325    pRowHeight = NULL;
     1326  }
     1327
    11651328  for(Int layer = 0; layer < MAX_LAYERS; layer++)
    11661329  {
     
    11711334      assert( strcmp(cfg_scaledRefLayerId[layer].c_str(),  ""));
    11721335#endif
     1336#if REF_REGION_OFFSET
     1337      Bool srloFlag =
     1338        strcmp(cfg_scaledRefLayerLeftOffset   [layer].c_str(), "") ||
     1339        strcmp(cfg_scaledRefLayerRightOffset  [layer].c_str(), "") ||
     1340        strcmp(cfg_scaledRefLayerTopOffset    [layer].c_str(), "") ||
     1341        strcmp(cfg_scaledRefLayerBottomOffset [layer].c_str(), "");
     1342      Bool rroFlag =
     1343        strcmp(cfg_refRegionLeftOffset   [layer].c_str(), "") ||
     1344        strcmp(cfg_refRegionRightOffset  [layer].c_str(), "") ||
     1345        strcmp(cfg_refRegionTopOffset    [layer].c_str(), "") ||
     1346        strcmp(cfg_refRegionBottomOffset [layer].c_str(), "");
     1347#if R0209_GENERIC_PHASE
     1348      Bool phaseSetFlag =
     1349        strcmp(cfg_phaseHorLuma   [layer].c_str(), "") ||
     1350        strcmp(cfg_phaseVerLuma  [layer].c_str(), "") ||
     1351        strcmp(cfg_phaseHorChroma    [layer].c_str(), "") ||
     1352        strcmp(cfg_phaseVerChroma [layer].c_str(), "");
     1353      assert( srloFlag || rroFlag || phaseSetFlag);
     1354#else
     1355      assert( srloFlag || rroFlag );
     1356#endif
     1357#else
    11731358#if P0312_VERT_PHASE_ADJ
    11741359      assert( strcmp(cfg_scaledRefLayerLeftOffset[layer].c_str(),  "") ||
     
    11831368              strcmp(cfg_scaledRefLayerBottomOffset[layer].c_str(),"") );
    11841369#endif
     1370#endif
    11851371    }
    11861372
     
    12031389#endif
    12041390
     1391#if REF_REGION_OFFSET
     1392    // Presense Flag //
     1393    if(strcmp(cfg_scaledRefLayerOffsetPresentFlag[layer].c_str(),  ""))
     1394    {
     1395      cfgStringToArray( &tempArray, cfg_scaledRefLayerOffsetPresentFlag[layer], m_acLayerCfg[layer].m_numScaledRefLayerOffsets, "ScaledRefLayerOffsetPresentFlag");
     1396      if(tempArray)
     1397      {
     1398        for(Int i = 0; i < m_acLayerCfg[layer].m_numScaledRefLayerOffsets; i++)
     1399        {
     1400          m_acLayerCfg[layer].m_scaledRefLayerOffsetPresentFlag[i] = tempArray[i];
     1401        }
     1402        delete [] tempArray; tempArray = NULL;
     1403      }
     1404    }
     1405#endif
     1406
    12051407    // Left offset //
    12061408    if(strcmp(cfg_scaledRefLayerLeftOffset[layer].c_str(),  ""))
     
    12731475    }
    12741476#endif
    1275   }
     1477#if REF_REGION_OFFSET
     1478    // Presense Flag //
     1479    if(strcmp(cfg_refRegionOffsetPresentFlag[layer].c_str(),  ""))
     1480    {
     1481      cfgStringToArray( &tempArray, cfg_refRegionOffsetPresentFlag[layer], m_acLayerCfg[layer].m_numScaledRefLayerOffsets, "RefRegionOffsetPresentFlag");
     1482      if(tempArray)
     1483      {
     1484        for(Int i = 0; i < m_acLayerCfg[layer].m_numScaledRefLayerOffsets; i++)
     1485        {
     1486          m_acLayerCfg[layer].m_refRegionOffsetPresentFlag[i] = tempArray[i];
     1487        }
     1488        delete [] tempArray; tempArray = NULL;
     1489      }
     1490    }
     1491
     1492    // Left offset //
     1493    if(strcmp(cfg_refRegionLeftOffset[layer].c_str(),  ""))
     1494    {
     1495      cfgStringToArray( &tempArray, cfg_refRegionLeftOffset[layer], m_acLayerCfg[layer].m_numScaledRefLayerOffsets, "RefRegionLeftOffset");
     1496      if(tempArray)
     1497      {
     1498        for(Int i = 0; i < m_acLayerCfg[layer].m_numScaledRefLayerOffsets; i++)
     1499        {
     1500          m_acLayerCfg[layer].m_refRegionLeftOffset[i] = tempArray[i];
     1501        }
     1502        delete [] tempArray; tempArray = NULL;
     1503      }
     1504    }
     1505
     1506    // Top offset //
     1507    if(strcmp(cfg_refRegionTopOffset[layer].c_str(),  ""))
     1508    {
     1509      cfgStringToArray( &tempArray, cfg_refRegionTopOffset[layer], m_acLayerCfg[layer].m_numScaledRefLayerOffsets, "RefRegionTopOffset");
     1510      if(tempArray)
     1511      {
     1512        for(Int i = 0; i < m_acLayerCfg[layer].m_numScaledRefLayerOffsets; i++)
     1513        {
     1514          m_acLayerCfg[layer].m_refRegionTopOffset[i] = tempArray[i];
     1515        }
     1516        delete [] tempArray; tempArray = NULL;
     1517      }
     1518    }
     1519
     1520    // Right offset //
     1521    if(strcmp(cfg_refRegionRightOffset[layer].c_str(),  ""))
     1522    {
     1523      cfgStringToArray( &tempArray, cfg_refRegionRightOffset[layer], m_acLayerCfg[layer].m_numScaledRefLayerOffsets, "RefRegionRightOffset");
     1524      if(tempArray)
     1525      {
     1526        for(Int i = 0; i < m_acLayerCfg[layer].m_numScaledRefLayerOffsets; i++)
     1527        {
     1528          m_acLayerCfg[layer].m_refRegionRightOffset[i] = tempArray[i];
     1529        }
     1530        delete [] tempArray; tempArray = NULL;
     1531      }
     1532    }
     1533
     1534    // Bottom offset //
     1535    if(strcmp(cfg_refRegionBottomOffset[layer].c_str(),  ""))
     1536    {
     1537      cfgStringToArray( &tempArray, cfg_refRegionBottomOffset[layer], m_acLayerCfg[layer].m_numScaledRefLayerOffsets, "RefRegionBottomOffset");
     1538      if(tempArray)
     1539      {
     1540        for(Int i = 0; i < m_acLayerCfg[layer].m_numScaledRefLayerOffsets; i++)
     1541        {
     1542          m_acLayerCfg[layer].m_refRegionBottomOffset[i] = tempArray[i];
     1543        }
     1544        delete [] tempArray; tempArray = NULL;
     1545      }
     1546    }
     1547#endif
     1548#if R0209_GENERIC_PHASE
     1549    Int numPhaseSet = m_acLayerCfg[layer].m_numScaledRefLayerOffsets;
     1550
     1551    // Presense Flag //
     1552    if(strcmp(cfg_resamplePhaseSetPresentFlag[layer].c_str(),  ""))
     1553    {
     1554      cfgStringToArray( &tempArray, cfg_resamplePhaseSetPresentFlag[layer], numPhaseSet, "resamplePhaseSetPresentFlag");
     1555      if(tempArray)
     1556      {
     1557        for(Int i = 0; i < numPhaseSet; i++)
     1558        {
     1559          m_acLayerCfg[layer].m_resamplePhaseSetPresentFlag[i] = tempArray[i];
     1560        }
     1561        delete [] tempArray; tempArray = NULL;
     1562      }
     1563    }
     1564
     1565    // Luma horizontal phase //
     1566    if(strcmp(cfg_phaseHorLuma[layer].c_str(),  ""))
     1567    {
     1568      cfgStringToArray( &tempArray, cfg_phaseHorLuma[layer], numPhaseSet, "phaseHorLuma");
     1569      if(tempArray)
     1570      {
     1571        for(Int i = 0; i < numPhaseSet; i++)
     1572        {
     1573          m_acLayerCfg[layer].m_phaseHorLuma[i] = tempArray[i];
     1574        }
     1575        delete [] tempArray; tempArray = NULL;
     1576      }
     1577    }
     1578
     1579    // Luma vertical phase //
     1580    if(strcmp(cfg_phaseVerLuma[layer].c_str(),  ""))
     1581    {
     1582      cfgStringToArray( &tempArray, cfg_phaseVerLuma[layer], numPhaseSet, "phaseVerLuma");
     1583      if(tempArray)
     1584      {
     1585        for(Int i = 0; i < numPhaseSet; i++)
     1586        {
     1587          m_acLayerCfg[layer].m_phaseVerLuma[i] = tempArray[i];
     1588        }
     1589        delete [] tempArray; tempArray = NULL;
     1590      }
     1591    }
     1592
     1593    // Chroma horizontal phase //
     1594    if(strcmp(cfg_phaseHorChroma[layer].c_str(),  ""))
     1595    {
     1596      cfgStringToArray( &tempArray, cfg_phaseHorChroma[layer], numPhaseSet, "phaseHorChroma");
     1597      if(tempArray)
     1598      {
     1599        for(Int i = 0; i < numPhaseSet; i++)
     1600        {
     1601          m_acLayerCfg[layer].m_phaseHorChroma[i] = tempArray[i];
     1602        }
     1603        delete [] tempArray; tempArray = NULL;
     1604      }
     1605    }
     1606
     1607    // Chroma vertical phase //
     1608    if(strcmp(cfg_phaseVerChroma[layer].c_str(),  ""))
     1609    {
     1610      cfgStringToArray( &tempArray, cfg_phaseVerChroma[layer], numPhaseSet, "phaseVerChroma");
     1611      if(tempArray)
     1612      {
     1613        for(Int i = 0; i < numPhaseSet; i++)
     1614        {
     1615          m_acLayerCfg[layer].m_phaseVerChroma[i] = tempArray[i];
     1616        }
     1617        delete [] tempArray; tempArray = NULL;
     1618      }
     1619    }
     1620#endif
     1621  }
     1622
    12761623#if VPS_EXTN_DIRECT_REF_LAYERS
    12771624  for(Int layer = 0; layer < MAX_LAYERS; layer++)
     
    13051652      m_acLayerCfg[layer].m_samplePredRefLayerIds = NULL;
    13061653    }
     1654
     1655    if( pSamplePredRefLayerIds )
     1656    {
     1657      free( pSamplePredRefLayerIds );
     1658      pSamplePredRefLayerIds = NULL;
     1659    }
    13071660  }
    13081661  for(Int layer = 0; layer < MAX_LAYERS; layer++)
     
    13361689      m_acLayerCfg[layer].m_motionPredRefLayerIds = NULL;
    13371690    }
     1691
     1692    if( pMotionPredRefLayerIds )
     1693    {
     1694      free( pMotionPredRefLayerIds );
     1695      pMotionPredRefLayerIds = NULL;
     1696    }
    13381697  }
    13391698
     
    13751734      m_acLayerCfg[layer].m_predLayerIds = NULL;
    13761735    }
     1736
     1737    if( pPredLayerIds )
     1738    {
     1739      free( pPredLayerIds );
     1740      pPredLayerIds = NULL;
     1741    }
    13771742  }
    13781743#endif
    13791744#if Q0078_ADD_LAYER_SETS
     1745#if OUTPUT_LAYER_SETS_CONFIG
     1746  for (Int layerSet = 1; layerSet < m_numLayerSets; layerSet++)
     1747  {
     1748    // Simplifying the code in the #else section, and allowing 0-th layer set t
     1749    assert( scanStringToArray( cfg_layerSetLayerIdList[layerSet], m_numLayerInIdList[layerSet], "NumLayerInIdList", m_layerSetLayerIdList[layerSet] ) );
     1750#else
    13801751  for (Int layerSet = 0; layerSet < m_numLayerSets; layerSet++)
    13811752  {
     
    13961767        i++;
    13971768      }
    1398     }
     1769
     1770      if( layerSetLayerIdListDup )
     1771      {
     1772        free( layerSetLayerIdListDup );
     1773        layerSetLayerIdListDup = NULL;
     1774      }
     1775    }
     1776#endif
    13991777  }
    14001778  for (Int addLayerSet = 0; addLayerSet < m_numAddLayerSets; addLayerSet++)
    14011779  {
     1780#if OUTPUT_LAYER_SETS_CONFIG
     1781    // Simplifying the code in the #else section
     1782    assert( scanStringToArray( cfg_layerSetLayerIdList[addLayerSet], m_numLayerInIdList[addLayerSet], "NumLayerInIdList",  m_highestLayerIdx[addLayerSet] ) );
     1783#else
    14021784    if (m_numHighestLayerIdx[addLayerSet] > 0)
    14031785    {
     
    14161798        i++;
    14171799      }
    1418     }
    1419   }
     1800
     1801      if( highestLayrIdxListDup )
     1802      {
     1803        free( highestLayrIdxListDup );
     1804        highestLayrIdxListDup = NULL;
     1805      }
     1806    }
     1807#endif
     1808  }
     1809#endif
     1810#if OUTPUT_LAYER_SETS_CONFIG
     1811  if( m_defaultTargetOutputLayerIdc != -1 )
     1812  {
     1813    assert( m_defaultTargetOutputLayerIdc >= 0 && m_defaultTargetOutputLayerIdc <= 3 );
     1814  }
     1815  assert( m_numOutputLayerSets != 0 );
     1816  assert( m_numOutputLayerSets >= m_numLayerSets + m_numAddLayerSets ); // Number of output layer sets must be at least as many as layer sets.
     1817
     1818  // If output layer Set Idx is specified, only specify it for the non-default output layer sets
     1819  Int numNonDefaultOls = m_numOutputLayerSets - (m_numLayerSets + m_numAddLayerSets);
     1820  if( numNonDefaultOls )
     1821  {
     1822    assert( scanStringToArray( *cfg_outputLayerSetIdx, numNonDefaultOls, "OutputLayerSetIdx", m_outputLayerSetIdx ) );
     1823    for(Int i = 0; i < numNonDefaultOls; i++)
     1824    {
     1825      assert( m_outputLayerSetIdx[i] >= 0 && m_outputLayerSetIdx[i] < (m_numLayerSets + m_numAddLayerSets) );
     1826    }
     1827  }
     1828
     1829  // Number of output layers in output layer sets
     1830  scanStringToArray( *cfg_numLayersInOutputLayerSet, m_numOutputLayerSets - 1, "NumLayersInOutputLayerSets", m_numLayersInOutputLayerSet );
     1831  m_numLayersInOutputLayerSet.insert(m_numLayersInOutputLayerSet.begin(), 1);
     1832  // Layers in the output layer set
     1833  m_listOfOutputLayers.resize(m_numOutputLayerSets);
     1834  Int startOlsCtr = 1;
     1835  if( m_defaultTargetOutputLayerIdc == 0 || m_defaultTargetOutputLayerIdc == 1 )
     1836  {
     1837    // Default output layer sets defined
     1838    startOlsCtr = m_numLayerSets + m_numAddLayerSets;
     1839  }
     1840  for( Int olsCtr = 1; olsCtr < m_numOutputLayerSets; olsCtr++ )
     1841  {
     1842    if( olsCtr < startOlsCtr )
     1843    {
     1844      if(scanStringToArray( cfg_listOfOutputLayers[olsCtr], m_numLayersInOutputLayerSet[olsCtr], "ListOfOutputLayers", m_listOfOutputLayers[olsCtr] ) )
     1845      {
     1846        std::cout << "Default OLS defined. Ignoring ListOfOutputLayers" << olsCtr << endl;
     1847      }
     1848    }
     1849    else
     1850    {
     1851      assert( scanStringToArray( cfg_listOfOutputLayers[olsCtr], m_numLayersInOutputLayerSet[olsCtr], "ListOfOutputLayers", m_listOfOutputLayers[olsCtr] ) );
     1852    }
     1853  }
     1854  delete cfg_numLayersInOutputLayerSet;
     1855  delete [] cfg_listOfOutputLayers;
     1856  delete cfg_outputLayerSetIdx;
    14201857#endif
    14211858#endif //SVC_EXTENSION
     
    14421879#if !SVC_EXTENSION
    14431880  // TODO:ChromaFmt assumes 4:2:0 below
    1444   switch (m_conformanceMode)
     1881  switch (m_conformanceWindowMode)
    14451882  {
    14461883  case 0:
    14471884    {
    14481885      // no conformance or padding
    1449       m_confLeft = m_confRight = m_confTop = m_confBottom = 0;
     1886      m_confWinLeft = m_confWinRight = m_confWinTop = m_confWinBottom = 0;
    14501887      m_aiPad[1] = m_aiPad[0] = 0;
    14511888      break;
     
    14571894      if (m_iSourceWidth % minCuSize)
    14581895      {
    1459         m_aiPad[0] = m_confRight  = ((m_iSourceWidth / minCuSize) + 1) * minCuSize - m_iSourceWidth;
    1460         m_iSourceWidth  += m_confRight;
     1896        m_aiPad[0] = m_confWinRight  = ((m_iSourceWidth / minCuSize) + 1) * minCuSize - m_iSourceWidth;
     1897        m_iSourceWidth  += m_confWinRight;
    14611898      }
    14621899      if (m_iSourceHeight % minCuSize)
    14631900      {
    1464         m_aiPad[1] = m_confBottom = ((m_iSourceHeight / minCuSize) + 1) * minCuSize - m_iSourceHeight;
    1465         m_iSourceHeight += m_confBottom;
     1901        m_aiPad[1] = m_confWinBottom = ((m_iSourceHeight / minCuSize) + 1) * minCuSize - m_iSourceHeight;
     1902        m_iSourceHeight += m_confWinBottom;
    14661903        if ( m_isField )
    14671904        {
    1468           m_iSourceHeightOrg += m_confBottom << 1;
    1469           m_aiPad[1] = m_confBottom << 1;
     1905          m_iSourceHeightOrg += m_confWinBottom << 1;
     1906          m_aiPad[1] = m_confWinBottom << 1;
    14701907        }
    14711908      }
     
    14871924      m_iSourceWidth  += m_aiPad[0];
    14881925      m_iSourceHeight += m_aiPad[1];
    1489       m_confRight  = m_aiPad[0];
    1490       m_confBottom = m_aiPad[1];
     1926      m_confWinRight  = m_aiPad[0];
     1927      m_confWinBottom = m_aiPad[1];
    14911928      break;
    14921929    }
     
    14941931    {
    14951932      // conformance
    1496       if ((m_confLeft == 0) && (m_confRight == 0) && (m_confTop == 0) && (m_confBottom == 0))
     1933      if ((m_confWinLeft == 0) && (m_confWinRight == 0) && (m_confWinTop == 0) && (m_confWinBottom == 0))
    14971934      {
    14981935        fprintf(stderr, "Warning: Conformance window enabled, but all conformance window parameters set to zero\n");
     
    16012038      m_targetPivotValue = NULL;
    16022039    }
     2040
     2041    if( pcStartOfCodedInterval )
     2042    {
     2043      free( pcStartOfCodedInterval );
     2044      pcStartOfCodedInterval = NULL;
     2045    }
     2046
     2047    if( pcCodedPivotValue )
     2048    {
     2049      free( pcCodedPivotValue );
     2050      pcCodedPivotValue = NULL;
     2051    }
     2052
     2053    if( pcTargetPivotValue )
     2054    {
     2055      free( pcTargetPivotValue );
     2056      pcTargetPivotValue = NULL;
     2057    }
    16032058  }
    16042059#if P0050_KNEE_FUNCTION_SEI
     
    16262081      i++;
    16272082    }
    1628   }
    1629 #endif
    1630 
     2083
     2084    if( pcInputKneePointValue )
     2085    {
     2086      free( pcInputKneePointValue );
     2087      pcInputKneePointValue = NULL;
     2088    }
     2089
     2090    if( pcOutputKneePointValue )
     2091    {
     2092      free( pcOutputKneePointValue );
     2093      pcOutputKneePointValue = NULL;
     2094    }
     2095  }
     2096#endif
     2097#if Q0074_COLOUR_REMAPPING_SEI
     2098#if !SVC_EXTENSION
     2099  // reading external Colour Remapping Information SEI message parameters from file
     2100  if( m_colourRemapSEIFile.size() > 0 )
     2101  {
     2102    FILE* fic;
     2103    Int retval;
     2104    if((fic = fopen(m_colourRemapSEIFile.c_str(),"r")) == (FILE*)NULL)
     2105    {
     2106      fprintf(stderr, "Can't open Colour Remapping Information SEI parameters file %s\n", m_colourRemapSEIFile.c_str());
     2107      exit(EXIT_FAILURE);
     2108    }
     2109
     2110    retval = fscanf( fic, "%d", &m_colourRemapSEIId );
     2111    retval = fscanf( fic, "%d", &m_colourRemapSEICancelFlag );
     2112    if( !m_colourRemapSEICancelFlag )
     2113    {
     2114      retval = fscanf( fic, "%d", &m_colourRemapSEIPersistenceFlag );
     2115      retval = fscanf( fic, "%d", &m_colourRemapSEIVideoSignalInfoPresentFlag);
     2116      if( m_colourRemapSEIVideoSignalInfoPresentFlag )
     2117      {
     2118        retval = fscanf( fic, "%d", &m_colourRemapSEIFullRangeFlag  );
     2119        retval = fscanf( fic, "%d", &m_colourRemapSEIPrimaries );
     2120        retval = fscanf( fic, "%d", &m_colourRemapSEITransferFunction );
     2121        retval = fscanf( fic, "%d", &m_colourRemapSEIMatrixCoefficients );
     2122      }
     2123
     2124      retval = fscanf( fic, "%d", &m_colourRemapSEIInputBitDepth );
     2125      retval = fscanf( fic, "%d", &m_colourRemapSEIBitDepth );
     2126 
     2127      for( Int c=0 ; c<3 ; c++ )
     2128      {
     2129        retval = fscanf( fic, "%d", &m_colourRemapSEIPreLutNumValMinus1[c] );
     2130        if( m_colourRemapSEIPreLutNumValMinus1[c]>0 )
     2131        {
     2132          m_colourRemapSEIPreLutCodedValue[c]  = new Int[m_colourRemapSEIPreLutNumValMinus1[c]+1];
     2133          m_colourRemapSEIPreLutTargetValue[c] = new Int[m_colourRemapSEIPreLutNumValMinus1[c]+1];
     2134          for( Int i=0 ; i<=m_colourRemapSEIPreLutNumValMinus1[c] ; i++ )
     2135          {
     2136            retval = fscanf( fic, "%d", &m_colourRemapSEIPreLutCodedValue[c][i] );
     2137            retval = fscanf( fic, "%d", &m_colourRemapSEIPreLutTargetValue[c][i] );
     2138          }
     2139        }
     2140      }
     2141
     2142      retval = fscanf( fic, "%d", &m_colourRemapSEIMatrixPresentFlag );
     2143      if( m_colourRemapSEIMatrixPresentFlag )
     2144      {
     2145        retval = fscanf( fic, "%d", &m_colourRemapSEILog2MatrixDenom );
     2146        for( Int c=0 ; c<3 ; c++ )
     2147          for( Int i=0 ; i<3 ; i++ )
     2148            retval = fscanf( fic, "%d", &m_colourRemapSEICoeffs[c][i] );
     2149      }
     2150
     2151      for( Int c=0 ; c<3 ; c++ )
     2152      {
     2153        retval = fscanf( fic, "%d", &m_colourRemapSEIPostLutNumValMinus1[c] );
     2154        if( m_colourRemapSEIPostLutNumValMinus1[c]>0 )
     2155        {
     2156          m_colourRemapSEIPostLutCodedValue[c]  = new Int[m_colourRemapSEIPostLutNumValMinus1[c]+1];
     2157          m_colourRemapSEIPostLutTargetValue[c] = new Int[m_colourRemapSEIPostLutNumValMinus1[c]+1];
     2158          for( Int i=0 ; i<=m_colourRemapSEIPostLutNumValMinus1[c] ; i++ )
     2159          {
     2160            retval = fscanf( fic, "%d", &m_colourRemapSEIPostLutCodedValue[c][i] );
     2161            retval = fscanf( fic, "%d", &m_colourRemapSEIPostLutTargetValue[c][i] );
     2162          }
     2163        }
     2164      }
     2165    }
     2166
     2167    fclose( fic );
     2168    if( retval != 1 )
     2169    {
     2170      fprintf(stderr, "Error while reading Colour Remapping Information SEI parameters file\n");
     2171      exit(EXIT_FAILURE);
     2172    }
     2173  }
     2174#else
     2175   // Reading external Colour Remapping Information SEI message parameters from file
     2176  // It seems that TAppEncLayerCfg::parseCfg is not used
     2177  for(UInt layer = 0; layer < m_numLayers; layer++)
     2178  {
     2179    if( cfg_colourRemapSEIFile[layer]->length() )
     2180    {
     2181      FILE* fic;
     2182      Int retval;
     2183      if((fic = fopen(cfg_colourRemapSEIFile[layer]->c_str(),"r")) == (FILE*)NULL)
     2184      {
     2185        fprintf(stderr, "Can't open Colour Remapping Information SEI parameters file %s\n", cfg_colourRemapSEIFile[layer]->c_str());
     2186        exit(EXIT_FAILURE);
     2187      }
     2188      Int tempCode;
     2189      retval = fscanf( fic, "%d", &m_acLayerCfg[layer].m_colourRemapSEIId );
     2190      retval = fscanf( fic, "%d", &tempCode ); m_acLayerCfg[layer].m_colourRemapSEICancelFlag = tempCode ? 1 : 0;
     2191      if( !m_acLayerCfg[layer].m_colourRemapSEICancelFlag )
     2192      {
     2193        retval = fscanf( fic, "%d", &tempCode ); m_acLayerCfg[layer].m_colourRemapSEIPersistenceFlag = tempCode ? 1 : 0;
     2194        retval = fscanf( fic, "%d", &tempCode ); m_acLayerCfg[layer].m_colourRemapSEIVideoSignalInfoPresentFlag = tempCode ? 1 : 0;
     2195        if( m_acLayerCfg[layer].m_colourRemapSEIVideoSignalInfoPresentFlag )
     2196        {
     2197          retval = fscanf( fic, "%d", &tempCode ); m_acLayerCfg[layer].m_colourRemapSEIFullRangeFlag = tempCode ? 1 : 0;
     2198          retval = fscanf( fic, "%d", &m_acLayerCfg[layer].m_colourRemapSEIPrimaries );
     2199          retval = fscanf( fic, "%d", &m_acLayerCfg[layer].m_colourRemapSEITransferFunction );
     2200          retval = fscanf( fic, "%d", &m_acLayerCfg[layer].m_colourRemapSEIMatrixCoefficients );
     2201        }
     2202
     2203        retval = fscanf( fic, "%d", &m_acLayerCfg[layer].m_colourRemapSEIInputBitDepth );
     2204        retval = fscanf( fic, "%d", &m_acLayerCfg[layer].m_colourRemapSEIBitDepth );
     2205 
     2206        for( Int c=0 ; c<3 ; c++ )
     2207        {
     2208          retval = fscanf( fic, "%d", &m_acLayerCfg[layer].m_colourRemapSEIPreLutNumValMinus1[c] );
     2209          if( m_acLayerCfg[layer].m_colourRemapSEIPreLutNumValMinus1[c]>0 )
     2210          {
     2211            m_acLayerCfg[layer].m_colourRemapSEIPreLutCodedValue[c]  = new Int[m_acLayerCfg[layer].m_colourRemapSEIPreLutNumValMinus1[c]+1];
     2212            m_acLayerCfg[layer].m_colourRemapSEIPreLutTargetValue[c] = new Int[m_acLayerCfg[layer].m_colourRemapSEIPreLutNumValMinus1[c]+1];
     2213            for( Int i=0 ; i<=m_acLayerCfg[layer].m_colourRemapSEIPreLutNumValMinus1[c] ; i++ )
     2214            {
     2215              retval = fscanf( fic, "%d", &m_acLayerCfg[layer].m_colourRemapSEIPreLutCodedValue[c][i] );
     2216              retval = fscanf( fic, "%d", &m_acLayerCfg[layer].m_colourRemapSEIPreLutTargetValue[c][i] );
     2217            }
     2218          }
     2219        }
     2220
     2221        retval = fscanf( fic, "%d", &tempCode ); m_acLayerCfg[layer].m_colourRemapSEIMatrixPresentFlag = tempCode ? 1 : 0;
     2222        if( m_acLayerCfg[layer].m_colourRemapSEIMatrixPresentFlag )
     2223        {
     2224          retval = fscanf( fic, "%d", &m_acLayerCfg[layer].m_colourRemapSEILog2MatrixDenom );
     2225          for( Int c=0 ; c<3 ; c++ )
     2226            for( Int i=0 ; i<3 ; i++ )
     2227              retval = fscanf( fic, "%d", &m_acLayerCfg[layer].m_colourRemapSEICoeffs[c][i] );
     2228        }
     2229
     2230        for( Int c=0 ; c<3 ; c++ )
     2231        {
     2232          retval = fscanf( fic, "%d", &m_acLayerCfg[layer].m_colourRemapSEIPostLutNumValMinus1[c] );
     2233          if( m_acLayerCfg[layer].m_colourRemapSEIPostLutNumValMinus1[c]>0 )
     2234          {
     2235            m_acLayerCfg[layer].m_colourRemapSEIPostLutCodedValue[c]  = new Int[m_acLayerCfg[layer].m_colourRemapSEIPostLutNumValMinus1[c]+1];
     2236            m_acLayerCfg[layer].m_colourRemapSEIPostLutTargetValue[c] = new Int[m_acLayerCfg[layer].m_colourRemapSEIPostLutNumValMinus1[c]+1];
     2237            for( Int i=0 ; i<=m_acLayerCfg[layer].m_colourRemapSEIPostLutNumValMinus1[c] ; i++ )
     2238            {
     2239              retval = fscanf( fic, "%d", &m_acLayerCfg[layer].m_colourRemapSEIPostLutCodedValue[c][i] );
     2240              retval = fscanf( fic, "%d", &m_acLayerCfg[layer].m_colourRemapSEIPostLutTargetValue[c][i] );
     2241            }
     2242          }
     2243        }
     2244      }
     2245
     2246      fclose( fic );
     2247      if( retval != 1 )
     2248      {
     2249        fprintf(stderr, "Error while reading Colour Remapping Information SEI parameters file\n");
     2250        exit(EXIT_FAILURE);
     2251      }
     2252    }
     2253  }
     2254#endif
     2255#endif
    16312256#if N0383_IL_CONSTRAINED_TILE_SETS_SEI
    16322257  if (m_interLayerConstrainedTileSetsSEIEnabled)
    16332258  {
    1634     if (m_iNumColumnsMinus1 == 0 && m_iNumRowsMinus1 == 0)
     2259    if (m_numTileColumnsMinus1 == 0 && m_numTileRowsMinus1 == 0)
    16352260    {
    16362261      printf( "Tiles are not defined (needed for inter-layer comnstrained tile sets SEI).\n" );
     
    16712296    }
    16722297    m_skippedTileSetPresentFlag = false;
     2298
     2299    if( pTileSets )
     2300    {
     2301      free( pTileSets );
     2302      pTileSets = NULL;
     2303    }
    16732304  }
    16742305#endif
     
    18372468  }
    18382469 
    1839   Bool tileFlag = (m_iNumColumnsMinus1 > 0 || m_iNumRowsMinus1 > 0 );
     2470#if !SVC_EXTENSION
     2471  Bool tileFlag = (m_numTileColumnsMinus1 > 0 || m_numTileRowsMinus1 > 0 );
    18402472  xConfirmPara( tileFlag && m_iWaveFrontSynchro,            "Tile and Wavefront can not be applied together");
    18412473
    18422474  //TODO:ChromaFmt assumes 4:2:0 below
    1843 #if !SVC_EXTENSION
    18442475  xConfirmPara( m_iSourceWidth  % TComSPS::getWinUnitX(CHROMA_420) != 0, "Picture width must be an integer multiple of the specified chroma subsampling");
    18452476  xConfirmPara( m_iSourceHeight % TComSPS::getWinUnitY(CHROMA_420) != 0, "Picture height must be an integer multiple of the specified chroma subsampling");
     
    18482479  xConfirmPara( m_aiPad[1] % TComSPS::getWinUnitY(CHROMA_420) != 0, "Vertical padding must be an integer multiple of the specified chroma subsampling");
    18492480
    1850   xConfirmPara( m_confLeft   % TComSPS::getWinUnitX(CHROMA_420) != 0, "Left conformance window offset must be an integer multiple of the specified chroma subsampling");
    1851   xConfirmPara( m_confRight  % TComSPS::getWinUnitX(CHROMA_420) != 0, "Right conformance window offset must be an integer multiple of the specified chroma subsampling");
    1852   xConfirmPara( m_confTop    % TComSPS::getWinUnitY(CHROMA_420) != 0, "Top conformance window offset must be an integer multiple of the specified chroma subsampling");
    1853   xConfirmPara( m_confBottom % TComSPS::getWinUnitY(CHROMA_420) != 0, "Bottom conformance window offset must be an integer multiple of the specified chroma subsampling");
     2481  xConfirmPara( m_confWinLeft   % TComSPS::getWinUnitX(CHROMA_420) != 0, "Left conformance window offset must be an integer multiple of the specified chroma subsampling");
     2482  xConfirmPara( m_confWinRight  % TComSPS::getWinUnitX(CHROMA_420) != 0, "Right conformance window offset must be an integer multiple of the specified chroma subsampling");
     2483  xConfirmPara( m_confWinTop    % TComSPS::getWinUnitY(CHROMA_420) != 0, "Top conformance window offset must be an integer multiple of the specified chroma subsampling");
     2484  xConfirmPara( m_confWinBottom % TComSPS::getWinUnitY(CHROMA_420) != 0, "Bottom conformance window offset must be an integer multiple of the specified chroma subsampling");
     2485
     2486  xConfirmPara( m_defaultDisplayWindowFlag && !m_vuiParametersPresentFlag, "VUI needs to be enabled for default display window");
     2487
     2488  if (m_defaultDisplayWindowFlag)
     2489  {
     2490    xConfirmPara( m_defDispWinLeftOffset   % TComSPS::getWinUnitX(CHROMA_420) != 0, "Left default display window offset must be an integer multiple of the specified chroma subsampling");
     2491    xConfirmPara( m_defDispWinRightOffset  % TComSPS::getWinUnitX(CHROMA_420) != 0, "Right default display window offset must be an integer multiple of the specified chroma subsampling");
     2492    xConfirmPara( m_defDispWinTopOffset    % TComSPS::getWinUnitY(CHROMA_420) != 0, "Top default display window offset must be an integer multiple of the specified chroma subsampling");
     2493    xConfirmPara( m_defDispWinBottomOffset % TComSPS::getWinUnitY(CHROMA_420) != 0, "Bottom default display window offset must be an integer multiple of the specified chroma subsampling");
     2494  }
    18542495#endif
    18552496
     
    19552596 
    19562597  // it can be updated after AVC BL support will be added to the WD
     2598#if VPS_AVC_BL_FLAG_REMOVAL
     2599  if( m_nonHEVCBaseLayerFlag )
     2600#else
    19572601  if( m_avcBaseLayerFlag )
     2602#endif
    19582603  {
    19592604    m_crossLayerIrapAlignFlag = false;
     
    25933238    Int m_uiMaxCUHeight = m_acLayerCfg[layer].m_uiMaxCUHeight;
    25943239#endif
    2595 #endif
     3240
     3241    Bool tileFlag = (m_numTileColumnsMinus1 > 0 || m_numTileRowsMinus1 > 0 );
     3242    Int m_iWaveFrontSynchro = m_acLayerCfg[layer].m_waveFrontSynchro;
     3243    xConfirmPara( tileFlag && m_iWaveFrontSynchro,            "Tile and Wavefront can not be applied together");
     3244#endif
     3245
    25963246  if(m_vuiParametersPresentFlag && m_bitstreamRestrictionFlag)
    25973247  {
     
    26033253      Int widthInCU = (m_iSourceWidth % m_uiMaxCUWidth) ? m_iSourceWidth/m_uiMaxCUWidth + 1: m_iSourceWidth/m_uiMaxCUWidth;
    26043254      Int heightInCU = (m_iSourceHeight % m_uiMaxCUHeight) ? m_iSourceHeight/m_uiMaxCUHeight + 1: m_iSourceHeight/m_uiMaxCUHeight;
    2605       if(m_iUniformSpacingIdr)
    2606       {
    2607         maxTileWidth = m_uiMaxCUWidth*((widthInCU+m_iNumColumnsMinus1)/(m_iNumColumnsMinus1+1));
    2608         maxTileHeight = m_uiMaxCUHeight*((heightInCU+m_iNumRowsMinus1)/(m_iNumRowsMinus1+1));
     3255      if(m_tileUniformSpacingFlag)
     3256      {
     3257        maxTileWidth = m_uiMaxCUWidth*((widthInCU+m_numTileColumnsMinus1)/(m_numTileColumnsMinus1+1));
     3258        maxTileHeight = m_uiMaxCUHeight*((heightInCU+m_numTileRowsMinus1)/(m_numTileRowsMinus1+1));
    26093259        // if only the last tile-row is one treeblock higher than the others
    26103260        // the maxTileHeight becomes smaller if the last row of treeblocks has lower height than the others
    2611         if(!((heightInCU-1)%(m_iNumRowsMinus1+1)))
     3261        if(!((heightInCU-1)%(m_numTileRowsMinus1+1)))
    26123262        {
    26133263          maxTileHeight = maxTileHeight - m_uiMaxCUHeight + (m_iSourceHeight % m_uiMaxCUHeight);
     
    26153265        // if only the last tile-column is one treeblock wider than the others
    26163266        // the maxTileWidth becomes smaller if the last column of treeblocks has lower width than the others   
    2617         if(!((widthInCU-1)%(m_iNumColumnsMinus1+1)))
     3267        if(!((widthInCU-1)%(m_numTileColumnsMinus1+1)))
    26183268        {
    26193269          maxTileWidth = maxTileWidth - m_uiMaxCUWidth + (m_iSourceWidth % m_uiMaxCUWidth);
     
    26223272      else // not uniform spacing
    26233273      {
    2624         if(m_iNumColumnsMinus1<1)
     3274        if(m_numTileColumnsMinus1<1)
    26253275        {
    26263276          maxTileWidth = m_iSourceWidth;
     
    26293279        {
    26303280          Int accColumnWidth = 0;
    2631           for(Int col=0; col<(m_iNumColumnsMinus1); col++)
     3281          for(Int col=0; col<(m_numTileColumnsMinus1); col++)
    26323282          {
    2633             maxTileWidth = m_pColumnWidth[col]>maxTileWidth ? m_pColumnWidth[col]:maxTileWidth;
    2634             accColumnWidth += m_pColumnWidth[col];
     3283            maxTileWidth = m_tileColumnWidth[col]>maxTileWidth ? m_tileColumnWidth[col]:maxTileWidth;
     3284            accColumnWidth += m_tileColumnWidth[col];
    26353285          }
    26363286          maxTileWidth = (widthInCU-accColumnWidth)>maxTileWidth ? m_uiMaxCUWidth*(widthInCU-accColumnWidth):m_uiMaxCUWidth*maxTileWidth;
    26373287        }
    2638         if(m_iNumRowsMinus1<1)
     3288        if(m_numTileRowsMinus1<1)
    26393289        {
    26403290          maxTileHeight = m_iSourceHeight;
     
    26433293        {
    26443294          Int accRowHeight = 0;
    2645           for(Int row=0; row<(m_iNumRowsMinus1); row++)
     3295          for(Int row=0; row<(m_numTileRowsMinus1); row++)
    26463296          {
    2647             maxTileHeight = m_pRowHeight[row]>maxTileHeight ? m_pRowHeight[row]:maxTileHeight;
    2648             accRowHeight += m_pRowHeight[row];
     3297            maxTileHeight = m_tileRowHeight[row]>maxTileHeight ? m_tileRowHeight[row]:maxTileHeight;
     3298            accRowHeight += m_tileRowHeight[row];
    26493299          }
    26503300          maxTileHeight = (heightInCU-accRowHeight)>maxTileHeight ? m_uiMaxCUHeight*(heightInCU-accRowHeight):m_uiMaxCUHeight*maxTileHeight;
     
    26703320  }
    26713321#endif
     3322#if !SVC_EXTENSION
    26723323  xConfirmPara( m_iWaveFrontSynchro < 0, "WaveFrontSynchro cannot be negative" );
    2673 #if !SVC_EXTENSION
    26743324  xConfirmPara( m_iWaveFrontSubstreams <= 0, "WaveFrontSubstreams must be positive" );
    26753325  xConfirmPara( m_iWaveFrontSubstreams > 1 && !m_iWaveFrontSynchro, "Must have WaveFrontSynchro > 0 in order to have WaveFrontSubstreams > 1" );
     
    27033353  }
    27043354#endif
     3355#if Q0074_COLOUR_REMAPPING_SEI
     3356#if !SVC_EXTENSION
     3357  if ( ( m_colourRemapSEIFile.size() > 0 ) && !m_colourRemapSEICancelFlag )
     3358  {
     3359    xConfirmPara( m_colourRemapSEIInputBitDepth < 8 || m_colourRemapSEIInputBitDepth > 16 , "colour_remap_input_bit_depth shall be in the range of 8 to 16, inclusive");
     3360    xConfirmPara( m_colourRemapSEIBitDepth < 8 || m_colourRemapSEIBitDepth > 16, "colour_remap_bit_depth shall be in the range of 8 to 16, inclusive");
     3361    for( Int c=0 ; c<3 ; c++)
     3362    {
     3363      xConfirmPara( m_colourRemapSEIPreLutNumValMinus1[c] < 0 || m_colourRemapSEIPreLutNumValMinus1[c] > 32, "pre_lut_num_val_minus1[c] shall be in the range of 0 to 32, inclusive");
     3364      if( m_colourRemapSEIPreLutNumValMinus1[c]>0 )
     3365        for( Int i=0 ; i<=m_colourRemapSEIPreLutNumValMinus1[c] ; i++)
     3366        {
     3367          xConfirmPara( m_colourRemapSEIPreLutCodedValue[c][i] < 0 || m_colourRemapSEIPreLutCodedValue[c][i] > ((1<<m_colourRemapSEIInputBitDepth)-1), "pre_lut_coded_value[c][i] shall be in the range of 0 to (1<<colour_remap_input_bit_depth)-1, inclusive");
     3368          xConfirmPara( m_colourRemapSEIPreLutTargetValue[c][i] < 0 || m_colourRemapSEIPreLutTargetValue[c][i] > ((1<<m_colourRemapSEIBitDepth)-1), "pre_lut_target_value[c][i] shall be in the range of 0 to (1<<colour_remap_bit_depth)-1, inclusive");
     3369        }
     3370      xConfirmPara( m_colourRemapSEIPostLutNumValMinus1[c] < 0 || m_colourRemapSEIPostLutNumValMinus1[c] > 32, "post_lut_num_val_minus1[c] shall be in the range of 0 to 32, inclusive");
     3371      if( m_colourRemapSEIPostLutNumValMinus1[c]>0 )
     3372        for( Int i=0 ; i<=m_colourRemapSEIPostLutNumValMinus1[c] ; i++)
     3373        {
     3374          xConfirmPara( m_colourRemapSEIPostLutCodedValue[c][i] < 0 || m_colourRemapSEIPostLutCodedValue[c][i] > ((1<<m_colourRemapSEIBitDepth)-1), "post_lut_coded_value[c][i] shall be in the range of 0 to (1<<colour_remap_bit_depth)-1, inclusive");
     3375          xConfirmPara( m_colourRemapSEIPostLutTargetValue[c][i] < 0 || m_colourRemapSEIPostLutTargetValue[c][i] > ((1<<m_colourRemapSEIBitDepth)-1), "post_lut_target_value[c][i] shall be in the range of 0 to (1<<colour_remap_bit_depth)-1, inclusive");
     3376        }
     3377    }
     3378    if ( m_colourRemapSEIMatrixPresentFlag )
     3379    {
     3380      xConfirmPara( m_colourRemapSEILog2MatrixDenom < 0 || m_colourRemapSEILog2MatrixDenom > 15, "log2_matrix_denom shall be in the range of 0 to 15, inclusive");
     3381      for( Int c=0 ; c<3 ; c++)
     3382        for( Int i=0 ; i<3 ; i++)
     3383          xConfirmPara( m_colourRemapSEICoeffs[c][i] < -32768 || m_colourRemapSEICoeffs[c][i] > 32767, "colour_remap_coeffs[c][i] shall be in the range of -32768 and 32767, inclusive");
     3384    }
     3385  }
     3386#endif
     3387#endif
    27053388
    27063389#if RC_SHVC_HARMONIZATION
     
    29093592  printf("Scalable                      : %d\n", m_scalabilityMask[SCALABILITY_ID] );
    29103593#if AVC_BASE
     3594#if VPS_AVC_BL_FLAG_REMOVAL
     3595  printf("Base layer                    : %s\n", m_nonHEVCBaseLayerFlag ? "Non-HEVC" : "HEVC");
     3596#else
    29113597  printf("Base layer                    : %s\n", m_avcBaseLayerFlag ? "AVC" : "HEVC");
     3598#endif
    29123599#endif
    29133600#if AUXILIARY_PICTURES
     
    29333620  {
    29343621    printf("=== Layer %d settings === \n", layer);
    2935 #if AVC_SYNTAX
    2936     m_acLayerCfg[layer].xPrintParameter( layer );
    2937 #else
    29383622    m_acLayerCfg[layer].xPrintParameter();
    2939 #endif
    29403623    printf("\n");
    29413624  }
    29423625  printf("=== Common configuration settings === \n");
    29433626  printf("Bitstream      File          : %s\n", m_pBitstreamFile      );
    2944 #else
     3627#else //SVC_EXTENSION
    29453628  printf("Input          File          : %s\n", m_pchInputFile          );
    29463629  printf("Bitstream      File          : %s\n", m_pchBitstreamFile      );
    29473630  printf("Reconstruction File          : %s\n", m_pchReconFile          );
    2948   printf("Real     Format              : %dx%d %dHz\n", m_iSourceWidth - m_confLeft - m_confRight, m_iSourceHeight - m_confTop - m_confBottom, m_iFrameRate );
     3631  printf("Real     Format              : %dx%d %dHz\n", m_iSourceWidth - m_confWinLeft - m_confWinRight, m_iSourceHeight - m_confWinTop - m_confWinBottom, m_iFrameRate );
    29493632  printf("Internal Format              : %dx%d %dHz\n", m_iSourceWidth, m_iSourceHeight, m_iFrameRate );
    2950 #endif
     3633#endif //SVC_EXTENSION
    29513634  if (m_isField)
    29523635  {
     
    30843767  printf("CGS: %d CGSMaxOctantDepth: %d CGSMaxYPartNumLog2: %d CGSLUTBit:%d " , m_nCGSFlag , m_nCGSMaxOctantDepth , m_nCGSMaxYPartNumLog2 , m_nCGSLUTBit );
    30853768#endif
     3769#if R0151_CGS_3D_ASYMLUT_IMPROVE
     3770  printf("CGSAdaptC:%d " , m_nCGSAdaptiveChroma );
     3771#endif
     3772#if R0179_ENC_OPT_3DLUT_SIZE
     3773  printf("CGSSizeRDO:%d " , m_nCGSLutSizeRDO );
     3774#endif
     3775
    30863776  printf("\n\n");
    30873777 
     
    30993789
    31003790#if SVC_EXTENSION
     3791#if OUTPUT_LAYER_SETS_CONFIG
     3792Void TAppEncCfg::cfgStringToArray(Int **arr, string const cfgString, Int const numEntries, const char* logString)
     3793#else
    31013794Void TAppEncCfg::cfgStringToArray(Int **arr, string cfgString, Int numEntries, const char* logString)
     3795#endif
    31023796{
    31033797  Char *tempChar = cfgString.empty() ? NULL : strdup(cfgString.c_str());
     
    31083802    *arr = new Int[numEntries];
    31093803
     3804#if OUTPUT_LAYER_SETS_CONFIG
     3805    if( tempChar == NULL )
     3806    {
     3807      arrayEntry = NULL;
     3808    }
     3809    else
     3810    {
     3811      arrayEntry = strtok( tempChar, " ,");
     3812    }
     3813#else
    31103814    arrayEntry = strtok( tempChar, " ,");
     3815#endif
    31113816    while(arrayEntry != NULL)
    31123817    {
     
    31303835    *arr = NULL;
    31313836  }
     3837
     3838  if( tempChar )
     3839  {
     3840    free( tempChar );
     3841    tempChar = NULL;
     3842  }
    31323843}
    31333844
     3845#if OUTPUT_LAYER_SETS_CONFIG
     3846Bool TAppEncCfg::scanStringToArray(string const cfgString, Int const numEntries, const char* logString, Int * const returnArray)
     3847{
     3848  Int *tempArray = NULL;
     3849  // For all layer sets
     3850  cfgStringToArray( &tempArray, cfgString, numEntries, logString );
     3851  if(tempArray)
     3852  {
     3853    for(Int i = 0; i < numEntries; i++)
     3854    {
     3855      returnArray[i] = tempArray[i];
     3856    }
     3857    delete [] tempArray; tempArray = NULL;
     3858    return true;
     3859  }
     3860  return false;
     3861}
     3862Bool TAppEncCfg::scanStringToArray(string const cfgString, Int const numEntries, const char* logString, std::vector<Int> & returnVector)
     3863{
     3864  Int *tempArray = NULL;
     3865  // For all layer sets
     3866  cfgStringToArray( &tempArray, cfgString, numEntries, logString );
     3867  if(tempArray)
     3868  {
     3869    returnVector.empty();
     3870    for(Int i = 0; i < numEntries; i++)
     3871    {
     3872      returnVector.push_back(tempArray[i]);
     3873    }
     3874    delete [] tempArray; tempArray = NULL;
     3875    return true;
     3876  }
     3877  return false;
     3878}
     3879#endif
    31343880#endif //SVC_EXTENSION
    31353881//! \}
  • trunk/source/App/TAppEncoder/TAppEncCfg.h

    r815 r906  
    4646#endif
    4747#include <sstream>
     48#include <vector>
    4849//! \ingroup TAppEncoder
    4950//! \{
     
    6869  Int       m_framesToBeEncoded;                              ///< number of encoded frames
    6970#if AVC_BASE
     71#if VPS_AVC_BL_FLAG_REMOVAL
     72  Int       m_nonHEVCBaseLayerFlag;                           ///< non HEVC BL
     73#else
    7074  Int       m_avcBaseLayerFlag;                               ///< avc_baselayer_flag
    7175#endif
    72 #if AVC_SYNTAX
    73   Char*     m_BLSyntaxFile;                                   ///< input syntax file
    7476#endif
    7577  Bool      m_maxTidRefPresentFlag;
     
    8183  Int       m_numHighestLayerIdx[MAX_VPS_LAYER_SETS_PLUS1];
    8284  Int       m_highestLayerIdx[MAX_VPS_LAYER_SETS_PLUS1][MAX_VPS_LAYER_ID_PLUS1];
     85#endif
     86#if OUTPUT_LAYER_SETS_CONFIG
     87  std::vector<Int>                m_outputLayerSetIdx;
     88  Int       m_defaultTargetOutputLayerIdc;
     89  Int       m_numOutputLayerSets;
     90  std::vector<Int>                m_numLayersInOutputLayerSet;
     91  std::vector< std::vector<Int> > m_listOfOutputLayers;
    8392#endif
    8493#else
     
    96105 
    97106 
    98   Int       m_conformanceMode;
    99   Int       m_confLeft;
    100   Int       m_confRight;
    101   Int       m_confTop;
    102   Int       m_confBottom;
     107  Int       m_conformanceWindowMode;
     108  Int       m_confWinLeft;
     109  Int       m_confWinRight;
     110  Int       m_confWinTop;
     111  Int       m_confWinBottom;
    103112  Int       m_framesToBeEncoded;                              ///< number of encoded frames
    104113  Int       m_aiPad[2];                                       ///< number of padded pixels for width and height
     
    222231  Bool      m_useRDOQ;                                       ///< flag for using RD optimized quantization
    223232  Bool      m_useRDOQTS;                                     ///< flag for using RD optimized quantization for transform skip
    224   Int      m_rdPenalty;                                      ///< RD-penalty for 32x32 TU for intra in non-intra slices (0: no RD-penalty, 1: RD-penalty, 2: maximum RD-penalty)
     233  Int       m_rdPenalty;                                      ///< RD-penalty for 32x32 TU for intra in non-intra slices (0: no RD-penalty, 1: RD-penalty, 2: maximum RD-penalty)
    225234  Int       m_iFastSearch;                                    ///< ME mode, 0 = full, 1 = diamond, 2 = PMVFAST
    226235  Int       m_iSearchRange;                                   ///< ME search range
     
    243252  Bool      m_bLFCrossSliceBoundaryFlag;  ///< 1: filter across slice boundaries 0: do not filter across slice boundaries
    244253  Bool      m_bLFCrossTileBoundaryFlag;   ///< 1: filter across tile boundaries  0: do not filter across tile boundaries
    245   Int       m_iUniformSpacingIdr;
    246   Int       m_iNumColumnsMinus1;
    247   Char*     m_pchColumnWidth;
    248   Int       m_iNumRowsMinus1;
    249   Char*     m_pchRowHeight;
    250   UInt*     m_pColumnWidth;
    251   UInt*     m_pRowHeight;
     254  Bool      m_tileUniformSpacingFlag;
     255  Int       m_numTileColumnsMinus1;
     256  Int       m_numTileRowsMinus1;
     257  std::vector<Int> m_tileColumnWidth;
     258  std::vector<Int> m_tileRowHeight;
     259#if !SVC_EXTENSION
    252260  Int       m_iWaveFrontSynchro; //< 0: no WPP. >= 1: WPP is enabled, the "Top right" from which inheritance occurs is this LCU offset in the line above the current.
    253 #if !SVC_EXTENSION
    254261  Int       m_iWaveFrontSubstreams; //< If iWaveFrontSynchro, this is the number of substreams per frame (dependent tiles) or per tile (independent tiles).
    255262#endif
    256 
    257263  Bool      m_bUseConstrainedIntraPred;                       ///< flag for using constrained intra prediction
    258  
    259264  Int       m_decodedPictureHashSEIEnabled;                    ///< Checksum(3)/CRC(2)/MD5(1)/disable(0) acting on decoded picture hash SEI message
    260265  Int       m_recoveryPointSEIEnabled;
     
    288293  Int*      m_codedPivotValue;
    289294  Int*      m_targetPivotValue;
    290 #if Q0074_SEI_COLOR_MAPPING
    291   Char*     m_pchSEIColorMappingFile;             ///< SEI Color Mapping File (initialized from external file)
    292 #endif
    293295  Int       m_framePackingSEIEnabled;
    294296  Int       m_framePackingSEIType;
     
    377379  Int       m_elRapSliceBEnabled;
    378380#endif
     381#if Q0074_COLOUR_REMAPPING_SEI
     382#if !SVC_EXTENSION
     383  string    m_colourRemapSEIFile;
     384  Int       m_colourRemapSEIId;
     385  Bool      m_colourRemapSEICancelFlag;
     386  Bool      m_colourRemapSEIPersistenceFlag;
     387  Bool      m_colourRemapSEIVideoSignalInfoPresentFlag;
     388  Bool      m_colourRemapSEIFullRangeFlag;
     389  Int       m_colourRemapSEIPrimaries;
     390  Int       m_colourRemapSEITransferFunction;
     391  Int       m_colourRemapSEIMatrixCoefficients;
     392  Int       m_colourRemapSEIInputBitDepth;
     393  Int       m_colourRemapSEIBitDepth;
     394  Int       m_colourRemapSEIPreLutNumValMinus1[3];
     395  Int*      m_colourRemapSEIPreLutCodedValue[3];
     396  Int*      m_colourRemapSEIPreLutTargetValue[3];
     397  Bool      m_colourRemapSEIMatrixPresentFlag;
     398  Int       m_colourRemapSEILog2MatrixDenom;
     399  Int       m_colourRemapSEICoeffs[3][3];
     400  Int       m_colourRemapSEIPostLutNumValMinus1[3];
     401  Int*      m_colourRemapSEIPostLutCodedValue[3];
     402  Int*      m_colourRemapSEIPostLutTargetValue[3];
     403#endif
     404#endif
    379405  // internal member functions
    380406#if LAYER_CTB
     
    439465  Int  m_nCGSMaxYPartNumLog2;
    440466  Int  m_nCGSLUTBit;
    441 #endif
     467#if R0151_CGS_3D_ASYMLUT_IMPROVE
     468  Int  m_nCGSAdaptiveChroma;
     469#endif
     470#if R0179_ENC_OPT_3DLUT_SIZE
     471  Int  m_nCGSLutSizeRDO;
     472#endif
     473#endif
    442474#endif //SVC_EXTENSION
    443475public:
     
    468500#endif
    469501  Int  getDecodingRefreshType()    {return m_iDecodingRefreshType; }
    470   Int  getWaveFrontSynchro()        { return m_iWaveFrontSynchro; }
     502  Int  getWaveFrontSynchro(Int layerId)        { return m_acLayerCfg[layerId].m_waveFrontSynchro; }
    471503  Void getDirFilename(string& filename, string& dir, const string path);
    472 #if AVC_SYNTAX
    473   Char* getBLSyntaxFile()           { return m_BLSyntaxFile;      }
    474 #endif
     504#if OUTPUT_LAYER_SETS_CONFIG
     505  Bool scanStringToArray(string const cfgString, Int const numEntries, const char* logString, Int * const returnArray);
     506  Bool scanStringToArray(string const cfgString, Int const numEntries, const char* logString, std::vector<Int> &  returnVector);
     507  Void cfgStringToArray(Int **arr, string const cfgString, Int const numEntries, const char* logString);
     508#else
    475509  Void cfgStringToArray(Int **arr, string cfgString, Int numEntries, const char* logString);
     510#endif
    476511#if REPN_FORMAT_IN_VPS
    477512  RepFormatCfg* getRepFormatCfg(Int i)  { return &m_repFormatCfg[i]; }
  • trunk/source/App/TAppEncoder/TAppEncLayerCfg.cpp

    r713 r906  
    4949, m_repFormatIdx (-1)
    5050#endif
    51 {
    52   m_confLeft = m_confRight = m_confTop = m_confBottom = 0;
     51#if Q0074_COLOUR_REMAPPING_SEI
     52,  m_colourRemapSEIFile(string(""))
     53#endif
     54{
     55#if Q0074_COLOUR_REMAPPING_SEI
     56  for( Int c=0 ; c<3 ; c++)
     57  {
     58    m_colourRemapSEIPreLutCodedValue[c]   = NULL;
     59    m_colourRemapSEIPreLutTargetValue[c]  = NULL;
     60    m_colourRemapSEIPostLutCodedValue[c]  = NULL;
     61    m_colourRemapSEIPostLutTargetValue[c] = NULL;
     62  }
     63#endif
     64  m_confWinLeft = m_confWinRight = m_confWinTop = m_confWinBottom = 0;
    5365  m_aiPad[1] = m_aiPad[0] = 0;
    5466  m_numScaledRefLayerOffsets = 0;
     
    6072  ::memset(m_scaledRefLayerRightOffset,  0, sizeof(m_scaledRefLayerRightOffset));
    6173  ::memset(m_scaledRefLayerBottomOffset, 0, sizeof(m_scaledRefLayerBottomOffset));
     74#if REF_REGION_OFFSET
     75  ::memset(m_scaledRefLayerOffsetPresentFlag, 0, sizeof(m_scaledRefLayerOffsetPresentFlag));
     76  ::memset(m_refRegionOffsetPresentFlag, 0, sizeof(m_refRegionOffsetPresentFlag));
     77  ::memset(m_refRegionLeftOffset,   0, sizeof(m_refRegionLeftOffset));
     78  ::memset(m_refRegionTopOffset,    0, sizeof(m_refRegionTopOffset));
     79  ::memset(m_refRegionRightOffset,  0, sizeof(m_refRegionRightOffset));
     80  ::memset(m_refRegionBottomOffset, 0, sizeof(m_refRegionBottomOffset));
     81#endif
     82#if R0209_GENERIC_PHASE
     83  ::memset(m_resamplePhaseSetPresentFlag, 0, sizeof(m_resamplePhaseSetPresentFlag));
     84  ::memset(m_phaseHorLuma,   0, sizeof(m_phaseHorLuma));
     85  ::memset(m_phaseVerLuma,   0, sizeof(m_phaseVerLuma));
     86  ::memset(m_phaseHorChroma, 0, sizeof(m_phaseHorChroma));
     87  ::memset(m_phaseVerChroma, 0, sizeof(m_phaseVerChroma));
     88#else
    6289#if P0312_VERT_PHASE_ADJ
    6390  ::memset(m_vertPhasePositionEnableFlag, 0, sizeof(m_vertPhasePositionEnableFlag));
    6491#endif
     92#endif
    6593}
    6694
     
    7199    delete[] m_aidQP;
    72100  }
     101#if Q0074_COLOUR_REMAPPING_SEI
     102  for( Int c=0 ; c<3 ; c++)
     103  {
     104    if ( m_colourRemapSEIPreLutCodedValue[c] )
     105    {
     106      delete[] m_colourRemapSEIPreLutCodedValue[c];
     107    }
     108    if ( m_colourRemapSEIPreLutTargetValue[c] )
     109    {
     110      delete[] m_colourRemapSEIPreLutTargetValue[c];
     111    }
     112    if ( m_colourRemapSEIPostLutCodedValue[c] )
     113    {
     114      delete[] m_colourRemapSEIPostLutCodedValue[c];
     115    }
     116    if ( m_colourRemapSEIPostLutTargetValue[c] )
     117    {
     118      delete[] m_colourRemapSEIPostLutTargetValue[c];
     119    }
     120  }
     121#endif
    73122}
    74123
     
    98147  Int tmpInputChromaFormat;
    99148  Int tmpChromaFormat;
     149#endif
     150#if Q0074_COLOUR_REMAPPING_SEI
     151  string  cfg_colourRemapSEIFile;
    100152#endif
    101153
     
    114166    ("ChromaFormatIDC",       tmpChromaFormat,    420, "ChromaFormatIDC (400|420|422|444 or set 0 (default) for same as InputChromaFormat)")
    115167#endif
    116     ("CropLeft",              m_confLeft,      0, "Left cropping/padding for cropping mode 3")
    117     ("CropRight",             m_confRight,     0, "Right cropping/padding for cropping mode 3")
    118     ("CropTop",               m_confTop,       0, "Top cropping/padding for cropping mode 3")
    119     ("CropBottom",            m_confBottom,    0, "Bottom cropping/padding for cropping mode 3")
     168    ("ConfLeft",              m_confWinLeft,            0, "Deprecated alias of ConfWinLeft")
     169    ("ConfRight",             m_confWinRight,           0, "Deprecated alias of ConfWinRight")
     170    ("ConfTop",               m_confWinTop,             0, "Deprecated alias of ConfWinTop")
     171    ("ConfBottom",            m_confWinBottom,          0, "Deprecated alias of ConfWinBottom")
     172    ("ConfWinLeft",           m_confWinLeft,            0, "Left offset for window conformance mode 3")
     173    ("ConfWinRight",          m_confWinRight,           0, "Right offset for window conformance mode 3")
     174    ("ConfWinTop",            m_confWinTop,             0, "Top offset for window conformance mode 3")
     175    ("ConfWinBottom",         m_confWinBottom,          0, "Bottom offset for window conformance mode 3")
    120176    ("HorizontalPadding,-pdx",m_aiPad[0],      0, "horizontal source padding for cropping mode 2")
    121177    ("VerticalPadding,-pdy",  m_aiPad[1],      0, "vertical source padding for cropping mode 2")
     
    124180    ("dQPFile,m",             cfg_dQPFile, string(""), "dQP file name")
    125181    ("QP,q",                  m_fQP,          30.0, "Qp value, if value is float, QP is switched once during encoding")
    126     ;
     182#if Q0074_COLOUR_REMAPPING_SEI
     183    ("SEIColourRemappingInfoFile", cfg_colourRemapSEIFile, string(""), "Colour Remapping Information SEI parameters file name")
     184#endif
     185  ;
    127186
    128187  po::setDefaults(opts);
     
    136195  m_chromaFormatIDC   = ((tmpChromaFormat == 0) ? (m_InputChromaFormat) : (numberToChromaFormat(tmpChromaFormat)));
    137196#endif
     197#if Q0074_COLOUR_REMAPPING_SEI
     198  m_colourRemapSEIFile = cfg_colourRemapSEIFile.empty() ? NULL : strdup(cfg_colourRemapSEIFile.c_str());
     199#endif
    138200
    139201  // reading external dQP description from file
     
    154216    }
    155217  }
     218
     219#if Q0074_COLOUR_REMAPPING_SEI
     220  if( m_colourRemapSEIFile.size() > 0 )
     221  {
     222    FILE* fic;
     223    Int retval;
     224    if((fic = fopen(m_colourRemapSEIFile.c_str(),"r")) == (FILE*)NULL)
     225    {
     226      fprintf(stderr, "Can't open Colour Remapping Information SEI parameters file %s\n", m_colourRemapSEIFile.c_str());
     227      exit(EXIT_FAILURE);
     228    }
     229
     230    Int tempCode;
     231    retval = fscanf( fic, "%d", &m_colourRemapSEIId );
     232    retval = fscanf( fic, "%d", &tempCode );m_colourRemapSEICancelFlag = tempCode ? 1 : 0;
     233    if( !m_colourRemapSEICancelFlag )
     234    {
     235      retval = fscanf( fic, "%d", &tempCode );m_colourRemapSEIPersistenceFlag = tempCode ? 1 : 0;
     236      retval = fscanf( fic, "%d", &tempCode );m_colourRemapSEIVideoSignalInfoPresentFlag = tempCode ? 1 : 0;
     237      if( m_colourRemapSEIVideoSignalInfoPresentFlag )
     238      {
     239        retval = fscanf( fic, "%d", &tempCode );m_colourRemapSEIFullRangeFlag = tempCode ? 1 : 0;
     240        retval = fscanf( fic, "%d", &m_colourRemapSEIPrimaries );
     241        retval = fscanf( fic, "%d", &m_colourRemapSEITransferFunction );
     242        retval = fscanf( fic, "%d", &m_colourRemapSEIMatrixCoefficients );
     243      }
     244
     245      retval = fscanf( fic, "%d", &m_colourRemapSEIInputBitDepth );
     246      retval = fscanf( fic, "%d", &m_colourRemapSEIBitDepth );
     247 
     248      for( Int c=0 ; c<3 ; c++ )
     249      {
     250        retval = fscanf( fic, "%d", &m_colourRemapSEIPreLutNumValMinus1[c] );
     251        if( m_colourRemapSEIPreLutNumValMinus1[c]>0 )
     252        {
     253          m_colourRemapSEIPreLutCodedValue[c]  = new Int[m_colourRemapSEIPreLutNumValMinus1[c]+1];
     254          m_colourRemapSEIPreLutTargetValue[c] = new Int[m_colourRemapSEIPreLutNumValMinus1[c]+1];
     255          for( Int i=0 ; i<=m_colourRemapSEIPreLutNumValMinus1[c] ; i++ )
     256          {
     257            retval = fscanf( fic, "%d", &m_colourRemapSEIPreLutCodedValue[c][i] );
     258            retval = fscanf( fic, "%d", &m_colourRemapSEIPreLutTargetValue[c][i] );
     259          }
     260        }
     261      }
     262
     263      retval = fscanf( fic, "%d", &tempCode );m_colourRemapSEIMatrixPresentFlag = tempCode ? 1 : 0;
     264      if( m_colourRemapSEIMatrixPresentFlag )
     265      {
     266        retval = fscanf( fic, "%d", &m_colourRemapSEILog2MatrixDenom );
     267        for( Int c=0 ; c<3 ; c++ )
     268          for( Int i=0 ; i<3 ; i++ )
     269            retval = fscanf( fic, "%d", &m_colourRemapSEICoeffs[c][i] );
     270      }
     271
     272      for( Int c=0 ; c<3 ; c++ )
     273      {
     274        retval = fscanf( fic, "%d", &m_colourRemapSEIPostLutNumValMinus1[c] );
     275        if( m_colourRemapSEIPostLutNumValMinus1[c]>0 )
     276        {
     277          m_colourRemapSEIPostLutCodedValue[c]  = new Int[m_colourRemapSEIPostLutNumValMinus1[c]+1];
     278          m_colourRemapSEIPostLutTargetValue[c] = new Int[m_colourRemapSEIPostLutNumValMinus1[c]+1];
     279          for( Int i=0 ; i<=m_colourRemapSEIPostLutNumValMinus1[c] ; i++ )
     280          {
     281            retval = fscanf( fic, "%d", &m_colourRemapSEIPostLutCodedValue[c][i] );
     282            retval = fscanf( fic, "%d", &m_colourRemapSEIPostLutTargetValue[c][i] );
     283          }
     284        }
     285      }
     286    }
     287
     288    fclose( fic );
     289    if( retval != 1 )
     290    {
     291      fprintf(stderr, "Error while reading Colour Remapping Information SEI parameters file\n");
     292      exit(EXIT_FAILURE);
     293    }
     294  }
     295#endif
     296
    156297  return true;
    157298}
    158299
    159 #if AVC_SYNTAX
    160 Void TAppEncLayerCfg::xPrintParameter( UInt layerId )
    161 #else
    162300Void TAppEncLayerCfg::xPrintParameter()
    163 #endif
    164301{
    165302  printf("Input File                    : %s\n", m_cInputFile.c_str()  );
    166303  printf("Reconstruction File           : %s\n", m_cReconFile.c_str()  );
    167 #if AVC_SYNTAX
    168   if( layerId == 0 )
    169   {
    170     printf("Base layer syntax file        : %s\n", m_cAppEncCfg->getBLSyntaxFile() );
    171   }
    172 #endif
    173304#if REPN_FORMAT_IN_VPS
    174   printf("Real     Format               : %dx%d %dHz\n", m_iSourceWidth - ( m_confLeft + m_confRight ) * TComSPS::getWinUnitX( m_chromaFormatIDC ), m_iSourceHeight - ( m_confTop + m_confBottom ) * TComSPS::getWinUnitY( m_chromaFormatIDC ), m_iFrameRate );
     305  printf("Real     Format               : %dx%d %dHz\n", m_iSourceWidth - ( m_confWinLeft + m_confWinRight ) * TComSPS::getWinUnitX( m_chromaFormatIDC ), m_iSourceHeight - ( m_confWinTop + m_confWinBottom ) * TComSPS::getWinUnitY( m_chromaFormatIDC ), m_iFrameRate );
    175306#else
    176   printf("Real     Format               : %dx%d %dHz\n", m_iSourceWidth - m_confLeft - m_confRight, m_iSourceHeight - m_confTop - m_confBottom, m_iFrameRate );
     307  printf("Real     Format               : %dx%d %dHz\n", m_iSourceWidth - m_confWinLeft - m_confWinRight, m_iSourceHeight - m_confWinTop - m_confWinBottom, m_iFrameRate );
    177308#endif
    178309  printf("Internal Format               : %dx%d %dHz\n", m_iSourceWidth, m_iSourceHeight, m_iFrameRate );
     
    202333  }
    203334#endif
    204   printf("WaveFrontSynchro:%d WaveFrontSubstreams:%d", m_cAppEncCfg->getWaveFrontSynchro(), m_iWaveFrontSubstreams);
     335  printf("WaveFrontSynchro:%d WaveFrontSubstreams:%d", m_waveFrontSynchro, m_iWaveFrontSubstreams);
    205336#if LAYER_CTB
    206337  printf("PCM:%d ", (m_cAppEncCfg->getUsePCM() && (1<<m_cAppEncCfg->getPCMLog2MinSize()) <= m_uiMaxCUWidth)? 1 : 0);
     
    217348    {
    218349      // no cropping or padding
    219       m_confLeft = m_confRight = m_confTop = m_confBottom = 0;
     350      m_confWinLeft = m_confWinRight = m_confWinTop = m_confWinBottom = 0;
    220351      m_aiPad[1] = m_aiPad[0] = 0;
    221352      break;
     
    231362      if (m_iSourceWidth % minCuSize)
    232363      {
    233         m_aiPad[0] = m_confRight  = ((m_iSourceWidth / minCuSize) + 1) * minCuSize - m_iSourceWidth;
    234         m_iSourceWidth  += m_confRight;
     364        m_aiPad[0] = m_confWinRight  = ((m_iSourceWidth / minCuSize) + 1) * minCuSize - m_iSourceWidth;
     365        m_iSourceWidth  += m_confWinRight;
    235366#if REPN_FORMAT_IN_VPS
    236         m_confRight /= TComSPS::getWinUnitX( m_chromaFormatIDC );
     367        m_confWinRight /= TComSPS::getWinUnitX( m_chromaFormatIDC );
    237368#endif
    238369      }
    239370      if (m_iSourceHeight % minCuSize)
    240371      {
    241         m_aiPad[1] = m_confBottom = ((m_iSourceHeight / minCuSize) + 1) * minCuSize - m_iSourceHeight;
    242         m_iSourceHeight += m_confBottom;
     372        m_aiPad[1] = m_confWinBottom = ((m_iSourceHeight / minCuSize) + 1) * minCuSize - m_iSourceHeight;
     373        m_iSourceHeight += m_confWinBottom;
    243374        if ( isField )
    244375        {
    245           m_iSourceHeightOrg += m_confBottom << 1;
    246           m_aiPad[1] = m_confBottom << 1;
     376          m_iSourceHeightOrg += m_confWinBottom << 1;
     377          m_aiPad[1] = m_confWinBottom << 1;
    247378        }
    248379#if REPN_FORMAT_IN_VPS
    249         m_confBottom /= TComSPS::getWinUnitY( m_chromaFormatIDC );
     380        m_confWinBottom /= TComSPS::getWinUnitY( m_chromaFormatIDC );
    250381#endif
    251382      }
     
    257388      m_iSourceWidth  += m_aiPad[0];
    258389      m_iSourceHeight += m_aiPad[1];
    259       m_confRight  = m_aiPad[0];
    260       m_confBottom = m_aiPad[1];
     390      m_confWinRight  = m_aiPad[0];
     391      m_confWinBottom = m_aiPad[1];
    261392#if REPN_FORMAT_IN_VPS
    262       m_confRight /= TComSPS::getWinUnitX( m_chromaFormatIDC );
    263       m_confBottom /= TComSPS::getWinUnitY( m_chromaFormatIDC );
     393      m_confWinRight /= TComSPS::getWinUnitX( m_chromaFormatIDC );
     394      m_confWinBottom /= TComSPS::getWinUnitY( m_chromaFormatIDC );
    264395#endif
    265396      break;
     
    268399    {
    269400      // conformance
    270       if ((m_confLeft == 0) && (m_confRight == 0) && (m_confTop == 0) && (m_confBottom == 0))
     401      if ((m_confWinLeft == 0) && (m_confWinRight == 0) && (m_confWinTop == 0) && (m_confWinBottom == 0))
    271402      {
    272403        fprintf(stderr, "Warning: Cropping enabled, but all cropping parameters set to zero\n");
     
    333464#endif
    334465
    335 
    336   m_iWaveFrontSubstreams = m_cAppEncCfg->getWaveFrontSynchro() ? (m_iSourceHeight + maxCUHeight - 1) / maxCUHeight : 1;
     466  m_iWaveFrontSubstreams = m_waveFrontSynchro ? (m_iSourceHeight + maxCUHeight - 1) / maxCUHeight : 1;
     467  xConfirmPara( m_waveFrontSynchro < 0, "WaveFrontSynchro cannot be negative" );
    337468  xConfirmPara( m_iWaveFrontSubstreams <= 0, "WaveFrontSubstreams must be positive" );
    338   xConfirmPara( m_iWaveFrontSubstreams > 1 && !m_cAppEncCfg->getWaveFrontSynchro(), "Must have WaveFrontSynchro > 0 in order to have WaveFrontSubstreams > 1" );
     469  xConfirmPara( m_iWaveFrontSubstreams > 1 && !m_waveFrontSynchro, "Must have WaveFrontSynchro > 0 in order to have WaveFrontSubstreams > 1" );
    339470
    340471  //chekc parameters
     
    386517  }
    387518#endif
     519#if Q0074_COLOUR_REMAPPING_SEI
     520  if ( ( m_colourRemapSEIFile.size() > 0 ) && !m_colourRemapSEICancelFlag )
     521  {
     522    xConfirmPara( m_colourRemapSEIInputBitDepth < 8 || m_colourRemapSEIInputBitDepth > 16 , "colour_remap_input_bit_depth shall be in the range of 8 to 16, inclusive");
     523    xConfirmPara( m_colourRemapSEIBitDepth < 8 || m_colourRemapSEIBitDepth > 16, "colour_remap_bit_depth shall be in the range of 8 to 16, inclusive");
     524    for( Int c=0 ; c<3 ; c++)
     525    {
     526      xConfirmPara( m_colourRemapSEIPreLutNumValMinus1[c] < 0 || m_colourRemapSEIPreLutNumValMinus1[c] > 32, "pre_lut_num_val_minus1[c] shall be in the range of 0 to 32, inclusive");
     527      if( m_colourRemapSEIPreLutNumValMinus1[c]>0 )
     528        for( Int i=0 ; i<=m_colourRemapSEIPreLutNumValMinus1[c] ; i++)
     529        {
     530          xConfirmPara( m_colourRemapSEIPreLutCodedValue[c][i] < 0 || m_colourRemapSEIPreLutCodedValue[c][i] > ((1<<m_colourRemapSEIInputBitDepth)-1), "pre_lut_coded_value[c][i] shall be in the range of 0 to (1<<colour_remap_input_bit_depth)-1, inclusive");
     531          xConfirmPara( m_colourRemapSEIPreLutTargetValue[c][i] < 0 || m_colourRemapSEIPreLutTargetValue[c][i] > ((1<<m_colourRemapSEIBitDepth)-1), "pre_lut_target_value[c][i] shall be in the range of 0 to (1<<colour_remap_bit_depth)-1, inclusive");
     532        }
     533      xConfirmPara( m_colourRemapSEIPostLutNumValMinus1[c] < 0 || m_colourRemapSEIPostLutNumValMinus1[c] > 32, "post_lut_num_val_minus1[c] shall be in the range of 0 to 32, inclusive");
     534      if( m_colourRemapSEIPostLutNumValMinus1[c]>0 )
     535        for( Int i=0 ; i<=m_colourRemapSEIPostLutNumValMinus1[c] ; i++)
     536        {
     537          xConfirmPara( m_colourRemapSEIPostLutCodedValue[c][i] < 0 || m_colourRemapSEIPostLutCodedValue[c][i] > ((1<<m_colourRemapSEIBitDepth)-1), "post_lut_coded_value[c][i] shall be in the range of 0 to (1<<colour_remap_bit_depth)-1, inclusive");
     538          xConfirmPara( m_colourRemapSEIPostLutTargetValue[c][i] < 0 || m_colourRemapSEIPostLutTargetValue[c][i] > ((1<<m_colourRemapSEIBitDepth)-1), "post_lut_target_value[c][i] shall be in the range of 0 to (1<<colour_remap_bit_depth)-1, inclusive");
     539        }
     540    }
     541    if( m_colourRemapSEIMatrixPresentFlag )
     542    {
     543      xConfirmPara( m_colourRemapSEILog2MatrixDenom < 0 || m_colourRemapSEILog2MatrixDenom > 15, "log2_matrix_denom shall be in the range of 0 to 15, inclusive");
     544      for( Int c=0 ; c<3 ; c++)
     545        for( Int i=0 ; i<3 ; i++)
     546          xConfirmPara( m_colourRemapSEICoeffs[c][i] < -32768 || m_colourRemapSEICoeffs[c][i] > 32767, "colour_remap_coeffs[c][i] shall be in the range of -32768 and 32767, inclusive");
     547    }
     548  }
     549#endif
    388550
    389551#undef xConfirmPara
  • trunk/source/App/TAppEncoder/TAppEncLayerCfg.h

    r815 r906  
    3535  Int       m_iSourceHeightOrg;                               ///< original source height in pixel (when interlaced = frame height)
    3636  Int       m_conformanceMode;
    37   Int       m_confLeft;
    38   Int       m_confRight;
    39   Int       m_confTop;
    40   Int       m_confBottom;
     37  Int       m_confWinLeft;
     38  Int       m_confWinRight;
     39  Int       m_confWinTop;
     40  Int       m_confWinBottom;
    4141  Int       m_aiPad[2];                                       ///< number of padded pixels for width and height
    4242  Int       m_iIntraPeriod;                                   ///< period of I-slice (random access period)
     
    5454  Int       *m_predLayerIds;
    5555  Int       m_numActiveRefLayers;
    56 #endif
    57 #if Q0074_SEI_COLOR_MAPPING
    58   string    m_cSeiColorMappingFile;
    5956#endif
    6057
     
    8481
    8582  Int       m_maxTidIlRefPicsPlus1;
    86   Int       m_iWaveFrontSubstreams; //< If iWaveFrontSynchro, this is the number of substreams per frame (dependent tiles) or per tile (independent tiles).
     83  Int       m_waveFrontSynchro;                   ///< 0: no WPP. >= 1: WPP is enabled, the "Top right" from which inheritance occurs is this LCU offset in the line above the current.
     84  Int       m_iWaveFrontSubstreams;               ///< If iWaveFrontSynchro, this is the number of substreams per frame (dependent tiles) or per tile (independent tiles).
    8785
    8886  Int       m_iQP;                                            ///< QP value of key-picture (integer)
     
    9896  Int       m_scaledRefLayerRightOffset [MAX_LAYERS];
    9997  Int       m_scaledRefLayerBottomOffset[MAX_LAYERS];
    100 #if P0312_VERT_PHASE_ADJ
     98#if REF_REGION_OFFSET
     99  Bool      m_scaledRefLayerOffsetPresentFlag [MAX_LAYERS];
     100  Bool      m_refRegionOffsetPresentFlag      [MAX_LAYERS];
     101  Int       m_refRegionLeftOffset  [MAX_LAYERS];
     102  Int       m_refRegionTopOffset   [MAX_LAYERS];
     103  Int       m_refRegionRightOffset [MAX_LAYERS];
     104  Int       m_refRegionBottomOffset[MAX_LAYERS];
     105#endif
     106#if P0312_VERT_PHASE_ADJ
    101107  Bool      m_vertPhasePositionEnableFlag[MAX_LAYERS];
     108#endif
     109#if R0209_GENERIC_PHASE
     110  Int       m_phaseHorLuma  [MAX_LAYERS];
     111  Int       m_phaseVerLuma  [MAX_LAYERS];
     112  Int       m_phaseHorChroma[MAX_LAYERS];
     113  Int       m_phaseVerChroma[MAX_LAYERS];
     114  Bool      m_resamplePhaseSetPresentFlag [MAX_LAYERS];
    102115#endif
    103116
     
    113126  Int       m_repFormatIdx;
    114127#endif
     128#if Q0074_COLOUR_REMAPPING_SEI
     129  string    m_colourRemapSEIFile;                           ///< Colour Remapping Information SEI message parameters file
     130  Int       m_colourRemapSEIId;
     131  Bool      m_colourRemapSEICancelFlag;
     132  Bool      m_colourRemapSEIPersistenceFlag;
     133  Bool      m_colourRemapSEIVideoSignalInfoPresentFlag;
     134  Bool      m_colourRemapSEIFullRangeFlag;
     135  Int       m_colourRemapSEIPrimaries;
     136  Int       m_colourRemapSEITransferFunction;
     137  Int       m_colourRemapSEIMatrixCoefficients;
     138  Int       m_colourRemapSEIInputBitDepth;
     139  Int       m_colourRemapSEIBitDepth;
     140  Int       m_colourRemapSEIPreLutNumValMinus1[3];
     141  Int*      m_colourRemapSEIPreLutCodedValue[3];
     142  Int*      m_colourRemapSEIPreLutTargetValue[3];
     143  Bool      m_colourRemapSEIMatrixPresentFlag;
     144  Int       m_colourRemapSEILog2MatrixDenom;
     145  Int       m_colourRemapSEICoeffs[3][3];
     146  Int       m_colourRemapSEIPostLutNumValMinus1[3];
     147  Int*      m_colourRemapSEIPostLutCodedValue[3];
     148  Int*      m_colourRemapSEIPostLutTargetValue[3];
     149#endif
     150
    115151public:
    116152  TAppEncLayerCfg();
     
    122158  bool  parseCfg  ( const string& cfgFileName );              ///< parse layer configuration file to fill member variables
    123159
    124 #if AVC_SYNTAX
    125   Void  xPrintParameter( UInt layerId );
    126 #else
    127160  Void  xPrintParameter();
    128 #endif
    129161  Bool  xCheckParameter( Bool isField );
    130162
     
    140172  Int*    getPad()                    {return m_aiPad;            }
    141173  Double  getFloatQP()                {return m_fQP;              }
    142   Int     getConfLeft()               {return m_confLeft;         }
    143   Int     getConfRight()              {return m_confRight;        }
    144   Int     getConfTop()                {return m_confTop;          }
    145   Int     getConfBottom()             {return m_confBottom;       }
     174  Int     getConfWinLeft()            {return m_confWinLeft;         }
     175  Int     getConfWinRight()           {return m_confWinRight;        }
     176  Int     getConfWinTop()             {return m_confWinTop;          }
     177  Int     getConfWinBottom()          {return m_confWinBottom;       }
    146178#if AUXILIARY_PICTURES
    147179  ChromaFormat getInputChromaFormat()   {return m_InputChromaFormat;}
  • trunk/source/App/TAppEncoder/TAppEncTop.cpp

    r815 r906  
    7777  TComVPS* vps = m_acTEncTop[0].getVPS();
    7878
     79#if P0297_VPS_POC_LSB_ALIGNED_FLAG
     80  vps->setVpsPocLsbAlignedFlag(false);
     81#endif
    7982  vps->setMaxTLayers                       ( m_maxTempLayer );
    8083  if (m_maxTempLayer == 1)
     
    181184    repFormat->setBitDepthVpsChroma         ( getInternalBitDepthC()                        );  // Need modification to change for each layer
    182185#endif
     186
     187#if R0156_CONF_WINDOW_IN_REP_FORMAT
     188    repFormat->getConformanceWindowVps().setWindow(
     189      m_acLayerCfg[mapIdxToLayer[idx]].m_confWinLeft,
     190      m_acLayerCfg[mapIdxToLayer[idx]].m_confWinRight,
     191      m_acLayerCfg[mapIdxToLayer[idx]].m_confWinTop,
     192      m_acLayerCfg[mapIdxToLayer[idx]].m_confWinBottom );
     193#endif
     194
    183195#if HIGHER_LAYER_IRAP_SKIP_FLAG
    184196    m_acTEncTop[mapIdxToLayer[idx]].setSkipPictureAtArcSwitch( m_skipPictureAtArcSwitch );
     
    213225    m_acTEncTop[layer].setSourceWidth                  ( m_acLayerCfg[layer].getSourceWidth() );
    214226    m_acTEncTop[layer].setSourceHeight                 ( m_acLayerCfg[layer].getSourceHeight() );
    215     m_acTEncTop[layer].setConformanceMode              ( m_acLayerCfg[layer].getConformanceMode() );
    216     m_acTEncTop[layer].setConformanceWindow            ( m_acLayerCfg[layer].m_confLeft, m_acLayerCfg[layer].m_confRight, m_acLayerCfg[layer].m_confTop, m_acLayerCfg[layer].m_confBottom );
     227    m_acTEncTop[layer].setConformanceWindow            ( m_acLayerCfg[layer].m_confWinLeft, m_acLayerCfg[layer].m_confWinRight, m_acLayerCfg[layer].m_confWinTop, m_acLayerCfg[layer].m_confWinBottom );
    217228    m_acTEncTop[layer].setFramesToBeEncoded            ( m_framesToBeEncoded );
    218229
     
    226237#if REF_IDX_MFM
    227238#if AVC_BASE
    228     m_acTEncTop[layer].setMFMEnabledFlag(layer == 0 ? false : ( m_avcBaseLayerFlag ? AVC_SYNTAX : true ) && m_acLayerCfg[layer].getNumMotionPredRefLayers());
     239#if VPS_AVC_BL_FLAG_REMOVAL
     240    m_acTEncTop[layer].setMFMEnabledFlag(layer == 0 ? false : ( m_nonHEVCBaseLayerFlag ? false : true ) && m_acLayerCfg[layer].getNumMotionPredRefLayers());
     241#else
     242    m_acTEncTop[layer].setMFMEnabledFlag(layer == 0 ? false : ( m_avcBaseLayerFlag ? false : true ) && m_acLayerCfg[layer].getNumMotionPredRefLayers());
     243#endif
    229244#else
    230245    m_acTEncTop[layer].setMFMEnabledFlag(layer == 0 ? false : ( m_acLayerCfg[layer].getNumMotionPredRefLayers() > 0 ) );
     
    352367        }
    353368      }
     369#if REF_REGION_OFFSET
     370      for(Int i = 0; i < m_acLayerCfg[layer].m_numScaledRefLayerOffsets; i++)
     371      {
     372#if AUXILIARY_PICTURES
     373        Int cf = m_acLayerCfg[i].m_chromaFormatIDC;
     374        Int rlSubWidthC  = ( cf == CHROMA_420 || cf == CHROMA_422 ) ? 2 : 1;
     375        Int rlSubHeightC = ( cf == CHROMA_420 ) ? 2 : 1;
     376#else
     377        Int rlSubWidthC  = 2;
     378        Int rlSubHeightC = 2;
     379#endif
     380        m_acTEncTop[layer].setRefRegionOffsetPresentFlag( i, m_acLayerCfg[layer].m_refRegionOffsetPresentFlag );
     381        m_acTEncTop[layer].getRefLayerWindow(i).setWindow( rlSubWidthC  * m_acLayerCfg[layer].m_refRegionLeftOffset[i], rlSubWidthC  * m_acLayerCfg[layer].m_refRegionRightOffset[i],
     382                                                           rlSubHeightC * m_acLayerCfg[layer].m_refRegionTopOffset[i],  rlSubHeightC * m_acLayerCfg[layer].m_refRegionBottomOffset[i]);
     383      }
     384#endif
     385    }
     386    else
     387    {
     388      assert( layer == 0 );
     389      m_acTEncTop[layer].setNumDirectRefLayers(0);
    354390    }
    355391#endif //VPS_EXTN_DIRECT_REF_LAYERS
     
    514550    m_acTEncTop[layer].setKneeSEIOutputKneePoint                    ( m_kneeSEIOutputKneePoint );
    515551#endif
    516 #if Q0074_SEI_COLOR_MAPPING
    517     m_acTEncTop[layer].setColorMappingInfoSEIFile                   ( m_acLayerCfg[layer].m_cSeiColorMappingFile.empty() ? NULL : const_cast<Char *>(m_acLayerCfg[layer].m_cSeiColorMappingFile.c_str()) );
     552#if Q0074_COLOUR_REMAPPING_SEI
     553    m_acTEncTop[layer].setCRISEIFile                                ( const_cast<Char*>(m_acLayerCfg[layer].m_colourRemapSEIFile.c_str()) );
     554    m_acTEncTop[layer].setCRISEIId                                  ( m_acLayerCfg[layer].m_colourRemapSEIId );
     555    m_acTEncTop[layer].setCRISEICancelFlag                          ( m_acLayerCfg[layer].m_colourRemapSEICancelFlag );
     556    m_acTEncTop[layer].setCRISEIPersistenceFlag                     ( m_acLayerCfg[layer].m_colourRemapSEIPersistenceFlag );
     557    m_acTEncTop[layer].setCRISEIVideoSignalInfoPresentFlag          ( m_acLayerCfg[layer].m_colourRemapSEIVideoSignalInfoPresentFlag );
     558    m_acTEncTop[layer].setCRISEIFullRangeFlag                       ( m_acLayerCfg[layer].m_colourRemapSEIFullRangeFlag );
     559    m_acTEncTop[layer].setCRISEIPrimaries                           ( m_acLayerCfg[layer].m_colourRemapSEIPrimaries );
     560    m_acTEncTop[layer].setCRISEITransferFunction                    ( m_acLayerCfg[layer].m_colourRemapSEITransferFunction );
     561    m_acTEncTop[layer].setCRISEIMatrixCoefficients                  ( m_acLayerCfg[layer].m_colourRemapSEIMatrixCoefficients );
     562    m_acTEncTop[layer].setCRISEIInputBitDepth                       ( m_acLayerCfg[layer].m_colourRemapSEIInputBitDepth );
     563    m_acTEncTop[layer].setCRISEIBitDepth                            ( m_acLayerCfg[layer].m_colourRemapSEIBitDepth );
     564    m_acTEncTop[layer].setCRISEIPreLutNumValMinus1                  ( m_acLayerCfg[layer].m_colourRemapSEIPreLutNumValMinus1 );
     565    m_acTEncTop[layer].setCRISEIPreLutCodedValue                    ( m_acLayerCfg[layer].m_colourRemapSEIPreLutCodedValue );
     566    m_acTEncTop[layer].setCRISEIPreLutTargetValue                   ( m_acLayerCfg[layer].m_colourRemapSEIPreLutTargetValue );
     567    m_acTEncTop[layer].setCRISEIMatrixPresentFlag                   ( m_acLayerCfg[layer].m_colourRemapSEIMatrixPresentFlag );
     568    m_acTEncTop[layer].setCRISEILog2MatrixDenom                     ( m_acLayerCfg[layer].m_colourRemapSEILog2MatrixDenom );
     569    m_acTEncTop[layer].setCRISEICoeffs                              ( m_acLayerCfg[layer].m_colourRemapSEICoeffs );
     570    m_acTEncTop[layer].setCRISEIPostLutNumValMinus1                 ( m_acLayerCfg[layer].m_colourRemapSEIPostLutNumValMinus1 );
     571    m_acTEncTop[layer].setCRISEIPostLutCodedValue                   ( m_acLayerCfg[layer]. m_colourRemapSEIPostLutCodedValue );
     572    m_acTEncTop[layer].setCRISEIPostLutTargetValue                  ( m_acLayerCfg[layer].m_colourRemapSEIPostLutTargetValue );
    518573#endif
    519574    m_acTEncTop[layer].setFramePackingArrangementSEIEnabled( m_framePackingSEIEnabled );
     
    542597    m_acTEncTop[layer].setIlcIdc( m_ilcIdc );
    543598#endif
    544     m_acTEncTop[layer].setUniformSpacingIdr          ( m_iUniformSpacingIdr );
    545     m_acTEncTop[layer].setNumColumnsMinus1           ( m_iNumColumnsMinus1 );
    546     m_acTEncTop[layer].setNumRowsMinus1              ( m_iNumRowsMinus1 );
    547     if(m_iUniformSpacingIdr==0)
    548     {
    549       m_acTEncTop[layer].setColumnWidth              ( m_pColumnWidth );
    550       m_acTEncTop[layer].setRowHeight                ( m_pRowHeight );
     599    m_acTEncTop[layer].setTileUniformSpacingFlag     ( m_tileUniformSpacingFlag );
     600    m_acTEncTop[layer].setNumColumnsMinus1           ( m_numTileColumnsMinus1 );
     601    m_acTEncTop[layer].setNumRowsMinus1              ( m_numTileRowsMinus1 );
     602    if(!m_tileUniformSpacingFlag)
     603    {
     604      m_acTEncTop[layer].setColumnWidth              ( m_tileColumnWidth );
     605      m_acTEncTop[layer].setRowHeight                ( m_tileRowHeight );
    551606    }
    552607    m_acTEncTop[layer].xCheckGSParameters();
    553     Int uiTilesCount          = (m_iNumRowsMinus1+1) * (m_iNumColumnsMinus1+1);
     608    Int uiTilesCount = (m_numTileRowsMinus1+1) * (m_numTileColumnsMinus1+1);
    554609    if(uiTilesCount == 1)
    555610    {
     
    557612    }
    558613    m_acTEncTop[layer].setLFCrossTileBoundaryFlag( m_bLFCrossTileBoundaryFlag );
    559     m_acTEncTop[layer].setWaveFrontSynchro           ( m_iWaveFrontSynchro );
     614    m_acTEncTop[layer].setWaveFrontSynchro           ( m_acLayerCfg[layer].m_waveFrontSynchro );
    560615    m_acTEncTop[layer].setWaveFrontSubstreams        ( m_acLayerCfg[layer].m_iWaveFrontSubstreams );
    561616    m_acTEncTop[layer].setTMVPModeId ( m_TMVPModeId );
     
    586641    m_acTEncTop[layer].setActiveParameterSetsSEIEnabled ( m_activeParameterSetsSEIEnabled );
    587642    m_acTEncTop[layer].setVuiParametersPresentFlag( m_vuiParametersPresentFlag );
     643    m_acTEncTop[layer].setAspectRatioInfoPresentFlag( m_aspectRatioInfoPresentFlag);
    588644    m_acTEncTop[layer].setAspectRatioIdc( m_aspectRatioIdc );
    589645    m_acTEncTop[layer].setSarWidth( m_sarWidth );
     
    617673    if( layer > 0 )
    618674    {
     675#if REF_REGION_OFFSET
     676#if AUXILIARY_PICTURES
     677      Int cf = m_acLayerCfg[layer].m_chromaFormatIDC;
     678      Int subWidthC  = ( cf == CHROMA_420 || cf == CHROMA_422 ) ? 2 : 1;
     679      Int subHeightC = ( cf == CHROMA_420 ) ? 2 : 1;
     680#else
     681      Int subWidthC  = 2;
     682      Int subHeightC = 2;
     683#endif
     684#endif
    619685      m_acTEncTop[layer].setNumScaledRefLayerOffsets( m_acLayerCfg[layer].m_numScaledRefLayerOffsets );
    620686      for(Int i = 0; i < m_acLayerCfg[layer].m_numScaledRefLayerOffsets; i++)
     
    623689        m_acTEncTop[layer].setScaledRefLayerId(i, m_acLayerCfg[layer].m_scaledRefLayerId[i]);
    624690#endif
     691#if REF_REGION_OFFSET
     692        m_acTEncTop[layer].setScaledRefLayerOffsetPresentFlag( i, m_acLayerCfg[layer].m_scaledRefLayerOffsetPresentFlag[i] );
     693        m_acTEncTop[layer].getScaledRefLayerWindow(i).setWindow( subWidthC  * m_acLayerCfg[layer].m_scaledRefLayerLeftOffset[i], subWidthC  * m_acLayerCfg[layer].m_scaledRefLayerRightOffset[i],
     694                                                                 subHeightC * m_acLayerCfg[layer].m_scaledRefLayerTopOffset[i],  subHeightC * m_acLayerCfg[layer].m_scaledRefLayerBottomOffset[i]);
     695#else
    625696#if P0312_VERT_PHASE_ADJ
    626697        m_acTEncTop[layer].setVertPhasePositionEnableFlag( i, m_acLayerCfg[layer].m_vertPhasePositionEnableFlag[i] );
     
    630701        m_acTEncTop[layer].getScaledRefLayerWindow(i).setWindow( 2*m_acLayerCfg[layer].m_scaledRefLayerLeftOffset[i], 2*m_acLayerCfg[layer].m_scaledRefLayerRightOffset[i],
    631702                                                  2*m_acLayerCfg[layer].m_scaledRefLayerTopOffset[i], 2*m_acLayerCfg[layer].m_scaledRefLayerBottomOffset[i]);
     703#endif
     704#endif
     705#if R0209_GENERIC_PHASE
     706        m_acTEncTop[layer].setResamplePhaseSetPresentFlag( i, m_acLayerCfg[layer].m_resamplePhaseSetPresentFlag[i] );
     707        m_acTEncTop[layer].setPhaseHorLuma( i, m_acLayerCfg[layer].m_phaseHorLuma[i] );
     708        m_acTEncTop[layer].setPhaseVerLuma( i, m_acLayerCfg[layer].m_phaseVerLuma[i] );
     709        m_acTEncTop[layer].setPhaseHorChroma( i, m_acLayerCfg[layer].m_phaseHorChroma[i] );
     710        m_acTEncTop[layer].setPhaseVerChroma( i, m_acLayerCfg[layer].m_phaseVerChroma[i] );
    632711#endif
    633712      }
     
    650729    m_acTEncTop[layer].setCGSMaxYPartNumLog2( m_nCGSMaxYPartNumLog2 );
    651730    m_acTEncTop[layer].setCGSLUTBit( m_nCGSLUTBit );
     731#if R0151_CGS_3D_ASYMLUT_IMPROVE
     732    m_acTEncTop[layer].setCGSAdaptChroma( m_nCGSAdaptiveChroma );
     733#endif
     734#if R0179_ENC_OPT_3DLUT_SIZE
     735    m_acTEncTop[layer].setCGSLutSizeRDO( m_nCGSLutSizeRDO );
     736#endif
    652737#endif
    653738#if Q0078_ADD_LAYER_SETS
     
    685770  m_cTEncTop.setSourceWidth                  ( m_iSourceWidth );
    686771  m_cTEncTop.setSourceHeight                 ( m_iSourceHeight );
    687   m_cTEncTop.setConformanceWindow            ( m_confLeft, m_confRight, m_confTop, m_confBottom );
     772  m_cTEncTop.setConformanceWindow            ( m_confWinLeft, m_confWinRight, m_confWinTop, m_confWinBottom );
    688773  m_cTEncTop.setFramesToBeEncoded            ( m_framesToBeEncoded );
    689774
     
    853938  m_cTEncTop.setKneeSEIOutputKneePoint      ( m_kneeSEIOutputKneePoint );
    854939#endif
    855 #if Q0074_SEI_COLOR_MAPPING
    856   m_cTEncTop.setColorMappingInfoSEIFile                   ( m_pchSEIColorMappingFile );
     940#if Q0074_COLOUR_REMAPPING_SEI
     941  m_cTEncTop.setCRISEIFile                       ( const_cast<Char*>(m_colourRemapSEIFile.c_str()) );
     942  m_cTEncTop.setCRISEIId                         ( m_colourRemapSEIId );
     943  m_cTEncTop.setCRISEICancelFlag                 ( m_colourRemapSEICancelFlag );
     944  m_cTEncTop.setCRISEIPersistenceFlag            ( m_colourRemapSEIPersistenceFlag );
     945  m_cTEncTop.setCRISEIVideoSignalInfoPresentFlag ( m_colourRemapSEIVideoSignalInfoPresentFlag );
     946  m_cTEncTop.setCRISEIFullRangeFlag              ( m_colourRemapSEIFullRangeFlag );
     947  m_cTEncTop.setCRISEIPrimaries                  ( m_colourRemapSEIPrimaries );
     948  m_cTEncTop.setCRISEITransferFunction           ( m_colourRemapSEITransferFunction );
     949  m_cTEncTop.setCRISEIMatrixCoefficients         ( m_colourRemapSEIMatrixCoefficients );
     950  m_cTEncTop.setCRISEIInputBitDepth              ( m_colourRemapSEIInputBitDepth );
     951  m_cTEncTop.setCRISEIBitDepth                   ( m_colourRemapSEIBitDepth );
     952  m_cTEncTop.setCRISEIPreLutNumValMinus1         ( m_colourRemapSEIPreLutNumValMinus1 );
     953  m_cTEncTop.setCRISEIPreLutCodedValue           ( m_colourRemapSEIPreLutCodedValue );
     954  m_cTEncTop.setCRISEIPreLutTargetValue          ( m_colourRemapSEIPreLutTargetValue );
     955  m_cTEncTop.setCRISEIMatrixPresentFlag          ( m_colourRemapSEIMatrixPresentFlag );
     956  m_cTEncTop.setCRISEILog2MatrixDenom            ( m_colourRemapSEILog2MatrixDenom );
     957  m_cTEncTop.setCRISEICoeffs                     ( m_colourRemapSEICoeffs );
     958  m_cTEncTop.setCRISEIPostLutNumValMinus1        ( m_colourRemapSEIPostLutNumValMinus1 );
     959  m_cTEncTop.setCRISEIPostLutCodedValue          ( m_colourRemapSEIPostLutCodedValue );
     960  m_cTEncTop.setCRISEIPostLutTargetValue         ( m_colourRemapSEIPostLutTargetValue );
    857961#endif
    858962  m_cTEncTop.setFramePackingArrangementSEIEnabled( m_framePackingSEIEnabled );
     
    870974  m_cTEncTop.setSOPDescriptionSEIEnabled( m_SOPDescriptionSEIEnabled );
    871975  m_cTEncTop.setScalableNestingSEIEnabled( m_scalableNestingSEIEnabled );
    872   m_cTEncTop.setUniformSpacingIdr          ( m_iUniformSpacingIdr );
    873   m_cTEncTop.setNumColumnsMinus1           ( m_iNumColumnsMinus1 );
    874   m_cTEncTop.setNumRowsMinus1              ( m_iNumRowsMinus1 );
    875   if(m_iUniformSpacingIdr==0)
    876   {
    877     m_cTEncTop.setColumnWidth              ( m_pColumnWidth );
    878     m_cTEncTop.setRowHeight                ( m_pRowHeight );
     976  m_cTEncTop.setTileUniformSpacingFlag     ( m_tileUniformSpacingFlag );
     977  m_cTEncTop.setNumColumnsMinus1           ( m_numTileColumnsMinus1 );
     978  m_cTEncTop.setNumRowsMinus1              ( m_numTileRowsMinus1 );
     979  if(!m_tileUniformSpacingFlag)
     980  {
     981    m_cTEncTop.setColumnWidth              ( m_tileColumnWidth );
     982    m_cTEncTop.setRowHeight                ( m_tileRowHeight );
    879983  }
    880984  m_cTEncTop.xCheckGSParameters();
    881   Int uiTilesCount          = (m_iNumRowsMinus1+1) * (m_iNumColumnsMinus1+1);
     985  Int uiTilesCount          = (m_numTileRowsMinus1+1) * (m_numTileColumnsMinus1+1);
    882986  if(uiTilesCount == 1)
    883987  {
     
    9041008  m_cTEncTop.setActiveParameterSetsSEIEnabled ( m_activeParameterSetsSEIEnabled );
    9051009  m_cTEncTop.setVuiParametersPresentFlag( m_vuiParametersPresentFlag );
     1010  m_cTEncTop.setAspectRatioInfoPresentFlag( m_aspectRatioInfoPresentFlag);
    9061011  m_cTEncTop.setAspectRatioIdc( m_aspectRatioIdc );
    9071012  m_cTEncTop.setSarWidth( m_sarWidth );
     
    10561161
    10571162#if Q0078_ADD_LAYER_SETS
     1163#if OUTPUT_LAYER_SETS_CONFIG
     1164  if (m_numLayerSets > 1)
     1165  {
     1166    vps->setNumLayerSets(m_numLayerSets);
     1167#else
    10581168  if (m_numLayerSets > 0)
    10591169  {
    10601170    vps->setNumLayerSets(m_numLayerSets+1);
     1171#endif
    10611172    for (Int setId = 1; setId < vps->getNumLayerSets(); setId++)
    10621173    {
     
    10681179    for (Int setId = 1; setId < vps->getNumLayerSets(); setId++)
    10691180    {
     1181#if OUTPUT_LAYER_SETS_CONFIG
     1182      for (Int i = 0; i < m_numLayerInIdList[setId]; i++)
     1183      {
     1184        Int layerId = m_layerSetLayerIdList[setId][i];
     1185#else
    10701186      for (Int i = 0; i < m_numLayerInIdList[setId-1]; i++)
    10711187      {
    10721188        Int layerId = m_layerSetLayerIdList[setId-1][i];
    1073 
     1189#endif
    10741190#if O0194_DIFFERENT_BITDEPTH_EL_BL
    10751191        //4
     
    11331249  UInt i = 0, dimIdLen = 0;
    11341250#if AVC_BASE
     1251#if VPS_AVC_BL_FLAG_REMOVAL
     1252  vps->setNonHEVCBaseLayerFlag( m_nonHEVCBaseLayerFlag );
     1253  if ( m_nonHEVCBaseLayerFlag )
     1254  {
     1255    vps->setBaseLayerInternalFlag (false);
     1256  }
     1257#else
    11351258  vps->setAvcBaseLayerFlag(m_avcBaseLayerFlag);
     1259#endif
    11361260#else
    11371261  vps->setAvcBaseLayerFlag(false);
     
    12001324#endif
    12011325#if VPS_TSLAYERS
    1202     vps->setMaxTSLayersPresentFlag(true);
    1203 
    1204     for( i = 0; i < vps->getMaxLayers(); i++ )
    1205     {
    1206       vps->setMaxTSLayersMinus1(i, vps->getMaxTLayers()-1);
    1207     }
     1326  vps->setMaxTSLayersPresentFlag(true);
     1327
     1328  for( i = 0; i < vps->getMaxLayers(); i++ )
     1329  {
     1330    vps->setMaxTSLayersMinus1(i, vps->getMaxTLayers()-1);
     1331  }
    12081332#endif
    12091333  vps->setMaxTidRefPresentFlag(m_maxTidRefPresentFlag);
     
    12381362    vps->setIlpSshSignalingEnabledFlag(false);
    12391363#if VPS_EXTN_PROFILE_INFO
     1364
     1365#if LIST_OF_PTL
     1366  vps->getPTLForExtnPtr()->resize(1);   // Dummy object - unused.
     1367  for(i = 0; i < vps->getMaxLayers(); i++)
     1368  {
     1369    // TODO: The profile tier level have to be given support to be included in the configuration files
     1370    if(i == 0)
     1371    {
     1372      if( vps->getBaseLayerInternalFlag() && vps->getMaxLayers() > 1 )
     1373      {
     1374        vps->setProfilePresentFlag(1, false);
     1375        vps->getPTLForExtnPtr()->push_back( *(m_acTEncTop[0].getSPS()->getPTL()) );
     1376      }
     1377    }
     1378    else  // i > 0
     1379    {
     1380      vps->setProfilePresentFlag(i, true);
     1381      // Note - may need to be changed for other layer structures.
     1382      vps->getPTLForExtnPtr()->push_back( *(m_acTEncTop[0].getSPS()->getPTL()) );
     1383    }
     1384  }
     1385#else
    12401386  vps->getPTLForExtnPtr()->resize(vps->getNumLayerSets());
    12411387  for(Int setId = 1; setId < vps->getNumLayerSets(); setId++)
     
    12451391    *(vps->getPTLForExtn(setId)) = *(m_acTEncTop[setId].getSPS()->getPTL());
    12461392  }
     1393#endif
    12471394#endif
    12481395#if VPS_EXTN_DIRECT_REF_LAYERS
     
    13171464#endif
    13181465#endif
     1466#if OUTPUT_LAYER_SETS_CONFIG
     1467
     1468  vps->setDefaultTargetOutputLayerIdc( m_defaultTargetOutputLayerIdc ); // As per configuration file
     1469
     1470  if( m_numOutputLayerSets == -1 )  // # of output layer sets not specified in the configuration file
     1471  {
     1472    vps->setNumOutputLayerSets(vps->getNumLayerSets());
     1473
     1474    for(i = 1; i < vps->getNumLayerSets(); i++)
     1475    {
     1476        vps->setOutputLayerSetIdx(i, i);
     1477    }
     1478  }
     1479  else
     1480  {
     1481    vps->setNumOutputLayerSets( m_numOutputLayerSets );
     1482    for( Int olsCtr = 0; olsCtr < vps->getNumLayerSets(); olsCtr ++ ) // Default output layer sets
     1483    {
     1484      vps->setOutputLayerSetIdx(olsCtr, olsCtr);
     1485    }
     1486    for( Int olsCtr = vps->getNumLayerSets(); olsCtr < vps->getNumOutputLayerSets(); olsCtr ++ )  // Non-default output layer sets
     1487    {
     1488      vps->setOutputLayerSetIdx(olsCtr, m_outputLayerSetIdx[olsCtr - vps->getNumLayerSets()]);
     1489    }
     1490  }
     1491#endif
    13191492  // Target output layer
     1493#if LIST_OF_PTL
     1494  vps->setNumProfileTierLevel( vps->getPTLForExtnPtr()->size() ); // +1 for the base VPS PTL()
     1495#else
    13201496  vps->setNumOutputLayerSets(vps->getNumLayerSets());
    13211497  vps->setNumProfileTierLevel(vps->getNumLayerSets());
     1498#endif
     1499#if !OUTPUT_LAYER_SETS_CONFIG // Taken care by configuration file parameter
    13221500#if P0295_DEFAULT_OUT_LAYER_IDC
    13231501  vps->setDefaultTargetOutputLayerIdc(1);
     
    13291507#endif
    13301508#endif
     1509#endif
     1510#if !PER_LAYER_PTL
    13311511  for(i = 1; i < vps->getNumLayerSets(); i++)
    13321512  {
    13331513    vps->setProfileLevelTierIdx(i, i);
     1514#if !OUTPUT_LAYER_SETS_CONFIG
    13341515    vps->setOutputLayerSetIdx(i, i);
     1516#endif
    13351517  } 
     1518#endif
    13361519#endif
    13371520 #if VPS_DPB_SIZE_TABLE
     
    13471530
    13481531  // derive OutputLayerFlag[i][j]
     1532#if !OUTPUT_LAYER_SETS_CONFIG
    13491533  if( vps->getDefaultTargetOutputLayerIdc() == 1 )
     1534#endif
    13501535  {
    13511536    // default_output_layer_idc equal to 1 specifies that only the layer with the highest value of nuh_layer_id such that nuh_layer_id equal to nuhLayerIdA and
     
    13601545        if( vps->getLayerIdIncludedFlag(lsIdx, layer) )     
    13611546#endif
    1362         {       
     1547        {
     1548#if OUTPUT_LAYER_SETS_CONFIG
     1549          switch(vps->getDefaultTargetOutputLayerIdc())
     1550          {
     1551            case 0: vps->setOutputLayerFlag( lsIdx, layer, 1 );
     1552              break;
     1553            case 1: vps->setOutputLayerFlag( lsIdx, layer, layer == vps->getNumLayersInIdList(lsIdx) - 1 );
     1554              break;
     1555            case 2:
     1556            case 3: vps->setOutputLayerFlag( lsIdx, layer, std::find( m_listOfOutputLayers[lsIdx].begin(), m_listOfOutputLayers[lsIdx].end(), layer) != m_listOfOutputLayers[lsIdx].end() );
     1557              break;
     1558          }
     1559#else
    13631560          vps->setOutputLayerFlag( lsIdx, layer, layer == vps->getNumLayersInIdList(lsIdx) - 1 );
     1561#endif
    13641562        }
    13651563      }
    13661564    }
    1367   }
     1565#if OUTPUT_LAYER_SETS_CONFIG
     1566    for( Int olsIdx = vps->getNumLayerSets(); olsIdx < vps->getNumOutputLayerSets(); olsIdx++ )
     1567    {
     1568      for( UInt layer = 0; layer < vps->getNumLayersInIdList(vps->getOutputLayerSetIdx(olsIdx)); layer++ )
     1569      {
     1570        vps->setOutputLayerFlag( olsIdx, layer, std::find( m_listOfOutputLayers[olsIdx].begin(), m_listOfOutputLayers[olsIdx].end(), layer) != m_listOfOutputLayers[olsIdx].end());
     1571      }
     1572    }
     1573#endif
     1574  }
     1575#if !OUTPUT_LAYER_SETS_CONFIG
    13681576  else
    13691577  {
     
    13711579    assert(!"default_output_layer_idc not equal to 1 is not yet supported");
    13721580  }
    1373 
     1581#endif
     1582#if NECESSARY_LAYER_FLAG
     1583  vps->deriveNecessaryLayerFlag();
     1584  vps->checkNecessaryLayerFlagCondition();
     1585#endif
     1586#if PER_LAYER_PTL
     1587  vps->getProfileLevelTierIdx()->resize(vps->getNumOutputLayerSets());
     1588  vps->getProfileLevelTierIdx(0)->push_back( vps->getBaseLayerInternalFlag() && vps->getMaxLayers() > 1 ? 1 : 0 ); // Default 0-th output layer set
     1589  for(i = 1; i < vps->getNumOutputLayerSets(); i++)
     1590  {
     1591    Int layerSetIdxForOutputLayerSet = vps->getOutputLayerSetIdx( i );
     1592    Int numLayerInLayerSet = vps->getNumLayersInIdList( layerSetIdxForOutputLayerSet );
     1593    for(Int j = 0; j < numLayerInLayerSet; j++)
     1594    {
     1595      Int layerIdxInVps = vps->getLayerIdInVps( vps->getLayerSetLayerIdList(layerSetIdxForOutputLayerSet, j) );
     1596      if( vps->getNecessaryLayerFlag(i, j) )
     1597      {
     1598        vps->getProfileLevelTierIdx(i)->push_back( vps->getBaseLayerInternalFlag() && vps->getMaxLayers() > 1 ? layerIdxInVps + 1 : layerIdxInVps);
     1599      }
     1600      else
     1601      {
     1602        vps->getProfileLevelTierIdx(i)->push_back( -1 );
     1603      }
     1604    }
     1605  }
     1606#endif
     1607#if SUB_LAYERS_IN_LAYER_SET
     1608  vps->calculateMaxSLInLayerSets();
     1609#endif
    13741610  // Initialize dpb_size_table() for all ouput layer sets in the VPS extension
    13751611  for(i = 1; i < vps->getNumOutputLayerSets(); i++)
     
    15011737#endif
    15021738
     1739#if VPS_VUI_BSP_HRD_PARAMS
     1740  vps->setVpsVuiBspHrdPresentFlag(false);
     1741  TEncTop *pcCfg = &m_acTEncTop[0];
     1742  if( pcCfg->getBufferingPeriodSEIEnabled() )
     1743  {
     1744    Int j;
     1745    vps->setVpsVuiBspHrdPresentFlag(true);
     1746    vps->setVpsNumAddHrdParams( vps->getMaxLayers() );
     1747    vps->createBspHrdParamBuffer(vps->getVpsNumAddHrdParams() + 1);
     1748    for( i = vps->getNumHrdParameters(), j = 0; i < vps->getNumHrdParameters() + vps->getVpsNumAddHrdParams(); i++, j++ )
     1749    {
     1750      vps->setCprmsAddPresentFlag( j, true );
     1751      vps->setNumSubLayerHrdMinus1( j, vps->getMaxTLayers() - 1 );
     1752
     1753      UInt layerId = j;
     1754      TEncTop *pcCfgLayer = &m_acTEncTop[layerId];
     1755
     1756      Int iPicWidth         = pcCfgLayer->getSourceWidth();
     1757      Int iPicHeight        = pcCfgLayer->getSourceHeight();
     1758#if LAYER_CTB
     1759      UInt uiWidthInCU       = ( iPicWidth  % m_acLayerCfg[layerId].m_uiMaxCUWidth  ) ? iPicWidth  / m_acLayerCfg[layerId].m_uiMaxCUWidth  + 1 : iPicWidth  / m_acLayerCfg[layerId].m_uiMaxCUWidth;
     1760      UInt uiHeightInCU      = ( iPicHeight % m_acLayerCfg[layerId].m_uiMaxCUHeight ) ? iPicHeight / m_acLayerCfg[layerId].m_uiMaxCUHeight + 1 : iPicHeight / m_acLayerCfg[layerId].m_uiMaxCUHeight;
     1761      UInt maxCU = pcCfgLayer->getSliceArgument() >> ( m_acLayerCfg[layerId].m_uiMaxCUDepth << 1);
     1762#else
     1763      UInt uiWidthInCU       = ( iPicWidth %m_uiMaxCUWidth  ) ? iPicWidth /m_uiMaxCUWidth  + 1 : iPicWidth /m_uiMaxCUWidth;
     1764      UInt uiHeightInCU      = ( iPicHeight%m_uiMaxCUHeight ) ? iPicHeight/m_uiMaxCUHeight + 1 : iPicHeight/m_uiMaxCUHeight;
     1765      UInt maxCU = pcCfgLayer->getSliceArgument() >> ( m_uiMaxCUDepth << 1);
     1766#endif
     1767      UInt uiNumCUsInFrame   = uiWidthInCU * uiHeightInCU;
     1768
     1769      UInt numDU = ( pcCfgLayer->getSliceMode() == 1 ) ? ( uiNumCUsInFrame / maxCU ) : ( 0 );
     1770      if( uiNumCUsInFrame % maxCU != 0 || numDU == 0 )
     1771      {
     1772        numDU ++;
     1773      }
     1774      vps->getBspHrd(i)->setNumDU( numDU );
     1775      vps->setBspHrdParameters( i, pcCfgLayer->getFrameRate(), numDU, pcCfgLayer->getTargetBitrate(), ( pcCfgLayer->getIntraPeriod() > 0 ) );
     1776    }
     1777
     1778    // Signalling of additional partitioning schemes
     1779    for(Int h = 1; h < vps->getNumOutputLayerSets(); h++)
     1780    {
     1781      Int lsIdx = vps->getOutputLayerSetIdx( h );
     1782      vps->setNumSignalledPartitioningSchemes(h, 1);  // Only the default per-layer partitioning scheme
     1783      for( j = 1; j < vps->getNumSignalledPartitioningSchemes(h); j++ )
     1784      {
     1785        // ToDo: Add code for additional partitioning schemes here
     1786        // ToDo: Initialize num_partitions_in_scheme_minus1 and layer_included_in_partition_flag
     1787      }
     1788
     1789      for( i = 0; i < vps->getNumSignalledPartitioningSchemes(h); i++ )
     1790      {
     1791        if( i == 0 )
     1792        {
     1793          for(Int t = 0; t <= vps->getMaxSLayersInLayerSetMinus1( lsIdx ); t++)
     1794          {
     1795            vps->setNumBspSchedulesMinus1( h, i, t, 0 );
     1796            for( j = 0; j <= vps->getNumBspSchedulesMinus1(h, i, t); j++ )
     1797            {
     1798              for( Int k = 0; k <= vps->getNumPartitionsInSchemeMinus1(h, i); k++ )
     1799              {
     1800                // Only for the default partition
     1801                Int nuhlayerId = vps->getLayerSetLayerIdList( lsIdx, k);
     1802                Int layerIdxInVps = vps->getLayerIdInVps( nuhlayerId );
     1803                vps->setBspHrdIdx(h, i, t, j, k, layerIdxInVps + vps->getNumHrdParameters());
     1804
     1805                vps->setBspSchedIdx(h, i, t, j, k, 0);
     1806              }
     1807            }
     1808          }
     1809        }
     1810        else
     1811        {
     1812          assert(0);    // Need to add support for additional partitioning schemes.
     1813        }
     1814      }
     1815    }
     1816  }
     1817#else
     1818
    15031819#if O0164_MULTI_LAYER_HRD
    15041820  vps->setVpsVuiBspHrdPresentFlag(false);
     
    15721888    }
    15731889  }
     1890#endif
    15741891#endif
    15751892
     
    16691986  }
    16701987
    1671 #if AVC_SYNTAX
    1672   fstream streamSyntaxFile;
    1673   if( m_acTEncTop[0].getVPS()->getAvcBaseLayerFlag() )
    1674   {
    1675     if( !m_BLSyntaxFile )
    1676     {
    1677       printf( "Wrong base layer syntax input file\n" );
    1678       exit(EXIT_FAILURE);
    1679     }
    1680     streamSyntaxFile.open( m_BLSyntaxFile, fstream::in | fstream::binary );
    1681     if( !streamSyntaxFile.good() )
    1682     {
    1683       printf( "Base layer syntax input reading error\n" );
    1684       exit(EXIT_FAILURE);
    1685     }
    1686     m_acTEncTop[0].setBLSyntaxFile( &streamSyntaxFile );
    1687   }
    1688 #endif
    1689 
    16901988  Bool bFirstFrame = true;
    16911989  while ( !bEos )
     
    18162114      }
    18172115    }
     2116#if R0247_SEI_ACTIVE
     2117    if(bFirstFrame)
     2118    {
     2119      list<AccessUnit>::iterator first_au = outputAccessUnits.begin();
     2120      AccessUnit::iterator it_sps;
     2121      for (it_sps = first_au->begin(); it_sps != first_au->end(); it_sps++)
     2122      {
     2123        if( (*it_sps)->m_nalUnitType == NAL_UNIT_SPS )
     2124        {
     2125          break;
     2126        }
     2127      }
     2128
     2129      for (list<AccessUnit>::iterator it_au = ++outputAccessUnits.begin(); it_au != outputAccessUnits.end(); it_au++)
     2130      {
     2131        for (AccessUnit::iterator it_nalu = it_au->begin(); it_nalu != it_au->end(); it_nalu++)
     2132        {
     2133          if( (*it_nalu)->m_nalUnitType == NAL_UNIT_SPS )
     2134          {
     2135            first_au->insert(++it_sps, *it_nalu);
     2136            it_nalu = it_au->erase(it_nalu);
     2137          }
     2138        }
     2139      }
     2140    }
     2141
     2142#endif
    18182143
    18192144#if RC_SHVC_HARMONIZATION
     
    18582183
    18592184        AccessUnit& accessUnit = outputAccessUnits.back();
     2185#if T_ID_EOB_BUG_FIX
     2186        nalu.m_temporalId = 0;
     2187#else
    18602188        nalu.m_temporalId = accessUnit.front()->m_temporalId;
     2189#endif
    18612190        accessUnit.push_back(new NALUnitEBSP(nalu));
    18622191      }
     
    18842213    m_acTEncTop[layer].deletePicBuffer();
    18852214  }
    1886 
    1887 #if AVC_SYNTAX
    1888   if( streamSyntaxFile.is_open() )
    1889   {
    1890     streamSyntaxFile.close();
    1891   }
    1892 #endif
    18932215
    18942216  // delete buffers & classes
     
    21542476      {
    21552477#if REPN_FORMAT_IN_VPS
    2156         m_acTVideoIOYuvReconFile[layer].write( pcPicYuvRecTop, pcPicYuvRecBottom, m_acLayerCfg[layer].getConfLeft() * xScal, m_acLayerCfg[layer].getConfRight() * xScal,
    2157           m_acLayerCfg[layer].getConfTop() * yScal, m_acLayerCfg[layer].getConfBottom() * yScal, m_isTopFieldFirst );
    2158 #else
    2159         m_acTVideoIOYuvReconFile[layer].write( pcPicYuvRecTop, pcPicYuvRecBottom, m_acLayerCfg[layer].getConfLeft(), m_acLayerCfg[layer].getConfRight(), m_acLayerCfg[layer].getConfTop(), m_acLayerCfg[layer].getConfBottom(), m_isTopFieldFirst );
     2478        m_acTVideoIOYuvReconFile[layer].write( pcPicYuvRecTop, pcPicYuvRecBottom, m_acLayerCfg[layer].getConfWinLeft() * xScal, m_acLayerCfg[layer].getConfWinRight() * xScal,
     2479          m_acLayerCfg[layer].getConfWinTop() * yScal, m_acLayerCfg[layer].getConfWinBottom() * yScal, m_isTopFieldFirst );
     2480#else
     2481        m_acTVideoIOYuvReconFile[layer].write( pcPicYuvRecTop, pcPicYuvRecBottom, m_acLayerCfg[layer].getConfWinLeft(), m_acLayerCfg[layer].getConfWinRight(), m_acLayerCfg[layer].getConfWinTop(), m_acLayerCfg[layer].getConfWinBottom(), m_isTopFieldFirst );
    21602482#endif
    21612483      }
     
    21832505      {
    21842506#if REPN_FORMAT_IN_VPS
    2185         m_acTVideoIOYuvReconFile[layer].write( pcPicYuvRec, m_acLayerCfg[layer].getConfLeft() * xScal, m_acLayerCfg[layer].getConfRight() * xScal,
    2186           m_acLayerCfg[layer].getConfTop() * yScal, m_acLayerCfg[layer].getConfBottom() * yScal );
    2187 #else
    2188         m_acTVideoIOYuvReconFile[layer].write( pcPicYuvRec, m_acLayerCfg[layer].getConfLeft(), m_acLayerCfg[layer].getConfRight(),
    2189           m_acLayerCfg[layer].getConfTop(), m_acLayerCfg[layer].getConfBottom() );
     2507        m_acTVideoIOYuvReconFile[layer].write( pcPicYuvRec, m_acLayerCfg[layer].getConfWinLeft() * xScal, m_acLayerCfg[layer].getConfWinRight() * xScal,
     2508          m_acLayerCfg[layer].getConfWinTop() * yScal, m_acLayerCfg[layer].getConfWinBottom() * yScal );
     2509#else
     2510        m_acTVideoIOYuvReconFile[layer].write( pcPicYuvRec, m_acLayerCfg[layer].getConfWinLeft(), m_acLayerCfg[layer].getConfWinRight(),
     2511          m_acLayerCfg[layer].getConfWinTop(), m_acLayerCfg[layer].getConfWinBottom() );
    21902512#endif
    21912513      }
     
    22952617      if (m_pchReconFile)
    22962618      {
    2297         m_cTVideoIOYuvReconFile.write( pcPicYuvRecTop, pcPicYuvRecBottom, m_confLeft, m_confRight, m_confTop, m_confBottom, m_isTopFieldFirst );
     2619        m_cTVideoIOYuvReconFile.write( pcPicYuvRecTop, pcPicYuvRecBottom, m_confWinLeft, m_confWinRight, m_confWinTop, m_confWinBottom, m_isTopFieldFirst );
    22982620      }
    22992621
     
    23102632  {
    23112633    Int i;
    2312 
    23132634    TComList<TComPicYuv*>::iterator iterPicYuvRec = m_cListPicYuvRec.end();
    23142635    list<AccessUnit>::const_iterator iterBitstream = accessUnits.begin();
     
    23242645      if (m_pchReconFile)
    23252646      {
    2326 #if SYNTAX_OUTPUT
    2327         m_cTVideoIOYuvReconFile.write( pcPicYuvRec, m_confLeft, m_confRight, m_confTop, m_confBottom );
    2328 #endif
     2647        m_cTVideoIOYuvReconFile.write( pcPicYuvRec, m_confWinLeft, m_confWinRight, m_confWinTop, m_confWinBottom );
    23292648      }
    23302649
  • trunk/source/Lib/TLibCommon/CommonDef.h

    r815 r906  
    5858#if SVC_EXTENSION
    5959#include <vector>
    60 #define NV_VERSION        "6.1 (HM-14.0)"                 ///< Current software version
     60#define NV_VERSION        "7.0 (HM-15.0)"                 ///< Current software version
    6161#else
    62 #define NV_VERSION        "14.0"                ///< Current software version
     62#define NV_VERSION        "15.0"                ///< Current software version
    6363#endif
    6464
  • trunk/source/Lib/TLibCommon/SEI.h

    r815 r906  
    9494    BSP_NESTING                          = 140,
    9595    BSP_INITIAL_ARRIVAL_TIME             = 141,
     96#if !REMOVE_BSP_HRD_SEI
    9697    BSP_HRD                              = 142,
    9798#endif
    98 #if Q0074_SEI_COLOR_MAPPING
    99     COLOR_MAPPING_INFO                   = 143,
     99#endif
     100#if Q0074_COLOUR_REMAPPING_SEI
     101    COLOUR_REMAPPING_INFO                = 143,
    100102#endif
    101103#if Q0078_ADD_LAYER_SETS
     
    173175  Int numSpsIdsMinus1;
    174176  std::vector<Int> activeSeqParameterSetId;
     177#if R0247_SEI_ACTIVE
     178  std::vector<Int> layerSpsIdx;
     179#endif
    175180};
    176181
     
    199204  UInt m_bpSeqParameterSetId;
    200205  Bool m_rapCpbParamsPresentFlag;
    201   Bool m_cpbDelayOffset;
    202   Bool m_dpbDelayOffset;
     206  UInt m_cpbDelayOffset;
     207  UInt m_dpbDelayOffset;
    203208  UInt m_initialCpbRemovalDelay         [MAX_CPB_CNT][2];
    204209  UInt m_initialCpbRemovalDelayOffset   [MAX_CPB_CNT][2];
     
    445450};
    446451#endif
    447 #if Q0074_SEI_COLOR_MAPPING
    448 class SEIColorMappingInfo : public SEI
    449 {
    450 public:
    451   PayloadType payloadType() const { return COLOR_MAPPING_INFO; }
    452   SEIColorMappingInfo() {
    453   }
    454   virtual ~SEIColorMappingInfo() {}
    455 
    456   Int   m_colorMapId;
    457   Bool  m_colorMapCancelFlag;
    458   Bool  m_colorMapPersistenceFlag;
    459   Bool  m_colorMap_video_signal_type_present_flag;
    460   Bool  m_colorMap_video_full_range_flag;
    461   Int   m_colorMap_primaries;
    462   Int   m_colorMap_transfer_characteristics;
    463   Int   m_colorMap_matrix_coeffs;
    464   Int   m_colorMapModelId;
    465 
    466   Int   m_colour_map_coded_data_bit_depth;
    467   Int   m_colour_map_target_bit_depth;
    468 
    469   Int   m_num_input_pivots[3];
    470   Int*  m_coded_input_pivot_value[3];
    471   Int*  m_target_input_pivot_value[3];
    472  
    473   Bool  m_matrix_flag;
    474   Int   m_log2_matrix_denom;
    475   Int   m_matrix_coef[3][3];
    476 
    477   Int   m_num_output_pivots[3];
    478   Int*  m_coded_output_pivot_value[3];
    479   Int*  m_target_output_pivot_value[3];
     452#if Q0074_COLOUR_REMAPPING_SEI
     453class SEIColourRemappingInfo : public SEI
     454{
     455public:
     456  PayloadType payloadType() const { return COLOUR_REMAPPING_INFO; }
     457  SEIColourRemappingInfo() {}
     458  ~SEIColourRemappingInfo() {}
     459 
     460  Int   m_colourRemapId;
     461  Bool  m_colourRemapCancelFlag;
     462  Bool  m_colourRemapPersistenceFlag;
     463  Bool  m_colourRemapVideoSignalInfoPresentFlag;
     464  Bool  m_colourRemapFullRangeFlag;
     465  Int   m_colourRemapPrimaries;
     466  Int   m_colourRemapTransferFunction;
     467  Int   m_colourRemapMatrixCoefficients;
     468  Int   m_colourRemapInputBitDepth;
     469  Int   m_colourRemapBitDepth;
     470  Int   m_preLutNumValMinus1[3];
     471  std::vector<Int> m_preLutCodedValue[3];
     472  std::vector<Int> m_preLutTargetValue[3];
     473  Bool  m_colourRemapMatrixPresentFlag;
     474  Int   m_log2MatrixDenom;
     475  Int   m_colourRemapCoeffs[3][3];
     476  Int   m_postLutNumValMinus1[3];
     477  std::vector<Int> m_postLutCodedValue[3];
     478  std::vector<Int> m_postLutTargetValue[3];
    480479};
    481480#endif
     
    593592  Bool  m_callerOwnsSEIs;
    594593  SEIMessages m_nestedSEIs;
     594#if VPS_VUI_BSP_HRD_PARAMS
     595  Int  m_seiPartitioningSchemeIdx;
     596  Int  m_seiOlsIdx;
     597#endif
    595598};
    596599
     
    607610};
    608611
     612#if !REMOVE_BSP_HRD_SEI
    609613class SEIBspHrd : public SEI
    610614{
     
    627631  TComHRD *hrd;
    628632};
     633#endif
    629634
    630635#endif
  • trunk/source/Lib/TLibCommon/TCom3DAsymLUT.cpp

    r815 r906  
    1717  m_pCuboid = NULL;
    1818  m_nResQuanBit = 0;
     19#if R0164_CGS_LUT_BUGFIX_CHECK
     20  m_pCuboidExplicit = NULL;
     21  m_pCuboidFilled = NULL;
     22#endif
    1923}
    2024
     
    2428}
    2529
    26 Void TCom3DAsymLUT::create( Int nMaxOctantDepth , Int nInputBitDepth , Int nInputBitDepthC , Int nOutputBitDepth , Int nOutputBitDepthC , Int nMaxYPartNumLog2 )
     30Void TCom3DAsymLUT::create( Int nMaxOctantDepth , Int nInputBitDepth , Int nInputBitDepthC , Int nOutputBitDepth , Int nOutputBitDepthC , Int nMaxYPartNumLog2
     31#if R0151_CGS_3D_ASYMLUT_IMPROVE
     32  , Int nAdaptCThresholdU , Int nAdaptCThresholdV
     33#endif
     34  )
    2735{
    2836  m_nMaxOctantDepth = nMaxOctantDepth;
     
    3644  m_nMaxPartNumLog2 = 3 * m_nMaxOctantDepth + m_nMaxYPartNumLog2;
    3745
    38   xUpdatePartitioning( nMaxOctantDepth , nMaxYPartNumLog2 );
     46  xUpdatePartitioning( nMaxOctantDepth , nMaxYPartNumLog2
     47#if R0151_CGS_3D_ASYMLUT_IMPROVE
     48    , nAdaptCThresholdU , nAdaptCThresholdV
     49#endif
     50    );
    3951
    4052  m_nYSize = 1 << ( m_nMaxOctantDepth + m_nMaxYPartNumLog2 );
     
    4860  }
    4961  xAllocate3DArray( m_pCuboid , m_nYSize , m_nUSize , m_nVSize );
     62
     63#if R0164_CGS_LUT_BUGFIX_CHECK
     64  xAllocate3DArray( m_pCuboidExplicit , m_nYSize , m_nUSize , m_nVSize );
     65  xAllocate3DArray( m_pCuboidFilled   , m_nYSize , m_nUSize , m_nVSize );
     66#endif
    5067}
    5168
     
    5370{
    5471  xFree3DArray( m_pCuboid );
    55 }
    56 
    57 Void TCom3DAsymLUT::xUpdatePartitioning( Int nCurOctantDepth , Int nCurYPartNumLog2 )
     72#if R0164_CGS_LUT_BUGFIX_CHECK
     73  xFree3DArray( m_pCuboidExplicit );
     74  xFree3DArray( m_pCuboidFilled   );
     75#endif
     76}
     77
     78
     79Void TCom3DAsymLUT::xUpdatePartitioning( Int nCurOctantDepth , Int nCurYPartNumLog2
     80#if R0151_CGS_3D_ASYMLUT_IMPROVE
     81  , Int nAdaptCThresholdU , Int nAdaptCThresholdV
     82#endif
     83  )
    5884{
    5985  assert( nCurOctantDepth <= m_nMaxOctantDepth );
     86#if R0179_CGS_SIZE_8x1x1
     87  assert( nCurYPartNumLog2 + nCurOctantDepth <= m_nMaxYPartNumLog2 + m_nMaxOctantDepth );
     88#else
    6089  assert( nCurYPartNumLog2 <= m_nMaxYPartNumLog2 );
     90#endif
    6191
    6292  m_nCurOctantDepth = nCurOctantDepth;
     
    6494  m_nYShift2Idx = m_nInputBitDepthY - m_nCurOctantDepth - m_nCurYPartNumLog2;
    6595  m_nUShift2Idx = m_nVShift2Idx = m_nInputBitDepthC - m_nCurOctantDepth;
     96#if R0151_CGS_3D_ASYMLUT_IMPROVE
     97  m_nMappingShift = 10 + m_nInputBitDepthY - m_nOutputBitDepthY;
     98  m_nAdaptCThresholdU = nAdaptCThresholdU;
     99  m_nAdaptCThresholdV = nAdaptCThresholdV;
     100#else
    66101  m_nMappingShift = m_nYShift2Idx + m_nUShift2Idx;
     102#endif
    67103  m_nMappingOffset = 1 << ( m_nMappingShift - 1 );
     104
     105#if R0179_ENC_OPT_3DLUT_SIZE
     106  m_nYSize = 1 << ( m_nCurOctantDepth + m_nCurYPartNumLog2 );
     107  m_nUSize = 1 << m_nCurOctantDepth;
     108  m_nVSize = 1 << m_nCurOctantDepth;
     109#endif
    68110}
    69111
     
    159201 
    160202  SYUVP sPred;
     203#if R0151_CGS_3D_ASYMLUT_IMPROVE
     204  sPred.Y = sPred.U = sPred.V = 0;
     205  if( nVertexIdx == 0 )
     206    sPred.Y = xGetNormCoeffOne() << ( m_nOutputBitDepthY - m_nInputBitDepthY );
     207  else if( nVertexIdx == 1 )
     208    sPred.U = xGetNormCoeffOne() << ( m_nOutputBitDepthY - m_nInputBitDepthY );
     209  else if( nVertexIdx == 2 )
     210    sPred.V = xGetNormCoeffOne() << ( m_nOutputBitDepthY - m_nInputBitDepthY );
     211#else
    161212  sPred.Y = ( yIdx + m_nVertexIdxOffset[nVertexIdx][0] ) << ( m_nYShift2Idx + m_nDeltaBitDepth );
    162213  sPred.U = ( uIdx + m_nVertexIdxOffset[nVertexIdx][1] ) << ( m_nUShift2Idx + m_nDeltaBitDepthC );
    163214  sPred.V = ( vIdx + m_nVertexIdxOffset[nVertexIdx][2] ) << ( m_nVShift2Idx + m_nDeltaBitDepthC );
     215#endif
    164216  return( sPred );
    165217}
     
    169221  SCuboid***  pCuboid = pCurCuboid ? pCurCuboid : m_pCuboid ;
    170222
     223#if R0151_CGS_3D_ASYMLUT_IMPROVE
     224  SYUVP sPred;
     225  if( yIdx == 0 )
     226  {
     227    sPred.Y = nVertexIdx == 0 ? 1024 : 0;
     228    sPred.U = nVertexIdx == 1 ? 1024 : 0;
     229    sPred.V = nVertexIdx == 2 ? 1024 : 0;
     230  }
     231  else
     232  {
     233    sPred = pCuboid[yIdx-1][uIdx][vIdx].P[nVertexIdx];
     234  }
     235#else
    171236  // PredA
    172237  SYUVP sPredA = xGetCuboidVertexPredA( yIdx , uIdx , vIdx , nVertexIdx );
     
    196261  sPred.U = sPredA.U + sPredB.U;
    197262  sPred.V = sPredA.V + sPredB.V;
    198 
     263#endif
    199264  return sPred ;
    200265}
     
    220285  rYUVP.U = sPred.U + ( deltaU << m_nResQuanBit );
    221286  rYUVP.V = sPred.V + ( deltaV << m_nResQuanBit );
     287#if R0150_CGS_SIGNAL_CONSTRAINTS
     288  // LUT coefficients are less than 12-bit
     289  assert( -2048 <= rYUVP.Y && rYUVP.Y <= 2047 );
     290  assert( -2048 <= rYUVP.U && rYUVP.U <= 2047 );
     291  assert( -2048 <= rYUVP.V && rYUVP.V <= 2047 );
     292#endif
    222293}
    223294
    224295Pel TCom3DAsymLUT::xMapY( Pel y , Pel u , Pel v )
    225296{
     297#if R0151_CGS_3D_ASYMLUT_IMPROVE
     298  const SCuboid & rCuboid = m_pCuboid[xGetYIdx(y)][xGetUIdx(u)][xGetVIdx(v)];
     299  Pel dstY = ( ( rCuboid.P[0].Y * y + rCuboid.P[1].Y * u + rCuboid.P[2].Y * v + m_nMappingOffset ) >> m_nMappingShift ) + rCuboid.P[3].Y;
     300#else
    226301  const SCuboid & rCuboid = m_pCuboid[y>>m_nYShift2Idx][u>>m_nUShift2Idx][v>>m_nVShift2Idx];
    227302  Pel dstY = rCuboid.P[0].Y;
     
    233308                   + ( ( deltaV * ( rCuboid.P[2].Y - rCuboid.P[1].Y ) ) << m_nYShift2Idx )
    234309                   + m_nMappingOffset ) >> m_nMappingShift );
     310#endif
    235311  return( dstY );
    236312}
     
    238314SYUVP TCom3DAsymLUT::xMapUV( Pel y , Pel u , Pel v )
    239315{
     316#if R0151_CGS_3D_ASYMLUT_IMPROVE
     317  const SCuboid & rCuboid = m_pCuboid[xGetYIdx(y)][xGetUIdx(u)][xGetVIdx(v)];
     318  SYUVP dst;
     319  dst.Y = 0;
     320  dst.U = ( ( rCuboid.P[0].U * y + rCuboid.P[1].U * u + rCuboid.P[2].U * v + m_nMappingOffset ) >> m_nMappingShift ) + rCuboid.P[3].U;
     321  dst.V = ( ( rCuboid.P[0].V * y + rCuboid.P[1].V * u + rCuboid.P[2].V * v + m_nMappingOffset ) >> m_nMappingShift ) + rCuboid.P[3].V;
     322#else
    240323  const SCuboid & rCuboid = m_pCuboid[y>>m_nYShift2Idx][u>>m_nUShift2Idx][v>>m_nVShift2Idx];
    241324  SYUVP dst = rCuboid.P[0];
     
    251334                    + ( ( deltaV * ( rCuboid.P[2].V - rCuboid.P[1].V ) ) << m_nYShift2Idx )
    252335                    + m_nMappingOffset ) >> m_nMappingShift );
     336#endif
    253337  return( dst );
    254338}
     
    256340Void TCom3DAsymLUT::xSaveCuboids( SCuboid *** pSrcCuboid )
    257341{
     342#if R0179_ENC_OPT_3DLUT_SIZE
     343  memcpy( m_pCuboid[0][0] , pSrcCuboid[0][0] , sizeof( SCuboid ) * getMaxYSize() * getMaxCSize() * getMaxCSize() );
     344#else
    258345  memcpy( m_pCuboid[0][0] , pSrcCuboid[0][0] , sizeof( SCuboid ) * m_nYSize * m_nUSize * m_nVSize );
     346#endif
    259347}
    260348
     
    262350{
    263351  assert( pSrc->getMaxOctantDepth() == getMaxOctantDepth() && pSrc->getMaxYPartNumLog2() == getMaxYPartNumLog2() );
    264   xUpdatePartitioning( pSrc->getCurOctantDepth() , pSrc->getCurYPartNumLog2() );
     352  xUpdatePartitioning( pSrc->getCurOctantDepth() , pSrc->getCurYPartNumLog2()
     353#if R0151_CGS_3D_ASYMLUT_IMPROVE
     354    , pSrc->getAdaptChromaThresholdU() , pSrc->getAdaptChromaThresholdV()
     355#endif
     356    );
    265357  setResQuantBit( pSrc->getResQuantBit() );
    266358  xSaveCuboids( pSrc->m_pCuboid );
    267359}
    268360
    269 #endif
    270 
     361#if R0164_CGS_LUT_BUGFIX_CHECK
     362Void TCom3DAsymLUT::xInitCuboids( )
     363{
     364  // All vertices are initialized as non-exlicitly-encoded
     365  for( Int yIdx = 0 ; yIdx < m_nYSize ; yIdx++ )
     366  {
     367    for( Int uIdx = 0 ; uIdx < m_nUSize ; uIdx++ )
     368    {
     369      for( Int vIdx = 0 ; vIdx < m_nVSize ; vIdx++ )
     370      {
     371        m_pCuboidExplicit[yIdx][uIdx][vIdx] = false;
     372        m_pCuboidFilled[yIdx][uIdx][vIdx]   = false;
     373      }
     374    }
     375  }
     376}
     377
     378Void TCom3DAsymLUT::xCuboidsFilledCheck( Int yIdx , Int uIdx , Int vIdx )
     379{
     380  if ( m_pCuboidFilled[yIdx][uIdx][vIdx] == false )
     381  {
     382    if( yIdx > 0)
     383      assert ( m_pCuboidFilled[yIdx-1][uIdx][vIdx] );
     384
     385    for ( Int nVertexIdx=0 ; nVertexIdx<4 ; nVertexIdx++ )
     386      m_pCuboid[yIdx][uIdx][vIdx].P[nVertexIdx] = yIdx == 0 ? xGetCuboidVertexPredA( yIdx , uIdx , vIdx , nVertexIdx ): xGetCuboidVertexPredAll( yIdx , uIdx , vIdx , nVertexIdx );
     387
     388    m_pCuboidFilled[yIdx][uIdx][vIdx] = true ;
     389  }
     390}
     391
     392
     393Void TCom3DAsymLUT::xCuboidsFilledCheck( Bool bDecode )
     394{
     395  Int ySize = 1 << ( getCurOctantDepth() + getCurYPartNumLog2() );
     396  Int uSize = 1 << getCurOctantDepth();
     397  Int vSize = 1 << getCurOctantDepth();
     398  for( Int yIdx = 0 ; yIdx < ySize ; yIdx++ )
     399  {
     400    for( Int uIdx = 0 ; uIdx < uSize ; uIdx++ )
     401    {
     402      for( Int vIdx = 0 ; vIdx < vSize ; vIdx++ )
     403      {
     404        if ( bDecode )
     405          xCuboidsFilledCheck( yIdx , uIdx , vIdx );
     406
     407        assert( m_pCuboidFilled[yIdx][uIdx][vIdx] );
     408      }
     409    }
     410  }
     411
     412}
     413#endif
     414
     415#if R0150_CGS_SIGNAL_CONSTRAINTS
     416Bool TCom3DAsymLUT::isRefLayer( UInt uiRefLayerId )
     417{
     418  Bool bIsRefLayer = false;
     419  for( UInt i = 0 ; i < m_vRefLayerId.size() ; i++ )
     420  {
     421    if( m_vRefLayerId[i] == uiRefLayerId )
     422    {
     423      bIsRefLayer = true;
     424      break;
     425    }
     426  }
     427
     428  return( bIsRefLayer );
     429}
     430#endif
     431
     432#if R0164_CGS_LUT_BUGFIX_CHECK
     433Void  TCom3DAsymLUT::display( Bool bFilled )
     434{
     435  Int ySize = 1 << ( getCurOctantDepth() + getCurYPartNumLog2() );
     436  Int uSize = 1 << getCurOctantDepth();
     437  Int vSize = 1 << getCurOctantDepth();
     438  Int vIdx=0;
     439
     440  printf("\n");
     441  printf("3DLut Explicit flag:\n");
     442  for( Int uIdx = 0 ; uIdx < uSize ; uIdx++ )
     443  {
     444    for( Int yIdx = 0 ; yIdx < ySize ; yIdx++ )
     445    {
     446      printf("%d\t", m_pCuboidExplicit[yIdx][uIdx][vIdx] );
     447    }
     448    printf("\n");
     449  }
     450
     451  printf("3DLut values (explicit):\n");
     452  for( Int uIdx = 0 ; uIdx < uSize ; uIdx++ )
     453  {
     454    for( Int yIdx = 0 ; yIdx < ySize ; yIdx++ )
     455    {
     456      if ( m_pCuboidExplicit[yIdx][uIdx][vIdx] )  printf("%d\t", m_pCuboid[yIdx][uIdx][vIdx].P[0].Y );
     457      else                                        printf("?\t", m_pCuboid[yIdx][uIdx][vIdx].P[0].Y );
     458    }
     459    printf("\n");
     460  }
     461
     462  printf("3DLut values (all):\n");
     463  for( Int uIdx = 0 ; uIdx < uSize ; uIdx++ )
     464  {
     465    for( Int yIdx = 0 ; yIdx < ySize ; yIdx++ )
     466    {
     467      if ( bFilled ) {
     468        if ( m_pCuboidFilled[yIdx][uIdx][vIdx] )  printf("%d\t"  , m_pCuboid[yIdx][uIdx][vIdx].P[0].Y );
     469        else                                      printf("unk\t" , m_pCuboid[yIdx][uIdx][vIdx].P[0].Y );
     470      }
     471      else
     472        printf("%d\t"  , m_pCuboid[yIdx][uIdx][vIdx].P[0].Y );
     473    }
     474    printf("\n");
     475  }
     476
     477}
     478#endif
     479
     480#endif
     481
  • trunk/source/Lib/TLibCommon/TCom3DAsymLUT.h

    r815 r906  
    44
    55#include "TypeDef.h"
     6#if R0150_CGS_SIGNAL_CONSTRAINTS
     7#include <cassert>
     8#include <vector>
     9#endif
    610
    711#if Q0048_CGS_3D_ASYMLUT
     
    2529  virtual ~TCom3DAsymLUT();
    2630
    27   virtual Void  create( Int nMaxOctantDepth , Int nInputBitDepth , Int nInputBitDepthC , Int nOutputBitDepth , Int nOutputBitDepthC , Int nMaxYPartNumLog2 );
     31  virtual Void  create( Int nMaxOctantDepth , Int nInputBitDepth , Int nInputBitDepthC , Int nOutputBitDepth , Int nOutputBitDepthC , Int nMaxYPartNumLog2
     32#if R0151_CGS_3D_ASYMLUT_IMPROVE
     33  , Int nAdaptCThresholdU , Int nAdaptCThresholdV
     34#endif
     35    );
    2836  virtual Void  destroy();
    2937
     
    3644  Int   getResQuantBit()     { return m_nResQuanBit; }
    3745  Void  setResQuantBit(Int n){ m_nResQuanBit = n; }
     46#if R0300_CGS_RES_COEFF_CODING
     47  Int   getMappingShift()     { return m_nMappingShift; }
     48  Int   getDeltaBits()        { return m_nDeltaBits; }
     49  Void  setDeltaBits(Int n)   { m_nDeltaBits = n; }
     50#endif
    3851  Int   getMaxYPartNumLog2() { return m_nMaxYPartNumLog2; }
    3952  Int   getCurYPartNumLog2() { return m_nCurYPartNumLog2; }
     53#if R0150_CGS_SIGNAL_CONSTRAINTS
     54  Void  addRefLayerId( UInt uiRefLayerId ) 
     55  {
     56    if( !isRefLayer( uiRefLayerId ) )
     57      m_vRefLayerId.push_back( uiRefLayerId );
     58  }
     59  size_t  getRefLayerNum()     { return m_vRefLayerId.size();  }
     60  UInt  getRefLayerId( UInt n )  { assert( n < m_vRefLayerId.size() ); return m_vRefLayerId[n];   }
     61  Bool  isRefLayer( UInt uiRefLayerId );
     62#endif
     63#if R0151_CGS_3D_ASYMLUT_IMPROVE
     64  Void  setAdaptChromaThresholdU( Int n ) { m_nAdaptCThresholdU = n; }
     65  Int   getAdaptChromaThresholdU()        { return m_nAdaptCThresholdU; }
     66  Void  setAdaptChromaThresholdV( Int n ) { m_nAdaptCThresholdV = n;  }
     67  Int   getAdaptChromaThresholdV()        { return m_nAdaptCThresholdV; }
     68#endif
     69#if R0179_ENC_OPT_3DLUT_SIZE
     70  Int   getMaxYSize() { return 1<<(m_nMaxOctantDepth+m_nMaxYPartNumLog2); }
     71  Int   getMaxCSize() { return 1<<m_nMaxOctantDepth; }
     72#endif
    4073
    4174  Void  colorMapping( TComPicYuv * pcPicSrc,  TComPicYuv * pcPicDst );
     
    4578  SYUVP getCuboidVertexResTree( Int yIdx , Int uIdx , Int vIdx , Int nVertexIdx );
    4679  Void  setCuboidVertexResTree( Int yIdx , Int uIdx , Int vIdx , Int nVertexIdx , Int deltaY , Int deltaU , Int deltaV );
    47 
     80#if R0164_CGS_LUT_BUGFIX_CHECK
     81  Void  xInitCuboids( );
     82  Void  xCuboidsFilledCheck( Int yIdx , Int uIdx , Int vIdx );
     83  Void  xCuboidsFilledCheck( Bool bDecode );
     84  Void  display( Bool bFilled=true );
     85  Void  xSetExplicit( Int yIdx , Int uIdx , Int vIdx )  { m_pCuboidExplicit[yIdx][uIdx][vIdx] = true ; xSetFilled(yIdx,uIdx,vIdx); }
     86  Void  xSetFilled( Int yIdx , Int uIdx , Int vIdx )    { m_pCuboidFilled[yIdx][uIdx][vIdx] = true ; }
     87#endif
    4888
    4989private:
     
    68108  Int   m_nMappingOffset;
    69109  Int   m_nResQuanBit;
     110#if R0300_CGS_RES_COEFF_CODING
     111  Int   m_nDeltaBits;
     112#endif
    70113  SCuboid *** m_pCuboid;
    71114  const static Int m_nVertexIdxOffset[4][3];
     115#if R0150_CGS_SIGNAL_CONSTRAINTS
     116  std::vector<UInt> m_vRefLayerId;
     117#endif
     118#if R0151_CGS_3D_ASYMLUT_IMPROVE
     119  Int   m_nAdaptCThresholdU;
     120  Int   m_nAdaptCThresholdV;
     121#endif
     122#if R0164_CGS_LUT_BUGFIX_CHECK
     123  Bool  *** m_pCuboidExplicit;
     124  Bool  *** m_pCuboidFilled;
     125#endif
    72126
    73127protected:
     
    79133  Void xFree3DArray( T *** &p );
    80134
    81   Void  xUpdatePartitioning( Int nCurOctantDepth , Int nCurYPartNumLog2 );
     135  Void  xUpdatePartitioning( Int nCurOctantDepth , Int nCurYPartNumLog2
     136#if R0151_CGS_3D_ASYMLUT_IMPROVE
     137    , Int nAdaptCThresholdU , Int nAdaptCThreshodV
     138#endif
     139    );
    82140  SYUVP xGetCuboidVertexPredA( Int yIdx , Int uIdx , Int vIdx , Int nVertexIdx );
    83141  Pel   xMapY( Pel y , Pel u , Pel v );
     
    87145  Int   xGetUSize()  { return m_nUSize;  }
    88146  Int   xGetVSize()  { return m_nVSize;  }
     147#if R0151_CGS_3D_ASYMLUT_IMPROVE
     148  Int   xGetYIdx(Pel y)  { return( y >> m_nYShift2Idx ); }
     149  Int   xGetUIdx(Pel u)  { return( m_nCurOctantDepth == 1 ? u >= m_nAdaptCThresholdU : u >> m_nUShift2Idx ); }
     150  Int   xGetVIdx(Pel v)  { return( m_nCurOctantDepth == 1 ? v >= m_nAdaptCThresholdV : v >> m_nVShift2Idx ); }
     151  Int   xGetNormCoeffOne()    { return( 1 << m_nMappingShift ); }
     152#else
    89153  Int   xGetYShift2Idx() { return m_nYShift2Idx; }
    90154  Int   xGetUShift2Idx() { return m_nUShift2Idx; }
    91155  Int   xGetVShift2Idx() { return m_nVShift2Idx; }
     156#endif
    92157  SCuboid & xGetCuboid( Int yIdx , Int uIdx , Int vIdx ){ return m_pCuboid[yIdx][uIdx][vIdx];  }
    93158  Void  xSaveCuboids( SCuboid *** pSrcCuboid );
  • trunk/source/Lib/TLibCommon/TComDataCU.cpp

    r815 r906  
    34813481
    34823482#if SVC_EXTENSION
    3483 TComDataCU*  TComDataCU::getBaseColCU( UInt refLayerIdc, UInt uiCuAbsPartIdx, UInt &uiCUAddrBase, UInt &uiAbsPartIdxBase, Int iMotionMapping )
     3483TComDataCU* TComDataCU::getBaseColCU( UInt refLayerIdc, UInt uiCuAbsPartIdx, UInt &uiCUAddrBase, UInt &uiAbsPartIdxBase, Bool motionMapping )
    34843484{
    34853485  UInt uiPelX = getCUPelX() + g_auiRasterToPelX[ g_auiZscanToRaster[uiCuAbsPartIdx] ];
    34863486  UInt uiPelY = getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiCuAbsPartIdx] ];
    34873487
    3488   return getBaseColCU( refLayerIdc, uiPelX, uiPelY, uiCUAddrBase, uiAbsPartIdxBase, iMotionMapping );
    3489 }
    3490 
    3491 TComDataCU*  TComDataCU::getBaseColCU( UInt refLayerIdc, UInt uiPelX, UInt uiPelY, UInt &uiCUAddrBase, UInt &uiAbsPartIdxBase, Int iMotionMapping )
     3488  return getBaseColCU( refLayerIdc, uiPelX, uiPelY, uiCUAddrBase, uiAbsPartIdxBase, motionMapping );
     3489}
     3490
     3491TComDataCU* TComDataCU::getBaseColCU( UInt refLayerIdc, UInt pelX, UInt pelY, UInt &uiCUAddrBase, UInt &uiAbsPartIdxBase, Bool motionMapping )
    34923492{
    34933493  TComPic* baseColPic = m_pcSlice->getBaseColPic(refLayerIdc);
    34943494
    3495   uiPelX = (UInt)Clip3<UInt>(0, m_pcPic->getPicYuvRec()->getWidth() - 1, uiPelX);
    3496   uiPelY = (UInt)Clip3<UInt>(0, m_pcPic->getPicYuvRec()->getHeight() - 1, uiPelY);
     3495  UInt uiPelX = (UInt)Clip3<UInt>(0, m_pcPic->getPicYuvRec()->getWidth()  - 1, pelX);
     3496  UInt uiPelY = (UInt)Clip3<UInt>(0, m_pcPic->getPicYuvRec()->getHeight() - 1, pelY);
     3497
     3498#if REF_IDX_MFM
     3499  // centre of the collocated 16x16 block for motion mapping
     3500  if( motionMapping )
     3501  {
     3502    uiPelX = pelX + 8;
     3503    uiPelY = pelY + 8;
     3504  }
     3505#endif
    34973506
    34983507#if !LAYER_CTB
     
    35003509#endif
    35013510
     3511#if MOVE_SCALED_OFFSET_TO_PPS
     3512#if O0098_SCALED_REF_LAYER_ID
     3513  Int leftStartL = baseColPic->getSlice(0)->getPPS()->getScaledRefLayerWindowForLayer(baseColPic->getSlice(0)->getVPS()->getRefLayerId(getSlice()->getLayerId(), refLayerIdc)).getWindowLeftOffset();
     3514  Int topStartL  = baseColPic->getSlice(0)->getPPS()->getScaledRefLayerWindowForLayer(baseColPic->getSlice(0)->getVPS()->getRefLayerId(getSlice()->getLayerId(), refLayerIdc)).getWindowTopOffset();
     3515#else
     3516  Int leftStartL = baseColPic->getSlice(0)->getPPS()->getScaledRefLayerWindow(refLayerIdc).getWindowLeftOffset();
     3517  Int topStartL  = baseColPic->getSlice(0)->getPPS()->getScaledRefLayerWindow(refLayerIdc).getWindowTopOffset();
     3518#endif
     3519#else
    35023520#if O0098_SCALED_REF_LAYER_ID
    35033521  Int leftStartL = baseColPic->getSlice(0)->getSPS()->getScaledRefLayerWindowForLayer(baseColPic->getSlice(0)->getVPS()->getRefLayerId(getSlice()->getLayerId(), refLayerIdc)).getWindowLeftOffset();
     
    35073525  Int topStartL  = baseColPic->getSlice(0)->getSPS()->getScaledRefLayerWindow(refLayerIdc).getWindowTopOffset();
    35083526#endif
    3509 
     3527#endif
     3528
     3529#if REF_REGION_OFFSET
     3530  const Window &windowRL = baseColPic->getSlice(0)->getPPS()->getRefLayerWindow(refLayerIdc);
     3531  Int iBX = (((uiPelX - leftStartL)*g_posScalingFactor[refLayerIdc][0] + (1<<15)) >> 16) + windowRL.getWindowLeftOffset();
     3532  Int iBY = (((uiPelY - topStartL )*g_posScalingFactor[refLayerIdc][1] + (1<<15)) >> 16) + windowRL.getWindowTopOffset();
     3533#else
    35103534#if Q0200_CONFORMANCE_BL_SIZE
    35113535  Int chromaFormatIdc = baseColPic->getSlice(0)->getChromaFormatIdc();
     
    35163540  Int iBY = ((uiPelY - topStartL )*g_posScalingFactor[refLayerIdc][1] + (1<<15)) >> 16;
    35173541#endif
     3542#endif
    35183543
    35193544#if REF_IDX_MFM
    35203545  // offset for collocated block in the motion mapping
    3521   if( iMotionMapping == 1 )
    3522   {
    3523     Bool unequalPictureSizeFlag = g_posScalingFactor[refLayerIdc][0] != 65536 || g_posScalingFactor[refLayerIdc][1] != 65536; //the condition should be updated according to the WD.
    3524 
    3525     // actually, motion field compression is performed in the Void TComPic::compressMotion() function, but with (+4) the rounding may have effect on the picture boundary check.
    3526     if( unequalPictureSizeFlag )
    3527     {
     3546  if( motionMapping )
     3547  {
     3548    if( m_pcPic->equalPictureSizeAndOffsetFlag(refLayerIdc) )
     3549    {
     3550      // copy motion field from the same sample position for the case of 1x scaling ratio and same offset value between the current and reference layers
     3551      iBX = pelX;
     3552      iBY = pelY;
     3553    }
     3554    else
     3555    {
     3556      // actually, motion field compression is performed in the Void TComPic::compressMotion() function, but with (+4) the rounding may have effect on the picture boundary check.
    35283557      iBX = ( ( iBX + 4 ) >> 4 ) << 4;
    35293558      iBY = ( ( iBY + 4 ) >> 4 ) << 4;
    3530     }
    3531     else
    3532     {
    3533       iBX += 4;
    3534       iBY += 4;
    35353559    }
    35363560  }
     
    35873611{
    35883612  // check BL mode
    3589   UInt          uiCUAddrBase = 0, uiAbsPartAddrBase = 0;
     3613  UInt uiCUAddrBase = 0, uiAbsPartAddrBase = 0;
    35903614  // the right reference layerIdc should be specified, currently it is set to m_layerId-1
    3591   TComDataCU*   pcTempCU = getBaseColCU(m_layerId - 1, uiAbsPartIdx, uiCUAddrBase, uiAbsPartAddrBase, 0 );
     3615  TComDataCU* pcTempCU = getBaseColCU(m_layerId - 1, uiAbsPartIdx, uiCUAddrBase, uiAbsPartAddrBase, false );
    35923616
    35933617  if( pcTempCU->getPredictionMode( uiAbsPartAddrBase ) != MODE_INTRA )
  • trunk/source/Lib/TLibCommon/TComDataCU.h

    r713 r906  
    469469  Bool xCheckZeroMVILRMvdL1Zero(Int iRefList, Int iRefIdx, Int MvpIdx);
    470470#endif
    471   TComDataCU*   getBaseColCU( UInt refLayerIdc, UInt uiCuAbsPartIdx, UInt &uiCUAddrBase, UInt &uiAbsPartIdxBase, Int iMotionMapping = 0 );
    472   TComDataCU*   getBaseColCU( UInt refLayerIdc, UInt uiPelX, UInt uiPelY, UInt &uiCUAddrBase, UInt &uiAbsPartIdxBase, Int iMotionMapping = 0 );
     471  TComDataCU*   getBaseColCU( UInt refLayerIdc, UInt uiCuAbsPartIdx, UInt &uiCUAddrBase, UInt &uiAbsPartIdxBase, Bool motionMapping = false );
     472  TComDataCU*   getBaseColCU( UInt refLayerIdc, UInt pelX, UInt pelY, UInt &uiCUAddrBase, UInt &uiAbsPartIdxBase, Bool motionMapping = false );
    473473  Void          scaleBaseMV( UInt refLayerIdc, TComMvField& rcMvFieldEnhance, TComMvField& rcMvFieldBase );
    474474#endif
  • trunk/source/Lib/TLibCommon/TComMotionInfo.h

    r713 r906  
    155155  Void compress(Char* pePredMode, Int scale);
    156156
    157 #if AVC_SYNTAX
    158   Void           setMv    (TComMv cMv,  Int iIdx )         { m_pcMv    [iIdx] = cMv; }
    159   Void           setRefIdx(Int iRefIdx, Int iIdx   )       { m_piRefIdx[iIdx] =  iRefIdx; }
    160 #endif
    161 
    162157#if REF_IDX_MFM
    163158  Void setMvField( TComMvField const& mvField, Int iIdx )
  • trunk/source/Lib/TLibCommon/TComPic.cpp

    r815 r906  
    6464  memset( m_pcFullPelBaseRec, 0, sizeof( m_pcFullPelBaseRec ) );
    6565  memset( m_bSpatialEnhLayer, false, sizeof( m_bSpatialEnhLayer ) );
     66  memset( m_equalPictureSizeAndOffsetFlag, false, sizeof( m_equalPictureSizeAndOffsetFlag ) );
    6667#endif
    6768  m_apcPicYuv[0]      = NULL;
     
    8485  if (!bIsVirtual)
    8586  {
     87#if R0156_CONF_WINDOW_IN_REP_FORMAT
     88#if AUXILIARY_PICTURES
     89    m_apcPicYuv[0]  = new TComPicYuv;  m_apcPicYuv[0]->create( iWidth, iHeight, chromaFormatIDC, uiMaxWidth, uiMaxHeight, uiMaxDepth, &conformanceWindow );
     90#else
     91    m_apcPicYuv[0]  = new TComPicYuv;  m_apcPicYuv[0]->create( iWidth, iHeight, uiMaxWidth, uiMaxHeight, uiMaxDepth, &conformanceWindow );
     92#endif
     93#else
    8694#if AUXILIARY_PICTURES
    8795    m_apcPicYuv[0]  = new TComPicYuv;  m_apcPicYuv[0]->create( iWidth, iHeight, chromaFormatIDC, uiMaxWidth, uiMaxHeight, uiMaxDepth, pcSps );
     
    8997    m_apcPicYuv[0]  = new TComPicYuv;  m_apcPicYuv[0]->create( iWidth, iHeight, uiMaxWidth, uiMaxHeight, uiMaxDepth, pcSps );
    9098#endif
    91   }
     99#endif
     100  }
     101#if R0156_CONF_WINDOW_IN_REP_FORMAT
     102#if AUXILIARY_PICTURES
     103  m_apcPicYuv[1]  = new TComPicYuv;  m_apcPicYuv[1]->create( iWidth, iHeight, chromaFormatIDC, uiMaxWidth, uiMaxHeight, uiMaxDepth, &conformanceWindow );
     104#else
     105  m_apcPicYuv[1]  = new TComPicYuv;  m_apcPicYuv[1]->create( iWidth, iHeight, uiMaxWidth, uiMaxHeight, uiMaxDepth, &conformanceWindow );
     106#endif
     107#else
    92108#if AUXILIARY_PICTURES
    93109  m_apcPicYuv[1]  = new TComPicYuv;  m_apcPicYuv[1]->create( iWidth, iHeight, chromaFormatIDC, uiMaxWidth, uiMaxHeight, uiMaxDepth, pcSps );
     
    95111  m_apcPicYuv[1]  = new TComPicYuv;  m_apcPicYuv[1]->create( iWidth, iHeight, uiMaxWidth, uiMaxHeight, uiMaxDepth, pcSps );
    96112#endif
     113#endif
    97114
    98115  for( Int i = 0; i < MAX_LAYERS; i++ )
     
    100117    if( m_bSpatialEnhLayer[i] )
    101118    {
     119#if R0156_CONF_WINDOW_IN_REP_FORMAT
     120#if AUXILIARY_PICTURES
     121      m_pcFullPelBaseRec[i] = new TComPicYuv;  m_pcFullPelBaseRec[i]->create( iWidth, iHeight, chromaFormatIDC, uiMaxWidth, uiMaxHeight, uiMaxDepth, &conformanceWindow );
     122#else
     123      m_pcFullPelBaseRec[i] = new TComPicYuv;  m_pcFullPelBaseRec[i]->create( iWidth, iHeight, uiMaxWidth, uiMaxHeight, uiMaxDepth, &conformanceWindow );
     124#endif
     125#else
    102126#if AUXILIARY_PICTURES
    103127      m_pcFullPelBaseRec[i] = new TComPicYuv;  m_pcFullPelBaseRec[i]->create( iWidth, iHeight, chromaFormatIDC, uiMaxWidth, uiMaxHeight, uiMaxDepth, pcSps );
    104128#else
    105129      m_pcFullPelBaseRec[i] = new TComPicYuv;  m_pcFullPelBaseRec[i]->create( iWidth, iHeight, uiMaxWidth, uiMaxHeight, uiMaxDepth, pcSps );
     130#endif
    106131#endif
    107132    }
     
    187212  for( Int i = 0; i < MAX_LAYERS; i++ )
    188213  {
    189     if( m_bSpatialEnhLayer[i] )
     214    if( m_bSpatialEnhLayer[i] && m_pcFullPelBaseRec[i] )
    190215    {
    191216      m_pcFullPelBaseRec[i]->destroy();
     
    260285Void TComPic::copyUpsampledMvField(UInt refLayerIdc, TComPic* pcPicBase)
    261286{
    262   UInt numPartitions   = 1<<(g_uiMaxCUDepth<<1);
    263   UInt widthMinPU      = g_uiMaxCUWidth/(1<<g_uiMaxCUDepth);
    264   UInt heightMinPU     = g_uiMaxCUHeight/(1<<g_uiMaxCUDepth);
    265   Int  unitNum         = max (1, (Int)((16/widthMinPU)*(16/heightMinPU)) );
     287  UInt numPartitions = 1<<(g_uiMaxCUDepth<<1);
     288  UInt widthMinPU    = g_uiMaxCUWidth/(1<<g_uiMaxCUDepth);
     289  UInt heightMinPU   = g_uiMaxCUHeight/(1<<g_uiMaxCUDepth);
     290  Int  unitNum       = max (1, (Int)((16/widthMinPU)*(16/heightMinPU)) );
    266291
    267292  for(UInt cuIdx = 0; cuIdx < getPicSym()->getNumberOfCUsInFrame(); cuIdx++)  //each LCU
     
    277302
    278303      TComDataCU *pcColCU = 0;
    279       pcColCU = pcCUDes->getBaseColCU(refLayerIdc, pelX + 8, pelY + 8, baseCUAddr, baseAbsPartIdx, 1);
     304      pcColCU = pcCUDes->getBaseColCU(refLayerIdc, pelX, pelY, baseCUAddr, baseAbsPartIdx, true);
    280305
    281306      if( pcColCU && (pcColCU->getPredictionMode(baseAbsPartIdx) != MODE_NONE) && (pcColCU->getPredictionMode(baseAbsPartIdx) != MODE_INTRA) )  //base layer unit not skip and invalid mode
     
    306331      }
    307332    }
    308     memset( pcCUDes->getPartitionSize(), SIZE_2Nx2N, sizeof(Char)*numPartitions);
     333    memset( pcCUDes->getPartitionSize(), SIZE_2Nx2N, sizeof(Char)*numPartitions );
    309334  }
    310335}
     
    332357}
    333358#endif
    334 #endif
    335 
    336 #if AVC_SYNTAX
    337 Void TComPic::readBLSyntax( fstream* filestream, UInt numBytes )
    338 {
    339   if( !filestream->good() )
    340   {
    341     return;
    342   }
    343 
    344   UInt   width      = this->getPicYuvRec()->getWidth();
    345   UInt   height     = this->getPicYuvRec()->getHeight();
    346 
    347   UInt64 poc        = (UInt64)this->getPOC();
    348   UInt   partWidth  = width / 4;
    349   UInt   partHeight = height / 4;
    350 
    351   UInt numPartInWidth    = this->getNumPartInWidth();
    352   UInt numPartInHeight   = this->getNumPartInHeight();
    353   UInt numPartLCUInWidth = this->getFrameWidthInCU();
    354 
    355   UInt64 uiPos = (UInt64)poc * width * height * numBytes / 16;
    356    
    357   filestream->seekg( uiPos, ios_base::beg );
    358 
    359   for( Int i = 0; i < partHeight; i++ )
    360   {
    361     for( Int j = 0; j < partWidth; j++ )
    362     {
    363       UInt x = ( j / numPartInWidth );
    364       UInt y = ( i / numPartInHeight );
    365 
    366       UInt addrLCU = y * numPartLCUInWidth + x;
    367       UInt partAddr = ( i - y * numPartInHeight ) * numPartInWidth + ( j - x * numPartInWidth );
    368       partAddr = g_auiRasterToZscan[partAddr];
    369      
    370       TComDataCU* pcCU = this->getCU( addrLCU );
    371      
    372       TComMv mv;
    373       Short temp;
    374 
    375       // RefIdxL0
    376       Char refIdxL0 = -1;
    377       filestream->read( &refIdxL0, 1 );
    378       assert( refIdxL0 >= -1 );
    379       pcCU->getCUMvField( REF_PIC_LIST_0 )->setRefIdx( (Int)refIdxL0, partAddr );
    380 
    381       // RefIdxL1
    382       Char refIdxL1 = -1;
    383       filestream->read( &refIdxL1, 1 );
    384       assert( refIdxL1 >= -1 );
    385       pcCU->getCUMvField( REF_PIC_LIST_1 )->setRefIdx( (Int)refIdxL1, partAddr );
    386 
    387       // MV L0
    388       temp = 0;
    389       filestream->read( reinterpret_cast<char*>(&temp), 2 );
    390       mv.setHor( (Short)temp );
    391       temp = 0;
    392       filestream->read( reinterpret_cast<char*>(&temp), 2 );
    393       mv.setVer( (Short)temp );
    394       pcCU->getCUMvField( REF_PIC_LIST_0 )->setMv( mv, partAddr );
    395 
    396       // MV L1
    397       temp = 0;
    398       filestream->read( reinterpret_cast<char*>(&temp), 2 );
    399       mv.setHor( (Short)temp );
    400       temp = 0;
    401       filestream->read( reinterpret_cast<char*>(&temp), 2 );
    402       mv.setVer( (Short)temp );
    403       pcCU->getCUMvField( REF_PIC_LIST_1 )->setMv( mv, partAddr );
    404 
    405       // set dependent information
    406       pcCU->setPredictionMode( partAddr, ( refIdxL0 == NOT_VALID && refIdxL1 == NOT_VALID ) ? MODE_INTRA : MODE_INTER );
    407       UInt interDir = ( refIdxL0 != NOT_VALID ) + ( refIdxL1 != NOT_VALID && this->getSlice(0)->isInterB() ) * 2;
    408       assert( interDir <= 3 );
    409       pcCU->setInterDir( partAddr, interDir );     
    410     }
    411   }
    412 }
    413 #endif
    414 
    415 #if SYNTAX_OUTPUT
    416 Void TComPic::wrireBLSyntax( fstream* filestream, UInt numBytes )
    417 {
    418   if( !filestream->good() )
    419   {
    420     return;
    421   }
    422 
    423   UInt   width       = this->getPicYuvRec()->getWidth();
    424   UInt   height      = this->getPicYuvRec()->getHeight();
    425 
    426   UInt64 poc        = (UInt64)this->getPOC();
    427   UInt   partWidth  = width / 4;
    428   UInt   partHeight = height / 4;
    429 
    430   UInt numPartInWidth    = this->getNumPartInWidth();
    431   UInt numPartInHeight   = this->getNumPartInHeight();
    432   UInt numPartLCUInWidth = this->getFrameWidthInCU();
    433 
    434   filestream->seekg( poc * width * height * numBytes / 16 );
    435    
    436   for( Int i = 0; i < partHeight; i++ )
    437   {
    438     for( Int j = 0; j < partWidth; j++ )
    439     {
    440       UInt x = ( j / numPartInWidth );
    441       UInt y = ( i / numPartInHeight );
    442 
    443       UInt addrLCU = y * numPartLCUInWidth + x;
    444       UInt partAddr = ( i - y * numPartInHeight ) * numPartInWidth + ( j - x * numPartInWidth );
    445       partAddr = g_auiRasterToZscan[partAddr];
    446      
    447       TComDataCU* pcCU = this->getCU( addrLCU );
    448      
    449       TComMv mv;
    450       Short temp;
    451       Char refIdxL0 = NOT_VALID, refIdxL1 = NOT_VALID;
    452 
    453       // RefIdx
    454       if( !pcCU->isIntra( partAddr ) )
    455       {
    456         refIdxL0 = (Char)pcCU->getCUMvField( REF_PIC_LIST_0 )->getRefIdx( partAddr );
    457         refIdxL1 = (Char)pcCU->getCUMvField( REF_PIC_LIST_1 )->getRefIdx( partAddr );
    458       }
    459       assert( refIdxL0 >= - 1 && refIdxL1 >= - 1 );
    460       filestream->put( refIdxL0 );
    461       filestream->put( refIdxL1 );
    462 
    463       // MV L0
    464       mv.setZero();
    465       if( refIdxL0 >= 0 )
    466       {
    467         mv = pcCU->getCUMvField( REF_PIC_LIST_0 )->getMv( partAddr );
    468       }
    469       temp = (Short)mv.getHor();
    470       filestream->write( reinterpret_cast<char*>(&temp), 2 );
    471       temp = (Short)mv.getVer();
    472       filestream->write( reinterpret_cast<char*>(&temp), 2 );
    473 
    474       // MV L1
    475       mv.setZero();
    476       if( refIdxL1 >= 0 )
    477       {
    478         mv = pcCU->getCUMvField( REF_PIC_LIST_1 )->getMv( partAddr );
    479       }
    480       temp = (Short)mv.getHor();
    481       filestream->write( reinterpret_cast<char*>(&temp), 2 );
    482       temp = (Short)mv.getVer();
    483       filestream->write( reinterpret_cast<char*>(&temp), 2 );
    484     }
    485   }
    486 }
    487359#endif
    488360
     
    529401#endif
    530402
     403#if WPP_FIX
     404UInt TComPic::getSubstreamForLCUAddr(const UInt uiLCUAddr, const Bool bAddressInRaster, TComSlice *pcSlice)
     405{
     406  const Int iNumSubstreams = pcSlice->getPPS()->getNumSubstreams();
     407  UInt uiSubStrm;
     408
     409  if (iNumSubstreams > 1) // wavefronts, and possibly tiles being used.
     410  {
     411    TComPicSym &picSym=*(getPicSym());
     412    const UInt uiLCUAddrRaster = bAddressInRaster?uiLCUAddr : picSym.getCUOrderMap(uiLCUAddr);
     413    const UInt uiWidthInLCUs  = picSym.getFrameWidthInCU();
     414    const UInt uiTileIndex=picSym.getTileIdxMap(uiLCUAddrRaster);
     415    const UInt widthInTiles=(picSym.getNumColumnsMinus1()+1);
     416    TComTile *pTile=picSym.getTComTile(uiTileIndex);
     417    const UInt uiTileStartLCU = pTile->getFirstCUAddr();
     418    const UInt uiTileLCUY = uiTileStartLCU / uiWidthInLCUs;
     419    // independent tiles => substreams are "per tile".  iNumSubstreams has already been multiplied.
     420    const UInt uiLin = uiLCUAddrRaster / uiWidthInLCUs;
     421          UInt uiStartingSubstreamForTile=(uiTileLCUY*widthInTiles) + (pTile->getTileHeight()*(uiTileIndex%widthInTiles));
     422    uiSubStrm = uiStartingSubstreamForTile + (uiLin-uiTileLCUY);
     423  }
     424  else
     425  {
     426    // dependent tiles => substreams are "per frame".
     427    uiSubStrm = 0;//uiLin % iNumSubstreams; // x modulo 1 = 0 !
     428  }
     429  return uiSubStrm;
     430}
     431#endif
     432
     433
    531434//! \}
  • trunk/source/Lib/TLibCommon/TComPic.h

    r815 r906  
    4545#include "TComBitStream.h"
    4646#include "SEI.h"
    47 #if AVC_BASE || SYNTAX_OUTPUT
     47#if AVC_BASE
    4848#include <fstream>
    4949#endif
     
    8888  Bool                  m_bSpatialEnhLayer[MAX_LAYERS];       // whether current layer is a spatial enhancement layer,
    8989  TComPicYuv*           m_pcFullPelBaseRec[MAX_LAYERS];    // upsampled base layer recontruction for difference domain inter prediction
     90#if REF_IDX_MFM
     91  Bool                  m_equalPictureSizeAndOffsetFlag[MAX_LAYERS];
     92#endif
    9093#endif
    9194#if Q0048_CGS_3D_ASYMLUT
     
    203206#endif
    204207#if REF_IDX_MFM
     208  Bool          equalPictureSizeAndOffsetFlag(UInt refLayerIdc)             { return m_equalPictureSizeAndOffsetFlag[refLayerIdc]; }
     209  Void          setEqualPictureSizeAndOffsetFlag(UInt refLayerIdc, Bool b)  { m_equalPictureSizeAndOffsetFlag[refLayerIdc] = b;    }
    205210  Void          copyUpsampledMvField  ( UInt refLayerIdc, TComPic* pcPicBase );
    206211  Void          initUpsampledMvField  ();
     
    213218#endif
    214219  Void  copyUpsampledPictureYuv(TComPicYuv*   pcPicYuvIn, TComPicYuv*   pcPicYuvOut);
    215 #if AVC_SYNTAX
    216   Void readBLSyntax( fstream* filestream, UInt numBytes );
    217 #endif
    218 #endif
    219 #if SYNTAX_OUTPUT
    220   Void wrireBLSyntax( fstream* filestream, UInt numBytes );
    221220#endif
    222221
     
    229228  Void setCurrAuFlag(Bool x) {m_currAuFlag = x; }
    230229#endif
     230#if WPP_FIX
     231  UInt          getSubstreamForLCUAddr(const UInt uiLCUAddr, const Bool bAddressInRaster, TComSlice *pcSlice);
     232#endif
    231233};// END CLASS DEFINITION TComPic
    232234
  • trunk/source/Lib/TLibCommon/TComPicSym.cpp

    r595 r906  
    3838#include "TComPicSym.h"
    3939#include "TComSampleAdaptiveOffset.h"
     40#include "TComSlice.h"
    4041
    4142//! \ingroup TLibCommon
     
    6364,m_iNumColumnsMinus1 (0)
    6465,m_iNumRowsMinus1(0)
    65 ,m_apcTComTile(NULL)
    6666,m_puiCUOrderMap(0)
    6767,m_puiTileIdxMap(NULL)
     
    101101    delete [] m_apcTComSlice;
    102102  }
    103   m_apcTComSlice      = new TComSlice*[m_uiNumCUsInFrame*m_uiNumPartitions]; 
     103  m_apcTComSlice      = new TComSlice*[m_uiNumCUsInFrame];
    104104  m_apcTComSlice[0]   = new TComSlice;
    105105  m_uiNumAllocatedSlice = 1;
     
    152152  delete [] m_apcTComDataCU;
    153153  m_apcTComDataCU = NULL;
    154 
    155 #if SVC_EXTENSION
    156   if( m_apcTComTile )
    157   {
    158 #endif
    159   for(Int i = 0; i < (m_iNumColumnsMinus1+1)*(m_iNumRowsMinus1+1); i++ )
    160   {
    161     delete m_apcTComTile[i];
    162   }
    163   delete [] m_apcTComTile;
    164 #if SVC_EXTENSION
    165   }
    166 #endif
    167 
    168   m_apcTComTile = NULL;
    169154
    170155  delete [] m_puiCUOrderMap;
     
    193178Void TComPicSym::allocateNewSlice()
    194179{
     180  assert ((m_uiNumAllocatedSlice + 1) <= m_uiNumCUsInFrame);
    195181  m_apcTComSlice[m_uiNumAllocatedSlice ++] = new TComSlice;
    196182  if (m_uiNumAllocatedSlice>=2)
     
    225211}
    226212
    227 Void TComPicSym::xCreateTComTileArray()
    228 {
    229   m_apcTComTile = new TComTile*[(m_iNumColumnsMinus1+1)*(m_iNumRowsMinus1+1)];
    230   for( UInt i=0; i<(m_iNumColumnsMinus1+1)*(m_iNumRowsMinus1+1); i++ )
    231   {
    232     m_apcTComTile[i] = new TComTile;
    233   }
    234 }
    235 
    236 Void TComPicSym::xInitTiles()
    237 {
    238   UInt  uiTileIdx;
    239   UInt  uiColumnIdx = 0;
    240   UInt  uiRowIdx = 0;
    241   UInt  uiRightEdgePosInCU;
    242   UInt  uiBottomEdgePosInCU;
    243   Int   i, j;
     213Void TComPicSym::initTiles(TComPPS *pps)
     214{
     215  //set NumColumnsMinus1 and NumRowsMinus1
     216  setNumColumnsMinus1( pps->getNumTileColumnsMinus1() );
     217  setNumRowsMinus1( pps->getTileNumRowsMinus1() );
     218
     219  const Int numCols = pps->getNumTileColumnsMinus1() + 1;
     220  const Int numRows = pps->getTileNumRowsMinus1() + 1;
     221  const Int numTiles = numRows * numCols;
     222
     223  // allocate memory for tile parameters
     224  m_tileParameters.resize(numTiles);
     225
     226  if( pps->getTileUniformSpacingFlag() )
     227  {
     228    //set width and height for each (uniform) tile
     229    for(Int row=0; row < numRows; row++)
     230  {
     231      for(Int col=0; col < numCols; col++)
     232      {
     233        const Int tileIdx = row * numCols + col;
     234        m_tileParameters[tileIdx].setTileWidth( (col+1)*getFrameWidthInCU()/numCols
     235                                              - (col*getFrameWidthInCU())/numCols );
     236        m_tileParameters[tileIdx].setTileHeight( (row+1)*getFrameHeightInCU()/numRows
     237                                               - (row*getFrameHeightInCU())/numRows );
     238      }
     239    }
     240  }
     241  else
     242  {
     243    //set the width for each tile
     244    for(Int row=0; row < numRows; row++)
     245    {
     246      Int cumulativeTileWidth = 0;
     247      for(Int col=0; col < getNumColumnsMinus1(); col++)
     248      {
     249        m_tileParameters[row * numCols + col].setTileWidth( pps->getTileColumnWidth(col) );
     250        cumulativeTileWidth += pps->getTileColumnWidth(col);
     251      }
     252      m_tileParameters[row * numCols + getNumColumnsMinus1()].setTileWidth( getFrameWidthInCU()-cumulativeTileWidth );
     253  }
     254
     255    //set the height for each tile
     256    for(Int col=0; col < numCols; col++)
     257    {
     258      Int cumulativeTileHeight = 0;
     259      for(Int row=0; row < getNumRowsMinus1(); row++)
     260      {
     261        m_tileParameters[row * numCols + col].setTileHeight( pps->getTileRowHeight(row) );
     262        cumulativeTileHeight += pps->getTileRowHeight(row);
     263      }
     264      m_tileParameters[getNumRowsMinus1() * numCols + col].setTileHeight( getFrameHeightInCU()-cumulativeTileHeight );
     265    }
     266  }
     267
     268#if TILE_SIZE_CHECK
     269  Int minWidth  = 1;
     270  Int minHeight = 1;
     271  const Int profileIdc = pps->getSPS()->getPTL()->getGeneralPTL()->getProfileIdc();
     272  if (  profileIdc == Profile::MAIN || profileIdc == Profile::MAIN10)
     273  {
     274    if (pps->getTilesEnabledFlag())
     275    {
     276      minHeight = 64  / g_uiMaxCUHeight;
     277      minWidth  = 256 / g_uiMaxCUWidth;
     278    }
     279  }
     280  for(Int row=0; row < numRows; row++)
     281  {
     282    for(Int col=0; col < numCols; col++)
     283    {
     284      const Int tileIdx = row * numCols + col;
     285      assert (m_tileParameters[tileIdx].getTileWidth() >= minWidth);
     286      assert (m_tileParameters[tileIdx].getTileHeight() >= minHeight);
     287    }
     288  }
     289#endif
    244290
    245291  //initialize each tile of the current picture
    246   for( uiRowIdx=0; uiRowIdx < m_iNumRowsMinus1+1; uiRowIdx++ )
    247   {
    248     for( uiColumnIdx=0; uiColumnIdx < m_iNumColumnsMinus1+1; uiColumnIdx++ )
    249     {
    250       uiTileIdx = uiRowIdx * (m_iNumColumnsMinus1+1) + uiColumnIdx;
     292  for( Int row=0; row < numRows; row++ )
     293  {
     294    for( Int col=0; col < numCols; col++ )
     295    {
     296      const Int tileIdx = row * numCols + col;
    251297
    252298      //initialize the RightEdgePosInCU for each tile
    253       uiRightEdgePosInCU = 0;
    254       for( i=0; i <= uiColumnIdx; i++ )
    255       {
    256         uiRightEdgePosInCU += this->getTComTile(uiRowIdx * (m_iNumColumnsMinus1+1) + i)->getTileWidth();
    257       }
    258       this->getTComTile(uiTileIdx)->setRightEdgePosInCU(uiRightEdgePosInCU-1);
     299      Int rightEdgePosInCTU = 0;
     300      for( Int i=0; i <= col; i++ )
     301      {
     302        rightEdgePosInCTU += m_tileParameters[row * numCols + i].getTileWidth();
     303      }
     304      m_tileParameters[tileIdx].setRightEdgePosInCU(rightEdgePosInCTU-1);
    259305
    260306      //initialize the BottomEdgePosInCU for each tile
    261       uiBottomEdgePosInCU = 0;
    262       for( i=0; i <= uiRowIdx; i++ )
    263       {
    264         uiBottomEdgePosInCU += this->getTComTile(i * (m_iNumColumnsMinus1+1) + uiColumnIdx)->getTileHeight();
    265       }
    266       this->getTComTile(uiTileIdx)->setBottomEdgePosInCU(uiBottomEdgePosInCU-1);
     307      Int bottomEdgePosInCTU = 0;
     308      for( Int i=0; i <= row; i++ )
     309      {
     310        bottomEdgePosInCTU += m_tileParameters[i * numCols + col].getTileHeight();
     311      }
     312      m_tileParameters[tileIdx].setBottomEdgePosInCU(bottomEdgePosInCTU-1);
    267313
    268314      //initialize the FirstCUAddr for each tile
    269       this->getTComTile(uiTileIdx)->setFirstCUAddr( (this->getTComTile(uiTileIdx)->getBottomEdgePosInCU() - this->getTComTile(uiTileIdx)->getTileHeight() +1)*m_uiWidthInCU +
    270         this->getTComTile(uiTileIdx)->getRightEdgePosInCU() - this->getTComTile(uiTileIdx)->getTileWidth() + 1);
    271     }
    272   }
     315      m_tileParameters[tileIdx].setFirstCUAddr( (m_tileParameters[tileIdx].getBottomEdgePosInCU() - m_tileParameters[tileIdx].getTileHeight() + 1) * getFrameWidthInCU() +
     316                                                 m_tileParameters[tileIdx].getRightEdgePosInCU() - m_tileParameters[tileIdx].getTileWidth() + 1);
     317    }
     318  }
     319
     320  Int  columnIdx = 0;
     321  Int  rowIdx = 0;
    273322
    274323  //initialize the TileIdxMap
    275   for( i=0; i<m_uiNumCUsInFrame; i++)
    276   {
    277     for(j=0; j < m_iNumColumnsMinus1+1; j++)
    278     {
    279       if(i % m_uiWidthInCU <= this->getTComTile(j)->getRightEdgePosInCU())
    280       {
    281         uiColumnIdx = j;
    282         j = m_iNumColumnsMinus1+1;
    283       }
    284     }
    285     for(j=0; j < m_iNumRowsMinus1+1; j++)
    286     {
    287       if(i/m_uiWidthInCU <= this->getTComTile(j*(m_iNumColumnsMinus1 + 1))->getBottomEdgePosInCU())
    288       {
    289         uiRowIdx = j;
    290         j = m_iNumRowsMinus1 + 1;
    291       }
    292     }
    293     m_puiTileIdxMap[i] = uiRowIdx * (m_iNumColumnsMinus1 + 1) + uiColumnIdx;
    294   }
    295 
     324  for( Int i=0; i<m_uiNumCUsInFrame; i++)
     325  {
     326    for( Int col=0; col < numCols; col++)
     327    {
     328      if(i % getFrameWidthInCU() <= m_tileParameters[col].getRightEdgePosInCU())
     329      {
     330        columnIdx = col;
     331        break;
     332      }
     333    }
     334    for(Int row=0; row < numRows; row++)
     335    {
     336      if(i / getFrameWidthInCU() <= m_tileParameters[row*numCols].getBottomEdgePosInCU())
     337      {
     338        rowIdx = row;
     339        break;
     340      }
     341    }
     342    m_puiTileIdxMap[i] = rowIdx * numCols + columnIdx;
     343  }
    296344}
    297345
     
    441489
    442490TComTile::TComTile()
     491: m_uiTileWidth         (0)
     492, m_uiTileHeight        (0)
     493, m_uiRightEdgePosInCU  (0)
     494, m_uiBottomEdgePosInCU (0)
     495, m_uiFirstCUAddr       (0)
     496
    443497{
    444498}
  • trunk/source/Lib/TLibCommon/TComPicSym.h

    r595 r906  
    4545#include "TComDataCU.h"
    4646class TComSampleAdaptiveOffset;
     47class TComPPS;
    4748
    4849//! \ingroup TLibCommon
     
    102103  Int           m_iNumColumnsMinus1;
    103104  Int           m_iNumRowsMinus1;
    104   TComTile**    m_apcTComTile;
     105  std::vector<TComTile> m_tileParameters;
    105106  UInt*         m_puiCUOrderMap;       //the map of LCU raster scan address relative to LCU encoding order
    106107  UInt*         m_puiTileIdxMap;       //the map of the tile index relative to LCU raster scan address
     
    142143  Int          getNumRowsMinus1()                                    { return m_iNumRowsMinus1; }
    143144  Int          getNumTiles()                                         { return (m_iNumRowsMinus1+1)*(m_iNumColumnsMinus1+1); }
    144   TComTile*    getTComTile  ( UInt tileIdx )                         { return *(m_apcTComTile + tileIdx); }
     145  TComTile*    getTComTile  ( UInt tileIdx )                         { return &(m_tileParameters[tileIdx]); }
    145146  Void         setCUOrderMap( Int encCUOrder, Int cuAddr )           { *(m_puiCUOrderMap + encCUOrder) = cuAddr; }
    146147  UInt         getCUOrderMap( Int encCUOrder )                       { return *(m_puiCUOrderMap + (encCUOrder>=m_uiNumCUsInFrame ? m_uiNumCUsInFrame : encCUOrder)); }
     
    150151  UInt         getPicSCUEncOrder( UInt SCUAddr );
    151152  UInt         getPicSCUAddr( UInt SCUEncOrder );
    152   Void         xCreateTComTileArray();
    153   Void         xInitTiles();
     153  Void         initTiles(TComPPS *pps);
    154154  UInt         xCalculateNxtCUAddr( UInt uiCurrCUAddr );
    155155  SAOBlkParam* getSAOBlkParam() { return m_saoBlkParams;}
     
    160160  UInt        getMaxCUWidth()           { return m_uiMaxCUWidth;                }
    161161  UInt        getMaxCUHeight()          { return m_uiMaxCUHeight;               }
    162 #endif
    163 #if AVC_SYNTAX
    164   UInt        getMaxCUWidth()           { return m_uiMaxCUWidth;                }
    165   UInt        getMaxCUHeight()          { return m_uiMaxCUHeight;               }
    166   UInt        getMaxDepth()             { return m_uhTotalDepth;               }
    167162#endif
    168163#if N0383_IL_CONSTRAINED_TILE_SETS_SEI
  • trunk/source/Lib/TLibCommon/TComPicYuv.cpp

    r815 r906  
    6969
    7070#if SVC_EXTENSION
     71#if R0156_CONF_WINDOW_IN_REP_FORMAT
     72#if AUXILIARY_PICTURES
     73Void TComPicYuv::create( Int iPicWidth, Int iPicHeight, ChromaFormat chromaFormatIDC, UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiMaxCUDepth, Window* conformanceWindow )
     74#else
     75Void TComPicYuv::create( Int iPicWidth, Int iPicHeight, UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiMaxCUDepth, Window* conformanceWindow )
     76#endif
     77#else // R0156_CONF_WINDOW_IN_REP_FORMAT
    7178#if AUXILIARY_PICTURES
    7279Void TComPicYuv::create( Int iPicWidth, Int iPicHeight, ChromaFormat chromaFormatIDC, UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiMaxCUDepth, TComSPS* pcSps )
     
    7481Void TComPicYuv::create( Int iPicWidth, Int iPicHeight, UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiMaxCUDepth, TComSPS* pcSps )
    7582#endif
     83#endif
    7684#else
    7785Void TComPicYuv::create( Int iPicWidth, Int iPicHeight, UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiMaxCUDepth )
     
    8290 
    8391#if SVC_EXTENSION
     92#if R0156_CONF_WINDOW_IN_REP_FORMAT
     93  if(conformanceWindow != NULL)
     94  {
     95    m_conformanceWindow = *conformanceWindow;
     96  }
     97#else
    8498  if(pcSps != NULL)
    8599  {
    86100    m_conformanceWindow = pcSps->getConformanceWindow();
    87101  }
     102#endif
    88103#endif
    89104
     
    366381}
    367382
    368 #if SVC_EXTENSION
    369383Void TComPicYuv::dump( Char* pFileName, Bool bAdd, Int bitDepth )
    370384{
     
    431445}
    432446
    433 #endif
    434 
    435447//! \}
  • trunk/source/Lib/TLibCommon/TComPicYuv.h

    r815 r906  
    111111  // ------------------------------------------------------------------------------------------------
    112112#if SVC_EXTENSION
     113#if R0156_CONF_WINDOW_IN_REP_FORMAT
     114#if AUXILIARY_PICTURES
     115  Void  create      ( Int iPicWidth, Int iPicHeight, ChromaFormat chromaFormatIDC, UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiMaxCUDepth, Window* conformanceWindow = NULL);
     116#else
     117  Void  create      ( Int iPicWidth, Int iPicHeight, UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiMaxCUDepth, Window* conformanceWindow = NULL);
     118#endif
     119#else
    113120#if AUXILIARY_PICTURES
    114121  Void  create      ( Int iPicWidth, Int iPicHeight, ChromaFormat chromaFormatIDC, UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiMaxCUDepth, TComSPS* pcSps = NULL);
    115122#else
    116123  Void  create      ( Int iPicWidth, Int iPicHeight, UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiMaxCUDepth, TComSPS* pcSps = NULL);
     124#endif
    117125#endif
    118126#else
     
    191199  Void convertToMonochrome();
    192200#endif
     201#endif //SVC_EXTENSION
    193202  Void dump( Char* pFileName, Bool bAdd, Int bitDepth );
    194 #endif //SVC_EXTENSION
    195203
    196204};// END CLASS DEFINITION TComPicYuv
  • trunk/source/Lib/TLibCommon/TComPrediction.cpp

    r815 r906  
    796796#else
    797797#if O0194_JOINT_US_BITSHIFT
     798#if REF_REGION_OFFSET
     799Void TComPrediction::upsampleBasePic( UInt refLayerIdc, TComPicYuv* pcUsPic, TComPicYuv* pcBasePic, TComPicYuv* pcTempPic, const Window window, const Window altRefWindow )
     800{
     801  m_cUsf.upsampleBasePic( refLayerIdc, pcUsPic, pcBasePic, pcTempPic, window, altRefWindow );
     802}
     803#else
    798804Void TComPrediction::upsampleBasePic( TComSlice* currSlice, UInt refLayerIdc, TComPicYuv* pcUsPic, TComPicYuv* pcBasePic, TComPicYuv* pcTempPic, const Window window)
    799805{
    800806  m_cUsf.upsampleBasePic( refLayerIdc, pcUsPic, pcBasePic, pcTempPic, window);
    801807}
     808#endif
    802809#else
    803810Void TComPrediction::upsampleBasePic( UInt refLayerIdc, TComPicYuv* pcUsPic, TComPicYuv* pcBasePic, TComPicYuv* pcTempPic, const Window window)
  • trunk/source/Lib/TLibCommon/TComPrediction.h

    r815 r906  
    126126#else
    127127#if O0194_JOINT_US_BITSHIFT
     128#if REF_REGION_OFFSET
     129  Void upsampleBasePic( TComSlice* currSlice, UInt refLayerIdc, TComPicYuv* pcUsPic, TComPicYuv* pcBasePic, TComPicYuv* pcTempPic, const Window window, const Window altRefWindow );
     130#else
    128131  Void upsampleBasePic( TComSlice* currSlice, UInt refLayerIdc, TComPicYuv* pcUsPic, TComPicYuv* pcBasePic, TComPicYuv* pcTempPic, const Window window );
     132#endif
    129133#else
    130134  Void upsampleBasePic( UInt refLayerIdc, TComPicYuv* pcUsPic, TComPicYuv* pcBasePic, TComPicYuv* pcTempPic, const Window window );
  • trunk/source/Lib/TLibCommon/TComSlice.cpp

    r815 r906  
    3636*/
    3737
     38#include <numeric>
    3839#include "CommonDef.h"
    3940#include "TComSlice.h"
     
    4748#if SVC_EXTENSION
    4849ParameterSetMap<TComVPS> ParameterSetManager::m_vpsMap(MAX_NUM_VPS);
     50ParameterSetMap<TComSPS> ParameterSetManager::m_spsMap(MAX_NUM_SPS);
     51ParameterSetMap<TComPPS> ParameterSetManager::m_ppsMap(MAX_NUM_PPS);
    4952Int ParameterSetManager::m_activeVPSId = -1;
    5053#endif
     
    104107, m_temporalLayerNonReferenceFlag ( false )
    105108, m_enableTMVPFlag                ( true )
     109#if R0226_SLICE_TMVP
     110, m_availableForTMVPRefFlag       ( true )
     111#endif
    106112#if SVC_EXTENSION
    107113, m_layerId                     ( 0 )
     
    124130, m_pocMsbValRequiredFlag         ( false )
    125131, m_pocMsbValPresentFlag          ( false )
     132#if P0297_VPS_POC_LSB_ALIGNED_FLAG
     133, m_pocMsbValNeeded               ( false )
     134#endif
    126135#endif
    127136#if POC_RESET_IDC_DECODER || POC_RESET_IDC_ENCODER
     
    215224  m_picOrderCntLsb = 0;
    216225#endif
     226#if P0297_VPS_POC_LSB_ALIGNED_FLAG
     227  m_pocMsbValNeeded  = false;
     228  m_pocResetDeltaPoc = 0;
     229#endif
    217230}
    218231
     
    265278  }
    266279}
     280
    267281Int TComSlice::getCurrMsb( Int currLsb, Int prevLsb, Int prevMsb, Int maxLsbVal )
    268282{
     
    281295}
    282296#endif
     297
    283298/**
    284299 - allocate table to contain substream sizes to be written to the slice header.
     
    516531#endif
    517532
    518 #if SVC_EXTENSION
    519   for( i = 0; i < m_activeNumILRRefIdx; i++ )
    520   {
    521     UInt refLayerIdc = m_interLayerPredLayerIdc[i];
    522     //inter-layer reference picture
    523 #if O0225_MAX_TID_FOR_REF_LAYERS
    524     Int maxTidIlRefPicsPlus1 = ( m_layerId > 0 && m_activeNumILRRefIdx > 0)? m_pcVPS->getMaxTidIlRefPicsPlus1(ilpPic[refLayerIdc]->getSlice(0)->getLayerId(),m_layerId) : 0;
    525 #else
    526     Int maxTidIlRefPicsPlus1 = ( m_layerId > 0 && m_activeNumILRRefIdx > 0)? m_pcVPS->getMaxTidIlRefPicsPlus1(ilpPic[refLayerIdc]->getSlice(0)->getLayerId()) : 0;
    527 #endif
    528     if( m_layerId > 0 && m_activeNumILRRefIdx > 0 && ( ( (Int)(ilpPic[refLayerIdc]->getSlice(0)->getTLayer())<=  maxTidIlRefPicsPlus1-1) || (maxTidIlRefPicsPlus1==0 && ilpPic[refLayerIdc]->getSlice(0)->getRapPicFlag()) )  )
    529     {
    530 #if REF_IDX_MFM
    531       if(!(m_eNalUnitType >= NAL_UNIT_CODED_SLICE_BLA_W_LP && m_eNalUnitType <= NAL_UNIT_CODED_SLICE_CRA) && getMFMEnabledFlag())
    532       {
    533         ilpPic[refLayerIdc]->copyUpsampledMvField( refLayerIdc, m_pcBaseColPic[refLayerIdc] );
    534       }
    535       else
    536       {
    537         ilpPic[refLayerIdc]->initUpsampledMvField();
    538       }
    539 #endif
    540       ilpPic[refLayerIdc]->setIsLongTerm(1);
    541     }
    542   }
    543 #endif
    544533  // ref_pic_list_init
    545534  TComPic*  rpsCurrList0[MAX_NUM_REF+1];
     
    595584        UInt refLayerId = m_pcVPS->getRefLayerId( m_layerId, refLayerIdc );
    596585#if RESAMPLING_CONSTRAINT_BUG_FIX
     586#if MOVE_SCALED_OFFSET_TO_PPS
     587#if O0098_SCALED_REF_LAYER_ID
     588        const Window &scalEL = getPPS()->getScaledRefLayerWindowForLayer(refLayerId);
     589#else
     590        const Window &scalEL = getPPS()->getScaledRefLayerWindow(m_interLayerPredLayerIdc[i]);
     591#endif
     592#else
    597593#if O0098_SCALED_REF_LAYER_ID
    598594        const Window &scalEL = getSPS()->getScaledRefLayerWindowForLayer(refLayerId);
    599595#else
    600596        const Window &scalEL = getSPS()->getScaledRefLayerWindow(m_interLayerPredLayerIdc[i]);
     597#endif
    601598#endif
    602599        Int scalingOffset = ((scalEL.getWindowLeftOffset()   == 0 ) &&
     
    19421939  Int nrOfPositivePictures = 0;
    19431940  TComReferencePictureSet* pcRPS = this->getLocalRPS();
     1941#if P0297_VPS_POC_LSB_ALIGNED_FLAG
     1942  Bool pocsAdjusted = false;
     1943#endif
    19441944
    19451945  // loop through all pictures in the Reference Picture Set
     
    19541954      rpcPic = *(iterPic++);
    19551955
     1956#if P0297_VPS_POC_LSB_ALIGNED_FLAG
     1957      // poc adjustement by poc reset needs to be taken into account here
     1958      Int deltaPOC = pReferencePictureSet->getDeltaPOC(i) - rpcPic->getPicSym()->getSlice(0)->getPocResetDeltaPoc();
     1959      if (rpcPic->getPicSym()->getSlice(0)->getPocResetDeltaPoc() != 0)
     1960      {
     1961        pocsAdjusted = true;
     1962      }
     1963
     1964      if (rpcPic->getPicSym()->getSlice(0)->getPOC() == this->getPOC() + deltaPOC && rpcPic->getSlice(0)->isReferenced())
     1965#else
    19561966      if(rpcPic->getPicSym()->getSlice(0)->getPOC() == this->getPOC() + pReferencePictureSet->getDeltaPOC(i) && rpcPic->getSlice(0)->isReferenced())
     1967#endif
    19571968      {
    19581969        // This picture exists as a reference picture
    19591970        // and should be added to the explicit Reference Picture Set
     1971#if P0297_VPS_POC_LSB_ALIGNED_FLAG
     1972        pcRPS->setDeltaPOC(k, deltaPOC);
     1973#else
    19601974        pcRPS->setDeltaPOC(k, pReferencePictureSet->getDeltaPOC(i));
     1975#endif
    19611976        pcRPS->setUsed(k, pReferencePictureSet->getUsed(i) && (!isRAP));
    19621977#if ALLOW_RECOVERY_POINT_AS_RAP
     1978#if P0297_VPS_POC_LSB_ALIGNED_FLAG
     1979        pcRPS->setUsed(k, pcRPS->getUsed(k) && !(bUseRecoveryPoint && this->getPOC() > pocRandomAccess && this->getPOC() + deltaPOC < pocRandomAccess) );
     1980#else
    19631981        pcRPS->setUsed(k, pcRPS->getUsed(k) && !(bUseRecoveryPoint && this->getPOC() > pocRandomAccess && this->getPOC() + pReferencePictureSet->getDeltaPOC(i) < pocRandomAccess) );
     1982#endif
    19641983#endif
    19651984        if(pcRPS->getDeltaPOC(k) < 0)
     
    20052024    || useNewRPS
    20062025#endif
     2026#if P0297_VPS_POC_LSB_ALIGNED_FLAG
     2027    || pocsAdjusted  // inter RPS prediction does not work if POCs have been adjusted
     2028#endif
    20072029    )
    20082030  {
     
    21392161  UInt retVal, layerId = getLayerId();
    21402162#if O0096_REP_FORMAT_INDEX
     2163#if R0279_REP_FORMAT_INBL
     2164  if ( layerId == 0 || sps->getV1CompatibleSPSFlag() == 1 )
     2165  {
     2166#if VPS_AVC_BL_FLAG_REMOVAL
     2167    if( layerId == 0 && vps->getNonHEVCBaseLayerFlag() )
     2168#else
     2169    if( layerId == 0 && vps->getAvcBaseLayerFlag() )
     2170#endif
     2171#else
    21412172  if ( layerId == 0 )
    21422173  {
    21432174    if( vps->getAvcBaseLayerFlag() )
     2175#endif
    21442176    {
    21452177      retVal = vps->getVpsRepFormat(layerId)->getPicWidthVpsInLumaSamples();
     
    21722204  UInt retVal, layerId = getLayerId();
    21732205#if O0096_REP_FORMAT_INDEX
    2174   if( layerId == 0 )
     2206#if R0279_REP_FORMAT_INBL
     2207  if ( layerId == 0 || sps->getV1CompatibleSPSFlag() == 1 )
     2208  {
     2209#if VPS_AVC_BL_FLAG_REMOVAL
     2210    if( layerId == 0 && vps->getNonHEVCBaseLayerFlag() )
     2211#else
     2212    if( layerId == 0 && vps->getAvcBaseLayerFlag() )
     2213#endif
     2214#else
     2215  if ( layerId == 0 )
    21752216  {
    21762217    if( vps->getAvcBaseLayerFlag() )
     2218#endif
    21772219    {
    21782220      retVal = vps->getVpsRepFormat(layerId)->getPicHeightVpsInLumaSamples();
     
    22142256#endif
    22152257#if O0096_REP_FORMAT_INDEX
    2216   if( layerId == 0 )
     2258#if R0279_REP_FORMAT_INBL
     2259  if ( layerId == 0 || sps->getV1CompatibleSPSFlag() == 1 )
     2260  {
     2261#if VPS_AVC_BL_FLAG_REMOVAL
     2262    if( layerId == 0 && vps->getNonHEVCBaseLayerFlag() )
     2263#else
     2264    if( layerId == 0 && vps->getAvcBaseLayerFlag() )
     2265#endif
     2266#else
     2267  if ( layerId == 0 )
    22172268  {
    22182269    if( vps->getAvcBaseLayerFlag() )
     2270#endif
    22192271    {
    22202272      retVal = vps->getVpsRepFormat(layerId)->getChromaFormatVpsIdc();
     
    22472299  UInt retVal, layerId = getLayerId();
    22482300#if O0096_REP_FORMAT_INDEX
    2249   if( layerId == 0 )
     2301#if R0279_REP_FORMAT_INBL
     2302  if ( layerId == 0 || sps->getV1CompatibleSPSFlag() == 1 )
     2303#else
     2304  if ( layerId == 0 )
     2305#endif
    22502306  {
    22512307    retVal = sps->getBitDepthY();
     
    22732329  UInt retVal, layerId = getLayerId();
    22742330#if O0096_REP_FORMAT_INDEX
    2275   if( layerId == 0 )
     2331#if R0279_REP_FORMAT_INBL
     2332  if ( layerId == 0 || sps->getV1CompatibleSPSFlag() == 1 )
     2333#else
     2334  if ( layerId == 0 )
     2335#endif
    22762336  {
    22772337    retVal = sps->getBitDepthC();
     
    23012361  return (getBitDepthC() - 8) * 6;
    23022362}
     2363
     2364#if R0156_CONF_WINDOW_IN_REP_FORMAT
     2365Window& TComSlice::getConformanceWindow()
     2366{
     2367  TComSPS *sps = getSPS();
     2368  TComVPS *vps = getVPS();
     2369  UInt layerId = getLayerId();
     2370#if O0096_REP_FORMAT_INDEX
     2371#if R0279_REP_FORMAT_INBL
     2372  if ( layerId == 0 || sps->getV1CompatibleSPSFlag() == 1 )
     2373  {
     2374#if VPS_AVC_BL_FLAG_REMOVAL
     2375    if( layerId == 0 && vps->getNonHEVCBaseLayerFlag() )
     2376#else
     2377    if( layerId == 0 && vps->getAvcBaseLayerFlag() )
     2378#endif
     2379#else
     2380  if ( layerId == 0 )
     2381  {
     2382    if( vps->getAvcBaseLayerFlag() )
     2383#endif
     2384    {
     2385      return vps->getVpsRepFormat(layerId)->getConformanceWindowVps();
     2386    }
     2387    else
     2388    {
     2389      return sps->getConformanceWindow();
     2390    }
     2391  }
     2392  else
     2393  {
     2394    return vps->getVpsRepFormat( vps->getVpsRepFormatIdx(sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : layerId) )->getConformanceWindowVps();
     2395  }
     2396#else
     2397  if( ( layerId == 0 ) || sps->getUpdateRepFormatFlag() )
     2398  {
     2399    return sps->getConformanceWindow();
     2400  }
     2401  else
     2402  {
     2403    return vps->getVpsRepFormat( vps->getVpsRepFormatIdx(layerId) )->getConformanceWindowVps();
     2404  }
     2405#endif
     2406}
     2407#endif
    23032408
    23042409RepFormat::RepFormat()
     
    23232428  m_bitDepthVpsLuma             = 0;
    23242429  m_bitDepthVpsChroma           = 0;
     2430#if R0156_CONF_WINDOW_IN_REP_FORMAT
     2431  m_conformanceWindowVps.resetWindow();
     2432#endif
    23252433}
    23262434#endif
     
    23332441TComVPS::TComVPS()
    23342442: m_VPSId                     (  0)
     2443#if VPS_RESERVED_FLAGS
     2444, m_baseLayerInternalFlag     (true)
     2445, m_baseLayerAvailableFlag    (true)
     2446#endif
    23352447, m_uiMaxTLayers              (  1)
    23362448, m_uiMaxLayers               (  1)
     
    23842496, m_vpsNonVuiExtLength (0)
    23852497#endif
     2498#if P0297_VPS_POC_LSB_ALIGNED_FLAG
     2499, m_vpsPocLsbAlignedFlag(false)
     2500#endif
    23862501{
    23872502  for( Int i = 0; i < MAX_TLAYER; i++)
     
    23922507  }
    23932508#if VPS_EXTN_MASK_AND_DIM_INFO
     2509#if VPS_AVC_BL_FLAG_REMOVAL
     2510  m_nonHEVCBaseLayerFlag = false;
     2511#else
    23942512  m_avcBaseLayerFlag = false;
     2513#endif
    23952514  m_splittingFlag = false;
    23962515  ::memset(m_scalabilityMask, 0, sizeof(m_scalabilityMask));
     
    24222541  ::memset(m_directDependencyType, 0, sizeof(m_directDependencyType));
    24232542#endif
     2543#if !NECESSARY_LAYER_FLAG
    24242544#if DERIVE_LAYER_ID_LIST_VARIABLES
    24252545  ::memset(m_layerSetLayerIdList,  0, sizeof(m_layerSetLayerIdList));
    24262546  ::memset(m_numLayerInIdList,     0, sizeof(m_numLayerInIdList   ));
    24272547#endif
     2548#endif
     2549#if !PER_LAYER_PTL
    24282550  ::memset(m_profileLevelTierIdx,  0, sizeof(m_profileLevelTierIdx));
     2551#endif
    24292552  m_maxOneActiveRefLayerFlag = true;
    24302553#if O0062_POC_LSB_NOT_PRESENT_FLAG
     
    25422665}
    25432666#if DERIVE_LAYER_ID_LIST_VARIABLES
     2667#if NECESSARY_LAYER_FLAG
     2668Void TComVPS::deriveLayerIdListVariables()
     2669{
     2670  // For layer 0
     2671  m_numLayerInIdList.push_back(1);
     2672  m_layerSetLayerIdList.resize(m_numLayerSets);
     2673  m_layerSetLayerIdList[0].push_back(0);
     2674 
     2675  // For other layers
     2676  for( Int i = 1; i < m_numLayerSets; i++ )
     2677  {
     2678    for( Int m = 0; m <= m_maxLayerId; m++)
     2679    {
     2680      if( m_layerIdIncludedFlag[i][m] )
     2681      {
     2682        m_layerSetLayerIdList[i].push_back(m);
     2683      }
     2684    }
     2685    m_numLayerInIdList.push_back(m_layerSetLayerIdList[i].size());
     2686  }
     2687}
     2688#else
    25442689Void TComVPS::deriveLayerIdListVariables()
    25452690{
     
    25642709}
    25652710#endif
     2711#endif
    25662712#if !RESOLUTION_BASED_DPB
    25672713#if VPS_DPB_SIZE_TABLE
     
    26602806Void TComVPS::setPredictedLayerIds()
    26612807{
    2662   for (UInt i = 0; i < getMaxLayers() - 1; i++)
    2663   {
    2664     UInt iNuhLId = getLayerIdInNuh(i);
     2808  for (UInt i = 0; i < m_uiMaxLayers - 1; i++)
     2809  {
     2810    UInt iNuhLId = m_layerIdInNuh[i];
    26652811    UInt predIdx = 0;
    26662812    for (UInt j = iNuhLId + 1; j < MAX_NUM_LAYER_IDS; j++)
    26672813    {
    2668       if (getRecursiveRefLayerFlag(j, iNuhLId))
    2669       {
    2670         setPredictedLayerId(i, predIdx, j);
     2814      if( m_recursiveRefLayerFlag[j][iNuhLId] )
     2815      {
     2816        m_predictedLayerId[iNuhLId][predIdx] = j;
    26712817        predIdx++;
    26722818      }
    26732819    }
    2674     setNumPredictedLayers(iNuhLId, predIdx);
    2675   }
     2820    m_numPredictedLayers[iNuhLId] = predIdx;
     2821  }
     2822  m_numPredictedLayers[m_layerIdInNuh[m_uiMaxLayers-1]] = 0;
    26762823}
    26772824
     
    26792826{
    26802827  Bool countedLayerIdxFlag[MAX_NUM_LAYER_IDS];
    2681 
    2682   for (UInt i = 0; i <= getMaxLayers() - 1; i++)
    2683   {
    2684     countedLayerIdxFlag[i] = false;
    2685   }
     2828  memset( countedLayerIdxFlag, 0, sizeof(countedLayerIdxFlag) );
    26862829
    26872830  Int numIndependentLayers = 0;
    26882831
    2689   for (UInt i = 0; i <= getMaxLayers() - 1; i++)
    2690   {
    2691     UInt iNuhLId = getLayerIdInNuh(i);
    2692     if (getNumDirectRefLayers(iNuhLId) == 0)
    2693     {
    2694       setTreePartitionLayerId(numIndependentLayers, 0, iNuhLId);
    2695       setNumLayersInTreePartition(numIndependentLayers, 1);
    2696       for (UInt j = 0; j < getNumPredictedLayers(iNuhLId); j++)
    2697       {
    2698         if (!countedLayerIdxFlag[getLayerIdInVps(iNuhLId)])
    2699         {
    2700           setTreePartitionLayerId(numIndependentLayers, getNumLayersInTreePartition(numIndependentLayers), getPredictedLayerId(iNuhLId, j));
    2701           setNumLayersInTreePartition(numIndependentLayers, getNumLayersInTreePartition(numIndependentLayers) + 1);
    2702           countedLayerIdxFlag[getLayerIdInVps(getPredictedLayerId(iNuhLId, j))] = true;
     2832  for (UInt i = 0; i < m_uiMaxLayers; i++)
     2833  {
     2834    UInt iNuhLId = m_layerIdInNuh[i];
     2835    if( m_numDirectRefLayers[iNuhLId] == 0 )
     2836    {
     2837      m_treePartitionLayerIdList[numIndependentLayers][0] = iNuhLId;
     2838      m_numLayersInTreePartition[numIndependentLayers] = 1;
     2839      for( UInt j = 0; j < m_numPredictedLayers[iNuhLId]; j++ )
     2840      {
     2841        if( !countedLayerIdxFlag[m_layerIdInVps[iNuhLId]] )
     2842        {
     2843          m_treePartitionLayerIdList[numIndependentLayers][m_numLayersInTreePartition[numIndependentLayers]] = m_predictedLayerId[iNuhLId][j];
     2844          m_numLayersInTreePartition[numIndependentLayers] = m_numLayersInTreePartition[numIndependentLayers] + 1;
     2845          countedLayerIdxFlag[m_layerIdInVps[m_predictedLayerId[iNuhLId][j]]] = true;
    27032846        }
    27042847      }
     
    27072850  }
    27082851
    2709   setNumIndependentLayers(numIndependentLayers);
     2852  m_numIndependentLayers = numIndependentLayers;
    27102853}
    27112854
    27122855void TComVPS::setLayerIdIncludedFlagsForAddLayerSets()
    27132856{
    2714   for (UInt i = 0; i < getNumAddLayerSets(); i++)
    2715   {
    2716     for (UInt j = 1; j < getNumIndependentLayers(); j++)
     2857  for (UInt i = 0; i < m_numAddLayerSets; i++)
     2858  {
     2859    for (UInt j = 1; j < m_numIndependentLayers; j++)
    27172860    {
    27182861      Int layerNum = 0;
    2719       Int lsIdx = getVpsNumLayerSetsMinus1() + 1 + i;
     2862      Int lsIdx = m_vpsNumLayerSetsMinus1 + 1 + i;
    27202863      for (Int layerId = 0; layerId < MAX_VPS_LAYER_ID_PLUS1; layerId++)
    27212864      {
    2722         setLayerIdIncludedFlag(false, lsIdx, layerId);
    2723       }
    2724       for (Int treeIdx = 1; treeIdx < getNumIndependentLayers(); treeIdx++)
    2725       {
    2726         for (Int layerCnt = 0; layerCnt < getHighestLayerIdxPlus1(i, j); layerCnt++)
    2727         {
    2728           setLayerSetLayerIdList(lsIdx, layerNum, getTreePartitionLayerId(treeIdx, layerCnt));
    2729           setLayerIdIncludedFlag(true, lsIdx, getTreePartitionLayerId(treeIdx, layerCnt));
     2865        m_layerIdIncludedFlag[lsIdx][layerId] = false;
     2866      }
     2867      for (Int treeIdx = 1; treeIdx < m_numIndependentLayers; treeIdx++)
     2868      {
     2869        for (Int layerCnt = 0; layerCnt < m_highestLayerIdxPlus1[i][j]; layerCnt++)
     2870        {
     2871          m_layerSetLayerIdList[lsIdx][layerNum] = m_treePartitionLayerIdList[treeIdx][layerCnt];
     2872          m_layerIdIncludedFlag[lsIdx][m_treePartitionLayerIdList[treeIdx][layerCnt]] = true;
    27302873          layerNum++;
    27312874        }
    27322875      }
    2733       setNumLayersInIdList(lsIdx, layerNum);
     2876      m_numLayerInIdList[lsIdx] = layerNum;
    27342877    }
    27352878  }
     
    29793122}
    29803123#endif
     3124#if NECESSARY_LAYER_FLAG
     3125Void TComVPS::deriveNecessaryLayerFlag()
     3126{
     3127  m_necessaryLayerFlag.empty();
     3128  m_numNecessaryLayers.empty();
     3129  // Assumed that output layer sets and variables RecursiveRefLayer are already derived
     3130  for( Int olsIdx = 0; olsIdx < getNumOutputLayerSets(); olsIdx++)
     3131  {
     3132    deriveNecessaryLayerFlag(olsIdx);
     3133  }
     3134}
     3135Void TComVPS::deriveNecessaryLayerFlag(Int const olsIdx)
     3136{
     3137  Int lsIdx = this->getOutputLayerSetIdx( olsIdx );
     3138  Int numLayersInLs = this->getNumLayersInIdList( lsIdx );
     3139  assert( m_necessaryLayerFlag.size() == olsIdx );   // Function should be called in the correct order.
     3140  m_necessaryLayerFlag.push_back( std::vector<Bool>( numLayersInLs, false ) ); // Initialize to false
     3141  for( Int lsLayerIdx = 0; lsLayerIdx < numLayersInLs; lsLayerIdx++ )
     3142  {
     3143    if( this->m_outputLayerFlag[olsIdx][lsLayerIdx] )
     3144    {
     3145      m_necessaryLayerFlag[olsIdx][lsLayerIdx] = true;
     3146      Int currNuhLayerId = this->m_layerSetLayerIdList[lsIdx][lsLayerIdx];
     3147      for( Int rLsLayerIdx = 0; rLsLayerIdx < lsLayerIdx; rLsLayerIdx++ )
     3148      {
     3149        Int refNuhLayerId = this->m_layerSetLayerIdList[lsIdx][rLsLayerIdx];
     3150        if( this->m_recursiveRefLayerFlag[currNuhLayerId][refNuhLayerId] )
     3151        {
     3152          m_necessaryLayerFlag[olsIdx][rLsLayerIdx] = true;
     3153        }
     3154      }
     3155    }
     3156  }
     3157  m_numNecessaryLayers.push_back(std::accumulate(m_necessaryLayerFlag[olsIdx].begin(), m_necessaryLayerFlag[olsIdx].end(), 0));
     3158}
     3159Void TComVPS::checkNecessaryLayerFlagCondition()
     3160{
     3161  /* It is a requirement of bitstream conformance that for each layer index layerIdx in the range of
     3162  ( vps_base_layer_internal_flag ? 0 : 1 ) to MaxLayersMinus1, inclusive, there shall be at least one OLS with index olsIdx such that
     3163  NecessaryLayerFlag[ olsIdx ][ lsLayerIdx ] is equal to 1 for the value of lsLayerIdx
     3164  for which LayerSetLayerIdList[ OlsIdxToLsIdx[ olsIdx ] ][ lsLayerIdx ] is equal to layer_id_in_nuh[ layerIdx ]. */
     3165  for(Int layerIdx = this->getBaseLayerInternalFlag() ? 0 : 1; layerIdx < this->getMaxLayers(); layerIdx++)
     3166  {
     3167    Bool layerFoundNecessaryLayerFlag = false;
     3168    for(Int olsIdx = 0; olsIdx < this->getNumOutputLayerSets(); olsIdx++)
     3169    {
     3170      Int lsIdx = this->getOutputLayerSetIdx( olsIdx );
     3171      Int currNuhLayerId = this->getLayerIdInNuh( layerIdx );
     3172      std::vector<Int>::iterator iter = std::find( m_layerSetLayerIdList[lsIdx].begin(), m_layerSetLayerIdList[lsIdx].end(), currNuhLayerId );
     3173      if( iter != m_layerSetLayerIdList[lsIdx].end() ) // Layer present in layer set
     3174      {
     3175        size_t positionLayer = iter - m_layerSetLayerIdList[lsIdx].begin();
     3176        if( *(m_necessaryLayerFlag[olsIdx].begin() + positionLayer) == true )
     3177        {
     3178          layerFoundNecessaryLayerFlag = true;
     3179          break;
     3180        }
     3181      }
     3182    }
     3183    assert( layerFoundNecessaryLayerFlag );
     3184  }
     3185}
     3186#endif
     3187#if PER_LAYER_PTL
     3188Int TComVPS::calculateLenOfSyntaxElement( Int const numVal )
     3189{
     3190  Int numBits = 1;
     3191  while((1 << numBits) < numVal)
     3192  {
     3193    numBits++;
     3194  }
     3195  return numBits;
     3196}
     3197#endif
     3198#if SUB_LAYERS_IN_LAYER_SET
     3199Void TComVPS::calculateMaxSLInLayerSets()
     3200{
     3201  for(Int lsIdx = 0; lsIdx < getNumLayerSets(); lsIdx++)
     3202  {
     3203    UInt maxSLMinus1 = 0;
     3204    for(Int k = 0; k < getNumLayersInIdList(lsIdx); k++ ) {
     3205      Int  lId = getLayerSetLayerIdList(lsIdx, k);
     3206      maxSLMinus1 = std::max(maxSLMinus1, getMaxTSLayersMinus1(getLayerIdInVps(lId)));
     3207    }
     3208    setMaxSLayersInLayerSetMinus1(lsIdx,maxSLMinus1);
     3209  }
     3210}
     3211#endif
     3212
    29813213#if RESOLUTION_BASED_DPB
    29823214// RepFormat Assignment operator
     
    29923224    m_bitDepthVpsLuma                 = other.m_bitDepthVpsLuma;
    29933225    m_bitDepthVpsChroma               = other.m_bitDepthVpsChroma;
     3226#if R0156_CONF_WINDOW_IN_REP_FORMAT
     3227    m_conformanceWindowVps            = other.m_conformanceWindowVps;
     3228#endif
    29943229  }
    29953230  return *this;
     
    30163251, m_chromaFormatIdc           (CHROMA_420)
    30173252, m_uiMaxTLayers              (  1)
     3253#if R0279_REP_FORMAT_INBL
     3254, m_bV1CompatibleSPSFlag      (  0)
     3255#endif
    30183256// Structure
    30193257, m_picWidthInLumaSamples     (352)
     
    30523290, m_layerId                   ( 0 )
    30533291, m_extensionFlag             ( false )
     3292#if !MOVE_SCALED_OFFSET_TO_PPS
    30543293, m_numScaledRefLayerOffsets  ( 0 )
     3294#endif
    30553295#if REPN_FORMAT_IN_VPS
    30563296, m_updateRepFormatFlag       (false)
     
    30753315  ::memset(m_usedByCurrPicLtSPSFlag, 0, sizeof(m_usedByCurrPicLtSPSFlag));
    30763316
     3317#if !MOVE_SCALED_OFFSET_TO_PPS
    30773318#if P0312_VERT_PHASE_ADJ
    30783319  ::memset(m_vertPhasePositionEnableFlag, 0, sizeof(m_vertPhasePositionEnableFlag));
     3320#endif
    30793321#endif
    30803322}
     
    32083450const Int TComSPS::m_winUnitY[]={1,2,1,1};
    32093451
     3452#if !MOVE_SCALED_OFFSET_TO_PPS
    32103453#if O0098_SCALED_REF_LAYER_ID
    32113454Window& TComSPS::getScaledRefLayerWindowForLayer(Int layerId)
     
    32243467  return win;
    32253468}
     3469#endif
     3470#if REF_REGION_OFFSET
     3471Window& TComSPS::getRefLayerWindowForLayer(Int layerId)
     3472{
     3473  static Window win;
     3474
     3475  for (Int i = 0; i < m_numRefLayerOffsets; i++)
     3476  {
     3477    if (layerId == m_refLayerId[i])
     3478    {
     3479      return m_refLayerWindow[i];
     3480    }
     3481  }
     3482
     3483  win.resetWindow();  // reference region offsets are inferred to be zero when not present
     3484  return win;
     3485}
     3486#endif
    32263487#endif
    32273488
     
    32463507, m_entropyCodingSyncEnabledFlag   (false)
    32473508, m_loopFilterAcrossTilesEnabledFlag  (true)
    3248 , m_uniformSpacingFlag           (0)
    3249 , m_iNumColumnsMinus1            (0)
    3250 , m_puiColumnWidth               (NULL)
    3251 , m_iNumRowsMinus1               (0)
    3252 , m_puiRowHeight                 (NULL)
    3253 , m_iNumSubstreams             (1)
     3509, m_uniformSpacingFlag           (false)
     3510, m_numTileColumnsMinus1         (0)
     3511, m_numTileRowsMinus1            (0)
     3512, m_numSubstreams               (1)
    32543513, m_signHideFlag(0)
    32553514, m_cabacInitPresentFlag        (false)
     
    32693528, m_pocResetInfoPresentFlag   (false)
    32703529#endif
     3530#if MOVE_SCALED_OFFSET_TO_PPS
     3531, m_numScaledRefLayerOffsets  ( 0 )
     3532#endif
    32713533#if Q0048_CGS_3D_ASYMLUT
    32723534, m_nCGSFlag(0)
     
    32773539{
    32783540  m_scalingList = new TComScalingList;
     3541#if REF_REGION_OFFSET
     3542  ::memset(m_scaledRefLayerOffsetPresentFlag,   0, sizeof(m_scaledRefLayerOffsetPresentFlag));
     3543  ::memset(m_refRegionOffsetPresentFlag,   0, sizeof(m_refRegionOffsetPresentFlag));
     3544#endif
     3545#if R0209_GENERIC_PHASE
     3546  ::memset(m_resamplePhaseSetPresentFlag,   0, sizeof(m_resamplePhaseSetPresentFlag));
     3547  ::memset(m_phaseHorLuma,   0, sizeof(m_phaseHorLuma));
     3548  ::memset(m_phaseVerLuma,   0, sizeof(m_phaseVerLuma));
     3549  ::memset(m_phaseHorChroma, 0, sizeof(m_phaseHorChroma));
     3550  ::memset(m_phaseVerChroma, 0, sizeof(m_phaseVerChroma));
     3551#endif
    32793552}
    32803553
    32813554TComPPS::~TComPPS()
    32823555{
    3283   if( m_iNumColumnsMinus1 > 0 && m_uniformSpacingFlag == 0 )
    3284   {
    3285     if (m_puiColumnWidth) delete [] m_puiColumnWidth;
    3286     m_puiColumnWidth = NULL;
    3287   }
    3288   if( m_iNumRowsMinus1 > 0 && m_uniformSpacingFlag == 0 )
    3289   {
    3290     if (m_puiRowHeight) delete [] m_puiRowHeight;
    3291     m_puiRowHeight = NULL;
    3292   }
    3293 
    32943556#if SCALINGLIST_INFERRING
    32953557  if( !m_inferScalingListFlag )
     
    32973559  delete m_scalingList;
    32983560}
     3561
     3562#if MOVE_SCALED_OFFSET_TO_PPS
     3563#if O0098_SCALED_REF_LAYER_ID
     3564Window& TComPPS::getScaledRefLayerWindowForLayer(Int layerId)
     3565{
     3566  static Window win;
     3567
     3568  for (Int i = 0; i < m_numScaledRefLayerOffsets; i++)
     3569  {
     3570    if (layerId == m_scaledRefLayerId[i])
     3571    {
     3572      return m_scaledRefLayerWindow[i];
     3573    }
     3574  }
     3575
     3576  win.resetWindow();  // scaled reference layer offsets are inferred to be zero when not present
     3577  return win;
     3578}
     3579#endif
     3580#if REF_REGION_OFFSET
     3581Window& TComPPS::getRefLayerWindowForLayer(Int layerId)
     3582{
     3583  static Window win;
     3584
     3585  for (Int i = 0; i < m_numScaledRefLayerOffsets; i++)
     3586  {
     3587    if (layerId == m_scaledRefLayerId[i])
     3588    {
     3589      return m_refLayerWindow[i];
     3590    }
     3591  }
     3592
     3593  win.resetWindow();  // reference region offsets are inferred to be zero when not present
     3594  return win;
     3595}
     3596#endif
     3597
     3598#if RESAMPLING_FIX
     3599#if R0209_GENERIC_PHASE
     3600Bool TComPPS::hasZeroResamplingPhase(Int refLayerIdc)
     3601{
     3602  Int phaseHorLuma   = this->getPhaseHorLuma(refLayerIdc);
     3603  Int phaseVerLuma   = this->getPhaseVerLuma(refLayerIdc);
     3604  Int phaseHorChroma = this->getPhaseHorChroma(refLayerIdc);
     3605  Int phaseVerChroma = this->getPhaseVerChroma(refLayerIdc);
     3606  return ( phaseHorLuma == 0 && phaseHorChroma == 0 && phaseVerLuma == 0 && phaseVerChroma == 0);
     3607}
     3608#endif
     3609#endif
     3610
     3611#endif
    32993612
    33003613TComReferencePictureSet::TComReferencePictureSet()
     
    37184031ParameterSetManager::ParameterSetManager()
    37194032#if SVC_EXTENSION
    3720 : m_spsMap(MAX_NUM_SPS)
    3721 , m_ppsMap(MAX_NUM_PPS)
    3722 , m_activeSPSId(-1)
     4033: m_activeSPSId(-1)
    37234034, m_activePPSId(-1)
    37244035#else
     
    38544165
    38554166#if SVC_EXTENSION
    3856 #if AVC_SYNTAX
    3857 Void TComSlice::initBaseLayerRPL( TComSlice *pcSlice )
    3858 {
    3859 // Assumed that RPL of the base layer is same to the EL, otherwise this information should be also dumped and read from the metadata file
    3860   setPOC( pcSlice->getPOC() );
    3861   if( pcSlice->getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP && pcSlice->getNalUnitType() <= NAL_UNIT_CODED_SLICE_CRA )
    3862   {
    3863     setSliceType( I_SLICE );
    3864   }
    3865   else
    3866   {
    3867     setSliceType( pcSlice->getSliceType() );
    3868   }
    3869 
    3870   if( this->isIntra() )
    3871   {
    3872     return;
    3873   }
    3874 
    3875   //initialize reference POC of BL
    3876   for( Int iRefPicList = 0; iRefPicList < 2; iRefPicList++ )
    3877   {
    3878     RefPicList eRefPicList = RefPicList( iRefPicList );
    3879 
    3880     assert( pcSlice->getNumRefIdx( eRefPicList) >= 0 );
    3881     setNumRefIdx( eRefPicList, pcSlice->getNumRefIdx( eRefPicList ) - 1 );
    3882     assert( getNumRefIdx( eRefPicList) <= MAX_NUM_REF);
    3883 
    3884     for(Int refIdx = 0; refIdx < getNumRefIdx( eRefPicList ); refIdx++)
    3885     {
    3886       setRefPOC( pcSlice->getRefPic( eRefPicList, refIdx )->getPOC(), eRefPicList, refIdx );
    3887       setRefPic( pcSlice->getRefPic( eRefPicList, refIdx ), eRefPicList, refIdx );
    3888       /*
    3889       // should be set if the base layer has its own instance of the reference picture lists, currently EL RPL is reused.
    3890       getRefPic( eRefPicList, refIdx )->setLayerId( 0 );
    3891       getRefPic( eRefPicList, refIdx )->setIsLongTerm( pcSlice->getRefPic( eRefPicList, refIdx )->getIsLongTerm() );     
    3892       */
    3893 
    3894     }
    3895   } 
    3896   return;
    3897 }
    3898 #endif
    3899 
    39004167Bool TComSlice::setBaseColPic(  TComList<TComPic*>& rcListPic, UInt refLayerIdc )
    39014168
     
    39394206#endif
    39404207
    3941 #if REF_IDX_MFM
    3942 Void TComSlice::setRefPOCListILP( TComPic** ilpPic, TComPic** pcRefPicRL )
    3943 {
    3944   for( UInt i = 0; i < m_activeNumILRRefIdx; i++ )
    3945   {
    3946     UInt refLayerIdc = m_interLayerPredLayerIdc[i];
    3947 
    3948     TComPic* pcRefPicBL = pcRefPicRL[refLayerIdc];
    3949 
    3950     //set reference picture POC of each ILP reference
    3951     Int thePoc = ilpPic[refLayerIdc]->getPOC();
    3952     assert(thePoc == pcRefPicBL->getPOC());
    3953 
    3954     ilpPic[refLayerIdc]->getSlice(0)->setBaseColPic( refLayerIdc, pcRefPicBL );
    3955 
    3956     //copy layer id from the reference layer   
    3957     ilpPic[refLayerIdc]->setLayerId( pcRefPicBL->getLayerId() );
    3958 
    3959     //copy slice type from the reference layer
    3960     ilpPic[refLayerIdc]->getSlice(0)->setSliceType( pcRefPicBL->getSlice(0)->getSliceType() );
    3961 
    3962     //copy "used for reference"
    3963     ilpPic[refLayerIdc]->getSlice(0)->setReferenced( pcRefPicBL->getSlice(0)->isReferenced() );
    3964 
    3965     for( Int refList = 0; refList < 2; refList++ )
    3966     {
    3967       RefPicList refPicList = RefPicList( refList );
    3968 
    3969       //set reference POC of ILP
    3970       ilpPic[refLayerIdc]->getSlice(0)->setNumRefIdx(refPicList, pcRefPicBL->getSlice(0)->getNumRefIdx(refPicList));
    3971       assert(ilpPic[refLayerIdc]->getSlice(0)->getNumRefIdx(refPicList) >= 0);
    3972       assert(ilpPic[refLayerIdc]->getSlice(0)->getNumRefIdx(refPicList) <= MAX_NUM_REF);
    3973 
    3974       //initialize reference POC of ILP
    3975       for(Int refIdx = 0; refIdx < pcRefPicBL->getSlice(0)->getNumRefIdx(refPicList); refIdx++)
    3976       {
    3977         ilpPic[refLayerIdc]->getSlice(0)->setRefPOC(pcRefPicBL->getSlice(0)->getRefPOC(refPicList, refIdx), refPicList, refIdx);
    3978         ilpPic[refLayerIdc]->getSlice(0)->setRefPic(pcRefPicBL->getSlice(0)->getRefPic(refPicList, refIdx), refPicList, refIdx);
    3979       }
    3980 
    3981       for(Int refIdx = pcRefPicBL->getSlice(0)->getNumRefIdx(refPicList); refIdx < MAX_NUM_REF; refIdx++)
    3982       {
    3983         ilpPic[refLayerIdc]->getSlice(0)->setRefPOC(0, refPicList, refIdx);
    3984         ilpPic[refLayerIdc]->getSlice(0)->setRefPic(NULL, refPicList, refIdx);
    3985       }
    3986 
    3987       //copy reference pictures' marking from the reference layer
    3988       for(Int j = 0; j < MAX_NUM_REF + 1; j++)
    3989       {
    3990         ilpPic[refLayerIdc]->getSlice(0)->setIsUsedAsLongTerm(refList, j, pcRefPicBL->getSlice(0)->getIsUsedAsLongTerm(refList, j));
    3991       }
    3992     }
    3993   }
    3994   return;
    3995 }
    3996 #endif
    3997 
    39984208Void TComSlice::setILRPic(TComPic **pcIlpPic)
    39994209{
     
    40044214    if( pcIlpPic[refLayerIdc] )
    40054215    {
    4006       pcIlpPic[refLayerIdc]->copyUpsampledPictureYuv( m_pcPic->getFullPelBaseRec( refLayerIdc ), pcIlpPic[refLayerIdc]->getPicYuvRec() );
     4216      TComPic* pcRefPicBL = m_pcBaseColPic[refLayerIdc];
     4217
     4218      // copy scalability ratio, it is needed to get the correct location for the motion field of the corresponding reference layer block
     4219      pcIlpPic[refLayerIdc]->setSpatialEnhLayerFlag( refLayerIdc, m_pcPic->isSpatialEnhLayer(refLayerIdc) );
     4220
     4221      pcIlpPic[refLayerIdc]->copyUpsampledPictureYuv( m_pcPic->getFullPelBaseRec( refLayerIdc ), pcIlpPic[refLayerIdc]->getPicYuvRec() );     
     4222      pcIlpPic[refLayerIdc]->getSlice(0)->setBaseColPic( refLayerIdc, pcRefPicBL );
     4223
     4224      //set reference picture POC of each ILP reference
    40074225      pcIlpPic[refLayerIdc]->getSlice(0)->setPOC( m_iPOC );
    4008       pcIlpPic[refLayerIdc]->setLayerId( m_pcBaseColPic[refLayerIdc]->getLayerId() ); //set reference layerId
     4226
     4227      //set temporal Id
     4228      pcIlpPic[refLayerIdc]->getSlice(0)->setTLayer( m_uiTLayer );
     4229
     4230      //copy layer id from the reference layer
     4231      pcIlpPic[refLayerIdc]->setLayerId( pcRefPicBL->getLayerId() );
     4232
    40094233      pcIlpPic[refLayerIdc]->getPicYuvRec()->setBorderExtension( false );
    40104234      pcIlpPic[refLayerIdc]->getPicYuvRec()->extendPicBorder();
     
    40134237        pcIlpPic[refLayerIdc]->getPicSym()->getCU(j)->setLayerId( pcIlpPic[refLayerIdc]->getLayerId() );
    40144238      }
    4015     }
    4016   }
    4017 }
    4018 
     4239      pcIlpPic[refLayerIdc]->setIsLongTerm(1);
     4240
     4241#if REF_IDX_MFM
     4242      if( m_bMFMEnabledFlag && !(m_eNalUnitType >= NAL_UNIT_CODED_SLICE_BLA_W_LP && m_eNalUnitType <= NAL_UNIT_CODED_SLICE_CRA) )
     4243      {
     4244        //set reference picture POC of each ILP reference
     4245        assert( pcIlpPic[refLayerIdc]->getPOC() == pcRefPicBL->getPOC() );
     4246
     4247        //copy slice type from the reference layer
     4248        pcIlpPic[refLayerIdc]->getSlice(0)->setSliceType( pcRefPicBL->getSlice(0)->getSliceType() );
     4249
     4250        //copy "used for reference"
     4251        pcIlpPic[refLayerIdc]->getSlice(0)->setReferenced( pcRefPicBL->getSlice(0)->isReferenced() );
     4252
     4253        for( Int refList = 0; refList < 2; refList++ )
     4254        {
     4255          RefPicList refPicList = RefPicList( refList );
     4256
     4257          //set reference POC of ILP
     4258          pcIlpPic[refLayerIdc]->getSlice(0)->setNumRefIdx(refPicList, pcRefPicBL->getSlice(0)->getNumRefIdx(refPicList));
     4259          assert(pcIlpPic[refLayerIdc]->getSlice(0)->getNumRefIdx(refPicList) >= 0);
     4260          assert(pcIlpPic[refLayerIdc]->getSlice(0)->getNumRefIdx(refPicList) <= MAX_NUM_REF);
     4261
     4262          //initialize reference POC of ILP
     4263          for(Int refIdx = 0; refIdx < pcRefPicBL->getSlice(0)->getNumRefIdx(refPicList); refIdx++)
     4264          {
     4265            pcIlpPic[refLayerIdc]->getSlice(0)->setRefPOC(pcRefPicBL->getSlice(0)->getRefPOC(refPicList, refIdx), refPicList, refIdx);
     4266            pcIlpPic[refLayerIdc]->getSlice(0)->setRefPic(pcRefPicBL->getSlice(0)->getRefPic(refPicList, refIdx), refPicList, refIdx);
     4267          }
     4268
     4269          for(Int refIdx = pcRefPicBL->getSlice(0)->getNumRefIdx(refPicList); refIdx < MAX_NUM_REF; refIdx++)
     4270          {
     4271            pcIlpPic[refLayerIdc]->getSlice(0)->setRefPOC(0, refPicList, refIdx);
     4272            pcIlpPic[refLayerIdc]->getSlice(0)->setRefPic(NULL, refPicList, refIdx);
     4273          }
     4274
     4275          //copy reference pictures' marking from the reference layer
     4276          for(Int j = 0; j < MAX_NUM_REF + 1; j++)
     4277          {
     4278            pcIlpPic[refLayerIdc]->getSlice(0)->setIsUsedAsLongTerm(refList, j, pcRefPicBL->getSlice(0)->getIsUsedAsLongTerm(refList, j));
     4279          }
     4280        }
     4281
     4282        pcIlpPic[refLayerIdc]->copyUpsampledMvField( refLayerIdc, m_pcBaseColPic[refLayerIdc] );
     4283      }
     4284      else
     4285      {
     4286        pcIlpPic[refLayerIdc]->initUpsampledMvField();
     4287      }
     4288#endif
     4289
     4290#if O0225_MAX_TID_FOR_REF_LAYERS
     4291      Int maxTidIlRefPicsPlus1 = m_pcVPS->getMaxTidIlRefPicsPlus1( pcIlpPic[refLayerIdc]->getSlice(0)->getLayerId(), m_layerId );
     4292#else
     4293      Int maxTidIlRefPicsPlus1 = m_pcVPS->getMaxTidIlRefPicsPlus1( pcIlpPic[refLayerIdc]->getSlice(0)->getLayerId() );
     4294#endif
     4295      assert( (Int)pcIlpPic[refLayerIdc]->getSlice(0)->getTLayer() < maxTidIlRefPicsPlus1 || ( !maxTidIlRefPicsPlus1 && pcIlpPic[refLayerIdc]->getSlice(0)->getRapPicFlag() ) );
     4296
     4297    }
     4298  }
     4299}
     4300
     4301Int TComSlice::getReferenceLayerIdc( UInt refLayerId )
     4302{
     4303  for( Int i = 0; i < m_activeNumILRRefIdx; i++ )
     4304  {
     4305    if( m_pcVPS->getRefLayerId(m_layerId, m_interLayerPredLayerIdc[i]) == refLayerId )
     4306    {
     4307      return m_interLayerPredLayerIdc[i];
     4308    }
     4309  }
     4310
     4311  return -1;
     4312}
    40194313#endif //SVC_EXTENSION
    40204314
  • trunk/source/Lib/TLibCommon/TComSlice.h

    r815 r906  
    370370  UInt getNumDU                              ( )            { return m_numDU;          }
    371371  Bool getCpbDpbDelaysPresentFlag() { return getNalHrdParametersPresentFlag() || getVclHrdParametersPresentFlag(); }
     372
     373#if VPS_VUI_BSP_HRD_PARAMS
     374Void copyCommonInformation( TComHRD *refHrd )
     375{
     376  m_nalHrdParametersPresentFlag         = refHrd->getNalHrdParametersPresentFlag();
     377  m_vclHrdParametersPresentFlag         = refHrd->getVclHrdParametersPresentFlag();
     378  m_subPicCpbParamsPresentFlag          = refHrd->getSubPicCpbParamsPresentFlag();
     379  m_tickDivisorMinus2                   = refHrd->getTickDivisorMinus2();
     380  m_duCpbRemovalDelayLengthMinus1       = refHrd->getDuCpbRemovalDelayLengthMinus1();
     381  m_subPicCpbParamsInPicTimingSEIFlag   = refHrd->getSubPicCpbParamsInPicTimingSEIFlag();
     382  m_dpbOutputDelayDuLengthMinus1        = refHrd->getDpbOutputDelayDuLengthMinus1();
     383  m_bitRateScale                        = refHrd->getBitRateScale();
     384  m_cpbSizeScale                        = refHrd->getCpbSizeScale();
     385  m_ducpbSizeScale                      = refHrd->getDuCpbSizeScale();
     386  m_initialCpbRemovalDelayLengthMinus1  = refHrd->getInitialCpbRemovalDelayLengthMinus1();
     387  m_cpbRemovalDelayLengthMinus1         = refHrd->getCpbRemovalDelayLengthMinus1();
     388  m_dpbOutputDelayLengthMinus1          = refHrd->getDpbOutputDelayLengthMinus1();
     389}
     390#endif
    372391};
    373392
     
    403422};
    404423
     424class Window
     425{
     426private:
     427  Bool          m_enabledFlag;
     428  Int           m_winLeftOffset;
     429  Int           m_winRightOffset;
     430  Int           m_winTopOffset;
     431  Int           m_winBottomOffset;
     432#if P0312_VERT_PHASE_ADJ
     433  Bool          m_vertPhasePositionEnableFlag;
     434#endif
     435public:
     436  Window()
     437  : m_enabledFlag (false)
     438  , m_winLeftOffset     (0)
     439  , m_winRightOffset    (0)
     440  , m_winTopOffset      (0)
     441  , m_winBottomOffset   (0)
     442#if P0312_VERT_PHASE_ADJ
     443  , m_vertPhasePositionEnableFlag(false) 
     444#endif
     445  { }
     446
     447  Bool          getWindowEnabledFlag() const      { return m_enabledFlag; }
     448#if P0312_VERT_PHASE_ADJ
     449  Void          resetWindow()                     { m_enabledFlag = false; m_winLeftOffset = m_winRightOffset = m_winTopOffset = m_winBottomOffset = 0; m_vertPhasePositionEnableFlag = false; }
     450#else
     451  Void          resetWindow()                     { m_enabledFlag = false; m_winLeftOffset = m_winRightOffset = m_winTopOffset = m_winBottomOffset = 0;}
     452#endif
     453  Int           getWindowLeftOffset() const       { return m_enabledFlag ? m_winLeftOffset : 0; }
     454  Void          setWindowLeftOffset(Int val)      { if(val) {m_winLeftOffset = val; m_enabledFlag = true;} }
     455  Int           getWindowRightOffset() const      { return m_enabledFlag ? m_winRightOffset : 0; }
     456  Void          setWindowRightOffset(Int val)     { if(val) {m_winRightOffset = val; m_enabledFlag = true;} }
     457  Int           getWindowTopOffset() const        { return m_enabledFlag ? m_winTopOffset : 0; }
     458  Void          setWindowTopOffset(Int val)       { if(val) {m_winTopOffset = val; m_enabledFlag = true;} }
     459  Int           getWindowBottomOffset() const     { return m_enabledFlag ? m_winBottomOffset: 0; }
     460  Void          setWindowBottomOffset(Int val)    { if(val) {m_winBottomOffset = val; m_enabledFlag = true;} }
     461#if P0312_VERT_PHASE_ADJ
     462  Bool          getVertPhasePositionEnableFlag() const     { return m_vertPhasePositionEnableFlag;  }
     463  Void          setVertPhasePositionEnableFlag(Bool val)    { m_vertPhasePositionEnableFlag = val;  }
     464#endif
     465#if REF_REGION_OFFSET && RESAMPLING_FIX
     466  Bool          hasEqualOffset(const Window& ref) const
     467  {
     468    return (    this->getWindowLeftOffset()   == ref.getWindowLeftOffset()
     469             && this->getWindowTopOffset()    == ref.getWindowTopOffset()
     470             && this->getWindowRightOffset()  == ref.getWindowRightOffset()
     471             && this->getWindowBottomOffset() == ref.getWindowBottomOffset() );
     472  }
     473#endif
     474
     475#if P0312_VERT_PHASE_ADJ
     476  Void          setWindow(Int offsetLeft, Int offsetLRight, Int offsetLTop, Int offsetLBottom, Bool vertPhasePositionEnableFlag = 0)
     477#else
     478  Void          setWindow(Int offsetLeft, Int offsetLRight, Int offsetLTop, Int offsetLBottom)
     479#endif
     480  {
     481    if(offsetLeft || offsetLRight || offsetLTop || offsetLBottom)
     482    {
     483      m_enabledFlag       = true;
     484      m_winLeftOffset     = offsetLeft;
     485      m_winRightOffset    = offsetLRight;
     486      m_winTopOffset      = offsetLTop;
     487      m_winBottomOffset   = offsetLBottom;
     488    }
     489#if P0312_VERT_PHASE_ADJ
     490    m_vertPhasePositionEnableFlag = vertPhasePositionEnableFlag;   
     491#endif
     492  }
     493};
     494
    405495#if REPN_FORMAT_IN_VPS
    406496class RepFormat
     
    420510  Int  m_bitDepthVpsChroma;             // coded as minus8
    421511
     512#if R0156_CONF_WINDOW_IN_REP_FORMAT
     513  Window m_conformanceWindowVps;
     514#endif
     515
    422516public:
    423517  RepFormat();
     
    454548  Int  getBitDepthVpsChroma()           { return m_bitDepthVpsChroma;   }
    455549  Void setBitDepthVpsChroma(Int x)      { m_bitDepthVpsChroma = x;      }
     550
     551#if R0156_CONF_WINDOW_IN_REP_FORMAT
     552  Window& getConformanceWindowVps()                           { return  m_conformanceWindowVps;             }
     553  Void    setConformanceWindowVps(Window& conformanceWindow ) { m_conformanceWindowVps = conformanceWindow; }
     554#endif
    456555};
    457556#endif
     
    460559private:
    461560  Int         m_VPSId;
     561#if VPS_RESERVED_FLAGS
     562  Bool        m_baseLayerInternalFlag;
     563  Bool        m_baseLayerAvailableFlag;
     564#endif
    462565  UInt        m_uiMaxTLayers;
    463566  UInt        m_uiMaxLayers;
     
    485588#if DERIVE_LAYER_ID_LIST_VARIABLES
    486589#if Q0078_ADD_LAYER_SETS
     590#if NECESSARY_LAYER_FLAG
     591  std::vector< std::vector<Int> >     m_layerSetLayerIdList;
     592  std::vector<Int>                      m_numLayerInIdList;;
     593#else
    487594  Int         m_layerSetLayerIdList[MAX_VPS_LAYER_SETS_PLUS1 + MAX_NUM_ADD_LAYER_SETS][MAX_VPS_LAYER_ID_PLUS1];
    488595  Int         m_numLayerInIdList[MAX_VPS_LAYER_SETS_PLUS1 + MAX_NUM_ADD_LAYER_SETS];
     596#endif
    489597#else
    490598  Int         m_layerSetLayerIdList[MAX_VPS_LAYER_SETS_PLUS1][MAX_VPS_LAYER_ID_PLUS1];
     
    510618  // ------------------------------------------
    511619#if VPS_EXTN_MASK_AND_DIM_INFO
     620#if VPS_AVC_BL_FLAG_REMOVAL
     621  Bool       m_nonHEVCBaseLayerFlag;
     622#else
    512623  Bool       m_avcBaseLayerFlag;                                // For now, always set to true.
     624#endif
    513625  Bool       m_splittingFlag;
    514626  Bool       m_scalabilityMask[MAX_VPS_NUM_SCALABILITY_TYPES];
     
    576688#endif
    577689#endif
     690#if PER_LAYER_PTL
     691  std::vector< std::vector<Int> >  m_profileLevelTierIdx;
     692#else
    578693  Int        m_profileLevelTierIdx[64];     
     694#endif
    579695  Bool       m_maxOneActiveRefLayerFlag;
    580696#if O0062_POC_LSB_NOT_PRESENT_FLAG
     
    717833#if O0164_MULTI_LAYER_HRD
    718834  Bool       m_vpsVuiBspHrdPresentFlag;
     835#if VPS_VUI_BSP_HRD_PARAMS
     836  Int                 m_vpsNumAddHrdParams;
     837  std::vector<Bool>   m_cprmsAddPresentFlag;
     838  std::vector<Int>    m_numSubLayerHrdMinus1;
     839  std::vector<TComHRD> m_bspHrd;
     840  Int    m_numSignalledPartitioningSchemes[MAX_VPS_OUTPUT_LAYER_SETS_PLUS1];
     841  Int    m_numPartitionsInSchemeMinus1    [MAX_VPS_OUTPUT_LAYER_SETS_PLUS1][16];
     842  Int    m_layerIncludedInPartitionFlag   [MAX_VPS_OUTPUT_LAYER_SETS_PLUS1][16][MAX_LAYERS][MAX_LAYERS];
     843  Int    m_numBspSchedulesMinus1          [MAX_VPS_OUTPUT_LAYER_SETS_PLUS1][16][MAX_TLAYER];
     844  Int    m_bspHrdIdx                      [MAX_VPS_OUTPUT_LAYER_SETS_PLUS1][16][MAX_TLAYER][31][MAX_LAYERS];
     845  Int    m_bspSchedIdx                    [MAX_VPS_OUTPUT_LAYER_SETS_PLUS1][16][MAX_TLAYER][31][MAX_LAYERS];
     846#else
    719847  UInt       m_vpsNumBspHrdParametersMinus1;
    720848  Bool       m_bspCprmsPresentFlag[MAX_VPS_LAYER_SETS_PLUS1];
     
    726854  UInt       m_bspCombSchedIdx[MAX_VPS_LAYER_SETS_PLUS1][16][16];
    727855#endif
     856#endif
    728857
    729858#if P0182_VPS_VUI_PS_FLAG
     
    741870  Int        m_vpsNonVuiExtLength;
    742871#endif
     872#if P0297_VPS_POC_LSB_ALIGNED_FLAG
     873  Bool       m_vpsPocLsbAlignedFlag;
     874#endif
    743875#if RESOLUTION_BASED_DPB
    744876  Int        m_subDpbAssigned            [MAX_VPS_LAYER_SETS_PLUS1][MAX_LAYERS];
     877#endif
     878#if NECESSARY_LAYER_FLAG
     879  std::vector< std::vector<Bool> > m_necessaryLayerFlag;
     880  std::vector<Int>               m_numNecessaryLayers;
    745881#endif
    746882#endif //SVC_EXTENSION
     
    748884  TComVPS();
    749885  virtual ~TComVPS();
     886
     887#if VPS_RESERVED_FLAGS
     888  Void        setBaseLayerInternalFlag(Bool x) { m_baseLayerInternalFlag = x; }
     889  Bool        getBaseLayerInternalFlag()         { return m_baseLayerInternalFlag; }
     890  Void        setBaseLayerAvailableFlag(Bool x) { m_baseLayerAvailableFlag = x; }
     891  Bool        getBaseLayerAvailableFlag()         { return m_baseLayerAvailableFlag; }
     892#endif
    750893
    751894  Void    createHrdParamBuffer()
     
    759902  Void    createBspHrdParamBuffer(UInt numHrds)
    760903  {
     904#if VPS_VUI_BSP_HRD_PARAMS
     905    m_bspHrd.resize( numHrds );
     906    m_cprmsAddPresentFlag.resize( numHrds );
     907    m_numSubLayerHrdMinus1.resize( numHrds );
     908#else
    761909    m_bspHrd    = new TComHRD[ numHrds ];
     910#endif
    762911//    m_hrdOpSetIdx      = new UInt   [ getNumHrdParameters() ];
    763912//    m_cprmsPresentFlag = new Bool   [ getNumHrdParameters() ];
     
    767916  Int getBspHrdParamBufferCpbCntMinus1(UInt i, UInt sl)
    768917  {
     918#if VPS_VUI_BSP_HRD_PARAMS
     919    return m_bspHrd[i].getCpbCntMinus1(sl);
     920#else
    769921    return m_bspHrd->getCpbCntMinus1(sl);
     922#endif
    770923  }
    771924#endif
     
    817970#if DERIVE_LAYER_ID_LIST_VARIABLES
    818971  Int     getLayerSetLayerIdList(Int set, Int layerId)          { return m_layerSetLayerIdList[set][layerId]; }
    819   Void    setLayerSetLayerIdList(Int set, Int layerId, Int x)   { m_layerSetLayerIdList[set][layerId] = x   ; }
     972  Void    setLayerSetLayerIdList(Int set, Int layerId, Int x)   { m_layerSetLayerIdList[set][layerId] = x;    }
    820973
    821974  Int     getNumLayersInIdList(Int set)                          { return m_numLayerInIdList[set]; }
    822   Void    setNumLayersInIdList(Int set, Int x)                   { m_numLayerInIdList[set] = x   ; }
     975  Void    setNumLayersInIdList(Int set, Int x)                   { m_numLayerInIdList[set] = x;    }
    823976
    824977  Void    deriveLayerIdListVariables();
     
    8611014  Void    setNumLayerSets(UInt v)                               { m_numLayerSets = v;    }
    8621015#if VPS_EXTN_MASK_AND_DIM_INFO
     1016#if VPS_AVC_BL_FLAG_REMOVAL
     1017  Bool   getNonHEVCBaseLayerFlag()                              { return m_nonHEVCBaseLayerFlag;       }
     1018  Void   setNonHEVCBaseLayerFlag(Bool x)                        { m_nonHEVCBaseLayerFlag = x;          }
     1019#else
    8631020  Bool   getAvcBaseLayerFlag()                                  { return m_avcBaseLayerFlag;       }
    8641021  Void   setAvcBaseLayerFlag(Bool x)                            { m_avcBaseLayerFlag = x;          }
     1022#endif
    8651023
    8661024  Bool   getSplittingFlag()                                     { return m_splittingFlag;          }
     
    9641122#endif
    9651123#endif
     1124#if PER_LAYER_PTL
     1125  Bool getNecessaryLayerFlag(Int const i, Int const j) { return m_necessaryLayerFlag[i][j]; }
     1126  std::vector< std::vector<Int> >* getProfileLevelTierIdx() { return &m_profileLevelTierIdx; }
     1127  std::vector<Int>* getProfileLevelTierIdx(Int const olsIdx) { return &m_profileLevelTierIdx[olsIdx]; }
     1128  Int    getProfileLevelTierIdx(Int const olsIdx, Int const layerIdx)     { return m_profileLevelTierIdx[olsIdx][layerIdx]; }
     1129  Void   setProfileLevelTierIdx(Int const olsIdx, Int const layerIdx, Int const ptlIdx)     { m_profileLevelTierIdx[olsIdx][layerIdx] = ptlIdx; }
     1130  Int calculateLenOfSyntaxElement( Int const numVal );
     1131#else
    9661132  Int    getProfileLevelTierIdx(Int i)                        { return m_profileLevelTierIdx[i]; }
    9671133  Void   setProfileLevelTierIdx(Int i, Int x)                 { m_profileLevelTierIdx[i] = x   ; }
     1134#endif
    9681135  Bool   getMaxOneActiveRefLayerFlag()                                          { return m_maxOneActiveRefLayerFlag;                      }
    9691136  Void   setMaxOneActiveRefLayerFlag(Bool x)                                    { m_maxOneActiveRefLayerFlag = x;                         }
     
    9711138  UInt   getPocLsbNotPresentFlag(Int i)                                         { return m_pocLsbNotPresentFlag[i]; }
    9721139  Void   setPocLsbNotPresentFlag(Int i, Bool x)                                 { m_pocLsbNotPresentFlag[i] = x;    }
     1140#endif
     1141#if P0297_VPS_POC_LSB_ALIGNED_FLAG
     1142  Bool   getVpsPocLsbAlignedFlag()                                              { return m_vpsPocLsbAlignedFlag; }
     1143  Void   setVpsPocLsbAlignedFlag(Bool x)                                        { m_vpsPocLsbAlignedFlag = x; }
    9731144#endif
    9741145#if O0223_PICTURE_TYPES_ALIGN_FLAG
     
    10741245  Bool     getVpsVuiBspHrdPresentFlag()                         { return m_vpsVuiBspHrdPresentFlag;      }
    10751246  Void     setVpsVuiBspHrdPresentFlag(Bool x)                   { m_vpsVuiBspHrdPresentFlag = x;         }
     1247#if VPS_VUI_BSP_HRD_PARAMS
     1248  Int      getVpsNumAddHrdParams()                              { return m_vpsNumAddHrdParams; }
     1249  Void     setVpsNumAddHrdParams(Int  i)                   { m_vpsNumAddHrdParams = i;    }
     1250
     1251  Bool     getCprmsAddPresentFlag(Int i)                        { return m_cprmsAddPresentFlag[i];       }
     1252  Void     setCprmsAddPresentFlag(Int  i, Bool  val)  { m_cprmsAddPresentFlag[i] = val;        }
     1253
     1254  Int      getNumSubLayerHrdMinus1(Int i)           { return m_numSubLayerHrdMinus1[i]; }
     1255  Void     setNumSubLayerHrdMinus1(Int i, Int val)  { m_numSubLayerHrdMinus1[i] = val; }
     1256
     1257  TComHRD*  getBspHrd(Int i)           {return &m_bspHrd[i];}
     1258
     1259  Int      getNumSignalledPartitioningSchemes(Int  i)                    { return m_numSignalledPartitioningSchemes[i];    }
     1260  Void     setNumSignalledPartitioningSchemes(Int  i, Int  val)          { m_numSignalledPartitioningSchemes[i] = val;     }
     1261
     1262  Int      getNumPartitionsInSchemeMinus1(Int  i, Int j)  { return m_numPartitionsInSchemeMinus1[i][j];}
     1263  Void     setNumPartitionsInSchemeMinus1(Int i, Int j, Int val) { m_numPartitionsInSchemeMinus1[i][j] = val; }
     1264
     1265  Int      getLayerIncludedInPartitionFlag(Int  i, Int j, Int k, Int l)  { return m_layerIncludedInPartitionFlag[i][j][k][l];}
     1266  Void     setLayerIncludedInPartitionFlag(Int i, Int j, Int k, Int l, Int val) { m_layerIncludedInPartitionFlag[i][j][k][l] = val; }
     1267
     1268  Int      getNumBspSchedulesMinus1(Int  i, Int j, Int k)         { return m_numBspSchedulesMinus1[i][j][k];}
     1269  Void     setNumBspSchedulesMinus1(Int i, Int j, Int k, Int val) { m_numBspSchedulesMinus1[i][j][k] = val; }
     1270
     1271  Int      getBspSchedIdx(Int  i, Int j, Int k, Int l, Int m)  { return m_bspSchedIdx[i][j][k][l][m];}
     1272  Void     setBspSchedIdx(Int  i, Int j, Int k, Int l, Int m, Int val) { m_bspSchedIdx[i][j][k][l][m] = val; }
     1273
     1274  Int      getBspHrdIdx(Int  i, Int j, Int k, Int l, Int m)  { return m_bspHrdIdx[i][j][k][l][m];}
     1275  Void     setBspHrdIdx(Int  i, Int j, Int k, Int l, Int m, Int val) { m_bspHrdIdx[i][j][k][l][m] = val; }
     1276#else
    10761277  UInt     getVpsNumBspHrdParametersMinus1()                    { return m_vpsNumBspHrdParametersMinus1; }
    10771278  Void     setVpsNumBspHrdParametersMinus1(UInt i)              { m_vpsNumBspHrdParametersMinus1 = i;    }
     
    10901291  Void     setBspCombSchedIdx(UInt h, UInt i, UInt j, UInt val) { m_bspCombSchedIdx[h][i][j] = val;      }
    10911292#endif
     1293#endif
    10921294#if P0182_VPS_VUI_PS_FLAG
    10931295  Int    getSPSId       (Int layer)                   { return m_SPSId[layer];       }
     
    12051407  Void setBspHrdParameters( UInt hrdIdx, UInt frameRate, UInt numDU, UInt bitRate, Bool randomAccess );
    12061408#endif
     1409#if NECESSARY_LAYER_FLAG
     1410  Void  deriveNecessaryLayerFlag();
     1411  Void  deriveNecessaryLayerFlag(Int const olsIdx);
     1412  Void  checkNecessaryLayerFlagCondition();
     1413#endif
     1414#if SUB_LAYERS_IN_LAYER_SET
     1415  Void  calculateMaxSLInLayerSets();
     1416#endif
    12071417#endif //SVC_EXTENSION
    12081418};
    1209 
    1210 class Window
    1211 {
    1212 private:
    1213   Bool          m_enabledFlag;
    1214   Int           m_winLeftOffset;
    1215   Int           m_winRightOffset;
    1216   Int           m_winTopOffset;
    1217   Int           m_winBottomOffset;
    1218 #if P0312_VERT_PHASE_ADJ
    1219   Bool          m_vertPhasePositionEnableFlag;
    1220 #endif
    1221 public:
    1222   Window()
    1223   : m_enabledFlag (false)
    1224   , m_winLeftOffset     (0)
    1225   , m_winRightOffset    (0)
    1226   , m_winTopOffset      (0)
    1227   , m_winBottomOffset   (0)
    1228 #if P0312_VERT_PHASE_ADJ
    1229   , m_vertPhasePositionEnableFlag(false) 
    1230 #endif
    1231   { }
    1232 
    1233   Bool          getWindowEnabledFlag() const      { return m_enabledFlag; }
    1234 #if P0312_VERT_PHASE_ADJ
    1235   Void          resetWindow()                     { m_enabledFlag = false; m_winLeftOffset = m_winRightOffset = m_winTopOffset = m_winBottomOffset = 0; m_vertPhasePositionEnableFlag = false; }
    1236 #else
    1237   Void          resetWindow()                     { m_enabledFlag = false; m_winLeftOffset = m_winRightOffset = m_winTopOffset = m_winBottomOffset = 0;}
    1238 #endif
    1239   Int           getWindowLeftOffset() const       { return m_enabledFlag ? m_winLeftOffset : 0; }
    1240   Void          setWindowLeftOffset(Int val)      { m_winLeftOffset = val; m_enabledFlag = true; }
    1241   Int           getWindowRightOffset() const      { return m_enabledFlag ? m_winRightOffset : 0; }
    1242   Void          setWindowRightOffset(Int val)     { m_winRightOffset = val; m_enabledFlag = true; }
    1243   Int           getWindowTopOffset() const        { return m_enabledFlag ? m_winTopOffset : 0; }
    1244   Void          setWindowTopOffset(Int val)       { m_winTopOffset = val; m_enabledFlag = true; }
    1245   Int           getWindowBottomOffset() const     { return m_enabledFlag ? m_winBottomOffset: 0; }
    1246   Void          setWindowBottomOffset(Int val)    { m_winBottomOffset = val; m_enabledFlag = true; }
    1247 
    1248 #if P0312_VERT_PHASE_ADJ
    1249   Bool          getVertPhasePositionEnableFlag() const     { return m_vertPhasePositionEnableFlag;  }
    1250   Void          setVertPhasePositionEnableFlag(Bool val)    { m_vertPhasePositionEnableFlag = val;  }
    1251   Void          setWindow(Int offsetLeft, Int offsetLRight, Int offsetLTop, Int offsetLBottom, Bool vertPhasePositionEnableFlag = 0)
    1252 #else
    1253   Void          setWindow(Int offsetLeft, Int offsetLRight, Int offsetLTop, Int offsetLBottom)
    1254 #endif
    1255   {
    1256     m_enabledFlag       = true;
    1257     m_winLeftOffset     = offsetLeft;
    1258     m_winRightOffset    = offsetLRight;
    1259     m_winTopOffset      = offsetLTop;
    1260     m_winBottomOffset   = offsetLBottom;
    1261 #if P0312_VERT_PHASE_ADJ
    1262     m_vertPhasePositionEnableFlag = vertPhasePositionEnableFlag;   
    1263 #endif
    1264   }
    1265 };
    1266 
    12671419
    12681420class TComVUI
     
    14451597  UInt        m_uiMaxTLayers;           // maximum number of temporal layers
    14461598
     1599#if R0279_REP_FORMAT_INBL
     1600  Bool        m_bV1CompatibleSPSFlag;
     1601#endif
     1602
    14471603  // Structure
    14481604  UInt        m_picWidthInLumaSamples;
     
    15141670  Bool        m_extensionFlag;
    15151671  UInt        m_numScaledRefLayerOffsets;
     1672#if R0042_PROFILE_INDICATION 
     1673  Int         m_NumDirectRefLayers;
     1674#endif
    15161675#if P0312_VERT_PHASE_ADJ
    15171676 Bool         m_vertPhasePositionEnableFlag[MAX_LAYERS];
    15181677#endif
     1678#if !MOVE_SCALED_OFFSET_TO_PPS
    15191679#if O0098_SCALED_REF_LAYER_ID
    15201680  UInt        m_scaledRefLayerId[MAX_LAYERS];
    15211681#endif
    15221682  Window      m_scaledRefLayerWindow[MAX_LAYERS];
     1683#endif
    15231684#if REPN_FORMAT_IN_VPS
    1524   Bool        m_updateRepFormatFlag;
     1685  Bool m_updateRepFormatFlag;
    15251686#if O0096_REP_FORMAT_INDEX
    15261687  UInt        m_updateRepFormatIndex;
     
    15321693#endif
    15331694#endif //SVC_EXTENSION
     1695
    15341696public:
    15351697  TComSPS();
     
    15541716  static Int getWinUnitY (Int chromaFormatIdc) { assert (chromaFormatIdc > 0 && chromaFormatIdc <= MAX_CHROMA_FORMAT_IDC); return m_winUnitY[chromaFormatIdc];      }
    15551717#endif
    1556  
     1718
     1719#if R0279_REP_FORMAT_INBL //These two functions shall be used / called when the syntax element sps_ext_or_max_sub_layers_minus1 and V1CompatibleSPSFlag are implemented
     1720  Bool getV1CompatibleSPSFlag()        {return m_bV1CompatibleSPSFlag;}
     1721  Void setV1CompatibleSPSFlag(Bool x)       { m_bV1CompatibleSPSFlag = x;}
     1722#endif
     1723
    15571724  // structure
    15581725  Void setPicWidthInLumaSamples       ( UInt u ) { m_picWidthInLumaSamples = u;        }
     
    16731840  Int      getExtensionFlag()                  { return m_extensionFlag;  }
    16741841  Void     setExtensionFlag(Int n)             { m_extensionFlag = n;     }
     1842#if R0042_PROFILE_INDICATION
     1843  Int      getNumDirectRefLayers()                  { return  m_NumDirectRefLayers;  }
     1844  Void     setNumDirectRefLayers(Int n)             {  m_NumDirectRefLayers = n;     }
     1845#endif
     1846#if !MOVE_SCALED_OFFSET_TO_PPS
    16751847  UInt     getNumScaledRefLayerOffsets()       { return m_numScaledRefLayerOffsets; }
    16761848  Void     setNumScaledRefLayerOffsets(Int x)  { m_numScaledRefLayerOffsets = x;    }
     
    16851857#endif
    16861858  Window&  getScaledRefLayerWindow( Int x )   { return m_scaledRefLayerWindow[x]; }
     1859#endif
    16871860#if REPN_FORMAT_IN_VPS
    16881861  Bool     getUpdateRepFormatFlag()       { return m_updateRepFormatFlag; }
     
    17611934 
    17621935  Bool     m_loopFilterAcrossTilesEnabledFlag;
    1763   Int      m_uniformSpacingFlag;
    1764   Int      m_iNumColumnsMinus1;
    1765   UInt*    m_puiColumnWidth;
    1766   Int      m_iNumRowsMinus1;
    1767   UInt*    m_puiRowHeight;
    1768 
    1769   Int      m_iNumSubstreams;
     1936  Bool             m_uniformSpacingFlag;
     1937  Int              m_numTileColumnsMinus1;
     1938  Int              m_numTileRowsMinus1;
     1939  std::vector<Int> m_tileColumnWidth;
     1940  std::vector<Int> m_tileRowHeight;
     1941
     1942  Int      m_numSubstreams;
    17701943
    17711944  Int      m_signHideFlag;
     
    17971970  Bool     m_pocResetInfoPresentFlag;
    17981971#endif
     1972#if MOVE_SCALED_OFFSET_TO_PPS
     1973  UInt     m_numScaledRefLayerOffsets;
     1974#if O0098_SCALED_REF_LAYER_ID
     1975  UInt     m_scaledRefLayerId[MAX_LAYERS];
     1976#endif
     1977  Window   m_scaledRefLayerWindow[MAX_LAYERS];
     1978#if REF_REGION_OFFSET
     1979  Window   m_refLayerWindow[MAX_LAYERS];
     1980  Bool     m_scaledRefLayerOffsetPresentFlag[MAX_LAYERS];
     1981  Bool     m_refRegionOffsetPresentFlag[MAX_LAYERS];
     1982#endif
     1983#if R0209_GENERIC_PHASE
     1984  Int      m_phaseHorLuma[MAX_LAYERS];
     1985  Int      m_phaseVerLuma[MAX_LAYERS];
     1986  Int      m_phaseHorChroma[MAX_LAYERS];
     1987  Int      m_phaseVerChroma[MAX_LAYERS];
     1988  Bool     m_resamplePhaseSetPresentFlag[MAX_LAYERS];
     1989#endif
     1990#endif
    17991991#if Q0048_CGS_3D_ASYMLUT
    18001992  Int      m_nCGSFlag;
     
    18552047  Bool    getDependentSliceSegmentsEnabledFlag() const     { return m_dependentSliceSegmentsEnabledFlag; }
    18562048  Void    setDependentSliceSegmentsEnabledFlag(Bool val)   { m_dependentSliceSegmentsEnabledFlag = val; }
    1857   Bool    getTilesEnabledFlag() const                      { return m_tilesEnabledFlag; }
    1858   Void    setTilesEnabledFlag(Bool val)                    { m_tilesEnabledFlag = val; }
    18592049  Bool    getEntropyCodingSyncEnabledFlag() const          { return m_entropyCodingSyncEnabledFlag; }
    18602050  Void    setEntropyCodingSyncEnabledFlag(Bool val)        { m_entropyCodingSyncEnabledFlag = val; }
    1861   Void     setUniformSpacingFlag            ( Bool b )          { m_uniformSpacingFlag = b; }
    1862   Bool     getUniformSpacingFlag            ()                  { return m_uniformSpacingFlag; }
    1863   Void     setNumColumnsMinus1              ( Int i )           { m_iNumColumnsMinus1 = i; }
    1864   Int      getNumColumnsMinus1              ()                  { return m_iNumColumnsMinus1; }
    1865   Void     setColumnWidth ( UInt* columnWidth )
    1866   {
    1867     if( m_uniformSpacingFlag == 0 && m_iNumColumnsMinus1 > 0 )
    1868     {
    1869       m_puiColumnWidth = new UInt[ m_iNumColumnsMinus1 ];
    1870 
    1871       for(Int i=0; i<m_iNumColumnsMinus1; i++)
    1872       {
    1873         m_puiColumnWidth[i] = columnWidth[i];
    1874       }
    1875     }
    1876   }
    1877   UInt     getColumnWidth  (UInt columnIdx) { return *( m_puiColumnWidth + columnIdx ); }
    1878   Void     setNumRowsMinus1( Int i )        { m_iNumRowsMinus1 = i; }
    1879   Int      getNumRowsMinus1()               { return m_iNumRowsMinus1; }
    1880   Void     setRowHeight    ( UInt* rowHeight )
    1881   {
    1882     if( m_uniformSpacingFlag == 0 && m_iNumRowsMinus1 > 0 )
    1883     {
    1884       m_puiRowHeight = new UInt[ m_iNumRowsMinus1 ];
    1885 
    1886       for(Int i=0; i<m_iNumRowsMinus1; i++)
    1887       {
    1888         m_puiRowHeight[i] = rowHeight[i];
    1889       }
    1890     }
    1891   }
    1892   UInt     getRowHeight           (UInt rowIdx)    { return *( m_puiRowHeight + rowIdx ); }
    1893   Void     setNumSubstreams(Int iNumSubstreams)               { m_iNumSubstreams = iNumSubstreams; }
    1894   Int      getNumSubstreams()                                 { return m_iNumSubstreams; }
     2051
     2052  Void     setTilesEnabledFlag       (Bool val)                             { m_tilesEnabledFlag = val; }
     2053  Bool     getTilesEnabledFlag       () const                               { return m_tilesEnabledFlag; }
     2054  Void     setTileUniformSpacingFlag (Bool b)                               { m_uniformSpacingFlag = b; }
     2055  Bool     getTileUniformSpacingFlag () const                               { return m_uniformSpacingFlag; }
     2056  Void     setNumTileColumnsMinus1   (Int i)                                { m_numTileColumnsMinus1 = i; }
     2057  Int      getNumTileColumnsMinus1   () const                               { return m_numTileColumnsMinus1; }
     2058  Void     setTileColumnWidth        (const std::vector<Int>& columnWidth ) { m_tileColumnWidth = columnWidth; }
     2059  UInt     getTileColumnWidth        (UInt columnIdx) const                 { return  m_tileColumnWidth[columnIdx]; }
     2060  Void     setNumTileRowsMinus1      (Int i)                                { m_numTileRowsMinus1 = i; }
     2061  Int      getTileNumRowsMinus1      () const                               { return m_numTileRowsMinus1; }
     2062  Void     setTileRowHeight          (const std::vector<Int>& rowHeight)    { m_tileRowHeight = rowHeight;  }
     2063  UInt     getTileRowHeight          (UInt rowIdx) const                    { return m_tileRowHeight[rowIdx]; }
     2064
     2065  Void     setNumSubstreams    (Int numSubstreams)                     { m_numSubstreams = numSubstreams; }
     2066  Int      getNumSubstreams    ()                                      { return m_numSubstreams; }
    18952067
    18962068  Void      setSignHideFlag( Int signHideFlag ) { m_signHideFlag = signHideFlag; }
     
    19452117  Void setPocResetInfoPresentFlag   (const Bool val)      { m_pocResetInfoPresentFlag = val; }
    19462118#endif
     2119#if MOVE_SCALED_OFFSET_TO_PPS
     2120  UInt     getNumScaledRefLayerOffsets()       { return m_numScaledRefLayerOffsets; }
     2121  Void     setNumScaledRefLayerOffsets(Int x)  { m_numScaledRefLayerOffsets = x;    }
     2122#if O0098_SCALED_REF_LAYER_ID
     2123  UInt     getScaledRefLayerId(Int x)          { return m_scaledRefLayerId[x]; }
     2124  Void     setScaledRefLayerId(Int x, UInt id) { m_scaledRefLayerId[x] = id;   }
     2125  Window&  getScaledRefLayerWindowForLayer( Int layerId );
     2126#endif
     2127  Window&  getScaledRefLayerWindow( Int x )   { return m_scaledRefLayerWindow[x]; }
     2128#if REF_REGION_OFFSET
     2129  Window&  getRefLayerWindowForLayer( Int layerId );
     2130  Window&  getRefLayerWindow( Int x )   { return m_refLayerWindow[x]; }
     2131  Bool getScaledRefLayerOffsetPresentFlag(Int x) { return m_scaledRefLayerOffsetPresentFlag[x]; }
     2132  Void setScaledRefLayerOffsetPresentFlag(Int x, Bool b) { m_scaledRefLayerOffsetPresentFlag[x] = b; }
     2133  Bool getRefRegionOffsetPresentFlag(Int x) { return m_refRegionOffsetPresentFlag[x]; }
     2134  Void setRefRegionOffsetPresentFlag(Int x, Bool b) { m_refRegionOffsetPresentFlag[x] = b; }
     2135#endif
     2136#if R0209_GENERIC_PHASE
     2137  Int getPhaseHorLuma(Int x) { return m_phaseHorLuma[x]; }
     2138  Int getPhaseVerLuma(Int x) { return m_phaseVerLuma[x]; }
     2139  Int getPhaseHorChroma(Int x) { return m_phaseHorChroma[x]; }
     2140  Int getPhaseVerChroma(Int x) { return m_phaseVerChroma[x]; }
     2141  Void setPhaseHorLuma(Int x, Int val) { m_phaseHorLuma[x] = val; }
     2142  Void setPhaseVerLuma(Int x, Int val) { m_phaseVerLuma[x] = val; }
     2143  Void setPhaseHorChroma(Int x, Int val) { m_phaseHorChroma[x] = val; }
     2144  Void setPhaseVerChroma(Int x, Int val) { m_phaseVerChroma[x] = val; }
     2145  Bool getResamplePhaseSetPresentFlag(Int x) { return m_resamplePhaseSetPresentFlag[x]; }
     2146  Void setResamplePhaseSetPresentFlag(Int x, Bool b) { m_resamplePhaseSetPresentFlag[x] = b; }
     2147#if RESAMPLING_FIX
     2148  Bool hasZeroResamplingPhase(Int layerId);
     2149#endif
     2150#endif
     2151#endif
    19472152#if Q0048_CGS_3D_ASYMLUT
    19482153  Int     getCGSFlag()                { return m_nCGSFlag;  }
     
    19942199  Int         m_associatedIrapPocBeforeReset;
    19952200#endif
    1996 
    19972201  NalUnitType m_iAssociatedIRAPType;
    19982202  static Int  m_prevTid0POC;
     
    20852289
    20862290  Bool       m_enableTMVPFlag;
     2291#if R0226_SLICE_TMVP
     2292  Bool       m_availableForTMVPRefFlag;
     2293#endif
    20872294
    20882295#if SVC_EXTENSION
     
    21202327  Bool        m_pocMsbValRequiredFlag;
    21212328  Bool        m_pocMsbValPresentFlag;
     2329#if P0297_VPS_POC_LSB_ALIGNED_FLAG
     2330  Bool        m_pocMsbValNeeded;
     2331  Int         m_pocResetDeltaPoc;
     2332#endif
    21222333#endif
    21232334#if POC_RESET_IDC_ENCODER
     
    23922603  Bool      getEnableTMVPFlag     ()              { return m_enableTMVPFlag;}
    23932604
     2605#if R0226_SLICE_TMVP
     2606  Void      setAvailableForTMVPRefFlag     ( Bool   b )    { m_availableForTMVPRefFlag = b; }
     2607  Bool      getAvailableForTMVPRefFlag     ()              { return m_availableForTMVPRefFlag;}
     2608#endif
     2609
    23942610#if SVC_EXTENSION
    23952611  Bool      setBaseColPic       ( TComList<TComPic*>& rcListPic , UInt refLayerIdc );
     
    24072623  TComPicYuv* getFullPelBaseRec   (UInt refLayerIdc)               { return  m_pcFullPelBaseRec[refLayerIdc];  }
    24082624
    2409 #if AVC_SYNTAX
    2410   Void      initBaseLayerRPL( TComSlice *pcSlice );
    2411 #endif
    2412 
    24132625  Void      setRefPicListModificationSvc();
    24142626  Int       getNumILRRefIdx     ( )                     { return  m_pcVPS->getNumDirectRefLayers( m_layerId ); }
    2415 
    2416 #if REF_IDX_MFM
    2417   Void      setRefPOCListILP(TComPic** ilpPic, TComPic** pcRefPicRL);
    2418 #endif
    24192627
    24202628  Int       getActiveNumILRRefIdx     ( )               { return  m_activeNumILRRefIdx; }
     
    24442652  Bool     isRASL()   { return (m_eNalUnitType == NAL_UNIT_CODED_SLICE_RASL_N || m_eNalUnitType == NAL_UNIT_CODED_SLICE_RASL_R); }
    24452653
     2654#if POC_RESET_RESTRICTIONS
     2655  Bool     isIDR()    { return (m_eNalUnitType == NAL_UNIT_CODED_SLICE_IDR_W_RADL
     2656                                  || m_eNalUnitType == NAL_UNIT_CODED_SLICE_IDR_N_LP); }
     2657  Bool     isCRA()    { return m_eNalUnitType == NAL_UNIT_CODED_SLICE_CRA; }
     2658  Bool     isBLA()    { return (m_eNalUnitType == NAL_UNIT_CODED_SLICE_BLA_W_LP
     2659                                  || m_eNalUnitType == NAL_UNIT_CODED_SLICE_BLA_W_RADL
     2660                                  || m_eNalUnitType == NAL_UNIT_CODED_SLICE_BLA_N_LP ); }
     2661  Bool     isSLNR()   { return (m_eNalUnitType == NAL_UNIT_CODED_SLICE_TRAIL_N
     2662                                  || m_eNalUnitType == NAL_UNIT_CODED_SLICE_TSA_N
     2663                                  || m_eNalUnitType == NAL_UNIT_CODED_SLICE_STSA_N
     2664                                  || m_eNalUnitType == NAL_UNIT_CODED_SLICE_RADL_N
     2665                                  || m_eNalUnitType == NAL_UNIT_CODED_SLICE_RASL_N
     2666                                  || m_eNalUnitType == NAL_UNIT_RESERVED_VCL_N10
     2667                                  || m_eNalUnitType == NAL_UNIT_RESERVED_VCL_N12
     2668                                  || m_eNalUnitType == NAL_UNIT_RESERVED_VCL_N14 ); }
     2669#endif
    24462670#if POC_RESET_FLAG
    24472671  Bool      getPocResetFlag  ()                              { return m_bPocResetFlag;       }
     
    24732697  Int  getQpBDOffsetY();
    24742698  Int  getQpBDOffsetC();
     2699
     2700#if R0156_CONF_WINDOW_IN_REP_FORMAT
     2701  Window& getConformanceWindow();
     2702#endif
    24752703#endif
    24762704
     
    24852713  Int       getPocLsbVal         ()                              { return m_pocLsbVal;       }
    24862714  Void      setPocLsbVal       (Int b)                           { m_pocLsbVal = b;          }
     2715#if P0297_VPS_POC_LSB_ALIGNED_FLAG
     2716  Void      setPocMsbNeeded      (Bool x)                        { m_pocMsbValNeeded = x; }
     2717  Bool      getPocMsbNeeded      ()                              { return m_pocMsbValNeeded; }
     2718  Int       getPocResetDeltaPoc  ()                              { return m_pocResetDeltaPoc; }
     2719  Void      setPocResetDeltaPoc  (Int x)                         { m_pocResetDeltaPoc = x; }
     2720#endif
    24872721  Int       getPocMsbVal         ()                              { return m_pocMsbVal;       }
    24882722  Void      setPocMsbVal       (Int b)                           { m_pocMsbVal = b;          }
     
    25122746  Int       getCurrMsb( Int currLsb, Int prevLsb, Int prevMsb, Int maxLsbVal );
    25132747#endif
    2514 
     2748  Int       getReferenceLayerIdc( UInt refLayerId );
    25152749
    25162750#endif //SVC_EXTENSION
     
    25672801  }
    25682802
    2569 #if Q0078_ADD_LAYER_SETS
    2570   Void removePS(Int psId)
    2571   {
    2572     assert(psId < m_maxId);
    2573     if (m_paramsetMap.find(psId) != m_paramsetMap.end())
    2574     {
    2575       m_paramsetMap.erase(psId);
    2576     }
    2577   }
    2578 #endif
    2579 
    2580 
    25812803private:
    25822804  std::map<Int,T *> m_paramsetMap;
     
    26012823  TComSPS* getSPS(Int spsId)  { return m_spsMap.getPS(spsId); };
    26022824  TComSPS* getFirstSPS()      { return m_spsMap.getFirstPS(); };
    2603 #if Q0078_ADD_LAYER_SETS
    2604   Void     removeSPS(Int spsId) { m_spsMap.removePS(spsId); };
    2605 #endif
    26062825
    26072826  //! store picture parameter set and take ownership of it
     
    26102829  TComPPS* getPPS(Int ppsId)  { return m_ppsMap.getPS(ppsId); };
    26112830  TComPPS* getFirstPPS()      { return m_ppsMap.getFirstPS(); };
    2612 #if Q0078_ADD_LAYER_SETS
    2613   Void     removePPS(Int ppsId) { m_ppsMap.removePS(ppsId); };
    2614 #endif
    26152831
    26162832  //! activate a SPS from a active parameter sets SEI message
     
    26302846#if SVC_EXTENSION
    26312847  static ParameterSetMap<TComVPS> m_vpsMap;
     2848  static ParameterSetMap<TComSPS> m_spsMap;
     2849  static ParameterSetMap<TComPPS> m_ppsMap;
    26322850#else
    26332851  ParameterSetMap<TComVPS> m_vpsMap;
    2634 #endif
    26352852  ParameterSetMap<TComSPS> m_spsMap;
    26362853  ParameterSetMap<TComPPS> m_ppsMap;
     2854#endif
    26372855
    26382856#if SVC_EXTENSION
     
    26482866
    26492867#endif // __TCOMSLICE__
     2868
  • trunk/source/Lib/TLibCommon/TComUpsampleFilter.cpp

    r815 r906  
    5959#else
    6060#if O0194_JOINT_US_BITSHIFT
     61#if REF_REGION_OFFSET
     62Void TComUpsampleFilter::upsampleBasePic( TComSlice* currSlice, UInt refLayerIdc, TComPicYuv* pcUsPic, TComPicYuv* pcBasePic, TComPicYuv* pcTempPic, const Window window, const Window altRefWindow )
     63#else
    6164Void TComUpsampleFilter::upsampleBasePic( TComSlice* currSlice, UInt refLayerIdc, TComPicYuv* pcUsPic, TComPicYuv* pcBasePic, TComPicYuv* pcTempPic, const Window window )
     65#endif
    6266#else
    6367Void TComUpsampleFilter::upsampleBasePic( UInt refLayerIdc, TComPicYuv* pcUsPic, TComPicYuv* pcBasePic, TComPicYuv* pcTempPic, const Window window )
     
    7579#endif
    7680
     81#if MOVE_SCALED_OFFSET_TO_PPS
     82#if O0098_SCALED_REF_LAYER_ID
     83  const Window &scalEL = currSlice->getPPS()->getScaledRefLayerWindowForLayer(refLayerId);
     84#else
     85  const Window &scalEL = currSlice->getPPS()->getScaledRefLayerWindow(refLayerIdc);
     86#endif
     87#if REF_REGION_OFFSET
     88  const Window &windowRL = currSlice->getPPS()->getRefLayerWindow(refLayerIdc);
     89#endif
     90#else
    7791#if O0098_SCALED_REF_LAYER_ID
    7892  const Window &scalEL = currSlice->getSPS()->getScaledRefLayerWindowForLayer(refLayerId);
    7993#else
    8094  const Window &scalEL = currSlice->getSPS()->getScaledRefLayerWindow(refLayerIdc);
     95#endif
    8196#endif
    8297
     
    91106
    92107#if Q0200_CONFORMANCE_BL_SIZE
     108  const Window &confBL = currSlice->getBaseColPic(refLayerIdc)->getConformanceWindow();
     109#endif
     110#if Q0200_CONFORMANCE_BL_SIZE || REF_REGION_OFFSET
    93111  Int chromaFormatIdc = currSlice->getBaseColPic(refLayerIdc)->getSlice(0)->getChromaFormatIdc();
    94   const Window &confBL = currSlice->getBaseColPic(refLayerIdc)->getConformanceWindow();
    95112  Int xScal = TComSPS::getWinUnitX( chromaFormatIdc );
    96113  Int yScal = TComSPS::getWinUnitY( chromaFormatIdc );
     114#endif
     115#if R0209_GENERIC_PHASE
     116  Int phaseHorLuma   = currSlice->getPPS()->getPhaseHorLuma(refLayerIdc);
     117  Int phaseVerLuma   = currSlice->getPPS()->getPhaseVerLuma(refLayerIdc);
     118  Int phaseHorChroma = currSlice->getPPS()->getPhaseHorChroma(refLayerIdc);
     119  Int phaseVerChroma;
     120  if (currSlice->getPPS()->getResamplePhaseSetPresentFlag(refLayerIdc))
     121  {
     122    phaseVerChroma = currSlice->getPPS()->getPhaseVerChroma(refLayerIdc);
     123  }
     124  else
     125  {
     126    Int refRegionHeight = heightBL - windowRL.getWindowTopOffset() - windowRL.getWindowBottomOffset();
     127    phaseVerChroma = (4 * heightEL + (refRegionHeight >> 1)) / refRegionHeight - 4;
     128  }
    97129#endif
    98130#if P0312_VERT_PHASE_ADJ
     
    223255    Int   shiftY = 16;
    224256
     257#if R0209_GENERIC_PHASE
     258    Int phaseX = phaseHorLuma;
     259    Int phaseY = phaseVerLuma;
     260    Int addX = ( ( phaseX * scaleX + 8 ) >> 4 ) -  (1 << ( shiftX - 5 ));
     261    Int addY = ( ( phaseY * scaleY + 8 ) >> 4 ) -  (1 << ( shiftX - 5 ));
     262#if REF_REGION_OFFSET
     263    Int refOffsetX = windowRL.getWindowLeftOffset() << 4;
     264    Int refOffsetY = windowRL.getWindowTopOffset()  << 4;
     265#else
     266#if Q0200_CONFORMANCE_BL_SIZE
     267    Int refOffsetX = ( confBL.getWindowLeftOffset() * xScal ) << 4;
     268    Int refOffsetY = ( confBL.getWindowTopOffset()  * yScal ) << 4;
     269#endif
     270#endif
     271#else
    225272#if O0215_PHASE_ALIGNMENT //for Luma, if Phase 0, then both PhaseX  and PhaseY should be 0. If symmetric: both PhaseX and PhaseY should be 2
    226273    Int   phaseX = 2*phaseAlignFlag;
     
    258305#endif
    259306
     307#if REF_REGION_OFFSET
     308    Int refOffsetX = windowRL.getWindowLeftOffset() << 4;
     309    Int refOffsetY = windowRL.getWindowTopOffset() << 4;
     310#else
    260311#if Q0200_CONFORMANCE_BL_SIZE
    261312    deltaX -= ( confBL.getWindowLeftOffset() * xScal ) << 4;
    262313    deltaY -= ( confBL.getWindowTopOffset() * yScal ) << 4;
    263314#endif
     315#endif
     316#endif
    264317
    265318    Int shiftXM4 = shiftX - 4;
     
    272325    heightBL = min<Int>( pcBasePic->getHeight(), heightEL );
    273326
     327#if R0220_REMOVE_EL_CLIP
     328    Int phaseXL = scalEL.getWindowLeftOffset();
     329    Int phaseYL = scalEL.getWindowTopOffset();
     330    Int rlClipL = -(NTAPS_US_LUMA>>1);
     331    Int rlClipR = widthBL -1 + (NTAPS_US_LUMA>>1);
     332    Int rlClipT = -(NTAPS_US_LUMA>>1);
     333    Int rlClipB = heightBL - 1 + (NTAPS_US_LUMA>>1);
     334#else
    274335    Int leftStartL = scalEL.getWindowLeftOffset();
    275336    Int rightEndL  = pcUsPic->getWidth() - scalEL.getWindowRightOffset();
     
    277338    Int bottomEndL = pcUsPic->getHeight() - scalEL.getWindowBottomOffset();
    278339    Int leftOffset = leftStartL > 0 ? leftStartL : 0;
     340#endif
    279341#if O0194_JOINT_US_BITSHIFT
    280342    // g_bitDepthY was set to EL bit-depth, but shift1 should be calculated using BL bit-depth
     
    293355    for( i = 0; i < widthEL; i++ )
    294356    {
     357#if R0220_REMOVE_EL_CLIP
     358      Int x = i;
     359#if R0209_GENERIC_PHASE
     360      refPos16 = (((x - phaseXL)*scaleX - addX) >> shiftXM4) + refOffsetX;
     361#else
     362#if REF_REGION_OFFSET
     363      refPos16 = (((x - phaseXL)*scaleX + addX) >> shiftXM4) - deltaX + refOffsetX;
     364#else
     365      refPos16 = (((x - phaseXL)*scaleX + addX) >> shiftXM4) - deltaX;
     366#endif
     367#endif
     368#else
    295369      Int x = Clip3( leftStartL, rightEndL - 1, i );
     370#if REF_REGION_OFFSET
     371      refPos16 = (((x - leftStartL)*scaleX + addX) >> shiftXM4) - deltaX + refOffsetX;
     372#else
    296373      refPos16 = (((x - leftStartL)*scaleX + addX) >> shiftXM4) - deltaX;
     374#endif
     375#endif
    297376      phase    = refPos16 & 15;
    298377      refPos   = refPos16 >> 4;
     378#if R0220_REMOVE_EL_CLIP
     379      refPos   = Clip3( rlClipL, rlClipR, refPos );
     380#endif
    299381      coeff = m_lumaFilter[phase];
    300382
     
    325407    for( j = 0; j < pcTempPic->getHeight(); j++ )
    326408    {
     409#if R0220_REMOVE_EL_CLIP
     410      Int y = j;
     411#if R0209_GENERIC_PHASE
     412      refPos16 = ((( y - phaseYL )*scaleY - addY) >> shiftYM4) + refOffsetY;
     413#else
     414#if REF_REGION_OFFSET
     415      refPos16 = ((( y - phaseYL )*scaleY + addY) >> shiftYM4) - deltaY + refOffsetY;
     416#else
     417      refPos16 = ((( y - pahseYL )*scaleY + addY) >> shiftYM4) - deltaY;
     418#endif
     419#endif
     420#else
    327421      Int y = Clip3(topStartL, bottomEndL - 1, j);
     422#if REF_REGION_OFFSET
     423      refPos16 = ((( y - topStartL )*scaleY + addY) >> shiftYM4) - deltaY + refOffsetY;
     424#else
    328425      refPos16 = ((( y - topStartL )*scaleY + addY) >> shiftYM4) - deltaY;
     426#endif
     427#endif
    329428      phase    = refPos16 & 15;
    330429      refPos   = refPos16 >> 4;
     430#if R0220_REMOVE_EL_CLIP
     431      refPos = Clip3( rlClipT, rlClipB, refPos );
     432#endif
    331433      coeff = m_lumaFilter[phase];
    332434
    333435      piSrcY = piTempBufY + (refPos -((NTAPS_US_LUMA>>1) - 1))*strideEL;
    334436      Pel* piDstY0 = piDstBufY + j * strideEL;
    335       piDstY = piDstY0 + leftOffset;
    336       piSrcY += leftOffset;
    337 
    338       for( i = min<Int>(rightEndL, pcTempPic->getWidth()) - max<Int>(0, leftStartL); i > 0; i-- )
     437
     438#if R0220_REMOVE_EL_CLIP
     439      piDstY = piDstY0;
     440
     441      for( i = pcTempPic->getWidth(); i > 0; i-- )
    339442      {
    340443        *piDstY = ClipY( (sumLumaVer(piSrcY, coeff, strideEL) + iOffset) >> (nShift));
     
    342445        piDstY++;
    343446      }
     447#else
     448      piDstY = piDstY0 + leftOffset;
     449      piSrcY += leftOffset;
     450
     451      for( i = min<Int>(rightEndL, pcTempPic->getWidth()) - max<Int>(0, leftStartL); i > 0; i-- )
     452      {
     453        *piDstY = ClipY( (sumLumaVer(piSrcY, coeff, strideEL) + iOffset) >> (nShift));
     454        piSrcY++;
     455        piDstY++;
     456      }
    344457
    345458      for( i = rightEndL; i < pcTempPic->getWidth(); i++ )
     
    355468        piDstY++;
    356469      }
    357 
     470#endif
    358471    }
    359472
     
    374487    strideEL  = pcUsPic->getCStride();
    375488
     489#if R0220_REMOVE_EL_CLIP
     490    Int srlLOffsetC = scalEL.getWindowLeftOffset() >> 1;
     491    Int srlTOffsetC = scalEL.getWindowTopOffset() >> 1;
     492    rlClipL = -(NTAPS_US_CHROMA>>1);
     493    rlClipR = widthBL -1 + (NTAPS_US_CHROMA>>1);
     494    rlClipT = -(NTAPS_US_CHROMA>>1);
     495    rlClipB = heightBL - 1 + (NTAPS_US_CHROMA>>1);
     496#else
    376497    Int leftStartC = scalEL.getWindowLeftOffset() >> 1;
    377498    Int rightEndC  = (pcUsPic->getWidth() >> 1) - (scalEL.getWindowRightOffset() >> 1);
     
    379500    Int bottomEndC = (pcUsPic->getHeight() >> 1) - (scalEL.getWindowBottomOffset() >> 1);
    380501    leftOffset = leftStartC > 0 ? leftStartC : 0;
     502#endif
    381503    shiftX = 16;
    382504    shiftY = 16;
    383505
     506#if R0209_GENERIC_PHASE
     507    addX = ( ( phaseHorChroma * scaleX + 8 ) >> 4 ) -  (1 << ( shiftX - 5 ));
     508    addY = ( ( phaseVerChroma * scaleY + 8 ) >> 4 ) -  (1 << ( shiftX - 5 ));
     509    Int refOffsetXC = (windowRL.getWindowLeftOffset() / xScal) << 4;
     510    Int refOffsetYC = (windowRL.getWindowTopOffset()  / yScal) << 4;
     511#else
    384512#if O0215_PHASE_ALIGNMENT
    385513    Int phaseXC = phaseAlignFlag;
     
    417545#endif
    418546
     547#if REF_REGION_OFFSET
     548    Int refOffsetXC = (windowRL.getWindowLeftOffset() / xScal) << 4;
     549    Int refOffsetYC  = (windowRL.getWindowTopOffset()  / yScal) << 4;
     550#else
    419551#if Q0200_CONFORMANCE_BL_SIZE
    420552    deltaX -= ( ( confBL.getWindowLeftOffset() * xScal ) >> 1 ) << 4;
    421553    deltaY  -= ( ( confBL.getWindowTopOffset() * yScal ) >> 1 ) << 4;
     554#endif
     555#endif
    422556#endif
    423557
     
    447581    for( i = 0; i < widthEL; i++ )
    448582    {
     583#if R0220_REMOVE_EL_CLIP
     584      Int x = i;
     585#if R0209_GENERIC_PHASE
     586      refPos16 = (((x - srlLOffsetC)*scaleX - addX) >> shiftXM4) + refOffsetXC;
     587#else
     588#if REF_REGION_OFFSET
     589      refPos16 = (((x - srlLOffsetC)*scaleX + addX) >> shiftXM4) - deltaX + refOffsetXC;
     590#else
     591      refPos16 = (((x - srlLOffsetC)*scaleX + addX) >> shiftXM4) - deltaX;
     592#endif
     593#endif
     594#else
    449595      Int x = Clip3(leftStartC, rightEndC - 1, i);
     596#if REF_REGION_OFFSET
     597      refPos16 = (((x - leftStartC)*scaleX + addX) >> shiftXM4) - deltaX + refOffsetXC;
     598#else
    450599      refPos16 = (((x - leftStartC)*scaleX + addX) >> shiftXM4) - deltaX;
     600#endif
     601#endif
    451602      phase    = refPos16 & 15;
    452603      refPos   = refPos16 >> 4;
     604#if R0220_REMOVE_EL_CLIP
     605      refPos   = Clip3(rlClipL, rlClipR, refPos);
     606#endif
    453607      coeff = m_chromaFilter[phase];
    454608
     
    485639    for( j = 0; j < pcTempPic->getHeight() >> 1; j++ )
    486640    {
     641#if R0220_REMOVE_EL_CLIP
     642      Int y = j;
     643#if R0209_GENERIC_PHASE
     644      refPos16 = (((y - srlTOffsetC)*scaleX - addY) >> shiftYM4) + refOffsetYC;
     645#else
     646#if REF_REGION_OFFSET
     647      refPos16 = (((y - srlTOffsetC)*scaleY + addY) >> shiftYM4) - deltaY + refOffsetYC;
     648#else
     649      refPos16 = (((y - srlTOffsetC)*scaleY + addY) >> shiftYM4) - deltaY;
     650#endif
     651#endif
     652#else
    487653      Int y = Clip3(topStartC, bottomEndC - 1, j);
     654#if REF_REGION_OFFSET
     655      refPos16 = (((y - topStartC)*scaleY + addY) >> shiftYM4) - deltaY + refOffsetYC;
     656#else
    488657      refPos16 = (((y - topStartC)*scaleY + addY) >> shiftYM4) - deltaY;
     658#endif
     659#endif
    489660      phase    = refPos16 & 15;
    490661      refPos   = refPos16 >> 4;
     662#if R0220_REMOVE_EL_CLIP
     663      refPos = Clip3(rlClipT, rlClipB, refPos);
     664#endif
    491665      coeff = m_chromaFilter[phase];
    492666
     
    496670      Pel* piDstU0 = piDstBufU + j*strideEL;
    497671      Pel* piDstV0 = piDstBufV + j*strideEL;
    498       piDstU = piDstU0 + leftOffset;
    499       piDstV = piDstV0 + leftOffset;
    500       piSrcU += leftOffset;
    501       piSrcV += leftOffset;
    502 
    503       for( i = min<Int>(rightEndC, pcTempPic->getWidth() >> 1) - max<Int>(0, leftStartC); i > 0; i-- )
     672
     673#if R0220_REMOVE_EL_CLIP
     674      piDstU = piDstU0;
     675      piDstV = piDstV0;
     676
     677      for( i = pcTempPic->getWidth() >> 1; i > 0; i-- )
    504678      {
    505679        *piDstU = ClipC( (sumChromaVer(piSrcU, coeff, strideEL) + iOffset) >> (nShift));
     
    510684        piDstV++;
    511685      }
     686#else
     687      piDstU = piDstU0 + leftOffset;
     688      piDstV = piDstV0 + leftOffset;
     689      piSrcU += leftOffset;
     690      piSrcV += leftOffset;
     691
     692      for( i = min<Int>(rightEndC, pcTempPic->getWidth() >> 1) - max<Int>(0, leftStartC); i > 0; i-- )
     693      {
     694        *piDstU = ClipC( (sumChromaVer(piSrcU, coeff, strideEL) + iOffset) >> (nShift));
     695        *piDstV = ClipC( (sumChromaVer(piSrcV, coeff, strideEL) + iOffset) >> (nShift));
     696        piSrcU++;
     697        piSrcV++;
     698        piDstU++;
     699        piDstV++;
     700      }
    512701
    513702      for( i = rightEndC; i < pcTempPic->getWidth() >> 1; i++ )
     
    528717        piDstV++;
    529718      }
     719#endif
    530720
    531721    }
  • trunk/source/Lib/TLibCommon/TComUpsampleFilter.h

    r713 r906  
    5151#else
    5252#if O0194_JOINT_US_BITSHIFT
     53#if REF_REGION_OFFSET
     54  Void upsampleBasePic( TComSlice* currSlice, UInt refLayerIdc, TComPicYuv* pcUsPic, TComPicYuv* pcBasePic, TComPicYuv* pcTempPic, const Window window, const Window altRefWindow );
     55#else
    5356  Void upsampleBasePic( TComSlice* currSlice, UInt refLayerIdc, TComPicYuv* pcUsPic, TComPicYuv* pcBasePic, TComPicYuv* pcTempPic, const Window window );
     57#endif
    5458#else
    5559  Void upsampleBasePic( UInt refLayerIdc, TComPicYuv* pcUsPic, TComPicYuv* pcBasePic, TComPicYuv* pcTempPic, const Window window );
  • trunk/source/Lib/TLibCommon/TypeDef.h

    r815 r906  
    4141#define SVC_EXTENSION                    1
    4242
    43 #define SYNTAX_BYTES                     10     ///< number of bytes taken by syntaxes per 4x4 block [RefIdxL0(1byte), RefIdxL1(1byte), MVxL0(2bytes), MVyL0(2bytes), MVxL1(2bytes), MVyL1(2bytes)]
    4443#if SVC_EXTENSION
    4544#define MAX_LAYERS                       8      ///< max number of layers the codec is supposed to handle
    4645
     46#define SIGNALLING_BITRATE_PICRATE_FIX   1      ///< Fix for signalling of bitrate and picture rate info in VPS VUI to be more aligned to JCTVC-R1008
     47#define INFERENCE_POC_MSB_VAL_PRESENT    1      ///< JCTVC-Q0146 -- poc_msb_val_present_flag shall be equal to 0 when slice_header_extension_length is (inferred to be ) equal to 0
     48#define CROSS_LAYER_BLA_FLAG_FIX         1      ///< Fix for earlier implementation mistake that omit the signalling of cross_layer_bla_flag
     49#define NON_REF_NAL_TYPE_DISCARDABLE     1      ///< JCTVC-P0041 -- If discardable picture is a non-IRAP, it must be a non-referenced sub-layer picture
     50#define VPS_AVC_BL_FLAG_REMOVAL          1      ///< remove avc_base_layer_flag and direct the function its offer to vps_base_layer_internal_flag and vps_base_layer_available_flag
     51#define VPS_RESERVED_FLAGS               1      ///< vps_base_layer_internal_flag and vps_base_layer_available_flag
     52#define VPS_VUI_VST_PARAMS               1      ///< JCTVC-R0227: Related to signalling of VST parameters of the base layer.
    4753#define VPS_VUI_OFFSET                   1      ///< N0085: Signal VPS VUI offset in the VPS extension
     54#define REMOVE_BSP_HRD_SEI               1      ///< R0010: Remove bitstream partition HRD SEI message.
     55#define NESTING_SEI_EXTENSIBILITY        1      ///< R0221: Signalling the number of SEI messages in bitstream partition nesting SEI message
     56#define POC_RESET_RESTRICTIONS           1      ///< Restrictions on semantics of POC reset-related syntax elements, including one item from R0223
     57#define POC_RESET_VALUE_RESTRICTION      1      ///< R0223: Restriction on the value of full_poc_reset_flag
     58#define OUTPUT_LAYER_SETS_CONFIG         1
     59#define MOVE_ADDN_LS_SIGNALLING          1      ///< JCTVC-R0238: (Ed.) Move additional layer set signalling in VPS extn.
     60#define PTL_SIGNALLING                   1      ///< Overall macro for all PTL-related signalling
     61#if PTL_SIGNALLING
     62#define LIST_OF_PTL                      1      ///< JCTVC-R0272: Signalling the PTL for the 0-th OLS
     63#define NECESSARY_LAYER_FLAG             1      ////< Derivation of NecessaryLayerFlag
     64#define PER_LAYER_PTL                    1      ///< Signal profile-tier-level information for each layer.
     65#endif
     66#define BSP_INIT_ARRIVAL_SEI             1      ///< JCTVC-R0231: Make signalling of vcl_initial_arrival_delay independent of NalHrdBpPresentFlag
     67#define SUB_LAYERS_IN_LAYER_SET          1      ///< Move calculation of MaxSubLayerInLayerSets to a separate function
     68#define VPS_VUI_BSP_HRD_PARAMS           1      ///< JCTVC-R0231: Define the VPS VUI BSP hrd_params() as a separate function, and apply changes adopted.
    4869#define O0137_MAX_LAYERID                1      ///< JCTVC-O0137, JCTVC-O0200, JCTVC-O0223: restrict nuh_layer_id and vps_max_layers_minus1
    4970
    50 #define Q0108_TSA_STSA                   0      ///< JCTVC-Q0108, Remove cross-layer alignment constraints of TSA and STSA pictures, enable to have different prediction structures in different layers
     71#define R0226_CONSTRAINT_TMVP_SEI        1      ///< JCTVC-R0226, Modification to semantics in temporal motion vector prediction constraints SEI message
     72#define R0226_SLICE_TMVP                 1      ///< JCTVC-R0226, Regarding slice_temporal_mvp_enabled_flag
     73#define R0279_REP_FORMAT_INBL            1      ///< JCTVC-R0279, For any independent non-base layer the used representation format is the one that is signalled in the active SPS for the layer
     74#define R0227_VUI_BSP_HRD_FLAG           1      ///< JCTVC-R0227, Conformance checking such that VPS VUI HRD only present if VPS timing info is signalled
     75#define R0227_REP_FORMAT_CONSTRAINT      1      ///< JCTVC-R0227, Conformance checking such that representation format of a particular layer shall not be greater than the one defined in VPS for that layer
     76#define R0227_BR_PR_ADD_LAYER_SET        1      ///< JCTVC-R0227, Signalling of bit-rate and picture rate for additional layer set
     77#define R0042_PROFILE_INDICATION         1      ///< JCTVC-R0042, Profile indication for additional layer sets
     78
     79#define Q0108_TSA_STSA                   1      ///< JCTVC-Q0108, Remove cross-layer alignment constraints of TSA and STSA pictures, enable to have different prediction structures in different layers
    5180#define Q0177_SPS_TEMP_NESTING_FIX       1      ///< JCTVC-Q0177; Fix the inference value of sps_temporal_id_nesting_flag when it is not present
    5281#define Q0177_EOS_CHECKS                 1      ///< JCTVC-Q0177; Put checks on handling EOS
     
    5483#define Q0146_SSH_EXT_DATA_BIT           1      ///< JCTVC-Q0146; Bug-fix -- the SSH_EXT_DATA_BIT can have any value -- not required to be 1
    5584
    56 #define Q0200_CONFORMANCE_BL_SIZE        1      ///< JCTVC-Q0200; use conformance picture size in re-sampling processs
    57 #define P0312_VERT_PHASE_ADJ             1      ///< JCTVC-P0312: vertical phase adjustment in re-sampling process (BoG report)
    58 #if P0312_VERT_PHASE_ADJ
    59 #define Q0120_PHASE_CALCULATION          1      ///< JCTVC-Q0120 phase offset derivation for combination of spatial scalibility and field coding.
    60 #endif
    6185#define P0130_EOB                        1      ///< JCTVC-P0130, set layer Id of EOB NALU to be fixed to 0
     86#define T_ID_EOB_BUG_FIX                 1      ///< Bug fix for the value of temporal id of EOB NALU. It must be set to 0
    6287#define P0307_REMOVE_VPS_VUI_OFFSET      1      ///< JCTVC-P0307, remove implementation related to VPS VUI offset signalling
    6388#define P0307_VPS_NON_VUI_EXTENSION      1      ///< JCTVC-P0307, implementation related to NON VUI VPS Extension signalling
     
    94119#if Q0048_CGS_3D_ASYMLUT
    95120#define CGS_GCC_NO_VECTORIZATION         1
    96 #define O0194_WEIGHTED_PREDICTION_CGS    0
    97 #else
    98 #define O0194_WEIGHTED_PREDICTION_CGS    1      ///< JCTVC-O0194: Weighted prediciton for color gamut scalability
    99 #endif
     121#define R0150_CGS_SIGNAL_CONSTRAINTS     1      ///< JCTVC-R0150: CGS signaling improvement and constraints
     122#define R0151_CGS_3D_ASYMLUT_IMPROVE     1      ///< JCTVC-R0151: Non-uniform chroma partitioning and improved LUT coefficient coding
     123#define R0164_CGS_LUT_BUGFIX             1      ///< JCTVC-R0164: Bug fix with LUT syntax
     124#define R0164_CGS_LUT_BUGFIX_CHECK       0      ///< JCTVC-R0164: Add traces explicitly/non-explicitly encoded vertices and check if 3DLUT is correctly filled
     125#define R0179_CGS_SIZE_8x1x1             1      ///< JCTVC-R0179: allow CGS LUT size to be 8x1x1 as well
     126#define R0300_CGS_RES_COEFF_CODING       1      ///< JCTVC-R0300: improved residual coefficient coding for R0151
     127#define R0179_ENC_OPT_3DLUT_SIZE         0      ///< JCTVC-R0179: RD decision based LUT size selection
     128#endif
     129#define O0194_WEIGHTED_PREDICTION_CGS    1      ///< JCTVC-O0194: Weighted prediction for colour gamut scalability
    100130#define POC_RESET_FLAG                   0      ///< JCTVC-N0244: POC reset flag for  layer pictures.
    101131#define POC_RESET_IDC                    1      ///< JCTVC-P0041: Include poc_reset_idc and related derivation - eventually will replace POC_RESET_FLAG
     
    107137#define UNAVAILABLE_PIC_BUGFIX           1
    108138#endif
     139#if INFERENCE_POC_MSB_VAL_PRESENT
     140#define POC_MSB_VAL_PRESENT_FLAG_SEM     0      ///< JCTVC-Q0146: Inference of poc_msb_val_present_flag
     141#else
    109142#define POC_MSB_VAL_PRESENT_FLAG_SEM     1      ///< JCTVC-Q0146: Inference of poc_msb_val_present_flag
     143#endif
    110144#define POC_RESET_INFO_INFERENCE         1      ///< JCTVC-Q0146: Infer the value of poc_reset_info_present_flag when not present
    111145#define NO_OUTPUT_OF_PRIOR_PICS          1      ///< Use no_output_of_prior_pics_flag
     
    123157#endif
    124158
     159#define P0297_VPS_POC_LSB_ALIGNED_FLAG   1      ///< JCTVC-P0297: vps_poc_lsb_aligned_flag for cross-layer POC anchor picture derivation
     160
    125161#define VPS_EXTN_MASK_AND_DIM_INFO       1      ///< Include avc_base_layer_flag, splitting_flag, scalability mask and dimension related info
    126162#if VPS_EXTN_MASK_AND_DIM_INFO
     
    152188
    153189#define AVC_BASE                         1      ///< YUV BL reading for AVC base SVC
    154 #if AVC_BASE
    155 #define AVC_SYNTAX                       0      ///< Syntax reading for AVC base
    156 #endif
    157190
    158191#define REF_IDX_MFM                      1      ///< JCTVC-L0336: motion vector mapping of inter-layer reference picture
     
    193226#define REP_FORMAT_FIX                   1      ///< update_rep_format_flag should be inferred to be equal to 0
    194227
     228#define R0156_CONF_WINDOW_IN_REP_FORMAT  O0096_REP_FORMAT_INDEX ///< JCTVC-R0156: add conformance window cropping offsets to rep_format()
     229
    195230#define RESAMPLING_CONSTRAINT_BUG_FIX    1
    196231#define O0098_SCALED_REF_LAYER_ID        1      ///< JCTVC-O0098: signal scaled reference id
     
    226261#define HRD_BPB                          1      ///< JCTVC-Q0101 Bitstream Partition Buffering Proposals
    227262#define DPB_CONSTRAINTS                  1      ///< JCTVC-Q0100 RPS DPB constraints
     263#define DPB_INTERNAL_BL_SIG              1      ///< JCTVC-R0153: external base layer
     264#define ALT_OPT_LAYER_FLAG               1      ///< JCTVC-R0154: proposal1 - alt_output_layer_flag[i] inference
     265#define DEF_OPT_LAYER_IDC                1      ///< JCTVC-R0154: proposal2 - default_output_layer_idc and output_layer_flag[i][j]
     266#define ISLICE_TYPE_NUMDIR               1      ///< JCTVC-R0155: Proposal 1 I slice_type
     267#define OLS_IDX_CHK                      1      ///< JCTVC-R0155: Proposal 2 valid range for output_layer_set_idx_to_vps[i]
     268#define R0340_RESAMPLING_MODIFICATION    1      ///< JCTVC-R0340: set of changes regarding resampling (as listed below)
     269#if R0340_RESAMPLING_MODIFICATION
     270#define MOVE_SCALED_OFFSET_TO_PPS        1      ///< JCTVC-R0013: move scaled reference layer offset from SPS to PPS
     271#if MOVE_SCALED_OFFSET_TO_PPS
     272#define REF_REGION_OFFSET                1      ///< JCTVC-Q0159/R0220: reference region offset
     273#define R0209_GENERIC_PHASE              1      ///< JCTVC-R0209: resampling with generic phase
     274#define R0220_REMOVE_EL_CLIP             1      ///< JCTVC-R0220: remove clip to scaled ref window in resampling process
     275#define RESAMPLING_FIX                   1      ///< Resampling fix -- equal offset check and conformance check
     276#endif
     277#else
     278#define Q0200_CONFORMANCE_BL_SIZE        1      ///< JCTVC-Q0200; use conformance picture size in re-sampling processs
     279#define P0312_VERT_PHASE_ADJ             1      ///< JCTVC-P0312: vertical phase adjustment in re-sampling process (BoG report)
     280#if P0312_VERT_PHASE_ADJ
     281#define Q0120_PHASE_CALCULATION          1      ///< JCTVC-Q0120 phase offset derivation for combination of spatial scalibility and field coding.
     282#endif
     283#endif
    228284
    229285/// scalability types
     
    234290  AUX_ID            = 3,
    235291};
     292
     293#define WPP_FIX                          1
    236294
    237295/// normative encoder constraints --------
     
    255313#define MAX_SUB_STREAMS                  1024
    256314#endif
    257 #define Q0074_SEI_COLOR_MAPPING          1      ///< JCTVC-Q0074, SEI Color Mapping
    258315#define LAYERS_NOT_PRESENT_SEI           1      ///< JCTVC-M0043: add layers not present SEI.
    259316#define N0383_IL_CONSTRAINED_TILE_SETS_SEI  1
    260317#define Q0189_TMVP_CONSTRAINTS           1      ///< JCTVC-Q0189: indicate constraints on TMVP
    261318#define Q0247_FRAME_FIELD_INFO           1      ///< JCTVC-Q0247: field_frame_info SEI message
    262 
    263 
    264 #else
    265 #define SYNTAX_OUTPUT                    0
     319#define R0247_SEI_ACTIVE                 1      ///< JCTVC-R0247: active parameter sets SEI message
     320
    266321#endif // SVC_EXTENSION
     322#define Q0074_COLOUR_REMAPPING_SEI       1      ///< JCTVC-Q0074, JCTVC-R0344: SEI Colour Remapping Information
    267323
    268324
     
    278334#define SAO_SGN_FUNC 1
    279335
     336#define TILE_SIZE_CHECK 1
     337
    280338#define FIX1172 1 ///< fix ticket #1172
    281339
     
    292350#define MAX_NESTING_NUM_OPS         1024
    293351#define MAX_NESTING_NUM_LAYER       64
    294 
     352#if NESTING_SEI_EXTENSIBILITY
     353#define MAX_SEIS_IN_BSP_NESTING     64
     354#endif
    295355#if SVC_EXTENSION
    296356#define MAX_VPS_OP_LAYER_SETS_PLUS1               (MAX_LAYERS+1)
    297357#define MAX_VPS_LAYER_SETS_PLUS1                  1024
     358#define MAX_VPS_OUTPUT_LAYER_SETS_PLUS1           1024
    298359#define MAX_VPS_LAYER_ID_PLUS1                    MAX_LAYERS
    299360#else
     
    438499typedef       double              Double;
    439500typedef       float               Float;
    440 
    441501// ====================================================================================================================
    442502// 64-bit integer type
  • trunk/source/Lib/TLibDecoder/SEIread.cpp

    r815 r906  
    9898    break;
    9999#endif
    100 #if Q0074_SEI_COLOR_MAPPING
    101   case SEI::COLOR_MAPPING_INFO:
    102     fprintf( g_hTrace, "===========Color Mapping Info SEI message ===========\n");
     100#if Q0074_COLOUR_REMAPPING_SEI
     101  case SEI::COLOUR_REMAPPING_INFO:
     102    fprintf( g_hTrace, "===========Colour Remapping Information SEI message ===========\n");
    103103    break;
    104104#endif
     
    132132    fprintf( g_hTrace, "=========== Bitstream parition initial arrival time SEI message ===========\n");
    133133    break;
     134#if !REMOVE_BSP_HRD_SEI
    134135  case SEI::BSP_HRD:
    135136    fprintf( g_hTrace, "=========== Bitstream parition HRD parameters SEI message ===========\n");
    136137    break;
     138#endif
    137139#endif
    138140#if Q0078_ADD_LAYER_SETS
     
    249251      {
    250252        sei = new SEIDecodingUnitInfo;
     253#if VPS_VUI_BSP_HRD_PARAMS
     254        xParseSEIDecodingUnitInfo((SEIDecodingUnitInfo&) *sei, payloadSize, sps, nestingSei, bspNestingSei, vps);
     255#else
    251256        xParseSEIDecodingUnitInfo((SEIDecodingUnitInfo&) *sei, payloadSize, sps);
     257#endif
    252258      }
    253259      break;
     
    260266      {
    261267        sei = new SEIBufferingPeriod;
     268#if VPS_VUI_BSP_HRD_PARAMS
     269        xParseSEIBufferingPeriod((SEIBufferingPeriod&) *sei, payloadSize, sps, nestingSei, bspNestingSei, vps);
     270#else
    262271        xParseSEIBufferingPeriod((SEIBufferingPeriod&) *sei, payloadSize, sps);
     272#endif
    263273      }
    264274      break;
     
    271281      {
    272282        sei = new SEIPictureTiming;
     283#if VPS_VUI_BSP_HRD_PARAMS
     284        xParseSEIPictureTiming((SEIPictureTiming&)*sei, payloadSize, sps, nestingSei, bspNestingSei, vps);
     285#else
    273286        xParseSEIPictureTiming((SEIPictureTiming&)*sei, payloadSize, sps);
     287#endif
    274288      }
    275289      break;
     
    304318      break;
    305319#endif
    306 #if Q0074_SEI_COLOR_MAPPING
    307     case SEI::COLOR_MAPPING_INFO:
    308       sei = new SEIColorMappingInfo;
    309       xParseSEIColorMappingInfo((SEIColorMappingInfo&) *sei, payloadSize);
     320#if Q0074_COLOUR_REMAPPING_SEI
     321    case SEI::COLOUR_REMAPPING_INFO:
     322      sei = new SEIColourRemappingInfo;
     323      xParseSEIColourRemappingInfo((SEIColourRemappingInfo&) *sei, payloadSize);
    310324      break;
    311325#endif
     
    345359   case SEI::SUB_BITSTREAM_PROPERTY:
    346360     sei = new SEISubBitstreamProperty;
     361#if OLS_IDX_CHK
     362     xParseSEISubBitstreamProperty((SEISubBitstreamProperty&) *sei, vps);
     363#else
    347364     xParseSEISubBitstreamProperty((SEISubBitstreamProperty&) *sei);
     365#endif
    348366     break;
    349367#endif
     
    361379     xParseSEIBspInitialArrivalTime((SEIBspInitialArrivalTime&) *sei, vps, sps, *nestingSei, *bspNestingSei);
    362380     break;
     381#if !REMOVE_BSP_HRD_SEI
    363382   case SEI::BSP_HRD:
    364383     sei = new SEIBspHrd;
    365384     xParseSEIBspHrd((SEIBspHrd&) *sei, sps, *nestingSei);
    366385     break;
     386#endif
    367387#endif
    368388#if Q0078_ADD_LAYER_SETS
     
    580600
    581601  sei.activeSeqParameterSetId.resize(sei.numSpsIdsMinus1 + 1);
     602#if R0247_SEI_ACTIVE
     603  sei.layerSpsIdx.resize(sei.numSpsIdsMinus1 + 1);
     604#endif
    582605  for (Int i=0; i < (sei.numSpsIdsMinus1 + 1); i++)
    583606  {
    584607    READ_UVLC(val, "active_seq_parameter_set_id");      sei.activeSeqParameterSetId[i] = val;
    585608  }
    586 
     609#if R0247_SEI_ACTIVE
     610  for (Int i=1; i < (sei.numSpsIdsMinus1 + 1); i++)
     611  {
     612    READ_UVLC(val, "layer_sps_idx"); sei.layerSpsIdx[i] = val;
     613  }
     614#endif
    587615  xParseByteAlign();
    588616}
    589617
     618#if VPS_VUI_BSP_HRD_PARAMS
     619Void SEIReader::xParseSEIDecodingUnitInfo(SEIDecodingUnitInfo& sei, UInt /*payloadSize*/, TComSPS *sps, const SEIScalableNesting* nestingSei, const SEIBspNesting* bspNestingSei, TComVPS *vps)
     620#else
    590621Void SEIReader::xParseSEIDecodingUnitInfo(SEIDecodingUnitInfo& sei, UInt /*payloadSize*/, TComSPS *sps)
     622#endif
    591623{
    592624  UInt val;
     
    594626  sei.m_decodingUnitIdx = val;
    595627
     628#if VPS_VUI_BSP_HRD_PARAMS
     629  TComHRD *hrd;
     630  if( bspNestingSei )   // If DU info SEI contained inside a BSP nesting SEI message
     631  {
     632    assert( nestingSei );
     633    Int psIdx = bspNestingSei->m_seiPartitioningSchemeIdx;
     634    Int seiOlsIdx = bspNestingSei->m_seiOlsIdx;
     635    Int maxTemporalId = nestingSei->m_nestingMaxTemporalIdPlus1[0] - 1;
     636    Int maxValues = vps->getNumBspSchedulesMinus1(seiOlsIdx, psIdx, maxTemporalId) + 1;
     637    std::vector<Int> hrdIdx(maxValues, 0);
     638    std::vector<TComHRD *> hrdVec;
     639    std::vector<Int> syntaxElemLen(maxValues, 0);
     640    for(Int i = 0; i < maxValues; i++)
     641    {
     642      hrdIdx[i] = vps->getBspHrdIdx( seiOlsIdx, psIdx, maxTemporalId, i, bspNestingSei->m_bspIdx);
     643      hrdVec.push_back(vps->getBspHrd(hrdIdx[i]));
     644   
     645      syntaxElemLen[i] = hrdVec[i]->getInitialCpbRemovalDelayLengthMinus1() + 1;
     646      if ( !(hrdVec[i]->getNalHrdParametersPresentFlag() || hrdVec[i]->getVclHrdParametersPresentFlag()) )
     647      {
     648        assert( syntaxElemLen[i] == 24 ); // Default of value init_cpb_removal_delay_length_minus1 is 23
     649      }
     650      if( i > 0 )
     651      {
     652        assert( hrdVec[i]->getSubPicCpbParamsPresentFlag()    == hrdVec[i-1]->getSubPicCpbParamsPresentFlag() );
     653        assert( hrdVec[i]->getSubPicCpbParamsInPicTimingSEIFlag()   == hrdVec[i-1]->getSubPicCpbParamsInPicTimingSEIFlag() );
     654        assert( hrdVec[i]->getDpbOutputDelayDuLengthMinus1()  == hrdVec[i-1]->getDpbOutputDelayDuLengthMinus1() );
     655        // To be done: Check CpbDpbDelaysPresentFlag
     656      }
     657    }
     658    hrd = hrdVec[0];
     659  }
     660  else
     661  {
     662    TComVUI *vui = sps->getVuiParameters();
     663    hrd = vui->getHrdParameters();
     664  }
     665#else
    596666  TComVUI *vui = sps->getVuiParameters();
    597   if(vui->getHrdParameters()->getSubPicCpbParamsInPicTimingSEIFlag())
    598   {
    599     READ_CODE( ( vui->getHrdParameters()->getDuCpbRemovalDelayLengthMinus1() + 1 ), val, "du_spt_cpb_removal_delay");
     667  TComHrd *hrd = vui->getHrdParameters();
     668#endif
     669  if(hrd->getSubPicCpbParamsInPicTimingSEIFlag())
     670  {
     671    READ_CODE( ( hrd->getDuCpbRemovalDelayLengthMinus1() + 1 ), val, "du_spt_cpb_removal_delay");
    600672    sei.m_duSptCpbRemovalDelay = val;
    601673  }
     
    607679  if(sei.m_dpbOutputDuDelayPresentFlag)
    608680  {
    609     READ_CODE(vui->getHrdParameters()->getDpbOutputDelayDuLengthMinus1() + 1, val, "pic_spt_dpb_output_du_delay");
     681    READ_CODE(hrd->getDpbOutputDelayDuLengthMinus1() + 1, val, "pic_spt_dpb_output_du_delay");
    610682    sei.m_picSptDpbOutputDuDelay = val;
    611683  }
     
    613685}
    614686
     687#if VPS_VUI_BSP_HRD_PARAMS
     688Void SEIReader::xParseSEIBufferingPeriod(SEIBufferingPeriod& sei, UInt /*payloadSize*/, TComSPS *sps, const SEIScalableNesting* nestingSei, const SEIBspNesting* bspNestingSei, TComVPS *vps)
     689#else
    615690Void SEIReader::xParseSEIBufferingPeriod(SEIBufferingPeriod& sei, UInt /*payloadSize*/, TComSPS *sps)
     691#endif
    616692{
    617693  Int i, nalOrVcl;
    618694  UInt code;
    619695
     696#if VPS_VUI_BSP_HRD_PARAMS
     697  TComHRD *pHRD;
     698  if( bspNestingSei )   // If BP SEI contained inside a BSP nesting SEI message
     699  {
     700    assert( nestingSei );
     701    Int psIdx = bspNestingSei->m_seiPartitioningSchemeIdx;
     702    Int seiOlsIdx = bspNestingSei->m_seiOlsIdx;
     703    Int maxTemporalId = nestingSei->m_nestingMaxTemporalIdPlus1[0] - 1;
     704    Int maxValues = vps->getNumBspSchedulesMinus1(seiOlsIdx, psIdx, maxTemporalId) + 1;
     705    std::vector<Int> hrdIdx(maxValues, 0);
     706    std::vector<TComHRD *> hrdVec;
     707    std::vector<Int> syntaxElemLen(maxValues, 0);
     708    for(i = 0; i < maxValues; i++)
     709    {
     710      hrdIdx[i] = vps->getBspHrdIdx( seiOlsIdx, psIdx, maxTemporalId, i, bspNestingSei->m_bspIdx);
     711      hrdVec.push_back(vps->getBspHrd(hrdIdx[i]));
     712   
     713      syntaxElemLen[i] = hrdVec[i]->getInitialCpbRemovalDelayLengthMinus1() + 1;
     714      if ( !(hrdVec[i]->getNalHrdParametersPresentFlag() || hrdVec[i]->getVclHrdParametersPresentFlag()) )
     715      {
     716        assert( syntaxElemLen[i] == 24 ); // Default of value init_cpb_removal_delay_length_minus1 is 23
     717      }
     718      if( i > 0 )
     719      {
     720        assert( hrdVec[i]->getCpbRemovalDelayLengthMinus1()   == hrdVec[i-1]->getCpbRemovalDelayLengthMinus1() );
     721        assert( hrdVec[i]->getDpbOutputDelayDuLengthMinus1()  == hrdVec[i-1]->getDpbOutputDelayDuLengthMinus1() );
     722        assert( hrdVec[i]->getSubPicCpbParamsPresentFlag()    == hrdVec[i-1]->getSubPicCpbParamsPresentFlag() );
     723      }
     724    }
     725    pHRD = hrdVec[i];
     726  }
     727  else
     728  {
     729    TComVUI *vui = sps->getVuiParameters();
     730    pHRD = vui->getHrdParameters();
     731  }
     732  // To be done: When contained in an BSP HRD SEI message, the hrd structure is to be chosen differently.
     733#else
    620734  TComVUI *pVUI = sps->getVuiParameters();
    621735  TComHRD *pHRD = pVUI->getHrdParameters();
     736#endif
    622737
    623738  READ_UVLC( code, "bp_seq_parameter_set_id" );                         sei.m_bpSeqParameterSetId     = code;
     
    671786  xParseByteAlign();
    672787}
     788#if VPS_VUI_BSP_HRD_PARAMS
     789Void SEIReader::xParseSEIPictureTiming(SEIPictureTiming& sei, UInt /*payloadSize*/, TComSPS *sps, const SEIScalableNesting* nestingSei, const SEIBspNesting* bspNestingSei, TComVPS *vps)
     790#else
    673791Void SEIReader::xParseSEIPictureTiming(SEIPictureTiming& sei, UInt /*payloadSize*/, TComSPS *sps)
     792#endif
    674793{
    675794  Int i;
    676795  UInt code;
    677796
     797#if VPS_VUI_BSP_HRD_PARAMS
     798  TComHRD *hrd;   
     799  TComVUI *vui = sps->getVuiParameters();
     800  if( bspNestingSei )   // If BP SEI contained inside a BSP nesting SEI message
     801  {
     802    assert( nestingSei );
     803    Int psIdx = bspNestingSei->m_seiPartitioningSchemeIdx;
     804    Int seiOlsIdx = bspNestingSei->m_seiOlsIdx;
     805    Int maxTemporalId = nestingSei->m_nestingMaxTemporalIdPlus1[0] - 1;
     806    Int maxValues = vps->getNumBspSchedulesMinus1(seiOlsIdx, psIdx, maxTemporalId) + 1;
     807    std::vector<Int> hrdIdx(maxValues, 0);
     808    std::vector<TComHRD *> hrdVec;
     809    std::vector<Int> syntaxElemLen(maxValues, 0);
     810    for(i = 0; i < maxValues; i++)
     811    {
     812      hrdIdx[i] = vps->getBspHrdIdx( seiOlsIdx, psIdx, maxTemporalId, i, bspNestingSei->m_bspIdx);
     813      hrdVec.push_back(vps->getBspHrd(hrdIdx[i]));
     814   
     815      syntaxElemLen[i] = hrdVec[i]->getInitialCpbRemovalDelayLengthMinus1() + 1;
     816      if ( !(hrdVec[i]->getNalHrdParametersPresentFlag() || hrdVec[i]->getVclHrdParametersPresentFlag()) )
     817      {
     818        assert( syntaxElemLen[i] == 24 ); // Default of value init_cpb_removal_delay_length_minus1 is 23
     819      }
     820      if( i > 0 )
     821      {
     822        assert( hrdVec[i]->getSubPicCpbParamsPresentFlag()    == hrdVec[i-1]->getSubPicCpbParamsPresentFlag() );
     823        assert( hrdVec[i]->getSubPicCpbParamsInPicTimingSEIFlag()   == hrdVec[i-1]->getSubPicCpbParamsInPicTimingSEIFlag() );
     824        assert( hrdVec[i]->getCpbRemovalDelayLengthMinus1()  == hrdVec[i-1]->getCpbRemovalDelayLengthMinus1() );
     825        assert( hrdVec[i]->getDpbOutputDelayLengthMinus1()  == hrdVec[i-1]->getDpbOutputDelayLengthMinus1() );
     826        assert( hrdVec[i]->getDpbOutputDelayDuLengthMinus1()  == hrdVec[i-1]->getDpbOutputDelayDuLengthMinus1() );
     827        assert( hrdVec[i]->getDuCpbRemovalDelayLengthMinus1()  == hrdVec[i-1]->getDuCpbRemovalDelayLengthMinus1() );
     828        // To be done: Check CpbDpbDelaysPresentFlag
     829      }
     830    }
     831    hrd = hrdVec[0];
     832  }
     833  else
     834  {
     835    hrd = vui->getHrdParameters();
     836  }
     837  // To be done: When contained in an BSP HRD SEI message, the hrd structure is to be chosen differently.
     838#else
    678839  TComVUI *vui = sps->getVuiParameters();
    679840  TComHRD *hrd = vui->getHrdParameters();
     841#endif
    680842
    681843  if( vui->getFrameFieldInfoPresentFlag() )
     
    9211083#endif
    9221084
    923 #if Q0074_SEI_COLOR_MAPPING
    924 Void SEIReader::xParseSEIColorMappingInfo(SEIColorMappingInfo& sei, UInt /*payloadSize*/)
     1085#if Q0074_COLOUR_REMAPPING_SEI
     1086Void SEIReader::xParseSEIColourRemappingInfo(SEIColourRemappingInfo& sei, UInt /*payloadSize*/)
    9251087{
    9261088  UInt  uiVal;
    9271089  Int   iVal;
    9281090
    929   READ_UVLC( uiVal, "colour_map_id" );          sei.m_colorMapId = uiVal;
    930   READ_FLAG( uiVal, "colour_map_cancel_flag" ); sei.m_colorMapCancelFlag = uiVal;
    931   if( !sei.m_colorMapCancelFlag )
    932   {
    933     READ_FLAG( uiVal, "colour_map_persistence_flag" );                sei.m_colorMapPersistenceFlag = uiVal;
    934     READ_FLAG( uiVal, "colour_map_video_signal_type_present_flag" );  sei.m_colorMap_video_signal_type_present_flag = uiVal;
    935     if ( sei.m_colorMap_video_signal_type_present_flag ) {
    936       READ_FLAG( uiVal,     "colour_map_video_full_range_flag" );     sei.m_colorMap_video_full_range_flag = uiVal;
    937       READ_CODE( 8, uiVal,  "colour_map_primaries" );                 sei.m_colorMap_primaries = uiVal;
    938       READ_CODE( 8, uiVal,  "colour_map_transfer_characteristics" );  sei.m_colorMap_transfer_characteristics = uiVal;
    939       READ_CODE( 8, uiVal,  "colour_map_matrix_coeffs" );             sei.m_colorMap_matrix_coeffs = uiVal;
    940     }
    941   }
    942 
    943   READ_CODE( 5, uiVal,  "colour_map_coded_data_bit_depth" );  sei.m_colour_map_coded_data_bit_depth = uiVal;
    944   READ_CODE( 5, uiVal,  "colour_map_target_bit_depth" );      sei.m_colour_map_target_bit_depth = uiVal;
    945   READ_UVLC( uiVal, "colour_map_model_id" );                  sei.m_colorMapModelId = uiVal;
    946 
    947   assert( sei.m_colorMapModelId == 0 );
     1091  READ_UVLC( uiVal, "colour_remap_id" );          sei.m_colourRemapId = uiVal;
     1092  READ_FLAG( uiVal, "colour_remap_cancel_flag" ); sei.m_colourRemapCancelFlag = uiVal;
     1093  if( !sei.m_colourRemapCancelFlag )
     1094  {
     1095    READ_FLAG( uiVal, "colour_remap_persistence_flag" );                sei.m_colourRemapPersistenceFlag = uiVal;
     1096    READ_FLAG( uiVal, "colour_remap_video_signal_info_present_flag" );  sei.m_colourRemapVideoSignalInfoPresentFlag = uiVal;
     1097    if ( sei.m_colourRemapVideoSignalInfoPresentFlag )
     1098    {
     1099      READ_FLAG( uiVal,    "colour_remap_full_range_flag" );           sei.m_colourRemapFullRangeFlag = uiVal;
     1100      READ_CODE( 8, uiVal, "colour_remap_primaries" );                 sei.m_colourRemapPrimaries = uiVal;
     1101      READ_CODE( 8, uiVal, "colour_remap_transfer_function" );         sei.m_colourRemapTransferFunction = uiVal;
     1102      READ_CODE( 8, uiVal, "colour_remap_matrix_coefficients" );       sei.m_colourRemapMatrixCoefficients = uiVal;
     1103    }
     1104    READ_CODE( 8, uiVal, "colour_remap_input_bit_depth" ); sei.m_colourRemapInputBitDepth = uiVal;
     1105    READ_CODE( 8, uiVal, "colour_remap_bit_depth" ); sei.m_colourRemapBitDepth = uiVal;
    9481106 
    949   for( Int i=0 ; i<3 ; i++ )
    950   {
    951     READ_CODE( 8, uiVal, "num_input_pivots_minus1[i]" ); sei.m_num_input_pivots[i] = (uiVal==0) ? 2 : (uiVal + 1) ;
    952     sei.m_coded_input_pivot_value[i]   = new Int[ sei.m_num_input_pivots[i] ];
    953     sei.m_target_input_pivot_value[i]  = new Int[ sei.m_num_input_pivots[i] ];
    954     if( uiVal > 0 )
    955     {
    956       for ( Int j=0 ; j<sei.m_num_input_pivots[i] ; j++ )
    957       {
    958         READ_CODE( (( sei.m_colour_map_coded_data_bit_depth + 7 ) >> 3 ) << 3, uiVal, "coded_input_pivot_value[i][j]" );  sei.m_coded_input_pivot_value[i][j] = uiVal;
    959         READ_CODE( (( sei.m_colour_map_coded_data_bit_depth + 7 ) >> 3 ) << 3, uiVal, "target_input_pivot_value[i][j]" ); sei.m_target_input_pivot_value[i][j] = uiVal;
    960       }
    961     }
    962     else
    963     {
    964       sei.m_coded_input_pivot_value[i][0]  = 0;
    965       sei.m_target_input_pivot_value[i][0] = 0;
    966       sei.m_coded_input_pivot_value[i][1]  = (1 << sei.m_colour_map_coded_data_bit_depth) - 1 ;
    967       sei.m_target_input_pivot_value[i][1] = (1 << sei.m_colour_map_target_bit_depth) - 1 ;
    968     }
    969   }
    970 
    971   READ_FLAG( uiVal,           "matrix_flag" ); sei.m_matrix_flag = uiVal;
    972   if( sei.m_matrix_flag )
    973   {
    974     READ_CODE( 4, uiVal,         "log2_matrix_denom" ); sei.m_log2_matrix_denom = uiVal;
    975     for ( Int i=0 ; i<3 ; i++ )
    976     {
    977       for ( Int j=0 ; j<3 ; j++ )
    978       {
    979         READ_SVLC( iVal,        "matrix_coef[i][j]" ); sei.m_matrix_coef[i][j] = iVal;
    980       }
    981     }
    982   }
    983 
    984   for ( Int i=0 ; i<3 ; i++ )
    985   {
    986     READ_CODE( 8, uiVal, "num_output_pivots_minus1[i]" ); sei.m_num_output_pivots[i] = (uiVal==0) ? 2 : (uiVal + 1) ;
    987     sei.m_coded_output_pivot_value[i]   = new Int[ sei.m_num_output_pivots[i] ];
    988     sei.m_target_output_pivot_value[i]  = new Int[ sei.m_num_output_pivots[i] ];
    989     if( uiVal > 0 )
    990     {
    991       for ( Int j=0 ; j<sei.m_num_output_pivots[i] ; j++ )
    992       {
    993         READ_CODE( (( sei.m_colour_map_coded_data_bit_depth + 7 ) >> 3 ) << 3, uiVal, "coded_output_pivot_value[i][j]" );  sei.m_coded_output_pivot_value[i][j] = uiVal;
    994         READ_CODE( (( sei.m_colour_map_coded_data_bit_depth + 7 ) >> 3 ) << 3, uiVal, "target_output_pivot_value[i][j]" ); sei.m_target_output_pivot_value[i][j] = uiVal;
    995       }
    996     }
    997     else
    998     {
    999       sei.m_coded_output_pivot_value[i][0]  = 0;
    1000       sei.m_target_output_pivot_value[i][0] = 0;
    1001       sei.m_coded_output_pivot_value[i][1]  = (1 << sei.m_colour_map_coded_data_bit_depth) - 1 ;
    1002       sei.m_target_output_pivot_value[i][1] = (1 << sei.m_colour_map_target_bit_depth) - 1 ;
     1107    for( Int c=0 ; c<3 ; c++ )
     1108    {
     1109      READ_CODE( 8, uiVal, "pre_lut_num_val_minus1[c]" ); sei.m_preLutNumValMinus1[c] = (uiVal==0) ? 1 : uiVal;
     1110      sei.m_preLutCodedValue[c].resize(sei.m_preLutNumValMinus1[c]+1);
     1111      sei.m_preLutTargetValue[c].resize(sei.m_preLutNumValMinus1[c]+1);
     1112      if( uiVal> 0 )
     1113        for ( Int i=0 ; i<=sei.m_preLutNumValMinus1[c] ; i++ )
     1114        {
     1115          READ_CODE( (( sei.m_colourRemapInputBitDepth   + 7 ) >> 3 ) << 3, uiVal, "pre_lut_coded_value[c][i]" );  sei.m_preLutCodedValue[c][i]  = uiVal;
     1116          READ_CODE( (( sei.m_colourRemapBitDepth + 7 ) >> 3 ) << 3, uiVal, "pre_lut_target_value[c][i]" ); sei.m_preLutTargetValue[c][i] = uiVal;
     1117        }
     1118      else // pre_lut_num_val_minus1[c] == 0
     1119      {
     1120        sei.m_preLutCodedValue[c][0]  = 0;
     1121        sei.m_preLutTargetValue[c][0] = 0;
     1122        sei.m_preLutCodedValue[c][1]  = (1 << sei.m_colourRemapInputBitDepth) - 1 ;
     1123        sei.m_preLutTargetValue[c][1] = (1 << sei.m_colourRemapBitDepth) - 1 ;
     1124      }
     1125    }
     1126
     1127    READ_FLAG( uiVal,      "colour_remap_matrix_present_flag" ); sei.m_colourRemapMatrixPresentFlag = uiVal;
     1128    if( sei.m_colourRemapMatrixPresentFlag )
     1129    {
     1130      READ_CODE( 4, uiVal, "log2_matrix_denom" ); sei.m_log2MatrixDenom = uiVal;
     1131      for ( Int c=0 ; c<3 ; c++ )
     1132        for ( Int i=0 ; i<3 ; i++ )
     1133        {
     1134          READ_SVLC( iVal, "colour_remap_coeffs[c][i]" ); sei.m_colourRemapCoeffs[c][i] = iVal;
     1135        }
     1136    }
     1137    else // setting default matrix (I3)
     1138    {
     1139      sei.m_log2MatrixDenom = 0;
     1140      for ( Int c=0 ; c<3 ; c++ )
     1141        for ( Int i=0 ; i<3 ; i++ )
     1142          sei.m_colourRemapCoeffs[c][i] = (c==i) ? 1 : 0;
     1143    }
     1144    for( Int c=0 ; c<3 ; c++ )
     1145    {
     1146      READ_CODE( 8, uiVal, "post_lut_num_val_minus1[c]" ); sei.m_postLutNumValMinus1[c] = (uiVal==0) ? 1 : uiVal;
     1147      sei.m_postLutCodedValue[c].resize(sei.m_postLutNumValMinus1[c]+1);
     1148      sei.m_postLutTargetValue[c].resize(sei.m_postLutNumValMinus1[c]+1);
     1149      if( uiVal > 0 )
     1150        for ( Int i=0 ; i<=sei.m_postLutNumValMinus1[c] ; i++ )
     1151        {
     1152          READ_CODE( (( sei.m_colourRemapBitDepth + 7 ) >> 3 ) << 3, uiVal, "post_lut_coded_value[c][i]" );  sei.m_postLutCodedValue[c][i] = uiVal;
     1153          READ_CODE( (( sei.m_colourRemapBitDepth + 7 ) >> 3 ) << 3, uiVal, "post_lut_target_value[c][i]" ); sei.m_postLutTargetValue[c][i] = uiVal;
     1154        }
     1155      else
     1156      {
     1157        sei.m_postLutCodedValue[c][0]  = 0;
     1158        sei.m_postLutTargetValue[c][0] = 0;
     1159        sei.m_postLutTargetValue[c][1] = (1 << sei.m_colourRemapBitDepth) - 1;
     1160        sei.m_postLutCodedValue[c][1]  = (1 << sei.m_colourRemapBitDepth) - 1;
     1161      }
    10031162    }
    10041163  }
     
    11941353#endif
    11951354#if SUB_BITSTREAM_PROPERTY_SEI
     1355#if OLS_IDX_CHK
     1356Void SEIReader::xParseSEISubBitstreamProperty(SEISubBitstreamProperty &sei, TComVPS *vps)
     1357#else
    11961358Void SEIReader::xParseSEISubBitstreamProperty(SEISubBitstreamProperty &sei)
     1359#endif
    11971360{
    11981361  UInt uiCode;
     
    12031366  {
    12041367    READ_CODE(  2, uiCode, "sub_bitstream_mode[i]"           ); sei.m_subBitstreamMode[i] = uiCode;
    1205     READ_UVLC(     uiCode, "output_layer_set_idx_to_vps[i]"  ); sei.m_outputLayerSetIdxToVps[i] = uiCode;
     1368    READ_UVLC(     uiCode, "output_layer_set_idx_to_vps[i]"  );
     1369#if OLS_IDX_CHK
     1370      // The value of output_layer_set_idx_to_vps[ i ]  shall be in the range of 0 to NumOutputLayerSets − 1, inclusive.
     1371      assert(uiCode > 0 && uiCode <= vps->getNumOutputLayerSets()-1);
     1372#endif
     1373      sei.m_outputLayerSetIdxToVps[i] = uiCode;
    12061374    READ_CODE(  3, uiCode, "highest_sub_layer_id[i]"         ); sei.m_highestSublayerId[i] = uiCode;
    12071375    READ_CODE( 16, uiCode, "avg_bit_rate[i]"                 ); sei.m_avgBitRate[i] = uiCode;
     
    12321400
    12331401  // read nested SEI messages
     1402#if NESTING_SEI_EXTENSIBILITY
     1403  Int numSeiMessages = 0;
     1404  READ_UVLC( uiCode, "num_seis_in_bsp_minus1" );  assert( uiCode <= MAX_SEIS_IN_BSP_NESTING );
     1405  numSeiMessages = uiCode;
     1406  for(Int i = 0; i < numSeiMessages; i++)
     1407  {
     1408    xReadSEImessage(sei.m_nestedSEIs, nalUnitType, vps, sps, &nestingSei, &sei);
     1409  }
     1410#else
    12341411  do {
    12351412#if LAYERS_NOT_PRESENT_SEI
     
    12391416#endif
    12401417  } while (m_pcBitstream->getNumBitsLeft() > 8);
     1418#endif
    12411419}
    12421420
     
    12451423  assert(vps->getVpsVuiPresentFlag());
    12461424
     1425#if VPS_VUI_BSP_HRD_PARAMS
     1426  UInt uiCode;
     1427  Int psIdx         = bspNestingSei.m_seiPartitioningSchemeIdx;
     1428  Int seiOlsIdx     = bspNestingSei.m_seiOlsIdx;
     1429  Int maxTemporalId = nestingSei.m_nestingMaxTemporalIdPlus1[0];
     1430  Int maxValues     = vps->getNumBspSchedulesMinus1(seiOlsIdx, psIdx, maxTemporalId) + 1;
     1431  std::vector<Int> hrdIdx(0, maxValues);
     1432  std::vector<TComHRD *> hrdVec;
     1433  std::vector<Int> syntaxElemLen;
     1434  for(Int i = 0; i < maxValues; i++)
     1435  {
     1436    hrdIdx[i] = vps->getBspHrdIdx( seiOlsIdx, psIdx, maxTemporalId, i, bspNestingSei.m_bspIdx);
     1437    hrdVec[i] = vps->getBspHrd(hrdIdx[i]);
     1438   
     1439    syntaxElemLen[i] = hrdVec[i]->getInitialCpbRemovalDelayLengthMinus1() + 1;
     1440    if ( !(hrdVec[i]->getNalHrdParametersPresentFlag() || hrdVec[i]->getVclHrdParametersPresentFlag()) )
     1441    {
     1442      assert( syntaxElemLen[i] == 24 ); // Default value of init_cpb_removal_delay_length_minus1 is 23
     1443    }
     1444    if( i > 0 )
     1445    {
     1446      assert( hrdVec[i]->getNalHrdParametersPresentFlag() == hrdVec[i-1]->getNalHrdParametersPresentFlag() );
     1447      assert( hrdVec[i]->getVclHrdParametersPresentFlag() == hrdVec[i-1]->getVclHrdParametersPresentFlag() );
     1448    }
     1449  }
     1450  if (hrdVec[0]->getNalHrdParametersPresentFlag())
     1451  {
     1452    for(UInt i = 0; i < maxValues; i++)
     1453    {
     1454      READ_CODE( syntaxElemLen[i], uiCode, "nal_initial_arrival_delay[i]" ); sei.m_nalInitialArrivalDelay[i] = uiCode;
     1455    }
     1456  }
     1457  if( hrdVec[0]->getVclHrdParametersPresentFlag() )
     1458  {
     1459    for(UInt i = 0; i < maxValues; i++)
     1460    {
     1461      READ_CODE( syntaxElemLen[i], uiCode, "vcl_initial_arrival_delay[i]" ); sei.m_vclInitialArrivalDelay[i] = uiCode;
     1462    }
     1463  }
     1464#else
    12471465  UInt schedCombCnt = vps->getNumBspSchedCombinations(nestingSei.m_nestingOpIdx[0]);
    12481466  UInt len;
     
    12771495    }
    12781496  }
     1497#if BSP_INIT_ARRIVAL_SEI
     1498  if( hrd->getVclHrdParametersPresentFlag() )
     1499#else
    12791500  else
     1501#endif
    12801502  {
    12811503    for(UInt i = 0; i < schedCombCnt; i++)
     
    12841506    }
    12851507  }
    1286 }
    1287 
     1508#endif
     1509}
     1510
     1511#if !REMOVE_BSP_HRD_SEI
    12881512Void SEIReader::xParseSEIBspHrd(SEIBspHrd &sei, TComSPS *sps, const SEIScalableNesting &nestingSei)
    12891513{
     
    13711595  }
    13721596}
     1597#endif
    13731598
    13741599Void SEIReader::xParseHrdParameters(TComHRD *hrd, Bool commonInfPresentFlag, UInt maxNumSubLayersMinus1)
  • trunk/source/Lib/TLibDecoder/SEIread.h

    r815 r906  
    8080  Void xParseSEIuserDataUnregistered  (SEIuserDataUnregistered &sei, UInt payloadSize);
    8181  Void xParseSEIActiveParameterSets   (SEIActiveParameterSets  &sei, UInt payloadSize);
     82  Void xParseSEIDecodedPictureHash    (SEIDecodedPictureHash& sei, UInt payloadSize);
     83#if VPS_VUI_BSP_HRD_PARAMS
     84  Void xParseSEIDecodingUnitInfo      (SEIDecodingUnitInfo& sei, UInt payloadSize, TComSPS *sps, const SEIScalableNesting* nestingSei, const SEIBspNesting* bspNestingSei, TComVPS *vps);
     85  Void xParseSEIBufferingPeriod       (SEIBufferingPeriod& sei, UInt payloadSize, TComSPS *sps, const SEIScalableNesting* nestingSei, const SEIBspNesting* bspNestingSei, TComVPS *vps);
     86  Void xParseSEIPictureTiming         (SEIPictureTiming& sei, UInt payloadSize, TComSPS *sps, const SEIScalableNesting* nestingSei, const SEIBspNesting* bspNestingSei, TComVPS *vps);
     87#else
    8288  Void xParseSEIDecodingUnitInfo      (SEIDecodingUnitInfo& sei, UInt payloadSize, TComSPS *sps);
    83   Void xParseSEIDecodedPictureHash    (SEIDecodedPictureHash& sei, UInt payloadSize);
    8489  Void xParseSEIBufferingPeriod       (SEIBufferingPeriod& sei, UInt payloadSize, TComSPS *sps);
    8590  Void xParseSEIPictureTiming         (SEIPictureTiming& sei, UInt payloadSize, TComSPS *sps);
     91#endif
    8692  Void xParseSEIRecoveryPoint         (SEIRecoveryPoint& sei, UInt payloadSize);
    8793  Void xParseSEIFramePacking          (SEIFramePacking& sei, UInt payloadSize);
     
    9399  Void xParseSEIKneeFunctionInfo      (SEIKneeFunctionInfo& sei, UInt payloadSize);
    94100#endif
    95 #if Q0074_SEI_COLOR_MAPPING
    96   Void xParseSEIColorMappingInfo      (SEIColorMappingInfo& sei, UInt payloadSize);
     101#if Q0074_COLOUR_REMAPPING_SEI
     102  Void xParseSEIColourRemappingInfo   (SEIColourRemappingInfo& sei, UInt payloadSize);
    97103#endif
    98104  Void xParseSEISOPDescription        (SEISOPDescription &sei, UInt payloadSize);
     
    101107#endif
    102108#if SUB_BITSTREAM_PROPERTY_SEI
     109#if OLS_IDX_CHK
     110Void   xParseSEISubBitstreamProperty   (SEISubBitstreamProperty &sei, TComVPS *vps);
     111#else
    103112Void   xParseSEISubBitstreamProperty   (SEISubBitstreamProperty &sei);
     113#endif
    104114#endif
    105115#if LAYERS_NOT_PRESENT_SEI
     
    116126#endif
    117127  Void xParseSEIBspInitialArrivalTime(SEIBspInitialArrivalTime &sei, TComVPS *vps, TComSPS *sps, const SEIScalableNesting &nestingSei, const SEIBspNesting &bspNestingSei);
     128#if !REMOVE_BSP_HRD_SEI
    118129  Void xParseSEIBspHrd(SEIBspHrd &sei, TComSPS *sps, const SEIScalableNesting &nestingSei);
     130#endif
    119131  Void xParseHrdParameters(TComHRD *hrd, Bool commonInfPresentFlag, UInt maxNumSubLayersMinus1);
    120132#endif
  • trunk/source/Lib/TLibDecoder/TDecCAVLC.cpp

    r815 r906  
    255255  if( pcPPS->getTilesEnabledFlag() )
    256256  {
    257     READ_UVLC ( uiCode, "num_tile_columns_minus1" );                pcPPS->setNumColumnsMinus1( uiCode );
    258     READ_UVLC ( uiCode, "num_tile_rows_minus1" );                   pcPPS->setNumRowsMinus1( uiCode );
    259     READ_FLAG ( uiCode, "uniform_spacing_flag" );                   pcPPS->setUniformSpacingFlag( uiCode );
    260 
    261     if( !pcPPS->getUniformSpacingFlag())
    262     {
    263       UInt* columnWidth = (UInt*)malloc(pcPPS->getNumColumnsMinus1()*sizeof(UInt));
    264       for(UInt i=0; i<pcPPS->getNumColumnsMinus1(); i++)
     257    READ_UVLC ( uiCode, "num_tile_columns_minus1" );                pcPPS->setNumTileColumnsMinus1( uiCode ); 
     258    READ_UVLC ( uiCode, "num_tile_rows_minus1" );                   pcPPS->setNumTileRowsMinus1( uiCode ); 
     259    READ_FLAG ( uiCode, "uniform_spacing_flag" );                   pcPPS->setTileUniformSpacingFlag( uiCode == 1 );
     260
     261    if( !pcPPS->getTileUniformSpacingFlag())
     262    {
     263      std::vector<Int> columnWidth(pcPPS->getNumTileColumnsMinus1());
     264      for(UInt i=0; i<pcPPS->getNumTileColumnsMinus1(); i++)
    265265      {
    266266        READ_UVLC( uiCode, "column_width_minus1" );
    267267        columnWidth[i] = uiCode+1;
    268268      }
    269       pcPPS->setColumnWidth(columnWidth);
    270       free(columnWidth);
    271 
    272       UInt* rowHeight = (UInt*)malloc(pcPPS->getNumRowsMinus1()*sizeof(UInt));
    273       for(UInt i=0; i<pcPPS->getNumRowsMinus1(); i++)
     269      pcPPS->setTileColumnWidth(columnWidth);
     270
     271      std::vector<Int> rowHeight (pcPPS->getTileNumRowsMinus1());
     272      for(UInt i=0; i<pcPPS->getTileNumRowsMinus1(); i++)
    274273      {
    275274        READ_UVLC( uiCode, "row_height_minus1" );
    276275        rowHeight[i] = uiCode + 1;
    277276      }
    278       pcPPS->setRowHeight(rowHeight);
    279       free(rowHeight);
    280     }
    281 
    282     if(pcPPS->getNumColumnsMinus1() !=0 || pcPPS->getNumRowsMinus1() !=0)
     277      pcPPS->setTileRowHeight(rowHeight);
     278    }
     279
     280    if(pcPPS->getNumTileColumnsMinus1() !=0 || pcPPS->getTileNumRowsMinus1() !=0)
    283281    {
    284282      READ_FLAG ( uiCode, "loop_filter_across_tiles_enabled_flag" );   pcPPS->setLoopFilterAcrossTilesEnabledFlag( uiCode ? true : false );
     
    297295    }
    298296  }
    299 
     297#if !R0042_PROFILE_INDICATION
    300298#if SCALINGLIST_INFERRING
    301299  if( pcPPS->getLayerId() > 0 )
     
    317315  {
    318316#endif
    319 
    320   READ_FLAG( uiCode, "pps_scaling_list_data_present_flag" );           pcPPS->setScalingListPresentFlag( uiCode ? true : false );
    321 
    322   if(pcPPS->getScalingListPresentFlag ())
    323   {
    324     parseScalingList( pcPPS->getScalingList() );
    325   }
    326 
     317#endif
     318
     319    READ_FLAG( uiCode, "pps_scaling_list_data_present_flag" );           pcPPS->setScalingListPresentFlag( uiCode ? true : false );
     320
     321    if(pcPPS->getScalingListPresentFlag ())
     322    {
     323      parseScalingList( pcPPS->getScalingList() );
     324    }
     325#if !R0042_PROFILE_INDICATION
    327326#if SCALINGLIST_INFERRING
    328327  }
     328#endif
    329329#endif
    330330
     
    338338  pcPPS->setSliceHeaderExtensionPresentFlag(uiCode);
    339339
     340#if !R0042_PROFILE_INDICATION
    340341  READ_FLAG( uiCode, "pps_extension_flag");
     342#else
     343  READ_FLAG( uiCode, "pps_extension_present_flag");
     344#endif
     345
     346#if !R0042_PROFILE_INDICATION
    341347#if POC_RESET_INFO_INFERENCE
    342348  pcPPS->setExtensionFlag( uiCode ? true : false );
     
    361367      READ_FLAG( uiCode, "poc_reset_info_present_flag" );
    362368      pcPPS->setPocResetInfoPresentFlag(uiCode ? true : false);
     369#if REF_REGION_OFFSET
     370      READ_UVLC( uiCode,      "num_scaled_ref_layer_offsets" ); pcPPS->setNumScaledRefLayerOffsets(uiCode);
     371      for(Int i = 0; i < pcPPS->getNumScaledRefLayerOffsets(); i++)
     372      {
     373        READ_CODE( 6, uiCode,  "scaled_ref_layer_id" );  pcPPS->setScaledRefLayerId( i, uiCode );
     374        READ_FLAG( uiCode, "scaled_ref_layer_offset_present_flag" );   pcPPS->setScaledRefLayerOffsetPresentFlag( i, uiCode );
     375        if (uiCode)
     376        {
     377          Window& scaledWindow = pcPPS->getScaledRefLayerWindow(i);
     378          READ_SVLC( iCode, "scaled_ref_layer_left_offset" );    scaledWindow.setWindowLeftOffset  (iCode << 1);
     379          READ_SVLC( iCode, "scaled_ref_layer_top_offset" );     scaledWindow.setWindowTopOffset   (iCode << 1);
     380          READ_SVLC( iCode, "scaled_ref_layer_right_offset" );   scaledWindow.setWindowRightOffset (iCode << 1);
     381          READ_SVLC( iCode, "scaled_ref_layer_bottom_offset" );  scaledWindow.setWindowBottomOffset(iCode << 1);
     382#if P0312_VERT_PHASE_ADJ
     383          READ_FLAG( uiCode, "vert_phase_position_enable_flag" ); scaledWindow.setVertPhasePositionEnableFlag(uiCode);  pcPPS->setVertPhasePositionEnableFlag( pcPPS->getScaledRefLayerId(i), uiCode);
     384#endif
     385        }
     386        READ_FLAG( uiCode, "ref_region_offset_present_flag" );   pcPPS->setRefRegionOffsetPresentFlag( i, uiCode );
     387        if (uiCode)
     388        {
     389          Window& refWindow = pcPPS->getRefLayerWindow(i);
     390          READ_SVLC( iCode, "ref_region_left_offset" );    refWindow.setWindowLeftOffset  (iCode << 1);
     391          READ_SVLC( iCode, "ref_region_top_offset" );     refWindow.setWindowTopOffset   (iCode << 1);
     392          READ_SVLC( iCode, "ref_region_right_offset" );   refWindow.setWindowRightOffset (iCode << 1);
     393          READ_SVLC( iCode, "ref_region_bottom_offset" );  refWindow.setWindowBottomOffset(iCode << 1);
     394        }
     395#if R0209_GENERIC_PHASE
     396        READ_FLAG( uiCode, "resample_phase_set_present_flag" );   pcPPS->setResamplePhaseSetPresentFlag( i, uiCode );
     397        if (uiCode)
     398        {
     399          READ_UVLC( uiCode, "phase_hor_luma" );    pcPPS->setPhaseHorLuma ( i, uiCode );
     400          READ_UVLC( uiCode, "phase_ver_luma" );    pcPPS->setPhaseVerLuma ( i, uiCode );
     401          READ_UVLC( uiCode, "phase_hor_chroma_plus8" );  pcPPS->setPhaseHorChroma (i, uiCode - 8);
     402          READ_UVLC( uiCode, "phase_ver_chroma_plus8" );  pcPPS->setPhaseVerChroma (i, uiCode - 8);
     403        }
     404#endif
     405      }
     406#else
     407#if MOVE_SCALED_OFFSET_TO_PPS
     408      READ_UVLC( uiCode,      "num_scaled_ref_layer_offsets" ); pcPPS->setNumScaledRefLayerOffsets(uiCode);
     409      for(Int i = 0; i < pcPPS->getNumScaledRefLayerOffsets(); i++)
     410      {
     411        Window& scaledWindow = pcPPS->getScaledRefLayerWindow(i);
     412#if O0098_SCALED_REF_LAYER_ID
     413        READ_CODE( 6,  uiCode,  "scaled_ref_layer_id" );       pcPPS->setScaledRefLayerId( i, uiCode );
     414#endif
     415        READ_SVLC( iCode, "scaled_ref_layer_left_offset" );    scaledWindow.setWindowLeftOffset  (iCode << 1);
     416        READ_SVLC( iCode, "scaled_ref_layer_top_offset" );     scaledWindow.setWindowTopOffset   (iCode << 1);
     417        READ_SVLC( iCode, "scaled_ref_layer_right_offset" );   scaledWindow.setWindowRightOffset (iCode << 1);
     418        READ_SVLC( iCode, "scaled_ref_layer_bottom_offset" );  scaledWindow.setWindowBottomOffset(iCode << 1);
     419#if P0312_VERT_PHASE_ADJ
     420        READ_FLAG( uiCode, "vert_phase_position_enable_flag" ); scaledWindow.setVertPhasePositionEnableFlag(uiCode);  pcPPS->setVertPhasePositionEnableFlag( pcPPS->getScaledRefLayerId(i), uiCode);
     421#endif
     422      }
     423#endif
     424#endif
    363425#if Q0048_CGS_3D_ASYMLUT
    364426      READ_FLAG( uiCode , "colour_mapping_enabled_flag" );
     
    383445#endif
    384446
    385     while ( xMoreRbspData() )
    386     {
    387       READ_FLAG( uiCode, "pps_extension_data_flag");
    388     }
     447      while ( xMoreRbspData() )
     448      {
     449        READ_FLAG( uiCode, "pps_extension_data_flag");
     450      }
    389451#if P0166_MODIFIED_PPS_EXTENSION
    390452    }
     
    397459  }
    398460#endif
     461#else
     462  pcPPS->setExtensionFlag( uiCode ? true : false );
     463  if( pcPPS->getExtensionFlag() )
     464  {
     465    READ_FLAG( uiCode, "pps_range_extension_flag" );
     466    assert(uiCode == 0);
     467    READ_FLAG( uiCode, "pps_multilayer_extension_flag" );
     468    assert(uiCode == 1);
     469    READ_CODE(6, uiCode, "pps_extension_6bits");
     470    assert(uiCode == 0);
     471
     472    READ_FLAG( uiCode, "poc_reset_info_present_flag" );
     473    pcPPS->setPocResetInfoPresentFlag(uiCode ? true : false);
     474
     475#if SCALINGLIST_INFERRING
     476    READ_FLAG( uiCode, "pps_infer_scaling_list_flag" );
     477    pcPPS->setInferScalingListFlag( uiCode );
     478
     479    if( pcPPS->getInferScalingListFlag() )
     480    {
     481      READ_UVLC( uiCode, "pps_scaling_list_ref_layer_id" );
     482      pcPPS->setScalingListRefLayerId( uiCode );
     483      // The value of pps_scaling_list_ref_layer_id shall be in the range of 0 to 62, inclusive
     484      assert( pcPPS->getScalingListRefLayerId() <= 62 );
     485      pcPPS->setScalingListPresentFlag( false );
     486    }
     487#endif
     488
     489#if REF_REGION_OFFSET
     490    READ_UVLC( uiCode,      "num_ref_loc_offsets" ); pcPPS->setNumScaledRefLayerOffsets(uiCode);
     491    for(Int i = 0; i < pcPPS->getNumScaledRefLayerOffsets(); i++)
     492    {
     493      READ_CODE( 6, uiCode,  "ref_loc_offset_layer_id" );  pcPPS->setScaledRefLayerId( i, uiCode );
     494      READ_FLAG( uiCode, "scaled_ref_layer_offset_present_flag" );   pcPPS->setScaledRefLayerOffsetPresentFlag( i, uiCode );
     495      if (uiCode)
     496      {
     497        Window& scaledWindow = pcPPS->getScaledRefLayerWindow(i);
     498        READ_SVLC( iCode, "scaled_ref_layer_left_offset" );    scaledWindow.setWindowLeftOffset  (iCode << 1);
     499        READ_SVLC( iCode, "scaled_ref_layer_top_offset" );     scaledWindow.setWindowTopOffset   (iCode << 1);
     500        READ_SVLC( iCode, "scaled_ref_layer_right_offset" );   scaledWindow.setWindowRightOffset (iCode << 1);
     501        READ_SVLC( iCode, "scaled_ref_layer_bottom_offset" );  scaledWindow.setWindowBottomOffset(iCode << 1);
     502#if P0312_VERT_PHASE_ADJ
     503        READ_FLAG( uiCode, "vert_phase_position_enable_flag" ); scaledWindow.setVertPhasePositionEnableFlag(uiCode);  pcPPS->setVertPhasePositionEnableFlag( pcPPS->getScaledRefLayerId(i), uiCode);
     504#endif
     505      }
     506      READ_FLAG( uiCode, "ref_region_offset_present_flag" );   pcPPS->setRefRegionOffsetPresentFlag( i, uiCode );
     507      if (uiCode)
     508      {
     509        Window& refWindow = pcPPS->getRefLayerWindow(i);
     510        READ_SVLC( iCode, "ref_region_left_offset" );    refWindow.setWindowLeftOffset  (iCode << 1);
     511        READ_SVLC( iCode, "ref_region_top_offset" );     refWindow.setWindowTopOffset   (iCode << 1);
     512        READ_SVLC( iCode, "ref_region_right_offset" );   refWindow.setWindowRightOffset (iCode << 1);
     513        READ_SVLC( iCode, "ref_region_bottom_offset" );  refWindow.setWindowBottomOffset(iCode << 1);
     514      }
     515#if R0209_GENERIC_PHASE
     516      READ_FLAG( uiCode, "resample_phase_set_present_flag" );   pcPPS->setResamplePhaseSetPresentFlag( i, uiCode );
     517      if (uiCode)
     518      {
     519        READ_UVLC( uiCode, "phase_hor_luma" );    pcPPS->setPhaseHorLuma ( i, uiCode );
     520        READ_UVLC( uiCode, "phase_ver_luma" );    pcPPS->setPhaseVerLuma ( i, uiCode );
     521        READ_UVLC( uiCode, "phase_hor_chroma_plus8" );  pcPPS->setPhaseHorChroma (i, uiCode - 8);
     522        READ_UVLC( uiCode, "phase_ver_chroma_plus8" );  pcPPS->setPhaseVerChroma (i, uiCode - 8);
     523      }
     524#endif
     525    }
     526#else
     527#if MOVE_SCALED_OFFSET_TO_PPS
     528      READ_UVLC( uiCode,      "num_scaled_ref_layer_offsets" ); pcPPS->setNumScaledRefLayerOffsets(uiCode);
     529      for(Int i = 0; i < pcPPS->getNumScaledRefLayerOffsets(); i++)
     530      {
     531        Window& scaledWindow = pcPPS->getScaledRefLayerWindow(i);
     532#if O0098_SCALED_REF_LAYER_ID
     533        READ_CODE( 6,  uiCode,  "scaled_ref_layer_id" );       pcPPS->setScaledRefLayerId( i, uiCode );
     534#endif
     535        READ_SVLC( iCode, "scaled_ref_layer_left_offset" );    scaledWindow.setWindowLeftOffset  (iCode << 1);
     536        READ_SVLC( iCode, "scaled_ref_layer_top_offset" );     scaledWindow.setWindowTopOffset   (iCode << 1);
     537        READ_SVLC( iCode, "scaled_ref_layer_right_offset" );   scaledWindow.setWindowRightOffset (iCode << 1);
     538        READ_SVLC( iCode, "scaled_ref_layer_bottom_offset" );  scaledWindow.setWindowBottomOffset(iCode << 1);
     539#if P0312_VERT_PHASE_ADJ
     540        READ_FLAG( uiCode, "vert_phase_position_enable_flag" ); scaledWindow.setVertPhasePositionEnableFlag(uiCode);  pcPPS->setVertPhasePositionEnableFlag( pcPPS->getScaledRefLayerId(i), uiCode);
     541#endif
     542      }
     543#endif
     544#endif
     545#if Q0048_CGS_3D_ASYMLUT
     546      READ_FLAG( uiCode , "colour_mapping_enabled_flag" );
     547      pcPPS->setCGSFlag( uiCode );
     548      if( pcPPS->getCGSFlag() )
     549      {
     550        xParse3DAsymLUT( pc3DAsymLUT );
     551        pcPPS->setCGSOutputBitDepthY( pc3DAsymLUT->getOutputBitDepthY() );
     552        pcPPS->setCGSOutputBitDepthC( pc3DAsymLUT->getOutputBitDepthC() );
     553      }
     554#endif
     555  }
     556#endif
     557
    399558}
    400559
     
    476635      READ_UVLC(   uiCode, "vui_num_ticks_poc_diff_one_minus1");    timingInfo->setNumTicksPocDiffOneMinus1   (uiCode);
    477636    }
    478   READ_FLAG(     uiCode, "hrd_parameters_present_flag");              pcVUI->setHrdParametersPresentFlag(uiCode);
    479   if( pcVUI->getHrdParametersPresentFlag() )
    480   {
    481     parseHrdParameters( pcVUI->getHrdParameters(), 1, pcSPS->getMaxTLayers() - 1 );
    482   }
     637    READ_FLAG(     uiCode, "hrd_parameters_present_flag");              pcVUI->setHrdParametersPresentFlag(uiCode);
     638    if( pcVUI->getHrdParametersPresentFlag() )
     639    {
     640      parseHrdParameters( pcVUI->getHrdParameters(), 1, pcSPS->getMaxTLayers() - 1 );
     641    }
    483642  }
    484643  READ_FLAG(     uiCode, "bitstream_restriction_flag");               pcVUI->setBitstreamRestrictionFlag(uiCode);
     
    524683      READ_CODE( 5, uiCode, "dpb_output_delay_length_minus1" );       hrd->setDpbOutputDelayLengthMinus1( uiCode );
    525684    }
     685#if VPS_VUI_BSP_HRD_PARAMS
     686    else
     687    {
     688      hrd->setInitialCpbRemovalDelayLengthMinus1( 23 );
     689      // Add inferred values for other syntax elements here.
     690    }
     691#endif
    526692  }
    527693  Int i, j, nalOrVcl;
     
    554720    {
    555721      if( ( ( nalOrVcl == 0 ) && ( hrd->getNalHrdParametersPresentFlag() ) ) ||
    556           ( ( nalOrVcl == 1 ) && ( hrd->getVclHrdParametersPresentFlag() ) ) )
     722        ( ( nalOrVcl == 1 ) && ( hrd->getVclHrdParametersPresentFlag() ) ) )
    557723      {
    558724        for( j = 0; j <= ( hrd->getCpbCntMinus1( i ) ); j ++ )
     
    582748#endif
    583749
     750#if R0042_PROFILE_INDICATION
     751  UInt uiTmp = 0;
     752  Bool bMultiLayerExtSpsFlag;
     753#endif
    584754  UInt  uiCode;
    585755  READ_CODE( 4,  uiCode, "sps_video_parameter_set_id");          pcSPS->setVPSId        ( uiCode );
     
    590760    READ_CODE( 3,  uiCode, "sps_max_sub_layers_minus1" );          pcSPS->setMaxTLayers   ( uiCode+1 );
    591761    assert(uiCode <= 6);
    592 
     762#if SVC_EXTENSION
     763  }
     764#if R0042_PROFILE_INDICATION
     765  else
     766  {
     767    READ_CODE( 3,  uiCode, "sps_ext_or_max_sub_layers_minus1" );     uiTmp = uiCode;
     768  }
     769#endif
     770#if !SPS_DPB_PARAMS
     771  if(pcSPS->getLayerId() != 0)
     772  {
     773    pcSPS->setMaxTLayers           ( parameterSetManager->getPrefetchedVPS(pcSPS->getVPSId())->getMaxTLayers()          );
     774  }
     775#endif
     776#endif
     777
     778#if SVC_EXTENSION
     779#if R0042_PROFILE_INDICATION
     780  bMultiLayerExtSpsFlag = ( pcSPS->getLayerId() != 0 && uiTmp == 7 );
     781#endif
     782#endif
     783
     784#if SVC_EXTENSION
     785#if !R0042_PROFILE_INDICATION
     786  if(pcSPS->getLayerId() == 0)
     787#else
     788  if(!bMultiLayerExtSpsFlag)
     789#endif
     790  {
     791#endif
    593792    READ_FLAG( uiCode, "sps_temporal_id_nesting_flag" );               pcSPS->setTemporalIdNestingFlag ( uiCode > 0 ? true : false );
    594793#if SVC_EXTENSION
     
    597796  else
    598797  {
    599     pcSPS->setMaxTLayers           ( parameterSetManager->getPrefetchedVPS(pcSPS->getVPSId())->getMaxTLayers()          );
    600798    pcSPS->setTemporalIdNestingFlag( parameterSetManager->getPrefetchedVPS(pcSPS->getVPSId())->getTemporalNestingFlag() );
    601799  }
     
    618816
    619817#ifdef SPS_PTL_FIX
     818#if !R0042_PROFILE_INDICATION
    620819  if ( pcSPS->getLayerId() == 0)
     820#else
     821  if(!bMultiLayerExtSpsFlag)
     822#endif
    621823  {
    622824    parsePTL(pcSPS->getPTL(), 1, pcSPS->getMaxTLayers() - 1);
     
    630832
    631833#if REPN_FORMAT_IN_VPS
     834#if !R0042_PROFILE_INDICATION
    632835  if( pcSPS->getLayerId() > 0 )
     836#else
     837  if( bMultiLayerExtSpsFlag)
     838#endif
    633839  {
    634840    READ_FLAG( uiCode, "update_rep_format_flag" );
    635841    pcSPS->setUpdateRepFormatFlag( uiCode ? true : false );
     842#if R0042_PROFILE_INDICATION   
     843    if( bMultiLayerExtSpsFlag && uiCode)
     844    {
     845      READ_CODE(8, uiCode, "sps_rep_format_idx");
     846      pcSPS->setUpdateRepFormatIndex(uiCode);
     847    }
     848#endif
    636849  }
    637850  else
     
    643856#endif
    644857  }
     858
     859#if R0042_PROFILE_INDICATION 
     860  if( !bMultiLayerExtSpsFlag )
     861  {
     862#else
    645863#if O0096_REP_FORMAT_INDEX
    646864  if( pcSPS->getLayerId() == 0 )
    647865#else
    648866  if( pcSPS->getLayerId() == 0 || pcSPS->getUpdateRepFormatFlag() )
     867#endif
    649868#endif
    650869  {
     
    668887  }
    669888#if O0096_REP_FORMAT_INDEX
     889#if !R0042_PROFILE_INDICATION
    670890  else if ( pcSPS->getUpdateRepFormatFlag() )
    671891  {
     
    675895#endif
    676896#endif
    677   READ_FLAG(     uiCode, "conformance_window_flag");
    678   if (uiCode != 0)
    679   {
    680     Window &conf = pcSPS->getConformanceWindow();
     897#endif
     898
     899#if R0156_CONF_WINDOW_IN_REP_FORMAT
    681900#if REPN_FORMAT_IN_VPS
    682     READ_UVLC(   uiCode, "conf_win_left_offset" );               conf.setWindowLeftOffset  ( uiCode );
    683     READ_UVLC(   uiCode, "conf_win_right_offset" );              conf.setWindowRightOffset ( uiCode );
    684     READ_UVLC(   uiCode, "conf_win_top_offset" );                conf.setWindowTopOffset   ( uiCode );
    685     READ_UVLC(   uiCode, "conf_win_bottom_offset" );             conf.setWindowBottomOffset( uiCode );
    686 #else
    687     READ_UVLC(   uiCode, "conf_win_left_offset" );               conf.setWindowLeftOffset  ( uiCode * TComSPS::getWinUnitX( pcSPS->getChromaFormatIdc() ) );
    688     READ_UVLC(   uiCode, "conf_win_right_offset" );              conf.setWindowRightOffset ( uiCode * TComSPS::getWinUnitX( pcSPS->getChromaFormatIdc() ) );
    689     READ_UVLC(   uiCode, "conf_win_top_offset" );                conf.setWindowTopOffset   ( uiCode * TComSPS::getWinUnitY( pcSPS->getChromaFormatIdc() ) );
    690     READ_UVLC(   uiCode, "conf_win_bottom_offset" );             conf.setWindowBottomOffset( uiCode * TComSPS::getWinUnitY( pcSPS->getChromaFormatIdc() ) );
    691 #endif
    692   }
    693 #if REPN_FORMAT_IN_VPS
     901#if !R0042_PROFILE_INDICATION 
    694902#if O0096_REP_FORMAT_INDEX
    695903  if( pcSPS->getLayerId() == 0 )
    696904#else
    697905  if(  pcSPS->getLayerId() == 0 || pcSPS->getUpdateRepFormatFlag() )
     906#endif
     907#endif
     908  {
     909#endif
     910#endif
     911    READ_FLAG(     uiCode, "conformance_window_flag");
     912    if (uiCode != 0)
     913    {
     914      Window &conf = pcSPS->getConformanceWindow();
     915#if REPN_FORMAT_IN_VPS
     916      READ_UVLC(   uiCode, "conf_win_left_offset" );               conf.setWindowLeftOffset  ( uiCode );
     917      READ_UVLC(   uiCode, "conf_win_right_offset" );              conf.setWindowRightOffset ( uiCode );
     918      READ_UVLC(   uiCode, "conf_win_top_offset" );                conf.setWindowTopOffset   ( uiCode );
     919      READ_UVLC(   uiCode, "conf_win_bottom_offset" );             conf.setWindowBottomOffset( uiCode );
     920#else
     921      READ_UVLC(   uiCode, "conf_win_left_offset" );               conf.setWindowLeftOffset  ( uiCode * TComSPS::getWinUnitX( pcSPS->getChromaFormatIdc() ) );
     922      READ_UVLC(   uiCode, "conf_win_right_offset" );              conf.setWindowRightOffset ( uiCode * TComSPS::getWinUnitX( pcSPS->getChromaFormatIdc() ) );
     923      READ_UVLC(   uiCode, "conf_win_top_offset" );                conf.setWindowTopOffset   ( uiCode * TComSPS::getWinUnitY( pcSPS->getChromaFormatIdc() ) );
     924      READ_UVLC(   uiCode, "conf_win_bottom_offset" );             conf.setWindowBottomOffset( uiCode * TComSPS::getWinUnitY( pcSPS->getChromaFormatIdc() ) );
     925#endif
     926    }
     927#if R0156_CONF_WINDOW_IN_REP_FORMAT
     928#if REPN_FORMAT_IN_VPS
     929  }
     930#endif
     931#endif
     932
     933#if REPN_FORMAT_IN_VPS
     934#if !R0042_PROFILE_INDICATION 
     935#if O0096_REP_FORMAT_INDEX
     936  if( pcSPS->getLayerId() == 0 )
     937#else
     938  if(  pcSPS->getLayerId() == 0 || pcSPS->getUpdateRepFormatFlag() )
     939#endif
    698940#endif
    699941  {
     
    711953  }
    712954#endif
     955#if R0042_PROFILE_INDICATION 
     956  }
     957#endif
     958
    713959  READ_UVLC( uiCode,    "log2_max_pic_order_cnt_lsb_minus4" );   pcSPS->setBitsForPOC( 4 + uiCode );
    714960  assert(uiCode <= 12);
    715961
    716962#if SPS_DPB_PARAMS
     963#if !R0042_PROFILE_INDICATION
    717964  if( pcSPS->getLayerId() == 0 ) 
    718965  {
     966#else
     967  if( !bMultiLayerExtSpsFlag ) 
     968  {
     969#endif
    719970#endif
    720971    UInt subLayerOrderingInfoPresentFlag;
     
    7491000  READ_UVLC( uiCode, "log2_diff_max_min_coding_block_size" );
    7501001  pcSPS->setLog2DiffMaxMinCodingBlockSize(uiCode);
    751  
     1002
    7521003  if (pcSPS->getPTL()->getGeneralPTL()->getLevelIdc() >= Level::LEVEL5)
    7531004  {
    7541005    assert(log2MinCUSize + pcSPS->getLog2DiffMaxMinCodingBlockSize() >= 5);
    7551006  }
    756  
     1007
    7571008  Int maxCUDepthDelta = uiCode;
    7581009  pcSPS->setMaxCUWidth  ( 1<<(log2MinCUSize + maxCUDepthDelta) );
     
    7731024  {
    7741025#if SCALINGLIST_INFERRING
     1026#if !R0042_PROFILE_INDICATION
    7751027    if( pcSPS->getLayerId() > 0 )
     1028#else
     1029    if( bMultiLayerExtSpsFlag )
     1030#endif
    7761031    {
    7771032      READ_FLAG( uiCode, "sps_infer_scaling_list_flag" ); pcSPS->setInferScalingListFlag( uiCode );
     
    7901045    {
    7911046#endif
    792     READ_FLAG( uiCode, "sps_scaling_list_data_present_flag" );                 pcSPS->setScalingListPresentFlag ( uiCode );
    793     if(pcSPS->getScalingListPresentFlag ())
    794     {
    795       parseScalingList( pcSPS->getScalingList() );
    796     }
     1047      READ_FLAG( uiCode, "sps_scaling_list_data_present_flag" );                 pcSPS->setScalingListPresentFlag ( uiCode );
     1048      if(pcSPS->getScalingListPresentFlag ())
     1049      {
     1050        parseScalingList( pcSPS->getScalingList() );
     1051      }
    7971052#if SCALINGLIST_INFERRING
    7981053    }
     
    8541109  if( pcSPS->getExtensionFlag() )
    8551110  {
     1111#if !R0042_PROFILE_INDICATION
    8561112#if O0142_CONDITIONAL_SPS_EXTENSION
    8571113    UInt spsExtensionTypeFlag[8];
     
    8771133      }
    8781134    }
    879   }
     1135    }
     1136#else
     1137    READ_FLAG( uiCode, "sps_range_extension_flag" );
     1138    assert(uiCode == 0);
     1139    READ_FLAG( uiCode, "sps_multilayer_extension_flag" );
     1140    assert(uiCode == 1);
     1141    READ_CODE(6, uiCode, "sps_extension_6bits");
     1142    assert(uiCode == 0);
     1143    parseSPSExtension( pcSPS );
     1144  }
     1145#endif
    8801146#else
    8811147  if (uiCode)
     
    8991165  assert( uiCode == 0 );
    9001166
     1167#if !MOVE_SCALED_OFFSET_TO_PPS
    9011168  if( pcSPS->getLayerId() > 0 )
    9021169  {
     
    9181185    }
    9191186  }
     1187#endif
    9201188}
    9211189#endif
     
    9261194
    9271195  READ_CODE( 4,  uiCode,  "vps_video_parameter_set_id" );         pcVPS->setVPSId( uiCode );
     1196#if VPS_RESERVED_FLAGS
     1197  READ_FLAG( uiCode, "vps_base_layer_internal_flag");             pcVPS->setBaseLayerInternalFlag( uiCode ? true : false );
     1198  READ_FLAG( uiCode, "vps_base_layer_available_flag");            pcVPS->setBaseLayerAvailableFlag( uiCode ? true : false );
     1199#if VPS_AVC_BL_FLAG_REMOVAL
     1200  pcVPS->setNonHEVCBaseLayerFlag( (pcVPS->getBaseLayerAvailableFlag() && !pcVPS->getBaseLayerInternalFlag()) ? true : false);
     1201#endif
     1202#else
    9281203  READ_CODE( 2,  uiCode,  "vps_reserved_three_2bits" );           assert(uiCode == 3);
     1204#endif
    9291205#if SVC_EXTENSION
    9301206#if O0137_MAX_LAYERID
     
    10251301        READ_FLAG( uiCode, "cprms_present_flag[i]" );               pcVPS->setCprmsPresentFlag( uiCode == 1 ? true : false, i );
    10261302      }
     1303      else
     1304      {
     1305        pcVPS->setCprmsPresentFlag( true, i );
     1306      }
     1307
    10271308      parseHrdParameters(pcVPS->getHrdParameters(i), pcVPS->getCprmsPresentFlag( i ), pcVPS->getMaxTLayers() - 1);
    10281309    }
     
    10821363  Int OlsHighestOutputLayerId[MAX_VPS_LAYER_SETS_PLUS1];
    10831364#endif
     1365#if LIST_OF_PTL
     1366  if( vps->getMaxLayers() > 1 && vps->getBaseLayerInternalFlag() )
     1367  {
     1368    vps->setProfilePresentFlag(1, false);
     1369    vps->getPTLForExtnPtr()->empty();
     1370    vps->getPTLForExtnPtr()->resize(2);
     1371    vps->getPTLForExtn(1)->copyProfileInfo( vps->getPTL() );
     1372    parsePTL( vps->getPTLForExtn(1), vps->getProfilePresentFlag(1), vps->getMaxTLayers() - 1 );
     1373  }
     1374#endif
    10841375#if VPS_EXTN_MASK_AND_DIM_INFO
    10851376  UInt numScalabilityTypes = 0, i = 0, j = 0;
    10861377
     1378#if !VPS_AVC_BL_FLAG_REMOVAL
    10871379  READ_FLAG( uiCode, "avc_base_layer_flag" ); vps->setAvcBaseLayerFlag(uiCode ? true : false);
     1380#endif
    10881381
    10891382#if !P0307_REMOVE_VPS_VUI_OFFSET
     
    10941387#endif
    10951388#if VPS_VUI_OFFSET
    1096   READ_CODE( 16, uiCode, "vps_vui_offset" );  vps->setVpsVuiOffset( uiCode );
     1389    READ_CODE( 16, uiCode, "vps_vui_offset" );  vps->setVpsVuiOffset( uiCode );
    10971390#endif
    10981391#if O0109_MOVE_VPS_VUI_FLAG
     
    11451438    if( !vps->getSplittingFlag() )
    11461439    {
    1147     for(j = 0; j < numScalabilityTypes; j++)
    1148     {
    1149       READ_CODE( vps->getDimensionIdLen(j), uiCode, "dimension_id[i][j]" ); vps->setDimensionId(i, j, uiCode);
     1440      for(j = 0; j < numScalabilityTypes; j++)
     1441      {
     1442        READ_CODE( vps->getDimensionIdLen(j), uiCode, "dimension_id[i][j]" ); vps->setDimensionId(i, j, uiCode);
    11501443#if !AUXILIARY_PICTURES
    1151       assert( uiCode <= vps->getMaxLayerId() );
    1152 #endif
    1153     }
    1154   }
     1444        assert( uiCode <= vps->getMaxLayerId() );
     1445#endif
     1446      }
     1447    }
    11551448  }
    11561449#endif
     
    12151508  vps->setTreePartitionLayerIdList();
    12161509#endif
     1510#if MOVE_ADDN_LS_SIGNALLING
     1511#if Q0078_ADD_LAYER_SETS
     1512  if (vps->getNumIndependentLayers() > 1)
     1513  {
     1514    READ_UVLC(uiCode, "num_add_layer_sets"); vps->setNumAddLayerSets(uiCode);
     1515    for (i = 0; i < vps->getNumAddLayerSets(); i++)
     1516    {
     1517      for (j = 1; j < vps->getNumIndependentLayers(); j++)
     1518      {
     1519        int len = 1;
     1520        while ((1 << len) < (vps->getNumLayersInTreePartition(j) + 1))
     1521        {
     1522          len++;
     1523        }
     1524        READ_CODE(len, uiCode, "highest_layer_idx_plus1[i][j]"); vps->setHighestLayerIdxPlus1(i, j, uiCode);
     1525      }
     1526    }
     1527    vps->setNumLayerSets(vps->getNumLayerSets() + vps->getNumAddLayerSets());
     1528    vps->setLayerIdIncludedFlagsForAddLayerSets();
     1529  }
     1530#endif
     1531#endif
    12171532#if VPS_TSLAYERS
    12181533  READ_FLAG( uiCode, "vps_sub_layers_max_minus1_present_flag"); vps->setMaxTSLayersPresentFlag(uiCode ? true : false);
     
    12391554    {
    12401555#if O0225_MAX_TID_FOR_REF_LAYERS
    1241        for( j = i+1; j <= vps->getMaxLayers() - 1; j++)
    1242        {
    1243          if(vps->getDirectDependencyFlag(j, i))
    1244          {
    1245            READ_CODE( 3, uiCode, "max_tid_il_ref_pics_plus1[i][j]" ); vps->setMaxTidIlRefPicsPlus1(i, j, uiCode);
    1246            assert( uiCode <= vps->getMaxTLayers());
    1247          }
    1248        }
     1556      for( j = i+1; j <= vps->getMaxLayers() - 1; j++)
     1557      {
     1558        if(vps->getDirectDependencyFlag(j, i))
     1559        {
     1560          READ_CODE( 3, uiCode, "max_tid_il_ref_pics_plus1[i][j]" ); vps->setMaxTidIlRefPicsPlus1(i, j, uiCode);         
     1561        }
     1562      }
    12491563#else
    12501564      READ_CODE( 3, uiCode, "max_tid_il_ref_pics_plus1[i]" ); vps->setMaxTidIlRefPicsPlus1(i, uiCode);
     
    12581572    {
    12591573#if O0225_MAX_TID_FOR_REF_LAYERS
    1260        for( j = i+1; j <= vps->getMaxLayers() - 1; j++)
    1261        {
    1262           vps->setMaxTidIlRefPicsPlus1(i, j, 7);
    1263        }
     1574      for( j = i+1; j <= vps->getMaxLayers() - 1; j++)
     1575      {
     1576        vps->setMaxTidIlRefPicsPlus1(i, j, 7);
     1577      }
    12641578#else
    12651579      vps->setMaxTidIlRefPicsPlus1(i, 7);
     
    12761590  READ_UVLC(  uiCode, "vps_num_profile_tier_level_minus1"); vps->setNumProfileTierLevel( uiCode + 1 );
    12771591#endif
     1592#if PER_LAYER_PTL
     1593  Int const numBitsForPtlIdx = vps->calculateLenOfSyntaxElement( vps->getNumProfileTierLevel() );
     1594#endif
    12781595  vps->getPTLForExtnPtr()->resize(vps->getNumProfileTierLevel());
     1596#if LIST_OF_PTL
     1597  for(Int idx = vps->getBaseLayerInternalFlag() ? 2 : 1; idx <= vps->getNumProfileTierLevel() - 1; idx++)
     1598#else
    12791599  for(Int idx = 1; idx <= vps->getNumProfileTierLevel() - 1; idx++)
     1600#endif
    12801601  {
    12811602    READ_FLAG( uiCode, "vps_profile_present_flag[i]" ); vps->setProfilePresentFlag(idx, uiCode ? true : false);
     
    13001621#endif
    13011622
     1623#if !MOVE_ADDN_LS_SIGNALLING
    13021624#if Q0078_ADD_LAYER_SETS
    13031625  if (vps->getNumIndependentLayers() > 1)
     
    13191641    vps->setLayerIdIncludedFlagsForAddLayerSets();
    13201642  }
     1643#endif
    13211644#endif
    13221645
     
    13631686#endif
    13641687  vps->setNumOutputLayerSets( numOutputLayerSets );
    1365 
     1688#if NECESSARY_LAYER_FLAG
     1689  // Default output layer set
     1690  vps->setOutputLayerSetIdx(0, 0);
     1691  vps->setOutputLayerFlag(0, 0, true);
     1692  vps->deriveNecessaryLayerFlag(0);
     1693#if PER_LAYER_PTL
     1694  vps->getProfileLevelTierIdx()->resize(numOutputLayerSets);
     1695  vps->getProfileLevelTierIdx(0)->push_back( vps->getBaseLayerInternalFlag() && vps->getMaxLayers() > 1 ? 1 : 0);
     1696#endif
     1697#endif
    13661698  for(i = 1; i < numOutputLayerSets; i++)
    13671699  {
     
    13791711      vps->setOutputLayerSetIdx( i, i );
    13801712    }
     1713    Int layerSetIdxForOutputLayerSet = vps->getOutputLayerSetIdx(i);
    13811714#if Q0078_ADD_LAYER_SETS
    13821715    if ( i > vps->getVpsNumLayerSetsMinus1() || vps->getDefaultTargetOutputLayerIdc() >= 2 )
     
    13851718#endif
    13861719    {
    1387       Int lsIdx = vps->getOutputLayerSetIdx(i);
    13881720#if NUM_OL_FLAGS
    1389       for(j = 0; j < vps->getNumLayersInIdList(lsIdx); j++)
     1721      for(j = 0; j < vps->getNumLayersInIdList(layerSetIdxForOutputLayerSet); j++)
    13901722#else
    13911723      for(j = 0; j < vps->getNumLayersInIdList(lsIdx) - 1; j++)
     
    13991731      // i <= (vps->getNumLayerSets() - 1)
    14001732      // Assign OutputLayerFlag depending on default_one_target_output_layer_flag
    1401       Int lsIdx = i;
    14021733      if( vps->getDefaultTargetOutputLayerIdc() == 1 )
    14031734      {
    1404         for(j = 0; j < vps->getNumLayersInIdList(lsIdx); j++)
    1405         {
    1406           vps->setOutputLayerFlag(i, j, (j == (vps->getNumLayersInIdList(lsIdx)-1)) && (vps->getDimensionId(j,1) == 0) );
     1735        for(j = 0; j < vps->getNumLayersInIdList(layerSetIdxForOutputLayerSet); j++)
     1736        {
     1737#if DEF_OPT_LAYER_IDC
     1738          vps->setOutputLayerFlag(i, j, (j == (vps->getNumLayersInIdList(layerSetIdxForOutputLayerSet)-1))  );
     1739
     1740#else
     1741          vps->setOutputLayerFlag(i, j, (j == (vps->getNumLayersInIdList(layerSetIdxForOutputLayerSet)-1)) && (vps->getDimensionId(j,1) == 0) );
     1742#endif
    14071743        }
    14081744      }
    14091745      else if ( vps->getDefaultTargetOutputLayerIdc() == 0 )
    14101746      {
    1411         for(j = 0; j < vps->getNumLayersInIdList(lsIdx); j++)
     1747        for(j = 0; j < vps->getNumLayersInIdList(layerSetIdxForOutputLayerSet); j++)
    14121748        {
    14131749          vps->setOutputLayerFlag(i, j, 1);
     
    14151751      }
    14161752    }
     1753#if NECESSARY_LAYER_FLAG
     1754    vps->deriveNecessaryLayerFlag(i); 
     1755#endif
     1756#if PER_LAYER_PTL
     1757    vps->getProfileLevelTierIdx(i)->assign(vps->getNumLayersInIdList(layerSetIdxForOutputLayerSet), -1);
     1758    for(j = 0; j < vps->getNumLayersInIdList(layerSetIdxForOutputLayerSet) ; j++)
     1759    {
     1760      if( vps->getNecessaryLayerFlag(i, j) )
     1761      {
     1762        READ_CODE( numBitsForPtlIdx, uiCode, "profile_level_tier_idx[i]" );
     1763        vps->setProfileLevelTierIdx(i, j, uiCode );
     1764      }
     1765    }
     1766#else
    14171767    Int numBits = 1;
    14181768    while ((1 << numBits) < (vps->getNumProfileTierLevel()))
     
    14211771    }
    14221772    READ_CODE( numBits, uiCode, "profile_level_tier_idx[i]" );     vps->setProfileLevelTierIdx(i, uiCode);
     1773#endif
    14231774#if P0300_ALT_OUTPUT_LAYER_FLAG
    14241775    NumOutputLayersInOutputLayerSet[i] = 0;
    1425     Int layerSetIdxForOutputLayerSet = vps->getOutputLayerSetIdx(i);
    14261776    for (j = 0; j < vps->getNumLayersInIdList(layerSetIdxForOutputLayerSet); j++)
    14271777    {
     
    14371787      vps->setAltOuputLayerFlag(i, uiCode ? true : false);
    14381788    }
     1789#if ALT_OPT_LAYER_FLAG
     1790    else
     1791    {
     1792          uiCode=0;
     1793          vps->setAltOuputLayerFlag(i, uiCode ? true : false);
     1794    }
     1795#endif
    14391796#if Q0165_OUTPUT_LAYER_SET
    14401797    assert( NumOutputLayersInOutputLayerSet[i]>0 );
     
    14431800#endif
    14441801  }
     1802#if NECESSARY_LAYER_FLAG
     1803  vps->checkNecessaryLayerFlagCondition(); 
     1804#endif
    14451805#else
    14461806  if( numOutputLayerSets > 1 )
     
    14881848        {
    14891849#if O0135_DEFAULT_ONE_OUT_SEMANTIC
     1850#if DEF_OPT_LAYER_IDC
     1851        vps->setOutputLayerFlag(i, j, (j == (vps->getNumLayersInIdList(lsIdx)-1)) );
     1852#else
    14901853          vps->setOutputLayerFlag(i, j, (j == (vps->getNumLayersInIdList(lsIdx)-1)) && (vps->getDimensionId(j,1)==0) );
     1854#endif
    14911855#else
    14921856          vps->setOutputLayerFlag(i, j, (j == (vps->getNumLayersInIdList(lsIdx)-1)));
     
    16692033  READ_FLAG(uiCode, "max_one_active_ref_layer_flag" );
    16702034  vps->setMaxOneActiveRefLayerFlag(uiCode);
     2035#if P0297_VPS_POC_LSB_ALIGNED_FLAG
     2036  READ_FLAG(uiCode, "vps_poc_lsb_aligned_flag");
     2037  vps->setVpsPocLsbAlignedFlag(uiCode);
     2038#endif
    16712039#if O0062_POC_LSB_NOT_PRESENT_FLAG
    16722040  for(i = 1; i< vps->getMaxLayers(); i++)
     
    18242192#endif
    18252193  }
    1826  
     2194
    18272195  // When not present, the value of num_add_olss is inferred to be equal to 0.
    18282196  // NumOutputLayerSets = num_add_olss + NumLayerSets
     
    18382206    for( j = 0; j < vps->getNumLayersInIdList(lsIdx); j++ )
    18392207    {
    1840     vps->setOutputLayerFlag(i, j, 1);
     2208      vps->setOutputLayerFlag(i, j, 1);
    18412209    }
    18422210  }
     
    18482216    vps->setSubLayerDpbInfoPresentFlag( i, 0, true );
    18492217  }
    1850  
     2218
    18512219  // When not present, the value of vps_num_rep_formats_minus1 is inferred to be equal to MaxLayersMinus1.
    18522220  vps->setVpsNumRepFormats( vps->getMaxLayers() );
     
    18642232  }
    18652233
    1866   // vps_poc_lsb_aligned_flag
    1867   // When not present, vps_poc_lsb_aligned_flag is inferred to be equal to 0.
    1868  
     2234#if P0297_VPS_POC_LSB_ALIGNED_FLAG
     2235  vps->setVpsPocLsbAlignedFlag(false);
     2236#endif
     2237
    18692238#if O0062_POC_LSB_NOT_PRESENT_FLAG
    18702239  // When not present, poc_lsb_not_present_flag[ i ] is inferred to be equal to 0.
     
    19372306    repFormat->setBitDepthVpsChroma         ( repFormatPrev->getBitDepthVpsChroma() );
    19382307  }
     2308
    19392309#else
    19402310#if AUXILIARY_PICTURES
     
    19432313  READ_CODE( 2, uiCode, "chroma_format_idc" );               repFormat->setChromaFormatVpsIdc( uiCode );
    19442314#endif
    1945  
     2315
    19462316  if( repFormat->getChromaFormatVpsIdc() == 3 )
    19472317  {
     
    19552325  READ_CODE( 4, uiCode, "bit_depth_chroma_minus8" );         repFormat->setBitDepthVpsChroma( uiCode + 8 );
    19562326#endif
     2327
     2328#if R0156_CONF_WINDOW_IN_REP_FORMAT
     2329  READ_FLAG( uiCode, "conformance_window_vps_flag" );
     2330  if( uiCode != 0)
     2331  {
     2332    Window &conf = repFormat->getConformanceWindowVps();
     2333    READ_UVLC( uiCode, "conf_win_vps_left_offset" );         conf.setWindowLeftOffset  ( uiCode );
     2334    READ_UVLC( uiCode, "conf_win_vps_right_offset" );        conf.setWindowRightOffset ( uiCode );
     2335    READ_UVLC( uiCode, "conf_win_vps_top_offset" );          conf.setWindowTopOffset   ( uiCode );
     2336    READ_UVLC( uiCode, "conf_win_vps_bottom_offset" );       conf.setWindowBottomOffset( uiCode );
     2337  }
     2338#endif
    19572339}
    19582340#endif
     
    19612343{
    19622344  UInt uiCode;
     2345#if SUB_LAYERS_IN_LAYER_SET
     2346  vps->calculateMaxSLInLayerSets();
     2347#else
    19632348#if DPB_PARAMS_MAXTLAYERS
    19642349#if BITRATE_PICRATE_SIGNALLING
    1965     Int * MaxSubLayersInLayerSetMinus1 = new Int[vps->getNumLayerSets()];
    1966     for(Int i = 0; i < vps->getNumLayerSets(); i++)
    1967 #else
    1968     Int * MaxSubLayersInLayerSetMinus1 = new Int[vps->getNumOutputLayerSets()];
    1969     for(Int i = 1; i < vps->getNumOutputLayerSets(); i++)
    1970 #endif
    1971     {
    1972         UInt maxSLMinus1 = 0;
     2350  Int * MaxSubLayersInLayerSetMinus1 = new Int[vps->getNumLayerSets()];
     2351  for(Int i = 0; i < vps->getNumLayerSets(); i++)
     2352#else
     2353  Int * MaxSubLayersInLayerSetMinus1 = new Int[vps->getNumOutputLayerSets()];
     2354  for(Int i = 1; i < vps->getNumOutputLayerSets(); i++)
     2355#endif
     2356  {
     2357    UInt maxSLMinus1 = 0;
    19732358#if CHANGE_NUMSUBDPB_IDX
    1974         Int optLsIdx = vps->getOutputLayerSetIdx( i );
    1975 #else
    1976         Int optLsIdx = i;
     2359    Int optLsIdx = vps->getOutputLayerSetIdx( i );
     2360#else
     2361    Int optLsIdx = i;
    19772362#endif
    19782363#if BITRATE_PICRATE_SIGNALLING
    1979         optLsIdx = i;
    1980 #endif
    1981         for(Int k = 0; k < vps->getNumLayersInIdList(optLsIdx); k++ ) {
    1982             Int  lId = vps->getLayerSetLayerIdList(optLsIdx, k);
    1983             maxSLMinus1 = max(maxSLMinus1, vps->getMaxTSLayersMinus1(vps->getLayerIdInVps(lId)));
    1984         }
    1985         MaxSubLayersInLayerSetMinus1[ i ] = maxSLMinus1;
     2364    optLsIdx = i;
     2365#endif
     2366    for(Int k = 0; k < vps->getNumLayersInIdList(optLsIdx); k++ ) {
     2367      Int  lId = vps->getLayerSetLayerIdList(optLsIdx, k);
     2368      maxSLMinus1 = max(maxSLMinus1, vps->getMaxTSLayersMinus1(vps->getLayerIdInVps(lId)));
     2369    }
     2370    MaxSubLayersInLayerSetMinus1[ i ] = maxSLMinus1;
    19862371#if BITRATE_PICRATE_SIGNALLING
    1987         vps->setMaxSLayersInLayerSetMinus1(i,MaxSubLayersInLayerSetMinus1[ i ]);
    1988 #endif
    1989     }
    1990 #endif
    1991    
     2372    vps->setMaxSLayersInLayerSetMinus1(i,MaxSubLayersInLayerSetMinus1[ i ]);
     2373#endif
     2374  }
     2375#endif
     2376#endif
     2377
    19922378#if !RESOLUTION_BASED_DPB
    19932379  vps->deriveNumberOfSubDpbs();
     
    19992385#endif
    20002386    READ_FLAG( uiCode, "sub_layer_flag_info_present_flag[i]");  vps->setSubLayerFlagInfoPresentFlag( i, uiCode ? true : false );
     2387#if SUB_LAYERS_IN_LAYER_SET
     2388    for(Int j = 0; j <= vps->getMaxSLayersInLayerSetMinus1( layerSetIdxForOutputLayerSet ); j++)
     2389#else
    20012390#if DPB_PARAMS_MAXTLAYERS
    20022391#if BITRATE_PICRATE_SIGNALLING
     
    20082397    for(Int j = 0; j <= vps->getMaxTLayers(); j++)
    20092398#endif
     2399#endif
    20102400    {
    20112401      if( j > 0 && vps->getSubLayerFlagInfoPresentFlag(i) )
     
    20322422#endif
    20332423        {
     2424#if DPB_INTERNAL_BL_SIG
     2425            uiCode=0;
     2426        if(vps->getBaseLayerInternalFlag()  || ( vps->getLayerSetLayerIdList(layerSetIdxForOutputLayerSet, k)   !=  0 ) )
     2427#endif
    20342428          READ_UVLC( uiCode, "max_vps_dec_pic_buffering_minus1[i][k][j]" ); vps->setMaxVpsDecPicBufferingMinus1( i, k, j, uiCode );
    20352429        }
     
    20602454  }
    20612455
     2456#if !SUB_LAYERS_IN_LAYER_SET
     2457#if BITRATE_PICRATE_SIGNALLING
     2458  if( MaxSubLayersInLayerSetMinus1 )
     2459  {
     2460    delete [] MaxSubLayersInLayerSetMinus1;
     2461  }
     2462#endif
     2463#endif
     2464
    20622465  // Infer values when not signalled
    20632466  for(Int i = 1; i < vps->getNumOutputLayerSets(); i++)
     
    21222525  READ_FLAG( uiCode,        "pic_rate_present_vps_flag" );  vps->setPicRatePresentVpsFlag( uiCode ? true : false );
    21232526
     2527#if SIGNALLING_BITRATE_PICRATE_FIX
     2528  if ( vps->getBitRatePresentVpsFlag() || vps->getPicRatePresentVpsFlag() )
     2529  {
     2530    for( i = vps->getBaseLayerInternalFlag() ? 0 : 1; i < vps->getNumLayerSets(); i++ )
     2531    {
     2532      for( j = 0; j <= vps->getMaxSLayersInLayerSetMinus1( i ); j++ )
     2533      {
     2534        if( vps->getBitRatePresentVpsFlag() )
     2535        {
     2536          READ_FLAG( uiCode, "bit_rate_present_flag[i][j]" ); vps->setBitRatePresentFlag( i, j, uiCode ? true : false );           
     2537        }
     2538        if( vps->getPicRatePresentVpsFlag( )  )
     2539        {
     2540          READ_FLAG( uiCode, "pic_rate_present_flag[i][j]" ); vps->setPicRatePresentFlag( i, j, uiCode ? true : false );
     2541        }
     2542        if( vps->getBitRatePresentFlag( i, j ) )
     2543        {
     2544          READ_CODE( 16, uiCode, "avg_bit_rate" ); vps->setAvgBitRate( i, j, uiCode );
     2545          READ_CODE( 16, uiCode, "max_bit_rate" ); vps->setMaxBitRate( i, j, uiCode );
     2546        }
     2547        else
     2548        {
     2549          vps->setAvgBitRate( i, j, 0 );
     2550          vps->setMaxBitRate( i, j, 0 );
     2551        }
     2552        if( vps->getPicRatePresentFlag( i, j ) )
     2553        {
     2554          READ_CODE( 2,  uiCode, "constant_pic_rate_idc" ); vps->setConstPicRateIdc( i, j, uiCode );
     2555          READ_CODE( 16, uiCode, "avg_pic_rate" );          vps->setAvgPicRate( i, j, uiCode );
     2556        }
     2557        else
     2558        {
     2559          vps->setConstPicRateIdc( i, j, 0 );
     2560          vps->setAvgPicRate( i, j, 0 );
     2561        }
     2562      }
     2563    }
     2564  }
     2565#else
    21242566  Bool parseFlag = vps->getBitRatePresentVpsFlag() || vps->getPicRatePresentVpsFlag();
    21252567
    21262568#if Q0078_ADD_LAYER_SETS
     2569#if R0227_BR_PR_ADD_LAYER_SET
     2570  for( i = 0; i < vps->getNumLayerSets(); i++ )
     2571#else
    21272572  for( i = 0; i <= vps->getVpsNumLayerSetsMinus1(); i++ )
     2573#endif
    21282574#else
    21292575  for( i = 0; i < vps->getNumLayerSets(); i++ )
     
    21742620    }
    21752621  }
     2622#endif
    21762623#if VPS_VUI_VIDEO_SIGNAL_MOVE
    21772624  READ_FLAG( uiCode, "video_signal_info_idx_present_flag" ); vps->setVideoSigPresentVpsFlag( uiCode == 1 );
     
    21822629  else
    21832630  {
     2631#if VPS_VUI_VST_PARAMS
     2632    vps->setNumVideoSignalInfo(vps->getMaxLayers() - vps->getBaseLayerInternalFlag() ? 0 : 1);
     2633#else
    21842634    vps->setNumVideoSignalInfo(vps->getMaxLayers());
     2635#endif
    21852636  }
    21862637
     
    21932644    READ_CODE(8, uiCode, "matrix_coeffs_vps" );vps->setMaxtrixCoeff(i,uiCode);
    21942645  }
     2646#if VPS_VUI_VST_PARAMS
     2647  if( vps->getVideoSigPresentVpsFlag() && vps->getNumVideoSignalInfo() > 1 )
     2648  {
     2649    for(i = vps->getBaseLayerInternalFlag() ? 0 : 1; i < vps->getMaxLayers(); i++)
     2650    {
     2651      READ_CODE(4, uiCode, "vps_video_signal_info_idx" ); vps->setVideoSignalInfoIdx(i, uiCode);
     2652    }
     2653  }
     2654  else if ( !vps->getVideoSigPresentVpsFlag() )
     2655  {
     2656    for(i = vps->getBaseLayerInternalFlag() ? 0 : 1; i < vps->getMaxLayers(); i++)
     2657    {
     2658      vps->setVideoSignalInfoIdx( i, i );
     2659    }
     2660  }
     2661  else // ( vps->getNumVideoSignalInfo() = 0 )
     2662  {
     2663    for(i = vps->getBaseLayerInternalFlag() ? 0 : 1; i < vps->getMaxLayers(); i++)
     2664    {
     2665      vps->setVideoSignalInfoIdx( i, 0 );
     2666    }
     2667  }
     2668#else
    21952669  if(!vps->getVideoSigPresentVpsFlag())
    21962670  {
     
    22142688    }
    22152689  }
     2690#endif
    22162691#endif
    22172692#if VPS_VUI_TILES_NOT_IN_USE__FLAG
     
    23032778#if VPS_VUI_VIDEO_SIGNAL_MOVE
    23042779#else
    2305     READ_FLAG( uiCode, "video_signal_info_idx_present_flag" ); vps->setVideoSigPresentVpsFlag( uiCode == 1 );
    2306     if (vps->getVideoSigPresentVpsFlag())
    2307     {
    2308         READ_CODE(4, uiCode, "vps_num_video_signal_info_minus1" ); vps->setNumVideoSignalInfo(uiCode + 1);
     2780  READ_FLAG( uiCode, "video_signal_info_idx_present_flag" ); vps->setVideoSigPresentVpsFlag( uiCode == 1 );
     2781  if (vps->getVideoSigPresentVpsFlag())
     2782  {
     2783    READ_CODE(4, uiCode, "vps_num_video_signal_info_minus1" ); vps->setNumVideoSignalInfo(uiCode + 1);
     2784  }
     2785  else
     2786  {
     2787    vps->setNumVideoSignalInfo(vps->getMaxLayers());
     2788  }
     2789
     2790
     2791  for(i = 0; i < vps->getNumVideoSignalInfo(); i++)
     2792  {
     2793    READ_CODE(3, uiCode, "video_vps_format" ); vps->setVideoVPSFormat(i,uiCode);
     2794    READ_FLAG(uiCode, "video_full_range_vps_flag" ); vps->setVideoFullRangeVpsFlag(i,uiCode);
     2795    READ_CODE(8, uiCode, "color_primaries_vps" ); vps->setColorPrimaries(i,uiCode);
     2796    READ_CODE(8, uiCode, "transfer_characteristics_vps" ); vps->setTransCharacter(i,uiCode);
     2797    READ_CODE(8, uiCode, "matrix_coeffs_vps" );vps->setMaxtrixCoeff(i,uiCode);
     2798  }
     2799  if(!vps->getVideoSigPresentVpsFlag())
     2800  {
     2801    for (i=0; i < vps->getMaxLayers(); i++)
     2802    {
     2803      vps->setVideoSignalInfoIdx(i,i);
     2804    }
     2805  }
     2806  else {
     2807    vps->setVideoSignalInfoIdx(0,0);
     2808    if (vps->getNumVideoSignalInfo() > 1 )
     2809    {
     2810      for (i=1; i < vps->getMaxLayers(); i++)
     2811        READ_CODE(4, uiCode, "vps_video_signal_info_idx" ); vps->setVideoSignalInfoIdx(i, uiCode);
     2812    }
     2813    else {
     2814      for (i=1; i < vps->getMaxLayers(); i++)
     2815      {
     2816        vps->setVideoSignalInfoIdx(i,0);
     2817      }
     2818    }
     2819  }
     2820#endif
     2821#endif
     2822
     2823#if O0164_MULTI_LAYER_HRD
     2824  READ_FLAG(uiCode, "vps_vui_bsp_hrd_present_flag" ); vps->setVpsVuiBspHrdPresentFlag(uiCode);
     2825  if (vps->getVpsVuiBspHrdPresentFlag())
     2826  {
     2827#if VPS_VUI_BSP_HRD_PARAMS
     2828    parseVpsVuiBspHrdParams(vps);
     2829#else
     2830#if R0227_VUI_BSP_HRD_FLAG
     2831    assert (vps->getTimingInfo()->getTimingInfoPresentFlag() == 1);
     2832#endif
     2833    READ_UVLC( uiCode, "vps_num_bsp_hrd_parameters_minus1" ); vps->setVpsNumBspHrdParametersMinus1(uiCode);
     2834    vps->createBspHrdParamBuffer(vps->getVpsNumBspHrdParametersMinus1() + 1);
     2835    for( i = 0; i <= vps->getVpsNumBspHrdParametersMinus1(); i++ )
     2836    {
     2837      if( i > 0 )
     2838      {
     2839        READ_FLAG( uiCode, "bsp_cprms_present_flag[i]" ); vps->setBspCprmsPresentFlag(i, uiCode);
     2840      }
     2841      parseHrdParameters(vps->getBspHrd(i), i==0 ? 1 : vps->getBspCprmsPresentFlag(i), vps->getMaxTLayers()-1);
     2842    }
     2843#if Q0078_ADD_LAYER_SETS
     2844    for (UInt h = 1; h <= vps->getVpsNumLayerSetsMinus1(); h++)
     2845#else
     2846    for( UInt h = 1; h <= (vps->getNumLayerSets()-1); h++ )
     2847#endif
     2848    {
     2849      READ_UVLC( uiCode, "num_bitstream_partitions[i]"); vps->setNumBitstreamPartitions(h, uiCode);
     2850#if HRD_BPB
     2851      Int chkPart=0;
     2852#endif
     2853      for( i = 0; i < vps->getNumBitstreamPartitions(h); i++ )
     2854      {
     2855        for( j = 0; j <= (vps->getMaxLayers()-1); j++ )
     2856        {
     2857          if( vps->getLayerIdIncludedFlag(h, j) )
     2858          {
     2859            READ_FLAG( uiCode, "layer_in_bsp_flag[h][i][j]" ); vps->setLayerInBspFlag(h, i, j, uiCode);
     2860          }
     2861        }
     2862#if HRD_BPB
     2863        chkPart+=vps->getLayerInBspFlag(h, i, j);
     2864#endif
     2865      }
     2866#if HRD_BPB
     2867      assert(chkPart<=1);
     2868#endif
     2869#if HRD_BPB
     2870      if(vps->getNumBitstreamPartitions(h)==1)
     2871      {
     2872        Int chkPartition1=0; Int chkPartition2=0;
     2873        for( j = 0; j <= (vps->getMaxLayers()-1); j++ )
     2874        {
     2875          if( vps->getLayerIdIncludedFlag(h, j) )
     2876          {
     2877            chkPartition1+=vps->getLayerInBspFlag(h, 0, j);
     2878            chkPartition2++;
     2879          }
     2880        }
     2881        assert(chkPartition1!=chkPartition2);
     2882      }
     2883#endif
     2884      if (vps->getNumBitstreamPartitions(h))
     2885      {
     2886#if Q0182_MULTI_LAYER_HRD_UPDATE
     2887        READ_UVLC( uiCode, "num_bsp_sched_combinations_minus1[h]"); vps->setNumBspSchedCombinations(h, uiCode + 1);
     2888#else
     2889        READ_UVLC( uiCode, "num_bsp_sched_combinations[h]"); vps->setNumBspSchedCombinations(h, uiCode);
     2890#endif
     2891        for( i = 0; i < vps->getNumBspSchedCombinations(h); i++ )
     2892        {
     2893          for( j = 0; j < vps->getNumBitstreamPartitions(h); j++ )
     2894          {
     2895            READ_UVLC( uiCode, "bsp_comb_hrd_idx[h][i][j]"); vps->setBspCombHrdIdx(h, i, j, uiCode);
     2896#if HRD_BPB
     2897            assert(uiCode <= vps->getVpsNumBspHrdParametersMinus1());
     2898#endif
     2899
     2900            READ_UVLC( uiCode, "bsp_comb_sched_idx[h][i][j]"); vps->setBspCombSchedIdx(h, i, j, uiCode);
     2901#if HRD_BPB
     2902            assert(uiCode <= vps->getBspHrdParamBufferCpbCntMinus1(uiCode,vps->getMaxTLayers()-1));
     2903#endif
     2904          }
     2905        }
     2906      }
     2907    }
     2908#endif
     2909  }
     2910#endif
     2911#if P0182_VPS_VUI_PS_FLAG
     2912  for(i = 1; i < vps->getMaxLayers(); i++)
     2913  {
     2914    if (vps->getNumRefLayers(vps->getLayerIdInNuh(i)) == 0)
     2915    {
     2916      READ_FLAG( uiCode, "base_layer_parameter_set_compatibility_flag" );
     2917      vps->setBaseLayerPSCompatibilityFlag( i, uiCode );
    23092918    }
    23102919    else
    23112920    {
    2312         vps->setNumVideoSignalInfo(vps->getMaxLayers());
    2313     }
    2314    
    2315    
    2316     for(i = 0; i < vps->getNumVideoSignalInfo(); i++)
    2317     {
    2318         READ_CODE(3, uiCode, "video_vps_format" ); vps->setVideoVPSFormat(i,uiCode);
    2319         READ_FLAG(uiCode, "video_full_range_vps_flag" ); vps->setVideoFullRangeVpsFlag(i,uiCode);
    2320         READ_CODE(8, uiCode, "color_primaries_vps" ); vps->setColorPrimaries(i,uiCode);
    2321         READ_CODE(8, uiCode, "transfer_characteristics_vps" ); vps->setTransCharacter(i,uiCode);
    2322         READ_CODE(8, uiCode, "matrix_coeffs_vps" );vps->setMaxtrixCoeff(i,uiCode);
    2323     }
    2324     if(!vps->getVideoSigPresentVpsFlag())
    2325     {
    2326         for (i=0; i < vps->getMaxLayers(); i++)
    2327         {
    2328             vps->setVideoSignalInfoIdx(i,i);
    2329         }
    2330     }
    2331     else {
    2332         vps->setVideoSignalInfoIdx(0,0);
    2333         if (vps->getNumVideoSignalInfo() > 1 )
    2334         {
    2335             for (i=1; i < vps->getMaxLayers(); i++)
    2336                 READ_CODE(4, uiCode, "vps_video_signal_info_idx" ); vps->setVideoSignalInfoIdx(i, uiCode);
    2337         }
    2338         else {
    2339           for (i=1; i < vps->getMaxLayers(); i++)
    2340           {
    2341             vps->setVideoSignalInfoIdx(i,0);
    2342           }
    2343         }
    2344     }
    2345 #endif
    2346 #endif
    2347 
    2348 #if O0164_MULTI_LAYER_HRD
    2349     READ_FLAG(uiCode, "vps_vui_bsp_hrd_present_flag" ); vps->setVpsVuiBspHrdPresentFlag(uiCode);
    2350     if (vps->getVpsVuiBspHrdPresentFlag())
    2351     {
    2352       READ_UVLC( uiCode, "vps_num_bsp_hrd_parameters_minus1" ); vps->setVpsNumBspHrdParametersMinus1(uiCode);
    2353       vps->createBspHrdParamBuffer(vps->getVpsNumBspHrdParametersMinus1() + 1);
    2354       for( i = 0; i <= vps->getVpsNumBspHrdParametersMinus1(); i++ )
    2355       {
    2356         if( i > 0 )
    2357         {
    2358           READ_FLAG( uiCode, "bsp_cprms_present_flag[i]" ); vps->setBspCprmsPresentFlag(i, uiCode);
    2359         }
    2360         parseHrdParameters(vps->getBspHrd(i), i==0 ? 1 : vps->getBspCprmsPresentFlag(i), vps->getMaxTLayers()-1);
    2361       }
    2362 #if Q0078_ADD_LAYER_SETS
    2363       for (UInt h = 1; h <= vps->getVpsNumLayerSetsMinus1(); h++)
    2364 #else
    2365       for( UInt h = 1; h <= (vps->getNumLayerSets()-1); h++ )
    2366 #endif
    2367       {
    2368         READ_UVLC( uiCode, "num_bitstream_partitions[i]"); vps->setNumBitstreamPartitions(h, uiCode);
    2369 #if HRD_BPB
    2370         Int chkPart=0;
    2371 #endif
    2372         for( i = 0; i < vps->getNumBitstreamPartitions(h); i++ )
    2373         {
    2374           for( j = 0; j <= (vps->getMaxLayers()-1); j++ )
    2375           {
    2376             if( vps->getLayerIdIncludedFlag(h, j) )
    2377             {
    2378               READ_FLAG( uiCode, "layer_in_bsp_flag[h][i][j]" ); vps->setLayerInBspFlag(h, i, j, uiCode);
    2379             }
    2380           }
    2381 #if HRD_BPB
    2382           chkPart+=vps->getLayerInBspFlag(h, i, j);
    2383 #endif
    2384         }
    2385 #if HRD_BPB
    2386         assert(chkPart<=1);
    2387 #endif
    2388 #if HRD_BPB
    2389         if(vps->getNumBitstreamPartitions(h)==1)
    2390         {
    2391           Int chkPartition1=0; Int chkPartition2=0;
    2392           for( j = 0; j <= (vps->getMaxLayers()-1); j++ )
    2393           {
    2394             if( vps->getLayerIdIncludedFlag(h, j) )
    2395             {
    2396               chkPartition1+=vps->getLayerInBspFlag(h, 0, j);
    2397               chkPartition2++;
    2398             }
    2399           }
    2400           assert(chkPartition1!=chkPartition2);
    2401         }
    2402 #endif
    2403         if (vps->getNumBitstreamPartitions(h))
    2404         {
    2405 #if Q0182_MULTI_LAYER_HRD_UPDATE
    2406           READ_UVLC( uiCode, "num_bsp_sched_combinations_minus1[h]"); vps->setNumBspSchedCombinations(h, uiCode + 1);
    2407 #else
    2408           READ_UVLC( uiCode, "num_bsp_sched_combinations[h]"); vps->setNumBspSchedCombinations(h, uiCode);
    2409 #endif
    2410           for( i = 0; i < vps->getNumBspSchedCombinations(h); i++ )
    2411           {
    2412             for( j = 0; j < vps->getNumBitstreamPartitions(h); j++ )
    2413             {
    2414               READ_UVLC( uiCode, "bsp_comb_hrd_idx[h][i][j]"); vps->setBspCombHrdIdx(h, i, j, uiCode);
    2415 #if HRD_BPB
    2416               assert(uiCode <= vps->getVpsNumBspHrdParametersMinus1());
    2417 #endif
    2418                
    2419               READ_UVLC( uiCode, "bsp_comb_sched_idx[h][i][j]"); vps->setBspCombSchedIdx(h, i, j, uiCode);
    2420 #if HRD_BPB
    2421               assert(uiCode <= vps->getBspHrdParamBufferCpbCntMinus1(uiCode,vps->getMaxTLayers()-1));
    2422 #endif
    2423             }
    2424           }
    2425         }
    2426       }
    2427     }
    2428 #endif
    2429 
    2430 #if P0182_VPS_VUI_PS_FLAG
    2431     for(i = 1; i < vps->getMaxLayers(); i++)
    2432     {
    2433       if (vps->getNumRefLayers(vps->getLayerIdInNuh(i)) == 0)
    2434       {
    2435         READ_FLAG( uiCode, "base_layer_parameter_set_compatibility_flag" );
    2436         vps->setBaseLayerPSCompatibilityFlag( i, uiCode );
    2437       }
    2438       else
    2439       {
    2440         vps->setBaseLayerPSCompatibilityFlag( i, 0 );
    2441       }
    2442     }
    2443 #endif
    2444 }
     2921      vps->setBaseLayerPSCompatibilityFlag( i, 0 );
     2922    }
     2923  }
     2924#endif
     2925}
     2926
    24452927#endif //SVC_EXTENSION
    24462928
     
    24762958  rpcSlice->setSPS(sps);
    24772959  rpcSlice->setPPS(pps);
     2960
     2961#if R0227_REP_FORMAT_CONSTRAINT //Conformance checking for rep format -- rep format of current picture of current layer shall never be greater rep format defined in VPS for the current layer
     2962  TComVPS* vps = NULL;
     2963  vps = parameterSetManager->getPrefetchedVPS(sps->getVPSId());
     2964#if R0279_REP_FORMAT_INBL
     2965  if ( vps->getVpsExtensionFlag() == 1 && (rpcSlice->getLayerId() == 0 || sps->getV1CompatibleSPSFlag() == 1) )
     2966  {
     2967    assert( sps->getPicWidthInLumaSamples() <= vps->getVpsRepFormat( vps->getVpsRepFormatIdx(rpcSlice->getLayerId()) )->getPicWidthVpsInLumaSamples() );
     2968    assert( sps->getPicHeightInLumaSamples() <= vps->getVpsRepFormat( vps->getVpsRepFormatIdx(rpcSlice->getLayerId()) )->getPicHeightVpsInLumaSamples() );
     2969    assert( sps->getChromaFormatIdc() <= vps->getVpsRepFormat( vps->getVpsRepFormatIdx(rpcSlice->getLayerId()) )->getChromaFormatVpsIdc() );
     2970    assert( sps->getBitDepthY() <= vps->getVpsRepFormat( vps->getVpsRepFormatIdx(rpcSlice->getLayerId()) )->getBitDepthVpsLuma() );
     2971    assert( sps->getBitDepthC() <= vps->getVpsRepFormat( vps->getVpsRepFormatIdx(rpcSlice->getLayerId()) )->getBitDepthVpsChroma() );
     2972#else
     2973  if ( rpcSlice->getLayerId() == 0 && vps->getVpsExtensionFlag() == 1 )
     2974  {
     2975    assert( sps->getPicWidthInLumaSamples() <= vps->getVpsRepFormat( vps->getVpsRepFormatIdx(0) )->getPicWidthVpsInLumaSamples() );
     2976    assert( sps->getPicHeightInLumaSamples() <= vps->getVpsRepFormat( vps->getVpsRepFormatIdx(0) )->getPicHeightVpsInLumaSamples() );
     2977    assert( sps->getChromaFormatIdc() <= vps->getVpsRepFormat( vps->getVpsRepFormatIdx(0) )->getChromaFormatVpsIdc() );
     2978    assert( sps->getBitDepthY() <= vps->getVpsRepFormat( vps->getVpsRepFormatIdx(0) )->getBitDepthVpsLuma() );
     2979    assert( sps->getBitDepthC() <= vps->getVpsRepFormat( vps->getVpsRepFormatIdx(0) )->getBitDepthVpsChroma() );
     2980#endif
     2981  }
     2982  else if ( vps->getVpsExtensionFlag() == 1 )
     2983  {
     2984    assert(vps->getVpsRepFormat( vps->getVpsRepFormatIdx(sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : rpcSlice->getLayerId()))->getPicWidthVpsInLumaSamples() <= vps->getVpsRepFormat( vps->getVpsRepFormatIdx(rpcSlice->getLayerId()))->getPicWidthVpsInLumaSamples());
     2985    assert(vps->getVpsRepFormat( vps->getVpsRepFormatIdx(sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : rpcSlice->getLayerId()))->getPicHeightVpsInLumaSamples() <= vps->getVpsRepFormat( vps->getVpsRepFormatIdx(rpcSlice->getLayerId()))->getPicHeightVpsInLumaSamples());
     2986    assert(vps->getVpsRepFormat( vps->getVpsRepFormatIdx(sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : rpcSlice->getLayerId()))->getChromaFormatVpsIdc() <= vps->getVpsRepFormat( vps->getVpsRepFormatIdx(rpcSlice->getLayerId()))->getChromaFormatVpsIdc());
     2987    assert(vps->getVpsRepFormat( vps->getVpsRepFormatIdx(sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : rpcSlice->getLayerId()))->getBitDepthVpsLuma() <= vps->getVpsRepFormat( vps->getVpsRepFormatIdx(rpcSlice->getLayerId()))->getBitDepthVpsLuma());
     2988    assert(vps->getVpsRepFormat( vps->getVpsRepFormatIdx(sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : rpcSlice->getLayerId()))->getBitDepthVpsChroma() <= vps->getVpsRepFormat( vps->getVpsRepFormatIdx(rpcSlice->getLayerId()))->getBitDepthVpsChroma());
     2989  }
     2990#endif
     2991
    24782992  if( pps->getDependentSliceSegmentsEnabledFlag() && ( !firstSliceSegmentInPic ))
    24792993  {
     
    25223036#if Q0142_POC_LSB_NOT_PRESENT
    25233037#if SHM_FIX7
    2524     Int iPOClsb = 0;
     3038  Int iPOClsb = 0;
    25253039#endif
    25263040#endif
     
    25573071    }
    25583072#else
     3073#if CROSS_LAYER_BLA_FLAG_FIX
     3074    Int iBits = 0;
     3075    if(rpcSlice->getPPS()->getNumExtraSliceHeaderBits() > iBits)
     3076#else
    25593077    if(rpcSlice->getPPS()->getNumExtraSliceHeaderBits()>0)
     3078#endif
    25603079    {
    25613080      READ_FLAG(uiCode, "discardable_flag"); // ignored
    2562     }
     3081#if NON_REF_NAL_TYPE_DISCARDABLE
     3082      rpcSlice->setDiscardableFlag( uiCode ? true : false );
     3083      if (uiCode)
     3084      {
     3085        assert(rpcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_TRAIL_R &&
     3086          rpcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_TSA_R &&
     3087          rpcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_STSA_R &&
     3088          rpcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_RADL_R &&
     3089          rpcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_RASL_R);
     3090      }
     3091#endif
     3092#if CROSS_LAYER_BLA_FLAG_FIX
     3093      iBits++;
     3094#endif
     3095    }
     3096#if CROSS_LAYER_BLA_FLAG_FIX
     3097    if(rpcSlice->getPPS()->getNumExtraSliceHeaderBits() > iBits)
     3098    {
     3099      READ_FLAG(uiCode, "cross_layer_bla_flag");  rpcSlice->setCrossLayerBLAFlag( uiCode ? true : false );
     3100      iBits++;
     3101    }
     3102    for ( ; iBits < rpcSlice->getPPS()->getNumExtraSliceHeaderBits(); iBits++)
     3103#else
    25633104    for (Int i = 1; i < rpcSlice->getPPS()->getNumExtraSliceHeaderBits(); i++)
     3105#endif
    25643106    {
    25653107      READ_FLAG(uiCode, "slice_reserved_undetermined_flag[]"); // ignored
     
    26493191#if N0065_LAYER_POC_ALIGNMENT
    26503192#if SHM_FIX7
    2651       }
     3193    }
    26523194#endif
    26533195#if POC_RESET_IDC_DECODER
    2654     else
    2655     {
    2656       rpcSlice->setPicOrderCntLsb( 0 );
    2657     }
    2658 #endif
    2659       if( !rpcSlice->getIdrPicFlag() )
    2660       {
    2661 #endif
    2662       TComReferencePictureSet* rps;
    2663       rps = rpcSlice->getLocalRPS();
    2664       rpcSlice->setRPS(rps);
    2665       READ_FLAG( uiCode, "short_term_ref_pic_set_sps_flag" );
    2666       if(uiCode == 0) // use short-term reference picture set explicitly signalled in slice header
    2667       {
    2668         parseShortTermRefPicSet(sps,rps, sps->getRPSList()->getNumberOfReferencePictureSets());
    2669       }
    2670       else // use reference to short-term reference picture set in PPS
    2671       {
    2672         Int numBits = 0;
    2673         while ((1 << numBits) < rpcSlice->getSPS()->getRPSList()->getNumberOfReferencePictureSets())
    2674         {
    2675           numBits++;
    2676         }
    2677         if (numBits > 0)
    2678         {
    2679           READ_CODE( numBits, uiCode, "short_term_ref_pic_set_idx");
     3196  else
     3197  {
     3198    rpcSlice->setPicOrderCntLsb( 0 );
     3199  }
     3200#endif
     3201  if( !rpcSlice->getIdrPicFlag() )
     3202  {
     3203#endif
     3204    TComReferencePictureSet* rps;
     3205    rps = rpcSlice->getLocalRPS();
     3206    rpcSlice->setRPS(rps);
     3207    READ_FLAG( uiCode, "short_term_ref_pic_set_sps_flag" );
     3208    if(uiCode == 0) // use short-term reference picture set explicitly signalled in slice header
     3209    {
     3210      parseShortTermRefPicSet(sps,rps, sps->getRPSList()->getNumberOfReferencePictureSets());
     3211    }
     3212    else // use reference to short-term reference picture set in PPS
     3213    {
     3214      Int numBits = 0;
     3215      while ((1 << numBits) < rpcSlice->getSPS()->getRPSList()->getNumberOfReferencePictureSets())
     3216      {
     3217        numBits++;
     3218      }
     3219      if (numBits > 0)
     3220      {
     3221        READ_CODE( numBits, uiCode, "short_term_ref_pic_set_idx");
     3222      }
     3223      else
     3224      {
     3225        uiCode = 0;       
     3226      }
     3227      *rps = *(sps->getRPSList()->getReferencePictureSet(uiCode));
     3228    }
     3229    if(sps->getLongTermRefsPresent())
     3230    {
     3231      Int offset = rps->getNumberOfNegativePictures()+rps->getNumberOfPositivePictures();
     3232      UInt numOfLtrp = 0;
     3233      UInt numLtrpInSPS = 0;
     3234      if (rpcSlice->getSPS()->getNumLongTermRefPicSPS() > 0)
     3235      {
     3236        READ_UVLC( uiCode, "num_long_term_sps");
     3237        numLtrpInSPS = uiCode;
     3238        numOfLtrp += numLtrpInSPS;
     3239        rps->setNumberOfLongtermPictures(numOfLtrp);
     3240      }
     3241      Int bitsForLtrpInSPS = 0;
     3242      while (rpcSlice->getSPS()->getNumLongTermRefPicSPS() > (1 << bitsForLtrpInSPS))
     3243      {
     3244        bitsForLtrpInSPS++;
     3245      }
     3246      READ_UVLC( uiCode, "num_long_term_pics");             rps->setNumberOfLongtermPictures(uiCode);
     3247      numOfLtrp += uiCode;
     3248      rps->setNumberOfLongtermPictures(numOfLtrp);
     3249      Int maxPicOrderCntLSB = 1 << rpcSlice->getSPS()->getBitsForPOC();
     3250      Int prevDeltaMSB = 0, deltaPocMSBCycleLT = 0;;
     3251      for(Int j=offset+rps->getNumberOfLongtermPictures()-1, k = 0; k < numOfLtrp; j--, k++)
     3252      {
     3253        Int pocLsbLt;
     3254        if (k < numLtrpInSPS)
     3255        {
     3256          uiCode = 0;
     3257          if (bitsForLtrpInSPS > 0)
     3258          {
     3259            READ_CODE(bitsForLtrpInSPS, uiCode, "lt_idx_sps[i]");
     3260          }
     3261          Int usedByCurrFromSPS=rpcSlice->getSPS()->getUsedByCurrPicLtSPSFlag(uiCode);
     3262
     3263          pocLsbLt = rpcSlice->getSPS()->getLtRefPicPocLsbSps(uiCode);
     3264          rps->setUsed(j,usedByCurrFromSPS);
    26803265        }
    26813266        else
    26823267        {
    2683           uiCode = 0;       
    2684         }
    2685         *rps = *(sps->getRPSList()->getReferencePictureSet(uiCode));
    2686       }
    2687       if(sps->getLongTermRefsPresent())
    2688       {
    2689         Int offset = rps->getNumberOfNegativePictures()+rps->getNumberOfPositivePictures();
    2690         UInt numOfLtrp = 0;
    2691         UInt numLtrpInSPS = 0;
    2692         if (rpcSlice->getSPS()->getNumLongTermRefPicSPS() > 0)
    2693         {
    2694           READ_UVLC( uiCode, "num_long_term_sps");
    2695           numLtrpInSPS = uiCode;
    2696           numOfLtrp += numLtrpInSPS;
    2697           rps->setNumberOfLongtermPictures(numOfLtrp);
    2698         }
    2699         Int bitsForLtrpInSPS = 0;
    2700         while (rpcSlice->getSPS()->getNumLongTermRefPicSPS() > (1 << bitsForLtrpInSPS))
    2701         {
    2702           bitsForLtrpInSPS++;
    2703         }
    2704         READ_UVLC( uiCode, "num_long_term_pics");             rps->setNumberOfLongtermPictures(uiCode);
    2705         numOfLtrp += uiCode;
    2706         rps->setNumberOfLongtermPictures(numOfLtrp);
    2707         Int maxPicOrderCntLSB = 1 << rpcSlice->getSPS()->getBitsForPOC();
    2708         Int prevDeltaMSB = 0, deltaPocMSBCycleLT = 0;;
    2709         for(Int j=offset+rps->getNumberOfLongtermPictures()-1, k = 0; k < numOfLtrp; j--, k++)
    2710         {
    2711           Int pocLsbLt;
    2712           if (k < numLtrpInSPS)
     3268          READ_CODE(rpcSlice->getSPS()->getBitsForPOC(), uiCode, "poc_lsb_lt"); pocLsbLt= uiCode;
     3269          READ_FLAG( uiCode, "used_by_curr_pic_lt_flag");     rps->setUsed(j,uiCode);
     3270        }
     3271        READ_FLAG(uiCode,"delta_poc_msb_present_flag");
     3272        Bool mSBPresentFlag = uiCode ? true : false;
     3273        if(mSBPresentFlag)
     3274        {
     3275          READ_UVLC( uiCode, "delta_poc_msb_cycle_lt[i]" );
     3276          Bool deltaFlag = false;
     3277          //            First LTRP                               || First LTRP from SH
     3278          if( (j == offset+rps->getNumberOfLongtermPictures()-1) || (j == offset+(numOfLtrp-numLtrpInSPS)-1) )
    27133279          {
    2714             uiCode = 0;
    2715             if (bitsForLtrpInSPS > 0)
    2716             {
    2717               READ_CODE(bitsForLtrpInSPS, uiCode, "lt_idx_sps[i]");
    2718             }
    2719             Int usedByCurrFromSPS=rpcSlice->getSPS()->getUsedByCurrPicLtSPSFlag(uiCode);
    2720 
    2721             pocLsbLt = rpcSlice->getSPS()->getLtRefPicPocLsbSps(uiCode);
    2722             rps->setUsed(j,usedByCurrFromSPS);
     3280            deltaFlag = true;
     3281          }
     3282          if(deltaFlag)
     3283          {
     3284            deltaPocMSBCycleLT = uiCode;
    27233285          }
    27243286          else
    27253287          {
    2726             READ_CODE(rpcSlice->getSPS()->getBitsForPOC(), uiCode, "poc_lsb_lt"); pocLsbLt= uiCode;
    2727             READ_FLAG( uiCode, "used_by_curr_pic_lt_flag");     rps->setUsed(j,uiCode);
     3288            deltaPocMSBCycleLT = uiCode + prevDeltaMSB;
    27283289          }
    2729           READ_FLAG(uiCode,"delta_poc_msb_present_flag");
    2730           Bool mSBPresentFlag = uiCode ? true : false;
    2731           if(mSBPresentFlag)
     3290
     3291          Int pocLTCurr = rpcSlice->getPOC() - deltaPocMSBCycleLT * maxPicOrderCntLSB
     3292            - iPOClsb + pocLsbLt;
     3293          rps->setPOC     (j, pocLTCurr);
     3294          rps->setDeltaPOC(j, - rpcSlice->getPOC() + pocLTCurr);
     3295          rps->setCheckLTMSBPresent(j,true);
     3296        }
     3297        else
     3298        {
     3299          rps->setPOC     (j, pocLsbLt);
     3300          rps->setDeltaPOC(j, - rpcSlice->getPOC() + pocLsbLt);
     3301          rps->setCheckLTMSBPresent(j,false);
     3302
     3303          // reset deltaPocMSBCycleLT for first LTRP from slice header if MSB not present
     3304          if( j == offset+(numOfLtrp-numLtrpInSPS)-1 )
    27323305          {
    2733             READ_UVLC( uiCode, "delta_poc_msb_cycle_lt[i]" );
    2734             Bool deltaFlag = false;
    2735             //            First LTRP                               || First LTRP from SH
    2736             if( (j == offset+rps->getNumberOfLongtermPictures()-1) || (j == offset+(numOfLtrp-numLtrpInSPS)-1) )
    2737             {
    2738               deltaFlag = true;
    2739             }
    2740             if(deltaFlag)
    2741             {
    2742               deltaPocMSBCycleLT = uiCode;
    2743             }
    2744             else
    2745             {
    2746               deltaPocMSBCycleLT = uiCode + prevDeltaMSB;
    2747             }
    2748 
    2749             Int pocLTCurr = rpcSlice->getPOC() - deltaPocMSBCycleLT * maxPicOrderCntLSB
    2750                                         - iPOClsb + pocLsbLt;
    2751             rps->setPOC     (j, pocLTCurr);
    2752             rps->setDeltaPOC(j, - rpcSlice->getPOC() + pocLTCurr);
    2753             rps->setCheckLTMSBPresent(j,true);
     3306            deltaPocMSBCycleLT = 0;
    27543307          }
    2755           else
     3308        }
     3309        prevDeltaMSB = deltaPocMSBCycleLT;
     3310      }
     3311      offset += rps->getNumberOfLongtermPictures();
     3312      rps->setNumberOfPictures(offset);
     3313    }
     3314#if DPB_CONSTRAINTS
     3315    if(rpcSlice->getVPS()->getVpsExtensionFlag()==1)
     3316    {
     3317#if Q0078_ADD_LAYER_SETS
     3318      for (Int ii = 1; ii < (rpcSlice->getVPS()->getVpsNumLayerSetsMinus1() + 1); ii++)  // prevent assert error when num_add_layer_sets > 0
     3319#else
     3320      for (Int ii=1; ii< rpcSlice->getVPS()->getNumOutputLayerSets(); ii++ )
     3321#endif
     3322      {
     3323        Int layerSetIdxForOutputLayerSet = rpcSlice->getVPS()->getOutputLayerSetIdx( ii );
     3324        Int chkAssert=0;
     3325        for(Int kk = 0; kk < rpcSlice->getVPS()->getNumLayersInIdList(layerSetIdxForOutputLayerSet); kk++)
     3326        {
     3327          if(rpcSlice->getLayerId()==rpcSlice->getVPS()->getLayerSetLayerIdList(layerSetIdxForOutputLayerSet, kk))
    27563328          {
    2757             rps->setPOC     (j, pocLsbLt);
    2758             rps->setDeltaPOC(j, - rpcSlice->getPOC() + pocLsbLt);
    2759             rps->setCheckLTMSBPresent(j,false);
    2760 
    2761             // reset deltaPocMSBCycleLT for first LTRP from slice header if MSB not present
    2762             if( j == offset+(numOfLtrp-numLtrpInSPS)-1 )
    2763             {
    2764               deltaPocMSBCycleLT = 0;
     3329            chkAssert=1;
     3330          }
     3331        }
     3332        if(chkAssert)
     3333        {
     3334          // There may be something wrong here (layer id assumed to be layer idx?)
     3335          assert(rps->getNumberOfNegativePictures() <= rpcSlice->getVPS()->getMaxVpsDecPicBufferingMinus1(ii , rpcSlice->getLayerId() , rpcSlice->getVPS()->getMaxSLayersInLayerSetMinus1(ii)));
     3336          assert(rps->getNumberOfPositivePictures() <= rpcSlice->getVPS()->getMaxVpsDecPicBufferingMinus1(ii , rpcSlice->getLayerId() , rpcSlice->getVPS()->getMaxSLayersInLayerSetMinus1(ii)) - rps->getNumberOfNegativePictures());
     3337          assert((rps->getNumberOfPositivePictures() + rps->getNumberOfNegativePictures() + rps->getNumberOfLongtermPictures()) <= rpcSlice->getVPS()->getMaxVpsDecPicBufferingMinus1(ii , rpcSlice->getLayerId() , rpcSlice->getVPS()->getMaxSLayersInLayerSetMinus1(ii)));
     3338        }
     3339      }
     3340
     3341
     3342    }
     3343    if(rpcSlice->getLayerId() == 0)
     3344    {
     3345      assert(rps->getNumberOfNegativePictures() <= rpcSlice->getSPS()->getMaxDecPicBuffering(rpcSlice->getSPS()->getMaxTLayers()-1) );
     3346      assert(rps->getNumberOfPositivePictures() <= rpcSlice->getSPS()->getMaxDecPicBuffering(rpcSlice->getSPS()->getMaxTLayers()-1) -rps->getNumberOfNegativePictures());
     3347      assert((rps->getNumberOfPositivePictures() + rps->getNumberOfNegativePictures() + rps->getNumberOfLongtermPictures()) <= rpcSlice->getSPS()->getMaxDecPicBuffering(rpcSlice->getSPS()->getMaxTLayers()-1));
     3348    }
     3349#endif
     3350    if ( rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP
     3351      || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL
     3352      || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP )
     3353    {
     3354      // In the case of BLA picture types, rps data is read from slice header but ignored
     3355      rps = rpcSlice->getLocalRPS();
     3356      rps->setNumberOfNegativePictures(0);
     3357      rps->setNumberOfPositivePictures(0);
     3358      rps->setNumberOfLongtermPictures(0);
     3359      rps->setNumberOfPictures(0);
     3360      rpcSlice->setRPS(rps);
     3361    }
     3362    if (rpcSlice->getSPS()->getTMVPFlagsPresent())
     3363    {
     3364#if R0226_SLICE_TMVP
     3365      READ_FLAG( uiCode, "slice_temporal_mvp_enabled_flag" );
     3366#else
     3367      READ_FLAG( uiCode, "slice_temporal_mvp_enable_flag" );
     3368#endif
     3369      rpcSlice->setEnableTMVPFlag( uiCode == 1 ? true : false );
     3370    }
     3371    else
     3372    {
     3373      rpcSlice->setEnableTMVPFlag(false);
     3374    }
     3375#if N0065_LAYER_POC_ALIGNMENT && !SHM_FIX7
     3376  }
     3377#endif
     3378  }
     3379
     3380#if SVC_EXTENSION
     3381  rpcSlice->setActiveNumILRRefIdx(0);
     3382  if((rpcSlice->getLayerId() > 0) && !(rpcSlice->getVPS()->getIlpSshSignalingEnabledFlag()) && (rpcSlice->getNumILRRefIdx() > 0) )
     3383  {
     3384    READ_FLAG(uiCode,"inter_layer_pred_enabled_flag");
     3385    rpcSlice->setInterLayerPredEnabledFlag(uiCode);
     3386    if( rpcSlice->getInterLayerPredEnabledFlag())
     3387    {
     3388      if(rpcSlice->getNumILRRefIdx() > 1)
     3389      {
     3390        Int numBits = 1;
     3391        while ((1 << numBits) < rpcSlice->getNumILRRefIdx())
     3392        {
     3393          numBits++;
     3394        }
     3395        if( !rpcSlice->getVPS()->getMaxOneActiveRefLayerFlag())
     3396        {
     3397          READ_CODE( numBits, uiCode,"num_inter_layer_ref_pics_minus1" );
     3398          rpcSlice->setActiveNumILRRefIdx(uiCode + 1);
     3399        }
     3400        else
     3401        {
     3402#if P0079_DERIVE_NUMACTIVE_REF_PICS
     3403          for( Int i = 0; i < rpcSlice->getNumILRRefIdx(); i++ )
     3404          {
     3405#if Q0060_MAX_TID_REF_EQUAL_TO_ZERO
     3406            if((rpcSlice->getVPS()->getMaxTidIlRefPicsPlus1(rpcSlice->getVPS()->getLayerIdInVps(i),rpcSlice->getLayerId()) >  rpcSlice->getTLayer() || rpcSlice->getTLayer()==0) &&
     3407              (rpcSlice->getVPS()->getMaxTSLayersMinus1(rpcSlice->getVPS()->getLayerIdInVps(i)) >=  rpcSlice->getTLayer()) )
     3408#else
     3409            if(rpcSlice->getVPS()->getMaxTidIlRefPicsPlus1(rpcSlice->getVPS()->getLayerIdInVps(i),rpcSlice->getLayerId()) >  rpcSlice->getTLayer() &&
     3410              (rpcSlice->getVPS()->getMaxTSLayersMinus1(rpcSlice->getVPS()->getLayerIdInVps(i)) >=  rpcSlice->getTLayer()) )
     3411#endif
     3412            {         
     3413              rpcSlice->setActiveNumILRRefIdx(1);
     3414              break;
    27653415            }
    27663416          }
    2767           prevDeltaMSB = deltaPocMSBCycleLT;
    2768         }
    2769         offset += rps->getNumberOfLongtermPictures();
    2770         rps->setNumberOfPictures(offset);
    2771       }
    2772 #if DPB_CONSTRAINTS
    2773           if(rpcSlice->getVPS()->getVpsExtensionFlag()==1)
     3417#else
     3418          rpcSlice->setActiveNumILRRefIdx(1);
     3419#endif
     3420        }
     3421
     3422        if( rpcSlice->getActiveNumILRRefIdx() == rpcSlice->getNumILRRefIdx() )
     3423        {
     3424          for( Int i = 0; i < rpcSlice->getActiveNumILRRefIdx(); i++ )
    27743425          {
    2775 #if Q0078_ADD_LAYER_SETS
    2776               for (Int ii = 1; ii < (rpcSlice->getVPS()->getVpsNumLayerSetsMinus1() + 1); ii++)  // prevent assert error when num_add_layer_sets > 0
    2777 #else
    2778               for (Int ii=1; ii< rpcSlice->getVPS()->getNumOutputLayerSets(); ii++ )
    2779 #endif
    2780               {
    2781                   Int layerSetIdxForOutputLayerSet = rpcSlice->getVPS()->getOutputLayerSetIdx( ii );
    2782                   Int chkAssert=0;
    2783                   for(Int kk = 0; kk < rpcSlice->getVPS()->getNumLayersInIdList(layerSetIdxForOutputLayerSet); kk++)
    2784                   {
    2785                       if(rpcSlice->getLayerId()==rpcSlice->getVPS()->getLayerSetLayerIdList(layerSetIdxForOutputLayerSet, kk))
    2786                       {
    2787                           chkAssert=1;
    2788                       }
    2789                   }
    2790                   if(chkAssert)
    2791                   {
    2792                       // There may be something wrong here (layer id assumed to be layer idx?)
    2793                       assert(rps->getNumberOfNegativePictures() <= rpcSlice->getVPS()->getMaxVpsDecPicBufferingMinus1(ii , rpcSlice->getLayerId() , rpcSlice->getVPS()->getMaxSLayersInLayerSetMinus1(ii)));
    2794                       assert(rps->getNumberOfPositivePictures() <= rpcSlice->getVPS()->getMaxVpsDecPicBufferingMinus1(ii , rpcSlice->getLayerId() , rpcSlice->getVPS()->getMaxSLayersInLayerSetMinus1(ii)) - rps->getNumberOfNegativePictures());
    2795                       assert((rps->getNumberOfPositivePictures() + rps->getNumberOfNegativePictures() + rps->getNumberOfLongtermPictures()) <= rpcSlice->getVPS()->getMaxVpsDecPicBufferingMinus1(ii , rpcSlice->getLayerId() , rpcSlice->getVPS()->getMaxSLayersInLayerSetMinus1(ii)));
    2796                   }
    2797               }
    2798              
    2799              
     3426            rpcSlice->setInterLayerPredLayerIdc(i,i);
    28003427          }
    2801           if(rpcSlice->getLayerId() == 0)
     3428        }
     3429        else
     3430        {
     3431          for(Int i = 0; i < rpcSlice->getActiveNumILRRefIdx(); i++ )
    28023432          {
    2803               assert(rps->getNumberOfNegativePictures() <= rpcSlice->getSPS()->getMaxDecPicBuffering(rpcSlice->getSPS()->getMaxTLayers()-1) );
    2804               assert(rps->getNumberOfPositivePictures() <= rpcSlice->getSPS()->getMaxDecPicBuffering(rpcSlice->getSPS()->getMaxTLayers()-1) -rps->getNumberOfNegativePictures());
    2805               assert((rps->getNumberOfPositivePictures() + rps->getNumberOfNegativePictures() + rps->getNumberOfLongtermPictures()) <= rpcSlice->getSPS()->getMaxDecPicBuffering(rpcSlice->getSPS()->getMaxTLayers()-1));
     3433            READ_CODE( numBits,uiCode,"inter_layer_pred_layer_idc[i]" );
     3434            rpcSlice->setInterLayerPredLayerIdc(uiCode,i);
    28063435          }
    2807 #endif
    2808       if ( rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP
    2809         || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL
    2810         || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP )
    2811       {
    2812         // In the case of BLA picture types, rps data is read from slice header but ignored
    2813         rps = rpcSlice->getLocalRPS();
    2814         rps->setNumberOfNegativePictures(0);
    2815         rps->setNumberOfPositivePictures(0);
    2816         rps->setNumberOfLongtermPictures(0);
    2817         rps->setNumberOfPictures(0);
    2818         rpcSlice->setRPS(rps);
    2819       }
    2820       if (rpcSlice->getSPS()->getTMVPFlagsPresent())
    2821       {
    2822         READ_FLAG( uiCode, "slice_temporal_mvp_enable_flag" );
    2823         rpcSlice->setEnableTMVPFlag( uiCode == 1 ? true : false );
     3436        }
    28243437      }
    28253438      else
    28263439      {
    2827         rpcSlice->setEnableTMVPFlag(false);
    2828       }
    2829 #if N0065_LAYER_POC_ALIGNMENT && !SHM_FIX7
    2830     }
    2831 #endif
    2832     }
    2833 
    2834 #if SVC_EXTENSION
    2835     rpcSlice->setActiveNumILRRefIdx(0);
    2836     if((rpcSlice->getLayerId() > 0) && !(rpcSlice->getVPS()->getIlpSshSignalingEnabledFlag()) && (rpcSlice->getNumILRRefIdx() > 0) )
    2837     {
    2838       READ_FLAG(uiCode,"inter_layer_pred_enabled_flag");
    2839       rpcSlice->setInterLayerPredEnabledFlag(uiCode);
    2840       if( rpcSlice->getInterLayerPredEnabledFlag())
    2841       {
    2842         if(rpcSlice->getNumILRRefIdx() > 1)
    2843         {
    2844           Int numBits = 1;
    2845           while ((1 << numBits) < rpcSlice->getNumILRRefIdx())
    2846           {
    2847             numBits++;
    2848           }
    2849           if( !rpcSlice->getVPS()->getMaxOneActiveRefLayerFlag())
    2850           {
    2851             READ_CODE( numBits, uiCode,"num_inter_layer_ref_pics_minus1" );
    2852             rpcSlice->setActiveNumILRRefIdx(uiCode + 1);
    2853           }
    2854           else
    2855           {
    2856 #if P0079_DERIVE_NUMACTIVE_REF_PICS
    2857             for( Int i = 0; i < rpcSlice->getNumILRRefIdx(); i++ )
    2858             {
    2859 #if Q0060_MAX_TID_REF_EQUAL_TO_ZERO
    2860               if((rpcSlice->getVPS()->getMaxTidIlRefPicsPlus1(rpcSlice->getVPS()->getLayerIdInVps(i),rpcSlice->getLayerId()) >  rpcSlice->getTLayer() || rpcSlice->getTLayer()==0) &&
    2861                 (rpcSlice->getVPS()->getMaxTSLayersMinus1(rpcSlice->getVPS()->getLayerIdInVps(i)) >=  rpcSlice->getTLayer()) )
    2862 #else
    2863               if(rpcSlice->getVPS()->getMaxTidIlRefPicsPlus1(rpcSlice->getVPS()->getLayerIdInVps(i),rpcSlice->getLayerId()) >  rpcSlice->getTLayer() &&
    2864                 (rpcSlice->getVPS()->getMaxTSLayersMinus1(rpcSlice->getVPS()->getLayerIdInVps(i)) >=  rpcSlice->getTLayer()) )
    2865 #endif
    2866               {         
    2867                 rpcSlice->setActiveNumILRRefIdx(1);
    2868                 break;
    2869               }
    2870             }
    2871 #else
    2872             rpcSlice->setActiveNumILRRefIdx(1);
    2873 #endif
    2874           }
    2875 
    2876           if( rpcSlice->getActiveNumILRRefIdx() == rpcSlice->getNumILRRefIdx() )
    2877           {
    2878             for( Int i = 0; i < rpcSlice->getActiveNumILRRefIdx(); i++ )
    2879             {
    2880               rpcSlice->setInterLayerPredLayerIdc(i,i);
    2881             }
    2882           }
    2883           else
    2884           {
    2885             for(Int i = 0; i < rpcSlice->getActiveNumILRRefIdx(); i++ )
    2886             {
    2887               READ_CODE( numBits,uiCode,"inter_layer_pred_layer_idc[i]" );
    2888               rpcSlice->setInterLayerPredLayerIdc(uiCode,i);
    2889             }
    2890           }
    2891         }
    2892         else
    2893         {
    28943440#if O0225_TID_BASED_IL_RPS_DERIV && TSLAYERS_IL_RPS
    28953441#if Q0060_MAX_TID_REF_EQUAL_TO_ZERO
    2896           if((rpcSlice->getVPS()->getMaxTidIlRefPicsPlus1(0,rpcSlice->getLayerId()) >  rpcSlice->getTLayer() || rpcSlice->getTLayer()==0) &&
    2897             (rpcSlice->getVPS()->getMaxTSLayersMinus1(0) >=  rpcSlice->getTLayer()) )
    2898 #else
    2899           if( (rpcSlice->getVPS()->getMaxTidIlRefPicsPlus1(0,rpcSlice->getLayerId()) >  rpcSlice->getTLayer()) &&
    2900              (rpcSlice->getVPS()->getMaxTSLayersMinus1(0) >=  rpcSlice->getTLayer()) )
     3442        if((rpcSlice->getVPS()->getMaxTidIlRefPicsPlus1(0,rpcSlice->getLayerId()) >  rpcSlice->getTLayer() || rpcSlice->getTLayer()==0) &&
     3443          (rpcSlice->getVPS()->getMaxTSLayersMinus1(0) >=  rpcSlice->getTLayer()) )
     3444#else
     3445        if( (rpcSlice->getVPS()->getMaxTidIlRefPicsPlus1(0,rpcSlice->getLayerId()) >  rpcSlice->getTLayer()) &&
     3446          (rpcSlice->getVPS()->getMaxTSLayersMinus1(0) >=  rpcSlice->getTLayer()) )
    29013447#endif
    29023448        {
     
    29073453        }
    29083454#endif
    2909         }
    2910       }
    2911     }
    2912     else if( rpcSlice->getVPS()->getIlpSshSignalingEnabledFlag() == true &&  (rpcSlice->getLayerId() > 0 ))
    2913     {
    2914       rpcSlice->setInterLayerPredEnabledFlag(true);
     3455      }
     3456    }
     3457  }
     3458  else if( rpcSlice->getVPS()->getIlpSshSignalingEnabledFlag() == true &&  (rpcSlice->getLayerId() > 0 ))
     3459  {
     3460    rpcSlice->setInterLayerPredEnabledFlag(true);
    29153461
    29163462#if O0225_TID_BASED_IL_RPS_DERIV && TSLAYERS_IL_RPS
    2917       Int   numRefLayerPics = 0;
    2918       Int   i = 0;
    2919       Int   refLayerPicIdc  [MAX_VPS_LAYER_ID_PLUS1];
    2920       for(i = 0, numRefLayerPics = 0;  i < rpcSlice->getNumILRRefIdx(); i++ )
    2921       {
     3463    Int   numRefLayerPics = 0;
     3464    Int   i = 0;
     3465    Int   refLayerPicIdc  [MAX_VPS_LAYER_ID_PLUS1];
     3466    for(i = 0, numRefLayerPics = 0;  i < rpcSlice->getNumILRRefIdx(); i++ )
     3467    {
    29223468#if Q0060_MAX_TID_REF_EQUAL_TO_ZERO
    2923         if((rpcSlice->getVPS()->getMaxTidIlRefPicsPlus1(rpcSlice->getVPS()->getLayerIdInVps(i),rpcSlice->getLayerId()) >  rpcSlice->getTLayer() || rpcSlice->getTLayer()==0) &&
    2924           (rpcSlice->getVPS()->getMaxTSLayersMinus1(rpcSlice->getVPS()->getLayerIdInVps(i)) >=  rpcSlice->getTLayer()) )
     3469      if((rpcSlice->getVPS()->getMaxTidIlRefPicsPlus1(rpcSlice->getVPS()->getLayerIdInVps(i),rpcSlice->getLayerId()) >  rpcSlice->getTLayer() || rpcSlice->getTLayer()==0) &&
     3470        (rpcSlice->getVPS()->getMaxTSLayersMinus1(rpcSlice->getVPS()->getLayerIdInVps(i)) >=  rpcSlice->getTLayer()) )
    29253471#else
    2926         if(rpcSlice->getVPS()->getMaxTidIlRefPicsPlus1(rpcSlice->getVPS()->getLayerIdInVps(i),rpcSlice->getLayerId()) >  rpcSlice->getTLayer() &&
    2927            (rpcSlice->getVPS()->getMaxTSLayersMinus1(rpcSlice->getVPS()->getLayerIdInVps(i)) >=  rpcSlice->getTLayer()) )
     3472      if(rpcSlice->getVPS()->getMaxTidIlRefPicsPlus1(rpcSlice->getVPS()->getLayerIdInVps(i),rpcSlice->getLayerId()) >  rpcSlice->getTLayer() &&
     3473        (rpcSlice->getVPS()->getMaxTSLayersMinus1(rpcSlice->getVPS()->getLayerIdInVps(i)) >=  rpcSlice->getTLayer()) )
    29283474#endif
    2929         {         
    2930           refLayerPicIdc[ numRefLayerPics++ ] = i;
    2931         }
    2932       }
    2933       rpcSlice->setActiveNumILRRefIdx(numRefLayerPics);
    2934       for( i = 0; i < rpcSlice->getActiveNumILRRefIdx(); i++ )
    2935       {
    2936         rpcSlice->setInterLayerPredLayerIdc(refLayerPicIdc[i],i);
    2937       }     
    2938 #else
    2939       rpcSlice->setActiveNumILRRefIdx(rpcSlice->getNumILRRefIdx());
    2940       for( Int i = 0; i < rpcSlice->getActiveNumILRRefIdx(); i++ )
    2941       {
    2942         rpcSlice->setInterLayerPredLayerIdc(i,i);
    2943       }
     3475      {         
     3476        refLayerPicIdc[ numRefLayerPics++ ] = i;
     3477      }
     3478    }
     3479    rpcSlice->setActiveNumILRRefIdx(numRefLayerPics);
     3480    for( i = 0; i < rpcSlice->getActiveNumILRRefIdx(); i++ )
     3481    {
     3482      rpcSlice->setInterLayerPredLayerIdc(refLayerPicIdc[i],i);
     3483    }     
     3484#else
     3485    rpcSlice->setActiveNumILRRefIdx(rpcSlice->getNumILRRefIdx());
     3486    for( Int i = 0; i < rpcSlice->getActiveNumILRRefIdx(); i++ )
     3487    {
     3488      rpcSlice->setInterLayerPredLayerIdc(i,i);
     3489    }
    29443490#endif
    2945     }
     3491  }
    29463492#if P0312_VERT_PHASE_ADJ
    29473493    for(Int i = 0; i < rpcSlice->getActiveNumILRRefIdx(); i++ )
    29483494    {
    29493495      UInt refLayerIdc = rpcSlice->getInterLayerPredLayerIdc(i);
     3496#if !MOVE_SCALED_OFFSET_TO_PPS
    29503497      if( rpcSlice->getSPS()->getVertPhasePositionEnableFlag(refLayerIdc) )
     3498#else
     3499      if( rpcSlice->getPPS()->getVertPhasePositionEnableFlag(refLayerIdc) )
     3500#endif
    29513501      {
    29523502        READ_FLAG( uiCode, "vert_phase_position_flag" ); rpcSlice->setVertPhasePositionFlag( uiCode? true : false, refLayerIdc );
    29533503      }
    2954     }
     3504  }
    29553505#endif
    29563506#endif //SVC_EXTENSION
    29573507
    2958     if(sps->getUseSAO())
    2959     {
    2960       READ_FLAG(uiCode, "slice_sao_luma_flag");  rpcSlice->setSaoEnabledFlag((Bool)uiCode);
     3508  if(sps->getUseSAO())
     3509  {
     3510    READ_FLAG(uiCode, "slice_sao_luma_flag");  rpcSlice->setSaoEnabledFlag((Bool)uiCode);
    29613511#if AUXILIARY_PICTURES
    2962       ChromaFormat format;
     3512    ChromaFormat format;
    29633513#if REPN_FORMAT_IN_VPS
    29643514#if O0096_REP_FORMAT_INDEX
    2965       if( sps->getLayerId() == 0 )
    2966       {
    2967         format = sps->getChromaFormatIdc();
    2968       }
    2969       else
    2970       {
    2971         format = rpcSlice->getVPS()->getVpsRepFormat( sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : rpcSlice->getVPS()->getVpsRepFormatIdx(sps->getLayerId()) )->getChromaFormatVpsIdc();
     3515    if( sps->getLayerId() == 0 )
     3516    {
     3517      format = sps->getChromaFormatIdc();
     3518    }
     3519    else
     3520    {
     3521      format = rpcSlice->getVPS()->getVpsRepFormat( sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : rpcSlice->getVPS()->getVpsRepFormatIdx(sps->getLayerId()) )->getChromaFormatVpsIdc();
    29723522#if Q0195_REP_FORMAT_CLEANUP
    2973          assert( (sps->getUpdateRepFormatFlag()==false && rpcSlice->getVPS()->getVpsNumRepFormats()==1) || rpcSlice->getVPS()->getVpsNumRepFormats() > 1 ); //conformance check
    2974 #endif
    2975       }
    2976 #else
    2977       if( ( sps->getLayerId() == 0 ) || sps->getUpdateRepFormatFlag() )
    2978       {
    2979         format = sps->getChromaFormatIdc();
    2980       }
    2981       else
    2982       {
    2983         format = rpcSlice->getVPS()->getVpsRepFormat( rpcSlice->getVPS()->getVpsRepFormatIdx(sps->getLayerId()) )->getChromaFormatVpsIdc();
    2984       }
    2985 #endif
    2986 #else
     3523      assert( (sps->getUpdateRepFormatFlag()==false && rpcSlice->getVPS()->getVpsNumRepFormats()==1) || rpcSlice->getVPS()->getVpsNumRepFormats() > 1 ); //conformance check
     3524#endif
     3525    }
     3526#else
     3527    if( ( sps->getLayerId() == 0 ) || sps->getUpdateRepFormatFlag() )
     3528    {
    29873529      format = sps->getChromaFormatIdc();
    2988 #endif
    2989       if (format != CHROMA_400)
    2990       {
     3530    }
     3531    else
     3532    {
     3533      format = rpcSlice->getVPS()->getVpsRepFormat( rpcSlice->getVPS()->getVpsRepFormatIdx(sps->getLayerId()) )->getChromaFormatVpsIdc();
     3534    }
     3535#endif
     3536#else
     3537    format = sps->getChromaFormatIdc();
     3538#endif
     3539    if (format != CHROMA_400)
     3540    {
    29913541#endif
    29923542      READ_FLAG(uiCode, "slice_sao_chroma_flag");  rpcSlice->setSaoEnabledFlagChroma((Bool)uiCode);
    29933543#if AUXILIARY_PICTURES
     3544    }
     3545    else
     3546    {
     3547      rpcSlice->setSaoEnabledFlagChroma(false);
     3548    }
     3549#endif
     3550  }
     3551
     3552  if (rpcSlice->getIdrPicFlag())
     3553  {
     3554    rpcSlice->setEnableTMVPFlag(false);
     3555  }
     3556  if (!rpcSlice->isIntra())
     3557  {
     3558
     3559    READ_FLAG( uiCode, "num_ref_idx_active_override_flag");
     3560    if (uiCode)
     3561    {
     3562      READ_UVLC (uiCode, "num_ref_idx_l0_active_minus1" );  rpcSlice->setNumRefIdx( REF_PIC_LIST_0, uiCode + 1 );
     3563      if (rpcSlice->isInterB())
     3564      {
     3565        READ_UVLC (uiCode, "num_ref_idx_l1_active_minus1" );  rpcSlice->setNumRefIdx( REF_PIC_LIST_1, uiCode + 1 );
    29943566      }
    29953567      else
    29963568      {
    2997         rpcSlice->setSaoEnabledFlagChroma(false);
    2998       }
    2999 #endif
    3000     }
    3001 
    3002     if (rpcSlice->getIdrPicFlag())
    3003     {
    3004       rpcSlice->setEnableTMVPFlag(false);
    3005     }
    3006     if (!rpcSlice->isIntra())
    3007     {
    3008 
    3009       READ_FLAG( uiCode, "num_ref_idx_active_override_flag");
    3010       if (uiCode)
    3011       {
    3012         READ_UVLC (uiCode, "num_ref_idx_l0_active_minus1" );  rpcSlice->setNumRefIdx( REF_PIC_LIST_0, uiCode + 1 );
    3013         if (rpcSlice->isInterB())
    3014         {
    3015           READ_UVLC (uiCode, "num_ref_idx_l1_active_minus1" );  rpcSlice->setNumRefIdx( REF_PIC_LIST_1, uiCode + 1 );
    3016         }
    3017         else
    3018         {
    3019           rpcSlice->setNumRefIdx(REF_PIC_LIST_1, 0);
    3020         }
     3569        rpcSlice->setNumRefIdx(REF_PIC_LIST_1, 0);
     3570      }
     3571    }
     3572    else
     3573    {
     3574      rpcSlice->setNumRefIdx(REF_PIC_LIST_0, rpcSlice->getPPS()->getNumRefIdxL0DefaultActive());
     3575      if (rpcSlice->isInterB())
     3576      {
     3577        rpcSlice->setNumRefIdx(REF_PIC_LIST_1, rpcSlice->getPPS()->getNumRefIdxL1DefaultActive());
    30213578      }
    30223579      else
    30233580      {
    3024         rpcSlice->setNumRefIdx(REF_PIC_LIST_0, rpcSlice->getPPS()->getNumRefIdxL0DefaultActive());
    3025         if (rpcSlice->isInterB())
    3026         {
    3027           rpcSlice->setNumRefIdx(REF_PIC_LIST_1, rpcSlice->getPPS()->getNumRefIdxL1DefaultActive());
    3028         }
    3029         else
    3030         {
    3031           rpcSlice->setNumRefIdx(REF_PIC_LIST_1,0);
    3032         }
    3033       }
    3034     }
    3035     // }
    3036     TComRefPicListModification* refPicListModification = rpcSlice->getRefPicListModification();
    3037     if(!rpcSlice->isIntra())
    3038     {
    3039       if( !rpcSlice->getPPS()->getListsModificationPresentFlag() || rpcSlice->getNumRpsCurrTempList() <= 1 )
    3040       {
    3041         refPicListModification->setRefPicListModificationFlagL0( 0 );
     3581        rpcSlice->setNumRefIdx(REF_PIC_LIST_1,0);
     3582      }
     3583    }
     3584  }
     3585  // }
     3586  TComRefPicListModification* refPicListModification = rpcSlice->getRefPicListModification();
     3587  if(!rpcSlice->isIntra())
     3588  {
     3589    if( !rpcSlice->getPPS()->getListsModificationPresentFlag() || rpcSlice->getNumRpsCurrTempList() <= 1 )
     3590    {
     3591      refPicListModification->setRefPicListModificationFlagL0( 0 );
     3592    }
     3593    else
     3594    {
     3595      READ_FLAG( uiCode, "ref_pic_list_modification_flag_l0" ); refPicListModification->setRefPicListModificationFlagL0( uiCode ? 1 : 0 );
     3596    }
     3597
     3598    if(refPicListModification->getRefPicListModificationFlagL0())
     3599    {
     3600      uiCode = 0;
     3601      Int i = 0;
     3602      Int numRpsCurrTempList0 = rpcSlice->getNumRpsCurrTempList();
     3603      if ( numRpsCurrTempList0 > 1 )
     3604      {
     3605        Int length = 1;
     3606        numRpsCurrTempList0 --;
     3607        while ( numRpsCurrTempList0 >>= 1)
     3608        {
     3609          length ++;
     3610        }
     3611        for (i = 0; i < rpcSlice->getNumRefIdx(REF_PIC_LIST_0); i ++)
     3612        {
     3613          READ_CODE( length, uiCode, "list_entry_l0" );
     3614          refPicListModification->setRefPicSetIdxL0(i, uiCode );
     3615        }
    30423616      }
    30433617      else
    30443618      {
    3045         READ_FLAG( uiCode, "ref_pic_list_modification_flag_l0" ); refPicListModification->setRefPicListModificationFlagL0( uiCode ? 1 : 0 );
    3046       }
    3047 
    3048       if(refPicListModification->getRefPicListModificationFlagL0())
    3049       {
    3050         uiCode = 0;
    3051         Int i = 0;
    3052         Int numRpsCurrTempList0 = rpcSlice->getNumRpsCurrTempList();
    3053         if ( numRpsCurrTempList0 > 1 )
    3054         {
    3055           Int length = 1;
    3056           numRpsCurrTempList0 --;
    3057           while ( numRpsCurrTempList0 >>= 1)
    3058           {
    3059             length ++;
    3060           }
    3061           for (i = 0; i < rpcSlice->getNumRefIdx(REF_PIC_LIST_0); i ++)
    3062           {
    3063             READ_CODE( length, uiCode, "list_entry_l0" );
    3064             refPicListModification->setRefPicSetIdxL0(i, uiCode );
    3065           }
    3066         }
    3067         else
    3068         {
    3069           for (i = 0; i < rpcSlice->getNumRefIdx(REF_PIC_LIST_0); i ++)
    3070           {
    3071             refPicListModification->setRefPicSetIdxL0(i, 0 );
    3072           }
    3073         }
    3074       }
     3619        for (i = 0; i < rpcSlice->getNumRefIdx(REF_PIC_LIST_0); i ++)
     3620        {
     3621          refPicListModification->setRefPicSetIdxL0(i, 0 );
     3622        }
     3623      }
     3624    }
     3625  }
     3626  else
     3627  {
     3628    refPicListModification->setRefPicListModificationFlagL0(0);
     3629  }
     3630  if(rpcSlice->isInterB())
     3631  {
     3632    if( !rpcSlice->getPPS()->getListsModificationPresentFlag() || rpcSlice->getNumRpsCurrTempList() <= 1 )
     3633    {
     3634      refPicListModification->setRefPicListModificationFlagL1( 0 );
    30753635    }
    30763636    else
    30773637    {
    3078       refPicListModification->setRefPicListModificationFlagL0(0);
    3079     }
    3080     if(rpcSlice->isInterB())
    3081     {
    3082       if( !rpcSlice->getPPS()->getListsModificationPresentFlag() || rpcSlice->getNumRpsCurrTempList() <= 1 )
    3083       {
    3084         refPicListModification->setRefPicListModificationFlagL1( 0 );
     3638      READ_FLAG( uiCode, "ref_pic_list_modification_flag_l1" ); refPicListModification->setRefPicListModificationFlagL1( uiCode ? 1 : 0 );
     3639    }
     3640    if(refPicListModification->getRefPicListModificationFlagL1())
     3641    {
     3642      uiCode = 0;
     3643      Int i = 0;
     3644      Int numRpsCurrTempList1 = rpcSlice->getNumRpsCurrTempList();
     3645      if ( numRpsCurrTempList1 > 1 )
     3646      {
     3647        Int length = 1;
     3648        numRpsCurrTempList1 --;
     3649        while ( numRpsCurrTempList1 >>= 1)
     3650        {
     3651          length ++;
     3652        }
     3653        for (i = 0; i < rpcSlice->getNumRefIdx(REF_PIC_LIST_1); i ++)
     3654        {
     3655          READ_CODE( length, uiCode, "list_entry_l1" );
     3656          refPicListModification->setRefPicSetIdxL1(i, uiCode );
     3657        }
    30853658      }
    30863659      else
    30873660      {
    3088         READ_FLAG( uiCode, "ref_pic_list_modification_flag_l1" ); refPicListModification->setRefPicListModificationFlagL1( uiCode ? 1 : 0 );
    3089       }
    3090       if(refPicListModification->getRefPicListModificationFlagL1())
    3091       {
    3092         uiCode = 0;
    3093         Int i = 0;
    3094         Int numRpsCurrTempList1 = rpcSlice->getNumRpsCurrTempList();
    3095         if ( numRpsCurrTempList1 > 1 )
    3096         {
    3097           Int length = 1;
    3098           numRpsCurrTempList1 --;
    3099           while ( numRpsCurrTempList1 >>= 1)
    3100           {
    3101             length ++;
    3102           }
    3103           for (i = 0; i < rpcSlice->getNumRefIdx(REF_PIC_LIST_1); i ++)
    3104           {
    3105             READ_CODE( length, uiCode, "list_entry_l1" );
    3106             refPicListModification->setRefPicSetIdxL1(i, uiCode );
    3107           }
    3108         }
    3109         else
    3110         {
    3111           for (i = 0; i < rpcSlice->getNumRefIdx(REF_PIC_LIST_1); i ++)
    3112           {
    3113             refPicListModification->setRefPicSetIdxL1(i, 0 );
    3114           }
    3115         }
    3116       }
     3661        for (i = 0; i < rpcSlice->getNumRefIdx(REF_PIC_LIST_1); i ++)
     3662        {
     3663          refPicListModification->setRefPicSetIdxL1(i, 0 );
     3664        }
     3665      }
     3666    }
     3667  }
     3668  else
     3669  {
     3670    refPicListModification->setRefPicListModificationFlagL1(0);
     3671  }
     3672  if (rpcSlice->isInterB())
     3673  {
     3674    READ_FLAG( uiCode, "mvd_l1_zero_flag" );       rpcSlice->setMvdL1ZeroFlag( (uiCode ? true : false) );
     3675  }
     3676
     3677  rpcSlice->setCabacInitFlag( false ); // default
     3678  if(pps->getCabacInitPresentFlag() && !rpcSlice->isIntra())
     3679  {
     3680    READ_FLAG(uiCode, "cabac_init_flag");
     3681    rpcSlice->setCabacInitFlag( uiCode ? true : false );
     3682  }
     3683
     3684  if ( rpcSlice->getEnableTMVPFlag() )
     3685  {
     3686#if SVC_EXTENSION && REF_IDX_MFM
     3687    // set motion mapping flag
     3688    rpcSlice->setMFMEnabledFlag( ( rpcSlice->getNumMotionPredRefLayers() > 0 && rpcSlice->getActiveNumILRRefIdx() && !rpcSlice->isIntra() ) ? true : false );
     3689#endif
     3690    if ( rpcSlice->getSliceType() == B_SLICE )
     3691    {
     3692      READ_FLAG( uiCode, "collocated_from_l0_flag" );
     3693      rpcSlice->setColFromL0Flag(uiCode);
    31173694    }
    31183695    else
    31193696    {
    3120       refPicListModification->setRefPicListModificationFlagL1(0);
    3121     }
    3122     if (rpcSlice->isInterB())
    3123     {
    3124       READ_FLAG( uiCode, "mvd_l1_zero_flag" );       rpcSlice->setMvdL1ZeroFlag( (uiCode ? true : false) );
    3125     }
    3126 
    3127     rpcSlice->setCabacInitFlag( false ); // default
    3128     if(pps->getCabacInitPresentFlag() && !rpcSlice->isIntra())
    3129     {
    3130       READ_FLAG(uiCode, "cabac_init_flag");
    3131       rpcSlice->setCabacInitFlag( uiCode ? true : false );
    3132     }
    3133 
    3134     if ( rpcSlice->getEnableTMVPFlag() )
    3135     {
    3136 #if SVC_EXTENSION && REF_IDX_MFM
    3137       // set motion mapping flag
    3138       rpcSlice->setMFMEnabledFlag( ( rpcSlice->getNumMotionPredRefLayers() > 0 && rpcSlice->getActiveNumILRRefIdx() && !rpcSlice->isIntra() ) ? true : false );
    3139 #endif
    3140       if ( rpcSlice->getSliceType() == B_SLICE )
    3141       {
    3142         READ_FLAG( uiCode, "collocated_from_l0_flag" );
    3143         rpcSlice->setColFromL0Flag(uiCode);
    3144       }
    3145       else
    3146       {
    3147         rpcSlice->setColFromL0Flag( 1 );
    3148       }
    3149 
    3150       if ( rpcSlice->getSliceType() != I_SLICE &&
    3151           ((rpcSlice->getColFromL0Flag() == 1 && rpcSlice->getNumRefIdx(REF_PIC_LIST_0) > 1)||
    3152            (rpcSlice->getColFromL0Flag() == 0 && rpcSlice->getNumRefIdx(REF_PIC_LIST_1) > 1)))
    3153       {
    3154         READ_UVLC( uiCode, "collocated_ref_idx" );
    3155         rpcSlice->setColRefIdx(uiCode);
    3156       }
    3157       else
    3158       {
    3159         rpcSlice->setColRefIdx(0);
    3160       }
    3161     }
    3162     if ( (pps->getUseWP() && rpcSlice->getSliceType()==P_SLICE) || (pps->getWPBiPred() && rpcSlice->getSliceType()==B_SLICE) )
    3163     {
    3164       xParsePredWeightTable(rpcSlice);
    3165       rpcSlice->initWpScaling();
    3166     }
    3167     if (!rpcSlice->isIntra())
    3168     {
    3169       READ_UVLC( uiCode, "five_minus_max_num_merge_cand");
    3170       rpcSlice->setMaxNumMergeCand(MRG_MAX_NUM_CANDS - uiCode);
    3171     }
    3172 
    3173     READ_SVLC( iCode, "slice_qp_delta" );
    3174     rpcSlice->setSliceQp (26 + pps->getPicInitQPMinus26() + iCode);
     3697      rpcSlice->setColFromL0Flag( 1 );
     3698    }
     3699
     3700    if ( rpcSlice->getSliceType() != I_SLICE &&
     3701      ((rpcSlice->getColFromL0Flag() == 1 && rpcSlice->getNumRefIdx(REF_PIC_LIST_0) > 1)||
     3702      (rpcSlice->getColFromL0Flag() == 0 && rpcSlice->getNumRefIdx(REF_PIC_LIST_1) > 1)))
     3703    {
     3704      READ_UVLC( uiCode, "collocated_ref_idx" );
     3705      rpcSlice->setColRefIdx(uiCode);
     3706    }
     3707    else
     3708    {
     3709      rpcSlice->setColRefIdx(0);
     3710    }
     3711  }
     3712  if ( (pps->getUseWP() && rpcSlice->getSliceType()==P_SLICE) || (pps->getWPBiPred() && rpcSlice->getSliceType()==B_SLICE) )
     3713  {
     3714    xParsePredWeightTable(rpcSlice);
     3715    rpcSlice->initWpScaling();
     3716  }
     3717  if (!rpcSlice->isIntra())
     3718  {
     3719    READ_UVLC( uiCode, "five_minus_max_num_merge_cand");
     3720    rpcSlice->setMaxNumMergeCand(MRG_MAX_NUM_CANDS - uiCode);
     3721  }
     3722
     3723  READ_SVLC( iCode, "slice_qp_delta" );
     3724  rpcSlice->setSliceQp (26 + pps->getPicInitQPMinus26() + iCode);
    31753725
    31763726#if REPN_FORMAT_IN_VPS
    31773727#if O0194_DIFFERENT_BITDEPTH_EL_BL
    3178     g_bitDepthYLayer[rpcSlice->getLayerId()] = rpcSlice->getBitDepthY();
    3179     g_bitDepthCLayer[rpcSlice->getLayerId()] = rpcSlice->getBitDepthC();
    3180 #endif
    3181     assert( rpcSlice->getSliceQp() >= -rpcSlice->getQpBDOffsetY() );
    3182 #else
    3183     assert( rpcSlice->getSliceQp() >= -sps->getQpBDOffsetY() );
    3184 #endif
    3185     assert( rpcSlice->getSliceQp() <=  51 );
    3186 
    3187     if (rpcSlice->getPPS()->getSliceChromaQpFlag())
    3188     {
    3189       READ_SVLC( iCode, "slice_qp_delta_cb" );
    3190       rpcSlice->setSliceQpDeltaCb( iCode );
    3191       assert( rpcSlice->getSliceQpDeltaCb() >= -12 );
    3192       assert( rpcSlice->getSliceQpDeltaCb() <=  12 );
    3193       assert( (rpcSlice->getPPS()->getChromaCbQpOffset() + rpcSlice->getSliceQpDeltaCb()) >= -12 );
    3194       assert( (rpcSlice->getPPS()->getChromaCbQpOffset() + rpcSlice->getSliceQpDeltaCb()) <=  12 );
    3195 
    3196       READ_SVLC( iCode, "slice_qp_delta_cr" );
    3197       rpcSlice->setSliceQpDeltaCr( iCode );
    3198       assert( rpcSlice->getSliceQpDeltaCr() >= -12 );
    3199       assert( rpcSlice->getSliceQpDeltaCr() <=  12 );
    3200       assert( (rpcSlice->getPPS()->getChromaCrQpOffset() + rpcSlice->getSliceQpDeltaCr()) >= -12 );
    3201       assert( (rpcSlice->getPPS()->getChromaCrQpOffset() + rpcSlice->getSliceQpDeltaCr()) <=  12 );
    3202     }
    3203 
    3204     if (rpcSlice->getPPS()->getDeblockingFilterControlPresentFlag())
    3205     {
    3206       if(rpcSlice->getPPS()->getDeblockingFilterOverrideEnabledFlag())
    3207       {
    3208         READ_FLAG ( uiCode, "deblocking_filter_override_flag" );        rpcSlice->setDeblockingFilterOverrideFlag(uiCode ? true : false);
     3728  g_bitDepthYLayer[rpcSlice->getLayerId()] = rpcSlice->getBitDepthY();
     3729  g_bitDepthCLayer[rpcSlice->getLayerId()] = rpcSlice->getBitDepthC();
     3730#endif
     3731  assert( rpcSlice->getSliceQp() >= -rpcSlice->getQpBDOffsetY() );
     3732#else
     3733  assert( rpcSlice->getSliceQp() >= -sps->getQpBDOffsetY() );
     3734#endif
     3735  assert( rpcSlice->getSliceQp() <=  51 );
     3736
     3737  if (rpcSlice->getPPS()->getSliceChromaQpFlag())
     3738  {
     3739    READ_SVLC( iCode, "slice_qp_delta_cb" );
     3740    rpcSlice->setSliceQpDeltaCb( iCode );
     3741    assert( rpcSlice->getSliceQpDeltaCb() >= -12 );
     3742    assert( rpcSlice->getSliceQpDeltaCb() <=  12 );
     3743    assert( (rpcSlice->getPPS()->getChromaCbQpOffset() + rpcSlice->getSliceQpDeltaCb()) >= -12 );
     3744    assert( (rpcSlice->getPPS()->getChromaCbQpOffset() + rpcSlice->getSliceQpDeltaCb()) <=  12 );
     3745
     3746    READ_SVLC( iCode, "slice_qp_delta_cr" );
     3747    rpcSlice->setSliceQpDeltaCr( iCode );
     3748    assert( rpcSlice->getSliceQpDeltaCr() >= -12 );
     3749    assert( rpcSlice->getSliceQpDeltaCr() <=  12 );
     3750    assert( (rpcSlice->getPPS()->getChromaCrQpOffset() + rpcSlice->getSliceQpDeltaCr()) >= -12 );
     3751    assert( (rpcSlice->getPPS()->getChromaCrQpOffset() + rpcSlice->getSliceQpDeltaCr()) <=  12 );
     3752  }
     3753
     3754  if (rpcSlice->getPPS()->getDeblockingFilterControlPresentFlag())
     3755  {
     3756    if(rpcSlice->getPPS()->getDeblockingFilterOverrideEnabledFlag())
     3757    {
     3758      READ_FLAG ( uiCode, "deblocking_filter_override_flag" );        rpcSlice->setDeblockingFilterOverrideFlag(uiCode ? true : false);
     3759    }
     3760    else
     3761    {
     3762      rpcSlice->setDeblockingFilterOverrideFlag(0);
     3763    }
     3764    if(rpcSlice->getDeblockingFilterOverrideFlag())
     3765    {
     3766      READ_FLAG ( uiCode, "slice_disable_deblocking_filter_flag" );   rpcSlice->setDeblockingFilterDisable(uiCode ? 1 : 0);
     3767      if(!rpcSlice->getDeblockingFilterDisable())
     3768      {
     3769        READ_SVLC( iCode, "slice_beta_offset_div2" );                       rpcSlice->setDeblockingFilterBetaOffsetDiv2(iCode);
     3770        assert(rpcSlice->getDeblockingFilterBetaOffsetDiv2() >= -6 &&
     3771          rpcSlice->getDeblockingFilterBetaOffsetDiv2() <=  6);
     3772        READ_SVLC( iCode, "slice_tc_offset_div2" );                         rpcSlice->setDeblockingFilterTcOffsetDiv2(iCode);
     3773        assert(rpcSlice->getDeblockingFilterTcOffsetDiv2() >= -6 &&
     3774          rpcSlice->getDeblockingFilterTcOffsetDiv2() <=  6);
     3775      }
     3776    }
     3777    else
     3778    {
     3779      rpcSlice->setDeblockingFilterDisable   ( rpcSlice->getPPS()->getPicDisableDeblockingFilterFlag() );
     3780      rpcSlice->setDeblockingFilterBetaOffsetDiv2( rpcSlice->getPPS()->getDeblockingFilterBetaOffsetDiv2() );
     3781      rpcSlice->setDeblockingFilterTcOffsetDiv2  ( rpcSlice->getPPS()->getDeblockingFilterTcOffsetDiv2() );
     3782    }
     3783  }
     3784  else
     3785  {
     3786    rpcSlice->setDeblockingFilterDisable       ( false );
     3787    rpcSlice->setDeblockingFilterBetaOffsetDiv2( 0 );
     3788    rpcSlice->setDeblockingFilterTcOffsetDiv2  ( 0 );
     3789  }
     3790
     3791  Bool isSAOEnabled = (!rpcSlice->getSPS()->getUseSAO())?(false):(rpcSlice->getSaoEnabledFlag()||rpcSlice->getSaoEnabledFlagChroma());
     3792  Bool isDBFEnabled = (!rpcSlice->getDeblockingFilterDisable());
     3793
     3794  if(rpcSlice->getPPS()->getLoopFilterAcrossSlicesEnabledFlag() && ( isSAOEnabled || isDBFEnabled ))
     3795  {
     3796    READ_FLAG( uiCode, "slice_loop_filter_across_slices_enabled_flag");
     3797  }
     3798  else
     3799  {
     3800    uiCode = rpcSlice->getPPS()->getLoopFilterAcrossSlicesEnabledFlag()?1:0;
     3801  }
     3802  rpcSlice->setLFCrossSliceBoundaryFlag( (uiCode==1)?true:false);
     3803
     3804}
     3805
     3806UInt *entryPointOffset          = NULL;
     3807UInt numEntryPointOffsets, offsetLenMinus1;
     3808if( pps->getTilesEnabledFlag() || pps->getEntropyCodingSyncEnabledFlag() )
     3809{
     3810  READ_UVLC(numEntryPointOffsets, "num_entry_point_offsets"); rpcSlice->setNumEntryPointOffsets ( numEntryPointOffsets );
     3811  if (numEntryPointOffsets>0)
     3812  {
     3813    READ_UVLC(offsetLenMinus1, "offset_len_minus1");
     3814  }
     3815  entryPointOffset = new UInt[numEntryPointOffsets];
     3816  for (UInt idx=0; idx<numEntryPointOffsets; idx++)
     3817  {
     3818    READ_CODE(offsetLenMinus1+1, uiCode, "entry_point_offset_minus1");
     3819    entryPointOffset[ idx ] = uiCode + 1;
     3820  }
     3821}
     3822else
     3823{
     3824  rpcSlice->setNumEntryPointOffsets ( 0 );
     3825}
     3826
     3827#if POC_RESET_IDC_SIGNALLING
     3828Int sliceHeaderExtensionLength = 0;
     3829if(pps->getSliceHeaderExtensionPresentFlag())
     3830{
     3831  READ_UVLC( uiCode, "slice_header_extension_length"); sliceHeaderExtensionLength = uiCode;
     3832}
     3833else
     3834{
     3835  sliceHeaderExtensionLength = 0;
     3836#if INFERENCE_POC_MSB_VAL_PRESENT
     3837  rpcSlice->setPocMsbValPresentFlag( false );
     3838#endif
     3839}
     3840UInt startBits = m_pcBitstream->getNumBitsRead();     // Start counter of # SH Extn bits
     3841if( sliceHeaderExtensionLength > 0 )
     3842{
     3843  if( rpcSlice->getPPS()->getPocResetInfoPresentFlag() )
     3844  {
     3845    READ_CODE( 2, uiCode,       "poc_reset_idc"); rpcSlice->setPocResetIdc(uiCode);
     3846#if POC_RESET_RESTRICTIONS
     3847    /* The value of poc_reset_idc shall not be equal to 1 or 2 for a RASL picture, a RADL picture,
     3848       a sub-layer non-reference picture, or a picture that has TemporalId greater than 0,
     3849       or a picture that has discardable_flag equal to 1. */
     3850    if( rpcSlice->getPocResetIdc() == 1 || rpcSlice->getPocResetIdc() == 2 )
     3851    {
     3852      assert( !rpcSlice->isRASL() );
     3853      assert( !rpcSlice->isRADL() );
     3854      assert( !rpcSlice->isSLNR() );
     3855      assert( rpcSlice->getTLayer() == 0 );
     3856      assert( rpcSlice->getDiscardableFlag() == 0 );
     3857    }
     3858
     3859    // The value of poc_reset_idc of a CRA or BLA picture shall be less than 3.
     3860    if( rpcSlice->getPocResetIdc() == 3)
     3861    {
     3862      assert( ! ( rpcSlice->isCRA() || rpcSlice->isBLA() ) );
     3863    }
     3864#endif
     3865  }
     3866  else
     3867  {
     3868    rpcSlice->setPocResetIdc( 0 );
     3869  }
     3870#if Q0142_POC_LSB_NOT_PRESENT
     3871  if ( rpcSlice->getVPS()->getPocLsbNotPresentFlag(rpcSlice->getLayerId()) && iPOClsb > 0 )
     3872  {
     3873    assert( rpcSlice->getPocResetIdc() != 2 );
     3874  }
     3875#endif
     3876  if( rpcSlice->getPocResetIdc() > 0 )
     3877  {
     3878    READ_CODE(6, uiCode,      "poc_reset_period_id"); rpcSlice->setPocResetPeriodId(uiCode);
     3879  }
     3880  else
     3881  {
     3882
     3883    rpcSlice->setPocResetPeriodId( 0 );
     3884  }
     3885
     3886  if (rpcSlice->getPocResetIdc() == 3)
     3887  {
     3888    READ_FLAG( uiCode,        "full_poc_reset_flag"); rpcSlice->setFullPocResetFlag((uiCode == 1) ? true : false);
     3889    READ_CODE(rpcSlice->getSPS()->getBitsForPOC(), uiCode,"poc_lsb_val"); rpcSlice->setPocLsbVal(uiCode);
     3890#if Q0142_POC_LSB_NOT_PRESENT
     3891    if ( rpcSlice->getVPS()->getPocLsbNotPresentFlag(rpcSlice->getLayerId()) && rpcSlice->getFullPocResetFlag() )
     3892    {
     3893      assert( rpcSlice->getPocLsbVal() == 0 );
     3894    }
     3895#endif
     3896  }
     3897
     3898  // Derive the value of PocMsbValRequiredFlag
     3899#if P0297_VPS_POC_LSB_ALIGNED_FLAG
     3900  rpcSlice->setPocMsbValRequiredFlag( (rpcSlice->getCraPicFlag() || rpcSlice->getBlaPicFlag())
     3901                                      && (!rpcSlice->getVPS()->getVpsPocLsbAlignedFlag() ||
     3902                                         (rpcSlice->getVPS()->getVpsPocLsbAlignedFlag() && rpcSlice->getVPS()->getNumDirectRefLayers(rpcSlice->getLayerId()) == 0))
     3903                                    );
     3904#else
     3905  rpcSlice->setPocMsbValRequiredFlag( rpcSlice->getCraPicFlag() || rpcSlice->getBlaPicFlag() );
     3906#endif
     3907
     3908#if P0297_VPS_POC_LSB_ALIGNED_FLAG
     3909  if (!rpcSlice->getPocMsbValRequiredFlag() && rpcSlice->getVPS()->getVpsPocLsbAlignedFlag())
     3910#else
     3911  if (!rpcSlice->getPocMsbValRequiredFlag() /* vps_poc_lsb_aligned_flag */)
     3912#endif
     3913  {
     3914#if P0297_VPS_POC_LSB_ALIGNED_FLAG
     3915    READ_FLAG(uiCode, "poc_msb_cycle_val_present_flag"); rpcSlice->setPocMsbValPresentFlag(uiCode ? true : false);
     3916#else
     3917    READ_FLAG(uiCode, "poc_msb_val_present_flag"); rpcSlice->setPocMsbValPresentFlag(uiCode ? true : false);
     3918#endif
     3919  }
     3920  else
     3921  {
     3922#if POC_MSB_VAL_PRESENT_FLAG_SEM
     3923    if( sliceHeaderExtensionLength == 0 )
     3924    {
     3925      rpcSlice->setPocMsbValPresentFlag( false );
     3926    }
     3927    else if( rpcSlice->getPocMsbValRequiredFlag() )
     3928#else
     3929    if( rpcSlice->getPocMsbValRequiredFlag() )
     3930#endif
     3931    {
     3932      rpcSlice->setPocMsbValPresentFlag( true );
     3933    }
     3934    else
     3935    {
     3936      rpcSlice->setPocMsbValPresentFlag( false );
     3937    }
     3938  }
     3939
     3940#if !POC_RESET_IDC_DECODER
     3941  Int maxPocLsb  = 1 << rpcSlice->getSPS()->getBitsForPOC();
     3942#endif
     3943  if( rpcSlice->getPocMsbValPresentFlag() )
     3944  {
     3945#if P0297_VPS_POC_LSB_ALIGNED_FLAG
     3946    READ_UVLC( uiCode,    "poc_msb_cycle_val");             rpcSlice->setPocMsbVal( uiCode );
     3947#else
     3948    READ_UVLC( uiCode,    "poc_msb_val");             rpcSlice->setPocMsbVal( uiCode );
     3949#endif
     3950
     3951#if !POC_RESET_IDC_DECODER
     3952    // Update POC of the slice based on this MSB val
     3953    Int pocLsb     = rpcSlice->getPOC() % maxPocLsb;
     3954    rpcSlice->setPOC((rpcSlice->getPocMsbVal() * maxPocLsb) + pocLsb);
     3955  }
     3956  else
     3957  {
     3958    rpcSlice->setPocMsbVal( rpcSlice->getPOC() / maxPocLsb );
     3959#endif
     3960  }
     3961
     3962  // Read remaining bits in the slice header extension.
     3963  UInt endBits = m_pcBitstream->getNumBitsRead();
     3964  Int counter = (endBits - startBits) % 8;
     3965  if( counter )
     3966  {
     3967    counter = 8 - counter;
     3968  }
     3969
     3970  while( counter )
     3971  {
     3972#if Q0146_SSH_EXT_DATA_BIT
     3973    READ_FLAG( uiCode, "slice_segment_header_extension_data_bit" );
     3974#else
     3975    READ_FLAG( uiCode, "slice_segment_header_extension_reserved_bit" ); assert( uiCode == 1 );
     3976#endif
     3977    counter--;
     3978  }
     3979}
     3980#else
     3981if(pps->getSliceHeaderExtensionPresentFlag())
     3982{
     3983  READ_UVLC(uiCode,"slice_header_extension_length");
     3984  for(Int i=0; i<uiCode; i++)
     3985  {
     3986    UInt ignore;
     3987    READ_CODE(8,ignore,"slice_header_extension_data_byte");
     3988  }
     3989}
     3990#endif
     3991m_pcBitstream->readByteAlignment();
     3992
     3993if( pps->getTilesEnabledFlag() || pps->getEntropyCodingSyncEnabledFlag() )
     3994{
     3995  Int endOfSliceHeaderLocation = m_pcBitstream->getByteLocation();
     3996
     3997  // Adjust endOfSliceHeaderLocation to account for emulation prevention bytes in the slice segment header
     3998  for ( UInt curByteIdx  = 0; curByteIdx<m_pcBitstream->numEmulationPreventionBytesRead(); curByteIdx++ )
     3999  {
     4000    if ( m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) < endOfSliceHeaderLocation )
     4001    {
     4002      endOfSliceHeaderLocation++;
     4003    }
     4004  }
     4005
     4006  Int  curEntryPointOffset     = 0;
     4007  Int  prevEntryPointOffset    = 0;
     4008  for (UInt idx=0; idx<numEntryPointOffsets; idx++)
     4009  {
     4010    curEntryPointOffset += entryPointOffset[ idx ];
     4011
     4012    Int emulationPreventionByteCount = 0;
     4013    for ( UInt curByteIdx  = 0; curByteIdx<m_pcBitstream->numEmulationPreventionBytesRead(); curByteIdx++ )
     4014    {
     4015      if ( m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) >= ( prevEntryPointOffset + endOfSliceHeaderLocation ) &&
     4016        m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) <  ( curEntryPointOffset  + endOfSliceHeaderLocation ) )
     4017      {
     4018        emulationPreventionByteCount++;
     4019      }
     4020    }
     4021
     4022    entryPointOffset[ idx ] -= emulationPreventionByteCount;
     4023    prevEntryPointOffset = curEntryPointOffset;
     4024  }
     4025
     4026  if ( pps->getTilesEnabledFlag() )
     4027  {
     4028    rpcSlice->setTileLocationCount( numEntryPointOffsets );
     4029
     4030    UInt prevPos = 0;
     4031    for (Int idx=0; idx<rpcSlice->getTileLocationCount(); idx++)
     4032    {
     4033      rpcSlice->setTileLocation( idx, prevPos + entryPointOffset [ idx ] );
     4034      prevPos += entryPointOffset[ idx ];
     4035    }
     4036  }
     4037  else if ( pps->getEntropyCodingSyncEnabledFlag() )
     4038  {
     4039    Int numSubstreams = rpcSlice->getNumEntryPointOffsets()+1;
     4040    rpcSlice->allocSubstreamSizes(numSubstreams);
     4041    UInt *pSubstreamSizes       = rpcSlice->getSubstreamSizes();
     4042    for (Int idx=0; idx<numSubstreams-1; idx++)
     4043    {
     4044      if ( idx < numEntryPointOffsets )
     4045      {
     4046        pSubstreamSizes[ idx ] = ( entryPointOffset[ idx ] << 3 ) ;
    32094047      }
    32104048      else
    32114049      {
    3212         rpcSlice->setDeblockingFilterOverrideFlag(0);
    3213       }
    3214       if(rpcSlice->getDeblockingFilterOverrideFlag())
    3215       {
    3216         READ_FLAG ( uiCode, "slice_disable_deblocking_filter_flag" );   rpcSlice->setDeblockingFilterDisable(uiCode ? 1 : 0);
    3217         if(!rpcSlice->getDeblockingFilterDisable())
    3218         {
    3219           READ_SVLC( iCode, "slice_beta_offset_div2" );                       rpcSlice->setDeblockingFilterBetaOffsetDiv2(iCode);
    3220           assert(rpcSlice->getDeblockingFilterBetaOffsetDiv2() >= -6 &&
    3221                  rpcSlice->getDeblockingFilterBetaOffsetDiv2() <=  6);
    3222           READ_SVLC( iCode, "slice_tc_offset_div2" );                         rpcSlice->setDeblockingFilterTcOffsetDiv2(iCode);
    3223           assert(rpcSlice->getDeblockingFilterTcOffsetDiv2() >= -6 &&
    3224                  rpcSlice->getDeblockingFilterTcOffsetDiv2() <=  6);
    3225         }
    3226       }
    3227       else
    3228       {
    3229         rpcSlice->setDeblockingFilterDisable   ( rpcSlice->getPPS()->getPicDisableDeblockingFilterFlag() );
    3230         rpcSlice->setDeblockingFilterBetaOffsetDiv2( rpcSlice->getPPS()->getDeblockingFilterBetaOffsetDiv2() );
    3231         rpcSlice->setDeblockingFilterTcOffsetDiv2  ( rpcSlice->getPPS()->getDeblockingFilterTcOffsetDiv2() );
    3232       }
    3233     }
    3234     else
    3235     {
    3236       rpcSlice->setDeblockingFilterDisable       ( false );
    3237       rpcSlice->setDeblockingFilterBetaOffsetDiv2( 0 );
    3238       rpcSlice->setDeblockingFilterTcOffsetDiv2  ( 0 );
    3239     }
    3240 
    3241     Bool isSAOEnabled = (!rpcSlice->getSPS()->getUseSAO())?(false):(rpcSlice->getSaoEnabledFlag()||rpcSlice->getSaoEnabledFlagChroma());
    3242     Bool isDBFEnabled = (!rpcSlice->getDeblockingFilterDisable());
    3243 
    3244     if(rpcSlice->getPPS()->getLoopFilterAcrossSlicesEnabledFlag() && ( isSAOEnabled || isDBFEnabled ))
    3245     {
    3246       READ_FLAG( uiCode, "slice_loop_filter_across_slices_enabled_flag");
    3247     }
    3248     else
    3249     {
    3250       uiCode = rpcSlice->getPPS()->getLoopFilterAcrossSlicesEnabledFlag()?1:0;
    3251     }
    3252     rpcSlice->setLFCrossSliceBoundaryFlag( (uiCode==1)?true:false);
    3253 
    3254   }
    3255 
    3256     UInt *entryPointOffset          = NULL;
    3257     UInt numEntryPointOffsets, offsetLenMinus1;
    3258   if( pps->getTilesEnabledFlag() || pps->getEntropyCodingSyncEnabledFlag() )
    3259   {
    3260     READ_UVLC(numEntryPointOffsets, "num_entry_point_offsets"); rpcSlice->setNumEntryPointOffsets ( numEntryPointOffsets );
    3261     if (numEntryPointOffsets>0)
    3262     {
    3263       READ_UVLC(offsetLenMinus1, "offset_len_minus1");
    3264     }
    3265     entryPointOffset = new UInt[numEntryPointOffsets];
    3266     for (UInt idx=0; idx<numEntryPointOffsets; idx++)
    3267     {
    3268       READ_CODE(offsetLenMinus1+1, uiCode, "entry_point_offset_minus1");
    3269       entryPointOffset[ idx ] = uiCode + 1;
    3270     }
    3271   }
    3272   else
    3273   {
    3274     rpcSlice->setNumEntryPointOffsets ( 0 );
    3275   }
    3276 
    3277 #if POC_RESET_IDC_SIGNALLING
    3278   Int sliceHeaderExtensionLength = 0;
    3279   if(pps->getSliceHeaderExtensionPresentFlag())
    3280   {
    3281     READ_UVLC( uiCode, "slice_header_extension_length"); sliceHeaderExtensionLength = uiCode;
    3282   }
    3283   else
    3284   {
    3285     sliceHeaderExtensionLength = 0;
    3286   }
    3287   UInt startBits = m_pcBitstream->getNumBitsRead();     // Start counter of # SH Extn bits
    3288   if( sliceHeaderExtensionLength > 0 )
    3289   {
    3290     if( rpcSlice->getPPS()->getPocResetInfoPresentFlag() )
    3291     {
    3292       READ_CODE( 2, uiCode,       "poc_reset_idc"); rpcSlice->setPocResetIdc(uiCode);
    3293     }
    3294     else
    3295     {
    3296       rpcSlice->setPocResetIdc( 0 );
    3297     }
    3298 #if Q0142_POC_LSB_NOT_PRESENT
    3299     if ( rpcSlice->getVPS()->getPocLsbNotPresentFlag(rpcSlice->getLayerId()) && iPOClsb > 0 )
    3300     {
    3301       assert( rpcSlice->getPocResetIdc() != 2 );
    3302     }
    3303 #endif
    3304     if( rpcSlice->getPocResetIdc() > 0 )
    3305     {
    3306       READ_CODE(6, uiCode,      "poc_reset_period_id"); rpcSlice->setPocResetPeriodId(uiCode);
    3307     }
    3308     else
    3309     {
    3310      
    3311       rpcSlice->setPocResetPeriodId( 0 );
    3312     }
    3313 
    3314     if (rpcSlice->getPocResetIdc() == 3)
    3315     {
    3316       READ_FLAG( uiCode,        "full_poc_reset_flag"); rpcSlice->setFullPocResetFlag((uiCode == 1) ? true : false);
    3317       READ_CODE(rpcSlice->getSPS()->getBitsForPOC(), uiCode,"poc_lsb_val"); rpcSlice->setPocLsbVal(uiCode);
    3318 #if Q0142_POC_LSB_NOT_PRESENT
    3319       if ( rpcSlice->getVPS()->getPocLsbNotPresentFlag(rpcSlice->getLayerId()) && rpcSlice->getFullPocResetFlag() )
    3320       {
    3321         assert( rpcSlice->getPocLsbVal() == 0 );
    3322       }
    3323 #endif
    3324     }
    3325 
    3326     // Derive the value of PocMsbValRequiredFlag
    3327     rpcSlice->setPocMsbValRequiredFlag( rpcSlice->getCraPicFlag() || rpcSlice->getBlaPicFlag()
    3328                                           /* || related to vps_poc_lsb_aligned_flag */
    3329                                           );
    3330 
    3331     if( !rpcSlice->getPocMsbValRequiredFlag() /* vps_poc_lsb_aligned_flag */ )
    3332     {
    3333       READ_FLAG( uiCode,    "poc_msb_val_present_flag"); rpcSlice->setPocMsbValPresentFlag( uiCode ? true : false );
    3334     }
    3335     else
    3336     {
    3337 #if POC_MSB_VAL_PRESENT_FLAG_SEM
    3338       if( sliceHeaderExtensionLength == 0 )
    3339       {
    3340         rpcSlice->setPocMsbValPresentFlag( false );
    3341       }
    3342       else if( rpcSlice->getPocMsbValRequiredFlag() )
    3343 #else
    3344       if( rpcSlice->getPocMsbValRequiredFlag() )
    3345 #endif
    3346       {
    3347         rpcSlice->setPocMsbValPresentFlag( true );
    3348       }
    3349       else
    3350       {
    3351         rpcSlice->setPocMsbValPresentFlag( false );
    3352       }
    3353     }
    3354 
    3355 #if !POC_RESET_IDC_DECODER
    3356     Int maxPocLsb  = 1 << rpcSlice->getSPS()->getBitsForPOC();
    3357 #endif
    3358     if( rpcSlice->getPocMsbValPresentFlag() )
    3359     {
    3360       READ_UVLC( uiCode,    "poc_msb_val");             rpcSlice->setPocMsbVal( uiCode );
    3361 
    3362 #if !POC_RESET_IDC_DECODER
    3363       // Update POC of the slice based on this MSB val
    3364       Int pocLsb     = rpcSlice->getPOC() % maxPocLsb;
    3365       rpcSlice->setPOC((rpcSlice->getPocMsbVal() * maxPocLsb) + pocLsb);
    3366     }
    3367     else
    3368     {
    3369       rpcSlice->setPocMsbVal( rpcSlice->getPOC() / maxPocLsb );
    3370 #endif
    3371     }
    3372 
    3373     // Read remaining bits in the slice header extension.
    3374     UInt endBits = m_pcBitstream->getNumBitsRead();
    3375     Int counter = (endBits - startBits) % 8;
    3376     if( counter )
    3377     {
    3378       counter = 8 - counter;
    3379     }
    3380 
    3381     while( counter )
    3382     {
    3383 #if Q0146_SSH_EXT_DATA_BIT
    3384       READ_FLAG( uiCode, "slice_segment_header_extension_data_bit" );
    3385 #else
    3386       READ_FLAG( uiCode, "slice_segment_header_extension_reserved_bit" ); assert( uiCode == 1 );
    3387 #endif
    3388       counter--;
    3389     }
    3390   }
    3391 #else
    3392   if(pps->getSliceHeaderExtensionPresentFlag())
    3393   {
    3394     READ_UVLC(uiCode,"slice_header_extension_length");
    3395     for(Int i=0; i<uiCode; i++)
    3396     {
    3397       UInt ignore;
    3398       READ_CODE(8,ignore,"slice_header_extension_data_byte");
    3399     }
    3400   }
    3401 #endif
    3402   m_pcBitstream->readByteAlignment();
    3403 
    3404   if( pps->getTilesEnabledFlag() || pps->getEntropyCodingSyncEnabledFlag() )
    3405   {
    3406     Int endOfSliceHeaderLocation = m_pcBitstream->getByteLocation();
    3407 
    3408     // Adjust endOfSliceHeaderLocation to account for emulation prevention bytes in the slice segment header
    3409     for ( UInt curByteIdx  = 0; curByteIdx<m_pcBitstream->numEmulationPreventionBytesRead(); curByteIdx++ )
    3410     {
    3411       if ( m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) < endOfSliceHeaderLocation )
    3412       {
    3413         endOfSliceHeaderLocation++;
    3414       }
    3415     }
    3416 
    3417     Int  curEntryPointOffset     = 0;
    3418     Int  prevEntryPointOffset    = 0;
    3419     for (UInt idx=0; idx<numEntryPointOffsets; idx++)
    3420     {
    3421       curEntryPointOffset += entryPointOffset[ idx ];
    3422 
    3423       Int emulationPreventionByteCount = 0;
    3424       for ( UInt curByteIdx  = 0; curByteIdx<m_pcBitstream->numEmulationPreventionBytesRead(); curByteIdx++ )
    3425       {
    3426         if ( m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) >= ( prevEntryPointOffset + endOfSliceHeaderLocation ) &&
    3427              m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) <  ( curEntryPointOffset  + endOfSliceHeaderLocation ) )
    3428         {
    3429           emulationPreventionByteCount++;
    3430         }
    3431       }
    3432 
    3433       entryPointOffset[ idx ] -= emulationPreventionByteCount;
    3434       prevEntryPointOffset = curEntryPointOffset;
    3435     }
    3436 
    3437     if ( pps->getTilesEnabledFlag() )
    3438     {
    3439       rpcSlice->setTileLocationCount( numEntryPointOffsets );
    3440 
    3441       UInt prevPos = 0;
    3442       for (Int idx=0; idx<rpcSlice->getTileLocationCount(); idx++)
    3443       {
    3444         rpcSlice->setTileLocation( idx, prevPos + entryPointOffset [ idx ] );
    3445         prevPos += entryPointOffset[ idx ];
    3446       }
    3447     }
    3448     else if ( pps->getEntropyCodingSyncEnabledFlag() )
    3449     {
    3450     Int numSubstreams = rpcSlice->getNumEntryPointOffsets()+1;
    3451       rpcSlice->allocSubstreamSizes(numSubstreams);
    3452       UInt *pSubstreamSizes       = rpcSlice->getSubstreamSizes();
    3453       for (Int idx=0; idx<numSubstreams-1; idx++)
    3454       {
    3455         if ( idx < numEntryPointOffsets )
    3456         {
    3457           pSubstreamSizes[ idx ] = ( entryPointOffset[ idx ] << 3 ) ;
    3458         }
    3459         else
    3460         {
    3461           pSubstreamSizes[ idx ] = 0;
    3462         }
    3463       }
    3464     }
    3465 
    3466     if (entryPointOffset)
    3467     {
    3468       delete [] entryPointOffset;
    3469     }
    3470   }
    3471 
    3472   return;
     4050        pSubstreamSizes[ idx ] = 0;
     4051      }
     4052    }
     4053  }
     4054
     4055  if (entryPointOffset)
     4056  {
     4057    delete [] entryPointOffset;
     4058  }
     4059}
     4060
     4061return;
    34734062}
    34744063
     
    37334322      {
    37344323#endif
    3735       wp[1].uiLog2WeightDenom = uiLog2WeightDenomChroma;
    3736       wp[2].uiLog2WeightDenom = uiLog2WeightDenomChroma;
     4324        wp[1].uiLog2WeightDenom = uiLog2WeightDenomChroma;
     4325        wp[2].uiLog2WeightDenom = uiLog2WeightDenomChroma;
    37374326#if AUXILIARY_PICTURES
    37384327      }
     
    39134502Void TDecCavlc::xParse3DAsymLUT( TCom3DAsymLUT * pc3DAsymLUT )
    39144503{
     4504#if R0150_CGS_SIGNAL_CONSTRAINTS
     4505  UInt uiNumRefLayersM1;
     4506  READ_UVLC( uiNumRefLayersM1 , "num_cm_ref_layers_minus1" );
     4507  assert( uiNumRefLayersM1 <= 61 );
     4508  for( UInt i = 0 ; i <= uiNumRefLayersM1 ; i++ )
     4509  {
     4510    UInt uiRefLayerId;
     4511    READ_CODE( 6 , uiRefLayerId , "cm_ref_layer_id" );
     4512    pc3DAsymLUT->addRefLayerId( uiRefLayerId );
     4513  }
     4514#endif
    39154515  UInt uiCurOctantDepth , uiCurPartNumLog2 , uiInputBitDepthM8 , uiOutputBitDepthM8 , uiResQaunBit;
     4516#if R0300_CGS_RES_COEFF_CODING
     4517  UInt uiDeltaBits;
     4518#endif
    39164519  READ_CODE( 2 , uiCurOctantDepth , "cm_octant_depth" );
    39174520  READ_CODE( 2 , uiCurPartNumLog2 , "cm_y_part_num_log2" );     
     4521#if R0150_CGS_SIGNAL_CONSTRAINTS
     4522  UInt uiChromaInputBitDepthM8 , uiChromaOutputBitDepthM8;
     4523  READ_UVLC( uiInputBitDepthM8 , "cm_input_luma_bit_depth_minus8" );
     4524  READ_UVLC( uiChromaInputBitDepthM8 , "cm_input_chroma_bit_depth_minus8" );
     4525  READ_UVLC( uiOutputBitDepthM8 , "cm_output_luma_bit_depth_minus8" );
     4526  READ_UVLC( uiChromaOutputBitDepthM8 , "cm_output_chroma_bit_depth_minus8" );
     4527#else
    39184528  READ_CODE( 3 , uiInputBitDepthM8 , "cm_input_bit_depth_minus8" );
    39194529  Int iInputBitDepthCDelta;
     
    39224532  Int iOutputBitDepthCDelta;
    39234533  READ_SVLC(iOutputBitDepthCDelta, "cm_output_bit_depth_chroma_delta");
     4534#endif
    39244535  READ_CODE( 2 , uiResQaunBit , "cm_res_quant_bit" );
     4536#if R0300_CGS_RES_COEFF_CODING
     4537  READ_CODE( 2 , uiDeltaBits , "cm_flc_bits" );
     4538  pc3DAsymLUT->setDeltaBits(uiDeltaBits + 1);
     4539#endif
     4540
     4541#if R0151_CGS_3D_ASYMLUT_IMPROVE
     4542#if R0150_CGS_SIGNAL_CONSTRAINTS
     4543  Int nAdaptCThresholdU = 1 << ( uiChromaInputBitDepthM8 + 8 - 1 );
     4544  Int nAdaptCThresholdV = 1 << ( uiChromaInputBitDepthM8 + 8 - 1 );
     4545#else
     4546  Int nAdaptCThresholdU = 1 << ( uiInputBitDepthM8 + 8 + iInputBitDepthCDelta - 1 );
     4547  Int nAdaptCThresholdV = 1 << ( uiInputBitDepthM8 + 8 + iInputBitDepthCDelta - 1 );
     4548#endif
     4549  if( uiCurOctantDepth == 1 )
     4550  {
     4551    Int delta = 0;
     4552    READ_SVLC( delta , "cm_adapt_threshold_u_delta" );
     4553    nAdaptCThresholdU += delta;
     4554    READ_SVLC( delta , "cm_adapt_threshold_v_delta" );
     4555    nAdaptCThresholdV += delta;
     4556  }
     4557#endif
    39254558  pc3DAsymLUT->destroy();
    3926   pc3DAsymLUT->create( uiCurOctantDepth , uiInputBitDepthM8 + 8 ,  uiInputBitDepthM8 + 8 + iInputBitDepthCDelta, uiOutputBitDepthM8 + 8 , uiOutputBitDepthM8 + 8 + iOutputBitDepthCDelta ,uiCurPartNumLog2 );
     4559  pc3DAsymLUT->create( uiCurOctantDepth , uiInputBitDepthM8 + 8 , 
     4560#if R0150_CGS_SIGNAL_CONSTRAINTS
     4561    uiChromaInputBitDepthM8 + 8 ,
     4562#else
     4563    uiInputBitDepthM8 + 8 + iInputBitDepthCDelta,
     4564#endif
     4565    uiOutputBitDepthM8 + 8 ,
     4566#if R0150_CGS_SIGNAL_CONSTRAINTS
     4567    uiChromaOutputBitDepthM8 + 8 ,
     4568#else
     4569    uiOutputBitDepthM8 + 8 + iOutputBitDepthCDelta ,
     4570#endif
     4571    uiCurPartNumLog2
     4572#if R0151_CGS_3D_ASYMLUT_IMPROVE
     4573    , nAdaptCThresholdU , nAdaptCThresholdV
     4574#endif   
     4575    );
    39274576  pc3DAsymLUT->setResQuantBit( uiResQaunBit );
    39284577
     4578#if R0164_CGS_LUT_BUGFIX_CHECK
     4579  pc3DAsymLUT->xInitCuboids();
     4580#endif
    39294581  xParse3DAsymLUTOctant( pc3DAsymLUT , 0 , 0 , 0 , 0 , 1 << pc3DAsymLUT->getCurOctantDepth() );
     4582#if R0164_CGS_LUT_BUGFIX
     4583#if R0164_CGS_LUT_BUGFIX_CHECK
     4584  printf("============= Before 'xCuboidsFilledCheck()': ================\n");
     4585  pc3DAsymLUT->display();
     4586  pc3DAsymLUT->xCuboidsFilledCheck( false );
     4587  printf("============= After 'xCuboidsFilledCheck()': =================\n");
     4588  pc3DAsymLUT->display();
     4589#endif
     4590#endif
    39304591}
    39314592
     
    39524613  else
    39534614  {
     4615#if R0300_CGS_RES_COEFF_CODING
     4616    Int nFLCbits = pc3DAsymLUT->getMappingShift()-pc3DAsymLUT->getResQuantBit()-pc3DAsymLUT->getDeltaBits() ;
     4617    nFLCbits = nFLCbits >= 0 ? nFLCbits:0;
     4618#endif
    39544619    for( Int l = 0 ; l < nYPartNum ; l++ )
    39554620    {
     4621#if R0164_CGS_LUT_BUGFIX
     4622      Int shift = pc3DAsymLUT->getCurOctantDepth() - nDepth ;
     4623#endif
    39564624      for( Int nVertexIdx = 0 ; nVertexIdx < 4 ; nVertexIdx++ )
    39574625      {
     
    39614629        if( uiCodeVertex )
    39624630        {
     4631#if R0151_CGS_3D_ASYMLUT_IMPROVE
     4632#if R0300_CGS_RES_COEFF_CODING
     4633          xReadParam( deltaY, nFLCbits );
     4634          xReadParam( deltaU, nFLCbits );
     4635          xReadParam( deltaV, nFLCbits );
     4636#else
     4637          xReadParam( deltaY );
     4638          xReadParam( deltaU );
     4639          xReadParam( deltaV );
     4640#endif
     4641#else
    39634642          READ_SVLC( deltaY , "resY" );
    39644643          READ_SVLC( deltaU , "resU" );
    39654644          READ_SVLC( deltaV , "resV" );
    3966         }
     4645#endif
     4646        }
     4647#if R0164_CGS_LUT_BUGFIX
     4648        pc3DAsymLUT->setCuboidVertexResTree( yIdx + (l<<shift) , uIdx , vIdx , nVertexIdx , deltaY , deltaU , deltaV );
     4649        for (Int m = 1; m < (1<<shift); m++) {
     4650          pc3DAsymLUT->setCuboidVertexResTree( yIdx + (l<<shift) + m , uIdx , vIdx , nVertexIdx , 0 , 0 , 0 );
     4651#if R0164_CGS_LUT_BUGFIX_CHECK
     4652          pc3DAsymLUT->xSetFilled( yIdx + (l<<shift) + m , uIdx , vIdx );
     4653#endif
     4654        }
     4655#else
    39674656        pc3DAsymLUT->setCuboidVertexResTree( yIdx + l , uIdx , vIdx , nVertexIdx , deltaY , deltaU , deltaV );
    3968       }
    3969     }
    3970   }
    3971 }
     4657#endif
     4658      }
     4659#if R0164_CGS_LUT_BUGFIX_CHECK
     4660      pc3DAsymLUT->xSetExplicit( yIdx + (l<<shift) , uIdx , vIdx );
     4661#endif
     4662    }
     4663#if R0164_CGS_LUT_BUGFIX
     4664    for ( Int u=0 ; u<nLength ; u++ ) {
     4665      for ( Int v=0 ; v<nLength ; v++ ) {
     4666        if ( u!=0 || v!=0 ) {
     4667          for ( Int y=0 ; y<nLength*nYPartNum ; y++ ) {
     4668            for( Int nVertexIdx = 0 ; nVertexIdx < 4 ; nVertexIdx++ )
     4669            {
     4670              pc3DAsymLUT->setCuboidVertexResTree( yIdx + y , uIdx + u , vIdx + v , nVertexIdx , 0 , 0 , 0 );
     4671#if R0164_CGS_LUT_BUGFIX_CHECK
     4672              pc3DAsymLUT->xSetFilled( yIdx + y , uIdx + u , vIdx + v );
     4673#endif
     4674            }
     4675          }
     4676        }
     4677      }
     4678    }
     4679#endif
     4680  }
     4681}
     4682
     4683#if R0151_CGS_3D_ASYMLUT_IMPROVE
     4684#if R0300_CGS_RES_COEFF_CODING
     4685Void TDecCavlc::xReadParam( Int& param, Int rParam )
     4686#else
     4687Void TDecCavlc::xReadParam( Int& param )
     4688#endif
     4689{
     4690#if !R0300_CGS_RES_COEFF_CODING
     4691  const UInt rParam = 7;
     4692#endif
     4693  UInt prefix;
     4694  UInt codeWord ;
     4695  UInt rSymbol;
     4696  UInt sign;
     4697
     4698  READ_UVLC( prefix, "quotient")  ;
     4699  READ_CODE (rParam, codeWord, "remainder");
     4700  rSymbol = (prefix<<rParam) + codeWord;
     4701
     4702  if(rSymbol)
     4703  {
     4704    READ_FLAG(sign, "sign");
     4705    param = sign ? -(Int)(rSymbol) : (Int)(rSymbol);
     4706  }
     4707  else param = 0;
     4708}
     4709#endif
     4710#if VPS_VUI_BSP_HRD_PARAMS
     4711Void TDecCavlc::parseVpsVuiBspHrdParams( TComVPS *vps )
     4712{
     4713  UInt uiCode;
     4714  assert (vps->getTimingInfo()->getTimingInfoPresentFlag() == 1);
     4715  READ_UVLC( uiCode, "vps_num_add_hrd_params" ); vps->setVpsNumAddHrdParams(uiCode);
     4716  vps->createBspHrdParamBuffer(vps->getVpsNumAddHrdParams()); // Also allocates m_cprmsAddPresentFlag and m_numSubLayerHrdMinus
     4717
     4718  for( Int i = vps->getNumHrdParameters(), j = 0; i < vps->getNumHrdParameters() + vps->getVpsNumAddHrdParams(); i++, j++ ) // j = i - vps->getNumHrdParameters()
     4719  {
     4720    if( i > 0 )
     4721    {
     4722      READ_FLAG( uiCode, "cprms_add_present_flag[i]" );   vps->setCprmsAddPresentFlag(j, uiCode ? true : false);
     4723    }
     4724    else
     4725    {
     4726      // i == 0
     4727      if( vps->getNumHrdParameters() == 0 )
     4728      {
     4729        vps->setCprmsAddPresentFlag(0, true);
     4730      }
     4731    }
     4732    READ_UVLC( uiCode, "num_sub_layer_hrd_minus1[i]" ); vps->setNumSubLayerHrdMinus1(j, uiCode );
     4733    assert( uiCode <= vps->getMaxTLayers() - 1 );
     4734   
     4735    parseHrdParameters( vps->getBspHrd(j), vps->getCprmsAddPresentFlag(j), vps->getNumSubLayerHrdMinus1(j) );
     4736    if( i > 0 && !vps->getCprmsAddPresentFlag(i) )
     4737    {
     4738      // Copy common information parameters
     4739      if( i == vps->getNumHrdParameters() )
     4740      {
     4741        vps->getBspHrd(j)->copyCommonInformation( vps->getHrdParameters( vps->getNumHrdParameters() - 1 ) );
     4742      }
     4743      else
     4744      {
     4745        vps->getBspHrd(j)->copyCommonInformation( vps->getBspHrd( j - 1 ) );
     4746      }
     4747    }
     4748  }
     4749  for (Int h = 1; h < vps->getNumOutputLayerSets(); h++)
     4750  {
     4751    Int lsIdx = vps->getOutputLayerSetIdx( h );
     4752    READ_UVLC( uiCode, "num_signalled_partitioning_schemes[h]"); vps->setNumSignalledPartitioningSchemes(h, uiCode);
     4753    for( Int j = 0; j < vps->getNumSignalledPartitioningSchemes(h); j++ )
     4754    {
     4755      READ_UVLC( uiCode, "num_partitions_in_scheme_minus1[h][j]" ); vps->setNumPartitionsInSchemeMinus1(h, j, uiCode);
     4756      for( Int k = 0; k <= vps->getNumPartitionsInSchemeMinus1(h, j); k++ )
     4757      {
     4758        for( Int r = 0; r < vps->getNumLayersInIdList( lsIdx ); r++ )
     4759        {
     4760          READ_FLAG( uiCode, "layer_included_in_partition_flag[h][j][k][r]" ); vps->setLayerIncludedInPartitionFlag(h, j, k, r, uiCode ? true : false);
     4761        }
     4762      }
     4763    }
     4764    for( Int i = 0; i < vps->getNumSignalledPartitioningSchemes(h) + 1; i++ )
     4765    {
     4766      for( Int t = 0; t <= vps->getMaxSLayersInLayerSetMinus1(lsIdx); t++ )
     4767      {
     4768        READ_UVLC( uiCode, "num_bsp_schedules_minus1[h][i][t]");              vps->setNumBspSchedulesMinus1(h, i, t, uiCode);
     4769        for( Int j = 0; j <= vps->getNumBspSchedulesMinus1(h, i, t); j++ )
     4770        {
     4771          for( Int k = 0; k < vps->getNumPartitionsInSchemeMinus1(h, i); k++ )
     4772          {
     4773            READ_UVLC( uiCode, "bsp_comb_hrd_idx[h][i][t][j][k]");      vps->setBspHrdIdx(h, i, t, j, k, uiCode);
     4774            READ_UVLC( uiCode, "bsp_comb_sched_idx[h][i][t][j][k]");    vps->setBspSchedIdx(h, i, t, j, k, uiCode);
     4775          }
     4776        }
     4777      }
     4778    }
     4779
     4780    // To be done: Check each layer included in not more than one BSP in every partitioning scheme,
     4781    // and other related checks associated with layers in bitstream partitions.
     4782
     4783  }
     4784}
     4785#endif
    39724786#endif
    39734787//! \}
  • trunk/source/Lib/TLibDecoder/TDecCAVLC.h

    r815 r906  
    8686  Void  parseVpsDpbSizeTable( TComVPS *vps );
    8787#endif
     88#if VPS_VUI_BSP_HRD_PARAMS
     89  Void  parseVpsVuiBspHrdParams( TComVPS *vps );
     90#endif
    8891#if SPS_DPB_PARAMS
    8992  Void  parseSPS            ( TComSPS* pcSPS ); // it should be removed after macro clean up
     
    143146  Void xParse3DAsymLUT( TCom3DAsymLUT * pc3DAsymLUT );
    144147  Void xParse3DAsymLUTOctant( TCom3DAsymLUT * pc3DAsymLUT , Int nDepth , Int yIdx , Int uIdx , Int vIdx , Int nLength );
     148#if R0151_CGS_3D_ASYMLUT_IMPROVE
     149#if R0300_CGS_RES_COEFF_CODING
     150  Void xReadParam( Int& param, Int flc_bits );
     151#else
     152  Void xReadParam( Int& param );
     153#endif
     154#endif
    145155#endif
    146156};
  • trunk/source/Lib/TLibDecoder/TDecGop.cpp

    r713 r906  
    5454//! \{
    5555static void calcAndPrintHashStatus(TComPicYuv& pic, const SEIDecodedPictureHash* pictureHashSEI);
     56#if Q0074_COLOUR_REMAPPING_SEI
     57static Void applyColourRemapping(TComPicYuv& pic, const SEIColourRemappingInfo* colourRemappingInfoSEI, UInt layerId=0 );
     58static std::vector<SEIColourRemappingInfo> storeCriSEI; //Persistent Colour Remapping Information SEI
     59#endif
    5660// ====================================================================================================================
    5761// Constructor / destructor / initialization / destroy
     
    218222      if( pcSlice->getRefPic(RefPicList(iRefList), iRefIndex)->isILR( m_layerId ) )
    219223      {
    220         printf( "%d(%d)", pcSlice->getRefPOC(RefPicList(iRefList), iRefIndex), pcSlice->getRefPic(RefPicList(iRefList), iRefIndex)->getLayerId() );
     224        UInt refLayerId = pcSlice->getRefPic(RefPicList(iRefList), iRefIndex)->getLayerId();
     225        UInt refLayerIdc = pcSlice->getReferenceLayerIdc(refLayerId);
     226        assert( g_posScalingFactor[refLayerIdc][0] );
     227        assert( g_posScalingFactor[refLayerIdc][1] );
     228
     229        printf( "%d(%d, {%1.2f, %1.2f}x)", pcSlice->getRefPOC(RefPicList(iRefList), iRefIndex), refLayerId, 65536.0/g_posScalingFactor[refLayerIdc][0], 65536.0/g_posScalingFactor[refLayerIdc][1] );
    221230      }
    222231      else
     
    247256    calcAndPrintHashStatus(*rpcPic->getPicYuvRec(), hash);
    248257  }
     258#if Q0074_COLOUR_REMAPPING_SEI
     259  if (m_colourRemapSEIEnabled)
     260  {
     261    SEIMessages colourRemappingInfo = getSeisByType(rpcPic->getSEIs(), SEI::COLOUR_REMAPPING_INFO );
     262    const SEIColourRemappingInfo *seiColourRemappingInfo = ( colourRemappingInfo.size() > 0 ) ? (SEIColourRemappingInfo*) *(colourRemappingInfo.begin()) : NULL;
     263    if (colourRemappingInfo.size() > 1)
     264    {
     265      printf ("Warning: Got multiple Colour Remapping Information SEI messages. Using first.");
     266    }
     267    applyColourRemapping(*rpcPic->getPicYuvRec(), seiColourRemappingInfo
     268#if SVC_EXTENSION
     269     , rpcPic->getLayerId()
     270#endif
     271     );
     272  }
     273#endif
    249274
    250275#if SETTING_PIC_OUTPUT_MARK
     
    334359  }
    335360}
     361
     362#if Q0074_COLOUR_REMAPPING_SEI
     363Void xInitColourRemappingLut( const Int bitDepthY, const Int bitDepthC, std::vector<Int>(&preLut)[3], std::vector<Int>(&postLut)[3], const SEIColourRemappingInfo* const pCriSEI )
     364{
     365  for ( Int c=0 ; c<3 ; c++ )
     366  { 
     367    Int bitDepth = c ? bitDepthC : bitDepthY ;
     368    preLut[c].resize(1 << bitDepth);
     369    postLut[c].resize(1 << pCriSEI->m_colourRemapBitDepth);
     370   
     371    Int bitDepthDiff = pCriSEI->m_colourRemapBitDepth - bitDepth;
     372    Int iShift1 = (bitDepthDiff>0) ? bitDepthDiff : 0; //bit scale from bitdepth to ColourRemapBitdepth (manage only case colourRemapBitDepth>= bitdepth)
     373    if( bitDepthDiff<0 )
     374      printf ("Warning: CRI SEI - colourRemapBitDepth (%d) <bitDepth (%d) - case not handled\n", pCriSEI->m_colourRemapBitDepth, bitDepth);
     375    bitDepthDiff = pCriSEI->m_colourRemapBitDepth - pCriSEI->m_colourRemapInputBitDepth;
     376    Int iShift2 = (bitDepthDiff>0) ? bitDepthDiff : 0; //bit scale from ColourRemapInputBitdepth to ColourRemapBitdepth (manage only case colourRemapBitDepth>= colourRemapInputBitDepth)
     377    if( bitDepthDiff<0 )
     378      printf ("Warning: CRI SEI - colourRemapBitDepth (%d) <colourRemapInputBitDepth (%d) - case not handled\n", pCriSEI->m_colourRemapBitDepth, pCriSEI->m_colourRemapInputBitDepth);
     379
     380    //Fill preLut
     381    for ( Int k=0 ; k<(1<<bitDepth) ; k++ )
     382    {
     383      Int iSample = k << iShift1 ;
     384      for ( Int iPivot=0 ; iPivot<=pCriSEI->m_preLutNumValMinus1[c] ; iPivot++ )
     385      {
     386        Int iCodedPrev  = pCriSEI->m_preLutCodedValue[c][iPivot]    << iShift2; //Coded in CRInputBitdepth
     387        Int iCodedNext  = pCriSEI->m_preLutCodedValue[c][iPivot+1]  << iShift2; //Coded in CRInputBitdepth
     388        Int iTargetPrev = pCriSEI->m_preLutTargetValue[c][iPivot];              //Coded in CRBitdepth
     389        Int iTargetNext = pCriSEI->m_preLutTargetValue[c][iPivot+1];            //Coded in CRBitdepth
     390        if ( iCodedPrev <= iSample && iSample <= iCodedNext )
     391        {
     392          Float fInterpol = (Float)( (iCodedNext - iSample)*iTargetPrev + (iSample - iCodedPrev)*iTargetNext ) * 1.f / (Float)(iCodedNext - iCodedPrev);
     393          preLut[c][k]  = (Int)( 0.5f + fInterpol );
     394          iPivot = pCriSEI->m_preLutNumValMinus1[c] + 1;
     395        }
     396      }
     397    }
     398   
     399    //Fill postLut
     400    for ( Int k=0 ; k<(1<<pCriSEI->m_colourRemapBitDepth) ; k++ )
     401    {
     402      Int iSample = k;
     403      for ( Int iPivot=0 ; iPivot<=pCriSEI->m_postLutNumValMinus1[c] ; iPivot++ )
     404      {
     405        Int iCodedPrev  = pCriSEI->m_postLutCodedValue[c][iPivot];    //Coded in CRBitdepth
     406        Int iCodedNext  = pCriSEI->m_postLutCodedValue[c][iPivot+1];  //Coded in CRBitdepth
     407        Int iTargetPrev = pCriSEI->m_postLutTargetValue[c][iPivot];   //Coded in CRBitdepth
     408        Int iTargetNext = pCriSEI->m_postLutTargetValue[c][iPivot+1]; //Coded in CRBitdepth
     409        if ( iCodedPrev <= iSample && iSample <= iCodedNext )
     410        {
     411          Float fInterpol =  (Float)( (iCodedNext - iSample)*iTargetPrev + (iSample - iCodedPrev)*iTargetNext ) * 1.f / (Float)(iCodedNext - iCodedPrev) ;
     412          postLut[c][k]  = (Int)( 0.5f + fInterpol );
     413          iPivot = pCriSEI->m_postLutNumValMinus1[c] + 1;
     414        }
     415      }
     416    }
     417  }
     418}
     419
     420static void applyColourRemapping(TComPicYuv& pic, const SEIColourRemappingInfo* pCriSEI, UInt layerId )
     421
     422  if( !storeCriSEI.size() )
     423#if SVC_EXTENSION
     424    storeCriSEI.resize(MAX_LAYERS);
     425#else
     426    storeCriSEI.resize(1);
     427#endif
     428
     429  if ( pCriSEI ) //if a CRI SEI has just been retrieved, keep it in memory (persistence management)
     430    storeCriSEI[layerId] = *pCriSEI;
     431
     432  if( !storeCriSEI[layerId].m_colourRemapCancelFlag )
     433  {
     434    Int iHeight  = pic.getHeight();
     435    Int iWidth   = pic.getWidth();
     436    Int iStride  = pic.getStride();
     437    Int iCStride = pic.getCStride();
     438
     439    Pel *YUVIn[3], *YUVOut[3];
     440    YUVIn[0] = pic.getLumaAddr();
     441    YUVIn[1] = pic.getCbAddr();
     442    YUVIn[2] = pic.getCrAddr();
     443   
     444    TComPicYuv picColourRemapped;
     445#if SVC_EXTENSION
     446#if AUXILIARY_PICTURES
     447    picColourRemapped.create( pic.getWidth(), pic.getHeight(), pic.getChromaFormat(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, NULL );
     448#else
     449    picColourRemapped.create( pic.getWidth(), pic.getHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, NULL );
     450#endif
     451#else
     452    picColourRemapped.create( pic.getWidth(), pic.getHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth );
     453#endif
     454    YUVOut[0] = picColourRemapped.getLumaAddr();
     455    YUVOut[1] = picColourRemapped.getCbAddr();
     456    YUVOut[2] = picColourRemapped.getCrAddr();
     457
     458#if SVC_EXTENSION
     459    Int bitDepthY = g_bitDepthYLayer[layerId];
     460    Int bitDepthC = g_bitDepthCLayer[layerId];
     461
     462    assert( g_bitDepthY == bitDepthY );
     463    assert( g_bitDepthC == bitDepthC );
     464#else
     465    Int bitDepthY = g_bitDepthY;
     466    Int bitDepthC = g_bitDepthC;
     467#endif
     468
     469    std::vector<Int> preLut[3];
     470    std::vector<Int> postLut[3];
     471    xInitColourRemappingLut( bitDepthY, bitDepthC, preLut, postLut, &storeCriSEI[layerId] );
     472   
     473    Int roundingOffset = (storeCriSEI[layerId].m_log2MatrixDenom==0) ? 0 : (1 << (storeCriSEI[layerId].m_log2MatrixDenom - 1));
     474
     475    for( Int y = 0; y < iHeight ; y++ )
     476    {
     477      for( Int x = 0; x < iWidth ; x++ )
     478      {
     479        Int YUVPre[3], YUVMat[3];
     480        YUVPre[0] = preLut[0][ YUVIn[0][x]   ];
     481        YUVPre[1] = preLut[1][ YUVIn[1][x>>1] ];
     482        YUVPre[2] = preLut[2][ YUVIn[2][x>>1] ];
     483
     484        YUVMat[0] = ( storeCriSEI[layerId].m_colourRemapCoeffs[0][0]*YUVPre[0]
     485                    + storeCriSEI[layerId].m_colourRemapCoeffs[0][1]*YUVPre[1]
     486                    + storeCriSEI[layerId].m_colourRemapCoeffs[0][2]*YUVPre[2]
     487                    + roundingOffset ) >> ( storeCriSEI[layerId].m_log2MatrixDenom );
     488        YUVMat[0] = Clip3( 0, (1<<storeCriSEI[layerId].m_colourRemapBitDepth)-1, YUVMat[0] );
     489        YUVOut[0][x] = postLut[0][ YUVMat[0] ];
     490
     491        if( (y&1) && (x&1) )
     492        {
     493          for(Int c=1 ; c<3 ; c++)
     494          {
     495            YUVMat[c] = ( storeCriSEI[layerId].m_colourRemapCoeffs[c][0]*YUVPre[0]
     496                        + storeCriSEI[layerId].m_colourRemapCoeffs[c][1]*YUVPre[1]
     497                        + storeCriSEI[layerId].m_colourRemapCoeffs[c][2]*YUVPre[2]
     498                        + roundingOffset ) >> ( storeCriSEI[layerId].m_log2MatrixDenom );
     499            YUVMat[c] = Clip3( 0, (1<<storeCriSEI[layerId].m_colourRemapBitDepth)-1, YUVMat[c] );
     500            YUVOut[c][x>>1] = postLut[c][ YUVMat[c] ];   
     501          }
     502        }
     503      }
     504      YUVIn[0]  += iStride;
     505      YUVOut[0] += iStride;
     506      if( y&1 )
     507      {
     508        YUVIn[1]  += iCStride;
     509        YUVIn[2]  += iCStride;
     510        YUVOut[1] += iCStride;
     511        YUVOut[2] += iCStride;
     512      }
     513    }
     514
     515    //Write remapped picture in decoding order
     516    Char  cTemp[255];
     517    sprintf(cTemp, "seiColourRemappedPic_L%d_%dx%d_%dbits.yuv", layerId, iWidth, iHeight, storeCriSEI[layerId].m_colourRemapBitDepth );
     518    picColourRemapped.dump( cTemp, true, storeCriSEI[layerId].m_colourRemapBitDepth );
     519
     520    picColourRemapped.destroy();
     521
     522    storeCriSEI[layerId].m_colourRemapCancelFlag = !storeCriSEI[layerId].m_colourRemapPersistenceFlag; //Handling persistence
     523  }
     524}
     525#endif
    336526//! \}
  • trunk/source/Lib/TLibDecoder/TDecGop.h

    r595 r906  
    8282  Double                m_dDecTime;
    8383  Int                   m_decodedPictureHashSEIEnabled;  ///< Checksum(3)/CRC(2)/MD5(1)/disable(0) acting on decoded picture hash SEI message
    84 
     84#if Q0074_COLOUR_REMAPPING_SEI
     85  Bool                  m_colourRemapSEIEnabled;         ///< Enable/disable Colour Remapping Information SEI message acting on decoded pictures
     86#endif
    8587#if SVC_EXTENSION
    8688  UInt                  m_layerId;
     
    114116
    115117  void setDecodedPictureHashSEIEnabled(Int enabled) { m_decodedPictureHashSEIEnabled = enabled; }
     118#if Q0074_COLOUR_REMAPPING_SEI
     119  void setColourRemappingInfoSEIEnabled(Int enabled) { m_colourRemapSEIEnabled = enabled; }
     120#endif
    116121#if SVC_EXTENSION
    117122  TDecTop*   getLayerDec(UInt LayerId)  { return m_ppcTDecTop[LayerId]; }
  • trunk/source/Lib/TLibDecoder/TDecSlice.cpp

    r644 r906  
    4242
    4343#if SVC_EXTENSION
    44   ParameterSetMap<TComVPS> ParameterSetManagerDecoder::m_vpsBuffer(MAX_NUM_VPS);
     44ParameterSetMap<TComVPS> ParameterSetManagerDecoder::m_vpsBuffer(MAX_NUM_VPS);
     45ParameterSetMap<TComSPS> ParameterSetManagerDecoder::m_spsBuffer(MAX_NUM_SPS);
     46ParameterSetMap<TComPPS> ParameterSetManagerDecoder::m_ppsBuffer(MAX_NUM_PPS);
    4547#endif
    4648
     
    144146  UInt uiTilesAcross   = rpcPic->getPicSym()->getNumColumnsMinus1()+1;
    145147  TComSlice*  pcSlice = rpcPic->getSlice(rpcPic->getCurrSliceIdx());
     148#if !WPP_FIX
    146149  Int  iNumSubstreams = pcSlice->getPPS()->getNumSubstreams();
     150#endif
    147151
    148152  // delete decoders if already allocated in previous slice
     
    191195  UInt uiWidthInLCUs  = rpcPic->getPicSym()->getFrameWidthInCU();
    192196  //UInt uiHeightInLCUs = rpcPic->getPicSym()->getFrameHeightInCU();
     197
     198#if WPP_FIX
     199  UInt uiTileCol;
     200  UInt uiTileLCUX;
     201  const Bool depSliceSegmentsEnabled = rpcPic->getSlice(rpcPic->getCurrSliceIdx())->getPPS()->getDependentSliceSegmentsEnabledFlag();
     202  const UInt startTileIdx=rpcPic->getPicSym()->getTileIdxMap(iStartCUAddr);
     203  TComTile *pCurrentTile=rpcPic->getPicSym()->getTComTile(startTileIdx);
     204  UInt uiTileStartLCU = pCurrentTile->getFirstCUAddr(); // Code tidy
     205
     206  // The first LCU of the slice is the first coded substream, but the global substream number, as calculated by getSubstreamForLCUAddr may be higher.
     207  // This calculates the common offset for all substreams in this slice.
     208  const UInt subStreamOffset=rpcPic->getSubstreamForLCUAddr(iStartCUAddr, true, pcSlice);
     209#else
    193210  UInt uiCol=0, uiLin=0, uiSubStrm=0;
    194211
     
    199216  Bool depSliceSegmentsEnabled = rpcPic->getSlice(rpcPic->getCurrSliceIdx())->getPPS()->getDependentSliceSegmentsEnabledFlag();
    200217  uiTileStartLCU = rpcPic->getPicSym()->getTComTile(rpcPic->getPicSym()->getTileIdxMap(iStartCUAddr))->getFirstCUAddr();
     218#endif
    201219  if( depSliceSegmentsEnabled )
    202220  {
     221#if WPP_FIX
     222    if( (!rpcPic->getSlice(rpcPic->getCurrSliceIdx())->isNextSlice()) && iStartCUAddr != uiTileStartLCU)  // Code tidy // Is this a dependent slice segment and not the start of a tile?
     223#else
    203224    if( (!rpcPic->getSlice(rpcPic->getCurrSliceIdx())->isNextSlice()) &&
    204225       iStartCUAddr != rpcPic->getPicSym()->getTComTile(rpcPic->getPicSym()->getTileIdxMap(iStartCUAddr))->getFirstCUAddr())
     226#endif
    205227    {
    206228      if(pcSlice->getPPS()->getEntropyCodingSyncEnabledFlag())
    207229      {
     230#if WPP_FIX
     231        uiTileCol = startTileIdx % (rpcPic->getPicSym()->getNumColumnsMinus1()+1); // Code tidy
     232#else
    208233        uiTileCol = rpcPic->getPicSym()->getTileIdxMap(iStartCUAddr) % (rpcPic->getPicSym()->getNumColumnsMinus1()+1);
     234#endif
    209235        m_pcBufferSbacDecoders[uiTileCol].loadContexts( CTXMem[1]  );//2.LCU
     236#if WPP_FIX
     237        if ( pCurrentTile->getTileWidth() < 2)
     238        {
     239          CTXMem[0]->loadContexts(pcSbacDecoder); // If tile width is less than 2, need to ensure CTX states get initialised to un-adapted CABAC. Set here, to load a few lines later (!)
     240        }
     241#else
    210242        if ( (iStartCUAddr%uiWidthInLCUs+1) >= uiWidthInLCUs  )
    211243        {
     
    217249          }
    218250        }
     251#endif
    219252      }
    220253      pcSbacDecoder->loadContexts(CTXMem[0] ); //end of depSlice-1
     254#if WPP_FIX
     255      pcSbacDecoders[0].loadContexts(pcSbacDecoder); // The first substream used for the slice will always be 0. (The original code was equivalent)
     256#else
    221257      pcSbacDecoders[uiSubStrm].loadContexts(pcSbacDecoder);
     258#endif
    222259    }
    223260    else
     
    237274    uiTileStartLCU = rpcPic->getPicSym()->getTComTile(rpcPic->getPicSym()->getTileIdxMap(iCUAddr))->getFirstCUAddr();
    238275    uiTileLCUX = uiTileStartLCU % uiWidthInLCUs;
     276#if WPP_FIX
     277    UInt uiCol     = iCUAddr % uiWidthInLCUs;
     278    UInt uiSubStrm=rpcPic->getSubstreamForLCUAddr(iCUAddr, true, pcSlice)-subStreamOffset;
     279#else
    239280    uiCol     = iCUAddr % uiWidthInLCUs;
    240281    // The 'line' is now relative to the 1st line in the slice, not the 1st line in the picture.
    241282    uiLin     = (iCUAddr/uiWidthInLCUs)-(iStartCUAddr/uiWidthInLCUs);
     283#endif
    242284    // inherit from TR if necessary, select substream to use.
    243285    if( (pcSlice->getPPS()->getNumSubstreams() > 1) || ( depSliceSegmentsEnabled  && (uiCol == uiTileLCUX)&&(pcSlice->getPPS()->getEntropyCodingSyncEnabledFlag()) ))
    244286    {
     287#if !WPP_FIX
    245288      // independent tiles => substreams are "per tile".  iNumSubstreams has already been multiplied.
    246289      iNumSubstreamsPerTile = iNumSubstreams/rpcPic->getPicSym()->getNumTiles();
    247290      uiSubStrm = rpcPic->getPicSym()->getTileIdxMap(iCUAddr)*iNumSubstreamsPerTile
    248291                  + uiLin%iNumSubstreamsPerTile;
     292#endif
    249293      m_pcEntropyDecoder->setBitstream( ppcSubstreams[uiSubStrm] );
    250294      // Synchronize cabac probabilities with upper-right LCU if it's available and we're at the start of a line.
     
    278322      pcSbacDecoder->load(&pcSbacDecoders[uiSubStrm]);  //this load is used to simplify the code (avoid to change all the call to pcSbacDecoders)
    279323    }
     324#if !WPP_FIX
    280325    else if ( pcSlice->getPPS()->getNumSubstreams() <= 1 )
    281326    {
     
    283328      iNumSubstreamsPerTile = 1;
    284329    }
     330#endif
    285331
    286332    if ( (iCUAddr == rpcPic->getPicSym()->getTComTile(rpcPic->getPicSym()->getTileIdxMap(iCUAddr))->getFirstCUAddr()) && // 1st in tile.
     
    397443
    398444ParameterSetManagerDecoder::ParameterSetManagerDecoder()
    399 #if SVC_EXTENSION
    400 : m_spsBuffer(MAX_NUM_SPS)
    401 , m_ppsBuffer(MAX_NUM_PPS)
    402 #else
     445#if !SVC_EXTENSION
    403446: m_vpsBuffer(MAX_NUM_VPS)
    404447, m_spsBuffer(MAX_NUM_SPS)
  • trunk/source/Lib/TLibDecoder/TDecSlice.h

    r644 r906  
    110110#if SVC_EXTENSION
    111111  static ParameterSetMap<TComVPS> m_vpsBuffer;
     112  static ParameterSetMap<TComSPS> m_spsBuffer;
     113  static ParameterSetMap<TComPPS> m_ppsBuffer;
    112114#else
    113115  ParameterSetMap<TComVPS> m_vpsBuffer;
    114 #endif
    115116  ParameterSetMap<TComSPS> m_spsBuffer;
    116117  ParameterSetMap<TComPPS> m_ppsBuffer;
     118#endif
    117119};
    118120
  • trunk/source/Lib/TLibDecoder/TDecTop.cpp

    r815 r906  
    4343UInt  TDecTop::m_uiPrevLayerId = MAX_UINT;
    4444Bool  TDecTop::m_bFirstSliceInSequence = true;
     45#if POC_RESET_RESTRICTIONS
     46Bool  TDecTop::m_checkPocRestrictionsForCurrAu       = false;
     47Int   TDecTop::m_pocResetIdcOrCurrAu                 = -1;
     48Bool  TDecTop::m_baseLayerIdrFlag                    = false;
     49Bool  TDecTop::m_baseLayerPicPresentFlag             = false;
     50Bool  TDecTop::m_baseLayerIrapFlag                   = false;
     51Bool  TDecTop::m_nonBaseIdrPresentFlag               = false;
     52Int   TDecTop::m_nonBaseIdrType                      = -1;
     53Bool  TDecTop::m_picNonIdrWithRadlPresentFlag        = false;
     54Bool  TDecTop::m_picNonIdrNoLpPresentFlag            = false;
     55#endif
     56#if POC_RESET_VALUE_RESTRICTION
     57Int   TDecTop::m_crossLayerPocResetPeriodId          = -1;
     58Int   TDecTop::m_crossLayerPocResetIdc               = -1;
     59#endif
    4560#endif
    4661
     
    7489  memset(m_cIlpPic, 0, sizeof(m_cIlpPic));
    7590#endif
    76 #if AVC_SYNTAX || SYNTAX_OUTPUT
    77   m_pBLSyntaxFile = NULL;
    78 #endif
    7991  m_prevSliceSkipped = false;
    8092  m_skippedPOC = 0;
     
    105117#endif
    106118
    107 #if Q0074_SEI_COLOR_MAPPING
    108   m_ColorMapping = new TDecColorMapping();
     119#if POC_RESET_RESTRICTIONS
     120  resetPocRestrictionCheckParameters();
     121#endif
     122#if P0297_VPS_POC_LSB_ALIGNED_FLAG
     123  m_pocResettingFlag        = false;
     124  m_pocDecrementedInDPBFlag = false;
    109125#endif
    110126}
     
    112128TDecTop::~TDecTop()
    113129{
    114 #if Q0078_ADD_LAYER_SETS
    115   for (Int psId = 0; psId < MAX_NUM_SPS; psId++)
    116   {
    117     TComSPS* sps = m_parameterSetManagerDecoder.getSPS(psId);
    118     if (sps != NULL)
    119     {
    120       // Remove parameter set from other layers to prevent multiple deletes of the same object
    121       for (Int lId = 0; lId < m_numLayer; lId++)
    122       {
    123         if (m_ppcTDecTop[lId] != this)
    124         {
    125           m_parameterSetManagerDecoder.removeSPS(psId);
    126         }
    127       }
    128     }
    129   }
    130   for (Int psId = 0; psId < MAX_NUM_PPS; psId++)
    131   {
    132     TComPPS* pps = m_parameterSetManagerDecoder.getPPS(psId);
    133     if (pps != NULL)
    134     {
    135       // Remove parameter set from other layers to prevent multiple deletes of the same object
    136       for (Int lId = 0; lId < m_numLayer; lId++)
    137       {
    138         if (m_ppcTDecTop[lId] != this)
    139         {
    140           m_parameterSetManagerDecoder.removePPS(psId);
    141         }
    142       }
    143     }
    144   }
    145 #endif
    146130#if ENC_DEC_TRACE
    147131  fclose( g_hTrace );
     
    154138    m_pColorMappedPic = NULL;
    155139  }
    156 #endif
    157 #if Q0074_SEI_COLOR_MAPPING
    158   if ( m_ColorMapping )  delete m_ColorMapping;
    159140#endif
    160141}
     
    188169      m_cIlpPic[i] = NULL;
    189170    }
    190   }   
     171  }
    191172#endif
    192173}
     
    237218
    238219    Int  numReorderPics[MAX_TLAYER];
     220#if R0156_CONF_WINDOW_IN_REP_FORMAT
     221    Window &conformanceWindow = slice->getConformanceWindow();
     222#else
    239223    Window &conformanceWindow = pcSPS->getConformanceWindow();
     224#endif
    240225    Window defaultDisplayWindow = pcSPS->getVuiParametersPresentFlag() ? pcSPS->getVuiParameters()->getDefaultDisplayWindow() : Window();
    241226
     
    326311{
    327312  Int  numReorderPics[MAX_TLAYER];
     313#if R0156_CONF_WINDOW_IN_REP_FORMAT
     314  Window &conformanceWindow = pcSlice->getConformanceWindow();
     315#else
    328316  Window &conformanceWindow = pcSlice->getSPS()->getConformanceWindow();
     317#endif
    329318  Window defaultDisplayWindow = pcSlice->getSPS()->getVuiParametersPresentFlag() ? pcSlice->getSPS()->getVuiParameters()->getDefaultDisplayWindow() : Window();
    330319
     
    362351#else
    363352    m_iMaxRefPicNum = pcSlice->getVPS()->getMaxVpsDecPicBufferingMinus1( getCommonDecoderParams()->getTargetOutputLayerSetIdx(), pcSlice->getLayerId(), pcSlice->getTLayer() ) + 1; // m_uiMaxDecPicBuffering has the space for the picture currently being decoded
     353    //TODO: HENDRY -- Do the checking here.
    364354#endif
    365355  }
     
    381371      for(UInt i = 0; i < pcSlice->getVPS()->getNumDirectRefLayers( m_layerId ); i++ )
    382372      {
     373#if MOVE_SCALED_OFFSET_TO_PPS
     374#if O0098_SCALED_REF_LAYER_ID
     375        const Window scalEL = pcSlice->getPPS()->getScaledRefLayerWindowForLayer(pcSlice->getVPS()->getRefLayerId(m_layerId, i));
     376#else
     377        const Window scalEL = pcSlice->getPPS()->getScaledRefLayerWindow(i);
     378#endif
     379#else
    383380#if O0098_SCALED_REF_LAYER_ID
    384381        const Window scalEL = pcSlice->getSPS()->getScaledRefLayerWindowForLayer(pcSlice->getVPS()->getRefLayerId(m_layerId, i));
     
    386383        const Window scalEL = pcSlice->getSPS()->getScaledRefLayerWindow(i);
    387384#endif
     385#endif
     386#if REF_REGION_OFFSET
     387        const Window refEL = pcSlice->getPPS()->getRefLayerWindowForLayer(pcSlice->getVPS()->getRefLayerId(m_layerId, i));
     388#if RESAMPLING_FIX
     389        Bool equalOffsets = scalEL.hasEqualOffset(refEL);
     390#if R0209_GENERIC_PHASE
     391        Bool zeroPhase = pcSlice->getPPS()->hasZeroResamplingPhase(pcSlice->getVPS()->getRefLayerId(m_layerId, i));
     392#endif
     393#else
     394        Bool zeroOffsets = ( scalEL.getWindowLeftOffset() == 0 && scalEL.getWindowRightOffset() == 0 && scalEL.getWindowTopOffset() == 0 && scalEL.getWindowBottomOffset() == 0
     395                             && refEL.getWindowLeftOffset() == 0 && refEL.getWindowRightOffset() == 0 && refEL.getWindowTopOffset() == 0 && refEL.getWindowBottomOffset() == 0 );
     396#endif
     397#else
    388398        Bool zeroOffsets = ( scalEL.getWindowLeftOffset() == 0 && scalEL.getWindowRightOffset() == 0 && scalEL.getWindowTopOffset() == 0 && scalEL.getWindowBottomOffset() == 0 );
     399#endif
    389400
    390401#if VPS_EXTN_DIRECT_REF_LAYERS
     
    400411        Bool sameBitDepths = ( g_bitDepthYLayer[m_layerId] == g_bitDepthYLayer[refLayerId] ) && ( g_bitDepthCLayer[m_layerId] == g_bitDepthCLayer[refLayerId] );
    401412
    402         if( pcPicYuvRecBase->getWidth() != pcSlice->getPicWidthInLumaSamples() || pcPicYuvRecBase->getHeight() != pcSlice->getPicHeightInLumaSamples() || !zeroOffsets || !sameBitDepths
     413#if REF_IDX_MFM
     414        if( pcPicYuvRecBase->getWidth() == pcSlice->getPicWidthInLumaSamples() && pcPicYuvRecBase->getHeight() == pcSlice->getPicHeightInLumaSamples() && equalOffsets && zeroPhase )
     415        {
     416          rpcPic->setEqualPictureSizeAndOffsetFlag( i, true );
     417        }
     418
     419        if( !rpcPic->equalPictureSizeAndOffsetFlag(i) || !sameBitDepths
     420#else
     421        if( pcPicYuvRecBase->getWidth() != pcSlice->getPicWidthInLumaSamples() || pcPicYuvRecBase->getHeight() != pcSlice->getPicHeightInLumaSamples() || !sameBitDepths
     422#if REF_REGION_OFFSET && RESAMPLING_FIX
     423          || !equalOffsets
     424#if R0209_GENERIC_PHASE
     425          || !zeroPhase
     426#endif
     427#else
     428          || !zeroOffsets
     429#endif
     430#endif
    403431#if Q0048_CGS_3D_ASYMLUT
    404432          || pcSlice->getPPS()->getCGSFlag() > 0
     
    409437          )
    410438#else
    411         if(pcPicYuvRecBase->getWidth() != pcSlice->getPicWidthInLumaSamples() || pcPicYuvRecBase->getHeight() != pcSlice->getPicHeightInLumaSamples() || !zeroOffsets )
    412 #endif
    413 #else
    414         if(pcPicYuvRecBase->getWidth() != pcSlice->getSPS()->getPicWidthInLumaSamples() || pcPicYuvRecBase->getHeight() != pcSlice->getSPS()->getPicHeightInLumaSamples() || !zeroOffsets )
     439        if(pcPicYuvRecBase->getWidth() != pcSlice->getPicWidthInLumaSamples() || pcPicYuvRecBase->getHeight() != pcSlice->getPicHeightInLumaSamples()
     440#if REF_REGION_OFFSET && RESAMPLING_FIX
     441          || !equalOffsets
     442#if R0209_GENERIC_PHASE
     443          || !zeroPhase
     444#endif
     445#else
     446          || !zeroOffsets
     447#endif
     448        )
     449#endif
     450#else
     451        if(pcPicYuvRecBase->getWidth() != pcSlice->getSPS()->getPicWidthInLumaSamples() || pcPicYuvRecBase->getHeight() != pcSlice->getSPS()->getPicHeightInLumaSamples()
     452#if REF_REGION_OFFSET && RESAMPLING_FIX
     453          || !equalOffsets
     454#if R0209_GENERIC_PHASE
     455          || !zeroPhase
     456#endif
     457#else
     458          || !zeroOffsets
     459#endif
     460        )
    415461#endif
    416462        {
     
    522568  m_cGopDecoder.filterPicture(pcPic);
    523569
    524 #if SYNTAX_OUTPUT
    525   pcPic->wrireBLSyntax( getBLSyntaxFile(), SYNTAX_BYTES );
    526 #endif
    527570  TComSlice::sortPicList( m_cListPic ); // sorting for application output
    528571  poc                 = pcPic->getSlice(m_uiSliceIdx-1)->getPOC();
     
    713756
    714757    // When avc_base_layer_flag is equal to 1, it is a requirement of bitstream conformance that the value of sps_scaling_list_ref_layer_id shall be greater than 0
     758#if VPS_AVC_BL_FLAG_REMOVAL
     759    if( activeVPS->getNonHEVCBaseLayerFlag() )
     760#else
    715761    if( activeVPS->getAvcBaseLayerFlag() )
     762#endif
    716763    {
    717764      assert( refLayerId > 0 );
     
    742789
    743790    // When avc_base_layer_flag is equal to 1, it is a requirement of bitstream conformance that the value of sps_scaling_list_ref_layer_id shall be greater than 0
     791#if VPS_AVC_BL_FLAG_REMOVAL
     792    if( activeVPS->getNonHEVCBaseLayerFlag() )
     793#else
    744794    if( activeVPS->getAvcBaseLayerFlag() )
     795#endif
    745796    {
    746797      assert( refLayerId > 0 );
     
    768819
    769820#if AVC_BASE
     821#if VPS_AVC_BL_FLAG_REMOVAL
     822  if( activeVPS->getNonHEVCBaseLayerFlag() )
     823#else
    770824  if( activeVPS->getAvcBaseLayerFlag() )
     825#endif
    771826  {
    772827    TComPic* pBLPic = (*m_ppcTDecTop[0]->getListPic()->begin());
     
    777832
    778833      Int  numReorderPics[MAX_TLAYER];
     834#if !R0156_CONF_WINDOW_IN_REP_FORMAT
    779835      Window conformanceWindow;
     836#endif
    780837      Window defaultDisplayWindow;
    781838
     839#if R0156_CONF_WINDOW_IN_REP_FORMAT
    782840#if AUXILIARY_PICTURES
    783 #if AVC_SYNTAX
    784       pBLPic->create( repFormat->getPicWidthVpsInLumaSamples(), repFormat->getPicHeightVpsInLumaSamples(), repFormat->getChromaFormatVpsIdc(), activeSPS->getMaxCUWidth(), activeSPS->getMaxCUHeight(), activeSPS->getMaxCUDepth(), conformanceWindow, defaultDisplayWindow, numReorderPics, activeSPS, true);
    785 #else
     841      pBLPic->create( repFormat->getPicWidthVpsInLumaSamples(), repFormat->getPicHeightVpsInLumaSamples(), repFormat->getChromaFormatVpsIdc(), activeSPS->getMaxCUWidth(), activeSPS->getMaxCUHeight(), activeSPS->getMaxCUDepth(), repFormat->getConformanceWindowVps(), defaultDisplayWindow, numReorderPics, NULL, true);
     842#else
     843      pBLPic->create( repFormat->getPicWidthVpsInLumaSamples(), repFormat->getPicHeightVpsInLumaSamples(), activeSPS->getMaxCUWidth(), activeSPS->getMaxCUHeight(), activeSPS->getMaxCUDepth(), repFormat->getConformanceWindowVps(), defaultDisplayWindow, numReorderPics, NULL, true);
     844#endif
     845#else
     846#if AUXILIARY_PICTURES
    786847      pBLPic->create( repFormat->getPicWidthVpsInLumaSamples(), repFormat->getPicHeightVpsInLumaSamples(), repFormat->getChromaFormatVpsIdc(), activeSPS->getMaxCUWidth(), activeSPS->getMaxCUHeight(), activeSPS->getMaxCUDepth(), conformanceWindow, defaultDisplayWindow, numReorderPics, NULL, true);
    787 #endif
    788 #else
    789 #if AVC_SYNTAX
    790       pBLPic->create( repFormat->getPicWidthVpsInLumaSamples(), repFormat->getPicHeightVpsInLumaSamples(), activeSPS->getMaxCUWidth(), activeSPS->getMaxCUHeight(), activeSPS->getMaxCUDepth(), conformanceWindow, defaultDisplayWindow, numReorderPics, activeSPS, true);
    791848#else
    792849      pBLPic->create( repFormat->getPicWidthVpsInLumaSamples(), repFormat->getPicHeightVpsInLumaSamples(), activeSPS->getMaxCUWidth(), activeSPS->getMaxCUHeight(), activeSPS->getMaxCUDepth(), conformanceWindow, defaultDisplayWindow, numReorderPics, NULL, true);
     
    805862
    806863#if P0312_VERT_PHASE_ADJ
     864#if MOVE_SCALED_OFFSET_TO_PPS
     865  if( activeVPS->getVpsVuiVertPhaseInUseFlag() == 0 )
     866  {   
     867    for(Int i = 0; i < activePPS->getNumScaledRefLayerOffsets(); i++)
     868    {
     869      UInt scaledRefLayerId = activePPS->getScaledRefLayerId(i);
     870      if( activePPS->getVertPhasePositionEnableFlag( scaledRefLayerId ) )
     871      {
     872        printf("\nWarning: LayerId = %d: vert_phase_position_enable_flag[%d] = 1, however indication vert_phase_position_in_use_flag = 0\n", m_layerId, scaledRefLayerId );
     873        break;
     874      }
     875    }
     876  }
     877#else
    807878  if( activeVPS->getVpsVuiVertPhaseInUseFlag() == 0 )
    808879  {   
     
    817888    }
    818889  }
     890#endif
    819891#endif
    820892
     
    868940  pps->setSPS(sps);
    869941#if REPN_FORMAT_IN_VPS
    870   pps->setNumSubstreams(pps->getEntropyCodingSyncEnabledFlag() ? ((sps->getPicHeightInLumaSamples() + sps->getMaxCUHeight() - 1) / sps->getMaxCUHeight()) * (pps->getNumColumnsMinus1() + 1) : 1);
    871 #else
    872   pps->setNumSubstreams(pps->getEntropyCodingSyncEnabledFlag() ? ((sps->getPicHeightInLumaSamples() + sps->getMaxCUHeight() - 1) / sps->getMaxCUHeight()) * (pps->getNumColumnsMinus1() + 1) : 1);
     942  pps->setNumSubstreams(pps->getEntropyCodingSyncEnabledFlag() ? ((sps->getPicHeightInLumaSamples() + sps->getMaxCUHeight() - 1) / sps->getMaxCUHeight()) * (pps->getNumTileColumnsMinus1() + 1) : 1);
     943#else
     944  pps->setNumSubstreams(pps->getEntropyCodingSyncEnabledFlag() ? ((sps->getPicHeightInLumaSamples() + sps->getMaxCUHeight() - 1) / sps->getMaxCUHeight()) * (pps->getNumTileColumnsMinus1() + 1) : 1);
    873945#endif
    874946  pps->setMinCuDQPSize( sps->getMaxCUWidth() >> ( pps->getMaxCuDQPDepth()) );
     
    885957  g_uiMaxCUDepth  = sps->getMaxCUDepth();
    886958  g_uiAddCUDepth  = max (0, sps->getLog2MinCodingBlockSize() - (Int)sps->getQuadtreeTULog2MinSize() );
    887 
    888 #if Q0074_SEI_COLOR_MAPPING
    889   for(Int compID=0; compID<3; compID++)
    890   {
    891     m_ColorMapping->setColorMapping( compID ? g_bitDepthC : g_bitDepthY, compID );
    892   }
    893 #endif
    894959
    895960  for (Int i = 0; i < sps->getLog2DiffMaxMinCodingBlockSize(); i++)
     
    9531018
    9541019  m_apcSlicePilot->setNalUnitType(nalu.m_nalUnitType);
     1020#if POC_RESET_RESTRICTIONS
     1021  m_apcSlicePilot->setTLayer( nalu.m_temporalId );
     1022#endif
    9551023  Bool nonReferenceFlag = (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_TRAIL_N ||
    9561024                           m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_N   ||
     
    10181086  }
    10191087
     1088  //TODO: HENDRY -- Probably do the checking for max number of positive and negative pics here
     1089
     1090
    10201091  //For inference of PicOutputFlag
    10211092  if (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_R)
     
    11091180  }
    11101181#endif
     1182
    11111183#if POC_RESET_IDC_DECODER
    11121184  if( m_parseIdc != -1 ) // Second pass for a POC resetting picture
     
    11291201    if(( m_layerId < m_uiPrevLayerId) ||( ( m_layerId == m_uiPrevLayerId) && bNewPOC)) // Decoding a lower layer than or same layer as previous - mark all earlier pictures as not in current AU
    11301202    {
     1203#if POC_RESET_RESTRICTIONS
     1204      // New access unit; reset all variables related to POC reset restrictions
     1205      resetPocRestrictionCheckParameters();
     1206#endif
    11311207      markAllPicsAsNoCurrAu();
    1132     }
     1208#if P0297_VPS_POC_LSB_ALIGNED_FLAG
     1209      for (UInt i = 0; i < MAX_LAYERS; i++)
     1210      {
     1211        m_ppcTDecTop[i]->m_pocDecrementedInDPBFlag = false;
     1212      }
     1213#endif
     1214    }
     1215
     1216
     1217#if P0297_VPS_POC_LSB_ALIGNED_FLAG
     1218    m_pocResettingFlag = false;
     1219
     1220    if (m_apcSlicePilot->getPocResetIdc() != 0)
     1221    {
     1222      if (m_apcSlicePilot->getVPS()->getVpsPocLsbAlignedFlag())
     1223      {
     1224        m_pocResettingFlag = true;
     1225      }
     1226      else if (m_pocDecrementedInDPBFlag)
     1227      {
     1228        m_pocResettingFlag = false;
     1229      }
     1230      else
     1231      {
     1232        m_pocResettingFlag = true;
     1233      }
     1234    }
     1235#endif
    11331236
    11341237    if( m_apcSlicePilot->getPocResetIdc() && m_apcSlicePilot->getSliceIdx() == 0 )
     
    11411244        m_parseIdc = 0;
    11421245      }
     1246#if POC_RESET_VALUE_RESTRICTION
     1247      // Check if the POC Reset period ID matches with the Reset Period ID
     1248      if( pocResetPeriodId == m_crossLayerPocResetPeriodId )
     1249      {
     1250        // If matching, and current poc_reset_idc = 3, then the values should match
     1251        if( m_apcSlicePilot->getPocResetIdc() == 3 )
     1252        {
     1253          assert( ( m_apcSlicePilot->getFullPocResetFlag() == false && m_crossLayerPocResetIdc == 1 ) ||
     1254                  ( m_apcSlicePilot->getFullPocResetFlag() == true  && m_crossLayerPocResetIdc == 2 ) );
     1255        }
     1256      }
     1257      else
     1258      {
     1259        // This is the first picture of a POC resetting access unit
     1260        m_crossLayerPocResetPeriodId = pocResetPeriodId;
     1261        if( m_apcSlicePilot->getPocResetIdc() == 1 || m_apcSlicePilot->getPocResetIdc() == 2 )
     1262        {
     1263          m_crossLayerPocResetIdc = m_apcSlicePilot->getPocResetIdc();
     1264        }
     1265        else
     1266        { // poc_reset_idc = 3
     1267          // In this case, the entire POC resetting access unit has been lost.
     1268          // Need more checking to ensure poc_reset_idc = 3 works.
     1269          assert ( 0 );
     1270        }
     1271      }
     1272#endif
    11431273    }
    11441274    else
    11451275    {
    11461276      m_parseIdc = 3; // Proceed to decoding POC and RPS
    1147     } 
     1277    }
    11481278  }
    11491279#endif
     
    11511281#if ALIGNED_BUMPING
    11521282#if POC_RESET_IDC_DECODER
     1283
     1284#if P0297_VPS_POC_LSB_ALIGNED_FLAG
     1285  UInt affectedLayerList[MAX_NUM_LAYER_IDS];
     1286  Int  numAffectedLayers;
     1287
     1288  affectedLayerList[0] = m_apcSlicePilot->getLayerId();
     1289  numAffectedLayers = 1;
     1290
     1291  if (m_apcSlicePilot->getVPS()->getVpsPocLsbAlignedFlag())
     1292  {
     1293    for (UInt j = 0; j < m_apcSlicePilot->getVPS()->getNumPredictedLayers(m_apcSlicePilot->getLayerId()); j++)
     1294    {
     1295      affectedLayerList[j + 1] = m_apcSlicePilot->getVPS()->getPredictedLayerId(m_apcSlicePilot->getLayerId(), j);
     1296    }
     1297    numAffectedLayers = m_apcSlicePilot->getVPS()->getNumPredictedLayers(m_apcSlicePilot->getLayerId()) + 1;
     1298  }
     1299#endif
     1300
    11531301  //if(  (bNewPOC || m_layerId != m_uiPrevLayerId) && ( m_parseIdc != 1) )
    1154   if( m_parseIdc == 1 )
     1302#if P0297_VPS_POC_LSB_ALIGNED_FLAG
     1303  if (m_parseIdc == 1 && m_pocResettingFlag)
     1304#else
     1305  if (m_parseIdc == 1)
     1306#endif
    11551307  {
    11561308    // Invoke output of pictures if the current picture is a POC reset picture
     
    12031355    Int deltaPocVal  =  pocMsbDelta + pocLsbDelta;
    12041356
     1357#if P0297_VPS_POC_LSB_ALIGNED_FLAG
     1358    for (UInt layerIdx = 0; layerIdx < numAffectedLayers; layerIdx++)
     1359    {
     1360      if (!m_ppcTDecTop[affectedLayerList[layerIdx]]->m_pocDecrementedInDPBFlag)
     1361      {
     1362        m_ppcTDecTop[affectedLayerList[layerIdx]]->m_pocDecrementedInDPBFlag = true;
     1363        TComList<TComPic*>::iterator  iterPic = m_ppcTDecTop[affectedLayerList[layerIdx]]->getListPic()->begin();
     1364        while (iterPic != m_ppcTDecTop[affectedLayerList[layerIdx]]->getListPic()->end())
     1365#else
    12051366    //Reset all POC for DPB -> basically do it for each slice in the picutre
    12061367    TComList<TComPic*>::iterator  iterPic = m_cListPic.begin(); 
     
    12081369    // Iterate through all picture in DPB
    12091370    while( iterPic != m_cListPic.end() )
     1371#endif
    12101372    {
    12111373      TComPic *dpbPic = *iterPic;
    12121374      // Check if the picture pointed to by iterPic is either used for reference or
    12131375      // needed for output, are in the same layer, and not the current picture.
    1214       if( /*  ( ( dpbPic->getSlice(0)->isReferenced() ) || ( dpbPic->getOutputMark() ) )
     1376#if P0297_VPS_POC_LSB_ALIGNED_FLAG
     1377      assert(dpbPic->getLayerId() == affectedLayerList[layerIdx]);
     1378      if ( (dpbPic->getReconMark()) && (dpbPic->getPicSym()->getSlice(0)->getPicOutputFlag()) )
     1379#else
     1380      if ( /*  ( ( dpbPic->getSlice(0)->isReferenced() ) || ( dpbPic->getOutputMark() ) )
    12151381          &&*/ ( dpbPic->getLayerId() == m_apcSlicePilot->getLayerId() )
    12161382            && ( dpbPic->getReconMark() ) && ( dpbPic->getPicSym()->getSlice(0)->getPicOutputFlag() ))
     1383#endif
    12171384      {
    12181385        for(Int i = dpbPic->getNumAllocatedSlice()-1; i >= 0; i--)
     
    12411408      iterPic++;
    12421409    }
     1410#if P0297_VPS_POC_LSB_ALIGNED_FLAG
     1411        // Update the value of pocCRA
     1412        m_ppcTDecTop[affectedLayerList[layerIdx]]->m_pocCRA -= deltaPocVal;
     1413      }
     1414    }
     1415#else
    12431416    // Update the value of pocCRA
    12441417    m_pocCRA -= deltaPocVal;
     1418#endif
    12451419
    12461420    // Update value of POCLastDisplay
     
    12501424  Int slicePicOrderCntLsb = m_apcSlicePilot->getPicOrderCntLsb();
    12511425
    1252   if( m_parseIdc == 1 || m_parseIdc == 2 ) // TODO This should be replaced by pocResettingFlag.
     1426#if P0297_VPS_POC_LSB_ALIGNED_FLAG
     1427  if (m_pocResettingFlag && (m_parseIdc == 1 || m_parseIdc == 2))
     1428#else
     1429  if (m_parseIdc == 1 || m_parseIdc == 2) // TODO This should be replaced by pocResettingFlag.
     1430#endif
    12531431  {
    12541432    // Set poc for current slice
     
    12961474        && !m_apcSlicePilot->getDiscardableFlag() )
    12971475    {
     1476#if P0297_VPS_POC_LSB_ALIGNED_FLAG
     1477      for (UInt i = 0; i < numAffectedLayers; i++)
     1478      {
     1479        m_ppcTDecTop[affectedLayerList[i]]->setPrevPicOrderCnt(m_apcSlicePilot->getPOC());
     1480      }
     1481#else
    12981482      this->setPrevPicOrderCnt( m_apcSlicePilot->getPOC() );
     1483#endif
    12991484    }
    13001485    else if ( m_apcSlicePilot->getPocResetIdc() == 3 )
    13011486    {
     1487#if P0297_VPS_POC_LSB_ALIGNED_FLAG
     1488      if (!m_firstPicInLayerDecodedFlag || (m_firstPicInLayerDecodedFlag && m_pocResettingFlag))
     1489      {
     1490        for (UInt i = 0; i < numAffectedLayers; i++)
     1491        {
     1492          m_ppcTDecTop[affectedLayerList[i]]->setPrevPicOrderCnt( m_apcSlicePilot->getFullPocResetFlag()
     1493                                                                  ? 0 : m_apcSlicePilot->getPocLsbVal() );
     1494        }
     1495      }
     1496#else
    13021497      this->setPrevPicOrderCnt( m_apcSlicePilot->getFullPocResetFlag()
    13031498                                            ? 0 : m_apcSlicePilot->getPocLsbVal() );
     1499#endif
    13041500    }
    13051501#else
     
    13241520#if POC_RESET_IDC_DECODER
    13251521  m_parseIdc = -1;
     1522#endif
     1523
     1524
     1525#if R0226_SLICE_TMVP
     1526  if ( m_apcSlicePilot->getTLayer() == 0 && m_apcSlicePilot->getEnableTMVPFlag() == 0 )
     1527  {
     1528    //update all pics in the DPB such that they cannot be used for TMPV ref
     1529    TComList<TComPic*>::iterator  iterRefPic = m_cListPic.begin(); 
     1530    while( iterRefPic != m_cListPic.end() )
     1531    {
     1532      TComPic *refPic = *iterRefPic;
     1533      if( ( refPic->getLayerId() == m_apcSlicePilot->getLayerId() ) && refPic->getReconMark() )
     1534      {
     1535        for(Int i = refPic->getNumAllocatedSlice()-1; i >= 0; i--)
     1536        {
     1537
     1538          TComSlice *refSlice = refPic->getSlice(i);
     1539          refSlice->setAvailableForTMVPRefFlag( false );
     1540        }
     1541      }
     1542      iterRefPic++;
     1543    }
     1544  }
     1545  m_apcSlicePilot->setAvailableForTMVPRefFlag( true );
    13261546#endif
    13271547
     
    14831703  {
    14841704#if AVC_BASE
     1705#if VPS_AVC_BL_FLAG_REMOVAL
     1706    if( m_layerId == 1 && m_parameterSetManagerDecoder.getPrefetchedVPS(0)->getNonHEVCBaseLayerFlag() )
     1707#else
    14851708    if( m_layerId == 1 && m_parameterSetManagerDecoder.getPrefetchedVPS(0)->getAvcBaseLayerFlag() )
     1709#endif
    14861710    {
    14871711      TComPic* pBLPic = (*m_ppcTDecTop[0]->getListPic()->begin());
     
    16111835
    16121836#if POC_RESET_IDC_DECODER
    1613   pcPic->setCurrAuFlag( true );
     1837    pcPic->setCurrAuFlag( true );
     1838#if POC_RESET_RESTRICTIONS
     1839    if( pcPic->getLayerId() > 0 && m_apcSlicePilot->isIDR() && !m_nonBaseIdrPresentFlag )
     1840    {
     1841      // IDR picture with nuh_layer_id > 0 present
     1842      m_nonBaseIdrPresentFlag = true;
     1843      m_nonBaseIdrType = (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL);
     1844    }
     1845    else
     1846    {
     1847      if( m_apcSlicePilot->getNalUnitType() != NAL_UNIT_CODED_SLICE_IDR_W_RADL )
     1848      {
     1849        // Picture with nal_unit_type not equal IDR_W_RADL present
     1850        m_picNonIdrWithRadlPresentFlag = true;
     1851      }
     1852      if( m_apcSlicePilot->getNalUnitType() != NAL_UNIT_CODED_SLICE_IDR_N_LP )
     1853      {
     1854        // Picture with nal_unit_type not equal IDR_N_LP present
     1855        m_picNonIdrNoLpPresentFlag = true;
     1856      }
     1857    }
     1858    if( !m_checkPocRestrictionsForCurrAu )  // Will be true for the first slice/picture of the AU
     1859    {
     1860      m_checkPocRestrictionsForCurrAu = true;
     1861      m_pocResetIdcOrCurrAu = m_apcSlicePilot->getPocResetIdc();
     1862      if( pcPic->getLayerId() == 0 )
     1863      {
     1864        // Base layer picture is present
     1865        m_baseLayerPicPresentFlag = true;
     1866        if( m_apcSlicePilot->isIRAP() )
     1867        {
     1868          // Base layer picture is IRAP
     1869          m_baseLayerIrapFlag = true;
     1870        }
     1871        if( m_apcSlicePilot->isIDR() )
     1872        {
     1873          // Base layer picture is IDR
     1874          m_baseLayerIdrFlag = true;
     1875        }
     1876        else
     1877        {
     1878          if( m_apcSlicePilot->getVPS()->getBaseLayerInternalFlag())
     1879          {
     1880            /* When the picture with nuh_layer_id equal to 0 in an access unit is not an IDR picture
     1881            and vps_base_layer_internal_flag is equal to 1, the value of poc_reset_idc shall not be equal to 2
     1882            for any picture in the access unit. */
     1883            assert( m_apcSlicePilot->getPocResetIdc() != 2 );
     1884          }
     1885        }
     1886      }
     1887    }
     1888    else
     1889    {
     1890      // The value of poc_reset_idc of all coded pictures that are present in the bitstream in an access unit shall be the same.
     1891      assert( m_pocResetIdcOrCurrAu == m_apcSlicePilot->getPocResetIdc() );
     1892
     1893      /* When the picture in an access unit with nuh_layer_id equal to 0 is an IRAP picture and vps_base_layer_internal_flag is equal to 1
     1894      and there is at least one other picture in the same access unit that is not an IRAP picture,
     1895      the value of poc_reset_idc shall be equal to 1 or 2 for all pictures in the access unit. */
     1896      if( m_baseLayerPicPresentFlag && m_baseLayerIrapFlag && !m_apcSlicePilot->isIRAP() && m_apcSlicePilot->getVPS()->getBaseLayerInternalFlag() )
     1897      {
     1898        assert( m_apcSlicePilot->getPocResetIdc() == 1 || m_apcSlicePilot->getPocResetIdc() == 2 );
     1899      }
     1900
     1901      /* When the picture with nuh_layer_id equal to 0 in an access unit is an IDR picture and
     1902      vps_base_layer_internal_flag is equal to 1 and there is at least one non-IDR picture in the same access unit,
     1903      the value of poc_reset_idc shall be equal to 2 for all pictures in the access unit. */
     1904      if( m_baseLayerPicPresentFlag && m_baseLayerIdrFlag && !m_apcSlicePilot->isIDR() && m_apcSlicePilot->getVPS()->getBaseLayerInternalFlag() )
     1905      {
     1906        assert( m_apcSlicePilot->getPocResetIdc() == 2 );
     1907      }
     1908
     1909      /* When there is at least one picture that has nuh_layer_id greater than 0 and that is an IDR picture
     1910      with a particular value of nal_unit_type in an access unit and there is at least one other coded picture
     1911      that is present in the bitstream in the same access unit with a different value of nal_unit_type,
     1912      the value of poc_reset_idc shall be equal to 1 or 2 for all pictures in the access unit. */
     1913      if( m_nonBaseIdrPresentFlag && (
     1914            ( m_nonBaseIdrType == 1 && m_picNonIdrWithRadlPresentFlag ) ||
     1915            ( m_nonBaseIdrType == 0 && m_picNonIdrNoLpPresentFlag )
     1916        ))
     1917      {
     1918        assert( m_apcSlicePilot->getPocResetIdc() == 1 || m_apcSlicePilot->getPocResetIdc() == 2 );
     1919      }
     1920    }
     1921#endif
    16141922#endif
    16151923
     
    16271935        isTff =  (pictureTiming->m_picStruct == 1);
    16281936      }
     1937
     1938#if R0226_CONSTRAINT_TMVP_SEI
     1939      // Check if any new temporal motion vector prediction constraints SEI has arrived
     1940      SEIMessages seiTMVPConstrainsList = extractSeisByType (m_SEIs, SEI::TMVP_CONSTRAINTS);
     1941      if (seiTMVPConstrainsList.size() > 0)
     1942      {
     1943        assert ( pcPic->getTLayer() == 0 );  //this SEI can present only for AU with Tid equal to 0
     1944        SEITMVPConstrains* tmvpConstraintSEI = (SEITMVPConstrains*) *(seiTMVPConstrainsList.begin());
     1945        if ( tmvpConstraintSEI->prev_pics_not_used_flag == 1 )
     1946        {
     1947          //update all pics in the DPB such that they cannot be used for TMPV ref
     1948          TComList<TComPic*>::iterator  iterRefPic = m_cListPic.begin(); 
     1949          while( iterRefPic != m_cListPic.end() )
     1950          {
     1951            TComPic *refPic = *iterRefPic;
     1952            if( ( refPic->getLayerId() == pcPic->getLayerId() ) && refPic->getReconMark() )
     1953            {
     1954              for(Int i = refPic->getNumAllocatedSlice()-1; i >= 0; i--)
     1955              {
     1956                TComSlice *refSlice = refPic->getSlice(i);
     1957                refSlice->setAvailableForTMVPRefFlag( false );
     1958              }
     1959            }
     1960            iterRefPic++;
     1961          }
     1962        }
     1963      }
     1964#endif
    16291965    }
    16301966   
     
    16652001  Bool bNextSlice     = pcSlice->isNextSlice();
    16662002
    1667   UInt uiCummulativeTileWidth;
    1668   UInt uiCummulativeTileHeight;
    1669   UInt i, j, p;
    1670 
    1671   //set NumColumnsMins1 and NumRowsMinus1
    1672   pcPic->getPicSym()->setNumColumnsMinus1( pcSlice->getPPS()->getNumColumnsMinus1() );
    1673   pcPic->getPicSym()->setNumRowsMinus1( pcSlice->getPPS()->getNumRowsMinus1() );
    1674 
    1675   //create the TComTileArray
    1676   pcPic->getPicSym()->xCreateTComTileArray();
    1677 
    1678   if( pcSlice->getPPS()->getUniformSpacingFlag() )
    1679   {
    1680     //set the width for each tile
    1681     for(j=0; j < pcPic->getPicSym()->getNumRowsMinus1()+1; j++)
    1682     {
    1683       for(p=0; p < pcPic->getPicSym()->getNumColumnsMinus1()+1; p++)
    1684       {
    1685         pcPic->getPicSym()->getTComTile( j * (pcPic->getPicSym()->getNumColumnsMinus1()+1) + p )->
    1686           setTileWidth( (p+1)*pcPic->getPicSym()->getFrameWidthInCU()/(pcPic->getPicSym()->getNumColumnsMinus1()+1)
    1687           - (p*pcPic->getPicSym()->getFrameWidthInCU())/(pcPic->getPicSym()->getNumColumnsMinus1()+1) );
    1688       }
    1689     }
    1690 
    1691     //set the height for each tile
    1692     for(j=0; j < pcPic->getPicSym()->getNumColumnsMinus1()+1; j++)
    1693     {
    1694       for(p=0; p < pcPic->getPicSym()->getNumRowsMinus1()+1; p++)
    1695       {
    1696         pcPic->getPicSym()->getTComTile( p * (pcPic->getPicSym()->getNumColumnsMinus1()+1) + j )->
    1697           setTileHeight( (p+1)*pcPic->getPicSym()->getFrameHeightInCU()/(pcPic->getPicSym()->getNumRowsMinus1()+1)
    1698           - (p*pcPic->getPicSym()->getFrameHeightInCU())/(pcPic->getPicSym()->getNumRowsMinus1()+1) );   
    1699       }
    1700     }
    1701   }
    1702   else
    1703   {
    1704     //set the width for each tile
    1705     for(j=0; j < pcSlice->getPPS()->getNumRowsMinus1()+1; j++)
    1706     {
    1707       uiCummulativeTileWidth = 0;
    1708       for(i=0; i < pcSlice->getPPS()->getNumColumnsMinus1(); i++)
    1709       {
    1710         pcPic->getPicSym()->getTComTile(j * (pcSlice->getPPS()->getNumColumnsMinus1()+1) + i)->setTileWidth( pcSlice->getPPS()->getColumnWidth(i) );
    1711         uiCummulativeTileWidth += pcSlice->getPPS()->getColumnWidth(i);
    1712       }
    1713       pcPic->getPicSym()->getTComTile(j * (pcSlice->getPPS()->getNumColumnsMinus1()+1) + i)->setTileWidth( pcPic->getPicSym()->getFrameWidthInCU()-uiCummulativeTileWidth );
    1714     }
    1715 
    1716     //set the height for each tile
    1717     for(j=0; j < pcSlice->getPPS()->getNumColumnsMinus1()+1; j++)
    1718     {
    1719       uiCummulativeTileHeight = 0;
    1720       for(i=0; i < pcSlice->getPPS()->getNumRowsMinus1(); i++)
    1721       {
    1722         pcPic->getPicSym()->getTComTile(i * (pcSlice->getPPS()->getNumColumnsMinus1()+1) + j)->setTileHeight( pcSlice->getPPS()->getRowHeight(i) );
    1723         uiCummulativeTileHeight += pcSlice->getPPS()->getRowHeight(i);
    1724       }
    1725       pcPic->getPicSym()->getTComTile(i * (pcSlice->getPPS()->getNumColumnsMinus1()+1) + j)->setTileHeight( pcPic->getPicSym()->getFrameHeightInCU()-uiCummulativeTileHeight );
    1726     }
    1727   }
    1728 
    1729   pcPic->getPicSym()->xInitTiles();
     2003  UInt i;
     2004  pcPic->getPicSym()->initTiles(pcSlice->getPPS());
    17302005
    17312006  //generate the Coding Order Map and Inverse Coding Order Map
     
    17932068        UInt refLayerId = pcSlice->getVPS()->getRefLayerId(m_layerId, refLayerIdc);
    17942069#if AVC_BASE
     2070#if VPS_AVC_BL_FLAG_REMOVAL
     2071        if( refLayerId == 0 && m_parameterSetManagerDecoder.getActiveVPS()->getNonHEVCBaseLayerFlag() )
     2072#else
    17952073        if( refLayerId == 0 && m_parameterSetManagerDecoder.getActiveVPS()->getAvcBaseLayerFlag() )
     2074#endif
    17962075        {         
    17972076          TComPic* pic = *m_ppcTDecTop[0]->getListPic()->begin();
     
    18052084            continue;
    18062085          }
    1807 #if AVC_SYNTAX
    1808           TComPic* pBLPic = pcSlice->getBaseColPic(refLayerIdc);
    1809           if( pcSlice->getPOC() == 0 )
    1810           {
    1811             // initialize partition order.
    1812             UInt* piTmp = &g_auiZscanToRaster[0];
    1813             initZscanToRaster( pBLPic->getPicSym()->getMaxDepth() + 1, 1, 0, piTmp );
    1814             initRasterToZscan( pBLPic->getPicSym()->getMaxCUWidth(), pBLPic->getPicSym()->getMaxCUHeight(), pBLPic->getPicSym()->getMaxDepth() + 1 );
    1815           }     
    1816           pBLPic->getSlice( 0 )->initBaseLayerRPL( pcSlice );
    1817           pBLPic->readBLSyntax( m_ppcTDecTop[0]->getBLSyntaxFile(), SYNTAX_BYTES );
    1818 #endif
    18192086        }
    18202087        else
     
    18412108#endif
    18422109
     2110#if MOVE_SCALED_OFFSET_TO_PPS
     2111#if O0098_SCALED_REF_LAYER_ID
     2112        const Window &scalEL = pcSlice->getPPS()->getScaledRefLayerWindowForLayer(refLayerId);
     2113#else
     2114        const Window &scalEL = pcSlice->getPPS()->getScaledRefLayerWindow(refLayerIdc);
     2115#endif
     2116#else
    18432117#if O0098_SCALED_REF_LAYER_ID
    18442118        const Window &scalEL = pcSlice->getSPS()->getScaledRefLayerWindowForLayer(refLayerId);
     
    18462120        const Window &scalEL = pcSlice->getSPS()->getScaledRefLayerWindow(refLayerIdc);
    18472121#endif
    1848 
     2122#endif
     2123
     2124#if REF_REGION_OFFSET
     2125        const Window &windowRL = pcSlice->getPPS()->getRefLayerWindowForLayer(pcSlice->getVPS()->getRefLayerId(m_layerId, refLayerIdc));
     2126        Int widthBL   = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec()->getWidth() - windowRL.getWindowLeftOffset() - windowRL.getWindowRightOffset();
     2127        Int heightBL  = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec()->getHeight() - windowRL.getWindowTopOffset() - windowRL.getWindowBottomOffset();
     2128#else
    18492129        Int widthBL   = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec()->getWidth();
    18502130        Int heightBL  = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec()->getHeight();
     
    18552135        heightBL -= ( confBL.getWindowTopOffset() + confBL.getWindowBottomOffset() ) * TComSPS::getWinUnitY( chromaFormatIdc );
    18562136#endif
     2137#endif
    18572138        Int widthEL   = pcPic->getPicYuvRec()->getWidth()  - scalEL.getWindowLeftOffset() - scalEL.getWindowRightOffset();
    18582139        Int heightEL  = pcPic->getPicYuvRec()->getHeight() - scalEL.getWindowTopOffset()  - scalEL.getWindowBottomOffset();
    18592140
     2141#if RESAMPLING_FIX
     2142#if REF_REGION_OFFSET
     2143        // conformance check: the values of RefLayerRegionWidthInSamplesY, RefLayerRegionHeightInSamplesY, ScaledRefRegionWidthInSamplesY and ScaledRefRegionHeightInSamplesY shall be greater than 0
     2144        assert(widthEL > 0 && heightEL > 0 && widthBL > 0 && widthEL > 0);
     2145
     2146        // conformance check: ScaledRefRegionWidthInSamplesY shall be greater or equal to RefLayerRegionWidthInSamplesY and ScaledRefRegionHeightInSamplesY shall be greater or equal to RefLayerRegionHeightInSamplesY
     2147        assert(widthEL >= widthBL && heightEL >= heightBL);
     2148
     2149#if R0209_GENERIC_PHASE
     2150        // conformance check: when ScaledRefRegionWidthInSamplesY is equal to RefLayerRegionWidthInSamplesY, PhaseHorY shall be equal to 0, when ScaledRefRegionWidthInSamplesC is equal to RefLayerRegionWidthInSamplesC, PhaseHorC shall be equal to 0, when ScaledRefRegionHeightInSamplesY is equal to RefLayerRegionHeightInSamplesY, PhaseVerY shall be equal to 0, and when ScaledRefRegionHeightInSamplesC is equal to RefLayerRegionHeightInSamplesC, PhaseVerC shall be equal to 0.
     2151        Int phaseHorLuma   = pcSlice->getPPS()->getPhaseHorLuma(refLayerIdc);
     2152        Int phaseVerLuma   = pcSlice->getPPS()->getPhaseVerLuma(refLayerIdc);
     2153        Int phaseHorChroma = pcSlice->getPPS()->getPhaseHorChroma(refLayerIdc);
     2154        Int phaseVerChroma = pcSlice->getPPS()->getPhaseVerChroma(refLayerIdc);
     2155        assert( ( (widthEL  != widthBL)  || (phaseHorLuma == 0 && phaseHorChroma == 0) )
     2156             && ( (heightEL != heightBL) || (phaseVerLuma == 0 && phaseVerChroma == 0) ) );
     2157#endif
     2158#endif
     2159#endif
     2160
    18602161        g_mvScalingFactor[refLayerIdc][0] = widthEL  == widthBL  ? 4096 : Clip3(-4096, 4095, ((widthEL  << 8) + (widthBL  >> 1)) / widthBL);
    18612162        g_mvScalingFactor[refLayerIdc][1] = heightEL == heightBL ? 4096 : Clip3(-4096, 4095, ((heightEL << 8) + (heightBL >> 1)) / heightBL);
     
    18662167#if Q0048_CGS_3D_ASYMLUT
    18672168        TComPicYuv* pBaseColRec = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec();
    1868         if( pcSlice->getPPS()->getCGSFlag() )
    1869         {
     2169        if( pcSlice->getPPS()->getCGSFlag()
     2170#if R0150_CGS_SIGNAL_CONSTRAINTS
     2171          && m_c3DAsymLUTPPS.isRefLayer( pcSlice->getVPS()->getRefLayerId(m_layerId, refLayerIdc) )
     2172#endif
     2173          )
     2174        {
     2175#if R0150_CGS_SIGNAL_CONSTRAINTS
     2176          assert( pcSlice->getBaseColPic( refLayerIdc )->getSlice( 0 )->getBitDepthY() == m_c3DAsymLUTPPS.getInputBitDepthY() );
     2177          assert( pcSlice->getBaseColPic( refLayerIdc )->getSlice( 0 )->getBitDepthC() == m_c3DAsymLUTPPS.getInputBitDepthC() );
     2178          assert( pcSlice->getBitDepthY() >= m_c3DAsymLUTPPS.getOutputBitDepthY() );
     2179          assert( pcSlice->getBitDepthY() >= m_c3DAsymLUTPPS.getOutputBitDepthC() );
     2180#endif
    18702181          if(!m_pColorMappedPic)
    18712182          {
     
    18912202#else
    18922203#if Q0048_CGS_3D_ASYMLUT
    1893             m_cPrediction.upsampleBasePic( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, pcPic->getPicYuvRec(), pcSlice->getSPS()->getScaledRefLayerWindow(refLayerIdc), pcSlice->getVPS()->getPhaseAlignFlag() );
    1894 #else
    1895             m_cPrediction.upsampleBasePic( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), pcPic->getPicYuvRec(), scalEL, pcSlice->getVPS()->getPhaseAlignFlag() );
     2204#if MOVE_SCALED_OFFSET_TO_PPS
     2205          m_cPrediction.upsampleBasePic( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, pcPic->getPicYuvRec(), pcSlice->getPPS()->getScaledRefLayerWindow(refLayerIdc), pcSlice->getVPS()->getPhaseAlignFlag() );
     2206#else
     2207          m_cPrediction.upsampleBasePic( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, pcPic->getPicYuvRec(), pcSlice->getSPS()->getScaledRefLayerWindow(refLayerIdc), pcSlice->getVPS()->getPhaseAlignFlag() );
     2208#endif
     2209#else
     2210          m_cPrediction.upsampleBasePic( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), pcPic->getPicYuvRec(), scalEL, pcSlice->getVPS()->getPhaseAlignFlag() );
    18962211#endif
    18972212#endif
     
    18992214#if O0194_JOINT_US_BITSHIFT
    19002215#if Q0048_CGS_3D_ASYMLUT
    1901             m_cPrediction.upsampleBasePic( pcSlice, refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, pcPic->getPicYuvRec(), scalEL );
    1902 #else
    1903             m_cPrediction.upsampleBasePic( pcSlice, refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), pcPic->getPicYuvRec(), scalEL );
     2216#if REF_REGION_OFFSET
     2217          m_cPrediction.upsampleBasePic( pcSlice, refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, pcPic->getPicYuvRec(), scalEL, altRL );
     2218#else
     2219          m_cPrediction.upsampleBasePic( pcSlice, refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, pcPic->getPicYuvRec(), scalEL );
     2220#endif
     2221#else
     2222          m_cPrediction.upsampleBasePic( pcSlice, refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), pcPic->getPicYuvRec(), scalEL );
    19042223#endif
    19052224#else
     
    19282247        UInt refLayerIdc = pcSlice->getInterLayerPredLayerIdc(i);
    19292248#if AVC_BASE
     2249#if VPS_AVC_BL_FLAG_REMOVAL
     2250        if( pcSlice->getVPS()->getRefLayerId( m_layerId, refLayerIdc ) == 0 && m_parameterSetManagerDecoder.getActiveVPS()->getNonHEVCBaseLayerFlag() )
     2251#else
    19302252        if( pcSlice->getVPS()->getRefLayerId( m_layerId, refLayerIdc ) == 0 && m_parameterSetManagerDecoder.getActiveVPS()->getAvcBaseLayerFlag() )
     2253#endif
    19312254        {
    19322255          pcSlice->setBaseColPic ( refLayerIdc, *m_ppcTDecTop[0]->getListPic()->begin() );
    1933 #if AVC_SYNTAX
    1934           TComPic* pBLPic = pcSlice->getBaseColPic(refLayerIdc);
    1935           if( pcSlice->getPOC() == 0 )
    1936           {
    1937             // initialize partition order.
    1938             UInt* piTmp = &g_auiZscanToRaster[0];
    1939             initZscanToRaster( pBLPic->getPicSym()->getMaxDepth() + 1, 1, 0, piTmp );
    1940             initRasterToZscan( pBLPic->getPicSym()->getMaxCUWidth(), pBLPic->getPicSym()->getMaxCUHeight(), pBLPic->getPicSym()->getMaxDepth() + 1 );
    1941           }     
    1942           pBLPic->getSlice( 0 )->initBaseLayerRPL( pcSlice );
    1943           pBLPic->readBLSyntax( m_ppcTDecTop[0]->getBLSyntaxFile(), SYNTAX_BYTES );
    1944 #endif
    19452256        }
    19462257        else
     
    19702281
    19712282#if REF_IDX_MFM
    1972       if( pcSlice->getMFMEnabledFlag() )
    1973       {
    1974         pcSlice->setRefPOCListILP(m_ppcTDecTop[m_layerId]->m_cIlpPic, pcSlice->getBaseColPic());
    1975       }
    19762283      pcSlice->setRefPicList( m_cListPic, false, m_cIlpPic);
    19772284    }
     
    20152322      }
    20162323    }
    2017 
     2324   
    20182325    if( m_layerId > 0 && !pcSlice->isIntra() && pcSlice->getEnableTMVPFlag() )
    20192326    {
     
    20212328
    20222329      assert( refPic );
     2330#if R0226_SLICE_TMVP
     2331      assert ( refPic->getPicSym()->getSlice(0)->getAvailableForTMVPRefFlag() == true );
     2332#endif
    20232333
    20242334      // It is a requirement of bitstream conformance when the collocated picture, used for temporal motion vector prediction, is an inter-layer reference picture,
     
    21002410  //  Decode a picture
    21012411  m_cGopDecoder.decompressSlice(nalu.m_Bitstream, pcPic);
     2412
     2413#if P0297_VPS_POC_LSB_ALIGNED_FLAG
     2414  setFirstPicInLayerDecodedFlag(true);
     2415#endif
    21022416
    21032417  m_bFirstSliceInPicture = false;
     
    21152429}
    21162430
     2431#if SVC_EXTENSION
    21172432Void TDecTop::xDecodeSPS()
    21182433{
    21192434  TComSPS* sps = new TComSPS();
    2120 #if SVC_EXTENSION
    21212435  sps->setLayerId(m_layerId);
    21222436#if SPS_DPB_PARAMS
     
    21262440#endif
    21272441  m_parameterSetManagerDecoder.storePrefetchedSPS(sps);
    2128 #if Q0078_ADD_LAYER_SETS
    2129   // Store SPS for all layers
    2130   for (Int lId = 0; lId < m_numLayer; lId++)
    2131   {
    2132     if (m_ppcTDecTop[lId] != this)
    2133     {
    2134       m_ppcTDecTop[lId]->getParameterSetManager()->storePrefetchedSPS(sps);
    2135     }
    2136   }
    2137 #endif
    21382442#if !REPN_FORMAT_IN_VPS   // ILRP can only be initialized at activation 
    21392443  if(m_numLayer>0)
     
    21422446  }
    21432447#endif
    2144 #else //SVC_EXTENSION
    2145   m_cEntropyDecoder.decodeSPS( sps );
    2146   m_parameterSetManagerDecoder.storePrefetchedSPS(sps);
    2147 #endif //SVC_EXTENSION
    21482448}
    21492449
     
    21662466    );
    21672467  m_parameterSetManagerDecoder.storePrefetchedPPS( pps );
    2168 #if Q0078_ADD_LAYER_SETS
    2169   // Store PPS for all layers
    2170   for (Int lId = 0; lId < m_numLayer; lId++)
    2171   {
    2172     if (m_ppcTDecTop[lId] != this)
    2173     {
    2174       m_ppcTDecTop[lId]->getParameterSetManager()->storePrefetchedPPS(pps);
    2175     }
    2176   }
    2177 #endif
    2178 
    2179   if( pps->getDependentSliceSegmentsEnabledFlag() )
    2180   {
    2181     Int NumCtx = pps->getEntropyCodingSyncEnabledFlag()?2:1;
    2182     m_cSliceDecoder.initCtxMem(NumCtx);
    2183     for ( UInt st = 0; st < NumCtx; st++ )
    2184     {
    2185       TDecSbac* ctx = NULL;
    2186       ctx = new TDecSbac;
    2187       ctx->init( &m_cBinCABAC );
    2188       m_cSliceDecoder.setCtxMem( ctx, st );
    2189     }
    2190   }
    21912468}
     2469#else
     2470Void TDecTop::xDecodeSPS()
     2471{
     2472  TComSPS* sps = new TComSPS();
     2473  m_cEntropyDecoder.decodeSPS( sps );
     2474  m_parameterSetManagerDecoder.storePrefetchedSPS(sps);
     2475}
     2476
     2477Void TDecTop::xDecodePPS()
     2478{
     2479  TComPPS* pps = new TComPPS();
     2480  m_cEntropyDecoder.decodePPS( pps );
     2481  m_parameterSetManagerDecoder.storePrefetchedPPS( pps );
     2482}
     2483#endif //SVC_EXTENSION
    21922484
    21932485Void TDecTop::xDecodeSEI( TComInputBitstream* bs, const NalUnitType nalUnitType )
     
    22172509    {
    22182510      SEIActiveParameterSets *seiAps = (SEIActiveParameterSets*)(*activeParamSets.begin());
     2511#if !R0247_SEI_ACTIVE
    22192512      m_parameterSetManagerDecoder.applyPrefetchedPS();
    22202513      assert(seiAps->activeSeqParameterSetId.size()>0);
     
    22232516        printf ("Warning SPS activation with Active parameter set SEI failed");
    22242517      }
    2225     }
    2226 #if Q0074_SEI_COLOR_MAPPING
    2227     m_ColorMapping->setColorMapping( m_SEIs );
    2228 #endif
     2518#else
     2519      getLayerDec(0)->m_parameterSetManagerDecoder.applyPrefetchedPS();
     2520      assert(seiAps->activeSeqParameterSetId.size()>0);
     2521      if( !getLayerDec(0)->m_parameterSetManagerDecoder.activateSPSWithSEI( seiAps->activeSeqParameterSetId[0] ) )
     2522      {
     2523        printf ("Warning SPS activation with Active parameter set SEI failed");
     2524      }
     2525      for (Int c=1 ; c <= seiAps->numSpsIdsMinus1; c++)
     2526      {
     2527        Int layerIdx = seiAps->layerSpsIdx[c];
     2528        getLayerDec(layerIdx)->m_parameterSetManagerDecoder.applyPrefetchedPS();
     2529        if( !getLayerDec(layerIdx)->m_parameterSetManagerDecoder.activateSPSWithSEI( seiAps->activeSeqParameterSetId[layerIdx] ) )
     2530        {
     2531          printf ("Warning SPS activation with Active parameter set SEI failed");
     2532        }
     2533      }
     2534#endif
     2535    }
    22292536  }
    22302537#else
     
    22872594#endif
    22882595#if AVC_BASE
     2596#if VPS_AVC_BL_FLAG_REMOVAL
     2597      if( m_parameterSetManagerDecoder.getPrefetchedVPS(0)->getNonHEVCBaseLayerFlag() )
     2598#else
    22892599      if( m_parameterSetManagerDecoder.getPrefetchedVPS(0)->getAvcBaseLayerFlag() )
     2600#endif
    22902601      {
    22912602        if( !m_ppcTDecTop[0]->getBLReconFile()->good() )
     
    22942605          exit(EXIT_FAILURE);
    22952606        }       
    2296 #if AVC_SYNTAX
    2297         if( !m_ppcTDecTop[0]->getBLSyntaxFile()->good() )
    2298         {
    2299           printf( "Base layer syntax input reading error\n" );
    2300           exit(EXIT_FAILURE);
    2301         }
    2302 #endif
    23032607      }
    23042608      else
     
    27483052}
    27493053#endif
    2750 
     3054#if POC_RESET_RESTRICTIONS
     3055Void TDecTop::resetPocRestrictionCheckParameters()
     3056{
     3057  TDecTop::m_checkPocRestrictionsForCurrAu       = false;
     3058  TDecTop::m_pocResetIdcOrCurrAu                 = -1;
     3059  TDecTop::m_baseLayerIdrFlag                    = false;
     3060  TDecTop::m_baseLayerPicPresentFlag             = false;
     3061  TDecTop::m_baseLayerIrapFlag                   = false;
     3062  TDecTop::m_nonBaseIdrPresentFlag               = false;
     3063  TDecTop::m_nonBaseIdrType                      = -1;
     3064  TDecTop::m_picNonIdrWithRadlPresentFlag        = false;
     3065  TDecTop::m_picNonIdrNoLpPresentFlag            = false;
     3066}
     3067#endif
    27513068#endif //SVC_EXTENSION
    27523069
    2753 #if Q0074_SEI_COLOR_MAPPING
    2754 TDecColorMapping::TDecColorMapping()
    2755 {
    2756   m_pcColorMappingPic[0]   = NULL;
    2757   m_pcColorMappingPic[1]   = NULL;
    2758 
    2759   m_colorMapCancelFlag  = true;
    2760 
    2761   for( Int i=0 ; i<3 ; i++ )
    2762   {
    2763     m_lut1d_computed[i]             = false;
    2764     m_lut1d_input[i]                = NULL;
    2765     m_coded_input_pivot_value[i]    = NULL;
    2766     m_target_input_pivot_value[i]   = NULL;
    2767   }
    2768   for( Int i=0 ; i<3 ; i++ )
    2769   {
    2770     m_lut1d_output[i]               = NULL;
    2771     m_coded_output_pivot_value[i]   = NULL;
    2772     m_target_output_pivot_value[i]  = NULL;
    2773   }
    2774 }
    2775 
    2776 TDecColorMapping::~TDecColorMapping()
    2777 {
    2778   if ( m_pcColorMappingPic[0] )  delete m_pcColorMappingPic[0];
    2779   if ( m_pcColorMappingPic[1] )  delete m_pcColorMappingPic[1];
    2780 
    2781   for( Int i=0 ; i<3 ; i++ )
    2782   {
    2783     if ( m_lut1d_input[i] )               delete  m_lut1d_input[i];
    2784     if ( m_coded_input_pivot_value[i] )   delete  m_coded_input_pivot_value[i];
    2785     if ( m_target_input_pivot_value[i] )  delete  m_target_input_pivot_value[i];
    2786   }
    2787   for( Int i=0 ; i<3 ; i++ )
    2788   {
    2789     if ( m_lut1d_output[i] )               delete  m_lut1d_output[i];
    2790     if ( m_coded_output_pivot_value[i] )   delete  m_coded_output_pivot_value[i];
    2791     if ( m_target_output_pivot_value[i] )  delete  m_target_output_pivot_value[i];
    2792   }
    2793 }
    2794 
    2795 Void  TDecColorMapping::setColorMapping( SEIMessages m_SEIs )
    2796 {
    2797   SEIMessages colorMappingInfo = getSeisByType(m_SEIs, SEI::COLOR_MAPPING_INFO) ;
    2798   SEIColorMappingInfo *seiColorMappingInfo = NULL;
    2799   if (colorMappingInfo.size() !=0)
    2800   {
    2801     seiColorMappingInfo = (SEIColorMappingInfo*)(*colorMappingInfo.begin());
    2802 
    2803     m_colorMapId                              = seiColorMappingInfo->m_colorMapId;
    2804     m_colorMapCancelFlag                      = seiColorMappingInfo->m_colorMapCancelFlag;
    2805     if( !m_colorMapCancelFlag )
    2806     {
    2807       m_colorMapPersistenceFlag                 = seiColorMappingInfo->m_colorMapPersistenceFlag;
    2808       m_colorMap_video_signal_type_present_flag = seiColorMappingInfo->m_colorMap_video_signal_type_present_flag;
    2809       m_colorMap_video_full_range_flag          = seiColorMappingInfo->m_colorMap_video_full_range_flag;
    2810       m_colorMap_primaries                      = seiColorMappingInfo->m_colorMap_primaries;
    2811       m_colorMap_transfer_characteristics       = seiColorMappingInfo->m_colorMap_transfer_characteristics;
    2812       m_colorMap_matrix_coeffs                  = seiColorMappingInfo->m_colorMap_matrix_coeffs;
    2813       m_colorMapModelId                         = seiColorMappingInfo->m_colorMapModelId;
    2814 
    2815       m_colour_map_coded_data_bit_depth         = seiColorMappingInfo->m_colour_map_coded_data_bit_depth;
    2816       m_colour_map_target_bit_depth             = seiColorMappingInfo->m_colour_map_target_bit_depth;
    2817 
    2818       for( Int i=0 ; i<3 ; i++ )
    2819       {
    2820         m_num_input_pivots[i]                 = seiColorMappingInfo->m_num_input_pivots[i];
    2821         if ( m_coded_input_pivot_value[i] )   delete  m_coded_input_pivot_value[i];
    2822         if ( m_target_input_pivot_value[i] )  delete  m_target_input_pivot_value[i];
    2823         m_coded_input_pivot_value[i]          = new Int[ m_num_input_pivots[i] ];
    2824         m_target_input_pivot_value[i]         = new Int[ m_num_input_pivots[i] ];
    2825         for( Int j=0 ; j<m_num_input_pivots[i] ; j++ )
    2826         {
    2827           m_coded_input_pivot_value[i][j]     = seiColorMappingInfo->m_coded_input_pivot_value[i][j];
    2828           m_target_input_pivot_value[i][j]    = seiColorMappingInfo->m_target_input_pivot_value[i][j];
    2829         }
    2830       }
    2831 
    2832       m_matrix_flag       = seiColorMappingInfo->m_matrix_flag;
    2833       m_log2_matrix_denom = m_matrix_flag ? (seiColorMappingInfo->m_log2_matrix_denom) : (0) ;
    2834       for( Int i=0 ; i<3 ; i++ )
    2835       {
    2836         for( Int j=0 ; j<3 ; j++ )
    2837         {
    2838           m_matrix_coef[i][j]  = seiColorMappingInfo->m_matrix_coef[i][j];
    2839         }
    2840       }
    2841 
    2842       for( Int i=0 ; i<3 ; i++ )
    2843       {
    2844         m_num_output_pivots[i]                 = seiColorMappingInfo->m_num_output_pivots[i];
    2845         if ( m_coded_output_pivot_value[i] )   delete  m_coded_output_pivot_value[i];
    2846         if ( m_target_output_pivot_value[i] )  delete  m_target_output_pivot_value[i];
    2847         m_coded_output_pivot_value[i]          = new Int[ m_num_output_pivots[i] ];
    2848         m_target_output_pivot_value[i]         = new Int[ m_num_output_pivots[i] ];
    2849         for( Int j=0 ; j<m_num_output_pivots[i] ; j++ )
    2850         {
    2851           m_coded_output_pivot_value[i][j]     = seiColorMappingInfo->m_coded_output_pivot_value[i][j];
    2852           m_target_output_pivot_value[i][j]    = seiColorMappingInfo->m_target_output_pivot_value[i][j];
    2853         }
    2854       }
    2855 
    2856       memset( m_lut1d_computed, 0, sizeof( m_lut1d_computed ) );
    2857     }
    2858   }
    2859 
    2860 }
    2861 
    2862 Void  TDecColorMapping::setColorMapping( Int bitDepth, Int iComp )
    2863 {
    2864   if( !m_colorMapCancelFlag && !m_lut1d_computed[iComp] )
    2865   {
    2866 
    2867     if ( m_lut1d_input[iComp] )   delete m_lut1d_input[iComp];
    2868     if ( m_lut1d_output[iComp] )  delete m_lut1d_output[iComp];
    2869 
    2870     m_lut1d_input[iComp]  = new Int[ 1 << bitDepth ];
    2871     m_lut1d_output[iComp] = new Int[ 1 << bitDepth ];
    2872 
    2873     Int iShift      = (m_colour_map_coded_data_bit_depth >= bitDepth) ? (m_colour_map_coded_data_bit_depth - bitDepth) : (0);
    2874     Int iShiftPivot = (m_colour_map_coded_data_bit_depth >= bitDepth) ? (0) : (bitDepth - m_colour_map_coded_data_bit_depth);
    2875 
    2876     for( Int k=0 ; k<(1<<bitDepth) ; k++ )
    2877     {
    2878       Int iSample = k << iShift ;
    2879       if( m_num_input_pivots[iComp] > 1 )
    2880       {
    2881         for( Int iPivot=0 ; iPivot<m_num_input_pivots[iComp] ; iPivot++ )
    2882         {
    2883           Int iCodedPrev  = m_coded_input_pivot_value[iComp][iPivot]     << iShiftPivot;
    2884           Int iCodedNext  = m_coded_input_pivot_value[iComp][iPivot+1]   << iShiftPivot;
    2885           Int iTargetPrev = m_target_input_pivot_value[iComp][iPivot]    << iShiftPivot;
    2886           Int iTargetNext = m_target_input_pivot_value[iComp][iPivot+1]  << iShiftPivot;
    2887           if ( iCodedPrev <= iSample && iSample < iCodedNext )
    2888           {
    2889             Float fInterpol = (Float)( (iCodedNext - iSample)*iTargetPrev + (iSample - iCodedPrev)*iTargetNext ) / (Float)(iCodedNext - iCodedPrev) ;
    2890             m_lut1d_input[iComp][k]  = (Int)( 0.5 + fInterpol );
    2891             iPivot = m_num_input_pivots[iComp]; // stop
    2892           }
    2893         }
    2894       }
    2895       else
    2896       {
    2897         m_lut1d_input[iComp][k]  = k;
    2898       }
    2899     }
    2900 
    2901     iShift      = ( (m_colour_map_coded_data_bit_depth >= bitDepth) ? (m_colour_map_coded_data_bit_depth - bitDepth) : (0) );
    2902     Int iOffset = iShift ? (1 << (iShift - 1)) : (0) ;
    2903     iShiftPivot = (m_colour_map_target_bit_depth >= bitDepth) ? (0) : (bitDepth - m_colour_map_target_bit_depth) ;
    2904     for( Int k=0 ; k<(1<<bitDepth) ; k++ )
    2905     {
    2906       Int iSample = k << iShift;
    2907       if ( m_num_output_pivots[iComp]>1 )
    2908       {
    2909         for( Int iPivot=0 ; iPivot<m_num_output_pivots[iComp] ; iPivot++ )
    2910         {
    2911           Int iCodedPrev  = m_coded_output_pivot_value[iComp][iPivot]     << iShiftPivot;
    2912           Int iCodedNext  = m_coded_output_pivot_value[iComp][iPivot+1]   << iShiftPivot;
    2913           Int iTargetPrev = m_target_output_pivot_value[iComp][iPivot]    << iShiftPivot;
    2914           Int iTargetNext = m_target_output_pivot_value[iComp][iPivot+1]  << iShiftPivot;
    2915           if ( iCodedPrev <= iSample && iSample < iCodedNext )
    2916           {
    2917             Float fInterpol =  (Float)( (iCodedNext - iSample)*iTargetPrev + (iSample - iCodedPrev)*iTargetNext ) / (Float)(iCodedNext - iCodedPrev) ;
    2918             m_lut1d_output[iComp][k]  = ( (Int)(0.5 + fInterpol) + iOffset ) >> iShift ;
    2919             iPivot = m_num_output_pivots[iComp]; // stop
    2920           }
    2921         }
    2922       }
    2923       else
    2924       {
    2925         m_lut1d_output[iComp][k]  = k;
    2926       }
    2927     }
    2928 
    2929     m_lut1d_computed[iComp] = true;
    2930   }
    2931 
    2932 }
    2933 
    2934 TComPicYuv* TDecColorMapping::getColorMapping( TComPicYuv* pPicYuvRec, Int iTop, Int curlayerId )
    2935 {
    2936   if( !m_colorMapCancelFlag )
    2937   {
    2938     if( !m_pcColorMappingPic[iTop] )
    2939     {
    2940       m_pcColorMappingPic[iTop] = new TComPicYuv;
    2941 #if SVC_EXTENSION
    2942       m_pcColorMappingPic[iTop]->create( pPicYuvRec->getWidth(), pPicYuvRec->getHeight(), pPicYuvRec->getChromaFormat(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth );
    2943 #else
    2944       m_pcColorMappingPic[iTop]->create( pPicYuvRec->getWidth(), pPicYuvRec->getHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth );
    2945 #endif
    2946     }
    2947 
    2948     Int iHeight   = pPicYuvRec->getHeight();
    2949     Int iWidth    = pPicYuvRec->getWidth();
    2950     Int iStride   = pPicYuvRec->getStride();
    2951     Int iCStride  = pPicYuvRec->getCStride();
    2952 
    2953     Pel* Lum0   = pPicYuvRec->getLumaAddr();
    2954     Pel* Cb0    = pPicYuvRec->getCbAddr();
    2955     Pel* Cr0    = pPicYuvRec->getCrAddr();
    2956     Pel* Lum1   = m_pcColorMappingPic[iTop]->getLumaAddr();
    2957     Pel* Cb1    = m_pcColorMappingPic[iTop]->getCbAddr();
    2958     Pel* Cr1    = m_pcColorMappingPic[iTop]->getCrAddr();
    2959 
    2960 #if SVC_EXTENSION
    2961     Int bitDepthY = g_bitDepthYLayer[curlayerId];
    2962     Int bitDepthC = g_bitDepthCLayer[curlayerId];
    2963 
    2964     assert( g_bitDepthY == bitDepthY );
    2965     assert( g_bitDepthC == bitDepthC );
    2966 #else
    2967     Int bitDepthY = g_bitDepthY;
    2968     Int bitDepthC = g_bitDepthC;
    2969 #endif
    2970 
    2971     Int iYShift = (m_colour_map_target_bit_depth >= bitDepthY) ? (m_colour_map_target_bit_depth - bitDepthY) : (0) ;
    2972     Int iCShift = (m_colour_map_target_bit_depth >= bitDepthC) ? (m_colour_map_target_bit_depth - bitDepthC) : (0) ;
    2973     Int offsetY = (1 << (m_log2_matrix_denom+iYShift - 1));
    2974     Int offsetC = (1 << (m_log2_matrix_denom+iCShift - 1));
    2975 
    2976     Int   cShift  = 1 ;
    2977 
    2978     //Pel*  LumPrev0 = Lum0;
    2979     for( Int y = 0; y < iHeight ; y++ )
    2980     {
    2981       Bool  bDoChroma = (y % 2);
    2982       for( Int x = 0; x < iWidth ; x++ )
    2983       {
    2984         Int s1Y = m_lut1d_input[0][ Lum0[x]   ];
    2985         Int s1U = m_lut1d_input[1][ Cb0[x>>1] ];
    2986         Int s1V = m_lut1d_input[2][ Cr0[x>>1] ];
    2987 
    2988         Int s2Y, s2U, s2V;
    2989         if( m_matrix_flag )
    2990         {
    2991           s2Y = ( m_matrix_coef[0][0]*s1Y + m_matrix_coef[0][1]*s1U + m_matrix_coef[0][2]*s1V + offsetY ) >> ( m_log2_matrix_denom + iYShift );
    2992           //s2Y = ClipBD( s2Y , bitDepthY );
    2993           s2Y = ClipY( s2Y );
    2994           Lum1[x]   = m_lut1d_output[0][ s2Y ];
    2995         }
    2996         else
    2997         {
    2998           s1Y       = ( s1Y + offsetY ) >> iYShift ;
    2999           //s1Y = ClipBD( s1Y , bitDepthY );
    3000           s1Y = ClipY( s1Y );
    3001           Lum1[x]   = m_lut1d_output[0][ s1Y ];
    3002         }
    3003 
    3004         if( bDoChroma && (x%2) )
    3005         {
    3006           if( m_matrix_flag )
    3007           {
    3008             //s1Y = ( m_lut1d_input[0][ Lum0[x] ] + m_lut1d_input[0][ Lum0[x+1] ] + m_lut1d_input[0][ LumPrev0[x] ] + m_lut1d_input[0][ LumPrev0[x+1] ] + 2 ) >> 2 ;
    3009             //s1Y = m_lut1d_input[0][ (Lum0[x] + Lum0[x+1] + LumPrev0[x] + LumPrev0[x+1] + 2)>>2 ] ;
    3010             s1Y = m_lut1d_input[0][ Lum0[x] ];
    3011 
    3012             s2U = ( m_matrix_coef[1][0]*s1Y + m_matrix_coef[1][1]*s1U + m_matrix_coef[1][2]*s1V + offsetC ) >> ( m_log2_matrix_denom + iCShift ) ;
    3013             s2V = ( m_matrix_coef[2][0]*s1Y + m_matrix_coef[2][1]*s1U + m_matrix_coef[2][2]*s1V + offsetC ) >> ( m_log2_matrix_denom + iCShift ) ;
    3014             //s2U = ClipBD( s2U , bitDepthC );
    3015             //s2V = ClipBD( s2V , bitDepthC );
    3016             s2U = ClipC( s2U );
    3017             s2V = ClipC( s2V );
    3018             Cb1[x>>cShift] = m_lut1d_output[1][ s2U ];
    3019             Cr1[x>>cShift] = m_lut1d_output[2][ s2V ];
    3020           }
    3021           else
    3022           {
    3023             s1U       = ( s1U + offsetC ) >> iCShift ;
    3024             s1V       = ( s1V + offsetC ) >> iCShift ;
    3025             //s1U = ClipBD( s1U , bitDepthC );
    3026             //s1V = ClipBD( s1V , bitDepthC );
    3027             s1U = ClipC( s1U );
    3028             s1V = ClipC( s1V );
    3029             Cb1[x>>cShift] = m_lut1d_output[1][ s1U ];
    3030             Cr1[x>>cShift] = m_lut1d_output[2][ s1V ];
    3031           }
    3032         }
    3033 
    3034       }
    3035 
    3036       //LumPrev0 = Lum0;
    3037       Lum0  += iStride;
    3038       Lum1  += iStride;
    3039       if( bDoChroma )
    3040       {
    3041         Cb0 += iCStride;
    3042         Cr0 += iCStride;
    3043         Cb1 += iCStride;
    3044         Cr1 += iCStride;
    3045       }
    3046     }
    3047 
    3048     return m_pcColorMappingPic[iTop];
    3049   }
    3050 
    3051   return pPicYuvRec;
    3052 }
    3053 #endif
    30543070
    30553071//! \}
  • trunk/source/Lib/TLibDecoder/TDecTop.h

    r815 r906  
    6464// ====================================================================================================================
    6565
    66 #if Q0074_SEI_COLOR_MAPPING
    67 class TDecColorMapping
    68 {
    69   Int   m_colorMapId;
    70   Bool  m_colorMapCancelFlag;
    71   Bool  m_colorMapPersistenceFlag;
    72   Bool  m_colorMap_video_signal_type_present_flag;
    73   Bool  m_colorMap_video_full_range_flag;
    74   Int   m_colorMap_primaries;
    75   Int   m_colorMap_transfer_characteristics;
    76   Int   m_colorMap_matrix_coeffs;
    77   Int   m_colorMapModelId;
    78 
    79   Int   m_colour_map_coded_data_bit_depth;
    80   Int   m_colour_map_target_bit_depth;
    81 
    82   Int   m_num_input_pivots[3];
    83   Int*  m_coded_input_pivot_value[3];
    84   Int*  m_target_input_pivot_value[3];
    85  
    86   Bool  m_matrix_flag;
    87   Int   m_log2_matrix_denom;
    88   Int   m_matrix_coef[3][3];
    89 
    90   Int   m_num_output_pivots[3];
    91   Int*  m_coded_output_pivot_value[3];
    92   Int*  m_target_output_pivot_value[3];
    93 
    94   Bool  m_lut1d_computed[3];
    95   Int*  m_lut1d_input[3];
    96   Int*  m_lut1d_output[3];
    97   TComPicYuv* m_pcColorMappingPic[2];
    98 
    99 public:
    100   TDecColorMapping();
    101   ~TDecColorMapping();
    102 
    103   Bool        getColorMappingFlag()                     { return(!m_colorMapCancelFlag);};
    104 
    105   Void        setColorMapping( SEIMessages m_SEIs );
    106   Void        setColorMapping( Int bitDepthY, Int bitDepthC );
    107   TComPicYuv* getColorMapping( TComPicYuv* pPicYuvRec, Int iTop=0, Int curlayerId=0 );
    108 };// END CLASS DEFINITION TDecColorMapping
    109 #endif
    110 
    11166/// decoder class
    11267class TDecTop
     
    165120  Bool                    m_isLastNALWasEos;
    166121#endif
    167 
    168122#if SVC_EXTENSION
    169123  static UInt             m_prevPOC;        // POC of the previous slice
     
    173127  UInt                    m_numLayer;
    174128  TDecTop**               m_ppcTDecTop;
     129#if P0297_VPS_POC_LSB_ALIGNED_FLAG
     130  Bool                    m_pocResettingFlag;
     131  Bool                    m_pocDecrementedInDPBFlag;
     132#endif
    175133#if AVC_BASE
    176134  fstream*                m_pBLReconFile;
     
    195153  CommonDecoderParams*    m_commonDecoderParams;
    196154#endif
    197 #if AVC_SYNTAX || SYNTAX_OUTPUT
    198   fstream*               m_pBLSyntaxFile;
    199 #endif
    200 
    201155#if NO_CLRAS_OUTPUT_FLAG 
    202156  Bool                    m_noClrasOutputFlag;
     
    214168#endif
    215169public:
    216 #if Q0074_SEI_COLOR_MAPPING
    217   TDecColorMapping* m_ColorMapping;
     170#if POC_RESET_RESTRICTIONS
     171  static Bool                    m_checkPocRestrictionsForCurrAu;
     172  static Int                     m_pocResetIdcOrCurrAu;
     173  static Bool                    m_baseLayerIdrFlag;
     174  static Bool                    m_baseLayerPicPresentFlag;
     175  static Bool                    m_baseLayerIrapFlag;
     176  static Bool                    m_nonBaseIdrPresentFlag;
     177  static Int                     m_nonBaseIdrType;
     178  static Bool                    m_picNonIdrWithRadlPresentFlag;
     179  static Bool                    m_picNonIdrNoLpPresentFlag;
     180#endif
     181#if POC_RESET_VALUE_RESTRICTION
     182  static Int                     m_crossLayerPocResetPeriodId;
     183  static Int                     m_crossLayerPocResetIdc;
    218184#endif
    219185
     
    225191
    226192  void setDecodedPictureHashSEIEnabled(Int enabled) { m_cGopDecoder.setDecodedPictureHashSEIEnabled(enabled); }
     193#if Q0074_COLOUR_REMAPPING_SEI
     194  void setColourRemappingInfoSEIEnabled(Bool enabled)  { m_cGopDecoder.setColourRemappingInfoSEIEnabled(enabled); }
     195#endif
    227196
    228197  Void  init();
     
    327296#endif
    328297#endif //SVC_EXTENSION
    329 #if AVC_SYNTAX || SYNTAX_OUTPUT
    330   Void      setBLSyntaxFile( fstream* pFile ) { m_pBLSyntaxFile = pFile; }
    331   fstream* getBLSyntaxFile() { return m_pBLSyntaxFile; }
    332 #endif
     298
    333299protected:
    334300  Void  xGetNewPicBuffer  (TComSlice* pcSlice, TComPic*& rpcPic);
     
    365331  Void initAsymLut(TComSlice *pcSlice);
    366332#endif
     333#if POC_RESET_RESTRICTIONS
     334  Void resetPocRestrictionCheckParameters();
     335#endif
    367336};// END CLASS DEFINITION TDecTop
    368337
    369338
     339
    370340//! \}
    371341
  • trunk/source/Lib/TLibEncoder/SEIwrite.cpp

    r815 r906  
    9292    break;
    9393#endif
    94 #if Q0074_SEI_COLOR_MAPPING
    95   case SEI::COLOR_MAPPING_INFO:
    96     fprintf( g_hTrace, "=========== Color Mapping Info SEI message ===========\n");
     94#if Q0074_COLOUR_REMAPPING_SEI
     95  case SEI::COLOUR_REMAPPING_INFO:
     96    fprintf( g_hTrace, "=========== Colour Remapping Information SEI message ===========\n");
    9797    break;
    9898#endif
     
    126126    fprintf( g_hTrace, "=========== Bitstream parition initial arrival time SEI message ===========\n");
    127127    break;
     128#if !REMOVE_BSP_HRD_SEI
    128129  case SEI::BSP_HRD:
    129130    fprintf( g_hTrace, "=========== Bitstream parition HRD parameters SEI message ===========\n");
    130131    break;
     132#endif
    131133#endif
    132134#if Q0078_ADD_LAYER_SETS
     
    147149
    148150#if O0164_MULTI_LAYER_HRD
     151#if VPS_VUI_BSP_HRD_PARAMS
     152void SEIWriter::xWriteSEIpayloadData(TComBitIf& bs, const SEI& sei, TComVPS *vps, TComSPS *sps, const SEIScalableNesting* nestingSeiPtr, const SEIBspNesting* bspNestingSeiPtr)
     153#else
    149154void SEIWriter::xWriteSEIpayloadData(TComBitIf& bs, const SEI& sei, TComVPS *vps, TComSPS *sps, const SEIScalableNesting& nestingSei, const SEIBspNesting& bspNestingSei)
     155#endif
    150156#else
    151157void SEIWriter::xWriteSEIpayloadData(TComBitIf& bs, const SEI& sei, TComSPS *sps)
    152158#endif
    153159{
     160#if VPS_VUI_BSP_HRD_PARAMS
     161  SEIScalableNesting nestingSei;
     162  SEIBspNesting      bspNestingSei;
     163  if( nestingSeiPtr )
     164  {
     165    nestingSei = *nestingSeiPtr;
     166  }
     167  if( bspNestingSeiPtr )
     168  {
     169    bspNestingSei = *bspNestingSeiPtr;
     170  }
     171#endif
    154172  switch (sei.payloadType())
    155173  {
     
    160178    xWriteSEIActiveParameterSets(*static_cast<const SEIActiveParameterSets*>(& sei));
    161179    break;
     180  case SEI::DECODED_PICTURE_HASH:
     181    xWriteSEIDecodedPictureHash(*static_cast<const SEIDecodedPictureHash*>(&sei));
     182    break;
     183#if VPS_VUI_BSP_HRD_PARAMS
     184  case SEI::DECODING_UNIT_INFO:
     185    xWriteSEIDecodingUnitInfo(*static_cast<const SEIDecodingUnitInfo*>(& sei), sps, nestingSeiPtr, bspNestingSeiPtr, vps);
     186    break;
     187  case SEI::BUFFERING_PERIOD:
     188    xWriteSEIBufferingPeriod(*static_cast<const SEIBufferingPeriod*>(&sei), sps, nestingSeiPtr, bspNestingSeiPtr, vps);
     189    break;
     190  case SEI::PICTURE_TIMING:
     191    xWriteSEIPictureTiming(*static_cast<const SEIPictureTiming*>(&sei), sps, nestingSeiPtr, bspNestingSeiPtr, vps);
     192    break;
     193#else
    162194  case SEI::DECODING_UNIT_INFO:
    163195    xWriteSEIDecodingUnitInfo(*static_cast<const SEIDecodingUnitInfo*>(& sei), sps);
    164196    break;
    165   case SEI::DECODED_PICTURE_HASH:
    166     xWriteSEIDecodedPictureHash(*static_cast<const SEIDecodedPictureHash*>(&sei));
    167     break;
    168197  case SEI::BUFFERING_PERIOD:
    169198    xWriteSEIBufferingPeriod(*static_cast<const SEIBufferingPeriod*>(&sei), sps);
     
    172201    xWriteSEIPictureTiming(*static_cast<const SEIPictureTiming*>(&sei), sps);
    173202    break;
     203#endif
    174204  case SEI::RECOVERY_POINT:
    175205    xWriteSEIRecoveryPoint(*static_cast<const SEIRecoveryPoint*>(&sei));
     
    195225    break;
    196226#endif
    197 #if Q0074_SEI_COLOR_MAPPING
    198   case SEI::COLOR_MAPPING_INFO:
    199     xWriteSEIColorMappingInfo(*static_cast<const SEIColorMappingInfo*>(&sei));
     227#if Q0074_COLOUR_REMAPPING_SEI
     228  case SEI::COLOUR_REMAPPING_INFO:
     229    xWriteSEIColourRemappingInfo(*static_cast<const SEIColourRemappingInfo*>(&sei));
    200230    break;
    201231#endif
     
    233263     xWriteSEIBspInitialArrivalTime(*static_cast<const SEIBspInitialArrivalTime*>(&sei), vps, sps, nestingSei, bspNestingSei);
    234264     break;
     265#if !REMOVE_BSP_HRD_SEI
    235266   case SEI::BSP_HRD:
    236267     xWriteSEIBspHrd(*static_cast<const SEIBspHrd*>(&sei), sps, nestingSei);
    237268     break;
     269#endif
    238270#endif
    239271#if Q0078_ADD_LAYER_SETS
     
    283315#endif
    284316#if O0164_MULTI_LAYER_HRD
     317#if VPS_VUI_BSP_HRD_PARAMS
     318  xWriteSEIpayloadData(bs_count, sei, vps, sps, nestingSei, bspNestingSei);
     319#else
    285320  xWriteSEIpayloadData(bs_count, sei, vps, sps, *nestingSei, *bspNestingSei);
     321#endif
    286322#else
    287323  xWriteSEIpayloadData(bs_count, sei, sps);
     
    322358
    323359#if O0164_MULTI_LAYER_HRD
     360#if VPS_VUI_BSP_HRD_PARAMS
     361  xWriteSEIpayloadData(bs, sei, vps, sps, nestingSei, bspNestingSei);
     362#else
    324363  xWriteSEIpayloadData(bs, sei, vps, sps, *nestingSei, *bspNestingSei);
     364#endif
    325365#else
    326366  xWriteSEIpayloadData(bs, sei, sps);
     
    390430    WRITE_UVLC(sei.activeSeqParameterSetId[i], "active_seq_parameter_set_id");
    391431  }
    392   xWriteByteAlign();
    393 }
    394 
     432#if R0247_SEI_ACTIVE
     433  for (Int i = 1; i < sei.activeSeqParameterSetId.size(); i++)
     434  {
     435    WRITE_UVLC(sei.layerSpsIdx[i], "layer_sps_idx");
     436  }
     437#endif
     438  xWriteByteAlign();
     439}
     440
     441#if VPS_VUI_BSP_HRD_PARAMS
     442Void SEIWriter::xWriteSEIDecodingUnitInfo(const SEIDecodingUnitInfo& sei, TComSPS *sps, const SEIScalableNesting* nestingSei, const SEIBspNesting* bspNestingSei, TComVPS *vps)
     443#else
    395444Void SEIWriter::xWriteSEIDecodingUnitInfo(const SEIDecodingUnitInfo& sei, TComSPS *sps)
    396 {
     445#endif
     446{
     447#if VPS_VUI_BSP_HRD_PARAMS
     448  TComHRD *hrd;
     449  if( bspNestingSei )   // If DU info SEI contained inside a BSP nesting SEI message
     450  {
     451    assert( nestingSei );
     452    Int psIdx = bspNestingSei->m_seiPartitioningSchemeIdx;
     453    Int seiOlsIdx = bspNestingSei->m_seiOlsIdx;
     454    Int maxTemporalId = nestingSei->m_nestingMaxTemporalIdPlus1[0] - 1;
     455    Int maxValues = vps->getNumBspSchedulesMinus1(seiOlsIdx, psIdx, maxTemporalId) + 1;
     456    std::vector<Int> hrdIdx(maxValues, 0);
     457    std::vector<TComHRD *> hrdVec;
     458    std::vector<Int> syntaxElemLen(maxValues, 0);
     459    for(Int i = 0; i < maxValues; i++)
     460    {
     461      hrdIdx[i] = vps->getBspHrdIdx( seiOlsIdx, psIdx, maxTemporalId, i, bspNestingSei->m_bspIdx);
     462      hrdVec.push_back(vps->getBspHrd(hrdIdx[i]));
     463   
     464      syntaxElemLen[i] = hrdVec[i]->getInitialCpbRemovalDelayLengthMinus1() + 1;
     465      if ( !(hrdVec[i]->getNalHrdParametersPresentFlag() || hrdVec[i]->getVclHrdParametersPresentFlag()) )
     466      {
     467        assert( syntaxElemLen[i] == 24 ); // Default of value init_cpb_removal_delay_length_minus1 is 23
     468      }
     469      if( i > 0 )
     470      {
     471        assert( hrdVec[i]->getSubPicCpbParamsPresentFlag()    == hrdVec[i-1]->getSubPicCpbParamsPresentFlag() );
     472        assert( hrdVec[i]->getSubPicCpbParamsInPicTimingSEIFlag()   == hrdVec[i-1]->getSubPicCpbParamsInPicTimingSEIFlag() );
     473        assert( hrdVec[i]->getDpbOutputDelayDuLengthMinus1()  == hrdVec[i-1]->getDpbOutputDelayDuLengthMinus1() );
     474        // To be done: Check CpbDpbDelaysPresentFlag
     475      }
     476    }
     477    hrd = hrdVec[0];
     478  }
     479  else
     480  {
     481    TComVUI *vui = sps->getVuiParameters();
     482    hrd = vui->getHrdParameters();
     483  }
     484#else
    397485  TComVUI *vui = sps->getVuiParameters();
     486  TComHrd *hrd = vui->getHrdParameters();
     487#endif
    398488  WRITE_UVLC(sei.m_decodingUnitIdx, "decoding_unit_idx");
    399   if(vui->getHrdParameters()->getSubPicCpbParamsInPicTimingSEIFlag())
    400   {
    401     WRITE_CODE( sei.m_duSptCpbRemovalDelay, (vui->getHrdParameters()->getDuCpbRemovalDelayLengthMinus1() + 1), "du_spt_cpb_removal_delay");
     489  if(hrd->getSubPicCpbParamsInPicTimingSEIFlag())
     490  {
     491    WRITE_CODE( sei.m_duSptCpbRemovalDelay, (hrd->getDuCpbRemovalDelayLengthMinus1() + 1), "du_spt_cpb_removal_delay");
    402492  }
    403493  WRITE_FLAG( sei.m_dpbOutputDuDelayPresentFlag, "dpb_output_du_delay_present_flag");
    404494  if(sei.m_dpbOutputDuDelayPresentFlag)
    405495  {
    406     WRITE_CODE(sei.m_picSptDpbOutputDuDelay, vui->getHrdParameters()->getDpbOutputDelayDuLengthMinus1() + 1, "pic_spt_dpb_output_du_delay");
    407   }
    408   xWriteByteAlign();
    409 }
    410 
     496    WRITE_CODE(sei.m_picSptDpbOutputDuDelay,hrd->getDpbOutputDelayDuLengthMinus1() + 1, "pic_spt_dpb_output_du_delay");
     497  }
     498  xWriteByteAlign();
     499}
     500
     501#if VPS_VUI_BSP_HRD_PARAMS
     502Void SEIWriter::xWriteSEIBufferingPeriod(const SEIBufferingPeriod& sei, TComSPS *sps, const SEIScalableNesting* nestingSei, const SEIBspNesting* bspNestingSei, TComVPS *vps)
     503#else
    411504Void SEIWriter::xWriteSEIBufferingPeriod(const SEIBufferingPeriod& sei, TComSPS *sps)
     505#endif
    412506{
    413507  Int i, nalOrVcl;
     508#if VPS_VUI_BSP_HRD_PARAMS
     509  TComHRD *hrd;
     510  if( bspNestingSei )   // If BP SEI contained inside a BSP nesting SEI message
     511  {
     512    assert( nestingSei );
     513    Int psIdx = bspNestingSei->m_seiPartitioningSchemeIdx;
     514    Int seiOlsIdx = bspNestingSei->m_seiOlsIdx;
     515    Int maxTemporalId = nestingSei->m_nestingMaxTemporalIdPlus1[0] - 1;
     516    Int maxValues = vps->getNumBspSchedulesMinus1(seiOlsIdx, psIdx, maxTemporalId) + 1;
     517    std::vector<Int> hrdIdx(maxValues, 0);
     518    std::vector<TComHRD *> hrdVec;
     519    std::vector<Int> syntaxElemLen(maxValues, 0);
     520    for(i = 0; i < maxValues; i++)
     521    {
     522      hrdIdx[i] = vps->getBspHrdIdx( seiOlsIdx, psIdx, maxTemporalId, i, bspNestingSei->m_bspIdx);
     523      hrdVec.push_back(vps->getBspHrd(hrdIdx[i]));
     524   
     525      syntaxElemLen[i] = hrdVec[i]->getInitialCpbRemovalDelayLengthMinus1() + 1;
     526      if ( !(hrdVec[i]->getNalHrdParametersPresentFlag() || hrdVec[i]->getVclHrdParametersPresentFlag()) )
     527      {
     528        assert( syntaxElemLen[i] == 24 ); // Default of value init_cpb_removal_delay_length_minus1 is 23
     529      }
     530      if( i > 0 )
     531      {
     532        assert( hrdVec[i]->getCpbRemovalDelayLengthMinus1()   == hrdVec[i-1]->getCpbRemovalDelayLengthMinus1() );
     533        assert( hrdVec[i]->getDpbOutputDelayDuLengthMinus1()  == hrdVec[i-1]->getDpbOutputDelayDuLengthMinus1() );
     534        assert( hrdVec[i]->getSubPicCpbParamsPresentFlag()    == hrdVec[i-1]->getSubPicCpbParamsPresentFlag() );
     535      }
     536    }
     537    hrd = hrdVec[i];
     538  }
     539  else
     540  {
     541    TComVUI *vui = sps->getVuiParameters();
     542    hrd = vui->getHrdParameters();
     543  }
     544  // To be done: When contained in an BSP HRD SEI message, the hrd structure is to be chosen differently.
     545#else
    414546  TComVUI *vui = sps->getVuiParameters();
    415547  TComHRD *hrd = vui->getHrdParameters();
     548#endif
    416549
    417550  WRITE_UVLC( sei.m_bpSeqParameterSetId, "bp_seq_parameter_set_id" );
     
    452585  xWriteByteAlign();
    453586}
     587#if VPS_VUI_BSP_HRD_PARAMS
     588Void SEIWriter::xWriteSEIPictureTiming(const SEIPictureTiming& sei,  TComSPS *sps, const SEIScalableNesting* nestingSei, const SEIBspNesting* bspNestingSei, TComVPS *vps)
     589#else
    454590Void SEIWriter::xWriteSEIPictureTiming(const SEIPictureTiming& sei,  TComSPS *sps)
     591#endif
    455592{
    456593  Int i;
     594#if VPS_VUI_BSP_HRD_PARAMS
     595  TComHRD *hrd;   
     596  TComVUI *vui = sps->getVuiParameters();
     597  if( bspNestingSei )   // If BP SEI contained inside a BSP nesting SEI message
     598  {
     599    assert( nestingSei );
     600    Int psIdx = bspNestingSei->m_seiPartitioningSchemeIdx;
     601    Int seiOlsIdx = bspNestingSei->m_seiOlsIdx;
     602    Int maxTemporalId = nestingSei->m_nestingMaxTemporalIdPlus1[0] - 1;
     603    Int maxValues = vps->getNumBspSchedulesMinus1(seiOlsIdx, psIdx, maxTemporalId) + 1;
     604    std::vector<Int> hrdIdx(maxValues, 0);
     605    std::vector<TComHRD *> hrdVec;
     606    std::vector<Int> syntaxElemLen(maxValues, 0);
     607    for(i = 0; i < maxValues; i++)
     608    {
     609      hrdIdx[i] = vps->getBspHrdIdx( seiOlsIdx, psIdx, maxTemporalId, i, bspNestingSei->m_bspIdx);
     610      hrdVec.push_back(vps->getBspHrd(hrdIdx[i]));
     611   
     612      syntaxElemLen[i] = hrdVec[i]->getInitialCpbRemovalDelayLengthMinus1() + 1;
     613      if ( !(hrdVec[i]->getNalHrdParametersPresentFlag() || hrdVec[i]->getVclHrdParametersPresentFlag()) )
     614      {
     615        assert( syntaxElemLen[i] == 24 ); // Default of value init_cpb_removal_delay_length_minus1 is 23
     616      }
     617      if( i > 0 )
     618      {
     619        assert( hrdVec[i]->getSubPicCpbParamsPresentFlag()    == hrdVec[i-1]->getSubPicCpbParamsPresentFlag() );
     620        assert( hrdVec[i]->getSubPicCpbParamsInPicTimingSEIFlag()   == hrdVec[i-1]->getSubPicCpbParamsInPicTimingSEIFlag() );
     621        assert( hrdVec[i]->getCpbRemovalDelayLengthMinus1()  == hrdVec[i-1]->getCpbRemovalDelayLengthMinus1() );
     622        assert( hrdVec[i]->getDpbOutputDelayLengthMinus1()  == hrdVec[i-1]->getDpbOutputDelayLengthMinus1() );
     623        assert( hrdVec[i]->getDpbOutputDelayDuLengthMinus1()  == hrdVec[i-1]->getDpbOutputDelayDuLengthMinus1() );
     624        assert( hrdVec[i]->getDuCpbRemovalDelayLengthMinus1()  == hrdVec[i-1]->getDuCpbRemovalDelayLengthMinus1() );
     625        // To be done: Check CpbDpbDelaysPresentFlag
     626      }
     627    }
     628    hrd = hrdVec[0];
     629  }
     630  else
     631  {
     632    hrd = vui->getHrdParameters();
     633  }
     634  // To be done: When contained in an BSP HRD SEI message, the hrd structure is to be chosen differently.
     635#else
    457636  TComVUI *vui = sps->getVuiParameters();
    458637  TComHRD *hrd = vui->getHrdParameters();
    459 
    460   if( vui->getFrameFieldInfoPresentFlag() )
     638#endif
     639
     640  if( vui->getFrameFieldInfoPresentFlag() ) // To be done: Check whether this is the correct invocation of vui when PT SEI contained in BSP nesting SEI
    461641  {
    462642    WRITE_CODE( sei.m_picStruct, 4,              "pic_struct" );
     
    634814}
    635815#endif
    636 #if Q0074_SEI_COLOR_MAPPING
    637 Void SEIWriter::xWriteSEIColorMappingInfo(const SEIColorMappingInfo& sei)
    638 {
    639   WRITE_UVLC( sei.m_colorMapId,                    "colour_map_id" );
    640   WRITE_FLAG( sei.m_colorMapCancelFlag,            "colour_map_cancel_flag" );
    641   if( !sei.m_colorMapCancelFlag )
    642   {
    643     WRITE_FLAG( sei.m_colorMapPersistenceFlag,            "colour_map_persistence_flag" );
    644     WRITE_FLAG( sei.m_colorMap_video_signal_type_present_flag,            "colour_map_video_signal_type_present_flag" );
    645     if ( sei.m_colorMap_video_signal_type_present_flag )
    646     {
    647       WRITE_FLAG( sei.m_colorMap_video_full_range_flag,       "colour_map_video_full_range_flag" );
    648       WRITE_CODE( sei.m_colorMap_primaries,                 8,      "colour_map_primaries" );
    649       WRITE_CODE( sei.m_colorMap_transfer_characteristics,  8,      "colour_map_transfer_characteristics" );
    650       WRITE_CODE( sei.m_colorMap_matrix_coeffs,             8,      "colour_map_matrix_coeffs" );
    651     }
    652   }
    653 
    654   WRITE_CODE( sei.m_colour_map_coded_data_bit_depth,  5,  "colour_map_coded_data_bit_depth" );
    655   WRITE_CODE( sei.m_colour_map_target_bit_depth,  5,      "colour_map_target_bit_depth" );
    656   WRITE_UVLC( sei.m_colorMapModelId,                      "colour_map_model_id" );
    657 
    658   assert( sei.m_colorMapModelId == 0 );
    659  
    660   for( Int i=0 ; i<3 ; i++ )
    661   {
    662     WRITE_CODE( sei.m_num_input_pivots[i] - 1,         8,      "num_input_pivots_minus1[i]" );
    663     for( Int j=0 ; j<sei.m_num_input_pivots[i] ; j++ )
    664     {
    665       WRITE_CODE( sei.m_coded_input_pivot_value[i][j],  (( sei.m_colour_map_coded_data_bit_depth + 7 ) >> 3 ) << 3, "coded_input_pivot_value[i][j]" );
    666       WRITE_CODE( sei.m_target_input_pivot_value[i][j], (( sei.m_colour_map_coded_data_bit_depth + 7 ) >> 3 ) << 3, "target_input_pivot_value[i][j]" );
    667     }
    668   }
    669 
    670   WRITE_FLAG( sei.m_matrix_flag,            "matrix_flag" );
    671   if( sei.m_matrix_flag )
    672   {
    673     WRITE_CODE( sei.m_log2_matrix_denom, 4, "log2_matrix_denom" );
    674     for( Int i=0 ; i<3 ; i++ )
    675     {
    676       for( Int j=0 ; j<3 ; j++ )
    677       {
    678         WRITE_SVLC( sei.m_matrix_coef[i][j],  "matrix_coef[i][j]" );
    679       }
    680     }
    681   }
    682 
    683   for( Int i=0 ; i<3 ; i++ )
    684   {
    685     WRITE_CODE( sei.m_num_output_pivots[i] - 1,         8,      "num_output_pivots_minus1[i]" );
    686     for( Int j=0 ; j<sei.m_num_output_pivots[i] ; j++ )
    687     {
    688       WRITE_CODE( sei.m_coded_output_pivot_value[i][j],  (( sei.m_colour_map_coded_data_bit_depth + 7 ) >> 3 ) << 3, "coded_output_pivot_value[i][j]" );
    689       WRITE_CODE( sei.m_target_output_pivot_value[i][j], (( sei.m_colour_map_coded_data_bit_depth + 7 ) >> 3 ) << 3, "target_output_pivot_value[i][j]" );
    690     }
    691   }
    692 
     816#if Q0074_COLOUR_REMAPPING_SEI
     817Void SEIWriter::xWriteSEIColourRemappingInfo(const SEIColourRemappingInfo& sei)
     818{
     819  WRITE_UVLC( sei.m_colourRemapId,                             "colour_remap_id" );
     820  WRITE_FLAG( sei.m_colourRemapCancelFlag,                     "colour_remap_cancel_flag" );
     821  if( !sei.m_colourRemapCancelFlag )
     822  {
     823    WRITE_FLAG( sei.m_colourRemapPersistenceFlag,              "colour_remap_persistence_flag" );
     824    WRITE_FLAG( sei.m_colourRemapVideoSignalInfoPresentFlag,   "colour_remap_video_signal_info_present_flag" );
     825    if ( sei.m_colourRemapVideoSignalInfoPresentFlag )
     826    {
     827      WRITE_FLAG( sei.m_colourRemapFullRangeFlag,              "colour_remap_full_range_flag" );
     828      WRITE_CODE( sei.m_colourRemapPrimaries,               8, "colour_remap_primaries" );
     829      WRITE_CODE( sei.m_colourRemapTransferFunction,        8, "colour_remap_transfer_function" );
     830      WRITE_CODE( sei.m_colourRemapMatrixCoefficients,      8, "colour_remap_matrix_coefficients" );
     831    }
     832    WRITE_CODE( sei.m_colourRemapInputBitDepth,             8, "colour_remap_input_bit_depth" );
     833    WRITE_CODE( sei.m_colourRemapBitDepth,                  8, "colour_remap_bit_depth" );
     834    for( Int c=0 ; c<3 ; c++ )
     835    {
     836      WRITE_CODE( sei.m_preLutNumValMinus1[c],              8, "pre_lut_num_val_minus1[c]" );
     837      if( sei.m_preLutNumValMinus1[c]>0 )
     838        for( Int i=0 ; i<=sei.m_preLutNumValMinus1[c] ; i++ )
     839        {
     840          WRITE_CODE( sei.m_preLutCodedValue[c][i], (( sei.m_colourRemapInputBitDepth + 7 ) >> 3 ) << 3, "pre_lut_coded_value[c][i]" );
     841          WRITE_CODE( sei.m_preLutTargetValue[c][i], (( sei.m_colourRemapBitDepth + 7 ) >> 3 ) << 3, "pre_lut_target_value[c][i]" );
     842        }
     843    }
     844    WRITE_FLAG( sei.m_colourRemapMatrixPresentFlag,            "colour_remap_matrix_present_flag" );
     845    if( sei.m_colourRemapMatrixPresentFlag )
     846    {
     847      WRITE_CODE( sei.m_log2MatrixDenom,                    4, "log2_matrix_denom" );
     848      for( Int c=0 ; c<3 ; c++ )
     849        for( Int i=0 ; i<3 ; i++ )
     850          WRITE_SVLC( sei.m_colourRemapCoeffs[c][i],           "colour_remap_coeffs[c][i]" );
     851    }
     852
     853    for( Int c=0 ; c<3 ; c++ )
     854    {
     855      WRITE_CODE( sei.m_postLutNumValMinus1[c],             8, "m_postLutNumValMinus1[c]" );
     856      if( sei.m_postLutNumValMinus1[c]>0 )
     857        for( Int i=0 ; i<=sei.m_postLutNumValMinus1[c] ; i++ )
     858        {
     859          WRITE_CODE( sei.m_postLutCodedValue[c][i], (( sei.m_colourRemapBitDepth + 7 ) >> 3 ) << 3, "post_lut_coded_value[c][i]" );       
     860          WRITE_CODE( sei.m_postLutTargetValue[c][i], (( sei.m_colourRemapBitDepth + 7 ) >> 3 ) << 3, "post_lut_target_value[c][i]" );
     861        }
     862    }
     863  }
    693864  xWriteByteAlign();
    694865}
     
    753924  {
    754925    WRITE_FLAG( sei.m_defaultOpFlag,                 "default_op_flag"               );
    755     WRITE_UVLC( sei.m_nestingNumOpsMinus1,           "nesting_num_ops"               );
     926    WRITE_UVLC( sei.m_nestingNumOpsMinus1,           "nesting_num_ops_minus1"        );
    756927    for (UInt i = (sei.m_defaultOpFlag ? 1 : 0); i <= sei.m_nestingNumOpsMinus1; i++)
    757928    {
    758       WRITE_CODE( sei.m_nestingNoOpMaxTemporalIdPlus1, 3, "nesting_no_op_max_temporal_id" );
    759       WRITE_CODE( sei.m_nestingMaxTemporalIdPlus1[i], 3,  "nesting_max_temporal_id"       );
     929      WRITE_CODE( sei.m_nestingMaxTemporalIdPlus1[i], 3,  "nesting_max_temporal_id_plus1" );
    760930      WRITE_UVLC( sei.m_nestingOpIdx[i],                  "nesting_op_idx"                );
    761931    }
     
    766936    if (!sei.m_allLayersFlag)
    767937    {
    768       WRITE_CODE( sei.m_nestingNoOpMaxTemporalIdPlus1, 3, "nesting_no_op_max_temporal_id" );
    769       WRITE_UVLC( sei.m_nestingNumLayersMinus1,           "nesting_num_layers"            );
     938      WRITE_CODE( sei.m_nestingNoOpMaxTemporalIdPlus1, 3, "nesting_no_op_max_temporal_id_plus1" );
     939      WRITE_UVLC( sei.m_nestingNumLayersMinus1,           "nesting_num_layers"                  );
    770940      for (UInt i = 0; i <= sei.m_nestingNumLayersMinus1; i++)
    771941      {
     
    9011071    WRITE_FLAG( 0, "bsp_nesting_zero_bit" );
    9021072  }
    903 
     1073#if NESTING_SEI_EXTENSIBILITY
     1074  assert( sei.m_nestedSEIs.size() <= MAX_SEIS_IN_BSP_NESTING );
     1075  WRITE_UVLC( sei.m_nestedSEIs.size(), "num_seis_in_bsp_minus1" );
     1076#endif
    9041077  // write nested SEI messages
    9051078  for (SEIMessages::const_iterator it = sei.m_nestedSEIs.begin(); it != sei.m_nestedSEIs.end(); it++)
     
    9131086  assert(vps->getVpsVuiPresentFlag());
    9141087
     1088#if VPS_VUI_BSP_HRD_PARAMS
     1089  Int psIdx = bspNestingSei.m_seiPartitioningSchemeIdx;
     1090  Int seiOlsIdx = bspNestingSei.m_seiOlsIdx;
     1091  Int maxTemporalId = nestingSei.m_nestingMaxTemporalIdPlus1[0] - 1;
     1092  Int maxValues = vps->getNumBspSchedulesMinus1(seiOlsIdx, psIdx, maxTemporalId) + 1;
     1093  std::vector<Int> hrdIdx(maxValues, 0);
     1094  std::vector<TComHRD *> hrdVec;
     1095  std::vector<Int> syntaxElemLen(maxValues, 0);
     1096  for(Int i = 0; i < maxValues; i++)
     1097  {
     1098    hrdIdx[i] = vps->getBspHrdIdx( seiOlsIdx, psIdx, maxTemporalId, i, bspNestingSei.m_bspIdx);
     1099    hrdVec.push_back(vps->getBspHrd(hrdIdx[i]));
     1100   
     1101    syntaxElemLen[i] = hrdVec[i]->getInitialCpbRemovalDelayLengthMinus1() + 1;
     1102    if ( !(hrdVec[i]->getNalHrdParametersPresentFlag() || hrdVec[i]->getVclHrdParametersPresentFlag()) )
     1103    {
     1104      assert( syntaxElemLen[i] == 24 ); // Default of value init_cpb_removal_delay_length_minus1 is 23
     1105    }
     1106    if( i > 0 )
     1107    {
     1108      assert( hrdVec[i]->getNalHrdParametersPresentFlag() == hrdVec[i-1]->getNalHrdParametersPresentFlag() );
     1109      assert( hrdVec[i]->getVclHrdParametersPresentFlag() == hrdVec[i-1]->getVclHrdParametersPresentFlag() );
     1110    }
     1111  }
     1112  if (hrdVec[0]->getNalHrdParametersPresentFlag())
     1113  {
     1114    for(UInt i = 0; i < maxValues; i++)
     1115    {
     1116      WRITE_CODE( sei.m_nalInitialArrivalDelay[i], syntaxElemLen[i], "nal_initial_arrival_delay[i]" );
     1117    }
     1118  }
     1119  if( hrdVec[0]->getVclHrdParametersPresentFlag() )
     1120  {
     1121    for(UInt i = 0; i < maxValues; i++)
     1122    {
     1123      WRITE_CODE( sei.m_vclInitialArrivalDelay[i], syntaxElemLen[i], "vcl_initial_arrival_delay[i]" );
     1124    }
     1125  }
     1126#else
    9151127  UInt schedCombCnt = vps->getNumBspSchedCombinations(nestingSei.m_nestingOpIdx[0]);
    9161128  UInt len;
     
    9441156    }
    9451157  }
     1158#if BSP_INIT_ARRIVAL_SEI
     1159  if( hrd->getVclHrdParametersPresentFlag() )
     1160#else
    9461161  else
     1162#endif
    9471163  {
    9481164    for(UInt i = 0; i < schedCombCnt; i++)
     
    9511167    }
    9521168  }
    953 }
    954 
     1169#endif
     1170}
     1171
     1172#if !REMOVE_BSP_HRD_SEI
    9551173Void SEIWriter::xWriteSEIBspHrd(const SEIBspHrd &sei, TComSPS *sps, const SEIScalableNesting &nestingSei)
    9561174{
     
    10041222  }
    10051223}
     1224#endif
    10061225
    10071226Void SEIWriter::xCodeHrdParameters( TComHRD *hrd, Bool commonInfPresentFlag, UInt maxNumSubLayersMinus1 )
  • trunk/source/Lib/TLibEncoder/SEIwrite.h

    r815 r906  
    5555protected:
    5656#if O0164_MULTI_LAYER_HRD
     57#if VPS_VUI_BSP_HRD_PARAMS
     58  Void xWriteSEIpayloadData(TComBitIf& bs, const SEI& sei, TComVPS *vps, TComSPS *sps, const SEIScalableNesting* nestingSei, const SEIBspNesting* bspNestingSei);
     59#else
    5760  Void xWriteSEIpayloadData(TComBitIf& bs, const SEI& sei, TComVPS *vps, TComSPS *sps, const SEIScalableNesting& nestingSei, const SEIBspNesting& bspNestingSei);
     61#endif
    5862#else
    5963  Void xWriteSEIpayloadData(TComBitIf& bs, const SEI& sei, TComSPS *sps);
     
    6165  Void xWriteSEIuserDataUnregistered(const SEIuserDataUnregistered &sei);
    6266  Void xWriteSEIActiveParameterSets(const SEIActiveParameterSets& sei);
     67  Void xWriteSEIDecodedPictureHash(const SEIDecodedPictureHash& sei);
     68#if VPS_VUI_BSP_HRD_PARAMS
     69  Void xWriteSEIDecodingUnitInfo(const SEIDecodingUnitInfo& sei, TComSPS *sps, const SEIScalableNesting* nestingSei, const SEIBspNesting* bspNestingSei, TComVPS *vps);
     70  Void xWriteSEIBufferingPeriod(const SEIBufferingPeriod& sei, TComSPS *sps, const SEIScalableNesting* nestingSei, const SEIBspNesting* bspNestingSei, TComVPS *vps);
     71  Void xWriteSEIPictureTiming(const SEIPictureTiming& sei, TComSPS *sps, const SEIScalableNesting* nestingSei, const SEIBspNesting* bspNestingSei, TComVPS *vps);
     72#else
    6373  Void xWriteSEIDecodingUnitInfo(const SEIDecodingUnitInfo& sei, TComSPS *sps);
    64   Void xWriteSEIDecodedPictureHash(const SEIDecodedPictureHash& sei);
    6574  Void xWriteSEIBufferingPeriod(const SEIBufferingPeriod& sei, TComSPS *sps);
    6675  Void xWriteSEIPictureTiming(const SEIPictureTiming& sei, TComSPS *sps);
     76#endif
    6777  TComSPS *m_pSPS;
    6878  Void xWriteSEIRecoveryPoint(const SEIRecoveryPoint& sei);
     
    7585  Void xWriteSEIKneeFunctionInfo(const SEIKneeFunctionInfo &sei);
    7686#endif
    77 #if Q0074_SEI_COLOR_MAPPING
    78   Void xWriteSEIColorMappingInfo(const SEIColorMappingInfo& sei);
     87#if Q0074_COLOUR_REMAPPING_SEI
     88  Void xWriteSEIColourRemappingInfo(const SEIColourRemappingInfo& sei);
    7989#endif
    8090  Void xWriteSEISOPDescription(const SEISOPDescription& sei);
     
    104114  Void xWriteSEIBspNesting(TComBitIf& bs, const SEIBspNesting &sei, TComVPS *vps, TComSPS *sps, const SEIScalableNesting &nestingSei);
    105115  Void xWriteSEIBspInitialArrivalTime(const SEIBspInitialArrivalTime &sei, TComVPS *vps, TComSPS *sps, const SEIScalableNesting &nestingSei, const SEIBspNesting &bspNestingSei);
     116#if !REMOVE_BSP_HRD_SEI
    106117  Void xWriteSEIBspHrd(const SEIBspHrd &sei, TComSPS *sps, const SEIScalableNesting &nestingSei);
     118#endif
    107119  Void xCodeHrdParameters( TComHRD *hrd, Bool commonInfPresentFlag, UInt maxNumSubLayersMinus1 );
    108120#endif
  • trunk/source/Lib/TLibEncoder/TEnc3DAsymLUT.cpp

    r815 r906  
    1414  m_pColorInfoC = NULL;
    1515  m_pEncCuboid = NULL;
     16
    1617  m_pBestEncCuboid = NULL;
     18#if R0151_CGS_3D_ASYMLUT_IMPROVE
     19  m_nAccuFrameBit = 0;
     20  m_nAccuFrameCGSBit = 0;
     21  m_nPrevFrameCGSPartNumLog2 = 0;
     22#else
    1723  memset( m_nPrevFrameBit , 0 , sizeof( m_nPrevFrameBit ) );
    1824  memset( m_nPrevFrameCGSBit , 0 , sizeof( m_nPrevFrameCGSBit ) );
    1925  memset( m_nPrevFrameCGSPartNumLog2 , 0 , sizeof( m_nPrevFrameCGSPartNumLog2 ) );
    2026  memset( m_nPrevFrameOverWritePPS , 0 , sizeof( m_nPrevFrameOverWritePPS ) );
     27#endif
    2128  m_dTotalFrameBit = 0;
    2229  m_nTotalCGSBit = 0;
    2330  m_nPPSBit = 0;
    2431  m_pDsOrigPic = NULL;
     32#if R0179_ENC_OPT_3DLUT_SIZE
     33  m_pMaxColorInfo = NULL;
     34  m_pMaxColorInfoC = NULL;
     35
     36 
     37  // fixed m_dDistFactor
     38  Double dTmpFactor[3];   
     39  dTmpFactor[I_SLICE] = 1.0;
     40  dTmpFactor[P_SLICE] = 4./3.;
     41  dTmpFactor[B_SLICE] = 1.5;
     42  for( Int iSliceType = 0; iSliceType < 3; iSliceType++)
     43  {
     44    for(Int iLayer = 0; iLayer < MAX_TLAYER; iLayer++)
     45    {
     46      m_dDistFactor[iSliceType][iLayer] = dTmpFactor[iSliceType]*(Double)(1<<iLayer);     
     47    }
     48  }
     49  // initialization with approximate number of bits to code the LUT
     50  m_nNumLUTBits[0][0] = 200; // 1x1x1
     51  m_nNumLUTBits[1][0] = 400; // 2x1x1 
     52  m_nNumLUTBits[1][1] = 1500; // 2x2x2 
     53  m_nNumLUTBits[2][0] = 800; // 4x1x1
     54  m_nNumLUTBits[2][1] = 3200; // 4x2x2 
     55  m_nNumLUTBits[2][2] = 8500; // 4x4x4 
     56  m_nNumLUTBits[3][0] = 1200; // 8x1x1
     57  m_nNumLUTBits[3][1] = 4500; // 8x2x2 
     58  m_nNumLUTBits[3][2] = 10000; // 8x4x4 
     59  m_nNumLUTBits[3][3] = 12000; // 8x8x8
     60#endif
    2561}
    2662
     
    3268  }
    3369
    34   TCom3DAsymLUT::create( nMaxOctantDepth , nInputBitDepth , nInputBitDepthC, nOutputBitDepth , nOutputBitDepthC, nMaxYPartNumLog2 );
     70  TCom3DAsymLUT::create( nMaxOctantDepth , nInputBitDepth , nInputBitDepthC, nOutputBitDepth , nOutputBitDepthC, nMaxYPartNumLog2
     71#if R0151_CGS_3D_ASYMLUT_IMPROVE
     72    , 1 << ( nInputBitDepthC - 1 ) , 1 << ( nInputBitDepthC - 1 )
     73#endif
     74    );
    3575  xAllocate3DArray( m_pColorInfo , xGetYSize() , xGetUSize() , xGetVSize() );
    3676  xAllocate3DArray( m_pColorInfoC , xGetYSize() , xGetUSize() , xGetVSize() );
    3777  xAllocate3DArray( m_pEncCuboid , xGetYSize() , xGetUSize() , xGetVSize() );
    3878  xAllocate3DArray( m_pBestEncCuboid , xGetYSize() , xGetUSize() , xGetVSize() );
     79#if R0179_ENC_OPT_3DLUT_SIZE
     80  xAllocate3DArray( m_pMaxColorInfo , xGetYSize() , xGetUSize() , xGetVSize() );
     81  xAllocate3DArray( m_pMaxColorInfoC , xGetYSize() , xGetUSize() , xGetVSize() );
     82
     83  m_pEncCavlc = new TEncCavlc;
     84  m_pBitstreamRedirect = new TComOutputBitstream;
     85  m_pEncCavlc->setBitstream(m_pBitstreamRedirect);
     86#endif
    3987}
    4088
     
    4593  xFree3DArray( m_pEncCuboid );
    4694  xFree3DArray( m_pBestEncCuboid );
     95#if R0179_ENC_OPT_3DLUT_SIZE
     96  xFree3DArray( m_pMaxColorInfo );
     97  xFree3DArray( m_pMaxColorInfoC );
     98  delete m_pBitstreamRedirect;
     99  delete m_pEncCavlc;
     100#endif
    47101  TCom3DAsymLUT::destroy();
    48102}
     
    58112}
    59113
     114#if R0151_CGS_3D_ASYMLUT_IMPROVE
     115Double TEnc3DAsymLUT::xxDeriveVertexPerColor( Double N , Double Ys , Double Yy , Double Yu , Double Yv , Double ys , Double us , Double vs , Double yy , Double yu , Double yv , Double uu , Double uv , Double vv , Double YY ,
     116  Pel & rP0 , Pel & rP1 , Pel & rP3 , Pel & rP7 , Int nResQuantBit )
     117{
     118  Int nInitP0 = rP0;
     119  Int nInitP1 = rP1;
     120  Int nInitP3 = rP3;
     121  Int nInitP7 = rP7;
     122
     123  const Int nOne = xGetNormCoeffOne();
     124  Double dNorm = (N * yy * vv * uu - N * yy * uv * uv - N * yv * yv * uu - N * vv * yu * yu + 2 * N * yv * uv * yu - yy * vs * vs * uu + 2 * yy * vs * uv * us - yy * vv * us * us - 2 * vs * uv * yu * ys + uv * uv * ys * ys + vs * vs * yu * yu - 2 * yv * vs * us * yu + 2 * yv * vs * ys * uu - 2 * yv * uv * us * ys + 2 * vv * yu * ys * us - vv * uu * ys * ys + yv * yv * us * us);
     125  if( N > 16 && dNorm != 0 )
     126  {
     127    Double dInitA = (-N * uu * yv * Yv + N * uu * Yy * vv - N * Yy * uv * uv + N * yv * uv * Yu - N * yu * Yu * vv + N * yu * uv * Yv + yu * us * Ys * vv - vs * ys * uv * Yu - yu * vs * us * Yv - yv * uv * us * Ys - yv * vs * us * Yu - yu * uv * vs * Ys - ys * us * uv * Yv + ys * us * Yu * vv + 2 * Yy * vs * uv * us + uu * yv * vs * Ys - uu * ys * Ys * vv + uu * vs * ys * Yv + ys * Ys * uv * uv - Yy * vv * us * us + yu * Yu * vs * vs + yv * Yv * us * us - uu * Yy * vs * vs) / dNorm;
     128    Double dInitB = (N * yy * Yu * vv - N * yy * uv * Yv - N * Yu * yv * yv - N * yu * Yy * vv + N * uv * yv * Yy + N * yv * yu * Yv - yy * us * Ys * vv + yy * uv * vs * Ys - yy * Yu * vs * vs + yy * vs * us * Yv - uv * vs * ys * Yy - yv * yu * vs * Ys + yu * Yy * vs * vs + yu * ys * Ys * vv - uv * yv * ys * Ys + 2 * Yu * yv * vs * ys + us * ys * Yy * vv - vs * ys * yu * Yv + uv * ys * ys * Yv + us * Ys * yv * yv - Yu * ys * ys * vv - yv * ys * us * Yv - vs * us * yv * Yy) / dNorm;
     129    Double dInitC = -(-N * yy * Yv * uu + N * yy * uv * Yu - N * yv * yu * Yu - N * uv * yu * Yy + N * Yv * yu * yu + N * yv * Yy * uu - yy * uv * us * Ys + yy * Yv * us * us + yy * vs * Ys * uu - yy * vs * us * Yu + yv * ys * us * Yu - vs * Ys * yu * yu - yv * ys * Ys * uu + vs * us * yu * Yy + vs * ys * yu * Yu - uv * Yu * ys * ys + Yv * uu * ys * ys - yv * Yy * us * us - 2 * Yv * yu * ys * us - vs * ys * Yy * uu + uv * us * ys * Yy + uv * yu * ys * Ys + yv * yu * us * Ys) / dNorm;
     130    nInitP0 = ( Int )( dInitA * nOne + 0.5 ) >> nResQuantBit << nResQuantBit;
     131    nInitP1 = ( Int )( dInitB * nOne + 0.5 ) >> nResQuantBit << nResQuantBit;
     132    nInitP3 = ( Int )( dInitC * nOne + 0.5 ) >> nResQuantBit << nResQuantBit;
     133  }
     134
     135  Int nMin = - ( 1 << ( m_nLUTBitDepth - 1 ) );
     136  Int nMax = - nMin - ( 1 << nResQuantBit  );
     137  Int nMask = ( 1 << nResQuantBit ) - 1;
     138
     139  Double dMinError = MAX_DOUBLE;
     140  Int nTestRange = 2;
     141  Int nStepSize = 1 << nResQuantBit;
     142  for( Int i = - nTestRange ; i <= nTestRange ; i++ )
     143  {
     144    for( Int j = - nTestRange ; j <= nTestRange ; j++ )
     145    {
     146      for( Int k = - nTestRange ; k <= nTestRange ; k++ )
     147      {
     148        Int nTestP0 = Clip3( nMin , nMax , nInitP0 + i * nStepSize );
     149        Int nTestP1 = Clip3( nMin , nMax , nInitP1 + j * nStepSize );
     150        Int nTestP3 = Clip3( nMin , nMax , nInitP3 + k * nStepSize );
     151        Double a = 1.0 * nTestP0 / nOne;
     152        Double b = 1.0 * nTestP1 / nOne;
     153        Double c = 1.0 * nTestP3 / nOne;
     154        Double d = ( Ys - a * ys - b * us - c * vs ) / N;
     155        nInitP7 = ( ( Int )d ) >> nResQuantBit << nResQuantBit;
     156        for( Int m = 0 ; m < 2 ; m++ )
     157        {
     158          Int nTestP7 = Clip3( nMin , nMax , nInitP7 + m * nStepSize );
     159          Double dError = xxCalEstDist( N , Ys , Yy , Yu , Yv , ys , us , vs , yy , yu , yv , uu , uv , vv , YY , a , b , c , nTestP7 );
     160          if( dError < dMinError )
     161          {
     162            dMinError = dError;
     163            rP0 = ( Pel )nTestP0;
     164            rP1 = ( Pel )nTestP1;
     165            rP3 = ( Pel )nTestP3;
     166            rP7 = ( Pel )nTestP7;
     167          }
     168        }
     169      }
     170    }
     171  }
     172  assert( !( rP0 & nMask ) && !( rP1 & nMask ) && !( rP3 & nMask ) && !( rP7 & nMask ) );
     173
     174  return( dMinError );
     175}
     176#else
    60177Double TEnc3DAsymLUT::xxDeriveVertexPerColor( Double N , Double Ys , Double Yy , Double Yu , Double Yv , Double ys , Double us , Double vs , Double yy , Double yu , Double yv , Double uu , Double uv , Double vv , Double YY ,
    61178  Int y0 , Int u0 , Int v0 , Int nLengthY , Int nLengthUV ,
     
    134251  return( dMinError );
    135252}
    136 
     253#endif
     254
     255#if R0151_CGS_3D_ASYMLUT_IMPROVE
     256Double TEnc3DAsymLUT::estimateDistWithCur3DAsymLUT( TComPic * pCurPic , UInt refLayerIdc )
     257{
     258  xxCollectData( pCurPic , refLayerIdc );
     259
     260  Double dErrorLuma = 0 , dErrorChroma = 0;
     261  Int nYSize = 1 << ( getCurOctantDepth() + getCurYPartNumLog2() );
     262  Int nUVSize = 1 << getCurOctantDepth();
     263  for( Int yIdx = 0 ; yIdx < nYSize ; yIdx++ )
     264  {
     265    for( Int uIdx = 0 ; uIdx < nUVSize ; uIdx++ )
     266    {
     267      for( Int vIdx = 0 ; vIdx < nUVSize ; vIdx++ )
     268      {
     269        SColorInfo & rCuboidColorInfo = m_pColorInfo[yIdx][uIdx][vIdx];
     270        SColorInfo & rCuboidColorInfoC = m_pColorInfoC[yIdx][uIdx][vIdx];
     271        SCuboid & rCuboid = xGetCuboid( yIdx , uIdx , vIdx );
     272        if( rCuboidColorInfo.N > 0 )
     273        {
     274          dErrorLuma += xxCalEstDist( rCuboidColorInfo.N , rCuboidColorInfo.Ys , rCuboidColorInfo.Yy , rCuboidColorInfo.Yu , rCuboidColorInfo.Yv , rCuboidColorInfo.ys , rCuboidColorInfo.us , rCuboidColorInfo.vs , rCuboidColorInfo.yy , rCuboidColorInfo.yu , rCuboidColorInfo.yv , rCuboidColorInfo.uu , rCuboidColorInfo.uv , rCuboidColorInfo.vv , rCuboidColorInfo.YY ,
     275            rCuboid.P[0].Y , rCuboid.P[1].Y , rCuboid.P[2].Y , rCuboid.P[3].Y );
     276        }
     277        if( rCuboidColorInfoC.N > 0 )
     278        {
     279          dErrorChroma += xxCalEstDist( rCuboidColorInfoC.N , rCuboidColorInfoC.Us , rCuboidColorInfoC.Uy , rCuboidColorInfoC.Uu , rCuboidColorInfoC.Uv , rCuboidColorInfoC.ys , rCuboidColorInfoC.us , rCuboidColorInfoC.vs , rCuboidColorInfoC.yy , rCuboidColorInfoC.yu , rCuboidColorInfoC.yv , rCuboidColorInfoC.uu , rCuboidColorInfoC.uv , rCuboidColorInfoC.vv , rCuboidColorInfoC.UU ,
     280            rCuboid.P[0].U , rCuboid.P[1].U , rCuboid.P[2].U , rCuboid.P[3].U );
     281          dErrorChroma += xxCalEstDist( rCuboidColorInfoC.N , rCuboidColorInfoC.Vs , rCuboidColorInfoC.Vy , rCuboidColorInfoC.Vu , rCuboidColorInfoC.Vv , rCuboidColorInfoC.ys , rCuboidColorInfoC.us , rCuboidColorInfoC.vs , rCuboidColorInfoC.yy , rCuboidColorInfoC.yu , rCuboidColorInfoC.yv , rCuboidColorInfoC.uu , rCuboidColorInfoC.uv , rCuboidColorInfoC.vv , rCuboidColorInfoC.VV ,
     282            rCuboid.P[0].V , rCuboid.P[1].V , rCuboid.P[2].V , rCuboid.P[3].V );
     283        }
     284      }
     285    }
     286  }
     287
     288  return( dErrorLuma + dErrorChroma);
     289}
     290#else
    137291Double TEnc3DAsymLUT::estimateDistWithCur3DAsymLUT( TComPic * pCurPic , UInt refLayerIdc )
    138292{
     
    174328  return( dErrorLuma + dErrorChroma);
    175329}
    176 
     330#endif
     331
     332#if R0151_CGS_3D_ASYMLUT_IMPROVE
     333#if R0179_ENC_OPT_3DLUT_SIZE
     334Double TEnc3DAsymLUT::derive3DAsymLUT( TComSlice * pSlice , TComPic * pCurPic , UInt refLayerIdc , TEncCfg * pCfg , Bool bSignalPPS , Bool bElRapSliceTypeB, Double dFrameLambda )
     335{
     336  m_nLUTBitDepth = pCfg->getCGSLUTBit();
     337
     338  Int nBestAdaptCThresholdU = 1 << ( getInputBitDepthC() - 1 );
     339  Int nBestAdaptCThresholdV = 1 << ( getInputBitDepthC() - 1 );
     340  Int nAdaptCThresholdU, nAdaptCThresholdV;
     341
     342  Int nTmpLutBits[MAX_Y_SIZE][MAX_C_SIZE] ;
     343  memset(nTmpLutBits, 0, sizeof(nTmpLutBits));
     344
     345  SLUTSize sMaxLutSize; 
     346
     347  // collect stats for the most partitions
     348  Int nCurYPartNumLog2 = 0 , nCurOctantDepth = 0;
     349  Int nMaxPartNumLog2 = xGetMaxPartNumLog2();
     350
     351  xxMapPartNum2DepthYPart( nMaxPartNumLog2 , nCurOctantDepth , nCurYPartNumLog2 );
     352  xUpdatePartitioning( nCurOctantDepth , nCurYPartNumLog2, nBestAdaptCThresholdU, nBestAdaptCThresholdV );
     353  xxCollectData( pCurPic , refLayerIdc );
     354  xxCopyColorInfo(m_pMaxColorInfo, m_pColorInfo, m_pMaxColorInfoC, m_pColorInfoC);
     355 
     356  sMaxLutSize.iCPartNumLog2 = nCurOctantDepth;
     357  sMaxLutSize.iYPartNumLog2 = nCurOctantDepth + nCurYPartNumLog2;
     358
     359  m_pBitstreamRedirect->clear();
     360
     361  // find the best partition based on RD cost
     362  Int i;
     363  Double dMinCost, dCurCost;
     364
     365  Int iBestLUTSizeIdx = 0;   
     366  Int nBestResQuanBit = 0;
     367  Double dCurError, dMinError;
     368  Int iNumBitsCurSize;
     369  Int iNumBitsCurSizeSave = m_pEncCavlc->getNumberOfWrittenBits();
     370  Double dDistFactor = getDistFactor(pSlice->getSliceType(), pSlice->getDepth());
     371
     372  // check all LUT sizes
     373  xxGetAllLutSizes(pSlice); 
     374  if (m_nTotalLutSizes == 0) // return if no valid size is found, LUT will not be updated
     375  {
     376    nCurOctantDepth = sMaxLutSize.iCPartNumLog2;
     377    nCurYPartNumLog2 = sMaxLutSize.iYPartNumLog2-nCurOctantDepth;
     378    xUpdatePartitioning( nCurOctantDepth , nCurYPartNumLog2, nBestAdaptCThresholdU, nBestAdaptCThresholdV );
     379    return MAX_DOUBLE;
     380  }
     381
     382  dMinCost = MAX_DOUBLE; dMinError = MAX_DOUBLE;
     383  for (i = 0; i < m_nTotalLutSizes; i++)
     384  {
     385    // add up the stats
     386    nCurOctantDepth = m_sLutSizes[i].iCPartNumLog2;
     387    nCurYPartNumLog2 = m_sLutSizes[i].iYPartNumLog2-nCurOctantDepth;
     388    xUpdatePartitioning( nCurOctantDepth , nCurYPartNumLog2, nBestAdaptCThresholdU, nBestAdaptCThresholdV );
     389    xxConsolidateData( &m_sLutSizes[i], &sMaxLutSize );
     390 
     391    dCurError = xxDeriveVertexes(nBestResQuanBit, m_pEncCuboid);
     392
     393    setResQuantBit( nBestResQuanBit );
     394    xSaveCuboids( m_pEncCuboid );
     395    m_pEncCavlc->xCode3DAsymLUT( this );
     396    iNumBitsCurSize = m_pEncCavlc->getNumberOfWrittenBits();
     397    dCurCost = dCurError/dDistFactor + dFrameLambda*(Double)(iNumBitsCurSize-iNumBitsCurSizeSave); 
     398    nTmpLutBits[m_sLutSizes[i].iYPartNumLog2][m_sLutSizes[i].iCPartNumLog2] = iNumBitsCurSize-iNumBitsCurSizeSave; // store LUT size
     399    iNumBitsCurSizeSave = iNumBitsCurSize;
     400    if(dCurCost < dMinCost )
     401    {
     402      SCuboid *** tmp = m_pBestEncCuboid;
     403      m_pBestEncCuboid = m_pEncCuboid;
     404      m_pEncCuboid = tmp;
     405      dMinCost = dCurCost;
     406      dMinError = dCurError;
     407      iBestLUTSizeIdx = i;
     408    }
     409  }
     410
     411  nCurOctantDepth = m_sLutSizes[iBestLUTSizeIdx].iCPartNumLog2;
     412  nCurYPartNumLog2 = m_sLutSizes[iBestLUTSizeIdx].iYPartNumLog2-nCurOctantDepth;
     413
     414  xUpdatePartitioning( nCurOctantDepth , nCurYPartNumLog2, nBestAdaptCThresholdU, nBestAdaptCThresholdV );
     415
     416  Bool bUseNewColorInfo = false;
     417  if( pCfg->getCGSAdaptChroma() && nCurOctantDepth <= 1 ) // if the best size found so far has depth = 0 or 1, then check AdaptC U/V thresholds
     418  {
     419    nAdaptCThresholdU = ( Int )( m_dSumU / m_nNChroma + 0.5 );
     420    nAdaptCThresholdV = ( Int )( m_dSumV / m_nNChroma + 0.5 );
     421    if( !(nAdaptCThresholdU == nBestAdaptCThresholdU && nAdaptCThresholdV == nBestAdaptCThresholdV ) )
     422    {
     423      nCurOctantDepth = 1;
     424      if( nCurOctantDepth + nCurYPartNumLog2 > getMaxYPartNumLog2()+getMaxOctantDepth() )
     425        nCurYPartNumLog2 = getMaxYPartNumLog2()+getMaxOctantDepth()-nCurOctantDepth;
     426      xUpdatePartitioning( nCurOctantDepth , nCurYPartNumLog2 , nAdaptCThresholdU , nAdaptCThresholdV );
     427      xxCollectData( pCurPic , refLayerIdc );
     428
     429      dCurError = xxDeriveVertexes( nBestResQuanBit , m_pEncCuboid ) ;
     430      setResQuantBit( nBestResQuanBit );
     431      xSaveCuboids( m_pEncCuboid );
     432      m_pEncCavlc->xCode3DAsymLUT( this );
     433      iNumBitsCurSize = m_pEncCavlc->getNumberOfWrittenBits();
     434      dCurCost = dCurError/dDistFactor + dFrameLambda*(Double)(iNumBitsCurSize-iNumBitsCurSizeSave); 
     435      iNumBitsCurSizeSave = iNumBitsCurSize;
     436      if(dCurCost < dMinCost )
     437      {
     438        SCuboid *** tmp = m_pBestEncCuboid;
     439        m_pBestEncCuboid = m_pEncCuboid;
     440        m_pEncCuboid = tmp;
     441        dMinCost = dCurCost;
     442        dMinError = dCurError;
     443        nBestAdaptCThresholdU = nAdaptCThresholdU;
     444        nBestAdaptCThresholdV = nAdaptCThresholdV;
     445        bUseNewColorInfo = true;
     446      }
     447    }
     448  }
     449
     450  xUpdatePartitioning( nCurOctantDepth , nCurYPartNumLog2, nBestAdaptCThresholdU, nBestAdaptCThresholdV );
     451
     452  // check res_quant_bits only for the best table size and best U/V threshold
     453  if( !bUseNewColorInfo )
     454    xxConsolidateData( &m_sLutSizes[iBestLUTSizeIdx], &sMaxLutSize );
     455
     456  //    xxCollectData( pCurPic , refLayerIdc );
     457  for( Int nResQuanBit = 1 ; nResQuanBit < 4 ; nResQuanBit++ )
     458  {
     459    dCurError = xxDeriveVertexes( nResQuanBit , m_pEncCuboid );
     460
     461    setResQuantBit( nResQuanBit );
     462    xSaveCuboids( m_pEncCuboid );
     463    m_pEncCavlc->xCode3DAsymLUT( this );
     464    iNumBitsCurSize = m_pEncCavlc->getNumberOfWrittenBits();
     465    dCurCost = dCurError/dDistFactor + dFrameLambda*(Double)(iNumBitsCurSize-iNumBitsCurSizeSave);   
     466
     467    iNumBitsCurSizeSave = iNumBitsCurSize;
     468    if(dCurCost < dMinCost)
     469    {
     470      nBestResQuanBit = nResQuanBit;
     471      SCuboid *** tmp = m_pBestEncCuboid;
     472      m_pBestEncCuboid = m_pEncCuboid;
     473      m_pEncCuboid = tmp;
     474      dMinCost = dCurCost;
     475      dMinError = dCurError;
     476    }
     477    else
     478    {
     479      break;
     480    }
     481  }
     482   
     483  setResQuantBit( nBestResQuanBit );
     484  xSaveCuboids( m_pBestEncCuboid );
     485
     486  // update LUT size stats
     487  for(Int iLutSizeY = 0; iLutSizeY < MAX_Y_SIZE; iLutSizeY++)
     488  {
     489    for(Int iLutSizeC = 0; iLutSizeC < MAX_C_SIZE; iLutSizeC++)
     490    {
     491      if(nTmpLutBits[iLutSizeY][iLutSizeC] != 0)
     492        m_nNumLUTBits[iLutSizeY][iLutSizeC] =  (m_nNumLUTBits[iLutSizeY][iLutSizeC] + nTmpLutBits[iLutSizeY][iLutSizeC]*3+2)>>2; // update with new stats
     493    }
     494  }
     495
     496  // return cost rather than error
     497  return( dMinCost );
     498}
     499#endif
     500
     501
     502Double TEnc3DAsymLUT::derive3DAsymLUT( TComSlice * pSlice , TComPic * pCurPic , UInt refLayerIdc , TEncCfg * pCfg , Bool bSignalPPS , Bool bElRapSliceTypeB )
     503{
     504  m_nLUTBitDepth = pCfg->getCGSLUTBit();
     505  Int nCurYPartNumLog2 = 0 , nCurOctantDepth = 0;
     506  xxDerivePartNumLog2( pSlice , pCfg , nCurOctantDepth , nCurYPartNumLog2 , bSignalPPS , bElRapSliceTypeB );
     507
     508  Int nBestResQuanBit = 0;
     509  Int nBestAdaptCThresholdU = 1 << ( getInputBitDepthC() - 1 );
     510  Int nBestAdaptCThresholdV = 1 << ( getInputBitDepthC() - 1 );
     511  Int nBestOctantDepth = nCurOctantDepth;
     512  Int nBestYPartNumLog2 = nCurYPartNumLog2;
     513  Int nTargetLoop = 1 + ( pCfg->getCGSAdaptChroma() && ( nCurOctantDepth == 1 || ( nCurOctantDepth * 3 + nCurYPartNumLog2 ) >= 5 ) );
     514  Double dMinError = MAX_DOUBLE;
     515  for( Int nLoop = 0 ; nLoop < nTargetLoop ; nLoop++ )
     516  {
     517    Int nAdaptCThresholdU = 1 << ( getInputBitDepthC() - 1 );
     518    Int nAdaptCThresholdV = 1 << ( getInputBitDepthC() - 1 );
     519    if( nLoop > 0 )
     520    {
     521      nAdaptCThresholdU = ( Int )( m_dSumU / m_nNChroma + 0.5 );
     522      nAdaptCThresholdV = ( Int )( m_dSumV / m_nNChroma + 0.5 );
     523      if( nCurOctantDepth > 1 )
     524      {
     525        nCurOctantDepth = 1;
     526        nCurYPartNumLog2 = 2;
     527      }
     528      if( nAdaptCThresholdU == nBestAdaptCThresholdU && nAdaptCThresholdV == nBestAdaptCThresholdV
     529        && nCurOctantDepth == nBestOctantDepth && nCurYPartNumLog2 == nBestYPartNumLog2 )
     530        break;
     531    }
     532
     533    xUpdatePartitioning( nCurOctantDepth , nCurYPartNumLog2 , nAdaptCThresholdU , nAdaptCThresholdV );
     534    xxCollectData( pCurPic , refLayerIdc );
     535    for( Int nResQuanBit = 0 ; nResQuanBit < 4 ; nResQuanBit++ )
     536    {
     537      Double dError = xxDeriveVertexes( nResQuanBit , m_pEncCuboid ) / ( 1 + ( nResQuanBit > 0 ) * 0.001 * ( pSlice->getDepth() + 1 ) );
     538      if( dError <= dMinError )
     539      {
     540        nBestResQuanBit = nResQuanBit;
     541        nBestAdaptCThresholdU = nAdaptCThresholdU;
     542        nBestAdaptCThresholdV = nAdaptCThresholdV;
     543        nBestOctantDepth = nCurOctantDepth;
     544        nBestYPartNumLog2 = nCurYPartNumLog2;
     545        SCuboid *** tmp = m_pBestEncCuboid;
     546        m_pBestEncCuboid = m_pEncCuboid;
     547        m_pEncCuboid = tmp;
     548        dMinError = dError;
     549      }
     550      else
     551      {
     552        break;
     553      }
     554    }
     555  }
     556
     557  setResQuantBit( nBestResQuanBit );
     558  xUpdatePartitioning( nBestOctantDepth , nBestYPartNumLog2 , nBestAdaptCThresholdU , nBestAdaptCThresholdV );
     559
     560  xSaveCuboids( m_pBestEncCuboid );
     561  return( dMinError );
     562}
     563#else
    177564Double TEnc3DAsymLUT::derive3DAsymLUT( TComSlice * pSlice , TComPic * pCurPic , UInt refLayerIdc , TEncCfg * pCfg , Bool bSignalPPS , Bool bElRapSliceTypeB )
    178565{
     
    204591  setResQuantBit( nBestResQuanBit );
    205592  xSaveCuboids( m_pBestEncCuboid );
    206 
    207593  return( dCurError );
    208594}
     595#endif
    209596
    210597Double TEnc3DAsymLUT::xxDeriveVertexes( Int nResQuanBit , SCuboid *** pCurCuboid )
     
    213600  Int nYSize = 1 << ( getCurOctantDepth() + getCurYPartNumLog2() );
    214601  Int nUVSize = 1 << getCurOctantDepth();
     602#if !R0151_CGS_3D_ASYMLUT_IMPROVE
    215603  Int nLengthY = 1 << ( getInputBitDepthY() - getCurOctantDepth() - getCurYPartNumLog2() );
    216604  Int nLengthUV = 1 << ( getInputBitDepthC() - getCurOctantDepth() );
     605#endif
    217606  for( Int yIdx = 0 ; yIdx < nYSize ; yIdx++ )
    218607  {
     
    224613        SColorInfo & rCuboidColorInfoC = m_pColorInfoC[yIdx][uIdx][vIdx];
    225614        SCuboid & rCuboid = pCurCuboid[yIdx][uIdx][vIdx];
     615#if !R0151_CGS_3D_ASYMLUT_IMPROVE
    226616        Int y0 = yIdx << xGetYShift2Idx();
    227617        Int u0 = uIdx << xGetUShift2Idx();
    228618        Int v0 = vIdx << xGetVShift2Idx();
     619#endif
    229620        for( Int idxVertex = 0 ; idxVertex < 4 ; idxVertex++ )
    230621        {
     
    235626        {
    236627          dErrorLuma += xxDeriveVertexPerColor( rCuboidColorInfo.N , rCuboidColorInfo.Ys , rCuboidColorInfo.Yy , rCuboidColorInfo.Yu , rCuboidColorInfo.Yv , rCuboidColorInfo.ys , rCuboidColorInfo.us , rCuboidColorInfo.vs , rCuboidColorInfo.yy , rCuboidColorInfo.yu , rCuboidColorInfo.yv , rCuboidColorInfo.uu , rCuboidColorInfo.uv , rCuboidColorInfo.vv , rCuboidColorInfo.YY ,
    237             y0 , u0 , v0 , nLengthY , nLengthUV , rCuboid.P[0].Y , rCuboid.P[1].Y , rCuboid.P[2].Y , rCuboid.P[3].Y , nResQuanBit );
     628#if !R0151_CGS_3D_ASYMLUT_IMPROVE
     629            y0 , u0 , v0 , nLengthY , nLengthUV ,
     630#endif
     631            rCuboid.P[0].Y , rCuboid.P[1].Y , rCuboid.P[2].Y , rCuboid.P[3].Y , nResQuanBit );
    238632        }
    239633        if( rCuboidColorInfoC.N > 0 )
    240634        {
    241635          dErrorChroma += xxDeriveVertexPerColor( rCuboidColorInfoC.N , rCuboidColorInfoC.Us , rCuboidColorInfoC.Uy , rCuboidColorInfoC.Uu , rCuboidColorInfoC.Uv , rCuboidColorInfoC.ys , rCuboidColorInfoC.us , rCuboidColorInfoC.vs , rCuboidColorInfoC.yy , rCuboidColorInfoC.yu , rCuboidColorInfoC.yv , rCuboidColorInfoC.uu , rCuboidColorInfoC.uv , rCuboidColorInfoC.vv , rCuboidColorInfoC.UU ,
    242             y0 , u0 , v0 , nLengthY , nLengthUV , rCuboid.P[0].U , rCuboid.P[1].U , rCuboid.P[2].U , rCuboid.P[3].U , nResQuanBit );
     636#if !R0151_CGS_3D_ASYMLUT_IMPROVE
     637            y0 , u0 , v0 , nLengthY , nLengthUV ,
     638#endif
     639            rCuboid.P[0].U , rCuboid.P[1].U , rCuboid.P[2].U , rCuboid.P[3].U , nResQuanBit );
    243640          dErrorChroma += xxDeriveVertexPerColor( rCuboidColorInfoC.N , rCuboidColorInfoC.Vs , rCuboidColorInfoC.Vy , rCuboidColorInfoC.Vu , rCuboidColorInfoC.Vv , rCuboidColorInfoC.ys , rCuboidColorInfoC.us , rCuboidColorInfoC.vs , rCuboidColorInfoC.yy , rCuboidColorInfoC.yu , rCuboidColorInfoC.yv , rCuboidColorInfoC.uu , rCuboidColorInfoC.uv , rCuboidColorInfoC.vv , rCuboidColorInfoC.VV ,
    244             y0 , u0 , v0 , nLengthY , nLengthUV , rCuboid.P[0].V , rCuboid.P[1].V , rCuboid.P[2].V , rCuboid.P[3].V , nResQuanBit );
     641#if !R0151_CGS_3D_ASYMLUT_IMPROVE
     642            y0 , u0 , v0 , nLengthY , nLengthUV ,
     643#endif
     644            rCuboid.P[0].V , rCuboid.P[1].V , rCuboid.P[2].V , rCuboid.P[3].V , nResQuanBit );
    245645        }
    246646
     
    276676  Int nStrideILRY = pRecPic->getStride();
    277677  Int nStrideILRC = pRecPic->getCStride();
     678#if R0179_ENC_OPT_3DLUT_SIZE
     679  xReset3DArray( m_pColorInfo  , getMaxYSize() , getMaxCSize() , getMaxCSize() );
     680  xReset3DArray( m_pColorInfoC , getMaxYSize() , getMaxCSize() , getMaxCSize() );
     681#else
    278682  xReset3DArray( m_pColorInfo , xGetYSize() , xGetUSize() , xGetVSize() );
    279683  xReset3DArray( m_pColorInfoC , xGetYSize() , xGetUSize() , xGetVSize() );
     684#endif
    280685
    281686  //alignment padding
     
    285690  TComSlice * pSlice = pCurPic->getSlice(pCurPic->getCurrSliceIdx());
    286691  UInt refLayerId = pSlice->getVPS()->getRefLayerId(pSlice->getLayerId(), refLayerIdc);
     692#if MOVE_SCALED_OFFSET_TO_PPS
     693  const Window &scalEL = pSlice->getPPS()->getScaledRefLayerWindowForLayer(refLayerId);
     694#else
    287695  const Window &scalEL = pSlice->getSPS()->getScaledRefLayerWindowForLayer(refLayerId);
     696#endif
    288697  TComPicYuv *pcRecPicBL = pSlice->getBaseColPic(refLayerIdc)->getPicYuvRec();
    289698  // borders of down-sampled picture
     
    299708  // since we do data collection only for overlapped region, the border extension is good enough
    300709
     710#if R0151_CGS_3D_ASYMLUT_IMPROVE
     711  m_dSumU = m_dSumV = 0;
     712  m_nNChroma = 0;
     713#endif
    301714  for( Int i = top ; i <= bottom ; i++ )
    302715  {
     
    330743      }
    331744
     745#if R0151_CGS_3D_ASYMLUT_IMPROVE
     746      m_dSumU += u;
     747      m_dSumV += v;
     748      m_nNChroma++;
     749#endif
    332750      SColorInfo sColorInfo;
     751#if R0151_CGS_3D_ASYMLUT_IMPROVE
     752      SColorInfo & rCuboidColorInfo = m_pColorInfo[xGetYIdx(y)][xGetUIdx(u)][xGetVIdx(v)];
     753#else
    333754      SColorInfo & rCuboidColorInfo = m_pColorInfo[y>>xGetYShift2Idx()][u>>xGetUShift2Idx()][v>>xGetVShift2Idx()];
     755#endif
    334756      memset(&sColorInfo, 0, sizeof(SColorInfo));
    335757      sColorInfo.Ys = Y;
     
    358780        u = pIRLU[posIRLUV];
    359781        v = pIRLV[posIRLUV];
     782#if R0151_CGS_3D_ASYMLUT_IMPROVE
     783        SColorInfo & rCuboidColorInfoC = m_pColorInfoC[xGetYIdx(y)][xGetUIdx(u)][xGetVIdx(v)];
     784#else
    360785        SColorInfo & rCuboidColorInfoC = m_pColorInfoC[y>>xGetYShift2Idx()][u>>xGetUShift2Idx()][v>>xGetVShift2Idx()];
     786#endif
    361787        sColorInfo.Us = U;
    362788        sColorInfo.Vs = V;
     
    389815Void TEnc3DAsymLUT::xxDerivePartNumLog2( TComSlice * pSlice , TEncCfg * pcCfg , Int & rOctantDepth , Int & rYPartNumLog2 , Bool bSignalPPS , Bool bElRapSliceTypeB )
    390816{
     817#if !R0151_CGS_3D_ASYMLUT_IMPROVE
    391818  Int nSliceType = pSlice->getSliceType();
    392819  // update slice type as what will be done later
     
    406833
    407834  const Int nSliceTempLevel = pSlice->getDepth();
     835#endif
    408836  Int nPartNumLog2 = 4;
    409837  if( pSlice->getBaseColPic( pSlice->getInterLayerPredLayerIdc( 0 ) )->getSlice( 0 )->isIntra() )
     
    411839    nPartNumLog2 = xGetMaxPartNumLog2();
    412840  }
     841#if R0151_CGS_3D_ASYMLUT_IMPROVE
     842  if( m_nAccuFrameBit && pSlice->getPPS()->getCGSFlag() )
     843  {
     844    Double dBitCost = 1.0 * m_nAccuFrameCGSBit / m_nAccuFrameBit;
     845    nPartNumLog2 = m_nPrevFrameCGSPartNumLog2;
     846#else
    413847  if( m_nPrevFrameBit[nSliceType][nSliceTempLevel] && pSlice->getPPS()->getCGSFlag() )
    414848  {
    415849    Double dBitCost = 1.0 * m_nPrevFrameCGSBit[nSliceType][nSliceTempLevel] / m_nPrevFrameBit[nSliceType][nSliceTempLevel];
    416850    nPartNumLog2 = m_nPrevFrameCGSPartNumLog2[nSliceType][nSliceTempLevel];
     851#endif
    417852    Double dBitCostT = 0.03;
    418853    if( dBitCost < dBitCostT / 6.0 )
     
    425860    }
    426861  }
     862#if !R0151_CGS_3D_ASYMLUT_IMPROVE
    427863  else
    428864  {
    429865    nPartNumLog2 -= nSliceTempLevel;
    430866  }
    431   nPartNumLog2 = Clip3( 0 , xGetMaxPartNumLog2() , nPartNumLog2 );
     867#endif
     868  nPartNumLog2 = Clip3( 0 , xGetMaxPartNumLog2()  , nPartNumLog2 );
    432869  xxMapPartNum2DepthYPart( nPartNumLog2 , rOctantDepth , rYPartNumLog2 );
    433870}
     
    453890Void TEnc3DAsymLUT::updatePicCGSBits( TComSlice * pcSlice , Int nPPSBit )
    454891{
     892#if !R0151_CGS_3D_ASYMLUT_IMPROVE
    455893  const Int nSliceType = pcSlice->getSliceType();
    456894  const Int nSliceTempLevel = pcSlice->getDepth();
    457 
     895#endif
    458896  for( Int i = 0; i < pcSlice->getActiveNumILRRefIdx(); i++ )
    459897  {
    460898    UInt refLayerIdc = pcSlice->getInterLayerPredLayerIdc(i);
     899#if R0151_CGS_3D_ASYMLUT_IMPROVE
     900    m_nAccuFrameBit += pcSlice->getPic()->getFrameBit() + pcSlice->getBaseColPic(refLayerIdc)->getFrameBit();
     901#else
    461902    m_nPrevFrameBit[nSliceType][nSliceTempLevel] = pcSlice->getPic()->getFrameBit() + pcSlice->getBaseColPic(refLayerIdc)->getFrameBit();
     903#endif
    462904    m_dTotalFrameBit += pcSlice->getPic()->getFrameBit() + pcSlice->getBaseColPic(refLayerIdc)->getFrameBit();
    463905  }
     906#if R0151_CGS_3D_ASYMLUT_IMPROVE
     907  m_nAccuFrameCGSBit += nPPSBit;
     908  m_nTotalCGSBit += nPPSBit;
     909  m_nPrevFrameCGSPartNumLog2 = getCurOctantDepth() * 3 + getCurYPartNumLog2();
     910#else
    464911  m_nPrevFrameOverWritePPS[nSliceType][nSliceTempLevel] = pcSlice->getCGSOverWritePPS();
    465912  m_nPrevFrameCGSBit[nSliceType][nSliceTempLevel] = nPPSBit;
    466913  m_nTotalCGSBit += nPPSBit;
    467914  m_nPrevFrameCGSPartNumLog2[nSliceType][nSliceTempLevel] = getCurOctantDepth() * 3 + getCurYPartNumLog2();
    468 }
    469 
    470 #endif
     915#endif
     916#if R0179_ENC_OPT_3DLUT_SIZE
     917  Int nCurELFrameBit = pcSlice->getPic()->getFrameBit();
     918  const Int nSliceType = pcSlice->getSliceType();
     919  const Int nSliceTempLevel = pcSlice->getDepth();
     920  m_nPrevELFrameBit[nSliceType][nSliceTempLevel] = m_nPrevELFrameBit[nSliceType][nSliceTempLevel] == 0 ? nCurELFrameBit:((m_nPrevELFrameBit[nSliceType][nSliceTempLevel]+nCurELFrameBit)>>1);
     921#endif
     922}
     923
     924#if R0179_ENC_OPT_3DLUT_SIZE
     925
     926Void TEnc3DAsymLUT::xxGetAllLutSizes(TComSlice *pSlice)
     927{
     928  Int iMaxYPartNumLog2, iMaxCPartNumLog2;
     929  Int iCurYPartNumLog2, iCurCPartNumLog2;
     930  Int iMaxAddYPartNumLog2;
     931  Int iNumELFrameBits = m_nPrevELFrameBit[pSlice->getSliceType()][pSlice->getDepth()];
     932
     933  xxMapPartNum2DepthYPart( xGetMaxPartNumLog2() , iMaxCPartNumLog2 , iMaxYPartNumLog2 );
     934  iMaxAddYPartNumLog2 = iMaxYPartNumLog2;
     935  iMaxYPartNumLog2 += iMaxCPartNumLog2;
     936
     937  //m_sLutSizes[0].iYPartNumLog2 = iMaxYPartNumLog2;
     938  //m_sLutSizes[0].iCPartNumLog2 = iMaxCPartNumLog2;
     939  m_nTotalLutSizes = 0;
     940
     941
     942  for(iCurYPartNumLog2 = iMaxYPartNumLog2; iCurYPartNumLog2 >= 0; iCurYPartNumLog2--)
     943  {
     944    for(iCurCPartNumLog2 = iMaxCPartNumLog2; iCurCPartNumLog2 >= 0; iCurCPartNumLog2--)
     945    {
     946       // try more sizes
     947      if(iCurCPartNumLog2 <= iCurYPartNumLog2  &&
     948         (m_nNumLUTBits[iCurYPartNumLog2][iCurCPartNumLog2] < (iNumELFrameBits>>1)) &&
     949         m_nTotalLutSizes < MAX_NUM_LUT_SIZES)
     950      {
     951        m_sLutSizes[m_nTotalLutSizes].iYPartNumLog2 = iCurYPartNumLog2;
     952        m_sLutSizes[m_nTotalLutSizes].iCPartNumLog2 = iCurCPartNumLog2;
     953        m_nTotalLutSizes ++;
     954      }
     955    }
     956  }
     957
     958}
     959
     960Void TEnc3DAsymLUT::xxCopyColorInfo( SColorInfo *** dst, SColorInfo *** src ,  SColorInfo *** dstC, SColorInfo *** srcC )
     961{
     962  Int yIdx, uIdx, vIdx;
     963
     964  // copy from pColorInfo to pMaxColorInfo
     965  for(yIdx = 0; yIdx < xGetYSize(); yIdx++)
     966  {
     967    for(uIdx = 0; uIdx < xGetUSize(); uIdx++)
     968    {
     969      for(vIdx = 0; vIdx < xGetVSize(); vIdx++)
     970      {
     971        dst [yIdx][uIdx][vIdx] = src [yIdx][uIdx][vIdx];
     972        dstC[yIdx][uIdx][vIdx] = srcC[yIdx][uIdx][vIdx];
     973      }
     974    }
     975  }
     976}
     977
     978Void TEnc3DAsymLUT::xxAddColorInfo( Int yIdx, Int uIdx, Int vIdx, Int iYDiffLog2, Int iCDiffLog2 )
     979{
     980  SColorInfo & rCuboidColorInfo  = m_pColorInfo [yIdx][uIdx][vIdx];
     981  SColorInfo & rCuboidColorInfoC = m_pColorInfoC[yIdx][uIdx][vIdx];
     982 
     983  for( Int i = 0; i < (1<<iYDiffLog2); i++)
     984  {
     985    for (Int j = 0; j < (1<<iCDiffLog2); j++)
     986    {
     987      for(Int k = 0; k < (1<<iCDiffLog2); k++)
     988      {
     989        rCuboidColorInfo  += m_pMaxColorInfo [(yIdx<<iYDiffLog2)+i][(uIdx<<iCDiffLog2)+j][(vIdx<<iCDiffLog2)+k];
     990        rCuboidColorInfoC += m_pMaxColorInfoC[(yIdx<<iYDiffLog2)+i][(uIdx<<iCDiffLog2)+j][(vIdx<<iCDiffLog2)+k];
     991      }
     992    }
     993  }
     994}
     995
     996Void TEnc3DAsymLUT::xxConsolidateData( SLUTSize *pCurLUTSize, SLUTSize *pMaxLUTSize )
     997{
     998  Int yIdx, uIdx, vIdx;
     999  Int iYDiffLog2, iCDiffLog2;
     1000  Int nYSize = 1<< pMaxLUTSize->iYPartNumLog2;
     1001  Int nCSize = 1<< pMaxLUTSize->iCPartNumLog2;
     1002
     1003  iYDiffLog2 = pMaxLUTSize->iYPartNumLog2-pCurLUTSize->iYPartNumLog2;
     1004  iCDiffLog2 = pMaxLUTSize->iCPartNumLog2-pCurLUTSize->iCPartNumLog2;
     1005
     1006  //assert(pMaxLUTSize->iCPartNumLog2 >= pCurLUTSize->iCPartNumLog2 && pMaxLUTSize->iYPartNumLog2 >= pCurLUTSize->iYPartNumLog2);
     1007  if (iYDiffLog2 == 0 && iCDiffLog2 == 0) // shouldn't have to do anything
     1008  {
     1009    xxCopyColorInfo(m_pColorInfo, m_pMaxColorInfo, m_pColorInfoC, m_pMaxColorInfoC);
     1010    return;
     1011  }
     1012
     1013  xReset3DArray( m_pColorInfo  ,  1<<pMaxLUTSize->iYPartNumLog2, 1<<pMaxLUTSize->iCPartNumLog2, 1<<pMaxLUTSize->iCPartNumLog2 );
     1014  xReset3DArray( m_pColorInfoC ,  1<<pMaxLUTSize->iYPartNumLog2, 1<<pMaxLUTSize->iCPartNumLog2, 1<<pMaxLUTSize->iCPartNumLog2 );
     1015
     1016  for(yIdx = 0; yIdx < nYSize; yIdx++)
     1017  {
     1018    for(uIdx = 0; uIdx < nCSize; uIdx++)
     1019    {
     1020      for(vIdx = 0; vIdx < nCSize; vIdx++)
     1021      {
     1022        const SColorInfo & rCuboidSrc   = m_pMaxColorInfo [yIdx][uIdx][vIdx];
     1023        const SColorInfo & rCuboidSrcC  = m_pMaxColorInfoC[yIdx][uIdx][vIdx];
     1024       
     1025        Int yIdx2, uIdx2, vIdx2;
     1026        yIdx2 = yIdx>>iYDiffLog2;
     1027        uIdx2 = uIdx>>iCDiffLog2;
     1028        vIdx2 = vIdx>>iCDiffLog2;
     1029
     1030        m_pColorInfo [yIdx2][uIdx2][vIdx2] += rCuboidSrc;
     1031        m_pColorInfoC[yIdx2][uIdx2][vIdx2] += rCuboidSrcC;
     1032      }
     1033    }
     1034  }
     1035}
     1036
     1037Void TEnc3DAsymLUT::update3DAsymLUTParam( TEnc3DAsymLUT * pSrc )
     1038{
     1039  assert( pSrc->getMaxOctantDepth() == getMaxOctantDepth() && pSrc->getMaxYPartNumLog2() == getMaxYPartNumLog2() );
     1040  xUpdatePartitioning( pSrc->getCurOctantDepth() , pSrc->getCurYPartNumLog2()
     1041#if R0151_CGS_3D_ASYMLUT_IMPROVE
     1042    , pSrc->getAdaptChromaThresholdU() , pSrc->getAdaptChromaThresholdV()
     1043#endif
     1044    );
     1045  setResQuantBit( pSrc->getResQuantBit() );
     1046}
     1047
     1048#endif
     1049#endif
  • trunk/source/Lib/TLibEncoder/TEnc3DAsymLUT.h

    r713 r906  
    88#include "../TLibCommon/TComPic.h"
    99#include "TEncCfg.h"
     10#if R0179_ENC_OPT_3DLUT_SIZE
     11#include "TEncCavlc.h"
     12#define MAX_NUM_LUT_SIZES               10   // 4+3+2+1
     13#define MAX_Y_SIZE                       4
     14#define MAX_C_SIZE                       4
     15#endif
    1016
    1117#if Q0048_CGS_3D_ASYMLUT
     
    5561}SColorInfo;
    5662
     63#if R0179_ENC_OPT_3DLUT_SIZE
     64typedef struct _LUTSize
     65{
     66  Int iYPartNumLog2;
     67  Int iCPartNumLog2;
     68} SLUTSize;
     69#endif
    5770
    5871class TEnc3DAsymLUT : public TCom3DAsymLUT
     
    6679  Double derive3DAsymLUT( TComSlice * pSlice , TComPic * pCurPic , UInt refLayerIdc , TEncCfg * pCfg , Bool bSignalPPS , Bool bElRapSliceTypeB );
    6780  Double estimateDistWithCur3DAsymLUT( TComPic * pCurPic , UInt refLayerIdc );
     81#if R0179_ENC_OPT_3DLUT_SIZE
     82  Double getDistFactor( Int iSliceType, Int iLayer) { return m_dDistFactor[iSliceType][iLayer];}
     83  Double derive3DAsymLUT( TComSlice * pSlice , TComPic * pCurPic , UInt refLayerIdc , TEncCfg * pCfg , Bool bSignalPPS , Bool bElRapSliceTypeB, Double dFrameLambda );
     84  Void   update3DAsymLUTParam( TEnc3DAsymLUT * pSrc );
     85#endif
    6886
    6987  Void  updatePicCGSBits( TComSlice * pcSlice , Int nPPSBit );
     
    7593  SColorInfo *** m_pColorInfo;
    7694  SColorInfo *** m_pColorInfoC;
     95#if R0179_ENC_OPT_3DLUT_SIZE
     96  SColorInfo *** m_pMaxColorInfo;
     97  SColorInfo *** m_pMaxColorInfoC;
     98#endif
    7799  TComPicYuv* m_pDsOrigPic;
    78100  SCuboid *** m_pEncCuboid;
    79101  SCuboid *** m_pBestEncCuboid;
     102#if R0151_CGS_3D_ASYMLUT_IMPROVE
     103  Int   m_nAccuFrameBit;                  // base + enhancement layer
     104  Int   m_nAccuFrameCGSBit;
     105  Int   m_nPrevFrameCGSPartNumLog2;
     106#else
    80107  Int   m_nPrevFrameBit[3][MAX_TLAYER];                  // base + enhancement layer
    81108  Int   m_nPrevFrameCGSBit[3][MAX_TLAYER];
    82109  Int   m_nPrevFrameCGSPartNumLog2[3][MAX_TLAYER];
    83110  Int   m_nPrevFrameOverWritePPS[3][MAX_TLAYER];
     111#endif
    84112  Double m_dTotalFrameBit;
    85113  Int   m_nTotalCGSBit;
    86114  Int   m_nPPSBit;
    87115  Int   m_nLUTBitDepth;
     116#if R0179_ENC_OPT_3DLUT_SIZE
     117
     118  Double m_dDistFactor[3][MAX_TLAYER];         
     119  Int    m_nNumLUTBits[MAX_Y_SIZE][MAX_C_SIZE];
     120  Int    m_nPrevELFrameBit[3][MAX_TLAYER];   
     121
     122
     123  Int   m_nTotalLutSizes;
     124  SLUTSize m_sLutSizes[MAX_NUM_LUT_SIZES];
     125#endif
     126#if R0151_CGS_3D_ASYMLUT_IMPROVE
     127  Double m_dSumU;
     128  Double m_dSumV;
     129  Int    m_nNChroma;
     130#endif
     131#if R0179_ENC_OPT_3DLUT_SIZE
     132  TComOutputBitstream  *m_pBitstreamRedirect;
     133  TEncCavlc *m_pEncCavlc;
     134#endif
    88135
    89136private:
     137#if R0151_CGS_3D_ASYMLUT_IMPROVE
     138  Double  xxDeriveVertexPerColor( Double N , Double Ys , Double Yy , Double Yu , Double Yv , Double ys , Double us , Double vs , Double yy , Double yu , Double yv , Double uu , Double uv , Double vv , Double YY ,
     139    Pel & rP0 , Pel & rP1 , Pel & rP3 , Pel & rP7 , Int nResQuantBit );
     140#else
    90141  Double  xxDeriveVertexPerColor( Double N , Double Ys , Double Yy , Double Yu , Double Yv , Double ys , Double us , Double vs , Double yy , Double yu , Double yv , Double uu , Double uv , Double vv , Double YY ,
    91142    Int y0 , Int u0 , Int v0 , Int nLengthY , Int nLengthUV ,
    92143    Pel & rP0 , Pel & rP1 , Pel & rP3 , Pel & rP7 , Int nResQuantBit );
     144#endif
    93145  Void    xxDerivePartNumLog2( TComSlice * pSlice , TEncCfg * pcCfg , Int & rOctantDepth , Int & rYPartNumLog2 , Bool bSignalPPS , Bool bElRapSliceTypeB );
    94146  Void    xxMapPartNum2DepthYPart( Int nPartNumLog2 , Int & rOctantDepth , Int & rYPartNumLog2 );
    95147  Int     xxCoeff2Vertex( Double a , Double b , Double c , Double d , Int y , Int u , Int v ) { return ( ( Int )( a * y + b * u + c * v + d + 0.5 ) ); }
    96148  Void    xxCollectData( TComPic * pCurPic , UInt refLayerIdc );
     149
    97150  Double  xxDeriveVertexes( Int nResQuantBit , SCuboid *** pCurCuboid );
    98151  inline Double  xxCalEstDist( Double N , Double Ys , Double Yy , Double Yu , Double Yv , Double ys , Double us , Double vs , Double yy , Double yu , Double yv , Double uu , Double uv , Double vv , Double YY ,
     
    100153  inline Double  xxCalEstDist( Double N , Double Ys , Double Yy , Double Yu , Double Yv , Double ys , Double us , Double vs , Double yy , Double yu , Double yv , Double uu , Double uv , Double vv , Double YY ,
    101154    Double a , Double b , Double c , Double d );
     155#if R0151_CGS_3D_ASYMLUT_IMPROVE
     156  inline Double  xxCalEstDist( Double N , Double Ys , Double Yy , Double Yu , Double Yv , Double ys , Double us , Double vs , Double yy , Double yu , Double yv , Double uu , Double uv , Double vv , Double YY ,
     157    Pel nP0 , Pel nP1 , Pel nP3 , Pel nP7 );
     158#endif
     159#if R0179_ENC_OPT_3DLUT_SIZE
     160  Void    xxConsolidateData( SLUTSize *pCurLUTSize, SLUTSize *pMaxLUTSize );
     161  Void    xxGetAllLutSizes(TComSlice *pSlice);
     162  Void    xxCopyColorInfo( SColorInfo *** dst, SColorInfo *** src ,  SColorInfo *** dstC, SColorInfo *** srcC );
     163  Void    xxAddColorInfo( Int yIdx, Int uIdx, Int vIdx, Int iYDiffLog2, Int iCDiffLog2 );
     164#endif
    102165};
    103166
     
    118181  return( dError );
    119182};
    120 #endif
    121 
    122 #endif
     183
     184#if R0151_CGS_3D_ASYMLUT_IMPROVE
     185Double TEnc3DAsymLUT::xxCalEstDist( Double N , Double Ys , Double Yy , Double Yu , Double Yv , Double ys , Double us , Double vs , Double yy , Double yu , Double yv , Double uu , Double uv , Double vv , Double YY ,
     186  Pel nP0 , Pel nP1 , Pel nP3 , Pel nP7 )
     187{
     188  const Int nOne = xGetNormCoeffOne();
     189  Double a = 1.0 * nP0 / nOne;
     190  Double b = 1.0 * nP1 / nOne;
     191  Double c = 1.0 * nP3 / nOne;
     192  Double d = nP7;
     193  Double dError = N * d * d + 2 * b * c * uv + 2 * a * c * yv + 2 * a * b * yu - 2 * c * Yv - 2 * b * Yu - 2 * a * Yy + 2 * c * d * vs + 2 * b * d * us + 2 * a * d * ys + a * a * yy + c * c * vv + b * b * uu - 2 * d * Ys + YY;
     194  return( dError );
     195};
     196#endif
     197
     198#endif
     199
     200#endif
  • trunk/source/Lib/TLibEncoder/TEncCavlc.cpp

    r815 r906  
    193193  if( pcPPS->getTilesEnabledFlag() )
    194194  {
    195     WRITE_UVLC( pcPPS->getNumColumnsMinus1(),                                    "num_tile_columns_minus1" );
    196     WRITE_UVLC( pcPPS->getNumRowsMinus1(),                                       "num_tile_rows_minus1" );
    197     WRITE_FLAG( pcPPS->getUniformSpacingFlag(),                                  "uniform_spacing_flag" );
    198     if( pcPPS->getUniformSpacingFlag() == 0 )
    199     {
    200       for(UInt i=0; i<pcPPS->getNumColumnsMinus1(); i++)
    201       {
    202         WRITE_UVLC( pcPPS->getColumnWidth(i)-1,                                  "column_width_minus1" );
    203       }
    204       for(UInt i=0; i<pcPPS->getNumRowsMinus1(); i++)
    205       {
    206         WRITE_UVLC( pcPPS->getRowHeight(i)-1,                                    "row_height_minus1" );
    207       }
    208     }
    209     if(pcPPS->getNumColumnsMinus1() !=0 || pcPPS->getNumRowsMinus1() !=0)
     195    WRITE_UVLC( pcPPS->getNumTileColumnsMinus1(),                                    "num_tile_columns_minus1" );
     196    WRITE_UVLC( pcPPS->getTileNumRowsMinus1(),                                       "num_tile_rows_minus1" );
     197    WRITE_FLAG( pcPPS->getTileUniformSpacingFlag(),                                  "uniform_spacing_flag" );
     198    if( !pcPPS->getTileUniformSpacingFlag() )
     199    {
     200      for(UInt i=0; i<pcPPS->getNumTileColumnsMinus1(); i++)
     201      {
     202        WRITE_UVLC( pcPPS->getTileColumnWidth(i)-1,                                  "column_width_minus1" );
     203      }
     204      for(UInt i=0; i<pcPPS->getTileNumRowsMinus1(); i++)
     205      {
     206        WRITE_UVLC( pcPPS->getTileRowHeight(i)-1,                                    "row_height_minus1" );
     207      }
     208    }
     209    if(pcPPS->getNumTileColumnsMinus1() !=0 || pcPPS->getTileNumRowsMinus1() !=0)
    210210    {
    211211      WRITE_FLAG( pcPPS->getLoopFilterAcrossTilesEnabledFlag()?1 : 0,          "loop_filter_across_tiles_enabled_flag");
     
    225225  }
    226226
     227#if !R0042_PROFILE_INDICATION
    227228#if SCALINGLIST_INFERRING
    228229  if( pcPPS->getLayerId() > 0 )
     
    241242  {
    242243#endif
     244#endif
    243245
    244246  WRITE_FLAG( pcPPS->getScalingListPresentFlag() ? 1 : 0,                          "pps_scaling_list_data_present_flag" );
     
    247249    codeScalingList( m_pcSlice->getScalingList() );
    248250  }
    249 
     251#if !R0042_PROFILE_INDICATION
    250252#if SCALINGLIST_INFERRING
    251253  }
     254#endif
    252255#endif
    253256
     
    256259  WRITE_FLAG( pcPPS->getSliceHeaderExtensionPresentFlag() ? 1 : 0, "slice_segment_header_extension_present_flag");
    257260#if P0166_MODIFIED_PPS_EXTENSION
     261#if !R0042_PROFILE_INDICATION
    258262  WRITE_FLAG( pcPPS->getExtensionFlag() ? 1 : 0, "pps_extension_flag" );
     263#else
     264  WRITE_FLAG( pcPPS->getExtensionFlag() ? 1 : 0, "pps_extension_present_flag" );
     265#endif
    259266
    260267  if( pcPPS->getExtensionFlag() )
    261268  {
     269#if !R0042_PROFILE_INDICATION
    262270#if !POC_RESET_IDC
    263271    UInt ppsExtensionTypeFlag[8] = { 0, 1, 0, 0, 0, 0, 0, 0 };
     
    273281    {
    274282      WRITE_FLAG( pcPPS->getPocResetInfoPresentFlag() ? 1 : 0, "poc_reset_info_present_flag" );
     283#if REF_REGION_OFFSET
     284      WRITE_UVLC( pcPPS->getNumScaledRefLayerOffsets(),      "num_scaled_ref_layer_offsets" );
     285      for(Int i = 0; i < pcPPS->getNumScaledRefLayerOffsets(); i++)
     286      {
     287        WRITE_CODE( pcPPS->getScaledRefLayerId(i), 6, "scaled_ref_layer_id" );
     288        WRITE_FLAG( pcPPS->getScaledRefLayerOffsetPresentFlag(i) ? 1 : 0, "scaled_ref_layer_offset_prsent_flag" );
     289        if (pcPPS->getScaledRefLayerOffsetPresentFlag(i))
     290        {
     291          Window scaledWindow = pcPPS->getScaledRefLayerWindow(i);
     292          WRITE_SVLC( scaledWindow.getWindowLeftOffset()   >> 1, "scaled_ref_layer_left_offset" );
     293          WRITE_SVLC( scaledWindow.getWindowTopOffset()    >> 1, "scaled_ref_layer_top_offset" );
     294          WRITE_SVLC( scaledWindow.getWindowRightOffset()  >> 1, "scaled_ref_layer_right_offset" );
     295          WRITE_SVLC( scaledWindow.getWindowBottomOffset() >> 1, "scaled_ref_layer_bottom_offset" );
     296        }
     297        WRITE_FLAG( pcPPS->getRefRegionOffsetPresentFlag(i) ? 1 : 0, "ref_region_offset_prsent_flag" );
     298        if (pcPPS->getRefRegionOffsetPresentFlag(i))
     299        {
     300          Window refWindow = pcPPS->getRefLayerWindow(i);
     301          WRITE_SVLC( refWindow.getWindowLeftOffset()   >> 1, "ref_layer_left_offset" );
     302          WRITE_SVLC( refWindow.getWindowTopOffset()    >> 1, "ref_layer_top_offset" );
     303          WRITE_SVLC( refWindow.getWindowRightOffset()  >> 1, "ref_layer_right_offset" );
     304          WRITE_SVLC( refWindow.getWindowBottomOffset() >> 1, "ref_layer_bottom_offset" );
     305        }
     306#if R0209_GENERIC_PHASE
     307        WRITE_FLAG( pcPPS->getResamplePhaseSetPresentFlag(i) ? 1 : 0, "resample_phase_set_present_flag" );
     308        if (pcPPS->getResamplePhaseSetPresentFlag(i))
     309        {
     310          WRITE_UVLC( pcPPS->getPhaseHorLuma(i), "phase_hor_luma" );
     311          WRITE_UVLC( pcPPS->getPhaseVerLuma(i), "phase_ver_luma" );
     312          WRITE_UVLC( pcPPS->getPhaseHorChroma(i) + 8, "phase_hor_chroma_plus8" );
     313          WRITE_UVLC( pcPPS->getPhaseVerChroma(i) + 8, "phase_ver_chroma_plus8" );
     314        }
     315#endif
     316      }
     317#else
     318#if MOVE_SCALED_OFFSET_TO_PPS
     319      WRITE_UVLC( pcPPS->getNumScaledRefLayerOffsets(),      "num_scaled_ref_layer_offsets" );
     320      for(Int i = 0; i < pcPPS->getNumScaledRefLayerOffsets(); i++)
     321      {
     322        Window scaledWindow = pcPPS->getScaledRefLayerWindow(i);
     323#if O0098_SCALED_REF_LAYER_ID
     324        WRITE_CODE( pcPPS->getScaledRefLayerId(i), 6,          "scaled_ref_layer_id" );
     325#endif
     326        WRITE_SVLC( scaledWindow.getWindowLeftOffset()   >> 1, "scaled_ref_layer_left_offset" );
     327        WRITE_SVLC( scaledWindow.getWindowTopOffset()    >> 1, "scaled_ref_layer_top_offset" );
     328        WRITE_SVLC( scaledWindow.getWindowRightOffset()  >> 1, "scaled_ref_layer_right_offset" );
     329        WRITE_SVLC( scaledWindow.getWindowBottomOffset() >> 1, "scaled_ref_layer_bottom_offset" );
     330      }
     331#endif
     332#endif
    275333#if Q0048_CGS_3D_ASYMLUT
    276334      UInt uiPos = getNumberOfWrittenBits();
     
    285343#endif
    286344    }
     345#else
     346  WRITE_FLAG( 0, "pps_range_extension_flag" );
     347  WRITE_FLAG( 1, "pps_multilayer_extension_flag" );
     348  WRITE_CODE( 0, 6,  "pps_extension_6bits" );     
     349
     350  WRITE_FLAG( pcPPS->getPocResetInfoPresentFlag() ? 1 : 0, "poc_reset_info_present_flag" );
     351#if SCALINGLIST_INFERRING
     352  WRITE_FLAG( pcPPS->getInferScalingListFlag() ? 1 : 0, "pps_infer_scaling_list_flag" );
     353  if( pcPPS->getInferScalingListFlag() )
     354  {
     355    // The value of pps_scaling_list_ref_layer_id shall be in the range of 0 to 62, inclusive
     356    assert( pcPPS->getScalingListRefLayerId() <= 62 );
     357    WRITE_UVLC( pcPPS->getScalingListRefLayerId(), "pps_scaling_list_ref_layer_id" );
     358  }
     359#endif
     360
     361#if REF_REGION_OFFSET
     362  WRITE_UVLC( pcPPS->getNumScaledRefLayerOffsets(),      "num_ref_loc_offsets" );
     363  for(Int i = 0; i < pcPPS->getNumScaledRefLayerOffsets(); i++)
     364  {
     365    WRITE_CODE( pcPPS->getScaledRefLayerId(i), 6, "ref_loc_offset_layer_id" );
     366    WRITE_FLAG( pcPPS->getScaledRefLayerOffsetPresentFlag(i) ? 1 : 0, "scaled_ref_layer_offset_prsent_flag" );
     367    if (pcPPS->getScaledRefLayerOffsetPresentFlag(i))
     368    {
     369      Window scaledWindow = pcPPS->getScaledRefLayerWindow(i);
     370      WRITE_SVLC( scaledWindow.getWindowLeftOffset()   >> 1, "scaled_ref_layer_left_offset" );
     371      WRITE_SVLC( scaledWindow.getWindowTopOffset()    >> 1, "scaled_ref_layer_top_offset" );
     372      WRITE_SVLC( scaledWindow.getWindowRightOffset()  >> 1, "scaled_ref_layer_right_offset" );
     373      WRITE_SVLC( scaledWindow.getWindowBottomOffset() >> 1, "scaled_ref_layer_bottom_offset" );
     374    }
     375    WRITE_FLAG( pcPPS->getRefRegionOffsetPresentFlag(i) ? 1 : 0, "ref_region_offset_prsent_flag" );
     376    if (pcPPS->getRefRegionOffsetPresentFlag(i))
     377    {
     378      Window refWindow = pcPPS->getRefLayerWindow(i);
     379      WRITE_SVLC( refWindow.getWindowLeftOffset()   >> 1, "ref_region_left_offset" );
     380      WRITE_SVLC( refWindow.getWindowTopOffset()    >> 1, "ref_region_top_offset" );
     381      WRITE_SVLC( refWindow.getWindowRightOffset()  >> 1, "ref_region_right_offset" );
     382      WRITE_SVLC( refWindow.getWindowBottomOffset() >> 1, "ref_region_bottom_offset" );
     383    }
     384#if R0209_GENERIC_PHASE
     385    WRITE_FLAG( pcPPS->getResamplePhaseSetPresentFlag(i) ? 1 : 0, "resample_phase_set_present_flag" );
     386    if (pcPPS->getResamplePhaseSetPresentFlag(i))
     387    {
     388      WRITE_UVLC( pcPPS->getPhaseHorLuma(i), "phase_hor_luma" );
     389      WRITE_UVLC( pcPPS->getPhaseVerLuma(i), "phase_ver_luma" );
     390      WRITE_UVLC( pcPPS->getPhaseHorChroma(i) + 8, "phase_hor_chroma_plus8" );
     391      WRITE_UVLC( pcPPS->getPhaseVerChroma(i) + 8, "phase_ver_chroma_plus8" );
     392    }
     393#endif
     394  }
     395#else
     396#if MOVE_SCALED_OFFSET_TO_PPS
     397  WRITE_UVLC( pcPPS->getNumScaledRefLayerOffsets(),      "num_scaled_ref_layer_offsets" );
     398  for(Int i = 0; i < pcPPS->getNumScaledRefLayerOffsets(); i++)
     399  {
     400    Window scaledWindow = pcPPS->getScaledRefLayerWindow(i);
     401#if O0098_SCALED_REF_LAYER_ID
     402    WRITE_CODE( pcPPS->getScaledRefLayerId(i), 6,          "scaled_ref_layer_id" );
     403#endif
     404    WRITE_SVLC( scaledWindow.getWindowLeftOffset()   >> 1, "scaled_ref_layer_left_offset" );
     405    WRITE_SVLC( scaledWindow.getWindowTopOffset()    >> 1, "scaled_ref_layer_top_offset" );
     406    WRITE_SVLC( scaledWindow.getWindowRightOffset()  >> 1, "scaled_ref_layer_right_offset" );
     407    WRITE_SVLC( scaledWindow.getWindowBottomOffset() >> 1, "scaled_ref_layer_bottom_offset" );
     408  }
     409#endif
     410#endif
     411#if Q0048_CGS_3D_ASYMLUT
     412  UInt uiPos = getNumberOfWrittenBits();
     413  WRITE_FLAG( pcPPS->getCGSFlag() , "colour_mapping_enabled_flag" );
     414  if( pcPPS->getCGSFlag() )
     415  {
     416    assert( pc3DAsymLUT != NULL );
     417    xCode3DAsymLUT( pc3DAsymLUT );
     418  }
     419  pc3DAsymLUT->setPPSBit( getNumberOfWrittenBits() - uiPos );
     420#endif
     421#endif
    287422  }
    288423#else
     
    340475  if( defaultDisplayWindow.getWindowEnabledFlag() )
    341476  {
    342     WRITE_UVLC(defaultDisplayWindow.getWindowLeftOffset(),      "def_disp_win_left_offset");
    343     WRITE_UVLC(defaultDisplayWindow.getWindowRightOffset(),    "def_disp_win_right_offset");
    344     WRITE_UVLC(defaultDisplayWindow.getWindowTopOffset(),      "def_disp_win_top_offset");
    345     WRITE_UVLC(defaultDisplayWindow.getWindowBottomOffset(),    "def_disp_win_bottom_offset");
     477    WRITE_UVLC(defaultDisplayWindow.getWindowLeftOffset()  / TComSPS::getWinUnitX(pcSPS->getChromaFormatIdc()), "def_disp_win_left_offset");
     478    WRITE_UVLC(defaultDisplayWindow.getWindowRightOffset() / TComSPS::getWinUnitX(pcSPS->getChromaFormatIdc()), "def_disp_win_right_offset");
     479    WRITE_UVLC(defaultDisplayWindow.getWindowTopOffset()   / TComSPS::getWinUnitY(pcSPS->getChromaFormatIdc()), "def_disp_win_top_offset");
     480    WRITE_UVLC(defaultDisplayWindow.getWindowBottomOffset()/ TComSPS::getWinUnitY(pcSPS->getChromaFormatIdc()), "def_disp_win_bottom_offset");
    346481  }
    347482  TimingInfo *timingInfo = pcVUI->getTimingInfo();
     
    452587Void TEncCavlc::codeSPS( TComSPS* pcSPS )
    453588{
     589#if R0042_PROFILE_INDICATION
     590  Bool bMultiLayerExtSpsFlag = (pcSPS->getNumDirectRefLayers() != 0 ) ;
     591#endif
    454592#if ENC_DEC_TRACE 
    455593  xTraceSPSHeader (pcSPS);
     
    461599#endif
    462600    WRITE_CODE( pcSPS->getMaxTLayers() - 1,  3,       "sps_max_sub_layers_minus1" );
     601#if SVC_EXTENSION
     602  }
     603#if R0042_PROFILE_INDICATION
     604  else
     605  {
     606    WRITE_CODE(bMultiLayerExtSpsFlag? 7:(pcSPS->getMaxTLayers() - 1) ,  3,       "sps_ext_or_max_sub_layers_minus1" );
     607  }
     608#endif
     609#endif
     610
     611#if SVC_EXTENSION
     612#if !R0042_PROFILE_INDICATION
     613  if(pcSPS->getLayerId() == 0)
     614#else
     615  if(!bMultiLayerExtSpsFlag)
     616#endif
     617  {
     618#endif
    463619    WRITE_FLAG( pcSPS->getTemporalIdNestingFlag() ? 1 : 0,                             "sps_temporal_id_nesting_flag" );
    464620#if SVC_EXTENSION
     
    466622#endif
    467623#ifdef SPS_PTL_FIX
     624#if !R0042_PROFILE_INDICATION
    468625  if (pcSPS->getLayerId() == 0)
     626#else
     627  if(!bMultiLayerExtSpsFlag)
     628#endif
    469629  {
    470630    codePTL(pcSPS->getPTL(), 1, pcSPS->getMaxTLayers() - 1);
     
    475635  WRITE_UVLC( pcSPS->getSPSId (),                   "sps_seq_parameter_set_id" );
    476636#if REPN_FORMAT_IN_VPS
     637#if !R0042_PROFILE_INDICATION
    477638  if( pcSPS->getLayerId() > 0 )
     639#else
     640  if(bMultiLayerExtSpsFlag)
     641#endif
    478642  {
    479643    WRITE_FLAG( pcSPS->getUpdateRepFormatFlag(), "update_rep_format_flag" );
    480644  }
     645#if R0042_PROFILE_INDICATION
     646  if( bMultiLayerExtSpsFlag && pcSPS->getUpdateRepFormatFlag())
     647  {
     648    WRITE_CODE( pcSPS->getUpdateRepFormatIndex(), 8,   "sps_rep_format_idx");
     649  }
     650#endif
     651
     652#if R0042_PROFILE_INDICATION
     653  if(!bMultiLayerExtSpsFlag)
     654  {
     655#endif
     656#if !R0042_PROFILE_INDICATION
    481657#if O0096_REP_FORMAT_INDEX
    482658  if( pcSPS->getLayerId() == 0 )
    483659#else
    484660  if( pcSPS->getLayerId() == 0 || pcSPS->getUpdateRepFormatFlag() )
     661#endif
    485662#endif
    486663  {
     
    498675#if REPN_FORMAT_IN_VPS
    499676  }
     677#if !R0042_PROFILE_INDICATION
    500678#if O0096_REP_FORMAT_INDEX
    501679  else if (pcSPS->getUpdateRepFormatFlag())
     
    505683#endif
    506684#endif
    507   Window conf = pcSPS->getConformanceWindow();
    508 
    509   WRITE_FLAG( conf.getWindowEnabledFlag(),          "conformance_window_flag" );
    510   if (conf.getWindowEnabledFlag())
    511   {
     685#endif
     686
     687#if R0156_CONF_WINDOW_IN_REP_FORMAT
    512688#if REPN_FORMAT_IN_VPS
    513     WRITE_UVLC( conf.getWindowLeftOffset(),   "conf_win_left_offset"   );
    514     WRITE_UVLC( conf.getWindowRightOffset(),  "conf_win_right_offset"  );
    515     WRITE_UVLC( conf.getWindowTopOffset(),    "conf_win_top_offset"    );
    516     WRITE_UVLC( conf.getWindowBottomOffset(), "conf_win_bottom_offset" );
    517 #else
    518     WRITE_UVLC( conf.getWindowLeftOffset()   / TComSPS::getWinUnitX(pcSPS->getChromaFormatIdc() ), "conf_win_left_offset" );
    519     WRITE_UVLC( conf.getWindowRightOffset()  / TComSPS::getWinUnitX(pcSPS->getChromaFormatIdc() ), "conf_win_right_offset" );
    520     WRITE_UVLC( conf.getWindowTopOffset()    / TComSPS::getWinUnitY(pcSPS->getChromaFormatIdc() ), "conf_win_top_offset" );
    521     WRITE_UVLC( conf.getWindowBottomOffset() / TComSPS::getWinUnitY(pcSPS->getChromaFormatIdc() ), "conf_win_bottom_offset" );
    522 #endif
    523   }
    524 
    525 #if REPN_FORMAT_IN_VPS
     689#if !R0042_PROFILE_INDICATION
    526690#if O0096_REP_FORMAT_INDEX
    527691  if( pcSPS->getLayerId() == 0 )
     
    529693  if( pcSPS->getLayerId() == 0 || pcSPS->getUpdateRepFormatFlag() )
    530694#endif 
     695#endif
     696  {
     697#endif
     698#endif
     699    Window conf = pcSPS->getConformanceWindow();
     700
     701    WRITE_FLAG( conf.getWindowEnabledFlag(),          "conformance_window_flag" );
     702    if (conf.getWindowEnabledFlag())
     703    {
     704#if REPN_FORMAT_IN_VPS
     705      WRITE_UVLC( conf.getWindowLeftOffset(),   "conf_win_left_offset"   );
     706      WRITE_UVLC( conf.getWindowRightOffset(),  "conf_win_right_offset"  );
     707      WRITE_UVLC( conf.getWindowTopOffset(),    "conf_win_top_offset"    );
     708      WRITE_UVLC( conf.getWindowBottomOffset(), "conf_win_bottom_offset" );
     709#else
     710      WRITE_UVLC( conf.getWindowLeftOffset()   / TComSPS::getWinUnitX(pcSPS->getChromaFormatIdc() ), "conf_win_left_offset" );
     711      WRITE_UVLC( conf.getWindowRightOffset()  / TComSPS::getWinUnitX(pcSPS->getChromaFormatIdc() ), "conf_win_right_offset" );
     712      WRITE_UVLC( conf.getWindowTopOffset()    / TComSPS::getWinUnitY(pcSPS->getChromaFormatIdc() ), "conf_win_top_offset" );
     713      WRITE_UVLC( conf.getWindowBottomOffset() / TComSPS::getWinUnitY(pcSPS->getChromaFormatIdc() ), "conf_win_bottom_offset" );
     714#endif
     715    }
     716#if R0156_CONF_WINDOW_IN_REP_FORMAT
     717#if REPN_FORMAT_IN_VPS
     718  }
     719#endif
     720#endif
     721
     722#if REPN_FORMAT_IN_VPS
     723#if !R0042_PROFILE_INDICATION
     724#if O0096_REP_FORMAT_INDEX
     725  if( pcSPS->getLayerId() == 0 )
     726#else
     727  if( pcSPS->getLayerId() == 0 || pcSPS->getUpdateRepFormatFlag() )
     728#endif
     729#endif
    531730  {
    532731    assert( pcSPS->getBitDepthY() >= 8 );
     
    538737  }
    539738#endif
     739#if R0042_PROFILE_INDICATION
     740  }
     741#endif
     742
    540743  WRITE_UVLC( pcSPS->getBitsForPOC()-4,                 "log2_max_pic_order_cnt_lsb_minus4" );
    541744
    542745#if SPS_DPB_PARAMS
     746#if !R0042_PROFILE_INDICATION
    543747  if( pcSPS->getLayerId() == 0 )
     748#else
     749  if(!bMultiLayerExtSpsFlag)
     750#endif
    544751  {
    545752#endif
     
    571778  {
    572779#if SCALINGLIST_INFERRING
     780#if !R0042_PROFILE_INDICATION
    573781    if( pcSPS->getLayerId() > 0 )
     782#else
     783    if( bMultiLayerExtSpsFlag)
     784#endif
    574785    {
    575786      WRITE_FLAG( pcSPS->getInferScalingListFlag() ? 1 : 0, "sps_infer_scaling_list_flag" );
     
    640851
    641852#if SVC_EXTENSION
     853#if !R0042_PROFILE_INDICATION
    642854  WRITE_FLAG( pcSPS->getExtensionFlag() ? 1 : 0, "sps_extension_flag" );
     855#else
     856  WRITE_FLAG( pcSPS->getExtensionFlag() ? 1 : 0, "sps_extension_present_flag" );
     857#endif
    643858
    644859  if( pcSPS->getExtensionFlag() )
    645860  {
     861#if !R0042_PROFILE_INDICATION
    646862#if O0142_CONDITIONAL_SPS_EXTENSION
    647863    UInt spsExtensionTypeFlag[8] = { 0, 1, 0, 0, 0, 0, 0, 0 };
     
    658874    WRITE_FLAG( 0, "sps_extension2_flag" );
    659875#endif
     876#else
     877    WRITE_FLAG( 0, "sps_range_extension_flag" );
     878    WRITE_FLAG( 1, "sps_multilayer_extension_flag" );
     879    WRITE_CODE( 0, 6,  "sps_extension_6bits" );   
     880    codeSPSExtension( pcSPS ); //it is sps_multilayer_extension
     881#endif
    660882  }
    661883#else
     
    672894  WRITE_FLAG( 0, "inter_view_mv_vert_constraint_flag" );
    673895
     896#if !MOVE_SCALED_OFFSET_TO_PPS
    674897  if( pcSPS->getLayerId() > 0 )
    675898  {
     
    690913    }
    691914  }
     915#endif
    692916}
    693917#endif //SVC_EXTENSION
     
    706930#endif
    707931  WRITE_CODE( pcVPS->getVPSId(),                    4,        "vps_video_parameter_set_id" );
     932#if VPS_RESERVED_FLAGS
     933  WRITE_FLAG( pcVPS->getBaseLayerInternalFlag(),              "vps_base_layer_internal_flag");
     934  WRITE_FLAG( pcVPS->getBaseLayerAvailableFlag(),             "vps_base_layer_available_flag");
     935#else
    708936  WRITE_CODE( 3,                                    2,        "vps_reserved_three_2bits" );
     937#endif
    709938#if SVC_EXTENSION
    710939  WRITE_CODE( pcVPS->getMaxLayers() - 1,            6,        "vps_max_layers_minus1" );           
     
    7741003    }
    7751004  }
     1005#if !NECESSARY_FLAG   // Already called once in TAppEncTop.cpp
    7761006#if DERIVE_LAYER_ID_LIST_VARIABLES
    7771007  pcVPS->deriveLayerIdListVariables();
     1008#endif
    7781009#endif
    7791010  TimingInfo *timingInfo = pcVPS->getTimingInfo();
     
    8481079  Int OlsHighestOutputLayerId[MAX_VPS_LAYER_SETS_PLUS1];
    8491080#endif
     1081#if LIST_OF_PTL
     1082  if( vps->getMaxLayers() > 1 && vps->getBaseLayerInternalFlag() )
     1083  {
     1084    codePTL( vps->getPTLForExtn(1), false, vps->getMaxTLayers() - 1 );
     1085  }
     1086#endif
    8501087#if VPS_EXTN_MASK_AND_DIM_INFO
    8511088  UInt i = 0, j = 0;
    852 
     1089#if !VPS_AVC_BL_FLAG_REMOVAL
    8531090  WRITE_FLAG( vps->getAvcBaseLayerFlag(),              "avc_base_layer_flag" );
     1091#endif
    8541092#if !P0307_REMOVE_VPS_VUI_OFFSET
    8551093#if O0109_MOVE_VPS_VUI_FLAG
     
    9481186    }
    9491187  }
     1188#endif
     1189#if MOVE_ADDN_LS_SIGNALLING
     1190#if Q0078_ADD_LAYER_SETS
     1191  if (vps->getNumIndependentLayers() > 1)
     1192  {
     1193    WRITE_UVLC( vps->getNumAddLayerSets(), "num_add_layer_sets" );
     1194    for (i = 0; i < vps->getNumAddLayerSets(); i++)
     1195    {
     1196      for (j = 1; j < vps->getNumIndependentLayers(); j++)
     1197      {
     1198        int len = 1;
     1199        while ((1 << len) < (vps->getNumLayersInTreePartition(j) + 1))
     1200        {
     1201          len++;
     1202        }
     1203        WRITE_CODE(vps->getHighestLayerIdxPlus1(i, j), len, "highest_layer_idx_plus1[i][j]");
     1204      }
     1205    }
     1206  }
     1207#endif
    9501208#endif
    9511209#if VPS_TSLAYERS
     
    9851243#else
    9861244  WRITE_UVLC( vps->getNumProfileTierLevel() - 1, "vps_num_profile_tier_level_minus1");
    987 #endif
     1245#if PER_LAYER_PTL
     1246  Int const numBitsForPtlIdx = vps->calculateLenOfSyntaxElement( vps->getNumProfileTierLevel() );
     1247#endif
     1248#endif
     1249#if LIST_OF_PTL
     1250  assert( vps->getNumProfileTierLevel() == vps->getPTLForExtnPtr()->size());
     1251  for(Int idx = vps->getBaseLayerInternalFlag() ? 2 : 1; idx <= vps->getNumProfileTierLevel() - 1; idx++)
     1252#else
    9881253  for(Int idx = 1; idx <= vps->getNumProfileTierLevel() - 1; idx++)
     1254#endif
    9891255  {
    9901256    WRITE_FLAG( vps->getProfilePresentFlag(idx),       "vps_profile_present_flag[i]" );
     
    9991265#endif
    10001266
     1267
     1268#if !MOVE_ADDN_LS_SIGNALLING
    10011269#if Q0078_ADD_LAYER_SETS
    10021270  if (vps->getNumIndependentLayers() > 1)
     
    10161284    }
    10171285  }
     1286#endif
    10181287#endif
    10191288
     
    10601329  for(i = 1; i < numOutputLayerSets; i++)
    10611330  {
     1331    Int layerSetIdxForOutputLayerSet = vps->getOutputLayerSetIdx(i);
    10621332    if( i > (vps->getNumLayerSets() - 1) )
    10631333    {
     
    10771347    {
    10781348#endif
    1079       Int lsIdx = vps->getOutputLayerSetIdx(i);
    10801349#if NUM_OL_FLAGS
    1081       for(j = 0; j < vps->getNumLayersInIdList(lsIdx) ; j++)
     1350      for(j = 0; j < vps->getNumLayersInIdList(layerSetIdxForOutputLayerSet) ; j++)
    10821351#else
    10831352      for(j = 0; j < vps->getNumLayersInIdList(lsIdx) - 1; j++)
     
    10871356      }
    10881357    }
     1358#if PER_LAYER_PTL
     1359    for(j = 0; j < vps->getNumLayersInIdList(layerSetIdxForOutputLayerSet) ; j++)
     1360    {
     1361      if( vps->getNecessaryLayerFlag(i, j) )
     1362      {
     1363        WRITE_CODE( vps->getProfileLevelTierIdx(i, j), numBitsForPtlIdx, "profile_level_tier_idx[i]" );
     1364      }
     1365    }
     1366#else
    10891367    Int numBits = 1;
    10901368    while ((1 << numBits) < (vps->getNumProfileTierLevel()))
     
    10931371    }
    10941372    WRITE_CODE( vps->getProfileLevelTierIdx(i), numBits, "profile_level_tier_idx[i]" );     
     1373#endif
    10951374#if P0300_ALT_OUTPUT_LAYER_FLAG
    10961375    NumOutputLayersInOutputLayerSet[i] = 0;
    1097     Int layerSetIdxForOutputLayerSet = vps->getOutputLayerSetIdx(i);
    10981376    for (j = 0; j < vps->getNumLayersInIdList(layerSetIdxForOutputLayerSet); j++)
    10991377    {
     
    12111489
    12121490  WRITE_FLAG(vps->getMaxOneActiveRefLayerFlag(), "max_one_active_ref_layer_flag");
     1491#if P0297_VPS_POC_LSB_ALIGNED_FLAG
     1492  WRITE_FLAG(vps->getVpsPocLsbAlignedFlag(), "vps_poc_lsb_aligned_flag");
     1493#endif
    12131494#if O0062_POC_LSB_NOT_PRESENT_FLAG
    12141495  for(i = 1; i< vps->getMaxLayers(); i++)
     
    13671648  WRITE_CODE( repFormat->getBitDepthVpsChroma() - 8, 4, "bit_depth_chroma_minus8" );
    13681649#endif
     1650
     1651#if R0156_CONF_WINDOW_IN_REP_FORMAT
     1652  Window conf = repFormat->getConformanceWindowVps();
     1653
     1654  WRITE_FLAG( conf.getWindowEnabledFlag(),    "conformance_window_vps_flag" );
     1655  if (conf.getWindowEnabledFlag())
     1656  {
     1657    WRITE_UVLC( conf.getWindowLeftOffset(),   "conf_win_vps_left_offset"   );
     1658    WRITE_UVLC( conf.getWindowRightOffset(),  "conf_win_vps_right_offset"  );
     1659    WRITE_UVLC( conf.getWindowTopOffset(),    "conf_win_vps_top_offset"    );
     1660    WRITE_UVLC( conf.getWindowBottomOffset(), "conf_win_vps_bottom_offset" );
     1661  }
     1662#endif
    13691663}
    13701664#endif
     
    13721666Void TEncCavlc::codeVpsDpbSizeTable(TComVPS *vps)
    13731667{
     1668#if !SUB_LAYERS_IN_LAYER_SET  // MaxSLInLayerSets calculated earlier in the encoder
    13741669#if DPB_PARAMS_MAXTLAYERS
    13751670#if BITRATE_PICRATE_SIGNALLING
     
    14001695    }
    14011696#endif
     1697#endif
    14021698   
    14031699   
     
    14081704#endif
    14091705    WRITE_FLAG( vps->getSubLayerFlagInfoPresentFlag( i ), "sub_layer_flag_info_present_flag[i]");
     1706#if SUB_LAYERS_IN_LAYER_SET
     1707    for(Int j = 0; j <= vps->getMaxSLayersInLayerSetMinus1( layerSetIdxForOutputLayerSet ); j++)
     1708#else
    14101709#if DPB_PARAMS_MAXTLAYERS
    14111710#if BITRATE_PICRATE_SIGNALLING
     
    14171716    for(Int j = 0; j < vps->getMaxTLayers(); j++)
    14181717#endif
     1718#endif
    14191719    {
    14201720      if( j > 0 && vps->getSubLayerFlagInfoPresentFlag(i) )
     
    14341734#endif
    14351735        {
    1436           WRITE_UVLC( vps->getMaxVpsDecPicBufferingMinus1( i, k, j), "max_vps_dec_pic_buffering_minus1[i][k][j]" );
     1736#if DPB_INTERNAL_BL_SIG
     1737        if(vps->getBaseLayerInternalFlag()  || ( vps->getLayerSetLayerIdList(layerSetIdxForOutputLayerSet, k)   !=  0 ) )
     1738#endif
     1739          WRITE_UVLC( vps->getMaxVpsDecPicBufferingMinus1( i, k, j), "max_vps_dec_pic_buffering_minus1[i][k][j]" );
    14371740        }
    14381741        WRITE_UVLC( vps->getMaxVpsNumReorderPics( i, j), "max_vps_num_reorder_pics[i][j]" );             
     
    14501753    }
    14511754  }
     1755
     1756#if !SUB_LAYERS_IN_LAYER_SET
     1757#if BITRATE_PICRATE_SIGNALLING
     1758  if( MaxSubLayersInLayerSetMinus1 )
     1759  {
     1760    delete [] MaxSubLayersInLayerSetMinus1;
     1761  }
     1762#endif
     1763#endif
    14521764}
    14531765#endif
     
    14791791  {
    14801792#if Q0078_ADD_LAYER_SETS
     1793#if R0227_BR_PR_ADD_LAYER_SET
     1794#if SIGNALLING_BITRATE_PICRATE_FIX
     1795    for( i = vps->getBaseLayerInternalFlag() ? 0 : 1; i < vps->getNumLayerSets(); i++ )
     1796#else
     1797    for( i = 0; i < vps->getNumLayerSets(); i++ )
     1798#endif
     1799#else
    14811800    for( i = 0; i <= vps->getVpsNumLayerSetsMinus1(); i++ )
     1801#endif
    14821802#else
    14831803    for( i = 0; i < vps->getNumLayerSets(); i++ )
     
    15291849  if (vps->getVideoSigPresentVpsFlag() && vps->getNumVideoSignalInfo() > 1 )
    15301850  {
     1851#if VPS_VUI_VST_PARAMS
     1852    for(i = vps->getBaseLayerInternalFlag() ? 0 : 1; i < vps->getMaxLayers(); i++)
     1853    {
     1854      WRITE_CODE( vps->getVideoSignalInfoIdx(i), 4, "vps_video_signal_info_idx" );
     1855    }
     1856#else
    15311857    for (i=1; i < vps->getMaxLayers(); i++)
    15321858      WRITE_CODE(vps->getVideoSignalInfoIdx(i), 4, "vps_video_signal_info_idx" );
     1859#endif
    15331860  }
    15341861#endif
     
    16451972    if (vps->getVpsVuiBspHrdPresentFlag())
    16461973    {
     1974#if VPS_VUI_BSP_HRD_PARAMS
     1975      codeVpsVuiBspHrdParams(vps);
     1976#else
    16471977      WRITE_UVLC( vps->getVpsNumBspHrdParametersMinus1(), "vps_num_bsp_hrd_parameters_minus1" );
    16481978      for( i = 0; i <= vps->getVpsNumBspHrdParametersMinus1(); i++ )
     
    16882018        }
    16892019      }
     2020#endif
    16902021    }
    16912022#endif
     
    17862117    }
    17872118#else
     2119#if CROSS_LAYER_BLA_FLAG_FIX
     2120    Int iBits = 0;
     2121    if(pcSlice->getPPS()->getNumExtraSliceHeaderBits() > iBits)
     2122#else
    17882123    if (pcSlice->getPPS()->getNumExtraSliceHeaderBits()>0)
     2124#endif
    17892125    {
    17902126      assert(!!"discardable_flag");
     2127#if NON_REF_NAL_TYPE_DISCARDABLE
     2128      if (pcSlice->getDiscardableFlag())
     2129      {
     2130        assert(pcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_TRAIL_R &&
     2131          pcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_TSA_R &&
     2132          pcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_STSA_R &&
     2133          pcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_RADL_R &&
     2134          pcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_RASL_R);
     2135      }
     2136#endif
    17912137      WRITE_FLAG(pcSlice->getDiscardableFlag(), "discardable_flag");
    1792     }
     2138#if CROSS_LAYER_BLA_FLAG_FIX
     2139      iBits++;
     2140#endif
     2141    }
     2142#if CROSS_LAYER_BLA_FLAG_FIX
     2143    if( pcSlice->getPPS()->getNumExtraSliceHeaderBits() > iBits )
     2144    {
     2145      assert(!!"cross_layer_bla_flag");
     2146      WRITE_FLAG(pcSlice->getCrossLayerBLAFlag(), "cross_layer_bla_flag");
     2147      iBits++;
     2148    }
     2149    for (; iBits < pcSlice->getPPS()->getNumExtraSliceHeaderBits(); iBits++)
     2150#else
    17932151    for (Int i = 1; i < pcSlice->getPPS()->getNumExtraSliceHeaderBits(); i++)
     2152#endif
    17942153    {
    17952154      assert(!!"slice_reserved_undetermined_flag[]");
     
    19782337      if (pcSlice->getSPS()->getTMVPFlagsPresent())
    19792338      {
     2339#if R0226_SLICE_TMVP
     2340        WRITE_FLAG( pcSlice->getEnableTMVPFlag() ? 1 : 0, "slice_temporal_mvp_enabled_flag" );
     2341#else
    19802342        WRITE_FLAG( pcSlice->getEnableTMVPFlag() ? 1 : 0, "slice_temporal_mvp_enable_flag" );
     2343#endif
    19812344      }
    19822345#if N0065_LAYER_POC_ALIGNMENT && !SHM_FIX7
     
    22622625  }
    22632626  UInt numEntryPointOffsets = 0, offsetLenMinus1 = 0, maxOffset = 0;
     2627#if !WPP_FIX
    22642628  Int  numZeroSubstreamsAtStartOfSlice  = 0;
     2629#endif
    22652630  UInt *entryPointOffset = NULL;
    22662631  if ( pSlice->getPPS()->getTilesEnabledFlag() )
     
    22892654    UInt* pSubstreamSizes               = pSlice->getSubstreamSizes();
    22902655    Int maxNumParts                       = pSlice->getPic()->getNumPartInCU();
     2656#if WPP_FIX
     2657    Int  numZeroSubstreamsAtStartOfSlice  = pSlice->getPic()->getSubstreamForLCUAddr(pSlice->getSliceSegmentCurStartCUAddr()/maxNumParts, false, pSlice);
     2658    Int  subStreamOfLastSegmentOfSlice    = pSlice->getPic()->getSubstreamForLCUAddr((pSlice->getSliceSegmentCurEndCUAddr()/maxNumParts)-1, false, pSlice);
     2659    numEntryPointOffsets                  = subStreamOfLastSegmentOfSlice-numZeroSubstreamsAtStartOfSlice;
     2660#else
    22912661    numZeroSubstreamsAtStartOfSlice       = pSlice->getSliceSegmentCurStartCUAddr()/maxNumParts/pSlice->getPic()->getFrameWidthInCU();
    22922662    Int  numZeroSubstreamsAtEndOfSlice    = pSlice->getPic()->getFrameHeightInCU()-1 - ((pSlice->getSliceSegmentCurEndCUAddr()-1)/maxNumParts/pSlice->getPic()->getFrameWidthInCU());
    22932663    numEntryPointOffsets                  = pSlice->getPPS()->getNumSubstreams() - numZeroSubstreamsAtStartOfSlice - numZeroSubstreamsAtEndOfSlice - 1;
     2664#endif
    22942665    pSlice->setNumEntryPointOffsets(numEntryPointOffsets);
    22952666    entryPointOffset           = new UInt[numEntryPointOffsets];
     
    23332704  {
    23342705    // Derive the value of PocMsbValRequiredFlag
    2335     slice->setPocMsbValRequiredFlag( slice->getCraPicFlag() || slice->getBlaPicFlag()
    2336                                           /* || related to vps_poc_lsb_aligned_flag */
    2337                                           );
     2706#if P0297_VPS_POC_LSB_ALIGNED_FLAG
     2707    slice->setPocMsbValRequiredFlag( (slice->getCraPicFlag() || slice->getBlaPicFlag())
     2708                                  && (!slice->getVPS()->getVpsPocLsbAlignedFlag() ||
     2709                                      (slice->getVPS()->getVpsPocLsbAlignedFlag() && slice->getVPS()->getNumDirectRefLayers(slice->getLayerId()) == 0))
     2710                                   );
     2711#else
     2712    slice->setPocMsbValRequiredFlag( slice->getCraPicFlag() || slice->getBlaPicFlag() );
     2713#endif
    23382714
    23392715    // Determine value of SH extension length.
     
    23532729
    23542730
    2355     if( !slice->getPocMsbValRequiredFlag() /* &&  vps_poc_lsb_aligned_flag */ )
     2731#if P0297_VPS_POC_LSB_ALIGNED_FLAG
     2732    if (!slice->getPocMsbValRequiredFlag() && slice->getVPS()->getVpsPocLsbAlignedFlag())
     2733#else
     2734    if (!slice->getPocMsbValRequiredFlag() /* &&  vps_poc_lsb_aligned_flag */)
     2735#endif
    23562736    {
    23572737      shExtnLengthInBit++;
     
    23692749    }
    23702750
    2371     if( slice->getPocMsbValPresentFlag() )
     2751#if P0297_VPS_POC_LSB_ALIGNED_FLAG
     2752    if (slice->getPocMsbNeeded())
     2753    {
     2754      slice->setPocMsbValPresentFlag(true);
     2755    }
     2756#endif
     2757
     2758    if (slice->getPocMsbValPresentFlag())
    23722759    {
    23732760      UInt lengthVal = 1;
     
    24032790    }
    24042791
    2405     if( !slice->getPocMsbValRequiredFlag() /* &&  vps_poc_lsb_aligned_flag */ )
    2406     {
     2792#if P0297_VPS_POC_LSB_ALIGNED_FLAG
     2793    if (!slice->getPocMsbValRequiredFlag() && slice->getVPS()->getVpsPocLsbAlignedFlag())
     2794#else
     2795    if (!slice->getPocMsbValRequiredFlag() /* &&  vps_poc_lsb_aligned_flag */)
     2796#endif
     2797    {
     2798#if P0297_VPS_POC_LSB_ALIGNED_FLAG
     2799      WRITE_FLAG( slice->getPocMsbValPresentFlag(),                           "poc_msb_cycle_val_present_flag" );
     2800#else
    24072801      WRITE_FLAG( slice->getPocMsbValPresentFlag(),                           "poc_msb_val_present_flag" );
    2408     }
    2409     if( slice->getPocMsbValPresentFlag() )
    2410     {
    2411       assert( slice->getPocMsbVal() % maxPocLsb == 0 );
    2412       WRITE_UVLC( slice->getPocMsbVal() / maxPocLsb,                                      "poc_msb_val" );
     2802#endif
     2803    }
     2804    if (slice->getPocMsbValPresentFlag())
     2805    {
     2806      assert(slice->getPocMsbVal() % maxPocLsb == 0);
     2807#if P0297_VPS_POC_LSB_ALIGNED_FLAG
     2808      WRITE_UVLC(slice->getPocMsbVal() / maxPocLsb, "poc_msb_cycle_val");
     2809#else
     2810      WRITE_UVLC(slice->getPocMsbVal() / maxPocLsb, "poc_msb_val");
     2811#endif
    24132812    }
    24142813    for (Int i = 0; i < shExtnAdditionalBits; i++)
     
    27553154Void TEncCavlc::xCode3DAsymLUT( TCom3DAsymLUT * pc3DAsymLUT )
    27563155{
     3156#if R0150_CGS_SIGNAL_CONSTRAINTS
     3157  UInt uiNumRefLayers = ( UInt )pc3DAsymLUT->getRefLayerNum();
     3158  WRITE_UVLC( uiNumRefLayers - 1 , "num_cm_ref_layers_minus1" );
     3159  for( UInt i = 0 ; i < uiNumRefLayers ; i++ )
     3160  {
     3161    WRITE_CODE( pc3DAsymLUT->getRefLayerId( i ) , 6 , "cm_ref_layer_id" );
     3162  }
     3163#endif
    27573164  assert( pc3DAsymLUT->getCurOctantDepth() < 4 );
    27583165  WRITE_CODE( pc3DAsymLUT->getCurOctantDepth() , 2 , "cm_octant_depth" );
     
    27603167  WRITE_CODE( pc3DAsymLUT->getCurYPartNumLog2() , 2 , "cm_y_part_num_log2" );
    27613168  assert( pc3DAsymLUT->getInputBitDepthY() < 16 );
     3169#if R0150_CGS_SIGNAL_CONSTRAINTS
     3170  WRITE_UVLC( pc3DAsymLUT->getInputBitDepthY() - 8 , "cm_input_luma_bit_depth_minus8" );
     3171  WRITE_UVLC( pc3DAsymLUT->getInputBitDepthC() - 8 , "cm_input_chroma_bit_depth_minus8" );
     3172  WRITE_UVLC( pc3DAsymLUT->getOutputBitDepthY() - 8 , "cm_output_luma_bit_depth_minus8" );
     3173  WRITE_UVLC( pc3DAsymLUT->getOutputBitDepthC() - 8 , "cm_output_chroma_bit_depth_minus8" );
     3174#else
    27623175  WRITE_CODE( pc3DAsymLUT->getInputBitDepthY() - 8 , 3 , "cm_input_bit_depth_minus8" );
    27633176  WRITE_SVLC(pc3DAsymLUT->getInputBitDepthC()-pc3DAsymLUT->getInputBitDepthY(), "cm_input_bit_depth_chroma delta");
     
    27653178  WRITE_CODE( pc3DAsymLUT->getOutputBitDepthY() - 8 , 3 , "cm_output_bit_depth_minus8" );
    27663179  WRITE_SVLC(pc3DAsymLUT->getOutputBitDepthC()-pc3DAsymLUT->getOutputBitDepthY(), "cm_output_bit_depth_chroma_delta");
     3180#endif
    27673181  assert( pc3DAsymLUT->getResQuantBit() < 4 );
    27683182  WRITE_CODE( pc3DAsymLUT->getResQuantBit() , 2 , "cm_res_quant_bit" );
    2769 
     3183#if R0300_CGS_RES_COEFF_CODING
     3184  xFindDeltaBits( pc3DAsymLUT );
     3185  assert(pc3DAsymLUT->getDeltaBits() >=1 && pc3DAsymLUT->getDeltaBits() <= 4);
     3186  WRITE_CODE( pc3DAsymLUT->getDeltaBits()-1 , 2 , "cm_delta_bit" );
     3187#endif
     3188#if R0151_CGS_3D_ASYMLUT_IMPROVE
     3189  if( pc3DAsymLUT->getCurOctantDepth() == 1 )
     3190  {
     3191    WRITE_SVLC( pc3DAsymLUT->getAdaptChromaThresholdU() - ( 1 << ( pc3DAsymLUT->getInputBitDepthC() - 1 ) ) , "cm_adapt_threshold_u_delta" );
     3192    WRITE_SVLC( pc3DAsymLUT->getAdaptChromaThresholdV() - ( 1 << ( pc3DAsymLUT->getInputBitDepthC() - 1 ) ) , "cm_adapt_threshold_v_delta" );
     3193  }
     3194#endif
     3195
     3196#if R0164_CGS_LUT_BUGFIX_CHECK
     3197  pc3DAsymLUT->xInitCuboids();
     3198#endif
    27703199  xCode3DAsymLUTOctant( pc3DAsymLUT , 0 , 0 , 0 , 0 , 1 << pc3DAsymLUT->getCurOctantDepth() );
     3200#if R0164_CGS_LUT_BUGFIX_CHECK
     3201  xCuboidsFilledCheck( false );
     3202  pc3DAsymLUT->display( false );
     3203#endif
    27713204}
    27723205
     
    27933226  else
    27943227  {
     3228#if R0300_CGS_RES_COEFF_CODING
     3229    Int nFLCbits = pc3DAsymLUT->getMappingShift()-pc3DAsymLUT->getResQuantBit()-pc3DAsymLUT->getDeltaBits() ;
     3230    nFLCbits = nFLCbits >= 0 ? nFLCbits : 0;
     3231#endif
    27953232    for( Int l = 0 ; l < nYPartNum ; l++ )
    27963233    {
     3234#if R0164_CGS_LUT_BUGFIX     
     3235      Int shift = pc3DAsymLUT->getCurOctantDepth() - nDepth ;
     3236#endif
    27973237      for( Int nVertexIdx = 0 ; nVertexIdx < 4 ; nVertexIdx++ )
    27983238      {
     3239#if R0164_CGS_LUT_BUGFIX
     3240        SYUVP sRes = pc3DAsymLUT->getCuboidVertexResTree( yIdx + (l<<shift) , uIdx , vIdx , nVertexIdx );
     3241#else
    27993242        SYUVP sRes = pc3DAsymLUT->getCuboidVertexResTree( yIdx + l , uIdx , vIdx , nVertexIdx );
     3243#endif
    28003244        UInt uiCodeVertex = sRes.Y != 0 || sRes.U != 0 || sRes.V != 0;
    28013245        WRITE_FLAG( uiCodeVertex , "coded_vertex_flag" );
    28023246        if( uiCodeVertex )
    28033247        {
     3248#if R0151_CGS_3D_ASYMLUT_IMPROVE
     3249#if R0300_CGS_RES_COEFF_CODING
     3250          xWriteParam( sRes.Y, nFLCbits );
     3251          xWriteParam( sRes.U, nFLCbits );
     3252          xWriteParam( sRes.V, nFLCbits );
     3253#else
     3254          xWriteParam( sRes.Y );
     3255          xWriteParam( sRes.U );
     3256          xWriteParam( sRes.V );
     3257#endif
     3258#else
    28043259          WRITE_SVLC( sRes.Y , "resY" );
    28053260          WRITE_SVLC( sRes.U , "resU" );
    28063261          WRITE_SVLC( sRes.V , "resV" );
    2807         }
    2808       }
    2809     }
    2810   }
    2811 }
     3262#endif
     3263        }
     3264      }
     3265#if R0164_CGS_LUT_BUGFIX_CHECK
     3266      pc3DAsymLUT->xSetExplicit( yIdx + (l<<shift) , uIdx , vIdx );
     3267#endif
     3268    }
     3269  }
     3270}
     3271
     3272#if R0151_CGS_3D_ASYMLUT_IMPROVE
     3273#if R0300_CGS_RES_COEFF_CODING
     3274Void TEncCavlc::xWriteParam( Int param, UInt rParam)
     3275#else
     3276Void TEncCavlc::xWriteParam( Int param)
     3277#endif
     3278{
     3279#if !R0300_CGS_RES_COEFF_CODING
     3280  const UInt rParam = 7;
     3281#endif
     3282  Int codeNumber = abs(param);
     3283  WRITE_UVLC(codeNumber / (1 << rParam), "quotient");
     3284  WRITE_CODE((codeNumber % (1 << rParam)), rParam, "remainder");
     3285  if (abs(param))
     3286    WRITE_FLAG( param <0, "sign");
     3287}
     3288#endif
     3289
     3290#if R0300_CGS_RES_COEFF_CODING
     3291Void TEncCavlc::xFindDeltaBits( TCom3DAsymLUT * pc3DAsymLUT )
     3292{
     3293  Int nDeltaBits;
     3294  Int nBestDeltaBits = -1;
     3295  Int nBestBits = MAX_INT;
     3296  for( nDeltaBits = 1; nDeltaBits < 5; nDeltaBits++)
     3297  {
     3298    Int nCurBits = 0;
     3299    xTally3DAsymLUTOctantBits( pc3DAsymLUT , 0 , 0 , 0 , 0 , 1 << pc3DAsymLUT->getCurOctantDepth(), nDeltaBits, nCurBits );
     3300    //printf("%d, %d, %d\n", nDeltaBits, nCurBits, nBestBits);
     3301    if(nCurBits < nBestBits)
     3302    {
     3303      nBestDeltaBits = nDeltaBits;
     3304      nBestBits = nCurBits;
     3305    }
     3306  }
     3307
     3308  assert(nBestDeltaBits >=1 && nBestDeltaBits < 5);
     3309  pc3DAsymLUT->setDeltaBits(nBestDeltaBits);
     3310}
     3311
     3312Void TEncCavlc::xTally3DAsymLUTOctantBits( TCom3DAsymLUT * pc3DAsymLUT , Int nDepth , Int yIdx , Int uIdx , Int vIdx , Int nLength, Int nDeltaBits, Int& nCurBits )
     3313{
     3314  UInt uiOctantSplit = nDepth < pc3DAsymLUT->getCurOctantDepth();
     3315  if( nDepth < pc3DAsymLUT->getCurOctantDepth() )
     3316    nCurBits ++;
     3317  Int nYPartNum = 1 << pc3DAsymLUT->getCurYPartNumLog2();
     3318  if( uiOctantSplit )
     3319  {
     3320    Int nHalfLength = nLength >> 1;
     3321    for( Int l = 0 ; l < 2 ; l++ )
     3322    {
     3323      for( Int m = 0 ; m < 2 ; m++ )
     3324      {
     3325        for( Int n = 0 ; n < 2 ; n++ )
     3326        {
     3327          xTally3DAsymLUTOctantBits( pc3DAsymLUT , nDepth + 1 , yIdx + l * nHalfLength * nYPartNum , uIdx + m * nHalfLength , vIdx + n * nHalfLength , nHalfLength, nDeltaBits, nCurBits );
     3328        }
     3329      }
     3330    }
     3331  }
     3332  else
     3333  {
     3334    Int nFLCbits = pc3DAsymLUT->getMappingShift()-pc3DAsymLUT->getResQuantBit()-nDeltaBits ;
     3335    nFLCbits = nFLCbits >= 0 ? nFLCbits:0;
     3336    //printf("nFLCbits = %d\n", nFLCbits);
     3337
     3338    for( Int l = 0 ; l < nYPartNum ; l++ )
     3339    {
     3340      for( Int nVertexIdx = 0 ; nVertexIdx < 4 ; nVertexIdx++ )
     3341      {
     3342        SYUVP sRes = pc3DAsymLUT->getCuboidVertexResTree( yIdx + l , uIdx , vIdx , nVertexIdx );
     3343
     3344        UInt uiCodeVertex = sRes.Y != 0 || sRes.U != 0 || sRes.V != 0;
     3345        nCurBits++;
     3346        if( uiCodeVertex )
     3347        {
     3348          xCheckParamBits( sRes.Y, nFLCbits, nCurBits );
     3349          xCheckParamBits( sRes.U, nFLCbits, nCurBits );
     3350          xCheckParamBits( sRes.V, nFLCbits, nCurBits );
     3351        }
     3352      }
     3353    }
     3354  }
     3355}
     3356
     3357Void TEncCavlc::xCheckParamBits( Int param, Int rParam, Int &nBits)
     3358{
     3359  Int codeNumber = abs(param);
     3360  Int codeQuotient = codeNumber >> rParam;
     3361  Int qLen;
     3362
     3363  UInt uiLength = 1;
     3364  UInt uiTemp = ++codeQuotient;
     3365   
     3366  while( 1 != uiTemp )
     3367  {
     3368    uiTemp >>= 1;
     3369    uiLength += 2;
     3370  }
     3371
     3372  qLen  = (uiLength >> 1);
     3373  qLen += ((uiLength+1) >> 1);
     3374
     3375  nBits += qLen;
     3376  nBits += rParam;
     3377  if (abs(param))
     3378    nBits++;
     3379}
     3380#endif
     3381#if VPS_VUI_BSP_HRD_PARAMS
     3382Void TEncCavlc::codeVpsVuiBspHrdParams(TComVPS * const vps)
     3383{
     3384  WRITE_UVLC( vps->getVpsNumAddHrdParams(), "vps_num_add_hrd_params" );
     3385  for( Int i = vps->getNumHrdParameters(), j = 0; i < vps->getNumHrdParameters() + vps->getVpsNumAddHrdParams(); i++, j++ ) // j = i - vps->getNumHrdParameters()
     3386  {
     3387    if( i > 0 )
     3388    {
     3389      WRITE_FLAG( vps->getCprmsAddPresentFlag(j), "cprms_add_present_flag[i]" );
     3390    }
     3391    WRITE_UVLC( vps->getNumSubLayerHrdMinus1(j), "num_sub_layer_hrd_minus1[i]" );
     3392    codeHrdParameters(vps->getBspHrd(j), i == 0 ? true : vps->getCprmsAddPresentFlag(j), vps->getNumSubLayerHrdMinus1(j));
     3393  }
     3394  for( Int h = 1; h < vps->getNumOutputLayerSets(); h++ )
     3395  {
     3396    Int lsIdx = vps->getOutputLayerSetIdx( h );
     3397    WRITE_UVLC( vps->getNumSignalledPartitioningSchemes(h), "num_signalled_partitioning_schemes[h]");
     3398    for( Int j = 0; j < vps->getNumSignalledPartitioningSchemes(h); j++ )
     3399    {
     3400      WRITE_UVLC( vps->getNumPartitionsInSchemeMinus1(h, j), "num_partitions_in_scheme_minus1[h][j]" );
     3401      for( Int k = 0; k <= vps->getNumPartitionsInSchemeMinus1(h, j); k++ )
     3402      {
     3403        for( Int r = 0; r < vps->getNumLayersInIdList( lsIdx ); r++ )
     3404        {
     3405          WRITE_FLAG( vps->getLayerIncludedInPartitionFlag(h, j, k, r), "layer_included_in_partition_flag[h][j][k][r]" );
     3406        }
     3407      }
     3408    }
     3409    for( Int i = 0; i < vps->getNumSignalledPartitioningSchemes(h) + 1; i++ )
     3410    {
     3411      for( Int t = 0; t <= vps->getMaxSLayersInLayerSetMinus1(lsIdx); t++ )
     3412      {
     3413        WRITE_UVLC(vps->getNumBspSchedulesMinus1(h, i, t), "num_bsp_schedules_minus1[h][i][t]");
     3414        for( Int j = 0; j <= vps->getNumBspSchedulesMinus1(h, i, t); j++ )
     3415        {
     3416          for( Int k = 0; k < vps->getNumPartitionsInSchemeMinus1(h, i); k++ )
     3417          {
     3418            WRITE_UVLC( vps->getBspHrdIdx(h, i, t, j, k),   "bsp_comb_hrd_idx[h][i][t][j][k]");
     3419            WRITE_UVLC( vps->getBspSchedIdx(h, i, t, j, k), "bsp_comb_sched_idx[h][i][t][j][k]");
     3420          }
     3421        }
     3422      }
     3423    }
     3424  }
     3425}
     3426#endif
    28123427#endif
    28133428//! \}
  • trunk/source/Lib/TLibEncoder/TEncCavlc.h

    r815 r906  
    169169  Void  codeVpsDpbSizeTable    (TComVPS *vps);
    170170#endif
    171 #if Q0048_CGS_3D_ASYMLUT
     171#if VPS_VUI_BSP_HRD_PARAMS
     172  Void  codeVpsVuiBspHrdParams  (TComVPS * const);
     173#endif
     174#if Q0048_CGS_3D_ASYMLUT
     175#if R0179_ENC_OPT_3DLUT_SIZE
     176public:
     177  Void xCode3DAsymLUT( TCom3DAsymLUT * pc3DAsymLUT );
     178protected:
     179  Void xCode3DAsymLUTOctant( TCom3DAsymLUT * pc3DAsymLUT , Int nDepth , Int yIdx , Int uIdx , Int vIdx , Int nLength );
     180#else
    172181protected:
    173182  Void xCode3DAsymLUT( TCom3DAsymLUT * pc3DAsymLUT );
    174183  Void xCode3DAsymLUTOctant( TCom3DAsymLUT * pc3DAsymLUT , Int nDepth , Int yIdx , Int uIdx , Int vIdx , Int nLength );
    175184#endif
     185#if R0151_CGS_3D_ASYMLUT_IMPROVE
     186#if R0300_CGS_RES_COEFF_CODING
     187  Void xWriteParam( Int param, UInt nFLCBits);
     188  Void xCheckParamBits( Int param, Int nFLCBits, Int & nCurBits);
     189  Void xTally3DAsymLUTOctantBits( TCom3DAsymLUT * pc3DAsymLUT , Int nDepth , Int yIdx , Int uIdx , Int vIdx , Int nLength, Int nDeltaBits, Int &nCurBits);
     190  Void xFindDeltaBits( TCom3DAsymLUT * pc3DAsymLUT );
     191#else
     192  Void xWriteParam( Int param);
     193#endif
     194#endif
     195#endif
    176196#endif //SVC_EXTENSION
    177197
  • trunk/source/Lib/TLibEncoder/TEncCfg.h

    r815 r906  
    107107  Int       m_iSourceWidth;
    108108  Int       m_iSourceHeight;
    109   Int       m_conformanceMode;
    110109  Window    m_conformanceWindow;
    111110  Int       m_framesToBeEncoded;
     
    208207  Bool      m_bPCMFilterDisableFlag;
    209208  Bool      m_loopFilterAcrossTilesEnabledFlag;
    210   Int       m_iUniformSpacingIdr;
     209  Bool      m_tileUniformSpacingFlag;
    211210  Int       m_iNumColumnsMinus1;
    212   UInt*     m_puiColumnWidth;
    213211  Int       m_iNumRowsMinus1;
    214   UInt*     m_puiRowHeight;
     212  std::vector<Int> m_tileColumnWidth;
     213  std::vector<Int> m_tileRowHeight;
    215214
    216215  Int       m_iWaveFrontSynchro;
     
    248247  Int*      m_codedPivotValue;
    249248  Int*      m_targetPivotValue;
    250 #if P0050_KNEE_FUNCTION_SEI
    251   Bool      m_kneeSEIEnabled;
    252   Int       m_kneeSEIId;
    253   Bool      m_kneeSEICancelFlag;
    254   Bool      m_kneeSEIPersistenceFlag;
    255   Bool      m_kneeSEIMappingFlag;
    256   Int       m_kneeSEIInputDrange;
    257   Int       m_kneeSEIInputDispLuminance;
    258   Int       m_kneeSEIOutputDrange;
    259   Int       m_kneeSEIOutputDispLuminance;
    260   Int       m_kneeSEINumKneePointsMinus1;
    261   Int*      m_kneeSEIInputKneePoint;
    262   Int*      m_kneeSEIOutputKneePoint;
    263 #endif
    264 #if Q0074_SEI_COLOR_MAPPING
    265   Char*     m_seiColorMappingFile;
    266 #endif
    267249  Int       m_framePackingSEIEnabled;
    268250  Int       m_framePackingSEIType;
     
    276258  Int       m_SOPDescriptionSEIEnabled;
    277259  Int       m_scalableNestingSEIEnabled;
    278 #if Q0189_TMVP_CONSTRAINTS
    279   Int       m_TMVPConstraintsSEIEnabled;
    280 #endif
    281260  //====== Weighted Prediction ========
    282261  Bool      m_useWeightedPred;       //< Use of Weighting Prediction (P_SLICE)
     
    388367  Int  m_nCGSMaxYPartNumLog2;
    389368  Int  m_nCGSLUTBit;
     369#if R0151_CGS_3D_ASYMLUT_IMPROVE
     370  Int  m_nCGSAdaptiveChroma;
     371#endif
     372#if R0179_ENC_OPT_3DLUT_SIZE
     373  Int  m_nCGSLutSizeRDO;
     374#endif
     375#endif
     376#if P0050_KNEE_FUNCTION_SEI
     377  Bool      m_kneeSEIEnabled;
     378  Int       m_kneeSEIId;
     379  Bool      m_kneeSEICancelFlag;
     380  Bool      m_kneeSEIPersistenceFlag;
     381  Bool      m_kneeSEIMappingFlag;
     382  Int       m_kneeSEIInputDrange;
     383  Int       m_kneeSEIInputDispLuminance;
     384  Int       m_kneeSEIOutputDrange;
     385  Int       m_kneeSEIOutputDispLuminance;
     386  Int       m_kneeSEINumKneePointsMinus1;
     387  Int*      m_kneeSEIInputKneePoint;
     388  Int*      m_kneeSEIOutputKneePoint;
     389#endif
     390#if Q0189_TMVP_CONSTRAINTS
     391  Int       m_TMVPConstraintsSEIEnabled;
    390392#endif
    391393#endif //SVC_EXTENSION
     394#if Q0074_COLOUR_REMAPPING_SEI
     395  Char*     m_colourRemapSEIFile;          ///< SEI Colour Remapping File (initialized from external file)
     396  Int       m_colourRemapSEIId;
     397  Bool      m_colourRemapSEICancelFlag;
     398  Bool      m_colourRemapSEIPersistenceFlag;
     399  Bool      m_colourRemapSEIVideoSignalInfoPresentFlag;
     400  Bool      m_colourRemapSEIFullRangeFlag;
     401  Int       m_colourRemapSEIPrimaries;
     402  Int       m_colourRemapSEITransferFunction;
     403  Int       m_colourRemapSEIMatrixCoefficients;
     404  Int       m_colourRemapSEIInputBitDepth;
     405  Int       m_colourRemapSEIBitDepth;
     406  Int       m_colourRemapSEIPreLutNumValMinus1[3];
     407  Int*      m_colourRemapSEIPreLutCodedValue[3];
     408  Int*      m_colourRemapSEIPreLutTargetValue[3];
     409  Bool      m_colourRemapSEIMatrixPresentFlag;
     410  Int       m_colourRemapSEILog2MatrixDenom;
     411  Int       m_colourRemapSEICoeffs[3][3];
     412  Int       m_colourRemapSEIPostLutNumValMinus1[3];
     413  Int*      m_colourRemapSEIPostLutCodedValue[3];
     414  Int*      m_colourRemapSEIPostLutTargetValue[3];
     415#endif
    392416
    393417public:
    394418  TEncCfg()
    395   : m_puiColumnWidth()
    396   , m_puiRowHeight()
     419  : m_tileColumnWidth()
     420  , m_tileRowHeight()
    397421  {}
    398422
    399423  virtual ~TEncCfg()
    400   {
    401     delete[] m_puiColumnWidth;
    402     delete[] m_puiRowHeight;
    403   }
     424  {}
    404425 
    405426  Void setProfile(Profile::Name profile) { m_profile = profile; }
     
    412433
    413434  Window   &getConformanceWindow()                           { return m_conformanceWindow; }
    414 #if P0312_VERT_PHASE_ADJ
     435#if P0312_VERT_PHASE_ADJ && !R0209_GENERIC_PHASE
    415436  Void      setConformanceWindow (Int confLeft, Int confRight, Int confTop, Int confBottom ) { m_conformanceWindow.setWindow (confLeft, confRight, confTop, confBottom, false); }
    416437#else
     
    437458  Void      setMaxRefPicNum                 ( Int iMaxRefPicNum )           { m_iMaxRefPicNum = iMaxRefPicNum;  }
    438459
    439   Bool      getMaxTempLayer                 ()                              { return m_maxTempLayer;              }
     460  Int       getMaxTempLayer                 ()                              { return m_maxTempLayer;              }
    440461  Void      setMaxTempLayer                 ( Int maxTempLayer )            { m_maxTempLayer = maxTempLayer;      }
    441462  //======== Transform =============
     
    582603  Void  setLFCrossTileBoundaryFlag               ( Bool   val  )       { m_loopFilterAcrossTilesEnabledFlag = val; }
    583604  Bool  getLFCrossTileBoundaryFlag               ()                    { return m_loopFilterAcrossTilesEnabledFlag;   }
    584   Void  setUniformSpacingIdr           ( Int i )           { m_iUniformSpacingIdr = i; }
    585   Int   getUniformSpacingIdr           ()                  { return m_iUniformSpacingIdr; }
     605  Void  setTileUniformSpacingFlag      ( Bool b )          { m_tileUniformSpacingFlag = b; }
     606  Bool  getTileUniformSpacingFlag      ()                  { return m_tileUniformSpacingFlag; }
    586607  Void  setNumColumnsMinus1            ( Int i )           { m_iNumColumnsMinus1 = i; }
    587608  Int   getNumColumnsMinus1            ()                  { return m_iNumColumnsMinus1; }
    588   Void  setColumnWidth ( UInt* columnWidth )
    589   {
    590     if( m_iUniformSpacingIdr == 0 && m_iNumColumnsMinus1 > 0 )
    591     {
    592       Int  m_iWidthInCU = ( m_iSourceWidth%g_uiMaxCUWidth ) ? m_iSourceWidth/g_uiMaxCUWidth + 1 : m_iSourceWidth/g_uiMaxCUWidth;
    593       m_puiColumnWidth = new UInt[ m_iNumColumnsMinus1 ];
    594 
    595       for(Int i=0; i<m_iNumColumnsMinus1; i++)
    596       {
    597         m_puiColumnWidth[i] = columnWidth[i];
    598         printf("col: m_iWidthInCU= %4d i=%4d width= %4d\n",m_iWidthInCU,i,m_puiColumnWidth[i]); //AFU
    599       }
    600     }
    601   }
    602   UInt  getColumnWidth                 ( UInt columnidx )  { return *( m_puiColumnWidth + columnidx ); }
     609  Void  setColumnWidth ( const std::vector<Int>& columnWidth ) { m_tileColumnWidth = columnWidth; }
     610  UInt  getColumnWidth                 ( UInt columnIdx )      { return m_tileColumnWidth[columnIdx]; }
    603611  Void  setNumRowsMinus1               ( Int i )           { m_iNumRowsMinus1 = i; }
    604612  Int   getNumRowsMinus1               ()                  { return m_iNumRowsMinus1; }
    605   Void  setRowHeight (UInt* rowHeight)
    606   {
    607     if( m_iUniformSpacingIdr == 0 && m_iNumRowsMinus1 > 0 )
    608     {
    609       Int  m_iHeightInCU = ( m_iSourceHeight%g_uiMaxCUHeight ) ? m_iSourceHeight/g_uiMaxCUHeight + 1 : m_iSourceHeight/g_uiMaxCUHeight;
    610       m_puiRowHeight = new UInt[ m_iNumRowsMinus1 ];
    611 
    612       for(Int i=0; i<m_iNumRowsMinus1; i++)
    613       {
    614         m_puiRowHeight[i] = rowHeight[i];
    615         printf("row: m_iHeightInCU=%4d i=%4d height=%4d\n",m_iHeightInCU,i,m_puiRowHeight[i]); //AFU
    616       }
    617     }
    618   }
    619   UInt  getRowHeight                   ( UInt rowIdx )     { return *( m_puiRowHeight + rowIdx ); }
     613  Void  setRowHeight ( const std::vector<Int>& rowHeight)      { m_tileRowHeight = rowHeight; }
     614  UInt  getRowHeight                   ( UInt rowIdx )         { return m_tileRowHeight[rowIdx]; }
    620615  Void  xCheckGSParameters();
    621616  Void  setWaveFrontSynchro(Int iWaveFrontSynchro)       { m_iWaveFrontSynchro = iWaveFrontSynchro; }
     
    711706  Int*  getKneeSEIOutputKneePoint()                          { return m_kneeSEIOutputKneePoint; }
    712707#endif
    713 #if Q0074_SEI_COLOR_MAPPING
    714   Void  setColorMappingInfoSEIFile( Char* nameFile )         {  m_seiColorMappingFile = nameFile; }
    715   Char* getColorMappingInfoSEIFile()                         {  return m_seiColorMappingFile; }
     708#if Q0074_COLOUR_REMAPPING_SEI
     709  Void  setCRISEIFile( Char* pch )                           { m_colourRemapSEIFile = pch; }
     710  Char* getCRISEIFile()                                      { return m_colourRemapSEIFile; }
     711  Void  setCRISEIId(Int i)                                   { m_colourRemapSEIId = i; }
     712  Int   getCRISEIId()                                        { return m_colourRemapSEIId; }
     713  Void  setCRISEICancelFlag(Bool b)                          { m_colourRemapSEICancelFlag = b; }
     714  Bool  getCRISEICancelFlag()                                { return m_colourRemapSEICancelFlag; }
     715  Void  setCRISEIPersistenceFlag(Bool b)                     { m_colourRemapSEIPersistenceFlag = b; }
     716  Bool  getCRISEIPersistenceFlag()                           { return m_colourRemapSEIPersistenceFlag; }
     717  Void  setCRISEIVideoSignalInfoPresentFlag(Bool b)          { m_colourRemapSEIVideoSignalInfoPresentFlag = b; }
     718  Bool  getCRISEIVideoSignalInfoPresentFlag()                { return m_colourRemapSEIVideoSignalInfoPresentFlag; }
     719  Void  setCRISEIFullRangeFlag(Bool b)                       { m_colourRemapSEIFullRangeFlag = b; }
     720  Bool  getCRISEIFullRangeFlag()                             { return m_colourRemapSEIFullRangeFlag; }
     721  Void  setCRISEIPrimaries(Int i)                            { m_colourRemapSEIPrimaries = i; }
     722  Int   getCRISEIPrimaries()                                 { return m_colourRemapSEIPrimaries; } 
     723  Void  setCRISEITransferFunction(Int i)                     { m_colourRemapSEITransferFunction = i; }
     724  Int   getCRISEITransferFunction()                          { return m_colourRemapSEITransferFunction; } 
     725  Void  setCRISEIMatrixCoefficients(Int i)                   { m_colourRemapSEIMatrixCoefficients = i; }
     726  Int   getCRISEIMatrixCoefficients()                        { return m_colourRemapSEIMatrixCoefficients; }
     727  Void  setCRISEIInputBitDepth(Int i)                        { m_colourRemapSEIInputBitDepth = i; }
     728  Int   getCRISEIInputBitDepth()                             { return m_colourRemapSEIInputBitDepth; }
     729  Void  setCRISEIBitDepth(Int i)                             { m_colourRemapSEIBitDepth = i; }
     730  Int   getCRISEIBitDepth()                                  { return m_colourRemapSEIBitDepth; }
     731  Void  setCRISEIPreLutNumValMinus1(Int *i)                  { for(Int c=0 ; c<3 ; c++) m_colourRemapSEIPreLutNumValMinus1[c] = i[c]; }
     732  Int   getCRISEIPreLutNumValMinus1(Int i)                   { return m_colourRemapSEIPreLutNumValMinus1[i]; }
     733  Void  setCRISEIPreLutCodedValue(Int **i)                   { for(Int c=0 ; c<3 ; c++) m_colourRemapSEIPreLutCodedValue[c] = i[c]; }
     734  Int*  getCRISEIPreLutCodedValue(Int i)                     { return m_colourRemapSEIPreLutCodedValue[i]; }
     735  Void  setCRISEIPreLutTargetValue(Int **i)                  { for(Int c=0 ; c<3 ; c++) m_colourRemapSEIPreLutTargetValue[c] = i[c]; }
     736  Int*  getCRISEIPreLutTargetValue(Int i)                    { return m_colourRemapSEIPreLutTargetValue[i]; }
     737  Void  setCRISEIMatrixPresentFlag(Bool b)                   { m_colourRemapSEIMatrixPresentFlag = b; }
     738  Bool  getCRISEIMatrixPresentFlag()                         { return m_colourRemapSEIMatrixPresentFlag; }
     739  Void  setCRISEILog2MatrixDenom(Int i)                      { m_colourRemapSEILog2MatrixDenom = i; }
     740  Int   getCRISEILog2MatrixDenom()                           { return m_colourRemapSEILog2MatrixDenom; }
     741  Void  setCRISEICoeffs(Int i[3][3])                         { for(Int c=0 ; c<3 ; c++) for(Int j=0 ; j<3 ; j++) m_colourRemapSEICoeffs[c][j] = i[c][j]; }
     742  Int*  getCRISEICoeffs(Int i)                               { return m_colourRemapSEICoeffs[i]; }
     743  Void  setCRISEIPostLutNumValMinus1(Int *i)                 { for(Int c=0 ; c<3 ; c++) m_colourRemapSEIPostLutNumValMinus1[c] = i[c]; }
     744  Int   getCRISEIPostLutNumValMinus1(Int i)                  { return m_colourRemapSEIPostLutNumValMinus1[i]; }
     745  Void  setCRISEIPostLutCodedValue(Int **i)                  { for(Int c=0 ; c<3 ; c++) m_colourRemapSEIPostLutCodedValue[c] = i[c]; }
     746  Int*  getCRISEIPostLutCodedValue(Int i)                    { return m_colourRemapSEIPostLutCodedValue[i]; }
     747  Void  setCRISEIPostLutTargetValue(Int **i)                 { for(Int c=0 ; c<3 ; c++) m_colourRemapSEIPostLutTargetValue[c] = i[c]; }
     748  Int*  getCRISEIPostLutTargetValue(Int i)                   { return m_colourRemapSEIPostLutTargetValue[i]; }
    716749#endif
    717750  Void  setFramePackingArrangementSEIEnabled(Int b)      { m_framePackingSEIEnabled = b; }
     
    865898  UInt      getNumLayer           () { return m_numLayer;             } 
    866899  Void      setNumLayer           (UInt uiNum)   { m_numLayer = uiNum;  }
    867   Void      setConformanceMode    (Int mode)     { m_conformanceMode = mode; }
    868900  Void      setConformanceWindow(Window& conformanceWindow ) { m_conformanceWindow = conformanceWindow; }
    869901  Void      setElRapSliceTypeB(Int bEnabled) {m_elRapSliceBEnabled = bEnabled;}
     
    9711003  Void      setCGSLUTBit(Int n)           { m_nCGSLUTBit = n;    }
    9721004  Int       getCGSLUTBit()                { return m_nCGSLUTBit; }
     1005#if R0151_CGS_3D_ASYMLUT_IMPROVE
     1006  Void      setCGSAdaptChroma(Int n)      { m_nCGSAdaptiveChroma = n;  }
     1007  Int       getCGSAdaptChroma()           { return m_nCGSAdaptiveChroma; }
     1008#endif
     1009#if R0179_ENC_OPT_3DLUT_SIZE
     1010  Void      setCGSLutSizeRDO(Int n)      { m_nCGSLutSizeRDO = n;  }
     1011  Int       getCGSLutSizeRDO()           { return m_nCGSLutSizeRDO; }
     1012#endif
    9731013#endif
    9741014#endif
  • trunk/source/Lib/TLibEncoder/TEncGOP.cpp

    r815 r906  
    4949#include <time.h>
    5050#include <math.h>
     51#if P0297_VPS_POC_LSB_ALIGNED_FLAG
     52#include <limits.h>
     53#endif
    5154
    5255using namespace std;
     
    202205  seiActiveParameterSets->m_selfContainedCvsFlag = false;
    203206  seiActiveParameterSets->m_noParameterSetUpdateFlag = false;
     207#if !R0247_SEI_ACTIVE
    204208  seiActiveParameterSets->numSpsIdsMinus1 = 0;
    205209  seiActiveParameterSets->activeSeqParameterSetId.resize(seiActiveParameterSets->numSpsIdsMinus1 + 1);
    206210  seiActiveParameterSets->activeSeqParameterSetId[0] = sps->getSPSId();
     211#else
     212  seiActiveParameterSets->numSpsIdsMinus1 = m_pcCfg->getNumLayer()-1;
     213  seiActiveParameterSets->activeSeqParameterSetId.resize(seiActiveParameterSets->numSpsIdsMinus1 + 1);
     214  seiActiveParameterSets->layerSpsIdx.resize(seiActiveParameterSets->numSpsIdsMinus1+ 1); 
     215  for (Int c=0; c <= seiActiveParameterSets->numSpsIdsMinus1; c++)
     216  {
     217     seiActiveParameterSets->activeSeqParameterSetId[c] = c;
     218  }
     219  for (Int c=1; c <= seiActiveParameterSets->numSpsIdsMinus1; c++)
     220  {
     221     seiActiveParameterSets->layerSpsIdx[c] = c;
     222  }
     223#endif
    207224  return seiActiveParameterSets;
    208225}
     
    365382#endif
    366383
    367 #if Q0074_SEI_COLOR_MAPPING
    368 SEIColorMappingInfo*  TEncGOP::xCreateSEIColorMappingInfo( Char* file )
     384#if Q0074_COLOUR_REMAPPING_SEI
     385SEIColourRemappingInfo*  TEncGOP::xCreateSEIColourRemappingInfo()
    369386{
    370   SEIColorMappingInfo *seiColorMappingInfo = new SEIColorMappingInfo();
    371 
    372   FILE* fic = fopen( file, "r" );
    373 
    374   Int iVal, retval;
    375 
    376   retval = fscanf( fic, "%d", &seiColorMappingInfo->m_colorMapId );
    377   retval = fscanf( fic, "%d", &iVal );
    378   seiColorMappingInfo->m_colorMapCancelFlag = iVal;
    379   if( !seiColorMappingInfo->m_colorMapCancelFlag )
    380   {
    381     retval = fscanf( fic, "%d", &iVal );
    382     seiColorMappingInfo->m_colorMapPersistenceFlag = iVal;
    383     retval = fscanf( fic, "%d", &iVal );
    384     seiColorMappingInfo->m_colorMap_video_signal_type_present_flag = iVal;
    385     if( seiColorMappingInfo->m_colorMap_video_signal_type_present_flag )
    386     {
    387       retval = fscanf( fic, "%d", &iVal );
    388       seiColorMappingInfo->m_colorMap_video_full_range_flag = iVal;
    389       retval = fscanf( fic, "%d", &seiColorMappingInfo->m_colorMap_primaries );
    390       retval = fscanf( fic, "%d", &seiColorMappingInfo->m_colorMap_transfer_characteristics );
    391       retval = fscanf( fic, "%d", &seiColorMappingInfo->m_colorMap_matrix_coeffs );
    392     }
    393   }
    394 
    395   retval = fscanf( fic, "%d", &seiColorMappingInfo->m_colour_map_coded_data_bit_depth );
    396   retval = fscanf( fic, "%d", &seiColorMappingInfo->m_colour_map_target_bit_depth );
    397   retval = fscanf( fic, "%d", &iVal );
    398   seiColorMappingInfo->m_colorMapModelId = iVal;
    399 
    400   assert( seiColorMappingInfo->m_colorMapModelId == 0 );
    401  
    402   for( Int i=0 ; i<3 ; i++ )
    403   {
    404     retval = fscanf( fic, "%d", &seiColorMappingInfo->m_num_input_pivots[i] );
    405     seiColorMappingInfo->m_coded_input_pivot_value[i]   = new Int[ seiColorMappingInfo->m_num_input_pivots[i] ];
    406     seiColorMappingInfo->m_target_input_pivot_value[i]  = new Int[ seiColorMappingInfo->m_num_input_pivots[i] ];
    407     for( Int j=0 ; j<seiColorMappingInfo->m_num_input_pivots[i] ; j++ )
    408     {
    409       retval = fscanf( fic, "%d", &seiColorMappingInfo->m_coded_input_pivot_value[i][j] );
    410       retval = fscanf( fic, "%d", &seiColorMappingInfo->m_target_input_pivot_value[i][j] );
    411     }
    412   }
    413 
    414   retval = fscanf( fic, "%d", &iVal );
    415   seiColorMappingInfo->m_matrix_flag = iVal;
    416   if( seiColorMappingInfo->m_matrix_flag )
    417   {
    418     retval = fscanf( fic, "%d", &seiColorMappingInfo->m_log2_matrix_denom );
    419     for( Int i=0 ; i<3 ; i++ )
    420     {
    421       for( Int j=0 ; j<3 ; j++ )
    422       {
    423         retval = fscanf( fic, "%d", &seiColorMappingInfo->m_matrix_coef[i][j] );
    424       }
    425     }
    426   }
    427 
    428   for( Int i=0 ; i<3 ; i++ )
    429   {
    430     retval = fscanf( fic, "%d", &seiColorMappingInfo->m_num_output_pivots[i] );
    431     seiColorMappingInfo->m_coded_output_pivot_value[i]   = new Int[ seiColorMappingInfo->m_num_output_pivots[i] ];
    432     seiColorMappingInfo->m_target_output_pivot_value[i]  = new Int[ seiColorMappingInfo->m_num_output_pivots[i] ];
    433     for( Int j=0 ; j<seiColorMappingInfo->m_num_output_pivots[i] ; j++ )
    434     {
    435       retval = fscanf( fic, "%d", &seiColorMappingInfo->m_coded_output_pivot_value[i][j] );
    436       retval = fscanf( fic, "%d", &seiColorMappingInfo->m_target_output_pivot_value[i][j] );
    437     }
    438   }
    439 
    440   fclose( fic );
    441 
    442   if( retval != 1 )
    443   {
    444     printf("Error: can't read color mapping information\n");
    445   }
    446 
    447   return seiColorMappingInfo;
     387  SEIColourRemappingInfo *seiColourRemappingInfo = new SEIColourRemappingInfo();
     388  seiColourRemappingInfo->m_colourRemapId         = m_pcCfg->getCRISEIId();
     389  seiColourRemappingInfo->m_colourRemapCancelFlag = m_pcCfg->getCRISEICancelFlag();
     390  if( !seiColourRemappingInfo->m_colourRemapCancelFlag )
     391  {
     392    seiColourRemappingInfo->m_colourRemapPersistenceFlag            = m_pcCfg->getCRISEIPersistenceFlag();
     393    seiColourRemappingInfo->m_colourRemapVideoSignalInfoPresentFlag = m_pcCfg->getCRISEIVideoSignalInfoPresentFlag();
     394    if( seiColourRemappingInfo->m_colourRemapVideoSignalInfoPresentFlag )
     395    {
     396      seiColourRemappingInfo->m_colourRemapFullRangeFlag           = m_pcCfg->getCRISEIFullRangeFlag();
     397      seiColourRemappingInfo->m_colourRemapPrimaries               = m_pcCfg->getCRISEIPrimaries();
     398      seiColourRemappingInfo->m_colourRemapTransferFunction        = m_pcCfg->getCRISEITransferFunction();
     399      seiColourRemappingInfo->m_colourRemapMatrixCoefficients      = m_pcCfg->getCRISEIMatrixCoefficients();
     400    }
     401    seiColourRemappingInfo->m_colourRemapInputBitDepth             = m_pcCfg->getCRISEIInputBitDepth();
     402    seiColourRemappingInfo->m_colourRemapBitDepth                  = m_pcCfg->getCRISEIBitDepth();
     403    for( Int c=0 ; c<3 ; c++ )
     404    {
     405      seiColourRemappingInfo->m_preLutNumValMinus1[c] = m_pcCfg->getCRISEIPreLutNumValMinus1(c);
     406      if( seiColourRemappingInfo->m_preLutNumValMinus1[c]>0 )
     407      {
     408        seiColourRemappingInfo->m_preLutCodedValue[c].resize(seiColourRemappingInfo->m_preLutNumValMinus1[c]+1);
     409        seiColourRemappingInfo->m_preLutTargetValue[c].resize(seiColourRemappingInfo->m_preLutNumValMinus1[c]+1);
     410        for( Int i=0 ; i<=seiColourRemappingInfo->m_preLutNumValMinus1[c] ; i++)
     411        {
     412          seiColourRemappingInfo->m_preLutCodedValue[c][i]  = (m_pcCfg->getCRISEIPreLutCodedValue(c))[i];
     413          seiColourRemappingInfo->m_preLutTargetValue[c][i] = (m_pcCfg->getCRISEIPreLutTargetValue(c))[i];
     414        }
     415      }
     416    }
     417    seiColourRemappingInfo->m_colourRemapMatrixPresentFlag = m_pcCfg->getCRISEIMatrixPresentFlag();
     418    if( seiColourRemappingInfo->m_colourRemapMatrixPresentFlag )
     419    {
     420      seiColourRemappingInfo->m_log2MatrixDenom = m_pcCfg->getCRISEILog2MatrixDenom();
     421      for( Int c=0 ; c<3 ; c++ )
     422        for( Int i=0 ; i<3 ; i++ )
     423          seiColourRemappingInfo->m_colourRemapCoeffs[c][i] = (m_pcCfg->getCRISEICoeffs(c))[i];
     424    }
     425    for( Int c=0 ; c<3 ; c++ )
     426    {
     427      seiColourRemappingInfo->m_postLutNumValMinus1[c] = m_pcCfg->getCRISEIPostLutNumValMinus1(c);
     428      if( seiColourRemappingInfo->m_postLutNumValMinus1[c]>0 )
     429      {
     430        seiColourRemappingInfo->m_postLutCodedValue[c].resize(seiColourRemappingInfo->m_postLutNumValMinus1[c]+1);
     431        seiColourRemappingInfo->m_postLutTargetValue[c].resize(seiColourRemappingInfo->m_postLutNumValMinus1[c]+1);
     432        for( Int i=0 ; i<=seiColourRemappingInfo->m_postLutNumValMinus1[c] ; i++)
     433        {
     434          seiColourRemappingInfo->m_postLutCodedValue[c][i]  = (m_pcCfg->getCRISEIPostLutCodedValue(c))[i];
     435          seiColourRemappingInfo->m_postLutTargetValue[c][i] = (m_pcCfg->getCRISEIPostLutTargetValue(c))[i];
     436        }
     437      }
     438    }
     439  }
     440  return seiColourRemappingInfo;
    448441}
    449442#endif
     
    453446  OutputNALUnit nalu(NAL_UNIT_PREFIX_SEI);
    454447
    455   if(m_pcCfg->getActiveParameterSetsSEIEnabled())
     448  if(m_pcCfg->getActiveParameterSetsSEIEnabled()
     449#if R0247_SEI_ACTIVE
     450    && m_layerId == 0
     451#endif
     452    )
    456453  {
    457454    SEIActiveParameterSets *sei = xCreateSEIActiveParameterSets (sps);
     
    532529  }
    533530#endif
    534 #if Q0074_SEI_COLOR_MAPPING
    535   if(m_pcCfg->getColorMappingInfoSEIFile())
    536   {
    537     SEIColorMappingInfo *sei = xCreateSEIColorMappingInfo( m_pcCfg->getColorMappingInfoSEIFile() );
     531#if Q0074_COLOUR_REMAPPING_SEI
     532  if(strlen(m_pcCfg->getCRISEIFile()))
     533  {
     534    SEIColourRemappingInfo *sei = xCreateSEIColourRemappingInfo ();
    538535     
    539536#if SVC_EXTENSION
    540     nalu = NALUnit(NAL_UNIT_PREFIX_SEI, 0, m_layerId);  // temporalId = 0 ?
     537    nalu = NALUnit(NAL_UNIT_PREFIX_SEI, 0, sps->getLayerId());  // SEI-CRI is applied per layer
    541538#else
    542539    nalu = NALUnit(NAL_UNIT_PREFIX_SEI);
     
    609606  TEncSbac* pcSbacCoders = NULL;
    610607  TComOutputBitstream* pcSubstreamsOut = NULL;
    611 #if Q0108_TSA_STSA
    612   Int flagTSTA = 0;
    613 #endif
    614608
    615609  xInitGOP( iPOCLast, iNumPicRcvd, rcListPic, rcListPicYuvRecOut, isField );
     
    918912    determinePocResetIdc(pocCurr, pcSlice);
    919913
     914#if P0297_VPS_POC_LSB_ALIGNED_FLAG
     915    Bool pocResettingFlag = false;
     916
     917    if (pcSlice->getPocResetIdc() != 0)
     918    {
     919      if (pcSlice->getVPS()->getVpsPocLsbAlignedFlag())
     920      {
     921        pocResettingFlag = true;
     922      }
     923      else if (m_pcEncTop->getPocDecrementedInDPBFlag())
     924      {
     925        pocResettingFlag = false;
     926      }
     927      else
     928      {
     929        pocResettingFlag = true;
     930      }
     931    }
     932#endif
     933
    920934    // If reset, do the following steps:
     935#if P0297_VPS_POC_LSB_ALIGNED_FLAG
     936    if( pocResettingFlag )
     937#else
    921938    if( pcSlice->getPocResetIdc() )
     939#endif
    922940    {
    923941      updatePocValuesOfPics(pocCurr, pcSlice);
     
    10201038      // inferring of the scaling list can be moved to the config file
    10211039      UInt refLayerId = 0;
     1040#if VPS_AVC_BL_FLAG_REMOVAL
     1041      if( m_layerId > 0 && !m_pcEncTop->getVPS()->getNonHEVCBaseLayerFlag() && m_pcEncTop->getVPS()->getRecursiveRefLayerFlag( m_layerId, refLayerId ) )
     1042#else
    10221043      if( m_layerId > 0 && !m_pcEncTop->getVPS()->getAvcBaseLayerFlag() && m_pcEncTop->getVPS()->getRecursiveRefLayerFlag( m_layerId, refLayerId ) )
     1044#endif
    10231045      {
    10241046        m_pcEncTop->getSPS()->setInferScalingListFlag( true );
     
    10501072      // inferring of the scaling list can be moved to the config file
    10511073      UInt refLayerId = 0;
     1074#if VPS_AVC_BL_FLAG_REMOVAL
     1075      if( m_layerId > 0 && !m_pcEncTop->getVPS()->getNonHEVCBaseLayerFlag() && m_pcEncTop->getVPS()->getRecursiveRefLayerFlag( m_layerId, refLayerId ) )
     1076#else
    10521077      if( m_layerId > 0 && !m_pcEncTop->getVPS()->getAvcBaseLayerFlag() && m_pcEncTop->getVPS()->getRecursiveRefLayerFlag( m_layerId, refLayerId ) )
     1078#endif
    10531079      {
    10541080        m_pcEncTop->getSPS()->setInferScalingListFlag( true );
     
    11351161#endif
    11361162
     1163#if REF_REGION_OFFSET
     1164        const Window &windowRL  = m_pcEncTop->getRefLayerWindowForLayer(pcSlice->getVPS()->getRefLayerId(m_layerId, refLayerIdc));
     1165        Int widthBL   = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec()->getWidth() - windowRL.getWindowLeftOffset() - windowRL.getWindowRightOffset();
     1166        Int heightBL  = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec()->getHeight() - windowRL.getWindowTopOffset() - windowRL.getWindowBottomOffset();
     1167#else
    11371168        Int widthBL   = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec()->getWidth();
    11381169        Int heightBL  = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec()->getHeight();
     
    11431174        heightBL -= ( confBL.getWindowTopOffset() + confBL.getWindowBottomOffset() ) * TComSPS::getWinUnitY( chromaFormatIdc );
    11441175#endif
     1176#endif
    11451177        Int widthEL   = pcPic->getPicYuvRec()->getWidth()  - scalEL.getWindowLeftOffset() - scalEL.getWindowRightOffset();
    11461178        Int heightEL  = pcPic->getPicYuvRec()->getHeight() - scalEL.getWindowTopOffset()  - scalEL.getWindowBottomOffset();
     1179
     1180#if RESAMPLING_FIX
     1181#if REF_REGION_OFFSET
     1182        // conformance check: the values of RefLayerRegionWidthInSamplesY, RefLayerRegionHeightInSamplesY, ScaledRefRegionWidthInSamplesY and ScaledRefRegionHeightInSamplesY shall be greater than 0
     1183        assert(widthEL > 0 && heightEL > 0 && widthBL > 0 && widthEL > 0);
     1184
     1185        // conformance check: ScaledRefRegionWidthInSamplesY shall be greater or equal to RefLayerRegionWidthInSamplesY and ScaledRefRegionHeightInSamplesY shall be greater or equal to RefLayerRegionHeightInSamplesY
     1186        assert(widthEL >= widthBL && heightEL >= heightBL);
     1187
     1188#if R0209_GENERIC_PHASE
     1189        // conformance check: when ScaledRefRegionWidthInSamplesY is equal to RefLayerRegionWidthInSamplesY, PhaseHorY shall be equal to 0, when ScaledRefRegionWidthInSamplesC is equal to RefLayerRegionWidthInSamplesC, PhaseHorC shall be equal to 0, when ScaledRefRegionHeightInSamplesY is equal to RefLayerRegionHeightInSamplesY, PhaseVerY shall be equal to 0, and when ScaledRefRegionHeightInSamplesC is equal to RefLayerRegionHeightInSamplesC, PhaseVerC shall be equal to 0.
     1190        Int phaseHorLuma   = pcSlice->getPPS()->getPhaseHorLuma(refLayerIdc);
     1191        Int phaseVerLuma   = pcSlice->getPPS()->getPhaseVerLuma(refLayerIdc);
     1192        Int phaseHorChroma = pcSlice->getPPS()->getPhaseHorChroma(refLayerIdc);
     1193        Int phaseVerChroma = pcSlice->getPPS()->getPhaseVerChroma(refLayerIdc);
     1194        assert( ( (widthEL  != widthBL)  || (phaseHorLuma == 0 && phaseHorChroma == 0) )
     1195             && ( (heightEL != heightBL) || (phaseVerLuma == 0 && phaseVerChroma == 0) ) );
     1196#endif
     1197#endif
     1198#endif
    11471199
    11481200        g_mvScalingFactor[refLayerIdc][0] = widthEL  == widthBL  ? 4096 : Clip3(-4096, 4095, ((widthEL  << 8) + (widthBL  >> 1)) / widthBL);
     
    11561208        if( pcSlice->getPPS()->getCGSFlag() )
    11571209        {
     1210#if R0150_CGS_SIGNAL_CONSTRAINTS
     1211          // all reference layers are currently taken as CGS reference layers
     1212          m_Enc3DAsymLUTPPS.addRefLayerId( pcSlice->getVPS()->getRefLayerId(m_layerId, refLayerIdc) );
     1213          m_Enc3DAsymLUTPicUpdate.addRefLayerId( pcSlice->getVPS()->getRefLayerId(m_layerId, refLayerIdc) );
     1214#endif
    11581215          if(g_posScalingFactor[refLayerIdc][0] < (1<<16) || g_posScalingFactor[refLayerIdc][1] < (1<<16)) //if(pcPic->isSpatialEnhLayer(refLayerIdc))
    11591216          {
     
    12071264#if O0194_JOINT_US_BITSHIFT
    12081265#if Q0048_CGS_3D_ASYMLUT
    1209             m_pcPredSearch->upsampleBasePic( pcSlice, refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, pcPic->getPicYuvRec(), scalEL );
    1210 #else
    1211             m_pcPredSearch->upsampleBasePic( pcSlice, refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), pcPic->getPicYuvRec(), scalEL );
     1266#if REF_REGION_OFFSET
     1267          m_pcPredSearch->upsampleBasePic( pcSlice, refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, pcPic->getPicYuvRec(), scalEL, altRL );
     1268#else
     1269          m_pcPredSearch->upsampleBasePic( pcSlice, refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, pcPic->getPicYuvRec(), scalEL );
     1270#endif
     1271#else
     1272          m_pcPredSearch->upsampleBasePic( pcSlice, refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), pcPic->getPicYuvRec(), scalEL );
    12121273#endif
    12131274#else
     
    12701331        }
    12711332      }
    1272 
     1333#if ISLICE_TYPE_NUMDIR
     1334      if( pcSlice->getActiveNumILRRefIdx() == 0 && pcSlice->getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP && pcSlice->getNalUnitType() <= NAL_UNIT_CODED_SLICE_CRA && (m_pcEncTop->getNumDirectRefLayers() == 0) )
     1335#else
    12731336      if( pcSlice->getActiveNumILRRefIdx() == 0 && pcSlice->getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP && pcSlice->getNalUnitType() <= NAL_UNIT_CODED_SLICE_CRA )
     1337#endif
    12741338      {
    12751339        pcSlice->setSliceType(I_SLICE);
     
    13951459      if(pcSlice->isTemporalLayerSwitchingPoint(rcListPic) || pcSlice->getSPS()->getTemporalIdNestingFlag())
    13961460      {
    1397 #if !Q0108_TSA_STSA
     1461#if SVC_EXTENSION && !Q0108_TSA_STSA
    13981462        if( pcSlice->getLayerId() > 0 )
    13991463        {
     
    14941558        if(isSTSA==true)
    14951559        {   
    1496 #if !Q0108_TSA_STSA
     1560#if SVC_EXTENSION && !Q0108_TSA_STSA
    14971561          if( pcSlice->getLayerId() > 0 )
    14981562          {
     
    15631627      }
    15641628    }
     1629
     1630    arrangeLongtermPicturesInRPS(pcSlice, rcListPic);
     1631    TComRefPicListModification* refPicListModification = pcSlice->getRefPicListModification();
     1632    refPicListModification->setRefPicListModificationFlagL0(0);
     1633    refPicListModification->setRefPicListModificationFlagL1(0);
     1634    pcSlice->setNumRefIdx(REF_PIC_LIST_0,min(m_pcCfg->getGOPEntry(iGOPid).m_numRefPicsActive,pcSlice->getRPS()->getNumberOfPictures()));
     1635    pcSlice->setNumRefIdx(REF_PIC_LIST_1,min(m_pcCfg->getGOPEntry(iGOPid).m_numRefPicsActive,pcSlice->getRPS()->getNumberOfPictures()));
     1636
     1637#if SVC_EXTENSION
     1638    if( m_layerId > 0 && pcSlice->getActiveNumILRRefIdx() )
     1639    {
     1640#if POC_RESET_FLAG || POC_RESET_IDC_ENCODER
     1641      if ( pocCurr > 0 && pcSlice->isRADL() && pcPic->getSlice(0)->getBaseColPic(pcPic->getSlice(0)->getInterLayerPredLayerIdc(0))->getSlice(0)->isRASL())
     1642#else
     1643      if (pcSlice->getPOC()>0  && pcSlice->isRADL() && pcPic->getSlice(0)->getBaseColPic(pcPic->getSlice(0)->getInterLayerPredLayerIdc(0))->getSlice(0)->isRASL())
     1644#endif
     1645      {
     1646        pcSlice->setActiveNumILRRefIdx(0);
     1647        pcSlice->setInterLayerPredEnabledFlag(0);
     1648      }
     1649      if( pcSlice->getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP && pcSlice->getNalUnitType() <= NAL_UNIT_CODED_SLICE_CRA )
     1650      {
     1651        pcSlice->setNumRefIdx(REF_PIC_LIST_0, pcSlice->getActiveNumILRRefIdx());
     1652        pcSlice->setNumRefIdx(REF_PIC_LIST_1, pcSlice->getActiveNumILRRefIdx());
     1653      }
     1654      else
     1655      {
     1656        pcSlice->setNumRefIdx(REF_PIC_LIST_0, pcSlice->getNumRefIdx(REF_PIC_LIST_0)+pcSlice->getActiveNumILRRefIdx());
     1657        pcSlice->setNumRefIdx(REF_PIC_LIST_1, pcSlice->getNumRefIdx(REF_PIC_LIST_1)+pcSlice->getActiveNumILRRefIdx());
     1658      }
     1659
     1660      // check for the reference pictures whether there is at least one either temporal picture or ILRP with sample prediction type
     1661      if( pcSlice->getNumRefIdx( REF_PIC_LIST_0 ) - pcSlice->getActiveNumILRRefIdx() == 0 && pcSlice->getNumRefIdx( REF_PIC_LIST_1 ) - pcSlice->getActiveNumILRRefIdx() == 0 )
     1662      {
     1663        Bool foundSamplePredPicture = false;               
     1664
     1665        for( Int i = 0; i < pcSlice->getActiveNumILRRefIdx(); i++ )
     1666        {
     1667          if( m_ppcTEncTop[m_layerId]->getSamplePredEnabledFlag( pcSlice->getVPS()->getRefLayerId( m_layerId, pcSlice->getInterLayerPredLayerIdc(i) ) ) )
     1668          {
     1669            foundSamplePredPicture = true;
     1670            break;
     1671          }
     1672        }
     1673
     1674        if( !foundSamplePredPicture )
     1675        {
     1676          pcSlice->setSliceType(I_SLICE);
     1677          pcSlice->setInterLayerPredEnabledFlag(0);
     1678          pcSlice->setActiveNumILRRefIdx(0);
     1679        }
     1680      }
     1681    }
     1682#endif //SVC_EXTENSION
     1683
    15651684#if Q0108_TSA_STSA
    1566     else if( ( pcSlice->getTLayer() == 0 && pcSlice->getLayerId() > 0)    // only for enhancement layer and with temporal layer 0
    1567        && !( pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_RADL_N     
     1685   if( ( pcSlice->getTLayer() == 0 && pcSlice->getLayerId() > 0  )    // only for enhancement layer and with temporal layer 0
     1686     && !( pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_RADL_N     
    15681687          || pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_RADL_R
    15691688          || pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N
     
    15761695    {
    15771696        Bool isSTSA=true;
     1697        Bool isIntra=false;
     1698
     1699        for( Int i = 0; i < pcSlice->getLayerId(); i++)
     1700        {
     1701          TComList<TComPic *> *cListPic = m_ppcTEncTop[i]->getListPic();
     1702          TComPic *lowerLayerPic = pcSlice->getRefPic(*cListPic, pcSlice->getPOC());
     1703          if( lowerLayerPic && pcSlice->getVPS()->getDirectDependencyFlag(pcSlice->getLayerId(), i) )
     1704          {
     1705            if( lowerLayerPic->getSlice(0)->getSliceType() == I_SLICE)
     1706            {
     1707              isIntra = true;
     1708            }
     1709          }
     1710        }
     1711
    15781712        for(Int ii=iGOPid+1; ii < m_pcCfg->getGOPSize() && isSTSA; ii++)
    15791713        {
     
    16051739          }
    16061740        }
    1607         if(isSTSA==true)
     1741        if(isSTSA==true && isIntra == false)
    16081742        {   
    1609 #if !Q0108_TSA_STSA
    1610           if( pcSlice->getLayerId() > 0 )
    1611           {
    1612             Bool oneRefLayerSTSA = false, oneRefLayerNotSTSA = false;
    1613             for( Int i = 0; i < pcSlice->getLayerId(); i++)
    1614             {
    1615               TComList<TComPic *> *cListPic = m_ppcTEncTop[i]->getListPic();
    1616               TComPic *lowerLayerPic = pcSlice->getRefPic(*cListPic, pcSlice->getPOC());
    1617               if( lowerLayerPic && pcSlice->getVPS()->getDirectDependencyFlag(pcSlice->getLayerId(), i) )
    1618               {
    1619                 if( ( lowerLayerPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_STSA_N ) ||
    1620                     ( lowerLayerPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_STSA_R )
    1621                   )
    1622                 {
    1623                   if(pcSlice->getTemporalLayerNonReferenceFlag() )
    1624                   {
    1625                     pcSlice->setNalUnitType(NAL_UNIT_CODED_SLICE_STSA_N);
    1626                   }
    1627                   else
    1628                   {
    1629                     pcSlice->setNalUnitType(NAL_UNIT_CODED_SLICE_STSA_R );
    1630                   }
    1631                   oneRefLayerSTSA = true;
    1632                 }
    1633                 else
    1634                 {
    1635                   oneRefLayerNotSTSA = true;
    1636                 }
    1637               }
    1638             }
    1639             assert( !( oneRefLayerNotSTSA && oneRefLayerSTSA ) ); // Only one variable should be true - failure of this assert means
    1640                                                                   // that two independent reference layers that are not dependent on
    1641                                                                   // each other, but are reference for current layer have inconsistency
    1642             if( oneRefLayerNotSTSA /*&& !oneRefLayerSTSA*/ )          // No reference layer is STSA - set current as TRAIL
    1643             {
    1644               if(pcSlice->getTemporalLayerNonReferenceFlag() )
    1645               {
    1646                 pcSlice->setNalUnitType( NAL_UNIT_CODED_SLICE_TRAIL_N );
    1647               }
    1648               else
    1649               {
    1650                 pcSlice->setNalUnitType( NAL_UNIT_CODED_SLICE_TRAIL_R );
    1651               }
    1652             }
    1653             else  // This means there is no reference layer picture for current picture in this AU
    1654             {
    1655               if(pcSlice->getTemporalLayerNonReferenceFlag() )
    1656               {
    1657                 pcSlice->setNalUnitType(NAL_UNIT_CODED_SLICE_STSA_N);
    1658               }
    1659               else
    1660               {
    1661                 pcSlice->setNalUnitType(NAL_UNIT_CODED_SLICE_STSA_R );
    1662               }
    1663             }
    1664           }
    1665 #else
    16661743          if(pcSlice->getTemporalLayerNonReferenceFlag())
    16671744          {
    16681745            pcSlice->setNalUnitType(NAL_UNIT_CODED_SLICE_STSA_N);
    1669             flagTSTA = 1;
    16701746          }
    16711747          else
    16721748          {
    16731749            pcSlice->setNalUnitType(NAL_UNIT_CODED_SLICE_STSA_R);
    1674             flagTSTA = 1;
    1675           }
    1676 #endif
    1677         }
    1678     }
    1679 #endif
    1680 
    1681     arrangeLongtermPicturesInRPS(pcSlice, rcListPic);
    1682     TComRefPicListModification* refPicListModification = pcSlice->getRefPicListModification();
    1683     refPicListModification->setRefPicListModificationFlagL0(0);
    1684     refPicListModification->setRefPicListModificationFlagL1(0);
    1685     pcSlice->setNumRefIdx(REF_PIC_LIST_0,min(m_pcCfg->getGOPEntry(iGOPid).m_numRefPicsActive,pcSlice->getRPS()->getNumberOfPictures()));
    1686     pcSlice->setNumRefIdx(REF_PIC_LIST_1,min(m_pcCfg->getGOPEntry(iGOPid).m_numRefPicsActive,pcSlice->getRPS()->getNumberOfPictures()));
    1687 
    1688 #if SVC_EXTENSION
    1689     if( m_layerId > 0 && pcSlice->getActiveNumILRRefIdx() )
    1690     {
    1691 #if POC_RESET_FLAG || POC_RESET_IDC_ENCODER
    1692       if ( pocCurr > 0 && pcSlice->isRADL() && pcPic->getSlice(0)->getBaseColPic(pcPic->getSlice(0)->getInterLayerPredLayerIdc(0))->getSlice(0)->isRASL())
    1693 #else
    1694       if (pcSlice->getPOC()>0  && pcSlice->isRADL() && pcPic->getSlice(0)->getBaseColPic(pcPic->getSlice(0)->getInterLayerPredLayerIdc(0))->getSlice(0)->isRASL())
    1695 #endif
    1696       {
    1697         pcSlice->setActiveNumILRRefIdx(0);
    1698         pcSlice->setInterLayerPredEnabledFlag(0);
    1699       }
    1700 #if Q0108_TSA_STSA
    1701      if( ( pcSlice->getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP && pcSlice->getNalUnitType() <= NAL_UNIT_CODED_SLICE_CRA ) || flagTSTA == 1 )
    1702 #else
    1703      if( pcSlice->getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP && pcSlice->getNalUnitType() <= NAL_UNIT_CODED_SLICE_CRA )
    1704 #endif
    1705       {
    1706         pcSlice->setNumRefIdx(REF_PIC_LIST_0, pcSlice->getActiveNumILRRefIdx());
    1707         pcSlice->setNumRefIdx(REF_PIC_LIST_1, pcSlice->getActiveNumILRRefIdx());
    1708       }
    1709       else
    1710       {
    1711         pcSlice->setNumRefIdx(REF_PIC_LIST_0, pcSlice->getNumRefIdx(REF_PIC_LIST_0)+pcSlice->getActiveNumILRRefIdx());
    1712         pcSlice->setNumRefIdx(REF_PIC_LIST_1, pcSlice->getNumRefIdx(REF_PIC_LIST_1)+pcSlice->getActiveNumILRRefIdx());
    1713       }
    1714 
    1715       // check for the reference pictures whether there is at least one either temporal picture or ILRP with sample prediction type
    1716       if( pcSlice->getNumRefIdx( REF_PIC_LIST_0 ) - pcSlice->getActiveNumILRRefIdx() == 0 && pcSlice->getNumRefIdx( REF_PIC_LIST_1 ) - pcSlice->getActiveNumILRRefIdx() == 0 )
    1717       {
    1718         Bool foundSamplePredPicture = false;               
    1719 
    1720         for( Int i = 0; i < pcSlice->getActiveNumILRRefIdx(); i++ )
    1721         {
    1722           if( m_ppcTEncTop[m_layerId]->getSamplePredEnabledFlag( pcSlice->getVPS()->getRefLayerId( m_layerId, pcSlice->getInterLayerPredLayerIdc(i) ) ) )
    1723           {
    1724             foundSamplePredPicture = true;
    1725             break;
    1726           }
    1727         }
    1728 
    1729         if( !foundSamplePredPicture )
    1730         {
    1731           pcSlice->setSliceType(I_SLICE);
    1732           pcSlice->setInterLayerPredEnabledFlag(0);
    1733           pcSlice->setActiveNumILRRefIdx(0);
    1734         }
    1735       }
    1736     }
    1737 #endif //SVC_EXTENSION
     1750          }
     1751        }
     1752    }
     1753#endif
    17381754
    17391755#if ADAPTIVE_QP_SELECTION
     
    17501766    if(m_layerId ==  0 || ( m_layerId > 0 && pcSlice->getActiveNumILRRefIdx() == 0 ) )
    17511767    {
    1752       pcSlice->setRefPicList( rcListPic);
     1768      pcSlice->setRefPicList( rcListPic );
    17531769    }
    17541770
     
    17561772    {
    17571773      pcSlice->setILRPic( m_pcEncTop->getIlpList() );
    1758 #if REF_IDX_MFM
    1759       if( pcSlice->getMFMEnabledFlag() )
    1760       {
    1761         pcSlice->setRefPOCListILP(m_pcEncTop->getIlpList(), pcSlice->getBaseColPic());
    1762       }
    1763 #else
     1774#if !REF_IDX_MFM
    17641775      //  Set reference list
    17651776      pcSlice->setRefPicList ( rcListPic );
     
    21102121    UInt uiRealEndAddress = uiExternalAddress*pcPic->getNumPartInCU()+uiInternalAddress;
    21112122
    2112     UInt uiCummulativeTileWidth;
    2113     UInt uiCummulativeTileHeight;
    21142123    Int  p, j;
    21152124    UInt uiEncCUAddr;
    21162125
    2117     //set NumColumnsMinus1 and NumRowsMinus1
    2118     pcPic->getPicSym()->setNumColumnsMinus1( pcSlice->getPPS()->getNumColumnsMinus1() );
    2119     pcPic->getPicSym()->setNumRowsMinus1( pcSlice->getPPS()->getNumRowsMinus1() );
    2120 
    2121     //create the TComTileArray
    2122     pcPic->getPicSym()->xCreateTComTileArray();
    2123 
    2124     if( pcSlice->getPPS()->getUniformSpacingFlag() == 1 )
    2125     {
    2126       //set the width for each tile
    2127       for(j=0; j < pcPic->getPicSym()->getNumRowsMinus1()+1; j++)
    2128       {
    2129         for(p=0; p < pcPic->getPicSym()->getNumColumnsMinus1()+1; p++)
    2130         {
    2131           pcPic->getPicSym()->getTComTile( j * (pcPic->getPicSym()->getNumColumnsMinus1()+1) + p )->
    2132             setTileWidth( (p+1)*pcPic->getPicSym()->getFrameWidthInCU()/(pcPic->getPicSym()->getNumColumnsMinus1()+1)
    2133             - (p*pcPic->getPicSym()->getFrameWidthInCU())/(pcPic->getPicSym()->getNumColumnsMinus1()+1) );
    2134         }
    2135       }
    2136 
    2137       //set the height for each tile
    2138       for(j=0; j < pcPic->getPicSym()->getNumColumnsMinus1()+1; j++)
    2139       {
    2140         for(p=0; p < pcPic->getPicSym()->getNumRowsMinus1()+1; p++)
    2141         {
    2142           pcPic->getPicSym()->getTComTile( p * (pcPic->getPicSym()->getNumColumnsMinus1()+1) + j )->
    2143             setTileHeight( (p+1)*pcPic->getPicSym()->getFrameHeightInCU()/(pcPic->getPicSym()->getNumRowsMinus1()+1)
    2144             - (p*pcPic->getPicSym()->getFrameHeightInCU())/(pcPic->getPicSym()->getNumRowsMinus1()+1) );   
    2145         }
    2146       }
    2147     }
    2148     else
    2149     {
    2150       //set the width for each tile
    2151       for(j=0; j < pcPic->getPicSym()->getNumRowsMinus1()+1; j++)
    2152       {
    2153         uiCummulativeTileWidth = 0;
    2154         for(p=0; p < pcPic->getPicSym()->getNumColumnsMinus1(); p++)
    2155         {
    2156           pcPic->getPicSym()->getTComTile( j * (pcPic->getPicSym()->getNumColumnsMinus1()+1) + p )->setTileWidth( pcSlice->getPPS()->getColumnWidth(p) );
    2157           uiCummulativeTileWidth += pcSlice->getPPS()->getColumnWidth(p);
    2158         }
    2159         pcPic->getPicSym()->getTComTile(j * (pcPic->getPicSym()->getNumColumnsMinus1()+1) + p)->setTileWidth( pcPic->getPicSym()->getFrameWidthInCU()-uiCummulativeTileWidth );
    2160       }
    2161 
    2162       //set the height for each tile
    2163       for(j=0; j < pcPic->getPicSym()->getNumColumnsMinus1()+1; j++)
    2164       {
    2165         uiCummulativeTileHeight = 0;
    2166         for(p=0; p < pcPic->getPicSym()->getNumRowsMinus1(); p++)
    2167         {
    2168           pcPic->getPicSym()->getTComTile( p * (pcPic->getPicSym()->getNumColumnsMinus1()+1) + j )->setTileHeight( pcSlice->getPPS()->getRowHeight(p) );
    2169           uiCummulativeTileHeight += pcSlice->getPPS()->getRowHeight(p);
    2170         }
    2171         pcPic->getPicSym()->getTComTile(p * (pcPic->getPicSym()->getNumColumnsMinus1()+1) + j)->setTileHeight( pcPic->getPicSym()->getFrameHeightInCU()-uiCummulativeTileHeight );
    2172       }
    2173     }
    2174     //intialize each tile of the current picture
    2175     pcPic->getPicSym()->xInitTiles();
     2126    pcPic->getPicSym()->initTiles(pcSlice->getPPS());
    21762127
    21772128#if N0383_IL_CONSTRAINED_TILE_SETS_SEI
     
    21832134
    21842135    // Allocate some coders, now we know how many tiles there are.
     2136#if WPP_FIX
     2137    const Int iNumSubstreams = pcSlice->getPPS()->getNumSubstreams();
     2138#else
    21852139    Int iNumSubstreams = pcSlice->getPPS()->getNumSubstreams();
     2140#endif
    21862141
    21872142    //generate the Coding Order Map and Inverse Coding Order Map
     
    22152170    startCUAddrSliceSegmentIdx++;
    22162171#if AVC_BASE
     2172#if VPS_AVC_BL_FLAG_REMOVAL
     2173    if( m_layerId == 0 && m_pcEncTop->getVPS()->getNonHEVCBaseLayerFlag() )
     2174#else
    22172175    if( m_layerId == 0 && m_pcEncTop->getVPS()->getAvcBaseLayerFlag() )
     2176#endif
    22182177    {
    22192178      pcPic->getPicYuvOrg()->copyToPic( pcPic->getPicYuvRec() );
     
    22252184      }
    22262185#endif
    2227 #if AVC_SYNTAX
    2228       pcPic->readBLSyntax( m_ppcTEncTop[0]->getBLSyntaxFile(), SYNTAX_BYTES );
    2229 #endif
     2186
     2187      if( pcSubstreamsOut )
     2188      {
     2189        delete[] pcSubstreamsOut;
     2190        pcSubstreamsOut = NULL;
     2191      }
     2192
     2193      if( pcBitstreamRedirect )
     2194      {
     2195        delete pcBitstreamRedirect;
     2196        pcBitstreamRedirect = NULL;
     2197      }
     2198
    22302199      return;
    22312200    }
     
    23182287      OutputNALUnit nalu( NAL_UNIT_VPS, 0, 0 ); // The value of nuh_layer_id of VPS NAL unit shall be equal to 0.
    23192288#if AVC_BASE
     2289#if VPS_AVC_BL_FLAG_REMOVAL
     2290      if( ( m_layerId == 1 && m_pcEncTop->getVPS()->getNonHEVCBaseLayerFlag() ) || ( m_layerId == 0 && !m_pcEncTop->getVPS()->getNonHEVCBaseLayerFlag() ) )
     2291#else
    23202292      if( ( m_layerId == 1 && m_pcEncTop->getVPS()->getAvcBaseLayerFlag() ) || ( m_layerId == 0 && !m_pcEncTop->getVPS()->getAvcBaseLayerFlag() ) )
     2293#endif
    23212294#else
    23222295      if( m_layerId == 0 )
     
    24182391      if (pcSlice->getLayerId() == 0 && m_pcEncTop->getVPS()->getVpsVuiBspHrdPresentFlag())
    24192392      {
    2420         nalu = NALUnit(NAL_UNIT_PREFIX_SEI, 0, 1);
    2421         m_pcEntropyCoder->setEntropyCoder(m_pcCavlcCoder, pcSlice);
    2422         m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
    2423         SEIScalableNesting *scalableBspNestingSei = xCreateBspNestingSEI(pcSlice);
    2424         m_seiWriter.writeSEImessage(nalu.m_Bitstream, *scalableBspNestingSei, m_pcEncTop->getVPS(), pcSlice->getSPS());
    2425         writeRBSPTrailingBits(nalu.m_Bitstream);
    2426 
    2427         UInt seiPositionInAu = xGetFirstSeiLocation(accessUnit);
    2428         UInt offsetPosition = m_activeParameterSetSEIPresentInAU
    2429           + m_bufferingPeriodSEIPresentInAU
    2430           + m_pictureTimingSEIPresentInAU
    2431           + m_nestedPictureTimingSEIPresentInAU;  // Insert SEI after APS, BP and PT SEI
    2432         AccessUnit::iterator it;
    2433         for(j = 0, it = accessUnit.begin(); j < seiPositionInAu + offsetPosition; j++)
    2434         {
    2435           it++;
    2436         }
    2437         accessUnit.insert(it, new NALUnitEBSP(nalu));
     2393#if VPS_VUI_BSP_HRD_PARAMS
     2394        TComVPS *vps = m_pcEncTop->getVPS();
     2395        for(Int i = 0; i < vps->getNumOutputLayerSets(); i++)
     2396        {
     2397          for(Int k = 0; k < vps->getNumSignalledPartitioningSchemes(i); k++)
     2398          {
     2399            for(Int l = 0; l < vps->getNumPartitionsInSchemeMinus1(i, k)+1; l++)
     2400            {
     2401#endif
     2402              nalu = NALUnit(NAL_UNIT_PREFIX_SEI, 0, 1);
     2403              m_pcEntropyCoder->setEntropyCoder(m_pcCavlcCoder, pcSlice);
     2404              m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
     2405#if VPS_VUI_BSP_HRD_PARAMS
     2406              SEIScalableNesting *scalableBspNestingSei = xCreateBspNestingSEI(pcSlice, i, k, l);
     2407#else
     2408              SEIScalableNesting *scalableBspNestingSei = xCreateBspNestingSEI(pcSlice);
     2409#endif
     2410              m_seiWriter.writeSEImessage(nalu.m_Bitstream, *scalableBspNestingSei, m_pcEncTop->getVPS(), pcSlice->getSPS());
     2411              writeRBSPTrailingBits(nalu.m_Bitstream);
     2412
     2413              UInt seiPositionInAu = xGetFirstSeiLocation(accessUnit);
     2414              UInt offsetPosition = m_activeParameterSetSEIPresentInAU
     2415                + m_bufferingPeriodSEIPresentInAU
     2416                + m_pictureTimingSEIPresentInAU
     2417                + m_nestedPictureTimingSEIPresentInAU;  // Insert SEI after APS, BP and PT SEI
     2418              AccessUnit::iterator it;
     2419              for(j = 0, it = accessUnit.begin(); j < seiPositionInAu + offsetPosition; j++)
     2420              {
     2421                it++;
     2422              }
     2423              accessUnit.insert(it, new NALUnitEBSP(nalu));
     2424#if VPS_VUI_BSP_HRD_PARAMS
     2425            }
     2426          }
     2427        }
     2428#endif
    24382429      }
    24392430#endif
     
    28422833
    28432834#if SETTING_NO_OUT_PIC_PRIOR
     2835          pcSlice->setNoRaslOutputFlag(false);
    28442836          if (pcSlice->isIRAP())
    28452837          {
     
    28492841            }
    28502842            //the inference for NoOutputPriorPicsFlag
     2843            // KJS: This cannot happen at the encoder
    28512844            if (!m_bFirst && pcSlice->isIRAP() && pcSlice->getNoRaslOutputFlag())
    28522845            {
     
    28762869            m_pcEntropyCoder->setEntropyCoder ( m_pcSbacCoder, pcSlice );
    28772870            m_pcEntropyCoder->resetEntropy    ();
     2871#if WPP_FIX
     2872            for ( UInt ui = 0 ; ui < iNumSubstreams ; ui++ )
     2873#else
    28782874            for ( UInt ui = 0 ; ui < pcSlice->getPPS()->getNumSubstreams() ; ui++ )
     2875#endif
    28792876            {
    28802877              m_pcEntropyCoder->setEntropyCoder ( &pcSbacCoders[ui], pcSlice );
     
    28882885            m_pcSbacCoder->init( (TEncBinIf*)m_pcBinCABAC );
    28892886            {
     2887#if WPP_FIX
     2888              for ( UInt ui = 0 ; ui < iNumSubstreams ; ui++ )
     2889#else
    28902890              for ( UInt ui = 0 ; ui < pcSlice->getPPS()->getNumSubstreams() ; ui++ )
     2891#endif
    28912892              {
    28922893                m_pcEntropyCoder->setEntropyCoder ( &pcSbacCoders[ui], pcSlice );
     
    29152916
    29162917          pcSlice->setTileOffstForMultES( uiOneBitstreamPerSliceLength );
    2917             pcSlice->setTileLocationCount ( 0 );
     2918          pcSlice->setTileLocationCount ( 0 );
    29182919          m_pcSliceEncoder->encodeSlice(pcPic, pcSubstreamsOut);
    29192920
     
    29422943
    29432944              Bool bNextSubstreamInNewTile = ((ui+1) < iNumSubstreams)&& ((ui+1)%uiNumSubstreamsPerTile == 0);
     2945#if WPP_FIX
     2946              if (bNextSubstreamInNewTile &&  !pcSlice->getPPS()->getEntropyCodingSyncEnabledFlag() )
     2947#else
    29442948              if (bNextSubstreamInNewTile)
     2949#endif
    29452950              {
    29462951                pcSlice->setTileLocation(ui/uiNumSubstreamsPerTile, pcSlice->getTileOffstForMultES()+(uiTotalCodedSize>>3));
    29472952              }
     2953#if WPP_FIX
     2954              if (ui+1 < iNumSubstreams)
     2955              {
     2956                puiSubstreamSizes[ui] = pcSubstreamsOut[ui].getNumberOfWrittenBits() + (pcSubstreamsOut[ui].countStartCodeEmulations()<<3);
     2957              }
     2958#else
    29482959              if (ui+1 < pcSlice->getPPS()->getNumSubstreams())
    29492960              {
    29502961                puiSubstreamSizes[ui] = pcSubstreamsOut[ui].getNumberOfWrittenBits() + (pcSubstreamsOut[ui].countStartCodeEmulations()<<3);
    29512962              }
     2963#endif
    29522964            }
    29532965
     
    29662978            // Substreams...
    29672979            TComOutputBitstream *pcOut = pcBitstreamRedirect;
    2968           Int offs = 0;
     2980#if WPP_FIX
     2981            Int numZeroSubstreamsAtStartOfSlice = 0;
     2982            Int numSubstreamsToCode = pcSlice->getPPS()->getNumSubstreams();
     2983            if (pcSlice->getPPS()->getEntropyCodingSyncEnabledFlag())
     2984            {
     2985              Int  maxNumParts                      = pcPic->getNumPartInCU();
     2986              numZeroSubstreamsAtStartOfSlice  = pcPic->getSubstreamForLCUAddr(pcSlice->getSliceSegmentCurStartCUAddr()/maxNumParts, false, pcSlice);
     2987              // 1st line present for WPP.
     2988              numSubstreamsToCode  = pcSlice->getNumEntryPointOffsets()+1;
     2989            }
     2990            for ( UInt ui = 0 ; ui < numSubstreamsToCode; ui++ )
     2991            {
     2992              pcOut->addSubstream(&pcSubstreamsOut[ui+numZeroSubstreamsAtStartOfSlice]);
     2993            }
     2994#else
     2995            Int offs = 0;
    29692996          Int nss = pcSlice->getPPS()->getNumSubstreams();
    29702997          if (pcSlice->getPPS()->getEntropyCodingSyncEnabledFlag())
     
    29783005            pcOut->addSubstream(&pcSubstreamsOut[ui+offs]);
    29793006            }
     3007#endif
    29803008          }
    29813009
     
    33963424      pcPicYuvRecOut->setReconstructed(true);
    33973425#endif
    3398 
     3426#if P0297_VPS_POC_LSB_ALIGNED_FLAG
     3427      m_pcEncTop->setFirstPicInLayerDecodedFlag(true);
     3428#endif
    33993429      pcPic->setReconMark   ( true );
    34003430      m_bFirst = false;
     
    34553485  // If BL picture in the AU is IDR, and another picture is not IDR, set the poc_reset_idc to 2
    34563486  // If BL picture is IRAP, and another picture is non-IRAP, then the poc_reset_idc is equal to 1 or 2.
     3487#if P0297_VPS_POC_LSB_ALIGNED_FLAG
     3488  slice->setPocMsbNeeded(false);
     3489#endif
    34573490  if( slice->getSliceIdx() == 0 ) // First slice - compute, copy for other slices
    34583491  {
     
    35143547        {
    35153548          slice->setPocResetIdc( 2 ); // Full reset needed
     3549#if P0297_VPS_POC_LSB_ALIGNED_FLAG
     3550          if (slice->getVPS()->getVpsPocLsbAlignedFlag() && slice->getVPS()->getNumDirectRefLayers(slice->getLayerId()) == 0)
     3551          {
     3552            slice->setPocMsbNeeded(true);  // Force msb writing
     3553          }
     3554#endif
    35163555        }
    35173556        else
     
    35303569        Int periodId = rand() % 64;
    35313570        m_lastPocPeriodId = (periodId == m_lastPocPeriodId) ? (periodId + 1) % 64 : periodId ;
     3571
     3572#if P0297_VPS_POC_LSB_ALIGNED_FLAG
     3573        for (UInt i = 0; i < MAX_LAYERS; i++)
     3574        {
     3575          m_ppcTEncTop[i]->setPocDecrementedInDPBFlag(false);
     3576        }
     3577#endif
    35323578      }
    35333579      else
     
    35463592Void TEncGOP::updatePocValuesOfPics(Int const pocCurr, TComSlice *const slice)
    35473593{
     3594#if P0297_VPS_POC_LSB_ALIGNED_FLAG
     3595  UInt affectedLayerList[MAX_NUM_LAYER_IDS];
     3596  Int  numAffectedLayers;
     3597
     3598  affectedLayerList[0] = m_layerId;
     3599  numAffectedLayers = 1;
     3600
     3601  if (m_pcEncTop->getVPS()->getVpsPocLsbAlignedFlag())
     3602  {
     3603    for (UInt j = 0; j < m_pcEncTop->getVPS()->getNumPredictedLayers(m_layerId); j++)
     3604    {
     3605      affectedLayerList[j + 1] = m_pcEncTop->getVPS()->getPredictedLayerId(m_layerId, j);
     3606    }
     3607    numAffectedLayers = m_pcEncTop->getVPS()->getNumPredictedLayers(m_layerId) + 1;
     3608  }
     3609#endif
    35483610
    35493611  Int pocAdjustValue = pocCurr - m_pcEncTop->getPocAdjustmentValue();
     
    35533615
    35543616  maxPocLsb   = 1 << slice->getSPS()->getBitsForPOC();
     3617
     3618#if P0297_VPS_POC_LSB_ALIGNED_FLAG
     3619  Int adjustedPocValue = pocCurr;
     3620
     3621  if (m_pcEncTop->getFirstPicInLayerDecodedFlag())
     3622  {
     3623#endif
     3624
    35553625  pocLsbVal   = (slice->getPocResetIdc() == 3)
    35563626                ? slice->getPocLsbVal()
     
    35613631                : 0;
    35623632  deltaPocVal = pocMsbDelta  + pocLsbDelta;
    3563  
     3633
     3634#if P0297_VPS_POC_LSB_ALIGNED_FLAG
     3635  Int origDeltaPocVal = deltaPocVal;  // original value needed when updating POC adjustment value
     3636
     3637  if (slice->getPocMsbNeeded())  // IDR picture in base layer, non-IDR picture in other layers, poc_lsb_aligned_flag = 1
     3638  {
     3639    if (slice->getLayerId() == 0)
     3640    {
     3641      Int highestPoc = INT_MIN;
     3642      // Find greatest POC in DPB for layer 0
     3643      for (TComList<TComPic*>::iterator iterPic = m_pcEncTop->getListPic()->begin(); iterPic != m_pcEncTop->getListPic()->end(); ++iterPic)
     3644      {
     3645        TComPic *dpbPic = *iterPic;
     3646        if (dpbPic->getReconMark() && dpbPic->getLayerId() == 0 && dpbPic->getPOC() > highestPoc)
     3647        {
     3648          highestPoc = dpbPic->getPOC();
     3649        }
     3650      }
     3651      deltaPocVal = (highestPoc - (highestPoc & (maxPocLsb - 1))) + 1*maxPocLsb;
     3652      m_pcEncTop->setCurrPocMsb(deltaPocVal);
     3653    }
     3654    else
     3655    {
     3656      deltaPocVal = m_ppcTEncTop[0]->getCurrPocMsb();  // copy from base layer
     3657    }
     3658    slice->setPocMsbVal(deltaPocVal);
     3659  }
     3660#endif
     3661
     3662#if P0297_VPS_POC_LSB_ALIGNED_FLAG
     3663  for (UInt layerIdx = 0; layerIdx < numAffectedLayers; layerIdx++)
     3664  {
     3665    if (!m_ppcTEncTop[affectedLayerList[layerIdx]]->getPocDecrementedInDPBFlag())
     3666    {
     3667      m_ppcTEncTop[affectedLayerList[layerIdx]]->setPocDecrementedInDPBFlag(true);
     3668
     3669      // Decrement value of associatedIrapPoc of the TEncGop object
     3670      m_ppcTEncTop[affectedLayerList[layerIdx]]->getGOPEncoder()->m_associatedIRAPPOC -= deltaPocVal;
     3671
     3672      // Decrememnt the value of m_pocCRA
     3673      m_ppcTEncTop[affectedLayerList[layerIdx]]->getGOPEncoder()->m_pocCRA -= deltaPocVal;
     3674
     3675      TComList<TComPic*>::iterator  iterPic = m_ppcTEncTop[affectedLayerList[layerIdx]]->getListPic()->begin();
     3676      while (iterPic != m_ppcTEncTop[affectedLayerList[layerIdx]]->getListPic()->end())
     3677#else
    35643678  // Decrement value of associatedIrapPoc of the TEncGop object
    35653679  this->m_associatedIRAPPOC -= deltaPocVal;
     
    35713685  TComList<TComPic*>::iterator  iterPic = getListPic()->begin(); 
    35723686  while( iterPic != getListPic()->end() )
     3687#endif
    35733688  {
    35743689    TComPic *dpbPic = *iterPic;
     
    35953710        // Update value of associatedIrapPoc of each slice
    35963711        dpbPicSlice->setAssociatedIRAPPOC( dpbPicSlice->getAssociatedIRAPPOC() - deltaPocVal );
     3712
     3713#if P0297_VPS_POC_LSB_ALIGNED_FLAG
     3714        if (slice->getPocMsbNeeded())
     3715        {
     3716          // this delta value is needed when computing delta POCs in reference picture set initialization
     3717          dpbPicSlice->setPocResetDeltaPoc(dpbPicSlice->getPocResetDeltaPoc() + (deltaPocVal - pocLsbVal));
     3718        }
     3719#endif
    35973720      }
    35983721    }
    35993722    iterPic++;
    36003723  }
    3601  
     3724#if P0297_VPS_POC_LSB_ALIGNED_FLAG
     3725    }
     3726  }
     3727#endif
     3728
    36023729  // Actual POC value before reset
     3730#if P0297_VPS_POC_LSB_ALIGNED_FLAG
     3731  adjustedPocValue = pocCurr - m_pcEncTop->getPocAdjustmentValue();
     3732#else
    36033733  Int adjustedPocValue = pocCurr - m_pcEncTop->getPocAdjustmentValue();
     3734#endif
    36043735
    36053736  // Set MSB value before reset
    36063737  Int tempLsbVal = adjustedPocValue & (maxPocLsb - 1);
    3607   slice->setPocMsbVal( adjustedPocValue - tempLsbVal);
     3738#if P0297_VPS_POC_LSB_ALIGNED_FLAG
     3739  if (!slice->getPocMsbNeeded())  // set poc msb normally if special msb handling is not needed
     3740  {
     3741#endif
     3742    slice->setPocMsbVal(adjustedPocValue - tempLsbVal);
     3743#if P0297_VPS_POC_LSB_ALIGNED_FLAG
     3744  }
     3745#endif
    36083746
    36093747  // Set LSB value before reset - this is needed in the case of resetIdc = 2
     
    36113749
    36123750  // Cumulative delta
     3751#if P0297_VPS_POC_LSB_ALIGNED_FLAG
     3752  deltaPocVal = origDeltaPocVal;  // restore deltaPoc for correct adjustment value update
     3753#endif
    36133754  m_pcEncTop->setPocAdjustmentValue( m_pcEncTop->getPocAdjustmentValue() + deltaPocVal );
     3755
     3756#if P0297_VPS_POC_LSB_ALIGNED_FLAG
     3757  }
     3758#endif
    36143759
    36153760  // New LSB value, after reset
     
    37383883  assert (m_iGopSize > 0);
    37393884 
    3740   return;
    3741 }
    3742 
    3743 Void TEncGOP::xInitGOP( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut )
    3744 {
    3745   assert( iNumPicRcvd > 0 );
    3746   //  Exception for the first frame
    3747   if ( iPOCLast == 0 )
    3748   {
    3749     m_iGopSize    = 1;
    3750   }
    3751   else
    3752     m_iGopSize    = m_pcCfg->getGOPSize();
    3753  
    3754   assert (m_iGopSize > 0);
    3755 
    37563885  return;
    37573886}
     
    40904219      {
    40914220#if POC_RESET_IDC_ENCODER
    4092         printf( "%d(%d)", pcSlice->getRefPOC(RefPicList(iRefList), iRefIndex), pcSlice->getRefPic(RefPicList(iRefList), iRefIndex)->getLayerId() );
     4221        UInt refLayerId = pcSlice->getRefPic(RefPicList(iRefList), iRefIndex)->getLayerId();
     4222        UInt refLayerIdc = pcSlice->getReferenceLayerIdc(refLayerId);
     4223        assert( g_posScalingFactor[refLayerIdc][0] );
     4224        assert( g_posScalingFactor[refLayerIdc][1] );
     4225
     4226        printf( "%d(%d, {%1.2f, %1.2f}x)", pcSlice->getRefPOC(RefPicList(iRefList), iRefIndex), refLayerId, 65536.0/g_posScalingFactor[refLayerIdc][0], 65536.0/g_posScalingFactor[refLayerIdc][1] );
    40934227#else
    40944228        printf( "%d(%d)", pcSlice->getRefPOC(RefPicList(iRefList), iRefIndex)-pcSlice->getLastIDR(), pcSlice->getRefPic(RefPicList(iRefList), iRefIndex)->getLayerId() );
     
    41204254  if( m_layerId && pcSlice->getPPS()->getCGSFlag() )
    41214255  {
     4256#if R0179_ENC_OPT_3DLUT_SIZE
     4257      m_Enc3DAsymLUTPicUpdate.update3DAsymLUTParam( &m_Enc3DAsymLUTPPS );
     4258#else
     4259    if( m_Enc3DAsymLUTPPS.getPPSBit() > 0 )
     4260      m_Enc3DAsymLUTPicUpdate.copy3DAsymLUT( &m_Enc3DAsymLUTPPS );
     4261#endif
    41224262    m_Enc3DAsymLUTPicUpdate.updatePicCGSBits( pcSlice , m_Enc3DAsymLUTPPS.getPPSBit() );
    41234263  }
     
    47714911
    47724912#if O0164_MULTI_LAYER_HRD
     4913#if VPS_VUI_BSP_HRD_PARAMS
     4914SEIScalableNesting* TEncGOP::xCreateBspNestingSEI(TComSlice *pcSlice, Int olsIdx, Int partitioningSchemeIdx, Int bspIdx)
     4915#else
    47734916SEIScalableNesting* TEncGOP::xCreateBspNestingSEI(TComSlice *pcSlice)
     4917#endif
    47744918{
    47754919  SEIScalableNesting *seiScalableNesting = new SEIScalableNesting();
     
    47844928  seiScalableNesting->m_defaultOpFlag                 = 0;
    47854929  seiScalableNesting->m_nestingNumOpsMinus1           = 0;      //nesting_num_ops_minus1
     4930#if VPS_VUI_BSP_HRD_PARAMS
     4931  seiScalableNesting->m_nestingOpIdx[0]               = pcSlice->getVPS()->getOutputLayerSetIdx(olsIdx);
     4932  seiScalableNesting->m_nestingMaxTemporalIdPlus1[0]  = 6 + 1;
     4933#else
    47864934  seiScalableNesting->m_nestingOpIdx[0]               = 1;
     4935#endif
    47874936  seiScalableNesting->m_allLayersFlag                 = 0;
    47884937  seiScalableNesting->m_nestingNoOpMaxTemporalIdPlus1 = 6 + 1;  //nesting_no_op_max_temporal_id_plus1
     
    48304979  seiBspNesting->m_nestedSEIs.push_back(seiBufferingPeriod);
    48314980  seiBspNesting->m_nestedSEIs.push_back(seiBspInitialArrivalTime);
     4981#if VPS_VUI_BSP_HRD_PARAMS
     4982  seiBspNesting->m_bspIdx = bspIdx;
     4983  seiBspNesting->m_seiOlsIdx = olsIdx;
     4984  seiBspNesting->m_seiPartitioningSchemeIdx = partitioningSchemeIdx;
     4985#endif
    48324986  seiScalableNesting->m_nestedSEIs.push_back(seiBspNesting); // BSP nesting SEI is contained in scalable nesting SEI
    48334987
     
    48424996  m_Enc3DAsymLUTPPS.setPPSBit( 0 );
    48434997  Double dErrorUpdatedPPS = 0 , dErrorPPS = 0;
    4844   dErrorUpdatedPPS = m_Enc3DAsymLUTPicUpdate.derive3DAsymLUT( pSlice , pCurPic , refLayerIdc , pCfg , bSignalPPS , m_pcEncTop->getElRapSliceTypeB() );
     4998
     4999#if R0179_ENC_OPT_3DLUT_SIZE
     5000  Int nTLthres = m_pcCfg->getCGSLutSizeRDO() ? 2:7;
     5001  Double dFrameLambda;
     5002#if FULL_NBIT
     5003  Int    SHIFT_QP = 12 + 6 * (pSlice->getBitDepthY() - 8);
     5004#else
     5005  Int    SHIFT_QP = 12;
     5006#endif
     5007  Int QP = pSlice->getSliceQp();
     5008
     5009  // set frame lambda
     5010  dFrameLambda = 0.68 * pow (2, (QP  - SHIFT_QP) / 3.0) * (m_pcCfg->getGOPSize() > 1 && pSlice->isInterB()? 2 : 1);
     5011
     5012  if(m_pcCfg->getCGSLutSizeRDO() == 1 && (!bSignalPPS && (pSlice->getDepth() < nTLthres)))
     5013    dErrorUpdatedPPS = m_Enc3DAsymLUTPicUpdate.derive3DAsymLUT( pSlice , pCurPic , refLayerIdc , pCfg , bSignalPPS , m_pcEncTop->getElRapSliceTypeB(), dFrameLambda );
     5014  else if (pSlice->getDepth() >= nTLthres)
     5015    dErrorUpdatedPPS = MAX_DOUBLE;
     5016  else // if (m_pcCfg->getCGSLutSizeRDO() = 0 || bSignalPPS)
     5017#endif   
     5018    dErrorUpdatedPPS = m_Enc3DAsymLUTPicUpdate.derive3DAsymLUT( pSlice , pCurPic , refLayerIdc , pCfg , bSignalPPS , m_pcEncTop->getElRapSliceTypeB() );
     5019
     5020
    48455021  if( bSignalPPS )
    48465022  {
     
    48505026  else if( nCGSFlag )
    48515027  {
    4852     dErrorPPS = m_Enc3DAsymLUTPPS.estimateDistWithCur3DAsymLUT( pCurPic , refLayerIdc );
    4853     Double dFactor = pCfg->getIntraPeriod() == 1 ? 0.99 : 0.9;
    4854     pSlice->setCGSOverWritePPS( dErrorUpdatedPPS < dFactor * dErrorPPS );
     5028#if R0179_ENC_OPT_3DLUT_SIZE
     5029    if(pSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_R || pSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N)
     5030    {
     5031      pSlice->setCGSOverWritePPS( 0 );
     5032    }
     5033    else if (pSlice->getDepth() >= nTLthres)
     5034    {
     5035      pSlice->setCGSOverWritePPS( 0 );
     5036    }
     5037    else
     5038    {
     5039#endif   
     5040      dErrorPPS = m_Enc3DAsymLUTPPS.estimateDistWithCur3DAsymLUT( pCurPic , refLayerIdc );
     5041      Double dFactor = pCfg->getIntraPeriod() == 1 ? 0.99 : 0.9;
     5042
     5043#if R0179_ENC_OPT_3DLUT_SIZE
     5044      if( m_pcCfg->getCGSLutSizeRDO() )
     5045      {
     5046        dErrorPPS = dErrorPPS/m_Enc3DAsymLUTPicUpdate.getDistFactor(pSlice->getSliceType(), pSlice->getDepth());
     5047      }
     5048#endif
     5049      pSlice->setCGSOverWritePPS( dErrorUpdatedPPS < dFactor * dErrorPPS );
     5050#if R0179_ENC_OPT_3DLUT_SIZE
     5051    }
     5052#endif
    48555053    if( pSlice->getCGSOverWritePPS() )
    48565054    {
  • trunk/source/Lib/TLibEncoder/TEncGOP.h

    r815 r906  
    207207protected:
    208208 
    209   Void xInitGOP( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut, Bool isField );
    210   Void  xInitGOP          ( Int iPOC, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut );
    211   Void  xGetBuffer        ( TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut, Int iNumPicRcvd, Int iTimeOffset, TComPic*& rpcPic, TComPicYuv*& rpcPicYuvRecOut, Int pocCurr, Bool isField );
     209  Void  xInitGOP          ( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut, bool isField );
     210  Void  xGetBuffer        ( TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut, Int iNumPicRcvd, Int iTimeOffset, TComPic*& rpcPic, TComPicYuv*& rpcPicYuvRecOut, Int pocCurr, bool isField );
    212211 
    213212  Void  xCalculateAddPSNR ( TComPic* pcPic, TComPicYuv* pcPicD, const AccessUnit&, Double dEncTime );
     
    226225  SEIKneeFunctionInfo*    xCreateSEIKneeFunctionInfo();
    227226#endif
    228 #if Q0074_SEI_COLOR_MAPPING
    229   SEIColorMappingInfo*    xCreateSEIColorMappingInfo( Char* file );
     227#if Q0074_COLOUR_REMAPPING_SEI
     228  SEIColourRemappingInfo* xCreateSEIColourRemappingInfo();
    230229#endif
    231230
     
    254253#endif
    255254#if O0164_MULTI_LAYER_HRD
     255#if VPS_VUI_BSP_HRD_PARAMS
     256  SEIScalableNesting* xCreateBspNestingSEI(TComSlice *pcSlice, Int olsIdx, Int partitioningSchemeIdx, Int bspIdx);
     257#else
    256258  SEIScalableNesting* xCreateBspNestingSEI(TComSlice *pcSlice);
     259#endif
    257260#endif
    258261#if Q0048_CGS_3D_ASYMLUT
  • trunk/source/Lib/TLibEncoder/TEncSearch.cpp

    r815 r906  
    48964896    if( bCodeChroma )
    48974897    {
     4898      m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[ uiDepth ][ CI_QT_TRAFO_ROOT ] );
     4899      m_pcEntropyCoder->resetBits();
    48984900      m_pcEntropyCoder->encodeQtCbf   ( pcCU, uiAbsPartIdx, TEXT_CHROMA_U, uiTrMode );
    48994901      m_pcEntropyCoder->encodeCoeffNxN( pcCU, pcCoeffCurrU, uiAbsPartIdx, trWidthC, trHeightC, uiDepth, TEXT_CHROMA_U );
    4900       uiSingleBitsU = m_pcEntropyCoder->getNumberOfWrittenBits() - uiSingleBitsY;
     4902      uiSingleBitsU = m_pcEntropyCoder->getNumberOfWrittenBits();
    49014903     
     4904      m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[ uiDepth ][ CI_QT_TRAFO_ROOT ] );
     4905      m_pcEntropyCoder->resetBits();
    49024906      m_pcEntropyCoder->encodeQtCbf   ( pcCU, uiAbsPartIdx, TEXT_CHROMA_V, uiTrMode );
    49034907      m_pcEntropyCoder->encodeCoeffNxN( pcCU, pcCoeffCurrV, uiAbsPartIdx, trWidthC, trHeightC, uiDepth, TEXT_CHROMA_V );
    4904       uiSingleBitsV = m_pcEntropyCoder->getNumberOfWrittenBits() - ( uiSingleBitsY + uiSingleBitsU );
     4908      uiSingleBitsV = m_pcEntropyCoder->getNumberOfWrittenBits();
    49054909    }
    49064910   
     
    49394943      {
    49404944        const Double singleCostY = m_pcRdCost->calcRdCost( uiSingleBitsY, uiNonzeroDistY );
     4945        m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[ uiDepth ][ CI_QT_TRAFO_ROOT ] );
    49414946        m_pcEntropyCoder->resetBits();
    49424947        m_pcEntropyCoder->encodeQtCbfZero( pcCU, TEXT_LUMA,     uiTrMode );
     
    49644969    else if( checkTransformSkipY )
    49654970    {
     4971      m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[ uiDepth ][ CI_QT_TRAFO_ROOT ] );
    49664972      m_pcEntropyCoder->resetBits();
    49674973      m_pcEntropyCoder->encodeQtCbfZero( pcCU, TEXT_LUMA, uiTrMode );
     
    50155021        {
    50165022          const Double dSingleCostU = m_pcRdCost->calcRdCost( uiSingleBitsU, uiNonzeroDistU );
     5023          m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[ uiDepth ][ CI_QT_TRAFO_ROOT ] );
    50175024          m_pcEntropyCoder->resetBits();
    50185025          m_pcEntropyCoder->encodeQtCbfZero( pcCU, TEXT_CHROMA_U,     uiTrMode );
     
    50405047      else if( checkTransformSkipUV )
    50415048      {
     5049        m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[ uiDepth ][ CI_QT_TRAFO_ROOT ] );
    50425050        m_pcEntropyCoder->resetBits();
    50435051        m_pcEntropyCoder->encodeQtCbfZero( pcCU, TEXT_CHROMA_U, uiTrMode );
     
    50845092        {
    50855093          const Double dSingleCostV = m_pcRdCost->calcRdCost( uiSingleBitsV, uiNonzeroDistV );
     5094          m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[ uiDepth ][ CI_QT_TRAFO_ROOT ] );
    50865095          m_pcEntropyCoder->resetBits();
    50875096          m_pcEntropyCoder->encodeQtCbfZero( pcCU, TEXT_CHROMA_V,     uiTrMode );
     
    51095118      else if( checkTransformSkipUV )
    51105119      {
     5120        m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[ uiDepth ][ CI_QT_TRAFO_ROOT ] );
    51115121        m_pcEntropyCoder->resetBits();
    51125122        m_pcEntropyCoder->encodeQtCbfZero( pcCU, TEXT_CHROMA_V, uiTrMode );
     
    52875297      pcCU->setCbfSubParts( uiAbsSumTransformSkipV ? uiSetCbf : 0, TEXT_CHROMA_V, uiAbsPartIdx, pcCU->getDepth(0)+uiTrModeC );
    52885298
    5289       m_pcEntropyCoder->resetBits();
    52905299      uiSingleBitsU = 0;
    52915300      uiSingleBitsV = 0;
     
    52935302      if( uiAbsSumTransformSkipU )
    52945303      {
     5304        m_pcEntropyCoder->resetBits();
    52955305        m_pcEntropyCoder->encodeQtCbf   ( pcCU, uiAbsPartIdx, TEXT_CHROMA_U, uiTrMode );
    52965306        m_pcEntropyCoder->encodeCoeffNxN( pcCU, pcCoeffCurrU, uiAbsPartIdx, trWidthC, trHeightC, uiDepth, TEXT_CHROMA_U );
     
    53355345      if( uiAbsSumTransformSkipV )
    53365346      {
     5347        m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[ uiDepth ][ CI_QT_TRAFO_ROOT ] );
     5348        m_pcEntropyCoder->resetBits();
    53375349        m_pcEntropyCoder->encodeQtCbf   ( pcCU, uiAbsPartIdx, TEXT_CHROMA_V, uiTrMode );
    53385350        m_pcEntropyCoder->encodeCoeffNxN( pcCU, pcCoeffCurrV, uiAbsPartIdx, trWidthC, trHeightC, uiDepth, TEXT_CHROMA_V );
    5339         uiSingleBitsV = m_pcEntropyCoder->getNumberOfWrittenBits() - uiSingleBitsU;
     5351        uiSingleBitsV = m_pcEntropyCoder->getNumberOfWrittenBits();
    53405352
    53415353        curChromaQpOffset = pcCU->getSlice()->getPPS()->getChromaCrQpOffset() + pcCU->getSlice()->getSliceQpDeltaCr();
  • trunk/source/Lib/TLibEncoder/TEncSlice.cpp

    r713 r906  
    836836Void TEncSlice::compressSlice( TComPic*& rpcPic )
    837837{
     838#if !WPP_FIX
    838839  UInt  uiCUAddr;
     840#endif
    839841  UInt   uiStartCUAddr;
    840842  UInt   uiBoundingCUAddr;
     
    907909  TEncSbac**** ppppcRDSbacCoders    = pcEncTop->getRDSbacCoders();
    908910  TComBitCounter* pcBitCounters     = pcEncTop->getBitCounters();
     911#if WPP_FIX
     912  const Int  iNumSubstreams = pcSlice->getPPS()->getNumSubstreams();
     913  const UInt uiTilesAcross  = rpcPic->getPicSym()->getNumColumnsMinus1()+1;
     914#else
    909915  Int  iNumSubstreams = 1;
    910916  UInt uiTilesAcross  = 0;
     
    912918  iNumSubstreams = pcSlice->getPPS()->getNumSubstreams();
    913919  uiTilesAcross = rpcPic->getPicSym()->getNumColumnsMinus1()+1;
     920#endif
    914921  delete[] m_pcBufferSbacCoders;
    915922  delete[] m_pcBufferBinCoderCABACs;
     
    943950  UInt uiWidthInLCUs  = rpcPic->getPicSym()->getFrameWidthInCU();
    944951  //UInt uiHeightInLCUs = rpcPic->getPicSym()->getFrameHeightInCU();
     952#if WPP_FIX
     953  UInt      uiTileCol               = 0;
     954  Bool      depSliceSegmentsEnabled = pcSlice->getPPS()->getDependentSliceSegmentsEnabledFlag();
     955  UInt      uiCUAddr                = rpcPic->getPicSym()->getCUOrderMap( uiStartCUAddr /rpcPic->getNumPartInCU());
     956  UInt      currentTileIdx          = rpcPic->getPicSym()->getTileIdxMap(uiCUAddr);
     957  TComTile *pCurrentTile            = rpcPic->getPicSym()->getTComTile(currentTileIdx);
     958  UInt      uiTileStartLCU          = pCurrentTile->getFirstCUAddr();
     959#else
    945960  UInt uiCol=0, uiLin=0, uiSubStrm=0;
    946961  UInt uiTileCol      = 0;
     
    950965  uiCUAddr = rpcPic->getPicSym()->getCUOrderMap( uiStartCUAddr /rpcPic->getNumPartInCU());
    951966  uiTileStartLCU = rpcPic->getPicSym()->getTComTile(rpcPic->getPicSym()->getTileIdxMap(uiCUAddr))->getFirstCUAddr();
     967#endif
    952968  if( depSliceSegmentsEnabled )
    953969  {
    954970    if((pcSlice->getSliceSegmentCurStartCUAddr()!= pcSlice->getSliceCurStartCUAddr())&&(uiCUAddr != uiTileStartLCU))
    955971    {
     972#if WPP_FIX
     973      UInt uiSubStrm=0;
     974#endif
    956975      if( m_pcCfg->getWaveFrontsynchro() )
    957976      {
     977#if WPP_FIX
     978        uiTileCol = currentTileIdx % (rpcPic->getPicSym()->getNumColumnsMinus1()+1);
     979         m_pcBufferSbacCoders[uiTileCol].loadContexts( CTXMem[1] );
     980         //uiCUAddr = rpcPic->getPicSym()->getCUOrderMap( uiStartCUAddr /rpcPic->getNumPartInCU());
     981         uiSubStrm=rpcPic->getSubstreamForLCUAddr(uiCUAddr, true, pcSlice);
     982         if ( pCurrentTile->getTileWidth() < 2)
     983         {
     984           CTXMem[0]->loadContexts(m_pcSbacCoder);
     985         }
     986#else
    958987        uiTileCol = rpcPic->getPicSym()->getTileIdxMap(uiCUAddr) % (rpcPic->getPicSym()->getNumColumnsMinus1()+1);
    959988        m_pcBufferSbacCoders[uiTileCol].loadContexts( CTXMem[1] );
     
    9721001          }
    9731002        }
     1003#endif
    9741004      }
    9751005      m_pppcRDSbacCoder[0][CI_CURR_BEST]->loadContexts( CTXMem[0] );
     
    9981028    uiTileCol = rpcPic->getPicSym()->getTileIdxMap(uiCUAddr) % (rpcPic->getPicSym()->getNumColumnsMinus1()+1); // what column of tiles are we in?
    9991029    uiTileStartLCU = rpcPic->getPicSym()->getTComTile(rpcPic->getPicSym()->getTileIdxMap(uiCUAddr))->getFirstCUAddr();
     1030#if WPP_FIX
     1031    UInt uiTileLCUX = uiTileStartLCU % uiWidthInLCUs;
     1032    //UInt uiSliceStartLCU = pcSlice->getSliceCurStartCUAddr();
     1033    UInt uiCol     = uiCUAddr % uiWidthInLCUs;
     1034    UInt uiSubStrm=rpcPic->getSubstreamForLCUAddr(uiCUAddr, true, pcSlice);
     1035
     1036    if ( ((iNumSubstreams > 1) || depSliceSegmentsEnabled ) && (uiCol == uiTileLCUX) && m_pcCfg->getWaveFrontsynchro())
     1037#else
    10001038    uiTileLCUX = uiTileStartLCU % uiWidthInLCUs;
    10011039    //UInt uiSliceStartLCU = pcSlice->getSliceCurStartCUAddr();
     
    10151053    }
    10161054    if ( ((pcSlice->getPPS()->getNumSubstreams() > 1) || depSliceSegmentsEnabled ) && (uiCol == uiTileLCUX) && m_pcCfg->getWaveFrontsynchro())
     1055#endif
    10171056    {
    10181057      // We'll sync if the TR is available.
     
    11381177    ppppcRDSbacCoders[uiSubStrm][0][CI_CURR_BEST]->load( m_pppcRDSbacCoder[0][CI_CURR_BEST] );
    11391178    //Store probabilties of second LCU in line into buffer
     1179#if WPP_FIX
     1180    if ( ( uiCol == uiTileLCUX+1) && (depSliceSegmentsEnabled || (iNumSubstreams > 1)) && m_pcCfg->getWaveFrontsynchro())
     1181#else
    11401182    if ( ( uiCol == uiTileLCUX+1) && (depSliceSegmentsEnabled || (pcSlice->getPPS()->getNumSubstreams() > 1)) && m_pcCfg->getWaveFrontsynchro())
     1183#endif
    11411184    {
    11421185      m_pcBufferSbacCoders[uiTileCol].loadContexts(ppppcRDSbacCoders[uiSubStrm][0][CI_CURR_BEST]);
     
    11771220    m_uiPicDist      += pcCU->getTotalDistortion();
    11781221  }
     1222#if WPP_FIX
     1223  if ((iNumSubstreams > 1) && !depSliceSegmentsEnabled)
     1224#else
    11791225  if ((pcSlice->getPPS()->getNumSubstreams() > 1) && !depSliceSegmentsEnabled)
     1226#endif
    11801227  {
    11811228    pcSlice->setNextSlice( true );
     
    12391286  TEncTop* pcEncTop = (TEncTop*) m_pcCfg;
    12401287  TEncSbac* pcSbacCoders = pcEncTop->getSbacCoders(); //coder for each substream
     1288#if WPP_FIX
     1289  const Int iNumSubstreams = pcSlice->getPPS()->getNumSubstreams();
     1290#else
    12411291  Int iNumSubstreams = pcSlice->getPPS()->getNumSubstreams();
     1292#endif
    12421293  UInt uiBitsOriginallyInSubstreams = 0;
    12431294  {
     
    12601311
    12611312  UInt uiWidthInLCUs  = rpcPic->getPicSym()->getFrameWidthInCU();
     1313#if WPP_FIX
     1314  UInt uiCol=0, uiSubStrm=0;
     1315#else
    12621316  UInt uiCol=0, uiLin=0, uiSubStrm=0;
     1317#endif
    12631318  UInt uiTileCol      = 0;
    12641319  UInt uiTileStartLCU = 0;
     
    12681323                                                                                               an encoding order index, so we need to convert the index (uiStartCUAddr)
    12691324                                                                                               into the real raster scan address (uiCUAddr) via the CUOrderMap */
     1325#if WPP_FIX
     1326  UInt currentTileIdx=rpcPic->getPicSym()->getTileIdxMap(uiCUAddr);
     1327  TComTile *pCurrentTile=rpcPic->getPicSym()->getTComTile(currentTileIdx);
     1328  uiTileStartLCU = pCurrentTile->getFirstCUAddr();
     1329#else
    12701330  uiTileStartLCU = rpcPic->getPicSym()->getTComTile(rpcPic->getPicSym()->getTileIdxMap(uiCUAddr))->getFirstCUAddr();
     1331#endif
    12711332  if( depSliceSegmentsEnabled )
    12721333  {
     1334#if WPP_FIX
     1335    if( pcSlice->isNextSlice()|| uiCUAddr == uiTileStartLCU)
     1336#else
    12731337    if( pcSlice->isNextSlice()||
    12741338        uiCUAddr == rpcPic->getPicSym()->getTComTile(rpcPic->getPicSym()->getTileIdxMap(uiCUAddr))->getFirstCUAddr())
     1339#endif
    12751340    {
    12761341      if(m_pcCfg->getWaveFrontsynchro())
     
    12841349      if(m_pcCfg->getWaveFrontsynchro())
    12851350      {
     1351#if WPP_FIX
     1352        uiTileCol = currentTileIdx % (rpcPic->getPicSym()->getNumColumnsMinus1()+1);
     1353#else
    12861354        uiTileCol = rpcPic->getPicSym()->getTileIdxMap(uiCUAddr) % (rpcPic->getPicSym()->getNumColumnsMinus1()+1);
     1355#endif
    12871356        m_pcBufferSbacCoders[uiTileCol].loadContexts( CTXMem[1] );
     1357#if WPP_FIX
     1358        uiCUAddr = rpcPic->getPicSym()->getCUOrderMap( uiStartCUAddr /rpcPic->getNumPartInCU());
     1359        uiSubStrm=rpcPic->getSubstreamForLCUAddr(uiCUAddr, true, pcSlice);
     1360        if ( pCurrentTile->getTileWidth() < 2)
     1361        {
     1362          CTXMem[0]->loadContexts(m_pcSbacCoder);
     1363        }
     1364#else
    12881365        Int iNumSubstreamsPerTile = iNumSubstreams/rpcPic->getPicSym()->getNumTiles();
    12891366        uiLin     = uiCUAddr / uiWidthInLCUs;
     
    12991376          }
    13001377        }
     1378#endif
    13011379      }
    13021380      pcSbacCoders[uiSubStrm].loadContexts( CTXMem[0] );
     
    13141392    //UInt uiSliceStartLCU = pcSlice->getSliceCurStartCUAddr();
    13151393    uiCol     = uiCUAddr % uiWidthInLCUs;
     1394#if WPP_FIX
     1395    uiSubStrm=rpcPic->getSubstreamForLCUAddr(uiCUAddr, true, pcSlice);
     1396#else
    13161397    uiLin     = uiCUAddr / uiWidthInLCUs;
    13171398    if (pcSlice->getPPS()->getNumSubstreams() > 1)
     
    13271408      uiSubStrm = uiLin % iNumSubstreams;
    13281409    }
     1410#endif
    13291411
    13301412    m_pcEntropyCoder->setBitstream( &pcSubstreams[uiSubStrm] );
    13311413    // Synchronize cabac probabilities with upper-right LCU if it's available and we're at the start of a line.
     1414#if WPP_FIX
     1415    if (((iNumSubstreams > 1) || depSliceSegmentsEnabled) && (uiCol == uiTileLCUX) && m_pcCfg->getWaveFrontsynchro())
     1416#else
    13321417    if (((pcSlice->getPPS()->getNumSubstreams() > 1) || depSliceSegmentsEnabled) && (uiCol == uiTileLCUX) && m_pcCfg->getWaveFrontsynchro())
     1418#endif
    13331419    {
    13341420      // We'll sync if the TR is available.
     
    13681454        // When tiles are independent, we have "substreams per tile".  Each substream has already been terminated, and we no longer
    13691455        // have to perform it here.
     1456#if WPP_FIX
     1457        if (iNumSubstreams <= 1)
     1458#else
    13701459        if (pcSlice->getPPS()->getNumSubstreams() > 1)
    13711460        {
     
    13731462        }
    13741463        else
     1464#endif
    13751465        {
    13761466          SliceType sliceType  = pcSlice->getSliceType();
     
    14481538    pcSbacCoders[uiSubStrm].load(m_pcSbacCoder);   //load back status of the entropy coder after encoding the LCU into relevant bitstream entropy coder
    14491539    //Store probabilties of second LCU in line into buffer
     1540#if WPP_FIX
     1541    if ( (depSliceSegmentsEnabled || (iNumSubstreams > 1)) && (uiCol == uiTileLCUX+1) && m_pcCfg->getWaveFrontsynchro())
     1542#else
    14501543    if ( (depSliceSegmentsEnabled || (pcSlice->getPPS()->getNumSubstreams() > 1)) && (uiCol == uiTileLCUX+1) && m_pcCfg->getWaveFrontsynchro())
     1544#endif
    14511545    {
    14521546      m_pcBufferSbacCoders[uiTileCol].loadContexts( &pcSbacCoders[uiSubStrm] );
     
    14801574}
    14811575
     1576#if WPP_FIX
     1577Void TEncSlice::calculateBoundingCUAddrForSlice(UInt &uiStartCUAddrSlice, UInt &uiBoundingCUAddrSlice, Bool &bReachedTileBoundary, TComPic*& rpcPic, Bool bEncodeSlice, Int sliceMode, Int sliceArgument, UInt uiSliceCurEndCUAddr)
     1578{
     1579  TComSlice* pcSlice = rpcPic->getSlice(getSliceIdx());
     1580  UInt uiNumberOfCUsInFrame = rpcPic->getNumCUsInFrame();
     1581  const UInt scaleCUAddr = rpcPic->getNumPartInCU(); // due to fine granularity slices all addresses are scaled.
     1582  uiBoundingCUAddrSlice=0;
     1583  bReachedTileBoundary=false;
     1584
     1585  switch (sliceMode)
     1586  {
     1587  case FIXED_NUMBER_OF_LCU:
     1588    {
     1589      UInt uiCUAddrIncrement    = sliceArgument;
     1590      uiBoundingCUAddrSlice     = ((uiStartCUAddrSlice + uiCUAddrIncrement) < uiNumberOfCUsInFrame*scaleCUAddr) ? (uiStartCUAddrSlice + uiCUAddrIncrement) : uiNumberOfCUsInFrame*scaleCUAddr;
     1591    }
     1592    break;
     1593  case FIXED_NUMBER_OF_BYTES:
     1594    if (bEncodeSlice)
     1595      uiBoundingCUAddrSlice     = uiSliceCurEndCUAddr;
     1596    else
     1597      uiBoundingCUAddrSlice     = uiNumberOfCUsInFrame*scaleCUAddr;
     1598    break;
     1599  case FIXED_NUMBER_OF_TILES:
     1600    {
     1601      UInt tileIdx              = rpcPic->getPicSym()->getTileIdxMap( rpcPic->getPicSym()->getCUOrderMap(uiStartCUAddrSlice/scaleCUAddr) );
     1602      UInt uiCUAddrIncrement    = 0;
     1603      UInt tileTotalCount       = (rpcPic->getPicSym()->getNumColumnsMinus1()+1) * (rpcPic->getPicSym()->getNumRowsMinus1()+1);
     1604
     1605      for(UInt tileIdxIncrement = 0; tileIdxIncrement < sliceArgument; tileIdxIncrement++)
     1606      {
     1607        if((tileIdx + tileIdxIncrement) < tileTotalCount)
     1608        {
     1609          UInt tileWidthInLcu   = rpcPic->getPicSym()->getTComTile(tileIdx + tileIdxIncrement)->getTileWidth();
     1610          UInt tileHeightInLcu  = rpcPic->getPicSym()->getTComTile(tileIdx + tileIdxIncrement)->getTileHeight();
     1611          uiCUAddrIncrement    += (tileWidthInLcu * tileHeightInLcu * scaleCUAddr);
     1612        }
     1613      }
     1614
     1615      uiBoundingCUAddrSlice     = ((uiStartCUAddrSlice + uiCUAddrIncrement) < uiNumberOfCUsInFrame*scaleCUAddr) ? (uiStartCUAddrSlice + uiCUAddrIncrement) : uiNumberOfCUsInFrame*scaleCUAddr;
     1616    }
     1617    break;
     1618  default:
     1619    uiBoundingCUAddrSlice       = uiNumberOfCUsInFrame*scaleCUAddr;
     1620    break;
     1621  }
     1622
     1623  // Adjust for tiles and wavefronts.
     1624  if ((sliceMode == FIXED_NUMBER_OF_LCU || sliceMode == FIXED_NUMBER_OF_BYTES) &&
     1625    (m_pcCfg->getNumRowsMinus1() > 0 || m_pcCfg->getNumColumnsMinus1() > 0))
     1626  {
     1627    const UInt lcuEncAddrStart = (uiStartCUAddrSlice+scaleCUAddr-1)/scaleCUAddr;
     1628    const UInt lcuAddr = rpcPic->getPicSym()->getCUOrderMap(lcuEncAddrStart);
     1629    const UInt startTileIdx = rpcPic->getPicSym()->getTileIdxMap(lcuAddr);
     1630    const Bool bWavefrontsEnabled = m_pcCfg->getWaveFrontsynchro();
     1631
     1632    TComTile *pStartingTile = rpcPic->getPicSym()->getTComTile(startTileIdx);
     1633    const UInt uiTileStartLCUEncAddr      = rpcPic->getPicSym()->getInverseCUOrderMap(pStartingTile->getFirstCUAddr());
     1634    const UInt uiTileStartWidth           = pStartingTile->getTileWidth();
     1635    const UInt uiTileStartHeight          = pStartingTile->getTileHeight();
     1636    const UInt uiTileLastLCUEncAddr_excl  = uiTileStartLCUEncAddr + uiTileStartWidth*uiTileStartHeight;
     1637    const UInt tileBoundingCUAddrSlice    = uiTileLastLCUEncAddr_excl * scaleCUAddr;
     1638
     1639    const UInt lcuColumnOfStartingTile=((lcuEncAddrStart-uiTileStartLCUEncAddr)%uiTileStartWidth);
     1640    if (bWavefrontsEnabled && lcuColumnOfStartingTile!=0)
     1641    {
     1642      // WPP: if a slice does not start at the beginning of a CTB row, it must end within the same CTB row
     1643      const UInt numberOfLCUsToEndOfRow=uiTileStartWidth-lcuColumnOfStartingTile;
     1644      const UInt wavefrontTileBoundingCUAddrSlice = (lcuEncAddrStart+numberOfLCUsToEndOfRow)*scaleCUAddr;
     1645      if (wavefrontTileBoundingCUAddrSlice < uiBoundingCUAddrSlice)
     1646      {
     1647        uiBoundingCUAddrSlice = wavefrontTileBoundingCUAddrSlice;
     1648      }
     1649    }
     1650
     1651    if (tileBoundingCUAddrSlice < uiBoundingCUAddrSlice)
     1652    {
     1653      uiBoundingCUAddrSlice = tileBoundingCUAddrSlice;
     1654      bReachedTileBoundary = true;
     1655    }
     1656  }
     1657  else if (pcSlice->getPPS()->getNumSubstreams() > 1 && (uiStartCUAddrSlice % (rpcPic->getFrameWidthInCU()*scaleCUAddr) != 0))
     1658  {
     1659    // WPP: if a slice does not start at the beginning of a CTB row, it must end within the same CTB row
     1660    uiBoundingCUAddrSlice = min(uiBoundingCUAddrSlice, uiStartCUAddrSlice - (uiStartCUAddrSlice % (rpcPic->getFrameWidthInCU()*scaleCUAddr)) + (rpcPic->getFrameWidthInCU()*scaleCUAddr));
     1661  }
     1662
     1663  //calculate real slice start address (fine granularity slices)
     1664  {
     1665    UInt uiInternalAddress = rpcPic->getPicSym()->getPicSCUAddr(uiStartCUAddrSlice) % scaleCUAddr;
     1666    UInt uiExternalAddress = rpcPic->getPicSym()->getPicSCUAddr(uiStartCUAddrSlice) / scaleCUAddr;
     1667    UInt uiPosX = ( uiExternalAddress % rpcPic->getFrameWidthInCU() ) * g_uiMaxCUWidth+ g_auiRasterToPelX[ g_auiZscanToRaster[uiInternalAddress] ];
     1668    UInt uiPosY = ( uiExternalAddress / rpcPic->getFrameWidthInCU() ) * g_uiMaxCUHeight+ g_auiRasterToPelY[ g_auiZscanToRaster[uiInternalAddress] ];
     1669#if REPN_FORMAT_IN_VPS
     1670    UInt uiWidth = pcSlice->getPicWidthInLumaSamples();
     1671    UInt uiHeight = pcSlice->getPicHeightInLumaSamples();
     1672#else
     1673    UInt uiWidth = pcSlice->getSPS()->getPicWidthInLumaSamples();
     1674    UInt uiHeight = pcSlice->getSPS()->getPicHeightInLumaSamples();
     1675#endif
     1676    while((uiPosX>=uiWidth||uiPosY>=uiHeight)&&!(uiPosX>=uiWidth&&uiPosY>=uiHeight))
     1677    {
     1678      uiInternalAddress++;
     1679      if(uiInternalAddress>=scaleCUAddr)
     1680      {
     1681        uiInternalAddress=0;
     1682        uiExternalAddress = rpcPic->getPicSym()->getCUOrderMap(rpcPic->getPicSym()->getInverseCUOrderMap(uiExternalAddress)+1);
     1683      }
     1684      uiPosX = ( uiExternalAddress % rpcPic->getFrameWidthInCU() ) * g_uiMaxCUWidth+ g_auiRasterToPelX[ g_auiZscanToRaster[uiInternalAddress] ];
     1685      uiPosY = ( uiExternalAddress / rpcPic->getFrameWidthInCU() ) * g_uiMaxCUHeight+ g_auiRasterToPelY[ g_auiZscanToRaster[uiInternalAddress] ];
     1686    }
     1687    UInt uiRealStartAddress = rpcPic->getPicSym()->getPicSCUEncOrder(uiExternalAddress*scaleCUAddr+uiInternalAddress);
     1688
     1689    uiStartCUAddrSlice=uiRealStartAddress;
     1690  }
     1691}
     1692
     1693/** Determines the starting and bounding LCU address of current slice / dependent slice
     1694* \param bEncodeSlice Identifies if the calling function is compressSlice() [false] or encodeSlice() [true]
     1695* \returns Updates uiStartCUAddr, uiBoundingCUAddr with appropriate LCU address
     1696*/
     1697Void TEncSlice::xDetermineStartAndBoundingCUAddr  ( UInt& startCUAddr, UInt& boundingCUAddr, TComPic*& rpcPic, Bool bEncodeSlice )
     1698{
     1699  TComSlice* pcSlice = rpcPic->getSlice(getSliceIdx());
     1700
     1701  // Non-dependent slice
     1702  UInt uiStartCUAddrSlice   = pcSlice->getSliceCurStartCUAddr();
     1703  Bool bTileBoundarySlice   = false;
     1704  UInt uiBoundingCUAddrSlice;
     1705  calculateBoundingCUAddrForSlice(uiStartCUAddrSlice, uiBoundingCUAddrSlice, bTileBoundarySlice, rpcPic, bEncodeSlice, m_pcCfg->getSliceMode(), m_pcCfg->getSliceArgument(), pcSlice->getSliceCurEndCUAddr());
     1706  pcSlice->setSliceCurEndCUAddr( uiBoundingCUAddrSlice );
     1707  pcSlice->setSliceCurStartCUAddr(uiStartCUAddrSlice);
     1708
     1709  // Dependent slice
     1710  UInt startCUAddrSliceSegment    = pcSlice->getSliceSegmentCurStartCUAddr();
     1711  Bool bTileBoundarySliceSegment  = false;
     1712  UInt boundingCUAddrSliceSegment;
     1713  calculateBoundingCUAddrForSlice(startCUAddrSliceSegment, boundingCUAddrSliceSegment, bTileBoundarySliceSegment, rpcPic, bEncodeSlice, m_pcCfg->getSliceSegmentMode(), m_pcCfg->getSliceSegmentArgument(), pcSlice->getSliceSegmentCurEndCUAddr());
     1714  pcSlice->setSliceSegmentCurEndCUAddr( boundingCUAddrSliceSegment );
     1715  pcSlice->setSliceSegmentCurStartCUAddr(startCUAddrSliceSegment);
     1716
     1717  // Make a joint decision based on reconstruction and dependent slice bounds
     1718  startCUAddr    = max(uiStartCUAddrSlice   , startCUAddrSliceSegment   );
     1719  boundingCUAddr = min(uiBoundingCUAddrSlice, boundingCUAddrSliceSegment);
     1720
     1721
     1722  if (!bEncodeSlice)
     1723  {
     1724    // For fixed number of LCU within an entropy and reconstruction slice we already know whether we will encounter end of entropy and/or reconstruction slice
     1725    // first. Set the flags accordingly.
     1726    if ( (m_pcCfg->getSliceMode()==FIXED_NUMBER_OF_LCU && m_pcCfg->getSliceSegmentMode()==FIXED_NUMBER_OF_LCU)
     1727      || (m_pcCfg->getSliceMode()==0 && m_pcCfg->getSliceSegmentMode()==FIXED_NUMBER_OF_LCU)
     1728      || (m_pcCfg->getSliceMode()==FIXED_NUMBER_OF_LCU && m_pcCfg->getSliceSegmentMode()==0)
     1729      || (m_pcCfg->getSliceMode()==FIXED_NUMBER_OF_TILES && m_pcCfg->getSliceSegmentMode()==FIXED_NUMBER_OF_LCU)
     1730      || (m_pcCfg->getSliceMode()==FIXED_NUMBER_OF_TILES && m_pcCfg->getSliceSegmentMode()==0)
     1731      || (m_pcCfg->getSliceSegmentMode()==FIXED_NUMBER_OF_TILES && m_pcCfg->getSliceMode()==0)
     1732      || bTileBoundarySlice || bTileBoundarySliceSegment )
     1733    {
     1734      if (uiBoundingCUAddrSlice < boundingCUAddrSliceSegment)
     1735      {
     1736        pcSlice->setNextSlice       ( true );
     1737        pcSlice->setNextSliceSegment( false );
     1738      }
     1739      else if (uiBoundingCUAddrSlice > boundingCUAddrSliceSegment)
     1740      {
     1741        pcSlice->setNextSlice       ( false );
     1742        pcSlice->setNextSliceSegment( true );
     1743      }
     1744      else
     1745      {
     1746        pcSlice->setNextSlice       ( true );
     1747        pcSlice->setNextSliceSegment( true );
     1748      }
     1749    }
     1750    else
     1751    {
     1752      pcSlice->setNextSlice       ( false );
     1753      pcSlice->setNextSliceSegment( false );
     1754    }
     1755  }
     1756}
     1757#else
    14821758/** Determines the starting and bounding LCU address of current slice / dependent slice
    14831759 * \param bEncodeSlice Identifies if the calling function is compressSlice() [false] or encodeSlice() [true]
     
    18162092  }
    18172093}
     2094#endif
    18182095
    18192096Double TEncSlice::xGetQPValueAccordingToLambda ( Double lambda )
  • trunk/source/Lib/TLibEncoder/TEncSlice.h

    r595 r906  
    150150  Void      setCtxMem( TEncSbac* sb, Int b )   { CTXMem[b] = sb; }
    151151
     152#if WPP_FIX
     153  Void     calculateBoundingCUAddrForSlice(UInt &uiStartCUAddrSlice, UInt &uiBoundingCUAddrSlice, Bool &bReachedTileBoundary, TComPic*& rpcPic, Bool bEncodeSlice, Int sliceMode, Int sliceArgument, UInt uiSliceCurEndCUAddr);
     154#endif
     155
    152156private:
    153157  Double  xGetQPValueAccordingToLambda ( Double lambda );
  • trunk/source/Lib/TLibEncoder/TEncTop.cpp

    r815 r906  
    9898  m_noOutputOfPriorPicsFlags   = false;
    9999#endif
     100#if P0297_VPS_POC_LSB_ALIGNED_FLAG
     101  m_pocDecrementedInDPBFlag    = false;
     102#endif
    100103#endif //SVC_EXTENSION
    101104}
     
    323326  /* set the VPS profile information */
    324327  *m_cVPS.getPTL() = *m_cSPS.getPTL();
     328#if VPS_VUI_BSP_HRD_PARAMS
     329  m_cVPS.getTimingInfo()->setTimingInfoPresentFlag       ( true );
     330#else
    325331  m_cVPS.getTimingInfo()->setTimingInfoPresentFlag       ( false );
     332#endif
    326333  // initialize PPS
    327334  m_cPPS.setSPS(&m_cSPS);
     
    779786        for(UInt i = 0; i < m_cVPS.getNumDirectRefLayers( m_layerId ); i++ )
    780787        {
     788#if MOVE_SCALED_OFFSET_TO_PPS
     789#if O0098_SCALED_REF_LAYER_ID
     790          const Window scalEL = getPPS()->getScaledRefLayerWindowForLayer(m_cVPS.getRefLayerId(m_layerId, i));
     791#else
     792          const Window scalEL = getPPS()->getScaledRefLayerWindow(i);
     793#endif
     794#else
    781795#if O0098_SCALED_REF_LAYER_ID
    782796          const Window scalEL = getSPS()->getScaledRefLayerWindowForLayer(m_cVPS.getRefLayerId(m_layerId, i));
     
    784798          const Window scalEL = getSPS()->getScaledRefLayerWindow(i);
    785799#endif
     800#endif
     801#if REF_REGION_OFFSET
     802          const Window altRL  = getPPS()->getRefLayerWindowForLayer(m_cVPS.getRefLayerId(m_layerId, i));
     803#if RESAMPLING_FIX
     804          Bool equalOffsets = scalEL.hasEqualOffset(altRL);
     805#if R0209_GENERIC_PHASE
     806          Bool zeroPhase = getPPS()->hasZeroResamplingPhase(m_cVPS.getRefLayerId(m_layerId, i));
     807#endif
     808#else
     809          Bool zeroOffsets = ( scalEL.getWindowLeftOffset() == 0 && scalEL.getWindowRightOffset() == 0 && scalEL.getWindowTopOffset() == 0 && scalEL.getWindowBottomOffset() == 0
     810                               && altRL.getWindowLeftOffset() == 0 && altRL.getWindowRightOffset() == 0 && altRL.getWindowTopOffset() == 0 && altRL.getWindowBottomOffset() == 0);
     811#endif
     812#else
    786813          Bool zeroOffsets = ( scalEL.getWindowLeftOffset() == 0 && scalEL.getWindowRightOffset() == 0 && scalEL.getWindowTopOffset() == 0 && scalEL.getWindowBottomOffset() == 0 );
     814#endif
    787815
    788816#if VPS_EXTN_DIRECT_REF_LAYERS
     
    795823          Bool sameBitDepths = ( g_bitDepthYLayer[m_layerId] == g_bitDepthYLayer[refLayerId] ) && ( g_bitDepthCLayer[m_layerId] == g_bitDepthCLayer[refLayerId] );
    796824
    797           if( m_iSourceWidth != pcEncTopBase->getSourceWidth() || m_iSourceHeight != pcEncTopBase->getSourceHeight() || !zeroOffsets || !sameBitDepths
     825#if REF_IDX_MFM
     826          if( m_iSourceWidth == pcEncTopBase->getSourceWidth() && m_iSourceHeight == pcEncTopBase->getSourceHeight() && equalOffsets && zeroPhase )
     827          {
     828            pcEPic->setEqualPictureSizeAndOffsetFlag( i, true );
     829          }
     830
     831          if( !pcEPic->equalPictureSizeAndOffsetFlag(i) || !sameBitDepths
     832#else
     833          if( m_iSourceWidth != pcEncTopBase->getSourceWidth() || m_iSourceHeight != pcEncTopBase->getSourceHeight() || !sameBitDepths
     834#if REF_REGION_OFFSET && RESAMPLING_FIX
     835            || !equalOffsets
     836#if R0209_GENERIC_PHASE
     837            || !zeroPhase
     838#endif
     839#else
     840            || !zeroOffsets
     841#endif
     842#endif
    798843#if Q0048_CGS_3D_ASYMLUT
    799844            || m_cPPS.getCGSFlag() > 0
     
    804849            )
    805850#else
    806           if(m_iSourceWidth != pcEncTopBase->getSourceWidth() || m_iSourceHeight != pcEncTopBase->getSourceHeight() || !zeroOffsets )
     851          if(m_iSourceWidth != pcEncTopBase->getSourceWidth() || m_iSourceHeight != pcEncTopBase->getSourceHeight()
     852#if REF_REGION_OFFSET && RESAMPLING_FIX
     853            || !equalOffsets
     854#if R0209_GENERIC_PHASE
     855            || !zeroPhase
     856#endif
     857#else
     858            || !zeroOffsets
     859#endif
     860          )
    807861#endif
    808862          {
     
    839893        for(UInt i = 0; i < m_cVPS.getNumDirectRefLayers( m_layerId ); i++ )
    840894        {
     895#if MOVE_SCALED_OFFSET_TO_PPS
     896#if O0098_SCALED_REF_LAYER_ID
     897          const Window scalEL = getPPS()->getScaledRefLayerWindowForLayer(m_cVPS.getRefLayerId(m_layerId, i));
     898#else
     899          const Window scalEL = getPPS()->getScaledRefLayerWindow(i);
     900#endif
     901#else
    841902#if O0098_SCALED_REF_LAYER_ID
    842903          const Window scalEL = getSPS()->getScaledRefLayerWindowForLayer(m_cVPS.getRefLayerId(m_layerId, i));
     
    844905          const Window scalEL = getSPS()->getScaledRefLayerWindow(i);
    845906#endif
     907#endif
     908#if REF_REGION_OFFSET
     909          const Window altRL  = getPPS()->getRefLayerWindowForLayer(m_cVPS.getRefLayerId(m_layerId, i));
     910#if RESAMPLING_FIX
     911          Bool equalOffsets = scalEL.hasEqualOffset(altRL);
     912#if R0209_GENERIC_PHASE
     913          Bool zeroPhase = getPPS()->hasZeroResamplingPhase(m_cVPS.getRefLayerId(m_layerId, i));
     914#endif
     915#else
     916          Bool zeroOffsets = ( scalEL.getWindowLeftOffset() == 0 && scalEL.getWindowRightOffset() == 0 && scalEL.getWindowTopOffset() == 0 && scalEL.getWindowBottomOffset() == 0
     917                               && altRL.getWindowLeftOffset() == 0 && altRL.getWindowRightOffset() == 0 && altRL.getWindowTopOffset() == 0 && altRL.getWindowBottomOffset() == 0);
     918#endif
     919#else
    846920          Bool zeroOffsets = ( scalEL.getWindowLeftOffset() == 0 && scalEL.getWindowRightOffset() == 0 && scalEL.getWindowTopOffset() == 0 && scalEL.getWindowBottomOffset() == 0 );
     921#endif
    847922
    848923#if VPS_EXTN_DIRECT_REF_LAYERS
     
    855930          Bool sameBitDepths = ( g_bitDepthYLayer[m_layerId] == g_bitDepthYLayer[refLayerId] ) && ( g_bitDepthCLayer[m_layerId] == g_bitDepthCLayer[refLayerId] );
    856931
    857           if( m_iSourceWidth != pcEncTopBase->getSourceWidth() || m_iSourceHeight != pcEncTopBase->getSourceHeight() || !zeroOffsets || !sameBitDepths
     932          if( m_iSourceWidth != pcEncTopBase->getSourceWidth() || m_iSourceHeight != pcEncTopBase->getSourceHeight() || !sameBitDepths
     933#if REF_REGION_OFFSET && RESAMPLING_FIX
     934            || !equalOffsets
     935#if R0209_GENERIC_PHASE
     936            || !zeroPhase
     937#endif
     938#else
     939            || !zeroOffsets
     940#endif
    858941#if Q0048_CGS_3D_ASYMLUT
    859942            || m_cPPS.getCGSFlag() > 0
     
    864947)
    865948#else
    866           if(m_iSourceWidth != pcEncTopBase->getSourceWidth() || m_iSourceHeight != pcEncTopBase->getSourceHeight() || !zeroOffsets )
     949          if(m_iSourceWidth != pcEncTopBase->getSourceWidth() || m_iSourceHeight != pcEncTopBase->getSourceHeight()
     950#if REF_REGION_OFFSET && RESAMPLING_FIX
     951            || !equalOffsets
     952#if R0209_GENERIC_PHASE
     953            || !zeroPhase
     954#endif
     955#else
     956            || !zeroOffsets
     957#endif
     958          )
    867959#endif
    868960          {
     
    905997#if SVC_EXTENSION
    906998  m_cSPS.setExtensionFlag( m_layerId > 0 ? true : false );
    907 
     999#if R0042_PROFILE_INDICATION
     1000  m_cSPS.setNumDirectRefLayers(m_numAddLayerSets);
     1001#endif
    9081002#if Q0078_ADD_LAYER_SETS
    909   if (getNumDirectRefLayers() == 0 && getNumAddLayerSets() > 0)
     1003  if( !m_numDirectRefLayers && m_numAddLayerSets )
    9101004  {
    9111005    m_cSPS.setLayerId(0); // layer ID 0 for independent layers
     
    9181012  m_cSPS.setLayerId(m_layerId);
    9191013#endif
     1014#if !MOVE_SCALED_OFFSET_TO_PPS
    9201015  m_cSPS.setNumScaledRefLayerOffsets(m_numScaledRefLayerOffsets);
    9211016  for(Int i = 0; i < m_cSPS.getNumScaledRefLayerOffsets(); i++)
     
    9291024#endif
    9301025  }
     1026#endif
    9311027#endif //SVC_EXTENSION
    9321028  ProfileTierLevel& profileTierLevel = *m_cSPS.getPTL()->getGeneralPTL();
     
    10411137  {
    10421138    TComVUI* pcVUI = m_cSPS.getVuiParameters();
    1043     pcVUI->setAspectRatioInfoPresentFlag(getAspectRatioIdc() != -1);
     1139    pcVUI->setAspectRatioInfoPresentFlag(getAspectRatioInfoPresentFlag());
    10441140    pcVUI->setAspectRatioIdc(getAspectRatioIdc());
    10451141    pcVUI->setSarWidth(getSarWidth());
     
    11771273
    11781274#if Q0078_ADD_LAYER_SETS
    1179   if (getNumDirectRefLayers() == 0 && getNumAddLayerSets() > 0)
     1275  if( !m_numDirectRefLayers && m_numAddLayerSets )
    11801276  {
    11811277    m_cPPS.setLayerId(0); // layer ID 0 for independent layers
     
    12031299  {
    12041300    m_cPPS.setNumExtraSliceHeaderBits( 3 );
     1301  }
     1302#endif
     1303#if MOVE_SCALED_OFFSET_TO_PPS
     1304  m_cPPS.setNumScaledRefLayerOffsets(m_numScaledRefLayerOffsets);
     1305  for(Int i = 0; i < m_cPPS.getNumScaledRefLayerOffsets(); i++)
     1306  {
     1307#if O0098_SCALED_REF_LAYER_ID
     1308    m_cPPS.setScaledRefLayerId(i, m_scaledRefLayerId[i]);
     1309#endif
     1310    m_cPPS.getScaledRefLayerWindow(i) = m_scaledRefLayerWindow[i];
     1311#if REF_REGION_OFFSET
     1312    m_cPPS.getRefLayerWindow(i) = m_refLayerWindow[i];
     1313    m_cPPS.setScaledRefLayerOffsetPresentFlag( m_scaledRefLayerId[i], m_scaledRefLayerOffsetPresentFlag[i] );
     1314    m_cPPS.setRefRegionOffsetPresentFlag( m_scaledRefLayerId[i], m_refRegionOffsetPresentFlag[i] );
     1315#endif
     1316#if R0209_GENERIC_PHASE
     1317    m_cPPS.setResamplePhaseSetPresentFlag( m_scaledRefLayerId[i], m_resamplePhaseSetPresentFlag[i] );
     1318    m_cPPS.setPhaseHorLuma( m_scaledRefLayerId[i], m_phaseHorLuma[i] );
     1319    m_cPPS.setPhaseVerLuma( m_scaledRefLayerId[i], m_phaseVerLuma[i] );
     1320    m_cPPS.setPhaseHorChroma( m_scaledRefLayerId[i], m_phaseHorChroma[i] );
     1321    m_cPPS.setPhaseVerChroma( m_scaledRefLayerId[i], m_phaseVerChroma[i] );
     1322#endif
     1323#if P0312_VERT_PHASE_ADJ
     1324    m_cPPS.setVertPhasePositionEnableFlag( m_scaledRefLayerId[i], m_scaledRefLayerWindow[i].getVertPhasePositionEnableFlag() );
     1325#endif
    12051326  }
    12061327#endif
     
    14771598Void  TEncTop::xInitPPSforTiles()
    14781599{
    1479   m_cPPS.setUniformSpacingFlag( m_iUniformSpacingIdr );
    1480   m_cPPS.setNumColumnsMinus1( m_iNumColumnsMinus1 );
    1481   m_cPPS.setNumRowsMinus1( m_iNumRowsMinus1 );
    1482   if( m_iUniformSpacingIdr == 0 )
    1483   {
    1484     m_cPPS.setColumnWidth( m_puiColumnWidth );
    1485     m_cPPS.setRowHeight( m_puiRowHeight );
     1600  m_cPPS.setTileUniformSpacingFlag( m_tileUniformSpacingFlag );
     1601  m_cPPS.setNumTileColumnsMinus1( m_iNumColumnsMinus1 );
     1602  m_cPPS.setNumTileRowsMinus1( m_iNumRowsMinus1 );
     1603  if( !m_tileUniformSpacingFlag )
     1604  {
     1605    m_cPPS.setTileColumnWidth( m_tileColumnWidth );
     1606    m_cPPS.setTileRowHeight( m_tileRowHeight );
    14861607  }
    14871608  m_cPPS.setLoopFilterAcrossTilesEnabledFlag( m_loopFilterAcrossTilesEnabledFlag );
    14881609
    14891610  // # substreams is "per tile" when tiles are independent.
    1490   if (m_iWaveFrontSynchro
    1491     )
     1611  if (m_iWaveFrontSynchro )
    14921612  {
    14931613    m_cPPS.setNumSubstreams(m_iWaveFrontSubstreams * (m_iNumColumnsMinus1+1));
     
    15151635  }
    15161636
    1517   if( m_iNumColumnsMinus1 && m_iUniformSpacingIdr==0 )
     1637  if( m_iNumColumnsMinus1 && !m_tileUniformSpacingFlag )
    15181638  {
    15191639    for(Int i=0; i<m_iNumColumnsMinus1; i++)
    15201640    {
    1521       uiCummulativeColumnWidth += m_puiColumnWidth[i];
     1641      uiCummulativeColumnWidth += m_tileColumnWidth[i];
    15221642    }
    15231643
     
    15421662  }
    15431663
    1544   if( m_iNumRowsMinus1 && m_iUniformSpacingIdr==0 )
     1664  if( m_iNumRowsMinus1 && !m_tileUniformSpacingFlag )
    15451665  {
    15461666    for(Int i=0; i<m_iNumRowsMinus1; i++)
    1547     {
    1548       uiCummulativeRowHeight += m_puiRowHeight[i];
    1549     }
     1667      uiCummulativeRowHeight += m_tileRowHeight[i];
    15501668
    15511669    if( uiCummulativeRowHeight >= iHeightInCU )
     
    16461764
    16471765    Int  numReorderPics[MAX_TLAYER];
     1766#if R0156_CONF_WINDOW_IN_REP_FORMAT
     1767    Window &conformanceWindow = repFormat->getConformanceWindowVps();
     1768#else
    16481769    Window &conformanceWindow = m_cSPS.getConformanceWindow();
     1770#endif
    16491771    Window defaultDisplayWindow = m_cSPS.getVuiParametersPresentFlag() ? m_cSPS.getVuiParameters()->getDefaultDisplayWindow() : Window();
    16501772
     
    16851807  return win;
    16861808}
     1809#if REF_REGION_OFFSET
     1810Window& TEncTop::getRefLayerWindowForLayer(Int layerId)
     1811{
     1812  static Window win;
     1813
     1814  for (Int i = 0; i < m_numScaledRefLayerOffsets; i++)
     1815  {
     1816    if (layerId == m_refLayerId[i])
     1817    {
     1818      return m_refLayerWindow[i];
     1819    }
     1820  }
     1821
     1822  win.resetWindow();  // reference offsets are inferred to be zero when not present
     1823  return win;
     1824}
     1825#endif
    16871826#endif
    16881827
  • trunk/source/Lib/TLibEncoder/TEncTop.h

    r815 r906  
    125125  static Int              m_iSPSIdCnt;                    ///< next Id number for SPS   
    126126  static Int              m_iPPSIdCnt;                    ///< next Id number for PPS   
    127 #if AVC_SYNTAX
    128   fstream*                m_pBLSyntaxFile;
    129 #endif
    130127  TEncTop**               m_ppcTEncTop;
    131128  TEncTop*                getLayerEnc(UInt layer)   { return m_ppcTEncTop[layer]; }
     
    139136#endif
    140137  Window                  m_scaledRefLayerWindow[MAX_LAYERS];
     138#if REF_REGION_OFFSET
     139  UInt                    m_numRefLayerOffsets;
     140  UInt                    m_refLayerId[MAX_LAYERS];
     141  Window                  m_refLayerWindow[MAX_LAYERS];
     142  Bool                    m_scaledRefLayerOffsetPresentFlag[MAX_LAYERS];
     143  Bool                    m_refRegionOffsetPresentFlag[MAX_LAYERS];
     144#endif
     145#if R0209_GENERIC_PHASE
     146  Int                     m_phaseHorLuma  [MAX_LAYERS];
     147  Int                     m_phaseVerLuma  [MAX_LAYERS];
     148  Int                     m_phaseHorChroma[MAX_LAYERS];
     149  Int                     m_phaseVerChroma[MAX_LAYERS];
     150  Int                     m_resamplePhaseSetPresentFlag[MAX_LAYERS];
     151#endif
    141152#if P0312_VERT_PHASE_ADJ
    142153  Bool                    m_vertPhasePositionEnableFlag[MAX_LAYERS];
     
    156167#if Q0078_ADD_LAYER_SETS
    157168  int                     m_numAddLayerSets;
     169#endif
     170#if P0297_VPS_POC_LSB_ALIGNED_FLAG
     171  Bool                    m_pocDecrementedInDPBFlag;
     172  Int                     m_currPocMsb;
    158173#endif
    159174#endif //SVC_EXTENSION
     
    232247#endif
    233248  Window&   getScaledRefLayerWindow(Int x)                 { return m_scaledRefLayerWindow[x];        }
     249#if REF_REGION_OFFSET
     250  Void      setNumRefLayerOffsets(Int x) { m_numRefLayerOffsets = x; }
     251  UInt      getNumRefLayerOffsets() { return m_numRefLayerOffsets; }
     252  Void      setRefLayerId(Int x, UInt id) { m_refLayerId[x] = id;   }
     253  UInt      getRefLayerId(Int x)          { return m_refLayerId[x]; }
     254  Window&   getRefLayerWindowForLayer(Int layerId);
     255  Window&   getRefLayerWindow(Int x)            { return m_refLayerWindow[x]; }
     256  Bool      getScaledRefLayerOffsetPresentFlag(Int x) { return m_scaledRefLayerOffsetPresentFlag[x]; }
     257  Void      setScaledRefLayerOffsetPresentFlag(Int x, Bool b) { m_scaledRefLayerOffsetPresentFlag[x] = b; }
     258  Bool      getRefRegionOffsetPresentFlag(Int x) { return m_refRegionOffsetPresentFlag[x]; }
     259  Void      setRefRegionOffsetPresentFlag(Int x, Bool b) { m_refRegionOffsetPresentFlag[x] = b; }
     260#endif
    234261#if P0312_VERT_PHASE_ADJ
    235262  Void      setVertPhasePositionEnableFlag(Int x, Bool b)  { m_vertPhasePositionEnableFlag[x] = b;    }
    236263  UInt      getVertPhasePositionEnableFlag(Int x)          { return m_vertPhasePositionEnableFlag[x]; }
     264#endif
     265#if R0209_GENERIC_PHASE
     266  Int getPhaseHorLuma(Int x) { return m_phaseHorLuma[x]; }
     267  Int getPhaseVerLuma(Int x) { return m_phaseVerLuma[x]; }
     268  Int getPhaseHorChroma(Int x) { return m_phaseHorChroma[x]; }
     269  Int getPhaseVerChroma(Int x) { return m_phaseVerChroma[x]; }
     270  Void setPhaseHorLuma(Int x, Int val) { m_phaseHorLuma[x] = val; }
     271  Void setPhaseVerLuma(Int x, Int val) { m_phaseVerLuma[x] = val; }
     272  Void setPhaseHorChroma(Int x, Int val) { m_phaseHorChroma[x] = val; }
     273  Void setPhaseVerChroma(Int x, Int val) { m_phaseVerChroma[x] = val; }
     274  Bool getResamplePhaseSetPresentFlag(Int x) { return m_resamplePhaseSetPresentFlag[x]; }
     275  Void setResamplePhaseSetPresentFlag(Int x, Bool b) { m_resamplePhaseSetPresentFlag[x] = b; }
    237276#endif
    238277
     
    245284  Void      setInterLayerWeightedPredFlag(Bool flag)   { m_interLayerWeightedPredFlag = flag; }
    246285  Bool      getInterLayerWeightedPredFlag()            { return m_interLayerWeightedPredFlag; }
    247 #endif
    248 #if AVC_SYNTAX
    249   Void      setBLSyntaxFile( fstream* pFile ) { m_pBLSyntaxFile = pFile; }
    250   fstream*  getBLSyntaxFile() { return m_pBLSyntaxFile; }
    251286#endif
    252287  Void      encode( TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsOut, Int iPicIdInGOP );
     
    275310  Int  getNumAddLayerSets()                  { return m_numAddLayerSets; }
    276311#endif
     312#if P0297_VPS_POC_LSB_ALIGNED_FLAG
     313  Void setPocDecrementedInDPBFlag(Bool x)    { m_pocDecrementedInDPBFlag = x; }
     314  Bool getPocDecrementedInDPBFlag()          { return m_pocDecrementedInDPBFlag; }
     315  Void setCurrPocMsb(Int poc)                { m_currPocMsb = poc; }
     316  Int  getCurrPocMsb()                       { return m_currPocMsb; }
     317#endif
    277318#else //SVC_EXTENSION
    278319  Void encode( Bool bEos, TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut,
  • trunk/source/Lib/TLibVideoIO/TVideoIOYuv.cpp

    r595 r906  
    470470  Bool retval = true;
    471471
     472  if ((width==0)||(height==0))
     473  {
     474    printf ("\nWarning: writing %d x %d luma sample output picture!", width, height);
     475  }
     476
    472477  if (m_bitDepthShiftY != 0 || m_bitDepthShiftC != 0)
    473478  {
     
    567572 
    568573  Bool retval = true;
     574 
     575  if ((width==0)||(height==0))
     576  {
     577    printf ("\nWarning: writing %d x %d luma sample output picture!", width, height);
     578  }
    569579 
    570580  if (m_bitDepthShiftY != 0 || m_bitDepthShiftC != 0)
Note: See TracChangeset for help on using the changeset viewer.