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