Changeset 1313 in 3DVCSoftware for trunk/source/Lib/TLibEncoder/TEncCavlc.cpp
- Timestamp:
- 13 Aug 2015, 17:38:13 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/source/Lib/TLibEncoder/TEncCavlc.cpp
r1196 r1313 2 2 * License, included below. This software may be subject to other third party 3 3 * and contributor rights, including patent rights, and no such rights are 4 * granted under this license. 4 * granted under this license. 5 5 * 6 * Copyright (c) 2010-2015, ITU/ISO/IEC6 * Copyright (c) 2010-2015, ITU/ISO/IEC 7 7 * All rights reserved. 8 8 * … … 39 39 #include "TEncCavlc.h" 40 40 #include "SEIwrite.h" 41 #include "../TLibCommon/TypeDef.h" 42 #if H_3D41 42 #if NH_3D 43 43 #include "TEncTop.h" 44 44 #endif 45 45 46 //! \ingroup TLibEncoder 46 47 //! \{ 47 48 48 49 49 #if ENC_DEC_TRACE 50 50 51 Void xTraceSPSHeader (TComSPS *pSPS) 52 { 53 #if H_MV_ENC_DEC_TRAC 54 fprintf( g_hTrace, "=========== Sequence Parameter Set LayerId: %d ===========\n", pSPS->getLayerId() ); 55 #else 56 fprintf( g_hTrace, "=========== Sequence Parameter Set ID: %d ===========\n", pSPS->getSPSId() ); 57 #endif 58 } 59 60 Void xTracePPSHeader (TComPPS *pPPS) 61 { 62 #if H_MV_ENC_DEC_TRAC 63 fprintf( g_hTrace, "=========== Picture Parameter Set LayerId: %d ===========\n", pPPS->getLayerId() ); 64 #else 65 fprintf( g_hTrace, "=========== Picture Parameter Set ID: %d ===========\n", pPPS->getPPSId() ); 66 #endif 67 } 68 69 Void xTraceSliceHeader (TComSlice *pSlice) 51 #if !H_MV_ENC_DEC_TRAC 52 Void xTraceVPSHeader () 53 { 54 fprintf( g_hTrace, "=========== Video Parameter Set ===========\n" ); 55 56 Void xTraceSPSHeader () 57 { 58 fprintf( g_hTrace, "=========== Sequence Parameter Set ===========\n" ); 59 } 60 61 Void xTracePPSHeader () 62 { 63 fprintf( g_hTrace, "=========== Picture Parameter Set ===========\n"); 64 } 65 66 Void xTraceSliceHeader ( ) 70 67 { 71 68 fprintf( g_hTrace, "=========== Slice ===========\n"); 72 69 } 73 74 #endif 75 76 77 70 #endif 71 #endif 78 72 // ==================================================================================================================== 79 73 // Constructor / destructor / create / destroy … … 83 77 { 84 78 m_pcBitIf = NULL; 85 m_uiCoeffCost = 0;86 79 } 87 80 … … 95 88 // ==================================================================================================================== 96 89 97 Void TEncCavlc::resetEntropy() 98 { 99 } 100 101 102 Void TEncCavlc::codeDFFlag(UInt uiCode, const Char *pSymbolName) 103 { 104 WRITE_FLAG(uiCode, pSymbolName); 105 } 106 Void TEncCavlc::codeDFSvlc(Int iCode, const Char *pSymbolName) 107 { 108 WRITE_SVLC(iCode, pSymbolName); 109 } 110 111 Void TEncCavlc::codeShortTermRefPicSet( TComSPS* pcSPS, TComReferencePictureSet* rps, Bool calledFromSliceHeader, Int idx) 90 Void TEncCavlc::resetEntropy(const TComSlice* /*pSlice*/) 91 { 92 } 93 94 95 Void TEncCavlc::codeShortTermRefPicSet( const TComReferencePictureSet* rps, Bool calledFromSliceHeader, Int idx) 112 96 { 113 97 #if PRINT_RPS_INFO … … 132 116 { 133 117 Int refIdc = rps->getRefIdc(j); 134 WRITE_CODE( (refIdc==1? 1: 0), 1, "used_by_curr_pic_flag" ); //first bit is "1" if Idc is 1 135 if (refIdc != 1) 118 WRITE_CODE( (refIdc==1? 1: 0), 1, "used_by_curr_pic_flag" ); //first bit is "1" if Idc is 1 119 if (refIdc != 1) 136 120 { 137 121 WRITE_CODE( refIdc>>1, 1, "use_delta_flag" ); //second bit is "1" if Idc is 2, "0" otherwise. … … 143 127 WRITE_UVLC( rps->getNumberOfNegativePictures(), "num_negative_pics" ); 144 128 WRITE_UVLC( rps->getNumberOfPositivePictures(), "num_positive_pics" ); 145 146 129 Int prev = 0; 147 130 for(Int j=0 ; j < rps->getNumberOfNegativePictures(); j++) … … 149 132 WRITE_UVLC( prev-rps->getDeltaPOC(j)-1, "delta_poc_s0_minus1" ); 150 133 prev = rps->getDeltaPOC(j); 151 WRITE_FLAG( rps->getUsed(j), "used_by_curr_pic_s0_flag"); 134 WRITE_FLAG( rps->getUsed(j), "used_by_curr_pic_s0_flag"); 152 135 } 153 136 prev = 0; … … 156 139 WRITE_UVLC( rps->getDeltaPOC(j)-prev-1, "delta_poc_s1_minus1" ); 157 140 prev = rps->getDeltaPOC(j); 158 WRITE_FLAG( rps->getUsed(j), "used_by_curr_pic_s1_flag" ); 141 WRITE_FLAG( rps->getUsed(j), "used_by_curr_pic_s1_flag" ); 159 142 } 160 143 } … … 167 150 168 151 169 Void TEncCavlc::codePPS( TComPPS* pcPPS ) 170 { 171 #if ENC_DEC_TRACE 172 xTracePPSHeader (pcPPS); 173 #endif 174 152 Void TEncCavlc::codePPS( const TComPPS* pcPPS ) 153 { 154 #if ENC_DEC_TRACE 155 #if H_MV_ENC_DEC_TRAC 156 tracePSHeader( "PPS", pcPPS->getLayerId() ); 157 #else 158 xTracePPSHeader (); 159 #endif 160 #endif 175 161 WRITE_UVLC( pcPPS->getPPSId(), "pps_pic_parameter_set_id" ); 176 162 WRITE_UVLC( pcPPS->getSPSId(), "pps_seq_parameter_set_id" ); … … 196 182 WRITE_SVLC( pcPPS->getPicInitQPMinus26(), "init_qp_minus26"); 197 183 WRITE_FLAG( pcPPS->getConstrainedIntraPred() ? 1 : 0, "constrained_intra_pred_flag" ); 198 WRITE_FLAG( pcPPS->getUseTransformSkip() ? 1 : 0, "transform_skip_enabled_flag" ); 184 WRITE_FLAG( pcPPS->getUseTransformSkip() ? 1 : 0, "transform_skip_enabled_flag" ); 199 185 WRITE_FLAG( pcPPS->getUseDQP() ? 1 : 0, "cu_qp_delta_enabled_flag" ); 200 186 if ( pcPPS->getUseDQP() ) … … 202 188 WRITE_UVLC( pcPPS->getMaxCuDQPDepth(), "diff_cu_qp_delta_depth" ); 203 189 } 204 WRITE_SVLC( pcPPS->getChromaCbQpOffset(), "pps_cb_qp_offset" ); 205 WRITE_SVLC( pcPPS->getChromaCrQpOffset(), "pps_cr_qp_offset" ); 190 191 WRITE_SVLC( pcPPS->getQpOffset(COMPONENT_Cb), "pps_cb_qp_offset" ); 192 WRITE_SVLC( pcPPS->getQpOffset(COMPONENT_Cr), "pps_cr_qp_offset" ); 193 206 194 WRITE_FLAG( pcPPS->getSliceChromaQpFlag() ? 1 : 0, "pps_slice_chroma_qp_offsets_present_flag" ); 207 195 … … 214 202 { 215 203 WRITE_UVLC( pcPPS->getNumTileColumnsMinus1(), "num_tile_columns_minus1" ); 216 WRITE_UVLC( pcPPS->get TileNumRowsMinus1(), "num_tile_rows_minus1" );204 WRITE_UVLC( pcPPS->getNumTileRowsMinus1(), "num_tile_rows_minus1" ); 217 205 WRITE_FLAG( pcPPS->getTileUniformSpacingFlag(), "uniform_spacing_flag" ); 218 206 if( !pcPPS->getTileUniformSpacingFlag() ) … … 222 210 WRITE_UVLC( pcPPS->getTileColumnWidth(i)-1, "column_width_minus1" ); 223 211 } 224 for(UInt i=0; i<pcPPS->get TileNumRowsMinus1(); i++)212 for(UInt i=0; i<pcPPS->getNumTileRowsMinus1(); i++) 225 213 { 226 214 WRITE_UVLC( pcPPS->getTileRowHeight(i)-1, "row_height_minus1" ); 227 215 } 228 216 } 229 if(pcPPS->getNumTileColumnsMinus1() !=0 || pcPPS->get TileNumRowsMinus1() !=0)217 if(pcPPS->getNumTileColumnsMinus1() !=0 || pcPPS->getNumTileRowsMinus1() !=0) 230 218 { 231 219 WRITE_FLAG( pcPPS->getLoopFilterAcrossTilesEnabledFlag()?1 : 0, "loop_filter_across_tiles_enabled_flag"); 232 220 } 233 221 } 234 WRITE_FLAG( pcPPS->getLoopFilterAcrossSlicesEnabledFlag()?1 : 0, " loop_filter_across_slices_enabled_flag");222 WRITE_FLAG( pcPPS->getLoopFilterAcrossSlicesEnabledFlag()?1 : 0, "pps_loop_filter_across_slices_enabled_flag"); 235 223 WRITE_FLAG( pcPPS->getDeblockingFilterControlPresentFlag()?1 : 0, "deblocking_filter_control_present_flag"); 236 224 if(pcPPS->getDeblockingFilterControlPresentFlag()) 237 225 { 238 WRITE_FLAG( pcPPS->getDeblockingFilterOverrideEnabledFlag() ? 1 : 0, "deblocking_filter_override_enabled_flag" ); 226 WRITE_FLAG( pcPPS->getDeblockingFilterOverrideEnabledFlag() ? 1 : 0, "deblocking_filter_override_enabled_flag" ); 239 227 WRITE_FLAG( pcPPS->getPicDisableDeblockingFilterFlag() ? 1 : 0, "pps_disable_deblocking_filter_flag" ); 240 228 if(!pcPPS->getPicDisableDeblockingFilterFlag()) … … 244 232 } 245 233 } 246 WRITE_FLAG( pcPPS->getScalingListPresentFlag() ? 1 : 0, "pps_scaling_list_data_present_flag" ); 234 WRITE_FLAG( pcPPS->getScalingListPresentFlag() ? 1 : 0, "pps_scaling_list_data_present_flag" ); 247 235 if( pcPPS->getScalingListPresentFlag() ) 248 236 { 249 codeScalingList( m_pcSlice->getScalingList() );237 codeScalingList( pcPPS->getScalingList() ); 250 238 } 251 239 #if PPS_FIX_DEPTH … … 259 247 WRITE_UVLC( pcPPS->getLog2ParallelMergeLevelMinus2(), "log2_parallel_merge_level_minus2"); 260 248 WRITE_FLAG( pcPPS->getSliceHeaderExtensionPresentFlag() ? 1 : 0, "slice_segment_header_extension_present_flag"); 261 262 #if H_3D 263 if(( !pcPPS->getSPS()->getVPS()->getDepthId( pcPPS->getSPS()->getLayerId() ) )|| 264 pcPPS->getLayerId() != 1 ) 265 { 266 pcPPS->setPps3dExtensionFlag( false ); 267 } 268 #endif 269 270 #if !H_MV 271 WRITE_FLAG( 0, "pps_extension_flag" ); 249 #if !NH_MV 250 Bool pps_extension_present_flag=false; 251 Bool pps_extension_flags[NUM_PPS_EXTENSION_FLAGS]={false}; 252 253 pps_extension_flags[PPS_EXT__REXT] = pcPPS->getPpsRangeExtension().settingsDifferFromDefaults(pcPPS->getUseTransformSkip()); 254 255 // Other PPS extension flags checked here. 256 257 for(Int i=0; i<NUM_PPS_EXTENSION_FLAGS; i++) 258 { 259 pps_extension_present_flag|=pps_extension_flags[i]; 260 } 261 262 WRITE_FLAG( (pps_extension_present_flag?1:0), "pps_extension_present_flag" ); 263 264 if (pps_extension_present_flag) 265 { 266 #if ENC_DEC_TRACE || RExt__DECODER_DEBUG_BIT_STATISTICS 267 static const char *syntaxStrings[]={ "pps_range_extension_flag", 268 "pps_multilayer_extension_flag", 269 "pps_extension_6bits[0]", 270 "pps_extension_6bits[1]", 271 "pps_extension_6bits[2]", 272 "pps_extension_6bits[3]", 273 "pps_extension_6bits[4]", 274 "pps_extension_6bits[5]" }; 275 #endif 276 277 for(Int i=0; i<NUM_PPS_EXTENSION_FLAGS; i++) 278 { 279 WRITE_FLAG( pps_extension_flags[i]?1:0, syntaxStrings[i] ); 280 } 281 282 for(Int i=0; i<NUM_PPS_EXTENSION_FLAGS; i++) // loop used so that the order is determined by the enum. 283 { 284 if (pps_extension_flags[i]) 285 { 286 switch (PPSExtensionFlagIndex(i)) 287 { 288 case PPS_EXT__REXT: 289 { 290 const TComPPSRExt &ppsRangeExtension = pcPPS->getPpsRangeExtension(); 291 if (pcPPS->getUseTransformSkip()) 292 { 293 WRITE_UVLC( ppsRangeExtension.getLog2MaxTransformSkipBlockSize()-2, "log2_max_transform_skip_block_size_minus2"); 294 } 295 296 WRITE_FLAG((ppsRangeExtension.getCrossComponentPredictionEnabledFlag() ? 1 : 0), "cross_component_prediction_enabled_flag" ); 297 298 WRITE_FLAG(UInt(ppsRangeExtension.getChromaQpOffsetListEnabledFlag()), "chroma_qp_offset_list_enabled_flag" ); 299 if (ppsRangeExtension.getChromaQpOffsetListEnabledFlag()) 300 { 301 WRITE_UVLC(ppsRangeExtension.getDiffCuChromaQpOffsetDepth(), "diff_cu_chroma_qp_offset_depth"); 302 WRITE_UVLC(ppsRangeExtension.getChromaQpOffsetListLen() - 1, "chroma_qp_offset_list_len_minus1"); 303 /* skip zero index */ 304 for (Int cuChromaQpOffsetIdx = 0; cuChromaQpOffsetIdx < ppsRangeExtension.getChromaQpOffsetListLen(); cuChromaQpOffsetIdx++) 305 { 306 WRITE_SVLC(ppsRangeExtension.getChromaQpOffsetListEntry(cuChromaQpOffsetIdx+1).u.comp.CbOffset, "cb_qp_offset_list[i]"); 307 WRITE_SVLC(ppsRangeExtension.getChromaQpOffsetListEntry(cuChromaQpOffsetIdx+1).u.comp.CrOffset, "cr_qp_offset_list[i]"); 308 } 309 } 310 311 WRITE_UVLC( ppsRangeExtension.getLog2SaoOffsetScale(CHANNEL_TYPE_LUMA), "log2_sao_offset_scale_luma" ); 312 WRITE_UVLC( ppsRangeExtension.getLog2SaoOffsetScale(CHANNEL_TYPE_CHROMA), "log2_sao_offset_scale_chroma" ); 313 } 314 break; 315 default: 316 assert(pps_extension_flags[i]==false); // Should never get here with an active PPS extension flag. 317 break; 318 } // switch 319 } // if flag present 320 } // loop over PPS flags 321 } // pps_extension_present_flag is non-zero 272 322 #else 273 WRITE_FLAG( 1, "pps_extension_present_flag" );323 WRITE_FLAG( 1, "pps_extension_present_flag" ); 274 324 275 325 WRITE_FLAG( pcPPS->getPpsRangeExtensionsFlag( ) ? 1 : 0 , "pps_range_extensions_flag" ); 276 326 WRITE_FLAG( pcPPS->getPpsMultilayerExtensionFlag( ) ? 1 : 0 , "pps_multilayer_extension_flag" ); 277 #if !H_3D278 WRITE_CODE( pcPPS->getPpsExtension6bits( ), 6, "pps_extension_6bits" );279 #else280 327 WRITE_FLAG( pcPPS->getPps3dExtensionFlag( ) ? 1 : 0 , "pps_3d_extension_flag" ); 281 328 WRITE_CODE( pcPPS->getPpsExtension5bits( ), 5, "pps_extension_5bits" ); 282 #endif283 329 if ( pcPPS->getPpsRangeExtensionsFlag() ) 284 330 { 285 assert(0); 331 const TComPPSRExt &ppsRangeExtension = pcPPS->getPpsRangeExtension(); 332 if (pcPPS->getUseTransformSkip()) 333 { 334 WRITE_UVLC( ppsRangeExtension.getLog2MaxTransformSkipBlockSize()-2, "log2_max_transform_skip_block_size_minus2"); 335 } 336 337 WRITE_FLAG((ppsRangeExtension.getCrossComponentPredictionEnabledFlag() ? 1 : 0), "cross_component_prediction_enabled_flag" ); 338 339 WRITE_FLAG(UInt(ppsRangeExtension.getChromaQpOffsetListEnabledFlag()), "chroma_qp_offset_list_enabled_flag" ); 340 if (ppsRangeExtension.getChromaQpOffsetListEnabledFlag()) 341 { 342 WRITE_UVLC(ppsRangeExtension.getDiffCuChromaQpOffsetDepth(), "diff_cu_chroma_qp_offset_depth"); 343 WRITE_UVLC(ppsRangeExtension.getChromaQpOffsetListLen() - 1, "chroma_qp_offset_list_len_minus1"); 344 /* skip zero index */ 345 for (Int cuChromaQpOffsetIdx = 0; cuChromaQpOffsetIdx < ppsRangeExtension.getChromaQpOffsetListLen(); cuChromaQpOffsetIdx++) 346 { 347 WRITE_SVLC(ppsRangeExtension.getChromaQpOffsetListEntry(cuChromaQpOffsetIdx+1).u.comp.CbOffset, "cb_qp_offset_list[i]"); 348 WRITE_SVLC(ppsRangeExtension.getChromaQpOffsetListEntry(cuChromaQpOffsetIdx+1).u.comp.CrOffset, "cr_qp_offset_list[i]"); 349 } 350 } 351 352 WRITE_UVLC( ppsRangeExtension.getLog2SaoOffsetScale(CHANNEL_TYPE_LUMA), "log2_sao_offset_scale_luma" ); 353 WRITE_UVLC( ppsRangeExtension.getLog2SaoOffsetScale(CHANNEL_TYPE_CHROMA), "log2_sao_offset_scale_chroma" ); 286 354 } 287 355 288 356 if ( pcPPS->getPpsMultilayerExtensionFlag() ) 289 357 { 290 codeP PSMultilayerExtension( pcPPS );291 } 292 293 #if H_3D358 codePpsMultilayerExtension( pcPPS ); 359 } 360 361 #if NH_3D 294 362 if( pcPPS->getPps3dExtensionFlag( ) ) // This probably needs to be aligned with Rext and SHVC 295 363 { 296 codePPSExtension( pcPPS ); 297 } 298 #endif 299 #endif 300 301 } 302 303 #if H_3D 304 Void TEncCavlc::codePPSExtension ( TComPPS* pcPPS ) 305 { 306 // Assuming that all PPS indirectly refer to the same VPS via different SPS 307 // There is no parsing dependency in decoding DLT in PPS. 308 // The VPS information passed to decodePPS() is used to arrange the decoded DLT tables to their corresponding layers. 309 // This is equivalent to the process of 310 // Step 1) decoding DLT tables based on the number of depth layers, and 311 // Step 2) mapping DLT tables to the depth layers 312 // as described in the 3D-HEVC WD. 313 TComVPS* pcVPS = pcPPS->getSPS()->getVPS(); 314 315 TComDLT* pcDLT = pcPPS->getDLT(); 316 317 WRITE_FLAG( pcDLT->getDltPresentFlag() ? 1 : 0, "dlt_present_flag" ); 318 319 if ( pcDLT->getDltPresentFlag() ) 320 { 321 WRITE_CODE(pcDLT->getNumDepthViews(), 6, "pps_depth_layers_minus1"); 322 WRITE_CODE((pcDLT->getDepthViewBitDepth() - 8), 4, "pps_bit_depth_for_depth_views_minus8"); 323 324 for( Int i = 0; i <= pcVPS->getMaxLayersMinus1(); i++ ) 325 { 326 if ( i != 0 ) 327 { 328 if ( pcVPS->getDepthId( i ) == 1 ) 329 { 330 WRITE_FLAG( pcDLT->getUseDLTFlag( i ) ? 1 : 0, "dlt_flag[i]" ); 331 332 if ( pcDLT->getUseDLTFlag( i ) ) 364 codePps3dExtension( pcPPS ); 365 } 366 #endif 367 #endif 368 xWriteRbspTrailingBits(); 369 } 370 371 #if NH_3D 372 Void TEncCavlc::codePps3dExtension ( const TComPPS* pcPPS ) 373 { 374 #if NH_3D_DLT 375 WRITE_FLAG( pcPPS->getDLT()->getDltPresentFlag() ? 1 : 0, "dlts_present_flag" ); 376 377 if ( pcPPS->getDLT()->getDltPresentFlag() ) 378 { 379 WRITE_CODE(pcPPS->getDLT()->getNumDepthViews() - 1, 6, "pps_depth_layers_minus1"); 380 WRITE_CODE((pcPPS->getDLT()->getDepthViewBitDepth() - 8), 4, "pps_bit_depth_for_depth_layers_minus8"); 381 382 #if NH_3D_DLT_FIX 383 for( Int i = 0; i <= pcPPS->getDLT()->getNumDepthViews()-1; i++ ) 384 #else 385 for( Int i = 0; i <= pcPPS->getDLT()->getNumDepthViews(); i++ ) 386 #endif 387 { 388 Int layerId = pcPPS->getDLT()->getDepthIdxToLayerId(i); 389 390 WRITE_FLAG( pcPPS->getDLT()->getUseDLTFlag( layerId ) ? 1 : 0, "dlt_flag[i]" ); 391 392 if ( pcPPS->getDLT()->getUseDLTFlag( layerId ) ) 393 { 394 std::vector<Int> aiIdx2DepthValue_coded(256, 0); 395 UInt uiNumDepthValues_coded = pcPPS->getDLT()->getNumDepthValues(layerId); 396 397 // ----------------------------- Actual coding ----------------------------- 398 WRITE_FLAG( pcPPS->getDLT()->getInterViewDltPredEnableFlag( layerId ) ? 1 : 0, "dlt_pred_flag[i]"); 399 if ( pcPPS->getDLT()->getInterViewDltPredEnableFlag( layerId ) == false ) 400 { 401 WRITE_FLAG( pcPPS->getDLT()->getUseBitmapRep( layerId ) ? 1 : 0, "dlt_val_flags_present_flag[i]" ); 402 403 for( UInt ui = 0; ui<uiNumDepthValues_coded; ui++ ) 333 404 { 334 WRITE_FLAG( pcDLT->getInterViewDltPredEnableFlag( i ) ? 1 : 0, "inter_view_dlt_pred_enable_flag[ i ]");335 336 // ----------------------------- determine whether to use bit-map -----------------------------337 Bool bDltBitMapRepFlag = false;338 UInt uiNumBitsNonBitMap = 0;339 UInt uiNumBitsBitMap = 0;340 341 UInt uiMaxDiff = 0;342 UInt uiMinDiff = 0xffffffff;343 UInt uiLengthMinDiff = 0;344 UInt uiLengthDltDiffMinusMin = 0;345 346 UInt* puiDltDiffValues = NULL;347 348 Int aiIdx2DepthValue_coded[256];349 UInt uiNumDepthValues_coded= 0;350 351 uiNumDepthValues_coded = pcDLT->getNumDepthValues(i);352 for( UInt ui = 0; ui<uiNumDepthValues_coded; ui++)405 aiIdx2DepthValue_coded[ui] = pcPPS->getDLT()->idx2DepthValue(layerId, ui); 406 } 407 } 408 else 409 { 410 AOF( layerId > 1 ); 411 // assumes ref layer id to be 1 412 std::vector<Int> viRefDLT = pcPPS->getDLT()->idx2DepthValue( 1 ); 413 UInt uiRefNum = pcPPS->getDLT()->getNumDepthValues( 1 ); 414 pcPPS->getDLT()->getDeltaDLT(layerId, viRefDLT, uiRefNum, aiIdx2DepthValue_coded, uiNumDepthValues_coded); 415 } 416 417 // bit map coding 418 if ( pcPPS->getDLT()->getUseBitmapRep( layerId ) ) 419 { 420 UInt uiDltArrayIndex = 0; 421 for (UInt d=0; d < 256; d++) 422 { 423 if ( d == aiIdx2DepthValue_coded[uiDltArrayIndex] ) 353 424 { 354 aiIdx2DepthValue_coded[ui] = pcDLT->idx2DepthValue(i, ui); 355 } 356 357 if( pcDLT->getInterViewDltPredEnableFlag( i ) ) 358 { 359 AOF( pcVPS->getDepthId( 1 ) == 1 ); 360 AOF( i > 1 ); 361 // assumes ref layer id to be 1 362 Int* piRefDLT = pcDLT->idx2DepthValue( 1 ); 363 UInt uiRefNum = pcDLT->getNumDepthValues( 1 ); 364 pcDLT->getDeltaDLT(i, piRefDLT, uiRefNum, aiIdx2DepthValue_coded, &uiNumDepthValues_coded); 365 } 366 367 if ( NULL == (puiDltDiffValues = (UInt *)calloc(uiNumDepthValues_coded, sizeof(UInt))) ) 368 { 369 // This should be changed to an assertion. 370 exit(-1); 371 } 372 373 for (UInt d = 1; d < uiNumDepthValues_coded; d++) 374 { 375 puiDltDiffValues[d] = aiIdx2DepthValue_coded[d] - aiIdx2DepthValue_coded[d-1]; 376 377 if ( uiMaxDiff < puiDltDiffValues[d] ) 378 { 379 uiMaxDiff = puiDltDiffValues[d]; 380 } 381 382 if ( uiMinDiff > puiDltDiffValues[d] ) 383 { 384 uiMinDiff = puiDltDiffValues[d]; 385 } 386 } 387 388 // counting bits 389 // diff coding branch 390 uiNumBitsNonBitMap += 8; // u(v) bits for num_depth_values_in_dlt[layerId] (i.e. num_entry[ layerId ]) 391 392 if ( uiNumDepthValues_coded > 1 ) 393 { 394 uiNumBitsNonBitMap += 8; // u(v) bits for max_diff[ layerId ] 395 } 396 397 if ( uiNumDepthValues_coded > 2 ) 398 { 399 uiLengthMinDiff = (UInt) ceil(Log2(uiMaxDiff + 1)); 400 uiNumBitsNonBitMap += uiLengthMinDiff; // u(v) bits for min_diff[ layerId ] 401 } 402 403 uiNumBitsNonBitMap += 8; // u(v) bits for dlt_depth_value0[ layerId ] 404 405 if (uiMaxDiff > uiMinDiff) 406 { 407 uiLengthDltDiffMinusMin = (UInt) ceil(Log2(uiMaxDiff - uiMinDiff + 1)); 408 uiNumBitsNonBitMap += uiLengthDltDiffMinusMin * (uiNumDepthValues_coded - 1); // u(v) bits for dlt_depth_value_diff_minus_min[ layerId ][ j ] 409 } 410 411 // bit map branch 412 uiNumBitsBitMap = 256; // uiNumBitsBitMap = 1 << pcDLT->getDepthViewBitDepth(); 413 414 // determine bDltBitMapFlag 415 bDltBitMapRepFlag = (uiNumBitsBitMap > uiNumBitsNonBitMap) ? false : true; 416 417 // ----------------------------- Actual coding ----------------------------- 418 if ( pcDLT->getInterViewDltPredEnableFlag( i ) == false ) 419 { 420 WRITE_FLAG( bDltBitMapRepFlag ? 1 : 0, "dlt_bit_map_rep_flag[ layerId ]" ); 425 WRITE_FLAG(1, "dlt_value_flag[i][j]"); 426 uiDltArrayIndex++; 421 427 } 422 428 else 423 429 { 424 bDltBitMapRepFlag = false;430 WRITE_FLAG(0, "dlt_value_flag[i][j]"); 425 431 } 426 427 // bit map coding 428 if ( bDltBitMapRepFlag ) 432 } 433 } 434 // Diff Coding 435 else 436 { 437 UInt uiMaxDiff = 0; 438 UInt uiMinDiff = MAX_INT; 439 UInt uiLengthMinDiff = 0; 440 UInt uiLengthDltDiffMinusMin = 0; 441 442 std::vector<UInt> puiDltDiffValues(uiNumDepthValues_coded, 0); 443 444 for (UInt d = 1; d < uiNumDepthValues_coded; d++) 445 { 446 puiDltDiffValues[d] = aiIdx2DepthValue_coded[d] - aiIdx2DepthValue_coded[d-1]; 447 448 if ( uiMaxDiff < puiDltDiffValues[d] ) 429 449 { 430 UInt uiDltArrayIndex = 0; 431 for (UInt d=0; d < 256; d++) 450 uiMaxDiff = puiDltDiffValues[d]; 451 } 452 453 if ( uiMinDiff > puiDltDiffValues[d] ) 454 { 455 uiMinDiff = puiDltDiffValues[d]; 456 } 457 } 458 459 if ( uiNumDepthValues_coded > 2 ) 460 { 461 uiLengthMinDiff = (UInt) gCeilLog2(uiMaxDiff + 1); 462 } 463 if (uiMaxDiff > uiMinDiff) 464 { 465 uiLengthDltDiffMinusMin = (UInt) gCeilLog2(uiMaxDiff - uiMinDiff + 1); 466 } 467 468 WRITE_CODE(uiNumDepthValues_coded, 8, "num_val_delta_dlt"); // num_entry 469 { 470 // The condition if( uiNumDepthValues_coded > 0 ) is always true since for Single-view Diff Coding, there is at least one depth value in depth component. 471 if ( uiNumDepthValues_coded > 1 ) 472 { 473 WRITE_CODE(uiMaxDiff, 8, "max_diff"); // max_diff 474 } 475 476 if ( uiNumDepthValues_coded > 2 ) 477 { 478 WRITE_CODE((uiMinDiff - 1), uiLengthMinDiff, "min_diff_minus1"); // min_diff_minus1 479 } 480 481 WRITE_CODE(aiIdx2DepthValue_coded[0], 8, "delta_dlt_val0"); // entry0 482 483 if (uiMaxDiff > uiMinDiff) 484 { 485 for (UInt d=1; d < uiNumDepthValues_coded; d++) 432 486 { 433 if ( d == aiIdx2DepthValue_coded[uiDltArrayIndex] ) 434 { 435 WRITE_FLAG(1, "dlt_bit_map_flag[ layerId ][ j ]"); 436 uiDltArrayIndex++; 437 } 438 else 439 { 440 WRITE_FLAG(0, "dlt_bit_map_flag[ layerId ][ j ]"); 441 } 487 WRITE_CODE( (puiDltDiffValues[d] - uiMinDiff), uiLengthDltDiffMinusMin, "delta_val_diff_minus_min[k]"); // entry_value_diff_minus_min[ k ] 442 488 } 443 489 } 444 // Diff Coding445 else446 {447 WRITE_CODE(uiNumDepthValues_coded, 8, "num_depth_values_in_dlt[i]"); // num_entry448 {449 // The condition if( uiNumDepthValues_coded > 0 ) is always true since for Single-view Diff Coding, there is at least one depth value in depth component.450 if ( uiNumDepthValues_coded > 1 )451 {452 WRITE_CODE(uiMaxDiff, 8, "max_diff[ layerId ]"); // max_diff453 }454 455 if ( uiNumDepthValues_coded > 2 )456 {457 WRITE_CODE((uiMinDiff - 1), uiLengthMinDiff, "min_diff_minus1[ layerId ]"); // min_diff_minus1458 }459 460 WRITE_CODE(aiIdx2DepthValue_coded[0], 8, "dlt_depth_value0[layerId]"); // entry0461 462 if (uiMaxDiff > uiMinDiff)463 {464 for (UInt d=1; d < uiNumDepthValues_coded; d++)465 {466 WRITE_CODE( (puiDltDiffValues[d] - uiMinDiff), uiLengthDltDiffMinusMin, "dlt_depth_value_diff_minus_min[ layerId ][ j ]"); // entry_value_diff_minus_min[ k ]467 }468 }469 }470 }471 472 free(puiDltDiffValues);473 490 } 474 } 475 } 476 } 477 } 478 } 479 #endif 480 481 Void TEncCavlc::codeVUI( TComVUI *pcVUI, TComSPS* pcSPS ) 491 492 } 493 } 494 } 495 } 496 #endif 497 } 498 #endif 499 500 Void TEncCavlc::codeVUI( const TComVUI *pcVUI, const TComSPS* pcSPS ) 482 501 { 483 502 #if ENC_DEC_TRACE … … 500 519 } 501 520 WRITE_FLAG(pcVUI->getVideoSignalTypePresentFlag(), "video_signal_type_present_flag"); 502 #if H_MV521 #if NH_MV 503 522 assert( pcSPS->getLayerId() == 0 || !pcVUI->getVideoSignalTypePresentFlag() ); 504 523 #endif … … 512 531 WRITE_CODE(pcVUI->getColourPrimaries(), 8, "colour_primaries"); 513 532 WRITE_CODE(pcVUI->getTransferCharacteristics(), 8, "transfer_characteristics"); 514 WRITE_CODE(pcVUI->getMatrixCoefficients(), 8, "matrix_coeff icients");533 WRITE_CODE(pcVUI->getMatrixCoefficients(), 8, "matrix_coeffs"); 515 534 } 516 535 } … … 536 555 WRITE_UVLC(defaultDisplayWindow.getWindowBottomOffset()/ TComSPS::getWinUnitY(pcSPS->getChromaFormatIdc()), "def_disp_win_bottom_offset"); 537 556 } 538 TimingInfo *timingInfo = pcVUI->getTimingInfo();557 const TimingInfo *timingInfo = pcVUI->getTimingInfo(); 539 558 WRITE_FLAG(timingInfo->getTimingInfoPresentFlag(), "vui_timing_info_present_flag"); 540 559 if(timingInfo->getTimingInfoPresentFlag()) … … 547 566 WRITE_UVLC(timingInfo->getNumTicksPocDiffOneMinus1(), "vui_num_ticks_poc_diff_one_minus1"); 548 567 } 549 WRITE_FLAG(pcVUI->getHrdParametersPresentFlag(), "hrd_parameters_present_flag");550 if( pcVUI->getHrdParametersPresentFlag() )551 {552 codeHrdParameters(pcVUI->getHrdParameters(), 1, pcSPS->getMaxTLayers() - 1 );553 }568 WRITE_FLAG(pcVUI->getHrdParametersPresentFlag(), "vui_hrd_parameters_present_flag"); 569 if( pcVUI->getHrdParametersPresentFlag() ) 570 { 571 codeHrdParameters(pcVUI->getHrdParameters(), 1, pcSPS->getMaxTLayers() - 1 ); 572 } 554 573 } 555 574 … … 562 581 WRITE_UVLC(pcVUI->getMinSpatialSegmentationIdc(), "min_spatial_segmentation_idc"); 563 582 WRITE_UVLC(pcVUI->getMaxBytesPerPicDenom(), "max_bytes_per_pic_denom"); 564 WRITE_UVLC(pcVUI->getMaxBitsPerMinCuDenom(), "max_bits_per_min cu_denom");583 WRITE_UVLC(pcVUI->getMaxBitsPerMinCuDenom(), "max_bits_per_min_cu_denom"); 565 584 WRITE_UVLC(pcVUI->getLog2MaxMvLengthHorizontal(), "log2_max_mv_length_horizontal"); 566 585 WRITE_UVLC(pcVUI->getLog2MaxMvLengthVertical(), "log2_max_mv_length_vertical"); … … 568 587 } 569 588 570 Void TEncCavlc::codeHrdParameters( TComHRD *hrd, Bool commonInfPresentFlag, UInt maxNumSubLayersMinus1 )589 Void TEncCavlc::codeHrdParameters( const TComHRD *hrd, Bool commonInfPresentFlag, UInt maxNumSubLayersMinus1 ) 571 590 { 572 591 if( commonInfPresentFlag ) … … 576 595 if( hrd->getNalHrdParametersPresentFlag() || hrd->getVclHrdParametersPresentFlag() ) 577 596 { 578 WRITE_FLAG( hrd->getSubPicCpbParamsPresentFlag() ? 1 : 0, "sub_pic_ cpb_params_present_flag" );597 WRITE_FLAG( hrd->getSubPicCpbParamsPresentFlag() ? 1 : 0, "sub_pic_hrd_params_present_flag" ); 579 598 if( hrd->getSubPicCpbParamsPresentFlag() ) 580 599 { 581 600 WRITE_CODE( hrd->getTickDivisorMinus2(), 8, "tick_divisor_minus2" ); 582 WRITE_CODE( hrd->getDuCpbRemovalDelayLengthMinus1(), 5, "du_cpb_removal_delay_ length_minus1" );601 WRITE_CODE( hrd->getDuCpbRemovalDelayLengthMinus1(), 5, "du_cpb_removal_delay_increment_length_minus1" ); 583 602 WRITE_FLAG( hrd->getSubPicCpbParamsInPicTimingSEIFlag() ? 1 : 0, "sub_pic_cpb_params_in_pic_timing_sei_flag" ); 584 603 WRITE_CODE( hrd->getDpbOutputDelayDuLengthMinus1(), 5, "dpb_output_delay_du_length_minus1" ); … … 588 607 if( hrd->getSubPicCpbParamsPresentFlag() ) 589 608 { 590 WRITE_CODE( hrd->getDuCpbSizeScale(), 4, "du_cpb_size_scale" ); 609 WRITE_CODE( hrd->getDuCpbSizeScale(), 4, "du_cpb_size_scale" ); 591 610 } 592 611 WRITE_CODE( hrd->getInitialCpbRemovalDelayLengthMinus1(), 5, "initial_cpb_removal_delay_length_minus1" ); … … 599 618 { 600 619 WRITE_FLAG( hrd->getFixedPicRateFlag( i ) ? 1 : 0, "fixed_pic_rate_general_flag"); 620 Bool fixedPixRateWithinCvsFlag = true; 601 621 if( !hrd->getFixedPicRateFlag( i ) ) 602 622 { 623 fixedPixRateWithinCvsFlag = hrd->getFixedPicRateWithinCvsFlag( i ); 603 624 WRITE_FLAG( hrd->getFixedPicRateWithinCvsFlag( i ) ? 1 : 0, "fixed_pic_rate_within_cvs_flag"); 604 625 } 626 if( fixedPixRateWithinCvsFlag ) 627 { 628 WRITE_UVLC( hrd->getPicDurationInTcMinus1( i ), "elemental_duration_in_tc_minus1"); 629 } 605 630 else 606 631 { 607 hrd->setFixedPicRateWithinCvsFlag( i, true );608 }609 if( hrd->getFixedPicRateWithinCvsFlag( i ) )610 {611 WRITE_UVLC( hrd->getPicDurationInTcMinus1( i ), "elemental_duration_in_tc_minus1");612 }613 else614 {615 632 WRITE_FLAG( hrd->getLowDelayHrdFlag( i ) ? 1 : 0, "low_delay_hrd_flag"); 616 633 } … … 619 636 WRITE_UVLC( hrd->getCpbCntMinus1( i ), "cpb_cnt_minus1"); 620 637 } 621 638 622 639 for( nalOrVcl = 0; nalOrVcl < 2; nalOrVcl ++ ) 623 640 { … … 631 648 if( hrd->getSubPicCpbParamsPresentFlag() ) 632 649 { 633 WRITE_UVLC( hrd->getDuCpbSizeValueMinus1( i, j, nalOrVcl ), "cpb_size_du_value_minus1"); 650 WRITE_UVLC( hrd->getDuCpbSizeValueMinus1( i, j, nalOrVcl ), "cpb_size_du_value_minus1"); 634 651 WRITE_UVLC( hrd->getDuBitRateValueMinus1( i, j, nalOrVcl ), "bit_rate_du_value_minus1"); 635 652 } … … 641 658 } 642 659 643 Void TEncCavlc::codeSPS( TComSPS* pcSPS ) 644 { 645 #if ENC_DEC_TRACE 646 xTraceSPSHeader (pcSPS); 660 Void TEncCavlc::codeSPS( const TComSPS* pcSPS ) 661 { 662 663 const ChromaFormat format = pcSPS->getChromaFormatIdc(); 664 const Bool chromaEnabled = isChromaEnabled(format); 665 666 #if ENC_DEC_TRACE 667 #if H_MV_ENC_DEC_TRAC 668 tracePSHeader( "SPS", pcSPS->getLayerId() ); 669 #else 670 xTraceSPSHeader (); 671 #endif 647 672 #endif 648 673 WRITE_CODE( pcSPS->getVPSId (), 4, "sps_video_parameter_set_id" ); 649 #if H_MV674 #if NH_MV 650 675 if ( pcSPS->getLayerId() == 0 ) 651 676 { 652 677 #endif 653 678 WRITE_CODE( pcSPS->getMaxTLayers() - 1, 3, "sps_max_sub_layers_minus1" ); 654 #if H_MV679 #if NH_MV 655 680 } 656 681 else … … 661 686 { 662 687 #endif 663 664 WRITE_FLAG( pcSPS->getTemporalIdNestingFlag() ? 1 : 0, "sps_temporal_id_nesting_flag" ); 688 WRITE_FLAG( pcSPS->getTemporalIdNestingFlag() ? 1 : 0, "sps_temporal_id_nesting_flag" ); 665 689 codePTL(pcSPS->getPTL(), 1, pcSPS->getMaxTLayers() - 1); 666 #if H_MV690 #if NH_MV 667 691 } 668 692 #endif 669 693 WRITE_UVLC( pcSPS->getSPSId (), "sps_seq_parameter_set_id" ); 670 #if H_MV694 #if NH_MV 671 695 if ( pcSPS->getMultiLayerExtSpsFlag() ) 672 696 { … … 680 704 { 681 705 #endif 682 WRITE_UVLC( pcSPS->getChromaFormatIdc (), "chroma_format_idc" ); 683 #if !H_3D_DISABLE_CHROMA 684 assert(pcSPS->getChromaFormatIdc () == 1); 685 #endif 686 // in the first version chroma_format_idc can only be equal to 1 (4:2:0) 687 if( pcSPS->getChromaFormatIdc () == 3 ) 706 WRITE_UVLC( Int(pcSPS->getChromaFormatIdc ()), "chroma_format_idc" ); 707 if( format == CHROMA_444 ) 688 708 { 689 709 WRITE_FLAG( 0, "separate_colour_plane_flag"); … … 702 722 WRITE_UVLC( conf.getWindowBottomOffset() / TComSPS::getWinUnitY(pcSPS->getChromaFormatIdc() ), "conf_win_bottom_offset" ); 703 723 } 704 #if H_MV 705 } 706 #endif 707 708 #if H_MV 724 #if NH_MV 725 } 726 #endif 727 #if NH_MV 709 728 if ( !pcSPS->getMultiLayerExtSpsFlag() ) 710 729 { 711 730 #endif 712 WRITE_UVLC( pcSPS->getBitDepthY() - 8, "bit_depth_luma_minus8" ); 713 WRITE_UVLC( pcSPS->getBitDepthC() - 8, "bit_depth_chroma_minus8" ); 714 #if H_MV 731 732 WRITE_UVLC( pcSPS->getBitDepth(CHANNEL_TYPE_LUMA) - 8, "bit_depth_luma_minus8" ); 733 734 WRITE_UVLC( chromaEnabled ? (pcSPS->getBitDepth(CHANNEL_TYPE_CHROMA) - 8):0, "bit_depth_chroma_minus8" ); 735 #if NH_MV 715 736 } 716 737 #endif 717 738 WRITE_UVLC( pcSPS->getBitsForPOC()-4, "log2_max_pic_order_cnt_lsb_minus4" ); 718 #if H_MV739 #if NH_MV 719 740 if ( !pcSPS->getMultiLayerExtSpsFlag()) 720 741 { 721 742 #endif 743 722 744 const Bool subLayerOrderingInfoPresentFlag = 1; 723 745 WRITE_FLAG(subLayerOrderingInfoPresentFlag, "sps_sub_layer_ordering_info_present_flag"); … … 725 747 { 726 748 WRITE_UVLC( pcSPS->getMaxDecPicBuffering(i) - 1, "sps_max_dec_pic_buffering_minus1[i]" ); 727 WRITE_UVLC( pcSPS->getNumReorderPics(i), "sps_ num_reorder_pics[i]" );749 WRITE_UVLC( pcSPS->getNumReorderPics(i), "sps_max_num_reorder_pics[i]" ); 728 750 WRITE_UVLC( pcSPS->getMaxLatencyIncrease(i), "sps_max_latency_increase_plus1[i]" ); 729 751 if (!subLayerOrderingInfoPresentFlag) … … 732 754 } 733 755 } 734 #if H_MV756 #if NH_MV 735 757 } 736 758 #endif 737 759 738 760 assert( pcSPS->getMaxCUWidth() == pcSPS->getMaxCUHeight() ); 739 740 WRITE_UVLC( pcSPS->getLog2MinCodingBlockSize() - 3, "log2_min_coding_block_size_minus3" ); 741 WRITE_UVLC( pcSPS->getLog2DiffMaxMinCodingBlockSize(), "log2_diff_max_min_coding_block_size" ); 742 WRITE_UVLC( pcSPS->getQuadtreeTULog2MinSize() - 2, "log2_min_transform_block_size_minus2" ); 743 WRITE_UVLC( pcSPS->getQuadtreeTULog2MaxSize() - pcSPS->getQuadtreeTULog2MinSize(), "log2_diff_max_min_transform_block_size" ); 761 WRITE_UVLC( pcSPS->getLog2MinCodingBlockSize() - 3, "log2_min_luma_coding_block_size_minus3" ); 762 WRITE_UVLC( pcSPS->getLog2DiffMaxMinCodingBlockSize(), "log2_diff_max_min_luma_coding_block_size" ); 763 WRITE_UVLC( pcSPS->getQuadtreeTULog2MinSize() - 2, "log2_min_luma_transform_block_size_minus2" ); 764 WRITE_UVLC( pcSPS->getQuadtreeTULog2MaxSize() - pcSPS->getQuadtreeTULog2MinSize(), "log2_diff_max_min_luma_transform_block_size" ); 744 765 WRITE_UVLC( pcSPS->getQuadtreeTUMaxDepthInter() - 1, "max_transform_hierarchy_depth_inter" ); 745 766 WRITE_UVLC( pcSPS->getQuadtreeTUMaxDepthIntra() - 1, "max_transform_hierarchy_depth_intra" ); 746 WRITE_FLAG( pcSPS->getScalingListFlag() ? 1 : 0, "scaling_list_enabled_flag" ); 767 WRITE_FLAG( pcSPS->getScalingListFlag() ? 1 : 0, "scaling_list_enabled_flag" ); 747 768 if(pcSPS->getScalingListFlag()) 748 769 { 749 #if H_MV770 #if NH_MV 750 771 if ( pcSPS->getMultiLayerExtSpsFlag() ) 751 772 { … … 760 781 { 761 782 #endif 762 WRITE_FLAG( pcSPS->getScalingListPresentFlag() ? 1 : 0, "sps_scaling_list_data_present_flag" ); 783 784 WRITE_FLAG( pcSPS->getScalingListPresentFlag() ? 1 : 0, "sps_scaling_list_data_present_flag" ); 763 785 if(pcSPS->getScalingListPresentFlag()) 764 786 { 765 codeScalingList( m_pcSlice->getScalingList() );766 } 767 #if H_MV787 codeScalingList( pcSPS->getScalingList() ); 788 } 789 #if NH_MV 768 790 } 769 791 #endif … … 775 797 if( pcSPS->getUsePCM() ) 776 798 { 777 WRITE_CODE( pcSPS->getPCMBitDepth Luma() - 1, 4,"pcm_sample_bit_depth_luma_minus1" );778 WRITE_CODE( pcSPS->getPCMBitDepthChroma() - 1, 4,"pcm_sample_bit_depth_chroma_minus1" );799 WRITE_CODE( pcSPS->getPCMBitDepth(CHANNEL_TYPE_LUMA) - 1, 4, "pcm_sample_bit_depth_luma_minus1" ); 800 WRITE_CODE( chromaEnabled ? (pcSPS->getPCMBitDepth(CHANNEL_TYPE_CHROMA) - 1) : 0, 4, "pcm_sample_bit_depth_chroma_minus1" ); 779 801 WRITE_UVLC( pcSPS->getPCMLog2MinSize() - 3, "log2_min_pcm_luma_coding_block_size_minus3" ); 780 802 WRITE_UVLC( pcSPS->getPCMLog2MaxSize() - pcSPS->getPCMLog2MinSize(), "log2_diff_max_min_pcm_luma_coding_block_size" ); … … 782 804 } 783 805 784 assert( pcSPS->getMaxTLayers() > 0 ); 785 786 TComRPSList* rpsList = pcSPS->getRPSList(); 787 TComReferencePictureSet* rps; 806 assert( pcSPS->getMaxTLayers() > 0 ); 807 808 const TComRPSList* rpsList = pcSPS->getRPSList(); 788 809 789 810 WRITE_UVLC(rpsList->getNumberOfReferencePictureSets(), "num_short_term_ref_pic_sets" ); 790 811 for(Int i=0; i < rpsList->getNumberOfReferencePictureSets(); i++) 791 812 { 792 rps = rpsList->getReferencePictureSet(i);793 codeShortTermRefPicSet( pcSPS,rps,false, i);813 const TComReferencePictureSet*rps = rpsList->getReferencePictureSet(i); 814 codeShortTermRefPicSet( rps,false, i); 794 815 } 795 816 WRITE_FLAG( pcSPS->getLongTermRefsPresent() ? 1 : 0, "long_term_ref_pics_present_flag" ); 796 if (pcSPS->getLongTermRefsPresent()) 797 { 798 WRITE_UVLC(pcSPS->getNumLongTermRefPicSPS(), "num_long_term_ref_pic _sps" );817 if (pcSPS->getLongTermRefsPresent()) 818 { 819 WRITE_UVLC(pcSPS->getNumLongTermRefPicSPS(), "num_long_term_ref_pics_sps" ); 799 820 for (UInt k = 0; k < pcSPS->getNumLongTermRefPicSPS(); k++) 800 821 { 801 822 WRITE_CODE( pcSPS->getLtRefPicPocLsbSps(k), pcSPS->getBitsForPOC(), "lt_ref_pic_poc_lsb_sps"); 802 WRITE_FLAG( pcSPS->getUsedByCurrPicLtSPSFlag(k), "used_by_curr_pic_lt_sps_flag ");823 WRITE_FLAG( pcSPS->getUsedByCurrPicLtSPSFlag(k), "used_by_curr_pic_lt_sps_flag[i]"); 803 824 } 804 825 } … … 813 834 } 814 835 815 #if !H_MV 816 WRITE_FLAG( 0, "sps_extension_flag" ); 836 #if !NH_MV 837 Bool sps_extension_present_flag=false; 838 Bool sps_extension_flags[NUM_SPS_EXTENSION_FLAGS]={false}; 839 840 sps_extension_flags[SPS_EXT__REXT] = pcSPS->getSpsRangeExtension().settingsDifferFromDefaults(); 841 842 // Other SPS extension flags checked here. 843 844 for(Int i=0; i<NUM_SPS_EXTENSION_FLAGS; i++) 845 { 846 sps_extension_present_flag|=sps_extension_flags[i]; 847 } 848 849 WRITE_FLAG( (sps_extension_present_flag?1:0), "sps_extension_present_flag" ); 850 851 if (sps_extension_present_flag) 852 { 853 #if ENC_DEC_TRACE || RExt__DECODER_DEBUG_BIT_STATISTICS 854 static const char *syntaxStrings[]={ "sps_range_extension_flag", 855 "sps_multilayer_extension_flag", 856 "sps_extension_6bits[0]", 857 "sps_extension_6bits[1]", 858 "sps_extension_6bits[2]", 859 "sps_extension_6bits[3]", 860 "sps_extension_6bits[4]", 861 "sps_extension_6bits[5]" }; 862 #endif 863 864 for(Int i=0; i<NUM_SPS_EXTENSION_FLAGS; i++) 865 { 866 WRITE_FLAG( sps_extension_flags[i]?1:0, syntaxStrings[i] ); 867 } 868 869 for(Int i=0; i<NUM_SPS_EXTENSION_FLAGS; i++) // loop used so that the order is determined by the enum. 870 { 871 if (sps_extension_flags[i]) 872 { 873 switch (SPSExtensionFlagIndex(i)) 874 { 875 case SPS_EXT__REXT: 876 { 877 const TComSPSRExt &spsRangeExtension=pcSPS->getSpsRangeExtension(); 878 879 WRITE_FLAG( (spsRangeExtension.getTransformSkipRotationEnabledFlag() ? 1 : 0), "transform_skip_rotation_enabled_flag"); 880 WRITE_FLAG( (spsRangeExtension.getTransformSkipContextEnabledFlag() ? 1 : 0), "transform_skip_context_enabled_flag"); 881 WRITE_FLAG( (spsRangeExtension.getRdpcmEnabledFlag(RDPCM_SIGNAL_IMPLICIT) ? 1 : 0), "implicit_rdpcm_enabled_flag" ); 882 WRITE_FLAG( (spsRangeExtension.getRdpcmEnabledFlag(RDPCM_SIGNAL_EXPLICIT) ? 1 : 0), "explicit_rdpcm_enabled_flag" ); 883 WRITE_FLAG( (spsRangeExtension.getExtendedPrecisionProcessingFlag() ? 1 : 0), "extended_precision_processing_flag" ); 884 WRITE_FLAG( (spsRangeExtension.getIntraSmoothingDisabledFlag() ? 1 : 0), "intra_smoothing_disabled_flag" ); 885 WRITE_FLAG( (spsRangeExtension.getHighPrecisionOffsetsEnabledFlag() ? 1 : 0), "high_precision_offsets_enabled_flag" ); 886 WRITE_FLAG( (spsRangeExtension.getPersistentRiceAdaptationEnabledFlag() ? 1 : 0), "persistent_rice_adaptation_enabled_flag" ); 887 WRITE_FLAG( (spsRangeExtension.getCabacBypassAlignmentEnabledFlag() ? 1 : 0), "cabac_bypass_alignment_enabled_flag" ); 888 break; 889 } 890 default: 891 assert(sps_extension_flags[i]==false); // Should never get here with an active SPS extension flag. 892 break; 893 } 894 } 895 } 896 } 817 897 #else 818 898 WRITE_FLAG( pcSPS->getSpsExtensionPresentFlag(), "sps_extension_present_flag" ); … … 820 900 if ( pcSPS->getSpsExtensionPresentFlag() ) 821 901 { 822 WRITE_FLAG( pcSPS->getSpsRangeExtensionsFlag( ) ? 1 : 0 , "sps_range_extensions_flag" );902 WRITE_FLAG( pcSPS->getSpsRangeExtensionsFlag( ) ? 1 : 0 , "sps_range_extensions_flag" ); 823 903 WRITE_FLAG( pcSPS->getSpsMultilayerExtensionFlag( ) ? 1 : 0 , "sps_multilayer_extension_flag" ); 824 #if !H_3D 825 WRITE_CODE( pcSPS->getSpsExtension6bits( ), 6, "sps_extension_6bits" ); 826 #else 827 WRITE_FLAG( pcSPS->getSps3dExtensionFlag( ) ? 1 : 0 , "sps_3d_extension_flag" ); 828 WRITE_CODE( pcSPS->getSpsExtension5bits( ), 5, "sps_extension_5bits" ); 829 #endif 904 WRITE_FLAG( pcSPS->getSps3dExtensionFlag( ) ? 1 : 0 , "sps_3d_extension_flag" ); 905 WRITE_CODE( pcSPS->getSpsExtension5bits( ) , 5 , "sps_extension_5bits" ); 830 906 } 831 907 832 908 if ( pcSPS->getSpsRangeExtensionsFlag() ) 833 909 { 834 assert( 0 ); 910 const TComSPSRExt &spsRangeExtension=pcSPS->getSpsRangeExtension(); 911 912 WRITE_FLAG( (spsRangeExtension.getTransformSkipRotationEnabledFlag() ? 1 : 0), "transform_skip_rotation_enabled_flag"); 913 WRITE_FLAG( (spsRangeExtension.getTransformSkipContextEnabledFlag() ? 1 : 0), "transform_skip_context_enabled_flag"); 914 WRITE_FLAG( (spsRangeExtension.getRdpcmEnabledFlag(RDPCM_SIGNAL_IMPLICIT) ? 1 : 0), "implicit_rdpcm_enabled_flag" ); 915 WRITE_FLAG( (spsRangeExtension.getRdpcmEnabledFlag(RDPCM_SIGNAL_EXPLICIT) ? 1 : 0), "explicit_rdpcm_enabled_flag" ); 916 WRITE_FLAG( (spsRangeExtension.getExtendedPrecisionProcessingFlag() ? 1 : 0), "extended_precision_processing_flag" ); 917 WRITE_FLAG( (spsRangeExtension.getIntraSmoothingDisabledFlag() ? 1 : 0), "intra_smoothing_disabled_flag" ); 918 WRITE_FLAG( (spsRangeExtension.getHighPrecisionOffsetsEnabledFlag() ? 1 : 0), "high_precision_offsets_enabled_flag" ); 919 WRITE_FLAG( (spsRangeExtension.getPersistentRiceAdaptationEnabledFlag() ? 1 : 0), "persistent_rice_adaptation_enabled_flag" ); 920 WRITE_FLAG( (spsRangeExtension.getCabacBypassAlignmentEnabledFlag() ? 1 : 0), "cabac_bypass_alignment_enabled_flag" ); 835 921 } 836 922 … … 840 926 } 841 927 842 #if H_3D928 #if NH_3D 843 929 if ( pcSPS->getSps3dExtensionFlag() ) 844 930 { … … 848 934 #endif 849 935 #endif 850 851 } 852 853 #if H_MV854 Void TEncCavlc::codeSPSExtension( TComSPS* pcSPS )936 xWriteRbspTrailingBits(); 937 } 938 939 #if NH_MV 940 Void TEncCavlc::codeSPSExtension( const TComSPS* pcSPS ) 855 941 { 856 942 WRITE_FLAG( pcSPS->getInterViewMvVertConstraintFlag() ? 1 : 0, "inter_view_mv_vert_constraint_flag" ); … … 858 944 859 945 860 Void TEncCavlc::codeP PSMultilayerExtension(TComPPS* pcPPS)946 Void TEncCavlc::codePpsMultilayerExtension(const TComPPS* pcPPS) 861 947 { 862 948 WRITE_FLAG( pcPPS->getPocResetInfoPresentFlag( ) ? 1 : 0 , "poc_reset_info_present_flag" ); … … 873 959 #endif 874 960 875 #if H_3D876 Void TEncCavlc::codeSPS3dExtension( TComSPS* pcSPS )877 { 878 TComSps3dExtension* sps3dExt = pcSPS->getSps3dExtension();961 #if NH_3D 962 Void TEncCavlc::codeSPS3dExtension( const TComSPS* pcSPS ) 963 { 964 const TComSps3dExtension* sps3dExt = pcSPS->getSps3dExtension(); 879 965 for( Int d = 0; d <= 1; d++ ) 880 966 { … … 904 990 905 991 906 907 908 Void TEncCavlc::codeVPS( TComVPS* pcVPS ) 909 { 992 Void TEncCavlc::codeVPS( const TComVPS* pcVPS ) 993 { 994 #if ENC_DEC_TRACE 995 #if H_MV_ENC_DEC_TRAC 996 tracePSHeader( "VPS", getEncTop()->getLayerId() ); 997 #else 998 xTraceVPSHeader(); 999 #endif 1000 #endif 910 1001 WRITE_CODE( pcVPS->getVPSId(), 4, "vps_video_parameter_set_id" ); 911 #if H_MV1002 #if NH_MV 912 1003 WRITE_FLAG( pcVPS->getVpsBaseLayerInternalFlag( ) ? 1 : 0 , "vps_base_layer_internal_flag" ); 913 1004 WRITE_FLAG( pcVPS->getVpsBaseLayerAvailableFlag( ) ? 1 : 0 , "vps_base_layer_available_flag" ); 914 1005 #else 915 WRITE_CODE( 3, 2, "vps_reserved_three_2bits" ); 916 #endif 917 #if H_MV 1006 WRITE_FLAG( 1, "vps_base_layer_internal_flag" ); 1007 WRITE_FLAG( 1, "vps_base_layer_available_flag" ); 1008 #endif 1009 #if NH_MV 918 1010 WRITE_CODE( pcVPS->getMaxLayersMinus1(), 6, "vps_max_layers_minus1" ); 919 1011 #else 920 WRITE_CODE( 0, 6, "vps_ reserved_zero_6bits" );1012 WRITE_CODE( 0, 6, "vps_max_layers_minus1" ); 921 1013 #endif 922 1014 WRITE_CODE( pcVPS->getMaxTLayers() - 1, 3, "vps_max_sub_layers_minus1" ); 923 1015 WRITE_FLAG( pcVPS->getTemporalNestingFlag(), "vps_temporal_id_nesting_flag" ); 924 1016 assert (pcVPS->getMaxTLayers()>1||pcVPS->getTemporalNestingFlag()); 925 WRITE_CODE( 0xffff, 16, "vps_reserved_ ffff_16bits" );1017 WRITE_CODE( 0xffff, 16, "vps_reserved_0xffff_16bits" ); 926 1018 codePTL( pcVPS->getPTL(), true, pcVPS->getMaxTLayers() - 1 ); 927 1019 const Bool subLayerOrderingInfoPresentFlag = 1; … … 930 1022 { 931 1023 WRITE_UVLC( pcVPS->getMaxDecPicBuffering(i) - 1, "vps_max_dec_pic_buffering_minus1[i]" ); 932 WRITE_UVLC( pcVPS->getNumReorderPics(i), "vps_ num_reorder_pics[i]" );1024 WRITE_UVLC( pcVPS->getNumReorderPics(i), "vps_max_num_reorder_pics[i]" ); 933 1025 WRITE_UVLC( pcVPS->getMaxLatencyIncrease(i), "vps_max_latency_increase_plus1[i]" ); 934 1026 if (!subLayerOrderingInfoPresentFlag) … … 937 1029 } 938 1030 } 1031 939 1032 assert( pcVPS->getNumHrdParameters() <= MAX_VPS_NUM_HRD_PARAMETERS ); 940 #if H_MV1033 #if NH_MV 941 1034 assert( pcVPS->getVpsMaxLayerId() < MAX_VPS_NUH_LAYER_ID_PLUS1 ); 942 1035 WRITE_CODE( pcVPS->getVpsMaxLayerId(), 6, "vps_max_layer_id" ); … … 949 1042 #else 950 1043 assert( pcVPS->getMaxNuhReservedZeroLayerId() < MAX_VPS_NUH_RESERVED_ZERO_LAYER_ID_PLUS1 ); 951 WRITE_CODE( pcVPS->getMaxNuhReservedZeroLayerId(), 6, "vps_max_nuh_reserved_zero_layer_id" ); 952 pcVPS->setMaxOpSets(1); 953 WRITE_UVLC( pcVPS->getMaxOpSets() - 1, "vps_max_op_sets_minus1" ); 1044 WRITE_CODE( pcVPS->getMaxNuhReservedZeroLayerId(), 6, "vps_max_layer_id" ); 1045 WRITE_UVLC( pcVPS->getMaxOpSets() - 1, "vps_num_layer_sets_minus1" ); 954 1046 for( UInt opsIdx = 1; opsIdx <= ( pcVPS->getMaxOpSets() - 1 ); opsIdx ++ ) 955 1047 { … … 958 1050 { 959 1051 // Only applicable for version 1 960 pcVPS->setLayerIdIncludedFlag( true, opsIdx, i );1052 // pcVPS->setLayerIdIncludedFlag( true, opsIdx, i ); 961 1053 #endif 962 1054 WRITE_FLAG( pcVPS->getLayerIdIncludedFlag( opsIdx, i ) ? 1 : 0, "layer_id_included_flag[opsIdx][i]" ); 963 1055 } 964 1056 } 965 TimingInfo *timingInfo = pcVPS->getTimingInfo();1057 const TimingInfo *timingInfo = pcVPS->getTimingInfo(); 966 1058 WRITE_FLAG(timingInfo->getTimingInfoPresentFlag(), "vps_timing_info_present_flag"); 967 1059 if(timingInfo->getTimingInfoPresentFlag()) … … 974 1066 WRITE_UVLC(timingInfo->getNumTicksPocDiffOneMinus1(), "vps_num_ticks_poc_diff_one_minus1"); 975 1067 } 976 pcVPS->setNumHrdParameters( 0 );977 1068 WRITE_UVLC( pcVPS->getNumHrdParameters(), "vps_num_hrd_parameters" ); 978 1069 979 1070 if( pcVPS->getNumHrdParameters() > 0 ) 980 1071 { 981 pcVPS->createHrdParamBuffer(); 982 } 983 for( UInt i = 0; i < pcVPS->getNumHrdParameters(); i ++ ) 984 { 985 // Only applicable for version 1 986 pcVPS->setHrdOpSetIdx( 0, i ); 987 WRITE_UVLC( pcVPS->getHrdOpSetIdx( i ), "hrd_op_set_idx" ); 988 if( i > 0 ) 989 { 990 WRITE_FLAG( pcVPS->getCprmsPresentFlag( i ) ? 1 : 0, "cprms_present_flag[i]" ); 991 } 992 codeHrdParameters(pcVPS->getHrdParameters(i), pcVPS->getCprmsPresentFlag( i ), pcVPS->getMaxTLayers() - 1); 993 } 994 } 995 #if H_MV 1072 for( UInt i = 0; i < pcVPS->getNumHrdParameters(); i ++ ) 1073 { 1074 // Only applicable for version 1 1075 WRITE_UVLC( pcVPS->getHrdOpSetIdx( i ), "hrd_layer_set_idx" ); 1076 if( i > 0 ) 1077 { 1078 WRITE_FLAG( pcVPS->getCprmsPresentFlag( i ) ? 1 : 0, "cprms_present_flag[i]" ); 1079 } 1080 codeHrdParameters(pcVPS->getHrdParameters(i), pcVPS->getCprmsPresentFlag( i ), pcVPS->getMaxTLayers() - 1); 1081 } 1082 } 1083 } 1084 #if NH_MV 996 1085 WRITE_FLAG( pcVPS->getVpsExtensionFlag(), "vps_extension_flag" ); 997 1086 m_pcBitIf->writeAlignOne(); 998 1087 codeVPSExtension( pcVPS ); 999 #if H_3D1088 #if NH_3D 1000 1089 WRITE_FLAG( 1, "vps_extension2_flag" ); 1001 1090 WRITE_FLAG( 1, "vps_3d_extension_flag" ); … … 1009 1098 WRITE_FLAG( 0, "vps_extension_flag" ); 1010 1099 #endif 1100 1011 1101 //future extensions here.. 1012 1013 return; 1014 } 1015 1016 1017 1018 #if H_MV 1019 Void TEncCavlc::codeVPSExtension( TComVPS *pcVPS ) 1102 xWriteRbspTrailingBits(); 1103 } 1104 1105 #if NH_MV 1106 Void TEncCavlc::codeVPSExtension( const TComVPS *pcVPS ) 1020 1107 { 1021 1108 if( pcVPS->getMaxLayersMinus1() > 0 && pcVPS->getVpsBaseLayerInternalFlag() ) … … 1037 1124 1038 1125 if ( pcVPS->getSplittingFlag() ) 1039 { 1040 pcVPS->setDimensionIdLen( pcVPS->getNumScalabilityTypes( ) - 1 ,pcVPS->inferLastDimsionIdLenMinus1() + 1 );1126 { 1127 assert( pcVPS->getDimensionIdLen( pcVPS->getNumScalabilityTypes( ) - 1 ) == pcVPS->inferLastDimsionIdLenMinus1() + 1 ); 1041 1128 } 1042 1129 … … 1213 1300 for (Int i = 0; i <= pcVPS->getVpsNumRepFormatsMinus1(); i++ ) 1214 1301 { 1215 1216 TComRepFormat* curRepFormat = pcVPS->getRepFormat(i); 1217 TComRepFormat* prevRepFormat = i > 0 ? pcVPS->getRepFormat( i - 1) : NULL; 1302 const TComRepFormat* curRepFormat = pcVPS->getRepFormat(i); 1303 const TComRepFormat* prevRepFormat = i > 0 ? pcVPS->getRepFormat( i - 1) : NULL; 1218 1304 codeRepFormat( i, curRepFormat , prevRepFormat); 1219 1220 1305 } 1221 1306 … … 1291 1376 else 1292 1377 { 1293 TComVPSVUI* pcVPSVUI = pcVPS->getVPSVUI( );1378 const TComVPSVUI* pcVPSVUI = pcVPS->getVPSVUI( ); 1294 1379 assert( pcVPSVUI ); 1295 pcVPSVUI->inferVpsVui( true );1296 } 1297 1298 } 1299 1300 Void TEncCavlc::codeVideoSignalInfo( TComVideoSignalInfo* pcVideoSignalInfo )1380 assert( !pcVPSVUI->getCrossLayerIrapAlignedFlag() ); 1381 } 1382 1383 } 1384 1385 Void TEncCavlc::codeVideoSignalInfo( const TComVideoSignalInfo* pcVideoSignalInfo ) 1301 1386 { 1302 1387 assert( pcVideoSignalInfo ); … … 1308 1393 } 1309 1394 1310 Void TEncCavlc::codeDpbSize( TComVPS* vps )1395 Void TEncCavlc::codeDpbSize( const TComVPS* vps ) 1311 1396 { 1312 TComDpbSize* dpbSize = vps->getDpbSize(); 1313 assert ( dpbSize != 0 ); 1397 const TComDpbSize * dpbSize = vps->getDpbSize(); 1314 1398 1315 1399 for( Int i = 1; i < vps->getNumOutputLayerSets(); i++ ) … … 1361 1445 } 1362 1446 1363 Void TEncCavlc::codeRepFormat( Int i, TComRepFormat* pcRepFormat,TComRepFormat* pcPrevRepFormat )1447 Void TEncCavlc::codeRepFormat( Int i, const TComRepFormat* pcRepFormat, const TComRepFormat* pcPrevRepFormat ) 1364 1448 { 1365 1449 assert( pcRepFormat ); … … 1384 1468 else 1385 1469 { 1386 pcRepFormat-> inferChromaAndBitDepth(pcPrevRepFormat, true);1470 pcRepFormat->checkInferChromaAndBitDepth(pcPrevRepFormat ); 1387 1471 } 1388 1472 WRITE_FLAG( pcRepFormat->getConformanceWindowVpsFlag( ) ? 1 : 0 , "conformance_window_vps_flag" ); … … 1396 1480 } 1397 1481 1398 Void TEncCavlc::codeVPSVUI( TComVPS* pcVPS )1482 Void TEncCavlc::codeVPSVUI( const TComVPS* pcVPS ) 1399 1483 { 1400 1484 assert( pcVPS ); 1401 1485 1402 TComVPSVUI* pcVPSVUI = pcVPS->getVPSVUI( );1486 const TComVPSVUI* pcVPSVUI = pcVPS->getVPSVUI( ); 1403 1487 1404 1488 assert( pcVPSVUI ); … … 1457 1541 { 1458 1542 assert( pcVPSVUI->getVideoSignalInfo( i ) != NULL ); 1459 TComVideoSignalInfo* curVideoSignalInfo = pcVPSVUI->getVideoSignalInfo( i );1543 const TComVideoSignalInfo* curVideoSignalInfo = pcVPSVUI->getVideoSignalInfo( i ); 1460 1544 codeVideoSignalInfo( curVideoSignalInfo ); 1461 1545 … … 1543 1627 } 1544 1628 1545 Void TEncCavlc::codeVpsVuiBspHrdParameters( TComVPS* pcVPS )1629 Void TEncCavlc::codeVpsVuiBspHrdParameters( const TComVPS* pcVPS ) 1546 1630 { 1547 1631 assert( pcVPS ); 1548 1632 1549 TComVPSVUI* pcVPSVUI = pcVPS->getVPSVUI( );1633 const TComVPSVUI* pcVPSVUI = pcVPS->getVPSVUI( ); 1550 1634 1551 1635 assert( pcVPSVUI ); 1552 1636 1553 TComVpsVuiBspHrdParameters* vpsVuiBspHrdP = pcVPSVUI->getVpsVuiBspHrdParameters();1637 const TComVpsVuiBspHrdParameters* vpsVuiBspHrdP = pcVPSVUI->getVpsVuiBspHrdParameters(); 1554 1638 1555 1639 assert ( vpsVuiBspHrdP ); … … 1564 1648 } 1565 1649 WRITE_UVLC( vpsVuiBspHrdP->getNumSubLayerHrdMinus1( i ), "num_sub_layer_hrd_minus1" ); 1566 TComHRD* hrdParameters = vpsVuiBspHrdP->getHrdParametermeters( i );1650 const TComHRD* hrdParameters = vpsVuiBspHrdP->getHrdParametermeters( i ); 1567 1651 codeHrdParameters( hrdParameters, vpsVuiBspHrdP->getCprmsAddPresentFlag( i ), vpsVuiBspHrdP->getNumSubLayerHrdMinus1( i ) ); 1568 1652 } … … 1599 1683 } 1600 1684 } 1601 1602 1685 } 1603 1686 #endif 1604 1687 1605 #if H_3D1606 Void TEncCavlc::codeVPS3dExtension( TComVPS* pcVPS )1688 #if NH_3D 1689 Void TEncCavlc::codeVPS3dExtension( const TComVPS* pcVPS ) 1607 1690 { 1608 1691 WRITE_UVLC( pcVPS->getCpPrecision( ), "cp_precision" ); … … 1634 1717 #endif 1635 1718 1719 1636 1720 Void TEncCavlc::codeSliceHeader ( TComSlice* pcSlice ) 1637 1721 { 1638 #if H_MV 1639 TComVPS* vps = pcSlice->getVPS(); 1640 #endif 1641 #if ENC_DEC_TRACE 1642 xTraceSliceHeader (pcSlice); 1643 #endif 1722 #if NH_MV 1723 const TComVPS* vps = pcSlice->getVPS(); 1724 #endif 1725 1726 #if ENC_DEC_TRACE 1727 #if NH_MV 1728 tracePSHeader( "Slice", pcSlice->getLayerId() ); 1729 #else 1730 xTraceSliceHeader (); 1731 #endif 1732 #endif 1733 1734 const ChromaFormat format = pcSlice->getSPS()->getChromaFormatIdc(); 1735 const UInt numberValidComponents = getNumberValidComponents(format); 1736 const Bool chromaEnabled = isChromaEnabled(format); 1644 1737 1645 1738 //calculate number of bits required for slice address 1646 Int maxSliceSegmentAddress = pcSlice->getPic()->getNum CUsInFrame();1739 Int maxSliceSegmentAddress = pcSlice->getPic()->getNumberOfCtusInFrame(); 1647 1740 Int bitsSliceSegmentAddress = 0; 1648 while(maxSliceSegmentAddress>(1<<bitsSliceSegmentAddress)) 1741 while(maxSliceSegmentAddress>(1<<bitsSliceSegmentAddress)) 1649 1742 { 1650 1743 bitsSliceSegmentAddress++; 1651 1744 } 1652 Int ctuAddress; 1653 if (pcSlice->isNextSlice()) 1654 { 1655 // Calculate slice address 1656 ctuAddress = (pcSlice->getSliceCurStartCUAddr()/pcSlice->getPic()->getNumPartInCU()); 1657 } 1658 else 1659 { 1660 // Calculate slice address 1661 ctuAddress = (pcSlice->getSliceSegmentCurStartCUAddr()/pcSlice->getPic()->getNumPartInCU()); 1662 } 1745 const Int ctuTsAddress = pcSlice->getSliceSegmentCurStartCtuTsAddr(); 1746 1663 1747 //write slice address 1664 Int sliceSegmentAddress = pcSlice->getPic()->getPicSym()->getCUOrderMap(ctuAddress);1665 1666 WRITE_FLAG( sliceSegment Address==0, "first_slice_segment_in_pic_flag" );1748 const Int sliceSegmentRsAddress = pcSlice->getPic()->getPicSym()->getCtuTsToRsAddrMap(ctuTsAddress); 1749 1750 WRITE_FLAG( sliceSegmentRsAddress==0, "first_slice_segment_in_pic_flag" ); 1667 1751 if ( pcSlice->getRapPicFlag() ) 1668 1752 { 1669 #if SETTING_NO_OUT_PIC_PRIOR1670 1753 WRITE_FLAG( pcSlice->getNoOutputPriorPicsFlag() ? 1 : 0, "no_output_of_prior_pics_flag" ); 1671 #else1672 WRITE_FLAG( 0, "no_output_of_prior_pics_flag" );1673 #endif1674 1754 } 1675 1755 #if PPS_FIX_DEPTH … … 1680 1760 else 1681 1761 #endif 1762 1682 1763 WRITE_UVLC( pcSlice->getPPS()->getPPSId(), "slice_pic_parameter_set_id" ); 1683 pcSlice->setDependentSliceSegmentFlag(!pcSlice->isNextSlice()); 1684 if ( pcSlice->getPPS()->getDependentSliceSegmentsEnabledFlag() && (sliceSegmentAddress!=0) ) 1764 if ( pcSlice->getPPS()->getDependentSliceSegmentsEnabledFlag() && (sliceSegmentRsAddress!=0) ) 1685 1765 { 1686 1766 WRITE_FLAG( pcSlice->getDependentSliceSegmentFlag() ? 1 : 0, "dependent_slice_segment_flag" ); 1687 1767 } 1688 if(sliceSegment Address>0)1689 { 1690 WRITE_CODE( sliceSegment Address, bitsSliceSegmentAddress, "slice_segment_address" );1768 if(sliceSegmentRsAddress>0) 1769 { 1770 WRITE_CODE( sliceSegmentRsAddress, bitsSliceSegmentAddress, "slice_segment_address" ); 1691 1771 } 1692 1772 if ( !pcSlice->getDependentSliceSegmentFlag() ) 1693 1773 { 1694 #if H_MV 1774 1775 #if NH_MV 1695 1776 Int esb = 0; //Don't use i, otherwise will shadow something below 1696 1777 … … 1716 1797 pcSlice->checkCrossLayerBlaFlag( ); 1717 1798 1718 1719 1720 1799 for (; esb < pcSlice->getPPS()->getNumExtraSliceHeaderBits(); esb++) 1721 1800 #else … … 1723 1802 #endif 1724 1803 { 1725 assert(!!"slice_reserved_undetermined_flag[]"); 1726 WRITE_FLAG(0, "slice_reserved_undetermined_flag[]"); 1727 } 1804 WRITE_FLAG(0, "slice_reserved_flag[]"); 1805 } 1806 1807 1728 1808 1729 1809 WRITE_UVLC( pcSlice->getSliceType(), "slice_type" ); … … 1734 1814 } 1735 1815 1736 // in the first version chroma_format_idc is equal to one, thus colour_plane_id will not be present 1737 #if H_3D_DISABLE_CHROMA 1738 assert (pcSlice->getSPS()->getChromaFormatIdc() == 1 || pcSlice->getIsDepth() ); 1739 assert (pcSlice->getSPS()->getChromaFormatIdc() == 0 || !pcSlice->getIsDepth() ); 1740 #else 1741 assert (pcSlice->getSPS()->getChromaFormatIdc() == 1 ); 1742 #endif 1743 // if( separate_colour_plane_flag == 1 ) 1744 // colour_plane_id u(2) 1745 #if H_MV 1816 #if NH_MV 1746 1817 if ( (pcSlice->getLayerId() > 0 && !vps->getPocLsbNotPresentFlag( pcSlice->getLayerIdInVps())) || !pcSlice->getIdrPicFlag() ) 1747 1818 { … … 1752 1823 1753 1824 #endif 1825 1754 1826 if( !pcSlice->getIdrPicFlag() ) 1755 1827 { 1756 #if ! H_MV1828 #if !NH_MV 1757 1829 Int picOrderCntLSB = (pcSlice->getPOC()-pcSlice->getLastIDR()+(1<<pcSlice->getSPS()->getBitsForPOC())) & ((1<<pcSlice->getSPS()->getBitsForPOC())-1); 1758 WRITE_CODE( picOrderCntLSB, pcSlice->getSPS()->getBitsForPOC(), " pic_order_cnt_lsb");1759 #endif 1760 TComReferencePictureSet* rps = pcSlice->getRPS();1761 1830 WRITE_CODE( picOrderCntLSB, pcSlice->getSPS()->getBitsForPOC(), "slice_pic_order_cnt_lsb"); 1831 #endif 1832 const TComReferencePictureSet* rps = pcSlice->getRPS(); 1833 1762 1834 // check for bitstream restriction stating that: 1763 1835 // If the current picture is a BLA or CRA picture, the value of NumPocTotalCurr shall be equal to 0. … … 1765 1837 if (pcSlice->isIRAP()) 1766 1838 { 1767 1768 1839 for (Int picIdx = 0; picIdx < rps->getNumberOfPictures(); picIdx++) 1840 { 1769 1841 assert (!rps->getUsed(picIdx)); 1770 1771 1842 } 1843 } 1772 1844 1773 1845 if(pcSlice->getRPSidx() < 0) 1774 1846 { 1775 1847 WRITE_FLAG( 0, "short_term_ref_pic_set_sps_flag"); 1776 codeShortTermRefPicSet( pcSlice->getSPS(),rps, true, pcSlice->getSPS()->getRPSList()->getNumberOfReferencePictureSets());1848 codeShortTermRefPicSet( rps, true, pcSlice->getSPS()->getRPSList()->getNumberOfReferencePictureSets()); 1777 1849 } 1778 1850 else … … 1786 1858 if (numBits > 0) 1787 1859 { 1788 WRITE_CODE( pcSlice->getRPSidx(), numBits, "short_term_ref_pic_set_idx" ); 1860 WRITE_CODE( pcSlice->getRPSidx(), numBits, "short_term_ref_pic_set_idx" ); 1789 1861 } 1790 1862 } … … 1796 1868 UInt ltrpIndex; 1797 1869 Int counter = 0; 1798 for(Int k = rps->getNumberOfPictures()-1; k > rps->getNumberOfPictures()-rps->getNumberOfLongtermPictures()-1; k--) 1799 { 1800 if (findMatchingLTRP(pcSlice, <rpIndex, rps->getPOC(k), rps->getUsed(k))) 1870 // WARNING: The following code only works only if a matching long-term RPS is 1871 // found in the SPS for ALL long-term pictures 1872 // The problem is that the SPS coded long-term pictures are moved to the 1873 // beginning of the list which causes a mismatch when no reference picture 1874 // list reordering is used 1875 // NB: Long-term coding is currently not supported in general by the HM encoder 1876 for(Int k = rps->getNumberOfPictures()-1; k > rps->getNumberOfPictures()-rps->getNumberOfLongtermPictures()-1; k--) 1877 { 1878 if (findMatchingLTRP(pcSlice, <rpIndex, rps->getPOC(k), rps->getUsed(k))) 1801 1879 { 1802 1880 ltrpInSPS[numLtrpInSPS] = ltrpIndex; … … 1809 1887 } 1810 1888 numLtrpInSH -= numLtrpInSPS; 1889 // check that either all long-term pictures are coded in SPS or in slice header (no mixing) 1890 assert (numLtrpInSH==0 || numLtrpInSPS==0); 1811 1891 1812 1892 Int bitsForLtrpInSPS = 0; … … 1815 1895 bitsForLtrpInSPS++; 1816 1896 } 1817 if (pcSlice->getSPS()->getNumLongTermRefPicSPS() > 0) 1897 if (pcSlice->getSPS()->getNumLongTermRefPicSPS() > 0) 1818 1898 { 1819 1899 WRITE_UVLC( numLtrpInSPS, "num_long_term_sps"); … … 1824 1904 Int prevDeltaMSB = 0, prevLSB = 0; 1825 1905 Int offset = rps->getNumberOfNegativePictures() + rps->getNumberOfPositivePictures(); 1826 for(Int i=rps->getNumberOfPictures()-1 ; i > offset-1; i--) 1906 counter = 0; 1907 // Warning: If some pictures are moved to ltrpInSPS, i is referring to a wrong index 1908 // (mapping would be required) 1909 for(Int i=rps->getNumberOfPictures()-1 ; i > offset-1; i--, counter++) 1827 1910 { 1828 1911 if (counter < numLtrpInSPS) … … 1830 1913 if (bitsForLtrpInSPS > 0) 1831 1914 { 1832 WRITE_CODE( ltrpInSPS[counter], bitsForLtrpInSPS, "lt_idx_sps[i]"); 1915 WRITE_CODE( ltrpInSPS[counter], bitsForLtrpInSPS, "lt_idx_sps[i]"); 1833 1916 } 1834 1917 } 1835 else 1918 else 1836 1919 { 1837 1920 WRITE_CODE( rps->getPocLSBLT(i), pcSlice->getSPS()->getBitsForPOC(), "poc_lsb_lt"); 1838 WRITE_FLAG( rps->getUsed(i), "used_by_curr_pic_lt_flag"); 1921 WRITE_FLAG( rps->getUsed(i), "used_by_curr_pic_lt_flag"); 1839 1922 } 1840 1923 WRITE_FLAG( rps->getDeltaPocMSBPresentFlag(i), "delta_poc_msb_present_flag"); … … 1853 1936 } 1854 1937 else 1855 { 1938 { 1856 1939 Int differenceInDeltaMSB = rps->getDeltaPocMSBCycleLT(i) - prevDeltaMSB; 1857 1940 assert(differenceInDeltaMSB >= 0); … … 1865 1948 if (pcSlice->getSPS()->getTMVPFlagsPresent()) 1866 1949 { 1867 #if H_MV1950 #if NH_MV 1868 1951 WRITE_FLAG( pcSlice->getEnableTMVPFlag() ? 1 : 0, "slice_temporal_mvp_enabled_flag" ); 1869 1952 #else 1870 WRITE_FLAG( pcSlice->getEnableTMVPFlag() ? 1 : 0, "slice_temporal_mvp_enable _flag" );1871 #endif 1872 } 1873 } 1874 #if H_MV1953 WRITE_FLAG( pcSlice->getEnableTMVPFlag() ? 1 : 0, "slice_temporal_mvp_enabled_flag" ); 1954 #endif 1955 } 1956 } 1957 #if NH_MV 1875 1958 Bool interLayerPredLayerIdcPresentFlag = false; 1876 1959 Int layerId = pcSlice->getLayerId(); 1877 #if H_3D1960 #if NH_3D 1878 1961 if( pcSlice->getLayerId() > 0 && !vps->getAllRefLayersActiveFlag() && vps->getNumRefListLayers( layerId ) > 0 ) 1879 1962 #else … … 1882 1965 { 1883 1966 WRITE_FLAG( pcSlice->getInterLayerPredEnabledFlag( ) ? 1 : 0 , "inter_layer_pred_enabled_flag" ); 1884 #if H_3D1967 #if NH_3D 1885 1968 if( pcSlice->getInterLayerPredEnabledFlag() && vps->getNumRefListLayers( layerId ) > 1 ) 1886 1969 #else … … 1892 1975 WRITE_CODE( pcSlice->getNumInterLayerRefPicsMinus1( ), pcSlice->getNumInterLayerRefPicsMinus1Len( ), "num_inter_layer_ref_pics_minus1" ); 1893 1976 } 1894 #if H_3D1977 #if NH_3D 1895 1978 if ( pcSlice->getNumActiveRefLayerPics() != vps->getNumRefListLayers( layerId ) ) 1896 1979 #else … … 1915 1998 #endif 1916 1999 1917 #if H_3D2000 #if NH_3D 1918 2001 if( getEncTop()->decProcAnnexI() ) 1919 2002 { … … 1924 2007 } 1925 2008 #endif 2009 1926 2010 if(pcSlice->getSPS()->getUseSAO()) 1927 2011 { 1928 if (pcSlice->getSPS()->getUseSAO()) 1929 { 1930 WRITE_FLAG( pcSlice->getSaoEnabledFlag(), "slice_sao_luma_flag" ); 1931 #if H_3D_DISABLE_CHROMA 1932 if ( !pcSlice->getIsDepth() ) 1933 { 1934 WRITE_FLAG( pcSlice->getSaoEnabledFlagChroma(), "slice_sao_chroma_flag" ); 1935 } 1936 #else 1937 WRITE_FLAG( pcSlice->getSaoEnabledFlagChroma(), "slice_sao_chroma_flag" ); 1938 #endif 1939 } 2012 WRITE_FLAG( pcSlice->getSaoEnabledFlag(CHANNEL_TYPE_LUMA), "slice_sao_luma_flag" ); 2013 if (chromaEnabled) 2014 { 2015 WRITE_FLAG( pcSlice->getSaoEnabledFlag(CHANNEL_TYPE_CHROMA), "slice_sao_chroma_flag" ); 2016 } 1940 2017 } 1941 2018 … … 1949 2026 #endif 1950 2027 WRITE_FLAG( overrideFlag ? 1 : 0, "num_ref_idx_active_override_flag"); 1951 if (overrideFlag) 2028 if (overrideFlag) 1952 2029 { 1953 2030 WRITE_UVLC( pcSlice->getNumRefIdx( REF_PIC_LIST_0 ) - 1, "num_ref_idx_l0_active_minus1" ); … … 1984 2061 Int length = 1; 1985 2062 numRpsCurrTempList0 --; 1986 while ( numRpsCurrTempList0 >>= 1) 2063 while ( numRpsCurrTempList0 >>= 1) 1987 2064 { 1988 2065 length ++; … … 1996 2073 } 1997 2074 if(pcSlice->isInterB()) 1998 { 2075 { 1999 2076 WRITE_FLAG(pcSlice->getRefPicListModification()->getRefPicListModificationFlagL1() ? 1 : 0, "ref_pic_list_modification_flag_l1" ); 2000 2077 if (pcSlice->getRefPicListModification()->getRefPicListModificationFlagL1()) … … 2017 2094 } 2018 2095 } 2019 2096 2020 2097 if (pcSlice->isInterB()) 2021 2098 { … … 2028 2105 { 2029 2106 SliceType sliceType = pcSlice->getSliceType(); 2030 Int encCABACTableIdx = pcSlice->getPPS()->getEncCABACTableIdx();2107 SliceType encCABACTableIdx = pcSlice->getEncCABACTableIdx(); 2031 2108 Bool encCabacInitFlag = (sliceType!=encCABACTableIdx && encCABACTableIdx!=I_SLICE) ? true : false; 2032 2109 pcSlice->setCabacInitFlag( encCabacInitFlag ); … … 2053 2130 xCodePredWeightTable( pcSlice ); 2054 2131 } 2055 #if H_3D_IC2132 #if NH_3D_IC 2056 2133 else if( pcSlice->getViewIndex() && ( pcSlice->getSliceType() == P_SLICE || pcSlice->getSliceType() == B_SLICE ) 2057 2134 && !pcSlice->getIsDepth() && vps->getNumRefListLayers( layerId ) > 0 … … 2062 2139 if( pcSlice->getApplyIC() ) 2063 2140 { 2064 WRITE_FLAG( pcSlice->getIcSkipParseFlag() ? 1 : 0, " ic_skip_mergeidx0" );2065 } 2066 } 2067 #endif 2068 #if H_3D_IV_MERGE2141 WRITE_FLAG( pcSlice->getIcSkipParseFlag() ? 1 : 0, "slice_ic_disabled_merge_zero_idx_flag" ); 2142 } 2143 } 2144 #endif 2145 #if NH_3D_IV_MERGE 2069 2146 assert(pcSlice->getMaxNumMergeCand()<=MRG_MAX_NUM_CANDS_MEM); 2070 2147 #else … … 2073 2150 if (!pcSlice->isIntra()) 2074 2151 { 2075 #if H_3D_IV_MERGE2152 #if NH_3D_IV_MERGE 2076 2153 WRITE_UVLC( ( ( pcSlice->getMpiFlag( ) || pcSlice->getIvMvPredFlag( ) || pcSlice->getViewSynthesisPredFlag( ) ) ? MRG_MAX_NUM_CANDS_MEM : MRG_MAX_NUM_CANDS ) - pcSlice->getMaxNumMergeCand(), "five_minus_max_num_merge_cand"); 2077 2154 #else … … 2080 2157 } 2081 2158 Int iCode = pcSlice->getSliceQp() - ( pcSlice->getPPS()->getPicInitQPMinus26() + 26 ); 2082 WRITE_SVLC( iCode, "slice_qp_delta" ); 2159 WRITE_SVLC( iCode, "slice_qp_delta" ); 2083 2160 if (pcSlice->getPPS()->getSliceChromaQpFlag()) 2084 2161 { 2085 iCode = pcSlice->getSliceQpDeltaCb(); 2086 WRITE_SVLC( iCode, "slice_qp_delta_cb" ); 2087 iCode = pcSlice->getSliceQpDeltaCr(); 2088 WRITE_SVLC( iCode, "slice_qp_delta_cr" ); 2089 } 2162 if (numberValidComponents > COMPONENT_Cb) 2163 { 2164 WRITE_SVLC( pcSlice->getSliceChromaQpDelta(COMPONENT_Cb), "slice_cb_qp_offset" ); 2165 } 2166 if (numberValidComponents > COMPONENT_Cr) 2167 { 2168 WRITE_SVLC( pcSlice->getSliceChromaQpDelta(COMPONENT_Cr), "slice_cr_qp_offset" ); 2169 } 2170 assert(numberValidComponents <= COMPONENT_Cr+1); 2171 } 2172 2173 if (pcSlice->getPPS()->getPpsRangeExtension().getChromaQpOffsetListEnabledFlag()) 2174 { 2175 WRITE_FLAG(pcSlice->getUseChromaQpAdj(), "cu_chroma_qp_offset_enabled_flag"); 2176 } 2177 2090 2178 if (pcSlice->getPPS()->getDeblockingFilterControlPresentFlag()) 2091 2179 { … … 2105 2193 } 2106 2194 2107 Bool isSAOEnabled = (!pcSlice->getSPS()->getUseSAO())?(false):(pcSlice->getSaoEnabledFlag()||pcSlice->getSaoEnabledFlagChroma());2195 Bool isSAOEnabled = pcSlice->getSPS()->getUseSAO() && (pcSlice->getSaoEnabledFlag(CHANNEL_TYPE_LUMA) || (chromaEnabled && pcSlice->getSaoEnabledFlag(CHANNEL_TYPE_CHROMA))); 2108 2196 Bool isDBFEnabled = (!pcSlice->getDeblockingFilterDisable()); 2109 2197 … … 2112 2200 WRITE_FLAG(pcSlice->getLFCrossSliceBoundaryFlag()?1:0, "slice_loop_filter_across_slices_enabled_flag"); 2113 2201 } 2114 #if H_3D2202 #if NH_3D 2115 2203 if (getEncTop()->decProcAnnexI() ) 2116 2204 { 2117 2205 Int voiInVps = vps->getVoiInVps( pcSlice->getViewIndex() ); 2206 #if NH_3D_FIX_TICKET_101 2207 if( vps->getCpInSliceSegmentHeaderFlag( voiInVps ) ) 2208 #else 2118 2209 if( vps->getCpInSliceSegmentHeaderFlag( voiInVps ) && !pcSlice->getIsDepth() ) 2210 #endif 2119 2211 { 2120 2212 for( Int m = 0; m < vps->getNumCp( voiInVps ); m++ ) … … 2129 2221 } 2130 2222 #endif 2131 } 2132 2133 2134 2135 #if !H_MV 2223 2224 } 2225 #if !NH_MV 2136 2226 if(pcSlice->getPPS()->getSliceHeaderExtensionPresentFlag()) 2137 2227 { 2138 WRITE_UVLC(0,"slice_ header_extension_length");2228 WRITE_UVLC(0,"slice_segment_header_extension_length"); 2139 2229 } 2140 2230 #else … … 2244 2334 } 2245 2335 #endif 2246 } 2247 2248 Void TEncCavlc::codePTL( TComPTL* pcPTL, Bool profilePresentFlag, Int maxNumSubLayersMinus1) 2336 2337 } 2338 2339 Void TEncCavlc::codePTL( const TComPTL* pcPTL, Bool profilePresentFlag, Int maxNumSubLayersMinus1) 2249 2340 { 2250 2341 if(profilePresentFlag) 2251 2342 { 2252 codeProfileTier(pcPTL->getGeneralPTL() ); // general_...2253 } 2254 WRITE_CODE( pcPTL->getGeneralPTL()->getLevelIdc(), 8, "general_level_idc" );2343 codeProfileTier(pcPTL->getGeneralPTL(), false); // general_... 2344 } 2345 WRITE_CODE( Int(pcPTL->getGeneralPTL()->getLevelIdc()), 8, "general_level_idc" ); 2255 2346 2256 2347 for (Int i = 0; i < maxNumSubLayersMinus1; i++) 2257 2348 { 2258 #if !H_MV 2259 if(profilePresentFlag) 2260 { 2261 #endif 2262 WRITE_FLAG( pcPTL->getSubLayerProfilePresentFlag(i), "sub_layer_profile_present_flag[i]" ); 2263 #if !H_MV 2264 } 2265 #endif 2266 2349 #if !NH_MV 2350 #endif 2351 WRITE_FLAG( pcPTL->getSubLayerProfilePresentFlag(i), "sub_layer_profile_present_flag[i]" ); 2352 #if !NH_MV 2353 #endif 2267 2354 WRITE_FLAG( pcPTL->getSubLayerLevelPresentFlag(i), "sub_layer_level_present_flag[i]" ); 2268 2355 } 2269 2356 2270 2357 if (maxNumSubLayersMinus1 > 0) 2271 2358 { … … 2275 2362 } 2276 2363 } 2277 2364 2278 2365 for(Int i = 0; i < maxNumSubLayersMinus1; i++) 2279 2366 { 2280 if( p rofilePresentFlag && pcPTL->getSubLayerProfilePresentFlag(i) )2281 { 2282 codeProfileTier(pcPTL->getSubLayerPTL(i) ); // sub_layer_...2367 if( pcPTL->getSubLayerProfilePresentFlag(i) ) 2368 { 2369 codeProfileTier(pcPTL->getSubLayerPTL(i), true); // sub_layer_... 2283 2370 } 2284 2371 if( pcPTL->getSubLayerLevelPresentFlag(i) ) 2285 2372 { 2286 WRITE_CODE( pcPTL->getSubLayerPTL(i)->getLevelIdc(), 8, "sub_layer_level_idc[i]" ); 2287 } 2288 } 2289 } 2290 Void TEncCavlc::codeProfileTier( ProfileTierLevel* ptl ) 2291 { 2292 WRITE_CODE( ptl->getProfileSpace(), 2 , "XXX_profile_space[]"); 2293 WRITE_FLAG( ptl->getTierFlag (), "XXX_tier_flag[]" ); 2294 WRITE_CODE( ptl->getProfileIdc (), 5 , "XXX_profile_idc[]" ); 2373 WRITE_CODE( Int(pcPTL->getSubLayerPTL(i)->getLevelIdc()), 8, "sub_layer_level_idc[i]" ); 2374 } 2375 } 2376 } 2377 2378 #if ENC_DEC_TRACE || RExt__DECODER_DEBUG_BIT_STATISTICS 2379 Void TEncCavlc::codeProfileTier( const ProfileTierLevel* ptl, const Bool bIsSubLayer ) 2380 #define PTL_TRACE_TEXT(txt) bIsSubLayer?("sub_layer_" txt) : ("general_" txt) 2381 #else 2382 Void TEncCavlc::codeProfileTier( const ProfileTierLevel* ptl, const Bool /*bIsSubLayer*/ ) 2383 #define PTL_TRACE_TEXT(txt) txt 2384 #endif 2385 { 2386 WRITE_CODE( ptl->getProfileSpace(), 2 , PTL_TRACE_TEXT("profile_space" )); 2387 WRITE_FLAG( ptl->getTierFlag()==Level::HIGH, PTL_TRACE_TEXT("tier_flag" )); 2388 WRITE_CODE( Int(ptl->getProfileIdc()), 5 , PTL_TRACE_TEXT("profile_idc" )); 2295 2389 for(Int j = 0; j < 32; j++) 2296 2390 { 2297 WRITE_FLAG( ptl->getProfileCompatibilityFlag(j), "XXX_profile_compatibility_flag[][j]");2298 } 2299 2300 WRITE_FLAG(ptl->getProgressiveSourceFlag(), "general_progressive_source_flag");2301 WRITE_FLAG(ptl->getInterlacedSourceFlag(), "general_interlaced_source_flag");2302 WRITE_FLAG(ptl->getNonPackedConstraintFlag(), "general_non_packed_constraint_flag");2303 WRITE_FLAG(ptl->getFrameOnlyConstraintFlag(), "general_frame_only_constraint_flag");2304 2305 #if H_MV2391 WRITE_FLAG( ptl->getProfileCompatibilityFlag(j), PTL_TRACE_TEXT("profile_compatibility_flag[][j]" )); 2392 } 2393 2394 WRITE_FLAG(ptl->getProgressiveSourceFlag(), PTL_TRACE_TEXT("progressive_source_flag" )); 2395 WRITE_FLAG(ptl->getInterlacedSourceFlag(), PTL_TRACE_TEXT("interlaced_source_flag" )); 2396 WRITE_FLAG(ptl->getNonPackedConstraintFlag(), PTL_TRACE_TEXT("non_packed_constraint_flag" )); 2397 WRITE_FLAG(ptl->getFrameOnlyConstraintFlag(), PTL_TRACE_TEXT("frame_only_constraint_flag" )); 2398 2399 #if NH_MV 2306 2400 if( ptl->getV2ConstraintsPresentFlag() ) 2307 2401 { … … 2334 2428 } 2335 2429 #else 2336 WRITE_CODE(0 , 16, "XXX_reserved_zero_44bits[0..15]"); 2337 WRITE_CODE(0 , 16, "XXX_reserved_zero_44bits[16..31]"); 2338 WRITE_CODE(0 , 12, "XXX_reserved_zero_44bits[32..43]"); 2430 if (ptl->getProfileIdc() == Profile::MAINREXT || ptl->getProfileIdc() == Profile::HIGHTHROUGHPUTREXT ) 2431 { 2432 const UInt bitDepthConstraint=ptl->getBitDepthConstraint(); 2433 WRITE_FLAG(bitDepthConstraint<=12, PTL_TRACE_TEXT("max_12bit_constraint_flag" )); 2434 WRITE_FLAG(bitDepthConstraint<=10, PTL_TRACE_TEXT("max_10bit_constraint_flag" )); 2435 WRITE_FLAG(bitDepthConstraint<= 8, PTL_TRACE_TEXT("max_8bit_constraint_flag" )); 2436 const ChromaFormat chromaFmtConstraint=ptl->getChromaFormatConstraint(); 2437 WRITE_FLAG(chromaFmtConstraint==CHROMA_422||chromaFmtConstraint==CHROMA_420||chromaFmtConstraint==CHROMA_400, PTL_TRACE_TEXT("max_422chroma_constraint_flag" )); 2438 WRITE_FLAG(chromaFmtConstraint==CHROMA_420||chromaFmtConstraint==CHROMA_400, PTL_TRACE_TEXT("max_420chroma_constraint_flag" )); 2439 WRITE_FLAG(chromaFmtConstraint==CHROMA_400, PTL_TRACE_TEXT("max_monochrome_constraint_flag")); 2440 WRITE_FLAG(ptl->getIntraConstraintFlag(), PTL_TRACE_TEXT("intra_constraint_flag" )); 2441 WRITE_FLAG(ptl->getOnePictureOnlyConstraintFlag(), PTL_TRACE_TEXT("one_picture_only_constraint_flag")); 2442 WRITE_FLAG(ptl->getLowerBitRateConstraintFlag(), PTL_TRACE_TEXT("lower_bit_rate_constraint_flag" )); 2443 WRITE_CODE(0 , 16, PTL_TRACE_TEXT("reserved_zero_34bits[0..15]" )); 2444 WRITE_CODE(0 , 16, PTL_TRACE_TEXT("reserved_zero_34bits[16..31]" )); 2445 WRITE_CODE(0 , 2, PTL_TRACE_TEXT("reserved_zero_34bits[32..33]" )); 2446 } 2447 else 2448 { 2449 WRITE_CODE(0x0000 , 16, PTL_TRACE_TEXT("reserved_zero_43bits[0..15]" )); 2450 WRITE_CODE(0x0000 , 16, PTL_TRACE_TEXT("reserved_zero_43bits[16..31]" )); 2451 WRITE_CODE(0x000 , 11, PTL_TRACE_TEXT("reserved_zero_43bits[32..42]" )); 2452 } 2453 WRITE_FLAG(false, PTL_TRACE_TEXT("inbld_flag" )); 2454 #undef PTL_TRACE_TEXT 2339 2455 #endif 2340 2456 } 2341 2457 2342 2458 /** 2343 - write wavefront substreams sizes for the slice header.2344 .2345 \param pcSlice Where we findthe substream size information.2459 * Write tiles and wavefront substreams sizes for the slice header (entry points). 2460 * 2461 * \param pSlice TComSlice structure that contains the substream size information. 2346 2462 */ 2347 2463 Void TEncCavlc::codeTilesWPPEntryPoint( TComSlice* pSlice ) … … 2351 2467 return; 2352 2468 } 2353 UInt numEntryPointOffsets = 0, offsetLenMinus1 = 0, maxOffset = 0; 2354 Int numZeroSubstreamsAtStartOfSlice = 0; 2355 UInt *entryPointOffset = NULL; 2356 if ( pSlice->getPPS()->getTilesEnabledFlag() ) 2357 { 2358 numEntryPointOffsets = pSlice->getTileLocationCount(); 2359 entryPointOffset = new UInt[numEntryPointOffsets]; 2360 for (Int idx=0; idx<pSlice->getTileLocationCount(); idx++) 2361 { 2362 if ( idx == 0 ) 2363 { 2364 entryPointOffset [ idx ] = pSlice->getTileLocation( 0 ); 2365 } 2366 else 2367 { 2368 entryPointOffset [ idx ] = pSlice->getTileLocation( idx ) - pSlice->getTileLocation( idx-1 ); 2369 } 2370 2371 if ( entryPointOffset[ idx ] > maxOffset ) 2372 { 2373 maxOffset = entryPointOffset[ idx ]; 2374 } 2375 } 2376 } 2377 else if ( pSlice->getPPS()->getEntropyCodingSyncEnabledFlag() ) 2378 { 2379 UInt* pSubstreamSizes = pSlice->getSubstreamSizes(); 2380 Int maxNumParts = pSlice->getPic()->getNumPartInCU(); 2381 numZeroSubstreamsAtStartOfSlice = pSlice->getSliceSegmentCurStartCUAddr()/maxNumParts/pSlice->getPic()->getFrameWidthInCU(); 2382 Int numZeroSubstreamsAtEndOfSlice = pSlice->getPic()->getFrameHeightInCU()-1 - ((pSlice->getSliceSegmentCurEndCUAddr()-1)/maxNumParts/pSlice->getPic()->getFrameWidthInCU()); 2383 numEntryPointOffsets = pSlice->getPPS()->getNumSubstreams() - numZeroSubstreamsAtStartOfSlice - numZeroSubstreamsAtEndOfSlice - 1; 2384 pSlice->setNumEntryPointOffsets(numEntryPointOffsets); 2385 entryPointOffset = new UInt[numEntryPointOffsets]; 2386 for (Int idx=0; idx<numEntryPointOffsets; idx++) 2387 { 2388 entryPointOffset[ idx ] = ( pSubstreamSizes[ idx+numZeroSubstreamsAtStartOfSlice ] >> 3 ) ; 2389 if ( entryPointOffset[ idx ] > maxOffset ) 2390 { 2391 maxOffset = entryPointOffset[ idx ]; 2392 } 2393 } 2394 } 2469 UInt maxOffset = 0; 2470 for(Int idx=0; idx<pSlice->getNumberOfSubstreamSizes(); idx++) 2471 { 2472 UInt offset=pSlice->getSubstreamSize(idx); 2473 if ( offset > maxOffset ) 2474 { 2475 maxOffset = offset; 2476 } 2477 } 2478 2395 2479 // Determine number of bits "offsetLenMinus1+1" required for entry point information 2396 offsetLenMinus1 = 0;2480 UInt offsetLenMinus1 = 0; 2397 2481 while (maxOffset >= (1u << (offsetLenMinus1 + 1))) 2398 2482 { 2399 2483 offsetLenMinus1++; 2400 assert(offsetLenMinus1 + 1 < 32); 2401 } 2402 2403 WRITE_UVLC( numEntryPointOffsets, "num_entry_point_offsets");2404 if ( numEntryPointOffsets>0)2484 assert(offsetLenMinus1 + 1 < 32); 2485 } 2486 2487 WRITE_UVLC(pSlice->getNumberOfSubstreamSizes(), "num_entry_point_offsets"); 2488 if (pSlice->getNumberOfSubstreamSizes()>0) 2405 2489 { 2406 2490 WRITE_UVLC(offsetLenMinus1, "offset_len_minus1"); 2407 } 2408 2409 for (UInt idx=0; idx<numEntryPointOffsets; idx++) 2410 { 2411 WRITE_CODE(entryPointOffset[ idx ]-1, offsetLenMinus1+1, "entry_point_offset_minus1"); 2412 } 2413 2414 delete [] entryPointOffset; 2415 } 2416 2417 Void TEncCavlc::codeTerminatingBit ( UInt uilsLast ) 2491 2492 for (UInt idx=0; idx<pSlice->getNumberOfSubstreamSizes(); idx++) 2493 { 2494 WRITE_CODE(pSlice->getSubstreamSize(idx)-1, offsetLenMinus1+1, "entry_point_offset_minus1"); 2495 } 2496 } 2497 } 2498 2499 Void TEncCavlc::codeTerminatingBit ( UInt /*uilsLast*/ ) 2418 2500 { 2419 2501 } … … 2423 2505 } 2424 2506 2425 Void TEncCavlc::codeMVPIdx ( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList)2507 Void TEncCavlc::codeMVPIdx ( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, RefPicList /*eRefList*/ ) 2426 2508 { 2427 2509 assert(0); 2428 2510 } 2429 2511 2430 Void TEncCavlc::codePartSize( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth)2512 Void TEncCavlc::codePartSize( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) 2431 2513 { 2432 2514 assert(0); 2433 2515 } 2434 2516 2435 Void TEncCavlc::codePredMode( TComDataCU* pcCU, UInt uiAbsPartIdx)2517 Void TEncCavlc::codePredMode( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/ ) 2436 2518 { 2437 2519 assert(0); 2438 2520 } 2439 2521 2440 Void TEncCavlc::codeMergeFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx)2522 Void TEncCavlc::codeMergeFlag ( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/ ) 2441 2523 { 2442 2524 assert(0); 2443 2525 } 2444 2526 2445 Void TEncCavlc::codeMergeIndex ( TComDataCU* pcCU, UInt uiAbsPartIdx)2527 Void TEncCavlc::codeMergeIndex ( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/ ) 2446 2528 { 2447 2529 assert(0); 2448 2530 } 2449 2531 2450 #if H_3D_ARP2532 #if NH_3D_ARP 2451 2533 Void TEncCavlc::codeARPW( TComDataCU* pcCU, UInt uiAbsPartIdx ) 2452 2534 { … … 2455 2537 #endif 2456 2538 2457 #if H_3D_IC2539 #if NH_3D_IC 2458 2540 Void TEncCavlc::codeICFlag( TComDataCU* pcCU, UInt uiAbsPartIdx ) 2459 2541 { … … 2462 2544 #endif 2463 2545 2464 Void TEncCavlc::codeInterModeFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiEncMode)2546 Void TEncCavlc::codeInterModeFlag( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/, UInt /*uiEncMode*/ ) 2465 2547 { 2466 2548 assert(0); 2467 2549 } 2468 2550 2469 Void TEncCavlc::codeCUTransquantBypassFlag( TComDataCU* pcCU, UInt uiAbsPartIdx)2551 Void TEncCavlc::codeCUTransquantBypassFlag( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/ ) 2470 2552 { 2471 2553 assert(0); 2472 2554 } 2473 2555 2474 Void TEncCavlc::codeSkipFlag( TComDataCU* pcCU, UInt uiAbsPartIdx)2556 Void TEncCavlc::codeSkipFlag( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/ ) 2475 2557 { 2476 2558 assert(0); 2477 2559 } 2478 #if H_3D2560 #if NH_3D_DIS 2479 2561 Void TEncCavlc::codeDIS( TComDataCU* pcCU, UInt uiAbsPartIdx ) 2480 2562 { … … 2483 2565 #endif 2484 2566 2485 Void TEncCavlc::codeSplitFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth)2567 Void TEncCavlc::codeSplitFlag ( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) 2486 2568 { 2487 2569 assert(0); 2488 2570 } 2489 2571 2490 Void TEncCavlc::codeTransformSubdivFlag( UInt uiSymbol, UInt uiCtx)2572 Void TEncCavlc::codeTransformSubdivFlag( UInt /*uiSymbol*/, UInt /*uiCtx*/ ) 2491 2573 { 2492 2574 assert(0); 2493 2575 } 2494 2576 2495 Void TEncCavlc::codeQtCbf( TCom DataCU* pcCU, UInt uiAbsPartIdx, TextType eType, UInt uiTrDepth)2577 Void TEncCavlc::codeQtCbf( TComTU& /*rTu*/, const ComponentID /*compID*/, const Bool /*lowestLevel*/ ) 2496 2578 { 2497 2579 assert(0); 2498 2580 } 2499 2581 2500 Void TEncCavlc::codeQtRootCbf( TComDataCU* pcCU, UInt uiAbsPartIdx)2582 Void TEncCavlc::codeQtRootCbf( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/ ) 2501 2583 { 2502 2584 assert(0); 2503 2585 } 2504 2586 2505 Void TEncCavlc::codeQtCbfZero( TCom DataCU* pcCU, TextType eType, UInt uiTrDepth)2587 Void TEncCavlc::codeQtCbfZero( TComTU& /*rTu*/, const ChannelType /*chType*/ ) 2506 2588 { 2507 2589 assert(0); 2508 2590 } 2509 Void TEncCavlc::codeQtRootCbfZero( TComDataCU* pcCU)2591 Void TEncCavlc::codeQtRootCbfZero( ) 2510 2592 { 2511 2593 assert(0); 2512 2594 } 2513 2595 2514 Void TEncCavlc::codeTransformSkipFlags (TCom DataCU* pcCU, UInt uiAbsPartIdx, UInt width, UInt height, TextType eTType)2596 Void TEncCavlc::codeTransformSkipFlags (TComTU& /*rTu*/, ComponentID /*component*/ ) 2515 2597 { 2516 2598 assert(0); … … 2522 2604 * \returns Void 2523 2605 */ 2524 Void TEncCavlc::codeIPCMInfo( TComDataCU* pcCU, UInt uiAbsPartIdx)2606 Void TEncCavlc::codeIPCMInfo( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/ ) 2525 2607 { 2526 2608 assert(0); 2527 2609 } 2528 2610 2529 Void TEncCavlc::codeIntraDirLumaAng( TComDataCU* pcCU, UInt uiAbsPartIdx, Bool isMultiple)2611 Void TEncCavlc::codeIntraDirLumaAng( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, Bool /*isMultiple*/) 2530 2612 { 2531 2613 assert(0); 2532 2614 } 2533 2615 2534 Void TEncCavlc::codeIntraDirChroma( TComDataCU* pcCU, UInt uiAbsPartIdx)2616 Void TEncCavlc::codeIntraDirChroma( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/ ) 2535 2617 { 2536 2618 assert(0); 2537 2619 } 2538 2620 2539 Void TEncCavlc::codeInterDir( TComDataCU* pcCU, UInt uiAbsPartIdx)2621 Void TEncCavlc::codeInterDir( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/ ) 2540 2622 { 2541 2623 assert(0); 2542 2624 } 2543 2625 2544 Void TEncCavlc::codeRefFrmIdx( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList)2626 Void TEncCavlc::codeRefFrmIdx( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, RefPicList /*eRefList*/ ) 2545 2627 { 2546 2628 assert(0); 2547 2629 } 2548 2630 2549 Void TEncCavlc::codeMvd( TComDataCU* pcCU, UInt uiAbsPartIdx, RefPicList eRefList)2631 Void TEncCavlc::codeMvd( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, RefPicList /*eRefList*/ ) 2550 2632 { 2551 2633 assert(0); 2552 2634 } 2553 2635 2636 Void TEncCavlc::codeCrossComponentPrediction( TComTU& /*rTu*/, ComponentID /*compID*/ ) 2637 { 2638 assert(0); 2639 } 2640 2554 2641 Void TEncCavlc::codeDeltaQP( TComDataCU* pcCU, UInt uiAbsPartIdx ) 2555 2642 { 2556 2643 Int iDQp = pcCU->getQP( uiAbsPartIdx ) - pcCU->getRefQP( uiAbsPartIdx ); 2557 2644 2558 Int qpBdOffsetY = pcCU->getSlice()->getSPS()->getQpBDOffset Y();2645 Int qpBdOffsetY = pcCU->getSlice()->getSPS()->getQpBDOffset(CHANNEL_TYPE_LUMA); 2559 2646 iDQp = (iDQp + 78 + qpBdOffsetY + (qpBdOffsetY/2)) % (52 + qpBdOffsetY) - 26 - (qpBdOffsetY/2); 2560 2647 2561 2648 xWriteSvlc( iDQp ); 2562 2649 2563 2650 return; 2564 2651 } 2565 2652 2566 Void TEncCavlc::codeC oeffNxN ( TComDataCU* pcCU, TCoeff* pcCoef, UInt uiAbsPartIdx, UInt uiWidth, UInt uiHeight, UInt uiDepth, TextType eTType)2653 Void TEncCavlc::codeChromaQpAdjustment( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/ ) 2567 2654 { 2568 2655 assert(0); 2569 2656 } 2570 2657 2571 Void TEncCavlc::estBit( estBitsSbacStruct* pcEstBitsCabac, Int width, Int height, TextType eTType ) 2658 Void TEncCavlc::codeCoeffNxN ( TComTU& /*rTu*/, TCoeff* /*pcCoef*/, const ComponentID /*compID*/ ) 2659 { 2660 assert(0); 2661 } 2662 2663 Void TEncCavlc::estBit( estBitsSbacStruct* /*pcEstBitsCabac*/, Int /*width*/, Int /*height*/, ChannelType /*chType*/ ) 2572 2664 { 2573 2665 // printf("error : no VLC mode support in this version\n"); … … 2579 2671 // ==================================================================================================================== 2580 2672 2581 /** code explicit wp tables 2582 * \param TComSlice* pcSlice 2583 * \returns Void 2584 */ 2673 //! Code weighted prediction tables 2585 2674 Void TEncCavlc::xCodePredWeightTable( TComSlice* pcSlice ) 2586 2675 { 2587 wpScalingParam *wp; 2588 #if H_3D_DISABLE_CHROMA 2589 Bool bChroma = !pcSlice->getIsDepth(); // color always present in HEVC ? 2590 #else 2591 Bool bChroma = true; // color always present in HEVC ? 2592 #endif 2593 Int iNbRef = (pcSlice->getSliceType() == B_SLICE ) ? (2) : (1); 2594 Bool bDenomCoded = false; 2595 UInt uiMode = 0; 2596 UInt uiTotalSignalledWeightFlags = 0; 2676 WPScalingParam *wp; 2677 const ChromaFormat format = pcSlice->getPic()->getChromaFormat(); 2678 const UInt numberValidComponents = getNumberValidComponents(format); 2679 const Bool bChroma = isChromaEnabled(format); 2680 const Int iNbRef = (pcSlice->getSliceType() == B_SLICE ) ? (2) : (1); 2681 Bool bDenomCoded = false; 2682 UInt uiTotalSignalledWeightFlags = 0; 2683 2597 2684 if ( (pcSlice->getSliceType()==P_SLICE && pcSlice->getPPS()->getUseWP()) || (pcSlice->getSliceType()==B_SLICE && pcSlice->getPPS()->getWPBiPred()) ) 2598 2685 { 2599 uiMode = 1; // explicit 2600 } 2601 if(uiMode == 1) 2602 { 2603 2604 for ( Int iNumRef=0 ; iNumRef<iNbRef ; iNumRef++ ) 2686 for ( Int iNumRef=0 ; iNumRef<iNbRef ; iNumRef++ ) // loop over l0 and l1 syntax elements 2605 2687 { 2606 2688 RefPicList eRefPicList = ( iNumRef ? REF_PIC_LIST_1 : REF_PIC_LIST_0 ); 2607 2689 2608 for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ ) 2690 // NOTE: wp[].uiLog2WeightDenom and wp[].bPresentFlag are actually per-channel-type settings. 2691 2692 for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ ) 2609 2693 { 2610 2694 pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); 2611 if ( !bDenomCoded ) 2695 if ( !bDenomCoded ) 2612 2696 { 2613 2697 Int iDeltaDenom; 2614 WRITE_UVLC( wp[ 0].uiLog2WeightDenom, "luma_log2_weight_denom" ); // ue(v): luma_log2_weight_denom2698 WRITE_UVLC( wp[COMPONENT_Y].uiLog2WeightDenom, "luma_log2_weight_denom" ); 2615 2699 2616 2700 if( bChroma ) 2617 2701 { 2618 iDeltaDenom = (wp[1].uiLog2WeightDenom - wp[0].uiLog2WeightDenom); 2619 WRITE_SVLC( iDeltaDenom, "delta_chroma_log2_weight_denom" ); // se(v): delta_chroma_log2_weight_denom 2702 assert(wp[COMPONENT_Cb].uiLog2WeightDenom == wp[COMPONENT_Cr].uiLog2WeightDenom); // check the channel-type settings are consistent across components. 2703 iDeltaDenom = (wp[COMPONENT_Cb].uiLog2WeightDenom - wp[COMPONENT_Y].uiLog2WeightDenom); 2704 WRITE_SVLC( iDeltaDenom, "delta_chroma_log2_weight_denom" ); 2620 2705 } 2621 2706 bDenomCoded = true; 2622 2707 } 2623 WRITE_FLAG( wp[ 0].bPresentFlag, "luma_weight_lX_flag" ); // u(1): luma_weight_lX_flag2624 uiTotalSignalledWeightFlags += wp[ 0].bPresentFlag;2625 } 2626 if (bChroma) 2627 { 2628 for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ ) 2708 WRITE_FLAG( wp[COMPONENT_Y].bPresentFlag, iNumRef==0?"luma_weight_l0_flag[i]":"luma_weight_l1_flag[i]" ); 2709 uiTotalSignalledWeightFlags += wp[COMPONENT_Y].bPresentFlag; 2710 } 2711 if (bChroma) 2712 { 2713 for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ ) 2629 2714 { 2630 2715 pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); 2631 WRITE_FLAG( wp[1].bPresentFlag, "chroma_weight_lX_flag" ); // u(1): chroma_weight_lX_flag 2632 uiTotalSignalledWeightFlags += 2*wp[1].bPresentFlag; 2633 } 2634 } 2635 2636 for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ ) 2716 assert(wp[COMPONENT_Cb].bPresentFlag == wp[COMPONENT_Cr].bPresentFlag); // check the channel-type settings are consistent across components. 2717 WRITE_FLAG( wp[COMPONENT_Cb].bPresentFlag, iNumRef==0?"chroma_weight_l0_flag[i]":"chroma_weight_l1_flag[i]" ); 2718 uiTotalSignalledWeightFlags += 2*wp[COMPONENT_Cb].bPresentFlag; 2719 } 2720 } 2721 2722 for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ ) 2637 2723 { 2638 2724 pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); 2639 if ( wp[ 0].bPresentFlag )2640 { 2641 Int iDeltaWeight = (wp[ 0].iWeight - (1<<wp[0].uiLog2WeightDenom));2642 WRITE_SVLC( iDeltaWeight, "delta_luma_weight_lX" ); // se(v): delta_luma_weight_lX2643 WRITE_SVLC( wp[ 0].iOffset, "luma_offset_lX" ); // se(v): luma_offset_lX2644 } 2645 2646 if ( bChroma ) 2647 { 2648 if ( wp[ 1].bPresentFlag )2725 if ( wp[COMPONENT_Y].bPresentFlag ) 2726 { 2727 Int iDeltaWeight = (wp[COMPONENT_Y].iWeight - (1<<wp[COMPONENT_Y].uiLog2WeightDenom)); 2728 WRITE_SVLC( iDeltaWeight, iNumRef==0?"delta_luma_weight_l0[i]":"delta_luma_weight_l1[i]" ); 2729 WRITE_SVLC( wp[COMPONENT_Y].iOffset, iNumRef==0?"luma_offset_l0[i]":"luma_offset_l1[i]" ); 2730 } 2731 2732 if ( bChroma ) 2733 { 2734 if ( wp[COMPONENT_Cb].bPresentFlag ) 2649 2735 { 2650 for ( Int j =1 ; j<3 ; j++ )2736 for ( Int j = COMPONENT_Cb ; j < numberValidComponents ; j++ ) 2651 2737 { 2652 Int iDeltaWeight = (wp[j].iWeight - (1<<wp[1].uiLog2WeightDenom)); 2653 WRITE_SVLC( iDeltaWeight, "delta_chroma_weight_lX" ); // se(v): delta_chroma_weight_lX 2654 2655 Int pred = ( 128 - ( ( 128*wp[j].iWeight)>>(wp[j].uiLog2WeightDenom) ) ); 2738 assert(wp[COMPONENT_Cb].uiLog2WeightDenom == wp[COMPONENT_Cr].uiLog2WeightDenom); 2739 Int iDeltaWeight = (wp[j].iWeight - (1<<wp[COMPONENT_Cb].uiLog2WeightDenom)); 2740 WRITE_SVLC( iDeltaWeight, iNumRef==0?"delta_chroma_weight_l0[i]":"delta_chroma_weight_l1[i]" ); 2741 2742 Int range=pcSlice->getSPS()->getSpsRangeExtension().getHighPrecisionOffsetsEnabledFlag() ? (1<<pcSlice->getSPS()->getBitDepth(CHANNEL_TYPE_CHROMA))/2 : 128; 2743 Int pred = ( range - ( ( range*wp[j].iWeight)>>(wp[j].uiLog2WeightDenom) ) ); 2656 2744 Int iDeltaChroma = (wp[j].iOffset - pred); 2657 WRITE_SVLC( iDeltaChroma, "delta_chroma_offset_lX" ); // se(v): delta_chroma_offset_lX2745 WRITE_SVLC( iDeltaChroma, iNumRef==0?"delta_chroma_offset_l0[i]":"delta_chroma_offset_l1[i]" ); 2658 2746 } 2659 2747 } … … 2668 2756 * \param scalingList quantization matrix information 2669 2757 */ 2670 Void TEncCavlc::codeScalingList( TComScalingList* scalingList ) 2671 { 2672 UInt listId,sizeId; 2673 Bool scalingListPredModeFlag; 2674 2675 //for each size 2676 for(sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) 2677 { 2678 for(listId = 0; listId < g_scalingListNum[sizeId]; listId++) 2679 { 2680 scalingListPredModeFlag = scalingList->checkPredMode( sizeId, listId ); 2681 WRITE_FLAG( scalingListPredModeFlag, "scaling_list_pred_mode_flag" ); 2682 if(!scalingListPredModeFlag)// Copy Mode 2683 { 2684 WRITE_UVLC( (Int)listId - (Int)scalingList->getRefMatrixId (sizeId,listId), "scaling_list_pred_matrix_id_delta"); 2685 } 2686 else// DPCM Mode 2687 { 2688 xCodeScalingList(scalingList, sizeId, listId); 2689 } 2690 } 2691 } 2758 Void TEncCavlc::codeScalingList( const TComScalingList &scalingList ) 2759 { 2760 //for each size 2761 for(UInt sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) 2762 { 2763 const Int predListStep = (sizeId == SCALING_LIST_32x32? (SCALING_LIST_NUM/NUMBER_OF_PREDICTION_MODES) : 1); // if 32x32, skip over chroma entries. 2764 2765 for(UInt listId = 0; listId < SCALING_LIST_NUM; listId+=predListStep) 2766 { 2767 Bool scalingListPredModeFlag = scalingList.getScalingListPredModeFlag(sizeId, listId); 2768 WRITE_FLAG( scalingListPredModeFlag, "scaling_list_pred_mode_flag" ); 2769 if(!scalingListPredModeFlag)// Copy Mode 2770 { 2771 if (sizeId == SCALING_LIST_32x32) 2772 { 2773 // adjust the code, to cope with the missing chroma entries 2774 WRITE_UVLC( ((Int)listId - (Int)scalingList.getRefMatrixId (sizeId,listId)) / (SCALING_LIST_NUM/NUMBER_OF_PREDICTION_MODES), "scaling_list_pred_matrix_id_delta"); 2775 } 2776 else 2777 { 2778 WRITE_UVLC( (Int)listId - (Int)scalingList.getRefMatrixId (sizeId,listId), "scaling_list_pred_matrix_id_delta"); 2779 } 2780 } 2781 else// DPCM Mode 2782 { 2783 xCodeScalingList(&scalingList, sizeId, listId); 2784 } 2785 } 2786 } 2692 2787 return; 2693 2788 } 2694 2789 /** code DPCM 2695 2790 * \param scalingList quantization matrix information 2696 * \param sizeId csize index2697 * \param listId clist index2791 * \param sizeId size index 2792 * \param listId list index 2698 2793 */ 2699 Void TEncCavlc::xCodeScalingList( TComScalingList* scalingList, UInt sizeId, UInt listId)2794 Void TEncCavlc::xCodeScalingList(const TComScalingList* scalingList, UInt sizeId, UInt listId) 2700 2795 { 2701 2796 Int coefNum = min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId]); 2702 UInt* scan = (sizeId == 0) ? g_auiSigLastScan [ SCAN_DIAG ] [ 1 ] : g_sigLastScanCG32x32;2797 UInt* scan = g_scanOrder[SCAN_UNGROUPED][SCAN_DIAG][sizeId==0 ? 2 : 3][sizeId==0 ? 2 : 3]; 2703 2798 Int nextCoef = SCALING_LIST_START_VALUE; 2704 2799 Int data; 2705 Int *src = scalingList->getScalingListAddress(sizeId, listId);2800 const Int *src = scalingList->getScalingListAddress(sizeId, listId); 2706 2801 if( sizeId > SCALING_LIST_8x8 ) 2707 2802 { … … 2739 2834 return false; 2740 2835 } 2741 Bool TComScalingList::checkPredMode(UInt sizeId, UInt listId) 2742 { 2743 for(Int predListIdx = (Int)listId ; predListIdx >= 0; predListIdx--) 2744 { 2745 if( !memcmp(getScalingListAddress(sizeId,listId),((listId == predListIdx) ? 2746 getScalingListDefaultAddress(sizeId, predListIdx): getScalingListAddress(sizeId, predListIdx)),sizeof(Int)*min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId])) // check value of matrix 2747 && ((sizeId < SCALING_LIST_16x16) || (getScalingListDC(sizeId,listId) == getScalingListDC(sizeId,predListIdx)))) // check DC value 2748 { 2749 setRefMatrixId(sizeId, listId, predListIdx); 2750 return false; 2751 } 2752 } 2753 return true; 2754 } 2755 2756 #if H_3D_INTER_SDC 2757 Void TEncCavlc::codeDeltaDC( TComDataCU* pcCU, UInt uiAbsPartIdx ) 2836 2837 Void TEncCavlc::codeExplicitRdpcmMode( TComTU& /*rTu*/, const ComponentID /*compID*/ ) 2838 { 2839 assert(0); 2840 } 2841 #if NH_3D_SDC_INTRA || NH_3D_SDC_INTER 2842 Void TEncCavlc::codeSDCFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx ) 2758 2843 { 2759 2844 assert(0); 2760 2845 } 2761 2762 Void TEncCavlc::codeSDCFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx ) 2846 #endif 2847 2848 #if NH_3D_DBBP 2849 Void TEncCavlc::codeDBBPFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx ) 2763 2850 { 2764 2851 assert(0); 2765 2852 } 2766 2767 #endif 2768 2769 #if H_3D_DBBP 2770 Void TEncCavlc::codeDBBPFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx ) 2771 { 2772 assert(0); 2773 } 2774 #endif 2853 #endif 2854 2855 2775 2856 //! \}
Note: See TracChangeset for help on using the changeset viewer.