source: SHVCSoftware/branches/SHM-6-dev/source/Lib/TLibCommon/SEI.h @ 693

Last change on this file since 693 was 652, checked in by seregin, 11 years ago

update to HM-14.0

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