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