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