Changeset 916 in SHVCSoftware for branches/SHM-upgrade/source/Lib/TLibDecoder/TDecCAVLC.cpp
- Timestamp:
- 12 Nov 2014, 08:09:17 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/SHM-upgrade/source/Lib/TLibDecoder/TDecCAVLC.cpp
r914 r916 39 39 #include "SEIread.h" 40 40 #include "TDecSlice.h" 41 #include "TLibCommon/TComChromaFormat.h" 42 #if RExt__DECODER_DEBUG_BIT_STATISTICS 43 #include "TLibCommon/TComCodingStatistics.h" 44 #endif 41 45 #if Q0048_CGS_3D_ASYMLUT 42 46 #include "../TLibCommon/TCom3DAsymLUT.h" … … 82 86 // ==================================================================================================================== 83 87 84 void TDecCavlc::parseShortTermRefPicSet( TComSPS* sps, TComReferencePictureSet* rps, Int idx )88 Void TDecCavlc::parseShortTermRefPicSet( TComSPS* sps, TComReferencePictureSet* rps, Int idx ) 85 89 { 86 90 UInt code; … … 178 182 } 179 183 180 Void TDecCavlc::parsePPS(TComPPS* pcPPS181 184 #if Q0048_CGS_3D_ASYMLUT 182 , TCom3DAsymLUT * pc3DAsymLUT , Int nLayerID 183 #endif 184 ) 185 Void TDecCavlc::parsePPS(TComPPS* pcPPS, TCom3DAsymLUT * pc3DAsymLUT , Int nLayerID) 186 #else 187 Void TDecCavlc::parsePPS(TComPPS* pcPPS) 188 #endif 189 185 190 { 186 191 #if ENC_DEC_TRACE … … 200 205 201 206 READ_FLAG( uiCode, "dependent_slice_segments_enabled_flag" ); pcPPS->setDependentSliceSegmentsEnabledFlag ( uiCode == 1 ); 207 202 208 READ_FLAG( uiCode, "output_flag_present_flag" ); pcPPS->setOutputFlagPresentFlag( uiCode==1 ); 203 209 204 210 READ_CODE(3, uiCode, "num_extra_slice_header_bits"); pcPPS->setNumExtraSliceHeaderBits(uiCode); 211 205 212 READ_FLAG ( uiCode, "sign_data_hiding_flag" ); pcPPS->setSignHideFlag( uiCode ); 206 213 … … 231 238 } 232 239 READ_SVLC( iCode, "pps_cb_qp_offset"); 233 pcPPS->set ChromaCbQpOffset(iCode);234 assert( pcPPS->get ChromaCbQpOffset() >= -12 );235 assert( pcPPS->get ChromaCbQpOffset() <= 12 );240 pcPPS->setQpOffset(COMPONENT_Cb, iCode); 241 assert( pcPPS->getQpOffset(COMPONENT_Cb) >= -12 ); 242 assert( pcPPS->getQpOffset(COMPONENT_Cb) <= 12 ); 236 243 237 244 READ_SVLC( iCode, "pps_cr_qp_offset"); 238 pcPPS->setChromaCrQpOffset(iCode); 239 assert( pcPPS->getChromaCrQpOffset() >= -12 ); 240 assert( pcPPS->getChromaCrQpOffset() <= 12 ); 245 pcPPS->setQpOffset(COMPONENT_Cr, iCode); 246 assert( pcPPS->getQpOffset(COMPONENT_Cr) >= -12 ); 247 assert( pcPPS->getQpOffset(COMPONENT_Cr) <= 12 ); 248 249 assert(MAX_NUM_COMPONENT<=3); 241 250 242 251 READ_FLAG( uiCode, "pps_slice_chroma_qp_offsets_present_flag" ); … … 259 268 READ_FLAG ( uiCode, "uniform_spacing_flag" ); pcPPS->setTileUniformSpacingFlag( uiCode == 1 ); 260 269 261 if( !pcPPS->getTileUniformSpacingFlag()) 262 { 263 std::vector<Int> columnWidth(pcPPS->getNumTileColumnsMinus1()); 264 for(UInt i=0; i<pcPPS->getNumTileColumnsMinus1(); i++) 265 { 266 READ_UVLC( uiCode, "column_width_minus1" ); 267 columnWidth[i] = uiCode+1; 268 } 269 pcPPS->setTileColumnWidth(columnWidth); 270 271 std::vector<Int> rowHeight (pcPPS->getTileNumRowsMinus1()); 272 for(UInt i=0; i<pcPPS->getTileNumRowsMinus1(); i++) 273 { 274 READ_UVLC( uiCode, "row_height_minus1" ); 275 rowHeight[i] = uiCode + 1; 276 } 277 pcPPS->setTileRowHeight(rowHeight); 278 } 279 280 if(pcPPS->getNumTileColumnsMinus1() !=0 || pcPPS->getTileNumRowsMinus1() !=0) 270 const UInt tileColumnsMinus1 = pcPPS->getNumTileColumnsMinus1(); 271 const UInt tileRowsMinus1 = pcPPS->getNumTileRowsMinus1(); 272 273 if ( !pcPPS->getTileUniformSpacingFlag()) 274 { 275 if (tileColumnsMinus1 > 0) 276 { 277 std::vector<Int> columnWidth(tileColumnsMinus1); 278 for(UInt i = 0; i < tileColumnsMinus1; i++) 279 { 280 READ_UVLC( uiCode, "column_width_minus1" ); 281 columnWidth[i] = uiCode+1; 282 } 283 pcPPS->setTileColumnWidth(columnWidth); 284 } 285 286 if (tileRowsMinus1 > 0) 287 { 288 std::vector<Int> rowHeight (tileRowsMinus1); 289 for(UInt i = 0; i < tileRowsMinus1; i++) 290 { 291 READ_UVLC( uiCode, "row_height_minus1" ); 292 rowHeight[i] = uiCode + 1; 293 } 294 pcPPS->setTileRowHeight(rowHeight); 295 } 296 } 297 298 if ((tileColumnsMinus1 + tileRowsMinus1) != 0) 281 299 { 282 300 READ_FLAG ( uiCode, "loop_filter_across_tiles_enabled_flag" ); pcPPS->setLoopFilterAcrossTilesEnabledFlag( uiCode ? true : false ); … … 295 313 } 296 314 } 297 #if !R0042_PROFILE_INDICATION 298 #if SCALINGLIST_INFERRING 299 if( pcPPS->getLayerId() > 0 ) 300 { 301 READ_FLAG( uiCode, "pps_infer_scaling_list_flag" ); 302 pcPPS->setInferScalingListFlag( uiCode ); 303 } 304 305 if( pcPPS->getInferScalingListFlag() ) 306 { 307 READ_UVLC( uiCode, "pps_scaling_list_ref_layer_id" ); pcPPS->setScalingListRefLayerId( uiCode ); 308 309 // The value of pps_scaling_list_ref_layer_id shall be in the range of 0 to 62, inclusive 310 assert( pcPPS->getScalingListRefLayerId() <= 62 ); 311 312 pcPPS->setScalingListPresentFlag( false ); 313 } 314 else 315 { 316 #endif 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 326 #if SCALINGLIST_INFERRING 327 } 328 #endif 329 #endif 315 READ_FLAG( uiCode, "pps_scaling_list_data_present_flag" ); pcPPS->setScalingListPresentFlag( uiCode ? true : false ); 316 if(pcPPS->getScalingListPresentFlag ()) 317 { 318 parseScalingList( pcPPS->getScalingList() ); 319 } 330 320 331 321 READ_FLAG( uiCode, "lists_modification_present_flag"); … … 338 328 pcPPS->setSliceHeaderExtensionPresentFlag(uiCode); 339 329 340 #if !R0042_PROFILE_INDICATION341 READ_FLAG( uiCode, "pps_extension_flag");342 #else343 330 READ_FLAG( uiCode, "pps_extension_present_flag"); 344 #endif 345 346 #if !R0042_PROFILE_INDICATION 347 #if POC_RESET_INFO_INFERENCE 348 pcPPS->setExtensionFlag( uiCode ? true : false ); 349 350 if( pcPPS->getExtensionFlag() ) 351 #else 352 if (uiCode) 353 #endif 354 { 355 #if P0166_MODIFIED_PPS_EXTENSION 356 UInt ppsExtensionTypeFlag[8]; 357 for (UInt i = 0; i < 8; i++) 358 { 359 READ_FLAG( ppsExtensionTypeFlag[i], "pps_extension_type_flag" ); 360 } 361 #if !POC_RESET_IDC 362 if (ppsExtensionTypeFlag[1]) 363 { 364 #else 365 if( ppsExtensionTypeFlag[0] ) 366 { 367 READ_FLAG( uiCode, "poc_reset_info_present_flag" ); 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 425 #if Q0048_CGS_3D_ASYMLUT 426 READ_FLAG( uiCode , "colour_mapping_enabled_flag" ); 427 pcPPS->setCGSFlag( uiCode ); 428 if( pcPPS->getCGSFlag() ) 429 { 430 xParse3DAsymLUT( pc3DAsymLUT ); 431 pcPPS->setCGSOutputBitDepthY( pc3DAsymLUT->getOutputBitDepthY() ); 432 pcPPS->setCGSOutputBitDepthC( pc3DAsymLUT->getOutputBitDepthC() ); 433 } 434 #endif 435 #endif 436 } 437 #if POC_RESET_INFO_INFERENCE 438 else // Extension type 0 absent 439 { 440 pcPPS->setPocResetInfoPresentFlag( false ); 441 } 442 #endif 443 if (ppsExtensionTypeFlag[7]) 444 { 445 #endif 446 447 while ( xMoreRbspData() ) 448 { 449 READ_FLAG( uiCode, "pps_extension_data_flag"); 450 } 451 #if P0166_MODIFIED_PPS_EXTENSION 452 } 453 #endif 454 } 455 #if POC_RESET_INFO_INFERENCE 456 if( !pcPPS->getExtensionFlag() ) 457 { 458 pcPPS->setPocResetInfoPresentFlag( false ); 459 } 460 #endif 461 #else 331 332 #if SVC_EXTENSION 462 333 pcPPS->setExtensionFlag( uiCode ? true : false ); 463 334 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); 335 #else 336 if (uiCode) 337 #endif 338 { 339 Bool pps_extension_flags[NUM_PPS_EXTENSION_FLAGS]; 340 for(Int i=0; i<NUM_PPS_EXTENSION_FLAGS; i++) 341 { 342 READ_FLAG( uiCode, "pps_extension_flag[]" ); 343 pps_extension_flags[i] = uiCode!=0; 344 } 345 346 Bool bSkipTrailingExtensionBits=false; 347 for(Int i=0; i<NUM_PPS_EXTENSION_FLAGS; i++) // loop used so that the order is determined by the enum. 348 { 349 if (pps_extension_flags[i]) 350 { 351 switch (PPSExtensionFlagIndex(i)) 352 { 353 case PPS_EXT__REXT: 354 assert(!bSkipTrailingExtensionBits); 355 356 if (pcPPS->getUseTransformSkip()) 357 { 358 READ_UVLC( uiCode, "log2_transform_skip_max_size_minus2"); 359 pcPPS->setTransformSkipLog2MaxSize(uiCode+2); 360 } 361 362 READ_FLAG( uiCode, "cross_component_prediction_flag"); 363 pcPPS->setUseCrossComponentPrediction(uiCode != 0); 364 365 READ_FLAG( uiCode, "chroma_qp_adjustment_enabled_flag"); 366 if (uiCode == 0) 367 { 368 pcPPS->clearChromaQpAdjTable(); 369 pcPPS->setMaxCuChromaQpAdjDepth(0); 370 } 371 else 372 { 373 READ_UVLC(uiCode, "diff_cu_chroma_qp_adjustment_depth"); pcPPS->setMaxCuChromaQpAdjDepth(uiCode); 374 UInt tableSizeMinus1 = 0; 375 READ_UVLC(tableSizeMinus1, "chroma_qp_adjustment_table_size_minus1"); 376 /* skip zero index */ 377 for (Int chromaQpAdjustmentIndex = 1; chromaQpAdjustmentIndex <= (tableSizeMinus1 + 1); chromaQpAdjustmentIndex++) 378 { 379 Int cbOffset; 380 Int crOffset; 381 READ_SVLC(cbOffset, "cb_qp_adjustnemt[i]"); 382 READ_SVLC(crOffset, "cr_qp_adjustnemt[i]"); 383 pcPPS->setChromaQpAdjTableAt(chromaQpAdjustmentIndex, cbOffset, crOffset); 384 } 385 assert(pcPPS->getChromaQpAdjTableSize() == tableSizeMinus1 + 1); 386 } 387 388 READ_UVLC( uiCode, "sao_luma_bit_shift"); 389 pcPPS->setSaoOffsetBitShift(CHANNEL_TYPE_LUMA, uiCode); 390 READ_UVLC( uiCode, "sao_chroma_bit_shift"); 391 pcPPS->setSaoOffsetBitShift(CHANNEL_TYPE_CHROMA, uiCode); 392 break; 393 394 #if SVC_EXTENSION 395 case PPS_EXT__MLAYER: 396 READ_FLAG( uiCode, "poc_reset_info_present_flag" ); 397 pcPPS->setPocResetInfoPresentFlag(uiCode ? true : false); 474 398 475 399 #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, inclusive484 assert( pcPPS->getScalingListRefLayerId() <= 62 );485 pcPPS->setScalingListPresentFlag( false );486 }400 READ_FLAG( uiCode, "pps_infer_scaling_list_flag" ); 401 pcPPS->setInferScalingListFlag( uiCode ); 402 403 if( pcPPS->getInferScalingListFlag() ) 404 { 405 READ_UVLC( uiCode, "pps_scaling_list_ref_layer_id" ); 406 pcPPS->setScalingListRefLayerId( uiCode ); 407 // The value of pps_scaling_list_ref_layer_id shall be in the range of 0 to 62, inclusive 408 assert( pcPPS->getScalingListRefLayerId() <= 62 ); 409 pcPPS->setScalingListPresentFlag( false ); 410 } 487 411 #endif 488 412 489 413 #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);414 READ_UVLC( uiCode, "num_ref_loc_offsets" ); pcPPS->setNumScaledRefLayerOffsets(uiCode); 415 for(Int i = 0; i < pcPPS->getNumScaledRefLayerOffsets(); i++) 416 { 417 READ_CODE( 6, uiCode, "ref_loc_offset_layer_id" ); pcPPS->setScaledRefLayerId( i, uiCode ); 418 READ_FLAG( uiCode, "scaled_ref_layer_offset_present_flag" ); pcPPS->setScaledRefLayerOffsetPresentFlag( i, uiCode ); 419 if (uiCode) 420 { 421 Window& scaledWindow = pcPPS->getScaledRefLayerWindow(i); 422 READ_SVLC( iCode, "scaled_ref_layer_left_offset" ); scaledWindow.setWindowLeftOffset (iCode << 1); 423 READ_SVLC( iCode, "scaled_ref_layer_top_offset" ); scaledWindow.setWindowTopOffset (iCode << 1); 424 READ_SVLC( iCode, "scaled_ref_layer_right_offset" ); scaledWindow.setWindowRightOffset (iCode << 1); 425 READ_SVLC( iCode, "scaled_ref_layer_bottom_offset" ); scaledWindow.setWindowBottomOffset(iCode << 1); 502 426 #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 }427 READ_FLAG( uiCode, "vert_phase_position_enable_flag" ); scaledWindow.setVertPhasePositionEnableFlag(uiCode); pcPPS->setVertPhasePositionEnableFlag( pcPPS->getScaledRefLayerId(i), uiCode); 428 #endif 429 } 430 READ_FLAG( uiCode, "ref_region_offset_present_flag" ); pcPPS->setRefRegionOffsetPresentFlag( i, uiCode ); 431 if (uiCode) 432 { 433 Window& refWindow = pcPPS->getRefLayerWindow(i); 434 READ_SVLC( iCode, "ref_region_left_offset" ); refWindow.setWindowLeftOffset (iCode << 1); 435 READ_SVLC( iCode, "ref_region_top_offset" ); refWindow.setWindowTopOffset (iCode << 1); 436 READ_SVLC( iCode, "ref_region_right_offset" ); refWindow.setWindowRightOffset (iCode << 1); 437 READ_SVLC( iCode, "ref_region_bottom_offset" ); refWindow.setWindowBottomOffset(iCode << 1); 438 } 515 439 #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 }440 READ_FLAG( uiCode, "resample_phase_set_present_flag" ); pcPPS->setResamplePhaseSetPresentFlag( i, uiCode ); 441 if (uiCode) 442 { 443 READ_UVLC( uiCode, "phase_hor_luma" ); pcPPS->setPhaseHorLuma ( i, uiCode ); 444 READ_UVLC( uiCode, "phase_ver_luma" ); pcPPS->setPhaseVerLuma ( i, uiCode ); 445 READ_UVLC( uiCode, "phase_hor_chroma_plus8" ); pcPPS->setPhaseHorChroma (i, uiCode - 8); 446 READ_UVLC( uiCode, "phase_ver_chroma_plus8" ); pcPPS->setPhaseVerChroma (i, uiCode - 8); 447 } 448 #endif 449 } 526 450 #else 527 451 #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);452 READ_UVLC( uiCode, "num_scaled_ref_layer_offsets" ); pcPPS->setNumScaledRefLayerOffsets(uiCode); 453 for(Int i = 0; i < pcPPS->getNumScaledRefLayerOffsets(); i++) 454 { 455 Window& scaledWindow = pcPPS->getScaledRefLayerWindow(i); 532 456 #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);457 READ_CODE( 6, uiCode, "scaled_ref_layer_id" ); pcPPS->setScaledRefLayerId( i, uiCode ); 458 #endif 459 READ_SVLC( iCode, "scaled_ref_layer_left_offset" ); scaledWindow.setWindowLeftOffset (iCode << 1); 460 READ_SVLC( iCode, "scaled_ref_layer_top_offset" ); scaledWindow.setWindowTopOffset (iCode << 1); 461 READ_SVLC( iCode, "scaled_ref_layer_right_offset" ); scaledWindow.setWindowRightOffset (iCode << 1); 462 READ_SVLC( iCode, "scaled_ref_layer_bottom_offset" ); scaledWindow.setWindowBottomOffset(iCode << 1); 539 463 #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 }464 READ_FLAG( uiCode, "vert_phase_position_enable_flag" ); scaledWindow.setVertPhasePositionEnableFlag(uiCode); pcPPS->setVertPhasePositionEnableFlag( pcPPS->getScaledRefLayerId(i), uiCode); 465 #endif 466 } 543 467 #endif 544 468 #endif 545 469 #if Q0048_CGS_3D_ASYMLUT 546 READ_FLAG( uiCode , "colour_mapping_enabled_flag" );547 pcPPS->setCGSFlag( uiCode );548 if( pcPPS->getCGSFlag() )549 {470 READ_FLAG( uiCode , "colour_mapping_enabled_flag" ); 471 pcPPS->setCGSFlag( uiCode ); 472 if( pcPPS->getCGSFlag() ) 473 { 550 474 #if R0157_RESTRICT_PPSID_FOR_CGS_LUT 551 // when pps_pic_parameter_set_id greater than or equal to 8, colour_mapping_enabled_flag shall be equal to 0 552 assert( pcPPS->getPPSId() < 8 ); 553 #endif 554 xParse3DAsymLUT( pc3DAsymLUT ); 555 pcPPS->setCGSOutputBitDepthY( pc3DAsymLUT->getOutputBitDepthY() ); 556 pcPPS->setCGSOutputBitDepthC( pc3DAsymLUT->getOutputBitDepthC() ); 557 } 558 #endif 559 } 560 #endif 561 475 // when pps_pic_parameter_set_id greater than or equal to 8, colour_mapping_enabled_flag shall be equal to 0 476 assert( pcPPS->getPPSId() < 8 ); 477 #endif 478 xParse3DAsymLUT( pc3DAsymLUT ); 479 pcPPS->setCGSOutputBitDepthY( pc3DAsymLUT->getOutputBitDepthY() ); 480 pcPPS->setCGSOutputBitDepthC( pc3DAsymLUT->getOutputBitDepthC() ); 481 } 482 #endif 483 break; 484 #endif 485 default: 486 bSkipTrailingExtensionBits=true; 487 break; 488 } 489 } 490 } 491 if (bSkipTrailingExtensionBits) 492 { 493 while ( xMoreRbspData() ) 494 { 495 READ_FLAG( uiCode, "pps_extension_data_flag"); 496 } 497 } 498 } 562 499 } 563 500 … … 622 559 READ_UVLC( uiCode, "def_disp_win_bottom_offset" ); defDisp.setWindowBottomOffset( uiCode * TComSPS::getWinUnitY( pcSPS->getChromaFormatIdc()) ); 623 560 } 561 624 562 TimingInfo *timingInfo = pcVUI->getTimingInfo(); 625 563 READ_FLAG( uiCode, "vui_timing_info_present_flag"); timingInfo->setTimingInfoPresentFlag (uiCode ? true : false); … … 639 577 READ_UVLC( uiCode, "vui_num_ticks_poc_diff_one_minus1"); timingInfo->setNumTicksPocDiffOneMinus1 (uiCode); 640 578 } 579 641 580 READ_FLAG( uiCode, "hrd_parameters_present_flag"); pcVUI->setHrdParametersPresentFlag(uiCode); 642 581 if( pcVUI->getHrdParametersPresentFlag() ) … … 645 584 } 646 585 } 586 647 587 READ_FLAG( uiCode, "bitstream_restriction_flag"); pcVUI->setBitstreamRestrictionFlag(uiCode); 648 588 if (pcVUI->getBitstreamRestrictionFlag()) … … 707 647 hrd->setFixedPicRateWithinCvsFlag( i, true ); 708 648 } 649 709 650 hrd->setLowDelayHrdFlag( i, 0 ); // Infered to be 0 when not present 710 651 hrd->setCpbCntMinus1 ( i, 0 ); // Infered to be 0 when not present 652 711 653 if( hrd->getFixedPicRateWithinCvsFlag( i ) ) 712 654 { … … 721 663 READ_UVLC( uiCode, "cpb_cnt_minus1" ); hrd->setCpbCntMinus1( i, uiCode ); 722 664 } 665 723 666 for( nalOrVcl = 0; nalOrVcl < 2; nalOrVcl ++ ) 724 667 { 725 668 if( ( ( nalOrVcl == 0 ) && ( hrd->getNalHrdParametersPresentFlag() ) ) || 726 ( ( nalOrVcl == 1 ) && ( hrd->getVclHrdParametersPresentFlag() ) ) )669 ( ( nalOrVcl == 1 ) && ( hrd->getVclHrdParametersPresentFlag() ) ) ) 727 670 { 728 671 for( j = 0; j <= ( hrd->getCpbCntMinus1( i ) ); j ++ ) … … 742 685 } 743 686 744 #if SVC_EXTENSION && !SPS_DPB_PARAMS745 Void TDecCavlc::parseSPS(TComSPS* pcSPS, ParameterSetManagerDecoder *parameterSetManager)746 #else747 687 Void TDecCavlc::parseSPS(TComSPS* pcSPS) 748 #endif749 688 { 750 689 #if ENC_DEC_TRACE … … 752 691 #endif 753 692 754 #if R0042_PROFILE_INDICATION755 UInt uiTmp = 0;756 Bool bMultiLayerExtSpsFlag;757 #endif758 693 UInt uiCode; 759 694 READ_CODE( 4, uiCode, "sps_video_parameter_set_id"); pcSPS->setVPSId ( uiCode ); 695 760 696 #if SVC_EXTENSION 697 UInt uiTmp = 0; 698 761 699 if(pcSPS->getLayerId() == 0) 762 700 { 763 701 #endif 764 765 702 READ_CODE( 3, uiCode, "sps_max_sub_layers_minus1" ); pcSPS->setMaxTLayers ( uiCode+1 ); 703 assert(uiCode <= 6); 766 704 #if SVC_EXTENSION 767 705 } 768 #if R0042_PROFILE_INDICATION769 706 else 770 707 { 771 708 READ_CODE( 3, uiCode, "sps_ext_or_max_sub_layers_minus1" ); uiTmp = uiCode; 772 709 } 773 #endif 774 #if !SPS_DPB_PARAMS 775 if(pcSPS->getLayerId() != 0) 776 { 777 pcSPS->setMaxTLayers ( parameterSetManager->getPrefetchedVPS(pcSPS->getVPSId())->getMaxTLayers() ); 778 } 779 #endif 780 #endif 781 710 711 Bool V1CompatibleSPSFlag = !( pcSPS->getLayerId() != 0 && uiTmp == 7 ); 712 713 if( V1CompatibleSPSFlag ) 714 { 715 #endif 716 READ_FLAG( uiCode, "sps_temporal_id_nesting_flag" ); pcSPS->setTemporalIdNestingFlag ( uiCode > 0 ? true : false ); 717 parsePTL(pcSPS->getPTL(), 1, pcSPS->getMaxTLayers() - 1); 782 718 #if SVC_EXTENSION 783 #if R0042_PROFILE_INDICATION 784 bMultiLayerExtSpsFlag = ( pcSPS->getLayerId() != 0 && uiTmp == 7 ); 785 #endif 786 #endif 787 788 #if SVC_EXTENSION 789 #if !R0042_PROFILE_INDICATION 790 if(pcSPS->getLayerId() == 0) 791 #else 792 if(!bMultiLayerExtSpsFlag) 793 #endif 794 { 795 #endif 796 READ_FLAG( uiCode, "sps_temporal_id_nesting_flag" ); pcSPS->setTemporalIdNestingFlag ( uiCode > 0 ? true : false ); 797 #if SVC_EXTENSION 798 } 799 #if !SPS_DPB_PARAMS 800 else 801 { 802 pcSPS->setTemporalIdNestingFlag( parameterSetManager->getPrefetchedVPS(pcSPS->getVPSId())->getTemporalNestingFlag() ); 803 } 804 #endif 805 #endif 806 807 #if !Q0177_SPS_TEMP_NESTING_FIX //This part is not needed anymore as it is already covered by implementation in TDecTop::xActivateParameterSets() 719 } 720 #else 808 721 if ( pcSPS->getMaxTLayers() == 1 ) 809 722 { 810 723 // sps_temporal_id_nesting_flag must be 1 when sps_max_sub_layers_minus1 is 0 811 #if SVC_EXTENSION812 #if !SPS_DPB_PARAMS813 assert( pcSPS->getTemporalIdNestingFlag() == true );814 #endif815 #else816 724 assert( uiCode == 1 ); 817 #endif 818 } 819 #endif 820 821 #ifdef SPS_PTL_FIX 822 #if !R0042_PROFILE_INDICATION 823 if ( pcSPS->getLayerId() == 0) 824 #else 825 if(!bMultiLayerExtSpsFlag) 826 #endif 827 { 828 parsePTL(pcSPS->getPTL(), 1, pcSPS->getMaxTLayers() - 1); 829 } 830 #else 831 parsePTL(pcSPS->getPTL(), 1, pcSPS->getMaxTLayers() - 1); 725 } 832 726 #endif 833 727 … … 835 729 assert(uiCode <= 15); 836 730 837 #if REPN_FORMAT_IN_VPS 838 #if !R0042_PROFILE_INDICATION 839 if( pcSPS->getLayerId() > 0 ) 840 #else 841 if( bMultiLayerExtSpsFlag) 842 #endif 731 #if SVC_EXTENSION 732 if( !V1CompatibleSPSFlag ) 843 733 { 844 734 READ_FLAG( uiCode, "update_rep_format_flag" ); 845 735 pcSPS->setUpdateRepFormatFlag( uiCode ? true : false ); 846 #if R0042_PROFILE_INDICATION847 if( bMultiLayerExtSpsFlag && uiCode)736 737 if( pcSPS->getUpdateRepFormatFlag() ) 848 738 { 849 739 READ_CODE(8, uiCode, "sps_rep_format_idx"); 850 740 pcSPS->setUpdateRepFormatIndex(uiCode); 851 741 } 852 #endif853 742 } 854 743 else 855 744 { 856 #if REP_FORMAT_FIX857 745 pcSPS->setUpdateRepFormatFlag( false ); 858 #else 859 pcSPS->setUpdateRepFormatFlag( true ); 860 #endif 861 } 862 863 #if R0042_PROFILE_INDICATION 864 if( !bMultiLayerExtSpsFlag ) 865 { 866 #else 867 #if O0096_REP_FORMAT_INDEX 868 if( pcSPS->getLayerId() == 0 ) 869 #else 870 if( pcSPS->getLayerId() == 0 || pcSPS->getUpdateRepFormatFlag() ) 871 #endif 872 #endif 873 { 874 #endif 875 #if AUXILIARY_PICTURES 876 READ_UVLC( uiCode, "chroma_format_idc" ); pcSPS->setChromaFormatIdc( ChromaFormat(uiCode) ); 877 #else 878 READ_UVLC( uiCode, "chroma_format_idc" ); pcSPS->setChromaFormatIdc( uiCode ); 879 #endif 880 assert(uiCode <= 3); 881 // in the first version we only support chroma_format_idc equal to 1 (4:2:0), so separate_colour_plane_flag cannot appear in the bitstream 882 assert (uiCode == 1); 883 if( uiCode == 3 ) 884 { 885 READ_FLAG( uiCode, "separate_colour_plane_flag"); assert(uiCode == 0); 886 } 887 888 READ_UVLC ( uiCode, "pic_width_in_luma_samples" ); pcSPS->setPicWidthInLumaSamples ( uiCode ); 889 READ_UVLC ( uiCode, "pic_height_in_luma_samples" ); pcSPS->setPicHeightInLumaSamples( uiCode ); 746 #endif 747 READ_UVLC( uiCode, "chroma_format_idc" ); pcSPS->setChromaFormatIdc( ChromaFormat(uiCode) ); 748 assert(uiCode <= 3); 749 750 if( pcSPS->getChromaFormatIdc() == CHROMA_444 ) 751 { 752 READ_FLAG( uiCode, "separate_colour_plane_flag"); assert(uiCode == 0); 753 } 754 755 READ_UVLC ( uiCode, "pic_width_in_luma_samples" ); pcSPS->setPicWidthInLumaSamples ( uiCode ); 756 READ_UVLC ( uiCode, "pic_height_in_luma_samples" ); pcSPS->setPicHeightInLumaSamples( uiCode ); 757 READ_FLAG( uiCode, "conformance_window_flag"); 758 if (uiCode != 0) 759 { 760 Window &conf = pcSPS->getConformanceWindow(); 890 761 #if REPN_FORMAT_IN_VPS 891 } 892 #if O0096_REP_FORMAT_INDEX 893 #if !R0042_PROFILE_INDICATION 894 else if ( pcSPS->getUpdateRepFormatFlag() ) 895 { 896 READ_CODE(8, uiCode, "update_rep_format_index"); 897 pcSPS->setUpdateRepFormatIndex(uiCode); 898 } 899 #endif 900 #endif 901 #endif 902 903 #if R0156_CONF_WINDOW_IN_REP_FORMAT 904 #if REPN_FORMAT_IN_VPS 905 #if !R0042_PROFILE_INDICATION 906 #if O0096_REP_FORMAT_INDEX 907 if( pcSPS->getLayerId() == 0 ) 908 #else 909 if( pcSPS->getLayerId() == 0 || pcSPS->getUpdateRepFormatFlag() ) 910 #endif 911 #endif 912 { 913 #endif 914 #endif 915 READ_FLAG( uiCode, "conformance_window_flag"); 916 if (uiCode != 0) 917 { 918 Window &conf = pcSPS->getConformanceWindow(); 919 #if REPN_FORMAT_IN_VPS 920 READ_UVLC( uiCode, "conf_win_left_offset" ); conf.setWindowLeftOffset ( uiCode ); 921 READ_UVLC( uiCode, "conf_win_right_offset" ); conf.setWindowRightOffset ( uiCode ); 922 READ_UVLC( uiCode, "conf_win_top_offset" ); conf.setWindowTopOffset ( uiCode ); 923 READ_UVLC( uiCode, "conf_win_bottom_offset" ); conf.setWindowBottomOffset( uiCode ); 924 #else 925 READ_UVLC( uiCode, "conf_win_left_offset" ); conf.setWindowLeftOffset ( uiCode * TComSPS::getWinUnitX( pcSPS->getChromaFormatIdc() ) ); 926 READ_UVLC( uiCode, "conf_win_right_offset" ); conf.setWindowRightOffset ( uiCode * TComSPS::getWinUnitX( pcSPS->getChromaFormatIdc() ) ); 927 READ_UVLC( uiCode, "conf_win_top_offset" ); conf.setWindowTopOffset ( uiCode * TComSPS::getWinUnitY( pcSPS->getChromaFormatIdc() ) ); 928 READ_UVLC( uiCode, "conf_win_bottom_offset" ); conf.setWindowBottomOffset( uiCode * TComSPS::getWinUnitY( pcSPS->getChromaFormatIdc() ) ); 929 #endif 930 } 931 #if R0156_CONF_WINDOW_IN_REP_FORMAT 932 #if REPN_FORMAT_IN_VPS 933 } 934 #endif 935 #endif 936 937 #if REPN_FORMAT_IN_VPS 938 #if !R0042_PROFILE_INDICATION 939 #if O0096_REP_FORMAT_INDEX 940 if( pcSPS->getLayerId() == 0 ) 941 #else 942 if( pcSPS->getLayerId() == 0 || pcSPS->getUpdateRepFormatFlag() ) 943 #endif 944 #endif 945 { 946 #endif 947 READ_UVLC( uiCode, "bit_depth_luma_minus8" ); 948 assert(uiCode <= 6); 949 pcSPS->setBitDepthY( uiCode + 8 ); 950 pcSPS->setQpBDOffsetY( (Int) (6*uiCode) ); 951 952 READ_UVLC( uiCode, "bit_depth_chroma_minus8" ); 953 assert(uiCode <= 6); 954 pcSPS->setBitDepthC( uiCode + 8 ); 955 pcSPS->setQpBDOffsetC( (Int) (6*uiCode) ); 956 #if REPN_FORMAT_IN_VPS 957 } 958 #endif 959 #if R0042_PROFILE_INDICATION 960 } 961 #endif 762 READ_UVLC( uiCode, "conf_win_left_offset" ); conf.setWindowLeftOffset ( uiCode ); 763 READ_UVLC( uiCode, "conf_win_right_offset" ); conf.setWindowRightOffset ( uiCode ); 764 READ_UVLC( uiCode, "conf_win_top_offset" ); conf.setWindowTopOffset ( uiCode ); 765 READ_UVLC( uiCode, "conf_win_bottom_offset" ); conf.setWindowBottomOffset( uiCode ); 766 #else 767 READ_UVLC( uiCode, "conf_win_left_offset" ); conf.setWindowLeftOffset ( uiCode * TComSPS::getWinUnitX( pcSPS->getChromaFormatIdc() ) ); 768 READ_UVLC( uiCode, "conf_win_right_offset" ); conf.setWindowRightOffset ( uiCode * TComSPS::getWinUnitX( pcSPS->getChromaFormatIdc() ) ); 769 READ_UVLC( uiCode, "conf_win_top_offset" ); conf.setWindowTopOffset ( uiCode * TComSPS::getWinUnitY( pcSPS->getChromaFormatIdc() ) ); 770 READ_UVLC( uiCode, "conf_win_bottom_offset" ); conf.setWindowBottomOffset( uiCode * TComSPS::getWinUnitY( pcSPS->getChromaFormatIdc() ) ); 771 #endif 772 } 773 774 READ_UVLC( uiCode, "bit_depth_luma_minus8" ); 775 #if O0043_BEST_EFFORT_DECODING 776 const UInt forceDecodeBitDepth = pcSPS->getForceDecodeBitDepth(); 777 g_bitDepthInStream[CHANNEL_TYPE_LUMA] = 8 + uiCode; 778 if (forceDecodeBitDepth != 0) 779 { 780 uiCode = forceDecodeBitDepth - 8; 781 } 782 #endif 783 assert(uiCode <= 8); 784 785 pcSPS->setBitDepth(CHANNEL_TYPE_LUMA, 8 + uiCode); 786 #if O0043_BEST_EFFORT_DECODING 787 pcSPS->setQpBDOffset(CHANNEL_TYPE_LUMA, (Int) (6*(g_bitDepthInStream[CHANNEL_TYPE_LUMA]-8)) ); 788 #else 789 pcSPS->setQpBDOffset(CHANNEL_TYPE_LUMA, (Int) (6*uiCode) ); 790 #endif 791 792 READ_UVLC( uiCode, "bit_depth_chroma_minus8" ); 793 #if O0043_BEST_EFFORT_DECODING 794 g_bitDepthInStream[CHANNEL_TYPE_CHROMA] = 8 + uiCode; 795 if (forceDecodeBitDepth != 0) 796 { 797 uiCode = forceDecodeBitDepth - 8; 798 } 799 #endif 800 assert(uiCode <= 8); 801 pcSPS->setBitDepth(CHANNEL_TYPE_CHROMA, 8 + uiCode); 802 #if O0043_BEST_EFFORT_DECODING 803 pcSPS->setQpBDOffset(CHANNEL_TYPE_CHROMA, (Int) (6*(g_bitDepthInStream[CHANNEL_TYPE_CHROMA]-8)) ); 804 #else 805 pcSPS->setQpBDOffset(CHANNEL_TYPE_CHROMA, (Int) (6*uiCode) ); 806 #endif 807 808 #if SVC_EXTENSION 809 } 810 #endif 811 962 812 963 813 READ_UVLC( uiCode, "log2_max_pic_order_cnt_lsb_minus4" ); pcSPS->setBitsForPOC( 4 + uiCode ); 964 814 assert(uiCode <= 12); 965 815 966 #if SPS_DPB_PARAMS 967 #if !R0042_PROFILE_INDICATION 968 if( pcSPS->getLayerId() == 0 ) 969 { 970 #else 971 if( !bMultiLayerExtSpsFlag ) 972 { 973 #endif 974 #endif 975 UInt subLayerOrderingInfoPresentFlag; 976 READ_FLAG(subLayerOrderingInfoPresentFlag, "sps_sub_layer_ordering_info_present_flag"); 977 978 for(UInt i=0; i <= pcSPS->getMaxTLayers()-1; i++) 979 { 980 READ_UVLC ( uiCode, "sps_max_dec_pic_buffering_minus1[i]"); 981 pcSPS->setMaxDecPicBuffering( uiCode + 1, i); 982 READ_UVLC ( uiCode, "sps_num_reorder_pics[i]" ); 983 pcSPS->setNumReorderPics(uiCode, i); 984 READ_UVLC ( uiCode, "sps_max_latency_increase_plus1[i]"); 985 pcSPS->setMaxLatencyIncrease( uiCode, i ); 986 987 if (!subLayerOrderingInfoPresentFlag) 988 { 989 for (i++; i <= pcSPS->getMaxTLayers()-1; i++) 990 { 991 pcSPS->setMaxDecPicBuffering(pcSPS->getMaxDecPicBuffering(0), i); 992 pcSPS->setNumReorderPics(pcSPS->getNumReorderPics(0), i); 993 pcSPS->setMaxLatencyIncrease(pcSPS->getMaxLatencyIncrease(0), i); 994 } 995 break; 996 } 997 } 998 #if SPS_DPB_PARAMS 816 #if SVC_EXTENSION 817 if( V1CompatibleSPSFlag ) 818 { 819 #endif 820 UInt subLayerOrderingInfoPresentFlag; 821 READ_FLAG(subLayerOrderingInfoPresentFlag, "sps_sub_layer_ordering_info_present_flag"); 822 823 for(UInt i=0; i <= pcSPS->getMaxTLayers()-1; i++) 824 { 825 READ_UVLC ( uiCode, "sps_max_dec_pic_buffering_minus1[i]"); 826 pcSPS->setMaxDecPicBuffering( uiCode + 1, i); 827 READ_UVLC ( uiCode, "sps_num_reorder_pics[i]" ); 828 pcSPS->setNumReorderPics(uiCode, i); 829 READ_UVLC ( uiCode, "sps_max_latency_increase_plus1[i]"); 830 pcSPS->setMaxLatencyIncrease( uiCode, i ); 831 832 if (!subLayerOrderingInfoPresentFlag) 833 { 834 for (i++; i <= pcSPS->getMaxTLayers()-1; i++) 835 { 836 pcSPS->setMaxDecPicBuffering(pcSPS->getMaxDecPicBuffering(0), i); 837 pcSPS->setNumReorderPics(pcSPS->getNumReorderPics(0), i); 838 pcSPS->setMaxLatencyIncrease(pcSPS->getMaxLatencyIncrease(0), i); 839 } 840 break; 841 } 842 } 843 #if SVC_EXTENSION 999 844 } 1000 845 #endif … … 1004 849 READ_UVLC( uiCode, "log2_diff_max_min_coding_block_size" ); 1005 850 pcSPS->setLog2DiffMaxMinCodingBlockSize(uiCode); 1006 851 1007 852 if (pcSPS->getPTL()->getGeneralPTL()->getLevelIdc() >= Level::LEVEL5) 1008 853 { 1009 854 assert(log2MinCUSize + pcSPS->getLog2DiffMaxMinCodingBlockSize() >= 5); 1010 855 } 1011 856 1012 857 Int maxCUDepthDelta = uiCode; 1013 858 pcSPS->setMaxCUWidth ( 1<<(log2MinCUSize + maxCUDepthDelta) ); … … 1022 867 1023 868 Int addCuDepth = max (0, log2MinCUSize - (Int)pcSPS->getQuadtreeTULog2MinSize() ); 1024 pcSPS->setMaxCUDepth( maxCUDepthDelta + addCuDepth ); 869 pcSPS->setMaxCUDepth( maxCUDepthDelta + addCuDepth + getMaxCUDepthOffset(pcSPS->getChromaFormatIdc(), pcSPS->getQuadtreeTULog2MinSize()) ); 870 1025 871 READ_FLAG( uiCode, "scaling_list_enabled_flag" ); pcSPS->setScalingListFlag ( uiCode ); 1026 1027 872 if(pcSPS->getScalingListFlag()) 1028 873 { 1029 #if SCALINGLIST_INFERRING 1030 #if !R0042_PROFILE_INDICATION 1031 if( pcSPS->getLayerId() > 0 ) 1032 #else 1033 if( bMultiLayerExtSpsFlag ) 1034 #endif 874 #if SVC_EXTENSION 875 if( !V1CompatibleSPSFlag ) 1035 876 { 1036 877 READ_FLAG( uiCode, "sps_infer_scaling_list_flag" ); pcSPS->setInferScalingListFlag( uiCode ); … … 1049 890 { 1050 891 #endif 1051 1052 1053 1054 1055 1056 #if S CALINGLIST_INFERRING892 READ_FLAG( uiCode, "sps_scaling_list_data_present_flag" ); pcSPS->setScalingListPresentFlag ( uiCode ); 893 if(pcSPS->getScalingListPresentFlag ()) 894 { 895 parseScalingList( pcSPS->getScalingList() ); 896 } 897 #if SVC_EXTENSION 1057 898 } 1058 899 #endif … … 1064 905 if( pcSPS->getUsePCM() ) 1065 906 { 1066 READ_CODE( 4, uiCode, "pcm_sample_bit_depth_luma_minus1" ); pcSPS->setPCMBitDepth Luma (1 + uiCode );1067 READ_CODE( 4, uiCode, "pcm_sample_bit_depth_chroma_minus1" ); pcSPS->setPCMBitDepth Chroma (1 + uiCode );907 READ_CODE( 4, uiCode, "pcm_sample_bit_depth_luma_minus1" ); pcSPS->setPCMBitDepth ( CHANNEL_TYPE_LUMA, 1 + uiCode ); 908 READ_CODE( 4, uiCode, "pcm_sample_bit_depth_chroma_minus1" ); pcSPS->setPCMBitDepth ( CHANNEL_TYPE_CHROMA, 1 + uiCode ); 1068 909 READ_UVLC( uiCode, "log2_min_pcm_luma_coding_block_size_minus3" ); pcSPS->setPCMLog2MinSize (uiCode+3); 1069 910 READ_UVLC( uiCode, "log2_diff_max_min_pcm_luma_coding_block_size" ); pcSPS->setPCMLog2MaxSize ( uiCode+pcSPS->getPCMLog2MinSize() ); … … 1097 938 } 1098 939 READ_FLAG( uiCode, "sps_temporal_mvp_enable_flag" ); pcSPS->setTMVPFlagsPresent(uiCode); 940 1099 941 READ_FLAG( uiCode, "sps_strong_intra_smoothing_enable_flag" ); pcSPS->setUseStrongIntraSmoothing(uiCode); 1100 942 … … 1106 948 } 1107 949 1108 READ_FLAG( uiCode, "sps_extension_ flag");950 READ_FLAG( uiCode, "sps_extension_present_flag"); 1109 951 1110 952 #if SVC_EXTENSION … … 1112 954 1113 955 if( pcSPS->getExtensionFlag() ) 1114 { 1115 #if !R0042_PROFILE_INDICATION 1116 #if O0142_CONDITIONAL_SPS_EXTENSION 1117 UInt spsExtensionTypeFlag[8]; 1118 for (UInt i = 0; i < 8; i++) 1119 { 1120 READ_FLAG( spsExtensionTypeFlag[i], "sps_extension_type_flag" ); 1121 } 1122 if (spsExtensionTypeFlag[1]) 1123 { 1124 parseSPSExtension( pcSPS ); 1125 } 1126 if (spsExtensionTypeFlag[7]) 1127 { 1128 #else 1129 parseSPSExtension( pcSPS ); 1130 READ_FLAG( uiCode, "sps_extension2_flag"); 1131 if(uiCode) 1132 { 1133 #endif 956 #else 957 if (uiCode) 958 #endif 959 { 960 Bool sps_extension_flags[NUM_SPS_EXTENSION_FLAGS]; 961 for(Int i=0; i<NUM_SPS_EXTENSION_FLAGS; i++) 962 { 963 READ_FLAG( uiCode, "sps_extension_flag[]" ); 964 sps_extension_flags[i] = uiCode!=0; 965 } 966 967 Bool bSkipTrailingExtensionBits=false; 968 for(Int i=0; i<NUM_SPS_EXTENSION_FLAGS; i++) // loop used so that the order is determined by the enum. 969 { 970 if (sps_extension_flags[i]) 971 { 972 switch (SPSExtensionFlagIndex(i)) 973 { 974 case SPS_EXT__REXT: 975 assert(!bSkipTrailingExtensionBits); 976 977 READ_FLAG( uiCode, "transform_skip_rotation_enabled_flag"); pcSPS->setUseResidualRotation (uiCode != 0); 978 READ_FLAG( uiCode, "transform_skip_context_enabled_flag"); pcSPS->setUseSingleSignificanceMapContext (uiCode != 0); 979 READ_FLAG( uiCode, "residual_dpcm_implicit_enabled_flag"); pcSPS->setUseResidualDPCM(RDPCM_SIGNAL_IMPLICIT, (uiCode != 0)); 980 READ_FLAG( uiCode, "residual_dpcm_explicit_enabled_flag"); pcSPS->setUseResidualDPCM(RDPCM_SIGNAL_EXPLICIT, (uiCode != 0)); 981 READ_FLAG( uiCode, "extended_precision_processing_flag"); pcSPS->setUseExtendedPrecision (uiCode != 0); 982 READ_FLAG( uiCode, "intra_smoothing_disabled_flag"); pcSPS->setDisableIntraReferenceSmoothing (uiCode != 0); 983 READ_FLAG( uiCode, "high_precision_prediction_weighting_flag"); pcSPS->setUseHighPrecisionPredictionWeighting (uiCode != 0); 984 READ_FLAG( uiCode, "golomb_rice_parameter_adaptation_flag"); pcSPS->setUseGolombRiceParameterAdaptation (uiCode != 0); 985 READ_FLAG( uiCode, "cabac_bypass_alignment_enabled_flag"); pcSPS->setAlignCABACBeforeBypass (uiCode != 0); 986 break; 987 #if SVC_EXTENSION 988 case SPS_EXT__MLAYER: 989 parseSPSExtension( pcSPS ); 990 break; 991 #endif 992 default: 993 bSkipTrailingExtensionBits=true; 994 break; 995 } 996 } 997 } 998 if (bSkipTrailingExtensionBits) 999 { 1134 1000 while ( xMoreRbspData() ) 1135 1001 { … … 1137 1003 } 1138 1004 } 1139 } 1140 #else 1141 READ_FLAG( uiCode, "sps_range_extension_flag" ); 1142 assert(uiCode == 0); 1143 READ_FLAG( uiCode, "sps_multilayer_extension_flag" ); 1144 assert(uiCode == 1); 1145 READ_CODE(6, uiCode, "sps_extension_6bits"); 1146 assert(uiCode == 0); 1147 parseSPSExtension( pcSPS ); 1148 } 1149 #endif 1150 #else 1151 if (uiCode) 1152 { 1153 while ( xMoreRbspData() ) 1154 { 1155 READ_FLAG( uiCode, "sps_extension_data_flag"); 1156 } 1157 } 1158 #endif 1159 } 1160 1161 #if SVC_EXTENSION 1162 Void TDecCavlc::parseSPSExtension( TComSPS* pcSPS ) 1163 { 1164 UInt uiCode; 1165 // more syntax elements to be parsed here 1166 1167 READ_FLAG( uiCode, "inter_view_mv_vert_constraint_flag" ); 1168 // Vertical MV component restriction is not used in SHVC CTC 1169 assert( uiCode == 0 ); 1170 1171 #if !MOVE_SCALED_OFFSET_TO_PPS 1172 if( pcSPS->getLayerId() > 0 ) 1173 { 1174 Int iCode; 1175 READ_UVLC( uiCode, "num_scaled_ref_layer_offsets" ); pcSPS->setNumScaledRefLayerOffsets(uiCode); 1176 for(Int i = 0; i < pcSPS->getNumScaledRefLayerOffsets(); i++) 1177 { 1178 Window& scaledWindow = pcSPS->getScaledRefLayerWindow(i); 1179 #if O0098_SCALED_REF_LAYER_ID 1180 READ_CODE( 6, uiCode, "scaled_ref_layer_id" ); pcSPS->setScaledRefLayerId( i, uiCode ); 1181 #endif 1182 READ_SVLC( iCode, "scaled_ref_layer_left_offset" ); scaledWindow.setWindowLeftOffset (iCode << 1); 1183 READ_SVLC( iCode, "scaled_ref_layer_top_offset" ); scaledWindow.setWindowTopOffset (iCode << 1); 1184 READ_SVLC( iCode, "scaled_ref_layer_right_offset" ); scaledWindow.setWindowRightOffset (iCode << 1); 1185 READ_SVLC( iCode, "scaled_ref_layer_bottom_offset" ); scaledWindow.setWindowBottomOffset(iCode << 1); 1186 #if P0312_VERT_PHASE_ADJ 1187 READ_FLAG( uiCode, "vert_phase_position_enable_flag" ); scaledWindow.setVertPhasePositionEnableFlag(uiCode); pcSPS->setVertPhasePositionEnableFlag( pcSPS->getScaledRefLayerId(i), uiCode); 1188 #endif 1189 } 1190 } 1191 #endif 1192 } 1193 #endif 1005 } 1006 } 1194 1007 1195 1008 Void TDecCavlc::parseVPS(TComVPS* pcVPS) … … 1216 1029 READ_CODE( 6, uiCode, "vps_reserved_zero_6bits" ); assert(uiCode == 0); 1217 1030 #endif 1218 READ_CODE( 3, uiCode, "vps_max_sub_layers_minus1" ); pcVPS->setMaxTLayers( uiCode + 1 ); assert(uiCode+1 <= MAX_TLAYER);1031 READ_CODE( 3, uiCode, "vps_max_sub_layers_minus1" ); pcVPS->setMaxTLayers( uiCode + 1 ); assert(uiCode+1 <= MAX_TLAYER); 1219 1032 READ_FLAG( uiCode, "vps_temporal_id_nesting_flag" ); pcVPS->setTemporalNestingFlag( uiCode ? true:false ); 1220 1033 assert (pcVPS->getMaxTLayers()>1||pcVPS->getTemporalNestingFlag()); … … 1292 1105 READ_UVLC( uiCode, "vps_num_ticks_poc_diff_one_minus1"); timingInfo->setNumTicksPocDiffOneMinus1 (uiCode); 1293 1106 } 1107 1294 1108 READ_UVLC( uiCode, "vps_num_hrd_parameters" ); pcVPS->setNumHrdParameters( uiCode ); 1295 1109 … … 1356 1170 1357 1171 return; 1172 } 1173 1174 Void TDecCavlc::parseSliceHeader (TComSlice* pcSlice, ParameterSetManagerDecoder *parameterSetManager) 1175 { 1176 UInt uiCode; 1177 Int iCode; 1178 1179 #if ENC_DEC_TRACE 1180 xTraceSliceHeader(pcSlice); 1181 #endif 1182 TComPPS* pps = NULL; 1183 TComSPS* sps = NULL; 1184 1185 UInt firstSliceSegmentInPic; 1186 READ_FLAG( firstSliceSegmentInPic, "first_slice_segment_in_pic_flag" ); 1187 if( pcSlice->getRapPicFlag()) 1188 { 1189 READ_FLAG( uiCode, "no_output_of_prior_pics_flag" ); //ignored -- updated already 1190 pcSlice->setNoOutputPriorPicsFlag(uiCode ? true : false); 1191 } 1192 READ_UVLC ( uiCode, "slice_pic_parameter_set_id" ); pcSlice->setPPSId(uiCode); 1193 pps = parameterSetManager->getPrefetchedPPS(uiCode); 1194 //!KS: need to add error handling code here, if PPS is not available 1195 assert(pps!=0); 1196 sps = parameterSetManager->getPrefetchedSPS(pps->getSPSId()); 1197 //!KS: need to add error handling code here, if SPS is not available 1198 assert(sps!=0); 1199 pcSlice->setSPS(sps); 1200 pcSlice->setPPS(pps); 1201 1202 const ChromaFormat chFmt = sps->getChromaFormatIdc(); 1203 const UInt numValidComp=getNumberValidComponents(chFmt); 1204 const Bool bChroma=(chFmt!=CHROMA_400); 1205 1206 if( pps->getDependentSliceSegmentsEnabledFlag() && ( !firstSliceSegmentInPic )) 1207 { 1208 READ_FLAG( uiCode, "dependent_slice_segment_flag" ); pcSlice->setDependentSliceSegmentFlag(uiCode ? true : false); 1209 } 1210 else 1211 { 1212 pcSlice->setDependentSliceSegmentFlag(false); 1213 } 1214 #if REPN_FORMAT_IN_VPS 1215 Int numCTUs = ((pcSlice->getPicWidthInLumaSamples()+sps->getMaxCUWidth()-1)/sps->getMaxCUWidth())*((pcSlice->getPicHeightInLumaSamples()+sps->getMaxCUHeight()-1)/sps->getMaxCUHeight()); 1216 #else 1217 Int numCTUs = ((sps->getPicWidthInLumaSamples()+sps->getMaxCUWidth()-1)/sps->getMaxCUWidth())*((sps->getPicHeightInLumaSamples()+sps->getMaxCUHeight()-1)/sps->getMaxCUHeight()); 1218 #endif 1219 UInt sliceSegmentAddress = 0; 1220 Int bitsSliceSegmentAddress = 0; 1221 while(numCTUs>(1<<bitsSliceSegmentAddress)) 1222 { 1223 bitsSliceSegmentAddress++; 1224 } 1225 1226 if(!firstSliceSegmentInPic) 1227 { 1228 READ_CODE( bitsSliceSegmentAddress, sliceSegmentAddress, "slice_segment_address" ); 1229 } 1230 //set uiCode to equal slice start address (or dependent slice start address) 1231 pcSlice->setSliceSegmentCurStartCtuTsAddr( sliceSegmentAddress );// this is actually a Raster-Scan (RS) address, but we do not have the RS->TS conversion table defined yet. 1232 pcSlice->setSliceSegmentCurEndCtuTsAddr(numCTUs); // Set end as the last CTU of the picture. 1233 1234 if (!pcSlice->getDependentSliceSegmentFlag()) 1235 { 1236 pcSlice->setSliceCurStartCtuTsAddr(sliceSegmentAddress); // this is actually a Raster-Scan (RS) address, but we do not have the RS->TS conversion table defined yet. 1237 pcSlice->setSliceCurEndCtuTsAddr(numCTUs); 1238 } 1239 1240 #if Q0142_POC_LSB_NOT_PRESENT 1241 #if SHM_FIX7 1242 Int iPOClsb = 0; 1243 #endif 1244 #endif 1245 1246 if(!pcSlice->getDependentSliceSegmentFlag()) 1247 { 1248 #if SVC_EXTENSION 1249 #if POC_RESET_FLAG 1250 Int iBits = 0; 1251 if(pcSlice->getPPS()->getNumExtraSliceHeaderBits() > iBits) 1252 { 1253 READ_FLAG(uiCode, "poc_reset_flag"); pcSlice->setPocResetFlag( uiCode ? true : false ); 1254 iBits++; 1255 } 1256 if(pcSlice->getPPS()->getNumExtraSliceHeaderBits() > iBits) 1257 { 1258 #if DISCARDABLE_PIC_RPS 1259 READ_FLAG(uiCode, "discardable_flag"); pcSlice->setDiscardableFlag( uiCode ? true : false ); 1260 #else 1261 READ_FLAG(uiCode, "discardable_flag"); // ignored 1262 #endif 1263 iBits++; 1264 } 1265 #if O0149_CROSS_LAYER_BLA_FLAG 1266 if(pcSlice->getPPS()->getNumExtraSliceHeaderBits() > iBits) 1267 { 1268 READ_FLAG(uiCode, "cross_layer_bla_flag"); pcSlice->setCrossLayerBLAFlag( uiCode ? true : false ); 1269 iBits++; 1270 } 1271 #endif 1272 for (; iBits < pcSlice->getPPS()->getNumExtraSliceHeaderBits(); iBits++) 1273 { 1274 READ_FLAG(uiCode, "slice_reserved_undetermined_flag[]"); // ignored 1275 } 1276 #else 1277 #if CROSS_LAYER_BLA_FLAG_FIX 1278 Int iBits = 0; 1279 if(pcSlice->getPPS()->getNumExtraSliceHeaderBits() > iBits) 1280 #else 1281 if(pcSlice->getPPS()->getNumExtraSliceHeaderBits()>0) 1282 #endif 1283 { 1284 READ_FLAG(uiCode, "discardable_flag"); // ignored 1285 #if NON_REF_NAL_TYPE_DISCARDABLE 1286 pcSlice->setDiscardableFlag( uiCode ? true : false ); 1287 if (uiCode) 1288 { 1289 assert(pcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_TRAIL_R && 1290 pcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_TSA_R && 1291 pcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_STSA_R && 1292 pcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_RADL_R && 1293 pcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_RASL_R); 1294 } 1295 #endif 1296 #if CROSS_LAYER_BLA_FLAG_FIX 1297 iBits++; 1298 #endif 1299 } 1300 #if CROSS_LAYER_BLA_FLAG_FIX 1301 if(pcSlice->getPPS()->getNumExtraSliceHeaderBits() > iBits) 1302 { 1303 READ_FLAG(uiCode, "cross_layer_bla_flag"); pcSlice->setCrossLayerBLAFlag( uiCode ? true : false ); 1304 iBits++; 1305 } 1306 for ( ; iBits < pcSlice->getPPS()->getNumExtraSliceHeaderBits(); iBits++) 1307 #else 1308 for (Int i = 1; i < pcSlice->getPPS()->getNumExtraSliceHeaderBits(); i++) 1309 #endif 1310 { 1311 READ_FLAG(uiCode, "slice_reserved_undetermined_flag[]"); // ignored 1312 } 1313 #endif 1314 #else //SVC_EXTENSION 1315 for (Int i = 0; i < pcSlice->getPPS()->getNumExtraSliceHeaderBits(); i++) 1316 { 1317 READ_FLAG(uiCode, "slice_reserved_undetermined_flag[]"); // ignored 1318 } 1319 #endif //SVC_EXTENSION 1320 1321 READ_UVLC ( uiCode, "slice_type" ); pcSlice->setSliceType((SliceType)uiCode); 1322 if( pps->getOutputFlagPresentFlag() ) 1323 { 1324 READ_FLAG( uiCode, "pic_output_flag" ); pcSlice->setPicOutputFlag( uiCode ? true : false ); 1325 } 1326 else 1327 { 1328 pcSlice->setPicOutputFlag( true ); 1329 } 1330 1331 if( pcSlice->getIdrPicFlag() ) 1332 { 1333 pcSlice->setPOC(0); 1334 TComReferencePictureSet* rps = pcSlice->getLocalRPS(); 1335 rps->setNumberOfNegativePictures(0); 1336 rps->setNumberOfPositivePictures(0); 1337 rps->setNumberOfLongtermPictures(0); 1338 rps->setNumberOfPictures(0); 1339 pcSlice->setRPS(rps); 1340 } 1341 #if N0065_LAYER_POC_ALIGNMENT 1342 #if O0062_POC_LSB_NOT_PRESENT_FLAG 1343 if( ( pcSlice->getLayerId() > 0 && !pcSlice->getVPS()->getPocLsbNotPresentFlag( pcSlice->getVPS()->getLayerIdInVps(pcSlice->getLayerId())) ) || !pcSlice->getIdrPicFlag() ) 1344 #else 1345 if( pcSlice->getLayerId() > 0 || !pcSlice->getIdrPicFlag() ) 1346 #endif 1347 #else 1348 else 1349 #endif 1350 { 1351 READ_CODE(sps->getBitsForPOC(), uiCode, "pic_order_cnt_lsb"); 1352 #if POC_RESET_IDC_DECODER 1353 pcSlice->setPicOrderCntLsb( uiCode ); 1354 #endif 1355 #if SVC_EXTENSION 1356 iPOClsb = uiCode; 1357 #else 1358 Int iPOClsb = uiCode; 1359 #endif 1360 Int iPrevPOC = pcSlice->getPrevTid0POC(); 1361 Int iMaxPOClsb = 1<< sps->getBitsForPOC(); 1362 Int iPrevPOClsb = iPrevPOC & (iMaxPOClsb - 1); 1363 Int iPrevPOCmsb = iPrevPOC-iPrevPOClsb; 1364 Int iPOCmsb; 1365 if( ( iPOClsb < iPrevPOClsb ) && ( ( iPrevPOClsb - iPOClsb ) >= ( iMaxPOClsb / 2 ) ) ) 1366 { 1367 iPOCmsb = iPrevPOCmsb + iMaxPOClsb; 1368 } 1369 else if( (iPOClsb > iPrevPOClsb ) && ( (iPOClsb - iPrevPOClsb ) > ( iMaxPOClsb / 2 ) ) ) 1370 { 1371 iPOCmsb = iPrevPOCmsb - iMaxPOClsb; 1372 } 1373 else 1374 { 1375 iPOCmsb = iPrevPOCmsb; 1376 } 1377 if ( pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP 1378 || pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL 1379 || pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP ) 1380 { 1381 // For BLA picture types, POCmsb is set to 0. 1382 iPOCmsb = 0; 1383 } 1384 pcSlice->setPOC (iPOCmsb+iPOClsb); 1385 1386 #if N0065_LAYER_POC_ALIGNMENT 1387 } 1388 #if POC_RESET_IDC_DECODER 1389 else 1390 { 1391 pcSlice->setPicOrderCntLsb( 0 ); 1392 } 1393 #endif 1394 if( !pcSlice->getIdrPicFlag() ) 1395 { 1396 #endif 1397 TComReferencePictureSet* rps; 1398 rps = pcSlice->getLocalRPS(); 1399 pcSlice->setRPS(rps); 1400 READ_FLAG( uiCode, "short_term_ref_pic_set_sps_flag" ); 1401 if(uiCode == 0) // use short-term reference picture set explicitly signalled in slice header 1402 { 1403 parseShortTermRefPicSet(sps,rps, sps->getRPSList()->getNumberOfReferencePictureSets()); 1404 } 1405 else // use reference to short-term reference picture set in PPS 1406 { 1407 Int numBits = 0; 1408 while ((1 << numBits) < pcSlice->getSPS()->getRPSList()->getNumberOfReferencePictureSets()) 1409 { 1410 numBits++; 1411 } 1412 if (numBits > 0) 1413 { 1414 READ_CODE( numBits, uiCode, "short_term_ref_pic_set_idx"); 1415 } 1416 else 1417 { 1418 uiCode = 0; 1419 1420 } 1421 *rps = *(sps->getRPSList()->getReferencePictureSet(uiCode)); 1422 } 1423 if(sps->getLongTermRefsPresent()) 1424 { 1425 Int offset = rps->getNumberOfNegativePictures()+rps->getNumberOfPositivePictures(); 1426 UInt numOfLtrp = 0; 1427 UInt numLtrpInSPS = 0; 1428 if (pcSlice->getSPS()->getNumLongTermRefPicSPS() > 0) 1429 { 1430 READ_UVLC( uiCode, "num_long_term_sps"); 1431 numLtrpInSPS = uiCode; 1432 numOfLtrp += numLtrpInSPS; 1433 rps->setNumberOfLongtermPictures(numOfLtrp); 1434 } 1435 Int bitsForLtrpInSPS = 0; 1436 while (pcSlice->getSPS()->getNumLongTermRefPicSPS() > (1 << bitsForLtrpInSPS)) 1437 { 1438 bitsForLtrpInSPS++; 1439 } 1440 READ_UVLC( uiCode, "num_long_term_pics"); rps->setNumberOfLongtermPictures(uiCode); 1441 numOfLtrp += uiCode; 1442 rps->setNumberOfLongtermPictures(numOfLtrp); 1443 Int maxPicOrderCntLSB = 1 << pcSlice->getSPS()->getBitsForPOC(); 1444 Int prevDeltaMSB = 0, deltaPocMSBCycleLT = 0; 1445 for(Int j=offset+rps->getNumberOfLongtermPictures()-1, k = 0; k < numOfLtrp; j--, k++) 1446 { 1447 Int pocLsbLt; 1448 if (k < numLtrpInSPS) 1449 { 1450 uiCode = 0; 1451 if (bitsForLtrpInSPS > 0) 1452 { 1453 READ_CODE(bitsForLtrpInSPS, uiCode, "lt_idx_sps[i]"); 1454 } 1455 Int usedByCurrFromSPS=pcSlice->getSPS()->getUsedByCurrPicLtSPSFlag(uiCode); 1456 1457 pocLsbLt = pcSlice->getSPS()->getLtRefPicPocLsbSps(uiCode); 1458 rps->setUsed(j,usedByCurrFromSPS); 1459 } 1460 else 1461 { 1462 READ_CODE(pcSlice->getSPS()->getBitsForPOC(), uiCode, "poc_lsb_lt"); pocLsbLt= uiCode; 1463 READ_FLAG( uiCode, "used_by_curr_pic_lt_flag"); rps->setUsed(j,uiCode); 1464 } 1465 READ_FLAG(uiCode,"delta_poc_msb_present_flag"); 1466 Bool mSBPresentFlag = uiCode ? true : false; 1467 if(mSBPresentFlag) 1468 { 1469 READ_UVLC( uiCode, "delta_poc_msb_cycle_lt[i]" ); 1470 Bool deltaFlag = false; 1471 // First LTRP || First LTRP from SH 1472 if( (j == offset+rps->getNumberOfLongtermPictures()-1) || (j == offset+(numOfLtrp-numLtrpInSPS)-1) ) 1473 { 1474 deltaFlag = true; 1475 } 1476 if(deltaFlag) 1477 { 1478 deltaPocMSBCycleLT = uiCode; 1479 } 1480 else 1481 { 1482 deltaPocMSBCycleLT = uiCode + prevDeltaMSB; 1483 } 1484 1485 Int pocLTCurr = pcSlice->getPOC() - deltaPocMSBCycleLT * maxPicOrderCntLSB 1486 - iPOClsb + pocLsbLt; 1487 rps->setPOC (j, pocLTCurr); 1488 rps->setDeltaPOC(j, - pcSlice->getPOC() + pocLTCurr); 1489 rps->setCheckLTMSBPresent(j,true); 1490 } 1491 else 1492 { 1493 rps->setPOC (j, pocLsbLt); 1494 rps->setDeltaPOC(j, - pcSlice->getPOC() + pocLsbLt); 1495 rps->setCheckLTMSBPresent(j,false); 1496 1497 // reset deltaPocMSBCycleLT for first LTRP from slice header if MSB not present 1498 if( j == offset+(numOfLtrp-numLtrpInSPS)-1 ) 1499 { 1500 deltaPocMSBCycleLT = 0; 1501 } 1502 } 1503 prevDeltaMSB = deltaPocMSBCycleLT; 1504 } 1505 offset += rps->getNumberOfLongtermPictures(); 1506 rps->setNumberOfPictures(offset); 1507 } 1508 #if DPB_CONSTRAINTS 1509 if(pcSlice->getVPS()->getVpsExtensionFlag()==1) 1510 { 1511 #if Q0078_ADD_LAYER_SETS 1512 for (Int ii = 1; ii < (pcSlice->getVPS()->getVpsNumLayerSetsMinus1() + 1); ii++) // prevent assert error when num_add_layer_sets > 0 1513 #else 1514 for (Int ii=1; ii< pcSlice->getVPS()->getNumOutputLayerSets(); ii++ ) 1515 #endif 1516 { 1517 Int layerSetIdxForOutputLayerSet = pcSlice->getVPS()->getOutputLayerSetIdx( ii ); 1518 Int chkAssert=0; 1519 for(Int kk = 0; kk < pcSlice->getVPS()->getNumLayersInIdList(layerSetIdxForOutputLayerSet); kk++) 1520 { 1521 if(pcSlice->getLayerId() == pcSlice->getVPS()->getLayerSetLayerIdList(layerSetIdxForOutputLayerSet, kk)) 1522 { 1523 chkAssert=1; 1524 } 1525 } 1526 if(chkAssert) 1527 { 1528 // There may be something wrong here (layer id assumed to be layer idx?) 1529 assert(rps->getNumberOfNegativePictures() <= pcSlice->getVPS()->getMaxVpsDecPicBufferingMinus1(ii , pcSlice->getLayerId() , pcSlice->getVPS()->getMaxSLayersInLayerSetMinus1(ii))); 1530 assert(rps->getNumberOfPositivePictures() <= pcSlice->getVPS()->getMaxVpsDecPicBufferingMinus1(ii , pcSlice->getLayerId() , pcSlice->getVPS()->getMaxSLayersInLayerSetMinus1(ii)) - rps->getNumberOfNegativePictures()); 1531 assert((rps->getNumberOfPositivePictures() + rps->getNumberOfNegativePictures() + rps->getNumberOfLongtermPictures()) <= pcSlice->getVPS()->getMaxVpsDecPicBufferingMinus1(ii , pcSlice->getLayerId() , pcSlice->getVPS()->getMaxSLayersInLayerSetMinus1(ii))); 1532 } 1533 } 1534 1535 1536 } 1537 if(pcSlice->getLayerId() == 0) 1538 { 1539 assert(rps->getNumberOfNegativePictures() <= pcSlice->getSPS()->getMaxDecPicBuffering(pcSlice->getSPS()->getMaxTLayers()-1) ); 1540 assert(rps->getNumberOfPositivePictures() <= pcSlice->getSPS()->getMaxDecPicBuffering(pcSlice->getSPS()->getMaxTLayers()-1) -rps->getNumberOfNegativePictures()); 1541 assert((rps->getNumberOfPositivePictures() + rps->getNumberOfNegativePictures() + rps->getNumberOfLongtermPictures()) <= pcSlice->getSPS()->getMaxDecPicBuffering(pcSlice->getSPS()->getMaxTLayers()-1)); 1542 } 1543 #endif 1544 if ( pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP 1545 || pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL 1546 || pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP ) 1547 { 1548 // In the case of BLA picture types, rps data is read from slice header but ignored 1549 rps = pcSlice->getLocalRPS(); 1550 rps->setNumberOfNegativePictures(0); 1551 rps->setNumberOfPositivePictures(0); 1552 rps->setNumberOfLongtermPictures(0); 1553 rps->setNumberOfPictures(0); 1554 pcSlice->setRPS(rps); 1555 } 1556 if (pcSlice->getSPS()->getTMVPFlagsPresent()) 1557 { 1558 READ_FLAG( uiCode, "slice_temporal_mvp_enable_flag" ); 1559 pcSlice->setEnableTMVPFlag( uiCode == 1 ? true : false ); 1560 } 1561 else 1562 { 1563 pcSlice->setEnableTMVPFlag(false); 1564 } 1565 } 1566 1567 #if SVC_EXTENSION 1568 pcSlice->setActiveNumILRRefIdx(0); 1569 if((pcSlice->getLayerId() > 0) && !(pcSlice->getVPS()->getIlpSshSignalingEnabledFlag()) && (pcSlice->getNumILRRefIdx() > 0) ) 1570 { 1571 READ_FLAG(uiCode,"inter_layer_pred_enabled_flag"); 1572 pcSlice->setInterLayerPredEnabledFlag(uiCode); 1573 if( pcSlice->getInterLayerPredEnabledFlag()) 1574 { 1575 if(pcSlice->getNumILRRefIdx() > 1) 1576 { 1577 Int numBits = 1; 1578 while ((1 << numBits) < pcSlice->getNumILRRefIdx()) 1579 { 1580 numBits++; 1581 } 1582 if( !pcSlice->getVPS()->getMaxOneActiveRefLayerFlag()) 1583 { 1584 READ_CODE( numBits, uiCode,"num_inter_layer_ref_pics_minus1" ); 1585 pcSlice->setActiveNumILRRefIdx(uiCode + 1); 1586 } 1587 else 1588 { 1589 #if P0079_DERIVE_NUMACTIVE_REF_PICS 1590 for( Int i = 0; i < pcSlice->getNumILRRefIdx(); i++ ) 1591 { 1592 #if Q0060_MAX_TID_REF_EQUAL_TO_ZERO 1593 if((pcSlice->getVPS()->getMaxTidIlRefPicsPlus1(pcSlice->getVPS()->getLayerIdInVps(i),pcSlice->getLayerId()) > pcSlice->getTLayer() || pcSlice->getTLayer()==0) && 1594 (pcSlice->getVPS()->getMaxTSLayersMinus1(pcSlice->getVPS()->getLayerIdInVps(i)) >= pcSlice->getTLayer()) ) 1595 #else 1596 if(pcSlice->getVPS()->getMaxTidIlRefPicsPlus1(pcSlice->getVPS()->getLayerIdInVps(i),pcSlice->getLayerId()) > pcSlice->getTLayer() && 1597 (pcSlice->getVPS()->getMaxTSLayersMinus1(pcSlice->getVPS()->getLayerIdInVps(i)) >= pcSlice->getTLayer()) ) 1598 #endif 1599 { 1600 pcSlice->setActiveNumILRRefIdx(1); 1601 break; 1602 } 1603 } 1604 #else 1605 pcSlice->setActiveNumILRRefIdx(1); 1606 #endif 1607 } 1608 1609 if( pcSlice->getActiveNumILRRefIdx() == pcSlice->getNumILRRefIdx() ) 1610 { 1611 for( Int i = 0; i < pcSlice->getActiveNumILRRefIdx(); i++ ) 1612 { 1613 pcSlice->setInterLayerPredLayerIdc(i,i); 1614 } 1615 } 1616 else 1617 { 1618 for(Int i = 0; i < pcSlice->getActiveNumILRRefIdx(); i++ ) 1619 { 1620 READ_CODE( numBits,uiCode,"inter_layer_pred_layer_idc[i]" ); 1621 pcSlice->setInterLayerPredLayerIdc(uiCode,i); 1622 } 1623 } 1624 } 1625 else 1626 { 1627 #if O0225_TID_BASED_IL_RPS_DERIV && TSLAYERS_IL_RPS 1628 #if Q0060_MAX_TID_REF_EQUAL_TO_ZERO 1629 if((pcSlice->getVPS()->getMaxTidIlRefPicsPlus1(0,pcSlice->getLayerId()) > pcSlice->getTLayer() || pcSlice->getTLayer()==0) && 1630 (pcSlice->getVPS()->getMaxTSLayersMinus1(0) >= pcSlice->getTLayer()) ) 1631 #else 1632 if( (pcSlice->getVPS()->getMaxTidIlRefPicsPlus1(0,pcSlice->getLayerId()) > pcSlice->getTLayer()) && 1633 (pcSlice->getVPS()->getMaxTSLayersMinus1(0) >= pcSlice->getTLayer()) ) 1634 #endif 1635 { 1636 #endif 1637 pcSlice->setActiveNumILRRefIdx(1); 1638 pcSlice->setInterLayerPredLayerIdc(0,0); 1639 #if O0225_TID_BASED_IL_RPS_DERIV && TSLAYERS_IL_RPS 1640 } 1641 #endif 1642 } 1643 } 1644 } 1645 else if( pcSlice->getVPS()->getIlpSshSignalingEnabledFlag() == true && (pcSlice->getLayerId() > 0 )) 1646 { 1647 pcSlice->setInterLayerPredEnabledFlag(true); 1648 1649 #if O0225_TID_BASED_IL_RPS_DERIV && TSLAYERS_IL_RPS 1650 Int numRefLayerPics = 0; 1651 Int i = 0; 1652 Int refLayerPicIdc [MAX_VPS_LAYER_ID_PLUS1]; 1653 for(i = 0, numRefLayerPics = 0; i < pcSlice->getNumILRRefIdx(); i++ ) 1654 { 1655 #if Q0060_MAX_TID_REF_EQUAL_TO_ZERO 1656 if((pcSlice->getVPS()->getMaxTidIlRefPicsPlus1(pcSlice->getVPS()->getLayerIdInVps(i),pcSlice->getLayerId()) > pcSlice->getTLayer() || pcSlice->getTLayer()==0) && 1657 (pcSlice->getVPS()->getMaxTSLayersMinus1(pcSlice->getVPS()->getLayerIdInVps(i)) >= pcSlice->getTLayer()) ) 1658 #else 1659 if(pcSlice->getVPS()->getMaxTidIlRefPicsPlus1(pcSlice->getVPS()->getLayerIdInVps(i),pcSlice->getLayerId()) > pcSlice->getTLayer() && 1660 (pcSlice->getVPS()->getMaxTSLayersMinus1(pcSlice->getVPS()->getLayerIdInVps(i)) >= pcSlice->getTLayer()) ) 1661 #endif 1662 { 1663 refLayerPicIdc[ numRefLayerPics++ ] = i; 1664 } 1665 } 1666 pcSlice->setActiveNumILRRefIdx(numRefLayerPics); 1667 for( i = 0; i < pcSlice->getActiveNumILRRefIdx(); i++ ) 1668 { 1669 pcSlice->setInterLayerPredLayerIdc(refLayerPicIdc[i],i); 1670 } 1671 #else 1672 pcSlice->setActiveNumILRRefIdx(pcSlice->getNumILRRefIdx()); 1673 for( Int i = 0; i < pcSlice->getActiveNumILRRefIdx(); i++ ) 1674 { 1675 pcSlice->setInterLayerPredLayerIdc(i,i); 1676 } 1677 #endif 1678 } 1679 #if P0312_VERT_PHASE_ADJ 1680 for(Int i = 0; i < pcSlice->getActiveNumILRRefIdx(); i++ ) 1681 { 1682 UInt refLayerIdc = pcSlice->getInterLayerPredLayerIdc(i); 1683 #if !MOVE_SCALED_OFFSET_TO_PPS 1684 if( pcSlice->getSPS()->getVertPhasePositionEnableFlag(refLayerIdc) ) 1685 #else 1686 if( pcSlice->getPPS()->getVertPhasePositionEnableFlag(refLayerIdc) ) 1687 #endif 1688 { 1689 READ_FLAG( uiCode, "vert_phase_position_flag" ); pcSlice->setVertPhasePositionFlag( uiCode? true : false, refLayerIdc ); 1690 } 1691 } 1692 #endif 1693 #endif //SVC_EXTENSION 1694 1695 if(sps->getUseSAO()) 1696 { 1697 READ_FLAG(uiCode, "slice_sao_luma_flag"); pcSlice->setSaoEnabledFlag(CHANNEL_TYPE_LUMA, (Bool)uiCode); 1698 #if SVC_EXTENSION 1699 ChromaFormat format; 1700 if( sps->getLayerId() == 0 ) 1701 { 1702 format = sps->getChromaFormatIdc(); 1703 } 1704 else 1705 { 1706 format = pcSlice->getVPS()->getVpsRepFormat( sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : pcSlice->getVPS()->getVpsRepFormatIdx(sps->getLayerId()) )->getChromaFormatVpsIdc(); 1707 #if Q0195_REP_FORMAT_CLEANUP 1708 assert( (sps->getUpdateRepFormatFlag()==false && pcSlice->getVPS()->getVpsNumRepFormats()==1) || pcSlice->getVPS()->getVpsNumRepFormats() > 1 ); //conformance check 1709 #endif 1710 } 1711 if (format != CHROMA_400) 1712 #else 1713 if (bChroma) 1714 #endif 1715 { 1716 READ_FLAG(uiCode, "slice_sao_chroma_flag"); pcSlice->setSaoEnabledFlag(CHANNEL_TYPE_CHROMA, (Bool)uiCode); 1717 } 1718 #if SVC_EXTENSION 1719 else 1720 { 1721 pcSlice->setSaoEnabledFlag(CHANNEL_TYPE_CHROMA, false); 1722 } 1723 #endif 1724 } 1725 1726 if (pcSlice->getIdrPicFlag()) 1727 { 1728 pcSlice->setEnableTMVPFlag(false); 1729 } 1730 if (!pcSlice->isIntra()) 1731 { 1732 1733 READ_FLAG( uiCode, "num_ref_idx_active_override_flag"); 1734 if (uiCode) 1735 { 1736 READ_UVLC (uiCode, "num_ref_idx_l0_active_minus1" ); pcSlice->setNumRefIdx( REF_PIC_LIST_0, uiCode + 1 ); 1737 if (pcSlice->isInterB()) 1738 { 1739 READ_UVLC (uiCode, "num_ref_idx_l1_active_minus1" ); pcSlice->setNumRefIdx( REF_PIC_LIST_1, uiCode + 1 ); 1740 } 1741 else 1742 { 1743 pcSlice->setNumRefIdx(REF_PIC_LIST_1, 0); 1744 } 1745 } 1746 else 1747 { 1748 pcSlice->setNumRefIdx(REF_PIC_LIST_0, pcSlice->getPPS()->getNumRefIdxL0DefaultActive()); 1749 if (pcSlice->isInterB()) 1750 { 1751 pcSlice->setNumRefIdx(REF_PIC_LIST_1, pcSlice->getPPS()->getNumRefIdxL1DefaultActive()); 1752 } 1753 else 1754 { 1755 pcSlice->setNumRefIdx(REF_PIC_LIST_1,0); 1756 } 1757 } 1758 } 1759 // } 1760 TComRefPicListModification* refPicListModification = pcSlice->getRefPicListModification(); 1761 if(!pcSlice->isIntra()) 1762 { 1763 if( !pcSlice->getPPS()->getListsModificationPresentFlag() || pcSlice->getNumRpsCurrTempList() <= 1 ) 1764 { 1765 refPicListModification->setRefPicListModificationFlagL0( 0 ); 1766 } 1767 else 1768 { 1769 READ_FLAG( uiCode, "ref_pic_list_modification_flag_l0" ); refPicListModification->setRefPicListModificationFlagL0( uiCode ? 1 : 0 ); 1770 } 1771 1772 if(refPicListModification->getRefPicListModificationFlagL0()) 1773 { 1774 uiCode = 0; 1775 Int i = 0; 1776 Int numRpsCurrTempList0 = pcSlice->getNumRpsCurrTempList(); 1777 if ( numRpsCurrTempList0 > 1 ) 1778 { 1779 Int length = 1; 1780 numRpsCurrTempList0 --; 1781 while ( numRpsCurrTempList0 >>= 1) 1782 { 1783 length ++; 1784 } 1785 for (i = 0; i < pcSlice->getNumRefIdx(REF_PIC_LIST_0); i ++) 1786 { 1787 READ_CODE( length, uiCode, "list_entry_l0" ); 1788 refPicListModification->setRefPicSetIdxL0(i, uiCode ); 1789 } 1790 } 1791 else 1792 { 1793 for (i = 0; i < pcSlice->getNumRefIdx(REF_PIC_LIST_0); i ++) 1794 { 1795 refPicListModification->setRefPicSetIdxL0(i, 0 ); 1796 } 1797 } 1798 } 1799 } 1800 else 1801 { 1802 refPicListModification->setRefPicListModificationFlagL0(0); 1803 } 1804 if(pcSlice->isInterB()) 1805 { 1806 if( !pcSlice->getPPS()->getListsModificationPresentFlag() || pcSlice->getNumRpsCurrTempList() <= 1 ) 1807 { 1808 refPicListModification->setRefPicListModificationFlagL1( 0 ); 1809 } 1810 else 1811 { 1812 READ_FLAG( uiCode, "ref_pic_list_modification_flag_l1" ); refPicListModification->setRefPicListModificationFlagL1( uiCode ? 1 : 0 ); 1813 } 1814 if(refPicListModification->getRefPicListModificationFlagL1()) 1815 { 1816 uiCode = 0; 1817 Int i = 0; 1818 Int numRpsCurrTempList1 = pcSlice->getNumRpsCurrTempList(); 1819 if ( numRpsCurrTempList1 > 1 ) 1820 { 1821 Int length = 1; 1822 numRpsCurrTempList1 --; 1823 while ( numRpsCurrTempList1 >>= 1) 1824 { 1825 length ++; 1826 } 1827 for (i = 0; i < pcSlice->getNumRefIdx(REF_PIC_LIST_1); i ++) 1828 { 1829 READ_CODE( length, uiCode, "list_entry_l1" ); 1830 refPicListModification->setRefPicSetIdxL1(i, uiCode ); 1831 } 1832 } 1833 else 1834 { 1835 for (i = 0; i < pcSlice->getNumRefIdx(REF_PIC_LIST_1); i ++) 1836 { 1837 refPicListModification->setRefPicSetIdxL1(i, 0 ); 1838 } 1839 } 1840 } 1841 } 1842 else 1843 { 1844 refPicListModification->setRefPicListModificationFlagL1(0); 1845 } 1846 if (pcSlice->isInterB()) 1847 { 1848 READ_FLAG( uiCode, "mvd_l1_zero_flag" ); pcSlice->setMvdL1ZeroFlag( (uiCode ? true : false) ); 1849 } 1850 1851 pcSlice->setCabacInitFlag( false ); // default 1852 if(pps->getCabacInitPresentFlag() && !pcSlice->isIntra()) 1853 { 1854 READ_FLAG(uiCode, "cabac_init_flag"); 1855 pcSlice->setCabacInitFlag( uiCode ? true : false ); 1856 } 1857 1858 if ( pcSlice->getEnableTMVPFlag() ) 1859 { 1860 #if SVC_EXTENSION && REF_IDX_MFM 1861 // set motion mapping flag 1862 pcSlice->setMFMEnabledFlag( ( pcSlice->getNumMotionPredRefLayers() > 0 && pcSlice->getActiveNumILRRefIdx() && !pcSlice->isIntra() ) ? true : false ); 1863 #endif 1864 if ( pcSlice->getSliceType() == B_SLICE ) 1865 { 1866 READ_FLAG( uiCode, "collocated_from_l0_flag" ); 1867 pcSlice->setColFromL0Flag(uiCode); 1868 } 1869 else 1870 { 1871 pcSlice->setColFromL0Flag( 1 ); 1872 } 1873 1874 if ( pcSlice->getSliceType() != I_SLICE && 1875 ((pcSlice->getColFromL0Flag() == 1 && pcSlice->getNumRefIdx(REF_PIC_LIST_0) > 1)|| 1876 (pcSlice->getColFromL0Flag() == 0 && pcSlice->getNumRefIdx(REF_PIC_LIST_1) > 1))) 1877 { 1878 READ_UVLC( uiCode, "collocated_ref_idx" ); 1879 pcSlice->setColRefIdx(uiCode); 1880 } 1881 else 1882 { 1883 pcSlice->setColRefIdx(0); 1884 } 1885 } 1886 if ( (pps->getUseWP() && pcSlice->getSliceType()==P_SLICE) || (pps->getWPBiPred() && pcSlice->getSliceType()==B_SLICE) ) 1887 { 1888 xParsePredWeightTable(pcSlice); 1889 pcSlice->initWpScaling(); 1890 } 1891 if (!pcSlice->isIntra()) 1892 { 1893 READ_UVLC( uiCode, "five_minus_max_num_merge_cand"); 1894 pcSlice->setMaxNumMergeCand(MRG_MAX_NUM_CANDS - uiCode); 1895 } 1896 1897 READ_SVLC( iCode, "slice_qp_delta" ); 1898 pcSlice->setSliceQp (26 + pps->getPicInitQPMinus26() + iCode); 1899 1900 #if REPN_FORMAT_IN_VPS 1901 #if O0194_DIFFERENT_BITDEPTH_EL_BL 1902 g_bitDepthLayer[CHANNEL_TYPE_LUMA][pcSlice->getLayerId()] = pcSlice->getBitDepthY(); 1903 g_bitDepthLayer[CHANNEL_TYPE_CHROMA][pcSlice->getLayerId()] = pcSlice->getBitDepthC(); 1904 #endif 1905 assert( pcSlice->getSliceQp() >= -pcSlice->getQpBDOffsetY() ); 1906 #else 1907 assert( pcSlice->getSliceQp() >= -sps->getQpBDOffset(CHANNEL_TYPE_LUMA) ); 1908 #endif 1909 assert( pcSlice->getSliceQp() <= 51 ); 1910 1911 if (pcSlice->getPPS()->getSliceChromaQpFlag()) 1912 { 1913 if (numValidComp>COMPONENT_Cb) 1914 { 1915 READ_SVLC( iCode, "slice_qp_delta_cb" ); 1916 pcSlice->setSliceChromaQpDelta(COMPONENT_Cb, iCode ); 1917 assert( pcSlice->getSliceChromaQpDelta(COMPONENT_Cb) >= -12 ); 1918 assert( pcSlice->getSliceChromaQpDelta(COMPONENT_Cb) <= 12 ); 1919 assert( (pcSlice->getPPS()->getQpOffset(COMPONENT_Cb) + pcSlice->getSliceChromaQpDelta(COMPONENT_Cb)) >= -12 ); 1920 assert( (pcSlice->getPPS()->getQpOffset(COMPONENT_Cb) + pcSlice->getSliceChromaQpDelta(COMPONENT_Cb)) <= 12 ); 1921 } 1922 1923 if (numValidComp>COMPONENT_Cr) 1924 { 1925 READ_SVLC( iCode, "slice_qp_delta_cr" ); 1926 pcSlice->setSliceChromaQpDelta(COMPONENT_Cr, iCode ); 1927 assert( pcSlice->getSliceChromaQpDelta(COMPONENT_Cr) >= -12 ); 1928 assert( pcSlice->getSliceChromaQpDelta(COMPONENT_Cr) <= 12 ); 1929 assert( (pcSlice->getPPS()->getQpOffset(COMPONENT_Cr) + pcSlice->getSliceChromaQpDelta(COMPONENT_Cr)) >= -12 ); 1930 assert( (pcSlice->getPPS()->getQpOffset(COMPONENT_Cr) + pcSlice->getSliceChromaQpDelta(COMPONENT_Cr)) <= 12 ); 1931 } 1932 } 1933 1934 if (pcSlice->getPPS()->getChromaQpAdjTableSize() > 0) 1935 { 1936 READ_FLAG(uiCode, "slice_chroma_qp_adjustment_enabled_flag"); pcSlice->setUseChromaQpAdj(uiCode != 0); 1937 } 1938 else pcSlice->setUseChromaQpAdj(false); 1939 1940 if (pcSlice->getPPS()->getDeblockingFilterControlPresentFlag()) 1941 { 1942 if(pcSlice->getPPS()->getDeblockingFilterOverrideEnabledFlag()) 1943 { 1944 READ_FLAG ( uiCode, "deblocking_filter_override_flag" ); pcSlice->setDeblockingFilterOverrideFlag(uiCode ? true : false); 1945 } 1946 else 1947 { 1948 pcSlice->setDeblockingFilterOverrideFlag(0); 1949 } 1950 if(pcSlice->getDeblockingFilterOverrideFlag()) 1951 { 1952 READ_FLAG ( uiCode, "slice_disable_deblocking_filter_flag" ); pcSlice->setDeblockingFilterDisable(uiCode ? 1 : 0); 1953 if(!pcSlice->getDeblockingFilterDisable()) 1954 { 1955 READ_SVLC( iCode, "slice_beta_offset_div2" ); pcSlice->setDeblockingFilterBetaOffsetDiv2(iCode); 1956 assert(pcSlice->getDeblockingFilterBetaOffsetDiv2() >= -6 && 1957 pcSlice->getDeblockingFilterBetaOffsetDiv2() <= 6); 1958 READ_SVLC( iCode, "slice_tc_offset_div2" ); pcSlice->setDeblockingFilterTcOffsetDiv2(iCode); 1959 assert(pcSlice->getDeblockingFilterTcOffsetDiv2() >= -6 && 1960 pcSlice->getDeblockingFilterTcOffsetDiv2() <= 6); 1961 } 1962 } 1963 else 1964 { 1965 pcSlice->setDeblockingFilterDisable ( pcSlice->getPPS()->getPicDisableDeblockingFilterFlag() ); 1966 pcSlice->setDeblockingFilterBetaOffsetDiv2( pcSlice->getPPS()->getDeblockingFilterBetaOffsetDiv2() ); 1967 pcSlice->setDeblockingFilterTcOffsetDiv2 ( pcSlice->getPPS()->getDeblockingFilterTcOffsetDiv2() ); 1968 } 1969 } 1970 else 1971 { 1972 pcSlice->setDeblockingFilterDisable ( false ); 1973 pcSlice->setDeblockingFilterBetaOffsetDiv2( 0 ); 1974 pcSlice->setDeblockingFilterTcOffsetDiv2 ( 0 ); 1975 } 1976 1977 Bool isSAOEnabled = pcSlice->getSPS()->getUseSAO() && (pcSlice->getSaoEnabledFlag(CHANNEL_TYPE_LUMA) || (bChroma && pcSlice->getSaoEnabledFlag(CHANNEL_TYPE_CHROMA))); 1978 Bool isDBFEnabled = (!pcSlice->getDeblockingFilterDisable()); 1979 1980 if(pcSlice->getPPS()->getLoopFilterAcrossSlicesEnabledFlag() && ( isSAOEnabled || isDBFEnabled )) 1981 { 1982 READ_FLAG( uiCode, "slice_loop_filter_across_slices_enabled_flag"); 1983 } 1984 else 1985 { 1986 uiCode = pcSlice->getPPS()->getLoopFilterAcrossSlicesEnabledFlag()?1:0; 1987 } 1988 pcSlice->setLFCrossSliceBoundaryFlag( (uiCode==1)?true:false); 1989 1990 } 1991 1992 std::vector<UInt> entryPointOffset; 1993 if( pps->getTilesEnabledFlag() || pps->getEntropyCodingSyncEnabledFlag() ) 1994 { 1995 UInt numEntryPointOffsets; 1996 UInt offsetLenMinus1; 1997 READ_UVLC(numEntryPointOffsets, "num_entry_point_offsets"); 1998 if (numEntryPointOffsets>0) 1999 { 2000 READ_UVLC(offsetLenMinus1, "offset_len_minus1"); 2001 entryPointOffset.resize(numEntryPointOffsets); 2002 for (UInt idx=0; idx<numEntryPointOffsets; idx++) 2003 { 2004 READ_CODE(offsetLenMinus1+1, uiCode, "entry_point_offset_minus1"); 2005 entryPointOffset[ idx ] = uiCode + 1; 2006 } 2007 } 2008 } 2009 2010 #if POC_RESET_IDC_SIGNALLING 2011 Int sliceHeaderExtensionLength = 0; 2012 if(pps->getSliceHeaderExtensionPresentFlag()) 2013 { 2014 READ_UVLC( uiCode, "slice_header_extension_length"); sliceHeaderExtensionLength = uiCode; 2015 } 2016 else 2017 { 2018 sliceHeaderExtensionLength = 0; 2019 #if INFERENCE_POC_MSB_VAL_PRESENT 2020 pcSlice->setPocMsbValPresentFlag( false ); 2021 #endif 2022 } 2023 UInt startBits = m_pcBitstream->getNumBitsRead(); // Start counter of # SH Extn bits 2024 if( sliceHeaderExtensionLength > 0 ) 2025 { 2026 if( pcSlice->getPPS()->getPocResetInfoPresentFlag() ) 2027 { 2028 READ_CODE( 2, uiCode, "poc_reset_idc"); pcSlice->setPocResetIdc(uiCode); 2029 #if POC_RESET_RESTRICTIONS 2030 /* The value of poc_reset_idc shall not be equal to 1 or 2 for a RASL picture, a RADL picture, 2031 a sub-layer non-reference picture, or a picture that has TemporalId greater than 0, 2032 or a picture that has discardable_flag equal to 1. */ 2033 if( pcSlice->getPocResetIdc() == 1 || pcSlice->getPocResetIdc() == 2 ) 2034 { 2035 assert( !pcSlice->isRASL() ); 2036 assert( !pcSlice->isRADL() ); 2037 assert( !pcSlice->isSLNR() ); 2038 assert( pcSlice->getTLayer() == 0 ); 2039 assert( pcSlice->getDiscardableFlag() == 0 ); 2040 } 2041 2042 // The value of poc_reset_idc of a CRA or BLA picture shall be less than 3. 2043 if( pcSlice->getPocResetIdc() == 3) 2044 { 2045 assert( ! ( pcSlice->isCRA() || pcSlice->isBLA() ) ); 2046 } 2047 #endif 2048 } 2049 else 2050 { 2051 pcSlice->setPocResetIdc( 0 ); 2052 } 2053 #if Q0142_POC_LSB_NOT_PRESENT 2054 if ( pcSlice->getVPS()->getPocLsbNotPresentFlag(pcSlice->getLayerId()) && iPOClsb > 0 ) 2055 { 2056 assert( pcSlice->getPocResetIdc() != 2 ); 2057 } 2058 #endif 2059 if( pcSlice->getPocResetIdc() > 0 ) 2060 { 2061 READ_CODE(6, uiCode, "poc_reset_period_id"); pcSlice->setPocResetPeriodId(uiCode); 2062 } 2063 else 2064 { 2065 2066 pcSlice->setPocResetPeriodId( 0 ); 2067 } 2068 2069 if (pcSlice->getPocResetIdc() == 3) 2070 { 2071 READ_FLAG( uiCode, "full_poc_reset_flag"); pcSlice->setFullPocResetFlag((uiCode == 1) ? true : false); 2072 READ_CODE(pcSlice->getSPS()->getBitsForPOC(), uiCode,"poc_lsb_val"); pcSlice->setPocLsbVal(uiCode); 2073 #if Q0142_POC_LSB_NOT_PRESENT 2074 if ( pcSlice->getVPS()->getPocLsbNotPresentFlag(pcSlice->getLayerId()) && pcSlice->getFullPocResetFlag() ) 2075 { 2076 assert( pcSlice->getPocLsbVal() == 0 ); 2077 } 2078 #endif 2079 } 2080 2081 // Derive the value of PocMsbValRequiredFlag 2082 #if P0297_VPS_POC_LSB_ALIGNED_FLAG 2083 pcSlice->setPocMsbValRequiredFlag( (pcSlice->getCraPicFlag() || pcSlice->getBlaPicFlag()) 2084 && (!pcSlice->getVPS()->getVpsPocLsbAlignedFlag() || 2085 (pcSlice->getVPS()->getVpsPocLsbAlignedFlag() && pcSlice->getVPS()->getNumDirectRefLayers(pcSlice->getLayerId()) == 0)) 2086 ); 2087 #else 2088 pcSlice->setPocMsbValRequiredFlag( pcSlice->getCraPicFlag() || pcSlice->getBlaPicFlag() ); 2089 #endif 2090 2091 #if P0297_VPS_POC_LSB_ALIGNED_FLAG 2092 if (!pcSlice->getPocMsbValRequiredFlag() && pcSlice->getVPS()->getVpsPocLsbAlignedFlag()) 2093 #else 2094 if (!pcSlice->getPocMsbValRequiredFlag() /* vps_poc_lsb_aligned_flag */) 2095 #endif 2096 { 2097 #if P0297_VPS_POC_LSB_ALIGNED_FLAG 2098 READ_FLAG(uiCode, "poc_msb_cycle_val_present_flag"); pcSlice->setPocMsbValPresentFlag(uiCode ? true : false); 2099 #else 2100 READ_FLAG(uiCode, "poc_msb_val_present_flag"); pcSlice->setPocMsbValPresentFlag(uiCode ? true : false); 2101 #endif 2102 } 2103 else 2104 { 2105 #if POC_MSB_VAL_PRESENT_FLAG_SEM 2106 if( sliceHeaderExtensionLength == 0 ) 2107 { 2108 pcSlice->setPocMsbValPresentFlag( false ); 2109 } 2110 else if( pcSlice->getPocMsbValRequiredFlag() ) 2111 #else 2112 if( pcSlice->getPocMsbValRequiredFlag() ) 2113 #endif 2114 { 2115 pcSlice->setPocMsbValPresentFlag( true ); 2116 } 2117 else 2118 { 2119 pcSlice->setPocMsbValPresentFlag( false ); 2120 } 2121 } 2122 2123 #if !POC_RESET_IDC_DECODER 2124 Int maxPocLsb = 1 << pcSlice->getSPS()->getBitsForPOC(); 2125 #endif 2126 if( pcSlice->getPocMsbValPresentFlag() ) 2127 { 2128 #if P0297_VPS_POC_LSB_ALIGNED_FLAG 2129 READ_UVLC( uiCode, "poc_msb_cycle_val"); pcSlice->setPocMsbVal( uiCode ); 2130 #else 2131 READ_UVLC( uiCode, "poc_msb_val"); pcSlice->setPocMsbVal( uiCode ); 2132 #endif 2133 2134 #if !POC_RESET_IDC_DECODER 2135 // Update POC of the slice based on this MSB val 2136 Int pocLsb = pcSlice->getPOC() % maxPocLsb; 2137 pcSlice->setPOC((pcSlice->getPocMsbVal() * maxPocLsb) + pocLsb); 2138 } 2139 else 2140 { 2141 pcSlice->setPocMsbVal( pcSlice->getPOC() / maxPocLsb ); 2142 #endif 2143 } 2144 2145 // Read remaining bits in the slice header extension. 2146 UInt endBits = m_pcBitstream->getNumBitsRead(); 2147 Int counter = (endBits - startBits) % 8; 2148 if( counter ) 2149 { 2150 counter = 8 - counter; 2151 } 2152 2153 while( counter ) 2154 { 2155 #if Q0146_SSH_EXT_DATA_BIT 2156 READ_FLAG( uiCode, "slice_segment_header_extension_data_bit" ); 2157 #else 2158 READ_FLAG( uiCode, "slice_segment_header_extension_reserved_bit" ); assert( uiCode == 1 ); 2159 #endif 2160 counter--; 2161 } 2162 } 2163 #else 2164 if(pps->getSliceHeaderExtensionPresentFlag()) 2165 { 2166 READ_UVLC(uiCode,"slice_header_extension_length"); 2167 for(Int i=0; i<uiCode; i++) 2168 { 2169 UInt ignore; 2170 READ_CODE(8,ignore,"slice_header_extension_data_byte"); 2171 } 2172 } 2173 #endif 2174 #if RExt__DECODER_DEBUG_BIT_STATISTICS 2175 TComCodingStatistics::IncrementStatisticEP(STATS__BYTE_ALIGNMENT_BITS,m_pcBitstream->readByteAlignment(),0); 2176 #else 2177 m_pcBitstream->readByteAlignment(); 2178 #endif 2179 2180 pcSlice->clearSubstreamSizes(); 2181 2182 if( pps->getTilesEnabledFlag() || pps->getEntropyCodingSyncEnabledFlag() ) 2183 { 2184 Int endOfSliceHeaderLocation = m_pcBitstream->getByteLocation(); 2185 2186 // Adjust endOfSliceHeaderLocation to account for emulation prevention bytes in the slice segment header 2187 for ( UInt curByteIdx = 0; curByteIdx<m_pcBitstream->numEmulationPreventionBytesRead(); curByteIdx++ ) 2188 { 2189 if ( m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) < endOfSliceHeaderLocation ) 2190 { 2191 endOfSliceHeaderLocation++; 2192 } 2193 } 2194 2195 Int curEntryPointOffset = 0; 2196 Int prevEntryPointOffset = 0; 2197 for (UInt idx=0; idx<entryPointOffset.size(); idx++) 2198 { 2199 curEntryPointOffset += entryPointOffset[ idx ]; 2200 2201 Int emulationPreventionByteCount = 0; 2202 for ( UInt curByteIdx = 0; curByteIdx<m_pcBitstream->numEmulationPreventionBytesRead(); curByteIdx++ ) 2203 { 2204 if ( m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) >= ( prevEntryPointOffset + endOfSliceHeaderLocation ) && 2205 m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) < ( curEntryPointOffset + endOfSliceHeaderLocation ) ) 2206 { 2207 emulationPreventionByteCount++; 2208 } 2209 } 2210 2211 entryPointOffset[ idx ] -= emulationPreventionByteCount; 2212 prevEntryPointOffset = curEntryPointOffset; 2213 pcSlice->addSubstreamSize(entryPointOffset [ idx ] ); 2214 } 2215 } 2216 2217 return; 2218 } 2219 2220 Void TDecCavlc::parsePTL( TComPTL *rpcPTL, Bool profilePresentFlag, Int maxNumSubLayersMinus1 ) 2221 { 2222 UInt uiCode; 2223 if(profilePresentFlag) 2224 { 2225 parseProfileTier(rpcPTL->getGeneralPTL()); 2226 } 2227 READ_CODE( 8, uiCode, "general_level_idc" ); rpcPTL->getGeneralPTL()->setLevelIdc(Level::Name(uiCode)); 2228 2229 for (Int i = 0; i < maxNumSubLayersMinus1; i++) 2230 { 2231 if(profilePresentFlag) 2232 { 2233 READ_FLAG( uiCode, "sub_layer_profile_present_flag[i]" ); rpcPTL->setSubLayerProfilePresentFlag(i, uiCode); 2234 } 2235 READ_FLAG( uiCode, "sub_layer_level_present_flag[i]" ); rpcPTL->setSubLayerLevelPresentFlag (i, uiCode); 2236 } 2237 2238 if (maxNumSubLayersMinus1 > 0) 2239 { 2240 for (Int i = maxNumSubLayersMinus1; i < 8; i++) 2241 { 2242 READ_CODE(2, uiCode, "reserved_zero_2bits"); 2243 assert(uiCode == 0); 2244 } 2245 } 2246 2247 for(Int i = 0; i < maxNumSubLayersMinus1; i++) 2248 { 2249 if( profilePresentFlag && rpcPTL->getSubLayerProfilePresentFlag(i) ) 2250 { 2251 parseProfileTier(rpcPTL->getSubLayerPTL(i)); 2252 } 2253 if(rpcPTL->getSubLayerLevelPresentFlag(i)) 2254 { 2255 READ_CODE( 8, uiCode, "sub_layer_level_idc[i]" ); rpcPTL->getSubLayerPTL(i)->setLevelIdc(Level::Name(uiCode)); 2256 } 2257 } 2258 } 2259 2260 Void TDecCavlc::parseProfileTier(ProfileTierLevel *ptl) 2261 { 2262 UInt uiCode; 2263 READ_CODE(2 , uiCode, "XXX_profile_space[]"); ptl->setProfileSpace(uiCode); 2264 READ_FLAG( uiCode, "XXX_tier_flag[]" ); ptl->setTierFlag (uiCode ? Level::HIGH : Level::MAIN); 2265 READ_CODE(5 , uiCode, "XXX_profile_idc[]" ); ptl->setProfileIdc (Profile::Name(uiCode)); 2266 for(Int j = 0; j < 32; j++) 2267 { 2268 READ_FLAG( uiCode, "XXX_profile_compatibility_flag[][j]"); ptl->setProfileCompatibilityFlag(j, uiCode ? 1 : 0); 2269 } 2270 READ_FLAG(uiCode, "general_progressive_source_flag"); 2271 ptl->setProgressiveSourceFlag(uiCode ? true : false); 2272 2273 READ_FLAG(uiCode, "general_interlaced_source_flag"); 2274 ptl->setInterlacedSourceFlag(uiCode ? true : false); 2275 2276 READ_FLAG(uiCode, "general_non_packed_constraint_flag"); 2277 ptl->setNonPackedConstraintFlag(uiCode ? true : false); 2278 2279 READ_FLAG(uiCode, "general_frame_only_constraint_flag"); 2280 ptl->setFrameOnlyConstraintFlag(uiCode ? true : false); 2281 2282 if (ptl->getProfileIdc() == Profile::MAINREXT || ptl->getProfileIdc() == Profile::HIGHTHROUGHPUTREXT ) 2283 { 2284 UInt maxBitDepth=16; 2285 READ_FLAG( uiCode, "general_max_12bit_constraint_flag" ); if (uiCode) maxBitDepth=12; 2286 READ_FLAG( uiCode, "general_max_10bit_constraint_flag" ); if (uiCode) maxBitDepth=10; 2287 READ_FLAG( uiCode, "general_max_8bit_constraint_flag" ); if (uiCode) maxBitDepth=8; 2288 ptl->setBitDepthConstraint(maxBitDepth); 2289 ChromaFormat chromaFmtConstraint=CHROMA_444; 2290 READ_FLAG( uiCode, "general_max_422chroma_constraint_flag" ); if (uiCode) chromaFmtConstraint=CHROMA_422; 2291 READ_FLAG( uiCode, "general_max_420chroma_constraint_flag" ); if (uiCode) chromaFmtConstraint=CHROMA_420; 2292 READ_FLAG( uiCode, "general_max_monochrome_constraint_flag" ); if (uiCode) chromaFmtConstraint=CHROMA_400; 2293 ptl->setChromaFormatConstraint(chromaFmtConstraint); 2294 READ_FLAG( uiCode, "general_intra_constraint_flag"); ptl->setIntraConstraintFlag(uiCode != 0); 2295 READ_FLAG( uiCode, "general_one_picture_only_constraint_flag"); 2296 READ_FLAG( uiCode, "general_lower_bit_rate_constraint_flag"); ptl->setLowerBitRateConstraintFlag(uiCode != 0); 2297 READ_CODE(16, uiCode, "XXX_reserved_zero_35bits[0..15]"); 2298 READ_CODE(16, uiCode, "XXX_reserved_zero_35bits[16..31]"); 2299 READ_CODE(3, uiCode, "XXX_reserved_zero_35bits[32..34]"); 2300 } 2301 else 2302 { 2303 ptl->setBitDepthConstraint((ptl->getProfileIdc() == Profile::MAIN10)?10:8); 2304 ptl->setChromaFormatConstraint(CHROMA_420); 2305 ptl->setIntraConstraintFlag(false); 2306 ptl->setLowerBitRateConstraintFlag(true); 2307 READ_CODE(16, uiCode, "XXX_reserved_zero_44bits[0..15]"); 2308 READ_CODE(16, uiCode, "XXX_reserved_zero_44bits[16..31]"); 2309 READ_CODE(12, uiCode, "XXX_reserved_zero_44bits[32..43]"); 2310 } 2311 } 2312 2313 Void TDecCavlc::parseTerminatingBit( UInt& ruiBit ) 2314 { 2315 ruiBit = false; 2316 Int iBitsLeft = m_pcBitstream->getNumBitsLeft(); 2317 if(iBitsLeft <= 8) 2318 { 2319 UInt uiPeekValue = m_pcBitstream->peekBits(iBitsLeft); 2320 if (uiPeekValue == (1<<(iBitsLeft-1))) 2321 { 2322 ruiBit = true; 2323 } 2324 } 2325 } 2326 2327 Void TDecCavlc::parseRemainingBytes( Bool noTrailingBytesExpected ) 2328 { 2329 if (noTrailingBytesExpected) 2330 { 2331 const UInt numberOfRemainingSubstreamBytes=m_pcBitstream->getNumBitsLeft(); 2332 assert (numberOfRemainingSubstreamBytes == 0); 2333 } 2334 else 2335 { 2336 while (m_pcBitstream->getNumBitsLeft()) 2337 { 2338 UInt trailingNullByte=m_pcBitstream->readByte(); 2339 if (trailingNullByte!=0) 2340 { 2341 printf("Trailing byte should be 0, but has value %02x\n", trailingNullByte); 2342 assert(trailingNullByte==0); 2343 } 2344 } 2345 } 2346 } 2347 2348 Void TDecCavlc::parseSkipFlag( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) 2349 { 2350 assert(0); 2351 } 2352 2353 Void TDecCavlc::parseCUTransquantBypassFlag( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) 2354 { 2355 assert(0); 2356 } 2357 2358 Void TDecCavlc::parseMVPIdx( Int& /*riMVPIdx*/ ) 2359 { 2360 assert(0); 2361 } 2362 2363 Void TDecCavlc::parseSplitFlag ( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) 2364 { 2365 assert(0); 2366 } 2367 2368 Void TDecCavlc::parsePartSize( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) 2369 { 2370 assert(0); 2371 } 2372 2373 Void TDecCavlc::parsePredMode( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) 2374 { 2375 assert(0); 2376 } 2377 2378 /** Parse I_PCM information. 2379 * \param pcCU pointer to CU 2380 * \param uiAbsPartIdx CU index 2381 * \param uiDepth CU depth 2382 * \returns Void 2383 * 2384 * If I_PCM flag indicates that the CU is I_PCM, parse its PCM alignment bits and codes. 2385 */ 2386 Void TDecCavlc::parseIPCMInfo( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) 2387 { 2388 assert(0); 2389 } 2390 2391 Void TDecCavlc::parseIntraDirLumaAng ( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) 2392 { 2393 assert(0); 2394 } 2395 2396 Void TDecCavlc::parseIntraDirChroma( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) 2397 { 2398 assert(0); 2399 } 2400 2401 Void TDecCavlc::parseInterDir( TComDataCU* /*pcCU*/, UInt& /*ruiInterDir*/, UInt /*uiAbsPartIdx*/ ) 2402 { 2403 assert(0); 2404 } 2405 2406 Void TDecCavlc::parseRefFrmIdx( TComDataCU* /*pcCU*/, Int& /*riRefFrmIdx*/, RefPicList /*eRefList*/ ) 2407 { 2408 assert(0); 2409 } 2410 2411 Void TDecCavlc::parseMvd( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiPartIdx*/, UInt /*uiDepth*/, RefPicList /*eRefList*/ ) 2412 { 2413 assert(0); 2414 } 2415 2416 Void TDecCavlc::parseCrossComponentPrediction( class TComTU& /*rTu*/, ComponentID /*compID*/ ) 2417 { 2418 assert(0); 2419 } 2420 2421 Void TDecCavlc::parseDeltaQP( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) 2422 { 2423 Int qp; 2424 Int iDQp; 2425 2426 #if RExt__DECODER_DEBUG_BIT_STATISTICS 2427 READ_SVLC(iDQp, "delta_qp"); 2428 #else 2429 xReadSvlc( iDQp ); 2430 #endif 2431 2432 Int qpBdOffsetY = pcCU->getSlice()->getSPS()->getQpBDOffset(CHANNEL_TYPE_LUMA); 2433 qp = (((Int) pcCU->getRefQP( uiAbsPartIdx ) + iDQp + 52 + 2*qpBdOffsetY )%(52+ qpBdOffsetY)) - qpBdOffsetY; 2434 2435 UInt uiAbsQpCUPartIdx = (uiAbsPartIdx>>((g_uiMaxCUDepth - pcCU->getSlice()->getPPS()->getMaxCuDQPDepth())<<1))<<((g_uiMaxCUDepth - pcCU->getSlice()->getPPS()->getMaxCuDQPDepth())<<1) ; 2436 UInt uiQpCUDepth = min(uiDepth,pcCU->getSlice()->getPPS()->getMaxCuDQPDepth()) ; 2437 2438 pcCU->setQPSubParts( qp, uiAbsQpCUPartIdx, uiQpCUDepth ); 2439 } 2440 2441 Void TDecCavlc::parseChromaQpAdjustment( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) 2442 { 2443 assert(0); 2444 } 2445 2446 Void TDecCavlc::parseCoeffNxN( TComTU &/*rTu*/, ComponentID /*compID*/ ) 2447 { 2448 assert(0); 2449 } 2450 2451 Void TDecCavlc::parseTransformSubdivFlag( UInt& /*ruiSubdivFlag*/, UInt /*uiLog2TransformBlockSize*/ ) 2452 { 2453 assert(0); 2454 } 2455 2456 Void TDecCavlc::parseQtCbf( TComTU &/*rTu*/, const ComponentID /*compID*/, const Bool /*lowestLevel*/ ) 2457 { 2458 assert(0); 2459 } 2460 2461 Void TDecCavlc::parseQtRootCbf( UInt /*uiAbsPartIdx*/, UInt& /*uiQtRootCbf*/ ) 2462 { 2463 assert(0); 2464 } 2465 2466 Void TDecCavlc::parseTransformSkipFlags (TComTU &/*rTu*/, ComponentID /*component*/) 2467 { 2468 assert(0); 2469 } 2470 2471 Void TDecCavlc::parseMergeFlag ( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/, UInt /*uiPUIdx*/ ) 2472 { 2473 assert(0); 2474 } 2475 2476 Void TDecCavlc::parseMergeIndex ( TComDataCU* /*pcCU*/, UInt& /*ruiMergeIndex*/ ) 2477 { 2478 assert(0); 2479 } 2480 2481 // ==================================================================================================================== 2482 // Protected member functions 2483 // ==================================================================================================================== 2484 2485 /** parse explicit wp tables 2486 * \param TComSlice* pcSlice 2487 * \returns Void 2488 */ 2489 Void TDecCavlc::xParsePredWeightTable( TComSlice* pcSlice ) 2490 { 2491 WPScalingParam *wp; 2492 TComSPS *sps = pcSlice->getSPS(); 2493 const ChromaFormat chFmt = sps->getChromaFormatIdc(); 2494 const Int numValidComp = Int(getNumberValidComponents(chFmt)); 2495 const Bool bChroma = (chFmt!=CHROMA_400); 2496 const SliceType eSliceType = pcSlice->getSliceType(); 2497 const Int iNbRef = (eSliceType == B_SLICE ) ? (2) : (1); 2498 UInt uiLog2WeightDenomLuma=0, uiLog2WeightDenomChroma=0; 2499 UInt uiTotalSignalledWeightFlags = 0; 2500 2501 Int iDeltaDenom; 2502 // decode delta_luma_log2_weight_denom : 2503 READ_UVLC( uiLog2WeightDenomLuma, "luma_log2_weight_denom" ); // ue(v): luma_log2_weight_denom 2504 assert( uiLog2WeightDenomLuma <= 7 ); 2505 if( bChroma ) 2506 { 2507 READ_SVLC( iDeltaDenom, "delta_chroma_log2_weight_denom" ); // se(v): delta_chroma_log2_weight_denom 2508 assert((iDeltaDenom + (Int)uiLog2WeightDenomLuma)>=0); 2509 assert((iDeltaDenom + (Int)uiLog2WeightDenomLuma)<=7); 2510 uiLog2WeightDenomChroma = (UInt)(iDeltaDenom + uiLog2WeightDenomLuma); 2511 } 2512 2513 for ( Int iNumRef=0 ; iNumRef<iNbRef ; iNumRef++ ) 2514 { 2515 RefPicList eRefPicList = ( iNumRef ? REF_PIC_LIST_1 : REF_PIC_LIST_0 ); 2516 for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ ) 2517 { 2518 pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); 2519 2520 wp[COMPONENT_Y].uiLog2WeightDenom = uiLog2WeightDenomLuma; 2521 for(Int j=1; j<numValidComp; j++) 2522 { 2523 wp[j].uiLog2WeightDenom = uiLog2WeightDenomChroma; 2524 } 2525 2526 UInt uiCode; 2527 READ_FLAG( uiCode, "luma_weight_lX_flag" ); // u(1): luma_weight_l0_flag 2528 wp[COMPONENT_Y].bPresentFlag = ( uiCode == 1 ); 2529 uiTotalSignalledWeightFlags += wp[COMPONENT_Y].bPresentFlag; 2530 } 2531 if ( bChroma ) 2532 { 2533 UInt uiCode; 2534 for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ ) 2535 { 2536 pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); 2537 READ_FLAG( uiCode, "chroma_weight_lX_flag" ); // u(1): chroma_weight_l0_flag 2538 for(Int j=1; j<numValidComp; j++) 2539 { 2540 wp[j].bPresentFlag = ( uiCode == 1 ); 2541 } 2542 uiTotalSignalledWeightFlags += 2*wp[COMPONENT_Cb].bPresentFlag; 2543 } 2544 } 2545 for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ ) 2546 { 2547 pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); 2548 if ( wp[COMPONENT_Y].bPresentFlag ) 2549 { 2550 Int iDeltaWeight; 2551 READ_SVLC( iDeltaWeight, "delta_luma_weight_lX" ); // se(v): delta_luma_weight_l0[i] 2552 assert( iDeltaWeight >= -128 ); 2553 assert( iDeltaWeight <= 127 ); 2554 wp[COMPONENT_Y].iWeight = (iDeltaWeight + (1<<wp[COMPONENT_Y].uiLog2WeightDenom)); 2555 READ_SVLC( wp[COMPONENT_Y].iOffset, "luma_offset_lX" ); // se(v): luma_offset_l0[i] 2556 Int range=sps->getUseHighPrecisionPredictionWeighting() ? (1<<g_bitDepth[CHANNEL_TYPE_LUMA])/2 : 128; 2557 assert( wp[0].iOffset >= -range ); 2558 assert( wp[0].iOffset < range ); 2559 } 2560 else 2561 { 2562 wp[COMPONENT_Y].iWeight = (1 << wp[COMPONENT_Y].uiLog2WeightDenom); 2563 wp[COMPONENT_Y].iOffset = 0; 2564 } 2565 if ( bChroma ) 2566 { 2567 if ( wp[COMPONENT_Cb].bPresentFlag ) 2568 { 2569 Int range=sps->getUseHighPrecisionPredictionWeighting() ? (1<<g_bitDepth[CHANNEL_TYPE_CHROMA])/2 : 128; 2570 for ( Int j=1 ; j<numValidComp ; j++ ) 2571 { 2572 Int iDeltaWeight; 2573 READ_SVLC( iDeltaWeight, "delta_chroma_weight_lX" ); // se(v): chroma_weight_l0[i][j] 2574 assert( iDeltaWeight >= -128 ); 2575 assert( iDeltaWeight <= 127 ); 2576 wp[j].iWeight = (iDeltaWeight + (1<<wp[j].uiLog2WeightDenom)); 2577 2578 Int iDeltaChroma; 2579 READ_SVLC( iDeltaChroma, "delta_chroma_offset_lX" ); // se(v): delta_chroma_offset_l0[i][j] 2580 assert( iDeltaChroma >= -4*range); 2581 assert( iDeltaChroma < 4*range); 2582 Int pred = ( range - ( ( range*wp[j].iWeight)>>(wp[j].uiLog2WeightDenom) ) ); 2583 wp[j].iOffset = Clip3(-range, range-1, (iDeltaChroma + pred) ); 2584 } 2585 } 2586 else 2587 { 2588 for ( Int j=1 ; j<numValidComp ; j++ ) 2589 { 2590 wp[j].iWeight = (1 << wp[j].uiLog2WeightDenom); 2591 wp[j].iOffset = 0; 2592 } 2593 } 2594 } 2595 } 2596 2597 for ( Int iRefIdx=pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx<MAX_NUM_REF ; iRefIdx++ ) 2598 { 2599 pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); 2600 2601 wp[0].bPresentFlag = false; 2602 wp[1].bPresentFlag = false; 2603 wp[2].bPresentFlag = false; 2604 } 2605 } 2606 assert(uiTotalSignalledWeightFlags<=24); 2607 } 2608 2609 /** decode quantization matrix 2610 * \param scalingList quantization matrix information 2611 */ 2612 Void TDecCavlc::parseScalingList(TComScalingList* scalingList) 2613 { 2614 UInt code, sizeId, listId; 2615 Bool scalingListPredModeFlag; 2616 //for each size 2617 for(sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) 2618 { 2619 for(listId = 0; listId < SCALING_LIST_NUM; listId++) 2620 { 2621 if ((sizeId==SCALING_LIST_32x32) && (listId%(SCALING_LIST_NUM/NUMBER_OF_PREDICTION_MODES) != 0)) 2622 { 2623 Int *src = scalingList->getScalingListAddress(sizeId, listId); 2624 const Int size = min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId]); 2625 const Int *srcNextSmallerSize = scalingList->getScalingListAddress(sizeId-1, listId); 2626 for(Int i=0; i<size; i++) 2627 { 2628 src[i] = srcNextSmallerSize[i]; 2629 } 2630 scalingList->setScalingListDC(sizeId,listId,(sizeId > SCALING_LIST_8x8) ? scalingList->getScalingListDC(sizeId-1, listId) : src[0]); 2631 } 2632 else 2633 { 2634 READ_FLAG( code, "scaling_list_pred_mode_flag"); 2635 scalingListPredModeFlag = (code) ? true : false; 2636 if(!scalingListPredModeFlag) //Copy Mode 2637 { 2638 READ_UVLC( code, "scaling_list_pred_matrix_id_delta"); 2639 2640 if (sizeId==SCALING_LIST_32x32) 2641 code*=(SCALING_LIST_NUM/NUMBER_OF_PREDICTION_MODES); // Adjust the decoded code for this size, to cope with the missing 32x32 chroma entries. 2642 2643 scalingList->setRefMatrixId (sizeId,listId,(UInt)((Int)(listId)-(code))); 2644 if( sizeId > SCALING_LIST_8x8 ) 2645 { 2646 scalingList->setScalingListDC(sizeId,listId,((listId == scalingList->getRefMatrixId (sizeId,listId))? 16 :scalingList->getScalingListDC(sizeId, scalingList->getRefMatrixId (sizeId,listId)))); 2647 } 2648 scalingList->processRefMatrix( sizeId, listId, scalingList->getRefMatrixId (sizeId,listId)); 2649 2650 } 2651 else //DPCM Mode 2652 { 2653 xDecodeScalingList(scalingList, sizeId, listId); 2654 } 2655 } 2656 } 2657 } 2658 2659 return; 2660 } 2661 /** decode DPCM 2662 * \param scalingList quantization matrix information 2663 * \param sizeId size index 2664 * \param listId list index 2665 */ 2666 Void TDecCavlc::xDecodeScalingList(TComScalingList *scalingList, UInt sizeId, UInt listId) 2667 { 2668 Int i,coefNum = min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId]); 2669 Int data; 2670 Int scalingListDcCoefMinus8 = 0; 2671 Int nextCoef = SCALING_LIST_START_VALUE; 2672 UInt* scan = g_scanOrder[SCAN_UNGROUPED][SCAN_DIAG][sizeId==0 ? 2 : 3][sizeId==0 ? 2 : 3]; 2673 Int *dst = scalingList->getScalingListAddress(sizeId, listId); 2674 2675 if( sizeId > SCALING_LIST_8x8 ) 2676 { 2677 READ_SVLC( scalingListDcCoefMinus8, "scaling_list_dc_coef_minus8"); 2678 scalingList->setScalingListDC(sizeId,listId,scalingListDcCoefMinus8 + 8); 2679 nextCoef = scalingList->getScalingListDC(sizeId,listId); 2680 } 2681 2682 for(i = 0; i < coefNum; i++) 2683 { 2684 READ_SVLC( data, "scaling_list_delta_coef"); 2685 nextCoef = (nextCoef + data + 256 ) % 256; 2686 dst[scan[i]] = nextCoef; 2687 } 2688 } 2689 2690 Bool TDecCavlc::xMoreRbspData() 2691 { 2692 Int bitsLeft = m_pcBitstream->getNumBitsLeft(); 2693 2694 // if there are more than 8 bits, it cannot be rbsp_trailing_bits 2695 if (bitsLeft > 8) 2696 { 2697 return true; 2698 } 2699 2700 UChar lastByte = m_pcBitstream->peekBits(bitsLeft); 2701 Int cnt = bitsLeft; 2702 2703 // remove trailing bits equal to zero 2704 while ((cnt>0) && ((lastByte & 1) == 0)) 2705 { 2706 lastByte >>= 1; 2707 cnt--; 2708 } 2709 // remove bit equal to one 2710 cnt--; 2711 2712 // we should not have a negative number of bits 2713 assert (cnt>=0); 2714 2715 // we have more data, if cnt is not zero 2716 return (cnt>0); 2717 } 2718 2719 Void TDecCavlc::parseExplicitRdpcmMode( TComTU &rTu, ComponentID compID ) 2720 { 2721 assert(0); 1358 2722 } 1359 2723 … … 2933 4297 } 2934 4298 2935 #endif //SVC_EXTENSION 2936 2937 Void TDecCavlc::parseSliceHeader (TComSlice*& rpcSlice, ParameterSetManagerDecoder *parameterSetManager) 2938 { 2939 UInt uiCode; 2940 Int iCode; 2941 2942 #if ENC_DEC_TRACE 2943 xTraceSliceHeader(rpcSlice); 2944 #endif 2945 TComPPS* pps = NULL; 2946 TComSPS* sps = NULL; 2947 2948 UInt firstSliceSegmentInPic; 2949 READ_FLAG( firstSliceSegmentInPic, "first_slice_segment_in_pic_flag" ); 2950 if( rpcSlice->getRapPicFlag()) 2951 { 2952 READ_FLAG( uiCode, "no_output_of_prior_pics_flag" ); //ignored -- updated already 2953 #if SETTING_NO_OUT_PIC_PRIOR 2954 rpcSlice->setNoOutputPriorPicsFlag(uiCode ? true : false); 2955 #else 2956 rpcSlice->setNoOutputPicPrior( false ); 2957 #endif 2958 } 2959 READ_UVLC ( uiCode, "slice_pic_parameter_set_id" ); rpcSlice->setPPSId(uiCode); 2960 pps = parameterSetManager->getPrefetchedPPS(uiCode); 2961 //!KS: need to add error handling code here, if PPS is not available 2962 assert(pps!=0); 2963 sps = parameterSetManager->getPrefetchedSPS(pps->getSPSId()); 2964 //!KS: need to add error handling code here, if SPS is not available 2965 assert(sps!=0); 2966 rpcSlice->setSPS(sps); 2967 rpcSlice->setPPS(pps); 2968 2969 #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 2970 TComVPS* vps = NULL; 2971 vps = parameterSetManager->getPrefetchedVPS(sps->getVPSId()); 2972 #if R0279_REP_FORMAT_INBL 2973 if ( vps->getVpsExtensionFlag() == 1 && (rpcSlice->getLayerId() == 0 || sps->getV1CompatibleSPSFlag() == 1) ) 2974 { 2975 assert( sps->getPicWidthInLumaSamples() <= vps->getVpsRepFormat( vps->getVpsRepFormatIdx(rpcSlice->getLayerId()) )->getPicWidthVpsInLumaSamples() ); 2976 assert( sps->getPicHeightInLumaSamples() <= vps->getVpsRepFormat( vps->getVpsRepFormatIdx(rpcSlice->getLayerId()) )->getPicHeightVpsInLumaSamples() ); 2977 assert( sps->getChromaFormatIdc() <= vps->getVpsRepFormat( vps->getVpsRepFormatIdx(rpcSlice->getLayerId()) )->getChromaFormatVpsIdc() ); 2978 assert( sps->getBitDepthY() <= vps->getVpsRepFormat( vps->getVpsRepFormatIdx(rpcSlice->getLayerId()) )->getBitDepthVpsLuma() ); 2979 assert( sps->getBitDepthC() <= vps->getVpsRepFormat( vps->getVpsRepFormatIdx(rpcSlice->getLayerId()) )->getBitDepthVpsChroma() ); 2980 #else 2981 if ( rpcSlice->getLayerId() == 0 && vps->getVpsExtensionFlag() == 1 ) 2982 { 2983 assert( sps->getPicWidthInLumaSamples() <= vps->getVpsRepFormat( vps->getVpsRepFormatIdx(0) )->getPicWidthVpsInLumaSamples() ); 2984 assert( sps->getPicHeightInLumaSamples() <= vps->getVpsRepFormat( vps->getVpsRepFormatIdx(0) )->getPicHeightVpsInLumaSamples() ); 2985 assert( sps->getChromaFormatIdc() <= vps->getVpsRepFormat( vps->getVpsRepFormatIdx(0) )->getChromaFormatVpsIdc() ); 2986 assert( sps->getBitDepthY() <= vps->getVpsRepFormat( vps->getVpsRepFormatIdx(0) )->getBitDepthVpsLuma() ); 2987 assert( sps->getBitDepthC() <= vps->getVpsRepFormat( vps->getVpsRepFormatIdx(0) )->getBitDepthVpsChroma() ); 2988 #endif 2989 } 2990 else if ( vps->getVpsExtensionFlag() == 1 ) 2991 { 2992 assert(vps->getVpsRepFormat( vps->getVpsRepFormatIdx(sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : rpcSlice->getLayerId()))->getPicWidthVpsInLumaSamples() <= vps->getVpsRepFormat( vps->getVpsRepFormatIdx(rpcSlice->getLayerId()))->getPicWidthVpsInLumaSamples()); 2993 assert(vps->getVpsRepFormat( vps->getVpsRepFormatIdx(sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : rpcSlice->getLayerId()))->getPicHeightVpsInLumaSamples() <= vps->getVpsRepFormat( vps->getVpsRepFormatIdx(rpcSlice->getLayerId()))->getPicHeightVpsInLumaSamples()); 2994 assert(vps->getVpsRepFormat( vps->getVpsRepFormatIdx(sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : rpcSlice->getLayerId()))->getChromaFormatVpsIdc() <= vps->getVpsRepFormat( vps->getVpsRepFormatIdx(rpcSlice->getLayerId()))->getChromaFormatVpsIdc()); 2995 assert(vps->getVpsRepFormat( vps->getVpsRepFormatIdx(sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : rpcSlice->getLayerId()))->getBitDepthVpsLuma() <= vps->getVpsRepFormat( vps->getVpsRepFormatIdx(rpcSlice->getLayerId()))->getBitDepthVpsLuma()); 2996 assert(vps->getVpsRepFormat( vps->getVpsRepFormatIdx(sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : rpcSlice->getLayerId()))->getBitDepthVpsChroma() <= vps->getVpsRepFormat( vps->getVpsRepFormatIdx(rpcSlice->getLayerId()))->getBitDepthVpsChroma()); 2997 } 2998 #endif 2999 3000 if( pps->getDependentSliceSegmentsEnabledFlag() && ( !firstSliceSegmentInPic )) 3001 { 3002 READ_FLAG( uiCode, "dependent_slice_segment_flag" ); rpcSlice->setDependentSliceSegmentFlag(uiCode ? true : false); 3003 } 3004 else 3005 { 3006 rpcSlice->setDependentSliceSegmentFlag(false); 3007 } 3008 #if REPN_FORMAT_IN_VPS 3009 Int numCTUs = ((rpcSlice->getPicWidthInLumaSamples()+sps->getMaxCUWidth()-1)/sps->getMaxCUWidth())*((rpcSlice->getPicHeightInLumaSamples()+sps->getMaxCUHeight()-1)/sps->getMaxCUHeight()); 3010 #else 3011 Int numCTUs = ((sps->getPicWidthInLumaSamples()+sps->getMaxCUWidth()-1)/sps->getMaxCUWidth())*((sps->getPicHeightInLumaSamples()+sps->getMaxCUHeight()-1)/sps->getMaxCUHeight()); 3012 #endif 3013 Int maxParts = (1<<(sps->getMaxCUDepth()<<1)); 3014 UInt sliceSegmentAddress = 0; 3015 Int bitsSliceSegmentAddress = 0; 3016 while(numCTUs>(1<<bitsSliceSegmentAddress)) 3017 { 3018 bitsSliceSegmentAddress++; 3019 } 3020 3021 if(!firstSliceSegmentInPic) 3022 { 3023 READ_CODE( bitsSliceSegmentAddress, sliceSegmentAddress, "slice_segment_address" ); 3024 } 3025 //set uiCode to equal slice start address (or dependent slice start address) 3026 Int startCuAddress = maxParts*sliceSegmentAddress; 3027 rpcSlice->setSliceSegmentCurStartCUAddr( startCuAddress ); 3028 rpcSlice->setSliceSegmentCurEndCUAddr(numCTUs*maxParts); 3029 3030 if (rpcSlice->getDependentSliceSegmentFlag()) 3031 { 3032 rpcSlice->setNextSlice ( false ); 3033 rpcSlice->setNextSliceSegment ( true ); 3034 } 3035 else 3036 { 3037 rpcSlice->setNextSlice ( true ); 3038 rpcSlice->setNextSliceSegment ( false ); 3039 3040 rpcSlice->setSliceCurStartCUAddr(startCuAddress); 3041 rpcSlice->setSliceCurEndCUAddr(numCTUs*maxParts); 3042 } 3043 3044 #if Q0142_POC_LSB_NOT_PRESENT 3045 #if SHM_FIX7 3046 Int iPOClsb = 0; 3047 #endif 3048 #endif 3049 3050 if(!rpcSlice->getDependentSliceSegmentFlag()) 3051 { 3052 #if SVC_EXTENSION 3053 #if POC_RESET_FLAG 3054 Int iBits = 0; 3055 if(rpcSlice->getPPS()->getNumExtraSliceHeaderBits() > iBits) 3056 { 3057 READ_FLAG(uiCode, "poc_reset_flag"); rpcSlice->setPocResetFlag( uiCode ? true : false ); 3058 iBits++; 3059 } 3060 if(rpcSlice->getPPS()->getNumExtraSliceHeaderBits() > iBits) 3061 { 3062 #if DISCARDABLE_PIC_RPS 3063 READ_FLAG(uiCode, "discardable_flag"); rpcSlice->setDiscardableFlag( uiCode ? true : false ); 3064 #else 3065 READ_FLAG(uiCode, "discardable_flag"); // ignored 3066 #endif 3067 iBits++; 3068 } 3069 #if O0149_CROSS_LAYER_BLA_FLAG 3070 if(rpcSlice->getPPS()->getNumExtraSliceHeaderBits() > iBits) 3071 { 3072 READ_FLAG(uiCode, "cross_layer_bla_flag"); rpcSlice->setCrossLayerBLAFlag( uiCode ? true : false ); 3073 iBits++; 3074 } 3075 #endif 3076 for (; iBits < rpcSlice->getPPS()->getNumExtraSliceHeaderBits(); iBits++) 3077 { 3078 READ_FLAG(uiCode, "slice_reserved_undetermined_flag[]"); // ignored 3079 } 3080 #else 3081 #if CROSS_LAYER_BLA_FLAG_FIX 3082 Int iBits = 0; 3083 if(rpcSlice->getPPS()->getNumExtraSliceHeaderBits() > iBits) 3084 #else 3085 if(rpcSlice->getPPS()->getNumExtraSliceHeaderBits()>0) 3086 #endif 3087 { 3088 READ_FLAG(uiCode, "discardable_flag"); // ignored 3089 #if NON_REF_NAL_TYPE_DISCARDABLE 3090 rpcSlice->setDiscardableFlag( uiCode ? true : false ); 3091 if (uiCode) 3092 { 3093 assert(rpcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_TRAIL_R && 3094 rpcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_TSA_R && 3095 rpcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_STSA_R && 3096 rpcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_RADL_R && 3097 rpcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_RASL_R); 3098 } 3099 #endif 3100 #if CROSS_LAYER_BLA_FLAG_FIX 3101 iBits++; 3102 #endif 3103 } 3104 #if CROSS_LAYER_BLA_FLAG_FIX 3105 if(rpcSlice->getPPS()->getNumExtraSliceHeaderBits() > iBits) 3106 { 3107 READ_FLAG(uiCode, "cross_layer_bla_flag"); rpcSlice->setCrossLayerBLAFlag( uiCode ? true : false ); 3108 iBits++; 3109 } 3110 for ( ; iBits < rpcSlice->getPPS()->getNumExtraSliceHeaderBits(); iBits++) 3111 #else 3112 for (Int i = 1; i < rpcSlice->getPPS()->getNumExtraSliceHeaderBits(); i++) 3113 #endif 3114 { 3115 READ_FLAG(uiCode, "slice_reserved_undetermined_flag[]"); // ignored 3116 } 3117 #endif 3118 #else //SVC_EXTENSION 3119 for (Int i = 0; i < rpcSlice->getPPS()->getNumExtraSliceHeaderBits(); i++) 3120 { 3121 READ_FLAG(uiCode, "slice_reserved_undetermined_flag[]"); // ignored 3122 } 3123 #endif //SVC_EXTENSION 3124 3125 READ_UVLC ( uiCode, "slice_type" ); rpcSlice->setSliceType((SliceType)uiCode); 3126 if( pps->getOutputFlagPresentFlag() ) 3127 { 3128 READ_FLAG( uiCode, "pic_output_flag" ); rpcSlice->setPicOutputFlag( uiCode ? true : false ); 3129 } 3130 else 3131 { 3132 rpcSlice->setPicOutputFlag( true ); 3133 } 3134 // in the first version chroma_format_idc is equal to one, thus colour_plane_id will not be present 3135 assert (sps->getChromaFormatIdc() == 1 ); 3136 // if( separate_colour_plane_flag == 1 ) 3137 // colour_plane_id u(2) 3138 3139 if( rpcSlice->getIdrPicFlag() ) 3140 { 3141 rpcSlice->setPOC(0); 3142 TComReferencePictureSet* rps = rpcSlice->getLocalRPS(); 3143 rps->setNumberOfNegativePictures(0); 3144 rps->setNumberOfPositivePictures(0); 3145 rps->setNumberOfLongtermPictures(0); 3146 rps->setNumberOfPictures(0); 3147 rpcSlice->setRPS(rps); 3148 } 3149 #if N0065_LAYER_POC_ALIGNMENT 3150 #if !Q0142_POC_LSB_NOT_PRESENT 3151 #if SHM_FIX7 3152 Int iPOClsb = 0; 3153 #endif 3154 #endif 3155 #if O0062_POC_LSB_NOT_PRESENT_FLAG 3156 if( ( rpcSlice->getLayerId() > 0 && !rpcSlice->getVPS()->getPocLsbNotPresentFlag( rpcSlice->getVPS()->getLayerIdInVps(rpcSlice->getLayerId())) ) || !rpcSlice->getIdrPicFlag()) 3157 #else 3158 if( rpcSlice->getLayerId() > 0 || !rpcSlice->getIdrPicFlag() ) 3159 #endif 3160 #else 3161 else 3162 #endif 3163 { 3164 READ_CODE(sps->getBitsForPOC(), uiCode, "pic_order_cnt_lsb"); 3165 #if POC_RESET_IDC_DECODER 3166 rpcSlice->setPicOrderCntLsb( uiCode ); 3167 #endif 3168 #if SHM_FIX7 3169 iPOClsb = uiCode; 3170 #else 3171 Int iPOClsb = uiCode; 3172 #endif 3173 Int iPrevPOC = rpcSlice->getPrevTid0POC(); 3174 Int iMaxPOClsb = 1<< sps->getBitsForPOC(); 3175 Int iPrevPOClsb = iPrevPOC & (iMaxPOClsb - 1); 3176 Int iPrevPOCmsb = iPrevPOC-iPrevPOClsb; 3177 Int iPOCmsb; 3178 if( ( iPOClsb < iPrevPOClsb ) && ( ( iPrevPOClsb - iPOClsb ) >= ( iMaxPOClsb / 2 ) ) ) 3179 { 3180 iPOCmsb = iPrevPOCmsb + iMaxPOClsb; 3181 } 3182 else if( (iPOClsb > iPrevPOClsb ) && ( (iPOClsb - iPrevPOClsb ) > ( iMaxPOClsb / 2 ) ) ) 3183 { 3184 iPOCmsb = iPrevPOCmsb - iMaxPOClsb; 3185 } 3186 else 3187 { 3188 iPOCmsb = iPrevPOCmsb; 3189 } 3190 if ( rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP 3191 || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL 3192 || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP ) 3193 { 3194 // For BLA picture types, POCmsb is set to 0. 3195 iPOCmsb = 0; 3196 } 3197 rpcSlice->setPOC (iPOCmsb+iPOClsb); 3198 3199 #if N0065_LAYER_POC_ALIGNMENT 3200 #if SHM_FIX7 3201 } 3202 #endif 3203 #if POC_RESET_IDC_DECODER 3204 else 3205 { 3206 rpcSlice->setPicOrderCntLsb( 0 ); 3207 } 3208 #endif 3209 if( !rpcSlice->getIdrPicFlag() ) 3210 { 3211 #endif 3212 TComReferencePictureSet* rps; 3213 rps = rpcSlice->getLocalRPS(); 3214 rpcSlice->setRPS(rps); 3215 READ_FLAG( uiCode, "short_term_ref_pic_set_sps_flag" ); 3216 if(uiCode == 0) // use short-term reference picture set explicitly signalled in slice header 3217 { 3218 parseShortTermRefPicSet(sps,rps, sps->getRPSList()->getNumberOfReferencePictureSets()); 3219 } 3220 else // use reference to short-term reference picture set in PPS 3221 { 3222 Int numBits = 0; 3223 while ((1 << numBits) < rpcSlice->getSPS()->getRPSList()->getNumberOfReferencePictureSets()) 3224 { 3225 numBits++; 3226 } 3227 if (numBits > 0) 3228 { 3229 READ_CODE( numBits, uiCode, "short_term_ref_pic_set_idx"); 3230 } 3231 else 3232 { 3233 uiCode = 0; 3234 } 3235 *rps = *(sps->getRPSList()->getReferencePictureSet(uiCode)); 3236 } 3237 if(sps->getLongTermRefsPresent()) 3238 { 3239 Int offset = rps->getNumberOfNegativePictures()+rps->getNumberOfPositivePictures(); 3240 UInt numOfLtrp = 0; 3241 UInt numLtrpInSPS = 0; 3242 if (rpcSlice->getSPS()->getNumLongTermRefPicSPS() > 0) 3243 { 3244 READ_UVLC( uiCode, "num_long_term_sps"); 3245 numLtrpInSPS = uiCode; 3246 numOfLtrp += numLtrpInSPS; 3247 rps->setNumberOfLongtermPictures(numOfLtrp); 3248 } 3249 Int bitsForLtrpInSPS = 0; 3250 while (rpcSlice->getSPS()->getNumLongTermRefPicSPS() > (1 << bitsForLtrpInSPS)) 3251 { 3252 bitsForLtrpInSPS++; 3253 } 3254 READ_UVLC( uiCode, "num_long_term_pics"); rps->setNumberOfLongtermPictures(uiCode); 3255 numOfLtrp += uiCode; 3256 rps->setNumberOfLongtermPictures(numOfLtrp); 3257 Int maxPicOrderCntLSB = 1 << rpcSlice->getSPS()->getBitsForPOC(); 3258 Int prevDeltaMSB = 0, deltaPocMSBCycleLT = 0;; 3259 for(Int j=offset+rps->getNumberOfLongtermPictures()-1, k = 0; k < numOfLtrp; j--, k++) 3260 { 3261 Int pocLsbLt; 3262 if (k < numLtrpInSPS) 3263 { 3264 uiCode = 0; 3265 if (bitsForLtrpInSPS > 0) 3266 { 3267 READ_CODE(bitsForLtrpInSPS, uiCode, "lt_idx_sps[i]"); 3268 } 3269 Int usedByCurrFromSPS=rpcSlice->getSPS()->getUsedByCurrPicLtSPSFlag(uiCode); 3270 3271 pocLsbLt = rpcSlice->getSPS()->getLtRefPicPocLsbSps(uiCode); 3272 rps->setUsed(j,usedByCurrFromSPS); 3273 } 3274 else 3275 { 3276 READ_CODE(rpcSlice->getSPS()->getBitsForPOC(), uiCode, "poc_lsb_lt"); pocLsbLt= uiCode; 3277 READ_FLAG( uiCode, "used_by_curr_pic_lt_flag"); rps->setUsed(j,uiCode); 3278 } 3279 READ_FLAG(uiCode,"delta_poc_msb_present_flag"); 3280 Bool mSBPresentFlag = uiCode ? true : false; 3281 if(mSBPresentFlag) 3282 { 3283 READ_UVLC( uiCode, "delta_poc_msb_cycle_lt[i]" ); 3284 Bool deltaFlag = false; 3285 // First LTRP || First LTRP from SH 3286 if( (j == offset+rps->getNumberOfLongtermPictures()-1) || (j == offset+(numOfLtrp-numLtrpInSPS)-1) ) 3287 { 3288 deltaFlag = true; 3289 } 3290 if(deltaFlag) 3291 { 3292 deltaPocMSBCycleLT = uiCode; 3293 } 3294 else 3295 { 3296 deltaPocMSBCycleLT = uiCode + prevDeltaMSB; 3297 } 3298 3299 Int pocLTCurr = rpcSlice->getPOC() - deltaPocMSBCycleLT * maxPicOrderCntLSB 3300 - iPOClsb + pocLsbLt; 3301 rps->setPOC (j, pocLTCurr); 3302 rps->setDeltaPOC(j, - rpcSlice->getPOC() + pocLTCurr); 3303 rps->setCheckLTMSBPresent(j,true); 3304 } 3305 else 3306 { 3307 rps->setPOC (j, pocLsbLt); 3308 rps->setDeltaPOC(j, - rpcSlice->getPOC() + pocLsbLt); 3309 rps->setCheckLTMSBPresent(j,false); 3310 3311 // reset deltaPocMSBCycleLT for first LTRP from slice header if MSB not present 3312 if( j == offset+(numOfLtrp-numLtrpInSPS)-1 ) 3313 { 3314 deltaPocMSBCycleLT = 0; 3315 } 3316 } 3317 prevDeltaMSB = deltaPocMSBCycleLT; 3318 } 3319 offset += rps->getNumberOfLongtermPictures(); 3320 rps->setNumberOfPictures(offset); 3321 } 3322 #if DPB_CONSTRAINTS 3323 if(rpcSlice->getVPS()->getVpsExtensionFlag()==1) 3324 { 3325 #if Q0078_ADD_LAYER_SETS 3326 for (Int ii = 1; ii < (rpcSlice->getVPS()->getVpsNumLayerSetsMinus1() + 1); ii++) // prevent assert error when num_add_layer_sets > 0 3327 #else 3328 for (Int ii=1; ii< rpcSlice->getVPS()->getNumOutputLayerSets(); ii++ ) 3329 #endif 3330 { 3331 Int layerSetIdxForOutputLayerSet = rpcSlice->getVPS()->getOutputLayerSetIdx( ii ); 3332 Int chkAssert=0; 3333 for(Int kk = 0; kk < rpcSlice->getVPS()->getNumLayersInIdList(layerSetIdxForOutputLayerSet); kk++) 3334 { 3335 if(rpcSlice->getLayerId()==rpcSlice->getVPS()->getLayerSetLayerIdList(layerSetIdxForOutputLayerSet, kk)) 3336 { 3337 chkAssert=1; 3338 } 3339 } 3340 if(chkAssert) 3341 { 3342 // There may be something wrong here (layer id assumed to be layer idx?) 3343 assert(rps->getNumberOfNegativePictures() <= rpcSlice->getVPS()->getMaxVpsDecPicBufferingMinus1(ii , rpcSlice->getLayerId() , rpcSlice->getVPS()->getMaxSLayersInLayerSetMinus1(ii))); 3344 assert(rps->getNumberOfPositivePictures() <= rpcSlice->getVPS()->getMaxVpsDecPicBufferingMinus1(ii , rpcSlice->getLayerId() , rpcSlice->getVPS()->getMaxSLayersInLayerSetMinus1(ii)) - rps->getNumberOfNegativePictures()); 3345 assert((rps->getNumberOfPositivePictures() + rps->getNumberOfNegativePictures() + rps->getNumberOfLongtermPictures()) <= rpcSlice->getVPS()->getMaxVpsDecPicBufferingMinus1(ii , rpcSlice->getLayerId() , rpcSlice->getVPS()->getMaxSLayersInLayerSetMinus1(ii))); 3346 } 3347 } 3348 3349 3350 } 3351 if(rpcSlice->getLayerId() == 0) 3352 { 3353 assert(rps->getNumberOfNegativePictures() <= rpcSlice->getSPS()->getMaxDecPicBuffering(rpcSlice->getSPS()->getMaxTLayers()-1) ); 3354 assert(rps->getNumberOfPositivePictures() <= rpcSlice->getSPS()->getMaxDecPicBuffering(rpcSlice->getSPS()->getMaxTLayers()-1) -rps->getNumberOfNegativePictures()); 3355 assert((rps->getNumberOfPositivePictures() + rps->getNumberOfNegativePictures() + rps->getNumberOfLongtermPictures()) <= rpcSlice->getSPS()->getMaxDecPicBuffering(rpcSlice->getSPS()->getMaxTLayers()-1)); 3356 } 3357 #endif 3358 if ( rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP 3359 || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL 3360 || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP ) 3361 { 3362 // In the case of BLA picture types, rps data is read from slice header but ignored 3363 rps = rpcSlice->getLocalRPS(); 3364 rps->setNumberOfNegativePictures(0); 3365 rps->setNumberOfPositivePictures(0); 3366 rps->setNumberOfLongtermPictures(0); 3367 rps->setNumberOfPictures(0); 3368 rpcSlice->setRPS(rps); 3369 } 3370 if (rpcSlice->getSPS()->getTMVPFlagsPresent()) 3371 { 3372 #if R0226_SLICE_TMVP 3373 READ_FLAG( uiCode, "slice_temporal_mvp_enabled_flag" ); 3374 #else 3375 READ_FLAG( uiCode, "slice_temporal_mvp_enable_flag" ); 3376 #endif 3377 rpcSlice->setEnableTMVPFlag( uiCode == 1 ? true : false ); 3378 } 3379 else 3380 { 3381 rpcSlice->setEnableTMVPFlag(false); 3382 } 3383 #if N0065_LAYER_POC_ALIGNMENT && !SHM_FIX7 3384 } 3385 #endif 3386 } 3387 3388 #if SVC_EXTENSION 3389 rpcSlice->setActiveNumILRRefIdx(0); 3390 if((rpcSlice->getLayerId() > 0) && !(rpcSlice->getVPS()->getIlpSshSignalingEnabledFlag()) && (rpcSlice->getNumILRRefIdx() > 0) ) 3391 { 3392 READ_FLAG(uiCode,"inter_layer_pred_enabled_flag"); 3393 rpcSlice->setInterLayerPredEnabledFlag(uiCode); 3394 if( rpcSlice->getInterLayerPredEnabledFlag()) 3395 { 3396 if(rpcSlice->getNumILRRefIdx() > 1) 3397 { 3398 Int numBits = 1; 3399 while ((1 << numBits) < rpcSlice->getNumILRRefIdx()) 3400 { 3401 numBits++; 3402 } 3403 if( !rpcSlice->getVPS()->getMaxOneActiveRefLayerFlag()) 3404 { 3405 READ_CODE( numBits, uiCode,"num_inter_layer_ref_pics_minus1" ); 3406 rpcSlice->setActiveNumILRRefIdx(uiCode + 1); 3407 } 3408 else 3409 { 3410 #if P0079_DERIVE_NUMACTIVE_REF_PICS 3411 for( Int i = 0; i < rpcSlice->getNumILRRefIdx(); i++ ) 3412 { 3413 #if Q0060_MAX_TID_REF_EQUAL_TO_ZERO 3414 if((rpcSlice->getVPS()->getMaxTidIlRefPicsPlus1(rpcSlice->getVPS()->getLayerIdInVps(i),rpcSlice->getLayerId()) > rpcSlice->getTLayer() || rpcSlice->getTLayer()==0) && 3415 (rpcSlice->getVPS()->getMaxTSLayersMinus1(rpcSlice->getVPS()->getLayerIdInVps(i)) >= rpcSlice->getTLayer()) ) 3416 #else 3417 if(rpcSlice->getVPS()->getMaxTidIlRefPicsPlus1(rpcSlice->getVPS()->getLayerIdInVps(i),rpcSlice->getLayerId()) > rpcSlice->getTLayer() && 3418 (rpcSlice->getVPS()->getMaxTSLayersMinus1(rpcSlice->getVPS()->getLayerIdInVps(i)) >= rpcSlice->getTLayer()) ) 3419 #endif 3420 { 3421 rpcSlice->setActiveNumILRRefIdx(1); 3422 break; 3423 } 3424 } 3425 #else 3426 rpcSlice->setActiveNumILRRefIdx(1); 3427 #endif 3428 } 3429 3430 if( rpcSlice->getActiveNumILRRefIdx() == rpcSlice->getNumILRRefIdx() ) 3431 { 3432 for( Int i = 0; i < rpcSlice->getActiveNumILRRefIdx(); i++ ) 3433 { 3434 rpcSlice->setInterLayerPredLayerIdc(i,i); 3435 } 3436 } 3437 else 3438 { 3439 for(Int i = 0; i < rpcSlice->getActiveNumILRRefIdx(); i++ ) 3440 { 3441 READ_CODE( numBits,uiCode,"inter_layer_pred_layer_idc[i]" ); 3442 rpcSlice->setInterLayerPredLayerIdc(uiCode,i); 3443 } 3444 } 3445 } 3446 else 3447 { 3448 #if O0225_TID_BASED_IL_RPS_DERIV && TSLAYERS_IL_RPS 3449 #if Q0060_MAX_TID_REF_EQUAL_TO_ZERO 3450 if((rpcSlice->getVPS()->getMaxTidIlRefPicsPlus1(0,rpcSlice->getLayerId()) > rpcSlice->getTLayer() || rpcSlice->getTLayer()==0) && 3451 (rpcSlice->getVPS()->getMaxTSLayersMinus1(0) >= rpcSlice->getTLayer()) ) 3452 #else 3453 if( (rpcSlice->getVPS()->getMaxTidIlRefPicsPlus1(0,rpcSlice->getLayerId()) > rpcSlice->getTLayer()) && 3454 (rpcSlice->getVPS()->getMaxTSLayersMinus1(0) >= rpcSlice->getTLayer()) ) 3455 #endif 3456 { 3457 #endif 3458 rpcSlice->setActiveNumILRRefIdx(1); 3459 rpcSlice->setInterLayerPredLayerIdc(0,0); 3460 #if O0225_TID_BASED_IL_RPS_DERIV && TSLAYERS_IL_RPS 3461 } 3462 #endif 3463 } 3464 } 3465 } 3466 else if( rpcSlice->getVPS()->getIlpSshSignalingEnabledFlag() == true && (rpcSlice->getLayerId() > 0 )) 3467 { 3468 rpcSlice->setInterLayerPredEnabledFlag(true); 3469 3470 #if O0225_TID_BASED_IL_RPS_DERIV && TSLAYERS_IL_RPS 3471 Int numRefLayerPics = 0; 3472 Int i = 0; 3473 Int refLayerPicIdc [MAX_VPS_LAYER_ID_PLUS1]; 3474 for(i = 0, numRefLayerPics = 0; i < rpcSlice->getNumILRRefIdx(); i++ ) 3475 { 3476 #if Q0060_MAX_TID_REF_EQUAL_TO_ZERO 3477 if((rpcSlice->getVPS()->getMaxTidIlRefPicsPlus1(rpcSlice->getVPS()->getLayerIdInVps(i),rpcSlice->getLayerId()) > rpcSlice->getTLayer() || rpcSlice->getTLayer()==0) && 3478 (rpcSlice->getVPS()->getMaxTSLayersMinus1(rpcSlice->getVPS()->getLayerIdInVps(i)) >= rpcSlice->getTLayer()) ) 3479 #else 3480 if(rpcSlice->getVPS()->getMaxTidIlRefPicsPlus1(rpcSlice->getVPS()->getLayerIdInVps(i),rpcSlice->getLayerId()) > rpcSlice->getTLayer() && 3481 (rpcSlice->getVPS()->getMaxTSLayersMinus1(rpcSlice->getVPS()->getLayerIdInVps(i)) >= rpcSlice->getTLayer()) ) 3482 #endif 3483 { 3484 refLayerPicIdc[ numRefLayerPics++ ] = i; 3485 } 3486 } 3487 rpcSlice->setActiveNumILRRefIdx(numRefLayerPics); 3488 for( i = 0; i < rpcSlice->getActiveNumILRRefIdx(); i++ ) 3489 { 3490 rpcSlice->setInterLayerPredLayerIdc(refLayerPicIdc[i],i); 3491 } 3492 #else 3493 rpcSlice->setActiveNumILRRefIdx(rpcSlice->getNumILRRefIdx()); 3494 for( Int i = 0; i < rpcSlice->getActiveNumILRRefIdx(); i++ ) 3495 { 3496 rpcSlice->setInterLayerPredLayerIdc(i,i); 3497 } 3498 #endif 3499 } 4299 Void TDecCavlc::parseSPSExtension( TComSPS* pcSPS ) 4300 { 4301 UInt uiCode; 4302 // more syntax elements to be parsed here 4303 4304 READ_FLAG( uiCode, "inter_view_mv_vert_constraint_flag" ); 4305 // Vertical MV component restriction is not used in SHVC CTC 4306 assert( uiCode == 0 ); 4307 4308 #if !MOVE_SCALED_OFFSET_TO_PPS 4309 if( pcSPS->getLayerId() > 0 ) 4310 { 4311 Int iCode; 4312 READ_UVLC( uiCode, "num_scaled_ref_layer_offsets" ); pcSPS->setNumScaledRefLayerOffsets(uiCode); 4313 for(Int i = 0; i < pcSPS->getNumScaledRefLayerOffsets(); i++) 4314 { 4315 Window& scaledWindow = pcSPS->getScaledRefLayerWindow(i); 4316 #if O0098_SCALED_REF_LAYER_ID 4317 READ_CODE( 6, uiCode, "scaled_ref_layer_id" ); pcSPS->setScaledRefLayerId( i, uiCode ); 4318 #endif 4319 READ_SVLC( iCode, "scaled_ref_layer_left_offset" ); scaledWindow.setWindowLeftOffset (iCode << 1); 4320 READ_SVLC( iCode, "scaled_ref_layer_top_offset" ); scaledWindow.setWindowTopOffset (iCode << 1); 4321 READ_SVLC( iCode, "scaled_ref_layer_right_offset" ); scaledWindow.setWindowRightOffset (iCode << 1); 4322 READ_SVLC( iCode, "scaled_ref_layer_bottom_offset" ); scaledWindow.setWindowBottomOffset(iCode << 1); 3500 4323 #if P0312_VERT_PHASE_ADJ 3501 for(Int i = 0; i < rpcSlice->getActiveNumILRRefIdx(); i++ ) 3502 { 3503 UInt refLayerIdc = rpcSlice->getInterLayerPredLayerIdc(i); 3504 #if !MOVE_SCALED_OFFSET_TO_PPS 3505 if( rpcSlice->getSPS()->getVertPhasePositionEnableFlag(refLayerIdc) ) 3506 #else 3507 if( rpcSlice->getPPS()->getVertPhasePositionEnableFlag(refLayerIdc) ) 3508 #endif 3509 { 3510 READ_FLAG( uiCode, "vert_phase_position_flag" ); rpcSlice->setVertPhasePositionFlag( uiCode? true : false, refLayerIdc ); 3511 } 3512 } 3513 #endif 3514 #endif //SVC_EXTENSION 3515 3516 if(sps->getUseSAO()) 3517 { 3518 READ_FLAG(uiCode, "slice_sao_luma_flag"); rpcSlice->setSaoEnabledFlag((Bool)uiCode); 3519 #if AUXILIARY_PICTURES 3520 ChromaFormat format; 3521 #if REPN_FORMAT_IN_VPS 3522 #if O0096_REP_FORMAT_INDEX 3523 if( sps->getLayerId() == 0 ) 3524 { 3525 format = sps->getChromaFormatIdc(); 3526 } 3527 else 3528 { 3529 format = rpcSlice->getVPS()->getVpsRepFormat( sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : rpcSlice->getVPS()->getVpsRepFormatIdx(sps->getLayerId()) )->getChromaFormatVpsIdc(); 3530 #if Q0195_REP_FORMAT_CLEANUP 3531 assert( (sps->getUpdateRepFormatFlag()==false && rpcSlice->getVPS()->getVpsNumRepFormats()==1) || rpcSlice->getVPS()->getVpsNumRepFormats() > 1 ); //conformance check 3532 #endif 3533 } 3534 #else 3535 if( ( sps->getLayerId() == 0 ) || sps->getUpdateRepFormatFlag() ) 3536 { 3537 format = sps->getChromaFormatIdc(); 3538 } 3539 else 3540 { 3541 format = rpcSlice->getVPS()->getVpsRepFormat( rpcSlice->getVPS()->getVpsRepFormatIdx(sps->getLayerId()) )->getChromaFormatVpsIdc(); 3542 } 3543 #endif 3544 #else 3545 format = sps->getChromaFormatIdc(); 3546 #endif 3547 if (format != CHROMA_400) 3548 { 3549 #endif 3550 READ_FLAG(uiCode, "slice_sao_chroma_flag"); rpcSlice->setSaoEnabledFlagChroma((Bool)uiCode); 3551 #if AUXILIARY_PICTURES 3552 } 3553 else 3554 { 3555 rpcSlice->setSaoEnabledFlagChroma(false); 3556 } 3557 #endif 3558 } 3559 3560 if (rpcSlice->getIdrPicFlag()) 3561 { 3562 rpcSlice->setEnableTMVPFlag(false); 3563 } 3564 if (!rpcSlice->isIntra()) 3565 { 3566 3567 READ_FLAG( uiCode, "num_ref_idx_active_override_flag"); 3568 if (uiCode) 3569 { 3570 READ_UVLC (uiCode, "num_ref_idx_l0_active_minus1" ); rpcSlice->setNumRefIdx( REF_PIC_LIST_0, uiCode + 1 ); 3571 if (rpcSlice->isInterB()) 3572 { 3573 READ_UVLC (uiCode, "num_ref_idx_l1_active_minus1" ); rpcSlice->setNumRefIdx( REF_PIC_LIST_1, uiCode + 1 ); 3574 } 3575 else 3576 { 3577 rpcSlice->setNumRefIdx(REF_PIC_LIST_1, 0); 3578 } 3579 } 3580 else 3581 { 3582 rpcSlice->setNumRefIdx(REF_PIC_LIST_0, rpcSlice->getPPS()->getNumRefIdxL0DefaultActive()); 3583 if (rpcSlice->isInterB()) 3584 { 3585 rpcSlice->setNumRefIdx(REF_PIC_LIST_1, rpcSlice->getPPS()->getNumRefIdxL1DefaultActive()); 3586 } 3587 else 3588 { 3589 rpcSlice->setNumRefIdx(REF_PIC_LIST_1,0); 3590 } 3591 } 3592 } 3593 // } 3594 TComRefPicListModification* refPicListModification = rpcSlice->getRefPicListModification(); 3595 if(!rpcSlice->isIntra()) 3596 { 3597 if( !rpcSlice->getPPS()->getListsModificationPresentFlag() || rpcSlice->getNumRpsCurrTempList() <= 1 ) 3598 { 3599 refPicListModification->setRefPicListModificationFlagL0( 0 ); 3600 } 3601 else 3602 { 3603 READ_FLAG( uiCode, "ref_pic_list_modification_flag_l0" ); refPicListModification->setRefPicListModificationFlagL0( uiCode ? 1 : 0 ); 3604 } 3605 3606 if(refPicListModification->getRefPicListModificationFlagL0()) 3607 { 3608 uiCode = 0; 3609 Int i = 0; 3610 Int numRpsCurrTempList0 = rpcSlice->getNumRpsCurrTempList(); 3611 if ( numRpsCurrTempList0 > 1 ) 3612 { 3613 Int length = 1; 3614 numRpsCurrTempList0 --; 3615 while ( numRpsCurrTempList0 >>= 1) 3616 { 3617 length ++; 3618 } 3619 for (i = 0; i < rpcSlice->getNumRefIdx(REF_PIC_LIST_0); i ++) 3620 { 3621 READ_CODE( length, uiCode, "list_entry_l0" ); 3622 refPicListModification->setRefPicSetIdxL0(i, uiCode ); 3623 } 3624 } 3625 else 3626 { 3627 for (i = 0; i < rpcSlice->getNumRefIdx(REF_PIC_LIST_0); i ++) 3628 { 3629 refPicListModification->setRefPicSetIdxL0(i, 0 ); 3630 } 3631 } 3632 } 3633 } 3634 else 3635 { 3636 refPicListModification->setRefPicListModificationFlagL0(0); 3637 } 3638 if(rpcSlice->isInterB()) 3639 { 3640 if( !rpcSlice->getPPS()->getListsModificationPresentFlag() || rpcSlice->getNumRpsCurrTempList() <= 1 ) 3641 { 3642 refPicListModification->setRefPicListModificationFlagL1( 0 ); 3643 } 3644 else 3645 { 3646 READ_FLAG( uiCode, "ref_pic_list_modification_flag_l1" ); refPicListModification->setRefPicListModificationFlagL1( uiCode ? 1 : 0 ); 3647 } 3648 if(refPicListModification->getRefPicListModificationFlagL1()) 3649 { 3650 uiCode = 0; 3651 Int i = 0; 3652 Int numRpsCurrTempList1 = rpcSlice->getNumRpsCurrTempList(); 3653 if ( numRpsCurrTempList1 > 1 ) 3654 { 3655 Int length = 1; 3656 numRpsCurrTempList1 --; 3657 while ( numRpsCurrTempList1 >>= 1) 3658 { 3659 length ++; 3660 } 3661 for (i = 0; i < rpcSlice->getNumRefIdx(REF_PIC_LIST_1); i ++) 3662 { 3663 READ_CODE( length, uiCode, "list_entry_l1" ); 3664 refPicListModification->setRefPicSetIdxL1(i, uiCode ); 3665 } 3666 } 3667 else 3668 { 3669 for (i = 0; i < rpcSlice->getNumRefIdx(REF_PIC_LIST_1); i ++) 3670 { 3671 refPicListModification->setRefPicSetIdxL1(i, 0 ); 3672 } 3673 } 3674 } 3675 } 3676 else 3677 { 3678 refPicListModification->setRefPicListModificationFlagL1(0); 3679 } 3680 if (rpcSlice->isInterB()) 3681 { 3682 READ_FLAG( uiCode, "mvd_l1_zero_flag" ); rpcSlice->setMvdL1ZeroFlag( (uiCode ? true : false) ); 3683 } 3684 3685 rpcSlice->setCabacInitFlag( false ); // default 3686 if(pps->getCabacInitPresentFlag() && !rpcSlice->isIntra()) 3687 { 3688 READ_FLAG(uiCode, "cabac_init_flag"); 3689 rpcSlice->setCabacInitFlag( uiCode ? true : false ); 3690 } 3691 3692 if ( rpcSlice->getEnableTMVPFlag() ) 3693 { 3694 #if SVC_EXTENSION && REF_IDX_MFM 3695 // set motion mapping flag 3696 rpcSlice->setMFMEnabledFlag( ( rpcSlice->getNumMotionPredRefLayers() > 0 && rpcSlice->getActiveNumILRRefIdx() && !rpcSlice->isIntra() ) ? true : false ); 3697 #endif 3698 if ( rpcSlice->getSliceType() == B_SLICE ) 3699 { 3700 READ_FLAG( uiCode, "collocated_from_l0_flag" ); 3701 rpcSlice->setColFromL0Flag(uiCode); 3702 } 3703 else 3704 { 3705 rpcSlice->setColFromL0Flag( 1 ); 3706 } 3707 3708 if ( rpcSlice->getSliceType() != I_SLICE && 3709 ((rpcSlice->getColFromL0Flag() == 1 && rpcSlice->getNumRefIdx(REF_PIC_LIST_0) > 1)|| 3710 (rpcSlice->getColFromL0Flag() == 0 && rpcSlice->getNumRefIdx(REF_PIC_LIST_1) > 1))) 3711 { 3712 READ_UVLC( uiCode, "collocated_ref_idx" ); 3713 rpcSlice->setColRefIdx(uiCode); 3714 } 3715 else 3716 { 3717 rpcSlice->setColRefIdx(0); 3718 } 3719 } 3720 if ( (pps->getUseWP() && rpcSlice->getSliceType()==P_SLICE) || (pps->getWPBiPred() && rpcSlice->getSliceType()==B_SLICE) ) 3721 { 3722 xParsePredWeightTable(rpcSlice); 3723 rpcSlice->initWpScaling(); 3724 } 3725 if (!rpcSlice->isIntra()) 3726 { 3727 READ_UVLC( uiCode, "five_minus_max_num_merge_cand"); 3728 rpcSlice->setMaxNumMergeCand(MRG_MAX_NUM_CANDS - uiCode); 3729 } 3730 3731 READ_SVLC( iCode, "slice_qp_delta" ); 3732 rpcSlice->setSliceQp (26 + pps->getPicInitQPMinus26() + iCode); 3733 3734 #if REPN_FORMAT_IN_VPS 3735 #if O0194_DIFFERENT_BITDEPTH_EL_BL 3736 g_bitDepthYLayer[rpcSlice->getLayerId()] = rpcSlice->getBitDepthY(); 3737 g_bitDepthCLayer[rpcSlice->getLayerId()] = rpcSlice->getBitDepthC(); 3738 #endif 3739 assert( rpcSlice->getSliceQp() >= -rpcSlice->getQpBDOffsetY() ); 3740 #else 3741 assert( rpcSlice->getSliceQp() >= -sps->getQpBDOffsetY() ); 3742 #endif 3743 assert( rpcSlice->getSliceQp() <= 51 ); 3744 3745 if (rpcSlice->getPPS()->getSliceChromaQpFlag()) 3746 { 3747 READ_SVLC( iCode, "slice_qp_delta_cb" ); 3748 rpcSlice->setSliceQpDeltaCb( iCode ); 3749 assert( rpcSlice->getSliceQpDeltaCb() >= -12 ); 3750 assert( rpcSlice->getSliceQpDeltaCb() <= 12 ); 3751 assert( (rpcSlice->getPPS()->getChromaCbQpOffset() + rpcSlice->getSliceQpDeltaCb()) >= -12 ); 3752 assert( (rpcSlice->getPPS()->getChromaCbQpOffset() + rpcSlice->getSliceQpDeltaCb()) <= 12 ); 3753 3754 READ_SVLC( iCode, "slice_qp_delta_cr" ); 3755 rpcSlice->setSliceQpDeltaCr( iCode ); 3756 assert( rpcSlice->getSliceQpDeltaCr() >= -12 ); 3757 assert( rpcSlice->getSliceQpDeltaCr() <= 12 ); 3758 assert( (rpcSlice->getPPS()->getChromaCrQpOffset() + rpcSlice->getSliceQpDeltaCr()) >= -12 ); 3759 assert( (rpcSlice->getPPS()->getChromaCrQpOffset() + rpcSlice->getSliceQpDeltaCr()) <= 12 ); 3760 } 3761 3762 if (rpcSlice->getPPS()->getDeblockingFilterControlPresentFlag()) 3763 { 3764 if(rpcSlice->getPPS()->getDeblockingFilterOverrideEnabledFlag()) 3765 { 3766 READ_FLAG ( uiCode, "deblocking_filter_override_flag" ); rpcSlice->setDeblockingFilterOverrideFlag(uiCode ? true : false); 3767 } 3768 else 3769 { 3770 rpcSlice->setDeblockingFilterOverrideFlag(0); 3771 } 3772 if(rpcSlice->getDeblockingFilterOverrideFlag()) 3773 { 3774 READ_FLAG ( uiCode, "slice_disable_deblocking_filter_flag" ); rpcSlice->setDeblockingFilterDisable(uiCode ? 1 : 0); 3775 if(!rpcSlice->getDeblockingFilterDisable()) 3776 { 3777 READ_SVLC( iCode, "slice_beta_offset_div2" ); rpcSlice->setDeblockingFilterBetaOffsetDiv2(iCode); 3778 assert(rpcSlice->getDeblockingFilterBetaOffsetDiv2() >= -6 && 3779 rpcSlice->getDeblockingFilterBetaOffsetDiv2() <= 6); 3780 READ_SVLC( iCode, "slice_tc_offset_div2" ); rpcSlice->setDeblockingFilterTcOffsetDiv2(iCode); 3781 assert(rpcSlice->getDeblockingFilterTcOffsetDiv2() >= -6 && 3782 rpcSlice->getDeblockingFilterTcOffsetDiv2() <= 6); 3783 } 3784 } 3785 else 3786 { 3787 rpcSlice->setDeblockingFilterDisable ( rpcSlice->getPPS()->getPicDisableDeblockingFilterFlag() ); 3788 rpcSlice->setDeblockingFilterBetaOffsetDiv2( rpcSlice->getPPS()->getDeblockingFilterBetaOffsetDiv2() ); 3789 rpcSlice->setDeblockingFilterTcOffsetDiv2 ( rpcSlice->getPPS()->getDeblockingFilterTcOffsetDiv2() ); 3790 } 3791 } 3792 else 3793 { 3794 rpcSlice->setDeblockingFilterDisable ( false ); 3795 rpcSlice->setDeblockingFilterBetaOffsetDiv2( 0 ); 3796 rpcSlice->setDeblockingFilterTcOffsetDiv2 ( 0 ); 3797 } 3798 3799 Bool isSAOEnabled = (!rpcSlice->getSPS()->getUseSAO())?(false):(rpcSlice->getSaoEnabledFlag()||rpcSlice->getSaoEnabledFlagChroma()); 3800 Bool isDBFEnabled = (!rpcSlice->getDeblockingFilterDisable()); 3801 3802 if(rpcSlice->getPPS()->getLoopFilterAcrossSlicesEnabledFlag() && ( isSAOEnabled || isDBFEnabled )) 3803 { 3804 READ_FLAG( uiCode, "slice_loop_filter_across_slices_enabled_flag"); 3805 } 3806 else 3807 { 3808 uiCode = rpcSlice->getPPS()->getLoopFilterAcrossSlicesEnabledFlag()?1:0; 3809 } 3810 rpcSlice->setLFCrossSliceBoundaryFlag( (uiCode==1)?true:false); 3811 3812 } 3813 3814 UInt *entryPointOffset = NULL; 3815 UInt numEntryPointOffsets, offsetLenMinus1; 3816 if( pps->getTilesEnabledFlag() || pps->getEntropyCodingSyncEnabledFlag() ) 3817 { 3818 READ_UVLC(numEntryPointOffsets, "num_entry_point_offsets"); rpcSlice->setNumEntryPointOffsets ( numEntryPointOffsets ); 3819 if (numEntryPointOffsets>0) 3820 { 3821 READ_UVLC(offsetLenMinus1, "offset_len_minus1"); 3822 } 3823 entryPointOffset = new UInt[numEntryPointOffsets]; 3824 for (UInt idx=0; idx<numEntryPointOffsets; idx++) 3825 { 3826 READ_CODE(offsetLenMinus1+1, uiCode, "entry_point_offset_minus1"); 3827 entryPointOffset[ idx ] = uiCode + 1; 3828 } 3829 } 3830 else 3831 { 3832 rpcSlice->setNumEntryPointOffsets ( 0 ); 3833 } 3834 3835 #if POC_RESET_IDC_SIGNALLING 3836 Int sliceHeaderExtensionLength = 0; 3837 if(pps->getSliceHeaderExtensionPresentFlag()) 3838 { 3839 READ_UVLC( uiCode, "slice_header_extension_length"); sliceHeaderExtensionLength = uiCode; 3840 } 3841 else 3842 { 3843 sliceHeaderExtensionLength = 0; 3844 #if INFERENCE_POC_MSB_VAL_PRESENT 3845 rpcSlice->setPocMsbValPresentFlag( false ); 3846 #endif 3847 } 3848 UInt startBits = m_pcBitstream->getNumBitsRead(); // Start counter of # SH Extn bits 3849 if( sliceHeaderExtensionLength > 0 ) 3850 { 3851 if( rpcSlice->getPPS()->getPocResetInfoPresentFlag() ) 3852 { 3853 READ_CODE( 2, uiCode, "poc_reset_idc"); rpcSlice->setPocResetIdc(uiCode); 3854 #if POC_RESET_RESTRICTIONS 3855 /* The value of poc_reset_idc shall not be equal to 1 or 2 for a RASL picture, a RADL picture, 3856 a sub-layer non-reference picture, or a picture that has TemporalId greater than 0, 3857 or a picture that has discardable_flag equal to 1. */ 3858 if( rpcSlice->getPocResetIdc() == 1 || rpcSlice->getPocResetIdc() == 2 ) 3859 { 3860 assert( !rpcSlice->isRASL() ); 3861 assert( !rpcSlice->isRADL() ); 3862 assert( !rpcSlice->isSLNR() ); 3863 assert( rpcSlice->getTLayer() == 0 ); 3864 assert( rpcSlice->getDiscardableFlag() == 0 ); 3865 } 3866 3867 // The value of poc_reset_idc of a CRA or BLA picture shall be less than 3. 3868 if( rpcSlice->getPocResetIdc() == 3) 3869 { 3870 assert( ! ( rpcSlice->isCRA() || rpcSlice->isBLA() ) ); 3871 } 3872 #endif 3873 } 3874 else 3875 { 3876 rpcSlice->setPocResetIdc( 0 ); 3877 } 3878 #if Q0142_POC_LSB_NOT_PRESENT 3879 if ( rpcSlice->getVPS()->getPocLsbNotPresentFlag(rpcSlice->getLayerId()) && iPOClsb > 0 ) 3880 { 3881 assert( rpcSlice->getPocResetIdc() != 2 ); 3882 } 3883 #endif 3884 if( rpcSlice->getPocResetIdc() > 0 ) 3885 { 3886 READ_CODE(6, uiCode, "poc_reset_period_id"); rpcSlice->setPocResetPeriodId(uiCode); 3887 } 3888 else 3889 { 3890 3891 rpcSlice->setPocResetPeriodId( 0 ); 3892 } 3893 3894 if (rpcSlice->getPocResetIdc() == 3) 3895 { 3896 READ_FLAG( uiCode, "full_poc_reset_flag"); rpcSlice->setFullPocResetFlag((uiCode == 1) ? true : false); 3897 READ_CODE(rpcSlice->getSPS()->getBitsForPOC(), uiCode,"poc_lsb_val"); rpcSlice->setPocLsbVal(uiCode); 3898 #if Q0142_POC_LSB_NOT_PRESENT 3899 if ( rpcSlice->getVPS()->getPocLsbNotPresentFlag(rpcSlice->getLayerId()) && rpcSlice->getFullPocResetFlag() ) 3900 { 3901 assert( rpcSlice->getPocLsbVal() == 0 ); 3902 } 3903 #endif 3904 } 3905 3906 // Derive the value of PocMsbValRequiredFlag 3907 #if P0297_VPS_POC_LSB_ALIGNED_FLAG 3908 rpcSlice->setPocMsbValRequiredFlag( (rpcSlice->getCraPicFlag() || rpcSlice->getBlaPicFlag()) 3909 && (!rpcSlice->getVPS()->getVpsPocLsbAlignedFlag() || 3910 (rpcSlice->getVPS()->getVpsPocLsbAlignedFlag() && rpcSlice->getVPS()->getNumDirectRefLayers(rpcSlice->getLayerId()) == 0)) 3911 ); 3912 #else 3913 rpcSlice->setPocMsbValRequiredFlag( rpcSlice->getCraPicFlag() || rpcSlice->getBlaPicFlag() ); 3914 #endif 3915 3916 #if P0297_VPS_POC_LSB_ALIGNED_FLAG 3917 if (!rpcSlice->getPocMsbValRequiredFlag() && rpcSlice->getVPS()->getVpsPocLsbAlignedFlag()) 3918 #else 3919 if (!rpcSlice->getPocMsbValRequiredFlag() /* vps_poc_lsb_aligned_flag */) 3920 #endif 3921 { 3922 #if P0297_VPS_POC_LSB_ALIGNED_FLAG 3923 READ_FLAG(uiCode, "poc_msb_cycle_val_present_flag"); rpcSlice->setPocMsbValPresentFlag(uiCode ? true : false); 3924 #else 3925 READ_FLAG(uiCode, "poc_msb_val_present_flag"); rpcSlice->setPocMsbValPresentFlag(uiCode ? true : false); 3926 #endif 3927 } 3928 else 3929 { 3930 #if POC_MSB_VAL_PRESENT_FLAG_SEM 3931 if( sliceHeaderExtensionLength == 0 ) 3932 { 3933 rpcSlice->setPocMsbValPresentFlag( false ); 3934 } 3935 else if( rpcSlice->getPocMsbValRequiredFlag() ) 3936 #else 3937 if( rpcSlice->getPocMsbValRequiredFlag() ) 3938 #endif 3939 { 3940 rpcSlice->setPocMsbValPresentFlag( true ); 3941 } 3942 else 3943 { 3944 rpcSlice->setPocMsbValPresentFlag( false ); 3945 } 3946 } 3947 3948 #if !POC_RESET_IDC_DECODER 3949 Int maxPocLsb = 1 << rpcSlice->getSPS()->getBitsForPOC(); 3950 #endif 3951 if( rpcSlice->getPocMsbValPresentFlag() ) 3952 { 3953 #if P0297_VPS_POC_LSB_ALIGNED_FLAG 3954 READ_UVLC( uiCode, "poc_msb_cycle_val"); rpcSlice->setPocMsbVal( uiCode ); 3955 #else 3956 READ_UVLC( uiCode, "poc_msb_val"); rpcSlice->setPocMsbVal( uiCode ); 3957 #endif 3958 3959 #if !POC_RESET_IDC_DECODER 3960 // Update POC of the slice based on this MSB val 3961 Int pocLsb = rpcSlice->getPOC() % maxPocLsb; 3962 rpcSlice->setPOC((rpcSlice->getPocMsbVal() * maxPocLsb) + pocLsb); 3963 } 3964 else 3965 { 3966 rpcSlice->setPocMsbVal( rpcSlice->getPOC() / maxPocLsb ); 3967 #endif 3968 } 3969 3970 // Read remaining bits in the slice header extension. 3971 UInt endBits = m_pcBitstream->getNumBitsRead(); 3972 Int counter = (endBits - startBits) % 8; 3973 if( counter ) 3974 { 3975 counter = 8 - counter; 3976 } 3977 3978 while( counter ) 3979 { 3980 #if Q0146_SSH_EXT_DATA_BIT 3981 READ_FLAG( uiCode, "slice_segment_header_extension_data_bit" ); 3982 #else 3983 READ_FLAG( uiCode, "slice_segment_header_extension_reserved_bit" ); assert( uiCode == 1 ); 3984 #endif 3985 counter--; 3986 } 3987 } 3988 #else 3989 if(pps->getSliceHeaderExtensionPresentFlag()) 3990 { 3991 READ_UVLC(uiCode,"slice_header_extension_length"); 3992 for(Int i=0; i<uiCode; i++) 3993 { 3994 UInt ignore; 3995 READ_CODE(8,ignore,"slice_header_extension_data_byte"); 3996 } 3997 } 3998 #endif 3999 m_pcBitstream->readByteAlignment(); 4000 4001 if( pps->getTilesEnabledFlag() || pps->getEntropyCodingSyncEnabledFlag() ) 4002 { 4003 Int endOfSliceHeaderLocation = m_pcBitstream->getByteLocation(); 4004 4005 // Adjust endOfSliceHeaderLocation to account for emulation prevention bytes in the slice segment header 4006 for ( UInt curByteIdx = 0; curByteIdx<m_pcBitstream->numEmulationPreventionBytesRead(); curByteIdx++ ) 4007 { 4008 if ( m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) < endOfSliceHeaderLocation ) 4009 { 4010 endOfSliceHeaderLocation++; 4011 } 4012 } 4013 4014 Int curEntryPointOffset = 0; 4015 Int prevEntryPointOffset = 0; 4016 for (UInt idx=0; idx<numEntryPointOffsets; idx++) 4017 { 4018 curEntryPointOffset += entryPointOffset[ idx ]; 4019 4020 Int emulationPreventionByteCount = 0; 4021 for ( UInt curByteIdx = 0; curByteIdx<m_pcBitstream->numEmulationPreventionBytesRead(); curByteIdx++ ) 4022 { 4023 if ( m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) >= ( prevEntryPointOffset + endOfSliceHeaderLocation ) && 4024 m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) < ( curEntryPointOffset + endOfSliceHeaderLocation ) ) 4025 { 4026 emulationPreventionByteCount++; 4027 } 4028 } 4029 4030 entryPointOffset[ idx ] -= emulationPreventionByteCount; 4031 prevEntryPointOffset = curEntryPointOffset; 4032 } 4033 4034 if ( pps->getTilesEnabledFlag() ) 4035 { 4036 rpcSlice->setTileLocationCount( numEntryPointOffsets ); 4037 4038 UInt prevPos = 0; 4039 for (Int idx=0; idx<rpcSlice->getTileLocationCount(); idx++) 4040 { 4041 rpcSlice->setTileLocation( idx, prevPos + entryPointOffset [ idx ] ); 4042 prevPos += entryPointOffset[ idx ]; 4043 } 4044 } 4045 else if ( pps->getEntropyCodingSyncEnabledFlag() ) 4046 { 4047 Int numSubstreams = rpcSlice->getNumEntryPointOffsets()+1; 4048 rpcSlice->allocSubstreamSizes(numSubstreams); 4049 UInt *pSubstreamSizes = rpcSlice->getSubstreamSizes(); 4050 for (Int idx=0; idx<numSubstreams-1; idx++) 4051 { 4052 if ( idx < numEntryPointOffsets ) 4053 { 4054 pSubstreamSizes[ idx ] = ( entryPointOffset[ idx ] << 3 ) ; 4055 } 4056 else 4057 { 4058 pSubstreamSizes[ idx ] = 0; 4059 } 4060 } 4061 } 4062 4063 if (entryPointOffset) 4064 { 4065 delete [] entryPointOffset; 4066 } 4067 } 4068 4069 return; 4070 } 4071 4072 Void TDecCavlc::parsePTL( TComPTL *rpcPTL, Bool profilePresentFlag, Int maxNumSubLayersMinus1 ) 4073 { 4074 UInt uiCode; 4075 if(profilePresentFlag) 4076 { 4077 parseProfileTier(rpcPTL->getGeneralPTL()); 4078 } 4079 READ_CODE( 8, uiCode, "general_level_idc" ); rpcPTL->getGeneralPTL()->setLevelIdc(uiCode); 4080 4081 for (Int i = 0; i < maxNumSubLayersMinus1; i++) 4082 { 4083 if(profilePresentFlag) 4084 { 4085 READ_FLAG( uiCode, "sub_layer_profile_present_flag[i]" ); rpcPTL->setSubLayerProfilePresentFlag(i, uiCode); 4086 } 4087 READ_FLAG( uiCode, "sub_layer_level_present_flag[i]" ); rpcPTL->setSubLayerLevelPresentFlag (i, uiCode); 4088 } 4089 4090 if (maxNumSubLayersMinus1 > 0) 4091 { 4092 for (Int i = maxNumSubLayersMinus1; i < 8; i++) 4093 { 4094 READ_CODE(2, uiCode, "reserved_zero_2bits"); 4095 assert(uiCode == 0); 4096 } 4097 } 4098 4099 for(Int i = 0; i < maxNumSubLayersMinus1; i++) 4100 { 4101 if( profilePresentFlag && rpcPTL->getSubLayerProfilePresentFlag(i) ) 4102 { 4103 parseProfileTier(rpcPTL->getSubLayerPTL(i)); 4104 } 4105 if(rpcPTL->getSubLayerLevelPresentFlag(i)) 4106 { 4107 READ_CODE( 8, uiCode, "sub_layer_level_idc[i]" ); rpcPTL->getSubLayerPTL(i)->setLevelIdc(uiCode); 4108 } 4109 } 4110 } 4111 4112 Void TDecCavlc::parseProfileTier(ProfileTierLevel *ptl) 4113 { 4114 UInt uiCode; 4115 READ_CODE(2 , uiCode, "XXX_profile_space[]"); ptl->setProfileSpace(uiCode); 4116 READ_FLAG( uiCode, "XXX_tier_flag[]" ); ptl->setTierFlag (uiCode ? 1 : 0); 4117 READ_CODE(5 , uiCode, "XXX_profile_idc[]" ); ptl->setProfileIdc (uiCode); 4118 for(Int j = 0; j < 32; j++) 4119 { 4120 READ_FLAG( uiCode, "XXX_profile_compatibility_flag[][j]"); ptl->setProfileCompatibilityFlag(j, uiCode ? 1 : 0); 4121 } 4122 READ_FLAG(uiCode, "general_progressive_source_flag"); 4123 ptl->setProgressiveSourceFlag(uiCode ? true : false); 4124 4125 READ_FLAG(uiCode, "general_interlaced_source_flag"); 4126 ptl->setInterlacedSourceFlag(uiCode ? true : false); 4127 4128 READ_FLAG(uiCode, "general_non_packed_constraint_flag"); 4129 ptl->setNonPackedConstraintFlag(uiCode ? true : false); 4130 4131 READ_FLAG(uiCode, "general_frame_only_constraint_flag"); 4132 ptl->setFrameOnlyConstraintFlag(uiCode ? true : false); 4133 4134 READ_CODE(16, uiCode, "XXX_reserved_zero_44bits[0..15]"); 4135 READ_CODE(16, uiCode, "XXX_reserved_zero_44bits[16..31]"); 4136 READ_CODE(12, uiCode, "XXX_reserved_zero_44bits[32..43]"); 4137 } 4138 4139 Void TDecCavlc::parseTerminatingBit( UInt& ruiBit ) 4140 { 4141 ruiBit = false; 4142 Int iBitsLeft = m_pcBitstream->getNumBitsLeft(); 4143 if(iBitsLeft <= 8) 4144 { 4145 UInt uiPeekValue = m_pcBitstream->peekBits(iBitsLeft); 4146 if (uiPeekValue == (1<<(iBitsLeft-1))) 4147 { 4148 ruiBit = true; 4149 } 4150 } 4151 } 4152 4153 Void TDecCavlc::parseSkipFlag( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) 4154 { 4155 assert(0); 4156 } 4157 4158 Void TDecCavlc::parseCUTransquantBypassFlag( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) 4159 { 4160 assert(0); 4161 } 4162 4163 Void TDecCavlc::parseMVPIdx( Int& /*riMVPIdx*/ ) 4164 { 4165 assert(0); 4166 } 4167 4168 Void TDecCavlc::parseSplitFlag ( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) 4169 { 4170 assert(0); 4171 } 4172 4173 Void TDecCavlc::parsePartSize( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) 4174 { 4175 assert(0); 4176 } 4177 4178 Void TDecCavlc::parsePredMode( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) 4179 { 4180 assert(0); 4181 } 4182 4183 /** Parse I_PCM information. 4184 * \param pcCU pointer to CU 4185 * \param uiAbsPartIdx CU index 4186 * \param uiDepth CU depth 4187 * \returns Void 4188 * 4189 * If I_PCM flag indicates that the CU is I_PCM, parse its PCM alignment bits and codes. 4190 */ 4191 Void TDecCavlc::parseIPCMInfo( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) 4192 { 4193 assert(0); 4194 } 4195 4196 Void TDecCavlc::parseIntraDirLumaAng ( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) 4197 { 4198 assert(0); 4199 } 4200 4201 Void TDecCavlc::parseIntraDirChroma( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) 4202 { 4203 assert(0); 4204 } 4205 4206 Void TDecCavlc::parseInterDir( TComDataCU* /*pcCU*/, UInt& /*ruiInterDir*/, UInt /*uiAbsPartIdx*/ ) 4207 { 4208 assert(0); 4209 } 4210 4211 Void TDecCavlc::parseRefFrmIdx( TComDataCU* /*pcCU*/, Int& /*riRefFrmIdx*/, RefPicList /*eRefList*/ ) 4212 { 4213 assert(0); 4214 } 4215 4216 Void TDecCavlc::parseMvd( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiPartIdx*/, UInt /*uiDepth*/, RefPicList /*eRefList*/ ) 4217 { 4218 assert(0); 4219 } 4220 4221 Void TDecCavlc::parseDeltaQP( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) 4222 { 4223 Int qp; 4224 Int iDQp; 4225 4226 xReadSvlc( iDQp ); 4227 4228 #if REPN_FORMAT_IN_VPS 4229 Int qpBdOffsetY = pcCU->getSlice()->getQpBDOffsetY(); 4230 #else 4231 Int qpBdOffsetY = pcCU->getSlice()->getSPS()->getQpBDOffsetY(); 4232 #endif 4233 qp = (((Int) pcCU->getRefQP( uiAbsPartIdx ) + iDQp + 52 + 2*qpBdOffsetY )%(52+ qpBdOffsetY)) - qpBdOffsetY; 4234 4235 UInt uiAbsQpCUPartIdx = (uiAbsPartIdx>>((g_uiMaxCUDepth - pcCU->getSlice()->getPPS()->getMaxCuDQPDepth())<<1))<<((g_uiMaxCUDepth - pcCU->getSlice()->getPPS()->getMaxCuDQPDepth())<<1) ; 4236 UInt uiQpCUDepth = min(uiDepth,pcCU->getSlice()->getPPS()->getMaxCuDQPDepth()) ; 4237 4238 pcCU->setQPSubParts( qp, uiAbsQpCUPartIdx, uiQpCUDepth ); 4239 } 4240 4241 Void TDecCavlc::parseCoeffNxN( TComDataCU* /*pcCU*/, TCoeff* /*pcCoef*/, UInt /*uiAbsPartIdx*/, UInt /*uiWidth*/, UInt /*uiHeight*/, UInt /*uiDepth*/, TextType /*eTType*/ ) 4242 { 4243 assert(0); 4244 } 4245 4246 Void TDecCavlc::parseTransformSubdivFlag( UInt& /*ruiSubdivFlag*/, UInt /*uiLog2TransformBlockSize*/ ) 4247 { 4248 assert(0); 4249 } 4250 4251 Void TDecCavlc::parseQtCbf( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, TextType /*eType*/, UInt /*uiTrDepth*/, UInt /*uiDepth*/ ) 4252 { 4253 assert(0); 4254 } 4255 4256 Void TDecCavlc::parseQtRootCbf( UInt /*uiAbsPartIdx*/, UInt& /*uiQtRootCbf*/ ) 4257 { 4258 assert(0); 4259 } 4260 4261 Void TDecCavlc::parseTransformSkipFlags (TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*width*/, UInt /*height*/, UInt /*uiDepth*/, TextType /*eTType*/) 4262 { 4263 assert(0); 4264 } 4265 4266 Void TDecCavlc::parseMergeFlag ( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/, UInt /*uiPUIdx*/ ) 4267 { 4268 assert(0); 4269 } 4270 4271 Void TDecCavlc::parseMergeIndex ( TComDataCU* /*pcCU*/, UInt& /*ruiMergeIndex*/ ) 4272 { 4273 assert(0); 4274 } 4275 4276 // ==================================================================================================================== 4277 // Protected member functions 4278 // ==================================================================================================================== 4279 4280 /** parse explicit wp tables 4281 * \param TComSlice* pcSlice 4282 * \returns Void 4283 */ 4284 Void TDecCavlc::xParsePredWeightTable( TComSlice* pcSlice ) 4285 { 4286 wpScalingParam *wp; 4287 Bool bChroma = true; // color always present in HEVC ? 4288 SliceType eSliceType = pcSlice->getSliceType(); 4289 Int iNbRef = (eSliceType == B_SLICE ) ? (2) : (1); 4290 #if SVC_EXTENSION 4291 UInt uiLog2WeightDenomLuma = 0, uiLog2WeightDenomChroma = 0; 4292 #else 4293 UInt uiLog2WeightDenomLuma, uiLog2WeightDenomChroma; 4294 #endif 4295 UInt uiTotalSignalledWeightFlags = 0; 4296 4297 Int iDeltaDenom; 4298 #if AUXILIARY_PICTURES 4299 if (pcSlice->getChromaFormatIdc() == CHROMA_400) 4300 { 4301 bChroma = false; 4302 } 4303 #endif 4304 // decode delta_luma_log2_weight_denom : 4305 READ_UVLC( uiLog2WeightDenomLuma, "luma_log2_weight_denom" ); // ue(v): luma_log2_weight_denom 4306 assert( uiLog2WeightDenomLuma <= 7 ); 4307 if( bChroma ) 4308 { 4309 READ_SVLC( iDeltaDenom, "delta_chroma_log2_weight_denom" ); // se(v): delta_chroma_log2_weight_denom 4310 assert((iDeltaDenom + (Int)uiLog2WeightDenomLuma)>=0); 4311 assert((iDeltaDenom + (Int)uiLog2WeightDenomLuma)<=7); 4312 uiLog2WeightDenomChroma = (UInt)(iDeltaDenom + uiLog2WeightDenomLuma); 4313 } 4314 4315 for ( Int iNumRef=0 ; iNumRef<iNbRef ; iNumRef++ ) 4316 { 4317 RefPicList eRefPicList = ( iNumRef ? REF_PIC_LIST_1 : REF_PIC_LIST_0 ); 4318 for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ ) 4319 { 4320 pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); 4321 4322 wp[0].uiLog2WeightDenom = uiLog2WeightDenomLuma; 4323 #if AUXILIARY_PICTURES 4324 if (!bChroma) 4325 { 4326 wp[1].uiLog2WeightDenom = 0; 4327 wp[2].uiLog2WeightDenom = 0; 4328 } 4329 else 4330 { 4331 #endif 4332 wp[1].uiLog2WeightDenom = uiLog2WeightDenomChroma; 4333 wp[2].uiLog2WeightDenom = uiLog2WeightDenomChroma; 4334 #if AUXILIARY_PICTURES 4335 } 4336 #endif 4337 4338 UInt uiCode; 4339 READ_FLAG( uiCode, "luma_weight_lX_flag" ); // u(1): luma_weight_l0_flag 4340 wp[0].bPresentFlag = ( uiCode == 1 ); 4341 uiTotalSignalledWeightFlags += wp[0].bPresentFlag; 4342 } 4343 if ( bChroma ) 4344 { 4345 UInt uiCode; 4346 for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ ) 4347 { 4348 pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); 4349 READ_FLAG( uiCode, "chroma_weight_lX_flag" ); // u(1): chroma_weight_l0_flag 4350 wp[1].bPresentFlag = ( uiCode == 1 ); 4351 wp[2].bPresentFlag = ( uiCode == 1 ); 4352 uiTotalSignalledWeightFlags += 2*wp[1].bPresentFlag; 4353 } 4354 } 4355 for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ ) 4356 { 4357 pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); 4358 if ( wp[0].bPresentFlag ) 4359 { 4360 Int iDeltaWeight; 4361 READ_SVLC( iDeltaWeight, "delta_luma_weight_lX" ); // se(v): delta_luma_weight_l0[i] 4362 assert( iDeltaWeight >= -128 ); 4363 assert( iDeltaWeight <= 127 ); 4364 wp[0].iWeight = (iDeltaWeight + (1<<wp[0].uiLog2WeightDenom)); 4365 READ_SVLC( wp[0].iOffset, "luma_offset_lX" ); // se(v): luma_offset_l0[i] 4366 assert( wp[0].iOffset >= -128 ); 4367 assert( wp[0].iOffset <= 127 ); 4368 } 4369 else 4370 { 4371 wp[0].iWeight = (1 << wp[0].uiLog2WeightDenom); 4372 wp[0].iOffset = 0; 4373 } 4374 if ( bChroma ) 4375 { 4376 if ( wp[1].bPresentFlag ) 4377 { 4378 for ( Int j=1 ; j<3 ; j++ ) 4379 { 4380 Int iDeltaWeight; 4381 READ_SVLC( iDeltaWeight, "delta_chroma_weight_lX" ); // se(v): chroma_weight_l0[i][j] 4382 assert( iDeltaWeight >= -128 ); 4383 assert( iDeltaWeight <= 127 ); 4384 wp[j].iWeight = (iDeltaWeight + (1<<wp[1].uiLog2WeightDenom)); 4385 4386 Int iDeltaChroma; 4387 READ_SVLC( iDeltaChroma, "delta_chroma_offset_lX" ); // se(v): delta_chroma_offset_l0[i][j] 4388 assert( iDeltaChroma >= -512 ); 4389 assert( iDeltaChroma <= 511 ); 4390 Int pred = ( 128 - ( ( 128*wp[j].iWeight)>>(wp[j].uiLog2WeightDenom) ) ); 4391 wp[j].iOffset = Clip3(-128, 127, (iDeltaChroma + pred) ); 4392 } 4393 } 4394 else 4395 { 4396 for ( Int j=1 ; j<3 ; j++ ) 4397 { 4398 wp[j].iWeight = (1 << wp[j].uiLog2WeightDenom); 4399 wp[j].iOffset = 0; 4400 } 4401 } 4402 } 4403 } 4404 4405 for ( Int iRefIdx=pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx<MAX_NUM_REF ; iRefIdx++ ) 4406 { 4407 pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); 4408 4409 wp[0].bPresentFlag = false; 4410 wp[1].bPresentFlag = false; 4411 wp[2].bPresentFlag = false; 4412 } 4413 } 4414 assert(uiTotalSignalledWeightFlags<=24); 4415 } 4416 4417 /** decode quantization matrix 4418 * \param scalingList quantization matrix information 4419 */ 4420 Void TDecCavlc::parseScalingList(TComScalingList* scalingList) 4421 { 4422 UInt code, sizeId, listId; 4423 Bool scalingListPredModeFlag; 4424 //for each size 4425 for(sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) 4426 { 4427 for(listId = 0; listId < g_scalingListNum[sizeId]; listId++) 4428 { 4429 READ_FLAG( code, "scaling_list_pred_mode_flag"); 4430 scalingListPredModeFlag = (code) ? true : false; 4431 if(!scalingListPredModeFlag) //Copy Mode 4432 { 4433 READ_UVLC( code, "scaling_list_pred_matrix_id_delta"); 4434 scalingList->setRefMatrixId (sizeId,listId,(UInt)((Int)(listId)-(code))); 4435 if( sizeId > SCALING_LIST_8x8 ) 4436 { 4437 scalingList->setScalingListDC(sizeId,listId,((listId == scalingList->getRefMatrixId (sizeId,listId))? 16 :scalingList->getScalingListDC(sizeId, scalingList->getRefMatrixId (sizeId,listId)))); 4438 } 4439 scalingList->processRefMatrix( sizeId, listId, scalingList->getRefMatrixId (sizeId,listId)); 4440 4441 } 4442 else //DPCM Mode 4443 { 4444 xDecodeScalingList(scalingList, sizeId, listId); 4445 } 4446 } 4447 } 4448 4449 return; 4450 } 4451 /** decode DPCM 4452 * \param scalingList quantization matrix information 4453 * \param sizeId size index 4454 * \param listId list index 4455 */ 4456 Void TDecCavlc::xDecodeScalingList(TComScalingList *scalingList, UInt sizeId, UInt listId) 4457 { 4458 Int i,coefNum = min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId]); 4459 Int data; 4460 Int scalingListDcCoefMinus8 = 0; 4461 Int nextCoef = SCALING_LIST_START_VALUE; 4462 UInt* scan = (sizeId == 0) ? g_auiSigLastScan [ SCAN_DIAG ] [ 1 ] : g_sigLastScanCG32x32; 4463 Int *dst = scalingList->getScalingListAddress(sizeId, listId); 4464 4465 if( sizeId > SCALING_LIST_8x8 ) 4466 { 4467 READ_SVLC( scalingListDcCoefMinus8, "scaling_list_dc_coef_minus8"); 4468 scalingList->setScalingListDC(sizeId,listId,scalingListDcCoefMinus8 + 8); 4469 nextCoef = scalingList->getScalingListDC(sizeId,listId); 4470 } 4471 4472 for(i = 0; i < coefNum; i++) 4473 { 4474 READ_SVLC( data, "scaling_list_delta_coef"); 4475 nextCoef = (nextCoef + data + 256 ) % 256; 4476 dst[scan[i]] = nextCoef; 4477 } 4478 } 4479 4480 Bool TDecCavlc::xMoreRbspData() 4481 { 4482 Int bitsLeft = m_pcBitstream->getNumBitsLeft(); 4483 4484 // if there are more than 8 bits, it cannot be rbsp_trailing_bits 4485 if (bitsLeft > 8) 4486 { 4487 return true; 4488 } 4489 4490 UChar lastByte = m_pcBitstream->peekBits(bitsLeft); 4491 Int cnt = bitsLeft; 4492 4493 // remove trailing bits equal to zero 4494 while ((cnt>0) && ((lastByte & 1) == 0)) 4495 { 4496 lastByte >>= 1; 4497 cnt--; 4498 } 4499 // remove bit equal to one 4500 cnt--; 4501 4502 // we should not have a negative number of bits 4503 assert (cnt>=0); 4504 4505 // we have more data, if cnt is not zero 4506 return (cnt>0); 4507 } 4324 READ_FLAG( uiCode, "vert_phase_position_enable_flag" ); scaledWindow.setVertPhasePositionEnableFlag(uiCode); pcSPS->setVertPhasePositionEnableFlag( pcSPS->getScaledRefLayerId(i), uiCode); 4325 #endif 4326 } 4327 } 4328 #endif 4329 } 4330 #endif 4508 4331 4509 4332 #if Q0048_CGS_3D_ASYMLUT
Note: See TracChangeset for help on using the changeset viewer.