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