source: SHVCSoftware/branches/SHM-dev/source/Lib/TLibCommon/SEI.cpp @ 1348

Last change on this file since 1348 was 1286, checked in by seregin, 9 years ago

port rev 4321

  • Property svn:eol-style set to native
File size: 11.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-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/** \file     SEI.cpp
35    \brief    helper functions for SEI handling
36*/
37
38#include "CommonDef.h"
39#include "SEI.h"
40
41SEIMessages getSeisByType(SEIMessages &seiList, SEI::PayloadType seiType)
42{
43  SEIMessages result;
44
45  for (SEIMessages::iterator it=seiList.begin(); it!=seiList.end(); it++)
46  {
47    if ((*it)->payloadType() == seiType)
48    {
49      result.push_back(*it);
50    }
51  }
52  return result;
53}
54
55SEIMessages extractSeisByType(SEIMessages &seiList, SEI::PayloadType seiType)
56{
57  SEIMessages result;
58
59  SEIMessages::iterator it=seiList.begin();
60  while ( it!=seiList.end() )
61  {
62    if ((*it)->payloadType() == seiType)
63    {
64      result.push_back(*it);
65      it = seiList.erase(it);
66    }
67    else
68    {
69      it++;
70    }
71  }
72  return result;
73}
74
75
76Void deleteSEIs (SEIMessages &seiList)
77{
78  for (SEIMessages::iterator it=seiList.begin(); it!=seiList.end(); it++)
79  {
80    delete (*it);
81  }
82  seiList.clear();
83}
84
85void SEIBufferingPeriod::copyTo (SEIBufferingPeriod& target)
86{
87  target.m_bpSeqParameterSetId = m_bpSeqParameterSetId;
88  target.m_rapCpbParamsPresentFlag = m_rapCpbParamsPresentFlag;
89  target.m_cpbDelayOffset = m_cpbDelayOffset;
90  target.m_dpbDelayOffset = m_dpbDelayOffset;
91  target.m_concatenationFlag = m_concatenationFlag;
92  target.m_auCpbRemovalDelayDelta = m_auCpbRemovalDelayDelta;
93  ::memcpy(target.m_initialCpbRemovalDelay, m_initialCpbRemovalDelay, sizeof(m_initialCpbRemovalDelay));
94  ::memcpy(target.m_initialCpbRemovalDelayOffset, m_initialCpbRemovalDelayOffset, sizeof(m_initialCpbRemovalDelayOffset));
95  ::memcpy(target.m_initialAltCpbRemovalDelay, m_initialAltCpbRemovalDelay, sizeof(m_initialAltCpbRemovalDelay));
96  ::memcpy(target.m_initialAltCpbRemovalDelayOffset, m_initialAltCpbRemovalDelayOffset, sizeof(m_initialAltCpbRemovalDelayOffset));
97}
98
99void SEIPictureTiming::copyTo (SEIPictureTiming& target)
100{
101  target.m_picStruct = m_picStruct;
102  target.m_sourceScanType = m_sourceScanType;
103  target.m_duplicateFlag = m_duplicateFlag;
104
105  target.m_auCpbRemovalDelay = m_auCpbRemovalDelay;
106  target.m_picDpbOutputDelay = m_picDpbOutputDelay;
107  target.m_picDpbOutputDuDelay = m_picDpbOutputDuDelay;
108  target.m_numDecodingUnitsMinus1 = m_numDecodingUnitsMinus1;
109  target.m_duCommonCpbRemovalDelayFlag = m_duCommonCpbRemovalDelayFlag;
110  target.m_duCommonCpbRemovalDelayMinus1 = m_duCommonCpbRemovalDelayMinus1;
111
112  target.m_numNalusInDuMinus1 = m_numNalusInDuMinus1;
113  target.m_duCpbRemovalDelayMinus1 = m_duCpbRemovalDelayMinus1;
114}
115
116// Static member
117const Char *SEI::getSEIMessageString(SEI::PayloadType payloadType)
118{
119  switch (payloadType)
120  {
121    case SEI::BUFFERING_PERIOD:                     return "Buffering period";
122    case SEI::PICTURE_TIMING:                       return "Picture timing";
123    case SEI::PAN_SCAN_RECT:                        return "Pan-scan rectangle";                   // not currently decoded
124    case SEI::FILLER_PAYLOAD:                       return "Filler payload";                       // not currently decoded
125    case SEI::USER_DATA_REGISTERED_ITU_T_T35:       return "User data registered";                 // not currently decoded
126    case SEI::USER_DATA_UNREGISTERED:               return "User data unregistered";
127    case SEI::RECOVERY_POINT:                       return "Recovery point";
128    case SEI::SCENE_INFO:                           return "Scene information";                    // not currently decoded
129    case SEI::FULL_FRAME_SNAPSHOT:                  return "Picture snapshot";                     // not currently decoded
130    case SEI::PROGRESSIVE_REFINEMENT_SEGMENT_START: return "Progressive refinement segment start"; // not currently decoded
131    case SEI::PROGRESSIVE_REFINEMENT_SEGMENT_END:   return "Progressive refinement segment end";   // not currently decoded
132    case SEI::FILM_GRAIN_CHARACTERISTICS:           return "Film grain characteristics";           // not currently decoded
133    case SEI::POST_FILTER_HINT:                     return "Post filter hint";                     // not currently decoded
134    case SEI::TONE_MAPPING_INFO:                    return "Tone mapping information";
135    case SEI::KNEE_FUNCTION_INFO:                   return "Knee function information";
136    case SEI::FRAME_PACKING:                        return "Frame packing arrangement";
137    case SEI::DISPLAY_ORIENTATION:                  return "Display orientation";
138    case SEI::SOP_DESCRIPTION:                      return "Structure of pictures information";
139    case SEI::ACTIVE_PARAMETER_SETS:                return "Active parameter sets";
140    case SEI::DECODING_UNIT_INFO:                   return "Decoding unit information";
141    case SEI::TEMPORAL_LEVEL0_INDEX:                return "Temporal sub-layer zero index";
142    case SEI::DECODED_PICTURE_HASH:                 return "Decoded picture hash";
143    case SEI::SCALABLE_NESTING:                     return "Scalable nesting";
144    case SEI::REGION_REFRESH_INFO:                  return "Region refresh information";
145    case SEI::NO_DISPLAY:                           return "No display";
146    case SEI::TIME_CODE:                            return "Time code";
147    case SEI::MASTERING_DISPLAY_COLOUR_VOLUME:      return "Mastering display colour volume";
148    case SEI::SEGM_RECT_FRAME_PACKING:              return "Segmented rectangular frame packing arrangement";
149    case SEI::TEMP_MOTION_CONSTRAINED_TILE_SETS:    return "Temporal motion constrained tile sets";
150    case SEI::CHROMA_SAMPLING_FILTER_HINT:          return "Chroma sampling filter hint";
151#if Q0074_COLOUR_REMAPPING_SEI
152    case SEI::COLOUR_REMAPPING_INFO:                return "Colour Remapping Information";
153#endif
154#if SVC_EXTENSION
155#if LAYERS_NOT_PRESENT_SEI
156    case SEI::LAYERS_NOT_PRESENT:                   return "Layers Present";
157#endif
158#if N0383_IL_CONSTRAINED_TILE_SETS_SEI
159    case SEI::INTER_LAYER_CONSTRAINED_TILE_SETS:    return "Inter Layer Constrained Tile Sets";
160#endif
161#if SUB_BITSTREAM_PROPERTY_SEI
162    case SEI::SUB_BITSTREAM_PROPERTY:               return "Sub-bitstream property";
163#endif
164#if O0164_MULTI_LAYER_HRD
165    case SEI::BSP_NESTING:                          return "Bitstream parition nesting";
166    case SEI::BSP_INITIAL_ARRIVAL_TIME:             return "Bitstream parition initial arrival time";
167#endif
168#if Q0096_OVERLAY_SEI
169    case SEI::OVERLAY_INFO:                         return "Overlay Information";
170#endif
171#if P0123_ALPHA_CHANNEL_SEI
172    case SEI::ALPHA_CHANNEL_INFO:                   return "Alpha Channel Information";
173#endif
174#if Q0189_TMVP_CONSTRAINTS
175    case SEI::TMVP_CONSTRAINTS:                     return "TMVP constraints";
176#endif
177#if Q0247_FRAME_FIELD_INFO
178    case SEI::FRAME_FIELD_INFO:                     return "Frame field info";
179#endif
180#endif
181    default:                                        return "Unknown";
182  }
183}
184
185
186#if SUB_BITSTREAM_PROPERTY_SEI
187SEISubBitstreamProperty::SEISubBitstreamProperty()
188{
189  m_activeVpsId             = -1;
190  m_numAdditionalSubStreams = 0;
191  ::memset(m_subBitstreamMode       , 0, sizeof(m_subBitstreamMode));
192  ::memset(m_outputLayerSetIdxToVps , 0, sizeof(m_outputLayerSetIdxToVps));
193  ::memset(m_highestSublayerId      , 0, sizeof(m_highestSublayerId));
194  ::memset(m_avgBitRate             , 0, sizeof(m_avgBitRate));
195  ::memset(m_maxBitRate             , 0, sizeof(m_maxBitRate));
196}
197#endif
198
199#if Q0074_COLOUR_REMAPPING_SEI
200Void  SEIColourRemappingInfo::copyFrom( SEIColourRemappingInfo const * SeiCriInput)
201{
202  m_colourRemapId                         = SeiCriInput->m_colourRemapId;
203  m_colourRemapCancelFlag                 = SeiCriInput->m_colourRemapCancelFlag;
204  m_colourRemapPersistenceFlag            = SeiCriInput->m_colourRemapPersistenceFlag;
205  m_colourRemapVideoSignalInfoPresentFlag = SeiCriInput->m_colourRemapVideoSignalInfoPresentFlag;
206  m_colourRemapFullRangeFlag              = SeiCriInput->m_colourRemapFullRangeFlag;
207  m_colourRemapPrimaries                  = SeiCriInput->m_colourRemapPrimaries;
208  m_colourRemapTransferFunction           = SeiCriInput->m_colourRemapTransferFunction;
209  m_colourRemapMatrixCoefficients         = SeiCriInput->m_colourRemapMatrixCoefficients;
210  m_colourRemapInputBitDepth              = SeiCriInput->m_colourRemapInputBitDepth;
211  m_colourRemapBitDepth                   = SeiCriInput->m_colourRemapBitDepth;
212
213  for( Int c=0 ; c<3 ; c++ )
214  {
215    m_preLutNumValMinus1[c] = SeiCriInput->m_preLutNumValMinus1[c];
216    m_preLutCodedValue[c].resize(m_preLutNumValMinus1[c]+1);
217    m_preLutTargetValue[c].resize(m_preLutNumValMinus1[c]+1);
218    for ( Int i=0 ; i <= SeiCriInput->m_preLutNumValMinus1[c] ; i++ )
219    {
220        m_preLutCodedValue[c][i]   = SeiCriInput->m_preLutCodedValue[c][i];
221        m_preLutTargetValue[c][i]  = SeiCriInput->m_preLutTargetValue[c][i];
222    } 
223  }
224   
225  m_colourRemapMatrixPresentFlag  = SeiCriInput->m_colourRemapMatrixPresentFlag;
226  m_log2MatrixDenom               = SeiCriInput->m_log2MatrixDenom;
227
228  for ( Int c=0 ; c<3 ; c++ )
229    for ( Int i=0 ; i<3 ; i++ )
230      m_colourRemapCoeffs[c][i] = SeiCriInput->m_colourRemapCoeffs[c][i];
231
232  for( Int c=0 ; c<3 ; c++ )
233  {
234    m_postLutNumValMinus1[c] = SeiCriInput->m_postLutNumValMinus1[c];
235    m_postLutCodedValue[c].resize(m_postLutNumValMinus1[c]+1);
236    m_postLutTargetValue[c].resize(m_postLutNumValMinus1[c]+1);
237    for ( Int i=0 ; i <= m_postLutNumValMinus1[c] ; i++ )
238    {
239        m_postLutCodedValue[c][i]  = SeiCriInput->m_postLutCodedValue[c][i];
240        m_postLutTargetValue[c][i] = SeiCriInput->m_postLutTargetValue[c][i];
241    } 
242  }
243}
244#endif
Note: See TracBrowser for help on using the repository browser.