source: 3DVCSoftware/branches/HTM-14.1-update-dev0/source/Lib/TLibCommon/SEI.h @ 1200

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

Update to HM-16.5.
Starting point for further re-activation of 3D-tools.

Includes:

active:

  • MV-HEVC
  • 3D-HLS (apart from DLT)
  • VSO

inactive:

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