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-2014, 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 | /** |
---|
35 | \file SEIread.cpp |
---|
36 | \brief reading functionality for SEI messages |
---|
37 | */ |
---|
38 | |
---|
39 | #include "TLibCommon/CommonDef.h" |
---|
40 | #include "TLibCommon/TComBitStream.h" |
---|
41 | #include "TLibCommon/SEI.h" |
---|
42 | #include "TLibCommon/TComSlice.h" |
---|
43 | #include "SyntaxElementParser.h" |
---|
44 | #include "SEIread.h" |
---|
45 | |
---|
46 | //! \ingroup TLibDecoder |
---|
47 | //! \{ |
---|
48 | |
---|
49 | #if ENC_DEC_TRACE |
---|
50 | Void xTraceSEIHeader() |
---|
51 | { |
---|
52 | fprintf( g_hTrace, "=========== SEI message ===========\n"); |
---|
53 | } |
---|
54 | |
---|
55 | Void xTraceSEIMessageType(SEI::PayloadType payloadType) |
---|
56 | { |
---|
57 | switch (payloadType) |
---|
58 | { |
---|
59 | case SEI::DECODED_PICTURE_HASH: |
---|
60 | fprintf( g_hTrace, "=========== Decoded picture hash SEI message ===========\n"); |
---|
61 | break; |
---|
62 | case SEI::USER_DATA_UNREGISTERED: |
---|
63 | fprintf( g_hTrace, "=========== User Data Unregistered SEI message ===========\n"); |
---|
64 | break; |
---|
65 | case SEI::ACTIVE_PARAMETER_SETS: |
---|
66 | fprintf( g_hTrace, "=========== Active Parameter sets SEI message ===========\n"); |
---|
67 | break; |
---|
68 | case SEI::BUFFERING_PERIOD: |
---|
69 | fprintf( g_hTrace, "=========== Buffering period SEI message ===========\n"); |
---|
70 | break; |
---|
71 | case SEI::PICTURE_TIMING: |
---|
72 | fprintf( g_hTrace, "=========== Picture timing SEI message ===========\n"); |
---|
73 | break; |
---|
74 | case SEI::RECOVERY_POINT: |
---|
75 | fprintf( g_hTrace, "=========== Recovery point SEI message ===========\n"); |
---|
76 | break; |
---|
77 | case SEI::FRAME_PACKING: |
---|
78 | fprintf( g_hTrace, "=========== Frame Packing Arrangement SEI message ===========\n"); |
---|
79 | break; |
---|
80 | case SEI::DISPLAY_ORIENTATION: |
---|
81 | fprintf( g_hTrace, "=========== Display Orientation SEI message ===========\n"); |
---|
82 | break; |
---|
83 | case SEI::TEMPORAL_LEVEL0_INDEX: |
---|
84 | fprintf( g_hTrace, "=========== Temporal Level Zero Index SEI message ===========\n"); |
---|
85 | break; |
---|
86 | case SEI::REGION_REFRESH_INFO: |
---|
87 | fprintf( g_hTrace, "=========== Gradual Decoding Refresh Information SEI message ===========\n"); |
---|
88 | break; |
---|
89 | case SEI::DECODING_UNIT_INFO: |
---|
90 | fprintf( g_hTrace, "=========== Decoding Unit Information SEI message ===========\n"); |
---|
91 | break; |
---|
92 | case SEI::TONE_MAPPING_INFO: |
---|
93 | fprintf( g_hTrace, "===========Tone Mapping Info SEI message ===========\n"); |
---|
94 | break; |
---|
95 | #if P0050_KNEE_FUNCTION_SEI |
---|
96 | case SEI::KNEE_FUNCTION_INFO: |
---|
97 | fprintf( g_hTrace, "=========== Knee Function Information SEI message ===========\n"); |
---|
98 | break; |
---|
99 | #endif |
---|
100 | #if Q0074_COLOUR_REMAPPING_SEI |
---|
101 | case SEI::COLOUR_REMAPPING_INFO: |
---|
102 | fprintf( g_hTrace, "===========Colour Remapping Information SEI message ===========\n"); |
---|
103 | break; |
---|
104 | #endif |
---|
105 | case SEI::SOP_DESCRIPTION: |
---|
106 | fprintf( g_hTrace, "=========== SOP Description SEI message ===========\n"); |
---|
107 | break; |
---|
108 | case SEI::SCALABLE_NESTING: |
---|
109 | fprintf( g_hTrace, "=========== Scalable Nesting SEI message ===========\n"); |
---|
110 | break; |
---|
111 | #if SVC_EXTENSION |
---|
112 | #if LAYERS_NOT_PRESENT_SEI |
---|
113 | case SEI::LAYERS_NOT_PRESENT: |
---|
114 | fprintf( g_hTrace, "=========== Layers Present SEI message ===========\n"); |
---|
115 | break; |
---|
116 | #endif |
---|
117 | #if N0383_IL_CONSTRAINED_TILE_SETS_SEI |
---|
118 | case SEI::INTER_LAYER_CONSTRAINED_TILE_SETS: |
---|
119 | fprintf( g_hTrace, "=========== Inter Layer Constrained Tile Sets SEI message ===========\n"); |
---|
120 | break; |
---|
121 | #endif |
---|
122 | #if SUB_BITSTREAM_PROPERTY_SEI |
---|
123 | case SEI::SUB_BITSTREAM_PROPERTY: |
---|
124 | fprintf( g_hTrace, "=========== Sub-bitstream property SEI message ===========\n"); |
---|
125 | break; |
---|
126 | #endif |
---|
127 | #if O0164_MULTI_LAYER_HRD |
---|
128 | case SEI::BSP_NESTING: |
---|
129 | fprintf( g_hTrace, "=========== Bitstream parition nesting SEI message ===========\n"); |
---|
130 | break; |
---|
131 | case SEI::BSP_INITIAL_ARRIVAL_TIME: |
---|
132 | fprintf( g_hTrace, "=========== Bitstream parition initial arrival time SEI message ===========\n"); |
---|
133 | break; |
---|
134 | #if !REMOVE_BSP_HRD_SEI |
---|
135 | case SEI::BSP_HRD: |
---|
136 | fprintf( g_hTrace, "=========== Bitstream parition HRD parameters SEI message ===========\n"); |
---|
137 | break; |
---|
138 | #endif |
---|
139 | #endif |
---|
140 | #if Q0078_ADD_LAYER_SETS |
---|
141 | case SEI::OUTPUT_LAYER_SET_NESTING: |
---|
142 | fprintf(g_hTrace, "=========== Output layer set nesting SEI message ===========\n"); |
---|
143 | break; |
---|
144 | case SEI::VPS_REWRITING: |
---|
145 | fprintf(g_hTrace, "=========== VPS rewriting SEI message ===========\n"); |
---|
146 | break; |
---|
147 | #endif |
---|
148 | #if Q0096_OVERLAY_SEI |
---|
149 | case SEI::OVERLAY_INFO: |
---|
150 | fprintf( g_hTrace, "=========== Overlay Information SEI message ===========\n"); |
---|
151 | break; |
---|
152 | #endif |
---|
153 | #endif //SVC_EXTENSION |
---|
154 | default: |
---|
155 | fprintf( g_hTrace, "=========== Unknown SEI message ===========\n"); |
---|
156 | break; |
---|
157 | } |
---|
158 | } |
---|
159 | #endif |
---|
160 | |
---|
161 | /** |
---|
162 | * unmarshal a single SEI message from bitstream bs |
---|
163 | */ |
---|
164 | #if LAYERS_NOT_PRESENT_SEI |
---|
165 | void SEIReader::parseSEImessage(TComInputBitstream* bs, SEIMessages& seis, const NalUnitType nalUnitType, TComVPS *vps, TComSPS *sps) |
---|
166 | #else |
---|
167 | void SEIReader::parseSEImessage(TComInputBitstream* bs, SEIMessages& seis, const NalUnitType nalUnitType, TComSPS *sps) |
---|
168 | #endif |
---|
169 | { |
---|
170 | setBitstream(bs); |
---|
171 | |
---|
172 | assert(!m_pcBitstream->getNumBitsUntilByteAligned()); |
---|
173 | do |
---|
174 | { |
---|
175 | #if LAYERS_NOT_PRESENT_SEI |
---|
176 | xReadSEImessage(seis, nalUnitType, vps, sps); |
---|
177 | #else |
---|
178 | xReadSEImessage(seis, nalUnitType, sps); |
---|
179 | #endif |
---|
180 | /* SEI messages are an integer number of bytes, something has failed |
---|
181 | * in the parsing if bitstream not byte-aligned */ |
---|
182 | assert(!m_pcBitstream->getNumBitsUntilByteAligned()); |
---|
183 | } while (m_pcBitstream->getNumBitsLeft() > 8); |
---|
184 | |
---|
185 | UInt rbspTrailingBits; |
---|
186 | READ_CODE(8, rbspTrailingBits, "rbsp_trailing_bits"); |
---|
187 | assert(rbspTrailingBits == 0x80); |
---|
188 | } |
---|
189 | |
---|
190 | #if O0164_MULTI_LAYER_HRD |
---|
191 | #if LAYERS_NOT_PRESENT_SEI |
---|
192 | Void SEIReader::xReadSEImessage(SEIMessages& seis, const NalUnitType nalUnitType, TComVPS *vps, TComSPS *sps, const SEIScalableNesting *nestingSei, const SEIBspNesting *bspNestingSei) |
---|
193 | #else |
---|
194 | Void SEIReader::xReadSEImessage(SEIMessages& seis, const NalUnitType nalUnitType, TComSPS *sps, const SEIScalableNesting *nestingSei) |
---|
195 | #endif |
---|
196 | #else |
---|
197 | #if LAYERS_NOT_PRESENT_SEI |
---|
198 | Void SEIReader::xReadSEImessage(SEIMessages& seis, const NalUnitType nalUnitType, TComVPS *vps, TComSPS *sps) |
---|
199 | #else |
---|
200 | Void SEIReader::xReadSEImessage(SEIMessages& seis, const NalUnitType nalUnitType, TComSPS *sps) |
---|
201 | #endif |
---|
202 | #endif |
---|
203 | { |
---|
204 | #if ENC_DEC_TRACE |
---|
205 | xTraceSEIHeader(); |
---|
206 | #endif |
---|
207 | Int payloadType = 0; |
---|
208 | UInt val = 0; |
---|
209 | |
---|
210 | do |
---|
211 | { |
---|
212 | READ_CODE (8, val, "payload_type"); |
---|
213 | payloadType += val; |
---|
214 | } while (val==0xFF); |
---|
215 | |
---|
216 | UInt payloadSize = 0; |
---|
217 | do |
---|
218 | { |
---|
219 | READ_CODE (8, val, "payload_size"); |
---|
220 | payloadSize += val; |
---|
221 | } while (val==0xFF); |
---|
222 | |
---|
223 | #if ENC_DEC_TRACE |
---|
224 | xTraceSEIMessageType((SEI::PayloadType)payloadType); |
---|
225 | #endif |
---|
226 | |
---|
227 | /* extract the payload for this single SEI message. |
---|
228 | * This allows greater safety in erroneous parsing of an SEI message |
---|
229 | * from affecting subsequent messages. |
---|
230 | * After parsing the payload, bs needs to be restored as the primary |
---|
231 | * bitstream. |
---|
232 | */ |
---|
233 | TComInputBitstream *bs = getBitstream(); |
---|
234 | setBitstream(bs->extractSubstream(payloadSize * 8)); |
---|
235 | |
---|
236 | SEI *sei = NULL; |
---|
237 | |
---|
238 | if(nalUnitType == NAL_UNIT_PREFIX_SEI) |
---|
239 | { |
---|
240 | switch (payloadType) |
---|
241 | { |
---|
242 | case SEI::USER_DATA_UNREGISTERED: |
---|
243 | sei = new SEIuserDataUnregistered; |
---|
244 | xParseSEIuserDataUnregistered((SEIuserDataUnregistered&) *sei, payloadSize); |
---|
245 | break; |
---|
246 | case SEI::ACTIVE_PARAMETER_SETS: |
---|
247 | sei = new SEIActiveParameterSets; |
---|
248 | xParseSEIActiveParameterSets((SEIActiveParameterSets&) *sei, payloadSize); |
---|
249 | break; |
---|
250 | case SEI::DECODING_UNIT_INFO: |
---|
251 | if (!sps) |
---|
252 | { |
---|
253 | printf ("Warning: Found Decoding unit SEI message, but no active SPS is available. Ignoring."); |
---|
254 | } |
---|
255 | else |
---|
256 | { |
---|
257 | sei = new SEIDecodingUnitInfo; |
---|
258 | #if VPS_VUI_BSP_HRD_PARAMS |
---|
259 | xParseSEIDecodingUnitInfo((SEIDecodingUnitInfo&) *sei, payloadSize, sps, nestingSei, bspNestingSei, vps); |
---|
260 | #else |
---|
261 | xParseSEIDecodingUnitInfo((SEIDecodingUnitInfo&) *sei, payloadSize, sps); |
---|
262 | #endif |
---|
263 | } |
---|
264 | break; |
---|
265 | case SEI::BUFFERING_PERIOD: |
---|
266 | if (!sps) |
---|
267 | { |
---|
268 | printf ("Warning: Found Buffering period SEI message, but no active SPS is available. Ignoring."); |
---|
269 | } |
---|
270 | else |
---|
271 | { |
---|
272 | sei = new SEIBufferingPeriod; |
---|
273 | #if VPS_VUI_BSP_HRD_PARAMS |
---|
274 | xParseSEIBufferingPeriod((SEIBufferingPeriod&) *sei, payloadSize, sps, nestingSei, bspNestingSei, vps); |
---|
275 | #else |
---|
276 | xParseSEIBufferingPeriod((SEIBufferingPeriod&) *sei, payloadSize, sps); |
---|
277 | #endif |
---|
278 | } |
---|
279 | break; |
---|
280 | case SEI::PICTURE_TIMING: |
---|
281 | if (!sps) |
---|
282 | { |
---|
283 | printf ("Warning: Found Picture timing SEI message, but no active SPS is available. Ignoring."); |
---|
284 | } |
---|
285 | else |
---|
286 | { |
---|
287 | sei = new SEIPictureTiming; |
---|
288 | #if VPS_VUI_BSP_HRD_PARAMS |
---|
289 | xParseSEIPictureTiming((SEIPictureTiming&)*sei, payloadSize, sps, nestingSei, bspNestingSei, vps); |
---|
290 | #else |
---|
291 | xParseSEIPictureTiming((SEIPictureTiming&)*sei, payloadSize, sps); |
---|
292 | #endif |
---|
293 | } |
---|
294 | break; |
---|
295 | case SEI::RECOVERY_POINT: |
---|
296 | sei = new SEIRecoveryPoint; |
---|
297 | xParseSEIRecoveryPoint((SEIRecoveryPoint&) *sei, payloadSize); |
---|
298 | break; |
---|
299 | case SEI::FRAME_PACKING: |
---|
300 | sei = new SEIFramePacking; |
---|
301 | xParseSEIFramePacking((SEIFramePacking&) *sei, payloadSize); |
---|
302 | break; |
---|
303 | case SEI::DISPLAY_ORIENTATION: |
---|
304 | sei = new SEIDisplayOrientation; |
---|
305 | xParseSEIDisplayOrientation((SEIDisplayOrientation&) *sei, payloadSize); |
---|
306 | break; |
---|
307 | case SEI::TEMPORAL_LEVEL0_INDEX: |
---|
308 | sei = new SEITemporalLevel0Index; |
---|
309 | xParseSEITemporalLevel0Index((SEITemporalLevel0Index&) *sei, payloadSize); |
---|
310 | break; |
---|
311 | case SEI::REGION_REFRESH_INFO: |
---|
312 | sei = new SEIGradualDecodingRefreshInfo; |
---|
313 | xParseSEIGradualDecodingRefreshInfo((SEIGradualDecodingRefreshInfo&) *sei, payloadSize); |
---|
314 | break; |
---|
315 | case SEI::TONE_MAPPING_INFO: |
---|
316 | sei = new SEIToneMappingInfo; |
---|
317 | xParseSEIToneMappingInfo((SEIToneMappingInfo&) *sei, payloadSize); |
---|
318 | break; |
---|
319 | #if P0050_KNEE_FUNCTION_SEI |
---|
320 | case SEI::KNEE_FUNCTION_INFO: |
---|
321 | sei = new SEIKneeFunctionInfo; |
---|
322 | xParseSEIKneeFunctionInfo((SEIKneeFunctionInfo&) *sei, payloadSize); |
---|
323 | break; |
---|
324 | #endif |
---|
325 | #if Q0074_COLOUR_REMAPPING_SEI |
---|
326 | case SEI::COLOUR_REMAPPING_INFO: |
---|
327 | sei = new SEIColourRemappingInfo; |
---|
328 | xParseSEIColourRemappingInfo((SEIColourRemappingInfo&) *sei, payloadSize); |
---|
329 | break; |
---|
330 | #endif |
---|
331 | case SEI::SOP_DESCRIPTION: |
---|
332 | sei = new SEISOPDescription; |
---|
333 | xParseSEISOPDescription((SEISOPDescription&) *sei, payloadSize); |
---|
334 | break; |
---|
335 | case SEI::SCALABLE_NESTING: |
---|
336 | sei = new SEIScalableNesting; |
---|
337 | #if LAYERS_NOT_PRESENT_SEI |
---|
338 | xParseSEIScalableNesting((SEIScalableNesting&) *sei, nalUnitType, payloadSize, vps, sps); |
---|
339 | #else |
---|
340 | xParseSEIScalableNesting((SEIScalableNesting&) *sei, nalUnitType, payloadSize, sps); |
---|
341 | #endif |
---|
342 | break; |
---|
343 | #if SVC_EXTENSION |
---|
344 | #if LAYERS_NOT_PRESENT_SEI |
---|
345 | case SEI::LAYERS_NOT_PRESENT: |
---|
346 | if (!vps) |
---|
347 | { |
---|
348 | printf ("Warning: Found Layers not present SEI message, but no active VPS is available. Ignoring."); |
---|
349 | } |
---|
350 | else |
---|
351 | { |
---|
352 | sei = new SEILayersNotPresent; |
---|
353 | xParseSEILayersNotPresent((SEILayersNotPresent&) *sei, payloadSize, vps); |
---|
354 | } |
---|
355 | break; |
---|
356 | #endif |
---|
357 | #if N0383_IL_CONSTRAINED_TILE_SETS_SEI |
---|
358 | case SEI::INTER_LAYER_CONSTRAINED_TILE_SETS: |
---|
359 | sei = new SEIInterLayerConstrainedTileSets; |
---|
360 | xParseSEIInterLayerConstrainedTileSets((SEIInterLayerConstrainedTileSets&) *sei, payloadSize); |
---|
361 | break; |
---|
362 | #endif |
---|
363 | #if SUB_BITSTREAM_PROPERTY_SEI |
---|
364 | case SEI::SUB_BITSTREAM_PROPERTY: |
---|
365 | sei = new SEISubBitstreamProperty; |
---|
366 | #if OLS_IDX_CHK |
---|
367 | xParseSEISubBitstreamProperty((SEISubBitstreamProperty&) *sei, vps); |
---|
368 | #else |
---|
369 | xParseSEISubBitstreamProperty((SEISubBitstreamProperty&) *sei); |
---|
370 | #endif |
---|
371 | break; |
---|
372 | #endif |
---|
373 | #if O0164_MULTI_LAYER_HRD |
---|
374 | case SEI::BSP_NESTING: |
---|
375 | sei = new SEIBspNesting; |
---|
376 | #if LAYERS_NOT_PRESENT_SEI |
---|
377 | xParseSEIBspNesting((SEIBspNesting&) *sei, nalUnitType, vps, sps, *nestingSei); |
---|
378 | #else |
---|
379 | xParseSEIBspNesting((SEIBspNesting&) *sei, nalUnitType, sps, *nestingSei); |
---|
380 | #endif |
---|
381 | break; |
---|
382 | case SEI::BSP_INITIAL_ARRIVAL_TIME: |
---|
383 | sei = new SEIBspInitialArrivalTime; |
---|
384 | xParseSEIBspInitialArrivalTime((SEIBspInitialArrivalTime&) *sei, vps, sps, *nestingSei, *bspNestingSei); |
---|
385 | break; |
---|
386 | #if !REMOVE_BSP_HRD_SEI |
---|
387 | case SEI::BSP_HRD: |
---|
388 | sei = new SEIBspHrd; |
---|
389 | xParseSEIBspHrd((SEIBspHrd&) *sei, sps, *nestingSei); |
---|
390 | break; |
---|
391 | #endif |
---|
392 | #endif |
---|
393 | #if Q0078_ADD_LAYER_SETS |
---|
394 | case SEI::OUTPUT_LAYER_SET_NESTING: |
---|
395 | sei = new SEIOutputLayerSetNesting; |
---|
396 | #if LAYERS_NOT_PRESENT_SEI |
---|
397 | xParseSEIOutputLayerSetNesting((SEIOutputLayerSetNesting&)*sei, nalUnitType, vps, sps); |
---|
398 | #else |
---|
399 | xParseSEIOutputLayerSetNesting((SEIOutputLayerSetNesting&)*sei, nalUnitType, sps); |
---|
400 | #endif |
---|
401 | break; |
---|
402 | case SEI::VPS_REWRITING: |
---|
403 | sei = new SEIVPSRewriting; |
---|
404 | xParseSEIVPSRewriting((SEIVPSRewriting&)*sei); |
---|
405 | break; |
---|
406 | #endif |
---|
407 | #if Q0189_TMVP_CONSTRAINTS |
---|
408 | case SEI::TMVP_CONSTRAINTS: |
---|
409 | sei = new SEITMVPConstrains; |
---|
410 | xParseSEITMVPConstraints((SEITMVPConstrains&) *sei, payloadSize); |
---|
411 | break; |
---|
412 | #endif |
---|
413 | #if Q0247_FRAME_FIELD_INFO |
---|
414 | case SEI::FRAME_FIELD_INFO: |
---|
415 | sei = new SEIFrameFieldInfo; |
---|
416 | xParseSEIFrameFieldInfo ((SEIFrameFieldInfo&) *sei, payloadSize); |
---|
417 | break; |
---|
418 | #endif |
---|
419 | #if Q0096_OVERLAY_SEI |
---|
420 | case SEI::OVERLAY_INFO: |
---|
421 | sei = new SEIOverlayInfo; |
---|
422 | xParseSEIOverlayInfo((SEIOverlayInfo&) *sei, payloadSize); |
---|
423 | break; |
---|
424 | #endif |
---|
425 | #endif //SVC_EXTENSION |
---|
426 | break; |
---|
427 | default: |
---|
428 | for (UInt i = 0; i < payloadSize; i++) |
---|
429 | { |
---|
430 | UInt seiByte; |
---|
431 | READ_CODE (8, seiByte, "unknown prefix SEI payload byte"); |
---|
432 | } |
---|
433 | printf ("Unknown prefix SEI message (payloadType = %d) was found!\n", payloadType); |
---|
434 | } |
---|
435 | } |
---|
436 | else |
---|
437 | { |
---|
438 | switch (payloadType) |
---|
439 | { |
---|
440 | case SEI::USER_DATA_UNREGISTERED: |
---|
441 | sei = new SEIuserDataUnregistered; |
---|
442 | xParseSEIuserDataUnregistered((SEIuserDataUnregistered&) *sei, payloadSize); |
---|
443 | break; |
---|
444 | case SEI::DECODED_PICTURE_HASH: |
---|
445 | sei = new SEIDecodedPictureHash; |
---|
446 | xParseSEIDecodedPictureHash((SEIDecodedPictureHash&) *sei, payloadSize); |
---|
447 | break; |
---|
448 | default: |
---|
449 | for (UInt i = 0; i < payloadSize; i++) |
---|
450 | { |
---|
451 | UInt seiByte; |
---|
452 | READ_CODE (8, seiByte, "unknown suffix SEI payload byte"); |
---|
453 | } |
---|
454 | printf ("Unknown suffix SEI message (payloadType = %d) was found!\n", payloadType); |
---|
455 | } |
---|
456 | } |
---|
457 | if (sei != NULL) |
---|
458 | { |
---|
459 | seis.push_back(sei); |
---|
460 | } |
---|
461 | |
---|
462 | /* By definition the underlying bitstream terminates in a byte-aligned manner. |
---|
463 | * 1. Extract all bar the last MIN(bitsremaining,nine) bits as reserved_payload_extension_data |
---|
464 | * 2. Examine the final 8 bits to determine the payload_bit_equal_to_one marker |
---|
465 | * 3. Extract the remainingreserved_payload_extension_data bits. |
---|
466 | * |
---|
467 | * If there are fewer than 9 bits available, extract them. |
---|
468 | */ |
---|
469 | Int payloadBitsRemaining = getBitstream()->getNumBitsLeft(); |
---|
470 | if (payloadBitsRemaining) /* more_data_in_payload() */ |
---|
471 | { |
---|
472 | for (; payloadBitsRemaining > 9; payloadBitsRemaining--) |
---|
473 | { |
---|
474 | UInt reservedPayloadExtensionData; |
---|
475 | READ_CODE (1, reservedPayloadExtensionData, "reserved_payload_extension_data"); |
---|
476 | } |
---|
477 | |
---|
478 | /* 2 */ |
---|
479 | Int finalBits = getBitstream()->peekBits(payloadBitsRemaining); |
---|
480 | Int finalPayloadBits = 0; |
---|
481 | for (Int mask = 0xff; finalBits & (mask >> finalPayloadBits); finalPayloadBits++) |
---|
482 | { |
---|
483 | continue; |
---|
484 | } |
---|
485 | |
---|
486 | /* 3 */ |
---|
487 | for (; payloadBitsRemaining > 9 - finalPayloadBits; payloadBitsRemaining--) |
---|
488 | { |
---|
489 | UInt reservedPayloadExtensionData; |
---|
490 | READ_FLAG (reservedPayloadExtensionData, "reserved_payload_extension_data"); |
---|
491 | } |
---|
492 | |
---|
493 | UInt dummy; |
---|
494 | READ_FLAG (dummy, "payload_bit_equal_to_one"); payloadBitsRemaining--; |
---|
495 | while (payloadBitsRemaining) |
---|
496 | { |
---|
497 | READ_FLAG (dummy, "payload_bit_equal_to_zero"); payloadBitsRemaining--; |
---|
498 | } |
---|
499 | } |
---|
500 | |
---|
501 | /* restore primary bitstream for sei_message */ |
---|
502 | getBitstream()->deleteFifo(); |
---|
503 | delete getBitstream(); |
---|
504 | setBitstream(bs); |
---|
505 | } |
---|
506 | |
---|
507 | #if P0138_USE_ALT_CPB_PARAMS_FLAG |
---|
508 | /** |
---|
509 | * Check if SEI message contains payload extension |
---|
510 | */ |
---|
511 | Bool SEIReader::xPayloadExtensionPresent() |
---|
512 | { |
---|
513 | Int payloadBitsRemaining = getBitstream()->getNumBitsLeft(); |
---|
514 | Bool payloadExtensionPresent = false; |
---|
515 | |
---|
516 | if (payloadBitsRemaining > 8) |
---|
517 | { |
---|
518 | payloadExtensionPresent = true; |
---|
519 | } |
---|
520 | else |
---|
521 | { |
---|
522 | Int finalBits = getBitstream()->peekBits(payloadBitsRemaining); |
---|
523 | while (payloadBitsRemaining && (finalBits & 1) == 0) |
---|
524 | { |
---|
525 | payloadBitsRemaining--; |
---|
526 | finalBits >>= 1; |
---|
527 | } |
---|
528 | payloadBitsRemaining--; |
---|
529 | if (payloadBitsRemaining > 0) |
---|
530 | { |
---|
531 | payloadExtensionPresent = true; |
---|
532 | } |
---|
533 | } |
---|
534 | |
---|
535 | return payloadExtensionPresent; |
---|
536 | } |
---|
537 | #endif |
---|
538 | |
---|
539 | /** |
---|
540 | * parse bitstream bs and unpack a user_data_unregistered SEI message |
---|
541 | * of payloasSize bytes into sei. |
---|
542 | */ |
---|
543 | Void SEIReader::xParseSEIuserDataUnregistered(SEIuserDataUnregistered &sei, UInt payloadSize) |
---|
544 | { |
---|
545 | assert(payloadSize >= 16); |
---|
546 | UInt val; |
---|
547 | |
---|
548 | for (UInt i = 0; i < 16; i++) |
---|
549 | { |
---|
550 | READ_CODE (8, val, "uuid_iso_iec_11578"); |
---|
551 | sei.uuid_iso_iec_11578[i] = val; |
---|
552 | } |
---|
553 | |
---|
554 | sei.userDataLength = payloadSize - 16; |
---|
555 | if (!sei.userDataLength) |
---|
556 | { |
---|
557 | sei.userData = 0; |
---|
558 | return; |
---|
559 | } |
---|
560 | |
---|
561 | sei.userData = new UChar[sei.userDataLength]; |
---|
562 | for (UInt i = 0; i < sei.userDataLength; i++) |
---|
563 | { |
---|
564 | READ_CODE (8, val, "user_data" ); |
---|
565 | sei.userData[i] = val; |
---|
566 | } |
---|
567 | } |
---|
568 | |
---|
569 | /** |
---|
570 | * parse bitstream bs and unpack a decoded picture hash SEI message |
---|
571 | * of payloadSize bytes into sei. |
---|
572 | */ |
---|
573 | Void SEIReader::xParseSEIDecodedPictureHash(SEIDecodedPictureHash& sei, UInt /*payloadSize*/) |
---|
574 | { |
---|
575 | UInt val; |
---|
576 | READ_CODE (8, val, "hash_type"); |
---|
577 | sei.method = static_cast<SEIDecodedPictureHash::Method>(val); |
---|
578 | for(Int yuvIdx = 0; yuvIdx < 3; yuvIdx++) |
---|
579 | { |
---|
580 | if(SEIDecodedPictureHash::MD5 == sei.method) |
---|
581 | { |
---|
582 | for (UInt i = 0; i < 16; i++) |
---|
583 | { |
---|
584 | READ_CODE(8, val, "picture_md5"); |
---|
585 | sei.digest[yuvIdx][i] = val; |
---|
586 | } |
---|
587 | } |
---|
588 | else if(SEIDecodedPictureHash::CRC == sei.method) |
---|
589 | { |
---|
590 | READ_CODE(16, val, "picture_crc"); |
---|
591 | sei.digest[yuvIdx][0] = val >> 8 & 0xFF; |
---|
592 | sei.digest[yuvIdx][1] = val & 0xFF; |
---|
593 | } |
---|
594 | else if(SEIDecodedPictureHash::CHECKSUM == sei.method) |
---|
595 | { |
---|
596 | READ_CODE(32, val, "picture_checksum"); |
---|
597 | sei.digest[yuvIdx][0] = (val>>24) & 0xff; |
---|
598 | sei.digest[yuvIdx][1] = (val>>16) & 0xff; |
---|
599 | sei.digest[yuvIdx][2] = (val>>8) & 0xff; |
---|
600 | sei.digest[yuvIdx][3] = val & 0xff; |
---|
601 | } |
---|
602 | } |
---|
603 | } |
---|
604 | Void SEIReader::xParseSEIActiveParameterSets(SEIActiveParameterSets& sei, UInt /*payloadSize*/) |
---|
605 | { |
---|
606 | UInt val; |
---|
607 | READ_CODE(4, val, "active_video_parameter_set_id"); sei.activeVPSId = val; |
---|
608 | READ_FLAG( val, "self_contained_cvs_flag"); sei.m_selfContainedCvsFlag = val ? true : false; |
---|
609 | READ_FLAG( val, "no_parameter_set_update_flag"); sei.m_noParameterSetUpdateFlag = val ? true : false; |
---|
610 | READ_UVLC( val, "num_sps_ids_minus1"); sei.numSpsIdsMinus1 = val; |
---|
611 | |
---|
612 | sei.activeSeqParameterSetId.resize(sei.numSpsIdsMinus1 + 1); |
---|
613 | #if R0247_SEI_ACTIVE |
---|
614 | sei.layerSpsIdx.resize(sei.numSpsIdsMinus1 + 1); |
---|
615 | #endif |
---|
616 | for (Int i=0; i < (sei.numSpsIdsMinus1 + 1); i++) |
---|
617 | { |
---|
618 | READ_UVLC(val, "active_seq_parameter_set_id"); sei.activeSeqParameterSetId[i] = val; |
---|
619 | } |
---|
620 | #if R0247_SEI_ACTIVE |
---|
621 | for (Int i=1; i < (sei.numSpsIdsMinus1 + 1); i++) |
---|
622 | { |
---|
623 | READ_UVLC(val, "layer_sps_idx"); sei.layerSpsIdx[i] = val; |
---|
624 | } |
---|
625 | #endif |
---|
626 | xParseByteAlign(); |
---|
627 | } |
---|
628 | |
---|
629 | #if VPS_VUI_BSP_HRD_PARAMS |
---|
630 | Void SEIReader::xParseSEIDecodingUnitInfo(SEIDecodingUnitInfo& sei, UInt /*payloadSize*/, TComSPS *sps, const SEIScalableNesting* nestingSei, const SEIBspNesting* bspNestingSei, TComVPS *vps) |
---|
631 | #else |
---|
632 | Void SEIReader::xParseSEIDecodingUnitInfo(SEIDecodingUnitInfo& sei, UInt /*payloadSize*/, TComSPS *sps) |
---|
633 | #endif |
---|
634 | { |
---|
635 | UInt val; |
---|
636 | READ_UVLC(val, "decoding_unit_idx"); |
---|
637 | sei.m_decodingUnitIdx = val; |
---|
638 | |
---|
639 | #if VPS_VUI_BSP_HRD_PARAMS |
---|
640 | TComHRD *hrd; |
---|
641 | if( bspNestingSei ) // If DU info SEI contained inside a BSP nesting SEI message |
---|
642 | { |
---|
643 | assert( nestingSei ); |
---|
644 | Int psIdx = bspNestingSei->m_seiPartitioningSchemeIdx; |
---|
645 | Int seiOlsIdx = bspNestingSei->m_seiOlsIdx; |
---|
646 | Int maxTemporalId = nestingSei->m_nestingMaxTemporalIdPlus1[0] - 1; |
---|
647 | Int maxValues = vps->getNumBspSchedulesMinus1(seiOlsIdx, psIdx, maxTemporalId) + 1; |
---|
648 | std::vector<Int> hrdIdx(maxValues, 0); |
---|
649 | std::vector<TComHRD *> hrdVec; |
---|
650 | std::vector<Int> syntaxElemLen(maxValues, 0); |
---|
651 | for(Int i = 0; i < maxValues; i++) |
---|
652 | { |
---|
653 | hrdIdx[i] = vps->getBspHrdIdx( seiOlsIdx, psIdx, maxTemporalId, i, bspNestingSei->m_bspIdx); |
---|
654 | hrdVec.push_back(vps->getBspHrd(hrdIdx[i])); |
---|
655 | |
---|
656 | syntaxElemLen[i] = hrdVec[i]->getInitialCpbRemovalDelayLengthMinus1() + 1; |
---|
657 | if ( !(hrdVec[i]->getNalHrdParametersPresentFlag() || hrdVec[i]->getVclHrdParametersPresentFlag()) ) |
---|
658 | { |
---|
659 | assert( syntaxElemLen[i] == 24 ); // Default of value init_cpb_removal_delay_length_minus1 is 23 |
---|
660 | } |
---|
661 | if( i > 0 ) |
---|
662 | { |
---|
663 | assert( hrdVec[i]->getSubPicCpbParamsPresentFlag() == hrdVec[i-1]->getSubPicCpbParamsPresentFlag() ); |
---|
664 | assert( hrdVec[i]->getSubPicCpbParamsInPicTimingSEIFlag() == hrdVec[i-1]->getSubPicCpbParamsInPicTimingSEIFlag() ); |
---|
665 | assert( hrdVec[i]->getDpbOutputDelayDuLengthMinus1() == hrdVec[i-1]->getDpbOutputDelayDuLengthMinus1() ); |
---|
666 | // To be done: Check CpbDpbDelaysPresentFlag |
---|
667 | } |
---|
668 | } |
---|
669 | hrd = hrdVec[0]; |
---|
670 | } |
---|
671 | else |
---|
672 | { |
---|
673 | TComVUI *vui = sps->getVuiParameters(); |
---|
674 | hrd = vui->getHrdParameters(); |
---|
675 | } |
---|
676 | #else |
---|
677 | TComVUI *vui = sps->getVuiParameters(); |
---|
678 | TComHrd *hrd = vui->getHrdParameters(); |
---|
679 | #endif |
---|
680 | if(hrd->getSubPicCpbParamsInPicTimingSEIFlag()) |
---|
681 | { |
---|
682 | READ_CODE( ( hrd->getDuCpbRemovalDelayLengthMinus1() + 1 ), val, "du_spt_cpb_removal_delay"); |
---|
683 | sei.m_duSptCpbRemovalDelay = val; |
---|
684 | } |
---|
685 | else |
---|
686 | { |
---|
687 | sei.m_duSptCpbRemovalDelay = 0; |
---|
688 | } |
---|
689 | READ_FLAG( val, "dpb_output_du_delay_present_flag"); sei.m_dpbOutputDuDelayPresentFlag = val ? true : false; |
---|
690 | if(sei.m_dpbOutputDuDelayPresentFlag) |
---|
691 | { |
---|
692 | READ_CODE(hrd->getDpbOutputDelayDuLengthMinus1() + 1, val, "pic_spt_dpb_output_du_delay"); |
---|
693 | sei.m_picSptDpbOutputDuDelay = val; |
---|
694 | } |
---|
695 | xParseByteAlign(); |
---|
696 | } |
---|
697 | |
---|
698 | #if VPS_VUI_BSP_HRD_PARAMS |
---|
699 | Void SEIReader::xParseSEIBufferingPeriod(SEIBufferingPeriod& sei, UInt /*payloadSize*/, TComSPS *sps, const SEIScalableNesting* nestingSei, const SEIBspNesting* bspNestingSei, TComVPS *vps) |
---|
700 | #else |
---|
701 | Void SEIReader::xParseSEIBufferingPeriod(SEIBufferingPeriod& sei, UInt /*payloadSize*/, TComSPS *sps) |
---|
702 | #endif |
---|
703 | { |
---|
704 | Int i, nalOrVcl; |
---|
705 | UInt code; |
---|
706 | |
---|
707 | #if VPS_VUI_BSP_HRD_PARAMS |
---|
708 | TComHRD *pHRD; |
---|
709 | if( bspNestingSei ) // If BP SEI contained inside a BSP nesting SEI message |
---|
710 | { |
---|
711 | assert( nestingSei ); |
---|
712 | Int psIdx = bspNestingSei->m_seiPartitioningSchemeIdx; |
---|
713 | Int seiOlsIdx = bspNestingSei->m_seiOlsIdx; |
---|
714 | Int maxTemporalId = nestingSei->m_nestingMaxTemporalIdPlus1[0] - 1; |
---|
715 | Int maxValues = vps->getNumBspSchedulesMinus1(seiOlsIdx, psIdx, maxTemporalId) + 1; |
---|
716 | std::vector<Int> hrdIdx(maxValues, 0); |
---|
717 | std::vector<TComHRD *> hrdVec; |
---|
718 | std::vector<Int> syntaxElemLen(maxValues, 0); |
---|
719 | for(i = 0; i < maxValues; i++) |
---|
720 | { |
---|
721 | hrdIdx[i] = vps->getBspHrdIdx( seiOlsIdx, psIdx, maxTemporalId, i, bspNestingSei->m_bspIdx); |
---|
722 | hrdVec.push_back(vps->getBspHrd(hrdIdx[i])); |
---|
723 | |
---|
724 | syntaxElemLen[i] = hrdVec[i]->getInitialCpbRemovalDelayLengthMinus1() + 1; |
---|
725 | if ( !(hrdVec[i]->getNalHrdParametersPresentFlag() || hrdVec[i]->getVclHrdParametersPresentFlag()) ) |
---|
726 | { |
---|
727 | assert( syntaxElemLen[i] == 24 ); // Default of value init_cpb_removal_delay_length_minus1 is 23 |
---|
728 | } |
---|
729 | if( i > 0 ) |
---|
730 | { |
---|
731 | assert( hrdVec[i]->getCpbRemovalDelayLengthMinus1() == hrdVec[i-1]->getCpbRemovalDelayLengthMinus1() ); |
---|
732 | assert( hrdVec[i]->getDpbOutputDelayDuLengthMinus1() == hrdVec[i-1]->getDpbOutputDelayDuLengthMinus1() ); |
---|
733 | assert( hrdVec[i]->getSubPicCpbParamsPresentFlag() == hrdVec[i-1]->getSubPicCpbParamsPresentFlag() ); |
---|
734 | } |
---|
735 | } |
---|
736 | pHRD = hrdVec[i]; |
---|
737 | } |
---|
738 | else |
---|
739 | { |
---|
740 | TComVUI *vui = sps->getVuiParameters(); |
---|
741 | pHRD = vui->getHrdParameters(); |
---|
742 | } |
---|
743 | // To be done: When contained in an BSP HRD SEI message, the hrd structure is to be chosen differently. |
---|
744 | #else |
---|
745 | TComVUI *pVUI = sps->getVuiParameters(); |
---|
746 | TComHRD *pHRD = pVUI->getHrdParameters(); |
---|
747 | #endif |
---|
748 | |
---|
749 | READ_UVLC( code, "bp_seq_parameter_set_id" ); sei.m_bpSeqParameterSetId = code; |
---|
750 | if( !pHRD->getSubPicCpbParamsPresentFlag() ) |
---|
751 | { |
---|
752 | READ_FLAG( code, "irap_cpb_params_present_flag" ); sei.m_rapCpbParamsPresentFlag = code; |
---|
753 | } |
---|
754 | if( sei.m_rapCpbParamsPresentFlag ) |
---|
755 | { |
---|
756 | READ_CODE( pHRD->getCpbRemovalDelayLengthMinus1() + 1, code, "cpb_delay_offset" ); sei.m_cpbDelayOffset = code; |
---|
757 | READ_CODE( pHRD->getDpbOutputDelayLengthMinus1() + 1, code, "dpb_delay_offset" ); sei.m_dpbDelayOffset = code; |
---|
758 | } |
---|
759 | //read splicing flag and cpb_removal_delay_delta |
---|
760 | READ_FLAG( code, "concatenation_flag"); |
---|
761 | sei.m_concatenationFlag = code; |
---|
762 | READ_CODE( ( pHRD->getCpbRemovalDelayLengthMinus1() + 1 ), code, "au_cpb_removal_delay_delta_minus1" ); |
---|
763 | sei.m_auCpbRemovalDelayDelta = code + 1; |
---|
764 | for( nalOrVcl = 0; nalOrVcl < 2; nalOrVcl ++ ) |
---|
765 | { |
---|
766 | if( ( ( nalOrVcl == 0 ) && ( pHRD->getNalHrdParametersPresentFlag() ) ) || |
---|
767 | ( ( nalOrVcl == 1 ) && ( pHRD->getVclHrdParametersPresentFlag() ) ) ) |
---|
768 | { |
---|
769 | for( i = 0; i < ( pHRD->getCpbCntMinus1( 0 ) + 1 ); i ++ ) |
---|
770 | { |
---|
771 | READ_CODE( ( pHRD->getInitialCpbRemovalDelayLengthMinus1() + 1 ) , code, "initial_cpb_removal_delay" ); |
---|
772 | sei.m_initialCpbRemovalDelay[i][nalOrVcl] = code; |
---|
773 | READ_CODE( ( pHRD->getInitialCpbRemovalDelayLengthMinus1() + 1 ) , code, "initial_cpb_removal_delay_offset" ); |
---|
774 | sei.m_initialCpbRemovalDelayOffset[i][nalOrVcl] = code; |
---|
775 | if( pHRD->getSubPicCpbParamsPresentFlag() || sei.m_rapCpbParamsPresentFlag ) |
---|
776 | { |
---|
777 | READ_CODE( ( pHRD->getInitialCpbRemovalDelayLengthMinus1() + 1 ) , code, "initial_alt_cpb_removal_delay" ); |
---|
778 | sei.m_initialAltCpbRemovalDelay[i][nalOrVcl] = code; |
---|
779 | READ_CODE( ( pHRD->getInitialCpbRemovalDelayLengthMinus1() + 1 ) , code, "initial_alt_cpb_removal_delay_offset" ); |
---|
780 | sei.m_initialAltCpbRemovalDelayOffset[i][nalOrVcl] = code; |
---|
781 | } |
---|
782 | } |
---|
783 | } |
---|
784 | } |
---|
785 | |
---|
786 | #if P0138_USE_ALT_CPB_PARAMS_FLAG |
---|
787 | sei.m_useAltCpbParamsFlag = false; |
---|
788 | sei.m_useAltCpbParamsFlagPresent = false; |
---|
789 | if (xPayloadExtensionPresent()) |
---|
790 | { |
---|
791 | READ_FLAG (code, "use_alt_cpb_params_flag"); |
---|
792 | sei.m_useAltCpbParamsFlag = code; |
---|
793 | sei.m_useAltCpbParamsFlagPresent = true; |
---|
794 | } |
---|
795 | #endif |
---|
796 | |
---|
797 | xParseByteAlign(); |
---|
798 | } |
---|
799 | #if VPS_VUI_BSP_HRD_PARAMS |
---|
800 | Void SEIReader::xParseSEIPictureTiming(SEIPictureTiming& sei, UInt /*payloadSize*/, TComSPS *sps, const SEIScalableNesting* nestingSei, const SEIBspNesting* bspNestingSei, TComVPS *vps) |
---|
801 | #else |
---|
802 | Void SEIReader::xParseSEIPictureTiming(SEIPictureTiming& sei, UInt /*payloadSize*/, TComSPS *sps) |
---|
803 | #endif |
---|
804 | { |
---|
805 | Int i; |
---|
806 | UInt code; |
---|
807 | |
---|
808 | #if VPS_VUI_BSP_HRD_PARAMS |
---|
809 | TComHRD *hrd; |
---|
810 | TComVUI *vui = sps->getVuiParameters(); |
---|
811 | if( bspNestingSei ) // If BP SEI contained inside a BSP nesting SEI message |
---|
812 | { |
---|
813 | assert( nestingSei ); |
---|
814 | Int psIdx = bspNestingSei->m_seiPartitioningSchemeIdx; |
---|
815 | Int seiOlsIdx = bspNestingSei->m_seiOlsIdx; |
---|
816 | Int maxTemporalId = nestingSei->m_nestingMaxTemporalIdPlus1[0] - 1; |
---|
817 | Int maxValues = vps->getNumBspSchedulesMinus1(seiOlsIdx, psIdx, maxTemporalId) + 1; |
---|
818 | std::vector<Int> hrdIdx(maxValues, 0); |
---|
819 | std::vector<TComHRD *> hrdVec; |
---|
820 | std::vector<Int> syntaxElemLen(maxValues, 0); |
---|
821 | for(i = 0; i < maxValues; i++) |
---|
822 | { |
---|
823 | hrdIdx[i] = vps->getBspHrdIdx( seiOlsIdx, psIdx, maxTemporalId, i, bspNestingSei->m_bspIdx); |
---|
824 | hrdVec.push_back(vps->getBspHrd(hrdIdx[i])); |
---|
825 | |
---|
826 | syntaxElemLen[i] = hrdVec[i]->getInitialCpbRemovalDelayLengthMinus1() + 1; |
---|
827 | if ( !(hrdVec[i]->getNalHrdParametersPresentFlag() || hrdVec[i]->getVclHrdParametersPresentFlag()) ) |
---|
828 | { |
---|
829 | assert( syntaxElemLen[i] == 24 ); // Default of value init_cpb_removal_delay_length_minus1 is 23 |
---|
830 | } |
---|
831 | if( i > 0 ) |
---|
832 | { |
---|
833 | assert( hrdVec[i]->getSubPicCpbParamsPresentFlag() == hrdVec[i-1]->getSubPicCpbParamsPresentFlag() ); |
---|
834 | assert( hrdVec[i]->getSubPicCpbParamsInPicTimingSEIFlag() == hrdVec[i-1]->getSubPicCpbParamsInPicTimingSEIFlag() ); |
---|
835 | assert( hrdVec[i]->getCpbRemovalDelayLengthMinus1() == hrdVec[i-1]->getCpbRemovalDelayLengthMinus1() ); |
---|
836 | assert( hrdVec[i]->getDpbOutputDelayLengthMinus1() == hrdVec[i-1]->getDpbOutputDelayLengthMinus1() ); |
---|
837 | assert( hrdVec[i]->getDpbOutputDelayDuLengthMinus1() == hrdVec[i-1]->getDpbOutputDelayDuLengthMinus1() ); |
---|
838 | assert( hrdVec[i]->getDuCpbRemovalDelayLengthMinus1() == hrdVec[i-1]->getDuCpbRemovalDelayLengthMinus1() ); |
---|
839 | // To be done: Check CpbDpbDelaysPresentFlag |
---|
840 | } |
---|
841 | } |
---|
842 | hrd = hrdVec[0]; |
---|
843 | } |
---|
844 | else |
---|
845 | { |
---|
846 | hrd = vui->getHrdParameters(); |
---|
847 | } |
---|
848 | // To be done: When contained in an BSP HRD SEI message, the hrd structure is to be chosen differently. |
---|
849 | #else |
---|
850 | TComVUI *vui = sps->getVuiParameters(); |
---|
851 | TComHRD *hrd = vui->getHrdParameters(); |
---|
852 | #endif |
---|
853 | |
---|
854 | if( vui->getFrameFieldInfoPresentFlag() ) |
---|
855 | { |
---|
856 | READ_CODE( 4, code, "pic_struct" ); sei.m_picStruct = code; |
---|
857 | READ_CODE( 2, code, "source_scan_type" ); sei.m_sourceScanType = code; |
---|
858 | READ_FLAG( code, "duplicate_flag" ); sei.m_duplicateFlag = ( code == 1 ? true : false ); |
---|
859 | } |
---|
860 | |
---|
861 | if( hrd->getCpbDpbDelaysPresentFlag()) |
---|
862 | { |
---|
863 | READ_CODE( ( hrd->getCpbRemovalDelayLengthMinus1() + 1 ), code, "au_cpb_removal_delay_minus1" ); |
---|
864 | sei.m_auCpbRemovalDelay = code + 1; |
---|
865 | READ_CODE( ( hrd->getDpbOutputDelayLengthMinus1() + 1 ), code, "pic_dpb_output_delay" ); |
---|
866 | sei.m_picDpbOutputDelay = code; |
---|
867 | |
---|
868 | if(hrd->getSubPicCpbParamsPresentFlag()) |
---|
869 | { |
---|
870 | READ_CODE(hrd->getDpbOutputDelayDuLengthMinus1()+1, code, "pic_dpb_output_du_delay" ); |
---|
871 | sei.m_picDpbOutputDuDelay = code; |
---|
872 | } |
---|
873 | if( hrd->getSubPicCpbParamsPresentFlag() && hrd->getSubPicCpbParamsInPicTimingSEIFlag() ) |
---|
874 | { |
---|
875 | READ_UVLC( code, "num_decoding_units_minus1"); |
---|
876 | sei.m_numDecodingUnitsMinus1 = code; |
---|
877 | READ_FLAG( code, "du_common_cpb_removal_delay_flag" ); |
---|
878 | sei.m_duCommonCpbRemovalDelayFlag = code; |
---|
879 | if( sei.m_duCommonCpbRemovalDelayFlag ) |
---|
880 | { |
---|
881 | READ_CODE( ( hrd->getDuCpbRemovalDelayLengthMinus1() + 1 ), code, "du_common_cpb_removal_delay_minus1" ); |
---|
882 | sei.m_duCommonCpbRemovalDelayMinus1 = code; |
---|
883 | } |
---|
884 | if( sei.m_numNalusInDuMinus1 != NULL ) |
---|
885 | { |
---|
886 | delete sei.m_numNalusInDuMinus1; |
---|
887 | } |
---|
888 | sei.m_numNalusInDuMinus1 = new UInt[ ( sei.m_numDecodingUnitsMinus1 + 1 ) ]; |
---|
889 | if( sei.m_duCpbRemovalDelayMinus1 != NULL ) |
---|
890 | { |
---|
891 | delete sei.m_duCpbRemovalDelayMinus1; |
---|
892 | } |
---|
893 | sei.m_duCpbRemovalDelayMinus1 = new UInt[ ( sei.m_numDecodingUnitsMinus1 + 1 ) ]; |
---|
894 | |
---|
895 | for( i = 0; i <= sei.m_numDecodingUnitsMinus1; i ++ ) |
---|
896 | { |
---|
897 | READ_UVLC( code, "num_nalus_in_du_minus1"); |
---|
898 | sei.m_numNalusInDuMinus1[ i ] = code; |
---|
899 | if( ( !sei.m_duCommonCpbRemovalDelayFlag ) && ( i < sei.m_numDecodingUnitsMinus1 ) ) |
---|
900 | { |
---|
901 | READ_CODE( ( hrd->getDuCpbRemovalDelayLengthMinus1() + 1 ), code, "du_cpb_removal_delay_minus1" ); |
---|
902 | sei.m_duCpbRemovalDelayMinus1[ i ] = code; |
---|
903 | } |
---|
904 | } |
---|
905 | } |
---|
906 | } |
---|
907 | xParseByteAlign(); |
---|
908 | } |
---|
909 | Void SEIReader::xParseSEIRecoveryPoint(SEIRecoveryPoint& sei, UInt /*payloadSize*/) |
---|
910 | { |
---|
911 | Int iCode; |
---|
912 | UInt uiCode; |
---|
913 | READ_SVLC( iCode, "recovery_poc_cnt" ); sei.m_recoveryPocCnt = iCode; |
---|
914 | READ_FLAG( uiCode, "exact_matching_flag" ); sei.m_exactMatchingFlag = uiCode; |
---|
915 | READ_FLAG( uiCode, "broken_link_flag" ); sei.m_brokenLinkFlag = uiCode; |
---|
916 | xParseByteAlign(); |
---|
917 | } |
---|
918 | Void SEIReader::xParseSEIFramePacking(SEIFramePacking& sei, UInt /*payloadSize*/) |
---|
919 | { |
---|
920 | UInt val; |
---|
921 | READ_UVLC( val, "frame_packing_arrangement_id" ); sei.m_arrangementId = val; |
---|
922 | READ_FLAG( val, "frame_packing_arrangement_cancel_flag" ); sei.m_arrangementCancelFlag = val; |
---|
923 | |
---|
924 | if ( !sei.m_arrangementCancelFlag ) |
---|
925 | { |
---|
926 | READ_CODE( 7, val, "frame_packing_arrangement_type" ); sei.m_arrangementType = val; |
---|
927 | assert((sei.m_arrangementType > 2) && (sei.m_arrangementType < 6) ); |
---|
928 | READ_FLAG( val, "quincunx_sampling_flag" ); sei.m_quincunxSamplingFlag = val; |
---|
929 | |
---|
930 | READ_CODE( 6, val, "content_interpretation_type" ); sei.m_contentInterpretationType = val; |
---|
931 | READ_FLAG( val, "spatial_flipping_flag" ); sei.m_spatialFlippingFlag = val; |
---|
932 | READ_FLAG( val, "frame0_flipped_flag" ); sei.m_frame0FlippedFlag = val; |
---|
933 | READ_FLAG( val, "field_views_flag" ); sei.m_fieldViewsFlag = val; |
---|
934 | READ_FLAG( val, "current_frame_is_frame0_flag" ); sei.m_currentFrameIsFrame0Flag = val; |
---|
935 | READ_FLAG( val, "frame0_self_contained_flag" ); sei.m_frame0SelfContainedFlag = val; |
---|
936 | READ_FLAG( val, "frame1_self_contained_flag" ); sei.m_frame1SelfContainedFlag = val; |
---|
937 | |
---|
938 | if ( sei.m_quincunxSamplingFlag == 0 && sei.m_arrangementType != 5) |
---|
939 | { |
---|
940 | READ_CODE( 4, val, "frame0_grid_position_x" ); sei.m_frame0GridPositionX = val; |
---|
941 | READ_CODE( 4, val, "frame0_grid_position_y" ); sei.m_frame0GridPositionY = val; |
---|
942 | READ_CODE( 4, val, "frame1_grid_position_x" ); sei.m_frame1GridPositionX = val; |
---|
943 | READ_CODE( 4, val, "frame1_grid_position_y" ); sei.m_frame1GridPositionY = val; |
---|
944 | } |
---|
945 | |
---|
946 | READ_CODE( 8, val, "frame_packing_arrangement_reserved_byte" ); sei.m_arrangementReservedByte = val; |
---|
947 | READ_FLAG( val, "frame_packing_arrangement_persistence_flag" ); sei.m_arrangementPersistenceFlag = val ? true : false; |
---|
948 | } |
---|
949 | READ_FLAG( val, "upsampled_aspect_ratio" ); sei.m_upsampledAspectRatio = val; |
---|
950 | |
---|
951 | xParseByteAlign(); |
---|
952 | } |
---|
953 | |
---|
954 | Void SEIReader::xParseSEIDisplayOrientation(SEIDisplayOrientation& sei, UInt /*payloadSize*/) |
---|
955 | { |
---|
956 | UInt val; |
---|
957 | READ_FLAG( val, "display_orientation_cancel_flag" ); sei.cancelFlag = val; |
---|
958 | if( !sei.cancelFlag ) |
---|
959 | { |
---|
960 | READ_FLAG( val, "hor_flip" ); sei.horFlip = val; |
---|
961 | READ_FLAG( val, "ver_flip" ); sei.verFlip = val; |
---|
962 | READ_CODE( 16, val, "anticlockwise_rotation" ); sei.anticlockwiseRotation = val; |
---|
963 | READ_FLAG( val, "display_orientation_persistence_flag" ); sei.persistenceFlag = val; |
---|
964 | } |
---|
965 | xParseByteAlign(); |
---|
966 | } |
---|
967 | |
---|
968 | Void SEIReader::xParseSEITemporalLevel0Index(SEITemporalLevel0Index& sei, UInt /*payloadSize*/) |
---|
969 | { |
---|
970 | UInt val; |
---|
971 | READ_CODE ( 8, val, "tl0_idx" ); sei.tl0Idx = val; |
---|
972 | READ_CODE ( 8, val, "rap_idx" ); sei.rapIdx = val; |
---|
973 | xParseByteAlign(); |
---|
974 | } |
---|
975 | |
---|
976 | Void SEIReader::xParseSEIGradualDecodingRefreshInfo(SEIGradualDecodingRefreshInfo& sei, UInt /*payloadSize*/) |
---|
977 | { |
---|
978 | UInt val; |
---|
979 | READ_FLAG( val, "gdr_foreground_flag" ); sei.m_gdrForegroundFlag = val ? 1 : 0; |
---|
980 | xParseByteAlign(); |
---|
981 | } |
---|
982 | |
---|
983 | Void SEIReader::xParseSEIToneMappingInfo(SEIToneMappingInfo& sei, UInt /*payloadSize*/) |
---|
984 | { |
---|
985 | Int i; |
---|
986 | UInt val; |
---|
987 | READ_UVLC( val, "tone_map_id" ); sei.m_toneMapId = val; |
---|
988 | READ_FLAG( val, "tone_map_cancel_flag" ); sei.m_toneMapCancelFlag = val; |
---|
989 | |
---|
990 | if ( !sei.m_toneMapCancelFlag ) |
---|
991 | { |
---|
992 | READ_FLAG( val, "tone_map_persistence_flag" ); sei.m_toneMapPersistenceFlag = val; |
---|
993 | READ_CODE( 8, val, "coded_data_bit_depth" ); sei.m_codedDataBitDepth = val; |
---|
994 | READ_CODE( 8, val, "target_bit_depth" ); sei.m_targetBitDepth = val; |
---|
995 | READ_UVLC( val, "model_id" ); sei.m_modelId = val; |
---|
996 | switch(sei.m_modelId) |
---|
997 | { |
---|
998 | case 0: |
---|
999 | { |
---|
1000 | READ_CODE( 32, val, "min_value" ); sei.m_minValue = val; |
---|
1001 | READ_CODE( 32, val, "max_value" ); sei.m_maxValue = val; |
---|
1002 | break; |
---|
1003 | } |
---|
1004 | case 1: |
---|
1005 | { |
---|
1006 | READ_CODE( 32, val, "sigmoid_midpoint" ); sei.m_sigmoidMidpoint = val; |
---|
1007 | READ_CODE( 32, val, "sigmoid_width" ); sei.m_sigmoidWidth = val; |
---|
1008 | break; |
---|
1009 | } |
---|
1010 | case 2: |
---|
1011 | { |
---|
1012 | UInt num = 1u << sei.m_targetBitDepth; |
---|
1013 | sei.m_startOfCodedInterval.resize(num+1); |
---|
1014 | for(i = 0; i < num; i++) |
---|
1015 | { |
---|
1016 | READ_CODE( ((( sei.m_codedDataBitDepth + 7 ) >> 3 ) << 3), val, "start_of_coded_interval" ); |
---|
1017 | sei.m_startOfCodedInterval[i] = val; |
---|
1018 | } |
---|
1019 | sei.m_startOfCodedInterval[num] = 1u << sei.m_codedDataBitDepth; |
---|
1020 | break; |
---|
1021 | } |
---|
1022 | case 3: |
---|
1023 | { |
---|
1024 | READ_CODE( 16, val, "num_pivots" ); sei.m_numPivots = val; |
---|
1025 | sei.m_codedPivotValue.resize(sei.m_numPivots); |
---|
1026 | sei.m_targetPivotValue.resize(sei.m_numPivots); |
---|
1027 | for(i = 0; i < sei.m_numPivots; i++ ) |
---|
1028 | { |
---|
1029 | READ_CODE( ((( sei.m_codedDataBitDepth + 7 ) >> 3 ) << 3), val, "coded_pivot_value" ); |
---|
1030 | sei.m_codedPivotValue[i] = val; |
---|
1031 | READ_CODE( ((( sei.m_targetBitDepth + 7 ) >> 3 ) << 3), val, "target_pivot_value" ); |
---|
1032 | sei.m_targetPivotValue[i] = val; |
---|
1033 | } |
---|
1034 | break; |
---|
1035 | } |
---|
1036 | case 4: |
---|
1037 | { |
---|
1038 | READ_CODE( 8, val, "camera_iso_speed_idc" ); sei.m_cameraIsoSpeedIdc = val; |
---|
1039 | if( sei.m_cameraIsoSpeedIdc == 255) //Extended_ISO |
---|
1040 | { |
---|
1041 | READ_CODE( 32, val, "camera_iso_speed_value" ); sei.m_cameraIsoSpeedValue = val; |
---|
1042 | } |
---|
1043 | READ_CODE( 8, val, "exposure_index_idc" ); sei.m_exposureIndexIdc = val; |
---|
1044 | if( sei.m_exposureIndexIdc == 255) //Extended_ISO |
---|
1045 | { |
---|
1046 | READ_CODE( 32, val, "exposure_index_value" ); sei.m_exposureIndexValue = val; |
---|
1047 | } |
---|
1048 | READ_FLAG( val, "exposure_compensation_value_sign_flag" ); sei.m_exposureCompensationValueSignFlag = val; |
---|
1049 | READ_CODE( 16, val, "exposure_compensation_value_numerator" ); sei.m_exposureCompensationValueNumerator = val; |
---|
1050 | READ_CODE( 16, val, "exposure_compensation_value_denom_idc" ); sei.m_exposureCompensationValueDenomIdc = val; |
---|
1051 | READ_CODE( 32, val, "ref_screen_luminance_white" ); sei.m_refScreenLuminanceWhite = val; |
---|
1052 | READ_CODE( 32, val, "extended_range_white_level" ); sei.m_extendedRangeWhiteLevel = val; |
---|
1053 | READ_CODE( 16, val, "nominal_black_level_luma_code_value" ); sei.m_nominalBlackLevelLumaCodeValue = val; |
---|
1054 | READ_CODE( 16, val, "nominal_white_level_luma_code_value" ); sei.m_nominalWhiteLevelLumaCodeValue= val; |
---|
1055 | READ_CODE( 16, val, "extended_white_level_luma_code_value" ); sei.m_extendedWhiteLevelLumaCodeValue = val; |
---|
1056 | break; |
---|
1057 | } |
---|
1058 | default: |
---|
1059 | { |
---|
1060 | assert(!"Undefined SEIToneMapModelId"); |
---|
1061 | break; |
---|
1062 | } |
---|
1063 | }//switch model id |
---|
1064 | }// if(!sei.m_toneMapCancelFlag) |
---|
1065 | |
---|
1066 | xParseByteAlign(); |
---|
1067 | } |
---|
1068 | |
---|
1069 | #if P0050_KNEE_FUNCTION_SEI |
---|
1070 | Void SEIReader::xParseSEIKneeFunctionInfo(SEIKneeFunctionInfo& sei, UInt /*payloadSize*/){ |
---|
1071 | Int i; |
---|
1072 | UInt val; |
---|
1073 | READ_UVLC( val, "knee_function_id" ); sei.m_kneeId = val; |
---|
1074 | READ_FLAG( val, "knee_function_cancel_flag" ); sei.m_kneeCancelFlag = val; |
---|
1075 | if ( !sei.m_kneeCancelFlag ) |
---|
1076 | { |
---|
1077 | READ_FLAG( val, "knee_function_persistence_flag" ); sei.m_kneePersistenceFlag = val; |
---|
1078 | READ_FLAG( val, "mapping_flag" ); sei.m_kneeMappingFlag = val; |
---|
1079 | READ_CODE( 32, val, "input_d_range" ); sei.m_kneeInputDrange = val; |
---|
1080 | READ_CODE( 32, val, "input_disp_luminance" ); sei.m_kneeInputDispLuminance = val; |
---|
1081 | READ_CODE( 32, val, "output_d_range" ); sei.m_kneeOutputDrange = val; |
---|
1082 | READ_CODE( 32, val, "output_disp_luminance" ); sei.m_kneeOutputDispLuminance = val; |
---|
1083 | READ_UVLC( val, "num_knee_points_minus1" ); sei.m_kneeNumKneePointsMinus1 = val; |
---|
1084 | assert( sei.m_kneeNumKneePointsMinus1 > 0 ); |
---|
1085 | sei.m_kneeInputKneePoint.resize(sei.m_kneeNumKneePointsMinus1+1); |
---|
1086 | sei.m_kneeOutputKneePoint.resize(sei.m_kneeNumKneePointsMinus1+1); |
---|
1087 | for(i = 0; i <= sei.m_kneeNumKneePointsMinus1; i++ ) |
---|
1088 | { |
---|
1089 | READ_CODE( 10, val, "input_knee_point" ); sei.m_kneeInputKneePoint[i] = val; |
---|
1090 | READ_CODE( 10, val, "output_knee_point" ); sei.m_kneeOutputKneePoint[i] = val; |
---|
1091 | } |
---|
1092 | } |
---|
1093 | } |
---|
1094 | #endif |
---|
1095 | |
---|
1096 | #if Q0074_COLOUR_REMAPPING_SEI |
---|
1097 | Void SEIReader::xParseSEIColourRemappingInfo(SEIColourRemappingInfo& sei, UInt /*payloadSize*/) |
---|
1098 | { |
---|
1099 | UInt uiVal; |
---|
1100 | Int iVal; |
---|
1101 | |
---|
1102 | READ_UVLC( uiVal, "colour_remap_id" ); sei.m_colourRemapId = uiVal; |
---|
1103 | READ_FLAG( uiVal, "colour_remap_cancel_flag" ); sei.m_colourRemapCancelFlag = uiVal; |
---|
1104 | if( !sei.m_colourRemapCancelFlag ) |
---|
1105 | { |
---|
1106 | READ_FLAG( uiVal, "colour_remap_persistence_flag" ); sei.m_colourRemapPersistenceFlag = uiVal; |
---|
1107 | READ_FLAG( uiVal, "colour_remap_video_signal_info_present_flag" ); sei.m_colourRemapVideoSignalInfoPresentFlag = uiVal; |
---|
1108 | if ( sei.m_colourRemapVideoSignalInfoPresentFlag ) |
---|
1109 | { |
---|
1110 | READ_FLAG( uiVal, "colour_remap_full_range_flag" ); sei.m_colourRemapFullRangeFlag = uiVal; |
---|
1111 | READ_CODE( 8, uiVal, "colour_remap_primaries" ); sei.m_colourRemapPrimaries = uiVal; |
---|
1112 | READ_CODE( 8, uiVal, "colour_remap_transfer_function" ); sei.m_colourRemapTransferFunction = uiVal; |
---|
1113 | READ_CODE( 8, uiVal, "colour_remap_matrix_coefficients" ); sei.m_colourRemapMatrixCoefficients = uiVal; |
---|
1114 | } |
---|
1115 | READ_CODE( 8, uiVal, "colour_remap_input_bit_depth" ); sei.m_colourRemapInputBitDepth = uiVal; |
---|
1116 | READ_CODE( 8, uiVal, "colour_remap_bit_depth" ); sei.m_colourRemapBitDepth = uiVal; |
---|
1117 | |
---|
1118 | for( Int c=0 ; c<3 ; c++ ) |
---|
1119 | { |
---|
1120 | READ_CODE( 8, uiVal, "pre_lut_num_val_minus1[c]" ); sei.m_preLutNumValMinus1[c] = (uiVal==0) ? 1 : uiVal; |
---|
1121 | sei.m_preLutCodedValue[c].resize(sei.m_preLutNumValMinus1[c]+1); |
---|
1122 | sei.m_preLutTargetValue[c].resize(sei.m_preLutNumValMinus1[c]+1); |
---|
1123 | if( uiVal> 0 ) |
---|
1124 | for ( Int i=0 ; i<=sei.m_preLutNumValMinus1[c] ; i++ ) |
---|
1125 | { |
---|
1126 | READ_CODE( (( sei.m_colourRemapInputBitDepth + 7 ) >> 3 ) << 3, uiVal, "pre_lut_coded_value[c][i]" ); sei.m_preLutCodedValue[c][i] = uiVal; |
---|
1127 | READ_CODE( (( sei.m_colourRemapBitDepth + 7 ) >> 3 ) << 3, uiVal, "pre_lut_target_value[c][i]" ); sei.m_preLutTargetValue[c][i] = uiVal; |
---|
1128 | } |
---|
1129 | else // pre_lut_num_val_minus1[c] == 0 |
---|
1130 | { |
---|
1131 | sei.m_preLutCodedValue[c][0] = 0; |
---|
1132 | sei.m_preLutTargetValue[c][0] = 0; |
---|
1133 | sei.m_preLutCodedValue[c][1] = (1 << sei.m_colourRemapInputBitDepth) - 1 ; |
---|
1134 | sei.m_preLutTargetValue[c][1] = (1 << sei.m_colourRemapBitDepth) - 1 ; |
---|
1135 | } |
---|
1136 | } |
---|
1137 | |
---|
1138 | READ_FLAG( uiVal, "colour_remap_matrix_present_flag" ); sei.m_colourRemapMatrixPresentFlag = uiVal; |
---|
1139 | if( sei.m_colourRemapMatrixPresentFlag ) |
---|
1140 | { |
---|
1141 | READ_CODE( 4, uiVal, "log2_matrix_denom" ); sei.m_log2MatrixDenom = uiVal; |
---|
1142 | for ( Int c=0 ; c<3 ; c++ ) |
---|
1143 | for ( Int i=0 ; i<3 ; i++ ) |
---|
1144 | { |
---|
1145 | READ_SVLC( iVal, "colour_remap_coeffs[c][i]" ); sei.m_colourRemapCoeffs[c][i] = iVal; |
---|
1146 | } |
---|
1147 | } |
---|
1148 | else // setting default matrix (I3) |
---|
1149 | { |
---|
1150 | sei.m_log2MatrixDenom = 0; |
---|
1151 | for ( Int c=0 ; c<3 ; c++ ) |
---|
1152 | for ( Int i=0 ; i<3 ; i++ ) |
---|
1153 | sei.m_colourRemapCoeffs[c][i] = (c==i) ? 1 : 0; |
---|
1154 | } |
---|
1155 | for( Int c=0 ; c<3 ; c++ ) |
---|
1156 | { |
---|
1157 | READ_CODE( 8, uiVal, "post_lut_num_val_minus1[c]" ); sei.m_postLutNumValMinus1[c] = (uiVal==0) ? 1 : uiVal; |
---|
1158 | sei.m_postLutCodedValue[c].resize(sei.m_postLutNumValMinus1[c]+1); |
---|
1159 | sei.m_postLutTargetValue[c].resize(sei.m_postLutNumValMinus1[c]+1); |
---|
1160 | if( uiVal > 0 ) |
---|
1161 | for ( Int i=0 ; i<=sei.m_postLutNumValMinus1[c] ; i++ ) |
---|
1162 | { |
---|
1163 | READ_CODE( (( sei.m_colourRemapBitDepth + 7 ) >> 3 ) << 3, uiVal, "post_lut_coded_value[c][i]" ); sei.m_postLutCodedValue[c][i] = uiVal; |
---|
1164 | READ_CODE( (( sei.m_colourRemapBitDepth + 7 ) >> 3 ) << 3, uiVal, "post_lut_target_value[c][i]" ); sei.m_postLutTargetValue[c][i] = uiVal; |
---|
1165 | } |
---|
1166 | else |
---|
1167 | { |
---|
1168 | sei.m_postLutCodedValue[c][0] = 0; |
---|
1169 | sei.m_postLutTargetValue[c][0] = 0; |
---|
1170 | sei.m_postLutTargetValue[c][1] = (1 << sei.m_colourRemapBitDepth) - 1; |
---|
1171 | sei.m_postLutCodedValue[c][1] = (1 << sei.m_colourRemapBitDepth) - 1; |
---|
1172 | } |
---|
1173 | } |
---|
1174 | } |
---|
1175 | |
---|
1176 | xParseByteAlign(); |
---|
1177 | } |
---|
1178 | #endif |
---|
1179 | |
---|
1180 | Void SEIReader::xParseSEISOPDescription(SEISOPDescription &sei, UInt payloadSize) |
---|
1181 | { |
---|
1182 | Int iCode; |
---|
1183 | UInt uiCode; |
---|
1184 | |
---|
1185 | READ_UVLC( uiCode, "sop_seq_parameter_set_id" ); sei.m_sopSeqParameterSetId = uiCode; |
---|
1186 | READ_UVLC( uiCode, "num_pics_in_sop_minus1" ); sei.m_numPicsInSopMinus1 = uiCode; |
---|
1187 | for (UInt i = 0; i <= sei.m_numPicsInSopMinus1; i++) |
---|
1188 | { |
---|
1189 | READ_CODE( 6, uiCode, "sop_desc_vcl_nalu_type" ); sei.m_sopDescVclNaluType[i] = uiCode; |
---|
1190 | READ_CODE( 3, sei.m_sopDescTemporalId[i], "sop_desc_temporal_id" ); sei.m_sopDescTemporalId[i] = uiCode; |
---|
1191 | if (sei.m_sopDescVclNaluType[i] != NAL_UNIT_CODED_SLICE_IDR_W_RADL && sei.m_sopDescVclNaluType[i] != NAL_UNIT_CODED_SLICE_IDR_N_LP) |
---|
1192 | { |
---|
1193 | READ_UVLC( sei.m_sopDescStRpsIdx[i], "sop_desc_st_rps_idx" ); sei.m_sopDescStRpsIdx[i] = uiCode; |
---|
1194 | } |
---|
1195 | if (i > 0) |
---|
1196 | { |
---|
1197 | READ_SVLC( iCode, "sop_desc_poc_delta" ); sei.m_sopDescPocDelta[i] = iCode; |
---|
1198 | } |
---|
1199 | } |
---|
1200 | |
---|
1201 | xParseByteAlign(); |
---|
1202 | } |
---|
1203 | |
---|
1204 | #if Q0189_TMVP_CONSTRAINTS |
---|
1205 | Void SEIReader::xParseSEITMVPConstraints (SEITMVPConstrains& sei, UInt payloadSize) |
---|
1206 | { |
---|
1207 | UInt uiCode; |
---|
1208 | READ_UVLC( uiCode, "prev_pics_not_used_flag" ); sei.prev_pics_not_used_flag = uiCode; |
---|
1209 | READ_UVLC( uiCode, "no_intra_layer_col_pic_flag" ); sei.no_intra_layer_col_pic_flag = uiCode; |
---|
1210 | xParseByteAlign(); |
---|
1211 | } |
---|
1212 | #endif |
---|
1213 | |
---|
1214 | #if Q0247_FRAME_FIELD_INFO |
---|
1215 | Void SEIReader::xParseSEIFrameFieldInfo (SEIFrameFieldInfo& sei, UInt payloadSize) |
---|
1216 | { |
---|
1217 | UInt code; |
---|
1218 | READ_CODE( 4, code, "ffinfo_pic_struct" ); sei.m_ffinfo_picStruct = code; |
---|
1219 | READ_CODE( 2, code, "ffinfo_source_scan_type" ); sei.m_ffinfo_sourceScanType = code; |
---|
1220 | READ_FLAG( code, "ffinfo_duplicate_flag" ); sei.m_ffinfo_duplicateFlag = ( code == 1 ? true : false ); |
---|
1221 | xParseByteAlign(); |
---|
1222 | } |
---|
1223 | #endif |
---|
1224 | |
---|
1225 | #if LAYERS_NOT_PRESENT_SEI |
---|
1226 | Void SEIReader::xParseSEIScalableNesting(SEIScalableNesting& sei, const NalUnitType nalUnitType, UInt payloadSize, TComVPS *vps, TComSPS *sps) |
---|
1227 | #else |
---|
1228 | Void SEIReader::xParseSEIScalableNesting(SEIScalableNesting& sei, const NalUnitType nalUnitType, UInt payloadSize, TComSPS *sps) |
---|
1229 | #endif |
---|
1230 | { |
---|
1231 | UInt uiCode; |
---|
1232 | SEIMessages seis; |
---|
1233 | |
---|
1234 | READ_FLAG( uiCode, "bitstream_subset_flag" ); sei.m_bitStreamSubsetFlag = uiCode; |
---|
1235 | READ_FLAG( uiCode, "nesting_op_flag" ); sei.m_nestingOpFlag = uiCode; |
---|
1236 | if (sei.m_nestingOpFlag) |
---|
1237 | { |
---|
1238 | READ_FLAG( uiCode, "default_op_flag" ); sei.m_defaultOpFlag = uiCode; |
---|
1239 | READ_UVLC( uiCode, "nesting_num_ops_minus1" ); sei.m_nestingNumOpsMinus1 = uiCode; |
---|
1240 | for (UInt i = sei.m_defaultOpFlag; i <= sei.m_nestingNumOpsMinus1; i++) |
---|
1241 | { |
---|
1242 | READ_CODE( 3, uiCode, "nesting_max_temporal_id_plus1" ); sei.m_nestingMaxTemporalIdPlus1[i] = uiCode; |
---|
1243 | READ_UVLC( uiCode, "nesting_op_idx" ); sei.m_nestingOpIdx[i] = uiCode; |
---|
1244 | } |
---|
1245 | } |
---|
1246 | else |
---|
1247 | { |
---|
1248 | READ_FLAG( uiCode, "all_layers_flag" ); sei.m_allLayersFlag = uiCode; |
---|
1249 | if (!sei.m_allLayersFlag) |
---|
1250 | { |
---|
1251 | READ_CODE( 3, uiCode, "nesting_no_op_max_temporal_id_plus1" ); sei.m_nestingNoOpMaxTemporalIdPlus1 = uiCode; |
---|
1252 | READ_UVLC( uiCode, "nesting_num_layers_minus1" ); sei.m_nestingNumLayersMinus1 = uiCode; |
---|
1253 | for (UInt i = 0; i <= sei.m_nestingNumLayersMinus1; i++) |
---|
1254 | { |
---|
1255 | READ_CODE( 6, uiCode, "nesting_layer_id" ); sei.m_nestingLayerId[i] = uiCode; |
---|
1256 | } |
---|
1257 | } |
---|
1258 | } |
---|
1259 | |
---|
1260 | // byte alignment |
---|
1261 | while ( m_pcBitstream->getNumBitsRead() % 8 != 0 ) |
---|
1262 | { |
---|
1263 | UInt code; |
---|
1264 | READ_FLAG( code, "nesting_zero_bit" ); |
---|
1265 | } |
---|
1266 | |
---|
1267 | sei.m_callerOwnsSEIs = false; |
---|
1268 | |
---|
1269 | // read nested SEI messages |
---|
1270 | do { |
---|
1271 | #if O0164_MULTI_LAYER_HRD |
---|
1272 | #if LAYERS_NOT_PRESENT_SEI |
---|
1273 | xReadSEImessage(sei.m_nestedSEIs, nalUnitType, vps, sps, &sei); |
---|
1274 | #else |
---|
1275 | xReadSEImessage(sei.m_nestedSEIs, nalUnitType, sps, &sei); |
---|
1276 | #endif |
---|
1277 | #else |
---|
1278 | #if LAYERS_NOT_PRESENT_SEI |
---|
1279 | xReadSEImessage(sei.m_nestedSEIs, nalUnitType, vps, sps); |
---|
1280 | #else |
---|
1281 | xReadSEImessage(sei.m_nestedSEIs, nalUnitType, sps); |
---|
1282 | #endif |
---|
1283 | #endif |
---|
1284 | } while (m_pcBitstream->getNumBitsLeft() > 8); |
---|
1285 | |
---|
1286 | } |
---|
1287 | |
---|
1288 | Void SEIReader::xParseByteAlign() |
---|
1289 | { |
---|
1290 | UInt code; |
---|
1291 | if( m_pcBitstream->getNumBitsRead() % 8 != 0 ) |
---|
1292 | { |
---|
1293 | READ_FLAG( code, "bit_equal_to_one" ); assert( code == 1 ); |
---|
1294 | } |
---|
1295 | while( m_pcBitstream->getNumBitsRead() % 8 != 0 ) |
---|
1296 | { |
---|
1297 | READ_FLAG( code, "bit_equal_to_zero" ); assert( code == 0 ); |
---|
1298 | } |
---|
1299 | } |
---|
1300 | |
---|
1301 | #if SVC_EXTENSION |
---|
1302 | #if LAYERS_NOT_PRESENT_SEI |
---|
1303 | Void SEIReader::xParseSEILayersNotPresent(SEILayersNotPresent &sei, UInt payloadSize, TComVPS *vps) |
---|
1304 | { |
---|
1305 | UInt uiCode; |
---|
1306 | UInt i = 0; |
---|
1307 | |
---|
1308 | READ_UVLC( uiCode, "lp_sei_active_vps_id" ); sei.m_activeVpsId = uiCode; |
---|
1309 | assert(vps->getVPSId() == sei.m_activeVpsId); |
---|
1310 | sei.m_vpsMaxLayers = vps->getMaxLayers(); |
---|
1311 | for (; i < sei.m_vpsMaxLayers; i++) |
---|
1312 | { |
---|
1313 | READ_FLAG( uiCode, "layer_not_present_flag" ); sei.m_layerNotPresentFlag[i] = uiCode ? true : false; |
---|
1314 | } |
---|
1315 | for (; i < MAX_LAYERS; i++) |
---|
1316 | { |
---|
1317 | sei.m_layerNotPresentFlag[i] = false; |
---|
1318 | } |
---|
1319 | xParseByteAlign(); |
---|
1320 | } |
---|
1321 | #endif |
---|
1322 | #if N0383_IL_CONSTRAINED_TILE_SETS_SEI |
---|
1323 | Void SEIReader::xParseSEIInterLayerConstrainedTileSets (SEIInterLayerConstrainedTileSets &sei, UInt payloadSize) |
---|
1324 | { |
---|
1325 | UInt uiCode; |
---|
1326 | |
---|
1327 | READ_FLAG( uiCode, "il_all_tiles_exact_sample_value_match_flag" ); sei.m_ilAllTilesExactSampleValueMatchFlag = uiCode; |
---|
1328 | READ_FLAG( uiCode, "il_one_tile_per_tile_set_flag" ); sei.m_ilOneTilePerTileSetFlag = uiCode; |
---|
1329 | if( !sei.m_ilOneTilePerTileSetFlag ) |
---|
1330 | { |
---|
1331 | READ_UVLC( uiCode, "il_num_sets_in_message_minus1" ); sei.m_ilNumSetsInMessageMinus1 = uiCode; |
---|
1332 | if( sei.m_ilNumSetsInMessageMinus1 ) |
---|
1333 | { |
---|
1334 | READ_FLAG( uiCode, "skipped_tile_set_present_flag" ); sei.m_skippedTileSetPresentFlag = uiCode; |
---|
1335 | } |
---|
1336 | else |
---|
1337 | { |
---|
1338 | sei.m_skippedTileSetPresentFlag = false; |
---|
1339 | } |
---|
1340 | UInt numSignificantSets = sei.m_ilNumSetsInMessageMinus1 - (sei.m_skippedTileSetPresentFlag ? 1 : 0) + 1; |
---|
1341 | for( UInt i = 0; i < numSignificantSets; i++ ) |
---|
1342 | { |
---|
1343 | READ_UVLC( uiCode, "ilcts_id" ); sei.m_ilctsId[i] = uiCode; |
---|
1344 | READ_UVLC( uiCode, "il_num_tile_rects_in_set_minus1" ) ;sei.m_ilNumTileRectsInSetMinus1[i] = uiCode; |
---|
1345 | for( UInt j = 0; j <= sei.m_ilNumTileRectsInSetMinus1[i]; j++ ) |
---|
1346 | { |
---|
1347 | READ_UVLC( uiCode, "il_top_left_tile_index" ); sei.m_ilTopLeftTileIndex[i][j] = uiCode; |
---|
1348 | READ_UVLC( uiCode, "il_bottom_right_tile_index" ); sei.m_ilBottomRightTileIndex[i][j] = uiCode; |
---|
1349 | } |
---|
1350 | READ_CODE( 2, uiCode, "ilc_idc" ); sei.m_ilcIdc[i] = uiCode; |
---|
1351 | if( sei.m_ilAllTilesExactSampleValueMatchFlag ) |
---|
1352 | { |
---|
1353 | READ_FLAG( uiCode, "il_exact_sample_value_match_flag" ); sei.m_ilExactSampleValueMatchFlag[i] = uiCode; |
---|
1354 | } |
---|
1355 | } |
---|
1356 | } |
---|
1357 | else |
---|
1358 | { |
---|
1359 | READ_CODE( 2, uiCode, "all_tiles_ilc_idc" ); sei.m_allTilesIlcIdc = uiCode; |
---|
1360 | } |
---|
1361 | |
---|
1362 | xParseByteAlign(); |
---|
1363 | } |
---|
1364 | #endif |
---|
1365 | #if SUB_BITSTREAM_PROPERTY_SEI |
---|
1366 | #if OLS_IDX_CHK |
---|
1367 | Void SEIReader::xParseSEISubBitstreamProperty(SEISubBitstreamProperty &sei, TComVPS *vps) |
---|
1368 | #else |
---|
1369 | Void SEIReader::xParseSEISubBitstreamProperty(SEISubBitstreamProperty &sei) |
---|
1370 | #endif |
---|
1371 | { |
---|
1372 | UInt uiCode; |
---|
1373 | READ_CODE( 4, uiCode, "active_vps_id" ); sei.m_activeVpsId = uiCode; |
---|
1374 | READ_UVLC( uiCode, "num_additional_sub_streams_minus1" ); sei.m_numAdditionalSubStreams = uiCode + 1; |
---|
1375 | |
---|
1376 | for( Int i = 0; i < sei.m_numAdditionalSubStreams; i++ ) |
---|
1377 | { |
---|
1378 | READ_CODE( 2, uiCode, "sub_bitstream_mode[i]" ); sei.m_subBitstreamMode[i] = uiCode; |
---|
1379 | READ_UVLC( uiCode, "output_layer_set_idx_to_vps[i]" ); |
---|
1380 | #if OLS_IDX_CHK |
---|
1381 | // The value of output_layer_set_idx_to_vps[ i ] shall be in the range of 0 to NumOutputLayerSets − 1, inclusive. |
---|
1382 | assert(uiCode > 0 && uiCode <= vps->getNumOutputLayerSets()-1); |
---|
1383 | #endif |
---|
1384 | sei.m_outputLayerSetIdxToVps[i] = uiCode; |
---|
1385 | READ_CODE( 3, uiCode, "highest_sub_layer_id[i]" ); sei.m_highestSublayerId[i] = uiCode; |
---|
1386 | READ_CODE( 16, uiCode, "avg_bit_rate[i]" ); sei.m_avgBitRate[i] = uiCode; |
---|
1387 | READ_CODE( 16, uiCode, "max_bit_rate[i]" ); sei.m_maxBitRate[i] = uiCode; |
---|
1388 | } |
---|
1389 | xParseByteAlign(); |
---|
1390 | } |
---|
1391 | #endif |
---|
1392 | |
---|
1393 | #if O0164_MULTI_LAYER_HRD |
---|
1394 | #if LAYERS_NOT_PRESENT_SEI |
---|
1395 | Void SEIReader::xParseSEIBspNesting(SEIBspNesting &sei, const NalUnitType nalUnitType, TComVPS *vps, TComSPS *sps, const SEIScalableNesting &nestingSei) |
---|
1396 | #else |
---|
1397 | Void SEIReader::xParseSEIBspNesting(SEIBspNesting &sei, const NalUnitType nalUnitType, TComSPS *sps, const SEIScalableNesting &nestingSei) |
---|
1398 | #endif |
---|
1399 | { |
---|
1400 | UInt uiCode; |
---|
1401 | READ_UVLC( uiCode, "bsp_idx" ); sei.m_bspIdx = uiCode; |
---|
1402 | |
---|
1403 | // byte alignment |
---|
1404 | while ( m_pcBitstream->getNumBitsRead() % 8 != 0 ) |
---|
1405 | { |
---|
1406 | UInt code; |
---|
1407 | READ_FLAG( code, "bsp_nesting_zero_bit" ); |
---|
1408 | } |
---|
1409 | |
---|
1410 | sei.m_callerOwnsSEIs = false; |
---|
1411 | |
---|
1412 | // read nested SEI messages |
---|
1413 | #if NESTING_SEI_EXTENSIBILITY |
---|
1414 | Int numSeiMessages = 0; |
---|
1415 | READ_UVLC( uiCode, "num_seis_in_bsp_minus1" ); assert( uiCode <= MAX_SEIS_IN_BSP_NESTING ); |
---|
1416 | numSeiMessages = uiCode; |
---|
1417 | for(Int i = 0; i < numSeiMessages; i++) |
---|
1418 | { |
---|
1419 | xReadSEImessage(sei.m_nestedSEIs, nalUnitType, vps, sps, &nestingSei, &sei); |
---|
1420 | } |
---|
1421 | #else |
---|
1422 | do { |
---|
1423 | #if LAYERS_NOT_PRESENT_SEI |
---|
1424 | xReadSEImessage(sei.m_nestedSEIs, nalUnitType, vps, sps, &nestingSei, &sei); |
---|
1425 | #else |
---|
1426 | xReadSEImessage(sei.m_nestedSEIs, nalUnitType, sps, &nestingSei); |
---|
1427 | #endif |
---|
1428 | } while (m_pcBitstream->getNumBitsLeft() > 8); |
---|
1429 | #endif |
---|
1430 | } |
---|
1431 | |
---|
1432 | Void SEIReader::xParseSEIBspInitialArrivalTime(SEIBspInitialArrivalTime &sei, TComVPS *vps, TComSPS *sps, const SEIScalableNesting &nestingSei, const SEIBspNesting &bspNestingSei) |
---|
1433 | { |
---|
1434 | assert(vps->getVpsVuiPresentFlag()); |
---|
1435 | |
---|
1436 | #if VPS_VUI_BSP_HRD_PARAMS |
---|
1437 | UInt uiCode; |
---|
1438 | Int psIdx = bspNestingSei.m_seiPartitioningSchemeIdx; |
---|
1439 | Int seiOlsIdx = bspNestingSei.m_seiOlsIdx; |
---|
1440 | Int maxTemporalId = nestingSei.m_nestingMaxTemporalIdPlus1[0]; |
---|
1441 | Int maxValues = vps->getNumBspSchedulesMinus1(seiOlsIdx, psIdx, maxTemporalId) + 1; |
---|
1442 | std::vector<Int> hrdIdx(0, maxValues); |
---|
1443 | std::vector<TComHRD *> hrdVec; |
---|
1444 | std::vector<Int> syntaxElemLen; |
---|
1445 | for(Int i = 0; i < maxValues; i++) |
---|
1446 | { |
---|
1447 | hrdIdx[i] = vps->getBspHrdIdx( seiOlsIdx, psIdx, maxTemporalId, i, bspNestingSei.m_bspIdx); |
---|
1448 | hrdVec[i] = vps->getBspHrd(hrdIdx[i]); |
---|
1449 | |
---|
1450 | syntaxElemLen[i] = hrdVec[i]->getInitialCpbRemovalDelayLengthMinus1() + 1; |
---|
1451 | if ( !(hrdVec[i]->getNalHrdParametersPresentFlag() || hrdVec[i]->getVclHrdParametersPresentFlag()) ) |
---|
1452 | { |
---|
1453 | assert( syntaxElemLen[i] == 24 ); // Default value of init_cpb_removal_delay_length_minus1 is 23 |
---|
1454 | } |
---|
1455 | if( i > 0 ) |
---|
1456 | { |
---|
1457 | assert( hrdVec[i]->getNalHrdParametersPresentFlag() == hrdVec[i-1]->getNalHrdParametersPresentFlag() ); |
---|
1458 | assert( hrdVec[i]->getVclHrdParametersPresentFlag() == hrdVec[i-1]->getVclHrdParametersPresentFlag() ); |
---|
1459 | } |
---|
1460 | } |
---|
1461 | if (hrdVec[0]->getNalHrdParametersPresentFlag()) |
---|
1462 | { |
---|
1463 | for(UInt i = 0; i < maxValues; i++) |
---|
1464 | { |
---|
1465 | READ_CODE( syntaxElemLen[i], uiCode, "nal_initial_arrival_delay[i]" ); sei.m_nalInitialArrivalDelay[i] = uiCode; |
---|
1466 | } |
---|
1467 | } |
---|
1468 | if( hrdVec[0]->getVclHrdParametersPresentFlag() ) |
---|
1469 | { |
---|
1470 | for(UInt i = 0; i < maxValues; i++) |
---|
1471 | { |
---|
1472 | READ_CODE( syntaxElemLen[i], uiCode, "vcl_initial_arrival_delay[i]" ); sei.m_vclInitialArrivalDelay[i] = uiCode; |
---|
1473 | } |
---|
1474 | } |
---|
1475 | #else |
---|
1476 | UInt schedCombCnt = vps->getNumBspSchedCombinations(nestingSei.m_nestingOpIdx[0]); |
---|
1477 | UInt len; |
---|
1478 | UInt hrdIdx; |
---|
1479 | UInt uiCode; |
---|
1480 | |
---|
1481 | if (schedCombCnt > 0) |
---|
1482 | { |
---|
1483 | hrdIdx = vps->getBspCombHrdIdx(nestingSei.m_nestingOpIdx[0], 0, bspNestingSei.m_bspIdx); |
---|
1484 | } |
---|
1485 | else |
---|
1486 | { |
---|
1487 | hrdIdx = 0; |
---|
1488 | } |
---|
1489 | |
---|
1490 | TComHRD *hrd = vps->getBspHrd(hrdIdx); |
---|
1491 | |
---|
1492 | if (hrd->getNalHrdParametersPresentFlag() || hrd->getVclHrdParametersPresentFlag()) |
---|
1493 | { |
---|
1494 | len = hrd->getInitialCpbRemovalDelayLengthMinus1() + 1; |
---|
1495 | } |
---|
1496 | else |
---|
1497 | { |
---|
1498 | len = 23 + 1; |
---|
1499 | } |
---|
1500 | |
---|
1501 | if (hrd->getNalHrdParametersPresentFlag()) |
---|
1502 | { |
---|
1503 | for(UInt i = 0; i < schedCombCnt; i++) |
---|
1504 | { |
---|
1505 | READ_CODE( len, uiCode, "nal_initial_arrival_delay" ); sei.m_nalInitialArrivalDelay[i] = uiCode; |
---|
1506 | } |
---|
1507 | } |
---|
1508 | #if BSP_INIT_ARRIVAL_SEI |
---|
1509 | if( hrd->getVclHrdParametersPresentFlag() ) |
---|
1510 | #else |
---|
1511 | else |
---|
1512 | #endif |
---|
1513 | { |
---|
1514 | for(UInt i = 0; i < schedCombCnt; i++) |
---|
1515 | { |
---|
1516 | READ_CODE( len, uiCode, "vcl_initial_arrival_delay" ); sei.m_vclInitialArrivalDelay[i] = uiCode; |
---|
1517 | } |
---|
1518 | } |
---|
1519 | #endif |
---|
1520 | } |
---|
1521 | |
---|
1522 | #if !REMOVE_BSP_HRD_SEI |
---|
1523 | Void SEIReader::xParseSEIBspHrd(SEIBspHrd &sei, TComSPS *sps, const SEIScalableNesting &nestingSei) |
---|
1524 | { |
---|
1525 | UInt uiCode; |
---|
1526 | READ_UVLC( uiCode, "sei_num_bsp_hrd_parameters_minus1" ); sei.m_seiNumBspHrdParametersMinus1 = uiCode; |
---|
1527 | for (UInt i = 0; i <= sei.m_seiNumBspHrdParametersMinus1; i++) |
---|
1528 | { |
---|
1529 | if (i > 0) |
---|
1530 | { |
---|
1531 | READ_FLAG( uiCode, "sei_bsp_cprms_present_flag" ); sei.m_seiBspCprmsPresentFlag[i] = uiCode; |
---|
1532 | } |
---|
1533 | xParseHrdParameters(sei.hrd, i==0 ? 1 : sei.m_seiBspCprmsPresentFlag[i], nestingSei.m_nestingMaxTemporalIdPlus1[0]-1); |
---|
1534 | } |
---|
1535 | for (UInt h = 0; h <= nestingSei.m_nestingNumOpsMinus1; h++) |
---|
1536 | { |
---|
1537 | UInt lsIdx = nestingSei.m_nestingOpIdx[h]; |
---|
1538 | READ_UVLC( uiCode, "num_sei_bitstream_partitions_minus1[i]"); sei.m_seiNumBitstreamPartitionsMinus1[lsIdx] = uiCode; |
---|
1539 | #if HRD_BPB |
---|
1540 | Int chkPart=0; |
---|
1541 | #endif |
---|
1542 | UInt i; |
---|
1543 | for(i = 0; i <= sei.m_seiNumBitstreamPartitionsMinus1[lsIdx]; i++) |
---|
1544 | { |
---|
1545 | #if HRD_BPB |
---|
1546 | UInt nl=0; UInt j; |
---|
1547 | for(j = 0; j < sei.m_vpsMaxLayers; j++) |
---|
1548 | { |
---|
1549 | if (sei.m_layerIdIncludedFlag[lsIdx][j]) |
---|
1550 | { |
---|
1551 | nl++; |
---|
1552 | } |
---|
1553 | } |
---|
1554 | for (j = 0; j < nl; j++) |
---|
1555 | { |
---|
1556 | #else |
---|
1557 | for (UInt j = 0; j < sei.m_vpsMaxLayers; j++) |
---|
1558 | { |
---|
1559 | if (sei.m_layerIdIncludedFlag[lsIdx][j]) |
---|
1560 | { |
---|
1561 | #endif |
---|
1562 | READ_FLAG( uiCode, "sei_layer_in_bsp_flag[lsIdx][i][j]" ); sei.m_seiLayerInBspFlag[lsIdx][i][j] = uiCode; |
---|
1563 | } |
---|
1564 | #if !HRD_BPB |
---|
1565 | } |
---|
1566 | #endif |
---|
1567 | #if HRD_BPB |
---|
1568 | chkPart+=sei.m_seiLayerInBspFlag[lsIdx][i][j]; |
---|
1569 | #endif |
---|
1570 | } |
---|
1571 | #if HRD_BPB |
---|
1572 | assert(chkPart<=1); |
---|
1573 | #endif |
---|
1574 | #if HRD_BPB |
---|
1575 | if(sei.m_seiNumBitstreamPartitionsMinus1[lsIdx]==0) |
---|
1576 | { |
---|
1577 | Int chkPartition1=0; Int chkPartition2=0; |
---|
1578 | for (UInt j = 0; j < sei.m_vpsMaxLayers; j++) |
---|
1579 | { |
---|
1580 | if( sei.m_layerIdIncludedFlag[lsIdx][j] ) |
---|
1581 | { |
---|
1582 | chkPartition1+=sei.m_seiLayerInBspFlag[lsIdx][0][j]; |
---|
1583 | chkPartition2++; |
---|
1584 | } |
---|
1585 | } |
---|
1586 | assert(chkPartition1!=chkPartition2); |
---|
1587 | } |
---|
1588 | #endif |
---|
1589 | |
---|
1590 | READ_UVLC( uiCode, "sei_num_bsp_sched_combinations_minus1[i]"); sei.m_seiNumBspSchedCombinationsMinus1[lsIdx] = uiCode; |
---|
1591 | for (i = 0; i <= sei.m_seiNumBspSchedCombinationsMinus1[lsIdx]; i++) |
---|
1592 | { |
---|
1593 | for (UInt j = 0; j <= sei.m_seiNumBitstreamPartitionsMinus1[lsIdx]; j++) |
---|
1594 | { |
---|
1595 | READ_UVLC( uiCode, "sei_bsp_comb_hrd_idx[lsIdx][i][j]"); sei.m_seiBspCombHrdIdx[lsIdx][i][j] = uiCode; |
---|
1596 | #if HRD_BPB |
---|
1597 | assert(uiCode <= sei.m_seiNumBspHrdParametersMinus1); |
---|
1598 | #endif |
---|
1599 | READ_UVLC( uiCode, "sei_bsp_comb_sched_idx[lsIdx][i][j]"); sei.m_seiBspCombScheddx[lsIdx][i][j] = uiCode; |
---|
1600 | #if HRD_BPB |
---|
1601 | assert(uiCode <= sei.hrd->getCpbCntMinus1( sps->getMaxTLayers()-1 )); |
---|
1602 | #endif |
---|
1603 | |
---|
1604 | } |
---|
1605 | } |
---|
1606 | } |
---|
1607 | } |
---|
1608 | #endif |
---|
1609 | |
---|
1610 | Void SEIReader::xParseHrdParameters(TComHRD *hrd, Bool commonInfPresentFlag, UInt maxNumSubLayersMinus1) |
---|
1611 | { |
---|
1612 | UInt uiCode; |
---|
1613 | if( commonInfPresentFlag ) |
---|
1614 | { |
---|
1615 | READ_FLAG( uiCode, "nal_hrd_parameters_present_flag" ); hrd->setNalHrdParametersPresentFlag( uiCode == 1 ? true : false ); |
---|
1616 | READ_FLAG( uiCode, "vcl_hrd_parameters_present_flag" ); hrd->setVclHrdParametersPresentFlag( uiCode == 1 ? true : false ); |
---|
1617 | if( hrd->getNalHrdParametersPresentFlag() || hrd->getVclHrdParametersPresentFlag() ) |
---|
1618 | { |
---|
1619 | READ_FLAG( uiCode, "sub_pic_cpb_params_present_flag" ); hrd->setSubPicCpbParamsPresentFlag( uiCode == 1 ? true : false ); |
---|
1620 | if( hrd->getSubPicCpbParamsPresentFlag() ) |
---|
1621 | { |
---|
1622 | READ_CODE( 8, uiCode, "tick_divisor_minus2" ); hrd->setTickDivisorMinus2( uiCode ); |
---|
1623 | READ_CODE( 5, uiCode, "du_cpb_removal_delay_length_minus1" ); hrd->setDuCpbRemovalDelayLengthMinus1( uiCode ); |
---|
1624 | READ_FLAG( uiCode, "sub_pic_cpb_params_in_pic_timing_sei_flag" ); hrd->setSubPicCpbParamsInPicTimingSEIFlag( uiCode == 1 ? true : false ); |
---|
1625 | READ_CODE( 5, uiCode, "dpb_output_delay_du_length_minus1" ); hrd->setDpbOutputDelayDuLengthMinus1( uiCode ); |
---|
1626 | } |
---|
1627 | READ_CODE( 4, uiCode, "bit_rate_scale" ); hrd->setBitRateScale( uiCode ); |
---|
1628 | READ_CODE( 4, uiCode, "cpb_size_scale" ); hrd->setCpbSizeScale( uiCode ); |
---|
1629 | if( hrd->getSubPicCpbParamsPresentFlag() ) |
---|
1630 | { |
---|
1631 | READ_CODE( 4, uiCode, "cpb_size_du_scale" ); hrd->setDuCpbSizeScale( uiCode ); |
---|
1632 | } |
---|
1633 | READ_CODE( 5, uiCode, "initial_cpb_removal_delay_length_minus1" ); hrd->setInitialCpbRemovalDelayLengthMinus1( uiCode ); |
---|
1634 | READ_CODE( 5, uiCode, "au_cpb_removal_delay_length_minus1" ); hrd->setCpbRemovalDelayLengthMinus1( uiCode ); |
---|
1635 | READ_CODE( 5, uiCode, "dpb_output_delay_length_minus1" ); hrd->setDpbOutputDelayLengthMinus1( uiCode ); |
---|
1636 | } |
---|
1637 | } |
---|
1638 | Int i, j, nalOrVcl; |
---|
1639 | for( i = 0; i <= maxNumSubLayersMinus1; i ++ ) |
---|
1640 | { |
---|
1641 | READ_FLAG( uiCode, "fixed_pic_rate_general_flag" ); hrd->setFixedPicRateFlag( i, uiCode == 1 ? true : false ); |
---|
1642 | if( !hrd->getFixedPicRateFlag( i ) ) |
---|
1643 | { |
---|
1644 | READ_FLAG( uiCode, "fixed_pic_rate_within_cvs_flag" ); hrd->setFixedPicRateWithinCvsFlag( i, uiCode == 1 ? true : false ); |
---|
1645 | } |
---|
1646 | else |
---|
1647 | { |
---|
1648 | hrd->setFixedPicRateWithinCvsFlag( i, true ); |
---|
1649 | } |
---|
1650 | hrd->setLowDelayHrdFlag( i, 0 ); // Infered to be 0 when not present |
---|
1651 | hrd->setCpbCntMinus1 ( i, 0 ); // Infered to be 0 when not present |
---|
1652 | if( hrd->getFixedPicRateWithinCvsFlag( i ) ) |
---|
1653 | { |
---|
1654 | READ_UVLC( uiCode, "elemental_duration_in_tc_minus1" ); hrd->setPicDurationInTcMinus1( i, uiCode ); |
---|
1655 | } |
---|
1656 | else |
---|
1657 | { |
---|
1658 | READ_FLAG( uiCode, "low_delay_hrd_flag" ); hrd->setLowDelayHrdFlag( i, uiCode == 1 ? true : false ); |
---|
1659 | } |
---|
1660 | if (!hrd->getLowDelayHrdFlag( i )) |
---|
1661 | { |
---|
1662 | READ_UVLC( uiCode, "cpb_cnt_minus1" ); hrd->setCpbCntMinus1( i, uiCode ); |
---|
1663 | } |
---|
1664 | for( nalOrVcl = 0; nalOrVcl < 2; nalOrVcl ++ ) |
---|
1665 | { |
---|
1666 | if( ( ( nalOrVcl == 0 ) && ( hrd->getNalHrdParametersPresentFlag() ) ) || |
---|
1667 | ( ( nalOrVcl == 1 ) && ( hrd->getVclHrdParametersPresentFlag() ) ) ) |
---|
1668 | { |
---|
1669 | for( j = 0; j <= ( hrd->getCpbCntMinus1( i ) ); j ++ ) |
---|
1670 | { |
---|
1671 | READ_UVLC( uiCode, "bit_rate_value_minus1" ); hrd->setBitRateValueMinus1( i, j, nalOrVcl, uiCode ); |
---|
1672 | READ_UVLC( uiCode, "cpb_size_value_minus1" ); hrd->setCpbSizeValueMinus1( i, j, nalOrVcl, uiCode ); |
---|
1673 | if( hrd->getSubPicCpbParamsPresentFlag() ) |
---|
1674 | { |
---|
1675 | READ_UVLC( uiCode, "cpb_size_du_value_minus1" ); hrd->setDuCpbSizeValueMinus1( i, j, nalOrVcl, uiCode ); |
---|
1676 | READ_UVLC( uiCode, "bit_rate_du_value_minus1" ); hrd->setDuBitRateValueMinus1( i, j, nalOrVcl, uiCode ); |
---|
1677 | } |
---|
1678 | READ_FLAG( uiCode, "cbr_flag" ); hrd->setCbrFlag( i, j, nalOrVcl, uiCode == 1 ? true : false ); |
---|
1679 | } |
---|
1680 | } |
---|
1681 | } |
---|
1682 | } |
---|
1683 | } |
---|
1684 | #endif |
---|
1685 | |
---|
1686 | #if Q0078_ADD_LAYER_SETS |
---|
1687 | |
---|
1688 | #if LAYERS_NOT_PRESENT_SEI |
---|
1689 | Void SEIReader::xParseSEIOutputLayerSetNesting(SEIOutputLayerSetNesting& sei, const NalUnitType nalUnitType, TComVPS *vps, TComSPS *sps) |
---|
1690 | #else |
---|
1691 | Void SEIReader::xParseSEIOutputLayerSetNesting(SEIOutputLayerSetNesting& sei, const NalUnitType nalUnitType, TComSPS *sps) |
---|
1692 | #endif |
---|
1693 | { |
---|
1694 | UInt uiCode; |
---|
1695 | SEIMessages seis; |
---|
1696 | |
---|
1697 | READ_FLAG(uiCode, "ols_flag"); sei.m_olsFlag = uiCode; |
---|
1698 | READ_UVLC(uiCode, "num_ols_indices_minus1"); sei.m_numOlsIndicesMinus1 = uiCode; |
---|
1699 | |
---|
1700 | for (Int i = 0; i <= sei.m_numOlsIndicesMinus1; i++) |
---|
1701 | { |
---|
1702 | READ_UVLC(uiCode, "ols_idx[i]"); sei.m_olsIdx[i] = uiCode; |
---|
1703 | } |
---|
1704 | |
---|
1705 | // byte alignment |
---|
1706 | while (m_pcBitstream->getNumBitsRead() % 8 != 0) |
---|
1707 | { |
---|
1708 | UInt code; |
---|
1709 | READ_FLAG(code, "ols_nesting_zero_bit"); |
---|
1710 | } |
---|
1711 | |
---|
1712 | sei.m_callerOwnsSEIs = false; |
---|
1713 | |
---|
1714 | // read nested SEI messages |
---|
1715 | do { |
---|
1716 | #if O0164_MULTI_LAYER_HRD |
---|
1717 | #if LAYERS_NOT_PRESENT_SEI |
---|
1718 | xReadSEImessage(sei.m_nestedSEIs, nalUnitType, vps, sps); |
---|
1719 | #else |
---|
1720 | xReadSEImessage(sei.m_nestedSEIs, nalUnitType, sps); |
---|
1721 | #endif |
---|
1722 | #else |
---|
1723 | #if LAYERS_NOT_PRESENT_SEI |
---|
1724 | xReadSEImessage(sei.m_nestedSEIs, nalUnitType, vps, sps); |
---|
1725 | #else |
---|
1726 | xReadSEImessage(sei.m_nestedSEIs, nalUnitType, sps); |
---|
1727 | #endif |
---|
1728 | #endif |
---|
1729 | } while (m_pcBitstream->getNumBitsLeft() > 8); |
---|
1730 | |
---|
1731 | } |
---|
1732 | |
---|
1733 | Void SEIReader::xParseSEIVPSRewriting(SEIVPSRewriting &sei) |
---|
1734 | { |
---|
1735 | } |
---|
1736 | |
---|
1737 | #endif |
---|
1738 | |
---|
1739 | #if Q0096_OVERLAY_SEI |
---|
1740 | Void SEIReader::xParseSEIOverlayInfo(SEIOverlayInfo& sei, UInt /*payloadSize*/){ |
---|
1741 | Int i, j; |
---|
1742 | UInt val; |
---|
1743 | READ_FLAG( val, "overlay_info_cancel_flag" ); sei.m_overlayInfoCancelFlag = val; |
---|
1744 | if ( !sei.m_overlayInfoCancelFlag ) |
---|
1745 | { |
---|
1746 | READ_UVLC( val, "overlay_content_aux_id_minus128" ); sei.m_overlayContentAuxIdMinus128 = val; |
---|
1747 | READ_UVLC( val, "overlay_label_aux_id_minus128" ); sei.m_overlayLabelAuxIdMinus128 = val; |
---|
1748 | READ_UVLC( val, "overlay_alpha_aux_id_minus128" ); sei.m_overlayAlphaAuxIdMinus128 = val; |
---|
1749 | READ_UVLC( val, "overlay_element_label_value_length_minus8" ); sei.m_overlayElementLabelValueLengthMinus8 = val; |
---|
1750 | READ_UVLC( val, "num_overlays_minus1" ); sei.m_numOverlaysMinus1 = val; |
---|
1751 | |
---|
1752 | assert( sei.m_numOverlaysMinus1 < MAX_OVERLAYS ); |
---|
1753 | sei.m_overlayIdx.resize( sei.m_numOverlaysMinus1+1 ); |
---|
1754 | sei.m_languageOverlayPresentFlag.resize( sei.m_numOverlaysMinus1+1 ); |
---|
1755 | sei.m_overlayContentLayerId.resize( sei.m_numOverlaysMinus1+1 ); |
---|
1756 | sei.m_overlayLabelPresentFlag.resize( sei.m_numOverlaysMinus1+1 ); |
---|
1757 | sei.m_overlayLabelLayerId.resize( sei.m_numOverlaysMinus1+1 ); |
---|
1758 | sei.m_overlayAlphaPresentFlag.resize( sei.m_numOverlaysMinus1+1 ); |
---|
1759 | sei.m_overlayAlphaLayerId.resize( sei.m_numOverlaysMinus1+1 ); |
---|
1760 | sei.m_numOverlayElementsMinus1.resize( sei.m_numOverlaysMinus1+1 ); |
---|
1761 | sei.m_overlayElementLabelMin.resize( sei.m_numOverlaysMinus1+1 ); |
---|
1762 | sei.m_overlayElementLabelMax.resize( sei.m_numOverlaysMinus1+1 ); |
---|
1763 | for ( i=0 ; i<=sei.m_numOverlaysMinus1 ; i++ ) |
---|
1764 | { |
---|
1765 | READ_UVLC( val, "overlay_idx" ); sei.m_overlayIdx[i] = val; |
---|
1766 | READ_FLAG( val, "language_overlay_present_flag" ); sei.m_languageOverlayPresentFlag[i] = val; |
---|
1767 | READ_CODE( 6, val, "overlay_content_layer_id"); sei.m_overlayContentLayerId[i] = val; |
---|
1768 | READ_FLAG( val, "overlay_label_present_flag" ); sei.m_overlayLabelPresentFlag[i] = val; |
---|
1769 | if ( sei.m_overlayLabelPresentFlag[i] ) |
---|
1770 | { |
---|
1771 | READ_CODE( 6, val, "overlay_label_layer_id"); sei.m_overlayLabelLayerId[i] = val; |
---|
1772 | } |
---|
1773 | READ_FLAG( val, "overlay_alpha_present_flag" ); sei.m_overlayAlphaPresentFlag[i] = val; |
---|
1774 | if ( sei.m_overlayAlphaPresentFlag[i] ) |
---|
1775 | { |
---|
1776 | READ_CODE( 6, val, "overlay_alpha_layer_id"); sei.m_overlayAlphaLayerId[i] = val; |
---|
1777 | } |
---|
1778 | if ( sei.m_overlayLabelPresentFlag[i] ) |
---|
1779 | { |
---|
1780 | READ_UVLC( val, "num_overlay_elements_minus1"); sei.m_numOverlayElementsMinus1[i] = val; |
---|
1781 | assert( sei.m_numOverlayElementsMinus1[i] < MAX_OVERLAY_ELEMENTS ); |
---|
1782 | sei.m_overlayElementLabelMin[i].resize( sei.m_numOverlayElementsMinus1[i]+1 ); |
---|
1783 | sei.m_overlayElementLabelMax[i].resize( sei.m_numOverlayElementsMinus1[i]+1 ); |
---|
1784 | for ( j=0 ; j<=sei.m_numOverlayElementsMinus1[i] ; j++ ) |
---|
1785 | { |
---|
1786 | READ_CODE(sei.m_overlayElementLabelValueLengthMinus8 + 8, val, "overlay_element_label_min"); sei.m_overlayElementLabelMin[i][j] = val; |
---|
1787 | READ_CODE(sei.m_overlayElementLabelValueLengthMinus8 + 8, val, "overlay_element_label_max"); sei.m_overlayElementLabelMax[i][j] = val; |
---|
1788 | } |
---|
1789 | } |
---|
1790 | else |
---|
1791 | { |
---|
1792 | sei.m_numOverlayElementsMinus1[i] = 0; |
---|
1793 | } |
---|
1794 | } |
---|
1795 | |
---|
1796 | // byte alignment |
---|
1797 | while ( m_pcBitstream->getNumBitsRead() % 8 != 0 ) |
---|
1798 | { |
---|
1799 | READ_FLAG( val, "overlay_zero_bit" ); |
---|
1800 | assert( val==0 ); |
---|
1801 | } |
---|
1802 | |
---|
1803 | UChar* sval = new UChar[MAX_OVERLAY_STRING_BYTES]; |
---|
1804 | UInt slen; |
---|
1805 | sei.m_overlayLanguage.resize( sei.m_numOverlaysMinus1+1, NULL ); |
---|
1806 | sei.m_overlayLanguageLength.resize( sei.m_numOverlaysMinus1+1 ); |
---|
1807 | sei.m_overlayName.resize( sei.m_numOverlaysMinus1+1, NULL ); |
---|
1808 | sei.m_overlayNameLength.resize( sei.m_numOverlaysMinus1+1 ); |
---|
1809 | sei.m_overlayElementName.resize( sei.m_numOverlaysMinus1+1 ); |
---|
1810 | sei.m_overlayElementNameLength.resize( sei.m_numOverlaysMinus1+1 ); |
---|
1811 | for ( i=0 ; i<=sei.m_numOverlaysMinus1 ; i++ ) |
---|
1812 | { |
---|
1813 | if ( sei.m_languageOverlayPresentFlag[i] ) |
---|
1814 | { |
---|
1815 | READ_STRING( MAX_OVERLAY_STRING_BYTES, sval, slen, "overlay_language" ); |
---|
1816 | sei.m_overlayLanguage[i] = new UChar[slen]; |
---|
1817 | memcpy(sei.m_overlayLanguage[i], sval, slen); |
---|
1818 | sei.m_overlayLanguageLength[i] = slen; |
---|
1819 | } |
---|
1820 | READ_STRING( MAX_OVERLAY_STRING_BYTES, sval, slen, "overlay_name" ); |
---|
1821 | sei.m_overlayName[i] = new UChar[slen]; |
---|
1822 | memcpy(sei.m_overlayName[i], sval, slen); |
---|
1823 | sei.m_overlayNameLength[i] = slen; |
---|
1824 | if ( sei.m_overlayLabelPresentFlag[i] ) |
---|
1825 | { |
---|
1826 | sei.m_overlayElementName[i].resize( sei.m_numOverlayElementsMinus1[i]+1, NULL ); |
---|
1827 | sei.m_overlayElementNameLength[i].resize( sei.m_numOverlayElementsMinus1[i]+1 ); |
---|
1828 | for ( j=0 ; j<=sei.m_numOverlayElementsMinus1[i] ; j++) |
---|
1829 | { |
---|
1830 | READ_STRING( MAX_OVERLAY_STRING_BYTES, sval, slen, "overlay_element_name" ); |
---|
1831 | sei.m_overlayElementName[i][j] = new UChar[slen]; |
---|
1832 | memcpy(sei.m_overlayElementName[i][j], sval, slen); |
---|
1833 | sei.m_overlayElementNameLength[i][j] = slen; |
---|
1834 | } |
---|
1835 | } |
---|
1836 | } |
---|
1837 | READ_FLAG( val, "overlay_info_persistence_flag" ); sei.m_overlayInfoPersistenceFlag = val; |
---|
1838 | } |
---|
1839 | xParseByteAlign(); |
---|
1840 | } |
---|
1841 | #endif |
---|
1842 | |
---|
1843 | #endif //SVC_EXTENSION |
---|
1844 | |
---|
1845 | //! \} |
---|