source: SHVCSoftware/trunk/source/Lib/TLibCommon/SEI.h @ 757

Last change on this file since 757 was 713, checked in by seregin, 11 years ago

merge with SHM-6-dev

  • Property svn:eol-style set to native
File size: 16.0 KB
RevLine 
[313]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 *
[595]6 * Copyright (c) 2010-2014, ITU/ISO/IEC
[313]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#pragma once
35#include <list>
36#include <vector>
37#include <cstring>
38
39//! \ingroup TLibCommon
40//! \{
41class TComSPS;
[644]42#if O0164_MULTI_LAYER_HRD
43class TComHRD;
44#endif
[313]45
46/**
47 * Abstract class representing an SEI message with lightweight RTTI.
48 */
49class SEI
50{
51public:
52  enum PayloadType
53  {
54    BUFFERING_PERIOD                     = 0,
55    PICTURE_TIMING                       = 1,
56    PAN_SCAN_RECT                        = 2,
57    FILLER_PAYLOAD                       = 3,
58    USER_DATA_REGISTERED_ITU_T_T35       = 4,
59    USER_DATA_UNREGISTERED               = 5,
60    RECOVERY_POINT                       = 6,
61    SCENE_INFO                           = 9,
62    FULL_FRAME_SNAPSHOT                  = 15,
63    PROGRESSIVE_REFINEMENT_SEGMENT_START = 16,
64    PROGRESSIVE_REFINEMENT_SEGMENT_END   = 17,
65    FILM_GRAIN_CHARACTERISTICS           = 19,
66    POST_FILTER_HINT                     = 22,
67    TONE_MAPPING_INFO                    = 23,
68    FRAME_PACKING                        = 45,
69    DISPLAY_ORIENTATION                  = 47,
70    SOP_DESCRIPTION                      = 128,
71    ACTIVE_PARAMETER_SETS                = 129,
72    DECODING_UNIT_INFO                   = 130,
73    TEMPORAL_LEVEL0_INDEX                = 131,
74    DECODED_PICTURE_HASH                 = 132,
75    SCALABLE_NESTING                     = 133,
76    REGION_REFRESH_INFO                  = 134,
[588]77#if LAYERS_NOT_PRESENT_SEI
78    LAYERS_NOT_PRESENT                   = 137,
[313]79#endif
[442]80#if N0383_IL_CONSTRAINED_TILE_SETS_SEI
[713]81    INTER_LAYER_CONSTRAINED_TILE_SETS    = 138,
[442]82#endif
[588]83#if SUB_BITSTREAM_PROPERTY_SEI
[713]84    SUB_BITSTREAM_PROPERTY               = 139,    // Final PayloadType to be defined after finalization
[588]85#endif
[644]86#if O0164_MULTI_LAYER_HRD
[713]87    BSP_NESTING                          = 140,
88    BSP_INITIAL_ARRIVAL_TIME             = 141,
89    BSP_HRD                              = 142,
[644]90#endif
[713]91#if Q0074_SEI_COLOR_MAPPING
92    COLOR_MAPPING_INFO                   = 143,
93#endif
[313]94  };
95 
96  SEI() {}
97  virtual ~SEI() {}
98 
99  virtual PayloadType payloadType() const = 0;
100};
101
102class SEIuserDataUnregistered : public SEI
103{
104public:
105  PayloadType payloadType() const { return USER_DATA_UNREGISTERED; }
106
107  SEIuserDataUnregistered()
108    : userData(0)
109    {}
110
111  virtual ~SEIuserDataUnregistered()
112  {
113    delete userData;
114  }
115
116  UChar uuid_iso_iec_11578[16];
117  UInt userDataLength;
118  UChar *userData;
119};
120
121class SEIDecodedPictureHash : public SEI
122{
123public:
124  PayloadType payloadType() const { return DECODED_PICTURE_HASH; }
125
126  SEIDecodedPictureHash() {}
127  virtual ~SEIDecodedPictureHash() {}
128 
129  enum Method
130  {
131    MD5,
132    CRC,
133    CHECKSUM,
134    RESERVED,
135  } method;
136
137  UChar digest[3][16];
138};
139
140class SEIActiveParameterSets : public SEI
141{
142public:
143  PayloadType payloadType() const { return ACTIVE_PARAMETER_SETS; }
144
145  SEIActiveParameterSets() 
146    : activeVPSId            (0)
[713]147    , m_selfContainedCvsFlag (false)
148    , m_noParameterSetUpdateFlag (false)
[313]149    , numSpsIdsMinus1        (0)
150  {}
151  virtual ~SEIActiveParameterSets() {}
152
153  Int activeVPSId; 
[713]154  Bool m_selfContainedCvsFlag;
155  Bool m_noParameterSetUpdateFlag;
[313]156  Int numSpsIdsMinus1;
[713]157  std::vector<Int> activeSeqParameterSetId; 
[313]158};
159
160class SEIBufferingPeriod : public SEI
161{
162public:
163  PayloadType payloadType() const { return BUFFERING_PERIOD; }
164
165  SEIBufferingPeriod()
166  : m_bpSeqParameterSetId (0)
167  , m_rapCpbParamsPresentFlag (false)
168  , m_cpbDelayOffset      (0)
169  , m_dpbDelayOffset      (0)
[644]170#if P0138_USE_ALT_CPB_PARAMS_FLAG
171  , m_useAltCpbParamsFlagPresent(false)
172  , m_useAltCpbParamsFlag (false)
173#endif
[313]174  {
175    ::memset(m_initialCpbRemovalDelay, 0, sizeof(m_initialCpbRemovalDelay));
176    ::memset(m_initialCpbRemovalDelayOffset, 0, sizeof(m_initialCpbRemovalDelayOffset));
177    ::memset(m_initialAltCpbRemovalDelay, 0, sizeof(m_initialAltCpbRemovalDelay));
178    ::memset(m_initialAltCpbRemovalDelayOffset, 0, sizeof(m_initialAltCpbRemovalDelayOffset));
179  }
180  virtual ~SEIBufferingPeriod() {}
181
182  UInt m_bpSeqParameterSetId;
183  Bool m_rapCpbParamsPresentFlag;
184  Bool m_cpbDelayOffset;
185  Bool m_dpbDelayOffset;
186  UInt m_initialCpbRemovalDelay         [MAX_CPB_CNT][2];
187  UInt m_initialCpbRemovalDelayOffset   [MAX_CPB_CNT][2];
188  UInt m_initialAltCpbRemovalDelay      [MAX_CPB_CNT][2];
189  UInt m_initialAltCpbRemovalDelayOffset[MAX_CPB_CNT][2];
190  Bool m_concatenationFlag;
191  UInt m_auCpbRemovalDelayDelta;
[644]192#if P0138_USE_ALT_CPB_PARAMS_FLAG
193  Bool m_useAltCpbParamsFlagPresent;
194  Bool m_useAltCpbParamsFlag;
195#endif
[313]196};
197class SEIPictureTiming : public SEI
198{
199public:
200  PayloadType payloadType() const { return PICTURE_TIMING; }
201
202  SEIPictureTiming()
203  : m_picStruct               (0)
204  , m_sourceScanType          (0)
205  , m_duplicateFlag           (false)
206  , m_picDpbOutputDuDelay     (0)
207  , m_numNalusInDuMinus1      (NULL)
208  , m_duCpbRemovalDelayMinus1 (NULL)
209  {}
210  virtual ~SEIPictureTiming()
211  {
212    if( m_numNalusInDuMinus1 != NULL )
213    {
214      delete m_numNalusInDuMinus1;
215    }
216    if( m_duCpbRemovalDelayMinus1  != NULL )
217    {
218      delete m_duCpbRemovalDelayMinus1;
219    }
220  }
221
222  UInt  m_picStruct;
223  UInt  m_sourceScanType;
224  Bool  m_duplicateFlag;
225
226  UInt  m_auCpbRemovalDelay;
227  UInt  m_picDpbOutputDelay;
228  UInt  m_picDpbOutputDuDelay;
229  UInt  m_numDecodingUnitsMinus1;
230  Bool  m_duCommonCpbRemovalDelayFlag;
231  UInt  m_duCommonCpbRemovalDelayMinus1;
232  UInt* m_numNalusInDuMinus1;
233  UInt* m_duCpbRemovalDelayMinus1;
234};
235
236class SEIDecodingUnitInfo : public SEI
237{
238public:
239  PayloadType payloadType() const { return DECODING_UNIT_INFO; }
240
241  SEIDecodingUnitInfo()
242    : m_decodingUnitIdx(0)
243    , m_duSptCpbRemovalDelay(0)
244    , m_dpbOutputDuDelayPresentFlag(false)
245    , m_picSptDpbOutputDuDelay(0)
246  {}
247  virtual ~SEIDecodingUnitInfo() {}
248  Int m_decodingUnitIdx;
249  Int m_duSptCpbRemovalDelay;
250  Bool m_dpbOutputDuDelayPresentFlag;
251  Int m_picSptDpbOutputDuDelay;
252};
253
254class SEIRecoveryPoint : public SEI
255{
256public:
257  PayloadType payloadType() const { return RECOVERY_POINT; }
258
259  SEIRecoveryPoint() {}
260  virtual ~SEIRecoveryPoint() {}
261
262  Int  m_recoveryPocCnt;
263  Bool m_exactMatchingFlag;
264  Bool m_brokenLinkFlag;
265};
266class SEIFramePacking : public SEI
267{
268public:
269  PayloadType payloadType() const { return FRAME_PACKING; }
270
271  SEIFramePacking() {}
272  virtual ~SEIFramePacking() {}
273
274  Int  m_arrangementId;
275  Bool m_arrangementCancelFlag;
276  Int  m_arrangementType;
277  Bool m_quincunxSamplingFlag;
278  Int  m_contentInterpretationType;
279  Bool m_spatialFlippingFlag;
280  Bool m_frame0FlippedFlag;
281  Bool m_fieldViewsFlag;
282  Bool m_currentFrameIsFrame0Flag;
283  Bool m_frame0SelfContainedFlag;
284  Bool m_frame1SelfContainedFlag;
285  Int  m_frame0GridPositionX;
286  Int  m_frame0GridPositionY;
287  Int  m_frame1GridPositionX;
288  Int  m_frame1GridPositionY;
289  Int  m_arrangementReservedByte;
290  Bool m_arrangementPersistenceFlag;
291  Bool m_upsampledAspectRatio;
292};
293
294class SEIDisplayOrientation : public SEI
295{
296public:
297  PayloadType payloadType() const { return DISPLAY_ORIENTATION; }
298
299  SEIDisplayOrientation()
300    : cancelFlag(true)
301    , persistenceFlag(0)
302    , extensionFlag(false)
303    {}
304  virtual ~SEIDisplayOrientation() {}
305
306  Bool cancelFlag;
307  Bool horFlip;
308  Bool verFlip;
309
310  UInt anticlockwiseRotation;
311  Bool persistenceFlag;
312  Bool extensionFlag;
313};
314
315class SEITemporalLevel0Index : public SEI
316{
317public:
318  PayloadType payloadType() const { return TEMPORAL_LEVEL0_INDEX; }
319
320  SEITemporalLevel0Index()
321    : tl0Idx(0)
322    , rapIdx(0)
323    {}
324  virtual ~SEITemporalLevel0Index() {}
325
326  UInt tl0Idx;
327  UInt rapIdx;
328};
329
330class SEIGradualDecodingRefreshInfo : public SEI
331{
332public:
333  PayloadType payloadType() const { return REGION_REFRESH_INFO; }
334
335  SEIGradualDecodingRefreshInfo()
336    : m_gdrForegroundFlag(0)
337  {}
338  virtual ~SEIGradualDecodingRefreshInfo() {}
339
340  Bool m_gdrForegroundFlag;
341};
342
[588]343#if LAYERS_NOT_PRESENT_SEI
344class SEILayersNotPresent : public SEI
[313]345{
346public:
[588]347  PayloadType payloadType() const { return LAYERS_NOT_PRESENT; }
[313]348
[588]349  SEILayersNotPresent() {}
350  virtual ~SEILayersNotPresent() {}
[313]351
352  UInt m_activeVpsId;
353  UInt m_vpsMaxLayers;
[588]354  Bool m_layerNotPresentFlag[MAX_LAYERS];
[313]355};
356#endif
357
358class SEISOPDescription : public SEI
359{
360public:
361  PayloadType payloadType() const { return SOP_DESCRIPTION; }
362
363  SEISOPDescription() {}
364  virtual ~SEISOPDescription() {}
365
366  UInt m_sopSeqParameterSetId;
367  UInt m_numPicsInSopMinus1;
368
369  UInt m_sopDescVclNaluType[MAX_NUM_PICS_IN_SOP];
370  UInt m_sopDescTemporalId[MAX_NUM_PICS_IN_SOP];
371  UInt m_sopDescStRpsIdx[MAX_NUM_PICS_IN_SOP];
372  Int m_sopDescPocDelta[MAX_NUM_PICS_IN_SOP];
373};
374
375class SEIToneMappingInfo : public SEI
376{
377public:
378  PayloadType payloadType() const { return TONE_MAPPING_INFO; }
379  SEIToneMappingInfo() {}
380  virtual ~SEIToneMappingInfo() {}
381
382  Int    m_toneMapId;
383  Bool   m_toneMapCancelFlag;
384  Bool   m_toneMapPersistenceFlag;
385  Int    m_codedDataBitDepth;
386  Int    m_targetBitDepth;
387  Int    m_modelId;
388  Int    m_minValue;
389  Int    m_maxValue;
390  Int    m_sigmoidMidpoint;
391  Int    m_sigmoidWidth;
392  std::vector<Int> m_startOfCodedInterval;
393  Int    m_numPivots;
394  std::vector<Int> m_codedPivotValue;
395  std::vector<Int> m_targetPivotValue;
396  Int    m_cameraIsoSpeedIdc;
397  Int    m_cameraIsoSpeedValue;
[713]398  Int    m_exposureIndexIdc;
399  Int    m_exposureIndexValue;
[313]400  Int    m_exposureCompensationValueSignFlag;
401  Int    m_exposureCompensationValueNumerator;
402  Int    m_exposureCompensationValueDenomIdc;
403  Int    m_refScreenLuminanceWhite;
404  Int    m_extendedRangeWhiteLevel;
405  Int    m_nominalBlackLevelLumaCodeValue;
406  Int    m_nominalWhiteLevelLumaCodeValue;
407  Int    m_extendedWhiteLevelLumaCodeValue;
408};
409
[713]410#if Q0074_SEI_COLOR_MAPPING
411class SEIColorMappingInfo : public SEI
412{
413public:
414  PayloadType payloadType() const { return COLOR_MAPPING_INFO; }
415  SEIColorMappingInfo() {
416  }
417  virtual ~SEIColorMappingInfo() {}
418
419  Int   m_colorMapId;
420  Bool  m_colorMapCancelFlag;
421  Bool  m_colorMapPersistenceFlag;
422  Bool  m_colorMap_video_signal_type_present_flag;
423  Bool  m_colorMap_video_full_range_flag;
424  Int   m_colorMap_primaries;
425  Int   m_colorMap_transfer_characteristics;
426  Int   m_colorMap_matrix_coeffs;
427  Int   m_colorMapModelId;
428
429  Int   m_colour_map_coded_data_bit_depth;
430  Int   m_colour_map_target_bit_depth;
431
432  Int   m_num_input_pivots[3];
433  Int*  m_coded_input_pivot_value[3];
434  Int*  m_target_input_pivot_value[3];
435 
436  Bool  m_matrix_flag;
437  Int   m_log2_matrix_denom;
438  Int   m_matrix_coef[3][3];
439
440  Int   m_num_output_pivots[3];
441  Int*  m_coded_output_pivot_value[3];
442  Int*  m_target_output_pivot_value[3];
443};
444#endif
445
[442]446#if N0383_IL_CONSTRAINED_TILE_SETS_SEI
447class SEIInterLayerConstrainedTileSets : public SEI
448{
449public:
450  PayloadType payloadType() const { return INTER_LAYER_CONSTRAINED_TILE_SETS; }
451
452  SEIInterLayerConstrainedTileSets() {}
453  virtual ~SEIInterLayerConstrainedTileSets() {}
454
455  Bool m_ilAllTilesExactSampleValueMatchFlag;
456  Bool m_ilOneTilePerTileSetFlag;
457  UInt m_ilNumSetsInMessageMinus1;
458  Bool m_skippedTileSetPresentFlag;
459  UInt m_ilctsId[256];
460  UInt m_ilNumTileRectsInSetMinus1[256];
461  UInt m_ilTopLeftTileIndex[256][440];
462  UInt m_ilBottomRightTileIndex[256][440];
463  UInt m_ilcIdc[256];
464  Bool m_ilExactSampleValueMatchFlag[256];
465  UInt m_allTilesIlcIdc;
466};
467#endif
468
[588]469#if SUB_BITSTREAM_PROPERTY_SEI
470class SEISubBitstreamProperty : public SEI
471{
472public:
473  PayloadType payloadType() const { return SUB_BITSTREAM_PROPERTY; }
[442]474
[588]475  SEISubBitstreamProperty();
476  virtual ~SEISubBitstreamProperty() {}
477
478  Int  m_activeVpsId;
479  Int  m_numAdditionalSubStreams;
480  Int  m_subBitstreamMode       [MAX_SUB_STREAMS];
481  Int  m_outputLayerSetIdxToVps [MAX_SUB_STREAMS];
482  Int  m_highestSublayerId      [MAX_SUB_STREAMS];
483  Int  m_avgBitRate             [MAX_SUB_STREAMS];
484  Int  m_maxBitRate             [MAX_SUB_STREAMS];
485};
486#endif
487
[313]488typedef std::list<SEI*> SEIMessages;
489
490/// output a selection of SEI messages by payload type. Ownership stays in original message list.
491SEIMessages getSeisByType(SEIMessages &seiList, SEI::PayloadType seiType);
492
493/// remove a selection of SEI messages by payload type from the original list and return them in a new list.
494SEIMessages extractSeisByType(SEIMessages &seiList, SEI::PayloadType seiType);
495
496/// delete list of SEI messages (freeing the referenced objects)
497Void deleteSEIs (SEIMessages &seiList);
498
[644]499#if O0164_MULTI_LAYER_HRD
500
501class SEIBspNesting : public SEI
502{
503public:
504  PayloadType payloadType() const { return BSP_NESTING; }
505
506  SEIBspNesting() {}
507  virtual ~SEIBspNesting()
508  {
509    if (!m_callerOwnsSEIs)
510    {
511      deleteSEIs(m_nestedSEIs);
512    }
513  }
514
515  Int  m_bspIdx;
516  Bool  m_callerOwnsSEIs;
517  SEIMessages m_nestedSEIs;
518};
519
520class SEIBspInitialArrivalTime : public SEI
521{
522public:
523  PayloadType payloadType() const { return BSP_INITIAL_ARRIVAL_TIME; }
524
525  SEIBspInitialArrivalTime () {}
526  virtual ~SEIBspInitialArrivalTime () {}
527
528  UInt m_nalInitialArrivalDelay[256];
529  UInt m_vclInitialArrivalDelay[256];
530};
531
532class SEIBspHrd : public SEI
533{
534public:
535  PayloadType payloadType() const { return BSP_HRD; }
536
537  SEIBspHrd () {}
538  virtual ~SEIBspHrd () {}
539
540  UInt m_seiNumBspHrdParametersMinus1;
541  Bool m_seiBspCprmsPresentFlag[MAX_VPS_LAYER_SETS_PLUS1];
542  UInt m_seiNumBitstreamPartitionsMinus1[MAX_VPS_LAYER_SETS_PLUS1];
543  Bool m_seiLayerInBspFlag[MAX_VPS_LAYER_SETS_PLUS1][8][MAX_LAYERS];
544  UInt m_seiNumBspSchedCombinationsMinus1[MAX_VPS_LAYER_SETS_PLUS1];
545  UInt m_seiBspCombHrdIdx[MAX_VPS_LAYER_SETS_PLUS1][16][16];
546  UInt m_seiBspCombScheddx[MAX_VPS_LAYER_SETS_PLUS1][16][16];
547  UInt m_vpsMaxLayers;
548  Bool m_layerIdIncludedFlag[MAX_VPS_LAYER_SETS_PLUS1][MAX_VPS_LAYER_ID_PLUS1];
549
550  TComHRD *hrd;
551};
552
553#endif
554
[313]555class SEIScalableNesting : public SEI
556{
557public:
558  PayloadType payloadType() const { return SCALABLE_NESTING; }
559
560  SEIScalableNesting() {}
561  virtual ~SEIScalableNesting()
562  {
563    if (!m_callerOwnsSEIs)
564    {
565      deleteSEIs(m_nestedSEIs);
566    }
567  }
568
569  Bool  m_bitStreamSubsetFlag;
570  Bool  m_nestingOpFlag;
571  Bool  m_defaultOpFlag;                             //value valid if m_nestingOpFlag != 0
572  UInt  m_nestingNumOpsMinus1;                       // -"-
573  UInt  m_nestingMaxTemporalIdPlus1[MAX_TLAYER];     // -"-
574  UInt  m_nestingOpIdx[MAX_NESTING_NUM_OPS];         // -"-
575
576  Bool  m_allLayersFlag;                             //value valid if m_nestingOpFlag == 0
577  UInt  m_nestingNoOpMaxTemporalIdPlus1;             //value valid if m_nestingOpFlag == 0 and m_allLayersFlag == 0
578  UInt  m_nestingNumLayersMinus1;                    //value valid if m_nestingOpFlag == 0 and m_allLayersFlag == 0
579  UChar m_nestingLayerId[MAX_NESTING_NUM_LAYER];     //value valid if m_nestingOpFlag == 0 and m_allLayersFlag == 0. This can e.g. be a static array of 64 unsigned char values
580
581  Bool  m_callerOwnsSEIs;
582  SEIMessages m_nestedSEIs;
583};
584
585//! \}
Note: See TracBrowser for help on using the repository browser.