Changeset 310 in SHVCSoftware for trunk/source/Lib/TLibEncoder
- Timestamp:
- 22 Jul 2013, 21:40:00 (12 years ago)
- Location:
- trunk
- Files:
-
- 20 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/SHM-2.1-dev (added) merged: 193-196,202,204,210-212,214-216,224,226-228,233-251,258,282-309
- Property svn:mergeinfo changed
-
trunk/source
- Property svn:mergeinfo changed
-
trunk/source/Lib/TLibEncoder/SEIwrite.cpp
r191 r310 84 84 fprintf( g_hTrace, "=========== Decoding Unit Information SEI message ===========\n"); 85 85 break; 86 #if J0149_TONE_MAPPING_SEI87 86 case SEI::TONE_MAPPING_INFO: 88 87 fprintf( g_hTrace, "=========== Tone Mapping Info SEI message ===========\n"); 89 88 break; 90 #endif 91 #if L0208_SOP_DESCRIPTION_SEI 89 #if M0043_LAYERS_PRESENT_SEI 90 case SEI::LAYERS_PRESENT: 91 fprintf( g_hTrace, "=========== Layers Present SEI message ===========\n"); 92 break; 93 #endif 92 94 case SEI::SOP_DESCRIPTION: 93 95 fprintf( g_hTrace, "=========== SOP Description SEI message ===========\n"); 94 96 break; 95 #endif96 #if K0180_SCALABLE_NESTING_SEI97 97 case SEI::SCALABLE_NESTING: 98 98 fprintf( g_hTrace, "=========== Scalable Nesting SEI message ===========\n"); 99 99 break; 100 #endif101 100 default: 102 101 fprintf( g_hTrace, "=========== Unknown SEI message ===========\n"); … … 106 105 #endif 107 106 108 #if K0180_SCALABLE_NESTING_SEI109 107 void SEIWriter::xWriteSEIpayloadData(TComBitIf& bs, const SEI& sei, TComSPS *sps) 110 #else111 void SEIWriter::xWriteSEIpayloadData(const SEI& sei, TComSPS *sps)112 #endif113 108 { 114 109 switch (sei.payloadType()) … … 147 142 xWriteSEIGradualDecodingRefreshInfo(*static_cast<const SEIGradualDecodingRefreshInfo*>(&sei)); 148 143 break; 149 #if J0149_TONE_MAPPING_SEI150 144 case SEI::TONE_MAPPING_INFO: 151 145 xWriteSEIToneMappingInfo(*static_cast<const SEIToneMappingInfo*>(&sei)); 152 146 break; 153 #endif 154 #if L0208_SOP_DESCRIPTION_SEI 147 #if M0043_LAYERS_PRESENT_SEI 148 case SEI::LAYERS_PRESENT: 149 xWriteSEILayersPresent(*static_cast<const SEILayersPresent*>(&sei)); 150 break; 151 #endif 155 152 case SEI::SOP_DESCRIPTION: 156 153 xWriteSEISOPDescription(*static_cast<const SEISOPDescription*>(&sei)); 157 154 break; 158 #endif159 #if K0180_SCALABLE_NESTING_SEI160 155 case SEI::SCALABLE_NESTING: 161 156 xWriteSEIScalableNesting(bs, *static_cast<const SEIScalableNesting*>(&sei), sps); 162 157 break; 163 #endif164 158 default: 165 159 assert(!"Unhandled SEI message"); … … 180 174 181 175 182 #if K0180_SCALABLE_NESTING_SEI183 184 176 #if ENC_DEC_TRACE 185 177 Bool traceEnable = g_HLSTraceEnable; … … 191 183 #endif 192 184 193 #else194 195 #if ENC_DEC_TRACE196 g_HLSTraceEnable = false;197 #endif198 xWriteSEIpayloadData(sei, sps);199 #if ENC_DEC_TRACE200 g_HLSTraceEnable = true;201 #endif202 203 #endif204 205 185 UInt payload_data_num_bits = bs_count.getNumberOfWrittenBits(); 206 186 assert(0 == payload_data_num_bits % 8); … … 209 189 210 190 #if ENC_DEC_TRACE 211 #if K0180_SCALABLE_NESTING_SEI212 191 if (g_HLSTraceEnable) 213 #endif214 192 xTraceSEIHeader(); 215 193 #endif … … 231 209 /* payloadData */ 232 210 #if ENC_DEC_TRACE 233 #if K0180_SCALABLE_NESTING_SEI234 211 if (g_HLSTraceEnable) 235 #endif236 212 xTraceSEIMessageType(sei.payloadType()); 237 213 #endif 238 214 239 #if K0180_SCALABLE_NESTING_SEI240 215 xWriteSEIpayloadData(bs, sei, sps); 241 #else242 xWriteSEIpayloadData(sei, sps);243 #endif244 216 } 245 217 … … 296 268 { 297 269 WRITE_CODE(sei.activeVPSId, 4, "active_vps_id"); 298 #if L0047_APS_FLAGS299 270 WRITE_FLAG(sei.m_fullRandomAccessFlag, "full_random_access_flag"); 300 271 WRITE_FLAG(sei.m_noParamSetUpdateFlag, "no_param_set_update_flag"); 301 #endif302 272 WRITE_UVLC(sei.numSpsIdsMinus1, "num_sps_ids_minus1"); 303 273 … … 330 300 WRITE_CODE( sei.m_duSptCpbRemovalDelay, (vui->getHrdParameters()->getDuCpbRemovalDelayLengthMinus1() + 1), "du_spt_cpb_removal_delay"); 331 301 } 332 #if L0044_DU_DPB_OUTPUT_DELAY_HRD333 302 WRITE_FLAG( sei.m_dpbOutputDuDelayPresentFlag, "dpb_output_du_delay_present_flag"); 334 303 if(sei.m_dpbOutputDuDelayPresentFlag) … … 336 305 WRITE_CODE(sei.m_picSptDpbOutputDuDelay, vui->getHrdParameters()->getDpbOutputDelayDuLengthMinus1() + 1, "pic_spt_dpb_output_du_delay"); 337 306 } 338 #endif339 307 xWriteByteAlign(); 340 308 } … … 351 319 WRITE_FLAG( sei.m_rapCpbParamsPresentFlag, "rap_cpb_params_present_flag" ); 352 320 } 353 #if L0328_SPLICING354 321 WRITE_FLAG( sei.m_concatenationFlag, "concatenation_flag"); 355 322 WRITE_CODE( sei.m_auCpbRemovalDelayDelta - 1, ( hrd->getCpbRemovalDelayLengthMinus1() + 1 ), "au_cpb_removal_delay_delta_minus1" ); 356 #endif357 #if L0044_CPB_DPB_DELAY_OFFSET358 323 if( sei.m_rapCpbParamsPresentFlag ) 359 324 { … … 361 326 WRITE_CODE( sei.m_dpbDelayOffset, hrd->getDpbOutputDelayLengthMinus1() + 1, "dpb_delay_offset" ); 362 327 } 363 #endif364 328 for( nalOrVcl = 0; nalOrVcl < 2; nalOrVcl ++ ) 365 329 { … … 387 351 TComHRD *hrd = vui->getHrdParameters(); 388 352 389 #if !L0045_CONDITION_SIGNALLING390 // This condition was probably OK before the pic_struct, progressive_source_idc, duplicate_flag were added391 if( !hrd->getNalHrdParametersPresentFlag() && !hrd->getVclHrdParametersPresentFlag() )392 return;393 #endif394 353 if( vui->getFrameFieldInfoPresentFlag() ) 395 354 { 396 355 WRITE_CODE( sei.m_picStruct, 4, "pic_struct" ); 397 #if L0046_RENAME_PROG_SRC_IDC398 356 WRITE_CODE( sei.m_sourceScanType, 2, "source_scan_type" ); 399 #else400 WRITE_CODE( sei.m_progressiveSourceIdc, 2, "progressive_source_idc" );401 #endif402 357 WRITE_FLAG( sei.m_duplicateFlag ? 1 : 0, "duplicate_flag" ); 403 358 } 404 359 405 #if L0045_CONDITION_SIGNALLING406 360 if( hrd->getCpbDpbDelaysPresentFlag() ) 407 361 { 408 #endif409 362 WRITE_CODE( sei.m_auCpbRemovalDelay - 1, ( hrd->getCpbRemovalDelayLengthMinus1() + 1 ), "au_cpb_removal_delay_minus1" ); 410 363 WRITE_CODE( sei.m_picDpbOutputDelay, ( hrd->getDpbOutputDelayLengthMinus1() + 1 ), "pic_dpb_output_delay" ); 411 #if L0044_DU_DPB_OUTPUT_DELAY_HRD412 364 if(hrd->getSubPicCpbParamsPresentFlag()) 413 365 { 414 366 WRITE_CODE(sei.m_picDpbOutputDuDelay, hrd->getDpbOutputDelayDuLengthMinus1()+1, "pic_dpb_output_du_delay" ); 415 367 } 416 #endif417 368 if( hrd->getSubPicCpbParamsPresentFlag() && hrd->getSubPicCpbParamsInPicTimingSEIFlag() ) 418 369 { … … 432 383 } 433 384 } 434 #if L0045_CONDITION_SIGNALLING 435 } 436 #endif 385 } 437 386 xWriteByteAlign(); 438 387 } … … 471 420 472 421 WRITE_CODE( sei.m_arrangementReservedByte, 8, "frame_packing_arrangement_reserved_byte" ); 473 #if L0045_PERSISTENCE_FLAGS474 422 WRITE_FLAG( sei.m_arrangementPersistenceFlag, "frame_packing_arrangement_persistence_flag" ); 475 #else476 WRITE_UVLC( sei.m_arrangementRepetetionPeriod, "frame_packing_arrangement_repetition_period" );477 #endif478 423 } 479 424 … … 483 428 } 484 429 485 #if J0149_TONE_MAPPING_SEI486 430 Void SEIWriter::xWriteSEIToneMappingInfo(const SEIToneMappingInfo& sei) 487 431 { … … 555 499 xWriteByteAlign(); 556 500 } 557 #endif558 501 559 502 Void SEIWriter::xWriteSEIDisplayOrientation(const SEIDisplayOrientation &sei) … … 565 508 WRITE_FLAG( sei.verFlip, "ver_flip" ); 566 509 WRITE_CODE( sei.anticlockwiseRotation, 16, "anticlockwise_rotation" ); 567 #if L0045_PERSISTENCE_FLAGS568 510 WRITE_FLAG( sei.persistenceFlag, "display_orientation_persistence_flag" ); 569 #else570 WRITE_UVLC( sei.repetitionPeriod, "display_orientation_repetition_period" );571 #endif572 #if !REMOVE_SINGLE_SEI_EXTENSION_FLAGS573 WRITE_FLAG( sei.extensionFlag, "display_orientation_extension_flag" );574 assert( !sei.extensionFlag );575 #endif576 511 } 577 512 xWriteByteAlign(); … … 591 526 } 592 527 593 #if L0208_SOP_DESCRIPTION_SEI 528 #if M0043_LAYERS_PRESENT_SEI 529 Void SEIWriter::xWriteSEILayersPresent(const SEILayersPresent& sei) 530 { 531 WRITE_UVLC( sei.m_activeVpsId, "lp_sei_active_vps_id" ); 532 for (UInt i = 0; i < sei.m_vpsMaxLayers; i++) 533 { 534 WRITE_FLAG( sei.m_layerPresentFlag[i], "layer_present_flag" ); 535 } 536 xWriteByteAlign(); 537 } 538 #endif 539 594 540 Void SEIWriter::xWriteSEISOPDescription(const SEISOPDescription& sei) 595 541 { … … 612 558 xWriteByteAlign(); 613 559 } 614 #endif 615 616 #if K0180_SCALABLE_NESTING_SEI 560 617 561 Void SEIWriter::xWriteSEIScalableNesting(TComBitIf& bs, const SEIScalableNesting& sei, TComSPS *sps) 618 562 { … … 656 600 } 657 601 } 658 #endif659 602 660 603 Void SEIWriter::xWriteByteAlign() -
trunk/source/Lib/TLibEncoder/SEIwrite.h
r191 r310 50 50 51 51 protected: 52 #if K0180_SCALABLE_NESTING_SEI53 52 Void xWriteSEIpayloadData(TComBitIf& bs, const SEI& sei, TComSPS *sps); 54 #else55 Void xWriteSEIpayloadData(const SEI& sei, TComSPS *sps);56 #endif57 53 Void xWriteSEIuserDataUnregistered(const SEIuserDataUnregistered &sei); 58 54 Void xWriteSEIActiveParameterSets(const SEIActiveParameterSets& sei); … … 67 63 Void xWriteSEITemporalLevel0Index(const SEITemporalLevel0Index &sei); 68 64 Void xWriteSEIGradualDecodingRefreshInfo(const SEIGradualDecodingRefreshInfo &sei); 69 #if J0149_TONE_MAPPING_SEI70 65 Void xWriteSEIToneMappingInfo(const SEIToneMappingInfo& sei); 66 #if M0043_LAYERS_PRESENT_SEI 67 Void xWriteSEILayersPresent(const SEILayersPresent& sei); 71 68 #endif 72 #if L0208_SOP_DESCRIPTION_SEI73 69 Void xWriteSEISOPDescription(const SEISOPDescription& sei); 74 #endif75 #if K0180_SCALABLE_NESTING_SEI76 70 Void xWriteSEIScalableNesting(TComBitIf& bs, const SEIScalableNesting& sei, TComSPS *sps); 77 #endif78 71 Void xWriteByteAlign(); 79 72 }; -
trunk/source/Lib/TLibEncoder/TEncCavlc.cpp
r191 r310 39 39 #include "TEncCavlc.h" 40 40 #include "SEIwrite.h" 41 #include <iostream> 41 42 42 //! \ingroup TLibEncoder 43 43 //! \{ … … 163 163 WRITE_UVLC( pcPPS->getSPSId(), "pps_seq_parameter_set_id" ); 164 164 WRITE_FLAG( pcPPS->getDependentSliceSegmentsEnabledFlag() ? 1 : 0, "dependent_slice_segments_enabled_flag" ); 165 #if L0255_MOVE_PPS_FLAGS166 165 WRITE_FLAG( pcPPS->getOutputFlagPresentFlag() ? 1 : 0, "output_flag_present_flag" ); 167 166 WRITE_CODE( pcPPS->getNumExtraSliceHeaderBits(), 3, "num_extra_slice_header_bits"); 168 #endif169 167 WRITE_FLAG( pcPPS->getSignHideFlag(), "sign_data_hiding_flag" ); 170 168 WRITE_FLAG( pcPPS->getCabacInitPresentFlag() ? 1 : 0, "cabac_init_present_flag" ); … … 186 184 WRITE_FLAG( pcPPS->getUseWP() ? 1 : 0, "weighted_pred_flag" ); // Use of Weighting Prediction (P_SLICE) 187 185 WRITE_FLAG( pcPPS->getWPBiPred() ? 1 : 0, "weighted_bipred_flag" ); // Use of Weighting Bi-Prediction (B_SLICE) 188 #if !L0255_MOVE_PPS_FLAGS189 WRITE_FLAG( pcPPS->getOutputFlagPresentFlag() ? 1 : 0, "output_flag_present_flag" );190 #endif191 186 WRITE_FLAG( pcPPS->getTransquantBypassEnableFlag() ? 1 : 0, "transquant_bypass_enable_flag" ); 192 187 WRITE_FLAG( pcPPS->getTilesEnabledFlag() ? 1 : 0, "tiles_enabled_flag" ); … … 235 230 WRITE_FLAG( pcPPS->getListsModificationPresentFlag(), "lists_modification_present_flag"); 236 231 WRITE_UVLC( pcPPS->getLog2ParallelMergeLevelMinus2(), "log2_parallel_merge_level_minus2"); 237 #if !L0255_MOVE_PPS_FLAGS238 WRITE_CODE( pcPPS->getNumExtraSliceHeaderBits(), 3, "num_extra_slice_header_bits");239 #endif240 232 WRITE_FLAG( pcPPS->getSliceHeaderExtensionPresentFlag() ? 1 : 0, "slice_segment_header_extension_present_flag"); 241 233 WRITE_FLAG( 0, "pps_extension_flag" ); … … 296 288 WRITE_UVLC(defaultDisplayWindow.getWindowBottomOffset(), "def_disp_win_bottom_offset"); 297 289 } 298 #if L0043_TIMING_INFO299 290 TimingInfo *timingInfo = pcVUI->getTimingInfo(); 300 291 WRITE_FLAG(timingInfo->getTimingInfoPresentFlag(), "vui_timing_info_present_flag"); … … 308 299 WRITE_UVLC(timingInfo->getNumTicksPocDiffOneMinus1(), "vui_num_ticks_poc_diff_one_minus1"); 309 300 } 310 #endif311 301 WRITE_FLAG(pcVUI->getHrdParametersPresentFlag(), "hrd_parameters_present_flag"); 312 302 if( pcVUI->getHrdParametersPresentFlag() ) … … 314 304 codeHrdParameters(pcVUI->getHrdParameters(), 1, pcSPS->getMaxTLayers() - 1 ); 315 305 } 316 #if L0043_TIMING_INFO 317 } 318 #endif 319 #if !L0043_TIMING_INFO 320 WRITE_FLAG( pcVUI->getPocProportionalToTimingFlag(), "poc_proportional_to_timing_flag" ); 321 if( pcVUI->getPocProportionalToTimingFlag() && pcVUI->getHrdParameters()->getTimingInfoPresentFlag() ) 322 { 323 WRITE_UVLC( pcVUI->getNumTicksPocDiffOneMinus1(), "num_ticks_poc_diff_one_minus1" ); 324 } 325 #endif 306 } 326 307 327 308 WRITE_FLAG(pcVUI->getBitstreamRestrictionFlag(), "bitstream_restriction_flag"); … … 329 310 { 330 311 WRITE_FLAG(pcVUI->getTilesFixedStructureFlag(), "tiles_fixed_structure_flag"); 312 #if M0464_TILE_BOUNDARY_ALIGNED_FLAG 313 if ( pcSPS->getLayerId() > 0 ) 314 { 315 WRITE_FLAG( pcVUI->getTileBoundariesAlignedFlag( ) ? 1 : 0 , "tile_boundaries_aligned_flag" ); 316 } 317 #endif 331 318 WRITE_FLAG(pcVUI->getMotionVectorsOverPicBoundariesFlag(), "motion_vectors_over_pic_boundaries_flag"); 332 319 WRITE_FLAG(pcVUI->getRestrictedRefPicListsFlag(), "restricted_ref_pic_lists_flag"); 333 #if L0043_MSS_IDC334 320 WRITE_UVLC(pcVUI->getMinSpatialSegmentationIdc(), "min_spatial_segmentation_idc"); 335 #else336 WRITE_CODE(pcVUI->getMinSpatialSegmentationIdc(), 8, "min_spatial_segmentation_idc");337 #endif338 321 WRITE_UVLC(pcVUI->getMaxBytesPerPicDenom(), "max_bytes_per_pic_denom"); 339 322 WRITE_UVLC(pcVUI->getMaxBitsPerMinCuDenom(), "max_bits_per_mincu_denom"); … … 347 330 if( commonInfPresentFlag ) 348 331 { 349 #if !L0043_TIMING_INFO350 WRITE_FLAG( hrd->getTimingInfoPresentFlag() ? 1 : 0, "timing_info_present_flag" );351 if( hrd->getTimingInfoPresentFlag() )352 {353 WRITE_CODE( hrd->getNumUnitsInTick(), 32, "num_units_in_tick" );354 WRITE_CODE( hrd->getTimeScale(), 32, "time_scale" );355 }356 #endif357 332 WRITE_FLAG( hrd->getNalHrdParametersPresentFlag() ? 1 : 0 , "nal_hrd_parameters_present_flag" ); 358 333 WRITE_FLAG( hrd->getVclHrdParametersPresentFlag() ? 1 : 0 , "vcl_hrd_parameters_present_flag" ); … … 365 340 WRITE_CODE( hrd->getDuCpbRemovalDelayLengthMinus1(), 5, "du_cpb_removal_delay_length_minus1" ); 366 341 WRITE_FLAG( hrd->getSubPicCpbParamsInPicTimingSEIFlag() ? 1 : 0, "sub_pic_cpb_params_in_pic_timing_sei_flag" ); 367 #if L0044_DU_DPB_OUTPUT_DELAY_HRD368 342 WRITE_CODE( hrd->getDpbOutputDelayDuLengthMinus1(), 5, "dpb_output_delay_du_length_minus1" ); 369 #endif370 343 } 371 344 WRITE_CODE( hrd->getBitRateScale(), 4, "bit_rate_scale" ); … … 396 369 WRITE_UVLC( hrd->getPicDurationInTcMinus1( i ), "elemental_duration_in_tc_minus1"); 397 370 } 398 #if L0372399 371 else 400 372 { … … 405 377 WRITE_UVLC( hrd->getCpbCntMinus1( i ), "cpb_cnt_minus1"); 406 378 } 407 #else408 WRITE_FLAG( hrd->getLowDelayHrdFlag( i ) ? 1 : 0, "low_delay_hrd_flag");409 WRITE_UVLC( hrd->getCpbCntMinus1( i ), "cpb_cnt_minus1");410 #endif411 379 412 380 for( nalOrVcl = 0; nalOrVcl < 2; nalOrVcl ++ ) … … 421 389 if( hrd->getSubPicCpbParamsPresentFlag() ) 422 390 { 423 #if L0363_DU_BIT_RATE 391 WRITE_UVLC( hrd->getDuCpbSizeValueMinus1( i, j, nalOrVcl ), "cpb_size_du_value_minus1"); 424 392 WRITE_UVLC( hrd->getDuBitRateValueMinus1( i, j, nalOrVcl ), "bit_rate_du_value_minus1"); 425 #endif426 WRITE_UVLC( hrd->getDuCpbSizeValueMinus1( i, j, nalOrVcl ), "cpb_size_du_value_minus1");427 393 } 428 394 WRITE_FLAG( hrd->getCbrFlag( i, j, nalOrVcl ) ? 1 : 0, "cbr_flag"); … … 439 405 #endif 440 406 WRITE_CODE( pcSPS->getVPSId (), 4, "sps_video_parameter_set_id" ); 441 WRITE_CODE( pcSPS->getMaxTLayers() - 1, 3, "sps_max_sub_layers_minus1" ); 442 WRITE_FLAG( pcSPS->getTemporalIdNestingFlag() ? 1 : 0, "sps_temporal_id_nesting_flag" ); 407 #if SPS_SUB_LAYER_INFO 408 if(pcSPS->getLayerId() == 0) 409 { 410 #endif 411 WRITE_CODE( pcSPS->getMaxTLayers() - 1, 3, "sps_max_sub_layers_minus1" ); 412 WRITE_FLAG( pcSPS->getTemporalIdNestingFlag() ? 1 : 0, "sps_temporal_id_nesting_flag" ); 413 #if SPS_SUB_LAYER_INFO 414 } 415 #endif 443 416 codePTL(pcSPS->getPTL(), 1, pcSPS->getMaxTLayers() - 1); 444 417 WRITE_UVLC( pcSPS->getSPSId (), "sps_seq_parameter_set_id" ); … … 473 446 for(UInt i=0; i <= pcSPS->getMaxTLayers()-1; i++) 474 447 { 475 #if L0323_DPB476 448 WRITE_UVLC( pcSPS->getMaxDecPicBuffering(i) - 1, "sps_max_dec_pic_buffering_minus1[i]" ); 477 #else478 WRITE_UVLC( pcSPS->getMaxDecPicBuffering(i), "sps_max_dec_pic_buffering[i]" );479 #endif480 449 WRITE_UVLC( pcSPS->getNumReorderPics(i), "sps_num_reorder_pics[i]" ); 481 WRITE_UVLC( pcSPS->getMaxLatencyIncrease(i), "sps_max_latency_increase [i]" );450 WRITE_UVLC( pcSPS->getMaxLatencyIncrease(i), "sps_max_latency_increase_plus1[i]" ); 482 451 if (!subLayerOrderingInfoPresentFlag) 483 452 { … … 541 510 WRITE_FLAG( pcSPS->getTMVPFlagsPresent() ? 1 : 0, "sps_temporal_mvp_enable_flag" ); 542 511 #if REF_IDX_MFM 512 #if !M0457_COL_PICTURE_SIGNALING 543 513 if( pcSPS->getLayerId() > 0 ) 544 514 { 545 515 WRITE_FLAG( pcSPS->getMFMEnabledFlag() ? 1 : 0, "sps_enh_mfm_enable_flag" ); 546 516 } 517 #endif 547 518 #endif 548 519 WRITE_FLAG( pcSPS->getUseStrongIntraSmoothing(), "sps_strong_intra_smoothing_enable_flag" ); … … 553 524 codeVUI(pcSPS->getVuiParameters(), pcSPS); 554 525 } 526 527 #if SPS_EXTENSION 528 WRITE_FLAG( 1, "sps_extension_flag" ); 529 if( 1 ) // if( sps_extension_flag ) 530 { 531 codeSPSExtension( pcSPS ); 532 WRITE_FLAG( 0, "sps_extension2_flag" ); 533 } 534 #else 535 WRITE_FLAG( 0, "sps_extension_flag" ); 536 #endif 537 } 538 #if SPS_EXTENSION 539 Void TEncCavlc::codeSPSExtension( TComSPS* pcSPS ) 540 { 541 // more syntax elements to be written here 555 542 #if SCALED_REF_LAYER_OFFSETS 543 #if SCALED_REF_LAYER_OFFSET_FLAG 544 WRITE_FLAG( pcSPS->getLayerId() > 0, "scaled_ref_layer_offset_present_flag" ); 556 545 if( pcSPS->getLayerId() > 0 ) 557 { 558 Window scaledWindow = pcSPS->getScaledRefLayerWindow(); 559 WRITE_SVLC( scaledWindow.getWindowLeftOffset() >> 1, "scaled_ref_layer_left_offset" ); 560 WRITE_SVLC( scaledWindow.getWindowTopOffset() >> 1, "scaled_ref_layer_top_offset" ); 561 WRITE_SVLC( scaledWindow.getWindowRightOffset() >> 1, "scaled_ref_layer_right_offset" ); 562 WRITE_SVLC( scaledWindow.getWindowBottomOffset() >> 1, "scaled_ref_layer_bottom_offset" ); 563 } 564 #endif 565 566 WRITE_FLAG( 0, "sps_extension_flag" ); 567 } 568 546 #else 547 if( pcSPS->getLayerId() > 0 ) 548 #endif 549 { 550 WRITE_UVLC( pcSPS->getNumScaledRefLayerOffsets(), "num_scaled_ref_layer_offsets" ); 551 for(Int i = 0; i < pcSPS->getNumScaledRefLayerOffsets(); i++) 552 { 553 Window scaledWindow = pcSPS->getScaledRefLayerWindow(i); 554 WRITE_SVLC( scaledWindow.getWindowLeftOffset() >> 1, "scaled_ref_layer_left_offset" ); 555 WRITE_SVLC( scaledWindow.getWindowTopOffset() >> 1, "scaled_ref_layer_top_offset" ); 556 WRITE_SVLC( scaledWindow.getWindowRightOffset() >> 1, "scaled_ref_layer_right_offset" ); 557 WRITE_SVLC( scaledWindow.getWindowBottomOffset() >> 1, "scaled_ref_layer_bottom_offset" ); 558 } 559 } 560 #endif 561 #if M0463_VUI_EXT_ILP_REF 562 //// sps_extension_vui_parameters( ) 563 if( pcSPS->getVuiParameters()->getBitstreamRestrictionFlag() ) 564 { 565 WRITE_UVLC( pcSPS->getNumIlpRestrictedRefLayers( ), "num_ilp_restricted_ref_layers" ); 566 for( Int i = 0; i < pcSPS->getNumIlpRestrictedRefLayers( ); i++ ) 567 { 568 WRITE_UVLC( pcSPS->getMinSpatialSegmentOffsetPlus1( i ), "min_spatial_segment_offset_plus1" ); 569 if( pcSPS->getMinSpatialSegmentOffsetPlus1( i ) > 0 ) 570 { 571 WRITE_FLAG( pcSPS->getCtuBasedOffsetEnabledFlag( i ), "ctu_based_offset_enabled_flag[ i ]"); 572 if( pcSPS->getCtuBasedOffsetEnabledFlag( i ) ) 573 { 574 WRITE_UVLC( pcSPS->getMinHorizontalCtuOffsetPlus1( i ), "min_horizontal_ctu_offset_plus1[ i ]"); 575 } 576 } 577 } 578 } 579 //// sps_extension_vui_parameters( ) END 580 #endif 581 } 582 #endif 569 583 Void TEncCavlc::codeVPS( TComVPS* pcVPS ) 570 584 { … … 581 595 WRITE_CODE( 0xffff, 16, "vps_reserved_ffff_16bits" ); 582 596 codePTL( pcVPS->getPTL(), true, pcVPS->getMaxTLayers() - 1 ); 583 #if SIGNAL_BITRATE_PICRATE_IN_VPS584 codeBitratePicRateInfo(pcVPS->getBitratePicrateInfo(), 0, pcVPS->getMaxTLayers() - 1);585 #endif586 597 const Bool subLayerOrderingInfoPresentFlag = 1; 587 598 WRITE_FLAG(subLayerOrderingInfoPresentFlag, "vps_sub_layer_ordering_info_present_flag"); 588 599 for(UInt i=0; i <= pcVPS->getMaxTLayers()-1; i++) 589 600 { 590 #if L0323_DPB591 601 WRITE_UVLC( pcVPS->getMaxDecPicBuffering(i) - 1, "vps_max_dec_pic_buffering_minus1[i]" ); 592 #else593 WRITE_UVLC( pcVPS->getMaxDecPicBuffering(i), "vps_max_dec_pic_buffering[i]" );594 #endif595 602 WRITE_UVLC( pcVPS->getNumReorderPics(i), "vps_num_reorder_pics[i]" ); 596 WRITE_UVLC( pcVPS->getMaxLatencyIncrease(i), "vps_max_latency_increase [i]" );603 WRITE_UVLC( pcVPS->getMaxLatencyIncrease(i), "vps_max_latency_increase_plus1[i]" ); 597 604 if (!subLayerOrderingInfoPresentFlag) 598 605 { … … 635 642 pcVPS->deriveLayerIdListVariables(); 636 643 #endif 637 #if L0043_TIMING_INFO638 644 TimingInfo *timingInfo = pcVPS->getTimingInfo(); 639 645 WRITE_FLAG(timingInfo->getTimingInfoPresentFlag(), "vps_timing_info_present_flag"); … … 647 653 WRITE_UVLC(timingInfo->getNumTicksPocDiffOneMinus1(), "vps_num_ticks_poc_diff_one_minus1"); 648 654 } 649 #endif650 655 pcVPS->setNumHrdParameters( 0 ); 651 656 WRITE_UVLC( pcVPS->getNumHrdParameters(), "vps_num_hrd_parameters" ); … … 666 671 codeHrdParameters(pcVPS->getHrdParameters(i), pcVPS->getCprmsPresentFlag( i ), pcVPS->getMaxTLayers() - 1); 667 672 } 668 #if L0043_TIMING_INFO 669 } 670 #endif 673 } 671 674 #if !VPS_EXTNS 672 675 WRITE_FLAG( 0, "vps_extension_flag" ); … … 696 699 } 697 700 701 #if VPS_SPLIT_FLAG 702 for(j = 0; j < vps->getNumScalabilityTypes() - vps->getSplittingFlag(); j++) 703 #else 698 704 for(j = 0; j < vps->getNumScalabilityTypes(); j++) 705 #endif 699 706 { 700 707 WRITE_CODE( vps->getDimensionIdLen(j) - 1, 3, "dimension_id_len_minus1[j]" ); … … 708 715 WRITE_CODE( vps->getLayerIdInNuh(i), 6, "layer_id_in_nuh[i]" ); 709 716 } 717 #if VPS_SPLIT_FLAG 718 if(!vps->getSplittingFlag()) 719 #endif 710 720 for(j = 0; j < vps->getNumScalabilityTypes(); j++) 711 721 { … … 725 735 } 726 736 #endif 737 #endif 738 #if JCTVC_M0203_INTERLAYER_PRED_IDC 739 for( i = 0; i < vps->getMaxLayers() - 1; i++) 740 { 741 WRITE_CODE(vps->getMaxSublayerForIlpPlus1(i), 3, "max_sublayer_for_ilp_plus1[i]" ); 742 } 727 743 #endif 728 744 #if VPS_EXTN_PROFILE_INFO … … 821 837 #endif 822 838 #endif 839 #if VPS_EXTN_DIRECT_REF_LAYERS && M0457_PREDICTION_INDICATIONS 840 WRITE_UVLC( vps->getDirectDepTypeLen()-2, "direct_dep_type_len_minus2"); 841 for(i = 1; i < vps->getMaxLayers(); i++) 842 { 843 for(j = 0; j < i; j++) 844 { 845 if (vps->getDirectDependencyFlag(i, j)) 846 { 847 WRITE_CODE( vps->getDirectDependencyType(i, j), vps->getDirectDepTypeLen(), "direct_dependency_type[i][j]" ); 848 } 849 } 850 } 851 #endif 852 #if M0040_ADAPTIVE_RESOLUTION_CHANGE 853 WRITE_FLAG(vps->getSingleLayerForNonIrapFlag(), "single_layer_for_non_irap_flag" ); 854 #endif 823 855 } 824 856 #endif … … 868 900 if ( !pcSlice->getDependentSliceSegmentFlag() ) 869 901 { 870 for (Int i = 0; i < pcSlice->getPPS()->getNumExtraSliceHeaderBits(); i++) 902 903 #if SH_DISCARDABLE_FLAG 904 if (pcSlice->getPPS()->getNumExtraSliceHeaderBits()>0) 905 { 906 assert(!!"discardable_flag"); 907 WRITE_FLAG(pcSlice->getDiscardableFlag(), "discardable_flag"); 908 } 909 for (Int i = 1; i < pcSlice->getPPS()->getNumExtraSliceHeaderBits(); i++) 871 910 { 872 911 assert(!!"slice_reserved_undetermined_flag[]"); 873 912 WRITE_FLAG(0, "slice_reserved_undetermined_flag[]"); 874 913 } 914 #else 915 for (Int i = 0; i < pcSlice->getPPS()->getNumExtraSliceHeaderBits(); i++) 916 { 917 assert(!!"slice_reserved_undetermined_flag[]"); 918 WRITE_FLAG(0, "slice_reserved_undetermined_flag[]"); 919 } 920 #endif 875 921 876 922 WRITE_UVLC( pcSlice->getSliceType(), "slice_type" ); … … 893 939 894 940 #if FIX1071 895 // Deal withbitstream restriction stating that:896 // –If the current picture is a BLA or CRA picture, the value of NumPocTotalCurr shall be equal to 0.941 // check for bitstream restriction stating that: 942 // If the current picture is a BLA or CRA picture, the value of NumPocTotalCurr shall be equal to 0. 897 943 // Ideally this process should not be repeated for each slice in a picture 898 TComReferencePictureSet altRps;899 Bool useAltRps = false;900 944 #if SVC_EXTENSION 901 945 if( pcSlice->getLayerId() == 0 ) 902 946 #endif 903 if (pcSlice->getRapPicFlag()) 904 { 905 for (Int picIdx = 0; !useAltRps && picIdx < rps->getNumberOfPictures(); picIdx++) 906 { 907 useAltRps = rps->getUsed(picIdx); 908 } 909 if (useAltRps) 910 { 911 memcpy(&altRps, rps, sizeof(TComReferencePictureSet)); 912 rps = &altRps; 913 for (Int picIdx = 0; picIdx < rps->getNumberOfPictures(); picIdx++) 914 { 915 rps->setUsed(picIdx, false); 916 } 917 } 918 } 919 920 if(pcSlice->getRPSidx() < 0 || useAltRps) 921 #else 947 if (pcSlice->isIRAP()) 948 { 949 for (Int picIdx = 0; picIdx < rps->getNumberOfPictures(); picIdx++) 950 { 951 assert (!rps->getUsed(picIdx)); 952 } 953 } 954 #endif 955 922 956 if(pcSlice->getRPSidx() < 0) 923 #endif924 957 { 925 958 WRITE_FLAG( 0, "short_term_ref_pic_set_sps_flag"); … … 1013 1046 } 1014 1047 } 1015 1016 1048 if (pcSlice->getSPS()->getTMVPFlagsPresent()) 1017 1049 { … … 1035 1067 if( !pcSlice->getVPS()->getMaxOneActiveRefLayerFlag()) 1036 1068 { 1037 WRITE_CODE(pcSlice->get NumInterLayerRefPics(), numBits,"num_inter_layer_ref_pics_minus1");1069 WRITE_CODE(pcSlice->getActiveNumILRRefIdx() - 1, numBits,"num_inter_layer_ref_pics_minus1"); 1038 1070 } 1039 for(Int i = 0; i < pcSlice->getActiveNumILRRefIdx(); i++ ) 1071 for(Int i = 0; i < pcSlice->getActiveNumILRRefIdx(); i++ ) 1072 { 1040 1073 WRITE_CODE(pcSlice->getInterLayerPredLayerIdc(i),numBits,"inter_layer_pred_layer_idc[i]"); 1074 } 1041 1075 } 1042 1076 } 1043 1077 } 1078 #if M0457_IL_SAMPLE_PRED_ONLY_FLAG 1079 if( pcSlice->getNumSamplePredRefLayers() > 0 && pcSlice->getActiveNumILRRefIdx() > 0 ) 1080 { 1081 WRITE_FLAG( pcSlice->getInterLayerSamplePredOnlyFlag(), "inter_layer_sample_pred_only_flag" ); 1082 } 1083 #endif 1044 1084 #endif 1045 1085 … … 1147 1187 if ( pcSlice->getEnableTMVPFlag() ) 1148 1188 { 1189 #if REF_IDX_FRAMEWORK && M0457_COL_PICTURE_SIGNALING 1190 if ( !pcSlice->getIdrPicFlag() && pcSlice->getLayerId() > 0 && pcSlice->getActiveNumILRRefIdx() > 0 && pcSlice->getNumMotionPredRefLayers() > 0 ) 1191 { 1192 WRITE_FLAG( pcSlice->getAltColIndicationFlag() ? 1 : 0, "alt_collocated_indication_flag" ); 1193 if (pcSlice->getAltColIndicationFlag() && pcSlice->getNumMotionPredRefLayers() > 1) 1194 { 1195 WRITE_UVLC(0, "collocated_ref_layer_idx"); 1196 } 1197 } 1198 else 1199 { 1200 #endif 1149 1201 if ( pcSlice->getSliceType() == B_SLICE ) 1150 1202 { … … 1158 1210 WRITE_UVLC( pcSlice->getColRefIdx(), "collocated_ref_idx" ); 1159 1211 } 1212 #if REF_IDX_FRAMEWORK && M0457_COL_PICTURE_SIGNALING 1213 } 1214 #endif 1160 1215 } 1161 1216 if ( (pcSlice->getPPS()->getUseWP() && pcSlice->getSliceType()==P_SLICE) || (pcSlice->getPPS()->getWPBiPred() && pcSlice->getSliceType()==B_SLICE) ) … … 1202 1257 } 1203 1258 } 1204 1205 1259 if(pcSlice->getPPS()->getSliceHeaderExtensionPresentFlag()) 1206 1260 { … … 1217 1271 WRITE_CODE( pcPTL->getGeneralPTL()->getLevelIdc(), 8, "general_level_idc" ); 1218 1272 1219 #if L0363_BYTE_ALIGN1220 1273 for (Int i = 0; i < maxNumSubLayersMinus1; i++) 1221 1274 { … … 1235 1288 } 1236 1289 } 1237 #endif1238 1290 1239 1291 for(Int i = 0; i < maxNumSubLayersMinus1; i++) 1240 1292 { 1241 #if !L0363_BYTE_ALIGN1242 if(profilePresentFlag)1243 {1244 WRITE_FLAG( pcPTL->getSubLayerProfilePresentFlag(i), "sub_layer_profile_present_flag[i]" );1245 }1246 1247 WRITE_FLAG( pcPTL->getSubLayerLevelPresentFlag(i), "sub_layer_level_present_flag[i]" );1248 #endif1249 1293 if( profilePresentFlag && pcPTL->getSubLayerProfilePresentFlag(i) ) 1250 1294 { … … 1267 1311 } 1268 1312 1269 #if L0046_CONSTRAINT_FLAGS1270 1313 WRITE_FLAG(ptl->getProgressiveSourceFlag(), "general_progressive_source_flag"); 1271 1314 WRITE_FLAG(ptl->getInterlacedSourceFlag(), "general_interlaced_source_flag"); … … 1276 1319 WRITE_CODE(0 , 16, "XXX_reserved_zero_44bits[16..31]"); 1277 1320 WRITE_CODE(0 , 12, "XXX_reserved_zero_44bits[32..43]"); 1278 #elif L0363_MORE_BITS 1279 WRITE_CODE(0 , 16, "XXX_reserved_zero_48bits[0..15]"); 1280 WRITE_CODE(0 , 16, "XXX_reserved_zero_48bits[16..31]"); 1281 WRITE_CODE(0 , 16, "XXX_reserved_zero_48bits[32..47]"); 1282 #else 1283 WRITE_CODE(0 , 16, "XXX_reserved_zero_16bits[]"); 1284 #endif 1285 } 1286 #if SIGNAL_BITRATE_PICRATE_IN_VPS 1287 Void TEncCavlc::codeBitratePicRateInfo(TComBitRatePicRateInfo *info, Int tempLevelLow, Int tempLevelHigh) 1288 { 1289 for(Int i = tempLevelLow; i <= tempLevelHigh; i++) 1290 { 1291 WRITE_FLAG( info->getBitRateInfoPresentFlag(i), "bit_rate_info_present_flag[i]" ); 1292 WRITE_FLAG( info->getPicRateInfoPresentFlag(i), "pic_rate_info_present_flag[i]" ); 1293 if(info->getBitRateInfoPresentFlag(i)) 1294 { 1295 WRITE_CODE( info->getAvgBitRate(i), 16, "avg_bit_rate[i]" ); 1296 WRITE_CODE( info->getMaxBitRate(i), 16, "max_bit_rate[i]" ); 1297 } 1298 if(info->getPicRateInfoPresentFlag(i)) 1299 { 1300 WRITE_CODE( info->getConstantPicRateIdc(i), 2, "constant_pic_rate_idc[i]" ); 1301 WRITE_CODE( info->getAvgPicRate(i), 16, "avg_pic_rate[i]" ); 1302 } 1303 } 1304 } 1305 #endif 1321 } 1322 1306 1323 /** 1307 1324 - write wavefront substreams sizes for the slice header. … … 1373 1390 for (UInt idx=0; idx<numEntryPointOffsets; idx++) 1374 1391 { 1375 #if L0116_ENTRY_POINT1376 1392 WRITE_CODE(entryPointOffset[ idx ]-1, offsetLenMinus1+1, "entry_point_offset_minus1"); 1377 #else1378 WRITE_CODE(entryPointOffset[ idx ], offsetLenMinus1+1, "entry_point_offset");1379 #endif1380 1393 } 1381 1394 -
trunk/source/Lib/TLibEncoder/TEncCavlc.h
r191 r310 89 89 Void codeVUI ( TComVUI *pcVUI, TComSPS* pcSPS ); 90 90 Void codeSPS ( TComSPS* pcSPS ); 91 #if SPS_EXTENSION 92 Void codeSPSExtension ( TComSPS* pcSPS ); 93 #endif 91 94 Void codePPS ( TComPPS* pcPPS ); 92 95 Void codeSliceHeader ( TComSlice* pcSlice ); 93 96 Void codePTL ( TComPTL* pcPTL, Bool profilePresentFlag, Int maxNumSubLayersMinus1); 94 97 Void codeProfileTier ( ProfileTierLevel* ptl ); 95 #if SIGNAL_BITRATE_PICRATE_IN_VPS96 Void codeBitratePicRateInfo(TComBitRatePicRateInfo *info, Int tempLevelLow, Int tempLevelHigh);97 #endif98 98 Void codeHrdParameters ( TComHRD *hrd, Bool commonInfPresentFlag, UInt maxNumSubLayersMinus1 ); 99 99 Void codeTilesWPPEntryPoint( TComSlice* pSlice ); -
trunk/source/Lib/TLibEncoder/TEncCfg.h
r191 r310 116 116 Level::Tier m_levelTier; 117 117 Level::Name m_level; 118 #if L0046_CONSTRAINT_FLAGS119 118 Bool m_progressiveSourceFlag; 120 119 Bool m_interlacedSourceFlag; 121 120 Bool m_nonPackedConstraintFlag; 122 121 Bool m_frameOnlyConstraintFlag; 123 #endif124 122 125 123 //====== Coding Structure ======== … … 145 143 Int m_numDirectRefLayers; 146 144 Int m_refLayerId[MAX_VPS_LAYER_ID_PLUS1]; 145 146 Int m_numActiveRefLayers; 147 Int m_predLayerId[MAX_VPS_LAYER_ID_PLUS1]; 148 #if M0457_PREDICTION_INDICATIONS 149 Int m_numSamplePredRefLayers; 150 Int m_samplePredRefLayerId[MAX_VPS_LAYER_ID_PLUS1]; 151 Int m_numMotionPredRefLayers; 152 Int m_motionPredRefLayerId[MAX_VPS_LAYER_ID_PLUS1]; 153 Bool m_samplePredEnabledFlag[MAX_VPS_LAYER_ID_PLUS1]; 154 Bool m_motionPredEnabledFlag[MAX_VPS_LAYER_ID_PLUS1]; 155 #endif 147 156 #endif 148 157 //======= Transform ============= … … 158 167 Int m_loopFilterTcOffsetDiv2; 159 168 Bool m_DeblockingFilterControlPresent; 160 #if L0386_DB_METRIC161 169 Bool m_DeblockingFilterMetric; 162 #endif163 170 Bool m_bUseSAO; 164 171 Int m_maxNumOffsetsPerPic; … … 191 198 Bool m_bUseASR; 192 199 Bool m_bUseHADME; 193 #if !L0034_COMBINED_LIST_CLEANUP194 Bool m_bUseLComb;195 #endif196 200 Bool m_useRDOQ; 197 201 Bool m_useRDOQTS; 198 #if L0232_RD_PENALTY199 202 UInt m_rdPenalty; 200 #endif201 203 Bool m_bUseFastEnc; 202 204 Bool m_bUseEarlyCU; … … 204 206 Bool m_bUseCbfFastMode; 205 207 Bool m_useEarlySkipDetection; 208 #if FAST_INTRA_SHVC 209 Bool m_useFastIntraScalable; 210 #endif 206 211 Bool m_useTransformSkip; 207 212 Bool m_useTransformSkipFast; … … 239 244 Int m_pictureTimingSEIEnabled; 240 245 Int m_recoveryPointSEIEnabled; 241 #if J0149_TONE_MAPPING_SEI242 246 Bool m_toneMappingInfoSEIEnabled; 243 247 Int m_toneMapId; … … 265 269 Int* m_codedPivotValue; 266 270 Int* m_targetPivotValue; 267 #endif268 271 Int m_framePackingSEIEnabled; 269 272 Int m_framePackingSEIType; … … 275 278 Int m_gradualDecodingRefreshInfoEnabled; 276 279 Int m_decodingUnitInfoSEIEnabled; 277 #if L0208_SOP_DESCRIPTION_SEI 280 #if M0043_LAYERS_PRESENT_SEI 281 Int m_layersPresentSEIEnabled; 282 #endif 278 283 Int m_SOPDescriptionSEIEnabled; 279 #endif280 #if K0180_SCALABLE_NESTING_SEI281 284 Int m_scalableNestingSEIEnabled; 282 #endif283 285 //====== Weighted Prediction ======== 284 286 Bool m_useWeightedPred; //< Use of Weighting Prediction (P_SLICE) … … 293 295 Bool m_RCEnableRateControl; 294 296 Int m_RCTargetBitrate; 297 #if M0036_RC_IMPROVEMENT 298 Int m_RCKeepHierarchicalBit; 299 #else 295 300 Bool m_RCKeepHierarchicalBit; 301 #endif 296 302 Bool m_RCLCULevelRC; 297 303 Bool m_RCUseLCUSeparateModel; … … 351 357 Int m_elRapSliceBEnabled; 352 358 #endif 359 #if M0040_ADAPTIVE_RESOLUTION_CHANGE 360 Int m_adaptiveResolutionChange; 361 #endif 353 362 354 363 public: … … 402 411 Int getRefLayerId (Int i) { return m_refLayerId[i]; } 403 412 Void setRefLayerId (Int i, Int refLayerId) { m_refLayerId[i] = refLayerId; } 413 414 Int getNumActiveRefLayers () { return m_numActiveRefLayers; } 415 Void setNumActiveRefLayers (Int num) { m_numActiveRefLayers = num; } 416 417 Int getPredLayerId (Int i) { return m_predLayerId[i]; } 418 Void setPredLayerId (Int i, Int refLayerId) { m_predLayerId[i] = refLayerId; } 419 420 #if M0457_PREDICTION_INDICATIONS 421 Int getNumSamplePredRefLayers () { return m_numSamplePredRefLayers; } 422 Void setNumSamplePredRefLayers (Int num) { m_numSamplePredRefLayers = num; } 423 424 Int getSamplePredRefLayerId (Int i) { return m_samplePredRefLayerId[i]; } 425 Void setSamplePredRefLayerId (Int i, Int refLayerId) { m_samplePredRefLayerId[i] = refLayerId; } 426 427 Int getNumMotionPredRefLayers () { return m_numMotionPredRefLayers; } 428 Void setNumMotionPredRefLayers (Int num) { m_numMotionPredRefLayers = num; } 429 430 Int getMotionPredRefLayerId (Int i) { return m_motionPredRefLayerId[i]; } 431 Void setMotionPredRefLayerId (Int i, Int refLayerId) { m_motionPredRefLayerId[i] = refLayerId; } 432 433 Bool getSamplePredEnabledFlag (Int i) { return m_samplePredEnabledFlag[i]; } 434 Void setSamplePredEnabledFlag (Int i,Bool flag) { m_samplePredEnabledFlag[i] = flag; } 435 436 Bool getMotionPredEnabledFlag (Int i) { return m_motionPredEnabledFlag[i]; } 437 Void setMotionPredEnabledFlag (Int i,Bool flag) { m_motionPredEnabledFlag[i] = flag; } 438 #endif 404 439 #endif 405 440 //======== Transform ============= … … 417 452 Void setLoopFilterTcOffset ( Int i ) { m_loopFilterTcOffsetDiv2 = i; } 418 453 Void setDeblockingFilterControlPresent ( Bool b ) { m_DeblockingFilterControlPresent = b; } 419 #if L0386_DB_METRIC420 454 Void setDeblockingFilterMetric ( Bool b ) { m_DeblockingFilterMetric = b; } 421 #endif422 455 423 456 //====== Motion search ======== … … 474 507 Int getLoopFilterTcOffset () { return m_loopFilterTcOffsetDiv2; } 475 508 Bool getDeblockingFilterControlPresent() { return m_DeblockingFilterControlPresent; } 476 #if L0386_DB_METRIC477 509 Bool getDeblockingFilterMetric () { return m_DeblockingFilterMetric; } 478 #endif479 510 480 511 //==== Motion search ======== … … 494 525 Void setUseASR ( Bool b ) { m_bUseASR = b; } 495 526 Void setUseHADME ( Bool b ) { m_bUseHADME = b; } 496 #if !L0034_COMBINED_LIST_CLEANUP497 Void setUseLComb ( Bool b ) { m_bUseLComb = b; }498 #endif499 527 Void setUseRDOQ ( Bool b ) { m_useRDOQ = b; } 500 528 Void setUseRDOQTS ( Bool b ) { m_useRDOQTS = b; } 501 #if L0232_RD_PENALTY502 529 Void setRDpenalty ( UInt b ) { m_rdPenalty = b; } 503 #endif504 530 Void setUseFastEnc ( Bool b ) { m_bUseFastEnc = b; } 505 531 Void setUseEarlyCU ( Bool b ) { m_bUseEarlyCU = b; } … … 507 533 Void setUseCbfFastMode ( Bool b ) { m_bUseCbfFastMode = b; } 508 534 Void setUseEarlySkipDetection ( Bool b ) { m_useEarlySkipDetection = b; } 535 #if FAST_INTRA_SHVC 536 Void setUseFastIntraScalable ( Bool b ) { m_useFastIntraScalable = b; } 537 #endif 509 538 Void setUseConstrainedIntraPred ( Bool b ) { m_bUseConstrainedIntraPred = b; } 510 539 Void setPCMInputBitDepthFlag ( Bool b ) { m_bPCMInputBitDepthFlag = b; } … … 518 547 Bool getUseASR () { return m_bUseASR; } 519 548 Bool getUseHADME () { return m_bUseHADME; } 520 #if !L0034_COMBINED_LIST_CLEANUP521 Bool getUseLComb () { return m_bUseLComb; }522 #endif523 549 Bool getUseRDOQ () { return m_useRDOQ; } 524 550 Bool getUseRDOQTS () { return m_useRDOQTS; } 525 #if L0232_RD_PENALTY526 551 Int getRDpenalty () { return m_rdPenalty; } 527 #endif528 552 Bool getUseFastEnc () { return m_bUseFastEnc; } 529 553 Bool getUseEarlyCU () { return m_bUseEarlyCU; } … … 531 555 Bool getUseCbfFastMode () { return m_bUseCbfFastMode; } 532 556 Bool getUseEarlySkipDetection () { return m_useEarlySkipDetection; } 557 #if FAST_INTRA_SHVC 558 Bool getUseFastIntraScalable () { return m_useFastIntraScalable; } 559 #endif 533 560 Bool getUseConstrainedIntraPred () { return m_bUseConstrainedIntraPred; } 534 561 Bool getPCMInputBitDepthFlag () { return m_bPCMInputBitDepthFlag; } … … 617 644 Void setRecoveryPointSEIEnabled(Int b) { m_recoveryPointSEIEnabled = b; } 618 645 Int getRecoveryPointSEIEnabled() { return m_recoveryPointSEIEnabled; } 619 #if J0149_TONE_MAPPING_SEI620 646 Void setToneMappingInfoSEIEnabled(Bool b) { m_toneMappingInfoSEIEnabled = b; } 621 647 Bool getToneMappingInfoSEIEnabled() { return m_toneMappingInfoSEIEnabled; } … … 668 694 Void setTMISEIExtendedWhiteLevelLumaCodeValue(Int b) { m_extendedWhiteLevelLumaCodeValue =b; } 669 695 Int getTMISEIExtendedWhiteLevelLumaCodeValue() { return m_extendedWhiteLevelLumaCodeValue; } 670 #endif671 696 Void setFramePackingArrangementSEIEnabled(Int b) { m_framePackingSEIEnabled = b; } 672 697 Int getFramePackingArrangementSEIEnabled() { return m_framePackingSEIEnabled; } … … 687 712 Void setDecodingUnitInfoSEIEnabled(Int b) { m_decodingUnitInfoSEIEnabled = b; } 688 713 Int getDecodingUnitInfoSEIEnabled() { return m_decodingUnitInfoSEIEnabled; } 689 #if L0208_SOP_DESCRIPTION_SEI 714 #if M0043_LAYERS_PRESENT_SEI 715 Void setLayersPresentSEIEnabled(Int b) { m_layersPresentSEIEnabled = b; } 716 Int getLayersPresentSEIEnabled() { return m_layersPresentSEIEnabled; } 717 #endif 690 718 Void setSOPDescriptionSEIEnabled(Int b) { m_SOPDescriptionSEIEnabled = b; } 691 719 Int getSOPDescriptionSEIEnabled() { return m_SOPDescriptionSEIEnabled; } 692 #endif693 #if K0180_SCALABLE_NESTING_SEI694 720 Void setScalableNestingSEIEnabled(Int b) { m_scalableNestingSEIEnabled = b; } 695 721 Int getScalableNestingSEIEnabled() { return m_scalableNestingSEIEnabled; } 696 #endif697 722 Void setUseWP ( Bool b ) { m_useWeightedPred = b; } 698 723 Void setWPBiPred ( Bool b ) { m_useWeightedBiPred = b; } … … 716 741 Int getTargetBitrate () { return m_RCTargetBitrate; } 717 742 Void setTargetBitrate ( Int bitrate ) { m_RCTargetBitrate = bitrate; } 743 #if M0036_RC_IMPROVEMENT 744 Int getKeepHierBit () { return m_RCKeepHierarchicalBit; } 745 Void setKeepHierBit ( Int i ) { m_RCKeepHierarchicalBit = i; } 746 #else 718 747 Bool getKeepHierBit () { return m_RCKeepHierarchicalBit; } 719 748 Void setKeepHierBit ( Bool b ) { m_RCKeepHierarchicalBit = b; } 749 #endif 720 750 Bool getLCULevelRC () { return m_RCLCULevelRC; } 721 751 Void setLCULevelRC ( Bool b ) { m_RCLCULevelRC = b; } … … 809 839 Void setLog2MaxMvLengthVertical(Int i) { m_log2MaxMvLengthVertical = i; } 810 840 811 #if L0046_CONSTRAINT_FLAGS812 841 Bool getProgressiveSourceFlag() const { return m_progressiveSourceFlag; } 813 842 Void setProgressiveSourceFlag(Bool b) { m_progressiveSourceFlag = b; } … … 821 850 Bool getFrameOnlyConstraintFlag() const { return m_frameOnlyConstraintFlag; } 822 851 Void setFrameOnlyConstraintFlag(Bool b) { m_frameOnlyConstraintFlag = b; } 823 #endif824 852 825 853 #if SVC_EXTENSION … … 835 863 Int getElRapSliceTypeB() {return m_elRapSliceBEnabled;} 836 864 #endif 865 #if M0040_ADAPTIVE_RESOLUTION_CHANGE 866 Void setAdaptiveResolutionChange(Int x) { m_adaptiveResolutionChange = x; } 867 Int getAdaptiveResolutionChange() { return m_adaptiveResolutionChange; } 868 #endif 837 869 }; 838 870 -
trunk/source/Lib/TLibEncoder/TEncCu.cpp
r191 r310 95 95 96 96 m_bEncodeDQP = false; 97 #if RATE_CONTROL_LAMBDA_DOMAIN 97 #if RATE_CONTROL_LAMBDA_DOMAIN && !M0036_RC_IMPROVEMENT 98 98 m_LCUPredictionSAD = 0; 99 99 m_addSADDepth = 0; … … 244 244 m_ppcTempCU[0]->initCU( rpcCU->getPic(), rpcCU->getAddr() ); 245 245 246 #if RATE_CONTROL_LAMBDA_DOMAIN 246 #if RATE_CONTROL_LAMBDA_DOMAIN && !M0036_RC_IMPROVEMENT 247 247 m_addSADDepth = 0; 248 248 m_LCUPredictionSAD = 0; … … 455 455 { 456 456 #if (ENCODER_FAST_MODE) 457 bool testInter = true;457 Bool testInter = true; 458 458 if (rpcBestCU->getLayerId() > 0) 459 459 { 460 if (rpcBestCU->getSlice()->getBaseColPic()->getSlice(0)->getSliceType() == I_SLICE) 461 { 462 testInter = false; 463 } 464 460 if(pcSlice->getSliceType() == P_SLICE && pcSlice->getNumRefIdx(REF_PIC_LIST_0) == pcSlice->getActiveNumILRRefIdx()) 461 testInter = false; 462 if(pcSlice->getSliceType() == B_SLICE && pcSlice->getNumRefIdx(REF_PIC_LIST_0) == pcSlice->getActiveNumILRRefIdx() && pcSlice->getNumRefIdx(REF_PIC_LIST_1) == pcSlice->getActiveNumILRRefIdx()) 463 testInter = false; 464 #if M0457_IL_SAMPLE_PRED_ONLY_FLAG 465 if( pcSlice->getInterLayerSamplePredOnlyFlag() ) 466 testInter = false; 467 #endif 465 468 } 466 469 #endif … … 544 547 } 545 548 546 #if RATE_CONTROL_LAMBDA_DOMAIN 549 #if RATE_CONTROL_LAMBDA_DOMAIN && !M0036_RC_IMPROVEMENT 547 550 if ( uiDepth <= m_addSADDepth ) 548 551 { … … 767 770 } 768 771 #endif 769 770 772 #if (ENCODER_FAST_MODE) 771 if(pcPic->getLayerId() > 0) 772 { 773 xCheckRDCostILRUni( rpcBestCU, rpcTempCU); 774 rpcTempCU->initEstData( uiDepth, iQP ); 775 } 773 if(pcPic->getLayerId() > 0) 774 { 775 for(Int refLayer = 0; refLayer < pcSlice->getActiveNumILRRefIdx(); refLayer++) 776 { 777 xCheckRDCostILRUni( rpcBestCU, rpcTempCU, pcSlice->getInterLayerPredLayerIdc(refLayer)); 778 rpcTempCU->initEstData( uiDepth, iQP ); 779 } 780 } 776 781 #endif 777 782 … … 816 821 { 817 822 bBoundary = true; 818 #if RATE_CONTROL_LAMBDA_DOMAIN 823 #if RATE_CONTROL_LAMBDA_DOMAIN && !M0036_RC_IMPROVEMENT 819 824 m_addSADDepth++; 820 825 #endif … … 1246 1251 } 1247 1252 1253 #if RATE_CONTROL_INTRA 1254 Int xCalcHADs8x8_ISlice(Pel *piOrg, Int iStrideOrg) 1255 { 1256 Int k, i, j, jj; 1257 Int diff[64], m1[8][8], m2[8][8], m3[8][8], iSumHad = 0; 1258 1259 for( k = 0; k < 64; k += 8 ) 1260 { 1261 diff[k+0] = piOrg[0] ; 1262 diff[k+1] = piOrg[1] ; 1263 diff[k+2] = piOrg[2] ; 1264 diff[k+3] = piOrg[3] ; 1265 diff[k+4] = piOrg[4] ; 1266 diff[k+5] = piOrg[5] ; 1267 diff[k+6] = piOrg[6] ; 1268 diff[k+7] = piOrg[7] ; 1269 1270 piOrg += iStrideOrg; 1271 } 1272 1273 //horizontal 1274 for (j=0; j < 8; j++) 1275 { 1276 jj = j << 3; 1277 m2[j][0] = diff[jj ] + diff[jj+4]; 1278 m2[j][1] = diff[jj+1] + diff[jj+5]; 1279 m2[j][2] = diff[jj+2] + diff[jj+6]; 1280 m2[j][3] = diff[jj+3] + diff[jj+7]; 1281 m2[j][4] = diff[jj ] - diff[jj+4]; 1282 m2[j][5] = diff[jj+1] - diff[jj+5]; 1283 m2[j][6] = diff[jj+2] - diff[jj+6]; 1284 m2[j][7] = diff[jj+3] - diff[jj+7]; 1285 1286 m1[j][0] = m2[j][0] + m2[j][2]; 1287 m1[j][1] = m2[j][1] + m2[j][3]; 1288 m1[j][2] = m2[j][0] - m2[j][2]; 1289 m1[j][3] = m2[j][1] - m2[j][3]; 1290 m1[j][4] = m2[j][4] + m2[j][6]; 1291 m1[j][5] = m2[j][5] + m2[j][7]; 1292 m1[j][6] = m2[j][4] - m2[j][6]; 1293 m1[j][7] = m2[j][5] - m2[j][7]; 1294 1295 m2[j][0] = m1[j][0] + m1[j][1]; 1296 m2[j][1] = m1[j][0] - m1[j][1]; 1297 m2[j][2] = m1[j][2] + m1[j][3]; 1298 m2[j][3] = m1[j][2] - m1[j][3]; 1299 m2[j][4] = m1[j][4] + m1[j][5]; 1300 m2[j][5] = m1[j][4] - m1[j][5]; 1301 m2[j][6] = m1[j][6] + m1[j][7]; 1302 m2[j][7] = m1[j][6] - m1[j][7]; 1303 } 1304 1305 //vertical 1306 for (i=0; i < 8; i++) 1307 { 1308 m3[0][i] = m2[0][i] + m2[4][i]; 1309 m3[1][i] = m2[1][i] + m2[5][i]; 1310 m3[2][i] = m2[2][i] + m2[6][i]; 1311 m3[3][i] = m2[3][i] + m2[7][i]; 1312 m3[4][i] = m2[0][i] - m2[4][i]; 1313 m3[5][i] = m2[1][i] - m2[5][i]; 1314 m3[6][i] = m2[2][i] - m2[6][i]; 1315 m3[7][i] = m2[3][i] - m2[7][i]; 1316 1317 m1[0][i] = m3[0][i] + m3[2][i]; 1318 m1[1][i] = m3[1][i] + m3[3][i]; 1319 m1[2][i] = m3[0][i] - m3[2][i]; 1320 m1[3][i] = m3[1][i] - m3[3][i]; 1321 m1[4][i] = m3[4][i] + m3[6][i]; 1322 m1[5][i] = m3[5][i] + m3[7][i]; 1323 m1[6][i] = m3[4][i] - m3[6][i]; 1324 m1[7][i] = m3[5][i] - m3[7][i]; 1325 1326 m2[0][i] = m1[0][i] + m1[1][i]; 1327 m2[1][i] = m1[0][i] - m1[1][i]; 1328 m2[2][i] = m1[2][i] + m1[3][i]; 1329 m2[3][i] = m1[2][i] - m1[3][i]; 1330 m2[4][i] = m1[4][i] + m1[5][i]; 1331 m2[5][i] = m1[4][i] - m1[5][i]; 1332 m2[6][i] = m1[6][i] + m1[7][i]; 1333 m2[7][i] = m1[6][i] - m1[7][i]; 1334 } 1335 1336 for (i = 0; i < 8; i++) 1337 { 1338 for (j = 0; j < 8; j++) 1339 { 1340 iSumHad += abs(m2[i][j]); 1341 } 1342 } 1343 iSumHad -= abs(m2[0][0]); 1344 iSumHad =(iSumHad+2)>>2; 1345 return(iSumHad); 1346 } 1347 1348 Int TEncCu::updateLCUDataISlice(TComDataCU* pcCU, Int LCUIdx, Int width, Int height) 1349 { 1350 Int xBl, yBl; 1351 const Int iBlkSize = 8; 1352 1353 Pel* pOrgInit = pcCU->getPic()->getPicYuvOrg()->getLumaAddr(pcCU->getAddr(), 0); 1354 Int iStrideOrig = pcCU->getPic()->getPicYuvOrg()->getStride(); 1355 Pel *pOrg; 1356 1357 Int iSumHad = 0; 1358 for ( yBl=0; (yBl+iBlkSize)<=height; yBl+= iBlkSize) 1359 { 1360 for ( xBl=0; (xBl+iBlkSize)<=width; xBl+= iBlkSize) 1361 { 1362 pOrg = pOrgInit + iStrideOrig*yBl + xBl; 1363 iSumHad += xCalcHADs8x8_ISlice(pOrg, iStrideOrig); 1364 } 1365 } 1366 return(iSumHad); 1367 } 1368 #endif 1369 1248 1370 /** check RD costs for a CU block encoded with merge 1249 1371 * \param rpcBestCU … … 1254 1376 { 1255 1377 assert( rpcTempCU->getSlice()->getSliceType() != I_SLICE ); 1256 TComMvField cMvFieldNeighbours[ MRG_MAX_NUM_CANDS << 1]; // double length for mv of both lists1378 TComMvField cMvFieldNeighbours[ 2 * MRG_MAX_NUM_CANDS ]; // double length for mv of both lists 1257 1379 UChar uhInterDirNeighbours[MRG_MAX_NUM_CANDS]; 1258 1380 Int numValidMergeCand = 0; … … 1268 1390 1269 1391 Int mergeCandBuffer[MRG_MAX_NUM_CANDS]; 1270 for( UInt ui = 0; ui < rpcTempCU->getSlice()->getMaxNumMergeCand(); ++ui )1392 for( UInt ui = 0; ui < numValidMergeCand; ++ui ) 1271 1393 { 1272 1394 mergeCandBuffer[ui] = 0; … … 1294 1416 { 1295 1417 #endif 1296 if(!(uiNoResidual==1 && mergeCandBuffer[uiMergeCand]==1)) 1297 { 1298 1418 if(!(uiNoResidual==1 && mergeCandBuffer[uiMergeCand]==1)) 1419 { 1299 1420 if( !(bestIsSkip && uiNoResidual == 0) ) 1300 1421 { … … 1308 1429 rpcTempCU->getCUMvField( REF_PIC_LIST_0 )->setAllMvField( cMvFieldNeighbours[0 + 2*uiMergeCand], SIZE_2Nx2N, 0, 0 ); // interprets depth relative to rpcTempCU level 1309 1430 rpcTempCU->getCUMvField( REF_PIC_LIST_1 )->setAllMvField( cMvFieldNeighbours[1 + 2*uiMergeCand], SIZE_2Nx2N, 0, 0 ); // interprets depth relative to rpcTempCU level 1310 1311 // do MC 1312 m_pcPredSearch->motionCompensation ( rpcTempCU, m_ppcPredYuvTemp[uhDepth] ); 1313 // estimate residual and encode everything 1314 m_pcPredSearch->encodeResAndCalcRdInterCU( rpcTempCU, 1315 m_ppcOrigYuv [uhDepth], 1316 m_ppcPredYuvTemp[uhDepth], 1317 m_ppcResiYuvTemp[uhDepth], 1318 m_ppcResiYuvBest[uhDepth], 1319 m_ppcRecoYuvTemp[uhDepth], 1320 (uiNoResidual? true:false)); 1321 1322 1323 if(uiNoResidual==0) 1324 { 1325 if(rpcTempCU->getQtRootCbf(0) == 0) 1326 { 1327 mergeCandBuffer[uiMergeCand] = 1; 1328 } 1329 } 1330 1331 rpcTempCU->setSkipFlagSubParts( rpcTempCU->getQtRootCbf(0) == 0, 0, uhDepth ); 1431 1432 // do MC 1433 m_pcPredSearch->motionCompensation ( rpcTempCU, m_ppcPredYuvTemp[uhDepth] ); 1434 // estimate residual and encode everything 1435 m_pcPredSearch->encodeResAndCalcRdInterCU( rpcTempCU, 1436 m_ppcOrigYuv [uhDepth], 1437 m_ppcPredYuvTemp[uhDepth], 1438 m_ppcResiYuvTemp[uhDepth], 1439 m_ppcResiYuvBest[uhDepth], 1440 m_ppcRecoYuvTemp[uhDepth], 1441 (uiNoResidual? true:false)); 1442 1443 1444 if ( uiNoResidual == 0 && rpcTempCU->getQtRootCbf(0) == 0 ) 1445 { 1446 // If no residual when allowing for one, then set mark to not try case where residual is forced to 0 1447 mergeCandBuffer[uiMergeCand] = 1; 1448 } 1449 1450 rpcTempCU->setSkipFlagSubParts( rpcTempCU->getQtRootCbf(0) == 0, 0, uhDepth ); 1332 1451 Int orgQP = rpcTempCU->getQP( 0 ); 1333 1452 xCheckDQP( rpcTempCU ); 1334 1453 xCheckBestMode(rpcBestCU, rpcTempCU, uhDepth); 1335 1454 rpcTempCU->initEstData( uhDepth, orgQP ); 1336 1337 1338 if( m_pcEncCfg->getUseFastDecisionForMerge() && !bestIsSkip ) 1339 { 1340 bestIsSkip = rpcBestCU->getQtRootCbf(0) == 0; 1341 } 1342 1343 } 1344 } 1455 1456 if( m_pcEncCfg->getUseFastDecisionForMerge() && !bestIsSkip ) 1457 { 1458 bestIsSkip = rpcBestCU->getQtRootCbf(0) == 0; 1459 } 1460 } 1345 1461 #if REF_IDX_ME_ZEROMV 1346 } 1347 #endif 1462 } 1463 #endif 1464 } 1348 1465 } 1349 1466 … … 1411 1528 #endif 1412 1529 1413 #if RATE_CONTROL_LAMBDA_DOMAIN 1530 #if RATE_CONTROL_LAMBDA_DOMAIN && !M0036_RC_IMPROVEMENT 1414 1531 if ( m_pcEncCfg->getUseRateCtrl() && m_pcEncCfg->getLCULevelRC() && ePartSize == SIZE_2Nx2N && uhDepth <= m_addSADDepth ) 1415 1532 { … … 1776 1893 // rpcTempCU->setLumaIntraDirSubParts( DC_IDX, 0, uiDepth ); 1777 1894 // rpcTempCU->setChromIntraDirSubParts( DC_IDX, 0, uiDepth ); 1778 m_ppcPredYuvTemp[uiDepth]->copyFromPicLuma ( rpcTempCU->getSlice()->getFullPelBaseRec( ), rpcTempCU->getAddr(), rpcTempCU->getZorderIdxInCU(), 0, rpcTempCU->getWidth(0), rpcTempCU->getHeight(0));1779 m_ppcPredYuvTemp[uiDepth]->copyFromPicChroma( rpcTempCU->getSlice()->getFullPelBaseRec( ), rpcTempCU->getAddr(), rpcTempCU->getZorderIdxInCU(), 0, (rpcTempCU->getWidth(0)>>1), (rpcTempCU->getHeight(0)>>1), 0);1780 m_ppcPredYuvTemp[uiDepth]->copyFromPicChroma( rpcTempCU->getSlice()->getFullPelBaseRec( ), rpcTempCU->getAddr(), rpcTempCU->getZorderIdxInCU(), 0, (rpcTempCU->getWidth(0)>>1), (rpcTempCU->getHeight(0)>>1), 1);1895 m_ppcPredYuvTemp[uiDepth]->copyFromPicLuma ( rpcTempCU->getSlice()->getFullPelBaseRec(rpcTempCU->getLayerId() - 1), rpcTempCU->getAddr(), rpcTempCU->getZorderIdxInCU(), 0, rpcTempCU->getWidth(0), rpcTempCU->getHeight(0)); 1896 m_ppcPredYuvTemp[uiDepth]->copyFromPicChroma( rpcTempCU->getSlice()->getFullPelBaseRec(rpcTempCU->getLayerId() - 1), rpcTempCU->getAddr(), rpcTempCU->getZorderIdxInCU(), 0, (rpcTempCU->getWidth(0)>>1), (rpcTempCU->getHeight(0)>>1), 0); 1897 m_ppcPredYuvTemp[uiDepth]->copyFromPicChroma( rpcTempCU->getSlice()->getFullPelBaseRec(rpcTempCU->getLayerId() - 1), rpcTempCU->getAddr(), rpcTempCU->getZorderIdxInCU(), 0, (rpcTempCU->getWidth(0)>>1), (rpcTempCU->getHeight(0)>>1), 1); 1781 1898 m_pcPredSearch->encodeResAndCalcRdInterCU( rpcTempCU, m_ppcOrigYuv[uiDepth], m_ppcPredYuvTemp[uiDepth], m_ppcResiYuvTemp[uiDepth], m_ppcResiYuvBest[uiDepth], m_ppcRecoYuvTemp[uiDepth], false ); 1782 1899 rpcTempCU->getTotalCost() = m_pcRdCost->calcRdCost( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() ); … … 1812 1929 } 1813 1930 #endif 1814 1815 1931 #if (ENCODER_FAST_MODE) 1816 Void TEncCu::xCheckRDCostILRUni(TComDataCU *&rpcBestCU, TComDataCU *&rpcTempCU )1932 Void TEncCu::xCheckRDCostILRUni(TComDataCU *&rpcBestCU, TComDataCU *&rpcTempCU, UInt refLayerId) 1817 1933 { 1818 1934 UChar uhDepth = rpcTempCU->getDepth( 0 ); 1819 1820 1935 rpcTempCU->setDepthSubParts( uhDepth, 0 ); 1821 1822 1936 #if SKIP_FLAG 1823 1937 rpcTempCU->setSkipFlagSubParts( false, 0, uhDepth ); 1824 1938 #endif 1825 1826 1939 rpcTempCU->setPartSizeSubParts ( SIZE_2Nx2N, 0, uhDepth ); //2Nx2N 1827 1940 rpcTempCU->setPredModeSubParts ( MODE_INTER, 0, uhDepth ); 1828 1941 rpcTempCU->setCUTransquantBypassSubParts ( m_pcEncCfg->getCUTransquantBypassFlagValue(), 0, uhDepth ); 1829 1830 Bool exitILR = m_pcPredSearch->predInterSearchILRUni( rpcTempCU, m_ppcOrigYuv[uhDepth], m_ppcPredYuvTemp[uhDepth], m_ppcResiYuvTemp[uhDepth], m_ppcRecoYuvTemp[uhDepth] ); 1831 1942 Bool exitILR = m_pcPredSearch->predInterSearchILRUni( rpcTempCU, m_ppcOrigYuv[uhDepth], m_ppcPredYuvTemp[uhDepth], m_ppcResiYuvTemp[uhDepth], m_ppcRecoYuvTemp[uhDepth], refLayerId ); 1832 1943 if(!exitILR) 1833 1944 { 1834 return; 1835 } 1836 1945 return; 1946 } 1837 1947 m_pcPredSearch->encodeResAndCalcRdInterCU( rpcTempCU, m_ppcOrigYuv[uhDepth], m_ppcPredYuvTemp[uhDepth], m_ppcResiYuvTemp[uhDepth], m_ppcResiYuvBest[uhDepth], m_ppcRecoYuvTemp[uhDepth], false ); 1838 1839 1948 rpcTempCU->getTotalCost() = m_pcRdCost->calcRdCost( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() ); 1840 1841 1949 xCheckDQP( rpcTempCU ); 1842 1950 xCheckBestMode(rpcBestCU, rpcTempCU, uhDepth); 1843 1844 1951 return; 1845 1952 } 1846 1953 #endif 1847 1848 1849 1954 //! \} -
trunk/source/Lib/TLibEncoder/TEncCu.h
r191 r310 106 106 Bool m_bUseSBACRD; 107 107 TEncRateCtrl* m_pcRateCtrl; 108 #if RATE_CONTROL_LAMBDA_DOMAIN 108 #if RATE_CONTROL_LAMBDA_DOMAIN && !M0036_RC_IMPROVEMENT 109 109 UInt m_LCUPredictionSAD; 110 110 Int m_addSADDepth; … … 128 128 129 129 Void setBitCounter ( TComBitCounter* pcBitCounter ) { m_pcBitCounter = pcBitCounter; } 130 #if RATE_CONTROL_LAMBDA_DOMAIN 130 #if RATE_CONTROL_LAMBDA_DOMAIN && !M0036_RC_IMPROVEMENT 131 131 UInt getLCUPredictionSAD() { return m_LCUPredictionSAD; } 132 #endif 133 #if RATE_CONTROL_INTRA 134 Int updateLCUDataISlice ( TComDataCU* pcCU, Int LCUIdx, Int width, Int height ); 132 135 #endif 133 136 #if INTRA_BL … … 158 161 #endif 159 162 #if ENCODER_FAST_MODE 160 Void xCheckRDCostILRUni ( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU 163 Void xCheckRDCostILRUni ( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, UInt refLayerId); 161 164 #endif 162 165 Void xCheckDQP ( TComDataCU* pcCU ); -
trunk/source/Lib/TLibEncoder/TEncGOP.cpp
r191 r310 94 94 m_cpbRemovalDelay = 0; 95 95 m_lastBPSEI = 0; 96 #if L0045_NON_NESTED_SEI_RESTRICTIONS97 96 xResetNonNestedSEIPresentFlags(); 98 #if K0180_SCALABLE_NESTING_SEI99 97 xResetNestedSEIPresentFlags(); 100 #endif101 #endif102 98 #if SVC_UPSAMPLING 103 99 m_pcPredSearch = NULL; … … 163 159 SEIActiveParameterSets *seiActiveParameterSets = new SEIActiveParameterSets(); 164 160 seiActiveParameterSets->activeVPSId = m_pcCfg->getVPS()->getVPSId(); 165 #if L0047_APS_FLAGS166 161 seiActiveParameterSets->m_fullRandomAccessFlag = false; 167 162 seiActiveParameterSets->m_noParamSetUpdateFlag = false; 168 #endif169 163 seiActiveParameterSets->numSpsIdsMinus1 = 0; 170 164 seiActiveParameterSets->activeSeqParamSetId.resize(seiActiveParameterSets->numSpsIdsMinus1 + 1); … … 172 166 return seiActiveParameterSets; 173 167 } 168 169 #if M0043_LAYERS_PRESENT_SEI 170 SEILayersPresent* TEncGOP::xCreateSEILayersPresent () 171 { 172 UInt i = 0; 173 SEILayersPresent *seiLayersPresent = new SEILayersPresent(); 174 seiLayersPresent->m_activeVpsId = m_pcCfg->getVPS()->getVPSId(); 175 seiLayersPresent->m_vpsMaxLayers = m_pcCfg->getVPS()->getMaxLayers(); 176 for ( ; i < seiLayersPresent->m_vpsMaxLayers; i++) 177 { 178 seiLayersPresent->m_layerPresentFlag[i] = true; 179 } 180 for ( ; i < MAX_LAYERS; i++) 181 { 182 seiLayersPresent->m_layerPresentFlag[i] = false; 183 } 184 return seiLayersPresent; 185 } 186 #endif 174 187 175 188 SEIFramePacking* TEncGOP::xCreateSEIFramePacking() … … 179 192 seiFramePacking->m_arrangementCancelFlag = 0; 180 193 seiFramePacking->m_arrangementType = m_pcCfg->getFramePackingArrangementSEIType(); 181 #if L0444_FPA_TYPE182 194 assert((seiFramePacking->m_arrangementType > 2) && (seiFramePacking->m_arrangementType < 6) ); 183 #endif184 195 seiFramePacking->m_quincunxSamplingFlag = m_pcCfg->getFramePackingArrangementSEIQuincunx(); 185 196 seiFramePacking->m_contentInterpretationType = m_pcCfg->getFramePackingArrangementSEIInterpretation(); … … 195 206 seiFramePacking->m_frame1GridPositionY = 0; 196 207 seiFramePacking->m_arrangementReservedByte = 0; 197 #if L0045_PERSISTENCE_FLAGS198 208 seiFramePacking->m_arrangementPersistenceFlag = true; 199 #else200 seiFramePacking->m_arrangementRepetetionPeriod = 1;201 #endif202 209 seiFramePacking->m_upsampledAspectRatio = 0; 203 210 return seiFramePacking; … … 214 221 } 215 222 216 #if J0149_TONE_MAPPING_SEI217 223 SEIToneMappingInfo* TEncGOP::xCreateSEIToneMappingInfo() 218 224 { … … 225 231 assert(seiToneMappingInfo->m_codedDataBitDepth >= 8 && seiToneMappingInfo->m_codedDataBitDepth <= 14); 226 232 seiToneMappingInfo->m_targetBitDepth = m_pcCfg->getTMISEITargetBitDepth(); 227 assert( (seiToneMappingInfo->m_targetBitDepth >= 1 && seiToneMappingInfo->m_targetBitDepth <= 17) || (seiToneMappingInfo->m_targetBitDepth == 255));233 assert( seiToneMappingInfo->m_targetBitDepth >= 1 && seiToneMappingInfo->m_targetBitDepth <= 17 ); 228 234 seiToneMappingInfo->m_modelId = m_pcCfg->getTMISEIModelID(); 229 235 assert(seiToneMappingInfo->m_modelId >=0 &&seiToneMappingInfo->m_modelId<=4); … … 300 306 return seiToneMappingInfo; 301 307 } 302 #endif 308 303 309 Void TEncGOP::xCreateLeadingSEIMessages (/*SEIMessages seiMessages,*/ AccessUnit &accessUnit, TComSPS *sps) 304 310 { … … 315 321 accessUnit.push_back(new NALUnitEBSP(nalu)); 316 322 delete sei; 317 #if L0045_NON_NESTED_SEI_RESTRICTIONS318 323 m_activeParameterSetSEIPresentInAU = true; 319 #endif 320 } 324 } 325 326 #if M0043_LAYERS_PRESENT_SEI 327 if(m_pcCfg->getLayersPresentSEIEnabled()) 328 { 329 SEILayersPresent *sei = xCreateSEILayersPresent (); 330 m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream); 331 m_seiWriter.writeSEImessage(nalu.m_Bitstream, *sei, sps); 332 writeRBSPTrailingBits(nalu.m_Bitstream); 333 accessUnit.push_back(new NALUnitEBSP(nalu)); 334 delete sei; 335 } 336 #endif 321 337 322 338 if(m_pcCfg->getFramePackingArrangementSEIEnabled()) … … 342 358 delete sei; 343 359 } 344 #if J0149_TONE_MAPPING_SEI345 360 if(m_pcCfg->getToneMappingInfoSEIEnabled()) 346 361 { … … 354 369 delete sei; 355 370 } 356 #endif357 371 } 358 372 … … 380 394 m_iNumPicCoded = 0; 381 395 SEIPictureTiming pictureTimingSEI; 382 #if L0208_SOP_DESCRIPTION_SEI383 396 Bool writeSOP = m_pcCfg->getSOPDescriptionSEIEnabled(); 384 #endif385 #if K0180_SCALABLE_NESTING_SEI386 397 // Initialize Scalable Nesting SEI with single layer values 387 398 SEIScalableNesting scalableNestingSEI; … … 394 405 scalableNestingSEI.m_nestingLayerId[0] = 0; 395 406 scalableNestingSEI.m_callerOwnsSEIs = true; 396 #endif397 #if L0044_DU_DPB_OUTPUT_DELAY_HRD398 407 Int picSptDpbOutputDuDelay = 0; 399 #endif400 408 UInt *accumBitsDU = NULL; 401 409 UInt *accumNalsDU = NULL; … … 466 474 continue; 467 475 } 476 477 #if M0040_ADAPTIVE_RESOLUTION_CHANGE 478 if (m_pcEncTop->getAdaptiveResolutionChange() > 0 && ((m_layerId == 1 && pocCurr < m_pcEncTop->getAdaptiveResolutionChange()) || 479 (m_layerId == 0 && pocCurr > m_pcEncTop->getAdaptiveResolutionChange())) ) 480 { 481 continue; 482 } 483 #endif 468 484 469 485 if( getNalUnitType(pocCurr, m_iLastIDR) == NAL_UNIT_CODED_SLICE_IDR_W_RADL || getNalUnitType(pocCurr, m_iLastIDR) == NAL_UNIT_CODED_SLICE_IDR_N_LP ) … … 487 503 m_pcSliceEncoder->initEncSlice ( pcPic, iPOCLast, pocCurr, iNumPicRcvd, iGOPid, pcSlice, m_pcEncTop->getSPS(), m_pcEncTop->getPPS() ); 488 504 #endif 505 506 #if M0040_ADAPTIVE_RESOLUTION_CHANGE 507 if (m_pcEncTop->getAdaptiveResolutionChange() > 0 && m_layerId == 1 && pocCurr > m_pcEncTop->getAdaptiveResolutionChange()) 508 { 509 pcSlice->setActiveNumILRRefIdx(0); 510 pcSlice->setInterLayerPredEnabledFlag(false); 511 #if M0457_COL_PICTURE_SIGNALING 512 pcSlice->setMFMEnabledFlag(false); 513 pcSlice->setAltColIndicationFlag(false); 514 #endif 515 } 516 #endif 517 518 #if M0457_IL_SAMPLE_PRED_ONLY_FLAG 519 pcSlice->setNumSamplePredRefLayers( m_pcEncTop->getNumSamplePredRefLayers() ); 520 pcSlice->setInterLayerSamplePredOnlyFlag( 0 ); 521 if( pcSlice->getNumSamplePredRefLayers() > 0 && pcSlice->getActiveNumILRRefIdx() > 0 ) 522 { 523 if( m_pcEncTop->getIlSampleOnlyPred() > 0 ) 524 { 525 pcSlice->setInterLayerSamplePredOnlyFlag( true ); 526 } 527 } 528 #endif 529 489 530 pcSlice->setLastIDR(m_iLastIDR); 490 531 pcSlice->setSliceIdx(0); … … 532 573 // Set the nal unit type 533 574 pcSlice->setNalUnitType(getNalUnitType(pocCurr, m_iLastIDR)); 575 #if SVC_EXTENSION 576 if (m_layerId > 0) 577 { 578 for( Int i = 0; i < pcSlice->getActiveNumILRRefIdx(); i++ ) 579 { 580 UInt refLayerIdc = pcSlice->getInterLayerPredLayerIdc(i); 581 #if VPS_EXTN_DIRECT_REF_LAYERS 582 TComList<TComPic*> *cListPic = m_ppcTEncTop[m_layerId]->getRefLayerEnc(refLayerIdc)->getListPic(); 583 #else 584 TComList<TComPic*> *cListPic = m_ppcTEncTop[m_layerId-1]->getListPic(); 585 #endif 586 pcSlice->setBaseColPic( *cListPic, refLayerIdc ); 587 588 #if SIMPLIFIED_MV_POS_SCALING 589 #if SCALED_REF_LAYER_OFFSETS 590 const Window &scalEL = m_pcEncTop->getScaledRefLayerWindow(refLayerIdc); 591 592 Int widthBL = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec()->getWidth(); 593 Int heightBL = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec()->getHeight(); 594 595 Int widthEL = pcPic->getPicYuvRec()->getWidth() - scalEL.getWindowLeftOffset() - scalEL.getWindowRightOffset(); 596 Int heightEL = pcPic->getPicYuvRec()->getHeight() - scalEL.getWindowTopOffset() - scalEL.getWindowBottomOffset(); 597 #else 598 const Window &confBL = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec()->getConformanceWindow(); 599 const Window &confEL = pcPic->getPicYuvRec()->getConformanceWindow(); 600 601 Int widthBL = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec()->getWidth () - confBL.getWindowLeftOffset() - confBL.getWindowRightOffset(); 602 Int heightBL = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec()->getHeight() - confBL.getWindowTopOffset() - confBL.getWindowBottomOffset(); 603 604 Int widthEL = pcPic->getPicYuvRec()->getWidth() - confEL.getWindowLeftOffset() - confEL.getWindowRightOffset(); 605 Int heightEL = pcPic->getPicYuvRec()->getHeight() - confEL.getWindowTopOffset() - confEL.getWindowBottomOffset(); 606 #endif 607 g_mvScalingFactor[refLayerIdc][0] = widthEL == widthBL ? 4096 : Clip3(-4096, 4095, ((widthEL << 8) + (widthBL >> 1)) / widthBL); 608 g_mvScalingFactor[refLayerIdc][1] = heightEL == heightBL ? 4096 : Clip3(-4096, 4095, ((heightEL << 8) + (heightBL >> 1)) / heightBL); 609 610 g_posScalingFactor[refLayerIdc][0] = ((widthBL << 16) + (widthEL >> 1)) / widthEL; 611 g_posScalingFactor[refLayerIdc][1] = ((heightBL << 16) + (heightEL >> 1)) / heightEL; 612 #endif 613 614 #if SVC_UPSAMPLING 615 if( pcPic->isSpatialEnhLayer(refLayerIdc)) 616 { 617 #if SCALED_REF_LAYER_OFFSETS 618 m_pcPredSearch->upsampleBasePic( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), pcPic->getPicYuvRec(), pcSlice->getSPS()->getScaledRefLayerWindow(refLayerIdc) ); 619 #else 620 m_pcPredSearch->upsampleBasePic( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), pcPic->getPicYuvRec() ); 621 #endif 622 } 623 else 624 { 625 pcPic->setFullPelBaseRec( refLayerIdc, pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec() ); 626 } 627 pcSlice->setFullPelBaseRec ( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc) ); 628 #endif 629 } 630 } 631 #endif 632 633 #if REF_IDX_FRAMEWORK 634 if( m_layerId > 0 && (pocCurr % m_pcCfg->getIntraPeriod() == 0) ) 635 { 534 636 #if IDR_ALIGNMENT 535 if (m_layerId > 0) 536 { 537 #if VPS_EXTN_DIRECT_REF_LAYERS_CONTINUE 538 TComList<TComPic*> *cListPic = m_ppcTEncTop[m_layerId]->getRefLayerEnc(m_layerId)->getListPic(); 539 #else 540 TComList<TComPic*> *cListPic = m_ppcTEncTop[m_layerId-1]->getListPic(); 541 #endif 542 pcSlice->setBaseColPic (*cListPic, m_layerId ); 543 } 544 #endif 545 #if REF_IDX_FRAMEWORK 546 547 if( m_layerId > 0 && (pocCurr % m_pcCfg->getIntraPeriod() == 0) ) 548 { 549 #if IDR_ALIGNMENT 550 if( pcSlice->getBaseColPic()->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL || pcSlice->getBaseColPic()->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP ) 551 { 552 pcSlice->setNalUnitType(pcSlice->getBaseColPic()->getSlice(0)->getNalUnitType()); 637 TComList<TComPic*> *cListPic = m_ppcTEncTop[m_layerId]->getRefLayerEnc(0)->getListPic(); 638 TComPic* picLayer0 = pcSlice->getRefPic(*cListPic, pcSlice->getPOC() ); 639 if( picLayer0->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL || picLayer0->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP ) 640 { 641 pcSlice->setNalUnitType(picLayer0->getSlice(0)->getNalUnitType()); 553 642 } 554 643 else … … 594 683 pcSlice->getRPS()->setNumberOfLongtermPictures(0); 595 684 685 #if FIX1071 686 if ((pcSlice->checkThatAllRefPicsAreAvailable(rcListPic, pcSlice->getRPS(), false) != 0) || (pcSlice->isIRAP())) 687 { 688 pcSlice->createExplicitReferencePictureSetFromReference(rcListPic, pcSlice->getRPS(), pcSlice->isIRAP()); 689 } 690 #else 596 691 if(pcSlice->checkThatAllRefPicsAreAvailable(rcListPic, pcSlice->getRPS(), false) != 0) 597 692 { 598 693 pcSlice->createExplicitReferencePictureSetFromReference(rcListPic, pcSlice->getRPS()); 599 694 } 695 #endif 600 696 pcSlice->applyReferencePictureSet(rcListPic, pcSlice->getRPS()); 601 697 … … 670 766 #endif 671 767 { 768 #if RESTR_CHK 769 if (pcSlice->getPOC()>0 && pcSlice->isRADL()&& pcPic->getSlice(0)->isRASL()) 770 { 771 #if JCTVC_M0458_INTERLAYER_RPS_SIG 772 pcSlice->setActiveNumILRRefIdx(0); 773 pcSlice->setInterLayerPredEnabledFlag(0); 774 #else 775 pcSlice->setNumILRRefIdx(0); 776 #endif 777 } 778 #endif 672 779 #if JCTVC_M0458_INTERLAYER_RPS_SIG 673 780 if( pcSlice->getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP && pcSlice->getNalUnitType() <= NAL_UNIT_CODED_SLICE_CRA ) … … 700 807 #endif 701 808 702 #if SVC_EXTENSION703 #if ZERO_NUM_DIRECT_LAYERS704 if( m_layerId > 0 && pcSlice->getActiveNumILRRefIdx() )705 #else706 if(m_layerId > 0)707 #endif708 {709 #if !IDR_ALIGNMENT710 TComList<TComPic*> *cListPic = m_ppcTEncTop[m_layerId-1]->getListPic();711 pcSlice->setBaseColPic (*cListPic, m_layerId );712 #endif713 #if SVC_UPSAMPLING714 if ( pcPic->isSpatialEnhLayer())715 {716 #if SCALED_REF_LAYER_OFFSETS717 m_pcPredSearch->upsampleBasePic( pcPic->getFullPelBaseRec(), pcSlice->getBaseColPic()->getPicYuvRec(), pcPic->getPicYuvRec(), pcSlice->getSPS()->getScaledRefLayerWindow() );718 #else719 m_pcPredSearch->upsampleBasePic( pcPic->getFullPelBaseRec(), pcSlice->getBaseColPic()->getPicYuvRec(), pcPic->getPicYuvRec() );720 #endif721 }722 else723 {724 pcPic->setFullPelBaseRec( pcSlice->getBaseColPic()->getPicYuvRec() );725 }726 pcSlice->setFullPelBaseRec ( pcPic->getFullPelBaseRec() );727 #endif728 }729 #endif730 731 809 #if REF_IDX_FRAMEWORK 810 #if M0457_COL_PICTURE_SIGNALING 811 if ( pcSlice->getSliceType() == B_SLICE && !(pcSlice->getActiveNumILRRefIdx() > 0 && m_pcEncTop->getNumMotionPredRefLayers() > 0) ) 812 #else 732 813 if( pcSlice->getSliceType() == B_SLICE ) 814 #endif 733 815 { 734 816 pcSlice->setColFromL0Flag(1-uiColDir); … … 759 841 760 842 #if REF_IDX_MFM 843 #if M0457_COL_PICTURE_SIGNALING 844 if( pcSlice->getMFMEnabledFlag() ) 845 #else 761 846 if( pcSlice->getSPS()->getMFMEnabledFlag() ) 847 #endif 762 848 { 763 849 pcSlice->setRefPOCListILP(m_pcEncTop->getIlpList(), pcSlice->getBaseColPic()); 850 #if M0457_COL_PICTURE_SIGNALING 851 pcSlice->setMotionPredIlp(getMotionPredIlp(pcSlice)); 852 #endif 764 853 } 765 854 #endif … … 768 857 769 858 #if REF_IDX_MFM 859 #if M0457_COL_PICTURE_SIGNALING 860 if( pcSlice->getMFMEnabledFlag() && !(pcSlice->getActiveNumILRRefIdx() > 0 && m_pcEncTop->getNumMotionPredRefLayers() > 0) ) 861 #else 770 862 if( pcSlice->getSPS()->getMFMEnabledFlag() ) 863 #endif 771 864 { 772 865 Bool found = false; … … 812 905 pcSlice->setSliceType ( P_SLICE ); 813 906 } 814 #if !L0034_COMBINED_LIST_CLEANUP 815 if (pcSlice->getSliceType() != B_SLICE || !pcSlice->getSPS()->getUseLComb()) 816 { 817 pcSlice->setNumRefIdx(REF_PIC_LIST_C, 0); 818 pcSlice->setRefPicListCombinationFlag(false); 819 pcSlice->setRefPicListModificationFlagLC(false); 820 } 821 else 822 { 823 pcSlice->setRefPicListCombinationFlag(pcSlice->getSPS()->getUseLComb()); 824 pcSlice->setNumRefIdx(REF_PIC_LIST_C, pcSlice->getNumRefIdx(REF_PIC_LIST_0)); 825 } 826 #endif 827 907 908 #if M0457_IL_SAMPLE_PRED_ONLY_FLAG 909 if (pcSlice->getSliceType() == B_SLICE && m_pcEncTop->getIlSampleOnlyPred() == 0) 910 #else 828 911 if (pcSlice->getSliceType() == B_SLICE) 912 #endif 829 913 { 830 914 #if !REF_IDX_FRAMEWORK … … 862 946 pcSlice->setRefPOCList(); 863 947 864 #if L0034_COMBINED_LIST_CLEANUP865 948 pcSlice->setList1IdxToList0Idx(); 866 #else867 pcSlice->setNoBackPredFlag( false );868 if ( pcSlice->getSliceType() == B_SLICE && !pcSlice->getRefPicListCombinationFlag())869 {870 if ( pcSlice->getNumRefIdx(RefPicList( 0 ) ) == pcSlice->getNumRefIdx(RefPicList( 1 ) ) )871 {872 pcSlice->setNoBackPredFlag( true );873 Int i;874 for ( i=0; i < pcSlice->getNumRefIdx(RefPicList( 1 ) ); i++ )875 {876 if ( pcSlice->getRefPOC(RefPicList(1), i) != pcSlice->getRefPOC(RefPicList(0), i) )877 {878 pcSlice->setNoBackPredFlag( false );879 break;880 }881 }882 }883 }884 885 if(pcSlice->getNoBackPredFlag())886 {887 pcSlice->setNumRefIdx(REF_PIC_LIST_C, 0);888 }889 pcSlice->generateCombinedList();890 #endif891 949 892 950 if (m_pcEncTop->getTMVPModeId() == 2) … … 906 964 { 907 965 pcSlice->getSPS()->setTMVPFlagsPresent(1); 966 #if SVC_EXTENSION 967 if( pcSlice->getIdrPicFlag() ) 968 { 969 pcSlice->setEnableTMVPFlag(0); 970 } 971 else 972 #endif 908 973 pcSlice->setEnableTMVPFlag(1); 909 974 } … … 948 1013 949 1014 #if RATE_CONTROL_LAMBDA_DOMAIN 950 Int sliceQP = pcSlice->getSliceQp();951 1015 Double lambda = 0.0; 952 1016 Int actualHeadBits = 0; … … 964 1028 estimatedBits = m_pcRateCtrl->getRCPic()->getTargetBits(); 965 1029 1030 Int sliceQP = m_pcCfg->getInitialQP(); 966 1031 if ( ( pcSlice->getPOC() == 0 && m_pcCfg->getInitialQP() > 0 ) || ( frameLevel == 0 && m_pcCfg->getForceIntraQP() ) ) // QP is specified 967 1032 { 968 sliceQP = m_pcCfg->getInitialQP();969 1033 Int NumberBFrames = ( m_pcCfg->getGOPSize() - 1 ); 970 1034 Double dLambda_scale = 1.0 - Clip3( 0.0, 0.5, 0.05*(Double)NumberBFrames ); … … 977 1041 else if ( frameLevel == 0 ) // intra case, but use the model 978 1042 { 1043 #if RATE_CONTROL_INTRA 1044 m_pcSliceEncoder->calCostSliceI(pcPic); 1045 #endif 979 1046 if ( m_pcCfg->getIntraPeriod() != 1 ) // do not refine allocated bits for all intra case 980 1047 { 981 1048 Int bits = m_pcRateCtrl->getRCSeq()->getLeftAverageBits(); 1049 #if RATE_CONTROL_INTRA 1050 bits = m_pcRateCtrl->getRCPic()->getRefineBitsForIntra( bits ); 1051 #else 982 1052 bits = m_pcRateCtrl->getRCSeq()->getRefineBitsForIntra( bits ); 1053 #endif 983 1054 if ( bits < 200 ) 984 1055 { … … 989 1060 990 1061 list<TEncRCPic*> listPreviousPicture = m_pcRateCtrl->getPicList(); 1062 #if RATE_CONTROL_INTRA 1063 m_pcRateCtrl->getRCPic()->getLCUInitTargetBits(); 1064 lambda = m_pcRateCtrl->getRCPic()->estimatePicLambda( listPreviousPicture, pcSlice->getSliceType()); 1065 #else 991 1066 lambda = m_pcRateCtrl->getRCPic()->estimatePicLambda( listPreviousPicture ); 1067 #endif 992 1068 sliceQP = m_pcRateCtrl->getRCPic()->estimatePicQP( lambda, listPreviousPicture ); 993 1069 } … … 995 1071 { 996 1072 list<TEncRCPic*> listPreviousPicture = m_pcRateCtrl->getPicList(); 1073 #if RATE_CONTROL_INTRA 1074 lambda = m_pcRateCtrl->getRCPic()->estimatePicLambda( listPreviousPicture, pcSlice->getSliceType()); 1075 #else 997 1076 lambda = m_pcRateCtrl->getRCPic()->estimatePicLambda( listPreviousPicture ); 1077 #endif 998 1078 sliceQP = m_pcRateCtrl->getRCPic()->estimatePicQP( lambda, listPreviousPicture ); 999 1079 } … … 1007 1087 1008 1088 UInt uiNumSlices = 1; 1009 1010 #if SIMPLIFIED_MV_POS_SCALING1011 if (m_layerId > 0)1012 {1013 #if SCALED_REF_LAYER_OFFSETS1014 const Window &scalEL = m_pcEncTop->getScaledRefLayerWindow();1015 1016 Int widthBL = pcSlice->getBaseColPic()->getPicYuvRec()->getWidth();1017 Int heightBL = pcSlice->getBaseColPic()->getPicYuvRec()->getHeight();1018 1019 Int widthEL = pcPic->getPicYuvRec()->getWidth() - scalEL.getWindowLeftOffset() - scalEL.getWindowRightOffset();1020 Int heightEL = pcPic->getPicYuvRec()->getHeight() - scalEL.getWindowTopOffset() - scalEL.getWindowBottomOffset();1021 #else1022 const Window &confBL = pcSlice->getBaseColPic()->getPicYuvRec()->getConformanceWindow();1023 const Window &confEL = pcPic->getPicYuvRec()->getConformanceWindow();1024 1025 Int widthBL = pcSlice->getBaseColPic()->getPicYuvRec()->getWidth () - confBL.getWindowLeftOffset() - confBL.getWindowRightOffset();1026 Int heightBL = pcSlice->getBaseColPic()->getPicYuvRec()->getHeight() - confBL.getWindowTopOffset() - confBL.getWindowBottomOffset();1027 1028 Int widthEL = pcPic->getPicYuvRec()->getWidth() - confEL.getWindowLeftOffset() - confEL.getWindowRightOffset();1029 Int heightEL = pcPic->getPicYuvRec()->getHeight() - confEL.getWindowTopOffset() - confEL.getWindowBottomOffset();1030 #endif1031 g_mvScalingFactor[m_layerId][0] = Clip3(-4096, 4095, ((widthEL << 8) + (widthBL >> 1)) / widthBL);1032 g_mvScalingFactor[m_layerId][1] = Clip3(-4096, 4095, ((heightEL << 8) + (heightBL >> 1)) / heightBL);1033 1034 g_posScalingFactor[m_layerId][0] = ((widthBL << 16) + (widthEL >> 1)) / widthEL;1035 g_posScalingFactor[m_layerId][1] = ((heightBL << 16) + (heightEL >> 1)) / heightEL;1036 }1037 #endif1038 1089 1039 1090 UInt uiInternalAddress = pcPic->getNumPartInCU()-4; … … 1233 1284 Bool bLFCrossTileBoundary = pcSlice->getPPS()->getLoopFilterAcrossTilesEnabledFlag(); 1234 1285 m_pcLoopFilter->setCfg(bLFCrossTileBoundary); 1235 #if L0386_DB_METRIC1236 1286 if ( m_pcCfg->getDeblockingFilterMetric() ) 1237 1287 { 1238 1288 dblMetric(pcPic, uiNumSlices); 1239 1289 } 1240 #endif1241 1290 m_pcLoopFilter->loopFilterPic( pcPic ); 1242 1291 … … 1309 1358 UInt maxCU = m_pcCfg->getSliceArgument() >> ( pcSlice->getSPS()->getMaxCUDepth() << 1); 1310 1359 UInt numDU = ( m_pcCfg->getSliceMode() == 1 ) ? ( pcPic->getNumCUsInFrame() / maxCU ) : ( 0 ); 1311 if( pcPic->getNumCUsInFrame() % maxCU != 0 )1360 if( pcPic->getNumCUsInFrame() % maxCU != 0 || numDU == 0 ) 1312 1361 { 1313 1362 numDU ++; … … 1345 1394 } 1346 1395 1347 #if L0208_SOP_DESCRIPTION_SEI1348 1396 if (writeSOP) // write SOP description SEI (if enabled) at the beginning of GOP 1349 1397 { … … 1383 1431 writeSOP = false; 1384 1432 } 1385 #endif1386 1433 1387 1434 if( ( m_pcCfg->getPictureTimingSEIEnabled() || m_pcCfg->getDecodingUnitInfoSEIEnabled() ) && … … 1415 1462 pictureTimingSEI.m_auCpbRemovalDelay = std::max<Int>(1, m_totalCoded - m_lastBPSEI); // Syntax element signalled as minus, hence the . 1416 1463 pictureTimingSEI.m_picDpbOutputDelay = pcSlice->getSPS()->getNumReorderPics(0) + pcSlice->getPOC() - m_totalCoded; 1417 #if L0044_DU_DPB_OUTPUT_DELAY_HRD1418 1464 Int factor = pcSlice->getSPS()->getVuiParameters()->getHrdParameters()->getTickDivisorMinus2() + 2; 1419 1465 pictureTimingSEI.m_picDpbOutputDuDelay = factor * pictureTimingSEI.m_picDpbOutputDelay; … … 1422 1468 picSptDpbOutputDuDelay = factor * pictureTimingSEI.m_picDpbOutputDelay; 1423 1469 } 1424 #endif1425 1470 } 1426 1471 … … 1442 1487 sei_buffering_period.m_initialCpbRemovalDelayOffset[0][1] = uiInitialCpbRemovalDelay; 1443 1488 1444 #if L0043_TIMING_INFO1445 1489 Double dTmp = (Double)pcSlice->getSPS()->getVuiParameters()->getTimingInfo()->getNumUnitsInTick() / (Double)pcSlice->getSPS()->getVuiParameters()->getTimingInfo()->getTimeScale(); 1446 #else1447 Double dTmp = (Double)pcSlice->getSPS()->getVuiParameters()->getHrdParameters()->getNumUnitsInTick() / (Double)pcSlice->getSPS()->getVuiParameters()->getHrdParameters()->getTimeScale();1448 #endif1449 1490 1450 1491 UInt uiTmp = (UInt)( dTmp * 90000.0 ); … … 1457 1498 1458 1499 sei_buffering_period.m_rapCpbParamsPresentFlag = 0; 1459 #if L0328_SPLICING1460 1500 //for the concatenation, it can be set to one during splicing. 1461 1501 sei_buffering_period.m_concatenationFlag = 0; 1462 1502 //since the temporal layer HRD is not ready, we assumed it is fixed 1463 1503 sei_buffering_period.m_auCpbRemovalDelayDelta = 1; 1464 #endif1465 #if L0044_CPB_DPB_DELAY_OFFSET1466 1504 sei_buffering_period.m_cpbDelayOffset = 0; 1467 1505 sei_buffering_period.m_dpbDelayOffset = 0; 1468 #endif1469 1506 1470 1507 m_seiWriter.writeSEImessage( nalu.m_Bitstream, sei_buffering_period, pcSlice->getSPS()); 1471 1508 writeRBSPTrailingBits(nalu.m_Bitstream); 1472 #if L0045_NON_NESTED_SEI_RESTRICTIONS1473 1509 { 1474 1510 UInt seiPositionInAu = xGetFirstSeiLocation(accessUnit); … … 1482 1518 m_bufferingPeriodSEIPresentInAU = true; 1483 1519 } 1484 #else 1485 accessUnit.push_back(new NALUnitEBSP(nalu)); 1486 #endif 1487 1488 #if K0180_SCALABLE_NESTING_SEI 1520 1489 1521 if (m_pcCfg->getScalableNestingSEIEnabled()) 1490 1522 { … … 1496 1528 m_seiWriter.writeSEImessage( naluTmp.m_Bitstream, scalableNestingSEI, pcSlice->getSPS()); 1497 1529 writeRBSPTrailingBits(naluTmp.m_Bitstream); 1498 #if L0045_NON_NESTED_SEI_RESTRICTIONS1499 1530 UInt seiPositionInAu = xGetFirstSeiLocation(accessUnit); 1500 1531 UInt offsetPosition = m_activeParameterSetSEIPresentInAU + m_bufferingPeriodSEIPresentInAU + m_pictureTimingSEIPresentInAU; // Insert BP SEI after non-nested APS, BP and PT SEIs … … 1506 1537 accessUnit.insert(it, new NALUnitEBSP(naluTmp)); 1507 1538 m_nestedBufferingPeriodSEIPresentInAU = true; 1508 #else 1509 accessUnit.push_back(new NALUnitEBSP(naluTmp)); 1510 #endif 1511 } 1512 #endif 1539 } 1513 1540 1514 1541 m_lastBPSEI = m_totalCoded; … … 1600 1627 startCUAddrSliceSegmentIdx++; 1601 1628 } 1602 1629 #if REF_IDX_FRAMEWORK && M0457_COL_PICTURE_SIGNALING 1630 pcSlice->setNumMotionPredRefLayers(m_pcEncTop->getNumMotionPredRefLayers()); 1631 #endif 1603 1632 pcSlice->setRPS(pcPic->getSlice(0)->getRPS()); 1604 1633 pcSlice->setRPSidx(pcPic->getSlice(0)->getRPSidx()); … … 1972 2001 if ( m_pcCfg->getUseRateCtrl() ) 1973 2002 { 2003 #if !M0036_RC_IMPROVEMENT 1974 2004 Double effectivePercentage = m_pcRateCtrl->getRCPic()->getEffectivePercentage(); 2005 #endif 1975 2006 Double avgQP = m_pcRateCtrl->getRCPic()->calAverageQP(); 1976 2007 Double avgLambda = m_pcRateCtrl->getRCPic()->calAverageLambda(); … … 1979 2010 avgLambda = lambda; 1980 2011 } 2012 #if M0036_RC_IMPROVEMENT 2013 #if RATE_CONTROL_INTRA 2014 m_pcRateCtrl->getRCPic()->updateAfterPicture( actualHeadBits, actualTotalBits, avgQP, avgLambda, pcSlice->getSliceType()); 2015 #else 2016 m_pcRateCtrl->getRCPic()->updateAfterPicture( actualHeadBits, actualTotalBits, avgQP, avgLambda ); 2017 #endif 2018 #else 1981 2019 m_pcRateCtrl->getRCPic()->updateAfterPicture( actualHeadBits, actualTotalBits, avgQP, avgLambda, effectivePercentage ); 2020 #endif 1982 2021 m_pcRateCtrl->getRCPic()->addToPictureLsit( m_pcRateCtrl->getPicList() ); 1983 2022 … … 1999 2038 } 2000 2039 #endif 2040 2001 2041 if( ( m_pcCfg->getPictureTimingSEIEnabled() || m_pcCfg->getDecodingUnitInfoSEIEnabled() ) && 2002 2042 ( pcSlice->getSPS()->getVuiParametersPresentFlag() ) && … … 2033 2073 for( i = ( numDU - 2 ); i >= 0; i -- ) 2034 2074 { 2035 #if L0043_TIMING_INFO2036 2075 ui64Tmp = ( ( ( accumBitsDU[ numDU - 1 ] - accumBitsDU[ i ] ) * ( vui->getTimingInfo()->getTimeScale() / vui->getTimingInfo()->getNumUnitsInTick() ) * ( hrd->getTickDivisorMinus2() + 2 ) ) / ( m_pcCfg->getTargetBitrate() ) ); 2037 #else2038 ui64Tmp = ( ( ( accumBitsDU[ numDU - 1 ] - accumBitsDU[ i ] ) * ( hrd->getTimeScale() / hrd->getNumUnitsInTick() ) * ( hrd->getTickDivisorMinus2() + 2 ) ) / ( m_pcCfg->getTargetBitrate() ) );2039 #endif2040 2076 if( (UInt)ui64Tmp > maxDiff ) 2041 2077 { … … 2049 2085 { 2050 2086 flag = 0; 2051 #if L0043_TIMING_INFO2052 2087 ui64Tmp = ( ( ( accumBitsDU[ numDU - 1 ] - accumBitsDU[ i ] ) * ( vui->getTimingInfo()->getTimeScale() / vui->getTimingInfo()->getNumUnitsInTick() ) * ( hrd->getTickDivisorMinus2() + 2 ) ) / ( m_pcCfg->getTargetBitrate() ) ); 2053 #else2054 ui64Tmp = ( ( ( accumBitsDU[ numDU - 1 ] - accumBitsDU[ i ] ) * ( hrd->getTimeScale() / hrd->getNumUnitsInTick() ) * ( hrd->getTickDivisorMinus2() + 2 ) ) / ( m_pcCfg->getTargetBitrate() ) );2055 #endif2056 2088 2057 2089 if( (UInt)ui64Tmp > maxDiff ) … … 2085 2117 m_seiWriter.writeSEImessage(nalu.m_Bitstream, pictureTimingSEI, pcSlice->getSPS()); 2086 2118 writeRBSPTrailingBits(nalu.m_Bitstream); 2087 #if L0045_NON_NESTED_SEI_RESTRICTIONS2088 2119 UInt seiPositionInAu = xGetFirstSeiLocation(accessUnit); 2089 2120 UInt offsetPosition = m_activeParameterSetSEIPresentInAU … … 2096 2127 accessUnit.insert(it, new NALUnitEBSP(nalu)); 2097 2128 m_pictureTimingSEIPresentInAU = true; 2098 #else 2099 AccessUnit::iterator it = find_if(accessUnit.begin(), accessUnit.end(), mem_fun(&NALUnit::isSlice)); 2100 accessUnit.insert(it, new NALUnitEBSP(nalu)); 2101 #endif 2102 } 2103 #if K0180_SCALABLE_NESTING_SEI 2129 } 2104 2130 if ( m_pcCfg->getScalableNestingSEIEnabled() ) // put picture timing SEI into scalable nesting SEI 2105 2131 { … … 2110 2136 m_seiWriter.writeSEImessage(nalu.m_Bitstream, scalableNestingSEI, pcSlice->getSPS()); 2111 2137 writeRBSPTrailingBits(nalu.m_Bitstream); 2112 #if L0045_NON_NESTED_SEI_RESTRICTIONS2113 2138 UInt seiPositionInAu = xGetFirstSeiLocation(accessUnit); 2114 2139 UInt offsetPosition = m_activeParameterSetSEIPresentInAU … … 2121 2146 accessUnit.insert(it, new NALUnitEBSP(nalu)); 2122 2147 m_nestedPictureTimingSEIPresentInAU = true; 2123 #else2124 AccessUnit::iterator it = find_if(accessUnit.begin(), accessUnit.end(), mem_fun(&NALUnit::isSlice));2125 accessUnit.insert(it, new NALUnitEBSP(nalu));2126 #endif2127 2148 } 2128 #endif2129 2130 2149 } 2131 2150 if( m_pcCfg->getDecodingUnitInfoSEIEnabled() && hrd->getSubPicCpbParamsPresentFlag() ) … … 2139 2158 tempSEI.m_decodingUnitIdx = i; 2140 2159 tempSEI.m_duSptCpbRemovalDelay = pictureTimingSEI.m_duCpbRemovalDelayMinus1[i] + 1; 2141 #if L0044_DU_DPB_OUTPUT_DELAY_HRD2142 2160 tempSEI.m_dpbOutputDuDelayPresentFlag = false; 2143 2161 tempSEI.m_picSptDpbOutputDuDelay = picSptDpbOutputDuDelay; 2144 #endif2145 2162 2146 2163 AccessUnit::iterator it; … … 2152 2169 writeRBSPTrailingBits(nalu.m_Bitstream); 2153 2170 2154 #if L0045_NON_NESTED_SEI_RESTRICTIONS2155 2171 UInt seiPositionInAu = xGetFirstSeiLocation(accessUnit); 2156 2172 UInt offsetPosition = m_activeParameterSetSEIPresentInAU … … 2162 2178 } 2163 2179 accessUnit.insert(it, new NALUnitEBSP(nalu)); 2164 #else2165 it = find_if(accessUnit.begin(), accessUnit.end(), mem_fun(&NALUnit::isSlice));2166 accessUnit.insert(it, new NALUnitEBSP(nalu));2167 #endif2168 2180 } 2169 2181 else … … 2191 2203 } 2192 2204 } 2193 #if L0045_NON_NESTED_SEI_RESTRICTIONS2194 2205 xResetNonNestedSEIPresentFlags(); 2195 #if K0180_SCALABLE_NESTING_SEI2196 2206 xResetNestedSEIPresentFlags(); 2197 #endif2198 #endif2199 2207 pcPic->getPicYuvRec()->copyToPic(pcPicYuvRecOut); 2208 2209 #if M0040_ADAPTIVE_RESOLUTION_CHANGE 2210 pcPicYuvRecOut->setReconstructed(true); 2211 #endif 2200 2212 2201 2213 pcPic->setReconMark ( true ); … … 2348 2360 } 2349 2361 2350 assert (rpcPic->getPOC() == pocCurr); 2362 assert( rpcPic != NULL ); 2363 assert( rpcPic->getPOC() == pocCurr ); 2351 2364 2352 2365 return; … … 2620 2633 for (Int iRefIndex = 0; iRefIndex < pcSlice->getNumRefIdx(RefPicList(iRefList)); iRefIndex++) 2621 2634 { 2622 #if REF_IDX_FRAMEWORK && VPS_EXTN_DIRECT_REF_LAYERS _CONTINUE2635 #if REF_IDX_FRAMEWORK && VPS_EXTN_DIRECT_REF_LAYERS 2623 2636 if( pcSlice->getRefPic(RefPicList(iRefList), iRefIndex)->isILR(m_layerId) ) 2624 2637 { … … 2848 2861 } 2849 2862 2850 #if L0045_NON_NESTED_SEI_RESTRICTIONS2851 2863 /** Function for finding the position to insert the first of APS and non-nested BP, PT, DU info SEI messages. 2852 2864 * \param accessUnit Access Unit of the current picture … … 2868 2880 return seiStartPos; 2869 2881 } 2870 #endif 2871 2872 #if L0386_DB_METRIC 2882 2873 2883 Void TEncGOP::dblMetric( TComPic* pcPic, UInt uiNumSlices ) 2874 2884 { … … 2884 2894 const UInt noCol = (picWidth>>log2maxTB); 2885 2895 const UInt noRows = (picHeight>>log2maxTB); 2896 assert(noCol > 1); 2897 assert(noRows > 1); 2886 2898 UInt64 *colSAD = (UInt64*)malloc(noCol*sizeof(UInt64)); 2887 2899 UInt64 *rowSAD = (UInt64*)malloc(noRows*sizeof(UInt64)); … … 2992 3004 free(rowSAD); 2993 3005 } 2994 #endif 3006 3007 #if M0457_COL_PICTURE_SIGNALING 3008 TComPic* TEncGOP::getMotionPredIlp(TComSlice* pcSlice) 3009 { 3010 TComPic* ilpPic = NULL; 3011 Int activeMotionPredReflayerIdx = 0; 3012 3013 for( Int i = 0; i < pcSlice->getActiveNumILRRefIdx(); i++ ) 3014 { 3015 UInt refLayerIdc = pcSlice->getInterLayerPredLayerIdc(i); 3016 if( m_pcEncTop->getMotionPredEnabledFlag( pcSlice->getVPS()->getRefLayerId( m_layerId, refLayerIdc ) ) ) 3017 { 3018 if (activeMotionPredReflayerIdx == pcSlice->getColRefLayerIdx()) 3019 { 3020 ilpPic = m_pcEncTop->getIlpList()[refLayerIdc]; 3021 break; 3022 } 3023 else 3024 { 3025 activeMotionPredReflayerIdx++; 3026 } 3027 } 3028 } 3029 3030 assert(ilpPic != NULL); 3031 3032 return ilpPic; 3033 } 3034 #endif 3035 2995 3036 //! \} -
trunk/source/Lib/TLibEncoder/TEncGOP.h
r191 r310 127 127 UInt m_tl0Idx; 128 128 UInt m_rapIdx; 129 #if L0045_NON_NESTED_SEI_RESTRICTIONS130 129 Bool m_activeParameterSetSEIPresentInAU; 131 130 Bool m_bufferingPeriodSEIPresentInAU; 132 131 Bool m_pictureTimingSEIPresentInAU; 133 #if K0180_SCALABLE_NESTING_SEI134 132 Bool m_nestedBufferingPeriodSEIPresentInAU; 135 133 Bool m_nestedPictureTimingSEIPresentInAU; 136 #endif137 #endif138 134 public: 139 135 TEncGOP(); … … 180 176 181 177 SEIActiveParameterSets* xCreateSEIActiveParameterSets (TComSPS *sps); 178 #if M0043_LAYERS_PRESENT_SEI 179 SEILayersPresent* xCreateSEILayersPresent (); 180 #endif 182 181 SEIFramePacking* xCreateSEIFramePacking(); 183 182 SEIDisplayOrientation* xCreateSEIDisplayOrientation(); 184 183 185 #if J0149_TONE_MAPPING_SEI186 184 SEIToneMappingInfo* xCreateSEIToneMappingInfo(); 187 #endif188 185 189 186 Void xCreateLeadingSEIMessages (/*SEIMessages seiMessages,*/ AccessUnit &accessUnit, TComSPS *sps); 190 #if L0045_NON_NESTED_SEI_RESTRICTIONS191 187 Int xGetFirstSeiLocation (AccessUnit &accessUnit); 192 188 Void xResetNonNestedSEIPresentFlags() … … 196 192 m_pictureTimingSEIPresentInAU = false; 197 193 } 198 #if K0180_SCALABLE_NESTING_SEI199 194 Void xResetNestedSEIPresentFlags() 200 195 { … … 202 197 m_nestedPictureTimingSEIPresentInAU = false; 203 198 } 204 #endif205 #endif206 #if L0386_DB_METRIC207 199 Void dblMetric( TComPic* pcPic, UInt uiNumSlices ); 200 #if M0457_COL_PICTURE_SIGNALING 201 TComPic* getMotionPredIlp(TComSlice* pcSlice); 208 202 #endif 209 203 };// END CLASS DEFINITION TEncGOP -
trunk/source/Lib/TLibEncoder/TEncRateCtrl.cpp
r191 r310 67 67 m_bitsLeft = 0; 68 68 m_useLCUSeparateModel = false; 69 #if M0036_RC_IMPROVEMENT 70 m_adaptiveBit = 0; 71 m_lastLambda = 0.0; 72 #endif 69 73 } 70 74 … … 74 78 } 75 79 80 #if M0036_RC_IMPROVEMENT 81 Void TEncRCSeq::create( Int totalFrames, Int targetBitrate, Int frameRate, Int GOPSize, Int picWidth, Int picHeight, Int LCUWidth, Int LCUHeight, Int numberOfLevel, Bool useLCUSeparateModel, Int adaptiveBit ) 82 #else 76 83 Void TEncRCSeq::create( Int totalFrames, Int targetBitrate, Int frameRate, Int GOPSize, Int picWidth, Int picHeight, Int LCUWidth, Int LCUHeight, Int numberOfLevel, Bool useLCUSeparateModel ) 84 #endif 77 85 { 78 86 destroy(); … … 101 109 m_betaUpdate = 0.025; 102 110 } 103 else 111 #if M0036_RC_IMPROVEMENT 112 else if ( m_seqTargetBpp < 0.2 ) 104 113 { 105 114 m_alphaUpdate = 0.1; 106 115 m_betaUpdate = 0.05; 107 116 } 117 else if ( m_seqTargetBpp < 0.5 ) 118 { 119 m_alphaUpdate = 0.2; 120 m_betaUpdate = 0.1; 121 } 122 else 123 { 124 m_alphaUpdate = 0.4; 125 m_betaUpdate = 0.2; 126 } 127 #else 128 else 129 { 130 m_alphaUpdate = 0.1; 131 m_betaUpdate = 0.05; 132 } 133 #endif 108 134 m_averageBits = (Int)(m_targetBits / totalFrames); 109 135 Int picWidthInBU = ( m_picWidth % m_LCUWidth ) == 0 ? m_picWidth / m_LCUWidth : m_picWidth / m_LCUWidth + 1; … … 146 172 m_framesLeft = m_totalFrames; 147 173 m_bitsLeft = m_targetBits; 174 #if M0036_RC_IMPROVEMENT 175 m_adaptiveBit = adaptiveBit; 176 m_lastLambda = 0.0; 177 #endif 148 178 } 149 179 … … 203 233 for ( Int i=0; i<m_numberOfLevel; i++ ) 204 234 { 235 #if RATE_CONTROL_INTRA 236 if (i>0) 237 { 205 238 m_picPara[i].m_alpha = 3.2003; 206 239 m_picPara[i].m_beta = -1.367; 207 240 } 241 else 242 { 243 m_picPara[i].m_alpha = ALPHA; 244 m_picPara[i].m_beta = BETA2; 245 } 246 #else 247 m_picPara[i].m_alpha = 3.2003; 248 m_picPara[i].m_beta = -1.367; 249 #endif 250 } 208 251 } 209 252 else … … 228 271 for ( Int j=0; j<m_numberOfLCU; j++) 229 272 { 273 #if RATE_CONTROL_INTRA 274 m_LCUPara[i][j].m_alpha = m_picPara[i].m_alpha; 275 m_LCUPara[i][j].m_beta = m_picPara[i].m_beta; 276 #else 230 277 m_LCUPara[i][j].m_alpha = 3.2003; 231 278 m_LCUPara[i][j].m_beta = -1.367; 279 #endif 232 280 } 233 281 } … … 251 299 } 252 300 301 #if !RATE_CONTROL_INTRA 253 302 Int TEncRCSeq::getRefineBitsForIntra( Int orgBits ) 254 303 { … … 264 313 return orgBits * 10; 265 314 } 315 #endif 316 317 #if M0036_RC_IMPROVEMENT 318 Void TEncRCSeq::setAllBitRatio( Double basicLambda, Double* equaCoeffA, Double* equaCoeffB ) 319 { 320 Int* bitsRatio = new Int[m_GOPSize]; 321 for ( Int i=0; i<m_GOPSize; i++ ) 322 { 323 bitsRatio[i] = (Int)( equaCoeffA[i] * pow( basicLambda, equaCoeffB[i] ) * m_numberOfPixel ); 324 } 325 initBitsRatio( bitsRatio ); 326 delete[] bitsRatio; 327 } 328 #endif 266 329 267 330 //GOP level … … 286 349 Int targetBits = xEstGOPTargetBits( encRCSeq, numPic ); 287 350 351 #if M0036_RC_IMPROVEMENT 352 if ( encRCSeq->getAdaptiveBits() > 0 && encRCSeq->getLastLambda() > 0.1 ) 353 { 354 Double targetBpp = (Double)targetBits / encRCSeq->getNumPixel(); 355 Double basicLambda = 0.0; 356 Double* lambdaRatio = new Double[encRCSeq->getGOPSize()]; 357 Double* equaCoeffA = new Double[encRCSeq->getGOPSize()]; 358 Double* equaCoeffB = new Double[encRCSeq->getGOPSize()]; 359 360 if ( encRCSeq->getAdaptiveBits() == 1 ) // for GOP size =4, low delay case 361 { 362 if ( encRCSeq->getLastLambda() < 120.0 ) 363 { 364 lambdaRatio[1] = 0.725 * log( encRCSeq->getLastLambda() ) + 0.5793; 365 lambdaRatio[0] = 1.3 * lambdaRatio[1]; 366 lambdaRatio[2] = 1.3 * lambdaRatio[1]; 367 lambdaRatio[3] = 1.0; 368 } 369 else 370 { 371 lambdaRatio[0] = 5.0; 372 lambdaRatio[1] = 4.0; 373 lambdaRatio[2] = 5.0; 374 lambdaRatio[3] = 1.0; 375 } 376 } 377 else if ( encRCSeq->getAdaptiveBits() == 2 ) // for GOP size = 8, random access case 378 { 379 if ( encRCSeq->getLastLambda() < 90.0 ) 380 { 381 lambdaRatio[0] = 1.0; 382 lambdaRatio[1] = 0.725 * log( encRCSeq->getLastLambda() ) + 0.7963; 383 lambdaRatio[2] = 1.3 * lambdaRatio[1]; 384 lambdaRatio[3] = 3.25 * lambdaRatio[1]; 385 lambdaRatio[4] = 3.25 * lambdaRatio[1]; 386 lambdaRatio[5] = 1.3 * lambdaRatio[1]; 387 lambdaRatio[6] = 3.25 * lambdaRatio[1]; 388 lambdaRatio[7] = 3.25 * lambdaRatio[1]; 389 } 390 else 391 { 392 lambdaRatio[0] = 1.0; 393 lambdaRatio[1] = 4.0; 394 lambdaRatio[2] = 5.0; 395 lambdaRatio[3] = 12.3; 396 lambdaRatio[4] = 12.3; 397 lambdaRatio[5] = 5.0; 398 lambdaRatio[6] = 12.3; 399 lambdaRatio[7] = 12.3; 400 } 401 } 402 403 xCalEquaCoeff( encRCSeq, lambdaRatio, equaCoeffA, equaCoeffB, encRCSeq->getGOPSize() ); 404 basicLambda = xSolveEqua( targetBpp, equaCoeffA, equaCoeffB, encRCSeq->getGOPSize() ); 405 encRCSeq->setAllBitRatio( basicLambda, equaCoeffA, equaCoeffB ); 406 407 delete []lambdaRatio; 408 delete []equaCoeffA; 409 delete []equaCoeffB; 410 } 411 #endif 412 288 413 m_picTargetBitInGOP = new Int[numPic]; 289 414 Int i; … … 297 422 { 298 423 currPicRatio = encRCSeq->getBitRatio( i ); 424 #if M0036_RC_IMPROVEMENT 425 m_picTargetBitInGOP[i] = (Int)( ((Double)targetBits) * currPicRatio / totalPicRatio ); 426 #else 299 427 m_picTargetBitInGOP[i] = targetBits * currPicRatio / totalPicRatio; 428 #endif 300 429 } 301 430 … … 306 435 m_bitsLeft = m_targetBits; 307 436 } 437 438 #if M0036_RC_IMPROVEMENT 439 Void TEncRCGOP::xCalEquaCoeff( TEncRCSeq* encRCSeq, Double* lambdaRatio, Double* equaCoeffA, Double* equaCoeffB, Int GOPSize ) 440 { 441 for ( Int i=0; i<GOPSize; i++ ) 442 { 443 Int frameLevel = encRCSeq->getGOPID2Level(i); 444 Double alpha = encRCSeq->getPicPara(frameLevel).m_alpha; 445 Double beta = encRCSeq->getPicPara(frameLevel).m_beta; 446 equaCoeffA[i] = pow( 1.0/alpha, 1.0/beta ) * pow( lambdaRatio[i], 1.0/beta ); 447 equaCoeffB[i] = 1.0/beta; 448 } 449 } 450 451 Double TEncRCGOP::xSolveEqua( Double targetBpp, Double* equaCoeffA, Double* equaCoeffB, Int GOPSize ) 452 { 453 Double solution = 100.0; 454 Double minNumber = 0.1; 455 Double maxNumber = 10000.0; 456 for ( Int i=0; i<g_RCIterationNum; i++ ) 457 { 458 Double fx = 0.0; 459 for ( Int j=0; j<GOPSize; j++ ) 460 { 461 fx += equaCoeffA[j] * pow( solution, equaCoeffB[j] ); 462 } 463 464 if ( fabs( fx - targetBpp ) < 0.000001 ) 465 { 466 break; 467 } 468 469 if ( fx > targetBpp ) 470 { 471 minNumber = solution; 472 solution = ( solution + maxNumber ) / 2.0; 473 } 474 else 475 { 476 maxNumber = solution; 477 solution = ( solution + minNumber ) / 2.0; 478 } 479 } 480 481 solution = Clip3( 0.1, 10000.0, solution ); 482 return solution; 483 } 484 #endif 308 485 309 486 Void TEncRCGOP::destroy() … … 357 534 358 535 m_LCUs = NULL; 536 #if !M0036_RC_IMPROVEMENT 359 537 m_lastPicture = NULL; 538 #endif 360 539 m_picActualHeaderBits = 0; 540 #if !M0036_RC_IMPROVEMENT 361 541 m_totalMAD = 0.0; 542 #endif 362 543 m_picActualBits = 0; 363 544 m_picQP = 0; … … 384 565 } 385 566 567 #if M0036_RC_IMPROVEMENT 568 targetBits = Int( ((Double)GOPbitsLeft) * currPicRatio / totalPicRatio ); 569 #else 386 570 targetBits = Int( GOPbitsLeft * currPicRatio / totalPicRatio ); 571 #endif 387 572 388 573 if ( targetBits < 100 ) … … 480 665 m_LCUs[LCUIdx].m_lambda = 0.0; 481 666 m_LCUs[LCUIdx].m_targetBits = 0; 667 #if M0036_RC_IMPROVEMENT 668 m_LCUs[LCUIdx].m_bitWeight = 1.0; 669 #else 482 670 m_LCUs[LCUIdx].m_MAD = 0.0; 671 #endif 483 672 Int currWidth = ( (i == picWidthInLCU -1) ? picWidth - LCUWidth *(picWidthInLCU -1) : LCUWidth ); 484 673 Int currHeight = ( (j == picHeightInLCU-1) ? picHeight - LCUHeight*(picHeightInLCU-1) : LCUHeight ); … … 487 676 } 488 677 m_picActualHeaderBits = 0; 678 #if !M0036_RC_IMPROVEMENT 489 679 m_totalMAD = 0.0; 680 #endif 490 681 m_picActualBits = 0; 491 682 m_picQP = 0; 492 683 m_picLambda = 0.0; 493 684 685 #if !M0036_RC_IMPROVEMENT 494 686 m_lastPicture = NULL; 495 687 list<TEncRCPic*>::reverse_iterator it; … … 502 694 } 503 695 } 696 #endif 504 697 } 505 698 … … 515 708 } 516 709 710 711 #if RATE_CONTROL_INTRA 712 Double TEncRCPic::estimatePicLambda( list<TEncRCPic*>& listPreviousPictures, SliceType eSliceType) 713 #else 517 714 Double TEncRCPic::estimatePicLambda( list<TEncRCPic*>& listPreviousPictures ) 715 #endif 518 716 { 519 717 Double alpha = m_encRCSeq->getPicPara( m_frameLevel ).m_alpha; 520 718 Double beta = m_encRCSeq->getPicPara( m_frameLevel ).m_beta; 521 719 Double bpp = (Double)m_targetBits/(Double)m_numberOfPixel; 720 #if RATE_CONTROL_INTRA 721 Double estLambda; 722 if (eSliceType == I_SLICE) 723 { 724 estLambda = calculateLambdaIntra(alpha, beta, pow(m_totalCostIntra/(Double)m_numberOfPixel, BETA1), bpp); 725 } 726 else 727 { 728 estLambda = alpha * pow( bpp, beta ); 729 } 730 #else 522 731 Double estLambda = alpha * pow( bpp, beta ); 732 #endif 733 523 734 Double lastLevelLambda = -1.0; 524 735 Double lastPicLambda = -1.0; … … 566 777 567 778 m_estPicLambda = estLambda; 779 780 #if M0036_RC_IMPROVEMENT 781 Double totalWeight = 0.0; 782 // initial BU bit allocation weight 783 for ( Int i=0; i<m_numberOfLCU; i++ ) 784 { 785 #if RC_FIX 786 Double alphaLCU, betaLCU; 787 if ( m_encRCSeq->getUseLCUSeparateModel() ) 788 { 789 alphaLCU = m_encRCSeq->getLCUPara( m_frameLevel, i ).m_alpha; 790 betaLCU = m_encRCSeq->getLCUPara( m_frameLevel, i ).m_beta; 791 } 792 else 793 { 794 alphaLCU = m_encRCSeq->getPicPara( m_frameLevel ).m_alpha; 795 betaLCU = m_encRCSeq->getPicPara( m_frameLevel ).m_beta; 796 } 797 #else 798 Double alphaLCU = m_encRCSeq->getLCUPara( m_frameLevel, i ).m_alpha; 799 Double betaLCU = m_encRCSeq->getLCUPara( m_frameLevel, i ).m_beta; 800 #endif 801 802 m_LCUs[i].m_bitWeight = m_LCUs[i].m_numberOfPixel * pow( estLambda/alphaLCU, 1.0/betaLCU ); 803 804 if ( m_LCUs[i].m_bitWeight < 0.01 ) 805 { 806 m_LCUs[i].m_bitWeight = 0.01; 807 } 808 totalWeight += m_LCUs[i].m_bitWeight; 809 } 810 for ( Int i=0; i<m_numberOfLCU; i++ ) 811 { 812 Double BUTargetBits = m_targetBits * m_LCUs[i].m_bitWeight / totalWeight; 813 m_LCUs[i].m_bitWeight = BUTargetBits; 814 } 815 #endif 816 568 817 return estLambda; 569 818 } … … 607 856 } 608 857 858 #if RATE_CONTROL_INTRA 859 Double TEncRCPic::getLCUTargetBpp(SliceType eSliceType) 860 #else 609 861 Double TEncRCPic::getLCUTargetBpp() 862 #endif 610 863 { 611 864 Int LCUIdx = getLCUCoded(); 612 865 Double bpp = -1.0; 613 866 Int avgBits = 0; 867 #if !M0036_RC_IMPROVEMENT 614 868 Double totalMAD = -1.0; 615 869 Double MAD = -1.0; 616 870 #endif 871 872 #if RATE_CONTROL_INTRA 873 if (eSliceType == I_SLICE){ 874 Int noOfLCUsLeft = m_numberOfLCU - LCUIdx + 1; 875 Int bitrateWindow = min(4,noOfLCUsLeft); 876 Double MAD = getLCU(LCUIdx).m_costIntra; 877 878 if (m_remainingCostIntra > 0.1 ) 879 { 880 Double weightedBitsLeft = (m_bitsLeft*bitrateWindow+(m_bitsLeft-getLCU(LCUIdx).m_targetBitsLeft)*noOfLCUsLeft)/(Double)bitrateWindow; 881 avgBits = Int( MAD*weightedBitsLeft/m_remainingCostIntra ); 882 } 883 else 884 { 885 avgBits = Int( m_bitsLeft / m_LCULeft ); 886 } 887 m_remainingCostIntra -= MAD; 888 } 889 else 890 { 891 #endif 892 #if M0036_RC_IMPROVEMENT 893 Double totalWeight = 0; 894 for ( Int i=LCUIdx; i<m_numberOfLCU; i++ ) 895 { 896 totalWeight += m_LCUs[i].m_bitWeight; 897 } 898 Int realInfluenceLCU = min( g_RCLCUSmoothWindowSize, getLCULeft() ); 899 avgBits = (Int)( m_LCUs[LCUIdx].m_bitWeight - ( totalWeight - m_bitsLeft ) / realInfluenceLCU + 0.5 ); 900 #else 617 901 if ( m_lastPicture == NULL ) 618 902 { … … 637 921 } 638 922 } 639 640 #if L0033_RC_BUGFIX 923 #endif 924 #if RATE_CONTROL_INTRA 925 } 926 #endif 927 641 928 if ( avgBits < 1 ) 642 929 { 643 930 avgBits = 1; 644 931 } 645 #else646 if ( avgBits < 5 )647 {648 avgBits = 5;649 }650 #endif651 932 652 933 bpp = ( Double )avgBits/( Double )m_LCUs[ LCUIdx ].m_numberOfPixel; … … 716 997 //for Lambda clip, LCU level clip 717 998 Int clipNeighbourQP = g_RCInvalidQPValue; 718 #if L0033_RC_BUGFIX719 999 for ( int i=LCUIdx - 1; i>=0; i-- ) 720 #else721 for ( int i=LCUIdx; i>=0; i-- )722 #endif723 1000 { 724 1001 if ( (getLCU(i)).m_QP > g_RCInvalidQPValue ) … … 773 1050 beta *= ( 1.0 - m_encRCSeq->getBetaUpdate() / 2.0 ); 774 1051 1052 #if M0036_RC_IMPROVEMENT 1053 alpha = Clip3( g_RCAlphaMinValue, g_RCAlphaMaxValue, alpha ); 1054 beta = Clip3( g_RCBetaMinValue, g_RCBetaMaxValue, beta ); 1055 #else 775 1056 alpha = Clip3( 0.05, 20.0, alpha ); 776 1057 beta = Clip3( -3.0, -0.1, beta ); 1058 #endif 777 1059 778 1060 TRCParameter rcPara; … … 787 1069 alpha += m_encRCSeq->getAlphaUpdate() * ( log( inputLambda ) - log( calLambda ) ) * alpha; 788 1070 double lnbpp = log( bpp ); 1071 #if M0036_RC_IMPROVEMENT 1072 lnbpp = Clip3( -5.0, -0.1, lnbpp ); 1073 #else 789 1074 lnbpp = Clip3( -5.0, 1.0, lnbpp ); 1075 #endif 790 1076 beta += m_encRCSeq->getBetaUpdate() * ( log( inputLambda ) - log( calLambda ) ) * lnbpp; 791 1077 1078 #if M0036_RC_IMPROVEMENT 1079 alpha = Clip3( g_RCAlphaMinValue, g_RCAlphaMaxValue, alpha ); 1080 beta = Clip3( g_RCBetaMinValue, g_RCBetaMaxValue, beta ); 1081 #else 792 1082 alpha = Clip3( 0.05, 20.0, alpha ); 793 1083 beta = Clip3( -3.0, -0.1, beta ); 1084 #endif 794 1085 TRCParameter rcPara; 795 1086 rcPara.m_alpha = alpha; … … 799 1090 } 800 1091 1092 #if !M0036_RC_IMPROVEMENT 801 1093 Double TEncRCPic::getEffectivePercentage() 802 1094 { … … 816 1108 return effectivePixelPercentage; 817 1109 } 1110 #endif 818 1111 819 1112 Double TEncRCPic::calAverageQP() … … 871 1164 } 872 1165 1166 #if M0036_RC_IMPROVEMENT 1167 #if RATE_CONTROL_INTRA 1168 Void TEncRCPic::updateAfterPicture( Int actualHeaderBits, Int actualTotalBits, Double averageQP, Double averageLambda, SliceType eSliceType) 1169 #else 1170 Void TEncRCPic::updateAfterPicture( Int actualHeaderBits, Int actualTotalBits, Double averageQP, Double averageLambda ) 1171 #endif 1172 #else 873 1173 Void TEncRCPic::updateAfterPicture( Int actualHeaderBits, Int actualTotalBits, Double averageQP, Double averageLambda, Double effectivePercentage ) 1174 #endif 874 1175 { 875 1176 m_picActualHeaderBits = actualHeaderBits; … … 884 1185 } 885 1186 m_picLambda = averageLambda; 1187 #if !M0036_RC_IMPROVEMENT 886 1188 for ( Int i=0; i<m_numberOfLCU; i++ ) 887 1189 { 888 1190 m_totalMAD += m_LCUs[i].m_MAD; 889 1191 } 1192 #endif 890 1193 891 1194 Double alpha = m_encRCSeq->getPicPara( m_frameLevel ).m_alpha; 892 1195 Double beta = m_encRCSeq->getPicPara( m_frameLevel ).m_beta; 893 1196 #if RATE_CONTROL_INTRA 1197 if (eSliceType == I_SLICE) 1198 { 1199 updateAlphaBetaIntra(&alpha, &beta); 1200 } 1201 else 1202 { 1203 #endif 894 1204 // update parameters 895 1205 Double picActualBits = ( Double )m_picActualBits; … … 898 1208 Double inputLambda = m_picLambda; 899 1209 1210 #if M0036_RC_IMPROVEMENT 1211 if ( inputLambda < 0.01 || calLambda < 0.01 || picActualBpp < 0.0001 ) 1212 #else 900 1213 if ( inputLambda < 0.01 || calLambda < 0.01 || picActualBpp < 0.0001 || effectivePercentage < 0.05 ) 1214 #endif 901 1215 { 902 1216 alpha *= ( 1.0 - m_encRCSeq->getAlphaUpdate() / 2.0 ); 903 1217 beta *= ( 1.0 - m_encRCSeq->getBetaUpdate() / 2.0 ); 904 1218 1219 #if M0036_RC_IMPROVEMENT 1220 alpha = Clip3( g_RCAlphaMinValue, g_RCAlphaMaxValue, alpha ); 1221 beta = Clip3( g_RCBetaMinValue, g_RCBetaMaxValue, beta ); 1222 #else 905 1223 alpha = Clip3( 0.05, 20.0, alpha ); 906 1224 beta = Clip3( -3.0, -0.1, beta ); 1225 #endif 907 1226 TRCParameter rcPara; 908 1227 rcPara.m_alpha = alpha; … … 916 1235 alpha += m_encRCSeq->getAlphaUpdate() * ( log( inputLambda ) - log( calLambda ) ) * alpha; 917 1236 double lnbpp = log( picActualBpp ); 1237 #if M0036_RC_IMPROVEMENT 1238 lnbpp = Clip3( -5.0, -0.1, lnbpp ); 1239 #else 918 1240 lnbpp = Clip3( -5.0, 1.0, lnbpp ); 1241 #endif 919 1242 beta += m_encRCSeq->getBetaUpdate() * ( log( inputLambda ) - log( calLambda ) ) * lnbpp; 920 1243 1244 #if M0036_RC_IMPROVEMENT 1245 alpha = Clip3( g_RCAlphaMinValue, g_RCAlphaMaxValue, alpha ); 1246 beta = Clip3( g_RCBetaMinValue, g_RCBetaMaxValue, beta ); 1247 #else 921 1248 alpha = Clip3( 0.05, 20.0, alpha ); 922 1249 beta = Clip3( -3.0, -0.1, beta ); 1250 #endif 1251 #if RATE_CONTROL_INTRA 1252 } 1253 #endif 923 1254 924 1255 TRCParameter rcPara; … … 927 1258 928 1259 m_encRCSeq->setPicPara( m_frameLevel, rcPara ); 929 } 1260 1261 #if M0036_RC_IMPROVEMENT 1262 if ( m_frameLevel == 1 ) 1263 { 1264 Double currLambda = Clip3( 0.1, 10000.0, m_picLambda ); 1265 Double updateLastLambda = g_RCWeightHistoryLambda * m_encRCSeq->getLastLambda() + g_RCWeightCurrentLambda * currLambda; 1266 m_encRCSeq->setLastLambda( updateLastLambda ); 1267 } 1268 #endif 1269 } 1270 1271 #if RATE_CONTROL_INTRA 1272 Int TEncRCPic::getRefineBitsForIntra( Int orgBits ) 1273 { 1274 Double alpha=0.25, beta=0.5582; 1275 Int iIntraBits; 1276 1277 if (orgBits*40 < m_numberOfPixel) 1278 { 1279 alpha=0.25; 1280 } 1281 else 1282 { 1283 alpha=0.30; 1284 } 1285 1286 iIntraBits = (Int)(alpha* pow(m_totalCostIntra*4.0/(Double)orgBits, beta)*(Double)orgBits+0.5); 1287 1288 return iIntraBits; 1289 } 1290 1291 Double TEncRCPic::calculateLambdaIntra(double alpha, double beta, double MADPerPixel, double bitsPerPixel) 1292 { 1293 return ( (alpha/256.0) * pow( MADPerPixel/bitsPerPixel, beta ) ); 1294 } 1295 1296 Void TEncRCPic::updateAlphaBetaIntra(double *alpha, double *beta) 1297 { 1298 Double lnbpp = log(pow(m_totalCostIntra / (Double)m_numberOfPixel, BETA1)); 1299 Double diffLambda = (*beta)*(log((Double)m_picActualBits)-log((Double)m_targetBits)); 1300 1301 diffLambda = Clip3(-0.125, 0.125, 0.25*diffLambda); 1302 *alpha = (*alpha) * exp(diffLambda); 1303 *beta = (*beta) + diffLambda / lnbpp; 1304 } 1305 1306 1307 Void TEncRCPic::getLCUInitTargetBits() 1308 { 1309 Int iAvgBits = 0; 1310 1311 m_remainingCostIntra = m_totalCostIntra; 1312 for (Int i=m_numberOfLCU-1; i>=0; i--) 1313 { 1314 iAvgBits += Int(m_targetBits * getLCU(i).m_costIntra/m_totalCostIntra); 1315 getLCU(i).m_targetBitsLeft = iAvgBits; 1316 } 1317 } 1318 1319 1320 Double TEncRCPic::getLCUEstLambdaAndQP(Double bpp, Int clipPicQP, Int *estQP) 1321 { 1322 Int LCUIdx = getLCUCoded(); 1323 1324 Double alpha = m_encRCSeq->getPicPara( m_frameLevel ).m_alpha; 1325 Double beta = m_encRCSeq->getPicPara( m_frameLevel ).m_beta; 1326 1327 Double costPerPixel = getLCU(LCUIdx).m_costIntra/(Double)getLCU(LCUIdx).m_numberOfPixel; 1328 costPerPixel = pow(costPerPixel, BETA1); 1329 Double estLambda = calculateLambdaIntra(alpha, beta, costPerPixel, bpp); 1330 1331 Int clipNeighbourQP = g_RCInvalidQPValue; 1332 for (int i=LCUIdx-1; i>=0; i--) 1333 { 1334 if ((getLCU(i)).m_QP > g_RCInvalidQPValue) 1335 { 1336 clipNeighbourQP = getLCU(i).m_QP; 1337 break; 1338 } 1339 } 1340 1341 Int minQP = clipPicQP - 2; 1342 Int maxQP = clipPicQP + 2; 1343 1344 if ( clipNeighbourQP > g_RCInvalidQPValue ) 1345 { 1346 maxQP = min(clipNeighbourQP + 1, maxQP); 1347 minQP = max(clipNeighbourQP - 1, minQP); 1348 } 1349 1350 Double maxLambda=exp(((Double)(maxQP+0.49)-13.7122)/4.2005); 1351 Double minLambda=exp(((Double)(minQP-0.49)-13.7122)/4.2005); 1352 1353 estLambda = Clip3(minLambda, maxLambda, estLambda); 1354 1355 *estQP = Int( 4.2005 * log(estLambda) + 13.7122 + 0.5 ); 1356 *estQP = Clip3(minQP, maxQP, *estQP); 1357 1358 return estLambda; 1359 } 1360 #endif 930 1361 931 1362 TEncRateCtrl::TEncRateCtrl() … … 961 1392 } 962 1393 1394 #if M0036_RC_IMPROVEMENT 1395 Void TEncRateCtrl::init( Int totalFrames, Int targetBitrate, Int frameRate, Int GOPSize, Int picWidth, Int picHeight, Int LCUWidth, Int LCUHeight, Int keepHierBits, Bool useLCUSeparateModel, GOPEntry GOPList[MAX_GOP] ) 1396 #else 963 1397 Void TEncRateCtrl::init( Int totalFrames, Int targetBitrate, Int frameRate, Int GOPSize, Int picWidth, Int picHeight, Int LCUWidth, Int LCUHeight, Bool keepHierBits, Bool useLCUSeparateModel, GOPEntry GOPList[MAX_GOP] ) 1398 #endif 964 1399 { 965 1400 destroy(); … … 976 1411 977 1412 Int numberOfLevel = 1; 1413 #if M0036_RC_IMPROVEMENT 1414 Int adaptiveBit = 0; 1415 if ( keepHierBits > 0 ) 1416 #else 978 1417 if ( keepHierBits ) 1418 #endif 979 1419 { 980 1420 numberOfLevel = Int( log((Double)GOPSize)/log(2.0) + 0.5 ) + 1; … … 998 1438 } 999 1439 } 1440 1441 #if M0036_RC_IMPROVEMENT 1442 if ( keepHierBits > 0 ) 1443 #else 1000 1444 if ( keepHierBits ) 1445 #endif 1001 1446 { 1002 1447 Double bpp = (Double)( targetBitrate / (Double)( frameRate*picWidth*picHeight ) ); … … 1031 1476 bitsRatio[3] = 14; 1032 1477 } 1478 #if M0036_RC_IMPROVEMENT 1479 if ( keepHierBits == 2 ) 1480 { 1481 adaptiveBit = 1; 1482 } 1483 #endif 1033 1484 } 1034 1485 else if ( GOPSize == 8 && !isLowdelay ) … … 1078 1529 bitsRatio[7] = 1; 1079 1530 } 1531 #if M0036_RC_IMPROVEMENT 1532 if ( keepHierBits == 2 ) 1533 { 1534 adaptiveBit = 2; 1535 } 1536 #endif 1080 1537 } 1081 1538 else 1082 1539 { 1540 #if M0036_RC_IMPROVEMENT 1541 printf( "\n hierarchical bit allocation is not support for the specified coding structure currently.\n" ); 1542 #else 1083 1543 printf( "\n hierarchical bit allocation is not support for the specified coding structure currently." ); 1544 #endif 1084 1545 } 1085 1546 } … … 1094 1555 } 1095 1556 } 1557 #if M0036_RC_IMPROVEMENT 1558 if ( keepHierBits > 0 ) 1559 #else 1096 1560 if ( keepHierBits ) 1561 #endif 1097 1562 { 1098 1563 if ( GOPSize == 4 && isLowdelay ) … … 1129 1594 1130 1595 m_encRCSeq = new TEncRCSeq; 1596 #if M0036_RC_IMPROVEMENT 1597 m_encRCSeq->create( totalFrames, targetBitrate, frameRate, GOPSize, picWidth, picHeight, LCUWidth, LCUHeight, numberOfLevel, useLCUSeparateModel, adaptiveBit ); 1598 #else 1131 1599 m_encRCSeq->create( totalFrames, targetBitrate, frameRate, GOPSize, picWidth, picHeight, LCUWidth, LCUHeight, numberOfLevel, useLCUSeparateModel ); 1600 #endif 1132 1601 m_encRCSeq->initBitsRatio( bitsRatio ); 1133 1602 m_encRCSeq->initGOPID2Level( GOPID2Level ); -
trunk/source/Lib/TLibEncoder/TEncRateCtrl.h
r191 r310 65 65 const Double g_RCWeightPicTargetBitInGOP = 0.9; 66 66 const Double g_RCWeightPicRargetBitInBuffer = 1.0 - g_RCWeightPicTargetBitInGOP; 67 #if M0036_RC_IMPROVEMENT 68 const Int g_RCIterationNum = 20; 69 const Double g_RCWeightHistoryLambda = 0.5; 70 const Double g_RCWeightCurrentLambda = 1.0 - g_RCWeightHistoryLambda; 71 const Int g_RCLCUSmoothWindowSize = 4; 72 const Double g_RCAlphaMinValue = 0.05; 73 const Double g_RCAlphaMaxValue = 500.0; 74 const Double g_RCBetaMinValue = -3.0; 75 const Double g_RCBetaMaxValue = -0.1; 76 #endif 77 78 #if RATE_CONTROL_INTRA 79 #define ALPHA 6.7542; 80 #define BETA1 1.2517 81 #define BETA2 1.7860 82 #endif 67 83 68 84 struct TRCLCU … … 72 88 Int m_targetBits; 73 89 Double m_lambda; 90 #if M0036_RC_IMPROVEMENT 91 Double m_bitWeight; 92 #else 74 93 Double m_MAD; 94 #endif 75 95 Int m_numberOfPixel; 96 #if RATE_CONTROL_INTRA 97 Double m_costIntra; 98 Int m_targetBitsLeft; 99 #endif 76 100 }; 77 101 … … 89 113 90 114 public: 115 #if M0036_RC_IMPROVEMENT 116 Void create( Int totalFrames, Int targetBitrate, Int frameRate, Int GOPSize, Int picWidth, Int picHeight, Int LCUWidth, Int LCUHeight, Int numberOfLevel, Bool useLCUSeparateModel, Int adaptiveBit ); 117 #else 91 118 Void create( Int totalFrames, Int targetBitrate, Int frameRate, Int GOPSize, Int picWidth, Int picHeight, Int LCUWidth, Int LCUHeight, Int numberOfLevel, Bool useLCUSeparateModel ); 119 #endif 92 120 Void destroy(); 93 121 Void initBitsRatio( Int bitsRatio[] ); … … 96 124 Void initLCUPara( TRCParameter** LCUPara = NULL ); // NULL to initial with default value 97 125 Void updateAfterPic ( Int bits ); 126 #if !RATE_CONTROL_INTRA 98 127 Int getRefineBitsForIntra( Int orgBits ); 128 #endif 129 #if M0036_RC_IMPROVEMENT 130 Void setAllBitRatio( Double basicLambda, Double* equaCoeffA, Double* equaCoeffB ); 131 #endif 99 132 100 133 public: … … 134 167 Double getBetaUpdate() { return m_betaUpdate; } 135 168 169 #if M0036_RC_IMPROVEMENT 170 Int getAdaptiveBits() { return m_adaptiveBit; } 171 Double getLastLambda() { return m_lastLambda; } 172 Void setLastLambda( Double lamdba ) { m_lastLambda = lamdba; } 173 #endif 174 136 175 private: 137 176 Int m_totalFrames; … … 160 199 Double m_betaUpdate; 161 200 Bool m_useLCUSeparateModel; 201 202 #if M0036_RC_IMPROVEMENT 203 Int m_adaptiveBit; 204 Double m_lastLambda; 205 #endif 162 206 }; 163 207 … … 175 219 private: 176 220 Int xEstGOPTargetBits( TEncRCSeq* encRCSeq, Int GOPSize ); 221 #if M0036_RC_IMPROVEMENT 222 Void xCalEquaCoeff( TEncRCSeq* encRCSeq, Double* lambdaRatio, Double* equaCoeffA, Double* equaCoeffB, Int GOPSize ); 223 Double xSolveEqua( Double targetBpp, Double* equaCoeffA, Double* equaCoeffB, Int GOPSize ); 224 #endif 177 225 178 226 public: … … 203 251 Void destroy(); 204 252 253 #if !RATE_CONTROL_INTRA 205 254 Double estimatePicLambda( list<TEncRCPic*>& listPreviousPictures ); 255 #endif 206 256 Int estimatePicQP ( Double lambda, list<TEncRCPic*>& listPreviousPictures ); 257 #if RATE_CONTROL_INTRA 258 Int getRefineBitsForIntra(Int orgBits); 259 Double calculateLambdaIntra(double alpha, double beta, double MADPerPixel, double bitsPerPixel); 260 Double estimatePicLambda( list<TEncRCPic*>& listPreviousPictures, SliceType eSliceType); 261 262 Void updateAlphaBetaIntra(double *alpha, double *beta); 263 264 Double getLCUTargetBpp(SliceType eSliceType); 265 Double getLCUEstLambdaAndQP(Double bpp, Int clipPicQP, Int *estQP); 266 #else 207 267 Double getLCUTargetBpp(); 268 #endif 208 269 Double getLCUEstLambda( Double bpp ); 209 270 Int getLCUEstQP( Double lambda, Int clipPicQP ); 210 271 211 272 Void updateAfterLCU( Int LCUIdx, Int bits, Int QP, Double lambda, Bool updateLCUParameter = true ); 273 #if M0036_RC_IMPROVEMENT 274 #if RATE_CONTROL_INTRA 275 Void updateAfterPicture( Int actualHeaderBits, Int actualTotalBits, Double averageQP, Double averageLambda, SliceType eSliceType); 276 #else 277 Void updateAfterPicture( Int actualHeaderBits, Int actualTotalBits, Double averageQP, Double averageLambda ); 278 #endif 279 #else 212 280 Void updateAfterPicture( Int actualHeaderBits, Int actualTotalBits, Double averageQP, Double averageLambda, Double effectivePercentage ); 281 #endif 213 282 214 283 Void addToPictureLsit( list<TEncRCPic*>& listPreviousPictures ); 284 #if !M0036_RC_IMPROVEMENT 215 285 Double getEffectivePercentage(); 286 #endif 216 287 Double calAverageQP(); 217 288 Double calAverageLambda(); … … 229 300 Int getNumberOfLCU() { return m_numberOfLCU; } 230 301 Int getTargetBits() { return m_targetBits; } 302 #if !RATE_CONTROL_INTRA 231 303 Void setTargetBits( Int bits ) { m_targetBits = bits; } 304 #endif 232 305 Int getEstHeaderBits() { return m_estHeaderBits; } 233 306 Int getLCULeft() { return m_LCULeft; } … … 239 312 TRCLCU& getLCU( Int LCUIdx ) { return m_LCUs[LCUIdx]; } 240 313 Int getPicActualHeaderBits() { return m_picActualHeaderBits; } 314 #if !M0036_RC_IMPROVEMENT 241 315 Double getTotalMAD() { return m_totalMAD; } 242 316 Void setTotalMAD( Double MAD ) { m_totalMAD = MAD; } 317 #endif 318 #if RATE_CONTROL_INTRA 319 Void setTargetBits( Int bits ) { m_targetBits = bits; m_bitsLeft = bits;} 320 Void setTotalIntraCost(Double cost) { m_totalCostIntra = cost; } 321 Void getLCUInitTargetBits(); 322 #endif 323 243 324 Int getPicActualBits() { return m_picActualBits; } 244 325 Int getPicActualQP() { return m_picQP; } … … 267 348 TRCLCU* m_LCUs; 268 349 Int m_picActualHeaderBits; // only SH and potential APS 350 #if !M0036_RC_IMPROVEMENT 269 351 Double m_totalMAD; 352 #endif 353 #if RATE_CONTROL_INTRA 354 Double m_totalCostIntra; 355 Double m_remainingCostIntra; 356 #endif 270 357 Int m_picActualBits; // the whole picture, including header 271 358 Int m_picQP; // in integer form 272 359 Double m_picLambda; 360 #if !M0036_RC_IMPROVEMENT 273 361 TEncRCPic* m_lastPicture; 362 #endif 274 363 }; 275 364 … … 281 370 282 371 public: 372 #if M0036_RC_IMPROVEMENT 373 Void init( Int totalFrames, Int targetBitrate, Int frameRate, Int GOPSize, Int picWidth, Int picHeight, Int LCUWidth, Int LCUHeight, Int keepHierBits, Bool useLCUSeparateModel, GOPEntry GOPList[MAX_GOP] ); 374 #else 283 375 Void init( Int totalFrames, Int targetBitrate, Int frameRate, Int GOPSize, Int picWidth, Int picHeight, Int LCUWidth, Int LCUHeight, Bool keepHierBits, Bool useLCUSeparateModel, GOPEntry GOPList[MAX_GOP] ); 376 #endif 284 377 Void destroy(); 285 378 Void initRCPic( Int frameLevel ); -
trunk/source/Lib/TLibEncoder/TEncSampleAdaptiveOffset.cpp
r191 r310 299 299 m_iTypePartBest[iPartIdx] = -1; 300 300 if( m_bUseSBACRD ) 301 { 301 302 m_pcRDGoOnSbacCoder->store( m_pppcRDSbacCoder[pOnePart->PartLevel][CI_TEMP_BEST] ); 303 } 302 304 } 303 305 } -
trunk/source/Lib/TLibEncoder/TEncSearch.cpp
r191 r310 1410 1410 1411 1411 #if HHI_RQT_INTRA_SPEEDUP 1412 #if L0232_RD_PENALTY1413 1412 Int maxTuSize = pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize(); 1414 1413 Int isIntraSlice = (pcCU->getSlice()->getSliceType() == I_SLICE); … … 1427 1426 } 1428 1427 if( bCheckFirst && noSplitIntraMaxTuSize ) 1428 { 1429 bCheckSplit = false; 1430 } 1429 1431 #else 1430 if( bCheckFirst && bCheckFull )1431 #endif1432 {1433 bCheckSplit = false;1434 }1435 #else1436 #if L0232_RD_PENALTY1437 1432 Int maxTuSize = pcCU->getSlice()->getSPS()->getQuadtreeTULog2MaxSize(); 1438 1433 Int isIntraSlice = (pcCU->getSlice()->getSliceType() == I_SLICE); … … 1442 1437 bCheckFull = ( uiLog2TrSize <= min(maxTuSize,4)); 1443 1438 } 1444 #endif1445 1439 #endif 1446 1440 Double dSingleCost = MAX_DOUBLE; … … 1617 1611 //----- determine rate and r-d cost ----- 1618 1612 UInt uiSingleBits = xGetIntraBitsQT( pcCU, uiTrDepth, uiAbsPartIdx, true, !bLumaOnly, false ); 1619 #if L0232_RD_PENALTY1620 1613 if(m_pcEncCfg->getRDpenalty() && (uiLog2TrSize==5) && !isIntraSlice) 1621 1614 { 1622 1615 uiSingleBits=uiSingleBits*4; 1623 1616 } 1624 #endif1625 1617 dSingleCost = m_pcRdCost->calcRdCost( uiSingleBits, uiSingleDistY + uiSingleDistC ); 1626 1618 } … … 2506 2498 { 2507 2499 assert(numModesForFullRD < numModesAvailable); 2500 #if FAST_INTRA_SHVC 2501 Int uiPreds[3] = {-1, -1, -1}; 2502 Int iMode = -1; 2503 Bool skipFastHAD = false; 2504 Int numCand = pcCU->getIntraDirLumaPredictor( uiPartOffset, uiPreds, &iMode ); 2505 2506 if ( m_pcEncCfg->getUseFastIntraScalable() ) 2507 { 2508 if( pcCU->getLayerId() > 0 ) 2509 { 2510 numModesAvailable = pcCU->reduceSetOfIntraModes(uiPartOffset, uiPreds, iMode ); 2511 if( numModesForFullRD > numModesAvailable ) //fast HAD can be skipped 2512 { 2513 skipFastHAD = true; 2514 numModesForFullRD = numModesAvailable; 2515 for( Int i=0; i < numModesForFullRD; i++ ) 2516 uiRdModeList[ i ] = g_reducedSetIntraModes[ i ]; 2517 } 2518 } 2519 } 2520 #endif 2508 2521 2509 2522 for( Int i=0; i < numModesForFullRD; i++ ) … … 2516 2529 { 2517 2530 UInt uiMode = modeIdx; 2531 #if FAST_INTRA_SHVC 2532 if ( m_pcEncCfg->getUseFastIntraScalable() ) 2533 { 2534 if( skipFastHAD )//indicates that fast HAD can be skipped 2535 break; 2536 uiMode = ( iMode==0 ) ? g_reducedSetIntraModes[modeIdx] : uiMode; //(iMode=0) indicates reduced set of modes 2537 } 2538 #endif 2518 2539 2519 2540 predIntraLumaAng( pcCU->getPattern(), uiMode, piPred, uiStride, uiWidth, uiHeight, bAboveAvail, bLeftAvail ); … … 2529 2550 2530 2551 #if FAST_UDI_USE_MPM 2552 #if FAST_INTRA_SHVC == 0 2531 2553 Int uiPreds[3] = {-1, -1, -1}; 2532 2554 Int iMode = -1; 2533 2555 Int numCand = pcCU->getIntraDirLumaPredictor( uiPartOffset, uiPreds, &iMode ); 2556 #endif 2534 2557 if( iMode >= 0 ) 2535 2558 { … … 3065 3088 Int iHeight = 0; 3066 3089 3067 #if 0 //REF_IDX_FRAMEWORK // HM bug fix3068 for( UInt uiMergeCand = 0; uiMergeCand < pcCU->getSlice()->getMaxNumMergeCand(); ++uiMergeCand )3069 {3070 uhInterDirNeighbours[uiMergeCand] = 0;3071 cMvFieldNeighbours[0 + 2*uiMergeCand].setMvField(TComMv(), NOT_VALID);3072 cMvFieldNeighbours[1 + 2*uiMergeCand].setMvField(TComMv(), NOT_VALID);3073 }3074 #endif3075 3090 pcCU->getPartIndexAndSize( iPUIdx, uiAbsPartIdx, iWidth, iHeight ); 3076 3091 UInt uiDepth = pcCU->getDepth( uiAbsPartIdx ); … … 3249 3264 UInt uiBitsTempL0[MAX_NUM_REF]; 3250 3265 3251 #if L0034_COMBINED_LIST_CLEANUP3252 3266 TComMv mvValidList1; 3253 3267 Int refIdxValidList1 = 0; 3254 3268 UInt bitsValidList1 = MAX_UINT; 3255 3269 UInt costValidList1 = MAX_UINT; 3256 #endif3257 3258 #if (ENCODER_FAST_MODE)3259 Bool testILR;3260 #endif3261 3270 3262 3271 xGetBlkBits( ePartSize, pcCU->getSlice()->isInterP(), iPartIdx, uiLastMode, uiMbBits); … … 3281 3290 RefPicList eRefPicList = ( iRefList ? REF_PIC_LIST_1 : REF_PIC_LIST_0 ); 3282 3291 3283 #if (ENCODER_FAST_MODE)3284 if (pcCU->getSlice()->getNumRefIdx(eRefPicList) > 1)3285 {3286 testILR = false;3287 }3288 else3289 {3290 testILR = true;3291 }3292 #endif3293 3294 3292 for ( Int iRefIdxTemp = 0; iRefIdxTemp < pcCU->getSlice()->getNumRefIdx(eRefPicList); iRefIdxTemp++ ) 3295 3293 { 3296 3294 #if (ENCODER_FAST_MODE) 3297 3295 TComPic* pcPic = pcCU->getSlice()->getRefPic( eRefPicList, iRefIdxTemp ); 3298 if( !testILR &&pcPic->isILR(pcCU->getLayerId()) && (ePartSize == SIZE_2Nx2N) )3296 if( pcPic->isILR(pcCU->getLayerId()) && (ePartSize == SIZE_2Nx2N) ) 3299 3297 { 3300 3298 continue; … … 3333 3331 uiBitsTemp += m_auiMVPIdxCost[aaiMvpIdx[iRefList][iRefIdxTemp]][AMVP_MAX_NUM_CANDS]; 3334 3332 #if ZERO_MVD_EST 3335 #if L0034_COMBINED_LIST_CLEANUP3336 3333 if ( iRefList == 0 || pcCU->getSlice()->getList1IdxToList0Idx( iRefIdxTemp ) < 0 ) 3337 #else3338 if ((iRefList != 1 || !pcCU->getSlice()->getNoBackPredFlag()) &&3339 (pcCU->getSlice()->getNumRefIdx(REF_PIC_LIST_C) <= 0 || pcCU->getSlice()->getRefIdxOfLC(eRefPicList, iRefIdxTemp)>=0))3340 #endif3341 3334 { 3342 3335 uiZeroMvdBitsTemp = uiBitsTemp; … … 3358 3351 3359 3352 #if GPB_SIMPLE_UNI 3360 #if L0034_COMBINED_LIST_CLEANUP3361 3353 if ( iRefList == 1 ) // list 1 3362 3354 { … … 3383 3375 } 3384 3376 #else 3385 if ( pcCU->getSlice()->getNumRefIdx(REF_PIC_LIST_C) > 0)3386 {3387 if ( iRefList && ( pcCU->getSlice()->getNoBackPredFlag() || (pcCU->getSlice()->getNumRefIdx(REF_PIC_LIST_C) > 0 && !pcCU->getSlice()->getNoBackPredFlag() && pcCU->getSlice()->getRefIdxOfL0FromRefIdxOfL1(iRefIdxTemp)>=0 ) ) )3388 {3389 if ( pcCU->getSlice()->getNoBackPredFlag() )3390 {3391 cMvTemp[1][iRefIdxTemp] = cMvTemp[0][iRefIdxTemp];3392 uiCostTemp = uiCostTempL0[iRefIdxTemp];3393 /*first subtract the bit-rate part of the cost of the other list*/3394 uiCostTemp -= m_pcRdCost->getCost( uiBitsTempL0[iRefIdxTemp] );3395 }3396 else3397 {3398 cMvTemp[1][iRefIdxTemp] = cMvTemp[0][pcCU->getSlice()->getRefIdxOfL0FromRefIdxOfL1(iRefIdxTemp)];3399 uiCostTemp = uiCostTempL0[pcCU->getSlice()->getRefIdxOfL0FromRefIdxOfL1(iRefIdxTemp)];3400 /*first subtract the bit-rate part of the cost of the other list*/3401 uiCostTemp -= m_pcRdCost->getCost( uiBitsTempL0[pcCU->getSlice()->getRefIdxOfL0FromRefIdxOfL1(iRefIdxTemp)] );3402 }3403 /*correct the bit-rate part of the current ref*/3404 m_pcRdCost->setPredictor ( cMvPred[iRefList][iRefIdxTemp] );3405 uiBitsTemp += m_pcRdCost->getBits( cMvTemp[1][iRefIdxTemp].getHor(), cMvTemp[1][iRefIdxTemp].getVer() );3406 /*calculate the correct cost*/3407 uiCostTemp += m_pcRdCost->getCost( uiBitsTemp );3408 }3409 else3410 {3411 xMotionEstimation ( pcCU, pcOrgYuv, iPartIdx, eRefPicList, &cMvPred[iRefList][iRefIdxTemp], iRefIdxTemp, cMvTemp[iRefList][iRefIdxTemp], uiBitsTemp, uiCostTemp );3412 }3413 }3414 else3415 {3416 if (iRefList && pcCU->getSlice()->getNoBackPredFlag())3417 {3418 uiCostTemp = MAX_UINT;3419 cMvTemp[1][iRefIdxTemp] = cMvTemp[0][iRefIdxTemp];3420 }3421 else3422 {3423 xMotionEstimation ( pcCU, pcOrgYuv, iPartIdx, eRefPicList, &cMvPred[iRefList][iRefIdxTemp], iRefIdxTemp, cMvTemp[iRefList][iRefIdxTemp], uiBitsTemp, uiCostTemp );3424 }3425 }3426 #endif3427 #else3428 3377 xMotionEstimation ( pcCU, pcOrgYuv, iPartIdx, eRefPicList, &cMvPred[iRefList][iRefIdxTemp], iRefIdxTemp, cMvTemp[iRefList][iRefIdxTemp], uiBitsTemp, uiCostTemp ); 3429 3378 #endif … … 3431 3380 xCheckBestMVP(pcCU, eRefPicList, cMvTemp[iRefList][iRefIdxTemp], cMvPred[iRefList][iRefIdxTemp], aaiMvpIdx[iRefList][iRefIdxTemp], uiBitsTemp, uiCostTemp); 3432 3381 3433 #if L0034_COMBINED_LIST_CLEANUP3434 3382 if ( iRefList == 0 ) 3435 3383 { … … 3456 3404 refIdxValidList1 = iRefIdxTemp; 3457 3405 } 3458 #else3459 if(pcCU->getSlice()->getNumRefIdx(REF_PIC_LIST_C) > 0 && !pcCU->getSlice()->getNoBackPredFlag())3460 {3461 if(iRefList==REF_PIC_LIST_0)3462 {3463 uiCostTempL0[iRefIdxTemp] = uiCostTemp;3464 uiBitsTempL0[iRefIdxTemp] = uiBitsTemp;3465 if(pcCU->getSlice()->getRefIdxOfLC(REF_PIC_LIST_0, iRefIdxTemp)<0)3466 {3467 uiCostTemp = MAX_UINT;3468 }3469 }3470 else3471 {3472 if(pcCU->getSlice()->getRefIdxOfLC(REF_PIC_LIST_1, iRefIdxTemp)<0)3473 {3474 uiCostTemp = MAX_UINT;3475 }3476 }3477 }3478 3479 #if ENCODER_BUGFIX3480 if ( ( iRefList == 0 && uiCostTemp < uiCost[iRefList] ) ||3481 ( iRefList == 1 && pcCU->getSlice()->getNoBackPredFlag() && iRefIdxTemp == iRefIdx[0] ) ||3482 ( iRefList == 1 && !pcCU->getSlice()->getNoBackPredFlag() && uiCostTemp < uiCost[iRefList] ) )3483 #else3484 if ( ( iRefList == 0 && uiCostTemp < uiCost[iRefList] ) ||3485 ( iRefList == 1 && pcCU->getSlice()->getNoBackPredFlag() && iRefIdxTemp == iRefIdx[0] ) ||3486 ( iRefList == 1 && (pcCU->getSlice()->getNumRefIdx(REF_PIC_LIST_C) > 0) && (iRefIdxTemp==0 || iRefIdxTemp == iRefIdx[0]) && !pcCU->getSlice()->getNoBackPredFlag() && (iRefIdxTemp == pcCU->getSlice()->getRefIdxOfL0FromRefIdxOfL1(iRefIdxTemp)) ) ||3487 ( iRefList == 1 && !pcCU->getSlice()->getNoBackPredFlag() && uiCostTemp < uiCost[iRefList] ) )3488 #endif3489 {3490 uiCost[iRefList] = uiCostTemp;3491 uiBits[iRefList] = uiBitsTemp; // storing for bi-prediction3492 3493 // set motion3494 cMv[iRefList] = cMvTemp[iRefList][iRefIdxTemp];3495 iRefIdx[iRefList] = iRefIdxTemp;3496 pcCU->getCUMvField(eRefPicList)->setAllMv( cMv[iRefList], ePartSize, uiPartAddr, 0, iPartIdx );3497 pcCU->getCUMvField(eRefPicList)->setAllRefIdx( iRefIdx[iRefList], ePartSize, uiPartAddr, 0, iPartIdx );3498 3499 if(!pcCU->getSlice()->getMvdL1ZeroFlag())3500 {3501 // storing list 1 prediction signal for iterative bi-directional prediction3502 if ( eRefPicList == REF_PIC_LIST_1 )3503 {3504 TComYuv* pcYuvPred = &m_acYuvPred[iRefList];3505 motionCompensation ( pcCU, pcYuvPred, eRefPicList, iPartIdx );3506 }3507 if ( (pcCU->getSlice()->getNoBackPredFlag() || (pcCU->getSlice()->getNumRefIdx(REF_PIC_LIST_C) > 0 && pcCU->getSlice()->getRefIdxOfL0FromRefIdxOfL1(0)==0 )) && eRefPicList == REF_PIC_LIST_0 )3508 {3509 TComYuv* pcYuvPred = &m_acYuvPred[iRefList];3510 motionCompensation ( pcCU, pcYuvPred, eRefPicList, iPartIdx );3511 }3512 }3513 }3514 #endif3515 3406 } 3516 3407 } … … 3580 3471 3581 3472 Int iRefList = iIter % 2; 3582 #if L0034_COMBINED_LIST_CLEANUP3583 3473 if ( m_pcEncCfg->getUseFastEnc() ) 3584 3474 { … … 3603 3493 motionCompensation ( pcCU, pcYuvPred, RefPicList(1-iRefList), iPartIdx ); 3604 3494 } 3605 #else3606 if ( m_pcEncCfg->getUseFastEnc() && (pcCU->getSlice()->getNoBackPredFlag() || (pcCU->getSlice()->getNumRefIdx(REF_PIC_LIST_C) > 0 && pcCU->getSlice()->getRefIdxOfL0FromRefIdxOfL1(0)==0 )) )3607 {3608 iRefList = 1;3609 }3610 #endif3611 3495 RefPicList eRefPicList = ( iRefList ? REF_PIC_LIST_1 : REF_PIC_LIST_0 ); 3612 3496 … … 3769 3653 UInt uiMEBits = 0; 3770 3654 // Set Motion Field_ 3771 #if L0034_COMBINED_LIST_CLEANUP3772 3655 cMv[1] = mvValidList1; 3773 3656 iRefIdx[1] = refIdxValidList1; 3774 3657 uiBits[1] = bitsValidList1; 3775 3658 uiCost[1] = costValidList1; 3776 #else3777 if ( pcCU->getSlice()->getNoBackPredFlag() || (pcCU->getSlice()->getNumRefIdx(REF_PIC_LIST_C) > 0 && pcCU->getSlice()->getRefIdxOfL0FromRefIdxOfL1(0)==0 ) )3778 {3779 uiCost[1] = MAX_UINT;3780 }3781 #endif3782 3659 #if AMP_MRG 3783 3660 if (bTestNormalMC) … … 6274 6151 6275 6152 #if ENCODER_FAST_MODE 6276 Bool TEncSearch::predInterSearchILRUni( TComDataCU* pcCU, TComYuv* pcOrgYuv, TComYuv*& rpcPredYuv, TComYuv*& rpcResiYuv, TComYuv*& rpcRecoYuv )6153 Bool TEncSearch::predInterSearchILRUni( TComDataCU* pcCU, TComYuv* pcOrgYuv, TComYuv*& rpcPredYuv, TComYuv*& rpcResiYuv, TComYuv*& rpcRecoYuv, UInt refLayerId ) 6277 6154 { 6278 rpcPredYuv->clear(); 6279 rpcRecoYuv->clear(); 6280 6281 Int iNumPredDir = pcCU->getSlice()->isInterP() ? 1 : 2; 6282 6283 TComMv cMv[2]; 6284 TComMv cMvPred[2][33]; 6285 TComMv cMvTemp[2][33]; 6286 TComMv TempMv; 6287 6288 Int iRefIdx[2]={0,0}; 6289 6290 Int aaiMvpIdx[2][33]; 6291 Int aaiMvpNum[2][33]; 6292 6293 UInt uiMbBits[3] = {1, 1, 0}; 6294 UInt uiLastMode = 0; 6295 6296 UInt uiCost[2] = { MAX_UINT, MAX_UINT }; //uni, rdCost 6297 UInt uiCostTemp; 6298 UInt biPDistTemp = MAX_INT; 6299 UInt uiBitsTemp; 6300 6301 PartSize ePartSize = pcCU->getPartitionSize( 0 ); //2Nx2N 6302 Int iPartIdx = 0; //one PU in CU 6303 UInt uiPartAddr; 6304 Int iRoiWidth, iRoiHeight; 6305 6306 xGetBlkBits( ePartSize, pcCU->getSlice()->isInterP(), iPartIdx, uiLastMode, uiMbBits); 6307 pcCU->getPartIndexAndSize( iPartIdx, uiPartAddr, iRoiWidth, iRoiHeight ); 6308 6309 for( Int iRefList = 0; iRefList < iNumPredDir; iRefList++) //list 6310 { 6311 RefPicList eRefPicList = ( iRefList ? REF_PIC_LIST_1 : REF_PIC_LIST_0 ); 6312 6313 Int iRefIdxTemp = -1; 6314 Bool foundILR = false; 6315 for( Int refIdx = 0; refIdx < pcCU->getSlice()->getNumRefIdx(eRefPicList); refIdx++ ) 6316 { 6317 if( pcCU->getSlice()->getRefPic(eRefPicList, refIdx)->isILR(pcCU->getLayerId()) ) 6318 { 6319 iRefIdxTemp = refIdx; 6320 foundILR = true; 6321 break; 6322 } 6323 } 6324 6325 if(!foundILR) //no ILR in eRefPiclist 6326 { 6327 continue; 6328 } 6329 6330 uiBitsTemp = uiMbBits[iRefList]; 6331 if ( pcCU->getSlice()->getNumRefIdx(eRefPicList) > 1 ) 6332 { 6333 uiBitsTemp += iRefIdxTemp+1; 6334 if ( iRefIdxTemp == pcCU->getSlice()->getNumRefIdx(eRefPicList)-1 ) uiBitsTemp--; 6335 } 6336 6337 xEstimateMvPredAMVP( pcCU, pcOrgYuv, iPartIdx, eRefPicList, iRefIdxTemp, cMvPred[iRefList][iRefIdxTemp], false, &biPDistTemp); 6338 aaiMvpIdx[iRefList][iRefIdxTemp] = pcCU->getMVPIdx(eRefPicList, uiPartAddr); 6339 aaiMvpNum[iRefList][iRefIdxTemp] = pcCU->getMVPNum(eRefPicList, uiPartAddr); 6340 6341 uiBitsTemp += m_auiMVPIdxCost[aaiMvpIdx[iRefList][iRefIdxTemp]][AMVP_MAX_NUM_CANDS]; 6342 6343 xMotionEstimation ( pcCU, pcOrgYuv, iPartIdx, eRefPicList, &cMvPred[iRefList][iRefIdxTemp], iRefIdxTemp, cMvTemp[iRefList][iRefIdxTemp], uiBitsTemp, uiCostTemp ); 6344 xCheckBestMVP(pcCU, eRefPicList, cMvTemp[iRefList][iRefIdxTemp], cMvPred[iRefList][iRefIdxTemp], aaiMvpIdx[iRefList][iRefIdxTemp], uiBitsTemp, uiCostTemp); 6345 6346 if( uiCostTemp < uiCost[iRefList] ) 6347 { 6348 uiCost[iRefList] = uiCostTemp; 6349 6350 cMv[iRefList] = cMvTemp[iRefList][iRefIdxTemp]; 6351 iRefIdx[iRefList] = iRefIdxTemp; 6352 6353 pcCU->getCUMvField(eRefPicList)->setAllMv( cMv[iRefList], ePartSize, uiPartAddr, 0, iPartIdx ); 6354 pcCU->getCUMvField(eRefPicList)->setAllRefIdx( iRefIdx[iRefList], ePartSize, uiPartAddr, 0, iPartIdx ); 6355 } 6356 } 6357 6358 if( uiCost[0] == MAX_UINT && uiCost[1] == MAX_UINT ) //no ILR in both list0 and list1 6359 { 6360 return false; 6361 } 6362 6363 // Clear Motion Field 6364 pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMvField( TComMvField(), ePartSize, uiPartAddr, 0, iPartIdx ); 6365 pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMvField( TComMvField(), ePartSize, uiPartAddr, 0, iPartIdx ); 6366 pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMvd ( TComMv(), ePartSize, uiPartAddr, 0, iPartIdx ); 6367 pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMvd ( TComMv(), ePartSize, uiPartAddr, 0, iPartIdx ); 6368 6369 pcCU->setMVPIdxSubParts( -1, REF_PIC_LIST_0, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr)); 6370 pcCU->setMVPNumSubParts( -1, REF_PIC_LIST_0, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr)); 6371 pcCU->setMVPIdxSubParts( -1, REF_PIC_LIST_1, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr)); 6372 pcCU->setMVPNumSubParts( -1, REF_PIC_LIST_1, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr)); 6373 6374 if( uiCost[0] <= uiCost[1] ) //list0 ILR 6375 { 6376 pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMv ( cMv[0], ePartSize, uiPartAddr, 0, iPartIdx ); 6377 pcCU->getCUMvField(REF_PIC_LIST_0)->setAllRefIdx( iRefIdx[0], ePartSize, uiPartAddr, 0, iPartIdx ); 6378 6379 TempMv = cMv[0] - cMvPred[0][iRefIdx[0]]; 6380 pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMvd( TempMv, ePartSize, uiPartAddr, 0, iPartIdx ); 6381 6382 pcCU->setInterDirSubParts( 1, uiPartAddr, iPartIdx, pcCU->getDepth(0) ); 6383 6384 pcCU->setMVPIdxSubParts( aaiMvpIdx[0][iRefIdx[0]], REF_PIC_LIST_0, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr)); 6385 pcCU->setMVPNumSubParts( aaiMvpNum[0][iRefIdx[0]], REF_PIC_LIST_0, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr)); 6386 } 6387 else if( uiCost[1] < uiCost[0] ) //list1 ILR 6388 { 6389 pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMv ( cMv[1], ePartSize, uiPartAddr, 0, iPartIdx ); 6390 pcCU->getCUMvField(REF_PIC_LIST_1)->setAllRefIdx( iRefIdx[1], ePartSize, uiPartAddr, 0, iPartIdx ); 6391 6392 TempMv = cMv[1] - cMvPred[1][iRefIdx[1]]; 6393 pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMvd( TempMv, ePartSize, uiPartAddr, 0, iPartIdx ); 6394 6395 pcCU->setInterDirSubParts( 2, uiPartAddr, iPartIdx, pcCU->getDepth(0) ); 6396 6397 pcCU->setMVPIdxSubParts( aaiMvpIdx[1][iRefIdx[1]], REF_PIC_LIST_1, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr)); 6398 pcCU->setMVPNumSubParts( aaiMvpNum[1][iRefIdx[1]], REF_PIC_LIST_1, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr)); 6399 } 6400 else 6401 { 6402 assert(0); 6403 } 6404 6405 pcCU->setMergeFlagSubParts( false, uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) ); 6406 6407 motionCompensation ( pcCU, rpcPredYuv, REF_PIC_LIST_X, iPartIdx ); 6408 6409 setWpScalingDistParam( pcCU, -1, REF_PIC_LIST_X ); 6410 6411 return true; 6155 rpcPredYuv->clear(); 6156 rpcRecoYuv->clear(); 6157 6158 Int iNumPredDir = pcCU->getSlice()->isInterP() ? 1 : 2; 6159 6160 TComMv cMv[2]; 6161 TComMv cMvPred[2][33]; 6162 TComMv cMvTemp[2][33]; 6163 TComMv TempMv; 6164 6165 Int iRefIdx[2]={0,0}; 6166 6167 Int aaiMvpIdx[2][33]; 6168 Int aaiMvpNum[2][33]; 6169 6170 UInt uiMbBits[3] = {1, 1, 0}; 6171 UInt uiLastMode = 0; 6172 6173 UInt uiCost[2] = { MAX_UINT, MAX_UINT }; //uni, rdCost 6174 UInt uiCostTemp; 6175 UInt biPDistTemp = MAX_INT; 6176 UInt uiBitsTemp; 6177 6178 PartSize ePartSize = pcCU->getPartitionSize( 0 ); //2Nx2N 6179 Int iPartIdx = 0; //one PU in CU 6180 UInt uiPartAddr; 6181 Int iRoiWidth, iRoiHeight; 6182 Bool bILRSearched = false; 6183 6184 xGetBlkBits( ePartSize, pcCU->getSlice()->isInterP(), iPartIdx, uiLastMode, uiMbBits); 6185 pcCU->getPartIndexAndSize( iPartIdx, uiPartAddr, iRoiWidth, iRoiHeight ); 6186 6187 for( Int iRefList = 0; iRefList < iNumPredDir; iRefList++) //list 6188 { 6189 if(bILRSearched) 6190 continue; 6191 6192 RefPicList eRefPicList = ( iRefList ? REF_PIC_LIST_1 : REF_PIC_LIST_0 ); 6193 6194 Int iRefIdxTemp = -1; 6195 Bool foundILR = false; 6196 6197 for( Int refIdx = 0; refIdx < pcCU->getSlice()->getNumRefIdx(eRefPicList); refIdx++ ) 6198 { 6199 if( pcCU->getSlice()->getRefPic(eRefPicList, refIdx)->isILR(pcCU->getLayerId()) && pcCU->getSlice()->getRefPic(eRefPicList, refIdx)->getLayerId() == refLayerId ) 6200 { 6201 iRefIdxTemp = refIdx; 6202 foundILR = true; 6203 bILRSearched = true; 6204 break; 6205 } 6206 } 6207 6208 if(!foundILR) //no ILR in eRefPiclist 6209 { 6210 continue; 6211 } 6212 6213 uiBitsTemp = uiMbBits[iRefList]; 6214 if ( pcCU->getSlice()->getNumRefIdx(eRefPicList) > 1 ) 6215 { 6216 uiBitsTemp += iRefIdxTemp+1; 6217 if ( iRefIdxTemp == pcCU->getSlice()->getNumRefIdx(eRefPicList)-1 ) uiBitsTemp--; 6218 } 6219 6220 xEstimateMvPredAMVP( pcCU, pcOrgYuv, iPartIdx, eRefPicList, iRefIdxTemp, cMvPred[iRefList][iRefIdxTemp], false, &biPDistTemp); 6221 aaiMvpIdx[iRefList][iRefIdxTemp] = pcCU->getMVPIdx(eRefPicList, uiPartAddr); 6222 aaiMvpNum[iRefList][iRefIdxTemp] = pcCU->getMVPNum(eRefPicList, uiPartAddr); 6223 6224 uiBitsTemp += m_auiMVPIdxCost[aaiMvpIdx[iRefList][iRefIdxTemp]][AMVP_MAX_NUM_CANDS]; 6225 6226 xMotionEstimation ( pcCU, pcOrgYuv, iPartIdx, eRefPicList, &cMvPred[iRefList][iRefIdxTemp], iRefIdxTemp, cMvTemp[iRefList][iRefIdxTemp], uiBitsTemp, uiCostTemp ); 6227 xCheckBestMVP(pcCU, eRefPicList, cMvTemp[iRefList][iRefIdxTemp], cMvPred[iRefList][iRefIdxTemp], aaiMvpIdx[iRefList][iRefIdxTemp], uiBitsTemp, uiCostTemp); 6228 6229 if( uiCostTemp < uiCost[iRefList] ) 6230 { 6231 uiCost[iRefList] = uiCostTemp; 6232 6233 cMv[iRefList] = cMvTemp[iRefList][iRefIdxTemp]; 6234 iRefIdx[iRefList] = iRefIdxTemp; 6235 6236 pcCU->getCUMvField(eRefPicList)->setAllMv( cMv[iRefList], ePartSize, uiPartAddr, 0, iPartIdx ); 6237 pcCU->getCUMvField(eRefPicList)->setAllRefIdx( iRefIdx[iRefList], ePartSize, uiPartAddr, 0, iPartIdx ); 6238 } 6239 } 6240 6241 if( uiCost[0] == MAX_UINT && uiCost[1] == MAX_UINT ) //no ILR in both list0 and list1 6242 { 6243 return false; 6244 } 6245 6246 // Clear Motion Field 6247 pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMvField( TComMvField(), ePartSize, uiPartAddr, 0, iPartIdx ); 6248 pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMvField( TComMvField(), ePartSize, uiPartAddr, 0, iPartIdx ); 6249 pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMvd ( TComMv(), ePartSize, uiPartAddr, 0, iPartIdx ); 6250 pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMvd ( TComMv(), ePartSize, uiPartAddr, 0, iPartIdx ); 6251 6252 pcCU->setMVPIdxSubParts( -1, REF_PIC_LIST_0, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr)); 6253 pcCU->setMVPNumSubParts( -1, REF_PIC_LIST_0, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr)); 6254 pcCU->setMVPIdxSubParts( -1, REF_PIC_LIST_1, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr)); 6255 pcCU->setMVPNumSubParts( -1, REF_PIC_LIST_1, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr)); 6256 6257 if( uiCost[0] <= uiCost[1] ) //list0 ILR 6258 { 6259 pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMv ( cMv[0], ePartSize, uiPartAddr, 0, iPartIdx ); 6260 pcCU->getCUMvField(REF_PIC_LIST_0)->setAllRefIdx( iRefIdx[0], ePartSize, uiPartAddr, 0, iPartIdx ); 6261 6262 TempMv = cMv[0] - cMvPred[0][iRefIdx[0]]; 6263 pcCU->getCUMvField(REF_PIC_LIST_0)->setAllMvd( TempMv, ePartSize, uiPartAddr, 0, iPartIdx ); 6264 6265 pcCU->setInterDirSubParts( 1, uiPartAddr, iPartIdx, pcCU->getDepth(0) ); 6266 6267 pcCU->setMVPIdxSubParts( aaiMvpIdx[0][iRefIdx[0]], REF_PIC_LIST_0, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr)); 6268 pcCU->setMVPNumSubParts( aaiMvpNum[0][iRefIdx[0]], REF_PIC_LIST_0, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr)); 6269 } 6270 else if( uiCost[1] < uiCost[0] ) //list1 ILR 6271 { 6272 pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMv ( cMv[1], ePartSize, uiPartAddr, 0, iPartIdx ); 6273 pcCU->getCUMvField(REF_PIC_LIST_1)->setAllRefIdx( iRefIdx[1], ePartSize, uiPartAddr, 0, iPartIdx ); 6274 6275 TempMv = cMv[1] - cMvPred[1][iRefIdx[1]]; 6276 pcCU->getCUMvField(REF_PIC_LIST_1)->setAllMvd( TempMv, ePartSize, uiPartAddr, 0, iPartIdx ); 6277 6278 pcCU->setInterDirSubParts( 2, uiPartAddr, iPartIdx, pcCU->getDepth(0) ); 6279 6280 pcCU->setMVPIdxSubParts( aaiMvpIdx[1][iRefIdx[1]], REF_PIC_LIST_1, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr)); 6281 pcCU->setMVPNumSubParts( aaiMvpNum[1][iRefIdx[1]], REF_PIC_LIST_1, uiPartAddr, iPartIdx, pcCU->getDepth(uiPartAddr)); 6282 } 6283 else 6284 { 6285 assert(0); 6286 } 6287 6288 pcCU->setMergeFlagSubParts( false, uiPartAddr, iPartIdx, pcCU->getDepth( uiPartAddr ) ); 6289 6290 motionCompensation ( pcCU, rpcPredYuv, REF_PIC_LIST_X, iPartIdx ); 6291 setWpScalingDistParam( pcCU, -1, REF_PIC_LIST_X ); 6292 6293 return true; 6412 6294 } 6413 6414 6415 6295 #endif 6416 6296 -
trunk/source/Lib/TLibEncoder/TEncSearch.h
r191 r310 216 216 217 217 #if (ENCODER_FAST_MODE) 218 Bool predInterSearchILRUni ( TComDataCU* pcCU, 219 TComYuv* pcOrgYuv, 220 TComYuv*& rpcPredYuv, 221 TComYuv*& rpcResiYuv, 222 TComYuv*& rpcRecoYuv 223 ); 224 218 Bool predInterSearchILRUni ( TComDataCU* pcCU, TComYuv* pcOrgYuv, TComYuv*& rpcPredYuv, TComYuv*& rpcResiYuv, TComYuv*& rpcRecoYuv, UInt refLayerId ); 225 219 #endif 226 220 -
trunk/source/Lib/TLibEncoder/TEncSlice.cpp
r191 r310 425 425 rpcSlice->setNumRefIdx(REF_PIC_LIST_1,m_pcCfg->getGOPEntry(iGOPid).m_numRefPicsActive); 426 426 427 #if L0386_DB_METRIC428 427 if ( m_pcCfg->getDeblockingFilterMetric() ) 429 428 { … … 433 432 rpcSlice->setDeblockingFilterTcOffsetDiv2( 0 ); 434 433 } else 435 #endif436 434 if (rpcSlice->getPPS()->getDeblockingFilterControlPresentFlag()) 437 435 { … … 491 489 { 492 490 #if JCTVC_M0458_INTERLAYER_RPS_SIG 493 // currently only one reference layer is supported in software and no decision logic to select yet.494 // hence num of active inter layer references is set to one always495 491 if( rpcSlice->getNumILRRefIdx() > 0 ) 496 492 { 497 rpcSlice->setActiveNumILRRefIdx(1); 493 rpcSlice->setActiveNumILRRefIdx( m_ppcTEncTop[layerId]->getNumActiveRefLayers() ); 494 for( Int i = 0; i < rpcSlice->getActiveNumILRRefIdx(); i++ ) 495 { 496 rpcSlice->setInterLayerPredLayerIdc( m_ppcTEncTop[layerId]->getPredLayerId(i), i ); 497 } 498 498 rpcSlice->setInterLayerPredEnabledFlag(1); 499 499 } 500 500 #else 501 501 rpcSlice->setNumILRRefIdx( rpcSlice->getVPS()->getNumDirectRefLayers( layerId ) ); 502 #endif 502 #endif 503 #if M0457_COL_PICTURE_SIGNALING 504 rpcSlice->setMFMEnabledFlag(m_ppcTEncTop[layerId]->getMFMEnabledFlag()); 505 rpcSlice->setAltColIndicationFlag(rpcSlice->getMFMEnabledFlag()); 506 #endif 503 507 } 504 508 … … 513 517 // store lambda 514 518 slice->setSliceQp( sliceQP ); 515 #if L0033_RC_BUGFIX516 519 slice->setSliceQpBase ( sliceQP ); 517 #endif518 520 m_pcRdCost ->setLambda( lambda ); 519 521 #if WEIGHTED_CHROMA_DISTORTION … … 822 824 /** \param rpcPic picture class 823 825 */ 826 #if RATE_CONTROL_INTRA 827 Void TEncSlice::calCostSliceI(TComPic*& rpcPic) 828 { 829 UInt uiCUAddr; 830 UInt uiStartCUAddr; 831 UInt uiBoundingCUAddr; 832 Int iSumHad, shift = g_bitDepthY-8, offset = (shift>0)?(1<<(shift-1)):0;; 833 Double iSumHadSlice = 0; 834 835 rpcPic->getSlice(getSliceIdx())->setSliceSegmentBits(0); 836 TComSlice* pcSlice = rpcPic->getSlice(getSliceIdx()); 837 xDetermineStartAndBoundingCUAddr ( uiStartCUAddr, uiBoundingCUAddr, rpcPic, false ); 838 839 UInt uiEncCUOrder; 840 uiCUAddr = rpcPic->getPicSym()->getCUOrderMap( uiStartCUAddr /rpcPic->getNumPartInCU()); 841 for( uiEncCUOrder = uiStartCUAddr/rpcPic->getNumPartInCU(); 842 uiEncCUOrder < (uiBoundingCUAddr+(rpcPic->getNumPartInCU()-1))/rpcPic->getNumPartInCU(); 843 uiCUAddr = rpcPic->getPicSym()->getCUOrderMap(++uiEncCUOrder) ) 844 { 845 // initialize CU encoder 846 TComDataCU*& pcCU = rpcPic->getCU( uiCUAddr ); 847 pcCU->initCU( rpcPic, uiCUAddr ); 848 849 Int height = min( pcSlice->getSPS()->getMaxCUHeight(),pcSlice->getSPS()->getPicHeightInLumaSamples() - uiCUAddr / rpcPic->getFrameWidthInCU() * pcSlice->getSPS()->getMaxCUHeight() ); 850 Int width = min( pcSlice->getSPS()->getMaxCUWidth(),pcSlice->getSPS()->getPicWidthInLumaSamples() - uiCUAddr % rpcPic->getFrameWidthInCU() * pcSlice->getSPS()->getMaxCUWidth() ); 851 852 iSumHad = m_pcCuEncoder->updateLCUDataISlice(pcCU, uiCUAddr, width, height); 853 854 (m_pcRateCtrl->getRCPic()->getLCU(uiCUAddr)).m_costIntra=(iSumHad+offset)>>shift; 855 iSumHadSlice += (m_pcRateCtrl->getRCPic()->getLCU(uiCUAddr)).m_costIntra; 856 857 } 858 m_pcRateCtrl->getRCPic()->setTotalIntraCost(iSumHadSlice); 859 } 860 #endif 861 824 862 Void TEncSlice::compressSlice( TComPic*& rpcPic ) 825 863 { … … 943 981 944 982 #if INTRA_BL 945 m_pcCuEncoder->setBaseRecPic( rpcPic->getLayerId() > 0 ? rpcPic->getFullPelBaseRec( ) : NULL);983 m_pcCuEncoder->setBaseRecPic( rpcPic->getLayerId() > 0 ? rpcPic->getFullPelBaseRec(rpcPic->getLayerId()-1) : NULL); 946 984 #endif 947 985 … … 993 1031 TComDataCU*& pcCU = rpcPic->getCU( uiCUAddr ); 994 1032 pcCU->initCU( rpcPic, uiCUAddr ); 995 #if SVC_EXTENSION996 pcCU->setLayerId(m_pcCfg->getLayerId());997 #endif998 1033 999 1034 #if !RATE_CONTROL_LAMBDA_DOMAIN … … 1088 1123 Double bpp = -1.0; 1089 1124 1125 #if M0036_RC_IMPROVEMENT 1126 if ( ( rpcPic->getSlice( 0 )->getSliceType() == I_SLICE && m_pcCfg->getForceIntraQP() ) || !m_pcCfg->getLCULevelRC() ) 1127 #else 1090 1128 if ( rpcPic->getSlice( 0 )->getSliceType() == I_SLICE || !m_pcCfg->getLCULevelRC() ) 1129 #endif 1091 1130 { 1092 1131 estQP = pcSlice->getSliceQp(); … … 1094 1133 else 1095 1134 { 1135 #if RATE_CONTROL_INTRA 1136 bpp = m_pcRateCtrl->getRCPic()->getLCUTargetBpp(pcSlice->getSliceType()); 1137 if ( rpcPic->getSlice( 0 )->getSliceType() == I_SLICE) 1138 { 1139 estLambda = m_pcRateCtrl->getRCPic()->getLCUEstLambdaAndQP(bpp, pcSlice->getSliceQp(), &estQP); 1140 } 1141 else 1142 { 1143 estLambda = m_pcRateCtrl->getRCPic()->getLCUEstLambda( bpp ); 1144 estQP = m_pcRateCtrl->getRCPic()->getLCUEstQP ( estLambda, pcSlice->getSliceQp() ); 1145 } 1146 #else 1096 1147 bpp = m_pcRateCtrl->getRCPic()->getLCUTargetBpp(); 1097 1148 estLambda = m_pcRateCtrl->getRCPic()->getLCUEstLambda( bpp ); 1098 1149 estQP = m_pcRateCtrl->getRCPic()->getLCUEstQP ( estLambda, pcSlice->getSliceQp() ); 1150 #endif 1151 1099 1152 estQP = Clip3( -pcSlice->getSPS()->getQpBDOffsetY(), MAX_QP, estQP ); 1100 1153 1101 1154 m_pcRdCost->setLambda(estLambda); 1155 #if M0036_RC_IMPROVEMENT 1156 #if RDOQ_CHROMA_LAMBDA 1157 // set lambda for RDOQ 1158 Double weight=m_pcRdCost->getChromaWeight(); 1159 m_pcTrQuant->setLambda( estLambda, estLambda / weight ); 1160 #else 1161 m_pcTrQuant->setLambda( estLambda ); 1162 #endif 1163 #endif 1102 1164 } 1103 1165 1104 1166 m_pcRateCtrl->setRCQP( estQP ); 1105 #if L0033_RC_BUGFIX1106 1167 pcCU->getSlice()->setSliceQpBase( estQP ); 1107 #endif1108 1168 } 1109 1169 #endif … … 1112 1172 m_pcCuEncoder->compressCU( pcCU ); 1113 1173 1174 #if !TICKET_1090_FIX 1114 1175 #if RATE_CONTROL_LAMBDA_DOMAIN 1115 1176 if ( m_pcCfg->getUseRateCtrl() ) 1116 1177 { 1178 #if !M0036_RC_IMPROVEMENT 1117 1179 UInt SAD = m_pcCuEncoder->getLCUPredictionSAD(); 1118 1180 Int height = min( pcSlice->getSPS()->getMaxCUHeight(),pcSlice->getSPS()->getPicHeightInLumaSamples() - uiCUAddr / rpcPic->getFrameWidthInCU() * pcSlice->getSPS()->getMaxCUHeight() ); … … 1121 1183 MAD = MAD * MAD; 1122 1184 ( m_pcRateCtrl->getRCPic()->getLCU(uiCUAddr) ).m_MAD = MAD; 1185 #endif 1123 1186 1124 1187 Int actualQP = g_RCInvalidQPValue; … … 1144 1207 } 1145 1208 m_pcRdCost->setLambda(oldLambda); 1146 1209 #if RATE_CONTROL_INTRA 1210 m_pcRateCtrl->getRCPic()->updateAfterLCU( m_pcRateCtrl->getRCPic()->getLCUCoded(), actualBits, actualQP, actualLambda, 1211 pcCU->getSlice()->getSliceType() == I_SLICE ? 0 : m_pcCfg->getLCULevelRC() ); 1212 #else 1147 1213 m_pcRateCtrl->getRCPic()->updateAfterLCU( m_pcRateCtrl->getRCPic()->getLCUCoded(), actualBits, actualQP, actualLambda, m_pcCfg->getLCULevelRC() ); 1148 } 1214 #endif 1215 } 1216 #endif 1149 1217 #endif 1150 1218 … … 1180 1248 } 1181 1249 } 1250 1251 #if TICKET_1090_FIX 1252 #if RATE_CONTROL_LAMBDA_DOMAIN 1253 if ( m_pcCfg->getUseRateCtrl() ) 1254 { 1255 #if !M0036_RC_IMPROVEMENT 1256 UInt SAD = m_pcCuEncoder->getLCUPredictionSAD(); 1257 Int height = min( pcSlice->getSPS()->getMaxCUHeight(),pcSlice->getSPS()->getPicHeightInLumaSamples() - uiCUAddr / rpcPic->getFrameWidthInCU() * pcSlice->getSPS()->getMaxCUHeight() ); 1258 Int width = min( pcSlice->getSPS()->getMaxCUWidth(),pcSlice->getSPS()->getPicWidthInLumaSamples() - uiCUAddr % rpcPic->getFrameWidthInCU() * pcSlice->getSPS()->getMaxCUWidth() ); 1259 Double MAD = (Double)SAD / (Double)(height * width); 1260 MAD = MAD * MAD; 1261 ( m_pcRateCtrl->getRCPic()->getLCU(uiCUAddr) ).m_MAD = MAD; 1262 #endif 1263 1264 Int actualQP = g_RCInvalidQPValue; 1265 Double actualLambda = m_pcRdCost->getLambda(); 1266 Int actualBits = pcCU->getTotalBits(); 1267 Int numberOfEffectivePixels = 0; 1268 for ( Int idx = 0; idx < rpcPic->getNumPartInCU(); idx++ ) 1269 { 1270 if ( pcCU->getPredictionMode( idx ) != MODE_NONE && ( !pcCU->isSkipped( idx ) ) ) 1271 { 1272 numberOfEffectivePixels = numberOfEffectivePixels + 16; 1273 break; 1274 } 1275 } 1276 1277 if ( numberOfEffectivePixels == 0 ) 1278 { 1279 actualQP = g_RCInvalidQPValue; 1280 } 1281 else 1282 { 1283 actualQP = pcCU->getQP( 0 ); 1284 } 1285 m_pcRdCost->setLambda(oldLambda); 1286 1287 #if RATE_CONTROL_INTRA 1288 m_pcRateCtrl->getRCPic()->updateAfterLCU( m_pcRateCtrl->getRCPic()->getLCUCoded(), actualBits, actualQP, actualLambda, 1289 pcCU->getSlice()->getSliceType() == I_SLICE ? 0 : m_pcCfg->getLCULevelRC() ); 1290 #else 1291 m_pcRateCtrl->getRCPic()->updateAfterLCU( m_pcRateCtrl->getRCPic()->getLCUCoded(), actualBits, actualQP, actualLambda, m_pcCfg->getLCULevelRC() ); 1292 #endif 1293 } 1294 #endif 1295 #endif 1182 1296 } 1183 1297 // other case: encodeCU is not called -
trunk/source/Lib/TLibEncoder/TEncSlice.h
r191 r310 132 132 Void precompressSlice ( TComPic*& rpcPic ); ///< precompress slice for multi-loop opt. 133 133 Void compressSlice ( TComPic*& rpcPic ); ///< analysis stage of slice 134 #if RATE_CONTROL_INTRA 135 Void calCostSliceI ( TComPic*& rpcPic ); 136 #endif 134 137 Void encodeSlice ( TComPic*& rpcPic, TComOutputBitstream* pcSubstreams ); 135 138 -
trunk/source/Lib/TLibEncoder/TEncTop.cpp
r191 r310 89 89 m_bMFMEnabledFlag = false; 90 90 #endif 91 #if SCALED_REF_LAYER_OFFSETS 92 m_numScaledRefLayerOffsets = 0; 93 #endif 91 94 } 92 95 … … 310 313 /* set the VPS profile information */ 311 314 *m_cVPS.getPTL() = *m_cSPS.getPTL(); 312 #if L0043_TIMING_INFO313 315 m_cVPS.getTimingInfo()->setTimingInfoPresentFlag ( false ); 314 #endif315 316 // initialize PPS 316 317 m_cPPS.setSPS(&m_cSPS); … … 386 387 // compress GOP 387 388 #if RATE_CONTROL_LAMBDA_DOMAIN 389 #if !RC_SHVC_HARMONIZATION 388 390 if ( m_RCEnableRateControl ) 389 391 { 390 392 m_cRateCtrl.initRCGOP( m_iNumPicRcvd ); 391 393 } 394 #endif 392 395 #endif 393 396 … … 396 399 397 400 #if RATE_CONTROL_LAMBDA_DOMAIN 401 #if !RC_SHVC_HARMONIZATION 398 402 if ( m_RCEnableRateControl ) 399 403 { 400 404 m_cRateCtrl.destroyRCGOP(); 401 405 } 406 #endif 402 407 #endif 403 408 … … 503 508 if(m_layerId > 0) 504 509 { 505 #if VPS_EXTN_DIRECT_REF_LAYERS_CONTINUE 506 TEncTop *pcEncTopBase = (TEncTop *)getRefLayerEnc( m_layerId ); 510 for(UInt i = 0; i < m_cVPS.getNumDirectRefLayers( m_layerId ); i++ ) 511 { 512 const Window scalEL = getSPS()->getScaledRefLayerWindow(i); 513 Bool zeroOffsets = ( scalEL.getWindowLeftOffset() == 0 && scalEL.getWindowRightOffset() == 0 && scalEL.getWindowTopOffset() == 0 && scalEL.getWindowBottomOffset() == 0 ); 514 515 #if VPS_EXTN_DIRECT_REF_LAYERS 516 TEncTop *pcEncTopBase = (TEncTop *)getRefLayerEnc( i ); 507 517 #else 508 TEncTop *pcEncTopBase = (TEncTop *)getLayerEnc( m_layerId-1 ); 509 #endif 510 if(m_iSourceWidth != pcEncTopBase->getSourceWidth() || m_iSourceHeight != pcEncTopBase->getSourceHeight() ) 511 { 512 pcEPic->setSpatialEnhLayerFlag( true ); 518 TEncTop *pcEncTopBase = (TEncTop *)getLayerEnc( m_layerId-1 ); 519 #endif 520 if(m_iSourceWidth != pcEncTopBase->getSourceWidth() || m_iSourceHeight != pcEncTopBase->getSourceHeight() || !zeroOffsets ) 521 { 522 pcEPic->setSpatialEnhLayerFlag( i, true ); 523 524 //only for scalable extension 525 assert( m_cVPS.getScalabilityMask(1) == true ); 526 } 513 527 } 514 528 } … … 531 545 if(m_layerId > 0) 532 546 { 533 #if VPS_EXTN_DIRECT_REF_LAYERS_CONTINUE 534 TEncTop *pcEncTopBase = (TEncTop *)getRefLayerEnc( m_layerId ); 547 for(UInt i = 0; i < m_cVPS.getNumDirectRefLayers( m_layerId ); i++ ) 548 { 549 const Window scalEL = getSPS()->getScaledRefLayerWindow(i); 550 Bool zeroOffsets = ( scalEL.getWindowLeftOffset() == 0 && scalEL.getWindowRightOffset() == 0 && scalEL.getWindowTopOffset() == 0 && scalEL.getWindowBottomOffset() == 0 ); 551 552 #if VPS_EXTN_DIRECT_REF_LAYERS 553 TEncTop *pcEncTopBase = (TEncTop *)getRefLayerEnc( i ); 535 554 #else 536 TEncTop *pcEncTopBase = (TEncTop *)getLayerEnc( m_layerId-1 ); 537 #endif 538 if(m_iSourceWidth != pcEncTopBase->getSourceWidth() || m_iSourceHeight != pcEncTopBase->getSourceHeight() ) 539 { 540 rpcPic->setSpatialEnhLayerFlag( true ); 555 TEncTop *pcEncTopBase = (TEncTop *)getLayerEnc( m_layerId-1 ); 556 #endif 557 if(m_iSourceWidth != pcEncTopBase->getSourceWidth() || m_iSourceHeight != pcEncTopBase->getSourceHeight() || !zeroOffsets ) 558 { 559 rpcPic->setSpatialEnhLayerFlag( i, true ); 560 561 //only for scalable extension 562 assert( m_cVPS.getScalabilityMask(1) == true ); 563 } 541 564 } 542 565 } … … 574 597 #endif 575 598 #if REF_IDX_MFM 599 #if !M0457_COL_PICTURE_SIGNALING 576 600 m_cSPS.setMFMEnabledFlag(m_bMFMEnabledFlag); 577 601 #endif 602 #endif 578 603 #if SCALED_REF_LAYER_OFFSETS 579 m_cSPS.getScaledRefLayerWindow() = m_scaledRefLayerWindow; 604 m_cSPS.setNumScaledRefLayerOffsets(m_numScaledRefLayerOffsets); 605 for(Int i = 0; i < m_cSPS.getNumScaledRefLayerOffsets(); i++) 606 { 607 m_cSPS.getScaledRefLayerWindow(i) = m_scaledRefLayerWindow[i]; 608 } 580 609 #endif 581 610 ProfileTierLevel& profileTierLevel = *m_cSPS.getPTL()->getGeneralPTL(); … … 584 613 profileTierLevel.setProfileIdc(m_profile); 585 614 profileTierLevel.setProfileCompatibilityFlag(m_profile, 1); 586 #if L0046_CONSTRAINT_FLAGS587 615 profileTierLevel.setProgressiveSourceFlag(m_progressiveSourceFlag); 588 616 profileTierLevel.setInterlacedSourceFlag(m_interlacedSourceFlag); 589 617 profileTierLevel.setNonPackedConstraintFlag(m_nonPackedConstraintFlag); 590 618 profileTierLevel.setFrameOnlyConstraintFlag(m_frameOnlyConstraintFlag); 591 #endif592 619 593 620 if (m_profile == Profile::MAIN10 && g_bitDepthY == 8 && g_bitDepthC == 8) … … 639 666 640 667 m_cSPS.setMaxTrSize ( 1 << m_uiQuadtreeTULog2MaxSize ); 641 #if !L0034_COMBINED_LIST_CLEANUP642 m_cSPS.setUseLComb ( m_bUseLComb );643 #endif644 668 645 669 Int i; … … 706 730 pcVUI->setFieldSeqFlag(false); 707 731 pcVUI->setHrdParametersPresentFlag(false); 708 #if L0043_TIMING_INFO709 732 pcVUI->getTimingInfo()->setPocProportionalToTimingFlag(getPocProportionalToTimingFlag()); 710 733 pcVUI->getTimingInfo()->setNumTicksPocDiffOneMinus1 (getNumTicksPocDiffOneMinus1() ); 711 #else712 pcVUI->setPocProportionalToTimingFlag(getPocProportionalToTimingFlag());713 pcVUI->setNumTicksPocDiffOneMinus1 (getNumTicksPocDiffOneMinus1() );714 #endif715 734 pcVUI->setBitstreamRestrictionFlag(getBitstreamRestrictionFlag()); 716 735 pcVUI->setTilesFixedStructureFlag(getTilesFixedStructureFlag()); … … 785 804 m_cPPS.setOutputFlagPresentFlag( false ); 786 805 m_cPPS.setSignHideFlag(getSignHideFlag()); 787 #if L0386_DB_METRIC788 806 if ( getDeblockingFilterMetric() ) 789 807 { … … 798 816 m_cPPS.setDeblockingFilterControlPresentFlag (m_DeblockingFilterControlPresent ); 799 817 } 800 #else801 m_cPPS.setDeblockingFilterControlPresentFlag (m_DeblockingFilterControlPresent );802 #endif803 818 m_cPPS.setLog2ParallelMergeLevelMinus2 (m_log2ParallelMergeLevelMinus2 ); 804 819 m_cPPS.setCabacInitPresentFlag(CABAC_INIT_PRESENT_FLAG); … … 824 839 } 825 840 } 826 #if L0323_LIMIT_DEFAULT_LIST_SIZE827 841 assert(bestPos <= 15); 828 #endif829 842 m_cPPS.setNumRefIdxL0DefaultActive(bestPos); 830 843 m_cPPS.setNumRefIdxL1DefaultActive(bestPos); … … 1073 1086 } 1074 1087 1075 #if L0208_SOP_DESCRIPTION_SEI1076 1088 Int TEncTop::getReferencePictureSetIdxForSOP(TComSlice* slice, Int POCCurr, Int GOPid ) 1077 1089 { … … 1103 1115 return rpsIdx; 1104 1116 } 1105 #endif1106 1117 1107 1118 Void TEncTop::xInitPPSforTiles() … … 1188 1199 1189 1200 #if SVC_EXTENSION 1190 #if VPS_EXTN_DIRECT_REF_LAYERS _CONTINUE1191 TEncTop* TEncTop::getRefLayerEnc( UInt layerId)1201 #if VPS_EXTN_DIRECT_REF_LAYERS 1202 TEncTop* TEncTop::getRefLayerEnc( UInt refLayerIdc ) 1192 1203 { 1193 1204 if( m_ppcTEncTop[m_layerId]->getNumDirectRefLayers() <= 0 ) … … 1200 1211 } 1201 1212 1202 // currently only one reference layer is supported 1203 assert( m_ppcTEncTop[m_layerId]->getNumDirectRefLayers() == 1 ); 1204 1205 return (TEncTop *)getLayerEnc( getVPS()->getRefLayerId( m_layerId, 0 ) ); 1213 return (TEncTop *)getLayerEnc( m_cVPS.getRefLayerId( m_layerId, refLayerIdc ) ); 1206 1214 } 1207 1215 #endif … … 1225 1233 if (m_cIlpPic[0] == NULL) 1226 1234 { 1227 for (Int j=0; j <1/*MAX_NUM_REF*/; j++)1235 for (Int j=0; j < MAX_LAYERS /*MAX_NUM_REF*/; j++) // consider to set to NumDirectRefLayers[LayerIdInVps[nuh_layer_id]] 1228 1236 { 1229 1237 m_cIlpPic[j] = new TComPic; … … 1244 1252 Void TEncTop::setILRPic(TComPic *pcPic) 1245 1253 { 1246 if(m_cIlpPic[0]) 1247 { 1248 m_cIlpPic[0]->copyUpsampledPictureYuv(pcPic->getFullPelBaseRec(), m_cIlpPic[0]->getPicYuvRec()); 1249 m_cIlpPic[0]->getSlice(0)->setPOC(pcPic->getPOC()); 1250 m_cIlpPic[0]->setLayerId(pcPic->getSlice(0)->getBaseColPic()->getLayerId()); //set reference layerId 1251 m_cIlpPic[0]->getPicYuvRec()->setBorderExtension(false); 1252 m_cIlpPic[0]->getPicYuvRec()->extendPicBorder(); 1254 for( Int i = 0; i < pcPic->getSlice(0)->getActiveNumILRRefIdx(); i++ ) 1255 { 1256 Int refLayerIdc = pcPic->getSlice(0)->getInterLayerPredLayerIdc(i); 1257 1258 if(m_cIlpPic[refLayerIdc]) 1259 { 1260 m_cIlpPic[refLayerIdc]->copyUpsampledPictureYuv(pcPic->getFullPelBaseRec(refLayerIdc), m_cIlpPic[refLayerIdc]->getPicYuvRec()); 1261 m_cIlpPic[refLayerIdc]->getSlice(0)->setPOC(pcPic->getPOC()); 1262 m_cIlpPic[refLayerIdc]->setLayerId(pcPic->getSlice(0)->getBaseColPic(refLayerIdc)->getLayerId()); //set reference layerId 1263 m_cIlpPic[refLayerIdc]->getPicYuvRec()->setBorderExtension(false); 1264 m_cIlpPic[refLayerIdc]->getPicYuvRec()->extendPicBorder(); 1265 } 1253 1266 } 1254 1267 } -
trunk/source/Lib/TLibEncoder/TEncTop.h
r191 r310 139 139 Bool m_bMFMEnabledFlag; 140 140 #endif 141 #if M0457_IL_SAMPLE_PRED_ONLY_FLAG 142 Int m_ilSampleOnlyPred; 143 #endif 141 144 #if SCALED_REF_LAYER_OFFSETS 142 Window m_scaledRefLayerWindow; 145 UInt m_numScaledRefLayerOffsets; 146 Window m_scaledRefLayerWindow[MAX_LAYERS]; 143 147 #endif 144 148 protected: … … 195 199 TComPPS* getPPS () { return &m_cPPS; } 196 200 Void selectReferencePictureSet(TComSlice* slice, Int POCCurr, Int GOPid ); 197 #if L0208_SOP_DESCRIPTION_SEI198 201 Int getReferencePictureSetIdxForSOP(TComSlice* slice, Int POCCurr, Int GOPid ); 199 #endif200 202 TComScalingList* getScalingList () { return &m_scalingList; } 201 203 #if SVC_EXTENSION … … 207 209 #endif 208 210 #if SCALED_REF_LAYER_OFFSETS 209 Window& getScaledRefLayerWindow() { return m_scaledRefLayerWindow; } 211 Void setNumScaledRefLayerOffsets(Int x) { m_numScaledRefLayerOffsets = x; } 212 UInt getNumScaledRefLayerOffsets() { return m_numScaledRefLayerOffsets; } 213 Window& getScaledRefLayerWindow(Int x) { return m_scaledRefLayerWindow[x]; } 210 214 #endif 211 215 … … 224 228 Bool getMFMEnabledFlag() {return m_bMFMEnabledFlag;} 225 229 #endif 230 #if M0457_IL_SAMPLE_PRED_ONLY_FLAG 231 Void setIlSampleOnlyPred( Int i ) { m_ilSampleOnlyPred = i; } 232 Int getIlSampleOnlyPred() { return m_ilSampleOnlyPred; } 233 #endif 226 234 #if AVC_SYNTAX 227 235 Void setBLSyntaxFile( fstream* pFile ) { m_pBLSyntaxFile = pFile; } … … 230 238 Void encode( TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsOut, Int iPicIdInGOP ); 231 239 Void encodePrep( TComPicYuv* pcPicYuvOrg ); 232 #if VPS_EXTN_DIRECT_REF_LAYERS _CONTINUE233 TEncTop* getRefLayerEnc(UInt layerId);240 #if VPS_EXTN_DIRECT_REF_LAYERS 241 TEncTop* getRefLayerEnc(UInt refLayerIdc); 234 242 #endif 235 243 #else
Note: See TracChangeset for help on using the changeset viewer.