[191] | 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 |
---|
[216] | 4 | * granted under this license. |
---|
[191] | 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 | |
---|
[216] | 95 | if (interRPSPred) |
---|
[191] | 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 | { |
---|
[216] | 116 | READ_CODE(1, bit, "used_by_curr_pic_flag" ); //first bit is "1" if Idc is 1 |
---|
[191] | 117 | Int refIdc = bit; |
---|
[216] | 118 | if (refIdc == 0) |
---|
[191] | 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 | } |
---|
[216] | 133 | else |
---|
[191] | 134 | { |
---|
| 135 | k1++; |
---|
| 136 | } |
---|
| 137 | k++; |
---|
[216] | 138 | } |
---|
| 139 | rps->setRefIdc(j,refIdc); |
---|
[191] | 140 | } |
---|
[216] | 141 | rps->setNumRefIdc(rpsRef->getNumberOfPictures()+1); |
---|
[191] | 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 | { |
---|
[216] | 179 | #if ENC_DEC_TRACE |
---|
[191] | 180 | xTracePPSHeader (pcPPS); |
---|
| 181 | #endif |
---|
| 182 | UInt uiCode; |
---|
| 183 | |
---|
| 184 | Int iCode; |
---|
| 185 | |
---|
[302] | 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 | |
---|
[191] | 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); |
---|
[216] | 205 | |
---|
[191] | 206 | READ_UVLC(uiCode, "num_ref_idx_l1_default_active_minus1"); |
---|
| 207 | assert(uiCode <= 14); |
---|
| 208 | pcPPS->setNumRefIdxL1DefaultActive(uiCode+1); |
---|
[216] | 209 | |
---|
[191] | 210 | READ_SVLC(iCode, "init_qp_minus26" ); pcPPS->setPicInitQPMinus26(iCode); |
---|
| 211 | READ_FLAG( uiCode, "constrained_intra_pred_flag" ); pcPPS->setConstrainedIntraPred( uiCode ? true : false ); |
---|
[216] | 212 | READ_FLAG( uiCode, "transform_skip_enabled_flag" ); |
---|
| 213 | pcPPS->setUseTransformSkip ( uiCode ? true : false ); |
---|
[191] | 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 ); |
---|
[216] | 247 | |
---|
[191] | 248 | if( pcPPS->getTilesEnabledFlag() ) |
---|
| 249 | { |
---|
[216] | 250 | READ_UVLC ( uiCode, "num_tile_columns_minus1" ); pcPPS->setNumColumnsMinus1( uiCode ); |
---|
| 251 | READ_UVLC ( uiCode, "num_tile_rows_minus1" ); pcPPS->setNumRowsMinus1( uiCode ); |
---|
[191] | 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++) |
---|
[216] | 258 | { |
---|
| 259 | READ_UVLC( uiCode, "column_width_minus1" ); |
---|
[191] | 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); |
---|
[216] | 272 | free(rowHeight); |
---|
[191] | 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(timingInfo->getTimingInfoPresentFlag()) |
---|
| 380 | { |
---|
| 381 | READ_CODE( 32, uiCode, "vui_num_units_in_tick"); timingInfo->setNumUnitsInTick (uiCode); |
---|
| 382 | READ_CODE( 32, uiCode, "vui_time_scale"); timingInfo->setTimeScale (uiCode); |
---|
| 383 | READ_FLAG( uiCode, "vui_poc_proportional_to_timing_flag"); timingInfo->setPocProportionalToTimingFlag(uiCode ? true : false); |
---|
| 384 | if(timingInfo->getPocProportionalToTimingFlag()) |
---|
| 385 | { |
---|
| 386 | READ_UVLC( uiCode, "vui_num_ticks_poc_diff_one_minus1"); timingInfo->setNumTicksPocDiffOneMinus1 (uiCode); |
---|
| 387 | } |
---|
| 388 | READ_FLAG( uiCode, "hrd_parameters_present_flag"); pcVUI->setHrdParametersPresentFlag(uiCode); |
---|
| 389 | if( pcVUI->getHrdParametersPresentFlag() ) |
---|
| 390 | { |
---|
| 391 | parseHrdParameters( pcVUI->getHrdParameters(), 1, pcSPS->getMaxTLayers() - 1 ); |
---|
| 392 | } |
---|
| 393 | } |
---|
| 394 | READ_FLAG( uiCode, "bitstream_restriction_flag"); pcVUI->setBitstreamRestrictionFlag(uiCode); |
---|
| 395 | if (pcVUI->getBitstreamRestrictionFlag()) |
---|
| 396 | { |
---|
| 397 | READ_FLAG( uiCode, "tiles_fixed_structure_flag"); pcVUI->setTilesFixedStructureFlag(uiCode); |
---|
[299] | 398 | #if M0464_TILE_BOUNDARY_ALIGNED_FLAG |
---|
| 399 | if ( pcSPS->getLayerId() > 0 ) |
---|
| 400 | { |
---|
| 401 | READ_FLAG( uiCode, "tile_boundaries_aligned_flag" ); pcVUI->setTileBoundariesAlignedFlag( uiCode == 1 ); |
---|
| 402 | } |
---|
| 403 | #endif |
---|
[191] | 404 | READ_FLAG( uiCode, "motion_vectors_over_pic_boundaries_flag"); pcVUI->setMotionVectorsOverPicBoundariesFlag(uiCode); |
---|
| 405 | READ_FLAG( uiCode, "restricted_ref_pic_lists_flag"); pcVUI->setRestrictedRefPicListsFlag(uiCode); |
---|
| 406 | READ_UVLC( uiCode, "min_spatial_segmentation_idc"); pcVUI->setMinSpatialSegmentationIdc(uiCode); |
---|
| 407 | assert(uiCode < 4096); |
---|
| 408 | READ_UVLC( uiCode, "max_bytes_per_pic_denom" ); pcVUI->setMaxBytesPerPicDenom(uiCode); |
---|
| 409 | READ_UVLC( uiCode, "max_bits_per_mincu_denom" ); pcVUI->setMaxBitsPerMinCuDenom(uiCode); |
---|
| 410 | READ_UVLC( uiCode, "log2_max_mv_length_horizontal" ); pcVUI->setLog2MaxMvLengthHorizontal(uiCode); |
---|
| 411 | READ_UVLC( uiCode, "log2_max_mv_length_vertical" ); pcVUI->setLog2MaxMvLengthVertical(uiCode); |
---|
| 412 | } |
---|
| 413 | } |
---|
| 414 | |
---|
| 415 | Void TDecCavlc::parseHrdParameters(TComHRD *hrd, Bool commonInfPresentFlag, UInt maxNumSubLayersMinus1) |
---|
| 416 | { |
---|
| 417 | UInt uiCode; |
---|
| 418 | if( commonInfPresentFlag ) |
---|
| 419 | { |
---|
| 420 | READ_FLAG( uiCode, "nal_hrd_parameters_present_flag" ); hrd->setNalHrdParametersPresentFlag( uiCode == 1 ? true : false ); |
---|
| 421 | READ_FLAG( uiCode, "vcl_hrd_parameters_present_flag" ); hrd->setVclHrdParametersPresentFlag( uiCode == 1 ? true : false ); |
---|
| 422 | if( hrd->getNalHrdParametersPresentFlag() || hrd->getVclHrdParametersPresentFlag() ) |
---|
| 423 | { |
---|
| 424 | READ_FLAG( uiCode, "sub_pic_cpb_params_present_flag" ); hrd->setSubPicCpbParamsPresentFlag( uiCode == 1 ? true : false ); |
---|
| 425 | if( hrd->getSubPicCpbParamsPresentFlag() ) |
---|
| 426 | { |
---|
| 427 | READ_CODE( 8, uiCode, "tick_divisor_minus2" ); hrd->setTickDivisorMinus2( uiCode ); |
---|
| 428 | READ_CODE( 5, uiCode, "du_cpb_removal_delay_length_minus1" ); hrd->setDuCpbRemovalDelayLengthMinus1( uiCode ); |
---|
| 429 | READ_FLAG( uiCode, "sub_pic_cpb_params_in_pic_timing_sei_flag" ); hrd->setSubPicCpbParamsInPicTimingSEIFlag( uiCode == 1 ? true : false ); |
---|
| 430 | READ_CODE( 5, uiCode, "dpb_output_delay_du_length_minus1" ); hrd->setDpbOutputDelayDuLengthMinus1( uiCode ); |
---|
| 431 | } |
---|
| 432 | READ_CODE( 4, uiCode, "bit_rate_scale" ); hrd->setBitRateScale( uiCode ); |
---|
| 433 | READ_CODE( 4, uiCode, "cpb_size_scale" ); hrd->setCpbSizeScale( uiCode ); |
---|
| 434 | if( hrd->getSubPicCpbParamsPresentFlag() ) |
---|
| 435 | { |
---|
| 436 | READ_CODE( 4, uiCode, "cpb_size_du_scale" ); hrd->setDuCpbSizeScale( uiCode ); |
---|
| 437 | } |
---|
| 438 | READ_CODE( 5, uiCode, "initial_cpb_removal_delay_length_minus1" ); hrd->setInitialCpbRemovalDelayLengthMinus1( uiCode ); |
---|
| 439 | READ_CODE( 5, uiCode, "au_cpb_removal_delay_length_minus1" ); hrd->setCpbRemovalDelayLengthMinus1( uiCode ); |
---|
| 440 | READ_CODE( 5, uiCode, "dpb_output_delay_length_minus1" ); hrd->setDpbOutputDelayLengthMinus1( uiCode ); |
---|
| 441 | } |
---|
| 442 | } |
---|
| 443 | Int i, j, nalOrVcl; |
---|
| 444 | for( i = 0; i <= maxNumSubLayersMinus1; i ++ ) |
---|
| 445 | { |
---|
| 446 | READ_FLAG( uiCode, "fixed_pic_rate_general_flag" ); hrd->setFixedPicRateFlag( i, uiCode == 1 ? true : false ); |
---|
| 447 | if( !hrd->getFixedPicRateFlag( i ) ) |
---|
| 448 | { |
---|
| 449 | READ_FLAG( uiCode, "fixed_pic_rate_within_cvs_flag" ); hrd->setFixedPicRateWithinCvsFlag( i, uiCode == 1 ? true : false ); |
---|
| 450 | } |
---|
| 451 | else |
---|
| 452 | { |
---|
| 453 | hrd->setFixedPicRateWithinCvsFlag( i, true ); |
---|
| 454 | } |
---|
| 455 | hrd->setLowDelayHrdFlag( i, 0 ); // Infered to be 0 when not present |
---|
| 456 | hrd->setCpbCntMinus1 ( i, 0 ); // Infered to be 0 when not present |
---|
| 457 | if( hrd->getFixedPicRateWithinCvsFlag( i ) ) |
---|
| 458 | { |
---|
| 459 | READ_UVLC( uiCode, "elemental_duration_in_tc_minus1" ); hrd->setPicDurationInTcMinus1( i, uiCode ); |
---|
| 460 | } |
---|
| 461 | else |
---|
[216] | 462 | { |
---|
[191] | 463 | READ_FLAG( uiCode, "low_delay_hrd_flag" ); hrd->setLowDelayHrdFlag( i, uiCode == 1 ? true : false ); |
---|
| 464 | } |
---|
| 465 | if (!hrd->getLowDelayHrdFlag( i )) |
---|
| 466 | { |
---|
[216] | 467 | READ_UVLC( uiCode, "cpb_cnt_minus1" ); hrd->setCpbCntMinus1( i, uiCode ); |
---|
[191] | 468 | } |
---|
| 469 | for( nalOrVcl = 0; nalOrVcl < 2; nalOrVcl ++ ) |
---|
| 470 | { |
---|
| 471 | if( ( ( nalOrVcl == 0 ) && ( hrd->getNalHrdParametersPresentFlag() ) ) || |
---|
| 472 | ( ( nalOrVcl == 1 ) && ( hrd->getVclHrdParametersPresentFlag() ) ) ) |
---|
| 473 | { |
---|
| 474 | for( j = 0; j <= ( hrd->getCpbCntMinus1( i ) ); j ++ ) |
---|
| 475 | { |
---|
| 476 | READ_UVLC( uiCode, "bit_rate_value_minus1" ); hrd->setBitRateValueMinus1( i, j, nalOrVcl, uiCode ); |
---|
| 477 | READ_UVLC( uiCode, "cpb_size_value_minus1" ); hrd->setCpbSizeValueMinus1( i, j, nalOrVcl, uiCode ); |
---|
| 478 | if( hrd->getSubPicCpbParamsPresentFlag() ) |
---|
| 479 | { |
---|
[302] | 480 | READ_UVLC( uiCode, "cpb_size_du_value_minus1" ); hrd->setDuCpbSizeValueMinus1( i, j, nalOrVcl, uiCode ); |
---|
[191] | 481 | READ_UVLC( uiCode, "bit_rate_du_value_minus1" ); hrd->setDuBitRateValueMinus1( i, j, nalOrVcl, uiCode ); |
---|
| 482 | } |
---|
| 483 | READ_FLAG( uiCode, "cbr_flag" ); hrd->setCbrFlag( i, j, nalOrVcl, uiCode == 1 ? true : false ); |
---|
| 484 | } |
---|
| 485 | } |
---|
| 486 | } |
---|
| 487 | } |
---|
| 488 | } |
---|
| 489 | |
---|
[224] | 490 | #if SPS_SUB_LAYER_INFO |
---|
| 491 | Void TDecCavlc::parseSPS(TComSPS* pcSPS, ParameterSetManagerDecoder *parameterSetManager) |
---|
| 492 | #else |
---|
[191] | 493 | Void TDecCavlc::parseSPS(TComSPS* pcSPS) |
---|
[224] | 494 | #endif |
---|
[191] | 495 | { |
---|
[216] | 496 | #if ENC_DEC_TRACE |
---|
[191] | 497 | xTraceSPSHeader (pcSPS); |
---|
| 498 | #endif |
---|
| 499 | |
---|
| 500 | UInt uiCode; |
---|
| 501 | READ_CODE( 4, uiCode, "sps_video_parameter_set_id"); pcSPS->setVPSId ( uiCode ); |
---|
[224] | 502 | #if SPS_SUB_LAYER_INFO |
---|
| 503 | if(pcSPS->getLayerId() == 0) |
---|
| 504 | { |
---|
| 505 | #endif |
---|
| 506 | READ_CODE( 3, uiCode, "sps_max_sub_layers_minus1" ); pcSPS->setMaxTLayers ( uiCode+1 ); |
---|
[302] | 507 | assert(uiCode <= 6); |
---|
| 508 | |
---|
[224] | 509 | READ_FLAG( uiCode, "sps_temporal_id_nesting_flag" ); pcSPS->setTemporalIdNestingFlag ( uiCode > 0 ? true : false ); |
---|
| 510 | #if SPS_SUB_LAYER_INFO |
---|
| 511 | } |
---|
| 512 | else |
---|
| 513 | { |
---|
| 514 | pcSPS->setMaxTLayers ( parameterSetManager->getPrefetchedVPS(pcSPS->getVPSId())->getMaxTLayers() ); |
---|
| 515 | pcSPS->setTemporalIdNestingFlag( parameterSetManager->getPrefetchedVPS(pcSPS->getVPSId())->getTemporalNestingFlag() ); |
---|
| 516 | } |
---|
| 517 | #endif |
---|
[191] | 518 | if ( pcSPS->getMaxTLayers() == 1 ) |
---|
| 519 | { |
---|
| 520 | // sps_temporal_id_nesting_flag must be 1 when sps_max_sub_layers_minus1 is 0 |
---|
[224] | 521 | #if SPS_SUB_LAYER_INFO |
---|
| 522 | assert( pcSPS->getTemporalIdNestingFlag() == true ); |
---|
| 523 | #else |
---|
[191] | 524 | assert( uiCode == 1 ); |
---|
[224] | 525 | #endif |
---|
[191] | 526 | } |
---|
[216] | 527 | |
---|
[191] | 528 | parsePTL(pcSPS->getPTL(), 1, pcSPS->getMaxTLayers() - 1); |
---|
| 529 | READ_UVLC( uiCode, "sps_seq_parameter_set_id" ); pcSPS->setSPSId( uiCode ); |
---|
[302] | 530 | assert(uiCode <= 15); |
---|
| 531 | |
---|
[191] | 532 | READ_UVLC( uiCode, "chroma_format_idc" ); pcSPS->setChromaFormatIdc( uiCode ); |
---|
[302] | 533 | assert(uiCode <= 3); |
---|
[191] | 534 | // 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 |
---|
| 535 | assert (uiCode == 1); |
---|
| 536 | if( uiCode == 3 ) |
---|
| 537 | { |
---|
| 538 | READ_FLAG( uiCode, "separate_colour_plane_flag"); assert(uiCode == 0); |
---|
| 539 | } |
---|
| 540 | |
---|
| 541 | READ_UVLC ( uiCode, "pic_width_in_luma_samples" ); pcSPS->setPicWidthInLumaSamples ( uiCode ); |
---|
| 542 | READ_UVLC ( uiCode, "pic_height_in_luma_samples" ); pcSPS->setPicHeightInLumaSamples( uiCode ); |
---|
| 543 | READ_FLAG( uiCode, "conformance_window_flag"); |
---|
| 544 | if (uiCode != 0) |
---|
| 545 | { |
---|
| 546 | Window &conf = pcSPS->getConformanceWindow(); |
---|
| 547 | READ_UVLC( uiCode, "conf_win_left_offset" ); conf.setWindowLeftOffset ( uiCode * TComSPS::getWinUnitX( pcSPS->getChromaFormatIdc() ) ); |
---|
| 548 | READ_UVLC( uiCode, "conf_win_right_offset" ); conf.setWindowRightOffset ( uiCode * TComSPS::getWinUnitX( pcSPS->getChromaFormatIdc() ) ); |
---|
| 549 | READ_UVLC( uiCode, "conf_win_top_offset" ); conf.setWindowTopOffset ( uiCode * TComSPS::getWinUnitY( pcSPS->getChromaFormatIdc() ) ); |
---|
| 550 | READ_UVLC( uiCode, "conf_win_bottom_offset" ); conf.setWindowBottomOffset( uiCode * TComSPS::getWinUnitY( pcSPS->getChromaFormatIdc() ) ); |
---|
| 551 | } |
---|
| 552 | |
---|
| 553 | READ_UVLC( uiCode, "bit_depth_luma_minus8" ); |
---|
[302] | 554 | assert(uiCode <= 6); |
---|
[191] | 555 | pcSPS->setBitDepthY( uiCode + 8 ); |
---|
| 556 | pcSPS->setQpBDOffsetY( (Int) (6*uiCode) ); |
---|
| 557 | |
---|
| 558 | READ_UVLC( uiCode, "bit_depth_chroma_minus8" ); |
---|
[302] | 559 | assert(uiCode <= 6); |
---|
[191] | 560 | pcSPS->setBitDepthC( uiCode + 8 ); |
---|
| 561 | pcSPS->setQpBDOffsetC( (Int) (6*uiCode) ); |
---|
| 562 | |
---|
| 563 | READ_UVLC( uiCode, "log2_max_pic_order_cnt_lsb_minus4" ); pcSPS->setBitsForPOC( 4 + uiCode ); |
---|
[302] | 564 | assert(uiCode <= 12); |
---|
[191] | 565 | |
---|
| 566 | UInt subLayerOrderingInfoPresentFlag; |
---|
| 567 | READ_FLAG(subLayerOrderingInfoPresentFlag, "sps_sub_layer_ordering_info_present_flag"); |
---|
[302] | 568 | |
---|
[191] | 569 | for(UInt i=0; i <= pcSPS->getMaxTLayers()-1; i++) |
---|
| 570 | { |
---|
| 571 | READ_UVLC ( uiCode, "sps_max_dec_pic_buffering_minus1"); |
---|
| 572 | pcSPS->setMaxDecPicBuffering( uiCode + 1, i); |
---|
| 573 | READ_UVLC ( uiCode, "sps_num_reorder_pics" ); |
---|
| 574 | pcSPS->setNumReorderPics(uiCode, i); |
---|
[302] | 575 | READ_UVLC ( uiCode, "sps_max_latency_increase_plus1"); |
---|
[191] | 576 | pcSPS->setMaxLatencyIncrease( uiCode, i ); |
---|
| 577 | |
---|
| 578 | if (!subLayerOrderingInfoPresentFlag) |
---|
| 579 | { |
---|
| 580 | for (i++; i <= pcSPS->getMaxTLayers()-1; i++) |
---|
| 581 | { |
---|
| 582 | pcSPS->setMaxDecPicBuffering(pcSPS->getMaxDecPicBuffering(0), i); |
---|
| 583 | pcSPS->setNumReorderPics(pcSPS->getNumReorderPics(0), i); |
---|
| 584 | pcSPS->setMaxLatencyIncrease(pcSPS->getMaxLatencyIncrease(0), i); |
---|
| 585 | } |
---|
| 586 | break; |
---|
| 587 | } |
---|
| 588 | } |
---|
| 589 | |
---|
| 590 | READ_UVLC( uiCode, "log2_min_coding_block_size_minus3" ); |
---|
| 591 | Int log2MinCUSize = uiCode + 3; |
---|
| 592 | pcSPS->setLog2MinCodingBlockSize(log2MinCUSize); |
---|
| 593 | READ_UVLC( uiCode, "log2_diff_max_min_coding_block_size" ); |
---|
| 594 | pcSPS->setLog2DiffMaxMinCodingBlockSize(uiCode); |
---|
| 595 | Int maxCUDepthDelta = uiCode; |
---|
[216] | 596 | pcSPS->setMaxCUWidth ( 1<<(log2MinCUSize + maxCUDepthDelta) ); |
---|
[191] | 597 | pcSPS->setMaxCUHeight ( 1<<(log2MinCUSize + maxCUDepthDelta) ); |
---|
| 598 | READ_UVLC( uiCode, "log2_min_transform_block_size_minus2" ); pcSPS->setQuadtreeTULog2MinSize( uiCode + 2 ); |
---|
| 599 | |
---|
| 600 | READ_UVLC( uiCode, "log2_diff_max_min_transform_block_size" ); pcSPS->setQuadtreeTULog2MaxSize( uiCode + pcSPS->getQuadtreeTULog2MinSize() ); |
---|
| 601 | pcSPS->setMaxTrSize( 1<<(uiCode + pcSPS->getQuadtreeTULog2MinSize()) ); |
---|
| 602 | |
---|
| 603 | READ_UVLC( uiCode, "max_transform_hierarchy_depth_inter" ); pcSPS->setQuadtreeTUMaxDepthInter( uiCode+1 ); |
---|
| 604 | READ_UVLC( uiCode, "max_transform_hierarchy_depth_intra" ); pcSPS->setQuadtreeTUMaxDepthIntra( uiCode+1 ); |
---|
| 605 | |
---|
| 606 | Int addCuDepth = max (0, log2MinCUSize - (Int)pcSPS->getQuadtreeTULog2MinSize() ); |
---|
[216] | 607 | pcSPS->setMaxCUDepth( maxCUDepthDelta + addCuDepth ); |
---|
[191] | 608 | |
---|
| 609 | READ_FLAG( uiCode, "scaling_list_enabled_flag" ); pcSPS->setScalingListFlag ( uiCode ); |
---|
| 610 | if(pcSPS->getScalingListFlag()) |
---|
| 611 | { |
---|
| 612 | READ_FLAG( uiCode, "sps_scaling_list_data_present_flag" ); pcSPS->setScalingListPresentFlag ( uiCode ); |
---|
| 613 | if(pcSPS->getScalingListPresentFlag ()) |
---|
| 614 | { |
---|
| 615 | parseScalingList( pcSPS->getScalingList() ); |
---|
| 616 | } |
---|
| 617 | } |
---|
| 618 | READ_FLAG( uiCode, "amp_enabled_flag" ); pcSPS->setUseAMP( uiCode ); |
---|
| 619 | READ_FLAG( uiCode, "sample_adaptive_offset_enabled_flag" ); pcSPS->setUseSAO ( uiCode ? true : false ); |
---|
| 620 | |
---|
| 621 | READ_FLAG( uiCode, "pcm_enabled_flag" ); pcSPS->setUsePCM( uiCode ? true : false ); |
---|
| 622 | if( pcSPS->getUsePCM() ) |
---|
| 623 | { |
---|
| 624 | READ_CODE( 4, uiCode, "pcm_sample_bit_depth_luma_minus1" ); pcSPS->setPCMBitDepthLuma ( 1 + uiCode ); |
---|
| 625 | READ_CODE( 4, uiCode, "pcm_sample_bit_depth_chroma_minus1" ); pcSPS->setPCMBitDepthChroma ( 1 + uiCode ); |
---|
| 626 | READ_UVLC( uiCode, "log2_min_pcm_luma_coding_block_size_minus3" ); pcSPS->setPCMLog2MinSize (uiCode+3); |
---|
| 627 | READ_UVLC( uiCode, "log2_diff_max_min_pcm_luma_coding_block_size" ); pcSPS->setPCMLog2MaxSize ( uiCode+pcSPS->getPCMLog2MinSize() ); |
---|
| 628 | READ_FLAG( uiCode, "pcm_loop_filter_disable_flag" ); pcSPS->setPCMFilterDisableFlag ( uiCode ? true : false ); |
---|
| 629 | } |
---|
| 630 | |
---|
| 631 | READ_UVLC( uiCode, "num_short_term_ref_pic_sets" ); |
---|
[302] | 632 | assert(uiCode <= 64); |
---|
[191] | 633 | pcSPS->createRPSList(uiCode); |
---|
| 634 | |
---|
| 635 | TComRPSList* rpsList = pcSPS->getRPSList(); |
---|
| 636 | TComReferencePictureSet* rps; |
---|
| 637 | |
---|
| 638 | for(UInt i=0; i< rpsList->getNumberOfReferencePictureSets(); i++) |
---|
| 639 | { |
---|
| 640 | rps = rpsList->getReferencePictureSet(i); |
---|
| 641 | parseShortTermRefPicSet(pcSPS,rps,i); |
---|
| 642 | } |
---|
| 643 | READ_FLAG( uiCode, "long_term_ref_pics_present_flag" ); pcSPS->setLongTermRefsPresent(uiCode); |
---|
[216] | 644 | if (pcSPS->getLongTermRefsPresent()) |
---|
[191] | 645 | { |
---|
| 646 | READ_UVLC( uiCode, "num_long_term_ref_pic_sps" ); |
---|
| 647 | pcSPS->setNumLongTermRefPicSPS(uiCode); |
---|
| 648 | for (UInt k = 0; k < pcSPS->getNumLongTermRefPicSPS(); k++) |
---|
| 649 | { |
---|
| 650 | READ_CODE( pcSPS->getBitsForPOC(), uiCode, "lt_ref_pic_poc_lsb_sps" ); |
---|
| 651 | pcSPS->setLtRefPicPocLsbSps(k, uiCode); |
---|
| 652 | READ_FLAG( uiCode, "used_by_curr_pic_lt_sps_flag[i]"); |
---|
| 653 | pcSPS->setUsedByCurrPicLtSPSFlag(k, uiCode?1:0); |
---|
| 654 | } |
---|
| 655 | } |
---|
| 656 | READ_FLAG( uiCode, "sps_temporal_mvp_enable_flag" ); pcSPS->setTMVPFlagsPresent(uiCode); |
---|
| 657 | #if REF_IDX_MFM |
---|
[291] | 658 | #if !M0457_COL_PICTURE_SIGNALING |
---|
[191] | 659 | if(pcSPS->getLayerId() > 0) |
---|
| 660 | { |
---|
| 661 | READ_FLAG( uiCode, "sps_enh_mfm_enable_flag" ); |
---|
| 662 | pcSPS->setMFMEnabledFlag( uiCode ? true : false ); |
---|
| 663 | } |
---|
| 664 | #endif |
---|
[291] | 665 | #endif |
---|
[191] | 666 | READ_FLAG( uiCode, "sps_strong_intra_smoothing_enable_flag" ); pcSPS->setUseStrongIntraSmoothing(uiCode); |
---|
| 667 | |
---|
| 668 | READ_FLAG( uiCode, "vui_parameters_present_flag" ); pcSPS->setVuiParametersPresentFlag(uiCode); |
---|
| 669 | |
---|
| 670 | if (pcSPS->getVuiParametersPresentFlag()) |
---|
| 671 | { |
---|
| 672 | parseVUI(pcSPS->getVuiParameters(), pcSPS); |
---|
| 673 | } |
---|
| 674 | |
---|
[299] | 675 | READ_FLAG( uiCode, "sps_extension_flag"); |
---|
| 676 | if (uiCode) |
---|
| 677 | { |
---|
| 678 | #if SPS_EXTENSION |
---|
| 679 | parseSPSExtension( pcSPS ); |
---|
| 680 | READ_FLAG( uiCode, "sps_extension2_flag"); |
---|
| 681 | if(uiCode) |
---|
| 682 | { |
---|
| 683 | #endif |
---|
| 684 | while ( xMoreRbspData() ) |
---|
| 685 | { |
---|
| 686 | READ_FLAG( uiCode, "sps_extension_data_flag"); |
---|
| 687 | } |
---|
| 688 | #if SPS_EXTENSION |
---|
| 689 | } |
---|
| 690 | #endif |
---|
| 691 | } |
---|
| 692 | } |
---|
| 693 | |
---|
| 694 | #if SPS_EXTENSION |
---|
| 695 | Void TDecCavlc::parseSPSExtension( TComSPS* pcSPS ) |
---|
| 696 | { |
---|
| 697 | UInt uiCode; |
---|
| 698 | // more syntax elements to be parsed here |
---|
[227] | 699 | #if SCALED_REF_LAYER_OFFSETS |
---|
[228] | 700 | #if SCALED_REF_LAYER_OFFSET_FLAG |
---|
| 701 | READ_FLAG( uiCode, "scaled_ref_layer_offset_present_flag" ); |
---|
| 702 | if( uiCode ) |
---|
| 703 | #else |
---|
[227] | 704 | if( pcSPS->getLayerId() > 0 ) |
---|
[228] | 705 | #endif |
---|
[227] | 706 | { |
---|
[288] | 707 | Int iCode; |
---|
| 708 | READ_UVLC( uiCode, "num_scaled_ref_layer_offsets" ); pcSPS->setNumScaledRefLayerOffsets(uiCode); |
---|
| 709 | for(Int i = 0; i < pcSPS->getNumScaledRefLayerOffsets(); i++) |
---|
| 710 | { |
---|
| 711 | Window& scaledWindow = pcSPS->getScaledRefLayerWindow(i); |
---|
| 712 | READ_SVLC( iCode, "scaled_ref_layer_left_offset" ); scaledWindow.setWindowLeftOffset (iCode << 1); |
---|
| 713 | READ_SVLC( iCode, "scaled_ref_layer_top_offset" ); scaledWindow.setWindowTopOffset (iCode << 1); |
---|
| 714 | READ_SVLC( iCode, "scaled_ref_layer_right_offset" ); scaledWindow.setWindowRightOffset (iCode << 1); |
---|
| 715 | READ_SVLC( iCode, "scaled_ref_layer_bottom_offset" ); scaledWindow.setWindowBottomOffset(iCode << 1); |
---|
| 716 | } |
---|
[227] | 717 | } |
---|
[299] | 718 | #endif |
---|
[300] | 719 | #if M0463_VUI_EXT_ILP_REF |
---|
| 720 | //// sps_extension_vui_parameters( ) |
---|
| 721 | if( pcSPS->getVuiParameters()->getBitstreamRestrictionFlag() ) |
---|
| 722 | { |
---|
| 723 | READ_UVLC( uiCode, "num_ilp_restricted_ref_layers" ); pcSPS->setNumIlpRestrictedRefLayers( uiCode ); |
---|
| 724 | for( Int i = 0; i < pcSPS->getNumIlpRestrictedRefLayers( ); i++ ) |
---|
| 725 | { |
---|
| 726 | READ_UVLC( uiCode, "min_spatial_segment_offset_plus1" ); pcSPS->setMinSpatialSegmentOffsetPlus1( i, uiCode ); |
---|
| 727 | if( pcSPS->getMinSpatialSegmentOffsetPlus1( i ) > 0 ) |
---|
| 728 | { |
---|
| 729 | READ_FLAG( uiCode, "ctu_based_offset_enabled_flag[ i ]"); pcSPS->setCtuBasedOffsetEnabledFlag(i, uiCode == 1 ); |
---|
| 730 | if( pcSPS->getCtuBasedOffsetEnabledFlag( i ) ) |
---|
| 731 | { |
---|
| 732 | READ_UVLC( uiCode, "min_horizontal_ctu_offset_plus1[ i ]"); pcSPS->setMinHorizontalCtuOffsetPlus1( i, uiCode ); |
---|
| 733 | } |
---|
| 734 | } |
---|
| 735 | } |
---|
| 736 | } |
---|
| 737 | //// sps_extension_vui_parameters( ) END |
---|
| 738 | #endif |
---|
[299] | 739 | } |
---|
| 740 | #endif |
---|
[300] | 741 | |
---|
[299] | 742 | Void TDecCavlc::parseVPS(TComVPS* pcVPS) |
---|
| 743 | { |
---|
| 744 | UInt uiCode; |
---|
[191] | 745 | |
---|
| 746 | READ_CODE( 4, uiCode, "vps_video_parameter_set_id" ); pcVPS->setVPSId( uiCode ); |
---|
| 747 | READ_CODE( 2, uiCode, "vps_reserved_three_2bits" ); assert(uiCode == 3); |
---|
| 748 | #if VPS_RENAME |
---|
| 749 | READ_CODE( 6, uiCode, "vps_max_layers_minus1" ); pcVPS->setMaxLayers( uiCode + 1); |
---|
| 750 | #else |
---|
| 751 | READ_CODE( 6, uiCode, "vps_reserved_zero_6bits" ); assert(uiCode == 0); |
---|
| 752 | #endif |
---|
| 753 | READ_CODE( 3, uiCode, "vps_max_sub_layers_minus1" ); pcVPS->setMaxTLayers( uiCode + 1 ); |
---|
| 754 | READ_FLAG( uiCode, "vps_temporal_id_nesting_flag" ); pcVPS->setTemporalNestingFlag( uiCode ? true:false ); |
---|
| 755 | assert (pcVPS->getMaxTLayers()>1||pcVPS->getTemporalNestingFlag()); |
---|
| 756 | READ_CODE( 16, uiCode, "vps_reserved_ffff_16bits" ); assert(uiCode == 0xffff); |
---|
| 757 | parsePTL ( pcVPS->getPTL(), true, pcVPS->getMaxTLayers()-1); |
---|
| 758 | UInt subLayerOrderingInfoPresentFlag; |
---|
| 759 | READ_FLAG(subLayerOrderingInfoPresentFlag, "vps_sub_layer_ordering_info_present_flag"); |
---|
| 760 | for(UInt i = 0; i <= pcVPS->getMaxTLayers()-1; i++) |
---|
| 761 | { |
---|
| 762 | READ_UVLC( uiCode, "vps_max_dec_pic_buffering_minus1[i]" ); pcVPS->setMaxDecPicBuffering( uiCode + 1, i ); |
---|
| 763 | READ_UVLC( uiCode, "vps_num_reorder_pics[i]" ); pcVPS->setNumReorderPics( uiCode, i ); |
---|
[302] | 764 | READ_UVLC( uiCode, "vps_max_latency_increase_plus1[i]" ); pcVPS->setMaxLatencyIncrease( uiCode, i ); |
---|
[191] | 765 | |
---|
| 766 | if (!subLayerOrderingInfoPresentFlag) |
---|
| 767 | { |
---|
| 768 | for (i++; i <= pcVPS->getMaxTLayers()-1; i++) |
---|
| 769 | { |
---|
| 770 | pcVPS->setMaxDecPicBuffering(pcVPS->getMaxDecPicBuffering(0), i); |
---|
| 771 | pcVPS->setNumReorderPics(pcVPS->getNumReorderPics(0), i); |
---|
| 772 | pcVPS->setMaxLatencyIncrease(pcVPS->getMaxLatencyIncrease(0), i); |
---|
| 773 | } |
---|
| 774 | break; |
---|
| 775 | } |
---|
| 776 | } |
---|
| 777 | |
---|
| 778 | #if VPS_RENAME |
---|
| 779 | assert( pcVPS->getNumHrdParameters() < MAX_VPS_LAYER_SETS_PLUS1 ); |
---|
| 780 | assert( pcVPS->getMaxLayerId() < MAX_VPS_LAYER_ID_PLUS1 ); |
---|
| 781 | READ_CODE( 6, uiCode, "vps_max_layer_id" ); pcVPS->setMaxLayerId( uiCode ); |
---|
| 782 | READ_UVLC( uiCode, "vps_num_layer_sets_minus1" ); pcVPS->setNumLayerSets( uiCode + 1 ); |
---|
| 783 | for( UInt opsIdx = 1; opsIdx <= ( pcVPS->getNumLayerSets() - 1 ); opsIdx ++ ) |
---|
| 784 | { |
---|
| 785 | // Operation point set |
---|
| 786 | for( UInt i = 0; i <= pcVPS->getMaxLayerId(); i ++ ) |
---|
| 787 | #else |
---|
| 788 | assert( pcVPS->getNumHrdParameters() < MAX_VPS_OP_SETS_PLUS1 ); |
---|
| 789 | assert( pcVPS->getMaxNuhReservedZeroLayerId() < MAX_VPS_NUH_RESERVED_ZERO_LAYER_ID_PLUS1 ); |
---|
| 790 | READ_CODE( 6, uiCode, "vps_max_nuh_reserved_zero_layer_id" ); pcVPS->setMaxNuhReservedZeroLayerId( uiCode ); |
---|
| 791 | READ_UVLC( uiCode, "vps_max_op_sets_minus1" ); pcVPS->setMaxOpSets( uiCode + 1 ); |
---|
| 792 | for( UInt opsIdx = 1; opsIdx <= ( pcVPS->getMaxOpSets() - 1 ); opsIdx ++ ) |
---|
| 793 | { |
---|
| 794 | // Operation point set |
---|
| 795 | for( UInt i = 0; i <= pcVPS->getMaxNuhReservedZeroLayerId(); i ++ ) |
---|
| 796 | #endif |
---|
| 797 | { |
---|
| 798 | READ_FLAG( uiCode, "layer_id_included_flag[opsIdx][i]" ); pcVPS->setLayerIdIncludedFlag( uiCode == 1 ? true : false, opsIdx, i ); |
---|
| 799 | } |
---|
| 800 | } |
---|
| 801 | #if DERIVE_LAYER_ID_LIST_VARIABLES |
---|
| 802 | pcVPS->deriveLayerIdListVariables(); |
---|
| 803 | #endif |
---|
| 804 | TimingInfo *timingInfo = pcVPS->getTimingInfo(); |
---|
| 805 | READ_FLAG( uiCode, "vps_timing_info_present_flag"); timingInfo->setTimingInfoPresentFlag (uiCode ? true : false); |
---|
| 806 | if(timingInfo->getTimingInfoPresentFlag()) |
---|
| 807 | { |
---|
| 808 | READ_CODE( 32, uiCode, "vps_num_units_in_tick"); timingInfo->setNumUnitsInTick (uiCode); |
---|
| 809 | READ_CODE( 32, uiCode, "vps_time_scale"); timingInfo->setTimeScale (uiCode); |
---|
| 810 | READ_FLAG( uiCode, "vps_poc_proportional_to_timing_flag"); timingInfo->setPocProportionalToTimingFlag(uiCode ? true : false); |
---|
| 811 | if(timingInfo->getPocProportionalToTimingFlag()) |
---|
| 812 | { |
---|
| 813 | READ_UVLC( uiCode, "vps_num_ticks_poc_diff_one_minus1"); timingInfo->setNumTicksPocDiffOneMinus1 (uiCode); |
---|
| 814 | } |
---|
| 815 | READ_UVLC( uiCode, "vps_num_hrd_parameters" ); pcVPS->setNumHrdParameters( uiCode ); |
---|
| 816 | |
---|
| 817 | if( pcVPS->getNumHrdParameters() > 0 ) |
---|
| 818 | { |
---|
| 819 | pcVPS->createHrdParamBuffer(); |
---|
| 820 | } |
---|
| 821 | for( UInt i = 0; i < pcVPS->getNumHrdParameters(); i ++ ) |
---|
| 822 | { |
---|
| 823 | READ_UVLC( uiCode, "hrd_op_set_idx" ); pcVPS->setHrdOpSetIdx( uiCode, i ); |
---|
| 824 | if( i > 0 ) |
---|
| 825 | { |
---|
| 826 | READ_FLAG( uiCode, "cprms_present_flag[i]" ); pcVPS->setCprmsPresentFlag( uiCode == 1 ? true : false, i ); |
---|
| 827 | } |
---|
| 828 | parseHrdParameters(pcVPS->getHrdParameters(i), pcVPS->getCprmsPresentFlag( i ), pcVPS->getMaxTLayers() - 1); |
---|
| 829 | } |
---|
| 830 | } |
---|
| 831 | READ_FLAG( uiCode, "vps_extension_flag" ); |
---|
| 832 | if (uiCode) |
---|
| 833 | { |
---|
| 834 | #if VPS_EXTNS |
---|
| 835 | parseVPSExtension(pcVPS); |
---|
| 836 | READ_FLAG( uiCode, "vps_entension2_flag" ); |
---|
| 837 | if(uiCode) |
---|
| 838 | { |
---|
| 839 | while ( xMoreRbspData() ) |
---|
| 840 | { |
---|
| 841 | READ_FLAG( uiCode, "vps_extension_data_flag"); |
---|
| 842 | } |
---|
| 843 | } |
---|
| 844 | #else |
---|
| 845 | while ( xMoreRbspData() ) |
---|
| 846 | { |
---|
| 847 | READ_FLAG( uiCode, "vps_extension_data_flag"); |
---|
| 848 | } |
---|
| 849 | #endif |
---|
| 850 | } |
---|
[216] | 851 | |
---|
[191] | 852 | return; |
---|
| 853 | } |
---|
| 854 | |
---|
| 855 | #if VPS_EXTNS |
---|
| 856 | Void TDecCavlc::parseVPSExtension(TComVPS *vps) |
---|
[216] | 857 | { |
---|
[191] | 858 | UInt uiCode; |
---|
| 859 | // ... More syntax elements to be parsed here |
---|
| 860 | #if VPS_EXTN_MASK_AND_DIM_INFO |
---|
| 861 | UInt numScalabilityTypes = 0, i = 0, j = 0; |
---|
| 862 | |
---|
| 863 | READ_FLAG( uiCode, "avc_base_layer_flag" ); vps->setAvcBaseLayerFlag(uiCode ? true : false); |
---|
| 864 | READ_FLAG( uiCode, "splitting_flag" ); vps->setSplittingFlag(uiCode ? true : false); |
---|
| 865 | |
---|
| 866 | for(i = 0; i < MAX_VPS_NUM_SCALABILITY_TYPES; i++) |
---|
| 867 | { |
---|
| 868 | READ_FLAG( uiCode, "scalability_mask[i]" ); vps->setScalabilityMask(i, uiCode ? true : false); |
---|
| 869 | numScalabilityTypes += uiCode; |
---|
| 870 | } |
---|
| 871 | vps->setNumScalabilityTypes(numScalabilityTypes); |
---|
| 872 | |
---|
[289] | 873 | #if VPS_SPLIT_FLAG |
---|
| 874 | for(j = 0; j < numScalabilityTypes - vps->getSplittingFlag(); j++) |
---|
| 875 | #else |
---|
[191] | 876 | for(j = 0; j < numScalabilityTypes; j++) |
---|
[289] | 877 | #endif |
---|
[191] | 878 | { |
---|
| 879 | READ_CODE( 3, uiCode, "dimension_id_len_minus1[j]" ); vps->setDimensionIdLen(j, uiCode + 1); |
---|
| 880 | } |
---|
[289] | 881 | #if VPS_SPLIT_FLAG |
---|
[191] | 882 | if(vps->getSplittingFlag()) |
---|
| 883 | { |
---|
| 884 | UInt numBits = 0; |
---|
[289] | 885 | for(j = 0; j < numScalabilityTypes - 1; j++) |
---|
| 886 | { |
---|
| 887 | numBits += vps->getDimensionIdLen(j); |
---|
| 888 | } |
---|
| 889 | assert( numBits < 6 ); |
---|
| 890 | vps->setDimensionIdLen(numScalabilityTypes-1, 6 - numBits); |
---|
| 891 | numBits = 6; |
---|
| 892 | } |
---|
| 893 | #else |
---|
| 894 | if(vps->getSplittingFlag()) |
---|
| 895 | { |
---|
| 896 | UInt numBits = 0; |
---|
[191] | 897 | for(j = 0; j < numScalabilityTypes; j++) |
---|
| 898 | { |
---|
| 899 | numBits += vps->getDimensionIdLen(j); |
---|
| 900 | } |
---|
| 901 | assert( numBits <= 6 ); |
---|
| 902 | } |
---|
[289] | 903 | #endif |
---|
[191] | 904 | |
---|
| 905 | READ_FLAG( uiCode, "vps_nuh_layer_id_present_flag" ); vps->setNuhLayerIdPresentFlag(uiCode ? true : false); |
---|
| 906 | vps->setLayerIdInNuh(0, 0); |
---|
| 907 | vps->setLayerIdInVps(0, 0); |
---|
| 908 | for(i = 1; i < vps->getMaxLayers(); i++) |
---|
| 909 | { |
---|
| 910 | if( vps->getNuhLayerIdPresentFlag() ) |
---|
| 911 | { |
---|
| 912 | READ_CODE( 6, uiCode, "layer_id_in_nuh[i]" ); vps->setLayerIdInNuh(i, uiCode); |
---|
| 913 | assert( uiCode > vps->getLayerIdInNuh(i-1) ); |
---|
| 914 | } |
---|
| 915 | else |
---|
| 916 | { |
---|
| 917 | vps->setLayerIdInNuh(i, i); |
---|
| 918 | } |
---|
| 919 | vps->setLayerIdInVps(vps->getLayerIdInNuh(i), i); |
---|
| 920 | |
---|
[289] | 921 | #if VPS_SPLIT_FLAG |
---|
| 922 | if(!vps->getSplittingFlag()) |
---|
| 923 | #endif |
---|
[191] | 924 | for(j = 0; j < numScalabilityTypes; j++) |
---|
| 925 | { |
---|
| 926 | READ_CODE( vps->getDimensionIdLen(j), uiCode, "dimension_id[i][j]" ); vps->setDimensionId(i, j, uiCode); |
---|
| 927 | assert( uiCode <= vps->getMaxLayerId() ); |
---|
| 928 | } |
---|
| 929 | } |
---|
| 930 | #endif |
---|
| 931 | #if VPS_MOVE_DIR_DEPENDENCY_FLAG |
---|
| 932 | #if VPS_EXTN_DIRECT_REF_LAYERS |
---|
| 933 | // For layer 0 |
---|
| 934 | vps->setNumDirectRefLayers(0, 0); |
---|
| 935 | // For other layers |
---|
| 936 | for( Int layerCtr = 1; layerCtr <= vps->getMaxLayers() - 1; layerCtr++) |
---|
| 937 | { |
---|
| 938 | UInt numDirectRefLayers = 0; |
---|
| 939 | for( Int refLayerCtr = 0; refLayerCtr < layerCtr; refLayerCtr++) |
---|
| 940 | { |
---|
| 941 | READ_FLAG(uiCode, "direct_dependency_flag[i][j]" ); vps->setDirectDependencyFlag(layerCtr, refLayerCtr, uiCode? true : false); |
---|
| 942 | if(uiCode) |
---|
| 943 | { |
---|
| 944 | vps->setRefLayerId(layerCtr, numDirectRefLayers, refLayerCtr); |
---|
| 945 | numDirectRefLayers++; |
---|
| 946 | } |
---|
| 947 | } |
---|
| 948 | vps->setNumDirectRefLayers(layerCtr, numDirectRefLayers); |
---|
| 949 | } |
---|
| 950 | #endif |
---|
| 951 | #endif |
---|
[216] | 952 | #if JCTVC_M0203_INTERLAYER_PRED_IDC |
---|
| 953 | for(i = 0; i < vps->getMaxLayers() - 1; i++) |
---|
| 954 | { |
---|
| 955 | READ_CODE( 3, uiCode, "max_sublayer_for_ilp_plus1[i]" ); vps->setMaxSublayerForIlpPlus1(i, uiCode); |
---|
| 956 | assert( uiCode <= vps->getMaxTLayers() ); |
---|
| 957 | } |
---|
| 958 | #endif |
---|
[191] | 959 | #if VPS_EXTN_PROFILE_INFO |
---|
| 960 | // Profile-tier-level signalling |
---|
| 961 | #if VPS_PROFILE_OUTPUT_LAYERS |
---|
| 962 | READ_CODE( 10, uiCode, "vps_number_layer_sets_minus1" ); assert( uiCode == (vps->getNumLayerSets() - 1) ); |
---|
| 963 | READ_CODE( 6, uiCode, "vps_num_profile_tier_level_minus1"); vps->setNumProfileTierLevel( uiCode + 1 ); |
---|
| 964 | vps->getPTLForExtnPtr()->resize(vps->getNumProfileTierLevel()); |
---|
| 965 | for(Int idx = 1; idx <= vps->getNumProfileTierLevel() - 1; idx++) |
---|
| 966 | #else |
---|
| 967 | vps->getPTLForExtnPtr()->resize(vps->getNumLayerSets()); |
---|
| 968 | for(Int idx = 1; idx <= vps->getNumLayerSets() - 1; idx++) |
---|
| 969 | #endif |
---|
| 970 | { |
---|
| 971 | READ_FLAG( uiCode, "vps_profile_present_flag[i]" ); vps->setProfilePresentFlag(idx, uiCode ? true : false); |
---|
| 972 | if( !vps->getProfilePresentFlag(idx) ) |
---|
| 973 | { |
---|
| 974 | #if VPS_PROFILE_OUTPUT_LAYERS |
---|
| 975 | READ_CODE( 6, uiCode, "profile_ref_minus1[i]" ); vps->setProfileLayerSetRef(idx, uiCode + 1); |
---|
| 976 | #else |
---|
| 977 | READ_UVLC( uiCode, "vps_profile_layer_set_ref_minus1[i]" ); vps->setProfileLayerSetRef(idx, uiCode + 1); |
---|
| 978 | #endif |
---|
| 979 | assert( vps->getProfileLayerSetRef(idx) < idx ); |
---|
[216] | 980 | // Copy profile information as indicated |
---|
[191] | 981 | vps->getPTLForExtn(idx)->copyProfileInfo( vps->getPTLForExtn( vps->getProfileLayerSetRef(idx) ) ); |
---|
[216] | 982 | } |
---|
[191] | 983 | parsePTL( vps->getPTLForExtn(idx), vps->getProfilePresentFlag(idx), vps->getMaxTLayers() - 1 ); |
---|
| 984 | } |
---|
| 985 | #endif |
---|
| 986 | |
---|
| 987 | #if VPS_PROFILE_OUTPUT_LAYERS |
---|
| 988 | READ_FLAG( uiCode, "more_output_layer_sets_than_default_flag" ); vps->setMoreOutputLayerSetsThanDefaultFlag( uiCode ? true : false ); |
---|
| 989 | Int numOutputLayerSets = 0; |
---|
| 990 | if(! vps->getMoreOutputLayerSetsThanDefaultFlag() ) |
---|
| 991 | { |
---|
| 992 | numOutputLayerSets = vps->getNumLayerSets(); |
---|
| 993 | } |
---|
| 994 | else |
---|
| 995 | { |
---|
| 996 | READ_CODE( 10, uiCode, "num_add_output_layer_sets" ); vps->setNumAddOutputLayerSets( uiCode ); |
---|
| 997 | numOutputLayerSets = vps->getNumLayerSets() + vps->getNumAddOutputLayerSets(); |
---|
| 998 | } |
---|
| 999 | if( numOutputLayerSets > 1 ) |
---|
| 1000 | { |
---|
| 1001 | READ_FLAG( uiCode, "default_one_target_output_layer_flag" ); vps->setDefaultOneTargetOutputLayerFlag( uiCode ? true : false ); |
---|
| 1002 | } |
---|
| 1003 | vps->setNumOutputLayerSets( numOutputLayerSets ); |
---|
| 1004 | |
---|
| 1005 | for(i = 1; i < numOutputLayerSets; i++) |
---|
| 1006 | { |
---|
| 1007 | if( i > (vps->getNumLayerSets() - 1) ) |
---|
| 1008 | { |
---|
| 1009 | Int numBits = 1; |
---|
| 1010 | while ((1 << numBits) < (vps->getNumLayerSets() - 1)) |
---|
| 1011 | { |
---|
| 1012 | numBits++; |
---|
| 1013 | } |
---|
| 1014 | READ_CODE( numBits, uiCode, "output_layer_set_idx_minus1"); vps->setOutputLayerSetIdx( i, uiCode + 1); |
---|
| 1015 | Int lsIdx = vps->getOutputLayerSetIdx(i); |
---|
| 1016 | for(j = 0; j < vps->getNumLayersInIdList(lsIdx) - 1; j++) |
---|
| 1017 | { |
---|
| 1018 | READ_FLAG( uiCode, "output_layer_flag[i][j]"); vps->setOutputLayerFlag(i, j, uiCode); |
---|
| 1019 | } |
---|
| 1020 | } |
---|
| 1021 | else |
---|
| 1022 | { |
---|
| 1023 | // i <= (vps->getNumLayerSets() - 1) |
---|
| 1024 | // Assign OutputLayerFlag depending on default_one_target_output_layer_flag |
---|
| 1025 | Int lsIdx = i; |
---|
| 1026 | if( vps->getDefaultOneTargetOutputLayerFlag() ) |
---|
| 1027 | { |
---|
| 1028 | for(j = 0; j < vps->getNumLayersInIdList(lsIdx); j++) |
---|
| 1029 | { |
---|
| 1030 | vps->setOutputLayerFlag(i, j, (j == (vps->getNumLayersInIdList(lsIdx)-1))); |
---|
| 1031 | } |
---|
| 1032 | } |
---|
| 1033 | else |
---|
| 1034 | { |
---|
| 1035 | for(j = 0; j < vps->getNumLayersInIdList(lsIdx); j++) |
---|
| 1036 | { |
---|
| 1037 | vps->setOutputLayerFlag(i, j, 1); |
---|
| 1038 | } |
---|
| 1039 | } |
---|
| 1040 | } |
---|
| 1041 | Int numBits = 1; |
---|
| 1042 | while ((1 << numBits) < (vps->getNumProfileTierLevel())) |
---|
| 1043 | { |
---|
| 1044 | numBits++; |
---|
| 1045 | } |
---|
| 1046 | READ_CODE( numBits, uiCode, "profile_level_tier_idx[i]" ); vps->setProfileLevelTierIdx(i, uiCode); |
---|
| 1047 | } |
---|
| 1048 | #else |
---|
| 1049 | #if VPS_EXTN_OP_LAYER_SETS |
---|
| 1050 | // Target output layer signalling |
---|
| 1051 | READ_UVLC( uiCode, "vps_num_output_layer_sets"); vps->setNumOutputLayerSets(uiCode); |
---|
| 1052 | for(i = 0; i < vps->getNumOutputLayerSets(); i++) |
---|
| 1053 | { |
---|
| 1054 | #if VPS_OUTPUT_LAYER_SET_IDX |
---|
| 1055 | READ_UVLC( uiCode, "vps_output_layer_set_idx_minus1[i]"); vps->setOutputLayerSetIdx(i, uiCode + 1); |
---|
| 1056 | #else |
---|
| 1057 | READ_UVLC( uiCode, "vps_output_layer_set_idx[i]"); vps->setOutputLayerSetIdx(i, uiCode); |
---|
| 1058 | #endif |
---|
| 1059 | Int lsIdx = vps->getOutputLayerSetIdx(i); |
---|
| 1060 | for(j = 0; j <= vps->getMaxLayerId(); j++) |
---|
| 1061 | { |
---|
| 1062 | if(vps->getLayerIdIncludedFlag(lsIdx, j)) |
---|
| 1063 | { |
---|
| 1064 | READ_FLAG( uiCode, "vps_output_layer_flag[lsIdx][j]"); vps->setOutputLayerFlag(lsIdx, j, uiCode); |
---|
| 1065 | } |
---|
| 1066 | } |
---|
[216] | 1067 | } |
---|
[191] | 1068 | #endif |
---|
| 1069 | #endif |
---|
| 1070 | #if JCTVC_M0458_INTERLAYER_RPS_SIG |
---|
| 1071 | READ_FLAG(uiCode, "max_one_active_ref_layer_flag" ); |
---|
[216] | 1072 | vps->setMaxOneActiveRefLayerFlag(uiCode); |
---|
| 1073 | #endif |
---|
[191] | 1074 | |
---|
| 1075 | #if !VPS_MOVE_DIR_DEPENDENCY_FLAG |
---|
| 1076 | #if VPS_EXTN_DIRECT_REF_LAYERS |
---|
| 1077 | // For layer 0 |
---|
| 1078 | vps->setNumDirectRefLayers(0, 0); |
---|
| 1079 | // For other layers |
---|
| 1080 | for( Int layerCtr = 1; layerCtr <= vps->getMaxLayers() - 1; layerCtr++) |
---|
| 1081 | { |
---|
| 1082 | UInt numDirectRefLayers = 0; |
---|
| 1083 | for( Int refLayerCtr = 0; refLayerCtr < layerCtr; refLayerCtr++) |
---|
| 1084 | { |
---|
| 1085 | READ_FLAG(uiCode, "direct_dependency_flag[i][j]" ); vps->setDirectDependencyFlag(layerCtr, refLayerCtr, uiCode? true : false); |
---|
| 1086 | if(uiCode) |
---|
| 1087 | { |
---|
| 1088 | vps->setRefLayerId(layerCtr, numDirectRefLayers, refLayerCtr); |
---|
| 1089 | numDirectRefLayers++; |
---|
| 1090 | } |
---|
| 1091 | } |
---|
| 1092 | vps->setNumDirectRefLayers(layerCtr, numDirectRefLayers); |
---|
| 1093 | } |
---|
| 1094 | #endif |
---|
| 1095 | #endif |
---|
[290] | 1096 | #if VPS_EXTN_DIRECT_REF_LAYERS && M0457_PREDICTION_INDICATIONS |
---|
| 1097 | READ_UVLC( uiCode, "direct_dep_type_len_minus2"); vps->setDirectDepTypeLen(uiCode+2); |
---|
| 1098 | for(i = 1; i < vps->getMaxLayers(); i++) |
---|
| 1099 | { |
---|
| 1100 | for(j = 0; j < i; j++) |
---|
| 1101 | { |
---|
| 1102 | if (vps->getDirectDependencyFlag(i, j)) |
---|
| 1103 | { |
---|
| 1104 | READ_CODE( vps->getDirectDepTypeLen(), uiCode, "direct_dependency_type[i][j]" ); vps->setDirectDependencyType(i, j, uiCode); |
---|
| 1105 | } |
---|
| 1106 | } |
---|
| 1107 | } |
---|
| 1108 | #endif |
---|
[296] | 1109 | #if M0040_ADAPTIVE_RESOLUTION_CHANGE |
---|
| 1110 | READ_FLAG(uiCode, "single_layer_for_non_irap_flag" ); vps->setSingleLayerForNonIrapFlag(uiCode == 1 ? true : false); |
---|
| 1111 | #endif |
---|
[191] | 1112 | } |
---|
| 1113 | #endif |
---|
| 1114 | |
---|
| 1115 | Void TDecCavlc::parseSliceHeader (TComSlice*& rpcSlice, ParameterSetManagerDecoder *parameterSetManager) |
---|
| 1116 | { |
---|
| 1117 | UInt uiCode; |
---|
| 1118 | Int iCode; |
---|
| 1119 | |
---|
| 1120 | #if ENC_DEC_TRACE |
---|
| 1121 | xTraceSliceHeader(rpcSlice); |
---|
| 1122 | #endif |
---|
| 1123 | TComPPS* pps = NULL; |
---|
| 1124 | TComSPS* sps = NULL; |
---|
| 1125 | |
---|
| 1126 | UInt firstSliceSegmentInPic; |
---|
| 1127 | READ_FLAG( firstSliceSegmentInPic, "first_slice_segment_in_pic_flag" ); |
---|
| 1128 | if( rpcSlice->getRapPicFlag()) |
---|
[216] | 1129 | { |
---|
[191] | 1130 | READ_FLAG( uiCode, "no_output_of_prior_pics_flag" ); //ignored |
---|
| 1131 | } |
---|
| 1132 | READ_UVLC ( uiCode, "slice_pic_parameter_set_id" ); rpcSlice->setPPSId(uiCode); |
---|
| 1133 | pps = parameterSetManager->getPrefetchedPPS(uiCode); |
---|
| 1134 | //!KS: need to add error handling code here, if PPS is not available |
---|
| 1135 | assert(pps!=0); |
---|
| 1136 | sps = parameterSetManager->getPrefetchedSPS(pps->getSPSId()); |
---|
| 1137 | //!KS: need to add error handling code here, if SPS is not available |
---|
| 1138 | assert(sps!=0); |
---|
| 1139 | rpcSlice->setSPS(sps); |
---|
| 1140 | rpcSlice->setPPS(pps); |
---|
| 1141 | if( pps->getDependentSliceSegmentsEnabledFlag() && ( !firstSliceSegmentInPic )) |
---|
| 1142 | { |
---|
| 1143 | READ_FLAG( uiCode, "dependent_slice_segment_flag" ); rpcSlice->setDependentSliceSegmentFlag(uiCode ? true : false); |
---|
| 1144 | } |
---|
| 1145 | else |
---|
| 1146 | { |
---|
| 1147 | rpcSlice->setDependentSliceSegmentFlag(false); |
---|
| 1148 | } |
---|
| 1149 | Int numCTUs = ((sps->getPicWidthInLumaSamples()+sps->getMaxCUWidth()-1)/sps->getMaxCUWidth())*((sps->getPicHeightInLumaSamples()+sps->getMaxCUHeight()-1)/sps->getMaxCUHeight()); |
---|
| 1150 | Int maxParts = (1<<(sps->getMaxCUDepth()<<1)); |
---|
| 1151 | UInt sliceSegmentAddress = 0; |
---|
| 1152 | Int bitsSliceSegmentAddress = 0; |
---|
| 1153 | while(numCTUs>(1<<bitsSliceSegmentAddress)) |
---|
| 1154 | { |
---|
| 1155 | bitsSliceSegmentAddress++; |
---|
| 1156 | } |
---|
| 1157 | |
---|
| 1158 | if(!firstSliceSegmentInPic) |
---|
| 1159 | { |
---|
| 1160 | READ_CODE( bitsSliceSegmentAddress, sliceSegmentAddress, "slice_segment_address" ); |
---|
| 1161 | } |
---|
| 1162 | //set uiCode to equal slice start address (or dependent slice start address) |
---|
| 1163 | Int startCuAddress = maxParts*sliceSegmentAddress; |
---|
| 1164 | rpcSlice->setSliceSegmentCurStartCUAddr( startCuAddress ); |
---|
| 1165 | rpcSlice->setSliceSegmentCurEndCUAddr(numCTUs*maxParts); |
---|
| 1166 | |
---|
| 1167 | if (rpcSlice->getDependentSliceSegmentFlag()) |
---|
| 1168 | { |
---|
| 1169 | rpcSlice->setNextSlice ( false ); |
---|
| 1170 | rpcSlice->setNextSliceSegment ( true ); |
---|
| 1171 | } |
---|
| 1172 | else |
---|
| 1173 | { |
---|
| 1174 | rpcSlice->setNextSlice ( true ); |
---|
| 1175 | rpcSlice->setNextSliceSegment ( false ); |
---|
| 1176 | |
---|
| 1177 | rpcSlice->setSliceCurStartCUAddr(startCuAddress); |
---|
| 1178 | rpcSlice->setSliceCurEndCUAddr(numCTUs*maxParts); |
---|
| 1179 | } |
---|
[216] | 1180 | |
---|
[191] | 1181 | if(!rpcSlice->getDependentSliceSegmentFlag()) |
---|
| 1182 | { |
---|
[289] | 1183 | |
---|
| 1184 | #if SH_DISCARDABLE_FLAG |
---|
| 1185 | if(rpcSlice->getPPS()->getNumExtraSliceHeaderBits()>0) |
---|
| 1186 | { |
---|
| 1187 | READ_FLAG(uiCode, "discardable_flag"); // ignored |
---|
| 1188 | } |
---|
| 1189 | for (Int i = 1; i < rpcSlice->getPPS()->getNumExtraSliceHeaderBits(); i++) |
---|
| 1190 | { |
---|
| 1191 | READ_FLAG(uiCode, "slice_reserved_undetermined_flag[]"); // ignored |
---|
| 1192 | } |
---|
| 1193 | #else |
---|
[191] | 1194 | for (Int i = 0; i < rpcSlice->getPPS()->getNumExtraSliceHeaderBits(); i++) |
---|
| 1195 | { |
---|
| 1196 | READ_FLAG(uiCode, "slice_reserved_undetermined_flag[]"); // ignored |
---|
| 1197 | } |
---|
[289] | 1198 | #endif |
---|
[191] | 1199 | |
---|
| 1200 | READ_UVLC ( uiCode, "slice_type" ); rpcSlice->setSliceType((SliceType)uiCode); |
---|
| 1201 | if( pps->getOutputFlagPresentFlag() ) |
---|
| 1202 | { |
---|
| 1203 | READ_FLAG( uiCode, "pic_output_flag" ); rpcSlice->setPicOutputFlag( uiCode ? true : false ); |
---|
| 1204 | } |
---|
| 1205 | else |
---|
| 1206 | { |
---|
| 1207 | rpcSlice->setPicOutputFlag( true ); |
---|
| 1208 | } |
---|
| 1209 | // in the first version chroma_format_idc is equal to one, thus colour_plane_id will not be present |
---|
| 1210 | assert (sps->getChromaFormatIdc() == 1 ); |
---|
| 1211 | // if( separate_colour_plane_flag == 1 ) |
---|
| 1212 | // colour_plane_id u(2) |
---|
| 1213 | |
---|
| 1214 | if( rpcSlice->getIdrPicFlag() ) |
---|
| 1215 | { |
---|
| 1216 | rpcSlice->setPOC(0); |
---|
| 1217 | TComReferencePictureSet* rps = rpcSlice->getLocalRPS(); |
---|
| 1218 | rps->setNumberOfNegativePictures(0); |
---|
| 1219 | rps->setNumberOfPositivePictures(0); |
---|
| 1220 | rps->setNumberOfLongtermPictures(0); |
---|
| 1221 | rps->setNumberOfPictures(0); |
---|
| 1222 | rpcSlice->setRPS(rps); |
---|
| 1223 | } |
---|
| 1224 | else |
---|
| 1225 | { |
---|
[216] | 1226 | READ_CODE(sps->getBitsForPOC(), uiCode, "pic_order_cnt_lsb"); |
---|
[191] | 1227 | Int iPOClsb = uiCode; |
---|
| 1228 | Int iPrevPOC = rpcSlice->getPrevPOC(); |
---|
| 1229 | Int iMaxPOClsb = 1<< sps->getBitsForPOC(); |
---|
| 1230 | Int iPrevPOClsb = iPrevPOC%iMaxPOClsb; |
---|
| 1231 | Int iPrevPOCmsb = iPrevPOC-iPrevPOClsb; |
---|
| 1232 | Int iPOCmsb; |
---|
| 1233 | if( ( iPOClsb < iPrevPOClsb ) && ( ( iPrevPOClsb - iPOClsb ) >= ( iMaxPOClsb / 2 ) ) ) |
---|
| 1234 | { |
---|
| 1235 | iPOCmsb = iPrevPOCmsb + iMaxPOClsb; |
---|
| 1236 | } |
---|
[216] | 1237 | else if( (iPOClsb > iPrevPOClsb ) && ( (iPOClsb - iPrevPOClsb ) > ( iMaxPOClsb / 2 ) ) ) |
---|
[191] | 1238 | { |
---|
| 1239 | iPOCmsb = iPrevPOCmsb - iMaxPOClsb; |
---|
| 1240 | } |
---|
| 1241 | else |
---|
| 1242 | { |
---|
| 1243 | iPOCmsb = iPrevPOCmsb; |
---|
| 1244 | } |
---|
| 1245 | if ( rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP |
---|
| 1246 | || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL |
---|
| 1247 | || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP ) |
---|
| 1248 | { |
---|
| 1249 | // For BLA picture types, POCmsb is set to 0. |
---|
| 1250 | iPOCmsb = 0; |
---|
| 1251 | } |
---|
| 1252 | rpcSlice->setPOC (iPOCmsb+iPOClsb); |
---|
| 1253 | |
---|
| 1254 | TComReferencePictureSet* rps; |
---|
| 1255 | rps = rpcSlice->getLocalRPS(); |
---|
| 1256 | rpcSlice->setRPS(rps); |
---|
| 1257 | READ_FLAG( uiCode, "short_term_ref_pic_set_sps_flag" ); |
---|
| 1258 | if(uiCode == 0) // use short-term reference picture set explicitly signalled in slice header |
---|
| 1259 | { |
---|
| 1260 | parseShortTermRefPicSet(sps,rps, sps->getRPSList()->getNumberOfReferencePictureSets()); |
---|
| 1261 | } |
---|
| 1262 | else // use reference to short-term reference picture set in PPS |
---|
| 1263 | { |
---|
| 1264 | Int numBits = 0; |
---|
| 1265 | while ((1 << numBits) < rpcSlice->getSPS()->getRPSList()->getNumberOfReferencePictureSets()) |
---|
| 1266 | { |
---|
| 1267 | numBits++; |
---|
| 1268 | } |
---|
| 1269 | if (numBits > 0) |
---|
| 1270 | { |
---|
| 1271 | READ_CODE( numBits, uiCode, "short_term_ref_pic_set_idx"); |
---|
| 1272 | } |
---|
| 1273 | else |
---|
| 1274 | { |
---|
| 1275 | uiCode = 0; |
---|
| 1276 | } |
---|
[302] | 1277 | *rps = *(sps->getRPSList()->getReferencePictureSet(uiCode)); |
---|
[191] | 1278 | } |
---|
| 1279 | if(sps->getLongTermRefsPresent()) |
---|
| 1280 | { |
---|
| 1281 | Int offset = rps->getNumberOfNegativePictures()+rps->getNumberOfPositivePictures(); |
---|
| 1282 | UInt numOfLtrp = 0; |
---|
| 1283 | UInt numLtrpInSPS = 0; |
---|
| 1284 | if (rpcSlice->getSPS()->getNumLongTermRefPicSPS() > 0) |
---|
| 1285 | { |
---|
| 1286 | READ_UVLC( uiCode, "num_long_term_sps"); |
---|
| 1287 | numLtrpInSPS = uiCode; |
---|
| 1288 | numOfLtrp += numLtrpInSPS; |
---|
| 1289 | rps->setNumberOfLongtermPictures(numOfLtrp); |
---|
| 1290 | } |
---|
| 1291 | Int bitsForLtrpInSPS = 0; |
---|
| 1292 | while (rpcSlice->getSPS()->getNumLongTermRefPicSPS() > (1 << bitsForLtrpInSPS)) |
---|
| 1293 | { |
---|
| 1294 | bitsForLtrpInSPS++; |
---|
| 1295 | } |
---|
| 1296 | READ_UVLC( uiCode, "num_long_term_pics"); rps->setNumberOfLongtermPictures(uiCode); |
---|
| 1297 | numOfLtrp += uiCode; |
---|
| 1298 | rps->setNumberOfLongtermPictures(numOfLtrp); |
---|
| 1299 | Int maxPicOrderCntLSB = 1 << rpcSlice->getSPS()->getBitsForPOC(); |
---|
| 1300 | Int prevDeltaMSB = 0, deltaPocMSBCycleLT = 0;; |
---|
| 1301 | for(Int j=offset+rps->getNumberOfLongtermPictures()-1, k = 0; k < numOfLtrp; j--, k++) |
---|
| 1302 | { |
---|
| 1303 | Int pocLsbLt; |
---|
| 1304 | if (k < numLtrpInSPS) |
---|
| 1305 | { |
---|
| 1306 | uiCode = 0; |
---|
| 1307 | if (bitsForLtrpInSPS > 0) |
---|
| 1308 | { |
---|
| 1309 | READ_CODE(bitsForLtrpInSPS, uiCode, "lt_idx_sps[i]"); |
---|
| 1310 | } |
---|
| 1311 | Int usedByCurrFromSPS=rpcSlice->getSPS()->getUsedByCurrPicLtSPSFlag(uiCode); |
---|
| 1312 | |
---|
| 1313 | pocLsbLt = rpcSlice->getSPS()->getLtRefPicPocLsbSps(uiCode); |
---|
| 1314 | rps->setUsed(j,usedByCurrFromSPS); |
---|
| 1315 | } |
---|
| 1316 | else |
---|
| 1317 | { |
---|
| 1318 | READ_CODE(rpcSlice->getSPS()->getBitsForPOC(), uiCode, "poc_lsb_lt"); pocLsbLt= uiCode; |
---|
| 1319 | READ_FLAG( uiCode, "used_by_curr_pic_lt_flag"); rps->setUsed(j,uiCode); |
---|
| 1320 | } |
---|
| 1321 | READ_FLAG(uiCode,"delta_poc_msb_present_flag"); |
---|
| 1322 | Bool mSBPresentFlag = uiCode ? true : false; |
---|
[216] | 1323 | if(mSBPresentFlag) |
---|
[191] | 1324 | { |
---|
| 1325 | READ_UVLC( uiCode, "delta_poc_msb_cycle_lt[i]" ); |
---|
| 1326 | Bool deltaFlag = false; |
---|
| 1327 | // First LTRP || First LTRP from SH |
---|
| 1328 | if( (j == offset+rps->getNumberOfLongtermPictures()-1) || (j == offset+(numOfLtrp-numLtrpInSPS)-1) ) |
---|
| 1329 | { |
---|
| 1330 | deltaFlag = true; |
---|
| 1331 | } |
---|
| 1332 | if(deltaFlag) |
---|
| 1333 | { |
---|
| 1334 | deltaPocMSBCycleLT = uiCode; |
---|
| 1335 | } |
---|
| 1336 | else |
---|
| 1337 | { |
---|
[216] | 1338 | deltaPocMSBCycleLT = uiCode + prevDeltaMSB; |
---|
[191] | 1339 | } |
---|
| 1340 | |
---|
[216] | 1341 | Int pocLTCurr = rpcSlice->getPOC() - deltaPocMSBCycleLT * maxPicOrderCntLSB |
---|
[191] | 1342 | - iPOClsb + pocLsbLt; |
---|
[216] | 1343 | rps->setPOC (j, pocLTCurr); |
---|
[191] | 1344 | rps->setDeltaPOC(j, - rpcSlice->getPOC() + pocLTCurr); |
---|
[216] | 1345 | rps->setCheckLTMSBPresent(j,true); |
---|
[191] | 1346 | } |
---|
| 1347 | else |
---|
| 1348 | { |
---|
| 1349 | rps->setPOC (j, pocLsbLt); |
---|
| 1350 | rps->setDeltaPOC(j, - rpcSlice->getPOC() + pocLsbLt); |
---|
[216] | 1351 | rps->setCheckLTMSBPresent(j,false); |
---|
[191] | 1352 | } |
---|
| 1353 | prevDeltaMSB = deltaPocMSBCycleLT; |
---|
| 1354 | } |
---|
| 1355 | offset += rps->getNumberOfLongtermPictures(); |
---|
[216] | 1356 | rps->setNumberOfPictures(offset); |
---|
| 1357 | } |
---|
[191] | 1358 | if ( rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP |
---|
| 1359 | || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL |
---|
| 1360 | || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP ) |
---|
| 1361 | { |
---|
| 1362 | // In the case of BLA picture types, rps data is read from slice header but ignored |
---|
| 1363 | rps = rpcSlice->getLocalRPS(); |
---|
| 1364 | rps->setNumberOfNegativePictures(0); |
---|
| 1365 | rps->setNumberOfPositivePictures(0); |
---|
| 1366 | rps->setNumberOfLongtermPictures(0); |
---|
| 1367 | rps->setNumberOfPictures(0); |
---|
| 1368 | rpcSlice->setRPS(rps); |
---|
| 1369 | } |
---|
| 1370 | if (rpcSlice->getSPS()->getTMVPFlagsPresent()) |
---|
| 1371 | { |
---|
| 1372 | READ_FLAG( uiCode, "slice_temporal_mvp_enable_flag" ); |
---|
[216] | 1373 | rpcSlice->setEnableTMVPFlag( uiCode == 1 ? true : false ); |
---|
[191] | 1374 | } |
---|
| 1375 | else |
---|
| 1376 | { |
---|
| 1377 | rpcSlice->setEnableTMVPFlag(false); |
---|
| 1378 | } |
---|
| 1379 | } |
---|
| 1380 | |
---|
| 1381 | #if REF_IDX_FRAMEWORK |
---|
[216] | 1382 | #if JCTVC_M0458_INTERLAYER_RPS_SIG |
---|
[191] | 1383 | rpcSlice->setActiveNumILRRefIdx(0); |
---|
[216] | 1384 | if((sps->getLayerId() > 0) && (rpcSlice->getNumILRRefIdx() > 0) ) |
---|
| 1385 | { |
---|
[191] | 1386 | READ_FLAG(uiCode,"inter_layer_pred_enabled_flag"); |
---|
| 1387 | rpcSlice->setInterLayerPredEnabledFlag(uiCode); |
---|
| 1388 | if( rpcSlice->getInterLayerPredEnabledFlag()) |
---|
| 1389 | { |
---|
[216] | 1390 | if(rpcSlice->getNumILRRefIdx() > 1) |
---|
[191] | 1391 | { |
---|
| 1392 | Int numBits = 1; |
---|
| 1393 | while ((1 << numBits) < rpcSlice->getNumILRRefIdx()) |
---|
| 1394 | { |
---|
| 1395 | numBits++; |
---|
| 1396 | } |
---|
[216] | 1397 | if( !rpcSlice->getVPS()->getMaxOneActiveRefLayerFlag()) |
---|
[191] | 1398 | { |
---|
| 1399 | READ_CODE( numBits, uiCode,"num_inter_layer_ref_pics_minus1" ); |
---|
[216] | 1400 | rpcSlice->setActiveNumILRRefIdx(uiCode + 1); |
---|
[191] | 1401 | } |
---|
| 1402 | else |
---|
| 1403 | { |
---|
[216] | 1404 | rpcSlice->setActiveNumILRRefIdx(1); |
---|
[191] | 1405 | } |
---|
[216] | 1406 | for(Int i = 0; i < rpcSlice->getActiveNumILRRefIdx(); i++ ) |
---|
[191] | 1407 | { |
---|
[216] | 1408 | READ_CODE( numBits,uiCode,"inter_layer_pred_layer_idc[i]" ); |
---|
| 1409 | rpcSlice->setInterLayerPredLayerIdc(uiCode,i); |
---|
[191] | 1410 | } |
---|
| 1411 | } |
---|
| 1412 | else |
---|
| 1413 | { |
---|
[216] | 1414 | rpcSlice->setActiveNumILRRefIdx(1); |
---|
| 1415 | rpcSlice->setInterLayerPredLayerIdc(0,0); |
---|
[191] | 1416 | } |
---|
| 1417 | } |
---|
| 1418 | } |
---|
[297] | 1419 | #if M0457_IL_SAMPLE_PRED_ONLY_FLAG |
---|
| 1420 | rpcSlice->setInterLayerSamplePredOnlyFlag( false ); |
---|
| 1421 | if( rpcSlice->getNumSamplePredRefLayers() > 0 && rpcSlice->getActiveNumILRRefIdx() > 0 ) |
---|
| 1422 | { |
---|
| 1423 | READ_FLAG( uiCode, "inter_layer_sample_pred_only_flag" ); |
---|
| 1424 | rpcSlice->setInterLayerSamplePredOnlyFlag( uiCode > 0 ); |
---|
| 1425 | } |
---|
| 1426 | #endif |
---|
[191] | 1427 | #else |
---|
| 1428 | if( rpcSlice->getLayerId() > 0 ) |
---|
| 1429 | { |
---|
| 1430 | rpcSlice->setNumILRRefIdx( rpcSlice->getVPS()->getNumDirectRefLayers( rpcSlice->getLayerId() ) ); |
---|
| 1431 | } |
---|
| 1432 | #endif |
---|
| 1433 | #endif |
---|
| 1434 | |
---|
| 1435 | if(sps->getUseSAO()) |
---|
| 1436 | { |
---|
| 1437 | READ_FLAG(uiCode, "slice_sao_luma_flag"); rpcSlice->setSaoEnabledFlag((Bool)uiCode); |
---|
| 1438 | READ_FLAG(uiCode, "slice_sao_chroma_flag"); rpcSlice->setSaoEnabledFlagChroma((Bool)uiCode); |
---|
| 1439 | } |
---|
| 1440 | |
---|
| 1441 | if (rpcSlice->getIdrPicFlag()) |
---|
| 1442 | { |
---|
| 1443 | rpcSlice->setEnableTMVPFlag(false); |
---|
| 1444 | } |
---|
| 1445 | if (!rpcSlice->isIntra()) |
---|
| 1446 | { |
---|
| 1447 | |
---|
| 1448 | READ_FLAG( uiCode, "num_ref_idx_active_override_flag"); |
---|
| 1449 | if (uiCode) |
---|
| 1450 | { |
---|
| 1451 | READ_UVLC (uiCode, "num_ref_idx_l0_active_minus1" ); rpcSlice->setNumRefIdx( REF_PIC_LIST_0, uiCode + 1 ); |
---|
| 1452 | if (rpcSlice->isInterB()) |
---|
| 1453 | { |
---|
| 1454 | READ_UVLC (uiCode, "num_ref_idx_l1_active_minus1" ); rpcSlice->setNumRefIdx( REF_PIC_LIST_1, uiCode + 1 ); |
---|
| 1455 | } |
---|
| 1456 | else |
---|
| 1457 | { |
---|
| 1458 | rpcSlice->setNumRefIdx(REF_PIC_LIST_1, 0); |
---|
| 1459 | } |
---|
| 1460 | } |
---|
| 1461 | else |
---|
| 1462 | { |
---|
| 1463 | rpcSlice->setNumRefIdx(REF_PIC_LIST_0, rpcSlice->getPPS()->getNumRefIdxL0DefaultActive()); |
---|
| 1464 | if (rpcSlice->isInterB()) |
---|
| 1465 | { |
---|
| 1466 | rpcSlice->setNumRefIdx(REF_PIC_LIST_1, rpcSlice->getPPS()->getNumRefIdxL1DefaultActive()); |
---|
| 1467 | } |
---|
| 1468 | else |
---|
| 1469 | { |
---|
| 1470 | rpcSlice->setNumRefIdx(REF_PIC_LIST_1,0); |
---|
| 1471 | } |
---|
| 1472 | } |
---|
| 1473 | } |
---|
| 1474 | // } |
---|
| 1475 | TComRefPicListModification* refPicListModification = rpcSlice->getRefPicListModification(); |
---|
| 1476 | if(!rpcSlice->isIntra()) |
---|
| 1477 | { |
---|
| 1478 | if( !rpcSlice->getPPS()->getListsModificationPresentFlag() || rpcSlice->getNumRpsCurrTempList() <= 1 ) |
---|
| 1479 | { |
---|
| 1480 | refPicListModification->setRefPicListModificationFlagL0( 0 ); |
---|
| 1481 | } |
---|
| 1482 | else |
---|
| 1483 | { |
---|
| 1484 | READ_FLAG( uiCode, "ref_pic_list_modification_flag_l0" ); refPicListModification->setRefPicListModificationFlagL0( uiCode ? 1 : 0 ); |
---|
| 1485 | } |
---|
| 1486 | |
---|
| 1487 | if(refPicListModification->getRefPicListModificationFlagL0()) |
---|
| 1488 | { |
---|
| 1489 | uiCode = 0; |
---|
| 1490 | Int i = 0; |
---|
| 1491 | Int numRpsCurrTempList0 = rpcSlice->getNumRpsCurrTempList(); |
---|
| 1492 | if ( numRpsCurrTempList0 > 1 ) |
---|
| 1493 | { |
---|
| 1494 | Int length = 1; |
---|
| 1495 | numRpsCurrTempList0 --; |
---|
[216] | 1496 | while ( numRpsCurrTempList0 >>= 1) |
---|
[191] | 1497 | { |
---|
| 1498 | length ++; |
---|
| 1499 | } |
---|
| 1500 | for (i = 0; i < rpcSlice->getNumRefIdx(REF_PIC_LIST_0); i ++) |
---|
| 1501 | { |
---|
| 1502 | READ_CODE( length, uiCode, "list_entry_l0" ); |
---|
| 1503 | refPicListModification->setRefPicSetIdxL0(i, uiCode ); |
---|
| 1504 | } |
---|
| 1505 | } |
---|
| 1506 | else |
---|
| 1507 | { |
---|
| 1508 | for (i = 0; i < rpcSlice->getNumRefIdx(REF_PIC_LIST_0); i ++) |
---|
| 1509 | { |
---|
| 1510 | refPicListModification->setRefPicSetIdxL0(i, 0 ); |
---|
| 1511 | } |
---|
| 1512 | } |
---|
| 1513 | } |
---|
| 1514 | } |
---|
| 1515 | else |
---|
| 1516 | { |
---|
| 1517 | refPicListModification->setRefPicListModificationFlagL0(0); |
---|
| 1518 | } |
---|
| 1519 | if(rpcSlice->isInterB()) |
---|
| 1520 | { |
---|
| 1521 | if( !rpcSlice->getPPS()->getListsModificationPresentFlag() || rpcSlice->getNumRpsCurrTempList() <= 1 ) |
---|
| 1522 | { |
---|
| 1523 | refPicListModification->setRefPicListModificationFlagL1( 0 ); |
---|
| 1524 | } |
---|
| 1525 | else |
---|
| 1526 | { |
---|
| 1527 | READ_FLAG( uiCode, "ref_pic_list_modification_flag_l1" ); refPicListModification->setRefPicListModificationFlagL1( uiCode ? 1 : 0 ); |
---|
| 1528 | } |
---|
| 1529 | if(refPicListModification->getRefPicListModificationFlagL1()) |
---|
| 1530 | { |
---|
| 1531 | uiCode = 0; |
---|
| 1532 | Int i = 0; |
---|
| 1533 | Int numRpsCurrTempList1 = rpcSlice->getNumRpsCurrTempList(); |
---|
| 1534 | if ( numRpsCurrTempList1 > 1 ) |
---|
| 1535 | { |
---|
| 1536 | Int length = 1; |
---|
| 1537 | numRpsCurrTempList1 --; |
---|
[216] | 1538 | while ( numRpsCurrTempList1 >>= 1) |
---|
[191] | 1539 | { |
---|
| 1540 | length ++; |
---|
| 1541 | } |
---|
| 1542 | for (i = 0; i < rpcSlice->getNumRefIdx(REF_PIC_LIST_1); i ++) |
---|
| 1543 | { |
---|
| 1544 | READ_CODE( length, uiCode, "list_entry_l1" ); |
---|
| 1545 | refPicListModification->setRefPicSetIdxL1(i, uiCode ); |
---|
| 1546 | } |
---|
| 1547 | } |
---|
| 1548 | else |
---|
| 1549 | { |
---|
| 1550 | for (i = 0; i < rpcSlice->getNumRefIdx(REF_PIC_LIST_1); i ++) |
---|
| 1551 | { |
---|
| 1552 | refPicListModification->setRefPicSetIdxL1(i, 0 ); |
---|
| 1553 | } |
---|
| 1554 | } |
---|
| 1555 | } |
---|
[216] | 1556 | } |
---|
[191] | 1557 | else |
---|
| 1558 | { |
---|
| 1559 | refPicListModification->setRefPicListModificationFlagL1(0); |
---|
| 1560 | } |
---|
| 1561 | if (rpcSlice->isInterB()) |
---|
| 1562 | { |
---|
| 1563 | READ_FLAG( uiCode, "mvd_l1_zero_flag" ); rpcSlice->setMvdL1ZeroFlag( (uiCode ? true : false) ); |
---|
| 1564 | } |
---|
| 1565 | |
---|
| 1566 | rpcSlice->setCabacInitFlag( false ); // default |
---|
| 1567 | if(pps->getCabacInitPresentFlag() && !rpcSlice->isIntra()) |
---|
| 1568 | { |
---|
| 1569 | READ_FLAG(uiCode, "cabac_init_flag"); |
---|
| 1570 | rpcSlice->setCabacInitFlag( uiCode ? true : false ); |
---|
| 1571 | } |
---|
| 1572 | |
---|
| 1573 | if ( rpcSlice->getEnableTMVPFlag() ) |
---|
| 1574 | { |
---|
[291] | 1575 | #if REF_IDX_FRAMEWORK && M0457_COL_PICTURE_SIGNALING |
---|
| 1576 | rpcSlice->setMFMEnabledFlag( false ); |
---|
| 1577 | rpcSlice->setColRefLayerIdx( 0 ); |
---|
| 1578 | rpcSlice->setAltColIndicationFlag( false ); |
---|
[296] | 1579 | if ( sps->getLayerId() > 0 && rpcSlice->getActiveNumILRRefIdx() > 0 && rpcSlice->getNumMotionPredRefLayers() > 0 ) |
---|
[291] | 1580 | { |
---|
| 1581 | READ_FLAG( uiCode, "alt_collocated_indication_flag" ); |
---|
| 1582 | rpcSlice->setAltColIndicationFlag( uiCode == 1 ? true : false ); |
---|
| 1583 | rpcSlice->setMFMEnabledFlag( uiCode == 1 ? true : false ); |
---|
| 1584 | if ( rpcSlice->getNumMotionPredRefLayers() > 1 ) |
---|
| 1585 | { |
---|
| 1586 | READ_UVLC( uiCode, "collocated_ref_layer_idx" ); |
---|
| 1587 | rpcSlice->setColRefLayerIdx( uiCode ); |
---|
| 1588 | } |
---|
| 1589 | } |
---|
| 1590 | else |
---|
| 1591 | { |
---|
| 1592 | #endif |
---|
[191] | 1593 | if ( rpcSlice->getSliceType() == B_SLICE ) |
---|
| 1594 | { |
---|
| 1595 | READ_FLAG( uiCode, "collocated_from_l0_flag" ); |
---|
| 1596 | rpcSlice->setColFromL0Flag(uiCode); |
---|
| 1597 | } |
---|
| 1598 | else |
---|
| 1599 | { |
---|
| 1600 | rpcSlice->setColFromL0Flag( 1 ); |
---|
| 1601 | } |
---|
| 1602 | |
---|
| 1603 | if ( rpcSlice->getSliceType() != I_SLICE && |
---|
| 1604 | ((rpcSlice->getColFromL0Flag() == 1 && rpcSlice->getNumRefIdx(REF_PIC_LIST_0) > 1)|| |
---|
| 1605 | (rpcSlice->getColFromL0Flag() == 0 && rpcSlice->getNumRefIdx(REF_PIC_LIST_1) > 1))) |
---|
| 1606 | { |
---|
| 1607 | READ_UVLC( uiCode, "collocated_ref_idx" ); |
---|
| 1608 | rpcSlice->setColRefIdx(uiCode); |
---|
| 1609 | } |
---|
| 1610 | else |
---|
| 1611 | { |
---|
| 1612 | rpcSlice->setColRefIdx(0); |
---|
| 1613 | } |
---|
[291] | 1614 | #if REF_IDX_FRAMEWORK && M0457_COL_PICTURE_SIGNALING |
---|
| 1615 | } |
---|
| 1616 | #endif |
---|
[191] | 1617 | } |
---|
| 1618 | if ( (pps->getUseWP() && rpcSlice->getSliceType()==P_SLICE) || (pps->getWPBiPred() && rpcSlice->getSliceType()==B_SLICE) ) |
---|
| 1619 | { |
---|
| 1620 | xParsePredWeightTable(rpcSlice); |
---|
| 1621 | rpcSlice->initWpScaling(); |
---|
| 1622 | } |
---|
| 1623 | if (!rpcSlice->isIntra()) |
---|
| 1624 | { |
---|
| 1625 | READ_UVLC( uiCode, "five_minus_max_num_merge_cand"); |
---|
| 1626 | rpcSlice->setMaxNumMergeCand(MRG_MAX_NUM_CANDS - uiCode); |
---|
| 1627 | } |
---|
| 1628 | |
---|
| 1629 | READ_SVLC( iCode, "slice_qp_delta" ); |
---|
| 1630 | rpcSlice->setSliceQp (26 + pps->getPicInitQPMinus26() + iCode); |
---|
| 1631 | |
---|
| 1632 | assert( rpcSlice->getSliceQp() >= -sps->getQpBDOffsetY() ); |
---|
| 1633 | assert( rpcSlice->getSliceQp() <= 51 ); |
---|
| 1634 | |
---|
| 1635 | if (rpcSlice->getPPS()->getSliceChromaQpFlag()) |
---|
| 1636 | { |
---|
| 1637 | READ_SVLC( iCode, "slice_qp_delta_cb" ); |
---|
| 1638 | rpcSlice->setSliceQpDeltaCb( iCode ); |
---|
| 1639 | assert( rpcSlice->getSliceQpDeltaCb() >= -12 ); |
---|
| 1640 | assert( rpcSlice->getSliceQpDeltaCb() <= 12 ); |
---|
| 1641 | assert( (rpcSlice->getPPS()->getChromaCbQpOffset() + rpcSlice->getSliceQpDeltaCb()) >= -12 ); |
---|
| 1642 | assert( (rpcSlice->getPPS()->getChromaCbQpOffset() + rpcSlice->getSliceQpDeltaCb()) <= 12 ); |
---|
| 1643 | |
---|
| 1644 | READ_SVLC( iCode, "slice_qp_delta_cr" ); |
---|
| 1645 | rpcSlice->setSliceQpDeltaCr( iCode ); |
---|
| 1646 | assert( rpcSlice->getSliceQpDeltaCr() >= -12 ); |
---|
| 1647 | assert( rpcSlice->getSliceQpDeltaCr() <= 12 ); |
---|
| 1648 | assert( (rpcSlice->getPPS()->getChromaCrQpOffset() + rpcSlice->getSliceQpDeltaCr()) >= -12 ); |
---|
| 1649 | assert( (rpcSlice->getPPS()->getChromaCrQpOffset() + rpcSlice->getSliceQpDeltaCr()) <= 12 ); |
---|
| 1650 | } |
---|
| 1651 | |
---|
| 1652 | if (rpcSlice->getPPS()->getDeblockingFilterControlPresentFlag()) |
---|
| 1653 | { |
---|
| 1654 | if(rpcSlice->getPPS()->getDeblockingFilterOverrideEnabledFlag()) |
---|
| 1655 | { |
---|
| 1656 | READ_FLAG ( uiCode, "deblocking_filter_override_flag" ); rpcSlice->setDeblockingFilterOverrideFlag(uiCode ? true : false); |
---|
| 1657 | } |
---|
| 1658 | else |
---|
[216] | 1659 | { |
---|
[191] | 1660 | rpcSlice->setDeblockingFilterOverrideFlag(0); |
---|
| 1661 | } |
---|
| 1662 | if(rpcSlice->getDeblockingFilterOverrideFlag()) |
---|
| 1663 | { |
---|
| 1664 | READ_FLAG ( uiCode, "slice_disable_deblocking_filter_flag" ); rpcSlice->setDeblockingFilterDisable(uiCode ? 1 : 0); |
---|
| 1665 | if(!rpcSlice->getDeblockingFilterDisable()) |
---|
| 1666 | { |
---|
| 1667 | READ_SVLC( iCode, "slice_beta_offset_div2" ); rpcSlice->setDeblockingFilterBetaOffsetDiv2(iCode); |
---|
| 1668 | assert(rpcSlice->getDeblockingFilterBetaOffsetDiv2() >= -6 && |
---|
| 1669 | rpcSlice->getDeblockingFilterBetaOffsetDiv2() <= 6); |
---|
| 1670 | READ_SVLC( iCode, "slice_tc_offset_div2" ); rpcSlice->setDeblockingFilterTcOffsetDiv2(iCode); |
---|
| 1671 | assert(rpcSlice->getDeblockingFilterTcOffsetDiv2() >= -6 && |
---|
| 1672 | rpcSlice->getDeblockingFilterTcOffsetDiv2() <= 6); |
---|
| 1673 | } |
---|
| 1674 | } |
---|
| 1675 | else |
---|
| 1676 | { |
---|
| 1677 | rpcSlice->setDeblockingFilterDisable ( rpcSlice->getPPS()->getPicDisableDeblockingFilterFlag() ); |
---|
| 1678 | rpcSlice->setDeblockingFilterBetaOffsetDiv2( rpcSlice->getPPS()->getDeblockingFilterBetaOffsetDiv2() ); |
---|
| 1679 | rpcSlice->setDeblockingFilterTcOffsetDiv2 ( rpcSlice->getPPS()->getDeblockingFilterTcOffsetDiv2() ); |
---|
| 1680 | } |
---|
| 1681 | } |
---|
| 1682 | else |
---|
[216] | 1683 | { |
---|
[191] | 1684 | rpcSlice->setDeblockingFilterDisable ( false ); |
---|
| 1685 | rpcSlice->setDeblockingFilterBetaOffsetDiv2( 0 ); |
---|
| 1686 | rpcSlice->setDeblockingFilterTcOffsetDiv2 ( 0 ); |
---|
| 1687 | } |
---|
| 1688 | |
---|
| 1689 | Bool isSAOEnabled = (!rpcSlice->getSPS()->getUseSAO())?(false):(rpcSlice->getSaoEnabledFlag()||rpcSlice->getSaoEnabledFlagChroma()); |
---|
| 1690 | Bool isDBFEnabled = (!rpcSlice->getDeblockingFilterDisable()); |
---|
| 1691 | |
---|
| 1692 | if(rpcSlice->getPPS()->getLoopFilterAcrossSlicesEnabledFlag() && ( isSAOEnabled || isDBFEnabled )) |
---|
| 1693 | { |
---|
| 1694 | READ_FLAG( uiCode, "slice_loop_filter_across_slices_enabled_flag"); |
---|
| 1695 | } |
---|
| 1696 | else |
---|
| 1697 | { |
---|
| 1698 | uiCode = rpcSlice->getPPS()->getLoopFilterAcrossSlicesEnabledFlag()?1:0; |
---|
| 1699 | } |
---|
| 1700 | rpcSlice->setLFCrossSliceBoundaryFlag( (uiCode==1)?true:false); |
---|
| 1701 | |
---|
| 1702 | } |
---|
[216] | 1703 | |
---|
[191] | 1704 | UInt *entryPointOffset = NULL; |
---|
| 1705 | UInt numEntryPointOffsets, offsetLenMinus1; |
---|
| 1706 | if( pps->getTilesEnabledFlag() || pps->getEntropyCodingSyncEnabledFlag() ) |
---|
| 1707 | { |
---|
| 1708 | READ_UVLC(numEntryPointOffsets, "num_entry_point_offsets"); rpcSlice->setNumEntryPointOffsets ( numEntryPointOffsets ); |
---|
| 1709 | if (numEntryPointOffsets>0) |
---|
| 1710 | { |
---|
| 1711 | READ_UVLC(offsetLenMinus1, "offset_len_minus1"); |
---|
| 1712 | } |
---|
| 1713 | entryPointOffset = new UInt[numEntryPointOffsets]; |
---|
| 1714 | for (UInt idx=0; idx<numEntryPointOffsets; idx++) |
---|
| 1715 | { |
---|
| 1716 | READ_CODE(offsetLenMinus1+1, uiCode, "entry_point_offset_minus1"); |
---|
| 1717 | entryPointOffset[ idx ] = uiCode + 1; |
---|
| 1718 | } |
---|
| 1719 | } |
---|
| 1720 | else |
---|
| 1721 | { |
---|
| 1722 | rpcSlice->setNumEntryPointOffsets ( 0 ); |
---|
| 1723 | } |
---|
| 1724 | |
---|
| 1725 | if(pps->getSliceHeaderExtensionPresentFlag()) |
---|
| 1726 | { |
---|
| 1727 | READ_UVLC(uiCode,"slice_header_extension_length"); |
---|
| 1728 | for(Int i=0; i<uiCode; i++) |
---|
| 1729 | { |
---|
| 1730 | UInt ignore; |
---|
| 1731 | READ_CODE(8,ignore,"slice_header_extension_data_byte"); |
---|
| 1732 | } |
---|
| 1733 | } |
---|
| 1734 | m_pcBitstream->readByteAlignment(); |
---|
| 1735 | |
---|
| 1736 | if( pps->getTilesEnabledFlag() || pps->getEntropyCodingSyncEnabledFlag() ) |
---|
| 1737 | { |
---|
| 1738 | Int endOfSliceHeaderLocation = m_pcBitstream->getByteLocation(); |
---|
[302] | 1739 | |
---|
| 1740 | // Adjust endOfSliceHeaderLocation to account for emulation prevention bytes in the slice segment header |
---|
| 1741 | for ( UInt curByteIdx = 0; curByteIdx<m_pcBitstream->numEmulationPreventionBytesRead(); curByteIdx++ ) |
---|
| 1742 | { |
---|
| 1743 | if ( m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) < endOfSliceHeaderLocation ) |
---|
| 1744 | { |
---|
| 1745 | endOfSliceHeaderLocation++; |
---|
| 1746 | } |
---|
| 1747 | } |
---|
| 1748 | |
---|
[191] | 1749 | Int curEntryPointOffset = 0; |
---|
| 1750 | Int prevEntryPointOffset = 0; |
---|
| 1751 | for (UInt idx=0; idx<numEntryPointOffsets; idx++) |
---|
| 1752 | { |
---|
| 1753 | curEntryPointOffset += entryPointOffset[ idx ]; |
---|
| 1754 | |
---|
| 1755 | Int emulationPreventionByteCount = 0; |
---|
| 1756 | for ( UInt curByteIdx = 0; curByteIdx<m_pcBitstream->numEmulationPreventionBytesRead(); curByteIdx++ ) |
---|
| 1757 | { |
---|
[216] | 1758 | if ( m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) >= ( prevEntryPointOffset + endOfSliceHeaderLocation ) && |
---|
[191] | 1759 | m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) < ( curEntryPointOffset + endOfSliceHeaderLocation ) ) |
---|
| 1760 | { |
---|
| 1761 | emulationPreventionByteCount++; |
---|
| 1762 | } |
---|
| 1763 | } |
---|
| 1764 | |
---|
| 1765 | entryPointOffset[ idx ] -= emulationPreventionByteCount; |
---|
| 1766 | prevEntryPointOffset = curEntryPointOffset; |
---|
| 1767 | } |
---|
| 1768 | |
---|
| 1769 | if ( pps->getTilesEnabledFlag() ) |
---|
| 1770 | { |
---|
| 1771 | rpcSlice->setTileLocationCount( numEntryPointOffsets ); |
---|
| 1772 | |
---|
| 1773 | UInt prevPos = 0; |
---|
| 1774 | for (Int idx=0; idx<rpcSlice->getTileLocationCount(); idx++) |
---|
| 1775 | { |
---|
| 1776 | rpcSlice->setTileLocation( idx, prevPos + entryPointOffset [ idx ] ); |
---|
| 1777 | prevPos += entryPointOffset[ idx ]; |
---|
| 1778 | } |
---|
| 1779 | } |
---|
| 1780 | else if ( pps->getEntropyCodingSyncEnabledFlag() ) |
---|
| 1781 | { |
---|
| 1782 | Int numSubstreams = rpcSlice->getNumEntryPointOffsets()+1; |
---|
| 1783 | rpcSlice->allocSubstreamSizes(numSubstreams); |
---|
| 1784 | UInt *pSubstreamSizes = rpcSlice->getSubstreamSizes(); |
---|
| 1785 | for (Int idx=0; idx<numSubstreams-1; idx++) |
---|
| 1786 | { |
---|
| 1787 | if ( idx < numEntryPointOffsets ) |
---|
| 1788 | { |
---|
| 1789 | pSubstreamSizes[ idx ] = ( entryPointOffset[ idx ] << 3 ) ; |
---|
| 1790 | } |
---|
| 1791 | else |
---|
| 1792 | { |
---|
| 1793 | pSubstreamSizes[ idx ] = 0; |
---|
| 1794 | } |
---|
| 1795 | } |
---|
| 1796 | } |
---|
| 1797 | |
---|
| 1798 | if (entryPointOffset) |
---|
| 1799 | { |
---|
| 1800 | delete [] entryPointOffset; |
---|
| 1801 | } |
---|
| 1802 | } |
---|
| 1803 | |
---|
| 1804 | return; |
---|
| 1805 | } |
---|
[216] | 1806 | |
---|
[191] | 1807 | Void TDecCavlc::parsePTL( TComPTL *rpcPTL, Bool profilePresentFlag, Int maxNumSubLayersMinus1 ) |
---|
| 1808 | { |
---|
| 1809 | UInt uiCode; |
---|
| 1810 | if(profilePresentFlag) |
---|
| 1811 | { |
---|
| 1812 | parseProfileTier(rpcPTL->getGeneralPTL()); |
---|
| 1813 | } |
---|
| 1814 | READ_CODE( 8, uiCode, "general_level_idc" ); rpcPTL->getGeneralPTL()->setLevelIdc(uiCode); |
---|
| 1815 | |
---|
| 1816 | for (Int i = 0; i < maxNumSubLayersMinus1; i++) |
---|
| 1817 | { |
---|
| 1818 | if(profilePresentFlag) |
---|
| 1819 | { |
---|
| 1820 | READ_FLAG( uiCode, "sub_layer_profile_present_flag[i]" ); rpcPTL->setSubLayerProfilePresentFlag(i, uiCode); |
---|
| 1821 | } |
---|
| 1822 | READ_FLAG( uiCode, "sub_layer_level_present_flag[i]" ); rpcPTL->setSubLayerLevelPresentFlag (i, uiCode); |
---|
| 1823 | } |
---|
[216] | 1824 | |
---|
[191] | 1825 | if (maxNumSubLayersMinus1 > 0) |
---|
| 1826 | { |
---|
| 1827 | for (Int i = maxNumSubLayersMinus1; i < 8; i++) |
---|
| 1828 | { |
---|
| 1829 | READ_CODE(2, uiCode, "reserved_zero_2bits"); |
---|
| 1830 | assert(uiCode == 0); |
---|
| 1831 | } |
---|
| 1832 | } |
---|
[216] | 1833 | |
---|
[191] | 1834 | for(Int i = 0; i < maxNumSubLayersMinus1; i++) |
---|
| 1835 | { |
---|
| 1836 | if( profilePresentFlag && rpcPTL->getSubLayerProfilePresentFlag(i) ) |
---|
| 1837 | { |
---|
| 1838 | parseProfileTier(rpcPTL->getSubLayerPTL(i)); |
---|
| 1839 | } |
---|
| 1840 | if(rpcPTL->getSubLayerLevelPresentFlag(i)) |
---|
| 1841 | { |
---|
| 1842 | READ_CODE( 8, uiCode, "sub_layer_level_idc[i]" ); rpcPTL->getSubLayerPTL(i)->setLevelIdc(uiCode); |
---|
| 1843 | } |
---|
| 1844 | } |
---|
| 1845 | } |
---|
| 1846 | |
---|
| 1847 | Void TDecCavlc::parseProfileTier(ProfileTierLevel *ptl) |
---|
| 1848 | { |
---|
| 1849 | UInt uiCode; |
---|
| 1850 | READ_CODE(2 , uiCode, "XXX_profile_space[]"); ptl->setProfileSpace(uiCode); |
---|
| 1851 | READ_FLAG( uiCode, "XXX_tier_flag[]" ); ptl->setTierFlag (uiCode ? 1 : 0); |
---|
| 1852 | READ_CODE(5 , uiCode, "XXX_profile_idc[]" ); ptl->setProfileIdc (uiCode); |
---|
| 1853 | for(Int j = 0; j < 32; j++) |
---|
| 1854 | { |
---|
| 1855 | READ_FLAG( uiCode, "XXX_profile_compatibility_flag[][j]"); ptl->setProfileCompatibilityFlag(j, uiCode ? 1 : 0); |
---|
| 1856 | } |
---|
| 1857 | READ_FLAG(uiCode, "general_progressive_source_flag"); |
---|
| 1858 | ptl->setProgressiveSourceFlag(uiCode ? true : false); |
---|
| 1859 | |
---|
| 1860 | READ_FLAG(uiCode, "general_interlaced_source_flag"); |
---|
| 1861 | ptl->setInterlacedSourceFlag(uiCode ? true : false); |
---|
[216] | 1862 | |
---|
[191] | 1863 | READ_FLAG(uiCode, "general_non_packed_constraint_flag"); |
---|
| 1864 | ptl->setNonPackedConstraintFlag(uiCode ? true : false); |
---|
[216] | 1865 | |
---|
[191] | 1866 | READ_FLAG(uiCode, "general_frame_only_constraint_flag"); |
---|
| 1867 | ptl->setFrameOnlyConstraintFlag(uiCode ? true : false); |
---|
[216] | 1868 | |
---|
[191] | 1869 | READ_CODE(16, uiCode, "XXX_reserved_zero_44bits[0..15]"); |
---|
| 1870 | READ_CODE(16, uiCode, "XXX_reserved_zero_44bits[16..31]"); |
---|
| 1871 | READ_CODE(12, uiCode, "XXX_reserved_zero_44bits[32..43]"); |
---|
| 1872 | } |
---|
[302] | 1873 | |
---|
[191] | 1874 | Void TDecCavlc::parseTerminatingBit( UInt& ruiBit ) |
---|
| 1875 | { |
---|
| 1876 | ruiBit = false; |
---|
| 1877 | Int iBitsLeft = m_pcBitstream->getNumBitsLeft(); |
---|
| 1878 | if(iBitsLeft <= 8) |
---|
| 1879 | { |
---|
| 1880 | UInt uiPeekValue = m_pcBitstream->peekBits(iBitsLeft); |
---|
| 1881 | if (uiPeekValue == (1<<(iBitsLeft-1))) |
---|
| 1882 | { |
---|
| 1883 | ruiBit = true; |
---|
| 1884 | } |
---|
| 1885 | } |
---|
| 1886 | } |
---|
| 1887 | |
---|
| 1888 | Void TDecCavlc::parseSkipFlag( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
| 1889 | { |
---|
| 1890 | assert(0); |
---|
| 1891 | } |
---|
| 1892 | |
---|
| 1893 | Void TDecCavlc::parseCUTransquantBypassFlag( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
| 1894 | { |
---|
| 1895 | assert(0); |
---|
| 1896 | } |
---|
| 1897 | |
---|
| 1898 | Void TDecCavlc::parseMVPIdx( Int& /*riMVPIdx*/ ) |
---|
| 1899 | { |
---|
| 1900 | assert(0); |
---|
| 1901 | } |
---|
| 1902 | |
---|
| 1903 | Void TDecCavlc::parseSplitFlag ( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
| 1904 | { |
---|
| 1905 | assert(0); |
---|
| 1906 | } |
---|
| 1907 | |
---|
| 1908 | Void TDecCavlc::parsePartSize( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
| 1909 | { |
---|
| 1910 | assert(0); |
---|
| 1911 | } |
---|
| 1912 | |
---|
| 1913 | Void TDecCavlc::parsePredMode( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
| 1914 | { |
---|
| 1915 | assert(0); |
---|
| 1916 | } |
---|
| 1917 | |
---|
[216] | 1918 | /** Parse I_PCM information. |
---|
[191] | 1919 | * \param pcCU pointer to CU |
---|
| 1920 | * \param uiAbsPartIdx CU index |
---|
| 1921 | * \param uiDepth CU depth |
---|
| 1922 | * \returns Void |
---|
| 1923 | * |
---|
[216] | 1924 | * If I_PCM flag indicates that the CU is I_PCM, parse its PCM alignment bits and codes. |
---|
[191] | 1925 | */ |
---|
| 1926 | Void TDecCavlc::parseIPCMInfo( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
| 1927 | { |
---|
| 1928 | assert(0); |
---|
| 1929 | } |
---|
| 1930 | |
---|
| 1931 | Void TDecCavlc::parseIntraDirLumaAng ( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
[216] | 1932 | { |
---|
[191] | 1933 | assert(0); |
---|
| 1934 | } |
---|
| 1935 | |
---|
| 1936 | Void TDecCavlc::parseIntraDirChroma( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
| 1937 | { |
---|
| 1938 | assert(0); |
---|
| 1939 | } |
---|
| 1940 | |
---|
| 1941 | Void TDecCavlc::parseInterDir( TComDataCU* /*pcCU*/, UInt& /*ruiInterDir*/, UInt /*uiAbsPartIdx*/ ) |
---|
| 1942 | { |
---|
| 1943 | assert(0); |
---|
| 1944 | } |
---|
| 1945 | |
---|
| 1946 | Void TDecCavlc::parseRefFrmIdx( TComDataCU* /*pcCU*/, Int& /*riRefFrmIdx*/, RefPicList /*eRefList*/ ) |
---|
| 1947 | { |
---|
| 1948 | assert(0); |
---|
| 1949 | } |
---|
| 1950 | |
---|
| 1951 | Void TDecCavlc::parseMvd( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiPartIdx*/, UInt /*uiDepth*/, RefPicList /*eRefList*/ ) |
---|
| 1952 | { |
---|
| 1953 | assert(0); |
---|
| 1954 | } |
---|
| 1955 | |
---|
| 1956 | Void TDecCavlc::parseDeltaQP( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 1957 | { |
---|
| 1958 | Int qp; |
---|
| 1959 | Int iDQp; |
---|
| 1960 | |
---|
| 1961 | xReadSvlc( iDQp ); |
---|
| 1962 | |
---|
| 1963 | Int qpBdOffsetY = pcCU->getSlice()->getSPS()->getQpBDOffsetY(); |
---|
| 1964 | qp = (((Int) pcCU->getRefQP( uiAbsPartIdx ) + iDQp + 52 + 2*qpBdOffsetY )%(52+ qpBdOffsetY)) - qpBdOffsetY; |
---|
| 1965 | |
---|
| 1966 | UInt uiAbsQpCUPartIdx = (uiAbsPartIdx>>((g_uiMaxCUDepth - pcCU->getSlice()->getPPS()->getMaxCuDQPDepth())<<1))<<((g_uiMaxCUDepth - pcCU->getSlice()->getPPS()->getMaxCuDQPDepth())<<1) ; |
---|
| 1967 | UInt uiQpCUDepth = min(uiDepth,pcCU->getSlice()->getPPS()->getMaxCuDQPDepth()) ; |
---|
| 1968 | |
---|
| 1969 | pcCU->setQPSubParts( qp, uiAbsQpCUPartIdx, uiQpCUDepth ); |
---|
| 1970 | } |
---|
| 1971 | |
---|
| 1972 | Void TDecCavlc::parseCoeffNxN( TComDataCU* /*pcCU*/, TCoeff* /*pcCoef*/, UInt /*uiAbsPartIdx*/, UInt /*uiWidth*/, UInt /*uiHeight*/, UInt /*uiDepth*/, TextType /*eTType*/ ) |
---|
| 1973 | { |
---|
| 1974 | assert(0); |
---|
| 1975 | } |
---|
| 1976 | |
---|
| 1977 | Void TDecCavlc::parseTransformSubdivFlag( UInt& /*ruiSubdivFlag*/, UInt /*uiLog2TransformBlockSize*/ ) |
---|
| 1978 | { |
---|
| 1979 | assert(0); |
---|
| 1980 | } |
---|
| 1981 | |
---|
| 1982 | Void TDecCavlc::parseQtCbf( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, TextType /*eType*/, UInt /*uiTrDepth*/, UInt /*uiDepth*/ ) |
---|
| 1983 | { |
---|
| 1984 | assert(0); |
---|
| 1985 | } |
---|
| 1986 | |
---|
| 1987 | Void TDecCavlc::parseQtRootCbf( UInt /*uiAbsPartIdx*/, UInt& /*uiQtRootCbf*/ ) |
---|
| 1988 | { |
---|
| 1989 | assert(0); |
---|
| 1990 | } |
---|
| 1991 | |
---|
| 1992 | Void TDecCavlc::parseTransformSkipFlags (TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*width*/, UInt /*height*/, UInt /*uiDepth*/, TextType /*eTType*/) |
---|
| 1993 | { |
---|
| 1994 | assert(0); |
---|
| 1995 | } |
---|
| 1996 | |
---|
| 1997 | Void TDecCavlc::parseMergeFlag ( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/, UInt /*uiPUIdx*/ ) |
---|
| 1998 | { |
---|
| 1999 | assert(0); |
---|
| 2000 | } |
---|
| 2001 | |
---|
| 2002 | Void TDecCavlc::parseMergeIndex ( TComDataCU* /*pcCU*/, UInt& /*ruiMergeIndex*/ ) |
---|
| 2003 | { |
---|
| 2004 | assert(0); |
---|
| 2005 | } |
---|
| 2006 | |
---|
| 2007 | // ==================================================================================================================== |
---|
| 2008 | // Protected member functions |
---|
| 2009 | // ==================================================================================================================== |
---|
| 2010 | |
---|
| 2011 | /** parse explicit wp tables |
---|
| 2012 | * \param TComSlice* pcSlice |
---|
| 2013 | * \returns Void |
---|
| 2014 | */ |
---|
| 2015 | Void TDecCavlc::xParsePredWeightTable( TComSlice* pcSlice ) |
---|
| 2016 | { |
---|
| 2017 | wpScalingParam *wp; |
---|
| 2018 | Bool bChroma = true; // color always present in HEVC ? |
---|
| 2019 | SliceType eSliceType = pcSlice->getSliceType(); |
---|
| 2020 | Int iNbRef = (eSliceType == B_SLICE ) ? (2) : (1); |
---|
| 2021 | UInt uiLog2WeightDenomLuma, uiLog2WeightDenomChroma; |
---|
| 2022 | UInt uiTotalSignalledWeightFlags = 0; |
---|
[216] | 2023 | |
---|
[191] | 2024 | Int iDeltaDenom; |
---|
| 2025 | // decode delta_luma_log2_weight_denom : |
---|
| 2026 | READ_UVLC( uiLog2WeightDenomLuma, "luma_log2_weight_denom" ); // ue(v): luma_log2_weight_denom |
---|
| 2027 | assert( uiLog2WeightDenomLuma <= 7 ); |
---|
[216] | 2028 | if( bChroma ) |
---|
[191] | 2029 | { |
---|
| 2030 | READ_SVLC( iDeltaDenom, "delta_chroma_log2_weight_denom" ); // se(v): delta_chroma_log2_weight_denom |
---|
| 2031 | assert((iDeltaDenom + (Int)uiLog2WeightDenomLuma)>=0); |
---|
| 2032 | assert((iDeltaDenom + (Int)uiLog2WeightDenomLuma)<=7); |
---|
| 2033 | uiLog2WeightDenomChroma = (UInt)(iDeltaDenom + uiLog2WeightDenomLuma); |
---|
| 2034 | } |
---|
| 2035 | |
---|
[216] | 2036 | for ( Int iNumRef=0 ; iNumRef<iNbRef ; iNumRef++ ) |
---|
[191] | 2037 | { |
---|
| 2038 | RefPicList eRefPicList = ( iNumRef ? REF_PIC_LIST_1 : REF_PIC_LIST_0 ); |
---|
[216] | 2039 | for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ ) |
---|
[191] | 2040 | { |
---|
| 2041 | pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); |
---|
| 2042 | |
---|
| 2043 | wp[0].uiLog2WeightDenom = uiLog2WeightDenomLuma; |
---|
| 2044 | wp[1].uiLog2WeightDenom = uiLog2WeightDenomChroma; |
---|
| 2045 | wp[2].uiLog2WeightDenom = uiLog2WeightDenomChroma; |
---|
| 2046 | |
---|
| 2047 | UInt uiCode; |
---|
| 2048 | READ_FLAG( uiCode, "luma_weight_lX_flag" ); // u(1): luma_weight_l0_flag |
---|
| 2049 | wp[0].bPresentFlag = ( uiCode == 1 ); |
---|
| 2050 | uiTotalSignalledWeightFlags += wp[0].bPresentFlag; |
---|
| 2051 | } |
---|
[216] | 2052 | if ( bChroma ) |
---|
[191] | 2053 | { |
---|
| 2054 | UInt uiCode; |
---|
[216] | 2055 | for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ ) |
---|
[191] | 2056 | { |
---|
| 2057 | pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); |
---|
| 2058 | READ_FLAG( uiCode, "chroma_weight_lX_flag" ); // u(1): chroma_weight_l0_flag |
---|
| 2059 | wp[1].bPresentFlag = ( uiCode == 1 ); |
---|
| 2060 | wp[2].bPresentFlag = ( uiCode == 1 ); |
---|
| 2061 | uiTotalSignalledWeightFlags += 2*wp[1].bPresentFlag; |
---|
| 2062 | } |
---|
| 2063 | } |
---|
[216] | 2064 | for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ ) |
---|
[191] | 2065 | { |
---|
| 2066 | pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); |
---|
[216] | 2067 | if ( wp[0].bPresentFlag ) |
---|
[191] | 2068 | { |
---|
| 2069 | Int iDeltaWeight; |
---|
| 2070 | READ_SVLC( iDeltaWeight, "delta_luma_weight_lX" ); // se(v): delta_luma_weight_l0[i] |
---|
| 2071 | assert( iDeltaWeight >= -128 ); |
---|
| 2072 | assert( iDeltaWeight <= 127 ); |
---|
| 2073 | wp[0].iWeight = (iDeltaWeight + (1<<wp[0].uiLog2WeightDenom)); |
---|
| 2074 | READ_SVLC( wp[0].iOffset, "luma_offset_lX" ); // se(v): luma_offset_l0[i] |
---|
| 2075 | assert( wp[0].iOffset >= -128 ); |
---|
| 2076 | assert( wp[0].iOffset <= 127 ); |
---|
| 2077 | } |
---|
[216] | 2078 | else |
---|
[191] | 2079 | { |
---|
| 2080 | wp[0].iWeight = (1 << wp[0].uiLog2WeightDenom); |
---|
| 2081 | wp[0].iOffset = 0; |
---|
| 2082 | } |
---|
[216] | 2083 | if ( bChroma ) |
---|
[191] | 2084 | { |
---|
[216] | 2085 | if ( wp[1].bPresentFlag ) |
---|
[191] | 2086 | { |
---|
[216] | 2087 | for ( Int j=1 ; j<3 ; j++ ) |
---|
[191] | 2088 | { |
---|
| 2089 | Int iDeltaWeight; |
---|
| 2090 | READ_SVLC( iDeltaWeight, "delta_chroma_weight_lX" ); // se(v): chroma_weight_l0[i][j] |
---|
| 2091 | assert( iDeltaWeight >= -128 ); |
---|
| 2092 | assert( iDeltaWeight <= 127 ); |
---|
| 2093 | wp[j].iWeight = (iDeltaWeight + (1<<wp[1].uiLog2WeightDenom)); |
---|
| 2094 | |
---|
| 2095 | Int iDeltaChroma; |
---|
| 2096 | READ_SVLC( iDeltaChroma, "delta_chroma_offset_lX" ); // se(v): delta_chroma_offset_l0[i][j] |
---|
| 2097 | assert( iDeltaChroma >= -512 ); |
---|
| 2098 | assert( iDeltaChroma <= 511 ); |
---|
| 2099 | Int pred = ( 128 - ( ( 128*wp[j].iWeight)>>(wp[j].uiLog2WeightDenom) ) ); |
---|
| 2100 | wp[j].iOffset = Clip3(-128, 127, (iDeltaChroma + pred) ); |
---|
| 2101 | } |
---|
| 2102 | } |
---|
[216] | 2103 | else |
---|
[191] | 2104 | { |
---|
[216] | 2105 | for ( Int j=1 ; j<3 ; j++ ) |
---|
[191] | 2106 | { |
---|
| 2107 | wp[j].iWeight = (1 << wp[j].uiLog2WeightDenom); |
---|
| 2108 | wp[j].iOffset = 0; |
---|
| 2109 | } |
---|
| 2110 | } |
---|
| 2111 | } |
---|
| 2112 | } |
---|
| 2113 | |
---|
[216] | 2114 | for ( Int iRefIdx=pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx<MAX_NUM_REF ; iRefIdx++ ) |
---|
[191] | 2115 | { |
---|
| 2116 | pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); |
---|
| 2117 | |
---|
| 2118 | wp[0].bPresentFlag = false; |
---|
| 2119 | wp[1].bPresentFlag = false; |
---|
| 2120 | wp[2].bPresentFlag = false; |
---|
| 2121 | } |
---|
| 2122 | } |
---|
| 2123 | assert(uiTotalSignalledWeightFlags<=24); |
---|
| 2124 | } |
---|
| 2125 | |
---|
| 2126 | /** decode quantization matrix |
---|
| 2127 | * \param scalingList quantization matrix information |
---|
| 2128 | */ |
---|
| 2129 | Void TDecCavlc::parseScalingList(TComScalingList* scalingList) |
---|
| 2130 | { |
---|
| 2131 | UInt code, sizeId, listId; |
---|
| 2132 | Bool scalingListPredModeFlag; |
---|
| 2133 | //for each size |
---|
| 2134 | for(sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
| 2135 | { |
---|
| 2136 | for(listId = 0; listId < g_scalingListNum[sizeId]; listId++) |
---|
| 2137 | { |
---|
| 2138 | READ_FLAG( code, "scaling_list_pred_mode_flag"); |
---|
| 2139 | scalingListPredModeFlag = (code) ? true : false; |
---|
| 2140 | if(!scalingListPredModeFlag) //Copy Mode |
---|
| 2141 | { |
---|
| 2142 | READ_UVLC( code, "scaling_list_pred_matrix_id_delta"); |
---|
| 2143 | scalingList->setRefMatrixId (sizeId,listId,(UInt)((Int)(listId)-(code))); |
---|
| 2144 | if( sizeId > SCALING_LIST_8x8 ) |
---|
| 2145 | { |
---|
| 2146 | scalingList->setScalingListDC(sizeId,listId,((listId == scalingList->getRefMatrixId (sizeId,listId))? 16 :scalingList->getScalingListDC(sizeId, scalingList->getRefMatrixId (sizeId,listId)))); |
---|
| 2147 | } |
---|
| 2148 | scalingList->processRefMatrix( sizeId, listId, scalingList->getRefMatrixId (sizeId,listId)); |
---|
| 2149 | |
---|
| 2150 | } |
---|
| 2151 | else //DPCM Mode |
---|
| 2152 | { |
---|
| 2153 | xDecodeScalingList(scalingList, sizeId, listId); |
---|
| 2154 | } |
---|
| 2155 | } |
---|
| 2156 | } |
---|
| 2157 | |
---|
| 2158 | return; |
---|
| 2159 | } |
---|
| 2160 | /** decode DPCM |
---|
| 2161 | * \param scalingList quantization matrix information |
---|
| 2162 | * \param sizeId size index |
---|
| 2163 | * \param listId list index |
---|
| 2164 | */ |
---|
| 2165 | Void TDecCavlc::xDecodeScalingList(TComScalingList *scalingList, UInt sizeId, UInt listId) |
---|
| 2166 | { |
---|
| 2167 | Int i,coefNum = min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId]); |
---|
| 2168 | Int data; |
---|
| 2169 | Int scalingListDcCoefMinus8 = 0; |
---|
| 2170 | Int nextCoef = SCALING_LIST_START_VALUE; |
---|
| 2171 | UInt* scan = (sizeId == 0) ? g_auiSigLastScan [ SCAN_DIAG ] [ 1 ] : g_sigLastScanCG32x32; |
---|
| 2172 | Int *dst = scalingList->getScalingListAddress(sizeId, listId); |
---|
| 2173 | |
---|
| 2174 | if( sizeId > SCALING_LIST_8x8 ) |
---|
| 2175 | { |
---|
| 2176 | READ_SVLC( scalingListDcCoefMinus8, "scaling_list_dc_coef_minus8"); |
---|
| 2177 | scalingList->setScalingListDC(sizeId,listId,scalingListDcCoefMinus8 + 8); |
---|
| 2178 | nextCoef = scalingList->getScalingListDC(sizeId,listId); |
---|
| 2179 | } |
---|
| 2180 | |
---|
| 2181 | for(i = 0; i < coefNum; i++) |
---|
| 2182 | { |
---|
| 2183 | READ_SVLC( data, "scaling_list_delta_coef"); |
---|
| 2184 | nextCoef = (nextCoef + data + 256 ) % 256; |
---|
| 2185 | dst[scan[i]] = nextCoef; |
---|
| 2186 | } |
---|
| 2187 | } |
---|
| 2188 | |
---|
| 2189 | Bool TDecCavlc::xMoreRbspData() |
---|
[216] | 2190 | { |
---|
[191] | 2191 | Int bitsLeft = m_pcBitstream->getNumBitsLeft(); |
---|
| 2192 | |
---|
| 2193 | // if there are more than 8 bits, it cannot be rbsp_trailing_bits |
---|
| 2194 | if (bitsLeft > 8) |
---|
| 2195 | { |
---|
| 2196 | return true; |
---|
| 2197 | } |
---|
| 2198 | |
---|
| 2199 | UChar lastByte = m_pcBitstream->peekBits(bitsLeft); |
---|
| 2200 | Int cnt = bitsLeft; |
---|
| 2201 | |
---|
| 2202 | // remove trailing bits equal to zero |
---|
| 2203 | while ((cnt>0) && ((lastByte & 1) == 0)) |
---|
| 2204 | { |
---|
| 2205 | lastByte >>= 1; |
---|
| 2206 | cnt--; |
---|
| 2207 | } |
---|
| 2208 | // remove bit equal to one |
---|
| 2209 | cnt--; |
---|
| 2210 | |
---|
| 2211 | // we should not have a negative number of bits |
---|
| 2212 | assert (cnt>=0); |
---|
| 2213 | |
---|
| 2214 | // we have more data, if cnt is not zero |
---|
| 2215 | return (cnt>0); |
---|
| 2216 | } |
---|
| 2217 | |
---|
| 2218 | #if INTRA_BL |
---|
| 2219 | Void TDecCavlc::parseIntraBLFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiPartIdx, UInt uiDepth ) |
---|
| 2220 | { |
---|
| 2221 | assert(0); |
---|
| 2222 | } |
---|
| 2223 | #endif |
---|
| 2224 | |
---|
| 2225 | //! \} |
---|
| 2226 | |
---|