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