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