| 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 | * |
|---|
| 6 | * Copyright (c) 2010-2014, ITU/ISO/IEC |
|---|
| 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" |
|---|
| 41 | #if Q0048_CGS_3D_ASYMLUT |
|---|
| 42 | #include "../TLibCommon/TCom3DAsymLUT.h" |
|---|
| 43 | #endif |
|---|
| 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 | |
|---|
| 180 | Void TDecCavlc::parsePPS(TComPPS* pcPPS |
|---|
| 181 | #if Q0048_CGS_3D_ASYMLUT |
|---|
| 182 | , TCom3DAsymLUT * pc3DAsymLUT , Int nLayerID |
|---|
| 183 | #endif |
|---|
| 184 | ) |
|---|
| 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); |
|---|
| 196 | |
|---|
| 197 | READ_UVLC( uiCode, "pps_seq_parameter_set_id"); |
|---|
| 198 | assert(uiCode <= 15); |
|---|
| 199 | pcPPS->setSPSId (uiCode); |
|---|
| 200 | |
|---|
| 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->setNumTileColumnsMinus1( uiCode ); |
|---|
| 258 | READ_UVLC ( uiCode, "num_tile_rows_minus1" ); pcPPS->setNumTileRowsMinus1( uiCode ); |
|---|
| 259 | READ_FLAG ( uiCode, "uniform_spacing_flag" ); pcPPS->setTileUniformSpacingFlag( uiCode == 1 ); |
|---|
| 260 | |
|---|
| 261 | if( !pcPPS->getTileUniformSpacingFlag()) |
|---|
| 262 | { |
|---|
| 263 | std::vector<Int> columnWidth(pcPPS->getNumTileColumnsMinus1()); |
|---|
| 264 | for(UInt i=0; i<pcPPS->getNumTileColumnsMinus1(); i++) |
|---|
| 265 | { |
|---|
| 266 | READ_UVLC( uiCode, "column_width_minus1" ); |
|---|
| 267 | columnWidth[i] = uiCode+1; |
|---|
| 268 | } |
|---|
| 269 | pcPPS->setTileColumnWidth(columnWidth); |
|---|
| 270 | |
|---|
| 271 | std::vector<Int> rowHeight (pcPPS->getTileNumRowsMinus1()); |
|---|
| 272 | for(UInt i=0; i<pcPPS->getTileNumRowsMinus1(); i++) |
|---|
| 273 | { |
|---|
| 274 | READ_UVLC( uiCode, "row_height_minus1" ); |
|---|
| 275 | rowHeight[i] = uiCode + 1; |
|---|
| 276 | } |
|---|
| 277 | pcPPS->setTileRowHeight(rowHeight); |
|---|
| 278 | } |
|---|
| 279 | |
|---|
| 280 | if(pcPPS->getNumTileColumnsMinus1() !=0 || pcPPS->getTileNumRowsMinus1() !=0) |
|---|
| 281 | { |
|---|
| 282 | READ_FLAG ( uiCode, "loop_filter_across_tiles_enabled_flag" ); pcPPS->setLoopFilterAcrossTilesEnabledFlag( uiCode ? true : false ); |
|---|
| 283 | } |
|---|
| 284 | } |
|---|
| 285 | READ_FLAG( uiCode, "loop_filter_across_slices_enabled_flag" ); pcPPS->setLoopFilterAcrossSlicesEnabledFlag( uiCode ? true : false ); |
|---|
| 286 | READ_FLAG( uiCode, "deblocking_filter_control_present_flag" ); pcPPS->setDeblockingFilterControlPresentFlag( uiCode ? true : false ); |
|---|
| 287 | if(pcPPS->getDeblockingFilterControlPresentFlag()) |
|---|
| 288 | { |
|---|
| 289 | READ_FLAG( uiCode, "deblocking_filter_override_enabled_flag" ); pcPPS->setDeblockingFilterOverrideEnabledFlag( uiCode ? true : false ); |
|---|
| 290 | READ_FLAG( uiCode, "pps_disable_deblocking_filter_flag" ); pcPPS->setPicDisableDeblockingFilterFlag(uiCode ? true : false ); |
|---|
| 291 | if(!pcPPS->getPicDisableDeblockingFilterFlag()) |
|---|
| 292 | { |
|---|
| 293 | READ_SVLC ( iCode, "pps_beta_offset_div2" ); pcPPS->setDeblockingFilterBetaOffsetDiv2( iCode ); |
|---|
| 294 | READ_SVLC ( iCode, "pps_tc_offset_div2" ); pcPPS->setDeblockingFilterTcOffsetDiv2( iCode ); |
|---|
| 295 | } |
|---|
| 296 | } |
|---|
| 297 | #if !R0042_PROFILE_INDICATION |
|---|
| 298 | #if SCALINGLIST_INFERRING |
|---|
| 299 | if( pcPPS->getLayerId() > 0 ) |
|---|
| 300 | { |
|---|
| 301 | READ_FLAG( uiCode, "pps_infer_scaling_list_flag" ); |
|---|
| 302 | pcPPS->setInferScalingListFlag( uiCode ); |
|---|
| 303 | } |
|---|
| 304 | |
|---|
| 305 | if( pcPPS->getInferScalingListFlag() ) |
|---|
| 306 | { |
|---|
| 307 | READ_CODE( 6, uiCode, "pps_scaling_list_ref_layer_id" ); pcPPS->setScalingListRefLayerId( uiCode ); |
|---|
| 308 | |
|---|
| 309 | // The value of pps_scaling_list_ref_layer_id shall be in the range of 0 to 62, inclusive |
|---|
| 310 | assert( pcPPS->getScalingListRefLayerId() <= 62 ); |
|---|
| 311 | |
|---|
| 312 | pcPPS->setScalingListPresentFlag( false ); |
|---|
| 313 | } |
|---|
| 314 | else |
|---|
| 315 | { |
|---|
| 316 | #endif |
|---|
| 317 | #endif |
|---|
| 318 | |
|---|
| 319 | READ_FLAG( uiCode, "pps_scaling_list_data_present_flag" ); pcPPS->setScalingListPresentFlag( uiCode ? true : false ); |
|---|
| 320 | |
|---|
| 321 | if(pcPPS->getScalingListPresentFlag ()) |
|---|
| 322 | { |
|---|
| 323 | parseScalingList( pcPPS->getScalingList() ); |
|---|
| 324 | } |
|---|
| 325 | #if !R0042_PROFILE_INDICATION |
|---|
| 326 | #if SCALINGLIST_INFERRING |
|---|
| 327 | } |
|---|
| 328 | #endif |
|---|
| 329 | #endif |
|---|
| 330 | |
|---|
| 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 | #if !R0042_PROFILE_INDICATION |
|---|
| 341 | READ_FLAG( uiCode, "pps_extension_flag"); |
|---|
| 342 | #else |
|---|
| 343 | READ_FLAG( uiCode, "pps_extension_present_flag"); |
|---|
| 344 | #endif |
|---|
| 345 | |
|---|
| 346 | #if !R0042_PROFILE_INDICATION |
|---|
| 347 | #if POC_RESET_INFO_INFERENCE |
|---|
| 348 | pcPPS->setExtensionFlag( uiCode ? true : false ); |
|---|
| 349 | |
|---|
| 350 | if( pcPPS->getExtensionFlag() ) |
|---|
| 351 | #else |
|---|
| 352 | if (uiCode) |
|---|
| 353 | #endif |
|---|
| 354 | { |
|---|
| 355 | #if P0166_MODIFIED_PPS_EXTENSION |
|---|
| 356 | UInt ppsExtensionTypeFlag[8]; |
|---|
| 357 | for (UInt i = 0; i < 8; i++) |
|---|
| 358 | { |
|---|
| 359 | READ_FLAG( ppsExtensionTypeFlag[i], "pps_extension_type_flag" ); |
|---|
| 360 | } |
|---|
| 361 | #if !POC_RESET_IDC |
|---|
| 362 | if (ppsExtensionTypeFlag[1]) |
|---|
| 363 | { |
|---|
| 364 | #else |
|---|
| 365 | if( ppsExtensionTypeFlag[0] ) |
|---|
| 366 | { |
|---|
| 367 | READ_FLAG( uiCode, "poc_reset_info_present_flag" ); |
|---|
| 368 | pcPPS->setPocResetInfoPresentFlag(uiCode ? true : false); |
|---|
| 369 | #if REF_REGION_OFFSET |
|---|
| 370 | READ_UVLC( uiCode, "num_scaled_ref_layer_offsets" ); pcPPS->setNumScaledRefLayerOffsets(uiCode); |
|---|
| 371 | for(Int i = 0; i < pcPPS->getNumScaledRefLayerOffsets(); i++) |
|---|
| 372 | { |
|---|
| 373 | READ_CODE( 6, uiCode, "scaled_ref_layer_id" ); pcPPS->setScaledRefLayerId( i, uiCode ); |
|---|
| 374 | READ_FLAG( uiCode, "scaled_ref_layer_offset_present_flag" ); pcPPS->setScaledRefLayerOffsetPresentFlag( i, uiCode ); |
|---|
| 375 | if (uiCode) |
|---|
| 376 | { |
|---|
| 377 | Window& scaledWindow = pcPPS->getScaledRefLayerWindow(i); |
|---|
| 378 | READ_SVLC( iCode, "scaled_ref_layer_left_offset" ); scaledWindow.setWindowLeftOffset (iCode << 1); |
|---|
| 379 | READ_SVLC( iCode, "scaled_ref_layer_top_offset" ); scaledWindow.setWindowTopOffset (iCode << 1); |
|---|
| 380 | READ_SVLC( iCode, "scaled_ref_layer_right_offset" ); scaledWindow.setWindowRightOffset (iCode << 1); |
|---|
| 381 | READ_SVLC( iCode, "scaled_ref_layer_bottom_offset" ); scaledWindow.setWindowBottomOffset(iCode << 1); |
|---|
| 382 | #if P0312_VERT_PHASE_ADJ |
|---|
| 383 | READ_FLAG( uiCode, "vert_phase_position_enable_flag" ); scaledWindow.setVertPhasePositionEnableFlag(uiCode); pcPPS->setVertPhasePositionEnableFlag( pcPPS->getScaledRefLayerId(i), uiCode); |
|---|
| 384 | #endif |
|---|
| 385 | } |
|---|
| 386 | READ_FLAG( uiCode, "ref_region_offset_present_flag" ); pcPPS->setRefRegionOffsetPresentFlag( i, uiCode ); |
|---|
| 387 | if (uiCode) |
|---|
| 388 | { |
|---|
| 389 | Window& refWindow = pcPPS->getRefLayerWindow(i); |
|---|
| 390 | READ_SVLC( iCode, "ref_region_left_offset" ); refWindow.setWindowLeftOffset (iCode << 1); |
|---|
| 391 | READ_SVLC( iCode, "ref_region_top_offset" ); refWindow.setWindowTopOffset (iCode << 1); |
|---|
| 392 | READ_SVLC( iCode, "ref_region_right_offset" ); refWindow.setWindowRightOffset (iCode << 1); |
|---|
| 393 | READ_SVLC( iCode, "ref_region_bottom_offset" ); refWindow.setWindowBottomOffset(iCode << 1); |
|---|
| 394 | } |
|---|
| 395 | #if R0209_GENERIC_PHASE |
|---|
| 396 | READ_FLAG( uiCode, "resample_phase_set_present_flag" ); pcPPS->setResamplePhaseSetPresentFlag( i, uiCode ); |
|---|
| 397 | if (uiCode) |
|---|
| 398 | { |
|---|
| 399 | READ_UVLC( uiCode, "phase_hor_luma" ); pcPPS->setPhaseHorLuma ( i, uiCode ); |
|---|
| 400 | READ_UVLC( uiCode, "phase_ver_luma" ); pcPPS->setPhaseVerLuma ( i, uiCode ); |
|---|
| 401 | READ_UVLC( uiCode, "phase_hor_chroma_plus8" ); pcPPS->setPhaseHorChroma (i, uiCode - 8); |
|---|
| 402 | READ_UVLC( uiCode, "phase_ver_chroma_plus8" ); pcPPS->setPhaseVerChroma (i, uiCode - 8); |
|---|
| 403 | } |
|---|
| 404 | #endif |
|---|
| 405 | } |
|---|
| 406 | #else |
|---|
| 407 | #if MOVE_SCALED_OFFSET_TO_PPS |
|---|
| 408 | READ_UVLC( uiCode, "num_scaled_ref_layer_offsets" ); pcPPS->setNumScaledRefLayerOffsets(uiCode); |
|---|
| 409 | for(Int i = 0; i < pcPPS->getNumScaledRefLayerOffsets(); i++) |
|---|
| 410 | { |
|---|
| 411 | Window& scaledWindow = pcPPS->getScaledRefLayerWindow(i); |
|---|
| 412 | #if O0098_SCALED_REF_LAYER_ID |
|---|
| 413 | READ_CODE( 6, uiCode, "scaled_ref_layer_id" ); pcPPS->setScaledRefLayerId( i, uiCode ); |
|---|
| 414 | #endif |
|---|
| 415 | READ_SVLC( iCode, "scaled_ref_layer_left_offset" ); scaledWindow.setWindowLeftOffset (iCode << 1); |
|---|
| 416 | READ_SVLC( iCode, "scaled_ref_layer_top_offset" ); scaledWindow.setWindowTopOffset (iCode << 1); |
|---|
| 417 | READ_SVLC( iCode, "scaled_ref_layer_right_offset" ); scaledWindow.setWindowRightOffset (iCode << 1); |
|---|
| 418 | READ_SVLC( iCode, "scaled_ref_layer_bottom_offset" ); scaledWindow.setWindowBottomOffset(iCode << 1); |
|---|
| 419 | #if P0312_VERT_PHASE_ADJ |
|---|
| 420 | READ_FLAG( uiCode, "vert_phase_position_enable_flag" ); scaledWindow.setVertPhasePositionEnableFlag(uiCode); pcPPS->setVertPhasePositionEnableFlag( pcPPS->getScaledRefLayerId(i), uiCode); |
|---|
| 421 | #endif |
|---|
| 422 | } |
|---|
| 423 | #endif |
|---|
| 424 | #endif |
|---|
| 425 | #if Q0048_CGS_3D_ASYMLUT |
|---|
| 426 | READ_FLAG( uiCode , "colour_mapping_enabled_flag" ); |
|---|
| 427 | pcPPS->setCGSFlag( uiCode ); |
|---|
| 428 | if( pcPPS->getCGSFlag() ) |
|---|
| 429 | { |
|---|
| 430 | xParse3DAsymLUT( pc3DAsymLUT ); |
|---|
| 431 | pcPPS->setCGSOutputBitDepthY( pc3DAsymLUT->getOutputBitDepthY() ); |
|---|
| 432 | pcPPS->setCGSOutputBitDepthC( pc3DAsymLUT->getOutputBitDepthC() ); |
|---|
| 433 | } |
|---|
| 434 | #endif |
|---|
| 435 | #endif |
|---|
| 436 | } |
|---|
| 437 | #if POC_RESET_INFO_INFERENCE |
|---|
| 438 | else // Extension type 0 absent |
|---|
| 439 | { |
|---|
| 440 | pcPPS->setPocResetInfoPresentFlag( false ); |
|---|
| 441 | } |
|---|
| 442 | #endif |
|---|
| 443 | if (ppsExtensionTypeFlag[7]) |
|---|
| 444 | { |
|---|
| 445 | #endif |
|---|
| 446 | |
|---|
| 447 | while ( xMoreRbspData() ) |
|---|
| 448 | { |
|---|
| 449 | READ_FLAG( uiCode, "pps_extension_data_flag"); |
|---|
| 450 | } |
|---|
| 451 | #if P0166_MODIFIED_PPS_EXTENSION |
|---|
| 452 | } |
|---|
| 453 | #endif |
|---|
| 454 | } |
|---|
| 455 | #if POC_RESET_INFO_INFERENCE |
|---|
| 456 | if( !pcPPS->getExtensionFlag() ) |
|---|
| 457 | { |
|---|
| 458 | pcPPS->setPocResetInfoPresentFlag( false ); |
|---|
| 459 | } |
|---|
| 460 | #endif |
|---|
| 461 | #else |
|---|
| 462 | pcPPS->setExtensionFlag( uiCode ? true : false ); |
|---|
| 463 | if( pcPPS->getExtensionFlag() ) |
|---|
| 464 | { |
|---|
| 465 | READ_FLAG( uiCode, "pps_range_extension_flag" ); |
|---|
| 466 | assert(uiCode == 0); |
|---|
| 467 | READ_FLAG( uiCode, "pps_multilayer_extension_flag" ); |
|---|
| 468 | assert(uiCode == 1); |
|---|
| 469 | READ_CODE(6, uiCode, "pps_extension_6bits"); |
|---|
| 470 | assert(uiCode == 0); |
|---|
| 471 | |
|---|
| 472 | READ_FLAG( uiCode, "poc_reset_info_present_flag" ); |
|---|
| 473 | pcPPS->setPocResetInfoPresentFlag(uiCode ? true : false); |
|---|
| 474 | |
|---|
| 475 | #if SCALINGLIST_INFERRING |
|---|
| 476 | READ_FLAG( uiCode, "pps_infer_scaling_list_flag" ); |
|---|
| 477 | pcPPS->setInferScalingListFlag( uiCode ); |
|---|
| 478 | |
|---|
| 479 | if( pcPPS->getInferScalingListFlag() ) |
|---|
| 480 | { |
|---|
| 481 | READ_CODE( 6, uiCode, "pps_scaling_list_ref_layer_id" ); |
|---|
| 482 | pcPPS->setScalingListRefLayerId( uiCode ); |
|---|
| 483 | // The value of pps_scaling_list_ref_layer_id shall be in the range of 0 to 62, inclusive |
|---|
| 484 | assert( pcPPS->getScalingListRefLayerId() <= 62 ); |
|---|
| 485 | pcPPS->setScalingListPresentFlag( false ); |
|---|
| 486 | } |
|---|
| 487 | #endif |
|---|
| 488 | |
|---|
| 489 | #if REF_REGION_OFFSET |
|---|
| 490 | READ_UVLC( uiCode, "num_ref_loc_offsets" ); pcPPS->setNumScaledRefLayerOffsets(uiCode); |
|---|
| 491 | for(Int i = 0; i < pcPPS->getNumScaledRefLayerOffsets(); i++) |
|---|
| 492 | { |
|---|
| 493 | READ_CODE( 6, uiCode, "ref_loc_offset_layer_id" ); pcPPS->setScaledRefLayerId( i, uiCode ); |
|---|
| 494 | READ_FLAG( uiCode, "scaled_ref_layer_offset_present_flag" ); pcPPS->setScaledRefLayerOffsetPresentFlag( i, uiCode ); |
|---|
| 495 | if (uiCode) |
|---|
| 496 | { |
|---|
| 497 | Window& scaledWindow = pcPPS->getScaledRefLayerWindow(i); |
|---|
| 498 | READ_SVLC( iCode, "scaled_ref_layer_left_offset" ); scaledWindow.setWindowLeftOffset (iCode << 1); |
|---|
| 499 | READ_SVLC( iCode, "scaled_ref_layer_top_offset" ); scaledWindow.setWindowTopOffset (iCode << 1); |
|---|
| 500 | READ_SVLC( iCode, "scaled_ref_layer_right_offset" ); scaledWindow.setWindowRightOffset (iCode << 1); |
|---|
| 501 | READ_SVLC( iCode, "scaled_ref_layer_bottom_offset" ); scaledWindow.setWindowBottomOffset(iCode << 1); |
|---|
| 502 | #if P0312_VERT_PHASE_ADJ |
|---|
| 503 | READ_FLAG( uiCode, "vert_phase_position_enable_flag" ); scaledWindow.setVertPhasePositionEnableFlag(uiCode); pcPPS->setVertPhasePositionEnableFlag( pcPPS->getScaledRefLayerId(i), uiCode); |
|---|
| 504 | #endif |
|---|
| 505 | } |
|---|
| 506 | READ_FLAG( uiCode, "ref_region_offset_present_flag" ); pcPPS->setRefRegionOffsetPresentFlag( i, uiCode ); |
|---|
| 507 | if (uiCode) |
|---|
| 508 | { |
|---|
| 509 | Window& refWindow = pcPPS->getRefLayerWindow(i); |
|---|
| 510 | READ_SVLC( iCode, "ref_region_left_offset" ); refWindow.setWindowLeftOffset (iCode << 1); |
|---|
| 511 | READ_SVLC( iCode, "ref_region_top_offset" ); refWindow.setWindowTopOffset (iCode << 1); |
|---|
| 512 | READ_SVLC( iCode, "ref_region_right_offset" ); refWindow.setWindowRightOffset (iCode << 1); |
|---|
| 513 | READ_SVLC( iCode, "ref_region_bottom_offset" ); refWindow.setWindowBottomOffset(iCode << 1); |
|---|
| 514 | } |
|---|
| 515 | #if R0209_GENERIC_PHASE |
|---|
| 516 | READ_FLAG( uiCode, "resample_phase_set_present_flag" ); pcPPS->setResamplePhaseSetPresentFlag( i, uiCode ); |
|---|
| 517 | if (uiCode) |
|---|
| 518 | { |
|---|
| 519 | READ_UVLC( uiCode, "phase_hor_luma" ); pcPPS->setPhaseHorLuma ( i, uiCode ); |
|---|
| 520 | READ_UVLC( uiCode, "phase_ver_luma" ); pcPPS->setPhaseVerLuma ( i, uiCode ); |
|---|
| 521 | READ_UVLC( uiCode, "phase_hor_chroma_plus8" ); pcPPS->setPhaseHorChroma (i, uiCode - 8); |
|---|
| 522 | READ_UVLC( uiCode, "phase_ver_chroma_plus8" ); pcPPS->setPhaseVerChroma (i, uiCode - 8); |
|---|
| 523 | } |
|---|
| 524 | #endif |
|---|
| 525 | } |
|---|
| 526 | #else |
|---|
| 527 | #if MOVE_SCALED_OFFSET_TO_PPS |
|---|
| 528 | READ_UVLC( uiCode, "num_scaled_ref_layer_offsets" ); pcPPS->setNumScaledRefLayerOffsets(uiCode); |
|---|
| 529 | for(Int i = 0; i < pcPPS->getNumScaledRefLayerOffsets(); i++) |
|---|
| 530 | { |
|---|
| 531 | Window& scaledWindow = pcPPS->getScaledRefLayerWindow(i); |
|---|
| 532 | #if O0098_SCALED_REF_LAYER_ID |
|---|
| 533 | READ_CODE( 6, uiCode, "scaled_ref_layer_id" ); pcPPS->setScaledRefLayerId( i, uiCode ); |
|---|
| 534 | #endif |
|---|
| 535 | READ_SVLC( iCode, "scaled_ref_layer_left_offset" ); scaledWindow.setWindowLeftOffset (iCode << 1); |
|---|
| 536 | READ_SVLC( iCode, "scaled_ref_layer_top_offset" ); scaledWindow.setWindowTopOffset (iCode << 1); |
|---|
| 537 | READ_SVLC( iCode, "scaled_ref_layer_right_offset" ); scaledWindow.setWindowRightOffset (iCode << 1); |
|---|
| 538 | READ_SVLC( iCode, "scaled_ref_layer_bottom_offset" ); scaledWindow.setWindowBottomOffset(iCode << 1); |
|---|
| 539 | #if P0312_VERT_PHASE_ADJ |
|---|
| 540 | READ_FLAG( uiCode, "vert_phase_position_enable_flag" ); scaledWindow.setVertPhasePositionEnableFlag(uiCode); pcPPS->setVertPhasePositionEnableFlag( pcPPS->getScaledRefLayerId(i), uiCode); |
|---|
| 541 | #endif |
|---|
| 542 | } |
|---|
| 543 | #endif |
|---|
| 544 | #endif |
|---|
| 545 | #if Q0048_CGS_3D_ASYMLUT |
|---|
| 546 | READ_FLAG( uiCode , "colour_mapping_enabled_flag" ); |
|---|
| 547 | pcPPS->setCGSFlag( uiCode ); |
|---|
| 548 | if( pcPPS->getCGSFlag() ) |
|---|
| 549 | { |
|---|
| 550 | #if R0157_RESTRICT_PPSID_FOR_CGS_LUT |
|---|
| 551 | // when pps_pic_parameter_set_id greater than or equal to 8, colour_mapping_enabled_flag shall be equal to 0 |
|---|
| 552 | assert( pcPPS->getPPSId() < 8 ); |
|---|
| 553 | #endif |
|---|
| 554 | xParse3DAsymLUT( pc3DAsymLUT ); |
|---|
| 555 | pcPPS->setCGSOutputBitDepthY( pc3DAsymLUT->getOutputBitDepthY() ); |
|---|
| 556 | pcPPS->setCGSOutputBitDepthC( pc3DAsymLUT->getOutputBitDepthC() ); |
|---|
| 557 | } |
|---|
| 558 | #endif |
|---|
| 559 | } |
|---|
| 560 | #endif |
|---|
| 561 | |
|---|
| 562 | } |
|---|
| 563 | |
|---|
| 564 | Void TDecCavlc::parseVUI(TComVUI* pcVUI, TComSPS *pcSPS) |
|---|
| 565 | { |
|---|
| 566 | #if ENC_DEC_TRACE |
|---|
| 567 | fprintf( g_hTrace, "----------- vui_parameters -----------\n"); |
|---|
| 568 | #endif |
|---|
| 569 | UInt uiCode; |
|---|
| 570 | |
|---|
| 571 | READ_FLAG( uiCode, "aspect_ratio_info_present_flag"); pcVUI->setAspectRatioInfoPresentFlag(uiCode); |
|---|
| 572 | if (pcVUI->getAspectRatioInfoPresentFlag()) |
|---|
| 573 | { |
|---|
| 574 | READ_CODE(8, uiCode, "aspect_ratio_idc"); pcVUI->setAspectRatioIdc(uiCode); |
|---|
| 575 | if (pcVUI->getAspectRatioIdc() == 255) |
|---|
| 576 | { |
|---|
| 577 | READ_CODE(16, uiCode, "sar_width"); pcVUI->setSarWidth(uiCode); |
|---|
| 578 | READ_CODE(16, uiCode, "sar_height"); pcVUI->setSarHeight(uiCode); |
|---|
| 579 | } |
|---|
| 580 | } |
|---|
| 581 | |
|---|
| 582 | READ_FLAG( uiCode, "overscan_info_present_flag"); pcVUI->setOverscanInfoPresentFlag(uiCode); |
|---|
| 583 | if (pcVUI->getOverscanInfoPresentFlag()) |
|---|
| 584 | { |
|---|
| 585 | READ_FLAG( uiCode, "overscan_appropriate_flag"); pcVUI->setOverscanAppropriateFlag(uiCode); |
|---|
| 586 | } |
|---|
| 587 | |
|---|
| 588 | READ_FLAG( uiCode, "video_signal_type_present_flag"); pcVUI->setVideoSignalTypePresentFlag(uiCode); |
|---|
| 589 | if (pcVUI->getVideoSignalTypePresentFlag()) |
|---|
| 590 | { |
|---|
| 591 | READ_CODE(3, uiCode, "video_format"); pcVUI->setVideoFormat(uiCode); |
|---|
| 592 | READ_FLAG( uiCode, "video_full_range_flag"); pcVUI->setVideoFullRangeFlag(uiCode); |
|---|
| 593 | READ_FLAG( uiCode, "colour_description_present_flag"); pcVUI->setColourDescriptionPresentFlag(uiCode); |
|---|
| 594 | if (pcVUI->getColourDescriptionPresentFlag()) |
|---|
| 595 | { |
|---|
| 596 | READ_CODE(8, uiCode, "colour_primaries"); pcVUI->setColourPrimaries(uiCode); |
|---|
| 597 | READ_CODE(8, uiCode, "transfer_characteristics"); pcVUI->setTransferCharacteristics(uiCode); |
|---|
| 598 | READ_CODE(8, uiCode, "matrix_coefficients"); pcVUI->setMatrixCoefficients(uiCode); |
|---|
| 599 | } |
|---|
| 600 | } |
|---|
| 601 | |
|---|
| 602 | READ_FLAG( uiCode, "chroma_loc_info_present_flag"); pcVUI->setChromaLocInfoPresentFlag(uiCode); |
|---|
| 603 | if (pcVUI->getChromaLocInfoPresentFlag()) |
|---|
| 604 | { |
|---|
| 605 | READ_UVLC( uiCode, "chroma_sample_loc_type_top_field" ); pcVUI->setChromaSampleLocTypeTopField(uiCode); |
|---|
| 606 | READ_UVLC( uiCode, "chroma_sample_loc_type_bottom_field" ); pcVUI->setChromaSampleLocTypeBottomField(uiCode); |
|---|
| 607 | } |
|---|
| 608 | |
|---|
| 609 | READ_FLAG( uiCode, "neutral_chroma_indication_flag"); pcVUI->setNeutralChromaIndicationFlag(uiCode); |
|---|
| 610 | |
|---|
| 611 | READ_FLAG( uiCode, "field_seq_flag"); pcVUI->setFieldSeqFlag(uiCode); |
|---|
| 612 | |
|---|
| 613 | READ_FLAG(uiCode, "frame_field_info_present_flag"); pcVUI->setFrameFieldInfoPresentFlag(uiCode); |
|---|
| 614 | |
|---|
| 615 | READ_FLAG( uiCode, "default_display_window_flag"); |
|---|
| 616 | if (uiCode != 0) |
|---|
| 617 | { |
|---|
| 618 | Window &defDisp = pcVUI->getDefaultDisplayWindow(); |
|---|
| 619 | READ_UVLC( uiCode, "def_disp_win_left_offset" ); defDisp.setWindowLeftOffset ( uiCode * TComSPS::getWinUnitX( pcSPS->getChromaFormatIdc()) ); |
|---|
| 620 | READ_UVLC( uiCode, "def_disp_win_right_offset" ); defDisp.setWindowRightOffset ( uiCode * TComSPS::getWinUnitX( pcSPS->getChromaFormatIdc()) ); |
|---|
| 621 | READ_UVLC( uiCode, "def_disp_win_top_offset" ); defDisp.setWindowTopOffset ( uiCode * TComSPS::getWinUnitY( pcSPS->getChromaFormatIdc()) ); |
|---|
| 622 | READ_UVLC( uiCode, "def_disp_win_bottom_offset" ); defDisp.setWindowBottomOffset( uiCode * TComSPS::getWinUnitY( pcSPS->getChromaFormatIdc()) ); |
|---|
| 623 | } |
|---|
| 624 | TimingInfo *timingInfo = pcVUI->getTimingInfo(); |
|---|
| 625 | READ_FLAG( uiCode, "vui_timing_info_present_flag"); timingInfo->setTimingInfoPresentFlag (uiCode ? true : false); |
|---|
| 626 | #if SVC_EXTENSION |
|---|
| 627 | if( pcSPS->getLayerId() > 0 ) |
|---|
| 628 | { |
|---|
| 629 | assert( timingInfo->getTimingInfoPresentFlag() == false ); |
|---|
| 630 | } |
|---|
| 631 | #endif |
|---|
| 632 | if(timingInfo->getTimingInfoPresentFlag()) |
|---|
| 633 | { |
|---|
| 634 | READ_CODE( 32, uiCode, "vui_num_units_in_tick"); timingInfo->setNumUnitsInTick (uiCode); |
|---|
| 635 | READ_CODE( 32, uiCode, "vui_time_scale"); timingInfo->setTimeScale (uiCode); |
|---|
| 636 | READ_FLAG( uiCode, "vui_poc_proportional_to_timing_flag"); timingInfo->setPocProportionalToTimingFlag(uiCode ? true : false); |
|---|
| 637 | if(timingInfo->getPocProportionalToTimingFlag()) |
|---|
| 638 | { |
|---|
| 639 | READ_UVLC( uiCode, "vui_num_ticks_poc_diff_one_minus1"); timingInfo->setNumTicksPocDiffOneMinus1 (uiCode); |
|---|
| 640 | } |
|---|
| 641 | READ_FLAG( uiCode, "hrd_parameters_present_flag"); pcVUI->setHrdParametersPresentFlag(uiCode); |
|---|
| 642 | if( pcVUI->getHrdParametersPresentFlag() ) |
|---|
| 643 | { |
|---|
| 644 | parseHrdParameters( pcVUI->getHrdParameters(), 1, pcSPS->getMaxTLayers() - 1 ); |
|---|
| 645 | } |
|---|
| 646 | } |
|---|
| 647 | READ_FLAG( uiCode, "bitstream_restriction_flag"); pcVUI->setBitstreamRestrictionFlag(uiCode); |
|---|
| 648 | if (pcVUI->getBitstreamRestrictionFlag()) |
|---|
| 649 | { |
|---|
| 650 | READ_FLAG( uiCode, "tiles_fixed_structure_flag"); pcVUI->setTilesFixedStructureFlag(uiCode); |
|---|
| 651 | READ_FLAG( uiCode, "motion_vectors_over_pic_boundaries_flag"); pcVUI->setMotionVectorsOverPicBoundariesFlag(uiCode); |
|---|
| 652 | READ_FLAG( uiCode, "restricted_ref_pic_lists_flag"); pcVUI->setRestrictedRefPicListsFlag(uiCode); |
|---|
| 653 | READ_UVLC( uiCode, "min_spatial_segmentation_idc"); pcVUI->setMinSpatialSegmentationIdc(uiCode); |
|---|
| 654 | assert(uiCode < 4096); |
|---|
| 655 | READ_UVLC( uiCode, "max_bytes_per_pic_denom" ); pcVUI->setMaxBytesPerPicDenom(uiCode); |
|---|
| 656 | READ_UVLC( uiCode, "max_bits_per_mincu_denom" ); pcVUI->setMaxBitsPerMinCuDenom(uiCode); |
|---|
| 657 | READ_UVLC( uiCode, "log2_max_mv_length_horizontal" ); pcVUI->setLog2MaxMvLengthHorizontal(uiCode); |
|---|
| 658 | READ_UVLC( uiCode, "log2_max_mv_length_vertical" ); pcVUI->setLog2MaxMvLengthVertical(uiCode); |
|---|
| 659 | } |
|---|
| 660 | } |
|---|
| 661 | |
|---|
| 662 | Void TDecCavlc::parseHrdParameters(TComHRD *hrd, Bool commonInfPresentFlag, UInt maxNumSubLayersMinus1) |
|---|
| 663 | { |
|---|
| 664 | UInt uiCode; |
|---|
| 665 | if( commonInfPresentFlag ) |
|---|
| 666 | { |
|---|
| 667 | READ_FLAG( uiCode, "nal_hrd_parameters_present_flag" ); hrd->setNalHrdParametersPresentFlag( uiCode == 1 ? true : false ); |
|---|
| 668 | READ_FLAG( uiCode, "vcl_hrd_parameters_present_flag" ); hrd->setVclHrdParametersPresentFlag( uiCode == 1 ? true : false ); |
|---|
| 669 | if( hrd->getNalHrdParametersPresentFlag() || hrd->getVclHrdParametersPresentFlag() ) |
|---|
| 670 | { |
|---|
| 671 | READ_FLAG( uiCode, "sub_pic_cpb_params_present_flag" ); hrd->setSubPicCpbParamsPresentFlag( uiCode == 1 ? true : false ); |
|---|
| 672 | if( hrd->getSubPicCpbParamsPresentFlag() ) |
|---|
| 673 | { |
|---|
| 674 | READ_CODE( 8, uiCode, "tick_divisor_minus2" ); hrd->setTickDivisorMinus2( uiCode ); |
|---|
| 675 | READ_CODE( 5, uiCode, "du_cpb_removal_delay_length_minus1" ); hrd->setDuCpbRemovalDelayLengthMinus1( uiCode ); |
|---|
| 676 | READ_FLAG( uiCode, "sub_pic_cpb_params_in_pic_timing_sei_flag" ); hrd->setSubPicCpbParamsInPicTimingSEIFlag( uiCode == 1 ? true : false ); |
|---|
| 677 | READ_CODE( 5, uiCode, "dpb_output_delay_du_length_minus1" ); hrd->setDpbOutputDelayDuLengthMinus1( uiCode ); |
|---|
| 678 | } |
|---|
| 679 | READ_CODE( 4, uiCode, "bit_rate_scale" ); hrd->setBitRateScale( uiCode ); |
|---|
| 680 | READ_CODE( 4, uiCode, "cpb_size_scale" ); hrd->setCpbSizeScale( uiCode ); |
|---|
| 681 | if( hrd->getSubPicCpbParamsPresentFlag() ) |
|---|
| 682 | { |
|---|
| 683 | READ_CODE( 4, uiCode, "cpb_size_du_scale" ); hrd->setDuCpbSizeScale( uiCode ); |
|---|
| 684 | } |
|---|
| 685 | READ_CODE( 5, uiCode, "initial_cpb_removal_delay_length_minus1" ); hrd->setInitialCpbRemovalDelayLengthMinus1( uiCode ); |
|---|
| 686 | READ_CODE( 5, uiCode, "au_cpb_removal_delay_length_minus1" ); hrd->setCpbRemovalDelayLengthMinus1( uiCode ); |
|---|
| 687 | READ_CODE( 5, uiCode, "dpb_output_delay_length_minus1" ); hrd->setDpbOutputDelayLengthMinus1( uiCode ); |
|---|
| 688 | } |
|---|
| 689 | #if VPS_VUI_BSP_HRD_PARAMS |
|---|
| 690 | else |
|---|
| 691 | { |
|---|
| 692 | hrd->setInitialCpbRemovalDelayLengthMinus1( 23 ); |
|---|
| 693 | // Add inferred values for other syntax elements here. |
|---|
| 694 | } |
|---|
| 695 | #endif |
|---|
| 696 | } |
|---|
| 697 | Int i, j, nalOrVcl; |
|---|
| 698 | for( i = 0; i <= maxNumSubLayersMinus1; i ++ ) |
|---|
| 699 | { |
|---|
| 700 | READ_FLAG( uiCode, "fixed_pic_rate_general_flag" ); hrd->setFixedPicRateFlag( i, uiCode == 1 ? true : false ); |
|---|
| 701 | if( !hrd->getFixedPicRateFlag( i ) ) |
|---|
| 702 | { |
|---|
| 703 | READ_FLAG( uiCode, "fixed_pic_rate_within_cvs_flag" ); hrd->setFixedPicRateWithinCvsFlag( i, uiCode == 1 ? true : false ); |
|---|
| 704 | } |
|---|
| 705 | else |
|---|
| 706 | { |
|---|
| 707 | hrd->setFixedPicRateWithinCvsFlag( i, true ); |
|---|
| 708 | } |
|---|
| 709 | hrd->setLowDelayHrdFlag( i, 0 ); // Infered to be 0 when not present |
|---|
| 710 | hrd->setCpbCntMinus1 ( i, 0 ); // Infered to be 0 when not present |
|---|
| 711 | if( hrd->getFixedPicRateWithinCvsFlag( i ) ) |
|---|
| 712 | { |
|---|
| 713 | READ_UVLC( uiCode, "elemental_duration_in_tc_minus1" ); hrd->setPicDurationInTcMinus1( i, uiCode ); |
|---|
| 714 | } |
|---|
| 715 | else |
|---|
| 716 | { |
|---|
| 717 | READ_FLAG( uiCode, "low_delay_hrd_flag" ); hrd->setLowDelayHrdFlag( i, uiCode == 1 ? true : false ); |
|---|
| 718 | } |
|---|
| 719 | if (!hrd->getLowDelayHrdFlag( i )) |
|---|
| 720 | { |
|---|
| 721 | READ_UVLC( uiCode, "cpb_cnt_minus1" ); hrd->setCpbCntMinus1( i, uiCode ); |
|---|
| 722 | } |
|---|
| 723 | for( nalOrVcl = 0; nalOrVcl < 2; nalOrVcl ++ ) |
|---|
| 724 | { |
|---|
| 725 | if( ( ( nalOrVcl == 0 ) && ( hrd->getNalHrdParametersPresentFlag() ) ) || |
|---|
| 726 | ( ( nalOrVcl == 1 ) && ( hrd->getVclHrdParametersPresentFlag() ) ) ) |
|---|
| 727 | { |
|---|
| 728 | for( j = 0; j <= ( hrd->getCpbCntMinus1( i ) ); j ++ ) |
|---|
| 729 | { |
|---|
| 730 | READ_UVLC( uiCode, "bit_rate_value_minus1" ); hrd->setBitRateValueMinus1( i, j, nalOrVcl, uiCode ); |
|---|
| 731 | READ_UVLC( uiCode, "cpb_size_value_minus1" ); hrd->setCpbSizeValueMinus1( i, j, nalOrVcl, uiCode ); |
|---|
| 732 | if( hrd->getSubPicCpbParamsPresentFlag() ) |
|---|
| 733 | { |
|---|
| 734 | READ_UVLC( uiCode, "cpb_size_du_value_minus1" ); hrd->setDuCpbSizeValueMinus1( i, j, nalOrVcl, uiCode ); |
|---|
| 735 | READ_UVLC( uiCode, "bit_rate_du_value_minus1" ); hrd->setDuBitRateValueMinus1( i, j, nalOrVcl, uiCode ); |
|---|
| 736 | } |
|---|
| 737 | READ_FLAG( uiCode, "cbr_flag" ); hrd->setCbrFlag( i, j, nalOrVcl, uiCode == 1 ? true : false ); |
|---|
| 738 | } |
|---|
| 739 | } |
|---|
| 740 | } |
|---|
| 741 | } |
|---|
| 742 | } |
|---|
| 743 | |
|---|
| 744 | #if SVC_EXTENSION && !SPS_DPB_PARAMS |
|---|
| 745 | Void TDecCavlc::parseSPS(TComSPS* pcSPS, ParameterSetManagerDecoder *parameterSetManager) |
|---|
| 746 | #else |
|---|
| 747 | Void TDecCavlc::parseSPS(TComSPS* pcSPS) |
|---|
| 748 | #endif |
|---|
| 749 | { |
|---|
| 750 | #if ENC_DEC_TRACE |
|---|
| 751 | xTraceSPSHeader (pcSPS); |
|---|
| 752 | #endif |
|---|
| 753 | |
|---|
| 754 | #if R0042_PROFILE_INDICATION |
|---|
| 755 | UInt uiTmp = 0; |
|---|
| 756 | Bool bMultiLayerExtSpsFlag; |
|---|
| 757 | #endif |
|---|
| 758 | UInt uiCode; |
|---|
| 759 | READ_CODE( 4, uiCode, "sps_video_parameter_set_id"); pcSPS->setVPSId ( uiCode ); |
|---|
| 760 | #if SVC_EXTENSION |
|---|
| 761 | if(pcSPS->getLayerId() == 0) |
|---|
| 762 | { |
|---|
| 763 | #endif |
|---|
| 764 | READ_CODE( 3, uiCode, "sps_max_sub_layers_minus1" ); pcSPS->setMaxTLayers ( uiCode+1 ); |
|---|
| 765 | assert(uiCode <= 6); |
|---|
| 766 | #if SVC_EXTENSION |
|---|
| 767 | } |
|---|
| 768 | #if R0042_PROFILE_INDICATION |
|---|
| 769 | else |
|---|
| 770 | { |
|---|
| 771 | READ_CODE( 3, uiCode, "sps_ext_or_max_sub_layers_minus1" ); uiTmp = uiCode; |
|---|
| 772 | if(!( pcSPS->getLayerId() != 0 && uiTmp == 7 )) |
|---|
| 773 | { |
|---|
| 774 | pcSPS->setMaxTLayers(uiTmp+1); |
|---|
| 775 | } |
|---|
| 776 | } |
|---|
| 777 | #endif |
|---|
| 778 | #if !SPS_DPB_PARAMS |
|---|
| 779 | if(pcSPS->getLayerId() != 0) |
|---|
| 780 | { |
|---|
| 781 | pcSPS->setMaxTLayers ( parameterSetManager->getPrefetchedVPS(pcSPS->getVPSId())->getMaxTLayers() ); |
|---|
| 782 | } |
|---|
| 783 | #endif |
|---|
| 784 | #endif |
|---|
| 785 | |
|---|
| 786 | #if SVC_EXTENSION |
|---|
| 787 | #if R0042_PROFILE_INDICATION |
|---|
| 788 | bMultiLayerExtSpsFlag = ( pcSPS->getLayerId() != 0 && uiTmp == 7 ); |
|---|
| 789 | #endif |
|---|
| 790 | #endif |
|---|
| 791 | |
|---|
| 792 | #if SVC_EXTENSION |
|---|
| 793 | #if !R0042_PROFILE_INDICATION |
|---|
| 794 | if(pcSPS->getLayerId() == 0) |
|---|
| 795 | #else |
|---|
| 796 | if(!bMultiLayerExtSpsFlag) |
|---|
| 797 | #endif |
|---|
| 798 | { |
|---|
| 799 | #endif |
|---|
| 800 | READ_FLAG( uiCode, "sps_temporal_id_nesting_flag" ); pcSPS->setTemporalIdNestingFlag ( uiCode > 0 ? true : false ); |
|---|
| 801 | #if SVC_EXTENSION |
|---|
| 802 | } |
|---|
| 803 | #if !SPS_DPB_PARAMS |
|---|
| 804 | else |
|---|
| 805 | { |
|---|
| 806 | pcSPS->setTemporalIdNestingFlag( parameterSetManager->getPrefetchedVPS(pcSPS->getVPSId())->getTemporalNestingFlag() ); |
|---|
| 807 | } |
|---|
| 808 | #endif |
|---|
| 809 | #endif |
|---|
| 810 | |
|---|
| 811 | #if !Q0177_SPS_TEMP_NESTING_FIX //This part is not needed anymore as it is already covered by implementation in TDecTop::xActivateParameterSets() |
|---|
| 812 | if ( pcSPS->getMaxTLayers() == 1 ) |
|---|
| 813 | { |
|---|
| 814 | // sps_temporal_id_nesting_flag must be 1 when sps_max_sub_layers_minus1 is 0 |
|---|
| 815 | #if SVC_EXTENSION |
|---|
| 816 | #if !SPS_DPB_PARAMS |
|---|
| 817 | assert( pcSPS->getTemporalIdNestingFlag() == true ); |
|---|
| 818 | #endif |
|---|
| 819 | #else |
|---|
| 820 | assert( uiCode == 1 ); |
|---|
| 821 | #endif |
|---|
| 822 | } |
|---|
| 823 | #endif |
|---|
| 824 | |
|---|
| 825 | #ifdef SPS_PTL_FIX |
|---|
| 826 | #if !R0042_PROFILE_INDICATION |
|---|
| 827 | if ( pcSPS->getLayerId() == 0) |
|---|
| 828 | #else |
|---|
| 829 | if(!bMultiLayerExtSpsFlag) |
|---|
| 830 | #endif |
|---|
| 831 | { |
|---|
| 832 | parsePTL(pcSPS->getPTL(), 1, pcSPS->getMaxTLayers() - 1); |
|---|
| 833 | } |
|---|
| 834 | #else |
|---|
| 835 | parsePTL(pcSPS->getPTL(), 1, pcSPS->getMaxTLayers() - 1); |
|---|
| 836 | #endif |
|---|
| 837 | |
|---|
| 838 | READ_UVLC( uiCode, "sps_seq_parameter_set_id" ); pcSPS->setSPSId( uiCode ); |
|---|
| 839 | assert(uiCode <= 15); |
|---|
| 840 | |
|---|
| 841 | #if REPN_FORMAT_IN_VPS |
|---|
| 842 | #if !R0042_PROFILE_INDICATION |
|---|
| 843 | if( pcSPS->getLayerId() > 0 ) |
|---|
| 844 | #else |
|---|
| 845 | if( bMultiLayerExtSpsFlag) |
|---|
| 846 | #endif |
|---|
| 847 | { |
|---|
| 848 | READ_FLAG( uiCode, "update_rep_format_flag" ); |
|---|
| 849 | pcSPS->setUpdateRepFormatFlag( uiCode ? true : false ); |
|---|
| 850 | #if R0042_PROFILE_INDICATION |
|---|
| 851 | if( bMultiLayerExtSpsFlag && uiCode) |
|---|
| 852 | { |
|---|
| 853 | READ_CODE(8, uiCode, "sps_rep_format_idx"); |
|---|
| 854 | pcSPS->setUpdateRepFormatIndex(uiCode); |
|---|
| 855 | } |
|---|
| 856 | #endif |
|---|
| 857 | } |
|---|
| 858 | else |
|---|
| 859 | { |
|---|
| 860 | #if REP_FORMAT_FIX |
|---|
| 861 | pcSPS->setUpdateRepFormatFlag( false ); |
|---|
| 862 | #else |
|---|
| 863 | pcSPS->setUpdateRepFormatFlag( true ); |
|---|
| 864 | #endif |
|---|
| 865 | } |
|---|
| 866 | |
|---|
| 867 | #if R0042_PROFILE_INDICATION |
|---|
| 868 | if( !bMultiLayerExtSpsFlag ) |
|---|
| 869 | { |
|---|
| 870 | #else |
|---|
| 871 | #if O0096_REP_FORMAT_INDEX |
|---|
| 872 | if( pcSPS->getLayerId() == 0 ) |
|---|
| 873 | #else |
|---|
| 874 | if( pcSPS->getLayerId() == 0 || pcSPS->getUpdateRepFormatFlag() ) |
|---|
| 875 | #endif |
|---|
| 876 | #endif |
|---|
| 877 | { |
|---|
| 878 | #endif |
|---|
| 879 | #if AUXILIARY_PICTURES |
|---|
| 880 | READ_UVLC( uiCode, "chroma_format_idc" ); pcSPS->setChromaFormatIdc( ChromaFormat(uiCode) ); |
|---|
| 881 | #else |
|---|
| 882 | READ_UVLC( uiCode, "chroma_format_idc" ); pcSPS->setChromaFormatIdc( uiCode ); |
|---|
| 883 | #endif |
|---|
| 884 | assert(uiCode <= 3); |
|---|
| 885 | // 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 |
|---|
| 886 | assert (uiCode == 1); |
|---|
| 887 | if( uiCode == 3 ) |
|---|
| 888 | { |
|---|
| 889 | READ_FLAG( uiCode, "separate_colour_plane_flag"); assert(uiCode == 0); |
|---|
| 890 | } |
|---|
| 891 | |
|---|
| 892 | READ_UVLC ( uiCode, "pic_width_in_luma_samples" ); pcSPS->setPicWidthInLumaSamples ( uiCode ); |
|---|
| 893 | READ_UVLC ( uiCode, "pic_height_in_luma_samples" ); pcSPS->setPicHeightInLumaSamples( uiCode ); |
|---|
| 894 | #if REPN_FORMAT_IN_VPS |
|---|
| 895 | } |
|---|
| 896 | #if O0096_REP_FORMAT_INDEX |
|---|
| 897 | #if !R0042_PROFILE_INDICATION |
|---|
| 898 | else if ( pcSPS->getUpdateRepFormatFlag() ) |
|---|
| 899 | { |
|---|
| 900 | READ_CODE(8, uiCode, "update_rep_format_index"); |
|---|
| 901 | pcSPS->setUpdateRepFormatIndex(uiCode); |
|---|
| 902 | } |
|---|
| 903 | #endif |
|---|
| 904 | #endif |
|---|
| 905 | #endif |
|---|
| 906 | |
|---|
| 907 | #if R0156_CONF_WINDOW_IN_REP_FORMAT |
|---|
| 908 | #if REPN_FORMAT_IN_VPS |
|---|
| 909 | #if !R0042_PROFILE_INDICATION |
|---|
| 910 | #if O0096_REP_FORMAT_INDEX |
|---|
| 911 | if( pcSPS->getLayerId() == 0 ) |
|---|
| 912 | #else |
|---|
| 913 | if( pcSPS->getLayerId() == 0 || pcSPS->getUpdateRepFormatFlag() ) |
|---|
| 914 | #endif |
|---|
| 915 | #endif |
|---|
| 916 | { |
|---|
| 917 | #endif |
|---|
| 918 | #endif |
|---|
| 919 | READ_FLAG( uiCode, "conformance_window_flag"); |
|---|
| 920 | if (uiCode != 0) |
|---|
| 921 | { |
|---|
| 922 | Window &conf = pcSPS->getConformanceWindow(); |
|---|
| 923 | #if REPN_FORMAT_IN_VPS |
|---|
| 924 | READ_UVLC( uiCode, "conf_win_left_offset" ); conf.setWindowLeftOffset ( uiCode ); |
|---|
| 925 | READ_UVLC( uiCode, "conf_win_right_offset" ); conf.setWindowRightOffset ( uiCode ); |
|---|
| 926 | READ_UVLC( uiCode, "conf_win_top_offset" ); conf.setWindowTopOffset ( uiCode ); |
|---|
| 927 | READ_UVLC( uiCode, "conf_win_bottom_offset" ); conf.setWindowBottomOffset( uiCode ); |
|---|
| 928 | #else |
|---|
| 929 | READ_UVLC( uiCode, "conf_win_left_offset" ); conf.setWindowLeftOffset ( uiCode * TComSPS::getWinUnitX( pcSPS->getChromaFormatIdc() ) ); |
|---|
| 930 | READ_UVLC( uiCode, "conf_win_right_offset" ); conf.setWindowRightOffset ( uiCode * TComSPS::getWinUnitX( pcSPS->getChromaFormatIdc() ) ); |
|---|
| 931 | READ_UVLC( uiCode, "conf_win_top_offset" ); conf.setWindowTopOffset ( uiCode * TComSPS::getWinUnitY( pcSPS->getChromaFormatIdc() ) ); |
|---|
| 932 | READ_UVLC( uiCode, "conf_win_bottom_offset" ); conf.setWindowBottomOffset( uiCode * TComSPS::getWinUnitY( pcSPS->getChromaFormatIdc() ) ); |
|---|
| 933 | #endif |
|---|
| 934 | } |
|---|
| 935 | #if R0156_CONF_WINDOW_IN_REP_FORMAT |
|---|
| 936 | #if REPN_FORMAT_IN_VPS |
|---|
| 937 | } |
|---|
| 938 | #endif |
|---|
| 939 | #endif |
|---|
| 940 | |
|---|
| 941 | #if REPN_FORMAT_IN_VPS |
|---|
| 942 | #if !R0042_PROFILE_INDICATION |
|---|
| 943 | #if O0096_REP_FORMAT_INDEX |
|---|
| 944 | if( pcSPS->getLayerId() == 0 ) |
|---|
| 945 | #else |
|---|
| 946 | if( pcSPS->getLayerId() == 0 || pcSPS->getUpdateRepFormatFlag() ) |
|---|
| 947 | #endif |
|---|
| 948 | #endif |
|---|
| 949 | { |
|---|
| 950 | #endif |
|---|
| 951 | READ_UVLC( uiCode, "bit_depth_luma_minus8" ); |
|---|
| 952 | assert(uiCode <= 6); |
|---|
| 953 | pcSPS->setBitDepthY( uiCode + 8 ); |
|---|
| 954 | pcSPS->setQpBDOffsetY( (Int) (6*uiCode) ); |
|---|
| 955 | |
|---|
| 956 | READ_UVLC( uiCode, "bit_depth_chroma_minus8" ); |
|---|
| 957 | assert(uiCode <= 6); |
|---|
| 958 | pcSPS->setBitDepthC( uiCode + 8 ); |
|---|
| 959 | pcSPS->setQpBDOffsetC( (Int) (6*uiCode) ); |
|---|
| 960 | #if REPN_FORMAT_IN_VPS |
|---|
| 961 | } |
|---|
| 962 | #endif |
|---|
| 963 | #if R0042_PROFILE_INDICATION |
|---|
| 964 | } |
|---|
| 965 | #endif |
|---|
| 966 | |
|---|
| 967 | READ_UVLC( uiCode, "log2_max_pic_order_cnt_lsb_minus4" ); pcSPS->setBitsForPOC( 4 + uiCode ); |
|---|
| 968 | assert(uiCode <= 12); |
|---|
| 969 | |
|---|
| 970 | #if SPS_DPB_PARAMS |
|---|
| 971 | #if !R0042_PROFILE_INDICATION |
|---|
| 972 | if( pcSPS->getLayerId() == 0 ) |
|---|
| 973 | { |
|---|
| 974 | #else |
|---|
| 975 | if( !bMultiLayerExtSpsFlag ) |
|---|
| 976 | { |
|---|
| 977 | #endif |
|---|
| 978 | #endif |
|---|
| 979 | UInt subLayerOrderingInfoPresentFlag; |
|---|
| 980 | READ_FLAG(subLayerOrderingInfoPresentFlag, "sps_sub_layer_ordering_info_present_flag"); |
|---|
| 981 | |
|---|
| 982 | for(UInt i=0; i <= pcSPS->getMaxTLayers()-1; i++) |
|---|
| 983 | { |
|---|
| 984 | READ_UVLC ( uiCode, "sps_max_dec_pic_buffering_minus1[i]"); |
|---|
| 985 | pcSPS->setMaxDecPicBuffering( uiCode + 1, i); |
|---|
| 986 | READ_UVLC ( uiCode, "sps_num_reorder_pics[i]" ); |
|---|
| 987 | pcSPS->setNumReorderPics(uiCode, i); |
|---|
| 988 | READ_UVLC ( uiCode, "sps_max_latency_increase_plus1[i]"); |
|---|
| 989 | pcSPS->setMaxLatencyIncrease( uiCode, i ); |
|---|
| 990 | |
|---|
| 991 | if (!subLayerOrderingInfoPresentFlag) |
|---|
| 992 | { |
|---|
| 993 | for (i++; i <= pcSPS->getMaxTLayers()-1; i++) |
|---|
| 994 | { |
|---|
| 995 | pcSPS->setMaxDecPicBuffering(pcSPS->getMaxDecPicBuffering(0), i); |
|---|
| 996 | pcSPS->setNumReorderPics(pcSPS->getNumReorderPics(0), i); |
|---|
| 997 | pcSPS->setMaxLatencyIncrease(pcSPS->getMaxLatencyIncrease(0), i); |
|---|
| 998 | } |
|---|
| 999 | break; |
|---|
| 1000 | } |
|---|
| 1001 | } |
|---|
| 1002 | #if SPS_DPB_PARAMS |
|---|
| 1003 | } |
|---|
| 1004 | #endif |
|---|
| 1005 | READ_UVLC( uiCode, "log2_min_coding_block_size_minus3" ); |
|---|
| 1006 | Int log2MinCUSize = uiCode + 3; |
|---|
| 1007 | pcSPS->setLog2MinCodingBlockSize(log2MinCUSize); |
|---|
| 1008 | READ_UVLC( uiCode, "log2_diff_max_min_coding_block_size" ); |
|---|
| 1009 | pcSPS->setLog2DiffMaxMinCodingBlockSize(uiCode); |
|---|
| 1010 | |
|---|
| 1011 | if (pcSPS->getPTL()->getGeneralPTL()->getLevelIdc() >= Level::LEVEL5) |
|---|
| 1012 | { |
|---|
| 1013 | assert(log2MinCUSize + pcSPS->getLog2DiffMaxMinCodingBlockSize() >= 5); |
|---|
| 1014 | } |
|---|
| 1015 | |
|---|
| 1016 | Int maxCUDepthDelta = uiCode; |
|---|
| 1017 | pcSPS->setMaxCUWidth ( 1<<(log2MinCUSize + maxCUDepthDelta) ); |
|---|
| 1018 | pcSPS->setMaxCUHeight ( 1<<(log2MinCUSize + maxCUDepthDelta) ); |
|---|
| 1019 | READ_UVLC( uiCode, "log2_min_transform_block_size_minus2" ); pcSPS->setQuadtreeTULog2MinSize( uiCode + 2 ); |
|---|
| 1020 | |
|---|
| 1021 | READ_UVLC( uiCode, "log2_diff_max_min_transform_block_size" ); pcSPS->setQuadtreeTULog2MaxSize( uiCode + pcSPS->getQuadtreeTULog2MinSize() ); |
|---|
| 1022 | pcSPS->setMaxTrSize( 1<<(uiCode + pcSPS->getQuadtreeTULog2MinSize()) ); |
|---|
| 1023 | |
|---|
| 1024 | READ_UVLC( uiCode, "max_transform_hierarchy_depth_inter" ); pcSPS->setQuadtreeTUMaxDepthInter( uiCode+1 ); |
|---|
| 1025 | READ_UVLC( uiCode, "max_transform_hierarchy_depth_intra" ); pcSPS->setQuadtreeTUMaxDepthIntra( uiCode+1 ); |
|---|
| 1026 | |
|---|
| 1027 | Int addCuDepth = max (0, log2MinCUSize - (Int)pcSPS->getQuadtreeTULog2MinSize() ); |
|---|
| 1028 | pcSPS->setMaxCUDepth( maxCUDepthDelta + addCuDepth ); |
|---|
| 1029 | READ_FLAG( uiCode, "scaling_list_enabled_flag" ); pcSPS->setScalingListFlag ( uiCode ); |
|---|
| 1030 | |
|---|
| 1031 | if(pcSPS->getScalingListFlag()) |
|---|
| 1032 | { |
|---|
| 1033 | #if SCALINGLIST_INFERRING |
|---|
| 1034 | #if !R0042_PROFILE_INDICATION |
|---|
| 1035 | if( pcSPS->getLayerId() > 0 ) |
|---|
| 1036 | #else |
|---|
| 1037 | if( bMultiLayerExtSpsFlag ) |
|---|
| 1038 | #endif |
|---|
| 1039 | { |
|---|
| 1040 | READ_FLAG( uiCode, "sps_infer_scaling_list_flag" ); pcSPS->setInferScalingListFlag( uiCode ); |
|---|
| 1041 | } |
|---|
| 1042 | |
|---|
| 1043 | if( pcSPS->getInferScalingListFlag() ) |
|---|
| 1044 | { |
|---|
| 1045 | READ_CODE( 6, uiCode, "sps_scaling_list_ref_layer_id" ); pcSPS->setScalingListRefLayerId( uiCode ); |
|---|
| 1046 | |
|---|
| 1047 | // The value of sps_scaling_list_ref_layer_id shall be in the range of 0 to 62, inclusive |
|---|
| 1048 | assert( pcSPS->getScalingListRefLayerId() <= 62 ); |
|---|
| 1049 | |
|---|
| 1050 | pcSPS->setScalingListPresentFlag( false ); |
|---|
| 1051 | } |
|---|
| 1052 | else |
|---|
| 1053 | { |
|---|
| 1054 | #endif |
|---|
| 1055 | READ_FLAG( uiCode, "sps_scaling_list_data_present_flag" ); pcSPS->setScalingListPresentFlag ( uiCode ); |
|---|
| 1056 | if(pcSPS->getScalingListPresentFlag ()) |
|---|
| 1057 | { |
|---|
| 1058 | parseScalingList( pcSPS->getScalingList() ); |
|---|
| 1059 | } |
|---|
| 1060 | #if SCALINGLIST_INFERRING |
|---|
| 1061 | } |
|---|
| 1062 | #endif |
|---|
| 1063 | } |
|---|
| 1064 | READ_FLAG( uiCode, "amp_enabled_flag" ); pcSPS->setUseAMP( uiCode ); |
|---|
| 1065 | READ_FLAG( uiCode, "sample_adaptive_offset_enabled_flag" ); pcSPS->setUseSAO ( uiCode ? true : false ); |
|---|
| 1066 | |
|---|
| 1067 | READ_FLAG( uiCode, "pcm_enabled_flag" ); pcSPS->setUsePCM( uiCode ? true : false ); |
|---|
| 1068 | if( pcSPS->getUsePCM() ) |
|---|
| 1069 | { |
|---|
| 1070 | READ_CODE( 4, uiCode, "pcm_sample_bit_depth_luma_minus1" ); pcSPS->setPCMBitDepthLuma ( 1 + uiCode ); |
|---|
| 1071 | READ_CODE( 4, uiCode, "pcm_sample_bit_depth_chroma_minus1" ); pcSPS->setPCMBitDepthChroma ( 1 + uiCode ); |
|---|
| 1072 | READ_UVLC( uiCode, "log2_min_pcm_luma_coding_block_size_minus3" ); pcSPS->setPCMLog2MinSize (uiCode+3); |
|---|
| 1073 | READ_UVLC( uiCode, "log2_diff_max_min_pcm_luma_coding_block_size" ); pcSPS->setPCMLog2MaxSize ( uiCode+pcSPS->getPCMLog2MinSize() ); |
|---|
| 1074 | READ_FLAG( uiCode, "pcm_loop_filter_disable_flag" ); pcSPS->setPCMFilterDisableFlag ( uiCode ? true : false ); |
|---|
| 1075 | } |
|---|
| 1076 | |
|---|
| 1077 | READ_UVLC( uiCode, "num_short_term_ref_pic_sets" ); |
|---|
| 1078 | assert(uiCode <= 64); |
|---|
| 1079 | pcSPS->createRPSList(uiCode); |
|---|
| 1080 | |
|---|
| 1081 | TComRPSList* rpsList = pcSPS->getRPSList(); |
|---|
| 1082 | TComReferencePictureSet* rps; |
|---|
| 1083 | |
|---|
| 1084 | for(UInt i=0; i< rpsList->getNumberOfReferencePictureSets(); i++) |
|---|
| 1085 | { |
|---|
| 1086 | rps = rpsList->getReferencePictureSet(i); |
|---|
| 1087 | parseShortTermRefPicSet(pcSPS,rps,i); |
|---|
| 1088 | } |
|---|
| 1089 | READ_FLAG( uiCode, "long_term_ref_pics_present_flag" ); pcSPS->setLongTermRefsPresent(uiCode); |
|---|
| 1090 | if (pcSPS->getLongTermRefsPresent()) |
|---|
| 1091 | { |
|---|
| 1092 | READ_UVLC( uiCode, "num_long_term_ref_pic_sps" ); |
|---|
| 1093 | pcSPS->setNumLongTermRefPicSPS(uiCode); |
|---|
| 1094 | for (UInt k = 0; k < pcSPS->getNumLongTermRefPicSPS(); k++) |
|---|
| 1095 | { |
|---|
| 1096 | READ_CODE( pcSPS->getBitsForPOC(), uiCode, "lt_ref_pic_poc_lsb_sps" ); |
|---|
| 1097 | pcSPS->setLtRefPicPocLsbSps(k, uiCode); |
|---|
| 1098 | READ_FLAG( uiCode, "used_by_curr_pic_lt_sps_flag[i]"); |
|---|
| 1099 | pcSPS->setUsedByCurrPicLtSPSFlag(k, uiCode?1:0); |
|---|
| 1100 | } |
|---|
| 1101 | } |
|---|
| 1102 | READ_FLAG( uiCode, "sps_temporal_mvp_enable_flag" ); pcSPS->setTMVPFlagsPresent(uiCode); |
|---|
| 1103 | READ_FLAG( uiCode, "sps_strong_intra_smoothing_enable_flag" ); pcSPS->setUseStrongIntraSmoothing(uiCode); |
|---|
| 1104 | |
|---|
| 1105 | READ_FLAG( uiCode, "vui_parameters_present_flag" ); pcSPS->setVuiParametersPresentFlag(uiCode); |
|---|
| 1106 | |
|---|
| 1107 | if (pcSPS->getVuiParametersPresentFlag()) |
|---|
| 1108 | { |
|---|
| 1109 | parseVUI(pcSPS->getVuiParameters(), pcSPS); |
|---|
| 1110 | } |
|---|
| 1111 | |
|---|
| 1112 | READ_FLAG( uiCode, "sps_extension_flag"); |
|---|
| 1113 | |
|---|
| 1114 | #if SVC_EXTENSION |
|---|
| 1115 | pcSPS->setExtensionFlag( uiCode ? true : false ); |
|---|
| 1116 | |
|---|
| 1117 | if( pcSPS->getExtensionFlag() ) |
|---|
| 1118 | { |
|---|
| 1119 | #if !R0042_PROFILE_INDICATION |
|---|
| 1120 | #if O0142_CONDITIONAL_SPS_EXTENSION |
|---|
| 1121 | UInt spsExtensionTypeFlag[8]; |
|---|
| 1122 | for (UInt i = 0; i < 8; i++) |
|---|
| 1123 | { |
|---|
| 1124 | READ_FLAG( spsExtensionTypeFlag[i], "sps_extension_type_flag" ); |
|---|
| 1125 | } |
|---|
| 1126 | if (spsExtensionTypeFlag[1]) |
|---|
| 1127 | { |
|---|
| 1128 | parseSPSExtension( pcSPS ); |
|---|
| 1129 | } |
|---|
| 1130 | if (spsExtensionTypeFlag[7]) |
|---|
| 1131 | { |
|---|
| 1132 | #else |
|---|
| 1133 | parseSPSExtension( pcSPS ); |
|---|
| 1134 | READ_FLAG( uiCode, "sps_extension2_flag"); |
|---|
| 1135 | if(uiCode) |
|---|
| 1136 | { |
|---|
| 1137 | #endif |
|---|
| 1138 | while ( xMoreRbspData() ) |
|---|
| 1139 | { |
|---|
| 1140 | READ_FLAG( uiCode, "sps_extension_data_flag"); |
|---|
| 1141 | } |
|---|
| 1142 | } |
|---|
| 1143 | } |
|---|
| 1144 | #else |
|---|
| 1145 | READ_FLAG( uiCode, "sps_range_extension_flag" ); |
|---|
| 1146 | assert(uiCode == 0); |
|---|
| 1147 | READ_FLAG( uiCode, "sps_multilayer_extension_flag" ); |
|---|
| 1148 | assert(uiCode == 1); |
|---|
| 1149 | READ_CODE(6, uiCode, "sps_extension_6bits"); |
|---|
| 1150 | assert(uiCode == 0); |
|---|
| 1151 | parseSPSExtension( pcSPS ); |
|---|
| 1152 | } |
|---|
| 1153 | #endif |
|---|
| 1154 | #else |
|---|
| 1155 | if (uiCode) |
|---|
| 1156 | { |
|---|
| 1157 | while ( xMoreRbspData() ) |
|---|
| 1158 | { |
|---|
| 1159 | READ_FLAG( uiCode, "sps_extension_data_flag"); |
|---|
| 1160 | } |
|---|
| 1161 | } |
|---|
| 1162 | #endif |
|---|
| 1163 | } |
|---|
| 1164 | |
|---|
| 1165 | #if SVC_EXTENSION |
|---|
| 1166 | Void TDecCavlc::parseSPSExtension( TComSPS* pcSPS ) |
|---|
| 1167 | { |
|---|
| 1168 | UInt uiCode; |
|---|
| 1169 | // more syntax elements to be parsed here |
|---|
| 1170 | |
|---|
| 1171 | READ_FLAG( uiCode, "inter_view_mv_vert_constraint_flag" ); |
|---|
| 1172 | // Vertical MV component restriction is not used in SHVC CTC |
|---|
| 1173 | assert( uiCode == 0 ); |
|---|
| 1174 | |
|---|
| 1175 | #if !MOVE_SCALED_OFFSET_TO_PPS |
|---|
| 1176 | if( pcSPS->getLayerId() > 0 ) |
|---|
| 1177 | { |
|---|
| 1178 | Int iCode; |
|---|
| 1179 | READ_UVLC( uiCode, "num_scaled_ref_layer_offsets" ); pcSPS->setNumScaledRefLayerOffsets(uiCode); |
|---|
| 1180 | for(Int i = 0; i < pcSPS->getNumScaledRefLayerOffsets(); i++) |
|---|
| 1181 | { |
|---|
| 1182 | Window& scaledWindow = pcSPS->getScaledRefLayerWindow(i); |
|---|
| 1183 | #if O0098_SCALED_REF_LAYER_ID |
|---|
| 1184 | READ_CODE( 6, uiCode, "scaled_ref_layer_id" ); pcSPS->setScaledRefLayerId( i, uiCode ); |
|---|
| 1185 | #endif |
|---|
| 1186 | READ_SVLC( iCode, "scaled_ref_layer_left_offset" ); scaledWindow.setWindowLeftOffset (iCode << 1); |
|---|
| 1187 | READ_SVLC( iCode, "scaled_ref_layer_top_offset" ); scaledWindow.setWindowTopOffset (iCode << 1); |
|---|
| 1188 | READ_SVLC( iCode, "scaled_ref_layer_right_offset" ); scaledWindow.setWindowRightOffset (iCode << 1); |
|---|
| 1189 | READ_SVLC( iCode, "scaled_ref_layer_bottom_offset" ); scaledWindow.setWindowBottomOffset(iCode << 1); |
|---|
| 1190 | #if P0312_VERT_PHASE_ADJ |
|---|
| 1191 | READ_FLAG( uiCode, "vert_phase_position_enable_flag" ); scaledWindow.setVertPhasePositionEnableFlag(uiCode); pcSPS->setVertPhasePositionEnableFlag( pcSPS->getScaledRefLayerId(i), uiCode); |
|---|
| 1192 | #endif |
|---|
| 1193 | } |
|---|
| 1194 | } |
|---|
| 1195 | #endif |
|---|
| 1196 | } |
|---|
| 1197 | #endif |
|---|
| 1198 | |
|---|
| 1199 | Void TDecCavlc::parseVPS(TComVPS* pcVPS) |
|---|
| 1200 | { |
|---|
| 1201 | UInt uiCode; |
|---|
| 1202 | |
|---|
| 1203 | READ_CODE( 4, uiCode, "vps_video_parameter_set_id" ); pcVPS->setVPSId( uiCode ); |
|---|
| 1204 | #if VPS_RESERVED_FLAGS |
|---|
| 1205 | READ_FLAG( uiCode, "vps_base_layer_internal_flag"); pcVPS->setBaseLayerInternalFlag( uiCode ? true : false ); |
|---|
| 1206 | READ_FLAG( uiCode, "vps_base_layer_available_flag"); pcVPS->setBaseLayerAvailableFlag( uiCode ? true : false ); |
|---|
| 1207 | #if VPS_AVC_BL_FLAG_REMOVAL |
|---|
| 1208 | pcVPS->setNonHEVCBaseLayerFlag( (pcVPS->getBaseLayerAvailableFlag() && !pcVPS->getBaseLayerInternalFlag()) ? true : false); |
|---|
| 1209 | #endif |
|---|
| 1210 | #else |
|---|
| 1211 | READ_CODE( 2, uiCode, "vps_reserved_three_2bits" ); assert(uiCode == 3); |
|---|
| 1212 | #endif |
|---|
| 1213 | #if SVC_EXTENSION |
|---|
| 1214 | #if O0137_MAX_LAYERID |
|---|
| 1215 | READ_CODE( 6, uiCode, "vps_max_layers_minus1" ); pcVPS->setMaxLayers( min( 62u, uiCode) + 1 ); |
|---|
| 1216 | #else |
|---|
| 1217 | READ_CODE( 6, uiCode, "vps_max_layers_minus1" ); pcVPS->setMaxLayers( uiCode + 1 ); |
|---|
| 1218 | #endif |
|---|
| 1219 | #else |
|---|
| 1220 | READ_CODE( 6, uiCode, "vps_reserved_zero_6bits" ); assert(uiCode == 0); |
|---|
| 1221 | #endif |
|---|
| 1222 | READ_CODE( 3, uiCode, "vps_max_sub_layers_minus1" ); pcVPS->setMaxTLayers( uiCode + 1 ); assert(uiCode+1 <= MAX_TLAYER); |
|---|
| 1223 | READ_FLAG( uiCode, "vps_temporal_id_nesting_flag" ); pcVPS->setTemporalNestingFlag( uiCode ? true:false ); |
|---|
| 1224 | assert (pcVPS->getMaxTLayers()>1||pcVPS->getTemporalNestingFlag()); |
|---|
| 1225 | #if !P0125_REVERT_VPS_EXTN_OFFSET_TO_RESERVED |
|---|
| 1226 | #if VPS_EXTN_OFFSET |
|---|
| 1227 | READ_CODE( 16, uiCode, "vps_extension_offset" ); pcVPS->setExtensionOffset( uiCode ); |
|---|
| 1228 | #else |
|---|
| 1229 | READ_CODE( 16, uiCode, "vps_reserved_ffff_16bits" ); assert(uiCode == 0xffff); |
|---|
| 1230 | #endif |
|---|
| 1231 | #else |
|---|
| 1232 | READ_CODE( 16, uiCode, "vps_reserved_ffff_16bits" ); assert(uiCode == 0xffff); |
|---|
| 1233 | #endif |
|---|
| 1234 | parsePTL ( pcVPS->getPTL(), true, pcVPS->getMaxTLayers()-1); |
|---|
| 1235 | UInt subLayerOrderingInfoPresentFlag; |
|---|
| 1236 | READ_FLAG(subLayerOrderingInfoPresentFlag, "vps_sub_layer_ordering_info_present_flag"); |
|---|
| 1237 | for(UInt i = 0; i <= pcVPS->getMaxTLayers()-1; i++) |
|---|
| 1238 | { |
|---|
| 1239 | READ_UVLC( uiCode, "vps_max_dec_pic_buffering_minus1[i]" ); pcVPS->setMaxDecPicBuffering( uiCode + 1, i ); |
|---|
| 1240 | READ_UVLC( uiCode, "vps_num_reorder_pics[i]" ); pcVPS->setNumReorderPics( uiCode, i ); |
|---|
| 1241 | READ_UVLC( uiCode, "vps_max_latency_increase_plus1[i]" ); pcVPS->setMaxLatencyIncrease( uiCode, i ); |
|---|
| 1242 | |
|---|
| 1243 | if (!subLayerOrderingInfoPresentFlag) |
|---|
| 1244 | { |
|---|
| 1245 | for (i++; i <= pcVPS->getMaxTLayers()-1; i++) |
|---|
| 1246 | { |
|---|
| 1247 | pcVPS->setMaxDecPicBuffering(pcVPS->getMaxDecPicBuffering(0), i); |
|---|
| 1248 | pcVPS->setNumReorderPics(pcVPS->getNumReorderPics(0), i); |
|---|
| 1249 | pcVPS->setMaxLatencyIncrease(pcVPS->getMaxLatencyIncrease(0), i); |
|---|
| 1250 | } |
|---|
| 1251 | break; |
|---|
| 1252 | } |
|---|
| 1253 | } |
|---|
| 1254 | |
|---|
| 1255 | #if SVC_EXTENSION |
|---|
| 1256 | assert( pcVPS->getNumHrdParameters() < MAX_VPS_LAYER_SETS_PLUS1 ); |
|---|
| 1257 | assert( pcVPS->getMaxLayerId() < MAX_VPS_LAYER_ID_PLUS1 ); |
|---|
| 1258 | READ_CODE( 6, uiCode, "vps_max_layer_id" ); pcVPS->setMaxLayerId( uiCode ); |
|---|
| 1259 | #if Q0078_ADD_LAYER_SETS |
|---|
| 1260 | READ_UVLC(uiCode, "vps_num_layer_sets_minus1"); pcVPS->setVpsNumLayerSetsMinus1(uiCode); |
|---|
| 1261 | pcVPS->setNumLayerSets(pcVPS->getVpsNumLayerSetsMinus1() + 1); |
|---|
| 1262 | for (UInt opsIdx = 1; opsIdx <= pcVPS->getVpsNumLayerSetsMinus1(); opsIdx++) |
|---|
| 1263 | #else |
|---|
| 1264 | READ_UVLC( uiCode, "vps_num_layer_sets_minus1" ); pcVPS->setNumLayerSets( uiCode + 1 ); |
|---|
| 1265 | for( UInt opsIdx = 1; opsIdx <= ( pcVPS->getNumLayerSets() - 1 ); opsIdx ++ ) |
|---|
| 1266 | #endif |
|---|
| 1267 | { |
|---|
| 1268 | // Operation point set |
|---|
| 1269 | for( UInt i = 0; i <= pcVPS->getMaxLayerId(); i ++ ) |
|---|
| 1270 | #else |
|---|
| 1271 | assert( pcVPS->getNumHrdParameters() < MAX_VPS_OP_SETS_PLUS1 ); |
|---|
| 1272 | assert( pcVPS->getMaxNuhReservedZeroLayerId() < MAX_VPS_NUH_RESERVED_ZERO_LAYER_ID_PLUS1 ); |
|---|
| 1273 | READ_CODE( 6, uiCode, "vps_max_nuh_reserved_zero_layer_id" ); pcVPS->setMaxNuhReservedZeroLayerId( uiCode ); |
|---|
| 1274 | READ_UVLC( uiCode, "vps_max_op_sets_minus1" ); pcVPS->setMaxOpSets( uiCode + 1 ); |
|---|
| 1275 | for( UInt opsIdx = 1; opsIdx <= ( pcVPS->getMaxOpSets() - 1 ); opsIdx ++ ) |
|---|
| 1276 | { |
|---|
| 1277 | // Operation point set |
|---|
| 1278 | for( UInt i = 0; i <= pcVPS->getMaxNuhReservedZeroLayerId(); i ++ ) |
|---|
| 1279 | #endif |
|---|
| 1280 | { |
|---|
| 1281 | READ_FLAG( uiCode, "layer_id_included_flag[opsIdx][i]" ); pcVPS->setLayerIdIncludedFlag( uiCode == 1 ? true : false, opsIdx, i ); |
|---|
| 1282 | } |
|---|
| 1283 | } |
|---|
| 1284 | #if DERIVE_LAYER_ID_LIST_VARIABLES |
|---|
| 1285 | pcVPS->deriveLayerIdListVariables(); |
|---|
| 1286 | #endif |
|---|
| 1287 | TimingInfo *timingInfo = pcVPS->getTimingInfo(); |
|---|
| 1288 | READ_FLAG( uiCode, "vps_timing_info_present_flag"); timingInfo->setTimingInfoPresentFlag (uiCode ? true : false); |
|---|
| 1289 | if(timingInfo->getTimingInfoPresentFlag()) |
|---|
| 1290 | { |
|---|
| 1291 | READ_CODE( 32, uiCode, "vps_num_units_in_tick"); timingInfo->setNumUnitsInTick (uiCode); |
|---|
| 1292 | READ_CODE( 32, uiCode, "vps_time_scale"); timingInfo->setTimeScale (uiCode); |
|---|
| 1293 | READ_FLAG( uiCode, "vps_poc_proportional_to_timing_flag"); timingInfo->setPocProportionalToTimingFlag(uiCode ? true : false); |
|---|
| 1294 | if(timingInfo->getPocProportionalToTimingFlag()) |
|---|
| 1295 | { |
|---|
| 1296 | READ_UVLC( uiCode, "vps_num_ticks_poc_diff_one_minus1"); timingInfo->setNumTicksPocDiffOneMinus1 (uiCode); |
|---|
| 1297 | } |
|---|
| 1298 | READ_UVLC( uiCode, "vps_num_hrd_parameters" ); pcVPS->setNumHrdParameters( uiCode ); |
|---|
| 1299 | |
|---|
| 1300 | if( pcVPS->getNumHrdParameters() > 0 ) |
|---|
| 1301 | { |
|---|
| 1302 | pcVPS->createHrdParamBuffer(); |
|---|
| 1303 | } |
|---|
| 1304 | for( UInt i = 0; i < pcVPS->getNumHrdParameters(); i ++ ) |
|---|
| 1305 | { |
|---|
| 1306 | READ_UVLC( uiCode, "hrd_op_set_idx" ); pcVPS->setHrdOpSetIdx( uiCode, i ); |
|---|
| 1307 | if( i > 0 ) |
|---|
| 1308 | { |
|---|
| 1309 | READ_FLAG( uiCode, "cprms_present_flag[i]" ); pcVPS->setCprmsPresentFlag( uiCode == 1 ? true : false, i ); |
|---|
| 1310 | } |
|---|
| 1311 | else |
|---|
| 1312 | { |
|---|
| 1313 | pcVPS->setCprmsPresentFlag( true, i ); |
|---|
| 1314 | } |
|---|
| 1315 | |
|---|
| 1316 | parseHrdParameters(pcVPS->getHrdParameters(i), pcVPS->getCprmsPresentFlag( i ), pcVPS->getMaxTLayers() - 1); |
|---|
| 1317 | } |
|---|
| 1318 | } |
|---|
| 1319 | |
|---|
| 1320 | #if SVC_EXTENSION |
|---|
| 1321 | READ_FLAG( uiCode, "vps_extension_flag" ); pcVPS->setVpsExtensionFlag( uiCode ? true : false ); |
|---|
| 1322 | |
|---|
| 1323 | // When MaxLayersMinus1 is greater than 0, vps_extension_flag shall be equal to 1. |
|---|
| 1324 | if( pcVPS->getMaxLayers() > 1 ) |
|---|
| 1325 | { |
|---|
| 1326 | assert( pcVPS->getVpsExtensionFlag() == true ); |
|---|
| 1327 | } |
|---|
| 1328 | |
|---|
| 1329 | if( pcVPS->getVpsExtensionFlag() ) |
|---|
| 1330 | { |
|---|
| 1331 | while ( m_pcBitstream->getNumBitsRead() % 8 != 0 ) |
|---|
| 1332 | { |
|---|
| 1333 | READ_FLAG( uiCode, "vps_extension_alignment_bit_equal_to_one"); assert(uiCode == 1); |
|---|
| 1334 | } |
|---|
| 1335 | parseVPSExtension(pcVPS); |
|---|
| 1336 | READ_FLAG( uiCode, "vps_entension2_flag" ); |
|---|
| 1337 | if(uiCode) |
|---|
| 1338 | { |
|---|
| 1339 | while ( xMoreRbspData() ) |
|---|
| 1340 | { |
|---|
| 1341 | READ_FLAG( uiCode, "vps_extension_data_flag"); |
|---|
| 1342 | } |
|---|
| 1343 | } |
|---|
| 1344 | } |
|---|
| 1345 | else |
|---|
| 1346 | { |
|---|
| 1347 | // set default parameters when syntax elements are not present |
|---|
| 1348 | defaultVPSExtension(pcVPS); |
|---|
| 1349 | } |
|---|
| 1350 | #else |
|---|
| 1351 | READ_FLAG( uiCode, "vps_extension_flag" ); |
|---|
| 1352 | if (uiCode) |
|---|
| 1353 | { |
|---|
| 1354 | while ( xMoreRbspData() ) |
|---|
| 1355 | { |
|---|
| 1356 | READ_FLAG( uiCode, "vps_extension_data_flag"); |
|---|
| 1357 | } |
|---|
| 1358 | } |
|---|
| 1359 | #endif |
|---|
| 1360 | |
|---|
| 1361 | return; |
|---|
| 1362 | } |
|---|
| 1363 | |
|---|
| 1364 | #if SVC_EXTENSION |
|---|
| 1365 | Void TDecCavlc::parseVPSExtension(TComVPS *vps) |
|---|
| 1366 | { |
|---|
| 1367 | UInt uiCode; |
|---|
| 1368 | // ... More syntax elements to be parsed here |
|---|
| 1369 | #if P0300_ALT_OUTPUT_LAYER_FLAG |
|---|
| 1370 | Int NumOutputLayersInOutputLayerSet[MAX_VPS_LAYER_SETS_PLUS1]; |
|---|
| 1371 | Int OlsHighestOutputLayerId[MAX_VPS_LAYER_SETS_PLUS1]; |
|---|
| 1372 | #endif |
|---|
| 1373 | #if LIST_OF_PTL |
|---|
| 1374 | if( vps->getMaxLayers() > 1 && vps->getBaseLayerInternalFlag() ) |
|---|
| 1375 | { |
|---|
| 1376 | vps->setProfilePresentFlag(1, false); |
|---|
| 1377 | #if MULTIPLE_PTL_SUPPORT |
|---|
| 1378 | parsePTL( vps->getPTL(1), vps->getProfilePresentFlag(1), vps->getMaxTLayers() - 1 ); |
|---|
| 1379 | #else |
|---|
| 1380 | vps->getPTLForExtnPtr()->empty(); |
|---|
| 1381 | vps->getPTLForExtnPtr()->resize(2); |
|---|
| 1382 | vps->getPTLForExtn(1)->copyProfileInfo( vps->getPTL() ); |
|---|
| 1383 | parsePTL( vps->getPTLForExtn(1), vps->getProfilePresentFlag(1), vps->getMaxTLayers() - 1 ); |
|---|
| 1384 | #endif |
|---|
| 1385 | } |
|---|
| 1386 | #endif |
|---|
| 1387 | #if VPS_EXTN_MASK_AND_DIM_INFO |
|---|
| 1388 | UInt numScalabilityTypes = 0, i = 0, j = 0; |
|---|
| 1389 | |
|---|
| 1390 | #if !VPS_AVC_BL_FLAG_REMOVAL |
|---|
| 1391 | READ_FLAG( uiCode, "avc_base_layer_flag" ); vps->setAvcBaseLayerFlag(uiCode ? true : false); |
|---|
| 1392 | #endif |
|---|
| 1393 | |
|---|
| 1394 | #if !P0307_REMOVE_VPS_VUI_OFFSET |
|---|
| 1395 | #if O0109_MOVE_VPS_VUI_FLAG |
|---|
| 1396 | READ_FLAG( uiCode, "vps_vui_present_flag"); vps->setVpsVuiPresentFlag(uiCode ? true : false); |
|---|
| 1397 | if ( uiCode ) |
|---|
| 1398 | { |
|---|
| 1399 | #endif |
|---|
| 1400 | #if VPS_VUI_OFFSET |
|---|
| 1401 | READ_CODE( 16, uiCode, "vps_vui_offset" ); vps->setVpsVuiOffset( uiCode ); |
|---|
| 1402 | #endif |
|---|
| 1403 | #if O0109_MOVE_VPS_VUI_FLAG |
|---|
| 1404 | } |
|---|
| 1405 | #endif |
|---|
| 1406 | #endif |
|---|
| 1407 | READ_FLAG( uiCode, "splitting_flag" ); vps->setSplittingFlag(uiCode ? true : false); |
|---|
| 1408 | |
|---|
| 1409 | for(i = 0; i < MAX_VPS_NUM_SCALABILITY_TYPES; i++) |
|---|
| 1410 | { |
|---|
| 1411 | READ_FLAG( uiCode, "scalability_mask[i]" ); vps->setScalabilityMask(i, uiCode ? true : false); |
|---|
| 1412 | numScalabilityTypes += uiCode; |
|---|
| 1413 | } |
|---|
| 1414 | vps->setNumScalabilityTypes(numScalabilityTypes); |
|---|
| 1415 | |
|---|
| 1416 | for(j = 0; j < numScalabilityTypes - vps->getSplittingFlag(); j++) |
|---|
| 1417 | { |
|---|
| 1418 | READ_CODE( 3, uiCode, "dimension_id_len_minus1[j]" ); vps->setDimensionIdLen(j, uiCode + 1); |
|---|
| 1419 | } |
|---|
| 1420 | |
|---|
| 1421 | // The value of dimBitOffset[ NumScalabilityTypes ] is set equal to 6. |
|---|
| 1422 | if(vps->getSplittingFlag()) |
|---|
| 1423 | { |
|---|
| 1424 | UInt numBits = 0; |
|---|
| 1425 | for(j = 0; j < numScalabilityTypes - 1; j++) |
|---|
| 1426 | { |
|---|
| 1427 | numBits += vps->getDimensionIdLen(j); |
|---|
| 1428 | } |
|---|
| 1429 | assert( numBits < 6 ); |
|---|
| 1430 | vps->setDimensionIdLen(numScalabilityTypes-1, 6 - numBits); |
|---|
| 1431 | numBits = 6; |
|---|
| 1432 | } |
|---|
| 1433 | |
|---|
| 1434 | READ_FLAG( uiCode, "vps_nuh_layer_id_present_flag" ); vps->setNuhLayerIdPresentFlag(uiCode ? true : false); |
|---|
| 1435 | vps->setLayerIdInNuh(0, 0); |
|---|
| 1436 | vps->setLayerIdInVps(0, 0); |
|---|
| 1437 | for(i = 1; i < vps->getMaxLayers(); i++) |
|---|
| 1438 | { |
|---|
| 1439 | if( vps->getNuhLayerIdPresentFlag() ) |
|---|
| 1440 | { |
|---|
| 1441 | READ_CODE( 6, uiCode, "layer_id_in_nuh[i]" ); vps->setLayerIdInNuh(i, uiCode); |
|---|
| 1442 | assert( uiCode > vps->getLayerIdInNuh(i-1) ); |
|---|
| 1443 | } |
|---|
| 1444 | else |
|---|
| 1445 | { |
|---|
| 1446 | vps->setLayerIdInNuh(i, i); |
|---|
| 1447 | } |
|---|
| 1448 | vps->setLayerIdInVps(vps->getLayerIdInNuh(i), i); |
|---|
| 1449 | |
|---|
| 1450 | if( !vps->getSplittingFlag() ) |
|---|
| 1451 | { |
|---|
| 1452 | for(j = 0; j < numScalabilityTypes; j++) |
|---|
| 1453 | { |
|---|
| 1454 | READ_CODE( vps->getDimensionIdLen(j), uiCode, "dimension_id[i][j]" ); vps->setDimensionId(i, j, uiCode); |
|---|
| 1455 | #if !AUXILIARY_PICTURES |
|---|
| 1456 | assert( uiCode <= vps->getMaxLayerId() ); |
|---|
| 1457 | #endif |
|---|
| 1458 | } |
|---|
| 1459 | } |
|---|
| 1460 | } |
|---|
| 1461 | #endif |
|---|
| 1462 | #if VIEW_ID_RELATED_SIGNALING |
|---|
| 1463 | // if ( pcVPS->getNumViews() > 1 ) |
|---|
| 1464 | // However, this is a bug in the text since, view_id_len_minus1 is needed to parse view_id_val. |
|---|
| 1465 | { |
|---|
| 1466 | #if O0109_VIEW_ID_LEN |
|---|
| 1467 | READ_CODE( 4, uiCode, "view_id_len" ); vps->setViewIdLen( uiCode ); |
|---|
| 1468 | #else |
|---|
| 1469 | READ_CODE( 4, uiCode, "view_id_len_minus1" ); vps->setViewIdLenMinus1( uiCode ); |
|---|
| 1470 | #endif |
|---|
| 1471 | } |
|---|
| 1472 | |
|---|
| 1473 | #if O0109_VIEW_ID_LEN |
|---|
| 1474 | if ( vps->getViewIdLen() > 0 ) |
|---|
| 1475 | { |
|---|
| 1476 | for( i = 0; i < vps->getNumViews(); i++ ) |
|---|
| 1477 | { |
|---|
| 1478 | READ_CODE( vps->getViewIdLen( ), uiCode, "view_id_val[i]" ); vps->setViewIdVal( i, uiCode ); |
|---|
| 1479 | } |
|---|
| 1480 | } |
|---|
| 1481 | #else |
|---|
| 1482 | for( i = 0; i < vps->getNumViews(); i++ ) |
|---|
| 1483 | { |
|---|
| 1484 | READ_CODE( vps->getViewIdLenMinus1( ) + 1, uiCode, "view_id_val[i]" ); vps->setViewIdVal( i, uiCode ); |
|---|
| 1485 | } |
|---|
| 1486 | #endif |
|---|
| 1487 | #endif // view id related signaling |
|---|
| 1488 | #if VPS_EXTN_DIRECT_REF_LAYERS |
|---|
| 1489 | // For layer 0 |
|---|
| 1490 | vps->setNumDirectRefLayers(0, 0); |
|---|
| 1491 | // For other layers |
|---|
| 1492 | for( Int layerCtr = 1; layerCtr <= vps->getMaxLayers() - 1; layerCtr++) |
|---|
| 1493 | { |
|---|
| 1494 | UInt numDirectRefLayers = 0; |
|---|
| 1495 | for( Int refLayerCtr = 0; refLayerCtr < layerCtr; refLayerCtr++) |
|---|
| 1496 | { |
|---|
| 1497 | READ_FLAG(uiCode, "direct_dependency_flag[i][j]" ); vps->setDirectDependencyFlag(layerCtr, refLayerCtr, uiCode? true : false); |
|---|
| 1498 | if(uiCode) |
|---|
| 1499 | { |
|---|
| 1500 | vps->setRefLayerId(layerCtr, numDirectRefLayers, refLayerCtr); |
|---|
| 1501 | numDirectRefLayers++; |
|---|
| 1502 | } |
|---|
| 1503 | } |
|---|
| 1504 | vps->setNumDirectRefLayers(layerCtr, numDirectRefLayers); |
|---|
| 1505 | } |
|---|
| 1506 | #endif |
|---|
| 1507 | #if Q0078_ADD_LAYER_SETS |
|---|
| 1508 | #if O0092_0094_DEPENDENCY_CONSTRAINT // Moved here |
|---|
| 1509 | vps->setNumRefLayers(); |
|---|
| 1510 | |
|---|
| 1511 | if (vps->getMaxLayers() > MAX_REF_LAYERS) |
|---|
| 1512 | { |
|---|
| 1513 | for (i = 1; i < vps->getMaxLayers(); i++) |
|---|
| 1514 | { |
|---|
| 1515 | assert(vps->getNumRefLayers(vps->getLayerIdInNuh(i)) <= MAX_REF_LAYERS); |
|---|
| 1516 | } |
|---|
| 1517 | } |
|---|
| 1518 | #endif |
|---|
| 1519 | vps->setPredictedLayerIds(); |
|---|
| 1520 | vps->setTreePartitionLayerIdList(); |
|---|
| 1521 | #endif |
|---|
| 1522 | #if MOVE_ADDN_LS_SIGNALLING |
|---|
| 1523 | #if Q0078_ADD_LAYER_SETS |
|---|
| 1524 | if (vps->getNumIndependentLayers() > 1) |
|---|
| 1525 | { |
|---|
| 1526 | READ_UVLC(uiCode, "num_add_layer_sets"); vps->setNumAddLayerSets(uiCode); |
|---|
| 1527 | for (i = 0; i < vps->getNumAddLayerSets(); i++) |
|---|
| 1528 | { |
|---|
| 1529 | for (j = 1; j < vps->getNumIndependentLayers(); j++) |
|---|
| 1530 | { |
|---|
| 1531 | int len = 1; |
|---|
| 1532 | while ((1 << len) < (vps->getNumLayersInTreePartition(j) + 1)) |
|---|
| 1533 | { |
|---|
| 1534 | len++; |
|---|
| 1535 | } |
|---|
| 1536 | READ_CODE(len, uiCode, "highest_layer_idx_plus1[i][j]"); vps->setHighestLayerIdxPlus1(i, j, uiCode); |
|---|
| 1537 | } |
|---|
| 1538 | } |
|---|
| 1539 | vps->setNumLayerSets(vps->getNumLayerSets() + vps->getNumAddLayerSets()); |
|---|
| 1540 | #if FIX_LAYER_ID_INIT |
|---|
| 1541 | vps->deriveLayerIdListVariablesForAddLayerSets(); |
|---|
| 1542 | #else |
|---|
| 1543 | vps->setLayerIdIncludedFlagsForAddLayerSets(); |
|---|
| 1544 | #endif |
|---|
| 1545 | } |
|---|
| 1546 | #endif |
|---|
| 1547 | #endif |
|---|
| 1548 | #if VPS_TSLAYERS |
|---|
| 1549 | READ_FLAG( uiCode, "vps_sub_layers_max_minus1_present_flag"); vps->setMaxTSLayersPresentFlag(uiCode ? true : false); |
|---|
| 1550 | |
|---|
| 1551 | if (vps->getMaxTSLayersPresentFlag()) |
|---|
| 1552 | { |
|---|
| 1553 | for(i = 0; i < vps->getMaxLayers(); i++) |
|---|
| 1554 | { |
|---|
| 1555 | READ_CODE( 3, uiCode, "sub_layers_vps_max_minus1[i]" ); vps->setMaxTSLayersMinus1(i, uiCode); |
|---|
| 1556 | } |
|---|
| 1557 | } |
|---|
| 1558 | else |
|---|
| 1559 | { |
|---|
| 1560 | for( i = 0; i < vps->getMaxLayers(); i++) |
|---|
| 1561 | { |
|---|
| 1562 | vps->setMaxTSLayersMinus1(i, vps->getMaxTLayers()-1); |
|---|
| 1563 | } |
|---|
| 1564 | } |
|---|
| 1565 | #endif |
|---|
| 1566 | READ_FLAG( uiCode, "max_tid_ref_present_flag"); vps->setMaxTidRefPresentFlag(uiCode ? true : false); |
|---|
| 1567 | if (vps->getMaxTidRefPresentFlag()) |
|---|
| 1568 | { |
|---|
| 1569 | for(i = 0; i < vps->getMaxLayers() - 1; i++) |
|---|
| 1570 | { |
|---|
| 1571 | #if O0225_MAX_TID_FOR_REF_LAYERS |
|---|
| 1572 | for( j = i+1; j <= vps->getMaxLayers() - 1; j++) |
|---|
| 1573 | { |
|---|
| 1574 | if(vps->getDirectDependencyFlag(j, i)) |
|---|
| 1575 | { |
|---|
| 1576 | READ_CODE( 3, uiCode, "max_tid_il_ref_pics_plus1[i][j]" ); vps->setMaxTidIlRefPicsPlus1(i, j, uiCode); |
|---|
| 1577 | } |
|---|
| 1578 | } |
|---|
| 1579 | #else |
|---|
| 1580 | READ_CODE( 3, uiCode, "max_tid_il_ref_pics_plus1[i]" ); vps->setMaxTidIlRefPicsPlus1(i, uiCode); |
|---|
| 1581 | assert( uiCode <= vps->getMaxTLayers()); |
|---|
| 1582 | #endif |
|---|
| 1583 | } |
|---|
| 1584 | } |
|---|
| 1585 | else |
|---|
| 1586 | { |
|---|
| 1587 | for(i = 0; i < vps->getMaxLayers() - 1; i++) |
|---|
| 1588 | { |
|---|
| 1589 | #if O0225_MAX_TID_FOR_REF_LAYERS |
|---|
| 1590 | for( j = i+1; j <= vps->getMaxLayers() - 1; j++) |
|---|
| 1591 | { |
|---|
| 1592 | vps->setMaxTidIlRefPicsPlus1(i, j, 7); |
|---|
| 1593 | } |
|---|
| 1594 | #else |
|---|
| 1595 | vps->setMaxTidIlRefPicsPlus1(i, 7); |
|---|
| 1596 | #endif |
|---|
| 1597 | } |
|---|
| 1598 | } |
|---|
| 1599 | READ_FLAG( uiCode, "all_ref_layers_active_flag" ); vps->setIlpSshSignalingEnabledFlag(uiCode ? true : false); |
|---|
| 1600 | #if VPS_EXTN_PROFILE_INFO |
|---|
| 1601 | // Profile-tier-level signalling |
|---|
| 1602 | #if !VPS_EXTN_UEV_CODING |
|---|
| 1603 | READ_CODE( 10, uiCode, "vps_number_layer_sets_minus1" ); assert( uiCode == (vps->getNumLayerSets() - 1) ); |
|---|
| 1604 | READ_CODE( 6, uiCode, "vps_num_profile_tier_level_minus1"); vps->setNumProfileTierLevel( uiCode + 1 ); |
|---|
| 1605 | #else |
|---|
| 1606 | READ_UVLC( uiCode, "vps_num_profile_tier_level_minus1"); vps->setNumProfileTierLevel( uiCode + 1 ); |
|---|
| 1607 | #endif |
|---|
| 1608 | #if PER_LAYER_PTL |
|---|
| 1609 | Int const numBitsForPtlIdx = vps->calculateLenOfSyntaxElement( vps->getNumProfileTierLevel() ); |
|---|
| 1610 | #endif |
|---|
| 1611 | #if !MULTIPLE_PTL_SUPPORT |
|---|
| 1612 | vps->getPTLForExtnPtr()->resize(vps->getNumProfileTierLevel()); |
|---|
| 1613 | #endif |
|---|
| 1614 | #if LIST_OF_PTL |
|---|
| 1615 | for(Int idx = vps->getBaseLayerInternalFlag() ? 2 : 1; idx <= vps->getNumProfileTierLevel() - 1; idx++) |
|---|
| 1616 | #else |
|---|
| 1617 | for(Int idx = 1; idx <= vps->getNumProfileTierLevel() - 1; idx++) |
|---|
| 1618 | #endif |
|---|
| 1619 | { |
|---|
| 1620 | READ_FLAG( uiCode, "vps_profile_present_flag[i]" ); |
|---|
| 1621 | vps->setProfilePresentFlag(idx, uiCode ? true : false); |
|---|
| 1622 | if( !vps->getProfilePresentFlag(idx) ) |
|---|
| 1623 | { |
|---|
| 1624 | #if P0048_REMOVE_PROFILE_REF |
|---|
| 1625 | // Copy profile information from previous one |
|---|
| 1626 | #if MULTIPLE_PTL_SUPPORT |
|---|
| 1627 | vps->getPTL(idx)->copyProfileInfo( vps->getPTL( idx - 1 ) ); |
|---|
| 1628 | #else |
|---|
| 1629 | vps->getPTLForExtn(idx)->copyProfileInfo( (idx==1) ? vps->getPTL() : vps->getPTLForExtn( idx - 1 ) ); |
|---|
| 1630 | #endif |
|---|
| 1631 | #else |
|---|
| 1632 | READ_CODE( 6, uiCode, "profile_ref_minus1[i]" ); vps->setProfileLayerSetRef(idx, uiCode + 1); |
|---|
| 1633 | #if O0109_PROF_REF_MINUS1 |
|---|
| 1634 | assert( vps->getProfileLayerSetRef(idx) <= idx ); |
|---|
| 1635 | #else |
|---|
| 1636 | assert( vps->getProfileLayerSetRef(idx) < idx ); |
|---|
| 1637 | #endif |
|---|
| 1638 | // Copy profile information as indicated |
|---|
| 1639 | vps->getPTLForExtn(idx)->copyProfileInfo( vps->getPTLForExtn( vps->getProfileLayerSetRef(idx) ) ); |
|---|
| 1640 | #endif |
|---|
| 1641 | } |
|---|
| 1642 | #if MULTIPLE_PTL_SUPPORT |
|---|
| 1643 | parsePTL( vps->getPTL(idx), vps->getProfilePresentFlag(idx), vps->getMaxTLayers() - 1 ); |
|---|
| 1644 | #else |
|---|
| 1645 | parsePTL( vps->getPTLForExtn(idx), vps->getProfilePresentFlag(idx), vps->getMaxTLayers() - 1 ); |
|---|
| 1646 | #endif |
|---|
| 1647 | } |
|---|
| 1648 | #endif |
|---|
| 1649 | |
|---|
| 1650 | #if !MOVE_ADDN_LS_SIGNALLING |
|---|
| 1651 | #if Q0078_ADD_LAYER_SETS |
|---|
| 1652 | if (vps->getNumIndependentLayers() > 1) |
|---|
| 1653 | { |
|---|
| 1654 | READ_UVLC(uiCode, "num_add_layer_sets"); vps->setNumAddLayerSets(uiCode); |
|---|
| 1655 | for (i = 0; i < vps->getNumAddLayerSets(); i++) |
|---|
| 1656 | { |
|---|
| 1657 | for (j = 1; j < vps->getNumIndependentLayers(); j++) |
|---|
| 1658 | { |
|---|
| 1659 | int len = 1; |
|---|
| 1660 | while ((1 << len) < (vps->getNumLayersInTreePartition(j) + 1)) |
|---|
| 1661 | { |
|---|
| 1662 | len++; |
|---|
| 1663 | } |
|---|
| 1664 | READ_CODE(len, uiCode, "highest_layer_idx_plus1[i][j]"); vps->setHighestLayerIdxPlus1(i, j, uiCode); |
|---|
| 1665 | } |
|---|
| 1666 | } |
|---|
| 1667 | vps->setNumLayerSets(vps->getNumLayerSets() + vps->getNumAddLayerSets()); |
|---|
| 1668 | vps->setLayerIdIncludedFlagsForAddLayerSets(); |
|---|
| 1669 | } |
|---|
| 1670 | #endif |
|---|
| 1671 | #endif |
|---|
| 1672 | |
|---|
| 1673 | #if !VPS_EXTN_UEV_CODING |
|---|
| 1674 | READ_FLAG( uiCode, "more_output_layer_sets_than_default_flag" ); vps->setMoreOutputLayerSetsThanDefaultFlag( uiCode ? true : false ); |
|---|
| 1675 | Int numOutputLayerSets = 0; |
|---|
| 1676 | if(! vps->getMoreOutputLayerSetsThanDefaultFlag() ) |
|---|
| 1677 | { |
|---|
| 1678 | numOutputLayerSets = vps->getNumLayerSets(); |
|---|
| 1679 | } |
|---|
| 1680 | else |
|---|
| 1681 | { |
|---|
| 1682 | READ_CODE( 10, uiCode, "num_add_output_layer_sets" ); vps->setNumAddOutputLayerSets( uiCode ); |
|---|
| 1683 | numOutputLayerSets = vps->getNumLayerSets() + vps->getNumAddOutputLayerSets(); |
|---|
| 1684 | } |
|---|
| 1685 | #else |
|---|
| 1686 | |
|---|
| 1687 | #if Q0165_NUM_ADD_OUTPUT_LAYER_SETS |
|---|
| 1688 | if( vps->getNumLayerSets() > 1 ) |
|---|
| 1689 | { |
|---|
| 1690 | READ_UVLC( uiCode, "num_add_olss" ); vps->setNumAddOutputLayerSets( uiCode ); |
|---|
| 1691 | READ_CODE( 2, uiCode, "default_output_layer_idc" ); vps->setDefaultTargetOutputLayerIdc( uiCode ); |
|---|
| 1692 | } |
|---|
| 1693 | else |
|---|
| 1694 | { |
|---|
| 1695 | vps->setNumAddOutputLayerSets( 0 ); |
|---|
| 1696 | } |
|---|
| 1697 | #else |
|---|
| 1698 | READ_UVLC( uiCode, "num_add_output_layer_sets" ); vps->setNumAddOutputLayerSets( uiCode ); |
|---|
| 1699 | #endif |
|---|
| 1700 | |
|---|
| 1701 | // The value of num_add_olss shall be in the range of 0 to 1023, inclusive. |
|---|
| 1702 | assert( vps->getNumAddOutputLayerSets() >= 0 && vps->getNumAddOutputLayerSets() < 1024 ); |
|---|
| 1703 | |
|---|
| 1704 | Int numOutputLayerSets = vps->getNumLayerSets() + vps->getNumAddOutputLayerSets(); |
|---|
| 1705 | #endif |
|---|
| 1706 | |
|---|
| 1707 | #if P0295_DEFAULT_OUT_LAYER_IDC |
|---|
| 1708 | #if !Q0165_NUM_ADD_OUTPUT_LAYER_SETS |
|---|
| 1709 | if( numOutputLayerSets > 1 ) |
|---|
| 1710 | { |
|---|
| 1711 | READ_CODE( 2, uiCode, "default_target_output_layer_idc" ); vps->setDefaultTargetOutputLayerIdc( uiCode ); |
|---|
| 1712 | } |
|---|
| 1713 | #endif |
|---|
| 1714 | vps->setNumOutputLayerSets( numOutputLayerSets ); |
|---|
| 1715 | #if NECESSARY_LAYER_FLAG |
|---|
| 1716 | // Default output layer set |
|---|
| 1717 | vps->setOutputLayerSetIdx(0, 0); |
|---|
| 1718 | vps->setOutputLayerFlag(0, 0, true); |
|---|
| 1719 | vps->deriveNecessaryLayerFlag(0); |
|---|
| 1720 | #if PER_LAYER_PTL |
|---|
| 1721 | vps->getProfileLevelTierIdx()->resize(numOutputLayerSets); |
|---|
| 1722 | vps->getProfileLevelTierIdx(0)->push_back( vps->getBaseLayerInternalFlag() && vps->getMaxLayers() > 1 ? 1 : 0); |
|---|
| 1723 | #endif |
|---|
| 1724 | #endif |
|---|
| 1725 | for(i = 1; i < numOutputLayerSets; i++) |
|---|
| 1726 | { |
|---|
| 1727 | if( i > (vps->getNumLayerSets() - 1) ) |
|---|
| 1728 | { |
|---|
| 1729 | Int numBits = 1; |
|---|
| 1730 | while ((1 << numBits) < (vps->getNumLayerSets() - 1)) |
|---|
| 1731 | { |
|---|
| 1732 | numBits++; |
|---|
| 1733 | } |
|---|
| 1734 | READ_CODE( numBits, uiCode, "layer_set_idx_for_ols_minus1"); vps->setOutputLayerSetIdx( i, uiCode + 1); |
|---|
| 1735 | } |
|---|
| 1736 | else |
|---|
| 1737 | { |
|---|
| 1738 | vps->setOutputLayerSetIdx( i, i ); |
|---|
| 1739 | } |
|---|
| 1740 | Int layerSetIdxForOutputLayerSet = vps->getOutputLayerSetIdx(i); |
|---|
| 1741 | #if Q0078_ADD_LAYER_SETS |
|---|
| 1742 | if ( i > vps->getVpsNumLayerSetsMinus1() || vps->getDefaultTargetOutputLayerIdc() >= 2 ) |
|---|
| 1743 | #else |
|---|
| 1744 | if ( i > (vps->getNumLayerSets() - 1) || vps->getDefaultTargetOutputLayerIdc() >= 2 ) |
|---|
| 1745 | #endif |
|---|
| 1746 | { |
|---|
| 1747 | #if NUM_OL_FLAGS |
|---|
| 1748 | for(j = 0; j < vps->getNumLayersInIdList(layerSetIdxForOutputLayerSet); j++) |
|---|
| 1749 | #else |
|---|
| 1750 | for(j = 0; j < vps->getNumLayersInIdList(lsIdx) - 1; j++) |
|---|
| 1751 | #endif |
|---|
| 1752 | { |
|---|
| 1753 | READ_FLAG( uiCode, "output_layer_flag[i][j]"); vps->setOutputLayerFlag(i, j, uiCode); |
|---|
| 1754 | } |
|---|
| 1755 | } |
|---|
| 1756 | else |
|---|
| 1757 | { |
|---|
| 1758 | // i <= (vps->getNumLayerSets() - 1) |
|---|
| 1759 | // Assign OutputLayerFlag depending on default_one_target_output_layer_flag |
|---|
| 1760 | if( vps->getDefaultTargetOutputLayerIdc() == 1 ) |
|---|
| 1761 | { |
|---|
| 1762 | for(j = 0; j < vps->getNumLayersInIdList(layerSetIdxForOutputLayerSet); j++) |
|---|
| 1763 | { |
|---|
| 1764 | #if DEF_OPT_LAYER_IDC |
|---|
| 1765 | vps->setOutputLayerFlag(i, j, (j == (vps->getNumLayersInIdList(layerSetIdxForOutputLayerSet)-1)) ); |
|---|
| 1766 | |
|---|
| 1767 | #else |
|---|
| 1768 | vps->setOutputLayerFlag(i, j, (j == (vps->getNumLayersInIdList(layerSetIdxForOutputLayerSet)-1)) && (vps->getDimensionId(j,1) == 0) ); |
|---|
| 1769 | #endif |
|---|
| 1770 | } |
|---|
| 1771 | } |
|---|
| 1772 | else if ( vps->getDefaultTargetOutputLayerIdc() == 0 ) |
|---|
| 1773 | { |
|---|
| 1774 | for(j = 0; j < vps->getNumLayersInIdList(layerSetIdxForOutputLayerSet); j++) |
|---|
| 1775 | { |
|---|
| 1776 | vps->setOutputLayerFlag(i, j, 1); |
|---|
| 1777 | } |
|---|
| 1778 | } |
|---|
| 1779 | } |
|---|
| 1780 | #if NECESSARY_LAYER_FLAG |
|---|
| 1781 | vps->deriveNecessaryLayerFlag(i); |
|---|
| 1782 | #endif |
|---|
| 1783 | #if PER_LAYER_PTL |
|---|
| 1784 | vps->getProfileLevelTierIdx(i)->assign(vps->getNumLayersInIdList(layerSetIdxForOutputLayerSet), -1); |
|---|
| 1785 | for(j = 0; j < vps->getNumLayersInIdList(layerSetIdxForOutputLayerSet) ; j++) |
|---|
| 1786 | { |
|---|
| 1787 | if( vps->getNecessaryLayerFlag(i, j) ) |
|---|
| 1788 | { |
|---|
| 1789 | READ_CODE( numBitsForPtlIdx, uiCode, "profile_level_tier_idx[i]" ); |
|---|
| 1790 | vps->setProfileLevelTierIdx(i, j, uiCode ); |
|---|
| 1791 | } |
|---|
| 1792 | } |
|---|
| 1793 | #else |
|---|
| 1794 | Int numBits = 1; |
|---|
| 1795 | while ((1 << numBits) < (vps->getNumProfileTierLevel())) |
|---|
| 1796 | { |
|---|
| 1797 | numBits++; |
|---|
| 1798 | } |
|---|
| 1799 | READ_CODE( numBits, uiCode, "profile_level_tier_idx[i]" ); vps->setProfileLevelTierIdx(i, uiCode); |
|---|
| 1800 | #endif |
|---|
| 1801 | #if P0300_ALT_OUTPUT_LAYER_FLAG |
|---|
| 1802 | NumOutputLayersInOutputLayerSet[i] = 0; |
|---|
| 1803 | for (j = 0; j < vps->getNumLayersInIdList(layerSetIdxForOutputLayerSet); j++) |
|---|
| 1804 | { |
|---|
| 1805 | NumOutputLayersInOutputLayerSet[i] += vps->getOutputLayerFlag(i, j); |
|---|
| 1806 | if (vps->getOutputLayerFlag(i, j)) |
|---|
| 1807 | { |
|---|
| 1808 | OlsHighestOutputLayerId[i] = vps->getLayerSetLayerIdList(layerSetIdxForOutputLayerSet, j); |
|---|
| 1809 | } |
|---|
| 1810 | } |
|---|
| 1811 | if (NumOutputLayersInOutputLayerSet[i] == 1 && vps->getNumDirectRefLayers(OlsHighestOutputLayerId[i]) > 0) |
|---|
| 1812 | { |
|---|
| 1813 | READ_FLAG(uiCode, "alt_output_layer_flag[i]"); |
|---|
| 1814 | vps->setAltOuputLayerFlag(i, uiCode ? true : false); |
|---|
| 1815 | } |
|---|
| 1816 | #if ALT_OPT_LAYER_FLAG |
|---|
| 1817 | else |
|---|
| 1818 | { |
|---|
| 1819 | uiCode=0; |
|---|
| 1820 | vps->setAltOuputLayerFlag(i, uiCode ? true : false); |
|---|
| 1821 | } |
|---|
| 1822 | #endif |
|---|
| 1823 | #if Q0165_OUTPUT_LAYER_SET |
|---|
| 1824 | assert( NumOutputLayersInOutputLayerSet[i]>0 ); |
|---|
| 1825 | #endif |
|---|
| 1826 | |
|---|
| 1827 | #endif |
|---|
| 1828 | } |
|---|
| 1829 | #if NECESSARY_LAYER_FLAG |
|---|
| 1830 | vps->checkNecessaryLayerFlagCondition(); |
|---|
| 1831 | #endif |
|---|
| 1832 | #else |
|---|
| 1833 | if( numOutputLayerSets > 1 ) |
|---|
| 1834 | { |
|---|
| 1835 | #if O0109_DEFAULT_ONE_OUT_LAYER_IDC |
|---|
| 1836 | READ_CODE( 2, uiCode, "default_one_target_output_layer_idc" ); vps->setDefaultOneTargetOutputLayerIdc( uiCode ); |
|---|
| 1837 | #else |
|---|
| 1838 | READ_FLAG( uiCode, "default_one_target_output_layer_flag" ); vps->setDefaultOneTargetOutputLayerFlag( uiCode ? true : false ); |
|---|
| 1839 | #endif |
|---|
| 1840 | } |
|---|
| 1841 | vps->setNumOutputLayerSets( numOutputLayerSets ); |
|---|
| 1842 | |
|---|
| 1843 | for(i = 1; i < numOutputLayerSets; i++) |
|---|
| 1844 | { |
|---|
| 1845 | if( i > (vps->getNumLayerSets() - 1) ) |
|---|
| 1846 | { |
|---|
| 1847 | Int numBits = 1; |
|---|
| 1848 | while ((1 << numBits) < (vps->getNumLayerSets() - 1)) |
|---|
| 1849 | { |
|---|
| 1850 | numBits++; |
|---|
| 1851 | } |
|---|
| 1852 | READ_CODE( numBits, uiCode, "output_layer_set_idx_minus1"); vps->setOutputLayerSetIdx( i, uiCode + 1); |
|---|
| 1853 | Int lsIdx = vps->getOutputLayerSetIdx(i); |
|---|
| 1854 | #if NUM_OL_FLAGS |
|---|
| 1855 | for(j = 0; j < vps->getNumLayersInIdList(lsIdx) ; j++) |
|---|
| 1856 | #else |
|---|
| 1857 | for(j = 0; j < vps->getNumLayersInIdList(lsIdx) - 1; j++) |
|---|
| 1858 | #endif |
|---|
| 1859 | { |
|---|
| 1860 | READ_FLAG( uiCode, "output_layer_flag[i][j]"); vps->setOutputLayerFlag(i, j, uiCode); |
|---|
| 1861 | } |
|---|
| 1862 | } |
|---|
| 1863 | else |
|---|
| 1864 | { |
|---|
| 1865 | #if VPS_DPB_SIZE_TABLE |
|---|
| 1866 | vps->setOutputLayerSetIdx( i, i ); |
|---|
| 1867 | #endif |
|---|
| 1868 | // i <= (vps->getNumLayerSets() - 1) |
|---|
| 1869 | // Assign OutputLayerFlag depending on default_one_target_output_layer_flag |
|---|
| 1870 | Int lsIdx = i; |
|---|
| 1871 | #if O0109_DEFAULT_ONE_OUT_LAYER_IDC |
|---|
| 1872 | if( vps->getDefaultOneTargetOutputLayerIdc() == 1 ) |
|---|
| 1873 | { |
|---|
| 1874 | for(j = 0; j < vps->getNumLayersInIdList(lsIdx); j++) |
|---|
| 1875 | { |
|---|
| 1876 | #if O0135_DEFAULT_ONE_OUT_SEMANTIC |
|---|
| 1877 | #if DEF_OPT_LAYER_IDC |
|---|
| 1878 | vps->setOutputLayerFlag(i, j, (j == (vps->getNumLayersInIdList(lsIdx)-1)) ); |
|---|
| 1879 | #else |
|---|
| 1880 | vps->setOutputLayerFlag(i, j, (j == (vps->getNumLayersInIdList(lsIdx)-1)) && (vps->getDimensionId(j,1)==0) ); |
|---|
| 1881 | #endif |
|---|
| 1882 | #else |
|---|
| 1883 | vps->setOutputLayerFlag(i, j, (j == (vps->getNumLayersInIdList(lsIdx)-1))); |
|---|
| 1884 | #endif |
|---|
| 1885 | } |
|---|
| 1886 | } |
|---|
| 1887 | else if ( vps->getDefaultOneTargetOutputLayerIdc() == 0 ) |
|---|
| 1888 | { |
|---|
| 1889 | for(j = 0; j < vps->getNumLayersInIdList(lsIdx); j++) |
|---|
| 1890 | { |
|---|
| 1891 | vps->setOutputLayerFlag(i, j, 1); |
|---|
| 1892 | } |
|---|
| 1893 | } |
|---|
| 1894 | else |
|---|
| 1895 | { |
|---|
| 1896 | // Other values of default_one_target_output_layer_idc than 0 and 1 are reserved for future use. |
|---|
| 1897 | } |
|---|
| 1898 | #else |
|---|
| 1899 | if( vps->getDefaultOneTargetOutputLayerFlag() ) |
|---|
| 1900 | { |
|---|
| 1901 | for(j = 0; j < vps->getNumLayersInIdList(lsIdx); j++) |
|---|
| 1902 | { |
|---|
| 1903 | vps->setOutputLayerFlag(i, j, (j == (vps->getNumLayersInIdList(lsIdx)-1))); |
|---|
| 1904 | } |
|---|
| 1905 | } |
|---|
| 1906 | else |
|---|
| 1907 | { |
|---|
| 1908 | for(j = 0; j < vps->getNumLayersInIdList(lsIdx); j++) |
|---|
| 1909 | { |
|---|
| 1910 | vps->setOutputLayerFlag(i, j, 1); |
|---|
| 1911 | } |
|---|
| 1912 | } |
|---|
| 1913 | #endif |
|---|
| 1914 | } |
|---|
| 1915 | Int numBits = 1; |
|---|
| 1916 | while ((1 << numBits) < (vps->getNumProfileTierLevel())) |
|---|
| 1917 | { |
|---|
| 1918 | numBits++; |
|---|
| 1919 | } |
|---|
| 1920 | READ_CODE( numBits, uiCode, "profile_level_tier_idx[i]" ); vps->setProfileLevelTierIdx(i, uiCode); |
|---|
| 1921 | } |
|---|
| 1922 | #endif |
|---|
| 1923 | |
|---|
| 1924 | #if !P0300_ALT_OUTPUT_LAYER_FLAG |
|---|
| 1925 | #if O0153_ALT_OUTPUT_LAYER_FLAG |
|---|
| 1926 | if( vps->getMaxLayers() > 1 ) |
|---|
| 1927 | { |
|---|
| 1928 | READ_FLAG( uiCode, "alt_output_layer_flag"); |
|---|
| 1929 | vps->setAltOuputLayerFlag( uiCode ? true : false ); |
|---|
| 1930 | } |
|---|
| 1931 | #endif |
|---|
| 1932 | #endif |
|---|
| 1933 | |
|---|
| 1934 | #if REPN_FORMAT_IN_VPS |
|---|
| 1935 | #if Q0195_REP_FORMAT_CLEANUP |
|---|
| 1936 | READ_UVLC( uiCode, "vps_num_rep_formats_minus1" ); |
|---|
| 1937 | vps->setVpsNumRepFormats( uiCode + 1 ); |
|---|
| 1938 | |
|---|
| 1939 | // The value of vps_num_rep_formats_minus1 shall be in the range of 0 to 255, inclusive. |
|---|
| 1940 | assert( vps->getVpsNumRepFormats() > 0 && vps->getVpsNumRepFormats() <= 256 ); |
|---|
| 1941 | |
|---|
| 1942 | for(i = 0; i < vps->getVpsNumRepFormats(); i++) |
|---|
| 1943 | { |
|---|
| 1944 | // Read rep_format_structures |
|---|
| 1945 | parseRepFormat( vps->getVpsRepFormat(i), i > 0 ? vps->getVpsRepFormat(i-1) : 0 ); |
|---|
| 1946 | } |
|---|
| 1947 | |
|---|
| 1948 | // Default assignment for layer 0 |
|---|
| 1949 | vps->setVpsRepFormatIdx( 0, 0 ); |
|---|
| 1950 | |
|---|
| 1951 | if( vps->getVpsNumRepFormats() > 1 ) |
|---|
| 1952 | { |
|---|
| 1953 | READ_FLAG( uiCode, "rep_format_idx_present_flag"); |
|---|
| 1954 | vps->setRepFormatIdxPresentFlag( uiCode ? true : false ); |
|---|
| 1955 | } |
|---|
| 1956 | else |
|---|
| 1957 | { |
|---|
| 1958 | // When not present, the value of rep_format_idx_present_flag is inferred to be equal to 0 |
|---|
| 1959 | vps->setRepFormatIdxPresentFlag( false ); |
|---|
| 1960 | } |
|---|
| 1961 | |
|---|
| 1962 | if( vps->getRepFormatIdxPresentFlag() ) |
|---|
| 1963 | { |
|---|
| 1964 | for(i = 1; i < vps->getMaxLayers(); i++) |
|---|
| 1965 | { |
|---|
| 1966 | Int numBits = 1; |
|---|
| 1967 | while ((1 << numBits) < (vps->getVpsNumRepFormats())) |
|---|
| 1968 | { |
|---|
| 1969 | numBits++; |
|---|
| 1970 | } |
|---|
| 1971 | READ_CODE( numBits, uiCode, "vps_rep_format_idx[i]" ); |
|---|
| 1972 | vps->setVpsRepFormatIdx( i, uiCode ); |
|---|
| 1973 | } |
|---|
| 1974 | } |
|---|
| 1975 | else |
|---|
| 1976 | { |
|---|
| 1977 | // When not present, the value of vps_rep_format_idx[ i ] is inferred to be equal to Min (i, vps_num_rep_formats_minus1) |
|---|
| 1978 | for(i = 1; i < vps->getMaxLayers(); i++) |
|---|
| 1979 | { |
|---|
| 1980 | vps->setVpsRepFormatIdx( i, min( (Int)i, vps->getVpsNumRepFormats()-1 ) ); |
|---|
| 1981 | } |
|---|
| 1982 | } |
|---|
| 1983 | #else |
|---|
| 1984 | READ_FLAG( uiCode, "rep_format_idx_present_flag"); |
|---|
| 1985 | vps->setRepFormatIdxPresentFlag( uiCode ? true : false ); |
|---|
| 1986 | |
|---|
| 1987 | if( vps->getRepFormatIdxPresentFlag() ) |
|---|
| 1988 | { |
|---|
| 1989 | #if O0096_REP_FORMAT_INDEX |
|---|
| 1990 | #if !VPS_EXTN_UEV_CODING |
|---|
| 1991 | READ_CODE( 8, uiCode, "vps_num_rep_formats_minus1" ); |
|---|
| 1992 | #else |
|---|
| 1993 | READ_UVLC( uiCode, "vps_num_rep_formats_minus1" ); |
|---|
| 1994 | #endif |
|---|
| 1995 | #else |
|---|
| 1996 | READ_CODE( 4, uiCode, "vps_num_rep_formats_minus1" ); |
|---|
| 1997 | #endif |
|---|
| 1998 | vps->setVpsNumRepFormats( uiCode + 1 ); |
|---|
| 1999 | } |
|---|
| 2000 | else |
|---|
| 2001 | { |
|---|
| 2002 | // default assignment |
|---|
| 2003 | assert (vps->getMaxLayers() <= 16); // If max_layers_is more than 15, num_rep_formats has to be signaled |
|---|
| 2004 | vps->setVpsNumRepFormats( vps->getMaxLayers() ); |
|---|
| 2005 | } |
|---|
| 2006 | |
|---|
| 2007 | // The value of vps_num_rep_formats_minus1 shall be in the range of 0 to 255, inclusive. |
|---|
| 2008 | assert( vps->getVpsNumRepFormats() > 0 && vps->getVpsNumRepFormats() <= 256 ); |
|---|
| 2009 | |
|---|
| 2010 | for(i = 0; i < vps->getVpsNumRepFormats(); i++) |
|---|
| 2011 | { |
|---|
| 2012 | // Read rep_format_structures |
|---|
| 2013 | parseRepFormat( vps->getVpsRepFormat(i), i > 0 ? vps->getVpsRepFormat(i-1) : 0 ); |
|---|
| 2014 | } |
|---|
| 2015 | |
|---|
| 2016 | // Default assignment for layer 0 |
|---|
| 2017 | vps->setVpsRepFormatIdx( 0, 0 ); |
|---|
| 2018 | if( vps->getRepFormatIdxPresentFlag() ) |
|---|
| 2019 | { |
|---|
| 2020 | for(i = 1; i < vps->getMaxLayers(); i++) |
|---|
| 2021 | { |
|---|
| 2022 | if( vps->getVpsNumRepFormats() > 1 ) |
|---|
| 2023 | { |
|---|
| 2024 | #if O0096_REP_FORMAT_INDEX |
|---|
| 2025 | #if !VPS_EXTN_UEV_CODING |
|---|
| 2026 | READ_CODE( 8, uiCode, "vps_rep_format_idx[i]" ); |
|---|
| 2027 | #else |
|---|
| 2028 | Int numBits = 1; |
|---|
| 2029 | while ((1 << numBits) < (vps->getVpsNumRepFormats())) |
|---|
| 2030 | { |
|---|
| 2031 | numBits++; |
|---|
| 2032 | } |
|---|
| 2033 | READ_CODE( numBits, uiCode, "vps_rep_format_idx[i]" ); |
|---|
| 2034 | #endif |
|---|
| 2035 | #else |
|---|
| 2036 | READ_CODE( 4, uiCode, "vps_rep_format_idx[i]" ); |
|---|
| 2037 | #endif |
|---|
| 2038 | vps->setVpsRepFormatIdx( i, uiCode ); |
|---|
| 2039 | } |
|---|
| 2040 | else |
|---|
| 2041 | { |
|---|
| 2042 | // default assignment - only one rep_format() structure |
|---|
| 2043 | vps->setVpsRepFormatIdx( i, 0 ); |
|---|
| 2044 | } |
|---|
| 2045 | } |
|---|
| 2046 | } |
|---|
| 2047 | else |
|---|
| 2048 | { |
|---|
| 2049 | // default assignment - each layer assigned each rep_format() structure in the order signaled |
|---|
| 2050 | for(i = 1; i < vps->getMaxLayers(); i++) |
|---|
| 2051 | { |
|---|
| 2052 | vps->setVpsRepFormatIdx( i, i ); |
|---|
| 2053 | } |
|---|
| 2054 | } |
|---|
| 2055 | #endif |
|---|
| 2056 | #endif |
|---|
| 2057 | #if RESOLUTION_BASED_DPB |
|---|
| 2058 | vps->assignSubDpbIndices(); |
|---|
| 2059 | #endif |
|---|
| 2060 | READ_FLAG(uiCode, "max_one_active_ref_layer_flag" ); |
|---|
| 2061 | vps->setMaxOneActiveRefLayerFlag(uiCode); |
|---|
| 2062 | #if P0297_VPS_POC_LSB_ALIGNED_FLAG |
|---|
| 2063 | READ_FLAG(uiCode, "vps_poc_lsb_aligned_flag"); |
|---|
| 2064 | vps->setVpsPocLsbAlignedFlag(uiCode); |
|---|
| 2065 | #endif |
|---|
| 2066 | #if O0062_POC_LSB_NOT_PRESENT_FLAG |
|---|
| 2067 | for(i = 1; i< vps->getMaxLayers(); i++) |
|---|
| 2068 | { |
|---|
| 2069 | if( vps->getNumDirectRefLayers( vps->getLayerIdInNuh(i) ) == 0 ) |
|---|
| 2070 | { |
|---|
| 2071 | READ_FLAG(uiCode, "poc_lsb_not_present_flag[i]"); |
|---|
| 2072 | vps->setPocLsbNotPresentFlag(i, uiCode); |
|---|
| 2073 | } |
|---|
| 2074 | } |
|---|
| 2075 | #endif |
|---|
| 2076 | #if O0215_PHASE_ALIGNMENT |
|---|
| 2077 | READ_FLAG( uiCode, "cross_layer_phase_alignment_flag"); vps->setPhaseAlignFlag( uiCode == 1 ? true : false ); |
|---|
| 2078 | #endif |
|---|
| 2079 | |
|---|
| 2080 | #if !IRAP_ALIGN_FLAG_IN_VPS_VUI |
|---|
| 2081 | READ_FLAG(uiCode, "cross_layer_irap_aligned_flag" ); |
|---|
| 2082 | vps->setCrossLayerIrapAlignFlag(uiCode); |
|---|
| 2083 | #endif |
|---|
| 2084 | |
|---|
| 2085 | #if VPS_DPB_SIZE_TABLE |
|---|
| 2086 | parseVpsDpbSizeTable(vps); |
|---|
| 2087 | #endif |
|---|
| 2088 | |
|---|
| 2089 | #if VPS_EXTN_DIRECT_REF_LAYERS |
|---|
| 2090 | READ_UVLC( uiCode, "direct_dep_type_len_minus2"); vps->setDirectDepTypeLen(uiCode+2); |
|---|
| 2091 | #if O0096_DEFAULT_DEPENDENCY_TYPE |
|---|
| 2092 | READ_FLAG(uiCode, "default_direct_dependency_type_flag"); |
|---|
| 2093 | vps->setDefaultDirectDependecyTypeFlag(uiCode == 1? true : false); |
|---|
| 2094 | if (vps->getDefaultDirectDependencyTypeFlag()) |
|---|
| 2095 | { |
|---|
| 2096 | READ_CODE( vps->getDirectDepTypeLen(), uiCode, "default_direct_dependency_type" ); |
|---|
| 2097 | vps->setDefaultDirectDependecyType(uiCode); |
|---|
| 2098 | } |
|---|
| 2099 | #endif |
|---|
| 2100 | for(i = 1; i < vps->getMaxLayers(); i++) |
|---|
| 2101 | { |
|---|
| 2102 | for(j = 0; j < i; j++) |
|---|
| 2103 | { |
|---|
| 2104 | if (vps->getDirectDependencyFlag(i, j)) |
|---|
| 2105 | { |
|---|
| 2106 | #if O0096_DEFAULT_DEPENDENCY_TYPE |
|---|
| 2107 | if (vps->getDefaultDirectDependencyTypeFlag()) |
|---|
| 2108 | { |
|---|
| 2109 | vps->setDirectDependencyType(i, j, vps->getDefaultDirectDependencyType()); |
|---|
| 2110 | } |
|---|
| 2111 | else |
|---|
| 2112 | { |
|---|
| 2113 | READ_CODE( vps->getDirectDepTypeLen(), uiCode, "direct_dependency_type[i][j]" ); |
|---|
| 2114 | vps->setDirectDependencyType(i, j, uiCode); |
|---|
| 2115 | } |
|---|
| 2116 | #else |
|---|
| 2117 | READ_CODE( vps->getDirectDepTypeLen(), uiCode, "direct_dependency_type[i][j]" ); |
|---|
| 2118 | vps->setDirectDependencyType(i, j, uiCode); |
|---|
| 2119 | #endif |
|---|
| 2120 | } |
|---|
| 2121 | } |
|---|
| 2122 | } |
|---|
| 2123 | #endif |
|---|
| 2124 | #if !Q0078_ADD_LAYER_SETS |
|---|
| 2125 | #if O0092_0094_DEPENDENCY_CONSTRAINT // Moved up |
|---|
| 2126 | vps->setNumRefLayers(); |
|---|
| 2127 | |
|---|
| 2128 | if(vps->getMaxLayers() > MAX_REF_LAYERS) |
|---|
| 2129 | { |
|---|
| 2130 | for(i = 1;i < vps->getMaxLayers(); i++) |
|---|
| 2131 | { |
|---|
| 2132 | assert( vps->getNumRefLayers(vps->getLayerIdInNuh(i)) <= MAX_REF_LAYERS); |
|---|
| 2133 | } |
|---|
| 2134 | } |
|---|
| 2135 | #endif |
|---|
| 2136 | #endif |
|---|
| 2137 | |
|---|
| 2138 | #if P0307_VPS_NON_VUI_EXTENSION |
|---|
| 2139 | READ_UVLC( uiCode, "vps_non_vui_extension_length"); vps->setVpsNonVuiExtLength((Int)uiCode); |
|---|
| 2140 | |
|---|
| 2141 | // The value of vps_non_vui_extension_length shall be in the range of 0 to 4096, inclusive. |
|---|
| 2142 | assert( vps->getVpsNonVuiExtLength() >= 0 && vps->getVpsNonVuiExtLength() <= 4096 ); |
|---|
| 2143 | |
|---|
| 2144 | #if P0307_VPS_NON_VUI_EXT_UPDATE |
|---|
| 2145 | Int nonVuiExtByte = uiCode; |
|---|
| 2146 | for (i = 1; i <= nonVuiExtByte; i++) |
|---|
| 2147 | { |
|---|
| 2148 | READ_CODE( 8, uiCode, "vps_non_vui_extension_data_byte" ); //just parse and discard for now. |
|---|
| 2149 | } |
|---|
| 2150 | #else |
|---|
| 2151 | if ( vps->getVpsNonVuiExtLength() > 0 ) |
|---|
| 2152 | { |
|---|
| 2153 | printf("\n\nUp to the current spec, the value of vps_non_vui_extension_length is supposed to be 0\n"); |
|---|
| 2154 | } |
|---|
| 2155 | #endif |
|---|
| 2156 | #endif |
|---|
| 2157 | |
|---|
| 2158 | #if !O0109_O0199_FLAGS_TO_VUI |
|---|
| 2159 | #if M0040_ADAPTIVE_RESOLUTION_CHANGE |
|---|
| 2160 | READ_FLAG(uiCode, "single_layer_for_non_irap_flag" ); vps->setSingleLayerForNonIrapFlag(uiCode == 1 ? true : false); |
|---|
| 2161 | #endif |
|---|
| 2162 | #if HIGHER_LAYER_IRAP_SKIP_FLAG |
|---|
| 2163 | READ_FLAG(uiCode, "higher_layer_irap_skip_flag" ); vps->setHigherLayerIrapSkipFlag(uiCode == 1 ? true : false); |
|---|
| 2164 | #endif |
|---|
| 2165 | #endif |
|---|
| 2166 | |
|---|
| 2167 | #if P0307_REMOVE_VPS_VUI_OFFSET |
|---|
| 2168 | READ_FLAG( uiCode, "vps_vui_present_flag"); vps->setVpsVuiPresentFlag(uiCode ? true : false); |
|---|
| 2169 | #endif |
|---|
| 2170 | |
|---|
| 2171 | #if O0109_MOVE_VPS_VUI_FLAG |
|---|
| 2172 | if ( vps->getVpsVuiPresentFlag() ) |
|---|
| 2173 | #else |
|---|
| 2174 | READ_FLAG( uiCode, "vps_vui_present_flag" ); |
|---|
| 2175 | if (uiCode) |
|---|
| 2176 | #endif |
|---|
| 2177 | { |
|---|
| 2178 | while ( m_pcBitstream->getNumBitsRead() % 8 != 0 ) |
|---|
| 2179 | { |
|---|
| 2180 | READ_FLAG( uiCode, "vps_vui_alignment_bit_equal_to_one"); assert(uiCode == 1); |
|---|
| 2181 | } |
|---|
| 2182 | parseVPSVUI(vps); |
|---|
| 2183 | } |
|---|
| 2184 | else |
|---|
| 2185 | { |
|---|
| 2186 | // set default values for VPS VUI |
|---|
| 2187 | defaultVPSVUI( vps ); |
|---|
| 2188 | } |
|---|
| 2189 | } |
|---|
| 2190 | |
|---|
| 2191 | Void TDecCavlc::defaultVPSExtension( TComVPS* vps ) |
|---|
| 2192 | { |
|---|
| 2193 | // set default parameters when they are not present |
|---|
| 2194 | Int i, j; |
|---|
| 2195 | |
|---|
| 2196 | // When layer_id_in_nuh[ i ] is not present, the value is inferred to be equal to i. |
|---|
| 2197 | for(i = 0; i < vps->getMaxLayers(); i++) |
|---|
| 2198 | { |
|---|
| 2199 | vps->setLayerIdInNuh(i, i); |
|---|
| 2200 | vps->setLayerIdInVps(vps->getLayerIdInNuh(i), i); |
|---|
| 2201 | } |
|---|
| 2202 | |
|---|
| 2203 | // When not present, sub_layers_vps_max_minus1[ i ] is inferred to be equal to vps_max_sub_layers_minus1. |
|---|
| 2204 | for( i = 0; i < vps->getMaxLayers(); i++) |
|---|
| 2205 | { |
|---|
| 2206 | vps->setMaxTSLayersMinus1(i, vps->getMaxTLayers()-1); |
|---|
| 2207 | } |
|---|
| 2208 | |
|---|
| 2209 | // When not present, max_tid_il_ref_pics_plus1[ i ][ j ] is inferred to be equal to 7. |
|---|
| 2210 | for( i = 0; i < vps->getMaxLayers() - 1; i++ ) |
|---|
| 2211 | { |
|---|
| 2212 | #if O0225_MAX_TID_FOR_REF_LAYERS |
|---|
| 2213 | for( j = i + 1; j < vps->getMaxLayers(); j++ ) |
|---|
| 2214 | { |
|---|
| 2215 | vps->setMaxTidIlRefPicsPlus1(i, j, 7); |
|---|
| 2216 | } |
|---|
| 2217 | #else |
|---|
| 2218 | vps->setMaxTidIlRefPicsPlus1(i, 7); |
|---|
| 2219 | #endif |
|---|
| 2220 | } |
|---|
| 2221 | |
|---|
| 2222 | // When not present, the value of num_add_olss is inferred to be equal to 0. |
|---|
| 2223 | // NumOutputLayerSets = num_add_olss + NumLayerSets |
|---|
| 2224 | vps->setNumOutputLayerSets( vps->getNumLayerSets() ); |
|---|
| 2225 | |
|---|
| 2226 | // For i in the range of 0 to NumOutputLayerSets-1, inclusive, the variable LayerSetIdxForOutputLayerSet[ i ] is derived as specified in the following: |
|---|
| 2227 | // LayerSetIdxForOutputLayerSet[ i ] = ( i <= vps_number_layer_sets_minus1 ) ? i : layer_set_idx_for_ols_minus1[ i ] + 1 |
|---|
| 2228 | for( i = 1; i < vps->getNumOutputLayerSets(); i++ ) |
|---|
| 2229 | { |
|---|
| 2230 | vps->setOutputLayerSetIdx( i, i ); |
|---|
| 2231 | Int lsIdx = vps->getOutputLayerSetIdx(i); |
|---|
| 2232 | |
|---|
| 2233 | for( j = 0; j < vps->getNumLayersInIdList(lsIdx); j++ ) |
|---|
| 2234 | { |
|---|
| 2235 | vps->setOutputLayerFlag(i, j, 1); |
|---|
| 2236 | } |
|---|
| 2237 | } |
|---|
| 2238 | |
|---|
| 2239 | // The value of sub_layer_dpb_info_present_flag[ i ][ 0 ] for any possible value of i is inferred to be equal to 1 |
|---|
| 2240 | // 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. |
|---|
| 2241 | for( i = 1; i < vps->getNumOutputLayerSets(); i++ ) |
|---|
| 2242 | { |
|---|
| 2243 | vps->setSubLayerDpbInfoPresentFlag( i, 0, true ); |
|---|
| 2244 | } |
|---|
| 2245 | |
|---|
| 2246 | // When not present, the value of vps_num_rep_formats_minus1 is inferred to be equal to MaxLayersMinus1. |
|---|
| 2247 | vps->setVpsNumRepFormats( vps->getMaxLayers() ); |
|---|
| 2248 | |
|---|
| 2249 | // When not present, the value of rep_format_idx_present_flag is inferred to be equal to 0 |
|---|
| 2250 | vps->setRepFormatIdxPresentFlag( false ); |
|---|
| 2251 | |
|---|
| 2252 | if( !vps->getRepFormatIdxPresentFlag() ) |
|---|
| 2253 | { |
|---|
| 2254 | // When not present, the value of vps_rep_format_idx[ i ] is inferred to be equal to Min(i, vps_num_rep_formats_minus1). |
|---|
| 2255 | for(i = 1; i < vps->getMaxLayers(); i++) |
|---|
| 2256 | { |
|---|
| 2257 | vps->setVpsRepFormatIdx( i, min( (Int)i, vps->getVpsNumRepFormats() - 1 ) ); |
|---|
| 2258 | } |
|---|
| 2259 | } |
|---|
| 2260 | |
|---|
| 2261 | #if P0297_VPS_POC_LSB_ALIGNED_FLAG |
|---|
| 2262 | vps->setVpsPocLsbAlignedFlag(false); |
|---|
| 2263 | #endif |
|---|
| 2264 | |
|---|
| 2265 | #if O0062_POC_LSB_NOT_PRESENT_FLAG |
|---|
| 2266 | // When not present, poc_lsb_not_present_flag[ i ] is inferred to be equal to 0. |
|---|
| 2267 | for(i = 1; i< vps->getMaxLayers(); i++) |
|---|
| 2268 | { |
|---|
| 2269 | vps->setPocLsbNotPresentFlag(i, 0); |
|---|
| 2270 | } |
|---|
| 2271 | #endif |
|---|
| 2272 | |
|---|
| 2273 | // set default values for VPS VUI |
|---|
| 2274 | defaultVPSVUI( vps ); |
|---|
| 2275 | } |
|---|
| 2276 | |
|---|
| 2277 | Void TDecCavlc::defaultVPSVUI( TComVPS* vps ) |
|---|
| 2278 | { |
|---|
| 2279 | // When not present, the value of all_layers_idr_aligned_flag is inferred to be equal to 0. |
|---|
| 2280 | vps->setCrossLayerIrapAlignFlag( false ); |
|---|
| 2281 | |
|---|
| 2282 | #if M0040_ADAPTIVE_RESOLUTION_CHANGE |
|---|
| 2283 | // When single_layer_for_non_irap_flag is not present, it is inferred to be equal to 0. |
|---|
| 2284 | vps->setSingleLayerForNonIrapFlag( false ); |
|---|
| 2285 | #endif |
|---|
| 2286 | |
|---|
| 2287 | #if HIGHER_LAYER_IRAP_SKIP_FLAG |
|---|
| 2288 | // When higher_layer_irap_skip_flag is not present it is inferred to be equal to 0 |
|---|
| 2289 | vps->setHigherLayerIrapSkipFlag( false ); |
|---|
| 2290 | #endif |
|---|
| 2291 | } |
|---|
| 2292 | |
|---|
| 2293 | #if REPN_FORMAT_IN_VPS |
|---|
| 2294 | Void TDecCavlc::parseRepFormat( RepFormat *repFormat, RepFormat *repFormatPrev ) |
|---|
| 2295 | { |
|---|
| 2296 | UInt uiCode; |
|---|
| 2297 | #if REPN_FORMAT_CONTROL_FLAG |
|---|
| 2298 | READ_CODE( 16, uiCode, "pic_width_vps_in_luma_samples" ); repFormat->setPicWidthVpsInLumaSamples ( uiCode ); |
|---|
| 2299 | READ_CODE( 16, uiCode, "pic_height_vps_in_luma_samples" ); repFormat->setPicHeightVpsInLumaSamples( uiCode ); |
|---|
| 2300 | READ_FLAG( uiCode, "chroma_and_bit_depth_vps_present_flag" ); repFormat->setChromaAndBitDepthVpsPresentFlag( uiCode ? true : false ); |
|---|
| 2301 | |
|---|
| 2302 | if( !repFormatPrev ) |
|---|
| 2303 | { |
|---|
| 2304 | // 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 |
|---|
| 2305 | assert( repFormat->getChromaAndBitDepthVpsPresentFlag() ); |
|---|
| 2306 | } |
|---|
| 2307 | |
|---|
| 2308 | if( repFormat->getChromaAndBitDepthVpsPresentFlag() ) |
|---|
| 2309 | { |
|---|
| 2310 | READ_CODE( 2, uiCode, "chroma_format_vps_idc" ); |
|---|
| 2311 | #if AUXILIARY_PICTURES |
|---|
| 2312 | repFormat->setChromaFormatVpsIdc( ChromaFormat(uiCode) ); |
|---|
| 2313 | #else |
|---|
| 2314 | repFormat->setChromaFormatVpsIdc( uiCode ); |
|---|
| 2315 | #endif |
|---|
| 2316 | |
|---|
| 2317 | if( repFormat->getChromaFormatVpsIdc() == 3 ) |
|---|
| 2318 | { |
|---|
| 2319 | READ_FLAG( uiCode, "separate_colour_plane_vps_flag" ); repFormat->setSeparateColourPlaneVpsFlag( uiCode ? true : false ); |
|---|
| 2320 | } |
|---|
| 2321 | |
|---|
| 2322 | READ_CODE( 4, uiCode, "bit_depth_vps_luma_minus8" ); repFormat->setBitDepthVpsLuma ( uiCode + 8 ); |
|---|
| 2323 | READ_CODE( 4, uiCode, "bit_depth_vps_chroma_minus8" ); repFormat->setBitDepthVpsChroma( uiCode + 8 ); |
|---|
| 2324 | } |
|---|
| 2325 | else if( repFormatPrev ) |
|---|
| 2326 | { |
|---|
| 2327 | // 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 |
|---|
| 2328 | // bit_depth_vps_chroma_minus8 are not present and inferred from the previous rep_format( ) syntax structure in the VPS. |
|---|
| 2329 | |
|---|
| 2330 | repFormat->setChromaFormatVpsIdc ( repFormatPrev->getChromaFormatVpsIdc() ); |
|---|
| 2331 | repFormat->setSeparateColourPlaneVpsFlag( repFormatPrev->getSeparateColourPlaneVpsFlag() ); |
|---|
| 2332 | repFormat->setBitDepthVpsLuma ( repFormatPrev->getBitDepthVpsLuma() ); |
|---|
| 2333 | repFormat->setBitDepthVpsChroma ( repFormatPrev->getBitDepthVpsChroma() ); |
|---|
| 2334 | } |
|---|
| 2335 | |
|---|
| 2336 | #else |
|---|
| 2337 | #if AUXILIARY_PICTURES |
|---|
| 2338 | READ_CODE( 2, uiCode, "chroma_format_idc" ); repFormat->setChromaFormatVpsIdc( ChromaFormat(uiCode) ); |
|---|
| 2339 | #else |
|---|
| 2340 | READ_CODE( 2, uiCode, "chroma_format_idc" ); repFormat->setChromaFormatVpsIdc( uiCode ); |
|---|
| 2341 | #endif |
|---|
| 2342 | |
|---|
| 2343 | if( repFormat->getChromaFormatVpsIdc() == 3 ) |
|---|
| 2344 | { |
|---|
| 2345 | READ_FLAG( uiCode, "separate_colour_plane_flag"); repFormat->setSeparateColourPlaneVpsFlag(uiCode ? true : false); |
|---|
| 2346 | } |
|---|
| 2347 | |
|---|
| 2348 | READ_CODE ( 16, uiCode, "pic_width_in_luma_samples" ); repFormat->setPicWidthVpsInLumaSamples ( uiCode ); |
|---|
| 2349 | READ_CODE ( 16, uiCode, "pic_height_in_luma_samples" ); repFormat->setPicHeightVpsInLumaSamples( uiCode ); |
|---|
| 2350 | |
|---|
| 2351 | READ_CODE( 4, uiCode, "bit_depth_luma_minus8" ); repFormat->setBitDepthVpsLuma ( uiCode + 8 ); |
|---|
| 2352 | READ_CODE( 4, uiCode, "bit_depth_chroma_minus8" ); repFormat->setBitDepthVpsChroma( uiCode + 8 ); |
|---|
| 2353 | #endif |
|---|
| 2354 | |
|---|
| 2355 | #if R0156_CONF_WINDOW_IN_REP_FORMAT |
|---|
| 2356 | READ_FLAG( uiCode, "conformance_window_vps_flag" ); |
|---|
| 2357 | if( uiCode != 0) |
|---|
| 2358 | { |
|---|
| 2359 | Window &conf = repFormat->getConformanceWindowVps(); |
|---|
| 2360 | READ_UVLC( uiCode, "conf_win_vps_left_offset" ); conf.setWindowLeftOffset ( uiCode ); |
|---|
| 2361 | READ_UVLC( uiCode, "conf_win_vps_right_offset" ); conf.setWindowRightOffset ( uiCode ); |
|---|
| 2362 | READ_UVLC( uiCode, "conf_win_vps_top_offset" ); conf.setWindowTopOffset ( uiCode ); |
|---|
| 2363 | READ_UVLC( uiCode, "conf_win_vps_bottom_offset" ); conf.setWindowBottomOffset( uiCode ); |
|---|
| 2364 | } |
|---|
| 2365 | #endif |
|---|
| 2366 | } |
|---|
| 2367 | #endif |
|---|
| 2368 | #if VPS_DPB_SIZE_TABLE |
|---|
| 2369 | Void TDecCavlc::parseVpsDpbSizeTable( TComVPS *vps ) |
|---|
| 2370 | { |
|---|
| 2371 | UInt uiCode; |
|---|
| 2372 | #if SUB_LAYERS_IN_LAYER_SET |
|---|
| 2373 | vps->calculateMaxSLInLayerSets(); |
|---|
| 2374 | #else |
|---|
| 2375 | #if DPB_PARAMS_MAXTLAYERS |
|---|
| 2376 | #if BITRATE_PICRATE_SIGNALLING |
|---|
| 2377 | Int * MaxSubLayersInLayerSetMinus1 = new Int[vps->getNumLayerSets()]; |
|---|
| 2378 | for(Int i = 0; i < vps->getNumLayerSets(); i++) |
|---|
| 2379 | #else |
|---|
| 2380 | Int * MaxSubLayersInLayerSetMinus1 = new Int[vps->getNumOutputLayerSets()]; |
|---|
| 2381 | for(Int i = 1; i < vps->getNumOutputLayerSets(); i++) |
|---|
| 2382 | #endif |
|---|
| 2383 | { |
|---|
| 2384 | UInt maxSLMinus1 = 0; |
|---|
| 2385 | #if CHANGE_NUMSUBDPB_IDX |
|---|
| 2386 | Int optLsIdx = vps->getOutputLayerSetIdx( i ); |
|---|
| 2387 | #else |
|---|
| 2388 | Int optLsIdx = i; |
|---|
| 2389 | #endif |
|---|
| 2390 | #if BITRATE_PICRATE_SIGNALLING |
|---|
| 2391 | optLsIdx = i; |
|---|
| 2392 | #endif |
|---|
| 2393 | for(Int k = 0; k < vps->getNumLayersInIdList(optLsIdx); k++ ) { |
|---|
| 2394 | Int lId = vps->getLayerSetLayerIdList(optLsIdx, k); |
|---|
| 2395 | maxSLMinus1 = max(maxSLMinus1, vps->getMaxTSLayersMinus1(vps->getLayerIdInVps(lId))); |
|---|
| 2396 | } |
|---|
| 2397 | MaxSubLayersInLayerSetMinus1[ i ] = maxSLMinus1; |
|---|
| 2398 | #if BITRATE_PICRATE_SIGNALLING |
|---|
| 2399 | vps->setMaxSLayersInLayerSetMinus1(i,MaxSubLayersInLayerSetMinus1[ i ]); |
|---|
| 2400 | #endif |
|---|
| 2401 | } |
|---|
| 2402 | #endif |
|---|
| 2403 | #endif |
|---|
| 2404 | |
|---|
| 2405 | #if !RESOLUTION_BASED_DPB |
|---|
| 2406 | vps->deriveNumberOfSubDpbs(); |
|---|
| 2407 | #endif |
|---|
| 2408 | for(Int i = 1; i < vps->getNumOutputLayerSets(); i++) |
|---|
| 2409 | { |
|---|
| 2410 | #if CHANGE_NUMSUBDPB_IDX |
|---|
| 2411 | Int layerSetIdxForOutputLayerSet = vps->getOutputLayerSetIdx( i ); |
|---|
| 2412 | #endif |
|---|
| 2413 | READ_FLAG( uiCode, "sub_layer_flag_info_present_flag[i]"); vps->setSubLayerFlagInfoPresentFlag( i, uiCode ? true : false ); |
|---|
| 2414 | #if SUB_LAYERS_IN_LAYER_SET |
|---|
| 2415 | for(Int j = 0; j <= vps->getMaxSLayersInLayerSetMinus1( layerSetIdxForOutputLayerSet ); j++) |
|---|
| 2416 | #else |
|---|
| 2417 | #if DPB_PARAMS_MAXTLAYERS |
|---|
| 2418 | #if BITRATE_PICRATE_SIGNALLING |
|---|
| 2419 | for(Int j = 0; j <= MaxSubLayersInLayerSetMinus1[ vps->getOutputLayerSetIdx( i ) ]; j++) |
|---|
| 2420 | #else |
|---|
| 2421 | for(Int j = 0; j <= MaxSubLayersInLayerSetMinus1[ i ]; j++) |
|---|
| 2422 | #endif |
|---|
| 2423 | #else |
|---|
| 2424 | for(Int j = 0; j <= vps->getMaxTLayers(); j++) |
|---|
| 2425 | #endif |
|---|
| 2426 | #endif |
|---|
| 2427 | { |
|---|
| 2428 | if( j > 0 && vps->getSubLayerFlagInfoPresentFlag(i) ) |
|---|
| 2429 | { |
|---|
| 2430 | READ_FLAG( uiCode, "sub_layer_dpb_info_present_flag[i]"); vps->setSubLayerDpbInfoPresentFlag( i, j, uiCode ? true : false); |
|---|
| 2431 | } |
|---|
| 2432 | else |
|---|
| 2433 | { |
|---|
| 2434 | if( j == 0 ) // Always signal for the first sub-layer |
|---|
| 2435 | { |
|---|
| 2436 | vps->setSubLayerDpbInfoPresentFlag( i, j, true ); |
|---|
| 2437 | } |
|---|
| 2438 | else // if (j != 0) && !vps->getSubLayerFlagInfoPresentFlag(i) |
|---|
| 2439 | { |
|---|
| 2440 | vps->setSubLayerDpbInfoPresentFlag( i, j, false ); |
|---|
| 2441 | } |
|---|
| 2442 | } |
|---|
| 2443 | if( vps->getSubLayerDpbInfoPresentFlag(i, j) ) // If sub-layer DPB information is present |
|---|
| 2444 | { |
|---|
| 2445 | #if CHANGE_NUMSUBDPB_IDX |
|---|
| 2446 | for(Int k = 0; k < vps->getNumSubDpbs(layerSetIdxForOutputLayerSet); k++) |
|---|
| 2447 | #else |
|---|
| 2448 | for(Int k = 0; k < vps->getNumSubDpbs(i); k++) |
|---|
| 2449 | #endif |
|---|
| 2450 | { |
|---|
| 2451 | #if DPB_INTERNAL_BL_SIG |
|---|
| 2452 | uiCode=0; |
|---|
| 2453 | if(vps->getBaseLayerInternalFlag() || ( vps->getLayerSetLayerIdList(layerSetIdxForOutputLayerSet, k) != 0 ) ) |
|---|
| 2454 | #endif |
|---|
| 2455 | READ_UVLC( uiCode, "max_vps_dec_pic_buffering_minus1[i][k][j]" ); vps->setMaxVpsDecPicBufferingMinus1( i, k, j, uiCode ); |
|---|
| 2456 | } |
|---|
| 2457 | READ_UVLC( uiCode, "max_vps_num_reorder_pics[i][j]" ); vps->setMaxVpsNumReorderPics( i, j, uiCode); |
|---|
| 2458 | #if RESOLUTION_BASED_DPB |
|---|
| 2459 | if( vps->getNumSubDpbs(layerSetIdxForOutputLayerSet) != vps->getNumLayersInIdList( layerSetIdxForOutputLayerSet ) ) |
|---|
| 2460 | { |
|---|
| 2461 | for(Int k = 0; k < vps->getNumLayersInIdList( layerSetIdxForOutputLayerSet ); k++) |
|---|
| 2462 | { |
|---|
| 2463 | READ_UVLC( uiCode, "max_vps_layer_dec_pic_buff_minus1[i][k][j]" ); vps->setMaxVpsLayerDecPicBuffMinus1( i, k, j, uiCode); |
|---|
| 2464 | } |
|---|
| 2465 | } |
|---|
| 2466 | else // vps->getNumSubDpbs(layerSetIdxForOutputLayerSet) == vps->getNumLayersInIdList( layerSetIdxForOutputLayerSet ) |
|---|
| 2467 | { |
|---|
| 2468 | for(Int k = 0; k < vps->getNumLayersInIdList( layerSetIdxForOutputLayerSet ); k++) |
|---|
| 2469 | { |
|---|
| 2470 | vps->setMaxVpsLayerDecPicBuffMinus1( i, k, j, vps->getMaxVpsDecPicBufferingMinus1( i, k, j)); |
|---|
| 2471 | } |
|---|
| 2472 | } |
|---|
| 2473 | #endif |
|---|
| 2474 | READ_UVLC( uiCode, "max_vps_latency_increase_plus1[i][j]" ); vps->setMaxVpsLatencyIncreasePlus1( i, j, uiCode); |
|---|
| 2475 | } |
|---|
| 2476 | } |
|---|
| 2477 | for(Int j = vps->getMaxTLayers(); j < MAX_TLAYER; j++) |
|---|
| 2478 | { |
|---|
| 2479 | vps->setSubLayerDpbInfoPresentFlag( i, j, false ); |
|---|
| 2480 | } |
|---|
| 2481 | } |
|---|
| 2482 | |
|---|
| 2483 | #if !SUB_LAYERS_IN_LAYER_SET |
|---|
| 2484 | #if BITRATE_PICRATE_SIGNALLING |
|---|
| 2485 | if( MaxSubLayersInLayerSetMinus1 ) |
|---|
| 2486 | { |
|---|
| 2487 | delete [] MaxSubLayersInLayerSetMinus1; |
|---|
| 2488 | } |
|---|
| 2489 | #endif |
|---|
| 2490 | #endif |
|---|
| 2491 | |
|---|
| 2492 | // Infer values when not signalled |
|---|
| 2493 | for(Int i = 1; i < vps->getNumOutputLayerSets(); i++) |
|---|
| 2494 | { |
|---|
| 2495 | Int layerSetIdxForOutputLayerSet = vps->getOutputLayerSetIdx( i ); |
|---|
| 2496 | for(Int j = 0; j < MAX_TLAYER; j++) |
|---|
| 2497 | { |
|---|
| 2498 | if( !vps->getSubLayerDpbInfoPresentFlag(i, j) ) // If sub-layer DPB information is NOT present |
|---|
| 2499 | { |
|---|
| 2500 | #if RESOLUTION_BASED_DPB |
|---|
| 2501 | for(Int k = 0; k < vps->getNumSubDpbs(layerSetIdxForOutputLayerSet); k++) |
|---|
| 2502 | #else |
|---|
| 2503 | for(Int k = 0; k < vps->getNumLayersInIdList( layerSetIdxForOutputLayerSet ); k++) |
|---|
| 2504 | #endif |
|---|
| 2505 | { |
|---|
| 2506 | vps->setMaxVpsDecPicBufferingMinus1( i, k, j, vps->getMaxVpsDecPicBufferingMinus1( i, k, j - 1 ) ); |
|---|
| 2507 | } |
|---|
| 2508 | vps->setMaxVpsNumReorderPics( i, j, vps->getMaxVpsNumReorderPics( i, j - 1) ); |
|---|
| 2509 | #if RESOLUTION_BASED_DPB |
|---|
| 2510 | for(Int k = 0; k < vps->getNumLayersInIdList( layerSetIdxForOutputLayerSet ); k++) |
|---|
| 2511 | { |
|---|
| 2512 | vps->setMaxVpsLayerDecPicBuffMinus1( i, k, j, vps->getMaxVpsLayerDecPicBuffMinus1( i, k, j - 1)); |
|---|
| 2513 | } |
|---|
| 2514 | #endif |
|---|
| 2515 | vps->setMaxVpsLatencyIncreasePlus1( i, j, vps->getMaxVpsLatencyIncreasePlus1( i, j - 1 ) ); |
|---|
| 2516 | } |
|---|
| 2517 | } |
|---|
| 2518 | } |
|---|
| 2519 | } |
|---|
| 2520 | #endif |
|---|
| 2521 | |
|---|
| 2522 | Void TDecCavlc::parseVPSVUI(TComVPS *vps) |
|---|
| 2523 | { |
|---|
| 2524 | UInt i,j; |
|---|
| 2525 | UInt uiCode; |
|---|
| 2526 | #if O0223_PICTURE_TYPES_ALIGN_FLAG |
|---|
| 2527 | READ_FLAG(uiCode, "cross_layer_pic_type_aligned_flag" ); |
|---|
| 2528 | vps->setCrossLayerPictureTypeAlignFlag(uiCode); |
|---|
| 2529 | if (!uiCode) |
|---|
| 2530 | { |
|---|
| 2531 | #endif |
|---|
| 2532 | #if IRAP_ALIGN_FLAG_IN_VPS_VUI |
|---|
| 2533 | READ_FLAG(uiCode, "cross_layer_irap_aligned_flag" ); |
|---|
| 2534 | vps->setCrossLayerIrapAlignFlag(uiCode); |
|---|
| 2535 | #if P0068_CROSS_LAYER_ALIGNED_IDR_ONLY_FOR_IRAP_FLAG |
|---|
| 2536 | if( uiCode ) |
|---|
| 2537 | { |
|---|
| 2538 | READ_FLAG( uiCode, "all_layers_idr_aligned_flag" ); |
|---|
| 2539 | vps->setCrossLayerAlignedIdrOnlyFlag(uiCode); |
|---|
| 2540 | } |
|---|
| 2541 | #endif |
|---|
| 2542 | #endif |
|---|
| 2543 | #if O0223_PICTURE_TYPES_ALIGN_FLAG |
|---|
| 2544 | } |
|---|
| 2545 | else |
|---|
| 2546 | { |
|---|
| 2547 | vps->setCrossLayerIrapAlignFlag(true); |
|---|
| 2548 | } |
|---|
| 2549 | #endif |
|---|
| 2550 | |
|---|
| 2551 | READ_FLAG( uiCode, "bit_rate_present_vps_flag" ); vps->setBitRatePresentVpsFlag( uiCode ? true : false ); |
|---|
| 2552 | READ_FLAG( uiCode, "pic_rate_present_vps_flag" ); vps->setPicRatePresentVpsFlag( uiCode ? true : false ); |
|---|
| 2553 | |
|---|
| 2554 | #if SIGNALLING_BITRATE_PICRATE_FIX |
|---|
| 2555 | if ( vps->getBitRatePresentVpsFlag() || vps->getPicRatePresentVpsFlag() ) |
|---|
| 2556 | { |
|---|
| 2557 | for( i = vps->getBaseLayerInternalFlag() ? 0 : 1; i < vps->getNumLayerSets(); i++ ) |
|---|
| 2558 | { |
|---|
| 2559 | for( j = 0; j <= vps->getMaxSLayersInLayerSetMinus1( i ); j++ ) |
|---|
| 2560 | { |
|---|
| 2561 | if( vps->getBitRatePresentVpsFlag() ) |
|---|
| 2562 | { |
|---|
| 2563 | READ_FLAG( uiCode, "bit_rate_present_flag[i][j]" ); vps->setBitRatePresentFlag( i, j, uiCode ? true : false ); |
|---|
| 2564 | } |
|---|
| 2565 | if( vps->getPicRatePresentVpsFlag( ) ) |
|---|
| 2566 | { |
|---|
| 2567 | READ_FLAG( uiCode, "pic_rate_present_flag[i][j]" ); vps->setPicRatePresentFlag( i, j, uiCode ? true : false ); |
|---|
| 2568 | } |
|---|
| 2569 | if( vps->getBitRatePresentFlag( i, j ) ) |
|---|
| 2570 | { |
|---|
| 2571 | READ_CODE( 16, uiCode, "avg_bit_rate" ); vps->setAvgBitRate( i, j, uiCode ); |
|---|
| 2572 | READ_CODE( 16, uiCode, "max_bit_rate" ); vps->setMaxBitRate( i, j, uiCode ); |
|---|
| 2573 | } |
|---|
| 2574 | else |
|---|
| 2575 | { |
|---|
| 2576 | vps->setAvgBitRate( i, j, 0 ); |
|---|
| 2577 | vps->setMaxBitRate( i, j, 0 ); |
|---|
| 2578 | } |
|---|
| 2579 | if( vps->getPicRatePresentFlag( i, j ) ) |
|---|
| 2580 | { |
|---|
| 2581 | READ_CODE( 2, uiCode, "constant_pic_rate_idc" ); vps->setConstPicRateIdc( i, j, uiCode ); |
|---|
| 2582 | READ_CODE( 16, uiCode, "avg_pic_rate" ); vps->setAvgPicRate( i, j, uiCode ); |
|---|
| 2583 | } |
|---|
| 2584 | else |
|---|
| 2585 | { |
|---|
| 2586 | vps->setConstPicRateIdc( i, j, 0 ); |
|---|
| 2587 | vps->setAvgPicRate( i, j, 0 ); |
|---|
| 2588 | } |
|---|
| 2589 | } |
|---|
| 2590 | } |
|---|
| 2591 | } |
|---|
| 2592 | #else |
|---|
| 2593 | Bool parseFlag = vps->getBitRatePresentVpsFlag() || vps->getPicRatePresentVpsFlag(); |
|---|
| 2594 | |
|---|
| 2595 | #if Q0078_ADD_LAYER_SETS |
|---|
| 2596 | #if R0227_BR_PR_ADD_LAYER_SET |
|---|
| 2597 | for( i = 0; i < vps->getNumLayerSets(); i++ ) |
|---|
| 2598 | #else |
|---|
| 2599 | for( i = 0; i <= vps->getVpsNumLayerSetsMinus1(); i++ ) |
|---|
| 2600 | #endif |
|---|
| 2601 | #else |
|---|
| 2602 | for( i = 0; i < vps->getNumLayerSets(); i++ ) |
|---|
| 2603 | #endif |
|---|
| 2604 | { |
|---|
| 2605 | #if BITRATE_PICRATE_SIGNALLING |
|---|
| 2606 | for( j = 0; j <= vps->getMaxSLayersInLayerSetMinus1(i); j++ ) |
|---|
| 2607 | #else |
|---|
| 2608 | for( j = 0; j < vps->getMaxTLayers(); j++ ) |
|---|
| 2609 | #endif |
|---|
| 2610 | { |
|---|
| 2611 | if( parseFlag && vps->getBitRatePresentVpsFlag() ) |
|---|
| 2612 | { |
|---|
| 2613 | READ_FLAG( uiCode, "bit_rate_present_flag[i][j]" ); vps->setBitRatePresentFlag( i, j, uiCode ? true : false ); |
|---|
| 2614 | } |
|---|
| 2615 | else |
|---|
| 2616 | { |
|---|
| 2617 | vps->setBitRatePresentFlag( i, j, false ); |
|---|
| 2618 | } |
|---|
| 2619 | if( parseFlag && vps->getPicRatePresentVpsFlag() ) |
|---|
| 2620 | { |
|---|
| 2621 | READ_FLAG( uiCode, "pic_rate_present_flag[i][j]" ); vps->setPicRatePresentFlag( i, j, uiCode ? true : false ); |
|---|
| 2622 | } |
|---|
| 2623 | else |
|---|
| 2624 | { |
|---|
| 2625 | vps->setPicRatePresentFlag( i, j, false ); |
|---|
| 2626 | } |
|---|
| 2627 | if( parseFlag && vps->getBitRatePresentFlag(i, j) ) |
|---|
| 2628 | { |
|---|
| 2629 | READ_CODE( 16, uiCode, "avg_bit_rate[i][j]" ); vps->setAvgBitRate( i, j, uiCode ); |
|---|
| 2630 | READ_CODE( 16, uiCode, "max_bit_rate[i][j]" ); vps->setMaxBitRate( i, j, uiCode ); |
|---|
| 2631 | } |
|---|
| 2632 | else |
|---|
| 2633 | { |
|---|
| 2634 | vps->setAvgBitRate( i, j, 0 ); |
|---|
| 2635 | vps->setMaxBitRate( i, j, 0 ); |
|---|
| 2636 | } |
|---|
| 2637 | if( parseFlag && vps->getPicRatePresentFlag(i, j) ) |
|---|
| 2638 | { |
|---|
| 2639 | READ_CODE( 2 , uiCode, "constant_pic_rate_idc[i][j]" ); vps->setConstPicRateIdc( i, j, uiCode ); |
|---|
| 2640 | READ_CODE( 16, uiCode, "avg_pic_rate[i][j]" ); vps->setAvgPicRate( i, j, uiCode ); |
|---|
| 2641 | } |
|---|
| 2642 | else |
|---|
| 2643 | { |
|---|
| 2644 | vps->setConstPicRateIdc( i, j, 0 ); |
|---|
| 2645 | vps->setAvgPicRate ( i, j, 0 ); |
|---|
| 2646 | } |
|---|
| 2647 | } |
|---|
| 2648 | } |
|---|
| 2649 | #endif |
|---|
| 2650 | #if VPS_VUI_VIDEO_SIGNAL_MOVE |
|---|
| 2651 | READ_FLAG( uiCode, "video_signal_info_idx_present_flag" ); vps->setVideoSigPresentVpsFlag( uiCode == 1 ); |
|---|
| 2652 | if (vps->getVideoSigPresentVpsFlag()) |
|---|
| 2653 | { |
|---|
| 2654 | READ_CODE(4, uiCode, "vps_num_video_signal_info_minus1" ); vps->setNumVideoSignalInfo(uiCode + 1); |
|---|
| 2655 | } |
|---|
| 2656 | else |
|---|
| 2657 | { |
|---|
| 2658 | #if VPS_VUI_VST_PARAMS |
|---|
| 2659 | vps->setNumVideoSignalInfo(vps->getMaxLayers() - vps->getBaseLayerInternalFlag() ? 0 : 1); |
|---|
| 2660 | #else |
|---|
| 2661 | vps->setNumVideoSignalInfo(vps->getMaxLayers()); |
|---|
| 2662 | #endif |
|---|
| 2663 | } |
|---|
| 2664 | |
|---|
| 2665 | for(i = 0; i < vps->getNumVideoSignalInfo(); i++) |
|---|
| 2666 | { |
|---|
| 2667 | READ_CODE(3, uiCode, "video_vps_format" ); vps->setVideoVPSFormat(i,uiCode); |
|---|
| 2668 | READ_FLAG(uiCode, "video_full_range_vps_flag" ); vps->setVideoFullRangeVpsFlag(i,uiCode); |
|---|
| 2669 | READ_CODE(8, uiCode, "color_primaries_vps" ); vps->setColorPrimaries(i,uiCode); |
|---|
| 2670 | READ_CODE(8, uiCode, "transfer_characteristics_vps" ); vps->setTransCharacter(i,uiCode); |
|---|
| 2671 | READ_CODE(8, uiCode, "matrix_coeffs_vps" );vps->setMaxtrixCoeff(i,uiCode); |
|---|
| 2672 | } |
|---|
| 2673 | #if VPS_VUI_VST_PARAMS |
|---|
| 2674 | if( vps->getVideoSigPresentVpsFlag() && vps->getNumVideoSignalInfo() > 1 ) |
|---|
| 2675 | { |
|---|
| 2676 | for(i = vps->getBaseLayerInternalFlag() ? 0 : 1; i < vps->getMaxLayers(); i++) |
|---|
| 2677 | { |
|---|
| 2678 | READ_CODE(4, uiCode, "vps_video_signal_info_idx" ); vps->setVideoSignalInfoIdx(i, uiCode); |
|---|
| 2679 | } |
|---|
| 2680 | } |
|---|
| 2681 | else if ( !vps->getVideoSigPresentVpsFlag() ) |
|---|
| 2682 | { |
|---|
| 2683 | for(i = vps->getBaseLayerInternalFlag() ? 0 : 1; i < vps->getMaxLayers(); i++) |
|---|
| 2684 | { |
|---|
| 2685 | vps->setVideoSignalInfoIdx( i, i ); |
|---|
| 2686 | } |
|---|
| 2687 | } |
|---|
| 2688 | else // ( vps->getNumVideoSignalInfo() = 0 ) |
|---|
| 2689 | { |
|---|
| 2690 | for(i = vps->getBaseLayerInternalFlag() ? 0 : 1; i < vps->getMaxLayers(); i++) |
|---|
| 2691 | { |
|---|
| 2692 | vps->setVideoSignalInfoIdx( i, 0 ); |
|---|
| 2693 | } |
|---|
| 2694 | } |
|---|
| 2695 | #else |
|---|
| 2696 | if(!vps->getVideoSigPresentVpsFlag()) |
|---|
| 2697 | { |
|---|
| 2698 | for (i=0; i < vps->getMaxLayers(); i++) |
|---|
| 2699 | { |
|---|
| 2700 | vps->setVideoSignalInfoIdx(i,i); |
|---|
| 2701 | } |
|---|
| 2702 | } |
|---|
| 2703 | else { |
|---|
| 2704 | vps->setVideoSignalInfoIdx(0,0); |
|---|
| 2705 | if (vps->getNumVideoSignalInfo() > 1 ) |
|---|
| 2706 | { |
|---|
| 2707 | for (i=1; i < vps->getMaxLayers(); i++) |
|---|
| 2708 | READ_CODE(4, uiCode, "vps_video_signal_info_idx" ); vps->setVideoSignalInfoIdx(i, uiCode); |
|---|
| 2709 | } |
|---|
| 2710 | else { |
|---|
| 2711 | for (i=1; i < vps->getMaxLayers(); i++) |
|---|
| 2712 | { |
|---|
| 2713 | vps->setVideoSignalInfoIdx(i,0); |
|---|
| 2714 | } |
|---|
| 2715 | } |
|---|
| 2716 | } |
|---|
| 2717 | #endif |
|---|
| 2718 | #endif |
|---|
| 2719 | #if VPS_VUI_TILES_NOT_IN_USE__FLAG |
|---|
| 2720 | UInt layerIdx; |
|---|
| 2721 | READ_FLAG( uiCode, "tiles_not_in_use_flag" ); vps->setTilesNotInUseFlag(uiCode == 1); |
|---|
| 2722 | if (!uiCode) |
|---|
| 2723 | { |
|---|
| 2724 | for(i = 0; i < vps->getMaxLayers(); i++) |
|---|
| 2725 | { |
|---|
| 2726 | READ_FLAG( uiCode, "tiles_in_use_flag[ i ]" ); vps->setTilesInUseFlag(i, (uiCode == 1)); |
|---|
| 2727 | if (uiCode) |
|---|
| 2728 | { |
|---|
| 2729 | READ_FLAG( uiCode, "loop_filter_not_across_tiles_flag[ i ]" ); vps->setLoopFilterNotAcrossTilesFlag(i, (uiCode == 1)); |
|---|
| 2730 | } |
|---|
| 2731 | else |
|---|
| 2732 | { |
|---|
| 2733 | vps->setLoopFilterNotAcrossTilesFlag(i, false); |
|---|
| 2734 | } |
|---|
| 2735 | } |
|---|
| 2736 | #endif |
|---|
| 2737 | |
|---|
| 2738 | for(i = 1; i < vps->getMaxLayers(); i++) |
|---|
| 2739 | { |
|---|
| 2740 | for(j = 0; j < vps->getNumDirectRefLayers(vps->getLayerIdInNuh(i)); j++) |
|---|
| 2741 | { |
|---|
| 2742 | #if VPS_VUI_TILES_NOT_IN_USE__FLAG |
|---|
| 2743 | layerIdx = vps->getLayerIdInVps(vps->getRefLayerId(vps->getLayerIdInNuh(i), j)); |
|---|
| 2744 | if (vps->getTilesInUseFlag(i) && vps->getTilesInUseFlag(layerIdx)) { |
|---|
| 2745 | READ_FLAG( uiCode, "tile_boundaries_aligned_flag[i][j]" ); vps->setTileBoundariesAlignedFlag(i,j,(uiCode == 1)); |
|---|
| 2746 | } |
|---|
| 2747 | #else |
|---|
| 2748 | READ_FLAG( uiCode, "tile_boundaries_aligned_flag[i][j]" ); vps->setTileBoundariesAlignedFlag(i,j,(uiCode == 1)); |
|---|
| 2749 | #endif |
|---|
| 2750 | } |
|---|
| 2751 | } |
|---|
| 2752 | #if VPS_VUI_TILES_NOT_IN_USE__FLAG |
|---|
| 2753 | } |
|---|
| 2754 | #endif |
|---|
| 2755 | #if VPS_VUI_WPP_NOT_IN_USE__FLAG |
|---|
| 2756 | READ_FLAG( uiCode, "wpp_not_in_use_flag" ); vps->setWppNotInUseFlag(uiCode == 1); |
|---|
| 2757 | if (!uiCode) |
|---|
| 2758 | { |
|---|
| 2759 | for(i = 0; i < vps->getMaxLayers(); i++) |
|---|
| 2760 | { |
|---|
| 2761 | READ_FLAG( uiCode, "wpp_in_use_flag[ i ]" ); vps->setWppInUseFlag(i, (uiCode == 1)); |
|---|
| 2762 | } |
|---|
| 2763 | } |
|---|
| 2764 | #endif |
|---|
| 2765 | |
|---|
| 2766 | #if O0109_O0199_FLAGS_TO_VUI |
|---|
| 2767 | #if M0040_ADAPTIVE_RESOLUTION_CHANGE |
|---|
| 2768 | READ_FLAG(uiCode, "single_layer_for_non_irap_flag" ); vps->setSingleLayerForNonIrapFlag(uiCode == 1 ? true : false); |
|---|
| 2769 | #endif |
|---|
| 2770 | #if HIGHER_LAYER_IRAP_SKIP_FLAG |
|---|
| 2771 | READ_FLAG(uiCode, "higher_layer_irap_skip_flag" ); vps->setHigherLayerIrapSkipFlag(uiCode == 1 ? true : false); |
|---|
| 2772 | |
|---|
| 2773 | // When single_layer_for_non_irap_flag is equal to 0, higher_layer_irap_skip_flag shall be equal to 0 |
|---|
| 2774 | if( !vps->getSingleLayerForNonIrapFlag() ) |
|---|
| 2775 | { |
|---|
| 2776 | assert( !vps->getHigherLayerIrapSkipFlag() ); |
|---|
| 2777 | } |
|---|
| 2778 | #endif |
|---|
| 2779 | #endif |
|---|
| 2780 | #if P0312_VERT_PHASE_ADJ |
|---|
| 2781 | READ_FLAG( uiCode, "vps_vui_vert_phase_in_use_flag" ); vps->setVpsVuiVertPhaseInUseFlag(uiCode); |
|---|
| 2782 | #endif |
|---|
| 2783 | #if N0160_VUI_EXT_ILP_REF |
|---|
| 2784 | READ_FLAG( uiCode, "ilp_restricted_ref_layers_flag" ); vps->setIlpRestrictedRefLayersFlag( uiCode == 1 ); |
|---|
| 2785 | if( vps->getIlpRestrictedRefLayersFlag()) |
|---|
| 2786 | { |
|---|
| 2787 | for(i = 1; i < vps->getMaxLayers(); i++) |
|---|
| 2788 | { |
|---|
| 2789 | for(j = 0; j < vps->getNumDirectRefLayers(vps->getLayerIdInNuh(i)); j++) |
|---|
| 2790 | { |
|---|
| 2791 | READ_UVLC( uiCode, "min_spatial_segment_offset_plus1[i][j]" ); vps->setMinSpatialSegmentOffsetPlus1( i, j, uiCode ); |
|---|
| 2792 | if( vps->getMinSpatialSegmentOffsetPlus1(i,j ) > 0 ) |
|---|
| 2793 | { |
|---|
| 2794 | READ_FLAG( uiCode, "ctu_based_offset_enabled_flag[i][j]"); vps->setCtuBasedOffsetEnabledFlag(i, j, uiCode == 1 ); |
|---|
| 2795 | if(vps->getCtuBasedOffsetEnabledFlag(i,j)) |
|---|
| 2796 | { |
|---|
| 2797 | READ_UVLC( uiCode, "min_horizontal_ctu_offset_plus1[i][j]"); vps->setMinHorizontalCtuOffsetPlus1( i,j, uiCode ); |
|---|
| 2798 | } |
|---|
| 2799 | } |
|---|
| 2800 | } |
|---|
| 2801 | } |
|---|
| 2802 | } |
|---|
| 2803 | #endif |
|---|
| 2804 | #if VPS_VUI_VIDEO_SIGNAL |
|---|
| 2805 | #if VPS_VUI_VIDEO_SIGNAL_MOVE |
|---|
| 2806 | #else |
|---|
| 2807 | READ_FLAG( uiCode, "video_signal_info_idx_present_flag" ); vps->setVideoSigPresentVpsFlag( uiCode == 1 ); |
|---|
| 2808 | if (vps->getVideoSigPresentVpsFlag()) |
|---|
| 2809 | { |
|---|
| 2810 | READ_CODE(4, uiCode, "vps_num_video_signal_info_minus1" ); vps->setNumVideoSignalInfo(uiCode + 1); |
|---|
| 2811 | } |
|---|
| 2812 | else |
|---|
| 2813 | { |
|---|
| 2814 | vps->setNumVideoSignalInfo(vps->getMaxLayers()); |
|---|
| 2815 | } |
|---|
| 2816 | |
|---|
| 2817 | |
|---|
| 2818 | for(i = 0; i < vps->getNumVideoSignalInfo(); i++) |
|---|
| 2819 | { |
|---|
| 2820 | READ_CODE(3, uiCode, "video_vps_format" ); vps->setVideoVPSFormat(i,uiCode); |
|---|
| 2821 | READ_FLAG(uiCode, "video_full_range_vps_flag" ); vps->setVideoFullRangeVpsFlag(i,uiCode); |
|---|
| 2822 | READ_CODE(8, uiCode, "color_primaries_vps" ); vps->setColorPrimaries(i,uiCode); |
|---|
| 2823 | READ_CODE(8, uiCode, "transfer_characteristics_vps" ); vps->setTransCharacter(i,uiCode); |
|---|
| 2824 | READ_CODE(8, uiCode, "matrix_coeffs_vps" );vps->setMaxtrixCoeff(i,uiCode); |
|---|
| 2825 | } |
|---|
| 2826 | if(!vps->getVideoSigPresentVpsFlag()) |
|---|
| 2827 | { |
|---|
| 2828 | for (i=0; i < vps->getMaxLayers(); i++) |
|---|
| 2829 | { |
|---|
| 2830 | vps->setVideoSignalInfoIdx(i,i); |
|---|
| 2831 | } |
|---|
| 2832 | } |
|---|
| 2833 | else { |
|---|
| 2834 | vps->setVideoSignalInfoIdx(0,0); |
|---|
| 2835 | if (vps->getNumVideoSignalInfo() > 1 ) |
|---|
| 2836 | { |
|---|
| 2837 | for (i=1; i < vps->getMaxLayers(); i++) |
|---|
| 2838 | READ_CODE(4, uiCode, "vps_video_signal_info_idx" ); vps->setVideoSignalInfoIdx(i, uiCode); |
|---|
| 2839 | } |
|---|
| 2840 | else { |
|---|
| 2841 | for (i=1; i < vps->getMaxLayers(); i++) |
|---|
| 2842 | { |
|---|
| 2843 | vps->setVideoSignalInfoIdx(i,0); |
|---|
| 2844 | } |
|---|
| 2845 | } |
|---|
| 2846 | } |
|---|
| 2847 | #endif |
|---|
| 2848 | #endif |
|---|
| 2849 | |
|---|
| 2850 | #if O0164_MULTI_LAYER_HRD |
|---|
| 2851 | READ_FLAG(uiCode, "vps_vui_bsp_hrd_present_flag" ); vps->setVpsVuiBspHrdPresentFlag(uiCode); |
|---|
| 2852 | if (vps->getVpsVuiBspHrdPresentFlag()) |
|---|
| 2853 | { |
|---|
| 2854 | #if VPS_VUI_BSP_HRD_PARAMS |
|---|
| 2855 | parseVpsVuiBspHrdParams(vps); |
|---|
| 2856 | #else |
|---|
| 2857 | #if R0227_VUI_BSP_HRD_FLAG |
|---|
| 2858 | assert (vps->getTimingInfo()->getTimingInfoPresentFlag() == 1); |
|---|
| 2859 | #endif |
|---|
| 2860 | READ_UVLC( uiCode, "vps_num_bsp_hrd_parameters_minus1" ); vps->setVpsNumBspHrdParametersMinus1(uiCode); |
|---|
| 2861 | vps->createBspHrdParamBuffer(vps->getVpsNumBspHrdParametersMinus1() + 1); |
|---|
| 2862 | for( i = 0; i <= vps->getVpsNumBspHrdParametersMinus1(); i++ ) |
|---|
| 2863 | { |
|---|
| 2864 | if( i > 0 ) |
|---|
| 2865 | { |
|---|
| 2866 | READ_FLAG( uiCode, "bsp_cprms_present_flag[i]" ); vps->setBspCprmsPresentFlag(i, uiCode); |
|---|
| 2867 | } |
|---|
| 2868 | parseHrdParameters(vps->getBspHrd(i), i==0 ? 1 : vps->getBspCprmsPresentFlag(i), vps->getMaxTLayers()-1); |
|---|
| 2869 | } |
|---|
| 2870 | #if Q0078_ADD_LAYER_SETS |
|---|
| 2871 | for (UInt h = 1; h <= vps->getVpsNumLayerSetsMinus1(); h++) |
|---|
| 2872 | #else |
|---|
| 2873 | for( UInt h = 1; h <= (vps->getNumLayerSets()-1); h++ ) |
|---|
| 2874 | #endif |
|---|
| 2875 | { |
|---|
| 2876 | READ_UVLC( uiCode, "num_bitstream_partitions[i]"); vps->setNumBitstreamPartitions(h, uiCode); |
|---|
| 2877 | #if HRD_BPB |
|---|
| 2878 | Int chkPart=0; |
|---|
| 2879 | #endif |
|---|
| 2880 | for( i = 0; i < vps->getNumBitstreamPartitions(h); i++ ) |
|---|
| 2881 | { |
|---|
| 2882 | for( j = 0; j <= (vps->getMaxLayers()-1); j++ ) |
|---|
| 2883 | { |
|---|
| 2884 | if( vps->getLayerIdIncludedFlag(h, j) ) |
|---|
| 2885 | { |
|---|
| 2886 | READ_FLAG( uiCode, "layer_in_bsp_flag[h][i][j]" ); vps->setLayerInBspFlag(h, i, j, uiCode); |
|---|
| 2887 | } |
|---|
| 2888 | } |
|---|
| 2889 | #if HRD_BPB |
|---|
| 2890 | chkPart+=vps->getLayerInBspFlag(h, i, j); |
|---|
| 2891 | #endif |
|---|
| 2892 | } |
|---|
| 2893 | #if HRD_BPB |
|---|
| 2894 | assert(chkPart<=1); |
|---|
| 2895 | #endif |
|---|
| 2896 | #if HRD_BPB |
|---|
| 2897 | if(vps->getNumBitstreamPartitions(h)==1) |
|---|
| 2898 | { |
|---|
| 2899 | Int chkPartition1=0; Int chkPartition2=0; |
|---|
| 2900 | for( j = 0; j <= (vps->getMaxLayers()-1); j++ ) |
|---|
| 2901 | { |
|---|
| 2902 | if( vps->getLayerIdIncludedFlag(h, j) ) |
|---|
| 2903 | { |
|---|
| 2904 | chkPartition1+=vps->getLayerInBspFlag(h, 0, j); |
|---|
| 2905 | chkPartition2++; |
|---|
| 2906 | } |
|---|
| 2907 | } |
|---|
| 2908 | assert(chkPartition1!=chkPartition2); |
|---|
| 2909 | } |
|---|
| 2910 | #endif |
|---|
| 2911 | if (vps->getNumBitstreamPartitions(h)) |
|---|
| 2912 | { |
|---|
| 2913 | #if Q0182_MULTI_LAYER_HRD_UPDATE |
|---|
| 2914 | READ_UVLC( uiCode, "num_bsp_sched_combinations_minus1[h]"); vps->setNumBspSchedCombinations(h, uiCode + 1); |
|---|
| 2915 | #else |
|---|
| 2916 | READ_UVLC( uiCode, "num_bsp_sched_combinations[h]"); vps->setNumBspSchedCombinations(h, uiCode); |
|---|
| 2917 | #endif |
|---|
| 2918 | for( i = 0; i < vps->getNumBspSchedCombinations(h); i++ ) |
|---|
| 2919 | { |
|---|
| 2920 | for( j = 0; j < vps->getNumBitstreamPartitions(h); j++ ) |
|---|
| 2921 | { |
|---|
| 2922 | READ_UVLC( uiCode, "bsp_comb_hrd_idx[h][i][j]"); vps->setBspCombHrdIdx(h, i, j, uiCode); |
|---|
| 2923 | #if HRD_BPB |
|---|
| 2924 | assert(uiCode <= vps->getVpsNumBspHrdParametersMinus1()); |
|---|
| 2925 | #endif |
|---|
| 2926 | |
|---|
| 2927 | READ_UVLC( uiCode, "bsp_comb_sched_idx[h][i][j]"); vps->setBspCombSchedIdx(h, i, j, uiCode); |
|---|
| 2928 | #if HRD_BPB |
|---|
| 2929 | assert(uiCode <= vps->getBspHrdParamBufferCpbCntMinus1(uiCode,vps->getMaxTLayers()-1)); |
|---|
| 2930 | #endif |
|---|
| 2931 | } |
|---|
| 2932 | } |
|---|
| 2933 | } |
|---|
| 2934 | } |
|---|
| 2935 | #endif |
|---|
| 2936 | } |
|---|
| 2937 | #endif |
|---|
| 2938 | #if P0182_VPS_VUI_PS_FLAG |
|---|
| 2939 | for(i = 1; i < vps->getMaxLayers(); i++) |
|---|
| 2940 | { |
|---|
| 2941 | if (vps->getNumRefLayers(vps->getLayerIdInNuh(i)) == 0) |
|---|
| 2942 | { |
|---|
| 2943 | READ_FLAG( uiCode, "base_layer_parameter_set_compatibility_flag" ); |
|---|
| 2944 | vps->setBaseLayerPSCompatibilityFlag( i, uiCode ); |
|---|
| 2945 | } |
|---|
| 2946 | else |
|---|
| 2947 | { |
|---|
| 2948 | vps->setBaseLayerPSCompatibilityFlag( i, 0 ); |
|---|
| 2949 | } |
|---|
| 2950 | } |
|---|
| 2951 | #endif |
|---|
| 2952 | } |
|---|
| 2953 | |
|---|
| 2954 | #endif //SVC_EXTENSION |
|---|
| 2955 | |
|---|
| 2956 | Void TDecCavlc::parseSliceHeader (TComSlice*& rpcSlice, ParameterSetManagerDecoder *parameterSetManager) |
|---|
| 2957 | { |
|---|
| 2958 | UInt uiCode; |
|---|
| 2959 | Int iCode; |
|---|
| 2960 | |
|---|
| 2961 | #if ENC_DEC_TRACE |
|---|
| 2962 | xTraceSliceHeader(rpcSlice); |
|---|
| 2963 | #endif |
|---|
| 2964 | TComPPS* pps = NULL; |
|---|
| 2965 | TComSPS* sps = NULL; |
|---|
| 2966 | |
|---|
| 2967 | UInt firstSliceSegmentInPic; |
|---|
| 2968 | READ_FLAG( firstSliceSegmentInPic, "first_slice_segment_in_pic_flag" ); |
|---|
| 2969 | if( rpcSlice->getRapPicFlag()) |
|---|
| 2970 | { |
|---|
| 2971 | READ_FLAG( uiCode, "no_output_of_prior_pics_flag" ); //ignored -- updated already |
|---|
| 2972 | #if SETTING_NO_OUT_PIC_PRIOR |
|---|
| 2973 | rpcSlice->setNoOutputPriorPicsFlag(uiCode ? true : false); |
|---|
| 2974 | #else |
|---|
| 2975 | rpcSlice->setNoOutputPicPrior( false ); |
|---|
| 2976 | #endif |
|---|
| 2977 | } |
|---|
| 2978 | READ_UVLC ( uiCode, "slice_pic_parameter_set_id" ); rpcSlice->setPPSId(uiCode); |
|---|
| 2979 | pps = parameterSetManager->getPrefetchedPPS(uiCode); |
|---|
| 2980 | //!KS: need to add error handling code here, if PPS is not available |
|---|
| 2981 | assert(pps!=0); |
|---|
| 2982 | sps = parameterSetManager->getPrefetchedSPS(pps->getSPSId()); |
|---|
| 2983 | //!KS: need to add error handling code here, if SPS is not available |
|---|
| 2984 | assert(sps!=0); |
|---|
| 2985 | rpcSlice->setSPS(sps); |
|---|
| 2986 | rpcSlice->setPPS(pps); |
|---|
| 2987 | |
|---|
| 2988 | #if R0227_REP_FORMAT_CONSTRAINT //Conformance checking for rep format -- rep format of current picture of current layer shall never be greater rep format defined in VPS for the current layer |
|---|
| 2989 | TComVPS* vps = NULL; |
|---|
| 2990 | vps = parameterSetManager->getPrefetchedVPS(sps->getVPSId()); |
|---|
| 2991 | #if R0279_REP_FORMAT_INBL |
|---|
| 2992 | if ( vps->getVpsExtensionFlag() == 1 && (rpcSlice->getLayerId() == 0 || sps->getV1CompatibleSPSFlag() == 1) ) |
|---|
| 2993 | { |
|---|
| 2994 | assert( sps->getPicWidthInLumaSamples() <= vps->getVpsRepFormat( vps->getVpsRepFormatIdx(rpcSlice->getLayerId()) )->getPicWidthVpsInLumaSamples() ); |
|---|
| 2995 | assert( sps->getPicHeightInLumaSamples() <= vps->getVpsRepFormat( vps->getVpsRepFormatIdx(rpcSlice->getLayerId()) )->getPicHeightVpsInLumaSamples() ); |
|---|
| 2996 | assert( sps->getChromaFormatIdc() <= vps->getVpsRepFormat( vps->getVpsRepFormatIdx(rpcSlice->getLayerId()) )->getChromaFormatVpsIdc() ); |
|---|
| 2997 | assert( sps->getBitDepthY() <= vps->getVpsRepFormat( vps->getVpsRepFormatIdx(rpcSlice->getLayerId()) )->getBitDepthVpsLuma() ); |
|---|
| 2998 | assert( sps->getBitDepthC() <= vps->getVpsRepFormat( vps->getVpsRepFormatIdx(rpcSlice->getLayerId()) )->getBitDepthVpsChroma() ); |
|---|
| 2999 | #else |
|---|
| 3000 | if ( rpcSlice->getLayerId() == 0 && vps->getVpsExtensionFlag() == 1 ) |
|---|
| 3001 | { |
|---|
| 3002 | assert( sps->getPicWidthInLumaSamples() <= vps->getVpsRepFormat( vps->getVpsRepFormatIdx(0) )->getPicWidthVpsInLumaSamples() ); |
|---|
| 3003 | assert( sps->getPicHeightInLumaSamples() <= vps->getVpsRepFormat( vps->getVpsRepFormatIdx(0) )->getPicHeightVpsInLumaSamples() ); |
|---|
| 3004 | assert( sps->getChromaFormatIdc() <= vps->getVpsRepFormat( vps->getVpsRepFormatIdx(0) )->getChromaFormatVpsIdc() ); |
|---|
| 3005 | assert( sps->getBitDepthY() <= vps->getVpsRepFormat( vps->getVpsRepFormatIdx(0) )->getBitDepthVpsLuma() ); |
|---|
| 3006 | assert( sps->getBitDepthC() <= vps->getVpsRepFormat( vps->getVpsRepFormatIdx(0) )->getBitDepthVpsChroma() ); |
|---|
| 3007 | #endif |
|---|
| 3008 | } |
|---|
| 3009 | else if ( vps->getVpsExtensionFlag() == 1 ) |
|---|
| 3010 | { |
|---|
| 3011 | assert(vps->getVpsRepFormat( vps->getVpsRepFormatIdx(sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : rpcSlice->getLayerId()))->getPicWidthVpsInLumaSamples() <= vps->getVpsRepFormat( vps->getVpsRepFormatIdx(rpcSlice->getLayerId()))->getPicWidthVpsInLumaSamples()); |
|---|
| 3012 | assert(vps->getVpsRepFormat( vps->getVpsRepFormatIdx(sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : rpcSlice->getLayerId()))->getPicHeightVpsInLumaSamples() <= vps->getVpsRepFormat( vps->getVpsRepFormatIdx(rpcSlice->getLayerId()))->getPicHeightVpsInLumaSamples()); |
|---|
| 3013 | assert(vps->getVpsRepFormat( vps->getVpsRepFormatIdx(sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : rpcSlice->getLayerId()))->getChromaFormatVpsIdc() <= vps->getVpsRepFormat( vps->getVpsRepFormatIdx(rpcSlice->getLayerId()))->getChromaFormatVpsIdc()); |
|---|
| 3014 | assert(vps->getVpsRepFormat( vps->getVpsRepFormatIdx(sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : rpcSlice->getLayerId()))->getBitDepthVpsLuma() <= vps->getVpsRepFormat( vps->getVpsRepFormatIdx(rpcSlice->getLayerId()))->getBitDepthVpsLuma()); |
|---|
| 3015 | assert(vps->getVpsRepFormat( vps->getVpsRepFormatIdx(sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : rpcSlice->getLayerId()))->getBitDepthVpsChroma() <= vps->getVpsRepFormat( vps->getVpsRepFormatIdx(rpcSlice->getLayerId()))->getBitDepthVpsChroma()); |
|---|
| 3016 | } |
|---|
| 3017 | #endif |
|---|
| 3018 | |
|---|
| 3019 | if( pps->getDependentSliceSegmentsEnabledFlag() && ( !firstSliceSegmentInPic )) |
|---|
| 3020 | { |
|---|
| 3021 | READ_FLAG( uiCode, "dependent_slice_segment_flag" ); rpcSlice->setDependentSliceSegmentFlag(uiCode ? true : false); |
|---|
| 3022 | } |
|---|
| 3023 | else |
|---|
| 3024 | { |
|---|
| 3025 | rpcSlice->setDependentSliceSegmentFlag(false); |
|---|
| 3026 | } |
|---|
| 3027 | #if REPN_FORMAT_IN_VPS |
|---|
| 3028 | Int numCTUs = ((rpcSlice->getPicWidthInLumaSamples()+sps->getMaxCUWidth()-1)/sps->getMaxCUWidth())*((rpcSlice->getPicHeightInLumaSamples()+sps->getMaxCUHeight()-1)/sps->getMaxCUHeight()); |
|---|
| 3029 | #else |
|---|
| 3030 | Int numCTUs = ((sps->getPicWidthInLumaSamples()+sps->getMaxCUWidth()-1)/sps->getMaxCUWidth())*((sps->getPicHeightInLumaSamples()+sps->getMaxCUHeight()-1)/sps->getMaxCUHeight()); |
|---|
| 3031 | #endif |
|---|
| 3032 | Int maxParts = (1<<(sps->getMaxCUDepth()<<1)); |
|---|
| 3033 | UInt sliceSegmentAddress = 0; |
|---|
| 3034 | Int bitsSliceSegmentAddress = 0; |
|---|
| 3035 | while(numCTUs>(1<<bitsSliceSegmentAddress)) |
|---|
| 3036 | { |
|---|
| 3037 | bitsSliceSegmentAddress++; |
|---|
| 3038 | } |
|---|
| 3039 | |
|---|
| 3040 | if(!firstSliceSegmentInPic) |
|---|
| 3041 | { |
|---|
| 3042 | READ_CODE( bitsSliceSegmentAddress, sliceSegmentAddress, "slice_segment_address" ); |
|---|
| 3043 | } |
|---|
| 3044 | //set uiCode to equal slice start address (or dependent slice start address) |
|---|
| 3045 | Int startCuAddress = maxParts*sliceSegmentAddress; |
|---|
| 3046 | rpcSlice->setSliceSegmentCurStartCUAddr( startCuAddress ); |
|---|
| 3047 | rpcSlice->setSliceSegmentCurEndCUAddr(numCTUs*maxParts); |
|---|
| 3048 | |
|---|
| 3049 | if (rpcSlice->getDependentSliceSegmentFlag()) |
|---|
| 3050 | { |
|---|
| 3051 | rpcSlice->setNextSlice ( false ); |
|---|
| 3052 | rpcSlice->setNextSliceSegment ( true ); |
|---|
| 3053 | } |
|---|
| 3054 | else |
|---|
| 3055 | { |
|---|
| 3056 | rpcSlice->setNextSlice ( true ); |
|---|
| 3057 | rpcSlice->setNextSliceSegment ( false ); |
|---|
| 3058 | |
|---|
| 3059 | rpcSlice->setSliceCurStartCUAddr(startCuAddress); |
|---|
| 3060 | rpcSlice->setSliceCurEndCUAddr(numCTUs*maxParts); |
|---|
| 3061 | } |
|---|
| 3062 | |
|---|
| 3063 | #if Q0142_POC_LSB_NOT_PRESENT |
|---|
| 3064 | #if SHM_FIX7 |
|---|
| 3065 | Int iPOClsb = 0; |
|---|
| 3066 | #endif |
|---|
| 3067 | #endif |
|---|
| 3068 | |
|---|
| 3069 | if(!rpcSlice->getDependentSliceSegmentFlag()) |
|---|
| 3070 | { |
|---|
| 3071 | #if SVC_EXTENSION |
|---|
| 3072 | #if POC_RESET_FLAG |
|---|
| 3073 | Int iBits = 0; |
|---|
| 3074 | if(rpcSlice->getPPS()->getNumExtraSliceHeaderBits() > iBits) |
|---|
| 3075 | { |
|---|
| 3076 | READ_FLAG(uiCode, "poc_reset_flag"); rpcSlice->setPocResetFlag( uiCode ? true : false ); |
|---|
| 3077 | iBits++; |
|---|
| 3078 | } |
|---|
| 3079 | if(rpcSlice->getPPS()->getNumExtraSliceHeaderBits() > iBits) |
|---|
| 3080 | { |
|---|
| 3081 | #if DISCARDABLE_PIC_RPS |
|---|
| 3082 | READ_FLAG(uiCode, "discardable_flag"); rpcSlice->setDiscardableFlag( uiCode ? true : false ); |
|---|
| 3083 | #else |
|---|
| 3084 | READ_FLAG(uiCode, "discardable_flag"); // ignored |
|---|
| 3085 | #endif |
|---|
| 3086 | iBits++; |
|---|
| 3087 | } |
|---|
| 3088 | #if O0149_CROSS_LAYER_BLA_FLAG |
|---|
| 3089 | if(rpcSlice->getPPS()->getNumExtraSliceHeaderBits() > iBits) |
|---|
| 3090 | { |
|---|
| 3091 | READ_FLAG(uiCode, "cross_layer_bla_flag"); rpcSlice->setCrossLayerBLAFlag( uiCode ? true : false ); |
|---|
| 3092 | iBits++; |
|---|
| 3093 | } |
|---|
| 3094 | #endif |
|---|
| 3095 | for (; iBits < rpcSlice->getPPS()->getNumExtraSliceHeaderBits(); iBits++) |
|---|
| 3096 | { |
|---|
| 3097 | READ_FLAG(uiCode, "slice_reserved_undetermined_flag[]"); // ignored |
|---|
| 3098 | } |
|---|
| 3099 | #else |
|---|
| 3100 | #if CROSS_LAYER_BLA_FLAG_FIX |
|---|
| 3101 | Int iBits = 0; |
|---|
| 3102 | if(rpcSlice->getPPS()->getNumExtraSliceHeaderBits() > iBits) |
|---|
| 3103 | #else |
|---|
| 3104 | if(rpcSlice->getPPS()->getNumExtraSliceHeaderBits()>0) |
|---|
| 3105 | #endif |
|---|
| 3106 | { |
|---|
| 3107 | READ_FLAG(uiCode, "discardable_flag"); // ignored |
|---|
| 3108 | #if NON_REF_NAL_TYPE_DISCARDABLE |
|---|
| 3109 | rpcSlice->setDiscardableFlag( uiCode ? true : false ); |
|---|
| 3110 | if (uiCode) |
|---|
| 3111 | { |
|---|
| 3112 | assert(rpcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_TRAIL_R && |
|---|
| 3113 | rpcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_TSA_R && |
|---|
| 3114 | rpcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_STSA_R && |
|---|
| 3115 | rpcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_RADL_R && |
|---|
| 3116 | rpcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_RASL_R); |
|---|
| 3117 | } |
|---|
| 3118 | #endif |
|---|
| 3119 | #if CROSS_LAYER_BLA_FLAG_FIX |
|---|
| 3120 | iBits++; |
|---|
| 3121 | #endif |
|---|
| 3122 | } |
|---|
| 3123 | #if CROSS_LAYER_BLA_FLAG_FIX |
|---|
| 3124 | if(rpcSlice->getPPS()->getNumExtraSliceHeaderBits() > iBits) |
|---|
| 3125 | { |
|---|
| 3126 | READ_FLAG(uiCode, "cross_layer_bla_flag"); rpcSlice->setCrossLayerBLAFlag( uiCode ? true : false ); |
|---|
| 3127 | iBits++; |
|---|
| 3128 | } |
|---|
| 3129 | for ( ; iBits < rpcSlice->getPPS()->getNumExtraSliceHeaderBits(); iBits++) |
|---|
| 3130 | #else |
|---|
| 3131 | for (Int i = 1; i < rpcSlice->getPPS()->getNumExtraSliceHeaderBits(); i++) |
|---|
| 3132 | #endif |
|---|
| 3133 | { |
|---|
| 3134 | READ_FLAG(uiCode, "slice_reserved_undetermined_flag[]"); // ignored |
|---|
| 3135 | } |
|---|
| 3136 | #endif |
|---|
| 3137 | #else //SVC_EXTENSION |
|---|
| 3138 | for (Int i = 0; i < rpcSlice->getPPS()->getNumExtraSliceHeaderBits(); i++) |
|---|
| 3139 | { |
|---|
| 3140 | READ_FLAG(uiCode, "slice_reserved_undetermined_flag[]"); // ignored |
|---|
| 3141 | } |
|---|
| 3142 | #endif //SVC_EXTENSION |
|---|
| 3143 | |
|---|
| 3144 | READ_UVLC ( uiCode, "slice_type" ); rpcSlice->setSliceType((SliceType)uiCode); |
|---|
| 3145 | if( pps->getOutputFlagPresentFlag() ) |
|---|
| 3146 | { |
|---|
| 3147 | READ_FLAG( uiCode, "pic_output_flag" ); rpcSlice->setPicOutputFlag( uiCode ? true : false ); |
|---|
| 3148 | } |
|---|
| 3149 | else |
|---|
| 3150 | { |
|---|
| 3151 | rpcSlice->setPicOutputFlag( true ); |
|---|
| 3152 | } |
|---|
| 3153 | // in the first version chroma_format_idc is equal to one, thus colour_plane_id will not be present |
|---|
| 3154 | assert (sps->getChromaFormatIdc() == 1 ); |
|---|
| 3155 | // if( separate_colour_plane_flag == 1 ) |
|---|
| 3156 | // colour_plane_id u(2) |
|---|
| 3157 | |
|---|
| 3158 | if( rpcSlice->getIdrPicFlag() ) |
|---|
| 3159 | { |
|---|
| 3160 | rpcSlice->setPOC(0); |
|---|
| 3161 | TComReferencePictureSet* rps = rpcSlice->getLocalRPS(); |
|---|
| 3162 | rps->setNumberOfNegativePictures(0); |
|---|
| 3163 | rps->setNumberOfPositivePictures(0); |
|---|
| 3164 | rps->setNumberOfLongtermPictures(0); |
|---|
| 3165 | rps->setNumberOfPictures(0); |
|---|
| 3166 | rpcSlice->setRPS(rps); |
|---|
| 3167 | } |
|---|
| 3168 | #if N0065_LAYER_POC_ALIGNMENT |
|---|
| 3169 | #if !Q0142_POC_LSB_NOT_PRESENT |
|---|
| 3170 | #if SHM_FIX7 |
|---|
| 3171 | Int iPOClsb = 0; |
|---|
| 3172 | #endif |
|---|
| 3173 | #endif |
|---|
| 3174 | #if O0062_POC_LSB_NOT_PRESENT_FLAG |
|---|
| 3175 | if( ( rpcSlice->getLayerId() > 0 && !rpcSlice->getVPS()->getPocLsbNotPresentFlag( rpcSlice->getVPS()->getLayerIdInVps(rpcSlice->getLayerId())) ) || !rpcSlice->getIdrPicFlag()) |
|---|
| 3176 | #else |
|---|
| 3177 | if( rpcSlice->getLayerId() > 0 || !rpcSlice->getIdrPicFlag() ) |
|---|
| 3178 | #endif |
|---|
| 3179 | #else |
|---|
| 3180 | else |
|---|
| 3181 | #endif |
|---|
| 3182 | { |
|---|
| 3183 | READ_CODE(sps->getBitsForPOC(), uiCode, "pic_order_cnt_lsb"); |
|---|
| 3184 | #if POC_RESET_IDC_DECODER |
|---|
| 3185 | rpcSlice->setPicOrderCntLsb( uiCode ); |
|---|
| 3186 | #endif |
|---|
| 3187 | #if SHM_FIX7 |
|---|
| 3188 | iPOClsb = uiCode; |
|---|
| 3189 | #else |
|---|
| 3190 | Int iPOClsb = uiCode; |
|---|
| 3191 | #endif |
|---|
| 3192 | Int iPrevPOC = rpcSlice->getPrevTid0POC(); |
|---|
| 3193 | Int iMaxPOClsb = 1<< sps->getBitsForPOC(); |
|---|
| 3194 | Int iPrevPOClsb = iPrevPOC & (iMaxPOClsb - 1); |
|---|
| 3195 | Int iPrevPOCmsb = iPrevPOC-iPrevPOClsb; |
|---|
| 3196 | Int iPOCmsb; |
|---|
| 3197 | if( ( iPOClsb < iPrevPOClsb ) && ( ( iPrevPOClsb - iPOClsb ) >= ( iMaxPOClsb / 2 ) ) ) |
|---|
| 3198 | { |
|---|
| 3199 | iPOCmsb = iPrevPOCmsb + iMaxPOClsb; |
|---|
| 3200 | } |
|---|
| 3201 | else if( (iPOClsb > iPrevPOClsb ) && ( (iPOClsb - iPrevPOClsb ) > ( iMaxPOClsb / 2 ) ) ) |
|---|
| 3202 | { |
|---|
| 3203 | iPOCmsb = iPrevPOCmsb - iMaxPOClsb; |
|---|
| 3204 | } |
|---|
| 3205 | else |
|---|
| 3206 | { |
|---|
| 3207 | iPOCmsb = iPrevPOCmsb; |
|---|
| 3208 | } |
|---|
| 3209 | if ( rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP |
|---|
| 3210 | || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL |
|---|
| 3211 | || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP ) |
|---|
| 3212 | { |
|---|
| 3213 | // For BLA picture types, POCmsb is set to 0. |
|---|
| 3214 | iPOCmsb = 0; |
|---|
| 3215 | } |
|---|
| 3216 | rpcSlice->setPOC (iPOCmsb+iPOClsb); |
|---|
| 3217 | |
|---|
| 3218 | #if N0065_LAYER_POC_ALIGNMENT |
|---|
| 3219 | #if SHM_FIX7 |
|---|
| 3220 | } |
|---|
| 3221 | #endif |
|---|
| 3222 | #if POC_RESET_IDC_DECODER |
|---|
| 3223 | else |
|---|
| 3224 | { |
|---|
| 3225 | rpcSlice->setPicOrderCntLsb( 0 ); |
|---|
| 3226 | } |
|---|
| 3227 | #endif |
|---|
| 3228 | if( !rpcSlice->getIdrPicFlag() ) |
|---|
| 3229 | { |
|---|
| 3230 | #endif |
|---|
| 3231 | TComReferencePictureSet* rps; |
|---|
| 3232 | rps = rpcSlice->getLocalRPS(); |
|---|
| 3233 | rpcSlice->setRPS(rps); |
|---|
| 3234 | READ_FLAG( uiCode, "short_term_ref_pic_set_sps_flag" ); |
|---|
| 3235 | if(uiCode == 0) // use short-term reference picture set explicitly signalled in slice header |
|---|
| 3236 | { |
|---|
| 3237 | parseShortTermRefPicSet(sps,rps, sps->getRPSList()->getNumberOfReferencePictureSets()); |
|---|
| 3238 | } |
|---|
| 3239 | else // use reference to short-term reference picture set in PPS |
|---|
| 3240 | { |
|---|
| 3241 | Int numBits = 0; |
|---|
| 3242 | while ((1 << numBits) < rpcSlice->getSPS()->getRPSList()->getNumberOfReferencePictureSets()) |
|---|
| 3243 | { |
|---|
| 3244 | numBits++; |
|---|
| 3245 | } |
|---|
| 3246 | if (numBits > 0) |
|---|
| 3247 | { |
|---|
| 3248 | READ_CODE( numBits, uiCode, "short_term_ref_pic_set_idx"); |
|---|
| 3249 | } |
|---|
| 3250 | else |
|---|
| 3251 | { |
|---|
| 3252 | uiCode = 0; |
|---|
| 3253 | } |
|---|
| 3254 | *rps = *(sps->getRPSList()->getReferencePictureSet(uiCode)); |
|---|
| 3255 | } |
|---|
| 3256 | if(sps->getLongTermRefsPresent()) |
|---|
| 3257 | { |
|---|
| 3258 | Int offset = rps->getNumberOfNegativePictures()+rps->getNumberOfPositivePictures(); |
|---|
| 3259 | UInt numOfLtrp = 0; |
|---|
| 3260 | UInt numLtrpInSPS = 0; |
|---|
| 3261 | if (rpcSlice->getSPS()->getNumLongTermRefPicSPS() > 0) |
|---|
| 3262 | { |
|---|
| 3263 | READ_UVLC( uiCode, "num_long_term_sps"); |
|---|
| 3264 | numLtrpInSPS = uiCode; |
|---|
| 3265 | numOfLtrp += numLtrpInSPS; |
|---|
| 3266 | rps->setNumberOfLongtermPictures(numOfLtrp); |
|---|
| 3267 | } |
|---|
| 3268 | Int bitsForLtrpInSPS = 0; |
|---|
| 3269 | while (rpcSlice->getSPS()->getNumLongTermRefPicSPS() > (1 << bitsForLtrpInSPS)) |
|---|
| 3270 | { |
|---|
| 3271 | bitsForLtrpInSPS++; |
|---|
| 3272 | } |
|---|
| 3273 | READ_UVLC( uiCode, "num_long_term_pics"); rps->setNumberOfLongtermPictures(uiCode); |
|---|
| 3274 | numOfLtrp += uiCode; |
|---|
| 3275 | rps->setNumberOfLongtermPictures(numOfLtrp); |
|---|
| 3276 | Int maxPicOrderCntLSB = 1 << rpcSlice->getSPS()->getBitsForPOC(); |
|---|
| 3277 | Int prevDeltaMSB = 0, deltaPocMSBCycleLT = 0;; |
|---|
| 3278 | for(Int j=offset+rps->getNumberOfLongtermPictures()-1, k = 0; k < numOfLtrp; j--, k++) |
|---|
| 3279 | { |
|---|
| 3280 | Int pocLsbLt; |
|---|
| 3281 | if (k < numLtrpInSPS) |
|---|
| 3282 | { |
|---|
| 3283 | uiCode = 0; |
|---|
| 3284 | if (bitsForLtrpInSPS > 0) |
|---|
| 3285 | { |
|---|
| 3286 | READ_CODE(bitsForLtrpInSPS, uiCode, "lt_idx_sps[i]"); |
|---|
| 3287 | } |
|---|
| 3288 | Int usedByCurrFromSPS=rpcSlice->getSPS()->getUsedByCurrPicLtSPSFlag(uiCode); |
|---|
| 3289 | |
|---|
| 3290 | pocLsbLt = rpcSlice->getSPS()->getLtRefPicPocLsbSps(uiCode); |
|---|
| 3291 | rps->setUsed(j,usedByCurrFromSPS); |
|---|
| 3292 | } |
|---|
| 3293 | else |
|---|
| 3294 | { |
|---|
| 3295 | READ_CODE(rpcSlice->getSPS()->getBitsForPOC(), uiCode, "poc_lsb_lt"); pocLsbLt= uiCode; |
|---|
| 3296 | READ_FLAG( uiCode, "used_by_curr_pic_lt_flag"); rps->setUsed(j,uiCode); |
|---|
| 3297 | } |
|---|
| 3298 | READ_FLAG(uiCode,"delta_poc_msb_present_flag"); |
|---|
| 3299 | Bool mSBPresentFlag = uiCode ? true : false; |
|---|
| 3300 | if(mSBPresentFlag) |
|---|
| 3301 | { |
|---|
| 3302 | READ_UVLC( uiCode, "delta_poc_msb_cycle_lt[i]" ); |
|---|
| 3303 | Bool deltaFlag = false; |
|---|
| 3304 | // First LTRP || First LTRP from SH |
|---|
| 3305 | if( (j == offset+rps->getNumberOfLongtermPictures()-1) || (j == offset+(numOfLtrp-numLtrpInSPS)-1) ) |
|---|
| 3306 | { |
|---|
| 3307 | deltaFlag = true; |
|---|
| 3308 | } |
|---|
| 3309 | if(deltaFlag) |
|---|
| 3310 | { |
|---|
| 3311 | deltaPocMSBCycleLT = uiCode; |
|---|
| 3312 | } |
|---|
| 3313 | else |
|---|
| 3314 | { |
|---|
| 3315 | deltaPocMSBCycleLT = uiCode + prevDeltaMSB; |
|---|
| 3316 | } |
|---|
| 3317 | |
|---|
| 3318 | Int pocLTCurr = rpcSlice->getPOC() - deltaPocMSBCycleLT * maxPicOrderCntLSB |
|---|
| 3319 | - iPOClsb + pocLsbLt; |
|---|
| 3320 | rps->setPOC (j, pocLTCurr); |
|---|
| 3321 | rps->setDeltaPOC(j, - rpcSlice->getPOC() + pocLTCurr); |
|---|
| 3322 | rps->setCheckLTMSBPresent(j,true); |
|---|
| 3323 | } |
|---|
| 3324 | else |
|---|
| 3325 | { |
|---|
| 3326 | rps->setPOC (j, pocLsbLt); |
|---|
| 3327 | rps->setDeltaPOC(j, - rpcSlice->getPOC() + pocLsbLt); |
|---|
| 3328 | rps->setCheckLTMSBPresent(j,false); |
|---|
| 3329 | |
|---|
| 3330 | // reset deltaPocMSBCycleLT for first LTRP from slice header if MSB not present |
|---|
| 3331 | if( j == offset+(numOfLtrp-numLtrpInSPS)-1 ) |
|---|
| 3332 | { |
|---|
| 3333 | deltaPocMSBCycleLT = 0; |
|---|
| 3334 | } |
|---|
| 3335 | } |
|---|
| 3336 | prevDeltaMSB = deltaPocMSBCycleLT; |
|---|
| 3337 | } |
|---|
| 3338 | offset += rps->getNumberOfLongtermPictures(); |
|---|
| 3339 | rps->setNumberOfPictures(offset); |
|---|
| 3340 | } |
|---|
| 3341 | #if DPB_CONSTRAINTS |
|---|
| 3342 | if(rpcSlice->getVPS()->getVpsExtensionFlag()==1) |
|---|
| 3343 | { |
|---|
| 3344 | #if Q0078_ADD_LAYER_SETS |
|---|
| 3345 | for (Int ii = 1; ii < (rpcSlice->getVPS()->getVpsNumLayerSetsMinus1() + 1); ii++) // prevent assert error when num_add_layer_sets > 0 |
|---|
| 3346 | #else |
|---|
| 3347 | for (Int ii=1; ii< rpcSlice->getVPS()->getNumOutputLayerSets(); ii++ ) |
|---|
| 3348 | #endif |
|---|
| 3349 | { |
|---|
| 3350 | Int layerSetIdxForOutputLayerSet = rpcSlice->getVPS()->getOutputLayerSetIdx( ii ); |
|---|
| 3351 | Int chkAssert=0; |
|---|
| 3352 | for(Int kk = 0; kk < rpcSlice->getVPS()->getNumLayersInIdList(layerSetIdxForOutputLayerSet); kk++) |
|---|
| 3353 | { |
|---|
| 3354 | if(rpcSlice->getLayerId()==rpcSlice->getVPS()->getLayerSetLayerIdList(layerSetIdxForOutputLayerSet, kk)) |
|---|
| 3355 | { |
|---|
| 3356 | chkAssert=1; |
|---|
| 3357 | } |
|---|
| 3358 | } |
|---|
| 3359 | if(chkAssert) |
|---|
| 3360 | { |
|---|
| 3361 | // There may be something wrong here (layer id assumed to be layer idx?) |
|---|
| 3362 | assert(rps->getNumberOfNegativePictures() <= rpcSlice->getVPS()->getMaxVpsDecPicBufferingMinus1(ii , rpcSlice->getLayerId() , rpcSlice->getVPS()->getMaxSLayersInLayerSetMinus1(ii))); |
|---|
| 3363 | assert(rps->getNumberOfPositivePictures() <= rpcSlice->getVPS()->getMaxVpsDecPicBufferingMinus1(ii , rpcSlice->getLayerId() , rpcSlice->getVPS()->getMaxSLayersInLayerSetMinus1(ii)) - rps->getNumberOfNegativePictures()); |
|---|
| 3364 | assert((rps->getNumberOfPositivePictures() + rps->getNumberOfNegativePictures() + rps->getNumberOfLongtermPictures()) <= rpcSlice->getVPS()->getMaxVpsDecPicBufferingMinus1(ii , rpcSlice->getLayerId() , rpcSlice->getVPS()->getMaxSLayersInLayerSetMinus1(ii))); |
|---|
| 3365 | } |
|---|
| 3366 | } |
|---|
| 3367 | |
|---|
| 3368 | |
|---|
| 3369 | } |
|---|
| 3370 | if(rpcSlice->getLayerId() == 0) |
|---|
| 3371 | { |
|---|
| 3372 | assert(rps->getNumberOfNegativePictures() <= rpcSlice->getSPS()->getMaxDecPicBuffering(rpcSlice->getSPS()->getMaxTLayers()-1) ); |
|---|
| 3373 | assert(rps->getNumberOfPositivePictures() <= rpcSlice->getSPS()->getMaxDecPicBuffering(rpcSlice->getSPS()->getMaxTLayers()-1) -rps->getNumberOfNegativePictures()); |
|---|
| 3374 | assert((rps->getNumberOfPositivePictures() + rps->getNumberOfNegativePictures() + rps->getNumberOfLongtermPictures()) <= rpcSlice->getSPS()->getMaxDecPicBuffering(rpcSlice->getSPS()->getMaxTLayers()-1)); |
|---|
| 3375 | } |
|---|
| 3376 | #endif |
|---|
| 3377 | if ( rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP |
|---|
| 3378 | || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL |
|---|
| 3379 | || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP ) |
|---|
| 3380 | { |
|---|
| 3381 | // In the case of BLA picture types, rps data is read from slice header but ignored |
|---|
| 3382 | rps = rpcSlice->getLocalRPS(); |
|---|
| 3383 | rps->setNumberOfNegativePictures(0); |
|---|
| 3384 | rps->setNumberOfPositivePictures(0); |
|---|
| 3385 | rps->setNumberOfLongtermPictures(0); |
|---|
| 3386 | rps->setNumberOfPictures(0); |
|---|
| 3387 | rpcSlice->setRPS(rps); |
|---|
| 3388 | } |
|---|
| 3389 | if (rpcSlice->getSPS()->getTMVPFlagsPresent()) |
|---|
| 3390 | { |
|---|
| 3391 | #if R0226_SLICE_TMVP |
|---|
| 3392 | READ_FLAG( uiCode, "slice_temporal_mvp_enabled_flag" ); |
|---|
| 3393 | #else |
|---|
| 3394 | READ_FLAG( uiCode, "slice_temporal_mvp_enable_flag" ); |
|---|
| 3395 | #endif |
|---|
| 3396 | rpcSlice->setEnableTMVPFlag( uiCode == 1 ? true : false ); |
|---|
| 3397 | } |
|---|
| 3398 | else |
|---|
| 3399 | { |
|---|
| 3400 | rpcSlice->setEnableTMVPFlag(false); |
|---|
| 3401 | } |
|---|
| 3402 | #if N0065_LAYER_POC_ALIGNMENT && !SHM_FIX7 |
|---|
| 3403 | } |
|---|
| 3404 | #endif |
|---|
| 3405 | } |
|---|
| 3406 | |
|---|
| 3407 | #if SVC_EXTENSION |
|---|
| 3408 | rpcSlice->setActiveNumILRRefIdx(0); |
|---|
| 3409 | if((rpcSlice->getLayerId() > 0) && !(rpcSlice->getVPS()->getIlpSshSignalingEnabledFlag()) && (rpcSlice->getNumILRRefIdx() > 0) ) |
|---|
| 3410 | { |
|---|
| 3411 | READ_FLAG(uiCode,"inter_layer_pred_enabled_flag"); |
|---|
| 3412 | rpcSlice->setInterLayerPredEnabledFlag(uiCode); |
|---|
| 3413 | if( rpcSlice->getInterLayerPredEnabledFlag()) |
|---|
| 3414 | { |
|---|
| 3415 | if(rpcSlice->getNumILRRefIdx() > 1) |
|---|
| 3416 | { |
|---|
| 3417 | Int numBits = 1; |
|---|
| 3418 | while ((1 << numBits) < rpcSlice->getNumILRRefIdx()) |
|---|
| 3419 | { |
|---|
| 3420 | numBits++; |
|---|
| 3421 | } |
|---|
| 3422 | if( !rpcSlice->getVPS()->getMaxOneActiveRefLayerFlag()) |
|---|
| 3423 | { |
|---|
| 3424 | READ_CODE( numBits, uiCode,"num_inter_layer_ref_pics_minus1" ); |
|---|
| 3425 | rpcSlice->setActiveNumILRRefIdx(uiCode + 1); |
|---|
| 3426 | } |
|---|
| 3427 | else |
|---|
| 3428 | { |
|---|
| 3429 | #if P0079_DERIVE_NUMACTIVE_REF_PICS |
|---|
| 3430 | for( Int i = 0; i < rpcSlice->getNumILRRefIdx(); i++ ) |
|---|
| 3431 | { |
|---|
| 3432 | #if Q0060_MAX_TID_REF_EQUAL_TO_ZERO |
|---|
| 3433 | if((rpcSlice->getVPS()->getMaxTidIlRefPicsPlus1(rpcSlice->getVPS()->getLayerIdInVps(i),rpcSlice->getLayerId()) > rpcSlice->getTLayer() || rpcSlice->getTLayer()==0) && |
|---|
| 3434 | (rpcSlice->getVPS()->getMaxTSLayersMinus1(rpcSlice->getVPS()->getLayerIdInVps(i)) >= rpcSlice->getTLayer()) ) |
|---|
| 3435 | #else |
|---|
| 3436 | if(rpcSlice->getVPS()->getMaxTidIlRefPicsPlus1(rpcSlice->getVPS()->getLayerIdInVps(i),rpcSlice->getLayerId()) > rpcSlice->getTLayer() && |
|---|
| 3437 | (rpcSlice->getVPS()->getMaxTSLayersMinus1(rpcSlice->getVPS()->getLayerIdInVps(i)) >= rpcSlice->getTLayer()) ) |
|---|
| 3438 | #endif |
|---|
| 3439 | { |
|---|
| 3440 | rpcSlice->setActiveNumILRRefIdx(1); |
|---|
| 3441 | break; |
|---|
| 3442 | } |
|---|
| 3443 | } |
|---|
| 3444 | #else |
|---|
| 3445 | rpcSlice->setActiveNumILRRefIdx(1); |
|---|
| 3446 | #endif |
|---|
| 3447 | } |
|---|
| 3448 | |
|---|
| 3449 | if( rpcSlice->getActiveNumILRRefIdx() == rpcSlice->getNumILRRefIdx() ) |
|---|
| 3450 | { |
|---|
| 3451 | for( Int i = 0; i < rpcSlice->getActiveNumILRRefIdx(); i++ ) |
|---|
| 3452 | { |
|---|
| 3453 | rpcSlice->setInterLayerPredLayerIdc(i,i); |
|---|
| 3454 | } |
|---|
| 3455 | } |
|---|
| 3456 | else |
|---|
| 3457 | { |
|---|
| 3458 | for(Int i = 0; i < rpcSlice->getActiveNumILRRefIdx(); i++ ) |
|---|
| 3459 | { |
|---|
| 3460 | READ_CODE( numBits,uiCode,"inter_layer_pred_layer_idc[i]" ); |
|---|
| 3461 | rpcSlice->setInterLayerPredLayerIdc(uiCode,i); |
|---|
| 3462 | } |
|---|
| 3463 | } |
|---|
| 3464 | } |
|---|
| 3465 | else |
|---|
| 3466 | { |
|---|
| 3467 | #if O0225_TID_BASED_IL_RPS_DERIV && TSLAYERS_IL_RPS |
|---|
| 3468 | #if Q0060_MAX_TID_REF_EQUAL_TO_ZERO |
|---|
| 3469 | if((rpcSlice->getVPS()->getMaxTidIlRefPicsPlus1(0,rpcSlice->getLayerId()) > rpcSlice->getTLayer() || rpcSlice->getTLayer()==0) && |
|---|
| 3470 | (rpcSlice->getVPS()->getMaxTSLayersMinus1(0) >= rpcSlice->getTLayer()) ) |
|---|
| 3471 | #else |
|---|
| 3472 | if( (rpcSlice->getVPS()->getMaxTidIlRefPicsPlus1(0,rpcSlice->getLayerId()) > rpcSlice->getTLayer()) && |
|---|
| 3473 | (rpcSlice->getVPS()->getMaxTSLayersMinus1(0) >= rpcSlice->getTLayer()) ) |
|---|
| 3474 | #endif |
|---|
| 3475 | { |
|---|
| 3476 | #endif |
|---|
| 3477 | rpcSlice->setActiveNumILRRefIdx(1); |
|---|
| 3478 | rpcSlice->setInterLayerPredLayerIdc(0,0); |
|---|
| 3479 | #if O0225_TID_BASED_IL_RPS_DERIV && TSLAYERS_IL_RPS |
|---|
| 3480 | } |
|---|
| 3481 | #endif |
|---|
| 3482 | } |
|---|
| 3483 | } |
|---|
| 3484 | } |
|---|
| 3485 | else if( rpcSlice->getVPS()->getIlpSshSignalingEnabledFlag() == true && (rpcSlice->getLayerId() > 0 )) |
|---|
| 3486 | { |
|---|
| 3487 | rpcSlice->setInterLayerPredEnabledFlag(true); |
|---|
| 3488 | |
|---|
| 3489 | #if O0225_TID_BASED_IL_RPS_DERIV && TSLAYERS_IL_RPS |
|---|
| 3490 | Int numRefLayerPics = 0; |
|---|
| 3491 | Int i = 0; |
|---|
| 3492 | Int refLayerPicIdc [MAX_VPS_LAYER_ID_PLUS1]; |
|---|
| 3493 | for(i = 0, numRefLayerPics = 0; i < rpcSlice->getNumILRRefIdx(); i++ ) |
|---|
| 3494 | { |
|---|
| 3495 | #if Q0060_MAX_TID_REF_EQUAL_TO_ZERO |
|---|
| 3496 | if((rpcSlice->getVPS()->getMaxTidIlRefPicsPlus1(rpcSlice->getVPS()->getLayerIdInVps(i),rpcSlice->getLayerId()) > rpcSlice->getTLayer() || rpcSlice->getTLayer()==0) && |
|---|
| 3497 | (rpcSlice->getVPS()->getMaxTSLayersMinus1(rpcSlice->getVPS()->getLayerIdInVps(i)) >= rpcSlice->getTLayer()) ) |
|---|
| 3498 | #else |
|---|
| 3499 | if(rpcSlice->getVPS()->getMaxTidIlRefPicsPlus1(rpcSlice->getVPS()->getLayerIdInVps(i),rpcSlice->getLayerId()) > rpcSlice->getTLayer() && |
|---|
| 3500 | (rpcSlice->getVPS()->getMaxTSLayersMinus1(rpcSlice->getVPS()->getLayerIdInVps(i)) >= rpcSlice->getTLayer()) ) |
|---|
| 3501 | #endif |
|---|
| 3502 | { |
|---|
| 3503 | refLayerPicIdc[ numRefLayerPics++ ] = i; |
|---|
| 3504 | } |
|---|
| 3505 | } |
|---|
| 3506 | rpcSlice->setActiveNumILRRefIdx(numRefLayerPics); |
|---|
| 3507 | for( i = 0; i < rpcSlice->getActiveNumILRRefIdx(); i++ ) |
|---|
| 3508 | { |
|---|
| 3509 | rpcSlice->setInterLayerPredLayerIdc(refLayerPicIdc[i],i); |
|---|
| 3510 | } |
|---|
| 3511 | #else |
|---|
| 3512 | rpcSlice->setActiveNumILRRefIdx(rpcSlice->getNumILRRefIdx()); |
|---|
| 3513 | for( Int i = 0; i < rpcSlice->getActiveNumILRRefIdx(); i++ ) |
|---|
| 3514 | { |
|---|
| 3515 | rpcSlice->setInterLayerPredLayerIdc(i,i); |
|---|
| 3516 | } |
|---|
| 3517 | #endif |
|---|
| 3518 | } |
|---|
| 3519 | #if P0312_VERT_PHASE_ADJ |
|---|
| 3520 | for(Int i = 0; i < rpcSlice->getActiveNumILRRefIdx(); i++ ) |
|---|
| 3521 | { |
|---|
| 3522 | UInt refLayerIdc = rpcSlice->getInterLayerPredLayerIdc(i); |
|---|
| 3523 | #if !MOVE_SCALED_OFFSET_TO_PPS |
|---|
| 3524 | if( rpcSlice->getSPS()->getVertPhasePositionEnableFlag(refLayerIdc) ) |
|---|
| 3525 | #else |
|---|
| 3526 | if( rpcSlice->getPPS()->getVertPhasePositionEnableFlag(refLayerIdc) ) |
|---|
| 3527 | #endif |
|---|
| 3528 | { |
|---|
| 3529 | READ_FLAG( uiCode, "vert_phase_position_flag" ); rpcSlice->setVertPhasePositionFlag( uiCode? true : false, refLayerIdc ); |
|---|
| 3530 | } |
|---|
| 3531 | } |
|---|
| 3532 | #endif |
|---|
| 3533 | #endif //SVC_EXTENSION |
|---|
| 3534 | |
|---|
| 3535 | if(sps->getUseSAO()) |
|---|
| 3536 | { |
|---|
| 3537 | READ_FLAG(uiCode, "slice_sao_luma_flag"); rpcSlice->setSaoEnabledFlag((Bool)uiCode); |
|---|
| 3538 | #if AUXILIARY_PICTURES |
|---|
| 3539 | ChromaFormat format; |
|---|
| 3540 | #if REPN_FORMAT_IN_VPS |
|---|
| 3541 | #if O0096_REP_FORMAT_INDEX |
|---|
| 3542 | if( sps->getLayerId() == 0 ) |
|---|
| 3543 | { |
|---|
| 3544 | format = sps->getChromaFormatIdc(); |
|---|
| 3545 | } |
|---|
| 3546 | else |
|---|
| 3547 | { |
|---|
| 3548 | format = rpcSlice->getVPS()->getVpsRepFormat( sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : rpcSlice->getVPS()->getVpsRepFormatIdx(sps->getLayerId()) )->getChromaFormatVpsIdc(); |
|---|
| 3549 | #if Q0195_REP_FORMAT_CLEANUP |
|---|
| 3550 | assert( (sps->getUpdateRepFormatFlag()==false && rpcSlice->getVPS()->getVpsNumRepFormats()==1) || rpcSlice->getVPS()->getVpsNumRepFormats() > 1 ); //conformance check |
|---|
| 3551 | #endif |
|---|
| 3552 | } |
|---|
| 3553 | #else |
|---|
| 3554 | if( ( sps->getLayerId() == 0 ) || sps->getUpdateRepFormatFlag() ) |
|---|
| 3555 | { |
|---|
| 3556 | format = sps->getChromaFormatIdc(); |
|---|
| 3557 | } |
|---|
| 3558 | else |
|---|
| 3559 | { |
|---|
| 3560 | format = rpcSlice->getVPS()->getVpsRepFormat( rpcSlice->getVPS()->getVpsRepFormatIdx(sps->getLayerId()) )->getChromaFormatVpsIdc(); |
|---|
| 3561 | } |
|---|
| 3562 | #endif |
|---|
| 3563 | #else |
|---|
| 3564 | format = sps->getChromaFormatIdc(); |
|---|
| 3565 | #endif |
|---|
| 3566 | if (format != CHROMA_400) |
|---|
| 3567 | { |
|---|
| 3568 | #endif |
|---|
| 3569 | READ_FLAG(uiCode, "slice_sao_chroma_flag"); rpcSlice->setSaoEnabledFlagChroma((Bool)uiCode); |
|---|
| 3570 | #if AUXILIARY_PICTURES |
|---|
| 3571 | } |
|---|
| 3572 | else |
|---|
| 3573 | { |
|---|
| 3574 | rpcSlice->setSaoEnabledFlagChroma(false); |
|---|
| 3575 | } |
|---|
| 3576 | #endif |
|---|
| 3577 | } |
|---|
| 3578 | |
|---|
| 3579 | if (rpcSlice->getIdrPicFlag()) |
|---|
| 3580 | { |
|---|
| 3581 | rpcSlice->setEnableTMVPFlag(false); |
|---|
| 3582 | } |
|---|
| 3583 | if (!rpcSlice->isIntra()) |
|---|
| 3584 | { |
|---|
| 3585 | |
|---|
| 3586 | READ_FLAG( uiCode, "num_ref_idx_active_override_flag"); |
|---|
| 3587 | if (uiCode) |
|---|
| 3588 | { |
|---|
| 3589 | READ_UVLC (uiCode, "num_ref_idx_l0_active_minus1" ); rpcSlice->setNumRefIdx( REF_PIC_LIST_0, uiCode + 1 ); |
|---|
| 3590 | if (rpcSlice->isInterB()) |
|---|
| 3591 | { |
|---|
| 3592 | READ_UVLC (uiCode, "num_ref_idx_l1_active_minus1" ); rpcSlice->setNumRefIdx( REF_PIC_LIST_1, uiCode + 1 ); |
|---|
| 3593 | } |
|---|
| 3594 | else |
|---|
| 3595 | { |
|---|
| 3596 | rpcSlice->setNumRefIdx(REF_PIC_LIST_1, 0); |
|---|
| 3597 | } |
|---|
| 3598 | } |
|---|
| 3599 | else |
|---|
| 3600 | { |
|---|
| 3601 | rpcSlice->setNumRefIdx(REF_PIC_LIST_0, rpcSlice->getPPS()->getNumRefIdxL0DefaultActive()); |
|---|
| 3602 | if (rpcSlice->isInterB()) |
|---|
| 3603 | { |
|---|
| 3604 | rpcSlice->setNumRefIdx(REF_PIC_LIST_1, rpcSlice->getPPS()->getNumRefIdxL1DefaultActive()); |
|---|
| 3605 | } |
|---|
| 3606 | else |
|---|
| 3607 | { |
|---|
| 3608 | rpcSlice->setNumRefIdx(REF_PIC_LIST_1,0); |
|---|
| 3609 | } |
|---|
| 3610 | } |
|---|
| 3611 | } |
|---|
| 3612 | // } |
|---|
| 3613 | TComRefPicListModification* refPicListModification = rpcSlice->getRefPicListModification(); |
|---|
| 3614 | if(!rpcSlice->isIntra()) |
|---|
| 3615 | { |
|---|
| 3616 | if( !rpcSlice->getPPS()->getListsModificationPresentFlag() || rpcSlice->getNumRpsCurrTempList() <= 1 ) |
|---|
| 3617 | { |
|---|
| 3618 | refPicListModification->setRefPicListModificationFlagL0( 0 ); |
|---|
| 3619 | } |
|---|
| 3620 | else |
|---|
| 3621 | { |
|---|
| 3622 | READ_FLAG( uiCode, "ref_pic_list_modification_flag_l0" ); refPicListModification->setRefPicListModificationFlagL0( uiCode ? 1 : 0 ); |
|---|
| 3623 | } |
|---|
| 3624 | |
|---|
| 3625 | if(refPicListModification->getRefPicListModificationFlagL0()) |
|---|
| 3626 | { |
|---|
| 3627 | uiCode = 0; |
|---|
| 3628 | Int i = 0; |
|---|
| 3629 | Int numRpsCurrTempList0 = rpcSlice->getNumRpsCurrTempList(); |
|---|
| 3630 | if ( numRpsCurrTempList0 > 1 ) |
|---|
| 3631 | { |
|---|
| 3632 | Int length = 1; |
|---|
| 3633 | numRpsCurrTempList0 --; |
|---|
| 3634 | while ( numRpsCurrTempList0 >>= 1) |
|---|
| 3635 | { |
|---|
| 3636 | length ++; |
|---|
| 3637 | } |
|---|
| 3638 | for (i = 0; i < rpcSlice->getNumRefIdx(REF_PIC_LIST_0); i ++) |
|---|
| 3639 | { |
|---|
| 3640 | READ_CODE( length, uiCode, "list_entry_l0" ); |
|---|
| 3641 | refPicListModification->setRefPicSetIdxL0(i, uiCode ); |
|---|
| 3642 | } |
|---|
| 3643 | } |
|---|
| 3644 | else |
|---|
| 3645 | { |
|---|
| 3646 | for (i = 0; i < rpcSlice->getNumRefIdx(REF_PIC_LIST_0); i ++) |
|---|
| 3647 | { |
|---|
| 3648 | refPicListModification->setRefPicSetIdxL0(i, 0 ); |
|---|
| 3649 | } |
|---|
| 3650 | } |
|---|
| 3651 | } |
|---|
| 3652 | } |
|---|
| 3653 | else |
|---|
| 3654 | { |
|---|
| 3655 | refPicListModification->setRefPicListModificationFlagL0(0); |
|---|
| 3656 | } |
|---|
| 3657 | if(rpcSlice->isInterB()) |
|---|
| 3658 | { |
|---|
| 3659 | if( !rpcSlice->getPPS()->getListsModificationPresentFlag() || rpcSlice->getNumRpsCurrTempList() <= 1 ) |
|---|
| 3660 | { |
|---|
| 3661 | refPicListModification->setRefPicListModificationFlagL1( 0 ); |
|---|
| 3662 | } |
|---|
| 3663 | else |
|---|
| 3664 | { |
|---|
| 3665 | READ_FLAG( uiCode, "ref_pic_list_modification_flag_l1" ); refPicListModification->setRefPicListModificationFlagL1( uiCode ? 1 : 0 ); |
|---|
| 3666 | } |
|---|
| 3667 | if(refPicListModification->getRefPicListModificationFlagL1()) |
|---|
| 3668 | { |
|---|
| 3669 | uiCode = 0; |
|---|
| 3670 | Int i = 0; |
|---|
| 3671 | Int numRpsCurrTempList1 = rpcSlice->getNumRpsCurrTempList(); |
|---|
| 3672 | if ( numRpsCurrTempList1 > 1 ) |
|---|
| 3673 | { |
|---|
| 3674 | Int length = 1; |
|---|
| 3675 | numRpsCurrTempList1 --; |
|---|
| 3676 | while ( numRpsCurrTempList1 >>= 1) |
|---|
| 3677 | { |
|---|
| 3678 | length ++; |
|---|
| 3679 | } |
|---|
| 3680 | for (i = 0; i < rpcSlice->getNumRefIdx(REF_PIC_LIST_1); i ++) |
|---|
| 3681 | { |
|---|
| 3682 | READ_CODE( length, uiCode, "list_entry_l1" ); |
|---|
| 3683 | refPicListModification->setRefPicSetIdxL1(i, uiCode ); |
|---|
| 3684 | } |
|---|
| 3685 | } |
|---|
| 3686 | else |
|---|
| 3687 | { |
|---|
| 3688 | for (i = 0; i < rpcSlice->getNumRefIdx(REF_PIC_LIST_1); i ++) |
|---|
| 3689 | { |
|---|
| 3690 | refPicListModification->setRefPicSetIdxL1(i, 0 ); |
|---|
| 3691 | } |
|---|
| 3692 | } |
|---|
| 3693 | } |
|---|
| 3694 | } |
|---|
| 3695 | else |
|---|
| 3696 | { |
|---|
| 3697 | refPicListModification->setRefPicListModificationFlagL1(0); |
|---|
| 3698 | } |
|---|
| 3699 | if (rpcSlice->isInterB()) |
|---|
| 3700 | { |
|---|
| 3701 | READ_FLAG( uiCode, "mvd_l1_zero_flag" ); rpcSlice->setMvdL1ZeroFlag( (uiCode ? true : false) ); |
|---|
| 3702 | } |
|---|
| 3703 | |
|---|
| 3704 | rpcSlice->setCabacInitFlag( false ); // default |
|---|
| 3705 | if(pps->getCabacInitPresentFlag() && !rpcSlice->isIntra()) |
|---|
| 3706 | { |
|---|
| 3707 | READ_FLAG(uiCode, "cabac_init_flag"); |
|---|
| 3708 | rpcSlice->setCabacInitFlag( uiCode ? true : false ); |
|---|
| 3709 | } |
|---|
| 3710 | |
|---|
| 3711 | if ( rpcSlice->getEnableTMVPFlag() ) |
|---|
| 3712 | { |
|---|
| 3713 | #if SVC_EXTENSION && REF_IDX_MFM |
|---|
| 3714 | // set motion mapping flag |
|---|
| 3715 | rpcSlice->setMFMEnabledFlag( ( rpcSlice->getNumMotionPredRefLayers() > 0 && rpcSlice->getActiveNumILRRefIdx() && !rpcSlice->isIntra() ) ? true : false ); |
|---|
| 3716 | #endif |
|---|
| 3717 | if ( rpcSlice->getSliceType() == B_SLICE ) |
|---|
| 3718 | { |
|---|
| 3719 | READ_FLAG( uiCode, "collocated_from_l0_flag" ); |
|---|
| 3720 | rpcSlice->setColFromL0Flag(uiCode); |
|---|
| 3721 | } |
|---|
| 3722 | else |
|---|
| 3723 | { |
|---|
| 3724 | rpcSlice->setColFromL0Flag( 1 ); |
|---|
| 3725 | } |
|---|
| 3726 | |
|---|
| 3727 | if ( rpcSlice->getSliceType() != I_SLICE && |
|---|
| 3728 | ((rpcSlice->getColFromL0Flag() == 1 && rpcSlice->getNumRefIdx(REF_PIC_LIST_0) > 1)|| |
|---|
| 3729 | (rpcSlice->getColFromL0Flag() == 0 && rpcSlice->getNumRefIdx(REF_PIC_LIST_1) > 1))) |
|---|
| 3730 | { |
|---|
| 3731 | READ_UVLC( uiCode, "collocated_ref_idx" ); |
|---|
| 3732 | rpcSlice->setColRefIdx(uiCode); |
|---|
| 3733 | } |
|---|
| 3734 | else |
|---|
| 3735 | { |
|---|
| 3736 | rpcSlice->setColRefIdx(0); |
|---|
| 3737 | } |
|---|
| 3738 | } |
|---|
| 3739 | if ( (pps->getUseWP() && rpcSlice->getSliceType()==P_SLICE) || (pps->getWPBiPred() && rpcSlice->getSliceType()==B_SLICE) ) |
|---|
| 3740 | { |
|---|
| 3741 | xParsePredWeightTable(rpcSlice); |
|---|
| 3742 | rpcSlice->initWpScaling(); |
|---|
| 3743 | } |
|---|
| 3744 | if (!rpcSlice->isIntra()) |
|---|
| 3745 | { |
|---|
| 3746 | READ_UVLC( uiCode, "five_minus_max_num_merge_cand"); |
|---|
| 3747 | rpcSlice->setMaxNumMergeCand(MRG_MAX_NUM_CANDS - uiCode); |
|---|
| 3748 | } |
|---|
| 3749 | |
|---|
| 3750 | READ_SVLC( iCode, "slice_qp_delta" ); |
|---|
| 3751 | rpcSlice->setSliceQp (26 + pps->getPicInitQPMinus26() + iCode); |
|---|
| 3752 | |
|---|
| 3753 | #if REPN_FORMAT_IN_VPS |
|---|
| 3754 | #if O0194_DIFFERENT_BITDEPTH_EL_BL |
|---|
| 3755 | g_bitDepthYLayer[rpcSlice->getLayerId()] = rpcSlice->getBitDepthY(); |
|---|
| 3756 | g_bitDepthCLayer[rpcSlice->getLayerId()] = rpcSlice->getBitDepthC(); |
|---|
| 3757 | #endif |
|---|
| 3758 | assert( rpcSlice->getSliceQp() >= -rpcSlice->getQpBDOffsetY() ); |
|---|
| 3759 | #else |
|---|
| 3760 | assert( rpcSlice->getSliceQp() >= -sps->getQpBDOffsetY() ); |
|---|
| 3761 | #endif |
|---|
| 3762 | assert( rpcSlice->getSliceQp() <= 51 ); |
|---|
| 3763 | |
|---|
| 3764 | if (rpcSlice->getPPS()->getSliceChromaQpFlag()) |
|---|
| 3765 | { |
|---|
| 3766 | READ_SVLC( iCode, "slice_qp_delta_cb" ); |
|---|
| 3767 | rpcSlice->setSliceQpDeltaCb( iCode ); |
|---|
| 3768 | assert( rpcSlice->getSliceQpDeltaCb() >= -12 ); |
|---|
| 3769 | assert( rpcSlice->getSliceQpDeltaCb() <= 12 ); |
|---|
| 3770 | assert( (rpcSlice->getPPS()->getChromaCbQpOffset() + rpcSlice->getSliceQpDeltaCb()) >= -12 ); |
|---|
| 3771 | assert( (rpcSlice->getPPS()->getChromaCbQpOffset() + rpcSlice->getSliceQpDeltaCb()) <= 12 ); |
|---|
| 3772 | |
|---|
| 3773 | READ_SVLC( iCode, "slice_qp_delta_cr" ); |
|---|
| 3774 | rpcSlice->setSliceQpDeltaCr( iCode ); |
|---|
| 3775 | assert( rpcSlice->getSliceQpDeltaCr() >= -12 ); |
|---|
| 3776 | assert( rpcSlice->getSliceQpDeltaCr() <= 12 ); |
|---|
| 3777 | assert( (rpcSlice->getPPS()->getChromaCrQpOffset() + rpcSlice->getSliceQpDeltaCr()) >= -12 ); |
|---|
| 3778 | assert( (rpcSlice->getPPS()->getChromaCrQpOffset() + rpcSlice->getSliceQpDeltaCr()) <= 12 ); |
|---|
| 3779 | } |
|---|
| 3780 | |
|---|
| 3781 | if (rpcSlice->getPPS()->getDeblockingFilterControlPresentFlag()) |
|---|
| 3782 | { |
|---|
| 3783 | if(rpcSlice->getPPS()->getDeblockingFilterOverrideEnabledFlag()) |
|---|
| 3784 | { |
|---|
| 3785 | READ_FLAG ( uiCode, "deblocking_filter_override_flag" ); rpcSlice->setDeblockingFilterOverrideFlag(uiCode ? true : false); |
|---|
| 3786 | } |
|---|
| 3787 | else |
|---|
| 3788 | { |
|---|
| 3789 | rpcSlice->setDeblockingFilterOverrideFlag(0); |
|---|
| 3790 | } |
|---|
| 3791 | if(rpcSlice->getDeblockingFilterOverrideFlag()) |
|---|
| 3792 | { |
|---|
| 3793 | READ_FLAG ( uiCode, "slice_disable_deblocking_filter_flag" ); rpcSlice->setDeblockingFilterDisable(uiCode ? 1 : 0); |
|---|
| 3794 | if(!rpcSlice->getDeblockingFilterDisable()) |
|---|
| 3795 | { |
|---|
| 3796 | READ_SVLC( iCode, "slice_beta_offset_div2" ); rpcSlice->setDeblockingFilterBetaOffsetDiv2(iCode); |
|---|
| 3797 | assert(rpcSlice->getDeblockingFilterBetaOffsetDiv2() >= -6 && |
|---|
| 3798 | rpcSlice->getDeblockingFilterBetaOffsetDiv2() <= 6); |
|---|
| 3799 | READ_SVLC( iCode, "slice_tc_offset_div2" ); rpcSlice->setDeblockingFilterTcOffsetDiv2(iCode); |
|---|
| 3800 | assert(rpcSlice->getDeblockingFilterTcOffsetDiv2() >= -6 && |
|---|
| 3801 | rpcSlice->getDeblockingFilterTcOffsetDiv2() <= 6); |
|---|
| 3802 | } |
|---|
| 3803 | } |
|---|
| 3804 | else |
|---|
| 3805 | { |
|---|
| 3806 | rpcSlice->setDeblockingFilterDisable ( rpcSlice->getPPS()->getPicDisableDeblockingFilterFlag() ); |
|---|
| 3807 | rpcSlice->setDeblockingFilterBetaOffsetDiv2( rpcSlice->getPPS()->getDeblockingFilterBetaOffsetDiv2() ); |
|---|
| 3808 | rpcSlice->setDeblockingFilterTcOffsetDiv2 ( rpcSlice->getPPS()->getDeblockingFilterTcOffsetDiv2() ); |
|---|
| 3809 | } |
|---|
| 3810 | } |
|---|
| 3811 | else |
|---|
| 3812 | { |
|---|
| 3813 | rpcSlice->setDeblockingFilterDisable ( false ); |
|---|
| 3814 | rpcSlice->setDeblockingFilterBetaOffsetDiv2( 0 ); |
|---|
| 3815 | rpcSlice->setDeblockingFilterTcOffsetDiv2 ( 0 ); |
|---|
| 3816 | } |
|---|
| 3817 | |
|---|
| 3818 | Bool isSAOEnabled = (!rpcSlice->getSPS()->getUseSAO())?(false):(rpcSlice->getSaoEnabledFlag()||rpcSlice->getSaoEnabledFlagChroma()); |
|---|
| 3819 | Bool isDBFEnabled = (!rpcSlice->getDeblockingFilterDisable()); |
|---|
| 3820 | |
|---|
| 3821 | if(rpcSlice->getPPS()->getLoopFilterAcrossSlicesEnabledFlag() && ( isSAOEnabled || isDBFEnabled )) |
|---|
| 3822 | { |
|---|
| 3823 | READ_FLAG( uiCode, "slice_loop_filter_across_slices_enabled_flag"); |
|---|
| 3824 | } |
|---|
| 3825 | else |
|---|
| 3826 | { |
|---|
| 3827 | uiCode = rpcSlice->getPPS()->getLoopFilterAcrossSlicesEnabledFlag()?1:0; |
|---|
| 3828 | } |
|---|
| 3829 | rpcSlice->setLFCrossSliceBoundaryFlag( (uiCode==1)?true:false); |
|---|
| 3830 | |
|---|
| 3831 | } |
|---|
| 3832 | |
|---|
| 3833 | UInt *entryPointOffset = NULL; |
|---|
| 3834 | UInt numEntryPointOffsets, offsetLenMinus1; |
|---|
| 3835 | if( pps->getTilesEnabledFlag() || pps->getEntropyCodingSyncEnabledFlag() ) |
|---|
| 3836 | { |
|---|
| 3837 | READ_UVLC(numEntryPointOffsets, "num_entry_point_offsets"); rpcSlice->setNumEntryPointOffsets ( numEntryPointOffsets ); |
|---|
| 3838 | if (numEntryPointOffsets>0) |
|---|
| 3839 | { |
|---|
| 3840 | READ_UVLC(offsetLenMinus1, "offset_len_minus1"); |
|---|
| 3841 | } |
|---|
| 3842 | entryPointOffset = new UInt[numEntryPointOffsets]; |
|---|
| 3843 | for (UInt idx=0; idx<numEntryPointOffsets; idx++) |
|---|
| 3844 | { |
|---|
| 3845 | READ_CODE(offsetLenMinus1+1, uiCode, "entry_point_offset_minus1"); |
|---|
| 3846 | entryPointOffset[ idx ] = uiCode + 1; |
|---|
| 3847 | } |
|---|
| 3848 | } |
|---|
| 3849 | else |
|---|
| 3850 | { |
|---|
| 3851 | rpcSlice->setNumEntryPointOffsets ( 0 ); |
|---|
| 3852 | } |
|---|
| 3853 | |
|---|
| 3854 | #if POC_RESET_IDC_SIGNALLING |
|---|
| 3855 | Int sliceHeaderExtensionLength = 0; |
|---|
| 3856 | if(pps->getSliceHeaderExtensionPresentFlag()) |
|---|
| 3857 | { |
|---|
| 3858 | READ_UVLC( uiCode, "slice_header_extension_length"); sliceHeaderExtensionLength = uiCode; |
|---|
| 3859 | } |
|---|
| 3860 | else |
|---|
| 3861 | { |
|---|
| 3862 | sliceHeaderExtensionLength = 0; |
|---|
| 3863 | #if INFERENCE_POC_MSB_VAL_PRESENT |
|---|
| 3864 | rpcSlice->setPocMsbValPresentFlag( false ); |
|---|
| 3865 | #endif |
|---|
| 3866 | } |
|---|
| 3867 | UInt startBits = m_pcBitstream->getNumBitsRead(); // Start counter of # SH Extn bits |
|---|
| 3868 | if( sliceHeaderExtensionLength > 0 ) |
|---|
| 3869 | { |
|---|
| 3870 | if( rpcSlice->getPPS()->getPocResetInfoPresentFlag() ) |
|---|
| 3871 | { |
|---|
| 3872 | READ_CODE( 2, uiCode, "poc_reset_idc"); rpcSlice->setPocResetIdc(uiCode); |
|---|
| 3873 | #if POC_RESET_RESTRICTIONS |
|---|
| 3874 | /* The value of poc_reset_idc shall not be equal to 1 or 2 for a RASL picture, a RADL picture, |
|---|
| 3875 | a sub-layer non-reference picture, or a picture that has TemporalId greater than 0, |
|---|
| 3876 | or a picture that has discardable_flag equal to 1. */ |
|---|
| 3877 | if( rpcSlice->getPocResetIdc() == 1 || rpcSlice->getPocResetIdc() == 2 ) |
|---|
| 3878 | { |
|---|
| 3879 | assert( !rpcSlice->isRASL() ); |
|---|
| 3880 | assert( !rpcSlice->isRADL() ); |
|---|
| 3881 | assert( !rpcSlice->isSLNR() ); |
|---|
| 3882 | assert( rpcSlice->getTLayer() == 0 ); |
|---|
| 3883 | assert( rpcSlice->getDiscardableFlag() == 0 ); |
|---|
| 3884 | } |
|---|
| 3885 | |
|---|
| 3886 | // The value of poc_reset_idc of a CRA or BLA picture shall be less than 3. |
|---|
| 3887 | if( rpcSlice->getPocResetIdc() == 3) |
|---|
| 3888 | { |
|---|
| 3889 | assert( ! ( rpcSlice->isCRA() || rpcSlice->isBLA() ) ); |
|---|
| 3890 | } |
|---|
| 3891 | #endif |
|---|
| 3892 | } |
|---|
| 3893 | else |
|---|
| 3894 | { |
|---|
| 3895 | rpcSlice->setPocResetIdc( 0 ); |
|---|
| 3896 | } |
|---|
| 3897 | #if Q0142_POC_LSB_NOT_PRESENT |
|---|
| 3898 | if ( rpcSlice->getVPS()->getPocLsbNotPresentFlag(rpcSlice->getLayerId()) && iPOClsb > 0 ) |
|---|
| 3899 | { |
|---|
| 3900 | assert( rpcSlice->getPocResetIdc() != 2 ); |
|---|
| 3901 | } |
|---|
| 3902 | #endif |
|---|
| 3903 | if( rpcSlice->getPocResetIdc() > 0 ) |
|---|
| 3904 | { |
|---|
| 3905 | READ_CODE(6, uiCode, "poc_reset_period_id"); rpcSlice->setPocResetPeriodId(uiCode); |
|---|
| 3906 | } |
|---|
| 3907 | else |
|---|
| 3908 | { |
|---|
| 3909 | |
|---|
| 3910 | rpcSlice->setPocResetPeriodId( 0 ); |
|---|
| 3911 | } |
|---|
| 3912 | |
|---|
| 3913 | if (rpcSlice->getPocResetIdc() == 3) |
|---|
| 3914 | { |
|---|
| 3915 | READ_FLAG( uiCode, "full_poc_reset_flag"); rpcSlice->setFullPocResetFlag((uiCode == 1) ? true : false); |
|---|
| 3916 | READ_CODE(rpcSlice->getSPS()->getBitsForPOC(), uiCode,"poc_lsb_val"); rpcSlice->setPocLsbVal(uiCode); |
|---|
| 3917 | #if Q0142_POC_LSB_NOT_PRESENT |
|---|
| 3918 | if ( rpcSlice->getVPS()->getPocLsbNotPresentFlag(rpcSlice->getLayerId()) && rpcSlice->getFullPocResetFlag() ) |
|---|
| 3919 | { |
|---|
| 3920 | assert( rpcSlice->getPocLsbVal() == 0 ); |
|---|
| 3921 | } |
|---|
| 3922 | #endif |
|---|
| 3923 | } |
|---|
| 3924 | |
|---|
| 3925 | // Derive the value of PocMsbValRequiredFlag |
|---|
| 3926 | #if P0297_VPS_POC_LSB_ALIGNED_FLAG |
|---|
| 3927 | rpcSlice->setPocMsbValRequiredFlag( (rpcSlice->getCraPicFlag() || rpcSlice->getBlaPicFlag()) |
|---|
| 3928 | && (!rpcSlice->getVPS()->getVpsPocLsbAlignedFlag() || |
|---|
| 3929 | (rpcSlice->getVPS()->getVpsPocLsbAlignedFlag() && rpcSlice->getVPS()->getNumDirectRefLayers(rpcSlice->getLayerId()) == 0)) |
|---|
| 3930 | ); |
|---|
| 3931 | #else |
|---|
| 3932 | rpcSlice->setPocMsbValRequiredFlag( rpcSlice->getCraPicFlag() || rpcSlice->getBlaPicFlag() ); |
|---|
| 3933 | #endif |
|---|
| 3934 | |
|---|
| 3935 | #if P0297_VPS_POC_LSB_ALIGNED_FLAG |
|---|
| 3936 | if (!rpcSlice->getPocMsbValRequiredFlag() && rpcSlice->getVPS()->getVpsPocLsbAlignedFlag()) |
|---|
| 3937 | #else |
|---|
| 3938 | if (!rpcSlice->getPocMsbValRequiredFlag() /* vps_poc_lsb_aligned_flag */) |
|---|
| 3939 | #endif |
|---|
| 3940 | { |
|---|
| 3941 | #if P0297_VPS_POC_LSB_ALIGNED_FLAG |
|---|
| 3942 | READ_FLAG(uiCode, "poc_msb_cycle_val_present_flag"); rpcSlice->setPocMsbValPresentFlag(uiCode ? true : false); |
|---|
| 3943 | #else |
|---|
| 3944 | READ_FLAG(uiCode, "poc_msb_val_present_flag"); rpcSlice->setPocMsbValPresentFlag(uiCode ? true : false); |
|---|
| 3945 | #endif |
|---|
| 3946 | } |
|---|
| 3947 | else |
|---|
| 3948 | { |
|---|
| 3949 | #if POC_MSB_VAL_PRESENT_FLAG_SEM |
|---|
| 3950 | if( sliceHeaderExtensionLength == 0 ) |
|---|
| 3951 | { |
|---|
| 3952 | rpcSlice->setPocMsbValPresentFlag( false ); |
|---|
| 3953 | } |
|---|
| 3954 | else if( rpcSlice->getPocMsbValRequiredFlag() ) |
|---|
| 3955 | #else |
|---|
| 3956 | if( rpcSlice->getPocMsbValRequiredFlag() ) |
|---|
| 3957 | #endif |
|---|
| 3958 | { |
|---|
| 3959 | rpcSlice->setPocMsbValPresentFlag( true ); |
|---|
| 3960 | } |
|---|
| 3961 | else |
|---|
| 3962 | { |
|---|
| 3963 | rpcSlice->setPocMsbValPresentFlag( false ); |
|---|
| 3964 | } |
|---|
| 3965 | } |
|---|
| 3966 | |
|---|
| 3967 | #if !POC_RESET_IDC_DECODER |
|---|
| 3968 | Int maxPocLsb = 1 << rpcSlice->getSPS()->getBitsForPOC(); |
|---|
| 3969 | #endif |
|---|
| 3970 | if( rpcSlice->getPocMsbValPresentFlag() ) |
|---|
| 3971 | { |
|---|
| 3972 | #if P0297_VPS_POC_LSB_ALIGNED_FLAG |
|---|
| 3973 | READ_UVLC( uiCode, "poc_msb_cycle_val"); rpcSlice->setPocMsbVal( uiCode ); |
|---|
| 3974 | #else |
|---|
| 3975 | READ_UVLC( uiCode, "poc_msb_val"); rpcSlice->setPocMsbVal( uiCode ); |
|---|
| 3976 | #endif |
|---|
| 3977 | |
|---|
| 3978 | #if !POC_RESET_IDC_DECODER |
|---|
| 3979 | // Update POC of the slice based on this MSB val |
|---|
| 3980 | Int pocLsb = rpcSlice->getPOC() % maxPocLsb; |
|---|
| 3981 | rpcSlice->setPOC((rpcSlice->getPocMsbVal() * maxPocLsb) + pocLsb); |
|---|
| 3982 | } |
|---|
| 3983 | else |
|---|
| 3984 | { |
|---|
| 3985 | rpcSlice->setPocMsbVal( rpcSlice->getPOC() / maxPocLsb ); |
|---|
| 3986 | #endif |
|---|
| 3987 | } |
|---|
| 3988 | |
|---|
| 3989 | // Read remaining bits in the slice header extension. |
|---|
| 3990 | UInt endBits = m_pcBitstream->getNumBitsRead(); |
|---|
| 3991 | Int counter = (endBits - startBits) % 8; |
|---|
| 3992 | if( counter ) |
|---|
| 3993 | { |
|---|
| 3994 | counter = 8 - counter; |
|---|
| 3995 | } |
|---|
| 3996 | |
|---|
| 3997 | while( counter ) |
|---|
| 3998 | { |
|---|
| 3999 | #if Q0146_SSH_EXT_DATA_BIT |
|---|
| 4000 | READ_FLAG( uiCode, "slice_segment_header_extension_data_bit" ); |
|---|
| 4001 | #else |
|---|
| 4002 | READ_FLAG( uiCode, "slice_segment_header_extension_reserved_bit" ); assert( uiCode == 1 ); |
|---|
| 4003 | #endif |
|---|
| 4004 | counter--; |
|---|
| 4005 | } |
|---|
| 4006 | } |
|---|
| 4007 | #else |
|---|
| 4008 | if(pps->getSliceHeaderExtensionPresentFlag()) |
|---|
| 4009 | { |
|---|
| 4010 | READ_UVLC(uiCode,"slice_header_extension_length"); |
|---|
| 4011 | for(Int i=0; i<uiCode; i++) |
|---|
| 4012 | { |
|---|
| 4013 | UInt ignore; |
|---|
| 4014 | READ_CODE(8,ignore,"slice_header_extension_data_byte"); |
|---|
| 4015 | } |
|---|
| 4016 | } |
|---|
| 4017 | #endif |
|---|
| 4018 | m_pcBitstream->readByteAlignment(); |
|---|
| 4019 | |
|---|
| 4020 | if( pps->getTilesEnabledFlag() || pps->getEntropyCodingSyncEnabledFlag() ) |
|---|
| 4021 | { |
|---|
| 4022 | Int endOfSliceHeaderLocation = m_pcBitstream->getByteLocation(); |
|---|
| 4023 | |
|---|
| 4024 | // Adjust endOfSliceHeaderLocation to account for emulation prevention bytes in the slice segment header |
|---|
| 4025 | for ( UInt curByteIdx = 0; curByteIdx<m_pcBitstream->numEmulationPreventionBytesRead(); curByteIdx++ ) |
|---|
| 4026 | { |
|---|
| 4027 | if ( m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) < endOfSliceHeaderLocation ) |
|---|
| 4028 | { |
|---|
| 4029 | endOfSliceHeaderLocation++; |
|---|
| 4030 | } |
|---|
| 4031 | } |
|---|
| 4032 | |
|---|
| 4033 | Int curEntryPointOffset = 0; |
|---|
| 4034 | Int prevEntryPointOffset = 0; |
|---|
| 4035 | for (UInt idx=0; idx<numEntryPointOffsets; idx++) |
|---|
| 4036 | { |
|---|
| 4037 | curEntryPointOffset += entryPointOffset[ idx ]; |
|---|
| 4038 | |
|---|
| 4039 | Int emulationPreventionByteCount = 0; |
|---|
| 4040 | for ( UInt curByteIdx = 0; curByteIdx<m_pcBitstream->numEmulationPreventionBytesRead(); curByteIdx++ ) |
|---|
| 4041 | { |
|---|
| 4042 | if ( m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) >= ( prevEntryPointOffset + endOfSliceHeaderLocation ) && |
|---|
| 4043 | m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) < ( curEntryPointOffset + endOfSliceHeaderLocation ) ) |
|---|
| 4044 | { |
|---|
| 4045 | emulationPreventionByteCount++; |
|---|
| 4046 | } |
|---|
| 4047 | } |
|---|
| 4048 | |
|---|
| 4049 | entryPointOffset[ idx ] -= emulationPreventionByteCount; |
|---|
| 4050 | prevEntryPointOffset = curEntryPointOffset; |
|---|
| 4051 | } |
|---|
| 4052 | |
|---|
| 4053 | if ( pps->getTilesEnabledFlag() ) |
|---|
| 4054 | { |
|---|
| 4055 | rpcSlice->setTileLocationCount( numEntryPointOffsets ); |
|---|
| 4056 | |
|---|
| 4057 | UInt prevPos = 0; |
|---|
| 4058 | for (Int idx=0; idx<rpcSlice->getTileLocationCount(); idx++) |
|---|
| 4059 | { |
|---|
| 4060 | rpcSlice->setTileLocation( idx, prevPos + entryPointOffset [ idx ] ); |
|---|
| 4061 | prevPos += entryPointOffset[ idx ]; |
|---|
| 4062 | } |
|---|
| 4063 | } |
|---|
| 4064 | else if ( pps->getEntropyCodingSyncEnabledFlag() ) |
|---|
| 4065 | { |
|---|
| 4066 | Int numSubstreams = rpcSlice->getNumEntryPointOffsets()+1; |
|---|
| 4067 | rpcSlice->allocSubstreamSizes(numSubstreams); |
|---|
| 4068 | UInt *pSubstreamSizes = rpcSlice->getSubstreamSizes(); |
|---|
| 4069 | for (Int idx=0; idx<numSubstreams-1; idx++) |
|---|
| 4070 | { |
|---|
| 4071 | if ( idx < numEntryPointOffsets ) |
|---|
| 4072 | { |
|---|
| 4073 | pSubstreamSizes[ idx ] = ( entryPointOffset[ idx ] << 3 ) ; |
|---|
| 4074 | } |
|---|
| 4075 | else |
|---|
| 4076 | { |
|---|
| 4077 | pSubstreamSizes[ idx ] = 0; |
|---|
| 4078 | } |
|---|
| 4079 | } |
|---|
| 4080 | } |
|---|
| 4081 | |
|---|
| 4082 | if (entryPointOffset) |
|---|
| 4083 | { |
|---|
| 4084 | delete [] entryPointOffset; |
|---|
| 4085 | } |
|---|
| 4086 | } |
|---|
| 4087 | |
|---|
| 4088 | return; |
|---|
| 4089 | } |
|---|
| 4090 | |
|---|
| 4091 | Void TDecCavlc::parsePTL( TComPTL *rpcPTL, Bool profilePresentFlag, Int maxNumSubLayersMinus1 ) |
|---|
| 4092 | { |
|---|
| 4093 | UInt uiCode; |
|---|
| 4094 | if(profilePresentFlag) |
|---|
| 4095 | { |
|---|
| 4096 | parseProfileTier(rpcPTL->getGeneralPTL()); |
|---|
| 4097 | } |
|---|
| 4098 | READ_CODE( 8, uiCode, "general_level_idc" ); rpcPTL->getGeneralPTL()->setLevelIdc(uiCode); |
|---|
| 4099 | |
|---|
| 4100 | for (Int i = 0; i < maxNumSubLayersMinus1; i++) |
|---|
| 4101 | { |
|---|
| 4102 | if(profilePresentFlag) |
|---|
| 4103 | { |
|---|
| 4104 | READ_FLAG( uiCode, "sub_layer_profile_present_flag[i]" ); rpcPTL->setSubLayerProfilePresentFlag(i, uiCode); |
|---|
| 4105 | } |
|---|
| 4106 | READ_FLAG( uiCode, "sub_layer_level_present_flag[i]" ); rpcPTL->setSubLayerLevelPresentFlag (i, uiCode); |
|---|
| 4107 | } |
|---|
| 4108 | |
|---|
| 4109 | if (maxNumSubLayersMinus1 > 0) |
|---|
| 4110 | { |
|---|
| 4111 | for (Int i = maxNumSubLayersMinus1; i < 8; i++) |
|---|
| 4112 | { |
|---|
| 4113 | READ_CODE(2, uiCode, "reserved_zero_2bits"); |
|---|
| 4114 | assert(uiCode == 0); |
|---|
| 4115 | } |
|---|
| 4116 | } |
|---|
| 4117 | |
|---|
| 4118 | for(Int i = 0; i < maxNumSubLayersMinus1; i++) |
|---|
| 4119 | { |
|---|
| 4120 | if( profilePresentFlag && rpcPTL->getSubLayerProfilePresentFlag(i) ) |
|---|
| 4121 | { |
|---|
| 4122 | parseProfileTier(rpcPTL->getSubLayerPTL(i)); |
|---|
| 4123 | } |
|---|
| 4124 | if(rpcPTL->getSubLayerLevelPresentFlag(i)) |
|---|
| 4125 | { |
|---|
| 4126 | READ_CODE( 8, uiCode, "sub_layer_level_idc[i]" ); rpcPTL->getSubLayerPTL(i)->setLevelIdc(uiCode); |
|---|
| 4127 | } |
|---|
| 4128 | } |
|---|
| 4129 | } |
|---|
| 4130 | |
|---|
| 4131 | Void TDecCavlc::parseProfileTier(ProfileTierLevel *ptl) |
|---|
| 4132 | { |
|---|
| 4133 | UInt uiCode; |
|---|
| 4134 | READ_CODE(2 , uiCode, "XXX_profile_space[]"); ptl->setProfileSpace(uiCode); |
|---|
| 4135 | READ_FLAG( uiCode, "XXX_tier_flag[]" ); ptl->setTierFlag (uiCode ? 1 : 0); |
|---|
| 4136 | READ_CODE(5 , uiCode, "XXX_profile_idc[]" ); ptl->setProfileIdc (uiCode); |
|---|
| 4137 | for(Int j = 0; j < 32; j++) |
|---|
| 4138 | { |
|---|
| 4139 | READ_FLAG( uiCode, "XXX_profile_compatibility_flag[][j]"); ptl->setProfileCompatibilityFlag(j, uiCode ? 1 : 0); |
|---|
| 4140 | } |
|---|
| 4141 | READ_FLAG(uiCode, "general_progressive_source_flag"); |
|---|
| 4142 | ptl->setProgressiveSourceFlag(uiCode ? true : false); |
|---|
| 4143 | |
|---|
| 4144 | READ_FLAG(uiCode, "general_interlaced_source_flag"); |
|---|
| 4145 | ptl->setInterlacedSourceFlag(uiCode ? true : false); |
|---|
| 4146 | |
|---|
| 4147 | READ_FLAG(uiCode, "general_non_packed_constraint_flag"); |
|---|
| 4148 | ptl->setNonPackedConstraintFlag(uiCode ? true : false); |
|---|
| 4149 | |
|---|
| 4150 | READ_FLAG(uiCode, "general_frame_only_constraint_flag"); |
|---|
| 4151 | ptl->setFrameOnlyConstraintFlag(uiCode ? true : false); |
|---|
| 4152 | |
|---|
| 4153 | READ_CODE(16, uiCode, "XXX_reserved_zero_44bits[0..15]"); |
|---|
| 4154 | READ_CODE(16, uiCode, "XXX_reserved_zero_44bits[16..31]"); |
|---|
| 4155 | READ_CODE(12, uiCode, "XXX_reserved_zero_44bits[32..43]"); |
|---|
| 4156 | } |
|---|
| 4157 | |
|---|
| 4158 | Void TDecCavlc::parseTerminatingBit( UInt& ruiBit ) |
|---|
| 4159 | { |
|---|
| 4160 | ruiBit = false; |
|---|
| 4161 | Int iBitsLeft = m_pcBitstream->getNumBitsLeft(); |
|---|
| 4162 | if(iBitsLeft <= 8) |
|---|
| 4163 | { |
|---|
| 4164 | UInt uiPeekValue = m_pcBitstream->peekBits(iBitsLeft); |
|---|
| 4165 | if (uiPeekValue == (1<<(iBitsLeft-1))) |
|---|
| 4166 | { |
|---|
| 4167 | ruiBit = true; |
|---|
| 4168 | } |
|---|
| 4169 | } |
|---|
| 4170 | } |
|---|
| 4171 | |
|---|
| 4172 | Void TDecCavlc::parseSkipFlag( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
|---|
| 4173 | { |
|---|
| 4174 | assert(0); |
|---|
| 4175 | } |
|---|
| 4176 | |
|---|
| 4177 | Void TDecCavlc::parseCUTransquantBypassFlag( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
|---|
| 4178 | { |
|---|
| 4179 | assert(0); |
|---|
| 4180 | } |
|---|
| 4181 | |
|---|
| 4182 | Void TDecCavlc::parseMVPIdx( Int& /*riMVPIdx*/ ) |
|---|
| 4183 | { |
|---|
| 4184 | assert(0); |
|---|
| 4185 | } |
|---|
| 4186 | |
|---|
| 4187 | Void TDecCavlc::parseSplitFlag ( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
|---|
| 4188 | { |
|---|
| 4189 | assert(0); |
|---|
| 4190 | } |
|---|
| 4191 | |
|---|
| 4192 | Void TDecCavlc::parsePartSize( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
|---|
| 4193 | { |
|---|
| 4194 | assert(0); |
|---|
| 4195 | } |
|---|
| 4196 | |
|---|
| 4197 | Void TDecCavlc::parsePredMode( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
|---|
| 4198 | { |
|---|
| 4199 | assert(0); |
|---|
| 4200 | } |
|---|
| 4201 | |
|---|
| 4202 | /** Parse I_PCM information. |
|---|
| 4203 | * \param pcCU pointer to CU |
|---|
| 4204 | * \param uiAbsPartIdx CU index |
|---|
| 4205 | * \param uiDepth CU depth |
|---|
| 4206 | * \returns Void |
|---|
| 4207 | * |
|---|
| 4208 | * If I_PCM flag indicates that the CU is I_PCM, parse its PCM alignment bits and codes. |
|---|
| 4209 | */ |
|---|
| 4210 | Void TDecCavlc::parseIPCMInfo( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
|---|
| 4211 | { |
|---|
| 4212 | assert(0); |
|---|
| 4213 | } |
|---|
| 4214 | |
|---|
| 4215 | Void TDecCavlc::parseIntraDirLumaAng ( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
|---|
| 4216 | { |
|---|
| 4217 | assert(0); |
|---|
| 4218 | } |
|---|
| 4219 | |
|---|
| 4220 | Void TDecCavlc::parseIntraDirChroma( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
|---|
| 4221 | { |
|---|
| 4222 | assert(0); |
|---|
| 4223 | } |
|---|
| 4224 | |
|---|
| 4225 | Void TDecCavlc::parseInterDir( TComDataCU* /*pcCU*/, UInt& /*ruiInterDir*/, UInt /*uiAbsPartIdx*/ ) |
|---|
| 4226 | { |
|---|
| 4227 | assert(0); |
|---|
| 4228 | } |
|---|
| 4229 | |
|---|
| 4230 | Void TDecCavlc::parseRefFrmIdx( TComDataCU* /*pcCU*/, Int& /*riRefFrmIdx*/, RefPicList /*eRefList*/ ) |
|---|
| 4231 | { |
|---|
| 4232 | assert(0); |
|---|
| 4233 | } |
|---|
| 4234 | |
|---|
| 4235 | Void TDecCavlc::parseMvd( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiPartIdx*/, UInt /*uiDepth*/, RefPicList /*eRefList*/ ) |
|---|
| 4236 | { |
|---|
| 4237 | assert(0); |
|---|
| 4238 | } |
|---|
| 4239 | |
|---|
| 4240 | Void TDecCavlc::parseDeltaQP( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
|---|
| 4241 | { |
|---|
| 4242 | Int qp; |
|---|
| 4243 | Int iDQp; |
|---|
| 4244 | |
|---|
| 4245 | xReadSvlc( iDQp ); |
|---|
| 4246 | |
|---|
| 4247 | #if REPN_FORMAT_IN_VPS |
|---|
| 4248 | Int qpBdOffsetY = pcCU->getSlice()->getQpBDOffsetY(); |
|---|
| 4249 | #else |
|---|
| 4250 | Int qpBdOffsetY = pcCU->getSlice()->getSPS()->getQpBDOffsetY(); |
|---|
| 4251 | #endif |
|---|
| 4252 | qp = (((Int) pcCU->getRefQP( uiAbsPartIdx ) + iDQp + 52 + 2*qpBdOffsetY )%(52+ qpBdOffsetY)) - qpBdOffsetY; |
|---|
| 4253 | |
|---|
| 4254 | UInt uiAbsQpCUPartIdx = (uiAbsPartIdx>>((g_uiMaxCUDepth - pcCU->getSlice()->getPPS()->getMaxCuDQPDepth())<<1))<<((g_uiMaxCUDepth - pcCU->getSlice()->getPPS()->getMaxCuDQPDepth())<<1) ; |
|---|
| 4255 | UInt uiQpCUDepth = min(uiDepth,pcCU->getSlice()->getPPS()->getMaxCuDQPDepth()) ; |
|---|
| 4256 | |
|---|
| 4257 | pcCU->setQPSubParts( qp, uiAbsQpCUPartIdx, uiQpCUDepth ); |
|---|
| 4258 | } |
|---|
| 4259 | |
|---|
| 4260 | Void TDecCavlc::parseCoeffNxN( TComDataCU* /*pcCU*/, TCoeff* /*pcCoef*/, UInt /*uiAbsPartIdx*/, UInt /*uiWidth*/, UInt /*uiHeight*/, UInt /*uiDepth*/, TextType /*eTType*/ ) |
|---|
| 4261 | { |
|---|
| 4262 | assert(0); |
|---|
| 4263 | } |
|---|
| 4264 | |
|---|
| 4265 | Void TDecCavlc::parseTransformSubdivFlag( UInt& /*ruiSubdivFlag*/, UInt /*uiLog2TransformBlockSize*/ ) |
|---|
| 4266 | { |
|---|
| 4267 | assert(0); |
|---|
| 4268 | } |
|---|
| 4269 | |
|---|
| 4270 | Void TDecCavlc::parseQtCbf( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, TextType /*eType*/, UInt /*uiTrDepth*/, UInt /*uiDepth*/ ) |
|---|
| 4271 | { |
|---|
| 4272 | assert(0); |
|---|
| 4273 | } |
|---|
| 4274 | |
|---|
| 4275 | Void TDecCavlc::parseQtRootCbf( UInt /*uiAbsPartIdx*/, UInt& /*uiQtRootCbf*/ ) |
|---|
| 4276 | { |
|---|
| 4277 | assert(0); |
|---|
| 4278 | } |
|---|
| 4279 | |
|---|
| 4280 | Void TDecCavlc::parseTransformSkipFlags (TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*width*/, UInt /*height*/, UInt /*uiDepth*/, TextType /*eTType*/) |
|---|
| 4281 | { |
|---|
| 4282 | assert(0); |
|---|
| 4283 | } |
|---|
| 4284 | |
|---|
| 4285 | Void TDecCavlc::parseMergeFlag ( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/, UInt /*uiPUIdx*/ ) |
|---|
| 4286 | { |
|---|
| 4287 | assert(0); |
|---|
| 4288 | } |
|---|
| 4289 | |
|---|
| 4290 | Void TDecCavlc::parseMergeIndex ( TComDataCU* /*pcCU*/, UInt& /*ruiMergeIndex*/ ) |
|---|
| 4291 | { |
|---|
| 4292 | assert(0); |
|---|
| 4293 | } |
|---|
| 4294 | |
|---|
| 4295 | // ==================================================================================================================== |
|---|
| 4296 | // Protected member functions |
|---|
| 4297 | // ==================================================================================================================== |
|---|
| 4298 | |
|---|
| 4299 | /** parse explicit wp tables |
|---|
| 4300 | * \param TComSlice* pcSlice |
|---|
| 4301 | * \returns Void |
|---|
| 4302 | */ |
|---|
| 4303 | Void TDecCavlc::xParsePredWeightTable( TComSlice* pcSlice ) |
|---|
| 4304 | { |
|---|
| 4305 | wpScalingParam *wp; |
|---|
| 4306 | Bool bChroma = true; // color always present in HEVC ? |
|---|
| 4307 | SliceType eSliceType = pcSlice->getSliceType(); |
|---|
| 4308 | Int iNbRef = (eSliceType == B_SLICE ) ? (2) : (1); |
|---|
| 4309 | #if SVC_EXTENSION |
|---|
| 4310 | UInt uiLog2WeightDenomLuma = 0, uiLog2WeightDenomChroma = 0; |
|---|
| 4311 | #else |
|---|
| 4312 | UInt uiLog2WeightDenomLuma, uiLog2WeightDenomChroma; |
|---|
| 4313 | #endif |
|---|
| 4314 | UInt uiTotalSignalledWeightFlags = 0; |
|---|
| 4315 | |
|---|
| 4316 | Int iDeltaDenom; |
|---|
| 4317 | #if AUXILIARY_PICTURES |
|---|
| 4318 | if (pcSlice->getChromaFormatIdc() == CHROMA_400) |
|---|
| 4319 | { |
|---|
| 4320 | bChroma = false; |
|---|
| 4321 | } |
|---|
| 4322 | #endif |
|---|
| 4323 | // decode delta_luma_log2_weight_denom : |
|---|
| 4324 | READ_UVLC( uiLog2WeightDenomLuma, "luma_log2_weight_denom" ); // ue(v): luma_log2_weight_denom |
|---|
| 4325 | assert( uiLog2WeightDenomLuma <= 7 ); |
|---|
| 4326 | if( bChroma ) |
|---|
| 4327 | { |
|---|
| 4328 | READ_SVLC( iDeltaDenom, "delta_chroma_log2_weight_denom" ); // se(v): delta_chroma_log2_weight_denom |
|---|
| 4329 | assert((iDeltaDenom + (Int)uiLog2WeightDenomLuma)>=0); |
|---|
| 4330 | assert((iDeltaDenom + (Int)uiLog2WeightDenomLuma)<=7); |
|---|
| 4331 | uiLog2WeightDenomChroma = (UInt)(iDeltaDenom + uiLog2WeightDenomLuma); |
|---|
| 4332 | } |
|---|
| 4333 | |
|---|
| 4334 | for ( Int iNumRef=0 ; iNumRef<iNbRef ; iNumRef++ ) |
|---|
| 4335 | { |
|---|
| 4336 | RefPicList eRefPicList = ( iNumRef ? REF_PIC_LIST_1 : REF_PIC_LIST_0 ); |
|---|
| 4337 | for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ ) |
|---|
| 4338 | { |
|---|
| 4339 | pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); |
|---|
| 4340 | |
|---|
| 4341 | wp[0].uiLog2WeightDenom = uiLog2WeightDenomLuma; |
|---|
| 4342 | #if AUXILIARY_PICTURES |
|---|
| 4343 | if (!bChroma) |
|---|
| 4344 | { |
|---|
| 4345 | wp[1].uiLog2WeightDenom = 0; |
|---|
| 4346 | wp[2].uiLog2WeightDenom = 0; |
|---|
| 4347 | } |
|---|
| 4348 | else |
|---|
| 4349 | { |
|---|
| 4350 | #endif |
|---|
| 4351 | wp[1].uiLog2WeightDenom = uiLog2WeightDenomChroma; |
|---|
| 4352 | wp[2].uiLog2WeightDenom = uiLog2WeightDenomChroma; |
|---|
| 4353 | #if AUXILIARY_PICTURES |
|---|
| 4354 | } |
|---|
| 4355 | #endif |
|---|
| 4356 | |
|---|
| 4357 | UInt uiCode; |
|---|
| 4358 | READ_FLAG( uiCode, "luma_weight_lX_flag" ); // u(1): luma_weight_l0_flag |
|---|
| 4359 | wp[0].bPresentFlag = ( uiCode == 1 ); |
|---|
| 4360 | uiTotalSignalledWeightFlags += wp[0].bPresentFlag; |
|---|
| 4361 | } |
|---|
| 4362 | if ( bChroma ) |
|---|
| 4363 | { |
|---|
| 4364 | UInt uiCode; |
|---|
| 4365 | for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ ) |
|---|
| 4366 | { |
|---|
| 4367 | pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); |
|---|
| 4368 | READ_FLAG( uiCode, "chroma_weight_lX_flag" ); // u(1): chroma_weight_l0_flag |
|---|
| 4369 | wp[1].bPresentFlag = ( uiCode == 1 ); |
|---|
| 4370 | wp[2].bPresentFlag = ( uiCode == 1 ); |
|---|
| 4371 | uiTotalSignalledWeightFlags += 2*wp[1].bPresentFlag; |
|---|
| 4372 | } |
|---|
| 4373 | } |
|---|
| 4374 | for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ ) |
|---|
| 4375 | { |
|---|
| 4376 | pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); |
|---|
| 4377 | if ( wp[0].bPresentFlag ) |
|---|
| 4378 | { |
|---|
| 4379 | Int iDeltaWeight; |
|---|
| 4380 | READ_SVLC( iDeltaWeight, "delta_luma_weight_lX" ); // se(v): delta_luma_weight_l0[i] |
|---|
| 4381 | assert( iDeltaWeight >= -128 ); |
|---|
| 4382 | assert( iDeltaWeight <= 127 ); |
|---|
| 4383 | wp[0].iWeight = (iDeltaWeight + (1<<wp[0].uiLog2WeightDenom)); |
|---|
| 4384 | READ_SVLC( wp[0].iOffset, "luma_offset_lX" ); // se(v): luma_offset_l0[i] |
|---|
| 4385 | assert( wp[0].iOffset >= -128 ); |
|---|
| 4386 | assert( wp[0].iOffset <= 127 ); |
|---|
| 4387 | } |
|---|
| 4388 | else |
|---|
| 4389 | { |
|---|
| 4390 | wp[0].iWeight = (1 << wp[0].uiLog2WeightDenom); |
|---|
| 4391 | wp[0].iOffset = 0; |
|---|
| 4392 | } |
|---|
| 4393 | if ( bChroma ) |
|---|
| 4394 | { |
|---|
| 4395 | if ( wp[1].bPresentFlag ) |
|---|
| 4396 | { |
|---|
| 4397 | for ( Int j=1 ; j<3 ; j++ ) |
|---|
| 4398 | { |
|---|
| 4399 | Int iDeltaWeight; |
|---|
| 4400 | READ_SVLC( iDeltaWeight, "delta_chroma_weight_lX" ); // se(v): chroma_weight_l0[i][j] |
|---|
| 4401 | assert( iDeltaWeight >= -128 ); |
|---|
| 4402 | assert( iDeltaWeight <= 127 ); |
|---|
| 4403 | wp[j].iWeight = (iDeltaWeight + (1<<wp[1].uiLog2WeightDenom)); |
|---|
| 4404 | |
|---|
| 4405 | Int iDeltaChroma; |
|---|
| 4406 | READ_SVLC( iDeltaChroma, "delta_chroma_offset_lX" ); // se(v): delta_chroma_offset_l0[i][j] |
|---|
| 4407 | assert( iDeltaChroma >= -512 ); |
|---|
| 4408 | assert( iDeltaChroma <= 511 ); |
|---|
| 4409 | Int pred = ( 128 - ( ( 128*wp[j].iWeight)>>(wp[j].uiLog2WeightDenom) ) ); |
|---|
| 4410 | wp[j].iOffset = Clip3(-128, 127, (iDeltaChroma + pred) ); |
|---|
| 4411 | } |
|---|
| 4412 | } |
|---|
| 4413 | else |
|---|
| 4414 | { |
|---|
| 4415 | for ( Int j=1 ; j<3 ; j++ ) |
|---|
| 4416 | { |
|---|
| 4417 | wp[j].iWeight = (1 << wp[j].uiLog2WeightDenom); |
|---|
| 4418 | wp[j].iOffset = 0; |
|---|
| 4419 | } |
|---|
| 4420 | } |
|---|
| 4421 | } |
|---|
| 4422 | } |
|---|
| 4423 | |
|---|
| 4424 | for ( Int iRefIdx=pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx<MAX_NUM_REF ; iRefIdx++ ) |
|---|
| 4425 | { |
|---|
| 4426 | pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); |
|---|
| 4427 | |
|---|
| 4428 | wp[0].bPresentFlag = false; |
|---|
| 4429 | wp[1].bPresentFlag = false; |
|---|
| 4430 | wp[2].bPresentFlag = false; |
|---|
| 4431 | } |
|---|
| 4432 | } |
|---|
| 4433 | assert(uiTotalSignalledWeightFlags<=24); |
|---|
| 4434 | } |
|---|
| 4435 | |
|---|
| 4436 | /** decode quantization matrix |
|---|
| 4437 | * \param scalingList quantization matrix information |
|---|
| 4438 | */ |
|---|
| 4439 | Void TDecCavlc::parseScalingList(TComScalingList* scalingList) |
|---|
| 4440 | { |
|---|
| 4441 | UInt code, sizeId, listId; |
|---|
| 4442 | Bool scalingListPredModeFlag; |
|---|
| 4443 | //for each size |
|---|
| 4444 | for(sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
|---|
| 4445 | { |
|---|
| 4446 | for(listId = 0; listId < g_scalingListNum[sizeId]; listId++) |
|---|
| 4447 | { |
|---|
| 4448 | READ_FLAG( code, "scaling_list_pred_mode_flag"); |
|---|
| 4449 | scalingListPredModeFlag = (code) ? true : false; |
|---|
| 4450 | if(!scalingListPredModeFlag) //Copy Mode |
|---|
| 4451 | { |
|---|
| 4452 | READ_UVLC( code, "scaling_list_pred_matrix_id_delta"); |
|---|
| 4453 | scalingList->setRefMatrixId (sizeId,listId,(UInt)((Int)(listId)-(code))); |
|---|
| 4454 | if( sizeId > SCALING_LIST_8x8 ) |
|---|
| 4455 | { |
|---|
| 4456 | scalingList->setScalingListDC(sizeId,listId,((listId == scalingList->getRefMatrixId (sizeId,listId))? 16 :scalingList->getScalingListDC(sizeId, scalingList->getRefMatrixId (sizeId,listId)))); |
|---|
| 4457 | } |
|---|
| 4458 | scalingList->processRefMatrix( sizeId, listId, scalingList->getRefMatrixId (sizeId,listId)); |
|---|
| 4459 | |
|---|
| 4460 | } |
|---|
| 4461 | else //DPCM Mode |
|---|
| 4462 | { |
|---|
| 4463 | xDecodeScalingList(scalingList, sizeId, listId); |
|---|
| 4464 | } |
|---|
| 4465 | } |
|---|
| 4466 | } |
|---|
| 4467 | |
|---|
| 4468 | return; |
|---|
| 4469 | } |
|---|
| 4470 | /** decode DPCM |
|---|
| 4471 | * \param scalingList quantization matrix information |
|---|
| 4472 | * \param sizeId size index |
|---|
| 4473 | * \param listId list index |
|---|
| 4474 | */ |
|---|
| 4475 | Void TDecCavlc::xDecodeScalingList(TComScalingList *scalingList, UInt sizeId, UInt listId) |
|---|
| 4476 | { |
|---|
| 4477 | Int i,coefNum = min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId]); |
|---|
| 4478 | Int data; |
|---|
| 4479 | Int scalingListDcCoefMinus8 = 0; |
|---|
| 4480 | Int nextCoef = SCALING_LIST_START_VALUE; |
|---|
| 4481 | UInt* scan = (sizeId == 0) ? g_auiSigLastScan [ SCAN_DIAG ] [ 1 ] : g_sigLastScanCG32x32; |
|---|
| 4482 | Int *dst = scalingList->getScalingListAddress(sizeId, listId); |
|---|
| 4483 | |
|---|
| 4484 | if( sizeId > SCALING_LIST_8x8 ) |
|---|
| 4485 | { |
|---|
| 4486 | READ_SVLC( scalingListDcCoefMinus8, "scaling_list_dc_coef_minus8"); |
|---|
| 4487 | scalingList->setScalingListDC(sizeId,listId,scalingListDcCoefMinus8 + 8); |
|---|
| 4488 | nextCoef = scalingList->getScalingListDC(sizeId,listId); |
|---|
| 4489 | } |
|---|
| 4490 | |
|---|
| 4491 | for(i = 0; i < coefNum; i++) |
|---|
| 4492 | { |
|---|
| 4493 | READ_SVLC( data, "scaling_list_delta_coef"); |
|---|
| 4494 | nextCoef = (nextCoef + data + 256 ) % 256; |
|---|
| 4495 | dst[scan[i]] = nextCoef; |
|---|
| 4496 | } |
|---|
| 4497 | } |
|---|
| 4498 | |
|---|
| 4499 | Bool TDecCavlc::xMoreRbspData() |
|---|
| 4500 | { |
|---|
| 4501 | Int bitsLeft = m_pcBitstream->getNumBitsLeft(); |
|---|
| 4502 | |
|---|
| 4503 | // if there are more than 8 bits, it cannot be rbsp_trailing_bits |
|---|
| 4504 | if (bitsLeft > 8) |
|---|
| 4505 | { |
|---|
| 4506 | return true; |
|---|
| 4507 | } |
|---|
| 4508 | |
|---|
| 4509 | UChar lastByte = m_pcBitstream->peekBits(bitsLeft); |
|---|
| 4510 | Int cnt = bitsLeft; |
|---|
| 4511 | |
|---|
| 4512 | // remove trailing bits equal to zero |
|---|
| 4513 | while ((cnt>0) && ((lastByte & 1) == 0)) |
|---|
| 4514 | { |
|---|
| 4515 | lastByte >>= 1; |
|---|
| 4516 | cnt--; |
|---|
| 4517 | } |
|---|
| 4518 | // remove bit equal to one |
|---|
| 4519 | cnt--; |
|---|
| 4520 | |
|---|
| 4521 | // we should not have a negative number of bits |
|---|
| 4522 | assert (cnt>=0); |
|---|
| 4523 | |
|---|
| 4524 | // we have more data, if cnt is not zero |
|---|
| 4525 | return (cnt>0); |
|---|
| 4526 | } |
|---|
| 4527 | |
|---|
| 4528 | #if Q0048_CGS_3D_ASYMLUT |
|---|
| 4529 | Void TDecCavlc::xParse3DAsymLUT( TCom3DAsymLUT * pc3DAsymLUT ) |
|---|
| 4530 | { |
|---|
| 4531 | #if R0150_CGS_SIGNAL_CONSTRAINTS |
|---|
| 4532 | UInt uiNumRefLayersM1; |
|---|
| 4533 | READ_UVLC( uiNumRefLayersM1 , "num_cm_ref_layers_minus1" ); |
|---|
| 4534 | assert( uiNumRefLayersM1 <= 61 ); |
|---|
| 4535 | for( UInt i = 0 ; i <= uiNumRefLayersM1 ; i++ ) |
|---|
| 4536 | { |
|---|
| 4537 | UInt uiRefLayerId; |
|---|
| 4538 | READ_CODE( 6 , uiRefLayerId , "cm_ref_layer_id" ); |
|---|
| 4539 | pc3DAsymLUT->addRefLayerId( uiRefLayerId ); |
|---|
| 4540 | } |
|---|
| 4541 | #endif |
|---|
| 4542 | UInt uiCurOctantDepth , uiCurPartNumLog2 , uiInputBitDepthM8 , uiOutputBitDepthM8 , uiResQaunBit; |
|---|
| 4543 | #if R0300_CGS_RES_COEFF_CODING |
|---|
| 4544 | UInt uiDeltaBits; |
|---|
| 4545 | #endif |
|---|
| 4546 | READ_CODE( 2 , uiCurOctantDepth , "cm_octant_depth" ); |
|---|
| 4547 | READ_CODE( 2 , uiCurPartNumLog2 , "cm_y_part_num_log2" ); |
|---|
| 4548 | #if R0150_CGS_SIGNAL_CONSTRAINTS |
|---|
| 4549 | UInt uiChromaInputBitDepthM8 , uiChromaOutputBitDepthM8; |
|---|
| 4550 | READ_UVLC( uiInputBitDepthM8 , "cm_input_luma_bit_depth_minus8" ); |
|---|
| 4551 | READ_UVLC( uiChromaInputBitDepthM8 , "cm_input_chroma_bit_depth_minus8" ); |
|---|
| 4552 | READ_UVLC( uiOutputBitDepthM8 , "cm_output_luma_bit_depth_minus8" ); |
|---|
| 4553 | READ_UVLC( uiChromaOutputBitDepthM8 , "cm_output_chroma_bit_depth_minus8" ); |
|---|
| 4554 | #else |
|---|
| 4555 | READ_CODE( 3 , uiInputBitDepthM8 , "cm_input_bit_depth_minus8" ); |
|---|
| 4556 | Int iInputBitDepthCDelta; |
|---|
| 4557 | READ_SVLC(iInputBitDepthCDelta, "cm_input_bit_depth_chroma delta"); |
|---|
| 4558 | READ_CODE( 3 , uiOutputBitDepthM8 , "cm_output_bit_depth_minus8" ); |
|---|
| 4559 | Int iOutputBitDepthCDelta; |
|---|
| 4560 | READ_SVLC(iOutputBitDepthCDelta, "cm_output_bit_depth_chroma_delta"); |
|---|
| 4561 | #endif |
|---|
| 4562 | READ_CODE( 2 , uiResQaunBit , "cm_res_quant_bit" ); |
|---|
| 4563 | #if R0300_CGS_RES_COEFF_CODING |
|---|
| 4564 | READ_CODE( 2 , uiDeltaBits , "cm_flc_bits" ); |
|---|
| 4565 | pc3DAsymLUT->setDeltaBits(uiDeltaBits + 1); |
|---|
| 4566 | #endif |
|---|
| 4567 | |
|---|
| 4568 | #if R0151_CGS_3D_ASYMLUT_IMPROVE |
|---|
| 4569 | #if R0150_CGS_SIGNAL_CONSTRAINTS |
|---|
| 4570 | Int nAdaptCThresholdU = 1 << ( uiChromaInputBitDepthM8 + 8 - 1 ); |
|---|
| 4571 | Int nAdaptCThresholdV = 1 << ( uiChromaInputBitDepthM8 + 8 - 1 ); |
|---|
| 4572 | #else |
|---|
| 4573 | Int nAdaptCThresholdU = 1 << ( uiInputBitDepthM8 + 8 + iInputBitDepthCDelta - 1 ); |
|---|
| 4574 | Int nAdaptCThresholdV = 1 << ( uiInputBitDepthM8 + 8 + iInputBitDepthCDelta - 1 ); |
|---|
| 4575 | #endif |
|---|
| 4576 | if( uiCurOctantDepth == 1 ) |
|---|
| 4577 | { |
|---|
| 4578 | Int delta = 0; |
|---|
| 4579 | READ_SVLC( delta , "cm_adapt_threshold_u_delta" ); |
|---|
| 4580 | nAdaptCThresholdU += delta; |
|---|
| 4581 | READ_SVLC( delta , "cm_adapt_threshold_v_delta" ); |
|---|
| 4582 | nAdaptCThresholdV += delta; |
|---|
| 4583 | } |
|---|
| 4584 | #endif |
|---|
| 4585 | pc3DAsymLUT->destroy(); |
|---|
| 4586 | pc3DAsymLUT->create( uiCurOctantDepth , uiInputBitDepthM8 + 8 , |
|---|
| 4587 | #if R0150_CGS_SIGNAL_CONSTRAINTS |
|---|
| 4588 | uiChromaInputBitDepthM8 + 8 , |
|---|
| 4589 | #else |
|---|
| 4590 | uiInputBitDepthM8 + 8 + iInputBitDepthCDelta, |
|---|
| 4591 | #endif |
|---|
| 4592 | uiOutputBitDepthM8 + 8 , |
|---|
| 4593 | #if R0150_CGS_SIGNAL_CONSTRAINTS |
|---|
| 4594 | uiChromaOutputBitDepthM8 + 8 , |
|---|
| 4595 | #else |
|---|
| 4596 | uiOutputBitDepthM8 + 8 + iOutputBitDepthCDelta , |
|---|
| 4597 | #endif |
|---|
| 4598 | uiCurPartNumLog2 |
|---|
| 4599 | #if R0151_CGS_3D_ASYMLUT_IMPROVE |
|---|
| 4600 | , nAdaptCThresholdU , nAdaptCThresholdV |
|---|
| 4601 | #endif |
|---|
| 4602 | ); |
|---|
| 4603 | pc3DAsymLUT->setResQuantBit( uiResQaunBit ); |
|---|
| 4604 | |
|---|
| 4605 | #if R0164_CGS_LUT_BUGFIX_CHECK |
|---|
| 4606 | pc3DAsymLUT->xInitCuboids(); |
|---|
| 4607 | #endif |
|---|
| 4608 | xParse3DAsymLUTOctant( pc3DAsymLUT , 0 , 0 , 0 , 0 , 1 << pc3DAsymLUT->getCurOctantDepth() ); |
|---|
| 4609 | #if R0164_CGS_LUT_BUGFIX |
|---|
| 4610 | #if R0164_CGS_LUT_BUGFIX_CHECK |
|---|
| 4611 | printf("============= Before 'xCuboidsFilledCheck()': ================\n"); |
|---|
| 4612 | pc3DAsymLUT->display(); |
|---|
| 4613 | pc3DAsymLUT->xCuboidsFilledCheck( false ); |
|---|
| 4614 | printf("============= After 'xCuboidsFilledCheck()': =================\n"); |
|---|
| 4615 | pc3DAsymLUT->display(); |
|---|
| 4616 | #endif |
|---|
| 4617 | #endif |
|---|
| 4618 | } |
|---|
| 4619 | |
|---|
| 4620 | Void TDecCavlc::xParse3DAsymLUTOctant( TCom3DAsymLUT * pc3DAsymLUT , Int nDepth , Int yIdx , Int uIdx , Int vIdx , Int nLength ) |
|---|
| 4621 | { |
|---|
| 4622 | UInt uiOctantSplit = nDepth < pc3DAsymLUT->getCurOctantDepth(); |
|---|
| 4623 | if( nDepth < pc3DAsymLUT->getCurOctantDepth() ) |
|---|
| 4624 | READ_FLAG( uiOctantSplit , "split_octant_flag" ); |
|---|
| 4625 | Int nYPartNum = 1 << pc3DAsymLUT->getCurYPartNumLog2(); |
|---|
| 4626 | if( uiOctantSplit ) |
|---|
| 4627 | { |
|---|
| 4628 | Int nHalfLength = nLength >> 1; |
|---|
| 4629 | for( Int l = 0 ; l < 2 ; l++ ) |
|---|
| 4630 | { |
|---|
| 4631 | for( Int m = 0 ; m < 2 ; m++ ) |
|---|
| 4632 | { |
|---|
| 4633 | for( Int n = 0 ; n < 2 ; n++ ) |
|---|
| 4634 | { |
|---|
| 4635 | xParse3DAsymLUTOctant( pc3DAsymLUT , nDepth + 1 , yIdx + l * nHalfLength * nYPartNum , uIdx + m * nHalfLength , vIdx + n * nHalfLength , nHalfLength ); |
|---|
| 4636 | } |
|---|
| 4637 | } |
|---|
| 4638 | } |
|---|
| 4639 | } |
|---|
| 4640 | else |
|---|
| 4641 | { |
|---|
| 4642 | #if R0300_CGS_RES_COEFF_CODING |
|---|
| 4643 | Int nFLCbits = pc3DAsymLUT->getMappingShift()-pc3DAsymLUT->getResQuantBit()-pc3DAsymLUT->getDeltaBits() ; |
|---|
| 4644 | nFLCbits = nFLCbits >= 0 ? nFLCbits:0; |
|---|
| 4645 | #endif |
|---|
| 4646 | for( Int l = 0 ; l < nYPartNum ; l++ ) |
|---|
| 4647 | { |
|---|
| 4648 | #if R0164_CGS_LUT_BUGFIX |
|---|
| 4649 | Int shift = pc3DAsymLUT->getCurOctantDepth() - nDepth ; |
|---|
| 4650 | #endif |
|---|
| 4651 | for( Int nVertexIdx = 0 ; nVertexIdx < 4 ; nVertexIdx++ ) |
|---|
| 4652 | { |
|---|
| 4653 | UInt uiCodeVertex = 0; |
|---|
| 4654 | Int deltaY = 0 , deltaU = 0 , deltaV = 0; |
|---|
| 4655 | READ_FLAG( uiCodeVertex , "coded_vertex_flag" ); |
|---|
| 4656 | if( uiCodeVertex ) |
|---|
| 4657 | { |
|---|
| 4658 | #if R0151_CGS_3D_ASYMLUT_IMPROVE |
|---|
| 4659 | #if R0300_CGS_RES_COEFF_CODING |
|---|
| 4660 | xReadParam( deltaY, nFLCbits ); |
|---|
| 4661 | xReadParam( deltaU, nFLCbits ); |
|---|
| 4662 | xReadParam( deltaV, nFLCbits ); |
|---|
| 4663 | #else |
|---|
| 4664 | xReadParam( deltaY ); |
|---|
| 4665 | xReadParam( deltaU ); |
|---|
| 4666 | xReadParam( deltaV ); |
|---|
| 4667 | #endif |
|---|
| 4668 | #else |
|---|
| 4669 | READ_SVLC( deltaY , "resY" ); |
|---|
| 4670 | READ_SVLC( deltaU , "resU" ); |
|---|
| 4671 | READ_SVLC( deltaV , "resV" ); |
|---|
| 4672 | #endif |
|---|
| 4673 | } |
|---|
| 4674 | #if R0164_CGS_LUT_BUGFIX |
|---|
| 4675 | pc3DAsymLUT->setCuboidVertexResTree( yIdx + (l<<shift) , uIdx , vIdx , nVertexIdx , deltaY , deltaU , deltaV ); |
|---|
| 4676 | for (Int m = 1; m < (1<<shift); m++) { |
|---|
| 4677 | pc3DAsymLUT->setCuboidVertexResTree( yIdx + (l<<shift) + m , uIdx , vIdx , nVertexIdx , 0 , 0 , 0 ); |
|---|
| 4678 | #if R0164_CGS_LUT_BUGFIX_CHECK |
|---|
| 4679 | pc3DAsymLUT->xSetFilled( yIdx + (l<<shift) + m , uIdx , vIdx ); |
|---|
| 4680 | #endif |
|---|
| 4681 | } |
|---|
| 4682 | #else |
|---|
| 4683 | pc3DAsymLUT->setCuboidVertexResTree( yIdx + l , uIdx , vIdx , nVertexIdx , deltaY , deltaU , deltaV ); |
|---|
| 4684 | #endif |
|---|
| 4685 | } |
|---|
| 4686 | #if R0164_CGS_LUT_BUGFIX_CHECK |
|---|
| 4687 | pc3DAsymLUT->xSetExplicit( yIdx + (l<<shift) , uIdx , vIdx ); |
|---|
| 4688 | #endif |
|---|
| 4689 | } |
|---|
| 4690 | #if R0164_CGS_LUT_BUGFIX |
|---|
| 4691 | for ( Int u=0 ; u<nLength ; u++ ) { |
|---|
| 4692 | for ( Int v=0 ; v<nLength ; v++ ) { |
|---|
| 4693 | if ( u!=0 || v!=0 ) { |
|---|
| 4694 | for ( Int y=0 ; y<nLength*nYPartNum ; y++ ) { |
|---|
| 4695 | for( Int nVertexIdx = 0 ; nVertexIdx < 4 ; nVertexIdx++ ) |
|---|
| 4696 | { |
|---|
| 4697 | pc3DAsymLUT->setCuboidVertexResTree( yIdx + y , uIdx + u , vIdx + v , nVertexIdx , 0 , 0 , 0 ); |
|---|
| 4698 | #if R0164_CGS_LUT_BUGFIX_CHECK |
|---|
| 4699 | pc3DAsymLUT->xSetFilled( yIdx + y , uIdx + u , vIdx + v ); |
|---|
| 4700 | #endif |
|---|
| 4701 | } |
|---|
| 4702 | } |
|---|
| 4703 | } |
|---|
| 4704 | } |
|---|
| 4705 | } |
|---|
| 4706 | #endif |
|---|
| 4707 | } |
|---|
| 4708 | } |
|---|
| 4709 | |
|---|
| 4710 | #if R0151_CGS_3D_ASYMLUT_IMPROVE |
|---|
| 4711 | #if R0300_CGS_RES_COEFF_CODING |
|---|
| 4712 | Void TDecCavlc::xReadParam( Int& param, Int rParam ) |
|---|
| 4713 | #else |
|---|
| 4714 | Void TDecCavlc::xReadParam( Int& param ) |
|---|
| 4715 | #endif |
|---|
| 4716 | { |
|---|
| 4717 | #if !R0300_CGS_RES_COEFF_CODING |
|---|
| 4718 | const UInt rParam = 7; |
|---|
| 4719 | #endif |
|---|
| 4720 | UInt prefix; |
|---|
| 4721 | UInt codeWord ; |
|---|
| 4722 | UInt rSymbol; |
|---|
| 4723 | UInt sign; |
|---|
| 4724 | |
|---|
| 4725 | READ_UVLC( prefix, "quotient") ; |
|---|
| 4726 | READ_CODE (rParam, codeWord, "remainder"); |
|---|
| 4727 | rSymbol = (prefix<<rParam) + codeWord; |
|---|
| 4728 | |
|---|
| 4729 | if(rSymbol) |
|---|
| 4730 | { |
|---|
| 4731 | READ_FLAG(sign, "sign"); |
|---|
| 4732 | param = sign ? -(Int)(rSymbol) : (Int)(rSymbol); |
|---|
| 4733 | } |
|---|
| 4734 | else param = 0; |
|---|
| 4735 | } |
|---|
| 4736 | #endif |
|---|
| 4737 | #if VPS_VUI_BSP_HRD_PARAMS |
|---|
| 4738 | Void TDecCavlc::parseVpsVuiBspHrdParams( TComVPS *vps ) |
|---|
| 4739 | { |
|---|
| 4740 | UInt uiCode; |
|---|
| 4741 | assert (vps->getTimingInfo()->getTimingInfoPresentFlag() == 1); |
|---|
| 4742 | READ_UVLC( uiCode, "vps_num_add_hrd_params" ); vps->setVpsNumAddHrdParams(uiCode); |
|---|
| 4743 | vps->createBspHrdParamBuffer(vps->getVpsNumAddHrdParams()); // Also allocates m_cprmsAddPresentFlag and m_numSubLayerHrdMinus |
|---|
| 4744 | |
|---|
| 4745 | for( Int i = vps->getNumHrdParameters(), j = 0; i < vps->getNumHrdParameters() + vps->getVpsNumAddHrdParams(); i++, j++ ) // j = i - vps->getNumHrdParameters() |
|---|
| 4746 | { |
|---|
| 4747 | if( i > 0 ) |
|---|
| 4748 | { |
|---|
| 4749 | READ_FLAG( uiCode, "cprms_add_present_flag[i]" ); vps->setCprmsAddPresentFlag(j, uiCode ? true : false); |
|---|
| 4750 | } |
|---|
| 4751 | else |
|---|
| 4752 | { |
|---|
| 4753 | // i == 0 |
|---|
| 4754 | if( vps->getNumHrdParameters() == 0 ) |
|---|
| 4755 | { |
|---|
| 4756 | vps->setCprmsAddPresentFlag(0, true); |
|---|
| 4757 | } |
|---|
| 4758 | } |
|---|
| 4759 | READ_UVLC( uiCode, "num_sub_layer_hrd_minus1[i]" ); vps->setNumSubLayerHrdMinus1(j, uiCode ); |
|---|
| 4760 | assert( uiCode <= vps->getMaxTLayers() - 1 ); |
|---|
| 4761 | |
|---|
| 4762 | parseHrdParameters( vps->getBspHrd(j), vps->getCprmsAddPresentFlag(j), vps->getNumSubLayerHrdMinus1(j) ); |
|---|
| 4763 | if( i > 0 && !vps->getCprmsAddPresentFlag(i) ) |
|---|
| 4764 | { |
|---|
| 4765 | // Copy common information parameters |
|---|
| 4766 | if( i == vps->getNumHrdParameters() ) |
|---|
| 4767 | { |
|---|
| 4768 | vps->getBspHrd(j)->copyCommonInformation( vps->getHrdParameters( vps->getNumHrdParameters() - 1 ) ); |
|---|
| 4769 | } |
|---|
| 4770 | else |
|---|
| 4771 | { |
|---|
| 4772 | vps->getBspHrd(j)->copyCommonInformation( vps->getBspHrd( j - 1 ) ); |
|---|
| 4773 | } |
|---|
| 4774 | } |
|---|
| 4775 | } |
|---|
| 4776 | for (Int h = 1; h < vps->getNumOutputLayerSets(); h++) |
|---|
| 4777 | { |
|---|
| 4778 | Int lsIdx = vps->getOutputLayerSetIdx( h ); |
|---|
| 4779 | READ_UVLC( uiCode, "num_signalled_partitioning_schemes[h]"); vps->setNumSignalledPartitioningSchemes(h, uiCode); |
|---|
| 4780 | for( Int j = 0; j < vps->getNumSignalledPartitioningSchemes(h); j++ ) |
|---|
| 4781 | { |
|---|
| 4782 | READ_UVLC( uiCode, "num_partitions_in_scheme_minus1[h][j]" ); vps->setNumPartitionsInSchemeMinus1(h, j, uiCode); |
|---|
| 4783 | for( Int k = 0; k <= vps->getNumPartitionsInSchemeMinus1(h, j); k++ ) |
|---|
| 4784 | { |
|---|
| 4785 | for( Int r = 0; r < vps->getNumLayersInIdList( lsIdx ); r++ ) |
|---|
| 4786 | { |
|---|
| 4787 | READ_FLAG( uiCode, "layer_included_in_partition_flag[h][j][k][r]" ); vps->setLayerIncludedInPartitionFlag(h, j, k, r, uiCode ? true : false); |
|---|
| 4788 | } |
|---|
| 4789 | } |
|---|
| 4790 | } |
|---|
| 4791 | for( Int i = 0; i < vps->getNumSignalledPartitioningSchemes(h) + 1; i++ ) |
|---|
| 4792 | { |
|---|
| 4793 | for( Int t = 0; t <= vps->getMaxSLayersInLayerSetMinus1(lsIdx); t++ ) |
|---|
| 4794 | { |
|---|
| 4795 | READ_UVLC( uiCode, "num_bsp_schedules_minus1[h][i][t]"); vps->setNumBspSchedulesMinus1(h, i, t, uiCode); |
|---|
| 4796 | for( Int j = 0; j <= vps->getNumBspSchedulesMinus1(h, i, t); j++ ) |
|---|
| 4797 | { |
|---|
| 4798 | for( Int k = 0; k < vps->getNumPartitionsInSchemeMinus1(h, i); k++ ) |
|---|
| 4799 | { |
|---|
| 4800 | READ_UVLC( uiCode, "bsp_comb_hrd_idx[h][i][t][j][k]"); vps->setBspHrdIdx(h, i, t, j, k, uiCode); |
|---|
| 4801 | READ_UVLC( uiCode, "bsp_comb_sched_idx[h][i][t][j][k]"); vps->setBspSchedIdx(h, i, t, j, k, uiCode); |
|---|
| 4802 | } |
|---|
| 4803 | } |
|---|
| 4804 | } |
|---|
| 4805 | } |
|---|
| 4806 | |
|---|
| 4807 | // To be done: Check each layer included in not more than one BSP in every partitioning scheme, |
|---|
| 4808 | // and other related checks associated with layers in bitstream partitions. |
|---|
| 4809 | |
|---|
| 4810 | } |
|---|
| 4811 | } |
|---|
| 4812 | #endif |
|---|
| 4813 | #endif |
|---|
| 4814 | //! \} |
|---|
| 4815 | |
|---|