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