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 | #endif //SVC_EXTENSION |
---|
118 | default: |
---|
119 | fprintf( g_hTrace, "=========== Unknown SEI message ===========\n"); |
---|
120 | break; |
---|
121 | } |
---|
122 | } |
---|
123 | #endif |
---|
124 | |
---|
125 | /** |
---|
126 | * unmarshal a single SEI message from bitstream bs |
---|
127 | */ |
---|
128 | #if LAYERS_NOT_PRESENT_SEI |
---|
129 | void SEIReader::parseSEImessage(TComInputBitstream* bs, SEIMessages& seis, const NalUnitType nalUnitType, TComVPS *vps, TComSPS *sps) |
---|
130 | #else |
---|
131 | void SEIReader::parseSEImessage(TComInputBitstream* bs, SEIMessages& seis, const NalUnitType nalUnitType, TComSPS *sps) |
---|
132 | #endif |
---|
133 | { |
---|
134 | setBitstream(bs); |
---|
135 | |
---|
136 | assert(!m_pcBitstream->getNumBitsUntilByteAligned()); |
---|
137 | do |
---|
138 | { |
---|
139 | #if LAYERS_NOT_PRESENT_SEI |
---|
140 | xReadSEImessage(seis, nalUnitType, vps, sps); |
---|
141 | #else |
---|
142 | xReadSEImessage(seis, nalUnitType, sps); |
---|
143 | #endif |
---|
144 | /* SEI messages are an integer number of bytes, something has failed |
---|
145 | * in the parsing if bitstream not byte-aligned */ |
---|
146 | assert(!m_pcBitstream->getNumBitsUntilByteAligned()); |
---|
147 | } while (m_pcBitstream->getNumBitsLeft() > 8); |
---|
148 | |
---|
149 | UInt rbspTrailingBits; |
---|
150 | READ_CODE(8, rbspTrailingBits, "rbsp_trailing_bits"); |
---|
151 | assert(rbspTrailingBits == 0x80); |
---|
152 | } |
---|
153 | |
---|
154 | #if LAYERS_NOT_PRESENT_SEI |
---|
155 | Void SEIReader::xReadSEImessage(SEIMessages& seis, const NalUnitType nalUnitType, TComVPS *vps, TComSPS *sps) |
---|
156 | #else |
---|
157 | Void SEIReader::xReadSEImessage(SEIMessages& seis, const NalUnitType nalUnitType, TComSPS *sps) |
---|
158 | #endif |
---|
159 | { |
---|
160 | #if ENC_DEC_TRACE |
---|
161 | xTraceSEIHeader(); |
---|
162 | #endif |
---|
163 | Int payloadType = 0; |
---|
164 | UInt val = 0; |
---|
165 | |
---|
166 | do |
---|
167 | { |
---|
168 | READ_CODE (8, val, "payload_type"); |
---|
169 | payloadType += val; |
---|
170 | } while (val==0xFF); |
---|
171 | |
---|
172 | UInt payloadSize = 0; |
---|
173 | do |
---|
174 | { |
---|
175 | READ_CODE (8, val, "payload_size"); |
---|
176 | payloadSize += val; |
---|
177 | } while (val==0xFF); |
---|
178 | |
---|
179 | #if ENC_DEC_TRACE |
---|
180 | xTraceSEIMessageType((SEI::PayloadType)payloadType); |
---|
181 | #endif |
---|
182 | |
---|
183 | /* extract the payload for this single SEI message. |
---|
184 | * This allows greater safety in erroneous parsing of an SEI message |
---|
185 | * from affecting subsequent messages. |
---|
186 | * After parsing the payload, bs needs to be restored as the primary |
---|
187 | * bitstream. |
---|
188 | */ |
---|
189 | TComInputBitstream *bs = getBitstream(); |
---|
190 | setBitstream(bs->extractSubstream(payloadSize * 8)); |
---|
191 | |
---|
192 | SEI *sei = NULL; |
---|
193 | |
---|
194 | if(nalUnitType == NAL_UNIT_PREFIX_SEI) |
---|
195 | { |
---|
196 | switch (payloadType) |
---|
197 | { |
---|
198 | case SEI::USER_DATA_UNREGISTERED: |
---|
199 | sei = new SEIuserDataUnregistered; |
---|
200 | xParseSEIuserDataUnregistered((SEIuserDataUnregistered&) *sei, payloadSize); |
---|
201 | break; |
---|
202 | case SEI::ACTIVE_PARAMETER_SETS: |
---|
203 | sei = new SEIActiveParameterSets; |
---|
204 | xParseSEIActiveParameterSets((SEIActiveParameterSets&) *sei, payloadSize); |
---|
205 | break; |
---|
206 | case SEI::DECODING_UNIT_INFO: |
---|
207 | if (!sps) |
---|
208 | { |
---|
209 | printf ("Warning: Found Decoding unit SEI message, but no active SPS is available. Ignoring."); |
---|
210 | } |
---|
211 | else |
---|
212 | { |
---|
213 | sei = new SEIDecodingUnitInfo; |
---|
214 | xParseSEIDecodingUnitInfo((SEIDecodingUnitInfo&) *sei, payloadSize, sps); |
---|
215 | } |
---|
216 | break; |
---|
217 | case SEI::BUFFERING_PERIOD: |
---|
218 | if (!sps) |
---|
219 | { |
---|
220 | printf ("Warning: Found Buffering period SEI message, but no active SPS is available. Ignoring."); |
---|
221 | } |
---|
222 | else |
---|
223 | { |
---|
224 | sei = new SEIBufferingPeriod; |
---|
225 | xParseSEIBufferingPeriod((SEIBufferingPeriod&) *sei, payloadSize, sps); |
---|
226 | } |
---|
227 | break; |
---|
228 | case SEI::PICTURE_TIMING: |
---|
229 | if (!sps) |
---|
230 | { |
---|
231 | printf ("Warning: Found Picture timing SEI message, but no active SPS is available. Ignoring."); |
---|
232 | } |
---|
233 | else |
---|
234 | { |
---|
235 | sei = new SEIPictureTiming; |
---|
236 | xParseSEIPictureTiming((SEIPictureTiming&)*sei, payloadSize, sps); |
---|
237 | } |
---|
238 | break; |
---|
239 | case SEI::RECOVERY_POINT: |
---|
240 | sei = new SEIRecoveryPoint; |
---|
241 | xParseSEIRecoveryPoint((SEIRecoveryPoint&) *sei, payloadSize); |
---|
242 | break; |
---|
243 | case SEI::FRAME_PACKING: |
---|
244 | sei = new SEIFramePacking; |
---|
245 | xParseSEIFramePacking((SEIFramePacking&) *sei, payloadSize); |
---|
246 | break; |
---|
247 | case SEI::DISPLAY_ORIENTATION: |
---|
248 | sei = new SEIDisplayOrientation; |
---|
249 | xParseSEIDisplayOrientation((SEIDisplayOrientation&) *sei, payloadSize); |
---|
250 | break; |
---|
251 | case SEI::TEMPORAL_LEVEL0_INDEX: |
---|
252 | sei = new SEITemporalLevel0Index; |
---|
253 | xParseSEITemporalLevel0Index((SEITemporalLevel0Index&) *sei, payloadSize); |
---|
254 | break; |
---|
255 | case SEI::REGION_REFRESH_INFO: |
---|
256 | sei = new SEIGradualDecodingRefreshInfo; |
---|
257 | xParseSEIGradualDecodingRefreshInfo((SEIGradualDecodingRefreshInfo&) *sei, payloadSize); |
---|
258 | break; |
---|
259 | case SEI::TONE_MAPPING_INFO: |
---|
260 | sei = new SEIToneMappingInfo; |
---|
261 | xParseSEIToneMappingInfo((SEIToneMappingInfo&) *sei, payloadSize); |
---|
262 | break; |
---|
263 | case SEI::SOP_DESCRIPTION: |
---|
264 | sei = new SEISOPDescription; |
---|
265 | xParseSEISOPDescription((SEISOPDescription&) *sei, payloadSize); |
---|
266 | break; |
---|
267 | case SEI::SCALABLE_NESTING: |
---|
268 | sei = new SEIScalableNesting; |
---|
269 | #if LAYERS_NOT_PRESENT_SEI |
---|
270 | xParseSEIScalableNesting((SEIScalableNesting&) *sei, nalUnitType, payloadSize, vps, sps); |
---|
271 | #else |
---|
272 | xParseSEIScalableNesting((SEIScalableNesting&) *sei, nalUnitType, payloadSize, sps); |
---|
273 | #endif |
---|
274 | #if SVC_EXTENSION |
---|
275 | #if LAYERS_NOT_PRESENT_SEI |
---|
276 | case SEI::LAYERS_NOT_PRESENT: |
---|
277 | if (!vps) |
---|
278 | { |
---|
279 | printf ("Warning: Found Layers not present SEI message, but no active VPS is available. Ignoring."); |
---|
280 | } |
---|
281 | else |
---|
282 | { |
---|
283 | sei = new SEILayersNotPresent; |
---|
284 | xParseSEILayersNotPresent((SEILayersNotPresent&) *sei, payloadSize, vps); |
---|
285 | } |
---|
286 | break; |
---|
287 | #endif |
---|
288 | #if N0383_IL_CONSTRAINED_TILE_SETS_SEI |
---|
289 | case SEI::INTER_LAYER_CONSTRAINED_TILE_SETS: |
---|
290 | sei = new SEIInterLayerConstrainedTileSets; |
---|
291 | xParseSEIInterLayerConstrainedTileSets((SEIInterLayerConstrainedTileSets&) *sei, payloadSize); |
---|
292 | break; |
---|
293 | #endif |
---|
294 | #if SUB_BITSTREAM_PROPERTY_SEI |
---|
295 | case SEI::SUB_BITSTREAM_PROPERTY: |
---|
296 | sei = new SEISubBitstreamProperty; |
---|
297 | xParseSEISubBitstreamProperty((SEISubBitstreamProperty&) *sei); |
---|
298 | break; |
---|
299 | #endif |
---|
300 | #endif //SVC_EXTENSION |
---|
301 | break; |
---|
302 | default: |
---|
303 | for (UInt i = 0; i < payloadSize; i++) |
---|
304 | { |
---|
305 | UInt seiByte; |
---|
306 | READ_CODE (8, seiByte, "unknown prefix SEI payload byte"); |
---|
307 | } |
---|
308 | printf ("Unknown prefix SEI message (payloadType = %d) was found!\n", payloadType); |
---|
309 | } |
---|
310 | } |
---|
311 | else |
---|
312 | { |
---|
313 | switch (payloadType) |
---|
314 | { |
---|
315 | case SEI::USER_DATA_UNREGISTERED: |
---|
316 | sei = new SEIuserDataUnregistered; |
---|
317 | xParseSEIuserDataUnregistered((SEIuserDataUnregistered&) *sei, payloadSize); |
---|
318 | break; |
---|
319 | case SEI::DECODED_PICTURE_HASH: |
---|
320 | sei = new SEIDecodedPictureHash; |
---|
321 | xParseSEIDecodedPictureHash((SEIDecodedPictureHash&) *sei, payloadSize); |
---|
322 | break; |
---|
323 | default: |
---|
324 | for (UInt i = 0; i < payloadSize; i++) |
---|
325 | { |
---|
326 | UInt seiByte; |
---|
327 | READ_CODE (8, seiByte, "unknown suffix SEI payload byte"); |
---|
328 | } |
---|
329 | printf ("Unknown suffix SEI message (payloadType = %d) was found!\n", payloadType); |
---|
330 | } |
---|
331 | } |
---|
332 | if (sei != NULL) |
---|
333 | { |
---|
334 | seis.push_back(sei); |
---|
335 | } |
---|
336 | |
---|
337 | /* By definition the underlying bitstream terminates in a byte-aligned manner. |
---|
338 | * 1. Extract all bar the last MIN(bitsremaining,nine) bits as reserved_payload_extension_data |
---|
339 | * 2. Examine the final 8 bits to determine the payload_bit_equal_to_one marker |
---|
340 | * 3. Extract the remainingreserved_payload_extension_data bits. |
---|
341 | * |
---|
342 | * If there are fewer than 9 bits available, extract them. |
---|
343 | */ |
---|
344 | Int payloadBitsRemaining = getBitstream()->getNumBitsLeft(); |
---|
345 | if (payloadBitsRemaining) /* more_data_in_payload() */ |
---|
346 | { |
---|
347 | for (; payloadBitsRemaining > 9; payloadBitsRemaining--) |
---|
348 | { |
---|
349 | UInt reservedPayloadExtensionData; |
---|
350 | READ_CODE (1, reservedPayloadExtensionData, "reserved_payload_extension_data"); |
---|
351 | } |
---|
352 | |
---|
353 | /* 2 */ |
---|
354 | Int finalBits = getBitstream()->peekBits(payloadBitsRemaining); |
---|
355 | Int finalPayloadBits = 0; |
---|
356 | for (Int mask = 0xff; finalBits & (mask >> finalPayloadBits); finalPayloadBits++) |
---|
357 | { |
---|
358 | continue; |
---|
359 | } |
---|
360 | |
---|
361 | /* 3 */ |
---|
362 | for (; payloadBitsRemaining > 9 - finalPayloadBits; payloadBitsRemaining--) |
---|
363 | { |
---|
364 | UInt reservedPayloadExtensionData; |
---|
365 | READ_FLAG (reservedPayloadExtensionData, "reserved_payload_extension_data"); |
---|
366 | } |
---|
367 | |
---|
368 | UInt dummy; |
---|
369 | READ_FLAG (dummy, "payload_bit_equal_to_one"); payloadBitsRemaining--; |
---|
370 | while (payloadBitsRemaining) |
---|
371 | { |
---|
372 | READ_FLAG (dummy, "payload_bit_equal_to_zero"); payloadBitsRemaining--; |
---|
373 | } |
---|
374 | } |
---|
375 | |
---|
376 | /* restore primary bitstream for sei_message */ |
---|
377 | getBitstream()->deleteFifo(); |
---|
378 | delete getBitstream(); |
---|
379 | setBitstream(bs); |
---|
380 | } |
---|
381 | |
---|
382 | /** |
---|
383 | * parse bitstream bs and unpack a user_data_unregistered SEI message |
---|
384 | * of payloasSize bytes into sei. |
---|
385 | */ |
---|
386 | Void SEIReader::xParseSEIuserDataUnregistered(SEIuserDataUnregistered &sei, UInt payloadSize) |
---|
387 | { |
---|
388 | assert(payloadSize >= 16); |
---|
389 | UInt val; |
---|
390 | |
---|
391 | for (UInt i = 0; i < 16; i++) |
---|
392 | { |
---|
393 | READ_CODE (8, val, "uuid_iso_iec_11578"); |
---|
394 | sei.uuid_iso_iec_11578[i] = val; |
---|
395 | } |
---|
396 | |
---|
397 | sei.userDataLength = payloadSize - 16; |
---|
398 | if (!sei.userDataLength) |
---|
399 | { |
---|
400 | sei.userData = 0; |
---|
401 | return; |
---|
402 | } |
---|
403 | |
---|
404 | sei.userData = new UChar[sei.userDataLength]; |
---|
405 | for (UInt i = 0; i < sei.userDataLength; i++) |
---|
406 | { |
---|
407 | READ_CODE (8, val, "user_data" ); |
---|
408 | sei.userData[i] = val; |
---|
409 | } |
---|
410 | } |
---|
411 | |
---|
412 | /** |
---|
413 | * parse bitstream bs and unpack a decoded picture hash SEI message |
---|
414 | * of payloadSize bytes into sei. |
---|
415 | */ |
---|
416 | Void SEIReader::xParseSEIDecodedPictureHash(SEIDecodedPictureHash& sei, UInt /*payloadSize*/) |
---|
417 | { |
---|
418 | UInt val; |
---|
419 | READ_CODE (8, val, "hash_type"); |
---|
420 | sei.method = static_cast<SEIDecodedPictureHash::Method>(val); |
---|
421 | for(Int yuvIdx = 0; yuvIdx < 3; yuvIdx++) |
---|
422 | { |
---|
423 | if(SEIDecodedPictureHash::MD5 == sei.method) |
---|
424 | { |
---|
425 | for (UInt i = 0; i < 16; i++) |
---|
426 | { |
---|
427 | READ_CODE(8, val, "picture_md5"); |
---|
428 | sei.digest[yuvIdx][i] = val; |
---|
429 | } |
---|
430 | } |
---|
431 | else if(SEIDecodedPictureHash::CRC == sei.method) |
---|
432 | { |
---|
433 | READ_CODE(16, val, "picture_crc"); |
---|
434 | sei.digest[yuvIdx][0] = val >> 8 & 0xFF; |
---|
435 | sei.digest[yuvIdx][1] = val & 0xFF; |
---|
436 | } |
---|
437 | else if(SEIDecodedPictureHash::CHECKSUM == sei.method) |
---|
438 | { |
---|
439 | READ_CODE(32, val, "picture_checksum"); |
---|
440 | sei.digest[yuvIdx][0] = (val>>24) & 0xff; |
---|
441 | sei.digest[yuvIdx][1] = (val>>16) & 0xff; |
---|
442 | sei.digest[yuvIdx][2] = (val>>8) & 0xff; |
---|
443 | sei.digest[yuvIdx][3] = val & 0xff; |
---|
444 | } |
---|
445 | } |
---|
446 | } |
---|
447 | Void SEIReader::xParseSEIActiveParameterSets(SEIActiveParameterSets& sei, UInt /*payloadSize*/) |
---|
448 | { |
---|
449 | UInt val; |
---|
450 | READ_CODE(4, val, "active_vps_id"); sei.activeVPSId = val; |
---|
451 | READ_FLAG( val, "full_random_access_flag"); sei.m_fullRandomAccessFlag = val ? true : false; |
---|
452 | READ_FLAG( val, "no_param_set_update_flag"); sei.m_noParamSetUpdateFlag = val ? true : false; |
---|
453 | READ_UVLC( val, "num_sps_ids_minus1"); sei.numSpsIdsMinus1 = val; |
---|
454 | |
---|
455 | sei.activeSeqParamSetId.resize(sei.numSpsIdsMinus1 + 1); |
---|
456 | for (Int i=0; i < (sei.numSpsIdsMinus1 + 1); i++) |
---|
457 | { |
---|
458 | READ_UVLC(val, "active_seq_param_set_id"); sei.activeSeqParamSetId[i] = val; |
---|
459 | } |
---|
460 | |
---|
461 | UInt uibits = m_pcBitstream->getNumBitsUntilByteAligned(); |
---|
462 | |
---|
463 | while(uibits--) |
---|
464 | { |
---|
465 | READ_FLAG(val, "alignment_bit"); |
---|
466 | } |
---|
467 | } |
---|
468 | |
---|
469 | Void SEIReader::xParseSEIDecodingUnitInfo(SEIDecodingUnitInfo& sei, UInt /*payloadSize*/, TComSPS *sps) |
---|
470 | { |
---|
471 | UInt val; |
---|
472 | READ_UVLC(val, "decoding_unit_idx"); |
---|
473 | sei.m_decodingUnitIdx = val; |
---|
474 | |
---|
475 | TComVUI *vui = sps->getVuiParameters(); |
---|
476 | if(vui->getHrdParameters()->getSubPicCpbParamsInPicTimingSEIFlag()) |
---|
477 | { |
---|
478 | READ_CODE( ( vui->getHrdParameters()->getDuCpbRemovalDelayLengthMinus1() + 1 ), val, "du_spt_cpb_removal_delay"); |
---|
479 | sei.m_duSptCpbRemovalDelay = val; |
---|
480 | } |
---|
481 | else |
---|
482 | { |
---|
483 | sei.m_duSptCpbRemovalDelay = 0; |
---|
484 | } |
---|
485 | READ_FLAG( val, "dpb_output_du_delay_present_flag"); sei.m_dpbOutputDuDelayPresentFlag = val ? true : false; |
---|
486 | if(sei.m_dpbOutputDuDelayPresentFlag) |
---|
487 | { |
---|
488 | READ_CODE(vui->getHrdParameters()->getDpbOutputDelayDuLengthMinus1() + 1, val, "pic_spt_dpb_output_du_delay"); |
---|
489 | sei.m_picSptDpbOutputDuDelay = val; |
---|
490 | } |
---|
491 | xParseByteAlign(); |
---|
492 | } |
---|
493 | |
---|
494 | Void SEIReader::xParseSEIBufferingPeriod(SEIBufferingPeriod& sei, UInt /*payloadSize*/, TComSPS *sps) |
---|
495 | { |
---|
496 | Int i, nalOrVcl; |
---|
497 | UInt code; |
---|
498 | |
---|
499 | TComVUI *pVUI = sps->getVuiParameters(); |
---|
500 | TComHRD *pHRD = pVUI->getHrdParameters(); |
---|
501 | |
---|
502 | READ_UVLC( code, "bp_seq_parameter_set_id" ); sei.m_bpSeqParameterSetId = code; |
---|
503 | if( !pHRD->getSubPicCpbParamsPresentFlag() ) |
---|
504 | { |
---|
505 | READ_FLAG( code, "irap_cpb_params_present_flag" ); sei.m_rapCpbParamsPresentFlag = code; |
---|
506 | } |
---|
507 | if( sei.m_rapCpbParamsPresentFlag ) |
---|
508 | { |
---|
509 | READ_CODE( pHRD->getCpbRemovalDelayLengthMinus1() + 1, code, "cpb_delay_offset" ); sei.m_cpbDelayOffset = code; |
---|
510 | READ_CODE( pHRD->getDpbOutputDelayLengthMinus1() + 1, code, "dpb_delay_offset" ); sei.m_dpbDelayOffset = code; |
---|
511 | } |
---|
512 | //read splicing flag and cpb_removal_delay_delta |
---|
513 | READ_FLAG( code, "concatenation_flag"); |
---|
514 | sei.m_concatenationFlag = code; |
---|
515 | READ_CODE( ( pHRD->getCpbRemovalDelayLengthMinus1() + 1 ), code, "au_cpb_removal_delay_delta_minus1" ); |
---|
516 | sei.m_auCpbRemovalDelayDelta = code + 1; |
---|
517 | for( nalOrVcl = 0; nalOrVcl < 2; nalOrVcl ++ ) |
---|
518 | { |
---|
519 | if( ( ( nalOrVcl == 0 ) && ( pHRD->getNalHrdParametersPresentFlag() ) ) || |
---|
520 | ( ( nalOrVcl == 1 ) && ( pHRD->getVclHrdParametersPresentFlag() ) ) ) |
---|
521 | { |
---|
522 | for( i = 0; i < ( pHRD->getCpbCntMinus1( 0 ) + 1 ); i ++ ) |
---|
523 | { |
---|
524 | READ_CODE( ( pHRD->getInitialCpbRemovalDelayLengthMinus1() + 1 ) , code, "initial_cpb_removal_delay" ); |
---|
525 | sei.m_initialCpbRemovalDelay[i][nalOrVcl] = code; |
---|
526 | READ_CODE( ( pHRD->getInitialCpbRemovalDelayLengthMinus1() + 1 ) , code, "initial_cpb_removal_delay_offset" ); |
---|
527 | sei.m_initialCpbRemovalDelayOffset[i][nalOrVcl] = code; |
---|
528 | if( pHRD->getSubPicCpbParamsPresentFlag() || sei.m_rapCpbParamsPresentFlag ) |
---|
529 | { |
---|
530 | READ_CODE( ( pHRD->getInitialCpbRemovalDelayLengthMinus1() + 1 ) , code, "initial_alt_cpb_removal_delay" ); |
---|
531 | sei.m_initialAltCpbRemovalDelay[i][nalOrVcl] = code; |
---|
532 | READ_CODE( ( pHRD->getInitialCpbRemovalDelayLengthMinus1() + 1 ) , code, "initial_alt_cpb_removal_delay_offset" ); |
---|
533 | sei.m_initialAltCpbRemovalDelayOffset[i][nalOrVcl] = code; |
---|
534 | } |
---|
535 | } |
---|
536 | } |
---|
537 | } |
---|
538 | xParseByteAlign(); |
---|
539 | } |
---|
540 | Void SEIReader::xParseSEIPictureTiming(SEIPictureTiming& sei, UInt /*payloadSize*/, TComSPS *sps) |
---|
541 | { |
---|
542 | Int i; |
---|
543 | UInt code; |
---|
544 | |
---|
545 | TComVUI *vui = sps->getVuiParameters(); |
---|
546 | TComHRD *hrd = vui->getHrdParameters(); |
---|
547 | |
---|
548 | if( vui->getFrameFieldInfoPresentFlag() ) |
---|
549 | { |
---|
550 | READ_CODE( 4, code, "pic_struct" ); sei.m_picStruct = code; |
---|
551 | READ_CODE( 2, code, "source_scan_type" ); sei.m_sourceScanType = code; |
---|
552 | READ_FLAG( code, "duplicate_flag" ); sei.m_duplicateFlag = ( code == 1 ? true : false ); |
---|
553 | } |
---|
554 | |
---|
555 | if( hrd->getCpbDpbDelaysPresentFlag()) |
---|
556 | { |
---|
557 | READ_CODE( ( hrd->getCpbRemovalDelayLengthMinus1() + 1 ), code, "au_cpb_removal_delay_minus1" ); |
---|
558 | sei.m_auCpbRemovalDelay = code + 1; |
---|
559 | READ_CODE( ( hrd->getDpbOutputDelayLengthMinus1() + 1 ), code, "pic_dpb_output_delay" ); |
---|
560 | sei.m_picDpbOutputDelay = code; |
---|
561 | |
---|
562 | if(hrd->getSubPicCpbParamsPresentFlag()) |
---|
563 | { |
---|
564 | READ_CODE(hrd->getDpbOutputDelayDuLengthMinus1()+1, code, "pic_dpb_output_du_delay" ); |
---|
565 | sei.m_picDpbOutputDuDelay = code; |
---|
566 | } |
---|
567 | if( hrd->getSubPicCpbParamsPresentFlag() && hrd->getSubPicCpbParamsInPicTimingSEIFlag() ) |
---|
568 | { |
---|
569 | READ_UVLC( code, "num_decoding_units_minus1"); |
---|
570 | sei.m_numDecodingUnitsMinus1 = code; |
---|
571 | READ_FLAG( code, "du_common_cpb_removal_delay_flag" ); |
---|
572 | sei.m_duCommonCpbRemovalDelayFlag = code; |
---|
573 | if( sei.m_duCommonCpbRemovalDelayFlag ) |
---|
574 | { |
---|
575 | READ_CODE( ( hrd->getDuCpbRemovalDelayLengthMinus1() + 1 ), code, "du_common_cpb_removal_delay_minus1" ); |
---|
576 | sei.m_duCommonCpbRemovalDelayMinus1 = code; |
---|
577 | } |
---|
578 | if( sei.m_numNalusInDuMinus1 != NULL ) |
---|
579 | { |
---|
580 | delete sei.m_numNalusInDuMinus1; |
---|
581 | } |
---|
582 | sei.m_numNalusInDuMinus1 = new UInt[ ( sei.m_numDecodingUnitsMinus1 + 1 ) ]; |
---|
583 | if( sei.m_duCpbRemovalDelayMinus1 != NULL ) |
---|
584 | { |
---|
585 | delete sei.m_duCpbRemovalDelayMinus1; |
---|
586 | } |
---|
587 | sei.m_duCpbRemovalDelayMinus1 = new UInt[ ( sei.m_numDecodingUnitsMinus1 + 1 ) ]; |
---|
588 | |
---|
589 | for( i = 0; i <= sei.m_numDecodingUnitsMinus1; i ++ ) |
---|
590 | { |
---|
591 | READ_UVLC( code, "num_nalus_in_du_minus1"); |
---|
592 | sei.m_numNalusInDuMinus1[ i ] = code; |
---|
593 | if( ( !sei.m_duCommonCpbRemovalDelayFlag ) && ( i < sei.m_numDecodingUnitsMinus1 ) ) |
---|
594 | { |
---|
595 | READ_CODE( ( hrd->getDuCpbRemovalDelayLengthMinus1() + 1 ), code, "du_cpb_removal_delay_minus1" ); |
---|
596 | sei.m_duCpbRemovalDelayMinus1[ i ] = code; |
---|
597 | } |
---|
598 | } |
---|
599 | } |
---|
600 | } |
---|
601 | xParseByteAlign(); |
---|
602 | } |
---|
603 | Void SEIReader::xParseSEIRecoveryPoint(SEIRecoveryPoint& sei, UInt /*payloadSize*/) |
---|
604 | { |
---|
605 | Int iCode; |
---|
606 | UInt uiCode; |
---|
607 | READ_SVLC( iCode, "recovery_poc_cnt" ); sei.m_recoveryPocCnt = iCode; |
---|
608 | READ_FLAG( uiCode, "exact_matching_flag" ); sei.m_exactMatchingFlag = uiCode; |
---|
609 | READ_FLAG( uiCode, "broken_link_flag" ); sei.m_brokenLinkFlag = uiCode; |
---|
610 | xParseByteAlign(); |
---|
611 | } |
---|
612 | Void SEIReader::xParseSEIFramePacking(SEIFramePacking& sei, UInt /*payloadSize*/) |
---|
613 | { |
---|
614 | UInt val; |
---|
615 | READ_UVLC( val, "frame_packing_arrangement_id" ); sei.m_arrangementId = val; |
---|
616 | READ_FLAG( val, "frame_packing_arrangement_cancel_flag" ); sei.m_arrangementCancelFlag = val; |
---|
617 | |
---|
618 | if ( !sei.m_arrangementCancelFlag ) |
---|
619 | { |
---|
620 | READ_CODE( 7, val, "frame_packing_arrangement_type" ); sei.m_arrangementType = val; |
---|
621 | assert((sei.m_arrangementType > 2) && (sei.m_arrangementType < 6) ); |
---|
622 | READ_FLAG( val, "quincunx_sampling_flag" ); sei.m_quincunxSamplingFlag = val; |
---|
623 | |
---|
624 | READ_CODE( 6, val, "content_interpretation_type" ); sei.m_contentInterpretationType = val; |
---|
625 | READ_FLAG( val, "spatial_flipping_flag" ); sei.m_spatialFlippingFlag = val; |
---|
626 | READ_FLAG( val, "frame0_flipped_flag" ); sei.m_frame0FlippedFlag = val; |
---|
627 | READ_FLAG( val, "field_views_flag" ); sei.m_fieldViewsFlag = val; |
---|
628 | READ_FLAG( val, "current_frame_is_frame0_flag" ); sei.m_currentFrameIsFrame0Flag = val; |
---|
629 | READ_FLAG( val, "frame0_self_contained_flag" ); sei.m_frame0SelfContainedFlag = val; |
---|
630 | READ_FLAG( val, "frame1_self_contained_flag" ); sei.m_frame1SelfContainedFlag = val; |
---|
631 | |
---|
632 | if ( sei.m_quincunxSamplingFlag == 0 && sei.m_arrangementType != 5) |
---|
633 | { |
---|
634 | READ_CODE( 4, val, "frame0_grid_position_x" ); sei.m_frame0GridPositionX = val; |
---|
635 | READ_CODE( 4, val, "frame0_grid_position_y" ); sei.m_frame0GridPositionY = val; |
---|
636 | READ_CODE( 4, val, "frame1_grid_position_x" ); sei.m_frame1GridPositionX = val; |
---|
637 | READ_CODE( 4, val, "frame1_grid_position_y" ); sei.m_frame1GridPositionY = val; |
---|
638 | } |
---|
639 | |
---|
640 | READ_CODE( 8, val, "frame_packing_arrangement_reserved_byte" ); sei.m_arrangementReservedByte = val; |
---|
641 | READ_FLAG( val, "frame_packing_arrangement_persistence_flag" ); sei.m_arrangementPersistenceFlag = val ? true : false; |
---|
642 | } |
---|
643 | READ_FLAG( val, "upsampled_aspect_ratio" ); sei.m_upsampledAspectRatio = val; |
---|
644 | |
---|
645 | xParseByteAlign(); |
---|
646 | } |
---|
647 | |
---|
648 | Void SEIReader::xParseSEIDisplayOrientation(SEIDisplayOrientation& sei, UInt /*payloadSize*/) |
---|
649 | { |
---|
650 | UInt val; |
---|
651 | READ_FLAG( val, "display_orientation_cancel_flag" ); sei.cancelFlag = val; |
---|
652 | if( !sei.cancelFlag ) |
---|
653 | { |
---|
654 | READ_FLAG( val, "hor_flip" ); sei.horFlip = val; |
---|
655 | READ_FLAG( val, "ver_flip" ); sei.verFlip = val; |
---|
656 | READ_CODE( 16, val, "anticlockwise_rotation" ); sei.anticlockwiseRotation = val; |
---|
657 | READ_FLAG( val, "display_orientation_persistence_flag" ); sei.persistenceFlag = val; |
---|
658 | } |
---|
659 | xParseByteAlign(); |
---|
660 | } |
---|
661 | |
---|
662 | Void SEIReader::xParseSEITemporalLevel0Index(SEITemporalLevel0Index& sei, UInt /*payloadSize*/) |
---|
663 | { |
---|
664 | UInt val; |
---|
665 | READ_CODE ( 8, val, "tl0_idx" ); sei.tl0Idx = val; |
---|
666 | READ_CODE ( 8, val, "rap_idx" ); sei.rapIdx = val; |
---|
667 | xParseByteAlign(); |
---|
668 | } |
---|
669 | |
---|
670 | Void SEIReader::xParseSEIGradualDecodingRefreshInfo(SEIGradualDecodingRefreshInfo& sei, UInt /*payloadSize*/) |
---|
671 | { |
---|
672 | UInt val; |
---|
673 | READ_FLAG( val, "gdr_foreground_flag" ); sei.m_gdrForegroundFlag = val ? 1 : 0; |
---|
674 | xParseByteAlign(); |
---|
675 | } |
---|
676 | |
---|
677 | Void SEIReader::xParseSEIToneMappingInfo(SEIToneMappingInfo& sei, UInt /*payloadSize*/) |
---|
678 | { |
---|
679 | Int i; |
---|
680 | UInt val; |
---|
681 | READ_UVLC( val, "tone_map_id" ); sei.m_toneMapId = val; |
---|
682 | READ_FLAG( val, "tone_map_cancel_flag" ); sei.m_toneMapCancelFlag = val; |
---|
683 | |
---|
684 | if ( !sei.m_toneMapCancelFlag ) |
---|
685 | { |
---|
686 | READ_FLAG( val, "tone_map_persistence_flag" ); sei.m_toneMapPersistenceFlag = val; |
---|
687 | READ_CODE( 8, val, "coded_data_bit_depth" ); sei.m_codedDataBitDepth = val; |
---|
688 | READ_CODE( 8, val, "target_bit_depth" ); sei.m_targetBitDepth = val; |
---|
689 | READ_UVLC( val, "model_id" ); sei.m_modelId = val; |
---|
690 | switch(sei.m_modelId) |
---|
691 | { |
---|
692 | case 0: |
---|
693 | { |
---|
694 | READ_CODE( 32, val, "min_value" ); sei.m_minValue = val; |
---|
695 | READ_CODE( 32, val, "max_value" ); sei.m_maxValue = val; |
---|
696 | break; |
---|
697 | } |
---|
698 | case 1: |
---|
699 | { |
---|
700 | READ_CODE( 32, val, "sigmoid_midpoint" ); sei.m_sigmoidMidpoint = val; |
---|
701 | READ_CODE( 32, val, "sigmoid_width" ); sei.m_sigmoidWidth = val; |
---|
702 | break; |
---|
703 | } |
---|
704 | case 2: |
---|
705 | { |
---|
706 | UInt num = 1u << sei.m_targetBitDepth; |
---|
707 | sei.m_startOfCodedInterval.resize(num+1); |
---|
708 | for(i = 0; i < num; i++) |
---|
709 | { |
---|
710 | READ_CODE( ((( sei.m_codedDataBitDepth + 7 ) >> 3 ) << 3), val, "start_of_coded_interval" ); |
---|
711 | sei.m_startOfCodedInterval[i] = val; |
---|
712 | } |
---|
713 | sei.m_startOfCodedInterval[num] = 1u << sei.m_codedDataBitDepth; |
---|
714 | break; |
---|
715 | } |
---|
716 | case 3: |
---|
717 | { |
---|
718 | READ_CODE( 16, val, "num_pivots" ); sei.m_numPivots = val; |
---|
719 | sei.m_codedPivotValue.resize(sei.m_numPivots); |
---|
720 | sei.m_targetPivotValue.resize(sei.m_numPivots); |
---|
721 | for(i = 0; i < sei.m_numPivots; i++ ) |
---|
722 | { |
---|
723 | READ_CODE( ((( sei.m_codedDataBitDepth + 7 ) >> 3 ) << 3), val, "coded_pivot_value" ); |
---|
724 | sei.m_codedPivotValue[i] = val; |
---|
725 | READ_CODE( ((( sei.m_targetBitDepth + 7 ) >> 3 ) << 3), val, "target_pivot_value" ); |
---|
726 | sei.m_targetPivotValue[i] = val; |
---|
727 | } |
---|
728 | break; |
---|
729 | } |
---|
730 | case 4: |
---|
731 | { |
---|
732 | READ_CODE( 8, val, "camera_iso_speed_idc" ); sei.m_cameraIsoSpeedValue = val; |
---|
733 | if( sei.m_cameraIsoSpeedValue == 255) //Extended_ISO |
---|
734 | { |
---|
735 | READ_CODE( 32, val, "camera_iso_speed_value" ); sei.m_cameraIsoSpeedValue = val; |
---|
736 | } |
---|
737 | READ_FLAG( val, "exposure_compensation_value_sign_flag" ); sei.m_exposureCompensationValueSignFlag = val; |
---|
738 | READ_CODE( 16, val, "exposure_compensation_value_numerator" ); sei.m_exposureCompensationValueNumerator = val; |
---|
739 | READ_CODE( 16, val, "exposure_compensation_value_denom_idc" ); sei.m_exposureCompensationValueDenomIdc = val; |
---|
740 | READ_CODE( 32, val, "ref_screen_luminance_white" ); sei.m_refScreenLuminanceWhite = val; |
---|
741 | READ_CODE( 32, val, "extended_range_white_level" ); sei.m_extendedRangeWhiteLevel = val; |
---|
742 | READ_CODE( 16, val, "nominal_black_level_luma_code_value" ); sei.m_nominalBlackLevelLumaCodeValue = val; |
---|
743 | READ_CODE( 16, val, "nominal_white_level_luma_code_value" ); sei.m_nominalWhiteLevelLumaCodeValue= val; |
---|
744 | READ_CODE( 16, val, "extended_white_level_luma_code_value" ); sei.m_extendedWhiteLevelLumaCodeValue = val; |
---|
745 | break; |
---|
746 | } |
---|
747 | default: |
---|
748 | { |
---|
749 | assert(!"Undefined SEIToneMapModelId"); |
---|
750 | break; |
---|
751 | } |
---|
752 | }//switch model id |
---|
753 | }// if(!sei.m_toneMapCancelFlag) |
---|
754 | |
---|
755 | xParseByteAlign(); |
---|
756 | } |
---|
757 | |
---|
758 | Void SEIReader::xParseSEISOPDescription(SEISOPDescription &sei, UInt payloadSize) |
---|
759 | { |
---|
760 | Int iCode; |
---|
761 | UInt uiCode; |
---|
762 | |
---|
763 | READ_UVLC( uiCode, "sop_seq_parameter_set_id" ); sei.m_sopSeqParameterSetId = uiCode; |
---|
764 | READ_UVLC( uiCode, "num_pics_in_sop_minus1" ); sei.m_numPicsInSopMinus1 = uiCode; |
---|
765 | for (UInt i = 0; i <= sei.m_numPicsInSopMinus1; i++) |
---|
766 | { |
---|
767 | READ_CODE( 6, uiCode, "sop_desc_vcl_nalu_type" ); sei.m_sopDescVclNaluType[i] = uiCode; |
---|
768 | READ_CODE( 3, sei.m_sopDescTemporalId[i], "sop_desc_temporal_id" ); sei.m_sopDescTemporalId[i] = uiCode; |
---|
769 | if (sei.m_sopDescVclNaluType[i] != NAL_UNIT_CODED_SLICE_IDR_W_RADL && sei.m_sopDescVclNaluType[i] != NAL_UNIT_CODED_SLICE_IDR_N_LP) |
---|
770 | { |
---|
771 | READ_UVLC( sei.m_sopDescStRpsIdx[i], "sop_desc_st_rps_idx" ); sei.m_sopDescStRpsIdx[i] = uiCode; |
---|
772 | } |
---|
773 | if (i > 0) |
---|
774 | { |
---|
775 | READ_SVLC( iCode, "sop_desc_poc_delta" ); sei.m_sopDescPocDelta[i] = iCode; |
---|
776 | } |
---|
777 | } |
---|
778 | |
---|
779 | xParseByteAlign(); |
---|
780 | } |
---|
781 | |
---|
782 | #if LAYERS_NOT_PRESENT_SEI |
---|
783 | Void SEIReader::xParseSEIScalableNesting(SEIScalableNesting& sei, const NalUnitType nalUnitType, UInt payloadSize, TComVPS *vps, TComSPS *sps) |
---|
784 | #else |
---|
785 | Void SEIReader::xParseSEIScalableNesting(SEIScalableNesting& sei, const NalUnitType nalUnitType, UInt payloadSize, TComSPS *sps) |
---|
786 | #endif |
---|
787 | { |
---|
788 | UInt uiCode; |
---|
789 | SEIMessages seis; |
---|
790 | |
---|
791 | READ_FLAG( uiCode, "bitstream_subset_flag" ); sei.m_bitStreamSubsetFlag = uiCode; |
---|
792 | READ_FLAG( uiCode, "nesting_op_flag" ); sei.m_nestingOpFlag = uiCode; |
---|
793 | if (sei.m_nestingOpFlag) |
---|
794 | { |
---|
795 | READ_FLAG( uiCode, "default_op_flag" ); sei.m_defaultOpFlag = uiCode; |
---|
796 | READ_UVLC( uiCode, "nesting_num_ops_minus1" ); sei.m_nestingNumOpsMinus1 = uiCode; |
---|
797 | for (UInt i = sei.m_defaultOpFlag; i <= sei.m_nestingNumOpsMinus1; i++) |
---|
798 | { |
---|
799 | READ_CODE( 3, uiCode, "nesting_max_temporal_id_plus1" ); sei.m_nestingMaxTemporalIdPlus1[i] = uiCode; |
---|
800 | READ_UVLC( uiCode, "nesting_op_idx" ); sei.m_nestingOpIdx[i] = uiCode; |
---|
801 | } |
---|
802 | } |
---|
803 | else |
---|
804 | { |
---|
805 | READ_FLAG( uiCode, "all_layers_flag" ); sei.m_allLayersFlag = uiCode; |
---|
806 | if (!sei.m_allLayersFlag) |
---|
807 | { |
---|
808 | READ_CODE( 3, uiCode, "nesting_no_op_max_temporal_id_plus1" ); sei.m_nestingNoOpMaxTemporalIdPlus1 = uiCode; |
---|
809 | READ_UVLC( uiCode, "nesting_num_layers_minus1" ); sei.m_nestingNumLayersMinus1 = uiCode; |
---|
810 | for (UInt i = 0; i <= sei.m_nestingNumLayersMinus1; i++) |
---|
811 | { |
---|
812 | READ_CODE( 6, uiCode, "nesting_layer_id" ); sei.m_nestingLayerId[i] = uiCode; |
---|
813 | } |
---|
814 | } |
---|
815 | } |
---|
816 | |
---|
817 | // byte alignment |
---|
818 | while ( m_pcBitstream->getNumBitsRead() % 8 != 0 ) |
---|
819 | { |
---|
820 | UInt code; |
---|
821 | READ_FLAG( code, "nesting_zero_bit" ); |
---|
822 | } |
---|
823 | |
---|
824 | sei.m_callerOwnsSEIs = false; |
---|
825 | |
---|
826 | // read nested SEI messages |
---|
827 | do { |
---|
828 | #if LAYERS_NOT_PRESENT_SEI |
---|
829 | xReadSEImessage(sei.m_nestedSEIs, nalUnitType, vps, sps); |
---|
830 | #else |
---|
831 | xReadSEImessage(sei.m_nestedSEIs, nalUnitType, sps); |
---|
832 | #endif |
---|
833 | } while (m_pcBitstream->getNumBitsLeft() > 8); |
---|
834 | |
---|
835 | } |
---|
836 | |
---|
837 | Void SEIReader::xParseByteAlign() |
---|
838 | { |
---|
839 | UInt code; |
---|
840 | if( m_pcBitstream->getNumBitsRead() % 8 != 0 ) |
---|
841 | { |
---|
842 | READ_FLAG( code, "bit_equal_to_one" ); assert( code == 1 ); |
---|
843 | } |
---|
844 | while( m_pcBitstream->getNumBitsRead() % 8 != 0 ) |
---|
845 | { |
---|
846 | READ_FLAG( code, "bit_equal_to_zero" ); assert( code == 0 ); |
---|
847 | } |
---|
848 | } |
---|
849 | |
---|
850 | #if SVC_EXTENSION |
---|
851 | #if LAYERS_NOT_PRESENT_SEI |
---|
852 | Void SEIReader::xParseSEILayersNotPresent(SEILayersNotPresent &sei, UInt payloadSize, TComVPS *vps) |
---|
853 | { |
---|
854 | UInt uiCode; |
---|
855 | UInt i = 0; |
---|
856 | |
---|
857 | READ_UVLC( uiCode, "lp_sei_active_vps_id" ); sei.m_activeVpsId = uiCode; |
---|
858 | assert(vps->getVPSId() == sei.m_activeVpsId); |
---|
859 | sei.m_vpsMaxLayers = vps->getMaxLayers(); |
---|
860 | for (; i < sei.m_vpsMaxLayers; i++) |
---|
861 | { |
---|
862 | READ_FLAG( uiCode, "layer_not_present_flag" ); sei.m_layerNotPresentFlag[i] = uiCode ? true : false; |
---|
863 | } |
---|
864 | for (; i < MAX_LAYERS; i++) |
---|
865 | { |
---|
866 | sei.m_layerNotPresentFlag[i] = false; |
---|
867 | } |
---|
868 | xParseByteAlign(); |
---|
869 | } |
---|
870 | #endif |
---|
871 | #if N0383_IL_CONSTRAINED_TILE_SETS_SEI |
---|
872 | Void SEIReader::xParseSEIInterLayerConstrainedTileSets (SEIInterLayerConstrainedTileSets &sei, UInt payloadSize) |
---|
873 | { |
---|
874 | UInt uiCode; |
---|
875 | |
---|
876 | READ_FLAG( uiCode, "il_all_tiles_exact_sample_value_match_flag" ); sei.m_ilAllTilesExactSampleValueMatchFlag = uiCode; |
---|
877 | READ_FLAG( uiCode, "il_one_tile_per_tile_set_flag" ); sei.m_ilOneTilePerTileSetFlag = uiCode; |
---|
878 | if( !sei.m_ilOneTilePerTileSetFlag ) |
---|
879 | { |
---|
880 | READ_UVLC( uiCode, "il_num_sets_in_message_minus1" ); sei.m_ilNumSetsInMessageMinus1 = uiCode; |
---|
881 | if( sei.m_ilNumSetsInMessageMinus1 ) |
---|
882 | { |
---|
883 | READ_FLAG( uiCode, "skipped_tile_set_present_flag" ); sei.m_skippedTileSetPresentFlag = uiCode; |
---|
884 | } |
---|
885 | else |
---|
886 | { |
---|
887 | sei.m_skippedTileSetPresentFlag = false; |
---|
888 | } |
---|
889 | UInt numSignificantSets = sei.m_ilNumSetsInMessageMinus1 - (sei.m_skippedTileSetPresentFlag ? 1 : 0) + 1; |
---|
890 | for( UInt i = 0; i < numSignificantSets; i++ ) |
---|
891 | { |
---|
892 | READ_UVLC( uiCode, "ilcts_id" ); sei.m_ilctsId[i] = uiCode; |
---|
893 | READ_UVLC( uiCode, "il_num_tile_rects_in_set_minus1" ) ;sei.m_ilNumTileRectsInSetMinus1[i] = uiCode; |
---|
894 | for( UInt j = 0; j <= sei.m_ilNumTileRectsInSetMinus1[i]; j++ ) |
---|
895 | { |
---|
896 | READ_UVLC( uiCode, "il_top_left_tile_index" ); sei.m_ilTopLeftTileIndex[i][j] = uiCode; |
---|
897 | READ_UVLC( uiCode, "il_bottom_right_tile_index" ); sei.m_ilBottomRightTileIndex[i][j] = uiCode; |
---|
898 | } |
---|
899 | READ_CODE( 2, uiCode, "ilc_idc" ); sei.m_ilcIdc[i] = uiCode; |
---|
900 | if( sei.m_ilAllTilesExactSampleValueMatchFlag ) |
---|
901 | { |
---|
902 | READ_FLAG( uiCode, "il_exact_sample_value_match_flag" ); sei.m_ilExactSampleValueMatchFlag[i] = uiCode; |
---|
903 | } |
---|
904 | } |
---|
905 | } |
---|
906 | else |
---|
907 | { |
---|
908 | READ_CODE( 2, uiCode, "all_tiles_ilc_idc" ); sei.m_allTilesIlcIdc = uiCode; |
---|
909 | } |
---|
910 | |
---|
911 | xParseByteAlign(); |
---|
912 | } |
---|
913 | #endif |
---|
914 | #if SUB_BITSTREAM_PROPERTY_SEI |
---|
915 | Void SEIReader::xParseSEISubBitstreamProperty(SEISubBitstreamProperty &sei) |
---|
916 | { |
---|
917 | UInt uiCode; |
---|
918 | READ_CODE( 4, uiCode, "active_vps_id" ); sei.m_activeVpsId = uiCode; |
---|
919 | READ_UVLC( uiCode, "num_additional_sub_streams_minus1" ); sei.m_numAdditionalSubStreams = uiCode + 1; |
---|
920 | |
---|
921 | for( Int i = 0; i < sei.m_numAdditionalSubStreams; i++ ) |
---|
922 | { |
---|
923 | READ_CODE( 2, uiCode, "sub_bitstream_mode[i]" ); sei.m_subBitstreamMode[i] = uiCode; |
---|
924 | READ_UVLC( uiCode, "output_layer_set_idx_to_vps[i]" ); sei.m_outputLayerSetIdxToVps[i] = uiCode; |
---|
925 | READ_CODE( 3, uiCode, "highest_sub_layer_id[i]" ); sei.m_highestSublayerId[i] = uiCode; |
---|
926 | READ_CODE( 16, uiCode, "avg_bit_rate[i]" ); sei.m_avgBitRate[i] = uiCode; |
---|
927 | READ_CODE( 16, uiCode, "max_bit_rate[i]" ); sei.m_maxBitRate[i] = uiCode; |
---|
928 | } |
---|
929 | xParseByteAlign(); |
---|
930 | } |
---|
931 | #endif |
---|
932 | #endif //SVC_EXTENSION |
---|
933 | |
---|
934 | //! \} |
---|