Changeset 1313 in 3DVCSoftware for trunk/source/Lib/TLibEncoder/SEIwrite.cpp
- Timestamp:
- 13 Aug 2015, 17:38:13 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/source/Lib/TLibEncoder/SEIwrite.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 * … … 36 36 #include "TLibCommon/SEI.h" 37 37 #include "TLibCommon/TComSlice.h" 38 #include "TLibCommon/TComPicYuv.h" 38 39 #include "SEIwrite.h" 39 40 … … 49 50 Void xTraceSEIMessageType(SEI::PayloadType payloadType) 50 51 { 51 switch (payloadType) 52 { 53 case SEI::DECODED_PICTURE_HASH: 54 fprintf( g_hTrace, "=========== Decoded picture hash SEI message ===========\n"); 55 break; 56 case SEI::USER_DATA_UNREGISTERED: 57 fprintf( g_hTrace, "=========== User Data Unregistered SEI message ===========\n"); 58 break; 59 case SEI::ACTIVE_PARAMETER_SETS: 60 fprintf( g_hTrace, "=========== Active Parameter sets SEI message ===========\n"); 61 break; 62 case SEI::BUFFERING_PERIOD: 63 fprintf( g_hTrace, "=========== Buffering period SEI message ===========\n"); 64 break; 65 case SEI::PICTURE_TIMING: 66 fprintf( g_hTrace, "=========== Picture timing SEI message ===========\n"); 67 break; 68 case SEI::RECOVERY_POINT: 69 fprintf( g_hTrace, "=========== Recovery point SEI message ===========\n"); 70 break; 71 case SEI::FRAME_PACKING: 72 fprintf( g_hTrace, "=========== Frame Packing Arrangement SEI message ===========\n"); 73 break; 74 case SEI::DISPLAY_ORIENTATION: 75 fprintf( g_hTrace, "=========== Display Orientation SEI message ===========\n"); 76 break; 77 case SEI::TEMPORAL_LEVEL0_INDEX: 78 fprintf( g_hTrace, "=========== Temporal Level Zero Index SEI message ===========\n"); 79 break; 80 case SEI::REGION_REFRESH_INFO: 81 fprintf( g_hTrace, "=========== Gradual Decoding Refresh Information SEI message ===========\n"); 82 break; 83 case SEI::DECODING_UNIT_INFO: 84 fprintf( g_hTrace, "=========== Decoding Unit Information SEI message ===========\n"); 85 break; 86 case SEI::TONE_MAPPING_INFO: 87 fprintf( g_hTrace, "=========== Tone Mapping Info SEI message ===========\n"); 88 break; 89 case SEI::SOP_DESCRIPTION: 90 fprintf( g_hTrace, "=========== SOP Description SEI message ===========\n"); 91 break; 92 case SEI::SCALABLE_NESTING: 93 fprintf( g_hTrace, "=========== Scalable Nesting SEI message ===========\n"); 94 break; 95 #if H_MV 96 case SEI::SUB_BITSTREAM_PROPERTY: 97 fprintf( g_hTrace, "=========== Sub-bitstream property SEI message ===========\n"); 98 break; 52 fprintf( g_hTrace, "=========== %s SEI message ===========\n", SEI::getSEIMessageString(payloadType)); 53 } 99 54 #endif 100 default: 101 fprintf( g_hTrace, "=========== Unknown SEI message ===========\n"); 102 break; 103 } 104 } 105 #endif 106 107 void SEIWriter::xWriteSEIpayloadData(TComBitIf& bs, const SEI& sei, TComSPS *sps) 55 56 Void SEIWriter::xWriteSEIpayloadData(TComBitIf& bs, const SEI& sei, const TComSPS *sps) 108 57 { 109 58 switch (sei.payloadType()) … … 113 62 break; 114 63 case SEI::ACTIVE_PARAMETER_SETS: 115 xWriteSEIActiveParameterSets(*static_cast<const SEIActiveParameterSets*>(& sei)); 116 break; 64 xWriteSEIActiveParameterSets(*static_cast<const SEIActiveParameterSets*>(& sei)); 65 break; 117 66 case SEI::DECODING_UNIT_INFO: 118 67 xWriteSEIDecodingUnitInfo(*static_cast<const SEIDecodingUnitInfo*>(& sei), sps); … … 133 82 xWriteSEIFramePacking(*static_cast<const SEIFramePacking*>(&sei)); 134 83 break; 84 case SEI::SEGM_RECT_FRAME_PACKING: 85 xWriteSEISegmentedRectFramePacking(*static_cast<const SEISegmentedRectFramePacking*>(&sei)); 86 break; 135 87 case SEI::DISPLAY_ORIENTATION: 136 88 xWriteSEIDisplayOrientation(*static_cast<const SEIDisplayOrientation*>(&sei)); … … 142 94 xWriteSEIGradualDecodingRefreshInfo(*static_cast<const SEIGradualDecodingRefreshInfo*>(&sei)); 143 95 break; 96 case SEI::NO_DISPLAY: 97 xWriteSEINoDisplay(*static_cast<const SEINoDisplay*>(&sei)); 98 break; 144 99 case SEI::TONE_MAPPING_INFO: 145 100 xWriteSEIToneMappingInfo(*static_cast<const SEIToneMappingInfo*>(&sei)); … … 151 106 xWriteSEIScalableNesting(bs, *static_cast<const SEIScalableNesting*>(&sei), sps); 152 107 break; 153 #if H_MV 108 case SEI::CHROMA_SAMPLING_FILTER_HINT: 109 xWriteSEIChromaSamplingFilterHint(*static_cast<const SEIChromaSamplingFilterHint*>(&sei)/*, sps*/); 110 break; 111 case SEI::TEMP_MOTION_CONSTRAINED_TILE_SETS: 112 xWriteSEITempMotionConstrainedTileSets(*static_cast<const SEITempMotionConstrainedTileSets*>(&sei)); 113 break; 114 case SEI::TIME_CODE: 115 xWriteSEITimeCode(*static_cast<const SEITimeCode*>(&sei)); 116 break; 117 case SEI::KNEE_FUNCTION_INFO: 118 xWriteSEIKneeFunctionInfo(*static_cast<const SEIKneeFunctionInfo*>(&sei)); 119 break; 120 case SEI::MASTERING_DISPLAY_COLOUR_VOLUME: 121 xWriteSEIMasteringDisplayColourVolume(*static_cast<const SEIMasteringDisplayColourVolume*>(&sei)); 122 break; 123 #if NH_MV 154 124 case SEI::SUB_BITSTREAM_PROPERTY: 155 125 xWriteSEISubBitstreamProperty(*static_cast<const SEISubBitstreamProperty*>(&sei)); 156 126 break; 157 127 #endif 128 158 129 default: 159 130 assert(!"Unhandled SEI message"); 160 } 131 break; 132 } 133 xWriteByteAlign(); 161 134 } 162 135 163 136 /** 164 * marshal a single SEI message sei, storing the marshalled representation 165 * in bitstream bs. 137 * marshal all SEI messages in provided list into one bitstream bs 166 138 */ 167 Void SEIWriter::writeSEImessage(TComBitIf& bs, const SEI& sei, TComSPS *sps) 168 { 169 /* calculate how large the payload data is */ 170 /* TODO: this would be far nicer if it used vectored buffers */ 171 TComBitCounter bs_count; 172 bs_count.resetBits(); 173 setBitstream(&bs_count); 174 175 176 #if ENC_DEC_TRACE 177 Bool traceEnable = g_HLSTraceEnable; 178 g_HLSTraceEnable = false; 179 #endif 180 xWriteSEIpayloadData(bs_count, sei, sps); 181 #if ENC_DEC_TRACE 182 g_HLSTraceEnable = traceEnable; 183 #endif 184 185 UInt payload_data_num_bits = bs_count.getNumberOfWrittenBits(); 186 assert(0 == payload_data_num_bits % 8); 187 188 setBitstream(&bs); 189 139 Void SEIWriter::writeSEImessages(TComBitIf& bs, const SEIMessages &seiList, const TComSPS *sps, Bool isNested) 140 { 190 141 #if ENC_DEC_TRACE 191 142 if (g_HLSTraceEnable) 192 xTraceSEIHeader();143 xTraceSEIHeader(); 193 144 #endif 194 145 195 UInt payloadType = sei.payloadType(); 196 for (; payloadType >= 0xff; payloadType -= 0xff) 197 { 198 WRITE_CODE(0xff, 8, "payload_type"); 199 } 200 WRITE_CODE(payloadType, 8, "payload_type"); 201 202 UInt payloadSize = payload_data_num_bits/8; 203 for (; payloadSize >= 0xff; payloadSize -= 0xff) 204 { 205 WRITE_CODE(0xff, 8, "payload_size"); 206 } 207 WRITE_CODE(payloadSize, 8, "payload_size"); 208 209 /* payloadData */ 146 TComBitCounter bs_count; 147 148 for (SEIMessages::const_iterator sei=seiList.begin(); sei!=seiList.end(); sei++) 149 { 150 // calculate how large the payload data is 151 // TODO: this would be far nicer if it used vectored buffers 152 bs_count.resetBits(); 153 setBitstream(&bs_count); 154 210 155 #if ENC_DEC_TRACE 211 if (g_HLSTraceEnable)212 xTraceSEIMessageType(sei.payloadType());156 Bool traceEnable = g_HLSTraceEnable; 157 g_HLSTraceEnable = false; 213 158 #endif 214 215 xWriteSEIpayloadData(bs, sei, sps); 159 xWriteSEIpayloadData(bs_count, **sei, sps); 160 #if ENC_DEC_TRACE 161 g_HLSTraceEnable = traceEnable; 162 #endif 163 UInt payload_data_num_bits = bs_count.getNumberOfWrittenBits(); 164 assert(0 == payload_data_num_bits % 8); 165 166 setBitstream(&bs); 167 UInt payloadType = (*sei)->payloadType(); 168 for (; payloadType >= 0xff; payloadType -= 0xff) 169 { 170 WRITE_CODE(0xff, 8, "payload_type"); 171 } 172 WRITE_CODE(payloadType, 8, "payload_type"); 173 174 UInt payloadSize = payload_data_num_bits/8; 175 for (; payloadSize >= 0xff; payloadSize -= 0xff) 176 { 177 WRITE_CODE(0xff, 8, "payload_size"); 178 } 179 WRITE_CODE(payloadSize, 8, "payload_size"); 180 181 /* payloadData */ 182 #if ENC_DEC_TRACE 183 if (g_HLSTraceEnable) 184 xTraceSEIMessageType((*sei)->payloadType()); 185 #endif 186 187 xWriteSEIpayloadData(bs, **sei, sps); 188 } 189 if (!isNested) 190 { 191 xWriteRbspTrailingBits(); 192 } 216 193 } 217 194 … … 222 199 Void SEIWriter::xWriteSEIuserDataUnregistered(const SEIuserDataUnregistered &sei) 223 200 { 224 for (UInt i = 0; i < 16; i++)201 for (UInt i = 0; i < ISO_IEC_11578_LEN; i++) 225 202 { 226 203 WRITE_CODE(sei.uuid_iso_iec_11578[i], 8 , "sei.uuid_iso_iec_11578[i]"); … … 239 216 Void SEIWriter::xWriteSEIDecodedPictureHash(const SEIDecodedPictureHash& sei) 240 217 { 241 UInt val; 242 243 WRITE_CODE(sei.method, 8, "hash_type"); 244 245 for(Int yuvIdx = 0; yuvIdx < 3; yuvIdx++) 246 { 247 if(sei.method == SEIDecodedPictureHash::MD5) 248 { 249 for (UInt i = 0; i < 16; i++) 250 { 251 WRITE_CODE(sei.digest[yuvIdx][i], 8, "picture_md5"); 252 } 253 } 254 else if(sei.method == SEIDecodedPictureHash::CRC) 255 { 256 val = (sei.digest[yuvIdx][0] << 8) + sei.digest[yuvIdx][1]; 257 WRITE_CODE(val, 16, "picture_crc"); 258 } 259 else if(sei.method == SEIDecodedPictureHash::CHECKSUM) 260 { 261 val = (sei.digest[yuvIdx][0] << 24) + (sei.digest[yuvIdx][1] << 16) + (sei.digest[yuvIdx][2] << 8) + sei.digest[yuvIdx][3]; 262 WRITE_CODE(val, 32, "picture_checksum"); 218 const Char *traceString="\0"; 219 switch (sei.method) 220 { 221 case SEIDecodedPictureHash::MD5: traceString="picture_md5"; break; 222 case SEIDecodedPictureHash::CRC: traceString="picture_crc"; break; 223 case SEIDecodedPictureHash::CHECKSUM: traceString="picture_checksum"; break; 224 default: assert(false); break; 225 } 226 227 if (traceString != 0) //use of this variable is needed to avoid a compiler error with G++ 4.6.1 228 { 229 WRITE_CODE(sei.method, 8, "hash_type"); 230 for(UInt i=0; i<UInt(sei.m_pictureHash.hash.size()); i++) 231 { 232 WRITE_CODE(sei.m_pictureHash.hash[i], 8, traceString); 263 233 } 264 234 } … … 270 240 WRITE_FLAG(sei.m_selfContainedCvsFlag, "self_contained_cvs_flag"); 271 241 WRITE_FLAG(sei.m_noParameterSetUpdateFlag, "no_parameter_set_update_flag"); 272 WRITE_UVLC(sei.numSpsIdsMinus1, "num_sps_ids_minus1");242 WRITE_UVLC(sei.numSpsIdsMinus1, "num_sps_ids_minus1"); 273 243 274 244 assert (sei.activeSeqParameterSetId.size() == (sei.numSpsIdsMinus1 + 1)); 275 245 276 246 for (Int i = 0; i < sei.activeSeqParameterSetId.size(); i++) 277 247 { 278 248 WRITE_UVLC(sei.activeSeqParameterSetId[i], "active_seq_parameter_set_id"); 279 249 } 280 xWriteByteAlign(); 281 } 282 283 Void SEIWriter::xWriteSEIDecodingUnitInfo(const SEIDecodingUnitInfo& sei, TComSPS *sps) 284 { 285 TComVUI *vui = sps->getVuiParameters(); 250 } 251 252 Void SEIWriter::xWriteSEIDecodingUnitInfo(const SEIDecodingUnitInfo& sei, const TComSPS *sps) 253 { 254 const TComVUI *vui = sps->getVuiParameters(); 286 255 WRITE_UVLC(sei.m_decodingUnitIdx, "decoding_unit_idx"); 287 256 if(vui->getHrdParameters()->getSubPicCpbParamsInPicTimingSEIFlag()) 288 257 { 289 WRITE_CODE( sei.m_duSptCpbRemovalDelay, (vui->getHrdParameters()->getDuCpbRemovalDelayLengthMinus1() + 1), "du_spt_cpb_removal_delay ");258 WRITE_CODE( sei.m_duSptCpbRemovalDelay, (vui->getHrdParameters()->getDuCpbRemovalDelayLengthMinus1() + 1), "du_spt_cpb_removal_delay_increment"); 290 259 } 291 260 WRITE_FLAG( sei.m_dpbOutputDuDelayPresentFlag, "dpb_output_du_delay_present_flag"); … … 294 263 WRITE_CODE(sei.m_picSptDpbOutputDuDelay, vui->getHrdParameters()->getDpbOutputDelayDuLengthMinus1() + 1, "pic_spt_dpb_output_du_delay"); 295 264 } 296 xWriteByteAlign(); 297 } 298 299 Void SEIWriter::xWriteSEIBufferingPeriod(const SEIBufferingPeriod& sei, TComSPS *sps) 265 } 266 267 Void SEIWriter::xWriteSEIBufferingPeriod(const SEIBufferingPeriod& sei, const TComSPS *sps) 300 268 { 301 269 Int i, nalOrVcl; 302 TComVUI *vui = sps->getVuiParameters();303 TComHRD *hrd = vui->getHrdParameters();270 const TComVUI *vui = sps->getVuiParameters(); 271 const TComHRD *hrd = vui->getHrdParameters(); 304 272 305 273 WRITE_UVLC( sei.m_bpSeqParameterSetId, "bp_seq_parameter_set_id" ); … … 332 300 } 333 301 } 334 xWriteByteAlign(); 335 } 336 Void SEIWriter::xWriteSEIPictureTiming(const SEIPictureTiming& sei, TComSPS *sps) 302 } 303 Void SEIWriter::xWriteSEIPictureTiming(const SEIPictureTiming& sei, const TComSPS *sps) 337 304 { 338 305 Int i; 339 TComVUI *vui = sps->getVuiParameters();340 TComHRD *hrd = vui->getHrdParameters();306 const TComVUI *vui = sps->getVuiParameters(); 307 const TComHRD *hrd = vui->getHrdParameters(); 341 308 342 309 if( vui->getFrameFieldInfoPresentFlag() ) … … 373 340 } 374 341 } 375 xWriteByteAlign();376 342 } 377 343 Void SEIWriter::xWriteSEIRecoveryPoint(const SEIRecoveryPoint& sei) … … 380 346 WRITE_FLAG( sei.m_exactMatchingFlag, "exact_matching_flag" ); 381 347 WRITE_FLAG( sei.m_brokenLinkFlag, "broken_link_flag" ); 382 xWriteByteAlign();383 348 } 384 349 Void SEIWriter::xWriteSEIFramePacking(const SEIFramePacking& sei) … … 387 352 WRITE_FLAG( sei.m_arrangementCancelFlag, "frame_packing_arrangement_cancel_flag" ); 388 353 389 if( sei.m_arrangementCancelFlag == 0 ) { 354 if( sei.m_arrangementCancelFlag == 0 ) 355 { 390 356 WRITE_CODE( sei.m_arrangementType, 7, "frame_packing_arrangement_type" ); 391 357 … … 413 379 414 380 WRITE_FLAG( sei.m_upsampledAspectRatio, "upsampled_aspect_ratio" ); 415 416 xWriteByteAlign(); 381 } 382 383 Void SEIWriter::xWriteSEISegmentedRectFramePacking(const SEISegmentedRectFramePacking& sei) 384 { 385 WRITE_FLAG( sei.m_arrangementCancelFlag, "segmented_rect_frame_packing_arrangement_cancel_flag" ); 386 if( sei.m_arrangementCancelFlag == 0 ) 387 { 388 WRITE_CODE( sei.m_contentInterpretationType, 2, "segmented_rect_content_interpretation_type" ); 389 WRITE_FLAG( sei.m_arrangementPersistenceFlag, "segmented_rect_frame_packing_arrangement_persistence" ); 390 } 417 391 } 418 392 … … 422 396 WRITE_UVLC( sei.m_toneMapId, "tone_map_id" ); 423 397 WRITE_FLAG( sei.m_toneMapCancelFlag, "tone_map_cancel_flag" ); 424 if( !sei.m_toneMapCancelFlag ) 398 if( !sei.m_toneMapCancelFlag ) 425 399 { 426 400 WRITE_FLAG( sei.m_toneMapPersistenceFlag, "tone_map_persistence_flag" ); … … 490 464 }//switch m_modelId 491 465 }//if(!sei.m_toneMapCancelFlag) 492 493 xWriteByteAlign();494 466 } 495 467 … … 504 476 WRITE_FLAG( sei.persistenceFlag, "display_orientation_persistence_flag" ); 505 477 } 506 xWriteByteAlign();507 478 } 508 479 … … 511 482 WRITE_CODE( sei.tl0Idx, 8 , "tl0_idx" ); 512 483 WRITE_CODE( sei.rapIdx, 8 , "rap_idx" ); 513 xWriteByteAlign();514 484 } 515 485 … … 517 487 { 518 488 WRITE_FLAG( sei.m_gdrForegroundFlag, "gdr_foreground_flag"); 519 xWriteByteAlign(); 489 } 490 491 Void SEIWriter::xWriteSEINoDisplay(const SEINoDisplay& /*sei*/) 492 { 520 493 } 521 494 … … 537 510 } 538 511 } 539 540 xWriteByteAlign(); 541 } 542 543 Void SEIWriter::xWriteSEIScalableNesting(TComBitIf& bs, const SEIScalableNesting& sei, TComSPS *sps) 512 } 513 514 Void SEIWriter::xWriteSEIScalableNesting(TComBitIf& bs, const SEIScalableNesting& sei, const TComSPS *sps) 544 515 { 545 516 WRITE_FLAG( sei.m_bitStreamSubsetFlag, "bitstream_subset_flag" ); … … 548 519 { 549 520 WRITE_FLAG( sei.m_defaultOpFlag, "default_op_flag" ); 550 WRITE_UVLC( sei.m_nestingNumOpsMinus1, "nesting_num_ops ");521 WRITE_UVLC( sei.m_nestingNumOpsMinus1, "nesting_num_ops_minus1" ); 551 522 for (UInt i = (sei.m_defaultOpFlag ? 1 : 0); i <= sei.m_nestingNumOpsMinus1; i++) 552 523 { 553 WRITE_CODE( sei.m_nestingNoOpMaxTemporalIdPlus1, 3, "nesting_no_op_max_temporal_id" ); 554 WRITE_CODE( sei.m_nestingMaxTemporalIdPlus1[i], 3, "nesting_max_temporal_id" ); 524 WRITE_CODE( sei.m_nestingMaxTemporalIdPlus1[i], 3, "nesting_max_temporal_id_plus1" ); 555 525 WRITE_UVLC( sei.m_nestingOpIdx[i], "nesting_op_idx" ); 556 526 } … … 561 531 if (!sei.m_allLayersFlag) 562 532 { 563 WRITE_CODE( sei.m_nestingNoOpMaxTemporalIdPlus1, 3, "nesting_no_op_max_temporal_id " );564 WRITE_UVLC( sei.m_nestingNumLayersMinus1, "nesting_num_layers" );533 WRITE_CODE( sei.m_nestingNoOpMaxTemporalIdPlus1, 3, "nesting_no_op_max_temporal_id_plus1" ); 534 WRITE_UVLC( sei.m_nestingNumLayersMinus1, "nesting_num_layers" ); 565 535 for (UInt i = 0; i <= sei.m_nestingNumLayersMinus1; i++) 566 536 { … … 569 539 } 570 540 } 571 541 572 542 // byte alignment 573 543 while ( m_pcBitIf->getNumberOfWrittenBits() % 8 != 0 ) … … 577 547 578 548 // write nested SEI messages 579 for (SEIMessages::const_iterator it = sei.m_nestedSEIs.begin(); it != sei.m_nestedSEIs.end(); it++) 580 { 581 writeSEImessage(bs, *(*it), sps); 582 } 583 } 584 585 #if H_MV 549 writeSEImessages(bs, sei.m_nestedSEIs, sps, true); 550 } 551 552 Void SEIWriter::xWriteSEITempMotionConstrainedTileSets(const SEITempMotionConstrainedTileSets& sei) 553 { 554 //UInt code; 555 WRITE_FLAG((sei.m_mc_all_tiles_exact_sample_value_match_flag ? 1 : 0), "mc_all_tiles_exact_sample_value_match_flag"); 556 WRITE_FLAG((sei.m_each_tile_one_tile_set_flag ? 1 : 0), "each_tile_one_tile_set_flag" ); 557 558 if(!sei.m_each_tile_one_tile_set_flag) 559 { 560 WRITE_FLAG((sei.m_limited_tile_set_display_flag ? 1 : 0), "limited_tile_set_display_flag"); 561 WRITE_UVLC((sei.getNumberOfTileSets() - 1), "num_sets_in_message_minus1" ); 562 563 if(sei.getNumberOfTileSets() > 0) 564 { 565 for(Int i = 0; i < sei.getNumberOfTileSets(); i++) 566 { 567 WRITE_UVLC(sei.tileSetData(i).m_mcts_id, "mcts_id"); 568 569 if(sei.m_limited_tile_set_display_flag) 570 { 571 WRITE_FLAG((sei.tileSetData(i).m_display_tile_set_flag ? 1 : 0), "display_tile_set_flag"); 572 } 573 574 WRITE_UVLC((sei.tileSetData(i).getNumberOfTileRects() - 1), "num_tile_rects_in_set_minus1"); 575 576 for(Int j = 0; j < sei.tileSetData(i).getNumberOfTileRects(); j++) 577 { 578 WRITE_UVLC(sei.tileSetData(i).topLeftTileIndex (j), "top_left_tile_index"); 579 WRITE_UVLC(sei.tileSetData(i).bottomRightTileIndex(j), "bottom_right_tile_index"); 580 } 581 582 if(!sei.m_mc_all_tiles_exact_sample_value_match_flag) 583 { 584 WRITE_FLAG((sei.tileSetData(i).m_exact_sample_value_match_flag ? 1 : 0), "exact_sample_value_match_flag"); 585 } 586 587 WRITE_FLAG((sei.tileSetData(i).m_mcts_tier_level_idc_present_flag ? 1 : 0), "mcts_tier_level_idc_present_flag"); 588 589 if(sei.tileSetData(i).m_mcts_tier_level_idc_present_flag) 590 { 591 WRITE_FLAG((sei.tileSetData(i).m_mcts_tier_flag ? 1 : 0), "mcts_tier_flag"); 592 WRITE_CODE( sei.tileSetData(i).m_mcts_level_idc, 8, "mcts_level_idc"); 593 } 594 } 595 } 596 } 597 else 598 { 599 WRITE_FLAG((sei.m_max_mcs_tier_level_idc_present_flag ? 1 : 0), "max_mcs_tier_level_idc_present_flag"); 600 601 if(sei.m_max_mcs_tier_level_idc_present_flag) 602 { 603 WRITE_FLAG((sei.m_max_mcts_tier_flag ? 1 : 0), "max_mcts_tier_flag"); 604 WRITE_CODE( sei.m_max_mcts_level_idc, 8, "max_mcts_level_idc"); 605 } 606 } 607 } 608 609 Void SEIWriter::xWriteSEITimeCode(const SEITimeCode& sei) 610 { 611 WRITE_CODE(sei.numClockTs, 2, "num_clock_ts"); 612 for(Int i = 0; i < sei.numClockTs; i++) 613 { 614 const TComSEITimeSet ¤tTimeSet = sei.timeSetArray[i]; 615 WRITE_FLAG(currentTimeSet.clockTimeStampFlag, "clock_time_stamp_flag"); 616 if(currentTimeSet.clockTimeStampFlag) 617 { 618 WRITE_FLAG(currentTimeSet.numUnitFieldBasedFlag, "units_field_based_flag"); 619 WRITE_CODE(currentTimeSet.countingType, 5, "counting_type"); 620 WRITE_FLAG(currentTimeSet.fullTimeStampFlag, "full_timestamp_flag"); 621 WRITE_FLAG(currentTimeSet.discontinuityFlag, "discontinuity_flag"); 622 WRITE_FLAG(currentTimeSet.cntDroppedFlag, "cnt_dropped_flag"); 623 WRITE_CODE(currentTimeSet.numberOfFrames, 9, "n_frames"); 624 if(currentTimeSet.fullTimeStampFlag) 625 { 626 WRITE_CODE(currentTimeSet.secondsValue, 6, "seconds_value"); 627 WRITE_CODE(currentTimeSet.minutesValue, 6, "minutes_value"); 628 WRITE_CODE(currentTimeSet.hoursValue, 5, "hours_value"); 629 } 630 else 631 { 632 WRITE_FLAG(currentTimeSet.secondsFlag, "seconds_flag"); 633 if(currentTimeSet.secondsFlag) 634 { 635 WRITE_CODE(currentTimeSet.secondsValue, 6, "seconds_value"); 636 WRITE_FLAG(currentTimeSet.minutesFlag, "minutes_flag"); 637 if(currentTimeSet.minutesFlag) 638 { 639 WRITE_CODE(currentTimeSet.minutesValue, 6, "minutes_value"); 640 WRITE_FLAG(currentTimeSet.hoursFlag, "hours_flag"); 641 if(currentTimeSet.hoursFlag) 642 { 643 WRITE_CODE(currentTimeSet.hoursValue, 5, "hours_value"); 644 } 645 } 646 } 647 } 648 WRITE_CODE(currentTimeSet.timeOffsetLength, 5, "time_offset_length"); 649 if(currentTimeSet.timeOffsetLength > 0) 650 { 651 if(currentTimeSet.timeOffsetValue >= 0) 652 { 653 WRITE_CODE((UInt)currentTimeSet.timeOffsetValue, currentTimeSet.timeOffsetLength, "time_offset_value"); 654 } 655 else 656 { 657 // Two's complement conversion 658 UInt offsetValue = ~(currentTimeSet.timeOffsetValue) + 1; 659 offsetValue |= (1 << (currentTimeSet.timeOffsetLength-1)); 660 WRITE_CODE(offsetValue, currentTimeSet.timeOffsetLength, "time_offset_value"); 661 } 662 } 663 } 664 } 665 } 666 667 Void SEIWriter::xWriteSEIChromaSamplingFilterHint(const SEIChromaSamplingFilterHint &sei/*, TComSPS* sps*/) 668 { 669 WRITE_CODE(sei.m_verChromaFilterIdc, 8, "ver_chroma_filter_idc"); 670 WRITE_CODE(sei.m_horChromaFilterIdc, 8, "hor_chroma_filter_idc"); 671 WRITE_FLAG(sei.m_verFilteringProcessFlag, "ver_filtering_process_flag"); 672 if(sei.m_verChromaFilterIdc == 1 || sei.m_horChromaFilterIdc == 1) 673 { 674 writeUserDefinedCoefficients(sei); 675 } 676 } 677 678 // write hardcoded chroma filter coefficients in the SEI messages 679 Void SEIWriter::writeUserDefinedCoefficients(const SEIChromaSamplingFilterHint &sei) 680 { 681 Int const iNumVerticalFilters = 3; 682 Int verticalTapLength_minus1[iNumVerticalFilters] = {5,3,3}; 683 Int* userVerticalCoefficients[iNumVerticalFilters]; 684 for(Int i = 0; i < iNumVerticalFilters; i ++) 685 { 686 userVerticalCoefficients[i] = (Int*)malloc( (verticalTapLength_minus1[i]+1) * sizeof(Int)); 687 } 688 userVerticalCoefficients[0][0] = -3; 689 userVerticalCoefficients[0][1] = 13; 690 userVerticalCoefficients[0][2] = 31; 691 userVerticalCoefficients[0][3] = 23; 692 userVerticalCoefficients[0][4] = 3; 693 userVerticalCoefficients[0][5] = -3; 694 695 userVerticalCoefficients[1][0] = -1; 696 userVerticalCoefficients[1][1] = 25; 697 userVerticalCoefficients[1][2] = 247; 698 userVerticalCoefficients[1][3] = -15; 699 700 userVerticalCoefficients[2][0] = -20; 701 userVerticalCoefficients[2][1] = 186; 702 userVerticalCoefficients[2][2] = 100; 703 userVerticalCoefficients[2][3] = -10; 704 705 Int const iNumHorizontalFilters = 1; 706 Int horizontalTapLength_minus1[iNumHorizontalFilters] = {3}; 707 Int* userHorizontalCoefficients[iNumHorizontalFilters]; 708 for(Int i = 0; i < iNumHorizontalFilters; i ++) 709 { 710 userHorizontalCoefficients[i] = (Int*)malloc( (horizontalTapLength_minus1[i]+1) * sizeof(Int)); 711 } 712 userHorizontalCoefficients[0][0] = 1; 713 userHorizontalCoefficients[0][1] = 6; 714 userHorizontalCoefficients[0][2] = 1; 715 716 WRITE_UVLC(3, "target_format_idc"); 717 if(sei.m_verChromaFilterIdc == 1) 718 { 719 WRITE_UVLC(iNumVerticalFilters, "num_vertical_filters"); 720 if(iNumVerticalFilters > 0) 721 { 722 for(Int i = 0; i < iNumVerticalFilters; i ++) 723 { 724 WRITE_UVLC(verticalTapLength_minus1[i], "ver_tap_length_minus_1"); 725 for(Int j = 0; j < verticalTapLength_minus1[i]; j ++) 726 { 727 WRITE_SVLC(userVerticalCoefficients[i][j], "ver_filter_coeff"); 728 } 729 } 730 } 731 } 732 if(sei.m_horChromaFilterIdc == 1) 733 { 734 WRITE_UVLC(iNumHorizontalFilters, "num_horizontal_filters"); 735 if(iNumHorizontalFilters > 0) 736 { 737 for(Int i = 0; i < iNumHorizontalFilters; i ++) 738 { 739 WRITE_UVLC(horizontalTapLength_minus1[i], "hor_tap_length_minus_1"); 740 for(Int j = 0; j < horizontalTapLength_minus1[i]; j ++) 741 { 742 WRITE_SVLC(userHorizontalCoefficients[i][j], "hor_filter_coeff"); 743 } 744 } 745 } 746 } 747 } 748 749 #if NH_MV 586 750 Void SEIWriter::xWriteSEISubBitstreamProperty(const SEISubBitstreamProperty &sei) 587 751 { … … 602 766 #endif 603 767 768 Void SEIWriter::xWriteSEIKneeFunctionInfo(const SEIKneeFunctionInfo &sei) 769 { 770 WRITE_UVLC( sei.m_kneeId, "knee_function_id" ); 771 WRITE_FLAG( sei.m_kneeCancelFlag, "knee_function_cancel_flag" ); 772 if ( !sei.m_kneeCancelFlag ) 773 { 774 WRITE_FLAG( sei.m_kneePersistenceFlag, "knee_function_persistence_flag" ); 775 WRITE_CODE( (UInt)sei.m_kneeInputDrange , 32, "input_d_range" ); 776 WRITE_CODE( (UInt)sei.m_kneeInputDispLuminance, 32, "input_disp_luminance" ); 777 WRITE_CODE( (UInt)sei.m_kneeOutputDrange, 32, "output_d_range" ); 778 WRITE_CODE( (UInt)sei.m_kneeOutputDispLuminance, 32, "output_disp_luminance" ); 779 WRITE_UVLC( sei.m_kneeNumKneePointsMinus1, "num_knee_points_minus1" ); 780 for(Int i = 0; i <= sei.m_kneeNumKneePointsMinus1; i++ ) 781 { 782 WRITE_CODE( (UInt)sei.m_kneeInputKneePoint[i], 10,"input_knee_point" ); 783 WRITE_CODE( (UInt)sei.m_kneeOutputKneePoint[i], 10, "output_knee_point" ); 784 } 785 } 786 } 787 788 789 Void SEIWriter::xWriteSEIMasteringDisplayColourVolume(const SEIMasteringDisplayColourVolume& sei) 790 { 791 WRITE_CODE( sei.values.primaries[0][0], 16, "display_primaries_x[0]" ); 792 WRITE_CODE( sei.values.primaries[0][1], 16, "display_primaries_y[0]" ); 793 794 WRITE_CODE( sei.values.primaries[1][0], 16, "display_primaries_x[1]" ); 795 WRITE_CODE( sei.values.primaries[1][1], 16, "display_primaries_y[1]" ); 796 797 WRITE_CODE( sei.values.primaries[2][0], 16, "display_primaries_x[2]" ); 798 WRITE_CODE( sei.values.primaries[2][1], 16, "display_primaries_y[2]" ); 799 800 WRITE_CODE( sei.values.whitePoint[0], 16, "white_point_x" ); 801 WRITE_CODE( sei.values.whitePoint[1], 16, "white_point_y" ); 802 803 WRITE_CODE( sei.values.maxLuminance, 32, "max_display_mastering_luminance" ); 804 WRITE_CODE( sei.values.minLuminance, 32, "min_display_mastering_luminance" ); 805 } 806 807 604 808 Void SEIWriter::xWriteByteAlign() 605 809 { 606 810 if( m_pcBitIf->getNumberOfWrittenBits() % 8 != 0) 607 811 { 608 WRITE_FLAG( 1, " bit_equal_to_one" );812 WRITE_FLAG( 1, "payload_bit_equal_to_one" ); 609 813 while( m_pcBitIf->getNumberOfWrittenBits() % 8 != 0 ) 610 814 { 611 WRITE_FLAG( 0, " bit_equal_to_zero" );612 } 613 } 614 } ;815 WRITE_FLAG( 0, "payload_bit_equal_to_zero" ); 816 } 817 } 818 } 615 819 616 820 //! \}
Note: See TracChangeset for help on using the changeset viewer.