HEVC Test Model (HM)  HM-16.18
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SEI.cpp
Go to the documentation of this file.
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-2017, 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 
38 #include "CommonDef.h"
39 #include "SEI.h"
40 #include <iostream>
41 
43 {
44  SEIMessages result;
45 
46  for (SEIMessages::iterator it=seiList.begin(); it!=seiList.end(); it++)
47  {
48  if ((*it)->payloadType() == seiType)
49  {
50  result.push_back(*it);
51  }
52  }
53  return result;
54 }
55 
57 {
58  SEIMessages result;
59 
60  SEIMessages::iterator it=seiList.begin();
61  while ( it!=seiList.end() )
62  {
63  if ((*it)->payloadType() == seiType)
64  {
65  result.push_back(*it);
66  it = seiList.erase(it);
67  }
68  else
69  {
70  it++;
71  }
72  }
73  return result;
74 }
75 
76 
78 {
79  for (SEIMessages::iterator it=seiList.begin(); it!=seiList.end(); it++)
80  {
81  delete (*it);
82  }
83  seiList.clear();
84 }
85 
87 {
98 }
99 
101 {
102  target.m_picStruct = m_picStruct;
105 
112 
115 }
116 #if RNSEI
117 std::ostream& operator<<(std::ostream &os, RNSEIWindow const &region)
118 {
119  os << region.getRegionId() << " " << region.getWindowLeftOffset() <<
120  region.getWindowRightOffset() << " " << region.getWindowTopOffset() << " " <<
121  region.getWindowBottomOffset() << "\n";
122  return os;
123 }
125 {
126  // Delete SEI messages
127  for(Int i = 0; i < m_rnSeiMessages.size(); i++)
128  {
129  delete m_rnSeiMessages[i].second;
130  }
131 }
133 {
134  // Check if no conflict with region IDs of regions
135  const RNSEIWindowVec newRegions = regSEI->getRegions();
136  RNSEIWindowVec regionsToAdd;
137  std::vector<UInt> listOfIndices;
138 
139  // Loop through regions to add
140  for(RNSEIWindowVec::const_iterator iterNew = newRegions.begin();
141  iterNew != newRegions.end(); iterNew++)
142  {
143  Bool addNewRegion = m_regions.empty() ? true : false;
144  Bool foundRegion = false;
145  // Loop through regions already present
146  for(RNSEIWindowVec::const_iterator iterRef = m_regions.begin();
147  !foundRegion && iterRef != m_regions.end(); iterRef++)
148  {
149  if( (*iterNew) == (*iterRef) ) // Check if same region present
150  {
151  listOfIndices.push_back(iterRef - m_regions.begin()); // Add index
152  foundRegion = true;
153  }
154  else if( iterRef->checkSameID(*iterNew) ) // Check if there is a region ID class
155  {
156  // Two regions are different yet have same ID value; violates constraint
157  std::cout << "Two different regions have the same ID; please check.\n";
158  std::cout << "Region:" << (*iterNew) << "\n";
159  std::cout << "Region:" << (*iterRef) << "\n";
160  exit(1);
161  }
162  }
163  addNewRegion = !foundRegion;
164 
165  if(addNewRegion)
166  {
167  // Index is current size of the m_regions;
168  listOfIndices.push_back(m_regions.size());
169  m_regions.push_back((*iterNew));
170  }
171  }
172  if(listOfIndices.empty())
173  {
174  std::cout << "Unable to add regions to the regional nesting SEI.\n";
175  exit(1);
176  }
177  addRegionalSEI(listOfIndices, regSEI->getSEI());
178 }
179 #endif
180 
181 // Static member
183 {
184  switch (payloadType)
185  {
186  case SEI::BUFFERING_PERIOD: return "Buffering period";
187  case SEI::PICTURE_TIMING: return "Picture timing";
188  case SEI::PAN_SCAN_RECT: return "Pan-scan rectangle";
189  case SEI::FILLER_PAYLOAD: return "Filler payload";
190  case SEI::USER_DATA_REGISTERED_ITU_T_T35: return "User data registered";
191  case SEI::USER_DATA_UNREGISTERED: return "User data unregistered";
192  case SEI::RECOVERY_POINT: return "Recovery point";
193  case SEI::SCENE_INFO: return "Scene information";
194  case SEI::PICTURE_SNAPSHOT: return "Picture snapshot";
195  case SEI::PROGRESSIVE_REFINEMENT_SEGMENT_START: return "Progressive refinement segment start";
196  case SEI::PROGRESSIVE_REFINEMENT_SEGMENT_END: return "Progressive refinement segment end";
197  case SEI::FILM_GRAIN_CHARACTERISTICS: return "Film grain characteristics";
198  case SEI::POST_FILTER_HINT: return "Post filter hint";
199  case SEI::TONE_MAPPING_INFO: return "Tone mapping information";
200  case SEI::KNEE_FUNCTION_INFO: return "Knee function information";
201  case SEI::FRAME_PACKING: return "Frame packing arrangement";
202  case SEI::DISPLAY_ORIENTATION: return "Display orientation";
203  case SEI::GREEN_METADATA: return "Green metadata information";
204  case SEI::SOP_DESCRIPTION: return "Structure of pictures information";
205  case SEI::ACTIVE_PARAMETER_SETS: return "Active parameter sets";
206  case SEI::DECODING_UNIT_INFO: return "Decoding unit information";
207  case SEI::TEMPORAL_LEVEL0_INDEX: return "Temporal sub-layer zero index";
208  case SEI::DECODED_PICTURE_HASH: return "Decoded picture hash";
209  case SEI::SCALABLE_NESTING: return "Scalable nesting";
210  case SEI::REGION_REFRESH_INFO: return "Region refresh information";
211  case SEI::NO_DISPLAY: return "No display";
212  case SEI::TIME_CODE: return "Time code";
213  case SEI::MASTERING_DISPLAY_COLOUR_VOLUME: return "Mastering display colour volume";
214  case SEI::SEGM_RECT_FRAME_PACKING: return "Segmented rectangular frame packing arrangement";
215  case SEI::TEMP_MOTION_CONSTRAINED_TILE_SETS: return "Temporal motion constrained tile sets";
216  case SEI::CHROMA_RESAMPLING_FILTER_HINT: return "Chroma sampling filter hint";
217  case SEI::COLOUR_REMAPPING_INFO: return "Colour remapping info";
218  case SEI::DEINTERLACE_FIELD_IDENTIFICATION: return "Deinterlace field identification";
219  case SEI::CONTENT_LIGHT_LEVEL_INFO: return "Content light level info";
220  case SEI::DEPENDENT_RAP_INDICATION: return "Dependent RAP indication";
221  case SEI::CODED_REGION_COMPLETION: return "Coded region completion";
222  case SEI::ALTERNATIVE_TRANSFER_CHARACTERISTICS: return "Alternative transfer characteristics";
223  case SEI::AMBIENT_VIEWING_ENVIRONMENT: return "Ambient viewing environment";
224 #if CCV_SEI_MESSAGE
225  case SEI::CONTENT_COLOUR_VOLUME: return "Content Colour Volume";
226 #endif
227 #if ERP_SR_OV_SEI_MESSAGE
228  case SEI::EQUIRECTANGULAR_PROJECTION: return "Equirectangular projection";
229  case SEI::SPHERE_ROTATION: return "Sphere rotation";
230  case SEI::OMNI_VIEWPORT: return "Omni viewport";
231 #endif
232 #if CMP_SEI_MESSAGE
233  case SEI::CUBEMAP_PROJECTION: return "Cubemap projection";
234 #endif
235 #if RWP_SEI_MESSAGE
236  case SEI::REGION_WISE_PACKING: return "Region wise packing information";
237 #endif
238 #if RNSEI
239  case SEI::REGIONAL_NESTING: return "Regional nesting";
240 #endif
241  default: return "Unknown";
242  }
243 }
RNSEIWindowVec m_regions
Definition: SEI.h:1073
PayloadType
Definition: SEI.h:55
Int getWindowTopOffset() const
Definition: TypeDef.h:929
UInt m_initialCpbRemovalDelay[MAX_CPB_CNT][2]
Definition: SEI.h:158
Defines version information, constants and small in-line functions.
void Void
Definition: TypeDef.h:203
UInt m_dpbDelayOffset
Definition: SEI.h:157
void copyTo(SEIBufferingPeriod &target)
Definition: SEI.cpp:86
Int getWindowBottomOffset() const
Definition: TypeDef.h:931
void copyTo(SEIPictureTiming &target)
Definition: SEI.cpp:100
Int getWindowLeftOffset() const
Definition: TypeDef.h:925
Void deleteSEIs(SEIMessages &seiList)
delete list of SEI messages (freeing the referenced objects)
Definition: SEI.cpp:77
SEIMessages getSeisByType(SEIMessages &seiList, SEI::PayloadType seiType)
output a selection of SEI messages by payload type. Ownership stays in original message list...
Definition: SEI.cpp:42
UInt m_picDpbOutputDelay
Definition: SEI.h:188
Bool m_rapCpbParamsPresentFlag
Definition: SEI.h:155
UInt m_cpbDelayOffset
Definition: SEI.h:156
std::vector< UInt > m_numNalusInDuMinus1
Definition: SEI.h:193
static const TChar * getSEIMessageString(SEI::PayloadType payloadType)
Definition: SEI.cpp:182
SEIMessages extractSeisByType(SEIMessages &seiList, SEI::PayloadType seiType)
remove a selection of SEI messages by payload type from the original list and return them in a new li...
Definition: SEI.cpp:56
char TChar
Definition: TypeDef.h:206
UInt m_picStruct
Definition: SEI.h:183
std::ostream & operator<<(std::ostream &left, const RuntimeError &right)
Convenient formatted output operator that just outputs the what string.
Definition: RuntimeError.h:71
std::vector< std::pair< std::vector< UInt >, SEI * > > m_rnSeiMessages
Definition: SEI.h:1074
UInt m_sourceScanType
Definition: SEI.h:184
bool Bool
Definition: TypeDef.h:204
const RNSEIWindowVec & getRegions()
Definition: SEI.h:1030
SEI * getSEI()
Definition: SEI.h:1028
UInt m_numDecodingUnitsMinus1
Definition: SEI.h:190
UInt m_bpSeqParameterSetId
Definition: SEI.h:154
UInt m_initialAltCpbRemovalDelayOffset[MAX_CPB_CNT][2]
Definition: SEI.h:161
UInt m_auCpbRemovalDelayDelta
Definition: SEI.h:163
Int getRegionId() const
Definition: TypeDef.h:960
UInt m_initialCpbRemovalDelayOffset[MAX_CPB_CNT][2]
Definition: SEI.h:159
UInt m_duCommonCpbRemovalDelayMinus1
Definition: SEI.h:192
std::vector< RNSEIWindow > RNSEIWindowVec
Definition: TypeDef.h:979
UInt m_initialAltCpbRemovalDelay[MAX_CPB_CNT][2]
Definition: SEI.h:160
Bool m_duCommonCpbRemovalDelayFlag
Definition: SEI.h:191
std::vector< UInt > m_duCpbRemovalDelayMinus1
Definition: SEI.h:194
UInt m_auCpbRemovalDelay
Definition: SEI.h:187
std::list< SEI * > SEIMessages
Definition: SEI.h:123
Void addRegionalSEI(std::vector< UInt > listInd, SEI *sei)
Definition: SEI.h:1066
int Int
Definition: TypeDef.h:211
Bool m_concatenationFlag
Definition: SEI.h:162
Int getWindowRightOffset() const
Definition: TypeDef.h:927
UInt m_picDpbOutputDuDelay
Definition: SEI.h:189
Bool m_duplicateFlag
Definition: SEI.h:185