Changeset 125 in SHVCSoftware for trunk/source/Lib/TLibEncoder/TEncCavlc.cpp
- Timestamp:
- 16 Apr 2013, 06:39:31 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/source/Lib/TLibEncoder/TEncCavlc.cpp
r33 r125 4 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-201 2, ITU/ISO/IEC6 * Copyright (c) 2010-2013, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 55 55 } 56 56 57 #if !REMOVE_APS58 Void xTraceAPSHeader (TComAPS *pAPS)59 {60 fprintf( g_hTrace, "=========== Adaptation Parameter Set ===========\n");61 }62 #endif63 64 57 Void xTraceSliceHeader (TComSlice *pSlice) 65 58 { … … 79 72 m_pcBitIf = NULL; 80 73 m_uiCoeffCost = 0; 81 #if !REMOVE_FGS82 m_iSliceGranularity = 0;83 #endif84 74 } 85 75 … … 98 88 99 89 100 #if !REMOVE_APS101 Void TEncCavlc::codeAPSInitInfo(TComAPS* pcAPS)102 {103 104 #if ENC_DEC_TRACE105 xTraceAPSHeader(pcAPS);106 #endif107 //APS ID108 WRITE_UVLC( pcAPS->getAPSID(), "aps_id" );109 }110 #endif111 112 90 Void TEncCavlc::codeDFFlag(UInt uiCode, const Char *pSymbolName) 113 91 { … … 119 97 } 120 98 121 #if J0234_INTER_RPS_SIMPL 122 Void TEncCavlc::codeShortTermRefPicSet( TComSPS* pcSPS, TComReferencePictureSet* rps, Bool calledFromSliceHeader) 123 #else 124 Void TEncCavlc::codeShortTermRefPicSet( TComSPS* pcSPS, TComReferencePictureSet* rps ) 125 #endif 99 Void TEncCavlc::codeShortTermRefPicSet( TComSPS* pcSPS, TComReferencePictureSet* rps, Bool calledFromSliceHeader, Int idx) 126 100 { 127 101 #if PRINT_RPS_INFO 128 int lastBits = getNumberOfWrittenBits(); 129 #endif 102 Int lastBits = getNumberOfWrittenBits(); 103 #endif 104 if (idx > 0) 105 { 130 106 WRITE_FLAG( rps->getInterRPSPrediction(), "inter_ref_pic_set_prediction_flag" ); // inter_RPS_prediction_flag 131 if (rps->getInterRPSPrediction()) 107 } 108 if (rps->getInterRPSPrediction()) 132 109 { 133 110 Int deltaRPS = rps->getDeltaRPS(); 134 #if J0234_INTER_RPS_SIMPL135 111 if(calledFromSliceHeader) 136 112 { 137 113 WRITE_UVLC( rps->getDeltaRIdxMinus1(), "delta_idx_minus1" ); // delta index of the Reference Picture Set used for prediction minus 1 138 114 } 139 #else140 WRITE_UVLC( rps->getDeltaRIdxMinus1(), "delta_idx_minus1" ); // delta index of the Reference Picture Set used for prediction minus 1141 #endif142 115 143 116 WRITE_CODE( (deltaRPS >=0 ? 0: 1), 1, "delta_rps_sign" ); //delta_rps_sign … … 187 160 #endif 188 161 189 WRITE_UVLC( pcPPS->getPPSId(), "pic_parameter_set_id" ); 190 WRITE_UVLC( pcPPS->getSPSId(), "seq_parameter_set_id" ); 191 162 WRITE_UVLC( pcPPS->getPPSId(), "pps_pic_parameter_set_id" ); 163 WRITE_UVLC( pcPPS->getSPSId(), "pps_seq_parameter_set_id" ); 164 WRITE_FLAG( pcPPS->getDependentSliceSegmentsEnabledFlag() ? 1 : 0, "dependent_slice_segments_enabled_flag" ); 165 #if L0255_MOVE_PPS_FLAGS 166 WRITE_FLAG( pcPPS->getOutputFlagPresentFlag() ? 1 : 0, "output_flag_present_flag" ); 167 WRITE_CODE( pcPPS->getNumExtraSliceHeaderBits(), 3, "num_extra_slice_header_bits"); 168 #endif 192 169 WRITE_FLAG( pcPPS->getSignHideFlag(), "sign_data_hiding_flag" ); 193 170 WRITE_FLAG( pcPPS->getCabacInitPresentFlag() ? 1 : 0, "cabac_init_present_flag" ); … … 195 172 WRITE_UVLC( pcPPS->getNumRefIdxL1DefaultActive()-1, "num_ref_idx_l1_default_active_minus1"); 196 173 197 WRITE_SVLC( pcPPS->getPicInitQPMinus26(), " pic_init_qp_minus26");174 WRITE_SVLC( pcPPS->getPicInitQPMinus26(), "init_qp_minus26"); 198 175 WRITE_FLAG( pcPPS->getConstrainedIntraPred() ? 1 : 0, "constrained_intra_pred_flag" ); 199 #if PPS_TS_FLAG200 176 WRITE_FLAG( pcPPS->getUseTransformSkip() ? 1 : 0, "transform_skip_enabled_flag" ); 201 #endif202 #if !REMOVE_FGS203 WRITE_CODE( pcPPS->getSliceGranularity(), 2, "slice_granularity");204 #endif205 #if CU_DQP_ENABLE_FLAG206 177 WRITE_FLAG( pcPPS->getUseDQP() ? 1 : 0, "cu_qp_delta_enabled_flag" ); 207 178 if ( pcPPS->getUseDQP() ) 208 179 { 209 #if REMOVE_FGS210 180 WRITE_UVLC( pcPPS->getMaxCuDQPDepth(), "diff_cu_qp_delta_depth" ); 211 #else 212 WRITE_UVLC( pcPPS->getMaxCuDQPDepth() - pcPPS->getSliceGranularity(), "diff_cu_qp_delta_depth" ); 213 #endif 214 } 215 #else 216 #if REMOVE_FGS 217 WRITE_UVLC( pcPPS->getMaxCuDQPDepth() + pcPPS->getUseDQP(), "diff_cu_qp_delta_depth" ); 218 #else 219 WRITE_UVLC( pcPPS->getMaxCuDQPDepth() - pcPPS->getSliceGranularity() + pcPPS->getUseDQP(), "diff_cu_qp_delta_depth" ); 220 #endif 221 #endif 222 WRITE_SVLC( pcPPS->getChromaCbQpOffset(), "cb_qp_offset" ); 223 WRITE_SVLC( pcPPS->getChromaCrQpOffset(), "cr_qp_offset" ); 224 #if CHROMA_QP_EXTENSION 225 WRITE_FLAG( pcPPS->getSliceChromaQpFlag() ? 1 : 0, "slicelevel_chroma_qp_flag" ); 226 #endif 181 } 182 WRITE_SVLC( pcPPS->getChromaCbQpOffset(), "pps_cb_qp_offset" ); 183 WRITE_SVLC( pcPPS->getChromaCrQpOffset(), "pps_cr_qp_offset" ); 184 WRITE_FLAG( pcPPS->getSliceChromaQpFlag() ? 1 : 0, "pps_slice_chroma_qp_offsets_present_flag" ); 227 185 228 186 WRITE_FLAG( pcPPS->getUseWP() ? 1 : 0, "weighted_pred_flag" ); // Use of Weighting Prediction (P_SLICE) 229 187 WRITE_FLAG( pcPPS->getWPBiPred() ? 1 : 0, "weighted_bipred_flag" ); // Use of Weighting Bi-Prediction (B_SLICE) 188 #if !L0255_MOVE_PPS_FLAGS 230 189 WRITE_FLAG( pcPPS->getOutputFlagPresentFlag() ? 1 : 0, "output_flag_present_flag" ); 231 #if !TILES_WPP_ENTROPYSLICES_FLAGS232 #if DEPENDENT_SLICES233 WRITE_FLAG( pcPPS->getDependentSliceEnabledFlag() ? 1 : 0, "dependent_slices_enabled_flag" );234 #endif235 190 #endif 236 191 WRITE_FLAG( pcPPS->getTransquantBypassEnableFlag() ? 1 : 0, "transquant_bypass_enable_flag" ); 237 238 #if TILES_WPP_ENTROPYSLICES_FLAGS239 #if DEPENDENT_SLICES240 WRITE_FLAG( pcPPS->getDependentSliceEnabledFlag() ? 1 : 0, "dependent_slice_enabled_flag" );241 #endif242 192 WRITE_FLAG( pcPPS->getTilesEnabledFlag() ? 1 : 0, "tiles_enabled_flag" ); 243 193 WRITE_FLAG( pcPPS->getEntropyCodingSyncEnabledFlag() ? 1 : 0, "entropy_coding_sync_enabled_flag" ); 244 WRITE_FLAG( pcPPS->getEntropySliceEnabledFlag() ? 1 : 0, "entropy_slice_enabled_flag" );245 194 if( pcPPS->getTilesEnabledFlag() ) 246 #else247 Int tilesOrEntropyCodingSyncIdc = 0;248 if ( pcPPS->getNumColumnsMinus1() > 0 || pcPPS->getNumRowsMinus1() > 0)249 {250 tilesOrEntropyCodingSyncIdc = 1;251 }252 else if ( pcPPS->getNumSubstreams() > 1 )253 {254 tilesOrEntropyCodingSyncIdc = 2;255 }256 #if DEPENDENT_SLICES257 else if( pcPPS->getDependentSliceEnabledFlag() )258 {259 if(pcPPS->getTilesOrEntropyCodingSyncIdc() != 2)260 {261 tilesOrEntropyCodingSyncIdc = 3;262 }263 else264 {265 tilesOrEntropyCodingSyncIdc = 2;266 }267 }268 #endif269 pcPPS->setTilesOrEntropyCodingSyncIdc( tilesOrEntropyCodingSyncIdc );270 WRITE_CODE(tilesOrEntropyCodingSyncIdc, 2, "tiles_or_entropy_coding_sync_idc");271 272 if(pcPPS->getTilesOrEntropyCodingSyncIdc()==1)273 #endif274 195 { 275 196 WRITE_UVLC( pcPPS->getNumColumnsMinus1(), "num_tile_columns_minus1" ); … … 292 213 } 293 214 } 294 #if !TILES_WPP_ENTROPYSLICES_FLAGS295 #if DEPENDENT_SLICES296 else if( pcPPS->getTilesOrEntropyCodingSyncIdc()==3 )297 {298 WRITE_FLAG( pcPPS->getCabacIndependentFlag()? 1 : 0, "cabac_independent_flag" );299 }300 #endif301 #endif302 #if MOVE_LOOP_FILTER_SLICES_FLAG303 215 WRITE_FLAG( pcPPS->getLoopFilterAcrossSlicesEnabledFlag()?1 : 0, "loop_filter_across_slices_enabled_flag"); 304 #endif305 216 WRITE_FLAG( pcPPS->getDeblockingFilterControlPresentFlag()?1 : 0, "deblocking_filter_control_present_flag"); 306 217 if(pcPPS->getDeblockingFilterControlPresentFlag()) 307 218 { 308 219 WRITE_FLAG( pcPPS->getDeblockingFilterOverrideEnabledFlag() ? 1 : 0, "deblocking_filter_override_enabled_flag" ); 309 WRITE_FLAG( pcPPS->getPicDisableDeblockingFilterFlag() , "pic_disable_deblocking_filter_flag" );220 WRITE_FLAG( pcPPS->getPicDisableDeblockingFilterFlag() ? 1 : 0, "pps_disable_deblocking_filter_flag" ); 310 221 if(!pcPPS->getPicDisableDeblockingFilterFlag()) 311 222 { … … 322 233 codeScalingList( m_pcSlice->getScalingList() ); 323 234 } 235 WRITE_FLAG( pcPPS->getListsModificationPresentFlag(), "lists_modification_present_flag"); 324 236 WRITE_UVLC( pcPPS->getLog2ParallelMergeLevelMinus2(), "log2_parallel_merge_level_minus2"); 325 #if SLICE_HEADER_EXTENSION 326 WRITE_FLAG( pcPPS->getSliceHeaderExtensionPresentFlag(), "slice_header_extension_present_flag"); 327 #endif 237 #if !L0255_MOVE_PPS_FLAGS 238 WRITE_CODE( pcPPS->getNumExtraSliceHeaderBits(), 3, "num_extra_slice_header_bits"); 239 #endif 240 WRITE_FLAG( pcPPS->getSliceHeaderExtensionPresentFlag() ? 1 : 0, "slice_segment_header_extension_present_flag"); 328 241 WRITE_FLAG( 0, "pps_extension_flag" ); 329 242 } 330 243 331 #if SUPPORT_FOR_VUI332 244 Void TEncCavlc::codeVUI( TComVUI *pcVUI, TComSPS* pcSPS ) 333 245 { … … 374 286 WRITE_FLAG(pcVUI->getFieldSeqFlag(), "field_seq_flag"); 375 287 assert(pcVUI->getFieldSeqFlag() == 0); // not currently supported 288 WRITE_FLAG(pcVUI->getFrameFieldInfoPresentFlag(), "frame_field_info_present_flag"); 289 290 Window defaultDisplayWindow = pcVUI->getDefaultDisplayWindow(); 291 WRITE_FLAG(defaultDisplayWindow.getWindowEnabledFlag(), "default_display_window_flag"); 292 if( defaultDisplayWindow.getWindowEnabledFlag() ) 293 { 294 WRITE_UVLC(defaultDisplayWindow.getWindowLeftOffset(), "def_disp_win_left_offset"); 295 WRITE_UVLC(defaultDisplayWindow.getWindowRightOffset(), "def_disp_win_right_offset"); 296 WRITE_UVLC(defaultDisplayWindow.getWindowTopOffset(), "def_disp_win_top_offset"); 297 WRITE_UVLC(defaultDisplayWindow.getWindowBottomOffset(), "def_disp_win_bottom_offset"); 298 } 299 #if L0043_TIMING_INFO 300 TimingInfo *timingInfo = pcVUI->getTimingInfo(); 301 WRITE_FLAG(timingInfo->getTimingInfoPresentFlag(), "vui_timing_info_present_flag"); 302 if(timingInfo->getTimingInfoPresentFlag()) 303 { 304 WRITE_CODE(timingInfo->getNumUnitsInTick(), 32, "vui_num_units_in_tick"); 305 WRITE_CODE(timingInfo->getTimeScale(), 32, "vui_time_scale"); 306 WRITE_FLAG(timingInfo->getPocProportionalToTimingFlag(), "vui_poc_proportional_to_timing_flag"); 307 if(timingInfo->getPocProportionalToTimingFlag()) 308 { 309 WRITE_UVLC(timingInfo->getNumTicksPocDiffOneMinus1(), "vui_num_ticks_poc_diff_one_minus1"); 310 } 311 #endif 376 312 WRITE_FLAG(pcVUI->getHrdParametersPresentFlag(), "hrd_parameters_present_flag"); 377 #if !BUFFERING_PERIOD_AND_TIMING_SEI378 assert(pcVUI->getHrdParametersPresentFlag() == 0); // not currently supported379 #else380 313 if( pcVUI->getHrdParametersPresentFlag() ) 381 314 { 382 WRITE_FLAG(pcVUI->getTimingInfoPresentFlag(), "timing_info_present_flag"); 383 if( pcVUI->getTimingInfoPresentFlag() ) 384 { 385 WRITE_CODE(pcVUI->getNumUnitsInTick(), 32, "num_units_in_tick"); 386 WRITE_CODE(pcVUI->getTimeScale(), 32, "time_scale"); 387 } 388 WRITE_FLAG(pcVUI->getNalHrdParametersPresentFlag(), "nal_hrd_parameters_present_flag"); 389 WRITE_FLAG(pcVUI->getVclHrdParametersPresentFlag(), "vcl_hrd_parameters_present_flag"); 390 if( pcVUI->getNalHrdParametersPresentFlag() || pcVUI->getVclHrdParametersPresentFlag() ) 391 { 392 WRITE_FLAG(pcVUI->getSubPicCpbParamsPresentFlag(), "sub_pic_cpb_params_present_flag"); 393 if( pcVUI->getSubPicCpbParamsPresentFlag() ) 394 { 395 WRITE_CODE(pcVUI->getTickDivisorMinus2(), 8, "tick_divisor_minus2"); 396 WRITE_CODE(pcVUI->getDuCpbRemovalDelayLengthMinus1(), 5, "du_cpb_removal_delay_length_minus1"); 397 } 398 WRITE_CODE(pcVUI->getBitRateScale(), 4, "bit_rate_scale"); 399 WRITE_CODE(pcVUI->getCpbSizeScale(), 4, "cpb_size_scale"); 400 WRITE_CODE(pcVUI->getInitialCpbRemovalDelayLengthMinus1(), 5, "initial_cpb_removal_delay_length_minus1"); 401 WRITE_CODE(pcVUI->getCpbRemovalDelayLengthMinus1(), 5, "cpb_removal_delay_length_minus1"); 402 WRITE_CODE(pcVUI->getDpbOutputDelayLengthMinus1(), 5, "dpb_output_delay_length_minus1"); 403 } 404 Int i, j, nalOrVcl; 405 for( i = 0; i <= pcSPS->getMaxTLayers(); i ++ ) 406 { 407 WRITE_FLAG(pcVUI->getFixedPicRateFlag(i), "fixed_pic_rate_flag"); 408 if( pcVUI->getFixedPicRateFlag( i ) ) 409 { 410 WRITE_UVLC(pcVUI->getPicDurationInTcMinus1(i), "pic_duration_in_tc_minus1"); 411 } 412 WRITE_FLAG(pcVUI->getLowDelayHrdFlag(i), "low_delay_hrd_flag"); 413 WRITE_UVLC(pcVUI->getCpbCntMinus1(i), "cpb_cnt_minus1"); 414 415 for( nalOrVcl = 0; nalOrVcl < 2; nalOrVcl ++ ) 416 { 417 if( ( ( nalOrVcl == 0 ) && ( pcVUI->getNalHrdParametersPresentFlag() ) ) || 418 ( ( nalOrVcl == 1 ) && ( pcVUI->getVclHrdParametersPresentFlag() ) ) ) 419 { 420 for( j = 0; j < ( pcVUI->getCpbCntMinus1( i ) + 1 ); j ++ ) 421 { 422 WRITE_UVLC(pcVUI->getBitRateValueMinus1(i, j, nalOrVcl), "bit_size_value_minus1"); 423 WRITE_UVLC(pcVUI->getCpbSizeValueMinus1(i, j, nalOrVcl), "cpb_size_value_minus1"); 424 WRITE_FLAG(pcVUI->getCbrFlag(i, j, nalOrVcl), "cbr_flag"); 425 } 426 } 427 } 428 } 429 } 430 #endif 315 codeHrdParameters(pcVUI->getHrdParameters(), 1, pcSPS->getMaxTLayers() - 1 ); 316 } 317 #if L0043_TIMING_INFO 318 } 319 #endif 320 #if !L0043_TIMING_INFO 321 WRITE_FLAG( pcVUI->getPocProportionalToTimingFlag(), "poc_proportional_to_timing_flag" ); 322 if( pcVUI->getPocProportionalToTimingFlag() && pcVUI->getHrdParameters()->getTimingInfoPresentFlag() ) 323 { 324 WRITE_UVLC( pcVUI->getNumTicksPocDiffOneMinus1(), "num_ticks_poc_diff_one_minus1" ); 325 } 326 #endif 327 431 328 WRITE_FLAG(pcVUI->getBitstreamRestrictionFlag(), "bitstream_restriction_flag"); 432 329 if (pcVUI->getBitstreamRestrictionFlag()) … … 434 331 WRITE_FLAG(pcVUI->getTilesFixedStructureFlag(), "tiles_fixed_structure_flag"); 435 332 WRITE_FLAG(pcVUI->getMotionVectorsOverPicBoundariesFlag(), "motion_vectors_over_pic_boundaries_flag"); 333 WRITE_FLAG(pcVUI->getRestrictedRefPicListsFlag(), "restricted_ref_pic_lists_flag"); 334 #if L0043_MSS_IDC 335 WRITE_UVLC(pcVUI->getMinSpatialSegmentationIdc(), "min_spatial_segmentation_idc"); 336 #else 337 WRITE_CODE(pcVUI->getMinSpatialSegmentationIdc(), 8, "min_spatial_segmentation_idc"); 338 #endif 436 339 WRITE_UVLC(pcVUI->getMaxBytesPerPicDenom(), "max_bytes_per_pic_denom"); 437 340 WRITE_UVLC(pcVUI->getMaxBitsPerMinCuDenom(), "max_bits_per_mincu_denom"); … … 439 342 WRITE_UVLC(pcVUI->getLog2MaxMvLengthVertical(), "log2_max_mv_length_vertical"); 440 343 } 441 442 } 443 #endif 344 } 345 346 Void TEncCavlc::codeHrdParameters( TComHRD *hrd, Bool commonInfPresentFlag, UInt maxNumSubLayersMinus1 ) 347 { 348 if( commonInfPresentFlag ) 349 { 350 #if !L0043_TIMING_INFO 351 WRITE_FLAG( hrd->getTimingInfoPresentFlag() ? 1 : 0, "timing_info_present_flag" ); 352 if( hrd->getTimingInfoPresentFlag() ) 353 { 354 WRITE_CODE( hrd->getNumUnitsInTick(), 32, "num_units_in_tick" ); 355 WRITE_CODE( hrd->getTimeScale(), 32, "time_scale" ); 356 } 357 #endif 358 WRITE_FLAG( hrd->getNalHrdParametersPresentFlag() ? 1 : 0 , "nal_hrd_parameters_present_flag" ); 359 WRITE_FLAG( hrd->getVclHrdParametersPresentFlag() ? 1 : 0 , "vcl_hrd_parameters_present_flag" ); 360 if( hrd->getNalHrdParametersPresentFlag() || hrd->getVclHrdParametersPresentFlag() ) 361 { 362 WRITE_FLAG( hrd->getSubPicCpbParamsPresentFlag() ? 1 : 0, "sub_pic_cpb_params_present_flag" ); 363 if( hrd->getSubPicCpbParamsPresentFlag() ) 364 { 365 WRITE_CODE( hrd->getTickDivisorMinus2(), 8, "tick_divisor_minus2" ); 366 WRITE_CODE( hrd->getDuCpbRemovalDelayLengthMinus1(), 5, "du_cpb_removal_delay_length_minus1" ); 367 WRITE_FLAG( hrd->getSubPicCpbParamsInPicTimingSEIFlag() ? 1 : 0, "sub_pic_cpb_params_in_pic_timing_sei_flag" ); 368 #if L0044_DU_DPB_OUTPUT_DELAY_HRD 369 WRITE_CODE( hrd->getDpbOutputDelayDuLengthMinus1(), 5, "dpb_output_delay_du_length_minus1" ); 370 #endif 371 } 372 WRITE_CODE( hrd->getBitRateScale(), 4, "bit_rate_scale" ); 373 WRITE_CODE( hrd->getCpbSizeScale(), 4, "cpb_size_scale" ); 374 if( hrd->getSubPicCpbParamsPresentFlag() ) 375 { 376 WRITE_CODE( hrd->getDuCpbSizeScale(), 4, "du_cpb_size_scale" ); 377 } 378 WRITE_CODE( hrd->getInitialCpbRemovalDelayLengthMinus1(), 5, "initial_cpb_removal_delay_length_minus1" ); 379 WRITE_CODE( hrd->getCpbRemovalDelayLengthMinus1(), 5, "au_cpb_removal_delay_length_minus1" ); 380 WRITE_CODE( hrd->getDpbOutputDelayLengthMinus1(), 5, "dpb_output_delay_length_minus1" ); 381 } 382 } 383 Int i, j, nalOrVcl; 384 for( i = 0; i <= maxNumSubLayersMinus1; i ++ ) 385 { 386 WRITE_FLAG( hrd->getFixedPicRateFlag( i ) ? 1 : 0, "fixed_pic_rate_general_flag"); 387 if( !hrd->getFixedPicRateFlag( i ) ) 388 { 389 WRITE_FLAG( hrd->getFixedPicRateWithinCvsFlag( i ) ? 1 : 0, "fixed_pic_rate_within_cvs_flag"); 390 } 391 else 392 { 393 hrd->setFixedPicRateWithinCvsFlag( i, true ); 394 } 395 if( hrd->getFixedPicRateWithinCvsFlag( i ) ) 396 { 397 WRITE_UVLC( hrd->getPicDurationInTcMinus1( i ), "elemental_duration_in_tc_minus1"); 398 } 399 #if L0372 400 else 401 { 402 WRITE_FLAG( hrd->getLowDelayHrdFlag( i ) ? 1 : 0, "low_delay_hrd_flag"); 403 } 404 if (!hrd->getLowDelayHrdFlag( i )) 405 { 406 WRITE_UVLC( hrd->getCpbCntMinus1( i ), "cpb_cnt_minus1"); 407 } 408 #else 409 WRITE_FLAG( hrd->getLowDelayHrdFlag( i ) ? 1 : 0, "low_delay_hrd_flag"); 410 WRITE_UVLC( hrd->getCpbCntMinus1( i ), "cpb_cnt_minus1"); 411 #endif 412 413 for( nalOrVcl = 0; nalOrVcl < 2; nalOrVcl ++ ) 414 { 415 if( ( ( nalOrVcl == 0 ) && ( hrd->getNalHrdParametersPresentFlag() ) ) || 416 ( ( nalOrVcl == 1 ) && ( hrd->getVclHrdParametersPresentFlag() ) ) ) 417 { 418 for( j = 0; j <= ( hrd->getCpbCntMinus1( i ) ); j ++ ) 419 { 420 WRITE_UVLC( hrd->getBitRateValueMinus1( i, j, nalOrVcl ), "bit_rate_value_minus1"); 421 WRITE_UVLC( hrd->getCpbSizeValueMinus1( i, j, nalOrVcl ), "cpb_size_value_minus1"); 422 if( hrd->getSubPicCpbParamsPresentFlag() ) 423 { 424 #if L0363_DU_BIT_RATE 425 WRITE_UVLC( hrd->getDuBitRateValueMinus1( i, j, nalOrVcl ), "bit_rate_du_value_minus1"); 426 #endif 427 WRITE_UVLC( hrd->getDuCpbSizeValueMinus1( i, j, nalOrVcl ), "cpb_size_du_value_minus1"); 428 } 429 WRITE_FLAG( hrd->getCbrFlag( i, j, nalOrVcl ) ? 1 : 0, "cbr_flag"); 430 } 431 } 432 } 433 } 434 } 444 435 445 436 Void TEncCavlc::codeSPS( TComSPS* pcSPS ) … … 448 439 xTraceSPSHeader (pcSPS); 449 440 #endif 450 #if SPS_SYNTAX_CHANGES 451 WRITE_CODE( pcSPS->getVPSId (), 4, "video_parameter_set_id" ); 441 WRITE_CODE( pcSPS->getVPSId (), 4, "sps_video_parameter_set_id" ); 452 442 WRITE_CODE( pcSPS->getMaxTLayers() - 1, 3, "sps_max_sub_layers_minus1" ); 453 WRITE_FLAG( 0, "sps_reserved_zero_bit");443 WRITE_FLAG( pcSPS->getTemporalIdNestingFlag() ? 1 : 0, "sps_temporal_id_nesting_flag" ); 454 444 codePTL(pcSPS->getPTL(), 1, pcSPS->getMaxTLayers() - 1); 455 WRITE_UVLC( pcSPS->getSPSId (), "s eq_parameter_set_id" );445 WRITE_UVLC( pcSPS->getSPSId (), "sps_seq_parameter_set_id" ); 456 446 WRITE_UVLC( pcSPS->getChromaFormatIdc (), "chroma_format_idc" ); 457 447 assert(pcSPS->getChromaFormatIdc () == 1); … … 462 452 } 463 453 464 #else465 WRITE_CODE( pcSPS->getProfileSpace (), 3, "profile_space" );466 WRITE_CODE( pcSPS->getProfileIdc (), 5, "profile_idc" );467 WRITE_CODE( pcSPS->getRsvdIndFlags(), 16, "reserved_indicator_flags" );468 WRITE_CODE( pcSPS->getLevelIdc (), 8, "level_idc" );469 WRITE_CODE( pcSPS->getProfileCompat (), 32, "profile_compatibility" );470 WRITE_UVLC( pcSPS->getSPSId (), "seq_parameter_set_id" );471 WRITE_UVLC( pcSPS->getVPSId (), "video_parameter_set_id" );472 WRITE_UVLC( pcSPS->getChromaFormatIdc (), "chroma_format_idc" );473 WRITE_CODE( pcSPS->getMaxTLayers() - 1, 3, "max_temporal_layers_minus1" );474 #endif475 454 WRITE_UVLC( pcSPS->getPicWidthInLumaSamples (), "pic_width_in_luma_samples" ); 476 455 WRITE_UVLC( pcSPS->getPicHeightInLumaSamples(), "pic_height_in_luma_samples" ); 477 WRITE_FLAG( pcSPS->getPicCroppingFlag(), "pic_cropping_flag" ); 478 if (pcSPS->getPicCroppingFlag()) 479 { 480 WRITE_UVLC( pcSPS->getPicCropLeftOffset() / TComSPS::getCropUnitX(pcSPS->getChromaFormatIdc() ), "pic_crop_left_offset" ); 481 WRITE_UVLC( pcSPS->getPicCropRightOffset() / TComSPS::getCropUnitX(pcSPS->getChromaFormatIdc() ), "pic_crop_right_offset" ); 482 WRITE_UVLC( pcSPS->getPicCropTopOffset() / TComSPS::getCropUnitY(pcSPS->getChromaFormatIdc() ), "pic_crop_top_offset" ); 483 WRITE_UVLC( pcSPS->getPicCropBottomOffset() / TComSPS::getCropUnitY(pcSPS->getChromaFormatIdc() ), "pic_crop_bottom_offset" ); 484 } 485 486 #if FULL_NBIT 487 WRITE_UVLC( pcSPS->getBitDepth() - 8, "bit_depth_luma_minus8" ); 488 #else 489 WRITE_UVLC( pcSPS->getBitIncrement(), "bit_depth_luma_minus8" ); 490 #endif 491 #if FULL_NBIT 492 WRITE_UVLC( pcSPS->getBitDepth() - 8, "bit_depth_chroma_minus8" ); 493 #else 494 WRITE_UVLC( pcSPS->getBitIncrement(), "bit_depth_chroma_minus8" ); 495 #endif 496 497 WRITE_FLAG( pcSPS->getUsePCM() ? 1 : 0, "pcm_enabled_flag"); 498 499 if( pcSPS->getUsePCM() ) 500 { 501 WRITE_CODE( pcSPS->getPCMBitDepthLuma() - 1, 4, "pcm_bit_depth_luma_minus1" ); 502 WRITE_CODE( pcSPS->getPCMBitDepthChroma() - 1, 4, "pcm_bit_depth_chroma_minus1" ); 503 } 456 Window conf = pcSPS->getConformanceWindow(); 457 458 WRITE_FLAG( conf.getWindowEnabledFlag(), "conformance_window_flag" ); 459 if (conf.getWindowEnabledFlag()) 460 { 461 WRITE_UVLC( conf.getWindowLeftOffset() / TComSPS::getWinUnitX(pcSPS->getChromaFormatIdc() ), "conf_win_left_offset" ); 462 WRITE_UVLC( conf.getWindowRightOffset() / TComSPS::getWinUnitX(pcSPS->getChromaFormatIdc() ), "conf_win_right_offset" ); 463 WRITE_UVLC( conf.getWindowTopOffset() / TComSPS::getWinUnitY(pcSPS->getChromaFormatIdc() ), "conf_win_top_offset" ); 464 WRITE_UVLC( conf.getWindowBottomOffset() / TComSPS::getWinUnitY(pcSPS->getChromaFormatIdc() ), "conf_win_bottom_offset" ); 465 } 466 467 WRITE_UVLC( pcSPS->getBitDepthY() - 8, "bit_depth_luma_minus8" ); 468 WRITE_UVLC( pcSPS->getBitDepthC() - 8, "bit_depth_chroma_minus8" ); 504 469 505 470 WRITE_UVLC( pcSPS->getBitsForPOC()-4, "log2_max_pic_order_cnt_lsb_minus4" ); 471 472 const Bool subLayerOrderingInfoPresentFlag = 1; 473 WRITE_FLAG(subLayerOrderingInfoPresentFlag, "sps_sub_layer_ordering_info_present_flag"); 506 474 for(UInt i=0; i <= pcSPS->getMaxTLayers()-1; i++) 507 475 { 508 WRITE_UVLC( pcSPS->getMaxDecPicBuffering(i), "max_dec_pic_buffering[i]" ); 509 WRITE_UVLC( pcSPS->getNumReorderPics(i), "num_reorder_pics[i]" ); 510 WRITE_UVLC( pcSPS->getMaxLatencyIncrease(i), "max_latency_increase[i]" ); 476 WRITE_UVLC( pcSPS->getMaxDecPicBuffering(i), "sps_max_dec_pic_buffering[i]" ); 477 WRITE_UVLC( pcSPS->getNumReorderPics(i), "sps_num_reorder_pics[i]" ); 478 WRITE_UVLC( pcSPS->getMaxLatencyIncrease(i), "sps_max_latency_increase[i]" ); 479 if (!subLayerOrderingInfoPresentFlag) 480 { 481 break; 482 } 511 483 } 512 484 assert( pcSPS->getMaxCUWidth() == pcSPS->getMaxCUHeight() ); … … 520 492 } 521 493 522 WRITE_FLAG( pcSPS->getRestrictedRefPicListsFlag(), "restricted_ref_pic_lists_flag" );523 if( pcSPS->getRestrictedRefPicListsFlag() )524 {525 WRITE_FLAG( pcSPS->getListsModificationPresentFlag(), "lists_modification_present_flag" );526 }527 494 WRITE_UVLC( log2MinCUSize - 3, "log2_min_coding_block_size_minus3" ); 528 495 WRITE_UVLC( pcSPS->getMaxCUDepth()-g_uiAddCUDepth, "log2_diff_max_min_coding_block_size" ); 529 496 WRITE_UVLC( pcSPS->getQuadtreeTULog2MinSize() - 2, "log2_min_transform_block_size_minus2" ); 530 497 WRITE_UVLC( pcSPS->getQuadtreeTULog2MaxSize() - pcSPS->getQuadtreeTULog2MinSize(), "log2_diff_max_min_transform_block_size" ); 531 if( pcSPS->getUsePCM() )532 {533 WRITE_UVLC( pcSPS->getPCMLog2MinSize() - 3, "log2_min_pcm_coding_block_size_minus3" );534 WRITE_UVLC( pcSPS->getPCMLog2MaxSize() - pcSPS->getPCMLog2MinSize(), "log2_diff_max_min_pcm_coding_block_size" );535 }536 498 WRITE_UVLC( pcSPS->getQuadtreeTUMaxDepthInter() - 1, "max_transform_hierarchy_depth_inter" ); 537 499 WRITE_UVLC( pcSPS->getQuadtreeTUMaxDepthIntra() - 1, "max_transform_hierarchy_depth_intra" ); … … 548 510 } 549 511 } 550 #if !REMOVE_LMCHROMA 551 WRITE_FLAG( pcSPS->getUseLMChroma () ? 1 : 0, "chroma_pred_from_luma_enabled_flag" ); 552 #endif 553 #if !PPS_TS_FLAG 554 WRITE_FLAG( pcSPS->getUseTransformSkip () ? 1 : 0, "transform_skip_enabled_flag" ); 555 #endif 556 #if !MOVE_LOOP_FILTER_SLICES_FLAG 557 WRITE_FLAG( pcSPS->getLFCrossSliceBoundaryFlag()?1 : 0, "seq_loop_filter_across_slices_enabled_flag"); 558 #endif 559 WRITE_FLAG( pcSPS->getUseAMP(), "asymmetric_motion_partitions_enabled_flag" ); 560 #if !REMOVE_NSQT 561 WRITE_FLAG( pcSPS->getUseNSQT(), "non_square_quadtree_enabled_flag" ); 562 #endif 512 WRITE_FLAG( pcSPS->getUseAMP() ? 1 : 0, "amp_enabled_flag" ); 563 513 WRITE_FLAG( pcSPS->getUseSAO() ? 1 : 0, "sample_adaptive_offset_enabled_flag"); 564 #if !REMOVE_ALF 565 WRITE_FLAG( pcSPS->getUseALF () ? 1 : 0, "adaptive_loop_filter_enabled_flag"); 566 #endif 514 515 WRITE_FLAG( pcSPS->getUsePCM() ? 1 : 0, "pcm_enabled_flag"); 567 516 if( pcSPS->getUsePCM() ) 568 517 { 569 WRITE_FLAG( pcSPS->getPCMFilterDisableFlag()?1 : 0, "pcm_loop_filter_disable_flag"); 518 WRITE_CODE( pcSPS->getPCMBitDepthLuma() - 1, 4, "pcm_sample_bit_depth_luma_minus1" ); 519 WRITE_CODE( pcSPS->getPCMBitDepthChroma() - 1, 4, "pcm_sample_bit_depth_chroma_minus1" ); 520 WRITE_UVLC( pcSPS->getPCMLog2MinSize() - 3, "log2_min_pcm_luma_coding_block_size_minus3" ); 521 WRITE_UVLC( pcSPS->getPCMLog2MaxSize() - pcSPS->getPCMLog2MinSize(), "log2_diff_max_min_pcm_luma_coding_block_size" ); 522 WRITE_FLAG( pcSPS->getPCMFilterDisableFlag()?1 : 0, "pcm_loop_filter_disable_flag"); 570 523 } 571 524 572 525 assert( pcSPS->getMaxTLayers() > 0 ); 573 574 WRITE_FLAG( pcSPS->getTemporalIdNestingFlag() ? 1 : 0, "temporal_id_nesting_flag" );575 526 576 527 TComRPSList* rpsList = pcSPS->getRPSList(); … … 581 532 { 582 533 rps = rpsList->getReferencePictureSet(i); 583 #if J0234_INTER_RPS_SIMPL 584 codeShortTermRefPicSet(pcSPS,rps,false); 585 #else 586 codeShortTermRefPicSet(pcSPS,rps); 587 #endif 588 } 534 codeShortTermRefPicSet(pcSPS,rps,false, i); 535 } 589 536 WRITE_FLAG( pcSPS->getLongTermRefsPresent() ? 1 : 0, "long_term_ref_pics_present_flag" ); 590 #if LTRP_IN_SPS591 537 if (pcSPS->getLongTermRefsPresent()) 592 538 { … … 598 544 } 599 545 } 600 #endif601 546 WRITE_FLAG( pcSPS->getTMVPFlagsPresent() ? 1 : 0, "sps_temporal_mvp_enable_flag" ); 602 547 #if REF_IDX_MFM 603 548 if( pcSPS->getLayerId() > 0 ) 604 549 { 605 assert(pcSPS->getMFMEnabledFlag());606 550 WRITE_FLAG( pcSPS->getMFMEnabledFlag() ? 1 : 0, "sps_enh_mfm_enable_flag" ); 607 551 } 608 552 #endif 609 #if SUPPORT_FOR_VUI 553 WRITE_FLAG( pcSPS->getUseStrongIntraSmoothing(), "sps_strong_intra_smoothing_enable_flag" ); 554 610 555 WRITE_FLAG( pcSPS->getVuiParametersPresentFlag(), "vui_parameters_present_flag" ); 611 556 if (pcSPS->getVuiParametersPresentFlag()) … … 613 558 codeVUI(pcSPS->getVuiParameters(), pcSPS); 614 559 } 615 #endif 616 #if !SPS_AMVP_CLEANUP 617 // AMVP mode for each depth 618 for (Int i = 0; i < pcSPS->getMaxCUDepth(); i++) 619 { 620 xWriteFlag( pcSPS->getAMVPMode(i) ? 1 : 0); 621 } 622 #endif 560 623 561 WRITE_FLAG( 0, "sps_extension_flag" ); 624 562 } … … 626 564 Void TEncCavlc::codeVPS( TComVPS* pcVPS ) 627 565 { 628 #if VPS_SYNTAX_CHANGES 629 WRITE_CODE( pcVPS->getVPSId(), 4, "video_parameter_set_id" ); 566 WRITE_CODE( pcVPS->getVPSId(), 4, "vps_video_parameter_set_id" ); 567 WRITE_CODE( 3, 2, "vps_reserved_three_2bits" ); 568 #if VPS_RENAME 569 WRITE_CODE( pcVPS->getMaxLayers() - 1, 6, "vps_max_layers_minus1" ); 570 #else 571 WRITE_CODE( 0, 6, "vps_reserved_zero_6bits" ); 572 #endif 573 WRITE_CODE( pcVPS->getMaxTLayers() - 1, 3, "vps_max_sub_layers_minus1" ); 630 574 WRITE_FLAG( pcVPS->getTemporalNestingFlag(), "vps_temporal_id_nesting_flag" ); 631 WRITE_CODE( 0, 2, "vps_reserved_zero_2bits" ); 632 WRITE_CODE( 0, 6, "vps_reserved_zero_6bits" ); 633 WRITE_CODE( pcVPS->getMaxTLayers() - 1, 3, "vps_max_sub_layers_minus1" ); 575 assert (pcVPS->getMaxTLayers()>1||pcVPS->getTemporalNestingFlag()); 576 WRITE_CODE( 0xffff, 16, "vps_reserved_ffff_16bits" ); 634 577 codePTL( pcVPS->getPTL(), true, pcVPS->getMaxTLayers() - 1 ); 635 WRITE_CODE( 0, 12, "vps_reserved_zero_12bits" ); 636 #else 637 WRITE_CODE( pcVPS->getMaxTLayers() - 1, 3, "vps_max_temporal_layers_minus1" ); 638 WRITE_CODE( pcVPS->getMaxLayers() - 1, 5, "vps_max_layers_minus1" ); 639 WRITE_UVLC( pcVPS->getVPSId(), "video_parameter_set_id" ); 640 WRITE_FLAG( pcVPS->getTemporalNestingFlag(), "vps_temporal_id_nesting_flag" ); 641 #endif 578 #if SIGNAL_BITRATE_PICRATE_IN_VPS 579 codeBitratePicRateInfo(pcVPS->getBitratePicrateInfo(), 0, pcVPS->getMaxTLayers() - 1); 580 #endif 581 const Bool subLayerOrderingInfoPresentFlag = 1; 582 WRITE_FLAG(subLayerOrderingInfoPresentFlag, "vps_sub_layer_ordering_info_present_flag"); 642 583 for(UInt i=0; i <= pcVPS->getMaxTLayers()-1; i++) 643 584 { … … 645 586 WRITE_UVLC( pcVPS->getNumReorderPics(i), "vps_num_reorder_pics[i]" ); 646 587 WRITE_UVLC( pcVPS->getMaxLatencyIncrease(i), "vps_max_latency_increase[i]" ); 647 } 648 #if VPS_SYNTAX_CHANGES 649 WRITE_UVLC( 0, "vps_num_hrd_parameters" ); 650 // hrd_parameters 651 #endif 588 if (!subLayerOrderingInfoPresentFlag) 589 { 590 break; 591 } 592 } 593 594 #if VPS_RENAME 595 assert( pcVPS->getNumHrdParameters() <= MAX_VPS_LAYER_SETS_PLUS1 ); 596 assert( pcVPS->getMaxLayerId() < MAX_VPS_LAYER_ID_PLUS1 ); 597 #if !VPS_EXTN_OP_LAYER_SETS // num layer sets set in TAppEncTop.cpp 598 pcVPS->setNumLayerSets(1); 599 #endif 600 WRITE_CODE( pcVPS->getMaxLayerId(), 6, "vps_max_layer_id" ); 601 WRITE_UVLC( pcVPS->getNumLayerSets() - 1, "vps_num_layer_sets_minus1" ); 602 for( UInt opsIdx = 1; opsIdx <= ( pcVPS->getNumLayerSets() - 1 ); opsIdx ++ ) 603 { 604 // Operation point set 605 for( UInt i = 0; i <= pcVPS->getMaxLayerId(); i ++ ) 606 #else 607 assert( pcVPS->getNumHrdParameters() <= MAX_VPS_NUM_HRD_PARAMETERS ); 608 assert( pcVPS->getMaxNuhReservedZeroLayerId() < MAX_VPS_NUH_RESERVED_ZERO_LAYER_ID_PLUS1 ); 609 WRITE_CODE( pcVPS->getMaxNuhReservedZeroLayerId(), 6, "vps_max_nuh_reserved_zero_layer_id" ); 610 pcVPS->setMaxOpSets(1); 611 WRITE_UVLC( pcVPS->getMaxOpSets() - 1, "vps_max_op_sets_minus1" ); 612 for( UInt opsIdx = 1; opsIdx <= ( pcVPS->getMaxOpSets() - 1 ); opsIdx ++ ) 613 { 614 // Operation point set 615 for( UInt i = 0; i <= pcVPS->getMaxNuhReservedZeroLayerId(); i ++ ) 616 #endif 617 { 618 #if !VPS_EXTN_OP_LAYER_SETS // layer Id include flag set in TAppEncTop.cpp 619 // Only applicable for version 1 620 pcVPS->setLayerIdIncludedFlag( true, opsIdx, i ); 621 #endif 622 WRITE_FLAG( pcVPS->getLayerIdIncludedFlag( opsIdx, i ) ? 1 : 0, "layer_id_included_flag[opsIdx][i]" ); 623 } 624 } 625 #if L0043_TIMING_INFO 626 TimingInfo *timingInfo = pcVPS->getTimingInfo(); 627 WRITE_FLAG(timingInfo->getTimingInfoPresentFlag(), "vps_timing_info_present_flag"); 628 if(timingInfo->getTimingInfoPresentFlag()) 629 { 630 WRITE_CODE(timingInfo->getNumUnitsInTick(), 32, "vps_num_units_in_tick"); 631 WRITE_CODE(timingInfo->getTimeScale(), 32, "vps_time_scale"); 632 WRITE_FLAG(timingInfo->getPocProportionalToTimingFlag(), "vps_poc_proportional_to_timing_flag"); 633 if(timingInfo->getPocProportionalToTimingFlag()) 634 { 635 WRITE_UVLC(timingInfo->getNumTicksPocDiffOneMinus1(), "vps_num_ticks_poc_diff_one_minus1"); 636 } 637 #endif 638 pcVPS->setNumHrdParameters( 0 ); 639 WRITE_UVLC( pcVPS->getNumHrdParameters(), "vps_num_hrd_parameters" ); 640 641 if( pcVPS->getNumHrdParameters() > 0 ) 642 { 643 pcVPS->createHrdParamBuffer(); 644 } 645 for( UInt i = 0; i < pcVPS->getNumHrdParameters(); i ++ ) 646 { 647 // Only applicable for version 1 648 pcVPS->setHrdOpSetIdx( 0, i ); 649 WRITE_UVLC( pcVPS->getHrdOpSetIdx( i ), "hrd_op_set_idx" ); 650 if( i > 0 ) 651 { 652 WRITE_FLAG( pcVPS->getCprmsPresentFlag( i ) ? 1 : 0, "cprms_present_flag[i]" ); 653 } 654 codeHrdParameters(pcVPS->getHrdParameters(i), pcVPS->getCprmsPresentFlag( i ), pcVPS->getMaxTLayers() - 1); 655 } 656 #if L0043_TIMING_INFO 657 } 658 #endif 659 #if !VPS_EXTNS 652 660 WRITE_FLAG( 0, "vps_extension_flag" ); 653 661 #else 662 WRITE_FLAG( 1, "vps_extension_flag" ); 663 codeVPSExtension(pcVPS); 664 WRITE_FLAG( 0, "vps_extension2_flag" ); // Flag value of 1 reserved 665 #endif 654 666 //future extensions here.. 655 667 … … 657 669 } 658 670 671 #if VPS_EXTNS 672 Void TEncCavlc::codeVPSExtension (TComVPS *vps) 673 { 674 // ... More syntax elements to be written here 675 #if VPS_EXTN_MASK_AND_DIM_INFO 676 UInt i = 0, j = 0; 677 678 WRITE_FLAG( vps->getAvcBaseLayerFlag(), "avc_base_layer_flag" ); 679 WRITE_FLAG( vps->getSplittingFlag(), "splitting_flag" ); 680 681 for(i = 0; i < MAX_VPS_NUM_SCALABILITY_TYPES; i++) 682 { 683 WRITE_FLAG( vps->getScalabilityMask(i), "scalability_mask[i]" ); 684 } 685 686 for(j = 0; j < vps->getNumScalabilityTypes(); j++) 687 { 688 WRITE_CODE( vps->getDimensionIdLen(j) - 1, 3, "dimension_id_len_minus1[j]" ); 689 } 690 691 WRITE_FLAG( vps->getNuhLayerIdPresentFlag(), "vps_nuh_layer_id_present_flag" ); 692 for(i = 1; i < vps->getMaxLayers(); i++) 693 { 694 if( vps->getNuhLayerIdPresentFlag() ) 695 { 696 WRITE_CODE( vps->getLayerIdInNuh(i), 6, "layer_id_in_nuh[i]" ); 697 } 698 for(j = 0; j < vps->getNumScalabilityTypes(); j++) 699 { 700 UInt bits = vps->getDimensionIdLen(j); 701 WRITE_CODE( vps->getDimensionId(i, j), bits, "dimension_id[i][j]" ); 702 } 703 } 704 #endif 705 #if VPS_EXTN_PROFILE_INFO 706 // Profile-tier-level signalling 707 for(Int idx = 1; idx <= vps->getNumLayerSets() - 1; idx++) 708 { 709 WRITE_FLAG( vps->getProfilePresentFlag(idx), "vps_profile_present_flag[i]" ); 710 if( !vps->getProfilePresentFlag(idx) ) 711 { 712 WRITE_UVLC( vps->getProfileLayerSetRef(idx) - 1, "vps_profile_layer_set_ref_minus1[i]" ); 713 } 714 codePTL( vps->getPTLForExtn(idx), vps->getProfilePresentFlag(idx), vps->getMaxTLayers() - 1 ); 715 } 716 #endif 717 #if VPS_EXTN_OP_LAYER_SETS 718 // Target output layer signalling 719 WRITE_UVLC( vps->getNumOutputLayerSets(), "vps_num_output_layer_sets"); 720 for(i = 0; i < vps->getNumOutputLayerSets(); i++) 721 { 722 WRITE_UVLC( vps->getOutputLayerSetIdx(i), "vps_output_layer_set_idx[i]"); 723 Int lsIdx = vps->getOutputLayerSetIdx(i); 724 for(j = 0; j <= vps->getMaxLayerId(); j++) 725 { 726 if(vps->getLayerIdIncludedFlag(lsIdx, j)) 727 { 728 WRITE_FLAG( vps->getOutputLayerFlag(lsIdx, j), "vps_output_layer_flag[lsIdx][j]"); 729 } 730 } 731 } 732 #endif 733 #if VPS_EXTN_DIRECT_REF_LAYERS 734 for( Int layerCtr = 1; layerCtr <= vps->getMaxLayers() - 1; layerCtr++) 735 { 736 for( Int refLayerCtr = 0; refLayerCtr < layerCtr; refLayerCtr++) 737 { 738 WRITE_FLAG(vps->getDirectDependencyFlag(layerCtr, refLayerCtr), "direct_dependency_flag[i][j]" ); 739 } 740 } 741 #endif 742 } 743 #endif 744 659 745 Void TEncCavlc::codeSliceHeader ( TComSlice* pcSlice ) 660 746 { … … 664 750 665 751 //calculate number of bits required for slice address 666 Int maxAddrOuter = pcSlice->getPic()->getNumCUsInFrame(); 667 Int reqBitsOuter = 0; 668 while(maxAddrOuter>(1<<reqBitsOuter)) 669 { 670 reqBitsOuter++; 671 } 672 Int maxAddrInner = pcSlice->getPic()->getNumPartInCU()>>(2); 673 #if REMOVE_FGS 674 maxAddrInner = 1; 675 #else 676 maxAddrInner = (1<<(pcSlice->getPPS()->getSliceGranularity()<<1)); 677 #endif 678 Int reqBitsInner = 0; 679 680 while(maxAddrInner>(1<<reqBitsInner)) 681 { 682 reqBitsInner++; 683 } 684 Int lCUAddress; 685 Int innerAddress; 752 Int maxSliceSegmentAddress = pcSlice->getPic()->getNumCUsInFrame(); 753 Int bitsSliceSegmentAddress = 0; 754 while(maxSliceSegmentAddress>(1<<bitsSliceSegmentAddress)) 755 { 756 bitsSliceSegmentAddress++; 757 } 758 Int ctuAddress; 686 759 if (pcSlice->isNextSlice()) 687 760 { 688 761 // Calculate slice address 689 lCUAddress = (pcSlice->getSliceCurStartCUAddr()/pcSlice->getPic()->getNumPartInCU()); 690 #if REMOVE_FGS 691 innerAddress = 0; 692 #else 693 innerAddress = (pcSlice->getSliceCurStartCUAddr()%(pcSlice->getPic()->getNumPartInCU()))>>((pcSlice->getSPS()->getMaxCUDepth()-pcSlice->getPPS()->getSliceGranularity())<<1); 694 #endif 762 ctuAddress = (pcSlice->getSliceCurStartCUAddr()/pcSlice->getPic()->getNumPartInCU()); 695 763 } 696 764 else 697 765 { 698 766 // Calculate slice address 699 lCUAddress = (pcSlice->getDependentSliceCurStartCUAddr()/pcSlice->getPic()->getNumPartInCU()); 700 #if REMOVE_FGS 701 innerAddress = 0; 702 #else 703 innerAddress = (pcSlice->getDependentSliceCurStartCUAddr()%(pcSlice->getPic()->getNumPartInCU()))>>((pcSlice->getSPS()->getMaxCUDepth()-pcSlice->getPPS()->getSliceGranularity())<<1); 704 #endif 705 767 ctuAddress = (pcSlice->getSliceSegmentCurStartCUAddr()/pcSlice->getPic()->getNumPartInCU()); 706 768 } 707 769 //write slice address 708 Int address = (pcSlice->getPic()->getPicSym()->getCUOrderMap(lCUAddress) << reqBitsInner) + innerAddress;709 WRITE_FLAG( address==0, "first_slice_in_pic_flag" ); 710 #if SPLICING_FRIENDLY_PARAMS 770 Int sliceSegmentAddress = pcSlice->getPic()->getPicSym()->getCUOrderMap(ctuAddress); 771 772 WRITE_FLAG( sliceSegmentAddress==0, "first_slice_segment_in_pic_flag" ); 711 773 if ( pcSlice->getRapPicFlag() ) 712 774 { 713 775 WRITE_FLAG( 0, "no_output_of_prior_pics_flag" ); 714 776 } 715 #endif 716 WRITE_UVLC( pcSlice->getPPS()->getPPSId(), "pic_parameter_set_id" ); 717 if(address>0) 718 { 719 WRITE_CODE( address, reqBitsOuter+reqBitsInner, "slice_address" ); 720 } 721 722 #if SLICEHEADER_SYNTAX_FIX 723 pcSlice->setDependentSliceFlag(!pcSlice->isNextSlice()); 724 if ( pcSlice->getPPS()->getDependentSliceEnabledFlag() && (address!=0) ) 725 { 726 WRITE_FLAG( pcSlice->getDependentSliceFlag() ? 1 : 0, "dependent_slice_flag" ); 727 } 728 if ( !pcSlice->getDependentSliceFlag() ) 729 { 730 #endif 777 WRITE_UVLC( pcSlice->getPPS()->getPPSId(), "slice_pic_parameter_set_id" ); 778 pcSlice->setDependentSliceSegmentFlag(!pcSlice->isNextSlice()); 779 if ( pcSlice->getPPS()->getDependentSliceSegmentsEnabledFlag() && (sliceSegmentAddress!=0) ) 780 { 781 WRITE_FLAG( pcSlice->getDependentSliceSegmentFlag() ? 1 : 0, "dependent_slice_segment_flag" ); 782 } 783 if(sliceSegmentAddress>0) 784 { 785 WRITE_CODE( sliceSegmentAddress, bitsSliceSegmentAddress, "slice_segment_address" ); 786 } 787 if ( !pcSlice->getDependentSliceSegmentFlag() ) 788 { 789 for (Int i = 0; i < pcSlice->getPPS()->getNumExtraSliceHeaderBits(); i++) 790 { 791 assert(!!"slice_reserved_undetermined_flag[]"); 792 WRITE_FLAG(0, "slice_reserved_undetermined_flag[]"); 793 } 731 794 732 795 WRITE_UVLC( pcSlice->getSliceType(), "slice_type" ); 733 796 734 #if !SLICEHEADER_SYNTAX_FIX735 Bool bDependentSlice = (!pcSlice->isNextSlice());736 WRITE_FLAG( bDependentSlice ? 1 : 0, "dependent_slice_flag" );737 738 #if DEPENDENT_SLICES739 if( pcSlice->getPPS()->getDependentSliceEnabledFlag() && bDependentSlice )740 return;741 #endif742 743 if (!bDependentSlice)744 {745 #endif746 797 if( pcSlice->getPPS()->getOutputFlagPresentFlag() ) 747 798 { … … 754 805 // colour_plane_id u(2) 755 806 756 #if !SPLICING_FRIENDLY_PARAMS757 if( pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR758 #if SUPPORT_FOR_RAP_N_LP759 || pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_IDR_N_LP760 || pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP761 #endif762 || pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLANT763 || pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA764 #if !NAL_UNIT_TYPES_J1003_D7765 || pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRANT766 #endif767 || pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_CRA )768 {769 WRITE_UVLC( 0, "rap_pic_id" );770 WRITE_FLAG( 0, "no_output_of_prior_pics_flag" );771 }772 #endif773 #if SUPPORT_FOR_RAP_N_LP774 807 if( !pcSlice->getIdrPicFlag() ) 775 #else776 if( pcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_IDR )777 #endif778 808 { 779 809 Int picOrderCntLSB = (pcSlice->getPOC()-pcSlice->getLastIDR()+(1<<pcSlice->getSPS()->getBitsForPOC()))%(1<<pcSlice->getSPS()->getBitsForPOC()); … … 783 813 { 784 814 WRITE_FLAG( 0, "short_term_ref_pic_set_sps_flag"); 785 #if J0234_INTER_RPS_SIMPL 786 codeShortTermRefPicSet(pcSlice->getSPS(), rps, true); 787 #else 788 codeShortTermRefPicSet(pcSlice->getSPS(), rps); 789 #endif 815 codeShortTermRefPicSet(pcSlice->getSPS(), rps, true, pcSlice->getSPS()->getRPSList()->getNumberOfReferencePictureSets()); 790 816 } 791 817 else 792 818 { 793 819 WRITE_FLAG( 1, "short_term_ref_pic_set_sps_flag"); 794 WRITE_UVLC( pcSlice->getRPSidx(), "short_term_ref_pic_set_idx" ); 820 Int numBits = 0; 821 while ((1 << numBits) < pcSlice->getSPS()->getRPSList()->getNumberOfReferencePictureSets()) 822 { 823 numBits++; 824 } 825 if (numBits > 0) 826 { 827 WRITE_CODE( pcSlice->getRPSidx(), numBits, "short_term_ref_pic_set_idx" ); 828 } 795 829 } 796 830 if(pcSlice->getSPS()->getLongTermRefsPresent()) 797 831 { 798 #if LTRP_IN_SPS799 832 Int numLtrpInSH = rps->getNumberOfLongtermPictures(); 800 833 Int ltrpInSPS[MAX_NUM_REF_PICS]; … … 816 849 numLtrpInSH -= numLtrpInSPS; 817 850 818 Int bitsForLtrpInSPS = 1;851 Int bitsForLtrpInSPS = 0; 819 852 while (pcSlice->getSPS()->getNumLongTermRefPicSPS() > (1 << bitsForLtrpInSPS)) 820 853 { … … 826 859 } 827 860 WRITE_UVLC( numLtrpInSH, "num_long_term_pics"); 828 #else829 WRITE_UVLC( rps->getNumberOfLongtermPictures(), "num_long_term_pics");830 #endif831 861 // Note that the LSBs of the LT ref. pic. POCs must be sorted before. 832 862 // Not sorted here because LT ref indices will be used in setRefPicList() … … 835 865 for(Int i=rps->getNumberOfPictures()-1 ; i > offset-1; i--) 836 866 { 837 #if LTRP_IN_SPS838 867 if (counter < numLtrpInSPS) 839 868 { 840 WRITE_CODE( ltrpInSPS[counter], bitsForLtrpInSPS, "lt_idx_sps[i]"); 869 if (bitsForLtrpInSPS > 0) 870 { 871 WRITE_CODE( ltrpInSPS[counter], bitsForLtrpInSPS, "lt_idx_sps[i]"); 872 } 841 873 } 842 874 else … … 845 877 WRITE_FLAG( rps->getUsed(i), "used_by_curr_pic_lt_flag"); 846 878 } 847 #else848 WRITE_CODE( rps->getPocLSBLT(i), pcSlice->getSPS()->getBitsForPOC(), "poc_lsb_lt");849 #endif850 879 WRITE_FLAG( rps->getDeltaPocMSBPresentFlag(i), "delta_poc_msb_present_flag"); 851 880 … … 853 882 { 854 883 Bool deltaFlag = false; 855 #if LTRP_IN_SPS856 884 // First LTRP from SPS || First LTRP from SH || curr LSB != prev LSB 857 885 if( (i == rps->getNumberOfPictures()-1) || (i == rps->getNumberOfPictures()-1-numLtrpInSPS) || (rps->getPocLSBLT(i) != prevLSB) ) 858 #else859 // First LTRP || curr LSB != prev LSB860 if( (i == rps->getNumberOfPictures()-1) || (rps->getPocLSBLT(i) != prevLSB) )861 #endif862 886 { 863 887 deltaFlag = true; … … 876 900 prevDeltaMSB = rps->getDeltaPocMSBCycleLT(i); 877 901 } 878 #if !LTRP_IN_SPS 879 WRITE_FLAG( rps->getUsed(i), "used_by_curr_pic_lt_flag");880 #endif 881 }882 }883 }884 #if REMOVE_ALF 902 } 903 } 904 if (pcSlice->getSPS()->getTMVPFlagsPresent()) 905 { 906 WRITE_FLAG( pcSlice->getEnableTMVPFlag() ? 1 : 0, "slice_temporal_mvp_enable_flag" ); 907 } 908 } 885 909 if(pcSlice->getSPS()->getUseSAO()) 886 #else887 if(pcSlice->getSPS()->getUseSAO() || pcSlice->getSPS()->getUseALF())888 #endif889 910 { 890 911 if (pcSlice->getSPS()->getUseSAO()) 891 912 { 892 913 WRITE_FLAG( pcSlice->getSaoEnabledFlag(), "slice_sao_luma_flag" ); 893 #if !SAO_LUM_CHROMA_ONOFF_FLAGS894 if (pcSlice->getSaoEnabledFlag() )895 #endif896 914 { 897 #if REMOVE_APS898 915 SAOParam *saoParam = pcSlice->getPic()->getPicSym()->getSaoParam(); 899 #else900 SAOParam *saoParam = pcSlice->getAPS()->getSaoParam();901 #endif902 #if SAO_TYPE_SHARING903 916 WRITE_FLAG( saoParam->bSaoFlag[1], "slice_sao_chroma_flag" ); 904 #else905 WRITE_FLAG( saoParam->bSaoFlag[1], "SAO on/off flag for Cb in slice header" );906 WRITE_FLAG( saoParam->bSaoFlag[2], "SAO on/off flag for Cr in slice header" );907 #endif908 917 } 909 918 } 910 #if !REMOVE_APS911 WRITE_UVLC( pcSlice->getAPS()->getAPSID(), "aps_id");912 #endif913 919 } 914 920 915 921 //check if numrefidxes match the defaults. If not, override 922 916 923 if (!pcSlice->isIntra()) 917 924 { 918 if (pcSlice->getSPS()->getTMVPFlagsPresent())919 {920 WRITE_FLAG( pcSlice->getEnableTMVPFlag(), "enable_temporal_mvp_flag" );921 }922 925 Bool overrideFlag = (pcSlice->getNumRefIdx( REF_PIC_LIST_0 )!=pcSlice->getPPS()->getNumRefIdxL0DefaultActive()||(pcSlice->isInterB()&&pcSlice->getNumRefIdx( REF_PIC_LIST_1 )!=pcSlice->getPPS()->getNumRefIdxL1DefaultActive())); 923 926 WRITE_FLAG( overrideFlag ? 1 : 0, "num_ref_idx_active_override_flag"); … … 940 943 pcSlice->setNumRefIdx(REF_PIC_LIST_1, 0); 941 944 } 942 if( pcSlice->getSPS()->getListsModificationPresentFlag() ) 945 946 if( pcSlice->getPPS()->getListsModificationPresentFlag() && pcSlice->getNumRpsCurrTempList() > 1) 943 947 { 944 948 TComRefPicListModification* refPicListModification = pcSlice->getRefPicListModification(); … … 986 990 } 987 991 } 988 #if !SLICEHEADER_SYNTAX_FIX989 }990 #endif991 992 992 993 if (pcSlice->isInterB()) … … 1007 1008 } 1008 1009 1009 #if !SLICEHEADER_SYNTAX_FIX1010 // if( !lightweight_slice_flag ) {1011 if (!bDependentSlice)1012 {1013 #else1014 1010 if ( pcSlice->getEnableTMVPFlag() ) 1015 1011 { … … 1031 1027 } 1032 1028 assert(pcSlice->getMaxNumMergeCand()<=MRG_MAX_NUM_CANDS); 1033 WRITE_UVLC(MRG_MAX_NUM_CANDS - pcSlice->getMaxNumMergeCand(), "five_minus_max_num_merge_cand"); 1034 #endif 1029 if (!pcSlice->isIntra()) 1030 { 1031 WRITE_UVLC(MRG_MAX_NUM_CANDS - pcSlice->getMaxNumMergeCand(), "five_minus_max_num_merge_cand"); 1032 } 1035 1033 Int iCode = pcSlice->getSliceQp() - ( pcSlice->getPPS()->getPicInitQPMinus26() + 26 ); 1036 1034 WRITE_SVLC( iCode, "slice_qp_delta" ); 1037 #if CHROMA_QP_EXTENSION1038 1035 if (pcSlice->getPPS()->getSliceChromaQpFlag()) 1039 1036 { … … 1043 1040 WRITE_SVLC( iCode, "slice_qp_delta_cr" ); 1044 1041 } 1045 #endif1046 1042 if (pcSlice->getPPS()->getDeblockingFilterControlPresentFlag()) 1047 1043 { … … 1055 1051 if(!pcSlice->getDeblockingFilterDisable()) 1056 1052 { 1057 WRITE_SVLC (pcSlice->getDeblockingFilterBetaOffsetDiv2(), "beta_offset_div2"); 1058 WRITE_SVLC (pcSlice->getDeblockingFilterTcOffsetDiv2(), "tc_offset_div2"); 1059 } 1060 } 1061 } 1062 #if !SLICEHEADER_SYNTAX_FIX 1063 if ( pcSlice->getEnableTMVPFlag() ) 1064 { 1065 if ( pcSlice->getSliceType() == B_SLICE ) 1066 { 1067 WRITE_FLAG( pcSlice->getColFromL0Flag(), "collocated_from_l0_flag" ); 1068 } 1069 1070 if ( pcSlice->getSliceType() != I_SLICE && 1071 ((pcSlice->getColFromL0Flag()==1 && pcSlice->getNumRefIdx(REF_PIC_LIST_0)>1)|| 1072 (pcSlice->getColFromL0Flag()==0 && pcSlice->getNumRefIdx(REF_PIC_LIST_1)>1))) 1073 { 1074 WRITE_UVLC( pcSlice->getColRefIdx(), "collocated_ref_idx" ); 1075 } 1076 } 1077 if ( (pcSlice->getPPS()->getUseWP() && pcSlice->getSliceType()==P_SLICE) || (pcSlice->getPPS()->getWPBiPred() && pcSlice->getSliceType()==B_SLICE) ) 1078 { 1079 xCodePredWeightTable( pcSlice ); 1080 } 1081 } 1082 assert(pcSlice->getMaxNumMergeCand()<=MRG_MAX_NUM_CANDS); 1083 WRITE_UVLC(MRG_MAX_NUM_CANDS - pcSlice->getMaxNumMergeCand(), "five_minus_max_num_merge_cand"); 1084 #endif 1085 1086 #if !REMOVE_ALF 1087 if (!bDependentSlice) 1088 { 1089 if (pcSlice->getSPS()->getUseALF()) 1090 { 1091 char syntaxString[50]; 1092 for(Int compIdx=0; compIdx< 3; compIdx++) 1093 { 1094 sprintf(syntaxString, "alf_slice_filter_flag[%d]", compIdx); 1095 WRITE_FLAG( pcSlice->getAlfEnabledFlag(compIdx)?1:0, syntaxString ); 1096 } 1097 } 1098 } 1099 #endif 1100 #if !SLICEHEADER_SYNTAX_FIX 1101 if(!bDependentSlice) 1102 { 1103 #endif 1104 #if !REMOVE_ALF 1105 Bool isAlfEnabled = (!pcSlice->getSPS()->getUseALF())?(false):(pcSlice->getAlfEnabledFlag(0)||pcSlice->getAlfEnabledFlag(1)||pcSlice->getAlfEnabledFlag(2)); 1106 #endif 1107 #if !SAO_LUM_CHROMA_ONOFF_FLAGS 1108 Bool isSAOEnabled = (!pcSlice->getSPS()->getUseSAO())?(false):(pcSlice->getSaoEnabledFlag()); 1109 #else 1053 WRITE_SVLC (pcSlice->getDeblockingFilterBetaOffsetDiv2(), "slice_beta_offset_div2"); 1054 WRITE_SVLC (pcSlice->getDeblockingFilterTcOffsetDiv2(), "slice_tc_offset_div2"); 1055 } 1056 } 1057 } 1058 1110 1059 Bool isSAOEnabled = (!pcSlice->getSPS()->getUseSAO())?(false):(pcSlice->getSaoEnabledFlag()||pcSlice->getSaoEnabledFlagChroma()); 1111 #endif1112 1060 Bool isDBFEnabled = (!pcSlice->getDeblockingFilterDisable()); 1113 1061 1114 #if REMOVE_ALF1115 #if MOVE_LOOP_FILTER_SLICES_FLAG1116 1062 if(pcSlice->getPPS()->getLoopFilterAcrossSlicesEnabledFlag() && ( isSAOEnabled || isDBFEnabled )) 1117 #else1118 if(pcSlice->getSPS()->getLFCrossSliceBoundaryFlag() && ( isSAOEnabled || isDBFEnabled ))1119 #endif1120 #else1121 if(pcSlice->getSPS()->getLFCrossSliceBoundaryFlag() && ( isAlfEnabled || isSAOEnabled || isDBFEnabled ))1122 #endif1123 1063 { 1124 1064 WRITE_FLAG(pcSlice->getLFCrossSliceBoundaryFlag()?1:0, "slice_loop_filter_across_slices_enabled_flag"); 1125 1065 } 1126 1066 } 1127 #if SLICE_HEADER_EXTENSION1128 1067 if(pcSlice->getPPS()->getSliceHeaderExtensionPresentFlag()) 1129 1068 { 1130 1069 WRITE_UVLC(0,"slice_header_extension_length"); 1131 1070 } 1132 #endif 1133 } 1134 1135 #if PROFILE_TIER_LEVEL_SYNTAX 1071 } 1072 1136 1073 Void TEncCavlc::codePTL( TComPTL* pcPTL, Bool profilePresentFlag, Int maxNumSubLayersMinus1) 1137 1074 { … … 1142 1079 WRITE_CODE( pcPTL->getGeneralPTL()->getLevelIdc(), 8, "general_level_idc" ); 1143 1080 1081 #if L0363_BYTE_ALIGN 1082 for (Int i = 0; i < maxNumSubLayersMinus1; i++) 1083 { 1084 if(profilePresentFlag) 1085 { 1086 WRITE_FLAG( pcPTL->getSubLayerProfilePresentFlag(i), "sub_layer_profile_present_flag[i]" ); 1087 } 1088 1089 WRITE_FLAG( pcPTL->getSubLayerLevelPresentFlag(i), "sub_layer_level_present_flag[i]" ); 1090 } 1091 1092 if (maxNumSubLayersMinus1 > 0) 1093 { 1094 for (Int i = maxNumSubLayersMinus1; i < 8; i++) 1095 { 1096 WRITE_CODE(0, 2, "reserved_zero_2bits"); 1097 } 1098 } 1099 #endif 1100 1144 1101 for(Int i = 0; i < maxNumSubLayersMinus1; i++) 1145 1102 { 1146 WRITE_FLAG( pcPTL->getSubLayerProfilePresentFlag(i), "sub_layer_profile_present_flag[i]" ); 1103 #if !L0363_BYTE_ALIGN 1104 if(profilePresentFlag) 1105 { 1106 WRITE_FLAG( pcPTL->getSubLayerProfilePresentFlag(i), "sub_layer_profile_present_flag[i]" ); 1107 } 1108 1147 1109 WRITE_FLAG( pcPTL->getSubLayerLevelPresentFlag(i), "sub_layer_level_present_flag[i]" ); 1110 #endif 1148 1111 if( profilePresentFlag && pcPTL->getSubLayerProfilePresentFlag(i) ) 1149 1112 { … … 1165 1128 WRITE_FLAG( ptl->getProfileCompatibilityFlag(j), "XXX_profile_compatibility_flag[][j]"); 1166 1129 } 1167 WRITE_CODE(0 , 16, "XXX_reserved_zero_16bits[]"); 1168 } 1169 #endif 1170 1130 1131 #if L0046_CONSTRAINT_FLAGS 1132 WRITE_FLAG(ptl->getProgressiveSourceFlag(), "general_progressive_source_flag"); 1133 WRITE_FLAG(ptl->getInterlacedSourceFlag(), "general_interlaced_source_flag"); 1134 WRITE_FLAG(ptl->getNonPackedConstraintFlag(), "general_non_packed_constraint_flag"); 1135 WRITE_FLAG(ptl->getFrameOnlyConstraintFlag(), "general_frame_only_constraint_flag"); 1136 1137 WRITE_CODE(0 , 16, "XXX_reserved_zero_44bits[0..15]"); 1138 WRITE_CODE(0 , 16, "XXX_reserved_zero_44bits[16..31]"); 1139 WRITE_CODE(0 , 12, "XXX_reserved_zero_44bits[32..43]"); 1140 #elif L0363_MORE_BITS 1141 WRITE_CODE(0 , 16, "XXX_reserved_zero_48bits[0..15]"); 1142 WRITE_CODE(0 , 16, "XXX_reserved_zero_48bits[16..31]"); 1143 WRITE_CODE(0 , 16, "XXX_reserved_zero_48bits[32..47]"); 1144 #else 1145 WRITE_CODE(0 , 16, "XXX_reserved_zero_16bits[]"); 1146 #endif 1147 } 1148 #if SIGNAL_BITRATE_PICRATE_IN_VPS 1149 Void TEncCavlc::codeBitratePicRateInfo(TComBitRatePicRateInfo *info, Int tempLevelLow, Int tempLevelHigh) 1150 { 1151 for(Int i = tempLevelLow; i <= tempLevelHigh; i++) 1152 { 1153 WRITE_FLAG( info->getBitRateInfoPresentFlag(i), "bit_rate_info_present_flag[i]" ); 1154 WRITE_FLAG( info->getPicRateInfoPresentFlag(i), "pic_rate_info_present_flag[i]" ); 1155 if(info->getBitRateInfoPresentFlag(i)) 1156 { 1157 WRITE_CODE( info->getAvgBitRate(i), 16, "avg_bit_rate[i]" ); 1158 WRITE_CODE( info->getMaxBitRate(i), 16, "max_bit_rate[i]" ); 1159 } 1160 if(info->getPicRateInfoPresentFlag(i)) 1161 { 1162 WRITE_CODE( info->getConstantPicRateIdc(i), 2, "constant_pic_rate_idc[i]" ); 1163 WRITE_CODE( info->getAvgPicRate(i), 16, "avg_pic_rate[i]" ); 1164 } 1165 } 1166 } 1167 #endif 1171 1168 /** 1172 1169 - write wavefront substreams sizes for the slice header. … … 1176 1173 Void TEncCavlc::codeTilesWPPEntryPoint( TComSlice* pSlice ) 1177 1174 { 1178 #if TILES_WPP_ENTROPYSLICES_FLAGS1179 1175 if (!pSlice->getPPS()->getTilesEnabledFlag() && !pSlice->getPPS()->getEntropyCodingSyncEnabledFlag()) 1180 #else1181 Int tilesOrEntropyCodingSyncIdc = pSlice->getPPS()->getTilesOrEntropyCodingSyncIdc();1182 if ( tilesOrEntropyCodingSyncIdc == 0 )1183 #endif1184 1176 { 1185 1177 return; … … 1188 1180 Int numZeroSubstreamsAtStartOfSlice = 0; 1189 1181 UInt *entryPointOffset = NULL; 1190 #if TILES_WPP_ENTROPYSLICES_FLAGS1191 1182 if ( pSlice->getPPS()->getTilesEnabledFlag() ) 1192 #else1193 if (tilesOrEntropyCodingSyncIdc == 1) // tiles1194 #endif1195 1183 { 1196 1184 numEntryPointOffsets = pSlice->getTileLocationCount(); … … 1213 1201 } 1214 1202 } 1215 #if TILES_WPP_ENTROPYSLICES_FLAGS1216 1203 else if ( pSlice->getPPS()->getEntropyCodingSyncEnabledFlag() ) 1217 #else1218 else if (tilesOrEntropyCodingSyncIdc == 2) // wavefront1219 #endif1220 1204 { 1221 1205 UInt* pSubstreamSizes = pSlice->getSubstreamSizes(); 1222 1206 Int maxNumParts = pSlice->getPic()->getNumPartInCU(); 1223 #if DEPENDENT_SLICES 1224 numZeroSubstreamsAtStartOfSlice = pSlice->getDependentSliceCurStartCUAddr()/maxNumParts/pSlice->getPic()->getFrameWidthInCU(); 1225 Int numZeroSubstreamsAtEndOfSlice = pSlice->getPic()->getFrameHeightInCU()-1 - ((pSlice->getDependentSliceCurEndCUAddr()-1)/maxNumParts/pSlice->getPic()->getFrameWidthInCU()); 1226 #else 1227 numZeroSubstreamsAtStartOfSlice = pSlice->getSliceCurStartCUAddr()/maxNumParts/pSlice->getPic()->getFrameWidthInCU(); 1228 Int numZeroSubstreamsAtEndOfSlice = pSlice->getPic()->getFrameHeightInCU()-1 - ((pSlice->getSliceCurEndCUAddr()-1)/maxNumParts/pSlice->getPic()->getFrameWidthInCU()); 1229 #endif 1207 numZeroSubstreamsAtStartOfSlice = pSlice->getSliceSegmentCurStartCUAddr()/maxNumParts/pSlice->getPic()->getFrameWidthInCU(); 1208 Int numZeroSubstreamsAtEndOfSlice = pSlice->getPic()->getFrameHeightInCU()-1 - ((pSlice->getSliceSegmentCurEndCUAddr()-1)/maxNumParts/pSlice->getPic()->getFrameWidthInCU()); 1230 1209 numEntryPointOffsets = pSlice->getPPS()->getNumSubstreams() - numZeroSubstreamsAtStartOfSlice - numZeroSubstreamsAtEndOfSlice - 1; 1231 1210 pSlice->setNumEntryPointOffsets(numEntryPointOffsets); … … 1256 1235 for (UInt idx=0; idx<numEntryPointOffsets; idx++) 1257 1236 { 1237 #if L0116_ENTRY_POINT 1238 WRITE_CODE(entryPointOffset[ idx ]-1, offsetLenMinus1+1, "entry_point_offset_minus1"); 1239 #else 1258 1240 WRITE_CODE(entryPointOffset[ idx ], offsetLenMinus1+1, "entry_point_offset"); 1241 #endif 1259 1242 } 1260 1243 … … 1295 1278 } 1296 1279 1297 Void TEncCavlc::codeApsExtensionFlag ()1298 {1299 WRITE_FLAG(0, "aps_extension_flag");1300 }1301 1302 1280 Void TEncCavlc::codeInterModeFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiEncMode ) 1303 1281 { … … 1315 1293 } 1316 1294 1317 #if INTRA_BL1318 Void TEncCavlc::codeIntraBLFlag( TComDataCU* pcCU, UInt uiAbsPartIdx )1319 {1320 assert(0);1321 }1322 1323 #endif1324 1295 Void TEncCavlc::codeSplitFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) 1325 1296 { … … 1342 1313 } 1343 1314 1344 #if TU_ZERO_CBF_RDO 1345 Void TEncCavlc::codeQtCbfZero( TComDataCU* pcCU, UInt uiAbsPartIdx, TextType eType, UInt uiTrDepth ) 1346 { 1347 assert(0); 1348 } 1349 Void TEncCavlc::codeQtRootCbfZero( TComDataCU* pcCU, UInt uiAbsPartIdx ) 1350 { 1351 assert(0); 1352 } 1353 #endif 1354 1355 Void TEncCavlc::codeTransformSkipFlags (TComDataCU* pcCU, UInt uiAbsPartIdx, UInt width, UInt height, UInt uiDepth, TextType eTType ) 1356 { 1357 assert(0); 1358 } 1359 1360 /** Code I_PCM information. 1315 Void TEncCavlc::codeQtCbfZero( TComDataCU* pcCU, TextType eType, UInt uiTrDepth ) 1316 { 1317 assert(0); 1318 } 1319 Void TEncCavlc::codeQtRootCbfZero( TComDataCU* pcCU ) 1320 { 1321 assert(0); 1322 } 1323 1324 Void TEncCavlc::codeTransformSkipFlags (TComDataCU* pcCU, UInt uiAbsPartIdx, UInt width, UInt height, TextType eTType ) 1325 { 1326 assert(0); 1327 } 1328 1329 /** Code I_PCM information. 1361 1330 * \param pcCU pointer to CU 1362 1331 * \param uiAbsPartIdx CU index 1363 * \param numIPCM the number of succesive IPCM blocks with the same size1364 * \param firstIPCMFlag1365 1332 * \returns Void 1366 1333 */ 1367 Void TEncCavlc::codeIPCMInfo( TComDataCU* pcCU, UInt uiAbsPartIdx , Int numIPCM, Bool firstIPCMFlag)1334 Void TEncCavlc::codeIPCMInfo( TComDataCU* pcCU, UInt uiAbsPartIdx ) 1368 1335 { 1369 1336 assert(0); … … 1411 1378 assert(0); 1412 1379 } 1413 1414 Void TEncCavlc::xGolombEncode(Int coeff, Int k)1415 {1416 xWriteEpExGolomb((UInt)abs(coeff), k);1417 if(coeff != 0)1418 {1419 Int sign = (coeff > 0)? 1: 0;1420 xWriteFlag(sign);1421 }1422 #if ENC_DEC_TRACE1423 fprintf( g_hTrace, "%8lld ", g_nSymbolCounter++ );1424 fprintf( g_hTrace, "%-40s se(v) : %d\n", "alf_filt_coeff", coeff );1425 #endif1426 1427 }1428 1429 #if !REMOVE_ALF1430 Void TEncCavlc::codeAlfParam(ALFParam* alfParam)1431 {1432 char syntaxString[50];1433 sprintf(syntaxString, "alf_aps_filter_flag[%d]", alfParam->componentID);1434 WRITE_FLAG(alfParam->alf_flag, syntaxString);1435 if(alfParam->alf_flag == 0)1436 {1437 return;1438 }1439 1440 const Int numCoeff = (Int)ALF_MAX_NUM_COEF;1441 switch(alfParam->componentID)1442 {1443 case ALF_Cb:1444 case ALF_Cr:1445 {1446 for(Int pos=0; pos< numCoeff; pos++)1447 {1448 WRITE_SVLC(alfParam->coeffmulti[0][pos], "alf_filt_coeff");1449 }1450 }1451 break;1452 case ALF_Y:1453 {1454 Int noFilters = min(alfParam->filters_per_group-1, 2);1455 WRITE_UVLC(noFilters, "alf_no_filters_minus1");1456 if(noFilters == 1)1457 {1458 WRITE_UVLC(alfParam->startSecondFilter, "alf_start_second_filter");1459 }1460 else if (noFilters == 2)1461 {1462 Int numMergeFlags = 16;1463 for (Int i=1; i<numMergeFlags; i++)1464 {1465 WRITE_FLAG(alfParam->filterPattern[i], "alf_filter_pattern");1466 }1467 }1468 for(Int f=0; f< alfParam->filters_per_group; f++)1469 {1470 for(Int pos=0; pos< numCoeff; pos++)1471 {1472 xGolombEncode(alfParam->coeffmulti[f][pos], kTableTabShapes[ALF_CROSS9x7_SQUARE3x3][pos]);1473 }1474 }1475 }1476 break;1477 default:1478 {1479 printf("Not a legal component ID\n");1480 assert(0);1481 exit(-1);1482 }1483 }1484 1485 }1486 #endif1487 1380 1488 1381 Void TEncCavlc::estBit( estBitsSbacStruct* pcEstBitsCabac, Int width, Int height, TextType eTType ) … … 1585 1478 Bool bDenomCoded = false; 1586 1479 UInt uiMode = 0; 1587 #if NUM_WP_LIMIT1588 1480 UInt uiTotalSignalledWeightFlags = 0; 1589 #endif1590 1481 if ( (pcSlice->getSliceType()==P_SLICE && pcSlice->getPPS()->getUseWP()) || (pcSlice->getSliceType()==B_SLICE && pcSlice->getPPS()->getWPBiPred()) ) 1591 1482 { … … 1615 1506 } 1616 1507 WRITE_FLAG( wp[0].bPresentFlag, "luma_weight_lX_flag" ); // u(1): luma_weight_lX_flag 1617 #if NUM_WP_LIMIT1618 1508 uiTotalSignalledWeightFlags += wp[0].bPresentFlag; 1619 1509 } … … 1631 1521 { 1632 1522 pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); 1633 #endif1634 1523 if ( wp[0].bPresentFlag ) 1635 1524 { … … 1641 1530 if ( bChroma ) 1642 1531 { 1643 #if !NUM_WP_LIMIT1644 WRITE_FLAG( wp[1].bPresentFlag, "chroma_weight_lX_flag" ); // u(1): chroma_weight_lX_flag1645 #endif1646 1532 if ( wp[1].bPresentFlag ) 1647 1533 { … … 1651 1537 WRITE_SVLC( iDeltaWeight, "delta_chroma_weight_lX" ); // se(v): delta_chroma_weight_lX 1652 1538 1653 Int shift = ((1<<(g_uiBitDepth+g_uiBitIncrement-1))); 1654 Int pred = ( shift - ( ( shift*wp[j].iWeight)>>(wp[j].uiLog2WeightDenom) ) ); 1539 Int pred = ( 128 - ( ( 128*wp[j].iWeight)>>(wp[j].uiLog2WeightDenom) ) ); 1655 1540 Int iDeltaChroma = (wp[j].iOffset - pred); 1656 1541 WRITE_SVLC( iDeltaChroma, "delta_chroma_offset_lX" ); // se(v): delta_chroma_offset_lX … … 1660 1545 } 1661 1546 } 1662 #if NUM_WP_LIMIT1663 1547 assert(uiTotalSignalledWeightFlags<=24); 1664 #endif1665 1548 } 1666 1549 } … … 1717 1600 { 1718 1601 Int coefNum = min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId]); 1719 #if REMOVE_ZIGZAG_SCAN1720 1602 UInt* scan = (sizeId == 0) ? g_auiSigLastScan [ SCAN_DIAG ] [ 1 ] : g_sigLastScanCG32x32; 1721 #else1722 UInt* scan = g_auiFrameScanXY [ (sizeId == 0)? 1 : 2];1723 #endif1724 1603 Int nextCoef = SCALING_LIST_START_VALUE; 1725 1604 Int data; … … 1746 1625 } 1747 1626 } 1748 #if LTRP_IN_SPS1749 1627 Bool TEncCavlc::findMatchingLTRP ( TComSlice* pcSlice, UInt *ltrpsIndex, Int ltrpPOC, Bool usedFlag ) 1750 1628 { 1751 // bool state = true, state2 = false;1629 // Bool state = true, state2 = false; 1752 1630 Int lsb = ltrpPOC % (1<<pcSlice->getSPS()->getBitsForPOC()); 1753 1631 for (Int k = 0; k < pcSlice->getSPS()->getNumLongTermRefPicSPS(); k++) … … 1761 1639 return false; 1762 1640 } 1763 #endif1764 1641 Bool TComScalingList::checkPredMode(UInt sizeId, UInt listId) 1765 1642 { … … 1776 1653 return true; 1777 1654 } 1655 1656 #if INTRA_BL 1657 Void TEncCavlc::codeIntraBLFlag( TComDataCU* pcCU, UInt uiAbsPartIdx ) 1658 { 1659 assert(0); 1660 } 1661 1662 #endif 1778 1663 //! \}
Note: See TracChangeset for help on using the changeset viewer.