Changeset 655 in 3DVCSoftware for trunk/source/Lib/TLibEncoder
- Timestamp:
- 23 Oct 2013, 23:01:30 (11 years ago)
- Location:
- trunk/source/Lib/TLibEncoder
- Files:
-
- 21 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/source/Lib/TLibEncoder/TEncAnalyze.cpp
r608 r655 52 52 TEncAnalyze m_gcAnalyzeP; 53 53 TEncAnalyze m_gcAnalyzeB; 54 55 TEncAnalyze m_gcAnalyzeAll_in; 54 56 #endif 55 57 -
trunk/source/Lib/TLibEncoder/TEncAnalyze.h
r608 r655 116 116 } 117 117 118 Void printOutInterlaced ( Char cDelim, Double bits ) 119 { 120 Double dFps = m_dFrmRate; //--CFG_KDY 121 Double dScale = dFps / 1000 / (Double)m_uiNumPic; 122 123 printf( "\tTotal Frames | " "Bitrate " "Y-PSNR " "U-PSNR " "V-PSNR \n" ); 124 //printf( "\t------------ " " ----------" " -------- " " -------- " " --------\n" ); 125 printf( "\t %8d %c" "%12.4lf " "%8.4lf " "%8.4lf " "%8.4lf\n", 126 getNumPic(), cDelim, 127 bits * dScale, 128 getPsnrY() / (Double)getNumPic(), 129 getPsnrU() / (Double)getNumPic(), 130 getPsnrV() / (Double)getNumPic() ); 131 } 132 133 Void printSummaryOutInterlaced (Int bits) 134 { 135 FILE* pFile = fopen ("summaryTotal.txt", "at"); 136 Double dFps = m_dFrmRate; //--CFG_KDY 137 Double dScale = dFps / 1000 / (Double)m_uiNumPic; 138 139 fprintf(pFile, "%f\t %f\t %f\t %f\n", bits * dScale, 140 getPsnrY() / (Double)getNumPic(), 141 getPsnrU() / (Double)getNumPic(), 142 getPsnrV() / (Double)getNumPic() ); 143 fclose(pFile); 144 } 145 146 118 147 Void printSummary(Char ch) 119 148 { … … 155 184 extern TEncAnalyze m_gcAnalyzeP; 156 185 extern TEncAnalyze m_gcAnalyzeB; 186 187 extern TEncAnalyze m_gcAnalyzeAll_in; 157 188 #endif 158 189 -
trunk/source/Lib/TLibEncoder/TEncCavlc.cpp
r622 r655 229 229 } 230 230 } 231 #if H_MV5232 231 #if H_MV 233 232 if ( pcPPS->getLayerId() > 0 ) … … 243 242 { 244 243 #endif 245 #endif246 244 WRITE_FLAG( pcPPS->getScalingListPresentFlag() ? 1 : 0, "pps_scaling_list_data_present_flag" ); 247 245 if( pcPPS->getScalingListPresentFlag() ) … … 252 250 codeScalingList( m_pcSlice->getScalingList() ); 253 251 } 254 #if H_MV5255 252 #if H_MV 256 253 } 257 #endif258 254 #endif 259 255 WRITE_FLAG( pcPPS->getListsModificationPresentFlag(), "lists_modification_present_flag"); … … 339 335 { 340 336 WRITE_FLAG(pcVUI->getTilesFixedStructureFlag(), "tiles_fixed_structure_flag"); 341 #if !H_MV5342 #if H_MV343 if ( pcSPS->getLayerId() > 0 )344 {345 WRITE_FLAG( pcVUI->getTileBoundariesAlignedFlag( ) ? 1 : 0 , "tile_boundaries_aligned_flag" );346 }347 #endif348 #endif349 337 WRITE_FLAG(pcVUI->getMotionVectorsOverPicBoundariesFlag(), "motion_vectors_over_pic_boundaries_flag"); 350 338 WRITE_FLAG(pcVUI->getRestrictedRefPicListsFlag(), "restricted_ref_pic_lists_flag"); … … 451 439 #endif 452 440 WRITE_UVLC( pcSPS->getSPSId (), "sps_seq_parameter_set_id" ); 453 #if H_MV5454 441 #if H_MV 455 442 if ( pcSPS->getLayerId() > 0 ) … … 460 447 if ( pcSPS->getUpdateRepFormatFlag() ) 461 448 { 462 #endif463 449 #endif 464 450 WRITE_UVLC( pcSPS->getChromaFormatIdc (), "chroma_format_idc" ); … … 472 458 WRITE_UVLC( pcSPS->getPicWidthInLumaSamples (), "pic_width_in_luma_samples" ); 473 459 WRITE_UVLC( pcSPS->getPicHeightInLumaSamples(), "pic_height_in_luma_samples" ); 474 #if H_MV5475 460 #if H_MV 476 461 } 477 #endif478 462 #endif 479 463 Window conf = pcSPS->getConformanceWindow(); … … 487 471 WRITE_UVLC( conf.getWindowBottomOffset() / TComSPS::getWinUnitY(pcSPS->getChromaFormatIdc() ), "conf_win_bottom_offset" ); 488 472 } 489 #if H_MV5490 473 #if H_MV 491 474 if ( pcSPS->getUpdateRepFormatFlag() ) 492 475 { 493 476 #endif 494 #endif495 477 WRITE_UVLC( pcSPS->getBitDepthY() - 8, "bit_depth_luma_minus8" ); 496 478 WRITE_UVLC( pcSPS->getBitDepthC() - 8, "bit_depth_chroma_minus8" ); 497 #if H_MV5498 479 #if H_MV 499 480 } 500 #endif501 481 #endif 502 482 WRITE_UVLC( pcSPS->getBitsForPOC()-4, "log2_max_pic_order_cnt_lsb_minus4" ); … … 525 505 if(pcSPS->getScalingListFlag()) 526 506 { 527 #if H_MV5528 507 #if H_MV 529 508 if ( pcSPS->getLayerId() > 0 ) … … 539 518 { 540 519 #endif 541 #endif542 520 WRITE_FLAG( pcSPS->getScalingListPresentFlag() ? 1 : 0, "sps_scaling_list_data_present_flag" ); 543 521 if(pcSPS->getScalingListPresentFlag()) … … 548 526 codeScalingList( m_pcSlice->getScalingList() ); 549 527 } 550 #if H_MV5551 528 #if H_MV 552 529 } 553 #endif554 530 #endif 555 531 } … … 598 574 } 599 575 600 #if !H_MV5601 #if H_MV602 WRITE_FLAG( 1, "sps_extension_flag" );603 WRITE_FLAG( pcSPS->getInterViewMvVertConstraintFlag() ? 1 : 0, "inter_view_mv_vert_constraint_flag" );604 //// sps_extension_vui_parameters( )605 if( pcSPS->getVuiParameters()->getBitstreamRestrictionFlag() )606 {607 WRITE_UVLC( pcSPS->getNumIlpRestrictedRefLayers( ), "num_ilp_restricted_ref_layers" );608 for( Int i = 0; i < pcSPS->getNumIlpRestrictedRefLayers( ); i++ )609 {610 WRITE_UVLC( pcSPS->getMinSpatialSegmentOffsetPlus1( i ), "min_spatial_segment_offset_plus1" );611 if( pcSPS->getMinSpatialSegmentOffsetPlus1( i ) > 0 )612 {613 WRITE_FLAG( pcSPS->getCtuBasedOffsetEnabledFlag( i ), "ctu_based_offset_enabled_flag[ i ]");614 if( pcSPS->getCtuBasedOffsetEnabledFlag( i ) )615 {616 WRITE_UVLC( pcSPS->getMinHorizontalCtuOffsetPlus1( i ), "min_horizontal_ctu_offset_plus1[ i ]");617 }618 }619 }620 }621 #if H_3D_QTLPC622 if( depthFlag )623 {624 WRITE_FLAG( pcSPS->getUseQTL() ? 1 : 0, "use_qtl_flag");625 WRITE_FLAG( pcSPS->getUsePC() ? 1 : 0, "use_pc_flag");626 }627 #endif628 //// sps_extension_vui_parameters( ) END629 WRITE_UVLC( 0, "sps_shvc_reserved_zero_idc" );630 #if !H_3D631 WRITE_FLAG( 0, "sps_extension2_flag" );632 #else633 WRITE_FLAG( 1, "sps_extension2_flag" );634 if (!depthFlag )635 {636 WRITE_UVLC( pcSPS->getCamParPrecision(), "cp_precision" );637 WRITE_FLAG( pcSPS->hasCamParInSliceHeader() ? 1 : 0, "cp_in_slice_header_flag" );638 if( !pcSPS->hasCamParInSliceHeader() )639 {640 for( UInt uiIndex = 0; uiIndex < viewIndex; uiIndex++ )641 {642 WRITE_SVLC( pcSPS->getCodedScale ()[ uiIndex ], "cp_scale" );643 WRITE_SVLC( pcSPS->getCodedOffset ()[ uiIndex ], "cp_off" );644 WRITE_SVLC( pcSPS->getInvCodedScale ()[ uiIndex ] + pcSPS->getCodedScale ()[ uiIndex ], "cp_inv_scale_plus_scale" );645 WRITE_SVLC( pcSPS->getInvCodedOffset()[ uiIndex ] + pcSPS->getCodedOffset()[ uiIndex ], "cp_inv_off_plus_off" );646 }647 }648 }649 650 WRITE_FLAG( 0, "sps_extension3_flag" );651 #endif652 #else653 WRITE_FLAG( 0, "sps_extension_flag" );654 #endif655 }656 #else657 576 #if !H_MV 658 577 WRITE_FLAG( 0, "sps_extension_flag" ); … … 706 625 } 707 626 #endif 708 #endif709 627 710 628 Void TEncCavlc::codeVPS( TComVPS* pcVPS ) … … 713 631 WRITE_CODE( 3, 2, "vps_reserved_three_2bits" ); 714 632 #if H_MV 715 #if H_MV5716 633 WRITE_CODE( pcVPS->getMaxLayersMinus1(), 6, "vps_max_layers_minus1" ); 717 #else718 WRITE_CODE( pcVPS->getMaxLayers() - 1, 6, "vps_max_layers_minus1" );719 #endif720 634 #else 721 635 WRITE_CODE( 0, 6, "vps_reserved_zero_6bits" ); … … 800 714 } 801 715 } 802 #if !H_MV5803 #if H_MV804 WRITE_FLAG( 1, "vps_extension_flag" );805 806 m_pcBitIf->writeAlignOne();807 808 WRITE_FLAG( pcVPS->getAvcBaseLayerFlag() ? 1 : 0, "avc_base_layer_flag" );809 WRITE_FLAG( pcVPS->getSplittingFlag() ? 1 : 0, "splitting_flag" );810 811 for( Int type = 0; type < MAX_NUM_SCALABILITY_TYPES; type++ )812 {813 WRITE_FLAG( pcVPS->getScalabilityMask( type ) ? 1 : 0, "scalability_mask[i]" );814 }815 816 for( Int sIdx = 0; sIdx < pcVPS->getNumScalabilityTypes( ) - ( pcVPS->getSplittingFlag() ? 1 : 0 ); sIdx++ )817 {818 WRITE_CODE( pcVPS->getDimensionIdLen( sIdx ) - 1 , 3, "dimension_id_len_minus1[j]");819 }820 821 if ( pcVPS->getSplittingFlag() )822 { // Ignore old dimension id length823 pcVPS->setDimensionIdLen( pcVPS->getNumScalabilityTypes( ) - 1 ,pcVPS->inferLastDimsionIdLenMinus1() + 1 );824 }825 826 827 WRITE_FLAG( pcVPS->getVpsNuhLayerIdPresentFlag() ? 1 : 0, "vps_nuh_layer_id_present_flag");828 829 for( Int i = 0; i <= pcVPS->getMaxLayers() - 1; i++ )830 {831 if ( pcVPS->getVpsNuhLayerIdPresentFlag() && ( i > 0 ) )832 {833 WRITE_CODE( pcVPS->getLayerIdInNuh( i ), 6, "layer_id_in_nuh[i]");834 }835 else836 {837 assert( pcVPS->getLayerIdInNuh( i ) == i );838 }839 840 assert( pcVPS->getLayerIdInVps( pcVPS->getLayerIdInNuh( i ) ) == i );841 842 for( Int j = 0; j < pcVPS->getNumScalabilityTypes() ; j++ )843 {844 if ( !pcVPS->getSplittingFlag() )845 {846 WRITE_CODE( pcVPS->getDimensionId( i, j ), pcVPS->getDimensionIdLen( j ), "dimension_id[i][j]");847 }848 else849 {850 assert( pcVPS->getDimensionId( i, j ) == pcVPS->inferDimensionId( i, j ) );851 }852 }853 }854 855 for( Int i = 1; i <= pcVPS->getMaxLayers() - 1; i++ )856 {857 for( Int j = 0; j < i; j++ )858 {859 WRITE_FLAG( pcVPS->getDirectDependencyFlag( i, j ), "direct_dependency_flag[i][j]" );860 }861 }862 863 for( Int i = 0; i < pcVPS->getMaxLayers() - 1; i++ )864 {865 WRITE_CODE( pcVPS->getMaxTidIlRefPicPlus1( i ), 3, "max_tid_il_ref_pics_plus1[i]" );866 }867 868 WRITE_CODE( pcVPS->getVpsNumberLayerSetsMinus1( ) , 10, "vps_number_layer_sets_minus1" );869 WRITE_CODE( pcVPS->getVpsNumProfileTierLevelMinus1( ), 6, "vps_num_profile_tier_level_minus1" );870 871 for( Int i = 1; i <= pcVPS->getVpsNumProfileTierLevelMinus1(); i++ )872 {873 WRITE_FLAG( pcVPS->getVpsProfilePresentFlag( i ) ? 1 : 0, "vps_profile_present_flag[i]" );874 if( !pcVPS->getVpsProfilePresentFlag( i ) )875 {876 WRITE_CODE( pcVPS->getProfileRefMinus1( i ), 6, "profile_ref_minus1[i]" );877 }878 codePTL( pcVPS->getPTL( i ), pcVPS->getVpsProfilePresentFlag( i ), pcVPS->getMaxTLayers() - 1 );879 }880 881 Int numOutputLayerSets = pcVPS->getVpsNumberLayerSetsMinus1( ) + 1;882 883 WRITE_FLAG( pcVPS->getMoreOutputLayerSetsThanDefaultFlag( ) ? 1 : 0, "more_output_layer_sets_than_default_flag" );884 885 if ( pcVPS->getMoreOutputLayerSetsThanDefaultFlag( ) )886 {887 WRITE_CODE( pcVPS->getNumAddOutputLayerSetsMinus1( ) , 10, "num_add_output_layer_sets_minus1" );888 numOutputLayerSets += ( pcVPS->getNumAddOutputLayerSetsMinus1( ) + 1 );889 }890 891 if( numOutputLayerSets > 1)892 {893 WRITE_FLAG( pcVPS->getDefaultOneTargetOutputLayerFlag( ) ? 1 : 0, "default_one_target_output_layer_flag" );894 }895 896 for( Int i = 1; i < numOutputLayerSets; i++ )897 {898 if( i > pcVPS->getVpsNumberLayerSetsMinus1( ) )899 {900 WRITE_UVLC( pcVPS->getOutputLayerSetIdxMinus1( i ), "output_layer_set_idx_minus1[i]" );901 for( Int j = 0; j < pcVPS->getNumLayersInIdList( j ) - 1 ; j++ )902 {903 WRITE_FLAG( pcVPS->getOutputLayerFlag( i, j) ? 1 : 0, "output_layer_flag" );904 }905 }906 if ( pcVPS->getProfileLevelTierIdxLen() > 0 )907 {908 WRITE_CODE( pcVPS->getProfileLevelTierIdx( i ), pcVPS->getProfileLevelTierIdxLen() ,"profile_level_tier_idx[ i ]" );909 }910 }911 912 WRITE_FLAG( pcVPS->getMaxOneActiveRefLayerFlag( ) ? 1 : 0, "max_one_active_ref_layer_flag" );913 WRITE_UVLC( pcVPS->getDirectDepTypeLenMinus2 ( ), "direct_dep_type_len_minus2");914 915 for( Int i = 1; i <= pcVPS->getMaxLayers() - 1; i++ )916 {917 for( Int j = 0; j < i; j++ )918 {919 if (pcVPS->getDirectDependencyFlag( i, j) )920 {921 assert ( pcVPS->getDirectDependencyType( i, j ) != -1 );922 WRITE_CODE( pcVPS->getDirectDependencyType( i, j ),pcVPS->getDirectDepTypeLenMinus2( ) + 2, "direct_dependency_type[i][j]" );923 }924 }925 }926 927 WRITE_FLAG ( 0, "vps_shvc_reserved_zero_flag" );928 929 #if H_3D930 WRITE_FLAG( 1, "vps_extension2_flag" );931 m_pcBitIf->writeAlignOne();932 for( Int i = 0; i <= pcVPS->getMaxLayers() - 1; i++ )933 {934 if (i!= 0)935 {936 if ( !( pcVPS->getDepthId( i ) == 1 ) )937 {938 #if H_3D_IV_MERGE939 WRITE_FLAG( pcVPS->getIvMvPredFlag ( i ) ? 1 : 0 , "iv_mv_pred_flag[i]");940 #endif941 #if H_3D_ARP942 WRITE_FLAG( pcVPS->getUseAdvRP ( i ) ? 1 : 0, "iv_res_pred_flag[i]" );943 #endif944 #if H_3D_NBDV_REF945 WRITE_FLAG( pcVPS->getDepthRefinementFlag ( i ) ? 1 : 0 , "depth_refinement_flag[i]");946 #endif947 #if H_3D_VSP948 WRITE_FLAG( pcVPS->getViewSynthesisPredFlag( i ) ? 1 : 0 , "view_synthesis_pred_flag[i]");949 #endif950 }951 else952 {953 WRITE_FLAG( pcVPS->getVpsDepthModesFlag( i ) ? 1 : 0 , "vps_depth_modes_flag[i]" );954 //WRITE_FLAG( pcVPS->getLimQtPredFlag ( i ) ? 1 : 0 , "lim_qt_pred_flag[i]" );955 #if H_3D_DIM_DLT956 if( pcVPS->getVpsDepthModesFlag( i ) )957 {958 WRITE_FLAG( pcVPS->getUseDLTFlag( i ) ? 1 : 0, "dlt_flag[i]" );959 }960 if( pcVPS->getUseDLTFlag( i ) )961 {962 // code mapping963 WRITE_UVLC(pcVPS->getNumDepthValues(i), "num_depth_values_in_dlt[i]");964 for(Int d=0; d<pcVPS->getNumDepthValues(i); d++)965 {966 WRITE_UVLC( pcVPS->idx2DepthValue(i, d), "dlt_depth_value[i][d]" );967 }968 }969 #endif970 #if LGE_INTER_SDC_E0156971 WRITE_FLAG( pcVPS->getInterSDCFlag( i ) ? 1 : 0, "depth_inter_SDC_flag" );972 #endif973 }974 }975 }976 WRITE_FLAG( pcVPS->getIvMvScalingFlag( ) ? 1 : 0 , "iv_mv_scaling_flag" );977 #else978 WRITE_FLAG( 0, "vps_extension2_flag" );979 #endif980 #else981 WRITE_FLAG( 0, "vps_extension_flag" );982 #endif983 984 //future extensions here..985 986 return;987 }988 #else989 716 #if H_MV 990 717 WRITE_FLAG( 1, "vps_extension_flag" ); … … 1003 730 #endif 1004 731 //future extensions here.. 1005 } 1006 1007 #endif 1008 1009 1010 #if H_MV5 732 733 return; 734 } 735 736 737 1011 738 #if H_MV 1012 739 Void TEncCavlc::codeVPSExtension( TComVPS *pcVPS ) … … 1309 1036 } 1310 1037 #endif 1311 #if LGE_INTER_SDC_E01561038 #if H_3D_INTER_SDC 1312 1039 WRITE_FLAG( pcVPS->getInterSDCFlag( i ) ? 1 : 0, "depth_inter_SDC_flag" ); 1313 1040 #endif … … 1319 1046 #endif 1320 1047 } 1321 #endif1322 1048 #endif 1323 1049 … … 1370 1096 { 1371 1097 #if H_MV 1372 #if H_MV51373 1098 Int esb = 0; //Don't use i, otherwise will shadow something below 1374 1099 if ( pcSlice->getPPS()->getNumExtraSliceHeaderBits() > esb ) … … 1385 1110 1386 1111 for (; esb < pcSlice->getPPS()->getNumExtraSliceHeaderBits(); esb++) 1387 #else1388 if ( pcSlice->getPPS()->getNumExtraSliceHeaderBits() > 0 )1389 {1390 WRITE_FLAG( pcSlice->getDiscardableFlag( ) ? 1 : 0 , "discardable_flag" );1391 }1392 1393 for (Int i = 1; i < pcSlice->getPPS()->getNumExtraSliceHeaderBits(); i++)1394 #endif1395 1112 #else 1396 1113 for (Int i = 0; i < pcSlice->getPPS()->getNumExtraSliceHeaderBits(); i++) … … 1415 1132 if( !pcSlice->getIdrPicFlag() ) 1416 1133 { 1417 Int picOrderCntLSB = (pcSlice->getPOC()-pcSlice->getLastIDR()+(1<<pcSlice->getSPS()->getBitsForPOC())) %(1<<pcSlice->getSPS()->getBitsForPOC());1134 Int picOrderCntLSB = (pcSlice->getPOC()-pcSlice->getLastIDR()+(1<<pcSlice->getSPS()->getBitsForPOC())) & ((1<<pcSlice->getSPS()->getBitsForPOC())-1); 1418 1135 WRITE_CODE( picOrderCntLSB, pcSlice->getSPS()->getBitsForPOC(), "pic_order_cnt_lsb"); 1419 1136 TComReferencePictureSet* rps = pcSlice->getRPS(); … … 1530 1247 } 1531 1248 #if H_MV 1532 #if H_MV51533 1249 Int layerId = pcSlice->getLayerId(); 1534 1250 if( pcSlice->getLayerId() > 0 && !vps->getAllRefLayersActiveFlag() && vps->getNumDirectRefLayers( layerId ) > 0 ) … … 1550 1266 } 1551 1267 } 1552 #else1553 Int layerIdInVps = pcSlice->getLayerIdInVps();1554 if( pcSlice->getLayerId() > 0 && vps->getNumDirectRefLayers( layerIdInVps ) > 0 )1555 {1556 WRITE_FLAG( pcSlice->getInterLayerPredEnabledFlag( ) ? 1 : 0 , "inter_layer_pred_enabled_flag" );1557 if( pcSlice->getInterLayerPredEnabledFlag() && vps->getNumDirectRefLayers( layerIdInVps ) > 1 )1558 {1559 if( !vps->getMaxOneActiveRefLayerFlag())1560 {1561 WRITE_CODE( pcSlice->getNumInterLayerRefPicsMinus1( ), pcSlice->getNumInterLayerRefPicsMinus1Len( ), "num_inter_layer_ref_pics_minus1" );1562 }1563 for( Int i = 0; i < pcSlice->getNumActiveRefLayerPics(); i++ )1564 {1565 WRITE_CODE( pcSlice->getInterLayerPredLayerIdc( i ), pcSlice->getInterLayerPredLayerIdcLen( ), "inter_layer_pred_layer_idc" );1566 }1567 }1568 }1569 1570 if( vps->getNumSamplePredRefLayers( layerIdInVps ) > 0 && pcSlice->getNumActiveRefLayerPics() > 0 )1571 {1572 WRITE_FLAG( pcSlice->getInterLayerSamplePredOnlyFlag( ) ? 1 : 0 , "inter_layer_sample_pred_only_flag" );1573 }1574 1575 #endif1576 1268 #endif 1577 1269 if(pcSlice->getSPS()->getUseSAO()) … … 1678 1370 if ( pcSlice->getEnableTMVPFlag() ) 1679 1371 { 1680 #if !H_MV51681 #if H_MV1682 if( pcSlice->getLayerId() > 0 && pcSlice->getNumActiveMotionPredRefLayers() > 0 )1683 {1684 WRITE_FLAG( pcSlice->getAltCollocatedIndicationFlag( ) ? 1 : 0 , "alt_collocated_indication_flag" );1685 }1686 if( pcSlice->getAltCollocatedIndicationFlag() && pcSlice->getNumActiveMotionPredRefLayers() > 1 )1687 {1688 WRITE_UVLC( pcSlice->getCollocatedRefLayerIdx( ), "collocated_ref_layer_idx" );1689 }1690 else1691 {1692 #endif1693 #endif1694 1372 if ( pcSlice->getSliceType() == B_SLICE ) 1695 1373 { … … 1704 1382 } 1705 1383 } 1706 #if !H_MV51707 #if H_MV1708 }1709 #endif1710 #endif1711 1384 if ( (pcSlice->getPPS()->getUseWP() && pcSlice->getSliceType()==P_SLICE) || (pcSlice->getPPS()->getWPBiPred() && pcSlice->getSliceType()==B_SLICE) ) 1712 1385 { … … 2256 1929 { 2257 1930 // Bool state = true, state2 = false; 2258 Int lsb = ltrpPOC % (1<<pcSlice->getSPS()->getBitsForPOC());1931 Int lsb = ltrpPOC & ((1<<pcSlice->getSPS()->getBitsForPOC())-1); 2259 1932 for (Int k = 0; k < pcSlice->getSPS()->getNumLongTermRefPicSPS(); k++) 2260 1933 { … … 2282 1955 } 2283 1956 2284 #if LGE_INTER_SDC_E01561957 #if H_3D_INTER_SDC 2285 1958 Void TEncCavlc::codeInterSDCFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx ) 2286 1959 { -
trunk/source/Lib/TLibEncoder/TEncCavlc.h
r622 r655 84 84 UInt getCoeffCost () { return m_uiCoeffCost; } 85 85 Void codeVPS ( TComVPS* pcVPS ); 86 #if H_MV587 86 #if H_MV 88 87 Void codeVPSExtension ( TComVPS *pcVPS ); … … 90 89 Void codeVPSVUI ( TComVPS* pcVPS ); 91 90 #endif 92 #endif93 91 Void codeVUI ( TComVUI *pcVUI, TComSPS* pcSPS ); 94 #if H_MV595 92 #if H_MV 96 93 Void codeSPSExtension ( TComSPS* pcSPS ); 97 94 #endif 98 #endif99 95 #if H_3D 100 #if H_MV5101 96 Void codeVPSExtension2 ( TComVPS* pcVPS ); 102 97 Void codeSPSExtension2 ( TComSPS* pcSPS, Int viewIndex, Bool depthFlag ); 103 #endif104 98 Void codeSPS ( TComSPS* pcSPS, Int viewIndex, Bool depthFlag ); 105 99 #else … … 133 127 Void codeICFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx ); 134 128 #endif 135 #if LGE_INTER_SDC_E0156129 #if H_3D_INTER_SDC 136 130 Void codeInterSDCFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx ); 137 131 Void codeInterSDCResidualData ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiSegment ); -
trunk/source/Lib/TLibEncoder/TEncCfg.h
r622 r655 77 77 Int m_interLayerPredLayerIdc [MAX_NUM_REF_PICS]; 78 78 Int m_interViewRefPosL[2][MAX_NUM_REF_PICS]; 79 #if !H_MV580 Int m_collocatedRefLayerIdx;81 #endif82 79 #endif 83 80 GOPEntry() … … 97 94 #if H_MV 98 95 , m_numActiveRefLayerPics(0) 99 #if !H_MV5100 , m_collocatedRefLayerIdx(-1)101 #endif102 96 #endif 103 97 { … … 310 304 Int m_RCInitialQP; 311 305 Bool m_RCForceIntraQP; 306 307 #if KWU_RC_MADPRED_E0227 308 UInt m_depthMADPred; 309 #endif 310 #if KWU_RC_VIEWRC_E0227 311 Bool m_bViewWiseRateCtrl; 312 #endif 312 313 #else 313 314 Bool m_enableRateCtrl; ///< Flag for using rate control algorithm 314 315 Int m_targetBitrate; ///< target bitrate 315 316 Int m_numLCUInUnit; ///< Total number of LCUs in a frame should be divided by the NumLCUInUnit 317 318 #if KWU_RC_MADPRED_E0227 319 UInt m_depthMADPred; 320 #endif 321 #if KWU_RC_VIEWRC_E0227 322 Bool m_bViewWiseRateCtrl; 323 #endif 316 324 #endif 317 325 Bool m_TransquantBypassEnableFlag; ///< transquant_bypass_enable_flag setting in PPS. … … 361 369 Int m_layerIdInVps; 362 370 Int m_viewId; 363 #if H_MV5364 371 Int m_viewIndex; 365 #endif366 372 #endif 367 373 368 374 #if H_3D 369 #if !H_MV5370 Int m_viewIndex;371 #endif372 375 Bool m_isDepth; 373 376 … … 403 406 Bool m_bUseIC; 404 407 #endif 405 #if LGE_INTER_SDC_E0156408 #if H_3D_INTER_SDC 406 409 bool m_bInterSDC; 407 410 #endif … … 426 429 , m_layerIdInVps(-1) 427 430 , m_viewId(-1) 428 #if H_MV5429 431 , m_viewIndex(-1) 430 #endif431 432 #if H_3D 432 #if !H_MV5433 , m_viewIndex(-1)434 #endif435 433 , m_isDepth(false) 436 434 , m_bUseVSO(false) … … 465 463 Void setViewId ( Int viewId ) { m_viewId = viewId; } 466 464 Int getViewId () { return m_viewId; } 467 #if H_MV5468 465 Void setViewIndex ( Int viewIndex ) { m_viewIndex = viewIndex; } 469 466 Int getViewIndex () { return m_viewIndex; } 470 #endif471 467 #if H_3D 472 #if !H_MV5473 Void setViewIndex ( Int viewIndex ) { m_viewIndex = viewIndex; }474 Int getViewIndex () { return m_viewIndex; }475 #endif476 468 Void setIsDepth ( Bool isDepth ) { m_isDepth = isDepth; } 477 469 Bool getIsDepth () { return m_isDepth; } … … 514 506 Bool getUseIC () { return m_bUseIC; } 515 507 #endif 516 #if LGE_INTER_SDC_E0156508 #if H_3D_INTER_SDC 517 509 Void setInterSDCEnable ( Bool bVal ) { m_bInterSDC = bVal; } 518 510 Bool getInterSDCEnable () { return m_bInterSDC; } … … 826 818 Bool getForceIntraQP () { return m_RCForceIntraQP; } 827 819 Void setForceIntraQP ( Bool b ) { m_RCForceIntraQP = b; } 820 821 #if KWU_RC_MADPRED_E0227 822 UInt getUseDepthMADPred () { return m_depthMADPred; } 823 Void setUseDepthMADPred (UInt b) { m_depthMADPred = b; } 824 #endif 825 #if KWU_RC_VIEWRC_E0227 826 Bool getUseViewWiseRateCtrl () { return m_bViewWiseRateCtrl; } 827 Void setUseViewWiseRateCtrl (Bool b) { m_bViewWiseRateCtrl = b; } 828 #endif 828 829 #else 829 830 Bool getUseRateCtrl () { return m_enableRateCtrl; } … … 833 834 Int getNumLCUInUnit () { return m_numLCUInUnit; } 834 835 Void setNumLCUInUnit (Int numLCUs) { m_numLCUInUnit = numLCUs; } 836 837 #if KWU_RC_MADPRED_E0227 838 UInt getUseDepthMADPred () { return m_depthMADPred; } 839 Void setUseDepthMADPred (UInt b) { m_depthMADPred = b; } 840 #endif 841 #if KWU_RC_VIEWRC_E0227 842 Bool getUseViewWiseRateCtrl () { return m_bViewWiseRateCtrl; } 843 Void setUseViewWiseRateCtrl (Bool b) { m_bViewWiseRateCtrl = b; } 844 #endif 835 845 #endif 836 846 Bool getTransquantBypassEnableFlag() { return m_TransquantBypassEnableFlag; } -
trunk/source/Lib/TLibEncoder/TEncCu.cpp
r622 r655 103 103 104 104 m_bEncodeDQP = false; 105 #if RATE_CONTROL_LAMBDA_DOMAIN && !M0036_RC_IMPROVEMENT 105 #if RATE_CONTROL_LAMBDA_DOMAIN 106 #if !M0036_RC_IMPROVEMENT 106 107 m_LCUPredictionSAD = 0; 107 108 m_addSADDepth = 0; 108 109 m_temporalSAD = 0; 110 #endif 111 #if M0036_RC_IMPROVEMENT && KWU_RC_MADPRED_E0227 112 m_LCUPredictionSAD = 0; 113 m_addSADDepth = 0; 114 m_temporalSAD = 0; 115 m_spatialSAD = 0; 116 #endif 117 #endif 118 #if !RATE_CONTROL_LAMBDA_DOMAIN && KWU_RC_MADPRED_E0227 119 m_LCUPredictionSAD = 0; 120 m_addSADDepth = 0; 121 m_temporalSAD = 0; 122 m_spatialSAD = 0; 109 123 #endif 110 124 … … 256 270 m_ppcTempCU[0]->initCU( rpcCU->getPic(), rpcCU->getAddr() ); 257 271 258 #if RATE_CONTROL_LAMBDA_DOMAIN && !M0036_RC_IMPROVEMENT 272 #if RATE_CONTROL_LAMBDA_DOMAIN 273 #if !M0036_RC_IMPROVEMENT 259 274 m_addSADDepth = 0; 260 275 m_LCUPredictionSAD = 0; 261 276 m_temporalSAD = 0; 277 #endif 278 #if M0036_RC_IMPROVEMENT && KWU_RC_MADPRED_E0227 279 m_LCUPredictionSAD = 0; 280 m_addSADDepth = 0; 281 m_temporalSAD = 0; 282 m_spatialSAD = 0; 283 #endif 284 #endif 285 #if KWU_RC_MADPRED_E0227 286 m_LCUPredictionSAD = 0; 287 m_addSADDepth = 0; 288 m_temporalSAD = 0; 289 m_spatialSAD = 0; 262 290 #endif 263 291 … … 404 432 405 433 // variables for fast encoder decision 406 Bool bEarlySkip = false; 407 Bool bTrySplit = true; 408 Double fRD_Skip = MAX_DOUBLE; 434 #if H_3D_QTLPC 435 Bool bTrySplit = true; 436 Bool bTrySplitDQP = true; 437 #endif 409 438 410 439 // variable for Early CU determination … … 415 444 Bool earlyDetectionSkipMode = false; 416 445 417 Bool bTrySplitDQP = true;418 446 #if H_3D_VSP 419 447 DisInfo DvInfo; … … 425 453 #endif 426 454 #endif 427 static Double afCost[ MAX_CU_DEPTH ];428 static Int aiNum [ MAX_CU_DEPTH ];429 430 if ( rpcBestCU->getAddr() == 0 )431 {432 ::memset( afCost, 0, sizeof( afCost ) );433 ::memset( aiNum, 0, sizeof( aiNum ) );434 }435 436 455 Bool bBoundary = false; 437 456 UInt uiLPelX = rpcBestCU->getCUPelX(); … … 489 508 if(!bSliceEnd && !bSliceStart && bInsidePicture ) 490 509 { 491 #if MTK_FAST_TEXTURE_ENCODING_E0173510 #if H_3D_FAST_TEXTURE_ENCODING 492 511 Bool bIVFMerge = false; 493 512 Int iIVFMaxD = 0; … … 501 520 } 502 521 // variables for fast encoder decision 503 bEarlySkip = false; 522 #if H_3D_QTLPC 504 523 bTrySplit = true; 505 fRD_Skip = MAX_DOUBLE; 524 #endif 506 525 507 526 rpcTempCU->initEstData( uiDepth, iQP ); … … 560 579 } 561 580 } 562 #if MTK_FAST_TEXTURE_ENCODING_E0173581 #if H_3D_FAST_TEXTURE_ENCODING 563 582 if(rpcTempCU->getSlice()->getViewIndex() && !rpcTempCU->getSlice()->getIsDepth()) 564 583 { … … 584 603 rpcTempCU->setICFlagSubParts(bICFlag, 0, 0, uiDepth); 585 604 #endif 586 #if MTK_FAST_TEXTURE_ENCODING_E0173605 #if H_3D_FAST_TEXTURE_ENCODING 587 606 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2Nx2N, bFMD ); rpcTempCU->initEstData( uiDepth, iQP );//by Competition for inter_2Nx2N 588 607 #else … … 598 617 #endif 599 618 xCheckRDCostMerge2Nx2N( rpcBestCU, rpcTempCU, &earlyDetectionSkipMode );//by Merge for inter_2Nx2N 600 #if MTK_FAST_TEXTURE_ENCODING_E0173619 #if H_3D_FAST_TEXTURE_ENCODING 601 620 bFMD = bIVFMerge && rpcBestCU->isSkipped(0); 602 621 #endif … … 605 624 rpcTempCU->setDvInfoSubParts(DvInfo, 0, uiDepth); 606 625 #endif 607 // fast encoder decision for early skip608 if ( m_pcEncCfg->getUseFastEnc() )609 {610 Int iIdx = g_aucConvertToBit[ rpcBestCU->getWidth(0) ];611 if ( aiNum [ iIdx ] > 5 && fRD_Skip < EARLY_SKIP_THRES*afCost[ iIdx ]/aiNum[ iIdx ] )612 {613 bEarlySkip = true;614 bTrySplit = false;615 }616 }617 626 618 627 if(!m_pcEncCfg->getUseEarlySkipDetection()) 619 628 { 620 629 // 2Nx2N, NxN 621 if ( !bEarlySkip )622 {623 630 #if H_3D_IC 624 631 rpcTempCU->setICFlagSubParts(bICFlag, 0, 0, uiDepth); 625 632 #endif 626 #if MTK_FAST_TEXTURE_ENCODING_E0173633 #if H_3D_FAST_TEXTURE_ENCODING 627 634 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2Nx2N, bFMD ); rpcTempCU->initEstData( uiDepth, iQP ); 628 635 #else … … 636 643 doNotBlockPu = rpcBestCU->getQtRootCbf( 0 ) != 0; 637 644 } 638 }639 645 } 640 646 #if H_3D_IC … … 643 649 } 644 650 645 #if H_3D_QTLPC 651 #if H_3D_QTLPC 646 652 if(depthMapDetect && !bIntraSliceDetect && !rapPic && sps->getUseQTL()) 647 653 { 648 654 bTrySplitDQP = bTrySplit; 649 655 } 650 else651 {652 #endif653 if( (g_uiMaxCUWidth>>uiDepth) >= rpcTempCU->getSlice()->getPPS()->getMinCuDQPSize() )654 {655 if(iQP == iBaseQP)656 {657 bTrySplitDQP = bTrySplit;658 }659 }660 else661 {662 bTrySplitDQP = bTrySplit;663 }664 #if H_3D_QTLPC665 }666 656 #endif 667 657 if (isAddLowestQP && (iQP == lowestQP)) … … 678 668 } 679 669 #endif 670 #if RATE_CONTROL_LAMBDA_DOMAIN && M0036_RC_IMPROVEMENT && KWU_RC_MADPRED_E0227 671 if ( uiDepth <= m_addSADDepth ) 672 { 673 m_LCUPredictionSAD += m_temporalSAD; 674 m_addSADDepth = uiDepth; 675 } 676 #endif 677 #if !RATE_CONTROL_LAMBDA_DOMAIN && KWU_RC_MADPRED_E0227 678 if ( uiDepth <= m_addSADDepth ) 679 { 680 m_LCUPredictionSAD += m_temporalSAD; 681 m_addSADDepth = uiDepth; 682 } 683 #endif 684 #if !RATE_CONTROL_LAMBDA_DOMAIN && KWU_FIX_URQ 685 if(m_pcEncCfg->getUseRateCtrl()) 686 { 687 Int qp = m_pcRateCtrl->getUnitQP(); 688 iMinQP = Clip3( MIN_QP, MAX_QP, qp); 689 iMaxQP = Clip3( MIN_QP, MAX_QP, qp); 690 } 691 #endif 680 692 681 693 #if H_3D_DIM_ENC … … 700 712 { 701 713 // 2Nx2N, NxN 702 if ( !bEarlySkip )703 {704 714 if(!( (rpcBestCU->getWidth(0)==8) && (rpcBestCU->getHeight(0)==8) )) 705 715 { … … 710 720 ) 711 721 { 712 #if MTK_FAST_TEXTURE_ENCODING_E0173722 #if H_3D_FAST_TEXTURE_ENCODING 713 723 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_NxN, bFMD ); 714 724 #else … … 721 731 } 722 732 } 723 }724 733 725 734 // 2NxN, Nx2N … … 730 739 ) 731 740 { 732 #if MTK_FAST_TEXTURE_ENCODING_E0173741 #if H_3D_FAST_TEXTURE_ENCODING 733 742 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_Nx2N, bFMD ); 734 743 #else … … 750 759 ) 751 760 { 752 #if MTK_FAST_TEXTURE_ENCODING_E0173761 #if H_3D_FAST_TEXTURE_ENCODING 753 762 xCheckRDCostInter ( rpcBestCU, rpcTempCU, SIZE_2NxN, bFMD ); 754 763 #else … … 789 798 ) 790 799 { 791 #if MTK_FAST_TEXTURE_ENCODING_E0173800 #if H_3D_FAST_TEXTURE_ENCODING 792 801 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnU, bFMD ); 793 802 #else … … 809 818 ) 810 819 { 811 #if MTK_FAST_TEXTURE_ENCODING_E0173820 #if H_3D_FAST_TEXTURE_ENCODING 812 821 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnD, bFMD ); 813 822 #else … … 833 842 ) 834 843 { 835 #if MTK_FAST_TEXTURE_ENCODING_E0173844 #if H_3D_FAST_TEXTURE_ENCODING 836 845 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnU, bFMD, true ); 837 846 #else … … 853 862 ) 854 863 { 855 #if MTK_FAST_TEXTURE_ENCODING_E0173864 #if H_3D_FAST_TEXTURE_ENCODING 856 865 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2NxnD, bFMD, true ); 857 866 #else … … 879 888 ) 880 889 { 881 #if MTK_FAST_TEXTURE_ENCODING_E0173890 #if H_3D_FAST_TEXTURE_ENCODING 882 891 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nLx2N, bFMD ); 883 892 #else … … 899 908 ) 900 909 { 901 #if MTK_FAST_TEXTURE_ENCODING_E0173910 #if H_3D_FAST_TEXTURE_ENCODING 902 911 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nRx2N, bFMD ); 903 912 #else … … 919 928 ) 920 929 { 921 #if MTK_FAST_TEXTURE_ENCODING_E0173930 #if H_3D_FAST_TEXTURE_ENCODING 922 931 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nLx2N, bFMD, true ); 923 932 #else … … 939 948 ) 940 949 { 941 #if MTK_FAST_TEXTURE_ENCODING_E0173950 #if H_3D_FAST_TEXTURE_ENCODING 942 951 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_nRx2N, bFMD, true ); 943 952 #else … … 990 999 #endif 991 1000 } 992 #if MTK_FAST_TEXTURE_ENCODING_E01731001 #if H_3D_FAST_TEXTURE_ENCODING 993 1002 if(!bFMD) 994 1003 { 995 1004 #endif 996 1005 // do normal intra modes 997 #if H_3D_DIM_ENC 998 if ( !bEarlySkip || ( rpcBestCU->getSlice()->getIsDepth() && rpcBestCU->getSlice()->isIRAP() ) ) 999 #else 1000 if ( !bEarlySkip ) 1001 #endif 1002 { 1006 1003 1007 // speedup for inter frames 1004 1008 if( rpcBestCU->getSlice()->getSliceType() == I_SLICE || … … 1012 1016 { 1013 1017 xCheckRDCostIntra( rpcBestCU, rpcTempCU, SIZE_2Nx2N ); 1018 1019 #if RATE_CONTROL_LAMBDA_DOMAIN && !M0036_RC_IMPROVEMENT && KWU_RC_MADPRED_E0227 1020 if ( uiDepth <= m_addSADDepth ) 1021 { 1022 m_LCUPredictionSAD += m_spatialSAD; 1023 m_addSADDepth = uiDepth; 1024 } 1025 #endif 1026 #if RATE_CONTROL_LAMBDA_DOMAIN && M0036_RC_IMPROVEMENT && KWU_RC_MADPRED_E0227 1027 if ( uiDepth <= m_addSADDepth ) 1028 { 1029 m_LCUPredictionSAD += m_spatialSAD; 1030 m_addSADDepth = uiDepth; 1031 } 1032 #endif 1033 1034 #if !RATE_CONTROL_LAMBDA_DOMAIN && KWU_RC_MADPRED_E0227 1035 if ( uiDepth <= m_addSADDepth ) 1036 { 1037 m_LCUPredictionSAD += m_spatialSAD; 1038 m_addSADDepth = uiDepth; 1039 } 1040 #endif 1014 1041 rpcTempCU->initEstData( uiDepth, iQP ); 1015 1042 if( uiDepth == g_uiMaxCUDepth - g_uiAddCUDepth ) … … 1029 1056 } 1030 1057 } 1031 }1032 1033 1058 // test PCM 1034 1059 if(pcPic->getSlice(0)->getSPS()->getUsePCM() … … 1049 1074 } 1050 1075 } 1051 #if MTK_FAST_TEXTURE_ENCODING_E01731076 #if H_3D_FAST_TEXTURE_ENCODING 1052 1077 } 1053 1078 #endif … … 1074 1099 rpcBestCU->getTotalCost() = m_pcRdCost->calcRdCost( rpcBestCU->getTotalBits(), rpcBestCU->getTotalDistortion() ); 1075 1100 1076 // accumulate statistics for early skip1077 if ( m_pcEncCfg->getUseFastEnc() )1078 {1079 if ( rpcBestCU->isSkipped(0) )1080 {1081 Int iIdx = g_aucConvertToBit[ rpcBestCU->getWidth(0) ];1082 afCost[ iIdx ] += rpcBestCU->getTotalCost();1083 aiNum [ iIdx ] ++;1084 }1085 }1086 1087 1101 // Early CU determination 1088 1102 if( m_pcEncCfg->getUseEarlyCU() && rpcBestCU->isSkipped(0) ) … … 1094 1108 bSubBranch = true; 1095 1109 } 1096 #if MTK_FAST_TEXTURE_ENCODING_E01731110 #if H_3D_FAST_TEXTURE_ENCODING 1097 1111 if(rpcBestCU->getSlice()->getViewIndex() && !rpcBestCU->getSlice()->getIsDepth() && (uiDepth >=iIVFMaxD) && rpcBestCU->isSkipped(0)) 1098 1112 { … … 1168 1182 1169 1183 // further split 1184 #if H_3D_QTLPC 1170 1185 if( bSubBranch && bTrySplitDQP && uiDepth < g_uiMaxCUDepth - g_uiAddCUDepth ) 1186 #else 1187 if( bSubBranch && uiDepth < g_uiMaxCUDepth - g_uiAddCUDepth ) 1188 #endif 1171 1189 { 1172 1190 #if H_3D_VSO // M9 … … 1580 1598 m_pcEntropyCoder->encodeARPW( pcCU , uiAbsPartIdx ); 1581 1599 #endif 1582 #if LGE_INTER_SDC_E01561600 #if H_3D_INTER_SDC 1583 1601 m_pcEntropyCoder->encodeInterSDCFlag( pcCU, uiAbsPartIdx, false ); 1584 1602 #endif … … 1875 1893 1876 1894 rpcTempCU->setSkipFlagSubParts( rpcTempCU->getQtRootCbf(0) == 0, 0, uhDepth ); 1877 #if LGE_INTER_SDC_E01561895 #if H_3D_INTER_SDC 1878 1896 TComDataCU *rpcTempCUPre = rpcTempCU; 1879 1897 #endif … … 1881 1899 xCheckDQP( rpcTempCU ); 1882 1900 xCheckBestMode(rpcBestCU, rpcTempCU, uhDepth); 1883 #if LGE_INTER_SDC_E01561901 #if H_3D_INTER_SDC 1884 1902 if( rpcTempCU->getSlice()->getVPS()->getInterSDCFlag( rpcTempCU->getSlice()->getLayerIdInVps() ) && rpcTempCU->getSlice()->getIsDepth() && !uiNoResidual ) 1885 1903 { … … 1917 1935 if( m_pcEncCfg->getUseFastDecisionForMerge() && !bestIsSkip ) 1918 1936 { 1919 #if LGE_INTER_SDC_E01561937 #if H_3D_INTER_SDC 1920 1938 if( rpcTempCU->getSlice()->getVPS()->getInterSDCFlag( rpcTempCU->getSlice()->getLayerIdInVps() ) ) 1921 1939 { … … 1926 1944 #endif 1927 1945 bestIsSkip = rpcBestCU->getQtRootCbf(0) == 0; 1928 #if LGE_INTER_SDC_E01561946 #if H_3D_INTER_SDC 1929 1947 } 1930 1948 #endif … … 1971 1989 1972 1990 #if AMP_MRG 1973 #if MTK_FAST_TEXTURE_ENCODING_E01731991 #if H_3D_FAST_TEXTURE_ENCODING 1974 1992 Void TEncCu::xCheckRDCostInter( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, PartSize ePartSize, Bool bFMD, Bool bUseMRG) 1975 1993 #else … … 1980 1998 #endif 1981 1999 { 1982 #if MTK_FAST_TEXTURE_ENCODING_E01732000 #if H_3D_FAST_TEXTURE_ENCODING 1983 2001 if(!(bFMD && (ePartSize == SIZE_2Nx2N))) //have motion estimation or merge check 1984 2002 { … … 2057 2075 #if AMP_MRG 2058 2076 rpcTempCU->setMergeAMP (true); 2059 #if MTK_FAST_TEXTURE_ENCODING_E01732077 #if H_3D_FAST_TEXTURE_ENCODING 2060 2078 m_pcPredSearch->predInterSearch ( rpcTempCU, m_ppcOrigYuv[uhDepth], m_ppcPredYuvTemp[uhDepth], m_ppcResiYuvTemp[uhDepth], m_ppcRecoYuvTemp[uhDepth], bFMD, false, bUseMRG ); 2061 2079 #else … … 2102 2120 #endif 2103 2121 2104 #if RATE_CONTROL_LAMBDA_DOMAIN && !M0036_RC_IMPROVEMENT2122 #if RATE_CONTROL_LAMBDA_DOMAIN && (!M0036_RC_IMPROVEMENT || KWU_RC_MADPRED_E0227) 2105 2123 if ( m_pcEncCfg->getUseRateCtrl() && m_pcEncCfg->getLCULevelRC() && ePartSize == SIZE_2Nx2N && uhDepth <= m_addSADDepth ) 2106 2124 { … … 2111 2129 } 2112 2130 #endif 2131 #if !RATE_CONTROL_LAMBDA_DOMAIN && KWU_RC_MADPRED_E0227 2132 if ( m_pcEncCfg->getUseRateCtrl() && ePartSize == SIZE_2Nx2N && uhDepth <= m_addSADDepth ) 2133 { 2134 UInt SAD = m_pcRdCost->getSADPart( g_bitDepthY, m_ppcPredYuvTemp[uhDepth]->getLumaAddr(), m_ppcPredYuvTemp[uhDepth]->getStride(), 2135 m_ppcOrigYuv[uhDepth]->getLumaAddr(), m_ppcOrigYuv[uhDepth]->getStride(), 2136 rpcTempCU->getWidth(0), rpcTempCU->getHeight(0) ); 2137 m_temporalSAD = (Int)SAD; 2138 } 2139 #endif 2113 2140 2114 2141 m_pcPredSearch->encodeResAndCalcRdInterCU( rpcTempCU, m_ppcOrigYuv[uhDepth], m_ppcPredYuvTemp[uhDepth], m_ppcResiYuvTemp[uhDepth], m_ppcResiYuvBest[uhDepth], m_ppcRecoYuvTemp[uhDepth], false ); … … 2121 2148 #endif 2122 2149 rpcTempCU->getTotalCost() = m_pcRdCost->calcRdCost( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() ); 2123 #if LGE_INTER_SDC_E01562150 #if H_3D_INTER_SDC 2124 2151 TComDataCU *rpcTempCUPre = rpcTempCU; 2125 2152 #endif 2126 2153 xCheckDQP( rpcTempCU ); 2127 2154 xCheckBestMode(rpcBestCU, rpcTempCU, uhDepth); 2128 #if LGE_INTER_SDC_E01562155 #if H_3D_INTER_SDC 2129 2156 if( rpcTempCU->getSlice()->getVPS()->getInterSDCFlag( rpcTempCU->getSlice()->getLayerIdInVps() ) && rpcTempCU->getSlice()->getIsDepth() ) 2130 2157 { … … 2163 2190 } 2164 2191 #endif 2165 #if MTK_FAST_TEXTURE_ENCODING_E01732192 #if H_3D_FAST_TEXTURE_ENCODING 2166 2193 } 2167 2194 #endif … … 2235 2262 rpcTempCU->getTotalCost() = m_pcRdCost->calcRdCost( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() ); 2236 2263 2264 #if RATE_CONTROL_LAMBDA_DOMAIN && !M0036_RC_IMPROVEMENT && KWU_RC_MADPRED_E0227 2265 UChar uhDepth = rpcTempCU->getDepth( 0 ); 2266 if ( m_pcEncCfg->getUseRateCtrl() && m_pcEncCfg->getLCULevelRC() && eSize == SIZE_2Nx2N && uhDepth <= m_addSADDepth ) 2267 { 2268 UInt SAD = m_pcRdCost->getSADPart( g_bitDepthY, m_ppcPredYuvTemp[uhDepth]->getLumaAddr(), m_ppcPredYuvTemp[uhDepth]->getStride(), 2269 m_ppcOrigYuv[uhDepth]->getLumaAddr(), m_ppcOrigYuv[uhDepth]->getStride(), 2270 rpcTempCU->getWidth(0), rpcTempCU->getHeight(0) ); 2271 m_spatialSAD = (Int)SAD; 2272 } 2273 #endif 2274 #if RATE_CONTROL_LAMBDA_DOMAIN && M0036_RC_IMPROVEMENT && KWU_RC_MADPRED_E0227 2275 UChar uhDepth = rpcTempCU->getDepth( 0 ); 2276 if ( m_pcEncCfg->getUseRateCtrl() && m_pcEncCfg->getLCULevelRC() && eSize == SIZE_2Nx2N && uhDepth <= m_addSADDepth ) 2277 { 2278 UInt SAD = m_pcRdCost->getSADPart( g_bitDepthY, m_ppcPredYuvTemp[uhDepth]->getLumaAddr(), m_ppcPredYuvTemp[uhDepth]->getStride(), 2279 m_ppcOrigYuv[uhDepth]->getLumaAddr(), m_ppcOrigYuv[uhDepth]->getStride(), 2280 rpcTempCU->getWidth(0), rpcTempCU->getHeight(0) ); 2281 m_spatialSAD = (Int)SAD; 2282 } 2283 #endif 2284 #if !RATE_CONTROL_LAMBDA_DOMAIN && KWU_RC_MADPRED_E0227 2285 UChar uhDepth = rpcTempCU->getDepth( 0 ); 2286 if ( m_pcEncCfg->getUseRateCtrl() && eSize == SIZE_2Nx2N && uhDepth <= m_addSADDepth ) 2287 { 2288 UInt SAD = m_pcRdCost->getSADPart( g_bitDepthY, m_ppcPredYuvTemp[uhDepth]->getLumaAddr(), m_ppcPredYuvTemp[uhDepth]->getStride(), 2289 m_ppcOrigYuv[uhDepth]->getLumaAddr(), m_ppcOrigYuv[uhDepth]->getStride(), 2290 rpcTempCU->getWidth(0), rpcTempCU->getHeight(0) ); 2291 m_spatialSAD = (Int)SAD; 2292 } 2293 #endif 2237 2294 xCheckDQP( rpcTempCU ); 2238 2295 xCheckBestMode(rpcBestCU, rpcTempCU, uiDepth); -
trunk/source/Lib/TLibEncoder/TEncCu.h
r608 r655 102 102 Bool m_bUseSBACRD; 103 103 TEncRateCtrl* m_pcRateCtrl; 104 #if RATE_CONTROL_LAMBDA_DOMAIN && !M0036_RC_IMPROVEMENT 104 #if RATE_CONTROL_LAMBDA_DOMAIN 105 #if !M0036_RC_IMPROVEMENT 105 106 UInt m_LCUPredictionSAD; 106 107 Int m_addSADDepth; 107 108 Int m_temporalSAD; 108 109 #endif 110 #if M0036_RC_IMPROVEMENT && KWU_RC_MADPRED_E0227 111 UInt m_LCUPredictionSAD; 112 Int m_addSADDepth; 113 Int m_temporalSAD; 114 Int m_spatialSAD; 115 #endif 116 #endif 117 #if !RATE_CONTROL_LAMBDA_DOMAIN && KWU_RC_MADPRED_E0227 118 UInt m_LCUPredictionSAD; 119 Int m_addSADDepth; 120 Int m_temporalSAD; 121 Int m_spatialSAD; 122 #endif 123 109 124 public: 110 125 /// copy parameters from encoder class … … 124 139 125 140 Void setBitCounter ( TComBitCounter* pcBitCounter ) { m_pcBitCounter = pcBitCounter; } 126 #if RATE_CONTROL_LAMBDA_DOMAIN && !M0036_RC_IMPROVEMENT141 #if (RATE_CONTROL_LAMBDA_DOMAIN && !M0036_RC_IMPROVEMENT) || KWU_RC_MADPRED_E0227 127 142 UInt getLCUPredictionSAD() { return m_LCUPredictionSAD; } 128 143 #endif … … 145 160 146 161 #if AMP_MRG 147 #if MTK_FAST_TEXTURE_ENCODING_E0173162 #if H_3D_FAST_TEXTURE_ENCODING 148 163 Void xCheckRDCostInter ( TComDataCU*& rpcBestCU, TComDataCU*& rpcTempCU, PartSize ePartSize, Bool bFMD, Bool bUseMRG = false ) ; 149 164 #else -
trunk/source/Lib/TLibEncoder/TEncEntropy.cpp
r608 r655 662 662 #endif 663 663 664 #if LGE_INTER_SDC_E0156664 #if H_3D_INTER_SDC 665 665 if( pcCU->getInterSDCFlag( uiAbsPartIdx ) ) 666 666 { … … 824 824 } 825 825 826 #if LGE_INTER_SDC_E0156826 #if H_3D_INTER_SDC 827 827 Void TEncEntropy::encodeInterSDCFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD ) 828 828 { -
trunk/source/Lib/TLibEncoder/TEncEntropy.h
r608 r655 94 94 virtual Void codeICFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0; 95 95 #endif 96 #if LGE_INTER_SDC_E015696 #if H_3D_INTER_SDC 97 97 virtual Void codeInterSDCFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx ) = 0; 98 98 virtual Void codeInterSDCResidualData ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiSegment ) = 0; … … 185 185 Void encodeICFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false ); 186 186 #endif 187 #if LGE_INTER_SDC_E0156187 #if H_3D_INTER_SDC 188 188 Void encodeInterSDCFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD = false ); 189 189 Void encodeInterSDCResidualData( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool bRD ); -
trunk/source/Lib/TLibEncoder/TEncGOP.cpp
r622 r655 153 153 #endif 154 154 #endif 155 156 #if KWU_FIX_URQ 157 m_pcRateCtrl = pcTEncTop->getRateCtrl(); 158 #endif 155 159 } 156 160 … … 351 355 #endif 352 356 #if H_MV 353 Void TEncGOP::compressPicInGOP( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsInGOP, Int iGOPid )354 #else 355 Void TEncGOP::compressGOP( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsInGOP )357 Void TEncGOP::compressPicInGOP( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsInGOP, Int iGOPid, bool isField, bool isTff) 358 #else 359 Void TEncGOP::compressGOP( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsInGOP, bool isField, bool isTff) 356 360 #endif 357 361 { … … 367 371 368 372 #if !H_MV 369 xInitGOP( iPOCLast, iNumPicRcvd, rcListPic, rcListPicYuvRecOut ); 373 xInitGOP( iPOCLast, iNumPicRcvd, rcListPic, rcListPicYuvRecOut, isField ); 374 370 375 371 376 m_iNumPicCoded = 0; … … 439 444 440 445 /////////////////////////////////////////////////////////////////////////////////////////////////// Initial to start encoding 441 Int pocCurr = iPOCLast -iNumPicRcvd+ m_pcCfg->getGOPEntry(iGOPid).m_POC; 442 Int iTimeOffset = m_pcCfg->getGOPEntry(iGOPid).m_POC; 443 if(iPOCLast == 0) 446 Int iTimeOffset; 447 Int pocCurr; 448 449 if(iPOCLast == 0) //case first frame or first top field 444 450 { 445 451 pocCurr=0; 446 452 iTimeOffset = 1; 453 } 454 else if(iPOCLast == 1 && isField) //case first bottom field, just like the first frame, the poc computation is not right anymore, we set the right value 455 { 456 pocCurr = 1; 457 iTimeOffset = 1; 458 } 459 else 460 { 461 pocCurr = iPOCLast - iNumPicRcvd + m_pcCfg->getGOPEntry(iGOPid).m_POC - isField; 462 iTimeOffset = m_pcCfg->getGOPEntry(iGOPid).m_POC; 447 463 } 448 464 if(pocCurr>=m_pcCfg->getFramesToBeEncoded()) … … 463 479 accessUnitsInGOP.push_back(AccessUnit()); 464 480 AccessUnit& accessUnit = accessUnitsInGOP.back(); 465 xGetBuffer( rcListPic, rcListPicYuvRecOut, iNumPicRcvd, iTimeOffset, pcPic, pcPicYuvRecOut, pocCurr 481 xGetBuffer( rcListPic, rcListPicYuvRecOut, iNumPicRcvd, iTimeOffset, pcPic, pcPicYuvRecOut, pocCurr, isField); 466 482 467 483 // Slice data initialization … … 472 488 473 489 474 #if H_MV5475 490 #if H_MV 476 m_pcSliceEncoder->initEncSlice ( pcPic, iPOCLast, pocCurr, iNumPicRcvd, iGOPid, pcSlice, m_pcEncTop->getVPS(), m_pcEncTop->getSPS(), m_pcEncTop->getPPS(), getLayerId() ); 477 #else 478 m_pcSliceEncoder->initEncSlice ( pcPic, iPOCLast, pocCurr, iNumPicRcvd, iGOPid, pcSlice, m_pcEncTop->getSPS(), m_pcEncTop->getPPS() ); 479 #endif 480 #else 481 #if H_3D 482 m_pcSliceEncoder->initEncSlice ( pcPic, iPOCLast, pocCurr, iNumPicRcvd, iGOPid, pcSlice, m_pcEncTop->getVPS(), m_pcEncTop->getSPS(), m_pcEncTop->getPPS(), getLayerId() ); 483 #else 484 m_pcSliceEncoder->initEncSlice ( pcPic, iPOCLast, pocCurr, iNumPicRcvd, iGOPid, pcSlice, m_pcEncTop->getSPS(), m_pcEncTop->getPPS() ); 485 #endif 486 #endif 491 m_pcSliceEncoder->initEncSlice ( pcPic, iPOCLast, pocCurr, iNumPicRcvd, iGOPid, pcSlice, m_pcEncTop->getVPS(), m_pcEncTop->getSPS(), m_pcEncTop->getPPS(), getLayerId(), isField ); 492 #else 493 m_pcSliceEncoder->initEncSlice ( pcPic, iPOCLast, pocCurr, iNumPicRcvd, iGOPid, pcSlice, m_pcEncTop->getSPS(), m_pcEncTop->getPPS(), isField ); 494 #endif 495 496 //Set Frame/Field coding 497 pcSlice->getPic()->setField(isField); 498 487 499 pcSlice->setLastIDR(m_iLastIDR); 488 500 pcSlice->setSliceIdx(0); 489 501 #if H_MV 490 #if H_MV5491 502 pcSlice->setRefPicSetInterLayer ( &m_refPicSetInterLayer0, &m_refPicSetInterLayer1 ); 492 #else493 pcSlice->setRefPicSetInterLayer ( &m_refPicSetInterLayer );494 #endif495 503 pcPic ->setLayerId ( getLayerId() ); 496 504 pcPic ->setViewId ( getViewId() ); … … 508 516 pcSlice->setLFCrossSliceBoundaryFlag( pcSlice->getPPS()->getLoopFilterAcrossSlicesEnabledFlag() ); 509 517 pcSlice->setScalingList ( m_pcEncTop->getScalingList() ); 510 pcSlice->getScalingList()->setUseTransformSkip(m_pcEncTop->getPPS()->getUseTransformSkip());511 518 if(m_pcEncTop->getUseScalingListId() == SCALING_LIST_OFF) 512 519 { … … 562 569 if(pcSlice->getTemporalLayerNonReferenceFlag()) 563 570 { 564 if(pcSlice->getNalUnitType()==NAL_UNIT_CODED_SLICE_TRAIL_R) 571 if (pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_TRAIL_R && 572 !(m_iGopSize == 1 && pcSlice->getSliceType() == I_SLICE)) 573 // Add this condition to avoid POC issues with encoder_intra_main.cfg configuration (see #1127 in bug tracker) 565 574 { 566 575 pcSlice->setNalUnitType(NAL_UNIT_CODED_SLICE_TRAIL_N); … … 655 664 refPicListModification->setRefPicListModificationFlagL1(0); 656 665 #if H_MV 657 #if H_MV5658 666 if ( pcSlice->getPPS()->getNumExtraSliceHeaderBits() > 1 ) 659 667 { … … 699 707 xSetRefPicListModificationsMv( tempRefPicLists, pcSlice, iGOPid ); 700 708 #else 701 if ( pcSlice->getPPS()->getNumExtraSliceHeaderBits() > 0 )702 {703 pcSlice->setDiscardableFlag ( false );704 }705 706 TComVPS* vps = pcSlice->getVPS();707 Int layerIdInVps = vps ->getLayerIdInVps( getLayerId());708 Int numDirectRefLayers = vps ->getNumDirectRefLayers( layerIdInVps );709 GOPEntry gopEntry = m_pcCfg->getGOPEntry( (pcSlice->getRapPicFlag() && getLayerId() > 0) ? MAX_GOP : iGOPid );710 711 if ( getLayerId() > 0 && numDirectRefLayers > 0 )712 {713 pcSlice->setInterLayerPredEnabledFlag ( gopEntry.m_numActiveRefLayerPics > 0 );714 if ( pcSlice->getInterLayerPredEnabledFlag() && numDirectRefLayers > 1 )715 {716 if ( !vps->getMaxOneActiveRefLayerFlag() )717 {718 pcSlice->setNumInterLayerRefPicsMinus1( gopEntry.m_numActiveRefLayerPics - 1 );719 }720 for (Int i = 0; i < gopEntry.m_numActiveRefLayerPics; i++ )721 {722 pcSlice->setInterLayerPredLayerIdc( i, gopEntry.m_interLayerPredLayerIdc[ i ] );723 }724 }725 }726 assert( pcSlice->getNumActiveRefLayerPics() == gopEntry.m_numActiveRefLayerPics );727 728 if ( vps->getNumSamplePredRefLayers( layerIdInVps ) > 0 && pcSlice->getNumActiveRefLayerPics() > 0)729 {730 pcSlice->setInterLayerSamplePredOnlyFlag( gopEntry.m_numRefPics == 0 );731 }732 733 pcSlice->createAndApplyIvReferencePictureSet( m_ivPicLists, m_refPicSetInterLayer );734 pcSlice->setNumRefIdx(REF_PIC_LIST_0,min(gopEntry.m_numRefPicsActive,( pcSlice->getRPS()->getNumberOfPictures() + (Int) m_refPicSetInterLayer.size() ) ) );735 pcSlice->setNumRefIdx(REF_PIC_LIST_1,min(gopEntry.m_numRefPicsActive,( pcSlice->getRPS()->getNumberOfPictures() + (Int) m_refPicSetInterLayer.size() ) ) );736 737 xSetRefPicListModificationsMv( pcSlice, iGOPid );738 739 pcSlice->setActiveMotionPredRefLayers( );740 741 if ( getLayerId() > 0 && pcSlice->getNumActiveMotionPredRefLayers() > 0 && pcSlice->getEnableTMVPFlag() &&742 ( pcSlice->getSliceType() == B_SLICE || pcSlice->getSliceType() == P_SLICE ))743 {744 pcSlice->setAltCollocatedIndicationFlag( gopEntry.m_collocatedRefLayerIdx >= 0 );745 if ( pcSlice->getNumActiveRefLayerPics() && pcSlice->getNumActiveMotionPredRefLayers() > 0 )746 {747 pcSlice->setCollocatedRefLayerIdx( gopEntry.m_collocatedRefLayerIdx );748 }749 }750 751 #endif752 #else753 709 pcSlice->setNumRefIdx(REF_PIC_LIST_0,min(m_pcCfg->getGOPEntry(iGOPid).m_numRefPicsActive,pcSlice->getRPS()->getNumberOfPictures())); 754 710 pcSlice->setNumRefIdx(REF_PIC_LIST_1,min(m_pcCfg->getGOPEntry(iGOPid).m_numRefPicsActive,pcSlice->getRPS()->getNumberOfPictures())); … … 760 716 761 717 // Set reference list 762 #if H_MV5763 718 #if H_MV 764 719 pcSlice->setRefPicList( tempRefPicLists, usedAsLongTerm, numPocTotalCurr ); … … 782 737 } 783 738 } 784 #endif785 #else786 #if H_MV787 pcSlice->setRefPicList( rcListPic, m_refPicSetInterLayer );788 #if H_3D_ARP789 pcSlice->setARPStepNum();790 if(pcSlice->getARPStepNum() > 1)791 {792 for(Int iLayerId = 0; iLayerId < getLayerId(); iLayerId ++ )793 {794 Int iViewIdx = pcSlice->getVPS()->getViewIndex(iLayerId);795 Bool bIsDepth = ( pcSlice->getVPS()->getDepthId ( iLayerId ) == 1 );796 if( iViewIdx<getViewIndex() && !bIsDepth )797 {798 pcSlice->setBaseViewRefPicList( m_ivPicLists->getPicList( iLayerId ), iViewIdx );799 }800 }801 }802 #endif803 #else804 pcSlice->setRefPicList ( rcListPic );805 #endif806 739 #endif 807 740 #if H_3D … … 913 846 914 847 // SAIT_VSO_EST_A0033 848 #if H_3D_FCO 849 Bool flagRec; 850 flagRec = ((m_pcEncTop->getIvPicLists()->getPicYuv( pcSlice->getViewIndex(), false, pcSlice->getPOC(), true) == NULL) ? false: true); 851 pcRdCost->setVideoRecPicYuv( m_pcEncTop->getIvPicLists()->getPicYuv( pcSlice->getViewIndex(), false, pcSlice->getPOC(), flagRec ) ); 852 pcRdCost->setDepthPicYuv ( m_pcEncTop->getIvPicLists()->getPicYuv( pcSlice->getViewIndex(), true, pcSlice->getPOC(), false ) ); 853 #else 915 854 pcRdCost->setVideoRecPicYuv( m_pcEncTop->getIvPicLists()->getPicYuv( pcSlice->getViewIndex(), false , pcSlice->getPOC(), true ) ); 916 855 pcRdCost->setDepthPicYuv ( m_pcEncTop->getIvPicLists()->getPicYuv( pcSlice->getViewIndex(), true , pcSlice->getPOC(), false ) ); 856 #endif 917 857 918 858 // LGE_WVSO_A0119 … … 970 910 } 971 911 m_pcRateCtrl->initRCPic( frameLevel ); 912 913 #if KWU_RC_MADPRED_E0227 914 if(m_pcCfg->getLayerId() != 0) 915 { 916 m_pcRateCtrl->getRCPic()->setIVPic( m_pcEncTop->getEncTop()->getTEncTop(0)->getRateCtrl()->getRCPic() ); 917 } 918 #endif 919 972 920 estimatedBits = m_pcRateCtrl->getRCPic()->getTargetBits(); 973 921 … … 1014 962 else // normal case 1015 963 { 964 #if KWU_RC_MADPRED_E0227 965 if(m_pcRateCtrl->getLayerID() != 0) 966 { 967 list<TEncRCPic*> listPreviousPicture = m_pcRateCtrl->getPicList(); 968 lambda = m_pcRateCtrl->getRCPic()->estimatePicLambdaIV( listPreviousPicture, pcSlice->getPOC() ); 969 sliceQP = m_pcRateCtrl->getRCPic()->estimatePicQP( lambda, listPreviousPicture ); 970 } 971 else 972 { 973 #endif 1016 974 list<TEncRCPic*> listPreviousPicture = m_pcRateCtrl->getPicList(); 1017 975 #if RATE_CONTROL_INTRA … … 1021 979 #endif 1022 980 sliceQP = m_pcRateCtrl->getRCPic()->estimatePicQP( lambda, listPreviousPicture ); 981 #if KWU_RC_MADPRED_E0227 982 } 983 #endif 1023 984 } 1024 985 … … 1155 1116 pcPic->setNumDdvCandPics(pcPic->getDisCandRefPictures(iColPoc)); 1156 1117 } 1118 #endif 1157 1119 #if H_3D 1158 1120 pcSlice->setDepthToDisparityLUTs(); 1159 1121 1160 1122 #endif 1161 #endif 1162 #if MTK_NBDV_TN_FIX_E01721123 1124 #if H_3D_NBDV 1163 1125 if(pcSlice->getViewIndex() && !pcSlice->getIsDepth() && !pcSlice->isIntra()) //Notes from QC: this condition shall be changed once the configuration is completed, e.g. in pcSlice->getSPS()->getMultiviewMvPredMode() || ARP in prev. HTM. Remove this comment once it is done. 1164 1126 { 1165 1127 pcPic->checkTemporalIVRef(); 1166 1128 } 1167 #endif 1168 #if MTK_TEXTURE_MRGCAND_BUGFIX_E0182 1129 1169 1130 if(pcSlice->getIsDepth()) 1170 1131 { … … 1412 1373 } 1413 1374 } 1414 pictureTimingSEI.m_auCpbRemovalDelay = std::m ax<Int>(1, m_totalCoded - m_lastBPSEI); // Syntax element signalled as minus, hence the .1375 pictureTimingSEI.m_auCpbRemovalDelay = std::min<Int>(std::max<Int>(1, m_totalCoded - m_lastBPSEI), static_cast<Int>(pow(2, static_cast<double>(pcSlice->getSPS()->getVuiParameters()->getHrdParameters()->getCpbRemovalDelayLengthMinus1()+1)))); // Syntax element signalled as minus, hence the . 1415 1376 pictureTimingSEI.m_picDpbOutputDelay = pcSlice->getSPS()->getNumReorderPics(0) + pcSlice->getPOC() - m_totalCoded; 1416 1377 Int factor = pcSlice->getSPS()->getVuiParameters()->getHrdParameters()->getTickDivisorMinus2() + 2; … … 1862 1823 pcPic->destroyNonDBFilterInfo(); 1863 1824 } 1864 #if MTK_SONY_PROGRESSIVE_MV_COMPRESSION_E01701825 #if H_3D 1865 1826 pcPic->compressMotion(2); 1866 1827 #endif … … 1898 1859 digestStr = digestToString(sei_recon_picture_digest.digest, 4); 1899 1860 } 1900 #if H_MV _FIX_LID_PIC_HASH_SEI_T401861 #if H_MV 1901 1862 OutputNALUnit nalu(NAL_UNIT_SUFFIX_SEI, pcSlice->getTLayer(), getLayerId() ); 1902 1863 #else … … 1940 1901 xCalculateAddPSNR( pcPic, pcPic->getPicYuvRec(), accessUnit, dEncTime ); 1941 1902 1903 //In case of field coding, compute the interlaced PSNR for both fields 1904 if (isField && ((!pcPic->isTopField() && isTff) || (pcPic->isTopField() && !isTff))) 1905 { 1906 //get complementary top field 1907 TComPic* pcPicTop; 1908 TComList<TComPic*>::iterator iterPic = rcListPic.begin(); 1909 while ((*iterPic)->getPOC() != pcPic->getPOC()-1) 1910 { 1911 iterPic ++; 1912 } 1913 pcPicTop = *(iterPic); 1914 xCalculateInterlacedAddPSNR(pcPicTop, pcPic, pcPicTop->getPicYuvRec(), pcPic->getPicYuvRec(), accessUnit, dEncTime ); 1915 } 1916 1942 1917 if (digestStr) 1943 1918 { … … 2072 2047 OutputNALUnit nalu(NAL_UNIT_PREFIX_SEI, pcSlice->getTLayer()); 2073 2048 m_pcEntropyCoder->setEntropyCoder(m_pcCavlcCoder, pcSlice); 2049 pictureTimingSEI.m_picStruct = (isField && pcSlice->getPic()->isTopField())? 1 : isField? 2 : 0; 2074 2050 m_seiWriter.writeSEImessage(nalu.m_Bitstream, pictureTimingSEI, pcSlice->getSPS()); 2075 2051 writeRBSPTrailingBits(nalu.m_Bitstream); … … 2166 2142 pcPic->setReconMark ( true ); 2167 2143 #if H_MV 2168 #if H_MV52169 2144 TComSlice::markIvRefPicsAsShortTerm( m_refPicSetInterLayer0, m_refPicSetInterLayer1 ); 2170 #else2171 TComSlice::markIvRefPicsAsShortTerm( m_refPicSetInterLayer );2172 #endif2173 2145 std::vector<Int> temp; 2174 2146 TComSlice::markCurrPic( pcPic ); … … 2184 2156 delete[] pcSubstreamsOut; 2185 2157 } 2186 #if ! RATE_CONTROL_LAMBDA_DOMAIN2158 #if !KWU_FIX_URQ && !RATE_CONTROL_LAMBDA_DOMAIN 2187 2159 if(m_pcCfg->getUseRateCtrl()) 2188 2160 { … … 2196 2168 2197 2169 #if !H_MV 2198 assert ( m_iNumPicCoded == iNumPicRcvd);2170 assert ( (m_iNumPicCoded == iNumPicRcvd) || (isField && iPOCLast == 1) ); 2199 2171 #endif 2200 2172 } 2201 2173 2202 2174 #if !H_MV 2203 Void TEncGOP::printOutSummary(UInt uiNumAllPicCoded )2175 Void TEncGOP::printOutSummary(UInt uiNumAllPicCoded, bool isField) 2204 2176 { 2205 2177 assert (uiNumAllPicCoded == m_gcAnalyzeAll.getNumPic()); … … 2207 2179 2208 2180 //--CFG_KDY 2181 if(isField) 2182 { 2183 m_gcAnalyzeAll.setFrmRate( m_pcCfg->getFrameRate() * 2); 2184 m_gcAnalyzeI.setFrmRate( m_pcCfg->getFrameRate() * 2); 2185 m_gcAnalyzeP.setFrmRate( m_pcCfg->getFrameRate() * 2); 2186 m_gcAnalyzeB.setFrmRate( m_pcCfg->getFrameRate() * 2); 2187 } 2188 else 2189 { 2209 2190 m_gcAnalyzeAll.setFrmRate( m_pcCfg->getFrameRate() ); 2210 2191 m_gcAnalyzeI.setFrmRate( m_pcCfg->getFrameRate() ); 2211 2192 m_gcAnalyzeP.setFrmRate( m_pcCfg->getFrameRate() ); 2212 2193 m_gcAnalyzeB.setFrmRate( m_pcCfg->getFrameRate() ); 2194 } 2213 2195 2214 2196 //-- all … … 2233 2215 m_gcAnalyzeB.printSummary('B'); 2234 2216 #endif 2217 2218 if(isField) 2219 { 2220 //-- interlaced summary 2221 m_gcAnalyzeAll_in.setFrmRate( m_pcCfg->getFrameRate()); 2222 printf( "\n\nSUMMARY INTERLACED ---------------------------------------------\n" ); 2223 m_gcAnalyzeAll_in.printOutInterlaced('a', m_gcAnalyzeAll.getBits()); 2224 2225 #if _SUMMARY_OUT_ 2226 m_gcAnalyzeAll_in.printSummaryOutInterlaced(); 2227 #endif 2228 } 2235 2229 2236 2230 printf("\nRVM: %.3lf\n" , xCalculateRVM()); … … 2276 2270 // Protected member functions 2277 2271 // ==================================================================================================================== 2272 2273 2274 Void TEncGOP::xInitGOP( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut, bool isField ) 2275 { 2276 assert( iNumPicRcvd > 0 ); 2277 // Exception for the first frames 2278 if ( ( isField && (iPOCLast == 0 || iPOCLast == 1) ) || (!isField && (iPOCLast == 0)) ) 2279 { 2280 m_iGopSize = 1; 2281 } 2282 else 2283 { 2284 m_iGopSize = m_pcCfg->getGOPSize(); 2285 } 2286 assert (m_iGopSize > 0); 2287 2288 return; 2289 } 2278 2290 2279 2291 Void TEncGOP::xInitGOP( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut ) … … 2299 2311 TComPic*& rpcPic, 2300 2312 TComPicYuv*& rpcPicYuvRecOut, 2301 Int pocCurr ) 2313 Int pocCurr, 2314 bool isField) 2302 2315 { 2303 2316 Int i; 2304 2317 // Rec. output 2305 2318 TComList<TComPicYuv*>::iterator iterPicYuvRec = rcListPicYuvRecOut.end(); 2306 for ( i = 0; i < iNumPicRcvd - iTimeOffset + 1; i++ ) 2319 2320 if (isField) 2321 { 2322 for ( i = 0; i < ( (pocCurr == 0 ) || (pocCurr == 1 ) ? (iNumPicRcvd - iTimeOffset + 1) : (iNumPicRcvd - iTimeOffset + 2) ); i++ ) 2323 { 2324 iterPicYuvRec--; 2325 } 2326 } 2327 else 2328 { 2329 for ( i = 0; i < (iNumPicRcvd - iTimeOffset + 1); i++ ) 2307 2330 { 2308 2331 iterPicYuvRec--; 2309 2332 } 2310 2333 2334 } 2335 2336 if (isField) 2337 { 2338 if(pocCurr == 1) 2339 { 2340 iterPicYuvRec++; 2341 } 2342 } 2311 2343 rpcPicYuvRecOut = *(iterPicYuvRec); 2312 2344 … … 2323 2355 iterPic++; 2324 2356 } 2325 2357 2358 #if !H_MV 2359 assert( rpcPic != NULL ); 2360 #endif 2326 2361 assert (rpcPic->getPOC() == pocCurr); 2327 2362 … … 2642 2677 } 2643 2678 2679 2680 Void reinterlace(Pel* top, Pel* bottom, Pel* dst, UInt stride, UInt width, UInt height, bool isTff) 2681 { 2682 2683 for (Int y = 0; y < height; y++) 2684 { 2685 for (Int x = 0; x < width; x++) 2686 { 2687 dst[x] = isTff ? (UChar) top[x] : (UChar) bottom[x]; 2688 dst[stride+x] = isTff ? (UChar) bottom[x] : (UChar) top[x]; 2689 } 2690 top += stride; 2691 bottom += stride; 2692 dst += stride*2; 2693 } 2694 } 2695 2696 2697 Void TEncGOP::xCalculateInterlacedAddPSNR( TComPic* pcPicOrgTop, TComPic* pcPicOrgBottom, TComPicYuv* pcPicRecTop, TComPicYuv* pcPicRecBottom, const AccessUnit& accessUnit, Double dEncTime ) 2698 { 2699 #if H_MV 2700 assert( 0 ); // Field coding and MV need to be aligned. 2701 #else 2702 Int x, y; 2703 2704 UInt64 uiSSDY_in = 0; 2705 UInt64 uiSSDU_in = 0; 2706 UInt64 uiSSDV_in = 0; 2707 2708 Double dYPSNR_in = 0.0; 2709 Double dUPSNR_in = 0.0; 2710 Double dVPSNR_in = 0.0; 2711 2712 /*------ INTERLACED PSNR -----------*/ 2713 2714 /* Luma */ 2715 2716 Pel* pOrgTop = pcPicOrgTop->getPicYuvOrg()->getLumaAddr(); 2717 Pel* pOrgBottom = pcPicOrgBottom->getPicYuvOrg()->getLumaAddr(); 2718 Pel* pRecTop = pcPicRecTop->getLumaAddr(); 2719 Pel* pRecBottom = pcPicRecBottom->getLumaAddr(); 2720 2721 Int iWidth; 2722 Int iHeight; 2723 Int iStride; 2724 2725 iWidth = pcPicOrgTop->getPicYuvOrg()->getWidth () - m_pcEncTop->getPad(0); 2726 iHeight = pcPicOrgTop->getPicYuvOrg()->getHeight() - m_pcEncTop->getPad(1); 2727 iStride = pcPicOrgTop->getPicYuvOrg()->getStride(); 2728 Int iSize = iWidth*iHeight; 2729 bool isTff = pcPicOrgTop->isTopField(); 2730 2731 TComPicYuv* pcOrgInterlaced = new TComPicYuv; 2732 pcOrgInterlaced->create( iWidth, iHeight << 1, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth ); 2733 2734 TComPicYuv* pcRecInterlaced = new TComPicYuv; 2735 pcRecInterlaced->create( iWidth, iHeight << 1, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth ); 2736 2737 Pel* pOrgInterlaced = pcOrgInterlaced->getLumaAddr(); 2738 Pel* pRecInterlaced = pcRecInterlaced->getLumaAddr(); 2739 2740 //=== Interlace fields ==== 2741 reinterlace(pOrgTop, pOrgBottom, pOrgInterlaced, iStride, iWidth, iHeight, isTff); 2742 reinterlace(pRecTop, pRecBottom, pRecInterlaced, iStride, iWidth, iHeight, isTff); 2743 2744 //===== calculate PSNR ===== 2745 for( y = 0; y < iHeight << 1; y++ ) 2746 { 2747 for( x = 0; x < iWidth; x++ ) 2748 { 2749 Int iDiff = (Int)( pOrgInterlaced[x] - pRecInterlaced[x] ); 2750 uiSSDY_in += iDiff * iDiff; 2751 } 2752 pOrgInterlaced += iStride; 2753 pRecInterlaced += iStride; 2754 } 2755 2756 /*Chroma*/ 2757 2758 iHeight >>= 1; 2759 iWidth >>= 1; 2760 iStride >>= 1; 2761 2762 pOrgTop = pcPicOrgTop->getPicYuvOrg()->getCbAddr(); 2763 pOrgBottom = pcPicOrgBottom->getPicYuvOrg()->getCbAddr(); 2764 pRecTop = pcPicRecTop->getCbAddr(); 2765 pRecBottom = pcPicRecBottom->getCbAddr(); 2766 pOrgInterlaced = pcOrgInterlaced->getCbAddr(); 2767 pRecInterlaced = pcRecInterlaced->getCbAddr(); 2768 2769 //=== Interlace fields ==== 2770 reinterlace(pOrgTop, pOrgBottom, pOrgInterlaced, iStride, iWidth, iHeight, isTff); 2771 reinterlace(pRecTop, pRecBottom, pRecInterlaced, iStride, iWidth, iHeight, isTff); 2772 2773 //===== calculate PSNR ===== 2774 for( y = 0; y < iHeight << 1; y++ ) 2775 { 2776 for( x = 0; x < iWidth; x++ ) 2777 { 2778 Int iDiff = (Int)( pOrgInterlaced[x] - pRecInterlaced[x] ); 2779 uiSSDU_in += iDiff * iDiff; 2780 } 2781 pOrgInterlaced += iStride; 2782 pRecInterlaced += iStride; 2783 } 2784 2785 pOrgTop = pcPicOrgTop->getPicYuvOrg()->getCrAddr(); 2786 pOrgBottom = pcPicOrgBottom->getPicYuvOrg()->getCrAddr(); 2787 pRecTop = pcPicRecTop->getCrAddr(); 2788 pRecBottom = pcPicRecBottom->getCrAddr(); 2789 pOrgInterlaced = pcOrgInterlaced->getCrAddr(); 2790 pRecInterlaced = pcRecInterlaced->getCrAddr(); 2791 2792 //=== Interlace fields ==== 2793 reinterlace(pOrgTop, pOrgBottom, pOrgInterlaced, iStride, iWidth, iHeight, isTff); 2794 reinterlace(pRecTop, pRecBottom, pRecInterlaced, iStride, iWidth, iHeight, isTff); 2795 2796 //===== calculate PSNR ===== 2797 for( y = 0; y < iHeight << 1; y++ ) 2798 { 2799 for( x = 0; x < iWidth; x++ ) 2800 { 2801 Int iDiff = (Int)( pOrgInterlaced[x] - pRecInterlaced[x] ); 2802 uiSSDV_in += iDiff * iDiff; 2803 } 2804 pOrgInterlaced += iStride; 2805 pRecInterlaced += iStride; 2806 } 2807 2808 Int maxvalY = 255 << (g_bitDepthY-8); 2809 Int maxvalC = 255 << (g_bitDepthC-8); 2810 Double fRefValueY = (Double) maxvalY * maxvalY * iSize*2; 2811 Double fRefValueC = (Double) maxvalC * maxvalC * iSize*2 / 4.0; 2812 dYPSNR_in = ( uiSSDY_in ? 10.0 * log10( fRefValueY / (Double)uiSSDY_in ) : 99.99 ); 2813 dUPSNR_in = ( uiSSDU_in ? 10.0 * log10( fRefValueC / (Double)uiSSDU_in ) : 99.99 ); 2814 dVPSNR_in = ( uiSSDV_in ? 10.0 * log10( fRefValueC / (Double)uiSSDV_in ) : 99.99 ); 2815 2816 /* calculate the size of the access unit, excluding: 2817 * - any AnnexB contributions (start_code_prefix, zero_byte, etc.,) 2818 * - SEI NAL units 2819 */ 2820 UInt numRBSPBytes = 0; 2821 for (AccessUnit::const_iterator it = accessUnit.begin(); it != accessUnit.end(); it++) 2822 { 2823 UInt numRBSPBytes_nal = UInt((*it)->m_nalUnitData.str().size()); 2824 2825 if ((*it)->m_nalUnitType != NAL_UNIT_PREFIX_SEI && (*it)->m_nalUnitType != NAL_UNIT_SUFFIX_SEI) 2826 numRBSPBytes += numRBSPBytes_nal; 2827 } 2828 2829 UInt uibits = numRBSPBytes * 8 ; 2830 2831 //===== add PSNR ===== 2832 m_gcAnalyzeAll_in.addResult (dYPSNR_in, dUPSNR_in, dVPSNR_in, (Double)uibits); 2833 2834 printf("\n Interlaced frame %d: [Y %6.4lf dB U %6.4lf dB V %6.4lf dB]", pcPicOrgBottom->getPOC()/2 , dYPSNR_in, dUPSNR_in, dVPSNR_in ); 2835 2836 pcOrgInterlaced->destroy(); 2837 delete pcOrgInterlaced; 2838 pcRecInterlaced->destroy(); 2839 delete pcRecInterlaced; 2840 #endif 2841 } 2644 2842 /** Function for deciding the nal_unit_type. 2645 2843 * \param pocCurr POC of the current picture … … 3002 3200 3003 3201 #if H_MV 3004 #if H_MV53005 3202 Void TEncGOP::xSetRefPicListModificationsMv( std::vector<TComPic*> tempPicLists[2], TComSlice* pcSlice, UInt iGOPid ) 3006 3203 { … … 3086 3283 } 3087 3284 } 3088 #else3089 Void TEncGOP::xSetRefPicListModificationsMv( TComSlice* pcSlice, UInt iGOPid )3090 {3091 Int layer = pcSlice->getLayerIdInVps( );3092 3093 if( pcSlice->getSliceType() == I_SLICE || !(pcSlice->getPPS()->getListsModificationPresentFlag()) || pcSlice->getNumActiveRefLayerPics() == 0 )3094 {3095 return;3096 }3097 3098 // analyze inter-view modifications3099 GOPEntry ge = m_pcCfg->getGOPEntry( (pcSlice->getRapPicFlag() && ( layer > 0) ) ? MAX_GOP : iGOPid );3100 assert( ge.m_numActiveRefLayerPics == pcSlice->getNumActiveRefLayerPics() );3101 3102 Int maxRefListSize = pcSlice->getNumRpsCurrTempList();3103 Int numTemporalRefs = maxRefListSize - pcSlice->getNumActiveRefLayerPics();3104 3105 for (Int li = 0; li < 2; li ++) // Loop over lists L0 and L13106 {3107 // set inter-view modifications3108 Int tempList[16];3109 for( Int k = 0; k < 16; k++ )3110 {3111 tempList[ k ] = -1;3112 }3113 3114 Bool isModified = false;3115 if ( maxRefListSize > 1 )3116 {3117 for( Int k = 0, orgIdx = numTemporalRefs; k < ge.m_numActiveRefLayerPics; k++, orgIdx++ )3118 {3119 Int targetIdx = ge.m_interViewRefPosL[ li ][ k ];3120 3121 isModified = ( targetIdx != orgIdx ) && ( targetIdx >= 0 );3122 if ( isModified )3123 {3124 assert( tempList[ targetIdx ] == -1 ); // Assert when two inter layer reference pictures are sorted to the same position3125 tempList[ targetIdx ] = orgIdx;3126 }3127 }3128 }3129 3130 TComRefPicListModification* refPicListModification = pcSlice->getRefPicListModification();3131 refPicListModification->setRefPicListModificationFlagL( li, isModified );3132 3133 if( isModified )3134 {3135 Int temporalRefIdx = 0;3136 for( Int i = 0; i < pcSlice->getNumRefIdx( ( li == 0 ) ? REF_PIC_LIST_0 : REF_PIC_LIST_1 ); i++ )3137 {3138 if( tempList[i] >= 0 )3139 {3140 refPicListModification->setRefPicSetIdxL( li, i, tempList[i] );3141 }3142 else3143 {3144 refPicListModification->setRefPicSetIdxL( li, i, temporalRefIdx );3145 temporalRefIdx++;3146 }3147 }3148 }3149 }3150 }3151 #endif3152 3285 #endif 3153 3286 //! \} -
trunk/source/Lib/TLibEncoder/TEncGOP.h
r622 r655 57 57 #include "TEncAnalyze.h" 58 58 #include "TEncRateCtrl.h" 59 #if KWU_RC_MADPRED_E0227 60 #include "../App/TAppEncoder/TAppEncTop.h" 61 #endif 59 62 #include <vector> 60 63 … … 99 102 #if H_MV 100 103 TComPicLists* m_ivPicLists; 101 #if H_MV5102 104 std::vector<TComPic*> m_refPicSetInterLayer0; 103 105 std::vector<TComPic*> m_refPicSetInterLayer1; 104 #else105 std::vector<TComPic*> m_refPicSetInterLayer;106 #endif107 106 108 107 Int m_pocLastCoded; … … 148 147 #if H_MV 149 148 Void initGOP ( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsInGOP); 150 Void compressPicInGOP ( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsInGOP, Int iGOPid );149 Void compressPicInGOP ( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsInGOP, Int iGOPid, Bool isField, Bool isTff ); 151 150 #else 152 Void compressGOP( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRec, std::list<AccessUnit>& accessUnitsInGOP );151 Void compressGOP( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRec, std::list<AccessUnit>& accessUnitsInGOP, Bool isField, Bool isTff ); 153 152 #endif 154 153 Void xAttachSliceDataToNalUnit (OutputNALUnit& rNalu, TComOutputBitstream*& rpcBitstreamRedirect); … … 169 168 170 169 #if !H_MV 171 Void printOutSummary ( UInt uiNumAllPicCoded );170 Void printOutSummary ( UInt uiNumAllPicCoded , bool isField); 172 171 #endif 173 172 #if H_3D_VSO … … 176 175 Void preLoopFilterPicAll ( TComPic* pcPic, UInt64& ruiDist, UInt64& ruiBits ); 177 176 #endif 178 177 178 #if KWU_RC_MADPRED_E0227 179 TEncTop* getEncTop() { return m_pcEncTop; } 180 #endif 181 179 182 TEncSlice* getSliceEncoder() { return m_pcSliceEncoder; } 180 183 NalUnitType getNalUnitType( Int pocCurr, Int lastIdr ); … … 184 187 185 188 protected: 189 Void xInitGOP( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut, bool isField ); 190 186 191 Void xInitGOP ( Int iPOC, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut ); 187 Void xGetBuffer ( TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut, Int iNumPicRcvd, Int iTimeOffset, TComPic*& rpcPic, TComPicYuv*& rpcPicYuvRecOut, Int pocCurr );192 Void xGetBuffer ( TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut, Int iNumPicRcvd, Int iTimeOffset, TComPic*& rpcPic, TComPicYuv*& rpcPicYuvRecOut, Int pocCurr, bool isField ); 188 193 189 194 Void xCalculateAddPSNR ( TComPic* pcPic, TComPicYuv* pcPicD, const AccessUnit&, Double dEncTime ); 195 Void xCalculateInterlacedAddPSNR( TComPic* pcPicOrgTop, TComPic* pcPicOrgBottom, TComPicYuv* pcPicRecTop, TComPicYuv* pcPicRecBottom, const AccessUnit& accessUnit, Double dEncTime ); 196 190 197 #if H_3D_VSO 191 198 Dist64 xFindDistortionFrame (TComPicYuv* pcPic0, TComPicYuv* pcPic1); … … 216 223 } 217 224 #if H_MV 218 #if H_MV5219 225 Void xSetRefPicListModificationsMv( std::vector<TComPic*> tempPicLists[2], TComSlice* pcSlice, UInt iGOPid ); 220 #else221 Void xSetRefPicListModificationsMv( TComSlice* pcSlice, UInt iGOPid );222 #endif223 226 #endif 224 227 Void dblMetric( TComPic* pcPic, UInt uiNumSlices ); -
trunk/source/Lib/TLibEncoder/TEncRateCtrl.cpp
r608 r655 537 537 m_lastPicture = NULL; 538 538 #endif 539 540 #if KWU_RC_MADPRED_E0227 541 m_lastIVPicture = NULL; 542 #endif 543 539 544 m_picActualHeaderBits = 0; 540 545 #if !M0036_RC_IMPROVEMENT … … 544 549 m_picQP = 0; 545 550 m_picLambda = 0.0; 551 552 #if KWU_RC_MADPRED_E0227 553 m_IVtotalMAD = 0.0; 554 #endif 546 555 } 547 556 … … 621 630 } 622 631 632 #if KWU_RC_MADPRED_E0227 633 Void TEncRCPic::addToPictureLsitIV( list<TEncRCPic*>& listPreviousPictures ) 634 { 635 m_lastIVPicture = NULL; 636 m_lastIVPicture = this; 637 } 638 639 Void TEncRCPic::setIVPic( TEncRCPic* BaseRCPic ) 640 { 641 m_lastIVPicture = BaseRCPic; 642 } 643 #endif 644 645 #if KWU_RC_MADPRED_E0227 646 Void TEncRCPic::create( TEncRCSeq* encRCSeq, TEncRCGOP* encRCGOP, Int frameLevel, list<TEncRCPic*>& listPreviousPictures, Int layerID ) 647 #else 623 648 Void TEncRCPic::create( TEncRCSeq* encRCSeq, TEncRCGOP* encRCGOP, Int frameLevel, list<TEncRCPic*>& listPreviousPictures ) 649 #endif 624 650 { 625 651 destroy(); … … 673 699 Int currHeight = ( (j == picHeightInLCU-1) ? picHeight - LCUHeight*(picHeightInLCU-1) : LCUHeight ); 674 700 m_LCUs[LCUIdx].m_numberOfPixel = currWidth * currHeight; 701 702 #if KWU_RC_MADPRED_E0227 703 m_LCUs[LCUIdx].m_CUWidth = currWidth; 704 m_LCUs[LCUIdx].m_CUHeight = currHeight; 705 m_LCUs[LCUIdx].m_IVMAD = -1.0; 706 #endif 675 707 } 676 708 } … … 683 715 m_picLambda = 0.0; 684 716 717 718 #if KWU_RC_MADPRED_E0227 719 m_LayerID = layerID; 720 m_lastIVPicture = NULL; 721 m_IVtotalMAD = 0.0; 722 #endif 723 724 685 725 #if !M0036_RC_IMPROVEMENT 686 726 m_lastPicture = NULL; 687 727 list<TEncRCPic*>::reverse_iterator it; 728 for ( it = listPreviousPictures.rbegin(); it != listPreviousPictures.rend(); it++ ) 729 { 730 if ( (*it)->getFrameLevel() == m_frameLevel ) 731 { 732 m_lastPicture = (*it); 733 break; 734 } 735 } 736 #endif 737 738 #if KWU_RC_MADPRED_E0227 739 list<TEncRCPic*>::reverse_iterator it; 740 if( m_LayerID != 0) 741 { 742 m_lastIVPicture = NULL; 743 for ( it = listPreviousPictures.rbegin(); it != listPreviousPictures.rend(); it++ ) 744 { 745 if ( (*it)->getLayerID() == 0 ) 746 { 747 m_lastIVPicture = (*it); 748 break; 749 } 750 } 751 } 752 753 m_lastPicture = NULL; 688 754 for ( it = listPreviousPictures.rbegin(); it != listPreviousPictures.rend(); it++ ) 689 755 { … … 856 922 } 857 923 924 925 #if KWU_RC_MADPRED_E0227 926 Double TEncRCPic::estimatePicLambdaIV( list<TEncRCPic*>& listPreviousPictures, Int CurPOC ) 927 { 928 Double alpha = m_encRCSeq->getPicPara( m_frameLevel ).m_alpha; 929 Double beta = m_encRCSeq->getPicPara( m_frameLevel ).m_beta; 930 Double bpp = (Double)m_targetBits/(Double)m_numberOfPixel; 931 Double estLambda = alpha * pow( bpp, beta ); 932 Double lastLevelLambda = -1.0; 933 Double lastPicLambda = -1.0; 934 Double lastValidLambda = -1.0; 935 list<TEncRCPic*>::iterator it; 936 937 if(listPreviousPictures.size() == 0 || CurPOC%8 == 0) 938 { 939 lastLevelLambda = m_lastIVPicture->getPicActualLambda(); 940 lastPicLambda = m_lastIVPicture->getPicActualLambda(); 941 } 942 else 943 { 944 for ( it = listPreviousPictures.begin(); it != listPreviousPictures.end(); it++ ) 945 { 946 if ( (*it)->getFrameLevel() == m_frameLevel ) 947 { 948 lastLevelLambda = (*it)->getPicActualLambda(); 949 } 950 lastPicLambda = (*it)->getPicActualLambda(); 951 952 if ( lastPicLambda > 0.0 ) 953 { 954 lastValidLambda = lastPicLambda; 955 } 956 } 957 } 958 959 if ( lastLevelLambda > 0.0 ) 960 { 961 lastLevelLambda = Clip3( 0.1, 10000.0, lastLevelLambda ); 962 estLambda = Clip3( lastLevelLambda * pow( 2.0, -3.0/3.0 ), lastLevelLambda * pow( 2.0, 3.0/3.0 ), estLambda ); 963 } 964 965 if ( lastPicLambda > 0.0 ) 966 { 967 lastPicLambda = Clip3( 0.1, 2000.0, lastPicLambda ); 968 estLambda = Clip3( lastPicLambda * pow( 2.0, -10.0/3.0 ), lastPicLambda * pow( 2.0, 10.0/3.0 ), estLambda ); 969 } 970 else if ( lastValidLambda > 0.0 ) 971 { 972 lastValidLambda = Clip3( 0.1, 2000.0, lastValidLambda ); 973 estLambda = Clip3( lastValidLambda * pow(2.0, -10.0/3.0), lastValidLambda * pow(2.0, 10.0/3.0), estLambda ); 974 } 975 else 976 { 977 estLambda = Clip3( 0.1, 10000.0, estLambda ); 978 } 979 980 if ( estLambda < 0.1 ) 981 { 982 estLambda = 0.1; 983 } 984 985 m_estPicLambda = estLambda; 986 return estLambda; 987 } 988 #endif 989 990 858 991 #if RATE_CONTROL_INTRA 859 992 Double TEncRCPic::getLCUTargetBpp(SliceType eSliceType) … … 937 1070 } 938 1071 1072 1073 #if KWU_RC_MADPRED_E0227 1074 Double TEncRCPic::getLCUTargetBppforInterView( list<TEncRCPic*>& listPreviousPictures, TComDataCU* pcCU, Double basePos, Double curPos, Double focalLen, Double znear, Double zfar, Int direction, Int* disparity ) 1075 { 1076 Int LCUIdx = getLCUCoded(); 1077 Double bpp = -1.0; 1078 Int avgBits = 0; 1079 #if !M0036_RC_IMPROVEMENT 1080 Double totalMAD = -1.0; 1081 Double MAD = -1.0; 1082 #endif 1083 1084 Double totalMAD = -1.0; 1085 Double MAD = -1.0; 1086 1087 Double IVMAD = -1.0; 1088 Double SAD = 0.0; 1089 Int x, y; 1090 Int Sum = 0; 1091 1092 { 1093 Pel* pOrg = pcCU->getSlice()->getIvPic(false, 0)->getPicYuvOrg()->getLumaAddr(pcCU->getAddr(), 0); 1094 Pel* pRec = pcCU->getSlice()->getIvPic(false, 0)->getPicYuvRec()->getLumaAddr(pcCU->getAddr(), 0); 1095 Pel* pDep = pcCU->getSlice()->getIvPic(true, pcCU->getSlice()->getViewIndex())->getPicYuvOrg()->getLumaAddr(pcCU->getAddr(), 0); 1096 Int iStride = pcCU->getSlice()->getIvPic(true, pcCU->getSlice()->getViewIndex())->getPicYuvOrg()->getStride(); 1097 1098 Int width = m_LCUs[ LCUIdx ].m_CUWidth; 1099 Int height = m_LCUs[ LCUIdx ].m_CUHeight; 1100 1101 for( y = 0 ; y < pcCU->getSlice()->getSPS()->getMaxCUHeight() ; y+=8) 1102 { 1103 for( x = 0 ; x < pcCU->getSlice()->getSPS()->getMaxCUWidth() ; x+=8) 1104 { 1105 Sum += pDep[x]; 1106 } 1107 pDep += iStride; 1108 } 1109 1110 Double AvgDepth = (Double)Sum/((pcCU->getSlice()->getSPS()->getMaxCUHeight()/8)*(pcCU->getSlice()->getSPS()->getMaxCUWidth()/8)); 1111 1112 Double fL = focalLen * abs( basePos - curPos ); 1113 Double z = abs( 1.0 / znear - 1.0 / zfar ) * ((Double)(AvgDepth) / (( 1 << g_bitDepthY ) - 1) ) + abs(1.0 / zfar); 1114 *disparity = (Int)(direction*fL * z); 1115 Int shift = DISTORTION_PRECISION_ADJUSTMENT(g_bitDepthY-8); 1116 1117 Int disp = *disparity; 1118 Int posX, posY; 1119 pcCU->getPosInPic(0, posX, posY); 1120 if((posX + *disparity) < 0 || (posX + *disparity + width) >= pcCU->getSlice()->getSPS()->getMaxCUWidth()) 1121 { 1122 disp = 0; 1123 } 1124 1125 for( y = 0; y < height; y++ ) 1126 { 1127 for( x = 0; x < width; x++ ) 1128 { 1129 SAD += abs( pOrg[Clip3(0, (Int)(pcCU->getPic()->getPicYuvOrg()->getWidth() - pcCU->getSlice()->getSPS()->getMaxCUWidth()), x + disp)] 1130 - pRec[Clip3(0, (Int)(pcCU->getPic()->getPicYuvOrg()->getWidth() - pcCU->getSlice()->getSPS()->getMaxCUWidth()), x + disp)] )>>shift; 1131 } 1132 pOrg += iStride; 1133 pRec += iStride; 1134 } 1135 IVMAD = SAD / (Double)(height * width); 1136 IVMAD = IVMAD * IVMAD; 1137 1138 m_LCUs[ LCUIdx ].m_IVMAD = IVMAD; 1139 if(m_lastPicture) 1140 { 1141 m_LCUs[ LCUIdx ].m_MAD = m_lastPicture->getLCU(LCUIdx).m_MAD; 1142 } 1143 1144 MAD = m_LCUs[ LCUIdx ].m_IVMAD; 1145 1146 if(m_lastPicture) 1147 { 1148 totalMAD = m_lastPicture->getTotalMAD(); // get total MAD of temporal frame 1149 for ( Int i=0; i<LCUIdx; i++ ) 1150 { 1151 totalMAD -= m_lastPicture->getLCU(i).m_MAD; 1152 } 1153 } 1154 else 1155 { 1156 totalMAD = m_lastIVPicture->getTotalMAD(); // get total MAD of inter-view frame 1157 for ( Int i=0; i<LCUIdx; i++ ) 1158 { 1159 totalMAD -= m_lastIVPicture->getLCU(i).m_MAD; 1160 } 1161 } 1162 1163 1164 if ( totalMAD > 0.1 ) 1165 { 1166 avgBits = Int( (m_bitsLeft * MAD) / totalMAD ); 1167 } 1168 else 1169 { 1170 avgBits = Int( (m_bitsLeft) / m_LCULeft ); 1171 } 1172 } 1173 1174 if ( avgBits < 5 ) 1175 { 1176 avgBits = 5; 1177 } 1178 1179 bpp = ( Double )avgBits/( Double )m_LCUs[ LCUIdx ].m_numberOfPixel; 1180 m_LCUs[ LCUIdx ].m_targetBits = avgBits; 1181 1182 return bpp; 1183 } 1184 #endif 1185 1186 1187 1188 939 1189 Double TEncRCPic::getLCUEstLambda( Double bpp ) 940 1190 { … … 1185 1435 } 1186 1436 m_picLambda = averageLambda; 1187 #if !M0036_RC_IMPROVEMENT 1437 #if !M0036_RC_IMPROVEMENT || KWU_RC_MADPRED_E0227 1438 #if KWU_RC_MADPRED_E0227 1439 m_totalMAD = 0; 1440 #endif 1188 1441 for ( Int i=0; i<m_numberOfLCU; i++ ) 1189 1442 { … … 1393 1646 1394 1647 #if M0036_RC_IMPROVEMENT 1648 #if KWU_RC_MADPRED_E0227 1649 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], Int layerID ) 1650 #else 1395 1651 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] ) 1652 #endif 1396 1653 #else 1397 1654 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] ) … … 1607 1864 } 1608 1865 1866 #if KWU_RC_MADPRED_E0227 1867 setLayerID(layerID); 1868 #endif 1869 1609 1870 delete[] bitsRatio; 1610 1871 delete[] GOPID2Level; … … 1614 1875 { 1615 1876 m_encRCPic = new TEncRCPic; 1877 #if KWU_RC_MADPRED_E0227 1878 m_encRCPic->create( m_encRCSeq, m_encRCGOP, frameLevel, m_listRCPictures, m_LayerID ); 1879 #else 1616 1880 m_encRCPic->create( m_encRCSeq, m_encRCGOP, frameLevel, m_listRCPictures ); 1881 #endif 1617 1882 } 1618 1883 … … 1815 2080 m_sourceHeightInLCU = (sourceHeight / maxCUHeight) + (( sourceHeight % maxCUHeight) ? 1 : 0); 1816 2081 m_isLowdelay = (sizeIntraPeriod == -1) ? true : false; 2082 1817 2083 m_prevBitrate = ( targetKbps << 10 ); // in units of 1,024 bps 1818 2084 m_currBitrate = ( targetKbps << 10 ); 2085 1819 2086 m_frameRate = frameRate; 1820 2087 m_refFrameNum = m_isLowdelay ? (sizeGOP) : (sizeGOP>>1); … … 2212 2479 } 2213 2480 2481 2482 #if KWU_RC_MADPRED_E0227 2483 Void TEncRateCtrl::updateLCUDataEnhancedView(TComDataCU* pcCU, UInt64 uiBits, Int qp, Double basePos, Double curPos, Double focalLen, Double znear, Double zfar, Int direction) 2484 { 2485 Int x, y; 2486 Double dMAD = 0.0; 2487 Int Sum = 0; 2488 Double SAD = 0.0; 2489 2490 Pel* pOrg = pcCU->getSlice()->getIvPic(false, 0)->getPicYuvOrg()->getLumaAddr(pcCU->getAddr(), 0); 2491 Pel* pRec = pcCU->getSlice()->getIvPic(false, 0)->getPicYuvRec()->getLumaAddr(pcCU->getAddr(), 0); 2492 Pel* pDep = pcCU->getSlice()->getIvPic(true, pcCU->getSlice()->getViewIndex())->getPicYuvOrg()->getLumaAddr(pcCU->getAddr(), 0); 2493 Int iStride = pcCU->getSlice()->getIvPic(true, pcCU->getSlice()->getViewIndex())->getPicYuvOrg()->getStride(); 2494 2495 Int width = m_pcLCUData[m_indexLCU].m_widthInPixel; 2496 Int height = m_pcLCUData[m_indexLCU].m_heightInPixel; 2497 2498 for( y = 0 ; y < pcCU->getSlice()->getSPS()->getMaxCUHeight() ; y+=8) 2499 { 2500 for( x = 0 ; x < pcCU->getSlice()->getSPS()->getMaxCUWidth() ; x+=8) 2501 { 2502 Sum += pDep[x]; 2503 } 2504 pDep += iStride; 2505 } 2506 2507 Double AvgDepth = (Double)Sum/((pcCU->getSlice()->getSPS()->getMaxCUHeight()/8)*(pcCU->getSlice()->getSPS()->getMaxCUWidth()/8)); 2508 Double fL = focalLen * abs( basePos - curPos ); 2509 Double z = abs( 1.0 / znear - 1.0 / zfar ) * ((Double)(AvgDepth) / (( 1 << g_bitDepthY ) - 1) ) + abs(1.0 / zfar); 2510 Int disparity = (Int)(direction*fL * z); 2511 Int shift = DISTORTION_PRECISION_ADJUSTMENT(g_bitDepthY-8); 2512 Int disp = disparity; 2513 2514 for( y = 0; y < height; y++ ) 2515 { 2516 for( x = 0; x < width; x++ ) 2517 { 2518 SAD += abs( pOrg[Clip3(0, (Int)(pcCU->getPic()->getPicYuvOrg()->getWidth() - pcCU->getSlice()->getSPS()->getMaxCUWidth()), x + disp)] 2519 - pRec[Clip3(0, (Int)(pcCU->getPic()->getPicYuvOrg()->getWidth() - pcCU->getSlice()->getSPS()->getMaxCUWidth()), x + disp)] )>>shift; 2520 } 2521 pOrg += iStride; 2522 pRec += iStride; 2523 } 2524 m_pcLCUData[m_indexLCU].m_qp = qp; 2525 m_pcLCUData[m_indexLCU].m_costMAD = (SAD /(Double)(width*height)); 2526 m_pcLCUData[m_indexLCU].m_bits = (Int)uiBits; 2527 } 2528 #endif 2529 2530 2214 2531 Double TEncRateCtrl::xAdjustmentBits(Int& reductionBits, Int& compensationBits) 2215 2532 { -
trunk/source/Lib/TLibEncoder/TEncRateCtrl.h
r608 r655 98 98 Int m_targetBitsLeft; 99 99 #endif 100 101 #if KWU_RC_MADPRED_E0227 102 Double m_MAD; 103 104 Int m_CUWidth; 105 Int m_CUHeight; 106 Double m_IVMAD; 107 #endif 100 108 }; 101 109 … … 248 256 249 257 public: 258 #if KWU_RC_MADPRED_E0227 259 Void create( TEncRCSeq* encRCSeq, TEncRCGOP* encRCGOP, Int frameLevel, list<TEncRCPic*>& listPreviousPictures, Int layerID ); 260 #else 250 261 Void create( TEncRCSeq* encRCSeq, TEncRCGOP* encRCGOP, Int frameLevel, list<TEncRCPic*>& listPreviousPictures ); 262 #endif 251 263 Void destroy(); 252 264 265 #if KWU_RC_MADPRED_E0227 266 Double estimatePicLambdaIV( list<TEncRCPic*>& listPreviousPictures, Int curPOC ); 267 #endif 253 268 #if !RATE_CONTROL_INTRA 254 269 Double estimatePicLambda( list<TEncRCPic*>& listPreviousPictures ); … … 267 282 Double getLCUTargetBpp(); 268 283 #endif 284 285 #if KWU_RC_MADPRED_E0227 286 Double getLCUTargetBppforInterView( list<TEncRCPic*>& listPreviousPictures, TComDataCU* pcCU, Double basePos, Double curPos, Double focalLen, Double znear, Double zfar, Int direction, Int* disparity ); 287 #endif 288 269 289 Double getLCUEstLambda( Double bpp ); 270 290 Int getLCUEstQP( Double lambda, Int clipPicQP ); … … 282 302 283 303 Void addToPictureLsit( list<TEncRCPic*>& listPreviousPictures ); 304 305 #if KWU_RC_MADPRED_E0227 306 Void addToPictureLsitIV( list<TEncRCPic*>& listPreviousPictures ); 307 Void setIVPic( TEncRCPic* baseRCPic ); 308 #endif 309 284 310 #if !M0036_RC_IMPROVEMENT 285 311 Double getEffectivePercentage(); … … 322 348 #endif 323 349 350 #if KWU_RC_MADPRED_E0227 351 Double getTotalMAD() { return m_totalMAD; } 352 Void setTotalMAD( Double MAD ) { m_totalMAD = MAD; } 353 354 Double getIVTotalMAD() { return m_IVtotalMAD; } 355 Void setIVTotalMAD( Double MAD ) { m_IVtotalMAD = MAD; } 356 #endif 357 324 358 Int getPicActualBits() { return m_picActualBits; } 325 359 Int getPicActualQP() { return m_picQP; } … … 330 364 Void setPicEstLambda( Double lambda ) { m_picLambda = lambda; } 331 365 366 #if KWU_RC_MADPRED_E0227 367 Int getLayerID() { return m_LayerID; } 368 Void setLayerID(Int layerid) { m_LayerID = layerid; } 369 #endif 370 332 371 private: 333 372 TEncRCSeq* m_encRCSeq; … … 361 400 TEncRCPic* m_lastPicture; 362 401 #endif 402 403 #if KWU_RC_MADPRED_E0227 404 Double m_totalMAD; 405 TEncRCPic* m_lastPicture; 406 Int m_LayerID; 407 TEncRCPic* m_lastIVPicture; 408 Double m_IVtotalMAD; 409 #endif 363 410 }; 364 411 … … 371 418 public: 372 419 #if M0036_RC_IMPROVEMENT 420 #if KWU_RC_MADPRED_E0227 421 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], Int layerID ); 422 #else 373 423 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] ); 424 #endif 374 425 #else 375 426 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] ); … … 388 439 list<TEncRCPic*>& getPicList() { return m_listRCPictures; } 389 440 441 #if KWU_RC_MADPRED_E0227 442 Int getLayerID() { return m_LayerID; } 443 Void setLayerID(Int layerid) { m_LayerID = layerid; } 444 #endif 445 390 446 private: 391 447 TEncRCSeq* m_encRCSeq; … … 394 450 list<TEncRCPic*> m_listRCPictures; 395 451 Int m_RCQP; 452 453 #if KWU_RC_MADPRED_E0227 454 Int m_LayerID; 455 #endif 396 456 }; 397 457 … … 518 578 Void updataRCUnitStatus (); 519 579 Void updateLCUData (TComDataCU* pcCU, UInt64 actualLCUBits, Int qp); 580 #if KWU_RC_MADPRED_E0227 581 Void updateLCUDataEnhancedView(TComDataCU* pcCU, UInt64 uiBits, Int qp, Double basePos, Double curPos, Double focalLen, Double znear, Double zfar, Int direction); 582 #endif 520 583 Void updateFrameData (UInt64 actualFrameBits); 521 584 Double xAdjustmentBits (Int& reductionBits, Int& compensationBits); -
trunk/source/Lib/TLibEncoder/TEncSbac.cpp
r622 r655 95 95 #if H_3D_DIM_DMM 96 96 , m_cDmm1DataSCModel ( 1, 1, NUM_DMM1_DATA_CTX , m_contextModels + m_numContextModels, m_numContextModels) 97 #if !SEC_DMM2_E0146_HHIFIX98 , m_cDmm2DataSCModel ( 1, 1, NUM_DMM2_DATA_CTX , m_contextModels + m_numContextModels, m_numContextModels)99 #endif100 97 , m_cDmm3DataSCModel ( 1, 1, NUM_DMM3_DATA_CTX , m_contextModels + m_numContextModels, m_numContextModels) 101 98 #endif … … 108 105 #endif 109 106 #endif 110 #if LGE_INTER_SDC_E0156107 #if H_3D_INTER_SDC 111 108 , m_cInterSDCFlagSCModel ( 1, 1, NUM_INTER_SDC_FLAG_CTX , m_contextModels + m_numContextModels, m_numContextModels) 112 109 , m_cInterSDCResidualSCModel ( 1, 1, NUM_INTER_SDC_RESIDUAL_CTX , m_contextModels + m_numContextModels, m_numContextModels) … … 177 174 #if H_3D_DIM_DMM 178 175 m_cDmm1DataSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_DMM1_DATA ); 179 #if !SEC_DMM2_E0146_HHIFIX180 m_cDmm2DataSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_DMM2_DATA );181 #endif182 176 m_cDmm3DataSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_DMM3_DATA ); 183 177 #endif … … 190 184 #endif 191 185 #endif 192 #if LGE_INTER_SDC_E0156186 #if H_3D_INTER_SDC 193 187 m_cInterSDCFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_INTER_SDC_FLAG ); 194 188 m_cInterSDCResidualSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_INTER_SDC_RESIDUAL ); … … 232 226 curCost += m_cCUICFlagSCModel.calcCost ( curSliceType, qp, (UChar*)INIT_IC_FLAG ); 233 227 #endif 234 #if LGE_INTER_SDC_E0156228 #if H_3D_INTER_SDC 235 229 curCost += m_cInterSDCFlagSCModel.calcCost ( curSliceType, qp, (UChar*)INIT_INTER_SDC_FLAG ); 236 230 curCost += m_cInterSDCResidualSCModel.calcCost ( curSliceType, qp, (UChar*)INIT_INTER_SDC_RESIDUAL ); … … 268 262 #if H_3D_DIM_DMM 269 263 curCost += m_cDmm1DataSCModel.calcCost ( curSliceType, qp, (UChar*)INIT_DMM1_DATA ); 270 #if !SEC_DMM2_E0146_HHIFIX271 curCost += m_cDmm2DataSCModel.calcCost ( curSliceType, qp, (UChar*)INIT_DMM2_DATA );272 #endif273 264 curCost += m_cDmm3DataSCModel.calcCost ( curSliceType, qp, (UChar*)INIT_DMM3_DATA ); 274 265 #endif … … 340 331 #if H_3D_DIM_DMM 341 332 m_cDmm1DataSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_DMM1_DATA ); 342 #if !SEC_DMM2_E0146_HHIFIX343 m_cDmm2DataSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_DMM2_DATA );344 #endif345 333 m_cDmm3DataSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_DMM3_DATA ); 346 334 #endif … … 353 341 #endif 354 342 #endif 355 #if LGE_INTER_SDC_E0156343 #if H_3D_INTER_SDC 356 344 m_cInterSDCFlagSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_INTER_SDC_FLAG ); 357 345 m_cInterSDCResidualSCModel.initBuffer ( eSliceType, iQp, (UChar*)INIT_INTER_SDC_RESIDUAL ); … … 548 536 } 549 537 } 550 551 #if !SEC_DMM2_E0146_HHIFIX552 Void TEncSbac::xCodeDmm2Offset( Int iOffset )553 {554 if( DMM2_DELTAEND_MAX > 0 )555 {556 m_pcBinIf->encodeBin( (iOffset != 0) , m_cDmm2DataSCModel.get(0, 0, 0) );557 if( iOffset != 0 )558 {559 UInt uiAbsValMinus1 = abs(iOffset)-1;560 m_pcBinIf->encodeBin( (uiAbsValMinus1 & 0x01), m_cDmm2DataSCModel.get(0, 0, 0) );561 m_pcBinIf->encodeBin( (uiAbsValMinus1 & 0x02) >> 1, m_cDmm2DataSCModel.get(0, 0, 0) );562 563 UInt uiSign = (iOffset > 0) ? 0 : 1;564 m_pcBinIf->encodeBinEP( uiSign );565 }566 }567 }568 #endif569 538 570 539 Void TEncSbac::xCodeDmm3WedgeIdx( UInt uiIntraIdx, Int iNumBit ) … … 1240 1209 xCodeDmm1WedgeIdx( pcCU->getDmmWedgeTabIdx( dimType, absPartIdx ), g_dmm1TabIdxBits[pcCU->getIntraSizeIdx(absPartIdx)] ); 1241 1210 } break; 1242 #if !SEC_DMM2_E0146_HHIFIX1243 case( DMM2_IDX ):1244 {1245 xCodeDmm2Offset( pcCU->getDmm2DeltaEnd( absPartIdx ) );1246 } break;1247 #endif1248 1211 case( DMM3_IDX ): 1249 1212 { … … 1294 1257 Void TEncSbac::codeIntraDepthMode( TComDataCU* pcCU, UInt absPartIdx ) 1295 1258 { 1296 #if ZJU_DEPTH_INTRA_MODE_E02041297 1259 UInt codeWordTable[3][7] = {{0, 0, 0, 2, 0,6, 7},{0, 0, 2, 7, 3, 6, 2},{0, 1, 0, 0, 0, 0, 0}}; 1298 1260 UInt codeWordLenTable[3][7] = {{0, 1, 0, 2, 0,3, 3},{1, 1, 2, 3, 2, 3, 2},{1, 1, 0, 0, 0, 0, 0}}; 1299 #else1300 #if LGE_SDC_REMOVE_DC_E01581301 #if SEC_DMM2_E0146_HHIFIX1302 UInt codeWordTable[3][7] = {{0, 0, 0, 2, 0,6, 7},{0, 2, 3, 4, 5, 6, 7},{0, 1, 0, 0, 0, 0, 0}};1303 UInt codeWordLenTable[3][7] = {{0, 1, 0, 2, 0,3, 3},{2, 3, 3, 3, 3, 3, 3},{1, 1, 0, 0, 0, 0, 0}};1304 #else1305 UInt codeWordTable[3][8] = { { 0, 0, 0, 2, 0, 6, 0, 7 }, { 0, 2, 3, 4, 5, 6, 15, 14 }, { 0, 1, 0, 0, 0, 0, 0, 0 } };1306 UInt codeWordLenTable[3][8] = { { 0, 1, 0, 2, 0, 3, 0, 3 }, { 2, 3, 3, 3, 3, 3, 4, 4 }, { 1, 1, 0, 0, 0, 0, 0, 0 } };1307 #endif1308 #else1309 #if SEC_DMM2_E0146_HHIFIX1310 UInt codeWordTable[3][8] = {{0, 0, 0, 2, 0,6, 0, 7},{0, 2, 3, 4, 5, 6, 14, 15},{0, 2, 0, 0, 0, 0, 3, 0}};1311 UInt codeWordLenTable[3][8] = {{0, 1, 0, 2, 0,3, 0, 3},{2, 3, 3, 3, 3, 3, 4, 4},{1, 2, 0, 0, 0, 0, 2, 0}};1312 #else1313 UInt codeWordTable[3][9] = {{0, 0, 0, 2, 0,6, 0, 0, 7},{0, 2, 3, 4, 5, 6, 14, 31, 30},{0, 2, 0, 0, 0, 0, 3, 0, 0}};1314 UInt codeWordLenTable[3][9] = {{0, 1, 0, 2, 0,3, 0, 0, 3},{2, 3, 3, 3, 3, 3, 4, 5, 5},{1, 2, 0, 0, 0, 0, 2, 0, 0}};1315 #endif1316 #endif1317 #endif1318 1261 UInt dir = pcCU->getLumaIntraDir( absPartIdx ); 1319 1262 UInt puIdx = (pcCU->getWidth(absPartIdx) == 64) ? 2 : ( (pcCU->getPartitionSize(absPartIdx) == SIZE_NxN && pcCU->getWidth(absPartIdx) == 8) ? 0 : 1 ); … … 1331 1274 case DMM4_IDX: codeIdx = 4; break; 1332 1275 case DMM3_IDX: codeIdx = 5; break; 1333 #if LGE_SDC_REMOVE_DC_E01581334 #if SEC_DMM2_E0146_HHIFIX1335 1276 case RBC_IDX: codeIdx = 6; break; 1336 #else1337 case DMM2_IDX: codeIdx = 6; break;1338 case RBC_IDX: codeIdx = 7; break;1339 #endif1340 #else1341 #if SEC_DMM2_E0146_HHIFIX1342 case RBC_IDX: codeIdx = 7; break;1343 #else1344 case DMM2_IDX: codeIdx = 7; break;1345 case RBC_IDX: codeIdx = 8; break;1346 #endif1347 #endif1348 1277 default: break; 1349 1278 } … … 1356 1285 { 1357 1286 case PLANAR_IDX: codeIdx = 0; break; 1358 #if !LGE_SDC_REMOVE_DC_E01581359 case DC_IDX: codeIdx = 6; break;1360 #endif1361 1287 default: codeIdx = 2; break; 1362 1288 } 1363 1289 } 1364 1290 #endif 1365 #if ZJU_DEPTH_INTRA_MODE_E02041366 1291 if( puIdx==1 ) 1367 1292 { … … 1375 1300 } 1376 1301 } 1377 #endif1378 1302 //mode coding 1379 1303 for( UInt i = 0; i < codeWordLenTable[puIdx][codeIdx]; i++ ) … … 2304 2228 } 2305 2229 2306 #if LGE_INTER_SDC_E01562230 #if H_3D_INTER_SDC 2307 2231 Void TEncSbac::codeInterSDCFlag( TComDataCU* pcCU, UInt uiAbsPartIdx ) 2308 2232 { -
trunk/source/Lib/TLibEncoder/TEncSbac.h
r622 r655 121 121 #if H_3D_DIM_DMM 122 122 Void xCodeDmm1WedgeIdx ( UInt uiTabIdx, Int iNumBit ); 123 #if !SEC_DMM2_E0146_HHIFIX124 Void xCodeDmm2Offset ( Int iOffset );125 #endif126 123 Void xCodeDmm3WedgeIdx ( UInt uiIntraIdx, Int iNumBit ); 127 124 #endif … … 160 157 Void codeICFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx ); 161 158 #endif 162 #if LGE_INTER_SDC_E0156159 #if H_3D_INTER_SDC 163 160 Void codeInterSDCFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx ); 164 161 Void codeInterSDCResidualData ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiSegment ); … … 256 253 #if H_3D_DIM_DMM 257 254 ContextModel3DBuffer m_cDmm1DataSCModel; 258 #if !SEC_DMM2_E0146_HHIFIX259 ContextModel3DBuffer m_cDmm2DataSCModel;260 #endif261 255 ContextModel3DBuffer m_cDmm3DataSCModel; 262 256 #endif … … 269 263 #endif 270 264 #endif 271 #if LGE_INTER_SDC_E0156265 #if H_3D_INTER_SDC 272 266 ContextModel3DBuffer m_cInterSDCFlagSCModel; 273 267 ContextModel3DBuffer m_cInterSDCResidualSCModel; -
trunk/source/Lib/TLibEncoder/TEncSearch.cpp
r622 r655 41 41 #include "TEncSearch.h" 42 42 #include <math.h> 43 #if LGE_INTER_SDC_E015643 #if H_3D_INTER_SDC 44 44 #include <memory.h> 45 45 #endif … … 323 323 m_cDistParam.bUseIC = pcPatternKey->getICFlag(); 324 324 #endif 325 #if LGE_INTER_SDC_E0156325 #if H_3D_INTER_SDC 326 326 m_cDistParam.bUseSDCMRSAD = pcPatternKey->getSDCMRSADFlag(); 327 327 #endif … … 755 755 m_cDistParam.bUseIC = pcPatternKey->getICFlag(); 756 756 #endif 757 #if LGE_INTER_SDC_E0156757 #if H_3D_INTER_SDC 758 758 m_cDistParam.bUseSDCMRSAD = pcPatternKey->getSDCMRSADFlag(); 759 759 #endif … … 1900 1900 // get DC prediction for each segment 1901 1901 Pel apDCPredValues[2]; 1902 #if KWU_SDC_SIMPLE_DC_E01171903 1902 analyzeSegmentsSDC(piPred, uiStride, uiWidth, apDCPredValues, uiNumSegments, pbMask, uiMaskStride, uiLumaPredMode ); 1904 #else1905 analyzeSegmentsSDC(piPred, uiStride, uiWidth, apDCPredValues, uiNumSegments, pbMask, uiMaskStride );1906 #endif1907 1903 1908 1904 // get original DC for each segment 1909 1905 Pel apDCOrigValues[2]; 1910 #if KWU_SDC_SIMPLE_DC_E01171911 1906 analyzeSegmentsSDC(piOrg, uiStride, uiWidth, apDCOrigValues, uiNumSegments, pbMask, uiMaskStride, uiLumaPredMode, true ); 1912 #else1913 analyzeSegmentsSDC(piOrg, uiStride, uiWidth, apDCOrigValues, uiNumSegments, pbMask, uiMaskStride );1914 #endif1915 1907 1916 1908 for( UInt uiSegment = 0; uiSegment < uiNumSegments; uiSegment++ ) … … 2851 2843 { 2852 2844 2853 #if SCU_HS_FAST_DEPTH_INTRA_E0238_HHIFIX2845 #if H_3D_FAST_DEPTH_INTRA 2854 2846 Int threshold = max(((pcCU->getQP(0))>>3)-1,3); 2855 2847 Int varThreshold = (Int)( threshold * threshold - 8 ); … … 2859 2851 #if H_3D_DIM_DMM 2860 2852 if( m_pcEncCfg->getUseDMM() 2861 #if SCU_HS_FAST_DEPTH_INTRA_E0238_HHIFIX2853 #if H_3D_FAST_DEPTH_INTRA 2862 2854 && (uiRdModeList[0] != PLANAR_IDX || varCU >= varThreshold) 2863 2855 #endif … … 2866 2858 for( UInt dmmType = 0; dmmType < DMM_NUM_TYPE; dmmType++ ) 2867 2859 { 2860 #if H_3D_FCO 2861 TComPic* picTexture = pcCU->getSlice()->getIvPic(false, pcCU->getSlice()->getViewIndex() ); 2862 if ( !picTexture->getReconMark() && (DMM3_IDX == dmmType || DMM4_IDX == dmmType ) ) 2863 { 2864 continue; 2865 } 2866 #endif 2868 2867 UInt uiTabIdx = 0; 2869 2868 TComWedgelet* biSegmentation = NULL; … … 2877 2876 biSegmentation = &(g_dmmWedgeLists[(g_aucConvertToBit[uiWidth])][uiTabIdx]); 2878 2877 } break; 2879 #if !SEC_DMM2_E0146_HHIFIX2880 case( DMM2_IDX ):2881 {2882 if( uiWidth > 4 )2883 {2884 Int dmm2DeltaEnd = 0;2885 xSearchDmm2Wedge( pcCU, uiPartOffset, piOrg, uiStride, uiWidth, uiHeight, uiTabIdx, dmm2DeltaEnd );2886 pcCU->setDmmWedgeTabIdxSubParts( uiTabIdx, dmmType, uiPartOffset, uiDepth + uiInitTrDepth );2887 pcCU->setDmm2DeltaEndSubParts( dmm2DeltaEnd, uiPartOffset, uiDepth + uiInitTrDepth );2888 biSegmentation = &(g_dmmWedgeLists[(g_aucConvertToBit[uiWidth])][uiTabIdx]);2889 }2890 } break;2891 #endif2892 2878 case( DMM3_IDX ): 2893 2879 { 2894 #if LGE_PKU_DMM3_OVERLAP_E0159_HHIFIX 2880 2895 2881 TComPic* pcPicTex = pcCU->getSlice()->getTexturePic(); 2896 2882 TComDataCU* pcColTexCU = pcPicTex->getCU( pcCU->getAddr() ); … … 2900 2886 if( uiColTexIntraDir > DC_IDX && uiColTexIntraDir < 35 ) 2901 2887 { 2902 #endif 2903 UInt uiIntraTabIdx = 0; 2904 #if LGE_PKU_DMM3_OVERLAP_E0159_HHIFIX 2888 UInt uiIntraTabIdx = 0; 2905 2889 xSearchDmm3Wedge( pcCU, uiPartOffset, piOrg, uiStride, uiWidth, uiHeight, uiTabIdx, uiIntraTabIdx, uiColTexIntraDir ); 2906 #else2907 xSearchDmm3Wedge( pcCU, uiPartOffset, piOrg, uiStride, uiWidth, uiHeight, uiTabIdx, uiIntraTabIdx );2908 #endif2909 2890 pcCU->setDmmWedgeTabIdxSubParts( uiTabIdx, dmmType, uiPartOffset, uiDepth + uiInitTrDepth ); 2910 2891 pcCU->setDmm3IntraTabIdxSubParts( uiIntraTabIdx, uiPartOffset, uiDepth + uiInitTrDepth ); 2911 2892 biSegmentation = &(g_dmmWedgeLists[(g_aucConvertToBit[uiWidth])][uiTabIdx]); 2912 #if LGE_PKU_DMM3_OVERLAP_E0159_HHIFIX2913 2893 } 2914 #endif2915 2894 } break; 2916 2895 case( DMM4_IDX ): … … 2941 2920 #if H_3D_DIM_RBC 2942 2921 if( m_pcEncCfg->getUseRBC() 2943 #if SCU_HS_FAST_DEPTH_INTRA_E0238_HHIFIX2922 #if H_3D_FAST_DEPTH_INTRA 2944 2923 && (uiRdModeList[0] != PLANAR_IDX || varCU >= varThreshold) 2945 2924 #endif … … 3581 3560 cDistParam.bUseIC = false; 3582 3561 #endif 3583 #if LGE_INTER_SDC_E01563562 #if H_3D_INTER_SDC 3584 3563 cDistParam.bUseSDCMRSAD = false; 3585 3564 #endif … … 3724 3703 */ 3725 3704 #if AMP_MRG 3726 #if MTK_FAST_TEXTURE_ENCODING_E01733705 #if H_3D_FAST_TEXTURE_ENCODING 3727 3706 Void TEncSearch::predInterSearch( TComDataCU* pcCU, TComYuv* pcOrgYuv, TComYuv*& rpcPredYuv, TComYuv*& rpcResiYuv, TComYuv*& rpcRecoYuv, Bool bFMD, Bool bUseRes, Bool bUseMRG ) 3728 3707 #else … … 3836 3815 #if AMP_MRG 3837 3816 Bool bTestNormalMC = true; 3838 #if MTK_FAST_TEXTURE_ENCODING_E01733817 #if H_3D_FAST_TEXTURE_ENCODING 3839 3818 if (bFMD||( bUseMRG && pcCU->getWidth( 0 ) > 8 && iNumPart == 2 )) 3840 3819 #else … … 4706 4685 pcPatternKey->setICFlag( bICFlag ); 4707 4686 #endif 4708 #if LGE_INTER_SDC_E01564687 #if H_3D_INTER_SDC 4709 4688 if ( pcCU->getSlice()->getIsDepth() && pcCU->getSlice()->getVPS()->getInterSDCFlag( pcCU->getSlice()->getLayerIdInVps() ) ) 4710 4689 { … … 4862 4841 m_cDistParam.bUseIC = pcPatternKey->getICFlag(); 4863 4842 #endif 4864 #if LGE_INTER_SDC_E01564843 #if H_3D_INTER_SDC 4865 4844 m_cDistParam.bUseSDCMRSAD = pcPatternKey->getSDCMRSADFlag(); 4866 4845 #endif … … 5471 5450 } 5472 5451 5473 #if LGE_INTER_SDC_E01565452 #if H_3D_INTER_SDC 5474 5453 Void TEncSearch::encodeResAndCalcRdInterSDCCU( TComDataCU* pcCU, TComYuv* pcOrg, TComYuv* pcPred, TComYuv* pcResi, TComYuv* pcRec, const UInt uiDepth ) 5475 5454 { … … 6794 6773 m_pcEntropyCoder->encodeARPW( pcCU , 0 ); 6795 6774 #endif 6796 #if LGE_INTER_SDC_E01566775 #if H_3D_INTER_SDC 6797 6776 m_pcEntropyCoder->encodeInterSDCFlag( pcCU, 0, true ); 6798 6777 #endif … … 7045 7024 } 7046 7025 7026 #if H_3D_DIM 7047 7027 // ------------------------------------------------------------------------------------------------------------------- 7048 7028 // Depth intra search 7049 7029 // ------------------------------------------------------------------------------------------------------------------- 7050 #if H_3D_DIM7051 7030 Void TEncSearch::xCalcBiSegDCs( Pel* ptrSrc, UInt srcStride, Bool* biSegPattern, Int patternStride, Pel& valDC1, Pel& valDC2 ) 7052 7031 { … … 7321 7300 } 7322 7301 7323 #if !SEC_DMM2_E0146_HHIFIX7324 Void TEncSearch::xSearchDmm2Wedge( TComDataCU* pcCU, UInt uiAbsPtIdx, Pel* piRef, UInt uiRefStride, UInt uiWidth, UInt uiHeight, UInt& ruiTabIdx, Int& riWedgeDeltaEnd )7325 {7326 ruiTabIdx = 0;7327 riWedgeDeltaEnd = 0;7328 7329 // local pred buffer7330 TComYuv cPredYuv;7331 cPredYuv.create( uiWidth, uiHeight );7332 cPredYuv.clear();7333 7334 UInt uiPredStride = cPredYuv.getStride();7335 Pel* piPred = cPredYuv.getLumaAddr();7336 7337 7338 // regular wedge search7339 Dist uiBestDist = RDO_DIST_MAX;7340 UInt uiBestTabIdx = 0;7341 Int iBestDeltaEnd = 0;7342 7343 UInt uiIdx = 0;7344 Pel refDC1 = 0; Pel refDC2 = 0;7345 for( Int iTestDeltaEnd = -DMM2_DELTAEND_MAX; iTestDeltaEnd <= DMM2_DELTAEND_MAX; iTestDeltaEnd++ )7346 {7347 uiIdx = xPredWedgeFromIntra( pcCU, uiAbsPtIdx, uiWidth, uiHeight, iTestDeltaEnd );7348 TComWedgelet* pcWedgelet = &(g_dmmWedgeLists[(g_aucConvertToBit[uiWidth])][uiIdx]);7349 xCalcBiSegDCs ( piRef, uiRefStride, pcWedgelet->getPattern(), pcWedgelet->getStride(), refDC1, refDC2 );7350 xAssignBiSegDCs( piPred, uiPredStride, pcWedgelet->getPattern(), pcWedgelet->getStride(), refDC1, refDC2 );7351 7352 Dist uiActDist = RDO_DIST_MAX;7353 #if H_3D_VSO7354 if( m_pcRdCost->getUseVSO() )7355 {7356 if( m_pcRdCost->getUseEstimatedVSD() )7357 {7358 uiActDist = m_pcRdCost->getDistPartVSD( pcCU, uiAbsPtIdx, piPred, uiPredStride, piRef, uiRefStride, uiWidth, uiHeight, false );7359 }7360 else7361 {7362 uiActDist = m_pcRdCost->getDistPartVSO( pcCU, uiAbsPtIdx, piPred, uiPredStride, piRef, uiRefStride, uiWidth, uiHeight, false );7363 }7364 }7365 else7366 #endif7367 {7368 uiActDist = m_pcRdCost->getDistPart( g_bitDepthY, piPred, uiPredStride, piRef, uiRefStride, uiWidth, uiHeight, TEXT_LUMA, DF_SAD );7369 }7370 7371 if( uiActDist < uiBestDist || uiBestDist == RDO_DIST_MAX )7372 {7373 uiBestDist = uiActDist;7374 uiBestTabIdx = uiIdx;7375 iBestDeltaEnd = iTestDeltaEnd;7376 }7377 else if( uiIdx == uiBestTabIdx && abs(iTestDeltaEnd) < abs(iBestDeltaEnd) )7378 {7379 iBestDeltaEnd = iTestDeltaEnd;7380 }7381 }7382 7383 ruiTabIdx = uiBestTabIdx;7384 riWedgeDeltaEnd = iBestDeltaEnd;7385 7386 cPredYuv.destroy();7387 return;7388 }7389 #endif7390 7391 #if LGE_PKU_DMM3_OVERLAP_E0159_HHIFIX7392 7302 Void TEncSearch::xSearchDmm3Wedge( TComDataCU* pcCU, UInt uiAbsPtIdx, Pel* piRef, UInt uiRefStride, UInt uiWidth, UInt uiHeight, UInt& ruiTabIdx, UInt& ruiIntraTabIdx, UInt colTexIntraDir ) 7393 7303 { … … 7426 7336 cPredYuv.destroy(); 7427 7337 } 7428 #else 7429 Void TEncSearch::xSearchDmm3Wedge( TComDataCU* pcCU, UInt uiAbsPtIdx, Pel* piRef, UInt uiRefStride, UInt uiWidth, UInt uiHeight, UInt& ruiTabIdx, UInt& ruiIntraTabIdx ) 7430 { 7431 ruiTabIdx = 0; 7432 ruiIntraTabIdx = 0; 7433 7434 // local pred buffer 7435 TComYuv cPredYuv; 7436 cPredYuv.create( uiWidth, uiHeight ); 7437 cPredYuv.clear(); 7438 Pel* piPred = cPredYuv.getLumaAddr(); 7439 UInt uiPredStride = cPredYuv.getStride(); 7440 7441 // wedge search 7442 UInt uiBestDist = MAX_UINT; 7443 WedgeList* pacWedgeList = &g_dmmWedgeLists[(g_aucConvertToBit[uiWidth])]; 7444 Pel refDC1 = 0; Pel refDC2 = 0; 7445 7446 TComPic* pcPicTex = pcCU->getSlice()->getTexturePic(); 7447 assert( pcPicTex != NULL ); 7448 TComDataCU* pcColTexCU = pcPicTex->getCU(pcCU->getAddr()); 7449 UInt uiTexPartIdx = pcCU->getZorderIdxInCU() + uiAbsPtIdx; 7450 Int uiColTexIntraDir = pcColTexCU->isIntra( uiTexPartIdx ) ? pcColTexCU->getLumaIntraDir( uiTexPartIdx ) : 255; 7451 7452 std::vector< std::vector<UInt> > pauiWdgLstSz = g_aauiWdgLstM3[g_aucConvertToBit[uiWidth]]; 7453 if( uiColTexIntraDir > DC_IDX && uiColTexIntraDir < 35 ) 7454 { 7455 std::vector<UInt>* pauiWdgLst = &pauiWdgLstSz[uiColTexIntraDir-2]; 7456 for( UInt uiIdxW = 0; uiIdxW < pauiWdgLst->size(); uiIdxW++ ) 7457 { 7458 UInt uiIdx = pauiWdgLst->at(uiIdxW); 7459 TComWedgelet* pcWedgelet = &(pacWedgeList->at(uiIdx)); 7460 xCalcBiSegDCs ( piRef, uiRefStride, pcWedgelet->getPattern(), pcWedgelet->getStride(), refDC1, refDC2 ); 7461 xAssignBiSegDCs( piPred, uiPredStride, pcWedgelet->getPattern(), pcWedgelet->getStride(), refDC1, refDC2 ); 7462 7463 UInt uiActDist = m_pcRdCost->getDistPart( g_bitDepthY, piPred, uiPredStride, piRef, uiRefStride, uiWidth, uiHeight, TEXT_LUMA, DF_SAD ); 7464 if( uiActDist < uiBestDist || uiBestDist == MAX_UINT ) 7465 { 7466 uiBestDist = uiActDist; 7467 ruiTabIdx = uiIdx; 7468 ruiIntraTabIdx = uiIdxW; 7469 } 7470 } 7471 } 7472 else 7473 { 7474 WedgeNodeList* pacWedgeNodeList = &g_dmmWedgeNodeLists[(g_aucConvertToBit[uiWidth])]; 7475 UInt uiBestNodeDist = MAX_UINT; 7476 UInt uiBestNodeId = 0; 7477 for( UInt uiNodeId = 0; uiNodeId < pacWedgeNodeList->size(); uiNodeId++ ) 7478 { 7479 TComWedgelet* pcWedgelet = &(pacWedgeList->at(pacWedgeNodeList->at(uiNodeId).getPatternIdx())); 7480 xCalcBiSegDCs ( piRef, uiRefStride, pcWedgelet->getPattern(), pcWedgelet->getStride(), refDC1, refDC2 ); 7481 xAssignBiSegDCs( piPred, uiPredStride, pcWedgelet->getPattern(), pcWedgelet->getStride(), refDC1, refDC2 ); 7482 7483 UInt uiActDist = m_pcRdCost->getDistPart( g_bitDepthY, piPred, uiPredStride, piRef, uiRefStride, uiWidth, uiHeight, TEXT_LUMA, DF_SAD ); 7484 if( uiActDist < uiBestNodeDist || uiBestNodeDist == MAX_UINT ) 7485 { 7486 uiBestNodeDist = uiActDist; 7487 uiBestNodeId = uiNodeId; 7488 ruiIntraTabIdx = uiNodeId; 7489 } 7490 } 7491 ruiTabIdx = pacWedgeNodeList->at(uiBestNodeId).getPatternIdx(); 7492 } 7493 7494 cPredYuv.destroy(); 7495 } 7496 #endif 7338 7497 7339 #endif 7498 7340 #if H_3D_DIM_RBC -
trunk/source/Lib/TLibEncoder/TEncSearch.h
r622 r655 196 196 TComYuv*& rpcResiYuv, 197 197 TComYuv*& rpcRecoYuv, 198 #if MTK_FAST_TEXTURE_ENCODING_E0173198 #if H_3D_FAST_TEXTURE_ENCODING 199 199 Bool bFMD, 200 200 #endif … … 213 213 TComYuv*& rpcYuvRec, 214 214 Bool bSkipRes ); 215 #if LGE_INTER_SDC_E0156215 #if H_3D_INTER_SDC 216 216 Void encodeResAndCalcRdInterSDCCU( TComDataCU* pcCU, 217 217 TComYuv* pcOrg, … … 343 343 UInt stateU0V1Both2 ); 344 344 345 345 #if H_3D_DIM 346 346 // ------------------------------------------------------------------------------------------------------------------- 347 347 // Depth intra search 348 348 // ------------------------------------------------------------------------------------------------------------------- 349 #if H_3D_DIM350 349 Void xCalcBiSegDCs ( Pel* ptrSrc, UInt srcStride, Bool* biSegPattern, Int patternStride, Pel& valDC1, Pel& valDC2 ); 351 350 #if H_3D_DIM_DMM 352 351 Void xSearchDmmDeltaDCs ( TComDataCU* pcCU, UInt uiAbsPtIdx, Pel* piOrig, Pel* piPredic, UInt uiStride, Bool* biSegPattern, Int patternStride, UInt uiWidth, UInt uiHeight, Pel& rDeltaDC1, Pel& rDeltaDC2 ); 353 352 Void xSearchDmm1Wedge ( TComDataCU* pcCU, UInt uiAbsPtIdx, Pel* piRef, UInt uiRefStride, UInt uiWidth, UInt uiHeight, UInt& ruiTabIdx ); 354 #if !SEC_DMM2_E0146_HHIFIX355 Void xSearchDmm2Wedge ( TComDataCU* pcCU, UInt uiAbsPtIdx, Pel* piRef, UInt uiRefStride, UInt uiWidth, UInt uiHeight, UInt& ruiTabIdx, Int& riWedgeDeltaEnd );356 #endif357 #if LGE_PKU_DMM3_OVERLAP_E0159_HHIFIX358 353 Void xSearchDmm3Wedge ( TComDataCU* pcCU, UInt uiAbsPtIdx, Pel* piRef, UInt uiRefStride, UInt uiWidth, UInt uiHeight, UInt& ruiTabIdx, UInt& ruiIntraTabIdx, UInt colTexIntraDir ); 359 #else360 Void xSearchDmm3Wedge ( TComDataCU* pcCU, UInt uiAbsPtIdx, Pel* piRef, UInt uiRefStride, UInt uiWidth, UInt uiHeight, UInt& ruiTabIdx, UInt& ruiIntraTabIdx );361 #endif362 354 #endif 363 355 #if H_3D_DIM_RBC -
trunk/source/Lib/TLibEncoder/TEncSlice.cpp
r622 r655 157 157 m_pdRdPicQp = (Double*)xMalloc( Double, m_pcCfg->getDeltaQpRD() * 2 + 1 ); 158 158 m_piRdPicQp = (Int* )xMalloc( Int, m_pcCfg->getDeltaQpRD() * 2 + 1 ); 159 #if KWU_RC_MADPRED_E0227 160 if(m_pcCfg->getUseRateCtrl()) 161 { 162 m_pcRateCtrl = pcEncTop->getRateCtrl(); 163 } 164 else 165 { 166 m_pcRateCtrl = NULL; 167 } 168 #else 159 169 m_pcRateCtrl = pcEncTop->getRateCtrl(); 170 #endif 160 171 } 161 172 … … 176 187 \param pPPS PPS associated with the slice 177 188 */ 178 #if H_MV5179 189 #if H_MV 180 Void TEncSlice::initEncSlice( TComPic* pcPic, Int pocLast, Int pocCurr, Int iNumPicRcvd, Int iGOPid, TComSlice*& rpcSlice, TComVPS* pVPS, TComSPS* pSPS, TComPPS *pPPS, Int layerId ) 181 #else 182 Void TEncSlice::initEncSlice( TComPic* pcPic, Int pocLast, Int pocCurr, Int iNumPicRcvd, Int iGOPid, TComSlice*& rpcSlice, TComSPS* pSPS, TComPPS *pPPS ) 183 #endif 184 #else 185 #if H_3D 186 Void TEncSlice::initEncSlice( TComPic* pcPic, Int pocLast, Int pocCurr, Int iNumPicRcvd, Int iGOPid, TComSlice*& rpcSlice, TComVPS* pVPS, TComSPS* pSPS, TComPPS *pPPS, Int layerId ) 187 #else 188 Void TEncSlice::initEncSlice( TComPic* pcPic, Int pocLast, Int pocCurr, Int iNumPicRcvd, Int iGOPid, TComSlice*& rpcSlice, TComSPS* pSPS, TComPPS *pPPS ) 189 #endif 190 Void TEncSlice::initEncSlice( TComPic* pcPic, Int pocLast, Int pocCurr, Int iNumPicRcvd, Int iGOPid, TComSlice*& rpcSlice, TComVPS* pVPS, TComSPS* pSPS, TComPPS *pPPS, Int layerId, bool isField ) 191 #else 192 Void TEncSlice::initEncSlice( TComPic* pcPic, Int pocLast, Int pocCurr, Int iNumPicRcvd, Int iGOPid, TComSlice*& rpcSlice, TComSPS* pSPS, TComPPS *pPPS, bool isField ) 190 193 #endif 191 194 { … … 195 198 rpcSlice = pcPic->getSlice(0); 196 199 197 #if H_MV 5200 #if H_MV 198 201 rpcSlice->setVPS( pVPS ); 199 202 … … 203 206 #if H_3D 204 207 rpcSlice->setIsDepth ( pVPS->getDepthId ( layerId ) != 0 ); 205 #endif206 #else207 #if H_3D208 // GT: Should also be activated for MV-HEVC at some stage209 rpcSlice->setVPS( pVPS );210 Int vpsLayerId = pVPS->getLayerIdInNuh( layerId );211 212 rpcSlice->setLayerId ( layerId );213 rpcSlice->setViewId ( pVPS->getViewId ( vpsLayerId ) );214 rpcSlice->setViewIndex ( pVPS->getViewIndex ( vpsLayerId ) );215 rpcSlice->setIsDepth ( pVPS->getDepthId ( vpsLayerId ) != 0 );216 208 #endif 217 209 #endif … … 342 334 Int NumberBFrames = ( m_pcCfg->getGOPSize() - 1 ); 343 335 Int SHIFT_QP = 12; 344 Double dLambda_scale = 1.0 - Clip3( 0.0, 0.5, 0.05*(Double) NumberBFrames);336 Double dLambda_scale = 1.0 - Clip3( 0.0, 0.5, 0.05*(Double)(isField ? NumberBFrames/2 : NumberBFrames) ); 345 337 #if FULL_NBIT 346 338 Int bitdepth_luma_qp_scale = 6 * (g_bitDepth - 8); … … 1125 1117 if(m_pcCfg->getUseRateCtrl()) 1126 1118 { 1119 #if KWU_RC_MADPRED_E0227 1120 if(pcSlice->getLayerId() != 0 && m_pcCfg->getUseDepthMADPred() && !pcSlice->getIsDepth()) 1121 { 1122 Double zn, zf, focallength, position, camshift; 1123 Double basepos; 1124 Bool bInterpolated; 1125 Int direction = pcSlice->getViewId() - pcCU->getSlice()->getIvPic(false, 0)->getViewId(); 1126 1127 pcEncTop->getCamParam()->xGetZNearZFar(pcEncTop->getCamParam()->getBaseViewNumbers()[pcSlice->getViewIndex()], pcSlice->getPOC(), zn, zf); 1128 pcEncTop->getCamParam()->xGetGeometryData(pcEncTop->getCamParam()->getBaseViewNumbers()[0], pcSlice->getPOC(), focallength, basepos, camshift, bInterpolated); 1129 pcEncTop->getCamParam()->xGetGeometryData(pcEncTop->getCamParam()->getBaseViewNumbers()[pcSlice->getViewIndex()], pcSlice->getPOC(), focallength, position, camshift, bInterpolated); 1130 1131 m_pcRateCtrl->updateLCUDataEnhancedView(pcCU, pcCU->getTotalBits(), pcCU->getQP(0), basepos, position, focallength, zn, zf, (direction > 0 ? 1 : -1)); 1132 } 1133 #endif 1127 1134 if(m_pcRateCtrl->calculateUnitQP()) 1128 1135 { … … 1223 1230 else 1224 1231 { 1232 #if KWU_RC_MADPRED_E0227 1233 if(pcSlice->getLayerId() != 0 && m_pcCfg->getUseDepthMADPred() && !pcSlice->getIsDepth()) 1234 { 1235 Double zn, zf, focallength, position, camShift; 1236 Double basePos; 1237 Bool bInterpolated; 1238 Int direction = pcSlice->getViewId() - pcCU->getSlice()->getIvPic(false, 0)->getViewId(); 1239 Int disparity; 1240 1241 pcEncTop->getCamParam()->xGetZNearZFar(pcEncTop->getCamParam()->getBaseViewNumbers()[pcSlice->getViewIndex()], pcSlice->getPOC(), zn, zf); 1242 pcEncTop->getCamParam()->xGetGeometryData(pcEncTop->getCamParam()->getBaseViewNumbers()[0], pcSlice->getPOC(), focallength, basePos, camShift, bInterpolated); 1243 pcEncTop->getCamParam()->xGetGeometryData(pcEncTop->getCamParam()->getBaseViewNumbers()[pcSlice->getViewIndex()], pcSlice->getPOC(), focallength, position, camShift, bInterpolated); 1244 bpp = m_pcRateCtrl->getRCPic()->getLCUTargetBppforInterView( m_pcRateCtrl->getPicList(), pcCU, 1245 basePos, position, focallength, zn, zf, (direction > 0 ? 1 : -1), &disparity ); 1246 } 1247 else 1248 { 1249 #endif 1225 1250 #if RATE_CONTROL_INTRA 1226 1251 bpp = m_pcRateCtrl->getRCPic()->getLCUTargetBpp(pcSlice->getSliceType()); … … 1239 1264 estQP = m_pcRateCtrl->getRCPic()->getLCUEstQP ( estLambda, pcSlice->getSliceQp() ); 1240 1265 #endif 1241 1266 #if KWU_RC_MADPRED_E0227 1267 } 1268 #endif 1269 #if KWU_RC_MADPRED_E0227 1270 estLambda = m_pcRateCtrl->getRCPic()->getLCUEstLambda( bpp ); 1271 estQP = m_pcRateCtrl->getRCPic()->getLCUEstQP ( estLambda, pcSlice->getSliceQp() ); 1272 #endif 1242 1273 estQP = Clip3( -pcSlice->getSPS()->getQpBDOffsetY(), MAX_QP, estQP ); 1243 1274 … … 1343 1374 if ( m_pcCfg->getUseRateCtrl() ) 1344 1375 { 1345 #if !M0036_RC_IMPROVEMENT 1376 #if !M0036_RC_IMPROVEMENT || KWU_RC_MADPRED_E0227 1346 1377 UInt SAD = m_pcCuEncoder->getLCUPredictionSAD(); 1347 1378 Int height = min( pcSlice->getSPS()->getMaxCUHeight(),pcSlice->getSPS()->getPicHeightInLumaSamples() - uiCUAddr / rpcPic->getFrameWidthInCU() * pcSlice->getSPS()->getMaxCUHeight() ); -
trunk/source/Lib/TLibEncoder/TEncSlice.h
r622 r655 116 116 117 117 /// preparation of slice encoding (reference marking, QP and lambda) 118 #if H_MV5119 118 #if H_MV 120 119 Void initEncSlice ( TComPic* pcPic, Int pocLast, Int pocCurr, Int iNumPicRcvd, 121 Int iGOPid, TComSlice*& rpcSlice, TComVPS* pVPS, TComSPS* pSPS, TComPPS *pPPS, Int layerId );120 Int iGOPid, TComSlice*& rpcSlice, TComVPS* pVPS, TComSPS* pSPS, TComPPS *pPPS, Int layerId, bool isField ); 122 121 #else 123 122 Void initEncSlice ( TComPic* pcPic, Int pocLast, Int pocCurr, Int iNumPicRcvd, 124 Int iGOPid, TComSlice*& rpcSlice, TComSPS* pSPS, TComPPS *pPPS ); 125 #endif 126 #else 127 #if H_3D 128 Void initEncSlice ( TComPic* pcPic, Int pocLast, Int pocCurr, Int iNumPicRcvd, 129 Int iGOPid, TComSlice*& rpcSlice, TComVPS* pVPS, TComSPS* pSPS, TComPPS *pPPS, Int layerId ); 130 #else 131 Void initEncSlice ( TComPic* pcPic, Int pocLast, Int pocCurr, Int iNumPicRcvd, 132 Int iGOPid, TComSlice*& rpcSlice, TComSPS* pSPS, TComPPS *pPPS ); 133 #endif 123 Int iGOPid, TComSlice*& rpcSlice, TComSPS* pSPS, TComPPS *pPPS, bool isField ); 134 124 #endif 135 125 #if RATE_CONTROL_LAMBDA_DOMAIN -
trunk/source/Lib/TLibEncoder/TEncTop.cpp
r622 r655 123 123 if ( m_RCEnableRateControl ) 124 124 { 125 #if KWU_RC_MADPRED_E0227 126 m_cRateCtrl.init( m_framesToBeEncoded, m_RCTargetBitrate, m_iFrameRate, m_iGOPSize, m_iSourceWidth, m_iSourceHeight, 127 g_uiMaxCUWidth, g_uiMaxCUHeight, m_RCKeepHierarchicalBit, m_RCUseLCUSeparateModel, m_GOPList, getLayerId() ); 128 #else 125 129 m_cRateCtrl.init( m_framesToBeEncoded, m_RCTargetBitrate, m_iFrameRate, m_iGOPSize, m_iSourceWidth, m_iSourceHeight, 126 130 g_uiMaxCUWidth, g_uiMaxCUHeight, m_RCKeepHierarchicalBit, m_RCUseLCUSeparateModel, m_GOPList ); 131 #endif 127 132 } 128 133 #else 129 m_cRateCtrl.create(getIntraPeriod(), getGOPSize(), getFrameRate(), getTargetBitrate(), getQP(), getNumLCUInUnit(), getSourceWidth(), getSourceHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight); 134 #if KWU_FIX_URQ 135 if(m_enableRateCtrl) 136 #endif 137 m_cRateCtrl.create(getIntraPeriod(), getGOPSize(), getFrameRate(), getTargetBitrate(), getQP(), getNumLCUInUnit(), getSourceWidth(), getSourceHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight); 130 138 #endif 131 139 // if SBAC-based RD optimization is used … … 284 292 } 285 293 286 Void TEncTop::init() 294 #if KWU_RC_MADPRED_E0227 295 Void TEncTop::init(TAppEncTop* pcTAppEncTop, Bool isFieldCoding) 296 #else 297 Void TEncTop::init(Bool isFieldCoding) 298 #endif 287 299 { 288 300 // initialize SPS … … 301 313 m_cPPS.setSPS(&m_cSPS); 302 314 xInitPPS(); 303 xInitRPS( );315 xInitRPS(isFieldCoding); 304 316 305 317 xInitPPSforTiles(); … … 310 322 m_cCuEncoder. init( this ); 311 323 324 #if KWU_RC_MADPRED_E0227 325 m_pcTAppEncTop = pcTAppEncTop; 326 #endif 312 327 // initialize transform & quantization class 313 328 m_pcCavlcCoder = getCavlcCoder(); … … 392 407 if( picLastCoded ) 393 408 { 394 #if MTK_SONY_PROGRESSIVE_MV_COMPRESSION_E0170395 409 picLastCoded->compressMotion(1); 396 #else397 picLastCoded->compressMotion();398 #endif399 410 } 400 411 #endif … … 433 444 #if H_MV 434 445 } 435 m_cGOPEncoder.compressPicInGOP(m_iPOCLast, m_iNumPicRcvd, m_cListPic, rcListPicYuvRecOut, accessUnitsOut, gopId );446 m_cGOPEncoder.compressPicInGOP(m_iPOCLast, m_iNumPicRcvd, m_cListPic, rcListPicYuvRecOut, accessUnitsOut, gopId, false, false ); 436 447 437 448 if( gopId + 1 == m_cGOPEncoder.getGOPSize() ) … … 439 450 #else 440 451 // compress GOP 441 m_cGOPEncoder.compressGOP(m_iPOCLast, m_iNumPicRcvd, m_cListPic, rcListPicYuvRecOut, accessUnitsOut );452 m_cGOPEncoder.compressGOP(m_iPOCLast, m_iNumPicRcvd, m_cListPic, rcListPicYuvRecOut, accessUnitsOut, false, false); 442 453 #endif 443 454 … … 456 467 #endif 457 468 } 469 /**------------------------------------------------ 470 Separate interlaced frame into two fields 471 -------------------------------------------------**/ 472 void separateFields(Pel* org, Pel* dstField, UInt stride, UInt width, UInt height, bool isTop) 473 { 474 if (!isTop) 475 { 476 org += stride; 477 } 478 for (Int y = 0; y < height>>1; y++) 479 { 480 for (Int x = 0; x < width; x++) 481 { 482 dstField[x] = org[x]; 483 } 484 485 dstField += stride; 486 org += stride*2; 487 } 488 489 } 490 491 #if H_MV 492 Void TEncTop::encode(Bool flush, TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsOut, Int& iNumEncoded, bool isTff, Int gopId ) 493 { 494 assert( 0 ); // Field coding and multiview need to be furhter harmonized. 495 } 496 #else 497 Void TEncTop::encode(Bool flush, TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsOut, Int& iNumEncoded, bool isTff) 498 { 499 /* -- TOP FIELD -- */ 500 501 if (pcPicYuvOrg) 502 { 503 504 /* -- Top field initialization -- */ 505 506 TComPic *pcTopField; 507 xGetNewPicBuffer( pcTopField ); 508 pcTopField->getPicSym()->allocSaoParam(&m_cEncSAO); 509 pcTopField->setReconMark (false); 510 511 pcTopField->getSlice(0)->setPOC( m_iPOCLast ); 512 pcTopField->getPicYuvRec()->setBorderExtension(false); 513 pcTopField->setTopField(isTff); 514 515 int nHeight = pcPicYuvOrg->getHeight(); 516 int nWidth = pcPicYuvOrg->getWidth(); 517 int nStride = pcPicYuvOrg->getStride(); 518 int nPadLuma = pcPicYuvOrg->getLumaMargin(); 519 int nPadChroma = pcPicYuvOrg->getChromaMargin(); 520 521 // Get pointers 522 Pel * PicBufY = pcPicYuvOrg->getBufY(); 523 Pel * PicBufU = pcPicYuvOrg->getBufU(); 524 Pel * PicBufV = pcPicYuvOrg->getBufV(); 525 526 Pel * pcTopFieldY = pcTopField->getPicYuvOrg()->getLumaAddr(); 527 Pel * pcTopFieldU = pcTopField->getPicYuvOrg()->getCbAddr(); 528 Pel * pcTopFieldV = pcTopField->getPicYuvOrg()->getCrAddr(); 529 530 // compute image characteristics 531 if ( getUseAdaptiveQP() ) 532 { 533 m_cPreanalyzer.xPreanalyze( dynamic_cast<TEncPic*>( pcTopField ) ); 534 } 535 536 /* -- Defield -- */ 537 538 bool isTop = isTff; 539 540 separateFields(PicBufY + nPadLuma + nStride*nPadLuma, pcTopFieldY, nStride, nWidth, nHeight, isTop); 541 separateFields(PicBufU + nPadChroma + (nStride >> 1)*nPadChroma, pcTopFieldU, nStride >> 1, nWidth >> 1, nHeight >> 1, isTop); 542 separateFields(PicBufV + nPadChroma + (nStride >> 1)*nPadChroma, pcTopFieldV, nStride >> 1, nWidth >> 1, nHeight >> 1, isTop); 543 544 } 545 546 if (m_iPOCLast == 0) // compress field 0 547 { 548 m_cGOPEncoder.compressGOP(m_iPOCLast, m_iNumPicRcvd, m_cListPic, rcListPicYuvRecOut, accessUnitsOut, true, isTff); 549 } 550 551 /* -- BOTTOM FIELD -- */ 552 553 if (pcPicYuvOrg) 554 { 555 556 /* -- Bottom field initialization -- */ 557 558 TComPic* pcBottomField; 559 xGetNewPicBuffer( pcBottomField ); 560 pcBottomField->getPicSym()->allocSaoParam(&m_cEncSAO); 561 pcBottomField->setReconMark (false); 562 563 TComPicYuv* rpcPicYuvRec = new TComPicYuv; 564 if ( rcListPicYuvRecOut.size() == (UInt)m_iGOPSize ) 565 { 566 rpcPicYuvRec = rcListPicYuvRecOut.popFront(); 567 } 568 else 569 { 570 rpcPicYuvRec->create( m_iSourceWidth, m_iSourceHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth ); 571 } 572 rcListPicYuvRecOut.pushBack( rpcPicYuvRec ); 573 574 pcBottomField->getSlice(0)->setPOC( m_iPOCLast); 575 pcBottomField->getPicYuvRec()->setBorderExtension(false); 576 pcBottomField->setTopField(!isTff); 577 578 int nHeight = pcPicYuvOrg->getHeight(); 579 int nWidth = pcPicYuvOrg->getWidth(); 580 int nStride = pcPicYuvOrg->getStride(); 581 int nPadLuma = pcPicYuvOrg->getLumaMargin(); 582 int nPadChroma = pcPicYuvOrg->getChromaMargin(); 583 584 // Get pointers 585 Pel * PicBufY = pcPicYuvOrg->getBufY(); 586 Pel * PicBufU = pcPicYuvOrg->getBufU(); 587 Pel * PicBufV = pcPicYuvOrg->getBufV(); 588 589 Pel * pcBottomFieldY = pcBottomField->getPicYuvOrg()->getLumaAddr(); 590 Pel * pcBottomFieldU = pcBottomField->getPicYuvOrg()->getCbAddr(); 591 Pel * pcBottomFieldV = pcBottomField->getPicYuvOrg()->getCrAddr(); 592 593 // Compute image characteristics 594 if ( getUseAdaptiveQP() ) 595 { 596 m_cPreanalyzer.xPreanalyze( dynamic_cast<TEncPic*>( pcBottomField ) ); 597 } 598 599 /* -- Defield -- */ 600 601 bool isTop = !isTff; 602 603 separateFields(PicBufY + nPadLuma + nStride*nPadLuma, pcBottomFieldY, nStride, nWidth, nHeight, isTop); 604 separateFields(PicBufU + nPadChroma + (nStride >> 1)*nPadChroma, pcBottomFieldU, nStride >> 1, nWidth >> 1, nHeight >> 1, isTop); 605 separateFields(PicBufV + nPadChroma + (nStride >> 1)*nPadChroma, pcBottomFieldV, nStride >> 1, nWidth >> 1, nHeight >> 1, isTop); 606 607 } 608 609 if ( ( !(m_iNumPicRcvd) || (!flush && m_iPOCLast != 1 && m_iNumPicRcvd != m_iGOPSize && m_iGOPSize)) ) 610 { 611 iNumEncoded = 0; 612 return; 613 } 614 615 // compress GOP 616 m_cGOPEncoder.compressGOP(m_iPOCLast, m_iNumPicRcvd, m_cListPic, rcListPicYuvRecOut, accessUnitsOut, true, isTff); 617 618 iNumEncoded = m_iNumPicRcvd; 619 m_iNumPicRcvd = 0; 620 m_uiNumAllPicCoded += iNumEncoded; 621 } 622 #endif 623 624 458 625 459 626 // ==================================================================================================================== … … 551 718 * that chooses the actual compatibility based upon options */ 552 719 553 #if H_MV5554 720 #if H_MV 555 721 m_cSPS.setUpdateRepFormatFlag ( m_layerId == 0 ); 556 722 m_cSPS.setSpsInferScalingListFlag ( m_layerId > 0 && m_cVPS->getInDirectDependencyFlag( getLayerIdInVps(), 0 ) ); 557 723 m_cSPS.setSpsScalingListRefLayerId ( 0 ); 558 #endif559 724 #endif 560 725 m_cSPS.setPicWidthInLumaSamples ( m_iSourceWidth ); … … 680 845 { 681 846 #if H_MV 682 #if H_MV5683 847 m_cPPS.setLayerId( getLayerId() ); 684 848 if( getVPS()->getNumDirectRefLayers( getLayerId() ) > 0 ) 685 #else686 if( getVPS()->getNumDirectRefLayers( getLayerIdInVps() ) > 0 )687 #endif688 849 { 689 850 m_cPPS.setListsModificationPresentFlag( true ); … … 734 895 #if RATE_CONTROL_LAMBDA_DOMAIN 735 896 if ( m_RCEnableRateControl ) 897 { 898 m_cPPS.setUseDQP(true); 899 m_cPPS.setMaxCuDQPDepth( 0 ); 900 m_cPPS.setMinCuDQPSize( m_cPPS.getSPS()->getMaxCUWidth() >> ( m_cPPS.getMaxCuDQPDepth()) ); 901 } 902 #endif 903 #if !RATE_CONTROL_LAMBDA_DOMAIN && KWU_FIX_URQ 904 if ( m_enableRateCtrl ) 736 905 { 737 906 m_cPPS.setUseDQP(true); … … 751 920 m_cPPS.setOutputFlagPresentFlag( false ); 752 921 #if H_MV 753 #if H_MV5754 922 m_cPPS.setNumExtraSliceHeaderBits( 2 ); 755 #else756 m_cPPS.setNumExtraSliceHeaderBits( 1 );757 #endif758 923 #endif 759 924 m_cPPS.setSignHideFlag(getSignHideFlag()); 760 m_cPPS.setDeblockingFilterControlPresentFlag (m_DeblockingFilterControlPresent ); 925 if ( getDeblockingFilterMetric() ) 926 { 927 m_cPPS.setDeblockingFilterControlPresentFlag (true); 928 m_cPPS.setDeblockingFilterOverrideEnabledFlag(true); 929 m_cPPS.setPicDisableDeblockingFilterFlag(false); 930 m_cPPS.setDeblockingFilterBetaOffsetDiv2(0); 931 m_cPPS.setDeblockingFilterTcOffsetDiv2(0); 932 } 933 else 934 { 935 m_cPPS.setDeblockingFilterControlPresentFlag (m_DeblockingFilterControlPresent ); 936 } 761 937 m_cPPS.setLog2ParallelMergeLevelMinus2 (m_log2ParallelMergeLevelMinus2 ); 762 938 m_cPPS.setCabacInitPresentFlag(CABAC_INIT_PRESENT_FLAG); … … 812 988 813 989 //Function for initializing m_RPSList, a list of TComReferencePictureSet, based on the GOPEntry objects read from the config file. 814 Void TEncTop::xInitRPS( )990 Void TEncTop::xInitRPS(Bool isFieldCoding) 815 991 { 816 992 TComReferencePictureSet* rps; 817 993 818 m_cSPS.createRPSList(getGOPSize()+m_extraRPSs );994 m_cSPS.createRPSList(getGOPSize()+m_extraRPSs+1); 819 995 TComRPSList* rpsList = m_cSPS.getRPSList(); 820 996 … … 913 1089 printf("Warning: number of negative pictures in RPS is different between intra and inter RPS specified in the config file.\n"); 914 1090 rps->setNumberOfNegativePictures(numNeg); 915 rps->setNumberOfP ositivePictures(numNeg+numPos);1091 rps->setNumberOfPictures(numNeg+numPos); 916 1092 } 917 1093 if (numPos != rps->getNumberOfPositivePictures()) … … 919 1095 printf("Warning: number of positive pictures in RPS is different between intra and inter RPS specified in the config file.\n"); 920 1096 rps->setNumberOfPositivePictures(numPos); 921 rps->setNumberOfP ositivePictures(numNeg+numPos);1097 rps->setNumberOfPictures(numNeg+numPos); 922 1098 } 923 1099 RPSTemp.setNumberOfPictures(numNeg+numPos); … … 983 1159 #endif //INTER_RPS_AUTO 984 1160 } 985 1161 //In case of field coding, we need to set special parameters for the first bottom field of the sequence, since it is not specified in the cfg file. 1162 //The position = GOPSize + extraRPSs which is (a priori) unused is reserved for this field in the RPS. 1163 if (isFieldCoding) 1164 { 1165 rps = rpsList->getReferencePictureSet(getGOPSize()+m_extraRPSs); 1166 rps->setNumberOfPictures(1); 1167 rps->setNumberOfNegativePictures(1); 1168 rps->setNumberOfPositivePictures(0); 1169 rps->setNumberOfLongtermPictures(0); 1170 rps->setDeltaPOC(0,-1); 1171 rps->setPOC(0,0); 1172 rps->setUsed(0,true); 1173 rps->setInterRPSPrediction(false); 1174 rps->setDeltaRIdxMinus1(0); 1175 rps->setDeltaRPS(0); 1176 rps->setNumRefIdc(0); 1177 } 986 1178 } 987 1179 … … 1028 1220 } 1029 1221 } 1222 if(POCCurr == 1 && slice->getPic()->isField()) 1223 { 1224 slice->setRPSidx(m_iGOPSize+m_extraRPSs); 1225 } 1030 1226 1031 1227 slice->setRPS(getSPS()->getRPSList()->getReferencePictureSet(slice->getRPSidx())); … … 1147 1343 } 1148 1344 #if H_MV 1149 Void TEncTop::printSummary( Int numAllPicCoded ) 1150 { 1345 Void TEncTop::printSummary( Int numAllPicCoded, Bool isField ) 1346 { 1347 assert ( !isField ); // Multiview and field coding need to be further unified 1151 1348 assert (numAllPicCoded == m_cAnalyzeAll.getNumPic()); 1152 1349 -
trunk/source/Lib/TLibEncoder/TEncTop.h
r608 r655 64 64 // ==================================================================================================================== 65 65 66 #if KWU_RC_MADPRED_E0227 67 class TAppEncTop; 68 #endif 66 69 /// encoder class 67 70 class TEncTop : public TEncCfg … … 124 127 TComScalingList m_scalingList; ///< quantization matrix information 125 128 TEncRateCtrl m_cRateCtrl; ///< Rate control class 129 130 #if KWU_RC_MADPRED_E0227 131 TAppEncTop* m_pcTAppEncTop; 132 TAppComCamPara* m_cCamParam; 133 #endif 126 134 127 135 #if H_MV … … 137 145 138 146 Void xInitPPSforTiles (); 139 Void xInitRPS ( );///< initialize PPS from encoder options147 Void xInitRPS (Bool isFieldCoding); ///< initialize PPS from encoder options 140 148 141 149 public: … … 145 153 Void create (); 146 154 Void destroy (); 147 Void init (); 155 #if KWU_RC_MADPRED_E0227 156 Void init ( TAppEncTop* pcTAppEncTop, Bool isFieldCoding ); 157 #else 158 Void init (Bool isFieldCoding); 159 #endif 160 148 161 #if H_MV 149 162 TComPicLists* getIvPicLists() { return m_ivPicLists; } … … 185 198 TEncSbac* getRDGoOnSbacCoders () { return m_pcRDGoOnSbacCoders; } 186 199 TEncRateCtrl* getRateCtrl () { return &m_cRateCtrl; } 200 #if KWU_RC_MADPRED_E0227 201 TAppEncTop* getEncTop () { return m_pcTAppEncTop; } 202 TAppComCamPara* getCamParam() { return m_cCamParam;} 203 Void setCamParam(TAppComCamPara * pCamparam) { m_cCamParam = pCamparam;} 204 #endif 187 205 TComSPS* getSPS () { return &m_cSPS; } 188 206 TComPPS* getPPS () { return &m_cPPS; } … … 210 228 #if H_MV 211 229 Void encode( Bool bEos, TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsOut, Int& iNumEncoded , Int gopId ); 230 231 /// encode several number of pictures until end-of-sequence 232 Void encode( bool bEos, TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut, 233 std::list<AccessUnit>& accessUnitsOut, Int& iNumEncoded, bool isTff , Int gopId ); 234 212 235 #else 213 236 Void encode( Bool bEos, TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut, 214 std::list<AccessUnit>& accessUnitsOut, Int& iNumEncoded ); 215 #endif 216 217 #if H_MV 218 Void printSummary ( Int numAllPicCoded ); 219 #else 220 void printSummary() { m_cGOPEncoder.printOutSummary (m_uiNumAllPicCoded); } 237 std::list<AccessUnit>& accessUnitsOut, Int& iNumEncoded ); 238 /// encode several number of pictures until end-of-sequence 239 Void encode( bool bEos, TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut, 240 std::list<AccessUnit>& accessUnitsOut, Int& iNumEncoded, bool isTff); 241 242 #endif 243 244 #if H_MV 245 Void printSummary ( Int numAllPicCoded, bool isField ); 246 #else 247 Void printSummary(bool isField) { m_cGOPEncoder.printOutSummary (m_uiNumAllPicCoded, isField); } 221 248 #endif 222 249
Note: See TracChangeset for help on using the changeset viewer.