[313] | 1 | /* The copyright in this software is being made available under the BSD |
---|
| 2 | * License, included below. This software may be subject to other third party |
---|
| 3 | * and contributor rights, including patent rights, and no such rights are |
---|
| 4 | * granted under this license. |
---|
| 5 | * |
---|
| 6 | * Copyright (c) 2010-2013, 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 | |
---|
| 42 | //! \ingroup TLibDecoder |
---|
| 43 | //! \{ |
---|
| 44 | |
---|
| 45 | #if ENC_DEC_TRACE |
---|
| 46 | |
---|
| 47 | Void xTraceSPSHeader (TComSPS *pSPS) |
---|
| 48 | { |
---|
| 49 | fprintf( g_hTrace, "=========== Sequence Parameter Set ID: %d ===========\n", pSPS->getSPSId() ); |
---|
| 50 | } |
---|
| 51 | |
---|
| 52 | Void xTracePPSHeader (TComPPS *pPPS) |
---|
| 53 | { |
---|
| 54 | fprintf( g_hTrace, "=========== Picture Parameter Set ID: %d ===========\n", pPPS->getPPSId() ); |
---|
| 55 | } |
---|
| 56 | |
---|
| 57 | Void xTraceSliceHeader (TComSlice *pSlice) |
---|
| 58 | { |
---|
| 59 | fprintf( g_hTrace, "=========== Slice ===========\n"); |
---|
| 60 | } |
---|
| 61 | |
---|
| 62 | #endif |
---|
| 63 | |
---|
| 64 | // ==================================================================================================================== |
---|
| 65 | // Constructor / destructor / create / destroy |
---|
| 66 | // ==================================================================================================================== |
---|
| 67 | |
---|
| 68 | TDecCavlc::TDecCavlc() |
---|
| 69 | { |
---|
| 70 | } |
---|
| 71 | |
---|
| 72 | TDecCavlc::~TDecCavlc() |
---|
| 73 | { |
---|
| 74 | |
---|
| 75 | } |
---|
| 76 | |
---|
| 77 | // ==================================================================================================================== |
---|
| 78 | // Public member functions |
---|
| 79 | // ==================================================================================================================== |
---|
| 80 | |
---|
| 81 | void TDecCavlc::parseShortTermRefPicSet( TComSPS* sps, TComReferencePictureSet* rps, Int idx ) |
---|
| 82 | { |
---|
| 83 | UInt code; |
---|
| 84 | UInt interRPSPred; |
---|
| 85 | if (idx > 0) |
---|
| 86 | { |
---|
| 87 | READ_FLAG(interRPSPred, "inter_ref_pic_set_prediction_flag"); rps->setInterRPSPrediction(interRPSPred); |
---|
| 88 | } |
---|
| 89 | else |
---|
| 90 | { |
---|
| 91 | interRPSPred = false; |
---|
| 92 | rps->setInterRPSPrediction(false); |
---|
| 93 | } |
---|
| 94 | |
---|
| 95 | if (interRPSPred) |
---|
| 96 | { |
---|
| 97 | UInt bit; |
---|
| 98 | if(idx == sps->getRPSList()->getNumberOfReferencePictureSets()) |
---|
| 99 | { |
---|
| 100 | READ_UVLC(code, "delta_idx_minus1" ); // delta index of the Reference Picture Set used for prediction minus 1 |
---|
| 101 | } |
---|
| 102 | else |
---|
| 103 | { |
---|
| 104 | code = 0; |
---|
| 105 | } |
---|
| 106 | 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 |
---|
| 107 | Int rIdx = idx - 1 - code; |
---|
| 108 | 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 |
---|
| 109 | TComReferencePictureSet* rpsRef = sps->getRPSList()->getReferencePictureSet(rIdx); |
---|
| 110 | Int k = 0, k0 = 0, k1 = 0; |
---|
| 111 | READ_CODE(1, bit, "delta_rps_sign"); // delta_RPS_sign |
---|
| 112 | READ_UVLC(code, "abs_delta_rps_minus1"); // absolute delta RPS minus 1 |
---|
| 113 | Int deltaRPS = (1 - 2 * bit) * (code + 1); // delta_RPS |
---|
| 114 | for(Int j=0 ; j <= rpsRef->getNumberOfPictures(); j++) |
---|
| 115 | { |
---|
| 116 | READ_CODE(1, bit, "used_by_curr_pic_flag" ); //first bit is "1" if Idc is 1 |
---|
| 117 | Int refIdc = bit; |
---|
| 118 | if (refIdc == 0) |
---|
| 119 | { |
---|
| 120 | READ_CODE(1, bit, "use_delta_flag" ); //second bit is "1" if Idc is 2, "0" otherwise. |
---|
| 121 | refIdc = bit<<1; //second bit is "1" if refIdc is 2, "0" if refIdc = 0. |
---|
| 122 | } |
---|
| 123 | if (refIdc == 1 || refIdc == 2) |
---|
| 124 | { |
---|
| 125 | Int deltaPOC = deltaRPS + ((j < rpsRef->getNumberOfPictures())? rpsRef->getDeltaPOC(j) : 0); |
---|
| 126 | rps->setDeltaPOC(k, deltaPOC); |
---|
| 127 | rps->setUsed(k, (refIdc == 1)); |
---|
| 128 | |
---|
| 129 | if (deltaPOC < 0) |
---|
| 130 | { |
---|
| 131 | k0++; |
---|
| 132 | } |
---|
| 133 | else |
---|
| 134 | { |
---|
| 135 | k1++; |
---|
| 136 | } |
---|
| 137 | k++; |
---|
| 138 | } |
---|
| 139 | rps->setRefIdc(j,refIdc); |
---|
| 140 | } |
---|
| 141 | rps->setNumRefIdc(rpsRef->getNumberOfPictures()+1); |
---|
| 142 | rps->setNumberOfPictures(k); |
---|
| 143 | rps->setNumberOfNegativePictures(k0); |
---|
| 144 | rps->setNumberOfPositivePictures(k1); |
---|
| 145 | rps->sortDeltaPOC(); |
---|
| 146 | } |
---|
| 147 | else |
---|
| 148 | { |
---|
| 149 | READ_UVLC(code, "num_negative_pics"); rps->setNumberOfNegativePictures(code); |
---|
| 150 | READ_UVLC(code, "num_positive_pics"); rps->setNumberOfPositivePictures(code); |
---|
| 151 | Int prev = 0; |
---|
| 152 | Int poc; |
---|
| 153 | for(Int j=0 ; j < rps->getNumberOfNegativePictures(); j++) |
---|
| 154 | { |
---|
| 155 | READ_UVLC(code, "delta_poc_s0_minus1"); |
---|
| 156 | poc = prev-code-1; |
---|
| 157 | prev = poc; |
---|
| 158 | rps->setDeltaPOC(j,poc); |
---|
| 159 | READ_FLAG(code, "used_by_curr_pic_s0_flag"); rps->setUsed(j,code); |
---|
| 160 | } |
---|
| 161 | prev = 0; |
---|
| 162 | for(Int j=rps->getNumberOfNegativePictures(); j < rps->getNumberOfNegativePictures()+rps->getNumberOfPositivePictures(); j++) |
---|
| 163 | { |
---|
| 164 | READ_UVLC(code, "delta_poc_s1_minus1"); |
---|
| 165 | poc = prev+code+1; |
---|
| 166 | prev = poc; |
---|
| 167 | rps->setDeltaPOC(j,poc); |
---|
| 168 | READ_FLAG(code, "used_by_curr_pic_s1_flag"); rps->setUsed(j,code); |
---|
| 169 | } |
---|
| 170 | rps->setNumberOfPictures(rps->getNumberOfNegativePictures()+rps->getNumberOfPositivePictures()); |
---|
| 171 | } |
---|
| 172 | #if PRINT_RPS_INFO |
---|
| 173 | rps->printDeltaPOC(); |
---|
| 174 | #endif |
---|
| 175 | } |
---|
| 176 | |
---|
| 177 | Void TDecCavlc::parsePPS(TComPPS* pcPPS) |
---|
| 178 | { |
---|
| 179 | #if ENC_DEC_TRACE |
---|
| 180 | xTracePPSHeader (pcPPS); |
---|
| 181 | #endif |
---|
| 182 | UInt uiCode; |
---|
| 183 | |
---|
| 184 | Int iCode; |
---|
| 185 | |
---|
| 186 | READ_UVLC( uiCode, "pps_pic_parameter_set_id"); |
---|
| 187 | assert(uiCode <= 63); |
---|
| 188 | pcPPS->setPPSId (uiCode); |
---|
| 189 | |
---|
| 190 | READ_UVLC( uiCode, "pps_seq_parameter_set_id"); |
---|
| 191 | assert(uiCode <= 15); |
---|
| 192 | pcPPS->setSPSId (uiCode); |
---|
| 193 | |
---|
| 194 | READ_FLAG( uiCode, "dependent_slice_segments_enabled_flag" ); pcPPS->setDependentSliceSegmentsEnabledFlag ( uiCode == 1 ); |
---|
| 195 | READ_FLAG( uiCode, "output_flag_present_flag" ); pcPPS->setOutputFlagPresentFlag( uiCode==1 ); |
---|
| 196 | |
---|
| 197 | READ_CODE(3, uiCode, "num_extra_slice_header_bits"); pcPPS->setNumExtraSliceHeaderBits(uiCode); |
---|
| 198 | READ_FLAG ( uiCode, "sign_data_hiding_flag" ); pcPPS->setSignHideFlag( uiCode ); |
---|
| 199 | |
---|
| 200 | READ_FLAG( uiCode, "cabac_init_present_flag" ); pcPPS->setCabacInitPresentFlag( uiCode ? true : false ); |
---|
| 201 | |
---|
| 202 | READ_UVLC(uiCode, "num_ref_idx_l0_default_active_minus1"); |
---|
| 203 | assert(uiCode <= 14); |
---|
| 204 | pcPPS->setNumRefIdxL0DefaultActive(uiCode+1); |
---|
| 205 | |
---|
| 206 | READ_UVLC(uiCode, "num_ref_idx_l1_default_active_minus1"); |
---|
| 207 | assert(uiCode <= 14); |
---|
| 208 | pcPPS->setNumRefIdxL1DefaultActive(uiCode+1); |
---|
| 209 | |
---|
| 210 | READ_SVLC(iCode, "init_qp_minus26" ); pcPPS->setPicInitQPMinus26(iCode); |
---|
| 211 | READ_FLAG( uiCode, "constrained_intra_pred_flag" ); pcPPS->setConstrainedIntraPred( uiCode ? true : false ); |
---|
| 212 | READ_FLAG( uiCode, "transform_skip_enabled_flag" ); |
---|
| 213 | pcPPS->setUseTransformSkip ( uiCode ? true : false ); |
---|
| 214 | |
---|
| 215 | READ_FLAG( uiCode, "cu_qp_delta_enabled_flag" ); pcPPS->setUseDQP( uiCode ? true : false ); |
---|
| 216 | if( pcPPS->getUseDQP() ) |
---|
| 217 | { |
---|
| 218 | READ_UVLC( uiCode, "diff_cu_qp_delta_depth" ); |
---|
| 219 | pcPPS->setMaxCuDQPDepth( uiCode ); |
---|
| 220 | } |
---|
| 221 | else |
---|
| 222 | { |
---|
| 223 | pcPPS->setMaxCuDQPDepth( 0 ); |
---|
| 224 | } |
---|
| 225 | READ_SVLC( iCode, "pps_cb_qp_offset"); |
---|
| 226 | pcPPS->setChromaCbQpOffset(iCode); |
---|
| 227 | assert( pcPPS->getChromaCbQpOffset() >= -12 ); |
---|
| 228 | assert( pcPPS->getChromaCbQpOffset() <= 12 ); |
---|
| 229 | |
---|
| 230 | READ_SVLC( iCode, "pps_cr_qp_offset"); |
---|
| 231 | pcPPS->setChromaCrQpOffset(iCode); |
---|
| 232 | assert( pcPPS->getChromaCrQpOffset() >= -12 ); |
---|
| 233 | assert( pcPPS->getChromaCrQpOffset() <= 12 ); |
---|
| 234 | |
---|
| 235 | READ_FLAG( uiCode, "pps_slice_chroma_qp_offsets_present_flag" ); |
---|
| 236 | pcPPS->setSliceChromaQpFlag( uiCode ? true : false ); |
---|
| 237 | |
---|
| 238 | READ_FLAG( uiCode, "weighted_pred_flag" ); // Use of Weighting Prediction (P_SLICE) |
---|
| 239 | pcPPS->setUseWP( uiCode==1 ); |
---|
| 240 | READ_FLAG( uiCode, "weighted_bipred_flag" ); // Use of Bi-Directional Weighting Prediction (B_SLICE) |
---|
| 241 | pcPPS->setWPBiPred( uiCode==1 ); |
---|
| 242 | |
---|
| 243 | READ_FLAG( uiCode, "transquant_bypass_enable_flag"); |
---|
| 244 | pcPPS->setTransquantBypassEnableFlag(uiCode ? true : false); |
---|
| 245 | READ_FLAG( uiCode, "tiles_enabled_flag" ); pcPPS->setTilesEnabledFlag ( uiCode == 1 ); |
---|
| 246 | READ_FLAG( uiCode, "entropy_coding_sync_enabled_flag" ); pcPPS->setEntropyCodingSyncEnabledFlag( uiCode == 1 ); |
---|
| 247 | |
---|
| 248 | if( pcPPS->getTilesEnabledFlag() ) |
---|
| 249 | { |
---|
| 250 | READ_UVLC ( uiCode, "num_tile_columns_minus1" ); pcPPS->setNumColumnsMinus1( uiCode ); |
---|
| 251 | READ_UVLC ( uiCode, "num_tile_rows_minus1" ); pcPPS->setNumRowsMinus1( uiCode ); |
---|
| 252 | READ_FLAG ( uiCode, "uniform_spacing_flag" ); pcPPS->setUniformSpacingFlag( uiCode ); |
---|
| 253 | |
---|
| 254 | if( !pcPPS->getUniformSpacingFlag()) |
---|
| 255 | { |
---|
| 256 | UInt* columnWidth = (UInt*)malloc(pcPPS->getNumColumnsMinus1()*sizeof(UInt)); |
---|
| 257 | for(UInt i=0; i<pcPPS->getNumColumnsMinus1(); i++) |
---|
| 258 | { |
---|
| 259 | READ_UVLC( uiCode, "column_width_minus1" ); |
---|
| 260 | columnWidth[i] = uiCode+1; |
---|
| 261 | } |
---|
| 262 | pcPPS->setColumnWidth(columnWidth); |
---|
| 263 | free(columnWidth); |
---|
| 264 | |
---|
| 265 | UInt* rowHeight = (UInt*)malloc(pcPPS->getNumRowsMinus1()*sizeof(UInt)); |
---|
| 266 | for(UInt i=0; i<pcPPS->getNumRowsMinus1(); i++) |
---|
| 267 | { |
---|
| 268 | READ_UVLC( uiCode, "row_height_minus1" ); |
---|
| 269 | rowHeight[i] = uiCode + 1; |
---|
| 270 | } |
---|
| 271 | pcPPS->setRowHeight(rowHeight); |
---|
| 272 | free(rowHeight); |
---|
| 273 | } |
---|
| 274 | |
---|
| 275 | if(pcPPS->getNumColumnsMinus1() !=0 || pcPPS->getNumRowsMinus1() !=0) |
---|
| 276 | { |
---|
| 277 | READ_FLAG ( uiCode, "loop_filter_across_tiles_enabled_flag" ); pcPPS->setLoopFilterAcrossTilesEnabledFlag( uiCode ? true : false ); |
---|
| 278 | } |
---|
| 279 | } |
---|
| 280 | READ_FLAG( uiCode, "loop_filter_across_slices_enabled_flag" ); pcPPS->setLoopFilterAcrossSlicesEnabledFlag( uiCode ? true : false ); |
---|
| 281 | READ_FLAG( uiCode, "deblocking_filter_control_present_flag" ); pcPPS->setDeblockingFilterControlPresentFlag( uiCode ? true : false ); |
---|
| 282 | if(pcPPS->getDeblockingFilterControlPresentFlag()) |
---|
| 283 | { |
---|
| 284 | READ_FLAG( uiCode, "deblocking_filter_override_enabled_flag" ); pcPPS->setDeblockingFilterOverrideEnabledFlag( uiCode ? true : false ); |
---|
| 285 | READ_FLAG( uiCode, "pps_disable_deblocking_filter_flag" ); pcPPS->setPicDisableDeblockingFilterFlag(uiCode ? true : false ); |
---|
| 286 | if(!pcPPS->getPicDisableDeblockingFilterFlag()) |
---|
| 287 | { |
---|
| 288 | READ_SVLC ( iCode, "pps_beta_offset_div2" ); pcPPS->setDeblockingFilterBetaOffsetDiv2( iCode ); |
---|
| 289 | READ_SVLC ( iCode, "pps_tc_offset_div2" ); pcPPS->setDeblockingFilterTcOffsetDiv2( iCode ); |
---|
| 290 | } |
---|
| 291 | } |
---|
| 292 | READ_FLAG( uiCode, "pps_scaling_list_data_present_flag" ); pcPPS->setScalingListPresentFlag( uiCode ? true : false ); |
---|
[442] | 293 | |
---|
| 294 | #if IL_SL_SIGNALLING_N0371 |
---|
| 295 | pcPPS->setPPS( pcPPS->getLayerId(), pcPPS ); |
---|
| 296 | #endif |
---|
| 297 | |
---|
[313] | 298 | if(pcPPS->getScalingListPresentFlag ()) |
---|
| 299 | { |
---|
[442] | 300 | #if IL_SL_SIGNALLING_N0371 |
---|
| 301 | pcPPS->getScalingList()->setLayerId( pcPPS->getLayerId() ); |
---|
| 302 | |
---|
| 303 | if( pcPPS->getLayerId() > 0 ) |
---|
| 304 | { |
---|
| 305 | READ_FLAG( uiCode, "pps_pred_scaling_list_flag" ); pcPPS->setPredScalingListFlag( uiCode ? true : false ); |
---|
| 306 | pcPPS->getScalingList()->setPredScalingListFlag( pcPPS->getPredScalingListFlag() ); |
---|
| 307 | |
---|
| 308 | if( pcPPS->getPredScalingListFlag() ) |
---|
| 309 | { |
---|
| 310 | READ_UVLC ( uiCode, "scaling_list_pps_ref_layer_id" ); pcPPS->setScalingListRefLayerId( uiCode ); |
---|
| 311 | |
---|
| 312 | // The value of pps_scaling_list_ref_layer_id shall be in the range of 0 to 62, inclusive |
---|
| 313 | assert( /*pcPPS->getScalingListRefLayerId() >= 0 &&*/ pcPPS->getScalingListRefLayerId() <= 62 ); |
---|
| 314 | |
---|
| 315 | // When avc_base_layer_flag is equal to 1, it is a requirement of bitstream conformance that the value of pps_scaling_list_ref_layer_id shall be greater than 0 |
---|
| 316 | if( pcPPS->getSPS()->getVPS()->getAvcBaseLayerFlag() ) |
---|
| 317 | { |
---|
| 318 | assert( pcPPS->getScalingListRefLayerId() > 0 ); |
---|
| 319 | } |
---|
| 320 | |
---|
| 321 | // It is a requirement of bitstream conformance that, when a PPS with nuh_layer_id equal to nuhLayerIdA is active for a layer with nuh_layer_id equal to nuhLayerIdB and |
---|
| 322 | // pps_infer_scaling_list_flag in the PPS is equal to 1, pps_infer_scaling_list_flag shall be equal to 0 for the PPS that is active for the layer with nuh_layer_id equal to pps_scaling_list_ref_layer_id |
---|
| 323 | assert( pcPPS->getPPS( pcPPS->getScalingListRefLayerId() )->getPredScalingListFlag() == false ); |
---|
| 324 | |
---|
| 325 | // It is a requirement of bitstream conformance that, when a PPS with nuh_layer_id equal to nuhLayerIdA is active for a layer with nuh_layer_id equal to nuhLayerIdB, |
---|
| 326 | // the layer with nuh_layer_id equal to pps_scaling_list_ref_layer_id shall be a direct or indirect reference layer of the layer with nuh_layer_id equal to nuhLayerIdB |
---|
| 327 | assert( pcPPS->getSPS()->getVPS()->getScalingListLayerDependency( pcPPS->getLayerId(), pcPPS->getScalingListRefLayerId() ) == true ); |
---|
| 328 | |
---|
| 329 | pcPPS->getScalingList()->setScalingListRefLayerId( pcPPS->getScalingListRefLayerId() ); |
---|
| 330 | parseScalingList( pcPPS->getScalingList() ); |
---|
| 331 | } |
---|
| 332 | else |
---|
| 333 | { |
---|
| 334 | parseScalingList( pcPPS->getScalingList() ); |
---|
| 335 | } |
---|
| 336 | } |
---|
| 337 | else |
---|
| 338 | { |
---|
| 339 | parseScalingList( pcPPS->getScalingList() ); |
---|
| 340 | } |
---|
| 341 | #else |
---|
[313] | 342 | parseScalingList( pcPPS->getScalingList() ); |
---|
[442] | 343 | #endif |
---|
[313] | 344 | } |
---|
| 345 | |
---|
| 346 | READ_FLAG( uiCode, "lists_modification_present_flag"); |
---|
| 347 | pcPPS->setListsModificationPresentFlag(uiCode); |
---|
| 348 | |
---|
| 349 | READ_UVLC( uiCode, "log2_parallel_merge_level_minus2"); |
---|
| 350 | pcPPS->setLog2ParallelMergeLevelMinus2 (uiCode); |
---|
| 351 | |
---|
| 352 | READ_FLAG( uiCode, "slice_segment_header_extension_present_flag"); |
---|
| 353 | pcPPS->setSliceHeaderExtensionPresentFlag(uiCode); |
---|
| 354 | |
---|
| 355 | READ_FLAG( uiCode, "pps_extension_flag"); |
---|
| 356 | if (uiCode) |
---|
| 357 | { |
---|
| 358 | while ( xMoreRbspData() ) |
---|
| 359 | { |
---|
| 360 | READ_FLAG( uiCode, "pps_extension_data_flag"); |
---|
| 361 | } |
---|
| 362 | } |
---|
| 363 | } |
---|
| 364 | |
---|
| 365 | Void TDecCavlc::parseVUI(TComVUI* pcVUI, TComSPS *pcSPS) |
---|
| 366 | { |
---|
| 367 | #if ENC_DEC_TRACE |
---|
| 368 | fprintf( g_hTrace, "----------- vui_parameters -----------\n"); |
---|
| 369 | #endif |
---|
| 370 | UInt uiCode; |
---|
| 371 | |
---|
| 372 | READ_FLAG( uiCode, "aspect_ratio_info_present_flag"); pcVUI->setAspectRatioInfoPresentFlag(uiCode); |
---|
| 373 | if (pcVUI->getAspectRatioInfoPresentFlag()) |
---|
| 374 | { |
---|
| 375 | READ_CODE(8, uiCode, "aspect_ratio_idc"); pcVUI->setAspectRatioIdc(uiCode); |
---|
| 376 | if (pcVUI->getAspectRatioIdc() == 255) |
---|
| 377 | { |
---|
| 378 | READ_CODE(16, uiCode, "sar_width"); pcVUI->setSarWidth(uiCode); |
---|
| 379 | READ_CODE(16, uiCode, "sar_height"); pcVUI->setSarHeight(uiCode); |
---|
| 380 | } |
---|
| 381 | } |
---|
| 382 | |
---|
| 383 | READ_FLAG( uiCode, "overscan_info_present_flag"); pcVUI->setOverscanInfoPresentFlag(uiCode); |
---|
| 384 | if (pcVUI->getOverscanInfoPresentFlag()) |
---|
| 385 | { |
---|
| 386 | READ_FLAG( uiCode, "overscan_appropriate_flag"); pcVUI->setOverscanAppropriateFlag(uiCode); |
---|
| 387 | } |
---|
| 388 | |
---|
| 389 | READ_FLAG( uiCode, "video_signal_type_present_flag"); pcVUI->setVideoSignalTypePresentFlag(uiCode); |
---|
| 390 | if (pcVUI->getVideoSignalTypePresentFlag()) |
---|
| 391 | { |
---|
| 392 | READ_CODE(3, uiCode, "video_format"); pcVUI->setVideoFormat(uiCode); |
---|
| 393 | READ_FLAG( uiCode, "video_full_range_flag"); pcVUI->setVideoFullRangeFlag(uiCode); |
---|
| 394 | READ_FLAG( uiCode, "colour_description_present_flag"); pcVUI->setColourDescriptionPresentFlag(uiCode); |
---|
| 395 | if (pcVUI->getColourDescriptionPresentFlag()) |
---|
| 396 | { |
---|
| 397 | READ_CODE(8, uiCode, "colour_primaries"); pcVUI->setColourPrimaries(uiCode); |
---|
| 398 | READ_CODE(8, uiCode, "transfer_characteristics"); pcVUI->setTransferCharacteristics(uiCode); |
---|
| 399 | READ_CODE(8, uiCode, "matrix_coefficients"); pcVUI->setMatrixCoefficients(uiCode); |
---|
| 400 | } |
---|
| 401 | } |
---|
| 402 | |
---|
| 403 | READ_FLAG( uiCode, "chroma_loc_info_present_flag"); pcVUI->setChromaLocInfoPresentFlag(uiCode); |
---|
| 404 | if (pcVUI->getChromaLocInfoPresentFlag()) |
---|
| 405 | { |
---|
| 406 | READ_UVLC( uiCode, "chroma_sample_loc_type_top_field" ); pcVUI->setChromaSampleLocTypeTopField(uiCode); |
---|
| 407 | READ_UVLC( uiCode, "chroma_sample_loc_type_bottom_field" ); pcVUI->setChromaSampleLocTypeBottomField(uiCode); |
---|
| 408 | } |
---|
| 409 | |
---|
| 410 | READ_FLAG( uiCode, "neutral_chroma_indication_flag"); pcVUI->setNeutralChromaIndicationFlag(uiCode); |
---|
| 411 | |
---|
| 412 | READ_FLAG( uiCode, "field_seq_flag"); pcVUI->setFieldSeqFlag(uiCode); |
---|
| 413 | |
---|
| 414 | READ_FLAG(uiCode, "frame_field_info_present_flag"); pcVUI->setFrameFieldInfoPresentFlag(uiCode); |
---|
| 415 | |
---|
| 416 | READ_FLAG( uiCode, "default_display_window_flag"); |
---|
| 417 | if (uiCode != 0) |
---|
| 418 | { |
---|
| 419 | Window &defDisp = pcVUI->getDefaultDisplayWindow(); |
---|
| 420 | READ_UVLC( uiCode, "def_disp_win_left_offset" ); defDisp.setWindowLeftOffset ( uiCode * TComSPS::getWinUnitX( pcSPS->getChromaFormatIdc()) ); |
---|
| 421 | READ_UVLC( uiCode, "def_disp_win_right_offset" ); defDisp.setWindowRightOffset ( uiCode * TComSPS::getWinUnitX( pcSPS->getChromaFormatIdc()) ); |
---|
| 422 | READ_UVLC( uiCode, "def_disp_win_top_offset" ); defDisp.setWindowTopOffset ( uiCode * TComSPS::getWinUnitY( pcSPS->getChromaFormatIdc()) ); |
---|
| 423 | READ_UVLC( uiCode, "def_disp_win_bottom_offset" ); defDisp.setWindowBottomOffset( uiCode * TComSPS::getWinUnitY( pcSPS->getChromaFormatIdc()) ); |
---|
| 424 | } |
---|
| 425 | TimingInfo *timingInfo = pcVUI->getTimingInfo(); |
---|
| 426 | READ_FLAG( uiCode, "vui_timing_info_present_flag"); timingInfo->setTimingInfoPresentFlag (uiCode ? true : false); |
---|
[442] | 427 | #if TIMING_INFO_NONZERO_LAYERID_SPS |
---|
| 428 | if( pcSPS->getLayerId() > 0 ) |
---|
| 429 | { |
---|
| 430 | assert( timingInfo->getTimingInfoPresentFlag() == false ); |
---|
| 431 | } |
---|
| 432 | #endif |
---|
[313] | 433 | if(timingInfo->getTimingInfoPresentFlag()) |
---|
| 434 | { |
---|
| 435 | READ_CODE( 32, uiCode, "vui_num_units_in_tick"); timingInfo->setNumUnitsInTick (uiCode); |
---|
| 436 | READ_CODE( 32, uiCode, "vui_time_scale"); timingInfo->setTimeScale (uiCode); |
---|
| 437 | READ_FLAG( uiCode, "vui_poc_proportional_to_timing_flag"); timingInfo->setPocProportionalToTimingFlag(uiCode ? true : false); |
---|
| 438 | if(timingInfo->getPocProportionalToTimingFlag()) |
---|
| 439 | { |
---|
| 440 | READ_UVLC( uiCode, "vui_num_ticks_poc_diff_one_minus1"); timingInfo->setNumTicksPocDiffOneMinus1 (uiCode); |
---|
| 441 | } |
---|
| 442 | READ_FLAG( uiCode, "hrd_parameters_present_flag"); pcVUI->setHrdParametersPresentFlag(uiCode); |
---|
| 443 | if( pcVUI->getHrdParametersPresentFlag() ) |
---|
| 444 | { |
---|
| 445 | parseHrdParameters( pcVUI->getHrdParameters(), 1, pcSPS->getMaxTLayers() - 1 ); |
---|
| 446 | } |
---|
| 447 | } |
---|
| 448 | READ_FLAG( uiCode, "bitstream_restriction_flag"); pcVUI->setBitstreamRestrictionFlag(uiCode); |
---|
| 449 | if (pcVUI->getBitstreamRestrictionFlag()) |
---|
| 450 | { |
---|
| 451 | READ_FLAG( uiCode, "tiles_fixed_structure_flag"); pcVUI->setTilesFixedStructureFlag(uiCode); |
---|
| 452 | #if M0464_TILE_BOUNDARY_ALIGNED_FLAG |
---|
| 453 | if ( pcSPS->getLayerId() > 0 ) |
---|
| 454 | { |
---|
| 455 | READ_FLAG( uiCode, "tile_boundaries_aligned_flag" ); pcVUI->setTileBoundariesAlignedFlag( uiCode == 1 ); |
---|
| 456 | } |
---|
| 457 | #endif |
---|
| 458 | READ_FLAG( uiCode, "motion_vectors_over_pic_boundaries_flag"); pcVUI->setMotionVectorsOverPicBoundariesFlag(uiCode); |
---|
| 459 | READ_FLAG( uiCode, "restricted_ref_pic_lists_flag"); pcVUI->setRestrictedRefPicListsFlag(uiCode); |
---|
| 460 | READ_UVLC( uiCode, "min_spatial_segmentation_idc"); pcVUI->setMinSpatialSegmentationIdc(uiCode); |
---|
| 461 | assert(uiCode < 4096); |
---|
| 462 | READ_UVLC( uiCode, "max_bytes_per_pic_denom" ); pcVUI->setMaxBytesPerPicDenom(uiCode); |
---|
| 463 | READ_UVLC( uiCode, "max_bits_per_mincu_denom" ); pcVUI->setMaxBitsPerMinCuDenom(uiCode); |
---|
| 464 | READ_UVLC( uiCode, "log2_max_mv_length_horizontal" ); pcVUI->setLog2MaxMvLengthHorizontal(uiCode); |
---|
| 465 | READ_UVLC( uiCode, "log2_max_mv_length_vertical" ); pcVUI->setLog2MaxMvLengthVertical(uiCode); |
---|
| 466 | } |
---|
| 467 | } |
---|
| 468 | |
---|
| 469 | Void TDecCavlc::parseHrdParameters(TComHRD *hrd, Bool commonInfPresentFlag, UInt maxNumSubLayersMinus1) |
---|
| 470 | { |
---|
| 471 | UInt uiCode; |
---|
| 472 | if( commonInfPresentFlag ) |
---|
| 473 | { |
---|
| 474 | READ_FLAG( uiCode, "nal_hrd_parameters_present_flag" ); hrd->setNalHrdParametersPresentFlag( uiCode == 1 ? true : false ); |
---|
| 475 | READ_FLAG( uiCode, "vcl_hrd_parameters_present_flag" ); hrd->setVclHrdParametersPresentFlag( uiCode == 1 ? true : false ); |
---|
| 476 | if( hrd->getNalHrdParametersPresentFlag() || hrd->getVclHrdParametersPresentFlag() ) |
---|
| 477 | { |
---|
| 478 | READ_FLAG( uiCode, "sub_pic_cpb_params_present_flag" ); hrd->setSubPicCpbParamsPresentFlag( uiCode == 1 ? true : false ); |
---|
| 479 | if( hrd->getSubPicCpbParamsPresentFlag() ) |
---|
| 480 | { |
---|
| 481 | READ_CODE( 8, uiCode, "tick_divisor_minus2" ); hrd->setTickDivisorMinus2( uiCode ); |
---|
| 482 | READ_CODE( 5, uiCode, "du_cpb_removal_delay_length_minus1" ); hrd->setDuCpbRemovalDelayLengthMinus1( uiCode ); |
---|
| 483 | READ_FLAG( uiCode, "sub_pic_cpb_params_in_pic_timing_sei_flag" ); hrd->setSubPicCpbParamsInPicTimingSEIFlag( uiCode == 1 ? true : false ); |
---|
| 484 | READ_CODE( 5, uiCode, "dpb_output_delay_du_length_minus1" ); hrd->setDpbOutputDelayDuLengthMinus1( uiCode ); |
---|
| 485 | } |
---|
| 486 | READ_CODE( 4, uiCode, "bit_rate_scale" ); hrd->setBitRateScale( uiCode ); |
---|
| 487 | READ_CODE( 4, uiCode, "cpb_size_scale" ); hrd->setCpbSizeScale( uiCode ); |
---|
| 488 | if( hrd->getSubPicCpbParamsPresentFlag() ) |
---|
| 489 | { |
---|
| 490 | READ_CODE( 4, uiCode, "cpb_size_du_scale" ); hrd->setDuCpbSizeScale( uiCode ); |
---|
| 491 | } |
---|
| 492 | READ_CODE( 5, uiCode, "initial_cpb_removal_delay_length_minus1" ); hrd->setInitialCpbRemovalDelayLengthMinus1( uiCode ); |
---|
| 493 | READ_CODE( 5, uiCode, "au_cpb_removal_delay_length_minus1" ); hrd->setCpbRemovalDelayLengthMinus1( uiCode ); |
---|
| 494 | READ_CODE( 5, uiCode, "dpb_output_delay_length_minus1" ); hrd->setDpbOutputDelayLengthMinus1( uiCode ); |
---|
| 495 | } |
---|
| 496 | } |
---|
| 497 | Int i, j, nalOrVcl; |
---|
| 498 | for( i = 0; i <= maxNumSubLayersMinus1; i ++ ) |
---|
| 499 | { |
---|
| 500 | READ_FLAG( uiCode, "fixed_pic_rate_general_flag" ); hrd->setFixedPicRateFlag( i, uiCode == 1 ? true : false ); |
---|
| 501 | if( !hrd->getFixedPicRateFlag( i ) ) |
---|
| 502 | { |
---|
| 503 | READ_FLAG( uiCode, "fixed_pic_rate_within_cvs_flag" ); hrd->setFixedPicRateWithinCvsFlag( i, uiCode == 1 ? true : false ); |
---|
| 504 | } |
---|
| 505 | else |
---|
| 506 | { |
---|
| 507 | hrd->setFixedPicRateWithinCvsFlag( i, true ); |
---|
| 508 | } |
---|
| 509 | hrd->setLowDelayHrdFlag( i, 0 ); // Infered to be 0 when not present |
---|
| 510 | hrd->setCpbCntMinus1 ( i, 0 ); // Infered to be 0 when not present |
---|
| 511 | if( hrd->getFixedPicRateWithinCvsFlag( i ) ) |
---|
| 512 | { |
---|
| 513 | READ_UVLC( uiCode, "elemental_duration_in_tc_minus1" ); hrd->setPicDurationInTcMinus1( i, uiCode ); |
---|
| 514 | } |
---|
| 515 | else |
---|
| 516 | { |
---|
| 517 | READ_FLAG( uiCode, "low_delay_hrd_flag" ); hrd->setLowDelayHrdFlag( i, uiCode == 1 ? true : false ); |
---|
| 518 | } |
---|
| 519 | if (!hrd->getLowDelayHrdFlag( i )) |
---|
| 520 | { |
---|
| 521 | READ_UVLC( uiCode, "cpb_cnt_minus1" ); hrd->setCpbCntMinus1( i, uiCode ); |
---|
| 522 | } |
---|
| 523 | for( nalOrVcl = 0; nalOrVcl < 2; nalOrVcl ++ ) |
---|
| 524 | { |
---|
| 525 | if( ( ( nalOrVcl == 0 ) && ( hrd->getNalHrdParametersPresentFlag() ) ) || |
---|
| 526 | ( ( nalOrVcl == 1 ) && ( hrd->getVclHrdParametersPresentFlag() ) ) ) |
---|
| 527 | { |
---|
| 528 | for( j = 0; j <= ( hrd->getCpbCntMinus1( i ) ); j ++ ) |
---|
| 529 | { |
---|
| 530 | READ_UVLC( uiCode, "bit_rate_value_minus1" ); hrd->setBitRateValueMinus1( i, j, nalOrVcl, uiCode ); |
---|
| 531 | READ_UVLC( uiCode, "cpb_size_value_minus1" ); hrd->setCpbSizeValueMinus1( i, j, nalOrVcl, uiCode ); |
---|
| 532 | if( hrd->getSubPicCpbParamsPresentFlag() ) |
---|
| 533 | { |
---|
| 534 | READ_UVLC( uiCode, "cpb_size_du_value_minus1" ); hrd->setDuCpbSizeValueMinus1( i, j, nalOrVcl, uiCode ); |
---|
| 535 | READ_UVLC( uiCode, "bit_rate_du_value_minus1" ); hrd->setDuBitRateValueMinus1( i, j, nalOrVcl, uiCode ); |
---|
| 536 | } |
---|
| 537 | READ_FLAG( uiCode, "cbr_flag" ); hrd->setCbrFlag( i, j, nalOrVcl, uiCode == 1 ? true : false ); |
---|
| 538 | } |
---|
| 539 | } |
---|
| 540 | } |
---|
| 541 | } |
---|
| 542 | } |
---|
| 543 | |
---|
| 544 | #if SPS_SUB_LAYER_INFO |
---|
| 545 | Void TDecCavlc::parseSPS(TComSPS* pcSPS, ParameterSetManagerDecoder *parameterSetManager) |
---|
| 546 | #else |
---|
| 547 | Void TDecCavlc::parseSPS(TComSPS* pcSPS) |
---|
| 548 | #endif |
---|
| 549 | { |
---|
| 550 | #if ENC_DEC_TRACE |
---|
| 551 | xTraceSPSHeader (pcSPS); |
---|
| 552 | #endif |
---|
| 553 | |
---|
| 554 | UInt uiCode; |
---|
| 555 | READ_CODE( 4, uiCode, "sps_video_parameter_set_id"); pcSPS->setVPSId ( uiCode ); |
---|
| 556 | #if SPS_SUB_LAYER_INFO |
---|
| 557 | if(pcSPS->getLayerId() == 0) |
---|
| 558 | { |
---|
| 559 | #endif |
---|
| 560 | READ_CODE( 3, uiCode, "sps_max_sub_layers_minus1" ); pcSPS->setMaxTLayers ( uiCode+1 ); |
---|
| 561 | assert(uiCode <= 6); |
---|
| 562 | |
---|
| 563 | READ_FLAG( uiCode, "sps_temporal_id_nesting_flag" ); pcSPS->setTemporalIdNestingFlag ( uiCode > 0 ? true : false ); |
---|
| 564 | #if SPS_SUB_LAYER_INFO |
---|
| 565 | } |
---|
| 566 | else |
---|
| 567 | { |
---|
| 568 | pcSPS->setMaxTLayers ( parameterSetManager->getPrefetchedVPS(pcSPS->getVPSId())->getMaxTLayers() ); |
---|
| 569 | pcSPS->setTemporalIdNestingFlag( parameterSetManager->getPrefetchedVPS(pcSPS->getVPSId())->getTemporalNestingFlag() ); |
---|
| 570 | } |
---|
| 571 | #endif |
---|
[442] | 572 | #if IL_SL_SIGNALLING_N0371 |
---|
| 573 | pcSPS->setVPS( parameterSetManager->getPrefetchedVPS(pcSPS->getVPSId()) ); |
---|
| 574 | pcSPS->setSPS( pcSPS->getLayerId(), pcSPS ); |
---|
| 575 | #endif |
---|
[313] | 576 | if ( pcSPS->getMaxTLayers() == 1 ) |
---|
| 577 | { |
---|
| 578 | // sps_temporal_id_nesting_flag must be 1 when sps_max_sub_layers_minus1 is 0 |
---|
| 579 | #if SPS_SUB_LAYER_INFO |
---|
| 580 | assert( pcSPS->getTemporalIdNestingFlag() == true ); |
---|
| 581 | #else |
---|
| 582 | assert( uiCode == 1 ); |
---|
| 583 | #endif |
---|
| 584 | } |
---|
[442] | 585 | #ifdef SPS_PTL_FIX |
---|
| 586 | if ( pcSPS->getLayerId() == 0) |
---|
| 587 | { |
---|
| 588 | parsePTL(pcSPS->getPTL(), 1, pcSPS->getMaxTLayers() - 1); |
---|
| 589 | } |
---|
| 590 | #else |
---|
| 591 | parsePTL(pcSPS->getPTL(), 1, pcSPS->getMaxTLayers() - 1); |
---|
| 592 | #endif |
---|
[313] | 593 | |
---|
| 594 | READ_UVLC( uiCode, "sps_seq_parameter_set_id" ); pcSPS->setSPSId( uiCode ); |
---|
| 595 | assert(uiCode <= 15); |
---|
[442] | 596 | |
---|
| 597 | #if REPN_FORMAT_IN_VPS |
---|
| 598 | if( pcSPS->getLayerId() > 0 ) |
---|
[313] | 599 | { |
---|
[442] | 600 | READ_FLAG( uiCode, "update_rep_format_flag" ); |
---|
| 601 | pcSPS->setUpdateRepFormatFlag( uiCode ? true : false ); |
---|
[313] | 602 | } |
---|
[442] | 603 | else |
---|
| 604 | { |
---|
| 605 | pcSPS->setUpdateRepFormatFlag( true ); |
---|
| 606 | } |
---|
| 607 | if( pcSPS->getLayerId() == 0 || pcSPS->getUpdateRepFormatFlag() ) |
---|
| 608 | { |
---|
| 609 | #endif |
---|
| 610 | READ_UVLC( uiCode, "chroma_format_idc" ); pcSPS->setChromaFormatIdc( uiCode ); |
---|
| 611 | assert(uiCode <= 3); |
---|
| 612 | // in the first version we only support chroma_format_idc equal to 1 (4:2:0), so separate_colour_plane_flag cannot appear in the bitstream |
---|
| 613 | assert (uiCode == 1); |
---|
| 614 | if( uiCode == 3 ) |
---|
| 615 | { |
---|
| 616 | READ_FLAG( uiCode, "separate_colour_plane_flag"); assert(uiCode == 0); |
---|
| 617 | } |
---|
[313] | 618 | |
---|
[442] | 619 | READ_UVLC ( uiCode, "pic_width_in_luma_samples" ); pcSPS->setPicWidthInLumaSamples ( uiCode ); |
---|
| 620 | READ_UVLC ( uiCode, "pic_height_in_luma_samples" ); pcSPS->setPicHeightInLumaSamples( uiCode ); |
---|
| 621 | #if REPN_FORMAT_IN_VPS |
---|
| 622 | } |
---|
| 623 | #endif |
---|
[313] | 624 | READ_FLAG( uiCode, "conformance_window_flag"); |
---|
| 625 | if (uiCode != 0) |
---|
| 626 | { |
---|
| 627 | Window &conf = pcSPS->getConformanceWindow(); |
---|
[442] | 628 | #if REPN_FORMAT_IN_VPS |
---|
| 629 | READ_UVLC( uiCode, "conf_win_left_offset" ); conf.setWindowLeftOffset ( uiCode ); |
---|
| 630 | READ_UVLC( uiCode, "conf_win_right_offset" ); conf.setWindowRightOffset ( uiCode ); |
---|
| 631 | READ_UVLC( uiCode, "conf_win_top_offset" ); conf.setWindowTopOffset ( uiCode ); |
---|
| 632 | READ_UVLC( uiCode, "conf_win_bottom_offset" ); conf.setWindowBottomOffset( uiCode ); |
---|
| 633 | #else |
---|
[313] | 634 | READ_UVLC( uiCode, "conf_win_left_offset" ); conf.setWindowLeftOffset ( uiCode * TComSPS::getWinUnitX( pcSPS->getChromaFormatIdc() ) ); |
---|
| 635 | READ_UVLC( uiCode, "conf_win_right_offset" ); conf.setWindowRightOffset ( uiCode * TComSPS::getWinUnitX( pcSPS->getChromaFormatIdc() ) ); |
---|
| 636 | READ_UVLC( uiCode, "conf_win_top_offset" ); conf.setWindowTopOffset ( uiCode * TComSPS::getWinUnitY( pcSPS->getChromaFormatIdc() ) ); |
---|
| 637 | READ_UVLC( uiCode, "conf_win_bottom_offset" ); conf.setWindowBottomOffset( uiCode * TComSPS::getWinUnitY( pcSPS->getChromaFormatIdc() ) ); |
---|
[442] | 638 | #endif |
---|
[313] | 639 | } |
---|
[442] | 640 | #if REPN_FORMAT_IN_VPS |
---|
| 641 | if( pcSPS->getLayerId() == 0 || pcSPS->getUpdateRepFormatFlag() ) |
---|
| 642 | { |
---|
| 643 | #endif |
---|
| 644 | READ_UVLC( uiCode, "bit_depth_luma_minus8" ); |
---|
| 645 | assert(uiCode <= 6); |
---|
| 646 | pcSPS->setBitDepthY( uiCode + 8 ); |
---|
| 647 | pcSPS->setQpBDOffsetY( (Int) (6*uiCode) ); |
---|
[313] | 648 | |
---|
[442] | 649 | READ_UVLC( uiCode, "bit_depth_chroma_minus8" ); |
---|
| 650 | assert(uiCode <= 6); |
---|
| 651 | pcSPS->setBitDepthC( uiCode + 8 ); |
---|
| 652 | pcSPS->setQpBDOffsetC( (Int) (6*uiCode) ); |
---|
| 653 | #if REPN_FORMAT_IN_VPS |
---|
| 654 | } |
---|
| 655 | #endif |
---|
[313] | 656 | READ_UVLC( uiCode, "log2_max_pic_order_cnt_lsb_minus4" ); pcSPS->setBitsForPOC( 4 + uiCode ); |
---|
| 657 | assert(uiCode <= 12); |
---|
| 658 | |
---|
| 659 | UInt subLayerOrderingInfoPresentFlag; |
---|
| 660 | READ_FLAG(subLayerOrderingInfoPresentFlag, "sps_sub_layer_ordering_info_present_flag"); |
---|
| 661 | |
---|
| 662 | for(UInt i=0; i <= pcSPS->getMaxTLayers()-1; i++) |
---|
| 663 | { |
---|
| 664 | READ_UVLC ( uiCode, "sps_max_dec_pic_buffering_minus1"); |
---|
| 665 | pcSPS->setMaxDecPicBuffering( uiCode + 1, i); |
---|
| 666 | READ_UVLC ( uiCode, "sps_num_reorder_pics" ); |
---|
| 667 | pcSPS->setNumReorderPics(uiCode, i); |
---|
| 668 | READ_UVLC ( uiCode, "sps_max_latency_increase_plus1"); |
---|
| 669 | pcSPS->setMaxLatencyIncrease( uiCode, i ); |
---|
| 670 | |
---|
| 671 | if (!subLayerOrderingInfoPresentFlag) |
---|
| 672 | { |
---|
| 673 | for (i++; i <= pcSPS->getMaxTLayers()-1; i++) |
---|
| 674 | { |
---|
| 675 | pcSPS->setMaxDecPicBuffering(pcSPS->getMaxDecPicBuffering(0), i); |
---|
| 676 | pcSPS->setNumReorderPics(pcSPS->getNumReorderPics(0), i); |
---|
| 677 | pcSPS->setMaxLatencyIncrease(pcSPS->getMaxLatencyIncrease(0), i); |
---|
| 678 | } |
---|
| 679 | break; |
---|
| 680 | } |
---|
| 681 | } |
---|
| 682 | |
---|
| 683 | READ_UVLC( uiCode, "log2_min_coding_block_size_minus3" ); |
---|
| 684 | Int log2MinCUSize = uiCode + 3; |
---|
| 685 | pcSPS->setLog2MinCodingBlockSize(log2MinCUSize); |
---|
| 686 | READ_UVLC( uiCode, "log2_diff_max_min_coding_block_size" ); |
---|
| 687 | pcSPS->setLog2DiffMaxMinCodingBlockSize(uiCode); |
---|
| 688 | Int maxCUDepthDelta = uiCode; |
---|
| 689 | pcSPS->setMaxCUWidth ( 1<<(log2MinCUSize + maxCUDepthDelta) ); |
---|
| 690 | pcSPS->setMaxCUHeight ( 1<<(log2MinCUSize + maxCUDepthDelta) ); |
---|
| 691 | READ_UVLC( uiCode, "log2_min_transform_block_size_minus2" ); pcSPS->setQuadtreeTULog2MinSize( uiCode + 2 ); |
---|
| 692 | |
---|
| 693 | READ_UVLC( uiCode, "log2_diff_max_min_transform_block_size" ); pcSPS->setQuadtreeTULog2MaxSize( uiCode + pcSPS->getQuadtreeTULog2MinSize() ); |
---|
| 694 | pcSPS->setMaxTrSize( 1<<(uiCode + pcSPS->getQuadtreeTULog2MinSize()) ); |
---|
| 695 | |
---|
| 696 | READ_UVLC( uiCode, "max_transform_hierarchy_depth_inter" ); pcSPS->setQuadtreeTUMaxDepthInter( uiCode+1 ); |
---|
| 697 | READ_UVLC( uiCode, "max_transform_hierarchy_depth_intra" ); pcSPS->setQuadtreeTUMaxDepthIntra( uiCode+1 ); |
---|
| 698 | |
---|
| 699 | Int addCuDepth = max (0, log2MinCUSize - (Int)pcSPS->getQuadtreeTULog2MinSize() ); |
---|
| 700 | pcSPS->setMaxCUDepth( maxCUDepthDelta + addCuDepth ); |
---|
[442] | 701 | READ_FLAG( uiCode, "scaling_list_enabled_flag" ); pcSPS->setScalingListFlag ( uiCode ); |
---|
[313] | 702 | |
---|
| 703 | if(pcSPS->getScalingListFlag()) |
---|
| 704 | { |
---|
| 705 | READ_FLAG( uiCode, "sps_scaling_list_data_present_flag" ); pcSPS->setScalingListPresentFlag ( uiCode ); |
---|
| 706 | if(pcSPS->getScalingListPresentFlag ()) |
---|
| 707 | { |
---|
[442] | 708 | |
---|
| 709 | #if IL_SL_SIGNALLING_N0371 |
---|
| 710 | pcSPS->getScalingList()->setLayerId( pcSPS->getLayerId() ); |
---|
| 711 | |
---|
| 712 | if( pcSPS->getLayerId() > 0 ) |
---|
| 713 | { |
---|
| 714 | READ_FLAG( uiCode, "sps_pred_scaling_list_flag" ); pcSPS->setPredScalingListFlag ( uiCode ); |
---|
| 715 | pcSPS->getScalingList()->setPredScalingListFlag( pcSPS->getPredScalingListFlag() ); |
---|
| 716 | |
---|
| 717 | if( pcSPS->getPredScalingListFlag() ) |
---|
| 718 | { |
---|
| 719 | READ_UVLC( uiCode, "scaling_list_sps_ref_layer_id" ); pcSPS->setScalingListRefLayerId( uiCode ); |
---|
| 720 | |
---|
| 721 | // The value of sps_scaling_list_ref_layer_id shall be in the range of 0 to 62, inclusive |
---|
| 722 | assert( /*pcSPS->getScalingListRefLayerId() >= 0 &&*/ pcSPS->getScalingListRefLayerId() <= 62 ); |
---|
| 723 | |
---|
| 724 | // When avc_base_layer_flag is equal to 1, it is a requirement of bitstream conformance that the value of sps_scaling_list_ref_layer_id shall be greater than 0 |
---|
| 725 | if( pcSPS->getVPS()->getAvcBaseLayerFlag() ) |
---|
| 726 | { |
---|
| 727 | assert( pcSPS->getScalingListRefLayerId() > 0 ); |
---|
| 728 | } |
---|
| 729 | |
---|
| 730 | // It is a requirement of bitstream conformance that, when an SPS with nuh_layer_id equal to nuhLayerIdA is active for a layer with nuh_layer_id equal to nuhLayerIdB and |
---|
| 731 | // sps_infer_scaling_list_flag in the SPS is equal to 1, sps_infer_scaling_list_flag shall be equal to 0 for the SPS that is active for the layer with nuh_layer_id equal to sps_scaling_list_ref_layer_id |
---|
| 732 | assert( pcSPS->getSPS( pcSPS->getScalingListRefLayerId() )->getPredScalingListFlag() == false ); |
---|
| 733 | |
---|
| 734 | // It is a requirement of bitstream conformance that, when an SPS with nuh_layer_id equal to nuhLayerIdA is active for a layer with nuh_layer_id equal to nuhLayerIdB, |
---|
| 735 | // the layer with nuh_layer_id equal to sps_scaling_list_ref_layer_id shall be a direct or indirect reference layer of the layer with nuh_layer_id equal to nuhLayerIdB |
---|
| 736 | assert( pcSPS->getVPS()->getScalingListLayerDependency( pcSPS->getLayerId(), pcSPS->getScalingListRefLayerId() ) == true ); |
---|
| 737 | |
---|
| 738 | pcSPS->getScalingList()->setScalingListRefLayerId( pcSPS->getScalingListRefLayerId() ); |
---|
| 739 | parseScalingList( pcSPS->getScalingList() ); |
---|
| 740 | } |
---|
| 741 | else |
---|
| 742 | { |
---|
| 743 | parseScalingList( pcSPS->getScalingList() ); |
---|
| 744 | } |
---|
| 745 | } |
---|
| 746 | else |
---|
| 747 | { |
---|
| 748 | parseScalingList( pcSPS->getScalingList() ); |
---|
| 749 | } |
---|
| 750 | #else |
---|
[313] | 751 | parseScalingList( pcSPS->getScalingList() ); |
---|
[442] | 752 | #endif |
---|
| 753 | |
---|
[313] | 754 | } |
---|
| 755 | } |
---|
| 756 | READ_FLAG( uiCode, "amp_enabled_flag" ); pcSPS->setUseAMP( uiCode ); |
---|
| 757 | READ_FLAG( uiCode, "sample_adaptive_offset_enabled_flag" ); pcSPS->setUseSAO ( uiCode ? true : false ); |
---|
| 758 | |
---|
| 759 | READ_FLAG( uiCode, "pcm_enabled_flag" ); pcSPS->setUsePCM( uiCode ? true : false ); |
---|
| 760 | if( pcSPS->getUsePCM() ) |
---|
| 761 | { |
---|
| 762 | READ_CODE( 4, uiCode, "pcm_sample_bit_depth_luma_minus1" ); pcSPS->setPCMBitDepthLuma ( 1 + uiCode ); |
---|
| 763 | READ_CODE( 4, uiCode, "pcm_sample_bit_depth_chroma_minus1" ); pcSPS->setPCMBitDepthChroma ( 1 + uiCode ); |
---|
| 764 | READ_UVLC( uiCode, "log2_min_pcm_luma_coding_block_size_minus3" ); pcSPS->setPCMLog2MinSize (uiCode+3); |
---|
| 765 | READ_UVLC( uiCode, "log2_diff_max_min_pcm_luma_coding_block_size" ); pcSPS->setPCMLog2MaxSize ( uiCode+pcSPS->getPCMLog2MinSize() ); |
---|
| 766 | READ_FLAG( uiCode, "pcm_loop_filter_disable_flag" ); pcSPS->setPCMFilterDisableFlag ( uiCode ? true : false ); |
---|
| 767 | } |
---|
| 768 | |
---|
| 769 | READ_UVLC( uiCode, "num_short_term_ref_pic_sets" ); |
---|
| 770 | assert(uiCode <= 64); |
---|
| 771 | pcSPS->createRPSList(uiCode); |
---|
| 772 | |
---|
| 773 | TComRPSList* rpsList = pcSPS->getRPSList(); |
---|
| 774 | TComReferencePictureSet* rps; |
---|
| 775 | |
---|
| 776 | for(UInt i=0; i< rpsList->getNumberOfReferencePictureSets(); i++) |
---|
| 777 | { |
---|
| 778 | rps = rpsList->getReferencePictureSet(i); |
---|
| 779 | parseShortTermRefPicSet(pcSPS,rps,i); |
---|
| 780 | } |
---|
| 781 | READ_FLAG( uiCode, "long_term_ref_pics_present_flag" ); pcSPS->setLongTermRefsPresent(uiCode); |
---|
| 782 | if (pcSPS->getLongTermRefsPresent()) |
---|
| 783 | { |
---|
| 784 | READ_UVLC( uiCode, "num_long_term_ref_pic_sps" ); |
---|
| 785 | pcSPS->setNumLongTermRefPicSPS(uiCode); |
---|
| 786 | for (UInt k = 0; k < pcSPS->getNumLongTermRefPicSPS(); k++) |
---|
| 787 | { |
---|
| 788 | READ_CODE( pcSPS->getBitsForPOC(), uiCode, "lt_ref_pic_poc_lsb_sps" ); |
---|
| 789 | pcSPS->setLtRefPicPocLsbSps(k, uiCode); |
---|
| 790 | READ_FLAG( uiCode, "used_by_curr_pic_lt_sps_flag[i]"); |
---|
| 791 | pcSPS->setUsedByCurrPicLtSPSFlag(k, uiCode?1:0); |
---|
| 792 | } |
---|
| 793 | } |
---|
| 794 | READ_FLAG( uiCode, "sps_temporal_mvp_enable_flag" ); pcSPS->setTMVPFlagsPresent(uiCode); |
---|
| 795 | #if REF_IDX_MFM |
---|
| 796 | #if !M0457_COL_PICTURE_SIGNALING |
---|
| 797 | if(pcSPS->getLayerId() > 0) |
---|
| 798 | { |
---|
| 799 | READ_FLAG( uiCode, "sps_enh_mfm_enable_flag" ); |
---|
| 800 | pcSPS->setMFMEnabledFlag( uiCode ? true : false ); |
---|
| 801 | } |
---|
| 802 | #endif |
---|
| 803 | #endif |
---|
| 804 | READ_FLAG( uiCode, "sps_strong_intra_smoothing_enable_flag" ); pcSPS->setUseStrongIntraSmoothing(uiCode); |
---|
| 805 | |
---|
| 806 | READ_FLAG( uiCode, "vui_parameters_present_flag" ); pcSPS->setVuiParametersPresentFlag(uiCode); |
---|
| 807 | |
---|
| 808 | if (pcSPS->getVuiParametersPresentFlag()) |
---|
| 809 | { |
---|
| 810 | parseVUI(pcSPS->getVuiParameters(), pcSPS); |
---|
| 811 | } |
---|
| 812 | |
---|
| 813 | READ_FLAG( uiCode, "sps_extension_flag"); |
---|
| 814 | if (uiCode) |
---|
| 815 | { |
---|
| 816 | #if SPS_EXTENSION |
---|
| 817 | parseSPSExtension( pcSPS ); |
---|
| 818 | READ_FLAG( uiCode, "sps_extension2_flag"); |
---|
| 819 | if(uiCode) |
---|
| 820 | { |
---|
| 821 | #endif |
---|
| 822 | while ( xMoreRbspData() ) |
---|
| 823 | { |
---|
| 824 | READ_FLAG( uiCode, "sps_extension_data_flag"); |
---|
| 825 | } |
---|
| 826 | #if SPS_EXTENSION |
---|
| 827 | } |
---|
| 828 | #endif |
---|
| 829 | } |
---|
| 830 | } |
---|
| 831 | |
---|
| 832 | #if SPS_EXTENSION |
---|
| 833 | Void TDecCavlc::parseSPSExtension( TComSPS* pcSPS ) |
---|
| 834 | { |
---|
| 835 | UInt uiCode; |
---|
| 836 | // more syntax elements to be parsed here |
---|
[442] | 837 | |
---|
| 838 | #if VERT_MV_CONSTRAINT |
---|
| 839 | READ_FLAG( uiCode, "inter_view_mv_vert_constraint_flag" ); |
---|
| 840 | // Vertical MV component restriction is not used in SHVC CTC |
---|
| 841 | assert( uiCode == 0 ); |
---|
| 842 | #endif |
---|
[313] | 843 | #if SCALED_REF_LAYER_OFFSETS |
---|
| 844 | if( pcSPS->getLayerId() > 0 ) |
---|
| 845 | { |
---|
| 846 | Int iCode; |
---|
| 847 | READ_UVLC( uiCode, "num_scaled_ref_layer_offsets" ); pcSPS->setNumScaledRefLayerOffsets(uiCode); |
---|
| 848 | for(Int i = 0; i < pcSPS->getNumScaledRefLayerOffsets(); i++) |
---|
| 849 | { |
---|
| 850 | Window& scaledWindow = pcSPS->getScaledRefLayerWindow(i); |
---|
| 851 | READ_SVLC( iCode, "scaled_ref_layer_left_offset" ); scaledWindow.setWindowLeftOffset (iCode << 1); |
---|
| 852 | READ_SVLC( iCode, "scaled_ref_layer_top_offset" ); scaledWindow.setWindowTopOffset (iCode << 1); |
---|
| 853 | READ_SVLC( iCode, "scaled_ref_layer_right_offset" ); scaledWindow.setWindowRightOffset (iCode << 1); |
---|
| 854 | READ_SVLC( iCode, "scaled_ref_layer_bottom_offset" ); scaledWindow.setWindowBottomOffset(iCode << 1); |
---|
| 855 | } |
---|
| 856 | } |
---|
| 857 | #endif |
---|
| 858 | #if M0463_VUI_EXT_ILP_REF |
---|
| 859 | //// sps_extension_vui_parameters( ) |
---|
| 860 | if( pcSPS->getVuiParameters()->getBitstreamRestrictionFlag() ) |
---|
| 861 | { |
---|
| 862 | READ_UVLC( uiCode, "num_ilp_restricted_ref_layers" ); pcSPS->setNumIlpRestrictedRefLayers( uiCode ); |
---|
| 863 | for( Int i = 0; i < pcSPS->getNumIlpRestrictedRefLayers( ); i++ ) |
---|
| 864 | { |
---|
| 865 | READ_UVLC( uiCode, "min_spatial_segment_offset_plus1" ); pcSPS->setMinSpatialSegmentOffsetPlus1( i, uiCode ); |
---|
| 866 | if( pcSPS->getMinSpatialSegmentOffsetPlus1( i ) > 0 ) |
---|
| 867 | { |
---|
| 868 | READ_FLAG( uiCode, "ctu_based_offset_enabled_flag[ i ]"); pcSPS->setCtuBasedOffsetEnabledFlag(i, uiCode == 1 ); |
---|
| 869 | if( pcSPS->getCtuBasedOffsetEnabledFlag( i ) ) |
---|
| 870 | { |
---|
| 871 | READ_UVLC( uiCode, "min_horizontal_ctu_offset_plus1[ i ]"); pcSPS->setMinHorizontalCtuOffsetPlus1( i, uiCode ); |
---|
| 872 | } |
---|
| 873 | } |
---|
| 874 | } |
---|
| 875 | } |
---|
| 876 | //// sps_extension_vui_parameters( ) END |
---|
| 877 | #endif |
---|
| 878 | } |
---|
| 879 | #endif |
---|
| 880 | |
---|
| 881 | Void TDecCavlc::parseVPS(TComVPS* pcVPS) |
---|
| 882 | { |
---|
| 883 | UInt uiCode; |
---|
| 884 | |
---|
| 885 | READ_CODE( 4, uiCode, "vps_video_parameter_set_id" ); pcVPS->setVPSId( uiCode ); |
---|
| 886 | READ_CODE( 2, uiCode, "vps_reserved_three_2bits" ); assert(uiCode == 3); |
---|
| 887 | #if VPS_RENAME |
---|
| 888 | READ_CODE( 6, uiCode, "vps_max_layers_minus1" ); pcVPS->setMaxLayers( uiCode + 1); |
---|
| 889 | #else |
---|
| 890 | READ_CODE( 6, uiCode, "vps_reserved_zero_6bits" ); assert(uiCode == 0); |
---|
| 891 | #endif |
---|
| 892 | READ_CODE( 3, uiCode, "vps_max_sub_layers_minus1" ); pcVPS->setMaxTLayers( uiCode + 1 ); |
---|
| 893 | READ_FLAG( uiCode, "vps_temporal_id_nesting_flag" ); pcVPS->setTemporalNestingFlag( uiCode ? true:false ); |
---|
| 894 | assert (pcVPS->getMaxTLayers()>1||pcVPS->getTemporalNestingFlag()); |
---|
[442] | 895 | #if VPS_EXTN_OFFSET |
---|
| 896 | READ_CODE( 16, uiCode, "vps_extension_offset" ); pcVPS->setExtensionOffset( uiCode ); |
---|
| 897 | #else |
---|
[313] | 898 | READ_CODE( 16, uiCode, "vps_reserved_ffff_16bits" ); assert(uiCode == 0xffff); |
---|
[442] | 899 | #endif |
---|
[313] | 900 | parsePTL ( pcVPS->getPTL(), true, pcVPS->getMaxTLayers()-1); |
---|
| 901 | UInt subLayerOrderingInfoPresentFlag; |
---|
| 902 | READ_FLAG(subLayerOrderingInfoPresentFlag, "vps_sub_layer_ordering_info_present_flag"); |
---|
| 903 | for(UInt i = 0; i <= pcVPS->getMaxTLayers()-1; i++) |
---|
| 904 | { |
---|
| 905 | READ_UVLC( uiCode, "vps_max_dec_pic_buffering_minus1[i]" ); pcVPS->setMaxDecPicBuffering( uiCode + 1, i ); |
---|
| 906 | READ_UVLC( uiCode, "vps_num_reorder_pics[i]" ); pcVPS->setNumReorderPics( uiCode, i ); |
---|
| 907 | READ_UVLC( uiCode, "vps_max_latency_increase_plus1[i]" ); pcVPS->setMaxLatencyIncrease( uiCode, i ); |
---|
| 908 | |
---|
| 909 | if (!subLayerOrderingInfoPresentFlag) |
---|
| 910 | { |
---|
| 911 | for (i++; i <= pcVPS->getMaxTLayers()-1; i++) |
---|
| 912 | { |
---|
| 913 | pcVPS->setMaxDecPicBuffering(pcVPS->getMaxDecPicBuffering(0), i); |
---|
| 914 | pcVPS->setNumReorderPics(pcVPS->getNumReorderPics(0), i); |
---|
| 915 | pcVPS->setMaxLatencyIncrease(pcVPS->getMaxLatencyIncrease(0), i); |
---|
| 916 | } |
---|
| 917 | break; |
---|
| 918 | } |
---|
| 919 | } |
---|
| 920 | |
---|
| 921 | #if VPS_RENAME |
---|
| 922 | assert( pcVPS->getNumHrdParameters() < MAX_VPS_LAYER_SETS_PLUS1 ); |
---|
| 923 | assert( pcVPS->getMaxLayerId() < MAX_VPS_LAYER_ID_PLUS1 ); |
---|
| 924 | READ_CODE( 6, uiCode, "vps_max_layer_id" ); pcVPS->setMaxLayerId( uiCode ); |
---|
| 925 | READ_UVLC( uiCode, "vps_num_layer_sets_minus1" ); pcVPS->setNumLayerSets( uiCode + 1 ); |
---|
| 926 | for( UInt opsIdx = 1; opsIdx <= ( pcVPS->getNumLayerSets() - 1 ); opsIdx ++ ) |
---|
| 927 | { |
---|
| 928 | // Operation point set |
---|
| 929 | for( UInt i = 0; i <= pcVPS->getMaxLayerId(); i ++ ) |
---|
| 930 | #else |
---|
| 931 | assert( pcVPS->getNumHrdParameters() < MAX_VPS_OP_SETS_PLUS1 ); |
---|
| 932 | assert( pcVPS->getMaxNuhReservedZeroLayerId() < MAX_VPS_NUH_RESERVED_ZERO_LAYER_ID_PLUS1 ); |
---|
| 933 | READ_CODE( 6, uiCode, "vps_max_nuh_reserved_zero_layer_id" ); pcVPS->setMaxNuhReservedZeroLayerId( uiCode ); |
---|
| 934 | READ_UVLC( uiCode, "vps_max_op_sets_minus1" ); pcVPS->setMaxOpSets( uiCode + 1 ); |
---|
| 935 | for( UInt opsIdx = 1; opsIdx <= ( pcVPS->getMaxOpSets() - 1 ); opsIdx ++ ) |
---|
| 936 | { |
---|
| 937 | // Operation point set |
---|
| 938 | for( UInt i = 0; i <= pcVPS->getMaxNuhReservedZeroLayerId(); i ++ ) |
---|
| 939 | #endif |
---|
| 940 | { |
---|
| 941 | READ_FLAG( uiCode, "layer_id_included_flag[opsIdx][i]" ); pcVPS->setLayerIdIncludedFlag( uiCode == 1 ? true : false, opsIdx, i ); |
---|
| 942 | } |
---|
| 943 | } |
---|
| 944 | #if DERIVE_LAYER_ID_LIST_VARIABLES |
---|
| 945 | pcVPS->deriveLayerIdListVariables(); |
---|
| 946 | #endif |
---|
| 947 | TimingInfo *timingInfo = pcVPS->getTimingInfo(); |
---|
| 948 | READ_FLAG( uiCode, "vps_timing_info_present_flag"); timingInfo->setTimingInfoPresentFlag (uiCode ? true : false); |
---|
| 949 | if(timingInfo->getTimingInfoPresentFlag()) |
---|
| 950 | { |
---|
| 951 | READ_CODE( 32, uiCode, "vps_num_units_in_tick"); timingInfo->setNumUnitsInTick (uiCode); |
---|
| 952 | READ_CODE( 32, uiCode, "vps_time_scale"); timingInfo->setTimeScale (uiCode); |
---|
| 953 | READ_FLAG( uiCode, "vps_poc_proportional_to_timing_flag"); timingInfo->setPocProportionalToTimingFlag(uiCode ? true : false); |
---|
| 954 | if(timingInfo->getPocProportionalToTimingFlag()) |
---|
| 955 | { |
---|
| 956 | READ_UVLC( uiCode, "vps_num_ticks_poc_diff_one_minus1"); timingInfo->setNumTicksPocDiffOneMinus1 (uiCode); |
---|
| 957 | } |
---|
| 958 | READ_UVLC( uiCode, "vps_num_hrd_parameters" ); pcVPS->setNumHrdParameters( uiCode ); |
---|
| 959 | |
---|
| 960 | if( pcVPS->getNumHrdParameters() > 0 ) |
---|
| 961 | { |
---|
| 962 | pcVPS->createHrdParamBuffer(); |
---|
| 963 | } |
---|
| 964 | for( UInt i = 0; i < pcVPS->getNumHrdParameters(); i ++ ) |
---|
| 965 | { |
---|
| 966 | READ_UVLC( uiCode, "hrd_op_set_idx" ); pcVPS->setHrdOpSetIdx( uiCode, i ); |
---|
| 967 | if( i > 0 ) |
---|
| 968 | { |
---|
| 969 | READ_FLAG( uiCode, "cprms_present_flag[i]" ); pcVPS->setCprmsPresentFlag( uiCode == 1 ? true : false, i ); |
---|
| 970 | } |
---|
| 971 | parseHrdParameters(pcVPS->getHrdParameters(i), pcVPS->getCprmsPresentFlag( i ), pcVPS->getMaxTLayers() - 1); |
---|
| 972 | } |
---|
| 973 | } |
---|
| 974 | READ_FLAG( uiCode, "vps_extension_flag" ); |
---|
| 975 | if (uiCode) |
---|
| 976 | { |
---|
| 977 | #if VPS_EXTNS |
---|
[442] | 978 | while ( m_pcBitstream->getNumBitsRead() % 8 != 0 ) |
---|
| 979 | { |
---|
| 980 | READ_FLAG( uiCode, "vps_extension_alignment_bit_equal_to_one"); assert(uiCode == 1); |
---|
| 981 | } |
---|
[313] | 982 | parseVPSExtension(pcVPS); |
---|
| 983 | READ_FLAG( uiCode, "vps_entension2_flag" ); |
---|
| 984 | if(uiCode) |
---|
| 985 | { |
---|
| 986 | while ( xMoreRbspData() ) |
---|
| 987 | { |
---|
| 988 | READ_FLAG( uiCode, "vps_extension_data_flag"); |
---|
| 989 | } |
---|
| 990 | } |
---|
| 991 | #else |
---|
| 992 | while ( xMoreRbspData() ) |
---|
| 993 | { |
---|
| 994 | READ_FLAG( uiCode, "vps_extension_data_flag"); |
---|
| 995 | } |
---|
| 996 | #endif |
---|
| 997 | } |
---|
| 998 | |
---|
| 999 | return; |
---|
| 1000 | } |
---|
| 1001 | |
---|
| 1002 | #if VPS_EXTNS |
---|
| 1003 | Void TDecCavlc::parseVPSExtension(TComVPS *vps) |
---|
| 1004 | { |
---|
| 1005 | UInt uiCode; |
---|
| 1006 | // ... More syntax elements to be parsed here |
---|
| 1007 | #if VPS_EXTN_MASK_AND_DIM_INFO |
---|
| 1008 | UInt numScalabilityTypes = 0, i = 0, j = 0; |
---|
| 1009 | |
---|
| 1010 | READ_FLAG( uiCode, "avc_base_layer_flag" ); vps->setAvcBaseLayerFlag(uiCode ? true : false); |
---|
| 1011 | READ_FLAG( uiCode, "splitting_flag" ); vps->setSplittingFlag(uiCode ? true : false); |
---|
| 1012 | |
---|
| 1013 | for(i = 0; i < MAX_VPS_NUM_SCALABILITY_TYPES; i++) |
---|
| 1014 | { |
---|
| 1015 | READ_FLAG( uiCode, "scalability_mask[i]" ); vps->setScalabilityMask(i, uiCode ? true : false); |
---|
| 1016 | numScalabilityTypes += uiCode; |
---|
| 1017 | } |
---|
| 1018 | vps->setNumScalabilityTypes(numScalabilityTypes); |
---|
| 1019 | |
---|
| 1020 | #if VPS_SPLIT_FLAG |
---|
| 1021 | for(j = 0; j < numScalabilityTypes - vps->getSplittingFlag(); j++) |
---|
| 1022 | #else |
---|
| 1023 | for(j = 0; j < numScalabilityTypes; j++) |
---|
| 1024 | #endif |
---|
| 1025 | { |
---|
| 1026 | READ_CODE( 3, uiCode, "dimension_id_len_minus1[j]" ); vps->setDimensionIdLen(j, uiCode + 1); |
---|
| 1027 | } |
---|
| 1028 | #if VPS_SPLIT_FLAG |
---|
| 1029 | if(vps->getSplittingFlag()) |
---|
| 1030 | { |
---|
| 1031 | UInt numBits = 0; |
---|
| 1032 | for(j = 0; j < numScalabilityTypes - 1; j++) |
---|
| 1033 | { |
---|
| 1034 | numBits += vps->getDimensionIdLen(j); |
---|
| 1035 | } |
---|
| 1036 | assert( numBits < 6 ); |
---|
| 1037 | vps->setDimensionIdLen(numScalabilityTypes-1, 6 - numBits); |
---|
| 1038 | numBits = 6; |
---|
| 1039 | } |
---|
| 1040 | #else |
---|
| 1041 | if(vps->getSplittingFlag()) |
---|
| 1042 | { |
---|
| 1043 | UInt numBits = 0; |
---|
| 1044 | for(j = 0; j < numScalabilityTypes; j++) |
---|
| 1045 | { |
---|
| 1046 | numBits += vps->getDimensionIdLen(j); |
---|
| 1047 | } |
---|
| 1048 | assert( numBits <= 6 ); |
---|
| 1049 | } |
---|
| 1050 | #endif |
---|
| 1051 | |
---|
| 1052 | READ_FLAG( uiCode, "vps_nuh_layer_id_present_flag" ); vps->setNuhLayerIdPresentFlag(uiCode ? true : false); |
---|
| 1053 | vps->setLayerIdInNuh(0, 0); |
---|
| 1054 | vps->setLayerIdInVps(0, 0); |
---|
| 1055 | for(i = 1; i < vps->getMaxLayers(); i++) |
---|
| 1056 | { |
---|
| 1057 | if( vps->getNuhLayerIdPresentFlag() ) |
---|
| 1058 | { |
---|
| 1059 | READ_CODE( 6, uiCode, "layer_id_in_nuh[i]" ); vps->setLayerIdInNuh(i, uiCode); |
---|
| 1060 | assert( uiCode > vps->getLayerIdInNuh(i-1) ); |
---|
| 1061 | } |
---|
| 1062 | else |
---|
| 1063 | { |
---|
| 1064 | vps->setLayerIdInNuh(i, i); |
---|
| 1065 | } |
---|
| 1066 | vps->setLayerIdInVps(vps->getLayerIdInNuh(i), i); |
---|
| 1067 | |
---|
| 1068 | #if VPS_SPLIT_FLAG |
---|
| 1069 | if(!vps->getSplittingFlag()) |
---|
| 1070 | #endif |
---|
| 1071 | for(j = 0; j < numScalabilityTypes; j++) |
---|
| 1072 | { |
---|
| 1073 | READ_CODE( vps->getDimensionIdLen(j), uiCode, "dimension_id[i][j]" ); vps->setDimensionId(i, j, uiCode); |
---|
| 1074 | assert( uiCode <= vps->getMaxLayerId() ); |
---|
| 1075 | } |
---|
| 1076 | } |
---|
| 1077 | #endif |
---|
[442] | 1078 | #if VIEW_ID_RELATED_SIGNALING |
---|
| 1079 | // if ( pcVPS->getNumViews() > 1 ) |
---|
| 1080 | // However, this is a bug in the text since, view_id_len_minus1 is needed to parse view_id_val. |
---|
| 1081 | { |
---|
| 1082 | READ_CODE( 4, uiCode, "view_id_len_minus1" ); vps->setViewIdLenMinus1( uiCode ); |
---|
| 1083 | } |
---|
| 1084 | |
---|
| 1085 | for( i = 0; i < vps->getNumViews(); i++ ) |
---|
| 1086 | { |
---|
| 1087 | READ_CODE( vps->getViewIdLenMinus1( ) + 1, uiCode, "view_id_val[i]" ); vps->setViewIdVal( i, uiCode ); |
---|
| 1088 | } |
---|
| 1089 | #endif |
---|
[313] | 1090 | #if VPS_MOVE_DIR_DEPENDENCY_FLAG |
---|
| 1091 | #if VPS_EXTN_DIRECT_REF_LAYERS |
---|
| 1092 | // For layer 0 |
---|
| 1093 | vps->setNumDirectRefLayers(0, 0); |
---|
| 1094 | // For other layers |
---|
| 1095 | for( Int layerCtr = 1; layerCtr <= vps->getMaxLayers() - 1; layerCtr++) |
---|
| 1096 | { |
---|
| 1097 | UInt numDirectRefLayers = 0; |
---|
| 1098 | for( Int refLayerCtr = 0; refLayerCtr < layerCtr; refLayerCtr++) |
---|
| 1099 | { |
---|
| 1100 | READ_FLAG(uiCode, "direct_dependency_flag[i][j]" ); vps->setDirectDependencyFlag(layerCtr, refLayerCtr, uiCode? true : false); |
---|
| 1101 | if(uiCode) |
---|
| 1102 | { |
---|
| 1103 | vps->setRefLayerId(layerCtr, numDirectRefLayers, refLayerCtr); |
---|
| 1104 | numDirectRefLayers++; |
---|
| 1105 | } |
---|
| 1106 | } |
---|
| 1107 | vps->setNumDirectRefLayers(layerCtr, numDirectRefLayers); |
---|
| 1108 | } |
---|
| 1109 | #endif |
---|
| 1110 | #endif |
---|
| 1111 | #if JCTVC_M0203_INTERLAYER_PRED_IDC |
---|
[345] | 1112 | #if N0120_MAX_TID_REF_PRESENT_FLAG |
---|
[442] | 1113 | READ_FLAG( uiCode, "max_tid_ref_present_flag"); vps->setMaxTidRefPresentFlag(uiCode ? true : false); |
---|
| 1114 | if (vps->getMaxTidRefPresentFlag()) |
---|
[345] | 1115 | { |
---|
| 1116 | for(i = 0; i < vps->getMaxLayers() - 1; i++) |
---|
| 1117 | { |
---|
[442] | 1118 | READ_CODE( 3, uiCode, "max_tid_il_ref_pics_plus1[i]" ); vps->setMaxTidIlRefPicsPlus1(i, uiCode); |
---|
| 1119 | #if N0120_MAX_TID_REF_CFG |
---|
| 1120 | assert( uiCode <= vps->getMaxTLayers()); |
---|
| 1121 | #else |
---|
| 1122 | assert( uiCode <= vps->getMaxTLayers()+ 1 ); |
---|
| 1123 | #endif |
---|
[345] | 1124 | } |
---|
| 1125 | } |
---|
| 1126 | else |
---|
| 1127 | { |
---|
| 1128 | for(i = 0; i < vps->getMaxLayers() - 1; i++) |
---|
| 1129 | { |
---|
[442] | 1130 | vps->setMaxTidIlRefPicsPlus1(i, 7); |
---|
[345] | 1131 | } |
---|
| 1132 | } |
---|
| 1133 | #else |
---|
[313] | 1134 | for(i = 0; i < vps->getMaxLayers() - 1; i++) |
---|
| 1135 | { |
---|
[442] | 1136 | READ_CODE( 3, uiCode, "max_tid_il_ref_pics_plus1[i]" ); vps->setMaxTidIlRefPicsPlus1(i, uiCode); |
---|
[313] | 1137 | assert( uiCode <= vps->getMaxTLayers() ); |
---|
| 1138 | } |
---|
| 1139 | #endif |
---|
[345] | 1140 | #endif |
---|
| 1141 | #if ILP_SSH_SIG |
---|
| 1142 | READ_FLAG( uiCode, "all_ref_layers_active_flag" ); vps->setIlpSshSignalingEnabledFlag(uiCode ? true : false); |
---|
| 1143 | #endif |
---|
[313] | 1144 | #if VPS_EXTN_PROFILE_INFO |
---|
| 1145 | // Profile-tier-level signalling |
---|
| 1146 | #if VPS_PROFILE_OUTPUT_LAYERS |
---|
| 1147 | READ_CODE( 10, uiCode, "vps_number_layer_sets_minus1" ); assert( uiCode == (vps->getNumLayerSets() - 1) ); |
---|
| 1148 | READ_CODE( 6, uiCode, "vps_num_profile_tier_level_minus1"); vps->setNumProfileTierLevel( uiCode + 1 ); |
---|
| 1149 | vps->getPTLForExtnPtr()->resize(vps->getNumProfileTierLevel()); |
---|
| 1150 | for(Int idx = 1; idx <= vps->getNumProfileTierLevel() - 1; idx++) |
---|
| 1151 | #else |
---|
| 1152 | vps->getPTLForExtnPtr()->resize(vps->getNumLayerSets()); |
---|
| 1153 | for(Int idx = 1; idx <= vps->getNumLayerSets() - 1; idx++) |
---|
| 1154 | #endif |
---|
| 1155 | { |
---|
| 1156 | READ_FLAG( uiCode, "vps_profile_present_flag[i]" ); vps->setProfilePresentFlag(idx, uiCode ? true : false); |
---|
| 1157 | if( !vps->getProfilePresentFlag(idx) ) |
---|
| 1158 | { |
---|
| 1159 | #if VPS_PROFILE_OUTPUT_LAYERS |
---|
| 1160 | READ_CODE( 6, uiCode, "profile_ref_minus1[i]" ); vps->setProfileLayerSetRef(idx, uiCode + 1); |
---|
| 1161 | #else |
---|
| 1162 | READ_UVLC( uiCode, "vps_profile_layer_set_ref_minus1[i]" ); vps->setProfileLayerSetRef(idx, uiCode + 1); |
---|
| 1163 | #endif |
---|
| 1164 | assert( vps->getProfileLayerSetRef(idx) < idx ); |
---|
| 1165 | // Copy profile information as indicated |
---|
| 1166 | vps->getPTLForExtn(idx)->copyProfileInfo( vps->getPTLForExtn( vps->getProfileLayerSetRef(idx) ) ); |
---|
| 1167 | } |
---|
| 1168 | parsePTL( vps->getPTLForExtn(idx), vps->getProfilePresentFlag(idx), vps->getMaxTLayers() - 1 ); |
---|
| 1169 | } |
---|
| 1170 | #endif |
---|
| 1171 | |
---|
| 1172 | #if VPS_PROFILE_OUTPUT_LAYERS |
---|
| 1173 | READ_FLAG( uiCode, "more_output_layer_sets_than_default_flag" ); vps->setMoreOutputLayerSetsThanDefaultFlag( uiCode ? true : false ); |
---|
| 1174 | Int numOutputLayerSets = 0; |
---|
| 1175 | if(! vps->getMoreOutputLayerSetsThanDefaultFlag() ) |
---|
| 1176 | { |
---|
| 1177 | numOutputLayerSets = vps->getNumLayerSets(); |
---|
| 1178 | } |
---|
| 1179 | else |
---|
| 1180 | { |
---|
| 1181 | READ_CODE( 10, uiCode, "num_add_output_layer_sets" ); vps->setNumAddOutputLayerSets( uiCode ); |
---|
| 1182 | numOutputLayerSets = vps->getNumLayerSets() + vps->getNumAddOutputLayerSets(); |
---|
| 1183 | } |
---|
| 1184 | if( numOutputLayerSets > 1 ) |
---|
| 1185 | { |
---|
| 1186 | READ_FLAG( uiCode, "default_one_target_output_layer_flag" ); vps->setDefaultOneTargetOutputLayerFlag( uiCode ? true : false ); |
---|
| 1187 | } |
---|
| 1188 | vps->setNumOutputLayerSets( numOutputLayerSets ); |
---|
| 1189 | |
---|
| 1190 | for(i = 1; i < numOutputLayerSets; i++) |
---|
| 1191 | { |
---|
| 1192 | if( i > (vps->getNumLayerSets() - 1) ) |
---|
| 1193 | { |
---|
| 1194 | Int numBits = 1; |
---|
| 1195 | while ((1 << numBits) < (vps->getNumLayerSets() - 1)) |
---|
| 1196 | { |
---|
| 1197 | numBits++; |
---|
| 1198 | } |
---|
| 1199 | READ_CODE( numBits, uiCode, "output_layer_set_idx_minus1"); vps->setOutputLayerSetIdx( i, uiCode + 1); |
---|
| 1200 | Int lsIdx = vps->getOutputLayerSetIdx(i); |
---|
| 1201 | for(j = 0; j < vps->getNumLayersInIdList(lsIdx) - 1; j++) |
---|
| 1202 | { |
---|
| 1203 | READ_FLAG( uiCode, "output_layer_flag[i][j]"); vps->setOutputLayerFlag(i, j, uiCode); |
---|
| 1204 | } |
---|
| 1205 | } |
---|
| 1206 | else |
---|
| 1207 | { |
---|
| 1208 | // i <= (vps->getNumLayerSets() - 1) |
---|
| 1209 | // Assign OutputLayerFlag depending on default_one_target_output_layer_flag |
---|
| 1210 | Int lsIdx = i; |
---|
| 1211 | if( vps->getDefaultOneTargetOutputLayerFlag() ) |
---|
| 1212 | { |
---|
| 1213 | for(j = 0; j < vps->getNumLayersInIdList(lsIdx); j++) |
---|
| 1214 | { |
---|
| 1215 | vps->setOutputLayerFlag(i, j, (j == (vps->getNumLayersInIdList(lsIdx)-1))); |
---|
| 1216 | } |
---|
| 1217 | } |
---|
| 1218 | else |
---|
| 1219 | { |
---|
| 1220 | for(j = 0; j < vps->getNumLayersInIdList(lsIdx); j++) |
---|
| 1221 | { |
---|
| 1222 | vps->setOutputLayerFlag(i, j, 1); |
---|
| 1223 | } |
---|
| 1224 | } |
---|
| 1225 | } |
---|
| 1226 | Int numBits = 1; |
---|
| 1227 | while ((1 << numBits) < (vps->getNumProfileTierLevel())) |
---|
| 1228 | { |
---|
| 1229 | numBits++; |
---|
| 1230 | } |
---|
| 1231 | READ_CODE( numBits, uiCode, "profile_level_tier_idx[i]" ); vps->setProfileLevelTierIdx(i, uiCode); |
---|
| 1232 | } |
---|
| 1233 | #else |
---|
| 1234 | #if VPS_EXTN_OP_LAYER_SETS |
---|
| 1235 | // Target output layer signalling |
---|
| 1236 | READ_UVLC( uiCode, "vps_num_output_layer_sets"); vps->setNumOutputLayerSets(uiCode); |
---|
| 1237 | for(i = 0; i < vps->getNumOutputLayerSets(); i++) |
---|
| 1238 | { |
---|
| 1239 | #if VPS_OUTPUT_LAYER_SET_IDX |
---|
| 1240 | READ_UVLC( uiCode, "vps_output_layer_set_idx_minus1[i]"); vps->setOutputLayerSetIdx(i, uiCode + 1); |
---|
| 1241 | #else |
---|
| 1242 | READ_UVLC( uiCode, "vps_output_layer_set_idx[i]"); vps->setOutputLayerSetIdx(i, uiCode); |
---|
| 1243 | #endif |
---|
| 1244 | Int lsIdx = vps->getOutputLayerSetIdx(i); |
---|
| 1245 | for(j = 0; j <= vps->getMaxLayerId(); j++) |
---|
| 1246 | { |
---|
| 1247 | if(vps->getLayerIdIncludedFlag(lsIdx, j)) |
---|
| 1248 | { |
---|
| 1249 | READ_FLAG( uiCode, "vps_output_layer_flag[lsIdx][j]"); vps->setOutputLayerFlag(lsIdx, j, uiCode); |
---|
| 1250 | } |
---|
| 1251 | } |
---|
| 1252 | } |
---|
| 1253 | #endif |
---|
| 1254 | #endif |
---|
[442] | 1255 | #if REPN_FORMAT_IN_VPS |
---|
| 1256 | READ_FLAG( uiCode, "rep_format_idx_present_flag"); |
---|
| 1257 | vps->setRepFormatIdxPresentFlag( uiCode ? true : false ); |
---|
| 1258 | |
---|
| 1259 | if( vps->getRepFormatIdxPresentFlag() ) |
---|
| 1260 | { |
---|
| 1261 | READ_CODE( 4, uiCode, "vps_num_rep_formats_minus1" ); |
---|
| 1262 | vps->setVpsNumRepFormats( uiCode + 1 ); |
---|
| 1263 | } |
---|
| 1264 | else |
---|
| 1265 | { |
---|
| 1266 | // default assignment |
---|
| 1267 | assert (vps->getMaxLayers() <= 16); // If max_layers_is more than 15, num_rep_formats has to be signaled |
---|
| 1268 | vps->setVpsNumRepFormats( vps->getMaxLayers() ); |
---|
| 1269 | } |
---|
| 1270 | for(i = 0; i < vps->getVpsNumRepFormats(); i++) |
---|
| 1271 | { |
---|
| 1272 | // Read rep_format_structures |
---|
| 1273 | parseRepFormat( vps->getVpsRepFormat(i) ); |
---|
| 1274 | } |
---|
| 1275 | |
---|
| 1276 | // Default assignment for layer 0 |
---|
| 1277 | vps->setVpsRepFormatIdx( 0, 0 ); |
---|
| 1278 | if( vps->getRepFormatIdxPresentFlag() ) |
---|
| 1279 | { |
---|
| 1280 | for(i = 1; i < vps->getMaxLayers(); i++) |
---|
| 1281 | { |
---|
| 1282 | if( vps->getVpsNumRepFormats() > 1 ) |
---|
| 1283 | { |
---|
| 1284 | READ_CODE( 4, uiCode, "vps_rep_format_idx[i]" ); |
---|
| 1285 | vps->setVpsRepFormatIdx( i, uiCode ); |
---|
| 1286 | } |
---|
| 1287 | else |
---|
| 1288 | { |
---|
| 1289 | // default assignment - only one rep_format() structure |
---|
| 1290 | vps->setVpsRepFormatIdx( i, 0 ); |
---|
| 1291 | } |
---|
| 1292 | } |
---|
| 1293 | } |
---|
| 1294 | else |
---|
| 1295 | { |
---|
| 1296 | // default assignment - each layer assigned each rep_format() structure in the order signaled |
---|
| 1297 | for(i = 1; i < vps->getMaxLayers(); i++) |
---|
| 1298 | { |
---|
| 1299 | vps->setVpsRepFormatIdx( i, i ); |
---|
| 1300 | } |
---|
| 1301 | } |
---|
| 1302 | #endif |
---|
[313] | 1303 | #if JCTVC_M0458_INTERLAYER_RPS_SIG |
---|
[442] | 1304 | READ_FLAG(uiCode, "max_one_active_ref_layer_flag" ); |
---|
| 1305 | vps->setMaxOneActiveRefLayerFlag(uiCode); |
---|
[313] | 1306 | #endif |
---|
| 1307 | |
---|
[442] | 1308 | #if N0147_IRAP_ALIGN_FLAG |
---|
| 1309 | READ_FLAG(uiCode, "cross_layer_irap_aligned_flag" ); |
---|
| 1310 | vps->setCrossLayerIrapAlignFlag(uiCode); |
---|
| 1311 | #endif |
---|
| 1312 | |
---|
[313] | 1313 | #if !VPS_MOVE_DIR_DEPENDENCY_FLAG |
---|
| 1314 | #if VPS_EXTN_DIRECT_REF_LAYERS |
---|
| 1315 | // For layer 0 |
---|
| 1316 | vps->setNumDirectRefLayers(0, 0); |
---|
| 1317 | // For other layers |
---|
| 1318 | for( Int layerCtr = 1; layerCtr <= vps->getMaxLayers() - 1; layerCtr++) |
---|
| 1319 | { |
---|
| 1320 | UInt numDirectRefLayers = 0; |
---|
| 1321 | for( Int refLayerCtr = 0; refLayerCtr < layerCtr; refLayerCtr++) |
---|
| 1322 | { |
---|
| 1323 | READ_FLAG(uiCode, "direct_dependency_flag[i][j]" ); vps->setDirectDependencyFlag(layerCtr, refLayerCtr, uiCode? true : false); |
---|
| 1324 | if(uiCode) |
---|
| 1325 | { |
---|
| 1326 | vps->setRefLayerId(layerCtr, numDirectRefLayers, refLayerCtr); |
---|
| 1327 | numDirectRefLayers++; |
---|
| 1328 | } |
---|
| 1329 | } |
---|
| 1330 | vps->setNumDirectRefLayers(layerCtr, numDirectRefLayers); |
---|
| 1331 | } |
---|
| 1332 | #endif |
---|
| 1333 | #endif |
---|
| 1334 | #if VPS_EXTN_DIRECT_REF_LAYERS && M0457_PREDICTION_INDICATIONS |
---|
| 1335 | READ_UVLC( uiCode, "direct_dep_type_len_minus2"); vps->setDirectDepTypeLen(uiCode+2); |
---|
| 1336 | for(i = 1; i < vps->getMaxLayers(); i++) |
---|
| 1337 | { |
---|
| 1338 | for(j = 0; j < i; j++) |
---|
| 1339 | { |
---|
| 1340 | if (vps->getDirectDependencyFlag(i, j)) |
---|
| 1341 | { |
---|
| 1342 | READ_CODE( vps->getDirectDepTypeLen(), uiCode, "direct_dependency_type[i][j]" ); vps->setDirectDependencyType(i, j, uiCode); |
---|
| 1343 | } |
---|
| 1344 | } |
---|
| 1345 | } |
---|
[442] | 1346 | |
---|
[313] | 1347 | #endif |
---|
[442] | 1348 | |
---|
| 1349 | #if IL_SL_SIGNALLING_N0371 |
---|
| 1350 | for(i = 1; i < vps->getMaxLayers(); i++) |
---|
| 1351 | { |
---|
| 1352 | for(j = 0; j < i; j++) |
---|
| 1353 | { |
---|
| 1354 | vps->setScalingListLayerDependency( i, j, vps->checkLayerDependency( i,j ) ); |
---|
| 1355 | } |
---|
| 1356 | } |
---|
| 1357 | #endif |
---|
| 1358 | |
---|
[313] | 1359 | #if M0040_ADAPTIVE_RESOLUTION_CHANGE |
---|
| 1360 | READ_FLAG(uiCode, "single_layer_for_non_irap_flag" ); vps->setSingleLayerForNonIrapFlag(uiCode == 1 ? true : false); |
---|
| 1361 | #endif |
---|
[442] | 1362 | |
---|
| 1363 | READ_FLAG( uiCode, "vps_vui_present_flag" ); |
---|
| 1364 | if (uiCode) |
---|
| 1365 | { |
---|
| 1366 | #if VPS_VUI |
---|
| 1367 | while ( m_pcBitstream->getNumBitsRead() % 8 != 0 ) |
---|
| 1368 | { |
---|
| 1369 | READ_FLAG( uiCode, "vps_vui_alignment_bit_equal_to_one"); assert(uiCode == 1); |
---|
| 1370 | } |
---|
| 1371 | parseVPSVUI(vps); |
---|
| 1372 | #endif |
---|
| 1373 | } |
---|
[313] | 1374 | } |
---|
| 1375 | #endif |
---|
[442] | 1376 | #if REPN_FORMAT_IN_VPS |
---|
| 1377 | Void TDecCavlc::parseRepFormat ( RepFormat *repFormat ) |
---|
| 1378 | { |
---|
| 1379 | UInt uiCode; |
---|
| 1380 | READ_CODE( 2, uiCode, "chroma_format_idc" ); repFormat->setChromaFormatVpsIdc( uiCode ); |
---|
| 1381 | |
---|
| 1382 | if( repFormat->getChromaFormatVpsIdc() == 3 ) |
---|
| 1383 | { |
---|
| 1384 | READ_FLAG( uiCode, "separate_colour_plane_flag"); repFormat->setSeparateColourPlaneVpsFlag(uiCode ? true : false); |
---|
| 1385 | } |
---|
[313] | 1386 | |
---|
[442] | 1387 | READ_CODE ( 16, uiCode, "pic_width_in_luma_samples" ); repFormat->setPicWidthVpsInLumaSamples ( uiCode ); |
---|
| 1388 | READ_CODE ( 16, uiCode, "pic_height_in_luma_samples" ); repFormat->setPicHeightVpsInLumaSamples( uiCode ); |
---|
| 1389 | |
---|
| 1390 | READ_CODE( 4, uiCode, "bit_depth_luma_minus8" ); repFormat->setBitDepthVpsLuma ( uiCode + 8 ); |
---|
| 1391 | READ_CODE( 4, uiCode, "bit_depth_chroma_minus8" ); repFormat->setBitDepthVpsChroma( uiCode + 8 ); |
---|
| 1392 | |
---|
| 1393 | } |
---|
| 1394 | #endif |
---|
| 1395 | #if VPS_VUI |
---|
| 1396 | Void TDecCavlc::parseVPSVUI(TComVPS *vps) |
---|
| 1397 | { |
---|
| 1398 | UInt i,j; |
---|
| 1399 | UInt uiCode; |
---|
| 1400 | #if VPS_VUI_BITRATE_PICRATE |
---|
| 1401 | READ_FLAG( uiCode, "bit_rate_present_vps_flag" ); vps->setBitRatePresentVpsFlag( uiCode ? true : false ); |
---|
| 1402 | READ_FLAG( uiCode, "pic_rate_present_vps_flag" ); vps->setPicRatePresentVpsFlag( uiCode ? true : false ); |
---|
| 1403 | |
---|
| 1404 | Bool parseFlag = vps->getBitRatePresentVpsFlag() || vps->getPicRatePresentVpsFlag(); |
---|
| 1405 | { |
---|
| 1406 | for( i = 0; i < vps->getNumLayerSets(); i++ ) |
---|
| 1407 | { |
---|
| 1408 | for( j = 0; j < vps->getMaxTLayers(); j++ ) |
---|
| 1409 | { |
---|
| 1410 | if( parseFlag && vps->getBitRatePresentVpsFlag() ) |
---|
| 1411 | { |
---|
| 1412 | READ_FLAG( uiCode, "bit_rate_present_vps_flag[i][j]" ); vps->setBitRatePresentFlag( i, j, uiCode ? true : false ); |
---|
| 1413 | } |
---|
| 1414 | else |
---|
| 1415 | { |
---|
| 1416 | vps->setBitRatePresentFlag( i, j, false ); |
---|
| 1417 | } |
---|
| 1418 | if( parseFlag && vps->getPicRatePresentVpsFlag() ) |
---|
| 1419 | { |
---|
| 1420 | READ_FLAG( uiCode, "pic_rate_present_vps_flag[i][j]" ); vps->setPicRatePresentFlag( i, j, uiCode ? true : false ); |
---|
| 1421 | } |
---|
| 1422 | else |
---|
| 1423 | { |
---|
| 1424 | vps->setPicRatePresentFlag( i, j, false ); |
---|
| 1425 | } |
---|
| 1426 | if( parseFlag && vps->getBitRatePresentFlag(i, j) ) |
---|
| 1427 | { |
---|
| 1428 | READ_CODE( 16, uiCode, "avg_bit_rate[i][j]" ); vps->setAvgBitRate( i, j, uiCode ); |
---|
| 1429 | READ_CODE( 16, uiCode, "max_bit_rate[i][j]" ); vps->setMaxBitRate( i, j, uiCode ); |
---|
| 1430 | } |
---|
| 1431 | else |
---|
| 1432 | { |
---|
| 1433 | vps->setAvgBitRate( i, j, 0 ); |
---|
| 1434 | vps->setMaxBitRate( i, j, 0 ); |
---|
| 1435 | } |
---|
| 1436 | if( parseFlag && vps->getPicRatePresentFlag(i, j) ) |
---|
| 1437 | { |
---|
| 1438 | READ_CODE( 2 , uiCode, "constant_pic_rate_idc[i][j]" ); vps->setConstPicRateIdc( i, j, uiCode ); |
---|
| 1439 | READ_CODE( 16, uiCode, "avg_pic_rate[i][j]" ); vps->setAvgPicRate( i, j, uiCode ); |
---|
| 1440 | } |
---|
| 1441 | else |
---|
| 1442 | { |
---|
| 1443 | vps->setConstPicRateIdc( i, j, 0 ); |
---|
| 1444 | vps->setAvgPicRate ( i, j, 0 ); |
---|
| 1445 | } |
---|
| 1446 | } |
---|
| 1447 | } |
---|
| 1448 | } |
---|
| 1449 | #endif |
---|
| 1450 | #if TILE_BOUNDARY_ALIGNED_FLAG |
---|
| 1451 | for(i = 1; i < vps->getMaxLayers(); i++) |
---|
| 1452 | { |
---|
| 1453 | for(j = 0; j < vps->getNumDirectRefLayers(vps->getLayerIdInNuh(i)); j++) |
---|
| 1454 | { |
---|
| 1455 | READ_FLAG( uiCode, "tile_boundaries_aligned_flag[i][j]" ); vps->setTileBoundariesAlignedFlag(i,j,(uiCode == 1)); |
---|
| 1456 | } |
---|
| 1457 | } |
---|
| 1458 | #endif |
---|
| 1459 | #if N0160_VUI_EXT_ILP_REF |
---|
| 1460 | READ_FLAG( uiCode, "num_ilp_restricted_ref_layers" ); vps->setNumIlpRestrictedRefLayers( uiCode == 1 ); |
---|
| 1461 | if( vps->getNumIlpRestrictedRefLayers()) |
---|
| 1462 | { |
---|
| 1463 | for(i = 1; i < vps->getMaxLayers(); i++) |
---|
| 1464 | { |
---|
| 1465 | for(j = 0; j < vps->getNumDirectRefLayers(vps->getLayerIdInNuh(i)); j++) |
---|
| 1466 | { |
---|
| 1467 | READ_UVLC( uiCode, "min_spatial_segment_offset_plus1[i][j]" ); vps->setMinSpatialSegmentOffsetPlus1( i, j, uiCode ); |
---|
| 1468 | if( vps->getMinSpatialSegmentOffsetPlus1(i,j ) > 0 ) |
---|
| 1469 | { |
---|
| 1470 | READ_FLAG( uiCode, "ctu_based_offset_enabled_flag[i][j]"); vps->setCtuBasedOffsetEnabledFlag(i, j, uiCode == 1 ); |
---|
| 1471 | if(vps->getCtuBasedOffsetEnabledFlag(i,j)) |
---|
| 1472 | { |
---|
| 1473 | READ_UVLC( uiCode, "min_horizontal_ctu_offset_plus1[i][j]"); vps->setMinHorizontalCtuOffsetPlus1( i,j, uiCode ); |
---|
| 1474 | } |
---|
| 1475 | } |
---|
| 1476 | } |
---|
| 1477 | } |
---|
| 1478 | } |
---|
| 1479 | #endif |
---|
| 1480 | } |
---|
| 1481 | #endif |
---|
[313] | 1482 | Void TDecCavlc::parseSliceHeader (TComSlice*& rpcSlice, ParameterSetManagerDecoder *parameterSetManager) |
---|
| 1483 | { |
---|
| 1484 | UInt uiCode; |
---|
| 1485 | Int iCode; |
---|
| 1486 | |
---|
| 1487 | #if ENC_DEC_TRACE |
---|
| 1488 | xTraceSliceHeader(rpcSlice); |
---|
| 1489 | #endif |
---|
| 1490 | TComPPS* pps = NULL; |
---|
| 1491 | TComSPS* sps = NULL; |
---|
| 1492 | |
---|
| 1493 | UInt firstSliceSegmentInPic; |
---|
| 1494 | READ_FLAG( firstSliceSegmentInPic, "first_slice_segment_in_pic_flag" ); |
---|
| 1495 | if( rpcSlice->getRapPicFlag()) |
---|
| 1496 | { |
---|
| 1497 | READ_FLAG( uiCode, "no_output_of_prior_pics_flag" ); //ignored |
---|
| 1498 | } |
---|
| 1499 | READ_UVLC ( uiCode, "slice_pic_parameter_set_id" ); rpcSlice->setPPSId(uiCode); |
---|
| 1500 | pps = parameterSetManager->getPrefetchedPPS(uiCode); |
---|
| 1501 | //!KS: need to add error handling code here, if PPS is not available |
---|
| 1502 | assert(pps!=0); |
---|
| 1503 | sps = parameterSetManager->getPrefetchedSPS(pps->getSPSId()); |
---|
| 1504 | //!KS: need to add error handling code here, if SPS is not available |
---|
| 1505 | assert(sps!=0); |
---|
| 1506 | rpcSlice->setSPS(sps); |
---|
| 1507 | rpcSlice->setPPS(pps); |
---|
| 1508 | if( pps->getDependentSliceSegmentsEnabledFlag() && ( !firstSliceSegmentInPic )) |
---|
| 1509 | { |
---|
| 1510 | READ_FLAG( uiCode, "dependent_slice_segment_flag" ); rpcSlice->setDependentSliceSegmentFlag(uiCode ? true : false); |
---|
| 1511 | } |
---|
| 1512 | else |
---|
| 1513 | { |
---|
| 1514 | rpcSlice->setDependentSliceSegmentFlag(false); |
---|
| 1515 | } |
---|
[442] | 1516 | #if REPN_FORMAT_IN_VPS |
---|
| 1517 | Int numCTUs = ((rpcSlice->getPicWidthInLumaSamples()+sps->getMaxCUWidth()-1)/sps->getMaxCUWidth())*((rpcSlice->getPicHeightInLumaSamples()+sps->getMaxCUHeight()-1)/sps->getMaxCUHeight()); |
---|
| 1518 | #else |
---|
[313] | 1519 | Int numCTUs = ((sps->getPicWidthInLumaSamples()+sps->getMaxCUWidth()-1)/sps->getMaxCUWidth())*((sps->getPicHeightInLumaSamples()+sps->getMaxCUHeight()-1)/sps->getMaxCUHeight()); |
---|
[442] | 1520 | #endif |
---|
[313] | 1521 | Int maxParts = (1<<(sps->getMaxCUDepth()<<1)); |
---|
| 1522 | UInt sliceSegmentAddress = 0; |
---|
| 1523 | Int bitsSliceSegmentAddress = 0; |
---|
| 1524 | while(numCTUs>(1<<bitsSliceSegmentAddress)) |
---|
| 1525 | { |
---|
| 1526 | bitsSliceSegmentAddress++; |
---|
| 1527 | } |
---|
| 1528 | |
---|
| 1529 | if(!firstSliceSegmentInPic) |
---|
| 1530 | { |
---|
| 1531 | READ_CODE( bitsSliceSegmentAddress, sliceSegmentAddress, "slice_segment_address" ); |
---|
| 1532 | } |
---|
| 1533 | //set uiCode to equal slice start address (or dependent slice start address) |
---|
| 1534 | Int startCuAddress = maxParts*sliceSegmentAddress; |
---|
| 1535 | rpcSlice->setSliceSegmentCurStartCUAddr( startCuAddress ); |
---|
| 1536 | rpcSlice->setSliceSegmentCurEndCUAddr(numCTUs*maxParts); |
---|
| 1537 | |
---|
| 1538 | if (rpcSlice->getDependentSliceSegmentFlag()) |
---|
| 1539 | { |
---|
| 1540 | rpcSlice->setNextSlice ( false ); |
---|
| 1541 | rpcSlice->setNextSliceSegment ( true ); |
---|
| 1542 | } |
---|
| 1543 | else |
---|
| 1544 | { |
---|
| 1545 | rpcSlice->setNextSlice ( true ); |
---|
| 1546 | rpcSlice->setNextSliceSegment ( false ); |
---|
| 1547 | |
---|
| 1548 | rpcSlice->setSliceCurStartCUAddr(startCuAddress); |
---|
| 1549 | rpcSlice->setSliceCurEndCUAddr(numCTUs*maxParts); |
---|
| 1550 | } |
---|
| 1551 | |
---|
| 1552 | if(!rpcSlice->getDependentSliceSegmentFlag()) |
---|
| 1553 | { |
---|
[442] | 1554 | #if POC_RESET_FLAG |
---|
| 1555 | Int iBits = 0; |
---|
| 1556 | if(rpcSlice->getPPS()->getNumExtraSliceHeaderBits() > iBits) |
---|
| 1557 | { |
---|
| 1558 | READ_FLAG(uiCode, "poc_reset_flag"); rpcSlice->setPocResetFlag( uiCode ? true : false ); |
---|
| 1559 | iBits++; |
---|
| 1560 | } |
---|
| 1561 | if(rpcSlice->getPPS()->getNumExtraSliceHeaderBits() > iBits) |
---|
| 1562 | { |
---|
| 1563 | READ_FLAG(uiCode, "discardable_flag"); // ignored |
---|
| 1564 | iBits++; |
---|
| 1565 | } |
---|
| 1566 | for (; iBits < rpcSlice->getPPS()->getNumExtraSliceHeaderBits(); iBits++) |
---|
| 1567 | { |
---|
| 1568 | READ_FLAG(uiCode, "slice_reserved_undetermined_flag[]"); // ignored |
---|
| 1569 | } |
---|
| 1570 | #else |
---|
[313] | 1571 | #if SH_DISCARDABLE_FLAG |
---|
| 1572 | if(rpcSlice->getPPS()->getNumExtraSliceHeaderBits()>0) |
---|
| 1573 | { |
---|
| 1574 | READ_FLAG(uiCode, "discardable_flag"); // ignored |
---|
| 1575 | } |
---|
| 1576 | for (Int i = 1; i < rpcSlice->getPPS()->getNumExtraSliceHeaderBits(); i++) |
---|
| 1577 | { |
---|
| 1578 | READ_FLAG(uiCode, "slice_reserved_undetermined_flag[]"); // ignored |
---|
| 1579 | } |
---|
| 1580 | #else |
---|
| 1581 | for (Int i = 0; i < rpcSlice->getPPS()->getNumExtraSliceHeaderBits(); i++) |
---|
| 1582 | { |
---|
| 1583 | READ_FLAG(uiCode, "slice_reserved_undetermined_flag[]"); // ignored |
---|
| 1584 | } |
---|
| 1585 | #endif |
---|
[442] | 1586 | #endif |
---|
[313] | 1587 | |
---|
| 1588 | READ_UVLC ( uiCode, "slice_type" ); rpcSlice->setSliceType((SliceType)uiCode); |
---|
| 1589 | if( pps->getOutputFlagPresentFlag() ) |
---|
| 1590 | { |
---|
| 1591 | READ_FLAG( uiCode, "pic_output_flag" ); rpcSlice->setPicOutputFlag( uiCode ? true : false ); |
---|
| 1592 | } |
---|
| 1593 | else |
---|
| 1594 | { |
---|
| 1595 | rpcSlice->setPicOutputFlag( true ); |
---|
| 1596 | } |
---|
| 1597 | // in the first version chroma_format_idc is equal to one, thus colour_plane_id will not be present |
---|
| 1598 | assert (sps->getChromaFormatIdc() == 1 ); |
---|
| 1599 | // if( separate_colour_plane_flag == 1 ) |
---|
| 1600 | // colour_plane_id u(2) |
---|
| 1601 | |
---|
| 1602 | if( rpcSlice->getIdrPicFlag() ) |
---|
| 1603 | { |
---|
| 1604 | rpcSlice->setPOC(0); |
---|
| 1605 | TComReferencePictureSet* rps = rpcSlice->getLocalRPS(); |
---|
| 1606 | rps->setNumberOfNegativePictures(0); |
---|
| 1607 | rps->setNumberOfPositivePictures(0); |
---|
| 1608 | rps->setNumberOfLongtermPictures(0); |
---|
| 1609 | rps->setNumberOfPictures(0); |
---|
| 1610 | rpcSlice->setRPS(rps); |
---|
| 1611 | } |
---|
[442] | 1612 | #if N0065_LAYER_POC_ALIGNMENT |
---|
| 1613 | if( rpcSlice->getLayerId() > 0 || !rpcSlice->getIdrPicFlag() ) |
---|
| 1614 | #else |
---|
[313] | 1615 | else |
---|
[442] | 1616 | #endif |
---|
[313] | 1617 | { |
---|
| 1618 | READ_CODE(sps->getBitsForPOC(), uiCode, "pic_order_cnt_lsb"); |
---|
| 1619 | Int iPOClsb = uiCode; |
---|
[442] | 1620 | Int iPrevPOC = rpcSlice->getPrevTid0POC(); |
---|
[313] | 1621 | Int iMaxPOClsb = 1<< sps->getBitsForPOC(); |
---|
[442] | 1622 | Int iPrevPOClsb = iPrevPOC & (iMaxPOClsb - 1); |
---|
[313] | 1623 | Int iPrevPOCmsb = iPrevPOC-iPrevPOClsb; |
---|
| 1624 | Int iPOCmsb; |
---|
| 1625 | if( ( iPOClsb < iPrevPOClsb ) && ( ( iPrevPOClsb - iPOClsb ) >= ( iMaxPOClsb / 2 ) ) ) |
---|
| 1626 | { |
---|
| 1627 | iPOCmsb = iPrevPOCmsb + iMaxPOClsb; |
---|
| 1628 | } |
---|
| 1629 | else if( (iPOClsb > iPrevPOClsb ) && ( (iPOClsb - iPrevPOClsb ) > ( iMaxPOClsb / 2 ) ) ) |
---|
| 1630 | { |
---|
| 1631 | iPOCmsb = iPrevPOCmsb - iMaxPOClsb; |
---|
| 1632 | } |
---|
| 1633 | else |
---|
| 1634 | { |
---|
| 1635 | iPOCmsb = iPrevPOCmsb; |
---|
| 1636 | } |
---|
| 1637 | if ( rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP |
---|
| 1638 | || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL |
---|
| 1639 | || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP ) |
---|
| 1640 | { |
---|
| 1641 | // For BLA picture types, POCmsb is set to 0. |
---|
| 1642 | iPOCmsb = 0; |
---|
| 1643 | } |
---|
| 1644 | rpcSlice->setPOC (iPOCmsb+iPOClsb); |
---|
| 1645 | |
---|
[442] | 1646 | #if N0065_LAYER_POC_ALIGNMENT |
---|
| 1647 | if( !rpcSlice->getIdrPicFlag() ) |
---|
| 1648 | { |
---|
| 1649 | #endif |
---|
[313] | 1650 | TComReferencePictureSet* rps; |
---|
| 1651 | rps = rpcSlice->getLocalRPS(); |
---|
| 1652 | rpcSlice->setRPS(rps); |
---|
| 1653 | READ_FLAG( uiCode, "short_term_ref_pic_set_sps_flag" ); |
---|
| 1654 | if(uiCode == 0) // use short-term reference picture set explicitly signalled in slice header |
---|
| 1655 | { |
---|
| 1656 | parseShortTermRefPicSet(sps,rps, sps->getRPSList()->getNumberOfReferencePictureSets()); |
---|
| 1657 | } |
---|
| 1658 | else // use reference to short-term reference picture set in PPS |
---|
| 1659 | { |
---|
| 1660 | Int numBits = 0; |
---|
| 1661 | while ((1 << numBits) < rpcSlice->getSPS()->getRPSList()->getNumberOfReferencePictureSets()) |
---|
| 1662 | { |
---|
| 1663 | numBits++; |
---|
| 1664 | } |
---|
| 1665 | if (numBits > 0) |
---|
| 1666 | { |
---|
| 1667 | READ_CODE( numBits, uiCode, "short_term_ref_pic_set_idx"); |
---|
| 1668 | } |
---|
| 1669 | else |
---|
| 1670 | { |
---|
| 1671 | uiCode = 0; |
---|
| 1672 | } |
---|
| 1673 | *rps = *(sps->getRPSList()->getReferencePictureSet(uiCode)); |
---|
| 1674 | } |
---|
| 1675 | if(sps->getLongTermRefsPresent()) |
---|
| 1676 | { |
---|
| 1677 | Int offset = rps->getNumberOfNegativePictures()+rps->getNumberOfPositivePictures(); |
---|
| 1678 | UInt numOfLtrp = 0; |
---|
| 1679 | UInt numLtrpInSPS = 0; |
---|
| 1680 | if (rpcSlice->getSPS()->getNumLongTermRefPicSPS() > 0) |
---|
| 1681 | { |
---|
| 1682 | READ_UVLC( uiCode, "num_long_term_sps"); |
---|
| 1683 | numLtrpInSPS = uiCode; |
---|
| 1684 | numOfLtrp += numLtrpInSPS; |
---|
| 1685 | rps->setNumberOfLongtermPictures(numOfLtrp); |
---|
| 1686 | } |
---|
| 1687 | Int bitsForLtrpInSPS = 0; |
---|
| 1688 | while (rpcSlice->getSPS()->getNumLongTermRefPicSPS() > (1 << bitsForLtrpInSPS)) |
---|
| 1689 | { |
---|
| 1690 | bitsForLtrpInSPS++; |
---|
| 1691 | } |
---|
| 1692 | READ_UVLC( uiCode, "num_long_term_pics"); rps->setNumberOfLongtermPictures(uiCode); |
---|
| 1693 | numOfLtrp += uiCode; |
---|
| 1694 | rps->setNumberOfLongtermPictures(numOfLtrp); |
---|
| 1695 | Int maxPicOrderCntLSB = 1 << rpcSlice->getSPS()->getBitsForPOC(); |
---|
| 1696 | Int prevDeltaMSB = 0, deltaPocMSBCycleLT = 0;; |
---|
| 1697 | for(Int j=offset+rps->getNumberOfLongtermPictures()-1, k = 0; k < numOfLtrp; j--, k++) |
---|
| 1698 | { |
---|
| 1699 | Int pocLsbLt; |
---|
| 1700 | if (k < numLtrpInSPS) |
---|
| 1701 | { |
---|
| 1702 | uiCode = 0; |
---|
| 1703 | if (bitsForLtrpInSPS > 0) |
---|
| 1704 | { |
---|
| 1705 | READ_CODE(bitsForLtrpInSPS, uiCode, "lt_idx_sps[i]"); |
---|
| 1706 | } |
---|
| 1707 | Int usedByCurrFromSPS=rpcSlice->getSPS()->getUsedByCurrPicLtSPSFlag(uiCode); |
---|
| 1708 | |
---|
| 1709 | pocLsbLt = rpcSlice->getSPS()->getLtRefPicPocLsbSps(uiCode); |
---|
| 1710 | rps->setUsed(j,usedByCurrFromSPS); |
---|
| 1711 | } |
---|
| 1712 | else |
---|
| 1713 | { |
---|
| 1714 | READ_CODE(rpcSlice->getSPS()->getBitsForPOC(), uiCode, "poc_lsb_lt"); pocLsbLt= uiCode; |
---|
| 1715 | READ_FLAG( uiCode, "used_by_curr_pic_lt_flag"); rps->setUsed(j,uiCode); |
---|
| 1716 | } |
---|
| 1717 | READ_FLAG(uiCode,"delta_poc_msb_present_flag"); |
---|
| 1718 | Bool mSBPresentFlag = uiCode ? true : false; |
---|
| 1719 | if(mSBPresentFlag) |
---|
| 1720 | { |
---|
| 1721 | READ_UVLC( uiCode, "delta_poc_msb_cycle_lt[i]" ); |
---|
| 1722 | Bool deltaFlag = false; |
---|
| 1723 | // First LTRP || First LTRP from SH |
---|
| 1724 | if( (j == offset+rps->getNumberOfLongtermPictures()-1) || (j == offset+(numOfLtrp-numLtrpInSPS)-1) ) |
---|
| 1725 | { |
---|
| 1726 | deltaFlag = true; |
---|
| 1727 | } |
---|
| 1728 | if(deltaFlag) |
---|
| 1729 | { |
---|
| 1730 | deltaPocMSBCycleLT = uiCode; |
---|
| 1731 | } |
---|
| 1732 | else |
---|
| 1733 | { |
---|
| 1734 | deltaPocMSBCycleLT = uiCode + prevDeltaMSB; |
---|
| 1735 | } |
---|
| 1736 | |
---|
| 1737 | Int pocLTCurr = rpcSlice->getPOC() - deltaPocMSBCycleLT * maxPicOrderCntLSB |
---|
| 1738 | - iPOClsb + pocLsbLt; |
---|
| 1739 | rps->setPOC (j, pocLTCurr); |
---|
| 1740 | rps->setDeltaPOC(j, - rpcSlice->getPOC() + pocLTCurr); |
---|
| 1741 | rps->setCheckLTMSBPresent(j,true); |
---|
| 1742 | } |
---|
| 1743 | else |
---|
| 1744 | { |
---|
| 1745 | rps->setPOC (j, pocLsbLt); |
---|
| 1746 | rps->setDeltaPOC(j, - rpcSlice->getPOC() + pocLsbLt); |
---|
| 1747 | rps->setCheckLTMSBPresent(j,false); |
---|
[442] | 1748 | |
---|
| 1749 | // reset deltaPocMSBCycleLT for first LTRP from slice header if MSB not present |
---|
| 1750 | if( j == offset+(numOfLtrp-numLtrpInSPS)-1 ) |
---|
| 1751 | { |
---|
| 1752 | deltaPocMSBCycleLT = 0; |
---|
| 1753 | } |
---|
[313] | 1754 | } |
---|
| 1755 | prevDeltaMSB = deltaPocMSBCycleLT; |
---|
| 1756 | } |
---|
| 1757 | offset += rps->getNumberOfLongtermPictures(); |
---|
| 1758 | rps->setNumberOfPictures(offset); |
---|
| 1759 | } |
---|
| 1760 | if ( rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP |
---|
| 1761 | || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL |
---|
| 1762 | || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP ) |
---|
| 1763 | { |
---|
| 1764 | // In the case of BLA picture types, rps data is read from slice header but ignored |
---|
| 1765 | rps = rpcSlice->getLocalRPS(); |
---|
| 1766 | rps->setNumberOfNegativePictures(0); |
---|
| 1767 | rps->setNumberOfPositivePictures(0); |
---|
| 1768 | rps->setNumberOfLongtermPictures(0); |
---|
| 1769 | rps->setNumberOfPictures(0); |
---|
| 1770 | rpcSlice->setRPS(rps); |
---|
| 1771 | } |
---|
| 1772 | if (rpcSlice->getSPS()->getTMVPFlagsPresent()) |
---|
| 1773 | { |
---|
| 1774 | READ_FLAG( uiCode, "slice_temporal_mvp_enable_flag" ); |
---|
| 1775 | rpcSlice->setEnableTMVPFlag( uiCode == 1 ? true : false ); |
---|
| 1776 | } |
---|
| 1777 | else |
---|
| 1778 | { |
---|
| 1779 | rpcSlice->setEnableTMVPFlag(false); |
---|
| 1780 | } |
---|
[442] | 1781 | #if N0065_LAYER_POC_ALIGNMENT |
---|
[313] | 1782 | } |
---|
[442] | 1783 | #endif |
---|
| 1784 | } |
---|
[313] | 1785 | |
---|
[442] | 1786 | #if SVC_EXTENSION |
---|
[313] | 1787 | #if JCTVC_M0458_INTERLAYER_RPS_SIG |
---|
| 1788 | rpcSlice->setActiveNumILRRefIdx(0); |
---|
[345] | 1789 | #if ILP_SSH_SIG |
---|
| 1790 | if((sps->getLayerId() > 0) && rpcSlice->getVPS()->getIlpSshSignalingEnabledFlag() && (rpcSlice->getNumILRRefIdx() > 0) ) |
---|
| 1791 | #else |
---|
[313] | 1792 | if((sps->getLayerId() > 0) && (rpcSlice->getNumILRRefIdx() > 0) ) |
---|
[345] | 1793 | #endif |
---|
[313] | 1794 | { |
---|
| 1795 | READ_FLAG(uiCode,"inter_layer_pred_enabled_flag"); |
---|
| 1796 | rpcSlice->setInterLayerPredEnabledFlag(uiCode); |
---|
| 1797 | if( rpcSlice->getInterLayerPredEnabledFlag()) |
---|
| 1798 | { |
---|
| 1799 | if(rpcSlice->getNumILRRefIdx() > 1) |
---|
| 1800 | { |
---|
| 1801 | Int numBits = 1; |
---|
| 1802 | while ((1 << numBits) < rpcSlice->getNumILRRefIdx()) |
---|
| 1803 | { |
---|
| 1804 | numBits++; |
---|
| 1805 | } |
---|
| 1806 | if( !rpcSlice->getVPS()->getMaxOneActiveRefLayerFlag()) |
---|
| 1807 | { |
---|
| 1808 | READ_CODE( numBits, uiCode,"num_inter_layer_ref_pics_minus1" ); |
---|
| 1809 | rpcSlice->setActiveNumILRRefIdx(uiCode + 1); |
---|
| 1810 | } |
---|
| 1811 | else |
---|
| 1812 | { |
---|
| 1813 | rpcSlice->setActiveNumILRRefIdx(1); |
---|
| 1814 | } |
---|
[345] | 1815 | #if ILP_NUM_REF_CHK |
---|
| 1816 | if( rpcSlice->getActiveNumILRRefIdx() == rpcSlice->getNumILRRefIdx() ) |
---|
| 1817 | { |
---|
| 1818 | for( Int i = 0; i < rpcSlice->getActiveNumILRRefIdx(); i++ ) |
---|
| 1819 | { |
---|
| 1820 | rpcSlice->setInterLayerPredLayerIdc(i,i); |
---|
| 1821 | } |
---|
| 1822 | } |
---|
| 1823 | else |
---|
| 1824 | { |
---|
| 1825 | #endif |
---|
[313] | 1826 | for(Int i = 0; i < rpcSlice->getActiveNumILRRefIdx(); i++ ) |
---|
| 1827 | { |
---|
| 1828 | READ_CODE( numBits,uiCode,"inter_layer_pred_layer_idc[i]" ); |
---|
| 1829 | rpcSlice->setInterLayerPredLayerIdc(uiCode,i); |
---|
| 1830 | } |
---|
[345] | 1831 | #if ILP_NUM_REF_CHK |
---|
| 1832 | } |
---|
| 1833 | #endif |
---|
[313] | 1834 | } |
---|
| 1835 | else |
---|
| 1836 | { |
---|
| 1837 | rpcSlice->setActiveNumILRRefIdx(1); |
---|
| 1838 | rpcSlice->setInterLayerPredLayerIdc(0,0); |
---|
| 1839 | } |
---|
| 1840 | } |
---|
| 1841 | } |
---|
[345] | 1842 | #if ILP_SSH_SIG |
---|
| 1843 | else if( rpcSlice->getVPS()->getIlpSshSignalingEnabledFlag() == false ) |
---|
| 1844 | { |
---|
| 1845 | rpcSlice->setInterLayerPredEnabledFlag(true); |
---|
| 1846 | rpcSlice->setActiveNumILRRefIdx(rpcSlice->getNumILRRefIdx()); |
---|
| 1847 | for( Int i = 0; i < rpcSlice->getActiveNumILRRefIdx(); i++ ) |
---|
| 1848 | { |
---|
| 1849 | rpcSlice->setInterLayerPredLayerIdc(i,i); |
---|
| 1850 | } |
---|
| 1851 | } |
---|
| 1852 | #endif |
---|
[313] | 1853 | #if M0457_IL_SAMPLE_PRED_ONLY_FLAG |
---|
| 1854 | rpcSlice->setInterLayerSamplePredOnlyFlag( false ); |
---|
| 1855 | if( rpcSlice->getNumSamplePredRefLayers() > 0 && rpcSlice->getActiveNumILRRefIdx() > 0 ) |
---|
| 1856 | { |
---|
| 1857 | READ_FLAG( uiCode, "inter_layer_sample_pred_only_flag" ); |
---|
| 1858 | rpcSlice->setInterLayerSamplePredOnlyFlag( uiCode > 0 ); |
---|
| 1859 | } |
---|
| 1860 | #endif |
---|
| 1861 | #else |
---|
| 1862 | if( rpcSlice->getLayerId() > 0 ) |
---|
| 1863 | { |
---|
| 1864 | rpcSlice->setNumILRRefIdx( rpcSlice->getVPS()->getNumDirectRefLayers( rpcSlice->getLayerId() ) ); |
---|
| 1865 | } |
---|
| 1866 | #endif |
---|
| 1867 | #endif |
---|
| 1868 | |
---|
| 1869 | if(sps->getUseSAO()) |
---|
| 1870 | { |
---|
| 1871 | READ_FLAG(uiCode, "slice_sao_luma_flag"); rpcSlice->setSaoEnabledFlag((Bool)uiCode); |
---|
| 1872 | READ_FLAG(uiCode, "slice_sao_chroma_flag"); rpcSlice->setSaoEnabledFlagChroma((Bool)uiCode); |
---|
| 1873 | } |
---|
| 1874 | |
---|
| 1875 | if (rpcSlice->getIdrPicFlag()) |
---|
| 1876 | { |
---|
| 1877 | rpcSlice->setEnableTMVPFlag(false); |
---|
| 1878 | } |
---|
| 1879 | if (!rpcSlice->isIntra()) |
---|
| 1880 | { |
---|
| 1881 | |
---|
| 1882 | READ_FLAG( uiCode, "num_ref_idx_active_override_flag"); |
---|
| 1883 | if (uiCode) |
---|
| 1884 | { |
---|
| 1885 | READ_UVLC (uiCode, "num_ref_idx_l0_active_minus1" ); rpcSlice->setNumRefIdx( REF_PIC_LIST_0, uiCode + 1 ); |
---|
| 1886 | if (rpcSlice->isInterB()) |
---|
| 1887 | { |
---|
| 1888 | READ_UVLC (uiCode, "num_ref_idx_l1_active_minus1" ); rpcSlice->setNumRefIdx( REF_PIC_LIST_1, uiCode + 1 ); |
---|
| 1889 | } |
---|
| 1890 | else |
---|
| 1891 | { |
---|
| 1892 | rpcSlice->setNumRefIdx(REF_PIC_LIST_1, 0); |
---|
| 1893 | } |
---|
| 1894 | } |
---|
| 1895 | else |
---|
| 1896 | { |
---|
| 1897 | rpcSlice->setNumRefIdx(REF_PIC_LIST_0, rpcSlice->getPPS()->getNumRefIdxL0DefaultActive()); |
---|
| 1898 | if (rpcSlice->isInterB()) |
---|
| 1899 | { |
---|
| 1900 | rpcSlice->setNumRefIdx(REF_PIC_LIST_1, rpcSlice->getPPS()->getNumRefIdxL1DefaultActive()); |
---|
| 1901 | } |
---|
| 1902 | else |
---|
| 1903 | { |
---|
| 1904 | rpcSlice->setNumRefIdx(REF_PIC_LIST_1,0); |
---|
| 1905 | } |
---|
| 1906 | } |
---|
| 1907 | } |
---|
| 1908 | // } |
---|
| 1909 | TComRefPicListModification* refPicListModification = rpcSlice->getRefPicListModification(); |
---|
| 1910 | if(!rpcSlice->isIntra()) |
---|
| 1911 | { |
---|
| 1912 | if( !rpcSlice->getPPS()->getListsModificationPresentFlag() || rpcSlice->getNumRpsCurrTempList() <= 1 ) |
---|
| 1913 | { |
---|
| 1914 | refPicListModification->setRefPicListModificationFlagL0( 0 ); |
---|
| 1915 | } |
---|
| 1916 | else |
---|
| 1917 | { |
---|
| 1918 | READ_FLAG( uiCode, "ref_pic_list_modification_flag_l0" ); refPicListModification->setRefPicListModificationFlagL0( uiCode ? 1 : 0 ); |
---|
| 1919 | } |
---|
| 1920 | |
---|
| 1921 | if(refPicListModification->getRefPicListModificationFlagL0()) |
---|
| 1922 | { |
---|
| 1923 | uiCode = 0; |
---|
| 1924 | Int i = 0; |
---|
| 1925 | Int numRpsCurrTempList0 = rpcSlice->getNumRpsCurrTempList(); |
---|
| 1926 | if ( numRpsCurrTempList0 > 1 ) |
---|
| 1927 | { |
---|
| 1928 | Int length = 1; |
---|
| 1929 | numRpsCurrTempList0 --; |
---|
| 1930 | while ( numRpsCurrTempList0 >>= 1) |
---|
| 1931 | { |
---|
| 1932 | length ++; |
---|
| 1933 | } |
---|
| 1934 | for (i = 0; i < rpcSlice->getNumRefIdx(REF_PIC_LIST_0); i ++) |
---|
| 1935 | { |
---|
| 1936 | READ_CODE( length, uiCode, "list_entry_l0" ); |
---|
| 1937 | refPicListModification->setRefPicSetIdxL0(i, uiCode ); |
---|
| 1938 | } |
---|
| 1939 | } |
---|
| 1940 | else |
---|
| 1941 | { |
---|
| 1942 | for (i = 0; i < rpcSlice->getNumRefIdx(REF_PIC_LIST_0); i ++) |
---|
| 1943 | { |
---|
| 1944 | refPicListModification->setRefPicSetIdxL0(i, 0 ); |
---|
| 1945 | } |
---|
| 1946 | } |
---|
| 1947 | } |
---|
| 1948 | } |
---|
| 1949 | else |
---|
| 1950 | { |
---|
| 1951 | refPicListModification->setRefPicListModificationFlagL0(0); |
---|
| 1952 | } |
---|
| 1953 | if(rpcSlice->isInterB()) |
---|
| 1954 | { |
---|
| 1955 | if( !rpcSlice->getPPS()->getListsModificationPresentFlag() || rpcSlice->getNumRpsCurrTempList() <= 1 ) |
---|
| 1956 | { |
---|
| 1957 | refPicListModification->setRefPicListModificationFlagL1( 0 ); |
---|
| 1958 | } |
---|
| 1959 | else |
---|
| 1960 | { |
---|
| 1961 | READ_FLAG( uiCode, "ref_pic_list_modification_flag_l1" ); refPicListModification->setRefPicListModificationFlagL1( uiCode ? 1 : 0 ); |
---|
| 1962 | } |
---|
| 1963 | if(refPicListModification->getRefPicListModificationFlagL1()) |
---|
| 1964 | { |
---|
| 1965 | uiCode = 0; |
---|
| 1966 | Int i = 0; |
---|
| 1967 | Int numRpsCurrTempList1 = rpcSlice->getNumRpsCurrTempList(); |
---|
| 1968 | if ( numRpsCurrTempList1 > 1 ) |
---|
| 1969 | { |
---|
| 1970 | Int length = 1; |
---|
| 1971 | numRpsCurrTempList1 --; |
---|
| 1972 | while ( numRpsCurrTempList1 >>= 1) |
---|
| 1973 | { |
---|
| 1974 | length ++; |
---|
| 1975 | } |
---|
| 1976 | for (i = 0; i < rpcSlice->getNumRefIdx(REF_PIC_LIST_1); i ++) |
---|
| 1977 | { |
---|
| 1978 | READ_CODE( length, uiCode, "list_entry_l1" ); |
---|
| 1979 | refPicListModification->setRefPicSetIdxL1(i, uiCode ); |
---|
| 1980 | } |
---|
| 1981 | } |
---|
| 1982 | else |
---|
| 1983 | { |
---|
| 1984 | for (i = 0; i < rpcSlice->getNumRefIdx(REF_PIC_LIST_1); i ++) |
---|
| 1985 | { |
---|
| 1986 | refPicListModification->setRefPicSetIdxL1(i, 0 ); |
---|
| 1987 | } |
---|
| 1988 | } |
---|
| 1989 | } |
---|
| 1990 | } |
---|
| 1991 | else |
---|
| 1992 | { |
---|
| 1993 | refPicListModification->setRefPicListModificationFlagL1(0); |
---|
| 1994 | } |
---|
| 1995 | if (rpcSlice->isInterB()) |
---|
| 1996 | { |
---|
| 1997 | READ_FLAG( uiCode, "mvd_l1_zero_flag" ); rpcSlice->setMvdL1ZeroFlag( (uiCode ? true : false) ); |
---|
| 1998 | } |
---|
| 1999 | |
---|
| 2000 | rpcSlice->setCabacInitFlag( false ); // default |
---|
| 2001 | if(pps->getCabacInitPresentFlag() && !rpcSlice->isIntra()) |
---|
| 2002 | { |
---|
| 2003 | READ_FLAG(uiCode, "cabac_init_flag"); |
---|
| 2004 | rpcSlice->setCabacInitFlag( uiCode ? true : false ); |
---|
| 2005 | } |
---|
| 2006 | |
---|
| 2007 | if ( rpcSlice->getEnableTMVPFlag() ) |
---|
| 2008 | { |
---|
[442] | 2009 | #if M0457_COL_PICTURE_SIGNALING |
---|
[345] | 2010 | #if REMOVE_COL_PICTURE_SIGNALING |
---|
| 2011 | rpcSlice->setMFMEnabledFlag( rpcSlice->getNumMotionPredRefLayers() > 0 ? true : false ); |
---|
| 2012 | #else |
---|
[313] | 2013 | rpcSlice->setMFMEnabledFlag( false ); |
---|
| 2014 | rpcSlice->setColRefLayerIdx( 0 ); |
---|
| 2015 | rpcSlice->setAltColIndicationFlag( false ); |
---|
| 2016 | if ( sps->getLayerId() > 0 && rpcSlice->getActiveNumILRRefIdx() > 0 && rpcSlice->getNumMotionPredRefLayers() > 0 ) |
---|
| 2017 | { |
---|
| 2018 | READ_FLAG( uiCode, "alt_collocated_indication_flag" ); |
---|
| 2019 | rpcSlice->setAltColIndicationFlag( uiCode == 1 ? true : false ); |
---|
| 2020 | rpcSlice->setMFMEnabledFlag( uiCode == 1 ? true : false ); |
---|
| 2021 | if ( rpcSlice->getNumMotionPredRefLayers() > 1 ) |
---|
| 2022 | { |
---|
| 2023 | READ_UVLC( uiCode, "collocated_ref_layer_idx" ); |
---|
| 2024 | rpcSlice->setColRefLayerIdx( uiCode ); |
---|
| 2025 | } |
---|
| 2026 | } |
---|
| 2027 | else |
---|
| 2028 | { |
---|
[345] | 2029 | #endif //REMOVE_COL_PICTURE_SIGNALING |
---|
[313] | 2030 | #endif |
---|
| 2031 | if ( rpcSlice->getSliceType() == B_SLICE ) |
---|
| 2032 | { |
---|
| 2033 | READ_FLAG( uiCode, "collocated_from_l0_flag" ); |
---|
| 2034 | rpcSlice->setColFromL0Flag(uiCode); |
---|
| 2035 | } |
---|
| 2036 | else |
---|
| 2037 | { |
---|
| 2038 | rpcSlice->setColFromL0Flag( 1 ); |
---|
| 2039 | } |
---|
| 2040 | |
---|
| 2041 | if ( rpcSlice->getSliceType() != I_SLICE && |
---|
| 2042 | ((rpcSlice->getColFromL0Flag() == 1 && rpcSlice->getNumRefIdx(REF_PIC_LIST_0) > 1)|| |
---|
| 2043 | (rpcSlice->getColFromL0Flag() == 0 && rpcSlice->getNumRefIdx(REF_PIC_LIST_1) > 1))) |
---|
| 2044 | { |
---|
| 2045 | READ_UVLC( uiCode, "collocated_ref_idx" ); |
---|
| 2046 | rpcSlice->setColRefIdx(uiCode); |
---|
| 2047 | } |
---|
| 2048 | else |
---|
| 2049 | { |
---|
| 2050 | rpcSlice->setColRefIdx(0); |
---|
| 2051 | } |
---|
[442] | 2052 | #if M0457_COL_PICTURE_SIGNALING && !REMOVE_COL_PICTURE_SIGNALING |
---|
[313] | 2053 | } |
---|
| 2054 | #endif |
---|
| 2055 | } |
---|
| 2056 | if ( (pps->getUseWP() && rpcSlice->getSliceType()==P_SLICE) || (pps->getWPBiPred() && rpcSlice->getSliceType()==B_SLICE) ) |
---|
| 2057 | { |
---|
| 2058 | xParsePredWeightTable(rpcSlice); |
---|
| 2059 | rpcSlice->initWpScaling(); |
---|
| 2060 | } |
---|
| 2061 | if (!rpcSlice->isIntra()) |
---|
| 2062 | { |
---|
| 2063 | READ_UVLC( uiCode, "five_minus_max_num_merge_cand"); |
---|
| 2064 | rpcSlice->setMaxNumMergeCand(MRG_MAX_NUM_CANDS - uiCode); |
---|
| 2065 | } |
---|
| 2066 | |
---|
| 2067 | READ_SVLC( iCode, "slice_qp_delta" ); |
---|
| 2068 | rpcSlice->setSliceQp (26 + pps->getPicInitQPMinus26() + iCode); |
---|
| 2069 | |
---|
[442] | 2070 | #if REPN_FORMAT_IN_VPS |
---|
| 2071 | assert( rpcSlice->getSliceQp() >= -rpcSlice->getQpBDOffsetY() ); |
---|
| 2072 | #else |
---|
[313] | 2073 | assert( rpcSlice->getSliceQp() >= -sps->getQpBDOffsetY() ); |
---|
[442] | 2074 | #endif |
---|
[313] | 2075 | assert( rpcSlice->getSliceQp() <= 51 ); |
---|
| 2076 | |
---|
| 2077 | if (rpcSlice->getPPS()->getSliceChromaQpFlag()) |
---|
| 2078 | { |
---|
| 2079 | READ_SVLC( iCode, "slice_qp_delta_cb" ); |
---|
| 2080 | rpcSlice->setSliceQpDeltaCb( iCode ); |
---|
| 2081 | assert( rpcSlice->getSliceQpDeltaCb() >= -12 ); |
---|
| 2082 | assert( rpcSlice->getSliceQpDeltaCb() <= 12 ); |
---|
| 2083 | assert( (rpcSlice->getPPS()->getChromaCbQpOffset() + rpcSlice->getSliceQpDeltaCb()) >= -12 ); |
---|
| 2084 | assert( (rpcSlice->getPPS()->getChromaCbQpOffset() + rpcSlice->getSliceQpDeltaCb()) <= 12 ); |
---|
| 2085 | |
---|
| 2086 | READ_SVLC( iCode, "slice_qp_delta_cr" ); |
---|
| 2087 | rpcSlice->setSliceQpDeltaCr( iCode ); |
---|
| 2088 | assert( rpcSlice->getSliceQpDeltaCr() >= -12 ); |
---|
| 2089 | assert( rpcSlice->getSliceQpDeltaCr() <= 12 ); |
---|
| 2090 | assert( (rpcSlice->getPPS()->getChromaCrQpOffset() + rpcSlice->getSliceQpDeltaCr()) >= -12 ); |
---|
| 2091 | assert( (rpcSlice->getPPS()->getChromaCrQpOffset() + rpcSlice->getSliceQpDeltaCr()) <= 12 ); |
---|
| 2092 | } |
---|
| 2093 | |
---|
| 2094 | if (rpcSlice->getPPS()->getDeblockingFilterControlPresentFlag()) |
---|
| 2095 | { |
---|
| 2096 | if(rpcSlice->getPPS()->getDeblockingFilterOverrideEnabledFlag()) |
---|
| 2097 | { |
---|
| 2098 | READ_FLAG ( uiCode, "deblocking_filter_override_flag" ); rpcSlice->setDeblockingFilterOverrideFlag(uiCode ? true : false); |
---|
| 2099 | } |
---|
| 2100 | else |
---|
| 2101 | { |
---|
| 2102 | rpcSlice->setDeblockingFilterOverrideFlag(0); |
---|
| 2103 | } |
---|
| 2104 | if(rpcSlice->getDeblockingFilterOverrideFlag()) |
---|
| 2105 | { |
---|
| 2106 | READ_FLAG ( uiCode, "slice_disable_deblocking_filter_flag" ); rpcSlice->setDeblockingFilterDisable(uiCode ? 1 : 0); |
---|
| 2107 | if(!rpcSlice->getDeblockingFilterDisable()) |
---|
| 2108 | { |
---|
| 2109 | READ_SVLC( iCode, "slice_beta_offset_div2" ); rpcSlice->setDeblockingFilterBetaOffsetDiv2(iCode); |
---|
| 2110 | assert(rpcSlice->getDeblockingFilterBetaOffsetDiv2() >= -6 && |
---|
| 2111 | rpcSlice->getDeblockingFilterBetaOffsetDiv2() <= 6); |
---|
| 2112 | READ_SVLC( iCode, "slice_tc_offset_div2" ); rpcSlice->setDeblockingFilterTcOffsetDiv2(iCode); |
---|
| 2113 | assert(rpcSlice->getDeblockingFilterTcOffsetDiv2() >= -6 && |
---|
| 2114 | rpcSlice->getDeblockingFilterTcOffsetDiv2() <= 6); |
---|
| 2115 | } |
---|
| 2116 | } |
---|
| 2117 | else |
---|
| 2118 | { |
---|
| 2119 | rpcSlice->setDeblockingFilterDisable ( rpcSlice->getPPS()->getPicDisableDeblockingFilterFlag() ); |
---|
| 2120 | rpcSlice->setDeblockingFilterBetaOffsetDiv2( rpcSlice->getPPS()->getDeblockingFilterBetaOffsetDiv2() ); |
---|
| 2121 | rpcSlice->setDeblockingFilterTcOffsetDiv2 ( rpcSlice->getPPS()->getDeblockingFilterTcOffsetDiv2() ); |
---|
| 2122 | } |
---|
| 2123 | } |
---|
| 2124 | else |
---|
| 2125 | { |
---|
| 2126 | rpcSlice->setDeblockingFilterDisable ( false ); |
---|
| 2127 | rpcSlice->setDeblockingFilterBetaOffsetDiv2( 0 ); |
---|
| 2128 | rpcSlice->setDeblockingFilterTcOffsetDiv2 ( 0 ); |
---|
| 2129 | } |
---|
| 2130 | |
---|
| 2131 | Bool isSAOEnabled = (!rpcSlice->getSPS()->getUseSAO())?(false):(rpcSlice->getSaoEnabledFlag()||rpcSlice->getSaoEnabledFlagChroma()); |
---|
| 2132 | Bool isDBFEnabled = (!rpcSlice->getDeblockingFilterDisable()); |
---|
| 2133 | |
---|
| 2134 | if(rpcSlice->getPPS()->getLoopFilterAcrossSlicesEnabledFlag() && ( isSAOEnabled || isDBFEnabled )) |
---|
| 2135 | { |
---|
| 2136 | READ_FLAG( uiCode, "slice_loop_filter_across_slices_enabled_flag"); |
---|
| 2137 | } |
---|
| 2138 | else |
---|
| 2139 | { |
---|
| 2140 | uiCode = rpcSlice->getPPS()->getLoopFilterAcrossSlicesEnabledFlag()?1:0; |
---|
| 2141 | } |
---|
| 2142 | rpcSlice->setLFCrossSliceBoundaryFlag( (uiCode==1)?true:false); |
---|
| 2143 | |
---|
| 2144 | } |
---|
| 2145 | |
---|
| 2146 | UInt *entryPointOffset = NULL; |
---|
| 2147 | UInt numEntryPointOffsets, offsetLenMinus1; |
---|
| 2148 | if( pps->getTilesEnabledFlag() || pps->getEntropyCodingSyncEnabledFlag() ) |
---|
| 2149 | { |
---|
| 2150 | READ_UVLC(numEntryPointOffsets, "num_entry_point_offsets"); rpcSlice->setNumEntryPointOffsets ( numEntryPointOffsets ); |
---|
| 2151 | if (numEntryPointOffsets>0) |
---|
| 2152 | { |
---|
| 2153 | READ_UVLC(offsetLenMinus1, "offset_len_minus1"); |
---|
| 2154 | } |
---|
| 2155 | entryPointOffset = new UInt[numEntryPointOffsets]; |
---|
| 2156 | for (UInt idx=0; idx<numEntryPointOffsets; idx++) |
---|
| 2157 | { |
---|
| 2158 | READ_CODE(offsetLenMinus1+1, uiCode, "entry_point_offset_minus1"); |
---|
| 2159 | entryPointOffset[ idx ] = uiCode + 1; |
---|
| 2160 | } |
---|
| 2161 | } |
---|
| 2162 | else |
---|
| 2163 | { |
---|
| 2164 | rpcSlice->setNumEntryPointOffsets ( 0 ); |
---|
| 2165 | } |
---|
| 2166 | |
---|
| 2167 | if(pps->getSliceHeaderExtensionPresentFlag()) |
---|
| 2168 | { |
---|
| 2169 | READ_UVLC(uiCode,"slice_header_extension_length"); |
---|
| 2170 | for(Int i=0; i<uiCode; i++) |
---|
| 2171 | { |
---|
| 2172 | UInt ignore; |
---|
| 2173 | READ_CODE(8,ignore,"slice_header_extension_data_byte"); |
---|
| 2174 | } |
---|
| 2175 | } |
---|
| 2176 | m_pcBitstream->readByteAlignment(); |
---|
| 2177 | |
---|
| 2178 | if( pps->getTilesEnabledFlag() || pps->getEntropyCodingSyncEnabledFlag() ) |
---|
| 2179 | { |
---|
| 2180 | Int endOfSliceHeaderLocation = m_pcBitstream->getByteLocation(); |
---|
| 2181 | |
---|
| 2182 | // Adjust endOfSliceHeaderLocation to account for emulation prevention bytes in the slice segment header |
---|
| 2183 | for ( UInt curByteIdx = 0; curByteIdx<m_pcBitstream->numEmulationPreventionBytesRead(); curByteIdx++ ) |
---|
| 2184 | { |
---|
| 2185 | if ( m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) < endOfSliceHeaderLocation ) |
---|
| 2186 | { |
---|
| 2187 | endOfSliceHeaderLocation++; |
---|
| 2188 | } |
---|
| 2189 | } |
---|
| 2190 | |
---|
| 2191 | Int curEntryPointOffset = 0; |
---|
| 2192 | Int prevEntryPointOffset = 0; |
---|
| 2193 | for (UInt idx=0; idx<numEntryPointOffsets; idx++) |
---|
| 2194 | { |
---|
| 2195 | curEntryPointOffset += entryPointOffset[ idx ]; |
---|
| 2196 | |
---|
| 2197 | Int emulationPreventionByteCount = 0; |
---|
| 2198 | for ( UInt curByteIdx = 0; curByteIdx<m_pcBitstream->numEmulationPreventionBytesRead(); curByteIdx++ ) |
---|
| 2199 | { |
---|
| 2200 | if ( m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) >= ( prevEntryPointOffset + endOfSliceHeaderLocation ) && |
---|
| 2201 | m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) < ( curEntryPointOffset + endOfSliceHeaderLocation ) ) |
---|
| 2202 | { |
---|
| 2203 | emulationPreventionByteCount++; |
---|
| 2204 | } |
---|
| 2205 | } |
---|
| 2206 | |
---|
| 2207 | entryPointOffset[ idx ] -= emulationPreventionByteCount; |
---|
| 2208 | prevEntryPointOffset = curEntryPointOffset; |
---|
| 2209 | } |
---|
| 2210 | |
---|
| 2211 | if ( pps->getTilesEnabledFlag() ) |
---|
| 2212 | { |
---|
| 2213 | rpcSlice->setTileLocationCount( numEntryPointOffsets ); |
---|
| 2214 | |
---|
| 2215 | UInt prevPos = 0; |
---|
| 2216 | for (Int idx=0; idx<rpcSlice->getTileLocationCount(); idx++) |
---|
| 2217 | { |
---|
| 2218 | rpcSlice->setTileLocation( idx, prevPos + entryPointOffset [ idx ] ); |
---|
| 2219 | prevPos += entryPointOffset[ idx ]; |
---|
| 2220 | } |
---|
| 2221 | } |
---|
| 2222 | else if ( pps->getEntropyCodingSyncEnabledFlag() ) |
---|
| 2223 | { |
---|
| 2224 | Int numSubstreams = rpcSlice->getNumEntryPointOffsets()+1; |
---|
| 2225 | rpcSlice->allocSubstreamSizes(numSubstreams); |
---|
| 2226 | UInt *pSubstreamSizes = rpcSlice->getSubstreamSizes(); |
---|
| 2227 | for (Int idx=0; idx<numSubstreams-1; idx++) |
---|
| 2228 | { |
---|
| 2229 | if ( idx < numEntryPointOffsets ) |
---|
| 2230 | { |
---|
| 2231 | pSubstreamSizes[ idx ] = ( entryPointOffset[ idx ] << 3 ) ; |
---|
| 2232 | } |
---|
| 2233 | else |
---|
| 2234 | { |
---|
| 2235 | pSubstreamSizes[ idx ] = 0; |
---|
| 2236 | } |
---|
| 2237 | } |
---|
| 2238 | } |
---|
| 2239 | |
---|
| 2240 | if (entryPointOffset) |
---|
| 2241 | { |
---|
| 2242 | delete [] entryPointOffset; |
---|
| 2243 | } |
---|
| 2244 | } |
---|
| 2245 | |
---|
| 2246 | return; |
---|
| 2247 | } |
---|
| 2248 | |
---|
| 2249 | Void TDecCavlc::parsePTL( TComPTL *rpcPTL, Bool profilePresentFlag, Int maxNumSubLayersMinus1 ) |
---|
| 2250 | { |
---|
| 2251 | UInt uiCode; |
---|
| 2252 | if(profilePresentFlag) |
---|
| 2253 | { |
---|
| 2254 | parseProfileTier(rpcPTL->getGeneralPTL()); |
---|
| 2255 | } |
---|
| 2256 | READ_CODE( 8, uiCode, "general_level_idc" ); rpcPTL->getGeneralPTL()->setLevelIdc(uiCode); |
---|
| 2257 | |
---|
| 2258 | for (Int i = 0; i < maxNumSubLayersMinus1; i++) |
---|
| 2259 | { |
---|
| 2260 | if(profilePresentFlag) |
---|
| 2261 | { |
---|
| 2262 | READ_FLAG( uiCode, "sub_layer_profile_present_flag[i]" ); rpcPTL->setSubLayerProfilePresentFlag(i, uiCode); |
---|
| 2263 | } |
---|
| 2264 | READ_FLAG( uiCode, "sub_layer_level_present_flag[i]" ); rpcPTL->setSubLayerLevelPresentFlag (i, uiCode); |
---|
| 2265 | } |
---|
| 2266 | |
---|
| 2267 | if (maxNumSubLayersMinus1 > 0) |
---|
| 2268 | { |
---|
| 2269 | for (Int i = maxNumSubLayersMinus1; i < 8; i++) |
---|
| 2270 | { |
---|
| 2271 | READ_CODE(2, uiCode, "reserved_zero_2bits"); |
---|
| 2272 | assert(uiCode == 0); |
---|
| 2273 | } |
---|
| 2274 | } |
---|
| 2275 | |
---|
| 2276 | for(Int i = 0; i < maxNumSubLayersMinus1; i++) |
---|
| 2277 | { |
---|
| 2278 | if( profilePresentFlag && rpcPTL->getSubLayerProfilePresentFlag(i) ) |
---|
| 2279 | { |
---|
| 2280 | parseProfileTier(rpcPTL->getSubLayerPTL(i)); |
---|
| 2281 | } |
---|
| 2282 | if(rpcPTL->getSubLayerLevelPresentFlag(i)) |
---|
| 2283 | { |
---|
| 2284 | READ_CODE( 8, uiCode, "sub_layer_level_idc[i]" ); rpcPTL->getSubLayerPTL(i)->setLevelIdc(uiCode); |
---|
| 2285 | } |
---|
| 2286 | } |
---|
| 2287 | } |
---|
| 2288 | |
---|
| 2289 | Void TDecCavlc::parseProfileTier(ProfileTierLevel *ptl) |
---|
| 2290 | { |
---|
| 2291 | UInt uiCode; |
---|
| 2292 | READ_CODE(2 , uiCode, "XXX_profile_space[]"); ptl->setProfileSpace(uiCode); |
---|
| 2293 | READ_FLAG( uiCode, "XXX_tier_flag[]" ); ptl->setTierFlag (uiCode ? 1 : 0); |
---|
| 2294 | READ_CODE(5 , uiCode, "XXX_profile_idc[]" ); ptl->setProfileIdc (uiCode); |
---|
| 2295 | for(Int j = 0; j < 32; j++) |
---|
| 2296 | { |
---|
| 2297 | READ_FLAG( uiCode, "XXX_profile_compatibility_flag[][j]"); ptl->setProfileCompatibilityFlag(j, uiCode ? 1 : 0); |
---|
| 2298 | } |
---|
| 2299 | READ_FLAG(uiCode, "general_progressive_source_flag"); |
---|
| 2300 | ptl->setProgressiveSourceFlag(uiCode ? true : false); |
---|
| 2301 | |
---|
| 2302 | READ_FLAG(uiCode, "general_interlaced_source_flag"); |
---|
| 2303 | ptl->setInterlacedSourceFlag(uiCode ? true : false); |
---|
| 2304 | |
---|
| 2305 | READ_FLAG(uiCode, "general_non_packed_constraint_flag"); |
---|
| 2306 | ptl->setNonPackedConstraintFlag(uiCode ? true : false); |
---|
| 2307 | |
---|
| 2308 | READ_FLAG(uiCode, "general_frame_only_constraint_flag"); |
---|
| 2309 | ptl->setFrameOnlyConstraintFlag(uiCode ? true : false); |
---|
| 2310 | |
---|
| 2311 | READ_CODE(16, uiCode, "XXX_reserved_zero_44bits[0..15]"); |
---|
| 2312 | READ_CODE(16, uiCode, "XXX_reserved_zero_44bits[16..31]"); |
---|
| 2313 | READ_CODE(12, uiCode, "XXX_reserved_zero_44bits[32..43]"); |
---|
| 2314 | } |
---|
| 2315 | |
---|
| 2316 | Void TDecCavlc::parseTerminatingBit( UInt& ruiBit ) |
---|
| 2317 | { |
---|
| 2318 | ruiBit = false; |
---|
| 2319 | Int iBitsLeft = m_pcBitstream->getNumBitsLeft(); |
---|
| 2320 | if(iBitsLeft <= 8) |
---|
| 2321 | { |
---|
| 2322 | UInt uiPeekValue = m_pcBitstream->peekBits(iBitsLeft); |
---|
| 2323 | if (uiPeekValue == (1<<(iBitsLeft-1))) |
---|
| 2324 | { |
---|
| 2325 | ruiBit = true; |
---|
| 2326 | } |
---|
| 2327 | } |
---|
| 2328 | } |
---|
| 2329 | |
---|
| 2330 | Void TDecCavlc::parseSkipFlag( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
| 2331 | { |
---|
| 2332 | assert(0); |
---|
| 2333 | } |
---|
| 2334 | |
---|
| 2335 | Void TDecCavlc::parseCUTransquantBypassFlag( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
| 2336 | { |
---|
| 2337 | assert(0); |
---|
| 2338 | } |
---|
| 2339 | |
---|
| 2340 | Void TDecCavlc::parseMVPIdx( Int& /*riMVPIdx*/ ) |
---|
| 2341 | { |
---|
| 2342 | assert(0); |
---|
| 2343 | } |
---|
| 2344 | |
---|
| 2345 | Void TDecCavlc::parseSplitFlag ( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
| 2346 | { |
---|
| 2347 | assert(0); |
---|
| 2348 | } |
---|
| 2349 | |
---|
| 2350 | Void TDecCavlc::parsePartSize( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
| 2351 | { |
---|
| 2352 | assert(0); |
---|
| 2353 | } |
---|
| 2354 | |
---|
| 2355 | Void TDecCavlc::parsePredMode( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
| 2356 | { |
---|
| 2357 | assert(0); |
---|
| 2358 | } |
---|
| 2359 | |
---|
| 2360 | /** Parse I_PCM information. |
---|
| 2361 | * \param pcCU pointer to CU |
---|
| 2362 | * \param uiAbsPartIdx CU index |
---|
| 2363 | * \param uiDepth CU depth |
---|
| 2364 | * \returns Void |
---|
| 2365 | * |
---|
| 2366 | * If I_PCM flag indicates that the CU is I_PCM, parse its PCM alignment bits and codes. |
---|
| 2367 | */ |
---|
| 2368 | Void TDecCavlc::parseIPCMInfo( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
| 2369 | { |
---|
| 2370 | assert(0); |
---|
| 2371 | } |
---|
| 2372 | |
---|
| 2373 | Void TDecCavlc::parseIntraDirLumaAng ( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
| 2374 | { |
---|
| 2375 | assert(0); |
---|
| 2376 | } |
---|
| 2377 | |
---|
| 2378 | Void TDecCavlc::parseIntraDirChroma( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
| 2379 | { |
---|
| 2380 | assert(0); |
---|
| 2381 | } |
---|
| 2382 | |
---|
| 2383 | Void TDecCavlc::parseInterDir( TComDataCU* /*pcCU*/, UInt& /*ruiInterDir*/, UInt /*uiAbsPartIdx*/ ) |
---|
| 2384 | { |
---|
| 2385 | assert(0); |
---|
| 2386 | } |
---|
| 2387 | |
---|
| 2388 | Void TDecCavlc::parseRefFrmIdx( TComDataCU* /*pcCU*/, Int& /*riRefFrmIdx*/, RefPicList /*eRefList*/ ) |
---|
| 2389 | { |
---|
| 2390 | assert(0); |
---|
| 2391 | } |
---|
| 2392 | |
---|
| 2393 | Void TDecCavlc::parseMvd( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiPartIdx*/, UInt /*uiDepth*/, RefPicList /*eRefList*/ ) |
---|
| 2394 | { |
---|
| 2395 | assert(0); |
---|
| 2396 | } |
---|
| 2397 | |
---|
| 2398 | Void TDecCavlc::parseDeltaQP( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 2399 | { |
---|
| 2400 | Int qp; |
---|
| 2401 | Int iDQp; |
---|
| 2402 | |
---|
| 2403 | xReadSvlc( iDQp ); |
---|
| 2404 | |
---|
[442] | 2405 | #if REPN_FORMAT_IN_VPS |
---|
| 2406 | Int qpBdOffsetY = pcCU->getSlice()->getQpBDOffsetY(); |
---|
| 2407 | #else |
---|
[313] | 2408 | Int qpBdOffsetY = pcCU->getSlice()->getSPS()->getQpBDOffsetY(); |
---|
[442] | 2409 | #endif |
---|
[313] | 2410 | qp = (((Int) pcCU->getRefQP( uiAbsPartIdx ) + iDQp + 52 + 2*qpBdOffsetY )%(52+ qpBdOffsetY)) - qpBdOffsetY; |
---|
| 2411 | |
---|
| 2412 | UInt uiAbsQpCUPartIdx = (uiAbsPartIdx>>((g_uiMaxCUDepth - pcCU->getSlice()->getPPS()->getMaxCuDQPDepth())<<1))<<((g_uiMaxCUDepth - pcCU->getSlice()->getPPS()->getMaxCuDQPDepth())<<1) ; |
---|
| 2413 | UInt uiQpCUDepth = min(uiDepth,pcCU->getSlice()->getPPS()->getMaxCuDQPDepth()) ; |
---|
| 2414 | |
---|
| 2415 | pcCU->setQPSubParts( qp, uiAbsQpCUPartIdx, uiQpCUDepth ); |
---|
| 2416 | } |
---|
| 2417 | |
---|
| 2418 | Void TDecCavlc::parseCoeffNxN( TComDataCU* /*pcCU*/, TCoeff* /*pcCoef*/, UInt /*uiAbsPartIdx*/, UInt /*uiWidth*/, UInt /*uiHeight*/, UInt /*uiDepth*/, TextType /*eTType*/ ) |
---|
| 2419 | { |
---|
| 2420 | assert(0); |
---|
| 2421 | } |
---|
| 2422 | |
---|
| 2423 | Void TDecCavlc::parseTransformSubdivFlag( UInt& /*ruiSubdivFlag*/, UInt /*uiLog2TransformBlockSize*/ ) |
---|
| 2424 | { |
---|
| 2425 | assert(0); |
---|
| 2426 | } |
---|
| 2427 | |
---|
| 2428 | Void TDecCavlc::parseQtCbf( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, TextType /*eType*/, UInt /*uiTrDepth*/, UInt /*uiDepth*/ ) |
---|
| 2429 | { |
---|
| 2430 | assert(0); |
---|
| 2431 | } |
---|
| 2432 | |
---|
| 2433 | Void TDecCavlc::parseQtRootCbf( UInt /*uiAbsPartIdx*/, UInt& /*uiQtRootCbf*/ ) |
---|
| 2434 | { |
---|
| 2435 | assert(0); |
---|
| 2436 | } |
---|
| 2437 | |
---|
| 2438 | Void TDecCavlc::parseTransformSkipFlags (TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*width*/, UInt /*height*/, UInt /*uiDepth*/, TextType /*eTType*/) |
---|
| 2439 | { |
---|
| 2440 | assert(0); |
---|
| 2441 | } |
---|
| 2442 | |
---|
| 2443 | Void TDecCavlc::parseMergeFlag ( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/, UInt /*uiPUIdx*/ ) |
---|
| 2444 | { |
---|
| 2445 | assert(0); |
---|
| 2446 | } |
---|
| 2447 | |
---|
| 2448 | Void TDecCavlc::parseMergeIndex ( TComDataCU* /*pcCU*/, UInt& /*ruiMergeIndex*/ ) |
---|
| 2449 | { |
---|
| 2450 | assert(0); |
---|
| 2451 | } |
---|
| 2452 | |
---|
| 2453 | // ==================================================================================================================== |
---|
| 2454 | // Protected member functions |
---|
| 2455 | // ==================================================================================================================== |
---|
| 2456 | |
---|
| 2457 | /** parse explicit wp tables |
---|
| 2458 | * \param TComSlice* pcSlice |
---|
| 2459 | * \returns Void |
---|
| 2460 | */ |
---|
| 2461 | Void TDecCavlc::xParsePredWeightTable( TComSlice* pcSlice ) |
---|
| 2462 | { |
---|
| 2463 | wpScalingParam *wp; |
---|
| 2464 | Bool bChroma = true; // color always present in HEVC ? |
---|
| 2465 | SliceType eSliceType = pcSlice->getSliceType(); |
---|
| 2466 | Int iNbRef = (eSliceType == B_SLICE ) ? (2) : (1); |
---|
| 2467 | UInt uiLog2WeightDenomLuma, uiLog2WeightDenomChroma; |
---|
| 2468 | UInt uiTotalSignalledWeightFlags = 0; |
---|
| 2469 | |
---|
| 2470 | Int iDeltaDenom; |
---|
| 2471 | // decode delta_luma_log2_weight_denom : |
---|
| 2472 | READ_UVLC( uiLog2WeightDenomLuma, "luma_log2_weight_denom" ); // ue(v): luma_log2_weight_denom |
---|
| 2473 | assert( uiLog2WeightDenomLuma <= 7 ); |
---|
| 2474 | if( bChroma ) |
---|
| 2475 | { |
---|
| 2476 | READ_SVLC( iDeltaDenom, "delta_chroma_log2_weight_denom" ); // se(v): delta_chroma_log2_weight_denom |
---|
| 2477 | assert((iDeltaDenom + (Int)uiLog2WeightDenomLuma)>=0); |
---|
| 2478 | assert((iDeltaDenom + (Int)uiLog2WeightDenomLuma)<=7); |
---|
| 2479 | uiLog2WeightDenomChroma = (UInt)(iDeltaDenom + uiLog2WeightDenomLuma); |
---|
| 2480 | } |
---|
| 2481 | |
---|
| 2482 | for ( Int iNumRef=0 ; iNumRef<iNbRef ; iNumRef++ ) |
---|
| 2483 | { |
---|
| 2484 | RefPicList eRefPicList = ( iNumRef ? REF_PIC_LIST_1 : REF_PIC_LIST_0 ); |
---|
| 2485 | for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ ) |
---|
| 2486 | { |
---|
| 2487 | pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); |
---|
| 2488 | |
---|
| 2489 | wp[0].uiLog2WeightDenom = uiLog2WeightDenomLuma; |
---|
| 2490 | wp[1].uiLog2WeightDenom = uiLog2WeightDenomChroma; |
---|
| 2491 | wp[2].uiLog2WeightDenom = uiLog2WeightDenomChroma; |
---|
| 2492 | |
---|
| 2493 | UInt uiCode; |
---|
| 2494 | READ_FLAG( uiCode, "luma_weight_lX_flag" ); // u(1): luma_weight_l0_flag |
---|
| 2495 | wp[0].bPresentFlag = ( uiCode == 1 ); |
---|
| 2496 | uiTotalSignalledWeightFlags += wp[0].bPresentFlag; |
---|
| 2497 | } |
---|
| 2498 | if ( bChroma ) |
---|
| 2499 | { |
---|
| 2500 | UInt uiCode; |
---|
| 2501 | for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ ) |
---|
| 2502 | { |
---|
| 2503 | pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); |
---|
| 2504 | READ_FLAG( uiCode, "chroma_weight_lX_flag" ); // u(1): chroma_weight_l0_flag |
---|
| 2505 | wp[1].bPresentFlag = ( uiCode == 1 ); |
---|
| 2506 | wp[2].bPresentFlag = ( uiCode == 1 ); |
---|
| 2507 | uiTotalSignalledWeightFlags += 2*wp[1].bPresentFlag; |
---|
| 2508 | } |
---|
| 2509 | } |
---|
| 2510 | for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ ) |
---|
| 2511 | { |
---|
| 2512 | pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); |
---|
| 2513 | if ( wp[0].bPresentFlag ) |
---|
| 2514 | { |
---|
| 2515 | Int iDeltaWeight; |
---|
| 2516 | READ_SVLC( iDeltaWeight, "delta_luma_weight_lX" ); // se(v): delta_luma_weight_l0[i] |
---|
| 2517 | assert( iDeltaWeight >= -128 ); |
---|
| 2518 | assert( iDeltaWeight <= 127 ); |
---|
| 2519 | wp[0].iWeight = (iDeltaWeight + (1<<wp[0].uiLog2WeightDenom)); |
---|
| 2520 | READ_SVLC( wp[0].iOffset, "luma_offset_lX" ); // se(v): luma_offset_l0[i] |
---|
| 2521 | assert( wp[0].iOffset >= -128 ); |
---|
| 2522 | assert( wp[0].iOffset <= 127 ); |
---|
| 2523 | } |
---|
| 2524 | else |
---|
| 2525 | { |
---|
| 2526 | wp[0].iWeight = (1 << wp[0].uiLog2WeightDenom); |
---|
| 2527 | wp[0].iOffset = 0; |
---|
| 2528 | } |
---|
| 2529 | if ( bChroma ) |
---|
| 2530 | { |
---|
| 2531 | if ( wp[1].bPresentFlag ) |
---|
| 2532 | { |
---|
| 2533 | for ( Int j=1 ; j<3 ; j++ ) |
---|
| 2534 | { |
---|
| 2535 | Int iDeltaWeight; |
---|
| 2536 | READ_SVLC( iDeltaWeight, "delta_chroma_weight_lX" ); // se(v): chroma_weight_l0[i][j] |
---|
| 2537 | assert( iDeltaWeight >= -128 ); |
---|
| 2538 | assert( iDeltaWeight <= 127 ); |
---|
| 2539 | wp[j].iWeight = (iDeltaWeight + (1<<wp[1].uiLog2WeightDenom)); |
---|
| 2540 | |
---|
| 2541 | Int iDeltaChroma; |
---|
| 2542 | READ_SVLC( iDeltaChroma, "delta_chroma_offset_lX" ); // se(v): delta_chroma_offset_l0[i][j] |
---|
| 2543 | assert( iDeltaChroma >= -512 ); |
---|
| 2544 | assert( iDeltaChroma <= 511 ); |
---|
| 2545 | Int pred = ( 128 - ( ( 128*wp[j].iWeight)>>(wp[j].uiLog2WeightDenom) ) ); |
---|
| 2546 | wp[j].iOffset = Clip3(-128, 127, (iDeltaChroma + pred) ); |
---|
| 2547 | } |
---|
| 2548 | } |
---|
| 2549 | else |
---|
| 2550 | { |
---|
| 2551 | for ( Int j=1 ; j<3 ; j++ ) |
---|
| 2552 | { |
---|
| 2553 | wp[j].iWeight = (1 << wp[j].uiLog2WeightDenom); |
---|
| 2554 | wp[j].iOffset = 0; |
---|
| 2555 | } |
---|
| 2556 | } |
---|
| 2557 | } |
---|
| 2558 | } |
---|
| 2559 | |
---|
| 2560 | for ( Int iRefIdx=pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx<MAX_NUM_REF ; iRefIdx++ ) |
---|
| 2561 | { |
---|
| 2562 | pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); |
---|
| 2563 | |
---|
| 2564 | wp[0].bPresentFlag = false; |
---|
| 2565 | wp[1].bPresentFlag = false; |
---|
| 2566 | wp[2].bPresentFlag = false; |
---|
| 2567 | } |
---|
| 2568 | } |
---|
| 2569 | assert(uiTotalSignalledWeightFlags<=24); |
---|
| 2570 | } |
---|
| 2571 | |
---|
| 2572 | /** decode quantization matrix |
---|
| 2573 | * \param scalingList quantization matrix information |
---|
| 2574 | */ |
---|
| 2575 | Void TDecCavlc::parseScalingList(TComScalingList* scalingList) |
---|
| 2576 | { |
---|
| 2577 | UInt code, sizeId, listId; |
---|
| 2578 | Bool scalingListPredModeFlag; |
---|
[442] | 2579 | |
---|
[313] | 2580 | //for each size |
---|
| 2581 | for(sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
| 2582 | { |
---|
| 2583 | for(listId = 0; listId < g_scalingListNum[sizeId]; listId++) |
---|
| 2584 | { |
---|
[442] | 2585 | #if IL_SL_SIGNALLING_N0371 |
---|
| 2586 | if ( scalingList->getLayerId() > 0 && scalingList->getPredScalingListFlag() ) |
---|
| 2587 | { |
---|
| 2588 | READ_FLAG( code, "scaling_list_pred_mode_flag"); |
---|
| 2589 | scalingListPredModeFlag = (code) ? true : false; |
---|
| 2590 | if(!scalingListPredModeFlag) //Copy Mode |
---|
| 2591 | { |
---|
| 2592 | READ_UVLC( code, "scaling_list_pred_matrix_id_delta"); |
---|
| 2593 | scalingList->setRefMatrixId (sizeId,listId,(UInt)((Int)(listId)-(code))); |
---|
| 2594 | if( sizeId > SCALING_LIST_8x8 ) |
---|
| 2595 | { |
---|
| 2596 | scalingList->setScalingListDC(sizeId,listId,((listId == scalingList->getRefMatrixId (sizeId,listId))? 16 :scalingList->getScalingListDC(sizeId, scalingList->getRefMatrixId (sizeId,listId)))); |
---|
| 2597 | } |
---|
| 2598 | scalingList->processRefMatrix( sizeId, listId, scalingList->getRefMatrixId (sizeId,listId)); |
---|
| 2599 | |
---|
| 2600 | } |
---|
| 2601 | else //DPCM Mode |
---|
| 2602 | { |
---|
| 2603 | xDecodeScalingList(scalingList, sizeId, listId); |
---|
| 2604 | } |
---|
| 2605 | } |
---|
| 2606 | else |
---|
| 2607 | { |
---|
| 2608 | READ_FLAG( code, "scaling_list_pred_mode_flag"); |
---|
| 2609 | scalingListPredModeFlag = (code) ? true : false; |
---|
| 2610 | if(!scalingListPredModeFlag) //Copy Mode |
---|
| 2611 | { |
---|
| 2612 | READ_UVLC( code, "scaling_list_pred_matrix_id_delta"); |
---|
| 2613 | scalingList->setRefMatrixId (sizeId,listId,(UInt)((Int)(listId)-(code))); |
---|
| 2614 | if( sizeId > SCALING_LIST_8x8 ) |
---|
| 2615 | { |
---|
| 2616 | scalingList->setScalingListDC(sizeId,listId,((listId == scalingList->getRefMatrixId (sizeId,listId))? 16 :scalingList->getScalingListDC(sizeId, scalingList->getRefMatrixId (sizeId,listId)))); |
---|
| 2617 | } |
---|
| 2618 | scalingList->processRefMatrix( sizeId, listId, scalingList->getRefMatrixId (sizeId,listId)); |
---|
| 2619 | |
---|
| 2620 | } |
---|
| 2621 | else //DPCM Mode |
---|
| 2622 | { |
---|
| 2623 | xDecodeScalingList(scalingList, sizeId, listId); |
---|
| 2624 | } |
---|
| 2625 | } |
---|
| 2626 | #else |
---|
[313] | 2627 | READ_FLAG( code, "scaling_list_pred_mode_flag"); |
---|
| 2628 | scalingListPredModeFlag = (code) ? true : false; |
---|
| 2629 | if(!scalingListPredModeFlag) //Copy Mode |
---|
| 2630 | { |
---|
| 2631 | READ_UVLC( code, "scaling_list_pred_matrix_id_delta"); |
---|
| 2632 | scalingList->setRefMatrixId (sizeId,listId,(UInt)((Int)(listId)-(code))); |
---|
| 2633 | if( sizeId > SCALING_LIST_8x8 ) |
---|
| 2634 | { |
---|
| 2635 | scalingList->setScalingListDC(sizeId,listId,((listId == scalingList->getRefMatrixId (sizeId,listId))? 16 :scalingList->getScalingListDC(sizeId, scalingList->getRefMatrixId (sizeId,listId)))); |
---|
| 2636 | } |
---|
| 2637 | scalingList->processRefMatrix( sizeId, listId, scalingList->getRefMatrixId (sizeId,listId)); |
---|
| 2638 | |
---|
| 2639 | } |
---|
| 2640 | else //DPCM Mode |
---|
| 2641 | { |
---|
| 2642 | xDecodeScalingList(scalingList, sizeId, listId); |
---|
| 2643 | } |
---|
[442] | 2644 | #endif |
---|
[313] | 2645 | } |
---|
| 2646 | } |
---|
| 2647 | |
---|
| 2648 | return; |
---|
| 2649 | } |
---|
| 2650 | /** decode DPCM |
---|
| 2651 | * \param scalingList quantization matrix information |
---|
| 2652 | * \param sizeId size index |
---|
| 2653 | * \param listId list index |
---|
| 2654 | */ |
---|
| 2655 | Void TDecCavlc::xDecodeScalingList(TComScalingList *scalingList, UInt sizeId, UInt listId) |
---|
| 2656 | { |
---|
| 2657 | Int i,coefNum = min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId]); |
---|
| 2658 | Int data; |
---|
| 2659 | Int scalingListDcCoefMinus8 = 0; |
---|
| 2660 | Int nextCoef = SCALING_LIST_START_VALUE; |
---|
| 2661 | UInt* scan = (sizeId == 0) ? g_auiSigLastScan [ SCAN_DIAG ] [ 1 ] : g_sigLastScanCG32x32; |
---|
| 2662 | Int *dst = scalingList->getScalingListAddress(sizeId, listId); |
---|
| 2663 | |
---|
| 2664 | if( sizeId > SCALING_LIST_8x8 ) |
---|
| 2665 | { |
---|
[442] | 2666 | #if IL_SL_SIGNALLING_N0371 |
---|
| 2667 | if( scalingList->getLayerId() > 0 && scalingList->getPredScalingListFlag() ) |
---|
| 2668 | { |
---|
| 2669 | ref_scalingListDC[scalingList->getLayerId()][sizeId][listId] = scalingList->getScalingListDC(sizeId,listId); |
---|
| 2670 | scalingList->setScalingListDC(sizeId,listId,ref_scalingListDC[scalingList->getScalingListRefLayerId()][sizeId][listId]); |
---|
| 2671 | } |
---|
| 2672 | else |
---|
| 2673 | { |
---|
| 2674 | READ_SVLC( scalingListDcCoefMinus8, "scaling_list_dc_coef_minus8"); |
---|
| 2675 | scalingList->setScalingListDC(sizeId,listId,scalingListDcCoefMinus8 + 8); |
---|
| 2676 | nextCoef = scalingList->getScalingListDC(sizeId,listId); |
---|
| 2677 | ref_scalingListDC[scalingList->getLayerId()][sizeId][listId] = scalingList->getScalingListDC(sizeId,listId); |
---|
| 2678 | } |
---|
| 2679 | #else |
---|
[313] | 2680 | READ_SVLC( scalingListDcCoefMinus8, "scaling_list_dc_coef_minus8"); |
---|
| 2681 | scalingList->setScalingListDC(sizeId,listId,scalingListDcCoefMinus8 + 8); |
---|
| 2682 | nextCoef = scalingList->getScalingListDC(sizeId,listId); |
---|
[442] | 2683 | #endif |
---|
[313] | 2684 | } |
---|
| 2685 | |
---|
| 2686 | for(i = 0; i < coefNum; i++) |
---|
| 2687 | { |
---|
[442] | 2688 | #if IL_SL_SIGNALLING_N0371 |
---|
| 2689 | if( scalingList->getLayerId() > 0 && scalingList->getPredScalingListFlag() ) |
---|
| 2690 | { |
---|
| 2691 | ref_scalingListCoef[scalingList->getLayerId()][sizeId][listId][i] = dst[scan[i]]; |
---|
| 2692 | dst[scan[i]] = ref_scalingListCoef[scalingList->getScalingListRefLayerId()][sizeId][listId][i]; |
---|
| 2693 | } |
---|
| 2694 | else |
---|
| 2695 | { |
---|
| 2696 | READ_SVLC( data, "scaling_list_delta_coef"); |
---|
| 2697 | nextCoef = (nextCoef + data + 256 ) % 256; |
---|
| 2698 | dst[scan[i]] = nextCoef; |
---|
| 2699 | ref_scalingListCoef[scalingList->getLayerId()][sizeId][listId][i] = dst[scan[i]]; |
---|
| 2700 | } |
---|
| 2701 | #else |
---|
[313] | 2702 | READ_SVLC( data, "scaling_list_delta_coef"); |
---|
| 2703 | nextCoef = (nextCoef + data + 256 ) % 256; |
---|
| 2704 | dst[scan[i]] = nextCoef; |
---|
[442] | 2705 | #endif |
---|
[313] | 2706 | } |
---|
| 2707 | } |
---|
| 2708 | |
---|
| 2709 | Bool TDecCavlc::xMoreRbspData() |
---|
| 2710 | { |
---|
| 2711 | Int bitsLeft = m_pcBitstream->getNumBitsLeft(); |
---|
| 2712 | |
---|
| 2713 | // if there are more than 8 bits, it cannot be rbsp_trailing_bits |
---|
| 2714 | if (bitsLeft > 8) |
---|
| 2715 | { |
---|
| 2716 | return true; |
---|
| 2717 | } |
---|
| 2718 | |
---|
| 2719 | UChar lastByte = m_pcBitstream->peekBits(bitsLeft); |
---|
| 2720 | Int cnt = bitsLeft; |
---|
| 2721 | |
---|
| 2722 | // remove trailing bits equal to zero |
---|
| 2723 | while ((cnt>0) && ((lastByte & 1) == 0)) |
---|
| 2724 | { |
---|
| 2725 | lastByte >>= 1; |
---|
| 2726 | cnt--; |
---|
| 2727 | } |
---|
| 2728 | // remove bit equal to one |
---|
| 2729 | cnt--; |
---|
| 2730 | |
---|
| 2731 | // we should not have a negative number of bits |
---|
| 2732 | assert (cnt>=0); |
---|
| 2733 | |
---|
| 2734 | // we have more data, if cnt is not zero |
---|
| 2735 | return (cnt>0); |
---|
| 2736 | } |
---|
| 2737 | //! \} |
---|
| 2738 | |
---|