Changeset 1273 in SHVCSoftware


Ignore:
Timestamp:
15 Jul 2015, 20:51:59 (9 years ago)
Author:
seregin
Message:

port rev 4306 and rev 4307

Location:
branches/SHM-dev/source
Files:
2 added
19 edited

Legend:

Unmodified
Added
Removed
  • branches/SHM-dev/source/App/TAppDecoder/TAppDecCfg.cpp

    r1259 r1273  
    116116                                                                                   "\t1: check hash in SEI messages if available in the bitstream\n"
    117117                                                                                   "\t0: ignore SEI message")
    118   ("SEIpictureDigest",          m_decodedPictureHashSEIEnabled,        1,          "deprecated alias for SEIDecodedPictureHash")
    119118  ("SEINoDisplay",              m_decodedNoDisplaySEIEnabled,          true,       "Control handling of decoded no display SEI messages")
    120119  ("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.")
  • branches/SHM-dev/source/App/TAppDecoder/TAppDecTop.cpp

    r1260 r1273  
    15441544        this->setMetadataFileRefresh(false);
    15451545
    1546         TComDigest recon_digest;
     1546        TComPictureHash recon_digest;
    15471547        Int numChar = calcMD5(*pic->getPicYuvRec(), recon_digest);
    1548         fprintf(fptr, "%8d%9d    MD5:%s\n", pic->getLayerId(), pic->getSlice(0)->getPOC(), digestToString(recon_digest, numChar).c_str());
     1548        fprintf(fptr, "%8d%9d    MD5:%s\n", pic->getLayerId(), pic->getSlice(0)->getPOC(), hashToString(recon_digest, numChar).c_str());
    15491549        fclose(fptr);
    15501550      }
  • branches/SHM-dev/source/App/TAppEncoder/TAppEncCfg.cpp

    r1259 r1273  
    14011401                                                                                                               "\t1: use MD5\n"
    14021402                                                                                                               "\t0: disable")
    1403   ("SEIpictureDigest",                                m_decodedPictureHashSEIEnabled,                       0, "deprecated alias for SEIDecodedPictureHash")
    14041403  ("TMVPMode",                                        m_TMVPModeId,                                         1, "TMVP mode 0: TMVP disable for all slices. 1: TMVP enable for all slices (default) 2: TMVP enable for certain slices only")
    14051404  ("FEN",                                             m_bUseFastEnc,                                    false, "fast encoder setting")
     
    41354134  if((m_numTileColumnsMinus1 <= 0) && (m_numTileRowsMinus1 <= 0) && m_tmctsSEIEnabled)
    41364135  {
    4137     printf("SEITempMotionConstrainedTileSets is set to false to disable 'temporal_motion_constrained_tile_sets' SEI because there are no tiles enabled\n");
     4136    printf("Warning: SEITempMotionConstrainedTileSets is set to false to disable temporal motion-constrained tile sets SEI message because there are no tiles enabled.\n");
    41384137    m_tmctsSEIEnabled = false;
    41394138  }
  • branches/SHM-dev/source/App/TAppEncoder/TAppEncTop.cpp

    r1260 r1273  
    16041604        numDU ++;
    16051605      }
    1606       vps->getBspHrd(i)->setNumDU( numDU );
     1606      //vps->getBspHrd(i)->setNumDU( numDU );
    16071607      vps->setBspHrdParameters( i, pcCfgLayer->getFrameRate(), numDU, pcCfgLayer->getTargetBitrate(), ( pcCfgLayer->getIntraPeriod() > 0 ) );
    16081608    }
  • branches/SHM-dev/source/Lib/TLibCommon/SEI.cpp

    r1259 r1273  
    4242Int  Table_exp_indicator[32] = {0, 10, 12, 16, 20, 25, 32, 40, 50, 64, 80, 100, 125, 160, 200, 250, 320, 400, 500, 640, 800, 1000, 1250, 1600, 2000, 2500, 3200, 4000, 5000, 6400, 8000, -1};
    4343
    44 #if SUB_BITSTREAM_PROPERTY_SEI
    45 SEISubBitstreamProperty::SEISubBitstreamProperty()
    46 {
    47   m_activeVpsId             = -1;
    48   m_numAdditionalSubStreams = 0;
    49   ::memset(m_subBitstreamMode       , 0, sizeof(m_subBitstreamMode));
    50   ::memset(m_outputLayerSetIdxToVps , 0, sizeof(m_outputLayerSetIdxToVps));
    51   ::memset(m_highestSublayerId      , 0, sizeof(m_highestSublayerId));
    52   ::memset(m_avgBitRate             , 0, sizeof(m_avgBitRate));
    53   ::memset(m_maxBitRate             , 0, sizeof(m_maxBitRate));
    54 }
    55 #endif
    56 
    5744SEIMessages getSeisByType(SEIMessages &seiList, SEI::PayloadType seiType)
    5845{
     
    9986}
    10087
     88void SEIBufferingPeriod::copyTo (SEIBufferingPeriod& target)
     89{
     90  target.m_bpSeqParameterSetId = m_bpSeqParameterSetId;
     91  target.m_rapCpbParamsPresentFlag = m_rapCpbParamsPresentFlag;
     92  target.m_cpbDelayOffset = m_cpbDelayOffset;
     93  target.m_dpbDelayOffset = m_dpbDelayOffset;
     94  target.m_concatenationFlag = m_concatenationFlag;
     95  target.m_auCpbRemovalDelayDelta = m_auCpbRemovalDelayDelta;
     96  ::memcpy(target.m_initialCpbRemovalDelay, m_initialCpbRemovalDelay, sizeof(m_initialCpbRemovalDelay));
     97  ::memcpy(target.m_initialCpbRemovalDelayOffset, m_initialCpbRemovalDelayOffset, sizeof(m_initialCpbRemovalDelayOffset));
     98  ::memcpy(target.m_initialAltCpbRemovalDelay, m_initialAltCpbRemovalDelay, sizeof(m_initialAltCpbRemovalDelay));
     99  ::memcpy(target.m_initialAltCpbRemovalDelayOffset, m_initialAltCpbRemovalDelayOffset, sizeof(m_initialAltCpbRemovalDelayOffset));
     100}
     101
     102void SEIPictureTiming::copyTo (SEIPictureTiming& target)
     103{
     104  target.m_picStruct = m_picStruct;
     105  target.m_sourceScanType = m_sourceScanType;
     106  target.m_duplicateFlag = m_duplicateFlag;
     107
     108  target.m_auCpbRemovalDelay = m_auCpbRemovalDelay;
     109  target.m_picDpbOutputDelay = m_picDpbOutputDelay;
     110  target.m_picDpbOutputDuDelay = m_picDpbOutputDuDelay;
     111  target.m_numDecodingUnitsMinus1 = m_numDecodingUnitsMinus1;
     112  target.m_duCommonCpbRemovalDelayFlag = m_duCommonCpbRemovalDelayFlag;
     113  target.m_duCommonCpbRemovalDelayMinus1 = m_duCommonCpbRemovalDelayMinus1;
     114
     115  target.m_numNalusInDuMinus1 = m_numNalusInDuMinus1;
     116  target.m_duCpbRemovalDelayMinus1 = m_duCpbRemovalDelayMinus1;
     117}
    101118
    102119// Static member
     
    169186}
    170187
     188
     189#if SUB_BITSTREAM_PROPERTY_SEI
     190SEISubBitstreamProperty::SEISubBitstreamProperty()
     191{
     192  m_activeVpsId             = -1;
     193  m_numAdditionalSubStreams = 0;
     194  ::memset(m_subBitstreamMode       , 0, sizeof(m_subBitstreamMode));
     195  ::memset(m_outputLayerSetIdxToVps , 0, sizeof(m_outputLayerSetIdxToVps));
     196  ::memset(m_highestSublayerId      , 0, sizeof(m_highestSublayerId));
     197  ::memset(m_avgBitRate             , 0, sizeof(m_avgBitRate));
     198  ::memset(m_maxBitRate             , 0, sizeof(m_maxBitRate));
     199}
     200#endif
     201
    171202#if Q0074_COLOUR_REMAPPING_SEI
    172203Void  SEIColourRemappingInfo::copyFrom( SEIColourRemappingInfo const * SeiCriInput)
  • branches/SHM-dev/source/Lib/TLibCommon/SEI.h

    r1259 r1273  
    166166  } method;
    167167
    168   TComDigest m_digest;
     168  TComPictureHash m_pictureHash;
    169169};
    170170
     
    196196public:
    197197  PayloadType payloadType() const { return BUFFERING_PERIOD; }
     198  void copyTo (SEIBufferingPeriod& target);
    198199
    199200  SEIBufferingPeriod()
     
    233234public:
    234235  PayloadType payloadType() const { return PICTURE_TIMING; }
     236  void copyTo (SEIPictureTiming& target);
    235237
    236238  SEIPictureTiming()
     
    239241  , m_duplicateFlag           (false)
    240242  , m_picDpbOutputDuDelay     (0)
    241   , m_numNalusInDuMinus1      (NULL)
    242   , m_duCpbRemovalDelayMinus1 (NULL)
    243243  {}
    244244  virtual ~SEIPictureTiming()
    245245  {
    246     if( m_numNalusInDuMinus1 != NULL )
    247     {
    248       delete m_numNalusInDuMinus1;
    249     }
    250     if( m_duCpbRemovalDelayMinus1  != NULL )
    251     {
    252       delete m_duCpbRemovalDelayMinus1;
    253     }
    254246  }
    255247
     
    264256  Bool  m_duCommonCpbRemovalDelayFlag;
    265257  UInt  m_duCommonCpbRemovalDelayMinus1;
    266   UInt* m_numNalusInDuMinus1;
    267   UInt* m_duCpbRemovalDelayMinus1;
     258  std::vector<UInt> m_numNalusInDuMinus1;
     259  std::vector<UInt> m_duCpbRemovalDelayMinus1;
    268260};
    269261
     
    714706
    715707#if Q0074_COLOUR_REMAPPING_SEI
     708struct TComSEIColourRemappingInfo
     709{
     710  std::string             m_colourRemapSEIFile;
     711  Int                     m_colourRemapSEIId;
     712  Bool                    m_colourRemapSEICancelFlag;
     713  Bool                    m_colourRemapSEIPersistenceFlag;
     714  Bool                    m_colourRemapSEIVideoSignalInfoPresentFlag;
     715  Bool                    m_colourRemapSEIFullRangeFlag;
     716  Int                     m_colourRemapSEIPrimaries;
     717  Int                     m_colourRemapSEITransferFunction;
     718  Int                     m_colourRemapSEIMatrixCoefficients;
     719  Int                     m_colourRemapSEIInputBitDepth;
     720  Int                     m_colourRemapSEIBitDepth;
     721  Int                     m_colourRemapSEIPreLutNumValMinus1[3];
     722  Int*                    m_colourRemapSEIPreLutCodedValue[3];
     723  Int*                    m_colourRemapSEIPreLutTargetValue[3];
     724  Bool                    m_colourRemapSEIMatrixPresentFlag;
     725  Int                     m_colourRemapSEILog2MatrixDenom;
     726  Int                     m_colourRemapSEICoeffs[3][3];
     727  Int                     m_colourRemapSEIPostLutNumValMinus1[3];
     728  Int*                    m_colourRemapSEIPostLutCodedValue[3];
     729  Int*                    m_colourRemapSEIPostLutTargetValue[3];
     730};
     731
    716732class SEIColourRemappingInfo : public SEI
    717733{
  • branches/SHM-dev/source/Lib/TLibCommon/TComPicYuv.h

    r1259 r1273  
    182182
    183183// These functions now return the length of the digest strings.
    184 UInt calcChecksum(const TComPicYuv& pic, TComDigest &digest);
    185 UInt calcCRC     (const TComPicYuv& pic, TComDigest &digest);
    186 UInt calcMD5     (const TComPicYuv& pic, TComDigest &digest);
    187 std::string digestToString(const TComDigest &digest, Int numChar);
     184UInt calcChecksum(const TComPicYuv& pic, TComPictureHash &digest);
     185UInt calcCRC     (const TComPicYuv& pic, TComPictureHash &digest);
     186UInt calcMD5     (const TComPicYuv& pic, TComPictureHash &digest);
     187std::string hashToString(const TComPictureHash &digest, Int numChar);
    188188//! \}
    189189
  • branches/SHM-dev/source/Lib/TLibCommon/TComPicYuvMD5.cpp

    r1259 r1273  
    8787
    8888
    89 UInt compCRC(Int bitdepth, const Pel* plane, UInt width, UInt height, UInt stride, TComDigest &digest)
     89UInt compCRC(Int bitdepth, const Pel* plane, UInt width, UInt height, UInt stride, TComPictureHash &digest)
    9090{
    9191  UInt crcMsb;
     
    127127}
    128128
    129 UInt calcCRC(const TComPicYuv& pic, TComDigest &digest)
     129UInt calcCRC(const TComPicYuv& pic, TComPictureHash &digest)
    130130{
    131131  UInt digestLen=0;
     
    139139}
    140140
    141 UInt compChecksum(Int bitdepth, const Pel* plane, UInt width, UInt height, UInt stride, TComDigest &digest)
     141UInt compChecksum(Int bitdepth, const Pel* plane, UInt width, UInt height, UInt stride, TComPictureHash &digest)
    142142{
    143143  UInt checksum = 0;
     
    165165}
    166166
    167 UInt calcChecksum(const TComPicYuv& pic, TComDigest &digest)
     167UInt calcChecksum(const TComPicYuv& pic, TComPictureHash &digest)
    168168{
    169169  UInt digestLen=0;
     
    183183 * uses little-endian two byte words; 8bit data uses single byte words.
    184184 */
    185 UInt calcMD5(const TComPicYuv& pic, TComDigest &digest)
     185UInt calcMD5(const TComPicYuv& pic, TComPictureHash &digest)
    186186{
    187187  /* choose an md5_plane packing function based on the system bitdepth */
     
    207207}
    208208
    209 std::string digestToString(const TComDigest &digest, Int numChar)
     209std::string hashToString(const TComPictureHash &digest, Int numChar)
    210210{
    211211  static const Char* hex = "0123456789abcdef";
  • branches/SHM-dev/source/Lib/TLibCommon/TComSlice.cpp

    r1265 r1273  
    21302130}
    21312131
    2132 Void TComSPS::setHrdParameters( UInt frameRate, UInt numDU, UInt bitRate, Bool randomAccess )
     2132Void TComSPS::setHrdParameters( UInt frameRate, Bool useSubCpbParams, UInt bitRate, Bool randomAccess )
    21332133{
    21342134  if( !getVuiParametersPresentFlag() )
     
    21762176  hrd->setVclHrdParametersPresentFlag( rateCnt );
    21772177
    2178   hrd->setSubPicCpbParamsPresentFlag( ( numDU > 1 ) );
     2178  hrd->setSubPicCpbParamsPresentFlag( useSubCpbParams );
    21792179
    21802180  if( hrd->getSubPicCpbParamsPresentFlag() )
     
    22232223    bitrateValue = bitRate;
    22242224    cpbSizeValue = bitRate;                                     // 1 second
    2225     duCpbSizeValue = bitRate/numDU;
     2225    // DU CPB size could be smaller, but we don't know how
     2226    // in how many DUs the slice segment settings will result
     2227    // (used to be: bitRate/numDU)
     2228    duCpbSizeValue = bitRate;
    22262229    duBitRateValue = bitRate;
    22272230
  • branches/SHM-dev/source/Lib/TLibCommon/TComSlice.h

    r1265 r1273  
    310310  UInt m_cpbRemovalDelayLengthMinus1;
    311311  UInt m_dpbOutputDelayLengthMinus1;
    312   UInt m_numDU;
    313312  HrdSubLayerInfo m_HRD[MAX_TLAYER];
    314313
     
    396395  Bool    getCbrFlag( Int layer, Int cpbcnt, Int nalOrVcl ) const                    { return m_HRD[layer].cbrFlag[cpbcnt][nalOrVcl];             }
    397396
    398   Void    setNumDU( UInt value )                                                     { m_numDU = value;                                           }
    399   UInt    getNumDU( ) const                                                          { return m_numDU;                                            }
    400397  Bool    getCpbDpbDelaysPresentFlag( ) const                      { return getNalHrdParametersPresentFlag() || getVclHrdParametersPresentFlag(); }
    401398
     
    12051202    , m_log2MaxMvLengthHorizontal         (15)
    12061203    , m_log2MaxMvLengthVertical           (15)
    1207  {}
     1204  {}
    12081205
    12091206  virtual           ~TComVUI() {}
     
    15251522  Bool                   getScalingListPresentFlag() const                                               { return m_scalingListPresentFlag;                                     }
    15261523  Void                   setScalingListPresentFlag( Bool b )                                             { m_scalingListPresentFlag  = b;                                       }
    1527 
    15281524  Void                   setScalingList( TComScalingList *scalingList);
    15291525  TComScalingList&       getScalingList()                                                                { return m_scalingList;                                                }
     
    15411537  TComVUI*               getVuiParameters()                                                              { return &m_vuiParameters;                                             }
    15421538  const TComVUI*         getVuiParameters() const                                                        { return &m_vuiParameters;                                             }
    1543   Void                   setHrdParameters( UInt frameRate, UInt numDU, UInt bitRate, Bool randomAccess );
    1544 
     1539  Void                   setHrdParameters( UInt frameRate, Bool useSubCpbParams, UInt bitRate, Bool randomAccess );
    15451540  const TComPTL*         getPTL() const                                                                  { return &m_pcPTL;                                                     }
    15461541  TComPTL*               getPTL()                                                                        { return &m_pcPTL;                                                     }
     
    15711566};
    15721567
     1568
    15731569/// Reference Picture Lists class
    15741570
     
    15971593  Void    setRefPicSetIdxL1(UInt idx, UInt refPicSetIdx) { assert(idx<REF_PIC_LIST_NUM_IDX); m_RefPicSetIdxL1[idx] = refPicSetIdx; }
    15981594};
    1599 
    16001595
    16011596/// PPS class
     
    18031798  Bool                   getScalingListPresentFlag() const                                { return m_scalingListPresentFlag;              }
    18041799  Void                   setScalingListPresentFlag( Bool b )                              { m_scalingListPresentFlag  = b;                }
    1805 
    18061800  TComScalingList&       getScalingList()                                                 { return m_scalingList;                         }
    18071801  const TComScalingList& getScalingList() const                                           { return m_scalingList;                         }
     
    23992393};// END CLASS DEFINITION TComSlice
    24002394
     2395
    24012396Void calculateParameterSetChangedFlag(Bool &bChanged, const std::vector<UChar> *pOldData, const std::vector<UChar> *pNewData);
    24022397
  • branches/SHM-dev/source/Lib/TLibCommon/TypeDef.h

    r1265 r1273  
    864864
    865865
    866 struct TComDigest
     866struct TComPictureHash
    867867{
    868868  std::vector<UChar> hash;
    869869
    870   Bool operator==(const TComDigest &other) const
     870  Bool operator==(const TComPictureHash &other) const
    871871  {
    872872    if (other.hash.size() != hash.size())
     
    884884  }
    885885
    886   Bool operator!=(const TComDigest &other) const
     886  Bool operator!=(const TComPictureHash &other) const
    887887  {
    888888    return !(*this == other);
  • branches/SHM-dev/source/Lib/TLibDecoder/SEIread.cpp

    r1259 r1273  
    341341#endif
    342342#if SUB_BITSTREAM_PROPERTY_SEI
    343    case SEI::SUB_BITSTREAM_PROPERTY:
    344      sei = new SEISubBitstreamProperty;
    345      xParseSEISubBitstreamProperty((SEISubBitstreamProperty&) *sei, vps, pDecodedMessageOutputStream);
    346      break;
     343    case SEI::SUB_BITSTREAM_PROPERTY:
     344      sei = new SEISubBitstreamProperty;
     345      xParseSEISubBitstreamProperty((SEISubBitstreamProperty&) *sei, vps, pDecodedMessageOutputStream);
     346      break;
    347347#endif
    348348#if O0164_MULTI_LAYER_HRD
    349    case SEI::BSP_NESTING:
    350      sei = new SEIBspNesting;
     349    case SEI::BSP_NESTING:
     350      sei = new SEIBspNesting;
    351351#if LAYERS_NOT_PRESENT_SEI
    352      xParseSEIBspNesting((SEIBspNesting&) *sei, nalUnitType, vps, sps, *nestingSei, pDecodedMessageOutputStream);
    353 #else
    354      xParseSEIBspNesting((SEIBspNesting&) *sei, nalUnitType, sps, *nestingSei, pDecodedMessageOutputStream);
    355 #endif
    356      break;
    357    case SEI::BSP_INITIAL_ARRIVAL_TIME:
    358      sei = new SEIBspInitialArrivalTime;
    359      xParseSEIBspInitialArrivalTime((SEIBspInitialArrivalTime&) *sei, vps, sps, *nestingSei, *bspNestingSei, pDecodedMessageOutputStream);
    360      break;
     352      xParseSEIBspNesting((SEIBspNesting&) *sei, nalUnitType, vps, sps, *nestingSei, pDecodedMessageOutputStream);
     353#else
     354      xParseSEIBspNesting((SEIBspNesting&) *sei, nalUnitType, sps, *nestingSei, pDecodedMessageOutputStream);
     355#endif
     356      break;
     357    case SEI::BSP_INITIAL_ARRIVAL_TIME:
     358      sei = new SEIBspInitialArrivalTime;
     359      xParseSEIBspInitialArrivalTime((SEIBspInitialArrivalTime&) *sei, vps, sps, *nestingSei, *bspNestingSei, pDecodedMessageOutputStream);
     360      break;
    361361#endif
    362362#if Q0189_TMVP_CONSTRAINTS
    363    case SEI::TMVP_CONSTRAINTS:
    364      sei =  new SEITMVPConstrains;
    365      xParseSEITMVPConstraints((SEITMVPConstrains&) *sei, payloadSize, pDecodedMessageOutputStream);
    366      break;
     363    case SEI::TMVP_CONSTRAINTS:
     364      sei =  new SEITMVPConstrains;
     365      xParseSEITMVPConstraints((SEITMVPConstrains&) *sei, payloadSize, pDecodedMessageOutputStream);
     366      break;
    367367#endif
    368368#if Q0247_FRAME_FIELD_INFO
    369    case SEI::FRAME_FIELD_INFO:
    370      sei =  new SEIFrameFieldInfo;
    371      xParseSEIFrameFieldInfo    ((SEIFrameFieldInfo&) *sei, payloadSize, pDecodedMessageOutputStream);
    372      break;
     369    case SEI::FRAME_FIELD_INFO:
     370      sei =  new SEIFrameFieldInfo;
     371      xParseSEIFrameFieldInfo    ((SEIFrameFieldInfo&) *sei, payloadSize, pDecodedMessageOutputStream);
     372      break;
    373373#endif
    374374#if P0123_ALPHA_CHANNEL_SEI
    375    case SEI::ALPHA_CHANNEL_INFO:
    376      sei = new SEIAlphaChannelInfo;
    377      xParseSEIAlphaChannelInfo((SEIAlphaChannelInfo &) *sei, payloadSize, pDecodedMessageOutputStream);
    378      break;
     375    case SEI::ALPHA_CHANNEL_INFO:
     376      sei = new SEIAlphaChannelInfo;
     377      xParseSEIAlphaChannelInfo((SEIAlphaChannelInfo &) *sei, payloadSize, pDecodedMessageOutputStream);
     378      break;
    379379#endif
    380380#if Q0096_OVERLAY_SEI
    381    case SEI::OVERLAY_INFO:
    382      sei = new SEIOverlayInfo;
    383      xParseSEIOverlayInfo((SEIOverlayInfo&) *sei, payloadSize, pDecodedMessageOutputStream);
    384      break;
     381    case SEI::OVERLAY_INFO:
     382      sei = new SEIOverlayInfo;
     383      xParseSEIOverlayInfo((SEIOverlayInfo&) *sei, payloadSize, pDecodedMessageOutputStream);
     384      break;
    385385#endif
    386386#endif //SVC_EXTENSION
    387    default:
    388      for (UInt i = 0; i < payloadSize; i++)
    389      {
    390        UInt seiByte;
    391        sei_read_code (NULL, 8, seiByte, "unknown prefix SEI payload byte");
    392      }
    393      printf ("Unknown prefix SEI message (payloadType = %d) was found!\n", payloadType);
    394      if (pDecodedMessageOutputStream)
    395      {
    396        (*pDecodedMessageOutputStream) << "Unknown prefix SEI message (payloadType = " << payloadType << ") was found!\n";
    397      }
    398      break;
     387    default:
     388      for (UInt i = 0; i < payloadSize; i++)
     389      {
     390        UInt seiByte;
     391        sei_read_code (NULL, 8, seiByte, "unknown prefix SEI payload byte");
     392      }
     393      printf ("Unknown prefix SEI message (payloadType = %d) was found!\n", payloadType);
     394      if (pDecodedMessageOutputStream)
     395      {
     396        (*pDecodedMessageOutputStream) << "Unknown prefix SEI message (payloadType = " << payloadType << ") was found!\n";
     397      }
     398      break;
    399399    }
    400400  }
     
    539539  }
    540540
    541   sei.m_digest.hash.clear();
     541  sei.m_pictureHash.hash.clear();
    542542  for(;bytesRead < payloadSize; bytesRead++)
    543543  {
    544544    sei_read_code( NULL, 8, val, traceString);
    545     sei.m_digest.hash.push_back((UChar)val);
     545    sei.m_pictureHash.hash.push_back((UChar)val);
    546546    if (pDecodedMessageOutputStream)
    547547    {
     
    858858        sei.m_duCommonCpbRemovalDelayMinus1 = code;
    859859      }
    860       if( sei.m_numNalusInDuMinus1 != NULL )
    861       {
    862         delete sei.m_numNalusInDuMinus1;
    863       }
    864       sei.m_numNalusInDuMinus1 = new UInt[ ( sei.m_numDecodingUnitsMinus1 + 1 ) ];
    865       if( sei.m_duCpbRemovalDelayMinus1  != NULL )
    866       {
    867         delete sei.m_duCpbRemovalDelayMinus1;
    868       }
    869       sei.m_duCpbRemovalDelayMinus1  = new UInt[ ( sei.m_numDecodingUnitsMinus1 + 1 ) ];
     860      sei.m_numNalusInDuMinus1.resize(sei.m_numDecodingUnitsMinus1 + 1 );
     861      sei.m_duCpbRemovalDelayMinus1.resize( sei.m_numDecodingUnitsMinus1 + 1 );
    870862
    871863      for( i = 0; i <= sei.m_numDecodingUnitsMinus1; i ++ )
  • branches/SHM-dev/source/Lib/TLibDecoder/TDecGop.cpp

    r1259 r1273  
    278278{
    279279  /* calculate MD5sum for entire reconstructed picture */
    280   TComDigest recon_digest;
     280  TComPictureHash recon_digest;
    281281  Int numChar=0;
    282282  const Char* hashType = "\0";
     
    319319  {
    320320    ok = "(OK)";
    321     if (recon_digest != pictureHashSEI->m_digest)
     321    if (recon_digest != pictureHashSEI->m_pictureHash)
    322322    {
    323323      ok = "(***ERROR***)";
     
    326326  }
    327327
    328   printf("[%s:%s,%s] ", hashType, digestToString(recon_digest, numChar).c_str(), ok);
     328  printf("[%s:%s,%s] ", hashType, hashToString(recon_digest, numChar).c_str(), ok);
    329329
    330330  if (mismatch)
    331331  {
    332332    g_md5_mismatch = true;
    333     printf("[rx%s:%s] ", hashType, digestToString(pictureHashSEI->m_digest, numChar).c_str());
    334   }
    335 }
    336 
     333    printf("[rx%s:%s] ", hashType, hashToString(pictureHashSEI->m_pictureHash, numChar).c_str());
     334  }
     335}
    337336//! \}
  • branches/SHM-dev/source/Lib/TLibEncoder/SEIwrite.cpp

    r1259 r1273  
    211211
    212212/**
    213  * marshal a single SEI message sei, storing the marshalled representation
    214  * in bitstream bs.
     213 * marshal all SEI messages in provided list into one bitstream bs
    215214 */
    216215#if O0164_MULTI_LAYER_HRD
    217 Void SEIWriter::writeSEImessage(TComBitIf& bs, const SEI& sei, const TComVPS *vps, const TComSPS *sps, const SEIScalableNesting* nestingSei, const SEIBspNesting* bspNestingSei)
     216Void SEIWriter::writeSEImessages(TComBitIf& bs, const SEIMessages &seiList, const TComVPS *vps, const TComSPS *sps, const SEIScalableNesting* nestingSei, const SEIBspNesting* bspNestingSei)
    218217#else
    219 Void SEIWriter::writeSEImessage(TComBitIf& bs, const SEI& sei, const TComSPS *sps)
    220 #endif
    221 {
    222   /* calculate how large the payload data is */
    223   /* TODO: this would be far nicer if it used vectored buffers */
    224   TComBitCounter bs_count;
    225   bs_count.resetBits();
    226   setBitstream(&bs_count);
    227 
    228 
    229 #if ENC_DEC_TRACE
    230   Bool traceEnable = g_HLSTraceEnable;
    231   g_HLSTraceEnable = false;
    232 #endif
    233 #if O0164_MULTI_LAYER_HRD
    234   xWriteSEIpayloadData(bs_count, sei, vps, sps, nestingSei, bspNestingSei);
    235 #else
    236   xWriteSEIpayloadData(bs_count, sei, sps);
    237 #endif
    238 #if ENC_DEC_TRACE
    239   g_HLSTraceEnable = traceEnable;
    240 #endif
    241 
    242   UInt payload_data_num_bits = bs_count.getNumberOfWrittenBits();
    243   assert(0 == payload_data_num_bits % 8);
    244 
    245   setBitstream(&bs);
    246 
     218Void SEIWriter::writeSEImessages(TComBitIf& bs, const SEIMessages &seiList, const TComSPS *sps)
     219#endif
     220{
    247221#if ENC_DEC_TRACE
    248222  if (g_HLSTraceEnable)
    249   {
    250223    xTraceSEIHeader();
    251   }
    252 #endif
    253 
    254   UInt payloadType = sei.payloadType();
    255   for (; payloadType >= 0xff; payloadType -= 0xff)
    256   {
    257     WRITE_CODE(0xff, 8, "payload_type");
    258   }
    259   WRITE_CODE(payloadType, 8, "payload_type");
    260 
    261   UInt payloadSize = payload_data_num_bits/8;
    262   for (; payloadSize >= 0xff; payloadSize -= 0xff)
    263   {
    264     WRITE_CODE(0xff, 8, "payload_size");
    265   }
    266   WRITE_CODE(payloadSize, 8, "payload_size");
    267 
    268   /* payloadData */
     224#endif
     225
     226  TComBitCounter bs_count;
     227
     228  for (SEIMessages::const_iterator sei=seiList.begin(); sei!=seiList.end(); sei++)
     229  {
     230    // calculate how large the payload data is
     231    // TODO: this would be far nicer if it used vectored buffers
     232    bs_count.resetBits();
     233    setBitstream(&bs_count);
     234
    269235#if ENC_DEC_TRACE
    270   if (g_HLSTraceEnable)
    271   {
    272     xTraceSEIMessageType(sei.payloadType());
    273   }
    274 #endif
    275 
     236    Bool traceEnable = g_HLSTraceEnable;
     237    g_HLSTraceEnable = false;
     238#endif
    276239#if O0164_MULTI_LAYER_HRD
    277   xWriteSEIpayloadData(bs, sei, vps, sps, nestingSei, bspNestingSei);
     240    xWriteSEIpayloadData(bs_count, **sei, vps, sps, nestingSei, bspNestingSei);
    278241#else
    279   xWriteSEIpayloadData(bs, sei, sps);
    280 #endif
     242    xWriteSEIpayloadData(bs_count, **sei, sps);
     243#endif
     244#if ENC_DEC_TRACE
     245    g_HLSTraceEnable = traceEnable;
     246#endif
     247    UInt payload_data_num_bits = bs_count.getNumberOfWrittenBits();
     248    assert(0 == payload_data_num_bits % 8);
     249
     250    setBitstream(&bs);
     251    UInt payloadType = (*sei)->payloadType();
     252    for (; payloadType >= 0xff; payloadType -= 0xff)
     253    {
     254      WRITE_CODE(0xff, 8, "payload_type");
     255    }
     256    WRITE_CODE(payloadType, 8, "payload_type");
     257
     258    UInt payloadSize = payload_data_num_bits/8;
     259    for (; payloadSize >= 0xff; payloadSize -= 0xff)
     260    {
     261      WRITE_CODE(0xff, 8, "payload_size");
     262    }
     263    WRITE_CODE(payloadSize, 8, "payload_size");
     264
     265    /* payloadData */
     266#if ENC_DEC_TRACE
     267    if (g_HLSTraceEnable)
     268      xTraceSEIMessageType((*sei)->payloadType());
     269#endif
     270
     271#if O0164_MULTI_LAYER_HRD
     272    xWriteSEIpayloadData(bs, **sei, vps, sps, nestingSei, bspNestingSei);
     273#else
     274    xWriteSEIpayloadData(bs, **sei, sps);
     275#endif
     276  }
    281277}
    282278
     
    316312  {
    317313    WRITE_CODE(sei.method, 8, "hash_type");
    318     for(UInt i=0; i<UInt(sei.m_digest.hash.size()); i++)
    319     {
    320       WRITE_CODE(sei.m_digest.hash[i], 8, traceString);
     314    for(UInt i=0; i<UInt(sei.m_pictureHash.hash.size()); i++)
     315    {
     316      WRITE_CODE(sei.m_pictureHash.hash[i], 8, traceString);
    321317    }
    322318  }
     
    795791
    796792  // write nested SEI messages
    797   for (SEIMessages::const_iterator it = sei.m_nestedSEIs.begin(); it != sei.m_nestedSEIs.end(); it++)
    798   {
    799 #if O0164_MULTI_LAYER_HRD
    800     writeSEImessage(bs, *(*it), vps, sps, &sei);
     793#if O0164_MULTI_LAYER_HRD 
     794  writeSEImessages(bs, sei.m_nestedSEIs, vps, sps, &sei);
    801795#else
    802     writeSEImessage(bs, *(*it), sps);
    803 #endif
    804   }
     796  writeSEImessages(bs, sei.m_nestedSEIs, sps);
     797#endif
    805798}
    806799
     
    11481141  assert( sei.m_nestedSEIs.size() <= MAX_SEIS_IN_BSP_NESTING );
    11491142  WRITE_UVLC( (UInt)sei.m_nestedSEIs.size(), "num_seis_in_bsp_minus1" );
    1150 
     1143 
    11511144  // write nested SEI messages
    1152   for (SEIMessages::const_iterator it = sei.m_nestedSEIs.begin(); it != sei.m_nestedSEIs.end(); it++)
    1153   {
    1154     writeSEImessage(bs, *(*it), vps, sps, &nestingSei, &sei);
    1155   }
     1145  writeSEImessages(bs, sei.m_nestedSEIs, vps, sps, &nestingSei, &sei);
    11561146}
    11571147
  • branches/SHM-dev/source/Lib/TLibEncoder/SEIwrite.h

    r1259 r1273  
    5151
    5252#if O0164_MULTI_LAYER_HRD
    53   Void writeSEImessage(TComBitIf& bs, const SEI& sei, const TComVPS *vps, const TComSPS *sps, const SEIScalableNesting* nestingSei=NULL, const SEIBspNesting* bspNestingSei=NULL);
     53  Void writeSEImessages(TComBitIf& bs, const SEIMessages &seiList, const TComVPS *vps, const TComSPS *sps, const SEIScalableNesting* nestingSei=NULL, const SEIBspNesting* bspNestingSei=NULL);
    5454#else
    55   Void writeSEImessage(TComBitIf& bs, const SEI& sei, const TComSPS *sps);
     55  Void writeSEImessages(TComBitIf& bs, const SEIMessages &seiList, const TComSPS *sps);
    5656#endif
    5757
     
    110110#endif
    111111#if Q0189_TMVP_CONSTRAINTS
    112 Void xWriteSEITMVPConstraints(const SEITMVPConstrains &sei);
     112  Void xWriteSEITMVPConstraints(const SEITMVPConstrains &sei);
    113113#endif
    114114#if Q0247_FRAME_FIELD_INFO
  • branches/SHM-dev/source/Lib/TLibEncoder/TEncCfg.h

    r1259 r1273  
    444444#endif
    445445#if Q0189_TMVP_CONSTRAINTS
    446   Int       m_TMVPConstraintsSEIEnabled;
     446  Int                                 m_TMVPConstraintsSEIEnabled;
    447447#endif
    448448#endif //SVC_EXTENSION
  • branches/SHM-dev/source/Lib/TLibEncoder/TEncGOP.cpp

    r1260 r1273  
    5353#endif
    5454
     55#include <deque>
    5556using namespace std;
    5657
     
    103104  ::memset(m_ltRefPicPocLsbSps, 0, sizeof(m_ltRefPicPocLsbSps));
    104105  ::memset(m_ltRefPicUsedByCurrPicFlag, 0, sizeof(m_ltRefPicUsedByCurrPicFlag));
    105   m_cpbRemovalDelay   = 0;
    106106  m_lastBPSEI         = 0;
    107107  xResetNonNestedSEIPresentFlags();
     
    123123
    124124#if Q0074_COLOUR_REMAPPING_SEI
    125   for( Int c=0 ; c<3 ; c++)
    126   {
    127     m_colourRemapSEIPreLutCodedValue[c]   = NULL;
    128     m_colourRemapSEIPreLutTargetValue[c]  = NULL;
    129     m_colourRemapSEIPostLutCodedValue[c]  = NULL;
    130     m_colourRemapSEIPostLutTargetValue[c] = NULL;
    131   }
     125  memset( m_seiColourRemappingInfo.m_colourRemapSEIPreLutCodedValue,   NULL, sizeof(m_seiColourRemappingInfo.m_colourRemapSEIPreLutCodedValue));
     126  memset( m_seiColourRemappingInfo.m_colourRemapSEIPreLutTargetValue,  NULL, sizeof(m_seiColourRemappingInfo.m_colourRemapSEIPreLutTargetValue));
     127  memset( m_seiColourRemappingInfo.m_colourRemapSEIPostLutCodedValue,  NULL, sizeof(m_seiColourRemappingInfo.m_colourRemapSEIPostLutCodedValue));
     128  memset( m_seiColourRemappingInfo.m_colourRemapSEIPostLutTargetValue, NULL, sizeof(m_seiColourRemappingInfo.m_colourRemapSEIPostLutTargetValue));
    132129#endif
    133130  return;
     
    176173  m_pcEncTop     = pcTEncTop;
    177174  m_pcCfg                = pcTEncTop;
     175  m_seiEncoder.init(m_pcCfg, pcTEncTop, this);
    178176  m_pcSliceEncoder       = pcTEncTop->getSliceEncoder();
    179177  m_pcListPic            = pcTEncTop->getListPic();
     
    216214}
    217215
    218 SEIActiveParameterSets* TEncGOP::xCreateSEIActiveParameterSets (const TComSPS *sps)
    219 {
    220   SEIActiveParameterSets *seiActiveParameterSets = new SEIActiveParameterSets();
    221   seiActiveParameterSets->activeVPSId = m_pcCfg->getVPS()->getVPSId();
    222   seiActiveParameterSets->m_selfContainedCvsFlag = false;
    223   seiActiveParameterSets->m_noParameterSetUpdateFlag = false; 
     216Int TEncGOP::xWriteVPS (AccessUnit &accessUnit, const TComVPS *vps)
     217{
     218  OutputNALUnit nalu(NAL_UNIT_VPS);
     219  m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
     220  m_pcEntropyCoder->encodeVPS(vps);
     221  writeRBSPTrailingBits(nalu.m_Bitstream);
     222  accessUnit.push_back(new NALUnitEBSP(nalu));
     223  return (Int)(accessUnit.back()->m_nalUnitData.str().size()) * 8;
     224}
     225
     226Int TEncGOP::xWriteSPS (AccessUnit &accessUnit, const TComSPS *sps)
     227{
     228#if SVC_EXTENSION
     229  OutputNALUnit nalu(NAL_UNIT_SPS, 0, m_layerId);
     230
     231  if (m_pcEncTop->getVPS()->getNumDirectRefLayers(m_layerId) == 0 && m_pcEncTop->getVPS()->getNumAddLayerSets() > 0)
     232  {
     233    nalu.m_nuhLayerId = 0; // For independent base layer rewriting
     234  }
     235
     236  // dependency constraint
     237  assert( sps->getLayerId() == 0 || sps->getLayerId() == m_layerId || m_pcEncTop->getVPS()->getRecursiveRefLayerFlag(m_layerId, sps->getLayerId()) );
     238#else
     239  OutputNALUnit nalu(NAL_UNIT_SPS);
     240#endif
     241  m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
     242  m_pcEntropyCoder->encodeSPS(sps);
     243  writeRBSPTrailingBits(nalu.m_Bitstream);
     244  accessUnit.push_back(new NALUnitEBSP(nalu));
     245  return (Int)(accessUnit.back()->m_nalUnitData.str().size()) * 8;
     246
     247}
     248
     249Int TEncGOP::xWritePPS (AccessUnit &accessUnit, const TComPPS *pps)
     250{
     251#if SVC_EXTENSION
     252  OutputNALUnit nalu(NAL_UNIT_PPS, 0, m_layerId);
     253
     254  if( m_pcEncTop->getVPS()->getNumDirectRefLayers(m_layerId) == 0 && m_pcEncTop->getVPS()->getNumAddLayerSets() > 0 )
     255  {
     256    // For independent base layer rewriting
     257    nalu.m_nuhLayerId = 0;
     258  }
     259
     260  // dependency constraint
     261  assert( pps->getLayerId() == 0 || pps->getLayerId() == m_layerId || m_pcEncTop->getVPS()->getRecursiveRefLayerFlag(m_layerId, pps->getLayerId()) );
     262#else
     263  OutputNALUnit nalu(NAL_UNIT_PPS);
     264#endif
     265  m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
     266#if SVC_EXTENSION && CGS_3D_ASYMLUT
     267  m_pcEntropyCoder->encodePPS(pps, &m_Enc3DAsymLUTPPS);
     268#else
     269  m_pcEntropyCoder->encodePPS(pps);
     270#endif
     271  writeRBSPTrailingBits(nalu.m_Bitstream);
     272  accessUnit.push_back(new NALUnitEBSP(nalu));
     273  return (Int)(accessUnit.back()->m_nalUnitData.str().size()) * 8;
     274}
     275
     276
     277Int TEncGOP::xWriteParameterSets (AccessUnit &accessUnit, TComSlice *slice)
     278{
     279  Int actualTotalBits = 0;
     280
     281  actualTotalBits += xWriteVPS(accessUnit, m_pcEncTop->getVPS());
     282  actualTotalBits += xWriteSPS(accessUnit, slice->getSPS());
     283  actualTotalBits += xWritePPS(accessUnit, slice->getPPS());
     284
     285  return actualTotalBits;
     286}
     287
     288// write SEI list into one NAL unit and add it to the Access unit at auPos
     289#if O0164_MULTI_LAYER_HRD
     290Void TEncGOP::xWriteSEI (NalUnitType naluType, SEIMessages& seiMessages, AccessUnit &accessUnit, AccessUnit::iterator &auPos, Int temporalId, const TComVPS *vps, const TComSPS *sps, const SEIScalableNesting* nestingSei, const SEIBspNesting* bspNestingSei)
     291#else
     292Void TEncGOP::xWriteSEI (NalUnitType naluType, SEIMessages& seiMessages, AccessUnit &accessUnit, AccessUnit::iterator &auPos, Int temporalId, const TComSPS *sps)
     293#endif
     294{
     295  // don't do anything, if we get an empty list
     296  if (seiMessages.empty())
     297  {
     298    return;
     299  }
     300#if O0164_MULTI_LAYER_HRD
     301  OutputNALUnit nalu(naluType, temporalId, sps->getLayerId());
     302  m_seiWriter.writeSEImessages(nalu.m_Bitstream, seiMessages, vps, sps, nestingSei, bspNestingSei);
     303#else
     304  OutputNALUnit nalu(naluType, temporalId);
     305  m_seiWriter.writeSEImessages(nalu.m_Bitstream, seiMessages, sps);
     306#endif
     307  writeRBSPTrailingBits(nalu.m_Bitstream);
     308  auPos = accessUnit.insert(auPos, new NALUnitEBSP(nalu));
     309  auPos++;
     310}
     311
     312#if O0164_MULTI_LAYER_HRD
     313Void TEncGOP::xWriteSEISeparately (NalUnitType naluType, SEIMessages& seiMessages, AccessUnit &accessUnit, AccessUnit::iterator &auPos, Int temporalId, const TComVPS *vps, const TComSPS *sps, const SEIScalableNesting* nestingSei, const SEIBspNesting* bspNestingSei)
     314#else
     315Void TEncGOP::xWriteSEISeparately (NalUnitType naluType, SEIMessages& seiMessages, AccessUnit &accessUnit, AccessUnit::iterator &auPos, Int temporalId, const TComSPS *sps)
     316#endif
     317{
     318  // don't do anything, if we get an empty list
     319  if (seiMessages.empty())
     320  {
     321    return;
     322  }
     323  for (SEIMessages::const_iterator sei = seiMessages.begin(); sei!=seiMessages.end(); sei++ )
     324  {
     325    SEIMessages tmpMessages;
     326    tmpMessages.push_back(*sei);
     327#if O0164_MULTI_LAYER_HRD
     328    OutputNALUnit nalu(naluType, temporalId, sps->getLayerId());
     329    m_seiWriter.writeSEImessages(nalu.m_Bitstream, tmpMessages, vps, sps, nestingSei, bspNestingSei);
     330#else
     331    OutputNALUnit nalu(naluType, temporalId);
     332    m_seiWriter.writeSEImessages(nalu.m_Bitstream, tmpMessages, sps);
     333#endif
     334    writeRBSPTrailingBits(nalu.m_Bitstream);
     335    auPos = accessUnit.insert(auPos, new NALUnitEBSP(nalu));
     336    auPos++;
     337  }
     338}
     339
     340Void TEncGOP::xClearSEIs(SEIMessages& seiMessages, Bool deleteMessages)
     341{
     342  if (deleteMessages)
     343  {
     344    deleteSEIs(seiMessages);
     345  }
     346  else
     347  {
     348    seiMessages.clear();
     349  }
     350}
     351
     352// write SEI messages as separate NAL units ordered
     353#if O0164_MULTI_LAYER_HRD
     354Void TEncGOP::xWriteLeadingSEIOrdered (SEIMessages& seiMessages, SEIMessages& duInfoSeiMessages, AccessUnit &accessUnit, Int temporalId,const TComVPS *vps, const TComSPS *sps, Bool testWrite, const SEIScalableNesting* nestingSei, const SEIBspNesting* bspNestingSei)
     355#else
     356Void TEncGOP::xWriteLeadingSEIOrdered (SEIMessages& seiMessages, SEIMessages& duInfoSeiMessages, AccessUnit &accessUnit, Int temporalId, const TComSPS *sps, Bool testWrite)
     357#endif
     358{
     359  AccessUnit::iterator itNalu = accessUnit.begin();
     360
     361  while ( (itNalu!=accessUnit.end())&&
     362    ( (*itNalu)->m_nalUnitType==NAL_UNIT_ACCESS_UNIT_DELIMITER
     363    || (*itNalu)->m_nalUnitType==NAL_UNIT_VPS
     364    || (*itNalu)->m_nalUnitType==NAL_UNIT_SPS
     365    || (*itNalu)->m_nalUnitType==NAL_UNIT_PPS
     366    ))
     367  {
     368    itNalu++;
     369  }
     370
     371  SEIMessages localMessages = seiMessages;
     372  SEIMessages currentMessages;
     373 
     374#if ENC_DEC_TRACE
     375  g_HLSTraceEnable = !testWrite;
     376#endif
     377  // The case that a specific SEI is not present is handled in xWriteSEI (empty list)
     378
     379  // Active parameter sets SEI must always be the first SEI
     380  currentMessages = extractSeisByType(localMessages, SEI::ACTIVE_PARAMETER_SETS);
     381  assert (currentMessages.size() <= 1);
     382#if O0164_MULTI_LAYER_HRD
     383  xWriteSEI(NAL_UNIT_PREFIX_SEI, currentMessages, accessUnit, itNalu, temporalId, vps, sps, nestingSei, bspNestingSei);
     384#else
     385  xWriteSEI(NAL_UNIT_PREFIX_SEI, currentMessages, accessUnit, itNalu, temporalId, sps);
     386#endif
     387  xClearSEIs(currentMessages, !testWrite);
     388 
     389  // Buffering period SEI must always be following active parameter sets
     390  currentMessages = extractSeisByType(localMessages, SEI::BUFFERING_PERIOD);
     391  assert (currentMessages.size() <= 1);
     392#if O0164_MULTI_LAYER_HRD
     393  xWriteSEI(NAL_UNIT_PREFIX_SEI, currentMessages, accessUnit, itNalu, temporalId, vps, sps, nestingSei, bspNestingSei);
     394#else
     395  xWriteSEI(NAL_UNIT_PREFIX_SEI, currentMessages, accessUnit, itNalu, temporalId, sps);
     396#endif
     397  xClearSEIs(currentMessages, !testWrite);
     398
     399  // Picture timing SEI must always be following buffering period
     400  currentMessages = extractSeisByType(localMessages, SEI::PICTURE_TIMING);
     401  assert (currentMessages.size() <= 1);
     402#if O0164_MULTI_LAYER_HRD
     403  xWriteSEI(NAL_UNIT_PREFIX_SEI, currentMessages, accessUnit, itNalu, temporalId, vps, sps, nestingSei, bspNestingSei);
     404#else
     405  xWriteSEI(NAL_UNIT_PREFIX_SEI, currentMessages, accessUnit, itNalu, temporalId, sps);
     406#endif
     407  xClearSEIs(currentMessages, !testWrite);
     408
     409  // Decoding unit info SEI must always be following picture timing
     410  if (!duInfoSeiMessages.empty())
     411  {
     412    currentMessages.push_back(duInfoSeiMessages.front());
     413    if (!testWrite)
     414    {
     415      duInfoSeiMessages.pop_front();
     416    }
     417#if O0164_MULTI_LAYER_HRD
     418    xWriteSEI(NAL_UNIT_PREFIX_SEI, currentMessages, accessUnit, itNalu, temporalId, vps, sps, nestingSei, bspNestingSei);
     419#else
     420    xWriteSEI(NAL_UNIT_PREFIX_SEI, currentMessages, accessUnit, itNalu, temporalId, sps);
     421#endif
     422    xClearSEIs(currentMessages, !testWrite);
     423  }
     424
     425  // Scalable nesting SEI must always be the following DU info
     426  currentMessages = extractSeisByType(localMessages, SEI::SCALABLE_NESTING);
     427#if O0164_MULTI_LAYER_HRD
     428  xWriteSEISeparately(NAL_UNIT_PREFIX_SEI, currentMessages, accessUnit, itNalu, temporalId, vps, sps, nestingSei, bspNestingSei);
     429#else
     430  xWriteSEISeparately(NAL_UNIT_PREFIX_SEI, currentMessages, accessUnit, itNalu, temporalId, sps);
     431#endif
     432  xClearSEIs(currentMessages, !testWrite);
     433
     434  // And finally everything else one by one
     435#if O0164_MULTI_LAYER_HRD
     436  xWriteSEISeparately(NAL_UNIT_PREFIX_SEI, localMessages, accessUnit, itNalu, temporalId, vps, sps, nestingSei, bspNestingSei);
     437#else
     438  xWriteSEISeparately(NAL_UNIT_PREFIX_SEI, localMessages, accessUnit, itNalu, temporalId, sps);
     439#endif
     440  xClearSEIs(currentMessages, !testWrite);
     441
     442  if (!testWrite)
     443  {
     444    seiMessages.clear();
     445  }
     446}
     447
     448#if O0164_MULTI_LAYER_HRD
     449Void TEncGOP::xWriteLeadingSEIMessages (SEIMessages& seiMessages, SEIMessages& duInfoSeiMessages, AccessUnit &accessUnit, Int temporalId,const TComVPS *vps, const TComSPS *sps, std::deque<DUData> &duData, const SEIScalableNesting* nestingSei, const SEIBspNesting* bspNestingSei)
     450#else
     451Void TEncGOP::xWriteLeadingSEIMessages (SEIMessages& seiMessages, SEIMessages& duInfoSeiMessages, AccessUnit &accessUnit, Int temporalId, const TComSPS *sps, std::deque<DUData> &duData)
     452#endif
     453{
     454  AccessUnit testAU;
     455  SEIMessages picTimingSEIs = getSeisByType(seiMessages, SEI::PICTURE_TIMING);
     456  assert (picTimingSEIs.size() < 2);
     457  SEIPictureTiming * picTiming = picTimingSEIs.empty() ? NULL : (SEIPictureTiming*) picTimingSEIs.front();
     458
     459  // test writing
     460#if O0164_MULTI_LAYER_HRD
     461  xWriteLeadingSEIOrdered(seiMessages, duInfoSeiMessages, testAU, temporalId, vps, sps, true, nestingSei, bspNestingSei);
     462#else
     463  xWriteLeadingSEIOrdered(seiMessages, duInfoSeiMessages, testAU, temporalId, sps, true);
     464#endif
     465  // update Timing and DU info SEI
     466  xUpdateDuData(testAU, duData);
     467  xUpdateTimingSEI(picTiming, duData, sps);
     468  xUpdateDuInfoSEI(duInfoSeiMessages, picTiming);
     469  // actual writing
     470#if O0164_MULTI_LAYER_HRD
     471  xWriteLeadingSEIOrdered(seiMessages, duInfoSeiMessages, accessUnit, temporalId, vps, sps, false, nestingSei, bspNestingSei);
     472#else
     473  xWriteLeadingSEIOrdered(seiMessages, duInfoSeiMessages, accessUnit, temporalId, sps, false);
     474#endif
     475
     476  // testAU will automatically be cleaned up when losing scope
     477}
     478
     479#if O0164_MULTI_LAYER_HRD
     480Void TEncGOP::xWriteTrailingSEIMessages (SEIMessages& seiMessages, AccessUnit &accessUnit, Int temporalId, const TComVPS *vps, const TComSPS *sps, const SEIScalableNesting* nestingSei, const SEIBspNesting* bspNestingSei)
     481#else
     482Void TEncGOP::xWriteTrailingSEIMessages (SEIMessages& seiMessages, AccessUnit &accessUnit, Int temporalId, const TComSPS *sps)
     483#endif
     484{
     485  // Note: using accessUnit.end() works only as long as this function is called after slice coding and before EOS/EOB NAL units
     486  AccessUnit::iterator pos = accessUnit.end();
     487#if O0164_MULTI_LAYER_HRD
     488  xWriteSEISeparately(NAL_UNIT_SUFFIX_SEI, seiMessages, accessUnit, pos, temporalId, vps, sps, nestingSei, bspNestingSei);
     489#else
     490  xWriteSEISeparately(NAL_UNIT_SUFFIX_SEI, seiMessages, accessUnit, pos, temporalId, sps);
     491#endif
     492}
     493
     494#if O0164_MULTI_LAYER_HRD
     495Void TEncGOP::xWriteDuSEIMessages (SEIMessages& duInfoSeiMessages, AccessUnit &accessUnit, Int temporalId, const TComVPS *vps, const TComSPS *sps, std::deque<DUData> &duData, const SEIScalableNesting* nestingSei, const SEIBspNesting* bspNestingSei)
     496#else
     497Void TEncGOP::xWriteDuSEIMessages (SEIMessages& duInfoSeiMessages, AccessUnit &accessUnit, Int temporalId, const TComSPS *sps, std::deque<DUData> &duData)
     498#endif
     499{
     500  const TComHRD *hrd = sps->getVuiParameters()->getHrdParameters();
     501
     502  if( m_pcCfg->getDecodingUnitInfoSEIEnabled() && hrd->getSubPicCpbParamsPresentFlag() )
     503  {
     504    Int naluIdx = 0;
     505    AccessUnit::iterator nalu = accessUnit.begin();
     506
     507    // skip over first DU, we have a DU info SEI there already
     508    while (naluIdx < duData[0].accumNalsDU && nalu!=accessUnit.end())
     509    {
     510      naluIdx++;
     511      nalu++;
     512    }
     513
     514    SEIMessages::iterator duSEI = duInfoSeiMessages.begin();
     515    // loop over remaining DUs
     516    for (Int duIdx = 1; duIdx < duData.size(); duIdx++)
     517    {
     518      if (duSEI == duInfoSeiMessages.end())
     519      {
     520        // if the number of generated SEIs matches the number of DUs, this should not happen
     521        assert (false);
     522        return;
     523      }
     524      // write the next SEI
     525      SEIMessages tmpSEI;
     526      tmpSEI.push_back(*duSEI);
     527#if O0164_MULTI_LAYER_HRD
     528      xWriteSEI(NAL_UNIT_PREFIX_SEI, tmpSEI, accessUnit, nalu, temporalId, vps, sps, nestingSei, bspNestingSei);
     529#else
     530      xWriteSEI(NAL_UNIT_PREFIX_SEI, tmpSEI, accessUnit, nalu, temporalId, sps);
     531#endif
     532      // nalu points to the position after the SEI, so we have to increase the index as well
     533      naluIdx++;
     534      while ((naluIdx < duData[duIdx].accumNalsDU) && nalu!=accessUnit.end())
     535      {
     536        naluIdx++;
     537        nalu++;
     538      }
     539      duSEI++;
     540    }
     541  }
     542  deleteSEIs(duInfoSeiMessages);
     543}
     544
     545
     546Void TEncGOP::xCreateIRAPLeadingSEIMessages (SEIMessages& seiMessages, const TComSPS *sps, const TComPPS *pps)
     547{
     548  OutputNALUnit nalu(NAL_UNIT_PREFIX_SEI);
     549
    224550#if R0247_SEI_ACTIVE
    225   seiActiveParameterSets->numSpsIdsMinus1 = m_pcCfg->getNumLayer()-1;
    226   seiActiveParameterSets->activeSeqParameterSetId.resize(seiActiveParameterSets->numSpsIdsMinus1 + 1);
    227   seiActiveParameterSets->layerSpsIdx.resize(seiActiveParameterSets->numSpsIdsMinus1+ 1); 
    228   for (Int c=0; c <= seiActiveParameterSets->numSpsIdsMinus1; c++)
    229   {
    230      seiActiveParameterSets->activeSeqParameterSetId[c] = c;
    231   }
    232   for (Int c=1; c <= seiActiveParameterSets->numSpsIdsMinus1; c++)
    233   {
    234      seiActiveParameterSets->layerSpsIdx[c] = c;
    235   }
    236 #else
    237   seiActiveParameterSets->numSpsIdsMinus1 = 0;
    238   seiActiveParameterSets->activeSeqParameterSetId.resize(seiActiveParameterSets->numSpsIdsMinus1 + 1);
    239   seiActiveParameterSets->activeSeqParameterSetId[0] = sps->getSPSId();
    240 #endif
    241   return seiActiveParameterSets;
    242 }
    243 
    244 SEIFramePacking* TEncGOP::xCreateSEIFramePacking()
    245 {
    246   SEIFramePacking *seiFramePacking = new SEIFramePacking();
    247   seiFramePacking->m_arrangementId = m_pcCfg->getFramePackingArrangementSEIId();
    248   seiFramePacking->m_arrangementCancelFlag = 0;
    249   seiFramePacking->m_arrangementType = m_pcCfg->getFramePackingArrangementSEIType();
    250   assert((seiFramePacking->m_arrangementType > 2) && (seiFramePacking->m_arrangementType < 6) );
    251   seiFramePacking->m_quincunxSamplingFlag = m_pcCfg->getFramePackingArrangementSEIQuincunx();
    252   seiFramePacking->m_contentInterpretationType = m_pcCfg->getFramePackingArrangementSEIInterpretation();
    253   seiFramePacking->m_spatialFlippingFlag = 0;
    254   seiFramePacking->m_frame0FlippedFlag = 0;
    255   seiFramePacking->m_fieldViewsFlag = (seiFramePacking->m_arrangementType == 2);
    256   seiFramePacking->m_currentFrameIsFrame0Flag = ((seiFramePacking->m_arrangementType == 5) && (m_iNumPicCoded&1));
    257   seiFramePacking->m_frame0SelfContainedFlag = 0;
    258   seiFramePacking->m_frame1SelfContainedFlag = 0;
    259   seiFramePacking->m_frame0GridPositionX = 0;
    260   seiFramePacking->m_frame0GridPositionY = 0;
    261   seiFramePacking->m_frame1GridPositionX = 0;
    262   seiFramePacking->m_frame1GridPositionY = 0;
    263   seiFramePacking->m_arrangementReservedByte = 0;
    264   seiFramePacking->m_arrangementPersistenceFlag = true;
    265   seiFramePacking->m_upsampledAspectRatio = 0;
    266   return seiFramePacking;
    267 }
    268 
    269 SEISegmentedRectFramePacking* TEncGOP::xCreateSEISegmentedRectFramePacking()
    270 {
    271   SEISegmentedRectFramePacking *seiSegmentedRectFramePacking = new SEISegmentedRectFramePacking();
    272   seiSegmentedRectFramePacking->m_arrangementCancelFlag = m_pcCfg->getSegmentedRectFramePackingArrangementSEICancel();
    273   seiSegmentedRectFramePacking->m_contentInterpretationType = m_pcCfg->getSegmentedRectFramePackingArrangementSEIType();
    274   seiSegmentedRectFramePacking->m_arrangementPersistenceFlag = m_pcCfg->getSegmentedRectFramePackingArrangementSEIPersistence();
    275   return seiSegmentedRectFramePacking;
    276 }
    277 
    278 SEIDisplayOrientation* TEncGOP::xCreateSEIDisplayOrientation()
    279 {
    280   SEIDisplayOrientation *seiDisplayOrientation = new SEIDisplayOrientation();
    281   seiDisplayOrientation->cancelFlag = false;
    282   seiDisplayOrientation->horFlip = false;
    283   seiDisplayOrientation->verFlip = false;
    284   seiDisplayOrientation->anticlockwiseRotation = m_pcCfg->getDisplayOrientationSEIAngle();
    285   return seiDisplayOrientation;
    286 }
    287 SEIToneMappingInfo*  TEncGOP::xCreateSEIToneMappingInfo()
    288 {
    289   SEIToneMappingInfo *seiToneMappingInfo = new SEIToneMappingInfo();
    290   seiToneMappingInfo->m_toneMapId = m_pcCfg->getTMISEIToneMapId();
    291   seiToneMappingInfo->m_toneMapCancelFlag = m_pcCfg->getTMISEIToneMapCancelFlag();
    292   seiToneMappingInfo->m_toneMapPersistenceFlag = m_pcCfg->getTMISEIToneMapPersistenceFlag();
    293 
    294   seiToneMappingInfo->m_codedDataBitDepth = m_pcCfg->getTMISEICodedDataBitDepth();
    295   assert(seiToneMappingInfo->m_codedDataBitDepth >= 8 && seiToneMappingInfo->m_codedDataBitDepth <= 14);
    296   seiToneMappingInfo->m_targetBitDepth = m_pcCfg->getTMISEITargetBitDepth();
    297   assert(seiToneMappingInfo->m_targetBitDepth >= 1 && seiToneMappingInfo->m_targetBitDepth <= 17);
    298   seiToneMappingInfo->m_modelId = m_pcCfg->getTMISEIModelID();
    299   assert(seiToneMappingInfo->m_modelId >=0 &&seiToneMappingInfo->m_modelId<=4);
    300 
    301   switch( seiToneMappingInfo->m_modelId)
    302   {
    303   case 0:
    304     {
    305       seiToneMappingInfo->m_minValue = m_pcCfg->getTMISEIMinValue();
    306       seiToneMappingInfo->m_maxValue = m_pcCfg->getTMISEIMaxValue();
    307       break;
    308     }
    309   case 1:
    310     {
    311       seiToneMappingInfo->m_sigmoidMidpoint = m_pcCfg->getTMISEISigmoidMidpoint();
    312       seiToneMappingInfo->m_sigmoidWidth = m_pcCfg->getTMISEISigmoidWidth();
    313       break;
    314     }
    315   case 2:
    316     {
    317       UInt num = 1u<<(seiToneMappingInfo->m_targetBitDepth);
    318       seiToneMappingInfo->m_startOfCodedInterval.resize(num);
    319       Int* ptmp = m_pcCfg->getTMISEIStartOfCodedInterva();
    320       if(ptmp)
    321       {
    322         for(Int i=0; i<num;i++)
    323         {
    324           seiToneMappingInfo->m_startOfCodedInterval[i] = ptmp[i];
    325         }
    326       }
    327       break;
    328     }
    329   case 3:
    330     {
    331       seiToneMappingInfo->m_numPivots = m_pcCfg->getTMISEINumPivots();
    332       seiToneMappingInfo->m_codedPivotValue.resize(seiToneMappingInfo->m_numPivots);
    333       seiToneMappingInfo->m_targetPivotValue.resize(seiToneMappingInfo->m_numPivots);
    334       Int* ptmpcoded = m_pcCfg->getTMISEICodedPivotValue();
    335       Int* ptmptarget = m_pcCfg->getTMISEITargetPivotValue();
    336       if(ptmpcoded&&ptmptarget)
    337       {
    338         for(Int i=0; i<(seiToneMappingInfo->m_numPivots);i++)
    339         {
    340           seiToneMappingInfo->m_codedPivotValue[i]=ptmpcoded[i];
    341           seiToneMappingInfo->m_targetPivotValue[i]=ptmptarget[i];
    342          }
    343        }
    344        break;
    345      }
    346   case 4:
    347      {
    348        seiToneMappingInfo->m_cameraIsoSpeedIdc = m_pcCfg->getTMISEICameraIsoSpeedIdc();
    349        seiToneMappingInfo->m_cameraIsoSpeedValue = m_pcCfg->getTMISEICameraIsoSpeedValue();
    350        assert( seiToneMappingInfo->m_cameraIsoSpeedValue !=0 );
    351        seiToneMappingInfo->m_exposureIndexIdc = m_pcCfg->getTMISEIExposurIndexIdc();
    352        seiToneMappingInfo->m_exposureIndexValue = m_pcCfg->getTMISEIExposurIndexValue();
    353        assert( seiToneMappingInfo->m_exposureIndexValue !=0 );
    354        seiToneMappingInfo->m_exposureCompensationValueSignFlag = m_pcCfg->getTMISEIExposureCompensationValueSignFlag();
    355        seiToneMappingInfo->m_exposureCompensationValueNumerator = m_pcCfg->getTMISEIExposureCompensationValueNumerator();
    356        seiToneMappingInfo->m_exposureCompensationValueDenomIdc = m_pcCfg->getTMISEIExposureCompensationValueDenomIdc();
    357        seiToneMappingInfo->m_refScreenLuminanceWhite = m_pcCfg->getTMISEIRefScreenLuminanceWhite();
    358        seiToneMappingInfo->m_extendedRangeWhiteLevel = m_pcCfg->getTMISEIExtendedRangeWhiteLevel();
    359        assert( seiToneMappingInfo->m_extendedRangeWhiteLevel >= 100 );
    360        seiToneMappingInfo->m_nominalBlackLevelLumaCodeValue = m_pcCfg->getTMISEINominalBlackLevelLumaCodeValue();
    361        seiToneMappingInfo->m_nominalWhiteLevelLumaCodeValue = m_pcCfg->getTMISEINominalWhiteLevelLumaCodeValue();
    362        assert( seiToneMappingInfo->m_nominalWhiteLevelLumaCodeValue > seiToneMappingInfo->m_nominalBlackLevelLumaCodeValue );
    363        seiToneMappingInfo->m_extendedWhiteLevelLumaCodeValue = m_pcCfg->getTMISEIExtendedWhiteLevelLumaCodeValue();
    364        assert( seiToneMappingInfo->m_extendedWhiteLevelLumaCodeValue >= seiToneMappingInfo->m_nominalWhiteLevelLumaCodeValue );
    365        break;
    366     }
    367   default:
    368     {
    369       assert(!"Undefined SEIToneMapModelId");
    370       break;
    371     }
    372   }
    373   return seiToneMappingInfo;
    374 }
    375 
    376 SEITempMotionConstrainedTileSets* TEncGOP::xCreateSEITempMotionConstrainedTileSets (const TComPPS *pps)
    377 {
    378   SEITempMotionConstrainedTileSets *sei = new SEITempMotionConstrainedTileSets();
    379   if(pps->getTilesEnabledFlag())
    380   {
    381     sei->m_mc_all_tiles_exact_sample_value_match_flag = false;
    382     sei->m_each_tile_one_tile_set_flag                = false;
    383     sei->m_limited_tile_set_display_flag              = false;
    384     sei->setNumberOfTileSets((pps->getNumTileColumnsMinus1() + 1) * (pps->getNumTileRowsMinus1() + 1));
    385 
    386     for(Int i=0; i < sei->getNumberOfTileSets(); i++)
    387     {
    388       sei->tileSetData(i).m_mcts_id = i;  //depends the application;
    389       sei->tileSetData(i).setNumberOfTileRects(1);
    390 
    391       for(Int j=0; j<sei->tileSetData(i).getNumberOfTileRects(); j++)
    392       {
    393         sei->tileSetData(i).topLeftTileIndex(j)     = i+j;
    394         sei->tileSetData(i).bottomRightTileIndex(j) = i+j;
    395       }
    396 
    397       sei->tileSetData(i).m_exact_sample_value_match_flag    = false;
    398       sei->tileSetData(i).m_mcts_tier_level_idc_present_flag = false;
    399     }
    400   }
    401   else
    402   {
    403     assert(!"Tile is not enabled");
    404   }
    405   return sei;
    406 }
    407 
    408 SEIKneeFunctionInfo* TEncGOP::xCreateSEIKneeFunctionInfo()
    409 {
    410   SEIKneeFunctionInfo *seiKneeFunctionInfo = new SEIKneeFunctionInfo();
    411   seiKneeFunctionInfo->m_kneeId = m_pcCfg->getKneeSEIId();
    412   seiKneeFunctionInfo->m_kneeCancelFlag = m_pcCfg->getKneeSEICancelFlag();
    413   if ( !seiKneeFunctionInfo->m_kneeCancelFlag )
    414   {
    415     seiKneeFunctionInfo->m_kneePersistenceFlag = m_pcCfg->getKneeSEIPersistenceFlag();
    416     seiKneeFunctionInfo->m_kneeInputDrange = m_pcCfg->getKneeSEIInputDrange();
    417     seiKneeFunctionInfo->m_kneeInputDispLuminance = m_pcCfg->getKneeSEIInputDispLuminance();
    418     seiKneeFunctionInfo->m_kneeOutputDrange = m_pcCfg->getKneeSEIOutputDrange();
    419     seiKneeFunctionInfo->m_kneeOutputDispLuminance = m_pcCfg->getKneeSEIOutputDispLuminance();
    420 
    421     seiKneeFunctionInfo->m_kneeNumKneePointsMinus1 = m_pcCfg->getKneeSEINumKneePointsMinus1();
    422     Int* piInputKneePoint  = m_pcCfg->getKneeSEIInputKneePoint();
    423     Int* piOutputKneePoint = m_pcCfg->getKneeSEIOutputKneePoint();
    424     if(piInputKneePoint&&piOutputKneePoint)
    425     {
    426       seiKneeFunctionInfo->m_kneeInputKneePoint.resize(seiKneeFunctionInfo->m_kneeNumKneePointsMinus1+1);
    427       seiKneeFunctionInfo->m_kneeOutputKneePoint.resize(seiKneeFunctionInfo->m_kneeNumKneePointsMinus1+1);
    428       for(Int i=0; i<=seiKneeFunctionInfo->m_kneeNumKneePointsMinus1; i++)
    429       {
    430         seiKneeFunctionInfo->m_kneeInputKneePoint[i] = piInputKneePoint[i];
    431         seiKneeFunctionInfo->m_kneeOutputKneePoint[i] = piOutputKneePoint[i];
    432        }
    433     }
    434   }
    435   return seiKneeFunctionInfo;
    436 }
    437 
    438 SEIChromaSamplingFilterHint* TEncGOP::xCreateSEIChromaSamplingFilterHint(Bool bChromaLocInfoPresent, Int iHorFilterIndex, Int iVerFilterIndex)
    439 {
    440   SEIChromaSamplingFilterHint *seiChromaSamplingFilterHint = new SEIChromaSamplingFilterHint();
    441   seiChromaSamplingFilterHint->m_verChromaFilterIdc = iVerFilterIndex;
    442   seiChromaSamplingFilterHint->m_horChromaFilterIdc = iHorFilterIndex;
    443   seiChromaSamplingFilterHint->m_verFilteringProcessFlag = 1;
    444   seiChromaSamplingFilterHint->m_targetFormatIdc = 3;
    445   seiChromaSamplingFilterHint->m_perfectReconstructionFlag = false;
    446   if(seiChromaSamplingFilterHint->m_verChromaFilterIdc == 1)
    447   {
    448     seiChromaSamplingFilterHint->m_numVerticalFilters = 1;
    449     seiChromaSamplingFilterHint->m_verTapLengthMinus1 = (Int*)malloc(seiChromaSamplingFilterHint->m_numVerticalFilters * sizeof(Int));
    450     seiChromaSamplingFilterHint->m_verFilterCoeff =    (Int**)malloc(seiChromaSamplingFilterHint->m_numVerticalFilters * sizeof(Int*));
    451     for(Int i = 0; i < seiChromaSamplingFilterHint->m_numVerticalFilters; i ++)
    452     {
    453       seiChromaSamplingFilterHint->m_verTapLengthMinus1[i] = 0;
    454       seiChromaSamplingFilterHint->m_verFilterCoeff[i] = (Int*)malloc(seiChromaSamplingFilterHint->m_verTapLengthMinus1[i] * sizeof(Int));
    455       for(Int j = 0; j < seiChromaSamplingFilterHint->m_verTapLengthMinus1[i]; j ++)
    456       {
    457         seiChromaSamplingFilterHint->m_verFilterCoeff[i][j] = 0;
    458       }
    459     }
    460   }
    461   else
    462   {
    463     seiChromaSamplingFilterHint->m_numVerticalFilters = 0;
    464     seiChromaSamplingFilterHint->m_verTapLengthMinus1 = NULL;
    465     seiChromaSamplingFilterHint->m_verFilterCoeff = NULL;
    466   }
    467   if(seiChromaSamplingFilterHint->m_horChromaFilterIdc == 1)
    468   {
    469     seiChromaSamplingFilterHint->m_numHorizontalFilters = 1;
    470     seiChromaSamplingFilterHint->m_horTapLengthMinus1 = (Int*)malloc(seiChromaSamplingFilterHint->m_numHorizontalFilters * sizeof(Int));
    471     seiChromaSamplingFilterHint->m_horFilterCoeff = (Int**)malloc(seiChromaSamplingFilterHint->m_numHorizontalFilters * sizeof(Int*));
    472     for(Int i = 0; i < seiChromaSamplingFilterHint->m_numHorizontalFilters; i ++)
    473     {
    474       seiChromaSamplingFilterHint->m_horTapLengthMinus1[i] = 0;
    475       seiChromaSamplingFilterHint->m_horFilterCoeff[i] = (Int*)malloc(seiChromaSamplingFilterHint->m_horTapLengthMinus1[i] * sizeof(Int));
    476       for(Int j = 0; j < seiChromaSamplingFilterHint->m_horTapLengthMinus1[i]; j ++)
    477       {
    478         seiChromaSamplingFilterHint->m_horFilterCoeff[i][j] = 0;
    479       }
    480     }
    481   }
    482   else
    483   {
    484     seiChromaSamplingFilterHint->m_numHorizontalFilters = 0;
    485     seiChromaSamplingFilterHint->m_horTapLengthMinus1 = NULL;
    486     seiChromaSamplingFilterHint->m_horFilterCoeff = NULL;
    487   }
    488   return seiChromaSamplingFilterHint;
    489 }
    490 
    491 Void TEncGOP::xCreateLeadingSEIMessages (/*SEIMessages seiMessages,*/ AccessUnit &accessUnit, const TComSPS *sps, const TComPPS *pps)
    492 {
    493   OutputNALUnit nalu(NAL_UNIT_PREFIX_SEI);
    494 
    495   if(m_pcCfg->getActiveParameterSetsSEIEnabled()
    496 #if R0247_SEI_ACTIVE
    497     && m_layerId == 0
    498 #endif
    499     )
    500   {
    501     SEIActiveParameterSets *sei = xCreateSEIActiveParameterSets (sps);
    502 
    503     //nalu = NALUnit(NAL_UNIT_PREFIX_SEI);
    504     m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
    505 #if O0164_MULTI_LAYER_HRD
    506     m_seiWriter.writeSEImessage(nalu.m_Bitstream, *sei, m_pcEncTop->getVPS(), sps);
    507 #else
    508     m_seiWriter.writeSEImessage(nalu.m_Bitstream, *sei, sps);
    509 #endif
    510     writeRBSPTrailingBits(nalu.m_Bitstream);
    511     accessUnit.push_back(new NALUnitEBSP(nalu));
    512     delete sei;
     551  if(m_pcCfg->getActiveParameterSetsSEIEnabled() && m_layerId == 0 )
     552#else
     553  if(m_pcCfg->getActiveParameterSetsSEIEnabled())
     554#endif
     555  {
     556    SEIActiveParameterSets *sei = new SEIActiveParameterSets;
     557    m_seiEncoder.initSEIActiveParameterSets (sei, m_pcCfg->getVPS(), sps);
     558    seiMessages.push_back(sei);
    513559    m_activeParameterSetSEIPresentInAU = true;
    514560  }
     
    516562  if(m_pcCfg->getFramePackingArrangementSEIEnabled())
    517563  {
    518     SEIFramePacking *sei = xCreateSEIFramePacking ();
    519 
    520     nalu = NALUnit(NAL_UNIT_PREFIX_SEI);
    521     m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
    522 #if O0164_MULTI_LAYER_HRD
    523     m_seiWriter.writeSEImessage(nalu.m_Bitstream, *sei, m_pcEncTop->getVPS(), sps);
    524 #else
    525     m_seiWriter.writeSEImessage(nalu.m_Bitstream, *sei, sps);
    526 #endif
    527     writeRBSPTrailingBits(nalu.m_Bitstream);
    528     accessUnit.push_back(new NALUnitEBSP(nalu));
    529     delete sei;
    530   }
     564    SEIFramePacking *sei = new SEIFramePacking;
     565    m_seiEncoder.initSEIFramePacking (sei, m_iNumPicCoded);
     566    seiMessages.push_back(sei);
     567  }
     568
    531569  if(m_pcCfg->getSegmentedRectFramePackingArrangementSEIEnabled())
    532570  {
    533     SEISegmentedRectFramePacking *sei = xCreateSEISegmentedRectFramePacking ();
    534 
    535     nalu = NALUnit(NAL_UNIT_PREFIX_SEI);
    536     m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
    537 #if O0164_MULTI_LAYER_HRD
    538     m_seiWriter.writeSEImessage(nalu.m_Bitstream, *sei, m_pcEncTop->getVPS(), sps);
    539 #else
    540     m_seiWriter.writeSEImessage(nalu.m_Bitstream, *sei, sps);
    541 #endif
    542     writeRBSPTrailingBits(nalu.m_Bitstream);
    543     accessUnit.push_back(new NALUnitEBSP(nalu));
    544     delete sei;
    545   }
     571    SEISegmentedRectFramePacking *sei = new SEISegmentedRectFramePacking;
     572    m_seiEncoder.initSEISegmentedRectFramePacking(sei);
     573    seiMessages.push_back(sei);
     574  }
     575
    546576  if (m_pcCfg->getDisplayOrientationSEIAngle())
    547577  {
    548     SEIDisplayOrientation *sei = xCreateSEIDisplayOrientation();
    549 
    550     nalu = NALUnit(NAL_UNIT_PREFIX_SEI);
    551     m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
    552 #if O0164_MULTI_LAYER_HRD
    553     m_seiWriter.writeSEImessage(nalu.m_Bitstream, *sei, m_pcEncTop->getVPS(), sps);
    554 #else
    555     m_seiWriter.writeSEImessage(nalu.m_Bitstream, *sei, sps);
    556 #endif
    557     writeRBSPTrailingBits(nalu.m_Bitstream);
    558     accessUnit.push_back(new NALUnitEBSP(nalu));
    559     delete sei;
     578    SEIDisplayOrientation *sei = new SEIDisplayOrientation;
     579    m_seiEncoder.initSEIDisplayOrientation(sei);
     580    seiMessages.push_back(sei);
    560581  }
    561582
    562583  if(m_pcCfg->getToneMappingInfoSEIEnabled())
    563584  {
    564     SEIToneMappingInfo *sei = xCreateSEIToneMappingInfo ();
    565 
    566     nalu = NALUnit(NAL_UNIT_PREFIX_SEI);
    567     m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
    568 #if O0164_MULTI_LAYER_HRD
    569     m_seiWriter.writeSEImessage(nalu.m_Bitstream, *sei, m_pcEncTop->getVPS(), sps);
    570 #else
    571     m_seiWriter.writeSEImessage(nalu.m_Bitstream, *sei, sps);
    572 #endif
    573     writeRBSPTrailingBits(nalu.m_Bitstream);
    574     accessUnit.push_back(new NALUnitEBSP(nalu));
    575     delete sei;
     585    SEIToneMappingInfo *sei = new SEIToneMappingInfo;
     586    m_seiEncoder.initSEIToneMappingInfo (sei);
     587    seiMessages.push_back(sei);
    576588  }
    577589
    578590  if(m_pcCfg->getTMCTSSEIEnabled())
    579591  {
    580     SEITempMotionConstrainedTileSets *sei_tmcts = xCreateSEITempMotionConstrainedTileSets (pps);
    581 
    582     nalu = NALUnit(NAL_UNIT_PREFIX_SEI);
    583     m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
    584 #if O0164_MULTI_LAYER_HRD
    585     m_seiWriter.writeSEImessage(nalu.m_Bitstream, *sei_tmcts, m_pcEncTop->getVPS(), sps);
    586 #else
    587     m_seiWriter.writeSEImessage(nalu.m_Bitstream, *sei_tmcts, sps);
    588 #endif
    589     writeRBSPTrailingBits(nalu.m_Bitstream);
    590     accessUnit.push_back(new NALUnitEBSP(nalu));
    591     delete sei_tmcts;
     592    SEITempMotionConstrainedTileSets *sei = new SEITempMotionConstrainedTileSets;
     593    m_seiEncoder.initSEITempMotionConstrainedTileSets(sei, pps);
     594    seiMessages.push_back(sei);
    592595  }
    593596
    594597  if(m_pcCfg->getTimeCodeSEIEnabled())
    595598  {
    596     SEITimeCode sei_time_code;
    597     //  Set data as per command line options
    598     sei_time_code.numClockTs = m_pcCfg->getNumberOfTimesets();
    599     for(Int i = 0; i < sei_time_code.numClockTs; i++)
    600     {
    601       sei_time_code.timeSetArray[i] = m_pcCfg->getTimeSet(i);
    602     }
    603 
    604     nalu = NALUnit(NAL_UNIT_PREFIX_SEI);
    605     m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
    606 #if O0164_MULTI_LAYER_HRD
    607     m_seiWriter.writeSEImessage(nalu.m_Bitstream, sei_time_code, m_pcEncTop->getVPS(), sps);
    608 #else
    609     m_seiWriter.writeSEImessage(nalu.m_Bitstream, sei_time_code, sps);
    610 #endif
    611     writeRBSPTrailingBits(nalu.m_Bitstream);
    612     accessUnit.push_back(new NALUnitEBSP(nalu));
     599    SEITimeCode *seiTimeCode = new SEITimeCode;
     600    m_seiEncoder.initSEITimeCode(seiTimeCode);
     601    seiMessages.push_back(seiTimeCode);
    613602  }
    614603
    615604  if(m_pcCfg->getKneeSEIEnabled())
    616605  {
    617     SEIKneeFunctionInfo *sei = xCreateSEIKneeFunctionInfo();
    618 
    619     nalu = NALUnit(NAL_UNIT_PREFIX_SEI);
    620     m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
    621 #if O0164_MULTI_LAYER_HRD
    622     m_seiWriter.writeSEImessage(nalu.m_Bitstream, *sei, m_pcEncTop->getVPS(), sps);
    623 #else
    624     m_seiWriter.writeSEImessage(nalu.m_Bitstream, *sei, sps);
    625 #endif
    626     writeRBSPTrailingBits(nalu.m_Bitstream);
    627     accessUnit.push_back(new NALUnitEBSP(nalu));
    628     delete sei;
     606    SEIKneeFunctionInfo *sei = new SEIKneeFunctionInfo;
     607    m_seiEncoder.initSEIKneeFunctionInfo(sei);
     608    seiMessages.push_back(sei);
    629609  }
    630610   
     
    632612  {
    633613    const TComSEIMasteringDisplay &seiCfg=m_pcCfg->getMasteringDisplaySEI();
    634     SEIMasteringDisplayColourVolume mdcv;
    635     mdcv.values = seiCfg;
    636 
    637     nalu = NALUnit(NAL_UNIT_PREFIX_SEI);
    638     m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
    639 #if O0164_MULTI_LAYER_HRD
    640     m_seiWriter.writeSEImessage(nalu.m_Bitstream, mdcv, m_pcEncTop->getVPS(), sps);
    641 #else
    642     m_seiWriter.writeSEImessage(nalu.m_Bitstream, mdcv, sps);
    643 #endif
    644     writeRBSPTrailingBits(nalu.m_Bitstream);
    645     accessUnit.push_back(new NALUnitEBSP(nalu));
    646      
     614    SEIMasteringDisplayColourVolume *sei = new SEIMasteringDisplayColourVolume;
     615    sei->values = seiCfg;
     616    seiMessages.push_back(sei);
    647617  }
    648618
     
    651621  if(m_pcCfg->getLayersNotPresentSEIEnabled())
    652622  {
    653     SEILayersNotPresent *sei = xCreateSEILayersNotPresent ();
    654     m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
    655 #if O0164_MULTI_LAYER_HRD
    656     m_seiWriter.writeSEImessage(nalu.m_Bitstream, *sei, m_pcEncTop->getVPS(), sps);
    657 #else
    658     m_seiWriter.writeSEImessage(nalu.m_Bitstream, *sei, sps);
    659 #endif
    660     writeRBSPTrailingBits(nalu.m_Bitstream);
    661     accessUnit.push_back(new NALUnitEBSP(nalu));
    662     delete sei;
     623    SEILayersNotPresent *sei = new SEILayersNotPresent;
     624    m_seiEncoder.initSEILayersNotPresent(sei);
     625    seiMessages.push_back(sei);
    663626  }
    664627#endif
     
    667630  if(m_pcCfg->getInterLayerConstrainedTileSetsSEIEnabled())
    668631  {
    669     SEIInterLayerConstrainedTileSets *sei = xCreateSEIInterLayerConstrainedTileSets ();
    670 
    671     nalu = NALUnit(NAL_UNIT_PREFIX_SEI, 0, m_pcCfg->getNumLayer()-1); // For highest layer
    672     m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
    673 #if O0164_MULTI_LAYER_HRD
    674     m_seiWriter.writeSEImessage(nalu.m_Bitstream, *sei, m_pcEncTop->getVPS(), sps);
    675 #else
    676     m_seiWriter.writeSEImessage(nalu.m_Bitstream, *sei, sps);
    677 #endif
    678     writeRBSPTrailingBits(nalu.m_Bitstream);
    679     accessUnit.push_back(new NALUnitEBSP(nalu));
    680     delete sei;
     632    SEIInterLayerConstrainedTileSets *sei = new SEIInterLayerConstrainedTileSets;
     633    m_seiEncoder.initSEIInterLayerConstrainedTileSets(sei);
     634
     635    // nalu = NALUnit(NAL_UNIT_PREFIX_SEI, 0, m_pcCfg->getNumLayer()-1); // For highest layer //ToDo(VS)
     636    seiMessages.push_back(sei);
    681637  }
    682638#endif
     
    685641  if( m_pcCfg->getAlphaSEIEnabled() && m_pcEncTop->getVPS()->getScalabilityId(m_layerId, AUX_ID) && m_pcEncTop->getVPS()->getDimensionId(m_pcEncTop->getVPS()->getLayerIdxInVps(m_layerId), m_pcEncTop->getVPS()->getNumScalabilityTypes() - 1) == AUX_ALPHA )
    686642  {
    687     SEIAlphaChannelInfo *sei = xCreateSEIAlphaChannelInfo();
    688     m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
    689 #if O0164_MULTI_LAYER_HRD
    690     m_seiWriter.writeSEImessage(nalu.m_Bitstream, *sei, m_pcEncTop->getVPS(), sps);
    691 #else
    692     m_seiWriter.writeSEImessage(nalu.m_Bitstream, *sei, sps);
    693 #endif
    694     writeRBSPTrailingBits(nalu.m_Bitstream);
    695     accessUnit.push_back(new NALUnitEBSP(nalu));
    696     delete sei;
     643    SEIAlphaChannelInfo *sei = new SEIAlphaChannelInfo;
     644    m_seiEncoder.initSEIAlphaChannelInfo(sei);
     645    seiMessages.push_back(sei);
    697646  }
    698647#endif
     
    700649#if Q0096_OVERLAY_SEI
    701650  if(m_pcCfg->getOverlaySEIEnabled())
    702   {   
    703     SEIOverlayInfo *sei = xCreateSEIOverlayInfo();       
     651  {
     652    SEIOverlayInfo *sei = new SEIOverlayInfo;
     653    m_seiEncoder.initSEIOverlayInfo(sei);
    704654    m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
     655    seiMessages.push_back(sei);
     656  }
     657#endif
    705658#if O0164_MULTI_LAYER_HRD
    706     m_seiWriter.writeSEImessage(nalu.m_Bitstream, *sei, m_pcEncTop->getVPS(), sps);
    707 #else
    708     m_seiWriter.writeSEImessage(nalu.m_Bitstream, *sei, sps);
    709 #endif
    710     writeRBSPTrailingBits(nalu.m_Bitstream);
    711     accessUnit.push_back(new NALUnitEBSP(nalu));
    712     delete sei;
     659  if( m_layerId == 0 && m_pcEncTop->getVPS()->getVpsVuiBspHrdPresentFlag() )
     660  {
     661    TComVPS *vps = m_pcEncTop->getVPS();
     662    for(Int i = 0; i < vps->getNumOutputLayerSets(); i++)
     663    {
     664      for(Int k = 0; k < vps->getNumSignalledPartitioningSchemes(i); k++)
     665      {
     666        for(Int l = 0; l < vps->getNumPartitionsInSchemeMinus1(i, k)+1; l++)
     667        {
     668          SEIScalableNesting *scalableBspNestingSei = new SEIScalableNesting;
     669          m_seiEncoder.initBspNestingSEI(scalableBspNestingSei, vps, sps, i, k, l);
     670          seiMessages.push_back(scalableBspNestingSei);
     671        }
     672      }
     673    }
    713674  }
    714675#endif
     
    721682  for( Int c=0 ; c<3 ; c++)
    722683  {
    723     if ( m_colourRemapSEIPreLutCodedValue[c] != NULL)
    724     {
    725       delete[] m_colourRemapSEIPreLutCodedValue[c];
    726       m_colourRemapSEIPreLutCodedValue[c] = NULL;
    727     }
    728     if ( m_colourRemapSEIPreLutTargetValue[c] != NULL)
    729     {
    730       delete[] m_colourRemapSEIPreLutTargetValue[c];
    731       m_colourRemapSEIPreLutTargetValue[c] = NULL;
    732     }
    733     if ( m_colourRemapSEIPostLutCodedValue[c] != NULL)
    734     {
    735       delete[] m_colourRemapSEIPostLutCodedValue[c];
    736       m_colourRemapSEIPostLutCodedValue[c] = NULL;
    737     }
    738     if ( m_colourRemapSEIPostLutTargetValue[c] != NULL)
    739     {
    740       delete[] m_colourRemapSEIPostLutTargetValue[c];
    741       m_colourRemapSEIPostLutTargetValue[c] = NULL;
     684    if ( m_seiColourRemappingInfo.m_colourRemapSEIPreLutCodedValue[c] != NULL)
     685    {
     686      delete[] m_seiColourRemappingInfo.m_colourRemapSEIPreLutCodedValue[c];
     687      m_seiColourRemappingInfo.m_colourRemapSEIPreLutCodedValue[c] = NULL;
     688    }
     689    if ( m_seiColourRemappingInfo.m_colourRemapSEIPreLutTargetValue[c] != NULL)
     690    {
     691      delete[] m_seiColourRemappingInfo.m_colourRemapSEIPreLutTargetValue[c];
     692      m_seiColourRemappingInfo.m_colourRemapSEIPreLutTargetValue[c] = NULL;
     693    }
     694    if ( m_seiColourRemappingInfo.m_colourRemapSEIPostLutCodedValue[c] != NULL)
     695    {
     696      delete[] m_seiColourRemappingInfo.m_colourRemapSEIPostLutCodedValue[c];
     697      m_seiColourRemappingInfo.m_colourRemapSEIPostLutCodedValue[c] = NULL;
     698    }
     699    if ( m_seiColourRemappingInfo.m_colourRemapSEIPostLutTargetValue[c] != NULL)
     700    {
     701      delete[] m_seiColourRemappingInfo.m_colourRemapSEIPostLutTargetValue[c];
     702      m_seiColourRemappingInfo.m_colourRemapSEIPostLutTargetValue[c] = NULL;
    742703    }
    743704  }
     
    747708
    748709  // reading external Colour Remapping Information SEI message parameters from file
    749   if( m_colourRemapSEIFile.c_str() )
     710  if( m_seiColourRemappingInfo.m_colourRemapSEIFile.c_str() )
    750711  {
    751712    FILE* fic;
    752713    Int retval;
    753     if((fic = fopen(m_colourRemapSEIFile.c_str(),"r")) == (FILE*)NULL)
     714    if((fic = fopen(m_seiColourRemappingInfo.m_colourRemapSEIFile.c_str(),"r")) == (FILE*)NULL)
    754715    {
    755716      //fprintf(stderr, "Can't open Colour Remapping Information SEI parameters file %s\n", m_colourRemapSEIFile.c_str());
     
    758719    }
    759720    Int tempCode;
    760     retval = fscanf( fic, "%d", &m_colourRemapSEIId );
    761     retval = fscanf( fic, "%d", &tempCode );m_colourRemapSEICancelFlag = tempCode ? 1 : 0;
    762     if( !m_colourRemapSEICancelFlag )
    763     {
    764       retval = fscanf( fic, "%d", &tempCode ); m_colourRemapSEIPersistenceFlag= tempCode ? 1 : 0;
    765       retval = fscanf( fic, "%d", &tempCode); m_colourRemapSEIVideoSignalInfoPresentFlag = tempCode ? 1 : 0;
    766       if( m_colourRemapSEIVideoSignalInfoPresentFlag )
    767       {
    768         retval = fscanf( fic, "%d", &tempCode  ); m_colourRemapSEIFullRangeFlag = tempCode ? 1 : 0;
    769         retval = fscanf( fic, "%d", &m_colourRemapSEIPrimaries );
    770         retval = fscanf( fic, "%d", &m_colourRemapSEITransferFunction );
    771         retval = fscanf( fic, "%d", &m_colourRemapSEIMatrixCoefficients );
    772       }
    773 
    774       retval = fscanf( fic, "%d", &m_colourRemapSEIInputBitDepth );
    775       retval = fscanf( fic, "%d", &m_colourRemapSEIBitDepth );
     721    retval = fscanf( fic, "%d", &m_seiColourRemappingInfo.m_colourRemapSEIId );
     722    retval = fscanf( fic, "%d", &tempCode ); m_seiColourRemappingInfo.m_colourRemapSEICancelFlag = tempCode ? 1 : 0;
     723    if( !m_seiColourRemappingInfo.m_colourRemapSEICancelFlag )
     724    {
     725      retval = fscanf( fic, "%d", &tempCode ); m_seiColourRemappingInfo.m_colourRemapSEIPersistenceFlag= tempCode ? 1 : 0;
     726      retval = fscanf( fic, "%d", &tempCode); m_seiColourRemappingInfo.m_colourRemapSEIVideoSignalInfoPresentFlag = tempCode ? 1 : 0;
     727      if( m_seiColourRemappingInfo.m_colourRemapSEIVideoSignalInfoPresentFlag )
     728      {
     729        retval = fscanf( fic, "%d", &tempCode  ); m_seiColourRemappingInfo.m_colourRemapSEIFullRangeFlag = tempCode ? 1 : 0;
     730        retval = fscanf( fic, "%d", &m_seiColourRemappingInfo.m_colourRemapSEIPrimaries );
     731        retval = fscanf( fic, "%d", &m_seiColourRemappingInfo.m_colourRemapSEITransferFunction );
     732        retval = fscanf( fic, "%d", &m_seiColourRemappingInfo.m_colourRemapSEIMatrixCoefficients );
     733      }
     734
     735      retval = fscanf( fic, "%d", &m_seiColourRemappingInfo.m_colourRemapSEIInputBitDepth );
     736      retval = fscanf( fic, "%d", &m_seiColourRemappingInfo.m_colourRemapSEIBitDepth );
    776737 
    777738      for( Int c=0 ; c<3 ; c++ )
    778739      {
    779         retval = fscanf( fic, "%d", &m_colourRemapSEIPreLutNumValMinus1[c] );
    780         if( m_colourRemapSEIPreLutNumValMinus1[c]>0 )
    781         {
    782           m_colourRemapSEIPreLutCodedValue[c]  = new Int[m_colourRemapSEIPreLutNumValMinus1[c]+1];
    783           m_colourRemapSEIPreLutTargetValue[c] = new Int[m_colourRemapSEIPreLutNumValMinus1[c]+1];
    784           for( Int i=0 ; i<=m_colourRemapSEIPreLutNumValMinus1[c] ; i++ )
     740        retval = fscanf( fic, "%d", &m_seiColourRemappingInfo.m_colourRemapSEIPreLutNumValMinus1[c] );
     741        if( m_seiColourRemappingInfo.m_colourRemapSEIPreLutNumValMinus1[c]>0 )
     742        {
     743          m_seiColourRemappingInfo.m_colourRemapSEIPreLutCodedValue[c]  = new Int[m_seiColourRemappingInfo.m_colourRemapSEIPreLutNumValMinus1[c]+1];
     744          m_seiColourRemappingInfo.m_colourRemapSEIPreLutTargetValue[c] = new Int[m_seiColourRemappingInfo.m_colourRemapSEIPreLutNumValMinus1[c]+1];
     745          for( Int i=0 ; i<=m_seiColourRemappingInfo.m_colourRemapSEIPreLutNumValMinus1[c] ; i++ )
    785746          {
    786             retval = fscanf( fic, "%d", &m_colourRemapSEIPreLutCodedValue[c][i] );
    787             retval = fscanf( fic, "%d", &m_colourRemapSEIPreLutTargetValue[c][i] );
    788           }
    789         }
    790       }
    791 
    792       retval = fscanf( fic, "%d", &tempCode ); m_colourRemapSEIMatrixPresentFlag = tempCode ? 1 : 0;
    793       if( m_colourRemapSEIMatrixPresentFlag )
    794       {
    795         retval = fscanf( fic, "%d", &m_colourRemapSEILog2MatrixDenom );
     747            retval = fscanf( fic, "%d", &m_seiColourRemappingInfo.m_colourRemapSEIPreLutCodedValue[c][i] );
     748            retval = fscanf( fic, "%d", &m_seiColourRemappingInfo.m_colourRemapSEIPreLutTargetValue[c][i] );
     749          }
     750        }
     751      }
     752
     753      retval = fscanf( fic, "%d", &tempCode ); m_seiColourRemappingInfo.m_colourRemapSEIMatrixPresentFlag = tempCode ? 1 : 0;
     754      if( m_seiColourRemappingInfo.m_colourRemapSEIMatrixPresentFlag )
     755      {
     756        retval = fscanf( fic, "%d", &m_seiColourRemappingInfo.m_colourRemapSEILog2MatrixDenom );
    796757        for( Int c=0 ; c<3 ; c++ )
     758        {
    797759          for( Int i=0 ; i<3 ; i++ )
    798             retval = fscanf( fic, "%d", &m_colourRemapSEICoeffs[c][i] );
     760          {
     761            retval = fscanf( fic, "%d", &m_seiColourRemappingInfo.m_colourRemapSEICoeffs[c][i] );
     762          }
     763        }
    799764      }
    800765
    801766      for( Int c=0 ; c<3 ; c++ )
    802767      {
    803         retval = fscanf( fic, "%d", &m_colourRemapSEIPostLutNumValMinus1[c] );
    804         if( m_colourRemapSEIPostLutNumValMinus1[c]>0 )
    805         {
    806           m_colourRemapSEIPostLutCodedValue[c]  = new Int[m_colourRemapSEIPostLutNumValMinus1[c]+1];
    807           m_colourRemapSEIPostLutTargetValue[c] = new Int[m_colourRemapSEIPostLutNumValMinus1[c]+1];
    808           for( Int i=0 ; i<=m_colourRemapSEIPostLutNumValMinus1[c] ; i++ )
     768        retval = fscanf( fic, "%d", &m_seiColourRemappingInfo.m_colourRemapSEIPostLutNumValMinus1[c] );
     769        if( m_seiColourRemappingInfo.m_colourRemapSEIPostLutNumValMinus1[c]>0 )
     770        {
     771          m_seiColourRemappingInfo.m_colourRemapSEIPostLutCodedValue[c]  = new Int[m_seiColourRemappingInfo.m_colourRemapSEIPostLutNumValMinus1[c]+1];
     772          m_seiColourRemappingInfo.m_colourRemapSEIPostLutTargetValue[c] = new Int[m_seiColourRemappingInfo.m_colourRemapSEIPostLutNumValMinus1[c]+1];
     773          for( Int i=0 ; i<= m_seiColourRemappingInfo.m_colourRemapSEIPostLutNumValMinus1[c] ; i++ )
    809774          {
    810             retval = fscanf( fic, "%d", &m_colourRemapSEIPostLutCodedValue[c][i] );
    811             retval = fscanf( fic, "%d", &m_colourRemapSEIPostLutTargetValue[c][i] );
     775            retval = fscanf( fic, "%d", &m_seiColourRemappingInfo.m_colourRemapSEIPostLutCodedValue[c][i] );
     776            retval = fscanf( fic, "%d", &m_seiColourRemappingInfo.m_colourRemapSEIPostLutTargetValue[c][i] );
    812777          }
    813778        }
     
    834799#define xConfirmParameter(a,b) check_failed |= confirmParameter(a,b)
    835800
    836   if ( m_colourRemapSEIFile.c_str() && !m_colourRemapSEICancelFlag )
    837   {
    838     xConfirmParameter( m_colourRemapSEIInputBitDepth < 8 || m_colourRemapSEIInputBitDepth > 16 , "colour_remap_coded_data_bit_depth shall be in the range of 8 to 16, inclusive");
    839     xConfirmParameter( m_colourRemapSEIBitDepth < 8 || (m_colourRemapSEIBitDepth > 16 && m_colourRemapSEIBitDepth < 255) , "colour_remap_target_bit_depth shall be in the range of 8 to 16, inclusive");
     801  if ( m_seiColourRemappingInfo.m_colourRemapSEIFile.c_str() && !m_seiColourRemappingInfo.m_colourRemapSEICancelFlag )
     802  {
     803    xConfirmParameter( m_seiColourRemappingInfo.m_colourRemapSEIInputBitDepth < 8 || m_seiColourRemappingInfo.m_colourRemapSEIInputBitDepth > 16 , "colour_remap_coded_data_bit_depth shall be in the range of 8 to 16, inclusive");
     804    xConfirmParameter( m_seiColourRemappingInfo.m_colourRemapSEIBitDepth < 8 || (m_seiColourRemappingInfo.m_colourRemapSEIBitDepth > 16 && m_seiColourRemappingInfo.m_colourRemapSEIBitDepth < 255) , "colour_remap_target_bit_depth shall be in the range of 8 to 16, inclusive");
    840805    for( Int c=0 ; c<3 ; c++)
    841806    {
    842       xConfirmParameter( m_colourRemapSEIPreLutNumValMinus1[c] < 0 || m_colourRemapSEIPreLutNumValMinus1[c] > 32, "pre_lut_num_val_minus1[c] shall be in the range of 0 to 32, inclusive");
    843       if( m_colourRemapSEIPreLutNumValMinus1[c]>0 )
    844         for( Int i=0 ; i<=m_colourRemapSEIPreLutNumValMinus1[c] ; i++)
    845         {
    846           xConfirmParameter( 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_coded_data_bit_depth)-1, inclusive");
    847           xConfirmParameter( 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_target_bit_depth)-1, inclusive");
    848         }
    849       xConfirmParameter( m_colourRemapSEIPostLutNumValMinus1[c] < 0 || m_colourRemapSEIPostLutNumValMinus1[c] > 32, "post_lut_num_val_minus1[c] shall be in the range of 0 to 32, inclusive");
    850       if( m_colourRemapSEIPostLutNumValMinus1[c]>0 )
    851         for( Int i=0 ; i<=m_colourRemapSEIPostLutNumValMinus1[c] ; i++)
    852         {
    853           xConfirmParameter( 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_target_bit_depth)-1, inclusive");
    854           xConfirmParameter( 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_target_bit_depth)-1, inclusive");
    855         }
    856     }
    857     if ( m_colourRemapSEIMatrixPresentFlag )
    858     {
    859       xConfirmParameter( m_colourRemapSEILog2MatrixDenom < 0 || m_colourRemapSEILog2MatrixDenom > 15, "log2_matrix_denom shall be in the range of 0 to 15, inclusive");
     807      xConfirmParameter( m_seiColourRemappingInfo.m_colourRemapSEIPreLutNumValMinus1[c] < 0 || m_seiColourRemappingInfo.m_colourRemapSEIPreLutNumValMinus1[c] > 32, "pre_lut_num_val_minus1[c] shall be in the range of 0 to 32, inclusive");
     808      if( m_seiColourRemappingInfo.m_colourRemapSEIPreLutNumValMinus1[c]>0 )
     809        for( Int i=0 ; i<= m_seiColourRemappingInfo.m_colourRemapSEIPreLutNumValMinus1[c] ; i++)
     810        {
     811          xConfirmParameter( m_seiColourRemappingInfo.m_colourRemapSEIPreLutCodedValue[c][i] < 0 || m_seiColourRemappingInfo.m_colourRemapSEIPreLutCodedValue[c][i] > ((1<<m_seiColourRemappingInfo.m_colourRemapSEIInputBitDepth)-1), "pre_lut_coded_value[c][i] shall be in the range of 0 to (1<<colour_remap_coded_data_bit_depth)-1, inclusive");
     812          xConfirmParameter( m_seiColourRemappingInfo.m_colourRemapSEIPreLutTargetValue[c][i] < 0 || m_seiColourRemappingInfo.m_colourRemapSEIPreLutTargetValue[c][i] > ((1<<m_seiColourRemappingInfo.m_colourRemapSEIBitDepth)-1), "pre_lut_target_value[c][i] shall be in the range of 0 to (1<<colour_remap_target_bit_depth)-1, inclusive");
     813        }
     814      xConfirmParameter( m_seiColourRemappingInfo.m_colourRemapSEIPostLutNumValMinus1[c] < 0 || m_seiColourRemappingInfo.m_colourRemapSEIPostLutNumValMinus1[c] > 32, "post_lut_num_val_minus1[c] shall be in the range of 0 to 32, inclusive");
     815      if( m_seiColourRemappingInfo.m_colourRemapSEIPostLutNumValMinus1[c]>0 )
     816        for( Int i=0 ; i<= m_seiColourRemappingInfo.m_colourRemapSEIPostLutNumValMinus1[c] ; i++)
     817        {
     818          xConfirmParameter( m_seiColourRemappingInfo.m_colourRemapSEIPostLutCodedValue[c][i] < 0 || m_seiColourRemappingInfo.m_colourRemapSEIPostLutCodedValue[c][i] > ((1<<m_seiColourRemappingInfo.m_colourRemapSEIBitDepth)-1), "post_lut_coded_value[c][i] shall be in the range of 0 to (1<<colour_remap_target_bit_depth)-1, inclusive");
     819          xConfirmParameter( m_seiColourRemappingInfo.m_colourRemapSEIPostLutTargetValue[c][i] < 0 || m_seiColourRemappingInfo.m_colourRemapSEIPostLutTargetValue[c][i] > ((1<<m_seiColourRemappingInfo.m_colourRemapSEIBitDepth)-1), "post_lut_target_value[c][i] shall be in the range of 0 to (1<<colour_remap_target_bit_depth)-1, inclusive");
     820        }
     821    }
     822    if ( m_seiColourRemappingInfo.m_colourRemapSEIMatrixPresentFlag )
     823    {
     824      xConfirmParameter( m_seiColourRemappingInfo.m_colourRemapSEILog2MatrixDenom < 0 || m_seiColourRemappingInfo.m_colourRemapSEILog2MatrixDenom > 15, "log2_matrix_denom shall be in the range of 0 to 15, inclusive");
    860825      for( Int c=0 ; c<3 ; c++)
    861826        for( Int i=0 ; i<3 ; i++)
    862           xConfirmParameter( 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");
    863     }
    864   }
    865 }
    866 #endif
     827          xConfirmParameter( m_seiColourRemappingInfo.m_colourRemapSEICoeffs[c][i] < -32768 || m_seiColourRemappingInfo.m_colourRemapSEICoeffs[c][i] > 32767, "colour_remap_coeffs[c][i] shall be in the range of -32768 and 32767, inclusive");
     828    }
     829  }
     830}
     831#endif
     832
     833Void TEncGOP::xCreatePerPictureSEIMessages (Int picInGOP, SEIMessages& seiMessages, SEIMessages& nestedSeiMessages, TComSlice *slice)
     834{
     835  if( ( m_pcCfg->getBufferingPeriodSEIEnabled() ) && ( slice->getSliceType() == I_SLICE ) &&
     836    ( slice->getSPS()->getVuiParametersPresentFlag() ) &&
     837    ( ( slice->getSPS()->getVuiParameters()->getHrdParameters()->getNalHrdParametersPresentFlag() )
     838    || ( slice->getSPS()->getVuiParameters()->getHrdParameters()->getVclHrdParametersPresentFlag() ) ) )
     839  {
     840    SEIBufferingPeriod *bufferingPeriodSEI = new SEIBufferingPeriod();
     841    m_seiEncoder.initSEIBufferingPeriod(bufferingPeriodSEI, slice);
     842    seiMessages.push_back(bufferingPeriodSEI);
     843    m_bufferingPeriodSEIPresentInAU = true;
     844
     845    if (m_pcCfg->getScalableNestingSEIEnabled())
     846    {
     847      SEIBufferingPeriod *bufferingPeriodSEIcopy = new SEIBufferingPeriod();
     848      bufferingPeriodSEI->copyTo(*bufferingPeriodSEIcopy);
     849      nestedSeiMessages.push_back(bufferingPeriodSEIcopy);
     850    }
     851  }
     852
     853  if (picInGOP ==0 && m_pcCfg->getSOPDescriptionSEIEnabled() ) // write SOP description SEI (if enabled) at the beginning of GOP
     854  {
     855    SEISOPDescription* sopDescriptionSEI = new SEISOPDescription();
     856    m_seiEncoder.initSEISOPDescription(sopDescriptionSEI, slice, picInGOP, m_iLastIDR, m_iGopSize);
     857    seiMessages.push_back(sopDescriptionSEI);
     858  }
     859
     860  if( ( m_pcEncTop->getRecoveryPointSEIEnabled() ) && ( slice->getSliceType() == I_SLICE ) )
     861  {
     862    if( m_pcEncTop->getGradualDecodingRefreshInfoEnabled() && !slice->getRapPicFlag() )
     863    {
     864      // Gradual decoding refresh SEI
     865      SEIGradualDecodingRefreshInfo *gradualDecodingRefreshInfoSEI = new SEIGradualDecodingRefreshInfo();
     866      gradualDecodingRefreshInfoSEI->m_gdrForegroundFlag = true; // Indicating all "foreground"
     867      seiMessages.push_back(gradualDecodingRefreshInfoSEI);
     868    }
     869    // Recovery point SEI
     870    SEIRecoveryPoint *recoveryPointSEI = new SEIRecoveryPoint();
     871    m_seiEncoder.initSEIRecoveryPoint(recoveryPointSEI, slice);
     872    seiMessages.push_back(recoveryPointSEI);
     873
     874#if ALLOW_RECOVERY_POINT_AS_RAP
     875    if(m_pcCfg->getDecodingRefreshType() == 3)
     876    {
     877      m_iLastRecoveryPicPOC = slice->getPOC();
     878    }
     879#endif
     880  }
     881  if (m_pcCfg->getTemporalLevel0IndexSEIEnabled())
     882  {
     883    SEITemporalLevel0Index *temporalLevel0IndexSEI = new SEITemporalLevel0Index();
     884    m_seiEncoder.initTemporalLevel0IndexSEI(temporalLevel0IndexSEI, slice);
     885    seiMessages.push_back(temporalLevel0IndexSEI);
     886  }
     887
     888  if(slice->getSPS()->getVuiParametersPresentFlag() && m_pcCfg->getChromaSamplingFilterHintEnabled() && ( slice->getSliceType() == I_SLICE ))
     889  {
     890    SEIChromaSamplingFilterHint *seiChromaSamplingFilterHint = new SEIChromaSamplingFilterHint;
     891    m_seiEncoder.initSEIChromaSamplingFilterHint(seiChromaSamplingFilterHint, m_pcCfg->getChromaLocInfoPresentFlag(), m_pcCfg->getChromaSamplingHorFilterIdc(), m_pcCfg->getChromaSamplingVerFilterIdc());
     892    seiMessages.push_back(seiChromaSamplingFilterHint);
     893  }
     894
     895  if( m_pcEncTop->getNoDisplaySEITLayer() && ( slice->getTLayer() >= m_pcEncTop->getNoDisplaySEITLayer() ) )
     896  {
     897    SEINoDisplay *seiNoDisplay = new SEINoDisplay;
     898    seiNoDisplay->m_noDisplay = true;
     899    seiMessages.push_back(seiNoDisplay);
     900  }
     901
     902#if Q0189_TMVP_CONSTRAINTS
     903  if( m_pcEncTop->getTMVPConstraintsSEIEnabled() == 1 && (m_pcEncTop->getTMVPModeId() == 1 || m_pcEncTop->getTMVPModeId() == 2) &&
     904    slice->getLayerId() > 0 && (slice->getNalUnitType() ==  NAL_UNIT_CODED_SLICE_IDR_W_RADL || slice->getNalUnitType() ==  NAL_UNIT_CODED_SLICE_IDR_N_LP))
     905  {
     906    SEITMVPConstrains *seiTMVPConstrains = new SEITMVPConstrains;
     907    seiTMVPConstrains->no_intra_layer_col_pic_flag = 1;
     908    seiTMVPConstrains->prev_pics_not_used_flag = 1;
     909    seiMessages.push_back(seiTMVPConstrains);
     910  }
     911#endif
     912#if Q0247_FRAME_FIELD_INFO
     913  if( slice->getLayerId()> 0 && ( (m_pcCfg->getProgressiveSourceFlag() && m_pcCfg->getInterlacedSourceFlag()) || m_pcCfg->getFrameFieldInfoPresentFlag()))
     914  {
     915    Bool isField = slice->getPic()->isField();
     916    SEIFrameFieldInfo *seiFFInfo = new SEIFrameFieldInfo;
     917    seiFFInfo->m_ffinfo_picStruct = (isField && slice->getPic()->isTopField())? 1 : isField? 2 : 0;
     918    seiMessages.push_back(seiFFInfo);
     919  }
     920#endif
     921#if Q0074_COLOUR_REMAPPING_SEI
     922    // insert one CRI by picture (if the file exist)   
     923    freeColourCRI();
     924
     925    // building the CRI file name with poc num in suffix "_poc.txt"
     926    char suffix[10];
     927    sprintf(suffix, "_%d.txt",  slice->getPOC());
     928    string  colourRemapSEIFileWithPoc(m_pcCfg->getCRISEIFileRoot());
     929    colourRemapSEIFileWithPoc.append(suffix);
     930    setCRISEIFile( const_cast<Char*>(colourRemapSEIFileWithPoc.c_str()) );
     931 
     932    Int ret = readingCRIparameters();
     933
     934    if(ret != -1 && m_pcCfg->getCRISEIFileRoot())
     935    {
     936      // check validity of input parameters
     937      xCheckParameter();
     938
     939      SEIColourRemappingInfo *seiColourRemappingInfo = new SEIColourRemappingInfo;
     940      m_seiEncoder.initSEIColourRemappingInfo(seiColourRemappingInfo, &m_seiColourRemappingInfo);
     941      seiMessages.push_back(seiColourRemappingInfo);
     942    }
     943#endif
     944}
     945
     946Void TEncGOP::xCreateScalableNestingSEI (SEIMessages& seiMessages, SEIMessages& nestedSeiMessages)
     947{
     948  SEIMessages tmpMessages;
     949  while (!nestedSeiMessages.empty())
     950  {
     951    SEI* sei=nestedSeiMessages.front();
     952    nestedSeiMessages.pop_front();
     953    tmpMessages.push_back(sei);
     954    SEIScalableNesting *nestingSEI = new SEIScalableNesting();
     955    m_seiEncoder.initSEIScalableNesting(nestingSEI, tmpMessages);
     956    seiMessages.push_back(nestingSEI);
     957    tmpMessages.clear();
     958  }
     959}
     960
     961Void TEncGOP::xCreatePictureTimingSEI  (Int IRAPGOPid, SEIMessages& seiMessages, SEIMessages& nestedSeiMessages, SEIMessages& duInfoSeiMessages, AccessUnit &accessUnit, TComSlice *slice, Bool isField, std::deque<DUData> &duData)
     962{
     963  Int picSptDpbOutputDuDelay = 0;
     964  SEIPictureTiming *pictureTimingSEI = new SEIPictureTiming();
     965
     966  const TComVUI *vui = slice->getSPS()->getVuiParameters();
     967  const TComHRD *hrd = vui->getHrdParameters();
     968
     969  // update decoding unit parameters
     970  if( ( m_pcCfg->getPictureTimingSEIEnabled() || m_pcCfg->getDecodingUnitInfoSEIEnabled() ) &&
     971    ( slice->getSPS()->getVuiParametersPresentFlag() ) &&
     972    (  hrd->getNalHrdParametersPresentFlag() || hrd->getVclHrdParametersPresentFlag() ) )
     973  {
     974    // DU parameters
     975    if( hrd->getSubPicCpbParamsPresentFlag() )
     976    {
     977      UInt numDU = (UInt) duData.size();
     978      pictureTimingSEI->m_numDecodingUnitsMinus1     = ( numDU - 1 );
     979      pictureTimingSEI->m_duCommonCpbRemovalDelayFlag = false;
     980      pictureTimingSEI->m_numNalusInDuMinus1.resize( numDU );
     981      pictureTimingSEI->m_duCpbRemovalDelayMinus1.resize( numDU );
     982    }
     983    pictureTimingSEI->m_auCpbRemovalDelay = std::min<Int>(std::max<Int>(1, m_totalCoded - m_lastBPSEI), static_cast<Int>(pow(2, static_cast<Double>(hrd->getCpbRemovalDelayLengthMinus1()+1)))); // Syntax element signalled as minus, hence the .
     984    pictureTimingSEI->m_picDpbOutputDelay = slice->getSPS()->getNumReorderPics(slice->getSPS()->getMaxTLayers()-1) + slice->getPOC() - m_totalCoded;
     985#if EFFICIENT_FIELD_IRAP
     986    if(IRAPGOPid > 0 && IRAPGOPid < m_iGopSize)
     987    {
     988      // if pictures have been swapped there is likely one more picture delay on their tid. Very rough approximation
     989      pictureTimingSEI->m_picDpbOutputDelay ++;
     990    }
     991#endif
     992    Int factor = hrd->getTickDivisorMinus2() + 2;
     993    pictureTimingSEI->m_picDpbOutputDuDelay = factor * pictureTimingSEI->m_picDpbOutputDelay;
     994    if( m_pcCfg->getDecodingUnitInfoSEIEnabled() )
     995    {
     996      picSptDpbOutputDuDelay = factor * pictureTimingSEI->m_picDpbOutputDelay;
     997    }
     998    if (m_bufferingPeriodSEIPresentInAU)
     999    {
     1000      m_lastBPSEI = m_totalCoded;
     1001    }
     1002
     1003    if( hrd->getSubPicCpbParamsPresentFlag() )
     1004    {
     1005      Int i;
     1006      UInt64 ui64Tmp;
     1007      UInt uiPrev = 0;
     1008      UInt numDU = ( pictureTimingSEI->m_numDecodingUnitsMinus1 + 1 );
     1009      std::vector<UInt> &rDuCpbRemovalDelayMinus1 = pictureTimingSEI->m_duCpbRemovalDelayMinus1;
     1010      UInt maxDiff = ( hrd->getTickDivisorMinus2() + 2 ) - 1;
     1011
     1012      for( i = 0; i < numDU; i ++ )
     1013      {
     1014        pictureTimingSEI->m_numNalusInDuMinus1[ i ]       = ( i == 0 ) ? ( duData[i].accumNalsDU - 1 ) : ( duData[i].accumNalsDU- duData[i-1].accumNalsDU - 1 );
     1015      }
     1016
     1017      if( numDU == 1 )
     1018      {
     1019        rDuCpbRemovalDelayMinus1[ 0 ] = 0; /* don't care */
     1020      }
     1021      else
     1022      {
     1023        rDuCpbRemovalDelayMinus1[ numDU - 1 ] = 0;/* by definition */
     1024        UInt tmp = 0;
     1025        UInt accum = 0;
     1026
     1027        for( i = ( numDU - 2 ); i >= 0; i -- )
     1028        {
     1029          ui64Tmp = ( ( ( duData[numDU - 1].accumBitsDU  - duData[i].accumBitsDU ) * ( vui->getTimingInfo()->getTimeScale() / vui->getTimingInfo()->getNumUnitsInTick() ) * ( hrd->getTickDivisorMinus2() + 2 ) ) / ( m_pcCfg->getTargetBitrate() ) );
     1030          if( (UInt)ui64Tmp > maxDiff )
     1031          {
     1032            tmp ++;
     1033          }
     1034        }
     1035        uiPrev = 0;
     1036
     1037        UInt flag = 0;
     1038        for( i = ( numDU - 2 ); i >= 0; i -- )
     1039        {
     1040          flag = 0;
     1041          ui64Tmp = ( ( ( duData[numDU - 1].accumBitsDU  - duData[i].accumBitsDU ) * ( vui->getTimingInfo()->getTimeScale() / vui->getTimingInfo()->getNumUnitsInTick() ) * ( hrd->getTickDivisorMinus2() + 2 ) ) / ( m_pcCfg->getTargetBitrate() ) );
     1042
     1043          if( (UInt)ui64Tmp > maxDiff )
     1044          {
     1045            if(uiPrev >= maxDiff - tmp)
     1046            {
     1047              ui64Tmp = uiPrev + 1;
     1048              flag = 1;
     1049            }
     1050            else                            ui64Tmp = maxDiff - tmp + 1;
     1051          }
     1052          rDuCpbRemovalDelayMinus1[ i ] = (UInt)ui64Tmp - uiPrev - 1;
     1053          if( (Int)rDuCpbRemovalDelayMinus1[ i ] < 0 )
     1054          {
     1055            rDuCpbRemovalDelayMinus1[ i ] = 0;
     1056          }
     1057          else if (tmp > 0 && flag == 1)
     1058          {
     1059            tmp --;
     1060          }
     1061          accum += rDuCpbRemovalDelayMinus1[ i ] + 1;
     1062          uiPrev = accum;
     1063        }
     1064      }
     1065    }
     1066   
     1067    if( m_pcCfg->getPictureTimingSEIEnabled() )
     1068    {
     1069      pictureTimingSEI->m_picStruct = (isField && slice->getPic()->isTopField())? 1 : isField? 2 : 0;
     1070      seiMessages.push_back(pictureTimingSEI);
     1071      m_pictureTimingSEIPresentInAU = true;
     1072
     1073      if ( m_pcCfg->getScalableNestingSEIEnabled() ) // put picture timing SEI into scalable nesting SEI
     1074      {
     1075        if (m_pcCfg->getScalableNestingSEIEnabled())
     1076        {
     1077          SEIPictureTiming *pictureTimingSEIcopy = new SEIPictureTiming();
     1078          pictureTimingSEI->copyTo(*pictureTimingSEIcopy);
     1079          nestedSeiMessages.push_back(pictureTimingSEIcopy);
     1080        }
     1081        m_nestedPictureTimingSEIPresentInAU = true;
     1082      }
     1083    }
     1084
     1085    if( m_pcCfg->getDecodingUnitInfoSEIEnabled() && hrd->getSubPicCpbParamsPresentFlag() )
     1086    {
     1087      for( Int i = 0; i < ( pictureTimingSEI->m_numDecodingUnitsMinus1 + 1 ); i ++ )
     1088      {
     1089        SEIDecodingUnitInfo *duInfoSEI = new SEIDecodingUnitInfo();
     1090        duInfoSEI->m_decodingUnitIdx = i;
     1091        duInfoSEI->m_duSptCpbRemovalDelay = pictureTimingSEI->m_duCpbRemovalDelayMinus1[i] + 1;
     1092        duInfoSEI->m_dpbOutputDuDelayPresentFlag = false;
     1093        duInfoSEI->m_picSptDpbOutputDuDelay = picSptDpbOutputDuDelay;
     1094
     1095        duInfoSeiMessages.push_back(duInfoSEI);
     1096      }
     1097    }
     1098  }
     1099}
     1100
     1101Void TEncGOP::xUpdateDuData(AccessUnit &testAU, std::deque<DUData> &duData)
     1102{
     1103  if (duData.empty())
     1104  {
     1105    return;
     1106  }
     1107  // fix first
     1108  UInt numNalUnits = (UInt)testAU.size();
     1109  UInt numRBSPBytes = 0;
     1110  for (AccessUnit::const_iterator it = testAU.begin(); it != testAU.end(); it++)
     1111  {
     1112    numRBSPBytes += UInt((*it)->m_nalUnitData.str().size());
     1113  }
     1114  duData[0].accumBitsDU += ( numRBSPBytes << 3 );
     1115  duData[0].accumNalsDU += numNalUnits;
     1116
     1117  // adapt cumulative sums for all following DUs
     1118  // and add one DU info SEI, if enabled
     1119  for (Int i=1; i<duData.size(); i++)
     1120  {
     1121    if (m_pcCfg->getDecodingUnitInfoSEIEnabled())
     1122    {
     1123      numNalUnits  += 1;
     1124      numRBSPBytes += ( 5 << 3 );
     1125    }
     1126    duData[i].accumBitsDU += numRBSPBytes; // probably around 5 bytes
     1127    duData[i].accumNalsDU += numNalUnits;
     1128  }
     1129
     1130  // The last DU may have a trailing SEI
     1131  if (m_pcCfg->getDecodedPictureHashSEIEnabled())
     1132  {
     1133    duData.back().accumBitsDU += ( 20 << 3 ); // probably around 20 bytes - should be further adjusted, e.g. by type
     1134    duData.back().accumNalsDU += 1;
     1135  }
     1136
     1137}
     1138Void TEncGOP::xUpdateTimingSEI(SEIPictureTiming *pictureTimingSEI, std::deque<DUData> &duData, const TComSPS *sps)
     1139{
     1140  if (!pictureTimingSEI)
     1141  {
     1142    return;
     1143  }
     1144  const TComVUI *vui = sps->getVuiParameters();
     1145  const TComHRD *hrd = vui->getHrdParameters();
     1146  if( hrd->getSubPicCpbParamsPresentFlag() )
     1147  {
     1148    Int i;
     1149    UInt64 ui64Tmp;
     1150    UInt uiPrev = 0;
     1151    UInt numDU = ( pictureTimingSEI->m_numDecodingUnitsMinus1 + 1 );
     1152    std::vector<UInt> &rDuCpbRemovalDelayMinus1 = pictureTimingSEI->m_duCpbRemovalDelayMinus1;
     1153    UInt maxDiff = ( hrd->getTickDivisorMinus2() + 2 ) - 1;
     1154
     1155    for( i = 0; i < numDU; i ++ )
     1156    {
     1157      pictureTimingSEI->m_numNalusInDuMinus1[ i ]       = ( i == 0 ) ? ( duData[i].accumNalsDU - 1 ) : ( duData[i].accumNalsDU- duData[i-1].accumNalsDU - 1 );
     1158    }
     1159
     1160    if( numDU == 1 )
     1161    {
     1162      rDuCpbRemovalDelayMinus1[ 0 ] = 0; /* don't care */
     1163    }
     1164    else
     1165    {
     1166      rDuCpbRemovalDelayMinus1[ numDU - 1 ] = 0;/* by definition */
     1167      UInt tmp = 0;
     1168      UInt accum = 0;
     1169
     1170      for( i = ( numDU - 2 ); i >= 0; i -- )
     1171      {
     1172        ui64Tmp = ( ( ( duData[numDU - 1].accumBitsDU  - duData[i].accumBitsDU ) * ( vui->getTimingInfo()->getTimeScale() / vui->getTimingInfo()->getNumUnitsInTick() ) * ( hrd->getTickDivisorMinus2() + 2 ) ) / ( m_pcCfg->getTargetBitrate() ) );
     1173        if( (UInt)ui64Tmp > maxDiff )
     1174        {
     1175          tmp ++;
     1176        }
     1177      }
     1178      uiPrev = 0;
     1179
     1180      UInt flag = 0;
     1181      for( i = ( numDU - 2 ); i >= 0; i -- )
     1182      {
     1183        flag = 0;
     1184        ui64Tmp = ( ( ( duData[numDU - 1].accumBitsDU  - duData[i].accumBitsDU ) * ( vui->getTimingInfo()->getTimeScale() / vui->getTimingInfo()->getNumUnitsInTick() ) * ( hrd->getTickDivisorMinus2() + 2 ) ) / ( m_pcCfg->getTargetBitrate() ) );
     1185
     1186        if( (UInt)ui64Tmp > maxDiff )
     1187        {
     1188          if(uiPrev >= maxDiff - tmp)
     1189          {
     1190            ui64Tmp = uiPrev + 1;
     1191            flag = 1;
     1192          }
     1193          else                            ui64Tmp = maxDiff - tmp + 1;
     1194        }
     1195        rDuCpbRemovalDelayMinus1[ i ] = (UInt)ui64Tmp - uiPrev - 1;
     1196        if( (Int)rDuCpbRemovalDelayMinus1[ i ] < 0 )
     1197        {
     1198          rDuCpbRemovalDelayMinus1[ i ] = 0;
     1199        }
     1200        else if (tmp > 0 && flag == 1)
     1201        {
     1202          tmp --;
     1203        }
     1204        accum += rDuCpbRemovalDelayMinus1[ i ] + 1;
     1205        uiPrev = accum;
     1206      }
     1207    }
     1208  }
     1209}
     1210Void TEncGOP::xUpdateDuInfoSEI(SEIMessages &duInfoSeiMessages, SEIPictureTiming *pictureTimingSEI)
     1211{
     1212  if (duInfoSeiMessages.empty() || (pictureTimingSEI == NULL))
     1213  {
     1214    return;
     1215  }
     1216
     1217  Int i=0;
     1218
     1219  for (SEIMessages::iterator du = duInfoSeiMessages.begin(); du!= duInfoSeiMessages.end(); du++)
     1220  {
     1221    SEIDecodingUnitInfo *duInfoSEI = (SEIDecodingUnitInfo*) (*du);
     1222    duInfoSEI->m_decodingUnitIdx = i;
     1223    duInfoSEI->m_duSptCpbRemovalDelay = pictureTimingSEI->m_duCpbRemovalDelayMinus1[i] + 1;
     1224    duInfoSEI->m_dpbOutputDuDelayPresentFlag = false;
     1225    i++;
     1226  }
     1227}
    8671228
    8681229// ====================================================================================================================
     
    8911252
    8921253  m_iNumPicCoded = 0;
    893   SEIPictureTiming pictureTimingSEI;
    894   Bool writeSOP = m_pcCfg->getSOPDescriptionSEIEnabled();
    895 
    896   // Initialize Scalable Nesting SEI with single layer values
    897   SEIScalableNesting scalableNestingSEI;
    898   scalableNestingSEI.m_bitStreamSubsetFlag           = 1;      // If the nested SEI messages are picture buffereing SEI mesages, picure timing SEI messages or sub-picture timing SEI messages, bitstream_subset_flag shall be equal to 1
    899   scalableNestingSEI.m_nestingOpFlag                 = 0;
    900   scalableNestingSEI.m_nestingNumOpsMinus1           = 0;      //nesting_num_ops_minus1
    901   scalableNestingSEI.m_allLayersFlag                 = 0;
    902   scalableNestingSEI.m_nestingNoOpMaxTemporalIdPlus1 = 6 + 1;  //nesting_no_op_max_temporal_id_plus1
    903   scalableNestingSEI.m_nestingNumLayersMinus1        = 1 - 1;  //nesting_num_layers_minus1
    904   scalableNestingSEI.m_nestingLayerId[0]             = 0;
    905   scalableNestingSEI.m_callerOwnsSEIs                = true;
    906 
    907   Int picSptDpbOutputDuDelay = 0;
    908   UInt *accumBitsDU = NULL;
    909   UInt *accumNalsDU = NULL;
     1254  SEIMessages leadingSeiMessages;
     1255  SEIMessages nestedSeiMessages;
     1256  SEIMessages duInfoSeiMessages;
     1257  SEIMessages trailingSeiMessages;
     1258  std::deque<DUData> duData;
    9101259  SEIDecodingUnitInfo decodingUnitInfoSEI;
    9111260
     
    20922441#endif
    20932442
     2443    duData.clear();
    20942444    pcSlice = pcPic->getSlice(0);
    20952445
     
    21132463    m_pcEntropyCoder->setEntropyCoder   ( m_pcCavlcCoder, pcSlice );
    21142464
    2115     // write various header sets.
    21162465    if ( m_bSeqFirst )
    21172466    {
    2118 #if SVC_EXTENSION
    2119       OutputNALUnit nalu( NAL_UNIT_VPS, 0, 0 ); // The value of nuh_layer_id of VPS NAL unit shall be equal to 0.
    2120 #if AVC_BASE
    2121       if( ( m_layerId > 0 && m_pcEncTop->getVPS()->getNonHEVCBaseLayerFlag() ) || ( m_layerId == 0 && !m_pcEncTop->getVPS()->getNonHEVCBaseLayerFlag() ) )
    2122 #else
    2123       if( m_layerId == 0 )
    2124 #endif
    2125       {
    2126         //The following code also calculates the VPS VUI offset
    2127 #else
    2128       OutputNALUnit nalu(NAL_UNIT_VPS);
    2129 #endif
    2130       m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
    2131       m_pcEntropyCoder->encodeVPS(m_pcEncTop->getVPS());
    2132       writeRBSPTrailingBits(nalu.m_Bitstream);
    2133       accessUnit.push_back(new NALUnitEBSP(nalu));
    2134       actualTotalBits += UInt(accessUnit.back()->m_nalUnitData.str().size()) * 8;
    2135 #if SVC_EXTENSION
    2136       }
    2137 #endif
    2138 
    2139 #if SVC_EXTENSION
    2140       nalu = NALUnit(NAL_UNIT_SPS, 0, m_layerId);
    2141 
    2142       if( m_pcEncTop->getVPS()->getNumDirectRefLayers(m_layerId) == 0 && m_pcEncTop->getVPS()->getNumAddLayerSets() > 0 )
    2143       {
    2144         // For independent base layer rewriting
    2145         nalu.m_nuhLayerId = 0;
    2146       }
    2147 #else
    2148       nalu = NALUnit(NAL_UNIT_SPS);
    2149 #endif
    2150 
    2151       m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
    2152      
    2153 #if SVC_EXTENSION
    2154       // dependency constraint
    2155       assert( pcSlice->getSPS()->getLayerId() == 0 || pcSlice->getSPS()->getLayerId() == m_layerId || m_pcEncTop->getVPS()->getRecursiveRefLayerFlag(m_layerId, pcSlice->getSPS()->getLayerId()) );
    2156 #endif
    2157 
    2158       m_pcEntropyCoder->encodeSPS(pcSlice->getSPS());
    2159       writeRBSPTrailingBits(nalu.m_Bitstream);
    2160       accessUnit.push_back(new NALUnitEBSP(nalu));
    2161       actualTotalBits += UInt(accessUnit.back()->m_nalUnitData.str().size()) * 8;
    2162 
    2163 #if SVC_EXTENSION
    2164       nalu = NALUnit(NAL_UNIT_PPS, 0, m_layerId);
    2165 
    2166       if( m_pcEncTop->getVPS()->getNumDirectRefLayers(m_layerId) == 0 && m_pcEncTop->getVPS()->getNumAddLayerSets() > 0 )
    2167       {
    2168         // For independent base layer rewriting
    2169         nalu.m_nuhLayerId = 0;
    2170       }
    2171 #else
    2172       nalu = NALUnit(NAL_UNIT_PPS);
    2173 #endif
    2174 
    2175       m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
    2176 
    2177 #if SVC_EXTENSION
    2178       // dependency constraint
    2179       assert( pcSlice->getPPS()->getLayerId() == 0 || pcSlice->getPPS()->getLayerId() == m_layerId || m_pcEncTop->getVPS()->getRecursiveRefLayerFlag(m_layerId, pcSlice->getPPS()->getLayerId()) );
    2180 #endif
     2467      // write various parameter sets
     2468      actualTotalBits += xWriteParameterSets(accessUnit, pcSlice);
     2469
     2470      // create prefix SEI messages at the beginning of the sequence
     2471      leadingSeiMessages.clear();
     2472      xCreateIRAPLeadingSEIMessages(leadingSeiMessages, pcSlice->getSPS(), pcSlice->getPPS());
     2473
     2474      m_bSeqFirst = false;
     2475    }
    21812476#if SVC_EXTENSION && CGS_3D_ASYMLUT
    2182       m_pcEntropyCoder->encodePPS(pcSlice->getPPS(), &m_Enc3DAsymLUTPPS);
    2183 #else
    2184       m_pcEntropyCoder->encodePPS(pcSlice->getPPS());
    2185 #endif
    2186       writeRBSPTrailingBits(nalu.m_Bitstream);
    2187       accessUnit.push_back(new NALUnitEBSP(nalu));
    2188       actualTotalBits += UInt(accessUnit.back()->m_nalUnitData.str().size()) * 8;
    2189 
    2190       xCreateLeadingSEIMessages(accessUnit, pcSlice->getSPS(), pcSlice->getPPS());
    2191 
    2192 #if O0164_MULTI_LAYER_HRD
    2193       if (pcSlice->getLayerId() == 0 && m_pcEncTop->getVPS()->getVpsVuiBspHrdPresentFlag())
    2194       {
    2195         Int j;
    2196         TComVPS *vps = m_pcEncTop->getVPS();
    2197 
    2198         for( Int i = 0; i < vps->getNumOutputLayerSets(); i++ )
    2199         {
    2200           for( Int k = 0; k < vps->getNumSignalledPartitioningSchemes(i); k++ )
    2201           {
    2202             for( Int l = 0; l < vps->getNumPartitionsInSchemeMinus1(i, k)+1; l++ )
    2203             {
    2204               nalu = NALUnit(NAL_UNIT_PREFIX_SEI, 0, 1);
    2205               m_pcEntropyCoder->setEntropyCoder(m_pcCavlcCoder, pcSlice);
    2206               m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
    2207               SEIScalableNesting *scalableBspNestingSei = xCreateBspNestingSEI(pcSlice, i, k, l);
    2208               m_seiWriter.writeSEImessage(nalu.m_Bitstream, *scalableBspNestingSei, m_pcEncTop->getVPS(), pcSlice->getSPS());
    2209               writeRBSPTrailingBits(nalu.m_Bitstream);
    2210 
    2211               UInt seiPositionInAu = xGetFirstSeiLocation(accessUnit);
    2212               UInt offsetPosition = m_activeParameterSetSEIPresentInAU
    2213                 + m_bufferingPeriodSEIPresentInAU
    2214                 + m_pictureTimingSEIPresentInAU
    2215                 + m_nestedPictureTimingSEIPresentInAU;  // Insert SEI after APS, BP and PT SEI
    2216 
    2217               AccessUnit::iterator it;
    2218 
    2219               for( j = 0, it = accessUnit.begin(); j < seiPositionInAu + offsetPosition; j++ )
    2220               {
    2221                 it++;
    2222               }
    2223 
    2224               accessUnit.insert(it, new NALUnitEBSP(nalu));
    2225             }
    2226           }
    2227         }
    2228       }
    2229 #endif
    2230 
    2231       m_bSeqFirst = false;
    2232     }
    2233 #if CGS_3D_ASYMLUT
    22342477    else if( m_pcCfg->getCGSFlag() && pcSlice->getLayerId() && pcSlice->getCGSOverWritePPS() )
    22352478    {
     
    22422485#endif
    22432486
    2244     if (writeSOP) // write SOP description SEI (if enabled) at the beginning of GOP
    2245     {
    2246       Int SOPcurrPOC = pocCurr;
    2247 
    2248       OutputNALUnit nalu(NAL_UNIT_PREFIX_SEI);
    2249       m_pcEntropyCoder->setEntropyCoder(m_pcCavlcCoder, pcSlice);
    2250       m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
    2251 
    2252       SEISOPDescription SOPDescriptionSEI;
    2253       SOPDescriptionSEI.m_sopSeqParameterSetId = pcSlice->getSPS()->getSPSId();
    2254 
    2255       UInt i = 0;
    2256       UInt prevEntryId = iGOPid;
    2257       for (Int j = iGOPid; j < m_iGopSize; j++)
    2258       {
    2259         Int deltaPOC = m_pcCfg->getGOPEntry(j).m_POC - m_pcCfg->getGOPEntry(prevEntryId).m_POC;
    2260         if ((SOPcurrPOC + deltaPOC) < m_pcCfg->getFramesToBeEncoded())
    2261         {
    2262           SOPcurrPOC += deltaPOC;
    2263           SOPDescriptionSEI.m_sopDescVclNaluType[i] = getNalUnitType(SOPcurrPOC, m_iLastIDR, isField);
    2264           SOPDescriptionSEI.m_sopDescTemporalId[i] = m_pcCfg->getGOPEntry(j).m_temporalId;
    2265           SOPDescriptionSEI.m_sopDescStRpsIdx[i] = m_pcEncTop->getReferencePictureSetIdxForSOP(pcSlice, SOPcurrPOC, j);
    2266           SOPDescriptionSEI.m_sopDescPocDelta[i] = deltaPOC;
    2267 
    2268           prevEntryId = j;
    2269           i++;
    2270         }
    2271       }
    2272 
    2273       SOPDescriptionSEI.m_numPicsInSopMinus1 = i - 1;
    2274 
    2275 #if O0164_MULTI_LAYER_HRD
    2276       m_seiWriter.writeSEImessage( nalu.m_Bitstream, SOPDescriptionSEI, m_pcEncTop->getVPS(), pcSlice->getSPS());
    2277 #else
    2278       m_seiWriter.writeSEImessage( nalu.m_Bitstream, SOPDescriptionSEI, pcSlice->getSPS());
    2279 #endif
    2280       writeRBSPTrailingBits(nalu.m_Bitstream);
    2281       accessUnit.push_back(new NALUnitEBSP(nalu));
    2282 
    2283       writeSOP = false;
    2284     }
    2285 #if Q0189_TMVP_CONSTRAINTS
    2286    if( m_pcEncTop->getTMVPConstraintsSEIEnabled() == 1 &&
    2287       (m_pcEncTop->getTMVPModeId() == 1 || m_pcEncTop->getTMVPModeId() == 2) &&
    2288       pcSlice->getLayerId() >0 &&
    2289       (pcSlice->getNalUnitType() ==  NAL_UNIT_CODED_SLICE_IDR_W_RADL || pcSlice->getNalUnitType() ==  NAL_UNIT_CODED_SLICE_IDR_N_LP))
    2290    {
    2291       OutputNALUnit nalu(NAL_UNIT_PREFIX_SEI);
    2292       SEITMVPConstrains seiTMVPConstrains;
    2293       m_pcEntropyCoder->setEntropyCoder(m_pcCavlcCoder, pcSlice);
    2294       m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
    2295       seiTMVPConstrains.no_intra_layer_col_pic_flag = 1;
    2296       seiTMVPConstrains.prev_pics_not_used_flag = 1;
    2297 #if O0164_MULTI_LAYER_HRD
    2298       m_seiWriter.writeSEImessage( nalu.m_Bitstream, seiTMVPConstrains, m_pcEncTop->getVPS(), pcSlice->getSPS() );
    2299 #else
    2300       m_seiWriter.writeSEImessage( nalu.m_Bitstream, seiTMVPConstrains, pcSlice->getSPS() );
    2301 #endif
    2302       writeRBSPTrailingBits(nalu.m_Bitstream);
    2303       accessUnit.push_back(new NALUnitEBSP(nalu));
    2304    }
    2305 #endif
    2306 #if Q0247_FRAME_FIELD_INFO
    2307     if(  pcSlice->getLayerId()> 0 &&
    2308      ( (m_pcCfg->getProgressiveSourceFlag() && m_pcCfg->getInterlacedSourceFlag()) || m_pcCfg->getFrameFieldInfoPresentFlag()))
    2309     {
    2310       OutputNALUnit nalu(NAL_UNIT_PREFIX_SEI);
    2311       SEIFrameFieldInfo seiFFInfo;
    2312       m_pcEntropyCoder->setEntropyCoder(m_pcCavlcCoder, pcSlice);
    2313       m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
    2314       seiFFInfo.m_ffinfo_picStruct = (isField && pcSlice->getPic()->isTopField())? 1 : isField? 2 : 0;
    2315 #if O0164_MULTI_LAYER_HRD
    2316       m_seiWriter.writeSEImessage( nalu.m_Bitstream, seiFFInfo, m_pcEncTop->getVPS(), pcSlice->getSPS() );
    2317 #else
    2318       m_seiWriter.writeSEImessage( nalu.m_Bitstream, seiFFInfo, pcSlice->getSPS() );
    2319 #endif
    2320       writeRBSPTrailingBits(nalu.m_Bitstream);
    2321       accessUnit.push_back(new NALUnitEBSP(nalu));
    2322     }
    2323 #endif
    2324 
    2325     if( ( m_pcCfg->getPictureTimingSEIEnabled() || m_pcCfg->getDecodingUnitInfoSEIEnabled() ) &&
    2326         ( pcSlice->getSPS()->getVuiParametersPresentFlag() ) &&
    2327         ( ( pcSlice->getSPS()->getVuiParameters()->getHrdParameters()->getNalHrdParametersPresentFlag() )
    2328        || ( pcSlice->getSPS()->getVuiParameters()->getHrdParameters()->getVclHrdParametersPresentFlag() ) ) )
    2329     {
    2330       if( pcSlice->getSPS()->getVuiParameters()->getHrdParameters()->getSubPicCpbParamsPresentFlag() )
    2331       {
    2332         UInt numDU = pcSlice->getSPS()->getVuiParameters()->getHrdParameters()->getNumDU();
    2333         pictureTimingSEI.m_numDecodingUnitsMinus1     = ( numDU - 1 );
    2334         pictureTimingSEI.m_duCommonCpbRemovalDelayFlag = false;
    2335 
    2336         if( pictureTimingSEI.m_numNalusInDuMinus1 == NULL )
    2337         {
    2338           pictureTimingSEI.m_numNalusInDuMinus1       = new UInt[ numDU ];
    2339         }
    2340         if( pictureTimingSEI.m_duCpbRemovalDelayMinus1  == NULL )
    2341         {
    2342           pictureTimingSEI.m_duCpbRemovalDelayMinus1  = new UInt[ numDU ];
    2343         }
    2344         if( accumBitsDU == NULL )
    2345         {
    2346           accumBitsDU                                  = new UInt[ numDU ];
    2347         }
    2348         if( accumNalsDU == NULL )
    2349         {
    2350           accumNalsDU                                  = new UInt[ numDU ];
    2351         }
    2352       }
    2353       pictureTimingSEI.m_auCpbRemovalDelay = std::min<Int>(std::max<Int>(1, m_totalCoded - m_lastBPSEI), static_cast<Int>(pow(2, static_cast<Double>(pcSlice->getSPS()->getVuiParameters()->getHrdParameters()->getCpbRemovalDelayLengthMinus1()+1)))); // Syntax element signalled as minus, hence the .
    2354 #if SVC_EXTENSION
    2355       pictureTimingSEI.m_picDpbOutputDelay = pcSlice->getSPS()->getNumReorderPics(pcSlice->getSPS()->getMaxTLayers()-1) + pocCurr - m_totalCoded;
    2356 #else
    2357       pictureTimingSEI.m_picDpbOutputDelay = pcSlice->getSPS()->getNumReorderPics(pcSlice->getSPS()->getMaxTLayers()-1) + pcSlice->getPOC() - m_totalCoded;
    2358 #endif
    2359 #if EFFICIENT_FIELD_IRAP
    2360       if(IRAPGOPid > 0 && IRAPGOPid < m_iGopSize)
    2361       {
    2362         // if pictures have been swapped there is likely one more picture delay on their tid. Very rough approximation
    2363         pictureTimingSEI.m_picDpbOutputDelay ++;
    2364       }
    2365 #endif
    2366       Int factor = pcSlice->getSPS()->getVuiParameters()->getHrdParameters()->getTickDivisorMinus2() + 2;
    2367       pictureTimingSEI.m_picDpbOutputDuDelay = factor * pictureTimingSEI.m_picDpbOutputDelay;
    2368       if( m_pcCfg->getDecodingUnitInfoSEIEnabled() )
    2369       {
    2370         picSptDpbOutputDuDelay = factor * pictureTimingSEI.m_picDpbOutputDelay;
    2371       }
    2372     }
    2373 
    2374     if( ( m_pcCfg->getBufferingPeriodSEIEnabled() ) && ( pcSlice->getSliceType() == I_SLICE ) &&
    2375         ( pcSlice->getSPS()->getVuiParametersPresentFlag() ) &&
    2376         ( ( pcSlice->getSPS()->getVuiParameters()->getHrdParameters()->getNalHrdParametersPresentFlag() )
    2377        || ( pcSlice->getSPS()->getVuiParameters()->getHrdParameters()->getVclHrdParametersPresentFlag() ) ) )
    2378     {
    2379       OutputNALUnit nalu(NAL_UNIT_PREFIX_SEI);
    2380       m_pcEntropyCoder->setEntropyCoder(m_pcCavlcCoder, pcSlice);
    2381       m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
    2382 
    2383       SEIBufferingPeriod sei_buffering_period;
    2384 
    2385       UInt uiInitialCpbRemovalDelay = (90000/2);                      // 0.5 sec
    2386       sei_buffering_period.m_initialCpbRemovalDelay      [0][0]     = uiInitialCpbRemovalDelay;
    2387       sei_buffering_period.m_initialCpbRemovalDelayOffset[0][0]     = uiInitialCpbRemovalDelay;
    2388       sei_buffering_period.m_initialCpbRemovalDelay      [0][1]     = uiInitialCpbRemovalDelay;
    2389       sei_buffering_period.m_initialCpbRemovalDelayOffset[0][1]     = uiInitialCpbRemovalDelay;
    2390 
    2391       Double dTmp = (Double)pcSlice->getSPS()->getVuiParameters()->getTimingInfo()->getNumUnitsInTick() / (Double)pcSlice->getSPS()->getVuiParameters()->getTimingInfo()->getTimeScale();
    2392 
    2393       UInt uiTmp = (UInt)( dTmp * 90000.0 );
    2394       uiInitialCpbRemovalDelay -= uiTmp;
    2395       uiInitialCpbRemovalDelay -= uiTmp / ( pcSlice->getSPS()->getVuiParameters()->getHrdParameters()->getTickDivisorMinus2() + 2 );
    2396       sei_buffering_period.m_initialAltCpbRemovalDelay      [0][0]  = uiInitialCpbRemovalDelay;
    2397       sei_buffering_period.m_initialAltCpbRemovalDelayOffset[0][0]  = uiInitialCpbRemovalDelay;
    2398       sei_buffering_period.m_initialAltCpbRemovalDelay      [0][1]  = uiInitialCpbRemovalDelay;
    2399       sei_buffering_period.m_initialAltCpbRemovalDelayOffset[0][1]  = uiInitialCpbRemovalDelay;
    2400 
    2401       sei_buffering_period.m_rapCpbParamsPresentFlag              = 0;
    2402       //for the concatenation, it can be set to one during splicing.
    2403       sei_buffering_period.m_concatenationFlag = 0;
    2404       //since the temporal layer HRD is not ready, we assumed it is fixed
    2405       sei_buffering_period.m_auCpbRemovalDelayDelta = 1;
    2406 
    2407       sei_buffering_period.m_cpbDelayOffset = 0;
    2408       sei_buffering_period.m_dpbDelayOffset = 0;
    2409 
    2410 #if O0164_MULTI_LAYER_HRD
    2411       m_seiWriter.writeSEImessage( nalu.m_Bitstream, sei_buffering_period, m_pcEncTop->getVPS(), pcSlice->getSPS());
    2412 #else
    2413       m_seiWriter.writeSEImessage( nalu.m_Bitstream, sei_buffering_period, pcSlice->getSPS());
    2414 #endif
    2415       writeRBSPTrailingBits(nalu.m_Bitstream);
    2416 
    2417       {
    2418         UInt seiPositionInAu = xGetFirstSeiLocation(accessUnit);
    2419         UInt offsetPosition = m_activeParameterSetSEIPresentInAU;   // Insert BP SEI after APS SEI
    2420         AccessUnit::iterator it = accessUnit.begin();
    2421         for(Int j = 0; j < seiPositionInAu + offsetPosition; j++)
    2422         {
    2423           it++;
    2424         }
    2425         accessUnit.insert(it, new NALUnitEBSP(nalu));
    2426         m_bufferingPeriodSEIPresentInAU = true;
    2427       }
    2428 
    2429       if (m_pcCfg->getScalableNestingSEIEnabled())
    2430       {
    2431         OutputNALUnit naluTmp(NAL_UNIT_PREFIX_SEI);
    2432         m_pcEntropyCoder->setEntropyCoder(m_pcCavlcCoder, pcSlice);
    2433         m_pcEntropyCoder->setBitstream(&naluTmp.m_Bitstream);
    2434         scalableNestingSEI.m_nestedSEIs.clear();
    2435         scalableNestingSEI.m_nestedSEIs.push_back(&sei_buffering_period);
    2436 #if O0164_MULTI_LAYER_HRD
    2437         m_seiWriter.writeSEImessage( naluTmp.m_Bitstream, scalableNestingSEI, m_pcEncTop->getVPS(), pcSlice->getSPS());
    2438 #else
    2439         m_seiWriter.writeSEImessage( naluTmp.m_Bitstream, scalableNestingSEI, pcSlice->getSPS());
    2440 #endif
    2441         writeRBSPTrailingBits(naluTmp.m_Bitstream);
    2442         UInt seiPositionInAu = xGetFirstSeiLocation(accessUnit);
    2443         UInt offsetPosition = m_activeParameterSetSEIPresentInAU + m_bufferingPeriodSEIPresentInAU + m_pictureTimingSEIPresentInAU;   // Insert BP SEI after non-nested APS, BP and PT SEIs
    2444         AccessUnit::iterator it = accessUnit.begin();
    2445         for(Int j = 0; j < seiPositionInAu + offsetPosition; j++)
    2446         {
    2447           it++;
    2448         }
    2449         accessUnit.insert(it, new NALUnitEBSP(naluTmp));
    2450         m_nestedBufferingPeriodSEIPresentInAU = true;
    2451       }
    2452 
    2453       m_lastBPSEI = m_totalCoded;
    2454       m_cpbRemovalDelay = 0;
    2455     }
    2456     m_cpbRemovalDelay ++;
    2457 
    2458     if(pcSlice->getSPS()->getVuiParametersPresentFlag() && m_pcCfg->getChromaSamplingFilterHintEnabled() && ( pcSlice->getSliceType() == I_SLICE ))
    2459     {
    2460       SEIChromaSamplingFilterHint *seiChromaSamplingFilterHint = xCreateSEIChromaSamplingFilterHint(m_pcCfg->getChromaLocInfoPresentFlag(), m_pcCfg->getChromaSamplingHorFilterIdc(), m_pcCfg->getChromaSamplingVerFilterIdc());
    2461 
    2462       OutputNALUnit naluTmp(NAL_UNIT_PREFIX_SEI);
    2463       m_pcEntropyCoder->setEntropyCoder(m_pcCavlcCoder, pcSlice);
    2464       m_pcEntropyCoder->setBitstream(&naluTmp.m_Bitstream);
    2465 #if O0164_MULTI_LAYER_HRD
    2466       m_seiWriter.writeSEImessage(naluTmp.m_Bitstream, *seiChromaSamplingFilterHint, m_pcEncTop->getVPS(), pcSlice->getSPS());
    2467 #else
    2468       m_seiWriter.writeSEImessage(naluTmp.m_Bitstream, *seiChromaSamplingFilterHint, pcSlice->getSPS());
    2469 #endif
    2470       writeRBSPTrailingBits(naluTmp.m_Bitstream);
    2471       accessUnit.push_back(new NALUnitEBSP(naluTmp));
    2472       delete seiChromaSamplingFilterHint;
    2473     }
    2474 
    2475     if( ( m_pcEncTop->getRecoveryPointSEIEnabled() ) && ( pcSlice->getSliceType() == I_SLICE ) )
    2476     {
    2477       if( m_pcEncTop->getGradualDecodingRefreshInfoEnabled() && !pcSlice->getRapPicFlag() )
    2478       {
    2479         // Gradual decoding refresh SEI
    2480         OutputNALUnit nalu(NAL_UNIT_PREFIX_SEI);
    2481         m_pcEntropyCoder->setEntropyCoder(m_pcCavlcCoder, pcSlice);
    2482         m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
    2483 
    2484         SEIGradualDecodingRefreshInfo seiGradualDecodingRefreshInfo;
    2485         seiGradualDecodingRefreshInfo.m_gdrForegroundFlag = true; // Indicating all "foreground"
    2486 
    2487 #if O0164_MULTI_LAYER_HRD
    2488         m_seiWriter.writeSEImessage( nalu.m_Bitstream, seiGradualDecodingRefreshInfo, m_pcEncTop->getVPS(), pcSlice->getSPS() );
    2489 #else
    2490         m_seiWriter.writeSEImessage( nalu.m_Bitstream, seiGradualDecodingRefreshInfo, pcSlice->getSPS() );
    2491 #endif
    2492         writeRBSPTrailingBits(nalu.m_Bitstream);
    2493         accessUnit.push_back(new NALUnitEBSP(nalu));
    2494       }
    2495     // Recovery point SEI
    2496       OutputNALUnit nalu(NAL_UNIT_PREFIX_SEI);
    2497       m_pcEntropyCoder->setEntropyCoder(m_pcCavlcCoder, pcSlice);
    2498       m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
    2499 
    2500       SEIRecoveryPoint sei_recovery_point;
    2501       sei_recovery_point.m_recoveryPocCnt    = 0;
    2502 #if SVC_EXTENSION
    2503       sei_recovery_point.m_exactMatchingFlag = ( pocCurr == 0 ) ? (true) : (false);
    2504 #else
    2505       sei_recovery_point.m_exactMatchingFlag = ( pcSlice->getPOC() == 0 ) ? (true) : (false);
    2506 #endif
    2507       sei_recovery_point.m_brokenLinkFlag    = false;
    2508 #if ALLOW_RECOVERY_POINT_AS_RAP
    2509       if(m_pcCfg->getDecodingRefreshType() == 3)
    2510       {
    2511         m_iLastRecoveryPicPOC = pocCurr;
    2512       }
    2513 #endif
    2514 
    2515 #if O0164_MULTI_LAYER_HRD
    2516       m_seiWriter.writeSEImessage( nalu.m_Bitstream, sei_recovery_point, m_pcEncTop->getVPS(), pcSlice->getSPS() );
    2517 #else
    2518       m_seiWriter.writeSEImessage( nalu.m_Bitstream, sei_recovery_point, pcSlice->getSPS() );
    2519 #endif
    2520       writeRBSPTrailingBits(nalu.m_Bitstream);
    2521       accessUnit.push_back(new NALUnitEBSP(nalu));
    2522     }
    2523 
    2524     if( m_pcEncTop->getNoDisplaySEITLayer() )
    2525     {
    2526       if( pcSlice->getTLayer() >= m_pcEncTop->getNoDisplaySEITLayer() )
    2527       {
    2528         // No display SEI
    2529         OutputNALUnit nalu(NAL_UNIT_PREFIX_SEI);
    2530         m_pcEntropyCoder->setEntropyCoder(m_pcCavlcCoder, pcSlice);
    2531         m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
    2532 
    2533         SEINoDisplay seiNoDisplay;
    2534         seiNoDisplay.m_noDisplay = true;
    2535 
    2536 #if O0164_MULTI_LAYER_HRD
    2537         m_seiWriter.writeSEImessage( nalu.m_Bitstream, seiNoDisplay, m_pcEncTop->getVPS(), pcSlice->getSPS() );
    2538 #else
    2539         m_seiWriter.writeSEImessage( nalu.m_Bitstream, seiNoDisplay, pcSlice->getSPS() );
    2540 #endif
    2541         writeRBSPTrailingBits(nalu.m_Bitstream);
    2542         accessUnit.push_back(new NALUnitEBSP(nalu));
    2543       }
    2544     }
    2545 
    2546     // insert one CRI by picture (if the file exist)
    2547 #if Q0074_COLOUR_REMAPPING_SEI
    2548  
    2549     freeColourCRI();
    2550 
    2551     // building the CRI file name with poc num in suffix "_poc.txt"
    2552     char suffix[10];
    2553     sprintf(suffix, "_%d.txt",  pcSlice->getPOC());
    2554     string  colourRemapSEIFileWithPoc(m_pcCfg->getCRISEIFileRoot());
    2555     colourRemapSEIFileWithPoc.append(suffix);
    2556     setCRISEIFile( const_cast<Char*>(colourRemapSEIFileWithPoc.c_str()) );
    2557  
    2558     Int ret = readingCRIparameters();
    2559 
    2560     if(ret != -1 && m_pcCfg->getCRISEIFileRoot())
    2561     {
    2562       // check validity of input parameters
    2563       xCheckParameter();
    2564 
    2565       SEIColourRemappingInfo *sei = xCreateSEIColourRemappingInfo ();
    2566 #if SVC_EXTENSION
    2567       OutputNALUnit nalu(NAL_UNIT_PREFIX_SEI, 0, pcSlice->getSPS()->getLayerId());  // SEI-CRI is applied per layer
    2568 #else
    2569       OutputNALUnit nalu(NAL_UNIT_PREFIX_SEI);
    2570 #endif
    2571       m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream);
    2572 #if SVC_EXTENSION
    2573       m_seiWriter.writeSEImessage(nalu.m_Bitstream, *sei, m_pcEncTop->getVPS(), pcSlice->getSPS() );
    2574 #else
    2575       m_seiWriter.writeSEImessage(nalu.m_Bitstream, *sei, pcSlice->getSPS() );
    2576 #endif
    2577       writeRBSPTrailingBits(nalu.m_Bitstream);
    2578       accessUnit.push_back(new NALUnitEBSP(nalu));
    2579       delete sei;
    2580     }
    2581 #endif
     2487    // create prefix SEI associated with a picture
     2488    xCreatePerPictureSEIMessages(iGOPid, leadingSeiMessages, nestedSeiMessages, pcSlice);
    25822489
    25832490    /* use the main bitstream buffer for storing the marshalled picture */
     
    27532660        for (AccessUnit::const_iterator it = accessUnit.begin(); it != accessUnit.end(); it++)
    27542661        {
    2755           UInt numRBSPBytes_nal = UInt((*it)->m_nalUnitData.str().size());
    2756           if ((*it)->m_nalUnitType != NAL_UNIT_PREFIX_SEI && (*it)->m_nalUnitType != NAL_UNIT_SUFFIX_SEI)
    2757           {
    2758             numRBSPBytes += numRBSPBytes_nal;
    2759             numNalus ++;
    2760           }
    2761         }
    2762         accumBitsDU[ pcSlice->getSliceIdx() ] = ( numRBSPBytes << 3 );
    2763         accumNalsDU[ pcSlice->getSliceIdx() ] = numNalus;   // SEI not counted for bit count; hence shouldn't be counted for # of NALUs - only for consistency
     2662          numRBSPBytes += UInt((*it)->m_nalUnitData.str().size());
     2663          numNalus ++;
     2664        }
     2665        duData.push_back(DUData());
     2666        duData.back().accumBitsDU = ( numRBSPBytes << 3 );
     2667        duData.back().accumNalsDU = numNalus;
    27642668      }
    27652669    } // end iteration over slices
     
    27922696          if (m_pcCfg->getCabacZeroWordPaddingEnabled())
    27932697          {
    2794             std::vector<Char> zeroBytesPadding((size_t)numberOfAdditionalCabacZeroBytes, Char(0));
     2698            std::vector<Char> zeroBytesPadding(numberOfAdditionalCabacZeroBytes, Char(0));
    27952699            for(std::size_t i=0; i<numberOfAdditionalCabacZeroWords; i++)
    27962700            {
    27972701              zeroBytesPadding[i*3+2]=3;  // 00 00 03
    27982702            }
    2799             accessUnit.back()->m_nalUnitData.write(&(zeroBytesPadding[0]), (size_t)numberOfAdditionalCabacZeroBytes);
     2703            accessUnit.back()->m_nalUnitData.write(&(zeroBytesPadding[0]), numberOfAdditionalCabacZeroBytes);
    28002704            printf("Adding %d bytes of padding\n", UInt(numberOfAdditionalCabacZeroWords*3));
    28012705          }
     
    28162720    if (m_pcCfg->getDecodedPictureHashSEIEnabled())
    28172721    {
    2818       /* calculate MD5sum for entire reconstructed picture */
    2819       SEIDecodedPictureHash sei_recon_picture_digest;
    2820       if(m_pcCfg->getDecodedPictureHashSEIEnabled() == 1)
    2821       {
    2822         sei_recon_picture_digest.method = SEIDecodedPictureHash::MD5;
    2823         UInt numChar=calcMD5(*pcPic->getPicYuvRec(), sei_recon_picture_digest.m_digest);
    2824         digestStr = digestToString(sei_recon_picture_digest.m_digest, numChar);
    2825       }
    2826       else if(m_pcCfg->getDecodedPictureHashSEIEnabled() == 2)
    2827       {
    2828         sei_recon_picture_digest.method = SEIDecodedPictureHash::CRC;
    2829         UInt numChar=calcCRC(*pcPic->getPicYuvRec(), sei_recon_picture_digest.m_digest);
    2830         digestStr = digestToString(sei_recon_picture_digest.m_digest, numChar);
    2831       }
    2832       else if(m_pcCfg->getDecodedPictureHashSEIEnabled() == 3)
    2833       {
    2834         sei_recon_picture_digest.method = SEIDecodedPictureHash::CHECKSUM;
    2835         UInt numChar=calcChecksum(*pcPic->getPicYuvRec(), sei_recon_picture_digest.m_digest);
    2836         digestStr = digestToString(sei_recon_picture_digest.m_digest, numChar);
    2837       }
    2838 
    2839 #if SVC_EXTENSION
    2840       OutputNALUnit nalu(NAL_UNIT_SUFFIX_SEI, pcSlice->getTLayer(), m_layerId);
    2841 #else
    2842       OutputNALUnit nalu(NAL_UNIT_SUFFIX_SEI, pcSlice->getTLayer());
    2843 #endif
    2844 
    2845       /* write the SEI messages */
    2846       m_pcEntropyCoder->setEntropyCoder(m_pcCavlcCoder, pcSlice);
     2722      SEIDecodedPictureHash *decodedPictureHashSei = new SEIDecodedPictureHash();
     2723      m_seiEncoder.initDecodedPictureHashSEI(decodedPictureHashSei, pcPic, digestStr);
     2724      trailingSeiMessages.push_back(decodedPictureHashSei);
     2725    }
     2726
    28472727#if O0164_MULTI_LAYER_HRD
    2848       m_seiWriter.writeSEImessage(nalu.m_Bitstream, sei_recon_picture_digest, m_pcEncTop->getVPS(), pcSlice->getSPS());
    2849 #else
    2850       m_seiWriter.writeSEImessage(nalu.m_Bitstream, sei_recon_picture_digest, pcSlice->getSPS());
    2851 #endif
    2852       writeRBSPTrailingBits(nalu.m_Bitstream);
    2853 
    2854       accessUnit.insert(accessUnit.end(), new NALUnitEBSP(nalu));
    2855     }
    2856     if (m_pcCfg->getTemporalLevel0IndexSEIEnabled())
    2857     {
    2858       SEITemporalLevel0Index sei_temporal_level0_index;
    2859       if (pcSlice->getRapPicFlag())
    2860       {
    2861         m_tl0Idx = 0;
    2862         m_rapIdx = (m_rapIdx + 1) & 0xFF;
    2863       }
    2864       else
    2865       {
    2866         m_tl0Idx = (m_tl0Idx + (pcSlice->getTLayer() ? 0 : 1)) & 0xFF;
    2867       }
    2868       sei_temporal_level0_index.tl0Idx = m_tl0Idx;
    2869       sei_temporal_level0_index.rapIdx = m_rapIdx;
    2870 
    2871       OutputNALUnit nalu(NAL_UNIT_PREFIX_SEI);
    2872 
    2873       /* write the SEI messages */
    2874       m_pcEntropyCoder->setEntropyCoder(m_pcCavlcCoder, pcSlice);
    2875 #if O0164_MULTI_LAYER_HRD
    2876       m_seiWriter.writeSEImessage(nalu.m_Bitstream, sei_temporal_level0_index, m_pcEncTop->getVPS(), pcSlice->getSPS());
    2877 #else
    2878       m_seiWriter.writeSEImessage(nalu.m_Bitstream, sei_temporal_level0_index, pcSlice->getSPS());     
    2879 #endif
    2880       writeRBSPTrailingBits(nalu.m_Bitstream);
    2881 
    2882       /* insert the SEI message NALUnit before any Slice NALUnits */
    2883       AccessUnit::iterator it = find_if(accessUnit.begin(), accessUnit.end(), mem_fun(&NALUnit::isSlice));
    2884       accessUnit.insert(it, new NALUnitEBSP(nalu));
    2885     }
     2728    xWriteTrailingSEIMessages(trailingSeiMessages, accessUnit, pcSlice->getTLayer(), pcSlice->getVPS(), pcSlice->getSPS());
     2729#else
     2730    xWriteTrailingSEIMessages(trailingSeiMessages, accessUnit, pcSlice->getTLayer(), pcSlice->getSPS());
     2731#endif
     2732    trailingSeiMessages.clear();
    28862733
    28872734    m_pcCfg->setEncodedFlag(iGOPid, true);
     
    29892836    }
    29902837
    2991     if( ( m_pcCfg->getPictureTimingSEIEnabled() || m_pcCfg->getDecodingUnitInfoSEIEnabled() ) &&
    2992         ( pcSlice->getSPS()->getVuiParametersPresentFlag() ) &&
    2993         ( ( pcSlice->getSPS()->getVuiParameters()->getHrdParameters()->getNalHrdParametersPresentFlag() )
    2994         || ( pcSlice->getSPS()->getVuiParameters()->getHrdParameters()->getVclHrdParametersPresentFlag() ) ) )
    2995     {
    2996       const TComVUI *vui = pcSlice->getSPS()->getVuiParameters();
    2997       const TComHRD *hrd = vui->getHrdParameters();
    2998 
    2999       if( hrd->getSubPicCpbParamsPresentFlag() )
    3000       {
    3001         Int i;
    3002         UInt64 ui64Tmp;
    3003         UInt uiPrev = 0;
    3004         UInt numDU = ( pictureTimingSEI.m_numDecodingUnitsMinus1 + 1 );
    3005         UInt *pCRD = &pictureTimingSEI.m_duCpbRemovalDelayMinus1[0];
    3006         UInt maxDiff = ( hrd->getTickDivisorMinus2() + 2 ) - 1;
    3007 
    3008         for( i = 0; i < numDU; i ++ )
    3009         {
    3010           pictureTimingSEI.m_numNalusInDuMinus1[ i ]       = ( i == 0 ) ? ( accumNalsDU[ i ] - 1 ) : ( accumNalsDU[ i ] - accumNalsDU[ i - 1] - 1 );
    3011         }
    3012 
    3013         if( numDU == 1 )
    3014         {
    3015           pCRD[ 0 ] = 0; /* don't care */
    3016         }
    3017         else
    3018         {
    3019           pCRD[ numDU - 1 ] = 0;/* by definition */
    3020           UInt tmp = 0;
    3021           UInt accum = 0;
    3022 
    3023           for( i = ( numDU - 2 ); i >= 0; i -- )
    3024           {
    3025             ui64Tmp = ( ( ( accumBitsDU[ numDU - 1 ]  - accumBitsDU[ i ] ) * ( vui->getTimingInfo()->getTimeScale() / vui->getTimingInfo()->getNumUnitsInTick() ) * ( hrd->getTickDivisorMinus2() + 2 ) ) / ( m_pcCfg->getTargetBitrate() ) );
    3026             if( (UInt)ui64Tmp > maxDiff )
    3027             {
    3028               tmp ++;
    3029             }
    3030           }
    3031           uiPrev = 0;
    3032 
    3033           UInt flag = 0;
    3034           for( i = ( numDU - 2 ); i >= 0; i -- )
    3035           {
    3036             flag = 0;
    3037             ui64Tmp = ( ( ( accumBitsDU[ numDU - 1 ]  - accumBitsDU[ i ] ) * ( vui->getTimingInfo()->getTimeScale() / vui->getTimingInfo()->getNumUnitsInTick() ) * ( hrd->getTickDivisorMinus2() + 2 ) ) / ( m_pcCfg->getTargetBitrate() ) );
    3038 
    3039             if( (UInt)ui64Tmp > maxDiff )
    3040             {
    3041               if(uiPrev >= maxDiff - tmp)
    3042               {
    3043                 ui64Tmp = uiPrev + 1;
    3044                 flag = 1;
    3045               }
    3046               else
    3047               {
    3048                 ui64Tmp = maxDiff - tmp + 1;
    3049               }
    3050             }
    3051             pCRD[ i ] = (UInt)ui64Tmp - uiPrev - 1;
    3052             if( (Int)pCRD[ i ] < 0 )
    3053             {
    3054               pCRD[ i ] = 0;
    3055             }
    3056             else if (tmp > 0 && flag == 1)
    3057             {
    3058               tmp --;
    3059             }
    3060             accum += pCRD[ i ] + 1;
    3061             uiPrev = accum;
    3062           }
    3063         }
    3064       }
    3065 
    3066       if( m_pcCfg->getPictureTimingSEIEnabled() )
    3067       {
    3068         {
    3069           OutputNALUnit nalu(NAL_UNIT_PREFIX_SEI, pcSlice->getTLayer());
    3070           m_pcEntropyCoder->setEntropyCoder(m_pcCavlcCoder, pcSlice);
    3071           pictureTimingSEI.m_picStruct = (isField && pcSlice->getPic()->isTopField())? 1 : isField? 2 : 0;
     2838    xCreatePictureTimingSEI(IRAPGOPid, leadingSeiMessages, nestedSeiMessages, duInfoSeiMessages, accessUnit, pcSlice, isField, duData);
     2839    if (m_pcCfg->getScalableNestingSEIEnabled())
     2840    {
     2841      xCreateScalableNestingSEI (leadingSeiMessages, nestedSeiMessages);
     2842    }
    30722843#if O0164_MULTI_LAYER_HRD
    3073           m_seiWriter.writeSEImessage(nalu.m_Bitstream, pictureTimingSEI, m_pcEncTop->getVPS(), pcSlice->getSPS());
    3074 #else
    3075           m_seiWriter.writeSEImessage(nalu.m_Bitstream, pictureTimingSEI, pcSlice->getSPS());
    3076 #endif
    3077           writeRBSPTrailingBits(nalu.m_Bitstream);
    3078           UInt seiPositionInAu = xGetFirstSeiLocation(accessUnit);
    3079           UInt offsetPosition = m_activeParameterSetSEIPresentInAU
    3080                                     + m_bufferingPeriodSEIPresentInAU;    // Insert PT SEI after APS and BP SEI
    3081           AccessUnit::iterator it = accessUnit.begin();
    3082           for(Int j = 0; j < seiPositionInAu + offsetPosition; j++)
    3083           {
    3084             it++;
    3085           }
    3086           accessUnit.insert(it, new NALUnitEBSP(nalu));
    3087           m_pictureTimingSEIPresentInAU = true;
    3088         }
    3089 
    3090         if ( m_pcCfg->getScalableNestingSEIEnabled() ) // put picture timing SEI into scalable nesting SEI
    3091         {
    3092           OutputNALUnit nalu(NAL_UNIT_PREFIX_SEI, pcSlice->getTLayer());
    3093           m_pcEntropyCoder->setEntropyCoder(m_pcCavlcCoder, pcSlice);
    3094           scalableNestingSEI.m_nestedSEIs.clear();
    3095           scalableNestingSEI.m_nestedSEIs.push_back(&pictureTimingSEI);
     2844    xWriteLeadingSEIMessages(leadingSeiMessages, duInfoSeiMessages, accessUnit, pcSlice->getTLayer(), pcSlice->getVPS(), pcSlice->getSPS(), duData);
     2845#else
     2846    xWriteLeadingSEIMessages(leadingSeiMessages, duInfoSeiMessages, accessUnit, pcSlice->getTLayer(), pcSlice->getSPS(), duData);
     2847#endif
     2848    leadingSeiMessages.clear();
    30962849#if O0164_MULTI_LAYER_HRD
    3097           m_seiWriter.writeSEImessage(nalu.m_Bitstream, scalableNestingSEI, m_pcEncTop->getVPS(), pcSlice->getSPS());
    3098 #else
    3099           m_seiWriter.writeSEImessage(nalu.m_Bitstream, scalableNestingSEI, pcSlice->getSPS());
    3100 #endif
    3101           writeRBSPTrailingBits(nalu.m_Bitstream);
    3102           UInt seiPositionInAu = xGetFirstSeiLocation(accessUnit);
    3103           UInt offsetPosition = m_activeParameterSetSEIPresentInAU
    3104             + m_bufferingPeriodSEIPresentInAU + m_pictureTimingSEIPresentInAU + m_nestedBufferingPeriodSEIPresentInAU;    // Insert PT SEI after APS and BP SEI
    3105           AccessUnit::iterator it = accessUnit.begin();
    3106           for(Int j = 0; j < seiPositionInAu + offsetPosition; j++)
    3107           {
    3108             it++;
    3109           }
    3110           accessUnit.insert(it, new NALUnitEBSP(nalu));
    3111           m_nestedPictureTimingSEIPresentInAU = true;
    3112         }
    3113       }
    3114 
    3115       if( m_pcCfg->getDecodingUnitInfoSEIEnabled() && hrd->getSubPicCpbParamsPresentFlag() )
    3116       {
    3117         m_pcEntropyCoder->setEntropyCoder(m_pcCavlcCoder, pcSlice);
    3118         for( Int i = 0; i < ( pictureTimingSEI.m_numDecodingUnitsMinus1 + 1 ); i ++ )
    3119         {
    3120           OutputNALUnit nalu(NAL_UNIT_PREFIX_SEI, pcSlice->getTLayer());
    3121 
    3122           SEIDecodingUnitInfo tempSEI;
    3123           tempSEI.m_decodingUnitIdx = i;
    3124           tempSEI.m_duSptCpbRemovalDelay = pictureTimingSEI.m_duCpbRemovalDelayMinus1[i] + 1;
    3125           tempSEI.m_dpbOutputDuDelayPresentFlag = false;
    3126           tempSEI.m_picSptDpbOutputDuDelay = picSptDpbOutputDuDelay;
    3127 
    3128           // Insert the first one in the right location, before the first slice
    3129           if(i == 0)
    3130           {
    3131             // Insert before the first slice.
    3132 #if O0164_MULTI_LAYER_HRD
    3133             m_seiWriter.writeSEImessage(nalu.m_Bitstream, tempSEI, m_pcEncTop->getVPS(), pcSlice->getSPS());
    3134 #else
    3135             m_seiWriter.writeSEImessage(nalu.m_Bitstream, tempSEI, pcSlice->getSPS());
    3136 #endif
    3137             writeRBSPTrailingBits(nalu.m_Bitstream);
    3138 
    3139             UInt seiPositionInAu = xGetFirstSeiLocation(accessUnit);
    3140             UInt offsetPosition = m_activeParameterSetSEIPresentInAU
    3141                                   + m_bufferingPeriodSEIPresentInAU
    3142                                   + m_pictureTimingSEIPresentInAU;  // Insert DU info SEI after APS, BP and PT SEI
    3143             AccessUnit::iterator it = accessUnit.begin();
    3144             for(Int j = 0; j < seiPositionInAu + offsetPosition; j++)
    3145             {
    3146               it++;
    3147             }
    3148             accessUnit.insert(it, new NALUnitEBSP(nalu));
    3149           }
    3150           else
    3151           {
    3152             // For the second decoding unit onwards we know how many NALUs are present
    3153             AccessUnit::iterator it = accessUnit.begin();
    3154             for (Int ctr = 0; it != accessUnit.end(); it++)
    3155             {
    3156               if(ctr == accumNalsDU[ i - 1 ])
    3157               {
    3158                 // Insert before the first slice.
    3159 #if O0164_MULTI_LAYER_HRD
    3160                 m_seiWriter.writeSEImessage(nalu.m_Bitstream, tempSEI, m_pcEncTop->getVPS(), pcSlice->getSPS());
    3161 #else
    3162                 m_seiWriter.writeSEImessage(nalu.m_Bitstream, tempSEI, pcSlice->getSPS());
    3163 #endif
    3164                 writeRBSPTrailingBits(nalu.m_Bitstream);
    3165 
    3166                 accessUnit.insert(it, new NALUnitEBSP(nalu));
    3167                 break;
    3168               }
    3169               if ((*it)->m_nalUnitType != NAL_UNIT_PREFIX_SEI && (*it)->m_nalUnitType != NAL_UNIT_SUFFIX_SEI)
    3170               {
    3171                 ctr++;
    3172               }
    3173             }
    3174           }
    3175         }
    3176       }
    3177     }
     2850    xWriteDuSEIMessages(duInfoSeiMessages, accessUnit, pcSlice->getTLayer(), pcSlice->getVPS(), pcSlice->getSPS(), duData);
     2851#else
     2852    xWriteDuSEIMessages(duInfoSeiMessages, accessUnit, pcSlice->getTLayer(), pcSlice->getSPS(), duData);
     2853#endif
    31782854
    31792855#if SVC_EXTENSION
     
    32512927
    32522928  delete pcBitstreamRedirect;
    3253 
    3254   if( accumBitsDU != NULL)
    3255   {
    3256     delete accumBitsDU;
    3257   }
    3258   if( accumNalsDU != NULL)
    3259   {
    3260     delete accumNalsDU;
    3261   }
    32622929
    32632930#if SVC_EXTENSION
     
    39983665}
    39993666
    4000 /** Function for finding the position to insert the first of APS and non-nested BP, PT, DU info SEI messages.
    4001  * \param accessUnit Access Unit of the current picture
    4002  * This function finds the position to insert the first of APS and non-nested BP, PT, DU info SEI messages.
    4003  */
    4004 Int TEncGOP::xGetFirstSeiLocation(AccessUnit &accessUnit)
    4005 {
    4006   // Find the location of the first SEI message
    4007   Int seiStartPos = 0;
    4008   for(AccessUnit::iterator it = accessUnit.begin(); it != accessUnit.end(); it++, seiStartPos++)
    4009   {
    4010      if ((*it)->isSei() || (*it)->isVcl())
    4011      {
    4012        break;
    4013      }
    4014   }
    4015   //  assert(it != accessUnit.end());  // Triggers with some legit configurations
    4016   return seiStartPos;
    4017 }
    4018 
    40193667Void TEncGOP::applyDeblockingFilterMetric( TComPic* pcPic, UInt uiNumSlices )
    40203668{
     
    41413789}
    41423790
    4143 #if P0123_ALPHA_CHANNEL_SEI
    4144 SEIAlphaChannelInfo* TEncGOP::xCreateSEIAlphaChannelInfo()
    4145 {
    4146   SEIAlphaChannelInfo *sei = new SEIAlphaChannelInfo();
    4147   sei->m_alphaChannelCancelFlag = m_pcCfg->getAlphaCancelFlag();
    4148   if(!sei->m_alphaChannelCancelFlag)
    4149   {
    4150     sei->m_alphaChannelUseIdc = m_pcCfg->getAlphaUseIdc();
    4151     sei->m_alphaChannelBitDepthMinus8 = m_pcCfg->getAlphaBitDepthMinus8();
    4152     sei->m_alphaTransparentValue = m_pcCfg->getAlphaTransparentValue();
    4153     sei->m_alphaOpaqueValue = m_pcCfg->getAlphaOpaqueValue();
    4154     sei->m_alphaChannelIncrFlag = m_pcCfg->getAlphaIncrementFlag();
    4155     sei->m_alphaChannelClipFlag = m_pcCfg->getAlphaClipFlag();
    4156     sei->m_alphaChannelClipTypeFlag = m_pcCfg->getAlphaClipTypeFlag();
    4157   }
    4158   return sei;
    4159 }
    4160 #endif
    4161 #if Q0096_OVERLAY_SEI
    4162 SEIOverlayInfo* TEncGOP::xCreateSEIOverlayInfo()
    4163 
    4164   SEIOverlayInfo *sei = new SEIOverlayInfo(); 
    4165   sei->m_overlayInfoCancelFlag = m_pcCfg->getOverlaySEICancelFlag();   
    4166   if ( !sei->m_overlayInfoCancelFlag )
    4167   {
    4168     sei->m_overlayContentAuxIdMinus128          = m_pcCfg->getOverlaySEIContentAuxIdMinus128();
    4169     sei->m_overlayLabelAuxIdMinus128            = m_pcCfg->getOverlaySEILabelAuxIdMinus128(); 
    4170     sei->m_overlayAlphaAuxIdMinus128            = m_pcCfg->getOverlaySEIAlphaAuxIdMinus128();
    4171     sei->m_overlayElementLabelValueLengthMinus8 = m_pcCfg->getOverlaySEIElementLabelValueLengthMinus8();
    4172     sei->m_numOverlaysMinus1                    = m_pcCfg->getOverlaySEINumOverlaysMinus1();     
    4173     sei->m_overlayIdx                           = m_pcCfg->getOverlaySEIIdx();           
    4174     sei->m_languageOverlayPresentFlag           = m_pcCfg->getOverlaySEILanguagePresentFlag();
    4175     sei->m_overlayContentLayerId                = m_pcCfg->getOverlaySEIContentLayerId();   
    4176     sei->m_overlayLabelPresentFlag              = m_pcCfg->getOverlaySEILabelPresentFlag();   
    4177     sei->m_overlayLabelLayerId                  = m_pcCfg->getOverlaySEILabelLayerId();   
    4178     sei->m_overlayAlphaPresentFlag              = m_pcCfg->getOverlaySEIAlphaPresentFlag();   
    4179     sei->m_overlayAlphaLayerId                  = m_pcCfg->getOverlaySEIAlphaLayerId();   
    4180     sei->m_numOverlayElementsMinus1             = m_pcCfg->getOverlaySEINumElementsMinus1();
    4181     sei->m_overlayElementLabelMin               = m_pcCfg->getOverlaySEIElementLabelMin();
    4182     sei->m_overlayElementLabelMax               = m_pcCfg->getOverlaySEIElementLabelMax();   
    4183     sei->m_overlayLanguage.resize               ( sei->m_numOverlaysMinus1+1, NULL );
    4184     sei->m_overlayLanguageLength.resize         ( sei->m_numOverlaysMinus1+1 );
    4185     sei->m_overlayName.resize                   ( sei->m_numOverlaysMinus1+1, NULL );
    4186     sei->m_overlayNameLength.resize             ( sei->m_numOverlaysMinus1+1 );
    4187     sei->m_overlayElementName.resize            ( sei->m_numOverlaysMinus1+1 );
    4188     sei->m_overlayElementNameLength.resize      ( sei->m_numOverlaysMinus1+1 ); 
    4189 
    4190     Int i,j;
    4191     string strTmp;
    4192     Int nBytes;
    4193     assert( m_pcCfg->getOverlaySEILanguage().size()    == sei->m_numOverlaysMinus1+1 );
    4194     assert( m_pcCfg->getOverlaySEIName().size()        == sei->m_numOverlaysMinus1+1 );
    4195     assert( m_pcCfg->getOverlaySEIElementName().size() == sei->m_numOverlaysMinus1+1 );
    4196    
    4197     for ( i=0 ; i<=sei->m_numOverlaysMinus1; i++ )
    4198     {     
    4199       //language tag
    4200       if ( sei->m_languageOverlayPresentFlag[i] )
    4201       {               
    4202         strTmp = m_pcCfg->getOverlaySEILanguage()[i];
    4203         nBytes = (Int)m_pcCfg->getOverlaySEILanguage()[i].size();       
    4204         assert( nBytes>0 );
    4205         sei->m_overlayLanguage[i] = new UChar[nBytes];
    4206         memcpy(sei->m_overlayLanguage[i], strTmp.c_str(), nBytes);       
    4207         sei->m_overlayLanguageLength[i] = nBytes;       
    4208       }
    4209 
    4210       //overlay name
    4211       strTmp = m_pcCfg->getOverlaySEIName()[i];
    4212       nBytes = (Int)m_pcCfg->getOverlaySEIName()[i].size();       
    4213       assert( nBytes>0 );
    4214       sei->m_overlayName[i] = new UChar[nBytes];     
    4215       memcpy(sei->m_overlayName[i], strTmp.c_str(), nBytes);       
    4216       sei->m_overlayNameLength[i] = nBytes;
    4217 
    4218       //overlay element names
    4219       if ( sei->m_overlayLabelPresentFlag[i] )
    4220       {       
    4221         sei->m_overlayElementName[i].resize( sei->m_numOverlayElementsMinus1[i]+1, NULL );
    4222         sei->m_overlayElementNameLength[i].resize( sei->m_numOverlayElementsMinus1[i]+1 );
    4223         assert( m_pcCfg->getOverlaySEIElementName()[i].size() == sei->m_numOverlayElementsMinus1[i]+1 );       
    4224         for ( j=0 ; j<=sei->m_numOverlayElementsMinus1[i] ; j++)
    4225         {
    4226           strTmp = m_pcCfg->getOverlaySEIElementName()[i][j];
    4227           nBytes = (Int)m_pcCfg->getOverlaySEIElementName()[i][j].size();       
    4228           assert( nBytes>0 );
    4229           sei->m_overlayElementName[i][j] = new UChar[nBytes];
    4230           memcpy(sei->m_overlayElementName[i][j], strTmp.c_str(), nBytes);       
    4231           sei->m_overlayElementNameLength[i][j] = nBytes;
    4232         }
    4233       }
    4234     }
    4235   sei->m_overlayInfoPersistenceFlag = true;
    4236   }
    4237   return sei;
    4238 }
    4239 #endif
    4240 
    4241 #if Q0074_COLOUR_REMAPPING_SEI
    4242 SEIColourRemappingInfo*  TEncGOP::xCreateSEIColourRemappingInfo()
    4243 {
    4244   SEIColourRemappingInfo *seiColourRemappingInfo = new SEIColourRemappingInfo();
    4245   seiColourRemappingInfo->m_colourRemapId         = m_colourRemapSEIId;
    4246   seiColourRemappingInfo->m_colourRemapCancelFlag = m_colourRemapSEICancelFlag;
    4247   printf("xCreateSEIColourRemappingInfo - m_colourRemapId = %d m_colourRemapCancelFlag = %d \n",seiColourRemappingInfo->m_colourRemapId, seiColourRemappingInfo->m_colourRemapCancelFlag);
    4248 
    4249   if( !seiColourRemappingInfo->m_colourRemapCancelFlag )
    4250   {
    4251     seiColourRemappingInfo->m_colourRemapPersistenceFlag            = m_colourRemapSEIPersistenceFlag;
    4252     seiColourRemappingInfo->m_colourRemapVideoSignalInfoPresentFlag = m_colourRemapSEIVideoSignalInfoPresentFlag;
    4253     if( seiColourRemappingInfo->m_colourRemapVideoSignalInfoPresentFlag )
    4254     {
    4255       seiColourRemappingInfo->m_colourRemapFullRangeFlag           = m_colourRemapSEIFullRangeFlag;
    4256       seiColourRemappingInfo->m_colourRemapPrimaries               = m_colourRemapSEIPrimaries;
    4257       seiColourRemappingInfo->m_colourRemapTransferFunction        = m_colourRemapSEITransferFunction;
    4258       seiColourRemappingInfo->m_colourRemapMatrixCoefficients      = m_colourRemapSEIMatrixCoefficients;
    4259     }
    4260     seiColourRemappingInfo->m_colourRemapInputBitDepth             = m_colourRemapSEIInputBitDepth;
    4261     seiColourRemappingInfo->m_colourRemapBitDepth                  = m_colourRemapSEIBitDepth;
    4262     for( Int c=0 ; c<3 ; c++ )
    4263     {
    4264       seiColourRemappingInfo->m_preLutNumValMinus1[c] = m_colourRemapSEIPreLutNumValMinus1[c];
    4265       if( seiColourRemappingInfo->m_preLutNumValMinus1[c]>0 )
    4266       {
    4267         seiColourRemappingInfo->m_preLutCodedValue[c].resize(seiColourRemappingInfo->m_preLutNumValMinus1[c]+1);
    4268         seiColourRemappingInfo->m_preLutTargetValue[c].resize(seiColourRemappingInfo->m_preLutNumValMinus1[c]+1);
    4269         for( Int i=0 ; i<=seiColourRemappingInfo->m_preLutNumValMinus1[c] ; i++)
    4270         {
    4271           seiColourRemappingInfo->m_preLutCodedValue[c][i]  = m_colourRemapSEIPreLutCodedValue[c][i];
    4272           seiColourRemappingInfo->m_preLutTargetValue[c][i] = m_colourRemapSEIPreLutTargetValue[c][i];
    4273         }
    4274       }
    4275     }
    4276     seiColourRemappingInfo->m_colourRemapMatrixPresentFlag = m_colourRemapSEIMatrixPresentFlag;
    4277     if( seiColourRemappingInfo->m_colourRemapMatrixPresentFlag )
    4278     {
    4279       seiColourRemappingInfo->m_log2MatrixDenom = m_colourRemapSEILog2MatrixDenom;
    4280       for( Int c=0 ; c<3 ; c++ )
    4281         for( Int i=0 ; i<3 ; i++ )
    4282           seiColourRemappingInfo->m_colourRemapCoeffs[c][i] = m_colourRemapSEICoeffs[c][i];
    4283     }
    4284     for( Int c=0 ; c<3 ; c++ )
    4285     {
    4286       seiColourRemappingInfo->m_postLutNumValMinus1[c] = m_colourRemapSEIPostLutNumValMinus1[c];
    4287       if( seiColourRemappingInfo->m_postLutNumValMinus1[c]>0 )
    4288       {
    4289         seiColourRemappingInfo->m_postLutCodedValue[c].resize(seiColourRemappingInfo->m_postLutNumValMinus1[c]+1);
    4290         seiColourRemappingInfo->m_postLutTargetValue[c].resize(seiColourRemappingInfo->m_postLutNumValMinus1[c]+1);
    4291         for( Int i=0 ; i<=seiColourRemappingInfo->m_postLutNumValMinus1[c] ; i++)
    4292         {
    4293           seiColourRemappingInfo->m_postLutCodedValue[c][i]  = m_colourRemapSEIPostLutCodedValue[c][i];
    4294           seiColourRemappingInfo->m_postLutTargetValue[c][i] = m_colourRemapSEIPostLutTargetValue[c][i];
    4295         }
    4296       }
    4297     }
    4298   }
    4299   return seiColourRemappingInfo;
    4300 }
    4301 #endif
    4302 
    43033791#if SVC_EXTENSION
    4304 #if LAYERS_NOT_PRESENT_SEI
    4305 SEILayersNotPresent* TEncGOP::xCreateSEILayersNotPresent ()
    4306 {
    4307   UInt i = 0;
    4308   SEILayersNotPresent *seiLayersNotPresent = new SEILayersNotPresent();
    4309   seiLayersNotPresent->m_activeVpsId = m_pcCfg->getVPS()->getVPSId();
    4310   seiLayersNotPresent->m_vpsMaxLayers = m_pcCfg->getVPS()->getMaxLayers();
    4311   for ( ; i < seiLayersNotPresent->m_vpsMaxLayers; i++)
    4312   {
    4313     seiLayersNotPresent->m_layerNotPresentFlag[i] = true;
    4314   }
    4315   for ( ; i < MAX_LAYERS; i++)
    4316   {
    4317     seiLayersNotPresent->m_layerNotPresentFlag[i] = false;
    4318   }
    4319   return seiLayersNotPresent;
    4320 }
    4321 #endif
    4322 
    43233792#if N0383_IL_CONSTRAINED_TILE_SETS_SEI
    4324 SEIInterLayerConstrainedTileSets* TEncGOP::xCreateSEIInterLayerConstrainedTileSets()
    4325 {
    4326   SEIInterLayerConstrainedTileSets *seiInterLayerConstrainedTileSets = new SEIInterLayerConstrainedTileSets();
    4327   seiInterLayerConstrainedTileSets->m_ilAllTilesExactSampleValueMatchFlag = false;
    4328   seiInterLayerConstrainedTileSets->m_ilOneTilePerTileSetFlag = false;
    4329   if (!seiInterLayerConstrainedTileSets->m_ilOneTilePerTileSetFlag)
    4330   {
    4331     seiInterLayerConstrainedTileSets->m_ilNumSetsInMessageMinus1 = m_pcCfg->getIlNumSetsInMessage() - 1;
    4332     if (seiInterLayerConstrainedTileSets->m_ilNumSetsInMessageMinus1)
    4333     {
    4334       seiInterLayerConstrainedTileSets->m_skippedTileSetPresentFlag = m_pcCfg->getSkippedTileSetPresentFlag();
    4335     }
    4336     else
    4337     {
    4338       seiInterLayerConstrainedTileSets->m_skippedTileSetPresentFlag = false;
    4339     }
    4340     seiInterLayerConstrainedTileSets->m_ilNumSetsInMessageMinus1 += seiInterLayerConstrainedTileSets->m_skippedTileSetPresentFlag ? 1 : 0;
    4341     for (UInt i = 0; i < m_pcCfg->getIlNumSetsInMessage(); i++)
    4342     {
    4343       seiInterLayerConstrainedTileSets->m_ilctsId[i] = i;
    4344       seiInterLayerConstrainedTileSets->m_ilNumTileRectsInSetMinus1[i] = 0;
    4345       for( UInt j = 0; j <= seiInterLayerConstrainedTileSets->m_ilNumTileRectsInSetMinus1[i]; j++)
    4346       {
    4347         seiInterLayerConstrainedTileSets->m_ilTopLeftTileIndex[i][j]     = m_pcCfg->getTopLeftTileIndex(i);
    4348         seiInterLayerConstrainedTileSets->m_ilBottomRightTileIndex[i][j] = m_pcCfg->getBottomRightTileIndex(i);
    4349       }
    4350       seiInterLayerConstrainedTileSets->m_ilcIdc[i] = m_pcCfg->getIlcIdc(i);
    4351       if (seiInterLayerConstrainedTileSets->m_ilAllTilesExactSampleValueMatchFlag)
    4352       {
    4353         seiInterLayerConstrainedTileSets->m_ilExactSampleValueMatchFlag[i] = false;
    4354       }
    4355     }
    4356   }
    4357 
    4358   return seiInterLayerConstrainedTileSets;
    4359 }
    4360 
    43613793Void TEncGOP::xBuildTileSetsMap(TComPicSym* picSym)
    43623794{
     
    46704102  }
    46714103}
    4672 
    4673 #if O0164_MULTI_LAYER_HRD
    4674 SEIScalableNesting* TEncGOP::xCreateBspNestingSEI(TComSlice *pcSlice, Int olsIdx, Int partitioningSchemeIdx, Int bspIdx)
    4675 {
    4676   SEIScalableNesting *seiScalableNesting = new SEIScalableNesting();
    4677   SEIBspInitialArrivalTime *seiBspInitialArrivalTime = new SEIBspInitialArrivalTime();
    4678   SEIBspNesting *seiBspNesting = new SEIBspNesting();
    4679   SEIBufferingPeriod *seiBufferingPeriod = new SEIBufferingPeriod();
    4680 
    4681   // Scalable nesting SEI
    4682 
    4683   seiScalableNesting->m_bitStreamSubsetFlag           = 1;      // If the nested SEI messages are picture buffereing SEI mesages, picure timing SEI messages or sub-picture timing SEI messages, bitstream_subset_flag shall be equal to 1
    4684   seiScalableNesting->m_nestingOpFlag                 = 1;
    4685   seiScalableNesting->m_defaultOpFlag                 = 0;
    4686   seiScalableNesting->m_nestingNumOpsMinus1           = 0;      //nesting_num_ops_minus1
    4687   seiScalableNesting->m_nestingOpIdx[0]               = pcSlice->getVPS()->getOutputLayerSetIdx(olsIdx);
    4688   seiScalableNesting->m_nestingMaxTemporalIdPlus1[0]  = 6 + 1;
    4689   seiScalableNesting->m_allLayersFlag                 = 0;
    4690   seiScalableNesting->m_nestingNoOpMaxTemporalIdPlus1 = 6 + 1;  //nesting_no_op_max_temporal_id_plus1
    4691   seiScalableNesting->m_nestingNumLayersMinus1        = 1 - 1;  //nesting_num_layers_minus1
    4692   seiScalableNesting->m_nestingLayerId[0]             = 0;
    4693   seiScalableNesting->m_callerOwnsSEIs                = true;
    4694 
    4695   // Bitstream partition nesting SEI
    4696 
    4697   seiBspNesting->m_bspIdx = 0;
    4698   seiBspNesting->m_callerOwnsSEIs = true;
    4699 
    4700   // Buffering period SEI
    4701 
    4702   UInt uiInitialCpbRemovalDelay = (90000/2);                      // 0.5 sec
    4703   seiBufferingPeriod->m_initialCpbRemovalDelay      [0][0]     = uiInitialCpbRemovalDelay;
    4704   seiBufferingPeriod->m_initialCpbRemovalDelayOffset[0][0]     = uiInitialCpbRemovalDelay;
    4705   seiBufferingPeriod->m_initialCpbRemovalDelay      [0][1]     = uiInitialCpbRemovalDelay;
    4706   seiBufferingPeriod->m_initialCpbRemovalDelayOffset[0][1]     = uiInitialCpbRemovalDelay;
    4707 
    4708   Double dTmp = (Double)pcSlice->getSPS()->getVuiParameters()->getTimingInfo()->getNumUnitsInTick() / (Double)pcSlice->getSPS()->getVuiParameters()->getTimingInfo()->getTimeScale();
    4709 
    4710   UInt uiTmp = (UInt)( dTmp * 90000.0 );
    4711   uiInitialCpbRemovalDelay -= uiTmp;
    4712   uiInitialCpbRemovalDelay -= uiTmp / ( pcSlice->getSPS()->getVuiParameters()->getHrdParameters()->getTickDivisorMinus2() + 2 );
    4713   seiBufferingPeriod->m_initialAltCpbRemovalDelay      [0][0]  = uiInitialCpbRemovalDelay;
    4714   seiBufferingPeriod->m_initialAltCpbRemovalDelayOffset[0][0]  = uiInitialCpbRemovalDelay;
    4715   seiBufferingPeriod->m_initialAltCpbRemovalDelay      [0][1]  = uiInitialCpbRemovalDelay;
    4716   seiBufferingPeriod->m_initialAltCpbRemovalDelayOffset[0][1]  = uiInitialCpbRemovalDelay;
    4717 
    4718   seiBufferingPeriod->m_rapCpbParamsPresentFlag              = 0;
    4719   //for the concatenation, it can be set to one during splicing.
    4720   seiBufferingPeriod->m_concatenationFlag = 0;
    4721   //since the temporal layer HRD is not ready, we assumed it is fixed
    4722   seiBufferingPeriod->m_auCpbRemovalDelayDelta = 1;
    4723   seiBufferingPeriod->m_cpbDelayOffset = 0;
    4724   seiBufferingPeriod->m_dpbDelayOffset = 0;
    4725 
    4726   // Intial arrival time SEI message
    4727 
    4728   seiBspInitialArrivalTime->m_nalInitialArrivalDelay[0] = 0;
    4729   seiBspInitialArrivalTime->m_vclInitialArrivalDelay[0] = 0;
    4730 
    4731 
    4732   seiBspNesting->m_nestedSEIs.push_back(seiBufferingPeriod);
    4733   seiBspNesting->m_nestedSEIs.push_back(seiBspInitialArrivalTime);
    4734   seiBspNesting->m_bspIdx = bspIdx;
    4735   seiBspNesting->m_seiOlsIdx = olsIdx;
    4736   seiBspNesting->m_seiPartitioningSchemeIdx = partitioningSchemeIdx;
    4737   seiScalableNesting->m_nestedSEIs.push_back(seiBspNesting); // BSP nesting SEI is contained in scalable nesting SEI
    4738 
    4739   return seiScalableNesting;
    4740 }
    4741 #endif
    47424104
    47434105#if CGS_3D_ASYMLUT
  • branches/SHM-dev/source/Lib/TLibEncoder/TEncGOP.h

    r1259 r1273  
    5454#include "TEncSbac.h"
    5555#include "SEIwrite.h"
     56#include "SEIEncoder.h"
    5657#if CGS_3D_ASYMLUT
    5758#include "TEnc3DAsymLUT.h"
     
    7374class TEncGOP
    7475{
     76  class DUData
     77  {
     78  public:
     79    DUData()
     80    :accumBitsDU(0)
     81    ,accumNalsDU(0) {};
     82
     83    Int accumBitsDU;
     84    Int accumNalsDU;
     85  };
     86
    7587private:
    7688  //  Data
     
    88100#endif
    89101
    90 #if Q0074_COLOUR_REMAPPING_SEI
    91   string                  m_colourRemapSEIFile;
    92   Int                     m_colourRemapSEIId;
    93   Bool                    m_colourRemapSEICancelFlag;
    94   Bool                    m_colourRemapSEIPersistenceFlag;
    95   Bool                    m_colourRemapSEIVideoSignalInfoPresentFlag;
    96   Bool                    m_colourRemapSEIFullRangeFlag;
    97   Int                     m_colourRemapSEIPrimaries;
    98   Int                     m_colourRemapSEITransferFunction;
    99   Int                     m_colourRemapSEIMatrixCoefficients;
    100   Int                     m_colourRemapSEIInputBitDepth;
    101   Int                     m_colourRemapSEIBitDepth;
    102   Int                     m_colourRemapSEIPreLutNumValMinus1[3];
    103   Int*                    m_colourRemapSEIPreLutCodedValue[3];
    104   Int*                    m_colourRemapSEIPreLutTargetValue[3];
    105   Bool                    m_colourRemapSEIMatrixPresentFlag;
    106   Int                     m_colourRemapSEILog2MatrixDenom;
    107   Int                     m_colourRemapSEICoeffs[3][3];
    108   Int                     m_colourRemapSEIPostLutNumValMinus1[3];
    109   Int*                    m_colourRemapSEIPostLutCodedValue[3];
    110   Int*                    m_colourRemapSEIPostLutTargetValue[3];
    111 #endif
    112102  //  Access channel
    113103  TEncTop*                m_pcEncTop;
     
    139129  UInt                    m_lastBPSEI;
    140130  UInt                    m_totalCoded;
    141   UInt                    m_cpbRemovalDelay;
    142   UInt                    m_tl0Idx;
    143   UInt                    m_rapIdx;
    144131  Bool                    m_activeParameterSetSEIPresentInAU;
    145132  Bool                    m_bufferingPeriodSEIPresentInAU;
     
    147134  Bool                    m_nestedBufferingPeriodSEIPresentInAU;
    148135  Bool                    m_nestedPictureTimingSEIPresentInAU;
    149 
     136  SEIEncoder              m_seiEncoder;
     137
     138#if Q0074_COLOUR_REMAPPING_SEI
     139  TComSEIColourRemappingInfo m_seiColourRemappingInfo; 
     140#endif
    150141#if SVC_EXTENSION
    151142  Int                     m_pocCraWithoutReset;
     
    236227  Double xCalculateRVM();
    237228
    238   SEIActiveParameterSets*           xCreateSEIActiveParameterSets (const TComSPS *sps);
    239   SEIFramePacking*                  xCreateSEIFramePacking();
    240   SEISegmentedRectFramePacking*     xCreateSEISegmentedRectFramePacking();
    241   SEIDisplayOrientation*            xCreateSEIDisplayOrientation();
    242   SEIToneMappingInfo*               xCreateSEIToneMappingInfo();
    243   SEITempMotionConstrainedTileSets* xCreateSEITempMotionConstrainedTileSets (const TComPPS *pps);
    244   SEIKneeFunctionInfo*              xCreateSEIKneeFunctionInfo();
    245   SEIChromaSamplingFilterHint*      xCreateSEIChromaSamplingFilterHint(Bool bChromaLocInfoPresent, Int iHorFilterIndex, Int iVerFilterIdc);
    246 
    247   Void xCreateLeadingSEIMessages (/*SEIMessages seiMessages,*/ AccessUnit &accessUnit, const TComSPS *sps, const TComPPS *pps);
    248   Int xGetFirstSeiLocation (AccessUnit &accessUnit);
     229  Void xCreateIRAPLeadingSEIMessages (SEIMessages& seiMessages, const TComSPS *sps, const TComPPS *pps);
     230  Void xCreatePerPictureSEIMessages (Int picInGOP, SEIMessages& seiMessages, SEIMessages& nestedSeiMessages, TComSlice *slice);
     231  Void xCreatePictureTimingSEI  (Int IRAPGOPid, SEIMessages& seiMessages, SEIMessages& nestedSeiMessages, SEIMessages& duInfoSeiMessages, AccessUnit &accessUnit, TComSlice *slice, Bool isField, std::deque<DUData> &duData);
     232  Void xUpdateDuData(AccessUnit &testAU, std::deque<DUData> &duData);
     233  Void xUpdateTimingSEI(SEIPictureTiming *pictureTimingSEI, std::deque<DUData> &duData, const TComSPS *sps);
     234  Void xUpdateDuInfoSEI(SEIMessages &duInfoSeiMessages, SEIPictureTiming *pictureTimingSEI);
     235
     236  Void xCreateScalableNestingSEI (SEIMessages& seiMessages, SEIMessages& nestedSeiMessages);
     237#if O0164_MULTI_LAYER_HRD
     238  Void xWriteSEI (NalUnitType naluType, SEIMessages& seiMessages, AccessUnit &accessUnit, AccessUnit::iterator &auPos, Int temporalId, const TComVPS *vps, const TComSPS *sps, const SEIScalableNesting* nestingSei=NULL, const SEIBspNesting* bspNestingSei=NULL);
     239  Void xWriteSEISeparately (NalUnitType naluType, SEIMessages& seiMessages, AccessUnit &accessUnit, AccessUnit::iterator &auPos, Int temporalId, const TComVPS *vps, const TComSPS *sps, const SEIScalableNesting* nestingSei=NULL, const SEIBspNesting* bspNestingSei=NULL);
     240#else
     241  Void xWriteSEI (NalUnitType naluType, SEIMessages& seiMessages, AccessUnit &accessUnit, AccessUnit::iterator &auPos, Int temporalId, const TComSPS *sps);
     242  Void xWriteSEISeparately (NalUnitType naluType, SEIMessages& seiMessages, AccessUnit &accessUnit, AccessUnit::iterator &auPos, Int temporalId, const TComSPS *sps);
     243#endif
     244  Void xClearSEIs(SEIMessages& seiMessages, Bool deleteMessages);
     245#if O0164_MULTI_LAYER_HRD
     246  Void xWriteLeadingSEIOrdered (SEIMessages& seiMessages, SEIMessages& duInfoSeiMessages, AccessUnit &accessUnit, Int temporalId, const TComVPS *vps, const TComSPS *sps, Bool testWrite, const SEIScalableNesting* nestingSei=NULL, const SEIBspNesting* bspNestingSei=NULL);
     247  Void xWriteLeadingSEIMessages  (SEIMessages& seiMessages, SEIMessages& duInfoSeiMessages, AccessUnit &accessUnit, Int temporalId, const TComVPS *vps, const TComSPS *sps, std::deque<DUData> &duData, const SEIScalableNesting* nestingSei=NULL, const SEIBspNesting* bspNestingSei=NULL);
     248  Void xWriteTrailingSEIMessages (SEIMessages& seiMessages, AccessUnit &accessUnit, Int temporalId, const TComVPS *vps, const TComSPS *sps, const SEIScalableNesting* nestingSei=NULL, const SEIBspNesting* bspNestingSei=NULL);
     249  Void xWriteDuSEIMessages       (SEIMessages& duInfoSeiMessages, AccessUnit &accessUnit, Int temporalId, const TComVPS *sps, const TComSPS *vps, std::deque<DUData> &duData, const SEIScalableNesting* nestingSei=NULL, const SEIBspNesting* bspNestingSei=NULL);
     250#else
     251  Void xWriteLeadingSEIOrdered (SEIMessages& seiMessages, SEIMessages& duInfoSeiMessages, AccessUnit &accessUnit, Int temporalId, const TComSPS *sps, Bool testWrite);
     252  Void xWriteLeadingSEIMessages  (SEIMessages& seiMessages, SEIMessages& duInfoSeiMessages, AccessUnit &accessUnit, Int temporalId, const TComSPS *sps, std::deque<DUData> &duData);
     253  Void xWriteTrailingSEIMessages (SEIMessages& seiMessages, AccessUnit &accessUnit, Int temporalId, const TComSPS *sps);
     254  Void xWriteDuSEIMessages       (SEIMessages& duInfoSeiMessages, AccessUnit &accessUnit, Int temporalId, const TComSPS *sps, std::deque<DUData> &duData);
     255#endif
     256
     257  Int xWriteVPS (AccessUnit &accessUnit, const TComVPS *vps);
     258  Int xWriteSPS (AccessUnit &accessUnit, const TComSPS *sps);
     259  Int xWritePPS (AccessUnit &accessUnit, const TComPPS *pps);
     260  Int xWriteParameterSets (AccessUnit &accessUnit, TComSlice *slice);
     261
    249262  Void xResetNonNestedSEIPresentFlags()
    250263  {
     
    261274
    262275#if Q0074_COLOUR_REMAPPING_SEI
    263   Void  setCRISEIFile( Char* pch )       { m_colourRemapSEIFile = pch; }
     276  TComSEIColourRemappingInfo* xGetSEIColourRemappingInfo()  { return &m_seiColourRemappingInfo; }
     277  Void  setCRISEIFile( Char* pch )       { m_seiColourRemappingInfo.m_colourRemapSEIFile = pch; }
    264278
    265279  Void freeColourCRI();
    266280  Int  readingCRIparameters();
    267281  Void xCheckParameter();
    268 
    269   SEIColourRemappingInfo* xCreateSEIColourRemappingInfo();
    270282#endif
    271283#if SVC_EXTENSION
    272 #if LAYERS_NOT_PRESENT_SEI
    273   SEILayersNotPresent*    xCreateSEILayersNotPresent ();
    274 #endif
    275284#if N0383_IL_CONSTRAINED_TILE_SETS_SEI
    276285  Void xBuildTileSetsMap(TComPicSym* picSym);
    277   SEIInterLayerConstrainedTileSets* xCreateSEIInterLayerConstrainedTileSets();
    278 #endif
    279 #if O0164_MULTI_LAYER_HRD
    280   SEIScalableNesting* xCreateBspNestingSEI(TComSlice *pcSlice, Int olsIdx, Int partitioningSchemeIdx, Int bspIdx);
    281 #endif
    282 #if P0123_ALPHA_CHANNEL_SEI
    283   SEIAlphaChannelInfo* xCreateSEIAlphaChannelInfo();
    284 #endif
    285 #if Q0096_OVERLAY_SEI
    286   SEIOverlayInfo* xCreateSEIOverlayInfo();
    287286#endif
    288287#if CGS_3D_ASYMLUT
  • branches/SHM-dev/source/Lib/TLibEncoder/TEncTop.cpp

    r1272 r1273  
    994994  if( getPictureTimingSEIEnabled() || getDecodingUnitInfoSEIEnabled() )
    995995  {
    996 #if SVC_EXTENSION
    997     const UInt picWidth = m_cVPS.getPicWidthInLumaSamples(&m_cSPS, m_layerId);
    998     const UInt picHeight= m_cVPS.getPicWidthInLumaSamples(&m_cSPS, m_layerId);
    999 #else
    1000     const UInt picWidth = m_cSPS.getPicWidthInLumaSamples();
    1001     const UInt picHeight= m_cSPS.getPicWidthInLumaSamples();
    1002 #endif
    1003 
    1004     const UInt frameWidthInCtus   = ( picWidth + g_uiMaxCUWidth -1 ) / g_uiMaxCUWidth;
    1005     const UInt frameHeightInCtus  = ( picHeight + g_uiMaxCUHeight - 1 ) / g_uiMaxCUHeight;
    1006     const UInt numCtusInFrame = frameWidthInCtus * frameHeightInCtus;
    1007 
    1008     UInt maxCU = getSliceArgument();
    1009     UInt numDU = ( getSliceMode() == FIXED_NUMBER_OF_CTU ) ? ( numCtusInFrame / maxCU ) : ( 0 );
    1010     if( numCtusInFrame % maxCU != 0 || numDU == 0 )
    1011     {
    1012       numDU ++;
    1013     }
    1014     m_cSPS.getVuiParameters()->getHrdParameters()->setNumDU( numDU );
    1015     m_cSPS.setHrdParameters( getFrameRate(), numDU, getTargetBitrate(), ( getIntraPeriod() > 0 ) );
     996    Bool useDUParameters = (getSliceMode() > 0) || (getSliceSegmentMode() > 0);
     997    m_cSPS.setHrdParameters( getFrameRate(), useDUParameters, getTargetBitrate(), ( getIntraPeriod() > 0 ) );
    1016998  }
    1017999  if( getBufferingPeriodSEIEnabled() || getPictureTimingSEIEnabled() || getDecodingUnitInfoSEIEnabled() )
     
    10191001    m_cSPS.getVuiParameters()->setHrdParametersPresentFlag( true );
    10201002  }
    1021 
    10221003}
    10231004
Note: See TracChangeset for help on using the changeset viewer.