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