source: SHVCSoftware/branches/SHM-2.1-dev/source/Lib/TLibCommon/SEI.h @ 292

Last change on this file since 292 was 292, checked in by vidyo, 11 years ago

Implementation of M0043 - Layers Present SEI.
This is disabled by default. Enable this by setting M0043_LAYERS_PRESENT_SEI to 1

File size: 13.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-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#if !L0047_APS_FLAGS
130    :numSpsIdsMinus1(0)
131#else
132    : activeVPSId            (0)
133    , m_fullRandomAccessFlag (false)
134    , m_noParamSetUpdateFlag (false)
135    , numSpsIdsMinus1        (0)
136#endif
137  {}
138  virtual ~SEIActiveParameterSets() {}
139
140  Int activeVPSId; 
141#if L0047_APS_FLAGS
142  Bool m_fullRandomAccessFlag;
143  Bool m_noParamSetUpdateFlag;
144#endif
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#if L0044_CPB_DPB_DELAY_OFFSET
156  : m_bpSeqParameterSetId (0)
157  , m_rapCpbParamsPresentFlag (false)
158  , m_cpbDelayOffset      (0)
159  , m_dpbDelayOffset      (0)
160  {
161    ::memset(m_initialCpbRemovalDelay, 0, sizeof(m_initialCpbRemovalDelay));
162    ::memset(m_initialCpbRemovalDelayOffset, 0, sizeof(m_initialCpbRemovalDelayOffset));
163    ::memset(m_initialAltCpbRemovalDelay, 0, sizeof(m_initialAltCpbRemovalDelay));
164    ::memset(m_initialAltCpbRemovalDelayOffset, 0, sizeof(m_initialAltCpbRemovalDelayOffset));
165  }
166#else
167  {}
168#endif
169  virtual ~SEIBufferingPeriod() {}
170
171  UInt m_bpSeqParameterSetId;
172  Bool m_rapCpbParamsPresentFlag;
173#if L0044_CPB_DPB_DELAY_OFFSET
174  Bool m_cpbDelayOffset;
175  Bool m_dpbDelayOffset;
176#endif
177  UInt m_initialCpbRemovalDelay         [MAX_CPB_CNT][2];
178  UInt m_initialCpbRemovalDelayOffset   [MAX_CPB_CNT][2];
179  UInt m_initialAltCpbRemovalDelay      [MAX_CPB_CNT][2];
180  UInt m_initialAltCpbRemovalDelayOffset[MAX_CPB_CNT][2];
181#if L0328_SPLICING
182  Bool m_concatenationFlag;
183  UInt m_auCpbRemovalDelayDelta;
184#endif
185};
186class SEIPictureTiming : public SEI
187{
188public:
189  PayloadType payloadType() const { return PICTURE_TIMING; }
190
191  SEIPictureTiming()
192  : m_picStruct               (0)
193#if L0046_RENAME_PROG_SRC_IDC
194  , m_sourceScanType          (0)
195#else
196  , m_progressiveSourceIdc    (0)
197#endif
198  , m_duplicateFlag           (false)
199#if L0044_DU_DPB_OUTPUT_DELAY_HRD
200  , m_picDpbOutputDuDelay     (0)
201#endif
202  , m_numNalusInDuMinus1      (NULL)
203  , m_duCpbRemovalDelayMinus1 (NULL)
204  {}
205  virtual ~SEIPictureTiming()
206  {
207    if( m_numNalusInDuMinus1 != NULL )
208    {
209      delete m_numNalusInDuMinus1;
210    }
211    if( m_duCpbRemovalDelayMinus1  != NULL )
212    {
213      delete m_duCpbRemovalDelayMinus1;
214    }
215  }
216
217  UInt  m_picStruct;
218#if L0046_RENAME_PROG_SRC_IDC
219  UInt  m_sourceScanType;
220#else
221  UInt  m_progressiveSourceIdc;
222#endif
223  Bool  m_duplicateFlag;
224
225  UInt  m_auCpbRemovalDelay;
226  UInt  m_picDpbOutputDelay;
227#if L0044_DU_DPB_OUTPUT_DELAY_HRD
228  UInt  m_picDpbOutputDuDelay;
229#endif
230  UInt  m_numDecodingUnitsMinus1;
231  Bool  m_duCommonCpbRemovalDelayFlag;
232  UInt  m_duCommonCpbRemovalDelayMinus1;
233  UInt* m_numNalusInDuMinus1;
234  UInt* m_duCpbRemovalDelayMinus1;
235};
236
237class SEIDecodingUnitInfo : public SEI
238{
239public:
240  PayloadType payloadType() const { return DECODING_UNIT_INFO; }
241
242  SEIDecodingUnitInfo()
243    : m_decodingUnitIdx(0)
244    , m_duSptCpbRemovalDelay(0)
245#if L0044_DU_DPB_OUTPUT_DELAY_HRD
246    , m_dpbOutputDuDelayPresentFlag(false)
247    , m_picSptDpbOutputDuDelay(0)
248#endif
249  {}
250  virtual ~SEIDecodingUnitInfo() {}
251  Int m_decodingUnitIdx;
252  Int m_duSptCpbRemovalDelay;
253#if L0044_DU_DPB_OUTPUT_DELAY_HRD
254  Bool m_dpbOutputDuDelayPresentFlag;
255  Int m_picSptDpbOutputDuDelay;
256#endif
257};
258
259class SEIRecoveryPoint : public SEI
260{
261public:
262  PayloadType payloadType() const { return RECOVERY_POINT; }
263
264  SEIRecoveryPoint() {}
265  virtual ~SEIRecoveryPoint() {}
266
267  Int  m_recoveryPocCnt;
268  Bool m_exactMatchingFlag;
269  Bool m_brokenLinkFlag;
270};
271class SEIFramePacking : public SEI
272{
273public:
274  PayloadType payloadType() const { return FRAME_PACKING; }
275
276  SEIFramePacking() {}
277  virtual ~SEIFramePacking() {}
278
279  Int  m_arrangementId;
280  Bool m_arrangementCancelFlag;
281  Int  m_arrangementType;
282  Bool m_quincunxSamplingFlag;
283  Int  m_contentInterpretationType;
284  Bool m_spatialFlippingFlag;
285  Bool m_frame0FlippedFlag;
286  Bool m_fieldViewsFlag;
287  Bool m_currentFrameIsFrame0Flag;
288  Bool m_frame0SelfContainedFlag;
289  Bool m_frame1SelfContainedFlag;
290  Int  m_frame0GridPositionX;
291  Int  m_frame0GridPositionY;
292  Int  m_frame1GridPositionX;
293  Int  m_frame1GridPositionY;
294  Int  m_arrangementReservedByte;
295#if L0045_PERSISTENCE_FLAGS
296  Bool m_arrangementPersistenceFlag;
297#else
298  Int  m_arrangementRepetetionPeriod;
299#endif
300  Bool m_upsampledAspectRatio;
301};
302
303class SEIDisplayOrientation : public SEI
304{
305public:
306  PayloadType payloadType() const { return DISPLAY_ORIENTATION; }
307
308  SEIDisplayOrientation()
309    : cancelFlag(true)
310#if L0045_PERSISTENCE_FLAGS
311    , persistenceFlag(0)
312#else
313    , repetitionPeriod(1)
314#endif
315    , extensionFlag(false)
316    {}
317  virtual ~SEIDisplayOrientation() {}
318
319  Bool cancelFlag;
320  Bool horFlip;
321  Bool verFlip;
322
323  UInt anticlockwiseRotation;
324#if L0045_PERSISTENCE_FLAGS
325  Bool persistenceFlag;
326#else
327  UInt repetitionPeriod;
328#endif
329  Bool extensionFlag;
330};
331
332class SEITemporalLevel0Index : public SEI
333{
334public:
335  PayloadType payloadType() const { return TEMPORAL_LEVEL0_INDEX; }
336
337  SEITemporalLevel0Index()
338    : tl0Idx(0)
339    , rapIdx(0)
340    {}
341  virtual ~SEITemporalLevel0Index() {}
342
343  UInt tl0Idx;
344  UInt rapIdx;
345};
346
347class SEIGradualDecodingRefreshInfo : public SEI
348{
349public:
350  PayloadType payloadType() const { return REGION_REFRESH_INFO; }
351
352  SEIGradualDecodingRefreshInfo()
353    : m_gdrForegroundFlag(0)
354  {}
355  virtual ~SEIGradualDecodingRefreshInfo() {}
356
357  Bool m_gdrForegroundFlag;
358};
359
360#if M0043_LAYERS_PRESENT_SEI
361class SEILayersPresent : public SEI
362{
363public:
364  PayloadType payloadType() const { return LAYERS_PRESENT; }
365
366  SEILayersPresent() {}
367  virtual ~SEILayersPresent() {}
368
369  UInt m_activeVpsId;
370  UInt m_vpsMaxLayers;
371  Bool m_layerPresentFlag[MAX_LAYERS];
372};
373#endif
374
375#if L0208_SOP_DESCRIPTION_SEI
376class SEISOPDescription : public SEI
377{
378public:
379  PayloadType payloadType() const { return SOP_DESCRIPTION; }
380
381  SEISOPDescription() {}
382  virtual ~SEISOPDescription() {}
383
384  UInt m_sopSeqParameterSetId;
385  UInt m_numPicsInSopMinus1;
386
387  UInt m_sopDescVclNaluType[MAX_NUM_PICS_IN_SOP];
388  UInt m_sopDescTemporalId[MAX_NUM_PICS_IN_SOP];
389  UInt m_sopDescStRpsIdx[MAX_NUM_PICS_IN_SOP];
390  Int m_sopDescPocDelta[MAX_NUM_PICS_IN_SOP];
391};
392#endif
393
394#if J0149_TONE_MAPPING_SEI
395class SEIToneMappingInfo : public SEI
396{
397public:
398  PayloadType payloadType() const { return TONE_MAPPING_INFO; }
399  SEIToneMappingInfo() {}
400  virtual ~SEIToneMappingInfo() {}
401
402  Int    m_toneMapId;
403  Bool   m_toneMapCancelFlag;
404  Bool   m_toneMapPersistenceFlag;
405  Int    m_codedDataBitDepth;
406  Int    m_targetBitDepth;
407  Int    m_modelId;
408  Int    m_minValue;
409  Int    m_maxValue;
410  Int    m_sigmoidMidpoint;
411  Int    m_sigmoidWidth;
412  std::vector<Int> m_startOfCodedInterval;
413  Int    m_numPivots;
414  std::vector<Int> m_codedPivotValue;
415  std::vector<Int> m_targetPivotValue;
416  Int    m_cameraIsoSpeedIdc;
417  Int    m_cameraIsoSpeedValue;
418  Int    m_exposureCompensationValueSignFlag;
419  Int    m_exposureCompensationValueNumerator;
420  Int    m_exposureCompensationValueDenomIdc;
421  Int    m_refScreenLuminanceWhite;
422  Int    m_extendedRangeWhiteLevel;
423  Int    m_nominalBlackLevelLumaCodeValue;
424  Int    m_nominalWhiteLevelLumaCodeValue;
425  Int    m_extendedWhiteLevelLumaCodeValue;
426};
427#endif
428
429typedef std::list<SEI*> SEIMessages;
430
431/// output a selection of SEI messages by payload type. Ownership stays in original message list.
432SEIMessages getSeisByType(SEIMessages &seiList, SEI::PayloadType seiType);
433
434/// remove a selection of SEI messages by payload type from the original list and return them in a new list.
435SEIMessages extractSeisByType(SEIMessages &seiList, SEI::PayloadType seiType);
436
437/// delete list of SEI messages (freeing the referenced objects)
438Void deleteSEIs (SEIMessages &seiList);
439
440#if K0180_SCALABLE_NESTING_SEI
441class SEIScalableNesting : public SEI
442{
443public:
444  PayloadType payloadType() const { return SCALABLE_NESTING; }
445
446  SEIScalableNesting() {}
447  virtual ~SEIScalableNesting()
448  {
449    if (!m_callerOwnsSEIs)
450    {
451      deleteSEIs(m_nestedSEIs);
452    }
453  }
454
455  Bool  m_bitStreamSubsetFlag;
456  Bool  m_nestingOpFlag;
457  Bool  m_defaultOpFlag;                             //value valid if m_nestingOpFlag != 0
458  UInt  m_nestingNumOpsMinus1;                       // -"-
459  UInt  m_nestingMaxTemporalIdPlus1[MAX_TLAYER];     // -"-
460  UInt  m_nestingOpIdx[MAX_NESTING_NUM_OPS];         // -"-
461
462  Bool  m_allLayersFlag;                             //value valid if m_nestingOpFlag == 0
463  UInt  m_nestingNoOpMaxTemporalIdPlus1;             //value valid if m_nestingOpFlag == 0 and m_allLayersFlag == 0
464  UInt  m_nestingNumLayersMinus1;                    //value valid if m_nestingOpFlag == 0 and m_allLayersFlag == 0
465  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
466
467  Bool  m_callerOwnsSEIs;
468  SEIMessages m_nestedSEIs;
469};
470#endif
471
472//! \}
Note: See TracBrowser for help on using the repository browser.