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