Changeset 1356 in 3DVCSoftware for trunk/source/Lib/TLibCommon/SEI.cpp


Ignore:
Timestamp:
27 Oct 2015, 11:33:16 (9 years ago)
Author:
tech
Message:

Merged 15.1-dev0-NICT@1355.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/Lib/TLibCommon/SEI.cpp

    r1313 r1356  
    3232 */
    3333
    34 /** \file     SEI.cpp
     34/** \file     #SEI.cpp
    3535    \brief    helper functions for SEI handling
    3636*/
     
    3838#include "CommonDef.h"
    3939#include "SEI.h"
     40#if NH_MV_SEI
     41#include "TComSlice.h"
     42#endif
    4043
    4144SEIMessages getSeisByType(SEIMessages &seiList, SEI::PayloadType seiType)
     
    150153    case SEI::CHROMA_SAMPLING_FILTER_HINT:          return "Chroma sampling filter hint";
    151154#if NH_MV
    152     case SEI::SUB_BITSTREAM_PROPERTY:               return "Sub-bitstream property SEI message";     
     155    case SEI::COLOUR_REMAPPING_INFO:                     return "Colour remapping information";
     156    case SEI::DEINTERLACED_FIELD_IDENTIFICATION:         return "Deinterlaced field identification";
     157    case SEI::LAYERS_NOT_PRESENT:                        return "Layers not present";
     158    case SEI::INTER_LAYER_CONSTRAINED_TILE_SETS:         return "Inter-layer constrained tile sets";
     159    case SEI::BSP_NESTING:                               return "Bitstream partition nesting";
     160    case SEI::BSP_INITIAL_ARRIVAL_TIME:                  return "Bitstream partition initial arrival time";
     161    case SEI::SUB_BITSTREAM_PROPERTY:                    return "Sub-bitstream property";
     162    case SEI::ALPHA_CHANNEL_INFO:                        return "Alpha channel information";
     163    case SEI::OVERLAY_INFO:                              return "Overlay information"  ;
     164    case SEI::TEMPORAL_MV_PREDICTION_CONSTRAINTS:        return "Temporal motion vector prediction constraints";
     165    case SEI::FRAME_FIELD_INFO:                          return "Frame-field information";
     166    case SEI::THREE_DIMENSIONAL_REFERENCE_DISPLAYS_INFO: return "3D reference displays information";
     167    case SEI::DEPTH_REPRESENTATION_INFO:                 return "Depth representation information";
     168    case SEI::MULTIVIEW_SCENE_INFO:                      return "Multiview scene information";
     169    case SEI::MULTIVIEW_ACQUISITION_INFO:                return "Multiview acquisition information";
     170    case SEI::MULTIVIEW_VIEW_POSITION:                   return "Multiview view position";
     171#if NH_3D
     172    case SEI::ALTERNATIVE_DEPTH_INFO:                    return "Alternative depth information";
     173#endif
    153174#endif
    154175    default:                                        return "Unknown";
    155176  }
    156177}
     178
     179#if NH_MV_SEI
     180SEI::SEI()
     181{
     182  m_scalNestSeiContThisSei = NULL;
     183}
     184
     185SEI* SEI::getNewSEIMessage(SEI::PayloadType payloadType)
     186{
     187  switch (payloadType)
     188  {
     189#if NH_MV_SEI_TBD
     190    //////////////////////////////////////////////////////////////////////////
     191    // TBD: Modify version 1 SEIs to use the same interfaces as Annex GFI SEI messages.
     192    //////////////////////////////////////////////////////////////////////////
     193
     194    case SEI::BUFFERING_PERIOD:                     return new SEIBufferingPeriod;
     195    case SEI::PICTURE_TIMING:                       return new SEIPictureTiming;
     196    case SEI::PAN_SCAN_RECT:                        return new SEIPanScanRectangle;                    // not currently decoded
     197    case SEI::FILLER_PAYLOAD:                       return new SEIFillerPaylod;                       // not currently decoded
     198    case SEI::USER_DATA_REGISTERED_ITU_T_T35:       return new SEIUserDataRegistered;                 // not currently decoded
     199    case SEI::USER_DATA_UNREGISTERED:               return new SEIuserDataUnregistered;
     200    case SEI::RECOVERY_POINT:                       return new SEIRecoveryPoint;
     201    case SEI::SCENE_INFO:                           return new SEISceneInformation;                    // not currently decoded
     202    case SEI::FULL_FRAME_SNAPSHOT:                  return new SEIPictureSnapshot;                     // not currently decoded
     203    case SEI::PROGRESSIVE_REFINEMENT_SEGMENT_START: return new SEIProgressiveRefinementSegmentStart;   // not currently decoded
     204    case SEI::PROGRESSIVE_REFINEMENT_SEGMENT_END:   return new SEIProgressiveRefinementSegmentEnd;     // not currently decoded
     205    case SEI::FILM_GRAIN_CHARACTERISTICS:           return new SEIFilmGrainCharacteristics;            // not currently decoded
     206    case SEI::POST_FILTER_HINT:                     return new SEIPostFilterHint;                      // not currently decoded
     207    case SEI::TONE_MAPPING_INFO:                    return new SEIToneMappingInfo;
     208    case SEI::KNEE_FUNCTION_INFO:                   return new SEIKneeFunctionInfo;
     209    case SEI::FRAME_PACKING:                        return new SEIFramePacking;
     210    case SEI::DISPLAY_ORIENTATION:                  return new SEIDisplayOrientation;
     211    case SEI::SOP_DESCRIPTION:                      return new SEISOPDescription;
     212    case SEI::ACTIVE_PARAMETER_SETS:                return new SEIActiveParameterSets;
     213    case SEI::DECODING_UNIT_INFO:                   return new SEIDecodingUnitInfo;
     214    case SEI::TEMPORAL_LEVEL0_INDEX:                return new SEITemporalLevel0Index
     215    case SEI::DECODED_PICTURE_HASH:                 return new SEIDecodedPictureHash;
     216    case SEI::SCALABLE_NESTING:                     return new SEIScalableNesting;
     217    case SEI::REGION_REFRESH_INFO:                  return new SEIRegionRefreshInfo;
     218    case SEI::NO_DISPLAY:                           return new SEINoDisplay;
     219    case SEI::TIME_CODE:                            return new SEITimeCode;
     220    case SEI::MASTERING_DISPLAY_COLOUR_VOLUME:      return new SEIMasteringDisplayColourVolume;
     221    case SEI::SEGM_RECT_FRAME_PACKING:              return new SEISegmentedRectFramePacking;
     222    case SEI::TEMP_MOTION_CONSTRAINED_TILE_SETS:    return new SEITempMotionConstrainedTileSets;
     223    case SEI::CHROMA_SAMPLING_FILTER_HINT:          return new SEIChromaSamplingFilterHint
     224#endif
     225#if NH_MV_SEI
     226#if NH_MV_LAYERS_NOT_PRESENT_SEI
     227  case SEI::LAYERS_NOT_PRESENT                    :               return new SEILayersNotPresent;
     228#endif
     229  case SEI::INTER_LAYER_CONSTRAINED_TILE_SETS     :               return new SEIInterLayerConstrainedTileSets;
     230#if NH_MV_SEI_TBD
     231  case SEI::BSP_NESTING                           :               return new SEIBspNesting;
     232  case SEI::BSP_INITIAL_ARRIVAL_TIME              :               return new SEIBspInitialArrivalTime;
     233#endif
     234  case SEI::SUB_BITSTREAM_PROPERTY                :               return new SEISubBitstreamProperty;
     235  case SEI::ALPHA_CHANNEL_INFO                    :               return new SEIAlphaChannelInfo;
     236  case SEI::OVERLAY_INFO                          :               return new SEIOverlayInfo;
     237  case SEI::TEMPORAL_MV_PREDICTION_CONSTRAINTS    :               return new SEITemporalMvPredictionConstraints;
     238#if NH_MV_SEI_TBD
     239  case SEI::FRAME_FIELD_INFO                      :               return new SEIFrameFieldInfo;
     240#endif
     241  case SEI::THREE_DIMENSIONAL_REFERENCE_DISPLAYS_INFO:            return new SEIThreeDimensionalReferenceDisplaysInfo;
     242#if SEI_DRI_F0169
     243  case SEI::DEPTH_REPRESENTATION_INFO             :               return new SEIDepthRepresentationInfo;
     244#endif
     245  case SEI::MULTIVIEW_SCENE_INFO                  :               return new SEIMultiviewSceneInfo;
     246  case SEI::MULTIVIEW_ACQUISITION_INFO            :               return new SEIMultiviewAcquisitionInfo;
     247  case SEI::MULTIVIEW_VIEW_POSITION               :               return new SEIMultiviewViewPosition;
     248#if NH_3D
     249  case SEI::ALTERNATIVE_DEPTH_INFO                :               return new SEIAlternativeDepthInfo;
     250#endif
     251#endif
     252  default:                                        assert( false ); return NULL;
     253  }
     254}
     255
     256Void SEI::setupFromSlice  ( const TComSlice* slice )
     257{
     258  xPrintCfgErrorIntro();
     259  std::cout << getSEIMessageString( payloadType() ) << "Setup by the encoder is currently not possible. Using the default SEI cfg-file." << std::endl;
     260}
     261
     262SEI* SEI::getCopy() const
     263{
     264  assert( 0 );
     265  return NULL;
     266}
     267
     268Void SEI::setupFromCfgFile( const Char* cfgFile )
     269{
     270  assert( false );
     271}
     272
     273Bool SEI::insertSei( Int curLayerId, Int curPoc, Int curTid, Int curNaluType ) const
     274{
     275  Bool insertSeiHere = true;
     276  if( !m_applicableLayerIds.empty() )
     277  {
     278    insertSeiHere = insertSeiHere && ( std::find( m_applicableLayerIds.begin(), m_applicableLayerIds.end(), curLayerId) != m_applicableLayerIds.end() ) ;
     279  }
     280  if( !m_applicablePocs     .empty() )
     281  {
     282    insertSeiHere = insertSeiHere && ( std::find( m_applicablePocs    .begin(), m_applicablePocs    .end(), curPoc    ) != m_applicablePocs    .end() ) ;
     283  }
     284  if( !m_applicableTids     .empty() )
     285  {
     286    insertSeiHere = insertSeiHere && ( std::find( m_applicableTids    .begin(), m_applicableTids    .end(), curTid    ) != m_applicableTids    .end() ) ;
     287  }
     288  if( !m_applicableVclNaluTypes.empty() )
     289  {
     290    insertSeiHere = insertSeiHere && ( std::find( m_applicableVclNaluTypes.begin(), m_applicableVclNaluTypes.end(), curNaluType) != m_applicableVclNaluTypes.end() ) ;
     291  }
     292  return insertSeiHere;
     293}
     294
     295Bool SEI::checkCfg( const TComSlice* slice )
     296{
     297  assert( false );
     298  return true;
     299}
     300
     301Void SEI::xPrintCfgErrorIntro()
     302{
     303  std::cout << "Error in configuration of " << getSEIMessageString( payloadType() ) << " SEI: ";
     304}
     305
     306Void SEI::xCheckCfgRange( Bool& wrongConfig, Int val, Int minVal, Int maxVal, const Char* seName )
     307{
     308  if ( val < minVal || val > maxVal  )
     309  {
     310    xPrintCfgErrorIntro();
     311    std::cout << "The value of " << seName << "shall be in the range of " << minVal << " to " << maxVal << ", inclusive." << std::endl;
     312    wrongConfig = true;
     313  }
     314}
     315
     316Void SEI::xAddGeneralOpts(po::Options &opts, IntAry1d defAppLayerIds, IntAry1d deftApplicablePocs,
     317                                            IntAry1d defAppTids,     IntAry1d defAppVclNaluTypes,
     318                                            Int defSeiNaluId, Int defPositionInSeiNalu, Bool defModifyByEncoder)
     319{
     320  opts.addOptions()
     321    ("PayloadType"            , m_payloadType            , -1                    , "Payload Type"                                                         )
     322    ("ApplicableLayerIds"     , m_applicableLayerIds     , defAppLayerIds        , "LayerIds      of layers   to which the SEI is added. (all when empty)")
     323    ("ApplicablePocs"         , m_applicablePocs         , deftApplicablePocs    , "POCs          of pictures to which the SEI is added. (all when empty)")
     324    ("ApplicableTids"         , m_applicableTids         , defAppTids            , "TIds          of pictures to which the SEI is added. (all when empty)")
     325    ("ApplicableVclNaluTypes" , m_applicableVclNaluTypes , defAppVclNaluTypes    , "NaluUnitTypes of picture  to which the SEI is added. (all when empty)")
     326    ("SeiNaluId"              , m_seiNaluId              , defSeiNaluId          , "Identifies to which NAL unit  the SEI is added." )
     327    ("PositionInSeiNalu"      , m_positionInSeiNalu      , defPositionInSeiNalu  , "Identifies the position within the NAL unit.")
     328    ("ModifyByEncoder"        , m_modifyByEncoder        , defModifyByEncoder    , "0: Use payload as specified in cfg file   1: Modify SEI by encoder");
     329}
     330
     331Void SEI::xCheckCfg( Bool& wrongConfig, Bool cond, const Char* errStr )
     332{
     333  if ( !cond  )
     334  {
     335    xPrintCfgErrorIntro();
     336    std::cout << errStr << std::endl;
     337    wrongConfig = true;
     338  }
     339}
     340
     341
     342#if NH_MV_LAYERS_NOT_PRESENT_SEI
     343Void SEILayersNotPresent::setupFromCfgFile(const Char* cfgFile)
     344{
     345  // Set default values
     346  IntAry1d defAppLayerIds, defAppPocs, defAppTids, defAppVclNaluTypes;
     347
     348  // TBD: Add default values for which layers, POCS, Tids or Nalu types the SEI should be send.
     349  // This SEI message doesn't need to be added by default to any Layer / POC / NAL Unit / T Layer. Not sure if empty is right.
     350  defAppLayerIds    .empty( );
     351  defAppPocs        .empty( );
     352  defAppTids        .empty( );
     353  defAppVclNaluTypes.empty( );
     354
     355  Int      defSeiNaluId                  = 0;
     356  Int      defPositionInSeiNalu          = 0;
     357  Bool     defModifyByEncoder            = false;   //0: Use payload as specified in cfg file   1: Modify SEI by encoder
     358
     359  // Setup config file options
     360  po::Options opts;
     361  xAddGeneralOpts( opts , defAppLayerIds, defAppPocs, defAppTids, defAppVclNaluTypes, defSeiNaluId, defPositionInSeiNalu, defModifyByEncoder );
     362
     363  opts.addOptions()
     364    ("LnpSeiActiveVpsId"              , m_lnpSeiActiveVpsId                , 0                              , "LnpSeiActiveVpsId"                )   //Why?
     365    ("LayerNotPresentFlag"            , m_layerNotPresentFlag              , BoolAry1d(1,0)                 , "LayerNotPresentFlag"              )
     366    ;
     367
     368  po::setDefaults(opts);
     369
     370  // Parse the cfg file
     371  po::ErrorReporter err;
     372  po::parseConfigFile( opts, cfgFile, err );
     373  m_lnpSeiMaxLayers = (UInt) m_layerNotPresentFlag.size();
     374};
     375
     376  Bool SEILayersNotPresent::checkCfg( const TComSlice* slice )
     377  {
     378  // Check config values
     379    Bool wrongConfig = false;
     380//
     381    const TComVPS* vps = slice->getVPS();
     382//  // TBD: Add constraints on presence of SEI here.
     383    xCheckCfg     ( wrongConfig, m_lnpSeiActiveVpsId == vps->getVPSId(), "The value of lnp_sei_active_vps_id shall be equal to the value of vps_video_parameter_set_id of the active VPS for the VCL NAL units of the access unit containing the SEI message." );
     384    xCheckCfg     ( wrongConfig, m_lnpSeiMaxLayers == vps->getMaxLayersMinus1(), "The number of LayerNotPresent flags shall be equal to vpsMaxLayersMinus1." );
     385
     386
     387    for (Int i = 0; i < vps->getMaxLayersMinus1(); i++)
     388    {
     389      if ( m_layerNotPresentFlag[ i ] && i < vps->getMaxLayersMinus1() )
     390      {
     391        for (Int j = 0; j < vps->getNumPredictedLayers( vps->getLayerIdInNuh( j ) - 1 ); j++ )
     392        {
     393          xCheckCfg     ( wrongConfig, m_layerNotPresentFlag[ vps->getLayerIdInVps( vps->getIdPredictedLayer( vps->getLayerIdInNuh(i),j) )], "When layer_not_present_flag[ i ] is equal to 1 and i is less than MaxLayersMinus1, layer_not_present_flag[ LayerIdxInVps[ IdPredictedLayer[ layer_id_in_nuh[ i ] ][ j ] ] ] shall be equal to 1 for all values of j in the range of 0 to NumPredictedLayers[ layer_id_in_nuh[ i ] ] - 1, inclusive." );
     394        }
     395      }
     396    }
     397
     398      return wrongConfig;
     399  };
     400#endif
     401
     402
     403Void SEIInterLayerConstrainedTileSets::setupFromCfgFile(const Char* cfgFile)
     404{
     405  // Set default values
     406  IntAry1d defAppLayerIds, defAppPocs, defAppTids, defAppVclNaluTypes;
     407
     408  // TBD: Add default values for which layers, POCS, Tids or Nalu types the SEI should be send.
     409  defAppLayerIds    .empty( );
     410  defAppPocs        .push_back( 0 );
     411  defAppTids        .empty( );
     412  defAppVclNaluTypes.empty( );
     413
     414  Int      defSeiNaluId                  = 0;
     415  Int      defPositionInSeiNalu          = 0;
     416  Bool     defModifyByEncoder            = false;
     417
     418  // Setup config file options
     419  po::Options opts;
     420  xAddGeneralOpts( opts , defAppLayerIds, defAppPocs, defAppTids, defAppVclNaluTypes, defSeiNaluId, defPositionInSeiNalu, defModifyByEncoder );
     421
     422  const Int maxNumTileInSet = 100;
     423
     424  opts.addOptions()
     425    ("IlAllTilesExactSampleValueMatchFlag", m_ilAllTilesExactSampleValueMatchFlag, false                    , "IlAllTilesExactSampleValueMatchFlag")
     426    ("IlOneTilePerTileSetFlag"        , m_ilOneTilePerTileSetFlag          , false                          , "IlOneTilePerTileSetFlag"          )
     427    ("IlNumSetsInMessageMinus1"       , m_ilNumSetsInMessageMinus1         , 0                              , "IlNumSetsInMessageMinus1"         )
     428    ("SkippedTileSetPresentFlag"      , m_skippedTileSetPresentFlag        , false                          , "SkippedTileSetPresentFlag"        )
     429    ("IlctsId"                        , m_ilctsId                          , IntAry1d (256,0)               , "IlctsId"                          )
     430    ("IlNumTileRectsInSetMinus1"      , m_ilNumTileRectsInSetMinus1        , IntAry1d (256,0)               , "IlNumTileRectsInSetMinus1"        )
     431    ("IlTopLeftTileIndex_%d"          , m_ilTopLeftTileIndex               , IntAry1d (maxNumTileInSet,0), 256, "IlTopLeftTileIndex"               )
     432    ("IlBottomRightTileIndex_%d"      , m_ilBottomRightTileIndex           , IntAry1d (maxNumTileInSet,0), 256, "IlBottomRightTileIndex"           )
     433    ("IlcIdc"                         , m_ilcIdc                           , IntAry1d (256,0)               , "IlcIdc"                           )
     434    ("IlExactSampleValueMatchFlag"    , m_ilExactSampleValueMatchFlag      , BoolAry1d(256,0)               , "IlExactSampleValueMatchFlag"      )
     435    ("AllTilesIlcIdc"                 , m_allTilesIlcIdc                   , 0                              , "AllTilesIlcIdc"                   )
     436    ;
     437
     438  po::setDefaults(opts);
     439
     440  // Parse the cfg file
     441  po::ErrorReporter err;
     442  po::parseConfigFile( opts, cfgFile, err );
     443};
     444
     445Bool SEIInterLayerConstrainedTileSets::checkCfg( const TComSlice* slice )
     446{
     447  // Check config values
     448  Bool wrongConfig = false;
     449  const TComPPS* pps = slice->getPPS();
     450
     451  // Currently only the active PPS checked.
     452  xCheckCfg     ( wrongConfig, pps->getTilesEnabledFlag() , "The inter-layer constrained tile sets SEI message shall not be present for the layer with nuh_layer_id equal to targetLayerId when tiles_enabled_flag is equal to 0 for any PPS that is active for the pictures of the CLVS of the layer with nuh_layer_id equal to targetLayerId." );
     453
     454  if ( m_ilOneTilePerTileSetFlag )
     455  {
     456    xCheckCfg( wrongConfig, ( pps->getNumTileColumnsMinus1() + 1 ) *  ( pps->getNumTileRowsMinus1() + 1 ) <= 256, "It is a requirement of bitstream conformance that when il_one_tile_per_tile_set_flag is equal to 1, the value of ( num_tile_columns_minus1 + 1 ) * ( num_tile_rows_minus1 + 1 ) shall be less than or equal to 256."    );
     457  }
     458  Int numSignificantSets = m_ilNumSetsInMessageMinus1 - m_skippedTileSetPresentFlag + 1;
     459
     460  for (Int i = 0 ; i < numSignificantSets; i++)
     461  {
     462    xCheckCfgRange( wrongConfig, m_ilctsId[i]                         , 0 , (1 << 30) - 1, "ilcts_id"                         );
     463  }
     464
     465  return wrongConfig;
     466};
     467#if NH_MV_SEI_TBD
     468
     469Void SEIBspNesting::setupFromSlice  ( const TComSlice* slice )
     470{
     471  sei.m_seiOlsIdx =  TBD ;
     472  sei.m_seiPartitioningSchemeIdx =  TBD ;
     473  sei.m_bspIdx =  TBD ;
     474  while( !ByteaLigned(() ) );
     475  {
     476    sei.m_bspNestingZeroBit =  TBD ;
     477  }
     478  sei.m_numSeisInBspMinus1 =  TBD ;
     479  for( Int i = 0; i  <=  NumSeisInBspMinus1( ); i++ )
     480  {
     481    SeiMessage(() );
     482  }
     483};
     484
     485Void SEIBspNesting::setupFromCfgFile(const Char* cfgFile)
     486{
     487  // Set default values
     488  IntAry1d defAppLayerIds, defAppPocs, defAppTids, defAppVclNaluTypes;
     489
     490  // TBD: Add default values for which layers, POCS, Tids or Nalu types the SEI should be send.
     491  defAppLayerIds    .push_back( TBD );
     492  defAppPocs        .push_back( TBD );
     493  defAppTids        .push_back( TBD );
     494  defAppVclNaluTypes.push_back( TBD );
     495
     496  Int      defSeiNaluId                  = 0;
     497  Int      defPositionInSeiNalu          = 0;
     498  Bool     defModifyByEncoder            = TBD;
     499
     500  // Setup config file options
     501  po::Options opts;
     502  xAddGeneralOpts( opts , defAppLayerIds, defAppPocs, defAppTids, defAppVclNaluTypes, defSeiNaluId, defPositionInSeiNalu, defModifyByEncoder );
     503
     504  opts.addOptions()
     505    ("SeiOlsIdx"                      , m_seiOlsIdx                        , 0                              , "SeiOlsIdx"                        )
     506    ("SeiPartitioningSchemeIdx"       , m_seiPartitioningSchemeIdx         , 0                              , "SeiPartitioningSchemeIdx"         )
     507    ("BspIdx"                         , m_bspIdx                           , 0                              , "BspIdx"                           )
     508    ("BspNestingZeroBit"              , m_bspNestingZeroBit                , 0                              , "BspNestingZeroBit"                )
     509    ("NumSeisInBspMinus1"             , m_numSeisInBspMinus1               , 0                              , "NumSeisInBspMinus1"               )
     510    ;
     511
     512  po::setDefaults(opts);
     513
     514  // Parse the cfg file
     515  po::ErrorReporter err;
     516  po::parseConfigFile( opts, cfgFile, err );
     517};
     518
     519Bool SEIBspNesting::checkCfg( const TComSlice* slice )
     520{
     521  // Check config values
     522  Bool wrongConfig = false;
     523
     524  // TBD: Add constraints on presence of SEI here.
     525  xCheckCfg     ( wrongConfig, TBD , "TBD" );
     526  xCheckCfg     ( wrongConfig, TBD , "TBD" );
     527
     528  // TBD: Modify constraints according to the SEI semantics.
     529  xCheckCfgRange( wrongConfig, m_seiOlsIdx                      , MINVAL , MAXVAL, "sei_ols_idx"          );
     530  xCheckCfgRange( wrongConfig, m_seiPartitioningSchemeIdx       , MINVAL , MAXVAL, "sei_partitioning_scheme_idx"       );
     531  xCheckCfgRange( wrongConfig, m_bspIdx                         , MINVAL , MAXVAL, "bsp_idx"              );
     532  xCheckCfgRange( wrongConfig, m_bspNestingZeroBit              , MINVAL , MAXVAL, "bsp_nesting_zero_bit ");
     533  xCheckCfgRange( wrongConfig, m_numSeisInBspMinus1             , MINVAL , MAXVAL, "num_seis_in_bsp_minus1"           );
     534
     535  return wrongConfig;
     536
     537};
     538
     539Void SEIBspInitialArrivalTime::setupFromSlice  ( const TComSlice* slice )
     540{
     541  psIdx = SeiPartitioningSchemeIdx();
     542  if( nalInitialArrivalDelayPresent )
     543  {
     544    for( Int i = 0; i < BspSchedCnt( SeiOlsIdx(), psIdx, MaxTemporalId( 0 ) ); i++ )
     545    {
     546      sei.m_nalInitialArrivalDelay[i] =  TBD ;
     547    }
     548  }
     549  if( vclInitialArrivalDelayPresent )
     550  {
     551    for( Int i = 0; i < BspSchedCnt( SeiOlsIdx(), psIdx, MaxTemporalId( 0 ) ); i++ )
     552    {
     553      sei.m_vclInitialArrivalDelay[i] =  TBD ;
     554    }
     555  }
     556};
     557
     558Void SEIBspInitialArrivalTime::setupFromCfgFile(const Char* cfgFile)
     559{
     560  // Set default values
     561  IntAry1d defAppLayerIds, defAppPocs, defAppTids, defAppVclNaluTypes;
     562
     563  // TBD: Add default values for which layers, POCS, Tids or Nalu types the SEI should be send.
     564  defAppLayerIds    .push_back( TBD );
     565  defAppPocs        .push_back( TBD );
     566  defAppTids        .push_back( TBD );
     567  defAppVclNaluTypes.push_back( TBD );
     568
     569  Int      defSeiNaluId                  = 0;
     570  Int      defPositionInSeiNalu          = 0;
     571  Bool     defModifyByEncoder            = TBD;
     572
     573  // Setup config file options
     574  po::Options opts;
     575  xAddGeneralOpts( opts , defAppLayerIds, defAppPocs, defAppTids, defAppVclNaluTypes, defSeiNaluId, defPositionInSeiNalu, defModifyByEncoder );
     576
     577  opts.addOptions()
     578    ("NalInitialArrivalDelay"         , m_nalInitialArrivalDelay           , IntAry1d (1,0)                 , "NalInitialArrivalDelay"           )
     579    ("VclInitialArrivalDelay"         , m_vclInitialArrivalDelay           , IntAry1d (1,0)                 , "VclInitialArrivalDelay"           )
     580    ;
     581
     582  po::setDefaults(opts);
     583
     584  // Parse the cfg file
     585  po::ErrorReporter err;
     586  po::parseConfigFile( opts, cfgFile, err );
     587};
     588
     589Bool SEIBspInitialArrivalTime::checkCfg( const TComSlice* slice )
     590{
     591  // Check config values
     592  Bool wrongConfig = false;
     593
     594  // TBD: Add constraints on presence of SEI here.
     595  xCheckCfg     ( wrongConfig, TBD , "TBD" );
     596  xCheckCfg     ( wrongConfig, TBD , "TBD" );
     597
     598  // TBD: Modify constraints according to the SEI semantics.
     599  xCheckCfgRange( wrongConfig, m_nalInitialArrivalDelay[i]      , MINVAL , MAXVAL, "nal_initial_arrival_delay"        );
     600  xCheckCfgRange( wrongConfig, m_vclInitialArrivalDelay[i]      , MINVAL , MAXVAL, "vcl_initial_arrival_delay"        );
     601
     602  return wrongConfig;
     603
     604};
     605#endif
     606
     607Void SEISubBitstreamProperty::setupFromCfgFile(const Char* cfgFile)
     608{
     609  // Set default values
     610  IntAry1d defAppLayerIds, defAppPocs, defAppTids, defAppVclNaluTypes;
     611
     612  // TBD: Add default values for which layers, POCS, Tids or Nalu types the SEI should be send.
     613  defAppLayerIds    .push_back( 0 );
     614  defAppPocs        .push_back( 0 );
     615  defAppTids        .push_back( 0 );
     616  defAppVclNaluTypes = IRAP_NAL_UNIT_TYPES;
     617
     618  Int      defSeiNaluId                  = 0;
     619  Int      defPositionInSeiNalu          = 0;
     620  Bool     defModifyByEncoder            = false;
     621
     622  // Setup config file options
     623  po::Options opts;
     624  xAddGeneralOpts( opts , defAppLayerIds, defAppPocs, defAppTids, defAppVclNaluTypes, defSeiNaluId, defPositionInSeiNalu, defModifyByEncoder );
     625
     626  opts.addOptions()
     627    ("SbPropertyActiveVpsId"          , m_sbPropertyActiveVpsId            , 0                              , "SbPropertyActiveVpsId"            )
     628    ("NumAdditionalSubStreamsMinus1"  , m_numAdditionalSubStreamsMinus1    , 0                              , "NumAdditionalSubStreamsMinus1"    )
     629    ("SubBitstreamMode"               , m_subBitstreamMode                 , IntAry1d (1,0)                 , "SubBitstreamMode"                 )
     630    ("OlsIdxToVps"                    , m_olsIdxToVps                      , IntAry1d (1,0)                 , "OlsIdxToVps"                      )
     631    ("HighestSublayerId"              , m_highestSublayerId                , IntAry1d (1,0)                 , "HighestSublayerId"                )
     632    ("AvgSbPropertyBitRate"           , m_avgSbPropertyBitRate             , IntAry1d (1,0)                 , "AvgSbPropertyBitRate"             )
     633    ("MaxSbPropertyBitRate"           , m_maxSbPropertyBitRate             , IntAry1d (1,0)                 , "MaxSbPropertyBitRate"             )
     634    ;
     635
     636  po::setDefaults(opts);
     637
     638  // Parse the cfg file
     639  po::ErrorReporter err;
     640  po::parseConfigFile( opts, cfgFile, err );
     641};
     642
     643Bool SEISubBitstreamProperty::checkCfg( const TComSlice* slice )
     644{
     645  // Check config values
     646  Bool wrongConfig = false;
     647
     648  // For the current encoder, the initial IRAP access unit has always POC zero.
     649  xCheckCfg     ( wrongConfig, slice->isIRAP() && (slice->getPOC() == 0), "When present, the sub-bitstream property SEI message shall be associated with an initial IRAP access unit and the information provided by the SEI messages applies to the bitstream corresponding to the CVS containing the associated initial IRAP access unit.");
     650
     651  Bool sizeNotCorrect =
     652    (    ( m_numAdditionalSubStreamsMinus1 + 1 ) != m_subBitstreamMode    .size() )
     653    || ( ( m_numAdditionalSubStreamsMinus1 + 1 ) != m_olsIdxToVps         .size() )
     654    || ( ( m_numAdditionalSubStreamsMinus1 + 1 ) != m_highestSublayerId   .size() )
     655    || ( ( m_numAdditionalSubStreamsMinus1 + 1 ) != m_avgSbPropertyBitRate.size() )
     656    || ( ( m_numAdditionalSubStreamsMinus1 + 1 ) != m_maxSbPropertyBitRate.size() );
     657
     658  xCheckCfg( wrongConfig, !sizeNotCorrect, "Some parameters of some sub-bitstream not provided." );
     659  xCheckCfg( wrongConfig, slice->getVPS()->getVPSId() == m_sbPropertyActiveVpsId, "The value of sb_property_active_vps_id shall be equal to the value of vps_video_parameter_set_id of the active VPS referred to by the VCL NAL units of the associated access unit." );
     660
     661  xCheckCfgRange( wrongConfig, m_numAdditionalSubStreamsMinus1  , 0 , (1 << 10) - 1 , "num_additional_sub_streams_minus1");
     662
     663  if ( !sizeNotCorrect )
     664  {
     665    for (Int i = 0; i <= m_numAdditionalSubStreamsMinus1; i++ )
     666    {
     667      xCheckCfgRange( wrongConfig, m_subBitstreamMode[i]    , 0 , 1                                          , "sub_bitstream_mode" );
     668      xCheckCfgRange( wrongConfig, m_olsIdxToVps[i]         , 0 , slice->getVPS()->getNumOutputLayerSets()-1 , "ols_idx_to_vps"     );
     669    }
     670  }
     671  return wrongConfig;
     672};
     673
     674Void SEISubBitstreamProperty::resizeArrays( )
     675{
     676  m_subBitstreamMode    .resize( m_numAdditionalSubStreamsMinus1 + 1);
     677  m_olsIdxToVps         .resize( m_numAdditionalSubStreamsMinus1 + 1);
     678  m_highestSublayerId   .resize( m_numAdditionalSubStreamsMinus1 + 1);
     679  m_avgSbPropertyBitRate.resize( m_numAdditionalSubStreamsMinus1 + 1);
     680  m_maxSbPropertyBitRate.resize( m_numAdditionalSubStreamsMinus1 + 1);
     681}
     682
     683Void SEIAlphaChannelInfo::setupFromCfgFile(const Char* cfgFile)
     684{
     685  // Set default values
     686  IntAry1d defAppLayerIds, defAppPocs, defAppTids, defAppVclNaluTypes;
     687
     688  // TBD: Add default values for which layers, POCS, Tids or Nalu types the SEI should be send.
     689  defAppLayerIds    .clear();
     690  defAppPocs        .push_back( 0 );
     691  defAppTids        .push_back( 0 );
     692  defAppVclNaluTypes = IDR_NAL_UNIT_TYPES;
     693
     694  Int      defSeiNaluId                  = 0;
     695  Int      defPositionInSeiNalu          = 0;
     696  Bool     defModifyByEncoder            = false;
     697
     698  // Setup config file options
     699  po::Options opts;
     700  xAddGeneralOpts( opts , defAppLayerIds, defAppPocs, defAppTids, defAppVclNaluTypes, defSeiNaluId, defPositionInSeiNalu, defModifyByEncoder );
     701
     702  opts.addOptions()
     703    ("AlphaChannelCancelFlag"         , m_alphaChannelCancelFlag           , false                          , "AlphaChannelCancelFlag"           )
     704    ("AlphaChannelUseIdc"             , m_alphaChannelUseIdc               , 0                              , "AlphaChannelUseIdc"               )
     705    ("AlphaChannelBitDepthMinus8"     , m_alphaChannelBitDepthMinus8       , 0                              , "AlphaChannelBitDepthMinus8"       )
     706    ("AlphaTransparentValue"          , m_alphaTransparentValue            , 0                              , "AlphaTransparentValue"            )
     707    ("AlphaOpaqueValue"               , m_alphaOpaqueValue                 , 255                            , "AlphaOpaqueValue"                 )
     708    ("AlphaChannelIncrFlag"           , m_alphaChannelIncrFlag             , false                          , "AlphaChannelIncrFlag"             )
     709    ("AlphaChannelClipFlag"           , m_alphaChannelClipFlag             , false                          , "AlphaChannelClipFlag"             )
     710    ("AlphaChannelClipTypeFlag"       , m_alphaChannelClipTypeFlag         , false                          , "AlphaChannelClipTypeFlag"         )
     711    ;
     712
     713  po::setDefaults(opts);
     714
     715  // Parse the cfg file
     716  po::ErrorReporter err;
     717  po::parseConfigFile( opts, cfgFile, err );
     718
     719};
     720
     721Bool SEIAlphaChannelInfo::checkCfg( const TComSlice* slice )
     722{
     723  // Check config values
     724  Bool wrongConfig = false;
     725
     726  int maxInterpretationValue = (1 << (m_alphaChannelBitDepthMinus8+9)) - 1;
     727  xCheckCfgRange( wrongConfig, m_alphaChannelCancelFlag         , 0 , 1, "alpha_channel_cancel_flag"        );
     728  xCheckCfgRange( wrongConfig, m_alphaChannelUseIdc             , 0 , 7, "alpha_channel_use_idc");
     729  xCheckCfgRange( wrongConfig, m_alphaChannelBitDepthMinus8     , 0 , 7, "alpha_channel_bit_depth_minus8"   );
     730  xCheckCfgRange( wrongConfig, m_alphaTransparentValue          , 0 , maxInterpretationValue, "alpha_transparent_value"          );
     731  xCheckCfgRange( wrongConfig, m_alphaOpaqueValue               , 0 , maxInterpretationValue, "alpha_opaque_value"   );
     732  xCheckCfgRange( wrongConfig, m_alphaChannelIncrFlag           , 0 , 1, "alpha_channel_incr_flag"          );
     733  xCheckCfgRange( wrongConfig, m_alphaChannelClipFlag           , 0 , 1, "alpha_channel_clip_flag"          );
     734  xCheckCfgRange( wrongConfig, m_alphaChannelClipTypeFlag       , 0 , 1, "alpha_channel_clip_type_flag"     );
     735
     736  return wrongConfig;
     737
     738};
     739
     740SEIOverlayInfo::SEIOverlayInfo ( )
     741  : m_numOverlaysMax(16)
     742  , m_numOverlayElementsMax(256)
     743  , m_numStringBytesMax(256) //incl. null termination byte
     744{ };
     745
     746Void SEIOverlayInfo::setupFromCfgFile(const Char* cfgFile)
     747{
     748  // Set default values
     749  IntAry1d defAppLayerIds, defAppPocs, defAppTids, defAppVclNaluTypes;
     750
     751  // Add default values for which layers, POCS, Tids or Nalu types the SEI should be send.
     752  defAppLayerIds    .clear();
     753  defAppPocs        .push_back( 0 );
     754  defAppTids        .push_back( 0 );
     755  defAppVclNaluTypes = IDR_NAL_UNIT_TYPES;
     756
     757  Int      defSeiNaluId                  = 0;
     758  Int      defPositionInSeiNalu          = 0;
     759  Bool     defModifyByEncoder            = false;
     760
     761  // Setup config file options
     762  po::Options opts;
     763  xAddGeneralOpts( opts , defAppLayerIds, defAppPocs, defAppTids, defAppVclNaluTypes, defSeiNaluId, defPositionInSeiNalu, defModifyByEncoder );
     764
     765  opts.addOptions()
     766    ("OverlayInfoCancelFlag"          , m_overlayInfoCancelFlag            , false                           , "OverlayInfoCancelFlag"            )
     767    ("OverlayContentAuxIdMinus128"    , m_overlayContentAuxIdMinus128      , 0                               , "OverlayContentAuxIdMinus128"      )
     768    ("OverlayLabelAuxIdMinus128"      , m_overlayLabelAuxIdMinus128        , 0                               , "OverlayLabelAuxIdMinus128"        )
     769    ("OverlayAlphaAuxIdMinus128"      , m_overlayAlphaAuxIdMinus128        , 0                               , "OverlayAlphaAuxIdMinus128"        )
     770    ("OverlayElementLabelValueLengthMinus8", m_overlayElementLabelValueLengthMinus8, 0                       , "OverlayElementLabelValueLengthMinus8")
     771    ("NumOverlaysMinus1"              , m_numOverlaysMinus1                , 0                               , "NumOverlaysMinus1"                )
     772    ("OverlayIdx"                     , m_overlayIdx                       , IntAry1d (16,0)                 , "OverlayIdx"                       )
     773    ("LanguageOverlayPresentFlag"     , m_languageOverlayPresentFlag       , BoolAry1d(16,0)                 , "LanguageOverlayPresentFlag"       )
     774    ("OverlayContentLayerId"          , m_overlayContentLayerId            , IntAry1d (16,0)                 , "OverlayContentLayerId"            )
     775    ("OverlayLabelPresentFlag"        , m_overlayLabelPresentFlag          , BoolAry1d(16,0)                 , "OverlayLabelPresentFlag"          )
     776    ("OverlayLabelLayerId"            , m_overlayLabelLayerId              , IntAry1d (16,0)                 , "OverlayLabelLayerId"              )
     777    ("OverlayAlphaPresentFlag"        , m_overlayAlphaPresentFlag          , BoolAry1d(16,0)                 , "OverlayAlphaPresentFlag"          )
     778    ("OverlayAlphaLayerId"            , m_overlayAlphaLayerId              , IntAry1d (16,0)                 , "OverlayAlphaLayerId"              )
     779    ("NumOverlayElementsMinus1"       , m_numOverlayElementsMinus1         , IntAry1d (16,0)                 , "NumOverlayElementsMinus1"         )
     780    ("OverlayElementLabelMin_%d"      , m_overlayElementLabelMin           , IntAry1d (256,0) ,16            , "OverlayElementLabelMin"           )
     781    ("OverlayElementLabelMax_%d"      , m_overlayElementLabelMax           , IntAry1d (256,0) ,16            , "OverlayElementLabelMax"           )
     782    ("OverlayLanguage_%d"             , m_overlayLanguage                  , std::string(""), 16             , "OverlayLanguage"                  )
     783    ("OverlayName_%d"                 , m_overlayName                      , std::string(""), 16             , "OverlayName"                      )
     784    ("OverlayElementName_%d_%d"       , m_overlayElementName               , std::string(""), 256 ,16        , "OverlayElementName"               )
     785    ("OverlayInfoPersistenceFlag"     , m_overlayInfoPersistenceFlag       , false                           , "OverlayInfoPersistenceFlag"       )
     786    ;
     787
     788  po::setDefaults(opts);
     789
     790  // Parse the cfg file
     791  po::ErrorReporter err;
     792  po::parseConfigFile( opts, cfgFile, err );
     793};
     794
     795
     796Bool SEIOverlayInfo::checkCfg( const TComSlice* slice )
     797{
     798  // Check config values
     799  Bool wrongConfig = false;
     800
     801  xCheckCfgRange( wrongConfig, m_overlayInfoCancelFlag          , 0 ,   1, "overlay_info_cancel_flag"         );
     802  xCheckCfgRange( wrongConfig, m_overlayContentAuxIdMinus128    , 0 ,  31, "overlay_content_aux_id_minus128"  );
     803  xCheckCfgRange( wrongConfig, m_overlayLabelAuxIdMinus128      , 0 ,  31, "overlay_label_aux_id_minus128"    );
     804  xCheckCfgRange( wrongConfig, m_overlayAlphaAuxIdMinus128      , 0 ,  31, "overlay_alpha_aux_id_minus128"    );
     805  xCheckCfgRange( wrongConfig, m_numOverlaysMinus1              , 0 ,  m_numOverlaysMax-1, "num_overlays_minus1"  );
     806  for (Int i=0 ; i<=m_numOverlaysMinus1 ; ++i)
     807  {
     808    xCheckCfgRange( wrongConfig, m_overlayIdx[i]                  , 0 , 255, "overlay_idx"          );
     809    xCheckCfgRange( wrongConfig, m_languageOverlayPresentFlag[i]  , 0 ,   1, "language_overlay_present_flag"    );
     810    xCheckCfgRange( wrongConfig, m_overlayLabelPresentFlag[i]     , 0 ,   1, "overlay_label_present_flag"       );
     811    xCheckCfgRange( wrongConfig, m_overlayAlphaPresentFlag[i]     , 0 ,   1, "overlay_alpha_present_flag"       );
     812    xCheckCfgRange( wrongConfig, m_overlayContentLayerId[i]       , 0 ,   63, "overlay_content_layer_id"    );
     813    xCheckCfgRange( wrongConfig, m_overlayLabelLayerId[i]         , 0 ,   63, "overlay_label_layer_id"    );
     814    xCheckCfgRange( wrongConfig, m_overlayAlphaLayerId[i]         , 0 ,   63, "overlay_alpha_layer_id"    );
     815    xCheckCfgRange( wrongConfig, m_numOverlayElementsMinus1[i]    , 0 , m_numOverlayElementsMax-1, "num_overlay_elements_minus1"       );
     816    for (Int j=0 ; j<=m_numOverlayElementsMinus1[i] ; ++j)
     817    {
     818      Int maxLabelMinMaxValue = ( 1 << ( m_overlayElementLabelValueLengthMinus8 + 8 ) )-1;
     819      xCheckCfgRange( wrongConfig, m_overlayElementLabelMin[i][j] , 0 , maxLabelMinMaxValue , "overlay_element_label_min"    );
     820      xCheckCfgRange( wrongConfig, m_overlayElementLabelMax[i][j] , 0 , maxLabelMinMaxValue , "overlay_element_label_max"    );
     821    }
     822  }
     823  xCheckCfgRange( wrongConfig, m_overlayInfoPersistenceFlag     , 0 ,   1, "overlay_info_persistence_flag"    );
     824
     825  return wrongConfig;
     826
     827};
     828
     829
     830Void SEITemporalMvPredictionConstraints::setupFromCfgFile(const Char* cfgFile)
     831{
     832  // Set default values
     833  IntAry1d defAppLayerIds, defAppPocs, defAppTids, defAppVclNaluTypes;
     834
     835  // TBD: Add default values for which layers, POCS, Tids or Nalu types the SEI should be send.
     836  defAppLayerIds    .clear    (   );
     837  defAppPocs        .push_back( 0 );
     838  defAppTids        .push_back( 0 );
     839  defAppVclNaluTypes.clear    (   );
     840
     841  Int      defSeiNaluId                  = 0;
     842  Int      defPositionInSeiNalu          = 0;
     843  Bool     defModifyByEncoder            = false;
     844
     845  // Setup config file options
     846  po::Options opts;
     847  xAddGeneralOpts( opts , defAppLayerIds, defAppPocs, defAppTids, defAppVclNaluTypes, defSeiNaluId, defPositionInSeiNalu, defModifyByEncoder );
     848
     849  opts.addOptions()
     850    ("PrevPicsNotUsedFlag"   , m_prevPicsNotUsedFlag   , false, "PrevPicsNotUsedFlag"    )
     851    ("NoIntraLayerColPicFlag", m_noIntraLayerColPicFlag, false, "NoIntraLayerColPicFlag" )
     852    ;
     853
     854  po::setDefaults(opts);
     855
     856  // Parse the cfg file
     857  po::ErrorReporter err;
     858  po::parseConfigFile( opts, cfgFile, err );
     859};
     860
     861Bool SEITemporalMvPredictionConstraints::checkCfg( const TComSlice* slice )
     862{
     863  // Check config values
     864  Bool wrongConfig = false;
     865
     866  xCheckCfg     ( wrongConfig, slice->getTemporalId() == 0 , "The temporal motion vector prediction constraints SEI message may be present in an access unit with TemporalId equal to 0 and shall not be present in an access unit with TemporalId greater than 0." );
     867
     868  return wrongConfig;
     869};
     870
     871#if NH_MV_SEI_TBD
     872Void SEIFrameFieldInfo::setupFromCfgFile(const Char* cfgFile)
     873{
     874  // Set default values
     875  IntAry1d defAppLayerIds, defAppPocs, defAppTids, defAppVclNaluTypes;
     876
     877  // TBD: Add default values for which layers, POCS, Tids or Nalu types the SEI should be send.
     878  defAppLayerIds    .push_back( TBD );
     879  defAppPocs        .push_back( TBD );
     880  defAppTids        .push_back( TBD );
     881  defAppVclNaluTypes.push_back( TBD );
     882
     883  Int      defSeiNaluId                  = 0;
     884  Int      defPositionInSeiNalu          = 0;
     885  Bool     defModifyByEncoder            = false;
     886
     887  // Setup config file options
     888  po::Options opts;
     889  xAddGeneralOpts( opts , defAppLayerIds, defAppPocs, defAppTids, defAppVclNaluTypes, defSeiNaluId, defPositionInSeiNalu, defModifyByEncoder );
     890
     891  opts.addOptions()
     892    ("FfinfoPicStruct"     , m_ffinfoPicStruct     , 0     , "FfinfoPicStruct"     )
     893    ("FfinfoSourceScanType", m_ffinfoSourceScanType, 0     , "FfinfoSourceScanType")
     894    ("FfinfoDuplicateFlag" , m_ffinfoDuplicateFlag , false , "FfinfoDuplicateFlag" )
     895    ;
     896
     897  po::setDefaults(opts);
     898
     899  // Parse the cfg file
     900  po::ErrorReporter err;
     901  po::parseConfigFile( opts, cfgFile, err );
     902};
     903
     904
     905Bool SEIFrameFieldInfo::checkCfg( const TComSlice* slice )
     906{
     907  // Check config values
     908  Bool wrongConfig = false;
     909
     910  // TBD: Add constraints on presence of SEI here.
     911  xCheckCfg     ( wrongConfig, TBD , "TBD" );
     912  xCheckCfg     ( wrongConfig, TBD , "TBD" );
     913
     914  // TBD: Modify constraints according to the SEI semantics.
     915  xCheckCfgRange( wrongConfig, m_ffinfoPicStruct                , MINVAL , MAXVAL, "ffinfo_pic_struct"                );
     916  xCheckCfgRange( wrongConfig, m_ffinfoSourceScanType           , MINVAL , MAXVAL, "ffinfo_source_scan_type"          );
     917  xCheckCfgRange( wrongConfig, m_ffinfoDuplicateFlag            , MINVAL , MAXVAL, "ffinfo_duplicate_flag"            );
     918
     919  return wrongConfig;
     920
     921};
     922#endif
     923
     924Void SEIThreeDimensionalReferenceDisplaysInfo::setupFromCfgFile(const Char* cfgFile)
     925{
     926  // Set default values
     927  IntAry1d defAppLayerIds, defAppPocs, defAppTids, defAppVclNaluTypes;
     928
     929  // Default values for which layers, POCS, Tids or Nalu types the SEI should be sent.
     930  defAppLayerIds      .push_back( 0 );
     931  defAppPocs          .push_back( 0 );
     932  defAppTids          .push_back( 0 );
     933  defAppVclNaluTypes = IRAP_NAL_UNIT_TYPES;
     934
     935  Int      defSeiNaluId                  = 0;
     936  Int      defPositionInSeiNalu          = 0;
     937  Bool     defModifyByEncoder            = 0;
     938
     939  // Setup config file options
     940  po::Options opts;
     941  xAddGeneralOpts( opts , defAppLayerIds, defAppPocs, defAppTids, defAppVclNaluTypes, defSeiNaluId, defPositionInSeiNalu, defModifyByEncoder );
     942
     943  opts.addOptions()
     944    ("PrecRefDisplayWidth"            , m_precRefDisplayWidth              , 0                              , "PrecRefDisplayWidth"              )
     945    ("RefViewingDistanceFlag"         , m_refViewingDistanceFlag           , false                          , "RefViewingDistanceFlag"           )
     946    ("PrecRefViewingDist"             , m_precRefViewingDist               , 0                              , "PrecRefViewingDist"               )
     947    ("NumRefDisplaysMinus1"           , m_numRefDisplaysMinus1             , 0                              , "NumRefDisplaysMinus1"             )
     948    ("LeftViewId"                     , m_leftViewId                       , IntAry1d (1,0)                 , "LeftViewId"                       )
     949    ("RightViewId"                    , m_rightViewId                      , IntAry1d (1,0)                 , "RightViewId"                      )
     950    ("ExponentRefDisplayWidth"        , m_exponentRefDisplayWidth          , IntAry1d (1,0)                 , "ExponentRefDisplayWidth"          )
     951    ("MantissaRefDisplayWidth"        , m_mantissaRefDisplayWidth          , IntAry1d (1,0)                 , "MantissaRefDisplayWidth"          )
     952    ("ExponentRefViewingDistance"     , m_exponentRefViewingDistance       , IntAry1d (1,0)                 , "ExponentRefViewingDistance"       )
     953    ("MantissaRefViewingDistance"     , m_mantissaRefViewingDistance       , IntAry1d (1,0)                 , "MantissaRefViewingDistance"       )
     954    ("AdditionalShiftPresentFlag"     , m_additionalShiftPresentFlag       , BoolAry1d(1,0)                 , "AdditionalShiftPresentFlag"       )
     955    ("NumSampleShiftPlus512"          , m_numSampleShiftPlus512            , IntAry1d (1,0)                 , "NumSampleShiftPlus512"            )
     956    ("ThreeDimensionalReferenceDisplaysExtensionFlag", m_threeDimensionalReferenceDisplaysExtensionFlag, false                          , "ThreeDimensionalReferenceDisplaysExtensionFlag")
     957    ;
     958
     959  po::setDefaults(opts);
     960
     961  // Parse the cfg file
     962  po::ErrorReporter err;
     963  po::parseConfigFile( opts, cfgFile, err );
     964};
     965
     966
     967UInt SEIThreeDimensionalReferenceDisplaysInfo::getMantissaReferenceDisplayWidthLen( Int i ) const
     968{
     969  return xGetSyntaxElementLen( m_exponentRefDisplayWidth[i], m_precRefDisplayWidth, m_mantissaRefDisplayWidth[ i ] );
     970}
     971
     972UInt SEIThreeDimensionalReferenceDisplaysInfo::getMantissaReferenceViewingDistanceLen( Int i ) const
     973{
     974  return xGetSyntaxElementLen( m_exponentRefViewingDistance[i], m_precRefViewingDist, m_mantissaRefViewingDistance[ i ] );
     975}
     976
     977UInt SEIThreeDimensionalReferenceDisplaysInfo::xGetSyntaxElementLen( Int expo, Int prec, Int val ) const
     978{
     979  UInt len;
     980  if( expo == 0 )
     981  {
     982    len = std::max(0, prec - 30 );
     983  }
     984  else
     985  {
     986    len = std::max( 0, expo + prec - 31 );
     987  }
     988
     989  assert( val >= 0 );
     990  assert( val <= ( ( 1 << len )- 1) );
     991  return len;
     992}
     993
     994Bool SEIThreeDimensionalReferenceDisplaysInfo::checkCfg( const TComSlice* slice )
     995{
     996  // Check config values
     997  Bool wrongConfig = false;
     998
     999  // The 3D reference display SEI should preferably be sent along with the multiview acquisition SEI. For now the multiview acquisition SEI is restricted to POC = 0, so 3D reference displays SEI is restricted to POC = 0 as well.
     1000  xCheckCfg     ( wrongConfig, slice->isIRAP() && (slice->getPOC() == 0)  , "The 3D reference displays SEI message currently is associated with an access unit that contains an IRAP picture." );
     1001
     1002  xCheckCfgRange( wrongConfig, m_precRefDisplayWidth            , 0 , 31, "prec_ref_display_width"  );
     1003  xCheckCfgRange( wrongConfig, m_refViewingDistanceFlag         , 0 , 1, "ref_viewing_distance_flag");
     1004  xCheckCfgRange( wrongConfig, m_precRefViewingDist             , 0 , 31, "prec_ref_viewing_dist"   );
     1005  xCheckCfgRange( wrongConfig, m_numRefDisplaysMinus1           , 0 , 31, "num_ref_displays_minus1" );
     1006
     1007  for (Int i = 0; i <= getNumRefDisplaysMinus1(); i++ )
     1008  {
     1009    xCheckCfgRange( wrongConfig, m_exponentRefDisplayWidth[i]     , 0 , 62, "exponent_ref_display_width"   );
     1010    xCheckCfgRange( wrongConfig, m_exponentRefViewingDistance[i]  , 0 , 62, "exponent_ref_viewing_distance");
     1011    xCheckCfgRange( wrongConfig, m_additionalShiftPresentFlag[i]  , 0 , 1, "additional_shift_present_flag" );
     1012    xCheckCfgRange( wrongConfig, m_numSampleShiftPlus512[i]       , 0 , 1023, "num_sample_shift_plus512"   );
     1013  }
     1014  xCheckCfgRange( wrongConfig, m_threeDimensionalReferenceDisplaysExtensionFlag, 0 , 1, "three_dimensional_reference_displays_extension_flag");
     1015
     1016  return wrongConfig;
     1017
     1018};
     1019
     1020#if SEI_DRI_F0169
     1021Void SEIDepthRepresentationInfo::setupFromSlice  ( const TComSlice* slice )
     1022{
     1023
     1024    m_currLayerID=slice->getLayerIdInVps();
     1025};
     1026
     1027Void SEIDepthRepresentationInfo::setupFromCfgFile(const Char* cfgFile)
     1028{
     1029  // Set default values
     1030  IntAry1d defAppLayerIds, defAppPocs, defAppTids, defAppVclNaluTypes;
     1031
     1032  // TBD: Add default values for which layers, POCS, Tids or Nalu types the SEI should be send.
     1033  //defAppLayerIds    .push_back( TBD );
     1034  defAppPocs        .push_back( 0 );
     1035  //defAppTids        .push_back( TBD );
     1036  //defAppVclNaluTypes.push_back( TBD );
     1037
     1038  Int      defSeiNaluId                  = 0;
     1039  Int      defPositionInSeiNalu          = 0;
     1040  Bool     defModifyByEncoder            = true;
     1041
     1042  // Setup config file options
     1043  po::Options opts;
     1044
     1045  xAddGeneralOpts( opts , defAppLayerIds, defAppPocs, defAppTids, defAppVclNaluTypes, defSeiNaluId, defPositionInSeiNalu, defModifyByEncoder );
     1046
     1047  opts.addOptions()
     1048    ("ZNear_%d"                      , m_zNear               , std::vector<double>(0,0)       , MAX_NUM_LAYERS , "ZNear"           )
     1049    ("ZFar_%d"                       , m_zFar                , std::vector<double>(0,0)       , MAX_NUM_LAYERS , "ZFar"            )
     1050    ("DMin_%d"                       , m_dMin                , std::vector<double>(0,0)       , MAX_NUM_LAYERS , "DMin"            )
     1051    ("DMax_%d"                       , m_dMax                , std::vector<double>(0,0)       , MAX_NUM_LAYERS , "DMax"            )
     1052    ("DepthRepresentationInfoSeiPresentFlag_%d",  m_depthRepresentationInfoSeiPresentFlag, BoolAry1d(1,0), MAX_NUM_LAYERS, "DepthRepresentationInfoSeiPresentFlag")
     1053    ("DepthRepresentationType_%d"        , m_depthRepresentationType          , IntAry1d(0,0), MAX_NUM_LAYERS,  "DepthRepresentationType"        )
     1054    ("DisparityRefViewId_%d"             , m_disparityRefViewId               ,  IntAry1d(0,0), MAX_NUM_LAYERS,  "DisparityRefViewId"             )
     1055    ("DepthNonlinearRepresentationNumMinus1_%d", m_depthNonlinearRepresentationNumMinus1, IntAry1d(0,0), MAX_NUM_LAYERS, "DepthNonlinearRepresentationNumMinus1")
     1056    ("DepthNonlinearRepresentationModel_%d"    , m_depth_nonlinear_representation_model ,   IntAry1d(0,0), MAX_NUM_LAYERS, "DepthNonlinearRepresentationModel") ;
     1057
     1058
     1059  po::setDefaults(opts);
     1060
     1061  // Parse the cfg file
     1062  po::ErrorReporter err;
     1063  po::parseConfigFile( opts, cfgFile, err );
     1064
     1065
     1066  for(int i=0;i<MAX_NUM_LAYERS;i++)
     1067  {
     1068    if (m_zNear[i].size()>0)
     1069    {
     1070      m_zNearFlag.push_back(true);
     1071    }
     1072    else
     1073    {
     1074      m_zNearFlag.push_back(false);
     1075    }
     1076
     1077    if (m_zFar[i].size()>0)
     1078    {
     1079      m_zFarFlag.push_back(true);
     1080    }
     1081    else
     1082    {
     1083      m_zFarFlag.push_back(false);
     1084    }
     1085
     1086    if (m_dMin[i].size()>0)
     1087    {
     1088      m_dMinFlag.push_back(true);
     1089    }
     1090    else
     1091    {
     1092      m_dMinFlag.push_back(false);
     1093    }
     1094
     1095    if (m_dMax[i].size()>0)
     1096    {
     1097      m_dMaxFlag.push_back(true);
     1098    }
     1099    else
     1100    {
     1101      m_dMaxFlag.push_back(false);
     1102    }
     1103
     1104
     1105    if (m_depthRepresentationInfoSeiPresentFlag[i][0])
     1106    {
     1107      if ( m_depthRepresentationType[i].size()<=0 )
     1108      {
     1109        printf("DepthRepresentationType_%d must be present for layer %d\n",i,i );
     1110        return;
     1111      }
     1112
     1113      if (  m_depthRepresentationType[i][0]<0 )
     1114      {
     1115        printf("DepthRepresentationType_%d must be equal to or greater than 0\n",i );
     1116        return;
     1117      }
     1118
     1119      if (m_dMinFlag[i] || m_dMaxFlag[i])
     1120      {
     1121        if (m_disparityRefViewId[i].size()<=0)
     1122        {
     1123          printf("DisparityRefViewId_%d must be present for layer %d\n",i,i );
     1124          assert(false);
     1125          return;
     1126        }
     1127        if (m_disparityRefViewId[i][0]<0)
     1128        {
     1129          printf("DisparityRefViewId_%d must be equal to or greater than 0\n",i );
     1130          assert(false);
     1131          return;
     1132        }
     1133      }
     1134
     1135      if (m_depthRepresentationType[i][0]==3)
     1136      {
     1137        if (m_depthNonlinearRepresentationNumMinus1[i].size()<=0)
     1138        {
     1139          printf("DepthNonlinearRepresentationNumMinus1_%d must be present for layer %d\n",i,i );
     1140          assert(false);
     1141          return;
     1142        }
     1143        if (m_depthNonlinearRepresentationNumMinus1[i][0]<0)
     1144        {
     1145          printf("DepthNonlinearRepresentationNumMinus1_%d must be equal to or greater than 0\n",i );
     1146          assert(false);
     1147          return;
     1148        }
     1149
     1150        if (m_depth_nonlinear_representation_model[i].size() != m_depthNonlinearRepresentationNumMinus1[i][0]+1)
     1151        {
     1152          printf("the number of values in Depth_nonlinear_representation_model must be equal to DepthNonlinearRepresentationNumMinus1+1 in layer %d\n",i );
     1153          assert(false);
     1154          return;
     1155        }
     1156      }
     1157    }
     1158  }
     1159
     1160  assert(m_zNearFlag.size()==MAX_NUM_LAYERS);
     1161  assert(m_zFarFlag.size()==MAX_NUM_LAYERS);
     1162  assert(m_dMinFlag.size()==MAX_NUM_LAYERS);
     1163  assert(m_dMaxFlag.size()==MAX_NUM_LAYERS);
     1164}
     1165
     1166Bool SEIDepthRepresentationInfo::checkCfg( const TComSlice* slice )
     1167{
     1168    // Check config values
     1169    Bool wrongConfig = false;
     1170    assert(m_currLayerID>=0);
     1171
     1172    if (m_depthRepresentationInfoSeiPresentFlag[m_currLayerID][0]==false)
     1173    {
     1174        printf("DepthRepresentationInfoSeiPresentFlag_%d should be equal to 1 when  ApplicableLayerIds is empty or ApplicableLayerIds contains  %d\n",m_currLayerID,slice->getLayerId());
     1175        assert(false);
     1176    }
     1177    // TBD: Add constraints on presence of SEI here.
     1178    xCheckCfg     ( wrongConfig, m_depthRepresentationType[m_currLayerID][0] >=0 , "depth_representation_type must be equal to or greater than 0" );
     1179    if ( m_dMaxFlag[m_currLayerID] || m_dMinFlag[m_currLayerID])
     1180    {
     1181        xCheckCfg( wrongConfig , m_disparityRefViewId[m_currLayerID][0]>=0, "disparity_ref_view_id must be equal to or greater than 0 when d_min or d_max are present");
     1182    }
     1183
     1184    if (m_depthRepresentationType[m_currLayerID][0]==3)
     1185    {
     1186        xCheckCfg(wrongConfig , m_depthNonlinearRepresentationNumMinus1[m_currLayerID][0]>=0, "depth_nonlinear_representation_num_minus1 must be greater than or equal to 0");
     1187
     1188        if (m_depthNonlinearRepresentationNumMinus1[m_currLayerID][0]>=0)
     1189        {
     1190            xCheckCfg( wrongConfig , m_depthNonlinearRepresentationNumMinus1[m_currLayerID][0]+1 == m_depth_nonlinear_representation_model[m_currLayerID].size() ,"the number of values in depth_nonlinear_representation_model must be equal to depth_nonlinear_representation_num_minus1+1");
     1191        }
     1192
     1193    }
     1194
     1195    return wrongConfig;
     1196}
     1197#endif
     1198
     1199Void SEIMultiviewSceneInfo::setupFromCfgFile(const Char* cfgFile)
     1200{
     1201  // Set default values
     1202  IntAry1d defAppLayerIds, defAppPocs, defAppTids, defAppVclNaluTypes;
     1203
     1204  // TBD: Add default values for which layers, POCS, Tids or Nalu types the SEI should be send.
     1205  defAppLayerIds      .clear();
     1206  defAppPocs          .clear();
     1207  defAppTids          .push_back( 0 );
     1208  defAppVclNaluTypes = IRAP_NAL_UNIT_TYPES;
     1209
     1210  Int      defSeiNaluId                  = 0;
     1211  Int      defPositionInSeiNalu          = 0;
     1212  Bool     defModifyByEncoder            = false;
     1213
     1214  // Setup config file options
     1215  po::Options opts;
     1216  xAddGeneralOpts( opts , defAppLayerIds, defAppPocs, defAppTids, defAppVclNaluTypes, defSeiNaluId, defPositionInSeiNalu, defModifyByEncoder );
     1217
     1218  opts.addOptions()
     1219    ("MinDisparity"                   , m_minDisparity                     , 0                              , "MinDisparity"                     )
     1220    ("MaxDisparityRange"              , m_maxDisparityRange                , 0                              , "MaxDisparityRange"                )
     1221    ;
     1222
     1223  po::setDefaults(opts);
     1224
     1225  // Parse the cfg file
     1226  po::ErrorReporter err;
     1227  po::parseConfigFile( opts, cfgFile, err );
     1228};
     1229
     1230
     1231Bool SEIMultiviewSceneInfo::checkCfg( const TComSlice* slice )
     1232{
     1233  // Check config values
     1234  Bool wrongConfig = false;
     1235
     1236  xCheckCfg     ( wrongConfig, slice->isIRAP(), "When present, the multiview scene information SEI message shall be associated with an IRAP access unit." );
     1237
     1238  xCheckCfgRange( wrongConfig, m_minDisparity              , -1024 , 1023, "min_disparity"                    );
     1239  xCheckCfgRange( wrongConfig, m_maxDisparityRange         ,     0 , 2047, "max_disparity_range"              );
     1240
     1241  return wrongConfig;
     1242
     1243};
     1244
     1245Void SEIMultiviewAcquisitionInfo::setupFromCfgFile(const Char* cfgFile)
     1246{
     1247  // Set default values
     1248  IntAry1d defAppLayerIds, defAppPocs, defAppTids, defAppVclNaluTypes;
     1249
     1250  defAppLayerIds    .clear();
     1251  defAppPocs        .push_back( 0 );
     1252  defAppTids        .push_back( 0 );
     1253  defAppVclNaluTypes = IDR_NAL_UNIT_TYPES;
     1254
     1255
     1256  Int      defSeiNaluId                  = 0;
     1257  Int      defPositionInSeiNalu          = 0;
     1258  Bool     defModifyByEncoder            = false;
     1259
     1260  // Setup config file options
     1261  po::Options opts;
     1262  xAddGeneralOpts( opts , defAppLayerIds, defAppPocs, defAppTids, defAppVclNaluTypes, defSeiNaluId, defPositionInSeiNalu, defModifyByEncoder );
     1263
     1264  opts.addOptions()
     1265    ("IntrinsicParamFlag"               , m_intrinsicParamFlag               , false                              , "IntrinsicParamFlag"               )
     1266    ("ExtrinsicParamFlag"               , m_extrinsicParamFlag               , false                              , "ExtrinsicParamFlag"               )
     1267    ("IntrinsicParamsEqualFlag"         , m_intrinsicParamsEqualFlag         , false                              , "IntrinsicParamsEqualFlag"         )
     1268    ("PrecFocalLength"                  , m_precFocalLength                  , 0                                  , "PrecFocalLength"                  )
     1269    ("PrecPrincipalPoint"               , m_precPrincipalPoint               , 0                                  , "PrecPrincipalPoint"               )
     1270    ("PrecSkewFactor"                   , m_precSkewFactor                   , 0                                  , "PrecSkewFactor"                   )
     1271    ("SignFocalLengthX"                 , m_signFocalLengthX                 , BoolAry1d(1,0)                     , "SignFocalLengthX"                 )
     1272    ("ExponentFocalLengthX"             , m_exponentFocalLengthX             , IntAry1d (1,0)                     , "ExponentFocalLengthX"             )
     1273    ("MantissaFocalLengthX"             , m_mantissaFocalLengthX             , IntAry1d (1,0)                     , "MantissaFocalLengthX"             )
     1274    ("SignFocalLengthY"                 , m_signFocalLengthY                 , BoolAry1d(1,0)                     , "SignFocalLengthY"                 )
     1275    ("ExponentFocalLengthY"             , m_exponentFocalLengthY             , IntAry1d (1,0)                     , "ExponentFocalLengthY"             )
     1276    ("MantissaFocalLengthY"             , m_mantissaFocalLengthY             , IntAry1d (1,0)                     , "MantissaFocalLengthY"             )
     1277    ("SignPrincipalPointX"              , m_signPrincipalPointX              , BoolAry1d(1,0)                     , "SignPrincipalPointX"              )
     1278    ("ExponentPrincipalPointX"          , m_exponentPrincipalPointX          , IntAry1d (1,0)                     , "ExponentPrincipalPointX"          )
     1279    ("MantissaPrincipalPointX"          , m_mantissaPrincipalPointX          , IntAry1d (1,0)                     , "MantissaPrincipalPointX"          )
     1280    ("SignPrincipalPointY"              , m_signPrincipalPointY              , BoolAry1d(1,0)                     , "SignPrincipalPointY"              )
     1281    ("ExponentPrincipalPointY"          , m_exponentPrincipalPointY          , IntAry1d (1,0)                     , "ExponentPrincipalPointY"          )
     1282    ("MantissaPrincipalPointY"          , m_mantissaPrincipalPointY          , IntAry1d (1,0)                     , "MantissaPrincipalPointY"          )
     1283    ("SignSkewFactor"                   , m_signSkewFactor                   , BoolAry1d(1,0)                     , "SignSkewFactor"                   )
     1284    ("ExponentSkewFactor"               , m_exponentSkewFactor               , IntAry1d (1,0)                     , "ExponentSkewFactor"               )
     1285    ("MantissaSkewFactor"               , m_mantissaSkewFactor               , IntAry1d (1,0)                     , "MantissaSkewFactor"               )
     1286    ("PrecRotationParam"                , m_precRotationParam                , 0                                  , "PrecRotationParam"                )
     1287    ("PrecTranslationParam"             , m_precTranslationParam             , 0                                  , "PrecTranslationParam"             )
     1288    ("SignR_%d_%d"                      , m_signR                            , BoolAry1d(3,0) ,MAX_NUM_LAYERS ,3  , "SignR"                            )
     1289    ("ExponentR_%d_%d"                  , m_exponentR                        , IntAry1d (3,0) ,MAX_NUM_LAYERS ,3  , "ExponentR"                        )
     1290    ("MantissaR_%d_%d"                  , m_mantissaR                        , IntAry1d (3,0) ,MAX_NUM_LAYERS ,3  , "MantissaR"                        )
     1291    ("SignT_%d"                         , m_signT                            , BoolAry1d(3,0) ,MAX_NUM_LAYERS     , "SignT"                            )
     1292    ("ExponentT_%d"                     , m_exponentT                        , IntAry1d (3,0) ,MAX_NUM_LAYERS     , "ExponentT"                        )
     1293    ("MantissaT_%d"                     , m_mantissaT                        , IntAry1d (3,0) ,MAX_NUM_LAYERS     , "MantissaT"                        )
     1294    ;
     1295
     1296  po::setDefaults(opts);
     1297
     1298  // Parse the cfg file
     1299  po::ErrorReporter err;
     1300  po::parseConfigFile( opts, cfgFile, err );
     1301};
     1302
     1303UInt SEIMultiviewAcquisitionInfo::getMantissaFocalLengthXLen( Int i ) const
     1304{
     1305  return xGetSyntaxElementLen( m_exponentFocalLengthX[i], m_precFocalLength, m_mantissaFocalLengthX[ i ] );
     1306}
     1307
     1308Bool SEIMultiviewAcquisitionInfo::checkCfg( const TComSlice* slice )
     1309{
     1310  // Check config values
     1311  Bool wrongConfig = false;
     1312
     1313  // Currently the encoder starts with POC 0 for all layers. The condition on POC 0 should be changed, when this changes.
     1314  xCheckCfg     ( wrongConfig, slice->isIRAP() && (slice->getPOC() == 0)  , "When present, the multiview acquisition information SEI message that applies to the current layer shall be included in an access unit that contains an IRAP picture that is the first picture of a CLVS of the current layer." );
     1315
     1316  xCheckCfgRange( wrongConfig, m_precFocalLength         , 0, 31, "prec_focal_length"         );
     1317  xCheckCfgRange( wrongConfig, m_precPrincipalPoint      , 0, 31, "prec_principle_point"      );
     1318  xCheckCfgRange( wrongConfig, m_precSkewFactor          , 0, 31, "prec_skew_factor"          );
     1319
     1320  for (Int i = 0; i <= getNumViewsMinus1(); i++ )
     1321  {
     1322    xCheckCfgRange( wrongConfig, m_exponentFocalLengthX    [ i ], 0, 62, "exponent_focal_length_x"   );
     1323    xCheckCfgRange( wrongConfig, m_exponentFocalLengthY    [ i ], 0, 62, "exponent_focal_length_y"   );
     1324    xCheckCfgRange( wrongConfig, m_exponentPrincipalPointX [ i ], 0, 62, "exponent_principal_point_x");
     1325    xCheckCfgRange( wrongConfig, m_exponentPrincipalPointY [ i ], 0, 62, "exponent_principal_point_y");
     1326    xCheckCfgRange( wrongConfig, m_exponentSkewFactor      [ i ], 0, 62, "exponent_skew_factor"      );
     1327  }
     1328
     1329  xCheckCfgRange( wrongConfig, m_precRotationParam       , 0, 31, "prec_focal_length"         );
     1330  xCheckCfgRange( wrongConfig, m_precTranslationParam    , 0, 31, "prec_focal_length"         );
     1331
     1332  for (Int i = 0; i <= getNumViewsMinus1(); i++ )
     1333  {
     1334    for (Int j = 0; j <= 2; j++)
     1335    {
     1336      xCheckCfgRange( wrongConfig, m_exponentT[i][j]     , 0, 62, "exponent_skew_factor"      );
     1337      for (Int k = 0; k <= 2; k++ )
     1338      {
     1339        xCheckCfgRange( wrongConfig, m_exponentR[i][j][k], 0, 62, "exponent_principal_point_y");
     1340      }
     1341    }
     1342  }
     1343
     1344  return wrongConfig;
     1345
     1346};
     1347
     1348UInt SEIMultiviewAcquisitionInfo::getMantissaFocalLengthYLen( Int i ) const
     1349{
     1350  return xGetSyntaxElementLen( m_exponentFocalLengthY[i], m_precFocalLength, m_mantissaFocalLengthY[ i ]  );
     1351}
     1352
     1353
     1354UInt SEIMultiviewAcquisitionInfo::getMantissaPrincipalPointXLen( Int i ) const
     1355{
     1356  return xGetSyntaxElementLen( m_exponentPrincipalPointX[i], m_precPrincipalPoint, m_mantissaPrincipalPointX[ i ]  );
     1357}
     1358
     1359UInt SEIMultiviewAcquisitionInfo::getMantissaPrincipalPointYLen( Int i ) const
     1360{
     1361  return xGetSyntaxElementLen( m_exponentPrincipalPointY[i], m_precPrincipalPoint, m_mantissaPrincipalPointY[ i ] );
     1362}
     1363
     1364UInt SEIMultiviewAcquisitionInfo::getMantissaSkewFactorLen( Int i ) const
     1365{
     1366  return xGetSyntaxElementLen( m_exponentSkewFactor[ i ], m_precSkewFactor, m_mantissaSkewFactor[ i ] );
     1367}
     1368
     1369UInt SEIMultiviewAcquisitionInfo::getMantissaRLen( Int i, Int j, Int k ) const
     1370{
     1371  return xGetSyntaxElementLen( m_exponentR[ i ][ j ][ k ], m_precRotationParam, m_mantissaR[ i ][ j] [ k ] );
     1372}
     1373
     1374UInt SEIMultiviewAcquisitionInfo::getMantissaTLen( Int i, Int j ) const
     1375{
     1376  return xGetSyntaxElementLen( m_exponentT[ i ][ j ], m_precTranslationParam, m_mantissaT[ i ][ j ] );
     1377}
     1378UInt SEIMultiviewAcquisitionInfo::xGetSyntaxElementLen( Int expo, Int prec, Int val ) const
     1379{
     1380  UInt len;
     1381  if( expo == 0 )
     1382  {
     1383    len = std::max(0, prec - 30 );
     1384  }
     1385  else
     1386  {
     1387    len = std::max( 0, expo + prec - 31 );
     1388  }
     1389
     1390  assert( val >= 0 );
     1391  assert( val <= ( ( 1 << len )- 1) );
     1392  return len;
     1393}
     1394
     1395Void SEIMultiviewViewPosition::setupFromSlice  ( const TComSlice* slice )
     1396{
     1397  const TComVPS* vps = slice->getVPS();
     1398  m_numViewsMinus1 = vps->getNumViews() - 1;
     1399  m_viewPosition.resize( m_numViewsMinus1 + 1 );
     1400  for (Int i = 0; i <= m_numViewsMinus1; i++ )
     1401  {
     1402    // Assuming that view ids indicate the position
     1403    m_viewPosition[i] = vps->getViewIdVal( i );
     1404  }
     1405}
     1406
     1407Void SEIMultiviewViewPosition::setupFromCfgFile(const Char* cfgFile)
     1408{
     1409  // Set default values
     1410  IntAry1d defAppLayerIds, defAppPocs, defAppTids, defAppVclNaluTypes;
     1411
     1412  defAppLayerIds    .push_back( 0 );
     1413  defAppPocs        .push_back( 0 );
     1414  defAppTids        .push_back( 0 );
     1415  defAppVclNaluTypes = IDR_NAL_UNIT_TYPES;
     1416
     1417  Int      defSeiNaluId                  = 0;
     1418  Int      defPositionInSeiNalu          = 0;
     1419  Bool     defModifyByEncoder            = true;
     1420
     1421  // Setup config file options
     1422  po::Options opts;
     1423  xAddGeneralOpts( opts , defAppLayerIds, defAppPocs, defAppTids, defAppVclNaluTypes, defSeiNaluId, defPositionInSeiNalu, defModifyByEncoder );
     1424
     1425  opts.addOptions()
     1426    ("NumViewsMinus1"         , m_numViewsMinus1                          , 0                       , "NumViewsMinus1")
     1427    ("ViewPosition"           , m_viewPosition                            , IntAry1d (1,0)          , "ViewPosition"  );
     1428  ;
     1429
     1430  po::setDefaults(opts);
     1431
     1432  // Parse the cfg file
     1433  po::ErrorReporter err;
     1434  po::parseConfigFile( opts, cfgFile, err );
     1435};
     1436
     1437Bool SEIMultiviewViewPosition::checkCfg( const TComSlice* slice )
     1438{
     1439  // Check config values
     1440  Bool wrongConfig = false;
     1441
     1442  // TBD: Add constraints on presence of SEI here.
     1443  xCheckCfg     ( wrongConfig, slice->isIRAP() , "When present, the multiview view position SEI message shall be associated with an IRAP access unit."  );
     1444
     1445  // TBD: Modify constraints according to the SEI semantics.
     1446  xCheckCfgRange( wrongConfig, m_numViewsMinus1                 , 0 , 62, "num_views_minus1");
     1447  for(Int i = 0; i <= m_numViewsMinus1; i++)
     1448  {
     1449    xCheckCfgRange( wrongConfig, m_viewPosition[i]                , 0 , 62, "view_position");
     1450  }
     1451
     1452  return wrongConfig;
     1453
     1454};
     1455
     1456
     1457#if NH_3D
     1458Void SEIAlternativeDepthInfo::setupFromCfgFile(const Char* cfgFile)
     1459{
     1460  // Set default values
     1461  IntAry1d defAppLayerIds, defAppPocs, defAppTids, defAppVclNaluTypes;
     1462
     1463  defAppLayerIds    .clear();
     1464  defAppPocs        .clear();
     1465  defAppTids        .clear();
     1466  defAppVclNaluTypes.clear();
     1467
     1468  Int      defSeiNaluId                  = 0;
     1469  Int      defPositionInSeiNalu          = 0;
     1470  Bool     defModifyByEncoder            = false;
     1471
     1472  // Setup config file options
     1473  po::Options opts;
     1474  xAddGeneralOpts( opts , defAppLayerIds, defAppPocs, defAppTids, defAppVclNaluTypes, defSeiNaluId, defPositionInSeiNalu, defModifyByEncoder );
     1475
     1476  opts.addOptions()
     1477    ("AlternativeDepthInfoCancelFlag" , m_alternativeDepthInfoCancelFlag  , false               , "AlternativeDepthInfoCancelFlag"  )
     1478    ("DepthType"                      , m_depthType                       , 1                   , "DepthType"                       )
     1479    ("NumConstituentViewsGvdMinus1"   , m_numConstituentViewsGvdMinus1    , 1                   , "NumConstituentViewsGvdMinus1"    )
     1480    ("DepthPresentGvdFlag"            , m_depthPresentGvdFlag             , false               , "DepthPresentGvdFlag"             )
     1481    ("ZGvdFlag"                       , m_zGvdFlag                        , false               , "ZGvdFlag"                        )
     1482    ("IntrinsicParamGvdFlag"          , m_intrinsicParamGvdFlag           , false               , "IntrinsicParamGvdFlag"           )
     1483    ("RotationGvdFlag"                , m_rotationGvdFlag                 , false               , "RotationGvdFlag"                 )
     1484    ("TranslationGvdFlag"             , m_translationGvdFlag              , false               , "TranslationGvdFlag"              )
     1485    ("SignGvdZNearFlag_%d"            , m_signGvdZNearFlag                , BoolAry1d(3,0), 3   , "SignGvdZNearFlag"                )
     1486    ("ExpGvdZNear_%d"                 , m_expGvdZNear                     , IntAry1d (3,0), 3   , "ExpGvdZNear"                     )
     1487    ("ManLenGvdZNearMinus1_%d"        , m_manLenGvdZNearMinus1            , IntAry1d (3,0), 3   , "ManLenGvdZNearMinus1"            )
     1488    ("ManGvdZNear_%d"                 , m_manGvdZNear                     , IntAry1d (3,0), 3   , "ManGvdZNear"                     )
     1489    ("SignGvdZFarFlag_%d"             , m_signGvdZFarFlag                 , BoolAry1d(3,0), 3   , "SignGvdZFarFlag"                 )
     1490    ("ExpGvdZFar_%d"                  , m_expGvdZFar                      , IntAry1d (3,0), 3   , "ExpGvdZFar"                      )
     1491    ("ManLenGvdZFarMinus1_%d"         , m_manLenGvdZFarMinus1             , IntAry1d (3,0), 3   , "ManLenGvdZFarMinus1"             )
     1492    ("ManGvdZFar_%d"                  , m_manGvdZFar                      , IntAry1d (3,0), 3   , "ManGvdZFar"                      )
     1493    ("PrecGvdFocalLength"             , m_precGvdFocalLength              , 18                  , "PrecGvdFocalLength"              )
     1494    ("PrecGvdPrincipalPoint"          , m_precGvdPrincipalPoint           , 18                  , "PrecGvdPrincipalPoint"           )
     1495    ("PrecGvdRotationParam"           , m_precGvdRotationParam            , 18                  , "PrecGvdRotationParam"            )
     1496    ("PrecGvdTranslationParam"        , m_precGvdTranslationParam         , 18                  , "PrecGvdTranslationParam"         )
     1497    ("SignGvdFocalLengthX_%d"         , m_signGvdFocalLengthX             , BoolAry1d(3,0), 3   ,"SignGvdFocalLengthX"              )
     1498    ("ExpGvdFocalLengthX_%d"          , m_expGvdFocalLengthX              , IntAry1d (3,0), 3   ,"ExpGvdFocalLengthX"               )
     1499    ("ManGvdFocalLengthX_%d"          , m_manGvdFocalLengthX              , IntAry1d (3,0), 3   ,"ManGvdFocalLengthX"               )
     1500    ("SignGvdFocalLengthY_%d"         , m_signGvdFocalLengthY             , BoolAry1d(3,0), 3   ,"SignGvdFocalLengthY"              )
     1501    ("ExpGvdFocalLengthY_%d"          , m_expGvdFocalLengthY              , IntAry1d (3,0), 3   ,"ExpGvdFocalLengthY"               )
     1502    ("ManGvdFocalLengthY_%d"          , m_manGvdFocalLengthY              , IntAry1d (3,0), 3   ,"ManGvdFocalLengthY"               )
     1503    ("SignGvdPrincipalPointX_%d"      , m_signGvdPrincipalPointX          , BoolAry1d(3,0), 3   ,"SignGvdPrincipalPointX"           )
     1504    ("ExpGvdPrincipalPointX_%d"       , m_expGvdPrincipalPointX           , IntAry1d (3,0), 3   ,"ExpGvdPrincipalPointX"            )
     1505    ("ManGvdPrincipalPointX_%d"       , m_manGvdPrincipalPointX           , IntAry1d (3,0), 3   ,"ManGvdPrincipalPointX"            )
     1506    ("SignGvdPrincipalPointY_%d"      , m_signGvdPrincipalPointY          , BoolAry1d(3,0), 3   ,"SignGvdPrincipalPointY"           )
     1507    ("ExpGvdPrincipalPointY_%d"       , m_expGvdPrincipalPointY           , IntAry1d (3,0), 3   ,"ExpGvdPrincipalPointY"            )
     1508    ("ManGvdPrincipalPointY_%d"       , m_manGvdPrincipalPointY           , IntAry1d (3,0), 3   ,"ManGvdPrincipalPointY"            )
     1509    ("SignGvdR00_%d"                  , m_signGvdR00                      , BoolAry1d(3,0), 3   ,"SignGvdR00"                       )
     1510    ("ExpGvdR00_%d"                   , m_expGvdR00                       , IntAry1d (3,0), 3   ,"ExpGvdR00"                        )
     1511    ("ManGvdR00_%d"                   , m_manGvdR00                       , IntAry1d (3,0), 3   ,"ManGvdR00"                        )
     1512    ("SignGvdR01_%d"                  , m_signGvdR01                      , BoolAry1d(3,0), 3   ,"SignGvdR01"                       )
     1513    ("ExpGvdR01_%d"                   , m_expGvdR01                       , IntAry1d (3,0), 3   ,"ExpGvdR01"                        )
     1514    ("ManGvdR01_%d"                   , m_manGvdR01                       , IntAry1d (3,0), 3   ,"ManGvdR01"                        )
     1515    ("SignGvdR02_%d"                  , m_signGvdR02                      , BoolAry1d(3,0), 3   ,"SignGvdR02"                       )
     1516    ("ExpGvdR02_%d"                   , m_expGvdR02                       , IntAry1d (3,0), 3   ,"ExpGvdR02"                        )
     1517    ("ManGvdR02_%d"                   , m_manGvdR02                       , IntAry1d (3,0), 3   ,"ManGvdR02"                        )
     1518    ("SignGvdR10_%d"                  , m_signGvdR10                      , BoolAry1d(3,0), 3   ,"SignGvdR10"                       )
     1519    ("ExpGvdR10_%d"                   , m_expGvdR10                       , IntAry1d (3,0), 3   ,"ExpGvdR10"                        )
     1520    ("ManGvdR10_%d"                   , m_manGvdR10                       , IntAry1d (3,0), 3   ,"ManGvdR10"                        )
     1521    ("SignGvdR11_%d"                  , m_signGvdR11                      , BoolAry1d(3,0), 3   ,"SignGvdR11"                       )
     1522    ("ExpGvdR11_%d"                   , m_expGvdR11                       , IntAry1d (3,0), 3   ,"ExpGvdR11"                        )
     1523    ("ManGvdR11_%d"                   , m_manGvdR11                       , IntAry1d (3,0), 3   ,"ManGvdR11"                        )
     1524    ("SignGvdR12_%d"                  , m_signGvdR12                      , BoolAry1d(3,0), 3   ,"SignGvdR12"                       )
     1525    ("ExpGvdR12_%d"                   , m_expGvdR12                       , IntAry1d (3,0), 3   ,"ExpGvdR12"                        )
     1526    ("ManGvdR12_%d"                   , m_manGvdR12                       , IntAry1d (3,0), 3   ,"ManGvdR12"                        )
     1527    ("SignGvdR20_%d"                  , m_signGvdR20                      , BoolAry1d(3,0), 3   ,"SignGvdR20"                       )
     1528    ("ExpGvdR20_%d"                   , m_expGvdR20                       , IntAry1d (3,0), 3   ,"ExpGvdR20"                        )
     1529    ("ManGvdR20_%d"                   , m_manGvdR20                       , IntAry1d (3,0), 3   ,"ManGvdR20"                        )
     1530    ("SignGvdR21_%d"                  , m_signGvdR21                      , BoolAry1d(3,0), 3   ,"SignGvdR21"                       )
     1531    ("ExpGvdR21_%d"                   , m_expGvdR21                       , IntAry1d (3,0), 3   ,"ExpGvdR21"                        )
     1532    ("ManGvdR21_%d"                   , m_manGvdR21                       , IntAry1d (3,0), 3   ,"ManGvdR21"                        )
     1533    ("SignGvdR22_%d"                  , m_signGvdR22                      , BoolAry1d(3,0), 3   ,"SignGvdR22"                       )
     1534    ("ExpGvdR22_%d"                   , m_expGvdR22                       , IntAry1d (3,0), 3   ,"ExpGvdR22"                        )
     1535    ("ManGvdR22_%d"                   , m_manGvdR22                       , IntAry1d (3,0), 3   ,"ManGvdR22"                        )
     1536    ("SignGvdTX_%d"                   , m_signGvdTX                       , BoolAry1d(3,0), 3   ,"SignGvdTX"                        )
     1537    ("ExpGvdTX_%d"                    , m_expGvdTX                        , IntAry1d (3,0), 3   ,"ExpGvdTX"                         )
     1538    ("ManGvdTX_%d"                    , m_manGvdTX                        , IntAry1d (3,0), 3   ,"ManGvdTX"                         )
     1539    ("MinOffsetXInt"                  , m_minOffsetXInt                   , 0                   , "MinOffsetXInt"                   )
     1540    ("MinOffsetXFrac"                 , m_minOffsetXFrac                  , 0                   , "MinOffsetXFrac"                  )
     1541    ("MaxOffsetXInt"                  , m_maxOffsetXInt                   , 0                   , "MaxOffsetXInt"                   )
     1542    ("MaxOffsetXFrac"                 , m_maxOffsetXFrac                  , 0                   , "MaxOffsetXFrac"                  )
     1543    ("OffsetYPresentFlag"             , m_offsetYPresentFlag              , false               , "OffsetYPresentFlag"              )
     1544    ("MinOffsetYInt"                  , m_minOffsetYInt                   , 0                   , "MinOffsetYInt"                   )
     1545    ("MinOffsetYFrac"                 , m_minOffsetYFrac                  , 0                   , "MinOffsetYFrac"                  )
     1546    ("MaxOffsetYInt"                  , m_maxOffsetYInt                   , 0                   , "MaxOffsetYInt"                   )
     1547    ("MaxOffsetYFrac"                 , m_maxOffsetYFrac                  , 0                   , "MaxOffsetYFrac"                  )
     1548    ("WarpMapSizePresentFlag"         , m_warpMapSizePresentFlag          , false               , "WarpMapSizePresentFlag"          )
     1549    ("WarpMapWidthMinus2"             , m_warpMapWidthMinus2              , 0                   , "WarpMapWidthMinus2"              )
     1550    ("WarpMapHeightMinus2"            , m_warpMapHeightMinus2             , 0                   , "WarpMapHeightMinus2"             )
     1551    ;
     1552
     1553  po::setDefaults(opts);
     1554
     1555  // Parse the cfg file
     1556  po::ErrorReporter err;
     1557  po::parseConfigFile( opts, cfgFile, err );
     1558};
     1559Bool SEIAlternativeDepthInfo::checkCfg( const TComSlice* slice )
     1560{
     1561  // Check config values
     1562  Bool wrongConfig = false;
     1563
     1564
     1565  xCheckCfgRange( wrongConfig, m_alternativeDepthInfoCancelFlag , 0 , 1, "alternative_depth_info_cancel_flag");
     1566  xCheckCfgRange( wrongConfig, m_depthType                      , 0 , 1, "depth_type"                       );
     1567
     1568  xCheckCfgRange( wrongConfig, m_numConstituentViewsGvdMinus1   , 1 , 1, "num_constituent_views_gvd_minus1 "); // 1: 3 views only, cuurent.
     1569  xCheckCfgRange( wrongConfig, m_depthPresentGvdFlag            , 0 , 1, "depth_present_gvd_flag"           );
     1570  xCheckCfgRange( wrongConfig, m_zGvdFlag                       , 0 , 1, "z_gvd_flag"                       );
     1571  xCheckCfgRange( wrongConfig, m_intrinsicParamGvdFlag          , 0 , 1, "intrinsic_param_gvd_flag"         );
     1572  xCheckCfgRange( wrongConfig, m_rotationGvdFlag                , 0 , 1, "rotation_gvd_flag"                );
     1573  xCheckCfgRange( wrongConfig, m_translationGvdFlag             , 0 , 1, "translation_gvd_flag"             );
     1574
     1575  return wrongConfig;
     1576
     1577};
     1578
     1579UInt SEIAlternativeDepthInfo::getManGvdFocalLengthXLen       ( Int i, int j ) const
     1580{
     1581  UInt rval;
     1582  rval = xGetSyntaxElementLen( m_expGvdFocalLengthX[i][j], m_precGvdFocalLength, m_manGvdFocalLengthX[i][j]  );
     1583  if (rval == 0)
     1584    return m_precGvdFocalLength;
     1585  else
     1586    return rval;
     1587};
     1588
     1589UInt SEIAlternativeDepthInfo::getManGvdFocalLengthYLen       ( Int i, int j ) const
     1590{
     1591  UInt rval;
     1592  rval = xGetSyntaxElementLen( m_expGvdFocalLengthY[i][j], m_precGvdFocalLength, m_manGvdFocalLengthY[i][j]  );
     1593  if (rval == 0)
     1594    return m_precGvdFocalLength;
     1595  else
     1596    return rval;
     1597};
     1598
     1599UInt SEIAlternativeDepthInfo::getManGvdPrincipalPointXLen    ( Int i, int j ) const
     1600{
     1601  UInt rval;
     1602  rval = xGetSyntaxElementLen( m_expGvdPrincipalPointX[i][j], m_precGvdPrincipalPoint, m_manGvdPrincipalPointX[i][j]  );
     1603  if (rval == 0)
     1604    return m_precGvdPrincipalPoint;
     1605  else
     1606    return rval;
     1607};
     1608
     1609UInt SEIAlternativeDepthInfo::getManGvdPrincipalPointYLen    ( Int i, int j ) const
     1610{
     1611  UInt rval;
     1612  rval = xGetSyntaxElementLen( m_expGvdPrincipalPointY[i][j], m_precGvdPrincipalPoint, m_manGvdPrincipalPointY[i][j]  );
     1613  if (rval == 0)
     1614    return m_precGvdPrincipalPoint;
     1615  else
     1616    return rval;
     1617};
     1618
     1619UInt SEIAlternativeDepthInfo::getManGvdTXLen                 ( Int i, int j ) const
     1620{
     1621  UInt rval;
     1622  rval = xGetSyntaxElementLen( m_expGvdTX[i][j], m_precGvdTranslationParam, m_manGvdTX[i][j]  );
     1623  if (rval == 0)
     1624    return m_precGvdTranslationParam;
     1625  else
     1626    return rval;
     1627};
     1628
     1629UInt SEIAlternativeDepthInfo::xGetSyntaxElementLen( Int expo, Int prec, Int val ) const
     1630{
     1631  UInt len;
     1632  if( expo == 0 )
     1633  {
     1634    len = std::max(0, prec - 30 );
     1635  }
     1636  else
     1637  {
     1638    len = std::max( 0, expo + prec - 31 );
     1639  }
     1640
     1641  assert( val >= 0 );
     1642  assert( val <= ( ( 1 << len )- 1) );
     1643  return len;
     1644}
     1645
     1646#endif
     1647
     1648#endif
Note: See TracChangeset for help on using the changeset viewer.