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 | case SEI::SOP_DESCRIPTION: |
---|
96 | fprintf( g_hTrace, "=========== SOP Description SEI message ===========\n"); |
---|
97 | break; |
---|
98 | case SEI::SCALABLE_NESTING: |
---|
99 | fprintf( g_hTrace, "=========== Scalable Nesting SEI message ===========\n"); |
---|
100 | break; |
---|
101 | #if SVC_EXTENSION |
---|
102 | #if LAYERS_NOT_PRESENT_SEI |
---|
103 | case SEI::LAYERS_NOT_PRESENT: |
---|
104 | fprintf( g_hTrace, "=========== Layers Present SEI message ===========\n"); |
---|
105 | break; |
---|
106 | #endif |
---|
107 | #if N0383_IL_CONSTRAINED_TILE_SETS_SEI |
---|
108 | case SEI::INTER_LAYER_CONSTRAINED_TILE_SETS: |
---|
109 | fprintf( g_hTrace, "=========== Inter Layer Constrained Tile Sets SEI message ===========\n"); |
---|
110 | break; |
---|
111 | #endif |
---|
112 | #if SUB_BITSTREAM_PROPERTY_SEI |
---|
113 | case SEI::SUB_BITSTREAM_PROPERTY: |
---|
114 | fprintf( g_hTrace, "=========== Sub-bitstream property SEI message ===========\n"); |
---|
115 | break; |
---|
116 | #endif |
---|
117 | #if O0164_MULTI_LAYER_HRD |
---|
118 | case SEI::BSP_NESTING: |
---|
119 | fprintf( g_hTrace, "=========== Bitstream parition nesting SEI message ===========\n"); |
---|
120 | break; |
---|
121 | case SEI::BSP_INITIAL_ARRIVAL_TIME: |
---|
122 | fprintf( g_hTrace, "=========== Bitstream parition initial arrival time SEI message ===========\n"); |
---|
123 | break; |
---|
124 | case SEI::BSP_HRD: |
---|
125 | fprintf( g_hTrace, "=========== Bitstream parition HRD parameters SEI message ===========\n"); |
---|
126 | break; |
---|
127 | #endif |
---|
128 | #endif //SVC_EXTENSION |
---|
129 | default: |
---|
130 | fprintf( g_hTrace, "=========== Unknown SEI message ===========\n"); |
---|
131 | break; |
---|
132 | } |
---|
133 | } |
---|
134 | #endif |
---|
135 | |
---|
136 | /** |
---|
137 | * unmarshal a single SEI message from bitstream bs |
---|
138 | */ |
---|
139 | #if LAYERS_NOT_PRESENT_SEI |
---|
140 | void SEIReader::parseSEImessage(TComInputBitstream* bs, SEIMessages& seis, const NalUnitType nalUnitType, TComVPS *vps, TComSPS *sps) |
---|
141 | #else |
---|
142 | void SEIReader::parseSEImessage(TComInputBitstream* bs, SEIMessages& seis, const NalUnitType nalUnitType, TComSPS *sps) |
---|
143 | #endif |
---|
144 | { |
---|
145 | setBitstream(bs); |
---|
146 | |
---|
147 | assert(!m_pcBitstream->getNumBitsUntilByteAligned()); |
---|
148 | do |
---|
149 | { |
---|
150 | #if LAYERS_NOT_PRESENT_SEI |
---|
151 | xReadSEImessage(seis, nalUnitType, vps, sps); |
---|
152 | #else |
---|
153 | xReadSEImessage(seis, nalUnitType, sps); |
---|
154 | #endif |
---|
155 | /* SEI messages are an integer number of bytes, something has failed |
---|
156 | * in the parsing if bitstream not byte-aligned */ |
---|
157 | assert(!m_pcBitstream->getNumBitsUntilByteAligned()); |
---|
158 | } while (m_pcBitstream->getNumBitsLeft() > 8); |
---|
159 | |
---|
160 | UInt rbspTrailingBits; |
---|
161 | READ_CODE(8, rbspTrailingBits, "rbsp_trailing_bits"); |
---|
162 | assert(rbspTrailingBits == 0x80); |
---|
163 | } |
---|
164 | |
---|
165 | #if O0164_MULTI_LAYER_HRD |
---|
166 | #if LAYERS_NOT_PRESENT_SEI |
---|
167 | Void SEIReader::xReadSEImessage(SEIMessages& seis, const NalUnitType nalUnitType, TComVPS *vps, TComSPS *sps, const SEIScalableNesting *nestingSei, const SEIBspNesting *bspNestingSei) |
---|
168 | #else |
---|
169 | Void SEIReader::xReadSEImessage(SEIMessages& seis, const NalUnitType nalUnitType, TComSPS *sps, const SEIScalableNesting *nestingSei) |
---|
170 | #endif |
---|
171 | #else |
---|
172 | #if LAYERS_NOT_PRESENT_SEI |
---|
173 | Void SEIReader::xReadSEImessage(SEIMessages& seis, const NalUnitType nalUnitType, TComVPS *vps, TComSPS *sps) |
---|
174 | #else |
---|
175 | Void SEIReader::xReadSEImessage(SEIMessages& seis, const NalUnitType nalUnitType, TComSPS *sps) |
---|
176 | #endif |
---|
177 | #endif |
---|
178 | { |
---|
179 | #if ENC_DEC_TRACE |
---|
180 | xTraceSEIHeader(); |
---|
181 | #endif |
---|
182 | Int payloadType = 0; |
---|
183 | UInt val = 0; |
---|
184 | |
---|
185 | do |
---|
186 | { |
---|
187 | READ_CODE (8, val, "payload_type"); |
---|
188 | payloadType += val; |
---|
189 | } while (val==0xFF); |
---|
190 | |
---|
191 | UInt payloadSize = 0; |
---|
192 | do |
---|
193 | { |
---|
194 | READ_CODE (8, val, "payload_size"); |
---|
195 | payloadSize += val; |
---|
196 | } while (val==0xFF); |
---|
197 | |
---|
198 | #if ENC_DEC_TRACE |
---|
199 | xTraceSEIMessageType((SEI::PayloadType)payloadType); |
---|
200 | #endif |
---|
201 | |
---|
202 | /* extract the payload for this single SEI message. |
---|
203 | * This allows greater safety in erroneous parsing of an SEI message |
---|
204 | * from affecting subsequent messages. |
---|
205 | * After parsing the payload, bs needs to be restored as the primary |
---|
206 | * bitstream. |
---|
207 | */ |
---|
208 | TComInputBitstream *bs = getBitstream(); |
---|
209 | setBitstream(bs->extractSubstream(payloadSize * 8)); |
---|
210 | |
---|
211 | SEI *sei = NULL; |
---|
212 | |
---|
213 | if(nalUnitType == NAL_UNIT_PREFIX_SEI) |
---|
214 | { |
---|
215 | switch (payloadType) |
---|
216 | { |
---|
217 | case SEI::USER_DATA_UNREGISTERED: |
---|
218 | sei = new SEIuserDataUnregistered; |
---|
219 | xParseSEIuserDataUnregistered((SEIuserDataUnregistered&) *sei, payloadSize); |
---|
220 | break; |
---|
221 | case SEI::ACTIVE_PARAMETER_SETS: |
---|
222 | sei = new SEIActiveParameterSets; |
---|
223 | xParseSEIActiveParameterSets((SEIActiveParameterSets&) *sei, payloadSize); |
---|
224 | break; |
---|
225 | case SEI::DECODING_UNIT_INFO: |
---|
226 | if (!sps) |
---|
227 | { |
---|
228 | printf ("Warning: Found Decoding unit SEI message, but no active SPS is available. Ignoring."); |
---|
229 | } |
---|
230 | else |
---|
231 | { |
---|
232 | sei = new SEIDecodingUnitInfo; |
---|
233 | xParseSEIDecodingUnitInfo((SEIDecodingUnitInfo&) *sei, payloadSize, sps); |
---|
234 | } |
---|
235 | break; |
---|
236 | case SEI::BUFFERING_PERIOD: |
---|
237 | if (!sps) |
---|
238 | { |
---|
239 | printf ("Warning: Found Buffering period SEI message, but no active SPS is available. Ignoring."); |
---|
240 | } |
---|
241 | else |
---|
242 | { |
---|
243 | sei = new SEIBufferingPeriod; |
---|
244 | xParseSEIBufferingPeriod((SEIBufferingPeriod&) *sei, payloadSize, sps); |
---|
245 | } |
---|
246 | break; |
---|
247 | case SEI::PICTURE_TIMING: |
---|
248 | if (!sps) |
---|
249 | { |
---|
250 | printf ("Warning: Found Picture timing SEI message, but no active SPS is available. Ignoring."); |
---|
251 | } |
---|
252 | else |
---|
253 | { |
---|
254 | sei = new SEIPictureTiming; |
---|
255 | xParseSEIPictureTiming((SEIPictureTiming&)*sei, payloadSize, sps); |
---|
256 | } |
---|
257 | break; |
---|
258 | case SEI::RECOVERY_POINT: |
---|
259 | sei = new SEIRecoveryPoint; |
---|
260 | xParseSEIRecoveryPoint((SEIRecoveryPoint&) *sei, payloadSize); |
---|
261 | break; |
---|
262 | case SEI::FRAME_PACKING: |
---|
263 | sei = new SEIFramePacking; |
---|
264 | xParseSEIFramePacking((SEIFramePacking&) *sei, payloadSize); |
---|
265 | break; |
---|
266 | case SEI::DISPLAY_ORIENTATION: |
---|
267 | sei = new SEIDisplayOrientation; |
---|
268 | xParseSEIDisplayOrientation((SEIDisplayOrientation&) *sei, payloadSize); |
---|
269 | break; |
---|
270 | case SEI::TEMPORAL_LEVEL0_INDEX: |
---|
271 | sei = new SEITemporalLevel0Index; |
---|
272 | xParseSEITemporalLevel0Index((SEITemporalLevel0Index&) *sei, payloadSize); |
---|
273 | break; |
---|
274 | case SEI::REGION_REFRESH_INFO: |
---|
275 | sei = new SEIGradualDecodingRefreshInfo; |
---|
276 | xParseSEIGradualDecodingRefreshInfo((SEIGradualDecodingRefreshInfo&) *sei, payloadSize); |
---|
277 | break; |
---|
278 | case SEI::TONE_MAPPING_INFO: |
---|
279 | sei = new SEIToneMappingInfo; |
---|
280 | xParseSEIToneMappingInfo((SEIToneMappingInfo&) *sei, payloadSize); |
---|
281 | break; |
---|
282 | case SEI::SOP_DESCRIPTION: |
---|
283 | sei = new SEISOPDescription; |
---|
284 | xParseSEISOPDescription((SEISOPDescription&) *sei, payloadSize); |
---|
285 | break; |
---|
286 | case SEI::SCALABLE_NESTING: |
---|
287 | sei = new SEIScalableNesting; |
---|
288 | #if LAYERS_NOT_PRESENT_SEI |
---|
289 | xParseSEIScalableNesting((SEIScalableNesting&) *sei, nalUnitType, payloadSize, vps, sps); |
---|
290 | #else |
---|
291 | xParseSEIScalableNesting((SEIScalableNesting&) *sei, nalUnitType, payloadSize, sps); |
---|
292 | #endif |
---|
293 | break; |
---|
294 | #if SVC_EXTENSION |
---|
295 | #if LAYERS_NOT_PRESENT_SEI |
---|
296 | case SEI::LAYERS_NOT_PRESENT: |
---|
297 | if (!vps) |
---|
298 | { |
---|
299 | printf ("Warning: Found Layers not present SEI message, but no active VPS is available. Ignoring."); |
---|
300 | } |
---|
301 | else |
---|
302 | { |
---|
303 | sei = new SEILayersNotPresent; |
---|
304 | xParseSEILayersNotPresent((SEILayersNotPresent&) *sei, payloadSize, vps); |
---|
305 | } |
---|
306 | break; |
---|
307 | #endif |
---|
308 | #if N0383_IL_CONSTRAINED_TILE_SETS_SEI |
---|
309 | case SEI::INTER_LAYER_CONSTRAINED_TILE_SETS: |
---|
310 | sei = new SEIInterLayerConstrainedTileSets; |
---|
311 | xParseSEIInterLayerConstrainedTileSets((SEIInterLayerConstrainedTileSets&) *sei, payloadSize); |
---|
312 | break; |
---|
313 | #endif |
---|
314 | #if SUB_BITSTREAM_PROPERTY_SEI |
---|
315 | case SEI::SUB_BITSTREAM_PROPERTY: |
---|
316 | sei = new SEISubBitstreamProperty; |
---|
317 | xParseSEISubBitstreamProperty((SEISubBitstreamProperty&) *sei); |
---|
318 | break; |
---|
319 | #endif |
---|
320 | #if O0164_MULTI_LAYER_HRD |
---|
321 | case SEI::BSP_NESTING: |
---|
322 | sei = new SEIBspNesting; |
---|
323 | #if LAYERS_NOT_PRESENT_SEI |
---|
324 | xParseSEIBspNesting((SEIBspNesting&) *sei, nalUnitType, vps, sps, *nestingSei); |
---|
325 | #else |
---|
326 | xParseSEIBspNesting((SEIBspNesting&) *sei, nalUnitType, sps, *nestingSei); |
---|
327 | #endif |
---|
328 | break; |
---|
329 | case SEI::BSP_INITIAL_ARRIVAL_TIME: |
---|
330 | sei = new SEIBspInitialArrivalTime; |
---|
331 | xParseSEIBspInitialArrivalTime((SEIBspInitialArrivalTime&) *sei, vps, sps, *nestingSei, *bspNestingSei); |
---|
332 | break; |
---|
333 | case SEI::BSP_HRD: |
---|
334 | sei = new SEIBspHrd; |
---|
335 | xParseSEIBspHrd((SEIBspHrd&) *sei, sps, *nestingSei); |
---|
336 | break; |
---|
337 | #endif |
---|
338 | #endif //SVC_EXTENSION |
---|
339 | break; |
---|
340 | default: |
---|
341 | for (UInt i = 0; i < payloadSize; i++) |
---|
342 | { |
---|
343 | UInt seiByte; |
---|
344 | READ_CODE (8, seiByte, "unknown prefix SEI payload byte"); |
---|
345 | } |
---|
346 | printf ("Unknown prefix SEI message (payloadType = %d) was found!\n", payloadType); |
---|
347 | } |
---|
348 | } |
---|
349 | else |
---|
350 | { |
---|
351 | switch (payloadType) |
---|
352 | { |
---|
353 | case SEI::USER_DATA_UNREGISTERED: |
---|
354 | sei = new SEIuserDataUnregistered; |
---|
355 | xParseSEIuserDataUnregistered((SEIuserDataUnregistered&) *sei, payloadSize); |
---|
356 | break; |
---|
357 | case SEI::DECODED_PICTURE_HASH: |
---|
358 | sei = new SEIDecodedPictureHash; |
---|
359 | xParseSEIDecodedPictureHash((SEIDecodedPictureHash&) *sei, payloadSize); |
---|
360 | break; |
---|
361 | default: |
---|
362 | for (UInt i = 0; i < payloadSize; i++) |
---|
363 | { |
---|
364 | UInt seiByte; |
---|
365 | READ_CODE (8, seiByte, "unknown suffix SEI payload byte"); |
---|
366 | } |
---|
367 | printf ("Unknown suffix SEI message (payloadType = %d) was found!\n", payloadType); |
---|
368 | } |
---|
369 | } |
---|
370 | if (sei != NULL) |
---|
371 | { |
---|
372 | seis.push_back(sei); |
---|
373 | } |
---|
374 | |
---|
375 | /* By definition the underlying bitstream terminates in a byte-aligned manner. |
---|
376 | * 1. Extract all bar the last MIN(bitsremaining,nine) bits as reserved_payload_extension_data |
---|
377 | * 2. Examine the final 8 bits to determine the payload_bit_equal_to_one marker |
---|
378 | * 3. Extract the remainingreserved_payload_extension_data bits. |
---|
379 | * |
---|
380 | * If there are fewer than 9 bits available, extract them. |
---|
381 | */ |
---|
382 | Int payloadBitsRemaining = getBitstream()->getNumBitsLeft(); |
---|
383 | if (payloadBitsRemaining) /* more_data_in_payload() */ |
---|
384 | { |
---|
385 | for (; payloadBitsRemaining > 9; payloadBitsRemaining--) |
---|
386 | { |
---|
387 | UInt reservedPayloadExtensionData; |
---|
388 | READ_CODE (1, reservedPayloadExtensionData, "reserved_payload_extension_data"); |
---|
389 | } |
---|
390 | |
---|
391 | /* 2 */ |
---|
392 | Int finalBits = getBitstream()->peekBits(payloadBitsRemaining); |
---|
393 | Int finalPayloadBits = 0; |
---|
394 | for (Int mask = 0xff; finalBits & (mask >> finalPayloadBits); finalPayloadBits++) |
---|
395 | { |
---|
396 | continue; |
---|
397 | } |
---|
398 | |
---|
399 | /* 3 */ |
---|
400 | for (; payloadBitsRemaining > 9 - finalPayloadBits; payloadBitsRemaining--) |
---|
401 | { |
---|
402 | UInt reservedPayloadExtensionData; |
---|
403 | READ_FLAG (reservedPayloadExtensionData, "reserved_payload_extension_data"); |
---|
404 | } |
---|
405 | |
---|
406 | UInt dummy; |
---|
407 | READ_FLAG (dummy, "payload_bit_equal_to_one"); payloadBitsRemaining--; |
---|
408 | while (payloadBitsRemaining) |
---|
409 | { |
---|
410 | READ_FLAG (dummy, "payload_bit_equal_to_zero"); payloadBitsRemaining--; |
---|
411 | } |
---|
412 | } |
---|
413 | |
---|
414 | /* restore primary bitstream for sei_message */ |
---|
415 | getBitstream()->deleteFifo(); |
---|
416 | delete getBitstream(); |
---|
417 | setBitstream(bs); |
---|
418 | } |
---|
419 | |
---|
420 | #if P0138_USE_ALT_CPB_PARAMS_FLAG |
---|
421 | /** |
---|
422 | * Check if SEI message contains payload extension |
---|
423 | */ |
---|
424 | Bool SEIReader::xPayloadExtensionPresent() |
---|
425 | { |
---|
426 | Int payloadBitsRemaining = getBitstream()->getNumBitsLeft(); |
---|
427 | Bool payloadExtensionPresent = false; |
---|
428 | |
---|
429 | if (payloadBitsRemaining > 8) |
---|
430 | { |
---|
431 | payloadExtensionPresent = true; |
---|
432 | } |
---|
433 | else |
---|
434 | { |
---|
435 | Int finalBits = getBitstream()->peekBits(payloadBitsRemaining); |
---|
436 | while (payloadBitsRemaining && (finalBits & 1) == 0) |
---|
437 | { |
---|
438 | payloadBitsRemaining--; |
---|
439 | finalBits >>= 1; |
---|
440 | } |
---|
441 | payloadBitsRemaining--; |
---|
442 | if (payloadBitsRemaining > 0) |
---|
443 | { |
---|
444 | payloadExtensionPresent = true; |
---|
445 | } |
---|
446 | } |
---|
447 | |
---|
448 | return payloadExtensionPresent; |
---|
449 | } |
---|
450 | #endif |
---|
451 | |
---|
452 | /** |
---|
453 | * parse bitstream bs and unpack a user_data_unregistered SEI message |
---|
454 | * of payloasSize bytes into sei. |
---|
455 | */ |
---|
456 | Void SEIReader::xParseSEIuserDataUnregistered(SEIuserDataUnregistered &sei, UInt payloadSize) |
---|
457 | { |
---|
458 | assert(payloadSize >= 16); |
---|
459 | UInt val; |
---|
460 | |
---|
461 | for (UInt i = 0; i < 16; i++) |
---|
462 | { |
---|
463 | READ_CODE (8, val, "uuid_iso_iec_11578"); |
---|
464 | sei.uuid_iso_iec_11578[i] = val; |
---|
465 | } |
---|
466 | |
---|
467 | sei.userDataLength = payloadSize - 16; |
---|
468 | if (!sei.userDataLength) |
---|
469 | { |
---|
470 | sei.userData = 0; |
---|
471 | return; |
---|
472 | } |
---|
473 | |
---|
474 | sei.userData = new UChar[sei.userDataLength]; |
---|
475 | for (UInt i = 0; i < sei.userDataLength; i++) |
---|
476 | { |
---|
477 | READ_CODE (8, val, "user_data" ); |
---|
478 | sei.userData[i] = val; |
---|
479 | } |
---|
480 | } |
---|
481 | |
---|
482 | /** |
---|
483 | * parse bitstream bs and unpack a decoded picture hash SEI message |
---|
484 | * of payloadSize bytes into sei. |
---|
485 | */ |
---|
486 | Void SEIReader::xParseSEIDecodedPictureHash(SEIDecodedPictureHash& sei, UInt /*payloadSize*/) |
---|
487 | { |
---|
488 | UInt val; |
---|
489 | READ_CODE (8, val, "hash_type"); |
---|
490 | sei.method = static_cast<SEIDecodedPictureHash::Method>(val); |
---|
491 | for(Int yuvIdx = 0; yuvIdx < 3; yuvIdx++) |
---|
492 | { |
---|
493 | if(SEIDecodedPictureHash::MD5 == sei.method) |
---|
494 | { |
---|
495 | for (UInt i = 0; i < 16; i++) |
---|
496 | { |
---|
497 | READ_CODE(8, val, "picture_md5"); |
---|
498 | sei.digest[yuvIdx][i] = val; |
---|
499 | } |
---|
500 | } |
---|
501 | else if(SEIDecodedPictureHash::CRC == sei.method) |
---|
502 | { |
---|
503 | READ_CODE(16, val, "picture_crc"); |
---|
504 | sei.digest[yuvIdx][0] = val >> 8 & 0xFF; |
---|
505 | sei.digest[yuvIdx][1] = val & 0xFF; |
---|
506 | } |
---|
507 | else if(SEIDecodedPictureHash::CHECKSUM == sei.method) |
---|
508 | { |
---|
509 | READ_CODE(32, val, "picture_checksum"); |
---|
510 | sei.digest[yuvIdx][0] = (val>>24) & 0xff; |
---|
511 | sei.digest[yuvIdx][1] = (val>>16) & 0xff; |
---|
512 | sei.digest[yuvIdx][2] = (val>>8) & 0xff; |
---|
513 | sei.digest[yuvIdx][3] = val & 0xff; |
---|
514 | } |
---|
515 | } |
---|
516 | } |
---|
517 | Void SEIReader::xParseSEIActiveParameterSets(SEIActiveParameterSets& sei, UInt /*payloadSize*/) |
---|
518 | { |
---|
519 | UInt val; |
---|
520 | READ_CODE(4, val, "active_vps_id"); sei.activeVPSId = val; |
---|
521 | READ_FLAG( val, "full_random_access_flag"); sei.m_fullRandomAccessFlag = val ? true : false; |
---|
522 | READ_FLAG( val, "no_param_set_update_flag"); sei.m_noParamSetUpdateFlag = val ? true : false; |
---|
523 | READ_UVLC( val, "num_sps_ids_minus1"); sei.numSpsIdsMinus1 = val; |
---|
524 | |
---|
525 | sei.activeSeqParamSetId.resize(sei.numSpsIdsMinus1 + 1); |
---|
526 | for (Int i=0; i < (sei.numSpsIdsMinus1 + 1); i++) |
---|
527 | { |
---|
528 | READ_UVLC(val, "active_seq_param_set_id"); sei.activeSeqParamSetId[i] = val; |
---|
529 | } |
---|
530 | |
---|
531 | UInt uibits = m_pcBitstream->getNumBitsUntilByteAligned(); |
---|
532 | |
---|
533 | while(uibits--) |
---|
534 | { |
---|
535 | READ_FLAG(val, "alignment_bit"); |
---|
536 | } |
---|
537 | } |
---|
538 | |
---|
539 | Void SEIReader::xParseSEIDecodingUnitInfo(SEIDecodingUnitInfo& sei, UInt /*payloadSize*/, TComSPS *sps) |
---|
540 | { |
---|
541 | UInt val; |
---|
542 | READ_UVLC(val, "decoding_unit_idx"); |
---|
543 | sei.m_decodingUnitIdx = val; |
---|
544 | |
---|
545 | TComVUI *vui = sps->getVuiParameters(); |
---|
546 | if(vui->getHrdParameters()->getSubPicCpbParamsInPicTimingSEIFlag()) |
---|
547 | { |
---|
548 | READ_CODE( ( vui->getHrdParameters()->getDuCpbRemovalDelayLengthMinus1() + 1 ), val, "du_spt_cpb_removal_delay"); |
---|
549 | sei.m_duSptCpbRemovalDelay = val; |
---|
550 | } |
---|
551 | else |
---|
552 | { |
---|
553 | sei.m_duSptCpbRemovalDelay = 0; |
---|
554 | } |
---|
555 | READ_FLAG( val, "dpb_output_du_delay_present_flag"); sei.m_dpbOutputDuDelayPresentFlag = val ? true : false; |
---|
556 | if(sei.m_dpbOutputDuDelayPresentFlag) |
---|
557 | { |
---|
558 | READ_CODE(vui->getHrdParameters()->getDpbOutputDelayDuLengthMinus1() + 1, val, "pic_spt_dpb_output_du_delay"); |
---|
559 | sei.m_picSptDpbOutputDuDelay = val; |
---|
560 | } |
---|
561 | xParseByteAlign(); |
---|
562 | } |
---|
563 | |
---|
564 | Void SEIReader::xParseSEIBufferingPeriod(SEIBufferingPeriod& sei, UInt /*payloadSize*/, TComSPS *sps) |
---|
565 | { |
---|
566 | Int i, nalOrVcl; |
---|
567 | UInt code; |
---|
568 | |
---|
569 | TComVUI *pVUI = sps->getVuiParameters(); |
---|
570 | TComHRD *pHRD = pVUI->getHrdParameters(); |
---|
571 | |
---|
572 | READ_UVLC( code, "bp_seq_parameter_set_id" ); sei.m_bpSeqParameterSetId = code; |
---|
573 | if( !pHRD->getSubPicCpbParamsPresentFlag() ) |
---|
574 | { |
---|
575 | READ_FLAG( code, "irap_cpb_params_present_flag" ); sei.m_rapCpbParamsPresentFlag = code; |
---|
576 | } |
---|
577 | if( sei.m_rapCpbParamsPresentFlag ) |
---|
578 | { |
---|
579 | READ_CODE( pHRD->getCpbRemovalDelayLengthMinus1() + 1, code, "cpb_delay_offset" ); sei.m_cpbDelayOffset = code; |
---|
580 | READ_CODE( pHRD->getDpbOutputDelayLengthMinus1() + 1, code, "dpb_delay_offset" ); sei.m_dpbDelayOffset = code; |
---|
581 | } |
---|
582 | //read splicing flag and cpb_removal_delay_delta |
---|
583 | READ_FLAG( code, "concatenation_flag"); |
---|
584 | sei.m_concatenationFlag = code; |
---|
585 | READ_CODE( ( pHRD->getCpbRemovalDelayLengthMinus1() + 1 ), code, "au_cpb_removal_delay_delta_minus1" ); |
---|
586 | sei.m_auCpbRemovalDelayDelta = code + 1; |
---|
587 | for( nalOrVcl = 0; nalOrVcl < 2; nalOrVcl ++ ) |
---|
588 | { |
---|
589 | if( ( ( nalOrVcl == 0 ) && ( pHRD->getNalHrdParametersPresentFlag() ) ) || |
---|
590 | ( ( nalOrVcl == 1 ) && ( pHRD->getVclHrdParametersPresentFlag() ) ) ) |
---|
591 | { |
---|
592 | for( i = 0; i < ( pHRD->getCpbCntMinus1( 0 ) + 1 ); i ++ ) |
---|
593 | { |
---|
594 | READ_CODE( ( pHRD->getInitialCpbRemovalDelayLengthMinus1() + 1 ) , code, "initial_cpb_removal_delay" ); |
---|
595 | sei.m_initialCpbRemovalDelay[i][nalOrVcl] = code; |
---|
596 | READ_CODE( ( pHRD->getInitialCpbRemovalDelayLengthMinus1() + 1 ) , code, "initial_cpb_removal_delay_offset" ); |
---|
597 | sei.m_initialCpbRemovalDelayOffset[i][nalOrVcl] = code; |
---|
598 | if( pHRD->getSubPicCpbParamsPresentFlag() || sei.m_rapCpbParamsPresentFlag ) |
---|
599 | { |
---|
600 | READ_CODE( ( pHRD->getInitialCpbRemovalDelayLengthMinus1() + 1 ) , code, "initial_alt_cpb_removal_delay" ); |
---|
601 | sei.m_initialAltCpbRemovalDelay[i][nalOrVcl] = code; |
---|
602 | READ_CODE( ( pHRD->getInitialCpbRemovalDelayLengthMinus1() + 1 ) , code, "initial_alt_cpb_removal_delay_offset" ); |
---|
603 | sei.m_initialAltCpbRemovalDelayOffset[i][nalOrVcl] = code; |
---|
604 | } |
---|
605 | } |
---|
606 | } |
---|
607 | } |
---|
608 | |
---|
609 | #if P0138_USE_ALT_CPB_PARAMS_FLAG |
---|
610 | sei.m_useAltCpbParamsFlag = false; |
---|
611 | sei.m_useAltCpbParamsFlagPresent = false; |
---|
612 | if (xPayloadExtensionPresent()) |
---|
613 | { |
---|
614 | READ_FLAG (code, "use_alt_cpb_params_flag"); |
---|
615 | sei.m_useAltCpbParamsFlag = code; |
---|
616 | sei.m_useAltCpbParamsFlagPresent = true; |
---|
617 | } |
---|
618 | #endif |
---|
619 | |
---|
620 | xParseByteAlign(); |
---|
621 | } |
---|
622 | Void SEIReader::xParseSEIPictureTiming(SEIPictureTiming& sei, UInt /*payloadSize*/, TComSPS *sps) |
---|
623 | { |
---|
624 | Int i; |
---|
625 | UInt code; |
---|
626 | |
---|
627 | TComVUI *vui = sps->getVuiParameters(); |
---|
628 | TComHRD *hrd = vui->getHrdParameters(); |
---|
629 | |
---|
630 | if( vui->getFrameFieldInfoPresentFlag() ) |
---|
631 | { |
---|
632 | READ_CODE( 4, code, "pic_struct" ); sei.m_picStruct = code; |
---|
633 | READ_CODE( 2, code, "source_scan_type" ); sei.m_sourceScanType = code; |
---|
634 | READ_FLAG( code, "duplicate_flag" ); sei.m_duplicateFlag = ( code == 1 ? true : false ); |
---|
635 | } |
---|
636 | |
---|
637 | if( hrd->getCpbDpbDelaysPresentFlag()) |
---|
638 | { |
---|
639 | READ_CODE( ( hrd->getCpbRemovalDelayLengthMinus1() + 1 ), code, "au_cpb_removal_delay_minus1" ); |
---|
640 | sei.m_auCpbRemovalDelay = code + 1; |
---|
641 | READ_CODE( ( hrd->getDpbOutputDelayLengthMinus1() + 1 ), code, "pic_dpb_output_delay" ); |
---|
642 | sei.m_picDpbOutputDelay = code; |
---|
643 | |
---|
644 | if(hrd->getSubPicCpbParamsPresentFlag()) |
---|
645 | { |
---|
646 | READ_CODE(hrd->getDpbOutputDelayDuLengthMinus1()+1, code, "pic_dpb_output_du_delay" ); |
---|
647 | sei.m_picDpbOutputDuDelay = code; |
---|
648 | } |
---|
649 | if( hrd->getSubPicCpbParamsPresentFlag() && hrd->getSubPicCpbParamsInPicTimingSEIFlag() ) |
---|
650 | { |
---|
651 | READ_UVLC( code, "num_decoding_units_minus1"); |
---|
652 | sei.m_numDecodingUnitsMinus1 = code; |
---|
653 | READ_FLAG( code, "du_common_cpb_removal_delay_flag" ); |
---|
654 | sei.m_duCommonCpbRemovalDelayFlag = code; |
---|
655 | if( sei.m_duCommonCpbRemovalDelayFlag ) |
---|
656 | { |
---|
657 | READ_CODE( ( hrd->getDuCpbRemovalDelayLengthMinus1() + 1 ), code, "du_common_cpb_removal_delay_minus1" ); |
---|
658 | sei.m_duCommonCpbRemovalDelayMinus1 = code; |
---|
659 | } |
---|
660 | if( sei.m_numNalusInDuMinus1 != NULL ) |
---|
661 | { |
---|
662 | delete sei.m_numNalusInDuMinus1; |
---|
663 | } |
---|
664 | sei.m_numNalusInDuMinus1 = new UInt[ ( sei.m_numDecodingUnitsMinus1 + 1 ) ]; |
---|
665 | if( sei.m_duCpbRemovalDelayMinus1 != NULL ) |
---|
666 | { |
---|
667 | delete sei.m_duCpbRemovalDelayMinus1; |
---|
668 | } |
---|
669 | sei.m_duCpbRemovalDelayMinus1 = new UInt[ ( sei.m_numDecodingUnitsMinus1 + 1 ) ]; |
---|
670 | |
---|
671 | for( i = 0; i <= sei.m_numDecodingUnitsMinus1; i ++ ) |
---|
672 | { |
---|
673 | READ_UVLC( code, "num_nalus_in_du_minus1"); |
---|
674 | sei.m_numNalusInDuMinus1[ i ] = code; |
---|
675 | if( ( !sei.m_duCommonCpbRemovalDelayFlag ) && ( i < sei.m_numDecodingUnitsMinus1 ) ) |
---|
676 | { |
---|
677 | READ_CODE( ( hrd->getDuCpbRemovalDelayLengthMinus1() + 1 ), code, "du_cpb_removal_delay_minus1" ); |
---|
678 | sei.m_duCpbRemovalDelayMinus1[ i ] = code; |
---|
679 | } |
---|
680 | } |
---|
681 | } |
---|
682 | } |
---|
683 | xParseByteAlign(); |
---|
684 | } |
---|
685 | Void SEIReader::xParseSEIRecoveryPoint(SEIRecoveryPoint& sei, UInt /*payloadSize*/) |
---|
686 | { |
---|
687 | Int iCode; |
---|
688 | UInt uiCode; |
---|
689 | READ_SVLC( iCode, "recovery_poc_cnt" ); sei.m_recoveryPocCnt = iCode; |
---|
690 | READ_FLAG( uiCode, "exact_matching_flag" ); sei.m_exactMatchingFlag = uiCode; |
---|
691 | READ_FLAG( uiCode, "broken_link_flag" ); sei.m_brokenLinkFlag = uiCode; |
---|
692 | xParseByteAlign(); |
---|
693 | } |
---|
694 | Void SEIReader::xParseSEIFramePacking(SEIFramePacking& sei, UInt /*payloadSize*/) |
---|
695 | { |
---|
696 | UInt val; |
---|
697 | READ_UVLC( val, "frame_packing_arrangement_id" ); sei.m_arrangementId = val; |
---|
698 | READ_FLAG( val, "frame_packing_arrangement_cancel_flag" ); sei.m_arrangementCancelFlag = val; |
---|
699 | |
---|
700 | if ( !sei.m_arrangementCancelFlag ) |
---|
701 | { |
---|
702 | READ_CODE( 7, val, "frame_packing_arrangement_type" ); sei.m_arrangementType = val; |
---|
703 | assert((sei.m_arrangementType > 2) && (sei.m_arrangementType < 6) ); |
---|
704 | READ_FLAG( val, "quincunx_sampling_flag" ); sei.m_quincunxSamplingFlag = val; |
---|
705 | |
---|
706 | READ_CODE( 6, val, "content_interpretation_type" ); sei.m_contentInterpretationType = val; |
---|
707 | READ_FLAG( val, "spatial_flipping_flag" ); sei.m_spatialFlippingFlag = val; |
---|
708 | READ_FLAG( val, "frame0_flipped_flag" ); sei.m_frame0FlippedFlag = val; |
---|
709 | READ_FLAG( val, "field_views_flag" ); sei.m_fieldViewsFlag = val; |
---|
710 | READ_FLAG( val, "current_frame_is_frame0_flag" ); sei.m_currentFrameIsFrame0Flag = val; |
---|
711 | READ_FLAG( val, "frame0_self_contained_flag" ); sei.m_frame0SelfContainedFlag = val; |
---|
712 | READ_FLAG( val, "frame1_self_contained_flag" ); sei.m_frame1SelfContainedFlag = val; |
---|
713 | |
---|
714 | if ( sei.m_quincunxSamplingFlag == 0 && sei.m_arrangementType != 5) |
---|
715 | { |
---|
716 | READ_CODE( 4, val, "frame0_grid_position_x" ); sei.m_frame0GridPositionX = val; |
---|
717 | READ_CODE( 4, val, "frame0_grid_position_y" ); sei.m_frame0GridPositionY = val; |
---|
718 | READ_CODE( 4, val, "frame1_grid_position_x" ); sei.m_frame1GridPositionX = val; |
---|
719 | READ_CODE( 4, val, "frame1_grid_position_y" ); sei.m_frame1GridPositionY = val; |
---|
720 | } |
---|
721 | |
---|
722 | READ_CODE( 8, val, "frame_packing_arrangement_reserved_byte" ); sei.m_arrangementReservedByte = val; |
---|
723 | READ_FLAG( val, "frame_packing_arrangement_persistence_flag" ); sei.m_arrangementPersistenceFlag = val ? true : false; |
---|
724 | } |
---|
725 | READ_FLAG( val, "upsampled_aspect_ratio" ); sei.m_upsampledAspectRatio = val; |
---|
726 | |
---|
727 | xParseByteAlign(); |
---|
728 | } |
---|
729 | |
---|
730 | Void SEIReader::xParseSEIDisplayOrientation(SEIDisplayOrientation& sei, UInt /*payloadSize*/) |
---|
731 | { |
---|
732 | UInt val; |
---|
733 | READ_FLAG( val, "display_orientation_cancel_flag" ); sei.cancelFlag = val; |
---|
734 | if( !sei.cancelFlag ) |
---|
735 | { |
---|
736 | READ_FLAG( val, "hor_flip" ); sei.horFlip = val; |
---|
737 | READ_FLAG( val, "ver_flip" ); sei.verFlip = val; |
---|
738 | READ_CODE( 16, val, "anticlockwise_rotation" ); sei.anticlockwiseRotation = val; |
---|
739 | READ_FLAG( val, "display_orientation_persistence_flag" ); sei.persistenceFlag = val; |
---|
740 | } |
---|
741 | xParseByteAlign(); |
---|
742 | } |
---|
743 | |
---|
744 | Void SEIReader::xParseSEITemporalLevel0Index(SEITemporalLevel0Index& sei, UInt /*payloadSize*/) |
---|
745 | { |
---|
746 | UInt val; |
---|
747 | READ_CODE ( 8, val, "tl0_idx" ); sei.tl0Idx = val; |
---|
748 | READ_CODE ( 8, val, "rap_idx" ); sei.rapIdx = val; |
---|
749 | xParseByteAlign(); |
---|
750 | } |
---|
751 | |
---|
752 | Void SEIReader::xParseSEIGradualDecodingRefreshInfo(SEIGradualDecodingRefreshInfo& sei, UInt /*payloadSize*/) |
---|
753 | { |
---|
754 | UInt val; |
---|
755 | READ_FLAG( val, "gdr_foreground_flag" ); sei.m_gdrForegroundFlag = val ? 1 : 0; |
---|
756 | xParseByteAlign(); |
---|
757 | } |
---|
758 | |
---|
759 | Void SEIReader::xParseSEIToneMappingInfo(SEIToneMappingInfo& sei, UInt /*payloadSize*/) |
---|
760 | { |
---|
761 | Int i; |
---|
762 | UInt val; |
---|
763 | READ_UVLC( val, "tone_map_id" ); sei.m_toneMapId = val; |
---|
764 | READ_FLAG( val, "tone_map_cancel_flag" ); sei.m_toneMapCancelFlag = val; |
---|
765 | |
---|
766 | if ( !sei.m_toneMapCancelFlag ) |
---|
767 | { |
---|
768 | READ_FLAG( val, "tone_map_persistence_flag" ); sei.m_toneMapPersistenceFlag = val; |
---|
769 | READ_CODE( 8, val, "coded_data_bit_depth" ); sei.m_codedDataBitDepth = val; |
---|
770 | READ_CODE( 8, val, "target_bit_depth" ); sei.m_targetBitDepth = val; |
---|
771 | READ_UVLC( val, "model_id" ); sei.m_modelId = val; |
---|
772 | switch(sei.m_modelId) |
---|
773 | { |
---|
774 | case 0: |
---|
775 | { |
---|
776 | READ_CODE( 32, val, "min_value" ); sei.m_minValue = val; |
---|
777 | READ_CODE( 32, val, "max_value" ); sei.m_maxValue = val; |
---|
778 | break; |
---|
779 | } |
---|
780 | case 1: |
---|
781 | { |
---|
782 | READ_CODE( 32, val, "sigmoid_midpoint" ); sei.m_sigmoidMidpoint = val; |
---|
783 | READ_CODE( 32, val, "sigmoid_width" ); sei.m_sigmoidWidth = val; |
---|
784 | break; |
---|
785 | } |
---|
786 | case 2: |
---|
787 | { |
---|
788 | UInt num = 1u << sei.m_targetBitDepth; |
---|
789 | sei.m_startOfCodedInterval.resize(num+1); |
---|
790 | for(i = 0; i < num; i++) |
---|
791 | { |
---|
792 | READ_CODE( ((( sei.m_codedDataBitDepth + 7 ) >> 3 ) << 3), val, "start_of_coded_interval" ); |
---|
793 | sei.m_startOfCodedInterval[i] = val; |
---|
794 | } |
---|
795 | sei.m_startOfCodedInterval[num] = 1u << sei.m_codedDataBitDepth; |
---|
796 | break; |
---|
797 | } |
---|
798 | case 3: |
---|
799 | { |
---|
800 | READ_CODE( 16, val, "num_pivots" ); sei.m_numPivots = val; |
---|
801 | sei.m_codedPivotValue.resize(sei.m_numPivots); |
---|
802 | sei.m_targetPivotValue.resize(sei.m_numPivots); |
---|
803 | for(i = 0; i < sei.m_numPivots; i++ ) |
---|
804 | { |
---|
805 | READ_CODE( ((( sei.m_codedDataBitDepth + 7 ) >> 3 ) << 3), val, "coded_pivot_value" ); |
---|
806 | sei.m_codedPivotValue[i] = val; |
---|
807 | READ_CODE( ((( sei.m_targetBitDepth + 7 ) >> 3 ) << 3), val, "target_pivot_value" ); |
---|
808 | sei.m_targetPivotValue[i] = val; |
---|
809 | } |
---|
810 | break; |
---|
811 | } |
---|
812 | case 4: |
---|
813 | { |
---|
814 | READ_CODE( 8, val, "camera_iso_speed_idc" ); sei.m_cameraIsoSpeedValue = val; |
---|
815 | if( sei.m_cameraIsoSpeedValue == 255) //Extended_ISO |
---|
816 | { |
---|
817 | READ_CODE( 32, val, "camera_iso_speed_value" ); sei.m_cameraIsoSpeedValue = val; |
---|
818 | } |
---|
819 | READ_FLAG( val, "exposure_compensation_value_sign_flag" ); sei.m_exposureCompensationValueSignFlag = val; |
---|
820 | READ_CODE( 16, val, "exposure_compensation_value_numerator" ); sei.m_exposureCompensationValueNumerator = val; |
---|
821 | READ_CODE( 16, val, "exposure_compensation_value_denom_idc" ); sei.m_exposureCompensationValueDenomIdc = val; |
---|
822 | READ_CODE( 32, val, "ref_screen_luminance_white" ); sei.m_refScreenLuminanceWhite = val; |
---|
823 | READ_CODE( 32, val, "extended_range_white_level" ); sei.m_extendedRangeWhiteLevel = val; |
---|
824 | READ_CODE( 16, val, "nominal_black_level_luma_code_value" ); sei.m_nominalBlackLevelLumaCodeValue = val; |
---|
825 | READ_CODE( 16, val, "nominal_white_level_luma_code_value" ); sei.m_nominalWhiteLevelLumaCodeValue= val; |
---|
826 | READ_CODE( 16, val, "extended_white_level_luma_code_value" ); sei.m_extendedWhiteLevelLumaCodeValue = val; |
---|
827 | break; |
---|
828 | } |
---|
829 | default: |
---|
830 | { |
---|
831 | assert(!"Undefined SEIToneMapModelId"); |
---|
832 | break; |
---|
833 | } |
---|
834 | }//switch model id |
---|
835 | }// if(!sei.m_toneMapCancelFlag) |
---|
836 | |
---|
837 | xParseByteAlign(); |
---|
838 | } |
---|
839 | |
---|
840 | Void SEIReader::xParseSEISOPDescription(SEISOPDescription &sei, UInt payloadSize) |
---|
841 | { |
---|
842 | Int iCode; |
---|
843 | UInt uiCode; |
---|
844 | |
---|
845 | READ_UVLC( uiCode, "sop_seq_parameter_set_id" ); sei.m_sopSeqParameterSetId = uiCode; |
---|
846 | READ_UVLC( uiCode, "num_pics_in_sop_minus1" ); sei.m_numPicsInSopMinus1 = uiCode; |
---|
847 | for (UInt i = 0; i <= sei.m_numPicsInSopMinus1; i++) |
---|
848 | { |
---|
849 | READ_CODE( 6, uiCode, "sop_desc_vcl_nalu_type" ); sei.m_sopDescVclNaluType[i] = uiCode; |
---|
850 | READ_CODE( 3, sei.m_sopDescTemporalId[i], "sop_desc_temporal_id" ); sei.m_sopDescTemporalId[i] = uiCode; |
---|
851 | if (sei.m_sopDescVclNaluType[i] != NAL_UNIT_CODED_SLICE_IDR_W_RADL && sei.m_sopDescVclNaluType[i] != NAL_UNIT_CODED_SLICE_IDR_N_LP) |
---|
852 | { |
---|
853 | READ_UVLC( sei.m_sopDescStRpsIdx[i], "sop_desc_st_rps_idx" ); sei.m_sopDescStRpsIdx[i] = uiCode; |
---|
854 | } |
---|
855 | if (i > 0) |
---|
856 | { |
---|
857 | READ_SVLC( iCode, "sop_desc_poc_delta" ); sei.m_sopDescPocDelta[i] = iCode; |
---|
858 | } |
---|
859 | } |
---|
860 | |
---|
861 | xParseByteAlign(); |
---|
862 | } |
---|
863 | |
---|
864 | #if LAYERS_NOT_PRESENT_SEI |
---|
865 | Void SEIReader::xParseSEIScalableNesting(SEIScalableNesting& sei, const NalUnitType nalUnitType, UInt payloadSize, TComVPS *vps, TComSPS *sps) |
---|
866 | #else |
---|
867 | Void SEIReader::xParseSEIScalableNesting(SEIScalableNesting& sei, const NalUnitType nalUnitType, UInt payloadSize, TComSPS *sps) |
---|
868 | #endif |
---|
869 | { |
---|
870 | UInt uiCode; |
---|
871 | SEIMessages seis; |
---|
872 | |
---|
873 | READ_FLAG( uiCode, "bitstream_subset_flag" ); sei.m_bitStreamSubsetFlag = uiCode; |
---|
874 | READ_FLAG( uiCode, "nesting_op_flag" ); sei.m_nestingOpFlag = uiCode; |
---|
875 | if (sei.m_nestingOpFlag) |
---|
876 | { |
---|
877 | READ_FLAG( uiCode, "default_op_flag" ); sei.m_defaultOpFlag = uiCode; |
---|
878 | READ_UVLC( uiCode, "nesting_num_ops_minus1" ); sei.m_nestingNumOpsMinus1 = uiCode; |
---|
879 | for (UInt i = sei.m_defaultOpFlag; i <= sei.m_nestingNumOpsMinus1; i++) |
---|
880 | { |
---|
881 | READ_CODE( 3, uiCode, "nesting_max_temporal_id_plus1" ); sei.m_nestingMaxTemporalIdPlus1[i] = uiCode; |
---|
882 | READ_UVLC( uiCode, "nesting_op_idx" ); sei.m_nestingOpIdx[i] = uiCode; |
---|
883 | } |
---|
884 | } |
---|
885 | else |
---|
886 | { |
---|
887 | READ_FLAG( uiCode, "all_layers_flag" ); sei.m_allLayersFlag = uiCode; |
---|
888 | if (!sei.m_allLayersFlag) |
---|
889 | { |
---|
890 | READ_CODE( 3, uiCode, "nesting_no_op_max_temporal_id_plus1" ); sei.m_nestingNoOpMaxTemporalIdPlus1 = uiCode; |
---|
891 | READ_UVLC( uiCode, "nesting_num_layers_minus1" ); sei.m_nestingNumLayersMinus1 = uiCode; |
---|
892 | for (UInt i = 0; i <= sei.m_nestingNumLayersMinus1; i++) |
---|
893 | { |
---|
894 | READ_CODE( 6, uiCode, "nesting_layer_id" ); sei.m_nestingLayerId[i] = uiCode; |
---|
895 | } |
---|
896 | } |
---|
897 | } |
---|
898 | |
---|
899 | // byte alignment |
---|
900 | while ( m_pcBitstream->getNumBitsRead() % 8 != 0 ) |
---|
901 | { |
---|
902 | UInt code; |
---|
903 | READ_FLAG( code, "nesting_zero_bit" ); |
---|
904 | } |
---|
905 | |
---|
906 | sei.m_callerOwnsSEIs = false; |
---|
907 | |
---|
908 | // read nested SEI messages |
---|
909 | do { |
---|
910 | #if O0164_MULTI_LAYER_HRD |
---|
911 | #if LAYERS_NOT_PRESENT_SEI |
---|
912 | xReadSEImessage(sei.m_nestedSEIs, nalUnitType, vps, sps, &sei); |
---|
913 | #else |
---|
914 | xReadSEImessage(sei.m_nestedSEIs, nalUnitType, sps, &sei); |
---|
915 | #endif |
---|
916 | #else |
---|
917 | #if LAYERS_NOT_PRESENT_SEI |
---|
918 | xReadSEImessage(sei.m_nestedSEIs, nalUnitType, vps, sps); |
---|
919 | #else |
---|
920 | xReadSEImessage(sei.m_nestedSEIs, nalUnitType, sps); |
---|
921 | #endif |
---|
922 | #endif |
---|
923 | } while (m_pcBitstream->getNumBitsLeft() > 8); |
---|
924 | |
---|
925 | } |
---|
926 | |
---|
927 | Void SEIReader::xParseByteAlign() |
---|
928 | { |
---|
929 | UInt code; |
---|
930 | if( m_pcBitstream->getNumBitsRead() % 8 != 0 ) |
---|
931 | { |
---|
932 | READ_FLAG( code, "bit_equal_to_one" ); assert( code == 1 ); |
---|
933 | } |
---|
934 | while( m_pcBitstream->getNumBitsRead() % 8 != 0 ) |
---|
935 | { |
---|
936 | READ_FLAG( code, "bit_equal_to_zero" ); assert( code == 0 ); |
---|
937 | } |
---|
938 | } |
---|
939 | |
---|
940 | #if SVC_EXTENSION |
---|
941 | #if LAYERS_NOT_PRESENT_SEI |
---|
942 | Void SEIReader::xParseSEILayersNotPresent(SEILayersNotPresent &sei, UInt payloadSize, TComVPS *vps) |
---|
943 | { |
---|
944 | UInt uiCode; |
---|
945 | UInt i = 0; |
---|
946 | |
---|
947 | READ_UVLC( uiCode, "lp_sei_active_vps_id" ); sei.m_activeVpsId = uiCode; |
---|
948 | assert(vps->getVPSId() == sei.m_activeVpsId); |
---|
949 | sei.m_vpsMaxLayers = vps->getMaxLayers(); |
---|
950 | for (; i < sei.m_vpsMaxLayers; i++) |
---|
951 | { |
---|
952 | READ_FLAG( uiCode, "layer_not_present_flag" ); sei.m_layerNotPresentFlag[i] = uiCode ? true : false; |
---|
953 | } |
---|
954 | for (; i < MAX_LAYERS; i++) |
---|
955 | { |
---|
956 | sei.m_layerNotPresentFlag[i] = false; |
---|
957 | } |
---|
958 | xParseByteAlign(); |
---|
959 | } |
---|
960 | #endif |
---|
961 | #if N0383_IL_CONSTRAINED_TILE_SETS_SEI |
---|
962 | Void SEIReader::xParseSEIInterLayerConstrainedTileSets (SEIInterLayerConstrainedTileSets &sei, UInt payloadSize) |
---|
963 | { |
---|
964 | UInt uiCode; |
---|
965 | |
---|
966 | READ_FLAG( uiCode, "il_all_tiles_exact_sample_value_match_flag" ); sei.m_ilAllTilesExactSampleValueMatchFlag = uiCode; |
---|
967 | READ_FLAG( uiCode, "il_one_tile_per_tile_set_flag" ); sei.m_ilOneTilePerTileSetFlag = uiCode; |
---|
968 | if( !sei.m_ilOneTilePerTileSetFlag ) |
---|
969 | { |
---|
970 | READ_UVLC( uiCode, "il_num_sets_in_message_minus1" ); sei.m_ilNumSetsInMessageMinus1 = uiCode; |
---|
971 | if( sei.m_ilNumSetsInMessageMinus1 ) |
---|
972 | { |
---|
973 | READ_FLAG( uiCode, "skipped_tile_set_present_flag" ); sei.m_skippedTileSetPresentFlag = uiCode; |
---|
974 | } |
---|
975 | else |
---|
976 | { |
---|
977 | sei.m_skippedTileSetPresentFlag = false; |
---|
978 | } |
---|
979 | UInt numSignificantSets = sei.m_ilNumSetsInMessageMinus1 - (sei.m_skippedTileSetPresentFlag ? 1 : 0) + 1; |
---|
980 | for( UInt i = 0; i < numSignificantSets; i++ ) |
---|
981 | { |
---|
982 | READ_UVLC( uiCode, "ilcts_id" ); sei.m_ilctsId[i] = uiCode; |
---|
983 | READ_UVLC( uiCode, "il_num_tile_rects_in_set_minus1" ) ;sei.m_ilNumTileRectsInSetMinus1[i] = uiCode; |
---|
984 | for( UInt j = 0; j <= sei.m_ilNumTileRectsInSetMinus1[i]; j++ ) |
---|
985 | { |
---|
986 | READ_UVLC( uiCode, "il_top_left_tile_index" ); sei.m_ilTopLeftTileIndex[i][j] = uiCode; |
---|
987 | READ_UVLC( uiCode, "il_bottom_right_tile_index" ); sei.m_ilBottomRightTileIndex[i][j] = uiCode; |
---|
988 | } |
---|
989 | READ_CODE( 2, uiCode, "ilc_idc" ); sei.m_ilcIdc[i] = uiCode; |
---|
990 | if( sei.m_ilAllTilesExactSampleValueMatchFlag ) |
---|
991 | { |
---|
992 | READ_FLAG( uiCode, "il_exact_sample_value_match_flag" ); sei.m_ilExactSampleValueMatchFlag[i] = uiCode; |
---|
993 | } |
---|
994 | } |
---|
995 | } |
---|
996 | else |
---|
997 | { |
---|
998 | READ_CODE( 2, uiCode, "all_tiles_ilc_idc" ); sei.m_allTilesIlcIdc = uiCode; |
---|
999 | } |
---|
1000 | |
---|
1001 | xParseByteAlign(); |
---|
1002 | } |
---|
1003 | #endif |
---|
1004 | #if SUB_BITSTREAM_PROPERTY_SEI |
---|
1005 | Void SEIReader::xParseSEISubBitstreamProperty(SEISubBitstreamProperty &sei) |
---|
1006 | { |
---|
1007 | UInt uiCode; |
---|
1008 | READ_CODE( 4, uiCode, "active_vps_id" ); sei.m_activeVpsId = uiCode; |
---|
1009 | READ_UVLC( uiCode, "num_additional_sub_streams_minus1" ); sei.m_numAdditionalSubStreams = uiCode + 1; |
---|
1010 | |
---|
1011 | for( Int i = 0; i < sei.m_numAdditionalSubStreams; i++ ) |
---|
1012 | { |
---|
1013 | READ_CODE( 2, uiCode, "sub_bitstream_mode[i]" ); sei.m_subBitstreamMode[i] = uiCode; |
---|
1014 | READ_UVLC( uiCode, "output_layer_set_idx_to_vps[i]" ); sei.m_outputLayerSetIdxToVps[i] = uiCode; |
---|
1015 | READ_CODE( 3, uiCode, "highest_sub_layer_id[i]" ); sei.m_highestSublayerId[i] = uiCode; |
---|
1016 | READ_CODE( 16, uiCode, "avg_bit_rate[i]" ); sei.m_avgBitRate[i] = uiCode; |
---|
1017 | READ_CODE( 16, uiCode, "max_bit_rate[i]" ); sei.m_maxBitRate[i] = uiCode; |
---|
1018 | } |
---|
1019 | xParseByteAlign(); |
---|
1020 | } |
---|
1021 | #endif |
---|
1022 | |
---|
1023 | #if O0164_MULTI_LAYER_HRD |
---|
1024 | #if LAYERS_NOT_PRESENT_SEI |
---|
1025 | Void SEIReader::xParseSEIBspNesting(SEIBspNesting &sei, const NalUnitType nalUnitType, TComVPS *vps, TComSPS *sps, const SEIScalableNesting &nestingSei) |
---|
1026 | #else |
---|
1027 | Void SEIReader::xParseSEIBspNesting(SEIBspNesting &sei, const NalUnitType nalUnitType, TComSPS *sps, const SEIScalableNesting &nestingSei) |
---|
1028 | #endif |
---|
1029 | { |
---|
1030 | UInt uiCode; |
---|
1031 | READ_UVLC( uiCode, "bsp_idx" ); sei.m_bspIdx = uiCode; |
---|
1032 | |
---|
1033 | // byte alignment |
---|
1034 | while ( m_pcBitstream->getNumBitsRead() % 8 != 0 ) |
---|
1035 | { |
---|
1036 | UInt code; |
---|
1037 | READ_FLAG( code, "bsp_nesting_zero_bit" ); |
---|
1038 | } |
---|
1039 | |
---|
1040 | sei.m_callerOwnsSEIs = false; |
---|
1041 | |
---|
1042 | // read nested SEI messages |
---|
1043 | do { |
---|
1044 | #if LAYERS_NOT_PRESENT_SEI |
---|
1045 | xReadSEImessage(sei.m_nestedSEIs, nalUnitType, vps, sps, &nestingSei, &sei); |
---|
1046 | #else |
---|
1047 | xReadSEImessage(sei.m_nestedSEIs, nalUnitType, sps, &nestingSei); |
---|
1048 | #endif |
---|
1049 | } while (m_pcBitstream->getNumBitsLeft() > 8); |
---|
1050 | } |
---|
1051 | |
---|
1052 | Void SEIReader::xParseSEIBspInitialArrivalTime(SEIBspInitialArrivalTime &sei, TComVPS *vps, TComSPS *sps, const SEIScalableNesting &nestingSei, const SEIBspNesting &bspNestingSei) |
---|
1053 | { |
---|
1054 | assert(vps->getVpsVuiPresentFlag()); |
---|
1055 | |
---|
1056 | UInt schedCombCnt = vps->getNumBspSchedCombinations(nestingSei.m_nestingOpIdx[0]); |
---|
1057 | UInt len; |
---|
1058 | UInt hrdIdx; |
---|
1059 | UInt uiCode; |
---|
1060 | |
---|
1061 | if (schedCombCnt > 0) |
---|
1062 | { |
---|
1063 | hrdIdx = vps->getBspCombHrdIdx(nestingSei.m_nestingOpIdx[0], 0, bspNestingSei.m_bspIdx); |
---|
1064 | } |
---|
1065 | else |
---|
1066 | { |
---|
1067 | hrdIdx = 0; |
---|
1068 | } |
---|
1069 | |
---|
1070 | TComHRD *hrd = vps->getBspHrd(hrdIdx); |
---|
1071 | |
---|
1072 | if (hrd->getNalHrdParametersPresentFlag() || hrd->getVclHrdParametersPresentFlag()) |
---|
1073 | { |
---|
1074 | len = hrd->getInitialCpbRemovalDelayLengthMinus1() + 1; |
---|
1075 | } |
---|
1076 | else |
---|
1077 | { |
---|
1078 | len = 23 + 1; |
---|
1079 | } |
---|
1080 | |
---|
1081 | if (hrd->getNalHrdParametersPresentFlag()) |
---|
1082 | { |
---|
1083 | for(UInt i = 0; i < schedCombCnt; i++) |
---|
1084 | { |
---|
1085 | READ_CODE( len, uiCode, "nal_initial_arrival_delay" ); sei.m_nalInitialArrivalDelay[i] = uiCode; |
---|
1086 | } |
---|
1087 | } |
---|
1088 | else |
---|
1089 | { |
---|
1090 | for(UInt i = 0; i < schedCombCnt; i++) |
---|
1091 | { |
---|
1092 | READ_CODE( len, uiCode, "vcl_initial_arrival_delay" ); sei.m_vclInitialArrivalDelay[i] = uiCode; |
---|
1093 | } |
---|
1094 | } |
---|
1095 | } |
---|
1096 | |
---|
1097 | Void SEIReader::xParseSEIBspHrd(SEIBspHrd &sei, TComSPS *sps, const SEIScalableNesting &nestingSei) |
---|
1098 | { |
---|
1099 | UInt uiCode; |
---|
1100 | READ_UVLC( uiCode, "sei_num_bsp_hrd_parameters_minus1" ); sei.m_seiNumBspHrdParametersMinus1 = uiCode; |
---|
1101 | for (UInt i = 0; i <= sei.m_seiNumBspHrdParametersMinus1; i++) |
---|
1102 | { |
---|
1103 | if (i > 0) |
---|
1104 | { |
---|
1105 | READ_FLAG( uiCode, "sei_bsp_cprms_present_flag" ); sei.m_seiBspCprmsPresentFlag[i] = uiCode; |
---|
1106 | } |
---|
1107 | xParseHrdParameters(sei.hrd, i==0 ? 1 : sei.m_seiBspCprmsPresentFlag[i], nestingSei.m_nestingMaxTemporalIdPlus1[0]-1); |
---|
1108 | } |
---|
1109 | for (UInt h = 0; h <= nestingSei.m_nestingNumOpsMinus1; h++) |
---|
1110 | { |
---|
1111 | UInt lsIdx = nestingSei.m_nestingOpIdx[h]; |
---|
1112 | READ_UVLC( uiCode, "num_sei_bitstream_partitions_minus1[i]"); sei.m_seiNumBitstreamPartitionsMinus1[lsIdx] = uiCode; |
---|
1113 | for (UInt i = 0; i <= sei.m_seiNumBitstreamPartitionsMinus1[lsIdx]; i++) |
---|
1114 | { |
---|
1115 | for (UInt j = 0; j < sei.m_vpsMaxLayers; j++) |
---|
1116 | { |
---|
1117 | if (sei.m_layerIdIncludedFlag[lsIdx][j]) |
---|
1118 | { |
---|
1119 | READ_FLAG( uiCode, "sei_layer_in_bsp_flag[lsIdx][i][j]" ); sei.m_seiLayerInBspFlag[lsIdx][i][j] = uiCode; |
---|
1120 | } |
---|
1121 | } |
---|
1122 | } |
---|
1123 | READ_UVLC( uiCode, "sei_num_bsp_sched_combinations_minus1[i]"); sei.m_seiNumBspSchedCombinationsMinus1[lsIdx] = uiCode; |
---|
1124 | for (UInt i = 0; i <= sei.m_seiNumBspSchedCombinationsMinus1[lsIdx]; i++) |
---|
1125 | { |
---|
1126 | for (UInt j = 0; j <= sei.m_seiNumBitstreamPartitionsMinus1[lsIdx]; j++) |
---|
1127 | { |
---|
1128 | READ_UVLC( uiCode, "sei_bsp_comb_hrd_idx[lsIdx][i][j]"); sei.m_seiBspCombHrdIdx[lsIdx][i][j] = uiCode; |
---|
1129 | READ_UVLC( uiCode, "sei_bsp_comb_sched_idx[lsIdx][i][j]"); sei.m_seiBspCombScheddx[lsIdx][i][j] = uiCode; |
---|
1130 | } |
---|
1131 | } |
---|
1132 | } |
---|
1133 | } |
---|
1134 | |
---|
1135 | Void SEIReader::xParseHrdParameters(TComHRD *hrd, Bool commonInfPresentFlag, UInt maxNumSubLayersMinus1) |
---|
1136 | { |
---|
1137 | UInt uiCode; |
---|
1138 | if( commonInfPresentFlag ) |
---|
1139 | { |
---|
1140 | READ_FLAG( uiCode, "nal_hrd_parameters_present_flag" ); hrd->setNalHrdParametersPresentFlag( uiCode == 1 ? true : false ); |
---|
1141 | READ_FLAG( uiCode, "vcl_hrd_parameters_present_flag" ); hrd->setVclHrdParametersPresentFlag( uiCode == 1 ? true : false ); |
---|
1142 | if( hrd->getNalHrdParametersPresentFlag() || hrd->getVclHrdParametersPresentFlag() ) |
---|
1143 | { |
---|
1144 | READ_FLAG( uiCode, "sub_pic_cpb_params_present_flag" ); hrd->setSubPicCpbParamsPresentFlag( uiCode == 1 ? true : false ); |
---|
1145 | if( hrd->getSubPicCpbParamsPresentFlag() ) |
---|
1146 | { |
---|
1147 | READ_CODE( 8, uiCode, "tick_divisor_minus2" ); hrd->setTickDivisorMinus2( uiCode ); |
---|
1148 | READ_CODE( 5, uiCode, "du_cpb_removal_delay_length_minus1" ); hrd->setDuCpbRemovalDelayLengthMinus1( uiCode ); |
---|
1149 | READ_FLAG( uiCode, "sub_pic_cpb_params_in_pic_timing_sei_flag" ); hrd->setSubPicCpbParamsInPicTimingSEIFlag( uiCode == 1 ? true : false ); |
---|
1150 | READ_CODE( 5, uiCode, "dpb_output_delay_du_length_minus1" ); hrd->setDpbOutputDelayDuLengthMinus1( uiCode ); |
---|
1151 | } |
---|
1152 | READ_CODE( 4, uiCode, "bit_rate_scale" ); hrd->setBitRateScale( uiCode ); |
---|
1153 | READ_CODE( 4, uiCode, "cpb_size_scale" ); hrd->setCpbSizeScale( uiCode ); |
---|
1154 | if( hrd->getSubPicCpbParamsPresentFlag() ) |
---|
1155 | { |
---|
1156 | READ_CODE( 4, uiCode, "cpb_size_du_scale" ); hrd->setDuCpbSizeScale( uiCode ); |
---|
1157 | } |
---|
1158 | READ_CODE( 5, uiCode, "initial_cpb_removal_delay_length_minus1" ); hrd->setInitialCpbRemovalDelayLengthMinus1( uiCode ); |
---|
1159 | READ_CODE( 5, uiCode, "au_cpb_removal_delay_length_minus1" ); hrd->setCpbRemovalDelayLengthMinus1( uiCode ); |
---|
1160 | READ_CODE( 5, uiCode, "dpb_output_delay_length_minus1" ); hrd->setDpbOutputDelayLengthMinus1( uiCode ); |
---|
1161 | } |
---|
1162 | } |
---|
1163 | Int i, j, nalOrVcl; |
---|
1164 | for( i = 0; i <= maxNumSubLayersMinus1; i ++ ) |
---|
1165 | { |
---|
1166 | READ_FLAG( uiCode, "fixed_pic_rate_general_flag" ); hrd->setFixedPicRateFlag( i, uiCode == 1 ? true : false ); |
---|
1167 | if( !hrd->getFixedPicRateFlag( i ) ) |
---|
1168 | { |
---|
1169 | READ_FLAG( uiCode, "fixed_pic_rate_within_cvs_flag" ); hrd->setFixedPicRateWithinCvsFlag( i, uiCode == 1 ? true : false ); |
---|
1170 | } |
---|
1171 | else |
---|
1172 | { |
---|
1173 | hrd->setFixedPicRateWithinCvsFlag( i, true ); |
---|
1174 | } |
---|
1175 | hrd->setLowDelayHrdFlag( i, 0 ); // Infered to be 0 when not present |
---|
1176 | hrd->setCpbCntMinus1 ( i, 0 ); // Infered to be 0 when not present |
---|
1177 | if( hrd->getFixedPicRateWithinCvsFlag( i ) ) |
---|
1178 | { |
---|
1179 | READ_UVLC( uiCode, "elemental_duration_in_tc_minus1" ); hrd->setPicDurationInTcMinus1( i, uiCode ); |
---|
1180 | } |
---|
1181 | else |
---|
1182 | { |
---|
1183 | READ_FLAG( uiCode, "low_delay_hrd_flag" ); hrd->setLowDelayHrdFlag( i, uiCode == 1 ? true : false ); |
---|
1184 | } |
---|
1185 | if (!hrd->getLowDelayHrdFlag( i )) |
---|
1186 | { |
---|
1187 | READ_UVLC( uiCode, "cpb_cnt_minus1" ); hrd->setCpbCntMinus1( i, uiCode ); |
---|
1188 | } |
---|
1189 | for( nalOrVcl = 0; nalOrVcl < 2; nalOrVcl ++ ) |
---|
1190 | { |
---|
1191 | if( ( ( nalOrVcl == 0 ) && ( hrd->getNalHrdParametersPresentFlag() ) ) || |
---|
1192 | ( ( nalOrVcl == 1 ) && ( hrd->getVclHrdParametersPresentFlag() ) ) ) |
---|
1193 | { |
---|
1194 | for( j = 0; j <= ( hrd->getCpbCntMinus1( i ) ); j ++ ) |
---|
1195 | { |
---|
1196 | READ_UVLC( uiCode, "bit_rate_value_minus1" ); hrd->setBitRateValueMinus1( i, j, nalOrVcl, uiCode ); |
---|
1197 | READ_UVLC( uiCode, "cpb_size_value_minus1" ); hrd->setCpbSizeValueMinus1( i, j, nalOrVcl, uiCode ); |
---|
1198 | if( hrd->getSubPicCpbParamsPresentFlag() ) |
---|
1199 | { |
---|
1200 | READ_UVLC( uiCode, "cpb_size_du_value_minus1" ); hrd->setDuCpbSizeValueMinus1( i, j, nalOrVcl, uiCode ); |
---|
1201 | READ_UVLC( uiCode, "bit_rate_du_value_minus1" ); hrd->setDuBitRateValueMinus1( i, j, nalOrVcl, uiCode ); |
---|
1202 | } |
---|
1203 | READ_FLAG( uiCode, "cbr_flag" ); hrd->setCbrFlag( i, j, nalOrVcl, uiCode == 1 ? true : false ); |
---|
1204 | } |
---|
1205 | } |
---|
1206 | } |
---|
1207 | } |
---|
1208 | } |
---|
1209 | #endif |
---|
1210 | |
---|
1211 | #endif //SVC_EXTENSION |
---|
1212 | |
---|
1213 | //! \} |
---|