Changeset 1313 in 3DVCSoftware for trunk/source/Lib/TLibDecoder/SEIread.cpp
- Timestamp:
- 13 Aug 2015, 17:38:13 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/source/Lib/TLibDecoder/SEIread.cpp
r1179 r1313 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-2015, ITU/ISO/IEC6 * Copyright (c) 2010-2015, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 32 32 */ 33 33 34 /** 34 /** 35 35 \file SEIread.cpp 36 \brief reading fun ctionality for SEI messages36 \brief reading funtionality for SEI messages 37 37 */ 38 38 … … 43 43 #include "SyntaxElementParser.h" 44 44 #include "SEIread.h" 45 #include "TLibCommon/TComPicYuv.h" 46 #include <iomanip> 47 45 48 46 49 //! \ingroup TLibDecoder 47 50 //! \{ 48 51 52 49 53 #if ENC_DEC_TRACE 50 54 Void xTraceSEIHeader() … … 55 59 Void xTraceSEIMessageType(SEI::PayloadType payloadType) 56 60 { 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 H_MV 102 case SEI::SUB_BITSTREAM_PROPERTY: 103 fprintf( g_hTrace, "=========== Sub-bitstream property SEI message ===========\n"); 104 break; 61 fprintf( g_hTrace, "=========== %s SEI message ===========\n", SEI::getSEIMessageString(payloadType)); 62 } 105 63 #endif 106 default: 107 fprintf( g_hTrace, "=========== Unknown SEI message ===========\n"); 108 break; 109 } 110 } 111 #endif 64 65 Void SEIReader::sei_read_code(std::ostream *pOS, UInt uiLength, UInt& ruiCode, const Char *pSymbolName) 66 { 67 READ_CODE(uiLength, ruiCode, pSymbolName); 68 if (pOS) 69 { 70 (*pOS) << " " << std::setw(55) << pSymbolName << ": " << ruiCode << "\n"; 71 } 72 } 73 74 Void SEIReader::sei_read_uvlc(std::ostream *pOS, UInt& ruiCode, const Char *pSymbolName) 75 { 76 READ_UVLC(ruiCode, pSymbolName); 77 if (pOS) 78 { 79 (*pOS) << " " << std::setw(55) << pSymbolName << ": " << ruiCode << "\n"; 80 } 81 } 82 83 Void SEIReader::sei_read_svlc(std::ostream *pOS, Int& ruiCode, const Char *pSymbolName) 84 { 85 READ_SVLC(ruiCode, pSymbolName); 86 if (pOS) 87 { 88 (*pOS) << " " << std::setw(55) << pSymbolName << ": " << ruiCode << "\n"; 89 } 90 } 91 92 Void SEIReader::sei_read_flag(std::ostream *pOS, UInt& ruiCode, const Char *pSymbolName) 93 { 94 READ_FLAG(ruiCode, pSymbolName); 95 if (pOS) 96 { 97 (*pOS) << " " << std::setw(55) << pSymbolName << ": " << (ruiCode?1:0) << "\n"; 98 } 99 } 100 101 static inline Void output_sei_message_header(SEI &sei, std::ostream *pDecodedMessageOutputStream, UInt payloadSize) 102 { 103 if (pDecodedMessageOutputStream) 104 { 105 std::string seiMessageHdr(SEI::getSEIMessageString(sei.payloadType())); seiMessageHdr+=" SEI message"; 106 (*pDecodedMessageOutputStream) << std::setfill('-') << std::setw(seiMessageHdr.size()) << "-" << std::setfill(' ') << "\n" << seiMessageHdr << " (" << payloadSize << " bytes)"<< "\n"; 107 } 108 } 109 110 #undef READ_CODE 111 #undef READ_SVLC 112 #undef READ_UVLC 113 #undef READ_FLAG 114 112 115 113 116 /** 114 117 * unmarshal a single SEI message from bitstream bs 115 118 */ 116 void SEIReader::parseSEImessage(TComInputBitstream* bs, SEIMessages& seis, const NalUnitType nalUnitType, TComSPS *sps)119 Void SEIReader::parseSEImessage(TComInputBitstream* bs, SEIMessages& seis, const NalUnitType nalUnitType, const TComSPS *sps, std::ostream *pDecodedMessageOutputStream) 117 120 { 118 121 setBitstream(bs); … … 121 124 do 122 125 { 123 xReadSEImessage(seis, nalUnitType, sps); 126 xReadSEImessage(seis, nalUnitType, sps, pDecodedMessageOutputStream); 127 124 128 /* SEI messages are an integer number of bytes, something has failed 125 129 * in the parsing if bitstream not byte-aligned */ 126 130 assert(!m_pcBitstream->getNumBitsUntilByteAligned()); 127 } while (m_pcBitstream->getNumBitsLeft() > 8); 128 129 UInt rbspTrailingBits; 130 READ_CODE(8, rbspTrailingBits, "rbsp_trailing_bits"); 131 assert(rbspTrailingBits == 0x80); 132 } 133 134 Void SEIReader::xReadSEImessage(SEIMessages& seis, const NalUnitType nalUnitType, TComSPS *sps) 131 } 132 while (m_pcBitstream->getNumBitsLeft() > 8); 133 134 xReadRbspTrailingBits(); 135 } 136 137 Void SEIReader::xReadSEImessage(SEIMessages& seis, const NalUnitType nalUnitType, const TComSPS *sps, std::ostream *pDecodedMessageOutputStream) 135 138 { 136 139 #if ENC_DEC_TRACE … … 142 145 do 143 146 { 144 READ_CODE (8, val, "payload_type");147 sei_read_code(NULL, 8, val, "payload_type"); 145 148 payloadType += val; 146 149 } while (val==0xFF); … … 149 152 do 150 153 { 151 READ_CODE (8, val, "payload_size");154 sei_read_code(NULL, 8, val, "payload_size"); 152 155 payloadSize += val; 153 156 } while (val==0xFF); … … 174 177 case SEI::USER_DATA_UNREGISTERED: 175 178 sei = new SEIuserDataUnregistered; 176 xParseSEIuserDataUnregistered((SEIuserDataUnregistered&) *sei, payloadSize );179 xParseSEIuserDataUnregistered((SEIuserDataUnregistered&) *sei, payloadSize, pDecodedMessageOutputStream); 177 180 break; 178 181 case SEI::ACTIVE_PARAMETER_SETS: 179 sei = new SEIActiveParameterSets; 180 xParseSEIActiveParameterSets((SEIActiveParameterSets&) *sei, payloadSize );181 break; 182 sei = new SEIActiveParameterSets; 183 xParseSEIActiveParameterSets((SEIActiveParameterSets&) *sei, payloadSize, pDecodedMessageOutputStream); 184 break; 182 185 case SEI::DECODING_UNIT_INFO: 183 186 if (!sps) … … 187 190 else 188 191 { 189 sei = new SEIDecodingUnitInfo; 190 xParseSEIDecodingUnitInfo((SEIDecodingUnitInfo&) *sei, payloadSize, sps );191 } 192 break; 192 sei = new SEIDecodingUnitInfo; 193 xParseSEIDecodingUnitInfo((SEIDecodingUnitInfo&) *sei, payloadSize, sps, pDecodedMessageOutputStream); 194 } 195 break; 193 196 case SEI::BUFFERING_PERIOD: 194 197 if (!sps) … … 199 202 { 200 203 sei = new SEIBufferingPeriod; 201 xParseSEIBufferingPeriod((SEIBufferingPeriod&) *sei, payloadSize, sps );204 xParseSEIBufferingPeriod((SEIBufferingPeriod&) *sei, payloadSize, sps, pDecodedMessageOutputStream); 202 205 } 203 206 break; … … 210 213 { 211 214 sei = new SEIPictureTiming; 212 xParseSEIPictureTiming((SEIPictureTiming&)*sei, payloadSize, sps );215 xParseSEIPictureTiming((SEIPictureTiming&)*sei, payloadSize, sps, pDecodedMessageOutputStream); 213 216 } 214 217 break; 215 218 case SEI::RECOVERY_POINT: 216 219 sei = new SEIRecoveryPoint; 217 xParseSEIRecoveryPoint((SEIRecoveryPoint&) *sei, payloadSize );220 xParseSEIRecoveryPoint((SEIRecoveryPoint&) *sei, payloadSize, pDecodedMessageOutputStream); 218 221 break; 219 222 case SEI::FRAME_PACKING: 220 223 sei = new SEIFramePacking; 221 xParseSEIFramePacking((SEIFramePacking&) *sei, payloadSize); 224 xParseSEIFramePacking((SEIFramePacking&) *sei, payloadSize, pDecodedMessageOutputStream); 225 break; 226 case SEI::SEGM_RECT_FRAME_PACKING: 227 sei = new SEISegmentedRectFramePacking; 228 xParseSEISegmentedRectFramePacking((SEISegmentedRectFramePacking&) *sei, payloadSize, pDecodedMessageOutputStream); 222 229 break; 223 230 case SEI::DISPLAY_ORIENTATION: 224 231 sei = new SEIDisplayOrientation; 225 xParseSEIDisplayOrientation((SEIDisplayOrientation&) *sei, payloadSize );232 xParseSEIDisplayOrientation((SEIDisplayOrientation&) *sei, payloadSize, pDecodedMessageOutputStream); 226 233 break; 227 234 case SEI::TEMPORAL_LEVEL0_INDEX: 228 235 sei = new SEITemporalLevel0Index; 229 xParseSEITemporalLevel0Index((SEITemporalLevel0Index&) *sei, payloadSize );236 xParseSEITemporalLevel0Index((SEITemporalLevel0Index&) *sei, payloadSize, pDecodedMessageOutputStream); 230 237 break; 231 238 case SEI::REGION_REFRESH_INFO: 232 239 sei = new SEIGradualDecodingRefreshInfo; 233 xParseSEIGradualDecodingRefreshInfo((SEIGradualDecodingRefreshInfo&) *sei, payloadSize); 240 xParseSEIRegionRefreshInfo((SEIGradualDecodingRefreshInfo&) *sei, payloadSize, pDecodedMessageOutputStream); 241 break; 242 case SEI::NO_DISPLAY: 243 sei = new SEINoDisplay; 244 xParseSEINoDisplay((SEINoDisplay&) *sei, payloadSize, pDecodedMessageOutputStream); 234 245 break; 235 246 case SEI::TONE_MAPPING_INFO: 236 247 sei = new SEIToneMappingInfo; 237 xParseSEIToneMappingInfo((SEIToneMappingInfo&) *sei, payloadSize );248 xParseSEIToneMappingInfo((SEIToneMappingInfo&) *sei, payloadSize, pDecodedMessageOutputStream); 238 249 break; 239 250 case SEI::SOP_DESCRIPTION: 240 251 sei = new SEISOPDescription; 241 xParseSEISOPDescription((SEISOPDescription&) *sei, payloadSize );252 xParseSEISOPDescription((SEISOPDescription&) *sei, payloadSize, pDecodedMessageOutputStream); 242 253 break; 243 254 case SEI::SCALABLE_NESTING: 244 255 sei = new SEIScalableNesting; 245 xParseSEIScalableNesting((SEIScalableNesting&) *sei, nalUnitType, payloadSize, sps); 246 break; 247 #if H_MV 248 case SEI::SUB_BITSTREAM_PROPERTY: 249 sei = new SEISubBitstreamProperty; 250 xParseSEISubBitstreamProperty((SEISubBitstreamProperty&) *sei); 251 break; 256 xParseSEIScalableNesting((SEIScalableNesting&) *sei, nalUnitType, payloadSize, sps, pDecodedMessageOutputStream); 257 break; 258 case SEI::TEMP_MOTION_CONSTRAINED_TILE_SETS: 259 sei = new SEITempMotionConstrainedTileSets; 260 xParseSEITempMotionConstraintsTileSets((SEITempMotionConstrainedTileSets&) *sei, payloadSize, pDecodedMessageOutputStream); 261 break; 262 case SEI::TIME_CODE: 263 sei = new SEITimeCode; 264 xParseSEITimeCode((SEITimeCode&) *sei, payloadSize, pDecodedMessageOutputStream); 265 break; 266 case SEI::CHROMA_SAMPLING_FILTER_HINT: 267 sei = new SEIChromaSamplingFilterHint; 268 xParseSEIChromaSamplingFilterHint((SEIChromaSamplingFilterHint&) *sei, payloadSize/*, sps*/, pDecodedMessageOutputStream); 269 //} 270 break; 271 case SEI::KNEE_FUNCTION_INFO: 272 sei = new SEIKneeFunctionInfo; 273 xParseSEIKneeFunctionInfo((SEIKneeFunctionInfo&) *sei, payloadSize, pDecodedMessageOutputStream); 274 break; 275 case SEI::MASTERING_DISPLAY_COLOUR_VOLUME: 276 sei = new SEIMasteringDisplayColourVolume; 277 xParseSEIMasteringDisplayColourVolume((SEIMasteringDisplayColourVolume&) *sei, payloadSize, pDecodedMessageOutputStream); 278 break; 279 #if NH_MV 280 case SEI::SUB_BITSTREAM_PROPERTY: 281 sei = new SEISubBitstreamProperty; 282 xParseSEISubBitstreamProperty((SEISubBitstreamProperty&) *sei, payloadSize, pDecodedMessageOutputStream ); 283 break; 252 284 #endif 253 285 default: … … 255 287 { 256 288 UInt seiByte; 257 READ_CODE (8, seiByte, "unknown prefix SEI payload byte");289 sei_read_code (NULL, 8, seiByte, "unknown prefix SEI payload byte"); 258 290 } 259 291 printf ("Unknown prefix SEI message (payloadType = %d) was found!\n", payloadType); 292 if (pDecodedMessageOutputStream) 293 { 294 (*pDecodedMessageOutputStream) << "Unknown prefix SEI message (payloadType = " << payloadType << ") was found!\n"; 295 } 296 break; 260 297 } 261 298 } … … 266 303 case SEI::USER_DATA_UNREGISTERED: 267 304 sei = new SEIuserDataUnregistered; 268 xParseSEIuserDataUnregistered((SEIuserDataUnregistered&) *sei, payloadSize );305 xParseSEIuserDataUnregistered((SEIuserDataUnregistered&) *sei, payloadSize, pDecodedMessageOutputStream); 269 306 break; 270 307 case SEI::DECODED_PICTURE_HASH: 271 308 sei = new SEIDecodedPictureHash; 272 xParseSEIDecodedPictureHash((SEIDecodedPictureHash&) *sei, payloadSize );309 xParseSEIDecodedPictureHash((SEIDecodedPictureHash&) *sei, payloadSize, pDecodedMessageOutputStream); 273 310 break; 274 311 default: … … 276 313 { 277 314 UInt seiByte; 278 READ_CODE (8, seiByte, "unknown suffix SEI payload byte");315 sei_read_code( NULL, 8, seiByte, "unknown suffix SEI payload byte"); 279 316 } 280 317 printf ("Unknown suffix SEI message (payloadType = %d) was found!\n", payloadType); 281 } 282 } 318 if (pDecodedMessageOutputStream) 319 { 320 (*pDecodedMessageOutputStream) << "Unknown suffix SEI message (payloadType = " << payloadType << ") was found!\n"; 321 } 322 break; 323 } 324 } 325 283 326 if (sei != NULL) 284 327 { … … 299 342 { 300 343 UInt reservedPayloadExtensionData; 301 READ_CODE (1, reservedPayloadExtensionData, "reserved_payload_extension_data");344 sei_read_code ( pDecodedMessageOutputStream, 1, reservedPayloadExtensionData, "reserved_payload_extension_data"); 302 345 } 303 346 … … 314 357 { 315 358 UInt reservedPayloadExtensionData; 316 READ_FLAG (reservedPayloadExtensionData, "reserved_payload_extension_data");359 sei_read_flag ( 0, reservedPayloadExtensionData, "reserved_payload_extension_data"); 317 360 } 318 361 319 362 UInt dummy; 320 READ_FLAG (dummy, "payload_bit_equal_to_one"); payloadBitsRemaining--;363 sei_read_flag( 0, dummy, "payload_bit_equal_to_one"); payloadBitsRemaining--; 321 364 while (payloadBitsRemaining) 322 365 { 323 READ_FLAG (dummy, "payload_bit_equal_to_zero"); payloadBitsRemaining--;366 sei_read_flag( 0, dummy, "payload_bit_equal_to_zero"); payloadBitsRemaining--; 324 367 } 325 368 } 326 369 327 370 /* restore primary bitstream for sei_message */ 328 getBitstream()->deleteFifo();329 371 delete getBitstream(); 330 372 setBitstream(bs); … … 335 377 * of payloasSize bytes into sei. 336 378 */ 337 Void SEIReader::xParseSEIuserDataUnregistered(SEIuserDataUnregistered &sei, UInt payloadSize) 338 { 339 assert(payloadSize >= 16); 379 380 Void SEIReader::xParseSEIuserDataUnregistered(SEIuserDataUnregistered &sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) 381 { 382 assert(payloadSize >= ISO_IEC_11578_LEN); 340 383 UInt val; 341 342 for (UInt i = 0; i < 16; i++) 343 { 344 READ_CODE (8, val, "uuid_iso_iec_11578"); 384 output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); 385 386 for (UInt i = 0; i < ISO_IEC_11578_LEN; i++) 387 { 388 sei_read_code( pDecodedMessageOutputStream, 8, val, "uuid_iso_iec_11578"); 345 389 sei.uuid_iso_iec_11578[i] = val; 346 390 } 347 391 348 sei.userDataLength = payloadSize - 16;392 sei.userDataLength = payloadSize - ISO_IEC_11578_LEN; 349 393 if (!sei.userDataLength) 350 394 { … … 356 400 for (UInt i = 0; i < sei.userDataLength; i++) 357 401 { 358 READ_CODE (8, val, "user_data" );402 sei_read_code( NULL, 8, val, "user_data_payload_byte" ); 359 403 sei.userData[i] = val; 404 } 405 if (pDecodedMessageOutputStream) 406 { 407 (*pDecodedMessageOutputStream) << " User data payload size: " << sei.userDataLength << "\n"; 360 408 } 361 409 } … … 365 413 * of payloadSize bytes into sei. 366 414 */ 367 Void SEIReader::xParseSEIDecodedPictureHash(SEIDecodedPictureHash& sei, UInt /*payloadSize*/) 368 { 415 Void SEIReader::xParseSEIDecodedPictureHash(SEIDecodedPictureHash& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) 416 { 417 UInt bytesRead = 0; 418 output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); 419 369 420 UInt val; 370 READ_CODE (8, val, "hash_type"); 371 sei.method = static_cast<SEIDecodedPictureHash::Method>(val); 372 for(Int yuvIdx = 0; yuvIdx < 3; yuvIdx++) 373 { 374 if(SEIDecodedPictureHash::MD5 == sei.method) 375 { 376 for (UInt i = 0; i < 16; i++) 377 { 378 READ_CODE(8, val, "picture_md5"); 379 sei.digest[yuvIdx][i] = val; 380 } 381 } 382 else if(SEIDecodedPictureHash::CRC == sei.method) 383 { 384 READ_CODE(16, val, "picture_crc"); 385 sei.digest[yuvIdx][0] = val >> 8 & 0xFF; 386 sei.digest[yuvIdx][1] = val & 0xFF; 387 } 388 else if(SEIDecodedPictureHash::CHECKSUM == sei.method) 389 { 390 READ_CODE(32, val, "picture_checksum"); 391 sei.digest[yuvIdx][0] = (val>>24) & 0xff; 392 sei.digest[yuvIdx][1] = (val>>16) & 0xff; 393 sei.digest[yuvIdx][2] = (val>>8) & 0xff; 394 sei.digest[yuvIdx][3] = val & 0xff; 395 } 396 } 397 } 398 Void SEIReader::xParseSEIActiveParameterSets(SEIActiveParameterSets& sei, UInt /*payloadSize*/) 421 sei_read_code( pDecodedMessageOutputStream, 8, val, "hash_type"); 422 sei.method = static_cast<SEIDecodedPictureHash::Method>(val); bytesRead++; 423 424 const Char *traceString="\0"; 425 switch (sei.method) 426 { 427 case SEIDecodedPictureHash::MD5: traceString="picture_md5"; break; 428 case SEIDecodedPictureHash::CRC: traceString="picture_crc"; break; 429 case SEIDecodedPictureHash::CHECKSUM: traceString="picture_checksum"; break; 430 default: assert(false); break; 431 } 432 433 if (pDecodedMessageOutputStream) 434 { 435 (*pDecodedMessageOutputStream) << " " << std::setw(55) << traceString << ": " << std::hex << std::setfill('0'); 436 } 437 438 sei.m_pictureHash.hash.clear(); 439 for(;bytesRead < payloadSize; bytesRead++) 440 { 441 sei_read_code( NULL, 8, val, traceString); 442 sei.m_pictureHash.hash.push_back((UChar)val); 443 if (pDecodedMessageOutputStream) 444 { 445 (*pDecodedMessageOutputStream) << std::setw(2) << val; 446 } 447 } 448 449 if (pDecodedMessageOutputStream) 450 { 451 (*pDecodedMessageOutputStream) << std::dec << std::setfill(' ') << "\n"; 452 } 453 } 454 455 Void SEIReader::xParseSEIActiveParameterSets(SEIActiveParameterSets& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) 399 456 { 400 457 UInt val; 401 READ_CODE(4, val, "active_video_parameter_set_id"); sei.activeVPSId = val; 402 READ_FLAG( val, "self_contained_cvs_flag"); sei.m_selfContainedCvsFlag = val ? true : false; 403 READ_FLAG( val, "no_parameter_set_update_flag"); sei.m_noParameterSetUpdateFlag = val ? true : false; 404 READ_UVLC( val, "num_sps_ids_minus1"); sei.numSpsIdsMinus1 = val; 458 output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); 459 460 sei_read_code( pDecodedMessageOutputStream, 4, val, "active_video_parameter_set_id"); sei.activeVPSId = val; 461 sei_read_flag( pDecodedMessageOutputStream, val, "self_contained_cvs_flag"); sei.m_selfContainedCvsFlag = (val != 0); 462 sei_read_flag( pDecodedMessageOutputStream, val, "no_parameter_set_update_flag"); sei.m_noParameterSetUpdateFlag = (val != 0); 463 sei_read_uvlc( pDecodedMessageOutputStream, val, "num_sps_ids_minus1"); sei.numSpsIdsMinus1 = val; 405 464 406 465 sei.activeSeqParameterSetId.resize(sei.numSpsIdsMinus1 + 1); 407 466 for (Int i=0; i < (sei.numSpsIdsMinus1 + 1); i++) 408 467 { 409 READ_UVLC(val, "active_seq_parameter_set_id"); sei.activeSeqParameterSetId[i] = val; 410 } 411 412 xParseByteAlign(); 413 } 414 415 Void SEIReader::xParseSEIDecodingUnitInfo(SEIDecodingUnitInfo& sei, UInt /*payloadSize*/, TComSPS *sps) 468 sei_read_uvlc( pDecodedMessageOutputStream, val, "active_seq_parameter_set_id[i]"); sei.activeSeqParameterSetId[i] = val; 469 } 470 } 471 472 Void SEIReader::xParseSEIDecodingUnitInfo(SEIDecodingUnitInfo& sei, UInt payloadSize, const TComSPS *sps, std::ostream *pDecodedMessageOutputStream) 416 473 { 417 474 UInt val; 418 READ_UVLC(val, "decoding_unit_idx"); 475 output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); 476 sei_read_uvlc( pDecodedMessageOutputStream, val, "decoding_unit_idx"); 419 477 sei.m_decodingUnitIdx = val; 420 478 421 TComVUI *vui = sps->getVuiParameters();479 const TComVUI *vui = sps->getVuiParameters(); 422 480 if(vui->getHrdParameters()->getSubPicCpbParamsInPicTimingSEIFlag()) 423 481 { 424 READ_CODE( ( vui->getHrdParameters()->getDuCpbRemovalDelayLengthMinus1() + 1 ), val, "du_spt_cpb_removal_delay");482 sei_read_code( pDecodedMessageOutputStream, ( vui->getHrdParameters()->getDuCpbRemovalDelayLengthMinus1() + 1 ), val, "du_spt_cpb_removal_delay_increment"); 425 483 sei.m_duSptCpbRemovalDelay = val; 426 484 } … … 429 487 sei.m_duSptCpbRemovalDelay = 0; 430 488 } 431 READ_FLAG( val, "dpb_output_du_delay_present_flag"); sei.m_dpbOutputDuDelayPresentFlag = val ? true : false;489 sei_read_flag( pDecodedMessageOutputStream, val, "dpb_output_du_delay_present_flag"); sei.m_dpbOutputDuDelayPresentFlag = (val != 0); 432 490 if(sei.m_dpbOutputDuDelayPresentFlag) 433 491 { 434 READ_CODE(vui->getHrdParameters()->getDpbOutputDelayDuLengthMinus1() + 1, val, "pic_spt_dpb_output_du_delay");492 sei_read_code( pDecodedMessageOutputStream, vui->getHrdParameters()->getDpbOutputDelayDuLengthMinus1() + 1, val, "pic_spt_dpb_output_du_delay"); 435 493 sei.m_picSptDpbOutputDuDelay = val; 436 494 } 437 xParseByteAlign(); 438 } 439 440 Void SEIReader::xParseSEIBufferingPeriod(SEIBufferingPeriod& sei, UInt /*payloadSize*/, TComSPS *sps) 495 } 496 497 Void SEIReader::xParseSEIBufferingPeriod(SEIBufferingPeriod& sei, UInt payloadSize, const TComSPS *sps, std::ostream *pDecodedMessageOutputStream) 441 498 { 442 499 Int i, nalOrVcl; 443 500 UInt code; 444 501 445 TComVUI *pVUI = sps->getVuiParameters(); 446 TComHRD *pHRD = pVUI->getHrdParameters(); 447 448 READ_UVLC( code, "bp_seq_parameter_set_id" ); sei.m_bpSeqParameterSetId = code; 502 const TComVUI *pVUI = sps->getVuiParameters(); 503 const TComHRD *pHRD = pVUI->getHrdParameters(); 504 505 output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); 506 507 sei_read_uvlc( pDecodedMessageOutputStream, code, "bp_seq_parameter_set_id" ); sei.m_bpSeqParameterSetId = code; 449 508 if( !pHRD->getSubPicCpbParamsPresentFlag() ) 450 509 { 451 READ_FLAG(code, "irap_cpb_params_present_flag" ); sei.m_rapCpbParamsPresentFlag = code;510 sei_read_flag( pDecodedMessageOutputStream, code, "irap_cpb_params_present_flag" ); sei.m_rapCpbParamsPresentFlag = code; 452 511 } 453 512 if( sei.m_rapCpbParamsPresentFlag ) 454 513 { 455 READ_CODE( pHRD->getCpbRemovalDelayLengthMinus1() + 1, code, "cpb_delay_offset" ); sei.m_cpbDelayOffset = code; 456 READ_CODE( pHRD->getDpbOutputDelayLengthMinus1() + 1, code, "dpb_delay_offset" ); sei.m_dpbDelayOffset = code; 457 } 514 sei_read_code( pDecodedMessageOutputStream, pHRD->getCpbRemovalDelayLengthMinus1() + 1, code, "cpb_delay_offset" ); sei.m_cpbDelayOffset = code; 515 sei_read_code( pDecodedMessageOutputStream, pHRD->getDpbOutputDelayLengthMinus1() + 1, code, "dpb_delay_offset" ); sei.m_dpbDelayOffset = code; 516 } 517 458 518 //read splicing flag and cpb_removal_delay_delta 459 READ_FLAG( code, "concatenation_flag");519 sei_read_flag( pDecodedMessageOutputStream, code, "concatenation_flag"); 460 520 sei.m_concatenationFlag = code; 461 READ_CODE(( pHRD->getCpbRemovalDelayLengthMinus1() + 1 ), code, "au_cpb_removal_delay_delta_minus1" );521 sei_read_code( pDecodedMessageOutputStream, ( pHRD->getCpbRemovalDelayLengthMinus1() + 1 ), code, "au_cpb_removal_delay_delta_minus1" ); 462 522 sei.m_auCpbRemovalDelayDelta = code + 1; 523 463 524 for( nalOrVcl = 0; nalOrVcl < 2; nalOrVcl ++ ) 464 525 { … … 468 529 for( i = 0; i < ( pHRD->getCpbCntMinus1( 0 ) + 1 ); i ++ ) 469 530 { 470 READ_CODE( ( pHRD->getInitialCpbRemovalDelayLengthMinus1() + 1 ) , code, "initial_cpb_removal_delay" );531 sei_read_code( pDecodedMessageOutputStream, ( pHRD->getInitialCpbRemovalDelayLengthMinus1() + 1 ) , code, nalOrVcl?"vcl_initial_cpb_removal_delay":"nal_initial_cpb_removal_delay" ); 471 532 sei.m_initialCpbRemovalDelay[i][nalOrVcl] = code; 472 READ_CODE( ( pHRD->getInitialCpbRemovalDelayLengthMinus1() + 1 ) , code, "initial_cpb_removal_delay_offset" );533 sei_read_code( pDecodedMessageOutputStream, ( pHRD->getInitialCpbRemovalDelayLengthMinus1() + 1 ) , code, nalOrVcl?"vcl_initial_cpb_removal_offset":"vcl_initial_cpb_removal_offset" ); 473 534 sei.m_initialCpbRemovalDelayOffset[i][nalOrVcl] = code; 474 535 if( pHRD->getSubPicCpbParamsPresentFlag() || sei.m_rapCpbParamsPresentFlag ) 475 536 { 476 READ_CODE( ( pHRD->getInitialCpbRemovalDelayLengthMinus1() + 1 ) , code, "initial_alt_cpb_removal_delay" );537 sei_read_code( pDecodedMessageOutputStream, ( pHRD->getInitialCpbRemovalDelayLengthMinus1() + 1 ) , code, nalOrVcl?"vcl_initial_alt_cpb_removal_delay":"vcl_initial_alt_cpb_removal_delay" ); 477 538 sei.m_initialAltCpbRemovalDelay[i][nalOrVcl] = code; 478 READ_CODE( ( pHRD->getInitialCpbRemovalDelayLengthMinus1() + 1 ) , code, "initial_alt_cpb_removal_delay_offset" );539 sei_read_code( pDecodedMessageOutputStream, ( pHRD->getInitialCpbRemovalDelayLengthMinus1() + 1 ) , code, nalOrVcl?"vcl_initial_alt_cpb_removal_offset":"vcl_initial_alt_cpb_removal_offset" ); 479 540 sei.m_initialAltCpbRemovalDelayOffset[i][nalOrVcl] = code; 480 541 } … … 482 543 } 483 544 } 484 xParseByteAlign(); 485 } 486 Void SEIReader::xParseSEIPictureTiming(SEIPictureTiming& sei, UInt /*payloadSize*/, TComSPS *sps)545 } 546 547 Void SEIReader::xParseSEIPictureTiming(SEIPictureTiming& sei, UInt payloadSize, const TComSPS *sps, std::ostream *pDecodedMessageOutputStream) 487 548 { 488 549 Int i; 489 550 UInt code; 490 551 491 TComVUI *vui = sps->getVuiParameters(); 492 TComHRD *hrd = vui->getHrdParameters(); 552 const TComVUI *vui = sps->getVuiParameters(); 553 const TComHRD *hrd = vui->getHrdParameters(); 554 output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); 493 555 494 556 if( vui->getFrameFieldInfoPresentFlag() ) 495 557 { 496 READ_CODE(4, code, "pic_struct" ); sei.m_picStruct = code;497 READ_CODE( 2, code, "source_scan_type" ); sei.m_sourceScanType= code;498 READ_FLAG( code, "duplicate_flag" ); sei.m_duplicateFlag = ( code == 1 ? true : false);558 sei_read_code( pDecodedMessageOutputStream, 4, code, "pic_struct" ); sei.m_picStruct = code; 559 sei_read_code( pDecodedMessageOutputStream, 2, code, "source_scan_type" ); sei.m_sourceScanType = code; 560 sei_read_flag( pDecodedMessageOutputStream, code, "duplicate_flag" ); sei.m_duplicateFlag = (code == 1); 499 561 } 500 562 501 563 if( hrd->getCpbDpbDelaysPresentFlag()) 502 564 { 503 READ_CODE(( hrd->getCpbRemovalDelayLengthMinus1() + 1 ), code, "au_cpb_removal_delay_minus1" );565 sei_read_code( pDecodedMessageOutputStream, ( hrd->getCpbRemovalDelayLengthMinus1() + 1 ), code, "au_cpb_removal_delay_minus1" ); 504 566 sei.m_auCpbRemovalDelay = code + 1; 505 READ_CODE(( hrd->getDpbOutputDelayLengthMinus1() + 1 ), code, "pic_dpb_output_delay" );567 sei_read_code( pDecodedMessageOutputStream, ( hrd->getDpbOutputDelayLengthMinus1() + 1 ), code, "pic_dpb_output_delay" ); 506 568 sei.m_picDpbOutputDelay = code; 507 569 508 570 if(hrd->getSubPicCpbParamsPresentFlag()) 509 571 { 510 READ_CODE(hrd->getDpbOutputDelayDuLengthMinus1()+1, code, "pic_dpb_output_du_delay" );572 sei_read_code( pDecodedMessageOutputStream, hrd->getDpbOutputDelayDuLengthMinus1()+1, code, "pic_dpb_output_du_delay" ); 511 573 sei.m_picDpbOutputDuDelay = code; 512 574 } 575 513 576 if( hrd->getSubPicCpbParamsPresentFlag() && hrd->getSubPicCpbParamsInPicTimingSEIFlag() ) 514 577 { 515 READ_UVLC(code, "num_decoding_units_minus1");578 sei_read_uvlc( pDecodedMessageOutputStream, code, "num_decoding_units_minus1"); 516 579 sei.m_numDecodingUnitsMinus1 = code; 517 READ_FLAG(code, "du_common_cpb_removal_delay_flag" );580 sei_read_flag( pDecodedMessageOutputStream, code, "du_common_cpb_removal_delay_flag" ); 518 581 sei.m_duCommonCpbRemovalDelayFlag = code; 519 582 if( sei.m_duCommonCpbRemovalDelayFlag ) 520 583 { 521 READ_CODE( ( hrd->getDuCpbRemovalDelayLengthMinus1() + 1 ), code, "du_common_cpb_removal_delay_minus1" );584 sei_read_code( pDecodedMessageOutputStream, ( hrd->getDuCpbRemovalDelayLengthMinus1() + 1 ), code, "du_common_cpb_removal_delay_increment_minus1" ); 522 585 sei.m_duCommonCpbRemovalDelayMinus1 = code; 523 586 } 524 if( sei.m_numNalusInDuMinus1 != NULL ) 525 { 526 delete sei.m_numNalusInDuMinus1; 527 } 528 sei.m_numNalusInDuMinus1 = new UInt[ ( sei.m_numDecodingUnitsMinus1 + 1 ) ]; 529 if( sei.m_duCpbRemovalDelayMinus1 != NULL ) 530 { 531 delete sei.m_duCpbRemovalDelayMinus1; 532 } 533 sei.m_duCpbRemovalDelayMinus1 = new UInt[ ( sei.m_numDecodingUnitsMinus1 + 1 ) ]; 587 sei.m_numNalusInDuMinus1.resize(sei.m_numDecodingUnitsMinus1 + 1 ); 588 sei.m_duCpbRemovalDelayMinus1.resize( sei.m_numDecodingUnitsMinus1 + 1 ); 534 589 535 590 for( i = 0; i <= sei.m_numDecodingUnitsMinus1; i ++ ) 536 591 { 537 READ_UVLC( code, "num_nalus_in_du_minus1");592 sei_read_uvlc( pDecodedMessageOutputStream, code, "num_nalus_in_du_minus1[i]"); 538 593 sei.m_numNalusInDuMinus1[ i ] = code; 539 594 if( ( !sei.m_duCommonCpbRemovalDelayFlag ) && ( i < sei.m_numDecodingUnitsMinus1 ) ) 540 595 { 541 READ_CODE( ( hrd->getDuCpbRemovalDelayLengthMinus1() + 1 ), code, "du_cpb_removal_delay_minus1" );596 sei_read_code( pDecodedMessageOutputStream, ( hrd->getDuCpbRemovalDelayLengthMinus1() + 1 ), code, "du_cpb_removal_delay_minus1[i]" ); 542 597 sei.m_duCpbRemovalDelayMinus1[ i ] = code; 543 598 } … … 545 600 } 546 601 } 547 xParseByteAlign(); 548 } 549 Void SEIReader::xParseSEIRecoveryPoint(SEIRecoveryPoint& sei, UInt /*payloadSize*/)602 } 603 604 Void SEIReader::xParseSEIRecoveryPoint(SEIRecoveryPoint& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) 550 605 { 551 606 Int iCode; 552 607 UInt uiCode; 553 READ_SVLC( iCode, "recovery_poc_cnt" ); sei.m_recoveryPocCnt = iCode; 554 READ_FLAG( uiCode, "exact_matching_flag" ); sei.m_exactMatchingFlag = uiCode; 555 READ_FLAG( uiCode, "broken_link_flag" ); sei.m_brokenLinkFlag = uiCode; 556 xParseByteAlign(); 557 } 558 Void SEIReader::xParseSEIFramePacking(SEIFramePacking& sei, UInt /*payloadSize*/) 608 output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); 609 610 sei_read_svlc( pDecodedMessageOutputStream, iCode, "recovery_poc_cnt" ); sei.m_recoveryPocCnt = iCode; 611 sei_read_flag( pDecodedMessageOutputStream, uiCode, "exact_matching_flag" ); sei.m_exactMatchingFlag = uiCode; 612 sei_read_flag( pDecodedMessageOutputStream, uiCode, "broken_link_flag" ); sei.m_brokenLinkFlag = uiCode; 613 } 614 615 Void SEIReader::xParseSEIFramePacking(SEIFramePacking& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) 559 616 { 560 617 UInt val; 561 READ_UVLC( val, "frame_packing_arrangement_id" ); sei.m_arrangementId = val; 562 READ_FLAG( val, "frame_packing_arrangement_cancel_flag" ); sei.m_arrangementCancelFlag = val; 618 output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); 619 620 sei_read_uvlc( pDecodedMessageOutputStream, val, "frame_packing_arrangement_id" ); sei.m_arrangementId = val; 621 sei_read_flag( pDecodedMessageOutputStream, val, "frame_packing_arrangement_cancel_flag" ); sei.m_arrangementCancelFlag = val; 563 622 564 623 if ( !sei.m_arrangementCancelFlag ) 565 624 { 566 READ_CODE(7, val, "frame_packing_arrangement_type" ); sei.m_arrangementType = val;625 sei_read_code( pDecodedMessageOutputStream, 7, val, "frame_packing_arrangement_type" ); sei.m_arrangementType = val; 567 626 assert((sei.m_arrangementType > 2) && (sei.m_arrangementType < 6) ); 568 READ_FLAG( val, "quincunx_sampling_flag" ); sei.m_quincunxSamplingFlag = val; 569 570 READ_CODE( 6, val, "content_interpretation_type" ); sei.m_contentInterpretationType = val; 571 READ_FLAG( val, "spatial_flipping_flag" ); sei.m_spatialFlippingFlag = val; 572 READ_FLAG( val, "frame0_flipped_flag" ); sei.m_frame0FlippedFlag = val; 573 READ_FLAG( val, "field_views_flag" ); sei.m_fieldViewsFlag = val; 574 READ_FLAG( val, "current_frame_is_frame0_flag" ); sei.m_currentFrameIsFrame0Flag = val; 575 READ_FLAG( val, "frame0_self_contained_flag" ); sei.m_frame0SelfContainedFlag = val; 576 READ_FLAG( val, "frame1_self_contained_flag" ); sei.m_frame1SelfContainedFlag = val; 627 628 sei_read_flag( pDecodedMessageOutputStream, val, "quincunx_sampling_flag" ); sei.m_quincunxSamplingFlag = val; 629 630 sei_read_code( pDecodedMessageOutputStream, 6, val, "content_interpretation_type" ); sei.m_contentInterpretationType = val; 631 sei_read_flag( pDecodedMessageOutputStream, val, "spatial_flipping_flag" ); sei.m_spatialFlippingFlag = val; 632 sei_read_flag( pDecodedMessageOutputStream, val, "frame0_flipped_flag" ); sei.m_frame0FlippedFlag = val; 633 sei_read_flag( pDecodedMessageOutputStream, val, "field_views_flag" ); sei.m_fieldViewsFlag = val; 634 sei_read_flag( pDecodedMessageOutputStream, val, "current_frame_is_frame0_flag" ); sei.m_currentFrameIsFrame0Flag = val; 635 sei_read_flag( pDecodedMessageOutputStream, val, "frame0_self_contained_flag" ); sei.m_frame0SelfContainedFlag = val; 636 sei_read_flag( pDecodedMessageOutputStream, val, "frame1_self_contained_flag" ); sei.m_frame1SelfContainedFlag = val; 577 637 578 638 if ( sei.m_quincunxSamplingFlag == 0 && sei.m_arrangementType != 5) 579 639 { 580 READ_CODE( 4, val, "frame0_grid_position_x" ); sei.m_frame0GridPositionX = val; 581 READ_CODE( 4, val, "frame0_grid_position_y" ); sei.m_frame0GridPositionY = val; 582 READ_CODE( 4, val, "frame1_grid_position_x" ); sei.m_frame1GridPositionX = val; 583 READ_CODE( 4, val, "frame1_grid_position_y" ); sei.m_frame1GridPositionY = val; 584 } 585 586 READ_CODE( 8, val, "frame_packing_arrangement_reserved_byte" ); sei.m_arrangementReservedByte = val; 587 READ_FLAG( val, "frame_packing_arrangement_persistence_flag" ); sei.m_arrangementPersistenceFlag = val ? true : false; 588 } 589 READ_FLAG( val, "upsampled_aspect_ratio" ); sei.m_upsampledAspectRatio = val; 590 591 xParseByteAlign(); 592 } 593 594 Void SEIReader::xParseSEIDisplayOrientation(SEIDisplayOrientation& sei, UInt /*payloadSize*/) 640 sei_read_code( pDecodedMessageOutputStream, 4, val, "frame0_grid_position_x" ); sei.m_frame0GridPositionX = val; 641 sei_read_code( pDecodedMessageOutputStream, 4, val, "frame0_grid_position_y" ); sei.m_frame0GridPositionY = val; 642 sei_read_code( pDecodedMessageOutputStream, 4, val, "frame1_grid_position_x" ); sei.m_frame1GridPositionX = val; 643 sei_read_code( pDecodedMessageOutputStream, 4, val, "frame1_grid_position_y" ); sei.m_frame1GridPositionY = val; 644 } 645 646 sei_read_code( pDecodedMessageOutputStream, 8, val, "frame_packing_arrangement_reserved_byte" ); sei.m_arrangementReservedByte = val; 647 sei_read_flag( pDecodedMessageOutputStream, val, "frame_packing_arrangement_persistence_flag" ); sei.m_arrangementPersistenceFlag = (val != 0); 648 } 649 sei_read_flag( pDecodedMessageOutputStream, val, "upsampled_aspect_ratio_flag" ); sei.m_upsampledAspectRatio = val; 650 } 651 652 Void SEIReader::xParseSEISegmentedRectFramePacking(SEISegmentedRectFramePacking& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) 595 653 { 596 654 UInt val; 597 READ_FLAG( val, "display_orientation_cancel_flag" ); sei.cancelFlag = val; 598 if( !sei.cancelFlag ) 599 { 600 READ_FLAG( val, "hor_flip" ); sei.horFlip = val; 601 READ_FLAG( val, "ver_flip" ); sei.verFlip = val; 602 READ_CODE( 16, val, "anticlockwise_rotation" ); sei.anticlockwiseRotation = val; 603 READ_FLAG( val, "display_orientation_persistence_flag" ); sei.persistenceFlag = val; 604 } 605 xParseByteAlign(); 606 } 607 608 Void SEIReader::xParseSEITemporalLevel0Index(SEITemporalLevel0Index& sei, UInt /*payloadSize*/) 655 output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); 656 sei_read_flag( pDecodedMessageOutputStream, val, "segmented_rect_frame_packing_arrangement_cancel_flag" ); sei.m_arrangementCancelFlag = val; 657 if( !sei.m_arrangementCancelFlag ) 658 { 659 sei_read_code( pDecodedMessageOutputStream, 2, val, "segmented_rect_content_interpretation_type" ); sei.m_contentInterpretationType = val; 660 sei_read_flag( pDecodedMessageOutputStream, val, "segmented_rect_frame_packing_arrangement_persistence" ); sei.m_arrangementPersistenceFlag = val; 661 } 662 } 663 664 Void SEIReader::xParseSEIDisplayOrientation(SEIDisplayOrientation& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) 609 665 { 610 666 UInt val; 611 READ_CODE ( 8, val, "tl0_idx" ); sei.tl0Idx = val; 612 READ_CODE ( 8, val, "rap_idx" ); sei.rapIdx = val; 613 xParseByteAlign(); 614 } 615 616 Void SEIReader::xParseSEIGradualDecodingRefreshInfo(SEIGradualDecodingRefreshInfo& sei, UInt /*payloadSize*/) 667 output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); 668 sei_read_flag( pDecodedMessageOutputStream, val, "display_orientation_cancel_flag" ); sei.cancelFlag = val; 669 if( !sei.cancelFlag ) 670 { 671 sei_read_flag( pDecodedMessageOutputStream, val, "hor_flip" ); sei.horFlip = val; 672 sei_read_flag( pDecodedMessageOutputStream, val, "ver_flip" ); sei.verFlip = val; 673 sei_read_code( pDecodedMessageOutputStream, 16, val, "anticlockwise_rotation" ); sei.anticlockwiseRotation = val; 674 sei_read_flag( pDecodedMessageOutputStream, val, "display_orientation_persistence_flag" ); sei.persistenceFlag = val; 675 } 676 } 677 678 Void SEIReader::xParseSEITemporalLevel0Index(SEITemporalLevel0Index& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) 617 679 { 618 680 UInt val; 619 READ_FLAG( val, "gdr_foreground_flag" ); sei.m_gdrForegroundFlag = val ? 1 : 0; 620 xParseByteAlign(); 621 } 622 623 Void SEIReader::xParseSEIToneMappingInfo(SEIToneMappingInfo& sei, UInt /*payloadSize*/) 681 output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); 682 sei_read_code( pDecodedMessageOutputStream, 8, val, "temporal_sub_layer_zero_idx" ); sei.tl0Idx = val; 683 sei_read_code( pDecodedMessageOutputStream, 8, val, "irap_pic_id" ); sei.rapIdx = val; 684 } 685 686 Void SEIReader::xParseSEIRegionRefreshInfo(SEIGradualDecodingRefreshInfo& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) 687 { 688 UInt val; 689 output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); 690 sei_read_flag( pDecodedMessageOutputStream, val, "refreshed_region_flag" ); sei.m_gdrForegroundFlag = val ? 1 : 0; 691 } 692 693 Void SEIReader::xParseSEINoDisplay(SEINoDisplay& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) 694 { 695 output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); 696 sei.m_noDisplay = true; 697 } 698 699 Void SEIReader::xParseSEIToneMappingInfo(SEIToneMappingInfo& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) 624 700 { 625 701 Int i; 626 702 UInt val; 627 READ_UVLC( val, "tone_map_id" ); sei.m_toneMapId = val; 628 READ_FLAG( val, "tone_map_cancel_flag" ); sei.m_toneMapCancelFlag = val; 703 output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); 704 sei_read_uvlc( pDecodedMessageOutputStream, val, "tone_map_id" ); sei.m_toneMapId = val; 705 sei_read_flag( pDecodedMessageOutputStream, val, "tone_map_cancel_flag" ); sei.m_toneMapCancelFlag = val; 629 706 630 707 if ( !sei.m_toneMapCancelFlag ) 631 708 { 632 READ_FLAG( val, "tone_map_persistence_flag" ); sei.m_toneMapPersistenceFlag = val;633 READ_CODE(8, val, "coded_data_bit_depth" ); sei.m_codedDataBitDepth = val;634 READ_CODE(8, val, "target_bit_depth" ); sei.m_targetBitDepth = val;635 READ_UVLC( val, "model_id" ); sei.m_modelId = val;709 sei_read_flag( pDecodedMessageOutputStream, val, "tone_map_persistence_flag" ); sei.m_toneMapPersistenceFlag = val; 710 sei_read_code( pDecodedMessageOutputStream, 8, val, "coded_data_bit_depth" ); sei.m_codedDataBitDepth = val; 711 sei_read_code( pDecodedMessageOutputStream, 8, val, "target_bit_depth" ); sei.m_targetBitDepth = val; 712 sei_read_uvlc( pDecodedMessageOutputStream, val, "tone_map_model_id" ); sei.m_modelId = val; 636 713 switch(sei.m_modelId) 637 714 { 638 715 case 0: 639 716 { 640 READ_CODE(32, val, "min_value" ); sei.m_minValue = val;641 READ_CODE(32, val, "max_value" ); sei.m_maxValue = val;717 sei_read_code( pDecodedMessageOutputStream, 32, val, "min_value" ); sei.m_minValue = val; 718 sei_read_code( pDecodedMessageOutputStream, 32, val, "max_value" ); sei.m_maxValue = val; 642 719 break; 643 720 } 644 721 case 1: 645 722 { 646 READ_CODE(32, val, "sigmoid_midpoint" ); sei.m_sigmoidMidpoint = val;647 READ_CODE(32, val, "sigmoid_width" ); sei.m_sigmoidWidth = val;723 sei_read_code( pDecodedMessageOutputStream, 32, val, "sigmoid_midpoint" ); sei.m_sigmoidMidpoint = val; 724 sei_read_code( pDecodedMessageOutputStream, 32, val, "sigmoid_width" ); sei.m_sigmoidWidth = val; 648 725 break; 649 726 } … … 654 731 for(i = 0; i < num; i++) 655 732 { 656 READ_CODE( ((( sei.m_codedDataBitDepth + 7 ) >> 3 ) << 3), val, "start_of_coded_interval" );733 sei_read_code( pDecodedMessageOutputStream, ((( sei.m_codedDataBitDepth + 7 ) >> 3 ) << 3), val, "start_of_coded_interval[i]" ); 657 734 sei.m_startOfCodedInterval[i] = val; 658 735 } … … 662 739 case 3: 663 740 { 664 READ_CODE(16, val, "num_pivots" ); sei.m_numPivots = val;741 sei_read_code( pDecodedMessageOutputStream, 16, val, "num_pivots" ); sei.m_numPivots = val; 665 742 sei.m_codedPivotValue.resize(sei.m_numPivots); 666 743 sei.m_targetPivotValue.resize(sei.m_numPivots); 667 744 for(i = 0; i < sei.m_numPivots; i++ ) 668 745 { 669 READ_CODE( ((( sei.m_codedDataBitDepth + 7 ) >> 3 ) << 3), val, "coded_pivot_value" );746 sei_read_code( pDecodedMessageOutputStream, ((( sei.m_codedDataBitDepth + 7 ) >> 3 ) << 3), val, "coded_pivot_value[i]" ); 670 747 sei.m_codedPivotValue[i] = val; 671 READ_CODE( ((( sei.m_targetBitDepth + 7 ) >> 3 ) << 3), val, "target_pivot_value" );748 sei_read_code( pDecodedMessageOutputStream, ((( sei.m_targetBitDepth + 7 ) >> 3 ) << 3), val, "target_pivot_value[i]" ); 672 749 sei.m_targetPivotValue[i] = val; 673 750 } … … 676 753 case 4: 677 754 { 678 READ_CODE(8, val, "camera_iso_speed_idc" ); sei.m_cameraIsoSpeedIdc = val;755 sei_read_code( pDecodedMessageOutputStream, 8, val, "camera_iso_speed_idc" ); sei.m_cameraIsoSpeedIdc = val; 679 756 if( sei.m_cameraIsoSpeedIdc == 255) //Extended_ISO 680 757 { 681 READ_CODE(32, val, "camera_iso_speed_value" ); sei.m_cameraIsoSpeedValue = val;682 } 683 READ_CODE(8, val, "exposure_index_idc" ); sei.m_exposureIndexIdc = val;758 sei_read_code( pDecodedMessageOutputStream, 32, val, "camera_iso_speed_value" ); sei.m_cameraIsoSpeedValue = val; 759 } 760 sei_read_code( pDecodedMessageOutputStream, 8, val, "exposure_index_idc" ); sei.m_exposureIndexIdc = val; 684 761 if( sei.m_exposureIndexIdc == 255) //Extended_ISO 685 762 { 686 READ_CODE(32, val, "exposure_index_value" ); sei.m_exposureIndexValue = val;687 } 688 READ_FLAG(val, "exposure_compensation_value_sign_flag" ); sei.m_exposureCompensationValueSignFlag = val;689 READ_CODE(16, val, "exposure_compensation_value_numerator" ); sei.m_exposureCompensationValueNumerator = val;690 READ_CODE(16, val, "exposure_compensation_value_denom_idc" ); sei.m_exposureCompensationValueDenomIdc = val;691 READ_CODE(32, val, "ref_screen_luminance_white" ); sei.m_refScreenLuminanceWhite = val;692 READ_CODE(32, val, "extended_range_white_level" ); sei.m_extendedRangeWhiteLevel = val;693 READ_CODE( 16, val, "nominal_black_level_luma_code_value" );sei.m_nominalBlackLevelLumaCodeValue = val;694 READ_CODE( 16, val, "nominal_white_level_luma_code_value" );sei.m_nominalWhiteLevelLumaCodeValue= val;695 READ_CODE( 16, val, "extended_white_level_luma_code_value" );sei.m_extendedWhiteLevelLumaCodeValue = val;763 sei_read_code( pDecodedMessageOutputStream, 32, val, "exposure_index_value" ); sei.m_exposureIndexValue = val; 764 } 765 sei_read_flag( pDecodedMessageOutputStream, val, "exposure_compensation_value_sign_flag" ); sei.m_exposureCompensationValueSignFlag = val; 766 sei_read_code( pDecodedMessageOutputStream, 16, val, "exposure_compensation_value_numerator" ); sei.m_exposureCompensationValueNumerator = val; 767 sei_read_code( pDecodedMessageOutputStream, 16, val, "exposure_compensation_value_denom_idc" ); sei.m_exposureCompensationValueDenomIdc = val; 768 sei_read_code( pDecodedMessageOutputStream, 32, val, "ref_screen_luminance_white" ); sei.m_refScreenLuminanceWhite = val; 769 sei_read_code( pDecodedMessageOutputStream, 32, val, "extended_range_white_level" ); sei.m_extendedRangeWhiteLevel = val; 770 sei_read_code( pDecodedMessageOutputStream, 16, val, "nominal_black_level_code_value" ); sei.m_nominalBlackLevelLumaCodeValue = val; 771 sei_read_code( pDecodedMessageOutputStream, 16, val, "nominal_white_level_code_value" ); sei.m_nominalWhiteLevelLumaCodeValue= val; 772 sei_read_code( pDecodedMessageOutputStream, 16, val, "extended_white_level_code_value" ); sei.m_extendedWhiteLevelLumaCodeValue = val; 696 773 break; 697 774 } … … 702 779 } 703 780 }//switch model id 704 }// if(!sei.m_toneMapCancelFlag) 705 706 xParseByteAlign(); 707 } 708 709 Void SEIReader::xParseSEISOPDescription(SEISOPDescription &sei, UInt payloadSize) 781 }// if(!sei.m_toneMapCancelFlag) 782 } 783 784 Void SEIReader::xParseSEISOPDescription(SEISOPDescription &sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) 710 785 { 711 786 Int iCode; 712 787 UInt uiCode; 713 714 READ_UVLC( uiCode, "sop_seq_parameter_set_id" ); sei.m_sopSeqParameterSetId = uiCode; 715 READ_UVLC( uiCode, "num_pics_in_sop_minus1" ); sei.m_numPicsInSopMinus1 = uiCode; 788 output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); 789 790 sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "sop_seq_parameter_set_id" ); sei.m_sopSeqParameterSetId = uiCode; 791 sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "num_pics_in_sop_minus1" ); sei.m_numPicsInSopMinus1 = uiCode; 716 792 for (UInt i = 0; i <= sei.m_numPicsInSopMinus1; i++) 717 793 { 718 READ_CODE( 6, uiCode, "sop_desc_vcl_nalu_type" ); sei.m_sopDescVclNaluType[i] = uiCode;719 READ_CODE( 3, sei.m_sopDescTemporalId[i], "sop_desc_temporal_id" ); sei.m_sopDescTemporalId[i] = uiCode;794 sei_read_code( pDecodedMessageOutputStream, 6, uiCode, "sop_vcl_nut[i]" ); sei.m_sopDescVclNaluType[i] = uiCode; 795 sei_read_code( pDecodedMessageOutputStream, 3, sei.m_sopDescTemporalId[i], "sop_temporal_id[i]" ); sei.m_sopDescTemporalId[i] = uiCode; 720 796 if (sei.m_sopDescVclNaluType[i] != NAL_UNIT_CODED_SLICE_IDR_W_RADL && sei.m_sopDescVclNaluType[i] != NAL_UNIT_CODED_SLICE_IDR_N_LP) 721 797 { 722 READ_UVLC( sei.m_sopDescStRpsIdx[i], "sop_desc_st_rps_idx" ); sei.m_sopDescStRpsIdx[i] = uiCode;798 sei_read_uvlc( pDecodedMessageOutputStream, sei.m_sopDescStRpsIdx[i], "sop_short_term_rps_idx[i]" ); sei.m_sopDescStRpsIdx[i] = uiCode; 723 799 } 724 800 if (i > 0) 725 801 { 726 READ_SVLC( iCode, "sop_desc_poc_delta" ); sei.m_sopDescPocDelta[i] = iCode; 727 } 728 } 729 730 xParseByteAlign(); 731 } 732 733 Void SEIReader::xParseSEIScalableNesting(SEIScalableNesting& sei, const NalUnitType nalUnitType, UInt payloadSize, TComSPS *sps) 802 sei_read_svlc( pDecodedMessageOutputStream, iCode, "sop_poc_delta[i]" ); sei.m_sopDescPocDelta[i] = iCode; 803 } 804 } 805 } 806 807 Void SEIReader::xParseSEIScalableNesting(SEIScalableNesting& sei, const NalUnitType nalUnitType, UInt payloadSize, const TComSPS *sps, std::ostream *pDecodedMessageOutputStream) 734 808 { 735 809 UInt uiCode; 736 810 SEIMessages seis; 737 738 READ_FLAG( uiCode, "bitstream_subset_flag" ); sei.m_bitStreamSubsetFlag = uiCode; 739 READ_FLAG( uiCode, "nesting_op_flag" ); sei.m_nestingOpFlag = uiCode; 811 output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); 812 813 sei_read_flag( pDecodedMessageOutputStream, uiCode, "bitstream_subset_flag" ); sei.m_bitStreamSubsetFlag = uiCode; 814 sei_read_flag( pDecodedMessageOutputStream, uiCode, "nesting_op_flag" ); sei.m_nestingOpFlag = uiCode; 740 815 if (sei.m_nestingOpFlag) 741 816 { 742 READ_FLAG(uiCode, "default_op_flag" ); sei.m_defaultOpFlag = uiCode;743 READ_UVLC(uiCode, "nesting_num_ops_minus1" ); sei.m_nestingNumOpsMinus1 = uiCode;817 sei_read_flag( pDecodedMessageOutputStream, uiCode, "default_op_flag" ); sei.m_defaultOpFlag = uiCode; 818 sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "nesting_num_ops_minus1" ); sei.m_nestingNumOpsMinus1 = uiCode; 744 819 for (UInt i = sei.m_defaultOpFlag; i <= sei.m_nestingNumOpsMinus1; i++) 745 820 { 746 READ_CODE( 3, uiCode, "nesting_max_temporal_id_plus1" ); sei.m_nestingMaxTemporalIdPlus1[i] = uiCode;747 READ_UVLC( uiCode, "nesting_op_idx" ); sei.m_nestingOpIdx[i] = uiCode;821 sei_read_code( pDecodedMessageOutputStream, 3, uiCode, "nesting_max_temporal_id_plus1[i]" ); sei.m_nestingMaxTemporalIdPlus1[i] = uiCode; 822 sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "nesting_op_idx[i]" ); sei.m_nestingOpIdx[i] = uiCode; 748 823 } 749 824 } 750 825 else 751 826 { 752 READ_FLAG(uiCode, "all_layers_flag" ); sei.m_allLayersFlag = uiCode;827 sei_read_flag( pDecodedMessageOutputStream, uiCode, "all_layers_flag" ); sei.m_allLayersFlag = uiCode; 753 828 if (!sei.m_allLayersFlag) 754 829 { 755 READ_CODE(3, uiCode, "nesting_no_op_max_temporal_id_plus1" ); sei.m_nestingNoOpMaxTemporalIdPlus1 = uiCode;756 READ_UVLC(uiCode, "nesting_num_layers_minus1" ); sei.m_nestingNumLayersMinus1 = uiCode;830 sei_read_code( pDecodedMessageOutputStream, 3, uiCode, "nesting_no_op_max_temporal_id_plus1" ); sei.m_nestingNoOpMaxTemporalIdPlus1 = uiCode; 831 sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "nesting_num_layers_minus1" ); sei.m_nestingNumLayersMinus1 = uiCode; 757 832 for (UInt i = 0; i <= sei.m_nestingNumLayersMinus1; i++) 758 833 { 759 READ_CODE( 6, uiCode, "nesting_layer_id" ); sei.m_nestingLayerId[i] = uiCode;834 sei_read_code( pDecodedMessageOutputStream, 6, uiCode, "nesting_layer_id[i]" ); sei.m_nestingLayerId[i] = uiCode; 760 835 } 761 836 } … … 766 841 { 767 842 UInt code; 768 READ_FLAG( code, "nesting_zero_bit" ); 769 } 770 771 sei.m_callerOwnsSEIs = false; 843 sei_read_flag( pDecodedMessageOutputStream, code, "nesting_zero_bit" ); 844 } 772 845 773 846 // read nested SEI messages 774 do { 775 xReadSEImessage(sei.m_nestedSEIs, nalUnitType, sps); 847 do 848 { 849 xReadSEImessage(sei.m_nestedSEIs, nalUnitType, sps, pDecodedMessageOutputStream); 776 850 } while (m_pcBitstream->getNumBitsLeft() > 8); 777 851 778 } 779 #if H_MV 780 Void SEIReader::xParseSEISubBitstreamProperty(SEISubBitstreamProperty &sei) 781 { 782 UInt uiCode; 783 READ_CODE( 4, uiCode, "active_vps_id" ); sei.m_activeVpsId = uiCode; 784 READ_UVLC( uiCode, "num_additional_sub_streams_minus1" ); sei.m_numAdditionalSubStreams = uiCode + 1; 852 if (pDecodedMessageOutputStream) 853 { 854 (*pDecodedMessageOutputStream) << "End of scalable nesting SEI message\n"; 855 } 856 } 857 858 #if NH_MV 859 Void SEIReader::xParseSEISubBitstreamProperty(SEISubBitstreamProperty &sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream ) 860 { 861 UInt code; 862 output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); 863 sei_read_code( pDecodedMessageOutputStream, 4, code, "active_vps_id" ); sei.m_activeVpsId = code; 864 sei_read_uvlc( pDecodedMessageOutputStream, code, "num_additional_sub_streams_minus1" ); sei.m_numAdditionalSubStreams = code + 1; 785 865 786 866 xResizeSubBitstreamPropertySeiArrays(sei); 787 867 for( Int i = 0; i < sei.m_numAdditionalSubStreams; i++ ) 788 868 { 789 READ_CODE( 2, uiCode, "sub_bitstream_mode[i]" ); sei.m_subBitstreamMode[i] = uiCode;790 READ_UVLC( uiCode, "output_layer_set_idx_to_vps[i]" ); sei.m_outputLayerSetIdxToVps[i] = uiCode;791 READ_CODE( 3, uiCode, "highest_sub_layer_id[i]" ); sei.m_highestSublayerId[i] = uiCode;792 READ_CODE( 16, uiCode, "avg_bit_rate[i]" ); sei.m_avgBitRate[i] = uiCode;793 READ_CODE( 16, uiCode, "max_bit_rate[i]" ); sei.m_maxBitRate[i] = uiCode;794 } 795 xParseByteAlign(); 796 } 869 sei_read_code( pDecodedMessageOutputStream, 2, code, "sub_bitstream_mode[i]" ); sei.m_subBitstreamMode[i] = code; 870 sei_read_uvlc( pDecodedMessageOutputStream, code, "output_layer_set_idx_to_vps[i]" ); sei.m_outputLayerSetIdxToVps[i] = code; 871 sei_read_code( pDecodedMessageOutputStream, 3, code, "highest_sub_layer_id[i]" ); sei.m_highestSublayerId[i] = code; 872 sei_read_code( pDecodedMessageOutputStream, 16, code, "avg_bit_rate[i]" ); sei.m_avgBitRate[i] = code; 873 sei_read_code( pDecodedMessageOutputStream, 16, code, "max_bit_rate[i]" ); sei.m_maxBitRate[i] = code; 874 } 875 } 876 797 877 Void SEIReader::xResizeSubBitstreamPropertySeiArrays(SEISubBitstreamProperty &sei) 798 878 { … … 805 885 #endif 806 886 807 Void SEIReader::xParseByteAlign() 887 888 Void SEIReader::xParseSEITempMotionConstraintsTileSets(SEITempMotionConstrainedTileSets& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) 808 889 { 809 890 UInt code; 810 if( m_pcBitstream->getNumBitsRead() % 8 != 0 ) 811 { 812 READ_FLAG( code, "bit_equal_to_one" ); assert( code == 1 ); 813 } 814 while( m_pcBitstream->getNumBitsRead() % 8 != 0 ) 815 { 816 READ_FLAG( code, "bit_equal_to_zero" ); assert( code == 0 ); 817 } 818 } 891 output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); 892 sei_read_flag( pDecodedMessageOutputStream, code, "mc_all_tiles_exact_sample_value_match_flag"); sei.m_mc_all_tiles_exact_sample_value_match_flag = (code != 0); 893 sei_read_flag( pDecodedMessageOutputStream, code, "each_tile_one_tile_set_flag"); sei.m_each_tile_one_tile_set_flag = (code != 0); 894 895 if(!sei.m_each_tile_one_tile_set_flag) 896 { 897 sei_read_flag( pDecodedMessageOutputStream, code, "limited_tile_set_display_flag"); sei.m_limited_tile_set_display_flag = (code != 0); 898 sei_read_uvlc( pDecodedMessageOutputStream, code, "num_sets_in_message_minus1"); sei.setNumberOfTileSets(code + 1); 899 900 if(sei.getNumberOfTileSets() != 0) 901 { 902 for(Int i = 0; i < sei.getNumberOfTileSets(); i++) 903 { 904 sei_read_uvlc( pDecodedMessageOutputStream, code, "mcts_id"); sei.tileSetData(i).m_mcts_id = code; 905 906 if(sei.m_limited_tile_set_display_flag) 907 { 908 sei_read_flag( pDecodedMessageOutputStream, code, "display_tile_set_flag"); sei.tileSetData(i).m_display_tile_set_flag = (code != 1); 909 } 910 911 sei_read_uvlc( pDecodedMessageOutputStream, code, "num_tile_rects_in_set_minus1"); sei.tileSetData(i).setNumberOfTileRects(code + 1); 912 913 for(Int j=0; j<sei.tileSetData(i).getNumberOfTileRects(); j++) 914 { 915 sei_read_uvlc( pDecodedMessageOutputStream, code, "top_left_tile_index"); sei.tileSetData(i).topLeftTileIndex(j) = code; 916 sei_read_uvlc( pDecodedMessageOutputStream, code, "bottom_right_tile_index"); sei.tileSetData(i).bottomRightTileIndex(j) = code; 917 } 918 919 if(!sei.m_mc_all_tiles_exact_sample_value_match_flag) 920 { 921 sei_read_flag( pDecodedMessageOutputStream, code, "exact_sample_value_match_flag"); sei.tileSetData(i).m_exact_sample_value_match_flag = (code != 0); 922 } 923 sei_read_flag( pDecodedMessageOutputStream, code, "mcts_tier_level_idc_present_flag"); sei.tileSetData(i).m_mcts_tier_level_idc_present_flag = (code != 0); 924 925 if(sei.tileSetData(i).m_mcts_tier_level_idc_present_flag) 926 { 927 sei_read_flag( pDecodedMessageOutputStream, code, "mcts_tier_flag"); sei.tileSetData(i).m_mcts_tier_flag = (code != 0); 928 sei_read_code( pDecodedMessageOutputStream, 8, code, "mcts_level_idc"); sei.tileSetData(i).m_mcts_level_idc = code; 929 } 930 } 931 } 932 } 933 else 934 { 935 sei_read_flag( pDecodedMessageOutputStream, code, "max_mcs_tier_level_idc_present_flag"); sei.m_max_mcs_tier_level_idc_present_flag = code; 936 if(sei.m_max_mcs_tier_level_idc_present_flag) 937 { 938 sei_read_flag( pDecodedMessageOutputStream, code, "max_mcts_tier_flag"); sei.m_max_mcts_tier_flag = code; 939 sei_read_code( pDecodedMessageOutputStream, 8, code, "max_mcts_level_idc"); sei.m_max_mcts_level_idc = code; 940 } 941 } 942 } 943 944 Void SEIReader::xParseSEITimeCode(SEITimeCode& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) 945 { 946 UInt code; 947 output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); 948 sei_read_code( pDecodedMessageOutputStream, 2, code, "num_clock_ts"); sei.numClockTs = code; 949 for(Int i = 0; i < sei.numClockTs; i++) 950 { 951 TComSEITimeSet currentTimeSet; 952 sei_read_flag( pDecodedMessageOutputStream, code, "clock_time_stamp_flag[i]"); currentTimeSet.clockTimeStampFlag = code; 953 if(currentTimeSet.clockTimeStampFlag) 954 { 955 sei_read_flag( pDecodedMessageOutputStream, code, "nuit_field_based_flag"); currentTimeSet.numUnitFieldBasedFlag = code; 956 sei_read_code( pDecodedMessageOutputStream, 5, code, "counting_type"); currentTimeSet.countingType = code; 957 sei_read_flag( pDecodedMessageOutputStream, code, "full_timestamp_flag"); currentTimeSet.fullTimeStampFlag = code; 958 sei_read_flag( pDecodedMessageOutputStream, code, "discontinuity_flag"); currentTimeSet.discontinuityFlag = code; 959 sei_read_flag( pDecodedMessageOutputStream, code, "cnt_dropped_flag"); currentTimeSet.cntDroppedFlag = code; 960 sei_read_code( pDecodedMessageOutputStream, 9, code, "n_frames"); currentTimeSet.numberOfFrames = code; 961 if(currentTimeSet.fullTimeStampFlag) 962 { 963 sei_read_code( pDecodedMessageOutputStream, 6, code, "seconds_value"); currentTimeSet.secondsValue = code; 964 sei_read_code( pDecodedMessageOutputStream, 6, code, "minutes_value"); currentTimeSet.minutesValue = code; 965 sei_read_code( pDecodedMessageOutputStream, 5, code, "hours_value"); currentTimeSet.hoursValue = code; 966 } 967 else 968 { 969 sei_read_flag( pDecodedMessageOutputStream, code, "seconds_flag"); currentTimeSet.secondsFlag = code; 970 if(currentTimeSet.secondsFlag) 971 { 972 sei_read_code( pDecodedMessageOutputStream, 6, code, "seconds_value"); currentTimeSet.secondsValue = code; 973 sei_read_flag( pDecodedMessageOutputStream, code, "minutes_flag"); currentTimeSet.minutesFlag = code; 974 if(currentTimeSet.minutesFlag) 975 { 976 sei_read_code( pDecodedMessageOutputStream, 6, code, "minutes_value"); currentTimeSet.minutesValue = code; 977 sei_read_flag( pDecodedMessageOutputStream, code, "hours_flag"); currentTimeSet.hoursFlag = code; 978 if(currentTimeSet.hoursFlag) 979 { 980 sei_read_code( pDecodedMessageOutputStream, 5, code, "hours_value"); currentTimeSet.hoursValue = code; 981 } 982 } 983 } 984 } 985 sei_read_code( pDecodedMessageOutputStream, 5, code, "time_offset_length"); currentTimeSet.timeOffsetLength = code; 986 if(currentTimeSet.timeOffsetLength > 0) 987 { 988 sei_read_code( pDecodedMessageOutputStream, currentTimeSet.timeOffsetLength, code, "time_offset_value"); 989 if((code & (1 << (currentTimeSet.timeOffsetLength-1))) == 0) 990 { 991 currentTimeSet.timeOffsetValue = code; 992 } 993 else 994 { 995 code &= (1<< (currentTimeSet.timeOffsetLength-1)) - 1; 996 currentTimeSet.timeOffsetValue = ~code + 1; 997 } 998 } 999 } 1000 sei.timeSetArray[i] = currentTimeSet; 1001 } 1002 } 1003 1004 Void SEIReader::xParseSEIChromaSamplingFilterHint(SEIChromaSamplingFilterHint& sei, UInt payloadSize/*, TComSPS* sps*/, std::ostream *pDecodedMessageOutputStream) 1005 { 1006 UInt uiCode; 1007 output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); 1008 1009 sei_read_code( pDecodedMessageOutputStream, 8, uiCode, "ver_chroma_filter_idc"); sei.m_verChromaFilterIdc = uiCode; 1010 sei_read_code( pDecodedMessageOutputStream, 8, uiCode, "hor_chroma_filter_idc"); sei.m_horChromaFilterIdc = uiCode; 1011 sei_read_flag( pDecodedMessageOutputStream, uiCode, "ver_filtering_process_flag"); sei.m_verFilteringProcessFlag = uiCode; 1012 if(sei.m_verChromaFilterIdc == 1 || sei.m_horChromaFilterIdc == 1) 1013 { 1014 sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "target_format_idc"); sei.m_targetFormatIdc = uiCode; 1015 if(sei.m_verChromaFilterIdc == 1) 1016 { 1017 sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "num_vertical_filters"); sei.m_numVerticalFilters = uiCode; 1018 if(sei.m_numVerticalFilters > 0) 1019 { 1020 sei.m_verTapLengthMinus1 = (Int*)malloc(sei.m_numVerticalFilters * sizeof(Int)); 1021 sei.m_verFilterCoeff = (Int**)malloc(sei.m_numVerticalFilters * sizeof(Int*)); 1022 for(Int i = 0; i < sei.m_numVerticalFilters; i ++) 1023 { 1024 sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "ver_tap_length_minus_1"); sei.m_verTapLengthMinus1[i] = uiCode; 1025 sei.m_verFilterCoeff[i] = (Int*)malloc(sei.m_verTapLengthMinus1[i] * sizeof(Int)); 1026 for(Int j = 0; j < sei.m_verTapLengthMinus1[i]; j ++) 1027 { 1028 sei_read_svlc( pDecodedMessageOutputStream, sei.m_verFilterCoeff[i][j], "ver_filter_coeff"); 1029 } 1030 } 1031 } 1032 } 1033 if(sei.m_horChromaFilterIdc == 1) 1034 { 1035 sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "num_horizontal_filters"); sei.m_numHorizontalFilters = uiCode; 1036 if(sei.m_numHorizontalFilters > 0) 1037 { 1038 sei.m_horTapLengthMinus1 = (Int*)malloc(sei.m_numHorizontalFilters * sizeof(Int)); 1039 sei.m_horFilterCoeff = (Int**)malloc(sei.m_numHorizontalFilters * sizeof(Int*)); 1040 for(Int i = 0; i < sei.m_numHorizontalFilters; i ++) 1041 { 1042 sei_read_uvlc( pDecodedMessageOutputStream, uiCode, "hor_tap_length_minus_1"); sei.m_horTapLengthMinus1[i] = uiCode; 1043 sei.m_horFilterCoeff[i] = (Int*)malloc(sei.m_horTapLengthMinus1[i] * sizeof(Int)); 1044 for(Int j = 0; j < sei.m_horTapLengthMinus1[i]; j ++) 1045 { 1046 sei_read_svlc( pDecodedMessageOutputStream, sei.m_horFilterCoeff[i][j], "hor_filter_coeff"); 1047 } 1048 } 1049 } 1050 } 1051 } 1052 } 1053 1054 Void SEIReader::xParseSEIKneeFunctionInfo(SEIKneeFunctionInfo& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) 1055 { 1056 Int i; 1057 UInt val; 1058 output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); 1059 1060 sei_read_uvlc( pDecodedMessageOutputStream, val, "knee_function_id" ); sei.m_kneeId = val; 1061 sei_read_flag( pDecodedMessageOutputStream, val, "knee_function_cancel_flag" ); sei.m_kneeCancelFlag = val; 1062 if ( !sei.m_kneeCancelFlag ) 1063 { 1064 sei_read_flag( pDecodedMessageOutputStream, val, "knee_function_persistence_flag" ); sei.m_kneePersistenceFlag = val; 1065 sei_read_code( pDecodedMessageOutputStream, 32, val, "input_d_range" ); sei.m_kneeInputDrange = val; 1066 sei_read_code( pDecodedMessageOutputStream, 32, val, "input_disp_luminance" ); sei.m_kneeInputDispLuminance = val; 1067 sei_read_code( pDecodedMessageOutputStream, 32, val, "output_d_range" ); sei.m_kneeOutputDrange = val; 1068 sei_read_code( pDecodedMessageOutputStream, 32, val, "output_disp_luminance" ); sei.m_kneeOutputDispLuminance = val; 1069 sei_read_uvlc( pDecodedMessageOutputStream, val, "num_knee_points_minus1" ); sei.m_kneeNumKneePointsMinus1 = val; 1070 assert( sei.m_kneeNumKneePointsMinus1 > 0 ); 1071 sei.m_kneeInputKneePoint.resize(sei.m_kneeNumKneePointsMinus1+1); 1072 sei.m_kneeOutputKneePoint.resize(sei.m_kneeNumKneePointsMinus1+1); 1073 for(i = 0; i <= sei.m_kneeNumKneePointsMinus1; i++ ) 1074 { 1075 sei_read_code( pDecodedMessageOutputStream, 10, val, "input_knee_point" ); sei.m_kneeInputKneePoint[i] = val; 1076 sei_read_code( pDecodedMessageOutputStream, 10, val, "output_knee_point" ); sei.m_kneeOutputKneePoint[i] = val; 1077 } 1078 } 1079 } 1080 1081 Void SEIReader::xParseSEIMasteringDisplayColourVolume(SEIMasteringDisplayColourVolume& sei, UInt payloadSize, std::ostream *pDecodedMessageOutputStream) 1082 { 1083 UInt code; 1084 output_sei_message_header(sei, pDecodedMessageOutputStream, payloadSize); 1085 1086 sei_read_code( pDecodedMessageOutputStream, 16, code, "display_primaries_x[0]" ); sei.values.primaries[0][0] = code; 1087 sei_read_code( pDecodedMessageOutputStream, 16, code, "display_primaries_y[0]" ); sei.values.primaries[0][1] = code; 1088 1089 sei_read_code( pDecodedMessageOutputStream, 16, code, "display_primaries_x[1]" ); sei.values.primaries[1][0] = code; 1090 sei_read_code( pDecodedMessageOutputStream, 16, code, "display_primaries_y[1]" ); sei.values.primaries[1][1] = code; 1091 1092 sei_read_code( pDecodedMessageOutputStream, 16, code, "display_primaries_x[2]" ); sei.values.primaries[2][0] = code; 1093 sei_read_code( pDecodedMessageOutputStream, 16, code, "display_primaries_y[2]" ); sei.values.primaries[2][1] = code; 1094 1095 1096 sei_read_code( pDecodedMessageOutputStream, 16, code, "white_point_x" ); sei.values.whitePoint[0] = code; 1097 sei_read_code( pDecodedMessageOutputStream, 16, code, "white_point_y" ); sei.values.whitePoint[1] = code; 1098 1099 sei_read_code( pDecodedMessageOutputStream, 32, code, "max_display_mastering_luminance" ); sei.values.maxLuminance = code; 1100 sei_read_code( pDecodedMessageOutputStream, 32, code, "min_display_mastering_luminance" ); sei.values.minLuminance = code; 1101 } 1102 819 1103 //! \}
Note: See TracChangeset for help on using the changeset viewer.