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