Changeset 442 in SHVCSoftware for trunk/source/Lib/TLibEncoder
- Timestamp:
- 21 Oct 2013, 13:41:29 (11 years ago)
- Location:
- trunk
- Files:
-
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/SHM-3.0-dev merged: 350-351,357-360 /branches/SHM-3.1-dev (added) merged: 354-356,361-403,405-441 /trunk merged: 352 reverse-merged: 312-314
- Property svn:mergeinfo changed
-
trunk/source
- Property svn:mergeinfo changed
/branches/SHM-3.0-dev/source merged: 357-360 /branches/SHM-3.1-dev/source (added) merged: 355-356,361-364,366-403,405,407-441 /trunk/source merged: 352 reverse-merged: 312-314
- Property svn:mergeinfo changed
-
trunk/source/Lib/TLibEncoder/SEIwrite.cpp
r313 r442 95 95 fprintf( g_hTrace, "=========== SOP Description SEI message ===========\n"); 96 96 break; 97 #if N0383_IL_CONSTRAINED_TILE_SETS_SEI 98 case SEI::INTER_LAYER_CONSTRAINED_TILE_SETS: 99 fprintf( g_hTrace, "=========== Inter Layer Constrained Tile Sets SEI message ===========\n"); 100 break; 101 #endif 97 102 case SEI::SCALABLE_NESTING: 98 103 fprintf( g_hTrace, "=========== Scalable Nesting SEI message ===========\n"); … … 153 158 xWriteSEISOPDescription(*static_cast<const SEISOPDescription*>(&sei)); 154 159 break; 160 #if N0383_IL_CONSTRAINED_TILE_SETS_SEI 161 case SEI::INTER_LAYER_CONSTRAINED_TILE_SETS: 162 xWriteSEIInterLayerConstrainedTileSets(*static_cast<const SEIInterLayerConstrainedTileSets*>(&sei)); 163 break; 164 #endif 155 165 case SEI::SCALABLE_NESTING: 156 166 xWriteSEIScalableNesting(bs, *static_cast<const SEIScalableNesting*>(&sei), sps); … … 559 569 } 560 570 571 #if N0383_IL_CONSTRAINED_TILE_SETS_SEI 572 Void SEIWriter::xWriteSEIInterLayerConstrainedTileSets(const SEIInterLayerConstrainedTileSets& sei) 573 { 574 WRITE_FLAG( sei.m_ilAllTilesExactSampleValueMatchFlag, "il_all_tiles_exact_sample_value_match_flag" ); 575 WRITE_FLAG( sei.m_ilOneTilePerTileSetFlag, "il_one_tile_per_tile_set_flag" ); 576 if( !sei.m_ilOneTilePerTileSetFlag ) 577 { 578 WRITE_UVLC( sei.m_ilNumSetsInMessageMinus1, "il_num_sets_in_message_minus1" ); 579 if( sei.m_ilNumSetsInMessageMinus1 ) 580 { 581 WRITE_FLAG( sei.m_skippedTileSetPresentFlag, "skipped_tile_set_present_flag" ); 582 } 583 UInt numSignificantSets = sei.m_ilNumSetsInMessageMinus1 - (sei.m_skippedTileSetPresentFlag ? 1 : 0) + 1; 584 for( UInt i = 0; i < numSignificantSets; i++ ) 585 { 586 WRITE_UVLC( sei.m_ilctsId[i], "ilcts_id" ); 587 WRITE_UVLC( sei.m_ilNumTileRectsInSetMinus1[i], "il_num_tile_rects_in_set_minus1" ); 588 for( UInt j = 0; j <= sei.m_ilNumTileRectsInSetMinus1[i]; j++ ) 589 { 590 WRITE_UVLC( sei.m_ilTopLeftTileIndex[i][j], "il_top_left_tile_index" ); 591 WRITE_UVLC( sei.m_ilBottomRightTileIndex[i][j], "il_bottom_right_tile_index" ); 592 } 593 WRITE_CODE( sei.m_ilcIdc[i], 2, "ilc_idc" ); 594 if( sei.m_ilAllTilesExactSampleValueMatchFlag ) 595 { 596 WRITE_FLAG( sei.m_ilExactSampleValueMatchFlag[i], "il_exact_sample_value_match_flag" ); 597 } 598 } 599 } 600 else 601 { 602 WRITE_CODE( sei.m_allTilesIlcIdc, 2, "all_tiles_ilc_idc" ); 603 } 604 605 xWriteByteAlign(); 606 } 607 #endif 608 561 609 Void SEIWriter::xWriteSEIScalableNesting(TComBitIf& bs, const SEIScalableNesting& sei, TComSPS *sps) 562 610 { -
trunk/source/Lib/TLibEncoder/SEIwrite.h
r313 r442 68 68 #endif 69 69 Void xWriteSEISOPDescription(const SEISOPDescription& sei); 70 #if N0383_IL_CONSTRAINED_TILE_SETS_SEI 71 Void xWriteSEIInterLayerConstrainedTileSets(const SEIInterLayerConstrainedTileSets& sei); 72 #endif 70 73 Void xWriteSEIScalableNesting(TComBitIf& bs, const SEIScalableNesting& sei, TComSPS *sps); 71 74 Void xWriteByteAlign(); -
trunk/source/Lib/TLibEncoder/TEncAnalyze.cpp
r313 r442 57 57 #endif 58 58 59 TEncAnalyze m_gcAnalyzeAll_in; 59 60 //! \} -
trunk/source/Lib/TLibEncoder/TEncAnalyze.h
r313 r442 131 131 fclose(pFile); 132 132 } 133 134 Void printOutInterlaced ( Char cDelim, Double bits ) 135 { 136 Double dFps = m_dFrmRate; //--CFG_KDY 137 Double dScale = dFps / 1000 / (Double)m_uiNumPic; 138 139 printf( "\tTotal Frames | " "Bitrate " "Y-PSNR " "U-PSNR " "V-PSNR \n" ); 140 //printf( "\t------------ " " ----------" " -------- " " -------- " " --------\n" ); 141 printf( "\t %8d %c" "%12.4lf " "%8.4lf " "%8.4lf " "%8.4lf\n", 142 getNumPic(), cDelim, 143 bits * dScale, 144 getPsnrY() / (Double)getNumPic(), 145 getPsnrU() / (Double)getNumPic(), 146 getPsnrV() / (Double)getNumPic() ); 147 } 148 149 Void printSummaryOutInterlaced (Int bits) 150 { 151 FILE* pFile = fopen ("summaryTotal.txt", "at"); 152 Double dFps = m_dFrmRate; //--CFG_KDY 153 Double dScale = dFps / 1000 / (Double)m_uiNumPic; 154 155 fprintf(pFile, "%f\t %f\t %f\t %f\n", bits * dScale, 156 getPsnrY() / (Double)getNumPic(), 157 getPsnrU() / (Double)getNumPic(), 158 getPsnrV() / (Double)getNumPic() ); 159 fclose(pFile); 160 } 133 161 134 162 Void printSummary(Char ch) … … 178 206 #endif 179 207 208 extern TEncAnalyze m_gcAnalyzeAll_in; 180 209 //! \} 181 210 -
trunk/source/Lib/TLibEncoder/TEncCavlc.cpp
r345 r442 221 221 } 222 222 WRITE_FLAG( pcPPS->getScalingListPresentFlag() ? 1 : 0, "pps_scaling_list_data_present_flag" ); 223 224 #if IL_SL_SIGNALLING_N0371 225 pcPPS->setPPS( pcPPS->getLayerId(), pcPPS ); 226 #endif 227 223 228 if( pcPPS->getScalingListPresentFlag() ) 224 229 { … … 226 231 printf("PPS\n"); 227 232 #endif 233 234 #if IL_SL_SIGNALLING_N0371 235 m_pcSlice->getScalingList()->setLayerId( pcPPS->getLayerId() ); 236 237 if( pcPPS->getLayerId() > 0 ) 238 { 239 WRITE_FLAG( pcPPS->getPredScalingListFlag() ? 1 : 0, "pps_pred_scaling_list_flag" ); 240 m_pcSlice->getScalingList()->setPredScalingListFlag( pcPPS->getPredScalingListFlag() ); 241 242 if( pcPPS->getPredScalingListFlag() ) 243 { 244 // The value of pps_scaling_list_ref_layer_id shall be in the range of 0 to 62, inclusive 245 assert( /*pcPPS->getScalingListRefLayerId() >= 0 &&*/ pcPPS->getScalingListRefLayerId() <= 62 ); 246 247 // When avc_base_layer_flag is equal to 1, it is a requirement of bitstream conformance that the value of pps_scaling_list_ref_layer_id shall be greater than 0 248 if( pcPPS->getSPS()->getVPS()->getAvcBaseLayerFlag() ) 249 { 250 assert( pcPPS->getScalingListRefLayerId() > 0 ); 251 } 252 253 // It is a requirement of bitstream conformance that, when a PPS with nuh_layer_id equal to nuhLayerIdA is active for a layer with nuh_layer_id equal to nuhLayerIdB and 254 // pps_infer_scaling_list_flag in the PPS is equal to 1, pps_infer_scaling_list_flag shall be equal to 0 for the PPS that is active for the layer with nuh_layer_id equal to pps_scaling_list_ref_layer_id 255 assert( pcPPS->getPPS( pcPPS->getScalingListRefLayerId() )->getPredScalingListFlag() == false ); 256 257 // It is a requirement of bitstream conformance that, when a PPS with nuh_layer_id equal to nuhLayerIdA is active for a layer with nuh_layer_id equal to nuhLayerIdB, 258 // the layer with nuh_layer_id equal to pps_scaling_list_ref_layer_id shall be a direct or indirect reference layer of the layer with nuh_layer_id equal to nuhLayerIdB 259 assert( pcPPS->getSPS()->getVPS()->getScalingListLayerDependency( pcPPS->getLayerId(), pcPPS->getScalingListRefLayerId() ) == true ); 260 261 WRITE_UVLC( pcPPS->getScalingListRefLayerId(), "scaling_list_pps_ref_layer_id" ); 262 m_pcSlice->getScalingList()->setScalingListRefLayerId( pcPPS->getScalingListRefLayerId() ); 263 codeScalingList( m_pcSlice->getScalingList() ); 264 } 265 else 266 { 267 codeScalingList( m_pcSlice->getScalingList() ); 268 } 269 } 270 else 271 { 272 codeScalingList( m_pcSlice->getScalingList() ); 273 } 274 #else 228 275 codeScalingList( m_pcSlice->getScalingList() ); 276 #endif 277 229 278 } 230 279 WRITE_FLAG( pcPPS->getListsModificationPresentFlag(), "lists_modification_present_flag"); … … 414 463 } 415 464 #endif 465 #ifdef SPS_PTL_FIX 466 if (pcSPS->getLayerId() == 0) 467 { 468 codePTL(pcSPS->getPTL(), 1, pcSPS->getMaxTLayers() - 1); 469 } 470 #else 416 471 codePTL(pcSPS->getPTL(), 1, pcSPS->getMaxTLayers() - 1); 472 #endif 417 473 WRITE_UVLC( pcSPS->getSPSId (), "sps_seq_parameter_set_id" ); 418 WRITE_UVLC( pcSPS->getChromaFormatIdc (), "chroma_format_idc" ); 419 assert(pcSPS->getChromaFormatIdc () == 1); 420 // in the first version chroma_format_idc can only be equal to 1 (4:2:0) 421 if( pcSPS->getChromaFormatIdc () == 3 ) 422 { 423 WRITE_FLAG( 0, "separate_colour_plane_flag"); 424 } 425 426 WRITE_UVLC( pcSPS->getPicWidthInLumaSamples (), "pic_width_in_luma_samples" ); 427 WRITE_UVLC( pcSPS->getPicHeightInLumaSamples(), "pic_height_in_luma_samples" ); 474 #if REPN_FORMAT_IN_VPS 475 if( pcSPS->getLayerId() > 0 ) 476 { 477 WRITE_FLAG( pcSPS->getUpdateRepFormatFlag(), "update_rep_format_flag" ); 478 } 479 if( pcSPS->getLayerId() == 0 || pcSPS->getUpdateRepFormatFlag() ) 480 { 481 #endif 482 WRITE_UVLC( pcSPS->getChromaFormatIdc (), "chroma_format_idc" ); 483 assert(pcSPS->getChromaFormatIdc () == 1); 484 // in the first version chroma_format_idc can only be equal to 1 (4:2:0) 485 if( pcSPS->getChromaFormatIdc () == 3 ) 486 { 487 WRITE_FLAG( 0, "separate_colour_plane_flag"); 488 } 489 490 WRITE_UVLC( pcSPS->getPicWidthInLumaSamples (), "pic_width_in_luma_samples" ); 491 WRITE_UVLC( pcSPS->getPicHeightInLumaSamples(), "pic_height_in_luma_samples" ); 492 #if REPN_FORMAT_IN_VPS 493 } 494 #endif 428 495 Window conf = pcSPS->getConformanceWindow(); 429 496 … … 437 504 } 438 505 439 WRITE_UVLC( pcSPS->getBitDepthY() - 8, "bit_depth_luma_minus8" ); 440 WRITE_UVLC( pcSPS->getBitDepthC() - 8, "bit_depth_chroma_minus8" ); 441 506 #if REPN_FORMAT_IN_VPS 507 if( pcSPS->getLayerId() == 0 || pcSPS->getUpdateRepFormatFlag() ) 508 { 509 assert( pcSPS->getBitDepthY() >= 8 ); 510 assert( pcSPS->getBitDepthC() >= 8 ); 511 #endif 512 WRITE_UVLC( pcSPS->getBitDepthY() - 8, "bit_depth_luma_minus8" ); 513 WRITE_UVLC( pcSPS->getBitDepthC() - 8, "bit_depth_chroma_minus8" ); 514 #if REPN_FORMAT_IN_VPS 515 } 516 #endif 442 517 WRITE_UVLC( pcSPS->getBitsForPOC()-4, "log2_max_pic_order_cnt_lsb_minus4" ); 443 518 … … 463 538 WRITE_UVLC( pcSPS->getQuadtreeTUMaxDepthIntra() - 1, "max_transform_hierarchy_depth_intra" ); 464 539 WRITE_FLAG( pcSPS->getScalingListFlag() ? 1 : 0, "scaling_list_enabled_flag" ); 540 541 #if IL_SL_SIGNALLING_N0371 542 pcSPS->setSPS( pcSPS->getLayerId(), pcSPS ); 543 #endif 544 465 545 if(pcSPS->getScalingListFlag()) 466 546 { … … 471 551 printf("SPS\n"); 472 552 #endif 553 554 #if IL_SL_SIGNALLING_N0371 555 m_pcSlice->getScalingList()->setLayerId( pcSPS->getLayerId() ); 556 557 if( pcSPS->getLayerId() > 0 ) 558 { 559 WRITE_FLAG( pcSPS->getPredScalingListFlag() ? 1 : 0, "sps_pred_scaling_list_flag" ); 560 m_pcSlice->getScalingList()->setPredScalingListFlag( pcSPS->getPredScalingListFlag() ); 561 562 if( pcSPS->getPredScalingListFlag() ) 563 { 564 565 // The value of sps_scaling_list_ref_layer_id shall be in the range of 0 to 62, inclusive 566 assert( /*pcSPS->getScalingListRefLayerId() >= 0 &&*/ pcSPS->getScalingListRefLayerId() <= 62 ); 567 568 // When avc_base_layer_flag is equal to 1, it is a requirement of bitstream conformance that the value of sps_scaling_list_ref_layer_id shall be greater than 0 569 if( pcSPS->getVPS()->getAvcBaseLayerFlag() ) 570 { 571 assert( pcSPS->getScalingListRefLayerId() > 0 ); 572 } 573 574 // It is a requirement of bitstream conformance that, when an SPS with nuh_layer_id equal to nuhLayerIdA is active for a layer with nuh_layer_id equal to nuhLayerIdB and 575 // sps_infer_scaling_list_flag in the SPS is equal to 1, sps_infer_scaling_list_flag shall be equal to 0 for the SPS that is active for the layer with nuh_layer_id equal to sps_scaling_list_ref_layer_id 576 assert( pcSPS->getSPS( pcSPS->getScalingListRefLayerId() )->getPredScalingListFlag() == false ); 577 578 // It is a requirement of bitstream conformance that, when an SPS with nuh_layer_id equal to nuhLayerIdA is active for a layer with nuh_layer_id equal to nuhLayerIdB, 579 // the layer with nuh_layer_id equal to sps_scaling_list_ref_layer_id shall be a direct or indirect reference layer of the layer with nuh_layer_id equal to nuhLayerIdB 580 assert( pcSPS->getVPS()->getScalingListLayerDependency( pcSPS->getLayerId(), pcSPS->getScalingListRefLayerId() ) == true ); 581 582 WRITE_UVLC( pcSPS->getScalingListRefLayerId(), "scaling_list_sps_ref_layer_id" ); 583 m_pcSlice->getScalingList()->setScalingListRefLayerId( pcSPS->getScalingListRefLayerId() ); 584 codeScalingList( m_pcSlice->getScalingList() ); 585 } 586 else 587 { 588 codeScalingList( m_pcSlice->getScalingList() ); 589 } 590 } 591 else 592 { 473 593 codeScalingList( m_pcSlice->getScalingList() ); 594 } 595 #else 596 codeScalingList( m_pcSlice->getScalingList() ); 597 #endif 598 474 599 } 475 600 } … … 491 616 TComRPSList* rpsList = pcSPS->getRPSList(); 492 617 TComReferencePictureSet* rps; 493 618 494 619 WRITE_UVLC(rpsList->getNumberOfReferencePictureSets(), "num_short_term_ref_pic_sets" ); 495 620 for(Int i=0; i < rpsList->getNumberOfReferencePictureSets(); i++) … … 540 665 { 541 666 // more syntax elements to be written here 667 668 #if VERT_MV_CONSTRAINT 669 // Vertical MV component restriction is not used in SHVC CTC 670 WRITE_FLAG( 0, "inter_view_mv_vert_constraint_flag" ); 671 #endif 542 672 #if SCALED_REF_LAYER_OFFSETS 543 #if SCALED_REF_LAYER_OFFSET_FLAG544 WRITE_FLAG( pcSPS->getLayerId() > 0, "scaled_ref_layer_offset_present_flag" );545 673 if( pcSPS->getLayerId() > 0 ) 546 #else547 if( pcSPS->getLayerId() > 0 )548 #endif549 674 { 550 675 WRITE_UVLC( pcSPS->getNumScaledRefLayerOffsets(), "num_scaled_ref_layer_offsets" ); … … 593 718 WRITE_FLAG( pcVPS->getTemporalNestingFlag(), "vps_temporal_id_nesting_flag" ); 594 719 assert (pcVPS->getMaxTLayers()>1||pcVPS->getTemporalNestingFlag()); 720 #if VPS_EXTN_OFFSET 721 WRITE_CODE( pcVPS->getExtensionOffset(), 16, "vps_extension_offset" ); 722 #else 595 723 WRITE_CODE( 0xffff, 16, "vps_reserved_ffff_16bits" ); 724 #endif 596 725 codePTL( pcVPS->getPTL(), true, pcVPS->getMaxTLayers() - 1 ); 597 726 const Bool subLayerOrderingInfoPresentFlag = 1; … … 676 805 #else 677 806 WRITE_FLAG( 1, "vps_extension_flag" ); 678 codeVPSExtension(pcVPS); 679 WRITE_FLAG( 0, "vps_extension2_flag" ); // Flag value of 1 reserved 807 if(1) // Should be conditioned on the value of vps_extension_flag 808 { 809 while ( m_pcBitIf->getNumberOfWrittenBits() % 8 != 0 ) 810 { 811 WRITE_FLAG(1, "vps_extension_alignment_bit_equal_to_one"); 812 } 813 codeVPSExtension(pcVPS); 814 WRITE_FLAG( 0, "vps_extension2_flag" ); // Flag value of 1 reserved 815 } 680 816 #endif 681 817 //future extensions here.. … … 737 873 } 738 874 #endif 875 #if VIEW_ID_RELATED_SIGNALING 876 // if ( pcVPS->getNumViews() > 1 ) 877 // However, this is a bug in the text since, view_id_len_minus1 is needed to parse view_id_val. 878 { 879 WRITE_CODE( vps->getViewIdLenMinus1( ), 4, "view_id_len_minus1" ); 880 } 881 882 for( i = 0; i < vps->getNumViews(); i++ ) 883 { 884 WRITE_CODE( vps->getViewIdVal( i ), vps->getViewIdLenMinus1( ) + 1, "view_id_val[i]" ); 885 } 886 #endif 739 887 #if VPS_MOVE_DIR_DEPENDENCY_FLAG 740 888 #if VPS_EXTN_DIRECT_REF_LAYERS … … 750 898 #if JCTVC_M0203_INTERLAYER_PRED_IDC 751 899 #if N0120_MAX_TID_REF_PRESENT_FLAG 752 WRITE_FLAG( vps->getMaxTid IlRefPicsPlus1PresentFlag(), "max_tid_il_ref_pics_plus1_present_flag");753 if (vps->getMaxTid IlRefPicsPlus1PresentFlag())900 WRITE_FLAG( vps->getMaxTidRefPresentFlag(), "max_tid_ref_present_flag"); 901 if (vps->getMaxTidRefPresentFlag()) 754 902 { 755 903 for( i = 0; i < vps->getMaxLayers() - 1; i++) 756 904 { 757 WRITE_CODE(vps->getMax SublayerForIlpPlus1(i), 3, "max_sublayer_for_ilp_plus1[i]" );905 WRITE_CODE(vps->getMaxTidIlRefPicsPlus1(i), 3, "max_tid_il_ref_pics_plus1[i]" ); 758 906 } 759 907 } … … 761 909 for( i = 0; i < vps->getMaxLayers() - 1; i++) 762 910 { 763 WRITE_CODE(vps->getMax SublayerForIlpPlus1(i), 3, "max_sublayer_for_ilp_plus1[i]" );911 WRITE_CODE(vps->getMaxTidIlRefPicsPlus1(i), 3, "max_tid_il_ref_pics_plus1[i]" ); 764 912 } 765 913 #endif … … 849 997 #endif 850 998 #endif 999 1000 #if REPN_FORMAT_IN_VPS 1001 WRITE_FLAG( vps->getRepFormatIdxPresentFlag(), "rep_format_idx_present_flag"); 1002 1003 if( vps->getRepFormatIdxPresentFlag() ) 1004 { 1005 WRITE_CODE( vps->getVpsNumRepFormats() - 1, 4, "vps_num_rep_formats_minus1" ); 1006 } 1007 for(i = 0; i < vps->getVpsNumRepFormats(); i++) 1008 { 1009 // Read rep_format_structures 1010 codeRepFormat( vps->getVpsRepFormat(i) ); 1011 } 1012 1013 if( vps->getRepFormatIdxPresentFlag() ) 1014 { 1015 for(i = 1; i < vps->getMaxLayers(); i++) 1016 { 1017 if( vps->getVpsNumRepFormats() > 1 ) 1018 { 1019 WRITE_CODE( vps->getVpsRepFormatIdx(i), 4, "vps_rep_format_idx[i]" ); 1020 } 1021 } 1022 } 1023 #endif 1024 851 1025 #if JCTVC_M0458_INTERLAYER_RPS_SIG 852 1026 WRITE_FLAG(vps->getMaxOneActiveRefLayerFlag(), "max_one_active_ref_layer_flag"); 1027 #endif 1028 #if N0147_IRAP_ALIGN_FLAG 1029 WRITE_FLAG(vps->getCrossLayerIrapAlignFlag(), "cross_layer_irap_aligned_flag"); 853 1030 #endif 854 1031 #if !VPS_MOVE_DIR_DEPENDENCY_FLAG … … 875 1052 } 876 1053 } 1054 1055 #if IL_SL_SIGNALLING_N0371 1056 for(i = 1; i < vps->getMaxLayers(); i++) 1057 { 1058 for(j = 0; j < i; j++) 1059 { 1060 vps->setScalingListLayerDependency( i, j, vps->checkLayerDependency( i,j ) ); 1061 } 1062 } 1063 #endif 1064 877 1065 #endif 878 1066 #if M0040_ADAPTIVE_RESOLUTION_CHANGE 879 1067 WRITE_FLAG(vps->getSingleLayerForNonIrapFlag(), "single_layer_for_non_irap_flag" ); 880 1068 #endif 1069 1070 #if !VPS_VUI 1071 WRITE_FLAG( 0, "vps_vui_present_flag" ); 1072 #else 1073 WRITE_FLAG( 1, "vps_vui_present_flag" ); 1074 if(1) // Should be conditioned on the value of vps_vui_present_flag 1075 { 1076 while ( m_pcBitIf->getNumberOfWrittenBits() % 8 != 0 ) 1077 { 1078 WRITE_FLAG(1, "vps_vui_alignment_bit_equal_to_one"); 1079 } 1080 codeVPSVUI(vps); 1081 } 1082 #endif 1083 } 1084 #endif 1085 #if REPN_FORMAT_IN_VPS 1086 Void TEncCavlc::codeRepFormat ( RepFormat *repFormat ) 1087 { 1088 WRITE_CODE( repFormat->getChromaFormatVpsIdc(), 2, "chroma_format_idc" ); 1089 1090 if( repFormat->getChromaFormatVpsIdc() == 3 ) 1091 { 1092 WRITE_FLAG( repFormat->getSeparateColourPlaneVpsFlag(), "separate_colour_plane_flag"); 1093 } 1094 1095 WRITE_CODE ( repFormat->getPicWidthVpsInLumaSamples (), 16, "pic_width_in_luma_samples" ); 1096 WRITE_CODE ( repFormat->getPicHeightVpsInLumaSamples(), 16, "pic_height_in_luma_samples" ); 1097 1098 assert( repFormat->getBitDepthVpsLuma() >= 8 ); 1099 assert( repFormat->getBitDepthVpsChroma() >= 8 ); 1100 WRITE_CODE( repFormat->getBitDepthVpsLuma() - 8, 4, "bit_depth_luma_minus8" ); 1101 WRITE_CODE( repFormat->getBitDepthVpsChroma() - 8, 4, "bit_depth_chroma_minus8" ); 1102 1103 } 1104 #endif 1105 #if VPS_VUI 1106 Void TEncCavlc::codeVPSVUI (TComVPS *vps) 1107 { 1108 Int i,j; 1109 #if VPS_VUI_BITRATE_PICRATE 1110 WRITE_FLAG( vps->getBitRatePresentVpsFlag(), "bit_rate_present_vps_flag" ); 1111 WRITE_FLAG( vps->getPicRatePresentVpsFlag(), "pic_rate_present_vps_flag" ); 1112 1113 if( vps->getBitRatePresentVpsFlag() || vps->getPicRatePresentVpsFlag() ) 1114 { 1115 for( i = 0; i < vps->getNumLayerSets(); i++ ) 1116 { 1117 for( j = 0; j < vps->getMaxTLayers(); j++ ) 1118 { 1119 if( vps->getBitRatePresentVpsFlag() ) 1120 { 1121 WRITE_FLAG( vps->getBitRatePresentFlag( i, j), "bit_rate_present_vps_flag[i][j]" ); 1122 } 1123 if( vps->getPicRatePresentVpsFlag() ) 1124 { 1125 WRITE_FLAG( vps->getPicRatePresentFlag( i, j), "pic_rate_present_vps_flag[i][j]" ); 1126 } 1127 if( vps->getBitRatePresentFlag(i, j) ) 1128 { 1129 WRITE_CODE( vps->getAvgBitRate( i, j ), 16, "avg_bit_rate[i][j]" ); 1130 WRITE_CODE( vps->getAvgBitRate( i, j ), 16, "max_bit_rate[i][j]" ); 1131 } 1132 if( vps->getPicRatePresentFlag(i, j) ) 1133 { 1134 WRITE_CODE( vps->getConstPicRateIdc( i, j), 2 , "constant_pic_rate_idc[i][j]" ); 1135 WRITE_CODE( vps->getConstPicRateIdc( i, j), 16, "avg_pic_rate[i][j]" ); 1136 } 1137 } 1138 } 1139 } 1140 #endif 1141 #if TILE_BOUNDARY_ALIGNED_FLAG 1142 for(i = 1; i < vps->getMaxLayers(); i++) 1143 { 1144 for(j = 0; j < vps->getNumDirectRefLayers(vps->getLayerIdInNuh(i)); j++) 1145 { 1146 WRITE_FLAG( vps->getTileBoundariesAlignedFlag(i,j) ? 1 : 0 , "tile_boundaries_aligned_flag[i][j]" ); 1147 } 1148 } 1149 #endif 1150 #if N0160_VUI_EXT_ILP_REF 1151 WRITE_FLAG( vps->getNumIlpRestrictedRefLayers() ? 1 : 0 , "num_ilp_restricted_ref_layers" ); 1152 if( vps->getNumIlpRestrictedRefLayers()) 1153 { 1154 for(i = 1; i < vps->getMaxLayers(); i++) 1155 { 1156 for(j = 0; j < vps->getNumDirectRefLayers(vps->getLayerIdInNuh(i)); j++) 1157 { 1158 WRITE_UVLC(vps->getMinSpatialSegmentOffsetPlus1( i, j), "min_spatial_segment_offset_plus1[i][j]"); 1159 1160 if( vps->getMinSpatialSegmentOffsetPlus1(i,j ) > 0 ) 1161 { 1162 WRITE_FLAG( vps->getCtuBasedOffsetEnabledFlag( i, j) ? 1 : 0 , "ctu_based_offset_enabled_flag[i][j]" ); 1163 1164 if(vps->getCtuBasedOffsetEnabledFlag(i,j)) 1165 { 1166 WRITE_UVLC(vps->getMinHorizontalCtuOffsetPlus1( i, j), "min_horizontal_ctu_offset_plus1[i][j]"); 1167 } 1168 } 1169 } 1170 } 1171 } 1172 #endif 881 1173 } 882 1174 #endif … … 927 1219 { 928 1220 1221 #if POC_RESET_FLAG 1222 Int iBits = 0; 1223 if( pcSlice->getPPS()->getNumExtraSliceHeaderBits() > iBits ) 1224 { 1225 WRITE_FLAG( pcSlice->getPocResetFlag(), "poc_reset_flag" ); 1226 iBits++; 1227 } 1228 if( pcSlice->getPPS()->getNumExtraSliceHeaderBits() > iBits ) 1229 { 1230 assert(!!"discardable_flag"); 1231 WRITE_FLAG(pcSlice->getDiscardableFlag(), "discardable_flag"); 1232 iBits++; 1233 } 1234 for ( ; iBits < pcSlice->getPPS()->getNumExtraSliceHeaderBits(); iBits++) 1235 { 1236 assert(!!"slice_reserved_undetermined_flag[]"); 1237 WRITE_FLAG(0, "slice_reserved_undetermined_flag[]"); 1238 } 1239 #else 929 1240 #if SH_DISCARDABLE_FLAG 930 1241 if (pcSlice->getPPS()->getNumExtraSliceHeaderBits()>0) … … 945 1256 } 946 1257 #endif 1258 #endif 947 1259 948 1260 WRITE_UVLC( pcSlice->getSliceType(), "slice_type" ); … … 953 1265 } 954 1266 1267 #if REPN_FORMAT_IN_VPS 1268 // in the first version chroma_format_idc is equal to one, thus colour_plane_id will not be present 1269 assert( pcSlice->getChromaFormatIdc() == 1 ); 1270 #else 955 1271 // in the first version chroma_format_idc is equal to one, thus colour_plane_id will not be present 956 1272 assert (pcSlice->getSPS()->getChromaFormatIdc() == 1 ); 1273 #endif 957 1274 // if( separate_colour_plane_flag == 1 ) 958 1275 // colour_plane_id u(2) 959 1276 1277 #if N0065_LAYER_POC_ALIGNMENT 1278 if( pcSlice->getLayerId() > 0 || !pcSlice->getIdrPicFlag() ) 1279 #else 960 1280 if( !pcSlice->getIdrPicFlag() ) 961 { 962 Int picOrderCntLSB = (pcSlice->getPOC()-pcSlice->getLastIDR()+(1<<pcSlice->getSPS()->getBitsForPOC()))%(1<<pcSlice->getSPS()->getBitsForPOC()); 1281 #endif 1282 { 1283 #if POC_RESET_FLAG 1284 Int picOrderCntLSB; 1285 if( !pcSlice->getPocResetFlag() ) 1286 { 1287 picOrderCntLSB = (pcSlice->getPOC()-pcSlice->getLastIDR()+(1<<pcSlice->getSPS()->getBitsForPOC())) & ((1<<pcSlice->getSPS()->getBitsForPOC())-1); 1288 } 1289 else 1290 { 1291 picOrderCntLSB = (pcSlice->getPocValueBeforeReset()-pcSlice->getLastIDR()+(1<<pcSlice->getSPS()->getBitsForPOC())) & ((1<<pcSlice->getSPS()->getBitsForPOC())-1); 1292 } 1293 #else 1294 Int picOrderCntLSB = (pcSlice->getPOC()-pcSlice->getLastIDR()+(1<<pcSlice->getSPS()->getBitsForPOC())) & ((1<<pcSlice->getSPS()->getBitsForPOC())-1); 1295 #endif 963 1296 WRITE_CODE( picOrderCntLSB, pcSlice->getSPS()->getBitsForPOC(), "pic_order_cnt_lsb"); 1297 1298 #if N0065_LAYER_POC_ALIGNMENT 1299 if( !pcSlice->getIdrPicFlag() ) 1300 { 1301 #endif 964 1302 TComReferencePictureSet* rps = pcSlice->getRPS(); 965 1303 … … 1076 1414 WRITE_FLAG( pcSlice->getEnableTMVPFlag() ? 1 : 0, "slice_temporal_mvp_enable_flag" ); 1077 1415 } 1416 #if N0065_LAYER_POC_ALIGNMENT 1417 } 1418 #endif 1078 1419 } 1079 1420 … … 1224 1565 if ( pcSlice->getEnableTMVPFlag() ) 1225 1566 { 1226 #if REF_IDX_FRAMEWORK&& M0457_COL_PICTURE_SIGNALING && !REMOVE_COL_PICTURE_SIGNALING1567 #if SVC_EXTENSION && M0457_COL_PICTURE_SIGNALING && !REMOVE_COL_PICTURE_SIGNALING 1227 1568 if ( !pcSlice->getIdrPicFlag() && pcSlice->getLayerId() > 0 && pcSlice->getActiveNumILRRefIdx() > 0 && pcSlice->getNumMotionPredRefLayers() > 0 ) 1228 1569 { … … 1247 1588 WRITE_UVLC( pcSlice->getColRefIdx(), "collocated_ref_idx" ); 1248 1589 } 1249 #if REF_IDX_FRAMEWORK&& M0457_COL_PICTURE_SIGNALING && !REMOVE_COL_PICTURE_SIGNALING1590 #if SVC_EXTENSION && M0457_COL_PICTURE_SIGNALING && !REMOVE_COL_PICTURE_SIGNALING 1250 1591 } 1251 1592 #endif … … 1554 1895 Int iDQp = pcCU->getQP( uiAbsPartIdx ) - pcCU->getRefQP( uiAbsPartIdx ); 1555 1896 1897 #if REPN_FORMAT_IN_VPS 1898 Int qpBdOffsetY = pcCU->getSlice()->getQpBDOffsetY(); 1899 #else 1556 1900 Int qpBdOffsetY = pcCU->getSlice()->getSPS()->getQpBDOffsetY(); 1901 #endif 1557 1902 iDQp = (iDQp + 78 + qpBdOffsetY + (qpBdOffsetY/2)) % (52 + qpBdOffsetY) - 26 - (qpBdOffsetY/2); 1558 1903 … … 1682 2027 startBit = m_pcBitIf->getNumberOfWrittenBits(); 1683 2028 #endif 2029 2030 #if IL_SL_SIGNALLING_N0371 2031 if( scalingList->getLayerId() > 0 && scalingList->getPredScalingListFlag() ) 2032 { 2033 scalingListPredModeFlag = scalingList->checkPredMode( sizeId, listId ); 2034 WRITE_FLAG( scalingListPredModeFlag, "scaling_list_pred_mode_flag" ); 2035 if(!scalingListPredModeFlag)// Copy Mode 2036 { 2037 WRITE_UVLC( (Int)listId - (Int)scalingList->getRefMatrixId (sizeId,listId), "scaling_list_pred_matrix_id_delta"); 2038 } 2039 else// DPCM Mode 2040 { 2041 xCodeScalingList(scalingList, sizeId, listId); 2042 } 2043 } 2044 else 2045 { 2046 scalingListPredModeFlag = scalingList->checkPredMode( sizeId, listId ); 2047 WRITE_FLAG( scalingListPredModeFlag, "scaling_list_pred_mode_flag" ); 2048 if(!scalingListPredModeFlag)// Copy Mode 2049 { 2050 WRITE_UVLC( (Int)listId - (Int)scalingList->getRefMatrixId (sizeId,listId), "scaling_list_pred_matrix_id_delta"); 2051 } 2052 else// DPCM Mode 2053 { 2054 xCodeScalingList(scalingList, sizeId, listId); 2055 } 2056 } 2057 #else 1684 2058 scalingListPredModeFlag = scalingList->checkPredMode( sizeId, listId ); 1685 2059 WRITE_FLAG( scalingListPredModeFlag, "scaling_list_pred_mode_flag" ); … … 1692 2066 xCodeScalingList(scalingList, sizeId, listId); 1693 2067 } 2068 #endif 2069 1694 2070 #if SCALING_LIST_OUTPUT_RESULT 1695 2071 printf("Matrix [%d][%d] Bit %d\n",sizeId,listId,m_pcBitIf->getNumberOfWrittenBits() - startBit); 1696 2072 #endif 2073 1697 2074 } 1698 2075 } … … 1714 2091 Int data; 1715 2092 Int *src = scalingList->getScalingListAddress(sizeId, listId); 2093 1716 2094 if( sizeId > SCALING_LIST_8x8 ) 1717 2095 { 2096 #if IL_SL_SIGNALLING_N0371 2097 if( scalingList->getLayerId() > 0 && scalingList->getPredScalingListFlag() ) 2098 { 2099 ref_scalingListDC[scalingList->getLayerId()][sizeId][listId] = scalingList->getScalingListDC(sizeId,listId); 2100 scalingList->setScalingListDC(sizeId,listId,ref_scalingListDC[scalingList->getScalingListRefLayerId()][sizeId][listId]); 2101 } 2102 else 2103 { 2104 WRITE_SVLC( scalingList->getScalingListDC(sizeId,listId) - 8, "scaling_list_dc_coef_minus8"); 2105 nextCoef = scalingList->getScalingListDC(sizeId,listId); 2106 ref_scalingListDC[scalingList->getLayerId()][sizeId][listId] = scalingList->getScalingListDC(sizeId,listId); 2107 } 2108 #else 1718 2109 WRITE_SVLC( scalingList->getScalingListDC(sizeId,listId) - 8, "scaling_list_dc_coef_minus8"); 1719 2110 nextCoef = scalingList->getScalingListDC(sizeId,listId); 2111 #endif 1720 2112 } 1721 2113 for(Int i=0;i<coefNum;i++) 1722 2114 { 2115 #if IL_SL_SIGNALLING_N0371 2116 if( scalingList->getLayerId() > 0 && scalingList->getPredScalingListFlag() ) 2117 { 2118 ref_scalingListCoef[scalingList->getLayerId()][sizeId][listId][i] = src[scan[i]]; 2119 src[scan[i]] = ref_scalingListCoef[scalingList->getScalingListRefLayerId()][sizeId][listId][i]; 2120 } 2121 else 2122 { 2123 data = src[scan[i]] - nextCoef; 2124 ref_scalingListCoef[scalingList->getLayerId()][sizeId][listId][i] = src[scan[i]]; 2125 nextCoef = src[scan[i]]; 2126 if(data > 127) 2127 { 2128 data = data - 256; 2129 } 2130 if(data < -128) 2131 { 2132 data = data + 256; 2133 } 2134 2135 WRITE_SVLC( data, "scaling_list_delta_coef"); 2136 } 2137 #else 1723 2138 data = src[scan[i]] - nextCoef; 1724 2139 nextCoef = src[scan[i]]; … … 1733 2148 1734 2149 WRITE_SVLC( data, "scaling_list_delta_coef"); 2150 #endif 1735 2151 } 1736 2152 } … … 1738 2154 { 1739 2155 // Bool state = true, state2 = false; 1740 Int lsb = ltrpPOC % (1<<pcSlice->getSPS()->getBitsForPOC());2156 Int lsb = ltrpPOC & ((1<<pcSlice->getSPS()->getBitsForPOC())-1); 1741 2157 for (Int k = 0; k < pcSlice->getSPS()->getNumLongTermRefPicSPS(); k++) 1742 2158 { -
trunk/source/Lib/TLibEncoder/TEncCavlc.h
r345 r442 87 87 Void codeVPSExtension ( TComVPS* pcVPS ); 88 88 #endif 89 90 #if VPS_VUI 91 Void codeVPSVUI (TComVPS *vps); 92 #endif 93 #if REPN_FORMAT_IN_VPS 94 Void codeRepFormat ( RepFormat *repFormat ); 95 #endif 89 96 Void codeVUI ( TComVUI *pcVUI, TComSPS* pcSPS ); 90 97 Void codeSPS ( TComSPS* pcSPS ); -
trunk/source/Lib/TLibEncoder/TEncCfg.h
r313 r442 69 69 Int m_numRefIdc; 70 70 Int m_refIdc[MAX_NUM_REF_PICS+1]; 71 #if EXTERNAL_USEDBYCURR_N0082 72 Int m_UseExtusedByCurrPic; 73 Int m_ExtusedByCurrPic[MAX_NUM_REF_PICS]; 74 #endif 71 75 GOPEntry() 72 76 : m_POC(-1) … … 83 87 , m_deltaRPS(0) 84 88 , m_numRefIdc(0) 89 #if EXTERNAL_USEDBYCURR_N0082 90 , m_UseExtusedByCurrPic(0) 91 #endif 85 92 { 86 93 ::memset( m_referencePics, 0, sizeof(m_referencePics) ); 87 94 ::memset( m_usedByCurrPic, 0, sizeof(m_usedByCurrPic) ); 88 95 ::memset( m_refIdc, 0, sizeof(m_refIdc) ); 96 #if EXTERNAL_USEDBYCURR_N0082 97 ::memset( m_usedByCurrPic, 0, sizeof(m_ExtusedByCurrPic) ); 98 #endif 89 99 } 90 100 }; 91 101 92 102 std::istringstream &operator>>(std::istringstream &in, GOPEntry &entry); //input 103 104 #if REPN_FORMAT_IN_VPS 105 struct RepFormatCfg 106 { 107 Int m_chromaFormatIdc; 108 Bool m_separateColourPlaneFlag; 109 Int m_picWidthInLumaSamples; 110 Int m_picHeightInLumaSamples; 111 Int m_bitDepthLuma; 112 Int m_bitDepthChroma; 113 RepFormatCfg() 114 : m_chromaFormatIdc (CHROMA_420) 115 , m_separateColourPlaneFlag (0) 116 , m_picWidthInLumaSamples (352) 117 , m_picHeightInLumaSamples (288) 118 , m_bitDepthLuma (8) 119 , m_bitDepthChroma (8) 120 {} 121 }; 122 std::istringstream &operator>>(std::istringstream &in, RepFormatCfg &repFormatCfg); 123 #endif 124 93 125 //! \ingroup TLibEncoder 94 126 //! \{ … … 155 187 #endif 156 188 #endif 189 #if N0120_MAX_TID_REF_CFG 190 Int m_maxTidIlRefPicsPlus1; 191 #endif 157 192 //======= Transform ============= 158 193 UInt m_uiQuadtreeTULog2MaxSize; … … 283 318 Int m_SOPDescriptionSEIEnabled; 284 319 Int m_scalableNestingSEIEnabled; 320 #if N0383_IL_CONSTRAINED_TILE_SETS_SEI 321 Bool m_interLayerConstrainedTileSetsSEIEnabled; 322 UInt m_ilNumSetsInMessage; 323 Bool m_skippedTileSetPresentFlag; 324 UInt m_topLeftTileIndex[1024]; 325 UInt m_bottomRightTileIndex[1024]; 326 UInt m_ilcIdc[1024]; 327 #endif 285 328 //====== Weighted Prediction ======== 286 329 Bool m_useWeightedPred; //< Use of Weighting Prediction (P_SLICE) … … 353 396 UInt m_layerId; 354 397 UInt m_numLayer; 355 #endif 356 #if REF_IDX_FRAMEWORK 357 Int m_elRapSliceBEnabled; 358 #endif 398 Int m_elRapSliceBEnabled; 359 399 #if M0040_ADAPTIVE_RESOLUTION_CHANGE 360 Int m_adaptiveResolutionChange; 400 Int m_adaptiveResolutionChange; 401 #endif 361 402 #endif 362 403 … … 438 479 #endif 439 480 #endif 481 #if N0120_MAX_TID_REF_CFG 482 Int getMaxTidIlRefPicsPlus1 () { return m_maxTidIlRefPicsPlus1; } 483 Void setMaxTidIlRefPicsPlus1 (Int num) { m_maxTidIlRefPicsPlus1 = num; } 484 #endif 440 485 //======== Transform ============= 441 486 Void setQuadtreeTULog2MaxSize ( UInt u ) { m_uiQuadtreeTULog2MaxSize = u; } … … 720 765 Void setScalableNestingSEIEnabled(Int b) { m_scalableNestingSEIEnabled = b; } 721 766 Int getScalableNestingSEIEnabled() { return m_scalableNestingSEIEnabled; } 767 #if N0383_IL_CONSTRAINED_TILE_SETS_SEI 768 Void setInterLayerConstrainedTileSetsSEIEnabled(Bool b) { m_interLayerConstrainedTileSetsSEIEnabled = b; } 769 Bool getInterLayerConstrainedTileSetsSEIEnabled() { return m_interLayerConstrainedTileSetsSEIEnabled; } 770 Void setIlNumSetsInMessage(UInt b) { m_ilNumSetsInMessage = b; } 771 Int getIlNumSetsInMessage() { return m_ilNumSetsInMessage; } 772 Void setSkippedTileSetPresentFlag(Bool b) { m_skippedTileSetPresentFlag = b; } 773 Bool getSkippedTileSetPresentFlag() { return m_skippedTileSetPresentFlag; } 774 Void setTopLeftTileIndex(UInt *b) 775 { 776 for (UInt i = 0; i < m_ilNumSetsInMessage; i++) 777 { 778 m_topLeftTileIndex[i] = b[i]; 779 } 780 } 781 UInt getTopLeftTileIndex(UInt b) { return m_topLeftTileIndex[b]; } 782 Void setBottomRightTileIndex(UInt *b) 783 { 784 for (UInt i = 0; i < m_ilNumSetsInMessage; i++) 785 { 786 m_bottomRightTileIndex[i] = b[i]; 787 } 788 } 789 UInt getBottomRightTileIndex(UInt b) { return m_bottomRightTileIndex[b]; } 790 Void setIlcIdc(UInt *b) 791 { 792 for (UInt i = 0; i < m_ilNumSetsInMessage; i++) 793 { 794 m_ilcIdc[i] = b[i]; 795 } 796 } 797 UInt getIlcIdc(UInt b) { return m_ilcIdc[b]; } 798 #endif 722 799 Void setUseWP ( Bool b ) { m_useWeightedPred = b; } 723 800 Void setWPBiPred ( Bool b ) { m_useWeightedBiPred = b; } … … 858 935 Void setConformanceMode (Int mode) { m_conformanceMode = mode; } 859 936 Void setConformanceWindow(Window& conformanceWindow ) { m_conformanceWindow = conformanceWindow; } 860 #endif861 #if REF_IDX_FRAMEWORK862 937 Void setElRapSliceTypeB(Int bEnabled) {m_elRapSliceBEnabled = bEnabled;} 863 938 Int getElRapSliceTypeB() {return m_elRapSliceBEnabled;} 864 #endif865 939 #if M0040_ADAPTIVE_RESOLUTION_CHANGE 866 940 Void setAdaptiveResolutionChange(Int x) { m_adaptiveResolutionChange = x; } 867 941 Int getAdaptiveResolutionChange() { return m_adaptiveResolutionChange; } 868 942 #endif 943 #endif 869 944 }; 870 945 -
trunk/source/Lib/TLibEncoder/TEncCu.cpp
r345 r442 379 379 m_ppcOrigYuv[uiDepth]->copyFromPicYuv( pcPic->getPicYuvOrg(), rpcBestCU->getAddr(), rpcBestCU->getZorderIdxInCU() ); 380 380 381 // variables for fast encoder decision382 Bool bEarlySkip = false;383 Bool bTrySplit = true;384 Double fRD_Skip = MAX_DOUBLE;385 386 381 // variable for Early CU determination 387 382 Bool bSubBranch = true; … … 390 385 Bool doNotBlockPu = true; 391 386 Bool earlyDetectionSkipMode = false; 392 393 Bool bTrySplitDQP = true;394 395 static Double afCost[ MAX_CU_DEPTH ];396 static Int aiNum [ MAX_CU_DEPTH ];397 398 if ( rpcBestCU->getAddr() == 0 )399 {400 ::memset( afCost, 0, sizeof( afCost ) );401 ::memset( aiNum, 0, sizeof( aiNum ) );402 }403 387 404 388 Bool bBoundary = false; … … 412 396 Int iMaxQP; 413 397 Bool isAddLowestQP = false; 398 #if REPN_FORMAT_IN_VPS 399 Int lowestQP = -rpcTempCU->getSlice()->getQpBDOffsetY(); 400 #else 414 401 Int lowestQP = -rpcTempCU->getSlice()->getSPS()->getQpBDOffsetY(); 402 #endif 415 403 416 404 if( (g_uiMaxCUWidth>>uiDepth) >= rpcTempCU->getSlice()->getPPS()->getMinCuDQPSize() ) 417 405 { 418 406 Int idQP = m_pcEncCfg->getMaxDeltaQP(); 407 #if REPN_FORMAT_IN_VPS 419 408 iMinQP = Clip3( -rpcTempCU->getSlice()->getSPS()->getQpBDOffsetY(), MAX_QP, iBaseQP-idQP ); 420 409 iMaxQP = Clip3( -rpcTempCU->getSlice()->getSPS()->getQpBDOffsetY(), MAX_QP, iBaseQP+idQP ); 410 #else 411 iMinQP = Clip3( -rpcTempCU->getSlice()->getSPS()->getQpBDOffsetY(), MAX_QP, iBaseQP-idQP ); 412 iMaxQP = Clip3( -rpcTempCU->getSlice()->getSPS()->getQpBDOffsetY(), MAX_QP, iBaseQP+idQP ); 413 #endif 421 414 if ( (rpcTempCU->getSlice()->getSPS()->getUseLossless()) && (lowestQP < iMinQP) && rpcTempCU->getSlice()->getPPS()->getUseDQP() ) 422 415 { … … 450 443 Bool bSliceStart = pcSlice->getSliceSegmentCurStartCUAddr()>rpcTempCU->getSCUAddr()&&pcSlice->getSliceSegmentCurStartCUAddr()<rpcTempCU->getSCUAddr()+rpcTempCU->getTotalNumPart(); 451 444 Bool bSliceEnd = (pcSlice->getSliceSegmentCurEndCUAddr()>rpcTempCU->getSCUAddr()&&pcSlice->getSliceSegmentCurEndCUAddr()<rpcTempCU->getSCUAddr()+rpcTempCU->getTotalNumPart()); 445 #if REPN_FORMAT_IN_VPS 446 Bool bInsidePicture = ( uiRPelX < rpcBestCU->getSlice()->getPicWidthInLumaSamples() ) && ( uiBPelY < rpcBestCU->getSlice()->getPicHeightInLumaSamples() ); 447 #else 452 448 Bool bInsidePicture = ( uiRPelX < rpcBestCU->getSlice()->getSPS()->getPicWidthInLumaSamples() ) && ( uiBPelY < rpcBestCU->getSlice()->getSPS()->getPicHeightInLumaSamples() ); 449 #endif 453 450 // We need to split, so don't try these modes. 454 451 if(!bSliceEnd && !bSliceStart && bInsidePicture ) … … 458 455 if (rpcBestCU->getLayerId() > 0) 459 456 { 460 if(pcSlice->getSliceType() == P_SLICE && pcSlice->getNumRefIdx(REF_PIC_LIST_0) == pcSlice->getActiveNumILRRefIdx()) 461 testInter = false; 462 if(pcSlice->getSliceType() == B_SLICE && pcSlice->getNumRefIdx(REF_PIC_LIST_0) == pcSlice->getActiveNumILRRefIdx() && pcSlice->getNumRefIdx(REF_PIC_LIST_1) == pcSlice->getActiveNumILRRefIdx()) 463 testInter = false; 457 if(pcSlice->getSliceType() == P_SLICE && pcSlice->getNumRefIdx(REF_PIC_LIST_0) == pcSlice->getActiveNumILRRefIdx()) 458 { 459 testInter = false; 460 } 461 if(pcSlice->getSliceType() == B_SLICE && pcSlice->getNumRefIdx(REF_PIC_LIST_0) == pcSlice->getActiveNumILRRefIdx() && pcSlice->getNumRefIdx(REF_PIC_LIST_1) == pcSlice->getActiveNumILRRefIdx()) 462 { 463 testInter = false; 464 } 464 465 #if M0457_IL_SAMPLE_PRED_ONLY_FLAG 465 if( pcSlice->getInterLayerSamplePredOnlyFlag() ) 466 testInter = false; 466 if( pcSlice->getInterLayerSamplePredOnlyFlag() ) 467 { 468 testInter = false; 469 } 467 470 #endif 468 471 } … … 474 477 iQP = lowestQP; 475 478 } 476 // variables for fast encoder decision477 bEarlySkip = false;478 bTrySplit = true;479 fRD_Skip = MAX_DOUBLE;480 479 481 480 rpcTempCU->initEstData( uiDepth, iQP ); … … 496 495 xCheckRDCostMerge2Nx2N( rpcBestCU, rpcTempCU, &earlyDetectionSkipMode );//by Merge for inter_2Nx2N 497 496 rpcTempCU->initEstData( uiDepth, iQP ); 498 499 // fast encoder decision for early skip 500 if ( m_pcEncCfg->getUseFastEnc() ) 501 { 502 Int iIdx = g_aucConvertToBit[ rpcBestCU->getWidth(0) ]; 503 if ( aiNum [ iIdx ] > 5 && fRD_Skip < EARLY_SKIP_THRES*afCost[ iIdx ]/aiNum[ iIdx ] ) 504 { 505 bEarlySkip = true; 506 bTrySplit = false; 507 } 508 } 497 509 498 #if (ENCODER_FAST_MODE == 2) 510 499 if (testInter) 511 500 { 512 501 #endif 513 514 502 if(!m_pcEncCfg->getUseEarlySkipDetection()) 515 503 { 516 504 // 2Nx2N, NxN 517 if ( !bEarlySkip ) 505 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2Nx2N ); rpcTempCU->initEstData( uiDepth, iQP ); 506 if(m_pcEncCfg->getUseCbfFastMode()) 518 507 { 519 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_2Nx2N ); rpcTempCU->initEstData( uiDepth, iQP ); 520 if(m_pcEncCfg->getUseCbfFastMode()) 521 { 522 doNotBlockPu = rpcBestCU->getQtRootCbf( 0 ) != 0; 523 } 508 doNotBlockPu = rpcBestCU->getQtRootCbf( 0 ) != 0; 524 509 } 525 510 } 526 511 #if (ENCODER_FAST_MODE == 2) 527 } 528 #endif 529 530 } 531 532 if( (g_uiMaxCUWidth>>uiDepth) >= rpcTempCU->getSlice()->getPPS()->getMinCuDQPSize() ) 533 { 534 if(iQP == iBaseQP) 535 { 536 bTrySplitDQP = bTrySplit; 537 } 538 } 539 else 540 { 541 bTrySplitDQP = bTrySplit; 542 } 512 } 513 #endif 514 } 515 543 516 if (isAddLowestQP && (iQP == lowestQP)) 544 517 { … … 567 540 // do inter modes, NxN, 2NxN, and Nx2N 568 541 #if (ENCODER_FAST_MODE) 569 if( rpcBestCU->getSlice()->getSliceType() != I_SLICE && testInter )542 if( rpcBestCU->getSlice()->getSliceType() != I_SLICE && testInter ) 570 543 #else 571 544 if( rpcBestCU->getSlice()->getSliceType() != I_SLICE ) … … 573 546 { 574 547 // 2Nx2N, NxN 575 if ( !bEarlySkip)548 if(!( (rpcBestCU->getWidth(0)==8) && (rpcBestCU->getHeight(0)==8) )) 576 549 { 577 if( !( (rpcBestCU->getWidth(0)==8) && (rpcBestCU->getHeight(0)==8) ))550 if( uiDepth == g_uiMaxCUDepth - g_uiAddCUDepth && doNotBlockPu) 578 551 { 579 if( uiDepth == g_uiMaxCUDepth - g_uiAddCUDepth && doNotBlockPu) 580 { 581 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_NxN ); 582 rpcTempCU->initEstData( uiDepth, iQP ); 583 } 552 xCheckRDCostInter( rpcBestCU, rpcTempCU, SIZE_NxN ); 553 rpcTempCU->initEstData( uiDepth, iQP ); 584 554 } 585 555 } … … 721 691 722 692 // do normal intra modes 723 if ( !bEarlySkip )724 {725 693 // speedup for inter frames 726 694 #if (ENCODER_FAST_MODE) … … 748 716 } 749 717 } 750 }751 718 752 719 // test PCM … … 790 757 rpcBestCU->getTotalCost() = m_pcRdCost->calcRdCost( rpcBestCU->getTotalBits(), rpcBestCU->getTotalDistortion() ); 791 758 792 // accumulate statistics for early skip793 if ( m_pcEncCfg->getUseFastEnc() )794 {795 if ( rpcBestCU->isSkipped(0) )796 {797 Int iIdx = g_aucConvertToBit[ rpcBestCU->getWidth(0) ];798 afCost[ iIdx ] += rpcBestCU->getTotalCost();799 aiNum [ iIdx ] ++;800 }801 }802 803 759 // Early CU determination 804 760 if( m_pcEncCfg->getUseEarlyCU() && rpcBestCU->isSkipped(0) ) … … 827 783 { 828 784 Int idQP = m_pcEncCfg->getMaxDeltaQP(); 785 #if REPN_FORMAT_IN_VPS 786 iMinQP = Clip3( -rpcTempCU->getSlice()->getQpBDOffsetY(), MAX_QP, iBaseQP-idQP ); 787 iMaxQP = Clip3( -rpcTempCU->getSlice()->getQpBDOffsetY(), MAX_QP, iBaseQP+idQP ); 788 #else 829 789 iMinQP = Clip3( -rpcTempCU->getSlice()->getSPS()->getQpBDOffsetY(), MAX_QP, iBaseQP-idQP ); 830 790 iMaxQP = Clip3( -rpcTempCU->getSlice()->getSPS()->getQpBDOffsetY(), MAX_QP, iBaseQP+idQP ); 791 #endif 831 792 if ( (rpcTempCU->getSlice()->getSPS()->getUseLossless()) && (lowestQP < iMinQP) && rpcTempCU->getSlice()->getPPS()->getUseDQP() ) 832 793 { … … 878 839 879 840 // further split 880 if( bSubBranch && bTrySplitDQP &&uiDepth < g_uiMaxCUDepth - g_uiAddCUDepth )841 if( bSubBranch && uiDepth < g_uiMaxCUDepth - g_uiAddCUDepth ) 881 842 { 882 843 UChar uhNextDepth = uiDepth+1; … … 890 851 891 852 Bool bInSlice = pcSubBestPartCU->getSCUAddr()+pcSubBestPartCU->getTotalNumPart()>pcSlice->getSliceSegmentCurStartCUAddr()&&pcSubBestPartCU->getSCUAddr()<pcSlice->getSliceSegmentCurEndCUAddr(); 853 #if REPN_FORMAT_IN_VPS 854 if(bInSlice && ( pcSubBestPartCU->getCUPelX() < pcSlice->getPicWidthInLumaSamples() ) && ( pcSubBestPartCU->getCUPelY() < pcSlice->getPicHeightInLumaSamples() ) ) 855 #else 892 856 if(bInSlice && ( pcSubBestPartCU->getCUPelX() < pcSlice->getSPS()->getPicWidthInLumaSamples() ) && ( pcSubBestPartCU->getCUPelY() < pcSlice->getSPS()->getPicHeightInLumaSamples() ) ) 857 #endif 893 858 { 894 859 if( m_bUseSBACRD ) … … 1038 1003 UInt uiPosX = ( uiExternalAddress % pcPic->getFrameWidthInCU() ) * g_uiMaxCUWidth+ g_auiRasterToPelX[ g_auiZscanToRaster[uiInternalAddress] ]; 1039 1004 UInt uiPosY = ( uiExternalAddress / pcPic->getFrameWidthInCU() ) * g_uiMaxCUHeight+ g_auiRasterToPelY[ g_auiZscanToRaster[uiInternalAddress] ]; 1005 #if REPN_FORMAT_IN_VPS 1006 UInt uiWidth = pcSlice->getPicWidthInLumaSamples(); 1007 UInt uiHeight = pcSlice->getPicHeightInLumaSamples(); 1008 #else 1040 1009 UInt uiWidth = pcSlice->getSPS()->getPicWidthInLumaSamples(); 1041 1010 UInt uiHeight = pcSlice->getSPS()->getPicHeightInLumaSamples(); 1011 #endif 1042 1012 while(uiPosX>=uiWidth||uiPosY>=uiHeight) 1043 1013 { … … 1136 1106 iQpOffset = Int(floor( dQpOffset + 0.49999 )); 1137 1107 } 1108 #if REPN_FORMAT_IN_VPS 1109 return Clip3(-pcCU->getSlice()->getQpBDOffsetY(), MAX_QP, iBaseQp+iQpOffset ); 1110 #else 1138 1111 return Clip3(-pcCU->getSlice()->getSPS()->getQpBDOffsetY(), MAX_QP, iBaseQp+iQpOffset ); 1112 #endif 1139 1113 } 1140 1114 … … 1160 1134 pcSlice->getSliceSegmentCurStartCUAddr() < pcPic->getPicSym()->getInverseCUOrderMap(pcCU->getAddr())*pcCU->getPic()->getNumPartInCU()+uiAbsPartIdx+( pcPic->getNumPartInCU() >> (uiDepth<<1) ); 1161 1135 // We need to split, so don't try these modes. 1136 #if REPN_FORMAT_IN_VPS 1137 if(!bSliceStart&&( uiRPelX < pcSlice->getPicWidthInLumaSamples() ) && ( uiBPelY < pcSlice->getPicHeightInLumaSamples() ) ) 1138 #else 1162 1139 if(!bSliceStart&&( uiRPelX < pcSlice->getSPS()->getPicWidthInLumaSamples() ) && ( uiBPelY < pcSlice->getSPS()->getPicHeightInLumaSamples() ) ) 1140 #endif 1163 1141 { 1164 1142 m_pcEntropyCoder->encodeSplitFlag( pcCU, uiAbsPartIdx, uiDepth ); … … 1181 1159 uiTPelY = pcCU->getCUPelY() + g_auiRasterToPelY[ g_auiZscanToRaster[uiAbsPartIdx] ]; 1182 1160 Bool bInSlice = pcCU->getSCUAddr()+uiAbsPartIdx+uiQNumParts>pcSlice->getSliceSegmentCurStartCUAddr()&&pcCU->getSCUAddr()+uiAbsPartIdx<pcSlice->getSliceSegmentCurEndCUAddr(); 1161 #if REPN_FORMAT_IN_VPS 1162 if(bInSlice&&( uiLPelX < pcSlice->getPicWidthInLumaSamples() ) && ( uiTPelY < pcSlice->getPicHeightInLumaSamples() ) ) 1163 #else 1183 1164 if(bInSlice&&( uiLPelX < pcSlice->getSPS()->getPicWidthInLumaSamples() ) && ( uiTPelY < pcSlice->getSPS()->getPicHeightInLumaSamples() ) ) 1165 #endif 1184 1166 { 1185 1167 xEncodeCU( pcCU, uiAbsPartIdx, uiDepth+1 ); … … 1706 1688 Bool bSliceEnd = pcSlice->getSliceSegmentCurEndCUAddr() > rpcPic->getPicSym()->getInverseCUOrderMap(pcCU->getAddr())*pcCU->getPic()->getNumPartInCU()+uiAbsPartIdx && 1707 1689 pcSlice->getSliceSegmentCurEndCUAddr() < rpcPic->getPicSym()->getInverseCUOrderMap(pcCU->getAddr())*pcCU->getPic()->getNumPartInCU()+uiAbsPartIdx+( pcCU->getPic()->getNumPartInCU() >> (uiDepth<<1) ); 1690 #if REPN_FORMAT_IN_VPS 1691 if(!bSliceEnd && !bSliceStart && ( uiRPelX < pcSlice->getPicWidthInLumaSamples() ) && ( uiBPelY < pcSlice->getPicHeightInLumaSamples() ) ) 1692 #else 1708 1693 if(!bSliceEnd && !bSliceStart && ( uiRPelX < pcSlice->getSPS()->getPicWidthInLumaSamples() ) && ( uiBPelY < pcSlice->getSPS()->getPicHeightInLumaSamples() ) ) 1694 #endif 1709 1695 { 1710 1696 UInt uiAbsPartIdxInRaster = g_auiZscanToRaster[uiAbsPartIdx]; … … 1727 1713 Bool bInSlice = rpcPic->getPicSym()->getInverseCUOrderMap(pcCU->getAddr())*pcCU->getPic()->getNumPartInCU()+uiAbsPartIdx+uiQNumParts > pcSlice->getSliceSegmentCurStartCUAddr() && 1728 1714 rpcPic->getPicSym()->getInverseCUOrderMap(pcCU->getAddr())*pcCU->getPic()->getNumPartInCU()+uiAbsPartIdx < pcSlice->getSliceSegmentCurEndCUAddr(); 1715 #if REPN_FORMAT_IN_VPS 1716 if(bInSlice&&( uiSubCULPelX < pcSlice->getPicWidthInLumaSamples() ) && ( uiSubCUTPelY < pcSlice->getPicHeightInLumaSamples() ) ) 1717 #else 1729 1718 if(bInSlice&&( uiSubCULPelX < pcSlice->getSPS()->getPicWidthInLumaSamples() ) && ( uiSubCUTPelY < pcSlice->getSPS()->getPicHeightInLumaSamples() ) ) 1719 #endif 1730 1720 { 1731 1721 xCopyYuv2Pic( rpcPic, uiCUAddr, uiAbsPartIdx, uiDepth+1, uiSrcDepth, pcCU, uiSubCULPelX, uiSubCUTPelY ); // Copy Yuv data to picture Yuv -
trunk/source/Lib/TLibEncoder/TEncGOP.cpp
r352 r442 307 307 } 308 308 309 #if N0383_IL_CONSTRAINED_TILE_SETS_SEI 310 SEIInterLayerConstrainedTileSets* TEncGOP::xCreateSEIInterLayerConstrainedTileSets() 311 { 312 SEIInterLayerConstrainedTileSets *seiInterLayerConstrainedTileSets = new SEIInterLayerConstrainedTileSets(); 313 seiInterLayerConstrainedTileSets->m_ilAllTilesExactSampleValueMatchFlag = false; 314 seiInterLayerConstrainedTileSets->m_ilOneTilePerTileSetFlag = false; 315 if (!seiInterLayerConstrainedTileSets->m_ilOneTilePerTileSetFlag) 316 { 317 seiInterLayerConstrainedTileSets->m_ilNumSetsInMessageMinus1 = m_pcCfg->getIlNumSetsInMessage() - 1; 318 if (seiInterLayerConstrainedTileSets->m_ilNumSetsInMessageMinus1) 319 { 320 seiInterLayerConstrainedTileSets->m_skippedTileSetPresentFlag = m_pcCfg->getSkippedTileSetPresentFlag(); 321 } 322 else 323 { 324 seiInterLayerConstrainedTileSets->m_skippedTileSetPresentFlag = false; 325 } 326 seiInterLayerConstrainedTileSets->m_ilNumSetsInMessageMinus1 += seiInterLayerConstrainedTileSets->m_skippedTileSetPresentFlag ? 1 : 0; 327 for (UInt i = 0; i < m_pcCfg->getIlNumSetsInMessage(); i++) 328 { 329 seiInterLayerConstrainedTileSets->m_ilctsId[i] = i; 330 seiInterLayerConstrainedTileSets->m_ilNumTileRectsInSetMinus1[i] = 0; 331 for( UInt j = 0; j <= seiInterLayerConstrainedTileSets->m_ilNumTileRectsInSetMinus1[i]; j++) 332 { 333 seiInterLayerConstrainedTileSets->m_ilTopLeftTileIndex[i][j] = m_pcCfg->getTopLeftTileIndex(i); 334 seiInterLayerConstrainedTileSets->m_ilBottomRightTileIndex[i][j] = m_pcCfg->getBottomRightTileIndex(i); 335 } 336 seiInterLayerConstrainedTileSets->m_ilcIdc[i] = m_pcCfg->getIlcIdc(i); 337 if (seiInterLayerConstrainedTileSets->m_ilAllTilesExactSampleValueMatchFlag) 338 { 339 seiInterLayerConstrainedTileSets->m_ilExactSampleValueMatchFlag[i] = false; 340 } 341 } 342 } 343 344 return seiInterLayerConstrainedTileSets; 345 } 346 #endif 347 309 348 Void TEncGOP::xCreateLeadingSEIMessages (/*SEIMessages seiMessages,*/ AccessUnit &accessUnit, TComSPS *sps) 310 349 { … … 369 408 delete sei; 370 409 } 410 #if N0383_IL_CONSTRAINED_TILE_SETS_SEI 411 if(m_pcCfg->getInterLayerConstrainedTileSetsSEIEnabled()) 412 { 413 SEIInterLayerConstrainedTileSets *sei = xCreateSEIInterLayerConstrainedTileSets (); 414 415 nalu = NALUnit(NAL_UNIT_PREFIX_SEI, 0, m_pcCfg->getNumLayer()-1); // For highest layer 416 m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream); 417 m_seiWriter.writeSEImessage(nalu.m_Bitstream, *sei, sps); 418 writeRBSPTrailingBits(nalu.m_Bitstream); 419 accessUnit.push_back(new NALUnitEBSP(nalu)); 420 delete sei; 421 } 422 #endif 371 423 } 372 424 … … 375 427 // ==================================================================================================================== 376 428 #if SVC_EXTENSION 377 Void TEncGOP::compressGOP( Int iPicIdInGOP, Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsInGOP )378 #else 379 Void TEncGOP::compressGOP( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsInGOP )429 Void TEncGOP::compressGOP( Int iPicIdInGOP, Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsInGOP, Bool isField, Bool isTff) 430 #else 431 Void TEncGOP::compressGOP( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsInGOP, Bool isField, Bool isTff) 380 432 #endif 381 433 { … … 390 442 TComOutputBitstream* pcSubstreamsOut = NULL; 391 443 392 xInitGOP( iPOCLast, iNumPicRcvd, rcListPic, rcListPicYuvRecOut );444 xInitGOP( iPOCLast, iNumPicRcvd, rcListPic, rcListPicYuvRecOut, isField ); 393 445 394 446 m_iNumPicCoded = 0; … … 463 515 464 516 /////////////////////////////////////////////////////////////////////////////////////////////////// Initial to start encoding 465 Int pocCurr = iPOCLast -iNumPicRcvd+ m_pcCfg->getGOPEntry(iGOPid).m_POC; 466 Int iTimeOffset = m_pcCfg->getGOPEntry(iGOPid).m_POC; 467 if(iPOCLast == 0) 517 Int iTimeOffset; 518 Int pocCurr; 519 520 if(iPOCLast == 0) //case first frame or first top field 468 521 { 469 522 pocCurr=0; 470 523 iTimeOffset = 1; 471 524 } 525 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 526 { 527 pocCurr = 1; 528 iTimeOffset = 1; 529 } 530 else 531 { 532 pocCurr = iPOCLast - iNumPicRcvd + m_pcCfg->getGOPEntry(iGOPid).m_POC - isField; 533 iTimeOffset = m_pcCfg->getGOPEntry(iGOPid).m_POC; 534 } 535 472 536 if(pocCurr>=m_pcCfg->getFramesToBeEncoded()) 473 537 { … … 490 554 accessUnitsInGOP.push_back(AccessUnit()); 491 555 AccessUnit& accessUnit = accessUnitsInGOP.back(); 492 xGetBuffer( rcListPic, rcListPicYuvRecOut, iNumPicRcvd, iTimeOffset, pcPic, pcPicYuvRecOut, pocCurr );556 xGetBuffer( rcListPic, rcListPicYuvRecOut, iNumPicRcvd, iTimeOffset, pcPic, pcPicYuvRecOut, pocCurr, isField ); 493 557 494 558 // Slice data initialization … … 499 563 #if SVC_EXTENSION 500 564 pcPic->setLayerId( m_layerId ); 501 m_pcSliceEncoder->initEncSlice ( pcPic, iPOCLast, pocCurr, iNumPicRcvd, iGOPid, pcSlice, m_pcEncTop->getSPS(), m_pcEncTop->getPPS(), m_pcEncTop->getVPS() ); 502 #else 503 m_pcSliceEncoder->initEncSlice ( pcPic, iPOCLast, pocCurr, iNumPicRcvd, iGOPid, pcSlice, m_pcEncTop->getSPS(), m_pcEncTop->getPPS() ); 504 #endif 505 565 m_pcSliceEncoder->initEncSlice ( pcPic, iPOCLast, pocCurr, iNumPicRcvd, iGOPid, pcSlice, m_pcEncTop->getSPS(), m_pcEncTop->getPPS(), m_pcEncTop->getVPS(), isField ); 566 #else 567 m_pcSliceEncoder->initEncSlice ( pcPic, iPOCLast, pocCurr, iNumPicRcvd, iGOPid, pcSlice, m_pcEncTop->getSPS(), m_pcEncTop->getPPS(), isField ); 568 #endif 569 570 //Set Frame/Field coding 571 pcSlice->getPic()->setField(isField); 572 573 #if POC_RESET_FLAG 574 if( !pcSlice->getPocResetFlag() ) // For picture that are not reset, we should adjust the value of POC calculated from the configuration files. 575 { 576 // Subtract POC adjustment value until now. 577 pcSlice->setPOC( pcSlice->getPOC() - m_pcEncTop->getPocAdjustmentValue() ); 578 } 579 else 580 { 581 // Check if this is the first slice in the picture 582 // In the encoder, the POC values are copied along with copySliceInfo, so we only need 583 // to do this for the first slice. 584 Int pocAdjustValue = pcSlice->getPOC() - m_pcEncTop->getPocAdjustmentValue(); 585 if( pcSlice->getSliceIdx() == 0 ) 586 { 587 TComList<TComPic*>::iterator iterPic = rcListPic.begin(); 588 589 // Iterate through all picture in DPB 590 while( iterPic != rcListPic.end() ) 591 { 592 TComPic *dpbPic = *iterPic; 593 if( dpbPic->getPOC() == pocCurr ) 594 { 595 if( dpbPic->getReconMark() ) 596 { 597 assert( !( dpbPic->getSlice(0)->isReferenced() ) && !( dpbPic->getOutputMark() ) ); 598 } 599 } 600 // Check if the picture pointed to by iterPic is either used for reference or 601 // needed for output, are in the same layer, and not the current picture. 602 if( /* ( ( dpbPic->getSlice(0)->isReferenced() ) || ( dpbPic->getOutputMark() ) ) 603 && */ ( dpbPic->getLayerId() == pcSlice->getLayerId() ) 604 && ( dpbPic->getReconMark() ) 605 ) 606 { 607 for(Int i = dpbPic->getNumAllocatedSlice()-1; i >= 0; i--) 608 { 609 TComSlice *slice = dpbPic->getSlice(i); 610 TComReferencePictureSet *rps = slice->getRPS(); 611 slice->setPOC( dpbPic->getSlice(i)->getPOC() - pocAdjustValue ); 612 613 // Also adjust the POC value stored in the RPS of each such slice 614 for(Int j = rps->getNumberOfPictures(); j >= 0; j--) 615 { 616 rps->setPOC( j, rps->getPOC(j) - pocAdjustValue ); 617 } 618 // Also adjust the value of refPOC 619 for(Int k = 0; k < 2; k++) // For List 0 and List 1 620 { 621 RefPicList list = (k == 1) ? REF_PIC_LIST_1 : REF_PIC_LIST_0; 622 for(Int j = 0; j < slice->getNumRefIdx(list); j++) 623 { 624 slice->setRefPOC( slice->getRefPOC(list, j) - pocAdjustValue, list, j); 625 } 626 } 627 } 628 } 629 iterPic++; 630 } 631 m_pcEncTop->setPocAdjustmentValue( m_pcEncTop->getPocAdjustmentValue() + pocAdjustValue ); 632 } 633 pcSlice->setPocValueBeforeReset( pcSlice->getPOC() - m_pcEncTop->getPocAdjustmentValue() + pocAdjustValue ); 634 pcSlice->setPOC( 0 ); 635 } 636 #endif 506 637 #if M0040_ADAPTIVE_RESOLUTION_CHANGE 507 638 if (m_pcEncTop->getAdaptiveResolutionChange() > 0 && m_layerId == 1 && pocCurr > m_pcEncTop->getAdaptiveResolutionChange()) … … 530 661 #endif 531 662 663 #if IL_SL_SIGNALLING_N0371 664 m_pcEncTop->getScalingList()->setLayerId( m_layerId ); 665 #endif 666 532 667 pcSlice->setLastIDR(m_iLastIDR); 533 668 pcSlice->setSliceIdx(0); … … 535 670 pcSlice->setLFCrossSliceBoundaryFlag( pcSlice->getPPS()->getLoopFilterAcrossSlicesEnabledFlag() ); 536 671 pcSlice->setScalingList ( m_pcEncTop->getScalingList() ); 537 pcSlice->getScalingList()->setUseTransformSkip(m_pcEncTop->getPPS()->getUseTransformSkip());538 672 if(m_pcEncTop->getUseScalingListId() == SCALING_LIST_OFF) 539 673 { 674 #if IL_SL_SIGNALLING_N0371 675 m_pcEncTop->getTrQuant()->setFlatScalingList( m_layerId ); 676 #else 540 677 m_pcEncTop->getTrQuant()->setFlatScalingList(); 678 #endif 541 679 m_pcEncTop->getTrQuant()->setUseScalingList(false); 542 680 m_pcEncTop->getSPS()->setScalingListPresentFlag(false); … … 545 683 else if(m_pcEncTop->getUseScalingListId() == SCALING_LIST_DEFAULT) 546 684 { 685 #if IL_SL_SIGNALLING_N0371 686 pcSlice->getScalingList()->setLayerId( m_layerId ); 687 #endif 688 689 #if IL_SL_SIGNALLING_N0371 690 pcSlice->setDefaultScalingList ( m_layerId ); 691 #else 547 692 pcSlice->setDefaultScalingList (); 693 #endif 694 548 695 m_pcEncTop->getSPS()->setScalingListPresentFlag(false); 549 696 m_pcEncTop->getPPS()->setScalingListPresentFlag(false); … … 553 700 else if(m_pcEncTop->getUseScalingListId() == SCALING_LIST_FILE_READ) 554 701 { 702 #if IL_SL_SIGNALLING_N0371 703 pcSlice->getScalingList()->setLayerId( m_layerId ); 704 #endif 705 555 706 if(pcSlice->getScalingList()->xParseScalingList(m_pcCfg->getScalingListFile())) 556 707 { 708 #if IL_SL_SIGNALLING_N0371 709 pcSlice->setDefaultScalingList ( m_layerId ); 710 #else 557 711 pcSlice->setDefaultScalingList (); 558 } 712 #endif 713 } 714 #if IL_SL_SIGNALLING_N0371 715 pcSlice->getScalingList()->checkDcOfMatrix( m_layerId ); 716 #else 559 717 pcSlice->getScalingList()->checkDcOfMatrix(); 718 #endif 560 719 m_pcEncTop->getSPS()->setScalingListPresentFlag(pcSlice->checkDefaultScalingList()); 720 721 #if IL_SL_SIGNALLING_N0371 722 if( m_layerId > 0 ) 723 { 724 m_pcEncTop->getSPS()->setPredScalingListFlag (true); 725 m_pcEncTop->getSPS()->setScalingListRefLayerId( 0 ); 726 } 727 #endif 728 561 729 m_pcEncTop->getPPS()->setScalingListPresentFlag(false); 730 731 #if IL_SL_SIGNALLING_N0371 732 if( m_layerId > 0 ) 733 { 734 m_pcEncTop->getPPS()->setPredScalingListFlag (false); 735 m_pcEncTop->getPPS()->setScalingListRefLayerId( 0 ); 736 } 737 #endif 738 562 739 m_pcEncTop->getTrQuant()->setScalingList(pcSlice->getScalingList()); 563 740 m_pcEncTop->getTrQuant()->setUseScalingList(true); … … 576 753 pcSlice->setNalUnitType(getNalUnitType(pocCurr, m_iLastIDR)); 577 754 #if SVC_EXTENSION 755 #if ILR_RESTR && ILR_RESTR_FIX 756 Int interLayerPredLayerIdcTmp[MAX_VPS_LAYER_ID_PLUS1]; 757 Int activeNumILRRefIdxTmp = 0; 758 #endif 578 759 if (m_layerId > 0) 579 760 { … … 588 769 pcSlice->setBaseColPic( *cListPic, refLayerIdc ); 589 770 590 #if SIMPLIFIED_MV_POS_SCALING 771 #if ILR_RESTR && ILR_RESTR_FIX 772 // Apply temporal layer restriction to inter-layer prediction 773 Int maxTidIlRefPicsPlus1 = m_pcEncTop->getVPS()->getMaxTidIlRefPicsPlus1(pcSlice->getBaseColPic(refLayerIdc)->getSlice(0)->getLayerId()); 774 if( ((Int)(pcSlice->getBaseColPic(refLayerIdc)->getSlice(0)->getTLayer())<=maxTidIlRefPicsPlus1-1) || (maxTidIlRefPicsPlus1==0 && pcSlice->getBaseColPic(refLayerIdc)->getSlice(0)->getRapPicFlag()) ) 775 { 776 interLayerPredLayerIdcTmp[activeNumILRRefIdxTmp++] = refLayerIdc; // add picture to the list of valid inter-layer pictures 777 } 778 else 779 { 780 continue; // ILP is not valid due to temporal layer restriction 781 } 782 #endif 783 591 784 #if SCALED_REF_LAYER_OFFSETS 592 785 const Window &scalEL = m_pcEncTop->getScaledRefLayerWindow(refLayerIdc); … … 612 805 g_posScalingFactor[refLayerIdc][0] = ((widthBL << 16) + (widthEL >> 1)) / widthEL; 613 806 g_posScalingFactor[refLayerIdc][1] = ((heightBL << 16) + (heightEL >> 1)) / heightEL; 614 #endif615 807 616 808 #if SVC_UPSAMPLING 617 809 if( pcPic->isSpatialEnhLayer(refLayerIdc)) 618 { 810 { 619 811 #if SCALED_REF_LAYER_OFFSETS 620 812 m_pcPredSearch->upsampleBasePic( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), pcPic->getPicYuvRec(), pcSlice->getSPS()->getScaledRefLayerWindow(refLayerIdc) ); … … 630 822 #endif 631 823 } 632 } 633 #endif 634 635 #if REF_IDX_FRAMEWORK 636 if( m_layerId > 0 && (pocCurr % m_pcCfg->getIntraPeriod() == 0) ) 637 { 824 825 #if ILR_RESTR && ILR_RESTR_FIX 826 // Update the list of active inter-layer pictures 827 for ( Int i = 0; i < activeNumILRRefIdxTmp; i++) 828 { 829 pcSlice->setInterLayerPredLayerIdc( interLayerPredLayerIdcTmp[i], i ); 830 } 831 pcSlice->setActiveNumILRRefIdx( activeNumILRRefIdxTmp ); 832 if ( pcSlice->getActiveNumILRRefIdx() == 0 ) 833 { 834 // No valid inter-layer pictures -> disable inter-layer prediction 835 pcSlice->setInterLayerPredEnabledFlag(false); 836 } 837 #endif 838 839 if( pocCurr % m_pcCfg->getIntraPeriod() == 0 ) 840 { 841 #if N0147_IRAP_ALIGN_FLAG 842 if(pcSlice->getVPS()->getCrossLayerIrapAlignFlag()) 843 { 844 TComList<TComPic*> *cListPic = m_ppcTEncTop[m_layerId]->getRefLayerEnc(0)->getListPic(); 845 TComPic* picLayer0 = pcSlice->getRefPic(*cListPic, pcSlice->getPOC() ); 846 if(picLayer0) 847 { 848 pcSlice->setNalUnitType(picLayer0->getSlice(0)->getNalUnitType()); 849 } 850 else 851 { 852 pcSlice->setNalUnitType(NAL_UNIT_CODED_SLICE_CRA); 853 } 854 } 855 else 856 #endif 857 pcSlice->setNalUnitType(NAL_UNIT_CODED_SLICE_CRA); 858 638 859 #if IDR_ALIGNMENT 639 TComList<TComPic*> *cListPic = m_ppcTEncTop[m_layerId]->getRefLayerEnc(0)->getListPic(); 640 TComPic* picLayer0 = pcSlice->getRefPic(*cListPic, pcSlice->getPOC() ); 641 if( picLayer0->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL || picLayer0->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP ) 642 { 643 pcSlice->setNalUnitType(picLayer0->getSlice(0)->getNalUnitType()); 644 } 645 else 646 #endif 647 pcSlice->setNalUnitType(NAL_UNIT_CODED_SLICE_CRA); 648 } 649 650 if( m_layerId > 0 && pcSlice->getActiveNumILRRefIdx() == 0 && pcSlice->getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP && pcSlice->getNalUnitType() <= NAL_UNIT_CODED_SLICE_CRA ) 651 { 652 pcSlice->setSliceType(I_SLICE); 653 } 654 else if( m_layerId > 0 && !m_pcEncTop->getElRapSliceTypeB() ) 655 { 656 if( (pcSlice->getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP) && 657 (pcSlice->getNalUnitType() <= NAL_UNIT_CODED_SLICE_CRA) && 860 TComList<TComPic*> *cListPic = m_ppcTEncTop[m_layerId]->getRefLayerEnc(0)->getListPic(); 861 TComPic* picLayer0 = pcSlice->getRefPic(*cListPic, pcSlice->getPOC() ); 862 if( picLayer0->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL || picLayer0->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP ) 863 { 864 pcSlice->setNalUnitType(picLayer0->getSlice(0)->getNalUnitType()); 865 } 866 else 867 { 868 pcSlice->setNalUnitType(NAL_UNIT_CODED_SLICE_CRA); 869 } 870 #endif 871 } 872 873 if( pcSlice->getActiveNumILRRefIdx() == 0 && pcSlice->getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP && pcSlice->getNalUnitType() <= NAL_UNIT_CODED_SLICE_CRA ) 874 { 875 pcSlice->setSliceType(I_SLICE); 876 } 877 else if( !m_pcEncTop->getElRapSliceTypeB() ) 878 { 879 if( (pcSlice->getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP) && 880 (pcSlice->getNalUnitType() <= NAL_UNIT_CODED_SLICE_CRA) && 658 881 pcSlice->getSliceType() == B_SLICE ) 659 { 660 pcSlice->setSliceType(P_SLICE); 661 } 662 } 663 #endif 882 { 883 pcSlice->setSliceType(P_SLICE); 884 } 885 } 886 } 887 #endif //#if SVC_EXTENSION 664 888 if(pcSlice->getTemporalLayerNonReferenceFlag()) 665 889 { 666 if(pcSlice->getNalUnitType()==NAL_UNIT_CODED_SLICE_TRAIL_R) 890 if (pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_TRAIL_R && 891 !(m_iGopSize == 1 && pcSlice->getSliceType() == I_SLICE)) 892 // Add this condition to avoid POC issues with encoder_intra_main.cfg configuration (see #1127 in bug tracker) 667 893 { 668 894 pcSlice->setNalUnitType(NAL_UNIT_CODED_SLICE_TRAIL_N); … … 700 926 if(pcSlice->isTemporalLayerSwitchingPoint(rcListPic) || pcSlice->getSPS()->getTemporalIdNestingFlag()) 701 927 { 928 #if ALIGN_TSA_STSA_PICS 929 if( pcSlice->getLayerId() > 0 ) 930 { 931 Bool oneRefLayerTSA = false, oneRefLayerNotTSA = false; 932 for( Int i = 0; i < pcSlice->getLayerId(); i++) 933 { 934 TComList<TComPic *> *cListPic = m_ppcTEncTop[i]->getListPic(); 935 TComPic *lowerLayerPic = pcSlice->getRefPic(*cListPic, pcSlice->getPOC()); 936 if( lowerLayerPic && pcSlice->getVPS()->getDirectDependencyFlag(pcSlice->getLayerId(), i) ) 937 { 938 if( ( lowerLayerPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_N ) || 939 ( lowerLayerPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_TLA_R ) 940 ) 941 { 942 if(pcSlice->getTemporalLayerNonReferenceFlag() ) 943 { 944 pcSlice->setNalUnitType(NAL_UNIT_CODED_SLICE_TSA_N); 945 } 946 else 947 { 948 pcSlice->setNalUnitType(NAL_UNIT_CODED_SLICE_TLA_R ); 949 } 950 oneRefLayerTSA = true; 951 } 952 else 953 { 954 oneRefLayerNotTSA = true; 955 } 956 } 957 } 958 assert( !( oneRefLayerNotTSA && oneRefLayerTSA ) ); // Only one variable should be true - failure of this assert means 959 // that two independent reference layers that are not dependent on 960 // each other, but are reference for current layer have inconsistency 961 if( oneRefLayerNotTSA /*&& !oneRefLayerTSA*/ ) // No reference layer is TSA - set current as TRAIL 962 { 963 if(pcSlice->getTemporalLayerNonReferenceFlag() ) 964 { 965 pcSlice->setNalUnitType( NAL_UNIT_CODED_SLICE_TRAIL_N ); 966 } 967 else 968 { 969 pcSlice->setNalUnitType( NAL_UNIT_CODED_SLICE_TRAIL_R ); 970 } 971 } 972 else // This means there is no reference layer picture for current picture in this AU 973 { 974 if(pcSlice->getTemporalLayerNonReferenceFlag() ) 975 { 976 pcSlice->setNalUnitType(NAL_UNIT_CODED_SLICE_TSA_N); 977 } 978 else 979 { 980 pcSlice->setNalUnitType(NAL_UNIT_CODED_SLICE_TLA_R ); 981 } 982 } 983 } 984 #else 702 985 if(pcSlice->getTemporalLayerNonReferenceFlag()) 703 986 { … … 708 991 pcSlice->setNalUnitType(NAL_UNIT_CODED_SLICE_TLA_R); 709 992 } 993 #endif 710 994 } 711 995 else if(pcSlice->isStepwiseTemporalLayerSwitchingPointCandidate(rcListPic)) … … 741 1025 if(isSTSA==true) 742 1026 { 1027 #if ALIGN_TSA_STSA_PICS 1028 if( pcSlice->getLayerId() > 0 ) 1029 { 1030 Bool oneRefLayerSTSA = false, oneRefLayerNotSTSA = false; 1031 for( Int i = 0; i < pcSlice->getLayerId(); i++) 1032 { 1033 TComList<TComPic *> *cListPic = m_ppcTEncTop[i]->getListPic(); 1034 TComPic *lowerLayerPic = pcSlice->getRefPic(*cListPic, pcSlice->getPOC()); 1035 if( lowerLayerPic && pcSlice->getVPS()->getDirectDependencyFlag(pcSlice->getLayerId(), i) ) 1036 { 1037 if( ( lowerLayerPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_STSA_N ) || 1038 ( lowerLayerPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_STSA_R ) 1039 ) 1040 { 1041 if(pcSlice->getTemporalLayerNonReferenceFlag() ) 1042 { 1043 pcSlice->setNalUnitType(NAL_UNIT_CODED_SLICE_STSA_N); 1044 } 1045 else 1046 { 1047 pcSlice->setNalUnitType(NAL_UNIT_CODED_SLICE_STSA_R ); 1048 } 1049 oneRefLayerSTSA = true; 1050 } 1051 else 1052 { 1053 oneRefLayerNotSTSA = true; 1054 } 1055 } 1056 } 1057 assert( !( oneRefLayerNotSTSA && oneRefLayerSTSA ) ); // Only one variable should be true - failure of this assert means 1058 // that two independent reference layers that are not dependent on 1059 // each other, but are reference for current layer have inconsistency 1060 if( oneRefLayerNotSTSA /*&& !oneRefLayerSTSA*/ ) // No reference layer is STSA - set current as TRAIL 1061 { 1062 if(pcSlice->getTemporalLayerNonReferenceFlag() ) 1063 { 1064 pcSlice->setNalUnitType( NAL_UNIT_CODED_SLICE_TRAIL_N ); 1065 } 1066 else 1067 { 1068 pcSlice->setNalUnitType( NAL_UNIT_CODED_SLICE_TRAIL_R ); 1069 } 1070 } 1071 else // This means there is no reference layer picture for current picture in this AU 1072 { 1073 if(pcSlice->getTemporalLayerNonReferenceFlag() ) 1074 { 1075 pcSlice->setNalUnitType(NAL_UNIT_CODED_SLICE_STSA_N); 1076 } 1077 else 1078 { 1079 pcSlice->setNalUnitType(NAL_UNIT_CODED_SLICE_STSA_R ); 1080 } 1081 } 1082 } 1083 #else 743 1084 if(pcSlice->getTemporalLayerNonReferenceFlag()) 744 1085 { … … 749 1090 pcSlice->setNalUnitType(NAL_UNIT_CODED_SLICE_STSA_R); 750 1091 } 1092 #endif 751 1093 } 752 1094 } … … 759 1101 pcSlice->setNumRefIdx(REF_PIC_LIST_1,min(m_pcCfg->getGOPEntry(iGOPid).m_numRefPicsActive,pcSlice->getRPS()->getNumberOfPictures())); 760 1102 761 #if REF_IDX_FRAMEWORK1103 #if SVC_EXTENSION 762 1104 if( m_layerId > 0 && pcSlice->getActiveNumILRRefIdx() ) 763 1105 { 764 1106 #if RESTR_CHK 765 if (pcSlice->getPOC()>0 && pcSlice->isRADL()&& pcPic->getSlice(0)->isRASL()) 1107 #if POC_RESET_FLAG 1108 if ( pocCurr > 0 && pcSlice->isRADL() && pcPic->getSlice(0)->getBaseColPic(pcPic->getSlice(0)->getInterLayerPredLayerIdc(0))->getSlice(0)->isRASL()) 1109 #else 1110 if (pcSlice->getPOC()>0 && pcSlice->isRADL() && pcPic->getSlice(0)->getBaseColPic(pcPic->getSlice(0)->getInterLayerPredLayerIdc(0))->getSlice(0)->isRASL()) 1111 #endif 766 1112 { 767 1113 #if JCTVC_M0458_INTERLAYER_RPS_SIG … … 797 1143 #endif 798 1144 } 799 #endif 1145 #endif //SVC_EXTENSION 800 1146 801 1147 #if ADAPTIVE_QP_SELECTION … … 803 1149 #endif 804 1150 805 #if REF_IDX_FRAMEWORK1151 #if SVC_EXTENSION 806 1152 #if M0457_COL_PICTURE_SIGNALING && !REMOVE_COL_PICTURE_SIGNALING 807 1153 if ( pcSlice->getSliceType() == B_SLICE && !(pcSlice->getActiveNumILRRefIdx() > 0 && m_pcEncTop->getNumMotionPredRefLayers() > 0) ) … … 812 1158 pcSlice->setColFromL0Flag(1-uiColDir); 813 1159 } 814 #endif815 1160 816 1161 // Set reference list 817 #if REF_IDX_FRAMEWORK818 1162 if(m_layerId == 0 || ( m_layerId > 0 && pcSlice->getActiveNumILRRefIdx() == 0 ) ) 819 1163 { 820 1164 pcSlice->setRefPicList( rcListPic); 821 1165 } 822 #else 823 pcSlice->setRefPicList ( rcListPic ); 824 #endif 825 #if REF_IDX_FRAMEWORK 1166 826 1167 if( m_layerId > 0 && pcSlice->getActiveNumILRRefIdx() ) 827 1168 { 828 1169 m_pcEncTop->setILRPic(pcPic); 829 830 1170 #if REF_IDX_MFM 831 1171 #if M0457_COL_PICTURE_SIGNALING … … 840 1180 #endif 841 1181 } 842 #endif 1182 #else 1183 // Set reference list 1184 pcSlice->setRefPicList ( rcListPic ); 1185 #endif //SVC_EXTENSION 843 1186 pcSlice->setRefPicListModificationSvc(); 844 1187 pcSlice->setRefPicList( rcListPic, false, m_pcEncTop->getIlpList()); … … 890 1233 #endif 891 1234 } 892 #endif 1235 #else //SVC_EXTENSION 1236 // Set reference list 1237 pcSlice->setRefPicList ( rcListPic ); 1238 #endif //#if SVC_EXTENSION 893 1239 894 1240 // Slice info. refinement … … 904 1250 #endif 905 1251 { 906 #if ! REF_IDX_FRAMEWORK1252 #if !SVC_EXTENSION 907 1253 pcSlice->setColFromL0Flag(1-uiColDir); 908 1254 #endif … … 1021 1367 1022 1368 Int sliceQP = m_pcCfg->getInitialQP(); 1369 #if POC_RESET_FLAG 1370 if ( ( pocCurr == 0 && m_pcCfg->getInitialQP() > 0 ) || ( frameLevel == 0 && m_pcCfg->getForceIntraQP() ) ) // QP is specified 1371 #else 1023 1372 if ( ( pcSlice->getPOC() == 0 && m_pcCfg->getInitialQP() > 0 ) || ( frameLevel == 0 && m_pcCfg->getForceIntraQP() ) ) // QP is specified 1373 #endif 1024 1374 { 1025 1375 Int NumberBFrames = ( m_pcCfg->getGOPSize() - 1 ); … … 1071 1421 } 1072 1422 1423 #if REPN_FORMAT_IN_VPS 1424 sliceQP = Clip3( -pcSlice->getQpBDOffsetY(), MAX_QP, sliceQP ); 1425 #else 1073 1426 sliceQP = Clip3( -pcSlice->getSPS()->getQpBDOffsetY(), MAX_QP, sliceQP ); 1427 #endif 1074 1428 m_pcRateCtrl->getRCPic()->setPicEstQP( sliceQP ); 1075 1429 … … 1084 1438 UInt uiPosX = ( uiExternalAddress % pcPic->getFrameWidthInCU() ) * g_uiMaxCUWidth+ g_auiRasterToPelX[ g_auiZscanToRaster[uiInternalAddress] ]; 1085 1439 UInt uiPosY = ( uiExternalAddress / pcPic->getFrameWidthInCU() ) * g_uiMaxCUHeight+ g_auiRasterToPelY[ g_auiZscanToRaster[uiInternalAddress] ]; 1440 #if REPN_FORMAT_IN_VPS 1441 UInt uiWidth = pcSlice->getPicWidthInLumaSamples(); 1442 UInt uiHeight = pcSlice->getPicHeightInLumaSamples(); 1443 #else 1086 1444 UInt uiWidth = pcSlice->getSPS()->getPicWidthInLumaSamples(); 1087 1445 UInt uiHeight = pcSlice->getSPS()->getPicHeightInLumaSamples(); 1446 #endif 1088 1447 while(uiPosX>=uiWidth||uiPosY>=uiHeight) 1089 1448 { … … 1164 1523 //intialize each tile of the current picture 1165 1524 pcPic->getPicSym()->xInitTiles(); 1525 1526 #if N0383_IL_CONSTRAINED_TILE_SETS_SEI 1527 if (m_pcCfg->getInterLayerConstrainedTileSetsSEIEnabled()) 1528 { 1529 xBuildTileSetsMap(pcPic->getPicSym()); 1530 } 1531 #endif 1166 1532 1167 1533 // Allocate some coders, now we know how many tiles there are. … … 1310 1676 { 1311 1677 #if SVC_EXTENSION 1678 #if VPS_NUH_LAYER_ID 1679 OutputNALUnit nalu(NAL_UNIT_VPS, 0, 0 ); // The value of nuh_layer_id of VPS NAL unit shall be equal to 0. 1680 #else 1312 1681 OutputNALUnit nalu(NAL_UNIT_VPS, 0, m_layerId); 1682 #endif 1313 1683 #if AVC_BASE 1314 1684 if( ( m_layerId == 1 && m_pcEncTop->getVPS()->getAvcBaseLayerFlag() ) || ( m_layerId == 0 && !m_pcEncTop->getVPS()->getAvcBaseLayerFlag() ) ) … … 1333 1703 #if SVC_EXTENSION 1334 1704 nalu = NALUnit(NAL_UNIT_SPS, 0, m_layerId); 1705 #if IL_SL_SIGNALLING_N0371 1706 pcSlice->getSPS()->setVPS( pcSlice->getVPS() ); 1707 #endif 1335 1708 #else 1336 1709 nalu = NALUnit(NAL_UNIT_SPS); … … 1452 1825 } 1453 1826 } 1454 pictureTimingSEI.m_auCpbRemovalDelay = std::max<Int>(1, m_totalCoded - m_lastBPSEI); // Syntax element signalled as minus, hence the . 1827 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 . 1828 #if POC_RESET_FLAG 1829 pictureTimingSEI.m_picDpbOutputDelay = pcSlice->getSPS()->getNumReorderPics(0) + pocCurr - m_totalCoded; 1830 #else 1455 1831 pictureTimingSEI.m_picDpbOutputDelay = pcSlice->getSPS()->getNumReorderPics(0) + pcSlice->getPOC() - m_totalCoded; 1832 #endif 1456 1833 Int factor = pcSlice->getSPS()->getVuiParameters()->getHrdParameters()->getTickDivisorMinus2() + 2; 1457 1834 pictureTimingSEI.m_picDpbOutputDuDelay = factor * pictureTimingSEI.m_picDpbOutputDelay; … … 1558 1935 SEIRecoveryPoint sei_recovery_point; 1559 1936 sei_recovery_point.m_recoveryPocCnt = 0; 1937 #if POC_RESET_FLAG 1938 sei_recovery_point.m_exactMatchingFlag = ( pocCurr == 0 ) ? (true) : (false); 1939 #else 1560 1940 sei_recovery_point.m_exactMatchingFlag = ( pcSlice->getPOC() == 0 ) ? (true) : (false); 1941 #endif 1561 1942 sei_recovery_point.m_brokenLinkFlag = false; 1562 1943 … … 1619 2000 startCUAddrSliceSegmentIdx++; 1620 2001 } 1621 #if REF_IDX_FRAMEWORK&& M0457_COL_PICTURE_SIGNALING2002 #if SVC_EXTENSION && M0457_COL_PICTURE_SIGNALING 1622 2003 pcSlice->setNumMotionPredRefLayers(m_pcEncTop->getNumMotionPredRefLayers()); 1623 2004 #endif … … 1632 2013 uiPosX = ( uiExternalAddress % pcPic->getFrameWidthInCU() ) * g_uiMaxCUWidth+ g_auiRasterToPelX[ g_auiZscanToRaster[uiInternalAddress] ]; 1633 2014 uiPosY = ( uiExternalAddress / pcPic->getFrameWidthInCU() ) * g_uiMaxCUHeight+ g_auiRasterToPelY[ g_auiZscanToRaster[uiInternalAddress] ]; 2015 2016 #if REPN_FORMAT_IN_VPS 2017 uiWidth = pcSlice->getPicWidthInLumaSamples(); 2018 uiHeight = pcSlice->getPicHeightInLumaSamples(); 2019 #else 1634 2020 uiWidth = pcSlice->getSPS()->getPicWidthInLumaSamples(); 1635 2021 uiHeight = pcSlice->getSPS()->getPicHeightInLumaSamples(); 2022 #endif 1636 2023 while(uiPosX>=uiWidth||uiPosY>=uiHeight) 1637 2024 { … … 1688 2075 tmpBitsBeforeWriting = m_pcEntropyCoder->getNumberOfWrittenBits(); 1689 2076 #endif 2077 1690 2078 m_pcEntropyCoder->encodeSliceHeader(pcSlice); 2079 1691 2080 #if RATE_CONTROL_LAMBDA_DOMAIN 1692 2081 actualHeadBits += ( m_pcEntropyCoder->getNumberOfWrittenBits() - tmpBitsBeforeWriting ); … … 1975 2364 xCalculateAddPSNR( pcPic, pcPic->getPicYuvRec(), accessUnit, dEncTime ); 1976 2365 2366 //In case of field coding, compute the interlaced PSNR for both fields 2367 if (isField && ((!pcPic->isTopField() && isTff) || (pcPic->isTopField() && !isTff))) 2368 { 2369 //get complementary top field 2370 TComPic* pcPicTop; 2371 TComList<TComPic*>::iterator iterPic = rcListPic.begin(); 2372 while ((*iterPic)->getPOC() != pcPic->getPOC()-1) 2373 { 2374 iterPic ++; 2375 } 2376 pcPicTop = *(iterPic); 2377 xCalculateInterlacedAddPSNR(pcPicTop, pcPic, pcPicTop->getPicYuvRec(), pcPic->getPicYuvRec(), accessUnit, dEncTime ); 2378 } 2379 1977 2380 if (digestStr) 1978 2381 { … … 2107 2510 OutputNALUnit nalu(NAL_UNIT_PREFIX_SEI, pcSlice->getTLayer()); 2108 2511 m_pcEntropyCoder->setEntropyCoder(m_pcCavlcCoder, pcSlice); 2512 pictureTimingSEI.m_picStruct = (isField && pcSlice->getPic()->isTopField())? 1 : isField? 2 : 0; 2109 2513 m_seiWriter.writeSEImessage(nalu.m_Bitstream, pictureTimingSEI, pcSlice->getSPS()); 2110 2514 writeRBSPTrailingBits(nalu.m_Bitstream); … … 2225 2629 2226 2630 #if SVC_EXTENSION 2227 assert ( m_iNumPicCoded <= 1 );2228 #else 2229 assert ( m_iNumPicCoded == iNumPicRcvd);2631 assert ( m_iNumPicCoded <= 1 || (isField && iPOCLast == 1) ); 2632 #else 2633 assert ( (m_iNumPicCoded == iNumPicRcvd) || (isField && iPOCLast == 1) ); 2230 2634 #endif 2231 2635 } 2232 2636 2233 2637 #if !SVC_EXTENSION 2234 Void TEncGOP::printOutSummary(UInt uiNumAllPicCoded )2638 Void TEncGOP::printOutSummary(UInt uiNumAllPicCoded, Bool isField) 2235 2639 { 2236 2640 assert (uiNumAllPicCoded == m_gcAnalyzeAll.getNumPic()); … … 2238 2642 2239 2643 //--CFG_KDY 2240 m_gcAnalyzeAll.setFrmRate( m_pcCfg->getFrameRate() ); 2241 m_gcAnalyzeI.setFrmRate( m_pcCfg->getFrameRate() ); 2242 m_gcAnalyzeP.setFrmRate( m_pcCfg->getFrameRate() ); 2243 m_gcAnalyzeB.setFrmRate( m_pcCfg->getFrameRate() ); 2644 if(isField) 2645 { 2646 m_gcAnalyzeAll.setFrmRate( m_pcCfg->getFrameRate() * 2); 2647 m_gcAnalyzeI.setFrmRate( m_pcCfg->getFrameRate() * 2); 2648 m_gcAnalyzeP.setFrmRate( m_pcCfg->getFrameRate() * 2); 2649 m_gcAnalyzeB.setFrmRate( m_pcCfg->getFrameRate() * 2); 2650 } 2651 else 2652 { 2653 m_gcAnalyzeAll.setFrmRate( m_pcCfg->getFrameRate() ); 2654 m_gcAnalyzeI.setFrmRate( m_pcCfg->getFrameRate() ); 2655 m_gcAnalyzeP.setFrmRate( m_pcCfg->getFrameRate() ); 2656 m_gcAnalyzeB.setFrmRate( m_pcCfg->getFrameRate() ); 2657 } 2244 2658 2245 2659 //-- all … … 2264 2678 m_gcAnalyzeB.printSummary('B'); 2265 2679 #endif 2680 2681 if(isField) 2682 { 2683 //-- interlaced summary 2684 m_gcAnalyzeAll_in.setFrmRate( m_pcCfg->getFrameRate()); 2685 printf( "\n\nSUMMARY INTERLACED ---------------------------------------------\n" ); 2686 m_gcAnalyzeAll_in.printOutInterlaced('a', m_gcAnalyzeAll.getBits()); 2687 2688 #if _SUMMARY_OUT_ 2689 m_gcAnalyzeAll_in.printSummaryOutInterlaced(); 2690 #endif 2691 } 2266 2692 2267 2693 printf("\nRVM: %.3lf\n" , xCalculateRVM()); … … 2305 2731 // ==================================================================================================================== 2306 2732 2733 2734 Void TEncGOP::xInitGOP( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut, Bool isField ) 2735 { 2736 assert( iNumPicRcvd > 0 ); 2737 // Exception for the first frames 2738 if ( ( isField && (iPOCLast == 0 || iPOCLast == 1) ) || (!isField && (iPOCLast == 0)) ) 2739 { 2740 m_iGopSize = 1; 2741 } 2742 else 2743 { 2744 m_iGopSize = m_pcCfg->getGOPSize(); 2745 } 2746 assert (m_iGopSize > 0); 2747 2748 return; 2749 } 2750 2307 2751 Void TEncGOP::xInitGOP( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut ) 2308 2752 { … … 2327 2771 TComPic*& rpcPic, 2328 2772 TComPicYuv*& rpcPicYuvRecOut, 2329 Int pocCurr ) 2773 Int pocCurr, 2774 Bool isField) 2330 2775 { 2331 2776 Int i; 2332 2777 // Rec. output 2333 2778 TComList<TComPicYuv*>::iterator iterPicYuvRec = rcListPicYuvRecOut.end(); 2334 for ( i = 0; i < iNumPicRcvd - iTimeOffset + 1; i++ ) 2335 { 2336 iterPicYuvRec--; 2337 } 2338 2779 2780 if (isField) 2781 { 2782 for ( i = 0; i < ( (pocCurr == 0 ) || (pocCurr == 1 ) ? (iNumPicRcvd - iTimeOffset + 1) : (iNumPicRcvd - iTimeOffset + 2) ); i++ ) 2783 { 2784 iterPicYuvRec--; 2785 } 2786 } 2787 else 2788 { 2789 for ( i = 0; i < (iNumPicRcvd - iTimeOffset + 1); i++ ) 2790 { 2791 iterPicYuvRec--; 2792 } 2793 } 2794 2795 if (isField) 2796 { 2797 if(pocCurr == 1) 2798 { 2799 iterPicYuvRec++; 2800 } 2801 } 2339 2802 rpcPicYuvRecOut = *(iterPicYuvRec); 2340 2803 … … 2421 2884 switch (type) 2422 2885 { 2423 case NAL_UNIT_CODED_SLICE_TRAIL_R: return "TRAIL_R";2424 case NAL_UNIT_CODED_SLICE_TRAIL_N: return "TRAIL_N";2886 case NAL_UNIT_CODED_SLICE_TRAIL_R: return "TRAIL_R"; 2887 case NAL_UNIT_CODED_SLICE_TRAIL_N: return "TRAIL_N"; 2425 2888 case NAL_UNIT_CODED_SLICE_TLA_R: return "TLA_R"; 2426 case NAL_UNIT_CODED_SLICE_TSA_N: return "TSA_N";2427 case NAL_UNIT_CODED_SLICE_STSA_R: return "STSA_R";2428 case NAL_UNIT_CODED_SLICE_STSA_N: return "STSA_N";2889 case NAL_UNIT_CODED_SLICE_TSA_N: return "TSA_N"; 2890 case NAL_UNIT_CODED_SLICE_STSA_R: return "STSA_R"; 2891 case NAL_UNIT_CODED_SLICE_STSA_N: return "STSA_N"; 2429 2892 case NAL_UNIT_CODED_SLICE_BLA_W_LP: return "BLA_W_LP"; 2430 2893 case NAL_UNIT_CODED_SLICE_BLA_W_RADL: return "BLA_W_RADL"; 2431 case NAL_UNIT_CODED_SLICE_BLA_N_LP: return "BLA_N_LP";2894 case NAL_UNIT_CODED_SLICE_BLA_N_LP: return "BLA_N_LP"; 2432 2895 case NAL_UNIT_CODED_SLICE_IDR_W_RADL: return "IDR_W_RADL"; 2433 case NAL_UNIT_CODED_SLICE_IDR_N_LP: return "IDR_N_LP";2434 case NAL_UNIT_CODED_SLICE_CRA: return "CRA";2896 case NAL_UNIT_CODED_SLICE_IDR_N_LP: return "IDR_N_LP"; 2897 case NAL_UNIT_CODED_SLICE_CRA: return "CRA"; 2435 2898 case NAL_UNIT_CODED_SLICE_RADL_R: return "RADL_R"; 2436 2899 case NAL_UNIT_CODED_SLICE_RASL_R: return "RASL_R"; 2437 case NAL_UNIT_VPS: return "VPS";2438 case NAL_UNIT_SPS: return "SPS";2439 case NAL_UNIT_PPS: return "PPS";2440 case NAL_UNIT_ACCESS_UNIT_DELIMITER: return "AUD";2441 case NAL_UNIT_EOS: return "EOS";2442 case NAL_UNIT_EOB: return "EOB";2443 case NAL_UNIT_FILLER_DATA: return "FILLER";2900 case NAL_UNIT_VPS: return "VPS"; 2901 case NAL_UNIT_SPS: return "SPS"; 2902 case NAL_UNIT_PPS: return "PPS"; 2903 case NAL_UNIT_ACCESS_UNIT_DELIMITER: return "AUD"; 2904 case NAL_UNIT_EOS: return "EOS"; 2905 case NAL_UNIT_EOB: return "EOB"; 2906 case NAL_UNIT_FILLER_DATA: return "FILLER"; 2444 2907 case NAL_UNIT_PREFIX_SEI: return "SEI"; 2445 2908 case NAL_UNIT_SUFFIX_SEI: return "SEI"; 2446 default: return "UNK";2909 default: return "UNK"; 2447 2910 } 2448 2911 } … … 2625 3088 for (Int iRefIndex = 0; iRefIndex < pcSlice->getNumRefIdx(RefPicList(iRefList)); iRefIndex++) 2626 3089 { 2627 #if REF_IDX_FRAMEWORK && VPS_EXTN_DIRECT_REF_LAYERS 3090 #if SVC_EXTENSION 3091 #if VPS_EXTN_DIRECT_REF_LAYERS 2628 3092 if( pcSlice->getRefPic(RefPicList(iRefList), iRefIndex)->isILR(m_layerId) ) 2629 3093 { 2630 printf( "%d(%d) 3094 printf( "%d(%d)", pcSlice->getRefPOC(RefPicList(iRefList), iRefIndex)-pcSlice->getLastIDR(), pcSlice->getRefPic(RefPicList(iRefList), iRefIndex)->getLayerId() ); 2631 3095 } 2632 3096 else 2633 #endif 3097 { 3098 printf ("%d", pcSlice->getRefPOC(RefPicList(iRefList), iRefIndex)-pcSlice->getLastIDR()); 3099 } 3100 #endif 3101 if( pcSlice->getEnableTMVPFlag() && iRefList == 1 - pcSlice->getColFromL0Flag() && iRefIndex == pcSlice->getColRefIdx() ) 3102 { 3103 printf( "c" ); 3104 } 3105 3106 printf( " " ); 3107 #else 2634 3108 printf ("%d ", pcSlice->getRefPOC(RefPicList(iRefList), iRefIndex)-pcSlice->getLastIDR()); 3109 #endif 2635 3110 } 2636 3111 printf("]"); 2637 3112 } 3113 } 3114 3115 3116 Void reinterlace(Pel* top, Pel* bottom, Pel* dst, UInt stride, UInt width, UInt height, Bool isTff) 3117 { 3118 3119 for (Int y = 0; y < height; y++) 3120 { 3121 for (Int x = 0; x < width; x++) 3122 { 3123 dst[x] = isTff ? (UChar) top[x] : (UChar) bottom[x]; 3124 dst[stride+x] = isTff ? (UChar) bottom[x] : (UChar) top[x]; 3125 } 3126 top += stride; 3127 bottom += stride; 3128 dst += stride*2; 3129 } 3130 } 3131 3132 Void TEncGOP::xCalculateInterlacedAddPSNR( TComPic* pcPicOrgTop, TComPic* pcPicOrgBottom, TComPicYuv* pcPicRecTop, TComPicYuv* pcPicRecBottom, const AccessUnit& accessUnit, Double dEncTime ) 3133 { 3134 Int x, y; 3135 3136 UInt64 uiSSDY_in = 0; 3137 UInt64 uiSSDU_in = 0; 3138 UInt64 uiSSDV_in = 0; 3139 3140 Double dYPSNR_in = 0.0; 3141 Double dUPSNR_in = 0.0; 3142 Double dVPSNR_in = 0.0; 3143 3144 /*------ INTERLACED PSNR -----------*/ 3145 3146 /* Luma */ 3147 3148 Pel* pOrgTop = pcPicOrgTop->getPicYuvOrg()->getLumaAddr(); 3149 Pel* pOrgBottom = pcPicOrgBottom->getPicYuvOrg()->getLumaAddr(); 3150 Pel* pRecTop = pcPicRecTop->getLumaAddr(); 3151 Pel* pRecBottom = pcPicRecBottom->getLumaAddr(); 3152 3153 Int iWidth; 3154 Int iHeight; 3155 Int iStride; 3156 3157 iWidth = pcPicOrgTop->getPicYuvOrg()->getWidth () - m_pcEncTop->getPad(0); 3158 iHeight = pcPicOrgTop->getPicYuvOrg()->getHeight() - m_pcEncTop->getPad(1); 3159 iStride = pcPicOrgTop->getPicYuvOrg()->getStride(); 3160 Int iSize = iWidth*iHeight; 3161 bool isTff = pcPicOrgTop->isTopField(); 3162 3163 TComPicYuv* pcOrgInterlaced = new TComPicYuv; 3164 pcOrgInterlaced->create( iWidth, iHeight << 1, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth ); 3165 3166 TComPicYuv* pcRecInterlaced = new TComPicYuv; 3167 pcRecInterlaced->create( iWidth, iHeight << 1, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth ); 3168 3169 Pel* pOrgInterlaced = pcOrgInterlaced->getLumaAddr(); 3170 Pel* pRecInterlaced = pcRecInterlaced->getLumaAddr(); 3171 3172 //=== Interlace fields ==== 3173 reinterlace(pOrgTop, pOrgBottom, pOrgInterlaced, iStride, iWidth, iHeight, isTff); 3174 reinterlace(pRecTop, pRecBottom, pRecInterlaced, iStride, iWidth, iHeight, isTff); 3175 3176 //===== calculate PSNR ===== 3177 for( y = 0; y < iHeight << 1; y++ ) 3178 { 3179 for( x = 0; x < iWidth; x++ ) 3180 { 3181 Int iDiff = (Int)( pOrgInterlaced[x] - pRecInterlaced[x] ); 3182 uiSSDY_in += iDiff * iDiff; 3183 } 3184 pOrgInterlaced += iStride; 3185 pRecInterlaced += iStride; 3186 } 3187 3188 /*Chroma*/ 3189 3190 iHeight >>= 1; 3191 iWidth >>= 1; 3192 iStride >>= 1; 3193 3194 pOrgTop = pcPicOrgTop->getPicYuvOrg()->getCbAddr(); 3195 pOrgBottom = pcPicOrgBottom->getPicYuvOrg()->getCbAddr(); 3196 pRecTop = pcPicRecTop->getCbAddr(); 3197 pRecBottom = pcPicRecBottom->getCbAddr(); 3198 pOrgInterlaced = pcOrgInterlaced->getCbAddr(); 3199 pRecInterlaced = pcRecInterlaced->getCbAddr(); 3200 3201 //=== Interlace fields ==== 3202 reinterlace(pOrgTop, pOrgBottom, pOrgInterlaced, iStride, iWidth, iHeight, isTff); 3203 reinterlace(pRecTop, pRecBottom, pRecInterlaced, iStride, iWidth, iHeight, isTff); 3204 3205 //===== calculate PSNR ===== 3206 for( y = 0; y < iHeight << 1; y++ ) 3207 { 3208 for( x = 0; x < iWidth; x++ ) 3209 { 3210 Int iDiff = (Int)( pOrgInterlaced[x] - pRecInterlaced[x] ); 3211 uiSSDU_in += iDiff * iDiff; 3212 } 3213 pOrgInterlaced += iStride; 3214 pRecInterlaced += iStride; 3215 } 3216 3217 pOrgTop = pcPicOrgTop->getPicYuvOrg()->getCrAddr(); 3218 pOrgBottom = pcPicOrgBottom->getPicYuvOrg()->getCrAddr(); 3219 pRecTop = pcPicRecTop->getCrAddr(); 3220 pRecBottom = pcPicRecBottom->getCrAddr(); 3221 pOrgInterlaced = pcOrgInterlaced->getCrAddr(); 3222 pRecInterlaced = pcRecInterlaced->getCrAddr(); 3223 3224 //=== Interlace fields ==== 3225 reinterlace(pOrgTop, pOrgBottom, pOrgInterlaced, iStride, iWidth, iHeight, isTff); 3226 reinterlace(pRecTop, pRecBottom, pRecInterlaced, iStride, iWidth, iHeight, isTff); 3227 3228 //===== calculate PSNR ===== 3229 for( y = 0; y < iHeight << 1; y++ ) 3230 { 3231 for( x = 0; x < iWidth; x++ ) 3232 { 3233 Int iDiff = (Int)( pOrgInterlaced[x] - pRecInterlaced[x] ); 3234 uiSSDV_in += iDiff * iDiff; 3235 } 3236 pOrgInterlaced += iStride; 3237 pRecInterlaced += iStride; 3238 } 3239 3240 Int maxvalY = 255 << (g_bitDepthY-8); 3241 Int maxvalC = 255 << (g_bitDepthC-8); 3242 Double fRefValueY = (Double) maxvalY * maxvalY * iSize*2; 3243 Double fRefValueC = (Double) maxvalC * maxvalC * iSize*2 / 4.0; 3244 dYPSNR_in = ( uiSSDY_in ? 10.0 * log10( fRefValueY / (Double)uiSSDY_in ) : 99.99 ); 3245 dUPSNR_in = ( uiSSDU_in ? 10.0 * log10( fRefValueC / (Double)uiSSDU_in ) : 99.99 ); 3246 dVPSNR_in = ( uiSSDV_in ? 10.0 * log10( fRefValueC / (Double)uiSSDV_in ) : 99.99 ); 3247 3248 /* calculate the size of the access unit, excluding: 3249 * - any AnnexB contributions (start_code_prefix, zero_byte, etc.,) 3250 * - SEI NAL units 3251 */ 3252 UInt numRBSPBytes = 0; 3253 for (AccessUnit::const_iterator it = accessUnit.begin(); it != accessUnit.end(); it++) 3254 { 3255 UInt numRBSPBytes_nal = UInt((*it)->m_nalUnitData.str().size()); 3256 3257 if ((*it)->m_nalUnitType != NAL_UNIT_PREFIX_SEI && (*it)->m_nalUnitType != NAL_UNIT_SUFFIX_SEI) 3258 numRBSPBytes += numRBSPBytes_nal; 3259 } 3260 3261 UInt uibits = numRBSPBytes * 8 ; 3262 3263 //===== add PSNR ===== 3264 m_gcAnalyzeAll_in.addResult (dYPSNR_in, dUPSNR_in, dVPSNR_in, (Double)uibits); 3265 3266 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 ); 3267 3268 pcOrgInterlaced->destroy(); 3269 delete pcOrgInterlaced; 3270 pcRecInterlaced->destroy(); 3271 delete pcRecInterlaced; 2638 3272 } 2639 3273 … … 2872 3506 return seiStartPos; 2873 3507 } 3508 3509 #if N0383_IL_CONSTRAINED_TILE_SETS_SEI 3510 Void TEncGOP::xBuildTileSetsMap(TComPicSym* picSym) 3511 { 3512 Int numCUs = picSym->getFrameWidthInCU() * picSym->getFrameHeightInCU(); 3513 3514 for (Int i = 0; i < numCUs; i++) 3515 { 3516 picSym->setTileSetIdxMap(i, -1, 0, false); 3517 } 3518 3519 for (Int i = 0; i < m_pcCfg->getIlNumSetsInMessage(); i++) 3520 { 3521 TComTile* topLeftTile = picSym->getTComTile(m_pcCfg->getTopLeftTileIndex(i)); 3522 TComTile* bottomRightTile = picSym->getTComTile(m_pcCfg->getBottomRightTileIndex(i)); 3523 Int tileSetLeftEdgePosInCU = topLeftTile->getRightEdgePosInCU() - topLeftTile->getTileWidth() + 1; 3524 Int tileSetRightEdgePosInCU = bottomRightTile->getRightEdgePosInCU(); 3525 Int tileSetTopEdgePosInCU = topLeftTile->getBottomEdgePosInCU() - topLeftTile->getTileHeight() + 1; 3526 Int tileSetBottomEdgePosInCU = bottomRightTile->getBottomEdgePosInCU(); 3527 assert(tileSetLeftEdgePosInCU < tileSetRightEdgePosInCU && tileSetTopEdgePosInCU < tileSetBottomEdgePosInCU); 3528 for (Int j = tileSetTopEdgePosInCU; j <= tileSetBottomEdgePosInCU; j++) 3529 { 3530 for (Int k = tileSetLeftEdgePosInCU; k <= tileSetRightEdgePosInCU; k++) 3531 { 3532 picSym->setTileSetIdxMap(j * picSym->getFrameWidthInCU() + k, i, m_pcCfg->getIlcIdc(i), false); 3533 } 3534 } 3535 } 3536 3537 if (m_pcCfg->getSkippedTileSetPresentFlag()) 3538 { 3539 Int skippedTileSetIdx = m_pcCfg->getIlNumSetsInMessage(); 3540 for (Int i = 0; i < numCUs; i++) 3541 { 3542 if (picSym->getTileSetIdxMap(i) < 0) 3543 { 3544 picSym->setTileSetIdxMap(i, skippedTileSetIdx, 0, true); 3545 } 3546 } 3547 } 3548 } 3549 #endif 2874 3550 2875 3551 Void TEncGOP::dblMetric( TComPic* pcPic, UInt uiNumSlices ) -
trunk/source/Lib/TLibEncoder/TEncGOP.h
r345 r442 145 145 Void init ( TEncTop* pcTEncTop ); 146 146 #if SVC_EXTENSION 147 Void compressGOP ( Int iPicIdInGOP, Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRec, std::list<AccessUnit>& accessUnitsInGOP );147 Void compressGOP ( Int iPicIdInGOP, Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRec, std::list<AccessUnit>& accessUnitsInGOP, Bool isField, Bool isTff ); 148 148 #else 149 Void compressGOP ( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRec, std::list<AccessUnit>& accessUnitsInGOP );149 Void compressGOP ( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRec, std::list<AccessUnit>& accessUnitsInGOP, Bool isField, Bool isTff ); 150 150 #endif 151 151 Void xAttachSliceDataToNalUnit (OutputNALUnit& rNalu, TComOutputBitstream*& rpcBitstreamRedirect); … … 156 156 TComList<TComPic*>* getListPic() { return m_pcListPic; } 157 157 158 Void printOutSummary ( UInt uiNumAllPicCoded ); 158 #if !SVC_EXTENSION 159 Void printOutSummary ( UInt uiNumAllPicCoded, Bool isField); 160 #endif 159 161 Void preLoopFilterPicAll ( TComPic* pcPic, UInt64& ruiDist, UInt64& ruiBits ); 160 162 … … 166 168 167 169 protected: 170 171 Void xInitGOP( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut, Bool isField ); 168 172 Void xInitGOP ( Int iPOC, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut ); 169 Void xGetBuffer ( TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut, Int iNumPicRcvd, Int iTimeOffset, TComPic*& rpcPic, TComPicYuv*& rpcPicYuvRecOut, Int pocCurr );173 Void xGetBuffer ( TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut, Int iNumPicRcvd, Int iTimeOffset, TComPic*& rpcPic, TComPicYuv*& rpcPicYuvRecOut, Int pocCurr, Bool isField ); 170 174 171 175 Void xCalculateAddPSNR ( TComPic* pcPic, TComPicYuv* pcPicD, const AccessUnit&, Double dEncTime ); 176 Void xCalculateInterlacedAddPSNR( TComPic* pcPicOrgTop, TComPic* pcPicOrgBottom, TComPicYuv* pcPicRecTop, TComPicYuv* pcPicRecBottom, const AccessUnit& accessUnit, Double dEncTime ); 172 177 173 178 UInt64 xFindDistortionFrame (TComPicYuv* pcPic0, TComPicYuv* pcPic1); … … 183 188 184 189 SEIToneMappingInfo* xCreateSEIToneMappingInfo(); 190 191 #if N0383_IL_CONSTRAINED_TILE_SETS_SEI 192 SEIInterLayerConstrainedTileSets* xCreateSEIInterLayerConstrainedTileSets(); 193 #endif 185 194 186 195 Void xCreateLeadingSEIMessages (/*SEIMessages seiMessages,*/ AccessUnit &accessUnit, TComSPS *sps); … … 197 206 m_nestedPictureTimingSEIPresentInAU = false; 198 207 } 208 #if N0383_IL_CONSTRAINED_TILE_SETS_SEI 209 Void xBuildTileSetsMap(TComPicSym* picSym); 210 #endif 199 211 Void dblMetric( TComPic* pcPic, UInt uiNumSlices ); 200 212 #if M0457_COL_PICTURE_SIGNALING && !REMOVE_COL_PICTURE_SIGNALING -
trunk/source/Lib/TLibEncoder/TEncSbac.cpp
r345 r442 804 804 Int iDQp = pcCU->getQP( uiAbsPartIdx ) - pcCU->getRefQP( uiAbsPartIdx ); 805 805 806 #if REPN_FORMAT_IN_VPS 807 Int qpBdOffsetY = pcCU->getSlice()->getQpBDOffsetY(); 808 #else 806 809 Int qpBdOffsetY = pcCU->getSlice()->getSPS()->getQpBDOffsetY(); 810 #endif 807 811 iDQp = (iDQp + 78 + qpBdOffsetY + (qpBdOffsetY/2)) % (52 + qpBdOffsetY) - 26 - (qpBdOffsetY/2); 808 812 -
trunk/source/Lib/TLibEncoder/TEncSearch.cpp
r345 r442 1104 1104 pcCU ->setTrIdxSubParts ( uiTrDepth, uiAbsPartIdx, uiFullDepth ); 1105 1105 1106 #if REPN_FORMAT_IN_VPS 1107 m_pcTrQuant->setQPforQuant ( pcCU->getQP( 0 ), TEXT_LUMA, pcCU->getSlice()->getQpBDOffsetY(), 0 ); 1108 #else 1106 1109 m_pcTrQuant->setQPforQuant ( pcCU->getQP( 0 ), TEXT_LUMA, pcCU->getSlice()->getSPS()->getQpBDOffsetY(), 0 ); 1110 #endif 1107 1111 1108 1112 #if RDOQ_CHROMA_LAMBDA … … 3217 3221 Int numValidMergeCand = 0 ; 3218 3222 3223 #if N0383_IL_CONSTRAINED_TILE_SETS_SEI 3224 Bool disableILP = false; 3225 if (pcCU->getPic()->getLayerId() == (m_pcEncCfg->getNumLayer() - 1) && m_pcEncCfg->getInterLayerConstrainedTileSetsSEIEnabled() && pcCU->getPic()->getPicSym()->getTileSetIdxMap(pcCU->getAddr()) >= 0) 3226 { 3227 if (pcCU->getPic()->getPicSym()->getTileSetType(pcCU->getAddr()) == 2) 3228 { 3229 disableILP = true; 3230 } 3231 if (pcCU->getPic()->getPicSym()->getTileSetType(pcCU->getAddr()) == 1) 3232 { 3233 Int currCUaddr = pcCU->getAddr(); 3234 Int frameWitdhInCU = pcCU->getPic()->getPicSym()->getFrameWidthInCU(); 3235 Int frameHeightInCU = pcCU->getPic()->getPicSym()->getFrameHeightInCU(); 3236 Bool leftCUExists = (currCUaddr % frameWitdhInCU) > 0; 3237 Bool aboveCUExists = (currCUaddr / frameWitdhInCU) > 0; 3238 Bool rightCUExists = (currCUaddr % frameWitdhInCU) < (frameWitdhInCU - 1); 3239 Bool belowCUExists = (currCUaddr / frameWitdhInCU) < (frameHeightInCU - 1); 3240 Int currTileSetIdx = pcCU->getPic()->getPicSym()->getTileIdxMap(currCUaddr); 3241 // Check if CU is at tile set boundary 3242 if ( (leftCUExists && pcCU->getPic()->getPicSym()->getTileIdxMap(currCUaddr-1) != currTileSetIdx) || 3243 (leftCUExists && aboveCUExists && pcCU->getPic()->getPicSym()->getTileIdxMap(currCUaddr-frameWitdhInCU-1) != currTileSetIdx) || 3244 (aboveCUExists && pcCU->getPic()->getPicSym()->getTileIdxMap(currCUaddr-frameWitdhInCU) != currTileSetIdx) || 3245 (aboveCUExists && rightCUExists && pcCU->getPic()->getPicSym()->getTileIdxMap(currCUaddr-frameWitdhInCU+1) != currTileSetIdx) || 3246 (rightCUExists && pcCU->getPic()->getPicSym()->getTileIdxMap(currCUaddr+1) != currTileSetIdx) || 3247 (rightCUExists && belowCUExists && pcCU->getPic()->getPicSym()->getTileIdxMap(currCUaddr+frameWitdhInCU+1) != currTileSetIdx) || 3248 (belowCUExists && pcCU->getPic()->getPicSym()->getTileIdxMap(currCUaddr+frameWitdhInCU) != currTileSetIdx) || 3249 (belowCUExists && leftCUExists && pcCU->getPic()->getPicSym()->getTileIdxMap(currCUaddr+frameWitdhInCU-1) != currTileSetIdx) ) 3250 { 3251 disableILP = true; // Disable ILP in tile set boundary CU 3252 } 3253 } 3254 } 3255 #endif 3256 3219 3257 for ( Int iPartIdx = 0; iPartIdx < iNumPart; iPartIdx++ ) 3220 3258 { … … 3266 3304 for ( Int iRefIdxTemp = 0; iRefIdxTemp < pcCU->getSlice()->getNumRefIdx(eRefPicList); iRefIdxTemp++ ) 3267 3305 { 3306 #if N0383_IL_CONSTRAINED_TILE_SETS_SEI 3307 if (pcCU->getSlice()->getRefPic( eRefPicList, iRefIdxTemp )->isILR(pcCU->getLayerId()) && disableILP) 3308 { 3309 continue; 3310 } 3311 #endif 3268 3312 #if (ENCODER_FAST_MODE) 3269 3313 TComPic* pcPic = pcCU->getSlice()->getRefPic( eRefPicList, iRefIdxTemp ); … … 3484 3528 testIter = false; //the fixed part is ILR, skip this iteration 3485 3529 } 3530 #if N0383_IL_CONSTRAINED_TILE_SETS_SEI 3531 if (pcPic->isILR(pcCU->getLayerId()) && disableILP) 3532 { 3533 testIter = false; 3534 } 3535 #endif 3486 3536 if(testIter) 3487 3537 { … … 3499 3549 testRefIdx = false; //the refined part is ILR, skip this reference pic 3500 3550 } 3551 #if N0383_IL_CONSTRAINED_TILE_SETS_SEI 3552 if (pcPic->isILR(pcCU->getLayerId()) && disableILP) 3553 { 3554 testRefIdx = false; 3555 } 3556 #endif 3501 3557 if(testRefIdx) 3502 3558 { … … 4610 4666 while((uiWidth>>uiMaxTrMode) < (g_uiMaxCUWidth>>g_uiMaxCUDepth)) uiMaxTrMode--; 4611 4667 4668 #if REPN_FORMAT_IN_VPS 4669 qpMin = bHighPass ? Clip3( -pcCU->getSlice()->getQpBDOffsetY(), MAX_QP, pcCU->getQP(0) - m_iMaxDeltaQP ) : pcCU->getQP( 0 ); 4670 qpMax = bHighPass ? Clip3( -pcCU->getSlice()->getQpBDOffsetY(), MAX_QP, pcCU->getQP(0) + m_iMaxDeltaQP ) : pcCU->getQP( 0 ); 4671 #else 4612 4672 qpMin = bHighPass ? Clip3( -pcCU->getSlice()->getSPS()->getQpBDOffsetY(), MAX_QP, pcCU->getQP(0) - m_iMaxDeltaQP ) : pcCU->getQP( 0 ); 4613 4673 qpMax = bHighPass ? Clip3( -pcCU->getSlice()->getSPS()->getQpBDOffsetY(), MAX_QP, pcCU->getQP(0) + m_iMaxDeltaQP ) : pcCU->getQP( 0 ); 4674 #endif 4614 4675 4615 4676 rpcYuvResi->subtract( pcYuvOrg, pcYuvPred, 0, uiWidth ); … … 4860 4921 } 4861 4922 4923 #if REPN_FORMAT_IN_VPS 4924 m_pcTrQuant->setQPforQuant( pcCU->getQP( 0 ), TEXT_LUMA, pcCU->getSlice()->getQpBDOffsetY(), 0 ); 4925 #else 4862 4926 m_pcTrQuant->setQPforQuant( pcCU->getQP( 0 ), TEXT_LUMA, pcCU->getSlice()->getSPS()->getQpBDOffsetY(), 0 ); 4927 #endif 4863 4928 4864 4929 #if RDOQ_CHROMA_LAMBDA … … 4946 5011 Pel *pcResiCurrY = m_pcQTTempTComYuv[ uiQTTempAccessLayer ].getLumaAddr( absTUPartIdx ); 4947 5012 5013 #if REPN_FORMAT_IN_VPS 4948 5014 m_pcTrQuant->setQPforQuant( pcCU->getQP( 0 ), TEXT_LUMA, pcCU->getSlice()->getSPS()->getQpBDOffsetY(), 0 ); 5015 #else 5016 m_pcTrQuant->setQPforQuant( pcCU->getQP( 0 ), TEXT_LUMA, pcCU->getSlice()->getSPS()->getQpBDOffsetY(), 0 ); 5017 #endif 4949 5018 4950 5019 Int scalingListType = 3 + g_eTTable[(Int)TEXT_LUMA]; … … 5195 5264 } 5196 5265 5266 #if REPN_FORMAT_IN_VPS 5267 m_pcTrQuant->setQPforQuant( pcCU->getQP( 0 ), TEXT_LUMA, pcCU->getSlice()->getQpBDOffsetY(), 0 ); 5268 #else 5197 5269 m_pcTrQuant->setQPforQuant( pcCU->getQP( 0 ), TEXT_LUMA, pcCU->getSlice()->getSPS()->getQpBDOffsetY(), 0 ); 5270 #endif 5198 5271 5199 5272 #if RDOQ_CHROMA_LAMBDA … … 5214 5287 const UInt uiTsSingleBitsY = m_pcEntropyCoder->getNumberOfWrittenBits(); 5215 5288 5289 #if REPN_FORMAT_IN_VPS 5290 m_pcTrQuant->setQPforQuant( pcCU->getQP( 0 ), TEXT_LUMA, pcCU->getSlice()->getQpBDOffsetY(), 0 ); 5291 #else 5216 5292 m_pcTrQuant->setQPforQuant( pcCU->getQP( 0 ), TEXT_LUMA, pcCU->getSlice()->getSPS()->getQpBDOffsetY(), 0 ); 5293 #endif 5217 5294 5218 5295 Int scalingListType = 3 + g_eTTable[(Int)TEXT_LUMA]; -
trunk/source/Lib/TLibEncoder/TEncSlice.cpp
r345 r442 180 180 #if SVC_EXTENSION 181 181 //\param vps VPS associated with the slice 182 Void TEncSlice::initEncSlice( TComPic* pcPic, Int pocLast, Int pocCurr, Int iNumPicRcvd, Int iGOPid, TComSlice*& rpcSlice, TComSPS* pSPS, TComPPS *pPPS, TComVPS *vps )183 #else 184 Void TEncSlice::initEncSlice( TComPic* pcPic, Int pocLast, Int pocCurr, Int iNumPicRcvd, Int iGOPid, TComSlice*& rpcSlice, TComSPS* pSPS, TComPPS *pPPS )182 Void TEncSlice::initEncSlice( TComPic* pcPic, Int pocLast, Int pocCurr, Int iNumPicRcvd, Int iGOPid, TComSlice*& rpcSlice, TComSPS* pSPS, TComPPS *pPPS, TComVPS *vps, Bool isField ) 183 #else 184 Void TEncSlice::initEncSlice( TComPic* pcPic, Int pocLast, Int pocCurr, Int iNumPicRcvd, Int iGOPid, TComSlice*& rpcSlice, TComSPS* pSPS, TComPPS *pPPS, Bool isField ) 185 185 #endif 186 186 { … … 260 260 if(eSliceType!=I_SLICE) 261 261 { 262 #if REPN_FORMAT_IN_VPS 263 if (!(( m_pcCfg->getMaxDeltaQP() == 0 ) && (dQP == -rpcSlice->getQpBDOffsetY() ) && (rpcSlice->getSPS()->getUseLossless()))) 264 #else 262 265 if (!(( m_pcCfg->getMaxDeltaQP() == 0 ) && (dQP == -rpcSlice->getSPS()->getQpBDOffsetY() ) && (rpcSlice->getSPS()->getUseLossless()))) 266 #endif 263 267 { 264 268 dQP += m_pcCfg->getGOPEntry(iGOPid).m_QPOffset; … … 294 298 Int NumberBFrames = ( m_pcCfg->getGOPSize() - 1 ); 295 299 Int SHIFT_QP = 12; 296 Double dLambda_scale = 1.0 - Clip3( 0.0, 0.5, 0.05*(Double)NumberBFrames ); 300 301 Double dLambda_scale = 1.0 - Clip3( 0.0, 0.5, 0.05*(Double)(isField ? NumberBFrames/2 : NumberBFrames) ); 302 297 303 #if FULL_NBIT 298 304 Int bitdepth_luma_qp_scale = 6 * (g_bitDepth - 8); … … 327 333 } 328 334 335 #if REPN_FORMAT_IN_VPS 336 iQP = max( -rpcSlice->getQpBDOffsetY(), min( MAX_QP, (Int) floor( dQP + 0.5 ) ) ); 337 #else 329 338 iQP = max( -pSPS->getQpBDOffsetY(), min( MAX_QP, (Int) floor( dQP + 0.5 ) ) ); 339 #endif 330 340 331 341 m_pdRdPicLambda[iDQpIdx] = dLambda; … … 400 410 eSliceType = (pocLast == 0 || pocCurr % m_pcCfg->getIntraPeriod() == 0 || m_pcGOPEncoder->getGOPSize() == 0) ? I_SLICE : eSliceType; 401 411 402 #if REF_IDX_FRAMEWORK412 #if SVC_EXTENSION 403 413 if(m_pcCfg->getLayerId() > 0) 404 414 { … … 412 422 { 413 423 dQP = xGetQPValueAccordingToLambda( dLambda ); 424 #if REPN_FORMAT_IN_VPS 425 iQP = max( -rpcSlice->getQpBDOffsetY(), min( MAX_QP, (Int) floor( dQP + 0.5 ) ) ); 426 #else 414 427 iQP = max( -pSPS->getQpBDOffsetY(), min( MAX_QP, (Int) floor( dQP + 0.5 ) ) ); 428 #endif 415 429 } 416 430 … … 467 481 468 482 pcPic->setTLayer( m_pcCfg->getGOPEntry(iGOPid).m_temporalId ); 483 #if TEMP_SCALABILITY_FIX 484 if((eSliceType==I_SLICE) || (rpcSlice->getPOC() == 0)) 485 #else 469 486 if(eSliceType==I_SLICE) 487 #endif 470 488 { 471 489 pcPic->setTLayer(0); … … 485 503 xStoreWPparam( pPPS->getUseWP(), pPPS->getWPBiPred() ); 486 504 487 #if SVC_EXTENSION && REF_IDX_FRAMEWORK505 #if SVC_EXTENSION 488 506 if( layerId > 0 ) 489 507 { … … 606 624 } 607 625 626 #if REPN_FORMAT_IN_VPS 627 qp = max( -pcSlice->getQpBDOffsetY(), min( MAX_QP, (Int) floor( recalQP + 0.5 ) ) ); 628 #else 608 629 qp = max( -pcSPS->getQpBDOffsetY(), min( MAX_QP, (Int) floor( recalQP + 0.5 ) ) ); 630 #endif 609 631 610 632 m_pdRdPicLambda[deltqQpIdx] = lambda; … … 849 871 pcCU->initCU( rpcPic, uiCUAddr ); 850 872 873 #if REPN_FORMAT_IN_VPS 874 Int height = min( pcSlice->getSPS()->getMaxCUHeight(),pcSlice->getPicHeightInLumaSamples() - uiCUAddr / rpcPic->getFrameWidthInCU() * pcSlice->getSPS()->getMaxCUHeight() ); 875 Int width = min( pcSlice->getSPS()->getMaxCUWidth(), pcSlice->getPicWidthInLumaSamples() - uiCUAddr % rpcPic->getFrameWidthInCU() * pcSlice->getSPS()->getMaxCUWidth() ); 876 #else 851 877 Int height = min( pcSlice->getSPS()->getMaxCUHeight(),pcSlice->getSPS()->getPicHeightInLumaSamples() - uiCUAddr / rpcPic->getFrameWidthInCU() * pcSlice->getSPS()->getMaxCUHeight() ); 852 878 Int width = min( pcSlice->getSPS()->getMaxCUWidth(),pcSlice->getSPS()->getPicWidthInLumaSamples() - uiCUAddr % rpcPic->getFrameWidthInCU() * pcSlice->getSPS()->getMaxCUWidth() ); 879 #endif 853 880 854 881 iSumHad = m_pcCuEncoder->updateLCUDataISlice(pcCU, uiCUAddr, width, height); … … 1148 1175 #endif 1149 1176 1177 #if REPN_FORMAT_IN_VPS 1178 estQP = Clip3( -pcSlice->getQpBDOffsetY(), MAX_QP, estQP ); 1179 #else 1150 1180 estQP = Clip3( -pcSlice->getSPS()->getQpBDOffsetY(), MAX_QP, estQP ); 1181 #endif 1151 1182 1152 1183 m_pcRdCost->setLambda(estLambda); … … 1176 1207 #if !M0036_RC_IMPROVEMENT 1177 1208 UInt SAD = m_pcCuEncoder->getLCUPredictionSAD(); 1209 #if REPN_FORMAT_IN_VPS 1210 Int height = min( pcSlice->getSPS()->getMaxCUHeight(),pcSlice->getPicHeightInLumaSamples() - uiCUAddr / rpcPic->getFrameWidthInCU() * pcSlice->getSPS()->getMaxCUHeight() ); 1211 Int width = min( pcSlice->getSPS()->getMaxCUWidth(),pcSlice->>getPicWidthInLumaSamples() - uiCUAddr % rpcPic->getFrameWidthInCU() * pcSlice->getSPS()->getMaxCUWidth() ); 1212 #else 1178 1213 Int height = min( pcSlice->getSPS()->getMaxCUHeight(),pcSlice->getSPS()->getPicHeightInLumaSamples() - uiCUAddr / rpcPic->getFrameWidthInCU() * pcSlice->getSPS()->getMaxCUHeight() ); 1179 1214 Int width = min( pcSlice->getSPS()->getMaxCUWidth(),pcSlice->getSPS()->getPicWidthInLumaSamples() - uiCUAddr % rpcPic->getFrameWidthInCU() * pcSlice->getSPS()->getMaxCUWidth() ); 1215 #endif 1180 1216 Double MAD = (Double)SAD / (Double)(height * width); 1181 1217 MAD = MAD * MAD; … … 1253 1289 #if !M0036_RC_IMPROVEMENT 1254 1290 UInt SAD = m_pcCuEncoder->getLCUPredictionSAD(); 1291 #if REPN_FORMAT_IN_VPS 1292 Int height = min( pcSlice->getSPS()->getMaxCUHeight(),pcSlice->getPicHeightInLumaSamples() - uiCUAddr / rpcPic->getFrameWidthInCU() * pcSlice->getSPS()->getMaxCUHeight() ); 1293 Int width = min( pcSlice->getSPS()->getMaxCUWidth(),pcSlice->getPicWidthInLumaSamples() - uiCUAddr % rpcPic->getFrameWidthInCU() * pcSlice->getSPS()->getMaxCUWidth() ); 1294 #else 1255 1295 Int height = min( pcSlice->getSPS()->getMaxCUHeight(),pcSlice->getSPS()->getPicHeightInLumaSamples() - uiCUAddr / rpcPic->getFrameWidthInCU() * pcSlice->getSPS()->getMaxCUHeight() ); 1256 1296 Int width = min( pcSlice->getSPS()->getMaxCUWidth(),pcSlice->getSPS()->getPicWidthInLumaSamples() - uiCUAddr % rpcPic->getFrameWidthInCU() * pcSlice->getSPS()->getMaxCUWidth() ); 1297 #endif 1257 1298 Double MAD = (Double)SAD / (Double)(height * width); 1258 1299 MAD = MAD * MAD; … … 1919 1960 UInt uiPosX = ( uiExternalAddress % rpcPic->getFrameWidthInCU() ) * g_uiMaxCUWidth+ g_auiRasterToPelX[ g_auiZscanToRaster[uiInternalAddress] ]; 1920 1961 UInt uiPosY = ( uiExternalAddress / rpcPic->getFrameWidthInCU() ) * g_uiMaxCUHeight+ g_auiRasterToPelY[ g_auiZscanToRaster[uiInternalAddress] ]; 1962 #if REPN_FORMAT_IN_VPS 1963 UInt uiWidth = pcSlice->getPicWidthInLumaSamples(); 1964 UInt uiHeight = pcSlice->getPicHeightInLumaSamples(); 1965 #else 1921 1966 UInt uiWidth = pcSlice->getSPS()->getPicWidthInLumaSamples(); 1922 1967 UInt uiHeight = pcSlice->getSPS()->getPicHeightInLumaSamples(); 1968 #endif 1923 1969 while((uiPosX>=uiWidth||uiPosY>=uiHeight)&&!(uiPosX>=uiWidth&&uiPosY>=uiHeight)) 1924 1970 { … … 1942 1988 uiPosX = ( uiExternalAddress % rpcPic->getFrameWidthInCU() ) * g_uiMaxCUWidth+ g_auiRasterToPelX[ g_auiZscanToRaster[uiInternalAddress] ]; 1943 1989 uiPosY = ( uiExternalAddress / rpcPic->getFrameWidthInCU() ) * g_uiMaxCUHeight+ g_auiRasterToPelY[ g_auiZscanToRaster[uiInternalAddress] ]; 1990 #if REPN_FORMAT_IN_VPS 1991 uiWidth = pcSlice->getPicWidthInLumaSamples(); 1992 uiHeight = pcSlice->getPicHeightInLumaSamples(); 1993 #else 1944 1994 uiWidth = pcSlice->getSPS()->getPicWidthInLumaSamples(); 1945 1995 uiHeight = pcSlice->getSPS()->getPicHeightInLumaSamples(); 1996 #endif 1946 1997 while((uiPosX>=uiWidth||uiPosY>=uiHeight)&&!(uiPosX>=uiWidth&&uiPosY>=uiHeight)) 1947 1998 { -
trunk/source/Lib/TLibEncoder/TEncSlice.h
r313 r442 118 118 #if SVC_EXTENSION 119 119 Void initEncSlice ( TComPic* pcPic, Int pocLast, Int pocCurr, Int iNumPicRcvd, 120 Int iGOPid, TComSlice*& rpcSlice, TComSPS* pSPS, TComPPS *pPPS, TComVPS *vps );120 Int iGOPid, TComSlice*& rpcSlice, TComSPS* pSPS, TComPPS *pPPS, TComVPS *vps, Bool isField ); 121 121 #else 122 122 Void initEncSlice ( TComPic* pcPic, Int pocLast, Int pocCurr, Int iNumPicRcvd, 123 Int iGOPid, TComSlice*& rpcSlice, TComSPS* pSPS, TComPPS *pPPS );123 Int iGOPid, TComSlice*& rpcSlice, TComSPS* pSPS, TComPPS *pPPS, Bool isField ); 124 124 #endif 125 125 -
trunk/source/Lib/TLibEncoder/TEncTop.cpp
r345 r442 83 83 m_pcBitCounters = NULL; 84 84 m_pcRdCosts = NULL; 85 #if REF_IDX_FRAMEWORK85 #if SVC_EXTENSION 86 86 memset(m_cIlpPic, 0, sizeof(m_cIlpPic)); 87 #endif88 87 #if REF_IDX_MFM 89 88 m_bMFMEnabledFlag = false; … … 91 90 #if SCALED_REF_LAYER_OFFSETS 92 91 m_numScaledRefLayerOffsets = 0; 92 #endif 93 #endif 94 #if POC_RESET_FLAG 95 m_pocAdjustmentValue = 0; 93 96 #endif 94 97 } … … 107 110 initROM(); 108 111 #endif 109 112 110 113 // create processing unit classes 111 114 #if SVC_EXTENSION … … 288 291 delete[] m_pcRdCosts; 289 292 290 #if !SVC_EXTENSION 291 // destroy ROM 292 destroyROM(); 293 #endif 294 #if REF_IDX_FRAMEWORK 293 #if SVC_EXTENSION 295 294 for(Int i=0; i<MAX_NUM_REF; i++) 296 295 { … … 301 300 m_cIlpPic[i] = NULL; 302 301 } 303 } 302 } 303 #else 304 // destroy ROM 305 destroyROM(); 304 306 #endif 305 307 return; 306 308 } 307 309 308 Void TEncTop::init( )310 Void TEncTop::init(Bool isFieldCoding) 309 311 { 310 312 // initialize SPS … … 317 319 m_cPPS.setSPS(&m_cSPS); 318 320 xInitPPS(); 319 xInitRPS( );321 xInitRPS(isFieldCoding); 320 322 321 323 xInitPPSforTiles(); … … 346 348 m_iSPSIdCnt ++; 347 349 m_iPPSIdCnt ++; 348 #endif349 #if REF_IDX_FRAMEWORK350 350 xInitILRP(); 351 351 #endif … … 396 396 397 397 // compress GOP 398 m_cGOPEncoder.compressGOP(iPicIdInGOP, m_iPOCLast, m_iNumPicRcvd, m_cListPic, rcListPicYuvRecOut, accessUnitsOut );398 m_cGOPEncoder.compressGOP(iPicIdInGOP, m_iPOCLast, m_iNumPicRcvd, m_cListPic, rcListPicYuvRecOut, accessUnitsOut, false, false); 399 399 400 400 #if RATE_CONTROL_LAMBDA_DOMAIN … … 456 456 457 457 // compress GOP 458 m_cGOPEncoder.compressGOP(m_iPOCLast, m_iNumPicRcvd, m_cListPic, rcListPicYuvRecOut, accessUnitsOut); 458 459 m_cGOPEncoder.compressGOP(m_iPOCLast, m_iNumPicRcvd, m_cListPic, rcListPicYuvRecOut, accessUnitsOut, false, false); 459 460 460 461 #if RATE_CONTROL_LAMBDA_DOMAIN … … 467 468 iNumEncoded = m_iNumPicRcvd; 468 469 m_iNumPicRcvd = 0; 470 m_uiNumAllPicCoded += iNumEncoded; 471 } 472 #endif 473 474 /**------------------------------------------------ 475 Separate interlaced frame into two fields 476 -------------------------------------------------**/ 477 void separateFields(Pel* org, Pel* dstField, UInt stride, UInt width, UInt height, Bool isTop) 478 { 479 if (!isTop) 480 { 481 org += stride; 482 } 483 for (Int y = 0; y < height>>1; y++) 484 { 485 for (Int x = 0; x < width; x++) 486 { 487 dstField[x] = org[x]; 488 } 489 490 dstField += stride; 491 org += stride*2; 492 } 493 494 } 495 496 #if SVC_EXTENSION 497 Void TEncTop::encodePrep( TComPicYuv* pcPicYuvOrg, Bool isTff ) 498 { 499 if (pcPicYuvOrg) 500 { 501 /* -- TOP FIELD -- */ 502 /* -- Top field initialization -- */ 503 504 TComPic *pcTopField; 505 xGetNewPicBuffer( pcTopField ); 506 pcTopField->getPicSym()->allocSaoParam(&m_cEncSAO); 507 pcTopField->setReconMark (false); 508 509 pcTopField->getSlice(0)->setPOC( m_iPOCLast ); 510 pcTopField->getPicYuvRec()->setBorderExtension(false); 511 pcTopField->setTopField(isTff); 512 513 Int nHeight = pcPicYuvOrg->getHeight(); 514 Int nWidth = pcPicYuvOrg->getWidth(); 515 Int nStride = pcPicYuvOrg->getStride(); 516 Int nPadLuma = pcPicYuvOrg->getLumaMargin(); 517 Int nPadChroma = pcPicYuvOrg->getChromaMargin(); 518 519 // Get pointers 520 Pel * PicBufY = pcPicYuvOrg->getBufY(); 521 Pel * PicBufU = pcPicYuvOrg->getBufU(); 522 Pel * PicBufV = pcPicYuvOrg->getBufV(); 523 524 Pel * pcTopFieldY = pcTopField->getPicYuvOrg()->getLumaAddr(); 525 Pel * pcTopFieldU = pcTopField->getPicYuvOrg()->getCbAddr(); 526 Pel * pcTopFieldV = pcTopField->getPicYuvOrg()->getCrAddr(); 527 528 // compute image characteristics 529 if ( getUseAdaptiveQP() ) 530 { 531 m_cPreanalyzer.xPreanalyze( dynamic_cast<TEncPic*>( pcTopField ) ); 532 } 533 534 /* -- Defield -- */ 535 536 Bool isTop = isTff; 537 538 separateFields(PicBufY + nPadLuma + nStride*nPadLuma, pcTopFieldY, nStride, nWidth, nHeight, isTop); 539 separateFields(PicBufU + nPadChroma + (nStride >> 1)*nPadChroma, pcTopFieldU, nStride >> 1, nWidth >> 1, nHeight >> 1, isTop); 540 separateFields(PicBufV + nPadChroma + (nStride >> 1)*nPadChroma, pcTopFieldV, nStride >> 1, nWidth >> 1, nHeight >> 1, isTop); 541 542 /* -- BOTTOM FIELD -- */ 543 /* -- Bottom field initialization -- */ 544 545 TComPic* pcBottomField; 546 xGetNewPicBuffer( pcBottomField ); 547 pcBottomField->getPicSym()->allocSaoParam(&m_cEncSAO); 548 pcBottomField->setReconMark (false); 549 550 pcBottomField->getSlice(0)->setPOC( m_iPOCLast); 551 pcBottomField->getPicYuvRec()->setBorderExtension(false); 552 pcBottomField->setTopField(!isTff); 553 554 nHeight = pcPicYuvOrg->getHeight(); 555 nWidth = pcPicYuvOrg->getWidth(); 556 nStride = pcPicYuvOrg->getStride(); 557 nPadLuma = pcPicYuvOrg->getLumaMargin(); 558 nPadChroma = pcPicYuvOrg->getChromaMargin(); 559 560 // Get pointers 561 PicBufY = pcPicYuvOrg->getBufY(); 562 PicBufU = pcPicYuvOrg->getBufU(); 563 PicBufV = pcPicYuvOrg->getBufV(); 564 565 Pel * pcBottomFieldY = pcBottomField->getPicYuvOrg()->getLumaAddr(); 566 Pel * pcBottomFieldU = pcBottomField->getPicYuvOrg()->getCbAddr(); 567 Pel * pcBottomFieldV = pcBottomField->getPicYuvOrg()->getCrAddr(); 568 569 // Compute image characteristics 570 if ( getUseAdaptiveQP() ) 571 { 572 m_cPreanalyzer.xPreanalyze( dynamic_cast<TEncPic*>( pcBottomField ) ); 573 } 574 575 /* -- Defield -- */ 576 577 isTop = !isTff; 578 579 separateFields(PicBufY + nPadLuma + nStride*nPadLuma, pcBottomFieldY, nStride, nWidth, nHeight, isTop); 580 separateFields(PicBufU + nPadChroma + (nStride >> 1)*nPadChroma, pcBottomFieldU, nStride >> 1, nWidth >> 1, nHeight >> 1, isTop); 581 separateFields(PicBufV + nPadChroma + (nStride >> 1)*nPadChroma, pcBottomFieldV, nStride >> 1, nWidth >> 1, nHeight >> 1, isTop); 582 583 } 584 } 585 586 Void TEncTop::encode( TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsOut, Int iPicIdInGOP, Bool isTff ) 587 { 588 // compress GOP 589 if (m_iPOCLast == 0) // compress field 0 590 { 591 m_cGOPEncoder.compressGOP(iPicIdInGOP, m_iPOCLast, m_iNumPicRcvd, m_cListPic, rcListPicYuvRecOut, accessUnitsOut, true, isTff); 592 } 593 594 if (pcPicYuvOrg) 595 { 596 TComPicYuv* rpcPicYuvRec = new TComPicYuv; 597 if ( rcListPicYuvRecOut.size() == (UInt)m_iGOPSize ) 598 { 599 rpcPicYuvRec = rcListPicYuvRecOut.popFront(); 600 } 601 else 602 { 603 rpcPicYuvRec->create( m_iSourceWidth, m_iSourceHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth ); 604 } 605 rcListPicYuvRecOut.pushBack( rpcPicYuvRec ); 606 } 607 608 // compress GOP 609 m_cGOPEncoder.compressGOP(iPicIdInGOP, m_iPOCLast, m_iNumPicRcvd, m_cListPic, rcListPicYuvRecOut, accessUnitsOut, true, isTff); 610 611 m_uiNumAllPicCoded ++; 612 } 613 #else 614 Void TEncTop::encode(Bool flush, TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsOut, Int& iNumEncoded, Bool isTff) 615 { 616 /* -- TOP FIELD -- */ 617 618 if (pcPicYuvOrg) 619 { 620 621 /* -- Top field initialization -- */ 622 623 TComPic *pcTopField; 624 xGetNewPicBuffer( pcTopField ); 625 pcTopField->getPicSym()->allocSaoParam(&m_cEncSAO); 626 pcTopField->setReconMark (false); 627 628 pcTopField->getSlice(0)->setPOC( m_iPOCLast ); 629 pcTopField->getPicYuvRec()->setBorderExtension(false); 630 pcTopField->setTopField(isTff); 631 632 Int nHeight = pcPicYuvOrg->getHeight(); 633 Int nWidth = pcPicYuvOrg->getWidth(); 634 Int nStride = pcPicYuvOrg->getStride(); 635 Int nPadLuma = pcPicYuvOrg->getLumaMargin(); 636 Int nPadChroma = pcPicYuvOrg->getChromaMargin(); 637 638 // Get pointers 639 Pel * PicBufY = pcPicYuvOrg->getBufY(); 640 Pel * PicBufU = pcPicYuvOrg->getBufU(); 641 Pel * PicBufV = pcPicYuvOrg->getBufV(); 642 643 Pel * pcTopFieldY = pcTopField->getPicYuvOrg()->getLumaAddr(); 644 Pel * pcTopFieldU = pcTopField->getPicYuvOrg()->getCbAddr(); 645 Pel * pcTopFieldV = pcTopField->getPicYuvOrg()->getCrAddr(); 646 647 // compute image characteristics 648 if ( getUseAdaptiveQP() ) 649 { 650 m_cPreanalyzer.xPreanalyze( dynamic_cast<TEncPic*>( pcTopField ) ); 651 } 652 653 /* -- Defield -- */ 654 655 Bool isTop = isTff; 656 657 separateFields(PicBufY + nPadLuma + nStride*nPadLuma, pcTopFieldY, nStride, nWidth, nHeight, isTop); 658 separateFields(PicBufU + nPadChroma + (nStride >> 1)*nPadChroma, pcTopFieldU, nStride >> 1, nWidth >> 1, nHeight >> 1, isTop); 659 separateFields(PicBufV + nPadChroma + (nStride >> 1)*nPadChroma, pcTopFieldV, nStride >> 1, nWidth >> 1, nHeight >> 1, isTop); 660 661 } 662 663 if (m_iPOCLast == 0) // compress field 0 664 { 665 m_cGOPEncoder.compressGOP(m_iPOCLast, m_iNumPicRcvd, m_cListPic, rcListPicYuvRecOut, accessUnitsOut, true, isTff); 666 } 667 668 /* -- BOTTOM FIELD -- */ 669 670 if (pcPicYuvOrg) 671 { 672 673 /* -- Bottom field initialization -- */ 674 675 TComPic* pcBottomField; 676 xGetNewPicBuffer( pcBottomField ); 677 pcBottomField->getPicSym()->allocSaoParam(&m_cEncSAO); 678 pcBottomField->setReconMark (false); 679 680 TComPicYuv* rpcPicYuvRec = new TComPicYuv; 681 if ( rcListPicYuvRecOut.size() == (UInt)m_iGOPSize ) 682 { 683 rpcPicYuvRec = rcListPicYuvRecOut.popFront(); 684 } 685 else 686 { 687 rpcPicYuvRec->create( m_iSourceWidth, m_iSourceHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth ); 688 } 689 rcListPicYuvRecOut.pushBack( rpcPicYuvRec ); 690 691 pcBottomField->getSlice(0)->setPOC( m_iPOCLast); 692 pcBottomField->getPicYuvRec()->setBorderExtension(false); 693 pcBottomField->setTopField(!isTff); 694 695 int nHeight = pcPicYuvOrg->getHeight(); 696 int nWidth = pcPicYuvOrg->getWidth(); 697 int nStride = pcPicYuvOrg->getStride(); 698 int nPadLuma = pcPicYuvOrg->getLumaMargin(); 699 int nPadChroma = pcPicYuvOrg->getChromaMargin(); 700 701 // Get pointers 702 Pel * PicBufY = pcPicYuvOrg->getBufY(); 703 Pel * PicBufU = pcPicYuvOrg->getBufU(); 704 Pel * PicBufV = pcPicYuvOrg->getBufV(); 705 706 Pel * pcBottomFieldY = pcBottomField->getPicYuvOrg()->getLumaAddr(); 707 Pel * pcBottomFieldU = pcBottomField->getPicYuvOrg()->getCbAddr(); 708 Pel * pcBottomFieldV = pcBottomField->getPicYuvOrg()->getCrAddr(); 709 710 // Compute image characteristics 711 if ( getUseAdaptiveQP() ) 712 { 713 m_cPreanalyzer.xPreanalyze( dynamic_cast<TEncPic*>( pcBottomField ) ); 714 } 715 716 /* -- Defield -- */ 717 718 Bool isTop = !isTff; 719 720 separateFields(PicBufY + nPadLuma + nStride*nPadLuma, pcBottomFieldY, nStride, nWidth, nHeight, isTop); 721 separateFields(PicBufU + nPadChroma + (nStride >> 1)*nPadChroma, pcBottomFieldU, nStride >> 1, nWidth >> 1, nHeight >> 1, isTop); 722 separateFields(PicBufV + nPadChroma + (nStride >> 1)*nPadChroma, pcBottomFieldV, nStride >> 1, nWidth >> 1, nHeight >> 1, isTop); 723 724 } 725 726 if ( ( !(m_iNumPicRcvd) || (!flush && m_iPOCLast != 1 && m_iNumPicRcvd != m_iGOPSize && m_iGOPSize)) ) 727 { 728 iNumEncoded = 0; 729 return; 730 } 731 732 // compress GOP 733 m_cGOPEncoder.compressGOP(m_iPOCLast, m_iNumPicRcvd, m_cListPic, rcListPicYuvRecOut, accessUnitsOut, true, isTff); 734 735 iNumEncoded = m_iNumPicRcvd; 736 m_iNumPicRcvd = 0; 469 737 m_uiNumAllPicCoded += iNumEncoded; 470 738 } … … 523 791 524 792 //only for scalable extension 793 #if SCALABILITY_MASK_E0104 794 assert( m_cVPS.getScalabilityMask(2) == true ); 795 #else 525 796 assert( m_cVPS.getScalabilityMask(1) == true ); 797 #endif 526 798 } 527 799 } … … 560 832 561 833 //only for scalable extension 834 #if SCALABILITY_MASK_E0104 835 assert( m_cVPS.getScalabilityMask(2) == true ); 836 #else 562 837 assert( m_cVPS.getScalabilityMask(1) == true ); 838 #endif 563 839 } 564 840 } … … 682 958 } 683 959 960 #if REPN_FORMAT_IN_VPS 961 m_cSPS.setBitDepthY( m_cVPS.getVpsRepFormat( m_cVPS.getVpsRepFormatIdx( m_layerId ) )->getBitDepthVpsLuma() ); 962 m_cSPS.setBitDepthC( m_cVPS.getVpsRepFormat( m_cVPS.getVpsRepFormatIdx( m_layerId ) )->getBitDepthVpsChroma() ); 963 964 m_cSPS.setQpBDOffsetY ( 6*(m_cVPS.getVpsRepFormat( m_cVPS.getVpsRepFormatIdx( m_layerId ) )->getBitDepthVpsLuma() - 8) ); 965 m_cSPS.setQpBDOffsetC ( 6*(m_cVPS.getVpsRepFormat( m_cVPS.getVpsRepFormatIdx( m_layerId ) )->getBitDepthVpsChroma() - 8) ); 966 #else 684 967 m_cSPS.setBitDepthY( g_bitDepthY ); 685 968 m_cSPS.setBitDepthC( g_bitDepthC ); … … 687 970 m_cSPS.setQpBDOffsetY ( 6*(g_bitDepthY - 8) ); 688 971 m_cSPS.setQpBDOffsetC ( 6*(g_bitDepthC - 8) ); 972 #endif 689 973 690 974 m_cSPS.setUseSAO( m_bUseSAO ); … … 745 1029 Void TEncTop::xInitPPS() 746 1030 { 1031 #if IL_SL_SIGNALLING_N0371 1032 m_cPPS.setLayerId(m_layerId); 1033 #endif 1034 747 1035 m_cPPS.setConstrainedIntraPred( m_bUseConstrainedIntraPred ); 748 1036 Bool bUseDQP = (getMaxCuDQPDepth() > 0)? true : false; 749 1037 1038 #if REPN_FORMAT_IN_VPS 1039 Int lowestQP; 1040 if( m_layerId == 0 || m_cSPS.getUpdateRepFormatFlag() ) 1041 { 1042 lowestQP = - m_cSPS.getQpBDOffsetY(); 1043 } 1044 else 1045 { 1046 lowestQP = - (m_cVPS.getVpsRepFormat( m_cVPS.getVpsRepFormatIdx( m_layerId ) )->getBitDepthVpsLuma() - 8) * 6; 1047 } 1048 #else 750 1049 Int lowestQP = - m_cSPS.getQpBDOffsetY(); 1050 #endif 751 1051 752 1052 if(getUseLossless()) … … 860 1160 } 861 1161 } 862 #if REF_IDX_FRAMEWORK1162 #if SVC_EXTENSION 863 1163 if (!m_layerId) 864 1164 { … … 869 1169 m_cPPS.setListsModificationPresentFlag(true); 870 1170 } 871 #endif 872 #if SVC_EXTENSION 1171 873 1172 m_cPPS.setPPSId ( m_iPPSIdCnt ); 874 1173 m_cPPS.setSPSId ( m_iSPSIdCnt ); 875 1174 #endif 1175 #if POC_RESET_FLAG 1176 m_cPPS.setNumExtraSliceHeaderBits( 2 ); 1177 #endif 876 1178 } 877 1179 878 1180 //Function for initializing m_RPSList, a list of TComReferencePictureSet, based on the GOPEntry objects read from the config file. 879 Void TEncTop::xInitRPS( )1181 Void TEncTop::xInitRPS(Bool isFieldCoding) 880 1182 { 881 1183 TComReferencePictureSet* rps; 882 1184 883 m_cSPS.createRPSList(getGOPSize()+m_extraRPSs );1185 m_cSPS.createRPSList(getGOPSize()+m_extraRPSs+1); 884 1186 TComRPSList* rpsList = m_cSPS.getRPSList(); 885 1187 … … 982 1284 printf("Warning: number of negative pictures in RPS is different between intra and inter RPS specified in the config file.\n"); 983 1285 rps->setNumberOfNegativePictures(numNeg); 984 rps->setNumberOfP ositivePictures(numNeg+numPos);1286 rps->setNumberOfPictures(numNeg+numPos); 985 1287 } 986 1288 if (numPos != rps->getNumberOfPositivePictures()) … … 988 1290 printf("Warning: number of positive pictures in RPS is different between intra and inter RPS specified in the config file.\n"); 989 1291 rps->setNumberOfPositivePictures(numPos); 990 rps->setNumberOfP ositivePictures(numNeg+numPos);1292 rps->setNumberOfPictures(numNeg+numPos); 991 1293 } 992 1294 RPSTemp.setNumberOfPictures(numNeg+numPos); … … 1052 1354 #endif //INTER_RPS_AUTO 1053 1355 } 1054 1356 //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. 1357 //The position = GOPSize + extraRPSs which is (a priori) unused is reserved for this field in the RPS. 1358 if (isFieldCoding) 1359 { 1360 rps = rpsList->getReferencePictureSet(getGOPSize()+m_extraRPSs); 1361 rps->setNumberOfPictures(1); 1362 rps->setNumberOfNegativePictures(1); 1363 rps->setNumberOfPositivePictures(0); 1364 rps->setNumberOfLongtermPictures(0); 1365 rps->setDeltaPOC(0,-1); 1366 rps->setPOC(0,0); 1367 rps->setUsed(0,true); 1368 rps->setInterRPSPrediction(false); 1369 rps->setDeltaRIdxMinus1(0); 1370 rps->setDeltaRPS(0); 1371 rps->setNumRefIdc(0); 1372 } 1055 1373 } 1056 1374 … … 1061 1379 { 1062 1380 slice->setRPSidx(GOPid); 1063 1064 1381 for(Int extraNum=m_iGOPSize; extraNum<m_extraRPSs+m_iGOPSize; extraNum++) 1065 1382 { … … 1085 1402 } 1086 1403 1404 if(POCCurr == 1 && slice->getPic()->isField()) 1405 { 1406 slice->setRPSidx(m_iGOPSize+m_extraRPSs); 1407 } 1408 1087 1409 slice->setRPS(getSPS()->getRPSList()->getReferencePictureSet(slice->getRPSidx())); 1088 1410 slice->getRPS()->setNumberOfPictures(slice->getRPS()->getNumberOfNegativePictures()+slice->getRPS()->getNumberOfPositivePictures()); 1089 1090 1411 } 1091 1412 … … 1215 1536 #endif 1216 1537 1217 #if REF_IDX_FRAMEWORK 1538 #if SVC_EXTENSION 1539 #if !REPN_FORMAT_IN_VPS 1218 1540 Void TEncTop::xInitILRP() 1219 1541 { … … 1249 1571 } 1250 1572 } 1251 1573 #else 1574 Void TEncTop::xInitILRP() 1575 { 1576 RepFormat *repFormat = m_cVPS.getVpsRepFormat( m_cVPS.getVpsRepFormatIdx( m_layerId ) ); 1577 Int bitDepthY,bitDepthC,picWidth,picHeight; 1578 1579 if( m_cSPS.getUpdateRepFormatFlag() ) 1580 { 1581 bitDepthY = m_cSPS.getBitDepthY(); 1582 bitDepthC = m_cSPS.getBitDepthC(); 1583 picWidth = m_cSPS.getPicWidthInLumaSamples(); 1584 picHeight = m_cSPS.getPicHeightInLumaSamples(); 1585 } 1586 else 1587 { 1588 bitDepthY = repFormat->getBitDepthVpsLuma(); 1589 bitDepthC = repFormat->getBitDepthVpsChroma(); 1590 picWidth = repFormat->getPicWidthVpsInLumaSamples(); 1591 picHeight = repFormat->getPicHeightVpsInLumaSamples(); 1592 } 1593 1594 if(m_layerId > 0) 1595 { 1596 g_bitDepthY = bitDepthY; 1597 g_bitDepthC = bitDepthC; 1598 g_uiMaxCUWidth = m_cSPS.getMaxCUWidth(); 1599 g_uiMaxCUHeight = m_cSPS.getMaxCUHeight(); 1600 g_uiMaxCUDepth = m_cSPS.getMaxCUDepth(); 1601 g_uiAddCUDepth = max (0, m_cSPS.getLog2MinCodingBlockSize() - (Int)m_cSPS.getQuadtreeTULog2MinSize() ); 1602 1603 Int numReorderPics[MAX_TLAYER]; 1604 Window &conformanceWindow = m_cSPS.getConformanceWindow(); 1605 Window defaultDisplayWindow = m_cSPS.getVuiParametersPresentFlag() ? m_cSPS.getVuiParameters()->getDefaultDisplayWindow() : Window(); 1606 1607 if (m_cIlpPic[0] == NULL) 1608 { 1609 for (Int j=0; j < MAX_LAYERS /*MAX_NUM_REF*/; j++) // consider to set to NumDirectRefLayers[LayerIdInVps[nuh_layer_id]] 1610 { 1611 m_cIlpPic[j] = new TComPic; 1612 #if SVC_UPSAMPLING 1613 m_cIlpPic[j]->create(picWidth, picHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, &m_cSPS, true); 1614 #else 1615 m_cIlpPic[j]->create(m_iSourceWidth, m_iSourceHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, conformanceWindow, defaultDisplayWindow, numReorderPics, true); 1616 #endif 1617 for (Int i=0; i<m_cIlpPic[j]->getPicSym()->getNumberOfCUsInFrame(); i++) 1618 { 1619 m_cIlpPic[j]->getPicSym()->getCU(i)->initCU(m_cIlpPic[j], i); 1620 } 1621 } 1622 } 1623 } 1624 } 1625 #endif 1252 1626 Void TEncTop::setILRPic(TComPic *pcPic) 1253 1627 { … … 1263 1637 m_cIlpPic[refLayerIdc]->getPicYuvRec()->setBorderExtension(false); 1264 1638 m_cIlpPic[refLayerIdc]->getPicYuvRec()->extendPicBorder(); 1639 for (Int j=0; j<m_cIlpPic[refLayerIdc]->getPicSym()->getNumberOfCUsInFrame(); j++) // set reference CU layerId 1640 { 1641 m_cIlpPic[refLayerIdc]->getPicSym()->getCU(j)->setLayerId(m_cIlpPic[refLayerIdc]->getLayerId()); 1642 } 1265 1643 } 1266 1644 } -
trunk/source/Lib/TLibEncoder/TEncTop.h
r313 r442 130 130 131 131 #if SVC_EXTENSION 132 132 133 TEncTop** m_ppcTEncTop; 133 134 TEncTop* getLayerEnc(UInt layer) { return m_ppcTEncTop[layer]; } 134 #endif135 #if REF_IDX_FRAMEWORK136 135 TComPic* m_cIlpPic[MAX_NUM_REF]; ///< Inter layer Prediction picture = upsampled picture 137 #endif138 136 #if REF_IDX_MFM 139 137 Bool m_bMFMEnabledFlag; … … 145 143 UInt m_numScaledRefLayerOffsets; 146 144 Window m_scaledRefLayerWindow[MAX_LAYERS]; 145 #endif 146 #if POC_RESET_FLAG 147 Int m_pocAdjustmentValue; 148 #endif 147 149 #endif 148 150 protected: … … 152 154 153 155 Void xInitPPSforTiles (); 154 Void xInitRPS ( );///< initialize PPS from encoder options155 #if REF_IDX_FRAMEWORK156 Void xInitRPS (Bool isFieldCoding); ///< initialize PPS from encoder options 157 #if SVC_EXTENSION 156 158 Void xInitILRP(); 157 159 #endif … … 162 164 Void create (); 163 165 Void destroy (); 164 Void init ( );166 Void init (Bool isFieldCoding); 165 167 Void deletePicBuffer (); 166 168 … … 207 209 Int getNumPicRcvd () { return m_iNumPicRcvd; } 208 210 Void setNumPicRcvd ( Int num ) { m_iNumPicRcvd = num; } 209 #endif210 211 #if SCALED_REF_LAYER_OFFSETS 211 212 Void setNumScaledRefLayerOffsets(Int x) { m_numScaledRefLayerOffsets = x; } … … 213 214 Window& getScaledRefLayerWindow(Int x) { return m_scaledRefLayerWindow[x]; } 214 215 #endif 216 #endif 215 217 216 218 // ------------------------------------------------------------------------------------------------------------------- … … 220 222 /// encode several number of pictures until end-of-sequence 221 223 #if SVC_EXTENSION 222 #if REF_IDX_FRAMEWORK223 224 TComPic** getIlpList() { return m_cIlpPic; } 224 225 Void setILRPic(TComPic *pcPic); 225 #endif226 226 #if REF_IDX_MFM 227 227 Void setMFMEnabledFlag (Bool flag) {m_bMFMEnabledFlag = flag;} … … 236 236 fstream* getBLSyntaxFile() { return m_pBLSyntaxFile; } 237 237 #endif 238 Void encode( TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsOut, Int iPicIdInGOP 238 Void encode( TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsOut, Int iPicIdInGOP ); 239 239 Void encodePrep( TComPicYuv* pcPicYuvOrg ); 240 Void encode( TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsOut, Int iPicIdInGOP, Bool isTff ); 241 Void encodePrep( TComPicYuv* pcPicYuvOrg, Bool isTff ); 240 242 #if VPS_EXTN_DIRECT_REF_LAYERS 241 243 TEncTop* getRefLayerEnc(UInt refLayerIdc); 242 244 #endif 243 #else 245 #if POC_RESET_FLAG 246 Int getPocAdjustmentValue() { return m_pocAdjustmentValue;} 247 Void setPocAdjustmentValue(Int x) { m_pocAdjustmentValue = x; } 248 #endif 249 #else //SVC_EXTENSION 244 250 Void encode( Bool bEos, TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut, 245 std::list<AccessUnit>& accessUnitsOut, Int& iNumEncoded ); 246 #endif 247 248 void printSummary() { m_cGOPEncoder.printOutSummary (m_uiNumAllPicCoded); } 251 std::list<AccessUnit>& accessUnitsOut, Int& iNumEncoded ); 252 253 /// encode several number of pictures until end-of-sequence 254 Void encode( bool bEos, TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut, 255 std::list<AccessUnit>& accessUnitsOut, Int& iNumEncoded, Bool isTff); 256 257 Void printSummary(Bool isField) { m_cGOPEncoder.printOutSummary (m_uiNumAllPicCoded, isField); } 258 #endif //#if SVC_EXTENSION 249 259 }; 250 260
Note: See TracChangeset for help on using the changeset viewer.