Changeset 906 in SHVCSoftware for trunk/source/Lib/TLibEncoder
- Timestamp:
- 15 Oct 2014, 07:25:10 (10 years ago)
- Location:
- trunk
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/SHM-dev (added) merged: 817-905
- Property svn:mergeinfo changed
-
trunk/source
- Property svn:mergeinfo changed
/branches/SHM-dev/source (added) merged: 818-875,877-905
- Property svn:mergeinfo changed
-
trunk/source/Lib/TLibEncoder/SEIwrite.cpp
r815 r906 92 92 break; 93 93 #endif 94 #if Q0074_ SEI_COLOR_MAPPING95 case SEI::COLO R_MAPPING_INFO:96 fprintf( g_hTrace, "=========== Colo r Mapping InfoSEI message ===========\n");94 #if Q0074_COLOUR_REMAPPING_SEI 95 case SEI::COLOUR_REMAPPING_INFO: 96 fprintf( g_hTrace, "=========== Colour Remapping Information SEI message ===========\n"); 97 97 break; 98 98 #endif … … 126 126 fprintf( g_hTrace, "=========== Bitstream parition initial arrival time SEI message ===========\n"); 127 127 break; 128 #if !REMOVE_BSP_HRD_SEI 128 129 case SEI::BSP_HRD: 129 130 fprintf( g_hTrace, "=========== Bitstream parition HRD parameters SEI message ===========\n"); 130 131 break; 132 #endif 131 133 #endif 132 134 #if Q0078_ADD_LAYER_SETS … … 147 149 148 150 #if O0164_MULTI_LAYER_HRD 151 #if VPS_VUI_BSP_HRD_PARAMS 152 void SEIWriter::xWriteSEIpayloadData(TComBitIf& bs, const SEI& sei, TComVPS *vps, TComSPS *sps, const SEIScalableNesting* nestingSeiPtr, const SEIBspNesting* bspNestingSeiPtr) 153 #else 149 154 void SEIWriter::xWriteSEIpayloadData(TComBitIf& bs, const SEI& sei, TComVPS *vps, TComSPS *sps, const SEIScalableNesting& nestingSei, const SEIBspNesting& bspNestingSei) 155 #endif 150 156 #else 151 157 void SEIWriter::xWriteSEIpayloadData(TComBitIf& bs, const SEI& sei, TComSPS *sps) 152 158 #endif 153 159 { 160 #if VPS_VUI_BSP_HRD_PARAMS 161 SEIScalableNesting nestingSei; 162 SEIBspNesting bspNestingSei; 163 if( nestingSeiPtr ) 164 { 165 nestingSei = *nestingSeiPtr; 166 } 167 if( bspNestingSeiPtr ) 168 { 169 bspNestingSei = *bspNestingSeiPtr; 170 } 171 #endif 154 172 switch (sei.payloadType()) 155 173 { … … 160 178 xWriteSEIActiveParameterSets(*static_cast<const SEIActiveParameterSets*>(& sei)); 161 179 break; 180 case SEI::DECODED_PICTURE_HASH: 181 xWriteSEIDecodedPictureHash(*static_cast<const SEIDecodedPictureHash*>(&sei)); 182 break; 183 #if VPS_VUI_BSP_HRD_PARAMS 184 case SEI::DECODING_UNIT_INFO: 185 xWriteSEIDecodingUnitInfo(*static_cast<const SEIDecodingUnitInfo*>(& sei), sps, nestingSeiPtr, bspNestingSeiPtr, vps); 186 break; 187 case SEI::BUFFERING_PERIOD: 188 xWriteSEIBufferingPeriod(*static_cast<const SEIBufferingPeriod*>(&sei), sps, nestingSeiPtr, bspNestingSeiPtr, vps); 189 break; 190 case SEI::PICTURE_TIMING: 191 xWriteSEIPictureTiming(*static_cast<const SEIPictureTiming*>(&sei), sps, nestingSeiPtr, bspNestingSeiPtr, vps); 192 break; 193 #else 162 194 case SEI::DECODING_UNIT_INFO: 163 195 xWriteSEIDecodingUnitInfo(*static_cast<const SEIDecodingUnitInfo*>(& sei), sps); 164 196 break; 165 case SEI::DECODED_PICTURE_HASH:166 xWriteSEIDecodedPictureHash(*static_cast<const SEIDecodedPictureHash*>(&sei));167 break;168 197 case SEI::BUFFERING_PERIOD: 169 198 xWriteSEIBufferingPeriod(*static_cast<const SEIBufferingPeriod*>(&sei), sps); … … 172 201 xWriteSEIPictureTiming(*static_cast<const SEIPictureTiming*>(&sei), sps); 173 202 break; 203 #endif 174 204 case SEI::RECOVERY_POINT: 175 205 xWriteSEIRecoveryPoint(*static_cast<const SEIRecoveryPoint*>(&sei)); … … 195 225 break; 196 226 #endif 197 #if Q0074_ SEI_COLOR_MAPPING198 case SEI::COLO R_MAPPING_INFO:199 xWriteSEIColo rMappingInfo(*static_cast<const SEIColorMappingInfo*>(&sei));227 #if Q0074_COLOUR_REMAPPING_SEI 228 case SEI::COLOUR_REMAPPING_INFO: 229 xWriteSEIColourRemappingInfo(*static_cast<const SEIColourRemappingInfo*>(&sei)); 200 230 break; 201 231 #endif … … 233 263 xWriteSEIBspInitialArrivalTime(*static_cast<const SEIBspInitialArrivalTime*>(&sei), vps, sps, nestingSei, bspNestingSei); 234 264 break; 265 #if !REMOVE_BSP_HRD_SEI 235 266 case SEI::BSP_HRD: 236 267 xWriteSEIBspHrd(*static_cast<const SEIBspHrd*>(&sei), sps, nestingSei); 237 268 break; 269 #endif 238 270 #endif 239 271 #if Q0078_ADD_LAYER_SETS … … 283 315 #endif 284 316 #if O0164_MULTI_LAYER_HRD 317 #if VPS_VUI_BSP_HRD_PARAMS 318 xWriteSEIpayloadData(bs_count, sei, vps, sps, nestingSei, bspNestingSei); 319 #else 285 320 xWriteSEIpayloadData(bs_count, sei, vps, sps, *nestingSei, *bspNestingSei); 321 #endif 286 322 #else 287 323 xWriteSEIpayloadData(bs_count, sei, sps); … … 322 358 323 359 #if O0164_MULTI_LAYER_HRD 360 #if VPS_VUI_BSP_HRD_PARAMS 361 xWriteSEIpayloadData(bs, sei, vps, sps, nestingSei, bspNestingSei); 362 #else 324 363 xWriteSEIpayloadData(bs, sei, vps, sps, *nestingSei, *bspNestingSei); 364 #endif 325 365 #else 326 366 xWriteSEIpayloadData(bs, sei, sps); … … 390 430 WRITE_UVLC(sei.activeSeqParameterSetId[i], "active_seq_parameter_set_id"); 391 431 } 392 xWriteByteAlign(); 393 } 394 432 #if R0247_SEI_ACTIVE 433 for (Int i = 1; i < sei.activeSeqParameterSetId.size(); i++) 434 { 435 WRITE_UVLC(sei.layerSpsIdx[i], "layer_sps_idx"); 436 } 437 #endif 438 xWriteByteAlign(); 439 } 440 441 #if VPS_VUI_BSP_HRD_PARAMS 442 Void SEIWriter::xWriteSEIDecodingUnitInfo(const SEIDecodingUnitInfo& sei, TComSPS *sps, const SEIScalableNesting* nestingSei, const SEIBspNesting* bspNestingSei, TComVPS *vps) 443 #else 395 444 Void SEIWriter::xWriteSEIDecodingUnitInfo(const SEIDecodingUnitInfo& sei, TComSPS *sps) 396 { 445 #endif 446 { 447 #if VPS_VUI_BSP_HRD_PARAMS 448 TComHRD *hrd; 449 if( bspNestingSei ) // If DU info SEI contained inside a BSP nesting SEI message 450 { 451 assert( nestingSei ); 452 Int psIdx = bspNestingSei->m_seiPartitioningSchemeIdx; 453 Int seiOlsIdx = bspNestingSei->m_seiOlsIdx; 454 Int maxTemporalId = nestingSei->m_nestingMaxTemporalIdPlus1[0] - 1; 455 Int maxValues = vps->getNumBspSchedulesMinus1(seiOlsIdx, psIdx, maxTemporalId) + 1; 456 std::vector<Int> hrdIdx(maxValues, 0); 457 std::vector<TComHRD *> hrdVec; 458 std::vector<Int> syntaxElemLen(maxValues, 0); 459 for(Int i = 0; i < maxValues; i++) 460 { 461 hrdIdx[i] = vps->getBspHrdIdx( seiOlsIdx, psIdx, maxTemporalId, i, bspNestingSei->m_bspIdx); 462 hrdVec.push_back(vps->getBspHrd(hrdIdx[i])); 463 464 syntaxElemLen[i] = hrdVec[i]->getInitialCpbRemovalDelayLengthMinus1() + 1; 465 if ( !(hrdVec[i]->getNalHrdParametersPresentFlag() || hrdVec[i]->getVclHrdParametersPresentFlag()) ) 466 { 467 assert( syntaxElemLen[i] == 24 ); // Default of value init_cpb_removal_delay_length_minus1 is 23 468 } 469 if( i > 0 ) 470 { 471 assert( hrdVec[i]->getSubPicCpbParamsPresentFlag() == hrdVec[i-1]->getSubPicCpbParamsPresentFlag() ); 472 assert( hrdVec[i]->getSubPicCpbParamsInPicTimingSEIFlag() == hrdVec[i-1]->getSubPicCpbParamsInPicTimingSEIFlag() ); 473 assert( hrdVec[i]->getDpbOutputDelayDuLengthMinus1() == hrdVec[i-1]->getDpbOutputDelayDuLengthMinus1() ); 474 // To be done: Check CpbDpbDelaysPresentFlag 475 } 476 } 477 hrd = hrdVec[0]; 478 } 479 else 480 { 481 TComVUI *vui = sps->getVuiParameters(); 482 hrd = vui->getHrdParameters(); 483 } 484 #else 397 485 TComVUI *vui = sps->getVuiParameters(); 486 TComHrd *hrd = vui->getHrdParameters(); 487 #endif 398 488 WRITE_UVLC(sei.m_decodingUnitIdx, "decoding_unit_idx"); 399 if( vui->getHrdParameters()->getSubPicCpbParamsInPicTimingSEIFlag())400 { 401 WRITE_CODE( sei.m_duSptCpbRemovalDelay, ( vui->getHrdParameters()->getDuCpbRemovalDelayLengthMinus1() + 1), "du_spt_cpb_removal_delay");489 if(hrd->getSubPicCpbParamsInPicTimingSEIFlag()) 490 { 491 WRITE_CODE( sei.m_duSptCpbRemovalDelay, (hrd->getDuCpbRemovalDelayLengthMinus1() + 1), "du_spt_cpb_removal_delay"); 402 492 } 403 493 WRITE_FLAG( sei.m_dpbOutputDuDelayPresentFlag, "dpb_output_du_delay_present_flag"); 404 494 if(sei.m_dpbOutputDuDelayPresentFlag) 405 495 { 406 WRITE_CODE(sei.m_picSptDpbOutputDuDelay, vui->getHrdParameters()->getDpbOutputDelayDuLengthMinus1() + 1, "pic_spt_dpb_output_du_delay"); 407 } 408 xWriteByteAlign(); 409 } 410 496 WRITE_CODE(sei.m_picSptDpbOutputDuDelay,hrd->getDpbOutputDelayDuLengthMinus1() + 1, "pic_spt_dpb_output_du_delay"); 497 } 498 xWriteByteAlign(); 499 } 500 501 #if VPS_VUI_BSP_HRD_PARAMS 502 Void SEIWriter::xWriteSEIBufferingPeriod(const SEIBufferingPeriod& sei, TComSPS *sps, const SEIScalableNesting* nestingSei, const SEIBspNesting* bspNestingSei, TComVPS *vps) 503 #else 411 504 Void SEIWriter::xWriteSEIBufferingPeriod(const SEIBufferingPeriod& sei, TComSPS *sps) 505 #endif 412 506 { 413 507 Int i, nalOrVcl; 508 #if VPS_VUI_BSP_HRD_PARAMS 509 TComHRD *hrd; 510 if( bspNestingSei ) // If BP SEI contained inside a BSP nesting SEI message 511 { 512 assert( nestingSei ); 513 Int psIdx = bspNestingSei->m_seiPartitioningSchemeIdx; 514 Int seiOlsIdx = bspNestingSei->m_seiOlsIdx; 515 Int maxTemporalId = nestingSei->m_nestingMaxTemporalIdPlus1[0] - 1; 516 Int maxValues = vps->getNumBspSchedulesMinus1(seiOlsIdx, psIdx, maxTemporalId) + 1; 517 std::vector<Int> hrdIdx(maxValues, 0); 518 std::vector<TComHRD *> hrdVec; 519 std::vector<Int> syntaxElemLen(maxValues, 0); 520 for(i = 0; i < maxValues; i++) 521 { 522 hrdIdx[i] = vps->getBspHrdIdx( seiOlsIdx, psIdx, maxTemporalId, i, bspNestingSei->m_bspIdx); 523 hrdVec.push_back(vps->getBspHrd(hrdIdx[i])); 524 525 syntaxElemLen[i] = hrdVec[i]->getInitialCpbRemovalDelayLengthMinus1() + 1; 526 if ( !(hrdVec[i]->getNalHrdParametersPresentFlag() || hrdVec[i]->getVclHrdParametersPresentFlag()) ) 527 { 528 assert( syntaxElemLen[i] == 24 ); // Default of value init_cpb_removal_delay_length_minus1 is 23 529 } 530 if( i > 0 ) 531 { 532 assert( hrdVec[i]->getCpbRemovalDelayLengthMinus1() == hrdVec[i-1]->getCpbRemovalDelayLengthMinus1() ); 533 assert( hrdVec[i]->getDpbOutputDelayDuLengthMinus1() == hrdVec[i-1]->getDpbOutputDelayDuLengthMinus1() ); 534 assert( hrdVec[i]->getSubPicCpbParamsPresentFlag() == hrdVec[i-1]->getSubPicCpbParamsPresentFlag() ); 535 } 536 } 537 hrd = hrdVec[i]; 538 } 539 else 540 { 541 TComVUI *vui = sps->getVuiParameters(); 542 hrd = vui->getHrdParameters(); 543 } 544 // To be done: When contained in an BSP HRD SEI message, the hrd structure is to be chosen differently. 545 #else 414 546 TComVUI *vui = sps->getVuiParameters(); 415 547 TComHRD *hrd = vui->getHrdParameters(); 548 #endif 416 549 417 550 WRITE_UVLC( sei.m_bpSeqParameterSetId, "bp_seq_parameter_set_id" ); … … 452 585 xWriteByteAlign(); 453 586 } 587 #if VPS_VUI_BSP_HRD_PARAMS 588 Void SEIWriter::xWriteSEIPictureTiming(const SEIPictureTiming& sei, TComSPS *sps, const SEIScalableNesting* nestingSei, const SEIBspNesting* bspNestingSei, TComVPS *vps) 589 #else 454 590 Void SEIWriter::xWriteSEIPictureTiming(const SEIPictureTiming& sei, TComSPS *sps) 591 #endif 455 592 { 456 593 Int i; 594 #if VPS_VUI_BSP_HRD_PARAMS 595 TComHRD *hrd; 596 TComVUI *vui = sps->getVuiParameters(); 597 if( bspNestingSei ) // If BP SEI contained inside a BSP nesting SEI message 598 { 599 assert( nestingSei ); 600 Int psIdx = bspNestingSei->m_seiPartitioningSchemeIdx; 601 Int seiOlsIdx = bspNestingSei->m_seiOlsIdx; 602 Int maxTemporalId = nestingSei->m_nestingMaxTemporalIdPlus1[0] - 1; 603 Int maxValues = vps->getNumBspSchedulesMinus1(seiOlsIdx, psIdx, maxTemporalId) + 1; 604 std::vector<Int> hrdIdx(maxValues, 0); 605 std::vector<TComHRD *> hrdVec; 606 std::vector<Int> syntaxElemLen(maxValues, 0); 607 for(i = 0; i < maxValues; i++) 608 { 609 hrdIdx[i] = vps->getBspHrdIdx( seiOlsIdx, psIdx, maxTemporalId, i, bspNestingSei->m_bspIdx); 610 hrdVec.push_back(vps->getBspHrd(hrdIdx[i])); 611 612 syntaxElemLen[i] = hrdVec[i]->getInitialCpbRemovalDelayLengthMinus1() + 1; 613 if ( !(hrdVec[i]->getNalHrdParametersPresentFlag() || hrdVec[i]->getVclHrdParametersPresentFlag()) ) 614 { 615 assert( syntaxElemLen[i] == 24 ); // Default of value init_cpb_removal_delay_length_minus1 is 23 616 } 617 if( i > 0 ) 618 { 619 assert( hrdVec[i]->getSubPicCpbParamsPresentFlag() == hrdVec[i-1]->getSubPicCpbParamsPresentFlag() ); 620 assert( hrdVec[i]->getSubPicCpbParamsInPicTimingSEIFlag() == hrdVec[i-1]->getSubPicCpbParamsInPicTimingSEIFlag() ); 621 assert( hrdVec[i]->getCpbRemovalDelayLengthMinus1() == hrdVec[i-1]->getCpbRemovalDelayLengthMinus1() ); 622 assert( hrdVec[i]->getDpbOutputDelayLengthMinus1() == hrdVec[i-1]->getDpbOutputDelayLengthMinus1() ); 623 assert( hrdVec[i]->getDpbOutputDelayDuLengthMinus1() == hrdVec[i-1]->getDpbOutputDelayDuLengthMinus1() ); 624 assert( hrdVec[i]->getDuCpbRemovalDelayLengthMinus1() == hrdVec[i-1]->getDuCpbRemovalDelayLengthMinus1() ); 625 // To be done: Check CpbDpbDelaysPresentFlag 626 } 627 } 628 hrd = hrdVec[0]; 629 } 630 else 631 { 632 hrd = vui->getHrdParameters(); 633 } 634 // To be done: When contained in an BSP HRD SEI message, the hrd structure is to be chosen differently. 635 #else 457 636 TComVUI *vui = sps->getVuiParameters(); 458 637 TComHRD *hrd = vui->getHrdParameters(); 459 460 if( vui->getFrameFieldInfoPresentFlag() ) 638 #endif 639 640 if( vui->getFrameFieldInfoPresentFlag() ) // To be done: Check whether this is the correct invocation of vui when PT SEI contained in BSP nesting SEI 461 641 { 462 642 WRITE_CODE( sei.m_picStruct, 4, "pic_struct" ); … … 634 814 } 635 815 #endif 636 #if Q0074_SEI_COLOR_MAPPING 637 Void SEIWriter::xWriteSEIColorMappingInfo(const SEIColorMappingInfo& sei) 638 { 639 WRITE_UVLC( sei.m_colorMapId, "colour_map_id" ); 640 WRITE_FLAG( sei.m_colorMapCancelFlag, "colour_map_cancel_flag" ); 641 if( !sei.m_colorMapCancelFlag ) 642 { 643 WRITE_FLAG( sei.m_colorMapPersistenceFlag, "colour_map_persistence_flag" ); 644 WRITE_FLAG( sei.m_colorMap_video_signal_type_present_flag, "colour_map_video_signal_type_present_flag" ); 645 if ( sei.m_colorMap_video_signal_type_present_flag ) 646 { 647 WRITE_FLAG( sei.m_colorMap_video_full_range_flag, "colour_map_video_full_range_flag" ); 648 WRITE_CODE( sei.m_colorMap_primaries, 8, "colour_map_primaries" ); 649 WRITE_CODE( sei.m_colorMap_transfer_characteristics, 8, "colour_map_transfer_characteristics" ); 650 WRITE_CODE( sei.m_colorMap_matrix_coeffs, 8, "colour_map_matrix_coeffs" ); 651 } 652 } 653 654 WRITE_CODE( sei.m_colour_map_coded_data_bit_depth, 5, "colour_map_coded_data_bit_depth" ); 655 WRITE_CODE( sei.m_colour_map_target_bit_depth, 5, "colour_map_target_bit_depth" ); 656 WRITE_UVLC( sei.m_colorMapModelId, "colour_map_model_id" ); 657 658 assert( sei.m_colorMapModelId == 0 ); 659 660 for( Int i=0 ; i<3 ; i++ ) 661 { 662 WRITE_CODE( sei.m_num_input_pivots[i] - 1, 8, "num_input_pivots_minus1[i]" ); 663 for( Int j=0 ; j<sei.m_num_input_pivots[i] ; j++ ) 664 { 665 WRITE_CODE( sei.m_coded_input_pivot_value[i][j], (( sei.m_colour_map_coded_data_bit_depth + 7 ) >> 3 ) << 3, "coded_input_pivot_value[i][j]" ); 666 WRITE_CODE( sei.m_target_input_pivot_value[i][j], (( sei.m_colour_map_coded_data_bit_depth + 7 ) >> 3 ) << 3, "target_input_pivot_value[i][j]" ); 667 } 668 } 669 670 WRITE_FLAG( sei.m_matrix_flag, "matrix_flag" ); 671 if( sei.m_matrix_flag ) 672 { 673 WRITE_CODE( sei.m_log2_matrix_denom, 4, "log2_matrix_denom" ); 674 for( Int i=0 ; i<3 ; i++ ) 675 { 676 for( Int j=0 ; j<3 ; j++ ) 677 { 678 WRITE_SVLC( sei.m_matrix_coef[i][j], "matrix_coef[i][j]" ); 679 } 680 } 681 } 682 683 for( Int i=0 ; i<3 ; i++ ) 684 { 685 WRITE_CODE( sei.m_num_output_pivots[i] - 1, 8, "num_output_pivots_minus1[i]" ); 686 for( Int j=0 ; j<sei.m_num_output_pivots[i] ; j++ ) 687 { 688 WRITE_CODE( sei.m_coded_output_pivot_value[i][j], (( sei.m_colour_map_coded_data_bit_depth + 7 ) >> 3 ) << 3, "coded_output_pivot_value[i][j]" ); 689 WRITE_CODE( sei.m_target_output_pivot_value[i][j], (( sei.m_colour_map_coded_data_bit_depth + 7 ) >> 3 ) << 3, "target_output_pivot_value[i][j]" ); 690 } 691 } 692 816 #if Q0074_COLOUR_REMAPPING_SEI 817 Void SEIWriter::xWriteSEIColourRemappingInfo(const SEIColourRemappingInfo& sei) 818 { 819 WRITE_UVLC( sei.m_colourRemapId, "colour_remap_id" ); 820 WRITE_FLAG( sei.m_colourRemapCancelFlag, "colour_remap_cancel_flag" ); 821 if( !sei.m_colourRemapCancelFlag ) 822 { 823 WRITE_FLAG( sei.m_colourRemapPersistenceFlag, "colour_remap_persistence_flag" ); 824 WRITE_FLAG( sei.m_colourRemapVideoSignalInfoPresentFlag, "colour_remap_video_signal_info_present_flag" ); 825 if ( sei.m_colourRemapVideoSignalInfoPresentFlag ) 826 { 827 WRITE_FLAG( sei.m_colourRemapFullRangeFlag, "colour_remap_full_range_flag" ); 828 WRITE_CODE( sei.m_colourRemapPrimaries, 8, "colour_remap_primaries" ); 829 WRITE_CODE( sei.m_colourRemapTransferFunction, 8, "colour_remap_transfer_function" ); 830 WRITE_CODE( sei.m_colourRemapMatrixCoefficients, 8, "colour_remap_matrix_coefficients" ); 831 } 832 WRITE_CODE( sei.m_colourRemapInputBitDepth, 8, "colour_remap_input_bit_depth" ); 833 WRITE_CODE( sei.m_colourRemapBitDepth, 8, "colour_remap_bit_depth" ); 834 for( Int c=0 ; c<3 ; c++ ) 835 { 836 WRITE_CODE( sei.m_preLutNumValMinus1[c], 8, "pre_lut_num_val_minus1[c]" ); 837 if( sei.m_preLutNumValMinus1[c]>0 ) 838 for( Int i=0 ; i<=sei.m_preLutNumValMinus1[c] ; i++ ) 839 { 840 WRITE_CODE( sei.m_preLutCodedValue[c][i], (( sei.m_colourRemapInputBitDepth + 7 ) >> 3 ) << 3, "pre_lut_coded_value[c][i]" ); 841 WRITE_CODE( sei.m_preLutTargetValue[c][i], (( sei.m_colourRemapBitDepth + 7 ) >> 3 ) << 3, "pre_lut_target_value[c][i]" ); 842 } 843 } 844 WRITE_FLAG( sei.m_colourRemapMatrixPresentFlag, "colour_remap_matrix_present_flag" ); 845 if( sei.m_colourRemapMatrixPresentFlag ) 846 { 847 WRITE_CODE( sei.m_log2MatrixDenom, 4, "log2_matrix_denom" ); 848 for( Int c=0 ; c<3 ; c++ ) 849 for( Int i=0 ; i<3 ; i++ ) 850 WRITE_SVLC( sei.m_colourRemapCoeffs[c][i], "colour_remap_coeffs[c][i]" ); 851 } 852 853 for( Int c=0 ; c<3 ; c++ ) 854 { 855 WRITE_CODE( sei.m_postLutNumValMinus1[c], 8, "m_postLutNumValMinus1[c]" ); 856 if( sei.m_postLutNumValMinus1[c]>0 ) 857 for( Int i=0 ; i<=sei.m_postLutNumValMinus1[c] ; i++ ) 858 { 859 WRITE_CODE( sei.m_postLutCodedValue[c][i], (( sei.m_colourRemapBitDepth + 7 ) >> 3 ) << 3, "post_lut_coded_value[c][i]" ); 860 WRITE_CODE( sei.m_postLutTargetValue[c][i], (( sei.m_colourRemapBitDepth + 7 ) >> 3 ) << 3, "post_lut_target_value[c][i]" ); 861 } 862 } 863 } 693 864 xWriteByteAlign(); 694 865 } … … 753 924 { 754 925 WRITE_FLAG( sei.m_defaultOpFlag, "default_op_flag" ); 755 WRITE_UVLC( sei.m_nestingNumOpsMinus1, "nesting_num_ops ");926 WRITE_UVLC( sei.m_nestingNumOpsMinus1, "nesting_num_ops_minus1" ); 756 927 for (UInt i = (sei.m_defaultOpFlag ? 1 : 0); i <= sei.m_nestingNumOpsMinus1; i++) 757 928 { 758 WRITE_CODE( sei.m_nestingNoOpMaxTemporalIdPlus1, 3, "nesting_no_op_max_temporal_id" ); 759 WRITE_CODE( sei.m_nestingMaxTemporalIdPlus1[i], 3, "nesting_max_temporal_id" ); 929 WRITE_CODE( sei.m_nestingMaxTemporalIdPlus1[i], 3, "nesting_max_temporal_id_plus1" ); 760 930 WRITE_UVLC( sei.m_nestingOpIdx[i], "nesting_op_idx" ); 761 931 } … … 766 936 if (!sei.m_allLayersFlag) 767 937 { 768 WRITE_CODE( sei.m_nestingNoOpMaxTemporalIdPlus1, 3, "nesting_no_op_max_temporal_id " );769 WRITE_UVLC( sei.m_nestingNumLayersMinus1, "nesting_num_layers" );938 WRITE_CODE( sei.m_nestingNoOpMaxTemporalIdPlus1, 3, "nesting_no_op_max_temporal_id_plus1" ); 939 WRITE_UVLC( sei.m_nestingNumLayersMinus1, "nesting_num_layers" ); 770 940 for (UInt i = 0; i <= sei.m_nestingNumLayersMinus1; i++) 771 941 { … … 901 1071 WRITE_FLAG( 0, "bsp_nesting_zero_bit" ); 902 1072 } 903 1073 #if NESTING_SEI_EXTENSIBILITY 1074 assert( sei.m_nestedSEIs.size() <= MAX_SEIS_IN_BSP_NESTING ); 1075 WRITE_UVLC( sei.m_nestedSEIs.size(), "num_seis_in_bsp_minus1" ); 1076 #endif 904 1077 // write nested SEI messages 905 1078 for (SEIMessages::const_iterator it = sei.m_nestedSEIs.begin(); it != sei.m_nestedSEIs.end(); it++) … … 913 1086 assert(vps->getVpsVuiPresentFlag()); 914 1087 1088 #if VPS_VUI_BSP_HRD_PARAMS 1089 Int psIdx = bspNestingSei.m_seiPartitioningSchemeIdx; 1090 Int seiOlsIdx = bspNestingSei.m_seiOlsIdx; 1091 Int maxTemporalId = nestingSei.m_nestingMaxTemporalIdPlus1[0] - 1; 1092 Int maxValues = vps->getNumBspSchedulesMinus1(seiOlsIdx, psIdx, maxTemporalId) + 1; 1093 std::vector<Int> hrdIdx(maxValues, 0); 1094 std::vector<TComHRD *> hrdVec; 1095 std::vector<Int> syntaxElemLen(maxValues, 0); 1096 for(Int i = 0; i < maxValues; i++) 1097 { 1098 hrdIdx[i] = vps->getBspHrdIdx( seiOlsIdx, psIdx, maxTemporalId, i, bspNestingSei.m_bspIdx); 1099 hrdVec.push_back(vps->getBspHrd(hrdIdx[i])); 1100 1101 syntaxElemLen[i] = hrdVec[i]->getInitialCpbRemovalDelayLengthMinus1() + 1; 1102 if ( !(hrdVec[i]->getNalHrdParametersPresentFlag() || hrdVec[i]->getVclHrdParametersPresentFlag()) ) 1103 { 1104 assert( syntaxElemLen[i] == 24 ); // Default of value init_cpb_removal_delay_length_minus1 is 23 1105 } 1106 if( i > 0 ) 1107 { 1108 assert( hrdVec[i]->getNalHrdParametersPresentFlag() == hrdVec[i-1]->getNalHrdParametersPresentFlag() ); 1109 assert( hrdVec[i]->getVclHrdParametersPresentFlag() == hrdVec[i-1]->getVclHrdParametersPresentFlag() ); 1110 } 1111 } 1112 if (hrdVec[0]->getNalHrdParametersPresentFlag()) 1113 { 1114 for(UInt i = 0; i < maxValues; i++) 1115 { 1116 WRITE_CODE( sei.m_nalInitialArrivalDelay[i], syntaxElemLen[i], "nal_initial_arrival_delay[i]" ); 1117 } 1118 } 1119 if( hrdVec[0]->getVclHrdParametersPresentFlag() ) 1120 { 1121 for(UInt i = 0; i < maxValues; i++) 1122 { 1123 WRITE_CODE( sei.m_vclInitialArrivalDelay[i], syntaxElemLen[i], "vcl_initial_arrival_delay[i]" ); 1124 } 1125 } 1126 #else 915 1127 UInt schedCombCnt = vps->getNumBspSchedCombinations(nestingSei.m_nestingOpIdx[0]); 916 1128 UInt len; … … 944 1156 } 945 1157 } 1158 #if BSP_INIT_ARRIVAL_SEI 1159 if( hrd->getVclHrdParametersPresentFlag() ) 1160 #else 946 1161 else 1162 #endif 947 1163 { 948 1164 for(UInt i = 0; i < schedCombCnt; i++) … … 951 1167 } 952 1168 } 953 } 954 1169 #endif 1170 } 1171 1172 #if !REMOVE_BSP_HRD_SEI 955 1173 Void SEIWriter::xWriteSEIBspHrd(const SEIBspHrd &sei, TComSPS *sps, const SEIScalableNesting &nestingSei) 956 1174 { … … 1004 1222 } 1005 1223 } 1224 #endif 1006 1225 1007 1226 Void SEIWriter::xCodeHrdParameters( TComHRD *hrd, Bool commonInfPresentFlag, UInt maxNumSubLayersMinus1 ) -
trunk/source/Lib/TLibEncoder/SEIwrite.h
r815 r906 55 55 protected: 56 56 #if O0164_MULTI_LAYER_HRD 57 #if VPS_VUI_BSP_HRD_PARAMS 58 Void xWriteSEIpayloadData(TComBitIf& bs, const SEI& sei, TComVPS *vps, TComSPS *sps, const SEIScalableNesting* nestingSei, const SEIBspNesting* bspNestingSei); 59 #else 57 60 Void xWriteSEIpayloadData(TComBitIf& bs, const SEI& sei, TComVPS *vps, TComSPS *sps, const SEIScalableNesting& nestingSei, const SEIBspNesting& bspNestingSei); 61 #endif 58 62 #else 59 63 Void xWriteSEIpayloadData(TComBitIf& bs, const SEI& sei, TComSPS *sps); … … 61 65 Void xWriteSEIuserDataUnregistered(const SEIuserDataUnregistered &sei); 62 66 Void xWriteSEIActiveParameterSets(const SEIActiveParameterSets& sei); 67 Void xWriteSEIDecodedPictureHash(const SEIDecodedPictureHash& sei); 68 #if VPS_VUI_BSP_HRD_PARAMS 69 Void xWriteSEIDecodingUnitInfo(const SEIDecodingUnitInfo& sei, TComSPS *sps, const SEIScalableNesting* nestingSei, const SEIBspNesting* bspNestingSei, TComVPS *vps); 70 Void xWriteSEIBufferingPeriod(const SEIBufferingPeriod& sei, TComSPS *sps, const SEIScalableNesting* nestingSei, const SEIBspNesting* bspNestingSei, TComVPS *vps); 71 Void xWriteSEIPictureTiming(const SEIPictureTiming& sei, TComSPS *sps, const SEIScalableNesting* nestingSei, const SEIBspNesting* bspNestingSei, TComVPS *vps); 72 #else 63 73 Void xWriteSEIDecodingUnitInfo(const SEIDecodingUnitInfo& sei, TComSPS *sps); 64 Void xWriteSEIDecodedPictureHash(const SEIDecodedPictureHash& sei);65 74 Void xWriteSEIBufferingPeriod(const SEIBufferingPeriod& sei, TComSPS *sps); 66 75 Void xWriteSEIPictureTiming(const SEIPictureTiming& sei, TComSPS *sps); 76 #endif 67 77 TComSPS *m_pSPS; 68 78 Void xWriteSEIRecoveryPoint(const SEIRecoveryPoint& sei); … … 75 85 Void xWriteSEIKneeFunctionInfo(const SEIKneeFunctionInfo &sei); 76 86 #endif 77 #if Q0074_ SEI_COLOR_MAPPING78 Void xWriteSEIColo rMappingInfo(const SEIColorMappingInfo& sei);87 #if Q0074_COLOUR_REMAPPING_SEI 88 Void xWriteSEIColourRemappingInfo(const SEIColourRemappingInfo& sei); 79 89 #endif 80 90 Void xWriteSEISOPDescription(const SEISOPDescription& sei); … … 104 114 Void xWriteSEIBspNesting(TComBitIf& bs, const SEIBspNesting &sei, TComVPS *vps, TComSPS *sps, const SEIScalableNesting &nestingSei); 105 115 Void xWriteSEIBspInitialArrivalTime(const SEIBspInitialArrivalTime &sei, TComVPS *vps, TComSPS *sps, const SEIScalableNesting &nestingSei, const SEIBspNesting &bspNestingSei); 116 #if !REMOVE_BSP_HRD_SEI 106 117 Void xWriteSEIBspHrd(const SEIBspHrd &sei, TComSPS *sps, const SEIScalableNesting &nestingSei); 118 #endif 107 119 Void xCodeHrdParameters( TComHRD *hrd, Bool commonInfPresentFlag, UInt maxNumSubLayersMinus1 ); 108 120 #endif -
trunk/source/Lib/TLibEncoder/TEnc3DAsymLUT.cpp
r815 r906 14 14 m_pColorInfoC = NULL; 15 15 m_pEncCuboid = NULL; 16 16 17 m_pBestEncCuboid = NULL; 18 #if R0151_CGS_3D_ASYMLUT_IMPROVE 19 m_nAccuFrameBit = 0; 20 m_nAccuFrameCGSBit = 0; 21 m_nPrevFrameCGSPartNumLog2 = 0; 22 #else 17 23 memset( m_nPrevFrameBit , 0 , sizeof( m_nPrevFrameBit ) ); 18 24 memset( m_nPrevFrameCGSBit , 0 , sizeof( m_nPrevFrameCGSBit ) ); 19 25 memset( m_nPrevFrameCGSPartNumLog2 , 0 , sizeof( m_nPrevFrameCGSPartNumLog2 ) ); 20 26 memset( m_nPrevFrameOverWritePPS , 0 , sizeof( m_nPrevFrameOverWritePPS ) ); 27 #endif 21 28 m_dTotalFrameBit = 0; 22 29 m_nTotalCGSBit = 0; 23 30 m_nPPSBit = 0; 24 31 m_pDsOrigPic = NULL; 32 #if R0179_ENC_OPT_3DLUT_SIZE 33 m_pMaxColorInfo = NULL; 34 m_pMaxColorInfoC = NULL; 35 36 37 // fixed m_dDistFactor 38 Double dTmpFactor[3]; 39 dTmpFactor[I_SLICE] = 1.0; 40 dTmpFactor[P_SLICE] = 4./3.; 41 dTmpFactor[B_SLICE] = 1.5; 42 for( Int iSliceType = 0; iSliceType < 3; iSliceType++) 43 { 44 for(Int iLayer = 0; iLayer < MAX_TLAYER; iLayer++) 45 { 46 m_dDistFactor[iSliceType][iLayer] = dTmpFactor[iSliceType]*(Double)(1<<iLayer); 47 } 48 } 49 // initialization with approximate number of bits to code the LUT 50 m_nNumLUTBits[0][0] = 200; // 1x1x1 51 m_nNumLUTBits[1][0] = 400; // 2x1x1 52 m_nNumLUTBits[1][1] = 1500; // 2x2x2 53 m_nNumLUTBits[2][0] = 800; // 4x1x1 54 m_nNumLUTBits[2][1] = 3200; // 4x2x2 55 m_nNumLUTBits[2][2] = 8500; // 4x4x4 56 m_nNumLUTBits[3][0] = 1200; // 8x1x1 57 m_nNumLUTBits[3][1] = 4500; // 8x2x2 58 m_nNumLUTBits[3][2] = 10000; // 8x4x4 59 m_nNumLUTBits[3][3] = 12000; // 8x8x8 60 #endif 25 61 } 26 62 … … 32 68 } 33 69 34 TCom3DAsymLUT::create( nMaxOctantDepth , nInputBitDepth , nInputBitDepthC, nOutputBitDepth , nOutputBitDepthC, nMaxYPartNumLog2 ); 70 TCom3DAsymLUT::create( nMaxOctantDepth , nInputBitDepth , nInputBitDepthC, nOutputBitDepth , nOutputBitDepthC, nMaxYPartNumLog2 71 #if R0151_CGS_3D_ASYMLUT_IMPROVE 72 , 1 << ( nInputBitDepthC - 1 ) , 1 << ( nInputBitDepthC - 1 ) 73 #endif 74 ); 35 75 xAllocate3DArray( m_pColorInfo , xGetYSize() , xGetUSize() , xGetVSize() ); 36 76 xAllocate3DArray( m_pColorInfoC , xGetYSize() , xGetUSize() , xGetVSize() ); 37 77 xAllocate3DArray( m_pEncCuboid , xGetYSize() , xGetUSize() , xGetVSize() ); 38 78 xAllocate3DArray( m_pBestEncCuboid , xGetYSize() , xGetUSize() , xGetVSize() ); 79 #if R0179_ENC_OPT_3DLUT_SIZE 80 xAllocate3DArray( m_pMaxColorInfo , xGetYSize() , xGetUSize() , xGetVSize() ); 81 xAllocate3DArray( m_pMaxColorInfoC , xGetYSize() , xGetUSize() , xGetVSize() ); 82 83 m_pEncCavlc = new TEncCavlc; 84 m_pBitstreamRedirect = new TComOutputBitstream; 85 m_pEncCavlc->setBitstream(m_pBitstreamRedirect); 86 #endif 39 87 } 40 88 … … 45 93 xFree3DArray( m_pEncCuboid ); 46 94 xFree3DArray( m_pBestEncCuboid ); 95 #if R0179_ENC_OPT_3DLUT_SIZE 96 xFree3DArray( m_pMaxColorInfo ); 97 xFree3DArray( m_pMaxColorInfoC ); 98 delete m_pBitstreamRedirect; 99 delete m_pEncCavlc; 100 #endif 47 101 TCom3DAsymLUT::destroy(); 48 102 } … … 58 112 } 59 113 114 #if R0151_CGS_3D_ASYMLUT_IMPROVE 115 Double TEnc3DAsymLUT::xxDeriveVertexPerColor( Double N , Double Ys , Double Yy , Double Yu , Double Yv , Double ys , Double us , Double vs , Double yy , Double yu , Double yv , Double uu , Double uv , Double vv , Double YY , 116 Pel & rP0 , Pel & rP1 , Pel & rP3 , Pel & rP7 , Int nResQuantBit ) 117 { 118 Int nInitP0 = rP0; 119 Int nInitP1 = rP1; 120 Int nInitP3 = rP3; 121 Int nInitP7 = rP7; 122 123 const Int nOne = xGetNormCoeffOne(); 124 Double dNorm = (N * yy * vv * uu - N * yy * uv * uv - N * yv * yv * uu - N * vv * yu * yu + 2 * N * yv * uv * yu - yy * vs * vs * uu + 2 * yy * vs * uv * us - yy * vv * us * us - 2 * vs * uv * yu * ys + uv * uv * ys * ys + vs * vs * yu * yu - 2 * yv * vs * us * yu + 2 * yv * vs * ys * uu - 2 * yv * uv * us * ys + 2 * vv * yu * ys * us - vv * uu * ys * ys + yv * yv * us * us); 125 if( N > 16 && dNorm != 0 ) 126 { 127 Double dInitA = (-N * uu * yv * Yv + N * uu * Yy * vv - N * Yy * uv * uv + N * yv * uv * Yu - N * yu * Yu * vv + N * yu * uv * Yv + yu * us * Ys * vv - vs * ys * uv * Yu - yu * vs * us * Yv - yv * uv * us * Ys - yv * vs * us * Yu - yu * uv * vs * Ys - ys * us * uv * Yv + ys * us * Yu * vv + 2 * Yy * vs * uv * us + uu * yv * vs * Ys - uu * ys * Ys * vv + uu * vs * ys * Yv + ys * Ys * uv * uv - Yy * vv * us * us + yu * Yu * vs * vs + yv * Yv * us * us - uu * Yy * vs * vs) / dNorm; 128 Double dInitB = (N * yy * Yu * vv - N * yy * uv * Yv - N * Yu * yv * yv - N * yu * Yy * vv + N * uv * yv * Yy + N * yv * yu * Yv - yy * us * Ys * vv + yy * uv * vs * Ys - yy * Yu * vs * vs + yy * vs * us * Yv - uv * vs * ys * Yy - yv * yu * vs * Ys + yu * Yy * vs * vs + yu * ys * Ys * vv - uv * yv * ys * Ys + 2 * Yu * yv * vs * ys + us * ys * Yy * vv - vs * ys * yu * Yv + uv * ys * ys * Yv + us * Ys * yv * yv - Yu * ys * ys * vv - yv * ys * us * Yv - vs * us * yv * Yy) / dNorm; 129 Double dInitC = -(-N * yy * Yv * uu + N * yy * uv * Yu - N * yv * yu * Yu - N * uv * yu * Yy + N * Yv * yu * yu + N * yv * Yy * uu - yy * uv * us * Ys + yy * Yv * us * us + yy * vs * Ys * uu - yy * vs * us * Yu + yv * ys * us * Yu - vs * Ys * yu * yu - yv * ys * Ys * uu + vs * us * yu * Yy + vs * ys * yu * Yu - uv * Yu * ys * ys + Yv * uu * ys * ys - yv * Yy * us * us - 2 * Yv * yu * ys * us - vs * ys * Yy * uu + uv * us * ys * Yy + uv * yu * ys * Ys + yv * yu * us * Ys) / dNorm; 130 nInitP0 = ( Int )( dInitA * nOne + 0.5 ) >> nResQuantBit << nResQuantBit; 131 nInitP1 = ( Int )( dInitB * nOne + 0.5 ) >> nResQuantBit << nResQuantBit; 132 nInitP3 = ( Int )( dInitC * nOne + 0.5 ) >> nResQuantBit << nResQuantBit; 133 } 134 135 Int nMin = - ( 1 << ( m_nLUTBitDepth - 1 ) ); 136 Int nMax = - nMin - ( 1 << nResQuantBit ); 137 Int nMask = ( 1 << nResQuantBit ) - 1; 138 139 Double dMinError = MAX_DOUBLE; 140 Int nTestRange = 2; 141 Int nStepSize = 1 << nResQuantBit; 142 for( Int i = - nTestRange ; i <= nTestRange ; i++ ) 143 { 144 for( Int j = - nTestRange ; j <= nTestRange ; j++ ) 145 { 146 for( Int k = - nTestRange ; k <= nTestRange ; k++ ) 147 { 148 Int nTestP0 = Clip3( nMin , nMax , nInitP0 + i * nStepSize ); 149 Int nTestP1 = Clip3( nMin , nMax , nInitP1 + j * nStepSize ); 150 Int nTestP3 = Clip3( nMin , nMax , nInitP3 + k * nStepSize ); 151 Double a = 1.0 * nTestP0 / nOne; 152 Double b = 1.0 * nTestP1 / nOne; 153 Double c = 1.0 * nTestP3 / nOne; 154 Double d = ( Ys - a * ys - b * us - c * vs ) / N; 155 nInitP7 = ( ( Int )d ) >> nResQuantBit << nResQuantBit; 156 for( Int m = 0 ; m < 2 ; m++ ) 157 { 158 Int nTestP7 = Clip3( nMin , nMax , nInitP7 + m * nStepSize ); 159 Double dError = xxCalEstDist( N , Ys , Yy , Yu , Yv , ys , us , vs , yy , yu , yv , uu , uv , vv , YY , a , b , c , nTestP7 ); 160 if( dError < dMinError ) 161 { 162 dMinError = dError; 163 rP0 = ( Pel )nTestP0; 164 rP1 = ( Pel )nTestP1; 165 rP3 = ( Pel )nTestP3; 166 rP7 = ( Pel )nTestP7; 167 } 168 } 169 } 170 } 171 } 172 assert( !( rP0 & nMask ) && !( rP1 & nMask ) && !( rP3 & nMask ) && !( rP7 & nMask ) ); 173 174 return( dMinError ); 175 } 176 #else 60 177 Double TEnc3DAsymLUT::xxDeriveVertexPerColor( Double N , Double Ys , Double Yy , Double Yu , Double Yv , Double ys , Double us , Double vs , Double yy , Double yu , Double yv , Double uu , Double uv , Double vv , Double YY , 61 178 Int y0 , Int u0 , Int v0 , Int nLengthY , Int nLengthUV , … … 134 251 return( dMinError ); 135 252 } 136 253 #endif 254 255 #if R0151_CGS_3D_ASYMLUT_IMPROVE 256 Double TEnc3DAsymLUT::estimateDistWithCur3DAsymLUT( TComPic * pCurPic , UInt refLayerIdc ) 257 { 258 xxCollectData( pCurPic , refLayerIdc ); 259 260 Double dErrorLuma = 0 , dErrorChroma = 0; 261 Int nYSize = 1 << ( getCurOctantDepth() + getCurYPartNumLog2() ); 262 Int nUVSize = 1 << getCurOctantDepth(); 263 for( Int yIdx = 0 ; yIdx < nYSize ; yIdx++ ) 264 { 265 for( Int uIdx = 0 ; uIdx < nUVSize ; uIdx++ ) 266 { 267 for( Int vIdx = 0 ; vIdx < nUVSize ; vIdx++ ) 268 { 269 SColorInfo & rCuboidColorInfo = m_pColorInfo[yIdx][uIdx][vIdx]; 270 SColorInfo & rCuboidColorInfoC = m_pColorInfoC[yIdx][uIdx][vIdx]; 271 SCuboid & rCuboid = xGetCuboid( yIdx , uIdx , vIdx ); 272 if( rCuboidColorInfo.N > 0 ) 273 { 274 dErrorLuma += xxCalEstDist( rCuboidColorInfo.N , rCuboidColorInfo.Ys , rCuboidColorInfo.Yy , rCuboidColorInfo.Yu , rCuboidColorInfo.Yv , rCuboidColorInfo.ys , rCuboidColorInfo.us , rCuboidColorInfo.vs , rCuboidColorInfo.yy , rCuboidColorInfo.yu , rCuboidColorInfo.yv , rCuboidColorInfo.uu , rCuboidColorInfo.uv , rCuboidColorInfo.vv , rCuboidColorInfo.YY , 275 rCuboid.P[0].Y , rCuboid.P[1].Y , rCuboid.P[2].Y , rCuboid.P[3].Y ); 276 } 277 if( rCuboidColorInfoC.N > 0 ) 278 { 279 dErrorChroma += xxCalEstDist( rCuboidColorInfoC.N , rCuboidColorInfoC.Us , rCuboidColorInfoC.Uy , rCuboidColorInfoC.Uu , rCuboidColorInfoC.Uv , rCuboidColorInfoC.ys , rCuboidColorInfoC.us , rCuboidColorInfoC.vs , rCuboidColorInfoC.yy , rCuboidColorInfoC.yu , rCuboidColorInfoC.yv , rCuboidColorInfoC.uu , rCuboidColorInfoC.uv , rCuboidColorInfoC.vv , rCuboidColorInfoC.UU , 280 rCuboid.P[0].U , rCuboid.P[1].U , rCuboid.P[2].U , rCuboid.P[3].U ); 281 dErrorChroma += xxCalEstDist( rCuboidColorInfoC.N , rCuboidColorInfoC.Vs , rCuboidColorInfoC.Vy , rCuboidColorInfoC.Vu , rCuboidColorInfoC.Vv , rCuboidColorInfoC.ys , rCuboidColorInfoC.us , rCuboidColorInfoC.vs , rCuboidColorInfoC.yy , rCuboidColorInfoC.yu , rCuboidColorInfoC.yv , rCuboidColorInfoC.uu , rCuboidColorInfoC.uv , rCuboidColorInfoC.vv , rCuboidColorInfoC.VV , 282 rCuboid.P[0].V , rCuboid.P[1].V , rCuboid.P[2].V , rCuboid.P[3].V ); 283 } 284 } 285 } 286 } 287 288 return( dErrorLuma + dErrorChroma); 289 } 290 #else 137 291 Double TEnc3DAsymLUT::estimateDistWithCur3DAsymLUT( TComPic * pCurPic , UInt refLayerIdc ) 138 292 { … … 174 328 return( dErrorLuma + dErrorChroma); 175 329 } 176 330 #endif 331 332 #if R0151_CGS_3D_ASYMLUT_IMPROVE 333 #if R0179_ENC_OPT_3DLUT_SIZE 334 Double TEnc3DAsymLUT::derive3DAsymLUT( TComSlice * pSlice , TComPic * pCurPic , UInt refLayerIdc , TEncCfg * pCfg , Bool bSignalPPS , Bool bElRapSliceTypeB, Double dFrameLambda ) 335 { 336 m_nLUTBitDepth = pCfg->getCGSLUTBit(); 337 338 Int nBestAdaptCThresholdU = 1 << ( getInputBitDepthC() - 1 ); 339 Int nBestAdaptCThresholdV = 1 << ( getInputBitDepthC() - 1 ); 340 Int nAdaptCThresholdU, nAdaptCThresholdV; 341 342 Int nTmpLutBits[MAX_Y_SIZE][MAX_C_SIZE] ; 343 memset(nTmpLutBits, 0, sizeof(nTmpLutBits)); 344 345 SLUTSize sMaxLutSize; 346 347 // collect stats for the most partitions 348 Int nCurYPartNumLog2 = 0 , nCurOctantDepth = 0; 349 Int nMaxPartNumLog2 = xGetMaxPartNumLog2(); 350 351 xxMapPartNum2DepthYPart( nMaxPartNumLog2 , nCurOctantDepth , nCurYPartNumLog2 ); 352 xUpdatePartitioning( nCurOctantDepth , nCurYPartNumLog2, nBestAdaptCThresholdU, nBestAdaptCThresholdV ); 353 xxCollectData( pCurPic , refLayerIdc ); 354 xxCopyColorInfo(m_pMaxColorInfo, m_pColorInfo, m_pMaxColorInfoC, m_pColorInfoC); 355 356 sMaxLutSize.iCPartNumLog2 = nCurOctantDepth; 357 sMaxLutSize.iYPartNumLog2 = nCurOctantDepth + nCurYPartNumLog2; 358 359 m_pBitstreamRedirect->clear(); 360 361 // find the best partition based on RD cost 362 Int i; 363 Double dMinCost, dCurCost; 364 365 Int iBestLUTSizeIdx = 0; 366 Int nBestResQuanBit = 0; 367 Double dCurError, dMinError; 368 Int iNumBitsCurSize; 369 Int iNumBitsCurSizeSave = m_pEncCavlc->getNumberOfWrittenBits(); 370 Double dDistFactor = getDistFactor(pSlice->getSliceType(), pSlice->getDepth()); 371 372 // check all LUT sizes 373 xxGetAllLutSizes(pSlice); 374 if (m_nTotalLutSizes == 0) // return if no valid size is found, LUT will not be updated 375 { 376 nCurOctantDepth = sMaxLutSize.iCPartNumLog2; 377 nCurYPartNumLog2 = sMaxLutSize.iYPartNumLog2-nCurOctantDepth; 378 xUpdatePartitioning( nCurOctantDepth , nCurYPartNumLog2, nBestAdaptCThresholdU, nBestAdaptCThresholdV ); 379 return MAX_DOUBLE; 380 } 381 382 dMinCost = MAX_DOUBLE; dMinError = MAX_DOUBLE; 383 for (i = 0; i < m_nTotalLutSizes; i++) 384 { 385 // add up the stats 386 nCurOctantDepth = m_sLutSizes[i].iCPartNumLog2; 387 nCurYPartNumLog2 = m_sLutSizes[i].iYPartNumLog2-nCurOctantDepth; 388 xUpdatePartitioning( nCurOctantDepth , nCurYPartNumLog2, nBestAdaptCThresholdU, nBestAdaptCThresholdV ); 389 xxConsolidateData( &m_sLutSizes[i], &sMaxLutSize ); 390 391 dCurError = xxDeriveVertexes(nBestResQuanBit, m_pEncCuboid); 392 393 setResQuantBit( nBestResQuanBit ); 394 xSaveCuboids( m_pEncCuboid ); 395 m_pEncCavlc->xCode3DAsymLUT( this ); 396 iNumBitsCurSize = m_pEncCavlc->getNumberOfWrittenBits(); 397 dCurCost = dCurError/dDistFactor + dFrameLambda*(Double)(iNumBitsCurSize-iNumBitsCurSizeSave); 398 nTmpLutBits[m_sLutSizes[i].iYPartNumLog2][m_sLutSizes[i].iCPartNumLog2] = iNumBitsCurSize-iNumBitsCurSizeSave; // store LUT size 399 iNumBitsCurSizeSave = iNumBitsCurSize; 400 if(dCurCost < dMinCost ) 401 { 402 SCuboid *** tmp = m_pBestEncCuboid; 403 m_pBestEncCuboid = m_pEncCuboid; 404 m_pEncCuboid = tmp; 405 dMinCost = dCurCost; 406 dMinError = dCurError; 407 iBestLUTSizeIdx = i; 408 } 409 } 410 411 nCurOctantDepth = m_sLutSizes[iBestLUTSizeIdx].iCPartNumLog2; 412 nCurYPartNumLog2 = m_sLutSizes[iBestLUTSizeIdx].iYPartNumLog2-nCurOctantDepth; 413 414 xUpdatePartitioning( nCurOctantDepth , nCurYPartNumLog2, nBestAdaptCThresholdU, nBestAdaptCThresholdV ); 415 416 Bool bUseNewColorInfo = false; 417 if( pCfg->getCGSAdaptChroma() && nCurOctantDepth <= 1 ) // if the best size found so far has depth = 0 or 1, then check AdaptC U/V thresholds 418 { 419 nAdaptCThresholdU = ( Int )( m_dSumU / m_nNChroma + 0.5 ); 420 nAdaptCThresholdV = ( Int )( m_dSumV / m_nNChroma + 0.5 ); 421 if( !(nAdaptCThresholdU == nBestAdaptCThresholdU && nAdaptCThresholdV == nBestAdaptCThresholdV ) ) 422 { 423 nCurOctantDepth = 1; 424 if( nCurOctantDepth + nCurYPartNumLog2 > getMaxYPartNumLog2()+getMaxOctantDepth() ) 425 nCurYPartNumLog2 = getMaxYPartNumLog2()+getMaxOctantDepth()-nCurOctantDepth; 426 xUpdatePartitioning( nCurOctantDepth , nCurYPartNumLog2 , nAdaptCThresholdU , nAdaptCThresholdV ); 427 xxCollectData( pCurPic , refLayerIdc ); 428 429 dCurError = xxDeriveVertexes( nBestResQuanBit , m_pEncCuboid ) ; 430 setResQuantBit( nBestResQuanBit ); 431 xSaveCuboids( m_pEncCuboid ); 432 m_pEncCavlc->xCode3DAsymLUT( this ); 433 iNumBitsCurSize = m_pEncCavlc->getNumberOfWrittenBits(); 434 dCurCost = dCurError/dDistFactor + dFrameLambda*(Double)(iNumBitsCurSize-iNumBitsCurSizeSave); 435 iNumBitsCurSizeSave = iNumBitsCurSize; 436 if(dCurCost < dMinCost ) 437 { 438 SCuboid *** tmp = m_pBestEncCuboid; 439 m_pBestEncCuboid = m_pEncCuboid; 440 m_pEncCuboid = tmp; 441 dMinCost = dCurCost; 442 dMinError = dCurError; 443 nBestAdaptCThresholdU = nAdaptCThresholdU; 444 nBestAdaptCThresholdV = nAdaptCThresholdV; 445 bUseNewColorInfo = true; 446 } 447 } 448 } 449 450 xUpdatePartitioning( nCurOctantDepth , nCurYPartNumLog2, nBestAdaptCThresholdU, nBestAdaptCThresholdV ); 451 452 // check res_quant_bits only for the best table size and best U/V threshold 453 if( !bUseNewColorInfo ) 454 xxConsolidateData( &m_sLutSizes[iBestLUTSizeIdx], &sMaxLutSize ); 455 456 // xxCollectData( pCurPic , refLayerIdc ); 457 for( Int nResQuanBit = 1 ; nResQuanBit < 4 ; nResQuanBit++ ) 458 { 459 dCurError = xxDeriveVertexes( nResQuanBit , m_pEncCuboid ); 460 461 setResQuantBit( nResQuanBit ); 462 xSaveCuboids( m_pEncCuboid ); 463 m_pEncCavlc->xCode3DAsymLUT( this ); 464 iNumBitsCurSize = m_pEncCavlc->getNumberOfWrittenBits(); 465 dCurCost = dCurError/dDistFactor + dFrameLambda*(Double)(iNumBitsCurSize-iNumBitsCurSizeSave); 466 467 iNumBitsCurSizeSave = iNumBitsCurSize; 468 if(dCurCost < dMinCost) 469 { 470 nBestResQuanBit = nResQuanBit; 471 SCuboid *** tmp = m_pBestEncCuboid; 472 m_pBestEncCuboid = m_pEncCuboid; 473 m_pEncCuboid = tmp; 474 dMinCost = dCurCost; 475 dMinError = dCurError; 476 } 477 else 478 { 479 break; 480 } 481 } 482 483 setResQuantBit( nBestResQuanBit ); 484 xSaveCuboids( m_pBestEncCuboid ); 485 486 // update LUT size stats 487 for(Int iLutSizeY = 0; iLutSizeY < MAX_Y_SIZE; iLutSizeY++) 488 { 489 for(Int iLutSizeC = 0; iLutSizeC < MAX_C_SIZE; iLutSizeC++) 490 { 491 if(nTmpLutBits[iLutSizeY][iLutSizeC] != 0) 492 m_nNumLUTBits[iLutSizeY][iLutSizeC] = (m_nNumLUTBits[iLutSizeY][iLutSizeC] + nTmpLutBits[iLutSizeY][iLutSizeC]*3+2)>>2; // update with new stats 493 } 494 } 495 496 // return cost rather than error 497 return( dMinCost ); 498 } 499 #endif 500 501 502 Double TEnc3DAsymLUT::derive3DAsymLUT( TComSlice * pSlice , TComPic * pCurPic , UInt refLayerIdc , TEncCfg * pCfg , Bool bSignalPPS , Bool bElRapSliceTypeB ) 503 { 504 m_nLUTBitDepth = pCfg->getCGSLUTBit(); 505 Int nCurYPartNumLog2 = 0 , nCurOctantDepth = 0; 506 xxDerivePartNumLog2( pSlice , pCfg , nCurOctantDepth , nCurYPartNumLog2 , bSignalPPS , bElRapSliceTypeB ); 507 508 Int nBestResQuanBit = 0; 509 Int nBestAdaptCThresholdU = 1 << ( getInputBitDepthC() - 1 ); 510 Int nBestAdaptCThresholdV = 1 << ( getInputBitDepthC() - 1 ); 511 Int nBestOctantDepth = nCurOctantDepth; 512 Int nBestYPartNumLog2 = nCurYPartNumLog2; 513 Int nTargetLoop = 1 + ( pCfg->getCGSAdaptChroma() && ( nCurOctantDepth == 1 || ( nCurOctantDepth * 3 + nCurYPartNumLog2 ) >= 5 ) ); 514 Double dMinError = MAX_DOUBLE; 515 for( Int nLoop = 0 ; nLoop < nTargetLoop ; nLoop++ ) 516 { 517 Int nAdaptCThresholdU = 1 << ( getInputBitDepthC() - 1 ); 518 Int nAdaptCThresholdV = 1 << ( getInputBitDepthC() - 1 ); 519 if( nLoop > 0 ) 520 { 521 nAdaptCThresholdU = ( Int )( m_dSumU / m_nNChroma + 0.5 ); 522 nAdaptCThresholdV = ( Int )( m_dSumV / m_nNChroma + 0.5 ); 523 if( nCurOctantDepth > 1 ) 524 { 525 nCurOctantDepth = 1; 526 nCurYPartNumLog2 = 2; 527 } 528 if( nAdaptCThresholdU == nBestAdaptCThresholdU && nAdaptCThresholdV == nBestAdaptCThresholdV 529 && nCurOctantDepth == nBestOctantDepth && nCurYPartNumLog2 == nBestYPartNumLog2 ) 530 break; 531 } 532 533 xUpdatePartitioning( nCurOctantDepth , nCurYPartNumLog2 , nAdaptCThresholdU , nAdaptCThresholdV ); 534 xxCollectData( pCurPic , refLayerIdc ); 535 for( Int nResQuanBit = 0 ; nResQuanBit < 4 ; nResQuanBit++ ) 536 { 537 Double dError = xxDeriveVertexes( nResQuanBit , m_pEncCuboid ) / ( 1 + ( nResQuanBit > 0 ) * 0.001 * ( pSlice->getDepth() + 1 ) ); 538 if( dError <= dMinError ) 539 { 540 nBestResQuanBit = nResQuanBit; 541 nBestAdaptCThresholdU = nAdaptCThresholdU; 542 nBestAdaptCThresholdV = nAdaptCThresholdV; 543 nBestOctantDepth = nCurOctantDepth; 544 nBestYPartNumLog2 = nCurYPartNumLog2; 545 SCuboid *** tmp = m_pBestEncCuboid; 546 m_pBestEncCuboid = m_pEncCuboid; 547 m_pEncCuboid = tmp; 548 dMinError = dError; 549 } 550 else 551 { 552 break; 553 } 554 } 555 } 556 557 setResQuantBit( nBestResQuanBit ); 558 xUpdatePartitioning( nBestOctantDepth , nBestYPartNumLog2 , nBestAdaptCThresholdU , nBestAdaptCThresholdV ); 559 560 xSaveCuboids( m_pBestEncCuboid ); 561 return( dMinError ); 562 } 563 #else 177 564 Double TEnc3DAsymLUT::derive3DAsymLUT( TComSlice * pSlice , TComPic * pCurPic , UInt refLayerIdc , TEncCfg * pCfg , Bool bSignalPPS , Bool bElRapSliceTypeB ) 178 565 { … … 204 591 setResQuantBit( nBestResQuanBit ); 205 592 xSaveCuboids( m_pBestEncCuboid ); 206 207 593 return( dCurError ); 208 594 } 595 #endif 209 596 210 597 Double TEnc3DAsymLUT::xxDeriveVertexes( Int nResQuanBit , SCuboid *** pCurCuboid ) … … 213 600 Int nYSize = 1 << ( getCurOctantDepth() + getCurYPartNumLog2() ); 214 601 Int nUVSize = 1 << getCurOctantDepth(); 602 #if !R0151_CGS_3D_ASYMLUT_IMPROVE 215 603 Int nLengthY = 1 << ( getInputBitDepthY() - getCurOctantDepth() - getCurYPartNumLog2() ); 216 604 Int nLengthUV = 1 << ( getInputBitDepthC() - getCurOctantDepth() ); 605 #endif 217 606 for( Int yIdx = 0 ; yIdx < nYSize ; yIdx++ ) 218 607 { … … 224 613 SColorInfo & rCuboidColorInfoC = m_pColorInfoC[yIdx][uIdx][vIdx]; 225 614 SCuboid & rCuboid = pCurCuboid[yIdx][uIdx][vIdx]; 615 #if !R0151_CGS_3D_ASYMLUT_IMPROVE 226 616 Int y0 = yIdx << xGetYShift2Idx(); 227 617 Int u0 = uIdx << xGetUShift2Idx(); 228 618 Int v0 = vIdx << xGetVShift2Idx(); 619 #endif 229 620 for( Int idxVertex = 0 ; idxVertex < 4 ; idxVertex++ ) 230 621 { … … 235 626 { 236 627 dErrorLuma += xxDeriveVertexPerColor( rCuboidColorInfo.N , rCuboidColorInfo.Ys , rCuboidColorInfo.Yy , rCuboidColorInfo.Yu , rCuboidColorInfo.Yv , rCuboidColorInfo.ys , rCuboidColorInfo.us , rCuboidColorInfo.vs , rCuboidColorInfo.yy , rCuboidColorInfo.yu , rCuboidColorInfo.yv , rCuboidColorInfo.uu , rCuboidColorInfo.uv , rCuboidColorInfo.vv , rCuboidColorInfo.YY , 237 y0 , u0 , v0 , nLengthY , nLengthUV , rCuboid.P[0].Y , rCuboid.P[1].Y , rCuboid.P[2].Y , rCuboid.P[3].Y , nResQuanBit ); 628 #if !R0151_CGS_3D_ASYMLUT_IMPROVE 629 y0 , u0 , v0 , nLengthY , nLengthUV , 630 #endif 631 rCuboid.P[0].Y , rCuboid.P[1].Y , rCuboid.P[2].Y , rCuboid.P[3].Y , nResQuanBit ); 238 632 } 239 633 if( rCuboidColorInfoC.N > 0 ) 240 634 { 241 635 dErrorChroma += xxDeriveVertexPerColor( rCuboidColorInfoC.N , rCuboidColorInfoC.Us , rCuboidColorInfoC.Uy , rCuboidColorInfoC.Uu , rCuboidColorInfoC.Uv , rCuboidColorInfoC.ys , rCuboidColorInfoC.us , rCuboidColorInfoC.vs , rCuboidColorInfoC.yy , rCuboidColorInfoC.yu , rCuboidColorInfoC.yv , rCuboidColorInfoC.uu , rCuboidColorInfoC.uv , rCuboidColorInfoC.vv , rCuboidColorInfoC.UU , 242 y0 , u0 , v0 , nLengthY , nLengthUV , rCuboid.P[0].U , rCuboid.P[1].U , rCuboid.P[2].U , rCuboid.P[3].U , nResQuanBit ); 636 #if !R0151_CGS_3D_ASYMLUT_IMPROVE 637 y0 , u0 , v0 , nLengthY , nLengthUV , 638 #endif 639 rCuboid.P[0].U , rCuboid.P[1].U , rCuboid.P[2].U , rCuboid.P[3].U , nResQuanBit ); 243 640 dErrorChroma += xxDeriveVertexPerColor( rCuboidColorInfoC.N , rCuboidColorInfoC.Vs , rCuboidColorInfoC.Vy , rCuboidColorInfoC.Vu , rCuboidColorInfoC.Vv , rCuboidColorInfoC.ys , rCuboidColorInfoC.us , rCuboidColorInfoC.vs , rCuboidColorInfoC.yy , rCuboidColorInfoC.yu , rCuboidColorInfoC.yv , rCuboidColorInfoC.uu , rCuboidColorInfoC.uv , rCuboidColorInfoC.vv , rCuboidColorInfoC.VV , 244 y0 , u0 , v0 , nLengthY , nLengthUV , rCuboid.P[0].V , rCuboid.P[1].V , rCuboid.P[2].V , rCuboid.P[3].V , nResQuanBit ); 641 #if !R0151_CGS_3D_ASYMLUT_IMPROVE 642 y0 , u0 , v0 , nLengthY , nLengthUV , 643 #endif 644 rCuboid.P[0].V , rCuboid.P[1].V , rCuboid.P[2].V , rCuboid.P[3].V , nResQuanBit ); 245 645 } 246 646 … … 276 676 Int nStrideILRY = pRecPic->getStride(); 277 677 Int nStrideILRC = pRecPic->getCStride(); 678 #if R0179_ENC_OPT_3DLUT_SIZE 679 xReset3DArray( m_pColorInfo , getMaxYSize() , getMaxCSize() , getMaxCSize() ); 680 xReset3DArray( m_pColorInfoC , getMaxYSize() , getMaxCSize() , getMaxCSize() ); 681 #else 278 682 xReset3DArray( m_pColorInfo , xGetYSize() , xGetUSize() , xGetVSize() ); 279 683 xReset3DArray( m_pColorInfoC , xGetYSize() , xGetUSize() , xGetVSize() ); 684 #endif 280 685 281 686 //alignment padding … … 285 690 TComSlice * pSlice = pCurPic->getSlice(pCurPic->getCurrSliceIdx()); 286 691 UInt refLayerId = pSlice->getVPS()->getRefLayerId(pSlice->getLayerId(), refLayerIdc); 692 #if MOVE_SCALED_OFFSET_TO_PPS 693 const Window &scalEL = pSlice->getPPS()->getScaledRefLayerWindowForLayer(refLayerId); 694 #else 287 695 const Window &scalEL = pSlice->getSPS()->getScaledRefLayerWindowForLayer(refLayerId); 696 #endif 288 697 TComPicYuv *pcRecPicBL = pSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(); 289 698 // borders of down-sampled picture … … 299 708 // since we do data collection only for overlapped region, the border extension is good enough 300 709 710 #if R0151_CGS_3D_ASYMLUT_IMPROVE 711 m_dSumU = m_dSumV = 0; 712 m_nNChroma = 0; 713 #endif 301 714 for( Int i = top ; i <= bottom ; i++ ) 302 715 { … … 330 743 } 331 744 745 #if R0151_CGS_3D_ASYMLUT_IMPROVE 746 m_dSumU += u; 747 m_dSumV += v; 748 m_nNChroma++; 749 #endif 332 750 SColorInfo sColorInfo; 751 #if R0151_CGS_3D_ASYMLUT_IMPROVE 752 SColorInfo & rCuboidColorInfo = m_pColorInfo[xGetYIdx(y)][xGetUIdx(u)][xGetVIdx(v)]; 753 #else 333 754 SColorInfo & rCuboidColorInfo = m_pColorInfo[y>>xGetYShift2Idx()][u>>xGetUShift2Idx()][v>>xGetVShift2Idx()]; 755 #endif 334 756 memset(&sColorInfo, 0, sizeof(SColorInfo)); 335 757 sColorInfo.Ys = Y; … … 358 780 u = pIRLU[posIRLUV]; 359 781 v = pIRLV[posIRLUV]; 782 #if R0151_CGS_3D_ASYMLUT_IMPROVE 783 SColorInfo & rCuboidColorInfoC = m_pColorInfoC[xGetYIdx(y)][xGetUIdx(u)][xGetVIdx(v)]; 784 #else 360 785 SColorInfo & rCuboidColorInfoC = m_pColorInfoC[y>>xGetYShift2Idx()][u>>xGetUShift2Idx()][v>>xGetVShift2Idx()]; 786 #endif 361 787 sColorInfo.Us = U; 362 788 sColorInfo.Vs = V; … … 389 815 Void TEnc3DAsymLUT::xxDerivePartNumLog2( TComSlice * pSlice , TEncCfg * pcCfg , Int & rOctantDepth , Int & rYPartNumLog2 , Bool bSignalPPS , Bool bElRapSliceTypeB ) 390 816 { 817 #if !R0151_CGS_3D_ASYMLUT_IMPROVE 391 818 Int nSliceType = pSlice->getSliceType(); 392 819 // update slice type as what will be done later … … 406 833 407 834 const Int nSliceTempLevel = pSlice->getDepth(); 835 #endif 408 836 Int nPartNumLog2 = 4; 409 837 if( pSlice->getBaseColPic( pSlice->getInterLayerPredLayerIdc( 0 ) )->getSlice( 0 )->isIntra() ) … … 411 839 nPartNumLog2 = xGetMaxPartNumLog2(); 412 840 } 841 #if R0151_CGS_3D_ASYMLUT_IMPROVE 842 if( m_nAccuFrameBit && pSlice->getPPS()->getCGSFlag() ) 843 { 844 Double dBitCost = 1.0 * m_nAccuFrameCGSBit / m_nAccuFrameBit; 845 nPartNumLog2 = m_nPrevFrameCGSPartNumLog2; 846 #else 413 847 if( m_nPrevFrameBit[nSliceType][nSliceTempLevel] && pSlice->getPPS()->getCGSFlag() ) 414 848 { 415 849 Double dBitCost = 1.0 * m_nPrevFrameCGSBit[nSliceType][nSliceTempLevel] / m_nPrevFrameBit[nSliceType][nSliceTempLevel]; 416 850 nPartNumLog2 = m_nPrevFrameCGSPartNumLog2[nSliceType][nSliceTempLevel]; 851 #endif 417 852 Double dBitCostT = 0.03; 418 853 if( dBitCost < dBitCostT / 6.0 ) … … 425 860 } 426 861 } 862 #if !R0151_CGS_3D_ASYMLUT_IMPROVE 427 863 else 428 864 { 429 865 nPartNumLog2 -= nSliceTempLevel; 430 866 } 431 nPartNumLog2 = Clip3( 0 , xGetMaxPartNumLog2() , nPartNumLog2 ); 867 #endif 868 nPartNumLog2 = Clip3( 0 , xGetMaxPartNumLog2() , nPartNumLog2 ); 432 869 xxMapPartNum2DepthYPart( nPartNumLog2 , rOctantDepth , rYPartNumLog2 ); 433 870 } … … 453 890 Void TEnc3DAsymLUT::updatePicCGSBits( TComSlice * pcSlice , Int nPPSBit ) 454 891 { 892 #if !R0151_CGS_3D_ASYMLUT_IMPROVE 455 893 const Int nSliceType = pcSlice->getSliceType(); 456 894 const Int nSliceTempLevel = pcSlice->getDepth(); 457 895 #endif 458 896 for( Int i = 0; i < pcSlice->getActiveNumILRRefIdx(); i++ ) 459 897 { 460 898 UInt refLayerIdc = pcSlice->getInterLayerPredLayerIdc(i); 899 #if R0151_CGS_3D_ASYMLUT_IMPROVE 900 m_nAccuFrameBit += pcSlice->getPic()->getFrameBit() + pcSlice->getBaseColPic(refLayerIdc)->getFrameBit(); 901 #else 461 902 m_nPrevFrameBit[nSliceType][nSliceTempLevel] = pcSlice->getPic()->getFrameBit() + pcSlice->getBaseColPic(refLayerIdc)->getFrameBit(); 903 #endif 462 904 m_dTotalFrameBit += pcSlice->getPic()->getFrameBit() + pcSlice->getBaseColPic(refLayerIdc)->getFrameBit(); 463 905 } 906 #if R0151_CGS_3D_ASYMLUT_IMPROVE 907 m_nAccuFrameCGSBit += nPPSBit; 908 m_nTotalCGSBit += nPPSBit; 909 m_nPrevFrameCGSPartNumLog2 = getCurOctantDepth() * 3 + getCurYPartNumLog2(); 910 #else 464 911 m_nPrevFrameOverWritePPS[nSliceType][nSliceTempLevel] = pcSlice->getCGSOverWritePPS(); 465 912 m_nPrevFrameCGSBit[nSliceType][nSliceTempLevel] = nPPSBit; 466 913 m_nTotalCGSBit += nPPSBit; 467 914 m_nPrevFrameCGSPartNumLog2[nSliceType][nSliceTempLevel] = getCurOctantDepth() * 3 + getCurYPartNumLog2(); 468 } 469 470 #endif 915 #endif 916 #if R0179_ENC_OPT_3DLUT_SIZE 917 Int nCurELFrameBit = pcSlice->getPic()->getFrameBit(); 918 const Int nSliceType = pcSlice->getSliceType(); 919 const Int nSliceTempLevel = pcSlice->getDepth(); 920 m_nPrevELFrameBit[nSliceType][nSliceTempLevel] = m_nPrevELFrameBit[nSliceType][nSliceTempLevel] == 0 ? nCurELFrameBit:((m_nPrevELFrameBit[nSliceType][nSliceTempLevel]+nCurELFrameBit)>>1); 921 #endif 922 } 923 924 #if R0179_ENC_OPT_3DLUT_SIZE 925 926 Void TEnc3DAsymLUT::xxGetAllLutSizes(TComSlice *pSlice) 927 { 928 Int iMaxYPartNumLog2, iMaxCPartNumLog2; 929 Int iCurYPartNumLog2, iCurCPartNumLog2; 930 Int iMaxAddYPartNumLog2; 931 Int iNumELFrameBits = m_nPrevELFrameBit[pSlice->getSliceType()][pSlice->getDepth()]; 932 933 xxMapPartNum2DepthYPart( xGetMaxPartNumLog2() , iMaxCPartNumLog2 , iMaxYPartNumLog2 ); 934 iMaxAddYPartNumLog2 = iMaxYPartNumLog2; 935 iMaxYPartNumLog2 += iMaxCPartNumLog2; 936 937 //m_sLutSizes[0].iYPartNumLog2 = iMaxYPartNumLog2; 938 //m_sLutSizes[0].iCPartNumLog2 = iMaxCPartNumLog2; 939 m_nTotalLutSizes = 0; 940 941 942 for(iCurYPartNumLog2 = iMaxYPartNumLog2; iCurYPartNumLog2 >= 0; iCurYPartNumLog2--) 943 { 944 for(iCurCPartNumLog2 = iMaxCPartNumLog2; iCurCPartNumLog2 >= 0; iCurCPartNumLog2--) 945 { 946 // try more sizes 947 if(iCurCPartNumLog2 <= iCurYPartNumLog2 && 948 (m_nNumLUTBits[iCurYPartNumLog2][iCurCPartNumLog2] < (iNumELFrameBits>>1)) && 949 m_nTotalLutSizes < MAX_NUM_LUT_SIZES) 950 { 951 m_sLutSizes[m_nTotalLutSizes].iYPartNumLog2 = iCurYPartNumLog2; 952 m_sLutSizes[m_nTotalLutSizes].iCPartNumLog2 = iCurCPartNumLog2; 953 m_nTotalLutSizes ++; 954 } 955 } 956 } 957 958 } 959 960 Void TEnc3DAsymLUT::xxCopyColorInfo( SColorInfo *** dst, SColorInfo *** src , SColorInfo *** dstC, SColorInfo *** srcC ) 961 { 962 Int yIdx, uIdx, vIdx; 963 964 // copy from pColorInfo to pMaxColorInfo 965 for(yIdx = 0; yIdx < xGetYSize(); yIdx++) 966 { 967 for(uIdx = 0; uIdx < xGetUSize(); uIdx++) 968 { 969 for(vIdx = 0; vIdx < xGetVSize(); vIdx++) 970 { 971 dst [yIdx][uIdx][vIdx] = src [yIdx][uIdx][vIdx]; 972 dstC[yIdx][uIdx][vIdx] = srcC[yIdx][uIdx][vIdx]; 973 } 974 } 975 } 976 } 977 978 Void TEnc3DAsymLUT::xxAddColorInfo( Int yIdx, Int uIdx, Int vIdx, Int iYDiffLog2, Int iCDiffLog2 ) 979 { 980 SColorInfo & rCuboidColorInfo = m_pColorInfo [yIdx][uIdx][vIdx]; 981 SColorInfo & rCuboidColorInfoC = m_pColorInfoC[yIdx][uIdx][vIdx]; 982 983 for( Int i = 0; i < (1<<iYDiffLog2); i++) 984 { 985 for (Int j = 0; j < (1<<iCDiffLog2); j++) 986 { 987 for(Int k = 0; k < (1<<iCDiffLog2); k++) 988 { 989 rCuboidColorInfo += m_pMaxColorInfo [(yIdx<<iYDiffLog2)+i][(uIdx<<iCDiffLog2)+j][(vIdx<<iCDiffLog2)+k]; 990 rCuboidColorInfoC += m_pMaxColorInfoC[(yIdx<<iYDiffLog2)+i][(uIdx<<iCDiffLog2)+j][(vIdx<<iCDiffLog2)+k]; 991 } 992 } 993 } 994 } 995 996 Void TEnc3DAsymLUT::xxConsolidateData( SLUTSize *pCurLUTSize, SLUTSize *pMaxLUTSize ) 997 { 998 Int yIdx, uIdx, vIdx; 999 Int iYDiffLog2, iCDiffLog2; 1000 Int nYSize = 1<< pMaxLUTSize->iYPartNumLog2; 1001 Int nCSize = 1<< pMaxLUTSize->iCPartNumLog2; 1002 1003 iYDiffLog2 = pMaxLUTSize->iYPartNumLog2-pCurLUTSize->iYPartNumLog2; 1004 iCDiffLog2 = pMaxLUTSize->iCPartNumLog2-pCurLUTSize->iCPartNumLog2; 1005 1006 //assert(pMaxLUTSize->iCPartNumLog2 >= pCurLUTSize->iCPartNumLog2 && pMaxLUTSize->iYPartNumLog2 >= pCurLUTSize->iYPartNumLog2); 1007 if (iYDiffLog2 == 0 && iCDiffLog2 == 0) // shouldn't have to do anything 1008 { 1009 xxCopyColorInfo(m_pColorInfo, m_pMaxColorInfo, m_pColorInfoC, m_pMaxColorInfoC); 1010 return; 1011 } 1012 1013 xReset3DArray( m_pColorInfo , 1<<pMaxLUTSize->iYPartNumLog2, 1<<pMaxLUTSize->iCPartNumLog2, 1<<pMaxLUTSize->iCPartNumLog2 ); 1014 xReset3DArray( m_pColorInfoC , 1<<pMaxLUTSize->iYPartNumLog2, 1<<pMaxLUTSize->iCPartNumLog2, 1<<pMaxLUTSize->iCPartNumLog2 ); 1015 1016 for(yIdx = 0; yIdx < nYSize; yIdx++) 1017 { 1018 for(uIdx = 0; uIdx < nCSize; uIdx++) 1019 { 1020 for(vIdx = 0; vIdx < nCSize; vIdx++) 1021 { 1022 const SColorInfo & rCuboidSrc = m_pMaxColorInfo [yIdx][uIdx][vIdx]; 1023 const SColorInfo & rCuboidSrcC = m_pMaxColorInfoC[yIdx][uIdx][vIdx]; 1024 1025 Int yIdx2, uIdx2, vIdx2; 1026 yIdx2 = yIdx>>iYDiffLog2; 1027 uIdx2 = uIdx>>iCDiffLog2; 1028 vIdx2 = vIdx>>iCDiffLog2; 1029 1030 m_pColorInfo [yIdx2][uIdx2][vIdx2] += rCuboidSrc; 1031 m_pColorInfoC[yIdx2][uIdx2][vIdx2] += rCuboidSrcC; 1032 } 1033 } 1034 } 1035 } 1036 1037 Void TEnc3DAsymLUT::update3DAsymLUTParam( TEnc3DAsymLUT * pSrc ) 1038 { 1039 assert( pSrc->getMaxOctantDepth() == getMaxOctantDepth() && pSrc->getMaxYPartNumLog2() == getMaxYPartNumLog2() ); 1040 xUpdatePartitioning( pSrc->getCurOctantDepth() , pSrc->getCurYPartNumLog2() 1041 #if R0151_CGS_3D_ASYMLUT_IMPROVE 1042 , pSrc->getAdaptChromaThresholdU() , pSrc->getAdaptChromaThresholdV() 1043 #endif 1044 ); 1045 setResQuantBit( pSrc->getResQuantBit() ); 1046 } 1047 1048 #endif 1049 #endif -
trunk/source/Lib/TLibEncoder/TEnc3DAsymLUT.h
r713 r906 8 8 #include "../TLibCommon/TComPic.h" 9 9 #include "TEncCfg.h" 10 #if R0179_ENC_OPT_3DLUT_SIZE 11 #include "TEncCavlc.h" 12 #define MAX_NUM_LUT_SIZES 10 // 4+3+2+1 13 #define MAX_Y_SIZE 4 14 #define MAX_C_SIZE 4 15 #endif 10 16 11 17 #if Q0048_CGS_3D_ASYMLUT … … 55 61 }SColorInfo; 56 62 63 #if R0179_ENC_OPT_3DLUT_SIZE 64 typedef struct _LUTSize 65 { 66 Int iYPartNumLog2; 67 Int iCPartNumLog2; 68 } SLUTSize; 69 #endif 57 70 58 71 class TEnc3DAsymLUT : public TCom3DAsymLUT … … 66 79 Double derive3DAsymLUT( TComSlice * pSlice , TComPic * pCurPic , UInt refLayerIdc , TEncCfg * pCfg , Bool bSignalPPS , Bool bElRapSliceTypeB ); 67 80 Double estimateDistWithCur3DAsymLUT( TComPic * pCurPic , UInt refLayerIdc ); 81 #if R0179_ENC_OPT_3DLUT_SIZE 82 Double getDistFactor( Int iSliceType, Int iLayer) { return m_dDistFactor[iSliceType][iLayer];} 83 Double derive3DAsymLUT( TComSlice * pSlice , TComPic * pCurPic , UInt refLayerIdc , TEncCfg * pCfg , Bool bSignalPPS , Bool bElRapSliceTypeB, Double dFrameLambda ); 84 Void update3DAsymLUTParam( TEnc3DAsymLUT * pSrc ); 85 #endif 68 86 69 87 Void updatePicCGSBits( TComSlice * pcSlice , Int nPPSBit ); … … 75 93 SColorInfo *** m_pColorInfo; 76 94 SColorInfo *** m_pColorInfoC; 95 #if R0179_ENC_OPT_3DLUT_SIZE 96 SColorInfo *** m_pMaxColorInfo; 97 SColorInfo *** m_pMaxColorInfoC; 98 #endif 77 99 TComPicYuv* m_pDsOrigPic; 78 100 SCuboid *** m_pEncCuboid; 79 101 SCuboid *** m_pBestEncCuboid; 102 #if R0151_CGS_3D_ASYMLUT_IMPROVE 103 Int m_nAccuFrameBit; // base + enhancement layer 104 Int m_nAccuFrameCGSBit; 105 Int m_nPrevFrameCGSPartNumLog2; 106 #else 80 107 Int m_nPrevFrameBit[3][MAX_TLAYER]; // base + enhancement layer 81 108 Int m_nPrevFrameCGSBit[3][MAX_TLAYER]; 82 109 Int m_nPrevFrameCGSPartNumLog2[3][MAX_TLAYER]; 83 110 Int m_nPrevFrameOverWritePPS[3][MAX_TLAYER]; 111 #endif 84 112 Double m_dTotalFrameBit; 85 113 Int m_nTotalCGSBit; 86 114 Int m_nPPSBit; 87 115 Int m_nLUTBitDepth; 116 #if R0179_ENC_OPT_3DLUT_SIZE 117 118 Double m_dDistFactor[3][MAX_TLAYER]; 119 Int m_nNumLUTBits[MAX_Y_SIZE][MAX_C_SIZE]; 120 Int m_nPrevELFrameBit[3][MAX_TLAYER]; 121 122 123 Int m_nTotalLutSizes; 124 SLUTSize m_sLutSizes[MAX_NUM_LUT_SIZES]; 125 #endif 126 #if R0151_CGS_3D_ASYMLUT_IMPROVE 127 Double m_dSumU; 128 Double m_dSumV; 129 Int m_nNChroma; 130 #endif 131 #if R0179_ENC_OPT_3DLUT_SIZE 132 TComOutputBitstream *m_pBitstreamRedirect; 133 TEncCavlc *m_pEncCavlc; 134 #endif 88 135 89 136 private: 137 #if R0151_CGS_3D_ASYMLUT_IMPROVE 138 Double xxDeriveVertexPerColor( Double N , Double Ys , Double Yy , Double Yu , Double Yv , Double ys , Double us , Double vs , Double yy , Double yu , Double yv , Double uu , Double uv , Double vv , Double YY , 139 Pel & rP0 , Pel & rP1 , Pel & rP3 , Pel & rP7 , Int nResQuantBit ); 140 #else 90 141 Double xxDeriveVertexPerColor( Double N , Double Ys , Double Yy , Double Yu , Double Yv , Double ys , Double us , Double vs , Double yy , Double yu , Double yv , Double uu , Double uv , Double vv , Double YY , 91 142 Int y0 , Int u0 , Int v0 , Int nLengthY , Int nLengthUV , 92 143 Pel & rP0 , Pel & rP1 , Pel & rP3 , Pel & rP7 , Int nResQuantBit ); 144 #endif 93 145 Void xxDerivePartNumLog2( TComSlice * pSlice , TEncCfg * pcCfg , Int & rOctantDepth , Int & rYPartNumLog2 , Bool bSignalPPS , Bool bElRapSliceTypeB ); 94 146 Void xxMapPartNum2DepthYPart( Int nPartNumLog2 , Int & rOctantDepth , Int & rYPartNumLog2 ); 95 147 Int xxCoeff2Vertex( Double a , Double b , Double c , Double d , Int y , Int u , Int v ) { return ( ( Int )( a * y + b * u + c * v + d + 0.5 ) ); } 96 148 Void xxCollectData( TComPic * pCurPic , UInt refLayerIdc ); 149 97 150 Double xxDeriveVertexes( Int nResQuantBit , SCuboid *** pCurCuboid ); 98 151 inline Double xxCalEstDist( Double N , Double Ys , Double Yy , Double Yu , Double Yv , Double ys , Double us , Double vs , Double yy , Double yu , Double yv , Double uu , Double uv , Double vv , Double YY , … … 100 153 inline Double xxCalEstDist( Double N , Double Ys , Double Yy , Double Yu , Double Yv , Double ys , Double us , Double vs , Double yy , Double yu , Double yv , Double uu , Double uv , Double vv , Double YY , 101 154 Double a , Double b , Double c , Double d ); 155 #if R0151_CGS_3D_ASYMLUT_IMPROVE 156 inline Double xxCalEstDist( Double N , Double Ys , Double Yy , Double Yu , Double Yv , Double ys , Double us , Double vs , Double yy , Double yu , Double yv , Double uu , Double uv , Double vv , Double YY , 157 Pel nP0 , Pel nP1 , Pel nP3 , Pel nP7 ); 158 #endif 159 #if R0179_ENC_OPT_3DLUT_SIZE 160 Void xxConsolidateData( SLUTSize *pCurLUTSize, SLUTSize *pMaxLUTSize ); 161 Void xxGetAllLutSizes(TComSlice *pSlice); 162 Void xxCopyColorInfo( SColorInfo *** dst, SColorInfo *** src , SColorInfo *** dstC, SColorInfo *** srcC ); 163 Void xxAddColorInfo( Int yIdx, Int uIdx, Int vIdx, Int iYDiffLog2, Int iCDiffLog2 ); 164 #endif 102 165 }; 103 166 … … 118 181 return( dError ); 119 182 }; 120 #endif 121 122 #endif 183 184 #if R0151_CGS_3D_ASYMLUT_IMPROVE 185 Double TEnc3DAsymLUT::xxCalEstDist( Double N , Double Ys , Double Yy , Double Yu , Double Yv , Double ys , Double us , Double vs , Double yy , Double yu , Double yv , Double uu , Double uv , Double vv , Double YY , 186 Pel nP0 , Pel nP1 , Pel nP3 , Pel nP7 ) 187 { 188 const Int nOne = xGetNormCoeffOne(); 189 Double a = 1.0 * nP0 / nOne; 190 Double b = 1.0 * nP1 / nOne; 191 Double c = 1.0 * nP3 / nOne; 192 Double d = nP7; 193 Double dError = N * d * d + 2 * b * c * uv + 2 * a * c * yv + 2 * a * b * yu - 2 * c * Yv - 2 * b * Yu - 2 * a * Yy + 2 * c * d * vs + 2 * b * d * us + 2 * a * d * ys + a * a * yy + c * c * vv + b * b * uu - 2 * d * Ys + YY; 194 return( dError ); 195 }; 196 #endif 197 198 #endif 199 200 #endif -
trunk/source/Lib/TLibEncoder/TEncCavlc.cpp
r815 r906 193 193 if( pcPPS->getTilesEnabledFlag() ) 194 194 { 195 WRITE_UVLC( pcPPS->getNum ColumnsMinus1(), "num_tile_columns_minus1" );196 WRITE_UVLC( pcPPS->get NumRowsMinus1(), "num_tile_rows_minus1" );197 WRITE_FLAG( pcPPS->get UniformSpacingFlag(), "uniform_spacing_flag" );198 if( pcPPS->getUniformSpacingFlag() == 0)199 { 200 for(UInt i=0; i<pcPPS->getNum ColumnsMinus1(); i++)201 { 202 WRITE_UVLC( pcPPS->get ColumnWidth(i)-1, "column_width_minus1" );203 } 204 for(UInt i=0; i<pcPPS->get NumRowsMinus1(); i++)205 { 206 WRITE_UVLC( pcPPS->get RowHeight(i)-1, "row_height_minus1" );207 } 208 } 209 if(pcPPS->getNum ColumnsMinus1() !=0 || pcPPS->getNumRowsMinus1() !=0)195 WRITE_UVLC( pcPPS->getNumTileColumnsMinus1(), "num_tile_columns_minus1" ); 196 WRITE_UVLC( pcPPS->getTileNumRowsMinus1(), "num_tile_rows_minus1" ); 197 WRITE_FLAG( pcPPS->getTileUniformSpacingFlag(), "uniform_spacing_flag" ); 198 if( !pcPPS->getTileUniformSpacingFlag() ) 199 { 200 for(UInt i=0; i<pcPPS->getNumTileColumnsMinus1(); i++) 201 { 202 WRITE_UVLC( pcPPS->getTileColumnWidth(i)-1, "column_width_minus1" ); 203 } 204 for(UInt i=0; i<pcPPS->getTileNumRowsMinus1(); i++) 205 { 206 WRITE_UVLC( pcPPS->getTileRowHeight(i)-1, "row_height_minus1" ); 207 } 208 } 209 if(pcPPS->getNumTileColumnsMinus1() !=0 || pcPPS->getTileNumRowsMinus1() !=0) 210 210 { 211 211 WRITE_FLAG( pcPPS->getLoopFilterAcrossTilesEnabledFlag()?1 : 0, "loop_filter_across_tiles_enabled_flag"); … … 225 225 } 226 226 227 #if !R0042_PROFILE_INDICATION 227 228 #if SCALINGLIST_INFERRING 228 229 if( pcPPS->getLayerId() > 0 ) … … 241 242 { 242 243 #endif 244 #endif 243 245 244 246 WRITE_FLAG( pcPPS->getScalingListPresentFlag() ? 1 : 0, "pps_scaling_list_data_present_flag" ); … … 247 249 codeScalingList( m_pcSlice->getScalingList() ); 248 250 } 249 251 #if !R0042_PROFILE_INDICATION 250 252 #if SCALINGLIST_INFERRING 251 253 } 254 #endif 252 255 #endif 253 256 … … 256 259 WRITE_FLAG( pcPPS->getSliceHeaderExtensionPresentFlag() ? 1 : 0, "slice_segment_header_extension_present_flag"); 257 260 #if P0166_MODIFIED_PPS_EXTENSION 261 #if !R0042_PROFILE_INDICATION 258 262 WRITE_FLAG( pcPPS->getExtensionFlag() ? 1 : 0, "pps_extension_flag" ); 263 #else 264 WRITE_FLAG( pcPPS->getExtensionFlag() ? 1 : 0, "pps_extension_present_flag" ); 265 #endif 259 266 260 267 if( pcPPS->getExtensionFlag() ) 261 268 { 269 #if !R0042_PROFILE_INDICATION 262 270 #if !POC_RESET_IDC 263 271 UInt ppsExtensionTypeFlag[8] = { 0, 1, 0, 0, 0, 0, 0, 0 }; … … 273 281 { 274 282 WRITE_FLAG( pcPPS->getPocResetInfoPresentFlag() ? 1 : 0, "poc_reset_info_present_flag" ); 283 #if REF_REGION_OFFSET 284 WRITE_UVLC( pcPPS->getNumScaledRefLayerOffsets(), "num_scaled_ref_layer_offsets" ); 285 for(Int i = 0; i < pcPPS->getNumScaledRefLayerOffsets(); i++) 286 { 287 WRITE_CODE( pcPPS->getScaledRefLayerId(i), 6, "scaled_ref_layer_id" ); 288 WRITE_FLAG( pcPPS->getScaledRefLayerOffsetPresentFlag(i) ? 1 : 0, "scaled_ref_layer_offset_prsent_flag" ); 289 if (pcPPS->getScaledRefLayerOffsetPresentFlag(i)) 290 { 291 Window scaledWindow = pcPPS->getScaledRefLayerWindow(i); 292 WRITE_SVLC( scaledWindow.getWindowLeftOffset() >> 1, "scaled_ref_layer_left_offset" ); 293 WRITE_SVLC( scaledWindow.getWindowTopOffset() >> 1, "scaled_ref_layer_top_offset" ); 294 WRITE_SVLC( scaledWindow.getWindowRightOffset() >> 1, "scaled_ref_layer_right_offset" ); 295 WRITE_SVLC( scaledWindow.getWindowBottomOffset() >> 1, "scaled_ref_layer_bottom_offset" ); 296 } 297 WRITE_FLAG( pcPPS->getRefRegionOffsetPresentFlag(i) ? 1 : 0, "ref_region_offset_prsent_flag" ); 298 if (pcPPS->getRefRegionOffsetPresentFlag(i)) 299 { 300 Window refWindow = pcPPS->getRefLayerWindow(i); 301 WRITE_SVLC( refWindow.getWindowLeftOffset() >> 1, "ref_layer_left_offset" ); 302 WRITE_SVLC( refWindow.getWindowTopOffset() >> 1, "ref_layer_top_offset" ); 303 WRITE_SVLC( refWindow.getWindowRightOffset() >> 1, "ref_layer_right_offset" ); 304 WRITE_SVLC( refWindow.getWindowBottomOffset() >> 1, "ref_layer_bottom_offset" ); 305 } 306 #if R0209_GENERIC_PHASE 307 WRITE_FLAG( pcPPS->getResamplePhaseSetPresentFlag(i) ? 1 : 0, "resample_phase_set_present_flag" ); 308 if (pcPPS->getResamplePhaseSetPresentFlag(i)) 309 { 310 WRITE_UVLC( pcPPS->getPhaseHorLuma(i), "phase_hor_luma" ); 311 WRITE_UVLC( pcPPS->getPhaseVerLuma(i), "phase_ver_luma" ); 312 WRITE_UVLC( pcPPS->getPhaseHorChroma(i) + 8, "phase_hor_chroma_plus8" ); 313 WRITE_UVLC( pcPPS->getPhaseVerChroma(i) + 8, "phase_ver_chroma_plus8" ); 314 } 315 #endif 316 } 317 #else 318 #if MOVE_SCALED_OFFSET_TO_PPS 319 WRITE_UVLC( pcPPS->getNumScaledRefLayerOffsets(), "num_scaled_ref_layer_offsets" ); 320 for(Int i = 0; i < pcPPS->getNumScaledRefLayerOffsets(); i++) 321 { 322 Window scaledWindow = pcPPS->getScaledRefLayerWindow(i); 323 #if O0098_SCALED_REF_LAYER_ID 324 WRITE_CODE( pcPPS->getScaledRefLayerId(i), 6, "scaled_ref_layer_id" ); 325 #endif 326 WRITE_SVLC( scaledWindow.getWindowLeftOffset() >> 1, "scaled_ref_layer_left_offset" ); 327 WRITE_SVLC( scaledWindow.getWindowTopOffset() >> 1, "scaled_ref_layer_top_offset" ); 328 WRITE_SVLC( scaledWindow.getWindowRightOffset() >> 1, "scaled_ref_layer_right_offset" ); 329 WRITE_SVLC( scaledWindow.getWindowBottomOffset() >> 1, "scaled_ref_layer_bottom_offset" ); 330 } 331 #endif 332 #endif 275 333 #if Q0048_CGS_3D_ASYMLUT 276 334 UInt uiPos = getNumberOfWrittenBits(); … … 285 343 #endif 286 344 } 345 #else 346 WRITE_FLAG( 0, "pps_range_extension_flag" ); 347 WRITE_FLAG( 1, "pps_multilayer_extension_flag" ); 348 WRITE_CODE( 0, 6, "pps_extension_6bits" ); 349 350 WRITE_FLAG( pcPPS->getPocResetInfoPresentFlag() ? 1 : 0, "poc_reset_info_present_flag" ); 351 #if SCALINGLIST_INFERRING 352 WRITE_FLAG( pcPPS->getInferScalingListFlag() ? 1 : 0, "pps_infer_scaling_list_flag" ); 353 if( pcPPS->getInferScalingListFlag() ) 354 { 355 // The value of pps_scaling_list_ref_layer_id shall be in the range of 0 to 62, inclusive 356 assert( pcPPS->getScalingListRefLayerId() <= 62 ); 357 WRITE_UVLC( pcPPS->getScalingListRefLayerId(), "pps_scaling_list_ref_layer_id" ); 358 } 359 #endif 360 361 #if REF_REGION_OFFSET 362 WRITE_UVLC( pcPPS->getNumScaledRefLayerOffsets(), "num_ref_loc_offsets" ); 363 for(Int i = 0; i < pcPPS->getNumScaledRefLayerOffsets(); i++) 364 { 365 WRITE_CODE( pcPPS->getScaledRefLayerId(i), 6, "ref_loc_offset_layer_id" ); 366 WRITE_FLAG( pcPPS->getScaledRefLayerOffsetPresentFlag(i) ? 1 : 0, "scaled_ref_layer_offset_prsent_flag" ); 367 if (pcPPS->getScaledRefLayerOffsetPresentFlag(i)) 368 { 369 Window scaledWindow = pcPPS->getScaledRefLayerWindow(i); 370 WRITE_SVLC( scaledWindow.getWindowLeftOffset() >> 1, "scaled_ref_layer_left_offset" ); 371 WRITE_SVLC( scaledWindow.getWindowTopOffset() >> 1, "scaled_ref_layer_top_offset" ); 372 WRITE_SVLC( scaledWindow.getWindowRightOffset() >> 1, "scaled_ref_layer_right_offset" ); 373 WRITE_SVLC( scaledWindow.getWindowBottomOffset() >> 1, "scaled_ref_layer_bottom_offset" ); 374 } 375 WRITE_FLAG( pcPPS->getRefRegionOffsetPresentFlag(i) ? 1 : 0, "ref_region_offset_prsent_flag" ); 376 if (pcPPS->getRefRegionOffsetPresentFlag(i)) 377 { 378 Window refWindow = pcPPS->getRefLayerWindow(i); 379 WRITE_SVLC( refWindow.getWindowLeftOffset() >> 1, "ref_region_left_offset" ); 380 WRITE_SVLC( refWindow.getWindowTopOffset() >> 1, "ref_region_top_offset" ); 381 WRITE_SVLC( refWindow.getWindowRightOffset() >> 1, "ref_region_right_offset" ); 382 WRITE_SVLC( refWindow.getWindowBottomOffset() >> 1, "ref_region_bottom_offset" ); 383 } 384 #if R0209_GENERIC_PHASE 385 WRITE_FLAG( pcPPS->getResamplePhaseSetPresentFlag(i) ? 1 : 0, "resample_phase_set_present_flag" ); 386 if (pcPPS->getResamplePhaseSetPresentFlag(i)) 387 { 388 WRITE_UVLC( pcPPS->getPhaseHorLuma(i), "phase_hor_luma" ); 389 WRITE_UVLC( pcPPS->getPhaseVerLuma(i), "phase_ver_luma" ); 390 WRITE_UVLC( pcPPS->getPhaseHorChroma(i) + 8, "phase_hor_chroma_plus8" ); 391 WRITE_UVLC( pcPPS->getPhaseVerChroma(i) + 8, "phase_ver_chroma_plus8" ); 392 } 393 #endif 394 } 395 #else 396 #if MOVE_SCALED_OFFSET_TO_PPS 397 WRITE_UVLC( pcPPS->getNumScaledRefLayerOffsets(), "num_scaled_ref_layer_offsets" ); 398 for(Int i = 0; i < pcPPS->getNumScaledRefLayerOffsets(); i++) 399 { 400 Window scaledWindow = pcPPS->getScaledRefLayerWindow(i); 401 #if O0098_SCALED_REF_LAYER_ID 402 WRITE_CODE( pcPPS->getScaledRefLayerId(i), 6, "scaled_ref_layer_id" ); 403 #endif 404 WRITE_SVLC( scaledWindow.getWindowLeftOffset() >> 1, "scaled_ref_layer_left_offset" ); 405 WRITE_SVLC( scaledWindow.getWindowTopOffset() >> 1, "scaled_ref_layer_top_offset" ); 406 WRITE_SVLC( scaledWindow.getWindowRightOffset() >> 1, "scaled_ref_layer_right_offset" ); 407 WRITE_SVLC( scaledWindow.getWindowBottomOffset() >> 1, "scaled_ref_layer_bottom_offset" ); 408 } 409 #endif 410 #endif 411 #if Q0048_CGS_3D_ASYMLUT 412 UInt uiPos = getNumberOfWrittenBits(); 413 WRITE_FLAG( pcPPS->getCGSFlag() , "colour_mapping_enabled_flag" ); 414 if( pcPPS->getCGSFlag() ) 415 { 416 assert( pc3DAsymLUT != NULL ); 417 xCode3DAsymLUT( pc3DAsymLUT ); 418 } 419 pc3DAsymLUT->setPPSBit( getNumberOfWrittenBits() - uiPos ); 420 #endif 421 #endif 287 422 } 288 423 #else … … 340 475 if( defaultDisplayWindow.getWindowEnabledFlag() ) 341 476 { 342 WRITE_UVLC(defaultDisplayWindow.getWindowLeftOffset() ,"def_disp_win_left_offset");343 WRITE_UVLC(defaultDisplayWindow.getWindowRightOffset() ,"def_disp_win_right_offset");344 WRITE_UVLC(defaultDisplayWindow.getWindowTopOffset() ,"def_disp_win_top_offset");345 WRITE_UVLC(defaultDisplayWindow.getWindowBottomOffset() ,"def_disp_win_bottom_offset");477 WRITE_UVLC(defaultDisplayWindow.getWindowLeftOffset() / TComSPS::getWinUnitX(pcSPS->getChromaFormatIdc()), "def_disp_win_left_offset"); 478 WRITE_UVLC(defaultDisplayWindow.getWindowRightOffset() / TComSPS::getWinUnitX(pcSPS->getChromaFormatIdc()), "def_disp_win_right_offset"); 479 WRITE_UVLC(defaultDisplayWindow.getWindowTopOffset() / TComSPS::getWinUnitY(pcSPS->getChromaFormatIdc()), "def_disp_win_top_offset"); 480 WRITE_UVLC(defaultDisplayWindow.getWindowBottomOffset()/ TComSPS::getWinUnitY(pcSPS->getChromaFormatIdc()), "def_disp_win_bottom_offset"); 346 481 } 347 482 TimingInfo *timingInfo = pcVUI->getTimingInfo(); … … 452 587 Void TEncCavlc::codeSPS( TComSPS* pcSPS ) 453 588 { 589 #if R0042_PROFILE_INDICATION 590 Bool bMultiLayerExtSpsFlag = (pcSPS->getNumDirectRefLayers() != 0 ) ; 591 #endif 454 592 #if ENC_DEC_TRACE 455 593 xTraceSPSHeader (pcSPS); … … 461 599 #endif 462 600 WRITE_CODE( pcSPS->getMaxTLayers() - 1, 3, "sps_max_sub_layers_minus1" ); 601 #if SVC_EXTENSION 602 } 603 #if R0042_PROFILE_INDICATION 604 else 605 { 606 WRITE_CODE(bMultiLayerExtSpsFlag? 7:(pcSPS->getMaxTLayers() - 1) , 3, "sps_ext_or_max_sub_layers_minus1" ); 607 } 608 #endif 609 #endif 610 611 #if SVC_EXTENSION 612 #if !R0042_PROFILE_INDICATION 613 if(pcSPS->getLayerId() == 0) 614 #else 615 if(!bMultiLayerExtSpsFlag) 616 #endif 617 { 618 #endif 463 619 WRITE_FLAG( pcSPS->getTemporalIdNestingFlag() ? 1 : 0, "sps_temporal_id_nesting_flag" ); 464 620 #if SVC_EXTENSION … … 466 622 #endif 467 623 #ifdef SPS_PTL_FIX 624 #if !R0042_PROFILE_INDICATION 468 625 if (pcSPS->getLayerId() == 0) 626 #else 627 if(!bMultiLayerExtSpsFlag) 628 #endif 469 629 { 470 630 codePTL(pcSPS->getPTL(), 1, pcSPS->getMaxTLayers() - 1); … … 475 635 WRITE_UVLC( pcSPS->getSPSId (), "sps_seq_parameter_set_id" ); 476 636 #if REPN_FORMAT_IN_VPS 637 #if !R0042_PROFILE_INDICATION 477 638 if( pcSPS->getLayerId() > 0 ) 639 #else 640 if(bMultiLayerExtSpsFlag) 641 #endif 478 642 { 479 643 WRITE_FLAG( pcSPS->getUpdateRepFormatFlag(), "update_rep_format_flag" ); 480 644 } 645 #if R0042_PROFILE_INDICATION 646 if( bMultiLayerExtSpsFlag && pcSPS->getUpdateRepFormatFlag()) 647 { 648 WRITE_CODE( pcSPS->getUpdateRepFormatIndex(), 8, "sps_rep_format_idx"); 649 } 650 #endif 651 652 #if R0042_PROFILE_INDICATION 653 if(!bMultiLayerExtSpsFlag) 654 { 655 #endif 656 #if !R0042_PROFILE_INDICATION 481 657 #if O0096_REP_FORMAT_INDEX 482 658 if( pcSPS->getLayerId() == 0 ) 483 659 #else 484 660 if( pcSPS->getLayerId() == 0 || pcSPS->getUpdateRepFormatFlag() ) 661 #endif 485 662 #endif 486 663 { … … 498 675 #if REPN_FORMAT_IN_VPS 499 676 } 677 #if !R0042_PROFILE_INDICATION 500 678 #if O0096_REP_FORMAT_INDEX 501 679 else if (pcSPS->getUpdateRepFormatFlag()) … … 505 683 #endif 506 684 #endif 507 Window conf = pcSPS->getConformanceWindow(); 508 509 WRITE_FLAG( conf.getWindowEnabledFlag(), "conformance_window_flag" ); 510 if (conf.getWindowEnabledFlag()) 511 { 685 #endif 686 687 #if R0156_CONF_WINDOW_IN_REP_FORMAT 512 688 #if REPN_FORMAT_IN_VPS 513 WRITE_UVLC( conf.getWindowLeftOffset(), "conf_win_left_offset" ); 514 WRITE_UVLC( conf.getWindowRightOffset(), "conf_win_right_offset" ); 515 WRITE_UVLC( conf.getWindowTopOffset(), "conf_win_top_offset" ); 516 WRITE_UVLC( conf.getWindowBottomOffset(), "conf_win_bottom_offset" ); 517 #else 518 WRITE_UVLC( conf.getWindowLeftOffset() / TComSPS::getWinUnitX(pcSPS->getChromaFormatIdc() ), "conf_win_left_offset" ); 519 WRITE_UVLC( conf.getWindowRightOffset() / TComSPS::getWinUnitX(pcSPS->getChromaFormatIdc() ), "conf_win_right_offset" ); 520 WRITE_UVLC( conf.getWindowTopOffset() / TComSPS::getWinUnitY(pcSPS->getChromaFormatIdc() ), "conf_win_top_offset" ); 521 WRITE_UVLC( conf.getWindowBottomOffset() / TComSPS::getWinUnitY(pcSPS->getChromaFormatIdc() ), "conf_win_bottom_offset" ); 522 #endif 523 } 524 525 #if REPN_FORMAT_IN_VPS 689 #if !R0042_PROFILE_INDICATION 526 690 #if O0096_REP_FORMAT_INDEX 527 691 if( pcSPS->getLayerId() == 0 ) … … 529 693 if( pcSPS->getLayerId() == 0 || pcSPS->getUpdateRepFormatFlag() ) 530 694 #endif 695 #endif 696 { 697 #endif 698 #endif 699 Window conf = pcSPS->getConformanceWindow(); 700 701 WRITE_FLAG( conf.getWindowEnabledFlag(), "conformance_window_flag" ); 702 if (conf.getWindowEnabledFlag()) 703 { 704 #if REPN_FORMAT_IN_VPS 705 WRITE_UVLC( conf.getWindowLeftOffset(), "conf_win_left_offset" ); 706 WRITE_UVLC( conf.getWindowRightOffset(), "conf_win_right_offset" ); 707 WRITE_UVLC( conf.getWindowTopOffset(), "conf_win_top_offset" ); 708 WRITE_UVLC( conf.getWindowBottomOffset(), "conf_win_bottom_offset" ); 709 #else 710 WRITE_UVLC( conf.getWindowLeftOffset() / TComSPS::getWinUnitX(pcSPS->getChromaFormatIdc() ), "conf_win_left_offset" ); 711 WRITE_UVLC( conf.getWindowRightOffset() / TComSPS::getWinUnitX(pcSPS->getChromaFormatIdc() ), "conf_win_right_offset" ); 712 WRITE_UVLC( conf.getWindowTopOffset() / TComSPS::getWinUnitY(pcSPS->getChromaFormatIdc() ), "conf_win_top_offset" ); 713 WRITE_UVLC( conf.getWindowBottomOffset() / TComSPS::getWinUnitY(pcSPS->getChromaFormatIdc() ), "conf_win_bottom_offset" ); 714 #endif 715 } 716 #if R0156_CONF_WINDOW_IN_REP_FORMAT 717 #if REPN_FORMAT_IN_VPS 718 } 719 #endif 720 #endif 721 722 #if REPN_FORMAT_IN_VPS 723 #if !R0042_PROFILE_INDICATION 724 #if O0096_REP_FORMAT_INDEX 725 if( pcSPS->getLayerId() == 0 ) 726 #else 727 if( pcSPS->getLayerId() == 0 || pcSPS->getUpdateRepFormatFlag() ) 728 #endif 729 #endif 531 730 { 532 731 assert( pcSPS->getBitDepthY() >= 8 ); … … 538 737 } 539 738 #endif 739 #if R0042_PROFILE_INDICATION 740 } 741 #endif 742 540 743 WRITE_UVLC( pcSPS->getBitsForPOC()-4, "log2_max_pic_order_cnt_lsb_minus4" ); 541 744 542 745 #if SPS_DPB_PARAMS 746 #if !R0042_PROFILE_INDICATION 543 747 if( pcSPS->getLayerId() == 0 ) 748 #else 749 if(!bMultiLayerExtSpsFlag) 750 #endif 544 751 { 545 752 #endif … … 571 778 { 572 779 #if SCALINGLIST_INFERRING 780 #if !R0042_PROFILE_INDICATION 573 781 if( pcSPS->getLayerId() > 0 ) 782 #else 783 if( bMultiLayerExtSpsFlag) 784 #endif 574 785 { 575 786 WRITE_FLAG( pcSPS->getInferScalingListFlag() ? 1 : 0, "sps_infer_scaling_list_flag" ); … … 640 851 641 852 #if SVC_EXTENSION 853 #if !R0042_PROFILE_INDICATION 642 854 WRITE_FLAG( pcSPS->getExtensionFlag() ? 1 : 0, "sps_extension_flag" ); 855 #else 856 WRITE_FLAG( pcSPS->getExtensionFlag() ? 1 : 0, "sps_extension_present_flag" ); 857 #endif 643 858 644 859 if( pcSPS->getExtensionFlag() ) 645 860 { 861 #if !R0042_PROFILE_INDICATION 646 862 #if O0142_CONDITIONAL_SPS_EXTENSION 647 863 UInt spsExtensionTypeFlag[8] = { 0, 1, 0, 0, 0, 0, 0, 0 }; … … 658 874 WRITE_FLAG( 0, "sps_extension2_flag" ); 659 875 #endif 876 #else 877 WRITE_FLAG( 0, "sps_range_extension_flag" ); 878 WRITE_FLAG( 1, "sps_multilayer_extension_flag" ); 879 WRITE_CODE( 0, 6, "sps_extension_6bits" ); 880 codeSPSExtension( pcSPS ); //it is sps_multilayer_extension 881 #endif 660 882 } 661 883 #else … … 672 894 WRITE_FLAG( 0, "inter_view_mv_vert_constraint_flag" ); 673 895 896 #if !MOVE_SCALED_OFFSET_TO_PPS 674 897 if( pcSPS->getLayerId() > 0 ) 675 898 { … … 690 913 } 691 914 } 915 #endif 692 916 } 693 917 #endif //SVC_EXTENSION … … 706 930 #endif 707 931 WRITE_CODE( pcVPS->getVPSId(), 4, "vps_video_parameter_set_id" ); 932 #if VPS_RESERVED_FLAGS 933 WRITE_FLAG( pcVPS->getBaseLayerInternalFlag(), "vps_base_layer_internal_flag"); 934 WRITE_FLAG( pcVPS->getBaseLayerAvailableFlag(), "vps_base_layer_available_flag"); 935 #else 708 936 WRITE_CODE( 3, 2, "vps_reserved_three_2bits" ); 937 #endif 709 938 #if SVC_EXTENSION 710 939 WRITE_CODE( pcVPS->getMaxLayers() - 1, 6, "vps_max_layers_minus1" ); … … 774 1003 } 775 1004 } 1005 #if !NECESSARY_FLAG // Already called once in TAppEncTop.cpp 776 1006 #if DERIVE_LAYER_ID_LIST_VARIABLES 777 1007 pcVPS->deriveLayerIdListVariables(); 1008 #endif 778 1009 #endif 779 1010 TimingInfo *timingInfo = pcVPS->getTimingInfo(); … … 848 1079 Int OlsHighestOutputLayerId[MAX_VPS_LAYER_SETS_PLUS1]; 849 1080 #endif 1081 #if LIST_OF_PTL 1082 if( vps->getMaxLayers() > 1 && vps->getBaseLayerInternalFlag() ) 1083 { 1084 codePTL( vps->getPTLForExtn(1), false, vps->getMaxTLayers() - 1 ); 1085 } 1086 #endif 850 1087 #if VPS_EXTN_MASK_AND_DIM_INFO 851 1088 UInt i = 0, j = 0; 852 1089 #if !VPS_AVC_BL_FLAG_REMOVAL 853 1090 WRITE_FLAG( vps->getAvcBaseLayerFlag(), "avc_base_layer_flag" ); 1091 #endif 854 1092 #if !P0307_REMOVE_VPS_VUI_OFFSET 855 1093 #if O0109_MOVE_VPS_VUI_FLAG … … 948 1186 } 949 1187 } 1188 #endif 1189 #if MOVE_ADDN_LS_SIGNALLING 1190 #if Q0078_ADD_LAYER_SETS 1191 if (vps->getNumIndependentLayers() > 1) 1192 { 1193 WRITE_UVLC( vps->getNumAddLayerSets(), "num_add_layer_sets" ); 1194 for (i = 0; i < vps->getNumAddLayerSets(); i++) 1195 { 1196 for (j = 1; j < vps->getNumIndependentLayers(); j++) 1197 { 1198 int len = 1; 1199 while ((1 << len) < (vps->getNumLayersInTreePartition(j) + 1)) 1200 { 1201 len++; 1202 } 1203 WRITE_CODE(vps->getHighestLayerIdxPlus1(i, j), len, "highest_layer_idx_plus1[i][j]"); 1204 } 1205 } 1206 } 1207 #endif 950 1208 #endif 951 1209 #if VPS_TSLAYERS … … 985 1243 #else 986 1244 WRITE_UVLC( vps->getNumProfileTierLevel() - 1, "vps_num_profile_tier_level_minus1"); 987 #endif 1245 #if PER_LAYER_PTL 1246 Int const numBitsForPtlIdx = vps->calculateLenOfSyntaxElement( vps->getNumProfileTierLevel() ); 1247 #endif 1248 #endif 1249 #if LIST_OF_PTL 1250 assert( vps->getNumProfileTierLevel() == vps->getPTLForExtnPtr()->size()); 1251 for(Int idx = vps->getBaseLayerInternalFlag() ? 2 : 1; idx <= vps->getNumProfileTierLevel() - 1; idx++) 1252 #else 988 1253 for(Int idx = 1; idx <= vps->getNumProfileTierLevel() - 1; idx++) 1254 #endif 989 1255 { 990 1256 WRITE_FLAG( vps->getProfilePresentFlag(idx), "vps_profile_present_flag[i]" ); … … 999 1265 #endif 1000 1266 1267 1268 #if !MOVE_ADDN_LS_SIGNALLING 1001 1269 #if Q0078_ADD_LAYER_SETS 1002 1270 if (vps->getNumIndependentLayers() > 1) … … 1016 1284 } 1017 1285 } 1286 #endif 1018 1287 #endif 1019 1288 … … 1060 1329 for(i = 1; i < numOutputLayerSets; i++) 1061 1330 { 1331 Int layerSetIdxForOutputLayerSet = vps->getOutputLayerSetIdx(i); 1062 1332 if( i > (vps->getNumLayerSets() - 1) ) 1063 1333 { … … 1077 1347 { 1078 1348 #endif 1079 Int lsIdx = vps->getOutputLayerSetIdx(i);1080 1349 #if NUM_OL_FLAGS 1081 for(j = 0; j < vps->getNumLayersInIdList(l sIdx) ; j++)1350 for(j = 0; j < vps->getNumLayersInIdList(layerSetIdxForOutputLayerSet) ; j++) 1082 1351 #else 1083 1352 for(j = 0; j < vps->getNumLayersInIdList(lsIdx) - 1; j++) … … 1087 1356 } 1088 1357 } 1358 #if PER_LAYER_PTL 1359 for(j = 0; j < vps->getNumLayersInIdList(layerSetIdxForOutputLayerSet) ; j++) 1360 { 1361 if( vps->getNecessaryLayerFlag(i, j) ) 1362 { 1363 WRITE_CODE( vps->getProfileLevelTierIdx(i, j), numBitsForPtlIdx, "profile_level_tier_idx[i]" ); 1364 } 1365 } 1366 #else 1089 1367 Int numBits = 1; 1090 1368 while ((1 << numBits) < (vps->getNumProfileTierLevel())) … … 1093 1371 } 1094 1372 WRITE_CODE( vps->getProfileLevelTierIdx(i), numBits, "profile_level_tier_idx[i]" ); 1373 #endif 1095 1374 #if P0300_ALT_OUTPUT_LAYER_FLAG 1096 1375 NumOutputLayersInOutputLayerSet[i] = 0; 1097 Int layerSetIdxForOutputLayerSet = vps->getOutputLayerSetIdx(i);1098 1376 for (j = 0; j < vps->getNumLayersInIdList(layerSetIdxForOutputLayerSet); j++) 1099 1377 { … … 1211 1489 1212 1490 WRITE_FLAG(vps->getMaxOneActiveRefLayerFlag(), "max_one_active_ref_layer_flag"); 1491 #if P0297_VPS_POC_LSB_ALIGNED_FLAG 1492 WRITE_FLAG(vps->getVpsPocLsbAlignedFlag(), "vps_poc_lsb_aligned_flag"); 1493 #endif 1213 1494 #if O0062_POC_LSB_NOT_PRESENT_FLAG 1214 1495 for(i = 1; i< vps->getMaxLayers(); i++) … … 1367 1648 WRITE_CODE( repFormat->getBitDepthVpsChroma() - 8, 4, "bit_depth_chroma_minus8" ); 1368 1649 #endif 1650 1651 #if R0156_CONF_WINDOW_IN_REP_FORMAT 1652 Window conf = repFormat->getConformanceWindowVps(); 1653 1654 WRITE_FLAG( conf.getWindowEnabledFlag(), "conformance_window_vps_flag" ); 1655 if (conf.getWindowEnabledFlag()) 1656 { 1657 WRITE_UVLC( conf.getWindowLeftOffset(), "conf_win_vps_left_offset" ); 1658 WRITE_UVLC( conf.getWindowRightOffset(), "conf_win_vps_right_offset" ); 1659 WRITE_UVLC( conf.getWindowTopOffset(), "conf_win_vps_top_offset" ); 1660 WRITE_UVLC( conf.getWindowBottomOffset(), "conf_win_vps_bottom_offset" ); 1661 } 1662 #endif 1369 1663 } 1370 1664 #endif … … 1372 1666 Void TEncCavlc::codeVpsDpbSizeTable(TComVPS *vps) 1373 1667 { 1668 #if !SUB_LAYERS_IN_LAYER_SET // MaxSLInLayerSets calculated earlier in the encoder 1374 1669 #if DPB_PARAMS_MAXTLAYERS 1375 1670 #if BITRATE_PICRATE_SIGNALLING … … 1400 1695 } 1401 1696 #endif 1697 #endif 1402 1698 1403 1699 … … 1408 1704 #endif 1409 1705 WRITE_FLAG( vps->getSubLayerFlagInfoPresentFlag( i ), "sub_layer_flag_info_present_flag[i]"); 1706 #if SUB_LAYERS_IN_LAYER_SET 1707 for(Int j = 0; j <= vps->getMaxSLayersInLayerSetMinus1( layerSetIdxForOutputLayerSet ); j++) 1708 #else 1410 1709 #if DPB_PARAMS_MAXTLAYERS 1411 1710 #if BITRATE_PICRATE_SIGNALLING … … 1417 1716 for(Int j = 0; j < vps->getMaxTLayers(); j++) 1418 1717 #endif 1718 #endif 1419 1719 { 1420 1720 if( j > 0 && vps->getSubLayerFlagInfoPresentFlag(i) ) … … 1434 1734 #endif 1435 1735 { 1436 WRITE_UVLC( vps->getMaxVpsDecPicBufferingMinus1( i, k, j), "max_vps_dec_pic_buffering_minus1[i][k][j]" ); 1736 #if DPB_INTERNAL_BL_SIG 1737 if(vps->getBaseLayerInternalFlag() || ( vps->getLayerSetLayerIdList(layerSetIdxForOutputLayerSet, k) != 0 ) ) 1738 #endif 1739 WRITE_UVLC( vps->getMaxVpsDecPicBufferingMinus1( i, k, j), "max_vps_dec_pic_buffering_minus1[i][k][j]" ); 1437 1740 } 1438 1741 WRITE_UVLC( vps->getMaxVpsNumReorderPics( i, j), "max_vps_num_reorder_pics[i][j]" ); … … 1450 1753 } 1451 1754 } 1755 1756 #if !SUB_LAYERS_IN_LAYER_SET 1757 #if BITRATE_PICRATE_SIGNALLING 1758 if( MaxSubLayersInLayerSetMinus1 ) 1759 { 1760 delete [] MaxSubLayersInLayerSetMinus1; 1761 } 1762 #endif 1763 #endif 1452 1764 } 1453 1765 #endif … … 1479 1791 { 1480 1792 #if Q0078_ADD_LAYER_SETS 1793 #if R0227_BR_PR_ADD_LAYER_SET 1794 #if SIGNALLING_BITRATE_PICRATE_FIX 1795 for( i = vps->getBaseLayerInternalFlag() ? 0 : 1; i < vps->getNumLayerSets(); i++ ) 1796 #else 1797 for( i = 0; i < vps->getNumLayerSets(); i++ ) 1798 #endif 1799 #else 1481 1800 for( i = 0; i <= vps->getVpsNumLayerSetsMinus1(); i++ ) 1801 #endif 1482 1802 #else 1483 1803 for( i = 0; i < vps->getNumLayerSets(); i++ ) … … 1529 1849 if (vps->getVideoSigPresentVpsFlag() && vps->getNumVideoSignalInfo() > 1 ) 1530 1850 { 1851 #if VPS_VUI_VST_PARAMS 1852 for(i = vps->getBaseLayerInternalFlag() ? 0 : 1; i < vps->getMaxLayers(); i++) 1853 { 1854 WRITE_CODE( vps->getVideoSignalInfoIdx(i), 4, "vps_video_signal_info_idx" ); 1855 } 1856 #else 1531 1857 for (i=1; i < vps->getMaxLayers(); i++) 1532 1858 WRITE_CODE(vps->getVideoSignalInfoIdx(i), 4, "vps_video_signal_info_idx" ); 1859 #endif 1533 1860 } 1534 1861 #endif … … 1645 1972 if (vps->getVpsVuiBspHrdPresentFlag()) 1646 1973 { 1974 #if VPS_VUI_BSP_HRD_PARAMS 1975 codeVpsVuiBspHrdParams(vps); 1976 #else 1647 1977 WRITE_UVLC( vps->getVpsNumBspHrdParametersMinus1(), "vps_num_bsp_hrd_parameters_minus1" ); 1648 1978 for( i = 0; i <= vps->getVpsNumBspHrdParametersMinus1(); i++ ) … … 1688 2018 } 1689 2019 } 2020 #endif 1690 2021 } 1691 2022 #endif … … 1786 2117 } 1787 2118 #else 2119 #if CROSS_LAYER_BLA_FLAG_FIX 2120 Int iBits = 0; 2121 if(pcSlice->getPPS()->getNumExtraSliceHeaderBits() > iBits) 2122 #else 1788 2123 if (pcSlice->getPPS()->getNumExtraSliceHeaderBits()>0) 2124 #endif 1789 2125 { 1790 2126 assert(!!"discardable_flag"); 2127 #if NON_REF_NAL_TYPE_DISCARDABLE 2128 if (pcSlice->getDiscardableFlag()) 2129 { 2130 assert(pcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_TRAIL_R && 2131 pcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_TSA_R && 2132 pcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_STSA_R && 2133 pcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_RADL_R && 2134 pcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_RASL_R); 2135 } 2136 #endif 1791 2137 WRITE_FLAG(pcSlice->getDiscardableFlag(), "discardable_flag"); 1792 } 2138 #if CROSS_LAYER_BLA_FLAG_FIX 2139 iBits++; 2140 #endif 2141 } 2142 #if CROSS_LAYER_BLA_FLAG_FIX 2143 if( pcSlice->getPPS()->getNumExtraSliceHeaderBits() > iBits ) 2144 { 2145 assert(!!"cross_layer_bla_flag"); 2146 WRITE_FLAG(pcSlice->getCrossLayerBLAFlag(), "cross_layer_bla_flag"); 2147 iBits++; 2148 } 2149 for (; iBits < pcSlice->getPPS()->getNumExtraSliceHeaderBits(); iBits++) 2150 #else 1793 2151 for (Int i = 1; i < pcSlice->getPPS()->getNumExtraSliceHeaderBits(); i++) 2152 #endif 1794 2153 { 1795 2154 assert(!!"slice_reserved_undetermined_flag[]"); … … 1978 2337 if (pcSlice->getSPS()->getTMVPFlagsPresent()) 1979 2338 { 2339 #if R0226_SLICE_TMVP 2340 WRITE_FLAG( pcSlice->getEnableTMVPFlag() ? 1 : 0, "slice_temporal_mvp_enabled_flag" ); 2341 #else 1980 2342 WRITE_FLAG( pcSlice->getEnableTMVPFlag() ? 1 : 0, "slice_temporal_mvp_enable_flag" ); 2343 #endif 1981 2344 } 1982 2345 #if N0065_LAYER_POC_ALIGNMENT && !SHM_FIX7 … … 2262 2625 } 2263 2626 UInt numEntryPointOffsets = 0, offsetLenMinus1 = 0, maxOffset = 0; 2627 #if !WPP_FIX 2264 2628 Int numZeroSubstreamsAtStartOfSlice = 0; 2629 #endif 2265 2630 UInt *entryPointOffset = NULL; 2266 2631 if ( pSlice->getPPS()->getTilesEnabledFlag() ) … … 2289 2654 UInt* pSubstreamSizes = pSlice->getSubstreamSizes(); 2290 2655 Int maxNumParts = pSlice->getPic()->getNumPartInCU(); 2656 #if WPP_FIX 2657 Int numZeroSubstreamsAtStartOfSlice = pSlice->getPic()->getSubstreamForLCUAddr(pSlice->getSliceSegmentCurStartCUAddr()/maxNumParts, false, pSlice); 2658 Int subStreamOfLastSegmentOfSlice = pSlice->getPic()->getSubstreamForLCUAddr((pSlice->getSliceSegmentCurEndCUAddr()/maxNumParts)-1, false, pSlice); 2659 numEntryPointOffsets = subStreamOfLastSegmentOfSlice-numZeroSubstreamsAtStartOfSlice; 2660 #else 2291 2661 numZeroSubstreamsAtStartOfSlice = pSlice->getSliceSegmentCurStartCUAddr()/maxNumParts/pSlice->getPic()->getFrameWidthInCU(); 2292 2662 Int numZeroSubstreamsAtEndOfSlice = pSlice->getPic()->getFrameHeightInCU()-1 - ((pSlice->getSliceSegmentCurEndCUAddr()-1)/maxNumParts/pSlice->getPic()->getFrameWidthInCU()); 2293 2663 numEntryPointOffsets = pSlice->getPPS()->getNumSubstreams() - numZeroSubstreamsAtStartOfSlice - numZeroSubstreamsAtEndOfSlice - 1; 2664 #endif 2294 2665 pSlice->setNumEntryPointOffsets(numEntryPointOffsets); 2295 2666 entryPointOffset = new UInt[numEntryPointOffsets]; … … 2333 2704 { 2334 2705 // Derive the value of PocMsbValRequiredFlag 2335 slice->setPocMsbValRequiredFlag( slice->getCraPicFlag() || slice->getBlaPicFlag() 2336 /* || related to vps_poc_lsb_aligned_flag */ 2337 ); 2706 #if P0297_VPS_POC_LSB_ALIGNED_FLAG 2707 slice->setPocMsbValRequiredFlag( (slice->getCraPicFlag() || slice->getBlaPicFlag()) 2708 && (!slice->getVPS()->getVpsPocLsbAlignedFlag() || 2709 (slice->getVPS()->getVpsPocLsbAlignedFlag() && slice->getVPS()->getNumDirectRefLayers(slice->getLayerId()) == 0)) 2710 ); 2711 #else 2712 slice->setPocMsbValRequiredFlag( slice->getCraPicFlag() || slice->getBlaPicFlag() ); 2713 #endif 2338 2714 2339 2715 // Determine value of SH extension length. … … 2353 2729 2354 2730 2355 if( !slice->getPocMsbValRequiredFlag() /* && vps_poc_lsb_aligned_flag */ ) 2731 #if P0297_VPS_POC_LSB_ALIGNED_FLAG 2732 if (!slice->getPocMsbValRequiredFlag() && slice->getVPS()->getVpsPocLsbAlignedFlag()) 2733 #else 2734 if (!slice->getPocMsbValRequiredFlag() /* && vps_poc_lsb_aligned_flag */) 2735 #endif 2356 2736 { 2357 2737 shExtnLengthInBit++; … … 2369 2749 } 2370 2750 2371 if( slice->getPocMsbValPresentFlag() ) 2751 #if P0297_VPS_POC_LSB_ALIGNED_FLAG 2752 if (slice->getPocMsbNeeded()) 2753 { 2754 slice->setPocMsbValPresentFlag(true); 2755 } 2756 #endif 2757 2758 if (slice->getPocMsbValPresentFlag()) 2372 2759 { 2373 2760 UInt lengthVal = 1; … … 2403 2790 } 2404 2791 2405 if( !slice->getPocMsbValRequiredFlag() /* && vps_poc_lsb_aligned_flag */ ) 2406 { 2792 #if P0297_VPS_POC_LSB_ALIGNED_FLAG 2793 if (!slice->getPocMsbValRequiredFlag() && slice->getVPS()->getVpsPocLsbAlignedFlag()) 2794 #else 2795 if (!slice->getPocMsbValRequiredFlag() /* && vps_poc_lsb_aligned_flag */) 2796 #endif 2797 { 2798 #if P0297_VPS_POC_LSB_ALIGNED_FLAG 2799 WRITE_FLAG( slice->getPocMsbValPresentFlag(), "poc_msb_cycle_val_present_flag" ); 2800 #else 2407 2801 WRITE_FLAG( slice->getPocMsbValPresentFlag(), "poc_msb_val_present_flag" ); 2408 } 2409 if( slice->getPocMsbValPresentFlag() ) 2410 { 2411 assert( slice->getPocMsbVal() % maxPocLsb == 0 ); 2412 WRITE_UVLC( slice->getPocMsbVal() / maxPocLsb, "poc_msb_val" ); 2802 #endif 2803 } 2804 if (slice->getPocMsbValPresentFlag()) 2805 { 2806 assert(slice->getPocMsbVal() % maxPocLsb == 0); 2807 #if P0297_VPS_POC_LSB_ALIGNED_FLAG 2808 WRITE_UVLC(slice->getPocMsbVal() / maxPocLsb, "poc_msb_cycle_val"); 2809 #else 2810 WRITE_UVLC(slice->getPocMsbVal() / maxPocLsb, "poc_msb_val"); 2811 #endif 2413 2812 } 2414 2813 for (Int i = 0; i < shExtnAdditionalBits; i++) … … 2755 3154 Void TEncCavlc::xCode3DAsymLUT( TCom3DAsymLUT * pc3DAsymLUT ) 2756 3155 { 3156 #if R0150_CGS_SIGNAL_CONSTRAINTS 3157 UInt uiNumRefLayers = ( UInt )pc3DAsymLUT->getRefLayerNum(); 3158 WRITE_UVLC( uiNumRefLayers - 1 , "num_cm_ref_layers_minus1" ); 3159 for( UInt i = 0 ; i < uiNumRefLayers ; i++ ) 3160 { 3161 WRITE_CODE( pc3DAsymLUT->getRefLayerId( i ) , 6 , "cm_ref_layer_id" ); 3162 } 3163 #endif 2757 3164 assert( pc3DAsymLUT->getCurOctantDepth() < 4 ); 2758 3165 WRITE_CODE( pc3DAsymLUT->getCurOctantDepth() , 2 , "cm_octant_depth" ); … … 2760 3167 WRITE_CODE( pc3DAsymLUT->getCurYPartNumLog2() , 2 , "cm_y_part_num_log2" ); 2761 3168 assert( pc3DAsymLUT->getInputBitDepthY() < 16 ); 3169 #if R0150_CGS_SIGNAL_CONSTRAINTS 3170 WRITE_UVLC( pc3DAsymLUT->getInputBitDepthY() - 8 , "cm_input_luma_bit_depth_minus8" ); 3171 WRITE_UVLC( pc3DAsymLUT->getInputBitDepthC() - 8 , "cm_input_chroma_bit_depth_minus8" ); 3172 WRITE_UVLC( pc3DAsymLUT->getOutputBitDepthY() - 8 , "cm_output_luma_bit_depth_minus8" ); 3173 WRITE_UVLC( pc3DAsymLUT->getOutputBitDepthC() - 8 , "cm_output_chroma_bit_depth_minus8" ); 3174 #else 2762 3175 WRITE_CODE( pc3DAsymLUT->getInputBitDepthY() - 8 , 3 , "cm_input_bit_depth_minus8" ); 2763 3176 WRITE_SVLC(pc3DAsymLUT->getInputBitDepthC()-pc3DAsymLUT->getInputBitDepthY(), "cm_input_bit_depth_chroma delta"); … … 2765 3178 WRITE_CODE( pc3DAsymLUT->getOutputBitDepthY() - 8 , 3 , "cm_output_bit_depth_minus8" ); 2766 3179 WRITE_SVLC(pc3DAsymLUT->getOutputBitDepthC()-pc3DAsymLUT->getOutputBitDepthY(), "cm_output_bit_depth_chroma_delta"); 3180 #endif 2767 3181 assert( pc3DAsymLUT->getResQuantBit() < 4 ); 2768 3182 WRITE_CODE( pc3DAsymLUT->getResQuantBit() , 2 , "cm_res_quant_bit" ); 2769 3183 #if R0300_CGS_RES_COEFF_CODING 3184 xFindDeltaBits( pc3DAsymLUT ); 3185 assert(pc3DAsymLUT->getDeltaBits() >=1 && pc3DAsymLUT->getDeltaBits() <= 4); 3186 WRITE_CODE( pc3DAsymLUT->getDeltaBits()-1 , 2 , "cm_delta_bit" ); 3187 #endif 3188 #if R0151_CGS_3D_ASYMLUT_IMPROVE 3189 if( pc3DAsymLUT->getCurOctantDepth() == 1 ) 3190 { 3191 WRITE_SVLC( pc3DAsymLUT->getAdaptChromaThresholdU() - ( 1 << ( pc3DAsymLUT->getInputBitDepthC() - 1 ) ) , "cm_adapt_threshold_u_delta" ); 3192 WRITE_SVLC( pc3DAsymLUT->getAdaptChromaThresholdV() - ( 1 << ( pc3DAsymLUT->getInputBitDepthC() - 1 ) ) , "cm_adapt_threshold_v_delta" ); 3193 } 3194 #endif 3195 3196 #if R0164_CGS_LUT_BUGFIX_CHECK 3197 pc3DAsymLUT->xInitCuboids(); 3198 #endif 2770 3199 xCode3DAsymLUTOctant( pc3DAsymLUT , 0 , 0 , 0 , 0 , 1 << pc3DAsymLUT->getCurOctantDepth() ); 3200 #if R0164_CGS_LUT_BUGFIX_CHECK 3201 xCuboidsFilledCheck( false ); 3202 pc3DAsymLUT->display( false ); 3203 #endif 2771 3204 } 2772 3205 … … 2793 3226 else 2794 3227 { 3228 #if R0300_CGS_RES_COEFF_CODING 3229 Int nFLCbits = pc3DAsymLUT->getMappingShift()-pc3DAsymLUT->getResQuantBit()-pc3DAsymLUT->getDeltaBits() ; 3230 nFLCbits = nFLCbits >= 0 ? nFLCbits : 0; 3231 #endif 2795 3232 for( Int l = 0 ; l < nYPartNum ; l++ ) 2796 3233 { 3234 #if R0164_CGS_LUT_BUGFIX 3235 Int shift = pc3DAsymLUT->getCurOctantDepth() - nDepth ; 3236 #endif 2797 3237 for( Int nVertexIdx = 0 ; nVertexIdx < 4 ; nVertexIdx++ ) 2798 3238 { 3239 #if R0164_CGS_LUT_BUGFIX 3240 SYUVP sRes = pc3DAsymLUT->getCuboidVertexResTree( yIdx + (l<<shift) , uIdx , vIdx , nVertexIdx ); 3241 #else 2799 3242 SYUVP sRes = pc3DAsymLUT->getCuboidVertexResTree( yIdx + l , uIdx , vIdx , nVertexIdx ); 3243 #endif 2800 3244 UInt uiCodeVertex = sRes.Y != 0 || sRes.U != 0 || sRes.V != 0; 2801 3245 WRITE_FLAG( uiCodeVertex , "coded_vertex_flag" ); 2802 3246 if( uiCodeVertex ) 2803 3247 { 3248 #if R0151_CGS_3D_ASYMLUT_IMPROVE 3249 #if R0300_CGS_RES_COEFF_CODING 3250 xWriteParam( sRes.Y, nFLCbits ); 3251 xWriteParam( sRes.U, nFLCbits ); 3252 xWriteParam( sRes.V, nFLCbits ); 3253 #else 3254 xWriteParam( sRes.Y ); 3255 xWriteParam( sRes.U ); 3256 xWriteParam( sRes.V ); 3257 #endif 3258 #else 2804 3259 WRITE_SVLC( sRes.Y , "resY" ); 2805 3260 WRITE_SVLC( sRes.U , "resU" ); 2806 3261 WRITE_SVLC( sRes.V , "resV" ); 2807 } 2808 } 2809 } 2810 } 2811 } 3262 #endif 3263 } 3264 } 3265 #if R0164_CGS_LUT_BUGFIX_CHECK 3266 pc3DAsymLUT->xSetExplicit( yIdx + (l<<shift) , uIdx , vIdx ); 3267 #endif 3268 } 3269 } 3270 } 3271 3272 #if R0151_CGS_3D_ASYMLUT_IMPROVE 3273 #if R0300_CGS_RES_COEFF_CODING 3274 Void TEncCavlc::xWriteParam( Int param, UInt rParam) 3275 #else 3276 Void TEncCavlc::xWriteParam( Int param) 3277 #endif 3278 { 3279 #if !R0300_CGS_RES_COEFF_CODING 3280 const UInt rParam = 7; 3281 #endif 3282 Int codeNumber = abs(param); 3283 WRITE_UVLC(codeNumber / (1 << rParam), "quotient"); 3284 WRITE_CODE((codeNumber % (1 << rParam)), rParam, "remainder"); 3285 if (abs(param)) 3286 WRITE_FLAG( param <0, "sign"); 3287 } 3288 #endif 3289 3290 #if R0300_CGS_RES_COEFF_CODING 3291 Void TEncCavlc::xFindDeltaBits( TCom3DAsymLUT * pc3DAsymLUT ) 3292 { 3293 Int nDeltaBits; 3294 Int nBestDeltaBits = -1; 3295 Int nBestBits = MAX_INT; 3296 for( nDeltaBits = 1; nDeltaBits < 5; nDeltaBits++) 3297 { 3298 Int nCurBits = 0; 3299 xTally3DAsymLUTOctantBits( pc3DAsymLUT , 0 , 0 , 0 , 0 , 1 << pc3DAsymLUT->getCurOctantDepth(), nDeltaBits, nCurBits ); 3300 //printf("%d, %d, %d\n", nDeltaBits, nCurBits, nBestBits); 3301 if(nCurBits < nBestBits) 3302 { 3303 nBestDeltaBits = nDeltaBits; 3304 nBestBits = nCurBits; 3305 } 3306 } 3307 3308 assert(nBestDeltaBits >=1 && nBestDeltaBits < 5); 3309 pc3DAsymLUT->setDeltaBits(nBestDeltaBits); 3310 } 3311 3312 Void TEncCavlc::xTally3DAsymLUTOctantBits( TCom3DAsymLUT * pc3DAsymLUT , Int nDepth , Int yIdx , Int uIdx , Int vIdx , Int nLength, Int nDeltaBits, Int& nCurBits ) 3313 { 3314 UInt uiOctantSplit = nDepth < pc3DAsymLUT->getCurOctantDepth(); 3315 if( nDepth < pc3DAsymLUT->getCurOctantDepth() ) 3316 nCurBits ++; 3317 Int nYPartNum = 1 << pc3DAsymLUT->getCurYPartNumLog2(); 3318 if( uiOctantSplit ) 3319 { 3320 Int nHalfLength = nLength >> 1; 3321 for( Int l = 0 ; l < 2 ; l++ ) 3322 { 3323 for( Int m = 0 ; m < 2 ; m++ ) 3324 { 3325 for( Int n = 0 ; n < 2 ; n++ ) 3326 { 3327 xTally3DAsymLUTOctantBits( pc3DAsymLUT , nDepth + 1 , yIdx + l * nHalfLength * nYPartNum , uIdx + m * nHalfLength , vIdx + n * nHalfLength , nHalfLength, nDeltaBits, nCurBits ); 3328 } 3329 } 3330 } 3331 } 3332 else 3333 { 3334 Int nFLCbits = pc3DAsymLUT->getMappingShift()-pc3DAsymLUT->getResQuantBit()-nDeltaBits ; 3335 nFLCbits = nFLCbits >= 0 ? nFLCbits:0; 3336 //printf("nFLCbits = %d\n", nFLCbits); 3337 3338 for( Int l = 0 ; l < nYPartNum ; l++ ) 3339 { 3340 for( Int nVertexIdx = 0 ; nVertexIdx < 4 ; nVertexIdx++ ) 3341 { 3342 SYUVP sRes = pc3DAsymLUT->getCuboidVertexResTree( yIdx + l , uIdx , vIdx , nVertexIdx ); 3343 3344 UInt uiCodeVertex = sRes.Y != 0 || sRes.U != 0 || sRes.V != 0; 3345 nCurBits++; 3346 if( uiCodeVertex ) 3347 { 3348 xCheckParamBits( sRes.Y, nFLCbits, nCurBits ); 3349 xCheckParamBits( sRes.U, nFLCbits, nCurBits ); 3350 xCheckParamBits( sRes.V, nFLCbits, nCurBits ); 3351 } 3352 } 3353 } 3354 } 3355 } 3356 3357 Void TEncCavlc::xCheckParamBits( Int param, Int rParam, Int &nBits) 3358 { 3359 Int codeNumber = abs(param); 3360 Int codeQuotient = codeNumber >> rParam; 3361 Int qLen; 3362 3363 UInt uiLength = 1; 3364 UInt uiTemp = ++codeQuotient; 3365 3366 while( 1 != uiTemp ) 3367 { 3368 uiTemp >>= 1; 3369 uiLength += 2; 3370 } 3371 3372 qLen = (uiLength >> 1); 3373 qLen += ((uiLength+1) >> 1); 3374 3375 nBits += qLen; 3376 nBits += rParam; 3377 if (abs(param)) 3378 nBits++; 3379 } 3380 #endif 3381 #if VPS_VUI_BSP_HRD_PARAMS 3382 Void TEncCavlc::codeVpsVuiBspHrdParams(TComVPS * const vps) 3383 { 3384 WRITE_UVLC( vps->getVpsNumAddHrdParams(), "vps_num_add_hrd_params" ); 3385 for( Int i = vps->getNumHrdParameters(), j = 0; i < vps->getNumHrdParameters() + vps->getVpsNumAddHrdParams(); i++, j++ ) // j = i - vps->getNumHrdParameters() 3386 { 3387 if( i > 0 ) 3388 { 3389 WRITE_FLAG( vps->getCprmsAddPresentFlag(j), "cprms_add_present_flag[i]" ); 3390 } 3391 WRITE_UVLC( vps->getNumSubLayerHrdMinus1(j), "num_sub_layer_hrd_minus1[i]" ); 3392 codeHrdParameters(vps->getBspHrd(j), i == 0 ? true : vps->getCprmsAddPresentFlag(j), vps->getNumSubLayerHrdMinus1(j)); 3393 } 3394 for( Int h = 1; h < vps->getNumOutputLayerSets(); h++ ) 3395 { 3396 Int lsIdx = vps->getOutputLayerSetIdx( h ); 3397 WRITE_UVLC( vps->getNumSignalledPartitioningSchemes(h), "num_signalled_partitioning_schemes[h]"); 3398 for( Int j = 0; j < vps->getNumSignalledPartitioningSchemes(h); j++ ) 3399 { 3400 WRITE_UVLC( vps->getNumPartitionsInSchemeMinus1(h, j), "num_partitions_in_scheme_minus1[h][j]" ); 3401 for( Int k = 0; k <= vps->getNumPartitionsInSchemeMinus1(h, j); k++ ) 3402 { 3403 for( Int r = 0; r < vps->getNumLayersInIdList( lsIdx ); r++ ) 3404 { 3405 WRITE_FLAG( vps->getLayerIncludedInPartitionFlag(h, j, k, r), "layer_included_in_partition_flag[h][j][k][r]" ); 3406 } 3407 } 3408 } 3409 for( Int i = 0; i < vps->getNumSignalledPartitioningSchemes(h) + 1; i++ ) 3410 { 3411 for( Int t = 0; t <= vps->getMaxSLayersInLayerSetMinus1(lsIdx); t++ ) 3412 { 3413 WRITE_UVLC(vps->getNumBspSchedulesMinus1(h, i, t), "num_bsp_schedules_minus1[h][i][t]"); 3414 for( Int j = 0; j <= vps->getNumBspSchedulesMinus1(h, i, t); j++ ) 3415 { 3416 for( Int k = 0; k < vps->getNumPartitionsInSchemeMinus1(h, i); k++ ) 3417 { 3418 WRITE_UVLC( vps->getBspHrdIdx(h, i, t, j, k), "bsp_comb_hrd_idx[h][i][t][j][k]"); 3419 WRITE_UVLC( vps->getBspSchedIdx(h, i, t, j, k), "bsp_comb_sched_idx[h][i][t][j][k]"); 3420 } 3421 } 3422 } 3423 } 3424 } 3425 } 3426 #endif 2812 3427 #endif 2813 3428 //! \} -
trunk/source/Lib/TLibEncoder/TEncCavlc.h
r815 r906 169 169 Void codeVpsDpbSizeTable (TComVPS *vps); 170 170 #endif 171 #if Q0048_CGS_3D_ASYMLUT 171 #if VPS_VUI_BSP_HRD_PARAMS 172 Void codeVpsVuiBspHrdParams (TComVPS * const); 173 #endif 174 #if Q0048_CGS_3D_ASYMLUT 175 #if R0179_ENC_OPT_3DLUT_SIZE 176 public: 177 Void xCode3DAsymLUT( TCom3DAsymLUT * pc3DAsymLUT ); 178 protected: 179 Void xCode3DAsymLUTOctant( TCom3DAsymLUT * pc3DAsymLUT , Int nDepth , Int yIdx , Int uIdx , Int vIdx , Int nLength ); 180 #else 172 181 protected: 173 182 Void xCode3DAsymLUT( TCom3DAsymLUT * pc3DAsymLUT ); 174 183 Void xCode3DAsymLUTOctant( TCom3DAsymLUT * pc3DAsymLUT , Int nDepth , Int yIdx , Int uIdx , Int vIdx , Int nLength ); 175 184 #endif 185 #if R0151_CGS_3D_ASYMLUT_IMPROVE 186 #if R0300_CGS_RES_COEFF_CODING 187 Void xWriteParam( Int param, UInt nFLCBits); 188 Void xCheckParamBits( Int param, Int nFLCBits, Int & nCurBits); 189 Void xTally3DAsymLUTOctantBits( TCom3DAsymLUT * pc3DAsymLUT , Int nDepth , Int yIdx , Int uIdx , Int vIdx , Int nLength, Int nDeltaBits, Int &nCurBits); 190 Void xFindDeltaBits( TCom3DAsymLUT * pc3DAsymLUT ); 191 #else 192 Void xWriteParam( Int param); 193 #endif 194 #endif 195 #endif 176 196 #endif //SVC_EXTENSION 177 197 -
trunk/source/Lib/TLibEncoder/TEncCfg.h
r815 r906 107 107 Int m_iSourceWidth; 108 108 Int m_iSourceHeight; 109 Int m_conformanceMode;110 109 Window m_conformanceWindow; 111 110 Int m_framesToBeEncoded; … … 208 207 Bool m_bPCMFilterDisableFlag; 209 208 Bool m_loopFilterAcrossTilesEnabledFlag; 210 Int m_iUniformSpacingIdr;209 Bool m_tileUniformSpacingFlag; 211 210 Int m_iNumColumnsMinus1; 212 UInt* m_puiColumnWidth;213 211 Int m_iNumRowsMinus1; 214 UInt* m_puiRowHeight; 212 std::vector<Int> m_tileColumnWidth; 213 std::vector<Int> m_tileRowHeight; 215 214 216 215 Int m_iWaveFrontSynchro; … … 248 247 Int* m_codedPivotValue; 249 248 Int* m_targetPivotValue; 250 #if P0050_KNEE_FUNCTION_SEI251 Bool m_kneeSEIEnabled;252 Int m_kneeSEIId;253 Bool m_kneeSEICancelFlag;254 Bool m_kneeSEIPersistenceFlag;255 Bool m_kneeSEIMappingFlag;256 Int m_kneeSEIInputDrange;257 Int m_kneeSEIInputDispLuminance;258 Int m_kneeSEIOutputDrange;259 Int m_kneeSEIOutputDispLuminance;260 Int m_kneeSEINumKneePointsMinus1;261 Int* m_kneeSEIInputKneePoint;262 Int* m_kneeSEIOutputKneePoint;263 #endif264 #if Q0074_SEI_COLOR_MAPPING265 Char* m_seiColorMappingFile;266 #endif267 249 Int m_framePackingSEIEnabled; 268 250 Int m_framePackingSEIType; … … 276 258 Int m_SOPDescriptionSEIEnabled; 277 259 Int m_scalableNestingSEIEnabled; 278 #if Q0189_TMVP_CONSTRAINTS279 Int m_TMVPConstraintsSEIEnabled;280 #endif281 260 //====== Weighted Prediction ======== 282 261 Bool m_useWeightedPred; //< Use of Weighting Prediction (P_SLICE) … … 388 367 Int m_nCGSMaxYPartNumLog2; 389 368 Int m_nCGSLUTBit; 369 #if R0151_CGS_3D_ASYMLUT_IMPROVE 370 Int m_nCGSAdaptiveChroma; 371 #endif 372 #if R0179_ENC_OPT_3DLUT_SIZE 373 Int m_nCGSLutSizeRDO; 374 #endif 375 #endif 376 #if P0050_KNEE_FUNCTION_SEI 377 Bool m_kneeSEIEnabled; 378 Int m_kneeSEIId; 379 Bool m_kneeSEICancelFlag; 380 Bool m_kneeSEIPersistenceFlag; 381 Bool m_kneeSEIMappingFlag; 382 Int m_kneeSEIInputDrange; 383 Int m_kneeSEIInputDispLuminance; 384 Int m_kneeSEIOutputDrange; 385 Int m_kneeSEIOutputDispLuminance; 386 Int m_kneeSEINumKneePointsMinus1; 387 Int* m_kneeSEIInputKneePoint; 388 Int* m_kneeSEIOutputKneePoint; 389 #endif 390 #if Q0189_TMVP_CONSTRAINTS 391 Int m_TMVPConstraintsSEIEnabled; 390 392 #endif 391 393 #endif //SVC_EXTENSION 394 #if Q0074_COLOUR_REMAPPING_SEI 395 Char* m_colourRemapSEIFile; ///< SEI Colour Remapping File (initialized from external file) 396 Int m_colourRemapSEIId; 397 Bool m_colourRemapSEICancelFlag; 398 Bool m_colourRemapSEIPersistenceFlag; 399 Bool m_colourRemapSEIVideoSignalInfoPresentFlag; 400 Bool m_colourRemapSEIFullRangeFlag; 401 Int m_colourRemapSEIPrimaries; 402 Int m_colourRemapSEITransferFunction; 403 Int m_colourRemapSEIMatrixCoefficients; 404 Int m_colourRemapSEIInputBitDepth; 405 Int m_colourRemapSEIBitDepth; 406 Int m_colourRemapSEIPreLutNumValMinus1[3]; 407 Int* m_colourRemapSEIPreLutCodedValue[3]; 408 Int* m_colourRemapSEIPreLutTargetValue[3]; 409 Bool m_colourRemapSEIMatrixPresentFlag; 410 Int m_colourRemapSEILog2MatrixDenom; 411 Int m_colourRemapSEICoeffs[3][3]; 412 Int m_colourRemapSEIPostLutNumValMinus1[3]; 413 Int* m_colourRemapSEIPostLutCodedValue[3]; 414 Int* m_colourRemapSEIPostLutTargetValue[3]; 415 #endif 392 416 393 417 public: 394 418 TEncCfg() 395 : m_ puiColumnWidth()396 , m_ puiRowHeight()419 : m_tileColumnWidth() 420 , m_tileRowHeight() 397 421 {} 398 422 399 423 virtual ~TEncCfg() 400 { 401 delete[] m_puiColumnWidth; 402 delete[] m_puiRowHeight; 403 } 424 {} 404 425 405 426 Void setProfile(Profile::Name profile) { m_profile = profile; } … … 412 433 413 434 Window &getConformanceWindow() { return m_conformanceWindow; } 414 #if P0312_VERT_PHASE_ADJ 435 #if P0312_VERT_PHASE_ADJ && !R0209_GENERIC_PHASE 415 436 Void setConformanceWindow (Int confLeft, Int confRight, Int confTop, Int confBottom ) { m_conformanceWindow.setWindow (confLeft, confRight, confTop, confBottom, false); } 416 437 #else … … 437 458 Void setMaxRefPicNum ( Int iMaxRefPicNum ) { m_iMaxRefPicNum = iMaxRefPicNum; } 438 459 439 BoolgetMaxTempLayer () { return m_maxTempLayer; }460 Int getMaxTempLayer () { return m_maxTempLayer; } 440 461 Void setMaxTempLayer ( Int maxTempLayer ) { m_maxTempLayer = maxTempLayer; } 441 462 //======== Transform ============= … … 582 603 Void setLFCrossTileBoundaryFlag ( Bool val ) { m_loopFilterAcrossTilesEnabledFlag = val; } 583 604 Bool getLFCrossTileBoundaryFlag () { return m_loopFilterAcrossTilesEnabledFlag; } 584 Void set UniformSpacingIdr ( Int i ) { m_iUniformSpacingIdr = i; }585 Int getUniformSpacingIdr () { return m_iUniformSpacingIdr; }605 Void setTileUniformSpacingFlag ( Bool b ) { m_tileUniformSpacingFlag = b; } 606 Bool getTileUniformSpacingFlag () { return m_tileUniformSpacingFlag; } 586 607 Void setNumColumnsMinus1 ( Int i ) { m_iNumColumnsMinus1 = i; } 587 608 Int getNumColumnsMinus1 () { return m_iNumColumnsMinus1; } 588 Void setColumnWidth ( UInt* columnWidth ) 589 { 590 if( m_iUniformSpacingIdr == 0 && m_iNumColumnsMinus1 > 0 ) 591 { 592 Int m_iWidthInCU = ( m_iSourceWidth%g_uiMaxCUWidth ) ? m_iSourceWidth/g_uiMaxCUWidth + 1 : m_iSourceWidth/g_uiMaxCUWidth; 593 m_puiColumnWidth = new UInt[ m_iNumColumnsMinus1 ]; 594 595 for(Int i=0; i<m_iNumColumnsMinus1; i++) 596 { 597 m_puiColumnWidth[i] = columnWidth[i]; 598 printf("col: m_iWidthInCU= %4d i=%4d width= %4d\n",m_iWidthInCU,i,m_puiColumnWidth[i]); //AFU 599 } 600 } 601 } 602 UInt getColumnWidth ( UInt columnidx ) { return *( m_puiColumnWidth + columnidx ); } 609 Void setColumnWidth ( const std::vector<Int>& columnWidth ) { m_tileColumnWidth = columnWidth; } 610 UInt getColumnWidth ( UInt columnIdx ) { return m_tileColumnWidth[columnIdx]; } 603 611 Void setNumRowsMinus1 ( Int i ) { m_iNumRowsMinus1 = i; } 604 612 Int getNumRowsMinus1 () { return m_iNumRowsMinus1; } 605 Void setRowHeight (UInt* rowHeight) 606 { 607 if( m_iUniformSpacingIdr == 0 && m_iNumRowsMinus1 > 0 ) 608 { 609 Int m_iHeightInCU = ( m_iSourceHeight%g_uiMaxCUHeight ) ? m_iSourceHeight/g_uiMaxCUHeight + 1 : m_iSourceHeight/g_uiMaxCUHeight; 610 m_puiRowHeight = new UInt[ m_iNumRowsMinus1 ]; 611 612 for(Int i=0; i<m_iNumRowsMinus1; i++) 613 { 614 m_puiRowHeight[i] = rowHeight[i]; 615 printf("row: m_iHeightInCU=%4d i=%4d height=%4d\n",m_iHeightInCU,i,m_puiRowHeight[i]); //AFU 616 } 617 } 618 } 619 UInt getRowHeight ( UInt rowIdx ) { return *( m_puiRowHeight + rowIdx ); } 613 Void setRowHeight ( const std::vector<Int>& rowHeight) { m_tileRowHeight = rowHeight; } 614 UInt getRowHeight ( UInt rowIdx ) { return m_tileRowHeight[rowIdx]; } 620 615 Void xCheckGSParameters(); 621 616 Void setWaveFrontSynchro(Int iWaveFrontSynchro) { m_iWaveFrontSynchro = iWaveFrontSynchro; } … … 711 706 Int* getKneeSEIOutputKneePoint() { return m_kneeSEIOutputKneePoint; } 712 707 #endif 713 #if Q0074_SEI_COLOR_MAPPING 714 Void setColorMappingInfoSEIFile( Char* nameFile ) { m_seiColorMappingFile = nameFile; } 715 Char* getColorMappingInfoSEIFile() { return m_seiColorMappingFile; } 708 #if Q0074_COLOUR_REMAPPING_SEI 709 Void setCRISEIFile( Char* pch ) { m_colourRemapSEIFile = pch; } 710 Char* getCRISEIFile() { return m_colourRemapSEIFile; } 711 Void setCRISEIId(Int i) { m_colourRemapSEIId = i; } 712 Int getCRISEIId() { return m_colourRemapSEIId; } 713 Void setCRISEICancelFlag(Bool b) { m_colourRemapSEICancelFlag = b; } 714 Bool getCRISEICancelFlag() { return m_colourRemapSEICancelFlag; } 715 Void setCRISEIPersistenceFlag(Bool b) { m_colourRemapSEIPersistenceFlag = b; } 716 Bool getCRISEIPersistenceFlag() { return m_colourRemapSEIPersistenceFlag; } 717 Void setCRISEIVideoSignalInfoPresentFlag(Bool b) { m_colourRemapSEIVideoSignalInfoPresentFlag = b; } 718 Bool getCRISEIVideoSignalInfoPresentFlag() { return m_colourRemapSEIVideoSignalInfoPresentFlag; } 719 Void setCRISEIFullRangeFlag(Bool b) { m_colourRemapSEIFullRangeFlag = b; } 720 Bool getCRISEIFullRangeFlag() { return m_colourRemapSEIFullRangeFlag; } 721 Void setCRISEIPrimaries(Int i) { m_colourRemapSEIPrimaries = i; } 722 Int getCRISEIPrimaries() { return m_colourRemapSEIPrimaries; } 723 Void setCRISEITransferFunction(Int i) { m_colourRemapSEITransferFunction = i; } 724 Int getCRISEITransferFunction() { return m_colourRemapSEITransferFunction; } 725 Void setCRISEIMatrixCoefficients(Int i) { m_colourRemapSEIMatrixCoefficients = i; } 726 Int getCRISEIMatrixCoefficients() { return m_colourRemapSEIMatrixCoefficients; } 727 Void setCRISEIInputBitDepth(Int i) { m_colourRemapSEIInputBitDepth = i; } 728 Int getCRISEIInputBitDepth() { return m_colourRemapSEIInputBitDepth; } 729 Void setCRISEIBitDepth(Int i) { m_colourRemapSEIBitDepth = i; } 730 Int getCRISEIBitDepth() { return m_colourRemapSEIBitDepth; } 731 Void setCRISEIPreLutNumValMinus1(Int *i) { for(Int c=0 ; c<3 ; c++) m_colourRemapSEIPreLutNumValMinus1[c] = i[c]; } 732 Int getCRISEIPreLutNumValMinus1(Int i) { return m_colourRemapSEIPreLutNumValMinus1[i]; } 733 Void setCRISEIPreLutCodedValue(Int **i) { for(Int c=0 ; c<3 ; c++) m_colourRemapSEIPreLutCodedValue[c] = i[c]; } 734 Int* getCRISEIPreLutCodedValue(Int i) { return m_colourRemapSEIPreLutCodedValue[i]; } 735 Void setCRISEIPreLutTargetValue(Int **i) { for(Int c=0 ; c<3 ; c++) m_colourRemapSEIPreLutTargetValue[c] = i[c]; } 736 Int* getCRISEIPreLutTargetValue(Int i) { return m_colourRemapSEIPreLutTargetValue[i]; } 737 Void setCRISEIMatrixPresentFlag(Bool b) { m_colourRemapSEIMatrixPresentFlag = b; } 738 Bool getCRISEIMatrixPresentFlag() { return m_colourRemapSEIMatrixPresentFlag; } 739 Void setCRISEILog2MatrixDenom(Int i) { m_colourRemapSEILog2MatrixDenom = i; } 740 Int getCRISEILog2MatrixDenom() { return m_colourRemapSEILog2MatrixDenom; } 741 Void setCRISEICoeffs(Int i[3][3]) { for(Int c=0 ; c<3 ; c++) for(Int j=0 ; j<3 ; j++) m_colourRemapSEICoeffs[c][j] = i[c][j]; } 742 Int* getCRISEICoeffs(Int i) { return m_colourRemapSEICoeffs[i]; } 743 Void setCRISEIPostLutNumValMinus1(Int *i) { for(Int c=0 ; c<3 ; c++) m_colourRemapSEIPostLutNumValMinus1[c] = i[c]; } 744 Int getCRISEIPostLutNumValMinus1(Int i) { return m_colourRemapSEIPostLutNumValMinus1[i]; } 745 Void setCRISEIPostLutCodedValue(Int **i) { for(Int c=0 ; c<3 ; c++) m_colourRemapSEIPostLutCodedValue[c] = i[c]; } 746 Int* getCRISEIPostLutCodedValue(Int i) { return m_colourRemapSEIPostLutCodedValue[i]; } 747 Void setCRISEIPostLutTargetValue(Int **i) { for(Int c=0 ; c<3 ; c++) m_colourRemapSEIPostLutTargetValue[c] = i[c]; } 748 Int* getCRISEIPostLutTargetValue(Int i) { return m_colourRemapSEIPostLutTargetValue[i]; } 716 749 #endif 717 750 Void setFramePackingArrangementSEIEnabled(Int b) { m_framePackingSEIEnabled = b; } … … 865 898 UInt getNumLayer () { return m_numLayer; } 866 899 Void setNumLayer (UInt uiNum) { m_numLayer = uiNum; } 867 Void setConformanceMode (Int mode) { m_conformanceMode = mode; }868 900 Void setConformanceWindow(Window& conformanceWindow ) { m_conformanceWindow = conformanceWindow; } 869 901 Void setElRapSliceTypeB(Int bEnabled) {m_elRapSliceBEnabled = bEnabled;} … … 971 1003 Void setCGSLUTBit(Int n) { m_nCGSLUTBit = n; } 972 1004 Int getCGSLUTBit() { return m_nCGSLUTBit; } 1005 #if R0151_CGS_3D_ASYMLUT_IMPROVE 1006 Void setCGSAdaptChroma(Int n) { m_nCGSAdaptiveChroma = n; } 1007 Int getCGSAdaptChroma() { return m_nCGSAdaptiveChroma; } 1008 #endif 1009 #if R0179_ENC_OPT_3DLUT_SIZE 1010 Void setCGSLutSizeRDO(Int n) { m_nCGSLutSizeRDO = n; } 1011 Int getCGSLutSizeRDO() { return m_nCGSLutSizeRDO; } 1012 #endif 973 1013 #endif 974 1014 #endif -
trunk/source/Lib/TLibEncoder/TEncGOP.cpp
r815 r906 49 49 #include <time.h> 50 50 #include <math.h> 51 #if P0297_VPS_POC_LSB_ALIGNED_FLAG 52 #include <limits.h> 53 #endif 51 54 52 55 using namespace std; … … 202 205 seiActiveParameterSets->m_selfContainedCvsFlag = false; 203 206 seiActiveParameterSets->m_noParameterSetUpdateFlag = false; 207 #if !R0247_SEI_ACTIVE 204 208 seiActiveParameterSets->numSpsIdsMinus1 = 0; 205 209 seiActiveParameterSets->activeSeqParameterSetId.resize(seiActiveParameterSets->numSpsIdsMinus1 + 1); 206 210 seiActiveParameterSets->activeSeqParameterSetId[0] = sps->getSPSId(); 211 #else 212 seiActiveParameterSets->numSpsIdsMinus1 = m_pcCfg->getNumLayer()-1; 213 seiActiveParameterSets->activeSeqParameterSetId.resize(seiActiveParameterSets->numSpsIdsMinus1 + 1); 214 seiActiveParameterSets->layerSpsIdx.resize(seiActiveParameterSets->numSpsIdsMinus1+ 1); 215 for (Int c=0; c <= seiActiveParameterSets->numSpsIdsMinus1; c++) 216 { 217 seiActiveParameterSets->activeSeqParameterSetId[c] = c; 218 } 219 for (Int c=1; c <= seiActiveParameterSets->numSpsIdsMinus1; c++) 220 { 221 seiActiveParameterSets->layerSpsIdx[c] = c; 222 } 223 #endif 207 224 return seiActiveParameterSets; 208 225 } … … 365 382 #endif 366 383 367 #if Q0074_ SEI_COLOR_MAPPING368 SEIColo rMappingInfo* TEncGOP::xCreateSEIColorMappingInfo( Char* file)384 #if Q0074_COLOUR_REMAPPING_SEI 385 SEIColourRemappingInfo* TEncGOP::xCreateSEIColourRemappingInfo() 369 386 { 370 SEIColorMappingInfo *seiColorMappingInfo = new SEIColorMappingInfo(); 371 372 FILE* fic = fopen( file, "r" ); 373 374 Int iVal, retval; 375 376 retval = fscanf( fic, "%d", &seiColorMappingInfo->m_colorMapId ); 377 retval = fscanf( fic, "%d", &iVal ); 378 seiColorMappingInfo->m_colorMapCancelFlag = iVal; 379 if( !seiColorMappingInfo->m_colorMapCancelFlag ) 380 { 381 retval = fscanf( fic, "%d", &iVal ); 382 seiColorMappingInfo->m_colorMapPersistenceFlag = iVal; 383 retval = fscanf( fic, "%d", &iVal ); 384 seiColorMappingInfo->m_colorMap_video_signal_type_present_flag = iVal; 385 if( seiColorMappingInfo->m_colorMap_video_signal_type_present_flag ) 386 { 387 retval = fscanf( fic, "%d", &iVal ); 388 seiColorMappingInfo->m_colorMap_video_full_range_flag = iVal; 389 retval = fscanf( fic, "%d", &seiColorMappingInfo->m_colorMap_primaries ); 390 retval = fscanf( fic, "%d", &seiColorMappingInfo->m_colorMap_transfer_characteristics ); 391 retval = fscanf( fic, "%d", &seiColorMappingInfo->m_colorMap_matrix_coeffs ); 392 } 393 } 394 395 retval = fscanf( fic, "%d", &seiColorMappingInfo->m_colour_map_coded_data_bit_depth ); 396 retval = fscanf( fic, "%d", &seiColorMappingInfo->m_colour_map_target_bit_depth ); 397 retval = fscanf( fic, "%d", &iVal ); 398 seiColorMappingInfo->m_colorMapModelId = iVal; 399 400 assert( seiColorMappingInfo->m_colorMapModelId == 0 ); 401 402 for( Int i=0 ; i<3 ; i++ ) 403 { 404 retval = fscanf( fic, "%d", &seiColorMappingInfo->m_num_input_pivots[i] ); 405 seiColorMappingInfo->m_coded_input_pivot_value[i] = new Int[ seiColorMappingInfo->m_num_input_pivots[i] ]; 406 seiColorMappingInfo->m_target_input_pivot_value[i] = new Int[ seiColorMappingInfo->m_num_input_pivots[i] ]; 407 for( Int j=0 ; j<seiColorMappingInfo->m_num_input_pivots[i] ; j++ ) 408 { 409 retval = fscanf( fic, "%d", &seiColorMappingInfo->m_coded_input_pivot_value[i][j] ); 410 retval = fscanf( fic, "%d", &seiColorMappingInfo->m_target_input_pivot_value[i][j] ); 411 } 412 } 413 414 retval = fscanf( fic, "%d", &iVal ); 415 seiColorMappingInfo->m_matrix_flag = iVal; 416 if( seiColorMappingInfo->m_matrix_flag ) 417 { 418 retval = fscanf( fic, "%d", &seiColorMappingInfo->m_log2_matrix_denom ); 419 for( Int i=0 ; i<3 ; i++ ) 420 { 421 for( Int j=0 ; j<3 ; j++ ) 422 { 423 retval = fscanf( fic, "%d", &seiColorMappingInfo->m_matrix_coef[i][j] ); 424 } 425 } 426 } 427 428 for( Int i=0 ; i<3 ; i++ ) 429 { 430 retval = fscanf( fic, "%d", &seiColorMappingInfo->m_num_output_pivots[i] ); 431 seiColorMappingInfo->m_coded_output_pivot_value[i] = new Int[ seiColorMappingInfo->m_num_output_pivots[i] ]; 432 seiColorMappingInfo->m_target_output_pivot_value[i] = new Int[ seiColorMappingInfo->m_num_output_pivots[i] ]; 433 for( Int j=0 ; j<seiColorMappingInfo->m_num_output_pivots[i] ; j++ ) 434 { 435 retval = fscanf( fic, "%d", &seiColorMappingInfo->m_coded_output_pivot_value[i][j] ); 436 retval = fscanf( fic, "%d", &seiColorMappingInfo->m_target_output_pivot_value[i][j] ); 437 } 438 } 439 440 fclose( fic ); 441 442 if( retval != 1 ) 443 { 444 printf("Error: can't read color mapping information\n"); 445 } 446 447 return seiColorMappingInfo; 387 SEIColourRemappingInfo *seiColourRemappingInfo = new SEIColourRemappingInfo(); 388 seiColourRemappingInfo->m_colourRemapId = m_pcCfg->getCRISEIId(); 389 seiColourRemappingInfo->m_colourRemapCancelFlag = m_pcCfg->getCRISEICancelFlag(); 390 if( !seiColourRemappingInfo->m_colourRemapCancelFlag ) 391 { 392 seiColourRemappingInfo->m_colourRemapPersistenceFlag = m_pcCfg->getCRISEIPersistenceFlag(); 393 seiColourRemappingInfo->m_colourRemapVideoSignalInfoPresentFlag = m_pcCfg->getCRISEIVideoSignalInfoPresentFlag(); 394 if( seiColourRemappingInfo->m_colourRemapVideoSignalInfoPresentFlag ) 395 { 396 seiColourRemappingInfo->m_colourRemapFullRangeFlag = m_pcCfg->getCRISEIFullRangeFlag(); 397 seiColourRemappingInfo->m_colourRemapPrimaries = m_pcCfg->getCRISEIPrimaries(); 398 seiColourRemappingInfo->m_colourRemapTransferFunction = m_pcCfg->getCRISEITransferFunction(); 399 seiColourRemappingInfo->m_colourRemapMatrixCoefficients = m_pcCfg->getCRISEIMatrixCoefficients(); 400 } 401 seiColourRemappingInfo->m_colourRemapInputBitDepth = m_pcCfg->getCRISEIInputBitDepth(); 402 seiColourRemappingInfo->m_colourRemapBitDepth = m_pcCfg->getCRISEIBitDepth(); 403 for( Int c=0 ; c<3 ; c++ ) 404 { 405 seiColourRemappingInfo->m_preLutNumValMinus1[c] = m_pcCfg->getCRISEIPreLutNumValMinus1(c); 406 if( seiColourRemappingInfo->m_preLutNumValMinus1[c]>0 ) 407 { 408 seiColourRemappingInfo->m_preLutCodedValue[c].resize(seiColourRemappingInfo->m_preLutNumValMinus1[c]+1); 409 seiColourRemappingInfo->m_preLutTargetValue[c].resize(seiColourRemappingInfo->m_preLutNumValMinus1[c]+1); 410 for( Int i=0 ; i<=seiColourRemappingInfo->m_preLutNumValMinus1[c] ; i++) 411 { 412 seiColourRemappingInfo->m_preLutCodedValue[c][i] = (m_pcCfg->getCRISEIPreLutCodedValue(c))[i]; 413 seiColourRemappingInfo->m_preLutTargetValue[c][i] = (m_pcCfg->getCRISEIPreLutTargetValue(c))[i]; 414 } 415 } 416 } 417 seiColourRemappingInfo->m_colourRemapMatrixPresentFlag = m_pcCfg->getCRISEIMatrixPresentFlag(); 418 if( seiColourRemappingInfo->m_colourRemapMatrixPresentFlag ) 419 { 420 seiColourRemappingInfo->m_log2MatrixDenom = m_pcCfg->getCRISEILog2MatrixDenom(); 421 for( Int c=0 ; c<3 ; c++ ) 422 for( Int i=0 ; i<3 ; i++ ) 423 seiColourRemappingInfo->m_colourRemapCoeffs[c][i] = (m_pcCfg->getCRISEICoeffs(c))[i]; 424 } 425 for( Int c=0 ; c<3 ; c++ ) 426 { 427 seiColourRemappingInfo->m_postLutNumValMinus1[c] = m_pcCfg->getCRISEIPostLutNumValMinus1(c); 428 if( seiColourRemappingInfo->m_postLutNumValMinus1[c]>0 ) 429 { 430 seiColourRemappingInfo->m_postLutCodedValue[c].resize(seiColourRemappingInfo->m_postLutNumValMinus1[c]+1); 431 seiColourRemappingInfo->m_postLutTargetValue[c].resize(seiColourRemappingInfo->m_postLutNumValMinus1[c]+1); 432 for( Int i=0 ; i<=seiColourRemappingInfo->m_postLutNumValMinus1[c] ; i++) 433 { 434 seiColourRemappingInfo->m_postLutCodedValue[c][i] = (m_pcCfg->getCRISEIPostLutCodedValue(c))[i]; 435 seiColourRemappingInfo->m_postLutTargetValue[c][i] = (m_pcCfg->getCRISEIPostLutTargetValue(c))[i]; 436 } 437 } 438 } 439 } 440 return seiColourRemappingInfo; 448 441 } 449 442 #endif … … 453 446 OutputNALUnit nalu(NAL_UNIT_PREFIX_SEI); 454 447 455 if(m_pcCfg->getActiveParameterSetsSEIEnabled()) 448 if(m_pcCfg->getActiveParameterSetsSEIEnabled() 449 #if R0247_SEI_ACTIVE 450 && m_layerId == 0 451 #endif 452 ) 456 453 { 457 454 SEIActiveParameterSets *sei = xCreateSEIActiveParameterSets (sps); … … 532 529 } 533 530 #endif 534 #if Q0074_ SEI_COLOR_MAPPING535 if( m_pcCfg->getColorMappingInfoSEIFile())536 { 537 SEIColo rMappingInfo *sei = xCreateSEIColorMappingInfo( m_pcCfg->getColorMappingInfoSEIFile());531 #if Q0074_COLOUR_REMAPPING_SEI 532 if(strlen(m_pcCfg->getCRISEIFile())) 533 { 534 SEIColourRemappingInfo *sei = xCreateSEIColourRemappingInfo (); 538 535 539 536 #if SVC_EXTENSION 540 nalu = NALUnit(NAL_UNIT_PREFIX_SEI, 0, m_layerId); // temporalId = 0 ?537 nalu = NALUnit(NAL_UNIT_PREFIX_SEI, 0, sps->getLayerId()); // SEI-CRI is applied per layer 541 538 #else 542 539 nalu = NALUnit(NAL_UNIT_PREFIX_SEI); … … 609 606 TEncSbac* pcSbacCoders = NULL; 610 607 TComOutputBitstream* pcSubstreamsOut = NULL; 611 #if Q0108_TSA_STSA612 Int flagTSTA = 0;613 #endif614 608 615 609 xInitGOP( iPOCLast, iNumPicRcvd, rcListPic, rcListPicYuvRecOut, isField ); … … 918 912 determinePocResetIdc(pocCurr, pcSlice); 919 913 914 #if P0297_VPS_POC_LSB_ALIGNED_FLAG 915 Bool pocResettingFlag = false; 916 917 if (pcSlice->getPocResetIdc() != 0) 918 { 919 if (pcSlice->getVPS()->getVpsPocLsbAlignedFlag()) 920 { 921 pocResettingFlag = true; 922 } 923 else if (m_pcEncTop->getPocDecrementedInDPBFlag()) 924 { 925 pocResettingFlag = false; 926 } 927 else 928 { 929 pocResettingFlag = true; 930 } 931 } 932 #endif 933 920 934 // If reset, do the following steps: 935 #if P0297_VPS_POC_LSB_ALIGNED_FLAG 936 if( pocResettingFlag ) 937 #else 921 938 if( pcSlice->getPocResetIdc() ) 939 #endif 922 940 { 923 941 updatePocValuesOfPics(pocCurr, pcSlice); … … 1020 1038 // inferring of the scaling list can be moved to the config file 1021 1039 UInt refLayerId = 0; 1040 #if VPS_AVC_BL_FLAG_REMOVAL 1041 if( m_layerId > 0 && !m_pcEncTop->getVPS()->getNonHEVCBaseLayerFlag() && m_pcEncTop->getVPS()->getRecursiveRefLayerFlag( m_layerId, refLayerId ) ) 1042 #else 1022 1043 if( m_layerId > 0 && !m_pcEncTop->getVPS()->getAvcBaseLayerFlag() && m_pcEncTop->getVPS()->getRecursiveRefLayerFlag( m_layerId, refLayerId ) ) 1044 #endif 1023 1045 { 1024 1046 m_pcEncTop->getSPS()->setInferScalingListFlag( true ); … … 1050 1072 // inferring of the scaling list can be moved to the config file 1051 1073 UInt refLayerId = 0; 1074 #if VPS_AVC_BL_FLAG_REMOVAL 1075 if( m_layerId > 0 && !m_pcEncTop->getVPS()->getNonHEVCBaseLayerFlag() && m_pcEncTop->getVPS()->getRecursiveRefLayerFlag( m_layerId, refLayerId ) ) 1076 #else 1052 1077 if( m_layerId > 0 && !m_pcEncTop->getVPS()->getAvcBaseLayerFlag() && m_pcEncTop->getVPS()->getRecursiveRefLayerFlag( m_layerId, refLayerId ) ) 1078 #endif 1053 1079 { 1054 1080 m_pcEncTop->getSPS()->setInferScalingListFlag( true ); … … 1135 1161 #endif 1136 1162 1163 #if REF_REGION_OFFSET 1164 const Window &windowRL = m_pcEncTop->getRefLayerWindowForLayer(pcSlice->getVPS()->getRefLayerId(m_layerId, refLayerIdc)); 1165 Int widthBL = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec()->getWidth() - windowRL.getWindowLeftOffset() - windowRL.getWindowRightOffset(); 1166 Int heightBL = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec()->getHeight() - windowRL.getWindowTopOffset() - windowRL.getWindowBottomOffset(); 1167 #else 1137 1168 Int widthBL = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec()->getWidth(); 1138 1169 Int heightBL = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec()->getHeight(); … … 1143 1174 heightBL -= ( confBL.getWindowTopOffset() + confBL.getWindowBottomOffset() ) * TComSPS::getWinUnitY( chromaFormatIdc ); 1144 1175 #endif 1176 #endif 1145 1177 Int widthEL = pcPic->getPicYuvRec()->getWidth() - scalEL.getWindowLeftOffset() - scalEL.getWindowRightOffset(); 1146 1178 Int heightEL = pcPic->getPicYuvRec()->getHeight() - scalEL.getWindowTopOffset() - scalEL.getWindowBottomOffset(); 1179 1180 #if RESAMPLING_FIX 1181 #if REF_REGION_OFFSET 1182 // conformance check: the values of RefLayerRegionWidthInSamplesY, RefLayerRegionHeightInSamplesY, ScaledRefRegionWidthInSamplesY and ScaledRefRegionHeightInSamplesY shall be greater than 0 1183 assert(widthEL > 0 && heightEL > 0 && widthBL > 0 && widthEL > 0); 1184 1185 // conformance check: ScaledRefRegionWidthInSamplesY shall be greater or equal to RefLayerRegionWidthInSamplesY and ScaledRefRegionHeightInSamplesY shall be greater or equal to RefLayerRegionHeightInSamplesY 1186 assert(widthEL >= widthBL && heightEL >= heightBL); 1187 1188 #if R0209_GENERIC_PHASE 1189 // conformance check: when ScaledRefRegionWidthInSamplesY is equal to RefLayerRegionWidthInSamplesY, PhaseHorY shall be equal to 0, when ScaledRefRegionWidthInSamplesC is equal to RefLayerRegionWidthInSamplesC, PhaseHorC shall be equal to 0, when ScaledRefRegionHeightInSamplesY is equal to RefLayerRegionHeightInSamplesY, PhaseVerY shall be equal to 0, and when ScaledRefRegionHeightInSamplesC is equal to RefLayerRegionHeightInSamplesC, PhaseVerC shall be equal to 0. 1190 Int phaseHorLuma = pcSlice->getPPS()->getPhaseHorLuma(refLayerIdc); 1191 Int phaseVerLuma = pcSlice->getPPS()->getPhaseVerLuma(refLayerIdc); 1192 Int phaseHorChroma = pcSlice->getPPS()->getPhaseHorChroma(refLayerIdc); 1193 Int phaseVerChroma = pcSlice->getPPS()->getPhaseVerChroma(refLayerIdc); 1194 assert( ( (widthEL != widthBL) || (phaseHorLuma == 0 && phaseHorChroma == 0) ) 1195 && ( (heightEL != heightBL) || (phaseVerLuma == 0 && phaseVerChroma == 0) ) ); 1196 #endif 1197 #endif 1198 #endif 1147 1199 1148 1200 g_mvScalingFactor[refLayerIdc][0] = widthEL == widthBL ? 4096 : Clip3(-4096, 4095, ((widthEL << 8) + (widthBL >> 1)) / widthBL); … … 1156 1208 if( pcSlice->getPPS()->getCGSFlag() ) 1157 1209 { 1210 #if R0150_CGS_SIGNAL_CONSTRAINTS 1211 // all reference layers are currently taken as CGS reference layers 1212 m_Enc3DAsymLUTPPS.addRefLayerId( pcSlice->getVPS()->getRefLayerId(m_layerId, refLayerIdc) ); 1213 m_Enc3DAsymLUTPicUpdate.addRefLayerId( pcSlice->getVPS()->getRefLayerId(m_layerId, refLayerIdc) ); 1214 #endif 1158 1215 if(g_posScalingFactor[refLayerIdc][0] < (1<<16) || g_posScalingFactor[refLayerIdc][1] < (1<<16)) //if(pcPic->isSpatialEnhLayer(refLayerIdc)) 1159 1216 { … … 1207 1264 #if O0194_JOINT_US_BITSHIFT 1208 1265 #if Q0048_CGS_3D_ASYMLUT 1209 m_pcPredSearch->upsampleBasePic( pcSlice, refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, pcPic->getPicYuvRec(), scalEL ); 1210 #else 1211 m_pcPredSearch->upsampleBasePic( pcSlice, refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), pcPic->getPicYuvRec(), scalEL ); 1266 #if REF_REGION_OFFSET 1267 m_pcPredSearch->upsampleBasePic( pcSlice, refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, pcPic->getPicYuvRec(), scalEL, altRL ); 1268 #else 1269 m_pcPredSearch->upsampleBasePic( pcSlice, refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, pcPic->getPicYuvRec(), scalEL ); 1270 #endif 1271 #else 1272 m_pcPredSearch->upsampleBasePic( pcSlice, refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), pcPic->getPicYuvRec(), scalEL ); 1212 1273 #endif 1213 1274 #else … … 1270 1331 } 1271 1332 } 1272 1333 #if ISLICE_TYPE_NUMDIR 1334 if( pcSlice->getActiveNumILRRefIdx() == 0 && pcSlice->getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP && pcSlice->getNalUnitType() <= NAL_UNIT_CODED_SLICE_CRA && (m_pcEncTop->getNumDirectRefLayers() == 0) ) 1335 #else 1273 1336 if( pcSlice->getActiveNumILRRefIdx() == 0 && pcSlice->getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP && pcSlice->getNalUnitType() <= NAL_UNIT_CODED_SLICE_CRA ) 1337 #endif 1274 1338 { 1275 1339 pcSlice->setSliceType(I_SLICE); … … 1395 1459 if(pcSlice->isTemporalLayerSwitchingPoint(rcListPic) || pcSlice->getSPS()->getTemporalIdNestingFlag()) 1396 1460 { 1397 #if !Q0108_TSA_STSA1461 #if SVC_EXTENSION && !Q0108_TSA_STSA 1398 1462 if( pcSlice->getLayerId() > 0 ) 1399 1463 { … … 1494 1558 if(isSTSA==true) 1495 1559 { 1496 #if !Q0108_TSA_STSA1560 #if SVC_EXTENSION && !Q0108_TSA_STSA 1497 1561 if( pcSlice->getLayerId() > 0 ) 1498 1562 { … … 1563 1627 } 1564 1628 } 1629 1630 arrangeLongtermPicturesInRPS(pcSlice, rcListPic); 1631 TComRefPicListModification* refPicListModification = pcSlice->getRefPicListModification(); 1632 refPicListModification->setRefPicListModificationFlagL0(0); 1633 refPicListModification->setRefPicListModificationFlagL1(0); 1634 pcSlice->setNumRefIdx(REF_PIC_LIST_0,min(m_pcCfg->getGOPEntry(iGOPid).m_numRefPicsActive,pcSlice->getRPS()->getNumberOfPictures())); 1635 pcSlice->setNumRefIdx(REF_PIC_LIST_1,min(m_pcCfg->getGOPEntry(iGOPid).m_numRefPicsActive,pcSlice->getRPS()->getNumberOfPictures())); 1636 1637 #if SVC_EXTENSION 1638 if( m_layerId > 0 && pcSlice->getActiveNumILRRefIdx() ) 1639 { 1640 #if POC_RESET_FLAG || POC_RESET_IDC_ENCODER 1641 if ( pocCurr > 0 && pcSlice->isRADL() && pcPic->getSlice(0)->getBaseColPic(pcPic->getSlice(0)->getInterLayerPredLayerIdc(0))->getSlice(0)->isRASL()) 1642 #else 1643 if (pcSlice->getPOC()>0 && pcSlice->isRADL() && pcPic->getSlice(0)->getBaseColPic(pcPic->getSlice(0)->getInterLayerPredLayerIdc(0))->getSlice(0)->isRASL()) 1644 #endif 1645 { 1646 pcSlice->setActiveNumILRRefIdx(0); 1647 pcSlice->setInterLayerPredEnabledFlag(0); 1648 } 1649 if( pcSlice->getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP && pcSlice->getNalUnitType() <= NAL_UNIT_CODED_SLICE_CRA ) 1650 { 1651 pcSlice->setNumRefIdx(REF_PIC_LIST_0, pcSlice->getActiveNumILRRefIdx()); 1652 pcSlice->setNumRefIdx(REF_PIC_LIST_1, pcSlice->getActiveNumILRRefIdx()); 1653 } 1654 else 1655 { 1656 pcSlice->setNumRefIdx(REF_PIC_LIST_0, pcSlice->getNumRefIdx(REF_PIC_LIST_0)+pcSlice->getActiveNumILRRefIdx()); 1657 pcSlice->setNumRefIdx(REF_PIC_LIST_1, pcSlice->getNumRefIdx(REF_PIC_LIST_1)+pcSlice->getActiveNumILRRefIdx()); 1658 } 1659 1660 // check for the reference pictures whether there is at least one either temporal picture or ILRP with sample prediction type 1661 if( pcSlice->getNumRefIdx( REF_PIC_LIST_0 ) - pcSlice->getActiveNumILRRefIdx() == 0 && pcSlice->getNumRefIdx( REF_PIC_LIST_1 ) - pcSlice->getActiveNumILRRefIdx() == 0 ) 1662 { 1663 Bool foundSamplePredPicture = false; 1664 1665 for( Int i = 0; i < pcSlice->getActiveNumILRRefIdx(); i++ ) 1666 { 1667 if( m_ppcTEncTop[m_layerId]->getSamplePredEnabledFlag( pcSlice->getVPS()->getRefLayerId( m_layerId, pcSlice->getInterLayerPredLayerIdc(i) ) ) ) 1668 { 1669 foundSamplePredPicture = true; 1670 break; 1671 } 1672 } 1673 1674 if( !foundSamplePredPicture ) 1675 { 1676 pcSlice->setSliceType(I_SLICE); 1677 pcSlice->setInterLayerPredEnabledFlag(0); 1678 pcSlice->setActiveNumILRRefIdx(0); 1679 } 1680 } 1681 } 1682 #endif //SVC_EXTENSION 1683 1565 1684 #if Q0108_TSA_STSA 1566 else if( ( pcSlice->getTLayer() == 0 && pcSlice->getLayerId() > 0) // only for enhancement layer and with temporal layer 01567 1685 if( ( pcSlice->getTLayer() == 0 && pcSlice->getLayerId() > 0 ) // only for enhancement layer and with temporal layer 0 1686 && !( pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_RADL_N 1568 1687 || pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_RADL_R 1569 1688 || pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N … … 1576 1695 { 1577 1696 Bool isSTSA=true; 1697 Bool isIntra=false; 1698 1699 for( Int i = 0; i < pcSlice->getLayerId(); i++) 1700 { 1701 TComList<TComPic *> *cListPic = m_ppcTEncTop[i]->getListPic(); 1702 TComPic *lowerLayerPic = pcSlice->getRefPic(*cListPic, pcSlice->getPOC()); 1703 if( lowerLayerPic && pcSlice->getVPS()->getDirectDependencyFlag(pcSlice->getLayerId(), i) ) 1704 { 1705 if( lowerLayerPic->getSlice(0)->getSliceType() == I_SLICE) 1706 { 1707 isIntra = true; 1708 } 1709 } 1710 } 1711 1578 1712 for(Int ii=iGOPid+1; ii < m_pcCfg->getGOPSize() && isSTSA; ii++) 1579 1713 { … … 1605 1739 } 1606 1740 } 1607 if(isSTSA==true )1741 if(isSTSA==true && isIntra == false) 1608 1742 { 1609 #if !Q0108_TSA_STSA1610 if( pcSlice->getLayerId() > 0 )1611 {1612 Bool oneRefLayerSTSA = false, oneRefLayerNotSTSA = false;1613 for( Int i = 0; i < pcSlice->getLayerId(); i++)1614 {1615 TComList<TComPic *> *cListPic = m_ppcTEncTop[i]->getListPic();1616 TComPic *lowerLayerPic = pcSlice->getRefPic(*cListPic, pcSlice->getPOC());1617 if( lowerLayerPic && pcSlice->getVPS()->getDirectDependencyFlag(pcSlice->getLayerId(), i) )1618 {1619 if( ( lowerLayerPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_STSA_N ) ||1620 ( lowerLayerPic->getSlice(0)->getNalUnitType() == NAL_UNIT_CODED_SLICE_STSA_R )1621 )1622 {1623 if(pcSlice->getTemporalLayerNonReferenceFlag() )1624 {1625 pcSlice->setNalUnitType(NAL_UNIT_CODED_SLICE_STSA_N);1626 }1627 else1628 {1629 pcSlice->setNalUnitType(NAL_UNIT_CODED_SLICE_STSA_R );1630 }1631 oneRefLayerSTSA = true;1632 }1633 else1634 {1635 oneRefLayerNotSTSA = true;1636 }1637 }1638 }1639 assert( !( oneRefLayerNotSTSA && oneRefLayerSTSA ) ); // Only one variable should be true - failure of this assert means1640 // that two independent reference layers that are not dependent on1641 // each other, but are reference for current layer have inconsistency1642 if( oneRefLayerNotSTSA /*&& !oneRefLayerSTSA*/ ) // No reference layer is STSA - set current as TRAIL1643 {1644 if(pcSlice->getTemporalLayerNonReferenceFlag() )1645 {1646 pcSlice->setNalUnitType( NAL_UNIT_CODED_SLICE_TRAIL_N );1647 }1648 else1649 {1650 pcSlice->setNalUnitType( NAL_UNIT_CODED_SLICE_TRAIL_R );1651 }1652 }1653 else // This means there is no reference layer picture for current picture in this AU1654 {1655 if(pcSlice->getTemporalLayerNonReferenceFlag() )1656 {1657 pcSlice->setNalUnitType(NAL_UNIT_CODED_SLICE_STSA_N);1658 }1659 else1660 {1661 pcSlice->setNalUnitType(NAL_UNIT_CODED_SLICE_STSA_R );1662 }1663 }1664 }1665 #else1666 1743 if(pcSlice->getTemporalLayerNonReferenceFlag()) 1667 1744 { 1668 1745 pcSlice->setNalUnitType(NAL_UNIT_CODED_SLICE_STSA_N); 1669 flagTSTA = 1;1670 1746 } 1671 1747 else 1672 1748 { 1673 1749 pcSlice->setNalUnitType(NAL_UNIT_CODED_SLICE_STSA_R); 1674 flagTSTA = 1; 1675 } 1676 #endif 1677 } 1678 } 1679 #endif 1680 1681 arrangeLongtermPicturesInRPS(pcSlice, rcListPic); 1682 TComRefPicListModification* refPicListModification = pcSlice->getRefPicListModification(); 1683 refPicListModification->setRefPicListModificationFlagL0(0); 1684 refPicListModification->setRefPicListModificationFlagL1(0); 1685 pcSlice->setNumRefIdx(REF_PIC_LIST_0,min(m_pcCfg->getGOPEntry(iGOPid).m_numRefPicsActive,pcSlice->getRPS()->getNumberOfPictures())); 1686 pcSlice->setNumRefIdx(REF_PIC_LIST_1,min(m_pcCfg->getGOPEntry(iGOPid).m_numRefPicsActive,pcSlice->getRPS()->getNumberOfPictures())); 1687 1688 #if SVC_EXTENSION 1689 if( m_layerId > 0 && pcSlice->getActiveNumILRRefIdx() ) 1690 { 1691 #if POC_RESET_FLAG || POC_RESET_IDC_ENCODER 1692 if ( pocCurr > 0 && pcSlice->isRADL() && pcPic->getSlice(0)->getBaseColPic(pcPic->getSlice(0)->getInterLayerPredLayerIdc(0))->getSlice(0)->isRASL()) 1693 #else 1694 if (pcSlice->getPOC()>0 && pcSlice->isRADL() && pcPic->getSlice(0)->getBaseColPic(pcPic->getSlice(0)->getInterLayerPredLayerIdc(0))->getSlice(0)->isRASL()) 1695 #endif 1696 { 1697 pcSlice->setActiveNumILRRefIdx(0); 1698 pcSlice->setInterLayerPredEnabledFlag(0); 1699 } 1700 #if Q0108_TSA_STSA 1701 if( ( pcSlice->getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP && pcSlice->getNalUnitType() <= NAL_UNIT_CODED_SLICE_CRA ) || flagTSTA == 1 ) 1702 #else 1703 if( pcSlice->getNalUnitType() >= NAL_UNIT_CODED_SLICE_BLA_W_LP && pcSlice->getNalUnitType() <= NAL_UNIT_CODED_SLICE_CRA ) 1704 #endif 1705 { 1706 pcSlice->setNumRefIdx(REF_PIC_LIST_0, pcSlice->getActiveNumILRRefIdx()); 1707 pcSlice->setNumRefIdx(REF_PIC_LIST_1, pcSlice->getActiveNumILRRefIdx()); 1708 } 1709 else 1710 { 1711 pcSlice->setNumRefIdx(REF_PIC_LIST_0, pcSlice->getNumRefIdx(REF_PIC_LIST_0)+pcSlice->getActiveNumILRRefIdx()); 1712 pcSlice->setNumRefIdx(REF_PIC_LIST_1, pcSlice->getNumRefIdx(REF_PIC_LIST_1)+pcSlice->getActiveNumILRRefIdx()); 1713 } 1714 1715 // check for the reference pictures whether there is at least one either temporal picture or ILRP with sample prediction type 1716 if( pcSlice->getNumRefIdx( REF_PIC_LIST_0 ) - pcSlice->getActiveNumILRRefIdx() == 0 && pcSlice->getNumRefIdx( REF_PIC_LIST_1 ) - pcSlice->getActiveNumILRRefIdx() == 0 ) 1717 { 1718 Bool foundSamplePredPicture = false; 1719 1720 for( Int i = 0; i < pcSlice->getActiveNumILRRefIdx(); i++ ) 1721 { 1722 if( m_ppcTEncTop[m_layerId]->getSamplePredEnabledFlag( pcSlice->getVPS()->getRefLayerId( m_layerId, pcSlice->getInterLayerPredLayerIdc(i) ) ) ) 1723 { 1724 foundSamplePredPicture = true; 1725 break; 1726 } 1727 } 1728 1729 if( !foundSamplePredPicture ) 1730 { 1731 pcSlice->setSliceType(I_SLICE); 1732 pcSlice->setInterLayerPredEnabledFlag(0); 1733 pcSlice->setActiveNumILRRefIdx(0); 1734 } 1735 } 1736 } 1737 #endif //SVC_EXTENSION 1750 } 1751 } 1752 } 1753 #endif 1738 1754 1739 1755 #if ADAPTIVE_QP_SELECTION … … 1750 1766 if(m_layerId == 0 || ( m_layerId > 0 && pcSlice->getActiveNumILRRefIdx() == 0 ) ) 1751 1767 { 1752 pcSlice->setRefPicList( rcListPic );1768 pcSlice->setRefPicList( rcListPic ); 1753 1769 } 1754 1770 … … 1756 1772 { 1757 1773 pcSlice->setILRPic( m_pcEncTop->getIlpList() ); 1758 #if REF_IDX_MFM 1759 if( pcSlice->getMFMEnabledFlag() ) 1760 { 1761 pcSlice->setRefPOCListILP(m_pcEncTop->getIlpList(), pcSlice->getBaseColPic()); 1762 } 1763 #else 1774 #if !REF_IDX_MFM 1764 1775 // Set reference list 1765 1776 pcSlice->setRefPicList ( rcListPic ); … … 2110 2121 UInt uiRealEndAddress = uiExternalAddress*pcPic->getNumPartInCU()+uiInternalAddress; 2111 2122 2112 UInt uiCummulativeTileWidth;2113 UInt uiCummulativeTileHeight;2114 2123 Int p, j; 2115 2124 UInt uiEncCUAddr; 2116 2125 2117 //set NumColumnsMinus1 and NumRowsMinus1 2118 pcPic->getPicSym()->setNumColumnsMinus1( pcSlice->getPPS()->getNumColumnsMinus1() ); 2119 pcPic->getPicSym()->setNumRowsMinus1( pcSlice->getPPS()->getNumRowsMinus1() ); 2120 2121 //create the TComTileArray 2122 pcPic->getPicSym()->xCreateTComTileArray(); 2123 2124 if( pcSlice->getPPS()->getUniformSpacingFlag() == 1 ) 2125 { 2126 //set the width for each tile 2127 for(j=0; j < pcPic->getPicSym()->getNumRowsMinus1()+1; j++) 2128 { 2129 for(p=0; p < pcPic->getPicSym()->getNumColumnsMinus1()+1; p++) 2130 { 2131 pcPic->getPicSym()->getTComTile( j * (pcPic->getPicSym()->getNumColumnsMinus1()+1) + p )-> 2132 setTileWidth( (p+1)*pcPic->getPicSym()->getFrameWidthInCU()/(pcPic->getPicSym()->getNumColumnsMinus1()+1) 2133 - (p*pcPic->getPicSym()->getFrameWidthInCU())/(pcPic->getPicSym()->getNumColumnsMinus1()+1) ); 2134 } 2135 } 2136 2137 //set the height for each tile 2138 for(j=0; j < pcPic->getPicSym()->getNumColumnsMinus1()+1; j++) 2139 { 2140 for(p=0; p < pcPic->getPicSym()->getNumRowsMinus1()+1; p++) 2141 { 2142 pcPic->getPicSym()->getTComTile( p * (pcPic->getPicSym()->getNumColumnsMinus1()+1) + j )-> 2143 setTileHeight( (p+1)*pcPic->getPicSym()->getFrameHeightInCU()/(pcPic->getPicSym()->getNumRowsMinus1()+1) 2144 - (p*pcPic->getPicSym()->getFrameHeightInCU())/(pcPic->getPicSym()->getNumRowsMinus1()+1) ); 2145 } 2146 } 2147 } 2148 else 2149 { 2150 //set the width for each tile 2151 for(j=0; j < pcPic->getPicSym()->getNumRowsMinus1()+1; j++) 2152 { 2153 uiCummulativeTileWidth = 0; 2154 for(p=0; p < pcPic->getPicSym()->getNumColumnsMinus1(); p++) 2155 { 2156 pcPic->getPicSym()->getTComTile( j * (pcPic->getPicSym()->getNumColumnsMinus1()+1) + p )->setTileWidth( pcSlice->getPPS()->getColumnWidth(p) ); 2157 uiCummulativeTileWidth += pcSlice->getPPS()->getColumnWidth(p); 2158 } 2159 pcPic->getPicSym()->getTComTile(j * (pcPic->getPicSym()->getNumColumnsMinus1()+1) + p)->setTileWidth( pcPic->getPicSym()->getFrameWidthInCU()-uiCummulativeTileWidth ); 2160 } 2161 2162 //set the height for each tile 2163 for(j=0; j < pcPic->getPicSym()->getNumColumnsMinus1()+1; j++) 2164 { 2165 uiCummulativeTileHeight = 0; 2166 for(p=0; p < pcPic->getPicSym()->getNumRowsMinus1(); p++) 2167 { 2168 pcPic->getPicSym()->getTComTile( p * (pcPic->getPicSym()->getNumColumnsMinus1()+1) + j )->setTileHeight( pcSlice->getPPS()->getRowHeight(p) ); 2169 uiCummulativeTileHeight += pcSlice->getPPS()->getRowHeight(p); 2170 } 2171 pcPic->getPicSym()->getTComTile(p * (pcPic->getPicSym()->getNumColumnsMinus1()+1) + j)->setTileHeight( pcPic->getPicSym()->getFrameHeightInCU()-uiCummulativeTileHeight ); 2172 } 2173 } 2174 //intialize each tile of the current picture 2175 pcPic->getPicSym()->xInitTiles(); 2126 pcPic->getPicSym()->initTiles(pcSlice->getPPS()); 2176 2127 2177 2128 #if N0383_IL_CONSTRAINED_TILE_SETS_SEI … … 2183 2134 2184 2135 // Allocate some coders, now we know how many tiles there are. 2136 #if WPP_FIX 2137 const Int iNumSubstreams = pcSlice->getPPS()->getNumSubstreams(); 2138 #else 2185 2139 Int iNumSubstreams = pcSlice->getPPS()->getNumSubstreams(); 2140 #endif 2186 2141 2187 2142 //generate the Coding Order Map and Inverse Coding Order Map … … 2215 2170 startCUAddrSliceSegmentIdx++; 2216 2171 #if AVC_BASE 2172 #if VPS_AVC_BL_FLAG_REMOVAL 2173 if( m_layerId == 0 && m_pcEncTop->getVPS()->getNonHEVCBaseLayerFlag() ) 2174 #else 2217 2175 if( m_layerId == 0 && m_pcEncTop->getVPS()->getAvcBaseLayerFlag() ) 2176 #endif 2218 2177 { 2219 2178 pcPic->getPicYuvOrg()->copyToPic( pcPic->getPicYuvRec() ); … … 2225 2184 } 2226 2185 #endif 2227 #if AVC_SYNTAX 2228 pcPic->readBLSyntax( m_ppcTEncTop[0]->getBLSyntaxFile(), SYNTAX_BYTES ); 2229 #endif 2186 2187 if( pcSubstreamsOut ) 2188 { 2189 delete[] pcSubstreamsOut; 2190 pcSubstreamsOut = NULL; 2191 } 2192 2193 if( pcBitstreamRedirect ) 2194 { 2195 delete pcBitstreamRedirect; 2196 pcBitstreamRedirect = NULL; 2197 } 2198 2230 2199 return; 2231 2200 } … … 2318 2287 OutputNALUnit nalu( NAL_UNIT_VPS, 0, 0 ); // The value of nuh_layer_id of VPS NAL unit shall be equal to 0. 2319 2288 #if AVC_BASE 2289 #if VPS_AVC_BL_FLAG_REMOVAL 2290 if( ( m_layerId == 1 && m_pcEncTop->getVPS()->getNonHEVCBaseLayerFlag() ) || ( m_layerId == 0 && !m_pcEncTop->getVPS()->getNonHEVCBaseLayerFlag() ) ) 2291 #else 2320 2292 if( ( m_layerId == 1 && m_pcEncTop->getVPS()->getAvcBaseLayerFlag() ) || ( m_layerId == 0 && !m_pcEncTop->getVPS()->getAvcBaseLayerFlag() ) ) 2293 #endif 2321 2294 #else 2322 2295 if( m_layerId == 0 ) … … 2418 2391 if (pcSlice->getLayerId() == 0 && m_pcEncTop->getVPS()->getVpsVuiBspHrdPresentFlag()) 2419 2392 { 2420 nalu = NALUnit(NAL_UNIT_PREFIX_SEI, 0, 1); 2421 m_pcEntropyCoder->setEntropyCoder(m_pcCavlcCoder, pcSlice); 2422 m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream); 2423 SEIScalableNesting *scalableBspNestingSei = xCreateBspNestingSEI(pcSlice); 2424 m_seiWriter.writeSEImessage(nalu.m_Bitstream, *scalableBspNestingSei, m_pcEncTop->getVPS(), pcSlice->getSPS()); 2425 writeRBSPTrailingBits(nalu.m_Bitstream); 2426 2427 UInt seiPositionInAu = xGetFirstSeiLocation(accessUnit); 2428 UInt offsetPosition = m_activeParameterSetSEIPresentInAU 2429 + m_bufferingPeriodSEIPresentInAU 2430 + m_pictureTimingSEIPresentInAU 2431 + m_nestedPictureTimingSEIPresentInAU; // Insert SEI after APS, BP and PT SEI 2432 AccessUnit::iterator it; 2433 for(j = 0, it = accessUnit.begin(); j < seiPositionInAu + offsetPosition; j++) 2434 { 2435 it++; 2436 } 2437 accessUnit.insert(it, new NALUnitEBSP(nalu)); 2393 #if VPS_VUI_BSP_HRD_PARAMS 2394 TComVPS *vps = m_pcEncTop->getVPS(); 2395 for(Int i = 0; i < vps->getNumOutputLayerSets(); i++) 2396 { 2397 for(Int k = 0; k < vps->getNumSignalledPartitioningSchemes(i); k++) 2398 { 2399 for(Int l = 0; l < vps->getNumPartitionsInSchemeMinus1(i, k)+1; l++) 2400 { 2401 #endif 2402 nalu = NALUnit(NAL_UNIT_PREFIX_SEI, 0, 1); 2403 m_pcEntropyCoder->setEntropyCoder(m_pcCavlcCoder, pcSlice); 2404 m_pcEntropyCoder->setBitstream(&nalu.m_Bitstream); 2405 #if VPS_VUI_BSP_HRD_PARAMS 2406 SEIScalableNesting *scalableBspNestingSei = xCreateBspNestingSEI(pcSlice, i, k, l); 2407 #else 2408 SEIScalableNesting *scalableBspNestingSei = xCreateBspNestingSEI(pcSlice); 2409 #endif 2410 m_seiWriter.writeSEImessage(nalu.m_Bitstream, *scalableBspNestingSei, m_pcEncTop->getVPS(), pcSlice->getSPS()); 2411 writeRBSPTrailingBits(nalu.m_Bitstream); 2412 2413 UInt seiPositionInAu = xGetFirstSeiLocation(accessUnit); 2414 UInt offsetPosition = m_activeParameterSetSEIPresentInAU 2415 + m_bufferingPeriodSEIPresentInAU 2416 + m_pictureTimingSEIPresentInAU 2417 + m_nestedPictureTimingSEIPresentInAU; // Insert SEI after APS, BP and PT SEI 2418 AccessUnit::iterator it; 2419 for(j = 0, it = accessUnit.begin(); j < seiPositionInAu + offsetPosition; j++) 2420 { 2421 it++; 2422 } 2423 accessUnit.insert(it, new NALUnitEBSP(nalu)); 2424 #if VPS_VUI_BSP_HRD_PARAMS 2425 } 2426 } 2427 } 2428 #endif 2438 2429 } 2439 2430 #endif … … 2842 2833 2843 2834 #if SETTING_NO_OUT_PIC_PRIOR 2835 pcSlice->setNoRaslOutputFlag(false); 2844 2836 if (pcSlice->isIRAP()) 2845 2837 { … … 2849 2841 } 2850 2842 //the inference for NoOutputPriorPicsFlag 2843 // KJS: This cannot happen at the encoder 2851 2844 if (!m_bFirst && pcSlice->isIRAP() && pcSlice->getNoRaslOutputFlag()) 2852 2845 { … … 2876 2869 m_pcEntropyCoder->setEntropyCoder ( m_pcSbacCoder, pcSlice ); 2877 2870 m_pcEntropyCoder->resetEntropy (); 2871 #if WPP_FIX 2872 for ( UInt ui = 0 ; ui < iNumSubstreams ; ui++ ) 2873 #else 2878 2874 for ( UInt ui = 0 ; ui < pcSlice->getPPS()->getNumSubstreams() ; ui++ ) 2875 #endif 2879 2876 { 2880 2877 m_pcEntropyCoder->setEntropyCoder ( &pcSbacCoders[ui], pcSlice ); … … 2888 2885 m_pcSbacCoder->init( (TEncBinIf*)m_pcBinCABAC ); 2889 2886 { 2887 #if WPP_FIX 2888 for ( UInt ui = 0 ; ui < iNumSubstreams ; ui++ ) 2889 #else 2890 2890 for ( UInt ui = 0 ; ui < pcSlice->getPPS()->getNumSubstreams() ; ui++ ) 2891 #endif 2891 2892 { 2892 2893 m_pcEntropyCoder->setEntropyCoder ( &pcSbacCoders[ui], pcSlice ); … … 2915 2916 2916 2917 pcSlice->setTileOffstForMultES( uiOneBitstreamPerSliceLength ); 2917 2918 pcSlice->setTileLocationCount ( 0 ); 2918 2919 m_pcSliceEncoder->encodeSlice(pcPic, pcSubstreamsOut); 2919 2920 … … 2942 2943 2943 2944 Bool bNextSubstreamInNewTile = ((ui+1) < iNumSubstreams)&& ((ui+1)%uiNumSubstreamsPerTile == 0); 2945 #if WPP_FIX 2946 if (bNextSubstreamInNewTile && !pcSlice->getPPS()->getEntropyCodingSyncEnabledFlag() ) 2947 #else 2944 2948 if (bNextSubstreamInNewTile) 2949 #endif 2945 2950 { 2946 2951 pcSlice->setTileLocation(ui/uiNumSubstreamsPerTile, pcSlice->getTileOffstForMultES()+(uiTotalCodedSize>>3)); 2947 2952 } 2953 #if WPP_FIX 2954 if (ui+1 < iNumSubstreams) 2955 { 2956 puiSubstreamSizes[ui] = pcSubstreamsOut[ui].getNumberOfWrittenBits() + (pcSubstreamsOut[ui].countStartCodeEmulations()<<3); 2957 } 2958 #else 2948 2959 if (ui+1 < pcSlice->getPPS()->getNumSubstreams()) 2949 2960 { 2950 2961 puiSubstreamSizes[ui] = pcSubstreamsOut[ui].getNumberOfWrittenBits() + (pcSubstreamsOut[ui].countStartCodeEmulations()<<3); 2951 2962 } 2963 #endif 2952 2964 } 2953 2965 … … 2966 2978 // Substreams... 2967 2979 TComOutputBitstream *pcOut = pcBitstreamRedirect; 2968 Int offs = 0; 2980 #if WPP_FIX 2981 Int numZeroSubstreamsAtStartOfSlice = 0; 2982 Int numSubstreamsToCode = pcSlice->getPPS()->getNumSubstreams(); 2983 if (pcSlice->getPPS()->getEntropyCodingSyncEnabledFlag()) 2984 { 2985 Int maxNumParts = pcPic->getNumPartInCU(); 2986 numZeroSubstreamsAtStartOfSlice = pcPic->getSubstreamForLCUAddr(pcSlice->getSliceSegmentCurStartCUAddr()/maxNumParts, false, pcSlice); 2987 // 1st line present for WPP. 2988 numSubstreamsToCode = pcSlice->getNumEntryPointOffsets()+1; 2989 } 2990 for ( UInt ui = 0 ; ui < numSubstreamsToCode; ui++ ) 2991 { 2992 pcOut->addSubstream(&pcSubstreamsOut[ui+numZeroSubstreamsAtStartOfSlice]); 2993 } 2994 #else 2995 Int offs = 0; 2969 2996 Int nss = pcSlice->getPPS()->getNumSubstreams(); 2970 2997 if (pcSlice->getPPS()->getEntropyCodingSyncEnabledFlag()) … … 2978 3005 pcOut->addSubstream(&pcSubstreamsOut[ui+offs]); 2979 3006 } 3007 #endif 2980 3008 } 2981 3009 … … 3396 3424 pcPicYuvRecOut->setReconstructed(true); 3397 3425 #endif 3398 3426 #if P0297_VPS_POC_LSB_ALIGNED_FLAG 3427 m_pcEncTop->setFirstPicInLayerDecodedFlag(true); 3428 #endif 3399 3429 pcPic->setReconMark ( true ); 3400 3430 m_bFirst = false; … … 3455 3485 // If BL picture in the AU is IDR, and another picture is not IDR, set the poc_reset_idc to 2 3456 3486 // If BL picture is IRAP, and another picture is non-IRAP, then the poc_reset_idc is equal to 1 or 2. 3487 #if P0297_VPS_POC_LSB_ALIGNED_FLAG 3488 slice->setPocMsbNeeded(false); 3489 #endif 3457 3490 if( slice->getSliceIdx() == 0 ) // First slice - compute, copy for other slices 3458 3491 { … … 3514 3547 { 3515 3548 slice->setPocResetIdc( 2 ); // Full reset needed 3549 #if P0297_VPS_POC_LSB_ALIGNED_FLAG 3550 if (slice->getVPS()->getVpsPocLsbAlignedFlag() && slice->getVPS()->getNumDirectRefLayers(slice->getLayerId()) == 0) 3551 { 3552 slice->setPocMsbNeeded(true); // Force msb writing 3553 } 3554 #endif 3516 3555 } 3517 3556 else … … 3530 3569 Int periodId = rand() % 64; 3531 3570 m_lastPocPeriodId = (periodId == m_lastPocPeriodId) ? (periodId + 1) % 64 : periodId ; 3571 3572 #if P0297_VPS_POC_LSB_ALIGNED_FLAG 3573 for (UInt i = 0; i < MAX_LAYERS; i++) 3574 { 3575 m_ppcTEncTop[i]->setPocDecrementedInDPBFlag(false); 3576 } 3577 #endif 3532 3578 } 3533 3579 else … … 3546 3592 Void TEncGOP::updatePocValuesOfPics(Int const pocCurr, TComSlice *const slice) 3547 3593 { 3594 #if P0297_VPS_POC_LSB_ALIGNED_FLAG 3595 UInt affectedLayerList[MAX_NUM_LAYER_IDS]; 3596 Int numAffectedLayers; 3597 3598 affectedLayerList[0] = m_layerId; 3599 numAffectedLayers = 1; 3600 3601 if (m_pcEncTop->getVPS()->getVpsPocLsbAlignedFlag()) 3602 { 3603 for (UInt j = 0; j < m_pcEncTop->getVPS()->getNumPredictedLayers(m_layerId); j++) 3604 { 3605 affectedLayerList[j + 1] = m_pcEncTop->getVPS()->getPredictedLayerId(m_layerId, j); 3606 } 3607 numAffectedLayers = m_pcEncTop->getVPS()->getNumPredictedLayers(m_layerId) + 1; 3608 } 3609 #endif 3548 3610 3549 3611 Int pocAdjustValue = pocCurr - m_pcEncTop->getPocAdjustmentValue(); … … 3553 3615 3554 3616 maxPocLsb = 1 << slice->getSPS()->getBitsForPOC(); 3617 3618 #if P0297_VPS_POC_LSB_ALIGNED_FLAG 3619 Int adjustedPocValue = pocCurr; 3620 3621 if (m_pcEncTop->getFirstPicInLayerDecodedFlag()) 3622 { 3623 #endif 3624 3555 3625 pocLsbVal = (slice->getPocResetIdc() == 3) 3556 3626 ? slice->getPocLsbVal() … … 3561 3631 : 0; 3562 3632 deltaPocVal = pocMsbDelta + pocLsbDelta; 3563 3633 3634 #if P0297_VPS_POC_LSB_ALIGNED_FLAG 3635 Int origDeltaPocVal = deltaPocVal; // original value needed when updating POC adjustment value 3636 3637 if (slice->getPocMsbNeeded()) // IDR picture in base layer, non-IDR picture in other layers, poc_lsb_aligned_flag = 1 3638 { 3639 if (slice->getLayerId() == 0) 3640 { 3641 Int highestPoc = INT_MIN; 3642 // Find greatest POC in DPB for layer 0 3643 for (TComList<TComPic*>::iterator iterPic = m_pcEncTop->getListPic()->begin(); iterPic != m_pcEncTop->getListPic()->end(); ++iterPic) 3644 { 3645 TComPic *dpbPic = *iterPic; 3646 if (dpbPic->getReconMark() && dpbPic->getLayerId() == 0 && dpbPic->getPOC() > highestPoc) 3647 { 3648 highestPoc = dpbPic->getPOC(); 3649 } 3650 } 3651 deltaPocVal = (highestPoc - (highestPoc & (maxPocLsb - 1))) + 1*maxPocLsb; 3652 m_pcEncTop->setCurrPocMsb(deltaPocVal); 3653 } 3654 else 3655 { 3656 deltaPocVal = m_ppcTEncTop[0]->getCurrPocMsb(); // copy from base layer 3657 } 3658 slice->setPocMsbVal(deltaPocVal); 3659 } 3660 #endif 3661 3662 #if P0297_VPS_POC_LSB_ALIGNED_FLAG 3663 for (UInt layerIdx = 0; layerIdx < numAffectedLayers; layerIdx++) 3664 { 3665 if (!m_ppcTEncTop[affectedLayerList[layerIdx]]->getPocDecrementedInDPBFlag()) 3666 { 3667 m_ppcTEncTop[affectedLayerList[layerIdx]]->setPocDecrementedInDPBFlag(true); 3668 3669 // Decrement value of associatedIrapPoc of the TEncGop object 3670 m_ppcTEncTop[affectedLayerList[layerIdx]]->getGOPEncoder()->m_associatedIRAPPOC -= deltaPocVal; 3671 3672 // Decrememnt the value of m_pocCRA 3673 m_ppcTEncTop[affectedLayerList[layerIdx]]->getGOPEncoder()->m_pocCRA -= deltaPocVal; 3674 3675 TComList<TComPic*>::iterator iterPic = m_ppcTEncTop[affectedLayerList[layerIdx]]->getListPic()->begin(); 3676 while (iterPic != m_ppcTEncTop[affectedLayerList[layerIdx]]->getListPic()->end()) 3677 #else 3564 3678 // Decrement value of associatedIrapPoc of the TEncGop object 3565 3679 this->m_associatedIRAPPOC -= deltaPocVal; … … 3571 3685 TComList<TComPic*>::iterator iterPic = getListPic()->begin(); 3572 3686 while( iterPic != getListPic()->end() ) 3687 #endif 3573 3688 { 3574 3689 TComPic *dpbPic = *iterPic; … … 3595 3710 // Update value of associatedIrapPoc of each slice 3596 3711 dpbPicSlice->setAssociatedIRAPPOC( dpbPicSlice->getAssociatedIRAPPOC() - deltaPocVal ); 3712 3713 #if P0297_VPS_POC_LSB_ALIGNED_FLAG 3714 if (slice->getPocMsbNeeded()) 3715 { 3716 // this delta value is needed when computing delta POCs in reference picture set initialization 3717 dpbPicSlice->setPocResetDeltaPoc(dpbPicSlice->getPocResetDeltaPoc() + (deltaPocVal - pocLsbVal)); 3718 } 3719 #endif 3597 3720 } 3598 3721 } 3599 3722 iterPic++; 3600 3723 } 3601 3724 #if P0297_VPS_POC_LSB_ALIGNED_FLAG 3725 } 3726 } 3727 #endif 3728 3602 3729 // Actual POC value before reset 3730 #if P0297_VPS_POC_LSB_ALIGNED_FLAG 3731 adjustedPocValue = pocCurr - m_pcEncTop->getPocAdjustmentValue(); 3732 #else 3603 3733 Int adjustedPocValue = pocCurr - m_pcEncTop->getPocAdjustmentValue(); 3734 #endif 3604 3735 3605 3736 // Set MSB value before reset 3606 3737 Int tempLsbVal = adjustedPocValue & (maxPocLsb - 1); 3607 slice->setPocMsbVal( adjustedPocValue - tempLsbVal); 3738 #if P0297_VPS_POC_LSB_ALIGNED_FLAG 3739 if (!slice->getPocMsbNeeded()) // set poc msb normally if special msb handling is not needed 3740 { 3741 #endif 3742 slice->setPocMsbVal(adjustedPocValue - tempLsbVal); 3743 #if P0297_VPS_POC_LSB_ALIGNED_FLAG 3744 } 3745 #endif 3608 3746 3609 3747 // Set LSB value before reset - this is needed in the case of resetIdc = 2 … … 3611 3749 3612 3750 // Cumulative delta 3751 #if P0297_VPS_POC_LSB_ALIGNED_FLAG 3752 deltaPocVal = origDeltaPocVal; // restore deltaPoc for correct adjustment value update 3753 #endif 3613 3754 m_pcEncTop->setPocAdjustmentValue( m_pcEncTop->getPocAdjustmentValue() + deltaPocVal ); 3755 3756 #if P0297_VPS_POC_LSB_ALIGNED_FLAG 3757 } 3758 #endif 3614 3759 3615 3760 // New LSB value, after reset … … 3738 3883 assert (m_iGopSize > 0); 3739 3884 3740 return;3741 }3742 3743 Void TEncGOP::xInitGOP( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut )3744 {3745 assert( iNumPicRcvd > 0 );3746 // Exception for the first frame3747 if ( iPOCLast == 0 )3748 {3749 m_iGopSize = 1;3750 }3751 else3752 m_iGopSize = m_pcCfg->getGOPSize();3753 3754 assert (m_iGopSize > 0);3755 3756 3885 return; 3757 3886 } … … 4090 4219 { 4091 4220 #if POC_RESET_IDC_ENCODER 4092 printf( "%d(%d)", pcSlice->getRefPOC(RefPicList(iRefList), iRefIndex), pcSlice->getRefPic(RefPicList(iRefList), iRefIndex)->getLayerId() ); 4221 UInt refLayerId = pcSlice->getRefPic(RefPicList(iRefList), iRefIndex)->getLayerId(); 4222 UInt refLayerIdc = pcSlice->getReferenceLayerIdc(refLayerId); 4223 assert( g_posScalingFactor[refLayerIdc][0] ); 4224 assert( g_posScalingFactor[refLayerIdc][1] ); 4225 4226 printf( "%d(%d, {%1.2f, %1.2f}x)", pcSlice->getRefPOC(RefPicList(iRefList), iRefIndex), refLayerId, 65536.0/g_posScalingFactor[refLayerIdc][0], 65536.0/g_posScalingFactor[refLayerIdc][1] ); 4093 4227 #else 4094 4228 printf( "%d(%d)", pcSlice->getRefPOC(RefPicList(iRefList), iRefIndex)-pcSlice->getLastIDR(), pcSlice->getRefPic(RefPicList(iRefList), iRefIndex)->getLayerId() ); … … 4120 4254 if( m_layerId && pcSlice->getPPS()->getCGSFlag() ) 4121 4255 { 4256 #if R0179_ENC_OPT_3DLUT_SIZE 4257 m_Enc3DAsymLUTPicUpdate.update3DAsymLUTParam( &m_Enc3DAsymLUTPPS ); 4258 #else 4259 if( m_Enc3DAsymLUTPPS.getPPSBit() > 0 ) 4260 m_Enc3DAsymLUTPicUpdate.copy3DAsymLUT( &m_Enc3DAsymLUTPPS ); 4261 #endif 4122 4262 m_Enc3DAsymLUTPicUpdate.updatePicCGSBits( pcSlice , m_Enc3DAsymLUTPPS.getPPSBit() ); 4123 4263 } … … 4771 4911 4772 4912 #if O0164_MULTI_LAYER_HRD 4913 #if VPS_VUI_BSP_HRD_PARAMS 4914 SEIScalableNesting* TEncGOP::xCreateBspNestingSEI(TComSlice *pcSlice, Int olsIdx, Int partitioningSchemeIdx, Int bspIdx) 4915 #else 4773 4916 SEIScalableNesting* TEncGOP::xCreateBspNestingSEI(TComSlice *pcSlice) 4917 #endif 4774 4918 { 4775 4919 SEIScalableNesting *seiScalableNesting = new SEIScalableNesting(); … … 4784 4928 seiScalableNesting->m_defaultOpFlag = 0; 4785 4929 seiScalableNesting->m_nestingNumOpsMinus1 = 0; //nesting_num_ops_minus1 4930 #if VPS_VUI_BSP_HRD_PARAMS 4931 seiScalableNesting->m_nestingOpIdx[0] = pcSlice->getVPS()->getOutputLayerSetIdx(olsIdx); 4932 seiScalableNesting->m_nestingMaxTemporalIdPlus1[0] = 6 + 1; 4933 #else 4786 4934 seiScalableNesting->m_nestingOpIdx[0] = 1; 4935 #endif 4787 4936 seiScalableNesting->m_allLayersFlag = 0; 4788 4937 seiScalableNesting->m_nestingNoOpMaxTemporalIdPlus1 = 6 + 1; //nesting_no_op_max_temporal_id_plus1 … … 4830 4979 seiBspNesting->m_nestedSEIs.push_back(seiBufferingPeriod); 4831 4980 seiBspNesting->m_nestedSEIs.push_back(seiBspInitialArrivalTime); 4981 #if VPS_VUI_BSP_HRD_PARAMS 4982 seiBspNesting->m_bspIdx = bspIdx; 4983 seiBspNesting->m_seiOlsIdx = olsIdx; 4984 seiBspNesting->m_seiPartitioningSchemeIdx = partitioningSchemeIdx; 4985 #endif 4832 4986 seiScalableNesting->m_nestedSEIs.push_back(seiBspNesting); // BSP nesting SEI is contained in scalable nesting SEI 4833 4987 … … 4842 4996 m_Enc3DAsymLUTPPS.setPPSBit( 0 ); 4843 4997 Double dErrorUpdatedPPS = 0 , dErrorPPS = 0; 4844 dErrorUpdatedPPS = m_Enc3DAsymLUTPicUpdate.derive3DAsymLUT( pSlice , pCurPic , refLayerIdc , pCfg , bSignalPPS , m_pcEncTop->getElRapSliceTypeB() ); 4998 4999 #if R0179_ENC_OPT_3DLUT_SIZE 5000 Int nTLthres = m_pcCfg->getCGSLutSizeRDO() ? 2:7; 5001 Double dFrameLambda; 5002 #if FULL_NBIT 5003 Int SHIFT_QP = 12 + 6 * (pSlice->getBitDepthY() - 8); 5004 #else 5005 Int SHIFT_QP = 12; 5006 #endif 5007 Int QP = pSlice->getSliceQp(); 5008 5009 // set frame lambda 5010 dFrameLambda = 0.68 * pow (2, (QP - SHIFT_QP) / 3.0) * (m_pcCfg->getGOPSize() > 1 && pSlice->isInterB()? 2 : 1); 5011 5012 if(m_pcCfg->getCGSLutSizeRDO() == 1 && (!bSignalPPS && (pSlice->getDepth() < nTLthres))) 5013 dErrorUpdatedPPS = m_Enc3DAsymLUTPicUpdate.derive3DAsymLUT( pSlice , pCurPic , refLayerIdc , pCfg , bSignalPPS , m_pcEncTop->getElRapSliceTypeB(), dFrameLambda ); 5014 else if (pSlice->getDepth() >= nTLthres) 5015 dErrorUpdatedPPS = MAX_DOUBLE; 5016 else // if (m_pcCfg->getCGSLutSizeRDO() = 0 || bSignalPPS) 5017 #endif 5018 dErrorUpdatedPPS = m_Enc3DAsymLUTPicUpdate.derive3DAsymLUT( pSlice , pCurPic , refLayerIdc , pCfg , bSignalPPS , m_pcEncTop->getElRapSliceTypeB() ); 5019 5020 4845 5021 if( bSignalPPS ) 4846 5022 { … … 4850 5026 else if( nCGSFlag ) 4851 5027 { 4852 dErrorPPS = m_Enc3DAsymLUTPPS.estimateDistWithCur3DAsymLUT( pCurPic , refLayerIdc ); 4853 Double dFactor = pCfg->getIntraPeriod() == 1 ? 0.99 : 0.9; 4854 pSlice->setCGSOverWritePPS( dErrorUpdatedPPS < dFactor * dErrorPPS ); 5028 #if R0179_ENC_OPT_3DLUT_SIZE 5029 if(pSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_R || pSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N) 5030 { 5031 pSlice->setCGSOverWritePPS( 0 ); 5032 } 5033 else if (pSlice->getDepth() >= nTLthres) 5034 { 5035 pSlice->setCGSOverWritePPS( 0 ); 5036 } 5037 else 5038 { 5039 #endif 5040 dErrorPPS = m_Enc3DAsymLUTPPS.estimateDistWithCur3DAsymLUT( pCurPic , refLayerIdc ); 5041 Double dFactor = pCfg->getIntraPeriod() == 1 ? 0.99 : 0.9; 5042 5043 #if R0179_ENC_OPT_3DLUT_SIZE 5044 if( m_pcCfg->getCGSLutSizeRDO() ) 5045 { 5046 dErrorPPS = dErrorPPS/m_Enc3DAsymLUTPicUpdate.getDistFactor(pSlice->getSliceType(), pSlice->getDepth()); 5047 } 5048 #endif 5049 pSlice->setCGSOverWritePPS( dErrorUpdatedPPS < dFactor * dErrorPPS ); 5050 #if R0179_ENC_OPT_3DLUT_SIZE 5051 } 5052 #endif 4855 5053 if( pSlice->getCGSOverWritePPS() ) 4856 5054 { -
trunk/source/Lib/TLibEncoder/TEncGOP.h
r815 r906 207 207 protected: 208 208 209 Void xInitGOP( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut, Bool isField ); 210 Void xInitGOP ( Int iPOC, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut ); 211 Void xGetBuffer ( TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut, Int iNumPicRcvd, Int iTimeOffset, TComPic*& rpcPic, TComPicYuv*& rpcPicYuvRecOut, Int pocCurr, Bool isField ); 209 Void xInitGOP ( Int iPOCLast, Int iNumPicRcvd, TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut, bool isField ); 210 Void xGetBuffer ( TComList<TComPic*>& rcListPic, TComList<TComPicYuv*>& rcListPicYuvRecOut, Int iNumPicRcvd, Int iTimeOffset, TComPic*& rpcPic, TComPicYuv*& rpcPicYuvRecOut, Int pocCurr, bool isField ); 212 211 213 212 Void xCalculateAddPSNR ( TComPic* pcPic, TComPicYuv* pcPicD, const AccessUnit&, Double dEncTime ); … … 226 225 SEIKneeFunctionInfo* xCreateSEIKneeFunctionInfo(); 227 226 #endif 228 #if Q0074_ SEI_COLOR_MAPPING229 SEIColo rMappingInfo* xCreateSEIColorMappingInfo( Char* file);227 #if Q0074_COLOUR_REMAPPING_SEI 228 SEIColourRemappingInfo* xCreateSEIColourRemappingInfo(); 230 229 #endif 231 230 … … 254 253 #endif 255 254 #if O0164_MULTI_LAYER_HRD 255 #if VPS_VUI_BSP_HRD_PARAMS 256 SEIScalableNesting* xCreateBspNestingSEI(TComSlice *pcSlice, Int olsIdx, Int partitioningSchemeIdx, Int bspIdx); 257 #else 256 258 SEIScalableNesting* xCreateBspNestingSEI(TComSlice *pcSlice); 259 #endif 257 260 #endif 258 261 #if Q0048_CGS_3D_ASYMLUT -
trunk/source/Lib/TLibEncoder/TEncSearch.cpp
r815 r906 4896 4896 if( bCodeChroma ) 4897 4897 { 4898 m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[ uiDepth ][ CI_QT_TRAFO_ROOT ] ); 4899 m_pcEntropyCoder->resetBits(); 4898 4900 m_pcEntropyCoder->encodeQtCbf ( pcCU, uiAbsPartIdx, TEXT_CHROMA_U, uiTrMode ); 4899 4901 m_pcEntropyCoder->encodeCoeffNxN( pcCU, pcCoeffCurrU, uiAbsPartIdx, trWidthC, trHeightC, uiDepth, TEXT_CHROMA_U ); 4900 uiSingleBitsU = m_pcEntropyCoder->getNumberOfWrittenBits() - uiSingleBitsY;4902 uiSingleBitsU = m_pcEntropyCoder->getNumberOfWrittenBits(); 4901 4903 4904 m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[ uiDepth ][ CI_QT_TRAFO_ROOT ] ); 4905 m_pcEntropyCoder->resetBits(); 4902 4906 m_pcEntropyCoder->encodeQtCbf ( pcCU, uiAbsPartIdx, TEXT_CHROMA_V, uiTrMode ); 4903 4907 m_pcEntropyCoder->encodeCoeffNxN( pcCU, pcCoeffCurrV, uiAbsPartIdx, trWidthC, trHeightC, uiDepth, TEXT_CHROMA_V ); 4904 uiSingleBitsV = m_pcEntropyCoder->getNumberOfWrittenBits() - ( uiSingleBitsY + uiSingleBitsU );4908 uiSingleBitsV = m_pcEntropyCoder->getNumberOfWrittenBits(); 4905 4909 } 4906 4910 … … 4939 4943 { 4940 4944 const Double singleCostY = m_pcRdCost->calcRdCost( uiSingleBitsY, uiNonzeroDistY ); 4945 m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[ uiDepth ][ CI_QT_TRAFO_ROOT ] ); 4941 4946 m_pcEntropyCoder->resetBits(); 4942 4947 m_pcEntropyCoder->encodeQtCbfZero( pcCU, TEXT_LUMA, uiTrMode ); … … 4964 4969 else if( checkTransformSkipY ) 4965 4970 { 4971 m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[ uiDepth ][ CI_QT_TRAFO_ROOT ] ); 4966 4972 m_pcEntropyCoder->resetBits(); 4967 4973 m_pcEntropyCoder->encodeQtCbfZero( pcCU, TEXT_LUMA, uiTrMode ); … … 5015 5021 { 5016 5022 const Double dSingleCostU = m_pcRdCost->calcRdCost( uiSingleBitsU, uiNonzeroDistU ); 5023 m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[ uiDepth ][ CI_QT_TRAFO_ROOT ] ); 5017 5024 m_pcEntropyCoder->resetBits(); 5018 5025 m_pcEntropyCoder->encodeQtCbfZero( pcCU, TEXT_CHROMA_U, uiTrMode ); … … 5040 5047 else if( checkTransformSkipUV ) 5041 5048 { 5049 m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[ uiDepth ][ CI_QT_TRAFO_ROOT ] ); 5042 5050 m_pcEntropyCoder->resetBits(); 5043 5051 m_pcEntropyCoder->encodeQtCbfZero( pcCU, TEXT_CHROMA_U, uiTrMode ); … … 5084 5092 { 5085 5093 const Double dSingleCostV = m_pcRdCost->calcRdCost( uiSingleBitsV, uiNonzeroDistV ); 5094 m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[ uiDepth ][ CI_QT_TRAFO_ROOT ] ); 5086 5095 m_pcEntropyCoder->resetBits(); 5087 5096 m_pcEntropyCoder->encodeQtCbfZero( pcCU, TEXT_CHROMA_V, uiTrMode ); … … 5109 5118 else if( checkTransformSkipUV ) 5110 5119 { 5120 m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[ uiDepth ][ CI_QT_TRAFO_ROOT ] ); 5111 5121 m_pcEntropyCoder->resetBits(); 5112 5122 m_pcEntropyCoder->encodeQtCbfZero( pcCU, TEXT_CHROMA_V, uiTrMode ); … … 5287 5297 pcCU->setCbfSubParts( uiAbsSumTransformSkipV ? uiSetCbf : 0, TEXT_CHROMA_V, uiAbsPartIdx, pcCU->getDepth(0)+uiTrModeC ); 5288 5298 5289 m_pcEntropyCoder->resetBits();5290 5299 uiSingleBitsU = 0; 5291 5300 uiSingleBitsV = 0; … … 5293 5302 if( uiAbsSumTransformSkipU ) 5294 5303 { 5304 m_pcEntropyCoder->resetBits(); 5295 5305 m_pcEntropyCoder->encodeQtCbf ( pcCU, uiAbsPartIdx, TEXT_CHROMA_U, uiTrMode ); 5296 5306 m_pcEntropyCoder->encodeCoeffNxN( pcCU, pcCoeffCurrU, uiAbsPartIdx, trWidthC, trHeightC, uiDepth, TEXT_CHROMA_U ); … … 5335 5345 if( uiAbsSumTransformSkipV ) 5336 5346 { 5347 m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[ uiDepth ][ CI_QT_TRAFO_ROOT ] ); 5348 m_pcEntropyCoder->resetBits(); 5337 5349 m_pcEntropyCoder->encodeQtCbf ( pcCU, uiAbsPartIdx, TEXT_CHROMA_V, uiTrMode ); 5338 5350 m_pcEntropyCoder->encodeCoeffNxN( pcCU, pcCoeffCurrV, uiAbsPartIdx, trWidthC, trHeightC, uiDepth, TEXT_CHROMA_V ); 5339 uiSingleBitsV = m_pcEntropyCoder->getNumberOfWrittenBits() - uiSingleBitsU;5351 uiSingleBitsV = m_pcEntropyCoder->getNumberOfWrittenBits(); 5340 5352 5341 5353 curChromaQpOffset = pcCU->getSlice()->getPPS()->getChromaCrQpOffset() + pcCU->getSlice()->getSliceQpDeltaCr(); -
trunk/source/Lib/TLibEncoder/TEncSlice.cpp
r713 r906 836 836 Void TEncSlice::compressSlice( TComPic*& rpcPic ) 837 837 { 838 #if !WPP_FIX 838 839 UInt uiCUAddr; 840 #endif 839 841 UInt uiStartCUAddr; 840 842 UInt uiBoundingCUAddr; … … 907 909 TEncSbac**** ppppcRDSbacCoders = pcEncTop->getRDSbacCoders(); 908 910 TComBitCounter* pcBitCounters = pcEncTop->getBitCounters(); 911 #if WPP_FIX 912 const Int iNumSubstreams = pcSlice->getPPS()->getNumSubstreams(); 913 const UInt uiTilesAcross = rpcPic->getPicSym()->getNumColumnsMinus1()+1; 914 #else 909 915 Int iNumSubstreams = 1; 910 916 UInt uiTilesAcross = 0; … … 912 918 iNumSubstreams = pcSlice->getPPS()->getNumSubstreams(); 913 919 uiTilesAcross = rpcPic->getPicSym()->getNumColumnsMinus1()+1; 920 #endif 914 921 delete[] m_pcBufferSbacCoders; 915 922 delete[] m_pcBufferBinCoderCABACs; … … 943 950 UInt uiWidthInLCUs = rpcPic->getPicSym()->getFrameWidthInCU(); 944 951 //UInt uiHeightInLCUs = rpcPic->getPicSym()->getFrameHeightInCU(); 952 #if WPP_FIX 953 UInt uiTileCol = 0; 954 Bool depSliceSegmentsEnabled = pcSlice->getPPS()->getDependentSliceSegmentsEnabledFlag(); 955 UInt uiCUAddr = rpcPic->getPicSym()->getCUOrderMap( uiStartCUAddr /rpcPic->getNumPartInCU()); 956 UInt currentTileIdx = rpcPic->getPicSym()->getTileIdxMap(uiCUAddr); 957 TComTile *pCurrentTile = rpcPic->getPicSym()->getTComTile(currentTileIdx); 958 UInt uiTileStartLCU = pCurrentTile->getFirstCUAddr(); 959 #else 945 960 UInt uiCol=0, uiLin=0, uiSubStrm=0; 946 961 UInt uiTileCol = 0; … … 950 965 uiCUAddr = rpcPic->getPicSym()->getCUOrderMap( uiStartCUAddr /rpcPic->getNumPartInCU()); 951 966 uiTileStartLCU = rpcPic->getPicSym()->getTComTile(rpcPic->getPicSym()->getTileIdxMap(uiCUAddr))->getFirstCUAddr(); 967 #endif 952 968 if( depSliceSegmentsEnabled ) 953 969 { 954 970 if((pcSlice->getSliceSegmentCurStartCUAddr()!= pcSlice->getSliceCurStartCUAddr())&&(uiCUAddr != uiTileStartLCU)) 955 971 { 972 #if WPP_FIX 973 UInt uiSubStrm=0; 974 #endif 956 975 if( m_pcCfg->getWaveFrontsynchro() ) 957 976 { 977 #if WPP_FIX 978 uiTileCol = currentTileIdx % (rpcPic->getPicSym()->getNumColumnsMinus1()+1); 979 m_pcBufferSbacCoders[uiTileCol].loadContexts( CTXMem[1] ); 980 //uiCUAddr = rpcPic->getPicSym()->getCUOrderMap( uiStartCUAddr /rpcPic->getNumPartInCU()); 981 uiSubStrm=rpcPic->getSubstreamForLCUAddr(uiCUAddr, true, pcSlice); 982 if ( pCurrentTile->getTileWidth() < 2) 983 { 984 CTXMem[0]->loadContexts(m_pcSbacCoder); 985 } 986 #else 958 987 uiTileCol = rpcPic->getPicSym()->getTileIdxMap(uiCUAddr) % (rpcPic->getPicSym()->getNumColumnsMinus1()+1); 959 988 m_pcBufferSbacCoders[uiTileCol].loadContexts( CTXMem[1] ); … … 972 1001 } 973 1002 } 1003 #endif 974 1004 } 975 1005 m_pppcRDSbacCoder[0][CI_CURR_BEST]->loadContexts( CTXMem[0] ); … … 998 1028 uiTileCol = rpcPic->getPicSym()->getTileIdxMap(uiCUAddr) % (rpcPic->getPicSym()->getNumColumnsMinus1()+1); // what column of tiles are we in? 999 1029 uiTileStartLCU = rpcPic->getPicSym()->getTComTile(rpcPic->getPicSym()->getTileIdxMap(uiCUAddr))->getFirstCUAddr(); 1030 #if WPP_FIX 1031 UInt uiTileLCUX = uiTileStartLCU % uiWidthInLCUs; 1032 //UInt uiSliceStartLCU = pcSlice->getSliceCurStartCUAddr(); 1033 UInt uiCol = uiCUAddr % uiWidthInLCUs; 1034 UInt uiSubStrm=rpcPic->getSubstreamForLCUAddr(uiCUAddr, true, pcSlice); 1035 1036 if ( ((iNumSubstreams > 1) || depSliceSegmentsEnabled ) && (uiCol == uiTileLCUX) && m_pcCfg->getWaveFrontsynchro()) 1037 #else 1000 1038 uiTileLCUX = uiTileStartLCU % uiWidthInLCUs; 1001 1039 //UInt uiSliceStartLCU = pcSlice->getSliceCurStartCUAddr(); … … 1015 1053 } 1016 1054 if ( ((pcSlice->getPPS()->getNumSubstreams() > 1) || depSliceSegmentsEnabled ) && (uiCol == uiTileLCUX) && m_pcCfg->getWaveFrontsynchro()) 1055 #endif 1017 1056 { 1018 1057 // We'll sync if the TR is available. … … 1138 1177 ppppcRDSbacCoders[uiSubStrm][0][CI_CURR_BEST]->load( m_pppcRDSbacCoder[0][CI_CURR_BEST] ); 1139 1178 //Store probabilties of second LCU in line into buffer 1179 #if WPP_FIX 1180 if ( ( uiCol == uiTileLCUX+1) && (depSliceSegmentsEnabled || (iNumSubstreams > 1)) && m_pcCfg->getWaveFrontsynchro()) 1181 #else 1140 1182 if ( ( uiCol == uiTileLCUX+1) && (depSliceSegmentsEnabled || (pcSlice->getPPS()->getNumSubstreams() > 1)) && m_pcCfg->getWaveFrontsynchro()) 1183 #endif 1141 1184 { 1142 1185 m_pcBufferSbacCoders[uiTileCol].loadContexts(ppppcRDSbacCoders[uiSubStrm][0][CI_CURR_BEST]); … … 1177 1220 m_uiPicDist += pcCU->getTotalDistortion(); 1178 1221 } 1222 #if WPP_FIX 1223 if ((iNumSubstreams > 1) && !depSliceSegmentsEnabled) 1224 #else 1179 1225 if ((pcSlice->getPPS()->getNumSubstreams() > 1) && !depSliceSegmentsEnabled) 1226 #endif 1180 1227 { 1181 1228 pcSlice->setNextSlice( true ); … … 1239 1286 TEncTop* pcEncTop = (TEncTop*) m_pcCfg; 1240 1287 TEncSbac* pcSbacCoders = pcEncTop->getSbacCoders(); //coder for each substream 1288 #if WPP_FIX 1289 const Int iNumSubstreams = pcSlice->getPPS()->getNumSubstreams(); 1290 #else 1241 1291 Int iNumSubstreams = pcSlice->getPPS()->getNumSubstreams(); 1292 #endif 1242 1293 UInt uiBitsOriginallyInSubstreams = 0; 1243 1294 { … … 1260 1311 1261 1312 UInt uiWidthInLCUs = rpcPic->getPicSym()->getFrameWidthInCU(); 1313 #if WPP_FIX 1314 UInt uiCol=0, uiSubStrm=0; 1315 #else 1262 1316 UInt uiCol=0, uiLin=0, uiSubStrm=0; 1317 #endif 1263 1318 UInt uiTileCol = 0; 1264 1319 UInt uiTileStartLCU = 0; … … 1268 1323 an encoding order index, so we need to convert the index (uiStartCUAddr) 1269 1324 into the real raster scan address (uiCUAddr) via the CUOrderMap */ 1325 #if WPP_FIX 1326 UInt currentTileIdx=rpcPic->getPicSym()->getTileIdxMap(uiCUAddr); 1327 TComTile *pCurrentTile=rpcPic->getPicSym()->getTComTile(currentTileIdx); 1328 uiTileStartLCU = pCurrentTile->getFirstCUAddr(); 1329 #else 1270 1330 uiTileStartLCU = rpcPic->getPicSym()->getTComTile(rpcPic->getPicSym()->getTileIdxMap(uiCUAddr))->getFirstCUAddr(); 1331 #endif 1271 1332 if( depSliceSegmentsEnabled ) 1272 1333 { 1334 #if WPP_FIX 1335 if( pcSlice->isNextSlice()|| uiCUAddr == uiTileStartLCU) 1336 #else 1273 1337 if( pcSlice->isNextSlice()|| 1274 1338 uiCUAddr == rpcPic->getPicSym()->getTComTile(rpcPic->getPicSym()->getTileIdxMap(uiCUAddr))->getFirstCUAddr()) 1339 #endif 1275 1340 { 1276 1341 if(m_pcCfg->getWaveFrontsynchro()) … … 1284 1349 if(m_pcCfg->getWaveFrontsynchro()) 1285 1350 { 1351 #if WPP_FIX 1352 uiTileCol = currentTileIdx % (rpcPic->getPicSym()->getNumColumnsMinus1()+1); 1353 #else 1286 1354 uiTileCol = rpcPic->getPicSym()->getTileIdxMap(uiCUAddr) % (rpcPic->getPicSym()->getNumColumnsMinus1()+1); 1355 #endif 1287 1356 m_pcBufferSbacCoders[uiTileCol].loadContexts( CTXMem[1] ); 1357 #if WPP_FIX 1358 uiCUAddr = rpcPic->getPicSym()->getCUOrderMap( uiStartCUAddr /rpcPic->getNumPartInCU()); 1359 uiSubStrm=rpcPic->getSubstreamForLCUAddr(uiCUAddr, true, pcSlice); 1360 if ( pCurrentTile->getTileWidth() < 2) 1361 { 1362 CTXMem[0]->loadContexts(m_pcSbacCoder); 1363 } 1364 #else 1288 1365 Int iNumSubstreamsPerTile = iNumSubstreams/rpcPic->getPicSym()->getNumTiles(); 1289 1366 uiLin = uiCUAddr / uiWidthInLCUs; … … 1299 1376 } 1300 1377 } 1378 #endif 1301 1379 } 1302 1380 pcSbacCoders[uiSubStrm].loadContexts( CTXMem[0] ); … … 1314 1392 //UInt uiSliceStartLCU = pcSlice->getSliceCurStartCUAddr(); 1315 1393 uiCol = uiCUAddr % uiWidthInLCUs; 1394 #if WPP_FIX 1395 uiSubStrm=rpcPic->getSubstreamForLCUAddr(uiCUAddr, true, pcSlice); 1396 #else 1316 1397 uiLin = uiCUAddr / uiWidthInLCUs; 1317 1398 if (pcSlice->getPPS()->getNumSubstreams() > 1) … … 1327 1408 uiSubStrm = uiLin % iNumSubstreams; 1328 1409 } 1410 #endif 1329 1411 1330 1412 m_pcEntropyCoder->setBitstream( &pcSubstreams[uiSubStrm] ); 1331 1413 // Synchronize cabac probabilities with upper-right LCU if it's available and we're at the start of a line. 1414 #if WPP_FIX 1415 if (((iNumSubstreams > 1) || depSliceSegmentsEnabled) && (uiCol == uiTileLCUX) && m_pcCfg->getWaveFrontsynchro()) 1416 #else 1332 1417 if (((pcSlice->getPPS()->getNumSubstreams() > 1) || depSliceSegmentsEnabled) && (uiCol == uiTileLCUX) && m_pcCfg->getWaveFrontsynchro()) 1418 #endif 1333 1419 { 1334 1420 // We'll sync if the TR is available. … … 1368 1454 // When tiles are independent, we have "substreams per tile". Each substream has already been terminated, and we no longer 1369 1455 // have to perform it here. 1456 #if WPP_FIX 1457 if (iNumSubstreams <= 1) 1458 #else 1370 1459 if (pcSlice->getPPS()->getNumSubstreams() > 1) 1371 1460 { … … 1373 1462 } 1374 1463 else 1464 #endif 1375 1465 { 1376 1466 SliceType sliceType = pcSlice->getSliceType(); … … 1448 1538 pcSbacCoders[uiSubStrm].load(m_pcSbacCoder); //load back status of the entropy coder after encoding the LCU into relevant bitstream entropy coder 1449 1539 //Store probabilties of second LCU in line into buffer 1540 #if WPP_FIX 1541 if ( (depSliceSegmentsEnabled || (iNumSubstreams > 1)) && (uiCol == uiTileLCUX+1) && m_pcCfg->getWaveFrontsynchro()) 1542 #else 1450 1543 if ( (depSliceSegmentsEnabled || (pcSlice->getPPS()->getNumSubstreams() > 1)) && (uiCol == uiTileLCUX+1) && m_pcCfg->getWaveFrontsynchro()) 1544 #endif 1451 1545 { 1452 1546 m_pcBufferSbacCoders[uiTileCol].loadContexts( &pcSbacCoders[uiSubStrm] ); … … 1480 1574 } 1481 1575 1576 #if WPP_FIX 1577 Void TEncSlice::calculateBoundingCUAddrForSlice(UInt &uiStartCUAddrSlice, UInt &uiBoundingCUAddrSlice, Bool &bReachedTileBoundary, TComPic*& rpcPic, Bool bEncodeSlice, Int sliceMode, Int sliceArgument, UInt uiSliceCurEndCUAddr) 1578 { 1579 TComSlice* pcSlice = rpcPic->getSlice(getSliceIdx()); 1580 UInt uiNumberOfCUsInFrame = rpcPic->getNumCUsInFrame(); 1581 const UInt scaleCUAddr = rpcPic->getNumPartInCU(); // due to fine granularity slices all addresses are scaled. 1582 uiBoundingCUAddrSlice=0; 1583 bReachedTileBoundary=false; 1584 1585 switch (sliceMode) 1586 { 1587 case FIXED_NUMBER_OF_LCU: 1588 { 1589 UInt uiCUAddrIncrement = sliceArgument; 1590 uiBoundingCUAddrSlice = ((uiStartCUAddrSlice + uiCUAddrIncrement) < uiNumberOfCUsInFrame*scaleCUAddr) ? (uiStartCUAddrSlice + uiCUAddrIncrement) : uiNumberOfCUsInFrame*scaleCUAddr; 1591 } 1592 break; 1593 case FIXED_NUMBER_OF_BYTES: 1594 if (bEncodeSlice) 1595 uiBoundingCUAddrSlice = uiSliceCurEndCUAddr; 1596 else 1597 uiBoundingCUAddrSlice = uiNumberOfCUsInFrame*scaleCUAddr; 1598 break; 1599 case FIXED_NUMBER_OF_TILES: 1600 { 1601 UInt tileIdx = rpcPic->getPicSym()->getTileIdxMap( rpcPic->getPicSym()->getCUOrderMap(uiStartCUAddrSlice/scaleCUAddr) ); 1602 UInt uiCUAddrIncrement = 0; 1603 UInt tileTotalCount = (rpcPic->getPicSym()->getNumColumnsMinus1()+1) * (rpcPic->getPicSym()->getNumRowsMinus1()+1); 1604 1605 for(UInt tileIdxIncrement = 0; tileIdxIncrement < sliceArgument; tileIdxIncrement++) 1606 { 1607 if((tileIdx + tileIdxIncrement) < tileTotalCount) 1608 { 1609 UInt tileWidthInLcu = rpcPic->getPicSym()->getTComTile(tileIdx + tileIdxIncrement)->getTileWidth(); 1610 UInt tileHeightInLcu = rpcPic->getPicSym()->getTComTile(tileIdx + tileIdxIncrement)->getTileHeight(); 1611 uiCUAddrIncrement += (tileWidthInLcu * tileHeightInLcu * scaleCUAddr); 1612 } 1613 } 1614 1615 uiBoundingCUAddrSlice = ((uiStartCUAddrSlice + uiCUAddrIncrement) < uiNumberOfCUsInFrame*scaleCUAddr) ? (uiStartCUAddrSlice + uiCUAddrIncrement) : uiNumberOfCUsInFrame*scaleCUAddr; 1616 } 1617 break; 1618 default: 1619 uiBoundingCUAddrSlice = uiNumberOfCUsInFrame*scaleCUAddr; 1620 break; 1621 } 1622 1623 // Adjust for tiles and wavefronts. 1624 if ((sliceMode == FIXED_NUMBER_OF_LCU || sliceMode == FIXED_NUMBER_OF_BYTES) && 1625 (m_pcCfg->getNumRowsMinus1() > 0 || m_pcCfg->getNumColumnsMinus1() > 0)) 1626 { 1627 const UInt lcuEncAddrStart = (uiStartCUAddrSlice+scaleCUAddr-1)/scaleCUAddr; 1628 const UInt lcuAddr = rpcPic->getPicSym()->getCUOrderMap(lcuEncAddrStart); 1629 const UInt startTileIdx = rpcPic->getPicSym()->getTileIdxMap(lcuAddr); 1630 const Bool bWavefrontsEnabled = m_pcCfg->getWaveFrontsynchro(); 1631 1632 TComTile *pStartingTile = rpcPic->getPicSym()->getTComTile(startTileIdx); 1633 const UInt uiTileStartLCUEncAddr = rpcPic->getPicSym()->getInverseCUOrderMap(pStartingTile->getFirstCUAddr()); 1634 const UInt uiTileStartWidth = pStartingTile->getTileWidth(); 1635 const UInt uiTileStartHeight = pStartingTile->getTileHeight(); 1636 const UInt uiTileLastLCUEncAddr_excl = uiTileStartLCUEncAddr + uiTileStartWidth*uiTileStartHeight; 1637 const UInt tileBoundingCUAddrSlice = uiTileLastLCUEncAddr_excl * scaleCUAddr; 1638 1639 const UInt lcuColumnOfStartingTile=((lcuEncAddrStart-uiTileStartLCUEncAddr)%uiTileStartWidth); 1640 if (bWavefrontsEnabled && lcuColumnOfStartingTile!=0) 1641 { 1642 // WPP: if a slice does not start at the beginning of a CTB row, it must end within the same CTB row 1643 const UInt numberOfLCUsToEndOfRow=uiTileStartWidth-lcuColumnOfStartingTile; 1644 const UInt wavefrontTileBoundingCUAddrSlice = (lcuEncAddrStart+numberOfLCUsToEndOfRow)*scaleCUAddr; 1645 if (wavefrontTileBoundingCUAddrSlice < uiBoundingCUAddrSlice) 1646 { 1647 uiBoundingCUAddrSlice = wavefrontTileBoundingCUAddrSlice; 1648 } 1649 } 1650 1651 if (tileBoundingCUAddrSlice < uiBoundingCUAddrSlice) 1652 { 1653 uiBoundingCUAddrSlice = tileBoundingCUAddrSlice; 1654 bReachedTileBoundary = true; 1655 } 1656 } 1657 else if (pcSlice->getPPS()->getNumSubstreams() > 1 && (uiStartCUAddrSlice % (rpcPic->getFrameWidthInCU()*scaleCUAddr) != 0)) 1658 { 1659 // WPP: if a slice does not start at the beginning of a CTB row, it must end within the same CTB row 1660 uiBoundingCUAddrSlice = min(uiBoundingCUAddrSlice, uiStartCUAddrSlice - (uiStartCUAddrSlice % (rpcPic->getFrameWidthInCU()*scaleCUAddr)) + (rpcPic->getFrameWidthInCU()*scaleCUAddr)); 1661 } 1662 1663 //calculate real slice start address (fine granularity slices) 1664 { 1665 UInt uiInternalAddress = rpcPic->getPicSym()->getPicSCUAddr(uiStartCUAddrSlice) % scaleCUAddr; 1666 UInt uiExternalAddress = rpcPic->getPicSym()->getPicSCUAddr(uiStartCUAddrSlice) / scaleCUAddr; 1667 UInt uiPosX = ( uiExternalAddress % rpcPic->getFrameWidthInCU() ) * g_uiMaxCUWidth+ g_auiRasterToPelX[ g_auiZscanToRaster[uiInternalAddress] ]; 1668 UInt uiPosY = ( uiExternalAddress / rpcPic->getFrameWidthInCU() ) * g_uiMaxCUHeight+ g_auiRasterToPelY[ g_auiZscanToRaster[uiInternalAddress] ]; 1669 #if REPN_FORMAT_IN_VPS 1670 UInt uiWidth = pcSlice->getPicWidthInLumaSamples(); 1671 UInt uiHeight = pcSlice->getPicHeightInLumaSamples(); 1672 #else 1673 UInt uiWidth = pcSlice->getSPS()->getPicWidthInLumaSamples(); 1674 UInt uiHeight = pcSlice->getSPS()->getPicHeightInLumaSamples(); 1675 #endif 1676 while((uiPosX>=uiWidth||uiPosY>=uiHeight)&&!(uiPosX>=uiWidth&&uiPosY>=uiHeight)) 1677 { 1678 uiInternalAddress++; 1679 if(uiInternalAddress>=scaleCUAddr) 1680 { 1681 uiInternalAddress=0; 1682 uiExternalAddress = rpcPic->getPicSym()->getCUOrderMap(rpcPic->getPicSym()->getInverseCUOrderMap(uiExternalAddress)+1); 1683 } 1684 uiPosX = ( uiExternalAddress % rpcPic->getFrameWidthInCU() ) * g_uiMaxCUWidth+ g_auiRasterToPelX[ g_auiZscanToRaster[uiInternalAddress] ]; 1685 uiPosY = ( uiExternalAddress / rpcPic->getFrameWidthInCU() ) * g_uiMaxCUHeight+ g_auiRasterToPelY[ g_auiZscanToRaster[uiInternalAddress] ]; 1686 } 1687 UInt uiRealStartAddress = rpcPic->getPicSym()->getPicSCUEncOrder(uiExternalAddress*scaleCUAddr+uiInternalAddress); 1688 1689 uiStartCUAddrSlice=uiRealStartAddress; 1690 } 1691 } 1692 1693 /** Determines the starting and bounding LCU address of current slice / dependent slice 1694 * \param bEncodeSlice Identifies if the calling function is compressSlice() [false] or encodeSlice() [true] 1695 * \returns Updates uiStartCUAddr, uiBoundingCUAddr with appropriate LCU address 1696 */ 1697 Void TEncSlice::xDetermineStartAndBoundingCUAddr ( UInt& startCUAddr, UInt& boundingCUAddr, TComPic*& rpcPic, Bool bEncodeSlice ) 1698 { 1699 TComSlice* pcSlice = rpcPic->getSlice(getSliceIdx()); 1700 1701 // Non-dependent slice 1702 UInt uiStartCUAddrSlice = pcSlice->getSliceCurStartCUAddr(); 1703 Bool bTileBoundarySlice = false; 1704 UInt uiBoundingCUAddrSlice; 1705 calculateBoundingCUAddrForSlice(uiStartCUAddrSlice, uiBoundingCUAddrSlice, bTileBoundarySlice, rpcPic, bEncodeSlice, m_pcCfg->getSliceMode(), m_pcCfg->getSliceArgument(), pcSlice->getSliceCurEndCUAddr()); 1706 pcSlice->setSliceCurEndCUAddr( uiBoundingCUAddrSlice ); 1707 pcSlice->setSliceCurStartCUAddr(uiStartCUAddrSlice); 1708 1709 // Dependent slice 1710 UInt startCUAddrSliceSegment = pcSlice->getSliceSegmentCurStartCUAddr(); 1711 Bool bTileBoundarySliceSegment = false; 1712 UInt boundingCUAddrSliceSegment; 1713 calculateBoundingCUAddrForSlice(startCUAddrSliceSegment, boundingCUAddrSliceSegment, bTileBoundarySliceSegment, rpcPic, bEncodeSlice, m_pcCfg->getSliceSegmentMode(), m_pcCfg->getSliceSegmentArgument(), pcSlice->getSliceSegmentCurEndCUAddr()); 1714 pcSlice->setSliceSegmentCurEndCUAddr( boundingCUAddrSliceSegment ); 1715 pcSlice->setSliceSegmentCurStartCUAddr(startCUAddrSliceSegment); 1716 1717 // Make a joint decision based on reconstruction and dependent slice bounds 1718 startCUAddr = max(uiStartCUAddrSlice , startCUAddrSliceSegment ); 1719 boundingCUAddr = min(uiBoundingCUAddrSlice, boundingCUAddrSliceSegment); 1720 1721 1722 if (!bEncodeSlice) 1723 { 1724 // For fixed number of LCU within an entropy and reconstruction slice we already know whether we will encounter end of entropy and/or reconstruction slice 1725 // first. Set the flags accordingly. 1726 if ( (m_pcCfg->getSliceMode()==FIXED_NUMBER_OF_LCU && m_pcCfg->getSliceSegmentMode()==FIXED_NUMBER_OF_LCU) 1727 || (m_pcCfg->getSliceMode()==0 && m_pcCfg->getSliceSegmentMode()==FIXED_NUMBER_OF_LCU) 1728 || (m_pcCfg->getSliceMode()==FIXED_NUMBER_OF_LCU && m_pcCfg->getSliceSegmentMode()==0) 1729 || (m_pcCfg->getSliceMode()==FIXED_NUMBER_OF_TILES && m_pcCfg->getSliceSegmentMode()==FIXED_NUMBER_OF_LCU) 1730 || (m_pcCfg->getSliceMode()==FIXED_NUMBER_OF_TILES && m_pcCfg->getSliceSegmentMode()==0) 1731 || (m_pcCfg->getSliceSegmentMode()==FIXED_NUMBER_OF_TILES && m_pcCfg->getSliceMode()==0) 1732 || bTileBoundarySlice || bTileBoundarySliceSegment ) 1733 { 1734 if (uiBoundingCUAddrSlice < boundingCUAddrSliceSegment) 1735 { 1736 pcSlice->setNextSlice ( true ); 1737 pcSlice->setNextSliceSegment( false ); 1738 } 1739 else if (uiBoundingCUAddrSlice > boundingCUAddrSliceSegment) 1740 { 1741 pcSlice->setNextSlice ( false ); 1742 pcSlice->setNextSliceSegment( true ); 1743 } 1744 else 1745 { 1746 pcSlice->setNextSlice ( true ); 1747 pcSlice->setNextSliceSegment( true ); 1748 } 1749 } 1750 else 1751 { 1752 pcSlice->setNextSlice ( false ); 1753 pcSlice->setNextSliceSegment( false ); 1754 } 1755 } 1756 } 1757 #else 1482 1758 /** Determines the starting and bounding LCU address of current slice / dependent slice 1483 1759 * \param bEncodeSlice Identifies if the calling function is compressSlice() [false] or encodeSlice() [true] … … 1816 2092 } 1817 2093 } 2094 #endif 1818 2095 1819 2096 Double TEncSlice::xGetQPValueAccordingToLambda ( Double lambda ) -
trunk/source/Lib/TLibEncoder/TEncSlice.h
r595 r906 150 150 Void setCtxMem( TEncSbac* sb, Int b ) { CTXMem[b] = sb; } 151 151 152 #if WPP_FIX 153 Void calculateBoundingCUAddrForSlice(UInt &uiStartCUAddrSlice, UInt &uiBoundingCUAddrSlice, Bool &bReachedTileBoundary, TComPic*& rpcPic, Bool bEncodeSlice, Int sliceMode, Int sliceArgument, UInt uiSliceCurEndCUAddr); 154 #endif 155 152 156 private: 153 157 Double xGetQPValueAccordingToLambda ( Double lambda ); -
trunk/source/Lib/TLibEncoder/TEncTop.cpp
r815 r906 98 98 m_noOutputOfPriorPicsFlags = false; 99 99 #endif 100 #if P0297_VPS_POC_LSB_ALIGNED_FLAG 101 m_pocDecrementedInDPBFlag = false; 102 #endif 100 103 #endif //SVC_EXTENSION 101 104 } … … 323 326 /* set the VPS profile information */ 324 327 *m_cVPS.getPTL() = *m_cSPS.getPTL(); 328 #if VPS_VUI_BSP_HRD_PARAMS 329 m_cVPS.getTimingInfo()->setTimingInfoPresentFlag ( true ); 330 #else 325 331 m_cVPS.getTimingInfo()->setTimingInfoPresentFlag ( false ); 332 #endif 326 333 // initialize PPS 327 334 m_cPPS.setSPS(&m_cSPS); … … 779 786 for(UInt i = 0; i < m_cVPS.getNumDirectRefLayers( m_layerId ); i++ ) 780 787 { 788 #if MOVE_SCALED_OFFSET_TO_PPS 789 #if O0098_SCALED_REF_LAYER_ID 790 const Window scalEL = getPPS()->getScaledRefLayerWindowForLayer(m_cVPS.getRefLayerId(m_layerId, i)); 791 #else 792 const Window scalEL = getPPS()->getScaledRefLayerWindow(i); 793 #endif 794 #else 781 795 #if O0098_SCALED_REF_LAYER_ID 782 796 const Window scalEL = getSPS()->getScaledRefLayerWindowForLayer(m_cVPS.getRefLayerId(m_layerId, i)); … … 784 798 const Window scalEL = getSPS()->getScaledRefLayerWindow(i); 785 799 #endif 800 #endif 801 #if REF_REGION_OFFSET 802 const Window altRL = getPPS()->getRefLayerWindowForLayer(m_cVPS.getRefLayerId(m_layerId, i)); 803 #if RESAMPLING_FIX 804 Bool equalOffsets = scalEL.hasEqualOffset(altRL); 805 #if R0209_GENERIC_PHASE 806 Bool zeroPhase = getPPS()->hasZeroResamplingPhase(m_cVPS.getRefLayerId(m_layerId, i)); 807 #endif 808 #else 809 Bool zeroOffsets = ( scalEL.getWindowLeftOffset() == 0 && scalEL.getWindowRightOffset() == 0 && scalEL.getWindowTopOffset() == 0 && scalEL.getWindowBottomOffset() == 0 810 && altRL.getWindowLeftOffset() == 0 && altRL.getWindowRightOffset() == 0 && altRL.getWindowTopOffset() == 0 && altRL.getWindowBottomOffset() == 0); 811 #endif 812 #else 786 813 Bool zeroOffsets = ( scalEL.getWindowLeftOffset() == 0 && scalEL.getWindowRightOffset() == 0 && scalEL.getWindowTopOffset() == 0 && scalEL.getWindowBottomOffset() == 0 ); 814 #endif 787 815 788 816 #if VPS_EXTN_DIRECT_REF_LAYERS … … 795 823 Bool sameBitDepths = ( g_bitDepthYLayer[m_layerId] == g_bitDepthYLayer[refLayerId] ) && ( g_bitDepthCLayer[m_layerId] == g_bitDepthCLayer[refLayerId] ); 796 824 797 if( m_iSourceWidth != pcEncTopBase->getSourceWidth() || m_iSourceHeight != pcEncTopBase->getSourceHeight() || !zeroOffsets || !sameBitDepths 825 #if REF_IDX_MFM 826 if( m_iSourceWidth == pcEncTopBase->getSourceWidth() && m_iSourceHeight == pcEncTopBase->getSourceHeight() && equalOffsets && zeroPhase ) 827 { 828 pcEPic->setEqualPictureSizeAndOffsetFlag( i, true ); 829 } 830 831 if( !pcEPic->equalPictureSizeAndOffsetFlag(i) || !sameBitDepths 832 #else 833 if( m_iSourceWidth != pcEncTopBase->getSourceWidth() || m_iSourceHeight != pcEncTopBase->getSourceHeight() || !sameBitDepths 834 #if REF_REGION_OFFSET && RESAMPLING_FIX 835 || !equalOffsets 836 #if R0209_GENERIC_PHASE 837 || !zeroPhase 838 #endif 839 #else 840 || !zeroOffsets 841 #endif 842 #endif 798 843 #if Q0048_CGS_3D_ASYMLUT 799 844 || m_cPPS.getCGSFlag() > 0 … … 804 849 ) 805 850 #else 806 if(m_iSourceWidth != pcEncTopBase->getSourceWidth() || m_iSourceHeight != pcEncTopBase->getSourceHeight() || !zeroOffsets ) 851 if(m_iSourceWidth != pcEncTopBase->getSourceWidth() || m_iSourceHeight != pcEncTopBase->getSourceHeight() 852 #if REF_REGION_OFFSET && RESAMPLING_FIX 853 || !equalOffsets 854 #if R0209_GENERIC_PHASE 855 || !zeroPhase 856 #endif 857 #else 858 || !zeroOffsets 859 #endif 860 ) 807 861 #endif 808 862 { … … 839 893 for(UInt i = 0; i < m_cVPS.getNumDirectRefLayers( m_layerId ); i++ ) 840 894 { 895 #if MOVE_SCALED_OFFSET_TO_PPS 896 #if O0098_SCALED_REF_LAYER_ID 897 const Window scalEL = getPPS()->getScaledRefLayerWindowForLayer(m_cVPS.getRefLayerId(m_layerId, i)); 898 #else 899 const Window scalEL = getPPS()->getScaledRefLayerWindow(i); 900 #endif 901 #else 841 902 #if O0098_SCALED_REF_LAYER_ID 842 903 const Window scalEL = getSPS()->getScaledRefLayerWindowForLayer(m_cVPS.getRefLayerId(m_layerId, i)); … … 844 905 const Window scalEL = getSPS()->getScaledRefLayerWindow(i); 845 906 #endif 907 #endif 908 #if REF_REGION_OFFSET 909 const Window altRL = getPPS()->getRefLayerWindowForLayer(m_cVPS.getRefLayerId(m_layerId, i)); 910 #if RESAMPLING_FIX 911 Bool equalOffsets = scalEL.hasEqualOffset(altRL); 912 #if R0209_GENERIC_PHASE 913 Bool zeroPhase = getPPS()->hasZeroResamplingPhase(m_cVPS.getRefLayerId(m_layerId, i)); 914 #endif 915 #else 916 Bool zeroOffsets = ( scalEL.getWindowLeftOffset() == 0 && scalEL.getWindowRightOffset() == 0 && scalEL.getWindowTopOffset() == 0 && scalEL.getWindowBottomOffset() == 0 917 && altRL.getWindowLeftOffset() == 0 && altRL.getWindowRightOffset() == 0 && altRL.getWindowTopOffset() == 0 && altRL.getWindowBottomOffset() == 0); 918 #endif 919 #else 846 920 Bool zeroOffsets = ( scalEL.getWindowLeftOffset() == 0 && scalEL.getWindowRightOffset() == 0 && scalEL.getWindowTopOffset() == 0 && scalEL.getWindowBottomOffset() == 0 ); 921 #endif 847 922 848 923 #if VPS_EXTN_DIRECT_REF_LAYERS … … 855 930 Bool sameBitDepths = ( g_bitDepthYLayer[m_layerId] == g_bitDepthYLayer[refLayerId] ) && ( g_bitDepthCLayer[m_layerId] == g_bitDepthCLayer[refLayerId] ); 856 931 857 if( m_iSourceWidth != pcEncTopBase->getSourceWidth() || m_iSourceHeight != pcEncTopBase->getSourceHeight() || !zeroOffsets || !sameBitDepths 932 if( m_iSourceWidth != pcEncTopBase->getSourceWidth() || m_iSourceHeight != pcEncTopBase->getSourceHeight() || !sameBitDepths 933 #if REF_REGION_OFFSET && RESAMPLING_FIX 934 || !equalOffsets 935 #if R0209_GENERIC_PHASE 936 || !zeroPhase 937 #endif 938 #else 939 || !zeroOffsets 940 #endif 858 941 #if Q0048_CGS_3D_ASYMLUT 859 942 || m_cPPS.getCGSFlag() > 0 … … 864 947 ) 865 948 #else 866 if(m_iSourceWidth != pcEncTopBase->getSourceWidth() || m_iSourceHeight != pcEncTopBase->getSourceHeight() || !zeroOffsets ) 949 if(m_iSourceWidth != pcEncTopBase->getSourceWidth() || m_iSourceHeight != pcEncTopBase->getSourceHeight() 950 #if REF_REGION_OFFSET && RESAMPLING_FIX 951 || !equalOffsets 952 #if R0209_GENERIC_PHASE 953 || !zeroPhase 954 #endif 955 #else 956 || !zeroOffsets 957 #endif 958 ) 867 959 #endif 868 960 { … … 905 997 #if SVC_EXTENSION 906 998 m_cSPS.setExtensionFlag( m_layerId > 0 ? true : false ); 907 999 #if R0042_PROFILE_INDICATION 1000 m_cSPS.setNumDirectRefLayers(m_numAddLayerSets); 1001 #endif 908 1002 #if Q0078_ADD_LAYER_SETS 909 if (getNumDirectRefLayers() == 0 && getNumAddLayerSets() > 0)1003 if( !m_numDirectRefLayers && m_numAddLayerSets ) 910 1004 { 911 1005 m_cSPS.setLayerId(0); // layer ID 0 for independent layers … … 918 1012 m_cSPS.setLayerId(m_layerId); 919 1013 #endif 1014 #if !MOVE_SCALED_OFFSET_TO_PPS 920 1015 m_cSPS.setNumScaledRefLayerOffsets(m_numScaledRefLayerOffsets); 921 1016 for(Int i = 0; i < m_cSPS.getNumScaledRefLayerOffsets(); i++) … … 929 1024 #endif 930 1025 } 1026 #endif 931 1027 #endif //SVC_EXTENSION 932 1028 ProfileTierLevel& profileTierLevel = *m_cSPS.getPTL()->getGeneralPTL(); … … 1041 1137 { 1042 1138 TComVUI* pcVUI = m_cSPS.getVuiParameters(); 1043 pcVUI->setAspectRatioInfoPresentFlag(getAspectRatioI dc() != -1);1139 pcVUI->setAspectRatioInfoPresentFlag(getAspectRatioInfoPresentFlag()); 1044 1140 pcVUI->setAspectRatioIdc(getAspectRatioIdc()); 1045 1141 pcVUI->setSarWidth(getSarWidth()); … … 1177 1273 1178 1274 #if Q0078_ADD_LAYER_SETS 1179 if (getNumDirectRefLayers() == 0 && getNumAddLayerSets() > 0)1275 if( !m_numDirectRefLayers && m_numAddLayerSets ) 1180 1276 { 1181 1277 m_cPPS.setLayerId(0); // layer ID 0 for independent layers … … 1203 1299 { 1204 1300 m_cPPS.setNumExtraSliceHeaderBits( 3 ); 1301 } 1302 #endif 1303 #if MOVE_SCALED_OFFSET_TO_PPS 1304 m_cPPS.setNumScaledRefLayerOffsets(m_numScaledRefLayerOffsets); 1305 for(Int i = 0; i < m_cPPS.getNumScaledRefLayerOffsets(); i++) 1306 { 1307 #if O0098_SCALED_REF_LAYER_ID 1308 m_cPPS.setScaledRefLayerId(i, m_scaledRefLayerId[i]); 1309 #endif 1310 m_cPPS.getScaledRefLayerWindow(i) = m_scaledRefLayerWindow[i]; 1311 #if REF_REGION_OFFSET 1312 m_cPPS.getRefLayerWindow(i) = m_refLayerWindow[i]; 1313 m_cPPS.setScaledRefLayerOffsetPresentFlag( m_scaledRefLayerId[i], m_scaledRefLayerOffsetPresentFlag[i] ); 1314 m_cPPS.setRefRegionOffsetPresentFlag( m_scaledRefLayerId[i], m_refRegionOffsetPresentFlag[i] ); 1315 #endif 1316 #if R0209_GENERIC_PHASE 1317 m_cPPS.setResamplePhaseSetPresentFlag( m_scaledRefLayerId[i], m_resamplePhaseSetPresentFlag[i] ); 1318 m_cPPS.setPhaseHorLuma( m_scaledRefLayerId[i], m_phaseHorLuma[i] ); 1319 m_cPPS.setPhaseVerLuma( m_scaledRefLayerId[i], m_phaseVerLuma[i] ); 1320 m_cPPS.setPhaseHorChroma( m_scaledRefLayerId[i], m_phaseHorChroma[i] ); 1321 m_cPPS.setPhaseVerChroma( m_scaledRefLayerId[i], m_phaseVerChroma[i] ); 1322 #endif 1323 #if P0312_VERT_PHASE_ADJ 1324 m_cPPS.setVertPhasePositionEnableFlag( m_scaledRefLayerId[i], m_scaledRefLayerWindow[i].getVertPhasePositionEnableFlag() ); 1325 #endif 1205 1326 } 1206 1327 #endif … … 1477 1598 Void TEncTop::xInitPPSforTiles() 1478 1599 { 1479 m_cPPS.set UniformSpacingFlag( m_iUniformSpacingIdr);1480 m_cPPS.setNum ColumnsMinus1( m_iNumColumnsMinus1 );1481 m_cPPS.setNum RowsMinus1( m_iNumRowsMinus1 );1482 if( m_iUniformSpacingIdr == 0)1483 { 1484 m_cPPS.set ColumnWidth( m_puiColumnWidth );1485 m_cPPS.set RowHeight( m_puiRowHeight );1600 m_cPPS.setTileUniformSpacingFlag( m_tileUniformSpacingFlag ); 1601 m_cPPS.setNumTileColumnsMinus1( m_iNumColumnsMinus1 ); 1602 m_cPPS.setNumTileRowsMinus1( m_iNumRowsMinus1 ); 1603 if( !m_tileUniformSpacingFlag ) 1604 { 1605 m_cPPS.setTileColumnWidth( m_tileColumnWidth ); 1606 m_cPPS.setTileRowHeight( m_tileRowHeight ); 1486 1607 } 1487 1608 m_cPPS.setLoopFilterAcrossTilesEnabledFlag( m_loopFilterAcrossTilesEnabledFlag ); 1488 1609 1489 1610 // # substreams is "per tile" when tiles are independent. 1490 if (m_iWaveFrontSynchro 1491 ) 1611 if (m_iWaveFrontSynchro ) 1492 1612 { 1493 1613 m_cPPS.setNumSubstreams(m_iWaveFrontSubstreams * (m_iNumColumnsMinus1+1)); … … 1515 1635 } 1516 1636 1517 if( m_iNumColumnsMinus1 && m_iUniformSpacingIdr==0)1637 if( m_iNumColumnsMinus1 && !m_tileUniformSpacingFlag ) 1518 1638 { 1519 1639 for(Int i=0; i<m_iNumColumnsMinus1; i++) 1520 1640 { 1521 uiCummulativeColumnWidth += m_ puiColumnWidth[i];1641 uiCummulativeColumnWidth += m_tileColumnWidth[i]; 1522 1642 } 1523 1643 … … 1542 1662 } 1543 1663 1544 if( m_iNumRowsMinus1 && m_iUniformSpacingIdr==0)1664 if( m_iNumRowsMinus1 && !m_tileUniformSpacingFlag ) 1545 1665 { 1546 1666 for(Int i=0; i<m_iNumRowsMinus1; i++) 1547 { 1548 uiCummulativeRowHeight += m_puiRowHeight[i]; 1549 } 1667 uiCummulativeRowHeight += m_tileRowHeight[i]; 1550 1668 1551 1669 if( uiCummulativeRowHeight >= iHeightInCU ) … … 1646 1764 1647 1765 Int numReorderPics[MAX_TLAYER]; 1766 #if R0156_CONF_WINDOW_IN_REP_FORMAT 1767 Window &conformanceWindow = repFormat->getConformanceWindowVps(); 1768 #else 1648 1769 Window &conformanceWindow = m_cSPS.getConformanceWindow(); 1770 #endif 1649 1771 Window defaultDisplayWindow = m_cSPS.getVuiParametersPresentFlag() ? m_cSPS.getVuiParameters()->getDefaultDisplayWindow() : Window(); 1650 1772 … … 1685 1807 return win; 1686 1808 } 1809 #if REF_REGION_OFFSET 1810 Window& TEncTop::getRefLayerWindowForLayer(Int layerId) 1811 { 1812 static Window win; 1813 1814 for (Int i = 0; i < m_numScaledRefLayerOffsets; i++) 1815 { 1816 if (layerId == m_refLayerId[i]) 1817 { 1818 return m_refLayerWindow[i]; 1819 } 1820 } 1821 1822 win.resetWindow(); // reference offsets are inferred to be zero when not present 1823 return win; 1824 } 1825 #endif 1687 1826 #endif 1688 1827 -
trunk/source/Lib/TLibEncoder/TEncTop.h
r815 r906 125 125 static Int m_iSPSIdCnt; ///< next Id number for SPS 126 126 static Int m_iPPSIdCnt; ///< next Id number for PPS 127 #if AVC_SYNTAX128 fstream* m_pBLSyntaxFile;129 #endif130 127 TEncTop** m_ppcTEncTop; 131 128 TEncTop* getLayerEnc(UInt layer) { return m_ppcTEncTop[layer]; } … … 139 136 #endif 140 137 Window m_scaledRefLayerWindow[MAX_LAYERS]; 138 #if REF_REGION_OFFSET 139 UInt m_numRefLayerOffsets; 140 UInt m_refLayerId[MAX_LAYERS]; 141 Window m_refLayerWindow[MAX_LAYERS]; 142 Bool m_scaledRefLayerOffsetPresentFlag[MAX_LAYERS]; 143 Bool m_refRegionOffsetPresentFlag[MAX_LAYERS]; 144 #endif 145 #if R0209_GENERIC_PHASE 146 Int m_phaseHorLuma [MAX_LAYERS]; 147 Int m_phaseVerLuma [MAX_LAYERS]; 148 Int m_phaseHorChroma[MAX_LAYERS]; 149 Int m_phaseVerChroma[MAX_LAYERS]; 150 Int m_resamplePhaseSetPresentFlag[MAX_LAYERS]; 151 #endif 141 152 #if P0312_VERT_PHASE_ADJ 142 153 Bool m_vertPhasePositionEnableFlag[MAX_LAYERS]; … … 156 167 #if Q0078_ADD_LAYER_SETS 157 168 int m_numAddLayerSets; 169 #endif 170 #if P0297_VPS_POC_LSB_ALIGNED_FLAG 171 Bool m_pocDecrementedInDPBFlag; 172 Int m_currPocMsb; 158 173 #endif 159 174 #endif //SVC_EXTENSION … … 232 247 #endif 233 248 Window& getScaledRefLayerWindow(Int x) { return m_scaledRefLayerWindow[x]; } 249 #if REF_REGION_OFFSET 250 Void setNumRefLayerOffsets(Int x) { m_numRefLayerOffsets = x; } 251 UInt getNumRefLayerOffsets() { return m_numRefLayerOffsets; } 252 Void setRefLayerId(Int x, UInt id) { m_refLayerId[x] = id; } 253 UInt getRefLayerId(Int x) { return m_refLayerId[x]; } 254 Window& getRefLayerWindowForLayer(Int layerId); 255 Window& getRefLayerWindow(Int x) { return m_refLayerWindow[x]; } 256 Bool getScaledRefLayerOffsetPresentFlag(Int x) { return m_scaledRefLayerOffsetPresentFlag[x]; } 257 Void setScaledRefLayerOffsetPresentFlag(Int x, Bool b) { m_scaledRefLayerOffsetPresentFlag[x] = b; } 258 Bool getRefRegionOffsetPresentFlag(Int x) { return m_refRegionOffsetPresentFlag[x]; } 259 Void setRefRegionOffsetPresentFlag(Int x, Bool b) { m_refRegionOffsetPresentFlag[x] = b; } 260 #endif 234 261 #if P0312_VERT_PHASE_ADJ 235 262 Void setVertPhasePositionEnableFlag(Int x, Bool b) { m_vertPhasePositionEnableFlag[x] = b; } 236 263 UInt getVertPhasePositionEnableFlag(Int x) { return m_vertPhasePositionEnableFlag[x]; } 264 #endif 265 #if R0209_GENERIC_PHASE 266 Int getPhaseHorLuma(Int x) { return m_phaseHorLuma[x]; } 267 Int getPhaseVerLuma(Int x) { return m_phaseVerLuma[x]; } 268 Int getPhaseHorChroma(Int x) { return m_phaseHorChroma[x]; } 269 Int getPhaseVerChroma(Int x) { return m_phaseVerChroma[x]; } 270 Void setPhaseHorLuma(Int x, Int val) { m_phaseHorLuma[x] = val; } 271 Void setPhaseVerLuma(Int x, Int val) { m_phaseVerLuma[x] = val; } 272 Void setPhaseHorChroma(Int x, Int val) { m_phaseHorChroma[x] = val; } 273 Void setPhaseVerChroma(Int x, Int val) { m_phaseVerChroma[x] = val; } 274 Bool getResamplePhaseSetPresentFlag(Int x) { return m_resamplePhaseSetPresentFlag[x]; } 275 Void setResamplePhaseSetPresentFlag(Int x, Bool b) { m_resamplePhaseSetPresentFlag[x] = b; } 237 276 #endif 238 277 … … 245 284 Void setInterLayerWeightedPredFlag(Bool flag) { m_interLayerWeightedPredFlag = flag; } 246 285 Bool getInterLayerWeightedPredFlag() { return m_interLayerWeightedPredFlag; } 247 #endif248 #if AVC_SYNTAX249 Void setBLSyntaxFile( fstream* pFile ) { m_pBLSyntaxFile = pFile; }250 fstream* getBLSyntaxFile() { return m_pBLSyntaxFile; }251 286 #endif 252 287 Void encode( TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut, std::list<AccessUnit>& accessUnitsOut, Int iPicIdInGOP ); … … 275 310 Int getNumAddLayerSets() { return m_numAddLayerSets; } 276 311 #endif 312 #if P0297_VPS_POC_LSB_ALIGNED_FLAG 313 Void setPocDecrementedInDPBFlag(Bool x) { m_pocDecrementedInDPBFlag = x; } 314 Bool getPocDecrementedInDPBFlag() { return m_pocDecrementedInDPBFlag; } 315 Void setCurrPocMsb(Int poc) { m_currPocMsb = poc; } 316 Int getCurrPocMsb() { return m_currPocMsb; } 317 #endif 277 318 #else //SVC_EXTENSION 278 319 Void encode( Bool bEos, TComPicYuv* pcPicYuvOrg, TComList<TComPicYuv*>& rcListPicYuvRecOut,
Note: See TracChangeset for help on using the changeset viewer.