source: SHVCSoftware/branches/SHM-3.0-dev/source/Lib/TLibCommon/SEI.h @ 1423

Last change on this file since 1423 was 313, checked in by suehring, 11 years ago

set svn:eol-style=native property on all source files to do proper
automatic line break conversion on check-out and check-in

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