source: 3DVCSoftware/branches/HTM-15.1-dev0/source/Lib/TLibCommon/SEI.h @ 1327

Last change on this file since 1327 was 1313, checked in by tech, 9 years ago

Merged 14.1-update-dev1@1312.

  • Property svn:eol-style set to native
File size: 17.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-2015, 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#ifndef __SEI__
35#define __SEI__
36
37#pragma once
38#include <list>
39#include <vector>
40#include <cstring>
41
42#include "CommonDef.h"
43#include "libmd5/MD5.h"
44//! \ingroup TLibCommon
45//! \{
46class TComSPS;
47
48/**
49 * Abstract class representing an SEI message with lightweight RTTI.
50 */
51class SEI
52{
53public:
54  enum PayloadType
55  {
56    BUFFERING_PERIOD                     = 0,
57    PICTURE_TIMING                       = 1,
58    PAN_SCAN_RECT                        = 2,
59    FILLER_PAYLOAD                       = 3,
60    USER_DATA_REGISTERED_ITU_T_T35       = 4,
61    USER_DATA_UNREGISTERED               = 5,
62    RECOVERY_POINT                       = 6,
63    SCENE_INFO                           = 9,
64    FULL_FRAME_SNAPSHOT                  = 15,
65    PROGRESSIVE_REFINEMENT_SEGMENT_START = 16,
66    PROGRESSIVE_REFINEMENT_SEGMENT_END   = 17,
67    FILM_GRAIN_CHARACTERISTICS           = 19,
68    POST_FILTER_HINT                     = 22,
69    TONE_MAPPING_INFO                    = 23,
70    FRAME_PACKING                        = 45,
71    DISPLAY_ORIENTATION                  = 47,
72    SOP_DESCRIPTION                      = 128,
73    ACTIVE_PARAMETER_SETS                = 129,
74    DECODING_UNIT_INFO                   = 130,
75    TEMPORAL_LEVEL0_INDEX                = 131,
76    DECODED_PICTURE_HASH                 = 132,
77    SCALABLE_NESTING                     = 133,
78    REGION_REFRESH_INFO                  = 134,
79    NO_DISPLAY                           = 135,
80    TIME_CODE                            = 136,
81    MASTERING_DISPLAY_COLOUR_VOLUME      = 137,
82    SEGM_RECT_FRAME_PACKING              = 138,
83    TEMP_MOTION_CONSTRAINED_TILE_SETS    = 139,
84    CHROMA_SAMPLING_FILTER_HINT          = 140,
85    KNEE_FUNCTION_INFO                   = 141
86#if NH_MV
87    ,SUB_BITSTREAM_PROPERTY              = 164
88#endif
89
90  };
91
92  SEI() {}
93  virtual ~SEI() {}
94
95  static const Char *getSEIMessageString(SEI::PayloadType payloadType);
96
97  virtual PayloadType payloadType() const = 0;
98};
99
100static const UInt ISO_IEC_11578_LEN=16;
101
102class SEIuserDataUnregistered : public SEI
103{
104public:
105  PayloadType payloadType() const { return USER_DATA_UNREGISTERED; }
106
107  SEIuserDataUnregistered()
108    : userData(0)
109    {}
110
111  virtual ~SEIuserDataUnregistered()
112  {
113    delete userData;
114  }
115
116  UChar uuid_iso_iec_11578[ISO_IEC_11578_LEN];
117  UInt  userDataLength;
118  UChar *userData;
119};
120
121class SEIDecodedPictureHash : public SEI
122{
123public:
124  PayloadType payloadType() const { return DECODED_PICTURE_HASH; }
125
126  SEIDecodedPictureHash() {}
127  virtual ~SEIDecodedPictureHash() {}
128
129  enum Method
130  {
131    MD5,
132    CRC,
133    CHECKSUM,
134    RESERVED,
135  } method;
136
137  TComPictureHash m_pictureHash;
138};
139
140class SEIActiveParameterSets : public SEI
141{
142public:
143  PayloadType payloadType() const { return ACTIVE_PARAMETER_SETS; }
144
145  SEIActiveParameterSets()
146    : activeVPSId            (0)
147    , m_selfContainedCvsFlag (false)
148    , m_noParameterSetUpdateFlag (false)
149    , numSpsIdsMinus1        (0)
150  {}
151  virtual ~SEIActiveParameterSets() {}
152
153  Int activeVPSId;
154  Bool m_selfContainedCvsFlag;
155  Bool m_noParameterSetUpdateFlag;
156  Int numSpsIdsMinus1;
157  std::vector<Int> activeSeqParameterSetId; 
158};
159
160class SEIBufferingPeriod : public SEI
161{
162public:
163  PayloadType payloadType() const { return BUFFERING_PERIOD; }
164  void copyTo (SEIBufferingPeriod& target);
165
166  SEIBufferingPeriod()
167  : m_bpSeqParameterSetId (0)
168  , m_rapCpbParamsPresentFlag (false)
169  , m_cpbDelayOffset      (0)
170  , m_dpbDelayOffset      (0)
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  UInt m_cpbDelayOffset;
182  UInt 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};
190class SEIPictureTiming : public SEI
191{
192public:
193  PayloadType payloadType() const { return PICTURE_TIMING; }
194  void copyTo (SEIPictureTiming& target);
195
196  SEIPictureTiming()
197  : m_picStruct               (0)
198  , m_sourceScanType          (0)
199  , m_duplicateFlag           (false)
200  , m_picDpbOutputDuDelay     (0)
201  {}
202  virtual ~SEIPictureTiming()
203  {
204  }
205
206  UInt  m_picStruct;
207  UInt  m_sourceScanType;
208  Bool  m_duplicateFlag;
209
210  UInt  m_auCpbRemovalDelay;
211  UInt  m_picDpbOutputDelay;
212  UInt  m_picDpbOutputDuDelay;
213  UInt  m_numDecodingUnitsMinus1;
214  Bool  m_duCommonCpbRemovalDelayFlag;
215  UInt  m_duCommonCpbRemovalDelayMinus1;
216  std::vector<UInt> m_numNalusInDuMinus1;
217  std::vector<UInt> m_duCpbRemovalDelayMinus1;
218};
219
220class SEIDecodingUnitInfo : public SEI
221{
222public:
223  PayloadType payloadType() const { return DECODING_UNIT_INFO; }
224
225  SEIDecodingUnitInfo()
226    : m_decodingUnitIdx(0)
227    , m_duSptCpbRemovalDelay(0)
228    , m_dpbOutputDuDelayPresentFlag(false)
229    , m_picSptDpbOutputDuDelay(0)
230  {}
231  virtual ~SEIDecodingUnitInfo() {}
232  Int m_decodingUnitIdx;
233  Int m_duSptCpbRemovalDelay;
234  Bool m_dpbOutputDuDelayPresentFlag;
235  Int m_picSptDpbOutputDuDelay;
236};
237
238class SEIRecoveryPoint : public SEI
239{
240public:
241  PayloadType payloadType() const { return RECOVERY_POINT; }
242
243  SEIRecoveryPoint() {}
244  virtual ~SEIRecoveryPoint() {}
245
246  Int  m_recoveryPocCnt;
247  Bool m_exactMatchingFlag;
248  Bool m_brokenLinkFlag;
249};
250
251class SEIFramePacking : public SEI
252{
253public:
254  PayloadType payloadType() const { return FRAME_PACKING; }
255
256  SEIFramePacking() {}
257  virtual ~SEIFramePacking() {}
258
259  Int  m_arrangementId;
260  Bool m_arrangementCancelFlag;
261  Int  m_arrangementType;
262  Bool m_quincunxSamplingFlag;
263  Int  m_contentInterpretationType;
264  Bool m_spatialFlippingFlag;
265  Bool m_frame0FlippedFlag;
266  Bool m_fieldViewsFlag;
267  Bool m_currentFrameIsFrame0Flag;
268  Bool m_frame0SelfContainedFlag;
269  Bool m_frame1SelfContainedFlag;
270  Int  m_frame0GridPositionX;
271  Int  m_frame0GridPositionY;
272  Int  m_frame1GridPositionX;
273  Int  m_frame1GridPositionY;
274  Int  m_arrangementReservedByte;
275  Bool m_arrangementPersistenceFlag;
276  Bool m_upsampledAspectRatio;
277};
278
279class SEISegmentedRectFramePacking : public SEI
280{
281public:
282  PayloadType payloadType() const { return SEGM_RECT_FRAME_PACKING; }
283
284  SEISegmentedRectFramePacking() {}
285  virtual ~SEISegmentedRectFramePacking() {}
286
287  Bool m_arrangementCancelFlag;
288  Int  m_contentInterpretationType;
289  Bool m_arrangementPersistenceFlag;
290};
291
292class SEIDisplayOrientation : public SEI
293{
294public:
295  PayloadType payloadType() const { return DISPLAY_ORIENTATION; }
296
297  SEIDisplayOrientation()
298    : cancelFlag(true)
299    , persistenceFlag(0)
300    , extensionFlag(false)
301    {}
302  virtual ~SEIDisplayOrientation() {}
303
304  Bool cancelFlag;
305  Bool horFlip;
306  Bool verFlip;
307
308  UInt anticlockwiseRotation;
309  Bool persistenceFlag;
310  Bool extensionFlag;
311};
312
313class SEITemporalLevel0Index : public SEI
314{
315public:
316  PayloadType payloadType() const { return TEMPORAL_LEVEL0_INDEX; }
317
318  SEITemporalLevel0Index()
319    : tl0Idx(0)
320    , rapIdx(0)
321    {}
322  virtual ~SEITemporalLevel0Index() {}
323
324  UInt tl0Idx;
325  UInt rapIdx;
326};
327
328class SEIGradualDecodingRefreshInfo : public SEI
329{
330public:
331  PayloadType payloadType() const { return REGION_REFRESH_INFO; }
332
333  SEIGradualDecodingRefreshInfo()
334    : m_gdrForegroundFlag(0)
335  {}
336  virtual ~SEIGradualDecodingRefreshInfo() {}
337
338  Bool m_gdrForegroundFlag;
339};
340
341class SEINoDisplay : public SEI
342{
343public:
344  PayloadType payloadType() const { return NO_DISPLAY; }
345
346  SEINoDisplay()
347    : m_noDisplay(false)
348  {}
349  virtual ~SEINoDisplay() {}
350
351  Bool m_noDisplay;
352};
353
354class SEISOPDescription : public SEI
355{
356public:
357  PayloadType payloadType() const { return SOP_DESCRIPTION; }
358
359  SEISOPDescription() {}
360  virtual ~SEISOPDescription() {}
361
362  UInt m_sopSeqParameterSetId;
363  UInt m_numPicsInSopMinus1;
364
365  UInt m_sopDescVclNaluType[MAX_NUM_PICS_IN_SOP];
366  UInt m_sopDescTemporalId[MAX_NUM_PICS_IN_SOP];
367  UInt m_sopDescStRpsIdx[MAX_NUM_PICS_IN_SOP];
368  Int m_sopDescPocDelta[MAX_NUM_PICS_IN_SOP];
369};
370
371class SEIToneMappingInfo : public SEI
372{
373public:
374  PayloadType payloadType() const { return TONE_MAPPING_INFO; }
375  SEIToneMappingInfo() {}
376  virtual ~SEIToneMappingInfo() {}
377
378  Int    m_toneMapId;
379  Bool   m_toneMapCancelFlag;
380  Bool   m_toneMapPersistenceFlag;
381  Int    m_codedDataBitDepth;
382  Int    m_targetBitDepth;
383  Int    m_modelId;
384  Int    m_minValue;
385  Int    m_maxValue;
386  Int    m_sigmoidMidpoint;
387  Int    m_sigmoidWidth;
388  std::vector<Int> m_startOfCodedInterval;
389  Int    m_numPivots;
390  std::vector<Int> m_codedPivotValue;
391  std::vector<Int> m_targetPivotValue;
392  Int    m_cameraIsoSpeedIdc;
393  Int    m_cameraIsoSpeedValue;
394  Int    m_exposureIndexIdc;
395  Int    m_exposureIndexValue;
396  Bool   m_exposureCompensationValueSignFlag;
397  Int    m_exposureCompensationValueNumerator;
398  Int    m_exposureCompensationValueDenomIdc;
399  Int    m_refScreenLuminanceWhite;
400  Int    m_extendedRangeWhiteLevel;
401  Int    m_nominalBlackLevelLumaCodeValue;
402  Int    m_nominalWhiteLevelLumaCodeValue;
403  Int    m_extendedWhiteLevelLumaCodeValue;
404};
405
406class SEIKneeFunctionInfo : public SEI
407{
408public:
409  PayloadType payloadType() const { return KNEE_FUNCTION_INFO; }
410  SEIKneeFunctionInfo() {}
411  virtual ~SEIKneeFunctionInfo() {}
412
413  Int   m_kneeId;
414  Bool  m_kneeCancelFlag;
415  Bool  m_kneePersistenceFlag;
416  Int   m_kneeInputDrange;
417  Int   m_kneeInputDispLuminance;
418  Int   m_kneeOutputDrange;
419  Int   m_kneeOutputDispLuminance;
420  Int   m_kneeNumKneePointsMinus1;
421  std::vector<Int> m_kneeInputKneePoint;
422  std::vector<Int> m_kneeOutputKneePoint;
423};
424
425class SEIChromaSamplingFilterHint : public SEI
426{
427public:
428  PayloadType payloadType() const {return CHROMA_SAMPLING_FILTER_HINT;}
429  SEIChromaSamplingFilterHint() {}
430  virtual ~SEIChromaSamplingFilterHint() {
431    if(m_verChromaFilterIdc == 1)
432    {
433      for(Int i = 0; i < m_numVerticalFilters; i ++)
434      {
435        free(m_verFilterCoeff[i]);
436      }
437      free(m_verFilterCoeff);
438      free(m_verTapLengthMinus1);
439    }
440    if(m_horChromaFilterIdc == 1)
441    {
442      for(Int i = 0; i < m_numHorizontalFilters; i ++)
443      {
444        free(m_horFilterCoeff[i]);
445      }
446      free(m_horFilterCoeff);
447      free(m_horTapLengthMinus1);
448    }
449  }
450
451  Int   m_verChromaFilterIdc;
452  Int   m_horChromaFilterIdc;
453  Bool  m_verFilteringProcessFlag;
454  Int   m_targetFormatIdc;
455  Bool  m_perfectReconstructionFlag;
456  Int   m_numVerticalFilters;
457  Int*  m_verTapLengthMinus1;
458  Int** m_verFilterCoeff;
459  Int   m_numHorizontalFilters;
460  Int*  m_horTapLengthMinus1;
461  Int** m_horFilterCoeff;
462};
463
464class SEIMasteringDisplayColourVolume : public SEI
465{
466public:
467    PayloadType payloadType() const { return MASTERING_DISPLAY_COLOUR_VOLUME; }
468    SEIMasteringDisplayColourVolume() {}
469    virtual ~SEIMasteringDisplayColourVolume(){}
470   
471    TComSEIMasteringDisplay values;
472};
473
474#if NH_MV
475class SEISubBitstreamProperty : public SEI
476{
477public:
478  PayloadType payloadType() const { return SUB_BITSTREAM_PROPERTY; }
479
480  SEISubBitstreamProperty():   m_activeVpsId(-1), m_numAdditionalSubStreams(0) {}
481  virtual ~SEISubBitstreamProperty() {}
482
483  Int  m_activeVpsId;
484  Int  m_numAdditionalSubStreams;
485  std::vector<Int>  m_subBitstreamMode;
486  std::vector<Int>  m_outputLayerSetIdxToVps;
487  std::vector<Int>  m_highestSublayerId;
488  std::vector<Int>  m_avgBitRate;
489  std::vector<Int>  m_maxBitRate;
490};
491#endif
492
493typedef std::list<SEI*> SEIMessages;
494
495/// output a selection of SEI messages by payload type. Ownership stays in original message list.
496SEIMessages getSeisByType(SEIMessages &seiList, SEI::PayloadType seiType);
497
498/// remove a selection of SEI messages by payload type from the original list and return them in a new list.
499SEIMessages extractSeisByType(SEIMessages &seiList, SEI::PayloadType seiType);
500
501/// delete list of SEI messages (freeing the referenced objects)
502Void deleteSEIs (SEIMessages &seiList);
503
504class SEIScalableNesting : public SEI
505{
506public:
507  PayloadType payloadType() const { return SCALABLE_NESTING; }
508
509  SEIScalableNesting() {}
510
511  virtual ~SEIScalableNesting()
512  {
513    deleteSEIs(m_nestedSEIs);
514  }
515
516  Bool  m_bitStreamSubsetFlag;
517  Bool  m_nestingOpFlag;
518  Bool  m_defaultOpFlag;                             //value valid if m_nestingOpFlag != 0
519  UInt  m_nestingNumOpsMinus1;                       // -"-
520  UInt  m_nestingMaxTemporalIdPlus1[MAX_TLAYER];     // -"-
521  UInt  m_nestingOpIdx[MAX_NESTING_NUM_OPS];         // -"-
522
523  Bool  m_allLayersFlag;                             //value valid if m_nestingOpFlag == 0
524  UInt  m_nestingNoOpMaxTemporalIdPlus1;             //value valid if m_nestingOpFlag == 0 and m_allLayersFlag == 0
525  UInt  m_nestingNumLayersMinus1;                    //value valid if m_nestingOpFlag == 0 and m_allLayersFlag == 0
526  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 UChar values
527
528  SEIMessages m_nestedSEIs;
529};
530
531class SEITimeCode : public SEI
532{
533public:
534  PayloadType payloadType() const { return TIME_CODE; }
535  SEITimeCode() {}
536  virtual ~SEITimeCode(){}
537
538  UInt numClockTs;
539  TComSEITimeSet timeSetArray[MAX_TIMECODE_SEI_SETS];
540};
541
542//definition according to P1005_v1;
543class SEITempMotionConstrainedTileSets: public SEI
544{
545  struct TileSetData
546  {
547    protected:
548      std::vector<Int> m_top_left_tile_index;  //[tileSetIdx][tileIdx];
549      std::vector<Int> m_bottom_right_tile_index;
550
551    public:
552      Int     m_mcts_id; 
553      Bool    m_display_tile_set_flag;
554      Int     m_num_tile_rects_in_set; //_minus1;
555      Bool    m_exact_sample_value_match_flag;
556      Bool    m_mcts_tier_level_idc_present_flag;
557      Bool    m_mcts_tier_flag;
558      Int     m_mcts_level_idc;
559
560      Void setNumberOfTileRects(const Int number)
561      {
562        m_top_left_tile_index    .resize(number);
563        m_bottom_right_tile_index.resize(number);
564      }
565
566      Int  getNumberOfTileRects() const
567      {
568        assert(m_top_left_tile_index.size() == m_bottom_right_tile_index.size());
569        return Int(m_top_left_tile_index.size());
570      }
571
572            Int &topLeftTileIndex    (const Int tileRectIndex)       { return m_top_left_tile_index    [tileRectIndex]; }
573            Int &bottomRightTileIndex(const Int tileRectIndex)       { return m_bottom_right_tile_index[tileRectIndex]; }
574      const Int &topLeftTileIndex    (const Int tileRectIndex) const { return m_top_left_tile_index    [tileRectIndex]; }
575      const Int &bottomRightTileIndex(const Int tileRectIndex) const { return m_bottom_right_tile_index[tileRectIndex]; }
576  };
577
578protected:
579  std::vector<TileSetData> m_tile_set_data;
580
581public:
582
583  Bool    m_mc_all_tiles_exact_sample_value_match_flag;
584  Bool    m_each_tile_one_tile_set_flag;
585  Bool    m_limited_tile_set_display_flag;
586  Bool    m_max_mcs_tier_level_idc_present_flag;
587  Bool    m_max_mcts_tier_flag;
588  Int     m_max_mcts_level_idc;
589
590  PayloadType payloadType() const { return TEMP_MOTION_CONSTRAINED_TILE_SETS; }
591
592  Void setNumberOfTileSets(const Int number)       { m_tile_set_data.resize(number);     }
593  Int  getNumberOfTileSets()                 const { return Int(m_tile_set_data.size()); }
594
595        TileSetData &tileSetData (const Int index)       { return m_tile_set_data[index]; }
596  const TileSetData &tileSetData (const Int index) const { return m_tile_set_data[index]; }
597
598};
599
600#endif
601
602//! \}
Note: See TracBrowser for help on using the repository browser.