[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 | * |
---|
[595] | 6 | * Copyright (c) 2010-2014, ITU/ISO/IEC |
---|
[313] | 7 | * All rights reserved. |
---|
| 8 | * |
---|
| 9 | * Redistribution and use in source and binary forms, with or without |
---|
| 10 | * modification, are permitted provided that the following conditions are met: |
---|
| 11 | * |
---|
| 12 | * * Redistributions of source code must retain the above copyright notice, |
---|
| 13 | * this list of conditions and the following disclaimer. |
---|
| 14 | * * Redistributions in binary form must reproduce the above copyright notice, |
---|
| 15 | * this list of conditions and the following disclaimer in the documentation |
---|
| 16 | * and/or other materials provided with the distribution. |
---|
| 17 | * * Neither the name of the ITU/ISO/IEC nor the names of its contributors may |
---|
| 18 | * be used to endorse or promote products derived from this software without |
---|
| 19 | * specific prior written permission. |
---|
| 20 | * |
---|
| 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
---|
| 22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
---|
| 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
---|
| 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS |
---|
| 25 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
---|
| 26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
---|
| 27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
---|
| 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
---|
| 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
---|
| 30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
---|
| 31 | * THE POSSIBILITY OF SUCH DAMAGE. |
---|
| 32 | */ |
---|
| 33 | |
---|
| 34 | /** \file TDecCAVLC.cpp |
---|
| 35 | \brief CAVLC decoder class |
---|
| 36 | */ |
---|
| 37 | |
---|
| 38 | #include "TDecCAVLC.h" |
---|
| 39 | #include "SEIread.h" |
---|
| 40 | #include "TDecSlice.h" |
---|
| 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 | } |
---|
[442] | 292 | |
---|
[540] | 293 | #if SCALINGLIST_INFERRING |
---|
| 294 | if( pcPPS->getLayerId() > 0 ) |
---|
| 295 | { |
---|
| 296 | READ_FLAG( uiCode, "pps_infer_scaling_list_flag" ); |
---|
| 297 | pcPPS->setInferScalingListFlag( uiCode ); |
---|
| 298 | } |
---|
[442] | 299 | |
---|
[540] | 300 | if( pcPPS->getInferScalingListFlag() ) |
---|
[313] | 301 | { |
---|
[540] | 302 | READ_UVLC( uiCode, "pps_scaling_list_ref_layer_id" ); pcPPS->setScalingListRefLayerId( uiCode ); |
---|
[442] | 303 | |
---|
[540] | 304 | // The value of pps_scaling_list_ref_layer_id shall be in the range of 0 to 62, inclusive |
---|
| 305 | assert( pcPPS->getScalingListRefLayerId() <= 62 ); |
---|
[494] | 306 | |
---|
[540] | 307 | pcPPS->setScalingListPresentFlag( false ); |
---|
| 308 | } |
---|
| 309 | else |
---|
| 310 | { |
---|
| 311 | #endif |
---|
[442] | 312 | |
---|
[540] | 313 | READ_FLAG( uiCode, "pps_scaling_list_data_present_flag" ); pcPPS->setScalingListPresentFlag( uiCode ? true : false ); |
---|
[442] | 314 | |
---|
[540] | 315 | if(pcPPS->getScalingListPresentFlag ()) |
---|
| 316 | { |
---|
[313] | 317 | parseScalingList( pcPPS->getScalingList() ); |
---|
| 318 | } |
---|
| 319 | |
---|
[540] | 320 | #if SCALINGLIST_INFERRING |
---|
| 321 | } |
---|
| 322 | #endif |
---|
| 323 | |
---|
[313] | 324 | READ_FLAG( uiCode, "lists_modification_present_flag"); |
---|
| 325 | pcPPS->setListsModificationPresentFlag(uiCode); |
---|
| 326 | |
---|
| 327 | READ_UVLC( uiCode, "log2_parallel_merge_level_minus2"); |
---|
| 328 | pcPPS->setLog2ParallelMergeLevelMinus2 (uiCode); |
---|
| 329 | |
---|
| 330 | READ_FLAG( uiCode, "slice_segment_header_extension_present_flag"); |
---|
| 331 | pcPPS->setSliceHeaderExtensionPresentFlag(uiCode); |
---|
| 332 | |
---|
| 333 | READ_FLAG( uiCode, "pps_extension_flag"); |
---|
| 334 | if (uiCode) |
---|
| 335 | { |
---|
[622] | 336 | #if P0166_MODIFIED_PPS_EXTENSION |
---|
| 337 | UInt ppsExtensionTypeFlag[8]; |
---|
| 338 | for (UInt i = 0; i < 8; i++) |
---|
| 339 | { |
---|
| 340 | READ_FLAG( ppsExtensionTypeFlag[i], "pps_extension_type_flag" ); |
---|
| 341 | } |
---|
[623] | 342 | #if !POC_RESET_IDC |
---|
[622] | 343 | if (ppsExtensionTypeFlag[1]) |
---|
| 344 | { |
---|
[623] | 345 | #else |
---|
| 346 | if( ppsExtensionTypeFlag[0] ) |
---|
| 347 | { |
---|
| 348 | READ_FLAG( uiCode, "poc_reset_info_present_flag" ); |
---|
| 349 | pcPPS->setPocResetInfoPresentFlag(uiCode ? true : false); |
---|
| 350 | #endif |
---|
[622] | 351 | } |
---|
| 352 | if (ppsExtensionTypeFlag[7]) |
---|
| 353 | { |
---|
| 354 | #endif |
---|
| 355 | |
---|
[313] | 356 | while ( xMoreRbspData() ) |
---|
| 357 | { |
---|
| 358 | READ_FLAG( uiCode, "pps_extension_data_flag"); |
---|
| 359 | } |
---|
[622] | 360 | #if P0166_MODIFIED_PPS_EXTENSION |
---|
| 361 | } |
---|
| 362 | #endif |
---|
[313] | 363 | } |
---|
| 364 | } |
---|
| 365 | |
---|
| 366 | Void TDecCavlc::parseVUI(TComVUI* pcVUI, TComSPS *pcSPS) |
---|
| 367 | { |
---|
| 368 | #if ENC_DEC_TRACE |
---|
| 369 | fprintf( g_hTrace, "----------- vui_parameters -----------\n"); |
---|
| 370 | #endif |
---|
| 371 | UInt uiCode; |
---|
| 372 | |
---|
| 373 | READ_FLAG( uiCode, "aspect_ratio_info_present_flag"); pcVUI->setAspectRatioInfoPresentFlag(uiCode); |
---|
| 374 | if (pcVUI->getAspectRatioInfoPresentFlag()) |
---|
| 375 | { |
---|
| 376 | READ_CODE(8, uiCode, "aspect_ratio_idc"); pcVUI->setAspectRatioIdc(uiCode); |
---|
| 377 | if (pcVUI->getAspectRatioIdc() == 255) |
---|
| 378 | { |
---|
| 379 | READ_CODE(16, uiCode, "sar_width"); pcVUI->setSarWidth(uiCode); |
---|
| 380 | READ_CODE(16, uiCode, "sar_height"); pcVUI->setSarHeight(uiCode); |
---|
| 381 | } |
---|
| 382 | } |
---|
| 383 | |
---|
| 384 | READ_FLAG( uiCode, "overscan_info_present_flag"); pcVUI->setOverscanInfoPresentFlag(uiCode); |
---|
| 385 | if (pcVUI->getOverscanInfoPresentFlag()) |
---|
| 386 | { |
---|
| 387 | READ_FLAG( uiCode, "overscan_appropriate_flag"); pcVUI->setOverscanAppropriateFlag(uiCode); |
---|
| 388 | } |
---|
| 389 | |
---|
| 390 | READ_FLAG( uiCode, "video_signal_type_present_flag"); pcVUI->setVideoSignalTypePresentFlag(uiCode); |
---|
| 391 | if (pcVUI->getVideoSignalTypePresentFlag()) |
---|
| 392 | { |
---|
| 393 | READ_CODE(3, uiCode, "video_format"); pcVUI->setVideoFormat(uiCode); |
---|
| 394 | READ_FLAG( uiCode, "video_full_range_flag"); pcVUI->setVideoFullRangeFlag(uiCode); |
---|
| 395 | READ_FLAG( uiCode, "colour_description_present_flag"); pcVUI->setColourDescriptionPresentFlag(uiCode); |
---|
| 396 | if (pcVUI->getColourDescriptionPresentFlag()) |
---|
| 397 | { |
---|
| 398 | READ_CODE(8, uiCode, "colour_primaries"); pcVUI->setColourPrimaries(uiCode); |
---|
| 399 | READ_CODE(8, uiCode, "transfer_characteristics"); pcVUI->setTransferCharacteristics(uiCode); |
---|
| 400 | READ_CODE(8, uiCode, "matrix_coefficients"); pcVUI->setMatrixCoefficients(uiCode); |
---|
| 401 | } |
---|
| 402 | } |
---|
| 403 | |
---|
| 404 | READ_FLAG( uiCode, "chroma_loc_info_present_flag"); pcVUI->setChromaLocInfoPresentFlag(uiCode); |
---|
| 405 | if (pcVUI->getChromaLocInfoPresentFlag()) |
---|
| 406 | { |
---|
| 407 | READ_UVLC( uiCode, "chroma_sample_loc_type_top_field" ); pcVUI->setChromaSampleLocTypeTopField(uiCode); |
---|
| 408 | READ_UVLC( uiCode, "chroma_sample_loc_type_bottom_field" ); pcVUI->setChromaSampleLocTypeBottomField(uiCode); |
---|
| 409 | } |
---|
| 410 | |
---|
| 411 | READ_FLAG( uiCode, "neutral_chroma_indication_flag"); pcVUI->setNeutralChromaIndicationFlag(uiCode); |
---|
| 412 | |
---|
| 413 | READ_FLAG( uiCode, "field_seq_flag"); pcVUI->setFieldSeqFlag(uiCode); |
---|
| 414 | |
---|
| 415 | READ_FLAG(uiCode, "frame_field_info_present_flag"); pcVUI->setFrameFieldInfoPresentFlag(uiCode); |
---|
| 416 | |
---|
| 417 | READ_FLAG( uiCode, "default_display_window_flag"); |
---|
| 418 | if (uiCode != 0) |
---|
| 419 | { |
---|
| 420 | Window &defDisp = pcVUI->getDefaultDisplayWindow(); |
---|
| 421 | READ_UVLC( uiCode, "def_disp_win_left_offset" ); defDisp.setWindowLeftOffset ( uiCode * TComSPS::getWinUnitX( pcSPS->getChromaFormatIdc()) ); |
---|
| 422 | READ_UVLC( uiCode, "def_disp_win_right_offset" ); defDisp.setWindowRightOffset ( uiCode * TComSPS::getWinUnitX( pcSPS->getChromaFormatIdc()) ); |
---|
| 423 | READ_UVLC( uiCode, "def_disp_win_top_offset" ); defDisp.setWindowTopOffset ( uiCode * TComSPS::getWinUnitY( pcSPS->getChromaFormatIdc()) ); |
---|
| 424 | READ_UVLC( uiCode, "def_disp_win_bottom_offset" ); defDisp.setWindowBottomOffset( uiCode * TComSPS::getWinUnitY( pcSPS->getChromaFormatIdc()) ); |
---|
| 425 | } |
---|
| 426 | TimingInfo *timingInfo = pcVUI->getTimingInfo(); |
---|
| 427 | READ_FLAG( uiCode, "vui_timing_info_present_flag"); timingInfo->setTimingInfoPresentFlag (uiCode ? true : false); |
---|
[442] | 428 | #if TIMING_INFO_NONZERO_LAYERID_SPS |
---|
| 429 | if( pcSPS->getLayerId() > 0 ) |
---|
| 430 | { |
---|
| 431 | assert( timingInfo->getTimingInfoPresentFlag() == false ); |
---|
| 432 | } |
---|
| 433 | #endif |
---|
[313] | 434 | if(timingInfo->getTimingInfoPresentFlag()) |
---|
| 435 | { |
---|
| 436 | READ_CODE( 32, uiCode, "vui_num_units_in_tick"); timingInfo->setNumUnitsInTick (uiCode); |
---|
| 437 | READ_CODE( 32, uiCode, "vui_time_scale"); timingInfo->setTimeScale (uiCode); |
---|
| 438 | READ_FLAG( uiCode, "vui_poc_proportional_to_timing_flag"); timingInfo->setPocProportionalToTimingFlag(uiCode ? true : false); |
---|
| 439 | if(timingInfo->getPocProportionalToTimingFlag()) |
---|
| 440 | { |
---|
| 441 | READ_UVLC( uiCode, "vui_num_ticks_poc_diff_one_minus1"); timingInfo->setNumTicksPocDiffOneMinus1 (uiCode); |
---|
| 442 | } |
---|
| 443 | READ_FLAG( uiCode, "hrd_parameters_present_flag"); pcVUI->setHrdParametersPresentFlag(uiCode); |
---|
| 444 | if( pcVUI->getHrdParametersPresentFlag() ) |
---|
| 445 | { |
---|
| 446 | parseHrdParameters( pcVUI->getHrdParameters(), 1, pcSPS->getMaxTLayers() - 1 ); |
---|
| 447 | } |
---|
| 448 | } |
---|
| 449 | READ_FLAG( uiCode, "bitstream_restriction_flag"); pcVUI->setBitstreamRestrictionFlag(uiCode); |
---|
| 450 | if (pcVUI->getBitstreamRestrictionFlag()) |
---|
| 451 | { |
---|
| 452 | READ_FLAG( uiCode, "tiles_fixed_structure_flag"); pcVUI->setTilesFixedStructureFlag(uiCode); |
---|
| 453 | READ_FLAG( uiCode, "motion_vectors_over_pic_boundaries_flag"); pcVUI->setMotionVectorsOverPicBoundariesFlag(uiCode); |
---|
| 454 | READ_FLAG( uiCode, "restricted_ref_pic_lists_flag"); pcVUI->setRestrictedRefPicListsFlag(uiCode); |
---|
| 455 | READ_UVLC( uiCode, "min_spatial_segmentation_idc"); pcVUI->setMinSpatialSegmentationIdc(uiCode); |
---|
| 456 | assert(uiCode < 4096); |
---|
| 457 | READ_UVLC( uiCode, "max_bytes_per_pic_denom" ); pcVUI->setMaxBytesPerPicDenom(uiCode); |
---|
| 458 | READ_UVLC( uiCode, "max_bits_per_mincu_denom" ); pcVUI->setMaxBitsPerMinCuDenom(uiCode); |
---|
| 459 | READ_UVLC( uiCode, "log2_max_mv_length_horizontal" ); pcVUI->setLog2MaxMvLengthHorizontal(uiCode); |
---|
| 460 | READ_UVLC( uiCode, "log2_max_mv_length_vertical" ); pcVUI->setLog2MaxMvLengthVertical(uiCode); |
---|
| 461 | } |
---|
| 462 | } |
---|
| 463 | |
---|
| 464 | Void TDecCavlc::parseHrdParameters(TComHRD *hrd, Bool commonInfPresentFlag, UInt maxNumSubLayersMinus1) |
---|
| 465 | { |
---|
| 466 | UInt uiCode; |
---|
| 467 | if( commonInfPresentFlag ) |
---|
| 468 | { |
---|
| 469 | READ_FLAG( uiCode, "nal_hrd_parameters_present_flag" ); hrd->setNalHrdParametersPresentFlag( uiCode == 1 ? true : false ); |
---|
| 470 | READ_FLAG( uiCode, "vcl_hrd_parameters_present_flag" ); hrd->setVclHrdParametersPresentFlag( uiCode == 1 ? true : false ); |
---|
| 471 | if( hrd->getNalHrdParametersPresentFlag() || hrd->getVclHrdParametersPresentFlag() ) |
---|
| 472 | { |
---|
| 473 | READ_FLAG( uiCode, "sub_pic_cpb_params_present_flag" ); hrd->setSubPicCpbParamsPresentFlag( uiCode == 1 ? true : false ); |
---|
| 474 | if( hrd->getSubPicCpbParamsPresentFlag() ) |
---|
| 475 | { |
---|
| 476 | READ_CODE( 8, uiCode, "tick_divisor_minus2" ); hrd->setTickDivisorMinus2( uiCode ); |
---|
| 477 | READ_CODE( 5, uiCode, "du_cpb_removal_delay_length_minus1" ); hrd->setDuCpbRemovalDelayLengthMinus1( uiCode ); |
---|
| 478 | READ_FLAG( uiCode, "sub_pic_cpb_params_in_pic_timing_sei_flag" ); hrd->setSubPicCpbParamsInPicTimingSEIFlag( uiCode == 1 ? true : false ); |
---|
| 479 | READ_CODE( 5, uiCode, "dpb_output_delay_du_length_minus1" ); hrd->setDpbOutputDelayDuLengthMinus1( uiCode ); |
---|
| 480 | } |
---|
| 481 | READ_CODE( 4, uiCode, "bit_rate_scale" ); hrd->setBitRateScale( uiCode ); |
---|
| 482 | READ_CODE( 4, uiCode, "cpb_size_scale" ); hrd->setCpbSizeScale( uiCode ); |
---|
| 483 | if( hrd->getSubPicCpbParamsPresentFlag() ) |
---|
| 484 | { |
---|
| 485 | READ_CODE( 4, uiCode, "cpb_size_du_scale" ); hrd->setDuCpbSizeScale( uiCode ); |
---|
| 486 | } |
---|
| 487 | READ_CODE( 5, uiCode, "initial_cpb_removal_delay_length_minus1" ); hrd->setInitialCpbRemovalDelayLengthMinus1( uiCode ); |
---|
| 488 | READ_CODE( 5, uiCode, "au_cpb_removal_delay_length_minus1" ); hrd->setCpbRemovalDelayLengthMinus1( uiCode ); |
---|
| 489 | READ_CODE( 5, uiCode, "dpb_output_delay_length_minus1" ); hrd->setDpbOutputDelayLengthMinus1( uiCode ); |
---|
| 490 | } |
---|
| 491 | } |
---|
| 492 | Int i, j, nalOrVcl; |
---|
| 493 | for( i = 0; i <= maxNumSubLayersMinus1; i ++ ) |
---|
| 494 | { |
---|
| 495 | READ_FLAG( uiCode, "fixed_pic_rate_general_flag" ); hrd->setFixedPicRateFlag( i, uiCode == 1 ? true : false ); |
---|
| 496 | if( !hrd->getFixedPicRateFlag( i ) ) |
---|
| 497 | { |
---|
| 498 | READ_FLAG( uiCode, "fixed_pic_rate_within_cvs_flag" ); hrd->setFixedPicRateWithinCvsFlag( i, uiCode == 1 ? true : false ); |
---|
| 499 | } |
---|
| 500 | else |
---|
| 501 | { |
---|
| 502 | hrd->setFixedPicRateWithinCvsFlag( i, true ); |
---|
| 503 | } |
---|
| 504 | hrd->setLowDelayHrdFlag( i, 0 ); // Infered to be 0 when not present |
---|
| 505 | hrd->setCpbCntMinus1 ( i, 0 ); // Infered to be 0 when not present |
---|
| 506 | if( hrd->getFixedPicRateWithinCvsFlag( i ) ) |
---|
| 507 | { |
---|
| 508 | READ_UVLC( uiCode, "elemental_duration_in_tc_minus1" ); hrd->setPicDurationInTcMinus1( i, uiCode ); |
---|
| 509 | } |
---|
| 510 | else |
---|
| 511 | { |
---|
| 512 | READ_FLAG( uiCode, "low_delay_hrd_flag" ); hrd->setLowDelayHrdFlag( i, uiCode == 1 ? true : false ); |
---|
| 513 | } |
---|
| 514 | if (!hrd->getLowDelayHrdFlag( i )) |
---|
| 515 | { |
---|
| 516 | READ_UVLC( uiCode, "cpb_cnt_minus1" ); hrd->setCpbCntMinus1( i, uiCode ); |
---|
| 517 | } |
---|
| 518 | for( nalOrVcl = 0; nalOrVcl < 2; nalOrVcl ++ ) |
---|
| 519 | { |
---|
| 520 | if( ( ( nalOrVcl == 0 ) && ( hrd->getNalHrdParametersPresentFlag() ) ) || |
---|
| 521 | ( ( nalOrVcl == 1 ) && ( hrd->getVclHrdParametersPresentFlag() ) ) ) |
---|
| 522 | { |
---|
| 523 | for( j = 0; j <= ( hrd->getCpbCntMinus1( i ) ); j ++ ) |
---|
| 524 | { |
---|
| 525 | READ_UVLC( uiCode, "bit_rate_value_minus1" ); hrd->setBitRateValueMinus1( i, j, nalOrVcl, uiCode ); |
---|
| 526 | READ_UVLC( uiCode, "cpb_size_value_minus1" ); hrd->setCpbSizeValueMinus1( i, j, nalOrVcl, uiCode ); |
---|
| 527 | if( hrd->getSubPicCpbParamsPresentFlag() ) |
---|
| 528 | { |
---|
| 529 | READ_UVLC( uiCode, "cpb_size_du_value_minus1" ); hrd->setDuCpbSizeValueMinus1( i, j, nalOrVcl, uiCode ); |
---|
| 530 | READ_UVLC( uiCode, "bit_rate_du_value_minus1" ); hrd->setDuBitRateValueMinus1( i, j, nalOrVcl, uiCode ); |
---|
| 531 | } |
---|
| 532 | READ_FLAG( uiCode, "cbr_flag" ); hrd->setCbrFlag( i, j, nalOrVcl, uiCode == 1 ? true : false ); |
---|
| 533 | } |
---|
| 534 | } |
---|
| 535 | } |
---|
| 536 | } |
---|
| 537 | } |
---|
| 538 | |
---|
[636] | 539 | #if SVC_EXTENSION && !SPS_DPB_PARAMS |
---|
[313] | 540 | Void TDecCavlc::parseSPS(TComSPS* pcSPS, ParameterSetManagerDecoder *parameterSetManager) |
---|
| 541 | #else |
---|
| 542 | Void TDecCavlc::parseSPS(TComSPS* pcSPS) |
---|
| 543 | #endif |
---|
| 544 | { |
---|
| 545 | #if ENC_DEC_TRACE |
---|
| 546 | xTraceSPSHeader (pcSPS); |
---|
| 547 | #endif |
---|
| 548 | |
---|
| 549 | UInt uiCode; |
---|
| 550 | READ_CODE( 4, uiCode, "sps_video_parameter_set_id"); pcSPS->setVPSId ( uiCode ); |
---|
[494] | 551 | #if SVC_EXTENSION |
---|
[313] | 552 | if(pcSPS->getLayerId() == 0) |
---|
| 553 | { |
---|
| 554 | #endif |
---|
| 555 | READ_CODE( 3, uiCode, "sps_max_sub_layers_minus1" ); pcSPS->setMaxTLayers ( uiCode+1 ); |
---|
| 556 | assert(uiCode <= 6); |
---|
[494] | 557 | |
---|
[313] | 558 | READ_FLAG( uiCode, "sps_temporal_id_nesting_flag" ); pcSPS->setTemporalIdNestingFlag ( uiCode > 0 ? true : false ); |
---|
[494] | 559 | #if SVC_EXTENSION |
---|
[313] | 560 | } |
---|
[636] | 561 | #if !SPS_DPB_PARAMS |
---|
[313] | 562 | else |
---|
| 563 | { |
---|
| 564 | pcSPS->setMaxTLayers ( parameterSetManager->getPrefetchedVPS(pcSPS->getVPSId())->getMaxTLayers() ); |
---|
| 565 | pcSPS->setTemporalIdNestingFlag( parameterSetManager->getPrefetchedVPS(pcSPS->getVPSId())->getTemporalNestingFlag() ); |
---|
| 566 | } |
---|
[442] | 567 | #endif |
---|
[636] | 568 | #endif |
---|
| 569 | |
---|
[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 |
---|
[636] | 574 | #if !SPS_DPB_PARAMS |
---|
[313] | 575 | assert( pcSPS->getTemporalIdNestingFlag() == true ); |
---|
[636] | 576 | #endif |
---|
[313] | 577 | #else |
---|
| 578 | assert( uiCode == 1 ); |
---|
| 579 | #endif |
---|
| 580 | } |
---|
[442] | 581 | #ifdef SPS_PTL_FIX |
---|
| 582 | if ( pcSPS->getLayerId() == 0) |
---|
| 583 | { |
---|
| 584 | parsePTL(pcSPS->getPTL(), 1, pcSPS->getMaxTLayers() - 1); |
---|
| 585 | } |
---|
| 586 | #else |
---|
| 587 | parsePTL(pcSPS->getPTL(), 1, pcSPS->getMaxTLayers() - 1); |
---|
| 588 | #endif |
---|
[313] | 589 | |
---|
| 590 | READ_UVLC( uiCode, "sps_seq_parameter_set_id" ); pcSPS->setSPSId( uiCode ); |
---|
| 591 | assert(uiCode <= 15); |
---|
[442] | 592 | |
---|
| 593 | #if REPN_FORMAT_IN_VPS |
---|
| 594 | if( pcSPS->getLayerId() > 0 ) |
---|
[313] | 595 | { |
---|
[494] | 596 | READ_FLAG( uiCode, "update_rep_format_flag" ); |
---|
[442] | 597 | pcSPS->setUpdateRepFormatFlag( uiCode ? true : false ); |
---|
[313] | 598 | } |
---|
[442] | 599 | else |
---|
| 600 | { |
---|
| 601 | pcSPS->setUpdateRepFormatFlag( true ); |
---|
| 602 | } |
---|
[540] | 603 | #if O0096_REP_FORMAT_INDEX |
---|
| 604 | if( pcSPS->getLayerId() == 0 ) |
---|
| 605 | #else |
---|
[494] | 606 | if( pcSPS->getLayerId() == 0 || pcSPS->getUpdateRepFormatFlag() ) |
---|
[540] | 607 | #endif |
---|
[442] | 608 | { |
---|
| 609 | #endif |
---|
[494] | 610 | #if AUXILIARY_PICTURES |
---|
| 611 | READ_UVLC( uiCode, "chroma_format_idc" ); pcSPS->setChromaFormatIdc( ChromaFormat(uiCode) ); |
---|
| 612 | #else |
---|
[442] | 613 | READ_UVLC( uiCode, "chroma_format_idc" ); pcSPS->setChromaFormatIdc( uiCode ); |
---|
[494] | 614 | #endif |
---|
[442] | 615 | assert(uiCode <= 3); |
---|
| 616 | // 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 |
---|
| 617 | assert (uiCode == 1); |
---|
| 618 | if( uiCode == 3 ) |
---|
| 619 | { |
---|
| 620 | READ_FLAG( uiCode, "separate_colour_plane_flag"); assert(uiCode == 0); |
---|
| 621 | } |
---|
[313] | 622 | |
---|
[442] | 623 | READ_UVLC ( uiCode, "pic_width_in_luma_samples" ); pcSPS->setPicWidthInLumaSamples ( uiCode ); |
---|
| 624 | READ_UVLC ( uiCode, "pic_height_in_luma_samples" ); pcSPS->setPicHeightInLumaSamples( uiCode ); |
---|
| 625 | #if REPN_FORMAT_IN_VPS |
---|
| 626 | } |
---|
[540] | 627 | #if O0096_REP_FORMAT_INDEX |
---|
| 628 | else if ( pcSPS->getUpdateRepFormatFlag() ) |
---|
| 629 | { |
---|
| 630 | READ_CODE(8, uiCode, "update_rep_format_index"); |
---|
| 631 | pcSPS->setUpdateRepFormatIndex(uiCode); |
---|
| 632 | } |
---|
[442] | 633 | #endif |
---|
[540] | 634 | #endif |
---|
[313] | 635 | READ_FLAG( uiCode, "conformance_window_flag"); |
---|
| 636 | if (uiCode != 0) |
---|
| 637 | { |
---|
| 638 | Window &conf = pcSPS->getConformanceWindow(); |
---|
[442] | 639 | #if REPN_FORMAT_IN_VPS |
---|
| 640 | READ_UVLC( uiCode, "conf_win_left_offset" ); conf.setWindowLeftOffset ( uiCode ); |
---|
| 641 | READ_UVLC( uiCode, "conf_win_right_offset" ); conf.setWindowRightOffset ( uiCode ); |
---|
| 642 | READ_UVLC( uiCode, "conf_win_top_offset" ); conf.setWindowTopOffset ( uiCode ); |
---|
| 643 | READ_UVLC( uiCode, "conf_win_bottom_offset" ); conf.setWindowBottomOffset( uiCode ); |
---|
| 644 | #else |
---|
[313] | 645 | READ_UVLC( uiCode, "conf_win_left_offset" ); conf.setWindowLeftOffset ( uiCode * TComSPS::getWinUnitX( pcSPS->getChromaFormatIdc() ) ); |
---|
| 646 | READ_UVLC( uiCode, "conf_win_right_offset" ); conf.setWindowRightOffset ( uiCode * TComSPS::getWinUnitX( pcSPS->getChromaFormatIdc() ) ); |
---|
| 647 | READ_UVLC( uiCode, "conf_win_top_offset" ); conf.setWindowTopOffset ( uiCode * TComSPS::getWinUnitY( pcSPS->getChromaFormatIdc() ) ); |
---|
| 648 | READ_UVLC( uiCode, "conf_win_bottom_offset" ); conf.setWindowBottomOffset( uiCode * TComSPS::getWinUnitY( pcSPS->getChromaFormatIdc() ) ); |
---|
[442] | 649 | #endif |
---|
[313] | 650 | } |
---|
[442] | 651 | #if REPN_FORMAT_IN_VPS |
---|
[540] | 652 | #if O0096_REP_FORMAT_INDEX |
---|
| 653 | if( pcSPS->getLayerId() == 0 ) |
---|
| 654 | #else |
---|
[494] | 655 | if( pcSPS->getLayerId() == 0 || pcSPS->getUpdateRepFormatFlag() ) |
---|
[540] | 656 | #endif |
---|
[442] | 657 | { |
---|
| 658 | #endif |
---|
| 659 | READ_UVLC( uiCode, "bit_depth_luma_minus8" ); |
---|
| 660 | assert(uiCode <= 6); |
---|
| 661 | pcSPS->setBitDepthY( uiCode + 8 ); |
---|
| 662 | pcSPS->setQpBDOffsetY( (Int) (6*uiCode) ); |
---|
[313] | 663 | |
---|
[442] | 664 | READ_UVLC( uiCode, "bit_depth_chroma_minus8" ); |
---|
| 665 | assert(uiCode <= 6); |
---|
| 666 | pcSPS->setBitDepthC( uiCode + 8 ); |
---|
| 667 | pcSPS->setQpBDOffsetC( (Int) (6*uiCode) ); |
---|
| 668 | #if REPN_FORMAT_IN_VPS |
---|
| 669 | } |
---|
| 670 | #endif |
---|
[313] | 671 | READ_UVLC( uiCode, "log2_max_pic_order_cnt_lsb_minus4" ); pcSPS->setBitsForPOC( 4 + uiCode ); |
---|
| 672 | assert(uiCode <= 12); |
---|
| 673 | |
---|
[613] | 674 | #if SPS_DPB_PARAMS |
---|
[619] | 675 | if( pcSPS->getLayerId() == 0 ) |
---|
| 676 | { |
---|
[613] | 677 | #endif |
---|
| 678 | UInt subLayerOrderingInfoPresentFlag; |
---|
[619] | 679 | READ_FLAG(subLayerOrderingInfoPresentFlag, "sps_sub_layer_ordering_info_present_flag"); |
---|
[494] | 680 | |
---|
[619] | 681 | for(UInt i=0; i <= pcSPS->getMaxTLayers()-1; i++) |
---|
| 682 | { |
---|
| 683 | READ_UVLC ( uiCode, "sps_max_dec_pic_buffering_minus1"); |
---|
| 684 | pcSPS->setMaxDecPicBuffering( uiCode + 1, i); |
---|
| 685 | READ_UVLC ( uiCode, "sps_num_reorder_pics" ); |
---|
| 686 | pcSPS->setNumReorderPics(uiCode, i); |
---|
| 687 | READ_UVLC ( uiCode, "sps_max_latency_increase_plus1"); |
---|
| 688 | pcSPS->setMaxLatencyIncrease( uiCode, i ); |
---|
[313] | 689 | |
---|
[619] | 690 | if (!subLayerOrderingInfoPresentFlag) |
---|
[313] | 691 | { |
---|
[619] | 692 | for (i++; i <= pcSPS->getMaxTLayers()-1; i++) |
---|
| 693 | { |
---|
| 694 | pcSPS->setMaxDecPicBuffering(pcSPS->getMaxDecPicBuffering(0), i); |
---|
| 695 | pcSPS->setNumReorderPics(pcSPS->getNumReorderPics(0), i); |
---|
| 696 | pcSPS->setMaxLatencyIncrease(pcSPS->getMaxLatencyIncrease(0), i); |
---|
| 697 | } |
---|
| 698 | break; |
---|
[313] | 699 | } |
---|
| 700 | } |
---|
[619] | 701 | #if SPS_DPB_PARAMS |
---|
[313] | 702 | } |
---|
[613] | 703 | #endif |
---|
[313] | 704 | READ_UVLC( uiCode, "log2_min_coding_block_size_minus3" ); |
---|
| 705 | Int log2MinCUSize = uiCode + 3; |
---|
| 706 | pcSPS->setLog2MinCodingBlockSize(log2MinCUSize); |
---|
| 707 | READ_UVLC( uiCode, "log2_diff_max_min_coding_block_size" ); |
---|
| 708 | pcSPS->setLog2DiffMaxMinCodingBlockSize(uiCode); |
---|
[595] | 709 | |
---|
| 710 | if (pcSPS->getPTL()->getGeneralPTL()->getLevelIdc() >= Level::LEVEL5) |
---|
| 711 | { |
---|
| 712 | assert(log2MinCUSize + pcSPS->getLog2DiffMaxMinCodingBlockSize() >= 5); |
---|
| 713 | } |
---|
| 714 | |
---|
[313] | 715 | Int maxCUDepthDelta = uiCode; |
---|
| 716 | pcSPS->setMaxCUWidth ( 1<<(log2MinCUSize + maxCUDepthDelta) ); |
---|
| 717 | pcSPS->setMaxCUHeight ( 1<<(log2MinCUSize + maxCUDepthDelta) ); |
---|
| 718 | READ_UVLC( uiCode, "log2_min_transform_block_size_minus2" ); pcSPS->setQuadtreeTULog2MinSize( uiCode + 2 ); |
---|
| 719 | |
---|
| 720 | READ_UVLC( uiCode, "log2_diff_max_min_transform_block_size" ); pcSPS->setQuadtreeTULog2MaxSize( uiCode + pcSPS->getQuadtreeTULog2MinSize() ); |
---|
| 721 | pcSPS->setMaxTrSize( 1<<(uiCode + pcSPS->getQuadtreeTULog2MinSize()) ); |
---|
| 722 | |
---|
| 723 | READ_UVLC( uiCode, "max_transform_hierarchy_depth_inter" ); pcSPS->setQuadtreeTUMaxDepthInter( uiCode+1 ); |
---|
| 724 | READ_UVLC( uiCode, "max_transform_hierarchy_depth_intra" ); pcSPS->setQuadtreeTUMaxDepthIntra( uiCode+1 ); |
---|
| 725 | |
---|
| 726 | Int addCuDepth = max (0, log2MinCUSize - (Int)pcSPS->getQuadtreeTULog2MinSize() ); |
---|
| 727 | pcSPS->setMaxCUDepth( maxCUDepthDelta + addCuDepth ); |
---|
[442] | 728 | READ_FLAG( uiCode, "scaling_list_enabled_flag" ); pcSPS->setScalingListFlag ( uiCode ); |
---|
[313] | 729 | |
---|
| 730 | if(pcSPS->getScalingListFlag()) |
---|
| 731 | { |
---|
[540] | 732 | #if SCALINGLIST_INFERRING |
---|
| 733 | if( pcSPS->getLayerId() > 0 ) |
---|
[313] | 734 | { |
---|
[540] | 735 | READ_FLAG( uiCode, "sps_infer_scaling_list_flag" ); pcSPS->setInferScalingListFlag( uiCode ); |
---|
| 736 | } |
---|
[442] | 737 | |
---|
[540] | 738 | if( pcSPS->getInferScalingListFlag() ) |
---|
| 739 | { |
---|
| 740 | READ_UVLC( uiCode, "sps_scaling_list_ref_layer_id" ); pcSPS->setScalingListRefLayerId( uiCode ); |
---|
[442] | 741 | |
---|
[540] | 742 | // The value of pps_scaling_list_ref_layer_id shall be in the range of 0 to 62, inclusive |
---|
| 743 | assert( pcSPS->getScalingListRefLayerId() <= 62 ); |
---|
[442] | 744 | |
---|
[540] | 745 | pcSPS->setScalingListPresentFlag( false ); |
---|
| 746 | } |
---|
| 747 | else |
---|
| 748 | { |
---|
| 749 | #endif |
---|
| 750 | READ_FLAG( uiCode, "sps_scaling_list_data_present_flag" ); pcSPS->setScalingListPresentFlag ( uiCode ); |
---|
| 751 | if(pcSPS->getScalingListPresentFlag ()) |
---|
| 752 | { |
---|
[313] | 753 | parseScalingList( pcSPS->getScalingList() ); |
---|
[540] | 754 | } |
---|
| 755 | #if SCALINGLIST_INFERRING |
---|
| 756 | } |
---|
[442] | 757 | #endif |
---|
[313] | 758 | } |
---|
| 759 | READ_FLAG( uiCode, "amp_enabled_flag" ); pcSPS->setUseAMP( uiCode ); |
---|
| 760 | READ_FLAG( uiCode, "sample_adaptive_offset_enabled_flag" ); pcSPS->setUseSAO ( uiCode ? true : false ); |
---|
| 761 | |
---|
| 762 | READ_FLAG( uiCode, "pcm_enabled_flag" ); pcSPS->setUsePCM( uiCode ? true : false ); |
---|
| 763 | if( pcSPS->getUsePCM() ) |
---|
| 764 | { |
---|
| 765 | READ_CODE( 4, uiCode, "pcm_sample_bit_depth_luma_minus1" ); pcSPS->setPCMBitDepthLuma ( 1 + uiCode ); |
---|
| 766 | READ_CODE( 4, uiCode, "pcm_sample_bit_depth_chroma_minus1" ); pcSPS->setPCMBitDepthChroma ( 1 + uiCode ); |
---|
| 767 | READ_UVLC( uiCode, "log2_min_pcm_luma_coding_block_size_minus3" ); pcSPS->setPCMLog2MinSize (uiCode+3); |
---|
| 768 | READ_UVLC( uiCode, "log2_diff_max_min_pcm_luma_coding_block_size" ); pcSPS->setPCMLog2MaxSize ( uiCode+pcSPS->getPCMLog2MinSize() ); |
---|
| 769 | READ_FLAG( uiCode, "pcm_loop_filter_disable_flag" ); pcSPS->setPCMFilterDisableFlag ( uiCode ? true : false ); |
---|
| 770 | } |
---|
| 771 | |
---|
| 772 | READ_UVLC( uiCode, "num_short_term_ref_pic_sets" ); |
---|
| 773 | assert(uiCode <= 64); |
---|
| 774 | pcSPS->createRPSList(uiCode); |
---|
| 775 | |
---|
| 776 | TComRPSList* rpsList = pcSPS->getRPSList(); |
---|
| 777 | TComReferencePictureSet* rps; |
---|
| 778 | |
---|
| 779 | for(UInt i=0; i< rpsList->getNumberOfReferencePictureSets(); i++) |
---|
| 780 | { |
---|
| 781 | rps = rpsList->getReferencePictureSet(i); |
---|
| 782 | parseShortTermRefPicSet(pcSPS,rps,i); |
---|
| 783 | } |
---|
| 784 | READ_FLAG( uiCode, "long_term_ref_pics_present_flag" ); pcSPS->setLongTermRefsPresent(uiCode); |
---|
| 785 | if (pcSPS->getLongTermRefsPresent()) |
---|
| 786 | { |
---|
| 787 | READ_UVLC( uiCode, "num_long_term_ref_pic_sps" ); |
---|
| 788 | pcSPS->setNumLongTermRefPicSPS(uiCode); |
---|
| 789 | for (UInt k = 0; k < pcSPS->getNumLongTermRefPicSPS(); k++) |
---|
| 790 | { |
---|
| 791 | READ_CODE( pcSPS->getBitsForPOC(), uiCode, "lt_ref_pic_poc_lsb_sps" ); |
---|
| 792 | pcSPS->setLtRefPicPocLsbSps(k, uiCode); |
---|
| 793 | READ_FLAG( uiCode, "used_by_curr_pic_lt_sps_flag[i]"); |
---|
| 794 | pcSPS->setUsedByCurrPicLtSPSFlag(k, uiCode?1:0); |
---|
| 795 | } |
---|
| 796 | } |
---|
| 797 | READ_FLAG( uiCode, "sps_temporal_mvp_enable_flag" ); pcSPS->setTMVPFlagsPresent(uiCode); |
---|
| 798 | READ_FLAG( uiCode, "sps_strong_intra_smoothing_enable_flag" ); pcSPS->setUseStrongIntraSmoothing(uiCode); |
---|
| 799 | |
---|
| 800 | READ_FLAG( uiCode, "vui_parameters_present_flag" ); pcSPS->setVuiParametersPresentFlag(uiCode); |
---|
| 801 | |
---|
| 802 | if (pcSPS->getVuiParametersPresentFlag()) |
---|
| 803 | { |
---|
| 804 | parseVUI(pcSPS->getVuiParameters(), pcSPS); |
---|
| 805 | } |
---|
| 806 | |
---|
| 807 | READ_FLAG( uiCode, "sps_extension_flag"); |
---|
| 808 | if (uiCode) |
---|
| 809 | { |
---|
| 810 | #if SPS_EXTENSION |
---|
[540] | 811 | |
---|
| 812 | #if O0142_CONDITIONAL_SPS_EXTENSION |
---|
| 813 | UInt spsExtensionTypeFlag[8]; |
---|
| 814 | for (UInt i = 0; i < 8; i++) |
---|
| 815 | { |
---|
| 816 | READ_FLAG( spsExtensionTypeFlag[i], "sps_extension_type_flag" ); |
---|
| 817 | } |
---|
| 818 | if (spsExtensionTypeFlag[1]) |
---|
| 819 | { |
---|
| 820 | parseSPSExtension( pcSPS ); |
---|
| 821 | } |
---|
| 822 | if (spsExtensionTypeFlag[7]) |
---|
| 823 | { |
---|
| 824 | #else |
---|
[313] | 825 | parseSPSExtension( pcSPS ); |
---|
| 826 | READ_FLAG( uiCode, "sps_extension2_flag"); |
---|
| 827 | if(uiCode) |
---|
| 828 | { |
---|
| 829 | #endif |
---|
[540] | 830 | |
---|
| 831 | #endif |
---|
[313] | 832 | while ( xMoreRbspData() ) |
---|
| 833 | { |
---|
| 834 | READ_FLAG( uiCode, "sps_extension_data_flag"); |
---|
| 835 | } |
---|
| 836 | #if SPS_EXTENSION |
---|
| 837 | } |
---|
| 838 | #endif |
---|
| 839 | } |
---|
| 840 | } |
---|
| 841 | |
---|
| 842 | #if SPS_EXTENSION |
---|
| 843 | Void TDecCavlc::parseSPSExtension( TComSPS* pcSPS ) |
---|
| 844 | { |
---|
| 845 | UInt uiCode; |
---|
| 846 | // more syntax elements to be parsed here |
---|
[442] | 847 | |
---|
| 848 | READ_FLAG( uiCode, "inter_view_mv_vert_constraint_flag" ); |
---|
| 849 | // Vertical MV component restriction is not used in SHVC CTC |
---|
| 850 | assert( uiCode == 0 ); |
---|
[588] | 851 | |
---|
[313] | 852 | if( pcSPS->getLayerId() > 0 ) |
---|
| 853 | { |
---|
[494] | 854 | Int iCode; |
---|
[313] | 855 | READ_UVLC( uiCode, "num_scaled_ref_layer_offsets" ); pcSPS->setNumScaledRefLayerOffsets(uiCode); |
---|
| 856 | for(Int i = 0; i < pcSPS->getNumScaledRefLayerOffsets(); i++) |
---|
| 857 | { |
---|
| 858 | Window& scaledWindow = pcSPS->getScaledRefLayerWindow(i); |
---|
[540] | 859 | #if O0098_SCALED_REF_LAYER_ID |
---|
[633] | 860 | READ_CODE( 6, uiCode, "scaled_ref_layer_id" ); pcSPS->setScaledRefLayerId( i, uiCode ); |
---|
[540] | 861 | #endif |
---|
[313] | 862 | READ_SVLC( iCode, "scaled_ref_layer_left_offset" ); scaledWindow.setWindowLeftOffset (iCode << 1); |
---|
| 863 | READ_SVLC( iCode, "scaled_ref_layer_top_offset" ); scaledWindow.setWindowTopOffset (iCode << 1); |
---|
| 864 | READ_SVLC( iCode, "scaled_ref_layer_right_offset" ); scaledWindow.setWindowRightOffset (iCode << 1); |
---|
| 865 | READ_SVLC( iCode, "scaled_ref_layer_bottom_offset" ); scaledWindow.setWindowBottomOffset(iCode << 1); |
---|
[627] | 866 | #if P0312_VERT_PHASE_ADJ |
---|
[633] | 867 | READ_FLAG( uiCode, "vert_phase_position_enable_flag" ); scaledWindow.setVertPhasePositionEnableFlag(uiCode); pcSPS->setVertPhasePositionEnableFlag( pcSPS->getScaledRefLayerId(i), uiCode); |
---|
[627] | 868 | #endif |
---|
[313] | 869 | } |
---|
| 870 | } |
---|
| 871 | } |
---|
| 872 | #endif |
---|
| 873 | |
---|
| 874 | Void TDecCavlc::parseVPS(TComVPS* pcVPS) |
---|
| 875 | { |
---|
| 876 | UInt uiCode; |
---|
| 877 | |
---|
| 878 | READ_CODE( 4, uiCode, "vps_video_parameter_set_id" ); pcVPS->setVPSId( uiCode ); |
---|
| 879 | READ_CODE( 2, uiCode, "vps_reserved_three_2bits" ); assert(uiCode == 3); |
---|
| 880 | #if VPS_RENAME |
---|
[547] | 881 | #if O0137_MAX_LAYERID |
---|
| 882 | READ_CODE( 6, uiCode, "vps_max_layers_minus1" ); pcVPS->setMaxLayers( min( 62u, uiCode) + 1 ); |
---|
[313] | 883 | #else |
---|
[547] | 884 | READ_CODE( 6, uiCode, "vps_max_layers_minus1" ); pcVPS->setMaxLayers( uiCode + 1 ); |
---|
| 885 | #endif |
---|
| 886 | #else |
---|
[313] | 887 | READ_CODE( 6, uiCode, "vps_reserved_zero_6bits" ); assert(uiCode == 0); |
---|
| 888 | #endif |
---|
[610] | 889 | READ_CODE( 3, uiCode, "vps_max_sub_layers_minus1" ); pcVPS->setMaxTLayers( uiCode + 1 ); assert(uiCode <= 6); |
---|
[313] | 890 | READ_FLAG( uiCode, "vps_temporal_id_nesting_flag" ); pcVPS->setTemporalNestingFlag( uiCode ? true:false ); |
---|
| 891 | assert (pcVPS->getMaxTLayers()>1||pcVPS->getTemporalNestingFlag()); |
---|
[588] | 892 | #if !P0125_REVERT_VPS_EXTN_OFFSET_TO_RESERVED |
---|
[442] | 893 | #if VPS_EXTN_OFFSET |
---|
| 894 | READ_CODE( 16, uiCode, "vps_extension_offset" ); pcVPS->setExtensionOffset( uiCode ); |
---|
| 895 | #else |
---|
[313] | 896 | READ_CODE( 16, uiCode, "vps_reserved_ffff_16bits" ); assert(uiCode == 0xffff); |
---|
[442] | 897 | #endif |
---|
[588] | 898 | #else |
---|
| 899 | READ_CODE( 16, uiCode, "vps_reserved_ffff_16bits" ); assert(uiCode == 0xffff); |
---|
| 900 | #endif |
---|
[313] | 901 | parsePTL ( pcVPS->getPTL(), true, pcVPS->getMaxTLayers()-1); |
---|
| 902 | UInt subLayerOrderingInfoPresentFlag; |
---|
| 903 | READ_FLAG(subLayerOrderingInfoPresentFlag, "vps_sub_layer_ordering_info_present_flag"); |
---|
| 904 | for(UInt i = 0; i <= pcVPS->getMaxTLayers()-1; i++) |
---|
| 905 | { |
---|
| 906 | READ_UVLC( uiCode, "vps_max_dec_pic_buffering_minus1[i]" ); pcVPS->setMaxDecPicBuffering( uiCode + 1, i ); |
---|
| 907 | READ_UVLC( uiCode, "vps_num_reorder_pics[i]" ); pcVPS->setNumReorderPics( uiCode, i ); |
---|
| 908 | READ_UVLC( uiCode, "vps_max_latency_increase_plus1[i]" ); pcVPS->setMaxLatencyIncrease( uiCode, i ); |
---|
| 909 | |
---|
| 910 | if (!subLayerOrderingInfoPresentFlag) |
---|
| 911 | { |
---|
| 912 | for (i++; i <= pcVPS->getMaxTLayers()-1; i++) |
---|
| 913 | { |
---|
| 914 | pcVPS->setMaxDecPicBuffering(pcVPS->getMaxDecPicBuffering(0), i); |
---|
| 915 | pcVPS->setNumReorderPics(pcVPS->getNumReorderPics(0), i); |
---|
| 916 | pcVPS->setMaxLatencyIncrease(pcVPS->getMaxLatencyIncrease(0), i); |
---|
| 917 | } |
---|
| 918 | break; |
---|
| 919 | } |
---|
| 920 | } |
---|
| 921 | |
---|
| 922 | #if VPS_RENAME |
---|
| 923 | assert( pcVPS->getNumHrdParameters() < MAX_VPS_LAYER_SETS_PLUS1 ); |
---|
| 924 | assert( pcVPS->getMaxLayerId() < MAX_VPS_LAYER_ID_PLUS1 ); |
---|
| 925 | READ_CODE( 6, uiCode, "vps_max_layer_id" ); pcVPS->setMaxLayerId( uiCode ); |
---|
| 926 | READ_UVLC( uiCode, "vps_num_layer_sets_minus1" ); pcVPS->setNumLayerSets( uiCode + 1 ); |
---|
| 927 | for( UInt opsIdx = 1; opsIdx <= ( pcVPS->getNumLayerSets() - 1 ); opsIdx ++ ) |
---|
| 928 | { |
---|
| 929 | // Operation point set |
---|
| 930 | for( UInt i = 0; i <= pcVPS->getMaxLayerId(); i ++ ) |
---|
| 931 | #else |
---|
| 932 | assert( pcVPS->getNumHrdParameters() < MAX_VPS_OP_SETS_PLUS1 ); |
---|
| 933 | assert( pcVPS->getMaxNuhReservedZeroLayerId() < MAX_VPS_NUH_RESERVED_ZERO_LAYER_ID_PLUS1 ); |
---|
| 934 | READ_CODE( 6, uiCode, "vps_max_nuh_reserved_zero_layer_id" ); pcVPS->setMaxNuhReservedZeroLayerId( uiCode ); |
---|
| 935 | READ_UVLC( uiCode, "vps_max_op_sets_minus1" ); pcVPS->setMaxOpSets( uiCode + 1 ); |
---|
| 936 | for( UInt opsIdx = 1; opsIdx <= ( pcVPS->getMaxOpSets() - 1 ); opsIdx ++ ) |
---|
| 937 | { |
---|
| 938 | // Operation point set |
---|
| 939 | for( UInt i = 0; i <= pcVPS->getMaxNuhReservedZeroLayerId(); i ++ ) |
---|
| 940 | #endif |
---|
| 941 | { |
---|
| 942 | READ_FLAG( uiCode, "layer_id_included_flag[opsIdx][i]" ); pcVPS->setLayerIdIncludedFlag( uiCode == 1 ? true : false, opsIdx, i ); |
---|
| 943 | } |
---|
| 944 | } |
---|
| 945 | #if DERIVE_LAYER_ID_LIST_VARIABLES |
---|
| 946 | pcVPS->deriveLayerIdListVariables(); |
---|
| 947 | #endif |
---|
| 948 | TimingInfo *timingInfo = pcVPS->getTimingInfo(); |
---|
| 949 | READ_FLAG( uiCode, "vps_timing_info_present_flag"); timingInfo->setTimingInfoPresentFlag (uiCode ? true : false); |
---|
| 950 | if(timingInfo->getTimingInfoPresentFlag()) |
---|
| 951 | { |
---|
| 952 | READ_CODE( 32, uiCode, "vps_num_units_in_tick"); timingInfo->setNumUnitsInTick (uiCode); |
---|
| 953 | READ_CODE( 32, uiCode, "vps_time_scale"); timingInfo->setTimeScale (uiCode); |
---|
| 954 | READ_FLAG( uiCode, "vps_poc_proportional_to_timing_flag"); timingInfo->setPocProportionalToTimingFlag(uiCode ? true : false); |
---|
| 955 | if(timingInfo->getPocProportionalToTimingFlag()) |
---|
| 956 | { |
---|
| 957 | READ_UVLC( uiCode, "vps_num_ticks_poc_diff_one_minus1"); timingInfo->setNumTicksPocDiffOneMinus1 (uiCode); |
---|
| 958 | } |
---|
| 959 | READ_UVLC( uiCode, "vps_num_hrd_parameters" ); pcVPS->setNumHrdParameters( uiCode ); |
---|
| 960 | |
---|
| 961 | if( pcVPS->getNumHrdParameters() > 0 ) |
---|
| 962 | { |
---|
| 963 | pcVPS->createHrdParamBuffer(); |
---|
| 964 | } |
---|
| 965 | for( UInt i = 0; i < pcVPS->getNumHrdParameters(); i ++ ) |
---|
| 966 | { |
---|
| 967 | READ_UVLC( uiCode, "hrd_op_set_idx" ); pcVPS->setHrdOpSetIdx( uiCode, i ); |
---|
| 968 | if( i > 0 ) |
---|
| 969 | { |
---|
| 970 | READ_FLAG( uiCode, "cprms_present_flag[i]" ); pcVPS->setCprmsPresentFlag( uiCode == 1 ? true : false, i ); |
---|
| 971 | } |
---|
| 972 | parseHrdParameters(pcVPS->getHrdParameters(i), pcVPS->getCprmsPresentFlag( i ), pcVPS->getMaxTLayers() - 1); |
---|
| 973 | } |
---|
| 974 | } |
---|
| 975 | READ_FLAG( uiCode, "vps_extension_flag" ); |
---|
| 976 | if (uiCode) |
---|
| 977 | { |
---|
| 978 | #if VPS_EXTNS |
---|
[442] | 979 | while ( m_pcBitstream->getNumBitsRead() % 8 != 0 ) |
---|
| 980 | { |
---|
| 981 | READ_FLAG( uiCode, "vps_extension_alignment_bit_equal_to_one"); assert(uiCode == 1); |
---|
| 982 | } |
---|
[313] | 983 | parseVPSExtension(pcVPS); |
---|
| 984 | READ_FLAG( uiCode, "vps_entension2_flag" ); |
---|
| 985 | if(uiCode) |
---|
| 986 | { |
---|
| 987 | while ( xMoreRbspData() ) |
---|
| 988 | { |
---|
| 989 | READ_FLAG( uiCode, "vps_extension_data_flag"); |
---|
| 990 | } |
---|
| 991 | } |
---|
| 992 | #else |
---|
| 993 | while ( xMoreRbspData() ) |
---|
| 994 | { |
---|
| 995 | READ_FLAG( uiCode, "vps_extension_data_flag"); |
---|
| 996 | } |
---|
| 997 | #endif |
---|
| 998 | } |
---|
| 999 | |
---|
| 1000 | return; |
---|
| 1001 | } |
---|
| 1002 | |
---|
[494] | 1003 | #if SVC_EXTENSION |
---|
[313] | 1004 | #if VPS_EXTNS |
---|
| 1005 | Void TDecCavlc::parseVPSExtension(TComVPS *vps) |
---|
| 1006 | { |
---|
| 1007 | UInt uiCode; |
---|
| 1008 | // ... More syntax elements to be parsed here |
---|
[602] | 1009 | #if P0300_ALT_OUTPUT_LAYER_FLAG |
---|
| 1010 | Int NumOutputLayersInOutputLayerSet[MAX_VPS_LAYER_SETS_PLUS1]; |
---|
| 1011 | Int OlsHighestOutputLayerId[MAX_VPS_LAYER_SETS_PLUS1]; |
---|
| 1012 | #endif |
---|
[313] | 1013 | #if VPS_EXTN_MASK_AND_DIM_INFO |
---|
| 1014 | UInt numScalabilityTypes = 0, i = 0, j = 0; |
---|
| 1015 | |
---|
| 1016 | READ_FLAG( uiCode, "avc_base_layer_flag" ); vps->setAvcBaseLayerFlag(uiCode ? true : false); |
---|
[547] | 1017 | |
---|
[588] | 1018 | #if !P0307_REMOVE_VPS_VUI_OFFSET |
---|
[547] | 1019 | #if O0109_MOVE_VPS_VUI_FLAG |
---|
| 1020 | READ_FLAG( uiCode, "vps_vui_present_flag"); vps->setVpsVuiPresentFlag(uiCode ? true : false); |
---|
| 1021 | if ( uiCode ) |
---|
| 1022 | { |
---|
| 1023 | #endif |
---|
| 1024 | #if VPS_VUI_OFFSET |
---|
| 1025 | READ_CODE( 16, uiCode, "vps_vui_offset" ); vps->setVpsVuiOffset( uiCode ); |
---|
| 1026 | #endif |
---|
| 1027 | #if O0109_MOVE_VPS_VUI_FLAG |
---|
| 1028 | } |
---|
| 1029 | #endif |
---|
[588] | 1030 | #endif |
---|
[313] | 1031 | READ_FLAG( uiCode, "splitting_flag" ); vps->setSplittingFlag(uiCode ? true : false); |
---|
| 1032 | |
---|
| 1033 | for(i = 0; i < MAX_VPS_NUM_SCALABILITY_TYPES; i++) |
---|
| 1034 | { |
---|
| 1035 | READ_FLAG( uiCode, "scalability_mask[i]" ); vps->setScalabilityMask(i, uiCode ? true : false); |
---|
| 1036 | numScalabilityTypes += uiCode; |
---|
| 1037 | } |
---|
| 1038 | vps->setNumScalabilityTypes(numScalabilityTypes); |
---|
| 1039 | |
---|
| 1040 | for(j = 0; j < numScalabilityTypes - vps->getSplittingFlag(); j++) |
---|
| 1041 | { |
---|
| 1042 | READ_CODE( 3, uiCode, "dimension_id_len_minus1[j]" ); vps->setDimensionIdLen(j, uiCode + 1); |
---|
| 1043 | } |
---|
[494] | 1044 | |
---|
[313] | 1045 | if(vps->getSplittingFlag()) |
---|
| 1046 | { |
---|
| 1047 | UInt numBits = 0; |
---|
| 1048 | for(j = 0; j < numScalabilityTypes - 1; j++) |
---|
| 1049 | { |
---|
| 1050 | numBits += vps->getDimensionIdLen(j); |
---|
| 1051 | } |
---|
| 1052 | assert( numBits < 6 ); |
---|
| 1053 | vps->setDimensionIdLen(numScalabilityTypes-1, 6 - numBits); |
---|
| 1054 | numBits = 6; |
---|
| 1055 | } |
---|
| 1056 | |
---|
| 1057 | READ_FLAG( uiCode, "vps_nuh_layer_id_present_flag" ); vps->setNuhLayerIdPresentFlag(uiCode ? true : false); |
---|
| 1058 | vps->setLayerIdInNuh(0, 0); |
---|
| 1059 | vps->setLayerIdInVps(0, 0); |
---|
| 1060 | for(i = 1; i < vps->getMaxLayers(); i++) |
---|
| 1061 | { |
---|
| 1062 | if( vps->getNuhLayerIdPresentFlag() ) |
---|
| 1063 | { |
---|
| 1064 | READ_CODE( 6, uiCode, "layer_id_in_nuh[i]" ); vps->setLayerIdInNuh(i, uiCode); |
---|
| 1065 | assert( uiCode > vps->getLayerIdInNuh(i-1) ); |
---|
| 1066 | } |
---|
| 1067 | else |
---|
| 1068 | { |
---|
| 1069 | vps->setLayerIdInNuh(i, i); |
---|
| 1070 | } |
---|
| 1071 | vps->setLayerIdInVps(vps->getLayerIdInNuh(i), i); |
---|
| 1072 | |
---|
[494] | 1073 | if( !vps->getSplittingFlag() ) |
---|
| 1074 | { |
---|
[313] | 1075 | for(j = 0; j < numScalabilityTypes; j++) |
---|
| 1076 | { |
---|
| 1077 | READ_CODE( vps->getDimensionIdLen(j), uiCode, "dimension_id[i][j]" ); vps->setDimensionId(i, j, uiCode); |
---|
[494] | 1078 | #if !AUXILIARY_PICTURES |
---|
[313] | 1079 | assert( uiCode <= vps->getMaxLayerId() ); |
---|
[494] | 1080 | #endif |
---|
[313] | 1081 | } |
---|
| 1082 | } |
---|
[494] | 1083 | } |
---|
[313] | 1084 | #endif |
---|
[494] | 1085 | #if VIEW_ID_RELATED_SIGNALING |
---|
| 1086 | // if ( pcVPS->getNumViews() > 1 ) |
---|
| 1087 | // However, this is a bug in the text since, view_id_len_minus1 is needed to parse view_id_val. |
---|
[442] | 1088 | { |
---|
[547] | 1089 | #if O0109_VIEW_ID_LEN |
---|
| 1090 | READ_CODE( 4, uiCode, "view_id_len" ); vps->setViewIdLen( uiCode ); |
---|
| 1091 | #else |
---|
[442] | 1092 | READ_CODE( 4, uiCode, "view_id_len_minus1" ); vps->setViewIdLenMinus1( uiCode ); |
---|
[547] | 1093 | #endif |
---|
[442] | 1094 | } |
---|
| 1095 | |
---|
[547] | 1096 | #if O0109_VIEW_ID_LEN |
---|
| 1097 | if ( vps->getViewIdLen() > 0 ) |
---|
| 1098 | { |
---|
| 1099 | for( i = 0; i < vps->getNumViews(); i++ ) |
---|
| 1100 | { |
---|
| 1101 | READ_CODE( vps->getViewIdLen( ), uiCode, "view_id_val[i]" ); vps->setViewIdVal( i, uiCode ); |
---|
| 1102 | } |
---|
| 1103 | } |
---|
| 1104 | #else |
---|
[442] | 1105 | for( i = 0; i < vps->getNumViews(); i++ ) |
---|
| 1106 | { |
---|
| 1107 | READ_CODE( vps->getViewIdLenMinus1( ) + 1, uiCode, "view_id_val[i]" ); vps->setViewIdVal( i, uiCode ); |
---|
| 1108 | } |
---|
| 1109 | #endif |
---|
[547] | 1110 | #endif // view id related signaling |
---|
[313] | 1111 | #if VPS_EXTN_DIRECT_REF_LAYERS |
---|
| 1112 | // For layer 0 |
---|
| 1113 | vps->setNumDirectRefLayers(0, 0); |
---|
| 1114 | // For other layers |
---|
| 1115 | for( Int layerCtr = 1; layerCtr <= vps->getMaxLayers() - 1; layerCtr++) |
---|
| 1116 | { |
---|
| 1117 | UInt numDirectRefLayers = 0; |
---|
| 1118 | for( Int refLayerCtr = 0; refLayerCtr < layerCtr; refLayerCtr++) |
---|
| 1119 | { |
---|
| 1120 | READ_FLAG(uiCode, "direct_dependency_flag[i][j]" ); vps->setDirectDependencyFlag(layerCtr, refLayerCtr, uiCode? true : false); |
---|
| 1121 | if(uiCode) |
---|
| 1122 | { |
---|
| 1123 | vps->setRefLayerId(layerCtr, numDirectRefLayers, refLayerCtr); |
---|
| 1124 | numDirectRefLayers++; |
---|
| 1125 | } |
---|
| 1126 | } |
---|
| 1127 | vps->setNumDirectRefLayers(layerCtr, numDirectRefLayers); |
---|
| 1128 | } |
---|
| 1129 | #endif |
---|
[540] | 1130 | #if VPS_TSLAYERS |
---|
| 1131 | READ_FLAG( uiCode, "vps_sub_layers_max_minus1_present_flag"); vps->setMaxTSLayersPresentFlag(uiCode ? true : false); |
---|
| 1132 | if (vps->getMaxTSLayersPresentFlag()) |
---|
| 1133 | { |
---|
[615] | 1134 | for(i = 0; i < vps->getMaxLayers(); i++) |
---|
[540] | 1135 | { |
---|
| 1136 | READ_CODE( 3, uiCode, "sub_layers_vps_max_minus1[i]" ); vps->setMaxTSLayersMinus1(i, uiCode); |
---|
| 1137 | } |
---|
| 1138 | } |
---|
| 1139 | else |
---|
| 1140 | { |
---|
[615] | 1141 | for( i = 0; i < vps->getMaxLayers(); i++) |
---|
[540] | 1142 | { |
---|
| 1143 | vps->setMaxTSLayersMinus1(i, vps->getMaxTLayers()-1); |
---|
| 1144 | } |
---|
| 1145 | } |
---|
| 1146 | #endif |
---|
[345] | 1147 | #if N0120_MAX_TID_REF_PRESENT_FLAG |
---|
[442] | 1148 | READ_FLAG( uiCode, "max_tid_ref_present_flag"); vps->setMaxTidRefPresentFlag(uiCode ? true : false); |
---|
| 1149 | if (vps->getMaxTidRefPresentFlag()) |
---|
[345] | 1150 | { |
---|
| 1151 | for(i = 0; i < vps->getMaxLayers() - 1; i++) |
---|
| 1152 | { |
---|
[494] | 1153 | #if O0225_MAX_TID_FOR_REF_LAYERS |
---|
| 1154 | for( j = i+1; j <= vps->getMaxLayers() - 1; j++) |
---|
| 1155 | { |
---|
| 1156 | if(vps->getDirectDependencyFlag(j, i)) |
---|
| 1157 | { |
---|
| 1158 | READ_CODE( 3, uiCode, "max_tid_il_ref_pics_plus1[i][j]" ); vps->setMaxTidIlRefPicsPlus1(i, j, uiCode); |
---|
| 1159 | assert( uiCode <= vps->getMaxTLayers()); |
---|
| 1160 | } |
---|
| 1161 | } |
---|
| 1162 | #else |
---|
[442] | 1163 | READ_CODE( 3, uiCode, "max_tid_il_ref_pics_plus1[i]" ); vps->setMaxTidIlRefPicsPlus1(i, uiCode); |
---|
| 1164 | #if N0120_MAX_TID_REF_CFG |
---|
| 1165 | assert( uiCode <= vps->getMaxTLayers()); |
---|
[494] | 1166 | #else |
---|
[442] | 1167 | assert( uiCode <= vps->getMaxTLayers()+ 1 ); |
---|
[494] | 1168 | #endif |
---|
[442] | 1169 | #endif |
---|
[345] | 1170 | } |
---|
| 1171 | } |
---|
[494] | 1172 | else |
---|
[345] | 1173 | { |
---|
| 1174 | for(i = 0; i < vps->getMaxLayers() - 1; i++) |
---|
| 1175 | { |
---|
[494] | 1176 | #if O0225_MAX_TID_FOR_REF_LAYERS |
---|
| 1177 | for( j = i+1; j <= vps->getMaxLayers() - 1; j++) |
---|
| 1178 | { |
---|
| 1179 | vps->setMaxTidIlRefPicsPlus1(i, j, 7); |
---|
| 1180 | } |
---|
| 1181 | #else |
---|
[442] | 1182 | vps->setMaxTidIlRefPicsPlus1(i, 7); |
---|
[494] | 1183 | #endif |
---|
[345] | 1184 | } |
---|
| 1185 | } |
---|
| 1186 | #else |
---|
[313] | 1187 | for(i = 0; i < vps->getMaxLayers() - 1; i++) |
---|
| 1188 | { |
---|
[494] | 1189 | #if O0225_MAX_TID_FOR_REF_LAYERS |
---|
| 1190 | for( j = i+1; j <= vps->getMaxLayers() - 1; j++) |
---|
| 1191 | { |
---|
| 1192 | if(vps->getDirectDependencyFlag(j, i)) |
---|
| 1193 | { |
---|
| 1194 | READ_CODE( 3, uiCode, "max_tid_il_ref_pics_plus1[i][j]" ); vps->setMaxTidIlRefPicsPlus1(i, j, uiCode); |
---|
| 1195 | assert( uiCode <= vps->getMaxTLayers() ); |
---|
| 1196 | } |
---|
| 1197 | } |
---|
| 1198 | #else |
---|
[442] | 1199 | READ_CODE( 3, uiCode, "max_tid_il_ref_pics_plus1[i]" ); vps->setMaxTidIlRefPicsPlus1(i, uiCode); |
---|
[313] | 1200 | assert( uiCode <= vps->getMaxTLayers() ); |
---|
[494] | 1201 | #endif |
---|
[313] | 1202 | } |
---|
| 1203 | #endif |
---|
[345] | 1204 | #if ILP_SSH_SIG |
---|
| 1205 | READ_FLAG( uiCode, "all_ref_layers_active_flag" ); vps->setIlpSshSignalingEnabledFlag(uiCode ? true : false); |
---|
| 1206 | #endif |
---|
[313] | 1207 | #if VPS_EXTN_PROFILE_INFO |
---|
| 1208 | // Profile-tier-level signalling |
---|
[588] | 1209 | #if !VPS_EXTN_UEV_CODING |
---|
[313] | 1210 | READ_CODE( 10, uiCode, "vps_number_layer_sets_minus1" ); assert( uiCode == (vps->getNumLayerSets() - 1) ); |
---|
| 1211 | READ_CODE( 6, uiCode, "vps_num_profile_tier_level_minus1"); vps->setNumProfileTierLevel( uiCode + 1 ); |
---|
[588] | 1212 | #else |
---|
| 1213 | READ_UVLC( uiCode, "vps_num_profile_tier_level_minus1"); vps->setNumProfileTierLevel( uiCode + 1 ); |
---|
| 1214 | #endif |
---|
[313] | 1215 | vps->getPTLForExtnPtr()->resize(vps->getNumProfileTierLevel()); |
---|
| 1216 | for(Int idx = 1; idx <= vps->getNumProfileTierLevel() - 1; idx++) |
---|
| 1217 | { |
---|
| 1218 | READ_FLAG( uiCode, "vps_profile_present_flag[i]" ); vps->setProfilePresentFlag(idx, uiCode ? true : false); |
---|
| 1219 | if( !vps->getProfilePresentFlag(idx) ) |
---|
| 1220 | { |
---|
[588] | 1221 | #if P0048_REMOVE_PROFILE_REF |
---|
| 1222 | // Copy profile information from previous one |
---|
| 1223 | vps->getPTLForExtn(idx)->copyProfileInfo( (idx==1) ? vps->getPTL() : vps->getPTLForExtn( idx - 1 ) ); |
---|
| 1224 | #else |
---|
[313] | 1225 | READ_CODE( 6, uiCode, "profile_ref_minus1[i]" ); vps->setProfileLayerSetRef(idx, uiCode + 1); |
---|
[547] | 1226 | #if O0109_PROF_REF_MINUS1 |
---|
| 1227 | assert( vps->getProfileLayerSetRef(idx) <= idx ); |
---|
| 1228 | #else |
---|
[313] | 1229 | assert( vps->getProfileLayerSetRef(idx) < idx ); |
---|
[547] | 1230 | #endif |
---|
[313] | 1231 | // Copy profile information as indicated |
---|
| 1232 | vps->getPTLForExtn(idx)->copyProfileInfo( vps->getPTLForExtn( vps->getProfileLayerSetRef(idx) ) ); |
---|
[588] | 1233 | #endif |
---|
[313] | 1234 | } |
---|
| 1235 | parsePTL( vps->getPTLForExtn(idx), vps->getProfilePresentFlag(idx), vps->getMaxTLayers() - 1 ); |
---|
| 1236 | } |
---|
| 1237 | #endif |
---|
| 1238 | |
---|
[588] | 1239 | #if !VPS_EXTN_UEV_CODING |
---|
[313] | 1240 | READ_FLAG( uiCode, "more_output_layer_sets_than_default_flag" ); vps->setMoreOutputLayerSetsThanDefaultFlag( uiCode ? true : false ); |
---|
| 1241 | Int numOutputLayerSets = 0; |
---|
| 1242 | if(! vps->getMoreOutputLayerSetsThanDefaultFlag() ) |
---|
| 1243 | { |
---|
| 1244 | numOutputLayerSets = vps->getNumLayerSets(); |
---|
| 1245 | } |
---|
| 1246 | else |
---|
| 1247 | { |
---|
| 1248 | READ_CODE( 10, uiCode, "num_add_output_layer_sets" ); vps->setNumAddOutputLayerSets( uiCode ); |
---|
| 1249 | numOutputLayerSets = vps->getNumLayerSets() + vps->getNumAddOutputLayerSets(); |
---|
| 1250 | } |
---|
[588] | 1251 | #else |
---|
| 1252 | READ_UVLC( uiCode, "num_add_output_layer_sets" ); vps->setNumAddOutputLayerSets( uiCode ); |
---|
| 1253 | Int numOutputLayerSets = vps->getNumLayerSets() + vps->getNumAddOutputLayerSets(); |
---|
| 1254 | #endif |
---|
| 1255 | |
---|
| 1256 | #if P0295_DEFAULT_OUT_LAYER_IDC |
---|
[313] | 1257 | if( numOutputLayerSets > 1 ) |
---|
| 1258 | { |
---|
[588] | 1259 | READ_CODE( 2, uiCode, "default_target_output_layer_idc" ); vps->setDefaultTargetOutputLayerIdc( uiCode ); |
---|
| 1260 | } |
---|
| 1261 | vps->setNumOutputLayerSets( numOutputLayerSets ); |
---|
| 1262 | |
---|
| 1263 | for(i = 1; i < numOutputLayerSets; i++) |
---|
| 1264 | { |
---|
| 1265 | if( i > (vps->getNumLayerSets() - 1) ) |
---|
| 1266 | { |
---|
| 1267 | Int numBits = 1; |
---|
| 1268 | while ((1 << numBits) < (vps->getNumLayerSets() - 1)) |
---|
| 1269 | { |
---|
| 1270 | numBits++; |
---|
| 1271 | } |
---|
| 1272 | READ_CODE( numBits, uiCode, "output_layer_set_idx_minus1"); vps->setOutputLayerSetIdx( i, uiCode + 1); |
---|
| 1273 | } |
---|
| 1274 | else |
---|
| 1275 | { |
---|
| 1276 | vps->setOutputLayerSetIdx( i, i ); |
---|
| 1277 | } |
---|
| 1278 | if ( i > (vps->getNumLayerSets() - 1) || vps->getDefaultTargetOutputLayerIdc() >= 2 ) |
---|
| 1279 | { |
---|
| 1280 | Int lsIdx = vps->getOutputLayerSetIdx(i); |
---|
[614] | 1281 | #if NUM_OL_FLAGS |
---|
[646] | 1282 | for(j = 0; j < vps->getNumLayersInIdList(lsIdx); j++) |
---|
[614] | 1283 | #else |
---|
[588] | 1284 | for(j = 0; j < vps->getNumLayersInIdList(lsIdx) - 1; j++) |
---|
[614] | 1285 | #endif |
---|
[588] | 1286 | { |
---|
| 1287 | READ_FLAG( uiCode, "output_layer_flag[i][j]"); vps->setOutputLayerFlag(i, j, uiCode); |
---|
| 1288 | } |
---|
| 1289 | } |
---|
| 1290 | else |
---|
| 1291 | { |
---|
| 1292 | // i <= (vps->getNumLayerSets() - 1) |
---|
| 1293 | // Assign OutputLayerFlag depending on default_one_target_output_layer_flag |
---|
| 1294 | Int lsIdx = i; |
---|
| 1295 | if( vps->getDefaultTargetOutputLayerIdc() == 1 ) |
---|
| 1296 | { |
---|
| 1297 | for(j = 0; j < vps->getNumLayersInIdList(lsIdx); j++) |
---|
| 1298 | { |
---|
| 1299 | vps->setOutputLayerFlag(i, j, (j == (vps->getNumLayersInIdList(lsIdx)-1)) && (vps->getDimensionId(j,1) == 0) ); |
---|
| 1300 | } |
---|
| 1301 | } |
---|
| 1302 | else if ( vps->getDefaultTargetOutputLayerIdc() == 0 ) |
---|
| 1303 | { |
---|
| 1304 | for(j = 0; j < vps->getNumLayersInIdList(lsIdx); j++) |
---|
| 1305 | { |
---|
| 1306 | vps->setOutputLayerFlag(i, j, 1); |
---|
| 1307 | } |
---|
| 1308 | } |
---|
| 1309 | } |
---|
| 1310 | Int numBits = 1; |
---|
| 1311 | while ((1 << numBits) < (vps->getNumProfileTierLevel())) |
---|
| 1312 | { |
---|
| 1313 | numBits++; |
---|
| 1314 | } |
---|
| 1315 | READ_CODE( numBits, uiCode, "profile_level_tier_idx[i]" ); vps->setProfileLevelTierIdx(i, uiCode); |
---|
[602] | 1316 | #if P0300_ALT_OUTPUT_LAYER_FLAG |
---|
| 1317 | NumOutputLayersInOutputLayerSet[i] = 0; |
---|
| 1318 | Int layerSetIdxForOutputLayerSet = vps->getOutputLayerSetIdx(i); |
---|
| 1319 | for (j = 0; j < vps->getNumLayersInIdList(layerSetIdxForOutputLayerSet); j++) |
---|
| 1320 | { |
---|
| 1321 | NumOutputLayersInOutputLayerSet[i] += vps->getOutputLayerFlag(i, j); |
---|
| 1322 | if (vps->getOutputLayerFlag(i, j)) |
---|
| 1323 | { |
---|
| 1324 | OlsHighestOutputLayerId[i] = vps->getLayerSetLayerIdList(layerSetIdxForOutputLayerSet, j); |
---|
| 1325 | } |
---|
| 1326 | } |
---|
| 1327 | if (NumOutputLayersInOutputLayerSet[i] == 1 && vps->getNumDirectRefLayers(OlsHighestOutputLayerId[i]) > 0) |
---|
| 1328 | { |
---|
| 1329 | READ_FLAG(uiCode, "alt_output_layer_flag[i]"); |
---|
| 1330 | vps->setAltOuputLayerFlag(i, uiCode ? true : false); |
---|
| 1331 | } |
---|
| 1332 | #endif |
---|
[588] | 1333 | } |
---|
| 1334 | #else |
---|
| 1335 | if( numOutputLayerSets > 1 ) |
---|
| 1336 | { |
---|
[547] | 1337 | #if O0109_DEFAULT_ONE_OUT_LAYER_IDC |
---|
| 1338 | READ_CODE( 2, uiCode, "default_one_target_output_layer_idc" ); vps->setDefaultOneTargetOutputLayerIdc( uiCode ); |
---|
| 1339 | #else |
---|
[313] | 1340 | READ_FLAG( uiCode, "default_one_target_output_layer_flag" ); vps->setDefaultOneTargetOutputLayerFlag( uiCode ? true : false ); |
---|
[547] | 1341 | #endif |
---|
[313] | 1342 | } |
---|
| 1343 | vps->setNumOutputLayerSets( numOutputLayerSets ); |
---|
| 1344 | |
---|
| 1345 | for(i = 1; i < numOutputLayerSets; i++) |
---|
| 1346 | { |
---|
| 1347 | if( i > (vps->getNumLayerSets() - 1) ) |
---|
| 1348 | { |
---|
| 1349 | Int numBits = 1; |
---|
| 1350 | while ((1 << numBits) < (vps->getNumLayerSets() - 1)) |
---|
| 1351 | { |
---|
| 1352 | numBits++; |
---|
| 1353 | } |
---|
| 1354 | READ_CODE( numBits, uiCode, "output_layer_set_idx_minus1"); vps->setOutputLayerSetIdx( i, uiCode + 1); |
---|
| 1355 | Int lsIdx = vps->getOutputLayerSetIdx(i); |
---|
[614] | 1356 | #if NUM_OL_FLAGS |
---|
| 1357 | for(j = 0; j < vps->getNumLayersInIdList(lsIdx) ; j++) |
---|
| 1358 | #else |
---|
[313] | 1359 | for(j = 0; j < vps->getNumLayersInIdList(lsIdx) - 1; j++) |
---|
[614] | 1360 | #endif |
---|
[313] | 1361 | { |
---|
| 1362 | READ_FLAG( uiCode, "output_layer_flag[i][j]"); vps->setOutputLayerFlag(i, j, uiCode); |
---|
| 1363 | } |
---|
| 1364 | } |
---|
| 1365 | else |
---|
| 1366 | { |
---|
[540] | 1367 | #if VPS_DPB_SIZE_TABLE |
---|
| 1368 | vps->setOutputLayerSetIdx( i, i ); |
---|
| 1369 | #endif |
---|
[313] | 1370 | // i <= (vps->getNumLayerSets() - 1) |
---|
| 1371 | // Assign OutputLayerFlag depending on default_one_target_output_layer_flag |
---|
| 1372 | Int lsIdx = i; |
---|
[547] | 1373 | #if O0109_DEFAULT_ONE_OUT_LAYER_IDC |
---|
| 1374 | if( vps->getDefaultOneTargetOutputLayerIdc() == 1 ) |
---|
| 1375 | { |
---|
| 1376 | for(j = 0; j < vps->getNumLayersInIdList(lsIdx); j++) |
---|
| 1377 | { |
---|
| 1378 | #if O0135_DEFAULT_ONE_OUT_SEMANTIC |
---|
| 1379 | vps->setOutputLayerFlag(i, j, (j == (vps->getNumLayersInIdList(lsIdx)-1)) && (vps->getDimensionId(j,1)==0) ); |
---|
| 1380 | #else |
---|
| 1381 | vps->setOutputLayerFlag(i, j, (j == (vps->getNumLayersInIdList(lsIdx)-1))); |
---|
| 1382 | #endif |
---|
| 1383 | } |
---|
| 1384 | } |
---|
| 1385 | else if ( vps->getDefaultOneTargetOutputLayerIdc() == 0 ) |
---|
| 1386 | { |
---|
| 1387 | for(j = 0; j < vps->getNumLayersInIdList(lsIdx); j++) |
---|
| 1388 | { |
---|
| 1389 | vps->setOutputLayerFlag(i, j, 1); |
---|
| 1390 | } |
---|
| 1391 | } |
---|
| 1392 | else |
---|
| 1393 | { |
---|
| 1394 | // Other values of default_one_target_output_layer_idc than 0 and 1 are reserved for future use. |
---|
| 1395 | } |
---|
| 1396 | #else |
---|
[313] | 1397 | if( vps->getDefaultOneTargetOutputLayerFlag() ) |
---|
| 1398 | { |
---|
| 1399 | for(j = 0; j < vps->getNumLayersInIdList(lsIdx); j++) |
---|
| 1400 | { |
---|
| 1401 | vps->setOutputLayerFlag(i, j, (j == (vps->getNumLayersInIdList(lsIdx)-1))); |
---|
| 1402 | } |
---|
| 1403 | } |
---|
| 1404 | else |
---|
| 1405 | { |
---|
| 1406 | for(j = 0; j < vps->getNumLayersInIdList(lsIdx); j++) |
---|
| 1407 | { |
---|
| 1408 | vps->setOutputLayerFlag(i, j, 1); |
---|
| 1409 | } |
---|
| 1410 | } |
---|
[547] | 1411 | #endif |
---|
[313] | 1412 | } |
---|
| 1413 | Int numBits = 1; |
---|
| 1414 | while ((1 << numBits) < (vps->getNumProfileTierLevel())) |
---|
| 1415 | { |
---|
| 1416 | numBits++; |
---|
| 1417 | } |
---|
| 1418 | READ_CODE( numBits, uiCode, "profile_level_tier_idx[i]" ); vps->setProfileLevelTierIdx(i, uiCode); |
---|
| 1419 | } |
---|
[588] | 1420 | #endif |
---|
[494] | 1421 | |
---|
[602] | 1422 | #if !P0300_ALT_OUTPUT_LAYER_FLAG |
---|
[540] | 1423 | #if O0153_ALT_OUTPUT_LAYER_FLAG |
---|
| 1424 | if( vps->getMaxLayers() > 1 ) |
---|
| 1425 | { |
---|
| 1426 | READ_FLAG( uiCode, "alt_output_layer_flag"); |
---|
| 1427 | vps->setAltOuputLayerFlag( uiCode ? true : false ); |
---|
| 1428 | } |
---|
| 1429 | #endif |
---|
[602] | 1430 | #endif |
---|
[540] | 1431 | |
---|
[442] | 1432 | #if REPN_FORMAT_IN_VPS |
---|
[494] | 1433 | READ_FLAG( uiCode, "rep_format_idx_present_flag"); |
---|
[442] | 1434 | vps->setRepFormatIdxPresentFlag( uiCode ? true : false ); |
---|
| 1435 | |
---|
| 1436 | if( vps->getRepFormatIdxPresentFlag() ) |
---|
| 1437 | { |
---|
[540] | 1438 | #if O0096_REP_FORMAT_INDEX |
---|
[588] | 1439 | #if !VPS_EXTN_UEV_CODING |
---|
[540] | 1440 | READ_CODE( 8, uiCode, "vps_num_rep_formats_minus1" ); |
---|
| 1441 | #else |
---|
[588] | 1442 | READ_UVLC( uiCode, "vps_num_rep_formats_minus1" ); |
---|
| 1443 | #endif |
---|
| 1444 | #else |
---|
[442] | 1445 | READ_CODE( 4, uiCode, "vps_num_rep_formats_minus1" ); |
---|
[540] | 1446 | #endif |
---|
[442] | 1447 | vps->setVpsNumRepFormats( uiCode + 1 ); |
---|
| 1448 | } |
---|
| 1449 | else |
---|
| 1450 | { |
---|
| 1451 | // default assignment |
---|
| 1452 | assert (vps->getMaxLayers() <= 16); // If max_layers_is more than 15, num_rep_formats has to be signaled |
---|
| 1453 | vps->setVpsNumRepFormats( vps->getMaxLayers() ); |
---|
| 1454 | } |
---|
| 1455 | for(i = 0; i < vps->getVpsNumRepFormats(); i++) |
---|
| 1456 | { |
---|
| 1457 | // Read rep_format_structures |
---|
| 1458 | parseRepFormat( vps->getVpsRepFormat(i) ); |
---|
| 1459 | } |
---|
[494] | 1460 | |
---|
[442] | 1461 | // Default assignment for layer 0 |
---|
| 1462 | vps->setVpsRepFormatIdx( 0, 0 ); |
---|
| 1463 | if( vps->getRepFormatIdxPresentFlag() ) |
---|
| 1464 | { |
---|
| 1465 | for(i = 1; i < vps->getMaxLayers(); i++) |
---|
| 1466 | { |
---|
| 1467 | if( vps->getVpsNumRepFormats() > 1 ) |
---|
| 1468 | { |
---|
[540] | 1469 | #if O0096_REP_FORMAT_INDEX |
---|
[588] | 1470 | #if !VPS_EXTN_UEV_CODING |
---|
[540] | 1471 | READ_CODE( 8, uiCode, "vps_rep_format_idx[i]" ); |
---|
| 1472 | #else |
---|
[588] | 1473 | Int numBits = 1; |
---|
| 1474 | while ((1 << numBits) < (vps->getVpsNumRepFormats())) |
---|
| 1475 | { |
---|
| 1476 | numBits++; |
---|
| 1477 | } |
---|
| 1478 | READ_CODE( numBits, uiCode, "vps_rep_format_idx[i]" ); |
---|
| 1479 | #endif |
---|
| 1480 | #else |
---|
[442] | 1481 | READ_CODE( 4, uiCode, "vps_rep_format_idx[i]" ); |
---|
[540] | 1482 | #endif |
---|
[442] | 1483 | vps->setVpsRepFormatIdx( i, uiCode ); |
---|
| 1484 | } |
---|
| 1485 | else |
---|
| 1486 | { |
---|
| 1487 | // default assignment - only one rep_format() structure |
---|
| 1488 | vps->setVpsRepFormatIdx( i, 0 ); |
---|
| 1489 | } |
---|
| 1490 | } |
---|
| 1491 | } |
---|
| 1492 | else |
---|
| 1493 | { |
---|
| 1494 | // default assignment - each layer assigned each rep_format() structure in the order signaled |
---|
| 1495 | for(i = 1; i < vps->getMaxLayers(); i++) |
---|
| 1496 | { |
---|
| 1497 | vps->setVpsRepFormatIdx( i, i ); |
---|
| 1498 | } |
---|
| 1499 | } |
---|
| 1500 | #endif |
---|
[588] | 1501 | #if RESOLUTION_BASED_DPB |
---|
| 1502 | vps->assignSubDpbIndices(); |
---|
| 1503 | #endif |
---|
[442] | 1504 | READ_FLAG(uiCode, "max_one_active_ref_layer_flag" ); |
---|
| 1505 | vps->setMaxOneActiveRefLayerFlag(uiCode); |
---|
[494] | 1506 | #if O0062_POC_LSB_NOT_PRESENT_FLAG |
---|
| 1507 | for(i = 1; i< vps->getMaxLayers(); i++) |
---|
[313] | 1508 | { |
---|
[494] | 1509 | if( vps->getNumDirectRefLayers( vps->getLayerIdInNuh(i) ) == 0 ) |
---|
[313] | 1510 | { |
---|
[494] | 1511 | READ_FLAG(uiCode, "poc_lsb_not_present_flag[i]"); |
---|
| 1512 | vps->setPocLsbNotPresentFlag(i, uiCode); |
---|
[313] | 1513 | } |
---|
| 1514 | } |
---|
| 1515 | #endif |
---|
[494] | 1516 | #if O0215_PHASE_ALIGNMENT |
---|
| 1517 | READ_FLAG( uiCode, "cross_layer_phase_alignment_flag"); vps->setPhaseAlignFlag( uiCode == 1 ? true : false ); |
---|
[313] | 1518 | #endif |
---|
[494] | 1519 | |
---|
| 1520 | #if N0147_IRAP_ALIGN_FLAG && !IRAP_ALIGN_FLAG_IN_VPS_VUI |
---|
| 1521 | READ_FLAG(uiCode, "cross_layer_irap_aligned_flag" ); |
---|
| 1522 | vps->setCrossLayerIrapAlignFlag(uiCode); |
---|
| 1523 | #endif |
---|
| 1524 | |
---|
[540] | 1525 | #if VPS_DPB_SIZE_TABLE |
---|
[588] | 1526 | parseVpsDpbSizeTable(vps); |
---|
[540] | 1527 | #endif |
---|
[588] | 1528 | |
---|
| 1529 | #if VPS_EXTN_DIRECT_REF_LAYERS |
---|
[313] | 1530 | READ_UVLC( uiCode, "direct_dep_type_len_minus2"); vps->setDirectDepTypeLen(uiCode+2); |
---|
[540] | 1531 | #if O0096_DEFAULT_DEPENDENCY_TYPE |
---|
| 1532 | READ_FLAG(uiCode, "default_direct_dependency_type_flag"); |
---|
| 1533 | vps->setDefaultDirectDependecyTypeFlag(uiCode == 1? true : false); |
---|
| 1534 | if (vps->getDefaultDirectDependencyTypeFlag()) |
---|
| 1535 | { |
---|
| 1536 | READ_CODE( vps->getDirectDepTypeLen(), uiCode, "default_direct_dependency_type" ); |
---|
| 1537 | vps->setDefaultDirectDependecyType(uiCode); |
---|
| 1538 | } |
---|
| 1539 | #endif |
---|
[313] | 1540 | for(i = 1; i < vps->getMaxLayers(); i++) |
---|
| 1541 | { |
---|
| 1542 | for(j = 0; j < i; j++) |
---|
| 1543 | { |
---|
| 1544 | if (vps->getDirectDependencyFlag(i, j)) |
---|
| 1545 | { |
---|
[540] | 1546 | #if O0096_DEFAULT_DEPENDENCY_TYPE |
---|
| 1547 | if (vps->getDefaultDirectDependencyTypeFlag()) |
---|
| 1548 | { |
---|
| 1549 | vps->setDirectDependencyType(i, j, vps->getDefaultDirectDependencyType()); |
---|
| 1550 | } |
---|
| 1551 | else |
---|
| 1552 | { |
---|
| 1553 | READ_CODE( vps->getDirectDepTypeLen(), uiCode, "direct_dependency_type[i][j]" ); |
---|
| 1554 | vps->setDirectDependencyType(i, j, uiCode); |
---|
| 1555 | } |
---|
| 1556 | #else |
---|
| 1557 | READ_CODE( vps->getDirectDepTypeLen(), uiCode, "direct_dependency_type[i][j]" ); |
---|
| 1558 | vps->setDirectDependencyType(i, j, uiCode); |
---|
| 1559 | #endif |
---|
[313] | 1560 | } |
---|
| 1561 | } |
---|
| 1562 | } |
---|
| 1563 | #endif |
---|
[540] | 1564 | #if O0092_0094_DEPENDENCY_CONSTRAINT |
---|
[442] | 1565 | for(i = 1; i < vps->getMaxLayers(); i++) |
---|
[540] | 1566 | { |
---|
| 1567 | vps->setNumRefLayers(vps->getLayerIdInNuh(i)); // identify the number of direct and indirect reference layers of current layer and set recursiveRefLayersFlags |
---|
| 1568 | } |
---|
| 1569 | if(vps->getMaxLayers() > MAX_REF_LAYERS) |
---|
| 1570 | { |
---|
| 1571 | for(i = 1;i < vps->getMaxLayers(); i++) |
---|
[442] | 1572 | { |
---|
[540] | 1573 | assert( vps->getNumRefLayers(vps->getLayerIdInNuh(i)) <= MAX_REF_LAYERS); |
---|
[442] | 1574 | } |
---|
[540] | 1575 | } |
---|
[442] | 1576 | #endif |
---|
| 1577 | |
---|
[588] | 1578 | #if P0307_VPS_NON_VUI_EXTENSION |
---|
| 1579 | READ_UVLC( uiCode, "vps_non_vui_extension_length"); vps->setVpsNonVuiExtLength((Int)uiCode); |
---|
[617] | 1580 | #if P0307_VPS_NON_VUI_EXT_UPDATE |
---|
[618] | 1581 | Int nonVuiExtByte = uiCode; |
---|
| 1582 | for (i = 1; i <= nonVuiExtByte; i++) |
---|
[617] | 1583 | { |
---|
[618] | 1584 | READ_CODE( 8, uiCode, "vps_non_vui_extension_data_byte" ); //just parse and discard for now. |
---|
[617] | 1585 | } |
---|
| 1586 | #else |
---|
[588] | 1587 | if ( vps->getVpsNonVuiExtLength() > 0 ) |
---|
| 1588 | { |
---|
| 1589 | printf("\n\nUp to the current spec, the value of vps_non_vui_extension_length is supposed to be 0\n"); |
---|
| 1590 | } |
---|
| 1591 | #endif |
---|
[617] | 1592 | #endif |
---|
[588] | 1593 | |
---|
[547] | 1594 | #if !O0109_O0199_FLAGS_TO_VUI |
---|
[313] | 1595 | #if M0040_ADAPTIVE_RESOLUTION_CHANGE |
---|
| 1596 | READ_FLAG(uiCode, "single_layer_for_non_irap_flag" ); vps->setSingleLayerForNonIrapFlag(uiCode == 1 ? true : false); |
---|
| 1597 | #endif |
---|
[540] | 1598 | #if HIGHER_LAYER_IRAP_SKIP_FLAG |
---|
| 1599 | READ_FLAG(uiCode, "higher_layer_irap_skip_flag" ); vps->setHigherLayerIrapSkipFlag(uiCode == 1 ? true : false); |
---|
| 1600 | #endif |
---|
[547] | 1601 | #endif |
---|
[442] | 1602 | |
---|
[588] | 1603 | #if P0307_REMOVE_VPS_VUI_OFFSET |
---|
| 1604 | READ_FLAG( uiCode, "vps_vui_present_flag"); vps->setVpsVuiPresentFlag(uiCode ? true : false); |
---|
| 1605 | #endif |
---|
| 1606 | |
---|
[547] | 1607 | #if O0109_MOVE_VPS_VUI_FLAG |
---|
| 1608 | if ( vps->getVpsVuiPresentFlag() ) |
---|
| 1609 | #else |
---|
[442] | 1610 | READ_FLAG( uiCode, "vps_vui_present_flag" ); |
---|
| 1611 | if (uiCode) |
---|
[547] | 1612 | #endif |
---|
[442] | 1613 | { |
---|
| 1614 | #if VPS_VUI |
---|
| 1615 | while ( m_pcBitstream->getNumBitsRead() % 8 != 0 ) |
---|
| 1616 | { |
---|
| 1617 | READ_FLAG( uiCode, "vps_vui_alignment_bit_equal_to_one"); assert(uiCode == 1); |
---|
| 1618 | } |
---|
| 1619 | parseVPSVUI(vps); |
---|
[494] | 1620 | #endif |
---|
[442] | 1621 | } |
---|
[313] | 1622 | } |
---|
| 1623 | #endif |
---|
[442] | 1624 | #if REPN_FORMAT_IN_VPS |
---|
| 1625 | Void TDecCavlc::parseRepFormat ( RepFormat *repFormat ) |
---|
| 1626 | { |
---|
| 1627 | UInt uiCode; |
---|
[540] | 1628 | #if REPN_FORMAT_CONTROL_FLAG |
---|
| 1629 | READ_FLAG ( uiCode, "chroma_and_bit_depth_vps_present_flag"); repFormat->setChromaAndBitDepthVpsPresentFlag(uiCode ? true : false); |
---|
| 1630 | READ_CODE ( 16, uiCode, "pic_width_in_luma_samples" ); repFormat->setPicWidthVpsInLumaSamples ( uiCode ); |
---|
| 1631 | READ_CODE ( 16, uiCode, "pic_height_in_luma_samples" ); repFormat->setPicHeightVpsInLumaSamples( uiCode ); |
---|
| 1632 | |
---|
| 1633 | if( repFormat->getChromaAndBitDepthVpsPresentFlag() ) |
---|
| 1634 | { |
---|
[494] | 1635 | #if AUXILIARY_PICTURES |
---|
[540] | 1636 | READ_CODE( 2, uiCode, "chroma_format_idc" ); repFormat->setChromaFormatVpsIdc( ChromaFormat(uiCode) ); |
---|
| 1637 | #else |
---|
| 1638 | READ_CODE( 2, uiCode, "chroma_format_idc" ); repFormat->setChromaFormatVpsIdc( uiCode ); |
---|
| 1639 | #endif |
---|
| 1640 | |
---|
| 1641 | if( repFormat->getChromaFormatVpsIdc() == 3 ) |
---|
| 1642 | { |
---|
| 1643 | READ_FLAG( uiCode, "separate_colour_plane_flag"); repFormat->setSeparateColourPlaneVpsFlag(uiCode ? true : false); |
---|
| 1644 | } |
---|
| 1645 | |
---|
| 1646 | |
---|
| 1647 | READ_CODE( 4, uiCode, "bit_depth_luma_minus8" ); repFormat->setBitDepthVpsLuma ( uiCode + 8 ); |
---|
| 1648 | READ_CODE( 4, uiCode, "bit_depth_chroma_minus8" ); repFormat->setBitDepthVpsChroma( uiCode + 8 ); |
---|
| 1649 | } |
---|
| 1650 | #else |
---|
| 1651 | #if AUXILIARY_PICTURES |
---|
[494] | 1652 | READ_CODE( 2, uiCode, "chroma_format_idc" ); repFormat->setChromaFormatVpsIdc( ChromaFormat(uiCode) ); |
---|
| 1653 | #else |
---|
[442] | 1654 | READ_CODE( 2, uiCode, "chroma_format_idc" ); repFormat->setChromaFormatVpsIdc( uiCode ); |
---|
[494] | 1655 | #endif |
---|
[442] | 1656 | |
---|
| 1657 | if( repFormat->getChromaFormatVpsIdc() == 3 ) |
---|
| 1658 | { |
---|
| 1659 | READ_FLAG( uiCode, "separate_colour_plane_flag"); repFormat->setSeparateColourPlaneVpsFlag(uiCode ? true : false); |
---|
| 1660 | } |
---|
[313] | 1661 | |
---|
[442] | 1662 | READ_CODE ( 16, uiCode, "pic_width_in_luma_samples" ); repFormat->setPicWidthVpsInLumaSamples ( uiCode ); |
---|
| 1663 | READ_CODE ( 16, uiCode, "pic_height_in_luma_samples" ); repFormat->setPicHeightVpsInLumaSamples( uiCode ); |
---|
[494] | 1664 | |
---|
[442] | 1665 | READ_CODE( 4, uiCode, "bit_depth_luma_minus8" ); repFormat->setBitDepthVpsLuma ( uiCode + 8 ); |
---|
| 1666 | READ_CODE( 4, uiCode, "bit_depth_chroma_minus8" ); repFormat->setBitDepthVpsChroma( uiCode + 8 ); |
---|
[540] | 1667 | #endif |
---|
[442] | 1668 | } |
---|
| 1669 | #endif |
---|
[588] | 1670 | #if VPS_DPB_SIZE_TABLE |
---|
| 1671 | Void TDecCavlc::parseVpsDpbSizeTable( TComVPS *vps ) |
---|
| 1672 | { |
---|
| 1673 | UInt uiCode; |
---|
[614] | 1674 | #if DPB_PARAMS_MAXTLAYERS |
---|
| 1675 | Int * MaxSubLayersInLayerSetMinus1 = new Int[vps->getNumOutputLayerSets()]; |
---|
| 1676 | for(Int i = 1; i < vps->getNumOutputLayerSets(); i++) |
---|
| 1677 | { |
---|
| 1678 | UInt maxSLMinus1 = 0; |
---|
| 1679 | #if CHANGE_NUMSUBDPB_IDX |
---|
| 1680 | Int optLsIdx = vps->getOutputLayerSetIdx( i ); |
---|
| 1681 | #else |
---|
| 1682 | Int optLsIdx = i; |
---|
| 1683 | #endif |
---|
| 1684 | for(Int k = 0; k < vps->getNumLayersInIdList(optLsIdx); k++ ) { |
---|
| 1685 | Int lId = vps->getLayerSetLayerIdList(optLsIdx, k); |
---|
| 1686 | maxSLMinus1 = max(maxSLMinus1, vps->getMaxTSLayersMinus1(vps->getLayerIdInVps(lId))); |
---|
| 1687 | } |
---|
| 1688 | MaxSubLayersInLayerSetMinus1[ i ] = maxSLMinus1; |
---|
| 1689 | } |
---|
| 1690 | #endif |
---|
| 1691 | |
---|
[588] | 1692 | #if !RESOLUTION_BASED_DPB |
---|
| 1693 | vps->deriveNumberOfSubDpbs(); |
---|
| 1694 | #endif |
---|
| 1695 | for(Int i = 1; i < vps->getNumOutputLayerSets(); i++) |
---|
| 1696 | { |
---|
| 1697 | #if CHANGE_NUMSUBDPB_IDX |
---|
| 1698 | Int layerSetIdxForOutputLayerSet = vps->getOutputLayerSetIdx( i ); |
---|
| 1699 | #endif |
---|
| 1700 | READ_FLAG( uiCode, "sub_layer_flag_info_present_flag[i]"); vps->setSubLayerFlagInfoPresentFlag( i, uiCode ? true : false ); |
---|
[614] | 1701 | #if DPB_PARAMS_MAXTLAYERS |
---|
| 1702 | for(Int j = 0; j <= MaxSubLayersInLayerSetMinus1[ i ]; j++) |
---|
| 1703 | #else |
---|
| 1704 | for(Int j = 0; j <= vps->getMaxTLayers(); j++) |
---|
| 1705 | #endif |
---|
[588] | 1706 | { |
---|
| 1707 | if( j > 0 && vps->getSubLayerFlagInfoPresentFlag(i) ) |
---|
| 1708 | { |
---|
| 1709 | READ_FLAG( uiCode, "sub_layer_dpb_info_present_flag[i]"); vps->setSubLayerDpbInfoPresentFlag( i, j, uiCode ? true : false); |
---|
| 1710 | } |
---|
| 1711 | else |
---|
| 1712 | { |
---|
| 1713 | if( j == 0 ) // Always signal for the first sub-layer |
---|
| 1714 | { |
---|
| 1715 | vps->setSubLayerDpbInfoPresentFlag( i, j, true ); |
---|
| 1716 | } |
---|
| 1717 | else // if (j != 0) && !vps->getSubLayerFlagInfoPresentFlag(i) |
---|
| 1718 | { |
---|
| 1719 | vps->setSubLayerDpbInfoPresentFlag( i, j, false ); |
---|
| 1720 | } |
---|
| 1721 | } |
---|
| 1722 | if( vps->getSubLayerDpbInfoPresentFlag(i, j) ) // If sub-layer DPB information is present |
---|
| 1723 | { |
---|
| 1724 | #if CHANGE_NUMSUBDPB_IDX |
---|
| 1725 | for(Int k = 0; k < vps->getNumSubDpbs(layerSetIdxForOutputLayerSet); k++) |
---|
| 1726 | #else |
---|
| 1727 | for(Int k = 0; k < vps->getNumSubDpbs(i); k++) |
---|
| 1728 | #endif |
---|
| 1729 | { |
---|
| 1730 | READ_UVLC( uiCode, "max_vps_dec_pic_buffering_minus1[i][k][j]" ); vps->setMaxVpsDecPicBufferingMinus1( i, k, j, uiCode ); |
---|
| 1731 | } |
---|
| 1732 | READ_UVLC( uiCode, "max_vps_num_reorder_pics[i][j]" ); vps->setMaxVpsNumReorderPics( i, j, uiCode); |
---|
| 1733 | #if RESOLUTION_BASED_DPB |
---|
| 1734 | if( vps->getNumSubDpbs(layerSetIdxForOutputLayerSet) != vps->getNumLayersInIdList( layerSetIdxForOutputLayerSet ) ) |
---|
| 1735 | { |
---|
| 1736 | for(Int k = 0; k < vps->getNumLayersInIdList( layerSetIdxForOutputLayerSet ); k++) |
---|
| 1737 | { |
---|
| 1738 | READ_UVLC( uiCode, "max_vps_layer_dec_pic_buff_minus1[i][k][j]" ); vps->setMaxVpsLayerDecPicBuffMinus1( i, k, j, uiCode); |
---|
| 1739 | } |
---|
| 1740 | } |
---|
| 1741 | else // vps->getNumSubDpbs(layerSetIdxForOutputLayerSet) == vps->getNumLayersInIdList( layerSetIdxForOutputLayerSet ) |
---|
| 1742 | { |
---|
| 1743 | for(Int k = 0; k < vps->getNumLayersInIdList( layerSetIdxForOutputLayerSet ); k++) |
---|
| 1744 | { |
---|
| 1745 | vps->setMaxVpsLayerDecPicBuffMinus1( i, k, j, vps->getMaxVpsDecPicBufferingMinus1( i, k, j)); |
---|
| 1746 | } |
---|
| 1747 | } |
---|
| 1748 | #endif |
---|
| 1749 | READ_UVLC( uiCode, "max_vps_latency_increase_plus1[i][j]" ); vps->setMaxVpsLatencyIncreasePlus1( i, j, uiCode); |
---|
| 1750 | } |
---|
| 1751 | } |
---|
[610] | 1752 | for(Int j = vps->getMaxTLayers(); j < MAX_TLAYER; j++) |
---|
| 1753 | { |
---|
| 1754 | vps->setSubLayerDpbInfoPresentFlag( i, j, false ); |
---|
| 1755 | } |
---|
[588] | 1756 | } |
---|
[610] | 1757 | |
---|
| 1758 | // Infer values when not signalled |
---|
| 1759 | for(Int i = 1; i < vps->getNumOutputLayerSets(); i++) |
---|
| 1760 | { |
---|
| 1761 | Int layerSetIdxForOutputLayerSet = vps->getOutputLayerSetIdx( i ); |
---|
| 1762 | for(Int j = 0; j < MAX_TLAYER; j++) |
---|
| 1763 | { |
---|
| 1764 | if( !vps->getSubLayerDpbInfoPresentFlag(i, j) ) // If sub-layer DPB information is NOT present |
---|
| 1765 | { |
---|
| 1766 | for(Int k = 0; k < vps->getNumSubDpbs(layerSetIdxForOutputLayerSet); k++) |
---|
| 1767 | { |
---|
| 1768 | vps->setMaxVpsDecPicBufferingMinus1( i, k, j, vps->getMaxVpsDecPicBufferingMinus1( i, k, j - 1 ) ); |
---|
| 1769 | } |
---|
| 1770 | vps->setMaxVpsNumReorderPics( i, j, vps->getMaxVpsNumReorderPics( i, j - 1) ); |
---|
| 1771 | for(Int k = 0; k < vps->getNumLayersInIdList( layerSetIdxForOutputLayerSet ); k++) |
---|
| 1772 | { |
---|
| 1773 | vps->setMaxVpsLayerDecPicBuffMinus1( i, k, j, vps->getMaxVpsLayerDecPicBuffMinus1( i, k, j - 1)); |
---|
| 1774 | } |
---|
| 1775 | vps->setMaxVpsLatencyIncreasePlus1( i, j, vps->getMaxVpsLatencyIncreasePlus1( i, j - 1 ) ); |
---|
| 1776 | } |
---|
| 1777 | } |
---|
| 1778 | } |
---|
[588] | 1779 | } |
---|
| 1780 | #endif |
---|
[442] | 1781 | #if VPS_VUI |
---|
| 1782 | Void TDecCavlc::parseVPSVUI(TComVPS *vps) |
---|
| 1783 | { |
---|
| 1784 | UInt i,j; |
---|
| 1785 | UInt uiCode; |
---|
[540] | 1786 | #if O0223_PICTURE_TYPES_ALIGN_FLAG |
---|
| 1787 | READ_FLAG(uiCode, "cross_layer_pic_type_aligned_flag" ); |
---|
| 1788 | vps->setCrossLayerPictureTypeAlignFlag(uiCode); |
---|
| 1789 | if (!uiCode) |
---|
| 1790 | { |
---|
| 1791 | #endif |
---|
[494] | 1792 | #if IRAP_ALIGN_FLAG_IN_VPS_VUI |
---|
[540] | 1793 | READ_FLAG(uiCode, "cross_layer_irap_aligned_flag" ); |
---|
| 1794 | vps->setCrossLayerIrapAlignFlag(uiCode); |
---|
[624] | 1795 | #if P0068_CROSS_LAYER_ALIGNED_IDR_ONLY_FOR_IRAP_FLAG |
---|
| 1796 | if (uiCode) |
---|
| 1797 | { |
---|
[648] | 1798 | READ_FLAG(uiCode, "all_layers_idr_aligned_flag" ); |
---|
[624] | 1799 | vps->setCrossLayerIrapAlignFlag(uiCode); |
---|
| 1800 | } |
---|
[494] | 1801 | #endif |
---|
[624] | 1802 | #endif |
---|
[540] | 1803 | #if O0223_PICTURE_TYPES_ALIGN_FLAG |
---|
| 1804 | } |
---|
| 1805 | else |
---|
| 1806 | { |
---|
| 1807 | vps->setCrossLayerIrapAlignFlag(true); |
---|
| 1808 | } |
---|
| 1809 | #endif |
---|
[442] | 1810 | #if VPS_VUI_BITRATE_PICRATE |
---|
| 1811 | READ_FLAG( uiCode, "bit_rate_present_vps_flag" ); vps->setBitRatePresentVpsFlag( uiCode ? true : false ); |
---|
| 1812 | READ_FLAG( uiCode, "pic_rate_present_vps_flag" ); vps->setPicRatePresentVpsFlag( uiCode ? true : false ); |
---|
| 1813 | |
---|
| 1814 | Bool parseFlag = vps->getBitRatePresentVpsFlag() || vps->getPicRatePresentVpsFlag(); |
---|
| 1815 | { |
---|
| 1816 | for( i = 0; i < vps->getNumLayerSets(); i++ ) |
---|
| 1817 | { |
---|
| 1818 | for( j = 0; j < vps->getMaxTLayers(); j++ ) |
---|
| 1819 | { |
---|
| 1820 | if( parseFlag && vps->getBitRatePresentVpsFlag() ) |
---|
| 1821 | { |
---|
| 1822 | READ_FLAG( uiCode, "bit_rate_present_vps_flag[i][j]" ); vps->setBitRatePresentFlag( i, j, uiCode ? true : false ); |
---|
| 1823 | } |
---|
| 1824 | else |
---|
| 1825 | { |
---|
| 1826 | vps->setBitRatePresentFlag( i, j, false ); |
---|
| 1827 | } |
---|
| 1828 | if( parseFlag && vps->getPicRatePresentVpsFlag() ) |
---|
| 1829 | { |
---|
| 1830 | READ_FLAG( uiCode, "pic_rate_present_vps_flag[i][j]" ); vps->setPicRatePresentFlag( i, j, uiCode ? true : false ); |
---|
| 1831 | } |
---|
| 1832 | else |
---|
| 1833 | { |
---|
| 1834 | vps->setPicRatePresentFlag( i, j, false ); |
---|
| 1835 | } |
---|
| 1836 | if( parseFlag && vps->getBitRatePresentFlag(i, j) ) |
---|
| 1837 | { |
---|
| 1838 | READ_CODE( 16, uiCode, "avg_bit_rate[i][j]" ); vps->setAvgBitRate( i, j, uiCode ); |
---|
| 1839 | READ_CODE( 16, uiCode, "max_bit_rate[i][j]" ); vps->setMaxBitRate( i, j, uiCode ); |
---|
| 1840 | } |
---|
| 1841 | else |
---|
| 1842 | { |
---|
| 1843 | vps->setAvgBitRate( i, j, 0 ); |
---|
| 1844 | vps->setMaxBitRate( i, j, 0 ); |
---|
| 1845 | } |
---|
| 1846 | if( parseFlag && vps->getPicRatePresentFlag(i, j) ) |
---|
| 1847 | { |
---|
| 1848 | READ_CODE( 2 , uiCode, "constant_pic_rate_idc[i][j]" ); vps->setConstPicRateIdc( i, j, uiCode ); |
---|
| 1849 | READ_CODE( 16, uiCode, "avg_pic_rate[i][j]" ); vps->setAvgPicRate( i, j, uiCode ); |
---|
| 1850 | } |
---|
| 1851 | else |
---|
| 1852 | { |
---|
| 1853 | vps->setConstPicRateIdc( i, j, 0 ); |
---|
| 1854 | vps->setAvgPicRate ( i, j, 0 ); |
---|
| 1855 | } |
---|
| 1856 | } |
---|
| 1857 | } |
---|
| 1858 | } |
---|
| 1859 | #endif |
---|
[588] | 1860 | #if VPS_VUI_VIDEO_SIGNAL_MOVE |
---|
| 1861 | READ_FLAG( uiCode, "video_signal_info_idx_present_flag" ); vps->setVideoSigPresentVpsFlag( uiCode == 1 ); |
---|
| 1862 | if (vps->getVideoSigPresentVpsFlag()) |
---|
| 1863 | { |
---|
| 1864 | READ_CODE(4, uiCode, "vps_num_video_signal_info_minus1" ); vps->setNumVideoSignalInfo(uiCode + 1); |
---|
| 1865 | } |
---|
| 1866 | else |
---|
| 1867 | { |
---|
| 1868 | vps->setNumVideoSignalInfo(vps->getMaxLayers()); |
---|
| 1869 | } |
---|
| 1870 | |
---|
| 1871 | |
---|
| 1872 | for(i = 0; i < vps->getNumVideoSignalInfo(); i++) |
---|
| 1873 | { |
---|
| 1874 | READ_CODE(3, uiCode, "video_vps_format" ); vps->setVideoVPSFormat(i,uiCode); |
---|
| 1875 | READ_FLAG(uiCode, "video_full_range_vps_flag" ); vps->setVideoFullRangeVpsFlag(i,uiCode); |
---|
| 1876 | READ_CODE(8, uiCode, "color_primaries_vps" ); vps->setColorPrimaries(i,uiCode); |
---|
| 1877 | READ_CODE(8, uiCode, "transfer_characteristics_vps" ); vps->setTransCharacter(i,uiCode); |
---|
| 1878 | READ_CODE(8, uiCode, "matrix_coeffs_vps" );vps->setMaxtrixCoeff(i,uiCode); |
---|
| 1879 | } |
---|
| 1880 | if(!vps->getVideoSigPresentVpsFlag()) |
---|
| 1881 | { |
---|
| 1882 | for (i=0; i < vps->getMaxLayers(); i++) |
---|
| 1883 | { |
---|
| 1884 | vps->setVideoSignalInfoIdx(i,i); |
---|
| 1885 | } |
---|
| 1886 | } |
---|
| 1887 | else { |
---|
| 1888 | vps->setVideoSignalInfoIdx(0,0); |
---|
| 1889 | if (vps->getNumVideoSignalInfo() > 1 ) |
---|
| 1890 | { |
---|
| 1891 | for (i=1; i < vps->getMaxLayers(); i++) |
---|
| 1892 | READ_CODE(4, uiCode, "vps_video_signal_info_idx" ); vps->setVideoSignalInfoIdx(i, uiCode); |
---|
| 1893 | } |
---|
| 1894 | else { |
---|
| 1895 | for (i=1; i < vps->getMaxLayers(); i++) |
---|
| 1896 | { |
---|
| 1897 | vps->setVideoSignalInfoIdx(i,0); |
---|
| 1898 | } |
---|
| 1899 | } |
---|
| 1900 | } |
---|
| 1901 | #endif |
---|
[540] | 1902 | #if VPS_VUI_TILES_NOT_IN_USE__FLAG |
---|
| 1903 | UInt layerIdx; |
---|
| 1904 | READ_FLAG( uiCode, "tiles_not_in_use_flag" ); vps->setTilesNotInUseFlag(uiCode == 1); |
---|
| 1905 | if (!uiCode) |
---|
| 1906 | { |
---|
| 1907 | for(i = 0; i < vps->getMaxLayers(); i++) |
---|
| 1908 | { |
---|
| 1909 | READ_FLAG( uiCode, "tiles_in_use_flag[ i ]" ); vps->setTilesInUseFlag(i, (uiCode == 1)); |
---|
| 1910 | if (uiCode) |
---|
| 1911 | { |
---|
| 1912 | READ_FLAG( uiCode, "loop_filter_not_across_tiles_flag[ i ]" ); vps->setLoopFilterNotAcrossTilesFlag(i, (uiCode == 1)); |
---|
| 1913 | } |
---|
| 1914 | else |
---|
| 1915 | { |
---|
| 1916 | vps->setLoopFilterNotAcrossTilesFlag(i, false); |
---|
| 1917 | } |
---|
| 1918 | } |
---|
| 1919 | #endif |
---|
[442] | 1920 | #if TILE_BOUNDARY_ALIGNED_FLAG |
---|
[540] | 1921 | for(i = 1; i < vps->getMaxLayers(); i++) |
---|
| 1922 | { |
---|
| 1923 | for(j = 0; j < vps->getNumDirectRefLayers(vps->getLayerIdInNuh(i)); j++) |
---|
| 1924 | { |
---|
| 1925 | #if VPS_VUI_TILES_NOT_IN_USE__FLAG |
---|
| 1926 | layerIdx = vps->getLayerIdInVps(vps->getRefLayerId(vps->getLayerIdInNuh(i), j)); |
---|
| 1927 | if (vps->getTilesInUseFlag(i) && vps->getTilesInUseFlag(layerIdx)) { |
---|
| 1928 | READ_FLAG( uiCode, "tile_boundaries_aligned_flag[i][j]" ); vps->setTileBoundariesAlignedFlag(i,j,(uiCode == 1)); |
---|
| 1929 | } |
---|
| 1930 | #else |
---|
| 1931 | READ_FLAG( uiCode, "tile_boundaries_aligned_flag[i][j]" ); vps->setTileBoundariesAlignedFlag(i,j,(uiCode == 1)); |
---|
| 1932 | #endif |
---|
| 1933 | } |
---|
| 1934 | } |
---|
| 1935 | #endif |
---|
| 1936 | #if VPS_VUI_TILES_NOT_IN_USE__FLAG |
---|
| 1937 | } |
---|
| 1938 | #endif |
---|
| 1939 | #if VPS_VUI_WPP_NOT_IN_USE__FLAG |
---|
| 1940 | READ_FLAG( uiCode, "wpp_not_in_use_flag" ); vps->setWppNotInUseFlag(uiCode == 1); |
---|
| 1941 | if (!uiCode) |
---|
[442] | 1942 | { |
---|
[540] | 1943 | for(i = 0; i < vps->getMaxLayers(); i++) |
---|
[442] | 1944 | { |
---|
[540] | 1945 | READ_FLAG( uiCode, "wpp_in_use_flag[ i ]" ); vps->setWppInUseFlag(i, (uiCode == 1)); |
---|
[442] | 1946 | } |
---|
[494] | 1947 | } |
---|
| 1948 | #endif |
---|
[547] | 1949 | |
---|
| 1950 | #if O0109_O0199_FLAGS_TO_VUI |
---|
| 1951 | #if M0040_ADAPTIVE_RESOLUTION_CHANGE |
---|
| 1952 | READ_FLAG(uiCode, "single_layer_for_non_irap_flag" ); vps->setSingleLayerForNonIrapFlag(uiCode == 1 ? true : false); |
---|
| 1953 | #endif |
---|
| 1954 | #if HIGHER_LAYER_IRAP_SKIP_FLAG |
---|
| 1955 | READ_FLAG(uiCode, "higher_layer_irap_skip_flag" ); vps->setHigherLayerIrapSkipFlag(uiCode == 1 ? true : false); |
---|
| 1956 | #endif |
---|
| 1957 | #endif |
---|
[633] | 1958 | #if P0312_VERT_PHASE_ADJ |
---|
| 1959 | READ_FLAG( uiCode, "vps_vui_vert_phase_in_use_flag" ); vps->setVpsVuiVertPhaseInUseFlag(uiCode); |
---|
| 1960 | #endif |
---|
[442] | 1961 | #if N0160_VUI_EXT_ILP_REF |
---|
[588] | 1962 | READ_FLAG( uiCode, "ilp_restricted_ref_layers_flag" ); vps->setIlpRestrictedRefLayersFlag( uiCode == 1 ); |
---|
| 1963 | if( vps->getIlpRestrictedRefLayersFlag()) |
---|
[442] | 1964 | { |
---|
| 1965 | for(i = 1; i < vps->getMaxLayers(); i++) |
---|
| 1966 | { |
---|
| 1967 | for(j = 0; j < vps->getNumDirectRefLayers(vps->getLayerIdInNuh(i)); j++) |
---|
| 1968 | { |
---|
[494] | 1969 | READ_UVLC( uiCode, "min_spatial_segment_offset_plus1[i][j]" ); vps->setMinSpatialSegmentOffsetPlus1( i, j, uiCode ); |
---|
| 1970 | if( vps->getMinSpatialSegmentOffsetPlus1(i,j ) > 0 ) |
---|
| 1971 | { |
---|
| 1972 | READ_FLAG( uiCode, "ctu_based_offset_enabled_flag[i][j]"); vps->setCtuBasedOffsetEnabledFlag(i, j, uiCode == 1 ); |
---|
| 1973 | if(vps->getCtuBasedOffsetEnabledFlag(i,j)) |
---|
[442] | 1974 | { |
---|
[494] | 1975 | READ_UVLC( uiCode, "min_horizontal_ctu_offset_plus1[i][j]"); vps->setMinHorizontalCtuOffsetPlus1( i,j, uiCode ); |
---|
[442] | 1976 | } |
---|
[494] | 1977 | } |
---|
| 1978 | } |
---|
[442] | 1979 | } |
---|
| 1980 | } |
---|
[494] | 1981 | #endif |
---|
[540] | 1982 | #if VPS_VUI_VIDEO_SIGNAL |
---|
[588] | 1983 | #if VPS_VUI_VIDEO_SIGNAL_MOVE |
---|
| 1984 | #else |
---|
[540] | 1985 | READ_FLAG( uiCode, "video_signal_info_idx_present_flag" ); vps->setVideoSigPresentVpsFlag( uiCode == 1 ); |
---|
| 1986 | if (vps->getVideoSigPresentVpsFlag()) |
---|
| 1987 | { |
---|
| 1988 | READ_CODE(4, uiCode, "vps_num_video_signal_info_minus1" ); vps->setNumVideoSignalInfo(uiCode + 1); |
---|
| 1989 | } |
---|
| 1990 | else |
---|
| 1991 | { |
---|
| 1992 | vps->setNumVideoSignalInfo(vps->getMaxLayers()); |
---|
| 1993 | } |
---|
| 1994 | |
---|
| 1995 | |
---|
| 1996 | for(i = 0; i < vps->getNumVideoSignalInfo(); i++) |
---|
| 1997 | { |
---|
| 1998 | READ_CODE(3, uiCode, "video_vps_format" ); vps->setVideoVPSFormat(i,uiCode); |
---|
| 1999 | READ_FLAG(uiCode, "video_full_range_vps_flag" ); vps->setVideoFullRangeVpsFlag(i,uiCode); |
---|
| 2000 | READ_CODE(8, uiCode, "color_primaries_vps" ); vps->setColorPrimaries(i,uiCode); |
---|
| 2001 | READ_CODE(8, uiCode, "transfer_characteristics_vps" ); vps->setTransCharacter(i,uiCode); |
---|
| 2002 | READ_CODE(8, uiCode, "matrix_coeffs_vps" );vps->setMaxtrixCoeff(i,uiCode); |
---|
| 2003 | } |
---|
| 2004 | if(!vps->getVideoSigPresentVpsFlag()) |
---|
| 2005 | { |
---|
| 2006 | for (i=0; i < vps->getMaxLayers(); i++) |
---|
| 2007 | { |
---|
| 2008 | vps->setVideoSignalInfoIdx(i,i); |
---|
| 2009 | } |
---|
| 2010 | } |
---|
| 2011 | else { |
---|
| 2012 | vps->setVideoSignalInfoIdx(0,0); |
---|
| 2013 | if (vps->getNumVideoSignalInfo() > 1 ) |
---|
| 2014 | { |
---|
| 2015 | for (i=1; i < vps->getMaxLayers(); i++) |
---|
| 2016 | READ_CODE(4, uiCode, "vps_video_signal_info_idx" ); vps->setVideoSignalInfoIdx(i, uiCode); |
---|
| 2017 | } |
---|
| 2018 | else { |
---|
| 2019 | for (i=1; i < vps->getMaxLayers(); i++) |
---|
| 2020 | { |
---|
| 2021 | vps->setVideoSignalInfoIdx(i,0); |
---|
| 2022 | } |
---|
| 2023 | } |
---|
| 2024 | } |
---|
[588] | 2025 | #endif |
---|
[540] | 2026 | #endif |
---|
[605] | 2027 | |
---|
[628] | 2028 | #if O0164_MULTI_LAYER_HRD |
---|
| 2029 | READ_FLAG(uiCode, "vps_vui_bsp_hrd_present_flag" ); vps->setVpsVuiBspHrdPresentFlag(uiCode); |
---|
| 2030 | if (vps->getVpsVuiBspHrdPresentFlag()) |
---|
| 2031 | { |
---|
| 2032 | READ_UVLC( uiCode, "vps_num_bsp_hrd_parameters_minus1" ); vps->setVpsNumBspHrdParametersMinus1(uiCode); |
---|
| 2033 | vps->createBspHrdParamBuffer(vps->getVpsNumBspHrdParametersMinus1() + 1); |
---|
[635] | 2034 | for( i = 0; i <= vps->getVpsNumBspHrdParametersMinus1(); i++ ) |
---|
[628] | 2035 | { |
---|
[635] | 2036 | if( i > 0 ) |
---|
[628] | 2037 | { |
---|
| 2038 | READ_FLAG( uiCode, "bsp_cprms_present_flag[i]" ); vps->setBspCprmsPresentFlag(i, uiCode); |
---|
| 2039 | } |
---|
| 2040 | parseHrdParameters(vps->getBspHrd(i), i==0 ? 1 : vps->getBspCprmsPresentFlag(i), vps->getMaxTLayers()-1); |
---|
| 2041 | } |
---|
[635] | 2042 | for( UInt h = 1; h <= (vps->getNumLayerSets()-1); h++ ) |
---|
[628] | 2043 | { |
---|
| 2044 | READ_UVLC( uiCode, "num_bitstream_partitions[i]"); vps->setNumBitstreamPartitions(h, uiCode); |
---|
[635] | 2045 | for( i = 0; i < vps->getNumBitstreamPartitions(h); i++ ) |
---|
[628] | 2046 | { |
---|
[635] | 2047 | for( j = 0; j <= (vps->getMaxLayers()-1); j++ ) |
---|
[628] | 2048 | { |
---|
[635] | 2049 | if( vps->getLayerIdIncludedFlag(h, j) ) |
---|
[628] | 2050 | { |
---|
| 2051 | READ_FLAG( uiCode, "layer_in_bsp_flag[h][i][j]" ); vps->setLayerInBspFlag(h, i, j, uiCode); |
---|
| 2052 | } |
---|
| 2053 | } |
---|
| 2054 | } |
---|
| 2055 | if (vps->getNumBitstreamPartitions(h)) |
---|
| 2056 | { |
---|
| 2057 | READ_UVLC( uiCode, "num_bsp_sched_combinations[h]"); vps->setNumBspSchedCombinations(h, uiCode); |
---|
[635] | 2058 | for( i = 0; i < vps->getNumBspSchedCombinations(h); i++ ) |
---|
[628] | 2059 | { |
---|
[635] | 2060 | for( j = 0; j < vps->getNumBitstreamPartitions(h); j++ ) |
---|
[628] | 2061 | { |
---|
| 2062 | READ_UVLC( uiCode, "bsp_comb_hrd_idx[h][i][j]"); vps->setBspCombHrdIdx(h, i, j, uiCode); |
---|
| 2063 | READ_UVLC( uiCode, "bsp_comb_sched_idx[h][i][j]"); vps->setBspCombSchedIdx(h, i, j, uiCode); |
---|
| 2064 | } |
---|
| 2065 | } |
---|
| 2066 | } |
---|
| 2067 | } |
---|
| 2068 | } |
---|
| 2069 | #endif |
---|
| 2070 | |
---|
[605] | 2071 | #if P0182_VPS_VUI_PS_FLAG |
---|
| 2072 | for(i = 1; i < vps->getMaxLayers(); i++) |
---|
| 2073 | { |
---|
| 2074 | if (vps->getNumRefLayers(vps->getLayerIdInNuh(i)) == 0) |
---|
| 2075 | { |
---|
| 2076 | READ_FLAG( uiCode, "base_layer_parameter_set_compatibility_flag" ); |
---|
| 2077 | vps->setBaseLayerPSCompatibilityFlag( i, uiCode ); |
---|
| 2078 | } |
---|
| 2079 | else |
---|
| 2080 | { |
---|
| 2081 | vps->setBaseLayerPSCompatibilityFlag( i, 0 ); |
---|
| 2082 | } |
---|
| 2083 | } |
---|
| 2084 | #endif |
---|
[442] | 2085 | } |
---|
[494] | 2086 | #endif |
---|
| 2087 | #endif //SVC_EXTENSION |
---|
| 2088 | |
---|
[313] | 2089 | Void TDecCavlc::parseSliceHeader (TComSlice*& rpcSlice, ParameterSetManagerDecoder *parameterSetManager) |
---|
| 2090 | { |
---|
| 2091 | UInt uiCode; |
---|
| 2092 | Int iCode; |
---|
| 2093 | |
---|
| 2094 | #if ENC_DEC_TRACE |
---|
| 2095 | xTraceSliceHeader(rpcSlice); |
---|
| 2096 | #endif |
---|
| 2097 | TComPPS* pps = NULL; |
---|
| 2098 | TComSPS* sps = NULL; |
---|
| 2099 | |
---|
| 2100 | UInt firstSliceSegmentInPic; |
---|
| 2101 | READ_FLAG( firstSliceSegmentInPic, "first_slice_segment_in_pic_flag" ); |
---|
| 2102 | if( rpcSlice->getRapPicFlag()) |
---|
| 2103 | { |
---|
[625] | 2104 | #if !NO_OUTPUT_OF_PRIOR_PICS |
---|
[313] | 2105 | READ_FLAG( uiCode, "no_output_of_prior_pics_flag" ); //ignored |
---|
[625] | 2106 | #else |
---|
| 2107 | READ_FLAG( uiCode, "no_output_of_prior_pics_flag" ); rpcSlice->setNoOutputOfPriorPicsFlag( uiCode ? true : false ); |
---|
| 2108 | #endif |
---|
[313] | 2109 | } |
---|
| 2110 | READ_UVLC ( uiCode, "slice_pic_parameter_set_id" ); rpcSlice->setPPSId(uiCode); |
---|
| 2111 | pps = parameterSetManager->getPrefetchedPPS(uiCode); |
---|
| 2112 | //!KS: need to add error handling code here, if PPS is not available |
---|
| 2113 | assert(pps!=0); |
---|
| 2114 | sps = parameterSetManager->getPrefetchedSPS(pps->getSPSId()); |
---|
| 2115 | //!KS: need to add error handling code here, if SPS is not available |
---|
| 2116 | assert(sps!=0); |
---|
| 2117 | rpcSlice->setSPS(sps); |
---|
| 2118 | rpcSlice->setPPS(pps); |
---|
| 2119 | if( pps->getDependentSliceSegmentsEnabledFlag() && ( !firstSliceSegmentInPic )) |
---|
| 2120 | { |
---|
| 2121 | READ_FLAG( uiCode, "dependent_slice_segment_flag" ); rpcSlice->setDependentSliceSegmentFlag(uiCode ? true : false); |
---|
| 2122 | } |
---|
| 2123 | else |
---|
| 2124 | { |
---|
| 2125 | rpcSlice->setDependentSliceSegmentFlag(false); |
---|
| 2126 | } |
---|
[442] | 2127 | #if REPN_FORMAT_IN_VPS |
---|
| 2128 | Int numCTUs = ((rpcSlice->getPicWidthInLumaSamples()+sps->getMaxCUWidth()-1)/sps->getMaxCUWidth())*((rpcSlice->getPicHeightInLumaSamples()+sps->getMaxCUHeight()-1)/sps->getMaxCUHeight()); |
---|
| 2129 | #else |
---|
[313] | 2130 | Int numCTUs = ((sps->getPicWidthInLumaSamples()+sps->getMaxCUWidth()-1)/sps->getMaxCUWidth())*((sps->getPicHeightInLumaSamples()+sps->getMaxCUHeight()-1)/sps->getMaxCUHeight()); |
---|
[442] | 2131 | #endif |
---|
[313] | 2132 | Int maxParts = (1<<(sps->getMaxCUDepth()<<1)); |
---|
| 2133 | UInt sliceSegmentAddress = 0; |
---|
| 2134 | Int bitsSliceSegmentAddress = 0; |
---|
| 2135 | while(numCTUs>(1<<bitsSliceSegmentAddress)) |
---|
| 2136 | { |
---|
| 2137 | bitsSliceSegmentAddress++; |
---|
| 2138 | } |
---|
| 2139 | |
---|
| 2140 | if(!firstSliceSegmentInPic) |
---|
| 2141 | { |
---|
| 2142 | READ_CODE( bitsSliceSegmentAddress, sliceSegmentAddress, "slice_segment_address" ); |
---|
| 2143 | } |
---|
| 2144 | //set uiCode to equal slice start address (or dependent slice start address) |
---|
| 2145 | Int startCuAddress = maxParts*sliceSegmentAddress; |
---|
| 2146 | rpcSlice->setSliceSegmentCurStartCUAddr( startCuAddress ); |
---|
| 2147 | rpcSlice->setSliceSegmentCurEndCUAddr(numCTUs*maxParts); |
---|
| 2148 | |
---|
| 2149 | if (rpcSlice->getDependentSliceSegmentFlag()) |
---|
| 2150 | { |
---|
| 2151 | rpcSlice->setNextSlice ( false ); |
---|
| 2152 | rpcSlice->setNextSliceSegment ( true ); |
---|
| 2153 | } |
---|
| 2154 | else |
---|
| 2155 | { |
---|
| 2156 | rpcSlice->setNextSlice ( true ); |
---|
| 2157 | rpcSlice->setNextSliceSegment ( false ); |
---|
| 2158 | |
---|
| 2159 | rpcSlice->setSliceCurStartCUAddr(startCuAddress); |
---|
| 2160 | rpcSlice->setSliceCurEndCUAddr(numCTUs*maxParts); |
---|
| 2161 | } |
---|
| 2162 | |
---|
| 2163 | if(!rpcSlice->getDependentSliceSegmentFlag()) |
---|
| 2164 | { |
---|
[494] | 2165 | #if SVC_EXTENSION |
---|
[442] | 2166 | #if POC_RESET_FLAG |
---|
[494] | 2167 | Int iBits = 0; |
---|
[442] | 2168 | if(rpcSlice->getPPS()->getNumExtraSliceHeaderBits() > iBits) |
---|
| 2169 | { |
---|
| 2170 | READ_FLAG(uiCode, "poc_reset_flag"); rpcSlice->setPocResetFlag( uiCode ? true : false ); |
---|
| 2171 | iBits++; |
---|
| 2172 | } |
---|
| 2173 | if(rpcSlice->getPPS()->getNumExtraSliceHeaderBits() > iBits) |
---|
| 2174 | { |
---|
[588] | 2175 | #if DISCARDABLE_PIC_RPS |
---|
| 2176 | READ_FLAG(uiCode, "discardable_flag"); rpcSlice->setDiscardableFlag( uiCode ? true : false ); |
---|
| 2177 | #else |
---|
[442] | 2178 | READ_FLAG(uiCode, "discardable_flag"); // ignored |
---|
[588] | 2179 | #endif |
---|
[442] | 2180 | iBits++; |
---|
| 2181 | } |
---|
[540] | 2182 | #if O0149_CROSS_LAYER_BLA_FLAG |
---|
| 2183 | if(rpcSlice->getPPS()->getNumExtraSliceHeaderBits() > iBits) |
---|
| 2184 | { |
---|
| 2185 | READ_FLAG(uiCode, "cross_layer_bla_flag"); rpcSlice->setCrossLayerBLAFlag( uiCode ? true : false ); |
---|
| 2186 | iBits++; |
---|
| 2187 | } |
---|
| 2188 | #endif |
---|
[442] | 2189 | for (; iBits < rpcSlice->getPPS()->getNumExtraSliceHeaderBits(); iBits++) |
---|
| 2190 | { |
---|
| 2191 | READ_FLAG(uiCode, "slice_reserved_undetermined_flag[]"); // ignored |
---|
| 2192 | } |
---|
| 2193 | #else |
---|
[313] | 2194 | if(rpcSlice->getPPS()->getNumExtraSliceHeaderBits()>0) |
---|
| 2195 | { |
---|
| 2196 | READ_FLAG(uiCode, "discardable_flag"); // ignored |
---|
| 2197 | } |
---|
| 2198 | for (Int i = 1; i < rpcSlice->getPPS()->getNumExtraSliceHeaderBits(); i++) |
---|
| 2199 | { |
---|
| 2200 | READ_FLAG(uiCode, "slice_reserved_undetermined_flag[]"); // ignored |
---|
| 2201 | } |
---|
[494] | 2202 | #endif |
---|
| 2203 | #else //SVC_EXTENSION |
---|
[313] | 2204 | for (Int i = 0; i < rpcSlice->getPPS()->getNumExtraSliceHeaderBits(); i++) |
---|
| 2205 | { |
---|
| 2206 | READ_FLAG(uiCode, "slice_reserved_undetermined_flag[]"); // ignored |
---|
| 2207 | } |
---|
[494] | 2208 | #endif //SVC_EXTENSION |
---|
[313] | 2209 | |
---|
| 2210 | READ_UVLC ( uiCode, "slice_type" ); rpcSlice->setSliceType((SliceType)uiCode); |
---|
| 2211 | if( pps->getOutputFlagPresentFlag() ) |
---|
| 2212 | { |
---|
| 2213 | READ_FLAG( uiCode, "pic_output_flag" ); rpcSlice->setPicOutputFlag( uiCode ? true : false ); |
---|
| 2214 | } |
---|
| 2215 | else |
---|
| 2216 | { |
---|
| 2217 | rpcSlice->setPicOutputFlag( true ); |
---|
| 2218 | } |
---|
| 2219 | // in the first version chroma_format_idc is equal to one, thus colour_plane_id will not be present |
---|
| 2220 | assert (sps->getChromaFormatIdc() == 1 ); |
---|
| 2221 | // if( separate_colour_plane_flag == 1 ) |
---|
| 2222 | // colour_plane_id u(2) |
---|
| 2223 | |
---|
| 2224 | if( rpcSlice->getIdrPicFlag() ) |
---|
| 2225 | { |
---|
| 2226 | rpcSlice->setPOC(0); |
---|
| 2227 | TComReferencePictureSet* rps = rpcSlice->getLocalRPS(); |
---|
| 2228 | rps->setNumberOfNegativePictures(0); |
---|
| 2229 | rps->setNumberOfPositivePictures(0); |
---|
| 2230 | rps->setNumberOfLongtermPictures(0); |
---|
| 2231 | rps->setNumberOfPictures(0); |
---|
| 2232 | rpcSlice->setRPS(rps); |
---|
| 2233 | } |
---|
[442] | 2234 | #if N0065_LAYER_POC_ALIGNMENT |
---|
[494] | 2235 | #if SHM_FIX7 |
---|
| 2236 | Int iPOClsb = 0; |
---|
| 2237 | #endif |
---|
| 2238 | #if O0062_POC_LSB_NOT_PRESENT_FLAG |
---|
| 2239 | if( ( rpcSlice->getLayerId() > 0 && !rpcSlice->getVPS()->getPocLsbNotPresentFlag( rpcSlice->getVPS()->getLayerIdInVps(rpcSlice->getLayerId())) ) || !rpcSlice->getIdrPicFlag()) |
---|
| 2240 | #else |
---|
[442] | 2241 | if( rpcSlice->getLayerId() > 0 || !rpcSlice->getIdrPicFlag() ) |
---|
[494] | 2242 | #endif |
---|
[442] | 2243 | #else |
---|
[313] | 2244 | else |
---|
[442] | 2245 | #endif |
---|
[313] | 2246 | { |
---|
| 2247 | READ_CODE(sps->getBitsForPOC(), uiCode, "pic_order_cnt_lsb"); |
---|
[494] | 2248 | #if SHM_FIX7 |
---|
| 2249 | iPOClsb = uiCode; |
---|
| 2250 | #else |
---|
[313] | 2251 | Int iPOClsb = uiCode; |
---|
[494] | 2252 | #endif |
---|
[442] | 2253 | Int iPrevPOC = rpcSlice->getPrevTid0POC(); |
---|
[313] | 2254 | Int iMaxPOClsb = 1<< sps->getBitsForPOC(); |
---|
[442] | 2255 | Int iPrevPOClsb = iPrevPOC & (iMaxPOClsb - 1); |
---|
[313] | 2256 | Int iPrevPOCmsb = iPrevPOC-iPrevPOClsb; |
---|
| 2257 | Int iPOCmsb; |
---|
| 2258 | if( ( iPOClsb < iPrevPOClsb ) && ( ( iPrevPOClsb - iPOClsb ) >= ( iMaxPOClsb / 2 ) ) ) |
---|
| 2259 | { |
---|
| 2260 | iPOCmsb = iPrevPOCmsb + iMaxPOClsb; |
---|
| 2261 | } |
---|
| 2262 | else if( (iPOClsb > iPrevPOClsb ) && ( (iPOClsb - iPrevPOClsb ) > ( iMaxPOClsb / 2 ) ) ) |
---|
| 2263 | { |
---|
| 2264 | iPOCmsb = iPrevPOCmsb - iMaxPOClsb; |
---|
| 2265 | } |
---|
| 2266 | else |
---|
| 2267 | { |
---|
| 2268 | iPOCmsb = iPrevPOCmsb; |
---|
| 2269 | } |
---|
| 2270 | if ( rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP |
---|
| 2271 | || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL |
---|
| 2272 | || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP ) |
---|
| 2273 | { |
---|
| 2274 | // For BLA picture types, POCmsb is set to 0. |
---|
| 2275 | iPOCmsb = 0; |
---|
| 2276 | } |
---|
| 2277 | rpcSlice->setPOC (iPOCmsb+iPOClsb); |
---|
| 2278 | |
---|
[442] | 2279 | #if N0065_LAYER_POC_ALIGNMENT |
---|
[494] | 2280 | #if SHM_FIX7 |
---|
| 2281 | } |
---|
| 2282 | #endif |
---|
[442] | 2283 | if( !rpcSlice->getIdrPicFlag() ) |
---|
| 2284 | { |
---|
| 2285 | #endif |
---|
[313] | 2286 | TComReferencePictureSet* rps; |
---|
| 2287 | rps = rpcSlice->getLocalRPS(); |
---|
| 2288 | rpcSlice->setRPS(rps); |
---|
| 2289 | READ_FLAG( uiCode, "short_term_ref_pic_set_sps_flag" ); |
---|
| 2290 | if(uiCode == 0) // use short-term reference picture set explicitly signalled in slice header |
---|
| 2291 | { |
---|
| 2292 | parseShortTermRefPicSet(sps,rps, sps->getRPSList()->getNumberOfReferencePictureSets()); |
---|
| 2293 | } |
---|
| 2294 | else // use reference to short-term reference picture set in PPS |
---|
| 2295 | { |
---|
| 2296 | Int numBits = 0; |
---|
| 2297 | while ((1 << numBits) < rpcSlice->getSPS()->getRPSList()->getNumberOfReferencePictureSets()) |
---|
| 2298 | { |
---|
| 2299 | numBits++; |
---|
| 2300 | } |
---|
| 2301 | if (numBits > 0) |
---|
| 2302 | { |
---|
| 2303 | READ_CODE( numBits, uiCode, "short_term_ref_pic_set_idx"); |
---|
| 2304 | } |
---|
| 2305 | else |
---|
| 2306 | { |
---|
| 2307 | uiCode = 0; |
---|
| 2308 | } |
---|
| 2309 | *rps = *(sps->getRPSList()->getReferencePictureSet(uiCode)); |
---|
| 2310 | } |
---|
| 2311 | if(sps->getLongTermRefsPresent()) |
---|
| 2312 | { |
---|
| 2313 | Int offset = rps->getNumberOfNegativePictures()+rps->getNumberOfPositivePictures(); |
---|
| 2314 | UInt numOfLtrp = 0; |
---|
| 2315 | UInt numLtrpInSPS = 0; |
---|
| 2316 | if (rpcSlice->getSPS()->getNumLongTermRefPicSPS() > 0) |
---|
| 2317 | { |
---|
| 2318 | READ_UVLC( uiCode, "num_long_term_sps"); |
---|
| 2319 | numLtrpInSPS = uiCode; |
---|
| 2320 | numOfLtrp += numLtrpInSPS; |
---|
| 2321 | rps->setNumberOfLongtermPictures(numOfLtrp); |
---|
| 2322 | } |
---|
| 2323 | Int bitsForLtrpInSPS = 0; |
---|
| 2324 | while (rpcSlice->getSPS()->getNumLongTermRefPicSPS() > (1 << bitsForLtrpInSPS)) |
---|
| 2325 | { |
---|
| 2326 | bitsForLtrpInSPS++; |
---|
| 2327 | } |
---|
| 2328 | READ_UVLC( uiCode, "num_long_term_pics"); rps->setNumberOfLongtermPictures(uiCode); |
---|
| 2329 | numOfLtrp += uiCode; |
---|
| 2330 | rps->setNumberOfLongtermPictures(numOfLtrp); |
---|
| 2331 | Int maxPicOrderCntLSB = 1 << rpcSlice->getSPS()->getBitsForPOC(); |
---|
| 2332 | Int prevDeltaMSB = 0, deltaPocMSBCycleLT = 0;; |
---|
| 2333 | for(Int j=offset+rps->getNumberOfLongtermPictures()-1, k = 0; k < numOfLtrp; j--, k++) |
---|
| 2334 | { |
---|
| 2335 | Int pocLsbLt; |
---|
| 2336 | if (k < numLtrpInSPS) |
---|
| 2337 | { |
---|
| 2338 | uiCode = 0; |
---|
| 2339 | if (bitsForLtrpInSPS > 0) |
---|
| 2340 | { |
---|
| 2341 | READ_CODE(bitsForLtrpInSPS, uiCode, "lt_idx_sps[i]"); |
---|
| 2342 | } |
---|
| 2343 | Int usedByCurrFromSPS=rpcSlice->getSPS()->getUsedByCurrPicLtSPSFlag(uiCode); |
---|
| 2344 | |
---|
| 2345 | pocLsbLt = rpcSlice->getSPS()->getLtRefPicPocLsbSps(uiCode); |
---|
| 2346 | rps->setUsed(j,usedByCurrFromSPS); |
---|
| 2347 | } |
---|
| 2348 | else |
---|
| 2349 | { |
---|
| 2350 | READ_CODE(rpcSlice->getSPS()->getBitsForPOC(), uiCode, "poc_lsb_lt"); pocLsbLt= uiCode; |
---|
| 2351 | READ_FLAG( uiCode, "used_by_curr_pic_lt_flag"); rps->setUsed(j,uiCode); |
---|
| 2352 | } |
---|
| 2353 | READ_FLAG(uiCode,"delta_poc_msb_present_flag"); |
---|
| 2354 | Bool mSBPresentFlag = uiCode ? true : false; |
---|
| 2355 | if(mSBPresentFlag) |
---|
| 2356 | { |
---|
| 2357 | READ_UVLC( uiCode, "delta_poc_msb_cycle_lt[i]" ); |
---|
| 2358 | Bool deltaFlag = false; |
---|
| 2359 | // First LTRP || First LTRP from SH |
---|
| 2360 | if( (j == offset+rps->getNumberOfLongtermPictures()-1) || (j == offset+(numOfLtrp-numLtrpInSPS)-1) ) |
---|
| 2361 | { |
---|
| 2362 | deltaFlag = true; |
---|
| 2363 | } |
---|
| 2364 | if(deltaFlag) |
---|
| 2365 | { |
---|
| 2366 | deltaPocMSBCycleLT = uiCode; |
---|
| 2367 | } |
---|
| 2368 | else |
---|
| 2369 | { |
---|
| 2370 | deltaPocMSBCycleLT = uiCode + prevDeltaMSB; |
---|
| 2371 | } |
---|
| 2372 | |
---|
| 2373 | Int pocLTCurr = rpcSlice->getPOC() - deltaPocMSBCycleLT * maxPicOrderCntLSB |
---|
| 2374 | - iPOClsb + pocLsbLt; |
---|
| 2375 | rps->setPOC (j, pocLTCurr); |
---|
| 2376 | rps->setDeltaPOC(j, - rpcSlice->getPOC() + pocLTCurr); |
---|
| 2377 | rps->setCheckLTMSBPresent(j,true); |
---|
| 2378 | } |
---|
| 2379 | else |
---|
| 2380 | { |
---|
| 2381 | rps->setPOC (j, pocLsbLt); |
---|
| 2382 | rps->setDeltaPOC(j, - rpcSlice->getPOC() + pocLsbLt); |
---|
| 2383 | rps->setCheckLTMSBPresent(j,false); |
---|
[494] | 2384 | |
---|
[442] | 2385 | // reset deltaPocMSBCycleLT for first LTRP from slice header if MSB not present |
---|
| 2386 | if( j == offset+(numOfLtrp-numLtrpInSPS)-1 ) |
---|
| 2387 | { |
---|
| 2388 | deltaPocMSBCycleLT = 0; |
---|
| 2389 | } |
---|
[313] | 2390 | } |
---|
| 2391 | prevDeltaMSB = deltaPocMSBCycleLT; |
---|
| 2392 | } |
---|
| 2393 | offset += rps->getNumberOfLongtermPictures(); |
---|
| 2394 | rps->setNumberOfPictures(offset); |
---|
| 2395 | } |
---|
| 2396 | if ( rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP |
---|
| 2397 | || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL |
---|
| 2398 | || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP ) |
---|
| 2399 | { |
---|
| 2400 | // In the case of BLA picture types, rps data is read from slice header but ignored |
---|
| 2401 | rps = rpcSlice->getLocalRPS(); |
---|
| 2402 | rps->setNumberOfNegativePictures(0); |
---|
| 2403 | rps->setNumberOfPositivePictures(0); |
---|
| 2404 | rps->setNumberOfLongtermPictures(0); |
---|
| 2405 | rps->setNumberOfPictures(0); |
---|
| 2406 | rpcSlice->setRPS(rps); |
---|
| 2407 | } |
---|
| 2408 | if (rpcSlice->getSPS()->getTMVPFlagsPresent()) |
---|
| 2409 | { |
---|
| 2410 | READ_FLAG( uiCode, "slice_temporal_mvp_enable_flag" ); |
---|
| 2411 | rpcSlice->setEnableTMVPFlag( uiCode == 1 ? true : false ); |
---|
| 2412 | } |
---|
| 2413 | else |
---|
| 2414 | { |
---|
| 2415 | rpcSlice->setEnableTMVPFlag(false); |
---|
| 2416 | } |
---|
[494] | 2417 | #if N0065_LAYER_POC_ALIGNMENT && !SHM_FIX7 |
---|
[313] | 2418 | } |
---|
[442] | 2419 | #endif |
---|
| 2420 | } |
---|
[313] | 2421 | |
---|
[442] | 2422 | #if SVC_EXTENSION |
---|
[313] | 2423 | rpcSlice->setActiveNumILRRefIdx(0); |
---|
[345] | 2424 | #if ILP_SSH_SIG |
---|
[494] | 2425 | #if ILP_SSH_SIG_FIX |
---|
[621] | 2426 | if((rpcSlice->getLayerId() > 0) && !(rpcSlice->getVPS()->getIlpSshSignalingEnabledFlag()) && (rpcSlice->getNumILRRefIdx() > 0) ) |
---|
[494] | 2427 | #else |
---|
[621] | 2428 | if((rpcSlice->getLayerId() > 0) && rpcSlice->getVPS()->getIlpSshSignalingEnabledFlag() && (rpcSlice->getNumILRRefIdx() > 0) ) |
---|
[494] | 2429 | #endif |
---|
[345] | 2430 | #else |
---|
[621] | 2431 | if((rpcSlice->getLayerId() > 0) && (rpcSlice->getNumILRRefIdx() > 0) ) |
---|
[345] | 2432 | #endif |
---|
[313] | 2433 | { |
---|
| 2434 | READ_FLAG(uiCode,"inter_layer_pred_enabled_flag"); |
---|
| 2435 | rpcSlice->setInterLayerPredEnabledFlag(uiCode); |
---|
| 2436 | if( rpcSlice->getInterLayerPredEnabledFlag()) |
---|
| 2437 | { |
---|
| 2438 | if(rpcSlice->getNumILRRefIdx() > 1) |
---|
| 2439 | { |
---|
| 2440 | Int numBits = 1; |
---|
| 2441 | while ((1 << numBits) < rpcSlice->getNumILRRefIdx()) |
---|
| 2442 | { |
---|
| 2443 | numBits++; |
---|
| 2444 | } |
---|
| 2445 | if( !rpcSlice->getVPS()->getMaxOneActiveRefLayerFlag()) |
---|
| 2446 | { |
---|
| 2447 | READ_CODE( numBits, uiCode,"num_inter_layer_ref_pics_minus1" ); |
---|
| 2448 | rpcSlice->setActiveNumILRRefIdx(uiCode + 1); |
---|
| 2449 | } |
---|
| 2450 | else |
---|
| 2451 | { |
---|
[588] | 2452 | #if P0079_DERIVE_NUMACTIVE_REF_PICS |
---|
[639] | 2453 | for( Int i = 0; i < rpcSlice->getNumILRRefIdx(); i++ ) |
---|
[588] | 2454 | { |
---|
| 2455 | if(rpcSlice->getVPS()->getMaxTidIlRefPicsPlus1(rpcSlice->getVPS()->getLayerIdInVps(i),rpcSlice->getLayerId()) > rpcSlice->getTLayer() && |
---|
| 2456 | (rpcSlice->getVPS()->getMaxTSLayersMinus1(rpcSlice->getVPS()->getLayerIdInVps(i)) >= rpcSlice->getTLayer()) ) |
---|
| 2457 | { |
---|
[639] | 2458 | rpcSlice->setActiveNumILRRefIdx(1); |
---|
| 2459 | break; |
---|
[588] | 2460 | } |
---|
| 2461 | } |
---|
| 2462 | #else |
---|
[313] | 2463 | rpcSlice->setActiveNumILRRefIdx(1); |
---|
[588] | 2464 | #endif |
---|
[313] | 2465 | } |
---|
[345] | 2466 | #if ILP_NUM_REF_CHK |
---|
| 2467 | if( rpcSlice->getActiveNumILRRefIdx() == rpcSlice->getNumILRRefIdx() ) |
---|
| 2468 | { |
---|
| 2469 | for( Int i = 0; i < rpcSlice->getActiveNumILRRefIdx(); i++ ) |
---|
| 2470 | { |
---|
| 2471 | rpcSlice->setInterLayerPredLayerIdc(i,i); |
---|
| 2472 | } |
---|
| 2473 | } |
---|
| 2474 | else |
---|
| 2475 | { |
---|
| 2476 | #endif |
---|
[313] | 2477 | for(Int i = 0; i < rpcSlice->getActiveNumILRRefIdx(); i++ ) |
---|
| 2478 | { |
---|
| 2479 | READ_CODE( numBits,uiCode,"inter_layer_pred_layer_idc[i]" ); |
---|
| 2480 | rpcSlice->setInterLayerPredLayerIdc(uiCode,i); |
---|
| 2481 | } |
---|
[345] | 2482 | #if ILP_NUM_REF_CHK |
---|
| 2483 | } |
---|
| 2484 | #endif |
---|
[313] | 2485 | } |
---|
| 2486 | else |
---|
| 2487 | { |
---|
[540] | 2488 | #if O0225_TID_BASED_IL_RPS_DERIV && TSLAYERS_IL_RPS |
---|
| 2489 | if( (rpcSlice->getVPS()->getMaxTidIlRefPicsPlus1(0,rpcSlice->getLayerId()) > rpcSlice->getTLayer()) && |
---|
| 2490 | (rpcSlice->getVPS()->getMaxTSLayersMinus1(0) >= rpcSlice->getTLayer()) ) |
---|
| 2491 | { |
---|
| 2492 | #endif |
---|
[313] | 2493 | rpcSlice->setActiveNumILRRefIdx(1); |
---|
| 2494 | rpcSlice->setInterLayerPredLayerIdc(0,0); |
---|
[540] | 2495 | #if O0225_TID_BASED_IL_RPS_DERIV && TSLAYERS_IL_RPS |
---|
[313] | 2496 | } |
---|
[540] | 2497 | #endif |
---|
| 2498 | } |
---|
[313] | 2499 | } |
---|
| 2500 | } |
---|
[345] | 2501 | #if ILP_SSH_SIG |
---|
[494] | 2502 | #if ILP_SSH_SIG_FIX |
---|
[540] | 2503 | else if( rpcSlice->getVPS()->getIlpSshSignalingEnabledFlag() == true && (rpcSlice->getLayerId() > 0 )) |
---|
[494] | 2504 | #else |
---|
[345] | 2505 | else if( rpcSlice->getVPS()->getIlpSshSignalingEnabledFlag() == false ) |
---|
[494] | 2506 | #endif |
---|
[345] | 2507 | { |
---|
| 2508 | rpcSlice->setInterLayerPredEnabledFlag(true); |
---|
[540] | 2509 | |
---|
| 2510 | #if O0225_TID_BASED_IL_RPS_DERIV && TSLAYERS_IL_RPS |
---|
| 2511 | Int numRefLayerPics = 0; |
---|
| 2512 | Int i = 0; |
---|
| 2513 | Int refLayerPicIdc [MAX_VPS_LAYER_ID_PLUS1]; |
---|
| 2514 | for(i = 0, numRefLayerPics = 0; i < rpcSlice->getNumILRRefIdx(); i++ ) |
---|
| 2515 | { |
---|
| 2516 | if(rpcSlice->getVPS()->getMaxTidIlRefPicsPlus1(rpcSlice->getVPS()->getLayerIdInVps(i),rpcSlice->getLayerId()) > rpcSlice->getTLayer() && |
---|
| 2517 | (rpcSlice->getVPS()->getMaxTSLayersMinus1(rpcSlice->getVPS()->getLayerIdInVps(i)) >= rpcSlice->getTLayer()) ) |
---|
| 2518 | { |
---|
| 2519 | refLayerPicIdc[ numRefLayerPics++ ] = i; |
---|
| 2520 | } |
---|
| 2521 | } |
---|
| 2522 | rpcSlice->setActiveNumILRRefIdx(numRefLayerPics); |
---|
| 2523 | for( i = 0; i < rpcSlice->getActiveNumILRRefIdx(); i++ ) |
---|
| 2524 | { |
---|
| 2525 | rpcSlice->setInterLayerPredLayerIdc(refLayerPicIdc[i],i); |
---|
| 2526 | } |
---|
| 2527 | #else |
---|
[345] | 2528 | rpcSlice->setActiveNumILRRefIdx(rpcSlice->getNumILRRefIdx()); |
---|
| 2529 | for( Int i = 0; i < rpcSlice->getActiveNumILRRefIdx(); i++ ) |
---|
| 2530 | { |
---|
| 2531 | rpcSlice->setInterLayerPredLayerIdc(i,i); |
---|
| 2532 | } |
---|
[540] | 2533 | #endif |
---|
[345] | 2534 | } |
---|
| 2535 | #endif |
---|
[313] | 2536 | #endif |
---|
[627] | 2537 | #if P0312_VERT_PHASE_ADJ |
---|
[629] | 2538 | for(Int i = 0; i < rpcSlice->getActiveNumILRRefIdx(); i++ ) |
---|
[627] | 2539 | { |
---|
[633] | 2540 | UInt refLayerIdc = rpcSlice->getInterLayerPredLayerIdc(i); |
---|
| 2541 | if( rpcSlice->getSPS()->getVertPhasePositionEnableFlag(refLayerIdc) ) |
---|
[627] | 2542 | { |
---|
[633] | 2543 | READ_FLAG( uiCode, "vert_phase_position_flag" ); rpcSlice->setVertPhasePositionFlag( uiCode? true : false, refLayerIdc ); |
---|
[627] | 2544 | } |
---|
| 2545 | } |
---|
| 2546 | #endif |
---|
[313] | 2547 | |
---|
| 2548 | if(sps->getUseSAO()) |
---|
| 2549 | { |
---|
| 2550 | READ_FLAG(uiCode, "slice_sao_luma_flag"); rpcSlice->setSaoEnabledFlag((Bool)uiCode); |
---|
[494] | 2551 | #if AUXILIARY_PICTURES |
---|
| 2552 | ChromaFormat format; |
---|
| 2553 | #if REPN_FORMAT_IN_VPS |
---|
[540] | 2554 | #if O0096_REP_FORMAT_INDEX |
---|
| 2555 | if( sps->getLayerId() == 0 ) |
---|
| 2556 | { |
---|
| 2557 | format = sps->getChromaFormatIdc(); |
---|
| 2558 | } |
---|
| 2559 | else |
---|
| 2560 | { |
---|
| 2561 | format = rpcSlice->getVPS()->getVpsRepFormat( sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : rpcSlice->getVPS()->getVpsRepFormatIdx(sps->getLayerId()) )->getChromaFormatVpsIdc(); |
---|
| 2562 | } |
---|
| 2563 | #else |
---|
[494] | 2564 | if( ( sps->getLayerId() == 0 ) || sps->getUpdateRepFormatFlag() ) |
---|
| 2565 | { |
---|
| 2566 | format = sps->getChromaFormatIdc(); |
---|
| 2567 | } |
---|
| 2568 | else |
---|
| 2569 | { |
---|
| 2570 | format = rpcSlice->getVPS()->getVpsRepFormat( rpcSlice->getVPS()->getVpsRepFormatIdx(sps->getLayerId()) )->getChromaFormatVpsIdc(); |
---|
| 2571 | } |
---|
[540] | 2572 | #endif |
---|
[494] | 2573 | #else |
---|
| 2574 | format = sps->getChromaFormatIdc(); |
---|
| 2575 | #endif |
---|
| 2576 | if (format != CHROMA_400) |
---|
| 2577 | { |
---|
| 2578 | #endif |
---|
[313] | 2579 | READ_FLAG(uiCode, "slice_sao_chroma_flag"); rpcSlice->setSaoEnabledFlagChroma((Bool)uiCode); |
---|
[494] | 2580 | #if AUXILIARY_PICTURES |
---|
| 2581 | } |
---|
| 2582 | else |
---|
| 2583 | { |
---|
| 2584 | rpcSlice->setSaoEnabledFlagChroma(false); |
---|
| 2585 | } |
---|
| 2586 | #endif |
---|
[313] | 2587 | } |
---|
| 2588 | |
---|
| 2589 | if (rpcSlice->getIdrPicFlag()) |
---|
| 2590 | { |
---|
| 2591 | rpcSlice->setEnableTMVPFlag(false); |
---|
| 2592 | } |
---|
| 2593 | if (!rpcSlice->isIntra()) |
---|
| 2594 | { |
---|
| 2595 | |
---|
| 2596 | READ_FLAG( uiCode, "num_ref_idx_active_override_flag"); |
---|
| 2597 | if (uiCode) |
---|
| 2598 | { |
---|
| 2599 | READ_UVLC (uiCode, "num_ref_idx_l0_active_minus1" ); rpcSlice->setNumRefIdx( REF_PIC_LIST_0, uiCode + 1 ); |
---|
| 2600 | if (rpcSlice->isInterB()) |
---|
| 2601 | { |
---|
| 2602 | READ_UVLC (uiCode, "num_ref_idx_l1_active_minus1" ); rpcSlice->setNumRefIdx( REF_PIC_LIST_1, uiCode + 1 ); |
---|
| 2603 | } |
---|
| 2604 | else |
---|
| 2605 | { |
---|
| 2606 | rpcSlice->setNumRefIdx(REF_PIC_LIST_1, 0); |
---|
| 2607 | } |
---|
| 2608 | } |
---|
| 2609 | else |
---|
| 2610 | { |
---|
| 2611 | rpcSlice->setNumRefIdx(REF_PIC_LIST_0, rpcSlice->getPPS()->getNumRefIdxL0DefaultActive()); |
---|
| 2612 | if (rpcSlice->isInterB()) |
---|
| 2613 | { |
---|
| 2614 | rpcSlice->setNumRefIdx(REF_PIC_LIST_1, rpcSlice->getPPS()->getNumRefIdxL1DefaultActive()); |
---|
| 2615 | } |
---|
| 2616 | else |
---|
| 2617 | { |
---|
| 2618 | rpcSlice->setNumRefIdx(REF_PIC_LIST_1,0); |
---|
| 2619 | } |
---|
| 2620 | } |
---|
| 2621 | } |
---|
| 2622 | // } |
---|
| 2623 | TComRefPicListModification* refPicListModification = rpcSlice->getRefPicListModification(); |
---|
| 2624 | if(!rpcSlice->isIntra()) |
---|
| 2625 | { |
---|
| 2626 | if( !rpcSlice->getPPS()->getListsModificationPresentFlag() || rpcSlice->getNumRpsCurrTempList() <= 1 ) |
---|
| 2627 | { |
---|
| 2628 | refPicListModification->setRefPicListModificationFlagL0( 0 ); |
---|
| 2629 | } |
---|
| 2630 | else |
---|
| 2631 | { |
---|
| 2632 | READ_FLAG( uiCode, "ref_pic_list_modification_flag_l0" ); refPicListModification->setRefPicListModificationFlagL0( uiCode ? 1 : 0 ); |
---|
| 2633 | } |
---|
| 2634 | |
---|
| 2635 | if(refPicListModification->getRefPicListModificationFlagL0()) |
---|
| 2636 | { |
---|
| 2637 | uiCode = 0; |
---|
| 2638 | Int i = 0; |
---|
| 2639 | Int numRpsCurrTempList0 = rpcSlice->getNumRpsCurrTempList(); |
---|
| 2640 | if ( numRpsCurrTempList0 > 1 ) |
---|
| 2641 | { |
---|
| 2642 | Int length = 1; |
---|
| 2643 | numRpsCurrTempList0 --; |
---|
| 2644 | while ( numRpsCurrTempList0 >>= 1) |
---|
| 2645 | { |
---|
| 2646 | length ++; |
---|
| 2647 | } |
---|
| 2648 | for (i = 0; i < rpcSlice->getNumRefIdx(REF_PIC_LIST_0); i ++) |
---|
| 2649 | { |
---|
| 2650 | READ_CODE( length, uiCode, "list_entry_l0" ); |
---|
| 2651 | refPicListModification->setRefPicSetIdxL0(i, uiCode ); |
---|
| 2652 | } |
---|
| 2653 | } |
---|
| 2654 | else |
---|
| 2655 | { |
---|
| 2656 | for (i = 0; i < rpcSlice->getNumRefIdx(REF_PIC_LIST_0); i ++) |
---|
| 2657 | { |
---|
| 2658 | refPicListModification->setRefPicSetIdxL0(i, 0 ); |
---|
| 2659 | } |
---|
| 2660 | } |
---|
| 2661 | } |
---|
| 2662 | } |
---|
| 2663 | else |
---|
| 2664 | { |
---|
| 2665 | refPicListModification->setRefPicListModificationFlagL0(0); |
---|
| 2666 | } |
---|
| 2667 | if(rpcSlice->isInterB()) |
---|
| 2668 | { |
---|
| 2669 | if( !rpcSlice->getPPS()->getListsModificationPresentFlag() || rpcSlice->getNumRpsCurrTempList() <= 1 ) |
---|
| 2670 | { |
---|
| 2671 | refPicListModification->setRefPicListModificationFlagL1( 0 ); |
---|
| 2672 | } |
---|
| 2673 | else |
---|
| 2674 | { |
---|
| 2675 | READ_FLAG( uiCode, "ref_pic_list_modification_flag_l1" ); refPicListModification->setRefPicListModificationFlagL1( uiCode ? 1 : 0 ); |
---|
| 2676 | } |
---|
| 2677 | if(refPicListModification->getRefPicListModificationFlagL1()) |
---|
| 2678 | { |
---|
| 2679 | uiCode = 0; |
---|
| 2680 | Int i = 0; |
---|
| 2681 | Int numRpsCurrTempList1 = rpcSlice->getNumRpsCurrTempList(); |
---|
| 2682 | if ( numRpsCurrTempList1 > 1 ) |
---|
| 2683 | { |
---|
| 2684 | Int length = 1; |
---|
| 2685 | numRpsCurrTempList1 --; |
---|
| 2686 | while ( numRpsCurrTempList1 >>= 1) |
---|
| 2687 | { |
---|
| 2688 | length ++; |
---|
| 2689 | } |
---|
| 2690 | for (i = 0; i < rpcSlice->getNumRefIdx(REF_PIC_LIST_1); i ++) |
---|
| 2691 | { |
---|
| 2692 | READ_CODE( length, uiCode, "list_entry_l1" ); |
---|
| 2693 | refPicListModification->setRefPicSetIdxL1(i, uiCode ); |
---|
| 2694 | } |
---|
| 2695 | } |
---|
| 2696 | else |
---|
| 2697 | { |
---|
| 2698 | for (i = 0; i < rpcSlice->getNumRefIdx(REF_PIC_LIST_1); i ++) |
---|
| 2699 | { |
---|
| 2700 | refPicListModification->setRefPicSetIdxL1(i, 0 ); |
---|
| 2701 | } |
---|
| 2702 | } |
---|
| 2703 | } |
---|
| 2704 | } |
---|
| 2705 | else |
---|
| 2706 | { |
---|
| 2707 | refPicListModification->setRefPicListModificationFlagL1(0); |
---|
| 2708 | } |
---|
| 2709 | if (rpcSlice->isInterB()) |
---|
| 2710 | { |
---|
| 2711 | READ_FLAG( uiCode, "mvd_l1_zero_flag" ); rpcSlice->setMvdL1ZeroFlag( (uiCode ? true : false) ); |
---|
| 2712 | } |
---|
| 2713 | |
---|
| 2714 | rpcSlice->setCabacInitFlag( false ); // default |
---|
| 2715 | if(pps->getCabacInitPresentFlag() && !rpcSlice->isIntra()) |
---|
| 2716 | { |
---|
| 2717 | READ_FLAG(uiCode, "cabac_init_flag"); |
---|
| 2718 | rpcSlice->setCabacInitFlag( uiCode ? true : false ); |
---|
| 2719 | } |
---|
| 2720 | |
---|
| 2721 | if ( rpcSlice->getEnableTMVPFlag() ) |
---|
| 2722 | { |
---|
[588] | 2723 | #if SVC_EXTENSION && REF_IDX_MFM |
---|
| 2724 | // set motion mapping flag |
---|
[540] | 2725 | rpcSlice->setMFMEnabledFlag( ( rpcSlice->getNumMotionPredRefLayers() > 0 && rpcSlice->getActiveNumILRRefIdx() ) ? true : false ); |
---|
[313] | 2726 | #endif |
---|
| 2727 | if ( rpcSlice->getSliceType() == B_SLICE ) |
---|
| 2728 | { |
---|
| 2729 | READ_FLAG( uiCode, "collocated_from_l0_flag" ); |
---|
| 2730 | rpcSlice->setColFromL0Flag(uiCode); |
---|
| 2731 | } |
---|
| 2732 | else |
---|
| 2733 | { |
---|
| 2734 | rpcSlice->setColFromL0Flag( 1 ); |
---|
| 2735 | } |
---|
| 2736 | |
---|
| 2737 | if ( rpcSlice->getSliceType() != I_SLICE && |
---|
| 2738 | ((rpcSlice->getColFromL0Flag() == 1 && rpcSlice->getNumRefIdx(REF_PIC_LIST_0) > 1)|| |
---|
| 2739 | (rpcSlice->getColFromL0Flag() == 0 && rpcSlice->getNumRefIdx(REF_PIC_LIST_1) > 1))) |
---|
| 2740 | { |
---|
| 2741 | READ_UVLC( uiCode, "collocated_ref_idx" ); |
---|
| 2742 | rpcSlice->setColRefIdx(uiCode); |
---|
| 2743 | } |
---|
| 2744 | else |
---|
| 2745 | { |
---|
| 2746 | rpcSlice->setColRefIdx(0); |
---|
| 2747 | } |
---|
| 2748 | } |
---|
| 2749 | if ( (pps->getUseWP() && rpcSlice->getSliceType()==P_SLICE) || (pps->getWPBiPred() && rpcSlice->getSliceType()==B_SLICE) ) |
---|
| 2750 | { |
---|
| 2751 | xParsePredWeightTable(rpcSlice); |
---|
| 2752 | rpcSlice->initWpScaling(); |
---|
| 2753 | } |
---|
| 2754 | if (!rpcSlice->isIntra()) |
---|
| 2755 | { |
---|
| 2756 | READ_UVLC( uiCode, "five_minus_max_num_merge_cand"); |
---|
| 2757 | rpcSlice->setMaxNumMergeCand(MRG_MAX_NUM_CANDS - uiCode); |
---|
| 2758 | } |
---|
| 2759 | |
---|
| 2760 | READ_SVLC( iCode, "slice_qp_delta" ); |
---|
| 2761 | rpcSlice->setSliceQp (26 + pps->getPicInitQPMinus26() + iCode); |
---|
| 2762 | |
---|
[442] | 2763 | #if REPN_FORMAT_IN_VPS |
---|
[494] | 2764 | #if O0194_DIFFERENT_BITDEPTH_EL_BL |
---|
| 2765 | g_bitDepthYLayer[rpcSlice->getLayerId()] = rpcSlice->getBitDepthY(); |
---|
| 2766 | g_bitDepthCLayer[rpcSlice->getLayerId()] = rpcSlice->getBitDepthC(); |
---|
| 2767 | #endif |
---|
[442] | 2768 | assert( rpcSlice->getSliceQp() >= -rpcSlice->getQpBDOffsetY() ); |
---|
| 2769 | #else |
---|
[313] | 2770 | assert( rpcSlice->getSliceQp() >= -sps->getQpBDOffsetY() ); |
---|
[442] | 2771 | #endif |
---|
[313] | 2772 | assert( rpcSlice->getSliceQp() <= 51 ); |
---|
| 2773 | |
---|
| 2774 | if (rpcSlice->getPPS()->getSliceChromaQpFlag()) |
---|
| 2775 | { |
---|
| 2776 | READ_SVLC( iCode, "slice_qp_delta_cb" ); |
---|
| 2777 | rpcSlice->setSliceQpDeltaCb( iCode ); |
---|
| 2778 | assert( rpcSlice->getSliceQpDeltaCb() >= -12 ); |
---|
| 2779 | assert( rpcSlice->getSliceQpDeltaCb() <= 12 ); |
---|
| 2780 | assert( (rpcSlice->getPPS()->getChromaCbQpOffset() + rpcSlice->getSliceQpDeltaCb()) >= -12 ); |
---|
| 2781 | assert( (rpcSlice->getPPS()->getChromaCbQpOffset() + rpcSlice->getSliceQpDeltaCb()) <= 12 ); |
---|
| 2782 | |
---|
| 2783 | READ_SVLC( iCode, "slice_qp_delta_cr" ); |
---|
| 2784 | rpcSlice->setSliceQpDeltaCr( iCode ); |
---|
| 2785 | assert( rpcSlice->getSliceQpDeltaCr() >= -12 ); |
---|
| 2786 | assert( rpcSlice->getSliceQpDeltaCr() <= 12 ); |
---|
| 2787 | assert( (rpcSlice->getPPS()->getChromaCrQpOffset() + rpcSlice->getSliceQpDeltaCr()) >= -12 ); |
---|
| 2788 | assert( (rpcSlice->getPPS()->getChromaCrQpOffset() + rpcSlice->getSliceQpDeltaCr()) <= 12 ); |
---|
| 2789 | } |
---|
| 2790 | |
---|
| 2791 | if (rpcSlice->getPPS()->getDeblockingFilterControlPresentFlag()) |
---|
| 2792 | { |
---|
| 2793 | if(rpcSlice->getPPS()->getDeblockingFilterOverrideEnabledFlag()) |
---|
| 2794 | { |
---|
| 2795 | READ_FLAG ( uiCode, "deblocking_filter_override_flag" ); rpcSlice->setDeblockingFilterOverrideFlag(uiCode ? true : false); |
---|
| 2796 | } |
---|
| 2797 | else |
---|
| 2798 | { |
---|
| 2799 | rpcSlice->setDeblockingFilterOverrideFlag(0); |
---|
| 2800 | } |
---|
| 2801 | if(rpcSlice->getDeblockingFilterOverrideFlag()) |
---|
| 2802 | { |
---|
| 2803 | READ_FLAG ( uiCode, "slice_disable_deblocking_filter_flag" ); rpcSlice->setDeblockingFilterDisable(uiCode ? 1 : 0); |
---|
| 2804 | if(!rpcSlice->getDeblockingFilterDisable()) |
---|
| 2805 | { |
---|
| 2806 | READ_SVLC( iCode, "slice_beta_offset_div2" ); rpcSlice->setDeblockingFilterBetaOffsetDiv2(iCode); |
---|
| 2807 | assert(rpcSlice->getDeblockingFilterBetaOffsetDiv2() >= -6 && |
---|
| 2808 | rpcSlice->getDeblockingFilterBetaOffsetDiv2() <= 6); |
---|
| 2809 | READ_SVLC( iCode, "slice_tc_offset_div2" ); rpcSlice->setDeblockingFilterTcOffsetDiv2(iCode); |
---|
| 2810 | assert(rpcSlice->getDeblockingFilterTcOffsetDiv2() >= -6 && |
---|
| 2811 | rpcSlice->getDeblockingFilterTcOffsetDiv2() <= 6); |
---|
| 2812 | } |
---|
| 2813 | } |
---|
| 2814 | else |
---|
| 2815 | { |
---|
| 2816 | rpcSlice->setDeblockingFilterDisable ( rpcSlice->getPPS()->getPicDisableDeblockingFilterFlag() ); |
---|
| 2817 | rpcSlice->setDeblockingFilterBetaOffsetDiv2( rpcSlice->getPPS()->getDeblockingFilterBetaOffsetDiv2() ); |
---|
| 2818 | rpcSlice->setDeblockingFilterTcOffsetDiv2 ( rpcSlice->getPPS()->getDeblockingFilterTcOffsetDiv2() ); |
---|
| 2819 | } |
---|
| 2820 | } |
---|
| 2821 | else |
---|
| 2822 | { |
---|
| 2823 | rpcSlice->setDeblockingFilterDisable ( false ); |
---|
| 2824 | rpcSlice->setDeblockingFilterBetaOffsetDiv2( 0 ); |
---|
| 2825 | rpcSlice->setDeblockingFilterTcOffsetDiv2 ( 0 ); |
---|
| 2826 | } |
---|
| 2827 | |
---|
| 2828 | Bool isSAOEnabled = (!rpcSlice->getSPS()->getUseSAO())?(false):(rpcSlice->getSaoEnabledFlag()||rpcSlice->getSaoEnabledFlagChroma()); |
---|
| 2829 | Bool isDBFEnabled = (!rpcSlice->getDeblockingFilterDisable()); |
---|
| 2830 | |
---|
| 2831 | if(rpcSlice->getPPS()->getLoopFilterAcrossSlicesEnabledFlag() && ( isSAOEnabled || isDBFEnabled )) |
---|
| 2832 | { |
---|
| 2833 | READ_FLAG( uiCode, "slice_loop_filter_across_slices_enabled_flag"); |
---|
| 2834 | } |
---|
| 2835 | else |
---|
| 2836 | { |
---|
| 2837 | uiCode = rpcSlice->getPPS()->getLoopFilterAcrossSlicesEnabledFlag()?1:0; |
---|
| 2838 | } |
---|
| 2839 | rpcSlice->setLFCrossSliceBoundaryFlag( (uiCode==1)?true:false); |
---|
| 2840 | |
---|
| 2841 | } |
---|
| 2842 | |
---|
| 2843 | UInt *entryPointOffset = NULL; |
---|
| 2844 | UInt numEntryPointOffsets, offsetLenMinus1; |
---|
| 2845 | if( pps->getTilesEnabledFlag() || pps->getEntropyCodingSyncEnabledFlag() ) |
---|
| 2846 | { |
---|
| 2847 | READ_UVLC(numEntryPointOffsets, "num_entry_point_offsets"); rpcSlice->setNumEntryPointOffsets ( numEntryPointOffsets ); |
---|
| 2848 | if (numEntryPointOffsets>0) |
---|
| 2849 | { |
---|
| 2850 | READ_UVLC(offsetLenMinus1, "offset_len_minus1"); |
---|
| 2851 | } |
---|
| 2852 | entryPointOffset = new UInt[numEntryPointOffsets]; |
---|
| 2853 | for (UInt idx=0; idx<numEntryPointOffsets; idx++) |
---|
| 2854 | { |
---|
| 2855 | READ_CODE(offsetLenMinus1+1, uiCode, "entry_point_offset_minus1"); |
---|
| 2856 | entryPointOffset[ idx ] = uiCode + 1; |
---|
| 2857 | } |
---|
| 2858 | } |
---|
| 2859 | else |
---|
| 2860 | { |
---|
| 2861 | rpcSlice->setNumEntryPointOffsets ( 0 ); |
---|
| 2862 | } |
---|
| 2863 | |
---|
[631] | 2864 | #if POC_RESET_IDC_SIGNALLING |
---|
[630] | 2865 | Int sliceHederExtensionLength = 0; |
---|
[313] | 2866 | if(pps->getSliceHeaderExtensionPresentFlag()) |
---|
| 2867 | { |
---|
[630] | 2868 | READ_UVLC( uiCode, "slice_header_extension_length"); sliceHederExtensionLength = uiCode; |
---|
| 2869 | } |
---|
| 2870 | else |
---|
| 2871 | { |
---|
| 2872 | sliceHederExtensionLength = 0; |
---|
| 2873 | } |
---|
| 2874 | UInt startBits = m_pcBitstream->getNumBitsRead(); // Start counter of # SH Extn bits |
---|
| 2875 | if( sliceHederExtensionLength > 0 ) |
---|
| 2876 | { |
---|
| 2877 | if( rpcSlice->getPPS()->getPocResetInfoPresentFlag() ) |
---|
| 2878 | { |
---|
| 2879 | READ_CODE( 2, uiCode, "poc_reset_idc"); rpcSlice->setPocResetIdc(uiCode); |
---|
| 2880 | } |
---|
| 2881 | else |
---|
| 2882 | { |
---|
| 2883 | rpcSlice->setPocResetIdc( 0 ); |
---|
| 2884 | } |
---|
| 2885 | if( rpcSlice->getPocResetIdc() > 0 ) |
---|
| 2886 | { |
---|
| 2887 | READ_CODE(6, uiCode, "poc_reset_period_id"); rpcSlice->setPocResetPeriodId(uiCode); |
---|
| 2888 | } |
---|
| 2889 | else |
---|
| 2890 | { |
---|
| 2891 | |
---|
| 2892 | rpcSlice->setPocResetPeriodId( 0 ); |
---|
| 2893 | } |
---|
| 2894 | |
---|
| 2895 | if (rpcSlice->getPocResetIdc() == 3) |
---|
| 2896 | { |
---|
| 2897 | READ_FLAG( uiCode, "full_poc_reset_flag"); rpcSlice->setFullPocResetFlag((uiCode == 1) ? true : false); |
---|
| 2898 | READ_CODE(rpcSlice->getSPS()->getBitsForPOC(), uiCode,"poc_lsb_val"); rpcSlice->setPocLsbVal(uiCode); |
---|
| 2899 | } |
---|
| 2900 | |
---|
| 2901 | // Derive the value of PocMsbValRequiredFlag |
---|
| 2902 | rpcSlice->setPocMsbValRequiredFlag( rpcSlice->getCraPicFlag() || rpcSlice->getBlaPicFlag() |
---|
| 2903 | /* || related to vps_poc_lsb_aligned_flag */ |
---|
| 2904 | ); |
---|
| 2905 | |
---|
[632] | 2906 | if( !rpcSlice->getPocMsbValRequiredFlag() /* vps_poc_lsb_aligned_flag */ ) |
---|
[630] | 2907 | { |
---|
| 2908 | READ_FLAG( uiCode, "poc_msb_val_present_flag"); rpcSlice->setPocMsbValPresentFlag( uiCode ? true : false ); |
---|
| 2909 | } |
---|
| 2910 | else |
---|
| 2911 | { |
---|
| 2912 | if( rpcSlice->getPocMsbValRequiredFlag() ) |
---|
| 2913 | { |
---|
| 2914 | rpcSlice->setPocMsbValPresentFlag( true ); |
---|
| 2915 | } |
---|
| 2916 | else |
---|
| 2917 | { |
---|
| 2918 | rpcSlice->setPocMsbValPresentFlag( false ); |
---|
| 2919 | } |
---|
| 2920 | } |
---|
| 2921 | |
---|
| 2922 | Int maxPocLsb = 1 << rpcSlice->getSPS()->getBitsForPOC(); |
---|
| 2923 | if( rpcSlice->getPocMsbValPresentFlag() ) |
---|
| 2924 | { |
---|
| 2925 | READ_UVLC( uiCode, "poc_msb_val"); rpcSlice->setPocMsbVal( uiCode ); |
---|
| 2926 | // Update POC of the slice based on this MSB val |
---|
| 2927 | Int pocLsb = rpcSlice->getPOC() % maxPocLsb; |
---|
| 2928 | rpcSlice->setPOC((rpcSlice->getPocMsbVal() * maxPocLsb) + pocLsb); |
---|
| 2929 | } |
---|
| 2930 | else |
---|
| 2931 | { |
---|
| 2932 | rpcSlice->setPocMsbVal( rpcSlice->getPOC() / maxPocLsb ); |
---|
| 2933 | } |
---|
| 2934 | |
---|
| 2935 | // Read remaining bits in the slice header extension. |
---|
| 2936 | UInt endBits = m_pcBitstream->getNumBitsRead(); |
---|
| 2937 | Int counter = (endBits - startBits) % 8; |
---|
| 2938 | if( counter ) |
---|
| 2939 | { |
---|
| 2940 | counter = 8 - counter; |
---|
| 2941 | } |
---|
| 2942 | |
---|
| 2943 | while( counter ) |
---|
| 2944 | { |
---|
| 2945 | READ_FLAG( uiCode, "slice_segment_header_extension_reserved_bit" ); assert( uiCode == 1 ); |
---|
| 2946 | counter--; |
---|
| 2947 | } |
---|
| 2948 | } |
---|
| 2949 | #else |
---|
| 2950 | if(pps->getSliceHeaderExtensionPresentFlag()) |
---|
| 2951 | { |
---|
[313] | 2952 | READ_UVLC(uiCode,"slice_header_extension_length"); |
---|
| 2953 | for(Int i=0; i<uiCode; i++) |
---|
| 2954 | { |
---|
| 2955 | UInt ignore; |
---|
| 2956 | READ_CODE(8,ignore,"slice_header_extension_data_byte"); |
---|
| 2957 | } |
---|
| 2958 | } |
---|
[630] | 2959 | #endif |
---|
[313] | 2960 | m_pcBitstream->readByteAlignment(); |
---|
| 2961 | |
---|
| 2962 | if( pps->getTilesEnabledFlag() || pps->getEntropyCodingSyncEnabledFlag() ) |
---|
| 2963 | { |
---|
| 2964 | Int endOfSliceHeaderLocation = m_pcBitstream->getByteLocation(); |
---|
[494] | 2965 | |
---|
[313] | 2966 | // Adjust endOfSliceHeaderLocation to account for emulation prevention bytes in the slice segment header |
---|
| 2967 | for ( UInt curByteIdx = 0; curByteIdx<m_pcBitstream->numEmulationPreventionBytesRead(); curByteIdx++ ) |
---|
| 2968 | { |
---|
| 2969 | if ( m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) < endOfSliceHeaderLocation ) |
---|
| 2970 | { |
---|
| 2971 | endOfSliceHeaderLocation++; |
---|
| 2972 | } |
---|
| 2973 | } |
---|
| 2974 | |
---|
| 2975 | Int curEntryPointOffset = 0; |
---|
| 2976 | Int prevEntryPointOffset = 0; |
---|
| 2977 | for (UInt idx=0; idx<numEntryPointOffsets; idx++) |
---|
| 2978 | { |
---|
| 2979 | curEntryPointOffset += entryPointOffset[ idx ]; |
---|
| 2980 | |
---|
| 2981 | Int emulationPreventionByteCount = 0; |
---|
| 2982 | for ( UInt curByteIdx = 0; curByteIdx<m_pcBitstream->numEmulationPreventionBytesRead(); curByteIdx++ ) |
---|
| 2983 | { |
---|
| 2984 | if ( m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) >= ( prevEntryPointOffset + endOfSliceHeaderLocation ) && |
---|
| 2985 | m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) < ( curEntryPointOffset + endOfSliceHeaderLocation ) ) |
---|
| 2986 | { |
---|
| 2987 | emulationPreventionByteCount++; |
---|
| 2988 | } |
---|
| 2989 | } |
---|
| 2990 | |
---|
| 2991 | entryPointOffset[ idx ] -= emulationPreventionByteCount; |
---|
| 2992 | prevEntryPointOffset = curEntryPointOffset; |
---|
| 2993 | } |
---|
| 2994 | |
---|
| 2995 | if ( pps->getTilesEnabledFlag() ) |
---|
| 2996 | { |
---|
| 2997 | rpcSlice->setTileLocationCount( numEntryPointOffsets ); |
---|
| 2998 | |
---|
| 2999 | UInt prevPos = 0; |
---|
| 3000 | for (Int idx=0; idx<rpcSlice->getTileLocationCount(); idx++) |
---|
| 3001 | { |
---|
| 3002 | rpcSlice->setTileLocation( idx, prevPos + entryPointOffset [ idx ] ); |
---|
| 3003 | prevPos += entryPointOffset[ idx ]; |
---|
| 3004 | } |
---|
| 3005 | } |
---|
| 3006 | else if ( pps->getEntropyCodingSyncEnabledFlag() ) |
---|
| 3007 | { |
---|
| 3008 | Int numSubstreams = rpcSlice->getNumEntryPointOffsets()+1; |
---|
| 3009 | rpcSlice->allocSubstreamSizes(numSubstreams); |
---|
| 3010 | UInt *pSubstreamSizes = rpcSlice->getSubstreamSizes(); |
---|
| 3011 | for (Int idx=0; idx<numSubstreams-1; idx++) |
---|
| 3012 | { |
---|
| 3013 | if ( idx < numEntryPointOffsets ) |
---|
| 3014 | { |
---|
| 3015 | pSubstreamSizes[ idx ] = ( entryPointOffset[ idx ] << 3 ) ; |
---|
| 3016 | } |
---|
| 3017 | else |
---|
| 3018 | { |
---|
| 3019 | pSubstreamSizes[ idx ] = 0; |
---|
| 3020 | } |
---|
| 3021 | } |
---|
| 3022 | } |
---|
| 3023 | |
---|
| 3024 | if (entryPointOffset) |
---|
| 3025 | { |
---|
| 3026 | delete [] entryPointOffset; |
---|
| 3027 | } |
---|
| 3028 | } |
---|
| 3029 | |
---|
| 3030 | return; |
---|
| 3031 | } |
---|
| 3032 | |
---|
| 3033 | Void TDecCavlc::parsePTL( TComPTL *rpcPTL, Bool profilePresentFlag, Int maxNumSubLayersMinus1 ) |
---|
| 3034 | { |
---|
| 3035 | UInt uiCode; |
---|
| 3036 | if(profilePresentFlag) |
---|
| 3037 | { |
---|
| 3038 | parseProfileTier(rpcPTL->getGeneralPTL()); |
---|
| 3039 | } |
---|
| 3040 | READ_CODE( 8, uiCode, "general_level_idc" ); rpcPTL->getGeneralPTL()->setLevelIdc(uiCode); |
---|
| 3041 | |
---|
| 3042 | for (Int i = 0; i < maxNumSubLayersMinus1; i++) |
---|
| 3043 | { |
---|
| 3044 | if(profilePresentFlag) |
---|
| 3045 | { |
---|
| 3046 | READ_FLAG( uiCode, "sub_layer_profile_present_flag[i]" ); rpcPTL->setSubLayerProfilePresentFlag(i, uiCode); |
---|
| 3047 | } |
---|
| 3048 | READ_FLAG( uiCode, "sub_layer_level_present_flag[i]" ); rpcPTL->setSubLayerLevelPresentFlag (i, uiCode); |
---|
| 3049 | } |
---|
| 3050 | |
---|
| 3051 | if (maxNumSubLayersMinus1 > 0) |
---|
| 3052 | { |
---|
| 3053 | for (Int i = maxNumSubLayersMinus1; i < 8; i++) |
---|
| 3054 | { |
---|
| 3055 | READ_CODE(2, uiCode, "reserved_zero_2bits"); |
---|
| 3056 | assert(uiCode == 0); |
---|
| 3057 | } |
---|
| 3058 | } |
---|
| 3059 | |
---|
| 3060 | for(Int i = 0; i < maxNumSubLayersMinus1; i++) |
---|
| 3061 | { |
---|
| 3062 | if( profilePresentFlag && rpcPTL->getSubLayerProfilePresentFlag(i) ) |
---|
| 3063 | { |
---|
| 3064 | parseProfileTier(rpcPTL->getSubLayerPTL(i)); |
---|
| 3065 | } |
---|
| 3066 | if(rpcPTL->getSubLayerLevelPresentFlag(i)) |
---|
| 3067 | { |
---|
| 3068 | READ_CODE( 8, uiCode, "sub_layer_level_idc[i]" ); rpcPTL->getSubLayerPTL(i)->setLevelIdc(uiCode); |
---|
| 3069 | } |
---|
| 3070 | } |
---|
| 3071 | } |
---|
| 3072 | |
---|
| 3073 | Void TDecCavlc::parseProfileTier(ProfileTierLevel *ptl) |
---|
| 3074 | { |
---|
| 3075 | UInt uiCode; |
---|
| 3076 | READ_CODE(2 , uiCode, "XXX_profile_space[]"); ptl->setProfileSpace(uiCode); |
---|
| 3077 | READ_FLAG( uiCode, "XXX_tier_flag[]" ); ptl->setTierFlag (uiCode ? 1 : 0); |
---|
| 3078 | READ_CODE(5 , uiCode, "XXX_profile_idc[]" ); ptl->setProfileIdc (uiCode); |
---|
| 3079 | for(Int j = 0; j < 32; j++) |
---|
| 3080 | { |
---|
| 3081 | READ_FLAG( uiCode, "XXX_profile_compatibility_flag[][j]"); ptl->setProfileCompatibilityFlag(j, uiCode ? 1 : 0); |
---|
| 3082 | } |
---|
| 3083 | READ_FLAG(uiCode, "general_progressive_source_flag"); |
---|
| 3084 | ptl->setProgressiveSourceFlag(uiCode ? true : false); |
---|
| 3085 | |
---|
| 3086 | READ_FLAG(uiCode, "general_interlaced_source_flag"); |
---|
| 3087 | ptl->setInterlacedSourceFlag(uiCode ? true : false); |
---|
| 3088 | |
---|
| 3089 | READ_FLAG(uiCode, "general_non_packed_constraint_flag"); |
---|
| 3090 | ptl->setNonPackedConstraintFlag(uiCode ? true : false); |
---|
| 3091 | |
---|
| 3092 | READ_FLAG(uiCode, "general_frame_only_constraint_flag"); |
---|
| 3093 | ptl->setFrameOnlyConstraintFlag(uiCode ? true : false); |
---|
| 3094 | |
---|
| 3095 | READ_CODE(16, uiCode, "XXX_reserved_zero_44bits[0..15]"); |
---|
| 3096 | READ_CODE(16, uiCode, "XXX_reserved_zero_44bits[16..31]"); |
---|
| 3097 | READ_CODE(12, uiCode, "XXX_reserved_zero_44bits[32..43]"); |
---|
| 3098 | } |
---|
| 3099 | |
---|
| 3100 | Void TDecCavlc::parseTerminatingBit( UInt& ruiBit ) |
---|
| 3101 | { |
---|
| 3102 | ruiBit = false; |
---|
| 3103 | Int iBitsLeft = m_pcBitstream->getNumBitsLeft(); |
---|
| 3104 | if(iBitsLeft <= 8) |
---|
| 3105 | { |
---|
| 3106 | UInt uiPeekValue = m_pcBitstream->peekBits(iBitsLeft); |
---|
| 3107 | if (uiPeekValue == (1<<(iBitsLeft-1))) |
---|
| 3108 | { |
---|
| 3109 | ruiBit = true; |
---|
| 3110 | } |
---|
| 3111 | } |
---|
| 3112 | } |
---|
| 3113 | |
---|
| 3114 | Void TDecCavlc::parseSkipFlag( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
| 3115 | { |
---|
| 3116 | assert(0); |
---|
| 3117 | } |
---|
| 3118 | |
---|
| 3119 | Void TDecCavlc::parseCUTransquantBypassFlag( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
| 3120 | { |
---|
| 3121 | assert(0); |
---|
| 3122 | } |
---|
| 3123 | |
---|
| 3124 | Void TDecCavlc::parseMVPIdx( Int& /*riMVPIdx*/ ) |
---|
| 3125 | { |
---|
| 3126 | assert(0); |
---|
| 3127 | } |
---|
| 3128 | |
---|
| 3129 | Void TDecCavlc::parseSplitFlag ( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
| 3130 | { |
---|
| 3131 | assert(0); |
---|
| 3132 | } |
---|
| 3133 | |
---|
| 3134 | Void TDecCavlc::parsePartSize( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
| 3135 | { |
---|
| 3136 | assert(0); |
---|
| 3137 | } |
---|
| 3138 | |
---|
| 3139 | Void TDecCavlc::parsePredMode( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
| 3140 | { |
---|
| 3141 | assert(0); |
---|
| 3142 | } |
---|
| 3143 | |
---|
| 3144 | /** Parse I_PCM information. |
---|
| 3145 | * \param pcCU pointer to CU |
---|
| 3146 | * \param uiAbsPartIdx CU index |
---|
| 3147 | * \param uiDepth CU depth |
---|
| 3148 | * \returns Void |
---|
| 3149 | * |
---|
| 3150 | * If I_PCM flag indicates that the CU is I_PCM, parse its PCM alignment bits and codes. |
---|
| 3151 | */ |
---|
| 3152 | Void TDecCavlc::parseIPCMInfo( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
| 3153 | { |
---|
| 3154 | assert(0); |
---|
| 3155 | } |
---|
| 3156 | |
---|
| 3157 | Void TDecCavlc::parseIntraDirLumaAng ( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
| 3158 | { |
---|
| 3159 | assert(0); |
---|
| 3160 | } |
---|
| 3161 | |
---|
| 3162 | Void TDecCavlc::parseIntraDirChroma( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
| 3163 | { |
---|
| 3164 | assert(0); |
---|
| 3165 | } |
---|
| 3166 | |
---|
| 3167 | Void TDecCavlc::parseInterDir( TComDataCU* /*pcCU*/, UInt& /*ruiInterDir*/, UInt /*uiAbsPartIdx*/ ) |
---|
| 3168 | { |
---|
| 3169 | assert(0); |
---|
| 3170 | } |
---|
| 3171 | |
---|
| 3172 | Void TDecCavlc::parseRefFrmIdx( TComDataCU* /*pcCU*/, Int& /*riRefFrmIdx*/, RefPicList /*eRefList*/ ) |
---|
| 3173 | { |
---|
| 3174 | assert(0); |
---|
| 3175 | } |
---|
| 3176 | |
---|
| 3177 | Void TDecCavlc::parseMvd( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiPartIdx*/, UInt /*uiDepth*/, RefPicList /*eRefList*/ ) |
---|
| 3178 | { |
---|
| 3179 | assert(0); |
---|
| 3180 | } |
---|
| 3181 | |
---|
| 3182 | Void TDecCavlc::parseDeltaQP( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 3183 | { |
---|
| 3184 | Int qp; |
---|
| 3185 | Int iDQp; |
---|
| 3186 | |
---|
| 3187 | xReadSvlc( iDQp ); |
---|
| 3188 | |
---|
[442] | 3189 | #if REPN_FORMAT_IN_VPS |
---|
| 3190 | Int qpBdOffsetY = pcCU->getSlice()->getQpBDOffsetY(); |
---|
| 3191 | #else |
---|
[313] | 3192 | Int qpBdOffsetY = pcCU->getSlice()->getSPS()->getQpBDOffsetY(); |
---|
[442] | 3193 | #endif |
---|
[313] | 3194 | qp = (((Int) pcCU->getRefQP( uiAbsPartIdx ) + iDQp + 52 + 2*qpBdOffsetY )%(52+ qpBdOffsetY)) - qpBdOffsetY; |
---|
| 3195 | |
---|
| 3196 | UInt uiAbsQpCUPartIdx = (uiAbsPartIdx>>((g_uiMaxCUDepth - pcCU->getSlice()->getPPS()->getMaxCuDQPDepth())<<1))<<((g_uiMaxCUDepth - pcCU->getSlice()->getPPS()->getMaxCuDQPDepth())<<1) ; |
---|
| 3197 | UInt uiQpCUDepth = min(uiDepth,pcCU->getSlice()->getPPS()->getMaxCuDQPDepth()) ; |
---|
| 3198 | |
---|
| 3199 | pcCU->setQPSubParts( qp, uiAbsQpCUPartIdx, uiQpCUDepth ); |
---|
| 3200 | } |
---|
| 3201 | |
---|
| 3202 | Void TDecCavlc::parseCoeffNxN( TComDataCU* /*pcCU*/, TCoeff* /*pcCoef*/, UInt /*uiAbsPartIdx*/, UInt /*uiWidth*/, UInt /*uiHeight*/, UInt /*uiDepth*/, TextType /*eTType*/ ) |
---|
| 3203 | { |
---|
| 3204 | assert(0); |
---|
| 3205 | } |
---|
| 3206 | |
---|
| 3207 | Void TDecCavlc::parseTransformSubdivFlag( UInt& /*ruiSubdivFlag*/, UInt /*uiLog2TransformBlockSize*/ ) |
---|
| 3208 | { |
---|
| 3209 | assert(0); |
---|
| 3210 | } |
---|
| 3211 | |
---|
| 3212 | Void TDecCavlc::parseQtCbf( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, TextType /*eType*/, UInt /*uiTrDepth*/, UInt /*uiDepth*/ ) |
---|
| 3213 | { |
---|
| 3214 | assert(0); |
---|
| 3215 | } |
---|
| 3216 | |
---|
| 3217 | Void TDecCavlc::parseQtRootCbf( UInt /*uiAbsPartIdx*/, UInt& /*uiQtRootCbf*/ ) |
---|
| 3218 | { |
---|
| 3219 | assert(0); |
---|
| 3220 | } |
---|
| 3221 | |
---|
| 3222 | Void TDecCavlc::parseTransformSkipFlags (TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*width*/, UInt /*height*/, UInt /*uiDepth*/, TextType /*eTType*/) |
---|
| 3223 | { |
---|
| 3224 | assert(0); |
---|
| 3225 | } |
---|
| 3226 | |
---|
| 3227 | Void TDecCavlc::parseMergeFlag ( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/, UInt /*uiPUIdx*/ ) |
---|
| 3228 | { |
---|
| 3229 | assert(0); |
---|
| 3230 | } |
---|
| 3231 | |
---|
| 3232 | Void TDecCavlc::parseMergeIndex ( TComDataCU* /*pcCU*/, UInt& /*ruiMergeIndex*/ ) |
---|
| 3233 | { |
---|
| 3234 | assert(0); |
---|
| 3235 | } |
---|
| 3236 | |
---|
| 3237 | // ==================================================================================================================== |
---|
| 3238 | // Protected member functions |
---|
| 3239 | // ==================================================================================================================== |
---|
| 3240 | |
---|
| 3241 | /** parse explicit wp tables |
---|
| 3242 | * \param TComSlice* pcSlice |
---|
| 3243 | * \returns Void |
---|
| 3244 | */ |
---|
| 3245 | Void TDecCavlc::xParsePredWeightTable( TComSlice* pcSlice ) |
---|
| 3246 | { |
---|
| 3247 | wpScalingParam *wp; |
---|
| 3248 | Bool bChroma = true; // color always present in HEVC ? |
---|
| 3249 | SliceType eSliceType = pcSlice->getSliceType(); |
---|
| 3250 | Int iNbRef = (eSliceType == B_SLICE ) ? (2) : (1); |
---|
[494] | 3251 | #if SVC_EXTENSION |
---|
| 3252 | UInt uiLog2WeightDenomLuma = 0, uiLog2WeightDenomChroma = 0; |
---|
| 3253 | #else |
---|
[313] | 3254 | UInt uiLog2WeightDenomLuma, uiLog2WeightDenomChroma; |
---|
[494] | 3255 | #endif |
---|
[313] | 3256 | UInt uiTotalSignalledWeightFlags = 0; |
---|
| 3257 | |
---|
| 3258 | Int iDeltaDenom; |
---|
[494] | 3259 | #if AUXILIARY_PICTURES |
---|
| 3260 | if (pcSlice->getChromaFormatIdc() == CHROMA_400) |
---|
| 3261 | { |
---|
| 3262 | bChroma = false; |
---|
| 3263 | } |
---|
| 3264 | #endif |
---|
[313] | 3265 | // decode delta_luma_log2_weight_denom : |
---|
| 3266 | READ_UVLC( uiLog2WeightDenomLuma, "luma_log2_weight_denom" ); // ue(v): luma_log2_weight_denom |
---|
| 3267 | assert( uiLog2WeightDenomLuma <= 7 ); |
---|
| 3268 | if( bChroma ) |
---|
| 3269 | { |
---|
| 3270 | READ_SVLC( iDeltaDenom, "delta_chroma_log2_weight_denom" ); // se(v): delta_chroma_log2_weight_denom |
---|
| 3271 | assert((iDeltaDenom + (Int)uiLog2WeightDenomLuma)>=0); |
---|
| 3272 | assert((iDeltaDenom + (Int)uiLog2WeightDenomLuma)<=7); |
---|
| 3273 | uiLog2WeightDenomChroma = (UInt)(iDeltaDenom + uiLog2WeightDenomLuma); |
---|
| 3274 | } |
---|
| 3275 | |
---|
| 3276 | for ( Int iNumRef=0 ; iNumRef<iNbRef ; iNumRef++ ) |
---|
| 3277 | { |
---|
| 3278 | RefPicList eRefPicList = ( iNumRef ? REF_PIC_LIST_1 : REF_PIC_LIST_0 ); |
---|
| 3279 | for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ ) |
---|
| 3280 | { |
---|
| 3281 | pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); |
---|
| 3282 | |
---|
| 3283 | wp[0].uiLog2WeightDenom = uiLog2WeightDenomLuma; |
---|
[494] | 3284 | #if AUXILIARY_PICTURES |
---|
| 3285 | if (!bChroma) |
---|
| 3286 | { |
---|
| 3287 | wp[1].uiLog2WeightDenom = 0; |
---|
| 3288 | wp[2].uiLog2WeightDenom = 0; |
---|
| 3289 | } |
---|
| 3290 | else |
---|
| 3291 | { |
---|
| 3292 | #endif |
---|
[313] | 3293 | wp[1].uiLog2WeightDenom = uiLog2WeightDenomChroma; |
---|
| 3294 | wp[2].uiLog2WeightDenom = uiLog2WeightDenomChroma; |
---|
[494] | 3295 | #if AUXILIARY_PICTURES |
---|
| 3296 | } |
---|
| 3297 | #endif |
---|
[313] | 3298 | |
---|
| 3299 | UInt uiCode; |
---|
| 3300 | READ_FLAG( uiCode, "luma_weight_lX_flag" ); // u(1): luma_weight_l0_flag |
---|
| 3301 | wp[0].bPresentFlag = ( uiCode == 1 ); |
---|
| 3302 | uiTotalSignalledWeightFlags += wp[0].bPresentFlag; |
---|
| 3303 | } |
---|
| 3304 | if ( bChroma ) |
---|
| 3305 | { |
---|
| 3306 | UInt uiCode; |
---|
| 3307 | for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ ) |
---|
| 3308 | { |
---|
| 3309 | pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); |
---|
| 3310 | READ_FLAG( uiCode, "chroma_weight_lX_flag" ); // u(1): chroma_weight_l0_flag |
---|
| 3311 | wp[1].bPresentFlag = ( uiCode == 1 ); |
---|
| 3312 | wp[2].bPresentFlag = ( uiCode == 1 ); |
---|
| 3313 | uiTotalSignalledWeightFlags += 2*wp[1].bPresentFlag; |
---|
| 3314 | } |
---|
| 3315 | } |
---|
| 3316 | for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ ) |
---|
| 3317 | { |
---|
| 3318 | pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); |
---|
| 3319 | if ( wp[0].bPresentFlag ) |
---|
| 3320 | { |
---|
| 3321 | Int iDeltaWeight; |
---|
| 3322 | READ_SVLC( iDeltaWeight, "delta_luma_weight_lX" ); // se(v): delta_luma_weight_l0[i] |
---|
| 3323 | assert( iDeltaWeight >= -128 ); |
---|
| 3324 | assert( iDeltaWeight <= 127 ); |
---|
| 3325 | wp[0].iWeight = (iDeltaWeight + (1<<wp[0].uiLog2WeightDenom)); |
---|
| 3326 | READ_SVLC( wp[0].iOffset, "luma_offset_lX" ); // se(v): luma_offset_l0[i] |
---|
| 3327 | assert( wp[0].iOffset >= -128 ); |
---|
| 3328 | assert( wp[0].iOffset <= 127 ); |
---|
| 3329 | } |
---|
| 3330 | else |
---|
| 3331 | { |
---|
| 3332 | wp[0].iWeight = (1 << wp[0].uiLog2WeightDenom); |
---|
| 3333 | wp[0].iOffset = 0; |
---|
| 3334 | } |
---|
| 3335 | if ( bChroma ) |
---|
| 3336 | { |
---|
| 3337 | if ( wp[1].bPresentFlag ) |
---|
| 3338 | { |
---|
| 3339 | for ( Int j=1 ; j<3 ; j++ ) |
---|
| 3340 | { |
---|
| 3341 | Int iDeltaWeight; |
---|
| 3342 | READ_SVLC( iDeltaWeight, "delta_chroma_weight_lX" ); // se(v): chroma_weight_l0[i][j] |
---|
| 3343 | assert( iDeltaWeight >= -128 ); |
---|
| 3344 | assert( iDeltaWeight <= 127 ); |
---|
| 3345 | wp[j].iWeight = (iDeltaWeight + (1<<wp[1].uiLog2WeightDenom)); |
---|
| 3346 | |
---|
| 3347 | Int iDeltaChroma; |
---|
| 3348 | READ_SVLC( iDeltaChroma, "delta_chroma_offset_lX" ); // se(v): delta_chroma_offset_l0[i][j] |
---|
| 3349 | assert( iDeltaChroma >= -512 ); |
---|
| 3350 | assert( iDeltaChroma <= 511 ); |
---|
| 3351 | Int pred = ( 128 - ( ( 128*wp[j].iWeight)>>(wp[j].uiLog2WeightDenom) ) ); |
---|
| 3352 | wp[j].iOffset = Clip3(-128, 127, (iDeltaChroma + pred) ); |
---|
| 3353 | } |
---|
| 3354 | } |
---|
| 3355 | else |
---|
| 3356 | { |
---|
| 3357 | for ( Int j=1 ; j<3 ; j++ ) |
---|
| 3358 | { |
---|
| 3359 | wp[j].iWeight = (1 << wp[j].uiLog2WeightDenom); |
---|
| 3360 | wp[j].iOffset = 0; |
---|
| 3361 | } |
---|
| 3362 | } |
---|
| 3363 | } |
---|
| 3364 | } |
---|
| 3365 | |
---|
| 3366 | for ( Int iRefIdx=pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx<MAX_NUM_REF ; iRefIdx++ ) |
---|
| 3367 | { |
---|
| 3368 | pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); |
---|
| 3369 | |
---|
| 3370 | wp[0].bPresentFlag = false; |
---|
| 3371 | wp[1].bPresentFlag = false; |
---|
| 3372 | wp[2].bPresentFlag = false; |
---|
| 3373 | } |
---|
| 3374 | } |
---|
| 3375 | assert(uiTotalSignalledWeightFlags<=24); |
---|
| 3376 | } |
---|
| 3377 | |
---|
| 3378 | /** decode quantization matrix |
---|
| 3379 | * \param scalingList quantization matrix information |
---|
| 3380 | */ |
---|
| 3381 | Void TDecCavlc::parseScalingList(TComScalingList* scalingList) |
---|
| 3382 | { |
---|
| 3383 | UInt code, sizeId, listId; |
---|
| 3384 | Bool scalingListPredModeFlag; |
---|
| 3385 | //for each size |
---|
| 3386 | for(sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
| 3387 | { |
---|
| 3388 | for(listId = 0; listId < g_scalingListNum[sizeId]; listId++) |
---|
| 3389 | { |
---|
| 3390 | READ_FLAG( code, "scaling_list_pred_mode_flag"); |
---|
| 3391 | scalingListPredModeFlag = (code) ? true : false; |
---|
| 3392 | if(!scalingListPredModeFlag) //Copy Mode |
---|
| 3393 | { |
---|
| 3394 | READ_UVLC( code, "scaling_list_pred_matrix_id_delta"); |
---|
| 3395 | scalingList->setRefMatrixId (sizeId,listId,(UInt)((Int)(listId)-(code))); |
---|
| 3396 | if( sizeId > SCALING_LIST_8x8 ) |
---|
| 3397 | { |
---|
| 3398 | scalingList->setScalingListDC(sizeId,listId,((listId == scalingList->getRefMatrixId (sizeId,listId))? 16 :scalingList->getScalingListDC(sizeId, scalingList->getRefMatrixId (sizeId,listId)))); |
---|
| 3399 | } |
---|
| 3400 | scalingList->processRefMatrix( sizeId, listId, scalingList->getRefMatrixId (sizeId,listId)); |
---|
| 3401 | |
---|
| 3402 | } |
---|
| 3403 | else //DPCM Mode |
---|
| 3404 | { |
---|
| 3405 | xDecodeScalingList(scalingList, sizeId, listId); |
---|
| 3406 | } |
---|
| 3407 | } |
---|
| 3408 | } |
---|
| 3409 | |
---|
| 3410 | return; |
---|
| 3411 | } |
---|
| 3412 | /** decode DPCM |
---|
| 3413 | * \param scalingList quantization matrix information |
---|
| 3414 | * \param sizeId size index |
---|
| 3415 | * \param listId list index |
---|
| 3416 | */ |
---|
| 3417 | Void TDecCavlc::xDecodeScalingList(TComScalingList *scalingList, UInt sizeId, UInt listId) |
---|
| 3418 | { |
---|
| 3419 | Int i,coefNum = min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId]); |
---|
| 3420 | Int data; |
---|
| 3421 | Int scalingListDcCoefMinus8 = 0; |
---|
| 3422 | Int nextCoef = SCALING_LIST_START_VALUE; |
---|
| 3423 | UInt* scan = (sizeId == 0) ? g_auiSigLastScan [ SCAN_DIAG ] [ 1 ] : g_sigLastScanCG32x32; |
---|
| 3424 | Int *dst = scalingList->getScalingListAddress(sizeId, listId); |
---|
| 3425 | |
---|
| 3426 | if( sizeId > SCALING_LIST_8x8 ) |
---|
| 3427 | { |
---|
| 3428 | READ_SVLC( scalingListDcCoefMinus8, "scaling_list_dc_coef_minus8"); |
---|
| 3429 | scalingList->setScalingListDC(sizeId,listId,scalingListDcCoefMinus8 + 8); |
---|
| 3430 | nextCoef = scalingList->getScalingListDC(sizeId,listId); |
---|
| 3431 | } |
---|
| 3432 | |
---|
| 3433 | for(i = 0; i < coefNum; i++) |
---|
| 3434 | { |
---|
| 3435 | READ_SVLC( data, "scaling_list_delta_coef"); |
---|
| 3436 | nextCoef = (nextCoef + data + 256 ) % 256; |
---|
| 3437 | dst[scan[i]] = nextCoef; |
---|
| 3438 | } |
---|
| 3439 | } |
---|
| 3440 | |
---|
| 3441 | Bool TDecCavlc::xMoreRbspData() |
---|
| 3442 | { |
---|
| 3443 | Int bitsLeft = m_pcBitstream->getNumBitsLeft(); |
---|
| 3444 | |
---|
| 3445 | // if there are more than 8 bits, it cannot be rbsp_trailing_bits |
---|
| 3446 | if (bitsLeft > 8) |
---|
| 3447 | { |
---|
| 3448 | return true; |
---|
| 3449 | } |
---|
| 3450 | |
---|
| 3451 | UChar lastByte = m_pcBitstream->peekBits(bitsLeft); |
---|
| 3452 | Int cnt = bitsLeft; |
---|
| 3453 | |
---|
| 3454 | // remove trailing bits equal to zero |
---|
| 3455 | while ((cnt>0) && ((lastByte & 1) == 0)) |
---|
| 3456 | { |
---|
| 3457 | lastByte >>= 1; |
---|
| 3458 | cnt--; |
---|
| 3459 | } |
---|
| 3460 | // remove bit equal to one |
---|
| 3461 | cnt--; |
---|
| 3462 | |
---|
| 3463 | // we should not have a negative number of bits |
---|
| 3464 | assert (cnt>=0); |
---|
| 3465 | |
---|
| 3466 | // we have more data, if cnt is not zero |
---|
| 3467 | return (cnt>0); |
---|
| 3468 | } |
---|
[540] | 3469 | |
---|
[313] | 3470 | //! \} |
---|
| 3471 | |
---|