Coverage Report

Created: 2026-09-14 06:44

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/work/vvdec/source/Lib/CommonLib/SEI_internal.cpp
Line
Count
Source
1
/* -----------------------------------------------------------------------------
2
The copyright in this software is being made available under the Clear BSD
3
License, included below. No patent rights, trademark rights and/or 
4
other Intellectual Property Rights other than the copyrights concerning 
5
the Software are granted under this license.
6
7
The Clear BSD License
8
9
Copyright (c) 2018-2026, Fraunhofer-Gesellschaft zur Förderung der angewandten Forschung e.V. & The VVdeC Authors.
10
All rights reserved.
11
12
Redistribution and use in source and binary forms, with or without modification,
13
are permitted (subject to the limitations in the disclaimer below) provided that
14
the following conditions are met:
15
16
     * Redistributions of source code must retain the above copyright notice,
17
     this list of conditions and the following disclaimer.
18
19
     * Redistributions in binary form must reproduce the above copyright
20
     notice, this list of conditions and the following disclaimer in the
21
     documentation and/or other materials provided with the distribution.
22
23
     * Neither the name of the copyright holder nor the names of its
24
     contributors may be used to endorse or promote products derived from this
25
     software without specific prior written permission.
26
27
NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY
28
THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
29
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
31
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
32
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
33
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
34
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
35
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
36
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
37
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
38
POSSIBILITY OF SUCH DAMAGE.
39
40
41
------------------------------------------------------------------------------------------- */
42
#include "SEI_internal.h"
43
#include "vvdec/sei.h"
44
#include <stdlib.h>
45
#include "CommonDef.h"
46
47
namespace vvdec
48
{
49
50
const char *SEI_internal::getSEIMessageString( vvdecSEIPayloadType payloadType)
51
0
{
52
0
  switch (payloadType)
53
0
  {
54
0
    case VVDEC_BUFFERING_PERIOD:                     return "Buffering period";
55
0
    case VVDEC_PICTURE_TIMING:                       return "Picture timing";
56
0
    case VVDEC_FILLER_PAYLOAD:                       return "Filler payload";                       // not currently decoded
57
0
    case VVDEC_USER_DATA_REGISTERED_ITU_T_T35:       return "User data registered";                 // not currently decoded
58
0
    case VVDEC_USER_DATA_UNREGISTERED:               return "User data unregistered";
59
0
    case VVDEC_FILM_GRAIN_CHARACTERISTICS:           return "Film grain characteristics";           // not currently decoded
60
0
    case VVDEC_FRAME_PACKING:                        return "Frame packing arrangement";
61
0
    case VVDEC_PARAMETER_SETS_INCLUSION_INDICATION:  return "Parameter sets inclusion indication";
62
0
    case VVDEC_DECODING_UNIT_INFO:                   return "Decoding unit information";
63
0
    case VVDEC_SCALABLE_NESTING:                     return "Scalable nesting";
64
0
    case VVDEC_DECODED_PICTURE_HASH:                 return "Decoded picture hash";
65
0
    case VVDEC_DEPENDENT_RAP_INDICATION:             return "Dependent RAP indication";
66
0
    case VVDEC_MASTERING_DISPLAY_COLOUR_VOLUME:      return "Mastering display colour volume";
67
0
    case VVDEC_ALTERNATIVE_TRANSFER_CHARACTERISTICS: return "Alternative transfer characteristics";
68
0
    case VVDEC_CONTENT_LIGHT_LEVEL_INFO:             return "Content light level information";
69
0
    case VVDEC_AMBIENT_VIEWING_ENVIRONMENT:          return "Ambient viewing environment";
70
0
    case VVDEC_CONTENT_COLOUR_VOLUME:                return "Content colour volume";
71
0
    case VVDEC_EQUIRECTANGULAR_PROJECTION:           return "Equirectangular projection";
72
0
    case VVDEC_SPHERE_ROTATION:                      return "Sphere rotation";
73
0
    case VVDEC_REGION_WISE_PACKING:                  return "Region wise packing information";
74
0
    case VVDEC_OMNI_VIEWPORT:                        return "Omni viewport";
75
0
    case VVDEC_GENERALIZED_CUBEMAP_PROJECTION:       return "Generalized cubemap projection";
76
0
    case VVDEC_FRAME_FIELD_INFO:                     return "Frame field info";
77
0
    case VVDEC_SAMPLE_ASPECT_RATIO_INFO:             return "Sample aspect ratio information";
78
0
    case VVDEC_SUBPICTURE_LEVEL_INFO:                return "Subpicture level information";
79
0
    default:                                        return "Unknown";
80
0
  }
81
0
}
82
83
seiMessages SEI_internal::getSeisByType(const seiMessages &seiList, vvdecSEIPayloadType seiType)
84
0
{
85
0
  seiMessages result;
86
87
0
  for( auto& s : seiList )
88
0
  {
89
0
    if ( s->payloadType == seiType)
90
0
    {
91
0
      result.push_back(s);
92
0
    }
93
0
  }
94
0
  return result;
95
0
}
96
97
seiMessages SEI_internal::extractSeisByType(seiMessages &seiList, vvdecSEIPayloadType seiType)
98
0
{
99
0
  seiMessages result;
100
0
  seiMessages::iterator it=seiList.begin();
101
0
  while ( it!=seiList.end() )
102
0
  {
103
0
    if ((*it)->payloadType == seiType)
104
0
    {
105
0
      result.push_back(*it);
106
0
      it = seiList.erase(it);
107
0
    }
108
0
    else
109
0
    {
110
0
      it++;
111
0
    }
112
0
  }
113
0
  return result;
114
0
}
115
116
void SEI_internal::deleteSEI( vvdecSEI* sei )
117
0
{
118
0
  if( !sei )
119
0
  {
120
0
    return;
121
0
  }
122
123
0
  if( sei->payloadType == VVDEC_SCALABLE_NESTING && sei->payload )
124
0
  {
125
0
    const vvdecSEIScalableNesting* nestingSei = ( vvdecSEIScalableNesting* ) sei->payload;
126
127
0
    for( int i = 0; i < nestingSei->snNumSEIs; ++i )
128
0
    {
129
      // nested SEIs may be unset, if parsing of the nesting SEI was aborted
130
0
      deleteSEI( nestingSei->nestedSEIs[i] );
131
0
    }
132
0
  }
133
134
0
  if( sei->payload )
135
0
    free( sei->payload );
136
0
  delete sei;
137
0
}
138
139
void SEI_internal::deleteSEIs ( seiMessages &seiList)
140
306
{
141
306
  for( auto &sei : seiList )
142
0
  {
143
0
    deleteSEI( sei );
144
0
  }
145
306
  seiList.clear();
146
306
}
147
148
vvdecSEI* SEI_internal::allocSEI( vvdecSEIPayloadType payloadType )
149
0
{
150
0
  vvdecSEI* sei = new vvdecSEI;
151
152
0
  if( sei )
153
0
  {
154
0
    sei->payload     = NULL;
155
0
    sei->payloadType = (vvdecSEIPayloadType)payloadType;
156
0
    sei->size        = 0;
157
0
  }
158
0
  else
159
0
  {
160
0
    CHECK_FATAL( !sei, "sei memory allocation error" );
161
0
    return nullptr;
162
0
  }
163
164
0
  if( 0 != allocSEIPayload( sei ))
165
0
  {
166
0
    CHECK_FATAL( !sei, "sei payload allocation error" );
167
0
    delete sei ;
168
0
    return nullptr;
169
0
  }
170
171
0
  return sei;
172
0
}
173
174
175
int SEI_internal::allocSEIPayload( vvdecSEI* sei, int userDefSize )
176
0
{
177
0
  if( NULL == sei ){ return -1; }
178
0
  int size = userDefSize>0 ? userDefSize : getPayloadSize( sei->payloadType );
179
0
  if( size <= 0 ){ return -1;}
180
181
0
  sei->payload = malloc( size );
182
0
  if( sei->payload )
183
0
  {
184
0
    sei->size = size;
185
0
    memset(  sei->payload, 0, size );
186
0
  }
187
188
0
  return 0;
189
0
}
190
191
int SEI_internal::getPayloadSize(vvdecSEIPayloadType payloadType)
192
0
{
193
0
  switch (payloadType)
194
0
  {
195
0
    case VVDEC_BUFFERING_PERIOD:                     return sizeof( vvdecSEIBufferingPeriod );
196
0
    case VVDEC_PICTURE_TIMING:                       return sizeof( vvdecSEIPictureTiming );
197
0
    case VVDEC_FILLER_PAYLOAD:                       return 0;
198
0
    case VVDEC_USER_DATA_REGISTERED_ITU_T_T35:       return sizeof( vvdecSEIUserDataRegistered );                 // not currently decoded
199
0
    case VVDEC_USER_DATA_UNREGISTERED:               return sizeof( vvdecSEIUserDataUnregistered );
200
0
    case VVDEC_FILM_GRAIN_CHARACTERISTICS:           return sizeof( vvdecSEIFilmGrainCharacteristics );
201
0
    case VVDEC_FRAME_PACKING:                        return sizeof( vvdecSEIFramePacking );
202
0
    case VVDEC_PARAMETER_SETS_INCLUSION_INDICATION:  return sizeof( vvdecSEIParameterSetsInclusionIndication );
203
0
    case VVDEC_DECODING_UNIT_INFO:                   return sizeof( vvdecSEIDecodingUnitInfo );
204
0
    case VVDEC_SCALABLE_NESTING:                     return sizeof( vvdecSEIScalableNesting );
205
0
    case VVDEC_DECODED_PICTURE_HASH:                 return sizeof( vvdecSEIDecodedPictureHash );
206
0
    case VVDEC_DEPENDENT_RAP_INDICATION:             return sizeof( vvdecSEIDependentRapIndication );
207
0
    case VVDEC_MASTERING_DISPLAY_COLOUR_VOLUME:      return sizeof( vvdecSEIMasteringDisplayColourVolume );
208
0
    case VVDEC_ALTERNATIVE_TRANSFER_CHARACTERISTICS: return sizeof( vvdecSEIAlternativeTransferCharacteristics );
209
0
    case VVDEC_CONTENT_LIGHT_LEVEL_INFO:             return sizeof( vvdecSEIContentLightLevelInfo );
210
0
    case VVDEC_AMBIENT_VIEWING_ENVIRONMENT:          return sizeof( vvdecSEIAmbientViewingEnvironment );
211
0
    case VVDEC_CONTENT_COLOUR_VOLUME:                return sizeof( vvdecSEIContentColourVolume );
212
0
    case VVDEC_EQUIRECTANGULAR_PROJECTION:           return sizeof( vvdecSEIEquirectangularProjection );
213
0
    case VVDEC_SPHERE_ROTATION:                      return sizeof( vvdecSEISphereRotation );
214
0
    case VVDEC_REGION_WISE_PACKING:                  return sizeof( vvdecSEIRegionWisePacking );
215
0
    case VVDEC_OMNI_VIEWPORT:                        return sizeof( vvdecSEIOmniViewport );
216
0
    case VVDEC_GENERALIZED_CUBEMAP_PROJECTION:       return sizeof( vvdecSEIGeneralizedCubemapProjection );
217
0
    case VVDEC_FRAME_FIELD_INFO:                     return sizeof( vvdecSEIFrameFieldInfo );
218
0
    case VVDEC_SAMPLE_ASPECT_RATIO_INFO:             return sizeof( vvdecSEISampleAspectRatioInfo );
219
0
    case VVDEC_SUBPICTURE_LEVEL_INFO:                return sizeof( vvdecSEISubpictureLevelInfo );
220
0
    default:                                         return -1;
221
0
  }
222
223
0
  return -1;
224
0
}
225
226
}