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