Changeset 825 in SHVCSoftware for branches/SHM-dev/source/Lib/TLibDecoder
- Timestamp:
- 11 Jul 2014, 20:42:00 (11 years ago)
- Location:
- branches/SHM-dev/source/Lib/TLibDecoder
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/SHM-dev/source/Lib/TLibDecoder/TDecCAVLC.cpp
r824 r825 316 316 #endif 317 317 318 READ_FLAG( uiCode, "pps_scaling_list_data_present_flag" ); pcPPS->setScalingListPresentFlag( uiCode ? true : false );319 320 if(pcPPS->getScalingListPresentFlag ())321 {322 parseScalingList( pcPPS->getScalingList() );323 }318 READ_FLAG( uiCode, "pps_scaling_list_data_present_flag" ); pcPPS->setScalingListPresentFlag( uiCode ? true : false ); 319 320 if(pcPPS->getScalingListPresentFlag ()) 321 { 322 parseScalingList( pcPPS->getScalingList() ); 323 } 324 324 325 325 #if SCALINGLIST_INFERRING … … 381 381 #endif 382 382 383 while ( xMoreRbspData() )384 {385 READ_FLAG( uiCode, "pps_extension_data_flag");386 }383 while ( xMoreRbspData() ) 384 { 385 READ_FLAG( uiCode, "pps_extension_data_flag"); 386 } 387 387 #if P0166_MODIFIED_PPS_EXTENSION 388 388 } … … 474 474 READ_UVLC( uiCode, "vui_num_ticks_poc_diff_one_minus1"); timingInfo->setNumTicksPocDiffOneMinus1 (uiCode); 475 475 } 476 READ_FLAG( uiCode, "hrd_parameters_present_flag"); pcVUI->setHrdParametersPresentFlag(uiCode);477 if( pcVUI->getHrdParametersPresentFlag() )478 {479 parseHrdParameters( pcVUI->getHrdParameters(), 1, pcSPS->getMaxTLayers() - 1 );480 }476 READ_FLAG( uiCode, "hrd_parameters_present_flag"); pcVUI->setHrdParametersPresentFlag(uiCode); 477 if( pcVUI->getHrdParametersPresentFlag() ) 478 { 479 parseHrdParameters( pcVUI->getHrdParameters(), 1, pcSPS->getMaxTLayers() - 1 ); 480 } 481 481 } 482 482 READ_FLAG( uiCode, "bitstream_restriction_flag"); pcVUI->setBitstreamRestrictionFlag(uiCode); … … 552 552 { 553 553 if( ( ( nalOrVcl == 0 ) && ( hrd->getNalHrdParametersPresentFlag() ) ) || 554 554 ( ( nalOrVcl == 1 ) && ( hrd->getVclHrdParametersPresentFlag() ) ) ) 555 555 { 556 556 for( j = 0; j <= ( hrd->getCpbCntMinus1( i ) ); j ++ ) … … 747 747 READ_UVLC( uiCode, "log2_diff_max_min_coding_block_size" ); 748 748 pcSPS->setLog2DiffMaxMinCodingBlockSize(uiCode); 749 749 750 750 if (pcSPS->getPTL()->getGeneralPTL()->getLevelIdc() >= Level::LEVEL5) 751 751 { 752 752 assert(log2MinCUSize + pcSPS->getLog2DiffMaxMinCodingBlockSize() >= 5); 753 753 } 754 754 755 755 Int maxCUDepthDelta = uiCode; 756 756 pcSPS->setMaxCUWidth ( 1<<(log2MinCUSize + maxCUDepthDelta) ); … … 788 788 { 789 789 #endif 790 READ_FLAG( uiCode, "sps_scaling_list_data_present_flag" ); pcSPS->setScalingListPresentFlag ( uiCode );791 if(pcSPS->getScalingListPresentFlag ())792 {793 parseScalingList( pcSPS->getScalingList() );794 }790 READ_FLAG( uiCode, "sps_scaling_list_data_present_flag" ); pcSPS->setScalingListPresentFlag ( uiCode ); 791 if(pcSPS->getScalingListPresentFlag ()) 792 { 793 parseScalingList( pcSPS->getScalingList() ); 794 } 795 795 #if SCALINGLIST_INFERRING 796 796 } … … 1097 1097 #endif 1098 1098 #if VPS_VUI_OFFSET 1099 READ_CODE( 16, uiCode, "vps_vui_offset" ); vps->setVpsVuiOffset( uiCode );1099 READ_CODE( 16, uiCode, "vps_vui_offset" ); vps->setVpsVuiOffset( uiCode ); 1100 1100 #endif 1101 1101 #if O0109_MOVE_VPS_VUI_FLAG … … 1148 1148 if( !vps->getSplittingFlag() ) 1149 1149 { 1150 for(j = 0; j < numScalabilityTypes; j++)1151 {1152 READ_CODE( vps->getDimensionIdLen(j), uiCode, "dimension_id[i][j]" ); vps->setDimensionId(i, j, uiCode);1150 for(j = 0; j < numScalabilityTypes; j++) 1151 { 1152 READ_CODE( vps->getDimensionIdLen(j), uiCode, "dimension_id[i][j]" ); vps->setDimensionId(i, j, uiCode); 1153 1153 #if !AUXILIARY_PICTURES 1154 assert( uiCode <= vps->getMaxLayerId() );1155 #endif 1156 }1157 }1154 assert( uiCode <= vps->getMaxLayerId() ); 1155 #endif 1156 } 1157 } 1158 1158 } 1159 1159 #endif … … 1242 1242 { 1243 1243 #if O0225_MAX_TID_FOR_REF_LAYERS 1244 1245 1246 1247 1248 1249 1250 1251 1244 for( j = i+1; j <= vps->getMaxLayers() - 1; j++) 1245 { 1246 if(vps->getDirectDependencyFlag(j, i)) 1247 { 1248 READ_CODE( 3, uiCode, "max_tid_il_ref_pics_plus1[i][j]" ); vps->setMaxTidIlRefPicsPlus1(i, j, uiCode); 1249 assert( uiCode <= vps->getMaxTLayers()); 1250 } 1251 } 1252 1252 #else 1253 1253 READ_CODE( 3, uiCode, "max_tid_il_ref_pics_plus1[i]" ); vps->setMaxTidIlRefPicsPlus1(i, uiCode); … … 1261 1261 { 1262 1262 #if O0225_MAX_TID_FOR_REF_LAYERS 1263 1264 1265 1266 1263 for( j = i+1; j <= vps->getMaxLayers() - 1; j++) 1264 { 1265 vps->setMaxTidIlRefPicsPlus1(i, j, 7); 1266 } 1267 1267 #else 1268 1268 vps->setMaxTidIlRefPicsPlus1(i, 7); … … 1827 1827 #endif 1828 1828 } 1829 1829 1830 1830 // When not present, the value of num_add_olss is inferred to be equal to 0. 1831 1831 // NumOutputLayerSets = num_add_olss + NumLayerSets … … 1841 1841 for( j = 0; j < vps->getNumLayersInIdList(lsIdx); j++ ) 1842 1842 { 1843 vps->setOutputLayerFlag(i, j, 1);1843 vps->setOutputLayerFlag(i, j, 1); 1844 1844 } 1845 1845 } … … 1851 1851 vps->setSubLayerDpbInfoPresentFlag( i, 0, true ); 1852 1852 } 1853 1853 1854 1854 // When not present, the value of vps_num_rep_formats_minus1 is inferred to be equal to MaxLayersMinus1. 1855 1855 vps->setVpsNumRepFormats( vps->getMaxLayers() ); … … 1869 1869 // vps_poc_lsb_aligned_flag 1870 1870 // When not present, vps_poc_lsb_aligned_flag is inferred to be equal to 0. 1871 1871 1872 1872 #if O0062_POC_LSB_NOT_PRESENT_FLAG 1873 1873 // When not present, poc_lsb_not_present_flag[ i ] is inferred to be equal to 0. … … 1946 1946 READ_CODE( 2, uiCode, "chroma_format_idc" ); repFormat->setChromaFormatVpsIdc( uiCode ); 1947 1947 #endif 1948 1948 1949 1949 if( repFormat->getChromaFormatVpsIdc() == 3 ) 1950 1950 { … … 1966 1966 #if DPB_PARAMS_MAXTLAYERS 1967 1967 #if BITRATE_PICRATE_SIGNALLING 1968 1969 1970 #else 1971 1972 1973 #endif 1974 1975 1968 Int * MaxSubLayersInLayerSetMinus1 = new Int[vps->getNumLayerSets()]; 1969 for(Int i = 0; i < vps->getNumLayerSets(); i++) 1970 #else 1971 Int * MaxSubLayersInLayerSetMinus1 = new Int[vps->getNumOutputLayerSets()]; 1972 for(Int i = 1; i < vps->getNumOutputLayerSets(); i++) 1973 #endif 1974 { 1975 UInt maxSLMinus1 = 0; 1976 1976 #if CHANGE_NUMSUBDPB_IDX 1977 1978 #else 1979 1977 Int optLsIdx = vps->getOutputLayerSetIdx( i ); 1978 #else 1979 Int optLsIdx = i; 1980 1980 #endif 1981 1981 #if BITRATE_PICRATE_SIGNALLING 1982 1983 #endif 1984 1985 1986 1987 1988 1982 optLsIdx = i; 1983 #endif 1984 for(Int k = 0; k < vps->getNumLayersInIdList(optLsIdx); k++ ) { 1985 Int lId = vps->getLayerSetLayerIdList(optLsIdx, k); 1986 maxSLMinus1 = max(maxSLMinus1, vps->getMaxTSLayersMinus1(vps->getLayerIdInVps(lId))); 1987 } 1988 MaxSubLayersInLayerSetMinus1[ i ] = maxSLMinus1; 1989 1989 #if BITRATE_PICRATE_SIGNALLING 1990 1991 #endif 1992 1993 #endif 1994 1990 vps->setMaxSLayersInLayerSetMinus1(i,MaxSubLayersInLayerSetMinus1[ i ]); 1991 #endif 1992 } 1993 #endif 1994 1995 1995 #if !RESOLUTION_BASED_DPB 1996 1996 vps->deriveNumberOfSubDpbs(); … … 2313 2313 #if VPS_VUI_VIDEO_SIGNAL_MOVE 2314 2314 #else 2315 READ_FLAG( uiCode, "video_signal_info_idx_present_flag" ); vps->setVideoSigPresentVpsFlag( uiCode == 1 ); 2316 if (vps->getVideoSigPresentVpsFlag()) 2317 { 2318 READ_CODE(4, uiCode, "vps_num_video_signal_info_minus1" ); vps->setNumVideoSignalInfo(uiCode + 1); 2315 READ_FLAG( uiCode, "video_signal_info_idx_present_flag" ); vps->setVideoSigPresentVpsFlag( uiCode == 1 ); 2316 if (vps->getVideoSigPresentVpsFlag()) 2317 { 2318 READ_CODE(4, uiCode, "vps_num_video_signal_info_minus1" ); vps->setNumVideoSignalInfo(uiCode + 1); 2319 } 2320 else 2321 { 2322 vps->setNumVideoSignalInfo(vps->getMaxLayers()); 2323 } 2324 2325 2326 for(i = 0; i < vps->getNumVideoSignalInfo(); i++) 2327 { 2328 READ_CODE(3, uiCode, "video_vps_format" ); vps->setVideoVPSFormat(i,uiCode); 2329 READ_FLAG(uiCode, "video_full_range_vps_flag" ); vps->setVideoFullRangeVpsFlag(i,uiCode); 2330 READ_CODE(8, uiCode, "color_primaries_vps" ); vps->setColorPrimaries(i,uiCode); 2331 READ_CODE(8, uiCode, "transfer_characteristics_vps" ); vps->setTransCharacter(i,uiCode); 2332 READ_CODE(8, uiCode, "matrix_coeffs_vps" );vps->setMaxtrixCoeff(i,uiCode); 2333 } 2334 if(!vps->getVideoSigPresentVpsFlag()) 2335 { 2336 for (i=0; i < vps->getMaxLayers(); i++) 2337 { 2338 vps->setVideoSignalInfoIdx(i,i); 2339 } 2340 } 2341 else { 2342 vps->setVideoSignalInfoIdx(0,0); 2343 if (vps->getNumVideoSignalInfo() > 1 ) 2344 { 2345 for (i=1; i < vps->getMaxLayers(); i++) 2346 READ_CODE(4, uiCode, "vps_video_signal_info_idx" ); vps->setVideoSignalInfoIdx(i, uiCode); 2347 } 2348 else { 2349 for (i=1; i < vps->getMaxLayers(); i++) 2350 { 2351 vps->setVideoSignalInfoIdx(i,0); 2352 } 2353 } 2354 } 2355 #endif 2356 #endif 2357 2358 #if O0164_MULTI_LAYER_HRD 2359 READ_FLAG(uiCode, "vps_vui_bsp_hrd_present_flag" ); vps->setVpsVuiBspHrdPresentFlag(uiCode); 2360 if (vps->getVpsVuiBspHrdPresentFlag()) 2361 { 2362 READ_UVLC( uiCode, "vps_num_bsp_hrd_parameters_minus1" ); vps->setVpsNumBspHrdParametersMinus1(uiCode); 2363 vps->createBspHrdParamBuffer(vps->getVpsNumBspHrdParametersMinus1() + 1); 2364 for( i = 0; i <= vps->getVpsNumBspHrdParametersMinus1(); i++ ) 2365 { 2366 if( i > 0 ) 2367 { 2368 READ_FLAG( uiCode, "bsp_cprms_present_flag[i]" ); vps->setBspCprmsPresentFlag(i, uiCode); 2369 } 2370 parseHrdParameters(vps->getBspHrd(i), i==0 ? 1 : vps->getBspCprmsPresentFlag(i), vps->getMaxTLayers()-1); 2371 } 2372 #if Q0078_ADD_LAYER_SETS 2373 for (UInt h = 1; h <= vps->getVpsNumLayerSetsMinus1(); h++) 2374 #else 2375 for( UInt h = 1; h <= (vps->getNumLayerSets()-1); h++ ) 2376 #endif 2377 { 2378 READ_UVLC( uiCode, "num_bitstream_partitions[i]"); vps->setNumBitstreamPartitions(h, uiCode); 2379 #if HRD_BPB 2380 Int chkPart=0; 2381 #endif 2382 for( i = 0; i < vps->getNumBitstreamPartitions(h); i++ ) 2383 { 2384 for( j = 0; j <= (vps->getMaxLayers()-1); j++ ) 2385 { 2386 if( vps->getLayerIdIncludedFlag(h, j) ) 2387 { 2388 READ_FLAG( uiCode, "layer_in_bsp_flag[h][i][j]" ); vps->setLayerInBspFlag(h, i, j, uiCode); 2389 } 2390 } 2391 #if HRD_BPB 2392 chkPart+=vps->getLayerInBspFlag(h, i, j); 2393 #endif 2394 } 2395 #if HRD_BPB 2396 assert(chkPart<=1); 2397 #endif 2398 #if HRD_BPB 2399 if(vps->getNumBitstreamPartitions(h)==1) 2400 { 2401 Int chkPartition1=0; Int chkPartition2=0; 2402 for( j = 0; j <= (vps->getMaxLayers()-1); j++ ) 2403 { 2404 if( vps->getLayerIdIncludedFlag(h, j) ) 2405 { 2406 chkPartition1+=vps->getLayerInBspFlag(h, 0, j); 2407 chkPartition2++; 2408 } 2409 } 2410 assert(chkPartition1!=chkPartition2); 2411 } 2412 #endif 2413 if (vps->getNumBitstreamPartitions(h)) 2414 { 2415 #if Q0182_MULTI_LAYER_HRD_UPDATE 2416 READ_UVLC( uiCode, "num_bsp_sched_combinations_minus1[h]"); vps->setNumBspSchedCombinations(h, uiCode + 1); 2417 #else 2418 READ_UVLC( uiCode, "num_bsp_sched_combinations[h]"); vps->setNumBspSchedCombinations(h, uiCode); 2419 #endif 2420 for( i = 0; i < vps->getNumBspSchedCombinations(h); i++ ) 2421 { 2422 for( j = 0; j < vps->getNumBitstreamPartitions(h); j++ ) 2423 { 2424 READ_UVLC( uiCode, "bsp_comb_hrd_idx[h][i][j]"); vps->setBspCombHrdIdx(h, i, j, uiCode); 2425 #if HRD_BPB 2426 assert(uiCode <= vps->getVpsNumBspHrdParametersMinus1()); 2427 #endif 2428 2429 READ_UVLC( uiCode, "bsp_comb_sched_idx[h][i][j]"); vps->setBspCombSchedIdx(h, i, j, uiCode); 2430 #if HRD_BPB 2431 assert(uiCode <= vps->getBspHrdParamBufferCpbCntMinus1(uiCode,vps->getMaxTLayers()-1)); 2432 #endif 2433 } 2434 } 2435 } 2436 } 2437 } 2438 #endif 2439 2440 #if P0182_VPS_VUI_PS_FLAG 2441 for(i = 1; i < vps->getMaxLayers(); i++) 2442 { 2443 if (vps->getNumRefLayers(vps->getLayerIdInNuh(i)) == 0) 2444 { 2445 READ_FLAG( uiCode, "base_layer_parameter_set_compatibility_flag" ); 2446 vps->setBaseLayerPSCompatibilityFlag( i, uiCode ); 2319 2447 } 2320 2448 else 2321 2449 { 2322 vps->setNumVideoSignalInfo(vps->getMaxLayers()); 2323 } 2324 2325 2326 for(i = 0; i < vps->getNumVideoSignalInfo(); i++) 2327 { 2328 READ_CODE(3, uiCode, "video_vps_format" ); vps->setVideoVPSFormat(i,uiCode); 2329 READ_FLAG(uiCode, "video_full_range_vps_flag" ); vps->setVideoFullRangeVpsFlag(i,uiCode); 2330 READ_CODE(8, uiCode, "color_primaries_vps" ); vps->setColorPrimaries(i,uiCode); 2331 READ_CODE(8, uiCode, "transfer_characteristics_vps" ); vps->setTransCharacter(i,uiCode); 2332 READ_CODE(8, uiCode, "matrix_coeffs_vps" );vps->setMaxtrixCoeff(i,uiCode); 2333 } 2334 if(!vps->getVideoSigPresentVpsFlag()) 2335 { 2336 for (i=0; i < vps->getMaxLayers(); i++) 2337 { 2338 vps->setVideoSignalInfoIdx(i,i); 2339 } 2340 } 2341 else { 2342 vps->setVideoSignalInfoIdx(0,0); 2343 if (vps->getNumVideoSignalInfo() > 1 ) 2344 { 2345 for (i=1; i < vps->getMaxLayers(); i++) 2346 READ_CODE(4, uiCode, "vps_video_signal_info_idx" ); vps->setVideoSignalInfoIdx(i, uiCode); 2347 } 2348 else { 2349 for (i=1; i < vps->getMaxLayers(); i++) 2350 { 2351 vps->setVideoSignalInfoIdx(i,0); 2352 } 2353 } 2354 } 2355 #endif 2356 #endif 2357 2358 #if O0164_MULTI_LAYER_HRD 2359 READ_FLAG(uiCode, "vps_vui_bsp_hrd_present_flag" ); vps->setVpsVuiBspHrdPresentFlag(uiCode); 2360 if (vps->getVpsVuiBspHrdPresentFlag()) 2361 { 2362 READ_UVLC( uiCode, "vps_num_bsp_hrd_parameters_minus1" ); vps->setVpsNumBspHrdParametersMinus1(uiCode); 2363 vps->createBspHrdParamBuffer(vps->getVpsNumBspHrdParametersMinus1() + 1); 2364 for( i = 0; i <= vps->getVpsNumBspHrdParametersMinus1(); i++ ) 2365 { 2366 if( i > 0 ) 2367 { 2368 READ_FLAG( uiCode, "bsp_cprms_present_flag[i]" ); vps->setBspCprmsPresentFlag(i, uiCode); 2369 } 2370 parseHrdParameters(vps->getBspHrd(i), i==0 ? 1 : vps->getBspCprmsPresentFlag(i), vps->getMaxTLayers()-1); 2371 } 2372 #if Q0078_ADD_LAYER_SETS 2373 for (UInt h = 1; h <= vps->getVpsNumLayerSetsMinus1(); h++) 2374 #else 2375 for( UInt h = 1; h <= (vps->getNumLayerSets()-1); h++ ) 2376 #endif 2377 { 2378 READ_UVLC( uiCode, "num_bitstream_partitions[i]"); vps->setNumBitstreamPartitions(h, uiCode); 2379 #if HRD_BPB 2380 Int chkPart=0; 2381 #endif 2382 for( i = 0; i < vps->getNumBitstreamPartitions(h); i++ ) 2383 { 2384 for( j = 0; j <= (vps->getMaxLayers()-1); j++ ) 2385 { 2386 if( vps->getLayerIdIncludedFlag(h, j) ) 2387 { 2388 READ_FLAG( uiCode, "layer_in_bsp_flag[h][i][j]" ); vps->setLayerInBspFlag(h, i, j, uiCode); 2389 } 2390 } 2391 #if HRD_BPB 2392 chkPart+=vps->getLayerInBspFlag(h, i, j); 2393 #endif 2394 } 2395 #if HRD_BPB 2396 assert(chkPart<=1); 2397 #endif 2398 #if HRD_BPB 2399 if(vps->getNumBitstreamPartitions(h)==1) 2400 { 2401 Int chkPartition1=0; Int chkPartition2=0; 2402 for( j = 0; j <= (vps->getMaxLayers()-1); j++ ) 2403 { 2404 if( vps->getLayerIdIncludedFlag(h, j) ) 2405 { 2406 chkPartition1+=vps->getLayerInBspFlag(h, 0, j); 2407 chkPartition2++; 2408 } 2409 } 2410 assert(chkPartition1!=chkPartition2); 2411 } 2412 #endif 2413 if (vps->getNumBitstreamPartitions(h)) 2414 { 2415 #if Q0182_MULTI_LAYER_HRD_UPDATE 2416 READ_UVLC( uiCode, "num_bsp_sched_combinations_minus1[h]"); vps->setNumBspSchedCombinations(h, uiCode + 1); 2417 #else 2418 READ_UVLC( uiCode, "num_bsp_sched_combinations[h]"); vps->setNumBspSchedCombinations(h, uiCode); 2419 #endif 2420 for( i = 0; i < vps->getNumBspSchedCombinations(h); i++ ) 2421 { 2422 for( j = 0; j < vps->getNumBitstreamPartitions(h); j++ ) 2423 { 2424 READ_UVLC( uiCode, "bsp_comb_hrd_idx[h][i][j]"); vps->setBspCombHrdIdx(h, i, j, uiCode); 2425 #if HRD_BPB 2426 assert(uiCode <= vps->getVpsNumBspHrdParametersMinus1()); 2427 #endif 2428 2429 READ_UVLC( uiCode, "bsp_comb_sched_idx[h][i][j]"); vps->setBspCombSchedIdx(h, i, j, uiCode); 2430 #if HRD_BPB 2431 assert(uiCode <= vps->getBspHrdParamBufferCpbCntMinus1(uiCode,vps->getMaxTLayers()-1)); 2432 #endif 2433 } 2434 } 2435 } 2436 } 2437 } 2438 #endif 2439 2440 #if P0182_VPS_VUI_PS_FLAG 2441 for(i = 1; i < vps->getMaxLayers(); i++) 2442 { 2443 if (vps->getNumRefLayers(vps->getLayerIdInNuh(i)) == 0) 2444 { 2445 READ_FLAG( uiCode, "base_layer_parameter_set_compatibility_flag" ); 2446 vps->setBaseLayerPSCompatibilityFlag( i, uiCode ); 2447 } 2448 else 2449 { 2450 vps->setBaseLayerPSCompatibilityFlag( i, 0 ); 2451 } 2452 } 2450 vps->setBaseLayerPSCompatibilityFlag( i, 0 ); 2451 } 2452 } 2453 2453 #endif 2454 2454 } … … 2532 2532 #if Q0142_POC_LSB_NOT_PRESENT 2533 2533 #if SHM_FIX7 2534 2534 Int iPOClsb = 0; 2535 2535 #endif 2536 2536 #endif … … 2659 2659 #if N0065_LAYER_POC_ALIGNMENT 2660 2660 #if SHM_FIX7 2661 2661 } 2662 2662 #endif 2663 2663 #if POC_RESET_IDC_DECODER 2664 else 2665 { 2666 rpcSlice->setPicOrderCntLsb( 0 ); 2667 } 2668 #endif 2669 if( !rpcSlice->getIdrPicFlag() ) 2670 { 2671 #endif 2672 TComReferencePictureSet* rps; 2673 rps = rpcSlice->getLocalRPS(); 2674 rpcSlice->setRPS(rps); 2675 READ_FLAG( uiCode, "short_term_ref_pic_set_sps_flag" ); 2676 if(uiCode == 0) // use short-term reference picture set explicitly signalled in slice header 2677 { 2678 parseShortTermRefPicSet(sps,rps, sps->getRPSList()->getNumberOfReferencePictureSets()); 2679 } 2680 else // use reference to short-term reference picture set in PPS 2681 { 2682 Int numBits = 0; 2683 while ((1 << numBits) < rpcSlice->getSPS()->getRPSList()->getNumberOfReferencePictureSets()) 2684 { 2685 numBits++; 2686 } 2687 if (numBits > 0) 2688 { 2689 READ_CODE( numBits, uiCode, "short_term_ref_pic_set_idx"); 2664 else 2665 { 2666 rpcSlice->setPicOrderCntLsb( 0 ); 2667 } 2668 #endif 2669 if( !rpcSlice->getIdrPicFlag() ) 2670 { 2671 #endif 2672 TComReferencePictureSet* rps; 2673 rps = rpcSlice->getLocalRPS(); 2674 rpcSlice->setRPS(rps); 2675 READ_FLAG( uiCode, "short_term_ref_pic_set_sps_flag" ); 2676 if(uiCode == 0) // use short-term reference picture set explicitly signalled in slice header 2677 { 2678 parseShortTermRefPicSet(sps,rps, sps->getRPSList()->getNumberOfReferencePictureSets()); 2679 } 2680 else // use reference to short-term reference picture set in PPS 2681 { 2682 Int numBits = 0; 2683 while ((1 << numBits) < rpcSlice->getSPS()->getRPSList()->getNumberOfReferencePictureSets()) 2684 { 2685 numBits++; 2686 } 2687 if (numBits > 0) 2688 { 2689 READ_CODE( numBits, uiCode, "short_term_ref_pic_set_idx"); 2690 } 2691 else 2692 { 2693 uiCode = 0; 2694 } 2695 *rps = *(sps->getRPSList()->getReferencePictureSet(uiCode)); 2696 } 2697 if(sps->getLongTermRefsPresent()) 2698 { 2699 Int offset = rps->getNumberOfNegativePictures()+rps->getNumberOfPositivePictures(); 2700 UInt numOfLtrp = 0; 2701 UInt numLtrpInSPS = 0; 2702 if (rpcSlice->getSPS()->getNumLongTermRefPicSPS() > 0) 2703 { 2704 READ_UVLC( uiCode, "num_long_term_sps"); 2705 numLtrpInSPS = uiCode; 2706 numOfLtrp += numLtrpInSPS; 2707 rps->setNumberOfLongtermPictures(numOfLtrp); 2708 } 2709 Int bitsForLtrpInSPS = 0; 2710 while (rpcSlice->getSPS()->getNumLongTermRefPicSPS() > (1 << bitsForLtrpInSPS)) 2711 { 2712 bitsForLtrpInSPS++; 2713 } 2714 READ_UVLC( uiCode, "num_long_term_pics"); rps->setNumberOfLongtermPictures(uiCode); 2715 numOfLtrp += uiCode; 2716 rps->setNumberOfLongtermPictures(numOfLtrp); 2717 Int maxPicOrderCntLSB = 1 << rpcSlice->getSPS()->getBitsForPOC(); 2718 Int prevDeltaMSB = 0, deltaPocMSBCycleLT = 0;; 2719 for(Int j=offset+rps->getNumberOfLongtermPictures()-1, k = 0; k < numOfLtrp; j--, k++) 2720 { 2721 Int pocLsbLt; 2722 if (k < numLtrpInSPS) 2723 { 2724 uiCode = 0; 2725 if (bitsForLtrpInSPS > 0) 2726 { 2727 READ_CODE(bitsForLtrpInSPS, uiCode, "lt_idx_sps[i]"); 2728 } 2729 Int usedByCurrFromSPS=rpcSlice->getSPS()->getUsedByCurrPicLtSPSFlag(uiCode); 2730 2731 pocLsbLt = rpcSlice->getSPS()->getLtRefPicPocLsbSps(uiCode); 2732 rps->setUsed(j,usedByCurrFromSPS); 2690 2733 } 2691 2734 else 2692 2735 { 2693 uiCode = 0; 2694 } 2695 *rps = *(sps->getRPSList()->getReferencePictureSet(uiCode)); 2696 } 2697 if(sps->getLongTermRefsPresent()) 2698 { 2699 Int offset = rps->getNumberOfNegativePictures()+rps->getNumberOfPositivePictures(); 2700 UInt numOfLtrp = 0; 2701 UInt numLtrpInSPS = 0; 2702 if (rpcSlice->getSPS()->getNumLongTermRefPicSPS() > 0) 2703 { 2704 READ_UVLC( uiCode, "num_long_term_sps"); 2705 numLtrpInSPS = uiCode; 2706 numOfLtrp += numLtrpInSPS; 2707 rps->setNumberOfLongtermPictures(numOfLtrp); 2708 } 2709 Int bitsForLtrpInSPS = 0; 2710 while (rpcSlice->getSPS()->getNumLongTermRefPicSPS() > (1 << bitsForLtrpInSPS)) 2711 { 2712 bitsForLtrpInSPS++; 2713 } 2714 READ_UVLC( uiCode, "num_long_term_pics"); rps->setNumberOfLongtermPictures(uiCode); 2715 numOfLtrp += uiCode; 2716 rps->setNumberOfLongtermPictures(numOfLtrp); 2717 Int maxPicOrderCntLSB = 1 << rpcSlice->getSPS()->getBitsForPOC(); 2718 Int prevDeltaMSB = 0, deltaPocMSBCycleLT = 0;; 2719 for(Int j=offset+rps->getNumberOfLongtermPictures()-1, k = 0; k < numOfLtrp; j--, k++) 2720 { 2721 Int pocLsbLt; 2722 if (k < numLtrpInSPS) 2736 READ_CODE(rpcSlice->getSPS()->getBitsForPOC(), uiCode, "poc_lsb_lt"); pocLsbLt= uiCode; 2737 READ_FLAG( uiCode, "used_by_curr_pic_lt_flag"); rps->setUsed(j,uiCode); 2738 } 2739 READ_FLAG(uiCode,"delta_poc_msb_present_flag"); 2740 Bool mSBPresentFlag = uiCode ? true : false; 2741 if(mSBPresentFlag) 2742 { 2743 READ_UVLC( uiCode, "delta_poc_msb_cycle_lt[i]" ); 2744 Bool deltaFlag = false; 2745 // First LTRP || First LTRP from SH 2746 if( (j == offset+rps->getNumberOfLongtermPictures()-1) || (j == offset+(numOfLtrp-numLtrpInSPS)-1) ) 2723 2747 { 2724 uiCode = 0; 2725 if (bitsForLtrpInSPS > 0) 2726 { 2727 READ_CODE(bitsForLtrpInSPS, uiCode, "lt_idx_sps[i]"); 2728 } 2729 Int usedByCurrFromSPS=rpcSlice->getSPS()->getUsedByCurrPicLtSPSFlag(uiCode); 2730 2731 pocLsbLt = rpcSlice->getSPS()->getLtRefPicPocLsbSps(uiCode); 2732 rps->setUsed(j,usedByCurrFromSPS); 2748 deltaFlag = true; 2749 } 2750 if(deltaFlag) 2751 { 2752 deltaPocMSBCycleLT = uiCode; 2733 2753 } 2734 2754 else 2735 2755 { 2736 READ_CODE(rpcSlice->getSPS()->getBitsForPOC(), uiCode, "poc_lsb_lt"); pocLsbLt= uiCode; 2737 READ_FLAG( uiCode, "used_by_curr_pic_lt_flag"); rps->setUsed(j,uiCode); 2756 deltaPocMSBCycleLT = uiCode + prevDeltaMSB; 2738 2757 } 2739 READ_FLAG(uiCode,"delta_poc_msb_present_flag"); 2740 Bool mSBPresentFlag = uiCode ? true : false; 2741 if(mSBPresentFlag) 2758 2759 Int pocLTCurr = rpcSlice->getPOC() - deltaPocMSBCycleLT * maxPicOrderCntLSB 2760 - iPOClsb + pocLsbLt; 2761 rps->setPOC (j, pocLTCurr); 2762 rps->setDeltaPOC(j, - rpcSlice->getPOC() + pocLTCurr); 2763 rps->setCheckLTMSBPresent(j,true); 2764 } 2765 else 2766 { 2767 rps->setPOC (j, pocLsbLt); 2768 rps->setDeltaPOC(j, - rpcSlice->getPOC() + pocLsbLt); 2769 rps->setCheckLTMSBPresent(j,false); 2770 2771 // reset deltaPocMSBCycleLT for first LTRP from slice header if MSB not present 2772 if( j == offset+(numOfLtrp-numLtrpInSPS)-1 ) 2742 2773 { 2743 READ_UVLC( uiCode, "delta_poc_msb_cycle_lt[i]" ); 2744 Bool deltaFlag = false; 2745 // First LTRP || First LTRP from SH 2746 if( (j == offset+rps->getNumberOfLongtermPictures()-1) || (j == offset+(numOfLtrp-numLtrpInSPS)-1) ) 2747 { 2748 deltaFlag = true; 2749 } 2750 if(deltaFlag) 2751 { 2752 deltaPocMSBCycleLT = uiCode; 2753 } 2754 else 2755 { 2756 deltaPocMSBCycleLT = uiCode + prevDeltaMSB; 2757 } 2758 2759 Int pocLTCurr = rpcSlice->getPOC() - deltaPocMSBCycleLT * maxPicOrderCntLSB 2760 - iPOClsb + pocLsbLt; 2761 rps->setPOC (j, pocLTCurr); 2762 rps->setDeltaPOC(j, - rpcSlice->getPOC() + pocLTCurr); 2763 rps->setCheckLTMSBPresent(j,true); 2774 deltaPocMSBCycleLT = 0; 2764 2775 } 2765 else 2776 } 2777 prevDeltaMSB = deltaPocMSBCycleLT; 2778 } 2779 offset += rps->getNumberOfLongtermPictures(); 2780 rps->setNumberOfPictures(offset); 2781 } 2782 #if DPB_CONSTRAINTS 2783 if(rpcSlice->getVPS()->getVpsExtensionFlag()==1) 2784 { 2785 #if Q0078_ADD_LAYER_SETS 2786 for (Int ii = 1; ii < (rpcSlice->getVPS()->getVpsNumLayerSetsMinus1() + 1); ii++) // prevent assert error when num_add_layer_sets > 0 2787 #else 2788 for (Int ii=1; ii< rpcSlice->getVPS()->getNumOutputLayerSets(); ii++ ) 2789 #endif 2790 { 2791 Int layerSetIdxForOutputLayerSet = rpcSlice->getVPS()->getOutputLayerSetIdx( ii ); 2792 Int chkAssert=0; 2793 for(Int kk = 0; kk < rpcSlice->getVPS()->getNumLayersInIdList(layerSetIdxForOutputLayerSet); kk++) 2794 { 2795 if(rpcSlice->getLayerId()==rpcSlice->getVPS()->getLayerSetLayerIdList(layerSetIdxForOutputLayerSet, kk)) 2766 2796 { 2767 rps->setPOC (j, pocLsbLt); 2768 rps->setDeltaPOC(j, - rpcSlice->getPOC() + pocLsbLt); 2769 rps->setCheckLTMSBPresent(j,false); 2770 2771 // reset deltaPocMSBCycleLT for first LTRP from slice header if MSB not present 2772 if( j == offset+(numOfLtrp-numLtrpInSPS)-1 ) 2773 { 2774 deltaPocMSBCycleLT = 0; 2797 chkAssert=1; 2798 } 2799 } 2800 if(chkAssert) 2801 { 2802 // There may be something wrong here (layer id assumed to be layer idx?) 2803 assert(rps->getNumberOfNegativePictures() <= rpcSlice->getVPS()->getMaxVpsDecPicBufferingMinus1(ii , rpcSlice->getLayerId() , rpcSlice->getVPS()->getMaxSLayersInLayerSetMinus1(ii))); 2804 assert(rps->getNumberOfPositivePictures() <= rpcSlice->getVPS()->getMaxVpsDecPicBufferingMinus1(ii , rpcSlice->getLayerId() , rpcSlice->getVPS()->getMaxSLayersInLayerSetMinus1(ii)) - rps->getNumberOfNegativePictures()); 2805 assert((rps->getNumberOfPositivePictures() + rps->getNumberOfNegativePictures() + rps->getNumberOfLongtermPictures()) <= rpcSlice->getVPS()->getMaxVpsDecPicBufferingMinus1(ii , rpcSlice->getLayerId() , rpcSlice->getVPS()->getMaxSLayersInLayerSetMinus1(ii))); 2806 } 2807 } 2808 2809 2810 } 2811 if(rpcSlice->getLayerId() == 0) 2812 { 2813 assert(rps->getNumberOfNegativePictures() <= rpcSlice->getSPS()->getMaxDecPicBuffering(rpcSlice->getSPS()->getMaxTLayers()-1) ); 2814 assert(rps->getNumberOfPositivePictures() <= rpcSlice->getSPS()->getMaxDecPicBuffering(rpcSlice->getSPS()->getMaxTLayers()-1) -rps->getNumberOfNegativePictures()); 2815 assert((rps->getNumberOfPositivePictures() + rps->getNumberOfNegativePictures() + rps->getNumberOfLongtermPictures()) <= rpcSlice->getSPS()->getMaxDecPicBuffering(rpcSlice->getSPS()->getMaxTLayers()-1)); 2816 } 2817 #endif 2818 if ( rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP 2819 || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL 2820 || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP ) 2821 { 2822 // In the case of BLA picture types, rps data is read from slice header but ignored 2823 rps = rpcSlice->getLocalRPS(); 2824 rps->setNumberOfNegativePictures(0); 2825 rps->setNumberOfPositivePictures(0); 2826 rps->setNumberOfLongtermPictures(0); 2827 rps->setNumberOfPictures(0); 2828 rpcSlice->setRPS(rps); 2829 } 2830 if (rpcSlice->getSPS()->getTMVPFlagsPresent()) 2831 { 2832 READ_FLAG( uiCode, "slice_temporal_mvp_enable_flag" ); 2833 rpcSlice->setEnableTMVPFlag( uiCode == 1 ? true : false ); 2834 } 2835 else 2836 { 2837 rpcSlice->setEnableTMVPFlag(false); 2838 } 2839 #if N0065_LAYER_POC_ALIGNMENT && !SHM_FIX7 2840 } 2841 #endif 2842 } 2843 2844 #if SVC_EXTENSION 2845 rpcSlice->setActiveNumILRRefIdx(0); 2846 if((rpcSlice->getLayerId() > 0) && !(rpcSlice->getVPS()->getIlpSshSignalingEnabledFlag()) && (rpcSlice->getNumILRRefIdx() > 0) ) 2847 { 2848 READ_FLAG(uiCode,"inter_layer_pred_enabled_flag"); 2849 rpcSlice->setInterLayerPredEnabledFlag(uiCode); 2850 if( rpcSlice->getInterLayerPredEnabledFlag()) 2851 { 2852 if(rpcSlice->getNumILRRefIdx() > 1) 2853 { 2854 Int numBits = 1; 2855 while ((1 << numBits) < rpcSlice->getNumILRRefIdx()) 2856 { 2857 numBits++; 2858 } 2859 if( !rpcSlice->getVPS()->getMaxOneActiveRefLayerFlag()) 2860 { 2861 READ_CODE( numBits, uiCode,"num_inter_layer_ref_pics_minus1" ); 2862 rpcSlice->setActiveNumILRRefIdx(uiCode + 1); 2863 } 2864 else 2865 { 2866 #if P0079_DERIVE_NUMACTIVE_REF_PICS 2867 for( Int i = 0; i < rpcSlice->getNumILRRefIdx(); i++ ) 2868 { 2869 #if Q0060_MAX_TID_REF_EQUAL_TO_ZERO 2870 if((rpcSlice->getVPS()->getMaxTidIlRefPicsPlus1(rpcSlice->getVPS()->getLayerIdInVps(i),rpcSlice->getLayerId()) > rpcSlice->getTLayer() || rpcSlice->getTLayer()==0) && 2871 (rpcSlice->getVPS()->getMaxTSLayersMinus1(rpcSlice->getVPS()->getLayerIdInVps(i)) >= rpcSlice->getTLayer()) ) 2872 #else 2873 if(rpcSlice->getVPS()->getMaxTidIlRefPicsPlus1(rpcSlice->getVPS()->getLayerIdInVps(i),rpcSlice->getLayerId()) > rpcSlice->getTLayer() && 2874 (rpcSlice->getVPS()->getMaxTSLayersMinus1(rpcSlice->getVPS()->getLayerIdInVps(i)) >= rpcSlice->getTLayer()) ) 2875 #endif 2876 { 2877 rpcSlice->setActiveNumILRRefIdx(1); 2878 break; 2775 2879 } 2776 2880 } 2777 prevDeltaMSB = deltaPocMSBCycleLT; 2778 } 2779 offset += rps->getNumberOfLongtermPictures(); 2780 rps->setNumberOfPictures(offset); 2781 } 2782 #if DPB_CONSTRAINTS 2783 if(rpcSlice->getVPS()->getVpsExtensionFlag()==1) 2881 #else 2882 rpcSlice->setActiveNumILRRefIdx(1); 2883 #endif 2884 } 2885 2886 if( rpcSlice->getActiveNumILRRefIdx() == rpcSlice->getNumILRRefIdx() ) 2887 { 2888 for( Int i = 0; i < rpcSlice->getActiveNumILRRefIdx(); i++ ) 2784 2889 { 2785 #if Q0078_ADD_LAYER_SETS 2786 for (Int ii = 1; ii < (rpcSlice->getVPS()->getVpsNumLayerSetsMinus1() + 1); ii++) // prevent assert error when num_add_layer_sets > 0 2787 #else 2788 for (Int ii=1; ii< rpcSlice->getVPS()->getNumOutputLayerSets(); ii++ ) 2789 #endif 2790 { 2791 Int layerSetIdxForOutputLayerSet = rpcSlice->getVPS()->getOutputLayerSetIdx( ii ); 2792 Int chkAssert=0; 2793 for(Int kk = 0; kk < rpcSlice->getVPS()->getNumLayersInIdList(layerSetIdxForOutputLayerSet); kk++) 2794 { 2795 if(rpcSlice->getLayerId()==rpcSlice->getVPS()->getLayerSetLayerIdList(layerSetIdxForOutputLayerSet, kk)) 2796 { 2797 chkAssert=1; 2798 } 2799 } 2800 if(chkAssert) 2801 { 2802 // There may be something wrong here (layer id assumed to be layer idx?) 2803 assert(rps->getNumberOfNegativePictures() <= rpcSlice->getVPS()->getMaxVpsDecPicBufferingMinus1(ii , rpcSlice->getLayerId() , rpcSlice->getVPS()->getMaxSLayersInLayerSetMinus1(ii))); 2804 assert(rps->getNumberOfPositivePictures() <= rpcSlice->getVPS()->getMaxVpsDecPicBufferingMinus1(ii , rpcSlice->getLayerId() , rpcSlice->getVPS()->getMaxSLayersInLayerSetMinus1(ii)) - rps->getNumberOfNegativePictures()); 2805 assert((rps->getNumberOfPositivePictures() + rps->getNumberOfNegativePictures() + rps->getNumberOfLongtermPictures()) <= rpcSlice->getVPS()->getMaxVpsDecPicBufferingMinus1(ii , rpcSlice->getLayerId() , rpcSlice->getVPS()->getMaxSLayersInLayerSetMinus1(ii))); 2806 } 2807 } 2808 2809 2890 rpcSlice->setInterLayerPredLayerIdc(i,i); 2810 2891 } 2811 if(rpcSlice->getLayerId() == 0) 2892 } 2893 else 2894 { 2895 for(Int i = 0; i < rpcSlice->getActiveNumILRRefIdx(); i++ ) 2812 2896 { 2813 assert(rps->getNumberOfNegativePictures() <= rpcSlice->getSPS()->getMaxDecPicBuffering(rpcSlice->getSPS()->getMaxTLayers()-1) ); 2814 assert(rps->getNumberOfPositivePictures() <= rpcSlice->getSPS()->getMaxDecPicBuffering(rpcSlice->getSPS()->getMaxTLayers()-1) -rps->getNumberOfNegativePictures()); 2815 assert((rps->getNumberOfPositivePictures() + rps->getNumberOfNegativePictures() + rps->getNumberOfLongtermPictures()) <= rpcSlice->getSPS()->getMaxDecPicBuffering(rpcSlice->getSPS()->getMaxTLayers()-1)); 2897 READ_CODE( numBits,uiCode,"inter_layer_pred_layer_idc[i]" ); 2898 rpcSlice->setInterLayerPredLayerIdc(uiCode,i); 2816 2899 } 2817 #endif 2818 if ( rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP 2819 || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL 2820 || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP ) 2821 { 2822 // In the case of BLA picture types, rps data is read from slice header but ignored 2823 rps = rpcSlice->getLocalRPS(); 2824 rps->setNumberOfNegativePictures(0); 2825 rps->setNumberOfPositivePictures(0); 2826 rps->setNumberOfLongtermPictures(0); 2827 rps->setNumberOfPictures(0); 2828 rpcSlice->setRPS(rps); 2829 } 2830 if (rpcSlice->getSPS()->getTMVPFlagsPresent()) 2831 { 2832 READ_FLAG( uiCode, "slice_temporal_mvp_enable_flag" ); 2833 rpcSlice->setEnableTMVPFlag( uiCode == 1 ? true : false ); 2900 } 2834 2901 } 2835 2902 else 2836 2903 { 2837 rpcSlice->setEnableTMVPFlag(false);2838 }2839 #if N0065_LAYER_POC_ALIGNMENT && !SHM_FIX72840 }2841 #endif2842 }2843 2844 #if SVC_EXTENSION2845 rpcSlice->setActiveNumILRRefIdx(0);2846 if((rpcSlice->getLayerId() > 0) && !(rpcSlice->getVPS()->getIlpSshSignalingEnabledFlag()) && (rpcSlice->getNumILRRefIdx() > 0) )2847 {2848 READ_FLAG(uiCode,"inter_layer_pred_enabled_flag");2849 rpcSlice->setInterLayerPredEnabledFlag(uiCode);2850 if( rpcSlice->getInterLayerPredEnabledFlag())2851 {2852 if(rpcSlice->getNumILRRefIdx() > 1)2853 {2854 Int numBits = 1;2855 while ((1 << numBits) < rpcSlice->getNumILRRefIdx())2856 {2857 numBits++;2858 }2859 if( !rpcSlice->getVPS()->getMaxOneActiveRefLayerFlag())2860 {2861 READ_CODE( numBits, uiCode,"num_inter_layer_ref_pics_minus1" );2862 rpcSlice->setActiveNumILRRefIdx(uiCode + 1);2863 }2864 else2865 {2866 #if P0079_DERIVE_NUMACTIVE_REF_PICS2867 for( Int i = 0; i < rpcSlice->getNumILRRefIdx(); i++ )2868 {2869 #if Q0060_MAX_TID_REF_EQUAL_TO_ZERO2870 if((rpcSlice->getVPS()->getMaxTidIlRefPicsPlus1(rpcSlice->getVPS()->getLayerIdInVps(i),rpcSlice->getLayerId()) > rpcSlice->getTLayer() || rpcSlice->getTLayer()==0) &&2871 (rpcSlice->getVPS()->getMaxTSLayersMinus1(rpcSlice->getVPS()->getLayerIdInVps(i)) >= rpcSlice->getTLayer()) )2872 #else2873 if(rpcSlice->getVPS()->getMaxTidIlRefPicsPlus1(rpcSlice->getVPS()->getLayerIdInVps(i),rpcSlice->getLayerId()) > rpcSlice->getTLayer() &&2874 (rpcSlice->getVPS()->getMaxTSLayersMinus1(rpcSlice->getVPS()->getLayerIdInVps(i)) >= rpcSlice->getTLayer()) )2875 #endif2876 {2877 rpcSlice->setActiveNumILRRefIdx(1);2878 break;2879 }2880 }2881 #else2882 rpcSlice->setActiveNumILRRefIdx(1);2883 #endif2884 }2885 2886 if( rpcSlice->getActiveNumILRRefIdx() == rpcSlice->getNumILRRefIdx() )2887 {2888 for( Int i = 0; i < rpcSlice->getActiveNumILRRefIdx(); i++ )2889 {2890 rpcSlice->setInterLayerPredLayerIdc(i,i);2891 }2892 }2893 else2894 {2895 for(Int i = 0; i < rpcSlice->getActiveNumILRRefIdx(); i++ )2896 {2897 READ_CODE( numBits,uiCode,"inter_layer_pred_layer_idc[i]" );2898 rpcSlice->setInterLayerPredLayerIdc(uiCode,i);2899 }2900 }2901 }2902 else2903 {2904 2904 #if O0225_TID_BASED_IL_RPS_DERIV && TSLAYERS_IL_RPS 2905 2905 #if Q0060_MAX_TID_REF_EQUAL_TO_ZERO 2906 2907 2908 #else 2909 2910 2906 if((rpcSlice->getVPS()->getMaxTidIlRefPicsPlus1(0,rpcSlice->getLayerId()) > rpcSlice->getTLayer() || rpcSlice->getTLayer()==0) && 2907 (rpcSlice->getVPS()->getMaxTSLayersMinus1(0) >= rpcSlice->getTLayer()) ) 2908 #else 2909 if( (rpcSlice->getVPS()->getMaxTidIlRefPicsPlus1(0,rpcSlice->getLayerId()) > rpcSlice->getTLayer()) && 2910 (rpcSlice->getVPS()->getMaxTSLayersMinus1(0) >= rpcSlice->getTLayer()) ) 2911 2911 #endif 2912 2912 { … … 2917 2917 } 2918 2918 #endif 2919 2920 2921 2922 2923 2924 2919 } 2920 } 2921 } 2922 else if( rpcSlice->getVPS()->getIlpSshSignalingEnabledFlag() == true && (rpcSlice->getLayerId() > 0 )) 2923 { 2924 rpcSlice->setInterLayerPredEnabledFlag(true); 2925 2925 2926 2926 #if O0225_TID_BASED_IL_RPS_DERIV && TSLAYERS_IL_RPS 2927 2928 2929 2930 2931 2927 Int numRefLayerPics = 0; 2928 Int i = 0; 2929 Int refLayerPicIdc [MAX_VPS_LAYER_ID_PLUS1]; 2930 for(i = 0, numRefLayerPics = 0; i < rpcSlice->getNumILRRefIdx(); i++ ) 2931 { 2932 2932 #if Q0060_MAX_TID_REF_EQUAL_TO_ZERO 2933 2934 2933 if((rpcSlice->getVPS()->getMaxTidIlRefPicsPlus1(rpcSlice->getVPS()->getLayerIdInVps(i),rpcSlice->getLayerId()) > rpcSlice->getTLayer() || rpcSlice->getTLayer()==0) && 2934 (rpcSlice->getVPS()->getMaxTSLayersMinus1(rpcSlice->getVPS()->getLayerIdInVps(i)) >= rpcSlice->getTLayer()) ) 2935 2935 #else 2936 2937 2936 if(rpcSlice->getVPS()->getMaxTidIlRefPicsPlus1(rpcSlice->getVPS()->getLayerIdInVps(i),rpcSlice->getLayerId()) > rpcSlice->getTLayer() && 2937 (rpcSlice->getVPS()->getMaxTSLayersMinus1(rpcSlice->getVPS()->getLayerIdInVps(i)) >= rpcSlice->getTLayer()) ) 2938 2938 #endif 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 #else 2949 2950 2951 2952 2953 2939 { 2940 refLayerPicIdc[ numRefLayerPics++ ] = i; 2941 } 2942 } 2943 rpcSlice->setActiveNumILRRefIdx(numRefLayerPics); 2944 for( i = 0; i < rpcSlice->getActiveNumILRRefIdx(); i++ ) 2945 { 2946 rpcSlice->setInterLayerPredLayerIdc(refLayerPicIdc[i],i); 2947 } 2948 #else 2949 rpcSlice->setActiveNumILRRefIdx(rpcSlice->getNumILRRefIdx()); 2950 for( Int i = 0; i < rpcSlice->getActiveNumILRRefIdx(); i++ ) 2951 { 2952 rpcSlice->setInterLayerPredLayerIdc(i,i); 2953 } 2954 2954 #endif 2955 2955 } 2956 2956 #if P0312_VERT_PHASE_ADJ 2957 2958 2959 2960 2961 2962 2963 2964 2957 for(Int i = 0; i < rpcSlice->getActiveNumILRRefIdx(); i++ ) 2958 { 2959 UInt refLayerIdc = rpcSlice->getInterLayerPredLayerIdc(i); 2960 if( rpcSlice->getSPS()->getVertPhasePositionEnableFlag(refLayerIdc) ) 2961 { 2962 READ_FLAG( uiCode, "vert_phase_position_flag" ); rpcSlice->setVertPhasePositionFlag( uiCode? true : false, refLayerIdc ); 2963 } 2964 } 2965 2965 #endif 2966 2966 #endif //SVC_EXTENSION 2967 2967 2968 2969 2970 2968 if(sps->getUseSAO()) 2969 { 2970 READ_FLAG(uiCode, "slice_sao_luma_flag"); rpcSlice->setSaoEnabledFlag((Bool)uiCode); 2971 2971 #if AUXILIARY_PICTURES 2972 2972 ChromaFormat format; 2973 2973 #if REPN_FORMAT_IN_VPS 2974 2974 #if O0096_REP_FORMAT_INDEX 2975 2976 2977 2978 2979 2980 2981 2975 if( sps->getLayerId() == 0 ) 2976 { 2977 format = sps->getChromaFormatIdc(); 2978 } 2979 else 2980 { 2981 format = rpcSlice->getVPS()->getVpsRepFormat( sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : rpcSlice->getVPS()->getVpsRepFormatIdx(sps->getLayerId()) )->getChromaFormatVpsIdc(); 2982 2982 #if Q0195_REP_FORMAT_CLEANUP 2983 assert( (sps->getUpdateRepFormatFlag()==false && rpcSlice->getVPS()->getVpsNumRepFormats()==1) || rpcSlice->getVPS()->getVpsNumRepFormats() > 1 ); //conformance check 2984 #endif 2985 } 2986 #else 2987 if( ( sps->getLayerId() == 0 ) || sps->getUpdateRepFormatFlag() ) 2988 { 2989 format = sps->getChromaFormatIdc(); 2990 } 2991 else 2992 { 2993 format = rpcSlice->getVPS()->getVpsRepFormat( rpcSlice->getVPS()->getVpsRepFormatIdx(sps->getLayerId()) )->getChromaFormatVpsIdc(); 2994 } 2995 #endif 2996 #else 2983 assert( (sps->getUpdateRepFormatFlag()==false && rpcSlice->getVPS()->getVpsNumRepFormats()==1) || rpcSlice->getVPS()->getVpsNumRepFormats() > 1 ); //conformance check 2984 #endif 2985 } 2986 #else 2987 if( ( sps->getLayerId() == 0 ) || sps->getUpdateRepFormatFlag() ) 2988 { 2997 2989 format = sps->getChromaFormatIdc(); 2998 #endif 2999 if (format != CHROMA_400) 3000 { 2990 } 2991 else 2992 { 2993 format = rpcSlice->getVPS()->getVpsRepFormat( rpcSlice->getVPS()->getVpsRepFormatIdx(sps->getLayerId()) )->getChromaFormatVpsIdc(); 2994 } 2995 #endif 2996 #else 2997 format = sps->getChromaFormatIdc(); 2998 #endif 2999 if (format != CHROMA_400) 3000 { 3001 3001 #endif 3002 3002 READ_FLAG(uiCode, "slice_sao_chroma_flag"); rpcSlice->setSaoEnabledFlagChroma((Bool)uiCode); 3003 3003 #if AUXILIARY_PICTURES 3004 } 3005 else 3006 { 3007 rpcSlice->setSaoEnabledFlagChroma(false); 3008 } 3009 #endif 3010 } 3011 3012 if (rpcSlice->getIdrPicFlag()) 3013 { 3014 rpcSlice->setEnableTMVPFlag(false); 3015 } 3016 if (!rpcSlice->isIntra()) 3017 { 3018 3019 READ_FLAG( uiCode, "num_ref_idx_active_override_flag"); 3020 if (uiCode) 3021 { 3022 READ_UVLC (uiCode, "num_ref_idx_l0_active_minus1" ); rpcSlice->setNumRefIdx( REF_PIC_LIST_0, uiCode + 1 ); 3023 if (rpcSlice->isInterB()) 3024 { 3025 READ_UVLC (uiCode, "num_ref_idx_l1_active_minus1" ); rpcSlice->setNumRefIdx( REF_PIC_LIST_1, uiCode + 1 ); 3004 3026 } 3005 3027 else 3006 3028 { 3007 rpcSlice->setSaoEnabledFlagChroma(false); 3008 } 3009 #endif 3010 } 3011 3012 if (rpcSlice->getIdrPicFlag()) 3013 { 3014 rpcSlice->setEnableTMVPFlag(false); 3015 } 3016 if (!rpcSlice->isIntra()) 3017 { 3018 3019 READ_FLAG( uiCode, "num_ref_idx_active_override_flag"); 3020 if (uiCode) 3021 { 3022 READ_UVLC (uiCode, "num_ref_idx_l0_active_minus1" ); rpcSlice->setNumRefIdx( REF_PIC_LIST_0, uiCode + 1 ); 3023 if (rpcSlice->isInterB()) 3024 { 3025 READ_UVLC (uiCode, "num_ref_idx_l1_active_minus1" ); rpcSlice->setNumRefIdx( REF_PIC_LIST_1, uiCode + 1 ); 3026 } 3027 else 3028 { 3029 rpcSlice->setNumRefIdx(REF_PIC_LIST_1, 0); 3030 } 3029 rpcSlice->setNumRefIdx(REF_PIC_LIST_1, 0); 3030 } 3031 } 3032 else 3033 { 3034 rpcSlice->setNumRefIdx(REF_PIC_LIST_0, rpcSlice->getPPS()->getNumRefIdxL0DefaultActive()); 3035 if (rpcSlice->isInterB()) 3036 { 3037 rpcSlice->setNumRefIdx(REF_PIC_LIST_1, rpcSlice->getPPS()->getNumRefIdxL1DefaultActive()); 3031 3038 } 3032 3039 else 3033 3040 { 3034 rpcSlice->setNumRefIdx(REF_PIC_LIST_0, rpcSlice->getPPS()->getNumRefIdxL0DefaultActive()); 3035 if (rpcSlice->isInterB()) 3036 { 3037 rpcSlice->setNumRefIdx(REF_PIC_LIST_1, rpcSlice->getPPS()->getNumRefIdxL1DefaultActive()); 3038 } 3039 else 3040 { 3041 rpcSlice->setNumRefIdx(REF_PIC_LIST_1,0); 3042 } 3043 } 3044 } 3045 // } 3046 TComRefPicListModification* refPicListModification = rpcSlice->getRefPicListModification(); 3047 if(!rpcSlice->isIntra()) 3048 { 3049 if( !rpcSlice->getPPS()->getListsModificationPresentFlag() || rpcSlice->getNumRpsCurrTempList() <= 1 ) 3050 { 3051 refPicListModification->setRefPicListModificationFlagL0( 0 ); 3041 rpcSlice->setNumRefIdx(REF_PIC_LIST_1,0); 3042 } 3043 } 3044 } 3045 // } 3046 TComRefPicListModification* refPicListModification = rpcSlice->getRefPicListModification(); 3047 if(!rpcSlice->isIntra()) 3048 { 3049 if( !rpcSlice->getPPS()->getListsModificationPresentFlag() || rpcSlice->getNumRpsCurrTempList() <= 1 ) 3050 { 3051 refPicListModification->setRefPicListModificationFlagL0( 0 ); 3052 } 3053 else 3054 { 3055 READ_FLAG( uiCode, "ref_pic_list_modification_flag_l0" ); refPicListModification->setRefPicListModificationFlagL0( uiCode ? 1 : 0 ); 3056 } 3057 3058 if(refPicListModification->getRefPicListModificationFlagL0()) 3059 { 3060 uiCode = 0; 3061 Int i = 0; 3062 Int numRpsCurrTempList0 = rpcSlice->getNumRpsCurrTempList(); 3063 if ( numRpsCurrTempList0 > 1 ) 3064 { 3065 Int length = 1; 3066 numRpsCurrTempList0 --; 3067 while ( numRpsCurrTempList0 >>= 1) 3068 { 3069 length ++; 3070 } 3071 for (i = 0; i < rpcSlice->getNumRefIdx(REF_PIC_LIST_0); i ++) 3072 { 3073 READ_CODE( length, uiCode, "list_entry_l0" ); 3074 refPicListModification->setRefPicSetIdxL0(i, uiCode ); 3075 } 3052 3076 } 3053 3077 else 3054 3078 { 3055 READ_FLAG( uiCode, "ref_pic_list_modification_flag_l0" ); refPicListModification->setRefPicListModificationFlagL0( uiCode ? 1 : 0 ); 3056 } 3057 3058 if(refPicListModification->getRefPicListModificationFlagL0()) 3059 { 3060 uiCode = 0; 3061 Int i = 0; 3062 Int numRpsCurrTempList0 = rpcSlice->getNumRpsCurrTempList(); 3063 if ( numRpsCurrTempList0 > 1 ) 3064 { 3065 Int length = 1; 3066 numRpsCurrTempList0 --; 3067 while ( numRpsCurrTempList0 >>= 1) 3068 { 3069 length ++; 3070 } 3071 for (i = 0; i < rpcSlice->getNumRefIdx(REF_PIC_LIST_0); i ++) 3072 { 3073 READ_CODE( length, uiCode, "list_entry_l0" ); 3074 refPicListModification->setRefPicSetIdxL0(i, uiCode ); 3075 } 3076 } 3077 else 3078 { 3079 for (i = 0; i < rpcSlice->getNumRefIdx(REF_PIC_LIST_0); i ++) 3080 { 3081 refPicListModification->setRefPicSetIdxL0(i, 0 ); 3082 } 3083 } 3084 } 3079 for (i = 0; i < rpcSlice->getNumRefIdx(REF_PIC_LIST_0); i ++) 3080 { 3081 refPicListModification->setRefPicSetIdxL0(i, 0 ); 3082 } 3083 } 3084 } 3085 } 3086 else 3087 { 3088 refPicListModification->setRefPicListModificationFlagL0(0); 3089 } 3090 if(rpcSlice->isInterB()) 3091 { 3092 if( !rpcSlice->getPPS()->getListsModificationPresentFlag() || rpcSlice->getNumRpsCurrTempList() <= 1 ) 3093 { 3094 refPicListModification->setRefPicListModificationFlagL1( 0 ); 3085 3095 } 3086 3096 else 3087 3097 { 3088 refPicListModification->setRefPicListModificationFlagL0(0); 3089 } 3090 if(rpcSlice->isInterB()) 3091 { 3092 if( !rpcSlice->getPPS()->getListsModificationPresentFlag() || rpcSlice->getNumRpsCurrTempList() <= 1 ) 3093 { 3094 refPicListModification->setRefPicListModificationFlagL1( 0 ); 3098 READ_FLAG( uiCode, "ref_pic_list_modification_flag_l1" ); refPicListModification->setRefPicListModificationFlagL1( uiCode ? 1 : 0 ); 3099 } 3100 if(refPicListModification->getRefPicListModificationFlagL1()) 3101 { 3102 uiCode = 0; 3103 Int i = 0; 3104 Int numRpsCurrTempList1 = rpcSlice->getNumRpsCurrTempList(); 3105 if ( numRpsCurrTempList1 > 1 ) 3106 { 3107 Int length = 1; 3108 numRpsCurrTempList1 --; 3109 while ( numRpsCurrTempList1 >>= 1) 3110 { 3111 length ++; 3112 } 3113 for (i = 0; i < rpcSlice->getNumRefIdx(REF_PIC_LIST_1); i ++) 3114 { 3115 READ_CODE( length, uiCode, "list_entry_l1" ); 3116 refPicListModification->setRefPicSetIdxL1(i, uiCode ); 3117 } 3095 3118 } 3096 3119 else 3097 3120 { 3098 READ_FLAG( uiCode, "ref_pic_list_modification_flag_l1" ); refPicListModification->setRefPicListModificationFlagL1( uiCode ? 1 : 0 ); 3099 } 3100 if(refPicListModification->getRefPicListModificationFlagL1()) 3101 { 3102 uiCode = 0; 3103 Int i = 0; 3104 Int numRpsCurrTempList1 = rpcSlice->getNumRpsCurrTempList(); 3105 if ( numRpsCurrTempList1 > 1 ) 3106 { 3107 Int length = 1; 3108 numRpsCurrTempList1 --; 3109 while ( numRpsCurrTempList1 >>= 1) 3110 { 3111 length ++; 3112 } 3113 for (i = 0; i < rpcSlice->getNumRefIdx(REF_PIC_LIST_1); i ++) 3114 { 3115 READ_CODE( length, uiCode, "list_entry_l1" ); 3116 refPicListModification->setRefPicSetIdxL1(i, uiCode ); 3117 } 3118 } 3119 else 3120 { 3121 for (i = 0; i < rpcSlice->getNumRefIdx(REF_PIC_LIST_1); i ++) 3122 { 3123 refPicListModification->setRefPicSetIdxL1(i, 0 ); 3124 } 3125 } 3126 } 3121 for (i = 0; i < rpcSlice->getNumRefIdx(REF_PIC_LIST_1); i ++) 3122 { 3123 refPicListModification->setRefPicSetIdxL1(i, 0 ); 3124 } 3125 } 3126 } 3127 } 3128 else 3129 { 3130 refPicListModification->setRefPicListModificationFlagL1(0); 3131 } 3132 if (rpcSlice->isInterB()) 3133 { 3134 READ_FLAG( uiCode, "mvd_l1_zero_flag" ); rpcSlice->setMvdL1ZeroFlag( (uiCode ? true : false) ); 3135 } 3136 3137 rpcSlice->setCabacInitFlag( false ); // default 3138 if(pps->getCabacInitPresentFlag() && !rpcSlice->isIntra()) 3139 { 3140 READ_FLAG(uiCode, "cabac_init_flag"); 3141 rpcSlice->setCabacInitFlag( uiCode ? true : false ); 3142 } 3143 3144 if ( rpcSlice->getEnableTMVPFlag() ) 3145 { 3146 #if SVC_EXTENSION && REF_IDX_MFM 3147 // set motion mapping flag 3148 rpcSlice->setMFMEnabledFlag( ( rpcSlice->getNumMotionPredRefLayers() > 0 && rpcSlice->getActiveNumILRRefIdx() && !rpcSlice->isIntra() ) ? true : false ); 3149 #endif 3150 if ( rpcSlice->getSliceType() == B_SLICE ) 3151 { 3152 READ_FLAG( uiCode, "collocated_from_l0_flag" ); 3153 rpcSlice->setColFromL0Flag(uiCode); 3127 3154 } 3128 3155 else 3129 3156 { 3130 refPicListModification->setRefPicListModificationFlagL1(0); 3131 } 3132 if (rpcSlice->isInterB()) 3133 { 3134 READ_FLAG( uiCode, "mvd_l1_zero_flag" ); rpcSlice->setMvdL1ZeroFlag( (uiCode ? true : false) ); 3135 } 3136 3137 rpcSlice->setCabacInitFlag( false ); // default 3138 if(pps->getCabacInitPresentFlag() && !rpcSlice->isIntra()) 3139 { 3140 READ_FLAG(uiCode, "cabac_init_flag"); 3141 rpcSlice->setCabacInitFlag( uiCode ? true : false ); 3142 } 3143 3144 if ( rpcSlice->getEnableTMVPFlag() ) 3145 { 3146 #if SVC_EXTENSION && REF_IDX_MFM 3147 // set motion mapping flag 3148 rpcSlice->setMFMEnabledFlag( ( rpcSlice->getNumMotionPredRefLayers() > 0 && rpcSlice->getActiveNumILRRefIdx() && !rpcSlice->isIntra() ) ? true : false ); 3149 #endif 3150 if ( rpcSlice->getSliceType() == B_SLICE ) 3151 { 3152 READ_FLAG( uiCode, "collocated_from_l0_flag" ); 3153 rpcSlice->setColFromL0Flag(uiCode); 3154 } 3155 else 3156 { 3157 rpcSlice->setColFromL0Flag( 1 ); 3158 } 3159 3160 if ( rpcSlice->getSliceType() != I_SLICE && 3161 ((rpcSlice->getColFromL0Flag() == 1 && rpcSlice->getNumRefIdx(REF_PIC_LIST_0) > 1)|| 3162 (rpcSlice->getColFromL0Flag() == 0 && rpcSlice->getNumRefIdx(REF_PIC_LIST_1) > 1))) 3163 { 3164 READ_UVLC( uiCode, "collocated_ref_idx" ); 3165 rpcSlice->setColRefIdx(uiCode); 3166 } 3167 else 3168 { 3169 rpcSlice->setColRefIdx(0); 3170 } 3171 } 3172 if ( (pps->getUseWP() && rpcSlice->getSliceType()==P_SLICE) || (pps->getWPBiPred() && rpcSlice->getSliceType()==B_SLICE) ) 3173 { 3174 xParsePredWeightTable(rpcSlice); 3175 rpcSlice->initWpScaling(); 3176 } 3177 if (!rpcSlice->isIntra()) 3178 { 3179 READ_UVLC( uiCode, "five_minus_max_num_merge_cand"); 3180 rpcSlice->setMaxNumMergeCand(MRG_MAX_NUM_CANDS - uiCode); 3181 } 3182 3183 READ_SVLC( iCode, "slice_qp_delta" ); 3184 rpcSlice->setSliceQp (26 + pps->getPicInitQPMinus26() + iCode); 3157 rpcSlice->setColFromL0Flag( 1 ); 3158 } 3159 3160 if ( rpcSlice->getSliceType() != I_SLICE && 3161 ((rpcSlice->getColFromL0Flag() == 1 && rpcSlice->getNumRefIdx(REF_PIC_LIST_0) > 1)|| 3162 (rpcSlice->getColFromL0Flag() == 0 && rpcSlice->getNumRefIdx(REF_PIC_LIST_1) > 1))) 3163 { 3164 READ_UVLC( uiCode, "collocated_ref_idx" ); 3165 rpcSlice->setColRefIdx(uiCode); 3166 } 3167 else 3168 { 3169 rpcSlice->setColRefIdx(0); 3170 } 3171 } 3172 if ( (pps->getUseWP() && rpcSlice->getSliceType()==P_SLICE) || (pps->getWPBiPred() && rpcSlice->getSliceType()==B_SLICE) ) 3173 { 3174 xParsePredWeightTable(rpcSlice); 3175 rpcSlice->initWpScaling(); 3176 } 3177 if (!rpcSlice->isIntra()) 3178 { 3179 READ_UVLC( uiCode, "five_minus_max_num_merge_cand"); 3180 rpcSlice->setMaxNumMergeCand(MRG_MAX_NUM_CANDS - uiCode); 3181 } 3182 3183 READ_SVLC( iCode, "slice_qp_delta" ); 3184 rpcSlice->setSliceQp (26 + pps->getPicInitQPMinus26() + iCode); 3185 3185 3186 3186 #if REPN_FORMAT_IN_VPS 3187 3187 #if O0194_DIFFERENT_BITDEPTH_EL_BL 3188 g_bitDepthYLayer[rpcSlice->getLayerId()] = rpcSlice->getBitDepthY(); 3189 g_bitDepthCLayer[rpcSlice->getLayerId()] = rpcSlice->getBitDepthC(); 3190 #endif 3191 assert( rpcSlice->getSliceQp() >= -rpcSlice->getQpBDOffsetY() ); 3192 #else 3193 assert( rpcSlice->getSliceQp() >= -sps->getQpBDOffsetY() ); 3194 #endif 3195 assert( rpcSlice->getSliceQp() <= 51 ); 3196 3197 if (rpcSlice->getPPS()->getSliceChromaQpFlag()) 3198 { 3199 READ_SVLC( iCode, "slice_qp_delta_cb" ); 3200 rpcSlice->setSliceQpDeltaCb( iCode ); 3201 assert( rpcSlice->getSliceQpDeltaCb() >= -12 ); 3202 assert( rpcSlice->getSliceQpDeltaCb() <= 12 ); 3203 assert( (rpcSlice->getPPS()->getChromaCbQpOffset() + rpcSlice->getSliceQpDeltaCb()) >= -12 ); 3204 assert( (rpcSlice->getPPS()->getChromaCbQpOffset() + rpcSlice->getSliceQpDeltaCb()) <= 12 ); 3205 3206 READ_SVLC( iCode, "slice_qp_delta_cr" ); 3207 rpcSlice->setSliceQpDeltaCr( iCode ); 3208 assert( rpcSlice->getSliceQpDeltaCr() >= -12 ); 3209 assert( rpcSlice->getSliceQpDeltaCr() <= 12 ); 3210 assert( (rpcSlice->getPPS()->getChromaCrQpOffset() + rpcSlice->getSliceQpDeltaCr()) >= -12 ); 3211 assert( (rpcSlice->getPPS()->getChromaCrQpOffset() + rpcSlice->getSliceQpDeltaCr()) <= 12 ); 3212 } 3213 3214 if (rpcSlice->getPPS()->getDeblockingFilterControlPresentFlag()) 3215 { 3216 if(rpcSlice->getPPS()->getDeblockingFilterOverrideEnabledFlag()) 3217 { 3218 READ_FLAG ( uiCode, "deblocking_filter_override_flag" ); rpcSlice->setDeblockingFilterOverrideFlag(uiCode ? true : false); 3188 g_bitDepthYLayer[rpcSlice->getLayerId()] = rpcSlice->getBitDepthY(); 3189 g_bitDepthCLayer[rpcSlice->getLayerId()] = rpcSlice->getBitDepthC(); 3190 #endif 3191 assert( rpcSlice->getSliceQp() >= -rpcSlice->getQpBDOffsetY() ); 3192 #else 3193 assert( rpcSlice->getSliceQp() >= -sps->getQpBDOffsetY() ); 3194 #endif 3195 assert( rpcSlice->getSliceQp() <= 51 ); 3196 3197 if (rpcSlice->getPPS()->getSliceChromaQpFlag()) 3198 { 3199 READ_SVLC( iCode, "slice_qp_delta_cb" ); 3200 rpcSlice->setSliceQpDeltaCb( iCode ); 3201 assert( rpcSlice->getSliceQpDeltaCb() >= -12 ); 3202 assert( rpcSlice->getSliceQpDeltaCb() <= 12 ); 3203 assert( (rpcSlice->getPPS()->getChromaCbQpOffset() + rpcSlice->getSliceQpDeltaCb()) >= -12 ); 3204 assert( (rpcSlice->getPPS()->getChromaCbQpOffset() + rpcSlice->getSliceQpDeltaCb()) <= 12 ); 3205 3206 READ_SVLC( iCode, "slice_qp_delta_cr" ); 3207 rpcSlice->setSliceQpDeltaCr( iCode ); 3208 assert( rpcSlice->getSliceQpDeltaCr() >= -12 ); 3209 assert( rpcSlice->getSliceQpDeltaCr() <= 12 ); 3210 assert( (rpcSlice->getPPS()->getChromaCrQpOffset() + rpcSlice->getSliceQpDeltaCr()) >= -12 ); 3211 assert( (rpcSlice->getPPS()->getChromaCrQpOffset() + rpcSlice->getSliceQpDeltaCr()) <= 12 ); 3212 } 3213 3214 if (rpcSlice->getPPS()->getDeblockingFilterControlPresentFlag()) 3215 { 3216 if(rpcSlice->getPPS()->getDeblockingFilterOverrideEnabledFlag()) 3217 { 3218 READ_FLAG ( uiCode, "deblocking_filter_override_flag" ); rpcSlice->setDeblockingFilterOverrideFlag(uiCode ? true : false); 3219 } 3220 else 3221 { 3222 rpcSlice->setDeblockingFilterOverrideFlag(0); 3223 } 3224 if(rpcSlice->getDeblockingFilterOverrideFlag()) 3225 { 3226 READ_FLAG ( uiCode, "slice_disable_deblocking_filter_flag" ); rpcSlice->setDeblockingFilterDisable(uiCode ? 1 : 0); 3227 if(!rpcSlice->getDeblockingFilterDisable()) 3228 { 3229 READ_SVLC( iCode, "slice_beta_offset_div2" ); rpcSlice->setDeblockingFilterBetaOffsetDiv2(iCode); 3230 assert(rpcSlice->getDeblockingFilterBetaOffsetDiv2() >= -6 && 3231 rpcSlice->getDeblockingFilterBetaOffsetDiv2() <= 6); 3232 READ_SVLC( iCode, "slice_tc_offset_div2" ); rpcSlice->setDeblockingFilterTcOffsetDiv2(iCode); 3233 assert(rpcSlice->getDeblockingFilterTcOffsetDiv2() >= -6 && 3234 rpcSlice->getDeblockingFilterTcOffsetDiv2() <= 6); 3235 } 3236 } 3237 else 3238 { 3239 rpcSlice->setDeblockingFilterDisable ( rpcSlice->getPPS()->getPicDisableDeblockingFilterFlag() ); 3240 rpcSlice->setDeblockingFilterBetaOffsetDiv2( rpcSlice->getPPS()->getDeblockingFilterBetaOffsetDiv2() ); 3241 rpcSlice->setDeblockingFilterTcOffsetDiv2 ( rpcSlice->getPPS()->getDeblockingFilterTcOffsetDiv2() ); 3242 } 3243 } 3244 else 3245 { 3246 rpcSlice->setDeblockingFilterDisable ( false ); 3247 rpcSlice->setDeblockingFilterBetaOffsetDiv2( 0 ); 3248 rpcSlice->setDeblockingFilterTcOffsetDiv2 ( 0 ); 3249 } 3250 3251 Bool isSAOEnabled = (!rpcSlice->getSPS()->getUseSAO())?(false):(rpcSlice->getSaoEnabledFlag()||rpcSlice->getSaoEnabledFlagChroma()); 3252 Bool isDBFEnabled = (!rpcSlice->getDeblockingFilterDisable()); 3253 3254 if(rpcSlice->getPPS()->getLoopFilterAcrossSlicesEnabledFlag() && ( isSAOEnabled || isDBFEnabled )) 3255 { 3256 READ_FLAG( uiCode, "slice_loop_filter_across_slices_enabled_flag"); 3257 } 3258 else 3259 { 3260 uiCode = rpcSlice->getPPS()->getLoopFilterAcrossSlicesEnabledFlag()?1:0; 3261 } 3262 rpcSlice->setLFCrossSliceBoundaryFlag( (uiCode==1)?true:false); 3263 3264 } 3265 3266 UInt *entryPointOffset = NULL; 3267 UInt numEntryPointOffsets, offsetLenMinus1; 3268 if( pps->getTilesEnabledFlag() || pps->getEntropyCodingSyncEnabledFlag() ) 3269 { 3270 READ_UVLC(numEntryPointOffsets, "num_entry_point_offsets"); rpcSlice->setNumEntryPointOffsets ( numEntryPointOffsets ); 3271 if (numEntryPointOffsets>0) 3272 { 3273 READ_UVLC(offsetLenMinus1, "offset_len_minus1"); 3274 } 3275 entryPointOffset = new UInt[numEntryPointOffsets]; 3276 for (UInt idx=0; idx<numEntryPointOffsets; idx++) 3277 { 3278 READ_CODE(offsetLenMinus1+1, uiCode, "entry_point_offset_minus1"); 3279 entryPointOffset[ idx ] = uiCode + 1; 3280 } 3281 } 3282 else 3283 { 3284 rpcSlice->setNumEntryPointOffsets ( 0 ); 3285 } 3286 3287 #if POC_RESET_IDC_SIGNALLING 3288 Int sliceHeaderExtensionLength = 0; 3289 if(pps->getSliceHeaderExtensionPresentFlag()) 3290 { 3291 READ_UVLC( uiCode, "slice_header_extension_length"); sliceHeaderExtensionLength = uiCode; 3292 } 3293 else 3294 { 3295 sliceHeaderExtensionLength = 0; 3296 } 3297 UInt startBits = m_pcBitstream->getNumBitsRead(); // Start counter of # SH Extn bits 3298 if( sliceHeaderExtensionLength > 0 ) 3299 { 3300 if( rpcSlice->getPPS()->getPocResetInfoPresentFlag() ) 3301 { 3302 READ_CODE( 2, uiCode, "poc_reset_idc"); rpcSlice->setPocResetIdc(uiCode); 3303 } 3304 else 3305 { 3306 rpcSlice->setPocResetIdc( 0 ); 3307 } 3308 #if Q0142_POC_LSB_NOT_PRESENT 3309 if ( rpcSlice->getVPS()->getPocLsbNotPresentFlag(rpcSlice->getLayerId()) && iPOClsb > 0 ) 3310 { 3311 assert( rpcSlice->getPocResetIdc() != 2 ); 3312 } 3313 #endif 3314 if( rpcSlice->getPocResetIdc() > 0 ) 3315 { 3316 READ_CODE(6, uiCode, "poc_reset_period_id"); rpcSlice->setPocResetPeriodId(uiCode); 3317 } 3318 else 3319 { 3320 3321 rpcSlice->setPocResetPeriodId( 0 ); 3322 } 3323 3324 if (rpcSlice->getPocResetIdc() == 3) 3325 { 3326 READ_FLAG( uiCode, "full_poc_reset_flag"); rpcSlice->setFullPocResetFlag((uiCode == 1) ? true : false); 3327 READ_CODE(rpcSlice->getSPS()->getBitsForPOC(), uiCode,"poc_lsb_val"); rpcSlice->setPocLsbVal(uiCode); 3328 #if Q0142_POC_LSB_NOT_PRESENT 3329 if ( rpcSlice->getVPS()->getPocLsbNotPresentFlag(rpcSlice->getLayerId()) && rpcSlice->getFullPocResetFlag() ) 3330 { 3331 assert( rpcSlice->getPocLsbVal() == 0 ); 3332 } 3333 #endif 3334 } 3335 3336 // Derive the value of PocMsbValRequiredFlag 3337 rpcSlice->setPocMsbValRequiredFlag( rpcSlice->getCraPicFlag() || rpcSlice->getBlaPicFlag() 3338 /* || related to vps_poc_lsb_aligned_flag */ 3339 ); 3340 3341 if( !rpcSlice->getPocMsbValRequiredFlag() /* vps_poc_lsb_aligned_flag */ ) 3342 { 3343 READ_FLAG( uiCode, "poc_msb_val_present_flag"); rpcSlice->setPocMsbValPresentFlag( uiCode ? true : false ); 3344 } 3345 else 3346 { 3347 #if POC_MSB_VAL_PRESENT_FLAG_SEM 3348 if( sliceHeaderExtensionLength == 0 ) 3349 { 3350 rpcSlice->setPocMsbValPresentFlag( false ); 3351 } 3352 else if( rpcSlice->getPocMsbValRequiredFlag() ) 3353 #else 3354 if( rpcSlice->getPocMsbValRequiredFlag() ) 3355 #endif 3356 { 3357 rpcSlice->setPocMsbValPresentFlag( true ); 3358 } 3359 else 3360 { 3361 rpcSlice->setPocMsbValPresentFlag( false ); 3362 } 3363 } 3364 3365 #if !POC_RESET_IDC_DECODER 3366 Int maxPocLsb = 1 << rpcSlice->getSPS()->getBitsForPOC(); 3367 #endif 3368 if( rpcSlice->getPocMsbValPresentFlag() ) 3369 { 3370 READ_UVLC( uiCode, "poc_msb_val"); rpcSlice->setPocMsbVal( uiCode ); 3371 3372 #if !POC_RESET_IDC_DECODER 3373 // Update POC of the slice based on this MSB val 3374 Int pocLsb = rpcSlice->getPOC() % maxPocLsb; 3375 rpcSlice->setPOC((rpcSlice->getPocMsbVal() * maxPocLsb) + pocLsb); 3376 } 3377 else 3378 { 3379 rpcSlice->setPocMsbVal( rpcSlice->getPOC() / maxPocLsb ); 3380 #endif 3381 } 3382 3383 // Read remaining bits in the slice header extension. 3384 UInt endBits = m_pcBitstream->getNumBitsRead(); 3385 Int counter = (endBits - startBits) % 8; 3386 if( counter ) 3387 { 3388 counter = 8 - counter; 3389 } 3390 3391 while( counter ) 3392 { 3393 #if Q0146_SSH_EXT_DATA_BIT 3394 READ_FLAG( uiCode, "slice_segment_header_extension_data_bit" ); 3395 #else 3396 READ_FLAG( uiCode, "slice_segment_header_extension_reserved_bit" ); assert( uiCode == 1 ); 3397 #endif 3398 counter--; 3399 } 3400 } 3401 #else 3402 if(pps->getSliceHeaderExtensionPresentFlag()) 3403 { 3404 READ_UVLC(uiCode,"slice_header_extension_length"); 3405 for(Int i=0; i<uiCode; i++) 3406 { 3407 UInt ignore; 3408 READ_CODE(8,ignore,"slice_header_extension_data_byte"); 3409 } 3410 } 3411 #endif 3412 m_pcBitstream->readByteAlignment(); 3413 3414 if( pps->getTilesEnabledFlag() || pps->getEntropyCodingSyncEnabledFlag() ) 3415 { 3416 Int endOfSliceHeaderLocation = m_pcBitstream->getByteLocation(); 3417 3418 // Adjust endOfSliceHeaderLocation to account for emulation prevention bytes in the slice segment header 3419 for ( UInt curByteIdx = 0; curByteIdx<m_pcBitstream->numEmulationPreventionBytesRead(); curByteIdx++ ) 3420 { 3421 if ( m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) < endOfSliceHeaderLocation ) 3422 { 3423 endOfSliceHeaderLocation++; 3424 } 3425 } 3426 3427 Int curEntryPointOffset = 0; 3428 Int prevEntryPointOffset = 0; 3429 for (UInt idx=0; idx<numEntryPointOffsets; idx++) 3430 { 3431 curEntryPointOffset += entryPointOffset[ idx ]; 3432 3433 Int emulationPreventionByteCount = 0; 3434 for ( UInt curByteIdx = 0; curByteIdx<m_pcBitstream->numEmulationPreventionBytesRead(); curByteIdx++ ) 3435 { 3436 if ( m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) >= ( prevEntryPointOffset + endOfSliceHeaderLocation ) && 3437 m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) < ( curEntryPointOffset + endOfSliceHeaderLocation ) ) 3438 { 3439 emulationPreventionByteCount++; 3440 } 3441 } 3442 3443 entryPointOffset[ idx ] -= emulationPreventionByteCount; 3444 prevEntryPointOffset = curEntryPointOffset; 3445 } 3446 3447 if ( pps->getTilesEnabledFlag() ) 3448 { 3449 rpcSlice->setTileLocationCount( numEntryPointOffsets ); 3450 3451 UInt prevPos = 0; 3452 for (Int idx=0; idx<rpcSlice->getTileLocationCount(); idx++) 3453 { 3454 rpcSlice->setTileLocation( idx, prevPos + entryPointOffset [ idx ] ); 3455 prevPos += entryPointOffset[ idx ]; 3456 } 3457 } 3458 else if ( pps->getEntropyCodingSyncEnabledFlag() ) 3459 { 3460 Int numSubstreams = rpcSlice->getNumEntryPointOffsets()+1; 3461 rpcSlice->allocSubstreamSizes(numSubstreams); 3462 UInt *pSubstreamSizes = rpcSlice->getSubstreamSizes(); 3463 for (Int idx=0; idx<numSubstreams-1; idx++) 3464 { 3465 if ( idx < numEntryPointOffsets ) 3466 { 3467 pSubstreamSizes[ idx ] = ( entryPointOffset[ idx ] << 3 ) ; 3219 3468 } 3220 3469 else 3221 3470 { 3222 rpcSlice->setDeblockingFilterOverrideFlag(0); 3223 } 3224 if(rpcSlice->getDeblockingFilterOverrideFlag()) 3225 { 3226 READ_FLAG ( uiCode, "slice_disable_deblocking_filter_flag" ); rpcSlice->setDeblockingFilterDisable(uiCode ? 1 : 0); 3227 if(!rpcSlice->getDeblockingFilterDisable()) 3228 { 3229 READ_SVLC( iCode, "slice_beta_offset_div2" ); rpcSlice->setDeblockingFilterBetaOffsetDiv2(iCode); 3230 assert(rpcSlice->getDeblockingFilterBetaOffsetDiv2() >= -6 && 3231 rpcSlice->getDeblockingFilterBetaOffsetDiv2() <= 6); 3232 READ_SVLC( iCode, "slice_tc_offset_div2" ); rpcSlice->setDeblockingFilterTcOffsetDiv2(iCode); 3233 assert(rpcSlice->getDeblockingFilterTcOffsetDiv2() >= -6 && 3234 rpcSlice->getDeblockingFilterTcOffsetDiv2() <= 6); 3235 } 3236 } 3237 else 3238 { 3239 rpcSlice->setDeblockingFilterDisable ( rpcSlice->getPPS()->getPicDisableDeblockingFilterFlag() ); 3240 rpcSlice->setDeblockingFilterBetaOffsetDiv2( rpcSlice->getPPS()->getDeblockingFilterBetaOffsetDiv2() ); 3241 rpcSlice->setDeblockingFilterTcOffsetDiv2 ( rpcSlice->getPPS()->getDeblockingFilterTcOffsetDiv2() ); 3242 } 3243 } 3244 else 3245 { 3246 rpcSlice->setDeblockingFilterDisable ( false ); 3247 rpcSlice->setDeblockingFilterBetaOffsetDiv2( 0 ); 3248 rpcSlice->setDeblockingFilterTcOffsetDiv2 ( 0 ); 3249 } 3250 3251 Bool isSAOEnabled = (!rpcSlice->getSPS()->getUseSAO())?(false):(rpcSlice->getSaoEnabledFlag()||rpcSlice->getSaoEnabledFlagChroma()); 3252 Bool isDBFEnabled = (!rpcSlice->getDeblockingFilterDisable()); 3253 3254 if(rpcSlice->getPPS()->getLoopFilterAcrossSlicesEnabledFlag() && ( isSAOEnabled || isDBFEnabled )) 3255 { 3256 READ_FLAG( uiCode, "slice_loop_filter_across_slices_enabled_flag"); 3257 } 3258 else 3259 { 3260 uiCode = rpcSlice->getPPS()->getLoopFilterAcrossSlicesEnabledFlag()?1:0; 3261 } 3262 rpcSlice->setLFCrossSliceBoundaryFlag( (uiCode==1)?true:false); 3263 3264 } 3265 3266 UInt *entryPointOffset = NULL; 3267 UInt numEntryPointOffsets, offsetLenMinus1; 3268 if( pps->getTilesEnabledFlag() || pps->getEntropyCodingSyncEnabledFlag() ) 3269 { 3270 READ_UVLC(numEntryPointOffsets, "num_entry_point_offsets"); rpcSlice->setNumEntryPointOffsets ( numEntryPointOffsets ); 3271 if (numEntryPointOffsets>0) 3272 { 3273 READ_UVLC(offsetLenMinus1, "offset_len_minus1"); 3274 } 3275 entryPointOffset = new UInt[numEntryPointOffsets]; 3276 for (UInt idx=0; idx<numEntryPointOffsets; idx++) 3277 { 3278 READ_CODE(offsetLenMinus1+1, uiCode, "entry_point_offset_minus1"); 3279 entryPointOffset[ idx ] = uiCode + 1; 3280 } 3281 } 3282 else 3283 { 3284 rpcSlice->setNumEntryPointOffsets ( 0 ); 3285 } 3286 3287 #if POC_RESET_IDC_SIGNALLING 3288 Int sliceHeaderExtensionLength = 0; 3289 if(pps->getSliceHeaderExtensionPresentFlag()) 3290 { 3291 READ_UVLC( uiCode, "slice_header_extension_length"); sliceHeaderExtensionLength = uiCode; 3292 } 3293 else 3294 { 3295 sliceHeaderExtensionLength = 0; 3296 } 3297 UInt startBits = m_pcBitstream->getNumBitsRead(); // Start counter of # SH Extn bits 3298 if( sliceHeaderExtensionLength > 0 ) 3299 { 3300 if( rpcSlice->getPPS()->getPocResetInfoPresentFlag() ) 3301 { 3302 READ_CODE( 2, uiCode, "poc_reset_idc"); rpcSlice->setPocResetIdc(uiCode); 3303 } 3304 else 3305 { 3306 rpcSlice->setPocResetIdc( 0 ); 3307 } 3308 #if Q0142_POC_LSB_NOT_PRESENT 3309 if ( rpcSlice->getVPS()->getPocLsbNotPresentFlag(rpcSlice->getLayerId()) && iPOClsb > 0 ) 3310 { 3311 assert( rpcSlice->getPocResetIdc() != 2 ); 3312 } 3313 #endif 3314 if( rpcSlice->getPocResetIdc() > 0 ) 3315 { 3316 READ_CODE(6, uiCode, "poc_reset_period_id"); rpcSlice->setPocResetPeriodId(uiCode); 3317 } 3318 else 3319 { 3320 3321 rpcSlice->setPocResetPeriodId( 0 ); 3322 } 3323 3324 if (rpcSlice->getPocResetIdc() == 3) 3325 { 3326 READ_FLAG( uiCode, "full_poc_reset_flag"); rpcSlice->setFullPocResetFlag((uiCode == 1) ? true : false); 3327 READ_CODE(rpcSlice->getSPS()->getBitsForPOC(), uiCode,"poc_lsb_val"); rpcSlice->setPocLsbVal(uiCode); 3328 #if Q0142_POC_LSB_NOT_PRESENT 3329 if ( rpcSlice->getVPS()->getPocLsbNotPresentFlag(rpcSlice->getLayerId()) && rpcSlice->getFullPocResetFlag() ) 3330 { 3331 assert( rpcSlice->getPocLsbVal() == 0 ); 3332 } 3333 #endif 3334 } 3335 3336 // Derive the value of PocMsbValRequiredFlag 3337 rpcSlice->setPocMsbValRequiredFlag( rpcSlice->getCraPicFlag() || rpcSlice->getBlaPicFlag() 3338 /* || related to vps_poc_lsb_aligned_flag */ 3339 ); 3340 3341 if( !rpcSlice->getPocMsbValRequiredFlag() /* vps_poc_lsb_aligned_flag */ ) 3342 { 3343 READ_FLAG( uiCode, "poc_msb_val_present_flag"); rpcSlice->setPocMsbValPresentFlag( uiCode ? true : false ); 3344 } 3345 else 3346 { 3347 #if POC_MSB_VAL_PRESENT_FLAG_SEM 3348 if( sliceHeaderExtensionLength == 0 ) 3349 { 3350 rpcSlice->setPocMsbValPresentFlag( false ); 3351 } 3352 else if( rpcSlice->getPocMsbValRequiredFlag() ) 3353 #else 3354 if( rpcSlice->getPocMsbValRequiredFlag() ) 3355 #endif 3356 { 3357 rpcSlice->setPocMsbValPresentFlag( true ); 3358 } 3359 else 3360 { 3361 rpcSlice->setPocMsbValPresentFlag( false ); 3362 } 3363 } 3364 3365 #if !POC_RESET_IDC_DECODER 3366 Int maxPocLsb = 1 << rpcSlice->getSPS()->getBitsForPOC(); 3367 #endif 3368 if( rpcSlice->getPocMsbValPresentFlag() ) 3369 { 3370 READ_UVLC( uiCode, "poc_msb_val"); rpcSlice->setPocMsbVal( uiCode ); 3371 3372 #if !POC_RESET_IDC_DECODER 3373 // Update POC of the slice based on this MSB val 3374 Int pocLsb = rpcSlice->getPOC() % maxPocLsb; 3375 rpcSlice->setPOC((rpcSlice->getPocMsbVal() * maxPocLsb) + pocLsb); 3376 } 3377 else 3378 { 3379 rpcSlice->setPocMsbVal( rpcSlice->getPOC() / maxPocLsb ); 3380 #endif 3381 } 3382 3383 // Read remaining bits in the slice header extension. 3384 UInt endBits = m_pcBitstream->getNumBitsRead(); 3385 Int counter = (endBits - startBits) % 8; 3386 if( counter ) 3387 { 3388 counter = 8 - counter; 3389 } 3390 3391 while( counter ) 3392 { 3393 #if Q0146_SSH_EXT_DATA_BIT 3394 READ_FLAG( uiCode, "slice_segment_header_extension_data_bit" ); 3395 #else 3396 READ_FLAG( uiCode, "slice_segment_header_extension_reserved_bit" ); assert( uiCode == 1 ); 3397 #endif 3398 counter--; 3399 } 3400 } 3401 #else 3402 if(pps->getSliceHeaderExtensionPresentFlag()) 3403 { 3404 READ_UVLC(uiCode,"slice_header_extension_length"); 3405 for(Int i=0; i<uiCode; i++) 3406 { 3407 UInt ignore; 3408 READ_CODE(8,ignore,"slice_header_extension_data_byte"); 3409 } 3410 } 3411 #endif 3412 m_pcBitstream->readByteAlignment(); 3413 3414 if( pps->getTilesEnabledFlag() || pps->getEntropyCodingSyncEnabledFlag() ) 3415 { 3416 Int endOfSliceHeaderLocation = m_pcBitstream->getByteLocation(); 3417 3418 // Adjust endOfSliceHeaderLocation to account for emulation prevention bytes in the slice segment header 3419 for ( UInt curByteIdx = 0; curByteIdx<m_pcBitstream->numEmulationPreventionBytesRead(); curByteIdx++ ) 3420 { 3421 if ( m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) < endOfSliceHeaderLocation ) 3422 { 3423 endOfSliceHeaderLocation++; 3424 } 3425 } 3426 3427 Int curEntryPointOffset = 0; 3428 Int prevEntryPointOffset = 0; 3429 for (UInt idx=0; idx<numEntryPointOffsets; idx++) 3430 { 3431 curEntryPointOffset += entryPointOffset[ idx ]; 3432 3433 Int emulationPreventionByteCount = 0; 3434 for ( UInt curByteIdx = 0; curByteIdx<m_pcBitstream->numEmulationPreventionBytesRead(); curByteIdx++ ) 3435 { 3436 if ( m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) >= ( prevEntryPointOffset + endOfSliceHeaderLocation ) && 3437 m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) < ( curEntryPointOffset + endOfSliceHeaderLocation ) ) 3438 { 3439 emulationPreventionByteCount++; 3440 } 3441 } 3442 3443 entryPointOffset[ idx ] -= emulationPreventionByteCount; 3444 prevEntryPointOffset = curEntryPointOffset; 3445 } 3446 3447 if ( pps->getTilesEnabledFlag() ) 3448 { 3449 rpcSlice->setTileLocationCount( numEntryPointOffsets ); 3450 3451 UInt prevPos = 0; 3452 for (Int idx=0; idx<rpcSlice->getTileLocationCount(); idx++) 3453 { 3454 rpcSlice->setTileLocation( idx, prevPos + entryPointOffset [ idx ] ); 3455 prevPos += entryPointOffset[ idx ]; 3456 } 3457 } 3458 else if ( pps->getEntropyCodingSyncEnabledFlag() ) 3459 { 3460 Int numSubstreams = rpcSlice->getNumEntryPointOffsets()+1; 3461 rpcSlice->allocSubstreamSizes(numSubstreams); 3462 UInt *pSubstreamSizes = rpcSlice->getSubstreamSizes(); 3463 for (Int idx=0; idx<numSubstreams-1; idx++) 3464 { 3465 if ( idx < numEntryPointOffsets ) 3466 { 3467 pSubstreamSizes[ idx ] = ( entryPointOffset[ idx ] << 3 ) ; 3468 } 3469 else 3470 { 3471 pSubstreamSizes[ idx ] = 0; 3472 } 3473 } 3474 } 3475 3476 if (entryPointOffset) 3477 { 3478 delete [] entryPointOffset; 3479 } 3480 } 3481 3482 return; 3471 pSubstreamSizes[ idx ] = 0; 3472 } 3473 } 3474 } 3475 3476 if (entryPointOffset) 3477 { 3478 delete [] entryPointOffset; 3479 } 3480 } 3481 3482 return; 3483 3483 } 3484 3484 … … 3743 3743 { 3744 3744 #endif 3745 wp[1].uiLog2WeightDenom = uiLog2WeightDenomChroma;3746 wp[2].uiLog2WeightDenom = uiLog2WeightDenomChroma;3745 wp[1].uiLog2WeightDenom = uiLog2WeightDenomChroma; 3746 wp[2].uiLog2WeightDenom = uiLog2WeightDenomChroma; 3747 3747 #if AUXILIARY_PICTURES 3748 3748 } … … 3923 3923 Void TDecCavlc::xParse3DAsymLUT( TCom3DAsymLUT * pc3DAsymLUT ) 3924 3924 { 3925 #if R0150_CGS_SIGNAL_CONSTRAINTS 3926 UInt uiNumRefLayersM1; 3927 READ_UVLC( uiNumRefLayersM1 , "num_cm_ref_layers_minus1" ); 3928 assert( uiNumRefLayersM1 <= 61 ); 3929 for( UInt i = 0 ; i <= uiNumRefLayersM1 ; i++ ) 3930 { 3931 UInt uiRefLayerId; 3932 READ_CODE( 6 , uiRefLayerId , "cm_ref_layer_id" ); 3933 pc3DAsymLUT->addRefLayerId( uiRefLayerId ); 3934 } 3935 #endif 3925 3936 UInt uiCurOctantDepth , uiCurPartNumLog2 , uiInputBitDepthM8 , uiOutputBitDepthM8 , uiResQaunBit; 3926 3937 READ_CODE( 2 , uiCurOctantDepth , "cm_octant_depth" ); 3927 3938 READ_CODE( 2 , uiCurPartNumLog2 , "cm_y_part_num_log2" ); 3939 #if R0150_CGS_SIGNAL_CONSTRAINTS 3940 UInt uiChromaInputBitDepthM8 , uiChromaOutputBitDepthM8; 3941 READ_CODE( 3 , uiInputBitDepthM8 , "cm_input_luma_bit_depth_minus8" ); 3942 READ_CODE( 3 , uiChromaInputBitDepthM8 , "cm_input_chroma_bit_depth_minus8" ); 3943 READ_CODE( 3 , uiOutputBitDepthM8 , "cm_output_luma_bit_depth_minus8" ); 3944 READ_CODE( 3 , uiChromaOutputBitDepthM8 , "cm_output_chroma_bit_depth_minus8" ); 3945 #else 3928 3946 READ_CODE( 3 , uiInputBitDepthM8 , "cm_input_bit_depth_minus8" ); 3929 3947 Int iInputBitDepthCDelta; … … 3932 3950 Int iOutputBitDepthCDelta; 3933 3951 READ_SVLC(iOutputBitDepthCDelta, "cm_output_bit_depth_chroma_delta"); 3952 #endif 3934 3953 READ_CODE( 2 , uiResQaunBit , "cm_res_quant_bit" ); 3954 #if R0151_CGS_3D_ASYMLUT_IMPROVE 3955 #if R0150_CGS_SIGNAL_CONSTRAINTS 3956 Int nAdaptCThresholdU = 1 << ( uiChromaInputBitDepthM8 + 8 - 1 ); 3957 Int nAdaptCThresholdV = 1 << ( uiChromaInputBitDepthM8 + 8 - 1 ); 3958 #else 3959 Int nAdaptCThresholdU = 1 << ( uiInputBitDepthM8 + 8 + iInputBitDepthCDelta - 1 ); 3960 Int nAdaptCThresholdV = 1 << ( uiInputBitDepthM8 + 8 + iInputBitDepthCDelta - 1 ); 3961 #endif 3962 if( uiCurOctantDepth == 1 ) 3963 { 3964 Int delta = 0; 3965 READ_SVLC( delta , "cm_adapt_threshold_u_delta" ); 3966 nAdaptCThresholdU += delta; 3967 READ_SVLC( delta , "cm_adapt_threshold_v_delta" ); 3968 nAdaptCThresholdV += delta; 3969 } 3970 #endif 3935 3971 pc3DAsymLUT->destroy(); 3936 pc3DAsymLUT->create( uiCurOctantDepth , uiInputBitDepthM8 + 8 , uiInputBitDepthM8 + 8 + iInputBitDepthCDelta, uiOutputBitDepthM8 + 8 , uiOutputBitDepthM8 + 8 + iOutputBitDepthCDelta ,uiCurPartNumLog2 ); 3972 pc3DAsymLUT->create( uiCurOctantDepth , uiInputBitDepthM8 + 8 , 3973 #if R0150_CGS_SIGNAL_CONSTRAINTS 3974 uiChromaInputBitDepthM8 + 8 , 3975 #else 3976 uiInputBitDepthM8 + 8 + iInputBitDepthCDelta, 3977 #endif 3978 uiOutputBitDepthM8 + 8 , 3979 #if R0150_CGS_SIGNAL_CONSTRAINTS 3980 uiChromaOutputBitDepthM8 + 8 , 3981 #else 3982 uiOutputBitDepthM8 + 8 + iOutputBitDepthCDelta , 3983 #endif 3984 uiCurPartNumLog2 3985 #if R0151_CGS_3D_ASYMLUT_IMPROVE 3986 , nAdaptCThresholdU , nAdaptCThresholdV 3987 #endif 3988 ); 3937 3989 pc3DAsymLUT->setResQuantBit( uiResQaunBit ); 3938 3990 3991 #if R0164_CGS_LUT_BUGFIX 3992 pc3DAsymLUT->xInitCuboids(); 3993 #endif 3939 3994 xParse3DAsymLUTOctant( pc3DAsymLUT , 0 , 0 , 0 , 0 , 1 << pc3DAsymLUT->getCurOctantDepth() ); 3995 #if R0164_CGS_LUT_BUGFIX 3996 pc3DAsymLUT->xCuboidsExplicitCheck( true ); 3997 #endif 3940 3998 } 3941 3999 … … 3964 4022 for( Int l = 0 ; l < nYPartNum ; l++ ) 3965 4023 { 4024 #if R0164_CGS_LUT_BUGFIX 4025 Int shift = pc3DAsymLUT->getMaxOctantDepth() - nDepth ; 4026 #endif 3966 4027 for( Int nVertexIdx = 0 ; nVertexIdx < 4 ; nVertexIdx++ ) 3967 4028 { … … 3971 4032 if( uiCodeVertex ) 3972 4033 { 4034 #if R0151_CGS_3D_ASYMLUT_IMPROVE 4035 xReadParam( deltaY ); 4036 xReadParam( deltaU ); 4037 xReadParam( deltaV ); 4038 #else 3973 4039 READ_SVLC( deltaY , "resY" ); 3974 4040 READ_SVLC( deltaU , "resU" ); 3975 4041 READ_SVLC( deltaV , "resV" ); 3976 } 4042 #endif 4043 } 4044 #if R0164_CGS_LUT_BUGFIX 4045 pc3DAsymLUT->setCuboidVertexResTree( yIdx + (l<<shift) , uIdx , vIdx , nVertexIdx , deltaY , deltaU , deltaV ); 4046 #else 3977 4047 pc3DAsymLUT->setCuboidVertexResTree( yIdx + l , uIdx , vIdx , nVertexIdx , deltaY , deltaU , deltaV ); 3978 } 3979 } 3980 } 3981 } 4048 #endif 4049 } 4050 #if R0164_CGS_LUT_BUGFIX 4051 pc3DAsymLUT->xSetExplicit( yIdx + (l<<shift) , uIdx , vIdx ); 4052 #endif 4053 } 4054 } 4055 } 4056 4057 #if R0151_CGS_3D_ASYMLUT_IMPROVE 4058 Void TDecCavlc::xReadParam( Int& param ) 4059 { 4060 const UInt rParam = 7; 4061 UInt prefix; 4062 UInt codeWord ; 4063 UInt rSymbol; 4064 UInt sign; 4065 4066 READ_UVLC( prefix, "quotient") ; 4067 READ_CODE (rParam, codeWord, "remainder"); 4068 rSymbol = (prefix<<rParam) + codeWord; 4069 4070 if(rSymbol) 4071 { 4072 READ_FLAG(sign, "sign"); 4073 param = sign ? -(Int)(rSymbol) : (Int)(rSymbol); 4074 } 4075 else param = 0; 4076 } 4077 #endif 3982 4078 #endif 3983 4079 //! \} -
branches/SHM-dev/source/Lib/TLibDecoder/TDecCAVLC.h
r815 r825 143 143 Void xParse3DAsymLUT( TCom3DAsymLUT * pc3DAsymLUT ); 144 144 Void xParse3DAsymLUTOctant( TCom3DAsymLUT * pc3DAsymLUT , Int nDepth , Int yIdx , Int uIdx , Int vIdx , Int nLength ); 145 #if R0151_CGS_3D_ASYMLUT_IMPROVE 146 Void xReadParam( Int& param ); 147 #endif 145 148 #endif 146 149 }; -
branches/SHM-dev/source/Lib/TLibDecoder/TDecTop.cpp
r823 r825 1779 1779 #if Q0048_CGS_3D_ASYMLUT 1780 1780 TComPicYuv* pBaseColRec = pcSlice->getBaseColPic(refLayerIdc)->getPicYuvRec(); 1781 if( pcSlice->getPPS()->getCGSFlag() ) 1782 { 1781 if( pcSlice->getPPS()->getCGSFlag() 1782 #if R0150_CGS_SIGNAL_CONSTRAINTS 1783 && m_c3DAsymLUTPPS.isRefLayer( pcSlice->getVPS()->getRefLayerId(m_layerId, refLayerIdc) ) 1784 #endif 1785 ) 1786 { 1787 #if R0150_CGS_SIGNAL_CONSTRAINTS 1788 assert( pcSlice->getBaseColPic( refLayerIdc )->getSlice( 0 )->getBitDepthY() == m_c3DAsymLUTPPS.getInputBitDepthY() ); 1789 assert( pcSlice->getBaseColPic( refLayerIdc )->getSlice( 0 )->getBitDepthC() == m_c3DAsymLUTPPS.getInputBitDepthC() ); 1790 assert( pcSlice->getBitDepthY() >= m_c3DAsymLUTPPS.getOutputBitDepthY() ); 1791 assert( pcSlice->getBitDepthY() >= m_c3DAsymLUTPPS.getOutputBitDepthC() ); 1792 #endif 1783 1793 if(!m_pColorMappedPic) 1784 1794 {
Note: See TracChangeset for help on using the changeset viewer.