Changeset 906 in SHVCSoftware for trunk/source/Lib/TLibDecoder
- Timestamp:
- 15 Oct 2014, 07:25:10 (10 years ago)
- Location:
- trunk
- Files:
-
- 12 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/TLibDecoder/SEIread.cpp
r815 r906 98 98 break; 99 99 #endif 100 #if Q0074_ SEI_COLOR_MAPPING101 case SEI::COLO R_MAPPING_INFO:102 fprintf( g_hTrace, "===========Colo r Mapping InfoSEI message ===========\n");100 #if Q0074_COLOUR_REMAPPING_SEI 101 case SEI::COLOUR_REMAPPING_INFO: 102 fprintf( g_hTrace, "===========Colour Remapping Information SEI message ===========\n"); 103 103 break; 104 104 #endif … … 132 132 fprintf( g_hTrace, "=========== Bitstream parition initial arrival time SEI message ===========\n"); 133 133 break; 134 #if !REMOVE_BSP_HRD_SEI 134 135 case SEI::BSP_HRD: 135 136 fprintf( g_hTrace, "=========== Bitstream parition HRD parameters SEI message ===========\n"); 136 137 break; 138 #endif 137 139 #endif 138 140 #if Q0078_ADD_LAYER_SETS … … 249 251 { 250 252 sei = new SEIDecodingUnitInfo; 253 #if VPS_VUI_BSP_HRD_PARAMS 254 xParseSEIDecodingUnitInfo((SEIDecodingUnitInfo&) *sei, payloadSize, sps, nestingSei, bspNestingSei, vps); 255 #else 251 256 xParseSEIDecodingUnitInfo((SEIDecodingUnitInfo&) *sei, payloadSize, sps); 257 #endif 252 258 } 253 259 break; … … 260 266 { 261 267 sei = new SEIBufferingPeriod; 268 #if VPS_VUI_BSP_HRD_PARAMS 269 xParseSEIBufferingPeriod((SEIBufferingPeriod&) *sei, payloadSize, sps, nestingSei, bspNestingSei, vps); 270 #else 262 271 xParseSEIBufferingPeriod((SEIBufferingPeriod&) *sei, payloadSize, sps); 272 #endif 263 273 } 264 274 break; … … 271 281 { 272 282 sei = new SEIPictureTiming; 283 #if VPS_VUI_BSP_HRD_PARAMS 284 xParseSEIPictureTiming((SEIPictureTiming&)*sei, payloadSize, sps, nestingSei, bspNestingSei, vps); 285 #else 273 286 xParseSEIPictureTiming((SEIPictureTiming&)*sei, payloadSize, sps); 287 #endif 274 288 } 275 289 break; … … 304 318 break; 305 319 #endif 306 #if Q0074_ SEI_COLOR_MAPPING307 case SEI::COLO R_MAPPING_INFO:308 sei = new SEIColo rMappingInfo;309 xParseSEIColo rMappingInfo((SEIColorMappingInfo&) *sei, payloadSize);320 #if Q0074_COLOUR_REMAPPING_SEI 321 case SEI::COLOUR_REMAPPING_INFO: 322 sei = new SEIColourRemappingInfo; 323 xParseSEIColourRemappingInfo((SEIColourRemappingInfo&) *sei, payloadSize); 310 324 break; 311 325 #endif … … 345 359 case SEI::SUB_BITSTREAM_PROPERTY: 346 360 sei = new SEISubBitstreamProperty; 361 #if OLS_IDX_CHK 362 xParseSEISubBitstreamProperty((SEISubBitstreamProperty&) *sei, vps); 363 #else 347 364 xParseSEISubBitstreamProperty((SEISubBitstreamProperty&) *sei); 365 #endif 348 366 break; 349 367 #endif … … 361 379 xParseSEIBspInitialArrivalTime((SEIBspInitialArrivalTime&) *sei, vps, sps, *nestingSei, *bspNestingSei); 362 380 break; 381 #if !REMOVE_BSP_HRD_SEI 363 382 case SEI::BSP_HRD: 364 383 sei = new SEIBspHrd; 365 384 xParseSEIBspHrd((SEIBspHrd&) *sei, sps, *nestingSei); 366 385 break; 386 #endif 367 387 #endif 368 388 #if Q0078_ADD_LAYER_SETS … … 580 600 581 601 sei.activeSeqParameterSetId.resize(sei.numSpsIdsMinus1 + 1); 602 #if R0247_SEI_ACTIVE 603 sei.layerSpsIdx.resize(sei.numSpsIdsMinus1 + 1); 604 #endif 582 605 for (Int i=0; i < (sei.numSpsIdsMinus1 + 1); i++) 583 606 { 584 607 READ_UVLC(val, "active_seq_parameter_set_id"); sei.activeSeqParameterSetId[i] = val; 585 608 } 586 609 #if R0247_SEI_ACTIVE 610 for (Int i=1; i < (sei.numSpsIdsMinus1 + 1); i++) 611 { 612 READ_UVLC(val, "layer_sps_idx"); sei.layerSpsIdx[i] = val; 613 } 614 #endif 587 615 xParseByteAlign(); 588 616 } 589 617 618 #if VPS_VUI_BSP_HRD_PARAMS 619 Void SEIReader::xParseSEIDecodingUnitInfo(SEIDecodingUnitInfo& sei, UInt /*payloadSize*/, TComSPS *sps, const SEIScalableNesting* nestingSei, const SEIBspNesting* bspNestingSei, TComVPS *vps) 620 #else 590 621 Void SEIReader::xParseSEIDecodingUnitInfo(SEIDecodingUnitInfo& sei, UInt /*payloadSize*/, TComSPS *sps) 622 #endif 591 623 { 592 624 UInt val; … … 594 626 sei.m_decodingUnitIdx = val; 595 627 628 #if VPS_VUI_BSP_HRD_PARAMS 629 TComHRD *hrd; 630 if( bspNestingSei ) // If DU info SEI contained inside a BSP nesting SEI message 631 { 632 assert( nestingSei ); 633 Int psIdx = bspNestingSei->m_seiPartitioningSchemeIdx; 634 Int seiOlsIdx = bspNestingSei->m_seiOlsIdx; 635 Int maxTemporalId = nestingSei->m_nestingMaxTemporalIdPlus1[0] - 1; 636 Int maxValues = vps->getNumBspSchedulesMinus1(seiOlsIdx, psIdx, maxTemporalId) + 1; 637 std::vector<Int> hrdIdx(maxValues, 0); 638 std::vector<TComHRD *> hrdVec; 639 std::vector<Int> syntaxElemLen(maxValues, 0); 640 for(Int i = 0; i < maxValues; i++) 641 { 642 hrdIdx[i] = vps->getBspHrdIdx( seiOlsIdx, psIdx, maxTemporalId, i, bspNestingSei->m_bspIdx); 643 hrdVec.push_back(vps->getBspHrd(hrdIdx[i])); 644 645 syntaxElemLen[i] = hrdVec[i]->getInitialCpbRemovalDelayLengthMinus1() + 1; 646 if ( !(hrdVec[i]->getNalHrdParametersPresentFlag() || hrdVec[i]->getVclHrdParametersPresentFlag()) ) 647 { 648 assert( syntaxElemLen[i] == 24 ); // Default of value init_cpb_removal_delay_length_minus1 is 23 649 } 650 if( i > 0 ) 651 { 652 assert( hrdVec[i]->getSubPicCpbParamsPresentFlag() == hrdVec[i-1]->getSubPicCpbParamsPresentFlag() ); 653 assert( hrdVec[i]->getSubPicCpbParamsInPicTimingSEIFlag() == hrdVec[i-1]->getSubPicCpbParamsInPicTimingSEIFlag() ); 654 assert( hrdVec[i]->getDpbOutputDelayDuLengthMinus1() == hrdVec[i-1]->getDpbOutputDelayDuLengthMinus1() ); 655 // To be done: Check CpbDpbDelaysPresentFlag 656 } 657 } 658 hrd = hrdVec[0]; 659 } 660 else 661 { 662 TComVUI *vui = sps->getVuiParameters(); 663 hrd = vui->getHrdParameters(); 664 } 665 #else 596 666 TComVUI *vui = sps->getVuiParameters(); 597 if(vui->getHrdParameters()->getSubPicCpbParamsInPicTimingSEIFlag()) 598 { 599 READ_CODE( ( vui->getHrdParameters()->getDuCpbRemovalDelayLengthMinus1() + 1 ), val, "du_spt_cpb_removal_delay"); 667 TComHrd *hrd = vui->getHrdParameters(); 668 #endif 669 if(hrd->getSubPicCpbParamsInPicTimingSEIFlag()) 670 { 671 READ_CODE( ( hrd->getDuCpbRemovalDelayLengthMinus1() + 1 ), val, "du_spt_cpb_removal_delay"); 600 672 sei.m_duSptCpbRemovalDelay = val; 601 673 } … … 607 679 if(sei.m_dpbOutputDuDelayPresentFlag) 608 680 { 609 READ_CODE( vui->getHrdParameters()->getDpbOutputDelayDuLengthMinus1() + 1, val, "pic_spt_dpb_output_du_delay");681 READ_CODE(hrd->getDpbOutputDelayDuLengthMinus1() + 1, val, "pic_spt_dpb_output_du_delay"); 610 682 sei.m_picSptDpbOutputDuDelay = val; 611 683 } … … 613 685 } 614 686 687 #if VPS_VUI_BSP_HRD_PARAMS 688 Void SEIReader::xParseSEIBufferingPeriod(SEIBufferingPeriod& sei, UInt /*payloadSize*/, TComSPS *sps, const SEIScalableNesting* nestingSei, const SEIBspNesting* bspNestingSei, TComVPS *vps) 689 #else 615 690 Void SEIReader::xParseSEIBufferingPeriod(SEIBufferingPeriod& sei, UInt /*payloadSize*/, TComSPS *sps) 691 #endif 616 692 { 617 693 Int i, nalOrVcl; 618 694 UInt code; 619 695 696 #if VPS_VUI_BSP_HRD_PARAMS 697 TComHRD *pHRD; 698 if( bspNestingSei ) // If BP SEI contained inside a BSP nesting SEI message 699 { 700 assert( nestingSei ); 701 Int psIdx = bspNestingSei->m_seiPartitioningSchemeIdx; 702 Int seiOlsIdx = bspNestingSei->m_seiOlsIdx; 703 Int maxTemporalId = nestingSei->m_nestingMaxTemporalIdPlus1[0] - 1; 704 Int maxValues = vps->getNumBspSchedulesMinus1(seiOlsIdx, psIdx, maxTemporalId) + 1; 705 std::vector<Int> hrdIdx(maxValues, 0); 706 std::vector<TComHRD *> hrdVec; 707 std::vector<Int> syntaxElemLen(maxValues, 0); 708 for(i = 0; i < maxValues; i++) 709 { 710 hrdIdx[i] = vps->getBspHrdIdx( seiOlsIdx, psIdx, maxTemporalId, i, bspNestingSei->m_bspIdx); 711 hrdVec.push_back(vps->getBspHrd(hrdIdx[i])); 712 713 syntaxElemLen[i] = hrdVec[i]->getInitialCpbRemovalDelayLengthMinus1() + 1; 714 if ( !(hrdVec[i]->getNalHrdParametersPresentFlag() || hrdVec[i]->getVclHrdParametersPresentFlag()) ) 715 { 716 assert( syntaxElemLen[i] == 24 ); // Default of value init_cpb_removal_delay_length_minus1 is 23 717 } 718 if( i > 0 ) 719 { 720 assert( hrdVec[i]->getCpbRemovalDelayLengthMinus1() == hrdVec[i-1]->getCpbRemovalDelayLengthMinus1() ); 721 assert( hrdVec[i]->getDpbOutputDelayDuLengthMinus1() == hrdVec[i-1]->getDpbOutputDelayDuLengthMinus1() ); 722 assert( hrdVec[i]->getSubPicCpbParamsPresentFlag() == hrdVec[i-1]->getSubPicCpbParamsPresentFlag() ); 723 } 724 } 725 pHRD = hrdVec[i]; 726 } 727 else 728 { 729 TComVUI *vui = sps->getVuiParameters(); 730 pHRD = vui->getHrdParameters(); 731 } 732 // To be done: When contained in an BSP HRD SEI message, the hrd structure is to be chosen differently. 733 #else 620 734 TComVUI *pVUI = sps->getVuiParameters(); 621 735 TComHRD *pHRD = pVUI->getHrdParameters(); 736 #endif 622 737 623 738 READ_UVLC( code, "bp_seq_parameter_set_id" ); sei.m_bpSeqParameterSetId = code; … … 671 786 xParseByteAlign(); 672 787 } 788 #if VPS_VUI_BSP_HRD_PARAMS 789 Void SEIReader::xParseSEIPictureTiming(SEIPictureTiming& sei, UInt /*payloadSize*/, TComSPS *sps, const SEIScalableNesting* nestingSei, const SEIBspNesting* bspNestingSei, TComVPS *vps) 790 #else 673 791 Void SEIReader::xParseSEIPictureTiming(SEIPictureTiming& sei, UInt /*payloadSize*/, TComSPS *sps) 792 #endif 674 793 { 675 794 Int i; 676 795 UInt code; 677 796 797 #if VPS_VUI_BSP_HRD_PARAMS 798 TComHRD *hrd; 799 TComVUI *vui = sps->getVuiParameters(); 800 if( bspNestingSei ) // If BP SEI contained inside a BSP nesting SEI message 801 { 802 assert( nestingSei ); 803 Int psIdx = bspNestingSei->m_seiPartitioningSchemeIdx; 804 Int seiOlsIdx = bspNestingSei->m_seiOlsIdx; 805 Int maxTemporalId = nestingSei->m_nestingMaxTemporalIdPlus1[0] - 1; 806 Int maxValues = vps->getNumBspSchedulesMinus1(seiOlsIdx, psIdx, maxTemporalId) + 1; 807 std::vector<Int> hrdIdx(maxValues, 0); 808 std::vector<TComHRD *> hrdVec; 809 std::vector<Int> syntaxElemLen(maxValues, 0); 810 for(i = 0; i < maxValues; i++) 811 { 812 hrdIdx[i] = vps->getBspHrdIdx( seiOlsIdx, psIdx, maxTemporalId, i, bspNestingSei->m_bspIdx); 813 hrdVec.push_back(vps->getBspHrd(hrdIdx[i])); 814 815 syntaxElemLen[i] = hrdVec[i]->getInitialCpbRemovalDelayLengthMinus1() + 1; 816 if ( !(hrdVec[i]->getNalHrdParametersPresentFlag() || hrdVec[i]->getVclHrdParametersPresentFlag()) ) 817 { 818 assert( syntaxElemLen[i] == 24 ); // Default of value init_cpb_removal_delay_length_minus1 is 23 819 } 820 if( i > 0 ) 821 { 822 assert( hrdVec[i]->getSubPicCpbParamsPresentFlag() == hrdVec[i-1]->getSubPicCpbParamsPresentFlag() ); 823 assert( hrdVec[i]->getSubPicCpbParamsInPicTimingSEIFlag() == hrdVec[i-1]->getSubPicCpbParamsInPicTimingSEIFlag() ); 824 assert( hrdVec[i]->getCpbRemovalDelayLengthMinus1() == hrdVec[i-1]->getCpbRemovalDelayLengthMinus1() ); 825 assert( hrdVec[i]->getDpbOutputDelayLengthMinus1() == hrdVec[i-1]->getDpbOutputDelayLengthMinus1() ); 826 assert( hrdVec[i]->getDpbOutputDelayDuLengthMinus1() == hrdVec[i-1]->getDpbOutputDelayDuLengthMinus1() ); 827 assert( hrdVec[i]->getDuCpbRemovalDelayLengthMinus1() == hrdVec[i-1]->getDuCpbRemovalDelayLengthMinus1() ); 828 // To be done: Check CpbDpbDelaysPresentFlag 829 } 830 } 831 hrd = hrdVec[0]; 832 } 833 else 834 { 835 hrd = vui->getHrdParameters(); 836 } 837 // To be done: When contained in an BSP HRD SEI message, the hrd structure is to be chosen differently. 838 #else 678 839 TComVUI *vui = sps->getVuiParameters(); 679 840 TComHRD *hrd = vui->getHrdParameters(); 841 #endif 680 842 681 843 if( vui->getFrameFieldInfoPresentFlag() ) … … 921 1083 #endif 922 1084 923 #if Q0074_ SEI_COLOR_MAPPING924 Void SEIReader::xParseSEIColo rMappingInfo(SEIColorMappingInfo& sei, UInt /*payloadSize*/)1085 #if Q0074_COLOUR_REMAPPING_SEI 1086 Void SEIReader::xParseSEIColourRemappingInfo(SEIColourRemappingInfo& sei, UInt /*payloadSize*/) 925 1087 { 926 1088 UInt uiVal; 927 1089 Int iVal; 928 1090 929 READ_UVLC( uiVal, "colour_map_id" ); sei.m_colorMapId = uiVal; 930 READ_FLAG( uiVal, "colour_map_cancel_flag" ); sei.m_colorMapCancelFlag = uiVal; 931 if( !sei.m_colorMapCancelFlag ) 932 { 933 READ_FLAG( uiVal, "colour_map_persistence_flag" ); sei.m_colorMapPersistenceFlag = uiVal; 934 READ_FLAG( uiVal, "colour_map_video_signal_type_present_flag" ); sei.m_colorMap_video_signal_type_present_flag = uiVal; 935 if ( sei.m_colorMap_video_signal_type_present_flag ) { 936 READ_FLAG( uiVal, "colour_map_video_full_range_flag" ); sei.m_colorMap_video_full_range_flag = uiVal; 937 READ_CODE( 8, uiVal, "colour_map_primaries" ); sei.m_colorMap_primaries = uiVal; 938 READ_CODE( 8, uiVal, "colour_map_transfer_characteristics" ); sei.m_colorMap_transfer_characteristics = uiVal; 939 READ_CODE( 8, uiVal, "colour_map_matrix_coeffs" ); sei.m_colorMap_matrix_coeffs = uiVal; 940 } 941 } 942 943 READ_CODE( 5, uiVal, "colour_map_coded_data_bit_depth" ); sei.m_colour_map_coded_data_bit_depth = uiVal; 944 READ_CODE( 5, uiVal, "colour_map_target_bit_depth" ); sei.m_colour_map_target_bit_depth = uiVal; 945 READ_UVLC( uiVal, "colour_map_model_id" ); sei.m_colorMapModelId = uiVal; 946 947 assert( sei.m_colorMapModelId == 0 ); 1091 READ_UVLC( uiVal, "colour_remap_id" ); sei.m_colourRemapId = uiVal; 1092 READ_FLAG( uiVal, "colour_remap_cancel_flag" ); sei.m_colourRemapCancelFlag = uiVal; 1093 if( !sei.m_colourRemapCancelFlag ) 1094 { 1095 READ_FLAG( uiVal, "colour_remap_persistence_flag" ); sei.m_colourRemapPersistenceFlag = uiVal; 1096 READ_FLAG( uiVal, "colour_remap_video_signal_info_present_flag" ); sei.m_colourRemapVideoSignalInfoPresentFlag = uiVal; 1097 if ( sei.m_colourRemapVideoSignalInfoPresentFlag ) 1098 { 1099 READ_FLAG( uiVal, "colour_remap_full_range_flag" ); sei.m_colourRemapFullRangeFlag = uiVal; 1100 READ_CODE( 8, uiVal, "colour_remap_primaries" ); sei.m_colourRemapPrimaries = uiVal; 1101 READ_CODE( 8, uiVal, "colour_remap_transfer_function" ); sei.m_colourRemapTransferFunction = uiVal; 1102 READ_CODE( 8, uiVal, "colour_remap_matrix_coefficients" ); sei.m_colourRemapMatrixCoefficients = uiVal; 1103 } 1104 READ_CODE( 8, uiVal, "colour_remap_input_bit_depth" ); sei.m_colourRemapInputBitDepth = uiVal; 1105 READ_CODE( 8, uiVal, "colour_remap_bit_depth" ); sei.m_colourRemapBitDepth = uiVal; 948 1106 949 for( Int i=0 ; i<3 ; i++ ) 950 { 951 READ_CODE( 8, uiVal, "num_input_pivots_minus1[i]" ); sei.m_num_input_pivots[i] = (uiVal==0) ? 2 : (uiVal + 1) ; 952 sei.m_coded_input_pivot_value[i] = new Int[ sei.m_num_input_pivots[i] ]; 953 sei.m_target_input_pivot_value[i] = new Int[ sei.m_num_input_pivots[i] ]; 954 if( uiVal > 0 ) 955 { 956 for ( Int j=0 ; j<sei.m_num_input_pivots[i] ; j++ ) 957 { 958 READ_CODE( (( sei.m_colour_map_coded_data_bit_depth + 7 ) >> 3 ) << 3, uiVal, "coded_input_pivot_value[i][j]" ); sei.m_coded_input_pivot_value[i][j] = uiVal; 959 READ_CODE( (( sei.m_colour_map_coded_data_bit_depth + 7 ) >> 3 ) << 3, uiVal, "target_input_pivot_value[i][j]" ); sei.m_target_input_pivot_value[i][j] = uiVal; 960 } 961 } 962 else 963 { 964 sei.m_coded_input_pivot_value[i][0] = 0; 965 sei.m_target_input_pivot_value[i][0] = 0; 966 sei.m_coded_input_pivot_value[i][1] = (1 << sei.m_colour_map_coded_data_bit_depth) - 1 ; 967 sei.m_target_input_pivot_value[i][1] = (1 << sei.m_colour_map_target_bit_depth) - 1 ; 968 } 969 } 970 971 READ_FLAG( uiVal, "matrix_flag" ); sei.m_matrix_flag = uiVal; 972 if( sei.m_matrix_flag ) 973 { 974 READ_CODE( 4, uiVal, "log2_matrix_denom" ); sei.m_log2_matrix_denom = uiVal; 975 for ( Int i=0 ; i<3 ; i++ ) 976 { 977 for ( Int j=0 ; j<3 ; j++ ) 978 { 979 READ_SVLC( iVal, "matrix_coef[i][j]" ); sei.m_matrix_coef[i][j] = iVal; 980 } 981 } 982 } 983 984 for ( Int i=0 ; i<3 ; i++ ) 985 { 986 READ_CODE( 8, uiVal, "num_output_pivots_minus1[i]" ); sei.m_num_output_pivots[i] = (uiVal==0) ? 2 : (uiVal + 1) ; 987 sei.m_coded_output_pivot_value[i] = new Int[ sei.m_num_output_pivots[i] ]; 988 sei.m_target_output_pivot_value[i] = new Int[ sei.m_num_output_pivots[i] ]; 989 if( uiVal > 0 ) 990 { 991 for ( Int j=0 ; j<sei.m_num_output_pivots[i] ; j++ ) 992 { 993 READ_CODE( (( sei.m_colour_map_coded_data_bit_depth + 7 ) >> 3 ) << 3, uiVal, "coded_output_pivot_value[i][j]" ); sei.m_coded_output_pivot_value[i][j] = uiVal; 994 READ_CODE( (( sei.m_colour_map_coded_data_bit_depth + 7 ) >> 3 ) << 3, uiVal, "target_output_pivot_value[i][j]" ); sei.m_target_output_pivot_value[i][j] = uiVal; 995 } 996 } 997 else 998 { 999 sei.m_coded_output_pivot_value[i][0] = 0; 1000 sei.m_target_output_pivot_value[i][0] = 0; 1001 sei.m_coded_output_pivot_value[i][1] = (1 << sei.m_colour_map_coded_data_bit_depth) - 1 ; 1002 sei.m_target_output_pivot_value[i][1] = (1 << sei.m_colour_map_target_bit_depth) - 1 ; 1107 for( Int c=0 ; c<3 ; c++ ) 1108 { 1109 READ_CODE( 8, uiVal, "pre_lut_num_val_minus1[c]" ); sei.m_preLutNumValMinus1[c] = (uiVal==0) ? 1 : uiVal; 1110 sei.m_preLutCodedValue[c].resize(sei.m_preLutNumValMinus1[c]+1); 1111 sei.m_preLutTargetValue[c].resize(sei.m_preLutNumValMinus1[c]+1); 1112 if( uiVal> 0 ) 1113 for ( Int i=0 ; i<=sei.m_preLutNumValMinus1[c] ; i++ ) 1114 { 1115 READ_CODE( (( sei.m_colourRemapInputBitDepth + 7 ) >> 3 ) << 3, uiVal, "pre_lut_coded_value[c][i]" ); sei.m_preLutCodedValue[c][i] = uiVal; 1116 READ_CODE( (( sei.m_colourRemapBitDepth + 7 ) >> 3 ) << 3, uiVal, "pre_lut_target_value[c][i]" ); sei.m_preLutTargetValue[c][i] = uiVal; 1117 } 1118 else // pre_lut_num_val_minus1[c] == 0 1119 { 1120 sei.m_preLutCodedValue[c][0] = 0; 1121 sei.m_preLutTargetValue[c][0] = 0; 1122 sei.m_preLutCodedValue[c][1] = (1 << sei.m_colourRemapInputBitDepth) - 1 ; 1123 sei.m_preLutTargetValue[c][1] = (1 << sei.m_colourRemapBitDepth) - 1 ; 1124 } 1125 } 1126 1127 READ_FLAG( uiVal, "colour_remap_matrix_present_flag" ); sei.m_colourRemapMatrixPresentFlag = uiVal; 1128 if( sei.m_colourRemapMatrixPresentFlag ) 1129 { 1130 READ_CODE( 4, uiVal, "log2_matrix_denom" ); sei.m_log2MatrixDenom = uiVal; 1131 for ( Int c=0 ; c<3 ; c++ ) 1132 for ( Int i=0 ; i<3 ; i++ ) 1133 { 1134 READ_SVLC( iVal, "colour_remap_coeffs[c][i]" ); sei.m_colourRemapCoeffs[c][i] = iVal; 1135 } 1136 } 1137 else // setting default matrix (I3) 1138 { 1139 sei.m_log2MatrixDenom = 0; 1140 for ( Int c=0 ; c<3 ; c++ ) 1141 for ( Int i=0 ; i<3 ; i++ ) 1142 sei.m_colourRemapCoeffs[c][i] = (c==i) ? 1 : 0; 1143 } 1144 for( Int c=0 ; c<3 ; c++ ) 1145 { 1146 READ_CODE( 8, uiVal, "post_lut_num_val_minus1[c]" ); sei.m_postLutNumValMinus1[c] = (uiVal==0) ? 1 : uiVal; 1147 sei.m_postLutCodedValue[c].resize(sei.m_postLutNumValMinus1[c]+1); 1148 sei.m_postLutTargetValue[c].resize(sei.m_postLutNumValMinus1[c]+1); 1149 if( uiVal > 0 ) 1150 for ( Int i=0 ; i<=sei.m_postLutNumValMinus1[c] ; i++ ) 1151 { 1152 READ_CODE( (( sei.m_colourRemapBitDepth + 7 ) >> 3 ) << 3, uiVal, "post_lut_coded_value[c][i]" ); sei.m_postLutCodedValue[c][i] = uiVal; 1153 READ_CODE( (( sei.m_colourRemapBitDepth + 7 ) >> 3 ) << 3, uiVal, "post_lut_target_value[c][i]" ); sei.m_postLutTargetValue[c][i] = uiVal; 1154 } 1155 else 1156 { 1157 sei.m_postLutCodedValue[c][0] = 0; 1158 sei.m_postLutTargetValue[c][0] = 0; 1159 sei.m_postLutTargetValue[c][1] = (1 << sei.m_colourRemapBitDepth) - 1; 1160 sei.m_postLutCodedValue[c][1] = (1 << sei.m_colourRemapBitDepth) - 1; 1161 } 1003 1162 } 1004 1163 } … … 1194 1353 #endif 1195 1354 #if SUB_BITSTREAM_PROPERTY_SEI 1355 #if OLS_IDX_CHK 1356 Void SEIReader::xParseSEISubBitstreamProperty(SEISubBitstreamProperty &sei, TComVPS *vps) 1357 #else 1196 1358 Void SEIReader::xParseSEISubBitstreamProperty(SEISubBitstreamProperty &sei) 1359 #endif 1197 1360 { 1198 1361 UInt uiCode; … … 1203 1366 { 1204 1367 READ_CODE( 2, uiCode, "sub_bitstream_mode[i]" ); sei.m_subBitstreamMode[i] = uiCode; 1205 READ_UVLC( uiCode, "output_layer_set_idx_to_vps[i]" ); sei.m_outputLayerSetIdxToVps[i] = uiCode; 1368 READ_UVLC( uiCode, "output_layer_set_idx_to_vps[i]" ); 1369 #if OLS_IDX_CHK 1370 // The value of output_layer_set_idx_to_vps[ i ] shall be in the range of 0 to NumOutputLayerSets − 1, inclusive. 1371 assert(uiCode > 0 && uiCode <= vps->getNumOutputLayerSets()-1); 1372 #endif 1373 sei.m_outputLayerSetIdxToVps[i] = uiCode; 1206 1374 READ_CODE( 3, uiCode, "highest_sub_layer_id[i]" ); sei.m_highestSublayerId[i] = uiCode; 1207 1375 READ_CODE( 16, uiCode, "avg_bit_rate[i]" ); sei.m_avgBitRate[i] = uiCode; … … 1232 1400 1233 1401 // read nested SEI messages 1402 #if NESTING_SEI_EXTENSIBILITY 1403 Int numSeiMessages = 0; 1404 READ_UVLC( uiCode, "num_seis_in_bsp_minus1" ); assert( uiCode <= MAX_SEIS_IN_BSP_NESTING ); 1405 numSeiMessages = uiCode; 1406 for(Int i = 0; i < numSeiMessages; i++) 1407 { 1408 xReadSEImessage(sei.m_nestedSEIs, nalUnitType, vps, sps, &nestingSei, &sei); 1409 } 1410 #else 1234 1411 do { 1235 1412 #if LAYERS_NOT_PRESENT_SEI … … 1239 1416 #endif 1240 1417 } while (m_pcBitstream->getNumBitsLeft() > 8); 1418 #endif 1241 1419 } 1242 1420 … … 1245 1423 assert(vps->getVpsVuiPresentFlag()); 1246 1424 1425 #if VPS_VUI_BSP_HRD_PARAMS 1426 UInt uiCode; 1427 Int psIdx = bspNestingSei.m_seiPartitioningSchemeIdx; 1428 Int seiOlsIdx = bspNestingSei.m_seiOlsIdx; 1429 Int maxTemporalId = nestingSei.m_nestingMaxTemporalIdPlus1[0]; 1430 Int maxValues = vps->getNumBspSchedulesMinus1(seiOlsIdx, psIdx, maxTemporalId) + 1; 1431 std::vector<Int> hrdIdx(0, maxValues); 1432 std::vector<TComHRD *> hrdVec; 1433 std::vector<Int> syntaxElemLen; 1434 for(Int i = 0; i < maxValues; i++) 1435 { 1436 hrdIdx[i] = vps->getBspHrdIdx( seiOlsIdx, psIdx, maxTemporalId, i, bspNestingSei.m_bspIdx); 1437 hrdVec[i] = vps->getBspHrd(hrdIdx[i]); 1438 1439 syntaxElemLen[i] = hrdVec[i]->getInitialCpbRemovalDelayLengthMinus1() + 1; 1440 if ( !(hrdVec[i]->getNalHrdParametersPresentFlag() || hrdVec[i]->getVclHrdParametersPresentFlag()) ) 1441 { 1442 assert( syntaxElemLen[i] == 24 ); // Default value of init_cpb_removal_delay_length_minus1 is 23 1443 } 1444 if( i > 0 ) 1445 { 1446 assert( hrdVec[i]->getNalHrdParametersPresentFlag() == hrdVec[i-1]->getNalHrdParametersPresentFlag() ); 1447 assert( hrdVec[i]->getVclHrdParametersPresentFlag() == hrdVec[i-1]->getVclHrdParametersPresentFlag() ); 1448 } 1449 } 1450 if (hrdVec[0]->getNalHrdParametersPresentFlag()) 1451 { 1452 for(UInt i = 0; i < maxValues; i++) 1453 { 1454 READ_CODE( syntaxElemLen[i], uiCode, "nal_initial_arrival_delay[i]" ); sei.m_nalInitialArrivalDelay[i] = uiCode; 1455 } 1456 } 1457 if( hrdVec[0]->getVclHrdParametersPresentFlag() ) 1458 { 1459 for(UInt i = 0; i < maxValues; i++) 1460 { 1461 READ_CODE( syntaxElemLen[i], uiCode, "vcl_initial_arrival_delay[i]" ); sei.m_vclInitialArrivalDelay[i] = uiCode; 1462 } 1463 } 1464 #else 1247 1465 UInt schedCombCnt = vps->getNumBspSchedCombinations(nestingSei.m_nestingOpIdx[0]); 1248 1466 UInt len; … … 1277 1495 } 1278 1496 } 1497 #if BSP_INIT_ARRIVAL_SEI 1498 if( hrd->getVclHrdParametersPresentFlag() ) 1499 #else 1279 1500 else 1501 #endif 1280 1502 { 1281 1503 for(UInt i = 0; i < schedCombCnt; i++) … … 1284 1506 } 1285 1507 } 1286 } 1287 1508 #endif 1509 } 1510 1511 #if !REMOVE_BSP_HRD_SEI 1288 1512 Void SEIReader::xParseSEIBspHrd(SEIBspHrd &sei, TComSPS *sps, const SEIScalableNesting &nestingSei) 1289 1513 { … … 1371 1595 } 1372 1596 } 1597 #endif 1373 1598 1374 1599 Void SEIReader::xParseHrdParameters(TComHRD *hrd, Bool commonInfPresentFlag, UInt maxNumSubLayersMinus1) -
trunk/source/Lib/TLibDecoder/SEIread.h
r815 r906 80 80 Void xParseSEIuserDataUnregistered (SEIuserDataUnregistered &sei, UInt payloadSize); 81 81 Void xParseSEIActiveParameterSets (SEIActiveParameterSets &sei, UInt payloadSize); 82 Void xParseSEIDecodedPictureHash (SEIDecodedPictureHash& sei, UInt payloadSize); 83 #if VPS_VUI_BSP_HRD_PARAMS 84 Void xParseSEIDecodingUnitInfo (SEIDecodingUnitInfo& sei, UInt payloadSize, TComSPS *sps, const SEIScalableNesting* nestingSei, const SEIBspNesting* bspNestingSei, TComVPS *vps); 85 Void xParseSEIBufferingPeriod (SEIBufferingPeriod& sei, UInt payloadSize, TComSPS *sps, const SEIScalableNesting* nestingSei, const SEIBspNesting* bspNestingSei, TComVPS *vps); 86 Void xParseSEIPictureTiming (SEIPictureTiming& sei, UInt payloadSize, TComSPS *sps, const SEIScalableNesting* nestingSei, const SEIBspNesting* bspNestingSei, TComVPS *vps); 87 #else 82 88 Void xParseSEIDecodingUnitInfo (SEIDecodingUnitInfo& sei, UInt payloadSize, TComSPS *sps); 83 Void xParseSEIDecodedPictureHash (SEIDecodedPictureHash& sei, UInt payloadSize);84 89 Void xParseSEIBufferingPeriod (SEIBufferingPeriod& sei, UInt payloadSize, TComSPS *sps); 85 90 Void xParseSEIPictureTiming (SEIPictureTiming& sei, UInt payloadSize, TComSPS *sps); 91 #endif 86 92 Void xParseSEIRecoveryPoint (SEIRecoveryPoint& sei, UInt payloadSize); 87 93 Void xParseSEIFramePacking (SEIFramePacking& sei, UInt payloadSize); … … 93 99 Void xParseSEIKneeFunctionInfo (SEIKneeFunctionInfo& sei, UInt payloadSize); 94 100 #endif 95 #if Q0074_ SEI_COLOR_MAPPING96 Void xParseSEIColo rMappingInfo (SEIColorMappingInfo& sei, UInt payloadSize);101 #if Q0074_COLOUR_REMAPPING_SEI 102 Void xParseSEIColourRemappingInfo (SEIColourRemappingInfo& sei, UInt payloadSize); 97 103 #endif 98 104 Void xParseSEISOPDescription (SEISOPDescription &sei, UInt payloadSize); … … 101 107 #endif 102 108 #if SUB_BITSTREAM_PROPERTY_SEI 109 #if OLS_IDX_CHK 110 Void xParseSEISubBitstreamProperty (SEISubBitstreamProperty &sei, TComVPS *vps); 111 #else 103 112 Void xParseSEISubBitstreamProperty (SEISubBitstreamProperty &sei); 113 #endif 104 114 #endif 105 115 #if LAYERS_NOT_PRESENT_SEI … … 116 126 #endif 117 127 Void xParseSEIBspInitialArrivalTime(SEIBspInitialArrivalTime &sei, TComVPS *vps, TComSPS *sps, const SEIScalableNesting &nestingSei, const SEIBspNesting &bspNestingSei); 128 #if !REMOVE_BSP_HRD_SEI 118 129 Void xParseSEIBspHrd(SEIBspHrd &sei, TComSPS *sps, const SEIScalableNesting &nestingSei); 130 #endif 119 131 Void xParseHrdParameters(TComHRD *hrd, Bool commonInfPresentFlag, UInt maxNumSubLayersMinus1); 120 132 #endif -
trunk/source/Lib/TLibDecoder/TDecCAVLC.cpp
r815 r906 255 255 if( pcPPS->getTilesEnabledFlag() ) 256 256 { 257 READ_UVLC ( uiCode, "num_tile_columns_minus1" ); pcPPS->setNum ColumnsMinus1( uiCode );258 READ_UVLC ( uiCode, "num_tile_rows_minus1" ); pcPPS->setNum RowsMinus1( uiCode );259 READ_FLAG ( uiCode, "uniform_spacing_flag" ); pcPPS->set UniformSpacingFlag( uiCode);260 261 if( !pcPPS->get UniformSpacingFlag())262 { 263 UInt* columnWidth = (UInt*)malloc(pcPPS->getNumColumnsMinus1()*sizeof(UInt));264 for(UInt i=0; i<pcPPS->getNum ColumnsMinus1(); i++)257 READ_UVLC ( uiCode, "num_tile_columns_minus1" ); pcPPS->setNumTileColumnsMinus1( uiCode ); 258 READ_UVLC ( uiCode, "num_tile_rows_minus1" ); pcPPS->setNumTileRowsMinus1( uiCode ); 259 READ_FLAG ( uiCode, "uniform_spacing_flag" ); pcPPS->setTileUniformSpacingFlag( uiCode == 1 ); 260 261 if( !pcPPS->getTileUniformSpacingFlag()) 262 { 263 std::vector<Int> columnWidth(pcPPS->getNumTileColumnsMinus1()); 264 for(UInt i=0; i<pcPPS->getNumTileColumnsMinus1(); i++) 265 265 { 266 266 READ_UVLC( uiCode, "column_width_minus1" ); 267 267 columnWidth[i] = uiCode+1; 268 268 } 269 pcPPS->setColumnWidth(columnWidth); 270 free(columnWidth); 271 272 UInt* rowHeight = (UInt*)malloc(pcPPS->getNumRowsMinus1()*sizeof(UInt)); 273 for(UInt i=0; i<pcPPS->getNumRowsMinus1(); i++) 269 pcPPS->setTileColumnWidth(columnWidth); 270 271 std::vector<Int> rowHeight (pcPPS->getTileNumRowsMinus1()); 272 for(UInt i=0; i<pcPPS->getTileNumRowsMinus1(); i++) 274 273 { 275 274 READ_UVLC( uiCode, "row_height_minus1" ); 276 275 rowHeight[i] = uiCode + 1; 277 276 } 278 pcPPS->setRowHeight(rowHeight); 279 free(rowHeight); 280 } 281 282 if(pcPPS->getNumColumnsMinus1() !=0 || pcPPS->getNumRowsMinus1() !=0) 277 pcPPS->setTileRowHeight(rowHeight); 278 } 279 280 if(pcPPS->getNumTileColumnsMinus1() !=0 || pcPPS->getTileNumRowsMinus1() !=0) 283 281 { 284 282 READ_FLAG ( uiCode, "loop_filter_across_tiles_enabled_flag" ); pcPPS->setLoopFilterAcrossTilesEnabledFlag( uiCode ? true : false ); … … 297 295 } 298 296 } 299 297 #if !R0042_PROFILE_INDICATION 300 298 #if SCALINGLIST_INFERRING 301 299 if( pcPPS->getLayerId() > 0 ) … … 317 315 { 318 316 #endif 319 320 READ_FLAG( uiCode, "pps_scaling_list_data_present_flag" ); pcPPS->setScalingListPresentFlag( uiCode ? true : false ); 321 322 if(pcPPS->getScalingListPresentFlag ()) 323 { 324 parseScalingList( pcPPS->getScalingList() ); 325 } 326 317 #endif 318 319 READ_FLAG( uiCode, "pps_scaling_list_data_present_flag" ); pcPPS->setScalingListPresentFlag( uiCode ? true : false ); 320 321 if(pcPPS->getScalingListPresentFlag ()) 322 { 323 parseScalingList( pcPPS->getScalingList() ); 324 } 325 #if !R0042_PROFILE_INDICATION 327 326 #if SCALINGLIST_INFERRING 328 327 } 328 #endif 329 329 #endif 330 330 … … 338 338 pcPPS->setSliceHeaderExtensionPresentFlag(uiCode); 339 339 340 #if !R0042_PROFILE_INDICATION 340 341 READ_FLAG( uiCode, "pps_extension_flag"); 342 #else 343 READ_FLAG( uiCode, "pps_extension_present_flag"); 344 #endif 345 346 #if !R0042_PROFILE_INDICATION 341 347 #if POC_RESET_INFO_INFERENCE 342 348 pcPPS->setExtensionFlag( uiCode ? true : false ); … … 361 367 READ_FLAG( uiCode, "poc_reset_info_present_flag" ); 362 368 pcPPS->setPocResetInfoPresentFlag(uiCode ? true : false); 369 #if REF_REGION_OFFSET 370 READ_UVLC( uiCode, "num_scaled_ref_layer_offsets" ); pcPPS->setNumScaledRefLayerOffsets(uiCode); 371 for(Int i = 0; i < pcPPS->getNumScaledRefLayerOffsets(); i++) 372 { 373 READ_CODE( 6, uiCode, "scaled_ref_layer_id" ); pcPPS->setScaledRefLayerId( i, uiCode ); 374 READ_FLAG( uiCode, "scaled_ref_layer_offset_present_flag" ); pcPPS->setScaledRefLayerOffsetPresentFlag( i, uiCode ); 375 if (uiCode) 376 { 377 Window& scaledWindow = pcPPS->getScaledRefLayerWindow(i); 378 READ_SVLC( iCode, "scaled_ref_layer_left_offset" ); scaledWindow.setWindowLeftOffset (iCode << 1); 379 READ_SVLC( iCode, "scaled_ref_layer_top_offset" ); scaledWindow.setWindowTopOffset (iCode << 1); 380 READ_SVLC( iCode, "scaled_ref_layer_right_offset" ); scaledWindow.setWindowRightOffset (iCode << 1); 381 READ_SVLC( iCode, "scaled_ref_layer_bottom_offset" ); scaledWindow.setWindowBottomOffset(iCode << 1); 382 #if P0312_VERT_PHASE_ADJ 383 READ_FLAG( uiCode, "vert_phase_position_enable_flag" ); scaledWindow.setVertPhasePositionEnableFlag(uiCode); pcPPS->setVertPhasePositionEnableFlag( pcPPS->getScaledRefLayerId(i), uiCode); 384 #endif 385 } 386 READ_FLAG( uiCode, "ref_region_offset_present_flag" ); pcPPS->setRefRegionOffsetPresentFlag( i, uiCode ); 387 if (uiCode) 388 { 389 Window& refWindow = pcPPS->getRefLayerWindow(i); 390 READ_SVLC( iCode, "ref_region_left_offset" ); refWindow.setWindowLeftOffset (iCode << 1); 391 READ_SVLC( iCode, "ref_region_top_offset" ); refWindow.setWindowTopOffset (iCode << 1); 392 READ_SVLC( iCode, "ref_region_right_offset" ); refWindow.setWindowRightOffset (iCode << 1); 393 READ_SVLC( iCode, "ref_region_bottom_offset" ); refWindow.setWindowBottomOffset(iCode << 1); 394 } 395 #if R0209_GENERIC_PHASE 396 READ_FLAG( uiCode, "resample_phase_set_present_flag" ); pcPPS->setResamplePhaseSetPresentFlag( i, uiCode ); 397 if (uiCode) 398 { 399 READ_UVLC( uiCode, "phase_hor_luma" ); pcPPS->setPhaseHorLuma ( i, uiCode ); 400 READ_UVLC( uiCode, "phase_ver_luma" ); pcPPS->setPhaseVerLuma ( i, uiCode ); 401 READ_UVLC( uiCode, "phase_hor_chroma_plus8" ); pcPPS->setPhaseHorChroma (i, uiCode - 8); 402 READ_UVLC( uiCode, "phase_ver_chroma_plus8" ); pcPPS->setPhaseVerChroma (i, uiCode - 8); 403 } 404 #endif 405 } 406 #else 407 #if MOVE_SCALED_OFFSET_TO_PPS 408 READ_UVLC( uiCode, "num_scaled_ref_layer_offsets" ); pcPPS->setNumScaledRefLayerOffsets(uiCode); 409 for(Int i = 0; i < pcPPS->getNumScaledRefLayerOffsets(); i++) 410 { 411 Window& scaledWindow = pcPPS->getScaledRefLayerWindow(i); 412 #if O0098_SCALED_REF_LAYER_ID 413 READ_CODE( 6, uiCode, "scaled_ref_layer_id" ); pcPPS->setScaledRefLayerId( i, uiCode ); 414 #endif 415 READ_SVLC( iCode, "scaled_ref_layer_left_offset" ); scaledWindow.setWindowLeftOffset (iCode << 1); 416 READ_SVLC( iCode, "scaled_ref_layer_top_offset" ); scaledWindow.setWindowTopOffset (iCode << 1); 417 READ_SVLC( iCode, "scaled_ref_layer_right_offset" ); scaledWindow.setWindowRightOffset (iCode << 1); 418 READ_SVLC( iCode, "scaled_ref_layer_bottom_offset" ); scaledWindow.setWindowBottomOffset(iCode << 1); 419 #if P0312_VERT_PHASE_ADJ 420 READ_FLAG( uiCode, "vert_phase_position_enable_flag" ); scaledWindow.setVertPhasePositionEnableFlag(uiCode); pcPPS->setVertPhasePositionEnableFlag( pcPPS->getScaledRefLayerId(i), uiCode); 421 #endif 422 } 423 #endif 424 #endif 363 425 #if Q0048_CGS_3D_ASYMLUT 364 426 READ_FLAG( uiCode , "colour_mapping_enabled_flag" ); … … 383 445 #endif 384 446 385 while ( xMoreRbspData() )386 {387 READ_FLAG( uiCode, "pps_extension_data_flag");388 }447 while ( xMoreRbspData() ) 448 { 449 READ_FLAG( uiCode, "pps_extension_data_flag"); 450 } 389 451 #if P0166_MODIFIED_PPS_EXTENSION 390 452 } … … 397 459 } 398 460 #endif 461 #else 462 pcPPS->setExtensionFlag( uiCode ? true : false ); 463 if( pcPPS->getExtensionFlag() ) 464 { 465 READ_FLAG( uiCode, "pps_range_extension_flag" ); 466 assert(uiCode == 0); 467 READ_FLAG( uiCode, "pps_multilayer_extension_flag" ); 468 assert(uiCode == 1); 469 READ_CODE(6, uiCode, "pps_extension_6bits"); 470 assert(uiCode == 0); 471 472 READ_FLAG( uiCode, "poc_reset_info_present_flag" ); 473 pcPPS->setPocResetInfoPresentFlag(uiCode ? true : false); 474 475 #if SCALINGLIST_INFERRING 476 READ_FLAG( uiCode, "pps_infer_scaling_list_flag" ); 477 pcPPS->setInferScalingListFlag( uiCode ); 478 479 if( pcPPS->getInferScalingListFlag() ) 480 { 481 READ_UVLC( uiCode, "pps_scaling_list_ref_layer_id" ); 482 pcPPS->setScalingListRefLayerId( uiCode ); 483 // The value of pps_scaling_list_ref_layer_id shall be in the range of 0 to 62, inclusive 484 assert( pcPPS->getScalingListRefLayerId() <= 62 ); 485 pcPPS->setScalingListPresentFlag( false ); 486 } 487 #endif 488 489 #if REF_REGION_OFFSET 490 READ_UVLC( uiCode, "num_ref_loc_offsets" ); pcPPS->setNumScaledRefLayerOffsets(uiCode); 491 for(Int i = 0; i < pcPPS->getNumScaledRefLayerOffsets(); i++) 492 { 493 READ_CODE( 6, uiCode, "ref_loc_offset_layer_id" ); pcPPS->setScaledRefLayerId( i, uiCode ); 494 READ_FLAG( uiCode, "scaled_ref_layer_offset_present_flag" ); pcPPS->setScaledRefLayerOffsetPresentFlag( i, uiCode ); 495 if (uiCode) 496 { 497 Window& scaledWindow = pcPPS->getScaledRefLayerWindow(i); 498 READ_SVLC( iCode, "scaled_ref_layer_left_offset" ); scaledWindow.setWindowLeftOffset (iCode << 1); 499 READ_SVLC( iCode, "scaled_ref_layer_top_offset" ); scaledWindow.setWindowTopOffset (iCode << 1); 500 READ_SVLC( iCode, "scaled_ref_layer_right_offset" ); scaledWindow.setWindowRightOffset (iCode << 1); 501 READ_SVLC( iCode, "scaled_ref_layer_bottom_offset" ); scaledWindow.setWindowBottomOffset(iCode << 1); 502 #if P0312_VERT_PHASE_ADJ 503 READ_FLAG( uiCode, "vert_phase_position_enable_flag" ); scaledWindow.setVertPhasePositionEnableFlag(uiCode); pcPPS->setVertPhasePositionEnableFlag( pcPPS->getScaledRefLayerId(i), uiCode); 504 #endif 505 } 506 READ_FLAG( uiCode, "ref_region_offset_present_flag" ); pcPPS->setRefRegionOffsetPresentFlag( i, uiCode ); 507 if (uiCode) 508 { 509 Window& refWindow = pcPPS->getRefLayerWindow(i); 510 READ_SVLC( iCode, "ref_region_left_offset" ); refWindow.setWindowLeftOffset (iCode << 1); 511 READ_SVLC( iCode, "ref_region_top_offset" ); refWindow.setWindowTopOffset (iCode << 1); 512 READ_SVLC( iCode, "ref_region_right_offset" ); refWindow.setWindowRightOffset (iCode << 1); 513 READ_SVLC( iCode, "ref_region_bottom_offset" ); refWindow.setWindowBottomOffset(iCode << 1); 514 } 515 #if R0209_GENERIC_PHASE 516 READ_FLAG( uiCode, "resample_phase_set_present_flag" ); pcPPS->setResamplePhaseSetPresentFlag( i, uiCode ); 517 if (uiCode) 518 { 519 READ_UVLC( uiCode, "phase_hor_luma" ); pcPPS->setPhaseHorLuma ( i, uiCode ); 520 READ_UVLC( uiCode, "phase_ver_luma" ); pcPPS->setPhaseVerLuma ( i, uiCode ); 521 READ_UVLC( uiCode, "phase_hor_chroma_plus8" ); pcPPS->setPhaseHorChroma (i, uiCode - 8); 522 READ_UVLC( uiCode, "phase_ver_chroma_plus8" ); pcPPS->setPhaseVerChroma (i, uiCode - 8); 523 } 524 #endif 525 } 526 #else 527 #if MOVE_SCALED_OFFSET_TO_PPS 528 READ_UVLC( uiCode, "num_scaled_ref_layer_offsets" ); pcPPS->setNumScaledRefLayerOffsets(uiCode); 529 for(Int i = 0; i < pcPPS->getNumScaledRefLayerOffsets(); i++) 530 { 531 Window& scaledWindow = pcPPS->getScaledRefLayerWindow(i); 532 #if O0098_SCALED_REF_LAYER_ID 533 READ_CODE( 6, uiCode, "scaled_ref_layer_id" ); pcPPS->setScaledRefLayerId( i, uiCode ); 534 #endif 535 READ_SVLC( iCode, "scaled_ref_layer_left_offset" ); scaledWindow.setWindowLeftOffset (iCode << 1); 536 READ_SVLC( iCode, "scaled_ref_layer_top_offset" ); scaledWindow.setWindowTopOffset (iCode << 1); 537 READ_SVLC( iCode, "scaled_ref_layer_right_offset" ); scaledWindow.setWindowRightOffset (iCode << 1); 538 READ_SVLC( iCode, "scaled_ref_layer_bottom_offset" ); scaledWindow.setWindowBottomOffset(iCode << 1); 539 #if P0312_VERT_PHASE_ADJ 540 READ_FLAG( uiCode, "vert_phase_position_enable_flag" ); scaledWindow.setVertPhasePositionEnableFlag(uiCode); pcPPS->setVertPhasePositionEnableFlag( pcPPS->getScaledRefLayerId(i), uiCode); 541 #endif 542 } 543 #endif 544 #endif 545 #if Q0048_CGS_3D_ASYMLUT 546 READ_FLAG( uiCode , "colour_mapping_enabled_flag" ); 547 pcPPS->setCGSFlag( uiCode ); 548 if( pcPPS->getCGSFlag() ) 549 { 550 xParse3DAsymLUT( pc3DAsymLUT ); 551 pcPPS->setCGSOutputBitDepthY( pc3DAsymLUT->getOutputBitDepthY() ); 552 pcPPS->setCGSOutputBitDepthC( pc3DAsymLUT->getOutputBitDepthC() ); 553 } 554 #endif 555 } 556 #endif 557 399 558 } 400 559 … … 476 635 READ_UVLC( uiCode, "vui_num_ticks_poc_diff_one_minus1"); timingInfo->setNumTicksPocDiffOneMinus1 (uiCode); 477 636 } 478 READ_FLAG( uiCode, "hrd_parameters_present_flag"); pcVUI->setHrdParametersPresentFlag(uiCode);479 if( pcVUI->getHrdParametersPresentFlag() )480 {481 parseHrdParameters( pcVUI->getHrdParameters(), 1, pcSPS->getMaxTLayers() - 1 );482 }637 READ_FLAG( uiCode, "hrd_parameters_present_flag"); pcVUI->setHrdParametersPresentFlag(uiCode); 638 if( pcVUI->getHrdParametersPresentFlag() ) 639 { 640 parseHrdParameters( pcVUI->getHrdParameters(), 1, pcSPS->getMaxTLayers() - 1 ); 641 } 483 642 } 484 643 READ_FLAG( uiCode, "bitstream_restriction_flag"); pcVUI->setBitstreamRestrictionFlag(uiCode); … … 524 683 READ_CODE( 5, uiCode, "dpb_output_delay_length_minus1" ); hrd->setDpbOutputDelayLengthMinus1( uiCode ); 525 684 } 685 #if VPS_VUI_BSP_HRD_PARAMS 686 else 687 { 688 hrd->setInitialCpbRemovalDelayLengthMinus1( 23 ); 689 // Add inferred values for other syntax elements here. 690 } 691 #endif 526 692 } 527 693 Int i, j, nalOrVcl; … … 554 720 { 555 721 if( ( ( nalOrVcl == 0 ) && ( hrd->getNalHrdParametersPresentFlag() ) ) || 556 722 ( ( nalOrVcl == 1 ) && ( hrd->getVclHrdParametersPresentFlag() ) ) ) 557 723 { 558 724 for( j = 0; j <= ( hrd->getCpbCntMinus1( i ) ); j ++ ) … … 582 748 #endif 583 749 750 #if R0042_PROFILE_INDICATION 751 UInt uiTmp = 0; 752 Bool bMultiLayerExtSpsFlag; 753 #endif 584 754 UInt uiCode; 585 755 READ_CODE( 4, uiCode, "sps_video_parameter_set_id"); pcSPS->setVPSId ( uiCode ); … … 590 760 READ_CODE( 3, uiCode, "sps_max_sub_layers_minus1" ); pcSPS->setMaxTLayers ( uiCode+1 ); 591 761 assert(uiCode <= 6); 592 762 #if SVC_EXTENSION 763 } 764 #if R0042_PROFILE_INDICATION 765 else 766 { 767 READ_CODE( 3, uiCode, "sps_ext_or_max_sub_layers_minus1" ); uiTmp = uiCode; 768 } 769 #endif 770 #if !SPS_DPB_PARAMS 771 if(pcSPS->getLayerId() != 0) 772 { 773 pcSPS->setMaxTLayers ( parameterSetManager->getPrefetchedVPS(pcSPS->getVPSId())->getMaxTLayers() ); 774 } 775 #endif 776 #endif 777 778 #if SVC_EXTENSION 779 #if R0042_PROFILE_INDICATION 780 bMultiLayerExtSpsFlag = ( pcSPS->getLayerId() != 0 && uiTmp == 7 ); 781 #endif 782 #endif 783 784 #if SVC_EXTENSION 785 #if !R0042_PROFILE_INDICATION 786 if(pcSPS->getLayerId() == 0) 787 #else 788 if(!bMultiLayerExtSpsFlag) 789 #endif 790 { 791 #endif 593 792 READ_FLAG( uiCode, "sps_temporal_id_nesting_flag" ); pcSPS->setTemporalIdNestingFlag ( uiCode > 0 ? true : false ); 594 793 #if SVC_EXTENSION … … 597 796 else 598 797 { 599 pcSPS->setMaxTLayers ( parameterSetManager->getPrefetchedVPS(pcSPS->getVPSId())->getMaxTLayers() );600 798 pcSPS->setTemporalIdNestingFlag( parameterSetManager->getPrefetchedVPS(pcSPS->getVPSId())->getTemporalNestingFlag() ); 601 799 } … … 618 816 619 817 #ifdef SPS_PTL_FIX 818 #if !R0042_PROFILE_INDICATION 620 819 if ( pcSPS->getLayerId() == 0) 820 #else 821 if(!bMultiLayerExtSpsFlag) 822 #endif 621 823 { 622 824 parsePTL(pcSPS->getPTL(), 1, pcSPS->getMaxTLayers() - 1); … … 630 832 631 833 #if REPN_FORMAT_IN_VPS 834 #if !R0042_PROFILE_INDICATION 632 835 if( pcSPS->getLayerId() > 0 ) 836 #else 837 if( bMultiLayerExtSpsFlag) 838 #endif 633 839 { 634 840 READ_FLAG( uiCode, "update_rep_format_flag" ); 635 841 pcSPS->setUpdateRepFormatFlag( uiCode ? true : false ); 842 #if R0042_PROFILE_INDICATION 843 if( bMultiLayerExtSpsFlag && uiCode) 844 { 845 READ_CODE(8, uiCode, "sps_rep_format_idx"); 846 pcSPS->setUpdateRepFormatIndex(uiCode); 847 } 848 #endif 636 849 } 637 850 else … … 643 856 #endif 644 857 } 858 859 #if R0042_PROFILE_INDICATION 860 if( !bMultiLayerExtSpsFlag ) 861 { 862 #else 645 863 #if O0096_REP_FORMAT_INDEX 646 864 if( pcSPS->getLayerId() == 0 ) 647 865 #else 648 866 if( pcSPS->getLayerId() == 0 || pcSPS->getUpdateRepFormatFlag() ) 867 #endif 649 868 #endif 650 869 { … … 668 887 } 669 888 #if O0096_REP_FORMAT_INDEX 889 #if !R0042_PROFILE_INDICATION 670 890 else if ( pcSPS->getUpdateRepFormatFlag() ) 671 891 { … … 675 895 #endif 676 896 #endif 677 READ_FLAG( uiCode, "conformance_window_flag"); 678 if (uiCode != 0) 679 { 680 Window &conf = pcSPS->getConformanceWindow(); 897 #endif 898 899 #if R0156_CONF_WINDOW_IN_REP_FORMAT 681 900 #if REPN_FORMAT_IN_VPS 682 READ_UVLC( uiCode, "conf_win_left_offset" ); conf.setWindowLeftOffset ( uiCode ); 683 READ_UVLC( uiCode, "conf_win_right_offset" ); conf.setWindowRightOffset ( uiCode ); 684 READ_UVLC( uiCode, "conf_win_top_offset" ); conf.setWindowTopOffset ( uiCode ); 685 READ_UVLC( uiCode, "conf_win_bottom_offset" ); conf.setWindowBottomOffset( uiCode ); 686 #else 687 READ_UVLC( uiCode, "conf_win_left_offset" ); conf.setWindowLeftOffset ( uiCode * TComSPS::getWinUnitX( pcSPS->getChromaFormatIdc() ) ); 688 READ_UVLC( uiCode, "conf_win_right_offset" ); conf.setWindowRightOffset ( uiCode * TComSPS::getWinUnitX( pcSPS->getChromaFormatIdc() ) ); 689 READ_UVLC( uiCode, "conf_win_top_offset" ); conf.setWindowTopOffset ( uiCode * TComSPS::getWinUnitY( pcSPS->getChromaFormatIdc() ) ); 690 READ_UVLC( uiCode, "conf_win_bottom_offset" ); conf.setWindowBottomOffset( uiCode * TComSPS::getWinUnitY( pcSPS->getChromaFormatIdc() ) ); 691 #endif 692 } 693 #if REPN_FORMAT_IN_VPS 901 #if !R0042_PROFILE_INDICATION 694 902 #if O0096_REP_FORMAT_INDEX 695 903 if( pcSPS->getLayerId() == 0 ) 696 904 #else 697 905 if( pcSPS->getLayerId() == 0 || pcSPS->getUpdateRepFormatFlag() ) 906 #endif 907 #endif 908 { 909 #endif 910 #endif 911 READ_FLAG( uiCode, "conformance_window_flag"); 912 if (uiCode != 0) 913 { 914 Window &conf = pcSPS->getConformanceWindow(); 915 #if REPN_FORMAT_IN_VPS 916 READ_UVLC( uiCode, "conf_win_left_offset" ); conf.setWindowLeftOffset ( uiCode ); 917 READ_UVLC( uiCode, "conf_win_right_offset" ); conf.setWindowRightOffset ( uiCode ); 918 READ_UVLC( uiCode, "conf_win_top_offset" ); conf.setWindowTopOffset ( uiCode ); 919 READ_UVLC( uiCode, "conf_win_bottom_offset" ); conf.setWindowBottomOffset( uiCode ); 920 #else 921 READ_UVLC( uiCode, "conf_win_left_offset" ); conf.setWindowLeftOffset ( uiCode * TComSPS::getWinUnitX( pcSPS->getChromaFormatIdc() ) ); 922 READ_UVLC( uiCode, "conf_win_right_offset" ); conf.setWindowRightOffset ( uiCode * TComSPS::getWinUnitX( pcSPS->getChromaFormatIdc() ) ); 923 READ_UVLC( uiCode, "conf_win_top_offset" ); conf.setWindowTopOffset ( uiCode * TComSPS::getWinUnitY( pcSPS->getChromaFormatIdc() ) ); 924 READ_UVLC( uiCode, "conf_win_bottom_offset" ); conf.setWindowBottomOffset( uiCode * TComSPS::getWinUnitY( pcSPS->getChromaFormatIdc() ) ); 925 #endif 926 } 927 #if R0156_CONF_WINDOW_IN_REP_FORMAT 928 #if REPN_FORMAT_IN_VPS 929 } 930 #endif 931 #endif 932 933 #if REPN_FORMAT_IN_VPS 934 #if !R0042_PROFILE_INDICATION 935 #if O0096_REP_FORMAT_INDEX 936 if( pcSPS->getLayerId() == 0 ) 937 #else 938 if( pcSPS->getLayerId() == 0 || pcSPS->getUpdateRepFormatFlag() ) 939 #endif 698 940 #endif 699 941 { … … 711 953 } 712 954 #endif 955 #if R0042_PROFILE_INDICATION 956 } 957 #endif 958 713 959 READ_UVLC( uiCode, "log2_max_pic_order_cnt_lsb_minus4" ); pcSPS->setBitsForPOC( 4 + uiCode ); 714 960 assert(uiCode <= 12); 715 961 716 962 #if SPS_DPB_PARAMS 963 #if !R0042_PROFILE_INDICATION 717 964 if( pcSPS->getLayerId() == 0 ) 718 965 { 966 #else 967 if( !bMultiLayerExtSpsFlag ) 968 { 969 #endif 719 970 #endif 720 971 UInt subLayerOrderingInfoPresentFlag; … … 749 1000 READ_UVLC( uiCode, "log2_diff_max_min_coding_block_size" ); 750 1001 pcSPS->setLog2DiffMaxMinCodingBlockSize(uiCode); 751 1002 752 1003 if (pcSPS->getPTL()->getGeneralPTL()->getLevelIdc() >= Level::LEVEL5) 753 1004 { 754 1005 assert(log2MinCUSize + pcSPS->getLog2DiffMaxMinCodingBlockSize() >= 5); 755 1006 } 756 1007 757 1008 Int maxCUDepthDelta = uiCode; 758 1009 pcSPS->setMaxCUWidth ( 1<<(log2MinCUSize + maxCUDepthDelta) ); … … 773 1024 { 774 1025 #if SCALINGLIST_INFERRING 1026 #if !R0042_PROFILE_INDICATION 775 1027 if( pcSPS->getLayerId() > 0 ) 1028 #else 1029 if( bMultiLayerExtSpsFlag ) 1030 #endif 776 1031 { 777 1032 READ_FLAG( uiCode, "sps_infer_scaling_list_flag" ); pcSPS->setInferScalingListFlag( uiCode ); … … 790 1045 { 791 1046 #endif 792 READ_FLAG( uiCode, "sps_scaling_list_data_present_flag" ); pcSPS->setScalingListPresentFlag ( uiCode );793 if(pcSPS->getScalingListPresentFlag ())794 {795 parseScalingList( pcSPS->getScalingList() );796 }1047 READ_FLAG( uiCode, "sps_scaling_list_data_present_flag" ); pcSPS->setScalingListPresentFlag ( uiCode ); 1048 if(pcSPS->getScalingListPresentFlag ()) 1049 { 1050 parseScalingList( pcSPS->getScalingList() ); 1051 } 797 1052 #if SCALINGLIST_INFERRING 798 1053 } … … 854 1109 if( pcSPS->getExtensionFlag() ) 855 1110 { 1111 #if !R0042_PROFILE_INDICATION 856 1112 #if O0142_CONDITIONAL_SPS_EXTENSION 857 1113 UInt spsExtensionTypeFlag[8]; … … 877 1133 } 878 1134 } 879 } 1135 } 1136 #else 1137 READ_FLAG( uiCode, "sps_range_extension_flag" ); 1138 assert(uiCode == 0); 1139 READ_FLAG( uiCode, "sps_multilayer_extension_flag" ); 1140 assert(uiCode == 1); 1141 READ_CODE(6, uiCode, "sps_extension_6bits"); 1142 assert(uiCode == 0); 1143 parseSPSExtension( pcSPS ); 1144 } 1145 #endif 880 1146 #else 881 1147 if (uiCode) … … 899 1165 assert( uiCode == 0 ); 900 1166 1167 #if !MOVE_SCALED_OFFSET_TO_PPS 901 1168 if( pcSPS->getLayerId() > 0 ) 902 1169 { … … 918 1185 } 919 1186 } 1187 #endif 920 1188 } 921 1189 #endif … … 926 1194 927 1195 READ_CODE( 4, uiCode, "vps_video_parameter_set_id" ); pcVPS->setVPSId( uiCode ); 1196 #if VPS_RESERVED_FLAGS 1197 READ_FLAG( uiCode, "vps_base_layer_internal_flag"); pcVPS->setBaseLayerInternalFlag( uiCode ? true : false ); 1198 READ_FLAG( uiCode, "vps_base_layer_available_flag"); pcVPS->setBaseLayerAvailableFlag( uiCode ? true : false ); 1199 #if VPS_AVC_BL_FLAG_REMOVAL 1200 pcVPS->setNonHEVCBaseLayerFlag( (pcVPS->getBaseLayerAvailableFlag() && !pcVPS->getBaseLayerInternalFlag()) ? true : false); 1201 #endif 1202 #else 928 1203 READ_CODE( 2, uiCode, "vps_reserved_three_2bits" ); assert(uiCode == 3); 1204 #endif 929 1205 #if SVC_EXTENSION 930 1206 #if O0137_MAX_LAYERID … … 1025 1301 READ_FLAG( uiCode, "cprms_present_flag[i]" ); pcVPS->setCprmsPresentFlag( uiCode == 1 ? true : false, i ); 1026 1302 } 1303 else 1304 { 1305 pcVPS->setCprmsPresentFlag( true, i ); 1306 } 1307 1027 1308 parseHrdParameters(pcVPS->getHrdParameters(i), pcVPS->getCprmsPresentFlag( i ), pcVPS->getMaxTLayers() - 1); 1028 1309 } … … 1082 1363 Int OlsHighestOutputLayerId[MAX_VPS_LAYER_SETS_PLUS1]; 1083 1364 #endif 1365 #if LIST_OF_PTL 1366 if( vps->getMaxLayers() > 1 && vps->getBaseLayerInternalFlag() ) 1367 { 1368 vps->setProfilePresentFlag(1, false); 1369 vps->getPTLForExtnPtr()->empty(); 1370 vps->getPTLForExtnPtr()->resize(2); 1371 vps->getPTLForExtn(1)->copyProfileInfo( vps->getPTL() ); 1372 parsePTL( vps->getPTLForExtn(1), vps->getProfilePresentFlag(1), vps->getMaxTLayers() - 1 ); 1373 } 1374 #endif 1084 1375 #if VPS_EXTN_MASK_AND_DIM_INFO 1085 1376 UInt numScalabilityTypes = 0, i = 0, j = 0; 1086 1377 1378 #if !VPS_AVC_BL_FLAG_REMOVAL 1087 1379 READ_FLAG( uiCode, "avc_base_layer_flag" ); vps->setAvcBaseLayerFlag(uiCode ? true : false); 1380 #endif 1088 1381 1089 1382 #if !P0307_REMOVE_VPS_VUI_OFFSET … … 1094 1387 #endif 1095 1388 #if VPS_VUI_OFFSET 1096 READ_CODE( 16, uiCode, "vps_vui_offset" ); vps->setVpsVuiOffset( uiCode );1389 READ_CODE( 16, uiCode, "vps_vui_offset" ); vps->setVpsVuiOffset( uiCode ); 1097 1390 #endif 1098 1391 #if O0109_MOVE_VPS_VUI_FLAG … … 1145 1438 if( !vps->getSplittingFlag() ) 1146 1439 { 1147 for(j = 0; j < numScalabilityTypes; j++)1148 {1149 READ_CODE( vps->getDimensionIdLen(j), uiCode, "dimension_id[i][j]" ); vps->setDimensionId(i, j, uiCode);1440 for(j = 0; j < numScalabilityTypes; j++) 1441 { 1442 READ_CODE( vps->getDimensionIdLen(j), uiCode, "dimension_id[i][j]" ); vps->setDimensionId(i, j, uiCode); 1150 1443 #if !AUXILIARY_PICTURES 1151 assert( uiCode <= vps->getMaxLayerId() );1152 #endif 1153 }1154 }1444 assert( uiCode <= vps->getMaxLayerId() ); 1445 #endif 1446 } 1447 } 1155 1448 } 1156 1449 #endif … … 1215 1508 vps->setTreePartitionLayerIdList(); 1216 1509 #endif 1510 #if MOVE_ADDN_LS_SIGNALLING 1511 #if Q0078_ADD_LAYER_SETS 1512 if (vps->getNumIndependentLayers() > 1) 1513 { 1514 READ_UVLC(uiCode, "num_add_layer_sets"); vps->setNumAddLayerSets(uiCode); 1515 for (i = 0; i < vps->getNumAddLayerSets(); i++) 1516 { 1517 for (j = 1; j < vps->getNumIndependentLayers(); j++) 1518 { 1519 int len = 1; 1520 while ((1 << len) < (vps->getNumLayersInTreePartition(j) + 1)) 1521 { 1522 len++; 1523 } 1524 READ_CODE(len, uiCode, "highest_layer_idx_plus1[i][j]"); vps->setHighestLayerIdxPlus1(i, j, uiCode); 1525 } 1526 } 1527 vps->setNumLayerSets(vps->getNumLayerSets() + vps->getNumAddLayerSets()); 1528 vps->setLayerIdIncludedFlagsForAddLayerSets(); 1529 } 1530 #endif 1531 #endif 1217 1532 #if VPS_TSLAYERS 1218 1533 READ_FLAG( uiCode, "vps_sub_layers_max_minus1_present_flag"); vps->setMaxTSLayersPresentFlag(uiCode ? true : false); … … 1239 1554 { 1240 1555 #if O0225_MAX_TID_FOR_REF_LAYERS 1241 for( j = i+1; j <= vps->getMaxLayers() - 1; j++) 1242 { 1243 if(vps->getDirectDependencyFlag(j, i)) 1244 { 1245 READ_CODE( 3, uiCode, "max_tid_il_ref_pics_plus1[i][j]" ); vps->setMaxTidIlRefPicsPlus1(i, j, uiCode); 1246 assert( uiCode <= vps->getMaxTLayers()); 1247 } 1248 } 1556 for( j = i+1; j <= vps->getMaxLayers() - 1; j++) 1557 { 1558 if(vps->getDirectDependencyFlag(j, i)) 1559 { 1560 READ_CODE( 3, uiCode, "max_tid_il_ref_pics_plus1[i][j]" ); vps->setMaxTidIlRefPicsPlus1(i, j, uiCode); 1561 } 1562 } 1249 1563 #else 1250 1564 READ_CODE( 3, uiCode, "max_tid_il_ref_pics_plus1[i]" ); vps->setMaxTidIlRefPicsPlus1(i, uiCode); … … 1258 1572 { 1259 1573 #if O0225_MAX_TID_FOR_REF_LAYERS 1260 1261 1262 1263 1574 for( j = i+1; j <= vps->getMaxLayers() - 1; j++) 1575 { 1576 vps->setMaxTidIlRefPicsPlus1(i, j, 7); 1577 } 1264 1578 #else 1265 1579 vps->setMaxTidIlRefPicsPlus1(i, 7); … … 1276 1590 READ_UVLC( uiCode, "vps_num_profile_tier_level_minus1"); vps->setNumProfileTierLevel( uiCode + 1 ); 1277 1591 #endif 1592 #if PER_LAYER_PTL 1593 Int const numBitsForPtlIdx = vps->calculateLenOfSyntaxElement( vps->getNumProfileTierLevel() ); 1594 #endif 1278 1595 vps->getPTLForExtnPtr()->resize(vps->getNumProfileTierLevel()); 1596 #if LIST_OF_PTL 1597 for(Int idx = vps->getBaseLayerInternalFlag() ? 2 : 1; idx <= vps->getNumProfileTierLevel() - 1; idx++) 1598 #else 1279 1599 for(Int idx = 1; idx <= vps->getNumProfileTierLevel() - 1; idx++) 1600 #endif 1280 1601 { 1281 1602 READ_FLAG( uiCode, "vps_profile_present_flag[i]" ); vps->setProfilePresentFlag(idx, uiCode ? true : false); … … 1300 1621 #endif 1301 1622 1623 #if !MOVE_ADDN_LS_SIGNALLING 1302 1624 #if Q0078_ADD_LAYER_SETS 1303 1625 if (vps->getNumIndependentLayers() > 1) … … 1319 1641 vps->setLayerIdIncludedFlagsForAddLayerSets(); 1320 1642 } 1643 #endif 1321 1644 #endif 1322 1645 … … 1363 1686 #endif 1364 1687 vps->setNumOutputLayerSets( numOutputLayerSets ); 1365 1688 #if NECESSARY_LAYER_FLAG 1689 // Default output layer set 1690 vps->setOutputLayerSetIdx(0, 0); 1691 vps->setOutputLayerFlag(0, 0, true); 1692 vps->deriveNecessaryLayerFlag(0); 1693 #if PER_LAYER_PTL 1694 vps->getProfileLevelTierIdx()->resize(numOutputLayerSets); 1695 vps->getProfileLevelTierIdx(0)->push_back( vps->getBaseLayerInternalFlag() && vps->getMaxLayers() > 1 ? 1 : 0); 1696 #endif 1697 #endif 1366 1698 for(i = 1; i < numOutputLayerSets; i++) 1367 1699 { … … 1379 1711 vps->setOutputLayerSetIdx( i, i ); 1380 1712 } 1713 Int layerSetIdxForOutputLayerSet = vps->getOutputLayerSetIdx(i); 1381 1714 #if Q0078_ADD_LAYER_SETS 1382 1715 if ( i > vps->getVpsNumLayerSetsMinus1() || vps->getDefaultTargetOutputLayerIdc() >= 2 ) … … 1385 1718 #endif 1386 1719 { 1387 Int lsIdx = vps->getOutputLayerSetIdx(i);1388 1720 #if NUM_OL_FLAGS 1389 for(j = 0; j < vps->getNumLayersInIdList(l sIdx); j++)1721 for(j = 0; j < vps->getNumLayersInIdList(layerSetIdxForOutputLayerSet); j++) 1390 1722 #else 1391 1723 for(j = 0; j < vps->getNumLayersInIdList(lsIdx) - 1; j++) … … 1399 1731 // i <= (vps->getNumLayerSets() - 1) 1400 1732 // Assign OutputLayerFlag depending on default_one_target_output_layer_flag 1401 Int lsIdx = i;1402 1733 if( vps->getDefaultTargetOutputLayerIdc() == 1 ) 1403 1734 { 1404 for(j = 0; j < vps->getNumLayersInIdList(lsIdx); j++) 1405 { 1406 vps->setOutputLayerFlag(i, j, (j == (vps->getNumLayersInIdList(lsIdx)-1)) && (vps->getDimensionId(j,1) == 0) ); 1735 for(j = 0; j < vps->getNumLayersInIdList(layerSetIdxForOutputLayerSet); j++) 1736 { 1737 #if DEF_OPT_LAYER_IDC 1738 vps->setOutputLayerFlag(i, j, (j == (vps->getNumLayersInIdList(layerSetIdxForOutputLayerSet)-1)) ); 1739 1740 #else 1741 vps->setOutputLayerFlag(i, j, (j == (vps->getNumLayersInIdList(layerSetIdxForOutputLayerSet)-1)) && (vps->getDimensionId(j,1) == 0) ); 1742 #endif 1407 1743 } 1408 1744 } 1409 1745 else if ( vps->getDefaultTargetOutputLayerIdc() == 0 ) 1410 1746 { 1411 for(j = 0; j < vps->getNumLayersInIdList(l sIdx); j++)1747 for(j = 0; j < vps->getNumLayersInIdList(layerSetIdxForOutputLayerSet); j++) 1412 1748 { 1413 1749 vps->setOutputLayerFlag(i, j, 1); … … 1415 1751 } 1416 1752 } 1753 #if NECESSARY_LAYER_FLAG 1754 vps->deriveNecessaryLayerFlag(i); 1755 #endif 1756 #if PER_LAYER_PTL 1757 vps->getProfileLevelTierIdx(i)->assign(vps->getNumLayersInIdList(layerSetIdxForOutputLayerSet), -1); 1758 for(j = 0; j < vps->getNumLayersInIdList(layerSetIdxForOutputLayerSet) ; j++) 1759 { 1760 if( vps->getNecessaryLayerFlag(i, j) ) 1761 { 1762 READ_CODE( numBitsForPtlIdx, uiCode, "profile_level_tier_idx[i]" ); 1763 vps->setProfileLevelTierIdx(i, j, uiCode ); 1764 } 1765 } 1766 #else 1417 1767 Int numBits = 1; 1418 1768 while ((1 << numBits) < (vps->getNumProfileTierLevel())) … … 1421 1771 } 1422 1772 READ_CODE( numBits, uiCode, "profile_level_tier_idx[i]" ); vps->setProfileLevelTierIdx(i, uiCode); 1773 #endif 1423 1774 #if P0300_ALT_OUTPUT_LAYER_FLAG 1424 1775 NumOutputLayersInOutputLayerSet[i] = 0; 1425 Int layerSetIdxForOutputLayerSet = vps->getOutputLayerSetIdx(i);1426 1776 for (j = 0; j < vps->getNumLayersInIdList(layerSetIdxForOutputLayerSet); j++) 1427 1777 { … … 1437 1787 vps->setAltOuputLayerFlag(i, uiCode ? true : false); 1438 1788 } 1789 #if ALT_OPT_LAYER_FLAG 1790 else 1791 { 1792 uiCode=0; 1793 vps->setAltOuputLayerFlag(i, uiCode ? true : false); 1794 } 1795 #endif 1439 1796 #if Q0165_OUTPUT_LAYER_SET 1440 1797 assert( NumOutputLayersInOutputLayerSet[i]>0 ); … … 1443 1800 #endif 1444 1801 } 1802 #if NECESSARY_LAYER_FLAG 1803 vps->checkNecessaryLayerFlagCondition(); 1804 #endif 1445 1805 #else 1446 1806 if( numOutputLayerSets > 1 ) … … 1488 1848 { 1489 1849 #if O0135_DEFAULT_ONE_OUT_SEMANTIC 1850 #if DEF_OPT_LAYER_IDC 1851 vps->setOutputLayerFlag(i, j, (j == (vps->getNumLayersInIdList(lsIdx)-1)) ); 1852 #else 1490 1853 vps->setOutputLayerFlag(i, j, (j == (vps->getNumLayersInIdList(lsIdx)-1)) && (vps->getDimensionId(j,1)==0) ); 1854 #endif 1491 1855 #else 1492 1856 vps->setOutputLayerFlag(i, j, (j == (vps->getNumLayersInIdList(lsIdx)-1))); … … 1669 2033 READ_FLAG(uiCode, "max_one_active_ref_layer_flag" ); 1670 2034 vps->setMaxOneActiveRefLayerFlag(uiCode); 2035 #if P0297_VPS_POC_LSB_ALIGNED_FLAG 2036 READ_FLAG(uiCode, "vps_poc_lsb_aligned_flag"); 2037 vps->setVpsPocLsbAlignedFlag(uiCode); 2038 #endif 1671 2039 #if O0062_POC_LSB_NOT_PRESENT_FLAG 1672 2040 for(i = 1; i< vps->getMaxLayers(); i++) … … 1824 2192 #endif 1825 2193 } 1826 2194 1827 2195 // When not present, the value of num_add_olss is inferred to be equal to 0. 1828 2196 // NumOutputLayerSets = num_add_olss + NumLayerSets … … 1838 2206 for( j = 0; j < vps->getNumLayersInIdList(lsIdx); j++ ) 1839 2207 { 1840 vps->setOutputLayerFlag(i, j, 1);2208 vps->setOutputLayerFlag(i, j, 1); 1841 2209 } 1842 2210 } … … 1848 2216 vps->setSubLayerDpbInfoPresentFlag( i, 0, true ); 1849 2217 } 1850 2218 1851 2219 // When not present, the value of vps_num_rep_formats_minus1 is inferred to be equal to MaxLayersMinus1. 1852 2220 vps->setVpsNumRepFormats( vps->getMaxLayers() ); … … 1864 2232 } 1865 2233 1866 // vps_poc_lsb_aligned_flag 1867 // When not present, vps_poc_lsb_aligned_flag is inferred to be equal to 0. 1868 2234 #if P0297_VPS_POC_LSB_ALIGNED_FLAG 2235 vps->setVpsPocLsbAlignedFlag(false); 2236 #endif 2237 1869 2238 #if O0062_POC_LSB_NOT_PRESENT_FLAG 1870 2239 // When not present, poc_lsb_not_present_flag[ i ] is inferred to be equal to 0. … … 1937 2306 repFormat->setBitDepthVpsChroma ( repFormatPrev->getBitDepthVpsChroma() ); 1938 2307 } 2308 1939 2309 #else 1940 2310 #if AUXILIARY_PICTURES … … 1943 2313 READ_CODE( 2, uiCode, "chroma_format_idc" ); repFormat->setChromaFormatVpsIdc( uiCode ); 1944 2314 #endif 1945 2315 1946 2316 if( repFormat->getChromaFormatVpsIdc() == 3 ) 1947 2317 { … … 1955 2325 READ_CODE( 4, uiCode, "bit_depth_chroma_minus8" ); repFormat->setBitDepthVpsChroma( uiCode + 8 ); 1956 2326 #endif 2327 2328 #if R0156_CONF_WINDOW_IN_REP_FORMAT 2329 READ_FLAG( uiCode, "conformance_window_vps_flag" ); 2330 if( uiCode != 0) 2331 { 2332 Window &conf = repFormat->getConformanceWindowVps(); 2333 READ_UVLC( uiCode, "conf_win_vps_left_offset" ); conf.setWindowLeftOffset ( uiCode ); 2334 READ_UVLC( uiCode, "conf_win_vps_right_offset" ); conf.setWindowRightOffset ( uiCode ); 2335 READ_UVLC( uiCode, "conf_win_vps_top_offset" ); conf.setWindowTopOffset ( uiCode ); 2336 READ_UVLC( uiCode, "conf_win_vps_bottom_offset" ); conf.setWindowBottomOffset( uiCode ); 2337 } 2338 #endif 1957 2339 } 1958 2340 #endif … … 1961 2343 { 1962 2344 UInt uiCode; 2345 #if SUB_LAYERS_IN_LAYER_SET 2346 vps->calculateMaxSLInLayerSets(); 2347 #else 1963 2348 #if DPB_PARAMS_MAXTLAYERS 1964 2349 #if BITRATE_PICRATE_SIGNALLING 1965 1966 1967 #else 1968 1969 1970 #endif 1971 1972 2350 Int * MaxSubLayersInLayerSetMinus1 = new Int[vps->getNumLayerSets()]; 2351 for(Int i = 0; i < vps->getNumLayerSets(); i++) 2352 #else 2353 Int * MaxSubLayersInLayerSetMinus1 = new Int[vps->getNumOutputLayerSets()]; 2354 for(Int i = 1; i < vps->getNumOutputLayerSets(); i++) 2355 #endif 2356 { 2357 UInt maxSLMinus1 = 0; 1973 2358 #if CHANGE_NUMSUBDPB_IDX 1974 1975 #else 1976 2359 Int optLsIdx = vps->getOutputLayerSetIdx( i ); 2360 #else 2361 Int optLsIdx = i; 1977 2362 #endif 1978 2363 #if BITRATE_PICRATE_SIGNALLING 1979 1980 #endif 1981 1982 1983 1984 1985 2364 optLsIdx = i; 2365 #endif 2366 for(Int k = 0; k < vps->getNumLayersInIdList(optLsIdx); k++ ) { 2367 Int lId = vps->getLayerSetLayerIdList(optLsIdx, k); 2368 maxSLMinus1 = max(maxSLMinus1, vps->getMaxTSLayersMinus1(vps->getLayerIdInVps(lId))); 2369 } 2370 MaxSubLayersInLayerSetMinus1[ i ] = maxSLMinus1; 1986 2371 #if BITRATE_PICRATE_SIGNALLING 1987 vps->setMaxSLayersInLayerSetMinus1(i,MaxSubLayersInLayerSetMinus1[ i ]); 1988 #endif 1989 } 1990 #endif 1991 2372 vps->setMaxSLayersInLayerSetMinus1(i,MaxSubLayersInLayerSetMinus1[ i ]); 2373 #endif 2374 } 2375 #endif 2376 #endif 2377 1992 2378 #if !RESOLUTION_BASED_DPB 1993 2379 vps->deriveNumberOfSubDpbs(); … … 1999 2385 #endif 2000 2386 READ_FLAG( uiCode, "sub_layer_flag_info_present_flag[i]"); vps->setSubLayerFlagInfoPresentFlag( i, uiCode ? true : false ); 2387 #if SUB_LAYERS_IN_LAYER_SET 2388 for(Int j = 0; j <= vps->getMaxSLayersInLayerSetMinus1( layerSetIdxForOutputLayerSet ); j++) 2389 #else 2001 2390 #if DPB_PARAMS_MAXTLAYERS 2002 2391 #if BITRATE_PICRATE_SIGNALLING … … 2008 2397 for(Int j = 0; j <= vps->getMaxTLayers(); j++) 2009 2398 #endif 2399 #endif 2010 2400 { 2011 2401 if( j > 0 && vps->getSubLayerFlagInfoPresentFlag(i) ) … … 2032 2422 #endif 2033 2423 { 2424 #if DPB_INTERNAL_BL_SIG 2425 uiCode=0; 2426 if(vps->getBaseLayerInternalFlag() || ( vps->getLayerSetLayerIdList(layerSetIdxForOutputLayerSet, k) != 0 ) ) 2427 #endif 2034 2428 READ_UVLC( uiCode, "max_vps_dec_pic_buffering_minus1[i][k][j]" ); vps->setMaxVpsDecPicBufferingMinus1( i, k, j, uiCode ); 2035 2429 } … … 2060 2454 } 2061 2455 2456 #if !SUB_LAYERS_IN_LAYER_SET 2457 #if BITRATE_PICRATE_SIGNALLING 2458 if( MaxSubLayersInLayerSetMinus1 ) 2459 { 2460 delete [] MaxSubLayersInLayerSetMinus1; 2461 } 2462 #endif 2463 #endif 2464 2062 2465 // Infer values when not signalled 2063 2466 for(Int i = 1; i < vps->getNumOutputLayerSets(); i++) … … 2122 2525 READ_FLAG( uiCode, "pic_rate_present_vps_flag" ); vps->setPicRatePresentVpsFlag( uiCode ? true : false ); 2123 2526 2527 #if SIGNALLING_BITRATE_PICRATE_FIX 2528 if ( vps->getBitRatePresentVpsFlag() || vps->getPicRatePresentVpsFlag() ) 2529 { 2530 for( i = vps->getBaseLayerInternalFlag() ? 0 : 1; i < vps->getNumLayerSets(); i++ ) 2531 { 2532 for( j = 0; j <= vps->getMaxSLayersInLayerSetMinus1( i ); j++ ) 2533 { 2534 if( vps->getBitRatePresentVpsFlag() ) 2535 { 2536 READ_FLAG( uiCode, "bit_rate_present_flag[i][j]" ); vps->setBitRatePresentFlag( i, j, uiCode ? true : false ); 2537 } 2538 if( vps->getPicRatePresentVpsFlag( ) ) 2539 { 2540 READ_FLAG( uiCode, "pic_rate_present_flag[i][j]" ); vps->setPicRatePresentFlag( i, j, uiCode ? true : false ); 2541 } 2542 if( vps->getBitRatePresentFlag( i, j ) ) 2543 { 2544 READ_CODE( 16, uiCode, "avg_bit_rate" ); vps->setAvgBitRate( i, j, uiCode ); 2545 READ_CODE( 16, uiCode, "max_bit_rate" ); vps->setMaxBitRate( i, j, uiCode ); 2546 } 2547 else 2548 { 2549 vps->setAvgBitRate( i, j, 0 ); 2550 vps->setMaxBitRate( i, j, 0 ); 2551 } 2552 if( vps->getPicRatePresentFlag( i, j ) ) 2553 { 2554 READ_CODE( 2, uiCode, "constant_pic_rate_idc" ); vps->setConstPicRateIdc( i, j, uiCode ); 2555 READ_CODE( 16, uiCode, "avg_pic_rate" ); vps->setAvgPicRate( i, j, uiCode ); 2556 } 2557 else 2558 { 2559 vps->setConstPicRateIdc( i, j, 0 ); 2560 vps->setAvgPicRate( i, j, 0 ); 2561 } 2562 } 2563 } 2564 } 2565 #else 2124 2566 Bool parseFlag = vps->getBitRatePresentVpsFlag() || vps->getPicRatePresentVpsFlag(); 2125 2567 2126 2568 #if Q0078_ADD_LAYER_SETS 2569 #if R0227_BR_PR_ADD_LAYER_SET 2570 for( i = 0; i < vps->getNumLayerSets(); i++ ) 2571 #else 2127 2572 for( i = 0; i <= vps->getVpsNumLayerSetsMinus1(); i++ ) 2573 #endif 2128 2574 #else 2129 2575 for( i = 0; i < vps->getNumLayerSets(); i++ ) … … 2174 2620 } 2175 2621 } 2622 #endif 2176 2623 #if VPS_VUI_VIDEO_SIGNAL_MOVE 2177 2624 READ_FLAG( uiCode, "video_signal_info_idx_present_flag" ); vps->setVideoSigPresentVpsFlag( uiCode == 1 ); … … 2182 2629 else 2183 2630 { 2631 #if VPS_VUI_VST_PARAMS 2632 vps->setNumVideoSignalInfo(vps->getMaxLayers() - vps->getBaseLayerInternalFlag() ? 0 : 1); 2633 #else 2184 2634 vps->setNumVideoSignalInfo(vps->getMaxLayers()); 2635 #endif 2185 2636 } 2186 2637 … … 2193 2644 READ_CODE(8, uiCode, "matrix_coeffs_vps" );vps->setMaxtrixCoeff(i,uiCode); 2194 2645 } 2646 #if VPS_VUI_VST_PARAMS 2647 if( vps->getVideoSigPresentVpsFlag() && vps->getNumVideoSignalInfo() > 1 ) 2648 { 2649 for(i = vps->getBaseLayerInternalFlag() ? 0 : 1; i < vps->getMaxLayers(); i++) 2650 { 2651 READ_CODE(4, uiCode, "vps_video_signal_info_idx" ); vps->setVideoSignalInfoIdx(i, uiCode); 2652 } 2653 } 2654 else if ( !vps->getVideoSigPresentVpsFlag() ) 2655 { 2656 for(i = vps->getBaseLayerInternalFlag() ? 0 : 1; i < vps->getMaxLayers(); i++) 2657 { 2658 vps->setVideoSignalInfoIdx( i, i ); 2659 } 2660 } 2661 else // ( vps->getNumVideoSignalInfo() = 0 ) 2662 { 2663 for(i = vps->getBaseLayerInternalFlag() ? 0 : 1; i < vps->getMaxLayers(); i++) 2664 { 2665 vps->setVideoSignalInfoIdx( i, 0 ); 2666 } 2667 } 2668 #else 2195 2669 if(!vps->getVideoSigPresentVpsFlag()) 2196 2670 { … … 2214 2688 } 2215 2689 } 2690 #endif 2216 2691 #endif 2217 2692 #if VPS_VUI_TILES_NOT_IN_USE__FLAG … … 2303 2778 #if VPS_VUI_VIDEO_SIGNAL_MOVE 2304 2779 #else 2305 READ_FLAG( uiCode, "video_signal_info_idx_present_flag" ); vps->setVideoSigPresentVpsFlag( uiCode == 1 ); 2306 if (vps->getVideoSigPresentVpsFlag()) 2307 { 2308 READ_CODE(4, uiCode, "vps_num_video_signal_info_minus1" ); vps->setNumVideoSignalInfo(uiCode + 1); 2780 READ_FLAG( uiCode, "video_signal_info_idx_present_flag" ); vps->setVideoSigPresentVpsFlag( uiCode == 1 ); 2781 if (vps->getVideoSigPresentVpsFlag()) 2782 { 2783 READ_CODE(4, uiCode, "vps_num_video_signal_info_minus1" ); vps->setNumVideoSignalInfo(uiCode + 1); 2784 } 2785 else 2786 { 2787 vps->setNumVideoSignalInfo(vps->getMaxLayers()); 2788 } 2789 2790 2791 for(i = 0; i < vps->getNumVideoSignalInfo(); i++) 2792 { 2793 READ_CODE(3, uiCode, "video_vps_format" ); vps->setVideoVPSFormat(i,uiCode); 2794 READ_FLAG(uiCode, "video_full_range_vps_flag" ); vps->setVideoFullRangeVpsFlag(i,uiCode); 2795 READ_CODE(8, uiCode, "color_primaries_vps" ); vps->setColorPrimaries(i,uiCode); 2796 READ_CODE(8, uiCode, "transfer_characteristics_vps" ); vps->setTransCharacter(i,uiCode); 2797 READ_CODE(8, uiCode, "matrix_coeffs_vps" );vps->setMaxtrixCoeff(i,uiCode); 2798 } 2799 if(!vps->getVideoSigPresentVpsFlag()) 2800 { 2801 for (i=0; i < vps->getMaxLayers(); i++) 2802 { 2803 vps->setVideoSignalInfoIdx(i,i); 2804 } 2805 } 2806 else { 2807 vps->setVideoSignalInfoIdx(0,0); 2808 if (vps->getNumVideoSignalInfo() > 1 ) 2809 { 2810 for (i=1; i < vps->getMaxLayers(); i++) 2811 READ_CODE(4, uiCode, "vps_video_signal_info_idx" ); vps->setVideoSignalInfoIdx(i, uiCode); 2812 } 2813 else { 2814 for (i=1; i < vps->getMaxLayers(); i++) 2815 { 2816 vps->setVideoSignalInfoIdx(i,0); 2817 } 2818 } 2819 } 2820 #endif 2821 #endif 2822 2823 #if O0164_MULTI_LAYER_HRD 2824 READ_FLAG(uiCode, "vps_vui_bsp_hrd_present_flag" ); vps->setVpsVuiBspHrdPresentFlag(uiCode); 2825 if (vps->getVpsVuiBspHrdPresentFlag()) 2826 { 2827 #if VPS_VUI_BSP_HRD_PARAMS 2828 parseVpsVuiBspHrdParams(vps); 2829 #else 2830 #if R0227_VUI_BSP_HRD_FLAG 2831 assert (vps->getTimingInfo()->getTimingInfoPresentFlag() == 1); 2832 #endif 2833 READ_UVLC( uiCode, "vps_num_bsp_hrd_parameters_minus1" ); vps->setVpsNumBspHrdParametersMinus1(uiCode); 2834 vps->createBspHrdParamBuffer(vps->getVpsNumBspHrdParametersMinus1() + 1); 2835 for( i = 0; i <= vps->getVpsNumBspHrdParametersMinus1(); i++ ) 2836 { 2837 if( i > 0 ) 2838 { 2839 READ_FLAG( uiCode, "bsp_cprms_present_flag[i]" ); vps->setBspCprmsPresentFlag(i, uiCode); 2840 } 2841 parseHrdParameters(vps->getBspHrd(i), i==0 ? 1 : vps->getBspCprmsPresentFlag(i), vps->getMaxTLayers()-1); 2842 } 2843 #if Q0078_ADD_LAYER_SETS 2844 for (UInt h = 1; h <= vps->getVpsNumLayerSetsMinus1(); h++) 2845 #else 2846 for( UInt h = 1; h <= (vps->getNumLayerSets()-1); h++ ) 2847 #endif 2848 { 2849 READ_UVLC( uiCode, "num_bitstream_partitions[i]"); vps->setNumBitstreamPartitions(h, uiCode); 2850 #if HRD_BPB 2851 Int chkPart=0; 2852 #endif 2853 for( i = 0; i < vps->getNumBitstreamPartitions(h); i++ ) 2854 { 2855 for( j = 0; j <= (vps->getMaxLayers()-1); j++ ) 2856 { 2857 if( vps->getLayerIdIncludedFlag(h, j) ) 2858 { 2859 READ_FLAG( uiCode, "layer_in_bsp_flag[h][i][j]" ); vps->setLayerInBspFlag(h, i, j, uiCode); 2860 } 2861 } 2862 #if HRD_BPB 2863 chkPart+=vps->getLayerInBspFlag(h, i, j); 2864 #endif 2865 } 2866 #if HRD_BPB 2867 assert(chkPart<=1); 2868 #endif 2869 #if HRD_BPB 2870 if(vps->getNumBitstreamPartitions(h)==1) 2871 { 2872 Int chkPartition1=0; Int chkPartition2=0; 2873 for( j = 0; j <= (vps->getMaxLayers()-1); j++ ) 2874 { 2875 if( vps->getLayerIdIncludedFlag(h, j) ) 2876 { 2877 chkPartition1+=vps->getLayerInBspFlag(h, 0, j); 2878 chkPartition2++; 2879 } 2880 } 2881 assert(chkPartition1!=chkPartition2); 2882 } 2883 #endif 2884 if (vps->getNumBitstreamPartitions(h)) 2885 { 2886 #if Q0182_MULTI_LAYER_HRD_UPDATE 2887 READ_UVLC( uiCode, "num_bsp_sched_combinations_minus1[h]"); vps->setNumBspSchedCombinations(h, uiCode + 1); 2888 #else 2889 READ_UVLC( uiCode, "num_bsp_sched_combinations[h]"); vps->setNumBspSchedCombinations(h, uiCode); 2890 #endif 2891 for( i = 0; i < vps->getNumBspSchedCombinations(h); i++ ) 2892 { 2893 for( j = 0; j < vps->getNumBitstreamPartitions(h); j++ ) 2894 { 2895 READ_UVLC( uiCode, "bsp_comb_hrd_idx[h][i][j]"); vps->setBspCombHrdIdx(h, i, j, uiCode); 2896 #if HRD_BPB 2897 assert(uiCode <= vps->getVpsNumBspHrdParametersMinus1()); 2898 #endif 2899 2900 READ_UVLC( uiCode, "bsp_comb_sched_idx[h][i][j]"); vps->setBspCombSchedIdx(h, i, j, uiCode); 2901 #if HRD_BPB 2902 assert(uiCode <= vps->getBspHrdParamBufferCpbCntMinus1(uiCode,vps->getMaxTLayers()-1)); 2903 #endif 2904 } 2905 } 2906 } 2907 } 2908 #endif 2909 } 2910 #endif 2911 #if P0182_VPS_VUI_PS_FLAG 2912 for(i = 1; i < vps->getMaxLayers(); i++) 2913 { 2914 if (vps->getNumRefLayers(vps->getLayerIdInNuh(i)) == 0) 2915 { 2916 READ_FLAG( uiCode, "base_layer_parameter_set_compatibility_flag" ); 2917 vps->setBaseLayerPSCompatibilityFlag( i, uiCode ); 2309 2918 } 2310 2919 else 2311 2920 { 2312 vps->setNumVideoSignalInfo(vps->getMaxLayers()); 2313 } 2314 2315 2316 for(i = 0; i < vps->getNumVideoSignalInfo(); i++) 2317 { 2318 READ_CODE(3, uiCode, "video_vps_format" ); vps->setVideoVPSFormat(i,uiCode); 2319 READ_FLAG(uiCode, "video_full_range_vps_flag" ); vps->setVideoFullRangeVpsFlag(i,uiCode); 2320 READ_CODE(8, uiCode, "color_primaries_vps" ); vps->setColorPrimaries(i,uiCode); 2321 READ_CODE(8, uiCode, "transfer_characteristics_vps" ); vps->setTransCharacter(i,uiCode); 2322 READ_CODE(8, uiCode, "matrix_coeffs_vps" );vps->setMaxtrixCoeff(i,uiCode); 2323 } 2324 if(!vps->getVideoSigPresentVpsFlag()) 2325 { 2326 for (i=0; i < vps->getMaxLayers(); i++) 2327 { 2328 vps->setVideoSignalInfoIdx(i,i); 2329 } 2330 } 2331 else { 2332 vps->setVideoSignalInfoIdx(0,0); 2333 if (vps->getNumVideoSignalInfo() > 1 ) 2334 { 2335 for (i=1; i < vps->getMaxLayers(); i++) 2336 READ_CODE(4, uiCode, "vps_video_signal_info_idx" ); vps->setVideoSignalInfoIdx(i, uiCode); 2337 } 2338 else { 2339 for (i=1; i < vps->getMaxLayers(); i++) 2340 { 2341 vps->setVideoSignalInfoIdx(i,0); 2342 } 2343 } 2344 } 2345 #endif 2346 #endif 2347 2348 #if O0164_MULTI_LAYER_HRD 2349 READ_FLAG(uiCode, "vps_vui_bsp_hrd_present_flag" ); vps->setVpsVuiBspHrdPresentFlag(uiCode); 2350 if (vps->getVpsVuiBspHrdPresentFlag()) 2351 { 2352 READ_UVLC( uiCode, "vps_num_bsp_hrd_parameters_minus1" ); vps->setVpsNumBspHrdParametersMinus1(uiCode); 2353 vps->createBspHrdParamBuffer(vps->getVpsNumBspHrdParametersMinus1() + 1); 2354 for( i = 0; i <= vps->getVpsNumBspHrdParametersMinus1(); i++ ) 2355 { 2356 if( i > 0 ) 2357 { 2358 READ_FLAG( uiCode, "bsp_cprms_present_flag[i]" ); vps->setBspCprmsPresentFlag(i, uiCode); 2359 } 2360 parseHrdParameters(vps->getBspHrd(i), i==0 ? 1 : vps->getBspCprmsPresentFlag(i), vps->getMaxTLayers()-1); 2361 } 2362 #if Q0078_ADD_LAYER_SETS 2363 for (UInt h = 1; h <= vps->getVpsNumLayerSetsMinus1(); h++) 2364 #else 2365 for( UInt h = 1; h <= (vps->getNumLayerSets()-1); h++ ) 2366 #endif 2367 { 2368 READ_UVLC( uiCode, "num_bitstream_partitions[i]"); vps->setNumBitstreamPartitions(h, uiCode); 2369 #if HRD_BPB 2370 Int chkPart=0; 2371 #endif 2372 for( i = 0; i < vps->getNumBitstreamPartitions(h); i++ ) 2373 { 2374 for( j = 0; j <= (vps->getMaxLayers()-1); j++ ) 2375 { 2376 if( vps->getLayerIdIncludedFlag(h, j) ) 2377 { 2378 READ_FLAG( uiCode, "layer_in_bsp_flag[h][i][j]" ); vps->setLayerInBspFlag(h, i, j, uiCode); 2379 } 2380 } 2381 #if HRD_BPB 2382 chkPart+=vps->getLayerInBspFlag(h, i, j); 2383 #endif 2384 } 2385 #if HRD_BPB 2386 assert(chkPart<=1); 2387 #endif 2388 #if HRD_BPB 2389 if(vps->getNumBitstreamPartitions(h)==1) 2390 { 2391 Int chkPartition1=0; Int chkPartition2=0; 2392 for( j = 0; j <= (vps->getMaxLayers()-1); j++ ) 2393 { 2394 if( vps->getLayerIdIncludedFlag(h, j) ) 2395 { 2396 chkPartition1+=vps->getLayerInBspFlag(h, 0, j); 2397 chkPartition2++; 2398 } 2399 } 2400 assert(chkPartition1!=chkPartition2); 2401 } 2402 #endif 2403 if (vps->getNumBitstreamPartitions(h)) 2404 { 2405 #if Q0182_MULTI_LAYER_HRD_UPDATE 2406 READ_UVLC( uiCode, "num_bsp_sched_combinations_minus1[h]"); vps->setNumBspSchedCombinations(h, uiCode + 1); 2407 #else 2408 READ_UVLC( uiCode, "num_bsp_sched_combinations[h]"); vps->setNumBspSchedCombinations(h, uiCode); 2409 #endif 2410 for( i = 0; i < vps->getNumBspSchedCombinations(h); i++ ) 2411 { 2412 for( j = 0; j < vps->getNumBitstreamPartitions(h); j++ ) 2413 { 2414 READ_UVLC( uiCode, "bsp_comb_hrd_idx[h][i][j]"); vps->setBspCombHrdIdx(h, i, j, uiCode); 2415 #if HRD_BPB 2416 assert(uiCode <= vps->getVpsNumBspHrdParametersMinus1()); 2417 #endif 2418 2419 READ_UVLC( uiCode, "bsp_comb_sched_idx[h][i][j]"); vps->setBspCombSchedIdx(h, i, j, uiCode); 2420 #if HRD_BPB 2421 assert(uiCode <= vps->getBspHrdParamBufferCpbCntMinus1(uiCode,vps->getMaxTLayers()-1)); 2422 #endif 2423 } 2424 } 2425 } 2426 } 2427 } 2428 #endif 2429 2430 #if P0182_VPS_VUI_PS_FLAG 2431 for(i = 1; i < vps->getMaxLayers(); i++) 2432 { 2433 if (vps->getNumRefLayers(vps->getLayerIdInNuh(i)) == 0) 2434 { 2435 READ_FLAG( uiCode, "base_layer_parameter_set_compatibility_flag" ); 2436 vps->setBaseLayerPSCompatibilityFlag( i, uiCode ); 2437 } 2438 else 2439 { 2440 vps->setBaseLayerPSCompatibilityFlag( i, 0 ); 2441 } 2442 } 2443 #endif 2444 } 2921 vps->setBaseLayerPSCompatibilityFlag( i, 0 ); 2922 } 2923 } 2924 #endif 2925 } 2926 2445 2927 #endif //SVC_EXTENSION 2446 2928 … … 2476 2958 rpcSlice->setSPS(sps); 2477 2959 rpcSlice->setPPS(pps); 2960 2961 #if R0227_REP_FORMAT_CONSTRAINT //Conformance checking for rep format -- rep format of current picture of current layer shall never be greater rep format defined in VPS for the current layer 2962 TComVPS* vps = NULL; 2963 vps = parameterSetManager->getPrefetchedVPS(sps->getVPSId()); 2964 #if R0279_REP_FORMAT_INBL 2965 if ( vps->getVpsExtensionFlag() == 1 && (rpcSlice->getLayerId() == 0 || sps->getV1CompatibleSPSFlag() == 1) ) 2966 { 2967 assert( sps->getPicWidthInLumaSamples() <= vps->getVpsRepFormat( vps->getVpsRepFormatIdx(rpcSlice->getLayerId()) )->getPicWidthVpsInLumaSamples() ); 2968 assert( sps->getPicHeightInLumaSamples() <= vps->getVpsRepFormat( vps->getVpsRepFormatIdx(rpcSlice->getLayerId()) )->getPicHeightVpsInLumaSamples() ); 2969 assert( sps->getChromaFormatIdc() <= vps->getVpsRepFormat( vps->getVpsRepFormatIdx(rpcSlice->getLayerId()) )->getChromaFormatVpsIdc() ); 2970 assert( sps->getBitDepthY() <= vps->getVpsRepFormat( vps->getVpsRepFormatIdx(rpcSlice->getLayerId()) )->getBitDepthVpsLuma() ); 2971 assert( sps->getBitDepthC() <= vps->getVpsRepFormat( vps->getVpsRepFormatIdx(rpcSlice->getLayerId()) )->getBitDepthVpsChroma() ); 2972 #else 2973 if ( rpcSlice->getLayerId() == 0 && vps->getVpsExtensionFlag() == 1 ) 2974 { 2975 assert( sps->getPicWidthInLumaSamples() <= vps->getVpsRepFormat( vps->getVpsRepFormatIdx(0) )->getPicWidthVpsInLumaSamples() ); 2976 assert( sps->getPicHeightInLumaSamples() <= vps->getVpsRepFormat( vps->getVpsRepFormatIdx(0) )->getPicHeightVpsInLumaSamples() ); 2977 assert( sps->getChromaFormatIdc() <= vps->getVpsRepFormat( vps->getVpsRepFormatIdx(0) )->getChromaFormatVpsIdc() ); 2978 assert( sps->getBitDepthY() <= vps->getVpsRepFormat( vps->getVpsRepFormatIdx(0) )->getBitDepthVpsLuma() ); 2979 assert( sps->getBitDepthC() <= vps->getVpsRepFormat( vps->getVpsRepFormatIdx(0) )->getBitDepthVpsChroma() ); 2980 #endif 2981 } 2982 else if ( vps->getVpsExtensionFlag() == 1 ) 2983 { 2984 assert(vps->getVpsRepFormat( vps->getVpsRepFormatIdx(sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : rpcSlice->getLayerId()))->getPicWidthVpsInLumaSamples() <= vps->getVpsRepFormat( vps->getVpsRepFormatIdx(rpcSlice->getLayerId()))->getPicWidthVpsInLumaSamples()); 2985 assert(vps->getVpsRepFormat( vps->getVpsRepFormatIdx(sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : rpcSlice->getLayerId()))->getPicHeightVpsInLumaSamples() <= vps->getVpsRepFormat( vps->getVpsRepFormatIdx(rpcSlice->getLayerId()))->getPicHeightVpsInLumaSamples()); 2986 assert(vps->getVpsRepFormat( vps->getVpsRepFormatIdx(sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : rpcSlice->getLayerId()))->getChromaFormatVpsIdc() <= vps->getVpsRepFormat( vps->getVpsRepFormatIdx(rpcSlice->getLayerId()))->getChromaFormatVpsIdc()); 2987 assert(vps->getVpsRepFormat( vps->getVpsRepFormatIdx(sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : rpcSlice->getLayerId()))->getBitDepthVpsLuma() <= vps->getVpsRepFormat( vps->getVpsRepFormatIdx(rpcSlice->getLayerId()))->getBitDepthVpsLuma()); 2988 assert(vps->getVpsRepFormat( vps->getVpsRepFormatIdx(sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : rpcSlice->getLayerId()))->getBitDepthVpsChroma() <= vps->getVpsRepFormat( vps->getVpsRepFormatIdx(rpcSlice->getLayerId()))->getBitDepthVpsChroma()); 2989 } 2990 #endif 2991 2478 2992 if( pps->getDependentSliceSegmentsEnabledFlag() && ( !firstSliceSegmentInPic )) 2479 2993 { … … 2522 3036 #if Q0142_POC_LSB_NOT_PRESENT 2523 3037 #if SHM_FIX7 2524 3038 Int iPOClsb = 0; 2525 3039 #endif 2526 3040 #endif … … 2557 3071 } 2558 3072 #else 3073 #if CROSS_LAYER_BLA_FLAG_FIX 3074 Int iBits = 0; 3075 if(rpcSlice->getPPS()->getNumExtraSliceHeaderBits() > iBits) 3076 #else 2559 3077 if(rpcSlice->getPPS()->getNumExtraSliceHeaderBits()>0) 3078 #endif 2560 3079 { 2561 3080 READ_FLAG(uiCode, "discardable_flag"); // ignored 2562 } 3081 #if NON_REF_NAL_TYPE_DISCARDABLE 3082 rpcSlice->setDiscardableFlag( uiCode ? true : false ); 3083 if (uiCode) 3084 { 3085 assert(rpcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_TRAIL_R && 3086 rpcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_TSA_R && 3087 rpcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_STSA_R && 3088 rpcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_RADL_R && 3089 rpcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_RASL_R); 3090 } 3091 #endif 3092 #if CROSS_LAYER_BLA_FLAG_FIX 3093 iBits++; 3094 #endif 3095 } 3096 #if CROSS_LAYER_BLA_FLAG_FIX 3097 if(rpcSlice->getPPS()->getNumExtraSliceHeaderBits() > iBits) 3098 { 3099 READ_FLAG(uiCode, "cross_layer_bla_flag"); rpcSlice->setCrossLayerBLAFlag( uiCode ? true : false ); 3100 iBits++; 3101 } 3102 for ( ; iBits < rpcSlice->getPPS()->getNumExtraSliceHeaderBits(); iBits++) 3103 #else 2563 3104 for (Int i = 1; i < rpcSlice->getPPS()->getNumExtraSliceHeaderBits(); i++) 3105 #endif 2564 3106 { 2565 3107 READ_FLAG(uiCode, "slice_reserved_undetermined_flag[]"); // ignored … … 2649 3191 #if N0065_LAYER_POC_ALIGNMENT 2650 3192 #if SHM_FIX7 2651 3193 } 2652 3194 #endif 2653 3195 #if POC_RESET_IDC_DECODER 2654 else 2655 { 2656 rpcSlice->setPicOrderCntLsb( 0 ); 2657 } 2658 #endif 2659 if( !rpcSlice->getIdrPicFlag() ) 2660 { 2661 #endif 2662 TComReferencePictureSet* rps; 2663 rps = rpcSlice->getLocalRPS(); 2664 rpcSlice->setRPS(rps); 2665 READ_FLAG( uiCode, "short_term_ref_pic_set_sps_flag" ); 2666 if(uiCode == 0) // use short-term reference picture set explicitly signalled in slice header 2667 { 2668 parseShortTermRefPicSet(sps,rps, sps->getRPSList()->getNumberOfReferencePictureSets()); 2669 } 2670 else // use reference to short-term reference picture set in PPS 2671 { 2672 Int numBits = 0; 2673 while ((1 << numBits) < rpcSlice->getSPS()->getRPSList()->getNumberOfReferencePictureSets()) 2674 { 2675 numBits++; 2676 } 2677 if (numBits > 0) 2678 { 2679 READ_CODE( numBits, uiCode, "short_term_ref_pic_set_idx"); 3196 else 3197 { 3198 rpcSlice->setPicOrderCntLsb( 0 ); 3199 } 3200 #endif 3201 if( !rpcSlice->getIdrPicFlag() ) 3202 { 3203 #endif 3204 TComReferencePictureSet* rps; 3205 rps = rpcSlice->getLocalRPS(); 3206 rpcSlice->setRPS(rps); 3207 READ_FLAG( uiCode, "short_term_ref_pic_set_sps_flag" ); 3208 if(uiCode == 0) // use short-term reference picture set explicitly signalled in slice header 3209 { 3210 parseShortTermRefPicSet(sps,rps, sps->getRPSList()->getNumberOfReferencePictureSets()); 3211 } 3212 else // use reference to short-term reference picture set in PPS 3213 { 3214 Int numBits = 0; 3215 while ((1 << numBits) < rpcSlice->getSPS()->getRPSList()->getNumberOfReferencePictureSets()) 3216 { 3217 numBits++; 3218 } 3219 if (numBits > 0) 3220 { 3221 READ_CODE( numBits, uiCode, "short_term_ref_pic_set_idx"); 3222 } 3223 else 3224 { 3225 uiCode = 0; 3226 } 3227 *rps = *(sps->getRPSList()->getReferencePictureSet(uiCode)); 3228 } 3229 if(sps->getLongTermRefsPresent()) 3230 { 3231 Int offset = rps->getNumberOfNegativePictures()+rps->getNumberOfPositivePictures(); 3232 UInt numOfLtrp = 0; 3233 UInt numLtrpInSPS = 0; 3234 if (rpcSlice->getSPS()->getNumLongTermRefPicSPS() > 0) 3235 { 3236 READ_UVLC( uiCode, "num_long_term_sps"); 3237 numLtrpInSPS = uiCode; 3238 numOfLtrp += numLtrpInSPS; 3239 rps->setNumberOfLongtermPictures(numOfLtrp); 3240 } 3241 Int bitsForLtrpInSPS = 0; 3242 while (rpcSlice->getSPS()->getNumLongTermRefPicSPS() > (1 << bitsForLtrpInSPS)) 3243 { 3244 bitsForLtrpInSPS++; 3245 } 3246 READ_UVLC( uiCode, "num_long_term_pics"); rps->setNumberOfLongtermPictures(uiCode); 3247 numOfLtrp += uiCode; 3248 rps->setNumberOfLongtermPictures(numOfLtrp); 3249 Int maxPicOrderCntLSB = 1 << rpcSlice->getSPS()->getBitsForPOC(); 3250 Int prevDeltaMSB = 0, deltaPocMSBCycleLT = 0;; 3251 for(Int j=offset+rps->getNumberOfLongtermPictures()-1, k = 0; k < numOfLtrp; j--, k++) 3252 { 3253 Int pocLsbLt; 3254 if (k < numLtrpInSPS) 3255 { 3256 uiCode = 0; 3257 if (bitsForLtrpInSPS > 0) 3258 { 3259 READ_CODE(bitsForLtrpInSPS, uiCode, "lt_idx_sps[i]"); 3260 } 3261 Int usedByCurrFromSPS=rpcSlice->getSPS()->getUsedByCurrPicLtSPSFlag(uiCode); 3262 3263 pocLsbLt = rpcSlice->getSPS()->getLtRefPicPocLsbSps(uiCode); 3264 rps->setUsed(j,usedByCurrFromSPS); 2680 3265 } 2681 3266 else 2682 3267 { 2683 uiCode = 0; 2684 } 2685 *rps = *(sps->getRPSList()->getReferencePictureSet(uiCode)); 2686 } 2687 if(sps->getLongTermRefsPresent()) 2688 { 2689 Int offset = rps->getNumberOfNegativePictures()+rps->getNumberOfPositivePictures(); 2690 UInt numOfLtrp = 0; 2691 UInt numLtrpInSPS = 0; 2692 if (rpcSlice->getSPS()->getNumLongTermRefPicSPS() > 0) 2693 { 2694 READ_UVLC( uiCode, "num_long_term_sps"); 2695 numLtrpInSPS = uiCode; 2696 numOfLtrp += numLtrpInSPS; 2697 rps->setNumberOfLongtermPictures(numOfLtrp); 2698 } 2699 Int bitsForLtrpInSPS = 0; 2700 while (rpcSlice->getSPS()->getNumLongTermRefPicSPS() > (1 << bitsForLtrpInSPS)) 2701 { 2702 bitsForLtrpInSPS++; 2703 } 2704 READ_UVLC( uiCode, "num_long_term_pics"); rps->setNumberOfLongtermPictures(uiCode); 2705 numOfLtrp += uiCode; 2706 rps->setNumberOfLongtermPictures(numOfLtrp); 2707 Int maxPicOrderCntLSB = 1 << rpcSlice->getSPS()->getBitsForPOC(); 2708 Int prevDeltaMSB = 0, deltaPocMSBCycleLT = 0;; 2709 for(Int j=offset+rps->getNumberOfLongtermPictures()-1, k = 0; k < numOfLtrp; j--, k++) 2710 { 2711 Int pocLsbLt; 2712 if (k < numLtrpInSPS) 3268 READ_CODE(rpcSlice->getSPS()->getBitsForPOC(), uiCode, "poc_lsb_lt"); pocLsbLt= uiCode; 3269 READ_FLAG( uiCode, "used_by_curr_pic_lt_flag"); rps->setUsed(j,uiCode); 3270 } 3271 READ_FLAG(uiCode,"delta_poc_msb_present_flag"); 3272 Bool mSBPresentFlag = uiCode ? true : false; 3273 if(mSBPresentFlag) 3274 { 3275 READ_UVLC( uiCode, "delta_poc_msb_cycle_lt[i]" ); 3276 Bool deltaFlag = false; 3277 // First LTRP || First LTRP from SH 3278 if( (j == offset+rps->getNumberOfLongtermPictures()-1) || (j == offset+(numOfLtrp-numLtrpInSPS)-1) ) 2713 3279 { 2714 uiCode = 0; 2715 if (bitsForLtrpInSPS > 0) 2716 { 2717 READ_CODE(bitsForLtrpInSPS, uiCode, "lt_idx_sps[i]"); 2718 } 2719 Int usedByCurrFromSPS=rpcSlice->getSPS()->getUsedByCurrPicLtSPSFlag(uiCode); 2720 2721 pocLsbLt = rpcSlice->getSPS()->getLtRefPicPocLsbSps(uiCode); 2722 rps->setUsed(j,usedByCurrFromSPS); 3280 deltaFlag = true; 3281 } 3282 if(deltaFlag) 3283 { 3284 deltaPocMSBCycleLT = uiCode; 2723 3285 } 2724 3286 else 2725 3287 { 2726 READ_CODE(rpcSlice->getSPS()->getBitsForPOC(), uiCode, "poc_lsb_lt"); pocLsbLt= uiCode; 2727 READ_FLAG( uiCode, "used_by_curr_pic_lt_flag"); rps->setUsed(j,uiCode); 3288 deltaPocMSBCycleLT = uiCode + prevDeltaMSB; 2728 3289 } 2729 READ_FLAG(uiCode,"delta_poc_msb_present_flag"); 2730 Bool mSBPresentFlag = uiCode ? true : false; 2731 if(mSBPresentFlag) 3290 3291 Int pocLTCurr = rpcSlice->getPOC() - deltaPocMSBCycleLT * maxPicOrderCntLSB 3292 - iPOClsb + pocLsbLt; 3293 rps->setPOC (j, pocLTCurr); 3294 rps->setDeltaPOC(j, - rpcSlice->getPOC() + pocLTCurr); 3295 rps->setCheckLTMSBPresent(j,true); 3296 } 3297 else 3298 { 3299 rps->setPOC (j, pocLsbLt); 3300 rps->setDeltaPOC(j, - rpcSlice->getPOC() + pocLsbLt); 3301 rps->setCheckLTMSBPresent(j,false); 3302 3303 // reset deltaPocMSBCycleLT for first LTRP from slice header if MSB not present 3304 if( j == offset+(numOfLtrp-numLtrpInSPS)-1 ) 2732 3305 { 2733 READ_UVLC( uiCode, "delta_poc_msb_cycle_lt[i]" ); 2734 Bool deltaFlag = false; 2735 // First LTRP || First LTRP from SH 2736 if( (j == offset+rps->getNumberOfLongtermPictures()-1) || (j == offset+(numOfLtrp-numLtrpInSPS)-1) ) 2737 { 2738 deltaFlag = true; 2739 } 2740 if(deltaFlag) 2741 { 2742 deltaPocMSBCycleLT = uiCode; 2743 } 2744 else 2745 { 2746 deltaPocMSBCycleLT = uiCode + prevDeltaMSB; 2747 } 2748 2749 Int pocLTCurr = rpcSlice->getPOC() - deltaPocMSBCycleLT * maxPicOrderCntLSB 2750 - iPOClsb + pocLsbLt; 2751 rps->setPOC (j, pocLTCurr); 2752 rps->setDeltaPOC(j, - rpcSlice->getPOC() + pocLTCurr); 2753 rps->setCheckLTMSBPresent(j,true); 3306 deltaPocMSBCycleLT = 0; 2754 3307 } 2755 else 3308 } 3309 prevDeltaMSB = deltaPocMSBCycleLT; 3310 } 3311 offset += rps->getNumberOfLongtermPictures(); 3312 rps->setNumberOfPictures(offset); 3313 } 3314 #if DPB_CONSTRAINTS 3315 if(rpcSlice->getVPS()->getVpsExtensionFlag()==1) 3316 { 3317 #if Q0078_ADD_LAYER_SETS 3318 for (Int ii = 1; ii < (rpcSlice->getVPS()->getVpsNumLayerSetsMinus1() + 1); ii++) // prevent assert error when num_add_layer_sets > 0 3319 #else 3320 for (Int ii=1; ii< rpcSlice->getVPS()->getNumOutputLayerSets(); ii++ ) 3321 #endif 3322 { 3323 Int layerSetIdxForOutputLayerSet = rpcSlice->getVPS()->getOutputLayerSetIdx( ii ); 3324 Int chkAssert=0; 3325 for(Int kk = 0; kk < rpcSlice->getVPS()->getNumLayersInIdList(layerSetIdxForOutputLayerSet); kk++) 3326 { 3327 if(rpcSlice->getLayerId()==rpcSlice->getVPS()->getLayerSetLayerIdList(layerSetIdxForOutputLayerSet, kk)) 2756 3328 { 2757 rps->setPOC (j, pocLsbLt); 2758 rps->setDeltaPOC(j, - rpcSlice->getPOC() + pocLsbLt); 2759 rps->setCheckLTMSBPresent(j,false); 2760 2761 // reset deltaPocMSBCycleLT for first LTRP from slice header if MSB not present 2762 if( j == offset+(numOfLtrp-numLtrpInSPS)-1 ) 2763 { 2764 deltaPocMSBCycleLT = 0; 3329 chkAssert=1; 3330 } 3331 } 3332 if(chkAssert) 3333 { 3334 // There may be something wrong here (layer id assumed to be layer idx?) 3335 assert(rps->getNumberOfNegativePictures() <= rpcSlice->getVPS()->getMaxVpsDecPicBufferingMinus1(ii , rpcSlice->getLayerId() , rpcSlice->getVPS()->getMaxSLayersInLayerSetMinus1(ii))); 3336 assert(rps->getNumberOfPositivePictures() <= rpcSlice->getVPS()->getMaxVpsDecPicBufferingMinus1(ii , rpcSlice->getLayerId() , rpcSlice->getVPS()->getMaxSLayersInLayerSetMinus1(ii)) - rps->getNumberOfNegativePictures()); 3337 assert((rps->getNumberOfPositivePictures() + rps->getNumberOfNegativePictures() + rps->getNumberOfLongtermPictures()) <= rpcSlice->getVPS()->getMaxVpsDecPicBufferingMinus1(ii , rpcSlice->getLayerId() , rpcSlice->getVPS()->getMaxSLayersInLayerSetMinus1(ii))); 3338 } 3339 } 3340 3341 3342 } 3343 if(rpcSlice->getLayerId() == 0) 3344 { 3345 assert(rps->getNumberOfNegativePictures() <= rpcSlice->getSPS()->getMaxDecPicBuffering(rpcSlice->getSPS()->getMaxTLayers()-1) ); 3346 assert(rps->getNumberOfPositivePictures() <= rpcSlice->getSPS()->getMaxDecPicBuffering(rpcSlice->getSPS()->getMaxTLayers()-1) -rps->getNumberOfNegativePictures()); 3347 assert((rps->getNumberOfPositivePictures() + rps->getNumberOfNegativePictures() + rps->getNumberOfLongtermPictures()) <= rpcSlice->getSPS()->getMaxDecPicBuffering(rpcSlice->getSPS()->getMaxTLayers()-1)); 3348 } 3349 #endif 3350 if ( rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP 3351 || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL 3352 || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP ) 3353 { 3354 // In the case of BLA picture types, rps data is read from slice header but ignored 3355 rps = rpcSlice->getLocalRPS(); 3356 rps->setNumberOfNegativePictures(0); 3357 rps->setNumberOfPositivePictures(0); 3358 rps->setNumberOfLongtermPictures(0); 3359 rps->setNumberOfPictures(0); 3360 rpcSlice->setRPS(rps); 3361 } 3362 if (rpcSlice->getSPS()->getTMVPFlagsPresent()) 3363 { 3364 #if R0226_SLICE_TMVP 3365 READ_FLAG( uiCode, "slice_temporal_mvp_enabled_flag" ); 3366 #else 3367 READ_FLAG( uiCode, "slice_temporal_mvp_enable_flag" ); 3368 #endif 3369 rpcSlice->setEnableTMVPFlag( uiCode == 1 ? true : false ); 3370 } 3371 else 3372 { 3373 rpcSlice->setEnableTMVPFlag(false); 3374 } 3375 #if N0065_LAYER_POC_ALIGNMENT && !SHM_FIX7 3376 } 3377 #endif 3378 } 3379 3380 #if SVC_EXTENSION 3381 rpcSlice->setActiveNumILRRefIdx(0); 3382 if((rpcSlice->getLayerId() > 0) && !(rpcSlice->getVPS()->getIlpSshSignalingEnabledFlag()) && (rpcSlice->getNumILRRefIdx() > 0) ) 3383 { 3384 READ_FLAG(uiCode,"inter_layer_pred_enabled_flag"); 3385 rpcSlice->setInterLayerPredEnabledFlag(uiCode); 3386 if( rpcSlice->getInterLayerPredEnabledFlag()) 3387 { 3388 if(rpcSlice->getNumILRRefIdx() > 1) 3389 { 3390 Int numBits = 1; 3391 while ((1 << numBits) < rpcSlice->getNumILRRefIdx()) 3392 { 3393 numBits++; 3394 } 3395 if( !rpcSlice->getVPS()->getMaxOneActiveRefLayerFlag()) 3396 { 3397 READ_CODE( numBits, uiCode,"num_inter_layer_ref_pics_minus1" ); 3398 rpcSlice->setActiveNumILRRefIdx(uiCode + 1); 3399 } 3400 else 3401 { 3402 #if P0079_DERIVE_NUMACTIVE_REF_PICS 3403 for( Int i = 0; i < rpcSlice->getNumILRRefIdx(); i++ ) 3404 { 3405 #if Q0060_MAX_TID_REF_EQUAL_TO_ZERO 3406 if((rpcSlice->getVPS()->getMaxTidIlRefPicsPlus1(rpcSlice->getVPS()->getLayerIdInVps(i),rpcSlice->getLayerId()) > rpcSlice->getTLayer() || rpcSlice->getTLayer()==0) && 3407 (rpcSlice->getVPS()->getMaxTSLayersMinus1(rpcSlice->getVPS()->getLayerIdInVps(i)) >= rpcSlice->getTLayer()) ) 3408 #else 3409 if(rpcSlice->getVPS()->getMaxTidIlRefPicsPlus1(rpcSlice->getVPS()->getLayerIdInVps(i),rpcSlice->getLayerId()) > rpcSlice->getTLayer() && 3410 (rpcSlice->getVPS()->getMaxTSLayersMinus1(rpcSlice->getVPS()->getLayerIdInVps(i)) >= rpcSlice->getTLayer()) ) 3411 #endif 3412 { 3413 rpcSlice->setActiveNumILRRefIdx(1); 3414 break; 2765 3415 } 2766 3416 } 2767 prevDeltaMSB = deltaPocMSBCycleLT; 2768 } 2769 offset += rps->getNumberOfLongtermPictures(); 2770 rps->setNumberOfPictures(offset); 2771 } 2772 #if DPB_CONSTRAINTS 2773 if(rpcSlice->getVPS()->getVpsExtensionFlag()==1) 3417 #else 3418 rpcSlice->setActiveNumILRRefIdx(1); 3419 #endif 3420 } 3421 3422 if( rpcSlice->getActiveNumILRRefIdx() == rpcSlice->getNumILRRefIdx() ) 3423 { 3424 for( Int i = 0; i < rpcSlice->getActiveNumILRRefIdx(); i++ ) 2774 3425 { 2775 #if Q0078_ADD_LAYER_SETS 2776 for (Int ii = 1; ii < (rpcSlice->getVPS()->getVpsNumLayerSetsMinus1() + 1); ii++) // prevent assert error when num_add_layer_sets > 0 2777 #else 2778 for (Int ii=1; ii< rpcSlice->getVPS()->getNumOutputLayerSets(); ii++ ) 2779 #endif 2780 { 2781 Int layerSetIdxForOutputLayerSet = rpcSlice->getVPS()->getOutputLayerSetIdx( ii ); 2782 Int chkAssert=0; 2783 for(Int kk = 0; kk < rpcSlice->getVPS()->getNumLayersInIdList(layerSetIdxForOutputLayerSet); kk++) 2784 { 2785 if(rpcSlice->getLayerId()==rpcSlice->getVPS()->getLayerSetLayerIdList(layerSetIdxForOutputLayerSet, kk)) 2786 { 2787 chkAssert=1; 2788 } 2789 } 2790 if(chkAssert) 2791 { 2792 // There may be something wrong here (layer id assumed to be layer idx?) 2793 assert(rps->getNumberOfNegativePictures() <= rpcSlice->getVPS()->getMaxVpsDecPicBufferingMinus1(ii , rpcSlice->getLayerId() , rpcSlice->getVPS()->getMaxSLayersInLayerSetMinus1(ii))); 2794 assert(rps->getNumberOfPositivePictures() <= rpcSlice->getVPS()->getMaxVpsDecPicBufferingMinus1(ii , rpcSlice->getLayerId() , rpcSlice->getVPS()->getMaxSLayersInLayerSetMinus1(ii)) - rps->getNumberOfNegativePictures()); 2795 assert((rps->getNumberOfPositivePictures() + rps->getNumberOfNegativePictures() + rps->getNumberOfLongtermPictures()) <= rpcSlice->getVPS()->getMaxVpsDecPicBufferingMinus1(ii , rpcSlice->getLayerId() , rpcSlice->getVPS()->getMaxSLayersInLayerSetMinus1(ii))); 2796 } 2797 } 2798 2799 3426 rpcSlice->setInterLayerPredLayerIdc(i,i); 2800 3427 } 2801 if(rpcSlice->getLayerId() == 0) 3428 } 3429 else 3430 { 3431 for(Int i = 0; i < rpcSlice->getActiveNumILRRefIdx(); i++ ) 2802 3432 { 2803 assert(rps->getNumberOfNegativePictures() <= rpcSlice->getSPS()->getMaxDecPicBuffering(rpcSlice->getSPS()->getMaxTLayers()-1) ); 2804 assert(rps->getNumberOfPositivePictures() <= rpcSlice->getSPS()->getMaxDecPicBuffering(rpcSlice->getSPS()->getMaxTLayers()-1) -rps->getNumberOfNegativePictures()); 2805 assert((rps->getNumberOfPositivePictures() + rps->getNumberOfNegativePictures() + rps->getNumberOfLongtermPictures()) <= rpcSlice->getSPS()->getMaxDecPicBuffering(rpcSlice->getSPS()->getMaxTLayers()-1)); 3433 READ_CODE( numBits,uiCode,"inter_layer_pred_layer_idc[i]" ); 3434 rpcSlice->setInterLayerPredLayerIdc(uiCode,i); 2806 3435 } 2807 #endif 2808 if ( rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP 2809 || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL 2810 || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP ) 2811 { 2812 // In the case of BLA picture types, rps data is read from slice header but ignored 2813 rps = rpcSlice->getLocalRPS(); 2814 rps->setNumberOfNegativePictures(0); 2815 rps->setNumberOfPositivePictures(0); 2816 rps->setNumberOfLongtermPictures(0); 2817 rps->setNumberOfPictures(0); 2818 rpcSlice->setRPS(rps); 2819 } 2820 if (rpcSlice->getSPS()->getTMVPFlagsPresent()) 2821 { 2822 READ_FLAG( uiCode, "slice_temporal_mvp_enable_flag" ); 2823 rpcSlice->setEnableTMVPFlag( uiCode == 1 ? true : false ); 3436 } 2824 3437 } 2825 3438 else 2826 3439 { 2827 rpcSlice->setEnableTMVPFlag(false);2828 }2829 #if N0065_LAYER_POC_ALIGNMENT && !SHM_FIX72830 }2831 #endif2832 }2833 2834 #if SVC_EXTENSION2835 rpcSlice->setActiveNumILRRefIdx(0);2836 if((rpcSlice->getLayerId() > 0) && !(rpcSlice->getVPS()->getIlpSshSignalingEnabledFlag()) && (rpcSlice->getNumILRRefIdx() > 0) )2837 {2838 READ_FLAG(uiCode,"inter_layer_pred_enabled_flag");2839 rpcSlice->setInterLayerPredEnabledFlag(uiCode);2840 if( rpcSlice->getInterLayerPredEnabledFlag())2841 {2842 if(rpcSlice->getNumILRRefIdx() > 1)2843 {2844 Int numBits = 1;2845 while ((1 << numBits) < rpcSlice->getNumILRRefIdx())2846 {2847 numBits++;2848 }2849 if( !rpcSlice->getVPS()->getMaxOneActiveRefLayerFlag())2850 {2851 READ_CODE( numBits, uiCode,"num_inter_layer_ref_pics_minus1" );2852 rpcSlice->setActiveNumILRRefIdx(uiCode + 1);2853 }2854 else2855 {2856 #if P0079_DERIVE_NUMACTIVE_REF_PICS2857 for( Int i = 0; i < rpcSlice->getNumILRRefIdx(); i++ )2858 {2859 #if Q0060_MAX_TID_REF_EQUAL_TO_ZERO2860 if((rpcSlice->getVPS()->getMaxTidIlRefPicsPlus1(rpcSlice->getVPS()->getLayerIdInVps(i),rpcSlice->getLayerId()) > rpcSlice->getTLayer() || rpcSlice->getTLayer()==0) &&2861 (rpcSlice->getVPS()->getMaxTSLayersMinus1(rpcSlice->getVPS()->getLayerIdInVps(i)) >= rpcSlice->getTLayer()) )2862 #else2863 if(rpcSlice->getVPS()->getMaxTidIlRefPicsPlus1(rpcSlice->getVPS()->getLayerIdInVps(i),rpcSlice->getLayerId()) > rpcSlice->getTLayer() &&2864 (rpcSlice->getVPS()->getMaxTSLayersMinus1(rpcSlice->getVPS()->getLayerIdInVps(i)) >= rpcSlice->getTLayer()) )2865 #endif2866 {2867 rpcSlice->setActiveNumILRRefIdx(1);2868 break;2869 }2870 }2871 #else2872 rpcSlice->setActiveNumILRRefIdx(1);2873 #endif2874 }2875 2876 if( rpcSlice->getActiveNumILRRefIdx() == rpcSlice->getNumILRRefIdx() )2877 {2878 for( Int i = 0; i < rpcSlice->getActiveNumILRRefIdx(); i++ )2879 {2880 rpcSlice->setInterLayerPredLayerIdc(i,i);2881 }2882 }2883 else2884 {2885 for(Int i = 0; i < rpcSlice->getActiveNumILRRefIdx(); i++ )2886 {2887 READ_CODE( numBits,uiCode,"inter_layer_pred_layer_idc[i]" );2888 rpcSlice->setInterLayerPredLayerIdc(uiCode,i);2889 }2890 }2891 }2892 else2893 {2894 3440 #if O0225_TID_BASED_IL_RPS_DERIV && TSLAYERS_IL_RPS 2895 3441 #if Q0060_MAX_TID_REF_EQUAL_TO_ZERO 2896 2897 2898 #else 2899 2900 3442 if((rpcSlice->getVPS()->getMaxTidIlRefPicsPlus1(0,rpcSlice->getLayerId()) > rpcSlice->getTLayer() || rpcSlice->getTLayer()==0) && 3443 (rpcSlice->getVPS()->getMaxTSLayersMinus1(0) >= rpcSlice->getTLayer()) ) 3444 #else 3445 if( (rpcSlice->getVPS()->getMaxTidIlRefPicsPlus1(0,rpcSlice->getLayerId()) > rpcSlice->getTLayer()) && 3446 (rpcSlice->getVPS()->getMaxTSLayersMinus1(0) >= rpcSlice->getTLayer()) ) 2901 3447 #endif 2902 3448 { … … 2907 3453 } 2908 3454 #endif 2909 2910 2911 2912 2913 2914 3455 } 3456 } 3457 } 3458 else if( rpcSlice->getVPS()->getIlpSshSignalingEnabledFlag() == true && (rpcSlice->getLayerId() > 0 )) 3459 { 3460 rpcSlice->setInterLayerPredEnabledFlag(true); 2915 3461 2916 3462 #if O0225_TID_BASED_IL_RPS_DERIV && TSLAYERS_IL_RPS 2917 2918 2919 2920 2921 3463 Int numRefLayerPics = 0; 3464 Int i = 0; 3465 Int refLayerPicIdc [MAX_VPS_LAYER_ID_PLUS1]; 3466 for(i = 0, numRefLayerPics = 0; i < rpcSlice->getNumILRRefIdx(); i++ ) 3467 { 2922 3468 #if Q0060_MAX_TID_REF_EQUAL_TO_ZERO 2923 2924 3469 if((rpcSlice->getVPS()->getMaxTidIlRefPicsPlus1(rpcSlice->getVPS()->getLayerIdInVps(i),rpcSlice->getLayerId()) > rpcSlice->getTLayer() || rpcSlice->getTLayer()==0) && 3470 (rpcSlice->getVPS()->getMaxTSLayersMinus1(rpcSlice->getVPS()->getLayerIdInVps(i)) >= rpcSlice->getTLayer()) ) 2925 3471 #else 2926 2927 3472 if(rpcSlice->getVPS()->getMaxTidIlRefPicsPlus1(rpcSlice->getVPS()->getLayerIdInVps(i),rpcSlice->getLayerId()) > rpcSlice->getTLayer() && 3473 (rpcSlice->getVPS()->getMaxTSLayersMinus1(rpcSlice->getVPS()->getLayerIdInVps(i)) >= rpcSlice->getTLayer()) ) 2928 3474 #endif 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 #else 2939 2940 2941 2942 2943 3475 { 3476 refLayerPicIdc[ numRefLayerPics++ ] = i; 3477 } 3478 } 3479 rpcSlice->setActiveNumILRRefIdx(numRefLayerPics); 3480 for( i = 0; i < rpcSlice->getActiveNumILRRefIdx(); i++ ) 3481 { 3482 rpcSlice->setInterLayerPredLayerIdc(refLayerPicIdc[i],i); 3483 } 3484 #else 3485 rpcSlice->setActiveNumILRRefIdx(rpcSlice->getNumILRRefIdx()); 3486 for( Int i = 0; i < rpcSlice->getActiveNumILRRefIdx(); i++ ) 3487 { 3488 rpcSlice->setInterLayerPredLayerIdc(i,i); 3489 } 2944 3490 #endif 2945 3491 } 2946 3492 #if P0312_VERT_PHASE_ADJ 2947 3493 for(Int i = 0; i < rpcSlice->getActiveNumILRRefIdx(); i++ ) 2948 3494 { 2949 3495 UInt refLayerIdc = rpcSlice->getInterLayerPredLayerIdc(i); 3496 #if !MOVE_SCALED_OFFSET_TO_PPS 2950 3497 if( rpcSlice->getSPS()->getVertPhasePositionEnableFlag(refLayerIdc) ) 3498 #else 3499 if( rpcSlice->getPPS()->getVertPhasePositionEnableFlag(refLayerIdc) ) 3500 #endif 2951 3501 { 2952 3502 READ_FLAG( uiCode, "vert_phase_position_flag" ); rpcSlice->setVertPhasePositionFlag( uiCode? true : false, refLayerIdc ); 2953 3503 } 2954 3504 } 2955 3505 #endif 2956 3506 #endif //SVC_EXTENSION 2957 3507 2958 2959 2960 3508 if(sps->getUseSAO()) 3509 { 3510 READ_FLAG(uiCode, "slice_sao_luma_flag"); rpcSlice->setSaoEnabledFlag((Bool)uiCode); 2961 3511 #if AUXILIARY_PICTURES 2962 3512 ChromaFormat format; 2963 3513 #if REPN_FORMAT_IN_VPS 2964 3514 #if O0096_REP_FORMAT_INDEX 2965 2966 2967 2968 2969 2970 2971 3515 if( sps->getLayerId() == 0 ) 3516 { 3517 format = sps->getChromaFormatIdc(); 3518 } 3519 else 3520 { 3521 format = rpcSlice->getVPS()->getVpsRepFormat( sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : rpcSlice->getVPS()->getVpsRepFormatIdx(sps->getLayerId()) )->getChromaFormatVpsIdc(); 2972 3522 #if Q0195_REP_FORMAT_CLEANUP 2973 assert( (sps->getUpdateRepFormatFlag()==false && rpcSlice->getVPS()->getVpsNumRepFormats()==1) || rpcSlice->getVPS()->getVpsNumRepFormats() > 1 ); //conformance check 2974 #endif 2975 } 2976 #else 2977 if( ( sps->getLayerId() == 0 ) || sps->getUpdateRepFormatFlag() ) 2978 { 2979 format = sps->getChromaFormatIdc(); 2980 } 2981 else 2982 { 2983 format = rpcSlice->getVPS()->getVpsRepFormat( rpcSlice->getVPS()->getVpsRepFormatIdx(sps->getLayerId()) )->getChromaFormatVpsIdc(); 2984 } 2985 #endif 2986 #else 3523 assert( (sps->getUpdateRepFormatFlag()==false && rpcSlice->getVPS()->getVpsNumRepFormats()==1) || rpcSlice->getVPS()->getVpsNumRepFormats() > 1 ); //conformance check 3524 #endif 3525 } 3526 #else 3527 if( ( sps->getLayerId() == 0 ) || sps->getUpdateRepFormatFlag() ) 3528 { 2987 3529 format = sps->getChromaFormatIdc(); 2988 #endif 2989 if (format != CHROMA_400) 2990 { 3530 } 3531 else 3532 { 3533 format = rpcSlice->getVPS()->getVpsRepFormat( rpcSlice->getVPS()->getVpsRepFormatIdx(sps->getLayerId()) )->getChromaFormatVpsIdc(); 3534 } 3535 #endif 3536 #else 3537 format = sps->getChromaFormatIdc(); 3538 #endif 3539 if (format != CHROMA_400) 3540 { 2991 3541 #endif 2992 3542 READ_FLAG(uiCode, "slice_sao_chroma_flag"); rpcSlice->setSaoEnabledFlagChroma((Bool)uiCode); 2993 3543 #if AUXILIARY_PICTURES 3544 } 3545 else 3546 { 3547 rpcSlice->setSaoEnabledFlagChroma(false); 3548 } 3549 #endif 3550 } 3551 3552 if (rpcSlice->getIdrPicFlag()) 3553 { 3554 rpcSlice->setEnableTMVPFlag(false); 3555 } 3556 if (!rpcSlice->isIntra()) 3557 { 3558 3559 READ_FLAG( uiCode, "num_ref_idx_active_override_flag"); 3560 if (uiCode) 3561 { 3562 READ_UVLC (uiCode, "num_ref_idx_l0_active_minus1" ); rpcSlice->setNumRefIdx( REF_PIC_LIST_0, uiCode + 1 ); 3563 if (rpcSlice->isInterB()) 3564 { 3565 READ_UVLC (uiCode, "num_ref_idx_l1_active_minus1" ); rpcSlice->setNumRefIdx( REF_PIC_LIST_1, uiCode + 1 ); 2994 3566 } 2995 3567 else 2996 3568 { 2997 rpcSlice->setSaoEnabledFlagChroma(false); 2998 } 2999 #endif 3000 } 3001 3002 if (rpcSlice->getIdrPicFlag()) 3003 { 3004 rpcSlice->setEnableTMVPFlag(false); 3005 } 3006 if (!rpcSlice->isIntra()) 3007 { 3008 3009 READ_FLAG( uiCode, "num_ref_idx_active_override_flag"); 3010 if (uiCode) 3011 { 3012 READ_UVLC (uiCode, "num_ref_idx_l0_active_minus1" ); rpcSlice->setNumRefIdx( REF_PIC_LIST_0, uiCode + 1 ); 3013 if (rpcSlice->isInterB()) 3014 { 3015 READ_UVLC (uiCode, "num_ref_idx_l1_active_minus1" ); rpcSlice->setNumRefIdx( REF_PIC_LIST_1, uiCode + 1 ); 3016 } 3017 else 3018 { 3019 rpcSlice->setNumRefIdx(REF_PIC_LIST_1, 0); 3020 } 3569 rpcSlice->setNumRefIdx(REF_PIC_LIST_1, 0); 3570 } 3571 } 3572 else 3573 { 3574 rpcSlice->setNumRefIdx(REF_PIC_LIST_0, rpcSlice->getPPS()->getNumRefIdxL0DefaultActive()); 3575 if (rpcSlice->isInterB()) 3576 { 3577 rpcSlice->setNumRefIdx(REF_PIC_LIST_1, rpcSlice->getPPS()->getNumRefIdxL1DefaultActive()); 3021 3578 } 3022 3579 else 3023 3580 { 3024 rpcSlice->setNumRefIdx(REF_PIC_LIST_0, rpcSlice->getPPS()->getNumRefIdxL0DefaultActive()); 3025 if (rpcSlice->isInterB()) 3026 { 3027 rpcSlice->setNumRefIdx(REF_PIC_LIST_1, rpcSlice->getPPS()->getNumRefIdxL1DefaultActive()); 3028 } 3029 else 3030 { 3031 rpcSlice->setNumRefIdx(REF_PIC_LIST_1,0); 3032 } 3033 } 3034 } 3035 // } 3036 TComRefPicListModification* refPicListModification = rpcSlice->getRefPicListModification(); 3037 if(!rpcSlice->isIntra()) 3038 { 3039 if( !rpcSlice->getPPS()->getListsModificationPresentFlag() || rpcSlice->getNumRpsCurrTempList() <= 1 ) 3040 { 3041 refPicListModification->setRefPicListModificationFlagL0( 0 ); 3581 rpcSlice->setNumRefIdx(REF_PIC_LIST_1,0); 3582 } 3583 } 3584 } 3585 // } 3586 TComRefPicListModification* refPicListModification = rpcSlice->getRefPicListModification(); 3587 if(!rpcSlice->isIntra()) 3588 { 3589 if( !rpcSlice->getPPS()->getListsModificationPresentFlag() || rpcSlice->getNumRpsCurrTempList() <= 1 ) 3590 { 3591 refPicListModification->setRefPicListModificationFlagL0( 0 ); 3592 } 3593 else 3594 { 3595 READ_FLAG( uiCode, "ref_pic_list_modification_flag_l0" ); refPicListModification->setRefPicListModificationFlagL0( uiCode ? 1 : 0 ); 3596 } 3597 3598 if(refPicListModification->getRefPicListModificationFlagL0()) 3599 { 3600 uiCode = 0; 3601 Int i = 0; 3602 Int numRpsCurrTempList0 = rpcSlice->getNumRpsCurrTempList(); 3603 if ( numRpsCurrTempList0 > 1 ) 3604 { 3605 Int length = 1; 3606 numRpsCurrTempList0 --; 3607 while ( numRpsCurrTempList0 >>= 1) 3608 { 3609 length ++; 3610 } 3611 for (i = 0; i < rpcSlice->getNumRefIdx(REF_PIC_LIST_0); i ++) 3612 { 3613 READ_CODE( length, uiCode, "list_entry_l0" ); 3614 refPicListModification->setRefPicSetIdxL0(i, uiCode ); 3615 } 3042 3616 } 3043 3617 else 3044 3618 { 3045 READ_FLAG( uiCode, "ref_pic_list_modification_flag_l0" ); refPicListModification->setRefPicListModificationFlagL0( uiCode ? 1 : 0 ); 3046 } 3047 3048 if(refPicListModification->getRefPicListModificationFlagL0()) 3049 { 3050 uiCode = 0; 3051 Int i = 0; 3052 Int numRpsCurrTempList0 = rpcSlice->getNumRpsCurrTempList(); 3053 if ( numRpsCurrTempList0 > 1 ) 3054 { 3055 Int length = 1; 3056 numRpsCurrTempList0 --; 3057 while ( numRpsCurrTempList0 >>= 1) 3058 { 3059 length ++; 3060 } 3061 for (i = 0; i < rpcSlice->getNumRefIdx(REF_PIC_LIST_0); i ++) 3062 { 3063 READ_CODE( length, uiCode, "list_entry_l0" ); 3064 refPicListModification->setRefPicSetIdxL0(i, uiCode ); 3065 } 3066 } 3067 else 3068 { 3069 for (i = 0; i < rpcSlice->getNumRefIdx(REF_PIC_LIST_0); i ++) 3070 { 3071 refPicListModification->setRefPicSetIdxL0(i, 0 ); 3072 } 3073 } 3074 } 3619 for (i = 0; i < rpcSlice->getNumRefIdx(REF_PIC_LIST_0); i ++) 3620 { 3621 refPicListModification->setRefPicSetIdxL0(i, 0 ); 3622 } 3623 } 3624 } 3625 } 3626 else 3627 { 3628 refPicListModification->setRefPicListModificationFlagL0(0); 3629 } 3630 if(rpcSlice->isInterB()) 3631 { 3632 if( !rpcSlice->getPPS()->getListsModificationPresentFlag() || rpcSlice->getNumRpsCurrTempList() <= 1 ) 3633 { 3634 refPicListModification->setRefPicListModificationFlagL1( 0 ); 3075 3635 } 3076 3636 else 3077 3637 { 3078 refPicListModification->setRefPicListModificationFlagL0(0); 3079 } 3080 if(rpcSlice->isInterB()) 3081 { 3082 if( !rpcSlice->getPPS()->getListsModificationPresentFlag() || rpcSlice->getNumRpsCurrTempList() <= 1 ) 3083 { 3084 refPicListModification->setRefPicListModificationFlagL1( 0 ); 3638 READ_FLAG( uiCode, "ref_pic_list_modification_flag_l1" ); refPicListModification->setRefPicListModificationFlagL1( uiCode ? 1 : 0 ); 3639 } 3640 if(refPicListModification->getRefPicListModificationFlagL1()) 3641 { 3642 uiCode = 0; 3643 Int i = 0; 3644 Int numRpsCurrTempList1 = rpcSlice->getNumRpsCurrTempList(); 3645 if ( numRpsCurrTempList1 > 1 ) 3646 { 3647 Int length = 1; 3648 numRpsCurrTempList1 --; 3649 while ( numRpsCurrTempList1 >>= 1) 3650 { 3651 length ++; 3652 } 3653 for (i = 0; i < rpcSlice->getNumRefIdx(REF_PIC_LIST_1); i ++) 3654 { 3655 READ_CODE( length, uiCode, "list_entry_l1" ); 3656 refPicListModification->setRefPicSetIdxL1(i, uiCode ); 3657 } 3085 3658 } 3086 3659 else 3087 3660 { 3088 READ_FLAG( uiCode, "ref_pic_list_modification_flag_l1" ); refPicListModification->setRefPicListModificationFlagL1( uiCode ? 1 : 0 ); 3089 } 3090 if(refPicListModification->getRefPicListModificationFlagL1()) 3091 { 3092 uiCode = 0; 3093 Int i = 0; 3094 Int numRpsCurrTempList1 = rpcSlice->getNumRpsCurrTempList(); 3095 if ( numRpsCurrTempList1 > 1 ) 3096 { 3097 Int length = 1; 3098 numRpsCurrTempList1 --; 3099 while ( numRpsCurrTempList1 >>= 1) 3100 { 3101 length ++; 3102 } 3103 for (i = 0; i < rpcSlice->getNumRefIdx(REF_PIC_LIST_1); i ++) 3104 { 3105 READ_CODE( length, uiCode, "list_entry_l1" ); 3106 refPicListModification->setRefPicSetIdxL1(i, uiCode ); 3107 } 3108 } 3109 else 3110 { 3111 for (i = 0; i < rpcSlice->getNumRefIdx(REF_PIC_LIST_1); i ++) 3112 { 3113 refPicListModification->setRefPicSetIdxL1(i, 0 ); 3114 } 3115 } 3116 } 3661 for (i = 0; i < rpcSlice->getNumRefIdx(REF_PIC_LIST_1); i ++) 3662 { 3663 refPicListModification->setRefPicSetIdxL1(i, 0 ); 3664 } 3665 } 3666 } 3667 } 3668 else 3669 { 3670 refPicListModification->setRefPicListModificationFlagL1(0); 3671 } 3672 if (rpcSlice->isInterB()) 3673 { 3674 READ_FLAG( uiCode, "mvd_l1_zero_flag" ); rpcSlice->setMvdL1ZeroFlag( (uiCode ? true : false) ); 3675 } 3676 3677 rpcSlice->setCabacInitFlag( false ); // default 3678 if(pps->getCabacInitPresentFlag() && !rpcSlice->isIntra()) 3679 { 3680 READ_FLAG(uiCode, "cabac_init_flag"); 3681 rpcSlice->setCabacInitFlag( uiCode ? true : false ); 3682 } 3683 3684 if ( rpcSlice->getEnableTMVPFlag() ) 3685 { 3686 #if SVC_EXTENSION && REF_IDX_MFM 3687 // set motion mapping flag 3688 rpcSlice->setMFMEnabledFlag( ( rpcSlice->getNumMotionPredRefLayers() > 0 && rpcSlice->getActiveNumILRRefIdx() && !rpcSlice->isIntra() ) ? true : false ); 3689 #endif 3690 if ( rpcSlice->getSliceType() == B_SLICE ) 3691 { 3692 READ_FLAG( uiCode, "collocated_from_l0_flag" ); 3693 rpcSlice->setColFromL0Flag(uiCode); 3117 3694 } 3118 3695 else 3119 3696 { 3120 refPicListModification->setRefPicListModificationFlagL1(0); 3121 } 3122 if (rpcSlice->isInterB()) 3123 { 3124 READ_FLAG( uiCode, "mvd_l1_zero_flag" ); rpcSlice->setMvdL1ZeroFlag( (uiCode ? true : false) ); 3125 } 3126 3127 rpcSlice->setCabacInitFlag( false ); // default 3128 if(pps->getCabacInitPresentFlag() && !rpcSlice->isIntra()) 3129 { 3130 READ_FLAG(uiCode, "cabac_init_flag"); 3131 rpcSlice->setCabacInitFlag( uiCode ? true : false ); 3132 } 3133 3134 if ( rpcSlice->getEnableTMVPFlag() ) 3135 { 3136 #if SVC_EXTENSION && REF_IDX_MFM 3137 // set motion mapping flag 3138 rpcSlice->setMFMEnabledFlag( ( rpcSlice->getNumMotionPredRefLayers() > 0 && rpcSlice->getActiveNumILRRefIdx() && !rpcSlice->isIntra() ) ? true : false ); 3139 #endif 3140 if ( rpcSlice->getSliceType() == B_SLICE ) 3141 { 3142 READ_FLAG( uiCode, "collocated_from_l0_flag" ); 3143 rpcSlice->setColFromL0Flag(uiCode); 3144 } 3145 else 3146 { 3147 rpcSlice->setColFromL0Flag( 1 ); 3148 } 3149 3150 if ( rpcSlice->getSliceType() != I_SLICE && 3151 ((rpcSlice->getColFromL0Flag() == 1 && rpcSlice->getNumRefIdx(REF_PIC_LIST_0) > 1)|| 3152 (rpcSlice->getColFromL0Flag() == 0 && rpcSlice->getNumRefIdx(REF_PIC_LIST_1) > 1))) 3153 { 3154 READ_UVLC( uiCode, "collocated_ref_idx" ); 3155 rpcSlice->setColRefIdx(uiCode); 3156 } 3157 else 3158 { 3159 rpcSlice->setColRefIdx(0); 3160 } 3161 } 3162 if ( (pps->getUseWP() && rpcSlice->getSliceType()==P_SLICE) || (pps->getWPBiPred() && rpcSlice->getSliceType()==B_SLICE) ) 3163 { 3164 xParsePredWeightTable(rpcSlice); 3165 rpcSlice->initWpScaling(); 3166 } 3167 if (!rpcSlice->isIntra()) 3168 { 3169 READ_UVLC( uiCode, "five_minus_max_num_merge_cand"); 3170 rpcSlice->setMaxNumMergeCand(MRG_MAX_NUM_CANDS - uiCode); 3171 } 3172 3173 READ_SVLC( iCode, "slice_qp_delta" ); 3174 rpcSlice->setSliceQp (26 + pps->getPicInitQPMinus26() + iCode); 3697 rpcSlice->setColFromL0Flag( 1 ); 3698 } 3699 3700 if ( rpcSlice->getSliceType() != I_SLICE && 3701 ((rpcSlice->getColFromL0Flag() == 1 && rpcSlice->getNumRefIdx(REF_PIC_LIST_0) > 1)|| 3702 (rpcSlice->getColFromL0Flag() == 0 && rpcSlice->getNumRefIdx(REF_PIC_LIST_1) > 1))) 3703 { 3704 READ_UVLC( uiCode, "collocated_ref_idx" ); 3705 rpcSlice->setColRefIdx(uiCode); 3706 } 3707 else 3708 { 3709 rpcSlice->setColRefIdx(0); 3710 } 3711 } 3712 if ( (pps->getUseWP() && rpcSlice->getSliceType()==P_SLICE) || (pps->getWPBiPred() && rpcSlice->getSliceType()==B_SLICE) ) 3713 { 3714 xParsePredWeightTable(rpcSlice); 3715 rpcSlice->initWpScaling(); 3716 } 3717 if (!rpcSlice->isIntra()) 3718 { 3719 READ_UVLC( uiCode, "five_minus_max_num_merge_cand"); 3720 rpcSlice->setMaxNumMergeCand(MRG_MAX_NUM_CANDS - uiCode); 3721 } 3722 3723 READ_SVLC( iCode, "slice_qp_delta" ); 3724 rpcSlice->setSliceQp (26 + pps->getPicInitQPMinus26() + iCode); 3175 3725 3176 3726 #if REPN_FORMAT_IN_VPS 3177 3727 #if O0194_DIFFERENT_BITDEPTH_EL_BL 3178 g_bitDepthYLayer[rpcSlice->getLayerId()] = rpcSlice->getBitDepthY(); 3179 g_bitDepthCLayer[rpcSlice->getLayerId()] = rpcSlice->getBitDepthC(); 3180 #endif 3181 assert( rpcSlice->getSliceQp() >= -rpcSlice->getQpBDOffsetY() ); 3182 #else 3183 assert( rpcSlice->getSliceQp() >= -sps->getQpBDOffsetY() ); 3184 #endif 3185 assert( rpcSlice->getSliceQp() <= 51 ); 3186 3187 if (rpcSlice->getPPS()->getSliceChromaQpFlag()) 3188 { 3189 READ_SVLC( iCode, "slice_qp_delta_cb" ); 3190 rpcSlice->setSliceQpDeltaCb( iCode ); 3191 assert( rpcSlice->getSliceQpDeltaCb() >= -12 ); 3192 assert( rpcSlice->getSliceQpDeltaCb() <= 12 ); 3193 assert( (rpcSlice->getPPS()->getChromaCbQpOffset() + rpcSlice->getSliceQpDeltaCb()) >= -12 ); 3194 assert( (rpcSlice->getPPS()->getChromaCbQpOffset() + rpcSlice->getSliceQpDeltaCb()) <= 12 ); 3195 3196 READ_SVLC( iCode, "slice_qp_delta_cr" ); 3197 rpcSlice->setSliceQpDeltaCr( iCode ); 3198 assert( rpcSlice->getSliceQpDeltaCr() >= -12 ); 3199 assert( rpcSlice->getSliceQpDeltaCr() <= 12 ); 3200 assert( (rpcSlice->getPPS()->getChromaCrQpOffset() + rpcSlice->getSliceQpDeltaCr()) >= -12 ); 3201 assert( (rpcSlice->getPPS()->getChromaCrQpOffset() + rpcSlice->getSliceQpDeltaCr()) <= 12 ); 3202 } 3203 3204 if (rpcSlice->getPPS()->getDeblockingFilterControlPresentFlag()) 3205 { 3206 if(rpcSlice->getPPS()->getDeblockingFilterOverrideEnabledFlag()) 3207 { 3208 READ_FLAG ( uiCode, "deblocking_filter_override_flag" ); rpcSlice->setDeblockingFilterOverrideFlag(uiCode ? true : false); 3728 g_bitDepthYLayer[rpcSlice->getLayerId()] = rpcSlice->getBitDepthY(); 3729 g_bitDepthCLayer[rpcSlice->getLayerId()] = rpcSlice->getBitDepthC(); 3730 #endif 3731 assert( rpcSlice->getSliceQp() >= -rpcSlice->getQpBDOffsetY() ); 3732 #else 3733 assert( rpcSlice->getSliceQp() >= -sps->getQpBDOffsetY() ); 3734 #endif 3735 assert( rpcSlice->getSliceQp() <= 51 ); 3736 3737 if (rpcSlice->getPPS()->getSliceChromaQpFlag()) 3738 { 3739 READ_SVLC( iCode, "slice_qp_delta_cb" ); 3740 rpcSlice->setSliceQpDeltaCb( iCode ); 3741 assert( rpcSlice->getSliceQpDeltaCb() >= -12 ); 3742 assert( rpcSlice->getSliceQpDeltaCb() <= 12 ); 3743 assert( (rpcSlice->getPPS()->getChromaCbQpOffset() + rpcSlice->getSliceQpDeltaCb()) >= -12 ); 3744 assert( (rpcSlice->getPPS()->getChromaCbQpOffset() + rpcSlice->getSliceQpDeltaCb()) <= 12 ); 3745 3746 READ_SVLC( iCode, "slice_qp_delta_cr" ); 3747 rpcSlice->setSliceQpDeltaCr( iCode ); 3748 assert( rpcSlice->getSliceQpDeltaCr() >= -12 ); 3749 assert( rpcSlice->getSliceQpDeltaCr() <= 12 ); 3750 assert( (rpcSlice->getPPS()->getChromaCrQpOffset() + rpcSlice->getSliceQpDeltaCr()) >= -12 ); 3751 assert( (rpcSlice->getPPS()->getChromaCrQpOffset() + rpcSlice->getSliceQpDeltaCr()) <= 12 ); 3752 } 3753 3754 if (rpcSlice->getPPS()->getDeblockingFilterControlPresentFlag()) 3755 { 3756 if(rpcSlice->getPPS()->getDeblockingFilterOverrideEnabledFlag()) 3757 { 3758 READ_FLAG ( uiCode, "deblocking_filter_override_flag" ); rpcSlice->setDeblockingFilterOverrideFlag(uiCode ? true : false); 3759 } 3760 else 3761 { 3762 rpcSlice->setDeblockingFilterOverrideFlag(0); 3763 } 3764 if(rpcSlice->getDeblockingFilterOverrideFlag()) 3765 { 3766 READ_FLAG ( uiCode, "slice_disable_deblocking_filter_flag" ); rpcSlice->setDeblockingFilterDisable(uiCode ? 1 : 0); 3767 if(!rpcSlice->getDeblockingFilterDisable()) 3768 { 3769 READ_SVLC( iCode, "slice_beta_offset_div2" ); rpcSlice->setDeblockingFilterBetaOffsetDiv2(iCode); 3770 assert(rpcSlice->getDeblockingFilterBetaOffsetDiv2() >= -6 && 3771 rpcSlice->getDeblockingFilterBetaOffsetDiv2() <= 6); 3772 READ_SVLC( iCode, "slice_tc_offset_div2" ); rpcSlice->setDeblockingFilterTcOffsetDiv2(iCode); 3773 assert(rpcSlice->getDeblockingFilterTcOffsetDiv2() >= -6 && 3774 rpcSlice->getDeblockingFilterTcOffsetDiv2() <= 6); 3775 } 3776 } 3777 else 3778 { 3779 rpcSlice->setDeblockingFilterDisable ( rpcSlice->getPPS()->getPicDisableDeblockingFilterFlag() ); 3780 rpcSlice->setDeblockingFilterBetaOffsetDiv2( rpcSlice->getPPS()->getDeblockingFilterBetaOffsetDiv2() ); 3781 rpcSlice->setDeblockingFilterTcOffsetDiv2 ( rpcSlice->getPPS()->getDeblockingFilterTcOffsetDiv2() ); 3782 } 3783 } 3784 else 3785 { 3786 rpcSlice->setDeblockingFilterDisable ( false ); 3787 rpcSlice->setDeblockingFilterBetaOffsetDiv2( 0 ); 3788 rpcSlice->setDeblockingFilterTcOffsetDiv2 ( 0 ); 3789 } 3790 3791 Bool isSAOEnabled = (!rpcSlice->getSPS()->getUseSAO())?(false):(rpcSlice->getSaoEnabledFlag()||rpcSlice->getSaoEnabledFlagChroma()); 3792 Bool isDBFEnabled = (!rpcSlice->getDeblockingFilterDisable()); 3793 3794 if(rpcSlice->getPPS()->getLoopFilterAcrossSlicesEnabledFlag() && ( isSAOEnabled || isDBFEnabled )) 3795 { 3796 READ_FLAG( uiCode, "slice_loop_filter_across_slices_enabled_flag"); 3797 } 3798 else 3799 { 3800 uiCode = rpcSlice->getPPS()->getLoopFilterAcrossSlicesEnabledFlag()?1:0; 3801 } 3802 rpcSlice->setLFCrossSliceBoundaryFlag( (uiCode==1)?true:false); 3803 3804 } 3805 3806 UInt *entryPointOffset = NULL; 3807 UInt numEntryPointOffsets, offsetLenMinus1; 3808 if( pps->getTilesEnabledFlag() || pps->getEntropyCodingSyncEnabledFlag() ) 3809 { 3810 READ_UVLC(numEntryPointOffsets, "num_entry_point_offsets"); rpcSlice->setNumEntryPointOffsets ( numEntryPointOffsets ); 3811 if (numEntryPointOffsets>0) 3812 { 3813 READ_UVLC(offsetLenMinus1, "offset_len_minus1"); 3814 } 3815 entryPointOffset = new UInt[numEntryPointOffsets]; 3816 for (UInt idx=0; idx<numEntryPointOffsets; idx++) 3817 { 3818 READ_CODE(offsetLenMinus1+1, uiCode, "entry_point_offset_minus1"); 3819 entryPointOffset[ idx ] = uiCode + 1; 3820 } 3821 } 3822 else 3823 { 3824 rpcSlice->setNumEntryPointOffsets ( 0 ); 3825 } 3826 3827 #if POC_RESET_IDC_SIGNALLING 3828 Int sliceHeaderExtensionLength = 0; 3829 if(pps->getSliceHeaderExtensionPresentFlag()) 3830 { 3831 READ_UVLC( uiCode, "slice_header_extension_length"); sliceHeaderExtensionLength = uiCode; 3832 } 3833 else 3834 { 3835 sliceHeaderExtensionLength = 0; 3836 #if INFERENCE_POC_MSB_VAL_PRESENT 3837 rpcSlice->setPocMsbValPresentFlag( false ); 3838 #endif 3839 } 3840 UInt startBits = m_pcBitstream->getNumBitsRead(); // Start counter of # SH Extn bits 3841 if( sliceHeaderExtensionLength > 0 ) 3842 { 3843 if( rpcSlice->getPPS()->getPocResetInfoPresentFlag() ) 3844 { 3845 READ_CODE( 2, uiCode, "poc_reset_idc"); rpcSlice->setPocResetIdc(uiCode); 3846 #if POC_RESET_RESTRICTIONS 3847 /* The value of poc_reset_idc shall not be equal to 1 or 2 for a RASL picture, a RADL picture, 3848 a sub-layer non-reference picture, or a picture that has TemporalId greater than 0, 3849 or a picture that has discardable_flag equal to 1. */ 3850 if( rpcSlice->getPocResetIdc() == 1 || rpcSlice->getPocResetIdc() == 2 ) 3851 { 3852 assert( !rpcSlice->isRASL() ); 3853 assert( !rpcSlice->isRADL() ); 3854 assert( !rpcSlice->isSLNR() ); 3855 assert( rpcSlice->getTLayer() == 0 ); 3856 assert( rpcSlice->getDiscardableFlag() == 0 ); 3857 } 3858 3859 // The value of poc_reset_idc of a CRA or BLA picture shall be less than 3. 3860 if( rpcSlice->getPocResetIdc() == 3) 3861 { 3862 assert( ! ( rpcSlice->isCRA() || rpcSlice->isBLA() ) ); 3863 } 3864 #endif 3865 } 3866 else 3867 { 3868 rpcSlice->setPocResetIdc( 0 ); 3869 } 3870 #if Q0142_POC_LSB_NOT_PRESENT 3871 if ( rpcSlice->getVPS()->getPocLsbNotPresentFlag(rpcSlice->getLayerId()) && iPOClsb > 0 ) 3872 { 3873 assert( rpcSlice->getPocResetIdc() != 2 ); 3874 } 3875 #endif 3876 if( rpcSlice->getPocResetIdc() > 0 ) 3877 { 3878 READ_CODE(6, uiCode, "poc_reset_period_id"); rpcSlice->setPocResetPeriodId(uiCode); 3879 } 3880 else 3881 { 3882 3883 rpcSlice->setPocResetPeriodId( 0 ); 3884 } 3885 3886 if (rpcSlice->getPocResetIdc() == 3) 3887 { 3888 READ_FLAG( uiCode, "full_poc_reset_flag"); rpcSlice->setFullPocResetFlag((uiCode == 1) ? true : false); 3889 READ_CODE(rpcSlice->getSPS()->getBitsForPOC(), uiCode,"poc_lsb_val"); rpcSlice->setPocLsbVal(uiCode); 3890 #if Q0142_POC_LSB_NOT_PRESENT 3891 if ( rpcSlice->getVPS()->getPocLsbNotPresentFlag(rpcSlice->getLayerId()) && rpcSlice->getFullPocResetFlag() ) 3892 { 3893 assert( rpcSlice->getPocLsbVal() == 0 ); 3894 } 3895 #endif 3896 } 3897 3898 // Derive the value of PocMsbValRequiredFlag 3899 #if P0297_VPS_POC_LSB_ALIGNED_FLAG 3900 rpcSlice->setPocMsbValRequiredFlag( (rpcSlice->getCraPicFlag() || rpcSlice->getBlaPicFlag()) 3901 && (!rpcSlice->getVPS()->getVpsPocLsbAlignedFlag() || 3902 (rpcSlice->getVPS()->getVpsPocLsbAlignedFlag() && rpcSlice->getVPS()->getNumDirectRefLayers(rpcSlice->getLayerId()) == 0)) 3903 ); 3904 #else 3905 rpcSlice->setPocMsbValRequiredFlag( rpcSlice->getCraPicFlag() || rpcSlice->getBlaPicFlag() ); 3906 #endif 3907 3908 #if P0297_VPS_POC_LSB_ALIGNED_FLAG 3909 if (!rpcSlice->getPocMsbValRequiredFlag() && rpcSlice->getVPS()->getVpsPocLsbAlignedFlag()) 3910 #else 3911 if (!rpcSlice->getPocMsbValRequiredFlag() /* vps_poc_lsb_aligned_flag */) 3912 #endif 3913 { 3914 #if P0297_VPS_POC_LSB_ALIGNED_FLAG 3915 READ_FLAG(uiCode, "poc_msb_cycle_val_present_flag"); rpcSlice->setPocMsbValPresentFlag(uiCode ? true : false); 3916 #else 3917 READ_FLAG(uiCode, "poc_msb_val_present_flag"); rpcSlice->setPocMsbValPresentFlag(uiCode ? true : false); 3918 #endif 3919 } 3920 else 3921 { 3922 #if POC_MSB_VAL_PRESENT_FLAG_SEM 3923 if( sliceHeaderExtensionLength == 0 ) 3924 { 3925 rpcSlice->setPocMsbValPresentFlag( false ); 3926 } 3927 else if( rpcSlice->getPocMsbValRequiredFlag() ) 3928 #else 3929 if( rpcSlice->getPocMsbValRequiredFlag() ) 3930 #endif 3931 { 3932 rpcSlice->setPocMsbValPresentFlag( true ); 3933 } 3934 else 3935 { 3936 rpcSlice->setPocMsbValPresentFlag( false ); 3937 } 3938 } 3939 3940 #if !POC_RESET_IDC_DECODER 3941 Int maxPocLsb = 1 << rpcSlice->getSPS()->getBitsForPOC(); 3942 #endif 3943 if( rpcSlice->getPocMsbValPresentFlag() ) 3944 { 3945 #if P0297_VPS_POC_LSB_ALIGNED_FLAG 3946 READ_UVLC( uiCode, "poc_msb_cycle_val"); rpcSlice->setPocMsbVal( uiCode ); 3947 #else 3948 READ_UVLC( uiCode, "poc_msb_val"); rpcSlice->setPocMsbVal( uiCode ); 3949 #endif 3950 3951 #if !POC_RESET_IDC_DECODER 3952 // Update POC of the slice based on this MSB val 3953 Int pocLsb = rpcSlice->getPOC() % maxPocLsb; 3954 rpcSlice->setPOC((rpcSlice->getPocMsbVal() * maxPocLsb) + pocLsb); 3955 } 3956 else 3957 { 3958 rpcSlice->setPocMsbVal( rpcSlice->getPOC() / maxPocLsb ); 3959 #endif 3960 } 3961 3962 // Read remaining bits in the slice header extension. 3963 UInt endBits = m_pcBitstream->getNumBitsRead(); 3964 Int counter = (endBits - startBits) % 8; 3965 if( counter ) 3966 { 3967 counter = 8 - counter; 3968 } 3969 3970 while( counter ) 3971 { 3972 #if Q0146_SSH_EXT_DATA_BIT 3973 READ_FLAG( uiCode, "slice_segment_header_extension_data_bit" ); 3974 #else 3975 READ_FLAG( uiCode, "slice_segment_header_extension_reserved_bit" ); assert( uiCode == 1 ); 3976 #endif 3977 counter--; 3978 } 3979 } 3980 #else 3981 if(pps->getSliceHeaderExtensionPresentFlag()) 3982 { 3983 READ_UVLC(uiCode,"slice_header_extension_length"); 3984 for(Int i=0; i<uiCode; i++) 3985 { 3986 UInt ignore; 3987 READ_CODE(8,ignore,"slice_header_extension_data_byte"); 3988 } 3989 } 3990 #endif 3991 m_pcBitstream->readByteAlignment(); 3992 3993 if( pps->getTilesEnabledFlag() || pps->getEntropyCodingSyncEnabledFlag() ) 3994 { 3995 Int endOfSliceHeaderLocation = m_pcBitstream->getByteLocation(); 3996 3997 // Adjust endOfSliceHeaderLocation to account for emulation prevention bytes in the slice segment header 3998 for ( UInt curByteIdx = 0; curByteIdx<m_pcBitstream->numEmulationPreventionBytesRead(); curByteIdx++ ) 3999 { 4000 if ( m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) < endOfSliceHeaderLocation ) 4001 { 4002 endOfSliceHeaderLocation++; 4003 } 4004 } 4005 4006 Int curEntryPointOffset = 0; 4007 Int prevEntryPointOffset = 0; 4008 for (UInt idx=0; idx<numEntryPointOffsets; idx++) 4009 { 4010 curEntryPointOffset += entryPointOffset[ idx ]; 4011 4012 Int emulationPreventionByteCount = 0; 4013 for ( UInt curByteIdx = 0; curByteIdx<m_pcBitstream->numEmulationPreventionBytesRead(); curByteIdx++ ) 4014 { 4015 if ( m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) >= ( prevEntryPointOffset + endOfSliceHeaderLocation ) && 4016 m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) < ( curEntryPointOffset + endOfSliceHeaderLocation ) ) 4017 { 4018 emulationPreventionByteCount++; 4019 } 4020 } 4021 4022 entryPointOffset[ idx ] -= emulationPreventionByteCount; 4023 prevEntryPointOffset = curEntryPointOffset; 4024 } 4025 4026 if ( pps->getTilesEnabledFlag() ) 4027 { 4028 rpcSlice->setTileLocationCount( numEntryPointOffsets ); 4029 4030 UInt prevPos = 0; 4031 for (Int idx=0; idx<rpcSlice->getTileLocationCount(); idx++) 4032 { 4033 rpcSlice->setTileLocation( idx, prevPos + entryPointOffset [ idx ] ); 4034 prevPos += entryPointOffset[ idx ]; 4035 } 4036 } 4037 else if ( pps->getEntropyCodingSyncEnabledFlag() ) 4038 { 4039 Int numSubstreams = rpcSlice->getNumEntryPointOffsets()+1; 4040 rpcSlice->allocSubstreamSizes(numSubstreams); 4041 UInt *pSubstreamSizes = rpcSlice->getSubstreamSizes(); 4042 for (Int idx=0; idx<numSubstreams-1; idx++) 4043 { 4044 if ( idx < numEntryPointOffsets ) 4045 { 4046 pSubstreamSizes[ idx ] = ( entryPointOffset[ idx ] << 3 ) ; 3209 4047 } 3210 4048 else 3211 4049 { 3212 rpcSlice->setDeblockingFilterOverrideFlag(0); 3213 } 3214 if(rpcSlice->getDeblockingFilterOverrideFlag()) 3215 { 3216 READ_FLAG ( uiCode, "slice_disable_deblocking_filter_flag" ); rpcSlice->setDeblockingFilterDisable(uiCode ? 1 : 0); 3217 if(!rpcSlice->getDeblockingFilterDisable()) 3218 { 3219 READ_SVLC( iCode, "slice_beta_offset_div2" ); rpcSlice->setDeblockingFilterBetaOffsetDiv2(iCode); 3220 assert(rpcSlice->getDeblockingFilterBetaOffsetDiv2() >= -6 && 3221 rpcSlice->getDeblockingFilterBetaOffsetDiv2() <= 6); 3222 READ_SVLC( iCode, "slice_tc_offset_div2" ); rpcSlice->setDeblockingFilterTcOffsetDiv2(iCode); 3223 assert(rpcSlice->getDeblockingFilterTcOffsetDiv2() >= -6 && 3224 rpcSlice->getDeblockingFilterTcOffsetDiv2() <= 6); 3225 } 3226 } 3227 else 3228 { 3229 rpcSlice->setDeblockingFilterDisable ( rpcSlice->getPPS()->getPicDisableDeblockingFilterFlag() ); 3230 rpcSlice->setDeblockingFilterBetaOffsetDiv2( rpcSlice->getPPS()->getDeblockingFilterBetaOffsetDiv2() ); 3231 rpcSlice->setDeblockingFilterTcOffsetDiv2 ( rpcSlice->getPPS()->getDeblockingFilterTcOffsetDiv2() ); 3232 } 3233 } 3234 else 3235 { 3236 rpcSlice->setDeblockingFilterDisable ( false ); 3237 rpcSlice->setDeblockingFilterBetaOffsetDiv2( 0 ); 3238 rpcSlice->setDeblockingFilterTcOffsetDiv2 ( 0 ); 3239 } 3240 3241 Bool isSAOEnabled = (!rpcSlice->getSPS()->getUseSAO())?(false):(rpcSlice->getSaoEnabledFlag()||rpcSlice->getSaoEnabledFlagChroma()); 3242 Bool isDBFEnabled = (!rpcSlice->getDeblockingFilterDisable()); 3243 3244 if(rpcSlice->getPPS()->getLoopFilterAcrossSlicesEnabledFlag() && ( isSAOEnabled || isDBFEnabled )) 3245 { 3246 READ_FLAG( uiCode, "slice_loop_filter_across_slices_enabled_flag"); 3247 } 3248 else 3249 { 3250 uiCode = rpcSlice->getPPS()->getLoopFilterAcrossSlicesEnabledFlag()?1:0; 3251 } 3252 rpcSlice->setLFCrossSliceBoundaryFlag( (uiCode==1)?true:false); 3253 3254 } 3255 3256 UInt *entryPointOffset = NULL; 3257 UInt numEntryPointOffsets, offsetLenMinus1; 3258 if( pps->getTilesEnabledFlag() || pps->getEntropyCodingSyncEnabledFlag() ) 3259 { 3260 READ_UVLC(numEntryPointOffsets, "num_entry_point_offsets"); rpcSlice->setNumEntryPointOffsets ( numEntryPointOffsets ); 3261 if (numEntryPointOffsets>0) 3262 { 3263 READ_UVLC(offsetLenMinus1, "offset_len_minus1"); 3264 } 3265 entryPointOffset = new UInt[numEntryPointOffsets]; 3266 for (UInt idx=0; idx<numEntryPointOffsets; idx++) 3267 { 3268 READ_CODE(offsetLenMinus1+1, uiCode, "entry_point_offset_minus1"); 3269 entryPointOffset[ idx ] = uiCode + 1; 3270 } 3271 } 3272 else 3273 { 3274 rpcSlice->setNumEntryPointOffsets ( 0 ); 3275 } 3276 3277 #if POC_RESET_IDC_SIGNALLING 3278 Int sliceHeaderExtensionLength = 0; 3279 if(pps->getSliceHeaderExtensionPresentFlag()) 3280 { 3281 READ_UVLC( uiCode, "slice_header_extension_length"); sliceHeaderExtensionLength = uiCode; 3282 } 3283 else 3284 { 3285 sliceHeaderExtensionLength = 0; 3286 } 3287 UInt startBits = m_pcBitstream->getNumBitsRead(); // Start counter of # SH Extn bits 3288 if( sliceHeaderExtensionLength > 0 ) 3289 { 3290 if( rpcSlice->getPPS()->getPocResetInfoPresentFlag() ) 3291 { 3292 READ_CODE( 2, uiCode, "poc_reset_idc"); rpcSlice->setPocResetIdc(uiCode); 3293 } 3294 else 3295 { 3296 rpcSlice->setPocResetIdc( 0 ); 3297 } 3298 #if Q0142_POC_LSB_NOT_PRESENT 3299 if ( rpcSlice->getVPS()->getPocLsbNotPresentFlag(rpcSlice->getLayerId()) && iPOClsb > 0 ) 3300 { 3301 assert( rpcSlice->getPocResetIdc() != 2 ); 3302 } 3303 #endif 3304 if( rpcSlice->getPocResetIdc() > 0 ) 3305 { 3306 READ_CODE(6, uiCode, "poc_reset_period_id"); rpcSlice->setPocResetPeriodId(uiCode); 3307 } 3308 else 3309 { 3310 3311 rpcSlice->setPocResetPeriodId( 0 ); 3312 } 3313 3314 if (rpcSlice->getPocResetIdc() == 3) 3315 { 3316 READ_FLAG( uiCode, "full_poc_reset_flag"); rpcSlice->setFullPocResetFlag((uiCode == 1) ? true : false); 3317 READ_CODE(rpcSlice->getSPS()->getBitsForPOC(), uiCode,"poc_lsb_val"); rpcSlice->setPocLsbVal(uiCode); 3318 #if Q0142_POC_LSB_NOT_PRESENT 3319 if ( rpcSlice->getVPS()->getPocLsbNotPresentFlag(rpcSlice->getLayerId()) && rpcSlice->getFullPocResetFlag() ) 3320 { 3321 assert( rpcSlice->getPocLsbVal() == 0 ); 3322 } 3323 #endif 3324 } 3325 3326 // Derive the value of PocMsbValRequiredFlag 3327 rpcSlice->setPocMsbValRequiredFlag( rpcSlice->getCraPicFlag() || rpcSlice->getBlaPicFlag() 3328 /* || related to vps_poc_lsb_aligned_flag */ 3329 ); 3330 3331 if( !rpcSlice->getPocMsbValRequiredFlag() /* vps_poc_lsb_aligned_flag */ ) 3332 { 3333 READ_FLAG( uiCode, "poc_msb_val_present_flag"); rpcSlice->setPocMsbValPresentFlag( uiCode ? true : false ); 3334 } 3335 else 3336 { 3337 #if POC_MSB_VAL_PRESENT_FLAG_SEM 3338 if( sliceHeaderExtensionLength == 0 ) 3339 { 3340 rpcSlice->setPocMsbValPresentFlag( false ); 3341 } 3342 else if( rpcSlice->getPocMsbValRequiredFlag() ) 3343 #else 3344 if( rpcSlice->getPocMsbValRequiredFlag() ) 3345 #endif 3346 { 3347 rpcSlice->setPocMsbValPresentFlag( true ); 3348 } 3349 else 3350 { 3351 rpcSlice->setPocMsbValPresentFlag( false ); 3352 } 3353 } 3354 3355 #if !POC_RESET_IDC_DECODER 3356 Int maxPocLsb = 1 << rpcSlice->getSPS()->getBitsForPOC(); 3357 #endif 3358 if( rpcSlice->getPocMsbValPresentFlag() ) 3359 { 3360 READ_UVLC( uiCode, "poc_msb_val"); rpcSlice->setPocMsbVal( uiCode ); 3361 3362 #if !POC_RESET_IDC_DECODER 3363 // Update POC of the slice based on this MSB val 3364 Int pocLsb = rpcSlice->getPOC() % maxPocLsb; 3365 rpcSlice->setPOC((rpcSlice->getPocMsbVal() * maxPocLsb) + pocLsb); 3366 } 3367 else 3368 { 3369 rpcSlice->setPocMsbVal( rpcSlice->getPOC() / maxPocLsb ); 3370 #endif 3371 } 3372 3373 // Read remaining bits in the slice header extension. 3374 UInt endBits = m_pcBitstream->getNumBitsRead(); 3375 Int counter = (endBits - startBits) % 8; 3376 if( counter ) 3377 { 3378 counter = 8 - counter; 3379 } 3380 3381 while( counter ) 3382 { 3383 #if Q0146_SSH_EXT_DATA_BIT 3384 READ_FLAG( uiCode, "slice_segment_header_extension_data_bit" ); 3385 #else 3386 READ_FLAG( uiCode, "slice_segment_header_extension_reserved_bit" ); assert( uiCode == 1 ); 3387 #endif 3388 counter--; 3389 } 3390 } 3391 #else 3392 if(pps->getSliceHeaderExtensionPresentFlag()) 3393 { 3394 READ_UVLC(uiCode,"slice_header_extension_length"); 3395 for(Int i=0; i<uiCode; i++) 3396 { 3397 UInt ignore; 3398 READ_CODE(8,ignore,"slice_header_extension_data_byte"); 3399 } 3400 } 3401 #endif 3402 m_pcBitstream->readByteAlignment(); 3403 3404 if( pps->getTilesEnabledFlag() || pps->getEntropyCodingSyncEnabledFlag() ) 3405 { 3406 Int endOfSliceHeaderLocation = m_pcBitstream->getByteLocation(); 3407 3408 // Adjust endOfSliceHeaderLocation to account for emulation prevention bytes in the slice segment header 3409 for ( UInt curByteIdx = 0; curByteIdx<m_pcBitstream->numEmulationPreventionBytesRead(); curByteIdx++ ) 3410 { 3411 if ( m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) < endOfSliceHeaderLocation ) 3412 { 3413 endOfSliceHeaderLocation++; 3414 } 3415 } 3416 3417 Int curEntryPointOffset = 0; 3418 Int prevEntryPointOffset = 0; 3419 for (UInt idx=0; idx<numEntryPointOffsets; idx++) 3420 { 3421 curEntryPointOffset += entryPointOffset[ idx ]; 3422 3423 Int emulationPreventionByteCount = 0; 3424 for ( UInt curByteIdx = 0; curByteIdx<m_pcBitstream->numEmulationPreventionBytesRead(); curByteIdx++ ) 3425 { 3426 if ( m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) >= ( prevEntryPointOffset + endOfSliceHeaderLocation ) && 3427 m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) < ( curEntryPointOffset + endOfSliceHeaderLocation ) ) 3428 { 3429 emulationPreventionByteCount++; 3430 } 3431 } 3432 3433 entryPointOffset[ idx ] -= emulationPreventionByteCount; 3434 prevEntryPointOffset = curEntryPointOffset; 3435 } 3436 3437 if ( pps->getTilesEnabledFlag() ) 3438 { 3439 rpcSlice->setTileLocationCount( numEntryPointOffsets ); 3440 3441 UInt prevPos = 0; 3442 for (Int idx=0; idx<rpcSlice->getTileLocationCount(); idx++) 3443 { 3444 rpcSlice->setTileLocation( idx, prevPos + entryPointOffset [ idx ] ); 3445 prevPos += entryPointOffset[ idx ]; 3446 } 3447 } 3448 else if ( pps->getEntropyCodingSyncEnabledFlag() ) 3449 { 3450 Int numSubstreams = rpcSlice->getNumEntryPointOffsets()+1; 3451 rpcSlice->allocSubstreamSizes(numSubstreams); 3452 UInt *pSubstreamSizes = rpcSlice->getSubstreamSizes(); 3453 for (Int idx=0; idx<numSubstreams-1; idx++) 3454 { 3455 if ( idx < numEntryPointOffsets ) 3456 { 3457 pSubstreamSizes[ idx ] = ( entryPointOffset[ idx ] << 3 ) ; 3458 } 3459 else 3460 { 3461 pSubstreamSizes[ idx ] = 0; 3462 } 3463 } 3464 } 3465 3466 if (entryPointOffset) 3467 { 3468 delete [] entryPointOffset; 3469 } 3470 } 3471 3472 return; 4050 pSubstreamSizes[ idx ] = 0; 4051 } 4052 } 4053 } 4054 4055 if (entryPointOffset) 4056 { 4057 delete [] entryPointOffset; 4058 } 4059 } 4060 4061 return; 3473 4062 } 3474 4063 … … 3733 4322 { 3734 4323 #endif 3735 wp[1].uiLog2WeightDenom = uiLog2WeightDenomChroma;3736 wp[2].uiLog2WeightDenom = uiLog2WeightDenomChroma;4324 wp[1].uiLog2WeightDenom = uiLog2WeightDenomChroma; 4325 wp[2].uiLog2WeightDenom = uiLog2WeightDenomChroma; 3737 4326 #if AUXILIARY_PICTURES 3738 4327 } … … 3913 4502 Void TDecCavlc::xParse3DAsymLUT( TCom3DAsymLUT * pc3DAsymLUT ) 3914 4503 { 4504 #if R0150_CGS_SIGNAL_CONSTRAINTS 4505 UInt uiNumRefLayersM1; 4506 READ_UVLC( uiNumRefLayersM1 , "num_cm_ref_layers_minus1" ); 4507 assert( uiNumRefLayersM1 <= 61 ); 4508 for( UInt i = 0 ; i <= uiNumRefLayersM1 ; i++ ) 4509 { 4510 UInt uiRefLayerId; 4511 READ_CODE( 6 , uiRefLayerId , "cm_ref_layer_id" ); 4512 pc3DAsymLUT->addRefLayerId( uiRefLayerId ); 4513 } 4514 #endif 3915 4515 UInt uiCurOctantDepth , uiCurPartNumLog2 , uiInputBitDepthM8 , uiOutputBitDepthM8 , uiResQaunBit; 4516 #if R0300_CGS_RES_COEFF_CODING 4517 UInt uiDeltaBits; 4518 #endif 3916 4519 READ_CODE( 2 , uiCurOctantDepth , "cm_octant_depth" ); 3917 4520 READ_CODE( 2 , uiCurPartNumLog2 , "cm_y_part_num_log2" ); 4521 #if R0150_CGS_SIGNAL_CONSTRAINTS 4522 UInt uiChromaInputBitDepthM8 , uiChromaOutputBitDepthM8; 4523 READ_UVLC( uiInputBitDepthM8 , "cm_input_luma_bit_depth_minus8" ); 4524 READ_UVLC( uiChromaInputBitDepthM8 , "cm_input_chroma_bit_depth_minus8" ); 4525 READ_UVLC( uiOutputBitDepthM8 , "cm_output_luma_bit_depth_minus8" ); 4526 READ_UVLC( uiChromaOutputBitDepthM8 , "cm_output_chroma_bit_depth_minus8" ); 4527 #else 3918 4528 READ_CODE( 3 , uiInputBitDepthM8 , "cm_input_bit_depth_minus8" ); 3919 4529 Int iInputBitDepthCDelta; … … 3922 4532 Int iOutputBitDepthCDelta; 3923 4533 READ_SVLC(iOutputBitDepthCDelta, "cm_output_bit_depth_chroma_delta"); 4534 #endif 3924 4535 READ_CODE( 2 , uiResQaunBit , "cm_res_quant_bit" ); 4536 #if R0300_CGS_RES_COEFF_CODING 4537 READ_CODE( 2 , uiDeltaBits , "cm_flc_bits" ); 4538 pc3DAsymLUT->setDeltaBits(uiDeltaBits + 1); 4539 #endif 4540 4541 #if R0151_CGS_3D_ASYMLUT_IMPROVE 4542 #if R0150_CGS_SIGNAL_CONSTRAINTS 4543 Int nAdaptCThresholdU = 1 << ( uiChromaInputBitDepthM8 + 8 - 1 ); 4544 Int nAdaptCThresholdV = 1 << ( uiChromaInputBitDepthM8 + 8 - 1 ); 4545 #else 4546 Int nAdaptCThresholdU = 1 << ( uiInputBitDepthM8 + 8 + iInputBitDepthCDelta - 1 ); 4547 Int nAdaptCThresholdV = 1 << ( uiInputBitDepthM8 + 8 + iInputBitDepthCDelta - 1 ); 4548 #endif 4549 if( uiCurOctantDepth == 1 ) 4550 { 4551 Int delta = 0; 4552 READ_SVLC( delta , "cm_adapt_threshold_u_delta" ); 4553 nAdaptCThresholdU += delta; 4554 READ_SVLC( delta , "cm_adapt_threshold_v_delta" ); 4555 nAdaptCThresholdV += delta; 4556 } 4557 #endif 3925 4558 pc3DAsymLUT->destroy(); 3926 pc3DAsymLUT->create( uiCurOctantDepth , uiInputBitDepthM8 + 8 , uiInputBitDepthM8 + 8 + iInputBitDepthCDelta, uiOutputBitDepthM8 + 8 , uiOutputBitDepthM8 + 8 + iOutputBitDepthCDelta ,uiCurPartNumLog2 ); 4559 pc3DAsymLUT->create( uiCurOctantDepth , uiInputBitDepthM8 + 8 , 4560 #if R0150_CGS_SIGNAL_CONSTRAINTS 4561 uiChromaInputBitDepthM8 + 8 , 4562 #else 4563 uiInputBitDepthM8 + 8 + iInputBitDepthCDelta, 4564 #endif 4565 uiOutputBitDepthM8 + 8 , 4566 #if R0150_CGS_SIGNAL_CONSTRAINTS 4567 uiChromaOutputBitDepthM8 + 8 , 4568 #else 4569 uiOutputBitDepthM8 + 8 + iOutputBitDepthCDelta , 4570 #endif 4571 uiCurPartNumLog2 4572 #if R0151_CGS_3D_ASYMLUT_IMPROVE 4573 , nAdaptCThresholdU , nAdaptCThresholdV 4574 #endif 4575 ); 3927 4576 pc3DAsymLUT->setResQuantBit( uiResQaunBit ); 3928 4577 4578 #if R0164_CGS_LUT_BUGFIX_CHECK 4579 pc3DAsymLUT->xInitCuboids(); 4580 #endif 3929 4581 xParse3DAsymLUTOctant( pc3DAsymLUT , 0 , 0 , 0 , 0 , 1 << pc3DAsymLUT->getCurOctantDepth() ); 4582 #if R0164_CGS_LUT_BUGFIX 4583 #if R0164_CGS_LUT_BUGFIX_CHECK 4584 printf("============= Before 'xCuboidsFilledCheck()': ================\n"); 4585 pc3DAsymLUT->display(); 4586 pc3DAsymLUT->xCuboidsFilledCheck( false ); 4587 printf("============= After 'xCuboidsFilledCheck()': =================\n"); 4588 pc3DAsymLUT->display(); 4589 #endif 4590 #endif 3930 4591 } 3931 4592 … … 3952 4613 else 3953 4614 { 4615 #if R0300_CGS_RES_COEFF_CODING 4616 Int nFLCbits = pc3DAsymLUT->getMappingShift()-pc3DAsymLUT->getResQuantBit()-pc3DAsymLUT->getDeltaBits() ; 4617 nFLCbits = nFLCbits >= 0 ? nFLCbits:0; 4618 #endif 3954 4619 for( Int l = 0 ; l < nYPartNum ; l++ ) 3955 4620 { 4621 #if R0164_CGS_LUT_BUGFIX 4622 Int shift = pc3DAsymLUT->getCurOctantDepth() - nDepth ; 4623 #endif 3956 4624 for( Int nVertexIdx = 0 ; nVertexIdx < 4 ; nVertexIdx++ ) 3957 4625 { … … 3961 4629 if( uiCodeVertex ) 3962 4630 { 4631 #if R0151_CGS_3D_ASYMLUT_IMPROVE 4632 #if R0300_CGS_RES_COEFF_CODING 4633 xReadParam( deltaY, nFLCbits ); 4634 xReadParam( deltaU, nFLCbits ); 4635 xReadParam( deltaV, nFLCbits ); 4636 #else 4637 xReadParam( deltaY ); 4638 xReadParam( deltaU ); 4639 xReadParam( deltaV ); 4640 #endif 4641 #else 3963 4642 READ_SVLC( deltaY , "resY" ); 3964 4643 READ_SVLC( deltaU , "resU" ); 3965 4644 READ_SVLC( deltaV , "resV" ); 3966 } 4645 #endif 4646 } 4647 #if R0164_CGS_LUT_BUGFIX 4648 pc3DAsymLUT->setCuboidVertexResTree( yIdx + (l<<shift) , uIdx , vIdx , nVertexIdx , deltaY , deltaU , deltaV ); 4649 for (Int m = 1; m < (1<<shift); m++) { 4650 pc3DAsymLUT->setCuboidVertexResTree( yIdx + (l<<shift) + m , uIdx , vIdx , nVertexIdx , 0 , 0 , 0 ); 4651 #if R0164_CGS_LUT_BUGFIX_CHECK 4652 pc3DAsymLUT->xSetFilled( yIdx + (l<<shift) + m , uIdx , vIdx ); 4653 #endif 4654 } 4655 #else 3967 4656 pc3DAsymLUT->setCuboidVertexResTree( yIdx + l , uIdx , vIdx , nVertexIdx , deltaY , deltaU , deltaV ); 3968 } 3969 } 3970 } 3971 } 4657 #endif 4658 } 4659 #if R0164_CGS_LUT_BUGFIX_CHECK 4660 pc3DAsymLUT->xSetExplicit( yIdx + (l<<shift) , uIdx , vIdx ); 4661 #endif 4662 } 4663 #if R0164_CGS_LUT_BUGFIX 4664 for ( Int u=0 ; u<nLength ; u++ ) { 4665 for ( Int v=0 ; v<nLength ; v++ ) { 4666 if ( u!=0 || v!=0 ) { 4667 for ( Int y=0 ; y<nLength*nYPartNum ; y++ ) { 4668 for( Int nVertexIdx = 0 ; nVertexIdx < 4 ; nVertexIdx++ ) 4669 { 4670 pc3DAsymLUT->setCuboidVertexResTree( yIdx + y , uIdx + u , vIdx + v , nVertexIdx , 0 , 0 , 0 ); 4671 #if R0164_CGS_LUT_BUGFIX_CHECK 4672 pc3DAsymLUT->xSetFilled( yIdx + y , uIdx + u , vIdx + v ); 4673 #endif 4674 } 4675 } 4676 } 4677 } 4678 } 4679 #endif 4680 } 4681 } 4682 4683 #if R0151_CGS_3D_ASYMLUT_IMPROVE 4684 #if R0300_CGS_RES_COEFF_CODING 4685 Void TDecCavlc::xReadParam( Int& param, Int rParam ) 4686 #else 4687 Void TDecCavlc::xReadParam( Int& param ) 4688 #endif 4689 { 4690 #if !R0300_CGS_RES_COEFF_CODING 4691 const UInt rParam = 7; 4692 #endif 4693 UInt prefix; 4694 UInt codeWord ; 4695 UInt rSymbol; 4696 UInt sign; 4697 4698 READ_UVLC( prefix, "quotient") ; 4699 READ_CODE (rParam, codeWord, "remainder"); 4700 rSymbol = (prefix<<rParam) + codeWord; 4701 4702 if(rSymbol) 4703 { 4704 READ_FLAG(sign, "sign"); 4705 param = sign ? -(Int)(rSymbol) : (Int)(rSymbol); 4706 } 4707 else param = 0; 4708 } 4709 #endif 4710 #if VPS_VUI_BSP_HRD_PARAMS 4711 Void TDecCavlc::parseVpsVuiBspHrdParams( TComVPS *vps ) 4712 { 4713 UInt uiCode; 4714 assert (vps->getTimingInfo()->getTimingInfoPresentFlag() == 1); 4715 READ_UVLC( uiCode, "vps_num_add_hrd_params" ); vps->setVpsNumAddHrdParams(uiCode); 4716 vps->createBspHrdParamBuffer(vps->getVpsNumAddHrdParams()); // Also allocates m_cprmsAddPresentFlag and m_numSubLayerHrdMinus 4717 4718 for( Int i = vps->getNumHrdParameters(), j = 0; i < vps->getNumHrdParameters() + vps->getVpsNumAddHrdParams(); i++, j++ ) // j = i - vps->getNumHrdParameters() 4719 { 4720 if( i > 0 ) 4721 { 4722 READ_FLAG( uiCode, "cprms_add_present_flag[i]" ); vps->setCprmsAddPresentFlag(j, uiCode ? true : false); 4723 } 4724 else 4725 { 4726 // i == 0 4727 if( vps->getNumHrdParameters() == 0 ) 4728 { 4729 vps->setCprmsAddPresentFlag(0, true); 4730 } 4731 } 4732 READ_UVLC( uiCode, "num_sub_layer_hrd_minus1[i]" ); vps->setNumSubLayerHrdMinus1(j, uiCode ); 4733 assert( uiCode <= vps->getMaxTLayers() - 1 ); 4734 4735 parseHrdParameters( vps->getBspHrd(j), vps->getCprmsAddPresentFlag(j), vps->getNumSubLayerHrdMinus1(j) ); 4736 if( i > 0 && !vps->getCprmsAddPresentFlag(i) ) 4737 { 4738 // Copy common information parameters 4739 if( i == vps->getNumHrdParameters() ) 4740 { 4741 vps->getBspHrd(j)->copyCommonInformation( vps->getHrdParameters( vps->getNumHrdParameters() - 1 ) ); 4742 } 4743 else 4744 { 4745 vps->getBspHrd(j)->copyCommonInformation( vps->getBspHrd( j - 1 ) ); 4746 } 4747 } 4748 } 4749 for (Int h = 1; h < vps->getNumOutputLayerSets(); h++) 4750 { 4751 Int lsIdx = vps->getOutputLayerSetIdx( h ); 4752 READ_UVLC( uiCode, "num_signalled_partitioning_schemes[h]"); vps->setNumSignalledPartitioningSchemes(h, uiCode); 4753 for( Int j = 0; j < vps->getNumSignalledPartitioningSchemes(h); j++ ) 4754 { 4755 READ_UVLC( uiCode, "num_partitions_in_scheme_minus1[h][j]" ); vps->setNumPartitionsInSchemeMinus1(h, j, uiCode); 4756 for( Int k = 0; k <= vps->getNumPartitionsInSchemeMinus1(h, j); k++ ) 4757 { 4758 for( Int r = 0; r < vps->getNumLayersInIdList( lsIdx ); r++ ) 4759 { 4760 READ_FLAG( uiCode, "layer_included_in_partition_flag[h][j][k][r]" ); vps->setLayerIncludedInPartitionFlag(h, j, k, r, uiCode ? true : false); 4761 } 4762 } 4763 } 4764 for( Int i = 0; i < vps->getNumSignalledPartitioningSchemes(h) + 1; i++ ) 4765 { 4766 for( Int t = 0; t <= vps->getMaxSLayersInLayerSetMinus1(lsIdx); t++ ) 4767 { 4768 READ_UVLC( uiCode, "num_bsp_schedules_minus1[h][i][t]"); vps->setNumBspSchedulesMinus1(h, i, t, uiCode); 4769 for( Int j = 0; j <= vps->getNumBspSchedulesMinus1(h, i, t); j++ ) 4770 { 4771 for( Int k = 0; k < vps->getNumPartitionsInSchemeMinus1(h, i); k++ ) 4772 { 4773 READ_UVLC( uiCode, "bsp_comb_hrd_idx[h][i][t][j][k]"); vps->setBspHrdIdx(h, i, t, j, k, uiCode); 4774 READ_UVLC( uiCode, "bsp_comb_sched_idx[h][i][t][j][k]"); vps->setBspSchedIdx(h, i, t, j, k, uiCode); 4775 } 4776 } 4777 } 4778 } 4779 4780 // To be done: Check each layer included in not more than one BSP in every partitioning scheme, 4781 // and other related checks associated with layers in bitstream partitions. 4782 4783 } 4784 } 4785 #endif 3972 4786 #endif 3973 4787 //! \} -
trunk/source/Lib/TLibDecoder/TDecCAVLC.h
r815 r906 86 86 Void parseVpsDpbSizeTable( TComVPS *vps ); 87 87 #endif 88 #if VPS_VUI_BSP_HRD_PARAMS 89 Void parseVpsVuiBspHrdParams( TComVPS *vps ); 90 #endif 88 91 #if SPS_DPB_PARAMS 89 92 Void parseSPS ( TComSPS* pcSPS ); // it should be removed after macro clean up … … 143 146 Void xParse3DAsymLUT( TCom3DAsymLUT * pc3DAsymLUT ); 144 147 Void xParse3DAsymLUTOctant( TCom3DAsymLUT * pc3DAsymLUT , Int nDepth , Int yIdx , Int uIdx , Int vIdx , Int nLength ); 148 #if R0151_CGS_3D_ASYMLUT_IMPROVE 149 #if R0300_CGS_RES_COEFF_CODING 150 Void xReadParam( Int& param, Int flc_bits ); 151 #else 152 Void xReadParam( Int& param ); 153 #endif 154 #endif 145 155 #endif 146 156 }; -
trunk/source/Lib/TLibDecoder/TDecGop.cpp
r713 r906 54 54 //! \{ 55 55 static void calcAndPrintHashStatus(TComPicYuv& pic, const SEIDecodedPictureHash* pictureHashSEI); 56 #if Q0074_COLOUR_REMAPPING_SEI 57 static Void applyColourRemapping(TComPicYuv& pic, const SEIColourRemappingInfo* colourRemappingInfoSEI, UInt layerId=0 ); 58 static std::vector<SEIColourRemappingInfo> storeCriSEI; //Persistent Colour Remapping Information SEI 59 #endif 56 60 // ==================================================================================================================== 57 61 // Constructor / destructor / initialization / destroy … … 218 222 if( pcSlice->getRefPic(RefPicList(iRefList), iRefIndex)->isILR( m_layerId ) ) 219 223 { 220 printf( "%d(%d)", pcSlice->getRefPOC(RefPicList(iRefList), iRefIndex), pcSlice->getRefPic(RefPicList(iRefList), iRefIndex)->getLayerId() ); 224 UInt refLayerId = pcSlice->getRefPic(RefPicList(iRefList), iRefIndex)->getLayerId(); 225 UInt refLayerIdc = pcSlice->getReferenceLayerIdc(refLayerId); 226 assert( g_posScalingFactor[refLayerIdc][0] ); 227 assert( g_posScalingFactor[refLayerIdc][1] ); 228 229 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] ); 221 230 } 222 231 else … … 247 256 calcAndPrintHashStatus(*rpcPic->getPicYuvRec(), hash); 248 257 } 258 #if Q0074_COLOUR_REMAPPING_SEI 259 if (m_colourRemapSEIEnabled) 260 { 261 SEIMessages colourRemappingInfo = getSeisByType(rpcPic->getSEIs(), SEI::COLOUR_REMAPPING_INFO ); 262 const SEIColourRemappingInfo *seiColourRemappingInfo = ( colourRemappingInfo.size() > 0 ) ? (SEIColourRemappingInfo*) *(colourRemappingInfo.begin()) : NULL; 263 if (colourRemappingInfo.size() > 1) 264 { 265 printf ("Warning: Got multiple Colour Remapping Information SEI messages. Using first."); 266 } 267 applyColourRemapping(*rpcPic->getPicYuvRec(), seiColourRemappingInfo 268 #if SVC_EXTENSION 269 , rpcPic->getLayerId() 270 #endif 271 ); 272 } 273 #endif 249 274 250 275 #if SETTING_PIC_OUTPUT_MARK … … 334 359 } 335 360 } 361 362 #if Q0074_COLOUR_REMAPPING_SEI 363 Void xInitColourRemappingLut( const Int bitDepthY, const Int bitDepthC, std::vector<Int>(&preLut)[3], std::vector<Int>(&postLut)[3], const SEIColourRemappingInfo* const pCriSEI ) 364 { 365 for ( Int c=0 ; c<3 ; c++ ) 366 { 367 Int bitDepth = c ? bitDepthC : bitDepthY ; 368 preLut[c].resize(1 << bitDepth); 369 postLut[c].resize(1 << pCriSEI->m_colourRemapBitDepth); 370 371 Int bitDepthDiff = pCriSEI->m_colourRemapBitDepth - bitDepth; 372 Int iShift1 = (bitDepthDiff>0) ? bitDepthDiff : 0; //bit scale from bitdepth to ColourRemapBitdepth (manage only case colourRemapBitDepth>= bitdepth) 373 if( bitDepthDiff<0 ) 374 printf ("Warning: CRI SEI - colourRemapBitDepth (%d) <bitDepth (%d) - case not handled\n", pCriSEI->m_colourRemapBitDepth, bitDepth); 375 bitDepthDiff = pCriSEI->m_colourRemapBitDepth - pCriSEI->m_colourRemapInputBitDepth; 376 Int iShift2 = (bitDepthDiff>0) ? bitDepthDiff : 0; //bit scale from ColourRemapInputBitdepth to ColourRemapBitdepth (manage only case colourRemapBitDepth>= colourRemapInputBitDepth) 377 if( bitDepthDiff<0 ) 378 printf ("Warning: CRI SEI - colourRemapBitDepth (%d) <colourRemapInputBitDepth (%d) - case not handled\n", pCriSEI->m_colourRemapBitDepth, pCriSEI->m_colourRemapInputBitDepth); 379 380 //Fill preLut 381 for ( Int k=0 ; k<(1<<bitDepth) ; k++ ) 382 { 383 Int iSample = k << iShift1 ; 384 for ( Int iPivot=0 ; iPivot<=pCriSEI->m_preLutNumValMinus1[c] ; iPivot++ ) 385 { 386 Int iCodedPrev = pCriSEI->m_preLutCodedValue[c][iPivot] << iShift2; //Coded in CRInputBitdepth 387 Int iCodedNext = pCriSEI->m_preLutCodedValue[c][iPivot+1] << iShift2; //Coded in CRInputBitdepth 388 Int iTargetPrev = pCriSEI->m_preLutTargetValue[c][iPivot]; //Coded in CRBitdepth 389 Int iTargetNext = pCriSEI->m_preLutTargetValue[c][iPivot+1]; //Coded in CRBitdepth 390 if ( iCodedPrev <= iSample && iSample <= iCodedNext ) 391 { 392 Float fInterpol = (Float)( (iCodedNext - iSample)*iTargetPrev + (iSample - iCodedPrev)*iTargetNext ) * 1.f / (Float)(iCodedNext - iCodedPrev); 393 preLut[c][k] = (Int)( 0.5f + fInterpol ); 394 iPivot = pCriSEI->m_preLutNumValMinus1[c] + 1; 395 } 396 } 397 } 398 399 //Fill postLut 400 for ( Int k=0 ; k<(1<<pCriSEI->m_colourRemapBitDepth) ; k++ ) 401 { 402 Int iSample = k; 403 for ( Int iPivot=0 ; iPivot<=pCriSEI->m_postLutNumValMinus1[c] ; iPivot++ ) 404 { 405 Int iCodedPrev = pCriSEI->m_postLutCodedValue[c][iPivot]; //Coded in CRBitdepth 406 Int iCodedNext = pCriSEI->m_postLutCodedValue[c][iPivot+1]; //Coded in CRBitdepth 407 Int iTargetPrev = pCriSEI->m_postLutTargetValue[c][iPivot]; //Coded in CRBitdepth 408 Int iTargetNext = pCriSEI->m_postLutTargetValue[c][iPivot+1]; //Coded in CRBitdepth 409 if ( iCodedPrev <= iSample && iSample <= iCodedNext ) 410 { 411 Float fInterpol = (Float)( (iCodedNext - iSample)*iTargetPrev + (iSample - iCodedPrev)*iTargetNext ) * 1.f / (Float)(iCodedNext - iCodedPrev) ; 412 postLut[c][k] = (Int)( 0.5f + fInterpol ); 413 iPivot = pCriSEI->m_postLutNumValMinus1[c] + 1; 414 } 415 } 416 } 417 } 418 } 419 420 static void applyColourRemapping(TComPicYuv& pic, const SEIColourRemappingInfo* pCriSEI, UInt layerId ) 421 { 422 if( !storeCriSEI.size() ) 423 #if SVC_EXTENSION 424 storeCriSEI.resize(MAX_LAYERS); 425 #else 426 storeCriSEI.resize(1); 427 #endif 428 429 if ( pCriSEI ) //if a CRI SEI has just been retrieved, keep it in memory (persistence management) 430 storeCriSEI[layerId] = *pCriSEI; 431 432 if( !storeCriSEI[layerId].m_colourRemapCancelFlag ) 433 { 434 Int iHeight = pic.getHeight(); 435 Int iWidth = pic.getWidth(); 436 Int iStride = pic.getStride(); 437 Int iCStride = pic.getCStride(); 438 439 Pel *YUVIn[3], *YUVOut[3]; 440 YUVIn[0] = pic.getLumaAddr(); 441 YUVIn[1] = pic.getCbAddr(); 442 YUVIn[2] = pic.getCrAddr(); 443 444 TComPicYuv picColourRemapped; 445 #if SVC_EXTENSION 446 #if AUXILIARY_PICTURES 447 picColourRemapped.create( pic.getWidth(), pic.getHeight(), pic.getChromaFormat(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, NULL ); 448 #else 449 picColourRemapped.create( pic.getWidth(), pic.getHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, NULL ); 450 #endif 451 #else 452 picColourRemapped.create( pic.getWidth(), pic.getHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth ); 453 #endif 454 YUVOut[0] = picColourRemapped.getLumaAddr(); 455 YUVOut[1] = picColourRemapped.getCbAddr(); 456 YUVOut[2] = picColourRemapped.getCrAddr(); 457 458 #if SVC_EXTENSION 459 Int bitDepthY = g_bitDepthYLayer[layerId]; 460 Int bitDepthC = g_bitDepthCLayer[layerId]; 461 462 assert( g_bitDepthY == bitDepthY ); 463 assert( g_bitDepthC == bitDepthC ); 464 #else 465 Int bitDepthY = g_bitDepthY; 466 Int bitDepthC = g_bitDepthC; 467 #endif 468 469 std::vector<Int> preLut[3]; 470 std::vector<Int> postLut[3]; 471 xInitColourRemappingLut( bitDepthY, bitDepthC, preLut, postLut, &storeCriSEI[layerId] ); 472 473 Int roundingOffset = (storeCriSEI[layerId].m_log2MatrixDenom==0) ? 0 : (1 << (storeCriSEI[layerId].m_log2MatrixDenom - 1)); 474 475 for( Int y = 0; y < iHeight ; y++ ) 476 { 477 for( Int x = 0; x < iWidth ; x++ ) 478 { 479 Int YUVPre[3], YUVMat[3]; 480 YUVPre[0] = preLut[0][ YUVIn[0][x] ]; 481 YUVPre[1] = preLut[1][ YUVIn[1][x>>1] ]; 482 YUVPre[2] = preLut[2][ YUVIn[2][x>>1] ]; 483 484 YUVMat[0] = ( storeCriSEI[layerId].m_colourRemapCoeffs[0][0]*YUVPre[0] 485 + storeCriSEI[layerId].m_colourRemapCoeffs[0][1]*YUVPre[1] 486 + storeCriSEI[layerId].m_colourRemapCoeffs[0][2]*YUVPre[2] 487 + roundingOffset ) >> ( storeCriSEI[layerId].m_log2MatrixDenom ); 488 YUVMat[0] = Clip3( 0, (1<<storeCriSEI[layerId].m_colourRemapBitDepth)-1, YUVMat[0] ); 489 YUVOut[0][x] = postLut[0][ YUVMat[0] ]; 490 491 if( (y&1) && (x&1) ) 492 { 493 for(Int c=1 ; c<3 ; c++) 494 { 495 YUVMat[c] = ( storeCriSEI[layerId].m_colourRemapCoeffs[c][0]*YUVPre[0] 496 + storeCriSEI[layerId].m_colourRemapCoeffs[c][1]*YUVPre[1] 497 + storeCriSEI[layerId].m_colourRemapCoeffs[c][2]*YUVPre[2] 498 + roundingOffset ) >> ( storeCriSEI[layerId].m_log2MatrixDenom ); 499 YUVMat[c] = Clip3( 0, (1<<storeCriSEI[layerId].m_colourRemapBitDepth)-1, YUVMat[c] ); 500 YUVOut[c][x>>1] = postLut[c][ YUVMat[c] ]; 501 } 502 } 503 } 504 YUVIn[0] += iStride; 505 YUVOut[0] += iStride; 506 if( y&1 ) 507 { 508 YUVIn[1] += iCStride; 509 YUVIn[2] += iCStride; 510 YUVOut[1] += iCStride; 511 YUVOut[2] += iCStride; 512 } 513 } 514 515 //Write remapped picture in decoding order 516 Char cTemp[255]; 517 sprintf(cTemp, "seiColourRemappedPic_L%d_%dx%d_%dbits.yuv", layerId, iWidth, iHeight, storeCriSEI[layerId].m_colourRemapBitDepth ); 518 picColourRemapped.dump( cTemp, true, storeCriSEI[layerId].m_colourRemapBitDepth ); 519 520 picColourRemapped.destroy(); 521 522 storeCriSEI[layerId].m_colourRemapCancelFlag = !storeCriSEI[layerId].m_colourRemapPersistenceFlag; //Handling persistence 523 } 524 } 525 #endif 336 526 //! \} -
trunk/source/Lib/TLibDecoder/TDecGop.h
r595 r906 82 82 Double m_dDecTime; 83 83 Int m_decodedPictureHashSEIEnabled; ///< Checksum(3)/CRC(2)/MD5(1)/disable(0) acting on decoded picture hash SEI message 84 84 #if Q0074_COLOUR_REMAPPING_SEI 85 Bool m_colourRemapSEIEnabled; ///< Enable/disable Colour Remapping Information SEI message acting on decoded pictures 86 #endif 85 87 #if SVC_EXTENSION 86 88 UInt m_layerId; … … 114 116 115 117 void setDecodedPictureHashSEIEnabled(Int enabled) { m_decodedPictureHashSEIEnabled = enabled; } 118 #if Q0074_COLOUR_REMAPPING_SEI 119 void setColourRemappingInfoSEIEnabled(Int enabled) { m_colourRemapSEIEnabled = enabled; } 120 #endif 116 121 #if SVC_EXTENSION 117 122 TDecTop* getLayerDec(UInt LayerId) { return m_ppcTDecTop[LayerId]; } -
trunk/source/Lib/TLibDecoder/TDecSlice.cpp
r644 r906 42 42 43 43 #if SVC_EXTENSION 44 ParameterSetMap<TComVPS> ParameterSetManagerDecoder::m_vpsBuffer(MAX_NUM_VPS); 44 ParameterSetMap<TComVPS> ParameterSetManagerDecoder::m_vpsBuffer(MAX_NUM_VPS); 45 ParameterSetMap<TComSPS> ParameterSetManagerDecoder::m_spsBuffer(MAX_NUM_SPS); 46 ParameterSetMap<TComPPS> ParameterSetManagerDecoder::m_ppsBuffer(MAX_NUM_PPS); 45 47 #endif 46 48 … … 144 146 UInt uiTilesAcross = rpcPic->getPicSym()->getNumColumnsMinus1()+1; 145 147 TComSlice* pcSlice = rpcPic->getSlice(rpcPic->getCurrSliceIdx()); 148 #if !WPP_FIX 146 149 Int iNumSubstreams = pcSlice->getPPS()->getNumSubstreams(); 150 #endif 147 151 148 152 // delete decoders if already allocated in previous slice … … 191 195 UInt uiWidthInLCUs = rpcPic->getPicSym()->getFrameWidthInCU(); 192 196 //UInt uiHeightInLCUs = rpcPic->getPicSym()->getFrameHeightInCU(); 197 198 #if WPP_FIX 199 UInt uiTileCol; 200 UInt uiTileLCUX; 201 const Bool depSliceSegmentsEnabled = rpcPic->getSlice(rpcPic->getCurrSliceIdx())->getPPS()->getDependentSliceSegmentsEnabledFlag(); 202 const UInt startTileIdx=rpcPic->getPicSym()->getTileIdxMap(iStartCUAddr); 203 TComTile *pCurrentTile=rpcPic->getPicSym()->getTComTile(startTileIdx); 204 UInt uiTileStartLCU = pCurrentTile->getFirstCUAddr(); // Code tidy 205 206 // The first LCU of the slice is the first coded substream, but the global substream number, as calculated by getSubstreamForLCUAddr may be higher. 207 // This calculates the common offset for all substreams in this slice. 208 const UInt subStreamOffset=rpcPic->getSubstreamForLCUAddr(iStartCUAddr, true, pcSlice); 209 #else 193 210 UInt uiCol=0, uiLin=0, uiSubStrm=0; 194 211 … … 199 216 Bool depSliceSegmentsEnabled = rpcPic->getSlice(rpcPic->getCurrSliceIdx())->getPPS()->getDependentSliceSegmentsEnabledFlag(); 200 217 uiTileStartLCU = rpcPic->getPicSym()->getTComTile(rpcPic->getPicSym()->getTileIdxMap(iStartCUAddr))->getFirstCUAddr(); 218 #endif 201 219 if( depSliceSegmentsEnabled ) 202 220 { 221 #if WPP_FIX 222 if( (!rpcPic->getSlice(rpcPic->getCurrSliceIdx())->isNextSlice()) && iStartCUAddr != uiTileStartLCU) // Code tidy // Is this a dependent slice segment and not the start of a tile? 223 #else 203 224 if( (!rpcPic->getSlice(rpcPic->getCurrSliceIdx())->isNextSlice()) && 204 225 iStartCUAddr != rpcPic->getPicSym()->getTComTile(rpcPic->getPicSym()->getTileIdxMap(iStartCUAddr))->getFirstCUAddr()) 226 #endif 205 227 { 206 228 if(pcSlice->getPPS()->getEntropyCodingSyncEnabledFlag()) 207 229 { 230 #if WPP_FIX 231 uiTileCol = startTileIdx % (rpcPic->getPicSym()->getNumColumnsMinus1()+1); // Code tidy 232 #else 208 233 uiTileCol = rpcPic->getPicSym()->getTileIdxMap(iStartCUAddr) % (rpcPic->getPicSym()->getNumColumnsMinus1()+1); 234 #endif 209 235 m_pcBufferSbacDecoders[uiTileCol].loadContexts( CTXMem[1] );//2.LCU 236 #if WPP_FIX 237 if ( pCurrentTile->getTileWidth() < 2) 238 { 239 CTXMem[0]->loadContexts(pcSbacDecoder); // If tile width is less than 2, need to ensure CTX states get initialised to un-adapted CABAC. Set here, to load a few lines later (!) 240 } 241 #else 210 242 if ( (iStartCUAddr%uiWidthInLCUs+1) >= uiWidthInLCUs ) 211 243 { … … 217 249 } 218 250 } 251 #endif 219 252 } 220 253 pcSbacDecoder->loadContexts(CTXMem[0] ); //end of depSlice-1 254 #if WPP_FIX 255 pcSbacDecoders[0].loadContexts(pcSbacDecoder); // The first substream used for the slice will always be 0. (The original code was equivalent) 256 #else 221 257 pcSbacDecoders[uiSubStrm].loadContexts(pcSbacDecoder); 258 #endif 222 259 } 223 260 else … … 237 274 uiTileStartLCU = rpcPic->getPicSym()->getTComTile(rpcPic->getPicSym()->getTileIdxMap(iCUAddr))->getFirstCUAddr(); 238 275 uiTileLCUX = uiTileStartLCU % uiWidthInLCUs; 276 #if WPP_FIX 277 UInt uiCol = iCUAddr % uiWidthInLCUs; 278 UInt uiSubStrm=rpcPic->getSubstreamForLCUAddr(iCUAddr, true, pcSlice)-subStreamOffset; 279 #else 239 280 uiCol = iCUAddr % uiWidthInLCUs; 240 281 // The 'line' is now relative to the 1st line in the slice, not the 1st line in the picture. 241 282 uiLin = (iCUAddr/uiWidthInLCUs)-(iStartCUAddr/uiWidthInLCUs); 283 #endif 242 284 // inherit from TR if necessary, select substream to use. 243 285 if( (pcSlice->getPPS()->getNumSubstreams() > 1) || ( depSliceSegmentsEnabled && (uiCol == uiTileLCUX)&&(pcSlice->getPPS()->getEntropyCodingSyncEnabledFlag()) )) 244 286 { 287 #if !WPP_FIX 245 288 // independent tiles => substreams are "per tile". iNumSubstreams has already been multiplied. 246 289 iNumSubstreamsPerTile = iNumSubstreams/rpcPic->getPicSym()->getNumTiles(); 247 290 uiSubStrm = rpcPic->getPicSym()->getTileIdxMap(iCUAddr)*iNumSubstreamsPerTile 248 291 + uiLin%iNumSubstreamsPerTile; 292 #endif 249 293 m_pcEntropyDecoder->setBitstream( ppcSubstreams[uiSubStrm] ); 250 294 // Synchronize cabac probabilities with upper-right LCU if it's available and we're at the start of a line. … … 278 322 pcSbacDecoder->load(&pcSbacDecoders[uiSubStrm]); //this load is used to simplify the code (avoid to change all the call to pcSbacDecoders) 279 323 } 324 #if !WPP_FIX 280 325 else if ( pcSlice->getPPS()->getNumSubstreams() <= 1 ) 281 326 { … … 283 328 iNumSubstreamsPerTile = 1; 284 329 } 330 #endif 285 331 286 332 if ( (iCUAddr == rpcPic->getPicSym()->getTComTile(rpcPic->getPicSym()->getTileIdxMap(iCUAddr))->getFirstCUAddr()) && // 1st in tile. … … 397 443 398 444 ParameterSetManagerDecoder::ParameterSetManagerDecoder() 399 #if SVC_EXTENSION 400 : m_spsBuffer(MAX_NUM_SPS) 401 , m_ppsBuffer(MAX_NUM_PPS) 402 #else 445 #if !SVC_EXTENSION 403 446 : m_vpsBuffer(MAX_NUM_VPS) 404 447 , m_spsBuffer(MAX_NUM_SPS) -
trunk/source/Lib/TLibDecoder/TDecSlice.h
r644 r906 110 110 #if SVC_EXTENSION 111 111 static ParameterSetMap<TComVPS> m_vpsBuffer; 112 static ParameterSetMap<TComSPS> m_spsBuffer; 113 static ParameterSetMap<TComPPS> m_ppsBuffer; 112 114 #else 113 115 ParameterSetMap<TComVPS> m_vpsBuffer; 114 #endif115 116 ParameterSetMap<TComSPS> m_spsBuffer; 116 117 ParameterSetMap<TComPPS> m_ppsBuffer; 118 #endif 117 119 }; 118 120 -
trunk/source/Lib/TLibDecoder/TDecTop.cpp
r815 r906 43 43 UInt TDecTop::m_uiPrevLayerId = MAX_UINT; 44 44 Bool TDecTop::m_bFirstSliceInSequence = true; 45 #if POC_RESET_RESTRICTIONS 46 Bool TDecTop::m_checkPocRestrictionsForCurrAu = false; 47 Int TDecTop::m_pocResetIdcOrCurrAu = -1; 48 Bool TDecTop::m_baseLayerIdrFlag = false; 49 Bool TDecTop::m_baseLayerPicPresentFlag = false; 50 Bool TDecTop::m_baseLayerIrapFlag = false; 51 Bool TDecTop::m_nonBaseIdrPresentFlag = false; 52 Int TDecTop::m_nonBaseIdrType = -1; 53 Bool TDecTop::m_picNonIdrWithRadlPresentFlag = false; 54 Bool TDecTop::m_picNonIdrNoLpPresentFlag = false; 55 #endif 56 #if POC_RESET_VALUE_RESTRICTION 57 Int TDecTop::m_crossLayerPocResetPeriodId = -1; 58 Int TDecTop::m_crossLayerPocResetIdc = -1; 59 #endif 45 60 #endif 46 61 … … 74 89 memset(m_cIlpPic, 0, sizeof(m_cIlpPic)); 75 90 #endif 76 #if AVC_SYNTAX || SYNTAX_OUTPUT77 m_pBLSyntaxFile = NULL;78 #endif79 91 m_prevSliceSkipped = false; 80 92 m_skippedPOC = 0; … … 105 117 #endif 106 118 107 #if Q0074_SEI_COLOR_MAPPING 108 m_ColorMapping = new TDecColorMapping(); 119 #if POC_RESET_RESTRICTIONS 120 resetPocRestrictionCheckParameters(); 121 #endif 122 #if P0297_VPS_POC_LSB_ALIGNED_FLAG 123 m_pocResettingFlag = false; 124 m_pocDecrementedInDPBFlag = false; 109 125 #endif 110 126 } … … 112 128 TDecTop::~TDecTop() 113 129 { 114 #if Q0078_ADD_LAYER_SETS115 for (Int psId = 0; psId < MAX_NUM_SPS; psId++)116 {117 TComSPS* sps = m_parameterSetManagerDecoder.getSPS(psId);118 if (sps != NULL)119 {120 // Remove parameter set from other layers to prevent multiple deletes of the same object121 for (Int lId = 0; lId < m_numLayer; lId++)122 {123 if (m_ppcTDecTop[lId] != this)124 {125 m_parameterSetManagerDecoder.removeSPS(psId);126 }127 }128 }129 }130 for (Int psId = 0; psId < MAX_NUM_PPS; psId++)131 {132 TComPPS* pps = m_parameterSetManagerDecoder.getPPS(psId);133 if (pps != NULL)134 {135 // Remove parameter set from other layers to prevent multiple deletes of the same object136 for (Int lId = 0; lId < m_numLayer; lId++)137 {138 if (m_ppcTDecTop[lId] != this)139 {140 m_parameterSetManagerDecoder.removePPS(psId);141 }142 }143 }144 }145 #endif146 130 #if ENC_DEC_TRACE 147 131 fclose( g_hTrace ); … … 154 138 m_pColorMappedPic = NULL; 155 139 } 156 #endif157 #if Q0074_SEI_COLOR_MAPPING158 if ( m_ColorMapping ) delete m_ColorMapping;159 140 #endif 160 141 } … … 188 169 m_cIlpPic[i] = NULL; 189 170 } 190 } 171 } 191 172 #endif 192 173 } … … 237 218 238 219 Int numReorderPics[MAX_TLAYER]; 220 #if R0156_CONF_WINDOW_IN_REP_FORMAT 221 Window &conformanceWindow = slice->getConformanceWindow(); 222 #else 239 223 Window &conformanceWindow = pcSPS->getConformanceWindow(); 224 #endif 240 225 Window defaultDisplayWindow = pcSPS->getVuiParametersPresentFlag() ? pcSPS->getVuiParameters()->getDefaultDisplayWindow() : Window(); 241 226 … … 326 311 { 327 312 Int numReorderPics[MAX_TLAYER]; 313 #if R0156_CONF_WINDOW_IN_REP_FORMAT 314 Window &conformanceWindow = pcSlice->getConformanceWindow(); 315 #else 328 316 Window &conformanceWindow = pcSlice->getSPS()->getConformanceWindow(); 317 #endif 329 318 Window defaultDisplayWindow = pcSlice->getSPS()->getVuiParametersPresentFlag() ? pcSlice->getSPS()->getVuiParameters()->getDefaultDisplayWindow() : Window(); 330 319 … … 362 351 #else 363 352 m_iMaxRefPicNum = pcSlice->getVPS()->getMaxVpsDecPicBufferingMinus1( getCommonDecoderParams()->getTargetOutputLayerSetIdx(), pcSlice->getLayerId(), pcSlice->getTLayer() ) + 1; // m_uiMaxDecPicBuffering has the space for the picture currently being decoded 353 //TODO: HENDRY -- Do the checking here. 364 354 #endif 365 355 } … … 381 371 for(UInt i = 0; i < pcSlice->getVPS()->getNumDirectRefLayers( m_layerId ); i++ ) 382 372 { 373 #if MOVE_SCALED_OFFSET_TO_PPS 374 #if O0098_SCALED_REF_LAYER_ID 375 const Window scalEL = pcSlice->getPPS()->getScaledRefLayerWindowForLayer(pcSlice->getVPS()->getRefLayerId(m_layerId, i)); 376 #else 377 const Window scalEL = pcSlice->getPPS()->getScaledRefLayerWindow(i); 378 #endif 379 #else 383 380 #if O0098_SCALED_REF_LAYER_ID 384 381 const Window scalEL = pcSlice->getSPS()->getScaledRefLayerWindowForLayer(pcSlice->getVPS()->getRefLayerId(m_layerId, i)); … … 386 383 const Window scalEL = pcSlice->getSPS()->getScaledRefLayerWindow(i); 387 384 #endif 385 #endif 386 #if REF_REGION_OFFSET 387 const Window refEL = pcSlice->getPPS()->getRefLayerWindowForLayer(pcSlice->getVPS()->getRefLayerId(m_layerId, i)); 388 #if RESAMPLING_FIX 389 Bool equalOffsets = scalEL.hasEqualOffset(refEL); 390 #if R0209_GENERIC_PHASE 391 Bool zeroPhase = pcSlice->getPPS()->hasZeroResamplingPhase(pcSlice->getVPS()->getRefLayerId(m_layerId, i)); 392 #endif 393 #else 394 Bool zeroOffsets = ( scalEL.getWindowLeftOffset() == 0 && scalEL.getWindowRightOffset() == 0 && scalEL.getWindowTopOffset() == 0 && scalEL.getWindowBottomOffset() == 0 395 && refEL.getWindowLeftOffset() == 0 && refEL.getWindowRightOffset() == 0 && refEL.getWindowTopOffset() == 0 && refEL.getWindowBottomOffset() == 0 ); 396 #endif 397 #else 388 398 Bool zeroOffsets = ( scalEL.getWindowLeftOffset() == 0 && scalEL.getWindowRightOffset() == 0 && scalEL.getWindowTopOffset() == 0 && scalEL.getWindowBottomOffset() == 0 ); 399 #endif 389 400 390 401 #if VPS_EXTN_DIRECT_REF_LAYERS … … 400 411 Bool sameBitDepths = ( g_bitDepthYLayer[m_layerId] == g_bitDepthYLayer[refLayerId] ) && ( g_bitDepthCLayer[m_layerId] == g_bitDepthCLayer[refLayerId] ); 401 412 402 if( pcPicYuvRecBase->getWidth() != pcSlice->getPicWidthInLumaSamples() || pcPicYuvRecBase->getHeight() != pcSlice->getPicHeightInLumaSamples() || !zeroOffsets || !sameBitDepths 413 #if REF_IDX_MFM 414 if( pcPicYuvRecBase->getWidth() == pcSlice->getPicWidthInLumaSamples() && pcPicYuvRecBase->getHeight() == pcSlice->getPicHeightInLumaSamples() && equalOffsets && zeroPhase ) 415 { 416 rpcPic->setEqualPictureSizeAndOffsetFlag( i, true ); 417 } 418 419 if( !rpcPic->equalPictureSizeAndOffsetFlag(i) || !sameBitDepths 420 #else 421 if( pcPicYuvRecBase->getWidth() != pcSlice->getPicWidthInLumaSamples() || pcPicYuvRecBase->getHeight() != pcSlice->getPicHeightInLumaSamples() || !sameBitDepths 422 #if REF_REGION_OFFSET && RESAMPLING_FIX 423 || !equalOffsets 424 #if R0209_GENERIC_PHASE 425 || !zeroPhase 426 #endif 427 #else 428 || !zeroOffsets 429 #endif 430 #endif 403 431 #if Q0048_CGS_3D_ASYMLUT 404 432 || pcSlice->getPPS()->getCGSFlag() > 0 … … 409 437 ) 410 438 #else 411 if(pcPicYuvRecBase->getWidth() != pcSlice->getPicWidthInLumaSamples() || pcPicYuvRecBase->getHeight() != pcSlice->getPicHeightInLumaSamples() || !zeroOffsets ) 412 #endif 413 #else 414 if(pcPicYuvRecBase->getWidth() != pcSlice->getSPS()->getPicWidthInLumaSamples() || pcPicYuvRecBase->getHeight() != pcSlice->getSPS()->getPicHeightInLumaSamples() || !zeroOffsets ) 439 if(pcPicYuvRecBase->getWidth() != pcSlice->getPicWidthInLumaSamples() || pcPicYuvRecBase->getHeight() != pcSlice->getPicHeightInLumaSamples() 440 #if REF_REGION_OFFSET && RESAMPLING_FIX 441 || !equalOffsets 442 #if R0209_GENERIC_PHASE 443 || !zeroPhase 444 #endif 445 #else 446 || !zeroOffsets 447 #endif 448 ) 449 #endif 450 #else 451 if(pcPicYuvRecBase->getWidth() != pcSlice->getSPS()->getPicWidthInLumaSamples() || pcPicYuvRecBase->getHeight() != pcSlice->getSPS()->getPicHeightInLumaSamples() 452 #if REF_REGION_OFFSET && RESAMPLING_FIX 453 || !equalOffsets 454 #if R0209_GENERIC_PHASE 455 || !zeroPhase 456 #endif 457 #else 458 || !zeroOffsets 459 #endif 460 ) 415 461 #endif 416 462 { … … 522 568 m_cGopDecoder.filterPicture(pcPic); 523 569 524 #if SYNTAX_OUTPUT525 pcPic->wrireBLSyntax( getBLSyntaxFile(), SYNTAX_BYTES );526 #endif527 570 TComSlice::sortPicList( m_cListPic ); // sorting for application output 528 571 poc = pcPic->getSlice(m_uiSliceIdx-1)->getPOC(); … … 713 756 714 757 // When avc_base_layer_flag is equal to 1, it is a requirement of bitstream conformance that the value of sps_scaling_list_ref_layer_id shall be greater than 0 758 #if VPS_AVC_BL_FLAG_REMOVAL 759 if( activeVPS->getNonHEVCBaseLayerFlag() ) 760 #else 715 761 if( activeVPS->getAvcBaseLayerFlag() ) 762 #endif 716 763 { 717 764 assert( refLayerId > 0 ); … … 742 789 743 790 // When avc_base_layer_flag is equal to 1, it is a requirement of bitstream conformance that the value of sps_scaling_list_ref_layer_id shall be greater than 0 791 #if VPS_AVC_BL_FLAG_REMOVAL 792 if( activeVPS->getNonHEVCBaseLayerFlag() ) 793 #else 744 794 if( activeVPS->getAvcBaseLayerFlag() ) 795 #endif 745 796 { 746 797 assert( refLayerId > 0 ); … … 768 819 769 820 #if AVC_BASE 821 #if VPS_AVC_BL_FLAG_REMOVAL 822 if( activeVPS->getNonHEVCBaseLayerFlag() ) 823 #else 770 824 if( activeVPS->getAvcBaseLayerFlag() ) 825 #endif 771 826 { 772 827 TComPic* pBLPic = (*m_ppcTDecTop[0]->getListPic()->begin()); … … 777 832 778 833 Int numReorderPics[MAX_TLAYER]; 834 #if !R0156_CONF_WINDOW_IN_REP_FORMAT 779 835 Window conformanceWindow; 836 #endif 780 837 Window defaultDisplayWindow; 781 838 839 #if R0156_CONF_WINDOW_IN_REP_FORMAT 782 840 #if AUXILIARY_PICTURES 783 #if AVC_SYNTAX 784 pBLPic->create( repFormat->getPicWidthVpsInLumaSamples(), repFormat->getPicHeightVpsInLumaSamples(), repFormat->getChromaFormatVpsIdc(), activeSPS->getMaxCUWidth(), activeSPS->getMaxCUHeight(), activeSPS->getMaxCUDepth(), conformanceWindow, defaultDisplayWindow, numReorderPics, activeSPS, true); 785 #else 841 pBLPic->create( repFormat->getPicWidthVpsInLumaSamples(), repFormat->getPicHeightVpsInLumaSamples(), repFormat->getChromaFormatVpsIdc(), activeSPS->getMaxCUWidth(), activeSPS->getMaxCUHeight(), activeSPS->getMaxCUDepth(), repFormat->getConformanceWindowVps(), defaultDisplayWindow, numReorderPics, NULL, true); 842 #else 843 pBLPic->create( repFormat->getPicWidthVpsInLumaSamples(), repFormat->getPicHeightVpsInLumaSamples(), activeSPS->getMaxCUWidth(), activeSPS->getMaxCUHeight(), activeSPS->getMaxCUDepth(), repFormat->getConformanceWindowVps(), defaultDisplayWindow, numReorderPics, NULL, true); 844 #endif 845 #else 846 #if AUXILIARY_PICTURES 786 847 pBLPic->create( repFormat->getPicWidthVpsInLumaSamples(), repFormat->getPicHeightVpsInLumaSamples(), repFormat->getChromaFormatVpsIdc(), activeSPS->getMaxCUWidth(), activeSPS->getMaxCUHeight(), activeSPS->getMaxCUDepth(), conformanceWindow, defaultDisplayWindow, numReorderPics, NULL, true); 787 #endif788 #else789 #if AVC_SYNTAX790 pBLPic->create( repFormat->getPicWidthVpsInLumaSamples(), repFormat->getPicHeightVpsInLumaSamples(), activeSPS->getMaxCUWidth(), activeSPS->getMaxCUHeight(), activeSPS->getMaxCUDepth(), conformanceWindow, defaultDisplayWindow, numReorderPics, activeSPS, true);791 848 #else 792 849 pBLPic->create( repFormat->getPicWidthVpsInLumaSamples(), repFormat->getPicHeightVpsInLumaSamples(), activeSPS->getMaxCUWidth(), activeSPS->getMaxCUHeight(), activeSPS->getMaxCUDepth(), conformanceWindow, defaultDisplayWindow, numReorderPics, NULL, true); … … 805 862 806 863 #if P0312_VERT_PHASE_ADJ 864 #if MOVE_SCALED_OFFSET_TO_PPS 865 if( activeVPS->getVpsVuiVertPhaseInUseFlag() == 0 ) 866 { 867 for(Int i = 0; i < activePPS->getNumScaledRefLayerOffsets(); i++) 868 { 869 UInt scaledRefLayerId = activePPS->getScaledRefLayerId(i); 870 if( activePPS->getVertPhasePositionEnableFlag( scaledRefLayerId ) ) 871 { 872 printf("\nWarning: LayerId = %d: vert_phase_position_enable_flag[%d] = 1, however indication vert_phase_position_in_use_flag = 0\n", m_layerId, scaledRefLayerId ); 873 break; 874 } 875 } 876 } 877 #else 807 878 if( activeVPS->getVpsVuiVertPhaseInUseFlag() == 0 ) 808 879 { … … 817 888 } 818 889 } 890 #endif 819 891 #endif 820 892 … … 868 940 pps->setSPS(sps); 869 941 #if REPN_FORMAT_IN_VPS 870 pps->setNumSubstreams(pps->getEntropyCodingSyncEnabledFlag() ? ((sps->getPicHeightInLumaSamples() + sps->getMaxCUHeight() - 1) / sps->getMaxCUHeight()) * (pps->getNum ColumnsMinus1() + 1) : 1);871 #else 872 pps->setNumSubstreams(pps->getEntropyCodingSyncEnabledFlag() ? ((sps->getPicHeightInLumaSamples() + sps->getMaxCUHeight() - 1) / sps->getMaxCUHeight()) * (pps->getNum ColumnsMinus1() + 1) : 1);942 pps->setNumSubstreams(pps->getEntropyCodingSyncEnabledFlag() ? ((sps->getPicHeightInLumaSamples() + sps->getMaxCUHeight() - 1) / sps->getMaxCUHeight()) * (pps->getNumTileColumnsMinus1() + 1) : 1); 943 #else 944 pps->setNumSubstreams(pps->getEntropyCodingSyncEnabledFlag() ? ((sps->getPicHeightInLumaSamples() + sps->getMaxCUHeight() - 1) / sps->getMaxCUHeight()) * (pps->getNumTileColumnsMinus1() + 1) : 1); 873 945 #endif 874 946 pps->setMinCuDQPSize( sps->getMaxCUWidth() >> ( pps->getMaxCuDQPDepth()) ); … … 885 957 g_uiMaxCUDepth = sps->getMaxCUDepth(); 886 958 g_uiAddCUDepth = max (0, sps->getLog2MinCodingBlockSize() - (Int)sps->getQuadtreeTULog2MinSize() ); 887 888 #if Q0074_SEI_COLOR_MAPPING889 for(Int compID=0; compID<3; compID++)890 {891 m_ColorMapping->setColorMapping( compID ? g_bitDepthC : g_bitDepthY, compID );892 }893 #endif894 959 895 960 for (Int i = 0; i < sps->getLog2DiffMaxMinCodingBlockSize(); i++) … … 953 1018 954 1019 m_apcSlicePilot->setNalUnitType(nalu.m_nalUnitType); 1020 #if POC_RESET_RESTRICTIONS 1021 m_apcSlicePilot->setTLayer( nalu.m_temporalId ); 1022 #endif 955 1023 Bool nonReferenceFlag = (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_TRAIL_N || 956 1024 m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_TSA_N || … … 1018 1086 } 1019 1087 1088 //TODO: HENDRY -- Probably do the checking for max number of positive and negative pics here 1089 1090 1020 1091 //For inference of PicOutputFlag 1021 1092 if (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_N || m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_RASL_R) … … 1109 1180 } 1110 1181 #endif 1182 1111 1183 #if POC_RESET_IDC_DECODER 1112 1184 if( m_parseIdc != -1 ) // Second pass for a POC resetting picture … … 1129 1201 if(( m_layerId < m_uiPrevLayerId) ||( ( m_layerId == m_uiPrevLayerId) && bNewPOC)) // Decoding a lower layer than or same layer as previous - mark all earlier pictures as not in current AU 1130 1202 { 1203 #if POC_RESET_RESTRICTIONS 1204 // New access unit; reset all variables related to POC reset restrictions 1205 resetPocRestrictionCheckParameters(); 1206 #endif 1131 1207 markAllPicsAsNoCurrAu(); 1132 } 1208 #if P0297_VPS_POC_LSB_ALIGNED_FLAG 1209 for (UInt i = 0; i < MAX_LAYERS; i++) 1210 { 1211 m_ppcTDecTop[i]->m_pocDecrementedInDPBFlag = false; 1212 } 1213 #endif 1214 } 1215 1216 1217 #if P0297_VPS_POC_LSB_ALIGNED_FLAG 1218 m_pocResettingFlag = false; 1219 1220 if (m_apcSlicePilot->getPocResetIdc() != 0) 1221 { 1222 if (m_apcSlicePilot->getVPS()->getVpsPocLsbAlignedFlag()) 1223 { 1224 m_pocResettingFlag = true; 1225 } 1226 else if (m_pocDecrementedInDPBFlag) 1227 { 1228 m_pocResettingFlag = false; 1229 } 1230 else 1231 { 1232 m_pocResettingFlag = true; 1233 } 1234 } 1235 #endif 1133 1236 1134 1237 if( m_apcSlicePilot->getPocResetIdc() && m_apcSlicePilot->getSliceIdx() == 0 ) … … 1141 1244 m_parseIdc = 0; 1142 1245 } 1246 #if POC_RESET_VALUE_RESTRICTION 1247 // Check if the POC Reset period ID matches with the Reset Period ID 1248 if( pocResetPeriodId == m_crossLayerPocResetPeriodId ) 1249 { 1250 // If matching, and current poc_reset_idc = 3, then the values should match 1251 if( m_apcSlicePilot->getPocResetIdc() == 3 ) 1252 { 1253 assert( ( m_apcSlicePilot->getFullPocResetFlag() == false && m_crossLayerPocResetIdc == 1 ) || 1254 ( m_apcSlicePilot->getFullPocResetFlag() == true && m_crossLayerPocResetIdc == 2 ) ); 1255 } 1256 } 1257 else 1258 { 1259 // This is the first picture of a POC resetting access unit 1260 m_crossLayerPocResetPeriodId = pocResetPeriodId; 1261 if( m_apcSlicePilot->getPocResetIdc() == 1 || m_apcSlicePilot->getPocResetIdc() == 2 ) 1262 { 1263 m_crossLayerPocResetIdc = m_apcSlicePilot->getPocResetIdc(); 1264 } 1265 else 1266 { // poc_reset_idc = 3 1267 // In this case, the entire POC resetting access unit has been lost. 1268 // Need more checking to ensure poc_reset_idc = 3 works. 1269 assert ( 0 ); 1270 } 1271 } 1272 #endif 1143 1273 } 1144 1274 else 1145 1275 { 1146 1276 m_parseIdc = 3; // Proceed to decoding POC and RPS 1147 } 1277 } 1148 1278 } 1149 1279 #endif … … 1151 1281 #if ALIGNED_BUMPING 1152 1282 #if POC_RESET_IDC_DECODER 1283 1284 #if P0297_VPS_POC_LSB_ALIGNED_FLAG 1285 UInt affectedLayerList[MAX_NUM_LAYER_IDS]; 1286 Int numAffectedLayers; 1287 1288 affectedLayerList[0] = m_apcSlicePilot->getLayerId(); 1289 numAffectedLayers = 1; 1290 1291 if (m_apcSlicePilot->getVPS()->getVpsPocLsbAlignedFlag()) 1292 { 1293 for (UInt j = 0; j < m_apcSlicePilot->getVPS()->getNumPredictedLayers(m_apcSlicePilot->getLayerId()); j++) 1294 { 1295 affectedLayerList[j + 1] = m_apcSlicePilot->getVPS()->getPredictedLayerId(m_apcSlicePilot->getLayerId(), j); 1296 } 1297 numAffectedLayers = m_apcSlicePilot->getVPS()->getNumPredictedLayers(m_apcSlicePilot->getLayerId()) + 1; 1298 } 1299 #endif 1300 1153 1301 //if( (bNewPOC || m_layerId != m_uiPrevLayerId) && ( m_parseIdc != 1) ) 1154 if( m_parseIdc == 1 ) 1302 #if P0297_VPS_POC_LSB_ALIGNED_FLAG 1303 if (m_parseIdc == 1 && m_pocResettingFlag) 1304 #else 1305 if (m_parseIdc == 1) 1306 #endif 1155 1307 { 1156 1308 // Invoke output of pictures if the current picture is a POC reset picture … … 1203 1355 Int deltaPocVal = pocMsbDelta + pocLsbDelta; 1204 1356 1357 #if P0297_VPS_POC_LSB_ALIGNED_FLAG 1358 for (UInt layerIdx = 0; layerIdx < numAffectedLayers; layerIdx++) 1359 { 1360 if (!m_ppcTDecTop[affectedLayerList[layerIdx]]->m_pocDecrementedInDPBFlag) 1361 { 1362 m_ppcTDecTop[affectedLayerList[layerIdx]]->m_pocDecrementedInDPBFlag = true; 1363 TComList<TComPic*>::iterator iterPic = m_ppcTDecTop[affectedLayerList[layerIdx]]->getListPic()->begin(); 1364 while (iterPic != m_ppcTDecTop[affectedLayerList[layerIdx]]->getListPic()->end()) 1365 #else 1205 1366 //Reset all POC for DPB -> basically do it for each slice in the picutre 1206 1367 TComList<TComPic*>::iterator iterPic = m_cListPic.begin(); … … 1208 1369 // Iterate through all picture in DPB 1209 1370 while( iterPic != m_cListPic.end() ) 1371 #endif 1210 1372 { 1211 1373 TComPic *dpbPic = *iterPic; 1212 1374 // Check if the picture pointed to by iterPic is either used for reference or 1213 1375 // needed for output, are in the same layer, and not the current picture. 1214 if( /* ( ( dpbPic->getSlice(0)->isReferenced() ) || ( dpbPic->getOutputMark() ) ) 1376 #if P0297_VPS_POC_LSB_ALIGNED_FLAG 1377 assert(dpbPic->getLayerId() == affectedLayerList[layerIdx]); 1378 if ( (dpbPic->getReconMark()) && (dpbPic->getPicSym()->getSlice(0)->getPicOutputFlag()) ) 1379 #else 1380 if ( /* ( ( dpbPic->getSlice(0)->isReferenced() ) || ( dpbPic->getOutputMark() ) ) 1215 1381 &&*/ ( dpbPic->getLayerId() == m_apcSlicePilot->getLayerId() ) 1216 1382 && ( dpbPic->getReconMark() ) && ( dpbPic->getPicSym()->getSlice(0)->getPicOutputFlag() )) 1383 #endif 1217 1384 { 1218 1385 for(Int i = dpbPic->getNumAllocatedSlice()-1; i >= 0; i--) … … 1241 1408 iterPic++; 1242 1409 } 1410 #if P0297_VPS_POC_LSB_ALIGNED_FLAG 1411 // Update the value of pocCRA 1412 m_ppcTDecTop[affectedLayerList[layerIdx]]->m_pocCRA -= deltaPocVal; 1413 } 1414 } 1415 #else 1243 1416 // Update the value of pocCRA 1244 1417 m_pocCRA -= deltaPocVal; 1418 #endif 1245 1419 1246 1420 // Update value of POCLastDisplay … … 1250 1424 Int slicePicOrderCntLsb = m_apcSlicePilot->getPicOrderCntLsb(); 1251 1425 1252 if( m_parseIdc == 1 || m_parseIdc == 2 ) // TODO This should be replaced by pocResettingFlag. 1426 #if P0297_VPS_POC_LSB_ALIGNED_FLAG 1427 if (m_pocResettingFlag && (m_parseIdc == 1 || m_parseIdc == 2)) 1428 #else 1429 if (m_parseIdc == 1 || m_parseIdc == 2) // TODO This should be replaced by pocResettingFlag. 1430 #endif 1253 1431 { 1254 1432 // Set poc for current slice … … 1296 1474 && !m_apcSlicePilot->getDiscardableFlag() ) 1297 1475 { 1476 #if P0297_VPS_POC_LSB_ALIGNED_FLAG 1477 for (UInt i = 0; i < numAffectedLayers; i++) 1478 { 1479 m_ppcTDecTop[affectedLayerList[i]]->setPrevPicOrderCnt(m_apcSlicePilot->getPOC()); 1480 } 1481 #else 1298 1482 this->setPrevPicOrderCnt( m_apcSlicePilot->getPOC() ); 1483 #endif 1299 1484 } 1300 1485 else if ( m_apcSlicePilot->getPocResetIdc() == 3 ) 1301 1486 { 1487 #if P0297_VPS_POC_LSB_ALIGNED_FLAG 1488 if (!m_firstPicInLayerDecodedFlag || (m_firstPicInLayerDecodedFlag && m_pocResettingFlag)) 1489 { 1490 for (UInt i = 0; i < numAffectedLayers; i++) 1491 { 1492 m_ppcTDecTop[affectedLayerList[i]]->setPrevPicOrderCnt( m_apcSlicePilot->getFullPocResetFlag() 1493 ? 0 : m_apcSlicePilot->getPocLsbVal() ); 1494 } 1495 } 1496 #else 1302 1497 this->setPrevPicOrderCnt( m_apcSlicePilot->getFullPocResetFlag() 1303 1498 ? 0 : m_apcSlicePilot->getPocLsbVal() ); 1499 #endif 1304 1500 } 1305 1501 #else … … 1324 1520 #if POC_RESET_IDC_DECODER 1325 1521 m_parseIdc = -1; 1522 #endif 1523 1524 1525 #if R0226_SLICE_TMVP 1526 if ( m_apcSlicePilot->getTLayer() == 0 && m_apcSlicePilot->getEnableTMVPFlag() == 0 ) 1527 { 1528 //update all pics in the DPB such that they cannot be used for TMPV ref 1529 TComList<TComPic*>::iterator iterRefPic = m_cListPic.begin(); 1530 while( iterRefPic != m_cListPic.end() ) 1531 { 1532 TComPic *refPic = *iterRefPic; 1533 if( ( refPic->getLayerId() == m_apcSlicePilot->getLayerId() ) && refPic->getReconMark() ) 1534 { 1535 for(Int i = refPic->getNumAllocatedSlice()-1; i >= 0; i--) 1536 { 1537 1538 TComSlice *refSlice = refPic->getSlice(i); 1539 refSlice->setAvailableForTMVPRefFlag( false ); 1540 } 1541 } 1542 iterRefPic++; 1543 } 1544 } 1545 m_apcSlicePilot->setAvailableForTMVPRefFlag( true ); 1326 1546 #endif 1327 1547 … … 1483 1703 { 1484 1704 #if AVC_BASE 1705 #if VPS_AVC_BL_FLAG_REMOVAL 1706 if( m_layerId == 1 && m_parameterSetManagerDecoder.getPrefetchedVPS(0)->getNonHEVCBaseLayerFlag() ) 1707 #else 1485 1708 if( m_layerId == 1 && m_parameterSetManagerDecoder.getPrefetchedVPS(0)->getAvcBaseLayerFlag() ) 1709 #endif 1486 1710 { 1487 1711 TComPic* pBLPic = (*m_ppcTDecTop[0]->getListPic()->begin()); … … 1611 1835 1612 1836 #if POC_RESET_IDC_DECODER 1613 pcPic->setCurrAuFlag( true ); 1837 pcPic->setCurrAuFlag( true ); 1838 #if POC_RESET_RESTRICTIONS 1839 if( pcPic->getLayerId() > 0 && m_apcSlicePilot->isIDR() && !m_nonBaseIdrPresentFlag ) 1840 { 1841 // IDR picture with nuh_layer_id > 0 present 1842 m_nonBaseIdrPresentFlag = true; 1843 m_nonBaseIdrType = (m_apcSlicePilot->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_W_RADL); 1844 } 1845 else 1846 { 1847 if( m_apcSlicePilot->getNalUnitType() != NAL_UNIT_CODED_SLICE_IDR_W_RADL ) 1848 { 1849 // Picture with nal_unit_type not equal IDR_W_RADL present 1850 m_picNonIdrWithRadlPresentFlag = true; 1851 } 1852 if( m_apcSlicePilot->getNalUnitType() != NAL_UNIT_CODED_SLICE_IDR_N_LP ) 1853 { 1854 // Picture with nal_unit_type not equal IDR_N_LP present 1855 m_picNonIdrNoLpPresentFlag = true; 1856 } 1857 } 1858 if( !m_checkPocRestrictionsForCurrAu ) // Will be true for the first slice/picture of the AU 1859 { 1860 m_checkPocRestrictionsForCurrAu = true; 1861 m_pocResetIdcOrCurrAu = m_apcSlicePilot->getPocResetIdc(); 1862 if( pcPic->getLayerId() == 0 ) 1863 { 1864 // Base layer picture is present 1865 m_baseLayerPicPresentFlag = true; 1866 if( m_apcSlicePilot->isIRAP() ) 1867 { 1868 // Base layer picture is IRAP 1869 m_baseLayerIrapFlag = true; 1870 } 1871 if( m_apcSlicePilot->isIDR() ) 1872 { 1873 // Base layer picture is IDR 1874 m_baseLayerIdrFlag = true; 1875 } 1876 else 1877 { 1878 if( m_apcSlicePilot->getVPS()->getBaseLayerInternalFlag()) 1879 { 1880 /* When the picture with nuh_layer_id equal to 0 in an access unit is not an IDR picture 1881 and vps_base_layer_internal_flag is equal to 1, the value of poc_reset_idc shall not be equal to 2 1882 for any picture in the access unit. */ 1883 assert( m_apcSlicePilot->getPocResetIdc() != 2 ); 1884 } 1885 } 1886 } 1887 } 1888 else 1889 { 1890 // The value of poc_reset_idc of all coded pictures that are present in the bitstream in an access unit shall be the same. 1891 assert( m_pocResetIdcOrCurrAu == m_apcSlicePilot->getPocResetIdc() ); 1892 1893 /* When the picture in an access unit with nuh_layer_id equal to 0 is an IRAP picture and vps_base_layer_internal_flag is equal to 1 1894 and there is at least one other picture in the same access unit that is not an IRAP picture, 1895 the value of poc_reset_idc shall be equal to 1 or 2 for all pictures in the access unit. */ 1896 if( m_baseLayerPicPresentFlag && m_baseLayerIrapFlag && !m_apcSlicePilot->isIRAP() && m_apcSlicePilot->getVPS()->getBaseLayerInternalFlag() ) 1897 { 1898 assert( m_apcSlicePilot->getPocResetIdc() == 1 || m_apcSlicePilot->getPocResetIdc() == 2 ); 1899 } 1900 1901 /* When the picture with nuh_layer_id equal to 0 in an access unit is an IDR picture and 1902 vps_base_layer_internal_flag is equal to 1 and there is at least one non-IDR picture in the same access unit, 1903 the value of poc_reset_idc shall be equal to 2 for all pictures in the access unit. */ 1904 if( m_baseLayerPicPresentFlag && m_baseLayerIdrFlag && !m_apcSlicePilot->isIDR() && m_apcSlicePilot->getVPS()->getBaseLayerInternalFlag() ) 1905 { 1906 assert( m_apcSlicePilot->getPocResetIdc() == 2 ); 1907 } 1908 1909 /* When there is at least one picture that has nuh_layer_id greater than 0 and that is an IDR picture 1910 with a particular value of nal_unit_type in an access unit and there is at least one other coded picture 1911 that is present in the bitstream in the same access unit with a different value of nal_unit_type, 1912 the value of poc_reset_idc shall be equal to 1 or 2 for all pictures in the access unit. */ 1913 if( m_nonBaseIdrPresentFlag && ( 1914 ( m_nonBaseIdrType == 1 && m_picNonIdrWithRadlPresentFlag ) || 1915 ( m_nonBaseIdrType == 0 && m_picNonIdrNoLpPresentFlag ) 1916 )) 1917 { 1918 assert( m_apcSlicePilot->getPocResetIdc() == 1 || m_apcSlicePilot->getPocResetIdc() == 2 ); 1919 } 1920 } 1921 #endif 1614 1922 #endif 1615 1923 … … 1627 1935 isTff = (pictureTiming->m_picStruct == 1); 1628 1936 } 1937 1938 #if R0226_CONSTRAINT_TMVP_SEI 1939 // Check if any new temporal motion vector prediction constraints SEI has arrived 1940 SEIMessages seiTMVPConstrainsList = extractSeisByType (m_SEIs, SEI::TMVP_CONSTRAINTS); 1941 if (seiTMVPConstrainsList.size() > 0) 1942 { 1943 assert ( pcPic->getTLayer() == 0 ); //this SEI can present only for AU with Tid equal to 0 1944 SEITMVPConstrains* tmvpConstraintSEI = (SEITMVPConstrains*) *(seiTMVPConstrainsList.begin()); 1945 if ( tmvpConstraintSEI->prev_pics_not_used_flag == 1 ) 1946 { 1947 //update all pics in the DPB such that they cannot be used for TMPV ref 1948 TComList<TComPic*>::iterator iterRefPic = m_cListPic.begin(); 1949 while( iterRefPic != m_cListPic.end() ) 1950 { 1951 TComPic *refPic = *iterRefPic; 1952 if( ( refPic->getLayerId() == pcPic->getLayerId() ) && refPic->getReconMark() ) 1953 { 1954 for(Int i = refPic->getNumAllocatedSlice()-1; i >= 0; i--) 1955 { 1956 TComSlice *refSlice = refPic->getSlice(i); 1957 refSlice->setAvailableForTMVPRefFlag( false ); 1958 } 1959 } 1960 iterRefPic++; 1961 } 1962 } 1963 } 1964 #endif 1629 1965 } 1630 1966 … … 1665 2001 Bool bNextSlice = pcSlice->isNextSlice(); 1666 2002 1667 UInt uiCummulativeTileWidth; 1668 UInt uiCummulativeTileHeight; 1669 UInt i, j, p; 1670 1671 //set NumColumnsMins1 and NumRowsMinus1 1672 pcPic->getPicSym()->setNumColumnsMinus1( pcSlice->getPPS()->getNumColumnsMinus1() ); 1673 pcPic->getPicSym()->setNumRowsMinus1( pcSlice->getPPS()->getNumRowsMinus1() ); 1674 1675 //create the TComTileArray 1676 pcPic->getPicSym()->xCreateTComTileArray(); 1677 1678 if( pcSlice->getPPS()->getUniformSpacingFlag() ) 1679 { 1680 //set the width for each tile 1681 for(j=0; j < pcPic->getPicSym()->getNumRowsMinus1()+1; j++) 1682 { 1683 for(p=0; p < pcPic->getPicSym()->getNumColumnsMinus1()+1; p++) 1684 { 1685 pcPic->getPicSym()->getTComTile( j * (pcPic->getPicSym()->getNumColumnsMinus1()+1) + p )-> 1686 setTileWidth( (p+1)*pcPic->getPicSym()->getFrameWidthInCU()/(pcPic->getPicSym()->getNumColumnsMinus1()+1) 1687 - (p*pcPic->getPicSym()->getFrameWidthInCU())/(pcPic->getPicSym()->getNumColumnsMinus1()+1) ); 1688 } 1689 } 1690 1691 //set the height for each tile 1692 for(j=0; j < pcPic->getPicSym()->getNumColumnsMinus1()+1; j++) 1693 { 1694 for(p=0; p < pcPic->getPicSym()->getNumRowsMinus1()+1; p++) 1695 { 1696 pcPic->getPicSym()->getTComTile( p * (pcPic->getPicSym()->getNumColumnsMinus1()+1) + j )-> 1697 setTileHeight( (p+1)*pcPic->getPicSym()->getFrameHeightInCU()/(pcPic->getPicSym()->getNumRowsMinus1()+1) 1698 - (p*pcPic->getPicSym()->getFrameHeightInCU())/(pcPic->getPicSym()->getNumRowsMinus1()+1) ); 1699 } 1700 } 1701 } 1702 else 1703 { 1704 //set the width for each tile 1705 for(j=0; j < pcSlice->getPPS()->getNumRowsMinus1()+1; j++) 1706 { 1707 uiCummulativeTileWidth = 0; 1708 for(i=0; i < pcSlice->getPPS()->getNumColumnsMinus1(); i++) 1709 { 1710 pcPic->getPicSym()->getTComTile(j * (pcSlice->getPPS()->getNumColumnsMinus1()+1) + i)->setTileWidth( pcSlice->getPPS()->getColumnWidth(i) ); 1711 uiCummulativeTileWidth += pcSlice->getPPS()->getColumnWidth(i); 1712 } 1713 pcPic->getPicSym()->getTComTile(j * (pcSlice->getPPS()->getNumColumnsMinus1()+1) + i)->setTileWidth( pcPic->getPicSym()->getFrameWidthInCU()-uiCummulativeTileWidth ); 1714 } 1715 1716 //set the height for each tile 1717 for(j=0; j < pcSlice->getPPS()->getNumColumnsMinus1()+1; j++) 1718 { 1719 uiCummulativeTileHeight = 0; 1720 for(i=0; i < pcSlice->getPPS()->getNumRowsMinus1(); i++) 1721 { 1722 pcPic->getPicSym()->getTComTile(i * (pcSlice->getPPS()->getNumColumnsMinus1()+1) + j)->setTileHeight( pcSlice->getPPS()->getRowHeight(i) ); 1723 uiCummulativeTileHeight += pcSlice->getPPS()->getRowHeight(i); 1724 } 1725 pcPic->getPicSym()->getTComTile(i * (pcSlice->getPPS()->getNumColumnsMinus1()+1) + j)->setTileHeight( pcPic->getPicSym()->getFrameHeightInCU()-uiCummulativeTileHeight ); 1726 } 1727 } 1728 1729 pcPic->getPicSym()->xInitTiles(); 2003 UInt i; 2004 pcPic->getPicSym()->initTiles(pcSlice->getPPS()); 1730 2005 1731 2006 //generate the Coding Order Map and Inverse Coding Order Map … … 1793 2068 UInt refLayerId = pcSlice->getVPS()->getRefLayerId(m_layerId, refLayerIdc); 1794 2069 #if AVC_BASE 2070 #if VPS_AVC_BL_FLAG_REMOVAL 2071 if( refLayerId == 0 && m_parameterSetManagerDecoder.getActiveVPS()->getNonHEVCBaseLayerFlag() ) 2072 #else 1795 2073 if( refLayerId == 0 && m_parameterSetManagerDecoder.getActiveVPS()->getAvcBaseLayerFlag() ) 2074 #endif 1796 2075 { 1797 2076 TComPic* pic = *m_ppcTDecTop[0]->getListPic()->begin(); … … 1805 2084 continue; 1806 2085 } 1807 #if AVC_SYNTAX1808 TComPic* pBLPic = pcSlice->getBaseColPic(refLayerIdc);1809 if( pcSlice->getPOC() == 0 )1810 {1811 // initialize partition order.1812 UInt* piTmp = &g_auiZscanToRaster[0];1813 initZscanToRaster( pBLPic->getPicSym()->getMaxDepth() + 1, 1, 0, piTmp );1814 initRasterToZscan( pBLPic->getPicSym()->getMaxCUWidth(), pBLPic->getPicSym()->getMaxCUHeight(), pBLPic->getPicSym()->getMaxDepth() + 1 );1815 }1816 pBLPic->getSlice( 0 )->initBaseLayerRPL( pcSlice );1817 pBLPic->readBLSyntax( m_ppcTDecTop[0]->getBLSyntaxFile(), SYNTAX_BYTES );1818 #endif1819 2086 } 1820 2087 else … … 1841 2108 #endif 1842 2109 2110 #if MOVE_SCALED_OFFSET_TO_PPS 2111 #if O0098_SCALED_REF_LAYER_ID 2112 const Window &scalEL = pcSlice->getPPS()->getScaledRefLayerWindowForLayer(refLayerId); 2113 #else 2114 const Window &scalEL = pcSlice->getPPS()->getScaledRefLayerWindow(refLayerIdc); 2115 #endif 2116 #else 1843 2117 #if O0098_SCALED_REF_LAYER_ID 1844 2118 const Window &scalEL = pcSlice->getSPS()->getScaledRefLayerWindowForLayer(refLayerId); … … 1846 2120 const Window &scalEL = pcSlice->getSPS()->getScaledRefLayerWindow(refLayerIdc); 1847 2121 #endif 1848 2122 #endif 2123 2124 #if REF_REGION_OFFSET 2125 const Window &windowRL = pcSlice->getPPS()->getRefLayerWindowForLayer(pcSlice->getVPS()->getRefLayerId(m_layerId, refLayerIdc)); 2126 Int widthBL = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec()->getWidth() - windowRL.getWindowLeftOffset() - windowRL.getWindowRightOffset(); 2127 Int heightBL = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec()->getHeight() - windowRL.getWindowTopOffset() - windowRL.getWindowBottomOffset(); 2128 #else 1849 2129 Int widthBL = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec()->getWidth(); 1850 2130 Int heightBL = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec()->getHeight(); … … 1855 2135 heightBL -= ( confBL.getWindowTopOffset() + confBL.getWindowBottomOffset() ) * TComSPS::getWinUnitY( chromaFormatIdc ); 1856 2136 #endif 2137 #endif 1857 2138 Int widthEL = pcPic->getPicYuvRec()->getWidth() - scalEL.getWindowLeftOffset() - scalEL.getWindowRightOffset(); 1858 2139 Int heightEL = pcPic->getPicYuvRec()->getHeight() - scalEL.getWindowTopOffset() - scalEL.getWindowBottomOffset(); 1859 2140 2141 #if RESAMPLING_FIX 2142 #if REF_REGION_OFFSET 2143 // conformance check: the values of RefLayerRegionWidthInSamplesY, RefLayerRegionHeightInSamplesY, ScaledRefRegionWidthInSamplesY and ScaledRefRegionHeightInSamplesY shall be greater than 0 2144 assert(widthEL > 0 && heightEL > 0 && widthBL > 0 && widthEL > 0); 2145 2146 // conformance check: ScaledRefRegionWidthInSamplesY shall be greater or equal to RefLayerRegionWidthInSamplesY and ScaledRefRegionHeightInSamplesY shall be greater or equal to RefLayerRegionHeightInSamplesY 2147 assert(widthEL >= widthBL && heightEL >= heightBL); 2148 2149 #if R0209_GENERIC_PHASE 2150 // 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. 2151 Int phaseHorLuma = pcSlice->getPPS()->getPhaseHorLuma(refLayerIdc); 2152 Int phaseVerLuma = pcSlice->getPPS()->getPhaseVerLuma(refLayerIdc); 2153 Int phaseHorChroma = pcSlice->getPPS()->getPhaseHorChroma(refLayerIdc); 2154 Int phaseVerChroma = pcSlice->getPPS()->getPhaseVerChroma(refLayerIdc); 2155 assert( ( (widthEL != widthBL) || (phaseHorLuma == 0 && phaseHorChroma == 0) ) 2156 && ( (heightEL != heightBL) || (phaseVerLuma == 0 && phaseVerChroma == 0) ) ); 2157 #endif 2158 #endif 2159 #endif 2160 1860 2161 g_mvScalingFactor[refLayerIdc][0] = widthEL == widthBL ? 4096 : Clip3(-4096, 4095, ((widthEL << 8) + (widthBL >> 1)) / widthBL); 1861 2162 g_mvScalingFactor[refLayerIdc][1] = heightEL == heightBL ? 4096 : Clip3(-4096, 4095, ((heightEL << 8) + (heightBL >> 1)) / heightBL); … … 1866 2167 #if Q0048_CGS_3D_ASYMLUT 1867 2168 TComPicYuv* pBaseColRec = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(); 1868 if( pcSlice->getPPS()->getCGSFlag() ) 1869 { 2169 if( pcSlice->getPPS()->getCGSFlag() 2170 #if R0150_CGS_SIGNAL_CONSTRAINTS 2171 && m_c3DAsymLUTPPS.isRefLayer( pcSlice->getVPS()->getRefLayerId(m_layerId, refLayerIdc) ) 2172 #endif 2173 ) 2174 { 2175 #if R0150_CGS_SIGNAL_CONSTRAINTS 2176 assert( pcSlice->getBaseColPic( refLayerIdc )->getSlice( 0 )->getBitDepthY() == m_c3DAsymLUTPPS.getInputBitDepthY() ); 2177 assert( pcSlice->getBaseColPic( refLayerIdc )->getSlice( 0 )->getBitDepthC() == m_c3DAsymLUTPPS.getInputBitDepthC() ); 2178 assert( pcSlice->getBitDepthY() >= m_c3DAsymLUTPPS.getOutputBitDepthY() ); 2179 assert( pcSlice->getBitDepthY() >= m_c3DAsymLUTPPS.getOutputBitDepthC() ); 2180 #endif 1870 2181 if(!m_pColorMappedPic) 1871 2182 { … … 1891 2202 #else 1892 2203 #if Q0048_CGS_3D_ASYMLUT 1893 m_cPrediction.upsampleBasePic( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, pcPic->getPicYuvRec(), pcSlice->getSPS()->getScaledRefLayerWindow(refLayerIdc), pcSlice->getVPS()->getPhaseAlignFlag() ); 1894 #else 1895 m_cPrediction.upsampleBasePic( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), pcPic->getPicYuvRec(), scalEL, pcSlice->getVPS()->getPhaseAlignFlag() ); 2204 #if MOVE_SCALED_OFFSET_TO_PPS 2205 m_cPrediction.upsampleBasePic( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, pcPic->getPicYuvRec(), pcSlice->getPPS()->getScaledRefLayerWindow(refLayerIdc), pcSlice->getVPS()->getPhaseAlignFlag() ); 2206 #else 2207 m_cPrediction.upsampleBasePic( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, pcPic->getPicYuvRec(), pcSlice->getSPS()->getScaledRefLayerWindow(refLayerIdc), pcSlice->getVPS()->getPhaseAlignFlag() ); 2208 #endif 2209 #else 2210 m_cPrediction.upsampleBasePic( refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), pcPic->getPicYuvRec(), scalEL, pcSlice->getVPS()->getPhaseAlignFlag() ); 1896 2211 #endif 1897 2212 #endif … … 1899 2214 #if O0194_JOINT_US_BITSHIFT 1900 2215 #if Q0048_CGS_3D_ASYMLUT 1901 m_cPrediction.upsampleBasePic( pcSlice, refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, pcPic->getPicYuvRec(), scalEL ); 1902 #else 1903 m_cPrediction.upsampleBasePic( pcSlice, refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), pcPic->getPicYuvRec(), scalEL ); 2216 #if REF_REGION_OFFSET 2217 m_cPrediction.upsampleBasePic( pcSlice, refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, pcPic->getPicYuvRec(), scalEL, altRL ); 2218 #else 2219 m_cPrediction.upsampleBasePic( pcSlice, refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pBaseColRec, pcPic->getPicYuvRec(), scalEL ); 2220 #endif 2221 #else 2222 m_cPrediction.upsampleBasePic( pcSlice, refLayerIdc, pcPic->getFullPelBaseRec(refLayerIdc), pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(), pcPic->getPicYuvRec(), scalEL ); 1904 2223 #endif 1905 2224 #else … … 1928 2247 UInt refLayerIdc = pcSlice->getInterLayerPredLayerIdc(i); 1929 2248 #if AVC_BASE 2249 #if VPS_AVC_BL_FLAG_REMOVAL 2250 if( pcSlice->getVPS()->getRefLayerId( m_layerId, refLayerIdc ) == 0 && m_parameterSetManagerDecoder.getActiveVPS()->getNonHEVCBaseLayerFlag() ) 2251 #else 1930 2252 if( pcSlice->getVPS()->getRefLayerId( m_layerId, refLayerIdc ) == 0 && m_parameterSetManagerDecoder.getActiveVPS()->getAvcBaseLayerFlag() ) 2253 #endif 1931 2254 { 1932 2255 pcSlice->setBaseColPic ( refLayerIdc, *m_ppcTDecTop[0]->getListPic()->begin() ); 1933 #if AVC_SYNTAX1934 TComPic* pBLPic = pcSlice->getBaseColPic(refLayerIdc);1935 if( pcSlice->getPOC() == 0 )1936 {1937 // initialize partition order.1938 UInt* piTmp = &g_auiZscanToRaster[0];1939 initZscanToRaster( pBLPic->getPicSym()->getMaxDepth() + 1, 1, 0, piTmp );1940 initRasterToZscan( pBLPic->getPicSym()->getMaxCUWidth(), pBLPic->getPicSym()->getMaxCUHeight(), pBLPic->getPicSym()->getMaxDepth() + 1 );1941 }1942 pBLPic->getSlice( 0 )->initBaseLayerRPL( pcSlice );1943 pBLPic->readBLSyntax( m_ppcTDecTop[0]->getBLSyntaxFile(), SYNTAX_BYTES );1944 #endif1945 2256 } 1946 2257 else … … 1970 2281 1971 2282 #if REF_IDX_MFM 1972 if( pcSlice->getMFMEnabledFlag() )1973 {1974 pcSlice->setRefPOCListILP(m_ppcTDecTop[m_layerId]->m_cIlpPic, pcSlice->getBaseColPic());1975 }1976 2283 pcSlice->setRefPicList( m_cListPic, false, m_cIlpPic); 1977 2284 } … … 2015 2322 } 2016 2323 } 2017 2324 2018 2325 if( m_layerId > 0 && !pcSlice->isIntra() && pcSlice->getEnableTMVPFlag() ) 2019 2326 { … … 2021 2328 2022 2329 assert( refPic ); 2330 #if R0226_SLICE_TMVP 2331 assert ( refPic->getPicSym()->getSlice(0)->getAvailableForTMVPRefFlag() == true ); 2332 #endif 2023 2333 2024 2334 // It is a requirement of bitstream conformance when the collocated picture, used for temporal motion vector prediction, is an inter-layer reference picture, … … 2100 2410 // Decode a picture 2101 2411 m_cGopDecoder.decompressSlice(nalu.m_Bitstream, pcPic); 2412 2413 #if P0297_VPS_POC_LSB_ALIGNED_FLAG 2414 setFirstPicInLayerDecodedFlag(true); 2415 #endif 2102 2416 2103 2417 m_bFirstSliceInPicture = false; … … 2115 2429 } 2116 2430 2431 #if SVC_EXTENSION 2117 2432 Void TDecTop::xDecodeSPS() 2118 2433 { 2119 2434 TComSPS* sps = new TComSPS(); 2120 #if SVC_EXTENSION2121 2435 sps->setLayerId(m_layerId); 2122 2436 #if SPS_DPB_PARAMS … … 2126 2440 #endif 2127 2441 m_parameterSetManagerDecoder.storePrefetchedSPS(sps); 2128 #if Q0078_ADD_LAYER_SETS2129 // Store SPS for all layers2130 for (Int lId = 0; lId < m_numLayer; lId++)2131 {2132 if (m_ppcTDecTop[lId] != this)2133 {2134 m_ppcTDecTop[lId]->getParameterSetManager()->storePrefetchedSPS(sps);2135 }2136 }2137 #endif2138 2442 #if !REPN_FORMAT_IN_VPS // ILRP can only be initialized at activation 2139 2443 if(m_numLayer>0) … … 2142 2446 } 2143 2447 #endif 2144 #else //SVC_EXTENSION2145 m_cEntropyDecoder.decodeSPS( sps );2146 m_parameterSetManagerDecoder.storePrefetchedSPS(sps);2147 #endif //SVC_EXTENSION2148 2448 } 2149 2449 … … 2166 2466 ); 2167 2467 m_parameterSetManagerDecoder.storePrefetchedPPS( pps ); 2168 #if Q0078_ADD_LAYER_SETS2169 // Store PPS for all layers2170 for (Int lId = 0; lId < m_numLayer; lId++)2171 {2172 if (m_ppcTDecTop[lId] != this)2173 {2174 m_ppcTDecTop[lId]->getParameterSetManager()->storePrefetchedPPS(pps);2175 }2176 }2177 #endif2178 2179 if( pps->getDependentSliceSegmentsEnabledFlag() )2180 {2181 Int NumCtx = pps->getEntropyCodingSyncEnabledFlag()?2:1;2182 m_cSliceDecoder.initCtxMem(NumCtx);2183 for ( UInt st = 0; st < NumCtx; st++ )2184 {2185 TDecSbac* ctx = NULL;2186 ctx = new TDecSbac;2187 ctx->init( &m_cBinCABAC );2188 m_cSliceDecoder.setCtxMem( ctx, st );2189 }2190 }2191 2468 } 2469 #else 2470 Void TDecTop::xDecodeSPS() 2471 { 2472 TComSPS* sps = new TComSPS(); 2473 m_cEntropyDecoder.decodeSPS( sps ); 2474 m_parameterSetManagerDecoder.storePrefetchedSPS(sps); 2475 } 2476 2477 Void TDecTop::xDecodePPS() 2478 { 2479 TComPPS* pps = new TComPPS(); 2480 m_cEntropyDecoder.decodePPS( pps ); 2481 m_parameterSetManagerDecoder.storePrefetchedPPS( pps ); 2482 } 2483 #endif //SVC_EXTENSION 2192 2484 2193 2485 Void TDecTop::xDecodeSEI( TComInputBitstream* bs, const NalUnitType nalUnitType ) … … 2217 2509 { 2218 2510 SEIActiveParameterSets *seiAps = (SEIActiveParameterSets*)(*activeParamSets.begin()); 2511 #if !R0247_SEI_ACTIVE 2219 2512 m_parameterSetManagerDecoder.applyPrefetchedPS(); 2220 2513 assert(seiAps->activeSeqParameterSetId.size()>0); … … 2223 2516 printf ("Warning SPS activation with Active parameter set SEI failed"); 2224 2517 } 2225 } 2226 #if Q0074_SEI_COLOR_MAPPING 2227 m_ColorMapping->setColorMapping( m_SEIs ); 2228 #endif 2518 #else 2519 getLayerDec(0)->m_parameterSetManagerDecoder.applyPrefetchedPS(); 2520 assert(seiAps->activeSeqParameterSetId.size()>0); 2521 if( !getLayerDec(0)->m_parameterSetManagerDecoder.activateSPSWithSEI( seiAps->activeSeqParameterSetId[0] ) ) 2522 { 2523 printf ("Warning SPS activation with Active parameter set SEI failed"); 2524 } 2525 for (Int c=1 ; c <= seiAps->numSpsIdsMinus1; c++) 2526 { 2527 Int layerIdx = seiAps->layerSpsIdx[c]; 2528 getLayerDec(layerIdx)->m_parameterSetManagerDecoder.applyPrefetchedPS(); 2529 if( !getLayerDec(layerIdx)->m_parameterSetManagerDecoder.activateSPSWithSEI( seiAps->activeSeqParameterSetId[layerIdx] ) ) 2530 { 2531 printf ("Warning SPS activation with Active parameter set SEI failed"); 2532 } 2533 } 2534 #endif 2535 } 2229 2536 } 2230 2537 #else … … 2287 2594 #endif 2288 2595 #if AVC_BASE 2596 #if VPS_AVC_BL_FLAG_REMOVAL 2597 if( m_parameterSetManagerDecoder.getPrefetchedVPS(0)->getNonHEVCBaseLayerFlag() ) 2598 #else 2289 2599 if( m_parameterSetManagerDecoder.getPrefetchedVPS(0)->getAvcBaseLayerFlag() ) 2600 #endif 2290 2601 { 2291 2602 if( !m_ppcTDecTop[0]->getBLReconFile()->good() ) … … 2294 2605 exit(EXIT_FAILURE); 2295 2606 } 2296 #if AVC_SYNTAX2297 if( !m_ppcTDecTop[0]->getBLSyntaxFile()->good() )2298 {2299 printf( "Base layer syntax input reading error\n" );2300 exit(EXIT_FAILURE);2301 }2302 #endif2303 2607 } 2304 2608 else … … 2748 3052 } 2749 3053 #endif 2750 3054 #if POC_RESET_RESTRICTIONS 3055 Void TDecTop::resetPocRestrictionCheckParameters() 3056 { 3057 TDecTop::m_checkPocRestrictionsForCurrAu = false; 3058 TDecTop::m_pocResetIdcOrCurrAu = -1; 3059 TDecTop::m_baseLayerIdrFlag = false; 3060 TDecTop::m_baseLayerPicPresentFlag = false; 3061 TDecTop::m_baseLayerIrapFlag = false; 3062 TDecTop::m_nonBaseIdrPresentFlag = false; 3063 TDecTop::m_nonBaseIdrType = -1; 3064 TDecTop::m_picNonIdrWithRadlPresentFlag = false; 3065 TDecTop::m_picNonIdrNoLpPresentFlag = false; 3066 } 3067 #endif 2751 3068 #endif //SVC_EXTENSION 2752 3069 2753 #if Q0074_SEI_COLOR_MAPPING2754 TDecColorMapping::TDecColorMapping()2755 {2756 m_pcColorMappingPic[0] = NULL;2757 m_pcColorMappingPic[1] = NULL;2758 2759 m_colorMapCancelFlag = true;2760 2761 for( Int i=0 ; i<3 ; i++ )2762 {2763 m_lut1d_computed[i] = false;2764 m_lut1d_input[i] = NULL;2765 m_coded_input_pivot_value[i] = NULL;2766 m_target_input_pivot_value[i] = NULL;2767 }2768 for( Int i=0 ; i<3 ; i++ )2769 {2770 m_lut1d_output[i] = NULL;2771 m_coded_output_pivot_value[i] = NULL;2772 m_target_output_pivot_value[i] = NULL;2773 }2774 }2775 2776 TDecColorMapping::~TDecColorMapping()2777 {2778 if ( m_pcColorMappingPic[0] ) delete m_pcColorMappingPic[0];2779 if ( m_pcColorMappingPic[1] ) delete m_pcColorMappingPic[1];2780 2781 for( Int i=0 ; i<3 ; i++ )2782 {2783 if ( m_lut1d_input[i] ) delete m_lut1d_input[i];2784 if ( m_coded_input_pivot_value[i] ) delete m_coded_input_pivot_value[i];2785 if ( m_target_input_pivot_value[i] ) delete m_target_input_pivot_value[i];2786 }2787 for( Int i=0 ; i<3 ; i++ )2788 {2789 if ( m_lut1d_output[i] ) delete m_lut1d_output[i];2790 if ( m_coded_output_pivot_value[i] ) delete m_coded_output_pivot_value[i];2791 if ( m_target_output_pivot_value[i] ) delete m_target_output_pivot_value[i];2792 }2793 }2794 2795 Void TDecColorMapping::setColorMapping( SEIMessages m_SEIs )2796 {2797 SEIMessages colorMappingInfo = getSeisByType(m_SEIs, SEI::COLOR_MAPPING_INFO) ;2798 SEIColorMappingInfo *seiColorMappingInfo = NULL;2799 if (colorMappingInfo.size() !=0)2800 {2801 seiColorMappingInfo = (SEIColorMappingInfo*)(*colorMappingInfo.begin());2802 2803 m_colorMapId = seiColorMappingInfo->m_colorMapId;2804 m_colorMapCancelFlag = seiColorMappingInfo->m_colorMapCancelFlag;2805 if( !m_colorMapCancelFlag )2806 {2807 m_colorMapPersistenceFlag = seiColorMappingInfo->m_colorMapPersistenceFlag;2808 m_colorMap_video_signal_type_present_flag = seiColorMappingInfo->m_colorMap_video_signal_type_present_flag;2809 m_colorMap_video_full_range_flag = seiColorMappingInfo->m_colorMap_video_full_range_flag;2810 m_colorMap_primaries = seiColorMappingInfo->m_colorMap_primaries;2811 m_colorMap_transfer_characteristics = seiColorMappingInfo->m_colorMap_transfer_characteristics;2812 m_colorMap_matrix_coeffs = seiColorMappingInfo->m_colorMap_matrix_coeffs;2813 m_colorMapModelId = seiColorMappingInfo->m_colorMapModelId;2814 2815 m_colour_map_coded_data_bit_depth = seiColorMappingInfo->m_colour_map_coded_data_bit_depth;2816 m_colour_map_target_bit_depth = seiColorMappingInfo->m_colour_map_target_bit_depth;2817 2818 for( Int i=0 ; i<3 ; i++ )2819 {2820 m_num_input_pivots[i] = seiColorMappingInfo->m_num_input_pivots[i];2821 if ( m_coded_input_pivot_value[i] ) delete m_coded_input_pivot_value[i];2822 if ( m_target_input_pivot_value[i] ) delete m_target_input_pivot_value[i];2823 m_coded_input_pivot_value[i] = new Int[ m_num_input_pivots[i] ];2824 m_target_input_pivot_value[i] = new Int[ m_num_input_pivots[i] ];2825 for( Int j=0 ; j<m_num_input_pivots[i] ; j++ )2826 {2827 m_coded_input_pivot_value[i][j] = seiColorMappingInfo->m_coded_input_pivot_value[i][j];2828 m_target_input_pivot_value[i][j] = seiColorMappingInfo->m_target_input_pivot_value[i][j];2829 }2830 }2831 2832 m_matrix_flag = seiColorMappingInfo->m_matrix_flag;2833 m_log2_matrix_denom = m_matrix_flag ? (seiColorMappingInfo->m_log2_matrix_denom) : (0) ;2834 for( Int i=0 ; i<3 ; i++ )2835 {2836 for( Int j=0 ; j<3 ; j++ )2837 {2838 m_matrix_coef[i][j] = seiColorMappingInfo->m_matrix_coef[i][j];2839 }2840 }2841 2842 for( Int i=0 ; i<3 ; i++ )2843 {2844 m_num_output_pivots[i] = seiColorMappingInfo->m_num_output_pivots[i];2845 if ( m_coded_output_pivot_value[i] ) delete m_coded_output_pivot_value[i];2846 if ( m_target_output_pivot_value[i] ) delete m_target_output_pivot_value[i];2847 m_coded_output_pivot_value[i] = new Int[ m_num_output_pivots[i] ];2848 m_target_output_pivot_value[i] = new Int[ m_num_output_pivots[i] ];2849 for( Int j=0 ; j<m_num_output_pivots[i] ; j++ )2850 {2851 m_coded_output_pivot_value[i][j] = seiColorMappingInfo->m_coded_output_pivot_value[i][j];2852 m_target_output_pivot_value[i][j] = seiColorMappingInfo->m_target_output_pivot_value[i][j];2853 }2854 }2855 2856 memset( m_lut1d_computed, 0, sizeof( m_lut1d_computed ) );2857 }2858 }2859 2860 }2861 2862 Void TDecColorMapping::setColorMapping( Int bitDepth, Int iComp )2863 {2864 if( !m_colorMapCancelFlag && !m_lut1d_computed[iComp] )2865 {2866 2867 if ( m_lut1d_input[iComp] ) delete m_lut1d_input[iComp];2868 if ( m_lut1d_output[iComp] ) delete m_lut1d_output[iComp];2869 2870 m_lut1d_input[iComp] = new Int[ 1 << bitDepth ];2871 m_lut1d_output[iComp] = new Int[ 1 << bitDepth ];2872 2873 Int iShift = (m_colour_map_coded_data_bit_depth >= bitDepth) ? (m_colour_map_coded_data_bit_depth - bitDepth) : (0);2874 Int iShiftPivot = (m_colour_map_coded_data_bit_depth >= bitDepth) ? (0) : (bitDepth - m_colour_map_coded_data_bit_depth);2875 2876 for( Int k=0 ; k<(1<<bitDepth) ; k++ )2877 {2878 Int iSample = k << iShift ;2879 if( m_num_input_pivots[iComp] > 1 )2880 {2881 for( Int iPivot=0 ; iPivot<m_num_input_pivots[iComp] ; iPivot++ )2882 {2883 Int iCodedPrev = m_coded_input_pivot_value[iComp][iPivot] << iShiftPivot;2884 Int iCodedNext = m_coded_input_pivot_value[iComp][iPivot+1] << iShiftPivot;2885 Int iTargetPrev = m_target_input_pivot_value[iComp][iPivot] << iShiftPivot;2886 Int iTargetNext = m_target_input_pivot_value[iComp][iPivot+1] << iShiftPivot;2887 if ( iCodedPrev <= iSample && iSample < iCodedNext )2888 {2889 Float fInterpol = (Float)( (iCodedNext - iSample)*iTargetPrev + (iSample - iCodedPrev)*iTargetNext ) / (Float)(iCodedNext - iCodedPrev) ;2890 m_lut1d_input[iComp][k] = (Int)( 0.5 + fInterpol );2891 iPivot = m_num_input_pivots[iComp]; // stop2892 }2893 }2894 }2895 else2896 {2897 m_lut1d_input[iComp][k] = k;2898 }2899 }2900 2901 iShift = ( (m_colour_map_coded_data_bit_depth >= bitDepth) ? (m_colour_map_coded_data_bit_depth - bitDepth) : (0) );2902 Int iOffset = iShift ? (1 << (iShift - 1)) : (0) ;2903 iShiftPivot = (m_colour_map_target_bit_depth >= bitDepth) ? (0) : (bitDepth - m_colour_map_target_bit_depth) ;2904 for( Int k=0 ; k<(1<<bitDepth) ; k++ )2905 {2906 Int iSample = k << iShift;2907 if ( m_num_output_pivots[iComp]>1 )2908 {2909 for( Int iPivot=0 ; iPivot<m_num_output_pivots[iComp] ; iPivot++ )2910 {2911 Int iCodedPrev = m_coded_output_pivot_value[iComp][iPivot] << iShiftPivot;2912 Int iCodedNext = m_coded_output_pivot_value[iComp][iPivot+1] << iShiftPivot;2913 Int iTargetPrev = m_target_output_pivot_value[iComp][iPivot] << iShiftPivot;2914 Int iTargetNext = m_target_output_pivot_value[iComp][iPivot+1] << iShiftPivot;2915 if ( iCodedPrev <= iSample && iSample < iCodedNext )2916 {2917 Float fInterpol = (Float)( (iCodedNext - iSample)*iTargetPrev + (iSample - iCodedPrev)*iTargetNext ) / (Float)(iCodedNext - iCodedPrev) ;2918 m_lut1d_output[iComp][k] = ( (Int)(0.5 + fInterpol) + iOffset ) >> iShift ;2919 iPivot = m_num_output_pivots[iComp]; // stop2920 }2921 }2922 }2923 else2924 {2925 m_lut1d_output[iComp][k] = k;2926 }2927 }2928 2929 m_lut1d_computed[iComp] = true;2930 }2931 2932 }2933 2934 TComPicYuv* TDecColorMapping::getColorMapping( TComPicYuv* pPicYuvRec, Int iTop, Int curlayerId )2935 {2936 if( !m_colorMapCancelFlag )2937 {2938 if( !m_pcColorMappingPic[iTop] )2939 {2940 m_pcColorMappingPic[iTop] = new TComPicYuv;2941 #if SVC_EXTENSION2942 m_pcColorMappingPic[iTop]->create( pPicYuvRec->getWidth(), pPicYuvRec->getHeight(), pPicYuvRec->getChromaFormat(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth );2943 #else2944 m_pcColorMappingPic[iTop]->create( pPicYuvRec->getWidth(), pPicYuvRec->getHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth );2945 #endif2946 }2947 2948 Int iHeight = pPicYuvRec->getHeight();2949 Int iWidth = pPicYuvRec->getWidth();2950 Int iStride = pPicYuvRec->getStride();2951 Int iCStride = pPicYuvRec->getCStride();2952 2953 Pel* Lum0 = pPicYuvRec->getLumaAddr();2954 Pel* Cb0 = pPicYuvRec->getCbAddr();2955 Pel* Cr0 = pPicYuvRec->getCrAddr();2956 Pel* Lum1 = m_pcColorMappingPic[iTop]->getLumaAddr();2957 Pel* Cb1 = m_pcColorMappingPic[iTop]->getCbAddr();2958 Pel* Cr1 = m_pcColorMappingPic[iTop]->getCrAddr();2959 2960 #if SVC_EXTENSION2961 Int bitDepthY = g_bitDepthYLayer[curlayerId];2962 Int bitDepthC = g_bitDepthCLayer[curlayerId];2963 2964 assert( g_bitDepthY == bitDepthY );2965 assert( g_bitDepthC == bitDepthC );2966 #else2967 Int bitDepthY = g_bitDepthY;2968 Int bitDepthC = g_bitDepthC;2969 #endif2970 2971 Int iYShift = (m_colour_map_target_bit_depth >= bitDepthY) ? (m_colour_map_target_bit_depth - bitDepthY) : (0) ;2972 Int iCShift = (m_colour_map_target_bit_depth >= bitDepthC) ? (m_colour_map_target_bit_depth - bitDepthC) : (0) ;2973 Int offsetY = (1 << (m_log2_matrix_denom+iYShift - 1));2974 Int offsetC = (1 << (m_log2_matrix_denom+iCShift - 1));2975 2976 Int cShift = 1 ;2977 2978 //Pel* LumPrev0 = Lum0;2979 for( Int y = 0; y < iHeight ; y++ )2980 {2981 Bool bDoChroma = (y % 2);2982 for( Int x = 0; x < iWidth ; x++ )2983 {2984 Int s1Y = m_lut1d_input[0][ Lum0[x] ];2985 Int s1U = m_lut1d_input[1][ Cb0[x>>1] ];2986 Int s1V = m_lut1d_input[2][ Cr0[x>>1] ];2987 2988 Int s2Y, s2U, s2V;2989 if( m_matrix_flag )2990 {2991 s2Y = ( m_matrix_coef[0][0]*s1Y + m_matrix_coef[0][1]*s1U + m_matrix_coef[0][2]*s1V + offsetY ) >> ( m_log2_matrix_denom + iYShift );2992 //s2Y = ClipBD( s2Y , bitDepthY );2993 s2Y = ClipY( s2Y );2994 Lum1[x] = m_lut1d_output[0][ s2Y ];2995 }2996 else2997 {2998 s1Y = ( s1Y + offsetY ) >> iYShift ;2999 //s1Y = ClipBD( s1Y , bitDepthY );3000 s1Y = ClipY( s1Y );3001 Lum1[x] = m_lut1d_output[0][ s1Y ];3002 }3003 3004 if( bDoChroma && (x%2) )3005 {3006 if( m_matrix_flag )3007 {3008 //s1Y = ( m_lut1d_input[0][ Lum0[x] ] + m_lut1d_input[0][ Lum0[x+1] ] + m_lut1d_input[0][ LumPrev0[x] ] + m_lut1d_input[0][ LumPrev0[x+1] ] + 2 ) >> 2 ;3009 //s1Y = m_lut1d_input[0][ (Lum0[x] + Lum0[x+1] + LumPrev0[x] + LumPrev0[x+1] + 2)>>2 ] ;3010 s1Y = m_lut1d_input[0][ Lum0[x] ];3011 3012 s2U = ( m_matrix_coef[1][0]*s1Y + m_matrix_coef[1][1]*s1U + m_matrix_coef[1][2]*s1V + offsetC ) >> ( m_log2_matrix_denom + iCShift ) ;3013 s2V = ( m_matrix_coef[2][0]*s1Y + m_matrix_coef[2][1]*s1U + m_matrix_coef[2][2]*s1V + offsetC ) >> ( m_log2_matrix_denom + iCShift ) ;3014 //s2U = ClipBD( s2U , bitDepthC );3015 //s2V = ClipBD( s2V , bitDepthC );3016 s2U = ClipC( s2U );3017 s2V = ClipC( s2V );3018 Cb1[x>>cShift] = m_lut1d_output[1][ s2U ];3019 Cr1[x>>cShift] = m_lut1d_output[2][ s2V ];3020 }3021 else3022 {3023 s1U = ( s1U + offsetC ) >> iCShift ;3024 s1V = ( s1V + offsetC ) >> iCShift ;3025 //s1U = ClipBD( s1U , bitDepthC );3026 //s1V = ClipBD( s1V , bitDepthC );3027 s1U = ClipC( s1U );3028 s1V = ClipC( s1V );3029 Cb1[x>>cShift] = m_lut1d_output[1][ s1U ];3030 Cr1[x>>cShift] = m_lut1d_output[2][ s1V ];3031 }3032 }3033 3034 }3035 3036 //LumPrev0 = Lum0;3037 Lum0 += iStride;3038 Lum1 += iStride;3039 if( bDoChroma )3040 {3041 Cb0 += iCStride;3042 Cr0 += iCStride;3043 Cb1 += iCStride;3044 Cr1 += iCStride;3045 }3046 }3047 3048 return m_pcColorMappingPic[iTop];3049 }3050 3051 return pPicYuvRec;3052 }3053 #endif3054 3070 3055 3071 //! \} -
trunk/source/Lib/TLibDecoder/TDecTop.h
r815 r906 64 64 // ==================================================================================================================== 65 65 66 #if Q0074_SEI_COLOR_MAPPING67 class TDecColorMapping68 {69 Int m_colorMapId;70 Bool m_colorMapCancelFlag;71 Bool m_colorMapPersistenceFlag;72 Bool m_colorMap_video_signal_type_present_flag;73 Bool m_colorMap_video_full_range_flag;74 Int m_colorMap_primaries;75 Int m_colorMap_transfer_characteristics;76 Int m_colorMap_matrix_coeffs;77 Int m_colorMapModelId;78 79 Int m_colour_map_coded_data_bit_depth;80 Int m_colour_map_target_bit_depth;81 82 Int m_num_input_pivots[3];83 Int* m_coded_input_pivot_value[3];84 Int* m_target_input_pivot_value[3];85 86 Bool m_matrix_flag;87 Int m_log2_matrix_denom;88 Int m_matrix_coef[3][3];89 90 Int m_num_output_pivots[3];91 Int* m_coded_output_pivot_value[3];92 Int* m_target_output_pivot_value[3];93 94 Bool m_lut1d_computed[3];95 Int* m_lut1d_input[3];96 Int* m_lut1d_output[3];97 TComPicYuv* m_pcColorMappingPic[2];98 99 public:100 TDecColorMapping();101 ~TDecColorMapping();102 103 Bool getColorMappingFlag() { return(!m_colorMapCancelFlag);};104 105 Void setColorMapping( SEIMessages m_SEIs );106 Void setColorMapping( Int bitDepthY, Int bitDepthC );107 TComPicYuv* getColorMapping( TComPicYuv* pPicYuvRec, Int iTop=0, Int curlayerId=0 );108 };// END CLASS DEFINITION TDecColorMapping109 #endif110 111 66 /// decoder class 112 67 class TDecTop … … 165 120 Bool m_isLastNALWasEos; 166 121 #endif 167 168 122 #if SVC_EXTENSION 169 123 static UInt m_prevPOC; // POC of the previous slice … … 173 127 UInt m_numLayer; 174 128 TDecTop** m_ppcTDecTop; 129 #if P0297_VPS_POC_LSB_ALIGNED_FLAG 130 Bool m_pocResettingFlag; 131 Bool m_pocDecrementedInDPBFlag; 132 #endif 175 133 #if AVC_BASE 176 134 fstream* m_pBLReconFile; … … 195 153 CommonDecoderParams* m_commonDecoderParams; 196 154 #endif 197 #if AVC_SYNTAX || SYNTAX_OUTPUT198 fstream* m_pBLSyntaxFile;199 #endif200 201 155 #if NO_CLRAS_OUTPUT_FLAG 202 156 Bool m_noClrasOutputFlag; … … 214 168 #endif 215 169 public: 216 #if Q0074_SEI_COLOR_MAPPING 217 TDecColorMapping* m_ColorMapping; 170 #if POC_RESET_RESTRICTIONS 171 static Bool m_checkPocRestrictionsForCurrAu; 172 static Int m_pocResetIdcOrCurrAu; 173 static Bool m_baseLayerIdrFlag; 174 static Bool m_baseLayerPicPresentFlag; 175 static Bool m_baseLayerIrapFlag; 176 static Bool m_nonBaseIdrPresentFlag; 177 static Int m_nonBaseIdrType; 178 static Bool m_picNonIdrWithRadlPresentFlag; 179 static Bool m_picNonIdrNoLpPresentFlag; 180 #endif 181 #if POC_RESET_VALUE_RESTRICTION 182 static Int m_crossLayerPocResetPeriodId; 183 static Int m_crossLayerPocResetIdc; 218 184 #endif 219 185 … … 225 191 226 192 void setDecodedPictureHashSEIEnabled(Int enabled) { m_cGopDecoder.setDecodedPictureHashSEIEnabled(enabled); } 193 #if Q0074_COLOUR_REMAPPING_SEI 194 void setColourRemappingInfoSEIEnabled(Bool enabled) { m_cGopDecoder.setColourRemappingInfoSEIEnabled(enabled); } 195 #endif 227 196 228 197 Void init(); … … 327 296 #endif 328 297 #endif //SVC_EXTENSION 329 #if AVC_SYNTAX || SYNTAX_OUTPUT 330 Void setBLSyntaxFile( fstream* pFile ) { m_pBLSyntaxFile = pFile; } 331 fstream* getBLSyntaxFile() { return m_pBLSyntaxFile; } 332 #endif 298 333 299 protected: 334 300 Void xGetNewPicBuffer (TComSlice* pcSlice, TComPic*& rpcPic); … … 365 331 Void initAsymLut(TComSlice *pcSlice); 366 332 #endif 333 #if POC_RESET_RESTRICTIONS 334 Void resetPocRestrictionCheckParameters(); 335 #endif 367 336 };// END CLASS DEFINITION TDecTop 368 337 369 338 339 370 340 //! \} 371 341
Note: See TracChangeset for help on using the changeset viewer.