source: SHVCSoftware/branches/SHM-5.0-dev/source/Lib/TLibCommon/SEI.h @ 852

Last change on this file since 852 was 593, checked in by seregin, 11 years ago

update to HM-13.0

  • Property svn:eol-style set to native
File size: 13.2 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
43/**
44 * Abstract class representing an SEI message with lightweight RTTI.
45 */
46class SEI
47{
48public:
49  enum PayloadType
50  {
51    BUFFERING_PERIOD                     = 0,
52    PICTURE_TIMING                       = 1,
53    PAN_SCAN_RECT                        = 2,
54    FILLER_PAYLOAD                       = 3,
55    USER_DATA_REGISTERED_ITU_T_T35       = 4,
56    USER_DATA_UNREGISTERED               = 5,
57    RECOVERY_POINT                       = 6,
58    SCENE_INFO                           = 9,
59    FULL_FRAME_SNAPSHOT                  = 15,
60    PROGRESSIVE_REFINEMENT_SEGMENT_START = 16,
61    PROGRESSIVE_REFINEMENT_SEGMENT_END   = 17,
62    FILM_GRAIN_CHARACTERISTICS           = 19,
63    POST_FILTER_HINT                     = 22,
64    TONE_MAPPING_INFO                    = 23,
65    FRAME_PACKING                        = 45,
66    DISPLAY_ORIENTATION                  = 47,
67    SOP_DESCRIPTION                      = 128,
68    ACTIVE_PARAMETER_SETS                = 129,
69    DECODING_UNIT_INFO                   = 130,
70    TEMPORAL_LEVEL0_INDEX                = 131,
71    DECODED_PICTURE_HASH                 = 132,
72    SCALABLE_NESTING                     = 133,
73    REGION_REFRESH_INFO                  = 134,
74#if LAYERS_NOT_PRESENT_SEI
75    LAYERS_NOT_PRESENT                   = 137,
76#endif
77#if N0383_IL_CONSTRAINED_TILE_SETS_SEI
78    INTER_LAYER_CONSTRAINED_TILE_SETS    = 138
79#endif
80#if SUB_BITSTREAM_PROPERTY_SEI
81   ,SUB_BITSTREAM_PROPERTY               = 139    // Final PayloadType to be defined after finalization
82#endif
83  };
84 
85  SEI() {}
86  virtual ~SEI() {}
87 
88  virtual PayloadType payloadType() const = 0;
89};
90
91class SEIuserDataUnregistered : public SEI
92{
93public:
94  PayloadType payloadType() const { return USER_DATA_UNREGISTERED; }
95
96  SEIuserDataUnregistered()
97    : userData(0)
98    {}
99
100  virtual ~SEIuserDataUnregistered()
101  {
102    delete userData;
103  }
104
105  UChar uuid_iso_iec_11578[16];
106  UInt userDataLength;
107  UChar *userData;
108};
109
110class SEIDecodedPictureHash : public SEI
111{
112public:
113  PayloadType payloadType() const { return DECODED_PICTURE_HASH; }
114
115  SEIDecodedPictureHash() {}
116  virtual ~SEIDecodedPictureHash() {}
117 
118  enum Method
119  {
120    MD5,
121    CRC,
122    CHECKSUM,
123    RESERVED,
124  } method;
125
126  UChar digest[3][16];
127};
128
129class SEIActiveParameterSets : public SEI
130{
131public:
132  PayloadType payloadType() const { return ACTIVE_PARAMETER_SETS; }
133
134  SEIActiveParameterSets() 
135    : activeVPSId            (0)
136    , m_fullRandomAccessFlag (false)
137    , m_noParamSetUpdateFlag (false)
138    , numSpsIdsMinus1        (0)
139  {}
140  virtual ~SEIActiveParameterSets() {}
141
142  Int activeVPSId; 
143  Bool m_fullRandomAccessFlag;
144  Bool m_noParamSetUpdateFlag;
145  Int numSpsIdsMinus1;
146  std::vector<Int> activeSeqParamSetId; 
147};
148
149class SEIBufferingPeriod : public SEI
150{
151public:
152  PayloadType payloadType() const { return BUFFERING_PERIOD; }
153
154  SEIBufferingPeriod()
155  : m_bpSeqParameterSetId (0)
156  , m_rapCpbParamsPresentFlag (false)
157  , m_cpbDelayOffset      (0)
158  , m_dpbDelayOffset      (0)
159  {
160    ::memset(m_initialCpbRemovalDelay, 0, sizeof(m_initialCpbRemovalDelay));
161    ::memset(m_initialCpbRemovalDelayOffset, 0, sizeof(m_initialCpbRemovalDelayOffset));
162    ::memset(m_initialAltCpbRemovalDelay, 0, sizeof(m_initialAltCpbRemovalDelay));
163    ::memset(m_initialAltCpbRemovalDelayOffset, 0, sizeof(m_initialAltCpbRemovalDelayOffset));
164  }
165  virtual ~SEIBufferingPeriod() {}
166
167  UInt m_bpSeqParameterSetId;
168  Bool m_rapCpbParamsPresentFlag;
169  Bool m_cpbDelayOffset;
170  Bool m_dpbDelayOffset;
171  UInt m_initialCpbRemovalDelay         [MAX_CPB_CNT][2];
172  UInt m_initialCpbRemovalDelayOffset   [MAX_CPB_CNT][2];
173  UInt m_initialAltCpbRemovalDelay      [MAX_CPB_CNT][2];
174  UInt m_initialAltCpbRemovalDelayOffset[MAX_CPB_CNT][2];
175  Bool m_concatenationFlag;
176  UInt m_auCpbRemovalDelayDelta;
177};
178class SEIPictureTiming : public SEI
179{
180public:
181  PayloadType payloadType() const { return PICTURE_TIMING; }
182
183  SEIPictureTiming()
184  : m_picStruct               (0)
185  , m_sourceScanType          (0)
186  , m_duplicateFlag           (false)
187  , m_picDpbOutputDuDelay     (0)
188  , m_numNalusInDuMinus1      (NULL)
189  , m_duCpbRemovalDelayMinus1 (NULL)
190  {}
191  virtual ~SEIPictureTiming()
192  {
193    if( m_numNalusInDuMinus1 != NULL )
194    {
195      delete m_numNalusInDuMinus1;
196    }
197    if( m_duCpbRemovalDelayMinus1  != NULL )
198    {
199      delete m_duCpbRemovalDelayMinus1;
200    }
201  }
202
203  UInt  m_picStruct;
204  UInt  m_sourceScanType;
205  Bool  m_duplicateFlag;
206
207  UInt  m_auCpbRemovalDelay;
208  UInt  m_picDpbOutputDelay;
209  UInt  m_picDpbOutputDuDelay;
210  UInt  m_numDecodingUnitsMinus1;
211  Bool  m_duCommonCpbRemovalDelayFlag;
212  UInt  m_duCommonCpbRemovalDelayMinus1;
213  UInt* m_numNalusInDuMinus1;
214  UInt* m_duCpbRemovalDelayMinus1;
215};
216
217class SEIDecodingUnitInfo : public SEI
218{
219public:
220  PayloadType payloadType() const { return DECODING_UNIT_INFO; }
221
222  SEIDecodingUnitInfo()
223    : m_decodingUnitIdx(0)
224    , m_duSptCpbRemovalDelay(0)
225    , m_dpbOutputDuDelayPresentFlag(false)
226    , m_picSptDpbOutputDuDelay(0)
227  {}
228  virtual ~SEIDecodingUnitInfo() {}
229  Int m_decodingUnitIdx;
230  Int m_duSptCpbRemovalDelay;
231  Bool m_dpbOutputDuDelayPresentFlag;
232  Int m_picSptDpbOutputDuDelay;
233};
234
235class SEIRecoveryPoint : public SEI
236{
237public:
238  PayloadType payloadType() const { return RECOVERY_POINT; }
239
240  SEIRecoveryPoint() {}
241  virtual ~SEIRecoveryPoint() {}
242
243  Int  m_recoveryPocCnt;
244  Bool m_exactMatchingFlag;
245  Bool m_brokenLinkFlag;
246};
247class SEIFramePacking : public SEI
248{
249public:
250  PayloadType payloadType() const { return FRAME_PACKING; }
251
252  SEIFramePacking() {}
253  virtual ~SEIFramePacking() {}
254
255  Int  m_arrangementId;
256  Bool m_arrangementCancelFlag;
257  Int  m_arrangementType;
258  Bool m_quincunxSamplingFlag;
259  Int  m_contentInterpretationType;
260  Bool m_spatialFlippingFlag;
261  Bool m_frame0FlippedFlag;
262  Bool m_fieldViewsFlag;
263  Bool m_currentFrameIsFrame0Flag;
264  Bool m_frame0SelfContainedFlag;
265  Bool m_frame1SelfContainedFlag;
266  Int  m_frame0GridPositionX;
267  Int  m_frame0GridPositionY;
268  Int  m_frame1GridPositionX;
269  Int  m_frame1GridPositionY;
270  Int  m_arrangementReservedByte;
271  Bool m_arrangementPersistenceFlag;
272  Bool m_upsampledAspectRatio;
273};
274
275class SEIDisplayOrientation : public SEI
276{
277public:
278  PayloadType payloadType() const { return DISPLAY_ORIENTATION; }
279
280  SEIDisplayOrientation()
281    : cancelFlag(true)
282    , persistenceFlag(0)
283    , extensionFlag(false)
284    {}
285  virtual ~SEIDisplayOrientation() {}
286
287  Bool cancelFlag;
288  Bool horFlip;
289  Bool verFlip;
290
291  UInt anticlockwiseRotation;
292  Bool persistenceFlag;
293  Bool extensionFlag;
294};
295
296class SEITemporalLevel0Index : public SEI
297{
298public:
299  PayloadType payloadType() const { return TEMPORAL_LEVEL0_INDEX; }
300
301  SEITemporalLevel0Index()
302    : tl0Idx(0)
303    , rapIdx(0)
304    {}
305  virtual ~SEITemporalLevel0Index() {}
306
307  UInt tl0Idx;
308  UInt rapIdx;
309};
310
311class SEIGradualDecodingRefreshInfo : public SEI
312{
313public:
314  PayloadType payloadType() const { return REGION_REFRESH_INFO; }
315
316  SEIGradualDecodingRefreshInfo()
317    : m_gdrForegroundFlag(0)
318  {}
319  virtual ~SEIGradualDecodingRefreshInfo() {}
320
321  Bool m_gdrForegroundFlag;
322};
323
324#if LAYERS_NOT_PRESENT_SEI
325class SEILayersNotPresent : public SEI
326{
327public:
328  PayloadType payloadType() const { return LAYERS_NOT_PRESENT; }
329
330  SEILayersNotPresent() {}
331  virtual ~SEILayersNotPresent() {}
332
333  UInt m_activeVpsId;
334  UInt m_vpsMaxLayers;
335  Bool m_layerNotPresentFlag[MAX_LAYERS];
336};
337#endif
338
339class SEISOPDescription : public SEI
340{
341public:
342  PayloadType payloadType() const { return SOP_DESCRIPTION; }
343
344  SEISOPDescription() {}
345  virtual ~SEISOPDescription() {}
346
347  UInt m_sopSeqParameterSetId;
348  UInt m_numPicsInSopMinus1;
349
350  UInt m_sopDescVclNaluType[MAX_NUM_PICS_IN_SOP];
351  UInt m_sopDescTemporalId[MAX_NUM_PICS_IN_SOP];
352  UInt m_sopDescStRpsIdx[MAX_NUM_PICS_IN_SOP];
353  Int m_sopDescPocDelta[MAX_NUM_PICS_IN_SOP];
354};
355
356class SEIToneMappingInfo : public SEI
357{
358public:
359  PayloadType payloadType() const { return TONE_MAPPING_INFO; }
360  SEIToneMappingInfo() {}
361  virtual ~SEIToneMappingInfo() {}
362
363  Int    m_toneMapId;
364  Bool   m_toneMapCancelFlag;
365  Bool   m_toneMapPersistenceFlag;
366  Int    m_codedDataBitDepth;
367  Int    m_targetBitDepth;
368  Int    m_modelId;
369  Int    m_minValue;
370  Int    m_maxValue;
371  Int    m_sigmoidMidpoint;
372  Int    m_sigmoidWidth;
373  std::vector<Int> m_startOfCodedInterval;
374  Int    m_numPivots;
375  std::vector<Int> m_codedPivotValue;
376  std::vector<Int> m_targetPivotValue;
377  Int    m_cameraIsoSpeedIdc;
378  Int    m_cameraIsoSpeedValue;
379  Int    m_exposureCompensationValueSignFlag;
380  Int    m_exposureCompensationValueNumerator;
381  Int    m_exposureCompensationValueDenomIdc;
382  Int    m_refScreenLuminanceWhite;
383  Int    m_extendedRangeWhiteLevel;
384  Int    m_nominalBlackLevelLumaCodeValue;
385  Int    m_nominalWhiteLevelLumaCodeValue;
386  Int    m_extendedWhiteLevelLumaCodeValue;
387};
388
389#if N0383_IL_CONSTRAINED_TILE_SETS_SEI
390class SEIInterLayerConstrainedTileSets : public SEI
391{
392public:
393  PayloadType payloadType() const { return INTER_LAYER_CONSTRAINED_TILE_SETS; }
394
395  SEIInterLayerConstrainedTileSets() {}
396  virtual ~SEIInterLayerConstrainedTileSets() {}
397
398  Bool m_ilAllTilesExactSampleValueMatchFlag;
399  Bool m_ilOneTilePerTileSetFlag;
400  UInt m_ilNumSetsInMessageMinus1;
401  Bool m_skippedTileSetPresentFlag;
402  UInt m_ilctsId[256];
403  UInt m_ilNumTileRectsInSetMinus1[256];
404  UInt m_ilTopLeftTileIndex[256][440];
405  UInt m_ilBottomRightTileIndex[256][440];
406  UInt m_ilcIdc[256];
407  Bool m_ilExactSampleValueMatchFlag[256];
408  UInt m_allTilesIlcIdc;
409};
410#endif
411
412#if SUB_BITSTREAM_PROPERTY_SEI
413class SEISubBitstreamProperty : public SEI
414{
415public:
416  PayloadType payloadType() const { return SUB_BITSTREAM_PROPERTY; }
417
418  SEISubBitstreamProperty();
419  virtual ~SEISubBitstreamProperty() {}
420
421  Int  m_activeVpsId;
422  Int  m_numAdditionalSubStreams;
423  Int  m_subBitstreamMode       [MAX_SUB_STREAMS];
424  Int  m_outputLayerSetIdxToVps [MAX_SUB_STREAMS];
425  Int  m_highestSublayerId      [MAX_SUB_STREAMS];
426  Int  m_avgBitRate             [MAX_SUB_STREAMS];
427  Int  m_maxBitRate             [MAX_SUB_STREAMS];
428};
429#endif
430
431typedef std::list<SEI*> SEIMessages;
432
433/// output a selection of SEI messages by payload type. Ownership stays in original message list.
434SEIMessages getSeisByType(SEIMessages &seiList, SEI::PayloadType seiType);
435
436/// remove a selection of SEI messages by payload type from the original list and return them in a new list.
437SEIMessages extractSeisByType(SEIMessages &seiList, SEI::PayloadType seiType);
438
439/// delete list of SEI messages (freeing the referenced objects)
440Void deleteSEIs (SEIMessages &seiList);
441
442class SEIScalableNesting : public SEI
443{
444public:
445  PayloadType payloadType() const { return SCALABLE_NESTING; }
446
447  SEIScalableNesting() {}
448  virtual ~SEIScalableNesting()
449  {
450    if (!m_callerOwnsSEIs)
451    {
452      deleteSEIs(m_nestedSEIs);
453    }
454  }
455
456  Bool  m_bitStreamSubsetFlag;
457  Bool  m_nestingOpFlag;
458  Bool  m_defaultOpFlag;                             //value valid if m_nestingOpFlag != 0
459  UInt  m_nestingNumOpsMinus1;                       // -"-
460  UInt  m_nestingMaxTemporalIdPlus1[MAX_TLAYER];     // -"-
461  UInt  m_nestingOpIdx[MAX_NESTING_NUM_OPS];         // -"-
462
463  Bool  m_allLayersFlag;                             //value valid if m_nestingOpFlag == 0
464  UInt  m_nestingNoOpMaxTemporalIdPlus1;             //value valid if m_nestingOpFlag == 0 and m_allLayersFlag == 0
465  UInt  m_nestingNumLayersMinus1;                    //value valid if m_nestingOpFlag == 0 and m_allLayersFlag == 0
466  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
467
468  Bool  m_callerOwnsSEIs;
469  SEIMessages m_nestedSEIs;
470};
471
472//! \}
Note: See TracBrowser for help on using the repository browser.