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

Last change on this file since 651 was 644, checked in by seregin, 11 years ago

merge with SHM-5.1-dev branch

  • Property svn:eol-style set to native
File size: 15.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
81    INTER_LAYER_CONSTRAINED_TILE_SETS    = 138
82#endif
[588]83#if SUB_BITSTREAM_PROPERTY_SEI
84   ,SUB_BITSTREAM_PROPERTY               = 139    // Final PayloadType to be defined after finalization
85#endif
[644]86#if O0164_MULTI_LAYER_HRD
87   ,BSP_NESTING                          = 140
88   ,BSP_INITIAL_ARRIVAL_TIME             = 141
89   ,BSP_HRD                              = 142
90#endif
[313]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_fullRandomAccessFlag (false)
145    , m_noParamSetUpdateFlag (false)
146    , numSpsIdsMinus1        (0)
147  {}
148  virtual ~SEIActiveParameterSets() {}
149
150  Int activeVPSId; 
151  Bool m_fullRandomAccessFlag;
152  Bool m_noParamSetUpdateFlag;
153  Int numSpsIdsMinus1;
154  std::vector<Int> activeSeqParamSetId; 
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)
[644]167#if P0138_USE_ALT_CPB_PARAMS_FLAG
168  , m_useAltCpbParamsFlagPresent(false)
169  , m_useAltCpbParamsFlag (false)
170#endif
[313]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;
[644]189#if P0138_USE_ALT_CPB_PARAMS_FLAG
190  Bool m_useAltCpbParamsFlagPresent;
191  Bool m_useAltCpbParamsFlag;
192#endif
[313]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
[588]340#if LAYERS_NOT_PRESENT_SEI
341class SEILayersNotPresent : public SEI
[313]342{
343public:
[588]344  PayloadType payloadType() const { return LAYERS_NOT_PRESENT; }
[313]345
[588]346  SEILayersNotPresent() {}
347  virtual ~SEILayersNotPresent() {}
[313]348
349  UInt m_activeVpsId;
350  UInt m_vpsMaxLayers;
[588]351  Bool m_layerNotPresentFlag[MAX_LAYERS];
[313]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_exposureCompensationValueSignFlag;
396  Int    m_exposureCompensationValueNumerator;
397  Int    m_exposureCompensationValueDenomIdc;
398  Int    m_refScreenLuminanceWhite;
399  Int    m_extendedRangeWhiteLevel;
400  Int    m_nominalBlackLevelLumaCodeValue;
401  Int    m_nominalWhiteLevelLumaCodeValue;
402  Int    m_extendedWhiteLevelLumaCodeValue;
403};
404
[442]405#if N0383_IL_CONSTRAINED_TILE_SETS_SEI
406class SEIInterLayerConstrainedTileSets : public SEI
407{
408public:
409  PayloadType payloadType() const { return INTER_LAYER_CONSTRAINED_TILE_SETS; }
410
411  SEIInterLayerConstrainedTileSets() {}
412  virtual ~SEIInterLayerConstrainedTileSets() {}
413
414  Bool m_ilAllTilesExactSampleValueMatchFlag;
415  Bool m_ilOneTilePerTileSetFlag;
416  UInt m_ilNumSetsInMessageMinus1;
417  Bool m_skippedTileSetPresentFlag;
418  UInt m_ilctsId[256];
419  UInt m_ilNumTileRectsInSetMinus1[256];
420  UInt m_ilTopLeftTileIndex[256][440];
421  UInt m_ilBottomRightTileIndex[256][440];
422  UInt m_ilcIdc[256];
423  Bool m_ilExactSampleValueMatchFlag[256];
424  UInt m_allTilesIlcIdc;
425};
426#endif
427
[588]428#if SUB_BITSTREAM_PROPERTY_SEI
429class SEISubBitstreamProperty : public SEI
430{
431public:
432  PayloadType payloadType() const { return SUB_BITSTREAM_PROPERTY; }
[442]433
[588]434  SEISubBitstreamProperty();
435  virtual ~SEISubBitstreamProperty() {}
436
437  Int  m_activeVpsId;
438  Int  m_numAdditionalSubStreams;
439  Int  m_subBitstreamMode       [MAX_SUB_STREAMS];
440  Int  m_outputLayerSetIdxToVps [MAX_SUB_STREAMS];
441  Int  m_highestSublayerId      [MAX_SUB_STREAMS];
442  Int  m_avgBitRate             [MAX_SUB_STREAMS];
443  Int  m_maxBitRate             [MAX_SUB_STREAMS];
444};
445#endif
446
[313]447typedef std::list<SEI*> SEIMessages;
448
449/// output a selection of SEI messages by payload type. Ownership stays in original message list.
450SEIMessages getSeisByType(SEIMessages &seiList, SEI::PayloadType seiType);
451
452/// remove a selection of SEI messages by payload type from the original list and return them in a new list.
453SEIMessages extractSeisByType(SEIMessages &seiList, SEI::PayloadType seiType);
454
455/// delete list of SEI messages (freeing the referenced objects)
456Void deleteSEIs (SEIMessages &seiList);
457
[644]458#if O0164_MULTI_LAYER_HRD
459
460class SEIBspNesting : public SEI
461{
462public:
463  PayloadType payloadType() const { return BSP_NESTING; }
464
465  SEIBspNesting() {}
466  virtual ~SEIBspNesting()
467  {
468    if (!m_callerOwnsSEIs)
469    {
470      deleteSEIs(m_nestedSEIs);
471    }
472  }
473
474  Int  m_bspIdx;
475  Bool  m_callerOwnsSEIs;
476  SEIMessages m_nestedSEIs;
477};
478
479class SEIBspInitialArrivalTime : public SEI
480{
481public:
482  PayloadType payloadType() const { return BSP_INITIAL_ARRIVAL_TIME; }
483
484  SEIBspInitialArrivalTime () {}
485  virtual ~SEIBspInitialArrivalTime () {}
486
487  UInt m_nalInitialArrivalDelay[256];
488  UInt m_vclInitialArrivalDelay[256];
489};
490
491class SEIBspHrd : public SEI
492{
493public:
494  PayloadType payloadType() const { return BSP_HRD; }
495
496  SEIBspHrd () {}
497  virtual ~SEIBspHrd () {}
498
499  UInt m_seiNumBspHrdParametersMinus1;
500  Bool m_seiBspCprmsPresentFlag[MAX_VPS_LAYER_SETS_PLUS1];
501  UInt m_seiNumBitstreamPartitionsMinus1[MAX_VPS_LAYER_SETS_PLUS1];
502  Bool m_seiLayerInBspFlag[MAX_VPS_LAYER_SETS_PLUS1][8][MAX_LAYERS];
503  UInt m_seiNumBspSchedCombinationsMinus1[MAX_VPS_LAYER_SETS_PLUS1];
504  UInt m_seiBspCombHrdIdx[MAX_VPS_LAYER_SETS_PLUS1][16][16];
505  UInt m_seiBspCombScheddx[MAX_VPS_LAYER_SETS_PLUS1][16][16];
506  UInt m_vpsMaxLayers;
507  Bool m_layerIdIncludedFlag[MAX_VPS_LAYER_SETS_PLUS1][MAX_VPS_LAYER_ID_PLUS1];
508
509  TComHRD *hrd;
510};
511
512#endif
513
[313]514class SEIScalableNesting : public SEI
515{
516public:
517  PayloadType payloadType() const { return SCALABLE_NESTING; }
518
519  SEIScalableNesting() {}
520  virtual ~SEIScalableNesting()
521  {
522    if (!m_callerOwnsSEIs)
523    {
524      deleteSEIs(m_nestedSEIs);
525    }
526  }
527
528  Bool  m_bitStreamSubsetFlag;
529  Bool  m_nestingOpFlag;
530  Bool  m_defaultOpFlag;                             //value valid if m_nestingOpFlag != 0
531  UInt  m_nestingNumOpsMinus1;                       // -"-
532  UInt  m_nestingMaxTemporalIdPlus1[MAX_TLAYER];     // -"-
533  UInt  m_nestingOpIdx[MAX_NESTING_NUM_OPS];         // -"-
534
535  Bool  m_allLayersFlag;                             //value valid if m_nestingOpFlag == 0
536  UInt  m_nestingNoOpMaxTemporalIdPlus1;             //value valid if m_nestingOpFlag == 0 and m_allLayersFlag == 0
537  UInt  m_nestingNumLayersMinus1;                    //value valid if m_nestingOpFlag == 0 and m_allLayersFlag == 0
538  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
539
540  Bool  m_callerOwnsSEIs;
541  SEIMessages m_nestedSEIs;
542};
543
544//! \}
Note: See TracBrowser for help on using the repository browser.