[313] | 1 | /* The copyright in this software is being made available under the BSD |
---|
| 2 | * License, included below. This software may be subject to other third party |
---|
| 3 | * and contributor rights, including patent rights, and no such rights are |
---|
| 4 | * granted under this license. |
---|
| 5 | * |
---|
[595] | 6 | * Copyright (c) 2010-2014, ITU/ISO/IEC |
---|
[313] | 7 | * All rights reserved. |
---|
| 8 | * |
---|
| 9 | * Redistribution and use in source and binary forms, with or without |
---|
| 10 | * modification, are permitted provided that the following conditions are met: |
---|
| 11 | * |
---|
| 12 | * * Redistributions of source code must retain the above copyright notice, |
---|
| 13 | * this list of conditions and the following disclaimer. |
---|
| 14 | * * Redistributions in binary form must reproduce the above copyright notice, |
---|
| 15 | * this list of conditions and the following disclaimer in the documentation |
---|
| 16 | * and/or other materials provided with the distribution. |
---|
| 17 | * * Neither the name of the ITU/ISO/IEC nor the names of its contributors may |
---|
| 18 | * be used to endorse or promote products derived from this software without |
---|
| 19 | * specific prior written permission. |
---|
| 20 | * |
---|
| 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
---|
| 22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
---|
| 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
---|
| 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS |
---|
| 25 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
---|
| 26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
---|
| 27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
---|
| 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
---|
| 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
---|
| 30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
---|
| 31 | * THE POSSIBILITY OF SUCH DAMAGE. |
---|
| 32 | */ |
---|
| 33 | |
---|
| 34 | /** \file TDecCAVLC.cpp |
---|
| 35 | \brief CAVLC decoder class |
---|
| 36 | */ |
---|
| 37 | |
---|
| 38 | #include "TDecCAVLC.h" |
---|
| 39 | #include "SEIread.h" |
---|
| 40 | #include "TDecSlice.h" |
---|
[713] | 41 | #if Q0048_CGS_3D_ASYMLUT |
---|
| 42 | #include "../TLibCommon/TCom3DAsymLUT.h" |
---|
| 43 | #endif |
---|
[313] | 44 | |
---|
| 45 | //! \ingroup TLibDecoder |
---|
| 46 | //! \{ |
---|
| 47 | |
---|
| 48 | #if ENC_DEC_TRACE |
---|
| 49 | |
---|
| 50 | Void xTraceSPSHeader (TComSPS *pSPS) |
---|
| 51 | { |
---|
| 52 | fprintf( g_hTrace, "=========== Sequence Parameter Set ID: %d ===========\n", pSPS->getSPSId() ); |
---|
| 53 | } |
---|
| 54 | |
---|
| 55 | Void xTracePPSHeader (TComPPS *pPPS) |
---|
| 56 | { |
---|
| 57 | fprintf( g_hTrace, "=========== Picture Parameter Set ID: %d ===========\n", pPPS->getPPSId() ); |
---|
| 58 | } |
---|
| 59 | |
---|
| 60 | Void xTraceSliceHeader (TComSlice *pSlice) |
---|
| 61 | { |
---|
| 62 | fprintf( g_hTrace, "=========== Slice ===========\n"); |
---|
| 63 | } |
---|
| 64 | |
---|
| 65 | #endif |
---|
| 66 | |
---|
| 67 | // ==================================================================================================================== |
---|
| 68 | // Constructor / destructor / create / destroy |
---|
| 69 | // ==================================================================================================================== |
---|
| 70 | |
---|
| 71 | TDecCavlc::TDecCavlc() |
---|
| 72 | { |
---|
| 73 | } |
---|
| 74 | |
---|
| 75 | TDecCavlc::~TDecCavlc() |
---|
| 76 | { |
---|
| 77 | |
---|
| 78 | } |
---|
| 79 | |
---|
| 80 | // ==================================================================================================================== |
---|
| 81 | // Public member functions |
---|
| 82 | // ==================================================================================================================== |
---|
| 83 | |
---|
| 84 | void TDecCavlc::parseShortTermRefPicSet( TComSPS* sps, TComReferencePictureSet* rps, Int idx ) |
---|
| 85 | { |
---|
| 86 | UInt code; |
---|
| 87 | UInt interRPSPred; |
---|
| 88 | if (idx > 0) |
---|
| 89 | { |
---|
| 90 | READ_FLAG(interRPSPred, "inter_ref_pic_set_prediction_flag"); rps->setInterRPSPrediction(interRPSPred); |
---|
| 91 | } |
---|
| 92 | else |
---|
| 93 | { |
---|
| 94 | interRPSPred = false; |
---|
| 95 | rps->setInterRPSPrediction(false); |
---|
| 96 | } |
---|
| 97 | |
---|
| 98 | if (interRPSPred) |
---|
| 99 | { |
---|
| 100 | UInt bit; |
---|
| 101 | if(idx == sps->getRPSList()->getNumberOfReferencePictureSets()) |
---|
| 102 | { |
---|
| 103 | READ_UVLC(code, "delta_idx_minus1" ); // delta index of the Reference Picture Set used for prediction minus 1 |
---|
| 104 | } |
---|
| 105 | else |
---|
| 106 | { |
---|
| 107 | code = 0; |
---|
| 108 | } |
---|
| 109 | assert(code <= idx-1); // delta_idx_minus1 shall not be larger than idx-1, otherwise we will predict from a negative row position that does not exist. When idx equals 0 there is no legal value and interRPSPred must be zero. See J0185-r2 |
---|
| 110 | Int rIdx = idx - 1 - code; |
---|
| 111 | assert (rIdx <= idx-1 && rIdx >= 0); // Made assert tighter; if rIdx = idx then prediction is done from itself. rIdx must belong to range 0, idx-1, inclusive, see J0185-r2 |
---|
| 112 | TComReferencePictureSet* rpsRef = sps->getRPSList()->getReferencePictureSet(rIdx); |
---|
| 113 | Int k = 0, k0 = 0, k1 = 0; |
---|
| 114 | READ_CODE(1, bit, "delta_rps_sign"); // delta_RPS_sign |
---|
| 115 | READ_UVLC(code, "abs_delta_rps_minus1"); // absolute delta RPS minus 1 |
---|
| 116 | Int deltaRPS = (1 - 2 * bit) * (code + 1); // delta_RPS |
---|
| 117 | for(Int j=0 ; j <= rpsRef->getNumberOfPictures(); j++) |
---|
| 118 | { |
---|
| 119 | READ_CODE(1, bit, "used_by_curr_pic_flag" ); //first bit is "1" if Idc is 1 |
---|
| 120 | Int refIdc = bit; |
---|
| 121 | if (refIdc == 0) |
---|
| 122 | { |
---|
| 123 | READ_CODE(1, bit, "use_delta_flag" ); //second bit is "1" if Idc is 2, "0" otherwise. |
---|
| 124 | refIdc = bit<<1; //second bit is "1" if refIdc is 2, "0" if refIdc = 0. |
---|
| 125 | } |
---|
| 126 | if (refIdc == 1 || refIdc == 2) |
---|
| 127 | { |
---|
| 128 | Int deltaPOC = deltaRPS + ((j < rpsRef->getNumberOfPictures())? rpsRef->getDeltaPOC(j) : 0); |
---|
| 129 | rps->setDeltaPOC(k, deltaPOC); |
---|
| 130 | rps->setUsed(k, (refIdc == 1)); |
---|
| 131 | |
---|
| 132 | if (deltaPOC < 0) |
---|
| 133 | { |
---|
| 134 | k0++; |
---|
| 135 | } |
---|
| 136 | else |
---|
| 137 | { |
---|
| 138 | k1++; |
---|
| 139 | } |
---|
| 140 | k++; |
---|
| 141 | } |
---|
| 142 | rps->setRefIdc(j,refIdc); |
---|
| 143 | } |
---|
| 144 | rps->setNumRefIdc(rpsRef->getNumberOfPictures()+1); |
---|
| 145 | rps->setNumberOfPictures(k); |
---|
| 146 | rps->setNumberOfNegativePictures(k0); |
---|
| 147 | rps->setNumberOfPositivePictures(k1); |
---|
| 148 | rps->sortDeltaPOC(); |
---|
| 149 | } |
---|
| 150 | else |
---|
| 151 | { |
---|
| 152 | READ_UVLC(code, "num_negative_pics"); rps->setNumberOfNegativePictures(code); |
---|
| 153 | READ_UVLC(code, "num_positive_pics"); rps->setNumberOfPositivePictures(code); |
---|
| 154 | Int prev = 0; |
---|
| 155 | Int poc; |
---|
| 156 | for(Int j=0 ; j < rps->getNumberOfNegativePictures(); j++) |
---|
| 157 | { |
---|
| 158 | READ_UVLC(code, "delta_poc_s0_minus1"); |
---|
| 159 | poc = prev-code-1; |
---|
| 160 | prev = poc; |
---|
| 161 | rps->setDeltaPOC(j,poc); |
---|
| 162 | READ_FLAG(code, "used_by_curr_pic_s0_flag"); rps->setUsed(j,code); |
---|
| 163 | } |
---|
| 164 | prev = 0; |
---|
| 165 | for(Int j=rps->getNumberOfNegativePictures(); j < rps->getNumberOfNegativePictures()+rps->getNumberOfPositivePictures(); j++) |
---|
| 166 | { |
---|
| 167 | READ_UVLC(code, "delta_poc_s1_minus1"); |
---|
| 168 | poc = prev+code+1; |
---|
| 169 | prev = poc; |
---|
| 170 | rps->setDeltaPOC(j,poc); |
---|
| 171 | READ_FLAG(code, "used_by_curr_pic_s1_flag"); rps->setUsed(j,code); |
---|
| 172 | } |
---|
| 173 | rps->setNumberOfPictures(rps->getNumberOfNegativePictures()+rps->getNumberOfPositivePictures()); |
---|
| 174 | } |
---|
| 175 | #if PRINT_RPS_INFO |
---|
| 176 | rps->printDeltaPOC(); |
---|
| 177 | #endif |
---|
| 178 | } |
---|
| 179 | |
---|
[713] | 180 | Void TDecCavlc::parsePPS(TComPPS* pcPPS |
---|
| 181 | #if Q0048_CGS_3D_ASYMLUT |
---|
| 182 | , TCom3DAsymLUT * pc3DAsymLUT , Int nLayerID |
---|
| 183 | #endif |
---|
| 184 | ) |
---|
[313] | 185 | { |
---|
| 186 | #if ENC_DEC_TRACE |
---|
| 187 | xTracePPSHeader (pcPPS); |
---|
| 188 | #endif |
---|
| 189 | UInt uiCode; |
---|
| 190 | |
---|
| 191 | Int iCode; |
---|
| 192 | |
---|
| 193 | READ_UVLC( uiCode, "pps_pic_parameter_set_id"); |
---|
| 194 | assert(uiCode <= 63); |
---|
| 195 | pcPPS->setPPSId (uiCode); |
---|
[494] | 196 | |
---|
[313] | 197 | READ_UVLC( uiCode, "pps_seq_parameter_set_id"); |
---|
| 198 | assert(uiCode <= 15); |
---|
| 199 | pcPPS->setSPSId (uiCode); |
---|
[494] | 200 | |
---|
[313] | 201 | READ_FLAG( uiCode, "dependent_slice_segments_enabled_flag" ); pcPPS->setDependentSliceSegmentsEnabledFlag ( uiCode == 1 ); |
---|
| 202 | READ_FLAG( uiCode, "output_flag_present_flag" ); pcPPS->setOutputFlagPresentFlag( uiCode==1 ); |
---|
| 203 | |
---|
| 204 | READ_CODE(3, uiCode, "num_extra_slice_header_bits"); pcPPS->setNumExtraSliceHeaderBits(uiCode); |
---|
| 205 | READ_FLAG ( uiCode, "sign_data_hiding_flag" ); pcPPS->setSignHideFlag( uiCode ); |
---|
| 206 | |
---|
| 207 | READ_FLAG( uiCode, "cabac_init_present_flag" ); pcPPS->setCabacInitPresentFlag( uiCode ? true : false ); |
---|
| 208 | |
---|
| 209 | READ_UVLC(uiCode, "num_ref_idx_l0_default_active_minus1"); |
---|
| 210 | assert(uiCode <= 14); |
---|
| 211 | pcPPS->setNumRefIdxL0DefaultActive(uiCode+1); |
---|
| 212 | |
---|
| 213 | READ_UVLC(uiCode, "num_ref_idx_l1_default_active_minus1"); |
---|
| 214 | assert(uiCode <= 14); |
---|
| 215 | pcPPS->setNumRefIdxL1DefaultActive(uiCode+1); |
---|
| 216 | |
---|
| 217 | READ_SVLC(iCode, "init_qp_minus26" ); pcPPS->setPicInitQPMinus26(iCode); |
---|
| 218 | READ_FLAG( uiCode, "constrained_intra_pred_flag" ); pcPPS->setConstrainedIntraPred( uiCode ? true : false ); |
---|
| 219 | READ_FLAG( uiCode, "transform_skip_enabled_flag" ); |
---|
| 220 | pcPPS->setUseTransformSkip ( uiCode ? true : false ); |
---|
| 221 | |
---|
| 222 | READ_FLAG( uiCode, "cu_qp_delta_enabled_flag" ); pcPPS->setUseDQP( uiCode ? true : false ); |
---|
| 223 | if( pcPPS->getUseDQP() ) |
---|
| 224 | { |
---|
| 225 | READ_UVLC( uiCode, "diff_cu_qp_delta_depth" ); |
---|
| 226 | pcPPS->setMaxCuDQPDepth( uiCode ); |
---|
| 227 | } |
---|
| 228 | else |
---|
| 229 | { |
---|
| 230 | pcPPS->setMaxCuDQPDepth( 0 ); |
---|
| 231 | } |
---|
| 232 | READ_SVLC( iCode, "pps_cb_qp_offset"); |
---|
| 233 | pcPPS->setChromaCbQpOffset(iCode); |
---|
| 234 | assert( pcPPS->getChromaCbQpOffset() >= -12 ); |
---|
| 235 | assert( pcPPS->getChromaCbQpOffset() <= 12 ); |
---|
| 236 | |
---|
| 237 | READ_SVLC( iCode, "pps_cr_qp_offset"); |
---|
| 238 | pcPPS->setChromaCrQpOffset(iCode); |
---|
| 239 | assert( pcPPS->getChromaCrQpOffset() >= -12 ); |
---|
| 240 | assert( pcPPS->getChromaCrQpOffset() <= 12 ); |
---|
| 241 | |
---|
| 242 | READ_FLAG( uiCode, "pps_slice_chroma_qp_offsets_present_flag" ); |
---|
| 243 | pcPPS->setSliceChromaQpFlag( uiCode ? true : false ); |
---|
| 244 | |
---|
| 245 | READ_FLAG( uiCode, "weighted_pred_flag" ); // Use of Weighting Prediction (P_SLICE) |
---|
| 246 | pcPPS->setUseWP( uiCode==1 ); |
---|
| 247 | READ_FLAG( uiCode, "weighted_bipred_flag" ); // Use of Bi-Directional Weighting Prediction (B_SLICE) |
---|
| 248 | pcPPS->setWPBiPred( uiCode==1 ); |
---|
| 249 | |
---|
| 250 | READ_FLAG( uiCode, "transquant_bypass_enable_flag"); |
---|
| 251 | pcPPS->setTransquantBypassEnableFlag(uiCode ? true : false); |
---|
| 252 | READ_FLAG( uiCode, "tiles_enabled_flag" ); pcPPS->setTilesEnabledFlag ( uiCode == 1 ); |
---|
| 253 | READ_FLAG( uiCode, "entropy_coding_sync_enabled_flag" ); pcPPS->setEntropyCodingSyncEnabledFlag( uiCode == 1 ); |
---|
| 254 | |
---|
| 255 | if( pcPPS->getTilesEnabledFlag() ) |
---|
| 256 | { |
---|
| 257 | READ_UVLC ( uiCode, "num_tile_columns_minus1" ); pcPPS->setNumColumnsMinus1( uiCode ); |
---|
| 258 | READ_UVLC ( uiCode, "num_tile_rows_minus1" ); pcPPS->setNumRowsMinus1( uiCode ); |
---|
| 259 | READ_FLAG ( uiCode, "uniform_spacing_flag" ); pcPPS->setUniformSpacingFlag( uiCode ); |
---|
| 260 | |
---|
| 261 | if( !pcPPS->getUniformSpacingFlag()) |
---|
| 262 | { |
---|
| 263 | UInt* columnWidth = (UInt*)malloc(pcPPS->getNumColumnsMinus1()*sizeof(UInt)); |
---|
| 264 | for(UInt i=0; i<pcPPS->getNumColumnsMinus1(); i++) |
---|
| 265 | { |
---|
| 266 | READ_UVLC( uiCode, "column_width_minus1" ); |
---|
| 267 | columnWidth[i] = uiCode+1; |
---|
| 268 | } |
---|
| 269 | pcPPS->setColumnWidth(columnWidth); |
---|
| 270 | free(columnWidth); |
---|
| 271 | |
---|
| 272 | UInt* rowHeight = (UInt*)malloc(pcPPS->getNumRowsMinus1()*sizeof(UInt)); |
---|
| 273 | for(UInt i=0; i<pcPPS->getNumRowsMinus1(); i++) |
---|
| 274 | { |
---|
| 275 | READ_UVLC( uiCode, "row_height_minus1" ); |
---|
| 276 | rowHeight[i] = uiCode + 1; |
---|
| 277 | } |
---|
| 278 | pcPPS->setRowHeight(rowHeight); |
---|
| 279 | free(rowHeight); |
---|
| 280 | } |
---|
| 281 | |
---|
| 282 | if(pcPPS->getNumColumnsMinus1() !=0 || pcPPS->getNumRowsMinus1() !=0) |
---|
| 283 | { |
---|
| 284 | READ_FLAG ( uiCode, "loop_filter_across_tiles_enabled_flag" ); pcPPS->setLoopFilterAcrossTilesEnabledFlag( uiCode ? true : false ); |
---|
| 285 | } |
---|
| 286 | } |
---|
| 287 | READ_FLAG( uiCode, "loop_filter_across_slices_enabled_flag" ); pcPPS->setLoopFilterAcrossSlicesEnabledFlag( uiCode ? true : false ); |
---|
| 288 | READ_FLAG( uiCode, "deblocking_filter_control_present_flag" ); pcPPS->setDeblockingFilterControlPresentFlag( uiCode ? true : false ); |
---|
| 289 | if(pcPPS->getDeblockingFilterControlPresentFlag()) |
---|
| 290 | { |
---|
| 291 | READ_FLAG( uiCode, "deblocking_filter_override_enabled_flag" ); pcPPS->setDeblockingFilterOverrideEnabledFlag( uiCode ? true : false ); |
---|
| 292 | READ_FLAG( uiCode, "pps_disable_deblocking_filter_flag" ); pcPPS->setPicDisableDeblockingFilterFlag(uiCode ? true : false ); |
---|
| 293 | if(!pcPPS->getPicDisableDeblockingFilterFlag()) |
---|
| 294 | { |
---|
| 295 | READ_SVLC ( iCode, "pps_beta_offset_div2" ); pcPPS->setDeblockingFilterBetaOffsetDiv2( iCode ); |
---|
| 296 | READ_SVLC ( iCode, "pps_tc_offset_div2" ); pcPPS->setDeblockingFilterTcOffsetDiv2( iCode ); |
---|
| 297 | } |
---|
| 298 | } |
---|
[442] | 299 | |
---|
[540] | 300 | #if SCALINGLIST_INFERRING |
---|
| 301 | if( pcPPS->getLayerId() > 0 ) |
---|
| 302 | { |
---|
| 303 | READ_FLAG( uiCode, "pps_infer_scaling_list_flag" ); |
---|
| 304 | pcPPS->setInferScalingListFlag( uiCode ); |
---|
| 305 | } |
---|
[442] | 306 | |
---|
[540] | 307 | if( pcPPS->getInferScalingListFlag() ) |
---|
[313] | 308 | { |
---|
[540] | 309 | READ_UVLC( uiCode, "pps_scaling_list_ref_layer_id" ); pcPPS->setScalingListRefLayerId( uiCode ); |
---|
[442] | 310 | |
---|
[540] | 311 | // The value of pps_scaling_list_ref_layer_id shall be in the range of 0 to 62, inclusive |
---|
| 312 | assert( pcPPS->getScalingListRefLayerId() <= 62 ); |
---|
[494] | 313 | |
---|
[540] | 314 | pcPPS->setScalingListPresentFlag( false ); |
---|
| 315 | } |
---|
| 316 | else |
---|
| 317 | { |
---|
| 318 | #endif |
---|
[442] | 319 | |
---|
[540] | 320 | READ_FLAG( uiCode, "pps_scaling_list_data_present_flag" ); pcPPS->setScalingListPresentFlag( uiCode ? true : false ); |
---|
[442] | 321 | |
---|
[540] | 322 | if(pcPPS->getScalingListPresentFlag ()) |
---|
| 323 | { |
---|
[313] | 324 | parseScalingList( pcPPS->getScalingList() ); |
---|
| 325 | } |
---|
| 326 | |
---|
[540] | 327 | #if SCALINGLIST_INFERRING |
---|
| 328 | } |
---|
| 329 | #endif |
---|
| 330 | |
---|
[313] | 331 | READ_FLAG( uiCode, "lists_modification_present_flag"); |
---|
| 332 | pcPPS->setListsModificationPresentFlag(uiCode); |
---|
| 333 | |
---|
| 334 | READ_UVLC( uiCode, "log2_parallel_merge_level_minus2"); |
---|
| 335 | pcPPS->setLog2ParallelMergeLevelMinus2 (uiCode); |
---|
| 336 | |
---|
| 337 | READ_FLAG( uiCode, "slice_segment_header_extension_present_flag"); |
---|
| 338 | pcPPS->setSliceHeaderExtensionPresentFlag(uiCode); |
---|
| 339 | |
---|
| 340 | READ_FLAG( uiCode, "pps_extension_flag"); |
---|
[815] | 341 | #if POC_RESET_INFO_INFERENCE |
---|
| 342 | pcPPS->setExtensionFlag( uiCode ? true : false ); |
---|
| 343 | |
---|
| 344 | if( pcPPS->getExtensionFlag() ) |
---|
| 345 | #else |
---|
[313] | 346 | if (uiCode) |
---|
[815] | 347 | #endif |
---|
[313] | 348 | { |
---|
[644] | 349 | #if P0166_MODIFIED_PPS_EXTENSION |
---|
| 350 | UInt ppsExtensionTypeFlag[8]; |
---|
| 351 | for (UInt i = 0; i < 8; i++) |
---|
| 352 | { |
---|
| 353 | READ_FLAG( ppsExtensionTypeFlag[i], "pps_extension_type_flag" ); |
---|
| 354 | } |
---|
| 355 | #if !POC_RESET_IDC |
---|
| 356 | if (ppsExtensionTypeFlag[1]) |
---|
| 357 | { |
---|
| 358 | #else |
---|
| 359 | if( ppsExtensionTypeFlag[0] ) |
---|
| 360 | { |
---|
| 361 | READ_FLAG( uiCode, "poc_reset_info_present_flag" ); |
---|
| 362 | pcPPS->setPocResetInfoPresentFlag(uiCode ? true : false); |
---|
[713] | 363 | #if Q0048_CGS_3D_ASYMLUT |
---|
| 364 | READ_FLAG( uiCode , "colour_mapping_enabled_flag" ); |
---|
| 365 | pcPPS->setCGSFlag( uiCode ); |
---|
| 366 | if( pcPPS->getCGSFlag() ) |
---|
| 367 | { |
---|
| 368 | xParse3DAsymLUT( pc3DAsymLUT ); |
---|
| 369 | pcPPS->setCGSOutputBitDepthY( pc3DAsymLUT->getOutputBitDepthY() ); |
---|
| 370 | pcPPS->setCGSOutputBitDepthC( pc3DAsymLUT->getOutputBitDepthC() ); |
---|
| 371 | } |
---|
[644] | 372 | #endif |
---|
[713] | 373 | #endif |
---|
[644] | 374 | } |
---|
[815] | 375 | #if POC_RESET_INFO_INFERENCE |
---|
| 376 | else // Extension type 0 absent |
---|
| 377 | { |
---|
| 378 | pcPPS->setPocResetInfoPresentFlag( false ); |
---|
| 379 | } |
---|
| 380 | #endif |
---|
[644] | 381 | if (ppsExtensionTypeFlag[7]) |
---|
| 382 | { |
---|
| 383 | #endif |
---|
| 384 | |
---|
[313] | 385 | while ( xMoreRbspData() ) |
---|
| 386 | { |
---|
| 387 | READ_FLAG( uiCode, "pps_extension_data_flag"); |
---|
| 388 | } |
---|
[644] | 389 | #if P0166_MODIFIED_PPS_EXTENSION |
---|
| 390 | } |
---|
| 391 | #endif |
---|
[313] | 392 | } |
---|
[815] | 393 | #if POC_RESET_INFO_INFERENCE |
---|
| 394 | if( !pcPPS->getExtensionFlag() ) |
---|
| 395 | { |
---|
| 396 | pcPPS->setPocResetInfoPresentFlag( false ); |
---|
| 397 | } |
---|
| 398 | #endif |
---|
[313] | 399 | } |
---|
| 400 | |
---|
| 401 | Void TDecCavlc::parseVUI(TComVUI* pcVUI, TComSPS *pcSPS) |
---|
| 402 | { |
---|
| 403 | #if ENC_DEC_TRACE |
---|
| 404 | fprintf( g_hTrace, "----------- vui_parameters -----------\n"); |
---|
| 405 | #endif |
---|
| 406 | UInt uiCode; |
---|
| 407 | |
---|
| 408 | READ_FLAG( uiCode, "aspect_ratio_info_present_flag"); pcVUI->setAspectRatioInfoPresentFlag(uiCode); |
---|
| 409 | if (pcVUI->getAspectRatioInfoPresentFlag()) |
---|
| 410 | { |
---|
| 411 | READ_CODE(8, uiCode, "aspect_ratio_idc"); pcVUI->setAspectRatioIdc(uiCode); |
---|
| 412 | if (pcVUI->getAspectRatioIdc() == 255) |
---|
| 413 | { |
---|
| 414 | READ_CODE(16, uiCode, "sar_width"); pcVUI->setSarWidth(uiCode); |
---|
| 415 | READ_CODE(16, uiCode, "sar_height"); pcVUI->setSarHeight(uiCode); |
---|
| 416 | } |
---|
| 417 | } |
---|
| 418 | |
---|
| 419 | READ_FLAG( uiCode, "overscan_info_present_flag"); pcVUI->setOverscanInfoPresentFlag(uiCode); |
---|
| 420 | if (pcVUI->getOverscanInfoPresentFlag()) |
---|
| 421 | { |
---|
| 422 | READ_FLAG( uiCode, "overscan_appropriate_flag"); pcVUI->setOverscanAppropriateFlag(uiCode); |
---|
| 423 | } |
---|
| 424 | |
---|
| 425 | READ_FLAG( uiCode, "video_signal_type_present_flag"); pcVUI->setVideoSignalTypePresentFlag(uiCode); |
---|
| 426 | if (pcVUI->getVideoSignalTypePresentFlag()) |
---|
| 427 | { |
---|
| 428 | READ_CODE(3, uiCode, "video_format"); pcVUI->setVideoFormat(uiCode); |
---|
| 429 | READ_FLAG( uiCode, "video_full_range_flag"); pcVUI->setVideoFullRangeFlag(uiCode); |
---|
| 430 | READ_FLAG( uiCode, "colour_description_present_flag"); pcVUI->setColourDescriptionPresentFlag(uiCode); |
---|
| 431 | if (pcVUI->getColourDescriptionPresentFlag()) |
---|
| 432 | { |
---|
| 433 | READ_CODE(8, uiCode, "colour_primaries"); pcVUI->setColourPrimaries(uiCode); |
---|
| 434 | READ_CODE(8, uiCode, "transfer_characteristics"); pcVUI->setTransferCharacteristics(uiCode); |
---|
| 435 | READ_CODE(8, uiCode, "matrix_coefficients"); pcVUI->setMatrixCoefficients(uiCode); |
---|
| 436 | } |
---|
| 437 | } |
---|
| 438 | |
---|
| 439 | READ_FLAG( uiCode, "chroma_loc_info_present_flag"); pcVUI->setChromaLocInfoPresentFlag(uiCode); |
---|
| 440 | if (pcVUI->getChromaLocInfoPresentFlag()) |
---|
| 441 | { |
---|
| 442 | READ_UVLC( uiCode, "chroma_sample_loc_type_top_field" ); pcVUI->setChromaSampleLocTypeTopField(uiCode); |
---|
| 443 | READ_UVLC( uiCode, "chroma_sample_loc_type_bottom_field" ); pcVUI->setChromaSampleLocTypeBottomField(uiCode); |
---|
| 444 | } |
---|
| 445 | |
---|
| 446 | READ_FLAG( uiCode, "neutral_chroma_indication_flag"); pcVUI->setNeutralChromaIndicationFlag(uiCode); |
---|
| 447 | |
---|
| 448 | READ_FLAG( uiCode, "field_seq_flag"); pcVUI->setFieldSeqFlag(uiCode); |
---|
| 449 | |
---|
| 450 | READ_FLAG(uiCode, "frame_field_info_present_flag"); pcVUI->setFrameFieldInfoPresentFlag(uiCode); |
---|
| 451 | |
---|
| 452 | READ_FLAG( uiCode, "default_display_window_flag"); |
---|
| 453 | if (uiCode != 0) |
---|
| 454 | { |
---|
| 455 | Window &defDisp = pcVUI->getDefaultDisplayWindow(); |
---|
| 456 | READ_UVLC( uiCode, "def_disp_win_left_offset" ); defDisp.setWindowLeftOffset ( uiCode * TComSPS::getWinUnitX( pcSPS->getChromaFormatIdc()) ); |
---|
| 457 | READ_UVLC( uiCode, "def_disp_win_right_offset" ); defDisp.setWindowRightOffset ( uiCode * TComSPS::getWinUnitX( pcSPS->getChromaFormatIdc()) ); |
---|
| 458 | READ_UVLC( uiCode, "def_disp_win_top_offset" ); defDisp.setWindowTopOffset ( uiCode * TComSPS::getWinUnitY( pcSPS->getChromaFormatIdc()) ); |
---|
| 459 | READ_UVLC( uiCode, "def_disp_win_bottom_offset" ); defDisp.setWindowBottomOffset( uiCode * TComSPS::getWinUnitY( pcSPS->getChromaFormatIdc()) ); |
---|
| 460 | } |
---|
| 461 | TimingInfo *timingInfo = pcVUI->getTimingInfo(); |
---|
| 462 | READ_FLAG( uiCode, "vui_timing_info_present_flag"); timingInfo->setTimingInfoPresentFlag (uiCode ? true : false); |
---|
[815] | 463 | #if SVC_EXTENSION |
---|
[442] | 464 | if( pcSPS->getLayerId() > 0 ) |
---|
| 465 | { |
---|
| 466 | assert( timingInfo->getTimingInfoPresentFlag() == false ); |
---|
| 467 | } |
---|
| 468 | #endif |
---|
[313] | 469 | if(timingInfo->getTimingInfoPresentFlag()) |
---|
| 470 | { |
---|
| 471 | READ_CODE( 32, uiCode, "vui_num_units_in_tick"); timingInfo->setNumUnitsInTick (uiCode); |
---|
| 472 | READ_CODE( 32, uiCode, "vui_time_scale"); timingInfo->setTimeScale (uiCode); |
---|
| 473 | READ_FLAG( uiCode, "vui_poc_proportional_to_timing_flag"); timingInfo->setPocProportionalToTimingFlag(uiCode ? true : false); |
---|
| 474 | if(timingInfo->getPocProportionalToTimingFlag()) |
---|
| 475 | { |
---|
| 476 | READ_UVLC( uiCode, "vui_num_ticks_poc_diff_one_minus1"); timingInfo->setNumTicksPocDiffOneMinus1 (uiCode); |
---|
| 477 | } |
---|
| 478 | READ_FLAG( uiCode, "hrd_parameters_present_flag"); pcVUI->setHrdParametersPresentFlag(uiCode); |
---|
| 479 | if( pcVUI->getHrdParametersPresentFlag() ) |
---|
| 480 | { |
---|
| 481 | parseHrdParameters( pcVUI->getHrdParameters(), 1, pcSPS->getMaxTLayers() - 1 ); |
---|
| 482 | } |
---|
| 483 | } |
---|
| 484 | READ_FLAG( uiCode, "bitstream_restriction_flag"); pcVUI->setBitstreamRestrictionFlag(uiCode); |
---|
| 485 | if (pcVUI->getBitstreamRestrictionFlag()) |
---|
| 486 | { |
---|
| 487 | READ_FLAG( uiCode, "tiles_fixed_structure_flag"); pcVUI->setTilesFixedStructureFlag(uiCode); |
---|
| 488 | READ_FLAG( uiCode, "motion_vectors_over_pic_boundaries_flag"); pcVUI->setMotionVectorsOverPicBoundariesFlag(uiCode); |
---|
| 489 | READ_FLAG( uiCode, "restricted_ref_pic_lists_flag"); pcVUI->setRestrictedRefPicListsFlag(uiCode); |
---|
| 490 | READ_UVLC( uiCode, "min_spatial_segmentation_idc"); pcVUI->setMinSpatialSegmentationIdc(uiCode); |
---|
| 491 | assert(uiCode < 4096); |
---|
| 492 | READ_UVLC( uiCode, "max_bytes_per_pic_denom" ); pcVUI->setMaxBytesPerPicDenom(uiCode); |
---|
| 493 | READ_UVLC( uiCode, "max_bits_per_mincu_denom" ); pcVUI->setMaxBitsPerMinCuDenom(uiCode); |
---|
| 494 | READ_UVLC( uiCode, "log2_max_mv_length_horizontal" ); pcVUI->setLog2MaxMvLengthHorizontal(uiCode); |
---|
| 495 | READ_UVLC( uiCode, "log2_max_mv_length_vertical" ); pcVUI->setLog2MaxMvLengthVertical(uiCode); |
---|
| 496 | } |
---|
| 497 | } |
---|
| 498 | |
---|
| 499 | Void TDecCavlc::parseHrdParameters(TComHRD *hrd, Bool commonInfPresentFlag, UInt maxNumSubLayersMinus1) |
---|
| 500 | { |
---|
| 501 | UInt uiCode; |
---|
| 502 | if( commonInfPresentFlag ) |
---|
| 503 | { |
---|
| 504 | READ_FLAG( uiCode, "nal_hrd_parameters_present_flag" ); hrd->setNalHrdParametersPresentFlag( uiCode == 1 ? true : false ); |
---|
| 505 | READ_FLAG( uiCode, "vcl_hrd_parameters_present_flag" ); hrd->setVclHrdParametersPresentFlag( uiCode == 1 ? true : false ); |
---|
| 506 | if( hrd->getNalHrdParametersPresentFlag() || hrd->getVclHrdParametersPresentFlag() ) |
---|
| 507 | { |
---|
| 508 | READ_FLAG( uiCode, "sub_pic_cpb_params_present_flag" ); hrd->setSubPicCpbParamsPresentFlag( uiCode == 1 ? true : false ); |
---|
| 509 | if( hrd->getSubPicCpbParamsPresentFlag() ) |
---|
| 510 | { |
---|
| 511 | READ_CODE( 8, uiCode, "tick_divisor_minus2" ); hrd->setTickDivisorMinus2( uiCode ); |
---|
| 512 | READ_CODE( 5, uiCode, "du_cpb_removal_delay_length_minus1" ); hrd->setDuCpbRemovalDelayLengthMinus1( uiCode ); |
---|
| 513 | READ_FLAG( uiCode, "sub_pic_cpb_params_in_pic_timing_sei_flag" ); hrd->setSubPicCpbParamsInPicTimingSEIFlag( uiCode == 1 ? true : false ); |
---|
| 514 | READ_CODE( 5, uiCode, "dpb_output_delay_du_length_minus1" ); hrd->setDpbOutputDelayDuLengthMinus1( uiCode ); |
---|
| 515 | } |
---|
| 516 | READ_CODE( 4, uiCode, "bit_rate_scale" ); hrd->setBitRateScale( uiCode ); |
---|
| 517 | READ_CODE( 4, uiCode, "cpb_size_scale" ); hrd->setCpbSizeScale( uiCode ); |
---|
| 518 | if( hrd->getSubPicCpbParamsPresentFlag() ) |
---|
| 519 | { |
---|
| 520 | READ_CODE( 4, uiCode, "cpb_size_du_scale" ); hrd->setDuCpbSizeScale( uiCode ); |
---|
| 521 | } |
---|
| 522 | READ_CODE( 5, uiCode, "initial_cpb_removal_delay_length_minus1" ); hrd->setInitialCpbRemovalDelayLengthMinus1( uiCode ); |
---|
| 523 | READ_CODE( 5, uiCode, "au_cpb_removal_delay_length_minus1" ); hrd->setCpbRemovalDelayLengthMinus1( uiCode ); |
---|
| 524 | READ_CODE( 5, uiCode, "dpb_output_delay_length_minus1" ); hrd->setDpbOutputDelayLengthMinus1( uiCode ); |
---|
| 525 | } |
---|
| 526 | } |
---|
| 527 | Int i, j, nalOrVcl; |
---|
| 528 | for( i = 0; i <= maxNumSubLayersMinus1; i ++ ) |
---|
| 529 | { |
---|
| 530 | READ_FLAG( uiCode, "fixed_pic_rate_general_flag" ); hrd->setFixedPicRateFlag( i, uiCode == 1 ? true : false ); |
---|
| 531 | if( !hrd->getFixedPicRateFlag( i ) ) |
---|
| 532 | { |
---|
| 533 | READ_FLAG( uiCode, "fixed_pic_rate_within_cvs_flag" ); hrd->setFixedPicRateWithinCvsFlag( i, uiCode == 1 ? true : false ); |
---|
| 534 | } |
---|
| 535 | else |
---|
| 536 | { |
---|
| 537 | hrd->setFixedPicRateWithinCvsFlag( i, true ); |
---|
| 538 | } |
---|
| 539 | hrd->setLowDelayHrdFlag( i, 0 ); // Infered to be 0 when not present |
---|
| 540 | hrd->setCpbCntMinus1 ( i, 0 ); // Infered to be 0 when not present |
---|
| 541 | if( hrd->getFixedPicRateWithinCvsFlag( i ) ) |
---|
| 542 | { |
---|
| 543 | READ_UVLC( uiCode, "elemental_duration_in_tc_minus1" ); hrd->setPicDurationInTcMinus1( i, uiCode ); |
---|
| 544 | } |
---|
| 545 | else |
---|
| 546 | { |
---|
| 547 | READ_FLAG( uiCode, "low_delay_hrd_flag" ); hrd->setLowDelayHrdFlag( i, uiCode == 1 ? true : false ); |
---|
| 548 | } |
---|
| 549 | if (!hrd->getLowDelayHrdFlag( i )) |
---|
| 550 | { |
---|
| 551 | READ_UVLC( uiCode, "cpb_cnt_minus1" ); hrd->setCpbCntMinus1( i, uiCode ); |
---|
| 552 | } |
---|
| 553 | for( nalOrVcl = 0; nalOrVcl < 2; nalOrVcl ++ ) |
---|
| 554 | { |
---|
| 555 | if( ( ( nalOrVcl == 0 ) && ( hrd->getNalHrdParametersPresentFlag() ) ) || |
---|
| 556 | ( ( nalOrVcl == 1 ) && ( hrd->getVclHrdParametersPresentFlag() ) ) ) |
---|
| 557 | { |
---|
| 558 | for( j = 0; j <= ( hrd->getCpbCntMinus1( i ) ); j ++ ) |
---|
| 559 | { |
---|
| 560 | READ_UVLC( uiCode, "bit_rate_value_minus1" ); hrd->setBitRateValueMinus1( i, j, nalOrVcl, uiCode ); |
---|
| 561 | READ_UVLC( uiCode, "cpb_size_value_minus1" ); hrd->setCpbSizeValueMinus1( i, j, nalOrVcl, uiCode ); |
---|
| 562 | if( hrd->getSubPicCpbParamsPresentFlag() ) |
---|
| 563 | { |
---|
| 564 | READ_UVLC( uiCode, "cpb_size_du_value_minus1" ); hrd->setDuCpbSizeValueMinus1( i, j, nalOrVcl, uiCode ); |
---|
| 565 | READ_UVLC( uiCode, "bit_rate_du_value_minus1" ); hrd->setDuBitRateValueMinus1( i, j, nalOrVcl, uiCode ); |
---|
| 566 | } |
---|
| 567 | READ_FLAG( uiCode, "cbr_flag" ); hrd->setCbrFlag( i, j, nalOrVcl, uiCode == 1 ? true : false ); |
---|
| 568 | } |
---|
| 569 | } |
---|
| 570 | } |
---|
| 571 | } |
---|
| 572 | } |
---|
| 573 | |
---|
[644] | 574 | #if SVC_EXTENSION && !SPS_DPB_PARAMS |
---|
[313] | 575 | Void TDecCavlc::parseSPS(TComSPS* pcSPS, ParameterSetManagerDecoder *parameterSetManager) |
---|
| 576 | #else |
---|
| 577 | Void TDecCavlc::parseSPS(TComSPS* pcSPS) |
---|
| 578 | #endif |
---|
| 579 | { |
---|
| 580 | #if ENC_DEC_TRACE |
---|
| 581 | xTraceSPSHeader (pcSPS); |
---|
| 582 | #endif |
---|
| 583 | |
---|
| 584 | UInt uiCode; |
---|
| 585 | READ_CODE( 4, uiCode, "sps_video_parameter_set_id"); pcSPS->setVPSId ( uiCode ); |
---|
[494] | 586 | #if SVC_EXTENSION |
---|
[313] | 587 | if(pcSPS->getLayerId() == 0) |
---|
| 588 | { |
---|
| 589 | #endif |
---|
| 590 | READ_CODE( 3, uiCode, "sps_max_sub_layers_minus1" ); pcSPS->setMaxTLayers ( uiCode+1 ); |
---|
| 591 | assert(uiCode <= 6); |
---|
[494] | 592 | |
---|
[313] | 593 | READ_FLAG( uiCode, "sps_temporal_id_nesting_flag" ); pcSPS->setTemporalIdNestingFlag ( uiCode > 0 ? true : false ); |
---|
[494] | 594 | #if SVC_EXTENSION |
---|
[313] | 595 | } |
---|
[644] | 596 | #if !SPS_DPB_PARAMS |
---|
[313] | 597 | else |
---|
| 598 | { |
---|
| 599 | pcSPS->setMaxTLayers ( parameterSetManager->getPrefetchedVPS(pcSPS->getVPSId())->getMaxTLayers() ); |
---|
| 600 | pcSPS->setTemporalIdNestingFlag( parameterSetManager->getPrefetchedVPS(pcSPS->getVPSId())->getTemporalNestingFlag() ); |
---|
| 601 | } |
---|
[442] | 602 | #endif |
---|
[644] | 603 | #endif |
---|
| 604 | |
---|
[815] | 605 | #if !Q0177_SPS_TEMP_NESTING_FIX //This part is not needed anymore as it is already covered by implementation in TDecTop::xActivateParameterSets() |
---|
[313] | 606 | if ( pcSPS->getMaxTLayers() == 1 ) |
---|
| 607 | { |
---|
| 608 | // sps_temporal_id_nesting_flag must be 1 when sps_max_sub_layers_minus1 is 0 |
---|
[494] | 609 | #if SVC_EXTENSION |
---|
[644] | 610 | #if !SPS_DPB_PARAMS |
---|
[313] | 611 | assert( pcSPS->getTemporalIdNestingFlag() == true ); |
---|
[644] | 612 | #endif |
---|
[313] | 613 | #else |
---|
| 614 | assert( uiCode == 1 ); |
---|
| 615 | #endif |
---|
| 616 | } |
---|
[815] | 617 | #endif |
---|
| 618 | |
---|
[442] | 619 | #ifdef SPS_PTL_FIX |
---|
| 620 | if ( pcSPS->getLayerId() == 0) |
---|
| 621 | { |
---|
| 622 | parsePTL(pcSPS->getPTL(), 1, pcSPS->getMaxTLayers() - 1); |
---|
| 623 | } |
---|
| 624 | #else |
---|
| 625 | parsePTL(pcSPS->getPTL(), 1, pcSPS->getMaxTLayers() - 1); |
---|
| 626 | #endif |
---|
[313] | 627 | |
---|
| 628 | READ_UVLC( uiCode, "sps_seq_parameter_set_id" ); pcSPS->setSPSId( uiCode ); |
---|
| 629 | assert(uiCode <= 15); |
---|
[442] | 630 | |
---|
| 631 | #if REPN_FORMAT_IN_VPS |
---|
| 632 | if( pcSPS->getLayerId() > 0 ) |
---|
[313] | 633 | { |
---|
[494] | 634 | READ_FLAG( uiCode, "update_rep_format_flag" ); |
---|
[442] | 635 | pcSPS->setUpdateRepFormatFlag( uiCode ? true : false ); |
---|
[313] | 636 | } |
---|
[442] | 637 | else |
---|
| 638 | { |
---|
[713] | 639 | #if REP_FORMAT_FIX |
---|
| 640 | pcSPS->setUpdateRepFormatFlag( false ); |
---|
| 641 | #else |
---|
[442] | 642 | pcSPS->setUpdateRepFormatFlag( true ); |
---|
[713] | 643 | #endif |
---|
[442] | 644 | } |
---|
[540] | 645 | #if O0096_REP_FORMAT_INDEX |
---|
| 646 | if( pcSPS->getLayerId() == 0 ) |
---|
| 647 | #else |
---|
[494] | 648 | if( pcSPS->getLayerId() == 0 || pcSPS->getUpdateRepFormatFlag() ) |
---|
[540] | 649 | #endif |
---|
[442] | 650 | { |
---|
| 651 | #endif |
---|
[494] | 652 | #if AUXILIARY_PICTURES |
---|
| 653 | READ_UVLC( uiCode, "chroma_format_idc" ); pcSPS->setChromaFormatIdc( ChromaFormat(uiCode) ); |
---|
| 654 | #else |
---|
[442] | 655 | READ_UVLC( uiCode, "chroma_format_idc" ); pcSPS->setChromaFormatIdc( uiCode ); |
---|
[494] | 656 | #endif |
---|
[442] | 657 | assert(uiCode <= 3); |
---|
| 658 | // in the first version we only support chroma_format_idc equal to 1 (4:2:0), so separate_colour_plane_flag cannot appear in the bitstream |
---|
| 659 | assert (uiCode == 1); |
---|
| 660 | if( uiCode == 3 ) |
---|
| 661 | { |
---|
| 662 | READ_FLAG( uiCode, "separate_colour_plane_flag"); assert(uiCode == 0); |
---|
| 663 | } |
---|
[313] | 664 | |
---|
[442] | 665 | READ_UVLC ( uiCode, "pic_width_in_luma_samples" ); pcSPS->setPicWidthInLumaSamples ( uiCode ); |
---|
| 666 | READ_UVLC ( uiCode, "pic_height_in_luma_samples" ); pcSPS->setPicHeightInLumaSamples( uiCode ); |
---|
| 667 | #if REPN_FORMAT_IN_VPS |
---|
| 668 | } |
---|
[540] | 669 | #if O0096_REP_FORMAT_INDEX |
---|
| 670 | else if ( pcSPS->getUpdateRepFormatFlag() ) |
---|
| 671 | { |
---|
| 672 | READ_CODE(8, uiCode, "update_rep_format_index"); |
---|
| 673 | pcSPS->setUpdateRepFormatIndex(uiCode); |
---|
| 674 | } |
---|
[442] | 675 | #endif |
---|
[540] | 676 | #endif |
---|
[313] | 677 | READ_FLAG( uiCode, "conformance_window_flag"); |
---|
| 678 | if (uiCode != 0) |
---|
| 679 | { |
---|
| 680 | Window &conf = pcSPS->getConformanceWindow(); |
---|
[442] | 681 | #if REPN_FORMAT_IN_VPS |
---|
| 682 | READ_UVLC( uiCode, "conf_win_left_offset" ); conf.setWindowLeftOffset ( uiCode ); |
---|
| 683 | READ_UVLC( uiCode, "conf_win_right_offset" ); conf.setWindowRightOffset ( uiCode ); |
---|
| 684 | READ_UVLC( uiCode, "conf_win_top_offset" ); conf.setWindowTopOffset ( uiCode ); |
---|
| 685 | READ_UVLC( uiCode, "conf_win_bottom_offset" ); conf.setWindowBottomOffset( uiCode ); |
---|
| 686 | #else |
---|
[313] | 687 | READ_UVLC( uiCode, "conf_win_left_offset" ); conf.setWindowLeftOffset ( uiCode * TComSPS::getWinUnitX( pcSPS->getChromaFormatIdc() ) ); |
---|
| 688 | READ_UVLC( uiCode, "conf_win_right_offset" ); conf.setWindowRightOffset ( uiCode * TComSPS::getWinUnitX( pcSPS->getChromaFormatIdc() ) ); |
---|
| 689 | READ_UVLC( uiCode, "conf_win_top_offset" ); conf.setWindowTopOffset ( uiCode * TComSPS::getWinUnitY( pcSPS->getChromaFormatIdc() ) ); |
---|
| 690 | READ_UVLC( uiCode, "conf_win_bottom_offset" ); conf.setWindowBottomOffset( uiCode * TComSPS::getWinUnitY( pcSPS->getChromaFormatIdc() ) ); |
---|
[442] | 691 | #endif |
---|
[313] | 692 | } |
---|
[442] | 693 | #if REPN_FORMAT_IN_VPS |
---|
[540] | 694 | #if O0096_REP_FORMAT_INDEX |
---|
| 695 | if( pcSPS->getLayerId() == 0 ) |
---|
| 696 | #else |
---|
[494] | 697 | if( pcSPS->getLayerId() == 0 || pcSPS->getUpdateRepFormatFlag() ) |
---|
[540] | 698 | #endif |
---|
[442] | 699 | { |
---|
| 700 | #endif |
---|
| 701 | READ_UVLC( uiCode, "bit_depth_luma_minus8" ); |
---|
| 702 | assert(uiCode <= 6); |
---|
| 703 | pcSPS->setBitDepthY( uiCode + 8 ); |
---|
| 704 | pcSPS->setQpBDOffsetY( (Int) (6*uiCode) ); |
---|
[313] | 705 | |
---|
[442] | 706 | READ_UVLC( uiCode, "bit_depth_chroma_minus8" ); |
---|
| 707 | assert(uiCode <= 6); |
---|
| 708 | pcSPS->setBitDepthC( uiCode + 8 ); |
---|
| 709 | pcSPS->setQpBDOffsetC( (Int) (6*uiCode) ); |
---|
| 710 | #if REPN_FORMAT_IN_VPS |
---|
| 711 | } |
---|
| 712 | #endif |
---|
[313] | 713 | READ_UVLC( uiCode, "log2_max_pic_order_cnt_lsb_minus4" ); pcSPS->setBitsForPOC( 4 + uiCode ); |
---|
| 714 | assert(uiCode <= 12); |
---|
| 715 | |
---|
[644] | 716 | #if SPS_DPB_PARAMS |
---|
| 717 | if( pcSPS->getLayerId() == 0 ) |
---|
[313] | 718 | { |
---|
[644] | 719 | #endif |
---|
| 720 | UInt subLayerOrderingInfoPresentFlag; |
---|
| 721 | READ_FLAG(subLayerOrderingInfoPresentFlag, "sps_sub_layer_ordering_info_present_flag"); |
---|
[313] | 722 | |
---|
[644] | 723 | for(UInt i=0; i <= pcSPS->getMaxTLayers()-1; i++) |
---|
[313] | 724 | { |
---|
[713] | 725 | READ_UVLC ( uiCode, "sps_max_dec_pic_buffering_minus1[i]"); |
---|
[644] | 726 | pcSPS->setMaxDecPicBuffering( uiCode + 1, i); |
---|
[713] | 727 | READ_UVLC ( uiCode, "sps_num_reorder_pics[i]" ); |
---|
[644] | 728 | pcSPS->setNumReorderPics(uiCode, i); |
---|
[713] | 729 | READ_UVLC ( uiCode, "sps_max_latency_increase_plus1[i]"); |
---|
[644] | 730 | pcSPS->setMaxLatencyIncrease( uiCode, i ); |
---|
| 731 | |
---|
| 732 | if (!subLayerOrderingInfoPresentFlag) |
---|
[313] | 733 | { |
---|
[644] | 734 | for (i++; i <= pcSPS->getMaxTLayers()-1; i++) |
---|
| 735 | { |
---|
| 736 | pcSPS->setMaxDecPicBuffering(pcSPS->getMaxDecPicBuffering(0), i); |
---|
| 737 | pcSPS->setNumReorderPics(pcSPS->getNumReorderPics(0), i); |
---|
| 738 | pcSPS->setMaxLatencyIncrease(pcSPS->getMaxLatencyIncrease(0), i); |
---|
| 739 | } |
---|
| 740 | break; |
---|
[313] | 741 | } |
---|
| 742 | } |
---|
[644] | 743 | #if SPS_DPB_PARAMS |
---|
[313] | 744 | } |
---|
[644] | 745 | #endif |
---|
[313] | 746 | READ_UVLC( uiCode, "log2_min_coding_block_size_minus3" ); |
---|
| 747 | Int log2MinCUSize = uiCode + 3; |
---|
| 748 | pcSPS->setLog2MinCodingBlockSize(log2MinCUSize); |
---|
| 749 | READ_UVLC( uiCode, "log2_diff_max_min_coding_block_size" ); |
---|
| 750 | pcSPS->setLog2DiffMaxMinCodingBlockSize(uiCode); |
---|
[595] | 751 | |
---|
| 752 | if (pcSPS->getPTL()->getGeneralPTL()->getLevelIdc() >= Level::LEVEL5) |
---|
| 753 | { |
---|
| 754 | assert(log2MinCUSize + pcSPS->getLog2DiffMaxMinCodingBlockSize() >= 5); |
---|
| 755 | } |
---|
| 756 | |
---|
[313] | 757 | Int maxCUDepthDelta = uiCode; |
---|
| 758 | pcSPS->setMaxCUWidth ( 1<<(log2MinCUSize + maxCUDepthDelta) ); |
---|
| 759 | pcSPS->setMaxCUHeight ( 1<<(log2MinCUSize + maxCUDepthDelta) ); |
---|
| 760 | READ_UVLC( uiCode, "log2_min_transform_block_size_minus2" ); pcSPS->setQuadtreeTULog2MinSize( uiCode + 2 ); |
---|
| 761 | |
---|
| 762 | READ_UVLC( uiCode, "log2_diff_max_min_transform_block_size" ); pcSPS->setQuadtreeTULog2MaxSize( uiCode + pcSPS->getQuadtreeTULog2MinSize() ); |
---|
| 763 | pcSPS->setMaxTrSize( 1<<(uiCode + pcSPS->getQuadtreeTULog2MinSize()) ); |
---|
| 764 | |
---|
| 765 | READ_UVLC( uiCode, "max_transform_hierarchy_depth_inter" ); pcSPS->setQuadtreeTUMaxDepthInter( uiCode+1 ); |
---|
| 766 | READ_UVLC( uiCode, "max_transform_hierarchy_depth_intra" ); pcSPS->setQuadtreeTUMaxDepthIntra( uiCode+1 ); |
---|
| 767 | |
---|
| 768 | Int addCuDepth = max (0, log2MinCUSize - (Int)pcSPS->getQuadtreeTULog2MinSize() ); |
---|
| 769 | pcSPS->setMaxCUDepth( maxCUDepthDelta + addCuDepth ); |
---|
[442] | 770 | READ_FLAG( uiCode, "scaling_list_enabled_flag" ); pcSPS->setScalingListFlag ( uiCode ); |
---|
[313] | 771 | |
---|
| 772 | if(pcSPS->getScalingListFlag()) |
---|
| 773 | { |
---|
[540] | 774 | #if SCALINGLIST_INFERRING |
---|
| 775 | if( pcSPS->getLayerId() > 0 ) |
---|
[313] | 776 | { |
---|
[540] | 777 | READ_FLAG( uiCode, "sps_infer_scaling_list_flag" ); pcSPS->setInferScalingListFlag( uiCode ); |
---|
| 778 | } |
---|
[442] | 779 | |
---|
[540] | 780 | if( pcSPS->getInferScalingListFlag() ) |
---|
| 781 | { |
---|
| 782 | READ_UVLC( uiCode, "sps_scaling_list_ref_layer_id" ); pcSPS->setScalingListRefLayerId( uiCode ); |
---|
[442] | 783 | |
---|
[540] | 784 | // The value of pps_scaling_list_ref_layer_id shall be in the range of 0 to 62, inclusive |
---|
| 785 | assert( pcSPS->getScalingListRefLayerId() <= 62 ); |
---|
[442] | 786 | |
---|
[540] | 787 | pcSPS->setScalingListPresentFlag( false ); |
---|
| 788 | } |
---|
| 789 | else |
---|
| 790 | { |
---|
| 791 | #endif |
---|
| 792 | READ_FLAG( uiCode, "sps_scaling_list_data_present_flag" ); pcSPS->setScalingListPresentFlag ( uiCode ); |
---|
| 793 | if(pcSPS->getScalingListPresentFlag ()) |
---|
| 794 | { |
---|
[313] | 795 | parseScalingList( pcSPS->getScalingList() ); |
---|
[540] | 796 | } |
---|
| 797 | #if SCALINGLIST_INFERRING |
---|
| 798 | } |
---|
[442] | 799 | #endif |
---|
[313] | 800 | } |
---|
| 801 | READ_FLAG( uiCode, "amp_enabled_flag" ); pcSPS->setUseAMP( uiCode ); |
---|
| 802 | READ_FLAG( uiCode, "sample_adaptive_offset_enabled_flag" ); pcSPS->setUseSAO ( uiCode ? true : false ); |
---|
| 803 | |
---|
| 804 | READ_FLAG( uiCode, "pcm_enabled_flag" ); pcSPS->setUsePCM( uiCode ? true : false ); |
---|
| 805 | if( pcSPS->getUsePCM() ) |
---|
| 806 | { |
---|
| 807 | READ_CODE( 4, uiCode, "pcm_sample_bit_depth_luma_minus1" ); pcSPS->setPCMBitDepthLuma ( 1 + uiCode ); |
---|
| 808 | READ_CODE( 4, uiCode, "pcm_sample_bit_depth_chroma_minus1" ); pcSPS->setPCMBitDepthChroma ( 1 + uiCode ); |
---|
| 809 | READ_UVLC( uiCode, "log2_min_pcm_luma_coding_block_size_minus3" ); pcSPS->setPCMLog2MinSize (uiCode+3); |
---|
| 810 | READ_UVLC( uiCode, "log2_diff_max_min_pcm_luma_coding_block_size" ); pcSPS->setPCMLog2MaxSize ( uiCode+pcSPS->getPCMLog2MinSize() ); |
---|
| 811 | READ_FLAG( uiCode, "pcm_loop_filter_disable_flag" ); pcSPS->setPCMFilterDisableFlag ( uiCode ? true : false ); |
---|
| 812 | } |
---|
| 813 | |
---|
| 814 | READ_UVLC( uiCode, "num_short_term_ref_pic_sets" ); |
---|
| 815 | assert(uiCode <= 64); |
---|
| 816 | pcSPS->createRPSList(uiCode); |
---|
| 817 | |
---|
| 818 | TComRPSList* rpsList = pcSPS->getRPSList(); |
---|
| 819 | TComReferencePictureSet* rps; |
---|
| 820 | |
---|
| 821 | for(UInt i=0; i< rpsList->getNumberOfReferencePictureSets(); i++) |
---|
| 822 | { |
---|
| 823 | rps = rpsList->getReferencePictureSet(i); |
---|
| 824 | parseShortTermRefPicSet(pcSPS,rps,i); |
---|
| 825 | } |
---|
| 826 | READ_FLAG( uiCode, "long_term_ref_pics_present_flag" ); pcSPS->setLongTermRefsPresent(uiCode); |
---|
| 827 | if (pcSPS->getLongTermRefsPresent()) |
---|
| 828 | { |
---|
| 829 | READ_UVLC( uiCode, "num_long_term_ref_pic_sps" ); |
---|
| 830 | pcSPS->setNumLongTermRefPicSPS(uiCode); |
---|
| 831 | for (UInt k = 0; k < pcSPS->getNumLongTermRefPicSPS(); k++) |
---|
| 832 | { |
---|
| 833 | READ_CODE( pcSPS->getBitsForPOC(), uiCode, "lt_ref_pic_poc_lsb_sps" ); |
---|
| 834 | pcSPS->setLtRefPicPocLsbSps(k, uiCode); |
---|
| 835 | READ_FLAG( uiCode, "used_by_curr_pic_lt_sps_flag[i]"); |
---|
| 836 | pcSPS->setUsedByCurrPicLtSPSFlag(k, uiCode?1:0); |
---|
| 837 | } |
---|
| 838 | } |
---|
| 839 | READ_FLAG( uiCode, "sps_temporal_mvp_enable_flag" ); pcSPS->setTMVPFlagsPresent(uiCode); |
---|
| 840 | READ_FLAG( uiCode, "sps_strong_intra_smoothing_enable_flag" ); pcSPS->setUseStrongIntraSmoothing(uiCode); |
---|
| 841 | |
---|
| 842 | READ_FLAG( uiCode, "vui_parameters_present_flag" ); pcSPS->setVuiParametersPresentFlag(uiCode); |
---|
| 843 | |
---|
| 844 | if (pcSPS->getVuiParametersPresentFlag()) |
---|
| 845 | { |
---|
| 846 | parseVUI(pcSPS->getVuiParameters(), pcSPS); |
---|
| 847 | } |
---|
| 848 | |
---|
| 849 | READ_FLAG( uiCode, "sps_extension_flag"); |
---|
[815] | 850 | |
---|
| 851 | #if SVC_EXTENSION |
---|
| 852 | pcSPS->setExtensionFlag( uiCode ? true : false ); |
---|
| 853 | |
---|
| 854 | if( pcSPS->getExtensionFlag() ) |
---|
[313] | 855 | { |
---|
[540] | 856 | #if O0142_CONDITIONAL_SPS_EXTENSION |
---|
| 857 | UInt spsExtensionTypeFlag[8]; |
---|
| 858 | for (UInt i = 0; i < 8; i++) |
---|
| 859 | { |
---|
| 860 | READ_FLAG( spsExtensionTypeFlag[i], "sps_extension_type_flag" ); |
---|
| 861 | } |
---|
| 862 | if (spsExtensionTypeFlag[1]) |
---|
| 863 | { |
---|
| 864 | parseSPSExtension( pcSPS ); |
---|
| 865 | } |
---|
| 866 | if (spsExtensionTypeFlag[7]) |
---|
| 867 | { |
---|
| 868 | #else |
---|
[313] | 869 | parseSPSExtension( pcSPS ); |
---|
| 870 | READ_FLAG( uiCode, "sps_extension2_flag"); |
---|
| 871 | if(uiCode) |
---|
| 872 | { |
---|
| 873 | #endif |
---|
| 874 | while ( xMoreRbspData() ) |
---|
| 875 | { |
---|
| 876 | READ_FLAG( uiCode, "sps_extension_data_flag"); |
---|
| 877 | } |
---|
| 878 | } |
---|
[815] | 879 | } |
---|
| 880 | #else |
---|
| 881 | if (uiCode) |
---|
| 882 | { |
---|
| 883 | while ( xMoreRbspData() ) |
---|
| 884 | { |
---|
| 885 | READ_FLAG( uiCode, "sps_extension_data_flag"); |
---|
| 886 | } |
---|
| 887 | } |
---|
[313] | 888 | #endif |
---|
| 889 | } |
---|
| 890 | |
---|
[815] | 891 | #if SVC_EXTENSION |
---|
[313] | 892 | Void TDecCavlc::parseSPSExtension( TComSPS* pcSPS ) |
---|
| 893 | { |
---|
| 894 | UInt uiCode; |
---|
| 895 | // more syntax elements to be parsed here |
---|
[442] | 896 | |
---|
| 897 | READ_FLAG( uiCode, "inter_view_mv_vert_constraint_flag" ); |
---|
| 898 | // Vertical MV component restriction is not used in SHVC CTC |
---|
| 899 | assert( uiCode == 0 ); |
---|
[588] | 900 | |
---|
[313] | 901 | if( pcSPS->getLayerId() > 0 ) |
---|
| 902 | { |
---|
[494] | 903 | Int iCode; |
---|
[313] | 904 | READ_UVLC( uiCode, "num_scaled_ref_layer_offsets" ); pcSPS->setNumScaledRefLayerOffsets(uiCode); |
---|
| 905 | for(Int i = 0; i < pcSPS->getNumScaledRefLayerOffsets(); i++) |
---|
| 906 | { |
---|
| 907 | Window& scaledWindow = pcSPS->getScaledRefLayerWindow(i); |
---|
[540] | 908 | #if O0098_SCALED_REF_LAYER_ID |
---|
[644] | 909 | READ_CODE( 6, uiCode, "scaled_ref_layer_id" ); pcSPS->setScaledRefLayerId( i, uiCode ); |
---|
[540] | 910 | #endif |
---|
[313] | 911 | READ_SVLC( iCode, "scaled_ref_layer_left_offset" ); scaledWindow.setWindowLeftOffset (iCode << 1); |
---|
| 912 | READ_SVLC( iCode, "scaled_ref_layer_top_offset" ); scaledWindow.setWindowTopOffset (iCode << 1); |
---|
| 913 | READ_SVLC( iCode, "scaled_ref_layer_right_offset" ); scaledWindow.setWindowRightOffset (iCode << 1); |
---|
| 914 | READ_SVLC( iCode, "scaled_ref_layer_bottom_offset" ); scaledWindow.setWindowBottomOffset(iCode << 1); |
---|
[644] | 915 | #if P0312_VERT_PHASE_ADJ |
---|
| 916 | READ_FLAG( uiCode, "vert_phase_position_enable_flag" ); scaledWindow.setVertPhasePositionEnableFlag(uiCode); pcSPS->setVertPhasePositionEnableFlag( pcSPS->getScaledRefLayerId(i), uiCode); |
---|
| 917 | #endif |
---|
[313] | 918 | } |
---|
| 919 | } |
---|
| 920 | } |
---|
| 921 | #endif |
---|
| 922 | |
---|
| 923 | Void TDecCavlc::parseVPS(TComVPS* pcVPS) |
---|
| 924 | { |
---|
| 925 | UInt uiCode; |
---|
| 926 | |
---|
| 927 | READ_CODE( 4, uiCode, "vps_video_parameter_set_id" ); pcVPS->setVPSId( uiCode ); |
---|
| 928 | READ_CODE( 2, uiCode, "vps_reserved_three_2bits" ); assert(uiCode == 3); |
---|
[815] | 929 | #if SVC_EXTENSION |
---|
[547] | 930 | #if O0137_MAX_LAYERID |
---|
| 931 | READ_CODE( 6, uiCode, "vps_max_layers_minus1" ); pcVPS->setMaxLayers( min( 62u, uiCode) + 1 ); |
---|
[313] | 932 | #else |
---|
[547] | 933 | READ_CODE( 6, uiCode, "vps_max_layers_minus1" ); pcVPS->setMaxLayers( uiCode + 1 ); |
---|
| 934 | #endif |
---|
| 935 | #else |
---|
[313] | 936 | READ_CODE( 6, uiCode, "vps_reserved_zero_6bits" ); assert(uiCode == 0); |
---|
| 937 | #endif |
---|
[713] | 938 | READ_CODE( 3, uiCode, "vps_max_sub_layers_minus1" ); pcVPS->setMaxTLayers( uiCode + 1 ); assert(uiCode+1 <= MAX_TLAYER); |
---|
[313] | 939 | READ_FLAG( uiCode, "vps_temporal_id_nesting_flag" ); pcVPS->setTemporalNestingFlag( uiCode ? true:false ); |
---|
| 940 | assert (pcVPS->getMaxTLayers()>1||pcVPS->getTemporalNestingFlag()); |
---|
[588] | 941 | #if !P0125_REVERT_VPS_EXTN_OFFSET_TO_RESERVED |
---|
[442] | 942 | #if VPS_EXTN_OFFSET |
---|
| 943 | READ_CODE( 16, uiCode, "vps_extension_offset" ); pcVPS->setExtensionOffset( uiCode ); |
---|
| 944 | #else |
---|
[313] | 945 | READ_CODE( 16, uiCode, "vps_reserved_ffff_16bits" ); assert(uiCode == 0xffff); |
---|
[442] | 946 | #endif |
---|
[588] | 947 | #else |
---|
| 948 | READ_CODE( 16, uiCode, "vps_reserved_ffff_16bits" ); assert(uiCode == 0xffff); |
---|
| 949 | #endif |
---|
[313] | 950 | parsePTL ( pcVPS->getPTL(), true, pcVPS->getMaxTLayers()-1); |
---|
| 951 | UInt subLayerOrderingInfoPresentFlag; |
---|
| 952 | READ_FLAG(subLayerOrderingInfoPresentFlag, "vps_sub_layer_ordering_info_present_flag"); |
---|
| 953 | for(UInt i = 0; i <= pcVPS->getMaxTLayers()-1; i++) |
---|
| 954 | { |
---|
| 955 | READ_UVLC( uiCode, "vps_max_dec_pic_buffering_minus1[i]" ); pcVPS->setMaxDecPicBuffering( uiCode + 1, i ); |
---|
| 956 | READ_UVLC( uiCode, "vps_num_reorder_pics[i]" ); pcVPS->setNumReorderPics( uiCode, i ); |
---|
| 957 | READ_UVLC( uiCode, "vps_max_latency_increase_plus1[i]" ); pcVPS->setMaxLatencyIncrease( uiCode, i ); |
---|
| 958 | |
---|
| 959 | if (!subLayerOrderingInfoPresentFlag) |
---|
| 960 | { |
---|
| 961 | for (i++; i <= pcVPS->getMaxTLayers()-1; i++) |
---|
| 962 | { |
---|
| 963 | pcVPS->setMaxDecPicBuffering(pcVPS->getMaxDecPicBuffering(0), i); |
---|
| 964 | pcVPS->setNumReorderPics(pcVPS->getNumReorderPics(0), i); |
---|
| 965 | pcVPS->setMaxLatencyIncrease(pcVPS->getMaxLatencyIncrease(0), i); |
---|
| 966 | } |
---|
| 967 | break; |
---|
| 968 | } |
---|
| 969 | } |
---|
| 970 | |
---|
[815] | 971 | #if SVC_EXTENSION |
---|
[313] | 972 | assert( pcVPS->getNumHrdParameters() < MAX_VPS_LAYER_SETS_PLUS1 ); |
---|
| 973 | assert( pcVPS->getMaxLayerId() < MAX_VPS_LAYER_ID_PLUS1 ); |
---|
| 974 | READ_CODE( 6, uiCode, "vps_max_layer_id" ); pcVPS->setMaxLayerId( uiCode ); |
---|
[815] | 975 | #if Q0078_ADD_LAYER_SETS |
---|
| 976 | READ_UVLC(uiCode, "vps_num_layer_sets_minus1"); pcVPS->setVpsNumLayerSetsMinus1(uiCode); |
---|
| 977 | pcVPS->setNumLayerSets(pcVPS->getVpsNumLayerSetsMinus1() + 1); |
---|
| 978 | for (UInt opsIdx = 1; opsIdx <= pcVPS->getVpsNumLayerSetsMinus1(); opsIdx++) |
---|
| 979 | #else |
---|
[313] | 980 | READ_UVLC( uiCode, "vps_num_layer_sets_minus1" ); pcVPS->setNumLayerSets( uiCode + 1 ); |
---|
| 981 | for( UInt opsIdx = 1; opsIdx <= ( pcVPS->getNumLayerSets() - 1 ); opsIdx ++ ) |
---|
[815] | 982 | #endif |
---|
[313] | 983 | { |
---|
| 984 | // Operation point set |
---|
| 985 | for( UInt i = 0; i <= pcVPS->getMaxLayerId(); i ++ ) |
---|
| 986 | #else |
---|
| 987 | assert( pcVPS->getNumHrdParameters() < MAX_VPS_OP_SETS_PLUS1 ); |
---|
| 988 | assert( pcVPS->getMaxNuhReservedZeroLayerId() < MAX_VPS_NUH_RESERVED_ZERO_LAYER_ID_PLUS1 ); |
---|
| 989 | READ_CODE( 6, uiCode, "vps_max_nuh_reserved_zero_layer_id" ); pcVPS->setMaxNuhReservedZeroLayerId( uiCode ); |
---|
| 990 | READ_UVLC( uiCode, "vps_max_op_sets_minus1" ); pcVPS->setMaxOpSets( uiCode + 1 ); |
---|
| 991 | for( UInt opsIdx = 1; opsIdx <= ( pcVPS->getMaxOpSets() - 1 ); opsIdx ++ ) |
---|
| 992 | { |
---|
| 993 | // Operation point set |
---|
| 994 | for( UInt i = 0; i <= pcVPS->getMaxNuhReservedZeroLayerId(); i ++ ) |
---|
| 995 | #endif |
---|
| 996 | { |
---|
| 997 | READ_FLAG( uiCode, "layer_id_included_flag[opsIdx][i]" ); pcVPS->setLayerIdIncludedFlag( uiCode == 1 ? true : false, opsIdx, i ); |
---|
| 998 | } |
---|
| 999 | } |
---|
| 1000 | #if DERIVE_LAYER_ID_LIST_VARIABLES |
---|
| 1001 | pcVPS->deriveLayerIdListVariables(); |
---|
| 1002 | #endif |
---|
| 1003 | TimingInfo *timingInfo = pcVPS->getTimingInfo(); |
---|
| 1004 | READ_FLAG( uiCode, "vps_timing_info_present_flag"); timingInfo->setTimingInfoPresentFlag (uiCode ? true : false); |
---|
| 1005 | if(timingInfo->getTimingInfoPresentFlag()) |
---|
| 1006 | { |
---|
| 1007 | READ_CODE( 32, uiCode, "vps_num_units_in_tick"); timingInfo->setNumUnitsInTick (uiCode); |
---|
| 1008 | READ_CODE( 32, uiCode, "vps_time_scale"); timingInfo->setTimeScale (uiCode); |
---|
| 1009 | READ_FLAG( uiCode, "vps_poc_proportional_to_timing_flag"); timingInfo->setPocProportionalToTimingFlag(uiCode ? true : false); |
---|
| 1010 | if(timingInfo->getPocProportionalToTimingFlag()) |
---|
| 1011 | { |
---|
| 1012 | READ_UVLC( uiCode, "vps_num_ticks_poc_diff_one_minus1"); timingInfo->setNumTicksPocDiffOneMinus1 (uiCode); |
---|
| 1013 | } |
---|
| 1014 | READ_UVLC( uiCode, "vps_num_hrd_parameters" ); pcVPS->setNumHrdParameters( uiCode ); |
---|
| 1015 | |
---|
| 1016 | if( pcVPS->getNumHrdParameters() > 0 ) |
---|
| 1017 | { |
---|
| 1018 | pcVPS->createHrdParamBuffer(); |
---|
| 1019 | } |
---|
| 1020 | for( UInt i = 0; i < pcVPS->getNumHrdParameters(); i ++ ) |
---|
| 1021 | { |
---|
| 1022 | READ_UVLC( uiCode, "hrd_op_set_idx" ); pcVPS->setHrdOpSetIdx( uiCode, i ); |
---|
| 1023 | if( i > 0 ) |
---|
| 1024 | { |
---|
| 1025 | READ_FLAG( uiCode, "cprms_present_flag[i]" ); pcVPS->setCprmsPresentFlag( uiCode == 1 ? true : false, i ); |
---|
| 1026 | } |
---|
| 1027 | parseHrdParameters(pcVPS->getHrdParameters(i), pcVPS->getCprmsPresentFlag( i ), pcVPS->getMaxTLayers() - 1); |
---|
| 1028 | } |
---|
| 1029 | } |
---|
[713] | 1030 | |
---|
[815] | 1031 | #if SVC_EXTENSION |
---|
[713] | 1032 | READ_FLAG( uiCode, "vps_extension_flag" ); pcVPS->setVpsExtensionFlag( uiCode ? true : false ); |
---|
| 1033 | |
---|
| 1034 | // When MaxLayersMinus1 is greater than 0, vps_extension_flag shall be equal to 1. |
---|
| 1035 | if( pcVPS->getMaxLayers() > 1 ) |
---|
[313] | 1036 | { |
---|
[713] | 1037 | assert( pcVPS->getVpsExtensionFlag() == true ); |
---|
| 1038 | } |
---|
| 1039 | |
---|
| 1040 | if( pcVPS->getVpsExtensionFlag() ) |
---|
| 1041 | { |
---|
[442] | 1042 | while ( m_pcBitstream->getNumBitsRead() % 8 != 0 ) |
---|
| 1043 | { |
---|
| 1044 | READ_FLAG( uiCode, "vps_extension_alignment_bit_equal_to_one"); assert(uiCode == 1); |
---|
| 1045 | } |
---|
[313] | 1046 | parseVPSExtension(pcVPS); |
---|
| 1047 | READ_FLAG( uiCode, "vps_entension2_flag" ); |
---|
| 1048 | if(uiCode) |
---|
| 1049 | { |
---|
| 1050 | while ( xMoreRbspData() ) |
---|
| 1051 | { |
---|
| 1052 | READ_FLAG( uiCode, "vps_extension_data_flag"); |
---|
| 1053 | } |
---|
| 1054 | } |
---|
[713] | 1055 | } |
---|
| 1056 | else |
---|
| 1057 | { |
---|
| 1058 | // set default parameters when syntax elements are not present |
---|
| 1059 | defaultVPSExtension(pcVPS); |
---|
| 1060 | } |
---|
[313] | 1061 | #else |
---|
[713] | 1062 | READ_FLAG( uiCode, "vps_extension_flag" ); |
---|
| 1063 | if (uiCode) |
---|
| 1064 | { |
---|
[313] | 1065 | while ( xMoreRbspData() ) |
---|
| 1066 | { |
---|
| 1067 | READ_FLAG( uiCode, "vps_extension_data_flag"); |
---|
| 1068 | } |
---|
[713] | 1069 | } |
---|
[313] | 1070 | #endif |
---|
| 1071 | |
---|
| 1072 | return; |
---|
| 1073 | } |
---|
| 1074 | |
---|
[494] | 1075 | #if SVC_EXTENSION |
---|
[313] | 1076 | Void TDecCavlc::parseVPSExtension(TComVPS *vps) |
---|
| 1077 | { |
---|
| 1078 | UInt uiCode; |
---|
| 1079 | // ... More syntax elements to be parsed here |
---|
[644] | 1080 | #if P0300_ALT_OUTPUT_LAYER_FLAG |
---|
| 1081 | Int NumOutputLayersInOutputLayerSet[MAX_VPS_LAYER_SETS_PLUS1]; |
---|
| 1082 | Int OlsHighestOutputLayerId[MAX_VPS_LAYER_SETS_PLUS1]; |
---|
| 1083 | #endif |
---|
[313] | 1084 | #if VPS_EXTN_MASK_AND_DIM_INFO |
---|
| 1085 | UInt numScalabilityTypes = 0, i = 0, j = 0; |
---|
| 1086 | |
---|
| 1087 | READ_FLAG( uiCode, "avc_base_layer_flag" ); vps->setAvcBaseLayerFlag(uiCode ? true : false); |
---|
[547] | 1088 | |
---|
[588] | 1089 | #if !P0307_REMOVE_VPS_VUI_OFFSET |
---|
[547] | 1090 | #if O0109_MOVE_VPS_VUI_FLAG |
---|
| 1091 | READ_FLAG( uiCode, "vps_vui_present_flag"); vps->setVpsVuiPresentFlag(uiCode ? true : false); |
---|
| 1092 | if ( uiCode ) |
---|
| 1093 | { |
---|
| 1094 | #endif |
---|
| 1095 | #if VPS_VUI_OFFSET |
---|
| 1096 | READ_CODE( 16, uiCode, "vps_vui_offset" ); vps->setVpsVuiOffset( uiCode ); |
---|
| 1097 | #endif |
---|
| 1098 | #if O0109_MOVE_VPS_VUI_FLAG |
---|
| 1099 | } |
---|
| 1100 | #endif |
---|
[588] | 1101 | #endif |
---|
[313] | 1102 | READ_FLAG( uiCode, "splitting_flag" ); vps->setSplittingFlag(uiCode ? true : false); |
---|
| 1103 | |
---|
| 1104 | for(i = 0; i < MAX_VPS_NUM_SCALABILITY_TYPES; i++) |
---|
| 1105 | { |
---|
| 1106 | READ_FLAG( uiCode, "scalability_mask[i]" ); vps->setScalabilityMask(i, uiCode ? true : false); |
---|
| 1107 | numScalabilityTypes += uiCode; |
---|
| 1108 | } |
---|
| 1109 | vps->setNumScalabilityTypes(numScalabilityTypes); |
---|
| 1110 | |
---|
| 1111 | for(j = 0; j < numScalabilityTypes - vps->getSplittingFlag(); j++) |
---|
| 1112 | { |
---|
| 1113 | READ_CODE( 3, uiCode, "dimension_id_len_minus1[j]" ); vps->setDimensionIdLen(j, uiCode + 1); |
---|
| 1114 | } |
---|
[494] | 1115 | |
---|
[815] | 1116 | // The value of dimBitOffset[ NumScalabilityTypes ] is set equal to 6. |
---|
[313] | 1117 | if(vps->getSplittingFlag()) |
---|
| 1118 | { |
---|
| 1119 | UInt numBits = 0; |
---|
| 1120 | for(j = 0; j < numScalabilityTypes - 1; j++) |
---|
| 1121 | { |
---|
| 1122 | numBits += vps->getDimensionIdLen(j); |
---|
| 1123 | } |
---|
| 1124 | assert( numBits < 6 ); |
---|
| 1125 | vps->setDimensionIdLen(numScalabilityTypes-1, 6 - numBits); |
---|
| 1126 | numBits = 6; |
---|
| 1127 | } |
---|
| 1128 | |
---|
| 1129 | READ_FLAG( uiCode, "vps_nuh_layer_id_present_flag" ); vps->setNuhLayerIdPresentFlag(uiCode ? true : false); |
---|
| 1130 | vps->setLayerIdInNuh(0, 0); |
---|
| 1131 | vps->setLayerIdInVps(0, 0); |
---|
| 1132 | for(i = 1; i < vps->getMaxLayers(); i++) |
---|
| 1133 | { |
---|
| 1134 | if( vps->getNuhLayerIdPresentFlag() ) |
---|
| 1135 | { |
---|
| 1136 | READ_CODE( 6, uiCode, "layer_id_in_nuh[i]" ); vps->setLayerIdInNuh(i, uiCode); |
---|
| 1137 | assert( uiCode > vps->getLayerIdInNuh(i-1) ); |
---|
| 1138 | } |
---|
| 1139 | else |
---|
| 1140 | { |
---|
| 1141 | vps->setLayerIdInNuh(i, i); |
---|
| 1142 | } |
---|
| 1143 | vps->setLayerIdInVps(vps->getLayerIdInNuh(i), i); |
---|
| 1144 | |
---|
[494] | 1145 | if( !vps->getSplittingFlag() ) |
---|
| 1146 | { |
---|
[313] | 1147 | for(j = 0; j < numScalabilityTypes; j++) |
---|
| 1148 | { |
---|
| 1149 | READ_CODE( vps->getDimensionIdLen(j), uiCode, "dimension_id[i][j]" ); vps->setDimensionId(i, j, uiCode); |
---|
[494] | 1150 | #if !AUXILIARY_PICTURES |
---|
[313] | 1151 | assert( uiCode <= vps->getMaxLayerId() ); |
---|
[494] | 1152 | #endif |
---|
[313] | 1153 | } |
---|
| 1154 | } |
---|
[494] | 1155 | } |
---|
[313] | 1156 | #endif |
---|
[494] | 1157 | #if VIEW_ID_RELATED_SIGNALING |
---|
| 1158 | // if ( pcVPS->getNumViews() > 1 ) |
---|
| 1159 | // However, this is a bug in the text since, view_id_len_minus1 is needed to parse view_id_val. |
---|
[442] | 1160 | { |
---|
[547] | 1161 | #if O0109_VIEW_ID_LEN |
---|
| 1162 | READ_CODE( 4, uiCode, "view_id_len" ); vps->setViewIdLen( uiCode ); |
---|
| 1163 | #else |
---|
[442] | 1164 | READ_CODE( 4, uiCode, "view_id_len_minus1" ); vps->setViewIdLenMinus1( uiCode ); |
---|
[547] | 1165 | #endif |
---|
[442] | 1166 | } |
---|
| 1167 | |
---|
[547] | 1168 | #if O0109_VIEW_ID_LEN |
---|
| 1169 | if ( vps->getViewIdLen() > 0 ) |
---|
| 1170 | { |
---|
| 1171 | for( i = 0; i < vps->getNumViews(); i++ ) |
---|
| 1172 | { |
---|
| 1173 | READ_CODE( vps->getViewIdLen( ), uiCode, "view_id_val[i]" ); vps->setViewIdVal( i, uiCode ); |
---|
| 1174 | } |
---|
| 1175 | } |
---|
| 1176 | #else |
---|
[442] | 1177 | for( i = 0; i < vps->getNumViews(); i++ ) |
---|
| 1178 | { |
---|
| 1179 | READ_CODE( vps->getViewIdLenMinus1( ) + 1, uiCode, "view_id_val[i]" ); vps->setViewIdVal( i, uiCode ); |
---|
| 1180 | } |
---|
| 1181 | #endif |
---|
[547] | 1182 | #endif // view id related signaling |
---|
[313] | 1183 | #if VPS_EXTN_DIRECT_REF_LAYERS |
---|
| 1184 | // For layer 0 |
---|
| 1185 | vps->setNumDirectRefLayers(0, 0); |
---|
| 1186 | // For other layers |
---|
| 1187 | for( Int layerCtr = 1; layerCtr <= vps->getMaxLayers() - 1; layerCtr++) |
---|
| 1188 | { |
---|
| 1189 | UInt numDirectRefLayers = 0; |
---|
| 1190 | for( Int refLayerCtr = 0; refLayerCtr < layerCtr; refLayerCtr++) |
---|
| 1191 | { |
---|
| 1192 | READ_FLAG(uiCode, "direct_dependency_flag[i][j]" ); vps->setDirectDependencyFlag(layerCtr, refLayerCtr, uiCode? true : false); |
---|
| 1193 | if(uiCode) |
---|
| 1194 | { |
---|
| 1195 | vps->setRefLayerId(layerCtr, numDirectRefLayers, refLayerCtr); |
---|
| 1196 | numDirectRefLayers++; |
---|
| 1197 | } |
---|
| 1198 | } |
---|
| 1199 | vps->setNumDirectRefLayers(layerCtr, numDirectRefLayers); |
---|
| 1200 | } |
---|
| 1201 | #endif |
---|
[815] | 1202 | #if Q0078_ADD_LAYER_SETS |
---|
| 1203 | #if O0092_0094_DEPENDENCY_CONSTRAINT // Moved here |
---|
| 1204 | vps->setNumRefLayers(); |
---|
| 1205 | |
---|
| 1206 | if (vps->getMaxLayers() > MAX_REF_LAYERS) |
---|
| 1207 | { |
---|
| 1208 | for (i = 1; i < vps->getMaxLayers(); i++) |
---|
| 1209 | { |
---|
| 1210 | assert(vps->getNumRefLayers(vps->getLayerIdInNuh(i)) <= MAX_REF_LAYERS); |
---|
| 1211 | } |
---|
| 1212 | } |
---|
| 1213 | #endif |
---|
| 1214 | vps->setPredictedLayerIds(); |
---|
| 1215 | vps->setTreePartitionLayerIdList(); |
---|
| 1216 | #endif |
---|
[540] | 1217 | #if VPS_TSLAYERS |
---|
[713] | 1218 | READ_FLAG( uiCode, "vps_sub_layers_max_minus1_present_flag"); vps->setMaxTSLayersPresentFlag(uiCode ? true : false); |
---|
| 1219 | |
---|
| 1220 | if (vps->getMaxTSLayersPresentFlag()) |
---|
| 1221 | { |
---|
| 1222 | for(i = 0; i < vps->getMaxLayers(); i++) |
---|
[540] | 1223 | { |
---|
[713] | 1224 | READ_CODE( 3, uiCode, "sub_layers_vps_max_minus1[i]" ); vps->setMaxTSLayersMinus1(i, uiCode); |
---|
[540] | 1225 | } |
---|
[713] | 1226 | } |
---|
| 1227 | else |
---|
| 1228 | { |
---|
| 1229 | for( i = 0; i < vps->getMaxLayers(); i++) |
---|
[540] | 1230 | { |
---|
[713] | 1231 | vps->setMaxTSLayersMinus1(i, vps->getMaxTLayers()-1); |
---|
[540] | 1232 | } |
---|
[713] | 1233 | } |
---|
[540] | 1234 | #endif |
---|
[442] | 1235 | READ_FLAG( uiCode, "max_tid_ref_present_flag"); vps->setMaxTidRefPresentFlag(uiCode ? true : false); |
---|
| 1236 | if (vps->getMaxTidRefPresentFlag()) |
---|
[345] | 1237 | { |
---|
| 1238 | for(i = 0; i < vps->getMaxLayers() - 1; i++) |
---|
| 1239 | { |
---|
[494] | 1240 | #if O0225_MAX_TID_FOR_REF_LAYERS |
---|
| 1241 | for( j = i+1; j <= vps->getMaxLayers() - 1; j++) |
---|
| 1242 | { |
---|
| 1243 | if(vps->getDirectDependencyFlag(j, i)) |
---|
| 1244 | { |
---|
| 1245 | READ_CODE( 3, uiCode, "max_tid_il_ref_pics_plus1[i][j]" ); vps->setMaxTidIlRefPicsPlus1(i, j, uiCode); |
---|
| 1246 | assert( uiCode <= vps->getMaxTLayers()); |
---|
| 1247 | } |
---|
| 1248 | } |
---|
| 1249 | #else |
---|
[442] | 1250 | READ_CODE( 3, uiCode, "max_tid_il_ref_pics_plus1[i]" ); vps->setMaxTidIlRefPicsPlus1(i, uiCode); |
---|
| 1251 | assert( uiCode <= vps->getMaxTLayers()); |
---|
| 1252 | #endif |
---|
[345] | 1253 | } |
---|
| 1254 | } |
---|
[494] | 1255 | else |
---|
[345] | 1256 | { |
---|
| 1257 | for(i = 0; i < vps->getMaxLayers() - 1; i++) |
---|
| 1258 | { |
---|
[494] | 1259 | #if O0225_MAX_TID_FOR_REF_LAYERS |
---|
| 1260 | for( j = i+1; j <= vps->getMaxLayers() - 1; j++) |
---|
| 1261 | { |
---|
| 1262 | vps->setMaxTidIlRefPicsPlus1(i, j, 7); |
---|
| 1263 | } |
---|
| 1264 | #else |
---|
[442] | 1265 | vps->setMaxTidIlRefPicsPlus1(i, 7); |
---|
[494] | 1266 | #endif |
---|
[345] | 1267 | } |
---|
| 1268 | } |
---|
[815] | 1269 | READ_FLAG( uiCode, "all_ref_layers_active_flag" ); vps->setIlpSshSignalingEnabledFlag(uiCode ? true : false); |
---|
[313] | 1270 | #if VPS_EXTN_PROFILE_INFO |
---|
| 1271 | // Profile-tier-level signalling |
---|
[588] | 1272 | #if !VPS_EXTN_UEV_CODING |
---|
[313] | 1273 | READ_CODE( 10, uiCode, "vps_number_layer_sets_minus1" ); assert( uiCode == (vps->getNumLayerSets() - 1) ); |
---|
| 1274 | READ_CODE( 6, uiCode, "vps_num_profile_tier_level_minus1"); vps->setNumProfileTierLevel( uiCode + 1 ); |
---|
[588] | 1275 | #else |
---|
| 1276 | READ_UVLC( uiCode, "vps_num_profile_tier_level_minus1"); vps->setNumProfileTierLevel( uiCode + 1 ); |
---|
| 1277 | #endif |
---|
[313] | 1278 | vps->getPTLForExtnPtr()->resize(vps->getNumProfileTierLevel()); |
---|
| 1279 | for(Int idx = 1; idx <= vps->getNumProfileTierLevel() - 1; idx++) |
---|
| 1280 | { |
---|
| 1281 | READ_FLAG( uiCode, "vps_profile_present_flag[i]" ); vps->setProfilePresentFlag(idx, uiCode ? true : false); |
---|
| 1282 | if( !vps->getProfilePresentFlag(idx) ) |
---|
| 1283 | { |
---|
[588] | 1284 | #if P0048_REMOVE_PROFILE_REF |
---|
| 1285 | // Copy profile information from previous one |
---|
| 1286 | vps->getPTLForExtn(idx)->copyProfileInfo( (idx==1) ? vps->getPTL() : vps->getPTLForExtn( idx - 1 ) ); |
---|
| 1287 | #else |
---|
[313] | 1288 | READ_CODE( 6, uiCode, "profile_ref_minus1[i]" ); vps->setProfileLayerSetRef(idx, uiCode + 1); |
---|
[547] | 1289 | #if O0109_PROF_REF_MINUS1 |
---|
| 1290 | assert( vps->getProfileLayerSetRef(idx) <= idx ); |
---|
| 1291 | #else |
---|
[313] | 1292 | assert( vps->getProfileLayerSetRef(idx) < idx ); |
---|
[547] | 1293 | #endif |
---|
[313] | 1294 | // Copy profile information as indicated |
---|
| 1295 | vps->getPTLForExtn(idx)->copyProfileInfo( vps->getPTLForExtn( vps->getProfileLayerSetRef(idx) ) ); |
---|
[588] | 1296 | #endif |
---|
[313] | 1297 | } |
---|
| 1298 | parsePTL( vps->getPTLForExtn(idx), vps->getProfilePresentFlag(idx), vps->getMaxTLayers() - 1 ); |
---|
| 1299 | } |
---|
| 1300 | #endif |
---|
| 1301 | |
---|
[815] | 1302 | #if Q0078_ADD_LAYER_SETS |
---|
| 1303 | if (vps->getNumIndependentLayers() > 1) |
---|
| 1304 | { |
---|
| 1305 | READ_UVLC(uiCode, "num_add_layer_sets"); vps->setNumAddLayerSets(uiCode); |
---|
| 1306 | for (i = 0; i < vps->getNumAddLayerSets(); i++) |
---|
| 1307 | { |
---|
| 1308 | for (j = 1; j < vps->getNumIndependentLayers(); j++) |
---|
| 1309 | { |
---|
| 1310 | int len = 1; |
---|
| 1311 | while ((1 << len) < (vps->getNumLayersInTreePartition(j) + 1)) |
---|
| 1312 | { |
---|
| 1313 | len++; |
---|
| 1314 | } |
---|
| 1315 | READ_CODE(len, uiCode, "highest_layer_idx_plus1[i][j]"); vps->setHighestLayerIdxPlus1(i, j, uiCode); |
---|
| 1316 | } |
---|
| 1317 | } |
---|
| 1318 | vps->setNumLayerSets(vps->getNumLayerSets() + vps->getNumAddLayerSets()); |
---|
| 1319 | vps->setLayerIdIncludedFlagsForAddLayerSets(); |
---|
| 1320 | } |
---|
| 1321 | #endif |
---|
| 1322 | |
---|
[588] | 1323 | #if !VPS_EXTN_UEV_CODING |
---|
[313] | 1324 | READ_FLAG( uiCode, "more_output_layer_sets_than_default_flag" ); vps->setMoreOutputLayerSetsThanDefaultFlag( uiCode ? true : false ); |
---|
| 1325 | Int numOutputLayerSets = 0; |
---|
| 1326 | if(! vps->getMoreOutputLayerSetsThanDefaultFlag() ) |
---|
| 1327 | { |
---|
| 1328 | numOutputLayerSets = vps->getNumLayerSets(); |
---|
| 1329 | } |
---|
| 1330 | else |
---|
| 1331 | { |
---|
| 1332 | READ_CODE( 10, uiCode, "num_add_output_layer_sets" ); vps->setNumAddOutputLayerSets( uiCode ); |
---|
| 1333 | numOutputLayerSets = vps->getNumLayerSets() + vps->getNumAddOutputLayerSets(); |
---|
| 1334 | } |
---|
[588] | 1335 | #else |
---|
[713] | 1336 | |
---|
| 1337 | #if Q0165_NUM_ADD_OUTPUT_LAYER_SETS |
---|
| 1338 | if( vps->getNumLayerSets() > 1 ) |
---|
| 1339 | { |
---|
[815] | 1340 | READ_UVLC( uiCode, "num_add_olss" ); vps->setNumAddOutputLayerSets( uiCode ); |
---|
| 1341 | READ_CODE( 2, uiCode, "default_output_layer_idc" ); vps->setDefaultTargetOutputLayerIdc( uiCode ); |
---|
[713] | 1342 | } |
---|
| 1343 | else |
---|
| 1344 | { |
---|
| 1345 | vps->setNumAddOutputLayerSets( 0 ); |
---|
| 1346 | } |
---|
| 1347 | #else |
---|
[588] | 1348 | READ_UVLC( uiCode, "num_add_output_layer_sets" ); vps->setNumAddOutputLayerSets( uiCode ); |
---|
[713] | 1349 | #endif |
---|
| 1350 | |
---|
[815] | 1351 | // The value of num_add_olss shall be in the range of 0 to 1023, inclusive. |
---|
[713] | 1352 | assert( vps->getNumAddOutputLayerSets() >= 0 && vps->getNumAddOutputLayerSets() < 1024 ); |
---|
| 1353 | |
---|
[588] | 1354 | Int numOutputLayerSets = vps->getNumLayerSets() + vps->getNumAddOutputLayerSets(); |
---|
| 1355 | #endif |
---|
| 1356 | |
---|
| 1357 | #if P0295_DEFAULT_OUT_LAYER_IDC |
---|
[713] | 1358 | #if !Q0165_NUM_ADD_OUTPUT_LAYER_SETS |
---|
[313] | 1359 | if( numOutputLayerSets > 1 ) |
---|
| 1360 | { |
---|
[588] | 1361 | READ_CODE( 2, uiCode, "default_target_output_layer_idc" ); vps->setDefaultTargetOutputLayerIdc( uiCode ); |
---|
| 1362 | } |
---|
[713] | 1363 | #endif |
---|
[588] | 1364 | vps->setNumOutputLayerSets( numOutputLayerSets ); |
---|
| 1365 | |
---|
| 1366 | for(i = 1; i < numOutputLayerSets; i++) |
---|
| 1367 | { |
---|
| 1368 | if( i > (vps->getNumLayerSets() - 1) ) |
---|
| 1369 | { |
---|
| 1370 | Int numBits = 1; |
---|
| 1371 | while ((1 << numBits) < (vps->getNumLayerSets() - 1)) |
---|
| 1372 | { |
---|
| 1373 | numBits++; |
---|
| 1374 | } |
---|
[815] | 1375 | READ_CODE( numBits, uiCode, "layer_set_idx_for_ols_minus1"); vps->setOutputLayerSetIdx( i, uiCode + 1); |
---|
[588] | 1376 | } |
---|
| 1377 | else |
---|
| 1378 | { |
---|
| 1379 | vps->setOutputLayerSetIdx( i, i ); |
---|
| 1380 | } |
---|
[815] | 1381 | #if Q0078_ADD_LAYER_SETS |
---|
| 1382 | if ( i > vps->getVpsNumLayerSetsMinus1() || vps->getDefaultTargetOutputLayerIdc() >= 2 ) |
---|
| 1383 | #else |
---|
[588] | 1384 | if ( i > (vps->getNumLayerSets() - 1) || vps->getDefaultTargetOutputLayerIdc() >= 2 ) |
---|
[815] | 1385 | #endif |
---|
[588] | 1386 | { |
---|
| 1387 | Int lsIdx = vps->getOutputLayerSetIdx(i); |
---|
[644] | 1388 | #if NUM_OL_FLAGS |
---|
[649] | 1389 | for(j = 0; j < vps->getNumLayersInIdList(lsIdx); j++) |
---|
[644] | 1390 | #else |
---|
[588] | 1391 | for(j = 0; j < vps->getNumLayersInIdList(lsIdx) - 1; j++) |
---|
[644] | 1392 | #endif |
---|
[588] | 1393 | { |
---|
| 1394 | READ_FLAG( uiCode, "output_layer_flag[i][j]"); vps->setOutputLayerFlag(i, j, uiCode); |
---|
| 1395 | } |
---|
| 1396 | } |
---|
| 1397 | else |
---|
| 1398 | { |
---|
| 1399 | // i <= (vps->getNumLayerSets() - 1) |
---|
| 1400 | // Assign OutputLayerFlag depending on default_one_target_output_layer_flag |
---|
| 1401 | Int lsIdx = i; |
---|
| 1402 | if( vps->getDefaultTargetOutputLayerIdc() == 1 ) |
---|
| 1403 | { |
---|
| 1404 | for(j = 0; j < vps->getNumLayersInIdList(lsIdx); j++) |
---|
| 1405 | { |
---|
| 1406 | vps->setOutputLayerFlag(i, j, (j == (vps->getNumLayersInIdList(lsIdx)-1)) && (vps->getDimensionId(j,1) == 0) ); |
---|
| 1407 | } |
---|
| 1408 | } |
---|
| 1409 | else if ( vps->getDefaultTargetOutputLayerIdc() == 0 ) |
---|
| 1410 | { |
---|
| 1411 | for(j = 0; j < vps->getNumLayersInIdList(lsIdx); j++) |
---|
| 1412 | { |
---|
| 1413 | vps->setOutputLayerFlag(i, j, 1); |
---|
| 1414 | } |
---|
| 1415 | } |
---|
| 1416 | } |
---|
| 1417 | Int numBits = 1; |
---|
| 1418 | while ((1 << numBits) < (vps->getNumProfileTierLevel())) |
---|
| 1419 | { |
---|
| 1420 | numBits++; |
---|
| 1421 | } |
---|
| 1422 | READ_CODE( numBits, uiCode, "profile_level_tier_idx[i]" ); vps->setProfileLevelTierIdx(i, uiCode); |
---|
[644] | 1423 | #if P0300_ALT_OUTPUT_LAYER_FLAG |
---|
| 1424 | NumOutputLayersInOutputLayerSet[i] = 0; |
---|
| 1425 | Int layerSetIdxForOutputLayerSet = vps->getOutputLayerSetIdx(i); |
---|
| 1426 | for (j = 0; j < vps->getNumLayersInIdList(layerSetIdxForOutputLayerSet); j++) |
---|
| 1427 | { |
---|
| 1428 | NumOutputLayersInOutputLayerSet[i] += vps->getOutputLayerFlag(i, j); |
---|
| 1429 | if (vps->getOutputLayerFlag(i, j)) |
---|
| 1430 | { |
---|
| 1431 | OlsHighestOutputLayerId[i] = vps->getLayerSetLayerIdList(layerSetIdxForOutputLayerSet, j); |
---|
| 1432 | } |
---|
| 1433 | } |
---|
| 1434 | if (NumOutputLayersInOutputLayerSet[i] == 1 && vps->getNumDirectRefLayers(OlsHighestOutputLayerId[i]) > 0) |
---|
| 1435 | { |
---|
| 1436 | READ_FLAG(uiCode, "alt_output_layer_flag[i]"); |
---|
| 1437 | vps->setAltOuputLayerFlag(i, uiCode ? true : false); |
---|
| 1438 | } |
---|
[713] | 1439 | #if Q0165_OUTPUT_LAYER_SET |
---|
| 1440 | assert( NumOutputLayersInOutputLayerSet[i]>0 ); |
---|
[644] | 1441 | #endif |
---|
[713] | 1442 | |
---|
| 1443 | #endif |
---|
[588] | 1444 | } |
---|
| 1445 | #else |
---|
| 1446 | if( numOutputLayerSets > 1 ) |
---|
| 1447 | { |
---|
[547] | 1448 | #if O0109_DEFAULT_ONE_OUT_LAYER_IDC |
---|
| 1449 | READ_CODE( 2, uiCode, "default_one_target_output_layer_idc" ); vps->setDefaultOneTargetOutputLayerIdc( uiCode ); |
---|
| 1450 | #else |
---|
[313] | 1451 | READ_FLAG( uiCode, "default_one_target_output_layer_flag" ); vps->setDefaultOneTargetOutputLayerFlag( uiCode ? true : false ); |
---|
[547] | 1452 | #endif |
---|
[313] | 1453 | } |
---|
| 1454 | vps->setNumOutputLayerSets( numOutputLayerSets ); |
---|
| 1455 | |
---|
| 1456 | for(i = 1; i < numOutputLayerSets; i++) |
---|
| 1457 | { |
---|
| 1458 | if( i > (vps->getNumLayerSets() - 1) ) |
---|
| 1459 | { |
---|
| 1460 | Int numBits = 1; |
---|
| 1461 | while ((1 << numBits) < (vps->getNumLayerSets() - 1)) |
---|
| 1462 | { |
---|
| 1463 | numBits++; |
---|
| 1464 | } |
---|
| 1465 | READ_CODE( numBits, uiCode, "output_layer_set_idx_minus1"); vps->setOutputLayerSetIdx( i, uiCode + 1); |
---|
| 1466 | Int lsIdx = vps->getOutputLayerSetIdx(i); |
---|
[644] | 1467 | #if NUM_OL_FLAGS |
---|
| 1468 | for(j = 0; j < vps->getNumLayersInIdList(lsIdx) ; j++) |
---|
| 1469 | #else |
---|
[313] | 1470 | for(j = 0; j < vps->getNumLayersInIdList(lsIdx) - 1; j++) |
---|
[644] | 1471 | #endif |
---|
[313] | 1472 | { |
---|
| 1473 | READ_FLAG( uiCode, "output_layer_flag[i][j]"); vps->setOutputLayerFlag(i, j, uiCode); |
---|
| 1474 | } |
---|
| 1475 | } |
---|
| 1476 | else |
---|
| 1477 | { |
---|
[540] | 1478 | #if VPS_DPB_SIZE_TABLE |
---|
| 1479 | vps->setOutputLayerSetIdx( i, i ); |
---|
| 1480 | #endif |
---|
[313] | 1481 | // i <= (vps->getNumLayerSets() - 1) |
---|
| 1482 | // Assign OutputLayerFlag depending on default_one_target_output_layer_flag |
---|
| 1483 | Int lsIdx = i; |
---|
[547] | 1484 | #if O0109_DEFAULT_ONE_OUT_LAYER_IDC |
---|
| 1485 | if( vps->getDefaultOneTargetOutputLayerIdc() == 1 ) |
---|
| 1486 | { |
---|
| 1487 | for(j = 0; j < vps->getNumLayersInIdList(lsIdx); j++) |
---|
| 1488 | { |
---|
| 1489 | #if O0135_DEFAULT_ONE_OUT_SEMANTIC |
---|
| 1490 | vps->setOutputLayerFlag(i, j, (j == (vps->getNumLayersInIdList(lsIdx)-1)) && (vps->getDimensionId(j,1)==0) ); |
---|
| 1491 | #else |
---|
| 1492 | vps->setOutputLayerFlag(i, j, (j == (vps->getNumLayersInIdList(lsIdx)-1))); |
---|
| 1493 | #endif |
---|
| 1494 | } |
---|
| 1495 | } |
---|
| 1496 | else if ( vps->getDefaultOneTargetOutputLayerIdc() == 0 ) |
---|
| 1497 | { |
---|
| 1498 | for(j = 0; j < vps->getNumLayersInIdList(lsIdx); j++) |
---|
| 1499 | { |
---|
| 1500 | vps->setOutputLayerFlag(i, j, 1); |
---|
| 1501 | } |
---|
| 1502 | } |
---|
| 1503 | else |
---|
| 1504 | { |
---|
| 1505 | // Other values of default_one_target_output_layer_idc than 0 and 1 are reserved for future use. |
---|
| 1506 | } |
---|
| 1507 | #else |
---|
[313] | 1508 | if( vps->getDefaultOneTargetOutputLayerFlag() ) |
---|
| 1509 | { |
---|
| 1510 | for(j = 0; j < vps->getNumLayersInIdList(lsIdx); j++) |
---|
| 1511 | { |
---|
| 1512 | vps->setOutputLayerFlag(i, j, (j == (vps->getNumLayersInIdList(lsIdx)-1))); |
---|
| 1513 | } |
---|
| 1514 | } |
---|
| 1515 | else |
---|
| 1516 | { |
---|
| 1517 | for(j = 0; j < vps->getNumLayersInIdList(lsIdx); j++) |
---|
| 1518 | { |
---|
| 1519 | vps->setOutputLayerFlag(i, j, 1); |
---|
| 1520 | } |
---|
| 1521 | } |
---|
[547] | 1522 | #endif |
---|
[313] | 1523 | } |
---|
| 1524 | Int numBits = 1; |
---|
| 1525 | while ((1 << numBits) < (vps->getNumProfileTierLevel())) |
---|
| 1526 | { |
---|
| 1527 | numBits++; |
---|
| 1528 | } |
---|
| 1529 | READ_CODE( numBits, uiCode, "profile_level_tier_idx[i]" ); vps->setProfileLevelTierIdx(i, uiCode); |
---|
| 1530 | } |
---|
[588] | 1531 | #endif |
---|
[494] | 1532 | |
---|
[644] | 1533 | #if !P0300_ALT_OUTPUT_LAYER_FLAG |
---|
[540] | 1534 | #if O0153_ALT_OUTPUT_LAYER_FLAG |
---|
| 1535 | if( vps->getMaxLayers() > 1 ) |
---|
| 1536 | { |
---|
| 1537 | READ_FLAG( uiCode, "alt_output_layer_flag"); |
---|
| 1538 | vps->setAltOuputLayerFlag( uiCode ? true : false ); |
---|
| 1539 | } |
---|
| 1540 | #endif |
---|
[644] | 1541 | #endif |
---|
[540] | 1542 | |
---|
[442] | 1543 | #if REPN_FORMAT_IN_VPS |
---|
[713] | 1544 | #if Q0195_REP_FORMAT_CLEANUP |
---|
| 1545 | READ_UVLC( uiCode, "vps_num_rep_formats_minus1" ); |
---|
| 1546 | vps->setVpsNumRepFormats( uiCode + 1 ); |
---|
| 1547 | |
---|
| 1548 | // The value of vps_num_rep_formats_minus1 shall be in the range of 0 to 255, inclusive. |
---|
| 1549 | assert( vps->getVpsNumRepFormats() > 0 && vps->getVpsNumRepFormats() <= 256 ); |
---|
| 1550 | |
---|
| 1551 | for(i = 0; i < vps->getVpsNumRepFormats(); i++) |
---|
| 1552 | { |
---|
| 1553 | // Read rep_format_structures |
---|
| 1554 | parseRepFormat( vps->getVpsRepFormat(i), i > 0 ? vps->getVpsRepFormat(i-1) : 0 ); |
---|
| 1555 | } |
---|
| 1556 | |
---|
| 1557 | // Default assignment for layer 0 |
---|
| 1558 | vps->setVpsRepFormatIdx( 0, 0 ); |
---|
| 1559 | |
---|
| 1560 | if( vps->getVpsNumRepFormats() > 1 ) |
---|
| 1561 | { |
---|
| 1562 | READ_FLAG( uiCode, "rep_format_idx_present_flag"); |
---|
| 1563 | vps->setRepFormatIdxPresentFlag( uiCode ? true : false ); |
---|
| 1564 | } |
---|
| 1565 | else |
---|
| 1566 | { |
---|
| 1567 | // When not present, the value of rep_format_idx_present_flag is inferred to be equal to 0 |
---|
| 1568 | vps->setRepFormatIdxPresentFlag( false ); |
---|
| 1569 | } |
---|
| 1570 | |
---|
| 1571 | if( vps->getRepFormatIdxPresentFlag() ) |
---|
| 1572 | { |
---|
| 1573 | for(i = 1; i < vps->getMaxLayers(); i++) |
---|
| 1574 | { |
---|
| 1575 | Int numBits = 1; |
---|
| 1576 | while ((1 << numBits) < (vps->getVpsNumRepFormats())) |
---|
| 1577 | { |
---|
| 1578 | numBits++; |
---|
| 1579 | } |
---|
| 1580 | READ_CODE( numBits, uiCode, "vps_rep_format_idx[i]" ); |
---|
| 1581 | vps->setVpsRepFormatIdx( i, uiCode ); |
---|
| 1582 | } |
---|
| 1583 | } |
---|
| 1584 | else |
---|
| 1585 | { |
---|
| 1586 | // When not present, the value of vps_rep_format_idx[ i ] is inferred to be equal to Min (i, vps_num_rep_formats_minus1) |
---|
| 1587 | for(i = 1; i < vps->getMaxLayers(); i++) |
---|
| 1588 | { |
---|
| 1589 | vps->setVpsRepFormatIdx( i, min( (Int)i, vps->getVpsNumRepFormats()-1 ) ); |
---|
| 1590 | } |
---|
| 1591 | } |
---|
| 1592 | #else |
---|
[494] | 1593 | READ_FLAG( uiCode, "rep_format_idx_present_flag"); |
---|
[442] | 1594 | vps->setRepFormatIdxPresentFlag( uiCode ? true : false ); |
---|
| 1595 | |
---|
| 1596 | if( vps->getRepFormatIdxPresentFlag() ) |
---|
| 1597 | { |
---|
[540] | 1598 | #if O0096_REP_FORMAT_INDEX |
---|
[588] | 1599 | #if !VPS_EXTN_UEV_CODING |
---|
[540] | 1600 | READ_CODE( 8, uiCode, "vps_num_rep_formats_minus1" ); |
---|
| 1601 | #else |
---|
[588] | 1602 | READ_UVLC( uiCode, "vps_num_rep_formats_minus1" ); |
---|
| 1603 | #endif |
---|
| 1604 | #else |
---|
[442] | 1605 | READ_CODE( 4, uiCode, "vps_num_rep_formats_minus1" ); |
---|
[540] | 1606 | #endif |
---|
[442] | 1607 | vps->setVpsNumRepFormats( uiCode + 1 ); |
---|
| 1608 | } |
---|
| 1609 | else |
---|
| 1610 | { |
---|
| 1611 | // default assignment |
---|
| 1612 | assert (vps->getMaxLayers() <= 16); // If max_layers_is more than 15, num_rep_formats has to be signaled |
---|
| 1613 | vps->setVpsNumRepFormats( vps->getMaxLayers() ); |
---|
| 1614 | } |
---|
[713] | 1615 | |
---|
| 1616 | // The value of vps_num_rep_formats_minus1 shall be in the range of 0 to 255, inclusive. |
---|
| 1617 | assert( vps->getVpsNumRepFormats() > 0 && vps->getVpsNumRepFormats() <= 256 ); |
---|
| 1618 | |
---|
[442] | 1619 | for(i = 0; i < vps->getVpsNumRepFormats(); i++) |
---|
| 1620 | { |
---|
| 1621 | // Read rep_format_structures |
---|
[713] | 1622 | parseRepFormat( vps->getVpsRepFormat(i), i > 0 ? vps->getVpsRepFormat(i-1) : 0 ); |
---|
[442] | 1623 | } |
---|
[494] | 1624 | |
---|
[442] | 1625 | // Default assignment for layer 0 |
---|
| 1626 | vps->setVpsRepFormatIdx( 0, 0 ); |
---|
| 1627 | if( vps->getRepFormatIdxPresentFlag() ) |
---|
| 1628 | { |
---|
| 1629 | for(i = 1; i < vps->getMaxLayers(); i++) |
---|
| 1630 | { |
---|
| 1631 | if( vps->getVpsNumRepFormats() > 1 ) |
---|
| 1632 | { |
---|
[540] | 1633 | #if O0096_REP_FORMAT_INDEX |
---|
[588] | 1634 | #if !VPS_EXTN_UEV_CODING |
---|
[540] | 1635 | READ_CODE( 8, uiCode, "vps_rep_format_idx[i]" ); |
---|
| 1636 | #else |
---|
[588] | 1637 | Int numBits = 1; |
---|
| 1638 | while ((1 << numBits) < (vps->getVpsNumRepFormats())) |
---|
| 1639 | { |
---|
| 1640 | numBits++; |
---|
| 1641 | } |
---|
| 1642 | READ_CODE( numBits, uiCode, "vps_rep_format_idx[i]" ); |
---|
| 1643 | #endif |
---|
| 1644 | #else |
---|
[442] | 1645 | READ_CODE( 4, uiCode, "vps_rep_format_idx[i]" ); |
---|
[540] | 1646 | #endif |
---|
[442] | 1647 | vps->setVpsRepFormatIdx( i, uiCode ); |
---|
| 1648 | } |
---|
| 1649 | else |
---|
| 1650 | { |
---|
| 1651 | // default assignment - only one rep_format() structure |
---|
| 1652 | vps->setVpsRepFormatIdx( i, 0 ); |
---|
| 1653 | } |
---|
| 1654 | } |
---|
| 1655 | } |
---|
| 1656 | else |
---|
| 1657 | { |
---|
| 1658 | // default assignment - each layer assigned each rep_format() structure in the order signaled |
---|
| 1659 | for(i = 1; i < vps->getMaxLayers(); i++) |
---|
| 1660 | { |
---|
| 1661 | vps->setVpsRepFormatIdx( i, i ); |
---|
| 1662 | } |
---|
| 1663 | } |
---|
| 1664 | #endif |
---|
[713] | 1665 | #endif |
---|
[588] | 1666 | #if RESOLUTION_BASED_DPB |
---|
| 1667 | vps->assignSubDpbIndices(); |
---|
| 1668 | #endif |
---|
[442] | 1669 | READ_FLAG(uiCode, "max_one_active_ref_layer_flag" ); |
---|
| 1670 | vps->setMaxOneActiveRefLayerFlag(uiCode); |
---|
[494] | 1671 | #if O0062_POC_LSB_NOT_PRESENT_FLAG |
---|
| 1672 | for(i = 1; i< vps->getMaxLayers(); i++) |
---|
[313] | 1673 | { |
---|
[494] | 1674 | if( vps->getNumDirectRefLayers( vps->getLayerIdInNuh(i) ) == 0 ) |
---|
[313] | 1675 | { |
---|
[494] | 1676 | READ_FLAG(uiCode, "poc_lsb_not_present_flag[i]"); |
---|
| 1677 | vps->setPocLsbNotPresentFlag(i, uiCode); |
---|
[313] | 1678 | } |
---|
| 1679 | } |
---|
| 1680 | #endif |
---|
[494] | 1681 | #if O0215_PHASE_ALIGNMENT |
---|
| 1682 | READ_FLAG( uiCode, "cross_layer_phase_alignment_flag"); vps->setPhaseAlignFlag( uiCode == 1 ? true : false ); |
---|
[313] | 1683 | #endif |
---|
[494] | 1684 | |
---|
[815] | 1685 | #if !IRAP_ALIGN_FLAG_IN_VPS_VUI |
---|
[494] | 1686 | READ_FLAG(uiCode, "cross_layer_irap_aligned_flag" ); |
---|
| 1687 | vps->setCrossLayerIrapAlignFlag(uiCode); |
---|
| 1688 | #endif |
---|
| 1689 | |
---|
[540] | 1690 | #if VPS_DPB_SIZE_TABLE |
---|
[588] | 1691 | parseVpsDpbSizeTable(vps); |
---|
[540] | 1692 | #endif |
---|
[588] | 1693 | |
---|
| 1694 | #if VPS_EXTN_DIRECT_REF_LAYERS |
---|
[313] | 1695 | READ_UVLC( uiCode, "direct_dep_type_len_minus2"); vps->setDirectDepTypeLen(uiCode+2); |
---|
[540] | 1696 | #if O0096_DEFAULT_DEPENDENCY_TYPE |
---|
| 1697 | READ_FLAG(uiCode, "default_direct_dependency_type_flag"); |
---|
| 1698 | vps->setDefaultDirectDependecyTypeFlag(uiCode == 1? true : false); |
---|
| 1699 | if (vps->getDefaultDirectDependencyTypeFlag()) |
---|
| 1700 | { |
---|
| 1701 | READ_CODE( vps->getDirectDepTypeLen(), uiCode, "default_direct_dependency_type" ); |
---|
| 1702 | vps->setDefaultDirectDependecyType(uiCode); |
---|
| 1703 | } |
---|
| 1704 | #endif |
---|
[313] | 1705 | for(i = 1; i < vps->getMaxLayers(); i++) |
---|
| 1706 | { |
---|
| 1707 | for(j = 0; j < i; j++) |
---|
| 1708 | { |
---|
| 1709 | if (vps->getDirectDependencyFlag(i, j)) |
---|
| 1710 | { |
---|
[540] | 1711 | #if O0096_DEFAULT_DEPENDENCY_TYPE |
---|
| 1712 | if (vps->getDefaultDirectDependencyTypeFlag()) |
---|
| 1713 | { |
---|
| 1714 | vps->setDirectDependencyType(i, j, vps->getDefaultDirectDependencyType()); |
---|
| 1715 | } |
---|
| 1716 | else |
---|
| 1717 | { |
---|
| 1718 | READ_CODE( vps->getDirectDepTypeLen(), uiCode, "direct_dependency_type[i][j]" ); |
---|
| 1719 | vps->setDirectDependencyType(i, j, uiCode); |
---|
| 1720 | } |
---|
| 1721 | #else |
---|
| 1722 | READ_CODE( vps->getDirectDepTypeLen(), uiCode, "direct_dependency_type[i][j]" ); |
---|
| 1723 | vps->setDirectDependencyType(i, j, uiCode); |
---|
| 1724 | #endif |
---|
[313] | 1725 | } |
---|
| 1726 | } |
---|
| 1727 | } |
---|
| 1728 | #endif |
---|
[815] | 1729 | #if !Q0078_ADD_LAYER_SETS |
---|
| 1730 | #if O0092_0094_DEPENDENCY_CONSTRAINT // Moved up |
---|
| 1731 | vps->setNumRefLayers(); |
---|
| 1732 | |
---|
[540] | 1733 | if(vps->getMaxLayers() > MAX_REF_LAYERS) |
---|
| 1734 | { |
---|
| 1735 | for(i = 1;i < vps->getMaxLayers(); i++) |
---|
[442] | 1736 | { |
---|
[540] | 1737 | assert( vps->getNumRefLayers(vps->getLayerIdInNuh(i)) <= MAX_REF_LAYERS); |
---|
[442] | 1738 | } |
---|
[540] | 1739 | } |
---|
[442] | 1740 | #endif |
---|
[815] | 1741 | #endif |
---|
[442] | 1742 | |
---|
[588] | 1743 | #if P0307_VPS_NON_VUI_EXTENSION |
---|
| 1744 | READ_UVLC( uiCode, "vps_non_vui_extension_length"); vps->setVpsNonVuiExtLength((Int)uiCode); |
---|
[713] | 1745 | |
---|
| 1746 | // The value of vps_non_vui_extension_length shall be in the range of 0 to 4096, inclusive. |
---|
| 1747 | assert( vps->getVpsNonVuiExtLength() >= 0 && vps->getVpsNonVuiExtLength() <= 4096 ); |
---|
| 1748 | |
---|
[644] | 1749 | #if P0307_VPS_NON_VUI_EXT_UPDATE |
---|
| 1750 | Int nonVuiExtByte = uiCode; |
---|
| 1751 | for (i = 1; i <= nonVuiExtByte; i++) |
---|
| 1752 | { |
---|
| 1753 | READ_CODE( 8, uiCode, "vps_non_vui_extension_data_byte" ); //just parse and discard for now. |
---|
| 1754 | } |
---|
| 1755 | #else |
---|
[588] | 1756 | if ( vps->getVpsNonVuiExtLength() > 0 ) |
---|
| 1757 | { |
---|
| 1758 | printf("\n\nUp to the current spec, the value of vps_non_vui_extension_length is supposed to be 0\n"); |
---|
| 1759 | } |
---|
| 1760 | #endif |
---|
[644] | 1761 | #endif |
---|
[588] | 1762 | |
---|
[547] | 1763 | #if !O0109_O0199_FLAGS_TO_VUI |
---|
[313] | 1764 | #if M0040_ADAPTIVE_RESOLUTION_CHANGE |
---|
| 1765 | READ_FLAG(uiCode, "single_layer_for_non_irap_flag" ); vps->setSingleLayerForNonIrapFlag(uiCode == 1 ? true : false); |
---|
| 1766 | #endif |
---|
[540] | 1767 | #if HIGHER_LAYER_IRAP_SKIP_FLAG |
---|
| 1768 | READ_FLAG(uiCode, "higher_layer_irap_skip_flag" ); vps->setHigherLayerIrapSkipFlag(uiCode == 1 ? true : false); |
---|
| 1769 | #endif |
---|
[547] | 1770 | #endif |
---|
[442] | 1771 | |
---|
[588] | 1772 | #if P0307_REMOVE_VPS_VUI_OFFSET |
---|
| 1773 | READ_FLAG( uiCode, "vps_vui_present_flag"); vps->setVpsVuiPresentFlag(uiCode ? true : false); |
---|
| 1774 | #endif |
---|
| 1775 | |
---|
[547] | 1776 | #if O0109_MOVE_VPS_VUI_FLAG |
---|
| 1777 | if ( vps->getVpsVuiPresentFlag() ) |
---|
| 1778 | #else |
---|
[442] | 1779 | READ_FLAG( uiCode, "vps_vui_present_flag" ); |
---|
| 1780 | if (uiCode) |
---|
[547] | 1781 | #endif |
---|
[442] | 1782 | { |
---|
| 1783 | while ( m_pcBitstream->getNumBitsRead() % 8 != 0 ) |
---|
| 1784 | { |
---|
| 1785 | READ_FLAG( uiCode, "vps_vui_alignment_bit_equal_to_one"); assert(uiCode == 1); |
---|
| 1786 | } |
---|
| 1787 | parseVPSVUI(vps); |
---|
| 1788 | } |
---|
[713] | 1789 | else |
---|
| 1790 | { |
---|
| 1791 | // set default values for VPS VUI |
---|
| 1792 | defaultVPSVUI( vps ); |
---|
| 1793 | } |
---|
[313] | 1794 | } |
---|
[713] | 1795 | |
---|
| 1796 | Void TDecCavlc::defaultVPSExtension( TComVPS* vps ) |
---|
| 1797 | { |
---|
| 1798 | // set default parameters when they are not present |
---|
| 1799 | Int i, j; |
---|
| 1800 | |
---|
| 1801 | // When layer_id_in_nuh[ i ] is not present, the value is inferred to be equal to i. |
---|
| 1802 | for(i = 0; i < vps->getMaxLayers(); i++) |
---|
| 1803 | { |
---|
| 1804 | vps->setLayerIdInNuh(i, i); |
---|
| 1805 | vps->setLayerIdInVps(vps->getLayerIdInNuh(i), i); |
---|
| 1806 | } |
---|
| 1807 | |
---|
| 1808 | // When not present, sub_layers_vps_max_minus1[ i ] is inferred to be equal to vps_max_sub_layers_minus1. |
---|
| 1809 | for( i = 0; i < vps->getMaxLayers(); i++) |
---|
| 1810 | { |
---|
| 1811 | vps->setMaxTSLayersMinus1(i, vps->getMaxTLayers()-1); |
---|
| 1812 | } |
---|
| 1813 | |
---|
| 1814 | // When not present, max_tid_il_ref_pics_plus1[ i ][ j ] is inferred to be equal to 7. |
---|
| 1815 | for( i = 0; i < vps->getMaxLayers() - 1; i++ ) |
---|
| 1816 | { |
---|
| 1817 | #if O0225_MAX_TID_FOR_REF_LAYERS |
---|
| 1818 | for( j = i + 1; j < vps->getMaxLayers(); j++ ) |
---|
| 1819 | { |
---|
| 1820 | vps->setMaxTidIlRefPicsPlus1(i, j, 7); |
---|
| 1821 | } |
---|
| 1822 | #else |
---|
| 1823 | vps->setMaxTidIlRefPicsPlus1(i, 7); |
---|
[313] | 1824 | #endif |
---|
[713] | 1825 | } |
---|
| 1826 | |
---|
[815] | 1827 | // When not present, the value of num_add_olss is inferred to be equal to 0. |
---|
| 1828 | // NumOutputLayerSets = num_add_olss + NumLayerSets |
---|
[713] | 1829 | vps->setNumOutputLayerSets( vps->getNumLayerSets() ); |
---|
| 1830 | |
---|
| 1831 | // For i in the range of 0 to NumOutputLayerSets-1, inclusive, the variable LayerSetIdxForOutputLayerSet[ i ] is derived as specified in the following: |
---|
[815] | 1832 | // LayerSetIdxForOutputLayerSet[ i ] = ( i <= vps_number_layer_sets_minus1 ) ? i : layer_set_idx_for_ols_minus1[ i ] + 1 |
---|
[713] | 1833 | for( i = 1; i < vps->getNumOutputLayerSets(); i++ ) |
---|
| 1834 | { |
---|
| 1835 | vps->setOutputLayerSetIdx( i, i ); |
---|
| 1836 | Int lsIdx = vps->getOutputLayerSetIdx(i); |
---|
| 1837 | |
---|
| 1838 | for( j = 0; j < vps->getNumLayersInIdList(lsIdx); j++ ) |
---|
| 1839 | { |
---|
| 1840 | vps->setOutputLayerFlag(i, j, 1); |
---|
| 1841 | } |
---|
| 1842 | } |
---|
| 1843 | |
---|
| 1844 | // The value of sub_layer_dpb_info_present_flag[ i ][ 0 ] for any possible value of i is inferred to be equal to 1 |
---|
| 1845 | // When not present, the value of sub_layer_dpb_info_present_flag[ i ][ j ] for j greater than 0 and any possible value of i, is inferred to be equal to be equal to 0. |
---|
| 1846 | for( i = 1; i < vps->getNumOutputLayerSets(); i++ ) |
---|
| 1847 | { |
---|
| 1848 | vps->setSubLayerDpbInfoPresentFlag( i, 0, true ); |
---|
| 1849 | } |
---|
| 1850 | |
---|
| 1851 | // When not present, the value of vps_num_rep_formats_minus1 is inferred to be equal to MaxLayersMinus1. |
---|
| 1852 | vps->setVpsNumRepFormats( vps->getMaxLayers() ); |
---|
| 1853 | |
---|
| 1854 | // When not present, the value of rep_format_idx_present_flag is inferred to be equal to 0 |
---|
| 1855 | vps->setRepFormatIdxPresentFlag( false ); |
---|
| 1856 | |
---|
| 1857 | if( !vps->getRepFormatIdxPresentFlag() ) |
---|
| 1858 | { |
---|
| 1859 | // When not present, the value of vps_rep_format_idx[ i ] is inferred to be equal to Min(i, vps_num_rep_formats_minus1). |
---|
| 1860 | for(i = 1; i < vps->getMaxLayers(); i++) |
---|
| 1861 | { |
---|
| 1862 | vps->setVpsRepFormatIdx( i, min( (Int)i, vps->getVpsNumRepFormats() - 1 ) ); |
---|
| 1863 | } |
---|
| 1864 | } |
---|
| 1865 | |
---|
| 1866 | // vps_poc_lsb_aligned_flag |
---|
| 1867 | // When not present, vps_poc_lsb_aligned_flag is inferred to be equal to 0. |
---|
| 1868 | |
---|
| 1869 | #if O0062_POC_LSB_NOT_PRESENT_FLAG |
---|
| 1870 | // When not present, poc_lsb_not_present_flag[ i ] is inferred to be equal to 0. |
---|
| 1871 | for(i = 1; i< vps->getMaxLayers(); i++) |
---|
| 1872 | { |
---|
| 1873 | vps->setPocLsbNotPresentFlag(i, 0); |
---|
| 1874 | } |
---|
| 1875 | #endif |
---|
| 1876 | |
---|
| 1877 | // set default values for VPS VUI |
---|
| 1878 | defaultVPSVUI( vps ); |
---|
| 1879 | } |
---|
| 1880 | |
---|
| 1881 | Void TDecCavlc::defaultVPSVUI( TComVPS* vps ) |
---|
| 1882 | { |
---|
| 1883 | // When not present, the value of all_layers_idr_aligned_flag is inferred to be equal to 0. |
---|
| 1884 | vps->setCrossLayerIrapAlignFlag( false ); |
---|
| 1885 | |
---|
| 1886 | #if M0040_ADAPTIVE_RESOLUTION_CHANGE |
---|
| 1887 | // When single_layer_for_non_irap_flag is not present, it is inferred to be equal to 0. |
---|
| 1888 | vps->setSingleLayerForNonIrapFlag( false ); |
---|
| 1889 | #endif |
---|
| 1890 | |
---|
| 1891 | #if HIGHER_LAYER_IRAP_SKIP_FLAG |
---|
| 1892 | // When higher_layer_irap_skip_flag is not present it is inferred to be equal to 0 |
---|
| 1893 | vps->setHigherLayerIrapSkipFlag( false ); |
---|
| 1894 | #endif |
---|
| 1895 | } |
---|
| 1896 | |
---|
[442] | 1897 | #if REPN_FORMAT_IN_VPS |
---|
[713] | 1898 | Void TDecCavlc::parseRepFormat( RepFormat *repFormat, RepFormat *repFormatPrev ) |
---|
[442] | 1899 | { |
---|
| 1900 | UInt uiCode; |
---|
[713] | 1901 | #if REPN_FORMAT_CONTROL_FLAG |
---|
| 1902 | READ_CODE( 16, uiCode, "pic_width_vps_in_luma_samples" ); repFormat->setPicWidthVpsInLumaSamples ( uiCode ); |
---|
| 1903 | READ_CODE( 16, uiCode, "pic_height_vps_in_luma_samples" ); repFormat->setPicHeightVpsInLumaSamples( uiCode ); |
---|
| 1904 | READ_FLAG( uiCode, "chroma_and_bit_depth_vps_present_flag" ); repFormat->setChromaAndBitDepthVpsPresentFlag( uiCode ? true : false ); |
---|
[540] | 1905 | |
---|
[713] | 1906 | if( !repFormatPrev ) |
---|
| 1907 | { |
---|
| 1908 | // The value of chroma_and_bit_depth_vps_present_flag of the first rep_format( ) syntax structure in the VPS shall be equal to 1 |
---|
| 1909 | assert( repFormat->getChromaAndBitDepthVpsPresentFlag() ); |
---|
| 1910 | } |
---|
| 1911 | |
---|
[540] | 1912 | if( repFormat->getChromaAndBitDepthVpsPresentFlag() ) |
---|
| 1913 | { |
---|
[713] | 1914 | READ_CODE( 2, uiCode, "chroma_format_vps_idc" ); |
---|
[494] | 1915 | #if AUXILIARY_PICTURES |
---|
[713] | 1916 | repFormat->setChromaFormatVpsIdc( ChromaFormat(uiCode) ); |
---|
[540] | 1917 | #else |
---|
[713] | 1918 | repFormat->setChromaFormatVpsIdc( uiCode ); |
---|
[540] | 1919 | #endif |
---|
| 1920 | |
---|
| 1921 | if( repFormat->getChromaFormatVpsIdc() == 3 ) |
---|
| 1922 | { |
---|
[713] | 1923 | READ_FLAG( uiCode, "separate_colour_plane_vps_flag" ); repFormat->setSeparateColourPlaneVpsFlag( uiCode ? true : false ); |
---|
[540] | 1924 | } |
---|
| 1925 | |
---|
[713] | 1926 | READ_CODE( 4, uiCode, "bit_depth_vps_luma_minus8" ); repFormat->setBitDepthVpsLuma ( uiCode + 8 ); |
---|
| 1927 | READ_CODE( 4, uiCode, "bit_depth_vps_chroma_minus8" ); repFormat->setBitDepthVpsChroma( uiCode + 8 ); |
---|
| 1928 | } |
---|
| 1929 | else if( repFormatPrev ) |
---|
| 1930 | { |
---|
| 1931 | // chroma_and_bit_depth_vps_present_flag equal to 0 specifies that the syntax elements, chroma_format_vps_idc, separate_colour_plane_vps_flag, bit_depth_vps_luma_minus8, and |
---|
| 1932 | // bit_depth_vps_chroma_minus8 are not present and inferred from the previous rep_format( ) syntax structure in the VPS. |
---|
[540] | 1933 | |
---|
[713] | 1934 | repFormat->setChromaFormatVpsIdc ( repFormatPrev->getChromaFormatVpsIdc() ); |
---|
| 1935 | repFormat->setSeparateColourPlaneVpsFlag( repFormatPrev->getSeparateColourPlaneVpsFlag() ); |
---|
| 1936 | repFormat->setBitDepthVpsLuma ( repFormatPrev->getBitDepthVpsLuma() ); |
---|
| 1937 | repFormat->setBitDepthVpsChroma ( repFormatPrev->getBitDepthVpsChroma() ); |
---|
[540] | 1938 | } |
---|
| 1939 | #else |
---|
| 1940 | #if AUXILIARY_PICTURES |
---|
[494] | 1941 | READ_CODE( 2, uiCode, "chroma_format_idc" ); repFormat->setChromaFormatVpsIdc( ChromaFormat(uiCode) ); |
---|
| 1942 | #else |
---|
[442] | 1943 | READ_CODE( 2, uiCode, "chroma_format_idc" ); repFormat->setChromaFormatVpsIdc( uiCode ); |
---|
[494] | 1944 | #endif |
---|
[442] | 1945 | |
---|
| 1946 | if( repFormat->getChromaFormatVpsIdc() == 3 ) |
---|
| 1947 | { |
---|
| 1948 | READ_FLAG( uiCode, "separate_colour_plane_flag"); repFormat->setSeparateColourPlaneVpsFlag(uiCode ? true : false); |
---|
| 1949 | } |
---|
[313] | 1950 | |
---|
[442] | 1951 | READ_CODE ( 16, uiCode, "pic_width_in_luma_samples" ); repFormat->setPicWidthVpsInLumaSamples ( uiCode ); |
---|
| 1952 | READ_CODE ( 16, uiCode, "pic_height_in_luma_samples" ); repFormat->setPicHeightVpsInLumaSamples( uiCode ); |
---|
[494] | 1953 | |
---|
[442] | 1954 | READ_CODE( 4, uiCode, "bit_depth_luma_minus8" ); repFormat->setBitDepthVpsLuma ( uiCode + 8 ); |
---|
| 1955 | READ_CODE( 4, uiCode, "bit_depth_chroma_minus8" ); repFormat->setBitDepthVpsChroma( uiCode + 8 ); |
---|
[540] | 1956 | #endif |
---|
[442] | 1957 | } |
---|
| 1958 | #endif |
---|
[588] | 1959 | #if VPS_DPB_SIZE_TABLE |
---|
| 1960 | Void TDecCavlc::parseVpsDpbSizeTable( TComVPS *vps ) |
---|
| 1961 | { |
---|
| 1962 | UInt uiCode; |
---|
[644] | 1963 | #if DPB_PARAMS_MAXTLAYERS |
---|
[815] | 1964 | #if BITRATE_PICRATE_SIGNALLING |
---|
| 1965 | Int * MaxSubLayersInLayerSetMinus1 = new Int[vps->getNumLayerSets()]; |
---|
| 1966 | for(Int i = 0; i < vps->getNumLayerSets(); i++) |
---|
| 1967 | #else |
---|
[644] | 1968 | Int * MaxSubLayersInLayerSetMinus1 = new Int[vps->getNumOutputLayerSets()]; |
---|
| 1969 | for(Int i = 1; i < vps->getNumOutputLayerSets(); i++) |
---|
[815] | 1970 | #endif |
---|
[644] | 1971 | { |
---|
| 1972 | UInt maxSLMinus1 = 0; |
---|
| 1973 | #if CHANGE_NUMSUBDPB_IDX |
---|
| 1974 | Int optLsIdx = vps->getOutputLayerSetIdx( i ); |
---|
| 1975 | #else |
---|
| 1976 | Int optLsIdx = i; |
---|
| 1977 | #endif |
---|
[815] | 1978 | #if BITRATE_PICRATE_SIGNALLING |
---|
| 1979 | optLsIdx = i; |
---|
| 1980 | #endif |
---|
[644] | 1981 | for(Int k = 0; k < vps->getNumLayersInIdList(optLsIdx); k++ ) { |
---|
| 1982 | Int lId = vps->getLayerSetLayerIdList(optLsIdx, k); |
---|
| 1983 | maxSLMinus1 = max(maxSLMinus1, vps->getMaxTSLayersMinus1(vps->getLayerIdInVps(lId))); |
---|
| 1984 | } |
---|
| 1985 | MaxSubLayersInLayerSetMinus1[ i ] = maxSLMinus1; |
---|
[815] | 1986 | #if BITRATE_PICRATE_SIGNALLING |
---|
| 1987 | vps->setMaxSLayersInLayerSetMinus1(i,MaxSubLayersInLayerSetMinus1[ i ]); |
---|
| 1988 | #endif |
---|
[644] | 1989 | } |
---|
| 1990 | #endif |
---|
| 1991 | |
---|
[588] | 1992 | #if !RESOLUTION_BASED_DPB |
---|
| 1993 | vps->deriveNumberOfSubDpbs(); |
---|
| 1994 | #endif |
---|
| 1995 | for(Int i = 1; i < vps->getNumOutputLayerSets(); i++) |
---|
| 1996 | { |
---|
| 1997 | #if CHANGE_NUMSUBDPB_IDX |
---|
| 1998 | Int layerSetIdxForOutputLayerSet = vps->getOutputLayerSetIdx( i ); |
---|
| 1999 | #endif |
---|
| 2000 | READ_FLAG( uiCode, "sub_layer_flag_info_present_flag[i]"); vps->setSubLayerFlagInfoPresentFlag( i, uiCode ? true : false ); |
---|
[644] | 2001 | #if DPB_PARAMS_MAXTLAYERS |
---|
[815] | 2002 | #if BITRATE_PICRATE_SIGNALLING |
---|
| 2003 | for(Int j = 0; j <= MaxSubLayersInLayerSetMinus1[ vps->getOutputLayerSetIdx( i ) ]; j++) |
---|
| 2004 | #else |
---|
[713] | 2005 | for(Int j = 0; j <= MaxSubLayersInLayerSetMinus1[ i ]; j++) |
---|
[815] | 2006 | #endif |
---|
[644] | 2007 | #else |
---|
| 2008 | for(Int j = 0; j <= vps->getMaxTLayers(); j++) |
---|
| 2009 | #endif |
---|
[588] | 2010 | { |
---|
| 2011 | if( j > 0 && vps->getSubLayerFlagInfoPresentFlag(i) ) |
---|
| 2012 | { |
---|
| 2013 | READ_FLAG( uiCode, "sub_layer_dpb_info_present_flag[i]"); vps->setSubLayerDpbInfoPresentFlag( i, j, uiCode ? true : false); |
---|
| 2014 | } |
---|
| 2015 | else |
---|
| 2016 | { |
---|
| 2017 | if( j == 0 ) // Always signal for the first sub-layer |
---|
| 2018 | { |
---|
| 2019 | vps->setSubLayerDpbInfoPresentFlag( i, j, true ); |
---|
| 2020 | } |
---|
| 2021 | else // if (j != 0) && !vps->getSubLayerFlagInfoPresentFlag(i) |
---|
| 2022 | { |
---|
| 2023 | vps->setSubLayerDpbInfoPresentFlag( i, j, false ); |
---|
| 2024 | } |
---|
| 2025 | } |
---|
| 2026 | if( vps->getSubLayerDpbInfoPresentFlag(i, j) ) // If sub-layer DPB information is present |
---|
| 2027 | { |
---|
| 2028 | #if CHANGE_NUMSUBDPB_IDX |
---|
| 2029 | for(Int k = 0; k < vps->getNumSubDpbs(layerSetIdxForOutputLayerSet); k++) |
---|
| 2030 | #else |
---|
| 2031 | for(Int k = 0; k < vps->getNumSubDpbs(i); k++) |
---|
| 2032 | #endif |
---|
| 2033 | { |
---|
| 2034 | READ_UVLC( uiCode, "max_vps_dec_pic_buffering_minus1[i][k][j]" ); vps->setMaxVpsDecPicBufferingMinus1( i, k, j, uiCode ); |
---|
| 2035 | } |
---|
| 2036 | READ_UVLC( uiCode, "max_vps_num_reorder_pics[i][j]" ); vps->setMaxVpsNumReorderPics( i, j, uiCode); |
---|
| 2037 | #if RESOLUTION_BASED_DPB |
---|
| 2038 | if( vps->getNumSubDpbs(layerSetIdxForOutputLayerSet) != vps->getNumLayersInIdList( layerSetIdxForOutputLayerSet ) ) |
---|
| 2039 | { |
---|
| 2040 | for(Int k = 0; k < vps->getNumLayersInIdList( layerSetIdxForOutputLayerSet ); k++) |
---|
| 2041 | { |
---|
| 2042 | READ_UVLC( uiCode, "max_vps_layer_dec_pic_buff_minus1[i][k][j]" ); vps->setMaxVpsLayerDecPicBuffMinus1( i, k, j, uiCode); |
---|
| 2043 | } |
---|
| 2044 | } |
---|
| 2045 | else // vps->getNumSubDpbs(layerSetIdxForOutputLayerSet) == vps->getNumLayersInIdList( layerSetIdxForOutputLayerSet ) |
---|
| 2046 | { |
---|
| 2047 | for(Int k = 0; k < vps->getNumLayersInIdList( layerSetIdxForOutputLayerSet ); k++) |
---|
| 2048 | { |
---|
| 2049 | vps->setMaxVpsLayerDecPicBuffMinus1( i, k, j, vps->getMaxVpsDecPicBufferingMinus1( i, k, j)); |
---|
| 2050 | } |
---|
| 2051 | } |
---|
| 2052 | #endif |
---|
| 2053 | READ_UVLC( uiCode, "max_vps_latency_increase_plus1[i][j]" ); vps->setMaxVpsLatencyIncreasePlus1( i, j, uiCode); |
---|
| 2054 | } |
---|
| 2055 | } |
---|
[644] | 2056 | for(Int j = vps->getMaxTLayers(); j < MAX_TLAYER; j++) |
---|
| 2057 | { |
---|
| 2058 | vps->setSubLayerDpbInfoPresentFlag( i, j, false ); |
---|
| 2059 | } |
---|
[588] | 2060 | } |
---|
[644] | 2061 | |
---|
| 2062 | // Infer values when not signalled |
---|
| 2063 | for(Int i = 1; i < vps->getNumOutputLayerSets(); i++) |
---|
| 2064 | { |
---|
| 2065 | Int layerSetIdxForOutputLayerSet = vps->getOutputLayerSetIdx( i ); |
---|
| 2066 | for(Int j = 0; j < MAX_TLAYER; j++) |
---|
| 2067 | { |
---|
| 2068 | if( !vps->getSubLayerDpbInfoPresentFlag(i, j) ) // If sub-layer DPB information is NOT present |
---|
| 2069 | { |
---|
[815] | 2070 | #if RESOLUTION_BASED_DPB |
---|
[644] | 2071 | for(Int k = 0; k < vps->getNumSubDpbs(layerSetIdxForOutputLayerSet); k++) |
---|
[815] | 2072 | #else |
---|
| 2073 | for(Int k = 0; k < vps->getNumLayersInIdList( layerSetIdxForOutputLayerSet ); k++) |
---|
| 2074 | #endif |
---|
[644] | 2075 | { |
---|
| 2076 | vps->setMaxVpsDecPicBufferingMinus1( i, k, j, vps->getMaxVpsDecPicBufferingMinus1( i, k, j - 1 ) ); |
---|
| 2077 | } |
---|
| 2078 | vps->setMaxVpsNumReorderPics( i, j, vps->getMaxVpsNumReorderPics( i, j - 1) ); |
---|
[815] | 2079 | #if RESOLUTION_BASED_DPB |
---|
[644] | 2080 | for(Int k = 0; k < vps->getNumLayersInIdList( layerSetIdxForOutputLayerSet ); k++) |
---|
| 2081 | { |
---|
| 2082 | vps->setMaxVpsLayerDecPicBuffMinus1( i, k, j, vps->getMaxVpsLayerDecPicBuffMinus1( i, k, j - 1)); |
---|
| 2083 | } |
---|
[815] | 2084 | #endif |
---|
[644] | 2085 | vps->setMaxVpsLatencyIncreasePlus1( i, j, vps->getMaxVpsLatencyIncreasePlus1( i, j - 1 ) ); |
---|
| 2086 | } |
---|
| 2087 | } |
---|
| 2088 | } |
---|
[588] | 2089 | } |
---|
| 2090 | #endif |
---|
[815] | 2091 | |
---|
[442] | 2092 | Void TDecCavlc::parseVPSVUI(TComVPS *vps) |
---|
| 2093 | { |
---|
| 2094 | UInt i,j; |
---|
| 2095 | UInt uiCode; |
---|
[540] | 2096 | #if O0223_PICTURE_TYPES_ALIGN_FLAG |
---|
| 2097 | READ_FLAG(uiCode, "cross_layer_pic_type_aligned_flag" ); |
---|
| 2098 | vps->setCrossLayerPictureTypeAlignFlag(uiCode); |
---|
| 2099 | if (!uiCode) |
---|
| 2100 | { |
---|
| 2101 | #endif |
---|
[494] | 2102 | #if IRAP_ALIGN_FLAG_IN_VPS_VUI |
---|
[540] | 2103 | READ_FLAG(uiCode, "cross_layer_irap_aligned_flag" ); |
---|
| 2104 | vps->setCrossLayerIrapAlignFlag(uiCode); |
---|
[644] | 2105 | #if P0068_CROSS_LAYER_ALIGNED_IDR_ONLY_FOR_IRAP_FLAG |
---|
[815] | 2106 | if( uiCode ) |
---|
[644] | 2107 | { |
---|
[815] | 2108 | READ_FLAG( uiCode, "all_layers_idr_aligned_flag" ); |
---|
| 2109 | vps->setCrossLayerAlignedIdrOnlyFlag(uiCode); |
---|
[644] | 2110 | } |
---|
[494] | 2111 | #endif |
---|
[644] | 2112 | #endif |
---|
[540] | 2113 | #if O0223_PICTURE_TYPES_ALIGN_FLAG |
---|
| 2114 | } |
---|
| 2115 | else |
---|
| 2116 | { |
---|
| 2117 | vps->setCrossLayerIrapAlignFlag(true); |
---|
| 2118 | } |
---|
| 2119 | #endif |
---|
[815] | 2120 | |
---|
[442] | 2121 | READ_FLAG( uiCode, "bit_rate_present_vps_flag" ); vps->setBitRatePresentVpsFlag( uiCode ? true : false ); |
---|
| 2122 | READ_FLAG( uiCode, "pic_rate_present_vps_flag" ); vps->setPicRatePresentVpsFlag( uiCode ? true : false ); |
---|
| 2123 | |
---|
| 2124 | Bool parseFlag = vps->getBitRatePresentVpsFlag() || vps->getPicRatePresentVpsFlag(); |
---|
[815] | 2125 | |
---|
| 2126 | #if Q0078_ADD_LAYER_SETS |
---|
| 2127 | for( i = 0; i <= vps->getVpsNumLayerSetsMinus1(); i++ ) |
---|
| 2128 | #else |
---|
| 2129 | for( i = 0; i < vps->getNumLayerSets(); i++ ) |
---|
| 2130 | #endif |
---|
[442] | 2131 | { |
---|
[815] | 2132 | #if BITRATE_PICRATE_SIGNALLING |
---|
| 2133 | for( j = 0; j <= vps->getMaxSLayersInLayerSetMinus1(i); j++ ) |
---|
| 2134 | #else |
---|
| 2135 | for( j = 0; j < vps->getMaxTLayers(); j++ ) |
---|
| 2136 | #endif |
---|
[442] | 2137 | { |
---|
[815] | 2138 | if( parseFlag && vps->getBitRatePresentVpsFlag() ) |
---|
[442] | 2139 | { |
---|
[815] | 2140 | READ_FLAG( uiCode, "bit_rate_present_flag[i][j]" ); vps->setBitRatePresentFlag( i, j, uiCode ? true : false ); |
---|
[442] | 2141 | } |
---|
[815] | 2142 | else |
---|
| 2143 | { |
---|
| 2144 | vps->setBitRatePresentFlag( i, j, false ); |
---|
| 2145 | } |
---|
| 2146 | if( parseFlag && vps->getPicRatePresentVpsFlag() ) |
---|
| 2147 | { |
---|
| 2148 | READ_FLAG( uiCode, "pic_rate_present_flag[i][j]" ); vps->setPicRatePresentFlag( i, j, uiCode ? true : false ); |
---|
| 2149 | } |
---|
| 2150 | else |
---|
| 2151 | { |
---|
| 2152 | vps->setPicRatePresentFlag( i, j, false ); |
---|
| 2153 | } |
---|
| 2154 | if( parseFlag && vps->getBitRatePresentFlag(i, j) ) |
---|
| 2155 | { |
---|
| 2156 | READ_CODE( 16, uiCode, "avg_bit_rate[i][j]" ); vps->setAvgBitRate( i, j, uiCode ); |
---|
| 2157 | READ_CODE( 16, uiCode, "max_bit_rate[i][j]" ); vps->setMaxBitRate( i, j, uiCode ); |
---|
| 2158 | } |
---|
| 2159 | else |
---|
| 2160 | { |
---|
| 2161 | vps->setAvgBitRate( i, j, 0 ); |
---|
| 2162 | vps->setMaxBitRate( i, j, 0 ); |
---|
| 2163 | } |
---|
| 2164 | if( parseFlag && vps->getPicRatePresentFlag(i, j) ) |
---|
| 2165 | { |
---|
| 2166 | READ_CODE( 2 , uiCode, "constant_pic_rate_idc[i][j]" ); vps->setConstPicRateIdc( i, j, uiCode ); |
---|
| 2167 | READ_CODE( 16, uiCode, "avg_pic_rate[i][j]" ); vps->setAvgPicRate( i, j, uiCode ); |
---|
| 2168 | } |
---|
| 2169 | else |
---|
| 2170 | { |
---|
| 2171 | vps->setConstPicRateIdc( i, j, 0 ); |
---|
| 2172 | vps->setAvgPicRate ( i, j, 0 ); |
---|
| 2173 | } |
---|
[442] | 2174 | } |
---|
| 2175 | } |
---|
[588] | 2176 | #if VPS_VUI_VIDEO_SIGNAL_MOVE |
---|
| 2177 | READ_FLAG( uiCode, "video_signal_info_idx_present_flag" ); vps->setVideoSigPresentVpsFlag( uiCode == 1 ); |
---|
| 2178 | if (vps->getVideoSigPresentVpsFlag()) |
---|
| 2179 | { |
---|
| 2180 | READ_CODE(4, uiCode, "vps_num_video_signal_info_minus1" ); vps->setNumVideoSignalInfo(uiCode + 1); |
---|
| 2181 | } |
---|
| 2182 | else |
---|
| 2183 | { |
---|
| 2184 | vps->setNumVideoSignalInfo(vps->getMaxLayers()); |
---|
| 2185 | } |
---|
| 2186 | |
---|
| 2187 | for(i = 0; i < vps->getNumVideoSignalInfo(); i++) |
---|
| 2188 | { |
---|
| 2189 | READ_CODE(3, uiCode, "video_vps_format" ); vps->setVideoVPSFormat(i,uiCode); |
---|
| 2190 | READ_FLAG(uiCode, "video_full_range_vps_flag" ); vps->setVideoFullRangeVpsFlag(i,uiCode); |
---|
| 2191 | READ_CODE(8, uiCode, "color_primaries_vps" ); vps->setColorPrimaries(i,uiCode); |
---|
| 2192 | READ_CODE(8, uiCode, "transfer_characteristics_vps" ); vps->setTransCharacter(i,uiCode); |
---|
| 2193 | READ_CODE(8, uiCode, "matrix_coeffs_vps" );vps->setMaxtrixCoeff(i,uiCode); |
---|
| 2194 | } |
---|
| 2195 | if(!vps->getVideoSigPresentVpsFlag()) |
---|
| 2196 | { |
---|
| 2197 | for (i=0; i < vps->getMaxLayers(); i++) |
---|
| 2198 | { |
---|
| 2199 | vps->setVideoSignalInfoIdx(i,i); |
---|
| 2200 | } |
---|
| 2201 | } |
---|
| 2202 | else { |
---|
| 2203 | vps->setVideoSignalInfoIdx(0,0); |
---|
| 2204 | if (vps->getNumVideoSignalInfo() > 1 ) |
---|
| 2205 | { |
---|
| 2206 | for (i=1; i < vps->getMaxLayers(); i++) |
---|
| 2207 | READ_CODE(4, uiCode, "vps_video_signal_info_idx" ); vps->setVideoSignalInfoIdx(i, uiCode); |
---|
| 2208 | } |
---|
| 2209 | else { |
---|
| 2210 | for (i=1; i < vps->getMaxLayers(); i++) |
---|
| 2211 | { |
---|
| 2212 | vps->setVideoSignalInfoIdx(i,0); |
---|
| 2213 | } |
---|
| 2214 | } |
---|
| 2215 | } |
---|
| 2216 | #endif |
---|
[540] | 2217 | #if VPS_VUI_TILES_NOT_IN_USE__FLAG |
---|
| 2218 | UInt layerIdx; |
---|
| 2219 | READ_FLAG( uiCode, "tiles_not_in_use_flag" ); vps->setTilesNotInUseFlag(uiCode == 1); |
---|
| 2220 | if (!uiCode) |
---|
| 2221 | { |
---|
| 2222 | for(i = 0; i < vps->getMaxLayers(); i++) |
---|
| 2223 | { |
---|
| 2224 | READ_FLAG( uiCode, "tiles_in_use_flag[ i ]" ); vps->setTilesInUseFlag(i, (uiCode == 1)); |
---|
| 2225 | if (uiCode) |
---|
| 2226 | { |
---|
| 2227 | READ_FLAG( uiCode, "loop_filter_not_across_tiles_flag[ i ]" ); vps->setLoopFilterNotAcrossTilesFlag(i, (uiCode == 1)); |
---|
| 2228 | } |
---|
| 2229 | else |
---|
| 2230 | { |
---|
| 2231 | vps->setLoopFilterNotAcrossTilesFlag(i, false); |
---|
| 2232 | } |
---|
| 2233 | } |
---|
| 2234 | #endif |
---|
[815] | 2235 | |
---|
[540] | 2236 | for(i = 1; i < vps->getMaxLayers(); i++) |
---|
| 2237 | { |
---|
| 2238 | for(j = 0; j < vps->getNumDirectRefLayers(vps->getLayerIdInNuh(i)); j++) |
---|
| 2239 | { |
---|
| 2240 | #if VPS_VUI_TILES_NOT_IN_USE__FLAG |
---|
| 2241 | layerIdx = vps->getLayerIdInVps(vps->getRefLayerId(vps->getLayerIdInNuh(i), j)); |
---|
| 2242 | if (vps->getTilesInUseFlag(i) && vps->getTilesInUseFlag(layerIdx)) { |
---|
| 2243 | READ_FLAG( uiCode, "tile_boundaries_aligned_flag[i][j]" ); vps->setTileBoundariesAlignedFlag(i,j,(uiCode == 1)); |
---|
| 2244 | } |
---|
| 2245 | #else |
---|
| 2246 | READ_FLAG( uiCode, "tile_boundaries_aligned_flag[i][j]" ); vps->setTileBoundariesAlignedFlag(i,j,(uiCode == 1)); |
---|
| 2247 | #endif |
---|
| 2248 | } |
---|
| 2249 | } |
---|
| 2250 | #if VPS_VUI_TILES_NOT_IN_USE__FLAG |
---|
| 2251 | } |
---|
| 2252 | #endif |
---|
| 2253 | #if VPS_VUI_WPP_NOT_IN_USE__FLAG |
---|
| 2254 | READ_FLAG( uiCode, "wpp_not_in_use_flag" ); vps->setWppNotInUseFlag(uiCode == 1); |
---|
| 2255 | if (!uiCode) |
---|
[442] | 2256 | { |
---|
[540] | 2257 | for(i = 0; i < vps->getMaxLayers(); i++) |
---|
[442] | 2258 | { |
---|
[540] | 2259 | READ_FLAG( uiCode, "wpp_in_use_flag[ i ]" ); vps->setWppInUseFlag(i, (uiCode == 1)); |
---|
[442] | 2260 | } |
---|
[494] | 2261 | } |
---|
| 2262 | #endif |
---|
[547] | 2263 | |
---|
| 2264 | #if O0109_O0199_FLAGS_TO_VUI |
---|
| 2265 | #if M0040_ADAPTIVE_RESOLUTION_CHANGE |
---|
| 2266 | READ_FLAG(uiCode, "single_layer_for_non_irap_flag" ); vps->setSingleLayerForNonIrapFlag(uiCode == 1 ? true : false); |
---|
| 2267 | #endif |
---|
| 2268 | #if HIGHER_LAYER_IRAP_SKIP_FLAG |
---|
| 2269 | READ_FLAG(uiCode, "higher_layer_irap_skip_flag" ); vps->setHigherLayerIrapSkipFlag(uiCode == 1 ? true : false); |
---|
[713] | 2270 | |
---|
| 2271 | // When single_layer_for_non_irap_flag is equal to 0, higher_layer_irap_skip_flag shall be equal to 0 |
---|
| 2272 | if( !vps->getSingleLayerForNonIrapFlag() ) |
---|
| 2273 | { |
---|
| 2274 | assert( !vps->getHigherLayerIrapSkipFlag() ); |
---|
| 2275 | } |
---|
[547] | 2276 | #endif |
---|
| 2277 | #endif |
---|
[644] | 2278 | #if P0312_VERT_PHASE_ADJ |
---|
| 2279 | READ_FLAG( uiCode, "vps_vui_vert_phase_in_use_flag" ); vps->setVpsVuiVertPhaseInUseFlag(uiCode); |
---|
| 2280 | #endif |
---|
[442] | 2281 | #if N0160_VUI_EXT_ILP_REF |
---|
[588] | 2282 | READ_FLAG( uiCode, "ilp_restricted_ref_layers_flag" ); vps->setIlpRestrictedRefLayersFlag( uiCode == 1 ); |
---|
| 2283 | if( vps->getIlpRestrictedRefLayersFlag()) |
---|
[442] | 2284 | { |
---|
| 2285 | for(i = 1; i < vps->getMaxLayers(); i++) |
---|
| 2286 | { |
---|
| 2287 | for(j = 0; j < vps->getNumDirectRefLayers(vps->getLayerIdInNuh(i)); j++) |
---|
| 2288 | { |
---|
[494] | 2289 | READ_UVLC( uiCode, "min_spatial_segment_offset_plus1[i][j]" ); vps->setMinSpatialSegmentOffsetPlus1( i, j, uiCode ); |
---|
| 2290 | if( vps->getMinSpatialSegmentOffsetPlus1(i,j ) > 0 ) |
---|
| 2291 | { |
---|
| 2292 | READ_FLAG( uiCode, "ctu_based_offset_enabled_flag[i][j]"); vps->setCtuBasedOffsetEnabledFlag(i, j, uiCode == 1 ); |
---|
| 2293 | if(vps->getCtuBasedOffsetEnabledFlag(i,j)) |
---|
[442] | 2294 | { |
---|
[494] | 2295 | READ_UVLC( uiCode, "min_horizontal_ctu_offset_plus1[i][j]"); vps->setMinHorizontalCtuOffsetPlus1( i,j, uiCode ); |
---|
[442] | 2296 | } |
---|
[494] | 2297 | } |
---|
| 2298 | } |
---|
[442] | 2299 | } |
---|
| 2300 | } |
---|
[494] | 2301 | #endif |
---|
[540] | 2302 | #if VPS_VUI_VIDEO_SIGNAL |
---|
[588] | 2303 | #if VPS_VUI_VIDEO_SIGNAL_MOVE |
---|
| 2304 | #else |
---|
[540] | 2305 | READ_FLAG( uiCode, "video_signal_info_idx_present_flag" ); vps->setVideoSigPresentVpsFlag( uiCode == 1 ); |
---|
| 2306 | if (vps->getVideoSigPresentVpsFlag()) |
---|
| 2307 | { |
---|
| 2308 | READ_CODE(4, uiCode, "vps_num_video_signal_info_minus1" ); vps->setNumVideoSignalInfo(uiCode + 1); |
---|
| 2309 | } |
---|
| 2310 | else |
---|
| 2311 | { |
---|
| 2312 | vps->setNumVideoSignalInfo(vps->getMaxLayers()); |
---|
| 2313 | } |
---|
| 2314 | |
---|
| 2315 | |
---|
| 2316 | for(i = 0; i < vps->getNumVideoSignalInfo(); i++) |
---|
| 2317 | { |
---|
| 2318 | READ_CODE(3, uiCode, "video_vps_format" ); vps->setVideoVPSFormat(i,uiCode); |
---|
| 2319 | READ_FLAG(uiCode, "video_full_range_vps_flag" ); vps->setVideoFullRangeVpsFlag(i,uiCode); |
---|
| 2320 | READ_CODE(8, uiCode, "color_primaries_vps" ); vps->setColorPrimaries(i,uiCode); |
---|
| 2321 | READ_CODE(8, uiCode, "transfer_characteristics_vps" ); vps->setTransCharacter(i,uiCode); |
---|
| 2322 | READ_CODE(8, uiCode, "matrix_coeffs_vps" );vps->setMaxtrixCoeff(i,uiCode); |
---|
| 2323 | } |
---|
| 2324 | if(!vps->getVideoSigPresentVpsFlag()) |
---|
| 2325 | { |
---|
| 2326 | for (i=0; i < vps->getMaxLayers(); i++) |
---|
| 2327 | { |
---|
| 2328 | vps->setVideoSignalInfoIdx(i,i); |
---|
| 2329 | } |
---|
| 2330 | } |
---|
| 2331 | else { |
---|
| 2332 | vps->setVideoSignalInfoIdx(0,0); |
---|
| 2333 | if (vps->getNumVideoSignalInfo() > 1 ) |
---|
| 2334 | { |
---|
| 2335 | for (i=1; i < vps->getMaxLayers(); i++) |
---|
| 2336 | READ_CODE(4, uiCode, "vps_video_signal_info_idx" ); vps->setVideoSignalInfoIdx(i, uiCode); |
---|
| 2337 | } |
---|
| 2338 | else { |
---|
| 2339 | for (i=1; i < vps->getMaxLayers(); i++) |
---|
| 2340 | { |
---|
| 2341 | vps->setVideoSignalInfoIdx(i,0); |
---|
| 2342 | } |
---|
| 2343 | } |
---|
| 2344 | } |
---|
[588] | 2345 | #endif |
---|
[540] | 2346 | #endif |
---|
[644] | 2347 | |
---|
| 2348 | #if O0164_MULTI_LAYER_HRD |
---|
| 2349 | READ_FLAG(uiCode, "vps_vui_bsp_hrd_present_flag" ); vps->setVpsVuiBspHrdPresentFlag(uiCode); |
---|
| 2350 | if (vps->getVpsVuiBspHrdPresentFlag()) |
---|
| 2351 | { |
---|
| 2352 | READ_UVLC( uiCode, "vps_num_bsp_hrd_parameters_minus1" ); vps->setVpsNumBspHrdParametersMinus1(uiCode); |
---|
| 2353 | vps->createBspHrdParamBuffer(vps->getVpsNumBspHrdParametersMinus1() + 1); |
---|
| 2354 | for( i = 0; i <= vps->getVpsNumBspHrdParametersMinus1(); i++ ) |
---|
| 2355 | { |
---|
| 2356 | if( i > 0 ) |
---|
| 2357 | { |
---|
| 2358 | READ_FLAG( uiCode, "bsp_cprms_present_flag[i]" ); vps->setBspCprmsPresentFlag(i, uiCode); |
---|
| 2359 | } |
---|
| 2360 | parseHrdParameters(vps->getBspHrd(i), i==0 ? 1 : vps->getBspCprmsPresentFlag(i), vps->getMaxTLayers()-1); |
---|
| 2361 | } |
---|
[815] | 2362 | #if Q0078_ADD_LAYER_SETS |
---|
| 2363 | for (UInt h = 1; h <= vps->getVpsNumLayerSetsMinus1(); h++) |
---|
| 2364 | #else |
---|
[644] | 2365 | for( UInt h = 1; h <= (vps->getNumLayerSets()-1); h++ ) |
---|
[815] | 2366 | #endif |
---|
[644] | 2367 | { |
---|
| 2368 | READ_UVLC( uiCode, "num_bitstream_partitions[i]"); vps->setNumBitstreamPartitions(h, uiCode); |
---|
[815] | 2369 | #if HRD_BPB |
---|
| 2370 | Int chkPart=0; |
---|
| 2371 | #endif |
---|
[644] | 2372 | for( i = 0; i < vps->getNumBitstreamPartitions(h); i++ ) |
---|
| 2373 | { |
---|
| 2374 | for( j = 0; j <= (vps->getMaxLayers()-1); j++ ) |
---|
| 2375 | { |
---|
| 2376 | if( vps->getLayerIdIncludedFlag(h, j) ) |
---|
| 2377 | { |
---|
| 2378 | READ_FLAG( uiCode, "layer_in_bsp_flag[h][i][j]" ); vps->setLayerInBspFlag(h, i, j, uiCode); |
---|
| 2379 | } |
---|
| 2380 | } |
---|
[815] | 2381 | #if HRD_BPB |
---|
| 2382 | chkPart+=vps->getLayerInBspFlag(h, i, j); |
---|
| 2383 | #endif |
---|
[644] | 2384 | } |
---|
[815] | 2385 | #if HRD_BPB |
---|
| 2386 | assert(chkPart<=1); |
---|
| 2387 | #endif |
---|
| 2388 | #if HRD_BPB |
---|
| 2389 | if(vps->getNumBitstreamPartitions(h)==1) |
---|
| 2390 | { |
---|
| 2391 | Int chkPartition1=0; Int chkPartition2=0; |
---|
| 2392 | for( j = 0; j <= (vps->getMaxLayers()-1); j++ ) |
---|
| 2393 | { |
---|
| 2394 | if( vps->getLayerIdIncludedFlag(h, j) ) |
---|
| 2395 | { |
---|
| 2396 | chkPartition1+=vps->getLayerInBspFlag(h, 0, j); |
---|
| 2397 | chkPartition2++; |
---|
| 2398 | } |
---|
| 2399 | } |
---|
| 2400 | assert(chkPartition1!=chkPartition2); |
---|
| 2401 | } |
---|
| 2402 | #endif |
---|
[644] | 2403 | if (vps->getNumBitstreamPartitions(h)) |
---|
| 2404 | { |
---|
[815] | 2405 | #if Q0182_MULTI_LAYER_HRD_UPDATE |
---|
| 2406 | READ_UVLC( uiCode, "num_bsp_sched_combinations_minus1[h]"); vps->setNumBspSchedCombinations(h, uiCode + 1); |
---|
| 2407 | #else |
---|
[644] | 2408 | READ_UVLC( uiCode, "num_bsp_sched_combinations[h]"); vps->setNumBspSchedCombinations(h, uiCode); |
---|
[815] | 2409 | #endif |
---|
[644] | 2410 | for( i = 0; i < vps->getNumBspSchedCombinations(h); i++ ) |
---|
| 2411 | { |
---|
| 2412 | for( j = 0; j < vps->getNumBitstreamPartitions(h); j++ ) |
---|
| 2413 | { |
---|
| 2414 | READ_UVLC( uiCode, "bsp_comb_hrd_idx[h][i][j]"); vps->setBspCombHrdIdx(h, i, j, uiCode); |
---|
[815] | 2415 | #if HRD_BPB |
---|
| 2416 | assert(uiCode <= vps->getVpsNumBspHrdParametersMinus1()); |
---|
| 2417 | #endif |
---|
| 2418 | |
---|
[644] | 2419 | READ_UVLC( uiCode, "bsp_comb_sched_idx[h][i][j]"); vps->setBspCombSchedIdx(h, i, j, uiCode); |
---|
[815] | 2420 | #if HRD_BPB |
---|
| 2421 | assert(uiCode <= vps->getBspHrdParamBufferCpbCntMinus1(uiCode,vps->getMaxTLayers()-1)); |
---|
| 2422 | #endif |
---|
[644] | 2423 | } |
---|
| 2424 | } |
---|
| 2425 | } |
---|
| 2426 | } |
---|
| 2427 | } |
---|
| 2428 | #endif |
---|
| 2429 | |
---|
| 2430 | #if P0182_VPS_VUI_PS_FLAG |
---|
| 2431 | for(i = 1; i < vps->getMaxLayers(); i++) |
---|
| 2432 | { |
---|
| 2433 | if (vps->getNumRefLayers(vps->getLayerIdInNuh(i)) == 0) |
---|
| 2434 | { |
---|
| 2435 | READ_FLAG( uiCode, "base_layer_parameter_set_compatibility_flag" ); |
---|
| 2436 | vps->setBaseLayerPSCompatibilityFlag( i, uiCode ); |
---|
| 2437 | } |
---|
| 2438 | else |
---|
| 2439 | { |
---|
| 2440 | vps->setBaseLayerPSCompatibilityFlag( i, 0 ); |
---|
| 2441 | } |
---|
| 2442 | } |
---|
| 2443 | #endif |
---|
[442] | 2444 | } |
---|
[494] | 2445 | #endif //SVC_EXTENSION |
---|
| 2446 | |
---|
[313] | 2447 | Void TDecCavlc::parseSliceHeader (TComSlice*& rpcSlice, ParameterSetManagerDecoder *parameterSetManager) |
---|
| 2448 | { |
---|
| 2449 | UInt uiCode; |
---|
| 2450 | Int iCode; |
---|
| 2451 | |
---|
| 2452 | #if ENC_DEC_TRACE |
---|
| 2453 | xTraceSliceHeader(rpcSlice); |
---|
| 2454 | #endif |
---|
| 2455 | TComPPS* pps = NULL; |
---|
| 2456 | TComSPS* sps = NULL; |
---|
| 2457 | |
---|
| 2458 | UInt firstSliceSegmentInPic; |
---|
| 2459 | READ_FLAG( firstSliceSegmentInPic, "first_slice_segment_in_pic_flag" ); |
---|
| 2460 | if( rpcSlice->getRapPicFlag()) |
---|
| 2461 | { |
---|
[713] | 2462 | READ_FLAG( uiCode, "no_output_of_prior_pics_flag" ); //ignored -- updated already |
---|
| 2463 | #if SETTING_NO_OUT_PIC_PRIOR |
---|
| 2464 | rpcSlice->setNoOutputPriorPicsFlag(uiCode ? true : false); |
---|
[644] | 2465 | #else |
---|
[713] | 2466 | rpcSlice->setNoOutputPicPrior( false ); |
---|
[644] | 2467 | #endif |
---|
[313] | 2468 | } |
---|
| 2469 | READ_UVLC ( uiCode, "slice_pic_parameter_set_id" ); rpcSlice->setPPSId(uiCode); |
---|
| 2470 | pps = parameterSetManager->getPrefetchedPPS(uiCode); |
---|
| 2471 | //!KS: need to add error handling code here, if PPS is not available |
---|
| 2472 | assert(pps!=0); |
---|
| 2473 | sps = parameterSetManager->getPrefetchedSPS(pps->getSPSId()); |
---|
| 2474 | //!KS: need to add error handling code here, if SPS is not available |
---|
| 2475 | assert(sps!=0); |
---|
| 2476 | rpcSlice->setSPS(sps); |
---|
| 2477 | rpcSlice->setPPS(pps); |
---|
| 2478 | if( pps->getDependentSliceSegmentsEnabledFlag() && ( !firstSliceSegmentInPic )) |
---|
| 2479 | { |
---|
| 2480 | READ_FLAG( uiCode, "dependent_slice_segment_flag" ); rpcSlice->setDependentSliceSegmentFlag(uiCode ? true : false); |
---|
| 2481 | } |
---|
| 2482 | else |
---|
| 2483 | { |
---|
| 2484 | rpcSlice->setDependentSliceSegmentFlag(false); |
---|
| 2485 | } |
---|
[442] | 2486 | #if REPN_FORMAT_IN_VPS |
---|
| 2487 | Int numCTUs = ((rpcSlice->getPicWidthInLumaSamples()+sps->getMaxCUWidth()-1)/sps->getMaxCUWidth())*((rpcSlice->getPicHeightInLumaSamples()+sps->getMaxCUHeight()-1)/sps->getMaxCUHeight()); |
---|
| 2488 | #else |
---|
[313] | 2489 | Int numCTUs = ((sps->getPicWidthInLumaSamples()+sps->getMaxCUWidth()-1)/sps->getMaxCUWidth())*((sps->getPicHeightInLumaSamples()+sps->getMaxCUHeight()-1)/sps->getMaxCUHeight()); |
---|
[442] | 2490 | #endif |
---|
[313] | 2491 | Int maxParts = (1<<(sps->getMaxCUDepth()<<1)); |
---|
| 2492 | UInt sliceSegmentAddress = 0; |
---|
| 2493 | Int bitsSliceSegmentAddress = 0; |
---|
| 2494 | while(numCTUs>(1<<bitsSliceSegmentAddress)) |
---|
| 2495 | { |
---|
| 2496 | bitsSliceSegmentAddress++; |
---|
| 2497 | } |
---|
| 2498 | |
---|
| 2499 | if(!firstSliceSegmentInPic) |
---|
| 2500 | { |
---|
| 2501 | READ_CODE( bitsSliceSegmentAddress, sliceSegmentAddress, "slice_segment_address" ); |
---|
| 2502 | } |
---|
| 2503 | //set uiCode to equal slice start address (or dependent slice start address) |
---|
| 2504 | Int startCuAddress = maxParts*sliceSegmentAddress; |
---|
| 2505 | rpcSlice->setSliceSegmentCurStartCUAddr( startCuAddress ); |
---|
| 2506 | rpcSlice->setSliceSegmentCurEndCUAddr(numCTUs*maxParts); |
---|
| 2507 | |
---|
| 2508 | if (rpcSlice->getDependentSliceSegmentFlag()) |
---|
| 2509 | { |
---|
| 2510 | rpcSlice->setNextSlice ( false ); |
---|
| 2511 | rpcSlice->setNextSliceSegment ( true ); |
---|
| 2512 | } |
---|
| 2513 | else |
---|
| 2514 | { |
---|
| 2515 | rpcSlice->setNextSlice ( true ); |
---|
| 2516 | rpcSlice->setNextSliceSegment ( false ); |
---|
| 2517 | |
---|
| 2518 | rpcSlice->setSliceCurStartCUAddr(startCuAddress); |
---|
| 2519 | rpcSlice->setSliceCurEndCUAddr(numCTUs*maxParts); |
---|
| 2520 | } |
---|
| 2521 | |
---|
[815] | 2522 | #if Q0142_POC_LSB_NOT_PRESENT |
---|
| 2523 | #if SHM_FIX7 |
---|
| 2524 | Int iPOClsb = 0; |
---|
| 2525 | #endif |
---|
| 2526 | #endif |
---|
| 2527 | |
---|
[313] | 2528 | if(!rpcSlice->getDependentSliceSegmentFlag()) |
---|
| 2529 | { |
---|
[494] | 2530 | #if SVC_EXTENSION |
---|
[442] | 2531 | #if POC_RESET_FLAG |
---|
[494] | 2532 | Int iBits = 0; |
---|
[442] | 2533 | if(rpcSlice->getPPS()->getNumExtraSliceHeaderBits() > iBits) |
---|
| 2534 | { |
---|
| 2535 | READ_FLAG(uiCode, "poc_reset_flag"); rpcSlice->setPocResetFlag( uiCode ? true : false ); |
---|
| 2536 | iBits++; |
---|
| 2537 | } |
---|
| 2538 | if(rpcSlice->getPPS()->getNumExtraSliceHeaderBits() > iBits) |
---|
| 2539 | { |
---|
[588] | 2540 | #if DISCARDABLE_PIC_RPS |
---|
| 2541 | READ_FLAG(uiCode, "discardable_flag"); rpcSlice->setDiscardableFlag( uiCode ? true : false ); |
---|
| 2542 | #else |
---|
[442] | 2543 | READ_FLAG(uiCode, "discardable_flag"); // ignored |
---|
[588] | 2544 | #endif |
---|
[442] | 2545 | iBits++; |
---|
| 2546 | } |
---|
[540] | 2547 | #if O0149_CROSS_LAYER_BLA_FLAG |
---|
| 2548 | if(rpcSlice->getPPS()->getNumExtraSliceHeaderBits() > iBits) |
---|
| 2549 | { |
---|
| 2550 | READ_FLAG(uiCode, "cross_layer_bla_flag"); rpcSlice->setCrossLayerBLAFlag( uiCode ? true : false ); |
---|
| 2551 | iBits++; |
---|
| 2552 | } |
---|
| 2553 | #endif |
---|
[442] | 2554 | for (; iBits < rpcSlice->getPPS()->getNumExtraSliceHeaderBits(); iBits++) |
---|
| 2555 | { |
---|
| 2556 | READ_FLAG(uiCode, "slice_reserved_undetermined_flag[]"); // ignored |
---|
| 2557 | } |
---|
| 2558 | #else |
---|
[313] | 2559 | if(rpcSlice->getPPS()->getNumExtraSliceHeaderBits()>0) |
---|
| 2560 | { |
---|
| 2561 | READ_FLAG(uiCode, "discardable_flag"); // ignored |
---|
| 2562 | } |
---|
| 2563 | for (Int i = 1; i < rpcSlice->getPPS()->getNumExtraSliceHeaderBits(); i++) |
---|
| 2564 | { |
---|
| 2565 | READ_FLAG(uiCode, "slice_reserved_undetermined_flag[]"); // ignored |
---|
| 2566 | } |
---|
[494] | 2567 | #endif |
---|
| 2568 | #else //SVC_EXTENSION |
---|
[313] | 2569 | for (Int i = 0; i < rpcSlice->getPPS()->getNumExtraSliceHeaderBits(); i++) |
---|
| 2570 | { |
---|
| 2571 | READ_FLAG(uiCode, "slice_reserved_undetermined_flag[]"); // ignored |
---|
| 2572 | } |
---|
[494] | 2573 | #endif //SVC_EXTENSION |
---|
[313] | 2574 | |
---|
| 2575 | READ_UVLC ( uiCode, "slice_type" ); rpcSlice->setSliceType((SliceType)uiCode); |
---|
| 2576 | if( pps->getOutputFlagPresentFlag() ) |
---|
| 2577 | { |
---|
| 2578 | READ_FLAG( uiCode, "pic_output_flag" ); rpcSlice->setPicOutputFlag( uiCode ? true : false ); |
---|
| 2579 | } |
---|
| 2580 | else |
---|
| 2581 | { |
---|
| 2582 | rpcSlice->setPicOutputFlag( true ); |
---|
| 2583 | } |
---|
| 2584 | // in the first version chroma_format_idc is equal to one, thus colour_plane_id will not be present |
---|
| 2585 | assert (sps->getChromaFormatIdc() == 1 ); |
---|
| 2586 | // if( separate_colour_plane_flag == 1 ) |
---|
| 2587 | // colour_plane_id u(2) |
---|
| 2588 | |
---|
| 2589 | if( rpcSlice->getIdrPicFlag() ) |
---|
| 2590 | { |
---|
| 2591 | rpcSlice->setPOC(0); |
---|
| 2592 | TComReferencePictureSet* rps = rpcSlice->getLocalRPS(); |
---|
| 2593 | rps->setNumberOfNegativePictures(0); |
---|
| 2594 | rps->setNumberOfPositivePictures(0); |
---|
| 2595 | rps->setNumberOfLongtermPictures(0); |
---|
| 2596 | rps->setNumberOfPictures(0); |
---|
| 2597 | rpcSlice->setRPS(rps); |
---|
| 2598 | } |
---|
[442] | 2599 | #if N0065_LAYER_POC_ALIGNMENT |
---|
[815] | 2600 | #if !Q0142_POC_LSB_NOT_PRESENT |
---|
[494] | 2601 | #if SHM_FIX7 |
---|
| 2602 | Int iPOClsb = 0; |
---|
| 2603 | #endif |
---|
[815] | 2604 | #endif |
---|
[494] | 2605 | #if O0062_POC_LSB_NOT_PRESENT_FLAG |
---|
| 2606 | if( ( rpcSlice->getLayerId() > 0 && !rpcSlice->getVPS()->getPocLsbNotPresentFlag( rpcSlice->getVPS()->getLayerIdInVps(rpcSlice->getLayerId())) ) || !rpcSlice->getIdrPicFlag()) |
---|
| 2607 | #else |
---|
[442] | 2608 | if( rpcSlice->getLayerId() > 0 || !rpcSlice->getIdrPicFlag() ) |
---|
[494] | 2609 | #endif |
---|
[442] | 2610 | #else |
---|
[313] | 2611 | else |
---|
[442] | 2612 | #endif |
---|
[313] | 2613 | { |
---|
| 2614 | READ_CODE(sps->getBitsForPOC(), uiCode, "pic_order_cnt_lsb"); |
---|
[815] | 2615 | #if POC_RESET_IDC_DECODER |
---|
| 2616 | rpcSlice->setPicOrderCntLsb( uiCode ); |
---|
| 2617 | #endif |
---|
[494] | 2618 | #if SHM_FIX7 |
---|
| 2619 | iPOClsb = uiCode; |
---|
| 2620 | #else |
---|
[313] | 2621 | Int iPOClsb = uiCode; |
---|
[494] | 2622 | #endif |
---|
[442] | 2623 | Int iPrevPOC = rpcSlice->getPrevTid0POC(); |
---|
[313] | 2624 | Int iMaxPOClsb = 1<< sps->getBitsForPOC(); |
---|
[442] | 2625 | Int iPrevPOClsb = iPrevPOC & (iMaxPOClsb - 1); |
---|
[313] | 2626 | Int iPrevPOCmsb = iPrevPOC-iPrevPOClsb; |
---|
| 2627 | Int iPOCmsb; |
---|
| 2628 | if( ( iPOClsb < iPrevPOClsb ) && ( ( iPrevPOClsb - iPOClsb ) >= ( iMaxPOClsb / 2 ) ) ) |
---|
| 2629 | { |
---|
| 2630 | iPOCmsb = iPrevPOCmsb + iMaxPOClsb; |
---|
| 2631 | } |
---|
| 2632 | else if( (iPOClsb > iPrevPOClsb ) && ( (iPOClsb - iPrevPOClsb ) > ( iMaxPOClsb / 2 ) ) ) |
---|
| 2633 | { |
---|
| 2634 | iPOCmsb = iPrevPOCmsb - iMaxPOClsb; |
---|
| 2635 | } |
---|
| 2636 | else |
---|
| 2637 | { |
---|
| 2638 | iPOCmsb = iPrevPOCmsb; |
---|
| 2639 | } |
---|
| 2640 | if ( rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP |
---|
| 2641 | || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL |
---|
| 2642 | || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP ) |
---|
| 2643 | { |
---|
| 2644 | // For BLA picture types, POCmsb is set to 0. |
---|
| 2645 | iPOCmsb = 0; |
---|
| 2646 | } |
---|
| 2647 | rpcSlice->setPOC (iPOCmsb+iPOClsb); |
---|
| 2648 | |
---|
[442] | 2649 | #if N0065_LAYER_POC_ALIGNMENT |
---|
[494] | 2650 | #if SHM_FIX7 |
---|
| 2651 | } |
---|
| 2652 | #endif |
---|
[815] | 2653 | #if POC_RESET_IDC_DECODER |
---|
| 2654 | else |
---|
| 2655 | { |
---|
| 2656 | rpcSlice->setPicOrderCntLsb( 0 ); |
---|
| 2657 | } |
---|
| 2658 | #endif |
---|
[442] | 2659 | if( !rpcSlice->getIdrPicFlag() ) |
---|
| 2660 | { |
---|
| 2661 | #endif |
---|
[313] | 2662 | TComReferencePictureSet* rps; |
---|
| 2663 | rps = rpcSlice->getLocalRPS(); |
---|
| 2664 | rpcSlice->setRPS(rps); |
---|
| 2665 | READ_FLAG( uiCode, "short_term_ref_pic_set_sps_flag" ); |
---|
| 2666 | if(uiCode == 0) // use short-term reference picture set explicitly signalled in slice header |
---|
| 2667 | { |
---|
| 2668 | parseShortTermRefPicSet(sps,rps, sps->getRPSList()->getNumberOfReferencePictureSets()); |
---|
| 2669 | } |
---|
| 2670 | else // use reference to short-term reference picture set in PPS |
---|
| 2671 | { |
---|
| 2672 | Int numBits = 0; |
---|
| 2673 | while ((1 << numBits) < rpcSlice->getSPS()->getRPSList()->getNumberOfReferencePictureSets()) |
---|
| 2674 | { |
---|
| 2675 | numBits++; |
---|
| 2676 | } |
---|
| 2677 | if (numBits > 0) |
---|
| 2678 | { |
---|
| 2679 | READ_CODE( numBits, uiCode, "short_term_ref_pic_set_idx"); |
---|
| 2680 | } |
---|
| 2681 | else |
---|
| 2682 | { |
---|
[713] | 2683 | uiCode = 0; |
---|
[313] | 2684 | } |
---|
| 2685 | *rps = *(sps->getRPSList()->getReferencePictureSet(uiCode)); |
---|
| 2686 | } |
---|
| 2687 | if(sps->getLongTermRefsPresent()) |
---|
| 2688 | { |
---|
| 2689 | Int offset = rps->getNumberOfNegativePictures()+rps->getNumberOfPositivePictures(); |
---|
| 2690 | UInt numOfLtrp = 0; |
---|
| 2691 | UInt numLtrpInSPS = 0; |
---|
| 2692 | if (rpcSlice->getSPS()->getNumLongTermRefPicSPS() > 0) |
---|
| 2693 | { |
---|
| 2694 | READ_UVLC( uiCode, "num_long_term_sps"); |
---|
| 2695 | numLtrpInSPS = uiCode; |
---|
| 2696 | numOfLtrp += numLtrpInSPS; |
---|
| 2697 | rps->setNumberOfLongtermPictures(numOfLtrp); |
---|
| 2698 | } |
---|
| 2699 | Int bitsForLtrpInSPS = 0; |
---|
| 2700 | while (rpcSlice->getSPS()->getNumLongTermRefPicSPS() > (1 << bitsForLtrpInSPS)) |
---|
| 2701 | { |
---|
| 2702 | bitsForLtrpInSPS++; |
---|
| 2703 | } |
---|
| 2704 | READ_UVLC( uiCode, "num_long_term_pics"); rps->setNumberOfLongtermPictures(uiCode); |
---|
| 2705 | numOfLtrp += uiCode; |
---|
| 2706 | rps->setNumberOfLongtermPictures(numOfLtrp); |
---|
| 2707 | Int maxPicOrderCntLSB = 1 << rpcSlice->getSPS()->getBitsForPOC(); |
---|
| 2708 | Int prevDeltaMSB = 0, deltaPocMSBCycleLT = 0;; |
---|
| 2709 | for(Int j=offset+rps->getNumberOfLongtermPictures()-1, k = 0; k < numOfLtrp; j--, k++) |
---|
| 2710 | { |
---|
| 2711 | Int pocLsbLt; |
---|
| 2712 | if (k < numLtrpInSPS) |
---|
| 2713 | { |
---|
| 2714 | uiCode = 0; |
---|
| 2715 | if (bitsForLtrpInSPS > 0) |
---|
| 2716 | { |
---|
| 2717 | READ_CODE(bitsForLtrpInSPS, uiCode, "lt_idx_sps[i]"); |
---|
| 2718 | } |
---|
| 2719 | Int usedByCurrFromSPS=rpcSlice->getSPS()->getUsedByCurrPicLtSPSFlag(uiCode); |
---|
| 2720 | |
---|
| 2721 | pocLsbLt = rpcSlice->getSPS()->getLtRefPicPocLsbSps(uiCode); |
---|
| 2722 | rps->setUsed(j,usedByCurrFromSPS); |
---|
| 2723 | } |
---|
| 2724 | else |
---|
| 2725 | { |
---|
| 2726 | READ_CODE(rpcSlice->getSPS()->getBitsForPOC(), uiCode, "poc_lsb_lt"); pocLsbLt= uiCode; |
---|
| 2727 | READ_FLAG( uiCode, "used_by_curr_pic_lt_flag"); rps->setUsed(j,uiCode); |
---|
| 2728 | } |
---|
| 2729 | READ_FLAG(uiCode,"delta_poc_msb_present_flag"); |
---|
| 2730 | Bool mSBPresentFlag = uiCode ? true : false; |
---|
| 2731 | if(mSBPresentFlag) |
---|
| 2732 | { |
---|
| 2733 | READ_UVLC( uiCode, "delta_poc_msb_cycle_lt[i]" ); |
---|
| 2734 | Bool deltaFlag = false; |
---|
| 2735 | // First LTRP || First LTRP from SH |
---|
| 2736 | if( (j == offset+rps->getNumberOfLongtermPictures()-1) || (j == offset+(numOfLtrp-numLtrpInSPS)-1) ) |
---|
| 2737 | { |
---|
| 2738 | deltaFlag = true; |
---|
| 2739 | } |
---|
| 2740 | if(deltaFlag) |
---|
| 2741 | { |
---|
| 2742 | deltaPocMSBCycleLT = uiCode; |
---|
| 2743 | } |
---|
| 2744 | else |
---|
| 2745 | { |
---|
| 2746 | deltaPocMSBCycleLT = uiCode + prevDeltaMSB; |
---|
| 2747 | } |
---|
| 2748 | |
---|
| 2749 | Int pocLTCurr = rpcSlice->getPOC() - deltaPocMSBCycleLT * maxPicOrderCntLSB |
---|
| 2750 | - iPOClsb + pocLsbLt; |
---|
| 2751 | rps->setPOC (j, pocLTCurr); |
---|
| 2752 | rps->setDeltaPOC(j, - rpcSlice->getPOC() + pocLTCurr); |
---|
| 2753 | rps->setCheckLTMSBPresent(j,true); |
---|
| 2754 | } |
---|
| 2755 | else |
---|
| 2756 | { |
---|
| 2757 | rps->setPOC (j, pocLsbLt); |
---|
| 2758 | rps->setDeltaPOC(j, - rpcSlice->getPOC() + pocLsbLt); |
---|
| 2759 | rps->setCheckLTMSBPresent(j,false); |
---|
[494] | 2760 | |
---|
[442] | 2761 | // reset deltaPocMSBCycleLT for first LTRP from slice header if MSB not present |
---|
| 2762 | if( j == offset+(numOfLtrp-numLtrpInSPS)-1 ) |
---|
| 2763 | { |
---|
| 2764 | deltaPocMSBCycleLT = 0; |
---|
| 2765 | } |
---|
[313] | 2766 | } |
---|
| 2767 | prevDeltaMSB = deltaPocMSBCycleLT; |
---|
| 2768 | } |
---|
| 2769 | offset += rps->getNumberOfLongtermPictures(); |
---|
| 2770 | rps->setNumberOfPictures(offset); |
---|
| 2771 | } |
---|
[815] | 2772 | #if DPB_CONSTRAINTS |
---|
| 2773 | if(rpcSlice->getVPS()->getVpsExtensionFlag()==1) |
---|
| 2774 | { |
---|
| 2775 | #if Q0078_ADD_LAYER_SETS |
---|
| 2776 | for (Int ii = 1; ii < (rpcSlice->getVPS()->getVpsNumLayerSetsMinus1() + 1); ii++) // prevent assert error when num_add_layer_sets > 0 |
---|
| 2777 | #else |
---|
| 2778 | for (Int ii=1; ii< rpcSlice->getVPS()->getNumOutputLayerSets(); ii++ ) |
---|
| 2779 | #endif |
---|
| 2780 | { |
---|
| 2781 | Int layerSetIdxForOutputLayerSet = rpcSlice->getVPS()->getOutputLayerSetIdx( ii ); |
---|
| 2782 | Int chkAssert=0; |
---|
| 2783 | for(Int kk = 0; kk < rpcSlice->getVPS()->getNumLayersInIdList(layerSetIdxForOutputLayerSet); kk++) |
---|
| 2784 | { |
---|
| 2785 | if(rpcSlice->getLayerId()==rpcSlice->getVPS()->getLayerSetLayerIdList(layerSetIdxForOutputLayerSet, kk)) |
---|
| 2786 | { |
---|
| 2787 | chkAssert=1; |
---|
| 2788 | } |
---|
| 2789 | } |
---|
| 2790 | if(chkAssert) |
---|
| 2791 | { |
---|
| 2792 | // There may be something wrong here (layer id assumed to be layer idx?) |
---|
| 2793 | assert(rps->getNumberOfNegativePictures() <= rpcSlice->getVPS()->getMaxVpsDecPicBufferingMinus1(ii , rpcSlice->getLayerId() , rpcSlice->getVPS()->getMaxSLayersInLayerSetMinus1(ii))); |
---|
| 2794 | assert(rps->getNumberOfPositivePictures() <= rpcSlice->getVPS()->getMaxVpsDecPicBufferingMinus1(ii , rpcSlice->getLayerId() , rpcSlice->getVPS()->getMaxSLayersInLayerSetMinus1(ii)) - rps->getNumberOfNegativePictures()); |
---|
| 2795 | assert((rps->getNumberOfPositivePictures() + rps->getNumberOfNegativePictures() + rps->getNumberOfLongtermPictures()) <= rpcSlice->getVPS()->getMaxVpsDecPicBufferingMinus1(ii , rpcSlice->getLayerId() , rpcSlice->getVPS()->getMaxSLayersInLayerSetMinus1(ii))); |
---|
| 2796 | } |
---|
| 2797 | } |
---|
| 2798 | |
---|
| 2799 | |
---|
| 2800 | } |
---|
| 2801 | if(rpcSlice->getLayerId() == 0) |
---|
| 2802 | { |
---|
| 2803 | assert(rps->getNumberOfNegativePictures() <= rpcSlice->getSPS()->getMaxDecPicBuffering(rpcSlice->getSPS()->getMaxTLayers()-1) ); |
---|
| 2804 | assert(rps->getNumberOfPositivePictures() <= rpcSlice->getSPS()->getMaxDecPicBuffering(rpcSlice->getSPS()->getMaxTLayers()-1) -rps->getNumberOfNegativePictures()); |
---|
| 2805 | assert((rps->getNumberOfPositivePictures() + rps->getNumberOfNegativePictures() + rps->getNumberOfLongtermPictures()) <= rpcSlice->getSPS()->getMaxDecPicBuffering(rpcSlice->getSPS()->getMaxTLayers()-1)); |
---|
| 2806 | } |
---|
| 2807 | #endif |
---|
[313] | 2808 | if ( rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP |
---|
| 2809 | || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL |
---|
| 2810 | || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP ) |
---|
| 2811 | { |
---|
| 2812 | // In the case of BLA picture types, rps data is read from slice header but ignored |
---|
| 2813 | rps = rpcSlice->getLocalRPS(); |
---|
| 2814 | rps->setNumberOfNegativePictures(0); |
---|
| 2815 | rps->setNumberOfPositivePictures(0); |
---|
| 2816 | rps->setNumberOfLongtermPictures(0); |
---|
| 2817 | rps->setNumberOfPictures(0); |
---|
| 2818 | rpcSlice->setRPS(rps); |
---|
| 2819 | } |
---|
| 2820 | if (rpcSlice->getSPS()->getTMVPFlagsPresent()) |
---|
| 2821 | { |
---|
| 2822 | READ_FLAG( uiCode, "slice_temporal_mvp_enable_flag" ); |
---|
| 2823 | rpcSlice->setEnableTMVPFlag( uiCode == 1 ? true : false ); |
---|
| 2824 | } |
---|
| 2825 | else |
---|
| 2826 | { |
---|
| 2827 | rpcSlice->setEnableTMVPFlag(false); |
---|
| 2828 | } |
---|
[494] | 2829 | #if N0065_LAYER_POC_ALIGNMENT && !SHM_FIX7 |
---|
[313] | 2830 | } |
---|
[442] | 2831 | #endif |
---|
| 2832 | } |
---|
[313] | 2833 | |
---|
[442] | 2834 | #if SVC_EXTENSION |
---|
[313] | 2835 | rpcSlice->setActiveNumILRRefIdx(0); |
---|
[644] | 2836 | if((rpcSlice->getLayerId() > 0) && !(rpcSlice->getVPS()->getIlpSshSignalingEnabledFlag()) && (rpcSlice->getNumILRRefIdx() > 0) ) |
---|
[313] | 2837 | { |
---|
| 2838 | READ_FLAG(uiCode,"inter_layer_pred_enabled_flag"); |
---|
| 2839 | rpcSlice->setInterLayerPredEnabledFlag(uiCode); |
---|
| 2840 | if( rpcSlice->getInterLayerPredEnabledFlag()) |
---|
| 2841 | { |
---|
| 2842 | if(rpcSlice->getNumILRRefIdx() > 1) |
---|
| 2843 | { |
---|
| 2844 | Int numBits = 1; |
---|
| 2845 | while ((1 << numBits) < rpcSlice->getNumILRRefIdx()) |
---|
| 2846 | { |
---|
| 2847 | numBits++; |
---|
| 2848 | } |
---|
| 2849 | if( !rpcSlice->getVPS()->getMaxOneActiveRefLayerFlag()) |
---|
| 2850 | { |
---|
| 2851 | READ_CODE( numBits, uiCode,"num_inter_layer_ref_pics_minus1" ); |
---|
| 2852 | rpcSlice->setActiveNumILRRefIdx(uiCode + 1); |
---|
| 2853 | } |
---|
| 2854 | else |
---|
| 2855 | { |
---|
[588] | 2856 | #if P0079_DERIVE_NUMACTIVE_REF_PICS |
---|
[644] | 2857 | for( Int i = 0; i < rpcSlice->getNumILRRefIdx(); i++ ) |
---|
[588] | 2858 | { |
---|
[713] | 2859 | #if Q0060_MAX_TID_REF_EQUAL_TO_ZERO |
---|
| 2860 | if((rpcSlice->getVPS()->getMaxTidIlRefPicsPlus1(rpcSlice->getVPS()->getLayerIdInVps(i),rpcSlice->getLayerId()) > rpcSlice->getTLayer() || rpcSlice->getTLayer()==0) && |
---|
| 2861 | (rpcSlice->getVPS()->getMaxTSLayersMinus1(rpcSlice->getVPS()->getLayerIdInVps(i)) >= rpcSlice->getTLayer()) ) |
---|
| 2862 | #else |
---|
[588] | 2863 | if(rpcSlice->getVPS()->getMaxTidIlRefPicsPlus1(rpcSlice->getVPS()->getLayerIdInVps(i),rpcSlice->getLayerId()) > rpcSlice->getTLayer() && |
---|
| 2864 | (rpcSlice->getVPS()->getMaxTSLayersMinus1(rpcSlice->getVPS()->getLayerIdInVps(i)) >= rpcSlice->getTLayer()) ) |
---|
[713] | 2865 | #endif |
---|
[588] | 2866 | { |
---|
[644] | 2867 | rpcSlice->setActiveNumILRRefIdx(1); |
---|
| 2868 | break; |
---|
[588] | 2869 | } |
---|
| 2870 | } |
---|
| 2871 | #else |
---|
[313] | 2872 | rpcSlice->setActiveNumILRRefIdx(1); |
---|
[588] | 2873 | #endif |
---|
[313] | 2874 | } |
---|
[815] | 2875 | |
---|
[345] | 2876 | if( rpcSlice->getActiveNumILRRefIdx() == rpcSlice->getNumILRRefIdx() ) |
---|
| 2877 | { |
---|
| 2878 | for( Int i = 0; i < rpcSlice->getActiveNumILRRefIdx(); i++ ) |
---|
| 2879 | { |
---|
| 2880 | rpcSlice->setInterLayerPredLayerIdc(i,i); |
---|
| 2881 | } |
---|
| 2882 | } |
---|
| 2883 | else |
---|
| 2884 | { |
---|
[815] | 2885 | for(Int i = 0; i < rpcSlice->getActiveNumILRRefIdx(); i++ ) |
---|
| 2886 | { |
---|
| 2887 | READ_CODE( numBits,uiCode,"inter_layer_pred_layer_idc[i]" ); |
---|
| 2888 | rpcSlice->setInterLayerPredLayerIdc(uiCode,i); |
---|
| 2889 | } |
---|
[313] | 2890 | } |
---|
| 2891 | } |
---|
| 2892 | else |
---|
| 2893 | { |
---|
[540] | 2894 | #if O0225_TID_BASED_IL_RPS_DERIV && TSLAYERS_IL_RPS |
---|
[713] | 2895 | #if Q0060_MAX_TID_REF_EQUAL_TO_ZERO |
---|
| 2896 | if((rpcSlice->getVPS()->getMaxTidIlRefPicsPlus1(0,rpcSlice->getLayerId()) > rpcSlice->getTLayer() || rpcSlice->getTLayer()==0) && |
---|
| 2897 | (rpcSlice->getVPS()->getMaxTSLayersMinus1(0) >= rpcSlice->getTLayer()) ) |
---|
| 2898 | #else |
---|
[540] | 2899 | if( (rpcSlice->getVPS()->getMaxTidIlRefPicsPlus1(0,rpcSlice->getLayerId()) > rpcSlice->getTLayer()) && |
---|
| 2900 | (rpcSlice->getVPS()->getMaxTSLayersMinus1(0) >= rpcSlice->getTLayer()) ) |
---|
[713] | 2901 | #endif |
---|
[540] | 2902 | { |
---|
| 2903 | #endif |
---|
[313] | 2904 | rpcSlice->setActiveNumILRRefIdx(1); |
---|
| 2905 | rpcSlice->setInterLayerPredLayerIdc(0,0); |
---|
[540] | 2906 | #if O0225_TID_BASED_IL_RPS_DERIV && TSLAYERS_IL_RPS |
---|
[313] | 2907 | } |
---|
[540] | 2908 | #endif |
---|
| 2909 | } |
---|
[313] | 2910 | } |
---|
| 2911 | } |
---|
[540] | 2912 | else if( rpcSlice->getVPS()->getIlpSshSignalingEnabledFlag() == true && (rpcSlice->getLayerId() > 0 )) |
---|
[345] | 2913 | { |
---|
| 2914 | rpcSlice->setInterLayerPredEnabledFlag(true); |
---|
[540] | 2915 | |
---|
| 2916 | #if O0225_TID_BASED_IL_RPS_DERIV && TSLAYERS_IL_RPS |
---|
| 2917 | Int numRefLayerPics = 0; |
---|
| 2918 | Int i = 0; |
---|
| 2919 | Int refLayerPicIdc [MAX_VPS_LAYER_ID_PLUS1]; |
---|
| 2920 | for(i = 0, numRefLayerPics = 0; i < rpcSlice->getNumILRRefIdx(); i++ ) |
---|
| 2921 | { |
---|
[713] | 2922 | #if Q0060_MAX_TID_REF_EQUAL_TO_ZERO |
---|
| 2923 | if((rpcSlice->getVPS()->getMaxTidIlRefPicsPlus1(rpcSlice->getVPS()->getLayerIdInVps(i),rpcSlice->getLayerId()) > rpcSlice->getTLayer() || rpcSlice->getTLayer()==0) && |
---|
| 2924 | (rpcSlice->getVPS()->getMaxTSLayersMinus1(rpcSlice->getVPS()->getLayerIdInVps(i)) >= rpcSlice->getTLayer()) ) |
---|
| 2925 | #else |
---|
[540] | 2926 | if(rpcSlice->getVPS()->getMaxTidIlRefPicsPlus1(rpcSlice->getVPS()->getLayerIdInVps(i),rpcSlice->getLayerId()) > rpcSlice->getTLayer() && |
---|
| 2927 | (rpcSlice->getVPS()->getMaxTSLayersMinus1(rpcSlice->getVPS()->getLayerIdInVps(i)) >= rpcSlice->getTLayer()) ) |
---|
[713] | 2928 | #endif |
---|
[540] | 2929 | { |
---|
| 2930 | refLayerPicIdc[ numRefLayerPics++ ] = i; |
---|
| 2931 | } |
---|
| 2932 | } |
---|
| 2933 | rpcSlice->setActiveNumILRRefIdx(numRefLayerPics); |
---|
| 2934 | for( i = 0; i < rpcSlice->getActiveNumILRRefIdx(); i++ ) |
---|
| 2935 | { |
---|
| 2936 | rpcSlice->setInterLayerPredLayerIdc(refLayerPicIdc[i],i); |
---|
| 2937 | } |
---|
| 2938 | #else |
---|
[345] | 2939 | rpcSlice->setActiveNumILRRefIdx(rpcSlice->getNumILRRefIdx()); |
---|
| 2940 | for( Int i = 0; i < rpcSlice->getActiveNumILRRefIdx(); i++ ) |
---|
| 2941 | { |
---|
| 2942 | rpcSlice->setInterLayerPredLayerIdc(i,i); |
---|
| 2943 | } |
---|
[540] | 2944 | #endif |
---|
[345] | 2945 | } |
---|
[644] | 2946 | #if P0312_VERT_PHASE_ADJ |
---|
| 2947 | for(Int i = 0; i < rpcSlice->getActiveNumILRRefIdx(); i++ ) |
---|
| 2948 | { |
---|
| 2949 | UInt refLayerIdc = rpcSlice->getInterLayerPredLayerIdc(i); |
---|
| 2950 | if( rpcSlice->getSPS()->getVertPhasePositionEnableFlag(refLayerIdc) ) |
---|
| 2951 | { |
---|
| 2952 | READ_FLAG( uiCode, "vert_phase_position_flag" ); rpcSlice->setVertPhasePositionFlag( uiCode? true : false, refLayerIdc ); |
---|
| 2953 | } |
---|
| 2954 | } |
---|
| 2955 | #endif |
---|
[815] | 2956 | #endif //SVC_EXTENSION |
---|
[313] | 2957 | |
---|
| 2958 | if(sps->getUseSAO()) |
---|
| 2959 | { |
---|
| 2960 | READ_FLAG(uiCode, "slice_sao_luma_flag"); rpcSlice->setSaoEnabledFlag((Bool)uiCode); |
---|
[494] | 2961 | #if AUXILIARY_PICTURES |
---|
| 2962 | ChromaFormat format; |
---|
| 2963 | #if REPN_FORMAT_IN_VPS |
---|
[540] | 2964 | #if O0096_REP_FORMAT_INDEX |
---|
| 2965 | if( sps->getLayerId() == 0 ) |
---|
| 2966 | { |
---|
| 2967 | format = sps->getChromaFormatIdc(); |
---|
| 2968 | } |
---|
| 2969 | else |
---|
| 2970 | { |
---|
| 2971 | format = rpcSlice->getVPS()->getVpsRepFormat( sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : rpcSlice->getVPS()->getVpsRepFormatIdx(sps->getLayerId()) )->getChromaFormatVpsIdc(); |
---|
[713] | 2972 | #if Q0195_REP_FORMAT_CLEANUP |
---|
| 2973 | assert( (sps->getUpdateRepFormatFlag()==false && rpcSlice->getVPS()->getVpsNumRepFormats()==1) || rpcSlice->getVPS()->getVpsNumRepFormats() > 1 ); //conformance check |
---|
| 2974 | #endif |
---|
[540] | 2975 | } |
---|
| 2976 | #else |
---|
[494] | 2977 | if( ( sps->getLayerId() == 0 ) || sps->getUpdateRepFormatFlag() ) |
---|
| 2978 | { |
---|
| 2979 | format = sps->getChromaFormatIdc(); |
---|
| 2980 | } |
---|
| 2981 | else |
---|
| 2982 | { |
---|
| 2983 | format = rpcSlice->getVPS()->getVpsRepFormat( rpcSlice->getVPS()->getVpsRepFormatIdx(sps->getLayerId()) )->getChromaFormatVpsIdc(); |
---|
| 2984 | } |
---|
[540] | 2985 | #endif |
---|
[494] | 2986 | #else |
---|
| 2987 | format = sps->getChromaFormatIdc(); |
---|
| 2988 | #endif |
---|
| 2989 | if (format != CHROMA_400) |
---|
| 2990 | { |
---|
| 2991 | #endif |
---|
[313] | 2992 | READ_FLAG(uiCode, "slice_sao_chroma_flag"); rpcSlice->setSaoEnabledFlagChroma((Bool)uiCode); |
---|
[494] | 2993 | #if AUXILIARY_PICTURES |
---|
| 2994 | } |
---|
| 2995 | else |
---|
| 2996 | { |
---|
| 2997 | rpcSlice->setSaoEnabledFlagChroma(false); |
---|
| 2998 | } |
---|
| 2999 | #endif |
---|
[313] | 3000 | } |
---|
| 3001 | |
---|
| 3002 | if (rpcSlice->getIdrPicFlag()) |
---|
| 3003 | { |
---|
| 3004 | rpcSlice->setEnableTMVPFlag(false); |
---|
| 3005 | } |
---|
| 3006 | if (!rpcSlice->isIntra()) |
---|
| 3007 | { |
---|
| 3008 | |
---|
| 3009 | READ_FLAG( uiCode, "num_ref_idx_active_override_flag"); |
---|
| 3010 | if (uiCode) |
---|
| 3011 | { |
---|
| 3012 | READ_UVLC (uiCode, "num_ref_idx_l0_active_minus1" ); rpcSlice->setNumRefIdx( REF_PIC_LIST_0, uiCode + 1 ); |
---|
| 3013 | if (rpcSlice->isInterB()) |
---|
| 3014 | { |
---|
| 3015 | READ_UVLC (uiCode, "num_ref_idx_l1_active_minus1" ); rpcSlice->setNumRefIdx( REF_PIC_LIST_1, uiCode + 1 ); |
---|
| 3016 | } |
---|
| 3017 | else |
---|
| 3018 | { |
---|
| 3019 | rpcSlice->setNumRefIdx(REF_PIC_LIST_1, 0); |
---|
| 3020 | } |
---|
| 3021 | } |
---|
| 3022 | else |
---|
| 3023 | { |
---|
| 3024 | rpcSlice->setNumRefIdx(REF_PIC_LIST_0, rpcSlice->getPPS()->getNumRefIdxL0DefaultActive()); |
---|
| 3025 | if (rpcSlice->isInterB()) |
---|
| 3026 | { |
---|
| 3027 | rpcSlice->setNumRefIdx(REF_PIC_LIST_1, rpcSlice->getPPS()->getNumRefIdxL1DefaultActive()); |
---|
| 3028 | } |
---|
| 3029 | else |
---|
| 3030 | { |
---|
| 3031 | rpcSlice->setNumRefIdx(REF_PIC_LIST_1,0); |
---|
| 3032 | } |
---|
| 3033 | } |
---|
| 3034 | } |
---|
| 3035 | // } |
---|
| 3036 | TComRefPicListModification* refPicListModification = rpcSlice->getRefPicListModification(); |
---|
| 3037 | if(!rpcSlice->isIntra()) |
---|
| 3038 | { |
---|
| 3039 | if( !rpcSlice->getPPS()->getListsModificationPresentFlag() || rpcSlice->getNumRpsCurrTempList() <= 1 ) |
---|
| 3040 | { |
---|
| 3041 | refPicListModification->setRefPicListModificationFlagL0( 0 ); |
---|
| 3042 | } |
---|
| 3043 | else |
---|
| 3044 | { |
---|
| 3045 | READ_FLAG( uiCode, "ref_pic_list_modification_flag_l0" ); refPicListModification->setRefPicListModificationFlagL0( uiCode ? 1 : 0 ); |
---|
| 3046 | } |
---|
| 3047 | |
---|
| 3048 | if(refPicListModification->getRefPicListModificationFlagL0()) |
---|
| 3049 | { |
---|
| 3050 | uiCode = 0; |
---|
| 3051 | Int i = 0; |
---|
| 3052 | Int numRpsCurrTempList0 = rpcSlice->getNumRpsCurrTempList(); |
---|
| 3053 | if ( numRpsCurrTempList0 > 1 ) |
---|
| 3054 | { |
---|
| 3055 | Int length = 1; |
---|
| 3056 | numRpsCurrTempList0 --; |
---|
| 3057 | while ( numRpsCurrTempList0 >>= 1) |
---|
| 3058 | { |
---|
| 3059 | length ++; |
---|
| 3060 | } |
---|
| 3061 | for (i = 0; i < rpcSlice->getNumRefIdx(REF_PIC_LIST_0); i ++) |
---|
| 3062 | { |
---|
| 3063 | READ_CODE( length, uiCode, "list_entry_l0" ); |
---|
| 3064 | refPicListModification->setRefPicSetIdxL0(i, uiCode ); |
---|
| 3065 | } |
---|
| 3066 | } |
---|
| 3067 | else |
---|
| 3068 | { |
---|
| 3069 | for (i = 0; i < rpcSlice->getNumRefIdx(REF_PIC_LIST_0); i ++) |
---|
| 3070 | { |
---|
| 3071 | refPicListModification->setRefPicSetIdxL0(i, 0 ); |
---|
| 3072 | } |
---|
| 3073 | } |
---|
| 3074 | } |
---|
| 3075 | } |
---|
| 3076 | else |
---|
| 3077 | { |
---|
| 3078 | refPicListModification->setRefPicListModificationFlagL0(0); |
---|
| 3079 | } |
---|
| 3080 | if(rpcSlice->isInterB()) |
---|
| 3081 | { |
---|
| 3082 | if( !rpcSlice->getPPS()->getListsModificationPresentFlag() || rpcSlice->getNumRpsCurrTempList() <= 1 ) |
---|
| 3083 | { |
---|
| 3084 | refPicListModification->setRefPicListModificationFlagL1( 0 ); |
---|
| 3085 | } |
---|
| 3086 | else |
---|
| 3087 | { |
---|
| 3088 | READ_FLAG( uiCode, "ref_pic_list_modification_flag_l1" ); refPicListModification->setRefPicListModificationFlagL1( uiCode ? 1 : 0 ); |
---|
| 3089 | } |
---|
| 3090 | if(refPicListModification->getRefPicListModificationFlagL1()) |
---|
| 3091 | { |
---|
| 3092 | uiCode = 0; |
---|
| 3093 | Int i = 0; |
---|
| 3094 | Int numRpsCurrTempList1 = rpcSlice->getNumRpsCurrTempList(); |
---|
| 3095 | if ( numRpsCurrTempList1 > 1 ) |
---|
| 3096 | { |
---|
| 3097 | Int length = 1; |
---|
| 3098 | numRpsCurrTempList1 --; |
---|
| 3099 | while ( numRpsCurrTempList1 >>= 1) |
---|
| 3100 | { |
---|
| 3101 | length ++; |
---|
| 3102 | } |
---|
| 3103 | for (i = 0; i < rpcSlice->getNumRefIdx(REF_PIC_LIST_1); i ++) |
---|
| 3104 | { |
---|
| 3105 | READ_CODE( length, uiCode, "list_entry_l1" ); |
---|
| 3106 | refPicListModification->setRefPicSetIdxL1(i, uiCode ); |
---|
| 3107 | } |
---|
| 3108 | } |
---|
| 3109 | else |
---|
| 3110 | { |
---|
| 3111 | for (i = 0; i < rpcSlice->getNumRefIdx(REF_PIC_LIST_1); i ++) |
---|
| 3112 | { |
---|
| 3113 | refPicListModification->setRefPicSetIdxL1(i, 0 ); |
---|
| 3114 | } |
---|
| 3115 | } |
---|
| 3116 | } |
---|
| 3117 | } |
---|
| 3118 | else |
---|
| 3119 | { |
---|
| 3120 | refPicListModification->setRefPicListModificationFlagL1(0); |
---|
| 3121 | } |
---|
| 3122 | if (rpcSlice->isInterB()) |
---|
| 3123 | { |
---|
| 3124 | READ_FLAG( uiCode, "mvd_l1_zero_flag" ); rpcSlice->setMvdL1ZeroFlag( (uiCode ? true : false) ); |
---|
| 3125 | } |
---|
| 3126 | |
---|
| 3127 | rpcSlice->setCabacInitFlag( false ); // default |
---|
| 3128 | if(pps->getCabacInitPresentFlag() && !rpcSlice->isIntra()) |
---|
| 3129 | { |
---|
| 3130 | READ_FLAG(uiCode, "cabac_init_flag"); |
---|
| 3131 | rpcSlice->setCabacInitFlag( uiCode ? true : false ); |
---|
| 3132 | } |
---|
| 3133 | |
---|
| 3134 | if ( rpcSlice->getEnableTMVPFlag() ) |
---|
| 3135 | { |
---|
[588] | 3136 | #if SVC_EXTENSION && REF_IDX_MFM |
---|
| 3137 | // set motion mapping flag |
---|
[815] | 3138 | rpcSlice->setMFMEnabledFlag( ( rpcSlice->getNumMotionPredRefLayers() > 0 && rpcSlice->getActiveNumILRRefIdx() && !rpcSlice->isIntra() ) ? true : false ); |
---|
[313] | 3139 | #endif |
---|
| 3140 | if ( rpcSlice->getSliceType() == B_SLICE ) |
---|
| 3141 | { |
---|
| 3142 | READ_FLAG( uiCode, "collocated_from_l0_flag" ); |
---|
| 3143 | rpcSlice->setColFromL0Flag(uiCode); |
---|
| 3144 | } |
---|
| 3145 | else |
---|
| 3146 | { |
---|
| 3147 | rpcSlice->setColFromL0Flag( 1 ); |
---|
| 3148 | } |
---|
| 3149 | |
---|
| 3150 | if ( rpcSlice->getSliceType() != I_SLICE && |
---|
| 3151 | ((rpcSlice->getColFromL0Flag() == 1 && rpcSlice->getNumRefIdx(REF_PIC_LIST_0) > 1)|| |
---|
| 3152 | (rpcSlice->getColFromL0Flag() == 0 && rpcSlice->getNumRefIdx(REF_PIC_LIST_1) > 1))) |
---|
| 3153 | { |
---|
| 3154 | READ_UVLC( uiCode, "collocated_ref_idx" ); |
---|
| 3155 | rpcSlice->setColRefIdx(uiCode); |
---|
| 3156 | } |
---|
| 3157 | else |
---|
| 3158 | { |
---|
| 3159 | rpcSlice->setColRefIdx(0); |
---|
| 3160 | } |
---|
| 3161 | } |
---|
| 3162 | if ( (pps->getUseWP() && rpcSlice->getSliceType()==P_SLICE) || (pps->getWPBiPred() && rpcSlice->getSliceType()==B_SLICE) ) |
---|
| 3163 | { |
---|
| 3164 | xParsePredWeightTable(rpcSlice); |
---|
| 3165 | rpcSlice->initWpScaling(); |
---|
| 3166 | } |
---|
| 3167 | if (!rpcSlice->isIntra()) |
---|
| 3168 | { |
---|
| 3169 | READ_UVLC( uiCode, "five_minus_max_num_merge_cand"); |
---|
| 3170 | rpcSlice->setMaxNumMergeCand(MRG_MAX_NUM_CANDS - uiCode); |
---|
| 3171 | } |
---|
| 3172 | |
---|
| 3173 | READ_SVLC( iCode, "slice_qp_delta" ); |
---|
| 3174 | rpcSlice->setSliceQp (26 + pps->getPicInitQPMinus26() + iCode); |
---|
| 3175 | |
---|
[442] | 3176 | #if REPN_FORMAT_IN_VPS |
---|
[494] | 3177 | #if O0194_DIFFERENT_BITDEPTH_EL_BL |
---|
| 3178 | g_bitDepthYLayer[rpcSlice->getLayerId()] = rpcSlice->getBitDepthY(); |
---|
| 3179 | g_bitDepthCLayer[rpcSlice->getLayerId()] = rpcSlice->getBitDepthC(); |
---|
| 3180 | #endif |
---|
[442] | 3181 | assert( rpcSlice->getSliceQp() >= -rpcSlice->getQpBDOffsetY() ); |
---|
| 3182 | #else |
---|
[313] | 3183 | assert( rpcSlice->getSliceQp() >= -sps->getQpBDOffsetY() ); |
---|
[442] | 3184 | #endif |
---|
[313] | 3185 | assert( rpcSlice->getSliceQp() <= 51 ); |
---|
| 3186 | |
---|
| 3187 | if (rpcSlice->getPPS()->getSliceChromaQpFlag()) |
---|
| 3188 | { |
---|
| 3189 | READ_SVLC( iCode, "slice_qp_delta_cb" ); |
---|
| 3190 | rpcSlice->setSliceQpDeltaCb( iCode ); |
---|
| 3191 | assert( rpcSlice->getSliceQpDeltaCb() >= -12 ); |
---|
| 3192 | assert( rpcSlice->getSliceQpDeltaCb() <= 12 ); |
---|
| 3193 | assert( (rpcSlice->getPPS()->getChromaCbQpOffset() + rpcSlice->getSliceQpDeltaCb()) >= -12 ); |
---|
| 3194 | assert( (rpcSlice->getPPS()->getChromaCbQpOffset() + rpcSlice->getSliceQpDeltaCb()) <= 12 ); |
---|
| 3195 | |
---|
| 3196 | READ_SVLC( iCode, "slice_qp_delta_cr" ); |
---|
| 3197 | rpcSlice->setSliceQpDeltaCr( iCode ); |
---|
| 3198 | assert( rpcSlice->getSliceQpDeltaCr() >= -12 ); |
---|
| 3199 | assert( rpcSlice->getSliceQpDeltaCr() <= 12 ); |
---|
| 3200 | assert( (rpcSlice->getPPS()->getChromaCrQpOffset() + rpcSlice->getSliceQpDeltaCr()) >= -12 ); |
---|
| 3201 | assert( (rpcSlice->getPPS()->getChromaCrQpOffset() + rpcSlice->getSliceQpDeltaCr()) <= 12 ); |
---|
| 3202 | } |
---|
| 3203 | |
---|
| 3204 | if (rpcSlice->getPPS()->getDeblockingFilterControlPresentFlag()) |
---|
| 3205 | { |
---|
| 3206 | if(rpcSlice->getPPS()->getDeblockingFilterOverrideEnabledFlag()) |
---|
| 3207 | { |
---|
| 3208 | READ_FLAG ( uiCode, "deblocking_filter_override_flag" ); rpcSlice->setDeblockingFilterOverrideFlag(uiCode ? true : false); |
---|
| 3209 | } |
---|
| 3210 | else |
---|
| 3211 | { |
---|
| 3212 | rpcSlice->setDeblockingFilterOverrideFlag(0); |
---|
| 3213 | } |
---|
| 3214 | if(rpcSlice->getDeblockingFilterOverrideFlag()) |
---|
| 3215 | { |
---|
| 3216 | READ_FLAG ( uiCode, "slice_disable_deblocking_filter_flag" ); rpcSlice->setDeblockingFilterDisable(uiCode ? 1 : 0); |
---|
| 3217 | if(!rpcSlice->getDeblockingFilterDisable()) |
---|
| 3218 | { |
---|
| 3219 | READ_SVLC( iCode, "slice_beta_offset_div2" ); rpcSlice->setDeblockingFilterBetaOffsetDiv2(iCode); |
---|
| 3220 | assert(rpcSlice->getDeblockingFilterBetaOffsetDiv2() >= -6 && |
---|
| 3221 | rpcSlice->getDeblockingFilterBetaOffsetDiv2() <= 6); |
---|
| 3222 | READ_SVLC( iCode, "slice_tc_offset_div2" ); rpcSlice->setDeblockingFilterTcOffsetDiv2(iCode); |
---|
| 3223 | assert(rpcSlice->getDeblockingFilterTcOffsetDiv2() >= -6 && |
---|
| 3224 | rpcSlice->getDeblockingFilterTcOffsetDiv2() <= 6); |
---|
| 3225 | } |
---|
| 3226 | } |
---|
| 3227 | else |
---|
| 3228 | { |
---|
| 3229 | rpcSlice->setDeblockingFilterDisable ( rpcSlice->getPPS()->getPicDisableDeblockingFilterFlag() ); |
---|
| 3230 | rpcSlice->setDeblockingFilterBetaOffsetDiv2( rpcSlice->getPPS()->getDeblockingFilterBetaOffsetDiv2() ); |
---|
| 3231 | rpcSlice->setDeblockingFilterTcOffsetDiv2 ( rpcSlice->getPPS()->getDeblockingFilterTcOffsetDiv2() ); |
---|
| 3232 | } |
---|
| 3233 | } |
---|
| 3234 | else |
---|
| 3235 | { |
---|
| 3236 | rpcSlice->setDeblockingFilterDisable ( false ); |
---|
| 3237 | rpcSlice->setDeblockingFilterBetaOffsetDiv2( 0 ); |
---|
| 3238 | rpcSlice->setDeblockingFilterTcOffsetDiv2 ( 0 ); |
---|
| 3239 | } |
---|
| 3240 | |
---|
| 3241 | Bool isSAOEnabled = (!rpcSlice->getSPS()->getUseSAO())?(false):(rpcSlice->getSaoEnabledFlag()||rpcSlice->getSaoEnabledFlagChroma()); |
---|
| 3242 | Bool isDBFEnabled = (!rpcSlice->getDeblockingFilterDisable()); |
---|
| 3243 | |
---|
| 3244 | if(rpcSlice->getPPS()->getLoopFilterAcrossSlicesEnabledFlag() && ( isSAOEnabled || isDBFEnabled )) |
---|
| 3245 | { |
---|
| 3246 | READ_FLAG( uiCode, "slice_loop_filter_across_slices_enabled_flag"); |
---|
| 3247 | } |
---|
| 3248 | else |
---|
| 3249 | { |
---|
| 3250 | uiCode = rpcSlice->getPPS()->getLoopFilterAcrossSlicesEnabledFlag()?1:0; |
---|
| 3251 | } |
---|
| 3252 | rpcSlice->setLFCrossSliceBoundaryFlag( (uiCode==1)?true:false); |
---|
| 3253 | |
---|
| 3254 | } |
---|
| 3255 | |
---|
| 3256 | UInt *entryPointOffset = NULL; |
---|
| 3257 | UInt numEntryPointOffsets, offsetLenMinus1; |
---|
| 3258 | if( pps->getTilesEnabledFlag() || pps->getEntropyCodingSyncEnabledFlag() ) |
---|
| 3259 | { |
---|
| 3260 | READ_UVLC(numEntryPointOffsets, "num_entry_point_offsets"); rpcSlice->setNumEntryPointOffsets ( numEntryPointOffsets ); |
---|
| 3261 | if (numEntryPointOffsets>0) |
---|
| 3262 | { |
---|
| 3263 | READ_UVLC(offsetLenMinus1, "offset_len_minus1"); |
---|
| 3264 | } |
---|
| 3265 | entryPointOffset = new UInt[numEntryPointOffsets]; |
---|
| 3266 | for (UInt idx=0; idx<numEntryPointOffsets; idx++) |
---|
| 3267 | { |
---|
| 3268 | READ_CODE(offsetLenMinus1+1, uiCode, "entry_point_offset_minus1"); |
---|
| 3269 | entryPointOffset[ idx ] = uiCode + 1; |
---|
| 3270 | } |
---|
| 3271 | } |
---|
| 3272 | else |
---|
| 3273 | { |
---|
| 3274 | rpcSlice->setNumEntryPointOffsets ( 0 ); |
---|
| 3275 | } |
---|
| 3276 | |
---|
[644] | 3277 | #if POC_RESET_IDC_SIGNALLING |
---|
[815] | 3278 | Int sliceHeaderExtensionLength = 0; |
---|
[313] | 3279 | if(pps->getSliceHeaderExtensionPresentFlag()) |
---|
| 3280 | { |
---|
[815] | 3281 | READ_UVLC( uiCode, "slice_header_extension_length"); sliceHeaderExtensionLength = uiCode; |
---|
[644] | 3282 | } |
---|
| 3283 | else |
---|
| 3284 | { |
---|
[815] | 3285 | sliceHeaderExtensionLength = 0; |
---|
[644] | 3286 | } |
---|
| 3287 | UInt startBits = m_pcBitstream->getNumBitsRead(); // Start counter of # SH Extn bits |
---|
[815] | 3288 | if( sliceHeaderExtensionLength > 0 ) |
---|
[644] | 3289 | { |
---|
| 3290 | if( rpcSlice->getPPS()->getPocResetInfoPresentFlag() ) |
---|
| 3291 | { |
---|
| 3292 | READ_CODE( 2, uiCode, "poc_reset_idc"); rpcSlice->setPocResetIdc(uiCode); |
---|
| 3293 | } |
---|
| 3294 | else |
---|
| 3295 | { |
---|
| 3296 | rpcSlice->setPocResetIdc( 0 ); |
---|
| 3297 | } |
---|
[815] | 3298 | #if Q0142_POC_LSB_NOT_PRESENT |
---|
| 3299 | if ( rpcSlice->getVPS()->getPocLsbNotPresentFlag(rpcSlice->getLayerId()) && iPOClsb > 0 ) |
---|
| 3300 | { |
---|
| 3301 | assert( rpcSlice->getPocResetIdc() != 2 ); |
---|
| 3302 | } |
---|
| 3303 | #endif |
---|
[644] | 3304 | if( rpcSlice->getPocResetIdc() > 0 ) |
---|
| 3305 | { |
---|
| 3306 | READ_CODE(6, uiCode, "poc_reset_period_id"); rpcSlice->setPocResetPeriodId(uiCode); |
---|
| 3307 | } |
---|
| 3308 | else |
---|
| 3309 | { |
---|
| 3310 | |
---|
| 3311 | rpcSlice->setPocResetPeriodId( 0 ); |
---|
| 3312 | } |
---|
| 3313 | |
---|
| 3314 | if (rpcSlice->getPocResetIdc() == 3) |
---|
| 3315 | { |
---|
| 3316 | READ_FLAG( uiCode, "full_poc_reset_flag"); rpcSlice->setFullPocResetFlag((uiCode == 1) ? true : false); |
---|
| 3317 | READ_CODE(rpcSlice->getSPS()->getBitsForPOC(), uiCode,"poc_lsb_val"); rpcSlice->setPocLsbVal(uiCode); |
---|
[815] | 3318 | #if Q0142_POC_LSB_NOT_PRESENT |
---|
| 3319 | if ( rpcSlice->getVPS()->getPocLsbNotPresentFlag(rpcSlice->getLayerId()) && rpcSlice->getFullPocResetFlag() ) |
---|
| 3320 | { |
---|
| 3321 | assert( rpcSlice->getPocLsbVal() == 0 ); |
---|
| 3322 | } |
---|
| 3323 | #endif |
---|
[644] | 3324 | } |
---|
| 3325 | |
---|
| 3326 | // Derive the value of PocMsbValRequiredFlag |
---|
| 3327 | rpcSlice->setPocMsbValRequiredFlag( rpcSlice->getCraPicFlag() || rpcSlice->getBlaPicFlag() |
---|
| 3328 | /* || related to vps_poc_lsb_aligned_flag */ |
---|
| 3329 | ); |
---|
| 3330 | |
---|
| 3331 | if( !rpcSlice->getPocMsbValRequiredFlag() /* vps_poc_lsb_aligned_flag */ ) |
---|
| 3332 | { |
---|
| 3333 | READ_FLAG( uiCode, "poc_msb_val_present_flag"); rpcSlice->setPocMsbValPresentFlag( uiCode ? true : false ); |
---|
| 3334 | } |
---|
| 3335 | else |
---|
| 3336 | { |
---|
[815] | 3337 | #if POC_MSB_VAL_PRESENT_FLAG_SEM |
---|
| 3338 | if( sliceHeaderExtensionLength == 0 ) |
---|
| 3339 | { |
---|
| 3340 | rpcSlice->setPocMsbValPresentFlag( false ); |
---|
| 3341 | } |
---|
| 3342 | else if( rpcSlice->getPocMsbValRequiredFlag() ) |
---|
| 3343 | #else |
---|
[644] | 3344 | if( rpcSlice->getPocMsbValRequiredFlag() ) |
---|
[815] | 3345 | #endif |
---|
[644] | 3346 | { |
---|
| 3347 | rpcSlice->setPocMsbValPresentFlag( true ); |
---|
| 3348 | } |
---|
| 3349 | else |
---|
| 3350 | { |
---|
| 3351 | rpcSlice->setPocMsbValPresentFlag( false ); |
---|
| 3352 | } |
---|
| 3353 | } |
---|
| 3354 | |
---|
[815] | 3355 | #if !POC_RESET_IDC_DECODER |
---|
[644] | 3356 | Int maxPocLsb = 1 << rpcSlice->getSPS()->getBitsForPOC(); |
---|
[815] | 3357 | #endif |
---|
[644] | 3358 | if( rpcSlice->getPocMsbValPresentFlag() ) |
---|
| 3359 | { |
---|
| 3360 | READ_UVLC( uiCode, "poc_msb_val"); rpcSlice->setPocMsbVal( uiCode ); |
---|
[815] | 3361 | |
---|
| 3362 | #if !POC_RESET_IDC_DECODER |
---|
[644] | 3363 | // Update POC of the slice based on this MSB val |
---|
| 3364 | Int pocLsb = rpcSlice->getPOC() % maxPocLsb; |
---|
| 3365 | rpcSlice->setPOC((rpcSlice->getPocMsbVal() * maxPocLsb) + pocLsb); |
---|
| 3366 | } |
---|
| 3367 | else |
---|
| 3368 | { |
---|
| 3369 | rpcSlice->setPocMsbVal( rpcSlice->getPOC() / maxPocLsb ); |
---|
[815] | 3370 | #endif |
---|
[644] | 3371 | } |
---|
| 3372 | |
---|
| 3373 | // Read remaining bits in the slice header extension. |
---|
| 3374 | UInt endBits = m_pcBitstream->getNumBitsRead(); |
---|
| 3375 | Int counter = (endBits - startBits) % 8; |
---|
| 3376 | if( counter ) |
---|
| 3377 | { |
---|
| 3378 | counter = 8 - counter; |
---|
| 3379 | } |
---|
| 3380 | |
---|
| 3381 | while( counter ) |
---|
| 3382 | { |
---|
[815] | 3383 | #if Q0146_SSH_EXT_DATA_BIT |
---|
| 3384 | READ_FLAG( uiCode, "slice_segment_header_extension_data_bit" ); |
---|
| 3385 | #else |
---|
[644] | 3386 | READ_FLAG( uiCode, "slice_segment_header_extension_reserved_bit" ); assert( uiCode == 1 ); |
---|
[815] | 3387 | #endif |
---|
[644] | 3388 | counter--; |
---|
| 3389 | } |
---|
| 3390 | } |
---|
| 3391 | #else |
---|
| 3392 | if(pps->getSliceHeaderExtensionPresentFlag()) |
---|
| 3393 | { |
---|
[313] | 3394 | READ_UVLC(uiCode,"slice_header_extension_length"); |
---|
| 3395 | for(Int i=0; i<uiCode; i++) |
---|
| 3396 | { |
---|
| 3397 | UInt ignore; |
---|
| 3398 | READ_CODE(8,ignore,"slice_header_extension_data_byte"); |
---|
| 3399 | } |
---|
| 3400 | } |
---|
[644] | 3401 | #endif |
---|
[313] | 3402 | m_pcBitstream->readByteAlignment(); |
---|
| 3403 | |
---|
| 3404 | if( pps->getTilesEnabledFlag() || pps->getEntropyCodingSyncEnabledFlag() ) |
---|
| 3405 | { |
---|
| 3406 | Int endOfSliceHeaderLocation = m_pcBitstream->getByteLocation(); |
---|
[494] | 3407 | |
---|
[313] | 3408 | // Adjust endOfSliceHeaderLocation to account for emulation prevention bytes in the slice segment header |
---|
| 3409 | for ( UInt curByteIdx = 0; curByteIdx<m_pcBitstream->numEmulationPreventionBytesRead(); curByteIdx++ ) |
---|
| 3410 | { |
---|
| 3411 | if ( m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) < endOfSliceHeaderLocation ) |
---|
| 3412 | { |
---|
| 3413 | endOfSliceHeaderLocation++; |
---|
| 3414 | } |
---|
| 3415 | } |
---|
| 3416 | |
---|
| 3417 | Int curEntryPointOffset = 0; |
---|
| 3418 | Int prevEntryPointOffset = 0; |
---|
| 3419 | for (UInt idx=0; idx<numEntryPointOffsets; idx++) |
---|
| 3420 | { |
---|
| 3421 | curEntryPointOffset += entryPointOffset[ idx ]; |
---|
| 3422 | |
---|
| 3423 | Int emulationPreventionByteCount = 0; |
---|
| 3424 | for ( UInt curByteIdx = 0; curByteIdx<m_pcBitstream->numEmulationPreventionBytesRead(); curByteIdx++ ) |
---|
| 3425 | { |
---|
| 3426 | if ( m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) >= ( prevEntryPointOffset + endOfSliceHeaderLocation ) && |
---|
| 3427 | m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) < ( curEntryPointOffset + endOfSliceHeaderLocation ) ) |
---|
| 3428 | { |
---|
| 3429 | emulationPreventionByteCount++; |
---|
| 3430 | } |
---|
| 3431 | } |
---|
| 3432 | |
---|
| 3433 | entryPointOffset[ idx ] -= emulationPreventionByteCount; |
---|
| 3434 | prevEntryPointOffset = curEntryPointOffset; |
---|
| 3435 | } |
---|
| 3436 | |
---|
| 3437 | if ( pps->getTilesEnabledFlag() ) |
---|
| 3438 | { |
---|
| 3439 | rpcSlice->setTileLocationCount( numEntryPointOffsets ); |
---|
| 3440 | |
---|
| 3441 | UInt prevPos = 0; |
---|
| 3442 | for (Int idx=0; idx<rpcSlice->getTileLocationCount(); idx++) |
---|
| 3443 | { |
---|
| 3444 | rpcSlice->setTileLocation( idx, prevPos + entryPointOffset [ idx ] ); |
---|
| 3445 | prevPos += entryPointOffset[ idx ]; |
---|
| 3446 | } |
---|
| 3447 | } |
---|
| 3448 | else if ( pps->getEntropyCodingSyncEnabledFlag() ) |
---|
| 3449 | { |
---|
| 3450 | Int numSubstreams = rpcSlice->getNumEntryPointOffsets()+1; |
---|
| 3451 | rpcSlice->allocSubstreamSizes(numSubstreams); |
---|
| 3452 | UInt *pSubstreamSizes = rpcSlice->getSubstreamSizes(); |
---|
| 3453 | for (Int idx=0; idx<numSubstreams-1; idx++) |
---|
| 3454 | { |
---|
| 3455 | if ( idx < numEntryPointOffsets ) |
---|
| 3456 | { |
---|
| 3457 | pSubstreamSizes[ idx ] = ( entryPointOffset[ idx ] << 3 ) ; |
---|
| 3458 | } |
---|
| 3459 | else |
---|
| 3460 | { |
---|
| 3461 | pSubstreamSizes[ idx ] = 0; |
---|
| 3462 | } |
---|
| 3463 | } |
---|
| 3464 | } |
---|
| 3465 | |
---|
| 3466 | if (entryPointOffset) |
---|
| 3467 | { |
---|
| 3468 | delete [] entryPointOffset; |
---|
| 3469 | } |
---|
| 3470 | } |
---|
| 3471 | |
---|
| 3472 | return; |
---|
| 3473 | } |
---|
| 3474 | |
---|
| 3475 | Void TDecCavlc::parsePTL( TComPTL *rpcPTL, Bool profilePresentFlag, Int maxNumSubLayersMinus1 ) |
---|
| 3476 | { |
---|
| 3477 | UInt uiCode; |
---|
| 3478 | if(profilePresentFlag) |
---|
| 3479 | { |
---|
| 3480 | parseProfileTier(rpcPTL->getGeneralPTL()); |
---|
| 3481 | } |
---|
| 3482 | READ_CODE( 8, uiCode, "general_level_idc" ); rpcPTL->getGeneralPTL()->setLevelIdc(uiCode); |
---|
| 3483 | |
---|
| 3484 | for (Int i = 0; i < maxNumSubLayersMinus1; i++) |
---|
| 3485 | { |
---|
| 3486 | if(profilePresentFlag) |
---|
| 3487 | { |
---|
| 3488 | READ_FLAG( uiCode, "sub_layer_profile_present_flag[i]" ); rpcPTL->setSubLayerProfilePresentFlag(i, uiCode); |
---|
| 3489 | } |
---|
| 3490 | READ_FLAG( uiCode, "sub_layer_level_present_flag[i]" ); rpcPTL->setSubLayerLevelPresentFlag (i, uiCode); |
---|
| 3491 | } |
---|
| 3492 | |
---|
| 3493 | if (maxNumSubLayersMinus1 > 0) |
---|
| 3494 | { |
---|
| 3495 | for (Int i = maxNumSubLayersMinus1; i < 8; i++) |
---|
| 3496 | { |
---|
| 3497 | READ_CODE(2, uiCode, "reserved_zero_2bits"); |
---|
| 3498 | assert(uiCode == 0); |
---|
| 3499 | } |
---|
| 3500 | } |
---|
| 3501 | |
---|
| 3502 | for(Int i = 0; i < maxNumSubLayersMinus1; i++) |
---|
| 3503 | { |
---|
| 3504 | if( profilePresentFlag && rpcPTL->getSubLayerProfilePresentFlag(i) ) |
---|
| 3505 | { |
---|
| 3506 | parseProfileTier(rpcPTL->getSubLayerPTL(i)); |
---|
| 3507 | } |
---|
| 3508 | if(rpcPTL->getSubLayerLevelPresentFlag(i)) |
---|
| 3509 | { |
---|
| 3510 | READ_CODE( 8, uiCode, "sub_layer_level_idc[i]" ); rpcPTL->getSubLayerPTL(i)->setLevelIdc(uiCode); |
---|
| 3511 | } |
---|
| 3512 | } |
---|
| 3513 | } |
---|
| 3514 | |
---|
| 3515 | Void TDecCavlc::parseProfileTier(ProfileTierLevel *ptl) |
---|
| 3516 | { |
---|
| 3517 | UInt uiCode; |
---|
| 3518 | READ_CODE(2 , uiCode, "XXX_profile_space[]"); ptl->setProfileSpace(uiCode); |
---|
| 3519 | READ_FLAG( uiCode, "XXX_tier_flag[]" ); ptl->setTierFlag (uiCode ? 1 : 0); |
---|
| 3520 | READ_CODE(5 , uiCode, "XXX_profile_idc[]" ); ptl->setProfileIdc (uiCode); |
---|
| 3521 | for(Int j = 0; j < 32; j++) |
---|
| 3522 | { |
---|
| 3523 | READ_FLAG( uiCode, "XXX_profile_compatibility_flag[][j]"); ptl->setProfileCompatibilityFlag(j, uiCode ? 1 : 0); |
---|
| 3524 | } |
---|
| 3525 | READ_FLAG(uiCode, "general_progressive_source_flag"); |
---|
| 3526 | ptl->setProgressiveSourceFlag(uiCode ? true : false); |
---|
| 3527 | |
---|
| 3528 | READ_FLAG(uiCode, "general_interlaced_source_flag"); |
---|
| 3529 | ptl->setInterlacedSourceFlag(uiCode ? true : false); |
---|
| 3530 | |
---|
| 3531 | READ_FLAG(uiCode, "general_non_packed_constraint_flag"); |
---|
| 3532 | ptl->setNonPackedConstraintFlag(uiCode ? true : false); |
---|
| 3533 | |
---|
| 3534 | READ_FLAG(uiCode, "general_frame_only_constraint_flag"); |
---|
| 3535 | ptl->setFrameOnlyConstraintFlag(uiCode ? true : false); |
---|
| 3536 | |
---|
| 3537 | READ_CODE(16, uiCode, "XXX_reserved_zero_44bits[0..15]"); |
---|
| 3538 | READ_CODE(16, uiCode, "XXX_reserved_zero_44bits[16..31]"); |
---|
| 3539 | READ_CODE(12, uiCode, "XXX_reserved_zero_44bits[32..43]"); |
---|
| 3540 | } |
---|
| 3541 | |
---|
| 3542 | Void TDecCavlc::parseTerminatingBit( UInt& ruiBit ) |
---|
| 3543 | { |
---|
| 3544 | ruiBit = false; |
---|
| 3545 | Int iBitsLeft = m_pcBitstream->getNumBitsLeft(); |
---|
| 3546 | if(iBitsLeft <= 8) |
---|
| 3547 | { |
---|
| 3548 | UInt uiPeekValue = m_pcBitstream->peekBits(iBitsLeft); |
---|
| 3549 | if (uiPeekValue == (1<<(iBitsLeft-1))) |
---|
| 3550 | { |
---|
| 3551 | ruiBit = true; |
---|
| 3552 | } |
---|
| 3553 | } |
---|
| 3554 | } |
---|
| 3555 | |
---|
| 3556 | Void TDecCavlc::parseSkipFlag( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
| 3557 | { |
---|
| 3558 | assert(0); |
---|
| 3559 | } |
---|
| 3560 | |
---|
| 3561 | Void TDecCavlc::parseCUTransquantBypassFlag( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
| 3562 | { |
---|
| 3563 | assert(0); |
---|
| 3564 | } |
---|
| 3565 | |
---|
| 3566 | Void TDecCavlc::parseMVPIdx( Int& /*riMVPIdx*/ ) |
---|
| 3567 | { |
---|
| 3568 | assert(0); |
---|
| 3569 | } |
---|
| 3570 | |
---|
| 3571 | Void TDecCavlc::parseSplitFlag ( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
| 3572 | { |
---|
| 3573 | assert(0); |
---|
| 3574 | } |
---|
| 3575 | |
---|
| 3576 | Void TDecCavlc::parsePartSize( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
| 3577 | { |
---|
| 3578 | assert(0); |
---|
| 3579 | } |
---|
| 3580 | |
---|
| 3581 | Void TDecCavlc::parsePredMode( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
| 3582 | { |
---|
| 3583 | assert(0); |
---|
| 3584 | } |
---|
| 3585 | |
---|
| 3586 | /** Parse I_PCM information. |
---|
| 3587 | * \param pcCU pointer to CU |
---|
| 3588 | * \param uiAbsPartIdx CU index |
---|
| 3589 | * \param uiDepth CU depth |
---|
| 3590 | * \returns Void |
---|
| 3591 | * |
---|
| 3592 | * If I_PCM flag indicates that the CU is I_PCM, parse its PCM alignment bits and codes. |
---|
| 3593 | */ |
---|
| 3594 | Void TDecCavlc::parseIPCMInfo( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
| 3595 | { |
---|
| 3596 | assert(0); |
---|
| 3597 | } |
---|
| 3598 | |
---|
| 3599 | Void TDecCavlc::parseIntraDirLumaAng ( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
| 3600 | { |
---|
| 3601 | assert(0); |
---|
| 3602 | } |
---|
| 3603 | |
---|
| 3604 | Void TDecCavlc::parseIntraDirChroma( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
| 3605 | { |
---|
| 3606 | assert(0); |
---|
| 3607 | } |
---|
| 3608 | |
---|
| 3609 | Void TDecCavlc::parseInterDir( TComDataCU* /*pcCU*/, UInt& /*ruiInterDir*/, UInt /*uiAbsPartIdx*/ ) |
---|
| 3610 | { |
---|
| 3611 | assert(0); |
---|
| 3612 | } |
---|
| 3613 | |
---|
| 3614 | Void TDecCavlc::parseRefFrmIdx( TComDataCU* /*pcCU*/, Int& /*riRefFrmIdx*/, RefPicList /*eRefList*/ ) |
---|
| 3615 | { |
---|
| 3616 | assert(0); |
---|
| 3617 | } |
---|
| 3618 | |
---|
| 3619 | Void TDecCavlc::parseMvd( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiPartIdx*/, UInt /*uiDepth*/, RefPicList /*eRefList*/ ) |
---|
| 3620 | { |
---|
| 3621 | assert(0); |
---|
| 3622 | } |
---|
| 3623 | |
---|
| 3624 | Void TDecCavlc::parseDeltaQP( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 3625 | { |
---|
| 3626 | Int qp; |
---|
| 3627 | Int iDQp; |
---|
| 3628 | |
---|
| 3629 | xReadSvlc( iDQp ); |
---|
| 3630 | |
---|
[442] | 3631 | #if REPN_FORMAT_IN_VPS |
---|
| 3632 | Int qpBdOffsetY = pcCU->getSlice()->getQpBDOffsetY(); |
---|
| 3633 | #else |
---|
[313] | 3634 | Int qpBdOffsetY = pcCU->getSlice()->getSPS()->getQpBDOffsetY(); |
---|
[442] | 3635 | #endif |
---|
[313] | 3636 | qp = (((Int) pcCU->getRefQP( uiAbsPartIdx ) + iDQp + 52 + 2*qpBdOffsetY )%(52+ qpBdOffsetY)) - qpBdOffsetY; |
---|
| 3637 | |
---|
| 3638 | UInt uiAbsQpCUPartIdx = (uiAbsPartIdx>>((g_uiMaxCUDepth - pcCU->getSlice()->getPPS()->getMaxCuDQPDepth())<<1))<<((g_uiMaxCUDepth - pcCU->getSlice()->getPPS()->getMaxCuDQPDepth())<<1) ; |
---|
| 3639 | UInt uiQpCUDepth = min(uiDepth,pcCU->getSlice()->getPPS()->getMaxCuDQPDepth()) ; |
---|
| 3640 | |
---|
| 3641 | pcCU->setQPSubParts( qp, uiAbsQpCUPartIdx, uiQpCUDepth ); |
---|
| 3642 | } |
---|
| 3643 | |
---|
| 3644 | Void TDecCavlc::parseCoeffNxN( TComDataCU* /*pcCU*/, TCoeff* /*pcCoef*/, UInt /*uiAbsPartIdx*/, UInt /*uiWidth*/, UInt /*uiHeight*/, UInt /*uiDepth*/, TextType /*eTType*/ ) |
---|
| 3645 | { |
---|
| 3646 | assert(0); |
---|
| 3647 | } |
---|
| 3648 | |
---|
| 3649 | Void TDecCavlc::parseTransformSubdivFlag( UInt& /*ruiSubdivFlag*/, UInt /*uiLog2TransformBlockSize*/ ) |
---|
| 3650 | { |
---|
| 3651 | assert(0); |
---|
| 3652 | } |
---|
| 3653 | |
---|
| 3654 | Void TDecCavlc::parseQtCbf( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, TextType /*eType*/, UInt /*uiTrDepth*/, UInt /*uiDepth*/ ) |
---|
| 3655 | { |
---|
| 3656 | assert(0); |
---|
| 3657 | } |
---|
| 3658 | |
---|
| 3659 | Void TDecCavlc::parseQtRootCbf( UInt /*uiAbsPartIdx*/, UInt& /*uiQtRootCbf*/ ) |
---|
| 3660 | { |
---|
| 3661 | assert(0); |
---|
| 3662 | } |
---|
| 3663 | |
---|
| 3664 | Void TDecCavlc::parseTransformSkipFlags (TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*width*/, UInt /*height*/, UInt /*uiDepth*/, TextType /*eTType*/) |
---|
| 3665 | { |
---|
| 3666 | assert(0); |
---|
| 3667 | } |
---|
| 3668 | |
---|
| 3669 | Void TDecCavlc::parseMergeFlag ( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/, UInt /*uiPUIdx*/ ) |
---|
| 3670 | { |
---|
| 3671 | assert(0); |
---|
| 3672 | } |
---|
| 3673 | |
---|
| 3674 | Void TDecCavlc::parseMergeIndex ( TComDataCU* /*pcCU*/, UInt& /*ruiMergeIndex*/ ) |
---|
| 3675 | { |
---|
| 3676 | assert(0); |
---|
| 3677 | } |
---|
| 3678 | |
---|
| 3679 | // ==================================================================================================================== |
---|
| 3680 | // Protected member functions |
---|
| 3681 | // ==================================================================================================================== |
---|
| 3682 | |
---|
| 3683 | /** parse explicit wp tables |
---|
| 3684 | * \param TComSlice* pcSlice |
---|
| 3685 | * \returns Void |
---|
| 3686 | */ |
---|
| 3687 | Void TDecCavlc::xParsePredWeightTable( TComSlice* pcSlice ) |
---|
| 3688 | { |
---|
| 3689 | wpScalingParam *wp; |
---|
| 3690 | Bool bChroma = true; // color always present in HEVC ? |
---|
| 3691 | SliceType eSliceType = pcSlice->getSliceType(); |
---|
| 3692 | Int iNbRef = (eSliceType == B_SLICE ) ? (2) : (1); |
---|
[494] | 3693 | #if SVC_EXTENSION |
---|
| 3694 | UInt uiLog2WeightDenomLuma = 0, uiLog2WeightDenomChroma = 0; |
---|
| 3695 | #else |
---|
[313] | 3696 | UInt uiLog2WeightDenomLuma, uiLog2WeightDenomChroma; |
---|
[494] | 3697 | #endif |
---|
[313] | 3698 | UInt uiTotalSignalledWeightFlags = 0; |
---|
| 3699 | |
---|
| 3700 | Int iDeltaDenom; |
---|
[494] | 3701 | #if AUXILIARY_PICTURES |
---|
| 3702 | if (pcSlice->getChromaFormatIdc() == CHROMA_400) |
---|
| 3703 | { |
---|
| 3704 | bChroma = false; |
---|
| 3705 | } |
---|
| 3706 | #endif |
---|
[313] | 3707 | // decode delta_luma_log2_weight_denom : |
---|
| 3708 | READ_UVLC( uiLog2WeightDenomLuma, "luma_log2_weight_denom" ); // ue(v): luma_log2_weight_denom |
---|
| 3709 | assert( uiLog2WeightDenomLuma <= 7 ); |
---|
| 3710 | if( bChroma ) |
---|
| 3711 | { |
---|
| 3712 | READ_SVLC( iDeltaDenom, "delta_chroma_log2_weight_denom" ); // se(v): delta_chroma_log2_weight_denom |
---|
| 3713 | assert((iDeltaDenom + (Int)uiLog2WeightDenomLuma)>=0); |
---|
| 3714 | assert((iDeltaDenom + (Int)uiLog2WeightDenomLuma)<=7); |
---|
| 3715 | uiLog2WeightDenomChroma = (UInt)(iDeltaDenom + uiLog2WeightDenomLuma); |
---|
| 3716 | } |
---|
| 3717 | |
---|
| 3718 | for ( Int iNumRef=0 ; iNumRef<iNbRef ; iNumRef++ ) |
---|
| 3719 | { |
---|
| 3720 | RefPicList eRefPicList = ( iNumRef ? REF_PIC_LIST_1 : REF_PIC_LIST_0 ); |
---|
| 3721 | for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ ) |
---|
| 3722 | { |
---|
| 3723 | pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); |
---|
| 3724 | |
---|
| 3725 | wp[0].uiLog2WeightDenom = uiLog2WeightDenomLuma; |
---|
[494] | 3726 | #if AUXILIARY_PICTURES |
---|
| 3727 | if (!bChroma) |
---|
| 3728 | { |
---|
| 3729 | wp[1].uiLog2WeightDenom = 0; |
---|
| 3730 | wp[2].uiLog2WeightDenom = 0; |
---|
| 3731 | } |
---|
| 3732 | else |
---|
| 3733 | { |
---|
| 3734 | #endif |
---|
[313] | 3735 | wp[1].uiLog2WeightDenom = uiLog2WeightDenomChroma; |
---|
| 3736 | wp[2].uiLog2WeightDenom = uiLog2WeightDenomChroma; |
---|
[494] | 3737 | #if AUXILIARY_PICTURES |
---|
| 3738 | } |
---|
| 3739 | #endif |
---|
[313] | 3740 | |
---|
| 3741 | UInt uiCode; |
---|
| 3742 | READ_FLAG( uiCode, "luma_weight_lX_flag" ); // u(1): luma_weight_l0_flag |
---|
| 3743 | wp[0].bPresentFlag = ( uiCode == 1 ); |
---|
| 3744 | uiTotalSignalledWeightFlags += wp[0].bPresentFlag; |
---|
| 3745 | } |
---|
| 3746 | if ( bChroma ) |
---|
| 3747 | { |
---|
| 3748 | UInt uiCode; |
---|
| 3749 | for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ ) |
---|
| 3750 | { |
---|
| 3751 | pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); |
---|
| 3752 | READ_FLAG( uiCode, "chroma_weight_lX_flag" ); // u(1): chroma_weight_l0_flag |
---|
| 3753 | wp[1].bPresentFlag = ( uiCode == 1 ); |
---|
| 3754 | wp[2].bPresentFlag = ( uiCode == 1 ); |
---|
| 3755 | uiTotalSignalledWeightFlags += 2*wp[1].bPresentFlag; |
---|
| 3756 | } |
---|
| 3757 | } |
---|
| 3758 | for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ ) |
---|
| 3759 | { |
---|
| 3760 | pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); |
---|
| 3761 | if ( wp[0].bPresentFlag ) |
---|
| 3762 | { |
---|
| 3763 | Int iDeltaWeight; |
---|
| 3764 | READ_SVLC( iDeltaWeight, "delta_luma_weight_lX" ); // se(v): delta_luma_weight_l0[i] |
---|
| 3765 | assert( iDeltaWeight >= -128 ); |
---|
| 3766 | assert( iDeltaWeight <= 127 ); |
---|
| 3767 | wp[0].iWeight = (iDeltaWeight + (1<<wp[0].uiLog2WeightDenom)); |
---|
| 3768 | READ_SVLC( wp[0].iOffset, "luma_offset_lX" ); // se(v): luma_offset_l0[i] |
---|
| 3769 | assert( wp[0].iOffset >= -128 ); |
---|
| 3770 | assert( wp[0].iOffset <= 127 ); |
---|
| 3771 | } |
---|
| 3772 | else |
---|
| 3773 | { |
---|
| 3774 | wp[0].iWeight = (1 << wp[0].uiLog2WeightDenom); |
---|
| 3775 | wp[0].iOffset = 0; |
---|
| 3776 | } |
---|
| 3777 | if ( bChroma ) |
---|
| 3778 | { |
---|
| 3779 | if ( wp[1].bPresentFlag ) |
---|
| 3780 | { |
---|
| 3781 | for ( Int j=1 ; j<3 ; j++ ) |
---|
| 3782 | { |
---|
| 3783 | Int iDeltaWeight; |
---|
| 3784 | READ_SVLC( iDeltaWeight, "delta_chroma_weight_lX" ); // se(v): chroma_weight_l0[i][j] |
---|
| 3785 | assert( iDeltaWeight >= -128 ); |
---|
| 3786 | assert( iDeltaWeight <= 127 ); |
---|
| 3787 | wp[j].iWeight = (iDeltaWeight + (1<<wp[1].uiLog2WeightDenom)); |
---|
| 3788 | |
---|
| 3789 | Int iDeltaChroma; |
---|
| 3790 | READ_SVLC( iDeltaChroma, "delta_chroma_offset_lX" ); // se(v): delta_chroma_offset_l0[i][j] |
---|
| 3791 | assert( iDeltaChroma >= -512 ); |
---|
| 3792 | assert( iDeltaChroma <= 511 ); |
---|
| 3793 | Int pred = ( 128 - ( ( 128*wp[j].iWeight)>>(wp[j].uiLog2WeightDenom) ) ); |
---|
| 3794 | wp[j].iOffset = Clip3(-128, 127, (iDeltaChroma + pred) ); |
---|
| 3795 | } |
---|
| 3796 | } |
---|
| 3797 | else |
---|
| 3798 | { |
---|
| 3799 | for ( Int j=1 ; j<3 ; j++ ) |
---|
| 3800 | { |
---|
| 3801 | wp[j].iWeight = (1 << wp[j].uiLog2WeightDenom); |
---|
| 3802 | wp[j].iOffset = 0; |
---|
| 3803 | } |
---|
| 3804 | } |
---|
| 3805 | } |
---|
| 3806 | } |
---|
| 3807 | |
---|
| 3808 | for ( Int iRefIdx=pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx<MAX_NUM_REF ; iRefIdx++ ) |
---|
| 3809 | { |
---|
| 3810 | pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); |
---|
| 3811 | |
---|
| 3812 | wp[0].bPresentFlag = false; |
---|
| 3813 | wp[1].bPresentFlag = false; |
---|
| 3814 | wp[2].bPresentFlag = false; |
---|
| 3815 | } |
---|
| 3816 | } |
---|
| 3817 | assert(uiTotalSignalledWeightFlags<=24); |
---|
| 3818 | } |
---|
| 3819 | |
---|
| 3820 | /** decode quantization matrix |
---|
| 3821 | * \param scalingList quantization matrix information |
---|
| 3822 | */ |
---|
| 3823 | Void TDecCavlc::parseScalingList(TComScalingList* scalingList) |
---|
| 3824 | { |
---|
| 3825 | UInt code, sizeId, listId; |
---|
| 3826 | Bool scalingListPredModeFlag; |
---|
| 3827 | //for each size |
---|
| 3828 | for(sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
| 3829 | { |
---|
| 3830 | for(listId = 0; listId < g_scalingListNum[sizeId]; listId++) |
---|
| 3831 | { |
---|
| 3832 | READ_FLAG( code, "scaling_list_pred_mode_flag"); |
---|
| 3833 | scalingListPredModeFlag = (code) ? true : false; |
---|
| 3834 | if(!scalingListPredModeFlag) //Copy Mode |
---|
| 3835 | { |
---|
| 3836 | READ_UVLC( code, "scaling_list_pred_matrix_id_delta"); |
---|
| 3837 | scalingList->setRefMatrixId (sizeId,listId,(UInt)((Int)(listId)-(code))); |
---|
| 3838 | if( sizeId > SCALING_LIST_8x8 ) |
---|
| 3839 | { |
---|
| 3840 | scalingList->setScalingListDC(sizeId,listId,((listId == scalingList->getRefMatrixId (sizeId,listId))? 16 :scalingList->getScalingListDC(sizeId, scalingList->getRefMatrixId (sizeId,listId)))); |
---|
| 3841 | } |
---|
| 3842 | scalingList->processRefMatrix( sizeId, listId, scalingList->getRefMatrixId (sizeId,listId)); |
---|
| 3843 | |
---|
| 3844 | } |
---|
| 3845 | else //DPCM Mode |
---|
| 3846 | { |
---|
| 3847 | xDecodeScalingList(scalingList, sizeId, listId); |
---|
| 3848 | } |
---|
| 3849 | } |
---|
| 3850 | } |
---|
| 3851 | |
---|
| 3852 | return; |
---|
| 3853 | } |
---|
| 3854 | /** decode DPCM |
---|
| 3855 | * \param scalingList quantization matrix information |
---|
| 3856 | * \param sizeId size index |
---|
| 3857 | * \param listId list index |
---|
| 3858 | */ |
---|
| 3859 | Void TDecCavlc::xDecodeScalingList(TComScalingList *scalingList, UInt sizeId, UInt listId) |
---|
| 3860 | { |
---|
| 3861 | Int i,coefNum = min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId]); |
---|
| 3862 | Int data; |
---|
| 3863 | Int scalingListDcCoefMinus8 = 0; |
---|
| 3864 | Int nextCoef = SCALING_LIST_START_VALUE; |
---|
| 3865 | UInt* scan = (sizeId == 0) ? g_auiSigLastScan [ SCAN_DIAG ] [ 1 ] : g_sigLastScanCG32x32; |
---|
| 3866 | Int *dst = scalingList->getScalingListAddress(sizeId, listId); |
---|
| 3867 | |
---|
| 3868 | if( sizeId > SCALING_LIST_8x8 ) |
---|
| 3869 | { |
---|
| 3870 | READ_SVLC( scalingListDcCoefMinus8, "scaling_list_dc_coef_minus8"); |
---|
| 3871 | scalingList->setScalingListDC(sizeId,listId,scalingListDcCoefMinus8 + 8); |
---|
| 3872 | nextCoef = scalingList->getScalingListDC(sizeId,listId); |
---|
| 3873 | } |
---|
| 3874 | |
---|
| 3875 | for(i = 0; i < coefNum; i++) |
---|
| 3876 | { |
---|
| 3877 | READ_SVLC( data, "scaling_list_delta_coef"); |
---|
| 3878 | nextCoef = (nextCoef + data + 256 ) % 256; |
---|
| 3879 | dst[scan[i]] = nextCoef; |
---|
| 3880 | } |
---|
| 3881 | } |
---|
| 3882 | |
---|
| 3883 | Bool TDecCavlc::xMoreRbspData() |
---|
| 3884 | { |
---|
| 3885 | Int bitsLeft = m_pcBitstream->getNumBitsLeft(); |
---|
| 3886 | |
---|
| 3887 | // if there are more than 8 bits, it cannot be rbsp_trailing_bits |
---|
| 3888 | if (bitsLeft > 8) |
---|
| 3889 | { |
---|
| 3890 | return true; |
---|
| 3891 | } |
---|
| 3892 | |
---|
| 3893 | UChar lastByte = m_pcBitstream->peekBits(bitsLeft); |
---|
| 3894 | Int cnt = bitsLeft; |
---|
| 3895 | |
---|
| 3896 | // remove trailing bits equal to zero |
---|
| 3897 | while ((cnt>0) && ((lastByte & 1) == 0)) |
---|
| 3898 | { |
---|
| 3899 | lastByte >>= 1; |
---|
| 3900 | cnt--; |
---|
| 3901 | } |
---|
| 3902 | // remove bit equal to one |
---|
| 3903 | cnt--; |
---|
| 3904 | |
---|
| 3905 | // we should not have a negative number of bits |
---|
| 3906 | assert (cnt>=0); |
---|
| 3907 | |
---|
| 3908 | // we have more data, if cnt is not zero |
---|
| 3909 | return (cnt>0); |
---|
| 3910 | } |
---|
[540] | 3911 | |
---|
[713] | 3912 | #if Q0048_CGS_3D_ASYMLUT |
---|
| 3913 | Void TDecCavlc::xParse3DAsymLUT( TCom3DAsymLUT * pc3DAsymLUT ) |
---|
| 3914 | { |
---|
| 3915 | UInt uiCurOctantDepth , uiCurPartNumLog2 , uiInputBitDepthM8 , uiOutputBitDepthM8 , uiResQaunBit; |
---|
| 3916 | READ_CODE( 2 , uiCurOctantDepth , "cm_octant_depth" ); |
---|
| 3917 | READ_CODE( 2 , uiCurPartNumLog2 , "cm_y_part_num_log2" ); |
---|
| 3918 | READ_CODE( 3 , uiInputBitDepthM8 , "cm_input_bit_depth_minus8" ); |
---|
| 3919 | Int iInputBitDepthCDelta; |
---|
| 3920 | READ_SVLC(iInputBitDepthCDelta, "cm_input_bit_depth_chroma delta"); |
---|
| 3921 | READ_CODE( 3 , uiOutputBitDepthM8 , "cm_output_bit_depth_minus8" ); |
---|
| 3922 | Int iOutputBitDepthCDelta; |
---|
| 3923 | READ_SVLC(iOutputBitDepthCDelta, "cm_output_bit_depth_chroma_delta"); |
---|
| 3924 | READ_CODE( 2 , uiResQaunBit , "cm_res_quant_bit" ); |
---|
| 3925 | pc3DAsymLUT->destroy(); |
---|
| 3926 | pc3DAsymLUT->create( uiCurOctantDepth , uiInputBitDepthM8 + 8 , uiInputBitDepthM8 + 8 + iInputBitDepthCDelta, uiOutputBitDepthM8 + 8 , uiOutputBitDepthM8 + 8 + iOutputBitDepthCDelta ,uiCurPartNumLog2 ); |
---|
| 3927 | pc3DAsymLUT->setResQuantBit( uiResQaunBit ); |
---|
| 3928 | |
---|
| 3929 | xParse3DAsymLUTOctant( pc3DAsymLUT , 0 , 0 , 0 , 0 , 1 << pc3DAsymLUT->getCurOctantDepth() ); |
---|
| 3930 | } |
---|
| 3931 | |
---|
| 3932 | Void TDecCavlc::xParse3DAsymLUTOctant( TCom3DAsymLUT * pc3DAsymLUT , Int nDepth , Int yIdx , Int uIdx , Int vIdx , Int nLength ) |
---|
| 3933 | { |
---|
| 3934 | UInt uiOctantSplit = nDepth < pc3DAsymLUT->getCurOctantDepth(); |
---|
| 3935 | if( nDepth < pc3DAsymLUT->getCurOctantDepth() ) |
---|
| 3936 | READ_FLAG( uiOctantSplit , "split_octant_flag" ); |
---|
| 3937 | Int nYPartNum = 1 << pc3DAsymLUT->getCurYPartNumLog2(); |
---|
| 3938 | if( uiOctantSplit ) |
---|
| 3939 | { |
---|
| 3940 | Int nHalfLength = nLength >> 1; |
---|
| 3941 | for( Int l = 0 ; l < 2 ; l++ ) |
---|
| 3942 | { |
---|
| 3943 | for( Int m = 0 ; m < 2 ; m++ ) |
---|
| 3944 | { |
---|
| 3945 | for( Int n = 0 ; n < 2 ; n++ ) |
---|
| 3946 | { |
---|
| 3947 | xParse3DAsymLUTOctant( pc3DAsymLUT , nDepth + 1 , yIdx + l * nHalfLength * nYPartNum , uIdx + m * nHalfLength , vIdx + n * nHalfLength , nHalfLength ); |
---|
| 3948 | } |
---|
| 3949 | } |
---|
| 3950 | } |
---|
| 3951 | } |
---|
| 3952 | else |
---|
| 3953 | { |
---|
| 3954 | for( Int l = 0 ; l < nYPartNum ; l++ ) |
---|
| 3955 | { |
---|
| 3956 | for( Int nVertexIdx = 0 ; nVertexIdx < 4 ; nVertexIdx++ ) |
---|
| 3957 | { |
---|
| 3958 | UInt uiCodeVertex = 0; |
---|
| 3959 | Int deltaY = 0 , deltaU = 0 , deltaV = 0; |
---|
| 3960 | READ_FLAG( uiCodeVertex , "coded_vertex_flag" ); |
---|
| 3961 | if( uiCodeVertex ) |
---|
| 3962 | { |
---|
| 3963 | READ_SVLC( deltaY , "resY" ); |
---|
| 3964 | READ_SVLC( deltaU , "resU" ); |
---|
| 3965 | READ_SVLC( deltaV , "resV" ); |
---|
| 3966 | } |
---|
| 3967 | pc3DAsymLUT->setCuboidVertexResTree( yIdx + l , uIdx , vIdx , nVertexIdx , deltaY , deltaU , deltaV ); |
---|
| 3968 | } |
---|
| 3969 | } |
---|
| 3970 | } |
---|
| 3971 | } |
---|
| 3972 | #endif |
---|
[313] | 3973 | //! \} |
---|
| 3974 | |
---|