source: 3DVCSoftware/branches/HTM-16.0-MV-draft-5/source/Lib/TLibCommon/SEI.cpp

Last change on this file was 1390, checked in by tech, 9 years ago

Removed 3D.

File size: 69.1 KB
Line 
1/* The copyright in this software is being made available under the BSD
2 * License, included below. This software may be subject to other third party
3 * and contributor rights, including patent rights, and no such rights are
4 * granted under this license.
5 *
6 * Copyright (c) 2010-2015, ITU/ISO/IEC
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions are met:
11 *
12 *  * Redistributions of source code must retain the above copyright notice,
13 *    this list of conditions and the following disclaimer.
14 *  * Redistributions in binary form must reproduce the above copyright notice,
15 *    this list of conditions and the following disclaimer in the documentation
16 *    and/or other materials provided with the distribution.
17 *  * Neither the name of the ITU/ISO/IEC nor the names of its contributors may
18 *    be used to endorse or promote products derived from this software without
19 *    specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
25 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
31 * THE POSSIBILITY OF SUCH DAMAGE.
32 */
33
34/** \file     SEI.cpp
35    \brief    helper functions for SEI handling
36*/
37
38#include "CommonDef.h"
39#include "SEI.h"
40#if NH_MV
41#include "TComSlice.h"
42#endif
43
44SEIMessages getSeisByType(SEIMessages &seiList, SEI::PayloadType seiType)
45{
46  SEIMessages result;
47
48  for (SEIMessages::iterator it=seiList.begin(); it!=seiList.end(); it++)
49  {
50    if ((*it)->payloadType() == seiType)
51    {
52      result.push_back(*it);
53    }
54  }
55  return result;
56}
57
58SEIMessages extractSeisByType(SEIMessages &seiList, SEI::PayloadType seiType)
59{
60  SEIMessages result;
61
62  SEIMessages::iterator it=seiList.begin();
63  while ( it!=seiList.end() )
64  {
65    if ((*it)->payloadType() == seiType)
66    {
67      result.push_back(*it);
68      it = seiList.erase(it);
69    }
70    else
71    {
72      it++;
73    }
74  }
75  return result;
76}
77
78
79Void deleteSEIs (SEIMessages &seiList)
80{
81  for (SEIMessages::iterator it=seiList.begin(); it!=seiList.end(); it++)
82  {
83    delete (*it);
84  }
85  seiList.clear();
86}
87
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}
118
119// Static member
120const TChar *SEI::getSEIMessageString(SEI::PayloadType payloadType)
121{
122  switch (payloadType)
123  {
124    case SEI::BUFFERING_PERIOD:                     return "Buffering period";
125    case SEI::PICTURE_TIMING:                       return "Picture timing";
126    case SEI::PAN_SCAN_RECT:                        return "Pan-scan rectangle";                   // not currently decoded
127    case SEI::FILLER_PAYLOAD:                       return "Filler payload";                       // not currently decoded
128    case SEI::USER_DATA_REGISTERED_ITU_T_T35:       return "User data registered";                 // not currently decoded
129    case SEI::USER_DATA_UNREGISTERED:               return "User data unregistered";
130    case SEI::RECOVERY_POINT:                       return "Recovery point";
131    case SEI::SCENE_INFO:                           return "Scene information";                    // not currently decoded
132    case SEI::FULL_FRAME_SNAPSHOT:                  return "Picture snapshot";                     // not currently decoded
133    case SEI::PROGRESSIVE_REFINEMENT_SEGMENT_START: return "Progressive refinement segment start"; // not currently decoded
134    case SEI::PROGRESSIVE_REFINEMENT_SEGMENT_END:   return "Progressive refinement segment end";   // not currently decoded
135    case SEI::FILM_GRAIN_CHARACTERISTICS:           return "Film grain characteristics";           // not currently decoded
136    case SEI::POST_FILTER_HINT:                     return "Post filter hint";                     // not currently decoded
137    case SEI::TONE_MAPPING_INFO:                    return "Tone mapping information";
138    case SEI::KNEE_FUNCTION_INFO:                   return "Knee function information";
139    case SEI::FRAME_PACKING:                        return "Frame packing arrangement";
140    case SEI::DISPLAY_ORIENTATION:                  return "Display orientation";
141    case SEI::SOP_DESCRIPTION:                      return "Structure of pictures information";
142    case SEI::ACTIVE_PARAMETER_SETS:                return "Active parameter sets";
143    case SEI::DECODING_UNIT_INFO:                   return "Decoding unit information";
144    case SEI::TEMPORAL_LEVEL0_INDEX:                return "Temporal sub-layer zero index";
145    case SEI::DECODED_PICTURE_HASH:                 return "Decoded picture hash";
146    case SEI::SCALABLE_NESTING:                     return "Scalable nesting";
147    case SEI::REGION_REFRESH_INFO:                  return "Region refresh information";
148    case SEI::NO_DISPLAY:                           return "No display";
149    case SEI::TIME_CODE:                            return "Time code";
150    case SEI::MASTERING_DISPLAY_COLOUR_VOLUME:      return "Mastering display colour volume";
151    case SEI::SEGM_RECT_FRAME_PACKING:              return "Segmented rectangular frame packing arrangement";
152    case SEI::TEMP_MOTION_CONSTRAINED_TILE_SETS:    return "Temporal motion constrained tile sets";
153    case SEI::CHROMA_RESAMPLING_FILTER_HINT:        return "Chroma sampling filter hint";
154    case SEI::COLOUR_REMAPPING_INFO:                return "Colour remapping info";
155
156#if NH_MV
157    case SEI::DEINTERLACED_FIELD_IDENTIFICATION:         return "Deinterlaced field identification";
158    case SEI::LAYERS_NOT_PRESENT:                        return "Layers not present";
159    case SEI::INTER_LAYER_CONSTRAINED_TILE_SETS:         return "Inter-layer constrained tile sets";
160    case SEI::BSP_NESTING:                               return "Bitstream partition nesting";
161    case SEI::BSP_INITIAL_ARRIVAL_TIME:                  return "Bitstream partition initial arrival time";
162    case SEI::SUB_BITSTREAM_PROPERTY:                    return "Sub-bitstream property";
163    case SEI::ALPHA_CHANNEL_INFO:                        return "Alpha channel information";
164    case SEI::OVERLAY_INFO:                              return "Overlay information"  ;
165    case SEI::TEMPORAL_MV_PREDICTION_CONSTRAINTS:        return "Temporal motion vector prediction constraints";
166    case SEI::FRAME_FIELD_INFO:                          return "Frame-field information";
167    case SEI::THREE_DIMENSIONAL_REFERENCE_DISPLAYS_INFO: return "3D reference displays information";
168    case SEI::DEPTH_REPRESENTATION_INFO:                 return "Depth representation information";
169    case SEI::MULTIVIEW_SCENE_INFO:                      return "Multiview scene information";
170    case SEI::MULTIVIEW_ACQUISITION_INFO:                return "Multiview acquisition information";
171    case SEI::MULTIVIEW_VIEW_POSITION:                   return "Multiview view position";
172#endif
173    default:                                        return "Unknown";
174  }
175}
176
177#if NH_MV
178SEI::SEI()
179{
180  m_scalNestSeiContThisSei = NULL;
181}
182
183SEI* SEI::getNewSEIMessage(SEI::PayloadType payloadType)
184{
185  switch (payloadType)
186  {
187#if NH_MV_SEI_TBD
188    //////////////////////////////////////////////////////////////////////////
189    // TBD: Modify version 1 SEIs to use the same interfaces as Annex GFI SEI messages.
190    //////////////////////////////////////////////////////////////////////////
191
192    case SEI::BUFFERING_PERIOD:                     return new SEIBufferingPeriod;
193    case SEI::PICTURE_TIMING:                       return new SEIPictureTiming;
194    case SEI::PAN_SCAN_RECT:                        return new SEIPanScanRectangle;                    // not currently decoded
195    case SEI::FILLER_PAYLOAD:                       return new SEIFillerPaylod;                       // not currently decoded
196    case SEI::USER_DATA_REGISTERED_ITU_T_T35:       return new SEIUserDataRegistered;                 // not currently decoded
197    case SEI::USER_DATA_UNREGISTERED:               return new SEIuserDataUnregistered;
198    case SEI::RECOVERY_POINT:                       return new SEIRecoveryPoint;
199    case SEI::SCENE_INFO:                           return new SEISceneInformation;                    // not currently decoded
200    case SEI::FULL_FRAME_SNAPSHOT:                  return new SEIPictureSnapshot;                     // not currently decoded
201    case SEI::PROGRESSIVE_REFINEMENT_SEGMENT_START: return new SEIProgressiveRefinementSegmentStart;   // not currently decoded
202    case SEI::PROGRESSIVE_REFINEMENT_SEGMENT_END:   return new SEIProgressiveRefinementSegmentEnd;     // not currently decoded
203    case SEI::FILM_GRAIN_CHARACTERISTICS:           return new SEIFilmGrainCharacteristics;            // not currently decoded
204    case SEI::POST_FILTER_HINT:                     return new SEIPostFilterHint;                      // not currently decoded
205    case SEI::TONE_MAPPING_INFO:                    return new SEIToneMappingInfo;
206    case SEI::KNEE_FUNCTION_INFO:                   return new SEIKneeFunctionInfo;
207    case SEI::FRAME_PACKING:                        return new SEIFramePacking;
208    case SEI::DISPLAY_ORIENTATION:                  return new SEIDisplayOrientation;
209    case SEI::SOP_DESCRIPTION:                      return new SEISOPDescription;
210    case SEI::ACTIVE_PARAMETER_SETS:                return new SEIActiveParameterSets;
211    case SEI::DECODING_UNIT_INFO:                   return new SEIDecodingUnitInfo;
212    case SEI::TEMPORAL_LEVEL0_INDEX:                return new SEITemporalLevel0Index
213    case SEI::DECODED_PICTURE_HASH:                 return new SEIDecodedPictureHash;
214    case SEI::SCALABLE_NESTING:                     return new SEIScalableNesting;
215    case SEI::REGION_REFRESH_INFO:                  return new SEIRegionRefreshInfo;
216    case SEI::NO_DISPLAY:                           return new SEINoDisplay;
217    case SEI::TIME_CODE:                            return new SEITimeCode;
218    case SEI::MASTERING_DISPLAY_COLOUR_VOLUME:      return new SEIMasteringDisplayColourVolume;
219    case SEI::SEGM_RECT_FRAME_PACKING:              return new SEISegmentedRectFramePacking;
220    case SEI::TEMP_MOTION_CONSTRAINED_TILE_SETS:    return new SEITempMotionConstrainedTileSets;
221    case SEI::CHROMA_SAMPLING_FILTER_HINT:          return new SEIChromaSamplingFilterHint
222#endif
223  case SEI::LAYERS_NOT_PRESENT                    :               return new SEILayersNotPresent;
224  case SEI::INTER_LAYER_CONSTRAINED_TILE_SETS     :               return new SEIInterLayerConstrainedTileSets;
225#if NH_MV_SEI_TBD
226  case SEI::BSP_NESTING                           :               return new SEIBspNesting;
227  case SEI::BSP_INITIAL_ARRIVAL_TIME              :               return new SEIBspInitialArrivalTime;
228#endif
229  case SEI::SUB_BITSTREAM_PROPERTY                :               return new SEISubBitstreamProperty;
230  case SEI::ALPHA_CHANNEL_INFO                    :               return new SEIAlphaChannelInfo;
231  case SEI::OVERLAY_INFO                          :               return new SEIOverlayInfo;
232  case SEI::TEMPORAL_MV_PREDICTION_CONSTRAINTS    :               return new SEITemporalMvPredictionConstraints;
233#if NH_MV_SEI_TBD
234  case SEI::FRAME_FIELD_INFO                      :               return new SEIFrameFieldInfo;
235#endif
236  case SEI::THREE_DIMENSIONAL_REFERENCE_DISPLAYS_INFO:            return new SEIThreeDimensionalReferenceDisplaysInfo;
237  case SEI::DEPTH_REPRESENTATION_INFO             :               return new SEIDepthRepresentationInfo;
238  case SEI::MULTIVIEW_SCENE_INFO                  :               return new SEIMultiviewSceneInfo;
239  case SEI::MULTIVIEW_ACQUISITION_INFO            :               return new SEIMultiviewAcquisitionInfo;
240  case SEI::MULTIVIEW_VIEW_POSITION               :               return new SEIMultiviewViewPosition;
241  default:                                        assert( false ); return NULL;
242  }
243}
244
245Void SEI::setupFromSlice  ( const TComSlice* slice )
246{
247  xPrintCfgErrorIntro();
248  std::cout << getSEIMessageString( payloadType() ) << "Setup by the encoder is currently not possible. Using the default SEI cfg-file." << std::endl;
249}
250
251SEI* SEI::getCopy() const
252{
253  assert( 0 );
254  return NULL;
255}
256
257Void SEI::setupFromCfgFile( const TChar* cfgFile )
258{
259  assert( false );
260}
261
262Bool SEI::insertSei( Int curLayerId, Int curPoc, Int curTid, Int curNaluType ) const
263{
264  Bool insertSeiHere = true;
265  if( !m_applicableLayerIds.empty() )
266  {
267    insertSeiHere = insertSeiHere && ( std::find( m_applicableLayerIds.begin(), m_applicableLayerIds.end(), curLayerId) != m_applicableLayerIds.end() ) ;
268  }
269  if( !m_applicablePocs     .empty() )
270  {
271    insertSeiHere = insertSeiHere && ( std::find( m_applicablePocs    .begin(), m_applicablePocs    .end(), curPoc    ) != m_applicablePocs    .end() ) ;
272  }
273  if( !m_applicableTids     .empty() )
274  {
275    insertSeiHere = insertSeiHere && ( std::find( m_applicableTids    .begin(), m_applicableTids    .end(), curTid    ) != m_applicableTids    .end() ) ;
276  }
277  if( !m_applicableVclNaluTypes.empty() )
278  {
279    insertSeiHere = insertSeiHere && ( std::find( m_applicableVclNaluTypes.begin(), m_applicableVclNaluTypes.end(), curNaluType) != m_applicableVclNaluTypes.end() ) ;
280  }
281  return insertSeiHere;
282}
283
284Bool SEI::checkCfg( const TComSlice* slice )
285{
286  assert( false );
287  return true;
288}
289
290Void SEI::xPrintCfgErrorIntro()
291{
292  std::cout << "Error in configuration of " << getSEIMessageString( payloadType() ) << " SEI: ";
293}
294
295Void SEI::xCheckCfgRange( Bool& wrongConfig, Int val, Int minVal, Int maxVal, const TChar* seName )
296{
297  if ( val < minVal || val > maxVal  )
298  {
299    xPrintCfgErrorIntro();
300    std::cout << "The value of " << seName << "shall be in the range of " << minVal << " to " << maxVal << ", inclusive." << std::endl;
301    wrongConfig = true;
302  }
303}
304
305Void SEI::xAddGeneralOpts(po::Options &opts, IntAry1d defAppLayerIds, IntAry1d deftApplicablePocs,
306                                            IntAry1d defAppTids,     IntAry1d defAppVclNaluTypes,
307                                            Int defSeiNaluId, Int defPositionInSeiNalu, Bool defModifyByEncoder)
308{
309  opts.addOptions()
310    ("PayloadType"            , m_payloadType            , -1                    , "Payload Type"                                                         )
311    ("ApplicableLayerIds"     , m_applicableLayerIds     , defAppLayerIds        , "LayerIds      of layers   to which the SEI is added. (all when empty)")
312    ("ApplicablePocs"         , m_applicablePocs         , deftApplicablePocs    , "POCs          of pictures to which the SEI is added. (all when empty)")
313    ("ApplicableTids"         , m_applicableTids         , defAppTids            , "TIds          of pictures to which the SEI is added. (all when empty)")
314    ("ApplicableVclNaluTypes" , m_applicableVclNaluTypes , defAppVclNaluTypes    , "NaluUnitTypes of picture  to which the SEI is added. (all when empty)")
315    ("SeiNaluId"              , m_seiNaluId              , defSeiNaluId          , "Identifies to which NAL unit  the SEI is added." )
316    ("PositionInSeiNalu"      , m_positionInSeiNalu      , defPositionInSeiNalu  , "Identifies the position within the NAL unit.")
317    ("ModifyByEncoder"        , m_modifyByEncoder        , defModifyByEncoder    , "0: Use payload as specified in cfg file   1: Modify SEI by encoder");
318}
319
320Void SEI::xCheckCfg( Bool& wrongConfig, Bool cond, const TChar* errStr )
321{
322  if ( !cond  )
323  {
324    xPrintCfgErrorIntro();
325    std::cout << errStr << std::endl;
326    wrongConfig = true;
327  }
328}
329
330Void SEILayersNotPresent::setupFromCfgFile(const TChar* cfgFile)
331{
332  // Set default values
333  IntAry1d defAppLayerIds, defAppPocs, defAppTids, defAppVclNaluTypes;
334
335  // TBD: Add default values for which layers, POCS, Tids or Nalu types the SEI should be send.
336  // 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.
337  defAppLayerIds    .empty( );
338  defAppPocs        .empty( );
339  defAppTids        .empty( );
340  defAppVclNaluTypes.empty( );
341
342  Int      defSeiNaluId                  = 0;
343  Int      defPositionInSeiNalu          = 0;
344  Bool     defModifyByEncoder            = false;   //0: Use payload as specified in cfg file   1: Modify SEI by encoder
345
346  // Setup config file options
347  po::Options opts;
348  xAddGeneralOpts( opts , defAppLayerIds, defAppPocs, defAppTids, defAppVclNaluTypes, defSeiNaluId, defPositionInSeiNalu, defModifyByEncoder );
349
350  opts.addOptions()
351    ("LnpSeiActiveVpsId"              , m_lnpSeiActiveVpsId                , 0                              , "LnpSeiActiveVpsId"                )   //Why?
352    ("LayerNotPresentFlag"            , m_layerNotPresentFlag              , BoolAry1d(1,0)                 , "LayerNotPresentFlag"              )
353    ;
354
355  po::setDefaults(opts);
356
357  // Parse the cfg file
358  po::ErrorReporter err;
359  po::parseConfigFile( opts, cfgFile, err );
360  m_lnpSeiMaxLayers = (UInt) m_layerNotPresentFlag.size();
361};
362
363  Bool SEILayersNotPresent::checkCfg( const TComSlice* slice )
364  {
365  // Check config values
366    Bool wrongConfig = false;
367//
368    const TComVPS* vps = slice->getVPS();
369//  // TBD: Add constraints on presence of SEI here.
370    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." );
371    xCheckCfg     ( wrongConfig, m_lnpSeiMaxLayers == vps->getMaxLayersMinus1(), "The number of LayerNotPresent flags shall be equal to vpsMaxLayersMinus1." );
372
373
374    for (Int i = 0; i < vps->getMaxLayersMinus1(); i++)
375    {
376      if ( m_layerNotPresentFlag[ i ] && i < vps->getMaxLayersMinus1() )
377      {
378        for (Int j = 0; j < vps->getNumPredictedLayers( vps->getLayerIdInNuh( j ) - 1 ); j++ )
379        {
380          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." );
381        }
382      }
383    }
384
385      return wrongConfig;
386  };
387
388
389
390Void SEIInterLayerConstrainedTileSets::setupFromCfgFile(const TChar* cfgFile)
391{
392  // Set default values
393  IntAry1d defAppLayerIds, defAppPocs, defAppTids, defAppVclNaluTypes;
394
395  // TBD: Add default values for which layers, POCS, Tids or Nalu types the SEI should be send.
396  defAppLayerIds    .empty( );
397  defAppPocs        .push_back( 0 );
398  defAppTids        .empty( );
399  defAppVclNaluTypes.empty( );
400
401  Int      defSeiNaluId                  = 0;
402  Int      defPositionInSeiNalu          = 0;
403  Bool     defModifyByEncoder            = false;
404
405  // Setup config file options
406  po::Options opts;
407  xAddGeneralOpts( opts , defAppLayerIds, defAppPocs, defAppTids, defAppVclNaluTypes, defSeiNaluId, defPositionInSeiNalu, defModifyByEncoder );
408
409  const Int maxNumTileInSet = 100;
410
411  opts.addOptions()
412    ("IlAllTilesExactSampleValueMatchFlag", m_ilAllTilesExactSampleValueMatchFlag, false                    , "IlAllTilesExactSampleValueMatchFlag")
413    ("IlOneTilePerTileSetFlag"        , m_ilOneTilePerTileSetFlag          , false                          , "IlOneTilePerTileSetFlag"          )
414    ("IlNumSetsInMessageMinus1"       , m_ilNumSetsInMessageMinus1         , 0                              , "IlNumSetsInMessageMinus1"         )
415    ("SkippedTileSetPresentFlag"      , m_skippedTileSetPresentFlag        , false                          , "SkippedTileSetPresentFlag"        )
416    ("IlctsId"                        , m_ilctsId                          , IntAry1d (256,0)               , "IlctsId"                          )
417    ("IlNumTileRectsInSetMinus1"      , m_ilNumTileRectsInSetMinus1        , IntAry1d (256,0)               , "IlNumTileRectsInSetMinus1"        )
418    ("IlTopLeftTileIndex_%d"          , m_ilTopLeftTileIndex               , IntAry1d (maxNumTileInSet,0), 256, "IlTopLeftTileIndex"               )
419    ("IlBottomRightTileIndex_%d"      , m_ilBottomRightTileIndex           , IntAry1d (maxNumTileInSet,0), 256, "IlBottomRightTileIndex"           )
420    ("IlcIdc"                         , m_ilcIdc                           , IntAry1d (256,0)               , "IlcIdc"                           )
421    ("IlExactSampleValueMatchFlag"    , m_ilExactSampleValueMatchFlag      , BoolAry1d(256,0)               , "IlExactSampleValueMatchFlag"      )
422    ("AllTilesIlcIdc"                 , m_allTilesIlcIdc                   , 0                              , "AllTilesIlcIdc"                   )
423    ;
424
425  po::setDefaults(opts);
426
427  // Parse the cfg file
428  po::ErrorReporter err;
429  po::parseConfigFile( opts, cfgFile, err );
430};
431
432Bool SEIInterLayerConstrainedTileSets::checkCfg( const TComSlice* slice )
433{
434  // Check config values
435  Bool wrongConfig = false;
436  const TComPPS* pps = slice->getPPS();
437
438  // Currently only the active PPS checked.
439  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." );
440
441  if ( m_ilOneTilePerTileSetFlag )
442  {
443    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."    );
444  }
445  Int numSignificantSets = m_ilNumSetsInMessageMinus1 - m_skippedTileSetPresentFlag + 1;
446
447  for (Int i = 0 ; i < numSignificantSets; i++)
448  {
449    xCheckCfgRange( wrongConfig, m_ilctsId[i]                         , 0 , (1 << 30) - 1, "ilcts_id"                         );
450  }
451
452  return wrongConfig;
453};
454#if NH_MV_SEI_TBD
455
456Void SEIBspNesting::setupFromSlice  ( const TComSlice* slice )
457{
458  sei.m_seiOlsIdx =  TBD ;
459  sei.m_seiPartitioningSchemeIdx =  TBD ;
460  sei.m_bspIdx =  TBD ;
461  while( !ByteaLigned(() ) );
462  {
463    sei.m_bspNestingZeroBit =  TBD ;
464  }
465  sei.m_numSeisInBspMinus1 =  TBD ;
466  for( Int i = 0; i  <=  NumSeisInBspMinus1( ); i++ )
467  {
468    SeiMessage(() );
469  }
470};
471
472Void SEIBspNesting::setupFromCfgFile(const TChar* cfgFile)
473{
474  // Set default values
475  IntAry1d defAppLayerIds, defAppPocs, defAppTids, defAppVclNaluTypes;
476
477  // TBD: Add default values for which layers, POCS, Tids or Nalu types the SEI should be send.
478  defAppLayerIds    .push_back( TBD );
479  defAppPocs        .push_back( TBD );
480  defAppTids        .push_back( TBD );
481  defAppVclNaluTypes.push_back( TBD );
482
483  Int      defSeiNaluId                  = 0;
484  Int      defPositionInSeiNalu          = 0;
485  Bool     defModifyByEncoder            = TBD;
486
487  // Setup config file options
488  po::Options opts;
489  xAddGeneralOpts( opts , defAppLayerIds, defAppPocs, defAppTids, defAppVclNaluTypes, defSeiNaluId, defPositionInSeiNalu, defModifyByEncoder );
490
491  opts.addOptions()
492    ("SeiOlsIdx"                      , m_seiOlsIdx                        , 0                              , "SeiOlsIdx"                        )
493    ("SeiPartitioningSchemeIdx"       , m_seiPartitioningSchemeIdx         , 0                              , "SeiPartitioningSchemeIdx"         )
494    ("BspIdx"                         , m_bspIdx                           , 0                              , "BspIdx"                           )
495    ("BspNestingZeroBit"              , m_bspNestingZeroBit                , 0                              , "BspNestingZeroBit"                )
496    ("NumSeisInBspMinus1"             , m_numSeisInBspMinus1               , 0                              , "NumSeisInBspMinus1"               )
497    ;
498
499  po::setDefaults(opts);
500
501  // Parse the cfg file
502  po::ErrorReporter err;
503  po::parseConfigFile( opts, cfgFile, err );
504};
505
506Bool SEIBspNesting::checkCfg( const TComSlice* slice )
507{
508  // Check config values
509  Bool wrongConfig = false;
510
511  // TBD: Add constraints on presence of SEI here.
512  xCheckCfg     ( wrongConfig, TBD , "TBD" );
513  xCheckCfg     ( wrongConfig, TBD , "TBD" );
514
515  // TBD: Modify constraints according to the SEI semantics.
516  xCheckCfgRange( wrongConfig, m_seiOlsIdx                      , MINVAL , MAXVAL, "sei_ols_idx"          );
517  xCheckCfgRange( wrongConfig, m_seiPartitioningSchemeIdx       , MINVAL , MAXVAL, "sei_partitioning_scheme_idx"       );
518  xCheckCfgRange( wrongConfig, m_bspIdx                         , MINVAL , MAXVAL, "bsp_idx"              );
519  xCheckCfgRange( wrongConfig, m_bspNestingZeroBit              , MINVAL , MAXVAL, "bsp_nesting_zero_bit ");
520  xCheckCfgRange( wrongConfig, m_numSeisInBspMinus1             , MINVAL , MAXVAL, "num_seis_in_bsp_minus1"           );
521
522  return wrongConfig;
523
524};
525
526Void SEIBspInitialArrivalTime::setupFromSlice  ( const TComSlice* slice )
527{
528  psIdx = SeiPartitioningSchemeIdx();
529  if( nalInitialArrivalDelayPresent )
530  {
531    for( Int i = 0; i < BspSchedCnt( SeiOlsIdx(), psIdx, MaxTemporalId( 0 ) ); i++ )
532    {
533      sei.m_nalInitialArrivalDelay[i] =  TBD ;
534    }
535  }
536  if( vclInitialArrivalDelayPresent )
537  {
538    for( Int i = 0; i < BspSchedCnt( SeiOlsIdx(), psIdx, MaxTemporalId( 0 ) ); i++ )
539    {
540      sei.m_vclInitialArrivalDelay[i] =  TBD ;
541    }
542  }
543};
544
545Void SEIBspInitialArrivalTime::setupFromCfgFile(const TChar* cfgFile)
546{
547  // Set default values
548  IntAry1d defAppLayerIds, defAppPocs, defAppTids, defAppVclNaluTypes;
549
550  // TBD: Add default values for which layers, POCS, Tids or Nalu types the SEI should be send.
551  defAppLayerIds    .push_back( TBD );
552  defAppPocs        .push_back( TBD );
553  defAppTids        .push_back( TBD );
554  defAppVclNaluTypes.push_back( TBD );
555
556  Int      defSeiNaluId                  = 0;
557  Int      defPositionInSeiNalu          = 0;
558  Bool     defModifyByEncoder            = TBD;
559
560  // Setup config file options
561  po::Options opts;
562  xAddGeneralOpts( opts , defAppLayerIds, defAppPocs, defAppTids, defAppVclNaluTypes, defSeiNaluId, defPositionInSeiNalu, defModifyByEncoder );
563
564  opts.addOptions()
565    ("NalInitialArrivalDelay"         , m_nalInitialArrivalDelay           , IntAry1d (1,0)                 , "NalInitialArrivalDelay"           )
566    ("VclInitialArrivalDelay"         , m_vclInitialArrivalDelay           , IntAry1d (1,0)                 , "VclInitialArrivalDelay"           )
567    ;
568
569  po::setDefaults(opts);
570
571  // Parse the cfg file
572  po::ErrorReporter err;
573  po::parseConfigFile( opts, cfgFile, err );
574};
575
576Bool SEIBspInitialArrivalTime::checkCfg( const TComSlice* slice )
577{
578  // Check config values
579  Bool wrongConfig = false;
580
581  // TBD: Add constraints on presence of SEI here.
582  xCheckCfg     ( wrongConfig, TBD , "TBD" );
583  xCheckCfg     ( wrongConfig, TBD , "TBD" );
584
585  // TBD: Modify constraints according to the SEI semantics.
586  xCheckCfgRange( wrongConfig, m_nalInitialArrivalDelay[i]      , MINVAL , MAXVAL, "nal_initial_arrival_delay"        );
587  xCheckCfgRange( wrongConfig, m_vclInitialArrivalDelay[i]      , MINVAL , MAXVAL, "vcl_initial_arrival_delay"        );
588
589  return wrongConfig;
590
591};
592#endif
593
594Void SEISubBitstreamProperty::setupFromCfgFile(const TChar* cfgFile)
595{
596  // Set default values
597  IntAry1d defAppLayerIds, defAppPocs, defAppTids, defAppVclNaluTypes;
598
599  // TBD: Add default values for which layers, POCS, Tids or Nalu types the SEI should be send.
600  defAppLayerIds    .push_back( 0 );
601  defAppPocs        .push_back( 0 );
602  defAppTids        .push_back( 0 );
603  defAppVclNaluTypes = IRAP_NAL_UNIT_TYPES;
604
605  Int      defSeiNaluId                  = 0;
606  Int      defPositionInSeiNalu          = 0;
607  Bool     defModifyByEncoder            = false;
608
609  // Setup config file options
610  po::Options opts;
611  xAddGeneralOpts( opts , defAppLayerIds, defAppPocs, defAppTids, defAppVclNaluTypes, defSeiNaluId, defPositionInSeiNalu, defModifyByEncoder );
612
613  opts.addOptions()
614    ("SbPropertyActiveVpsId"          , m_sbPropertyActiveVpsId            , 0                              , "SbPropertyActiveVpsId"            )
615    ("NumAdditionalSubStreamsMinus1"  , m_numAdditionalSubStreamsMinus1    , 0                              , "NumAdditionalSubStreamsMinus1"    )
616    ("SubBitstreamMode"               , m_subBitstreamMode                 , IntAry1d (1,0)                 , "SubBitstreamMode"                 )
617    ("OlsIdxToVps"                    , m_olsIdxToVps                      , IntAry1d (1,0)                 , "OlsIdxToVps"                      )
618    ("HighestSublayerId"              , m_highestSublayerId                , IntAry1d (1,0)                 , "HighestSublayerId"                )
619    ("AvgSbPropertyBitRate"           , m_avgSbPropertyBitRate             , IntAry1d (1,0)                 , "AvgSbPropertyBitRate"             )
620    ("MaxSbPropertyBitRate"           , m_maxSbPropertyBitRate             , IntAry1d (1,0)                 , "MaxSbPropertyBitRate"             )
621    ;
622
623  po::setDefaults(opts);
624
625  // Parse the cfg file
626  po::ErrorReporter err;
627  po::parseConfigFile( opts, cfgFile, err );
628};
629
630Bool SEISubBitstreamProperty::checkCfg( const TComSlice* slice )
631{
632  // Check config values
633  Bool wrongConfig = false;
634
635  // For the current encoder, the initial IRAP access unit has always POC zero.
636  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.");
637
638  Bool sizeNotCorrect =
639    (    ( m_numAdditionalSubStreamsMinus1 + 1 ) != m_subBitstreamMode    .size() )
640    || ( ( m_numAdditionalSubStreamsMinus1 + 1 ) != m_olsIdxToVps         .size() )
641    || ( ( m_numAdditionalSubStreamsMinus1 + 1 ) != m_highestSublayerId   .size() )
642    || ( ( m_numAdditionalSubStreamsMinus1 + 1 ) != m_avgSbPropertyBitRate.size() )
643    || ( ( m_numAdditionalSubStreamsMinus1 + 1 ) != m_maxSbPropertyBitRate.size() );
644
645  xCheckCfg( wrongConfig, !sizeNotCorrect, "Some parameters of some sub-bitstream not provided." );
646  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." );
647
648  xCheckCfgRange( wrongConfig, m_numAdditionalSubStreamsMinus1  , 0 , (1 << 10) - 1 , "num_additional_sub_streams_minus1");
649
650  if ( !sizeNotCorrect )
651  {
652    for (Int i = 0; i <= m_numAdditionalSubStreamsMinus1; i++ )
653    {
654      xCheckCfgRange( wrongConfig, m_subBitstreamMode[i]    , 0 , 1                                          , "sub_bitstream_mode" );
655      xCheckCfgRange( wrongConfig, m_olsIdxToVps[i]         , 0 , slice->getVPS()->getNumOutputLayerSets()-1 , "ols_idx_to_vps"     );
656    }
657  }
658  return wrongConfig;
659};
660
661Void SEISubBitstreamProperty::resizeArrays( )
662{
663  m_subBitstreamMode    .resize( m_numAdditionalSubStreamsMinus1 + 1);
664  m_olsIdxToVps         .resize( m_numAdditionalSubStreamsMinus1 + 1);
665  m_highestSublayerId   .resize( m_numAdditionalSubStreamsMinus1 + 1);
666  m_avgSbPropertyBitRate.resize( m_numAdditionalSubStreamsMinus1 + 1);
667  m_maxSbPropertyBitRate.resize( m_numAdditionalSubStreamsMinus1 + 1);
668}
669
670Void SEIAlphaChannelInfo::setupFromCfgFile(const TChar* cfgFile)
671{
672  // Set default values
673  IntAry1d defAppLayerIds, defAppPocs, defAppTids, defAppVclNaluTypes;
674
675  // TBD: Add default values for which layers, POCS, Tids or Nalu types the SEI should be send.
676  defAppLayerIds    .clear();
677  defAppPocs        .push_back( 0 );
678  defAppTids        .push_back( 0 );
679  defAppVclNaluTypes = IDR_NAL_UNIT_TYPES;
680
681  Int      defSeiNaluId                  = 0;
682  Int      defPositionInSeiNalu          = 0;
683  Bool     defModifyByEncoder            = false;
684
685  // Setup config file options
686  po::Options opts;
687  xAddGeneralOpts( opts , defAppLayerIds, defAppPocs, defAppTids, defAppVclNaluTypes, defSeiNaluId, defPositionInSeiNalu, defModifyByEncoder );
688
689  opts.addOptions()
690    ("AlphaChannelCancelFlag"         , m_alphaChannelCancelFlag           , false                          , "AlphaChannelCancelFlag"           )
691    ("AlphaChannelUseIdc"             , m_alphaChannelUseIdc               , 0                              , "AlphaChannelUseIdc"               )
692    ("AlphaChannelBitDepthMinus8"     , m_alphaChannelBitDepthMinus8       , 0                              , "AlphaChannelBitDepthMinus8"       )
693    ("AlphaTransparentValue"          , m_alphaTransparentValue            , 0                              , "AlphaTransparentValue"            )
694    ("AlphaOpaqueValue"               , m_alphaOpaqueValue                 , 255                            , "AlphaOpaqueValue"                 )
695    ("AlphaChannelIncrFlag"           , m_alphaChannelIncrFlag             , false                          , "AlphaChannelIncrFlag"             )
696    ("AlphaChannelClipFlag"           , m_alphaChannelClipFlag             , false                          , "AlphaChannelClipFlag"             )
697    ("AlphaChannelClipTypeFlag"       , m_alphaChannelClipTypeFlag         , false                          , "AlphaChannelClipTypeFlag"         )
698    ;
699
700  po::setDefaults(opts);
701
702  // Parse the cfg file
703  po::ErrorReporter err;
704  po::parseConfigFile( opts, cfgFile, err );
705
706};
707
708Bool SEIAlphaChannelInfo::checkCfg( const TComSlice* slice )
709{
710  // Check config values
711  Bool wrongConfig = false;
712
713  int maxInterpretationValue = (1 << (m_alphaChannelBitDepthMinus8+9)) - 1;
714  xCheckCfgRange( wrongConfig, m_alphaChannelCancelFlag         , 0 , 1, "alpha_channel_cancel_flag"        );
715  xCheckCfgRange( wrongConfig, m_alphaChannelUseIdc             , 0 , 7, "alpha_channel_use_idc");
716  xCheckCfgRange( wrongConfig, m_alphaChannelBitDepthMinus8     , 0 , 7, "alpha_channel_bit_depth_minus8"   );
717  xCheckCfgRange( wrongConfig, m_alphaTransparentValue          , 0 , maxInterpretationValue, "alpha_transparent_value"          );
718  xCheckCfgRange( wrongConfig, m_alphaOpaqueValue               , 0 , maxInterpretationValue, "alpha_opaque_value"   );
719  xCheckCfgRange( wrongConfig, m_alphaChannelIncrFlag           , 0 , 1, "alpha_channel_incr_flag"          );
720  xCheckCfgRange( wrongConfig, m_alphaChannelClipFlag           , 0 , 1, "alpha_channel_clip_flag"          );
721  xCheckCfgRange( wrongConfig, m_alphaChannelClipTypeFlag       , 0 , 1, "alpha_channel_clip_type_flag"     );
722
723  return wrongConfig;
724
725};
726
727SEIOverlayInfo::SEIOverlayInfo ( )
728  : m_numOverlaysMax(16)
729  , m_numOverlayElementsMax(256)
730  , m_numStringBytesMax(256) //incl. null termination byte
731{ };
732
733Void SEIOverlayInfo::setupFromCfgFile(const TChar* cfgFile)
734{
735  // Set default values
736  IntAry1d defAppLayerIds, defAppPocs, defAppTids, defAppVclNaluTypes;
737
738  // Add default values for which layers, POCS, Tids or Nalu types the SEI should be send.
739  defAppLayerIds    .clear();
740  defAppPocs        .push_back( 0 );
741  defAppTids        .push_back( 0 );
742  defAppVclNaluTypes = IDR_NAL_UNIT_TYPES;
743
744  Int      defSeiNaluId                  = 0;
745  Int      defPositionInSeiNalu          = 0;
746  Bool     defModifyByEncoder            = false;
747
748  // Setup config file options
749  po::Options opts;
750  xAddGeneralOpts( opts , defAppLayerIds, defAppPocs, defAppTids, defAppVclNaluTypes, defSeiNaluId, defPositionInSeiNalu, defModifyByEncoder );
751
752  opts.addOptions()
753    ("OverlayInfoCancelFlag"          , m_overlayInfoCancelFlag            , false                           , "OverlayInfoCancelFlag"            )
754    ("OverlayContentAuxIdMinus128"    , m_overlayContentAuxIdMinus128      , 0                               , "OverlayContentAuxIdMinus128"      )
755    ("OverlayLabelAuxIdMinus128"      , m_overlayLabelAuxIdMinus128        , 0                               , "OverlayLabelAuxIdMinus128"        )
756    ("OverlayAlphaAuxIdMinus128"      , m_overlayAlphaAuxIdMinus128        , 0                               , "OverlayAlphaAuxIdMinus128"        )
757    ("OverlayElementLabelValueLengthMinus8", m_overlayElementLabelValueLengthMinus8, 0                       , "OverlayElementLabelValueLengthMinus8")
758    ("NumOverlaysMinus1"              , m_numOverlaysMinus1                , 0                               , "NumOverlaysMinus1"                )
759    ("OverlayIdx"                     , m_overlayIdx                       , IntAry1d (16,0)                 , "OverlayIdx"                       )
760    ("LanguageOverlayPresentFlag"     , m_languageOverlayPresentFlag       , BoolAry1d(16,0)                 , "LanguageOverlayPresentFlag"       )
761    ("OverlayContentLayerId"          , m_overlayContentLayerId            , IntAry1d (16,0)                 , "OverlayContentLayerId"            )
762    ("OverlayLabelPresentFlag"        , m_overlayLabelPresentFlag          , BoolAry1d(16,0)                 , "OverlayLabelPresentFlag"          )
763    ("OverlayLabelLayerId"            , m_overlayLabelLayerId              , IntAry1d (16,0)                 , "OverlayLabelLayerId"              )
764    ("OverlayAlphaPresentFlag"        , m_overlayAlphaPresentFlag          , BoolAry1d(16,0)                 , "OverlayAlphaPresentFlag"          )
765    ("OverlayAlphaLayerId"            , m_overlayAlphaLayerId              , IntAry1d (16,0)                 , "OverlayAlphaLayerId"              )
766    ("NumOverlayElementsMinus1"       , m_numOverlayElementsMinus1         , IntAry1d (16,0)                 , "NumOverlayElementsMinus1"         )
767    ("OverlayElementLabelMin_%d"      , m_overlayElementLabelMin           , IntAry1d (256,0) ,16            , "OverlayElementLabelMin"           )
768    ("OverlayElementLabelMax_%d"      , m_overlayElementLabelMax           , IntAry1d (256,0) ,16            , "OverlayElementLabelMax"           )
769    ("OverlayLanguage_%d"             , m_overlayLanguage                  , std::string(""), 16             , "OverlayLanguage"                  )
770    ("OverlayName_%d"                 , m_overlayName                      , std::string(""), 16             , "OverlayName"                      )
771    ("OverlayElementName_%d_%d"       , m_overlayElementName               , std::string(""), 256 ,16        , "OverlayElementName"               )
772    ("OverlayInfoPersistenceFlag"     , m_overlayInfoPersistenceFlag       , false                           , "OverlayInfoPersistenceFlag"       )
773    ;
774
775  po::setDefaults(opts);
776
777  // Parse the cfg file
778  po::ErrorReporter err;
779  po::parseConfigFile( opts, cfgFile, err );
780};
781
782
783Bool SEIOverlayInfo::checkCfg( const TComSlice* slice )
784{
785  // Check config values
786  Bool wrongConfig = false;
787
788  xCheckCfgRange( wrongConfig, m_overlayInfoCancelFlag          , 0 ,   1, "overlay_info_cancel_flag"         );
789  xCheckCfgRange( wrongConfig, m_overlayContentAuxIdMinus128    , 0 ,  31, "overlay_content_aux_id_minus128"  );
790  xCheckCfgRange( wrongConfig, m_overlayLabelAuxIdMinus128      , 0 ,  31, "overlay_label_aux_id_minus128"    );
791  xCheckCfgRange( wrongConfig, m_overlayAlphaAuxIdMinus128      , 0 ,  31, "overlay_alpha_aux_id_minus128"    );
792  xCheckCfgRange( wrongConfig, m_numOverlaysMinus1              , 0 ,  m_numOverlaysMax-1, "num_overlays_minus1"  );
793  for (Int i=0 ; i<=m_numOverlaysMinus1 ; ++i)
794  {
795    xCheckCfgRange( wrongConfig, m_overlayIdx[i]                  , 0 , 255, "overlay_idx"          );
796    xCheckCfgRange( wrongConfig, m_languageOverlayPresentFlag[i]  , 0 ,   1, "language_overlay_present_flag"    );
797    xCheckCfgRange( wrongConfig, m_overlayLabelPresentFlag[i]     , 0 ,   1, "overlay_label_present_flag"       );
798    xCheckCfgRange( wrongConfig, m_overlayAlphaPresentFlag[i]     , 0 ,   1, "overlay_alpha_present_flag"       );
799    xCheckCfgRange( wrongConfig, m_overlayContentLayerId[i]       , 0 ,   63, "overlay_content_layer_id"    );
800    xCheckCfgRange( wrongConfig, m_overlayLabelLayerId[i]         , 0 ,   63, "overlay_label_layer_id"    );
801    xCheckCfgRange( wrongConfig, m_overlayAlphaLayerId[i]         , 0 ,   63, "overlay_alpha_layer_id"    );
802    xCheckCfgRange( wrongConfig, m_numOverlayElementsMinus1[i]    , 0 , m_numOverlayElementsMax-1, "num_overlay_elements_minus1"       );
803    for (Int j=0 ; j<=m_numOverlayElementsMinus1[i] ; ++j)
804    {
805      Int maxLabelMinMaxValue = ( 1 << ( m_overlayElementLabelValueLengthMinus8 + 8 ) )-1;
806      xCheckCfgRange( wrongConfig, m_overlayElementLabelMin[i][j] , 0 , maxLabelMinMaxValue , "overlay_element_label_min"    );
807      xCheckCfgRange( wrongConfig, m_overlayElementLabelMax[i][j] , 0 , maxLabelMinMaxValue , "overlay_element_label_max"    );
808    }
809  }
810  xCheckCfgRange( wrongConfig, m_overlayInfoPersistenceFlag     , 0 ,   1, "overlay_info_persistence_flag"    );
811
812  return wrongConfig;
813
814};
815
816
817Void SEITemporalMvPredictionConstraints::setupFromCfgFile(const TChar* cfgFile)
818{
819  // Set default values
820  IntAry1d defAppLayerIds, defAppPocs, defAppTids, defAppVclNaluTypes;
821
822  // TBD: Add default values for which layers, POCS, Tids or Nalu types the SEI should be send.
823  defAppLayerIds    .clear    (   );
824  defAppPocs        .push_back( 0 );
825  defAppTids        .push_back( 0 );
826  defAppVclNaluTypes.clear    (   );
827
828  Int      defSeiNaluId                  = 0;
829  Int      defPositionInSeiNalu          = 0;
830  Bool     defModifyByEncoder            = false;
831
832  // Setup config file options
833  po::Options opts;
834  xAddGeneralOpts( opts , defAppLayerIds, defAppPocs, defAppTids, defAppVclNaluTypes, defSeiNaluId, defPositionInSeiNalu, defModifyByEncoder );
835
836  opts.addOptions()
837    ("PrevPicsNotUsedFlag"   , m_prevPicsNotUsedFlag   , false, "PrevPicsNotUsedFlag"    )
838    ("NoIntraLayerColPicFlag", m_noIntraLayerColPicFlag, false, "NoIntraLayerColPicFlag" )
839    ;
840
841  po::setDefaults(opts);
842
843  // Parse the cfg file
844  po::ErrorReporter err;
845  po::parseConfigFile( opts, cfgFile, err );
846};
847
848Bool SEITemporalMvPredictionConstraints::checkCfg( const TComSlice* slice )
849{
850  // Check config values
851  Bool wrongConfig = false;
852
853  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." );
854
855  return wrongConfig;
856};
857
858#if NH_MV_SEI_TBD
859Void SEIFrameFieldInfo::setupFromCfgFile(const TChar* cfgFile)
860{
861  // Set default values
862  IntAry1d defAppLayerIds, defAppPocs, defAppTids, defAppVclNaluTypes;
863
864  // TBD: Add default values for which layers, POCS, Tids or Nalu types the SEI should be send.
865  defAppLayerIds    .push_back( TBD );
866  defAppPocs        .push_back( TBD );
867  defAppTids        .push_back( TBD );
868  defAppVclNaluTypes.push_back( TBD );
869
870  Int      defSeiNaluId                  = 0;
871  Int      defPositionInSeiNalu          = 0;
872  Bool     defModifyByEncoder            = false;
873
874  // Setup config file options
875  po::Options opts;
876  xAddGeneralOpts( opts , defAppLayerIds, defAppPocs, defAppTids, defAppVclNaluTypes, defSeiNaluId, defPositionInSeiNalu, defModifyByEncoder );
877
878  opts.addOptions()
879    ("FfinfoPicStruct"     , m_ffinfoPicStruct     , 0     , "FfinfoPicStruct"     )
880    ("FfinfoSourceScanType", m_ffinfoSourceScanType, 0     , "FfinfoSourceScanType")
881    ("FfinfoDuplicateFlag" , m_ffinfoDuplicateFlag , false , "FfinfoDuplicateFlag" )
882    ;
883
884  po::setDefaults(opts);
885
886  // Parse the cfg file
887  po::ErrorReporter err;
888  po::parseConfigFile( opts, cfgFile, err );
889};
890
891
892Bool SEIFrameFieldInfo::checkCfg( const TComSlice* slice )
893{
894  // Check config values
895  Bool wrongConfig = false;
896
897  // TBD: Add constraints on presence of SEI here.
898  xCheckCfg     ( wrongConfig, TBD , "TBD" );
899  xCheckCfg     ( wrongConfig, TBD , "TBD" );
900
901  // TBD: Modify constraints according to the SEI semantics.
902  xCheckCfgRange( wrongConfig, m_ffinfoPicStruct                , MINVAL , MAXVAL, "ffinfo_pic_struct"                );
903  xCheckCfgRange( wrongConfig, m_ffinfoSourceScanType           , MINVAL , MAXVAL, "ffinfo_source_scan_type"          );
904  xCheckCfgRange( wrongConfig, m_ffinfoDuplicateFlag            , MINVAL , MAXVAL, "ffinfo_duplicate_flag"            );
905
906  return wrongConfig;
907
908};
909#endif
910
911Void SEIThreeDimensionalReferenceDisplaysInfo::setupFromCfgFile(const TChar* cfgFile)
912{
913  // Set default values
914  IntAry1d defAppLayerIds, defAppPocs, defAppTids, defAppVclNaluTypes;
915
916  // Default values for which layers, POCS, Tids or Nalu types the SEI should be sent.
917  defAppLayerIds      .push_back( 0 );
918  defAppPocs          .push_back( 0 );
919  defAppTids          .push_back( 0 );
920  defAppVclNaluTypes = IRAP_NAL_UNIT_TYPES;
921
922  Int      defSeiNaluId                  = 0;
923  Int      defPositionInSeiNalu          = 0;
924  Bool     defModifyByEncoder            = 0;
925
926  // Setup config file options
927  po::Options opts;
928  xAddGeneralOpts( opts , defAppLayerIds, defAppPocs, defAppTids, defAppVclNaluTypes, defSeiNaluId, defPositionInSeiNalu, defModifyByEncoder );
929
930  opts.addOptions()
931    ("PrecRefDisplayWidth"            , m_precRefDisplayWidth              , 0                              , "PrecRefDisplayWidth"              )
932    ("RefViewingDistanceFlag"         , m_refViewingDistanceFlag           , false                          , "RefViewingDistanceFlag"           )
933    ("PrecRefViewingDist"             , m_precRefViewingDist               , 0                              , "PrecRefViewingDist"               )
934    ("NumRefDisplaysMinus1"           , m_numRefDisplaysMinus1             , 0                              , "NumRefDisplaysMinus1"             )
935    ("LeftViewId"                     , m_leftViewId                       , IntAry1d (1,0)                 , "LeftViewId"                       )
936    ("RightViewId"                    , m_rightViewId                      , IntAry1d (1,0)                 , "RightViewId"                      )
937    ("ExponentRefDisplayWidth"        , m_exponentRefDisplayWidth          , IntAry1d (1,0)                 , "ExponentRefDisplayWidth"          )
938    ("MantissaRefDisplayWidth"        , m_mantissaRefDisplayWidth          , IntAry1d (1,0)                 , "MantissaRefDisplayWidth"          )
939    ("ExponentRefViewingDistance"     , m_exponentRefViewingDistance       , IntAry1d (1,0)                 , "ExponentRefViewingDistance"       )
940    ("MantissaRefViewingDistance"     , m_mantissaRefViewingDistance       , IntAry1d (1,0)                 , "MantissaRefViewingDistance"       )
941    ("AdditionalShiftPresentFlag"     , m_additionalShiftPresentFlag       , BoolAry1d(1,0)                 , "AdditionalShiftPresentFlag"       )
942    ("NumSampleShiftPlus512"          , m_numSampleShiftPlus512            , IntAry1d (1,0)                 , "NumSampleShiftPlus512"            )
943    ("ThreeDimensionalReferenceDisplaysExtensionFlag", m_threeDimensionalReferenceDisplaysExtensionFlag, false                          , "ThreeDimensionalReferenceDisplaysExtensionFlag")
944    ;
945
946  po::setDefaults(opts);
947
948  // Parse the cfg file
949  po::ErrorReporter err;
950  po::parseConfigFile( opts, cfgFile, err );
951};
952
953
954UInt SEIThreeDimensionalReferenceDisplaysInfo::getMantissaReferenceDisplayWidthLen( Int i ) const
955{
956  return xGetSyntaxElementLen( m_exponentRefDisplayWidth[i], m_precRefDisplayWidth, m_mantissaRefDisplayWidth[ i ] );
957}
958
959UInt SEIThreeDimensionalReferenceDisplaysInfo::getMantissaReferenceViewingDistanceLen( Int i ) const
960{
961  return xGetSyntaxElementLen( m_exponentRefViewingDistance[i], m_precRefViewingDist, m_mantissaRefViewingDistance[ i ] );
962}
963
964UInt SEIThreeDimensionalReferenceDisplaysInfo::xGetSyntaxElementLen( Int expo, Int prec, Int val ) const
965{
966  UInt len;
967  if( expo == 0 )
968  {
969    len = std::max(0, prec - 30 );
970  }
971  else
972  {
973    len = std::max( 0, expo + prec - 31 );
974  }
975
976  assert( val >= 0 );
977  assert( val <= ( ( 1 << len )- 1) );
978  return len;
979}
980
981Bool SEIThreeDimensionalReferenceDisplaysInfo::checkCfg( const TComSlice* slice )
982{
983  // Check config values
984  Bool wrongConfig = false;
985
986  // 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.
987  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." );
988
989  xCheckCfgRange( wrongConfig, m_precRefDisplayWidth            , 0 , 31, "prec_ref_display_width"  );
990  xCheckCfgRange( wrongConfig, m_refViewingDistanceFlag         , 0 , 1, "ref_viewing_distance_flag");
991  xCheckCfgRange( wrongConfig, m_precRefViewingDist             , 0 , 31, "prec_ref_viewing_dist"   );
992  xCheckCfgRange( wrongConfig, m_numRefDisplaysMinus1           , 0 , 31, "num_ref_displays_minus1" );
993
994  for (Int i = 0; i <= getNumRefDisplaysMinus1(); i++ )
995  {
996    xCheckCfgRange( wrongConfig, m_exponentRefDisplayWidth[i]     , 0 , 62, "exponent_ref_display_width"   );
997    xCheckCfgRange( wrongConfig, m_exponentRefViewingDistance[i]  , 0 , 62, "exponent_ref_viewing_distance");
998    xCheckCfgRange( wrongConfig, m_additionalShiftPresentFlag[i]  , 0 , 1, "additional_shift_present_flag" );
999    xCheckCfgRange( wrongConfig, m_numSampleShiftPlus512[i]       , 0 , 1023, "num_sample_shift_plus512"   );
1000  }
1001  xCheckCfgRange( wrongConfig, m_threeDimensionalReferenceDisplaysExtensionFlag, 0 , 1, "three_dimensional_reference_displays_extension_flag");
1002
1003  return wrongConfig;
1004
1005};
1006
1007Void SEIDepthRepresentationInfo::setupFromSlice  ( const TComSlice* slice )
1008{
1009
1010    m_currLayerID=slice->getLayerIdInVps();
1011};
1012
1013Void SEIDepthRepresentationInfo::setupFromCfgFile(const TChar* cfgFile)
1014{
1015  // Set default values
1016  IntAry1d defAppLayerIds, defAppPocs, defAppTids, defAppVclNaluTypes;
1017
1018  // TBD: Add default values for which layers, POCS, Tids or Nalu types the SEI should be send.
1019  //defAppLayerIds    .push_back( TBD );
1020  defAppPocs        .push_back( 0 );
1021  //defAppTids        .push_back( TBD );
1022  //defAppVclNaluTypes.push_back( TBD );
1023
1024  Int      defSeiNaluId                  = 0;
1025  Int      defPositionInSeiNalu          = 0;
1026  Bool     defModifyByEncoder            = true;
1027
1028  // Setup config file options
1029  po::Options opts;
1030
1031  xAddGeneralOpts( opts , defAppLayerIds, defAppPocs, defAppTids, defAppVclNaluTypes, defSeiNaluId, defPositionInSeiNalu, defModifyByEncoder );
1032
1033  opts.addOptions()
1034    ("ZNear_%d"                      , m_zNear               , std::vector<double>(0,0)       , MAX_NUM_LAYERS , "ZNear"           )
1035    ("ZFar_%d"                       , m_zFar                , std::vector<double>(0,0)       , MAX_NUM_LAYERS , "ZFar"            )
1036    ("DMin_%d"                       , m_dMin                , std::vector<double>(0,0)       , MAX_NUM_LAYERS , "DMin"            )
1037    ("DMax_%d"                       , m_dMax                , std::vector<double>(0,0)       , MAX_NUM_LAYERS , "DMax"            )
1038    ("DepthRepresentationInfoSeiPresentFlag_%d",  m_depthRepresentationInfoSeiPresentFlag, BoolAry1d(1,0), MAX_NUM_LAYERS, "DepthRepresentationInfoSeiPresentFlag")
1039    ("DepthRepresentationType_%d"        , m_depthRepresentationType          , IntAry1d(0,0), MAX_NUM_LAYERS,  "DepthRepresentationType"        )
1040    ("DisparityRefViewId_%d"             , m_disparityRefViewId               ,  IntAry1d(0,0), MAX_NUM_LAYERS,  "DisparityRefViewId"             )
1041    ("DepthNonlinearRepresentationNumMinus1_%d", m_depthNonlinearRepresentationNumMinus1, IntAry1d(0,0), MAX_NUM_LAYERS, "DepthNonlinearRepresentationNumMinus1")
1042    ("DepthNonlinearRepresentationModel_%d"    , m_depth_nonlinear_representation_model ,   IntAry1d(0,0), MAX_NUM_LAYERS, "DepthNonlinearRepresentationModel") ;
1043
1044
1045  po::setDefaults(opts);
1046
1047  // Parse the cfg file
1048  po::ErrorReporter err;
1049  po::parseConfigFile( opts, cfgFile, err );
1050
1051
1052  for(int i=0;i<MAX_NUM_LAYERS;i++)
1053  {
1054    if (m_zNear[i].size()>0)
1055    {
1056      m_zNearFlag.push_back(true);
1057    }
1058    else
1059    {
1060      m_zNearFlag.push_back(false);
1061    }
1062
1063    if (m_zFar[i].size()>0)
1064    {
1065      m_zFarFlag.push_back(true);
1066    }
1067    else
1068    {
1069      m_zFarFlag.push_back(false);
1070    }
1071
1072    if (m_dMin[i].size()>0)
1073    {
1074      m_dMinFlag.push_back(true);
1075    }
1076    else
1077    {
1078      m_dMinFlag.push_back(false);
1079    }
1080
1081    if (m_dMax[i].size()>0)
1082    {
1083      m_dMaxFlag.push_back(true);
1084    }
1085    else
1086    {
1087      m_dMaxFlag.push_back(false);
1088    }
1089
1090
1091    if (m_depthRepresentationInfoSeiPresentFlag[i][0])
1092    {
1093      if ( m_depthRepresentationType[i].size()<=0 )
1094      {
1095        printf("DepthRepresentationType_%d must be present for layer %d\n",i,i );
1096        return;
1097      }
1098
1099      if (  m_depthRepresentationType[i][0]<0 )
1100      {
1101        printf("DepthRepresentationType_%d must be equal to or greater than 0\n",i );
1102        return;
1103      }
1104
1105      if (m_dMinFlag[i] || m_dMaxFlag[i])
1106      {
1107        if (m_disparityRefViewId[i].size()<=0)
1108        {
1109          printf("DisparityRefViewId_%d must be present for layer %d\n",i,i );
1110          assert(false);
1111          return;
1112        }
1113        if (m_disparityRefViewId[i][0]<0)
1114        {
1115          printf("DisparityRefViewId_%d must be equal to or greater than 0\n",i );
1116          assert(false);
1117          return;
1118        }
1119      }
1120
1121      if (m_depthRepresentationType[i][0]==3)
1122      {
1123        if (m_depthNonlinearRepresentationNumMinus1[i].size()<=0)
1124        {
1125          printf("DepthNonlinearRepresentationNumMinus1_%d must be present for layer %d\n",i,i );
1126          assert(false);
1127          return;
1128        }
1129        if (m_depthNonlinearRepresentationNumMinus1[i][0]<0)
1130        {
1131          printf("DepthNonlinearRepresentationNumMinus1_%d must be equal to or greater than 0\n",i );
1132          assert(false);
1133          return;
1134        }
1135
1136        if (m_depth_nonlinear_representation_model[i].size() != m_depthNonlinearRepresentationNumMinus1[i][0]+1)
1137        {
1138          printf("the number of values in Depth_nonlinear_representation_model must be equal to DepthNonlinearRepresentationNumMinus1+1 in layer %d\n",i );
1139          assert(false);
1140          return;
1141        }
1142      }
1143    }
1144  }
1145
1146  assert(m_zNearFlag.size()==MAX_NUM_LAYERS);
1147  assert(m_zFarFlag.size()==MAX_NUM_LAYERS);
1148  assert(m_dMinFlag.size()==MAX_NUM_LAYERS);
1149  assert(m_dMaxFlag.size()==MAX_NUM_LAYERS);
1150}
1151
1152Bool SEIDepthRepresentationInfo::checkCfg( const TComSlice* slice )
1153{
1154    // Check config values
1155    Bool wrongConfig = false;
1156    assert(m_currLayerID>=0);
1157
1158    if (m_depthRepresentationInfoSeiPresentFlag[m_currLayerID][0]==false)
1159    {
1160        printf("DepthRepresentationInfoSeiPresentFlag_%d should be equal to 1 when  ApplicableLayerIds is empty or ApplicableLayerIds contains  %d\n",m_currLayerID,slice->getLayerId());
1161        assert(false);
1162    }
1163    // TBD: Add constraints on presence of SEI here.
1164    xCheckCfg     ( wrongConfig, m_depthRepresentationType[m_currLayerID][0] >=0 , "depth_representation_type must be equal to or greater than 0" );
1165    if ( m_dMaxFlag[m_currLayerID] || m_dMinFlag[m_currLayerID])
1166    {
1167        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");
1168    }
1169
1170    if (m_depthRepresentationType[m_currLayerID][0]==3)
1171    {
1172        xCheckCfg(wrongConfig , m_depthNonlinearRepresentationNumMinus1[m_currLayerID][0]>=0, "depth_nonlinear_representation_num_minus1 must be greater than or equal to 0");
1173
1174        if (m_depthNonlinearRepresentationNumMinus1[m_currLayerID][0]>=0)
1175        {
1176            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");
1177        }
1178
1179    }
1180
1181    return wrongConfig;
1182}
1183
1184
1185Void SEIMultiviewSceneInfo::setupFromCfgFile(const TChar* cfgFile)
1186{
1187  // Set default values
1188  IntAry1d defAppLayerIds, defAppPocs, defAppTids, defAppVclNaluTypes;
1189
1190  // TBD: Add default values for which layers, POCS, Tids or Nalu types the SEI should be send.
1191  defAppLayerIds      .clear();
1192  defAppPocs          .clear();
1193  defAppTids          .push_back( 0 );
1194  defAppVclNaluTypes = IRAP_NAL_UNIT_TYPES;
1195
1196  Int      defSeiNaluId                  = 0;
1197  Int      defPositionInSeiNalu          = 0;
1198  Bool     defModifyByEncoder            = false;
1199
1200  // Setup config file options
1201  po::Options opts;
1202  xAddGeneralOpts( opts , defAppLayerIds, defAppPocs, defAppTids, defAppVclNaluTypes, defSeiNaluId, defPositionInSeiNalu, defModifyByEncoder );
1203
1204  opts.addOptions()
1205    ("MinDisparity"                   , m_minDisparity                     , 0                              , "MinDisparity"                     )
1206    ("MaxDisparityRange"              , m_maxDisparityRange                , 0                              , "MaxDisparityRange"                )
1207    ;
1208
1209  po::setDefaults(opts);
1210
1211  // Parse the cfg file
1212  po::ErrorReporter err;
1213  po::parseConfigFile( opts, cfgFile, err );
1214};
1215
1216
1217Bool SEIMultiviewSceneInfo::checkCfg( const TComSlice* slice )
1218{
1219  // Check config values
1220  Bool wrongConfig = false;
1221
1222  xCheckCfg     ( wrongConfig, slice->isIRAP(), "When present, the multiview scene information SEI message shall be associated with an IRAP access unit." );
1223
1224  xCheckCfgRange( wrongConfig, m_minDisparity              , -1024 , 1023, "min_disparity"                    );
1225  xCheckCfgRange( wrongConfig, m_maxDisparityRange         ,     0 , 2047, "max_disparity_range"              );
1226
1227  return wrongConfig;
1228
1229};
1230
1231Void SEIMultiviewAcquisitionInfo::setupFromCfgFile(const TChar* cfgFile)
1232{
1233  // Set default values
1234  IntAry1d defAppLayerIds, defAppPocs, defAppTids, defAppVclNaluTypes;
1235
1236  defAppLayerIds    .clear();
1237  defAppPocs        .push_back( 0 );
1238  defAppTids        .push_back( 0 );
1239  defAppVclNaluTypes = IDR_NAL_UNIT_TYPES;
1240
1241
1242  Int      defSeiNaluId                  = 0;
1243  Int      defPositionInSeiNalu          = 0;
1244  Bool     defModifyByEncoder            = false;
1245
1246  // Setup config file options
1247  po::Options opts;
1248  xAddGeneralOpts( opts , defAppLayerIds, defAppPocs, defAppTids, defAppVclNaluTypes, defSeiNaluId, defPositionInSeiNalu, defModifyByEncoder );
1249
1250  opts.addOptions()
1251    ("IntrinsicParamFlag"               , m_intrinsicParamFlag               , false                              , "IntrinsicParamFlag"               )
1252    ("ExtrinsicParamFlag"               , m_extrinsicParamFlag               , false                              , "ExtrinsicParamFlag"               )
1253    ("IntrinsicParamsEqualFlag"         , m_intrinsicParamsEqualFlag         , false                              , "IntrinsicParamsEqualFlag"         )
1254    ("PrecFocalLength"                  , m_precFocalLength                  , 0                                  , "PrecFocalLength"                  )
1255    ("PrecPrincipalPoint"               , m_precPrincipalPoint               , 0                                  , "PrecPrincipalPoint"               )
1256    ("PrecSkewFactor"                   , m_precSkewFactor                   , 0                                  , "PrecSkewFactor"                   )
1257    ("SignFocalLengthX"                 , m_signFocalLengthX                 , BoolAry1d(1,0)                     , "SignFocalLengthX"                 )
1258    ("ExponentFocalLengthX"             , m_exponentFocalLengthX             , IntAry1d (1,0)                     , "ExponentFocalLengthX"             )
1259    ("MantissaFocalLengthX"             , m_mantissaFocalLengthX             , IntAry1d (1,0)                     , "MantissaFocalLengthX"             )
1260    ("SignFocalLengthY"                 , m_signFocalLengthY                 , BoolAry1d(1,0)                     , "SignFocalLengthY"                 )
1261    ("ExponentFocalLengthY"             , m_exponentFocalLengthY             , IntAry1d (1,0)                     , "ExponentFocalLengthY"             )
1262    ("MantissaFocalLengthY"             , m_mantissaFocalLengthY             , IntAry1d (1,0)                     , "MantissaFocalLengthY"             )
1263    ("SignPrincipalPointX"              , m_signPrincipalPointX              , BoolAry1d(1,0)                     , "SignPrincipalPointX"              )
1264    ("ExponentPrincipalPointX"          , m_exponentPrincipalPointX          , IntAry1d (1,0)                     , "ExponentPrincipalPointX"          )
1265    ("MantissaPrincipalPointX"          , m_mantissaPrincipalPointX          , IntAry1d (1,0)                     , "MantissaPrincipalPointX"          )
1266    ("SignPrincipalPointY"              , m_signPrincipalPointY              , BoolAry1d(1,0)                     , "SignPrincipalPointY"              )
1267    ("ExponentPrincipalPointY"          , m_exponentPrincipalPointY          , IntAry1d (1,0)                     , "ExponentPrincipalPointY"          )
1268    ("MantissaPrincipalPointY"          , m_mantissaPrincipalPointY          , IntAry1d (1,0)                     , "MantissaPrincipalPointY"          )
1269    ("SignSkewFactor"                   , m_signSkewFactor                   , BoolAry1d(1,0)                     , "SignSkewFactor"                   )
1270    ("ExponentSkewFactor"               , m_exponentSkewFactor               , IntAry1d (1,0)                     , "ExponentSkewFactor"               )
1271    ("MantissaSkewFactor"               , m_mantissaSkewFactor               , IntAry1d (1,0)                     , "MantissaSkewFactor"               )
1272    ("PrecRotationParam"                , m_precRotationParam                , 0                                  , "PrecRotationParam"                )
1273    ("PrecTranslationParam"             , m_precTranslationParam             , 0                                  , "PrecTranslationParam"             )
1274    ("SignR_%d_%d"                      , m_signR                            , BoolAry1d(3,0) ,MAX_NUM_LAYERS ,3  , "SignR"                            )
1275    ("ExponentR_%d_%d"                  , m_exponentR                        , IntAry1d (3,0) ,MAX_NUM_LAYERS ,3  , "ExponentR"                        )
1276    ("MantissaR_%d_%d"                  , m_mantissaR                        , IntAry1d (3,0) ,MAX_NUM_LAYERS ,3  , "MantissaR"                        )
1277    ("SignT_%d"                         , m_signT                            , BoolAry1d(3,0) ,MAX_NUM_LAYERS     , "SignT"                            )
1278    ("ExponentT_%d"                     , m_exponentT                        , IntAry1d (3,0) ,MAX_NUM_LAYERS     , "ExponentT"                        )
1279    ("MantissaT_%d"                     , m_mantissaT                        , IntAry1d (3,0) ,MAX_NUM_LAYERS     , "MantissaT"                        )
1280    ;
1281
1282  po::setDefaults(opts);
1283
1284  // Parse the cfg file
1285  po::ErrorReporter err;
1286  po::parseConfigFile( opts, cfgFile, err );
1287};
1288
1289UInt SEIMultiviewAcquisitionInfo::getMantissaFocalLengthXLen( Int i ) const
1290{
1291  return xGetSyntaxElementLen( m_exponentFocalLengthX[i], m_precFocalLength, m_mantissaFocalLengthX[ i ] );
1292}
1293
1294Bool SEIMultiviewAcquisitionInfo::checkCfg( const TComSlice* slice )
1295{
1296  // Check config values
1297  Bool wrongConfig = false;
1298
1299  // Currently the encoder starts with POC 0 for all layers. The condition on POC 0 should be changed, when this changes.
1300  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." );
1301
1302  xCheckCfgRange( wrongConfig, m_precFocalLength         , 0, 31, "prec_focal_length"         );
1303  xCheckCfgRange( wrongConfig, m_precPrincipalPoint      , 0, 31, "prec_principle_point"      );
1304  xCheckCfgRange( wrongConfig, m_precSkewFactor          , 0, 31, "prec_skew_factor"          );
1305
1306  for (Int i = 0; i <= getNumViewsMinus1(); i++ )
1307  {
1308    xCheckCfgRange( wrongConfig, m_exponentFocalLengthX    [ i ], 0, 62, "exponent_focal_length_x"   );
1309    xCheckCfgRange( wrongConfig, m_exponentFocalLengthY    [ i ], 0, 62, "exponent_focal_length_y"   );
1310    xCheckCfgRange( wrongConfig, m_exponentPrincipalPointX [ i ], 0, 62, "exponent_principal_point_x");
1311    xCheckCfgRange( wrongConfig, m_exponentPrincipalPointY [ i ], 0, 62, "exponent_principal_point_y");
1312    xCheckCfgRange( wrongConfig, m_exponentSkewFactor      [ i ], 0, 62, "exponent_skew_factor"      );
1313  }
1314
1315  xCheckCfgRange( wrongConfig, m_precRotationParam       , 0, 31, "prec_focal_length"         );
1316  xCheckCfgRange( wrongConfig, m_precTranslationParam    , 0, 31, "prec_focal_length"         );
1317
1318  for (Int i = 0; i <= getNumViewsMinus1(); i++ )
1319  {
1320    for (Int j = 0; j <= 2; j++)
1321    {
1322      xCheckCfgRange( wrongConfig, m_exponentT[i][j]     , 0, 62, "exponent_skew_factor"      );
1323      for (Int k = 0; k <= 2; k++ )
1324      {
1325        xCheckCfgRange( wrongConfig, m_exponentR[i][j][k], 0, 62, "exponent_principal_point_y");
1326      }
1327    }
1328  }
1329
1330  return wrongConfig;
1331
1332};
1333
1334UInt SEIMultiviewAcquisitionInfo::getMantissaFocalLengthYLen( Int i ) const
1335{
1336  return xGetSyntaxElementLen( m_exponentFocalLengthY[i], m_precFocalLength, m_mantissaFocalLengthY[ i ]  );
1337}
1338
1339
1340UInt SEIMultiviewAcquisitionInfo::getMantissaPrincipalPointXLen( Int i ) const
1341{
1342  return xGetSyntaxElementLen( m_exponentPrincipalPointX[i], m_precPrincipalPoint, m_mantissaPrincipalPointX[ i ]  );
1343}
1344
1345UInt SEIMultiviewAcquisitionInfo::getMantissaPrincipalPointYLen( Int i ) const
1346{
1347  return xGetSyntaxElementLen( m_exponentPrincipalPointY[i], m_precPrincipalPoint, m_mantissaPrincipalPointY[ i ] );
1348}
1349
1350UInt SEIMultiviewAcquisitionInfo::getMantissaSkewFactorLen( Int i ) const
1351{
1352  return xGetSyntaxElementLen( m_exponentSkewFactor[ i ], m_precSkewFactor, m_mantissaSkewFactor[ i ] );
1353}
1354
1355UInt SEIMultiviewAcquisitionInfo::getMantissaRLen( Int i, Int j, Int k ) const
1356{
1357  return xGetSyntaxElementLen( m_exponentR[ i ][ j ][ k ], m_precRotationParam, m_mantissaR[ i ][ j] [ k ] );
1358}
1359
1360UInt SEIMultiviewAcquisitionInfo::getMantissaTLen( Int i, Int j ) const
1361{
1362  return xGetSyntaxElementLen( m_exponentT[ i ][ j ], m_precTranslationParam, m_mantissaT[ i ][ j ] );
1363}
1364UInt SEIMultiviewAcquisitionInfo::xGetSyntaxElementLen( Int expo, Int prec, Int val ) const
1365{
1366  UInt len;
1367  if( expo == 0 )
1368  {
1369    len = std::max(0, prec - 30 );
1370  }
1371  else
1372  {
1373    len = std::max( 0, expo + prec - 31 );
1374  }
1375
1376  assert( val >= 0 );
1377  assert( val <= ( ( 1 << len )- 1) );
1378  return len;
1379}
1380
1381Void SEIMultiviewViewPosition::setupFromSlice  ( const TComSlice* slice )
1382{
1383  const TComVPS* vps = slice->getVPS();
1384  m_numViewsMinus1 = vps->getNumViews() - 1;
1385  m_viewPosition.resize( m_numViewsMinus1 + 1 );
1386  for (Int i = 0; i <= m_numViewsMinus1; i++ )
1387  {
1388    // Assuming that view ids indicate the position
1389    m_viewPosition[i] = vps->getViewIdVal( i );
1390  }
1391}
1392
1393Void SEIMultiviewViewPosition::setupFromCfgFile(const TChar* cfgFile)
1394{
1395  // Set default values
1396  IntAry1d defAppLayerIds, defAppPocs, defAppTids, defAppVclNaluTypes;
1397
1398  defAppLayerIds    .push_back( 0 );
1399  defAppPocs        .push_back( 0 );
1400  defAppTids        .push_back( 0 );
1401  defAppVclNaluTypes = IDR_NAL_UNIT_TYPES;
1402
1403  Int      defSeiNaluId                  = 0;
1404  Int      defPositionInSeiNalu          = 0;
1405  Bool     defModifyByEncoder            = true;
1406
1407  // Setup config file options
1408  po::Options opts;
1409  xAddGeneralOpts( opts , defAppLayerIds, defAppPocs, defAppTids, defAppVclNaluTypes, defSeiNaluId, defPositionInSeiNalu, defModifyByEncoder );
1410
1411  opts.addOptions()
1412    ("NumViewsMinus1"         , m_numViewsMinus1                          , 0                       , "NumViewsMinus1")
1413    ("ViewPosition"           , m_viewPosition                            , IntAry1d (1,0)          , "ViewPosition"  );
1414  ;
1415
1416  po::setDefaults(opts);
1417
1418  // Parse the cfg file
1419  po::ErrorReporter err;
1420  po::parseConfigFile( opts, cfgFile, err );
1421};
1422
1423Bool SEIMultiviewViewPosition::checkCfg( const TComSlice* slice )
1424{
1425  // Check config values
1426  Bool wrongConfig = false;
1427
1428  // TBD: Add constraints on presence of SEI here.
1429  xCheckCfg     ( wrongConfig, slice->isIRAP() , "When present, the multiview view position SEI message shall be associated with an IRAP access unit."  );
1430
1431  // TBD: Modify constraints according to the SEI semantics.
1432  xCheckCfgRange( wrongConfig, m_numViewsMinus1                 , 0 , 62, "num_views_minus1");
1433  for(Int i = 0; i <= m_numViewsMinus1; i++)
1434  {
1435    xCheckCfgRange( wrongConfig, m_viewPosition[i]                , 0 , 62, "view_position");
1436  }
1437
1438  return wrongConfig;
1439
1440};
1441
1442
1443
1444#endif
Note: See TracBrowser for help on using the repository browser.