[5] | 1 | /* The copyright in this software is being made available under the BSD |
---|
[608] | 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 | * |
---|
[872] | 6 | * Copyright (c) 2010-2014, ITU/ISO/IEC |
---|
[608] | 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 | */ |
---|
[2] | 33 | |
---|
| 34 | /** \file TDecCAVLC.cpp |
---|
[608] | 35 | \brief CAVLC decoder class |
---|
[2] | 36 | */ |
---|
| 37 | |
---|
| 38 | #include "TDecCAVLC.h" |
---|
| 39 | #include "SEIread.h" |
---|
[56] | 40 | #include "TDecSlice.h" |
---|
[2] | 41 | |
---|
[56] | 42 | //! \ingroup TLibDecoder |
---|
| 43 | //! \{ |
---|
| 44 | |
---|
| 45 | #if ENC_DEC_TRACE |
---|
| 46 | |
---|
| 47 | Void xTraceSPSHeader (TComSPS *pSPS) |
---|
| 48 | { |
---|
[608] | 49 | #if H_MV_ENC_DEC_TRAC |
---|
| 50 | if ( g_disableHLSTrace ) |
---|
| 51 | { |
---|
| 52 | return; |
---|
| 53 | } |
---|
| 54 | // To avoid mismatches |
---|
[1066] | 55 | fprintf( g_hTrace, "=========== Sequence Parameter Set LayerId: %d ===========\n", pSPS->getLayerId() ); |
---|
| 56 | #else |
---|
[56] | 57 | fprintf( g_hTrace, "=========== Sequence Parameter Set ID: %d ===========\n", pSPS->getSPSId() ); |
---|
[608] | 58 | #endif |
---|
[56] | 59 | } |
---|
| 60 | |
---|
| 61 | Void xTracePPSHeader (TComPPS *pPPS) |
---|
| 62 | { |
---|
[608] | 63 | #if H_MV_ENC_DEC_TRAC |
---|
| 64 | if ( g_disableHLSTrace ) |
---|
| 65 | { |
---|
| 66 | return; |
---|
| 67 | } |
---|
[1066] | 68 | fprintf( g_hTrace, "=========== Picture Parameter Set LayerId: %d ===========\n", pPPS->getLayerId() ); |
---|
| 69 | #else |
---|
[56] | 70 | fprintf( g_hTrace, "=========== Picture Parameter Set ID: %d ===========\n", pPPS->getPPSId() ); |
---|
[608] | 71 | #endif |
---|
[56] | 72 | } |
---|
| 73 | |
---|
| 74 | Void xTraceSliceHeader (TComSlice *pSlice) |
---|
| 75 | { |
---|
[608] | 76 | #if H_MV_ENC_DEC_TRAC |
---|
| 77 | if ( g_disableHLSTrace ) |
---|
| 78 | { |
---|
| 79 | return; |
---|
| 80 | } |
---|
| 81 | #endif |
---|
[56] | 82 | fprintf( g_hTrace, "=========== Slice ===========\n"); |
---|
| 83 | } |
---|
| 84 | |
---|
| 85 | #endif |
---|
| 86 | |
---|
[2] | 87 | // ==================================================================================================================== |
---|
| 88 | // Constructor / destructor / create / destroy |
---|
| 89 | // ==================================================================================================================== |
---|
| 90 | |
---|
| 91 | TDecCavlc::TDecCavlc() |
---|
| 92 | { |
---|
[608] | 93 | #if H_3D |
---|
| 94 | m_aaiTempScale = new Int* [ MAX_NUM_LAYERS ]; |
---|
| 95 | m_aaiTempOffset = new Int* [ MAX_NUM_LAYERS ]; |
---|
| 96 | for( UInt uiVId = 0; uiVId < MAX_NUM_LAYERS; uiVId++ ) |
---|
[2] | 97 | { |
---|
[608] | 98 | m_aaiTempScale [ uiVId ] = new Int [ MAX_NUM_LAYERS ]; |
---|
| 99 | m_aaiTempOffset [ uiVId ] = new Int [ MAX_NUM_LAYERS ]; |
---|
[2] | 100 | } |
---|
[608] | 101 | #endif |
---|
[2] | 102 | } |
---|
| 103 | |
---|
| 104 | TDecCavlc::~TDecCavlc() |
---|
| 105 | { |
---|
[608] | 106 | #if H_3D |
---|
| 107 | for( UInt uiVId = 0; uiVId < MAX_NUM_LAYERS; uiVId++ ) |
---|
[2] | 108 | { |
---|
| 109 | delete [] m_aaiTempScale [ uiVId ]; |
---|
| 110 | delete [] m_aaiTempOffset [ uiVId ]; |
---|
| 111 | } |
---|
| 112 | delete [] m_aaiTempScale; |
---|
| 113 | delete [] m_aaiTempOffset; |
---|
[608] | 114 | #endif |
---|
[2] | 115 | } |
---|
| 116 | |
---|
| 117 | // ==================================================================================================================== |
---|
| 118 | // Public member functions |
---|
| 119 | // ==================================================================================================================== |
---|
| 120 | |
---|
[56] | 121 | void TDecCavlc::parseShortTermRefPicSet( TComSPS* sps, TComReferencePictureSet* rps, Int idx ) |
---|
[2] | 122 | { |
---|
[56] | 123 | UInt code; |
---|
| 124 | UInt interRPSPred; |
---|
[608] | 125 | if (idx > 0) |
---|
| 126 | { |
---|
| 127 | READ_FLAG(interRPSPred, "inter_ref_pic_set_prediction_flag"); rps->setInterRPSPrediction(interRPSPred); |
---|
| 128 | } |
---|
| 129 | else |
---|
| 130 | { |
---|
| 131 | interRPSPred = false; |
---|
| 132 | rps->setInterRPSPrediction(false); |
---|
| 133 | } |
---|
| 134 | |
---|
[56] | 135 | if (interRPSPred) |
---|
| 136 | { |
---|
| 137 | UInt bit; |
---|
[608] | 138 | if(idx == sps->getRPSList()->getNumberOfReferencePictureSets()) |
---|
| 139 | { |
---|
| 140 | READ_UVLC(code, "delta_idx_minus1" ); // delta index of the Reference Picture Set used for prediction minus 1 |
---|
| 141 | } |
---|
| 142 | else |
---|
| 143 | { |
---|
| 144 | code = 0; |
---|
| 145 | } |
---|
| 146 | 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 |
---|
[56] | 147 | Int rIdx = idx - 1 - code; |
---|
[608] | 148 | 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 |
---|
[56] | 149 | TComReferencePictureSet* rpsRef = sps->getRPSList()->getReferencePictureSet(rIdx); |
---|
| 150 | Int k = 0, k0 = 0, k1 = 0; |
---|
| 151 | READ_CODE(1, bit, "delta_rps_sign"); // delta_RPS_sign |
---|
| 152 | READ_UVLC(code, "abs_delta_rps_minus1"); // absolute delta RPS minus 1 |
---|
[608] | 153 | Int deltaRPS = (1 - 2 * bit) * (code + 1); // delta_RPS |
---|
[56] | 154 | for(Int j=0 ; j <= rpsRef->getNumberOfPictures(); j++) |
---|
| 155 | { |
---|
| 156 | READ_CODE(1, bit, "used_by_curr_pic_flag" ); //first bit is "1" if Idc is 1 |
---|
| 157 | Int refIdc = bit; |
---|
| 158 | if (refIdc == 0) |
---|
| 159 | { |
---|
| 160 | READ_CODE(1, bit, "use_delta_flag" ); //second bit is "1" if Idc is 2, "0" otherwise. |
---|
| 161 | refIdc = bit<<1; //second bit is "1" if refIdc is 2, "0" if refIdc = 0. |
---|
| 162 | } |
---|
| 163 | if (refIdc == 1 || refIdc == 2) |
---|
| 164 | { |
---|
| 165 | Int deltaPOC = deltaRPS + ((j < rpsRef->getNumberOfPictures())? rpsRef->getDeltaPOC(j) : 0); |
---|
| 166 | rps->setDeltaPOC(k, deltaPOC); |
---|
| 167 | rps->setUsed(k, (refIdc == 1)); |
---|
[2] | 168 | |
---|
[608] | 169 | if (deltaPOC < 0) |
---|
| 170 | { |
---|
[56] | 171 | k0++; |
---|
| 172 | } |
---|
| 173 | else |
---|
| 174 | { |
---|
| 175 | k1++; |
---|
| 176 | } |
---|
| 177 | k++; |
---|
| 178 | } |
---|
| 179 | rps->setRefIdc(j,refIdc); |
---|
| 180 | } |
---|
| 181 | rps->setNumRefIdc(rpsRef->getNumberOfPictures()+1); |
---|
| 182 | rps->setNumberOfPictures(k); |
---|
| 183 | rps->setNumberOfNegativePictures(k0); |
---|
| 184 | rps->setNumberOfPositivePictures(k1); |
---|
| 185 | rps->sortDeltaPOC(); |
---|
| 186 | } |
---|
| 187 | else |
---|
| 188 | { |
---|
| 189 | READ_UVLC(code, "num_negative_pics"); rps->setNumberOfNegativePictures(code); |
---|
| 190 | READ_UVLC(code, "num_positive_pics"); rps->setNumberOfPositivePictures(code); |
---|
| 191 | Int prev = 0; |
---|
| 192 | Int poc; |
---|
| 193 | for(Int j=0 ; j < rps->getNumberOfNegativePictures(); j++) |
---|
| 194 | { |
---|
| 195 | READ_UVLC(code, "delta_poc_s0_minus1"); |
---|
| 196 | poc = prev-code-1; |
---|
| 197 | prev = poc; |
---|
| 198 | rps->setDeltaPOC(j,poc); |
---|
| 199 | READ_FLAG(code, "used_by_curr_pic_s0_flag"); rps->setUsed(j,code); |
---|
| 200 | } |
---|
| 201 | prev = 0; |
---|
| 202 | for(Int j=rps->getNumberOfNegativePictures(); j < rps->getNumberOfNegativePictures()+rps->getNumberOfPositivePictures(); j++) |
---|
| 203 | { |
---|
| 204 | READ_UVLC(code, "delta_poc_s1_minus1"); |
---|
| 205 | poc = prev+code+1; |
---|
| 206 | prev = poc; |
---|
| 207 | rps->setDeltaPOC(j,poc); |
---|
| 208 | READ_FLAG(code, "used_by_curr_pic_s1_flag"); rps->setUsed(j,code); |
---|
| 209 | } |
---|
| 210 | rps->setNumberOfPictures(rps->getNumberOfNegativePictures()+rps->getNumberOfPositivePictures()); |
---|
| 211 | } |
---|
| 212 | #if PRINT_RPS_INFO |
---|
| 213 | rps->printDeltaPOC(); |
---|
[2] | 214 | #endif |
---|
| 215 | } |
---|
| 216 | |
---|
[773] | 217 | #if H_3D |
---|
[758] | 218 | Void TDecCavlc::parsePPS(TComPPS* pcPPS, TComVPS* pcVPS ) |
---|
| 219 | #else |
---|
[608] | 220 | Void TDecCavlc::parsePPS(TComPPS* pcPPS) |
---|
[758] | 221 | #endif |
---|
[2] | 222 | { |
---|
[56] | 223 | #if ENC_DEC_TRACE |
---|
[608] | 224 | xTracePPSHeader (pcPPS); |
---|
[2] | 225 | #endif |
---|
[608] | 226 | UInt uiCode; |
---|
[2] | 227 | |
---|
[608] | 228 | Int iCode; |
---|
[2] | 229 | |
---|
[608] | 230 | READ_UVLC( uiCode, "pps_pic_parameter_set_id"); |
---|
| 231 | assert(uiCode <= 63); |
---|
| 232 | pcPPS->setPPSId (uiCode); |
---|
| 233 | |
---|
| 234 | READ_UVLC( uiCode, "pps_seq_parameter_set_id"); |
---|
| 235 | assert(uiCode <= 15); |
---|
| 236 | pcPPS->setSPSId (uiCode); |
---|
| 237 | |
---|
| 238 | READ_FLAG( uiCode, "dependent_slice_segments_enabled_flag" ); pcPPS->setDependentSliceSegmentsEnabledFlag ( uiCode == 1 ); |
---|
| 239 | READ_FLAG( uiCode, "output_flag_present_flag" ); pcPPS->setOutputFlagPresentFlag( uiCode==1 ); |
---|
[2] | 240 | |
---|
[608] | 241 | READ_CODE(3, uiCode, "num_extra_slice_header_bits"); pcPPS->setNumExtraSliceHeaderBits(uiCode); |
---|
| 242 | READ_FLAG ( uiCode, "sign_data_hiding_flag" ); pcPPS->setSignHideFlag( uiCode ); |
---|
[2] | 243 | |
---|
[608] | 244 | READ_FLAG( uiCode, "cabac_init_present_flag" ); pcPPS->setCabacInitPresentFlag( uiCode ? true : false ); |
---|
[56] | 245 | |
---|
[608] | 246 | READ_UVLC(uiCode, "num_ref_idx_l0_default_active_minus1"); |
---|
| 247 | assert(uiCode <= 14); |
---|
| 248 | pcPPS->setNumRefIdxL0DefaultActive(uiCode+1); |
---|
| 249 | |
---|
| 250 | READ_UVLC(uiCode, "num_ref_idx_l1_default_active_minus1"); |
---|
| 251 | assert(uiCode <= 14); |
---|
| 252 | pcPPS->setNumRefIdxL1DefaultActive(uiCode+1); |
---|
| 253 | |
---|
| 254 | READ_SVLC(iCode, "init_qp_minus26" ); pcPPS->setPicInitQPMinus26(iCode); |
---|
| 255 | READ_FLAG( uiCode, "constrained_intra_pred_flag" ); pcPPS->setConstrainedIntraPred( uiCode ? true : false ); |
---|
| 256 | READ_FLAG( uiCode, "transform_skip_enabled_flag" ); |
---|
| 257 | pcPPS->setUseTransformSkip ( uiCode ? true : false ); |
---|
[2] | 258 | |
---|
[608] | 259 | READ_FLAG( uiCode, "cu_qp_delta_enabled_flag" ); pcPPS->setUseDQP( uiCode ? true : false ); |
---|
| 260 | if( pcPPS->getUseDQP() ) |
---|
[56] | 261 | { |
---|
[608] | 262 | READ_UVLC( uiCode, "diff_cu_qp_delta_depth" ); |
---|
| 263 | pcPPS->setMaxCuDQPDepth( uiCode ); |
---|
[56] | 264 | } |
---|
| 265 | else |
---|
| 266 | { |
---|
[608] | 267 | pcPPS->setMaxCuDQPDepth( 0 ); |
---|
[56] | 268 | } |
---|
[608] | 269 | READ_SVLC( iCode, "pps_cb_qp_offset"); |
---|
| 270 | pcPPS->setChromaCbQpOffset(iCode); |
---|
| 271 | assert( pcPPS->getChromaCbQpOffset() >= -12 ); |
---|
| 272 | assert( pcPPS->getChromaCbQpOffset() <= 12 ); |
---|
[2] | 273 | |
---|
[608] | 274 | READ_SVLC( iCode, "pps_cr_qp_offset"); |
---|
| 275 | pcPPS->setChromaCrQpOffset(iCode); |
---|
| 276 | assert( pcPPS->getChromaCrQpOffset() >= -12 ); |
---|
| 277 | assert( pcPPS->getChromaCrQpOffset() <= 12 ); |
---|
[56] | 278 | |
---|
[608] | 279 | READ_FLAG( uiCode, "pps_slice_chroma_qp_offsets_present_flag" ); |
---|
| 280 | pcPPS->setSliceChromaQpFlag( uiCode ? true : false ); |
---|
[56] | 281 | |
---|
[608] | 282 | READ_FLAG( uiCode, "weighted_pred_flag" ); // Use of Weighting Prediction (P_SLICE) |
---|
| 283 | pcPPS->setUseWP( uiCode==1 ); |
---|
| 284 | READ_FLAG( uiCode, "weighted_bipred_flag" ); // Use of Bi-Directional Weighting Prediction (B_SLICE) |
---|
| 285 | pcPPS->setWPBiPred( uiCode==1 ); |
---|
[56] | 286 | |
---|
[608] | 287 | READ_FLAG( uiCode, "transquant_bypass_enable_flag"); |
---|
| 288 | pcPPS->setTransquantBypassEnableFlag(uiCode ? true : false); |
---|
| 289 | READ_FLAG( uiCode, "tiles_enabled_flag" ); pcPPS->setTilesEnabledFlag ( uiCode == 1 ); |
---|
| 290 | READ_FLAG( uiCode, "entropy_coding_sync_enabled_flag" ); pcPPS->setEntropyCodingSyncEnabledFlag( uiCode == 1 ); |
---|
| 291 | |
---|
| 292 | if( pcPPS->getTilesEnabledFlag() ) |
---|
[56] | 293 | { |
---|
[1084] | 294 | READ_UVLC ( uiCode, "num_tile_columns_minus1" ); pcPPS->setNumTileColumnsMinus1( uiCode ); |
---|
| 295 | READ_UVLC ( uiCode, "num_tile_rows_minus1" ); pcPPS->setNumTileRowsMinus1( uiCode ); |
---|
| 296 | READ_FLAG ( uiCode, "uniform_spacing_flag" ); pcPPS->setTileUniformSpacingFlag( uiCode == 1 ); |
---|
[608] | 297 | |
---|
[1084] | 298 | if( !pcPPS->getTileUniformSpacingFlag()) |
---|
[2] | 299 | { |
---|
[1084] | 300 | std::vector<Int> columnWidth(pcPPS->getNumTileColumnsMinus1()); |
---|
| 301 | for(UInt i=0; i<pcPPS->getNumTileColumnsMinus1(); i++) |
---|
[608] | 302 | { |
---|
| 303 | READ_UVLC( uiCode, "column_width_minus1" ); |
---|
| 304 | columnWidth[i] = uiCode+1; |
---|
[56] | 305 | } |
---|
[1084] | 306 | pcPPS->setTileColumnWidth(columnWidth); |
---|
[608] | 307 | |
---|
[1084] | 308 | std::vector<Int> rowHeight (pcPPS->getTileNumRowsMinus1()); |
---|
| 309 | for(UInt i=0; i<pcPPS->getTileNumRowsMinus1(); i++) |
---|
[56] | 310 | { |
---|
[608] | 311 | READ_UVLC( uiCode, "row_height_minus1" ); |
---|
| 312 | rowHeight[i] = uiCode + 1; |
---|
[2] | 313 | } |
---|
[1084] | 314 | pcPPS->setTileRowHeight(rowHeight); |
---|
[2] | 315 | } |
---|
[608] | 316 | |
---|
[1084] | 317 | if(pcPPS->getNumTileColumnsMinus1() !=0 || pcPPS->getTileNumRowsMinus1() !=0) |
---|
[2] | 318 | { |
---|
[608] | 319 | READ_FLAG ( uiCode, "loop_filter_across_tiles_enabled_flag" ); pcPPS->setLoopFilterAcrossTilesEnabledFlag( uiCode ? true : false ); |
---|
[2] | 320 | } |
---|
[56] | 321 | } |
---|
[608] | 322 | READ_FLAG( uiCode, "loop_filter_across_slices_enabled_flag" ); pcPPS->setLoopFilterAcrossSlicesEnabledFlag( uiCode ? true : false ); |
---|
| 323 | READ_FLAG( uiCode, "deblocking_filter_control_present_flag" ); pcPPS->setDeblockingFilterControlPresentFlag( uiCode ? true : false ); |
---|
| 324 | if(pcPPS->getDeblockingFilterControlPresentFlag()) |
---|
[56] | 325 | { |
---|
[608] | 326 | READ_FLAG( uiCode, "deblocking_filter_override_enabled_flag" ); pcPPS->setDeblockingFilterOverrideEnabledFlag( uiCode ? true : false ); |
---|
| 327 | READ_FLAG( uiCode, "pps_disable_deblocking_filter_flag" ); pcPPS->setPicDisableDeblockingFilterFlag(uiCode ? true : false ); |
---|
| 328 | if(!pcPPS->getPicDisableDeblockingFilterFlag()) |
---|
[56] | 329 | { |
---|
[608] | 330 | READ_SVLC ( iCode, "pps_beta_offset_div2" ); pcPPS->setDeblockingFilterBetaOffsetDiv2( iCode ); |
---|
| 331 | READ_SVLC ( iCode, "pps_tc_offset_div2" ); pcPPS->setDeblockingFilterTcOffsetDiv2( iCode ); |
---|
[56] | 332 | } |
---|
| 333 | } |
---|
[608] | 334 | READ_FLAG( uiCode, "pps_scaling_list_data_present_flag" ); pcPPS->setScalingListPresentFlag( uiCode ? true : false ); |
---|
| 335 | if(pcPPS->getScalingListPresentFlag ()) |
---|
[2] | 336 | { |
---|
[608] | 337 | parseScalingList( pcPPS->getScalingList() ); |
---|
[2] | 338 | } |
---|
[608] | 339 | READ_FLAG( uiCode, "lists_modification_present_flag"); |
---|
| 340 | pcPPS->setListsModificationPresentFlag(uiCode); |
---|
[2] | 341 | |
---|
[608] | 342 | READ_UVLC( uiCode, "log2_parallel_merge_level_minus2"); |
---|
| 343 | pcPPS->setLog2ParallelMergeLevelMinus2 (uiCode); |
---|
[2] | 344 | |
---|
[608] | 345 | READ_FLAG( uiCode, "slice_segment_header_extension_present_flag"); |
---|
| 346 | pcPPS->setSliceHeaderExtensionPresentFlag(uiCode); |
---|
[964] | 347 | |
---|
| 348 | #if H_MV |
---|
| 349 | READ_FLAG( uiCode, "pps_extension_present_flag"); |
---|
| 350 | #else |
---|
[608] | 351 | READ_FLAG( uiCode, "pps_extension_flag"); |
---|
[964] | 352 | #endif |
---|
[608] | 353 | if (uiCode) |
---|
[2] | 354 | { |
---|
[964] | 355 | |
---|
[872] | 356 | #if H_MV |
---|
[964] | 357 | READ_FLAG( uiCode, "pps_range_extensions_flag" ); pcPPS->setPpsRangeExtensionsFlag( uiCode == 1 ); |
---|
| 358 | READ_FLAG( uiCode, "pps_multilayer_extension_flag" ); pcPPS->setPpsMultilayerExtensionFlag( uiCode == 1 ); |
---|
| 359 | #if !H_3D |
---|
| 360 | READ_CODE( 6, uiCode, "pps_extension_6bits" ); pcPPS->setPpsExtension6bits( uiCode ); |
---|
| 361 | #else |
---|
| 362 | READ_FLAG( uiCode, "pps_3d_extension_flag" ); pcPPS->setPps3dExtensionFlag( uiCode == 1 ); |
---|
| 363 | READ_CODE( 5, uiCode, "pps_extension_5bits" ); pcPPS->setPpsExtension5bits( uiCode ); |
---|
| 364 | #endif |
---|
| 365 | if ( pcPPS->getPpsRangeExtensionsFlag() ) |
---|
| 366 | { |
---|
| 367 | assert(0); |
---|
| 368 | } |
---|
| 369 | |
---|
| 370 | if ( pcPPS->getPpsMultilayerExtensionFlag() ) |
---|
| 371 | { |
---|
[1066] | 372 | parsePPSMultilayerExtension( pcPPS ); |
---|
[964] | 373 | } |
---|
| 374 | #if !H_3D |
---|
| 375 | if ( pcPPS->getPpsExtension6bits() ) |
---|
| 376 | { |
---|
| 377 | #else |
---|
| 378 | if ( pcPPS->getPps3dExtensionFlag() ) |
---|
| 379 | { |
---|
| 380 | parsePPSExtension( pcPPS, pcVPS ); |
---|
| 381 | } |
---|
| 382 | if ( pcPPS->getPpsExtension5bits() ) |
---|
| 383 | { |
---|
| 384 | #endif |
---|
[872] | 385 | |
---|
| 386 | #endif |
---|
| 387 | |
---|
| 388 | while ( xMoreRbspData() ) |
---|
| 389 | { |
---|
| 390 | READ_FLAG( uiCode, "pps_extension_data_flag"); |
---|
| 391 | } |
---|
| 392 | #if H_MV |
---|
| 393 | } |
---|
| 394 | #endif |
---|
| 395 | } |
---|
[56] | 396 | } |
---|
[2] | 397 | |
---|
[1066] | 398 | |
---|
[773] | 399 | #if H_3D |
---|
[758] | 400 | Void TDecCavlc::parsePPSExtension( TComPPS* pcPPS, TComVPS* pcVPS ) |
---|
| 401 | { |
---|
[773] | 402 | //Ed.(GT): pcVPS should not be used here. Needs to be fixed. |
---|
[758] | 403 | UInt uiCode = 0; |
---|
| 404 | TComDLT* pcDLT = new TComDLT; |
---|
| 405 | |
---|
| 406 | READ_FLAG(uiCode, "dlt_present_flag"); |
---|
| 407 | pcDLT->setDltPresentFlag( (uiCode == 1) ? true : false ); |
---|
| 408 | |
---|
| 409 | if ( pcDLT->getDltPresentFlag() ) |
---|
| 410 | { |
---|
| 411 | READ_CODE(6, uiCode, "pps_depth_layers_minus1"); |
---|
| 412 | pcDLT->setNumDepthViews( uiCode ); |
---|
| 413 | |
---|
| 414 | READ_CODE(4, uiCode, "pps_bit_depth_for_depth_views_minus8"); |
---|
| 415 | pcDLT->setDepthViewBitDepth( (uiCode+8) ); |
---|
| 416 | |
---|
| 417 | for( Int i = 0; i <= pcVPS->getMaxLayersMinus1(); i++ ) |
---|
| 418 | { |
---|
| 419 | if ( i != 0 ) |
---|
| 420 | { |
---|
| 421 | if( pcVPS->getDepthId( i ) == 1 ) |
---|
| 422 | { |
---|
| 423 | READ_FLAG(uiCode, "dlt_flag[i]"); |
---|
| 424 | pcDLT->setUseDLTFlag(i, (uiCode == 1) ? true : false); |
---|
| 425 | |
---|
| 426 | if ( pcDLT->getUseDLTFlag( i ) ) |
---|
| 427 | { |
---|
| 428 | Bool bDltBitMapRepFlag = false; |
---|
| 429 | UInt uiMaxDiff = 0xffffffff; |
---|
| 430 | UInt uiMinDiff = 0; |
---|
| 431 | UInt uiCodeLength = 0; |
---|
| 432 | |
---|
| 433 | READ_FLAG(uiCode, "inter_view_dlt_pred_enable_flag[ i ]"); |
---|
[950] | 434 | |
---|
| 435 | if( uiCode ) |
---|
| 436 | { |
---|
| 437 | assert( pcDLT->getUseDLTFlag( 1 )); |
---|
| 438 | } |
---|
[758] | 439 | pcDLT->setInterViewDltPredEnableFlag( i, (uiCode == 1) ? true : false ); |
---|
| 440 | |
---|
| 441 | if ( pcDLT->getInterViewDltPredEnableFlag( i ) == false ) |
---|
| 442 | { |
---|
| 443 | READ_FLAG(uiCode, "dlt_bit_map_rep_flag[ layerId ]"); |
---|
| 444 | bDltBitMapRepFlag = (uiCode == 1) ? true : false; |
---|
| 445 | } |
---|
| 446 | else |
---|
| 447 | { |
---|
| 448 | bDltBitMapRepFlag = false; |
---|
| 449 | } |
---|
| 450 | |
---|
| 451 | UInt uiNumDepthValues = 0; |
---|
| 452 | Int aiIdx2DepthValue[256]; |
---|
| 453 | |
---|
| 454 | // Bit map |
---|
| 455 | if ( bDltBitMapRepFlag ) |
---|
| 456 | { |
---|
| 457 | for (UInt d=0; d<256; d++) |
---|
| 458 | { |
---|
| 459 | READ_FLAG(uiCode, "dlt_bit_map_flag[ layerId ][ j ]"); |
---|
| 460 | if (uiCode == 1) |
---|
| 461 | { |
---|
| 462 | aiIdx2DepthValue[uiNumDepthValues] = d; |
---|
| 463 | uiNumDepthValues++; |
---|
| 464 | } |
---|
| 465 | } |
---|
| 466 | } |
---|
| 467 | // Diff Coding |
---|
| 468 | else |
---|
| 469 | { |
---|
| 470 | READ_CODE(8, uiNumDepthValues, "num_depth_values_in_dlt[i]"); // num_entry |
---|
| 471 | |
---|
| 472 | { |
---|
| 473 | // The condition if( pcVPS->getNumDepthValues(i) > 0 ) is always true since for Single-view Diff Coding, there is at least one depth value in depth component. |
---|
| 474 | |
---|
| 475 | if (uiNumDepthValues > 1) |
---|
| 476 | { |
---|
| 477 | READ_CODE(8, uiCode, "max_diff[ layerId ]"); |
---|
| 478 | uiMaxDiff = uiCode; |
---|
| 479 | } |
---|
| 480 | else |
---|
| 481 | { |
---|
| 482 | uiMaxDiff = 0; // when there is only one value in DLT |
---|
| 483 | } |
---|
| 484 | |
---|
| 485 | if (uiNumDepthValues > 2) |
---|
| 486 | { |
---|
| 487 | uiCodeLength = (UInt) ceil(Log2(uiMaxDiff + 1)); |
---|
| 488 | READ_CODE(uiCodeLength, uiCode, "min_diff_minus1[ layerId ]"); |
---|
| 489 | uiMinDiff = uiCode + 1; |
---|
| 490 | } |
---|
| 491 | else |
---|
| 492 | { |
---|
| 493 | uiMinDiff = uiMaxDiff; // when there are only one or two values in DLT |
---|
| 494 | } |
---|
| 495 | |
---|
| 496 | READ_CODE(8, uiCode, "dlt_depth_value0[layerId]"); // entry0 |
---|
| 497 | aiIdx2DepthValue[0] = uiCode; |
---|
| 498 | |
---|
| 499 | if (uiMaxDiff == uiMinDiff) |
---|
| 500 | { |
---|
| 501 | for (UInt d=1; d<uiNumDepthValues; d++) |
---|
| 502 | { |
---|
| 503 | aiIdx2DepthValue[d] = aiIdx2DepthValue[d-1] + uiMinDiff + 0; |
---|
| 504 | } |
---|
| 505 | } |
---|
| 506 | else |
---|
| 507 | { |
---|
| 508 | uiCodeLength = (UInt) ceil(Log2(uiMaxDiff - uiMinDiff + 1)); |
---|
| 509 | for (UInt d=1; d<uiNumDepthValues; d++) |
---|
| 510 | { |
---|
| 511 | READ_CODE(uiCodeLength, uiCode, "dlt_depth_value_diff_minus_min[ layerId ][ j ]"); |
---|
| 512 | aiIdx2DepthValue[d] = aiIdx2DepthValue[d-1] + uiMinDiff + uiCode; |
---|
| 513 | } |
---|
| 514 | } |
---|
| 515 | |
---|
| 516 | } |
---|
| 517 | } |
---|
| 518 | |
---|
| 519 | if( pcDLT->getInterViewDltPredEnableFlag( i ) ) |
---|
| 520 | { |
---|
| 521 | // interpret decoded values as delta DLT |
---|
| 522 | AOF( pcVPS->getDepthId( 1 ) == 1 ); |
---|
| 523 | AOF( i > 1 ); |
---|
| 524 | // assumes ref layer id to be 1 |
---|
| 525 | Int* piRefDLT = pcDLT->idx2DepthValue( 1 ); |
---|
| 526 | UInt uiRefNum = pcDLT->getNumDepthValues( 1 ); |
---|
| 527 | pcDLT->setDeltaDLT(i, piRefDLT, uiRefNum, aiIdx2DepthValue, uiNumDepthValues); |
---|
| 528 | } |
---|
| 529 | else |
---|
| 530 | { |
---|
| 531 | // store final DLT |
---|
| 532 | pcDLT->setDepthLUTs(i, aiIdx2DepthValue, uiNumDepthValues); |
---|
| 533 | } |
---|
[1084] | 534 | |
---|
[758] | 535 | } |
---|
| 536 | } |
---|
| 537 | } |
---|
| 538 | } |
---|
| 539 | } |
---|
| 540 | |
---|
| 541 | pcPPS->setDLT( pcDLT ); |
---|
| 542 | } |
---|
| 543 | #endif |
---|
| 544 | |
---|
[608] | 545 | Void TDecCavlc::parseVUI(TComVUI* pcVUI, TComSPS *pcSPS) |
---|
| 546 | { |
---|
| 547 | #if ENC_DEC_TRACE |
---|
| 548 | fprintf( g_hTrace, "----------- vui_parameters -----------\n"); |
---|
| 549 | #endif |
---|
| 550 | UInt uiCode; |
---|
[2] | 551 | |
---|
[608] | 552 | READ_FLAG( uiCode, "aspect_ratio_info_present_flag"); pcVUI->setAspectRatioInfoPresentFlag(uiCode); |
---|
| 553 | if (pcVUI->getAspectRatioInfoPresentFlag()) |
---|
[2] | 554 | { |
---|
[608] | 555 | READ_CODE(8, uiCode, "aspect_ratio_idc"); pcVUI->setAspectRatioIdc(uiCode); |
---|
| 556 | if (pcVUI->getAspectRatioIdc() == 255) |
---|
[2] | 557 | { |
---|
[608] | 558 | READ_CODE(16, uiCode, "sar_width"); pcVUI->setSarWidth(uiCode); |
---|
| 559 | READ_CODE(16, uiCode, "sar_height"); pcVUI->setSarHeight(uiCode); |
---|
[2] | 560 | } |
---|
| 561 | } |
---|
[608] | 562 | |
---|
| 563 | READ_FLAG( uiCode, "overscan_info_present_flag"); pcVUI->setOverscanInfoPresentFlag(uiCode); |
---|
| 564 | if (pcVUI->getOverscanInfoPresentFlag()) |
---|
[56] | 565 | { |
---|
[608] | 566 | READ_FLAG( uiCode, "overscan_appropriate_flag"); pcVUI->setOverscanAppropriateFlag(uiCode); |
---|
[56] | 567 | } |
---|
[2] | 568 | |
---|
[608] | 569 | READ_FLAG( uiCode, "video_signal_type_present_flag"); pcVUI->setVideoSignalTypePresentFlag(uiCode); |
---|
[773] | 570 | #if H_MV |
---|
[738] | 571 | assert( pcSPS->getLayerId() == 0 || !pcVUI->getVideoSignalTypePresentFlag() ); |
---|
| 572 | #endif |
---|
[608] | 573 | if (pcVUI->getVideoSignalTypePresentFlag()) |
---|
[2] | 574 | { |
---|
[608] | 575 | READ_CODE(3, uiCode, "video_format"); pcVUI->setVideoFormat(uiCode); |
---|
| 576 | READ_FLAG( uiCode, "video_full_range_flag"); pcVUI->setVideoFullRangeFlag(uiCode); |
---|
| 577 | READ_FLAG( uiCode, "colour_description_present_flag"); pcVUI->setColourDescriptionPresentFlag(uiCode); |
---|
| 578 | if (pcVUI->getColourDescriptionPresentFlag()) |
---|
[2] | 579 | { |
---|
[608] | 580 | READ_CODE(8, uiCode, "colour_primaries"); pcVUI->setColourPrimaries(uiCode); |
---|
| 581 | READ_CODE(8, uiCode, "transfer_characteristics"); pcVUI->setTransferCharacteristics(uiCode); |
---|
| 582 | READ_CODE(8, uiCode, "matrix_coefficients"); pcVUI->setMatrixCoefficients(uiCode); |
---|
[2] | 583 | } |
---|
| 584 | } |
---|
[56] | 585 | |
---|
[608] | 586 | READ_FLAG( uiCode, "chroma_loc_info_present_flag"); pcVUI->setChromaLocInfoPresentFlag(uiCode); |
---|
| 587 | if (pcVUI->getChromaLocInfoPresentFlag()) |
---|
[2] | 588 | { |
---|
[608] | 589 | READ_UVLC( uiCode, "chroma_sample_loc_type_top_field" ); pcVUI->setChromaSampleLocTypeTopField(uiCode); |
---|
| 590 | READ_UVLC( uiCode, "chroma_sample_loc_type_bottom_field" ); pcVUI->setChromaSampleLocTypeBottomField(uiCode); |
---|
[2] | 591 | } |
---|
| 592 | |
---|
[608] | 593 | READ_FLAG( uiCode, "neutral_chroma_indication_flag"); pcVUI->setNeutralChromaIndicationFlag(uiCode); |
---|
[2] | 594 | |
---|
[608] | 595 | READ_FLAG( uiCode, "field_seq_flag"); pcVUI->setFieldSeqFlag(uiCode); |
---|
[2] | 596 | |
---|
[608] | 597 | READ_FLAG(uiCode, "frame_field_info_present_flag"); pcVUI->setFrameFieldInfoPresentFlag(uiCode); |
---|
[56] | 598 | |
---|
[608] | 599 | READ_FLAG( uiCode, "default_display_window_flag"); |
---|
| 600 | if (uiCode != 0) |
---|
[56] | 601 | { |
---|
[608] | 602 | Window &defDisp = pcVUI->getDefaultDisplayWindow(); |
---|
[622] | 603 | #if H_MV |
---|
| 604 | defDisp.setScaledFlag( false ); |
---|
| 605 | READ_UVLC( uiCode, "def_disp_win_left_offset" ); defDisp.setWindowLeftOffset ( uiCode ); |
---|
| 606 | READ_UVLC( uiCode, "def_disp_win_right_offset" ); defDisp.setWindowRightOffset ( uiCode ); |
---|
| 607 | READ_UVLC( uiCode, "def_disp_win_top_offset" ); defDisp.setWindowTopOffset ( uiCode ); |
---|
| 608 | READ_UVLC( uiCode, "def_disp_win_bottom_offset" ); defDisp.setWindowBottomOffset( uiCode ); |
---|
| 609 | #else |
---|
| 610 | READ_UVLC( uiCode, "def_disp_win_left_offset" ); defDisp.setWindowLeftOffset ( uiCode * TComSPS::getWinUnitX( pcSPS->getChromaFormatIdc()) ); |
---|
| 611 | READ_UVLC( uiCode, "def_disp_win_right_offset" ); defDisp.setWindowRightOffset ( uiCode * TComSPS::getWinUnitX( pcSPS->getChromaFormatIdc()) ); |
---|
| 612 | READ_UVLC( uiCode, "def_disp_win_top_offset" ); defDisp.setWindowTopOffset ( uiCode * TComSPS::getWinUnitY( pcSPS->getChromaFormatIdc()) ); |
---|
| 613 | READ_UVLC( uiCode, "def_disp_win_bottom_offset" ); defDisp.setWindowBottomOffset( uiCode * TComSPS::getWinUnitY( pcSPS->getChromaFormatIdc()) ); |
---|
| 614 | #endif |
---|
[56] | 615 | } |
---|
[608] | 616 | TimingInfo *timingInfo = pcVUI->getTimingInfo(); |
---|
| 617 | READ_FLAG( uiCode, "vui_timing_info_present_flag"); timingInfo->setTimingInfoPresentFlag (uiCode ? true : false); |
---|
| 618 | if(timingInfo->getTimingInfoPresentFlag()) |
---|
[56] | 619 | { |
---|
[608] | 620 | READ_CODE( 32, uiCode, "vui_num_units_in_tick"); timingInfo->setNumUnitsInTick (uiCode); |
---|
| 621 | READ_CODE( 32, uiCode, "vui_time_scale"); timingInfo->setTimeScale (uiCode); |
---|
| 622 | READ_FLAG( uiCode, "vui_poc_proportional_to_timing_flag"); timingInfo->setPocProportionalToTimingFlag(uiCode ? true : false); |
---|
| 623 | if(timingInfo->getPocProportionalToTimingFlag()) |
---|
[2] | 624 | { |
---|
[608] | 625 | READ_UVLC( uiCode, "vui_num_ticks_poc_diff_one_minus1"); timingInfo->setNumTicksPocDiffOneMinus1 (uiCode); |
---|
[2] | 626 | } |
---|
[608] | 627 | READ_FLAG( uiCode, "hrd_parameters_present_flag"); pcVUI->setHrdParametersPresentFlag(uiCode); |
---|
| 628 | if( pcVUI->getHrdParametersPresentFlag() ) |
---|
[56] | 629 | { |
---|
[608] | 630 | parseHrdParameters( pcVUI->getHrdParameters(), 1, pcSPS->getMaxTLayers() - 1 ); |
---|
[56] | 631 | } |
---|
| 632 | } |
---|
[608] | 633 | READ_FLAG( uiCode, "bitstream_restriction_flag"); pcVUI->setBitstreamRestrictionFlag(uiCode); |
---|
| 634 | if (pcVUI->getBitstreamRestrictionFlag()) |
---|
[56] | 635 | { |
---|
[608] | 636 | READ_FLAG( uiCode, "tiles_fixed_structure_flag"); pcVUI->setTilesFixedStructureFlag(uiCode); |
---|
| 637 | READ_FLAG( uiCode, "motion_vectors_over_pic_boundaries_flag"); pcVUI->setMotionVectorsOverPicBoundariesFlag(uiCode); |
---|
| 638 | READ_FLAG( uiCode, "restricted_ref_pic_lists_flag"); pcVUI->setRestrictedRefPicListsFlag(uiCode); |
---|
| 639 | READ_UVLC( uiCode, "min_spatial_segmentation_idc"); pcVUI->setMinSpatialSegmentationIdc(uiCode); |
---|
| 640 | assert(uiCode < 4096); |
---|
| 641 | READ_UVLC( uiCode, "max_bytes_per_pic_denom" ); pcVUI->setMaxBytesPerPicDenom(uiCode); |
---|
| 642 | READ_UVLC( uiCode, "max_bits_per_mincu_denom" ); pcVUI->setMaxBitsPerMinCuDenom(uiCode); |
---|
| 643 | READ_UVLC( uiCode, "log2_max_mv_length_horizontal" ); pcVUI->setLog2MaxMvLengthHorizontal(uiCode); |
---|
| 644 | READ_UVLC( uiCode, "log2_max_mv_length_vertical" ); pcVUI->setLog2MaxMvLengthVertical(uiCode); |
---|
[56] | 645 | } |
---|
[2] | 646 | } |
---|
[56] | 647 | |
---|
[608] | 648 | Void TDecCavlc::parseHrdParameters(TComHRD *hrd, Bool commonInfPresentFlag, UInt maxNumSubLayersMinus1) |
---|
[56] | 649 | { |
---|
| 650 | UInt uiCode; |
---|
[608] | 651 | if( commonInfPresentFlag ) |
---|
[2] | 652 | { |
---|
[608] | 653 | READ_FLAG( uiCode, "nal_hrd_parameters_present_flag" ); hrd->setNalHrdParametersPresentFlag( uiCode == 1 ? true : false ); |
---|
| 654 | READ_FLAG( uiCode, "vcl_hrd_parameters_present_flag" ); hrd->setVclHrdParametersPresentFlag( uiCode == 1 ? true : false ); |
---|
| 655 | if( hrd->getNalHrdParametersPresentFlag() || hrd->getVclHrdParametersPresentFlag() ) |
---|
[2] | 656 | { |
---|
[608] | 657 | READ_FLAG( uiCode, "sub_pic_cpb_params_present_flag" ); hrd->setSubPicCpbParamsPresentFlag( uiCode == 1 ? true : false ); |
---|
| 658 | if( hrd->getSubPicCpbParamsPresentFlag() ) |
---|
[2] | 659 | { |
---|
[608] | 660 | READ_CODE( 8, uiCode, "tick_divisor_minus2" ); hrd->setTickDivisorMinus2( uiCode ); |
---|
| 661 | READ_CODE( 5, uiCode, "du_cpb_removal_delay_length_minus1" ); hrd->setDuCpbRemovalDelayLengthMinus1( uiCode ); |
---|
| 662 | READ_FLAG( uiCode, "sub_pic_cpb_params_in_pic_timing_sei_flag" ); hrd->setSubPicCpbParamsInPicTimingSEIFlag( uiCode == 1 ? true : false ); |
---|
| 663 | READ_CODE( 5, uiCode, "dpb_output_delay_du_length_minus1" ); hrd->setDpbOutputDelayDuLengthMinus1( uiCode ); |
---|
[2] | 664 | } |
---|
[608] | 665 | READ_CODE( 4, uiCode, "bit_rate_scale" ); hrd->setBitRateScale( uiCode ); |
---|
| 666 | READ_CODE( 4, uiCode, "cpb_size_scale" ); hrd->setCpbSizeScale( uiCode ); |
---|
| 667 | if( hrd->getSubPicCpbParamsPresentFlag() ) |
---|
[2] | 668 | { |
---|
[608] | 669 | READ_CODE( 4, uiCode, "cpb_size_du_scale" ); hrd->setDuCpbSizeScale( uiCode ); |
---|
[2] | 670 | } |
---|
[608] | 671 | READ_CODE( 5, uiCode, "initial_cpb_removal_delay_length_minus1" ); hrd->setInitialCpbRemovalDelayLengthMinus1( uiCode ); |
---|
| 672 | READ_CODE( 5, uiCode, "au_cpb_removal_delay_length_minus1" ); hrd->setCpbRemovalDelayLengthMinus1( uiCode ); |
---|
| 673 | READ_CODE( 5, uiCode, "dpb_output_delay_length_minus1" ); hrd->setDpbOutputDelayLengthMinus1( uiCode ); |
---|
[2] | 674 | } |
---|
| 675 | } |
---|
[608] | 676 | Int i, j, nalOrVcl; |
---|
| 677 | for( i = 0; i <= maxNumSubLayersMinus1; i ++ ) |
---|
[56] | 678 | { |
---|
[608] | 679 | READ_FLAG( uiCode, "fixed_pic_rate_general_flag" ); hrd->setFixedPicRateFlag( i, uiCode == 1 ? true : false ); |
---|
| 680 | if( !hrd->getFixedPicRateFlag( i ) ) |
---|
[2] | 681 | { |
---|
[608] | 682 | READ_FLAG( uiCode, "fixed_pic_rate_within_cvs_flag" ); hrd->setFixedPicRateWithinCvsFlag( i, uiCode == 1 ? true : false ); |
---|
[2] | 683 | } |
---|
[608] | 684 | else |
---|
[210] | 685 | { |
---|
[608] | 686 | hrd->setFixedPicRateWithinCvsFlag( i, true ); |
---|
[210] | 687 | } |
---|
[608] | 688 | hrd->setLowDelayHrdFlag( i, 0 ); // Infered to be 0 when not present |
---|
| 689 | hrd->setCpbCntMinus1 ( i, 0 ); // Infered to be 0 when not present |
---|
| 690 | if( hrd->getFixedPicRateWithinCvsFlag( i ) ) |
---|
[210] | 691 | { |
---|
[608] | 692 | READ_UVLC( uiCode, "elemental_duration_in_tc_minus1" ); hrd->setPicDurationInTcMinus1( i, uiCode ); |
---|
[210] | 693 | } |
---|
[608] | 694 | else |
---|
| 695 | { |
---|
| 696 | READ_FLAG( uiCode, "low_delay_hrd_flag" ); hrd->setLowDelayHrdFlag( i, uiCode == 1 ? true : false ); |
---|
[210] | 697 | } |
---|
[608] | 698 | if (!hrd->getLowDelayHrdFlag( i )) |
---|
[210] | 699 | { |
---|
[608] | 700 | READ_UVLC( uiCode, "cpb_cnt_minus1" ); hrd->setCpbCntMinus1( i, uiCode ); |
---|
[210] | 701 | } |
---|
[608] | 702 | for( nalOrVcl = 0; nalOrVcl < 2; nalOrVcl ++ ) |
---|
[210] | 703 | { |
---|
[608] | 704 | if( ( ( nalOrVcl == 0 ) && ( hrd->getNalHrdParametersPresentFlag() ) ) || |
---|
| 705 | ( ( nalOrVcl == 1 ) && ( hrd->getVclHrdParametersPresentFlag() ) ) ) |
---|
[77] | 706 | { |
---|
[608] | 707 | for( j = 0; j <= ( hrd->getCpbCntMinus1( i ) ); j ++ ) |
---|
[77] | 708 | { |
---|
[608] | 709 | READ_UVLC( uiCode, "bit_rate_value_minus1" ); hrd->setBitRateValueMinus1( i, j, nalOrVcl, uiCode ); |
---|
| 710 | READ_UVLC( uiCode, "cpb_size_value_minus1" ); hrd->setCpbSizeValueMinus1( i, j, nalOrVcl, uiCode ); |
---|
| 711 | if( hrd->getSubPicCpbParamsPresentFlag() ) |
---|
| 712 | { |
---|
| 713 | READ_UVLC( uiCode, "cpb_size_du_value_minus1" ); hrd->setDuCpbSizeValueMinus1( i, j, nalOrVcl, uiCode ); |
---|
| 714 | READ_UVLC( uiCode, "bit_rate_du_value_minus1" ); hrd->setDuBitRateValueMinus1( i, j, nalOrVcl, uiCode ); |
---|
| 715 | } |
---|
| 716 | READ_FLAG( uiCode, "cbr_flag" ); hrd->setCbrFlag( i, j, nalOrVcl, uiCode == 1 ? true : false ); |
---|
[77] | 717 | } |
---|
| 718 | } |
---|
| 719 | } |
---|
| 720 | } |
---|
| 721 | } |
---|
| 722 | |
---|
[1124] | 723 | Void TDecCavlc::parseSPS(TComSPS* pcSPS) |
---|
[2] | 724 | { |
---|
[56] | 725 | #if ENC_DEC_TRACE |
---|
| 726 | xTraceSPSHeader (pcSPS); |
---|
| 727 | #endif |
---|
[608] | 728 | |
---|
[56] | 729 | UInt uiCode; |
---|
[608] | 730 | READ_CODE( 4, uiCode, "sps_video_parameter_set_id"); pcSPS->setVPSId ( uiCode ); |
---|
[1066] | 731 | |
---|
[608] | 732 | #if H_MV |
---|
| 733 | if ( pcSPS->getLayerId() == 0 ) |
---|
| 734 | { |
---|
[210] | 735 | #endif |
---|
[976] | 736 | READ_CODE( 3, uiCode, "sps_max_sub_layers_minus1" ); pcSPS->setMaxTLayers ( uiCode+1 ); |
---|
| 737 | assert(uiCode <= 6); |
---|
[1066] | 738 | #if H_MV |
---|
| 739 | } |
---|
| 740 | else |
---|
| 741 | { |
---|
| 742 | READ_CODE( 3, uiCode, "sps_ext_or_max_sub_layers_minus1" ); pcSPS->setSpsExtOrMaxSubLayersMinus1( uiCode ); |
---|
| 743 | pcSPS->inferSpsMaxSubLayersMinus1( false, NULL ); |
---|
| 744 | } |
---|
| 745 | if ( !pcSPS->getMultiLayerExtSpsFlag() ) |
---|
| 746 | { |
---|
| 747 | #endif |
---|
[976] | 748 | |
---|
| 749 | READ_FLAG( uiCode, "sps_temporal_id_nesting_flag" ); pcSPS->setTemporalIdNestingFlag ( uiCode > 0 ? true : false ); |
---|
| 750 | if ( pcSPS->getMaxTLayers() == 1 ) |
---|
| 751 | { |
---|
| 752 | // sps_temporal_id_nesting_flag must be 1 when sps_max_sub_layers_minus1 is 0 |
---|
| 753 | assert( uiCode == 1 ); |
---|
| 754 | } |
---|
| 755 | |
---|
| 756 | parsePTL(pcSPS->getPTL(), 1, pcSPS->getMaxTLayers() - 1); |
---|
[1084] | 757 | #if H_MV |
---|
[1066] | 758 | pcSPS->getPTL()->inferGeneralValues ( true, 0, NULL ); |
---|
| 759 | pcSPS->getPTL()->inferSubLayerValues( pcSPS->getMaxTLayers() - 1, 0, NULL ); |
---|
[608] | 760 | } |
---|
[77] | 761 | #endif |
---|
[608] | 762 | READ_UVLC( uiCode, "sps_seq_parameter_set_id" ); pcSPS->setSPSId( uiCode ); |
---|
| 763 | assert(uiCode <= 15); |
---|
[622] | 764 | #if H_MV |
---|
[1066] | 765 | if ( pcSPS->getMultiLayerExtSpsFlag() ) |
---|
[622] | 766 | { |
---|
| 767 | READ_FLAG( uiCode, "update_rep_format_flag" ); pcSPS->setUpdateRepFormatFlag( uiCode == 1 ); |
---|
[738] | 768 | if ( pcSPS->getUpdateRepFormatFlag() ) |
---|
| 769 | { |
---|
| 770 | READ_CODE( 8, uiCode, "sps_rep_format_idx" ); pcSPS->setSpsRepFormatIdx( uiCode ); |
---|
| 771 | } |
---|
[622] | 772 | } |
---|
[738] | 773 | else |
---|
| 774 | { |
---|
[622] | 775 | #endif |
---|
[976] | 776 | READ_UVLC( uiCode, "chroma_format_idc" ); pcSPS->setChromaFormatIdc( uiCode ); |
---|
| 777 | assert(uiCode <= 3); |
---|
| 778 | // 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 |
---|
| 779 | assert (uiCode == 1); |
---|
| 780 | if( uiCode == 3 ) |
---|
| 781 | { |
---|
| 782 | READ_FLAG( uiCode, "separate_colour_plane_flag"); assert(uiCode == 0); |
---|
| 783 | } |
---|
[608] | 784 | |
---|
[976] | 785 | READ_UVLC ( uiCode, "pic_width_in_luma_samples" ); pcSPS->setPicWidthInLumaSamples ( uiCode ); |
---|
| 786 | READ_UVLC ( uiCode, "pic_height_in_luma_samples" ); pcSPS->setPicHeightInLumaSamples( uiCode ); |
---|
[608] | 787 | READ_FLAG( uiCode, "conformance_window_flag"); |
---|
[56] | 788 | if (uiCode != 0) |
---|
[2] | 789 | { |
---|
[608] | 790 | Window &conf = pcSPS->getConformanceWindow(); |
---|
[622] | 791 | #if H_MV |
---|
| 792 | // Needs to be scaled later, when ChromaFormatIdc is known. |
---|
| 793 | conf.setScaledFlag( false ); |
---|
| 794 | READ_UVLC( uiCode, "conf_win_left_offset" ); conf.setWindowLeftOffset ( uiCode ); |
---|
| 795 | READ_UVLC( uiCode, "conf_win_right_offset" ); conf.setWindowRightOffset ( uiCode ); |
---|
| 796 | READ_UVLC( uiCode, "conf_win_top_offset" ); conf.setWindowTopOffset ( uiCode ); |
---|
| 797 | READ_UVLC( uiCode, "conf_win_bottom_offset" ); conf.setWindowBottomOffset( uiCode ); |
---|
[1066] | 798 | } |
---|
[622] | 799 | #else |
---|
[608] | 800 | READ_UVLC( uiCode, "conf_win_left_offset" ); conf.setWindowLeftOffset ( uiCode * TComSPS::getWinUnitX( pcSPS->getChromaFormatIdc() ) ); |
---|
| 801 | READ_UVLC( uiCode, "conf_win_right_offset" ); conf.setWindowRightOffset ( uiCode * TComSPS::getWinUnitX( pcSPS->getChromaFormatIdc() ) ); |
---|
| 802 | READ_UVLC( uiCode, "conf_win_top_offset" ); conf.setWindowTopOffset ( uiCode * TComSPS::getWinUnitY( pcSPS->getChromaFormatIdc() ) ); |
---|
| 803 | READ_UVLC( uiCode, "conf_win_bottom_offset" ); conf.setWindowBottomOffset( uiCode * TComSPS::getWinUnitY( pcSPS->getChromaFormatIdc() ) ); |
---|
[622] | 804 | #endif |
---|
[2] | 805 | } |
---|
| 806 | |
---|
[622] | 807 | #if H_MV |
---|
[1066] | 808 | if ( !pcSPS->getMultiLayerExtSpsFlag() ) |
---|
[622] | 809 | { |
---|
| 810 | #endif |
---|
[976] | 811 | READ_UVLC( uiCode, "bit_depth_luma_minus8" ); |
---|
| 812 | assert(uiCode <= 6); |
---|
| 813 | pcSPS->setBitDepthY( uiCode + 8 ); |
---|
| 814 | pcSPS->setQpBDOffsetY( (Int) (6*uiCode) ); |
---|
[2] | 815 | |
---|
[976] | 816 | READ_UVLC( uiCode, "bit_depth_chroma_minus8" ); |
---|
| 817 | assert(uiCode <= 6); |
---|
| 818 | pcSPS->setBitDepthC( uiCode + 8 ); |
---|
| 819 | pcSPS->setQpBDOffsetC( (Int) (6*uiCode) ); |
---|
[622] | 820 | #if H_MV |
---|
| 821 | } |
---|
| 822 | #endif |
---|
[2] | 823 | |
---|
[608] | 824 | READ_UVLC( uiCode, "log2_max_pic_order_cnt_lsb_minus4" ); pcSPS->setBitsForPOC( 4 + uiCode ); |
---|
| 825 | assert(uiCode <= 12); |
---|
[56] | 826 | |
---|
[884] | 827 | #if H_MV |
---|
[1066] | 828 | if ( !pcSPS->getMultiLayerExtSpsFlag()) |
---|
[872] | 829 | { |
---|
| 830 | #endif |
---|
[976] | 831 | UInt subLayerOrderingInfoPresentFlag; |
---|
| 832 | READ_FLAG(subLayerOrderingInfoPresentFlag, "sps_sub_layer_ordering_info_present_flag"); |
---|
[608] | 833 | |
---|
[976] | 834 | for(UInt i=0; i <= pcSPS->getMaxTLayers()-1; i++) |
---|
[608] | 835 | { |
---|
[976] | 836 | READ_UVLC ( uiCode, "sps_max_dec_pic_buffering_minus1[i]"); |
---|
| 837 | pcSPS->setMaxDecPicBuffering( uiCode + 1, i); |
---|
| 838 | READ_UVLC ( uiCode, "sps_num_reorder_pics[i]" ); |
---|
| 839 | pcSPS->setNumReorderPics(uiCode, i); |
---|
| 840 | READ_UVLC ( uiCode, "sps_max_latency_increase_plus1[i]"); |
---|
| 841 | pcSPS->setMaxLatencyIncrease( uiCode, i ); |
---|
| 842 | |
---|
| 843 | if (!subLayerOrderingInfoPresentFlag) |
---|
[608] | 844 | { |
---|
[976] | 845 | for (i++; i <= pcSPS->getMaxTLayers()-1; i++) |
---|
| 846 | { |
---|
| 847 | pcSPS->setMaxDecPicBuffering(pcSPS->getMaxDecPicBuffering(0), i); |
---|
| 848 | pcSPS->setNumReorderPics(pcSPS->getNumReorderPics(0), i); |
---|
| 849 | pcSPS->setMaxLatencyIncrease(pcSPS->getMaxLatencyIncrease(0), i); |
---|
| 850 | } |
---|
| 851 | break; |
---|
[608] | 852 | } |
---|
| 853 | } |
---|
[884] | 854 | #if H_MV |
---|
[872] | 855 | } |
---|
| 856 | #endif |
---|
[2] | 857 | |
---|
[56] | 858 | READ_UVLC( uiCode, "log2_min_coding_block_size_minus3" ); |
---|
[608] | 859 | Int log2MinCUSize = uiCode + 3; |
---|
| 860 | pcSPS->setLog2MinCodingBlockSize(log2MinCUSize); |
---|
[56] | 861 | READ_UVLC( uiCode, "log2_diff_max_min_coding_block_size" ); |
---|
[608] | 862 | pcSPS->setLog2DiffMaxMinCodingBlockSize(uiCode); |
---|
[976] | 863 | |
---|
[872] | 864 | if (pcSPS->getPTL()->getGeneralPTL()->getLevelIdc() >= Level::LEVEL5) |
---|
| 865 | { |
---|
| 866 | assert(log2MinCUSize + pcSPS->getLog2DiffMaxMinCodingBlockSize() >= 5); |
---|
| 867 | } |
---|
[976] | 868 | |
---|
[608] | 869 | Int maxCUDepthDelta = uiCode; |
---|
| 870 | pcSPS->setMaxCUWidth ( 1<<(log2MinCUSize + maxCUDepthDelta) ); |
---|
| 871 | pcSPS->setMaxCUHeight ( 1<<(log2MinCUSize + maxCUDepthDelta) ); |
---|
[56] | 872 | READ_UVLC( uiCode, "log2_min_transform_block_size_minus2" ); pcSPS->setQuadtreeTULog2MinSize( uiCode + 2 ); |
---|
[2] | 873 | |
---|
[56] | 874 | READ_UVLC( uiCode, "log2_diff_max_min_transform_block_size" ); pcSPS->setQuadtreeTULog2MaxSize( uiCode + pcSPS->getQuadtreeTULog2MinSize() ); |
---|
| 875 | pcSPS->setMaxTrSize( 1<<(uiCode + pcSPS->getQuadtreeTULog2MinSize()) ); |
---|
[2] | 876 | |
---|
[608] | 877 | READ_UVLC( uiCode, "max_transform_hierarchy_depth_inter" ); pcSPS->setQuadtreeTUMaxDepthInter( uiCode+1 ); |
---|
| 878 | READ_UVLC( uiCode, "max_transform_hierarchy_depth_intra" ); pcSPS->setQuadtreeTUMaxDepthIntra( uiCode+1 ); |
---|
[2] | 879 | |
---|
[608] | 880 | Int addCuDepth = max (0, log2MinCUSize - (Int)pcSPS->getQuadtreeTULog2MinSize() ); |
---|
| 881 | pcSPS->setMaxCUDepth( maxCUDepthDelta + addCuDepth ); |
---|
[2] | 882 | |
---|
[56] | 883 | READ_FLAG( uiCode, "scaling_list_enabled_flag" ); pcSPS->setScalingListFlag ( uiCode ); |
---|
[608] | 884 | if(pcSPS->getScalingListFlag()) |
---|
[2] | 885 | { |
---|
[622] | 886 | #if H_MV |
---|
[1066] | 887 | if ( pcSPS->getMultiLayerExtSpsFlag() ) |
---|
[622] | 888 | { |
---|
| 889 | READ_FLAG( uiCode, "sps_infer_scaling_list_flag" ); pcSPS->setSpsInferScalingListFlag( uiCode == 1 ); |
---|
| 890 | } |
---|
| 891 | |
---|
| 892 | if ( pcSPS->getSpsInferScalingListFlag() ) |
---|
| 893 | { |
---|
| 894 | READ_CODE( 6, uiCode, "sps_scaling_list_ref_layer_id" ); pcSPS->setSpsScalingListRefLayerId( uiCode ); |
---|
| 895 | } |
---|
| 896 | else |
---|
| 897 | { |
---|
| 898 | #endif |
---|
[976] | 899 | READ_FLAG( uiCode, "sps_scaling_list_data_present_flag" ); pcSPS->setScalingListPresentFlag ( uiCode ); |
---|
| 900 | if(pcSPS->getScalingListPresentFlag ()) |
---|
| 901 | { |
---|
| 902 | parseScalingList( pcSPS->getScalingList() ); |
---|
| 903 | } |
---|
[622] | 904 | #if H_MV |
---|
| 905 | } |
---|
| 906 | #endif |
---|
[56] | 907 | } |
---|
[608] | 908 | READ_FLAG( uiCode, "amp_enabled_flag" ); pcSPS->setUseAMP( uiCode ); |
---|
| 909 | READ_FLAG( uiCode, "sample_adaptive_offset_enabled_flag" ); pcSPS->setUseSAO ( uiCode ? true : false ); |
---|
| 910 | |
---|
| 911 | READ_FLAG( uiCode, "pcm_enabled_flag" ); pcSPS->setUsePCM( uiCode ? true : false ); |
---|
[56] | 912 | if( pcSPS->getUsePCM() ) |
---|
| 913 | { |
---|
[608] | 914 | READ_CODE( 4, uiCode, "pcm_sample_bit_depth_luma_minus1" ); pcSPS->setPCMBitDepthLuma ( 1 + uiCode ); |
---|
| 915 | READ_CODE( 4, uiCode, "pcm_sample_bit_depth_chroma_minus1" ); pcSPS->setPCMBitDepthChroma ( 1 + uiCode ); |
---|
| 916 | READ_UVLC( uiCode, "log2_min_pcm_luma_coding_block_size_minus3" ); pcSPS->setPCMLog2MinSize (uiCode+3); |
---|
| 917 | READ_UVLC( uiCode, "log2_diff_max_min_pcm_luma_coding_block_size" ); pcSPS->setPCMLog2MaxSize ( uiCode+pcSPS->getPCMLog2MinSize() ); |
---|
| 918 | READ_FLAG( uiCode, "pcm_loop_filter_disable_flag" ); pcSPS->setPCMFilterDisableFlag ( uiCode ? true : false ); |
---|
[56] | 919 | } |
---|
[2] | 920 | |
---|
[608] | 921 | READ_UVLC( uiCode, "num_short_term_ref_pic_sets" ); |
---|
| 922 | assert(uiCode <= 64); |
---|
| 923 | pcSPS->createRPSList(uiCode); |
---|
[2] | 924 | |
---|
[56] | 925 | TComRPSList* rpsList = pcSPS->getRPSList(); |
---|
| 926 | TComReferencePictureSet* rps; |
---|
[2] | 927 | |
---|
[56] | 928 | for(UInt i=0; i< rpsList->getNumberOfReferencePictureSets(); i++) |
---|
[2] | 929 | { |
---|
[56] | 930 | rps = rpsList->getReferencePictureSet(i); |
---|
| 931 | parseShortTermRefPicSet(pcSPS,rps,i); |
---|
[2] | 932 | } |
---|
[56] | 933 | READ_FLAG( uiCode, "long_term_ref_pics_present_flag" ); pcSPS->setLongTermRefsPresent(uiCode); |
---|
[608] | 934 | if (pcSPS->getLongTermRefsPresent()) |
---|
[56] | 935 | { |
---|
[608] | 936 | READ_UVLC( uiCode, "num_long_term_ref_pic_sps" ); |
---|
| 937 | pcSPS->setNumLongTermRefPicSPS(uiCode); |
---|
| 938 | for (UInt k = 0; k < pcSPS->getNumLongTermRefPicSPS(); k++) |
---|
| 939 | { |
---|
| 940 | READ_CODE( pcSPS->getBitsForPOC(), uiCode, "lt_ref_pic_poc_lsb_sps" ); |
---|
| 941 | pcSPS->setLtRefPicPocLsbSps(k, uiCode); |
---|
| 942 | READ_FLAG( uiCode, "used_by_curr_pic_lt_sps_flag[i]"); |
---|
| 943 | pcSPS->setUsedByCurrPicLtSPSFlag(k, uiCode?1:0); |
---|
| 944 | } |
---|
[56] | 945 | } |
---|
[608] | 946 | READ_FLAG( uiCode, "sps_temporal_mvp_enable_flag" ); pcSPS->setTMVPFlagsPresent(uiCode); |
---|
[2] | 947 | |
---|
[608] | 948 | READ_FLAG( uiCode, "sps_strong_intra_smoothing_enable_flag" ); pcSPS->setUseStrongIntraSmoothing(uiCode); |
---|
[2] | 949 | |
---|
[608] | 950 | READ_FLAG( uiCode, "vui_parameters_present_flag" ); pcSPS->setVuiParametersPresentFlag(uiCode); |
---|
| 951 | |
---|
| 952 | if (pcSPS->getVuiParametersPresentFlag()) |
---|
[2] | 953 | { |
---|
[608] | 954 | parseVUI(pcSPS->getVuiParameters(), pcSPS); |
---|
| 955 | } |
---|
| 956 | |
---|
[964] | 957 | |
---|
[773] | 958 | #if H_MV |
---|
[964] | 959 | READ_FLAG( uiCode, "sps_extension_present_flag"); |
---|
| 960 | pcSPS->setSpsExtensionPresentFlag( uiCode ); |
---|
| 961 | if (pcSPS->getSpsExtensionPresentFlag( ) ) |
---|
[773] | 962 | #else |
---|
[964] | 963 | READ_FLAG( uiCode, "sps_extension_flag"); |
---|
[773] | 964 | if (uiCode) |
---|
[738] | 965 | #endif |
---|
[608] | 966 | { |
---|
[622] | 967 | #if H_MV |
---|
[964] | 968 | READ_FLAG( uiCode, "sps_range_extensions_flag" ); pcSPS->setSpsRangeExtensionsFlag( uiCode == 1 ); |
---|
| 969 | READ_FLAG( uiCode, "sps_multilayer_extension_flag" ); pcSPS->setSpsMultilayerExtensionFlag( uiCode == 1 ); |
---|
| 970 | #if !H_3D |
---|
| 971 | READ_CODE( 6, uiCode, "sps_extension_6bits" ); pcSPS->setSpsExtension6bits( uiCode ); |
---|
| 972 | #else |
---|
| 973 | READ_FLAG( uiCode, "sps_3d_extension_flag" ); pcSPS->setSps3dExtensionFlag( uiCode == 1 ); |
---|
| 974 | READ_CODE( 5, uiCode, "sps_extension_5bits" ); pcSPS->setSpsExtension5bits( uiCode ); |
---|
| 975 | #endif |
---|
| 976 | } |
---|
| 977 | |
---|
| 978 | if ( pcSPS->getSpsRangeExtensionsFlag() ) |
---|
| 979 | { |
---|
| 980 | assert( 0 ); |
---|
| 981 | } |
---|
| 982 | |
---|
| 983 | if ( pcSPS->getSpsMultilayerExtensionFlag() ) |
---|
| 984 | { |
---|
| 985 | parseSPSExtension( pcSPS ); |
---|
| 986 | } |
---|
| 987 | |
---|
| 988 | #if H_3D |
---|
| 989 | if ( pcSPS->getSps3dExtensionFlag() ) |
---|
| 990 | { |
---|
[1124] | 991 | parseSPS3dExtension( pcSPS ); |
---|
[964] | 992 | } |
---|
| 993 | |
---|
| 994 | if ( pcSPS->getSpsExtension5bits() ) |
---|
| 995 | { |
---|
| 996 | #else |
---|
| 997 | if ( pcSPS->getSpsExtension6bits() ) |
---|
| 998 | { |
---|
| 999 | #endif |
---|
[976] | 1000 | |
---|
[738] | 1001 | #endif |
---|
[976] | 1002 | while ( xMoreRbspData() ) |
---|
[738] | 1003 | { |
---|
[976] | 1004 | READ_FLAG( uiCode, "sps_extension_data_flag"); |
---|
[738] | 1005 | } |
---|
[622] | 1006 | } |
---|
| 1007 | } |
---|
[655] | 1008 | |
---|
| 1009 | #if H_MV |
---|
[622] | 1010 | Void TDecCavlc::parseSPSExtension( TComSPS* pcSPS ) |
---|
| 1011 | { |
---|
| 1012 | UInt uiCode; |
---|
| 1013 | READ_FLAG( uiCode, "inter_view_mv_vert_constraint_flag" ); pcSPS->setInterViewMvVertConstraintFlag(uiCode == 1 ? true : false); |
---|
[738] | 1014 | |
---|
[622] | 1015 | } |
---|
[56] | 1016 | |
---|
[622] | 1017 | #if H_3D |
---|
[1124] | 1018 | Void TDecCavlc::parseSPS3dExtension( TComSPS* pcSPS ) |
---|
| 1019 | { |
---|
| 1020 | TComSps3dExtension* sps3dExt = pcSPS->getSps3dExtension(); |
---|
| 1021 | UInt uiCode; |
---|
| 1022 | for( Int d = 0; d <= 1; d++ ) |
---|
| 1023 | { |
---|
| 1024 | READ_FLAG( uiCode, "iv_mv_pred_flag" ); sps3dExt->setIvMvPredFlag( d, uiCode == 1 ); |
---|
| 1025 | READ_FLAG( uiCode, "iv_mv_scaling_flag" ); sps3dExt->setIvMvScalingFlag( d, uiCode == 1 ); |
---|
| 1026 | if( d == 0 ) |
---|
| 1027 | { |
---|
| 1028 | READ_UVLC( uiCode, "log2_sub_pb_size_minus3" ); sps3dExt->setLog2SubPbSizeMinus3( d, uiCode ); |
---|
| 1029 | READ_FLAG( uiCode, "iv_res_pred_flag" ); sps3dExt->setIvResPredFlag( d, uiCode == 1 ); |
---|
| 1030 | READ_FLAG( uiCode, "depth_refinement_flag" ); sps3dExt->setDepthRefinementFlag( d, uiCode == 1 ); |
---|
| 1031 | READ_FLAG( uiCode, "view_synthesis_pred_flag" ); sps3dExt->setViewSynthesisPredFlag( d, uiCode == 1 ); |
---|
| 1032 | READ_FLAG( uiCode, "depth_based_blk_part_flag" ); sps3dExt->setDepthBasedBlkPartFlag( d, uiCode == 1 ); |
---|
| 1033 | } |
---|
| 1034 | else |
---|
| 1035 | { |
---|
| 1036 | READ_FLAG( uiCode, "mpi_flag" ); sps3dExt->setMpiFlag( d, uiCode == 1 ); |
---|
| 1037 | READ_UVLC( uiCode, "log2_mpi_sub_pb_size_minus3" ); sps3dExt->setLog2MpiSubPbSizeMinus3( d, uiCode ); |
---|
| 1038 | READ_FLAG( uiCode, "intra_contour_flag" ); sps3dExt->setIntraContourFlag( d, uiCode == 1 ); |
---|
| 1039 | READ_FLAG( uiCode, "intra_sdc_wedge_flag" ); sps3dExt->setIntraSdcWedgeFlag( d, uiCode == 1 ); |
---|
| 1040 | READ_FLAG( uiCode, "qt_pred_flag" ); sps3dExt->setQtPredFlag( d, uiCode == 1 ); |
---|
| 1041 | READ_FLAG( uiCode, "inter_sdc_flag" ); sps3dExt->setInterSdcFlag( d, uiCode == 1 ); |
---|
| 1042 | READ_FLAG( uiCode, "intra_single_flag" ); sps3dExt->setIntraSingleFlag( d, uiCode == 1 ); |
---|
| 1043 | } |
---|
| 1044 | } |
---|
| 1045 | } |
---|
[622] | 1046 | #endif |
---|
[1066] | 1047 | |
---|
| 1048 | Void TDecCavlc::parsePPSMultilayerExtension(TComPPS* pcPPS) |
---|
| 1049 | { |
---|
| 1050 | UInt uiCode = 0; |
---|
| 1051 | READ_FLAG( uiCode, "poc_reset_info_present_flag" ); pcPPS->setPocResetInfoPresentFlag( uiCode == 1 ); |
---|
| 1052 | READ_FLAG( uiCode, "pps_infer_scaling_list_flag" ); pcPPS->setPpsInferScalingListFlag( uiCode == 1 ); |
---|
| 1053 | READ_CODE( 6, uiCode, "pps_scaling_list_ref_layer_id" ); pcPPS->setPpsScalingListRefLayerId( uiCode ); |
---|
[1124] | 1054 | |
---|
| 1055 | UInt numRefLocOffsets;; |
---|
| 1056 | READ_UVLC( numRefLocOffsets, "num_ref_loc_offsets" ); |
---|
| 1057 | |
---|
| 1058 | // All of the following stuff is not needed, but allowed to be present. |
---|
| 1059 | for (Int i = 0; i < numRefLocOffsets; i++ ) |
---|
| 1060 | { |
---|
| 1061 | Int iCode = 0; |
---|
| 1062 | READ_CODE( 6, uiCode, "ref_loc_offset_layer_id" ); |
---|
| 1063 | READ_FLAG( uiCode, "scaled_ref_layer_offset_present_flag" ); |
---|
| 1064 | |
---|
| 1065 | if (uiCode) |
---|
| 1066 | { |
---|
| 1067 | READ_SVLC( iCode, "scaled_ref_layer_left_offset" ); |
---|
| 1068 | READ_SVLC( iCode, "scaled_ref_layer_top_offset" ); |
---|
| 1069 | READ_SVLC( iCode, "scaled_ref_layer_right_offset" ); |
---|
| 1070 | READ_SVLC( iCode, "scaled_ref_layer_bottom_offset" ); |
---|
| 1071 | } |
---|
| 1072 | |
---|
| 1073 | READ_FLAG( uiCode, "ref_region_offset_present_flag" ); |
---|
| 1074 | if (uiCode) |
---|
| 1075 | { |
---|
| 1076 | READ_SVLC( iCode, "ref_region_left_offset" ); |
---|
| 1077 | READ_SVLC( iCode, "ref_region_top_offset" ); |
---|
| 1078 | READ_SVLC( iCode, "ref_region_right_offset" ); |
---|
| 1079 | READ_SVLC( iCode, "ref_region_bottom_offset" ); |
---|
| 1080 | } |
---|
| 1081 | |
---|
| 1082 | READ_FLAG( uiCode, "resample_phase_set_present_flag" ); |
---|
| 1083 | if (uiCode) |
---|
| 1084 | { |
---|
| 1085 | READ_UVLC( uiCode, "phase_hor_luma" ); |
---|
| 1086 | READ_UVLC( uiCode, "phase_ver_luma" ); |
---|
| 1087 | READ_UVLC( uiCode, "phase_hor_chroma_plus8" ); |
---|
| 1088 | READ_UVLC( uiCode, "phase_ver_chroma_plus8" ); |
---|
| 1089 | } |
---|
| 1090 | } |
---|
| 1091 | READ_FLAG( uiCode, "colour_mapping_enabled_flag" ); |
---|
| 1092 | // This is required to equal to 0 for Multiview Main profile. |
---|
| 1093 | assert( uiCode == 0 ); |
---|
[1066] | 1094 | } |
---|
| 1095 | |
---|
[622] | 1096 | #endif |
---|
| 1097 | |
---|
[608] | 1098 | Void TDecCavlc::parseVPS(TComVPS* pcVPS) |
---|
| 1099 | { |
---|
| 1100 | UInt uiCode; |
---|
| 1101 | |
---|
| 1102 | READ_CODE( 4, uiCode, "vps_video_parameter_set_id" ); pcVPS->setVPSId( uiCode ); |
---|
[976] | 1103 | #if H_MV |
---|
[964] | 1104 | READ_FLAG( uiCode, "vps_base_layer_internal_flag" ); pcVPS->setVpsBaseLayerInternalFlag( uiCode == 1 ); |
---|
[1066] | 1105 | READ_FLAG( uiCode, "vps_base_layer_available_flag" ); pcVPS->setVpsBaseLayerAvailableFlag( uiCode == 1 ); |
---|
| 1106 | #else |
---|
[608] | 1107 | READ_CODE( 2, uiCode, "vps_reserved_three_2bits" ); assert(uiCode == 3); |
---|
[964] | 1108 | #endif |
---|
[608] | 1109 | #if H_MV |
---|
[738] | 1110 | READ_CODE( 6, uiCode, "vps_max_layers_minus1" ); pcVPS->setMaxLayersMinus1( std::min( uiCode, (UInt) ( MAX_NUM_LAYER_IDS-1) ) ); |
---|
| 1111 | #else |
---|
[608] | 1112 | READ_CODE( 6, uiCode, "vps_reserved_zero_6bits" ); assert(uiCode == 0); |
---|
| 1113 | #endif |
---|
[964] | 1114 | READ_CODE( 3, uiCode, "vps_max_sub_layers_minus1" ); pcVPS->setMaxTLayers( uiCode + 1 ); assert(uiCode+1 <= MAX_TLAYER); |
---|
[608] | 1115 | READ_FLAG( uiCode, "vps_temporal_id_nesting_flag" ); pcVPS->setTemporalNestingFlag( uiCode ? true:false ); |
---|
| 1116 | assert (pcVPS->getMaxTLayers()>1||pcVPS->getTemporalNestingFlag()); |
---|
[872] | 1117 | |
---|
| 1118 | READ_CODE( 16, uiCode, "vps_reserved_ffff_16bits" ); assert(uiCode == 0xffff); |
---|
[608] | 1119 | parsePTL ( pcVPS->getPTL(), true, pcVPS->getMaxTLayers()-1); |
---|
[1066] | 1120 | #if H_MV |
---|
| 1121 | pcVPS->getPTL()->inferGeneralValues ( true, 0, NULL ); |
---|
| 1122 | pcVPS->getPTL()->inferSubLayerValues( pcVPS->getMaxTLayers() - 1, 0, NULL ); |
---|
| 1123 | #endif |
---|
[608] | 1124 | UInt subLayerOrderingInfoPresentFlag; |
---|
| 1125 | READ_FLAG(subLayerOrderingInfoPresentFlag, "vps_sub_layer_ordering_info_present_flag"); |
---|
| 1126 | for(UInt i = 0; i <= pcVPS->getMaxTLayers()-1; i++) |
---|
| 1127 | { |
---|
| 1128 | READ_UVLC( uiCode, "vps_max_dec_pic_buffering_minus1[i]" ); pcVPS->setMaxDecPicBuffering( uiCode + 1, i ); |
---|
| 1129 | READ_UVLC( uiCode, "vps_num_reorder_pics[i]" ); pcVPS->setNumReorderPics( uiCode, i ); |
---|
| 1130 | READ_UVLC( uiCode, "vps_max_latency_increase_plus1[i]" ); pcVPS->setMaxLatencyIncrease( uiCode, i ); |
---|
| 1131 | |
---|
| 1132 | if (!subLayerOrderingInfoPresentFlag) |
---|
| 1133 | { |
---|
| 1134 | for (i++; i <= pcVPS->getMaxTLayers()-1; i++) |
---|
[56] | 1135 | { |
---|
[608] | 1136 | pcVPS->setMaxDecPicBuffering(pcVPS->getMaxDecPicBuffering(0), i); |
---|
| 1137 | pcVPS->setNumReorderPics(pcVPS->getNumReorderPics(0), i); |
---|
| 1138 | pcVPS->setMaxLatencyIncrease(pcVPS->getMaxLatencyIncrease(0), i); |
---|
[56] | 1139 | } |
---|
[608] | 1140 | break; |
---|
[2] | 1141 | } |
---|
[608] | 1142 | } |
---|
[56] | 1143 | |
---|
[608] | 1144 | assert( pcVPS->getNumHrdParameters() < MAX_VPS_OP_SETS_PLUS1 ); |
---|
| 1145 | #if H_MV |
---|
| 1146 | assert( pcVPS->getVpsMaxLayerId() < MAX_VPS_NUH_LAYER_ID_PLUS1 ); |
---|
| 1147 | READ_CODE( 6, uiCode, "vps_max_layer_id" ); pcVPS->setVpsMaxLayerId( uiCode ); |
---|
| 1148 | |
---|
[1066] | 1149 | READ_UVLC( uiCode, "vps_num_layer_sets_minus1" ); pcVPS->setVpsNumLayerSetsMinus1( uiCode ); |
---|
[608] | 1150 | for( UInt opsIdx = 1; opsIdx <= pcVPS->getVpsNumLayerSetsMinus1(); opsIdx ++ ) |
---|
| 1151 | { |
---|
| 1152 | for( UInt i = 0; i <= pcVPS->getVpsMaxLayerId(); i ++ ) |
---|
| 1153 | #else |
---|
| 1154 | assert( pcVPS->getMaxNuhReservedZeroLayerId() < MAX_VPS_NUH_RESERVED_ZERO_LAYER_ID_PLUS1 ); |
---|
| 1155 | READ_CODE( 6, uiCode, "vps_max_nuh_reserved_zero_layer_id" ); pcVPS->setMaxNuhReservedZeroLayerId( uiCode ); |
---|
| 1156 | READ_UVLC( uiCode, "vps_max_op_sets_minus1" ); pcVPS->setMaxOpSets( uiCode + 1 ); |
---|
| 1157 | for( UInt opsIdx = 1; opsIdx <= ( pcVPS->getMaxOpSets() - 1 ); opsIdx ++ ) |
---|
| 1158 | { |
---|
| 1159 | // Operation point set |
---|
| 1160 | for( UInt i = 0; i <= pcVPS->getMaxNuhReservedZeroLayerId(); i ++ ) |
---|
| 1161 | #endif |
---|
[2] | 1162 | { |
---|
[608] | 1163 | READ_FLAG( uiCode, "layer_id_included_flag[opsIdx][i]" ); pcVPS->setLayerIdIncludedFlag( uiCode == 1 ? true : false, opsIdx, i ); |
---|
[2] | 1164 | } |
---|
| 1165 | } |
---|
[773] | 1166 | #if H_MV |
---|
[738] | 1167 | pcVPS->deriveLayerSetLayerIdList(); |
---|
| 1168 | #endif |
---|
[608] | 1169 | TimingInfo *timingInfo = pcVPS->getTimingInfo(); |
---|
| 1170 | READ_FLAG( uiCode, "vps_timing_info_present_flag"); timingInfo->setTimingInfoPresentFlag (uiCode ? true : false); |
---|
| 1171 | if(timingInfo->getTimingInfoPresentFlag()) |
---|
[2] | 1172 | { |
---|
[608] | 1173 | READ_CODE( 32, uiCode, "vps_num_units_in_tick"); timingInfo->setNumUnitsInTick (uiCode); |
---|
| 1174 | READ_CODE( 32, uiCode, "vps_time_scale"); timingInfo->setTimeScale (uiCode); |
---|
| 1175 | READ_FLAG( uiCode, "vps_poc_proportional_to_timing_flag"); timingInfo->setPocProportionalToTimingFlag(uiCode ? true : false); |
---|
| 1176 | if(timingInfo->getPocProportionalToTimingFlag()) |
---|
[2] | 1177 | { |
---|
[608] | 1178 | READ_UVLC( uiCode, "vps_num_ticks_poc_diff_one_minus1"); timingInfo->setNumTicksPocDiffOneMinus1 (uiCode); |
---|
| 1179 | } |
---|
| 1180 | READ_UVLC( uiCode, "vps_num_hrd_parameters" ); pcVPS->setNumHrdParameters( uiCode ); |
---|
[56] | 1181 | |
---|
[608] | 1182 | if( pcVPS->getNumHrdParameters() > 0 ) |
---|
| 1183 | { |
---|
| 1184 | pcVPS->createHrdParamBuffer(); |
---|
| 1185 | } |
---|
| 1186 | for( UInt i = 0; i < pcVPS->getNumHrdParameters(); i ++ ) |
---|
| 1187 | { |
---|
| 1188 | READ_UVLC( uiCode, "hrd_op_set_idx" ); pcVPS->setHrdOpSetIdx( uiCode, i ); |
---|
| 1189 | if( i > 0 ) |
---|
[2] | 1190 | { |
---|
[608] | 1191 | READ_FLAG( uiCode, "cprms_present_flag[i]" ); pcVPS->setCprmsPresentFlag( uiCode == 1 ? true : false, i ); |
---|
[2] | 1192 | } |
---|
[1084] | 1193 | else |
---|
| 1194 | { |
---|
| 1195 | pcVPS->setCprmsPresentFlag( true, i ); |
---|
| 1196 | } |
---|
| 1197 | |
---|
[608] | 1198 | parseHrdParameters(pcVPS->getHrdParameters(i), pcVPS->getCprmsPresentFlag( i ), pcVPS->getMaxTLayers() - 1); |
---|
[56] | 1199 | } |
---|
[608] | 1200 | } |
---|
[976] | 1201 | #if H_MV |
---|
[964] | 1202 | READ_FLAG( uiCode, "vps_extension_flag" ); pcVPS->setVpsExtensionFlag( uiCode == 1 ? true : false ); |
---|
| 1203 | if ( pcVPS->getVpsExtensionFlag() ) |
---|
| 1204 | #else |
---|
[608] | 1205 | READ_FLAG( uiCode, "vps_extension_flag" ); |
---|
| 1206 | if (uiCode) |
---|
[964] | 1207 | #endif |
---|
[608] | 1208 | { |
---|
| 1209 | #if H_MV |
---|
| 1210 | m_pcBitstream->readOutTrailingBits(); |
---|
[622] | 1211 | parseVPSExtension( pcVPS ); |
---|
| 1212 | READ_FLAG( uiCode, "vps_extension2_flag" ); |
---|
| 1213 | if (uiCode) |
---|
| 1214 | { |
---|
| 1215 | #if H_3D |
---|
[1124] | 1216 | READ_FLAG( uiCode, "vps_3d_extension_flag" ); |
---|
| 1217 | if ( uiCode ) |
---|
| 1218 | { |
---|
| 1219 | m_pcBitstream->readOutTrailingBits(); |
---|
| 1220 | pcVPS->createCamPars(pcVPS->getNumViews()); |
---|
| 1221 | parseVPS3dExtension( pcVPS ); |
---|
| 1222 | } |
---|
| 1223 | READ_FLAG( uiCode, "vps_extension3_flag" ); |
---|
| 1224 | if (uiCode) |
---|
| 1225 | { |
---|
[622] | 1226 | #endif |
---|
| 1227 | #endif |
---|
| 1228 | while ( xMoreRbspData() ) |
---|
| 1229 | { |
---|
| 1230 | READ_FLAG( uiCode, "vps_extension_data_flag"); |
---|
| 1231 | } |
---|
| 1232 | #if H_MV |
---|
| 1233 | #if H_3D |
---|
| 1234 | } |
---|
| 1235 | #endif |
---|
| 1236 | } |
---|
| 1237 | #endif |
---|
| 1238 | } |
---|
[655] | 1239 | return; |
---|
[622] | 1240 | } |
---|
[2] | 1241 | |
---|
[622] | 1242 | #if H_MV |
---|
| 1243 | Void TDecCavlc::parseVPSExtension( TComVPS* pcVPS ) |
---|
| 1244 | { |
---|
| 1245 | UInt uiCode; |
---|
[872] | 1246 | |
---|
[1066] | 1247 | if( pcVPS->getMaxLayersMinus1() > 0 && pcVPS->getVpsBaseLayerInternalFlag() ) |
---|
| 1248 | { |
---|
| 1249 | parsePTL( pcVPS->getPTL( 1 ),0, pcVPS->getMaxSubLayersMinus1() ); |
---|
| 1250 | |
---|
| 1251 | pcVPS->getPTL( 1 )->inferGeneralValues ( false, 1, pcVPS->getPTL( 0 ) ); |
---|
| 1252 | pcVPS->getPTL( 1 )->inferSubLayerValues( pcVPS->getMaxSubLayersMinus1(), 1, pcVPS->getPTL( 0 ) ); |
---|
| 1253 | } |
---|
| 1254 | |
---|
[622] | 1255 | READ_FLAG( uiCode, "splitting_flag" ); pcVPS->setSplittingFlag( uiCode == 1 ? true : false ); |
---|
| 1256 | |
---|
| 1257 | for( Int sIdx = 0; sIdx < MAX_NUM_SCALABILITY_TYPES; sIdx++ ) |
---|
| 1258 | { |
---|
| 1259 | READ_FLAG( uiCode, "scalability_mask_flag[i]" ); pcVPS->setScalabilityMaskFlag( sIdx, uiCode == 1 ? true : false ); |
---|
| 1260 | } |
---|
| 1261 | |
---|
| 1262 | for( Int sIdx = 0; sIdx < pcVPS->getNumScalabilityTypes( ) - ( pcVPS->getSplittingFlag() ? 1 : 0 ); sIdx++ ) |
---|
| 1263 | { |
---|
| 1264 | READ_CODE( 3, uiCode, "dimension_id_len_minus1[j]" ); pcVPS->setDimensionIdLen( sIdx, uiCode + 1 ); |
---|
| 1265 | } |
---|
| 1266 | |
---|
| 1267 | if ( pcVPS->getSplittingFlag() ) |
---|
| 1268 | { |
---|
| 1269 | pcVPS->setDimensionIdLen( pcVPS->getNumScalabilityTypes( ) - 1, pcVPS->inferLastDimsionIdLenMinus1() ); |
---|
| 1270 | } |
---|
| 1271 | |
---|
| 1272 | READ_FLAG( uiCode, "vps_nuh_layer_id_present_flag" ); pcVPS->setVpsNuhLayerIdPresentFlag( uiCode == 1 ? true : false ); |
---|
| 1273 | |
---|
| 1274 | for( Int i = 1; i <= pcVPS->getMaxLayersMinus1(); i++ ) |
---|
| 1275 | { |
---|
| 1276 | if ( pcVPS->getVpsNuhLayerIdPresentFlag() ) |
---|
| 1277 | { |
---|
| 1278 | READ_CODE( 6, uiCode, "layer_id_in_nuh[i]" ); pcVPS->setLayerIdInNuh( i, uiCode ); |
---|
| 1279 | } |
---|
| 1280 | else |
---|
| 1281 | { |
---|
| 1282 | pcVPS->setLayerIdInNuh( i, i );; |
---|
| 1283 | } |
---|
| 1284 | |
---|
| 1285 | pcVPS->setLayerIdInVps( pcVPS->getLayerIdInNuh( i ), i ); |
---|
| 1286 | |
---|
| 1287 | for( Int j = 0; j < pcVPS->getNumScalabilityTypes() ; j++ ) |
---|
| 1288 | { |
---|
| 1289 | if ( !pcVPS->getSplittingFlag() ) |
---|
| 1290 | { |
---|
| 1291 | READ_CODE( pcVPS->getDimensionIdLen( j ), uiCode, "dimension_id[i][j]" ); pcVPS->setDimensionId( i, j, uiCode ); |
---|
| 1292 | } |
---|
| 1293 | else |
---|
| 1294 | { |
---|
| 1295 | pcVPS->setDimensionId( i, j, pcVPS->inferDimensionId( i, j) ); |
---|
| 1296 | } |
---|
| 1297 | } |
---|
| 1298 | } |
---|
| 1299 | |
---|
[1124] | 1300 | pcVPS->initNumViews(); |
---|
| 1301 | |
---|
[738] | 1302 | READ_CODE( 4, uiCode, "view_id_len" ); pcVPS->setViewIdLen( uiCode ); |
---|
| 1303 | |
---|
| 1304 | if ( pcVPS->getViewIdLen( ) > 0 ) |
---|
| 1305 | { |
---|
| 1306 | for( Int i = 0; i < pcVPS->getNumViews(); i++ ) |
---|
| 1307 | { |
---|
| 1308 | READ_CODE( pcVPS->getViewIdLen( ), uiCode, "view_id_val[i]" ); pcVPS->setViewIdVal( i, uiCode ); |
---|
| 1309 | } |
---|
| 1310 | } |
---|
| 1311 | else |
---|
| 1312 | { |
---|
| 1313 | for( Int i = 0; i < pcVPS->getNumViews(); i++ ) |
---|
| 1314 | { |
---|
| 1315 | pcVPS->setViewIdVal( i, 0 ); |
---|
| 1316 | } |
---|
| 1317 | } |
---|
[622] | 1318 | |
---|
| 1319 | |
---|
| 1320 | for( Int i = 1; i <= pcVPS->getMaxLayersMinus1(); i++ ) |
---|
| 1321 | { |
---|
| 1322 | for( Int j = 0; j < i; j++ ) |
---|
| 1323 | { |
---|
| 1324 | READ_FLAG( uiCode, "direct_dependency_flag[i][j]" ); pcVPS->setDirectDependencyFlag( i, j, uiCode ); |
---|
| 1325 | } |
---|
| 1326 | } |
---|
[738] | 1327 | pcVPS->setRefLayers(); |
---|
[1066] | 1328 | |
---|
| 1329 | if ( pcVPS->getNumIndependentLayers() > 1 ) |
---|
| 1330 | { |
---|
| 1331 | READ_UVLC( uiCode, "num_add_layer_sets" ); pcVPS->setNumAddLayerSets( uiCode ); |
---|
| 1332 | } |
---|
| 1333 | for (Int i = 0; i < pcVPS->getNumAddLayerSets(); i++) |
---|
| 1334 | { |
---|
| 1335 | for (Int j = 1; j < pcVPS->getNumIndependentLayers(); j++) |
---|
| 1336 | { |
---|
| 1337 | READ_CODE( pcVPS->getHighestLayerIdxPlus1Len( j ) , uiCode, "highest_layer_idx_plus1" ); pcVPS->setHighestLayerIdxPlus1( i, j, uiCode ); |
---|
| 1338 | } |
---|
| 1339 | pcVPS->deriveAddLayerSetLayerIdList( i ); |
---|
| 1340 | } |
---|
| 1341 | |
---|
[738] | 1342 | READ_FLAG( uiCode, "vps_sub_layers_max_minus1_present_flag" ); pcVPS->setVpsSubLayersMaxMinus1PresentFlag( uiCode == 1 ); |
---|
| 1343 | if ( pcVPS->getVpsSubLayersMaxMinus1PresentFlag() ) |
---|
| 1344 | { |
---|
[872] | 1345 | for (Int i = 0; i <= pcVPS->getMaxLayersMinus1(); i++ ) |
---|
[738] | 1346 | { |
---|
| 1347 | READ_CODE( 3, uiCode, "sub_layers_vps_max_minus1" ); pcVPS->setSubLayersVpsMaxMinus1( i, uiCode ); |
---|
| 1348 | pcVPS->checkSubLayersVpsMaxMinus1( i ); |
---|
| 1349 | } |
---|
| 1350 | } |
---|
| 1351 | else |
---|
| 1352 | { |
---|
[872] | 1353 | for (Int i = 0; i <= pcVPS->getMaxLayersMinus1(); i++ ) |
---|
[738] | 1354 | { |
---|
| 1355 | pcVPS->setSubLayersVpsMaxMinus1( i, pcVPS->getMaxTLayers( ) - 1); |
---|
| 1356 | } |
---|
| 1357 | } |
---|
[622] | 1358 | READ_FLAG( uiCode, "max_tid_ref_present_flag" ); pcVPS->setMaxTidRefPresentFlag( uiCode == 1 ); |
---|
| 1359 | |
---|
| 1360 | if ( pcVPS->getMaxTidRefPresentFlag() ) |
---|
| 1361 | { |
---|
| 1362 | for( Int i = 0; i < pcVPS->getMaxLayersMinus1(); i++ ) |
---|
| 1363 | { |
---|
[738] | 1364 | for( Int j = i + 1; j <= pcVPS->getMaxLayersMinus1(); j++ ) |
---|
| 1365 | { |
---|
| 1366 | if ( pcVPS->getDirectDependencyFlag(j,i) ) |
---|
| 1367 | { |
---|
| 1368 | READ_CODE( 3, uiCode, "max_tid_il_ref_pics_plus1" ); pcVPS->setMaxTidIlRefPicsPlus1( i, j, uiCode ); |
---|
| 1369 | } |
---|
| 1370 | } |
---|
[622] | 1371 | } |
---|
| 1372 | } |
---|
| 1373 | |
---|
| 1374 | READ_FLAG( uiCode, "all_ref_layers_active_flag" ); pcVPS->setAllRefLayersActiveFlag( uiCode == 1 ); |
---|
[872] | 1375 | READ_UVLC( uiCode, "vps_num_profile_tier_level_minus1" ); pcVPS->setVpsNumProfileTierLevelMinus1( uiCode ); |
---|
[884] | 1376 | |
---|
[1066] | 1377 | Int offsetVal = ( pcVPS->getMaxLayersMinus1() > 0 && pcVPS->getVpsBaseLayerInternalFlag() ) ? 2 : 1; |
---|
| 1378 | for( Int i = pcVPS->getVpsBaseLayerInternalFlag() ? 2 : 1; i <= pcVPS->getVpsNumProfileTierLevelMinus1(); i++ ) |
---|
| 1379 | { |
---|
| 1380 | READ_FLAG( uiCode, "vps_profile_present_flag[i]" ); pcVPS->setVpsProfilePresentFlag( i, uiCode == 1 ); |
---|
| 1381 | parsePTL ( pcVPS->getPTL( offsetVal ), pcVPS->getVpsProfilePresentFlag( i ), pcVPS->getMaxTLayers()-1); |
---|
| 1382 | pcVPS->getPTL( offsetVal )->inferGeneralValues ( pcVPS->getVpsProfilePresentFlag( i ), offsetVal, pcVPS->getPTL( offsetVal - 1 ) ); |
---|
| 1383 | pcVPS->getPTL( offsetVal )->inferSubLayerValues( pcVPS->getMaxSubLayersMinus1() , offsetVal, pcVPS->getPTL( offsetVal - 1 ) ); |
---|
| 1384 | offsetVal++; |
---|
| 1385 | } |
---|
[622] | 1386 | |
---|
[1066] | 1387 | |
---|
[964] | 1388 | if (pcVPS->getNumLayerSets() > 1) |
---|
| 1389 | { |
---|
| 1390 | READ_UVLC( uiCode, "num_add_olss" ); pcVPS->setNumAddOlss( uiCode ); |
---|
| 1391 | READ_CODE( 2, uiCode, "default_output_layer_idc" ); pcVPS->setDefaultOutputLayerIdc( std::min( uiCode, (UInt) 2 ) ); |
---|
| 1392 | } |
---|
| 1393 | |
---|
[872] | 1394 | pcVPS->initTargetLayerIdLists( ); |
---|
[964] | 1395 | |
---|
[872] | 1396 | |
---|
[738] | 1397 | pcVPS->setOutputLayerFlag(0, 0, pcVPS->inferOutputLayerFlag( 0, 0 )); |
---|
[964] | 1398 | pcVPS->setLayerSetIdxForOlsMinus1(0, -1); |
---|
[872] | 1399 | |
---|
[1066] | 1400 | pcVPS->deriveNecessaryLayerFlags( 0 ); |
---|
[872] | 1401 | pcVPS->deriveTargetLayerIdList( 0 ); |
---|
[964] | 1402 | |
---|
[1066] | 1403 | if (pcVPS->getVpsBaseLayerInternalFlag() ) |
---|
| 1404 | { |
---|
| 1405 | pcVPS->setProfileTierLevelIdx(0,0, pcVPS->inferProfileTierLevelIdx(0,0) ); |
---|
| 1406 | } |
---|
[872] | 1407 | for( Int i = 1; i < pcVPS->getNumOutputLayerSets( ); i++ ) |
---|
| 1408 | { |
---|
[1124] | 1409 | if( pcVPS->getNumLayerSets() > 2 && i >= pcVPS->getNumLayerSets( ) ) |
---|
[622] | 1410 | { |
---|
[1066] | 1411 | READ_CODE( pcVPS->getLayerSetIdxForOlsMinus1Len( i ), uiCode, "layer_set_idx_for_ols_minus1[i]" ); pcVPS->setLayerSetIdxForOlsMinus1( i, uiCode ); |
---|
[872] | 1412 | } |
---|
| 1413 | |
---|
[964] | 1414 | if ( i > pcVPS->getVpsNumLayerSetsMinus1() || pcVPS->getDefaultOutputLayerIdc() == 2 ) |
---|
[872] | 1415 | { |
---|
[964] | 1416 | for( Int j = 0; j < pcVPS->getNumLayersInIdList( pcVPS->olsIdxToLsIdx( i ) ); j++ ) |
---|
[872] | 1417 | { |
---|
| 1418 | READ_FLAG( uiCode, "output_layer_flag" ); pcVPS->setOutputLayerFlag( i, j, uiCode == 1 ); |
---|
| 1419 | } |
---|
| 1420 | } |
---|
| 1421 | else |
---|
| 1422 | { |
---|
[964] | 1423 | for( Int j = 0; j < pcVPS->getNumLayersInIdList( pcVPS->olsIdxToLsIdx( i ) ); j++ ) |
---|
[872] | 1424 | { |
---|
| 1425 | pcVPS->setOutputLayerFlag(i,j, pcVPS->inferOutputLayerFlag( i, j )); |
---|
| 1426 | } |
---|
| 1427 | } |
---|
[1066] | 1428 | pcVPS->deriveNecessaryLayerFlags( i ); |
---|
[872] | 1429 | pcVPS->deriveTargetLayerIdList( i ); |
---|
[884] | 1430 | |
---|
[1066] | 1431 | for ( Int j = 0; j < pcVPS->getNumLayersInIdList( pcVPS->olsIdxToLsIdx(i)); j++ ) |
---|
| 1432 | { |
---|
| 1433 | if (pcVPS->getNecessaryLayerFlag( i, j ) && pcVPS->getVpsNumProfileTierLevelMinus1() > 0 ) |
---|
| 1434 | { |
---|
| 1435 | READ_CODE( pcVPS->getProfileTierLevelIdxLen(), uiCode,"profile_tier_level_idx[ i ][ j ]" ); pcVPS->setProfileTierLevelIdx( i, j, uiCode ); |
---|
| 1436 | } |
---|
| 1437 | if (pcVPS->getNecessaryLayerFlag( i, j ) && pcVPS->getVpsNumProfileTierLevelMinus1() == 0 ) |
---|
| 1438 | { |
---|
| 1439 | pcVPS->setProfileTierLevelIdx( i , j, pcVPS->inferProfileTierLevelIdx( i, j) ); |
---|
| 1440 | } |
---|
| 1441 | } |
---|
| 1442 | |
---|
[872] | 1443 | if( pcVPS->getNumOutputLayersInOutputLayerSet( i ) == 1 && pcVPS->getNumDirectRefLayers( pcVPS->getOlsHighestOutputLayerId( i ) ) > 0 ) |
---|
| 1444 | { |
---|
| 1445 | READ_FLAG( uiCode, "alt_output_layer_flag[ i ]" ); pcVPS->setAltOutputLayerFlag( i, uiCode == 1 ); |
---|
| 1446 | } |
---|
[622] | 1447 | } |
---|
[872] | 1448 | |
---|
[964] | 1449 | READ_UVLC( uiCode, "vps_num_rep_formats_minus1" ); pcVPS->setVpsNumRepFormatsMinus1( uiCode ); |
---|
[622] | 1450 | |
---|
| 1451 | for (Int i = 0; i <= pcVPS->getVpsNumRepFormatsMinus1(); i++ ) |
---|
| 1452 | { |
---|
| 1453 | assert( pcVPS->getRepFormat(i) == NULL ); |
---|
[738] | 1454 | TComRepFormat* curRepFormat = new TComRepFormat(); |
---|
| 1455 | TComRepFormat* prevRepFormat = i > 0 ? pcVPS->getRepFormat( i - 1) : NULL; |
---|
| 1456 | parseRepFormat( i, curRepFormat , prevRepFormat); |
---|
| 1457 | pcVPS->setRepFormat(i, curRepFormat ); |
---|
[622] | 1458 | } |
---|
| 1459 | |
---|
[964] | 1460 | if ( pcVPS->getVpsNumRepFormatsMinus1() > 0 ) |
---|
| 1461 | { |
---|
| 1462 | READ_FLAG( uiCode, "rep_format_idx_present_flag" ); pcVPS->setRepFormatIdxPresentFlag( uiCode == 1 ); |
---|
| 1463 | } |
---|
[622] | 1464 | if( pcVPS->getRepFormatIdxPresentFlag() ) |
---|
| 1465 | { |
---|
[964] | 1466 | for( Int i = pcVPS->getVpsBaseLayerInternalFlag() ? 1 : 0; i <= pcVPS->getMaxLayersMinus1(); i++ ) |
---|
[622] | 1467 | { |
---|
[872] | 1468 | READ_CODE( pcVPS->getVpsRepFormatIdxLen(), uiCode, "vps_rep_format_idx[i]" ); pcVPS->setVpsRepFormatIdx( i, uiCode ); |
---|
[622] | 1469 | } |
---|
| 1470 | } |
---|
[964] | 1471 | else |
---|
| 1472 | { |
---|
| 1473 | for( Int i = pcVPS->getVpsBaseLayerInternalFlag() ? 1 : 0; i <= pcVPS->getMaxLayersMinus1(); i++ ) |
---|
| 1474 | { |
---|
| 1475 | pcVPS->setVpsRepFormatIdx( i, pcVPS->inferVpsRepFormatIdx( i ) ); |
---|
| 1476 | } |
---|
| 1477 | } |
---|
[622] | 1478 | |
---|
| 1479 | READ_FLAG( uiCode, "max_one_active_ref_layer_flag" ); pcVPS->setMaxOneActiveRefLayerFlag ( uiCode == 1 ); |
---|
[1124] | 1480 | |
---|
[872] | 1481 | READ_FLAG( uiCode, "vps_poc_lsb_aligned_flag" ); pcVPS->setVpsPocLsbAlignedFlag( uiCode == 1 ); |
---|
[738] | 1482 | for( Int i = 1; i <= pcVPS->getMaxLayersMinus1(); i++ ) |
---|
| 1483 | { |
---|
| 1484 | if( pcVPS->getNumDirectRefLayers( pcVPS->getLayerIdInNuh( i ) ) == 0 ) |
---|
| 1485 | { |
---|
| 1486 | READ_FLAG( uiCode, "poc_lsb_not_present_flag" ); pcVPS->setPocLsbNotPresentFlag( i, uiCode == 1 ); |
---|
| 1487 | } |
---|
| 1488 | } |
---|
| 1489 | |
---|
| 1490 | parseDpbSize( pcVPS ); |
---|
| 1491 | |
---|
[622] | 1492 | READ_UVLC( uiCode, "direct_dep_type_len_minus2") ; pcVPS->setDirectDepTypeLenMinus2 ( uiCode ); |
---|
| 1493 | |
---|
[738] | 1494 | READ_FLAG( uiCode, "default_direct_dependency_flag" ); pcVPS->setDefaultDirectDependencyFlag( uiCode == 1 ); |
---|
| 1495 | if ( pcVPS->getDefaultDirectDependencyFlag( ) ) |
---|
| 1496 | { |
---|
| 1497 | READ_CODE( pcVPS->getDirectDepTypeLenMinus2( ) + 2, uiCode, "default_direct_dependency_type" ); pcVPS->setDefaultDirectDependencyType( uiCode ); |
---|
| 1498 | } |
---|
| 1499 | |
---|
[964] | 1500 | for( Int i = pcVPS->getVpsBaseLayerInternalFlag() ? 1 : 2; i <= pcVPS->getMaxLayersMinus1(); i++ ) |
---|
| 1501 | { |
---|
| 1502 | for( Int j = pcVPS->getVpsBaseLayerInternalFlag() ? 0 : 1; j < i; j++ ) |
---|
[622] | 1503 | { |
---|
| 1504 | if (pcVPS->getDirectDependencyFlag( i, j) ) |
---|
| 1505 | { |
---|
[738] | 1506 | if ( pcVPS->getDefaultDirectDependencyFlag( ) ) |
---|
| 1507 | { |
---|
| 1508 | pcVPS->setDirectDependencyType( i, j , pcVPS->getDefaultDirectDependencyType( ) ); |
---|
| 1509 | } |
---|
| 1510 | else |
---|
| 1511 | { |
---|
[964] | 1512 | |
---|
[738] | 1513 | READ_CODE( pcVPS->getDirectDepTypeLenMinus2( ) + 2, uiCode, "direct_dependency_type[i][j]" ); pcVPS->setDirectDependencyType( i, j , uiCode); |
---|
| 1514 | } |
---|
| 1515 | } |
---|
| 1516 | } |
---|
| 1517 | } |
---|
[872] | 1518 | READ_UVLC( uiCode, "vps_non_vui_extension_length" ); pcVPS->setVpsNonVuiExtensionLength( uiCode ); |
---|
| 1519 | for ( Int i = 1; i <= pcVPS->getVpsNonVuiExtensionLength(); i++ ) |
---|
| 1520 | { |
---|
| 1521 | READ_CODE( 8, uiCode, "vps_non_vui_extension_data_byte" ); |
---|
| 1522 | } |
---|
| 1523 | READ_FLAG( uiCode, "vps_vui_present_flag" ); pcVPS->setVpsVuiPresentFlag( uiCode == 1 ); |
---|
[622] | 1524 | if( pcVPS->getVpsVuiPresentFlag() ) |
---|
| 1525 | { |
---|
| 1526 | m_pcBitstream->readOutTrailingBits(); // vps_vui_alignment_bit_equal_to_one |
---|
| 1527 | parseVPSVUI( pcVPS ); |
---|
| 1528 | } |
---|
[1124] | 1529 | else |
---|
[872] | 1530 | { |
---|
| 1531 | TComVPSVUI* pcVPSVUI = pcVPS->getVPSVUI( ); |
---|
| 1532 | assert( pcVPSVUI ); |
---|
| 1533 | pcVPSVUI->inferVpsVui( false ); |
---|
| 1534 | } |
---|
[622] | 1535 | pcVPS->checkVPSExtensionSyntax(); |
---|
| 1536 | } |
---|
| 1537 | |
---|
[738] | 1538 | Void TDecCavlc::parseRepFormat( Int i, TComRepFormat* pcRepFormat, TComRepFormat* pcPrevRepFormat ) |
---|
[622] | 1539 | { |
---|
| 1540 | assert( pcRepFormat ); |
---|
| 1541 | |
---|
| 1542 | UInt uiCode; |
---|
[738] | 1543 | |
---|
| 1544 | READ_CODE( 16, uiCode, "pic_width_vps_in_luma_samples" ); pcRepFormat->setPicWidthVpsInLumaSamples ( uiCode ); |
---|
| 1545 | READ_CODE( 16, uiCode, "pic_height_vps_in_luma_samples" ); pcRepFormat->setPicHeightVpsInLumaSamples( uiCode ); |
---|
| 1546 | READ_FLAG( uiCode, "chroma_and_bit_depth_vps_present_flag" ); pcRepFormat->setChromaAndBitDepthVpsPresentFlag( uiCode == 1 ); |
---|
| 1547 | |
---|
| 1548 | pcRepFormat->checkChromaAndBitDepthVpsPresentFlag( i ); |
---|
| 1549 | |
---|
| 1550 | if ( pcRepFormat->getChromaAndBitDepthVpsPresentFlag() ) |
---|
| 1551 | { |
---|
[1066] | 1552 | READ_CODE( 2, uiCode, "chroma_format_vps_idc" ); pcRepFormat->setChromaFormatVpsIdc ( uiCode ); |
---|
| 1553 | if ( pcRepFormat->getChromaFormatVpsIdc() == 3 ) |
---|
| 1554 | { |
---|
| 1555 | READ_FLAG( uiCode, "separate_colour_plane_vps_flag" ); pcRepFormat->setSeparateColourPlaneVpsFlag( uiCode == 1 ); |
---|
| 1556 | } |
---|
| 1557 | READ_CODE( 4, uiCode, "bit_depth_vps_luma_minus8" ); pcRepFormat->setBitDepthVpsLumaMinus8 ( uiCode ); |
---|
| 1558 | READ_CODE( 4, uiCode, "bit_depth_vps_chroma_minus8" ); pcRepFormat->setBitDepthVpsChromaMinus8 ( uiCode ); |
---|
[622] | 1559 | } |
---|
[738] | 1560 | else |
---|
| 1561 | { |
---|
| 1562 | pcRepFormat->inferChromaAndBitDepth(pcPrevRepFormat, false ); |
---|
| 1563 | } |
---|
[1066] | 1564 | READ_FLAG( uiCode, "conformance_window_vps_flag" ); pcRepFormat->setConformanceWindowVpsFlag( uiCode == 1 ); |
---|
| 1565 | if ( pcRepFormat->getConformanceWindowVpsFlag() ) |
---|
| 1566 | { |
---|
| 1567 | READ_UVLC( uiCode, "conf_win_vps_left_offset" ); pcRepFormat->setConfWinVpsLeftOffset( uiCode ); |
---|
| 1568 | READ_UVLC( uiCode, "conf_win_vps_right_offset" ); pcRepFormat->setConfWinVpsRightOffset( uiCode ); |
---|
| 1569 | READ_UVLC( uiCode, "conf_win_vps_top_offset" ); pcRepFormat->setConfWinVpsTopOffset( uiCode ); |
---|
| 1570 | READ_UVLC( uiCode, "conf_win_vps_bottom_offset" ); pcRepFormat->setConfWinVpsBottomOffset( uiCode ); |
---|
| 1571 | } |
---|
[622] | 1572 | } |
---|
| 1573 | |
---|
| 1574 | |
---|
| 1575 | Void TDecCavlc::parseVPSVUI( TComVPS* pcVPS ) |
---|
| 1576 | { |
---|
| 1577 | assert( pcVPS ); |
---|
| 1578 | |
---|
| 1579 | TComVPSVUI* pcVPSVUI = pcVPS->getVPSVUI( ); |
---|
| 1580 | |
---|
| 1581 | assert( pcVPSVUI ); |
---|
| 1582 | |
---|
| 1583 | UInt uiCode; |
---|
[738] | 1584 | READ_FLAG( uiCode, "cross_layer_pic_type_aligned_flag" ); pcVPSVUI->setCrossLayerPicTypeAlignedFlag( uiCode == 1 ); |
---|
| 1585 | if ( !pcVPSVUI->getCrossLayerPicTypeAlignedFlag() ) |
---|
| 1586 | { |
---|
| 1587 | READ_FLAG( uiCode, "cross_layer_irap_aligned_flag" ); pcVPSVUI->setCrossLayerIrapAlignedFlag( uiCode == 1 ); |
---|
| 1588 | } |
---|
[872] | 1589 | if( pcVPSVUI->getCrossLayerIrapAlignedFlag( ) ) |
---|
| 1590 | { |
---|
| 1591 | READ_FLAG( uiCode, "all_layers_idr_aligned_flag" ); pcVPSVUI->setAllLayersIdrAlignedFlag( uiCode == 1 ); |
---|
| 1592 | } |
---|
[622] | 1593 | READ_FLAG( uiCode, "bit_rate_present_vps_flag" ); pcVPSVUI->setBitRatePresentVpsFlag( uiCode == 1 ); |
---|
| 1594 | READ_FLAG( uiCode, "pic_rate_present_vps_flag" ); pcVPSVUI->setPicRatePresentVpsFlag( uiCode == 1 ); |
---|
| 1595 | if( pcVPSVUI->getBitRatePresentVpsFlag( ) || pcVPSVUI->getPicRatePresentVpsFlag( ) ) |
---|
| 1596 | { |
---|
[1066] | 1597 | for( Int i = pcVPS->getVpsBaseLayerInternalFlag() ? 0 : 1; i < pcVPS->getNumLayerSets(); i++ ) |
---|
[622] | 1598 | { |
---|
[964] | 1599 | for( Int j = 0; j <= pcVPS->getMaxSubLayersInLayerSetMinus1( i ); j++ ) |
---|
[622] | 1600 | { |
---|
| 1601 | if( pcVPSVUI->getBitRatePresentVpsFlag( ) ) |
---|
| 1602 | { |
---|
| 1603 | READ_FLAG( uiCode, "bit_rate_present_flag" ); pcVPSVUI->setBitRatePresentFlag( i, j, uiCode == 1 ); |
---|
| 1604 | } |
---|
| 1605 | if( pcVPSVUI->getPicRatePresentVpsFlag( ) ) |
---|
| 1606 | { |
---|
| 1607 | READ_FLAG( uiCode, "pic_rate_present_flag" ); pcVPSVUI->setPicRatePresentFlag( i, j, uiCode == 1 ); |
---|
| 1608 | } |
---|
| 1609 | if( pcVPSVUI->getBitRatePresentFlag( i, j ) ) |
---|
| 1610 | { |
---|
| 1611 | READ_CODE( 16, uiCode, "avg_bit_rate" ); pcVPSVUI->setAvgBitRate( i, j, uiCode ); |
---|
| 1612 | READ_CODE( 16, uiCode, "max_bit_rate" ); pcVPSVUI->setMaxBitRate( i, j, uiCode ); |
---|
| 1613 | } |
---|
| 1614 | if( pcVPSVUI->getPicRatePresentFlag( i, j ) ) |
---|
| 1615 | { |
---|
| 1616 | READ_CODE( 2, uiCode, "constant_pic_rate_idc" ); pcVPSVUI->setConstantPicRateIdc( i, j, uiCode ); |
---|
| 1617 | READ_CODE( 16, uiCode, "avg_pic_rate" ); pcVPSVUI->setAvgPicRate( i, j, uiCode ); |
---|
| 1618 | } |
---|
| 1619 | } |
---|
| 1620 | } |
---|
| 1621 | } |
---|
| 1622 | |
---|
[872] | 1623 | READ_FLAG( uiCode, "video_signal_info_idx_present_flag" ); pcVPSVUI->setVideoSignalInfoIdxPresentFlag( uiCode == 1 ); |
---|
| 1624 | if( pcVPSVUI->getVideoSignalInfoIdxPresentFlag() ) |
---|
| 1625 | { |
---|
| 1626 | READ_CODE( 4, uiCode, "vps_num_video_signal_info_minus1" ); pcVPSVUI->setVpsNumVideoSignalInfoMinus1( uiCode ); |
---|
| 1627 | } |
---|
| 1628 | else |
---|
| 1629 | { |
---|
[1066] | 1630 | pcVPSVUI->setVpsNumVideoSignalInfoMinus1( pcVPS->getMaxLayersMinus1() - pcVPS->getVpsBaseLayerInternalFlag() ? 0 : 1 ); |
---|
[872] | 1631 | } |
---|
| 1632 | |
---|
| 1633 | for( Int i = 0; i <= pcVPSVUI->getVpsNumVideoSignalInfoMinus1(); i++ ) |
---|
| 1634 | { |
---|
| 1635 | assert( pcVPSVUI->getVideoSignalInfo( i ) == NULL ); |
---|
| 1636 | TComVideoSignalInfo* curVideoSignalInfo = new TComVideoSignalInfo(); |
---|
| 1637 | parseVideoSignalInfo( curVideoSignalInfo ); |
---|
| 1638 | pcVPSVUI->setVideoSignalInfo(i, curVideoSignalInfo ); |
---|
| 1639 | } |
---|
| 1640 | |
---|
| 1641 | if( pcVPSVUI->getVideoSignalInfoIdxPresentFlag() && pcVPSVUI->getVpsNumVideoSignalInfoMinus1() > 0 ) |
---|
| 1642 | { |
---|
[1066] | 1643 | for( Int i = pcVPS->getVpsBaseLayerInternalFlag() ? 0 : 1; i <= pcVPS->getMaxLayersMinus1(); i++ ) |
---|
| 1644 | { |
---|
| 1645 | READ_CODE( 4, uiCode, "vps_video_signal_info_idx" ); pcVPSVUI->setVpsVideoSignalInfoIdx( i, uiCode ); |
---|
| 1646 | } |
---|
| 1647 | } |
---|
| 1648 | else if ( !pcVPSVUI->getVideoSignalInfoIdxPresentFlag() ) |
---|
| 1649 | { |
---|
| 1650 | for( Int i = pcVPS->getVpsBaseLayerInternalFlag() ? 0 : 1; i <= pcVPS->getMaxLayersMinus1(); i++ ) |
---|
| 1651 | { |
---|
| 1652 | pcVPSVUI->setVpsVideoSignalInfoIdx( i, i ); |
---|
| 1653 | } |
---|
| 1654 | } |
---|
| 1655 | else |
---|
| 1656 | { |
---|
| 1657 | for( Int i = pcVPS->getVpsBaseLayerInternalFlag() ? 0 : 1; i <= pcVPS->getMaxLayersMinus1(); i++ ) |
---|
| 1658 | { |
---|
| 1659 | pcVPSVUI->setVpsVideoSignalInfoIdx( i, 0 ); |
---|
| 1660 | } |
---|
| 1661 | } |
---|
[1084] | 1662 | |
---|
[738] | 1663 | READ_FLAG( uiCode, "tiles_not_in_use_flag" ); pcVPSVUI->setTilesNotInUseFlag( uiCode == 1 ); |
---|
| 1664 | if( !pcVPSVUI->getTilesNotInUseFlag() ) |
---|
| 1665 | { |
---|
[964] | 1666 | for( Int i = pcVPS->getVpsBaseLayerInternalFlag() ? 0 : 1; i <= pcVPS->getMaxLayersMinus1(); i++ ) |
---|
[738] | 1667 | { |
---|
| 1668 | READ_FLAG( uiCode, "tiles_in_use_flag[i]" ); pcVPSVUI->setTilesInUseFlag( i, uiCode == 1 ); |
---|
| 1669 | if( pcVPSVUI->getTilesInUseFlag( i ) ) |
---|
| 1670 | { |
---|
| 1671 | READ_FLAG( uiCode, "loop_filter_not_across_tiles_flag[i]" ); pcVPSVUI->setLoopFilterNotAcrossTilesFlag( i, uiCode == 1 ); |
---|
| 1672 | } |
---|
| 1673 | } |
---|
[964] | 1674 | for( Int i = pcVPS->getVpsBaseLayerInternalFlag() ? 1 : 2; i <= pcVPS->getMaxLayersMinus1(); i++ ) |
---|
[738] | 1675 | { |
---|
| 1676 | for( Int j = 0; j < pcVPS->getNumDirectRefLayers( pcVPS->getLayerIdInNuh( i ) ) ; j++ ) |
---|
[1066] | 1677 | { |
---|
| 1678 | Int layerIdx = pcVPS->getLayerIdInVps(pcVPS->getIdDirectRefLayer(pcVPS->getLayerIdInNuh( i ) , j )); |
---|
[738] | 1679 | if( pcVPSVUI->getTilesInUseFlag( i ) && pcVPSVUI->getTilesInUseFlag( layerIdx ) ) |
---|
| 1680 | { |
---|
| 1681 | READ_FLAG( uiCode, "tile_boundaries_aligned_flag[i][j]" ); pcVPSVUI->setTileBoundariesAlignedFlag( i, j, uiCode == 1 ); |
---|
| 1682 | } |
---|
| 1683 | } |
---|
| 1684 | } |
---|
| 1685 | } |
---|
| 1686 | |
---|
| 1687 | READ_FLAG( uiCode, "wpp_not_in_use_flag" ); pcVPSVUI->setWppNotInUseFlag( uiCode == 1 ); |
---|
| 1688 | |
---|
| 1689 | if( !pcVPSVUI->getWppNotInUseFlag( )) |
---|
| 1690 | { |
---|
| 1691 | for( Int i = 0; i <= pcVPS->getMaxLayersMinus1(); i++ ) |
---|
| 1692 | { |
---|
| 1693 | READ_FLAG( uiCode, "wpp_in_use_flag[i]" ); pcVPSVUI->setWppInUseFlag( i, uiCode == 1 ); |
---|
| 1694 | } |
---|
| 1695 | } |
---|
[1066] | 1696 | READ_FLAG( uiCode, "single_layer_for_non_irap_flag" ); pcVPSVUI->setSingleLayerForNonIrapFlag( uiCode == 1 ); |
---|
| 1697 | READ_FLAG( uiCode, "higher_layer_irap_skip_flag" ); pcVPSVUI->setHigherLayerIrapSkipFlag( uiCode == 1 ); |
---|
[622] | 1698 | READ_FLAG( uiCode, "ilp_restricted_ref_layers_flag" ); pcVPSVUI->setIlpRestrictedRefLayersFlag( uiCode == 1 ); |
---|
| 1699 | |
---|
| 1700 | if( pcVPSVUI->getIlpRestrictedRefLayersFlag( ) ) |
---|
| 1701 | { |
---|
| 1702 | for( Int i = 1; i <= pcVPS->getMaxLayersMinus1(); i++ ) |
---|
| 1703 | { |
---|
| 1704 | for( Int j = 0; j < pcVPS->getNumDirectRefLayers( pcVPS->getLayerIdInNuh( i ) ); j++ ) |
---|
| 1705 | { |
---|
[1066] | 1706 | if( pcVPS->getVpsBaseLayerInternalFlag() || pcVPS->getIdDirectRefLayer( pcVPS->getLayerIdInNuh( i ), j ) > 0 ) |
---|
[964] | 1707 | { |
---|
| 1708 | READ_UVLC( uiCode, "min_spatial_segment_offset_plus1" ); pcVPSVUI->setMinSpatialSegmentOffsetPlus1( i, j, uiCode ); |
---|
| 1709 | if( pcVPSVUI->getMinSpatialSegmentOffsetPlus1( i, j ) > 0 ) |
---|
[622] | 1710 | { |
---|
[964] | 1711 | READ_FLAG( uiCode, "ctu_based_offset_enabled_flag" ); pcVPSVUI->setCtuBasedOffsetEnabledFlag( i, j, uiCode == 1 ); |
---|
| 1712 | if( pcVPSVUI->getCtuBasedOffsetEnabledFlag( i, j ) ) |
---|
| 1713 | { |
---|
| 1714 | READ_UVLC( uiCode, "min_horizontal_ctu_offset_plus1" ); pcVPSVUI->setMinHorizontalCtuOffsetPlus1( i, j, uiCode ); |
---|
| 1715 | } |
---|
[622] | 1716 | } |
---|
| 1717 | } |
---|
| 1718 | } |
---|
| 1719 | } |
---|
| 1720 | } |
---|
[738] | 1721 | |
---|
| 1722 | READ_FLAG( uiCode, "vps_vui_bsp_hrd_present_flag" ); pcVPSVUI->setVpsVuiBspHrdPresentFlag( uiCode == 1 ); |
---|
| 1723 | if ( pcVPSVUI->getVpsVuiBspHrdPresentFlag( ) ) |
---|
| 1724 | { |
---|
[1066] | 1725 | assert(pcVPS->getTimingInfo()->getTimingInfoPresentFlag() == 1); |
---|
[738] | 1726 | parseVpsVuiBspHrdParameters( pcVPS ); |
---|
[964] | 1727 | } |
---|
[872] | 1728 | for( Int i = 1; i <= pcVPS->getMaxLayersMinus1(); i++ ) |
---|
| 1729 | { |
---|
| 1730 | if( pcVPS->getNumDirectRefLayers( pcVPS->getLayerIdInNuh( i )) == 0 ) |
---|
| 1731 | { |
---|
| 1732 | READ_FLAG( uiCode, "base_layer_parameter_set_compatibility_flag" ); pcVPSVUI->setBaseLayerParameterSetCompatibilityFlag( i, uiCode == 1 ); |
---|
| 1733 | } |
---|
| 1734 | } |
---|
[738] | 1735 | } |
---|
[622] | 1736 | |
---|
[738] | 1737 | Void TDecCavlc::parseVpsVuiBspHrdParameters( TComVPS* pcVPS ) |
---|
| 1738 | { |
---|
| 1739 | assert( pcVPS ); |
---|
| 1740 | |
---|
| 1741 | TComVPSVUI* pcVPSVUI = pcVPS->getVPSVUI( ); |
---|
| 1742 | |
---|
| 1743 | assert( pcVPSVUI ); |
---|
| 1744 | |
---|
| 1745 | TComVpsVuiBspHrdParameters* vpsVuiBspHrdP = pcVPSVUI->getVpsVuiBspHrdParameters(); |
---|
[1066] | 1746 | assert( vpsVuiBspHrdP == NULL ); |
---|
| 1747 | vpsVuiBspHrdP = new TComVpsVuiBspHrdParameters; |
---|
| 1748 | pcVPSVUI->setVpsVuiBspHrdParameters( vpsVuiBspHrdP ); |
---|
| 1749 | UInt uiCode; |
---|
| 1750 | READ_UVLC( uiCode, "vps_num_add_hrd_params" ); vpsVuiBspHrdP->setVpsNumAddHrdParams( uiCode ); |
---|
| 1751 | vpsVuiBspHrdP->createAfterVpsNumAddHrdParams( pcVPS ); |
---|
| 1752 | for( Int i = pcVPS->getNumHrdParameters(); i < pcVPS->getNumHrdParameters() + vpsVuiBspHrdP->getVpsNumAddHrdParams(); i++ ) |
---|
| 1753 | { |
---|
| 1754 | if( i > 0 ) |
---|
| 1755 | { |
---|
| 1756 | READ_FLAG( uiCode, "cprms_add_present_flag" ); vpsVuiBspHrdP->setCprmsAddPresentFlag( i, uiCode == 1 ); |
---|
| 1757 | } |
---|
| 1758 | else |
---|
| 1759 | { |
---|
| 1760 | vpsVuiBspHrdP->setCprmsAddPresentFlag( i, true ); |
---|
| 1761 | } |
---|
[738] | 1762 | |
---|
[1066] | 1763 | READ_UVLC( uiCode, "num_sub_layer_hrd_minus1" ); vpsVuiBspHrdP->setNumSubLayerHrdMinus1( i, uiCode ); |
---|
| 1764 | TComHRD* hrdParameters = vpsVuiBspHrdP->getHrdParametermeters( i ); |
---|
| 1765 | parseHrdParameters( hrdParameters, vpsVuiBspHrdP->getCprmsAddPresentFlag( i ), vpsVuiBspHrdP->getNumSubLayerHrdMinus1( i ) ); |
---|
| 1766 | } |
---|
| 1767 | |
---|
| 1768 | vpsVuiBspHrdP->setNumPartitionsInSchemeMinus1( 0, 0, 0); |
---|
| 1769 | vpsVuiBspHrdP->createAfterNumPartitionsInSchemeMinus1( 0, 0 ); |
---|
| 1770 | |
---|
| 1771 | for( Int h = 0; h < pcVPS->getNumOutputLayerSets(); h++ ) |
---|
| 1772 | { |
---|
| 1773 | if ( h == 0) |
---|
| 1774 | { |
---|
| 1775 | vpsVuiBspHrdP->setNumSignalledPartitioningSchemes( h, 0 ); |
---|
| 1776 | } |
---|
| 1777 | else |
---|
| 1778 | { |
---|
| 1779 | READ_UVLC( uiCode, "num_signalled_partitioning_schemes" ); vpsVuiBspHrdP->setNumSignalledPartitioningSchemes( h, uiCode ); |
---|
| 1780 | } |
---|
| 1781 | vpsVuiBspHrdP->createAfterNumSignalledPartitioningSchemes( h ); |
---|
| 1782 | |
---|
| 1783 | for( Int j = 0; j < vpsVuiBspHrdP->getNumSignalledPartitioningSchemes( h ) + 1; j++ ) |
---|
| 1784 | { |
---|
| 1785 | if ( j == 0 && h == 0 ) |
---|
| 1786 | { |
---|
| 1787 | vpsVuiBspHrdP->setNumPartitionsInSchemeMinus1( h, j, uiCode ); |
---|
| 1788 | } |
---|
| 1789 | else if( j == 0 ) |
---|
| 1790 | { |
---|
| 1791 | vpsVuiBspHrdP->setNumPartitionsInSchemeMinus1( h, j, pcVPS->getNumLayersInIdList( h ) - 1 ); |
---|
| 1792 | } |
---|
| 1793 | else |
---|
| 1794 | { |
---|
| 1795 | READ_UVLC( uiCode, "num_partitions_in_scheme_minus1" ); vpsVuiBspHrdP->setNumPartitionsInSchemeMinus1( h, j, uiCode ); |
---|
| 1796 | } |
---|
| 1797 | vpsVuiBspHrdP->createAfterNumPartitionsInSchemeMinus1( h, j ); |
---|
| 1798 | |
---|
| 1799 | for( Int k = 0; k <= vpsVuiBspHrdP->getNumPartitionsInSchemeMinus1( h, j ); k++ ) |
---|
| 1800 | { |
---|
| 1801 | for( Int r = 0; r < pcVPS->getNumLayersInIdList(pcVPS->olsIdxToLsIdx( h ) ) ; r++ ) |
---|
| 1802 | { |
---|
| 1803 | if( h == 0 && j == 0 && k == 0 && r == 0 ) |
---|
| 1804 | { |
---|
| 1805 | vpsVuiBspHrdP->setLayerIncludedInPartitionFlag( h, j, k, r, true ); |
---|
| 1806 | } |
---|
| 1807 | else if ( h > 0 && j == 0 ) |
---|
| 1808 | { |
---|
| 1809 | vpsVuiBspHrdP->setLayerIncludedInPartitionFlag( h, j, k, r, (k == r) ); |
---|
| 1810 | } |
---|
| 1811 | else |
---|
| 1812 | { |
---|
| 1813 | READ_FLAG( uiCode, "layer_included_in_partition_flag" ); vpsVuiBspHrdP->setLayerIncludedInPartitionFlag( h, j, k, r, uiCode == 1 ); |
---|
| 1814 | } |
---|
| 1815 | } |
---|
| 1816 | } |
---|
| 1817 | } |
---|
| 1818 | if ( h > 0 ) |
---|
| 1819 | { |
---|
| 1820 | for( Int i = 0; i < vpsVuiBspHrdP->getNumSignalledPartitioningSchemes( h ) + 1; i++ ) |
---|
| 1821 | { |
---|
| 1822 | for( Int t = 0; t <= pcVPS->getMaxSubLayersInLayerSetMinus1( pcVPS->olsIdxToLsIdx( i ) ); t++ ) |
---|
| 1823 | { |
---|
| 1824 | READ_UVLC( uiCode, "num_bsp_schedules_minus1" ); vpsVuiBspHrdP->setNumBspSchedulesMinus1( h, i, t, uiCode ); |
---|
| 1825 | vpsVuiBspHrdP->createAfterNumBspSchedulesMinus1( h, i, t ); |
---|
| 1826 | for( Int j = 0; j <= vpsVuiBspHrdP->getNumBspSchedulesMinus1( h, i, t ); j++ ) |
---|
| 1827 | { |
---|
| 1828 | for( Int k = 0; k <= vpsVuiBspHrdP->getNumPartitionsInSchemeMinus1( h, j ); k++ ) |
---|
| 1829 | { |
---|
| 1830 | READ_CODE( vpsVuiBspHrdP->getBspHrdIdxLen( pcVPS ), uiCode, "bsp_hrd_idx" ); vpsVuiBspHrdP->setBspHrdIdx( h, i, t, j, k, uiCode ); |
---|
| 1831 | READ_UVLC( uiCode, "bsp_sched_idx" ); vpsVuiBspHrdP->setBspSchedIdx( h, i, t, j, k, uiCode ); |
---|
| 1832 | } |
---|
| 1833 | } |
---|
| 1834 | } |
---|
| 1835 | } |
---|
| 1836 | } |
---|
| 1837 | } |
---|
| 1838 | } |
---|
[738] | 1839 | |
---|
| 1840 | Void TDecCavlc::parseVideoSignalInfo( TComVideoSignalInfo* pcVideoSignalInfo ) |
---|
| 1841 | { |
---|
| 1842 | UInt uiCode; |
---|
| 1843 | READ_CODE( 3, uiCode, "video_vps_format" ); pcVideoSignalInfo->setVideoVpsFormat( uiCode ); |
---|
| 1844 | READ_FLAG( uiCode, "video_full_range_vps_flag" ); pcVideoSignalInfo->setVideoFullRangeVpsFlag( uiCode == 1 ); |
---|
| 1845 | READ_CODE( 8, uiCode, "colour_primaries_vps" ); pcVideoSignalInfo->setColourPrimariesVps( uiCode ); |
---|
| 1846 | READ_CODE( 8, uiCode, "transfer_characteristics_vps" ); pcVideoSignalInfo->setTransferCharacteristicsVps( uiCode ); |
---|
| 1847 | READ_CODE( 8, uiCode, "matrix_coeffs_vps" ); pcVideoSignalInfo->setMatrixCoeffsVps( uiCode ); |
---|
| 1848 | } |
---|
| 1849 | |
---|
| 1850 | Void TDecCavlc::parseDpbSize( TComVPS* vps ) |
---|
| 1851 | { |
---|
| 1852 | UInt uiCode; |
---|
| 1853 | TComDpbSize* dpbSize = vps->getDpbSize(); |
---|
| 1854 | assert ( dpbSize != 0 ); |
---|
| 1855 | |
---|
| 1856 | for( Int i = 1; i < vps->getNumOutputLayerSets(); i++ ) |
---|
| 1857 | { |
---|
[964] | 1858 | Int currLsIdx = vps->olsIdxToLsIdx( i ); |
---|
[738] | 1859 | READ_FLAG( uiCode, "sub_layer_flag_info_present_flag" ); dpbSize->setSubLayerFlagInfoPresentFlag( i, uiCode == 1 ); |
---|
[964] | 1860 | for( Int j = 0; j <= vps->getMaxSubLayersInLayerSetMinus1( currLsIdx ); j++ ) |
---|
[738] | 1861 | { |
---|
| 1862 | if( j > 0 && dpbSize->getSubLayerDpbInfoPresentFlag( i, j ) ) |
---|
| 1863 | { |
---|
| 1864 | READ_FLAG( uiCode, "sub_layer_dpb_info_present_flag" ); dpbSize->setSubLayerDpbInfoPresentFlag( i, j, uiCode == 1 ); |
---|
| 1865 | } |
---|
| 1866 | if( dpbSize->getSubLayerDpbInfoPresentFlag( i, j ) ) |
---|
| 1867 | { |
---|
[964] | 1868 | for( Int k = 0; k < vps->getNumLayersInIdList( currLsIdx ); k++ ) |
---|
[738] | 1869 | { |
---|
[1066] | 1870 | if ( vps->getNecessaryLayerFlag( i, k ) && ( vps->getVpsBaseLayerInternalFlag() || ( vps->getLayerSetLayerIdList(vps->olsIdxToLsIdx(i),k) != 0 ) )) |
---|
| 1871 | { |
---|
| 1872 | READ_UVLC( uiCode, "max_vps_dec_pic_buffering_minus1" ); dpbSize->setMaxVpsDecPicBufferingMinus1( i, k, j, uiCode ); |
---|
| 1873 | } |
---|
| 1874 | else |
---|
| 1875 | { |
---|
| 1876 | if ( vps->getNecessaryLayerFlag( i, k ) && ( j == 0 ) && ( k == 0 )) |
---|
| 1877 | { |
---|
| 1878 | dpbSize->setMaxVpsDecPicBufferingMinus1(i ,k, j, 0 ); |
---|
| 1879 | } |
---|
| 1880 | } |
---|
[738] | 1881 | } |
---|
| 1882 | READ_UVLC( uiCode, "max_vps_num_reorder_pics" ); dpbSize->setMaxVpsNumReorderPics( i, j, uiCode ); |
---|
| 1883 | READ_UVLC( uiCode, "max_vps_latency_increase_plus1" ); dpbSize->setMaxVpsLatencyIncreasePlus1( i, j, uiCode ); |
---|
| 1884 | } |
---|
| 1885 | else |
---|
| 1886 | { |
---|
| 1887 | if ( j > 0 ) |
---|
| 1888 | { |
---|
[964] | 1889 | for( Int k = 0; k < vps->getNumLayersInIdList( vps->olsIdxToLsIdx( i ) ); k++ ) |
---|
[738] | 1890 | { |
---|
[1066] | 1891 | if ( vps->getNecessaryLayerFlag(i, k ) ) |
---|
| 1892 | { |
---|
| 1893 | dpbSize->setMaxVpsDecPicBufferingMinus1( i, k, j, dpbSize->getMaxVpsDecPicBufferingMinus1( i,k, j - 1 ) ); |
---|
| 1894 | } |
---|
[738] | 1895 | } |
---|
| 1896 | dpbSize->setMaxVpsNumReorderPics ( i, j, dpbSize->getMaxVpsNumReorderPics ( i, j - 1 ) ); |
---|
| 1897 | dpbSize->setMaxVpsLatencyIncreasePlus1( i, j, dpbSize->getMaxVpsLatencyIncreasePlus1( i, j - 1 ) ); |
---|
| 1898 | } |
---|
| 1899 | } |
---|
| 1900 | } |
---|
| 1901 | } |
---|
| 1902 | } |
---|
| 1903 | |
---|
[622] | 1904 | #if H_3D |
---|
[1124] | 1905 | Void TDecCavlc::parseVPS3dExtension( TComVPS* pcVPS ) |
---|
[622] | 1906 | { |
---|
| 1907 | UInt uiCode; |
---|
[1124] | 1908 | |
---|
[773] | 1909 | |
---|
[758] | 1910 | UInt uiCamParPrecision = 0; |
---|
| 1911 | Bool bCamParSlice = false; |
---|
| 1912 | Bool bCamParPresentFlag = false; |
---|
| 1913 | |
---|
| 1914 | READ_UVLC( uiCamParPrecision, "cp_precision" ); |
---|
[1124] | 1915 | #if HHI_VIEW_ID_LIST_I5_J0107 |
---|
| 1916 | for (Int n = 1; n < pcVPS->getNumViews(); n++) |
---|
| 1917 | { |
---|
| 1918 | Int viewIndex = pcVPS->getViewOIdxList( n ); |
---|
| 1919 | #else |
---|
[1039] | 1920 | for (UInt viewIndex=1; viewIndex<pcVPS->getNumViews(); viewIndex++) |
---|
[758] | 1921 | { |
---|
[1124] | 1922 | #endif |
---|
[872] | 1923 | pcVPS->setCamParPresent ( viewIndex, false ); |
---|
| 1924 | pcVPS->setHasCamParInSliceHeader( viewIndex, false ); |
---|
[758] | 1925 | READ_FLAG( uiCode, "cp_present_flag[i]" ); bCamParPresentFlag = ( uiCode == 1); |
---|
| 1926 | if ( bCamParPresentFlag ) |
---|
| 1927 | { |
---|
| 1928 | READ_FLAG( uiCode, "cp_in_slice_segment_header_flag[i]" ); bCamParSlice = ( uiCode == 1); |
---|
| 1929 | if ( !bCamParSlice ) |
---|
| 1930 | { |
---|
[1124] | 1931 | #if HHI_VIEW_ID_LIST_I5_J0107 |
---|
| 1932 | for( UInt m = 0; m < n; n++ ) |
---|
| 1933 | { |
---|
| 1934 | Int uiBaseIndex = pcVPS->getViewOIdxList ( m ); |
---|
| 1935 | Int iCode; |
---|
| 1936 | READ_SVLC( iCode, "vps_cp_scale" ); m_aaiTempScale [ uiBaseIndex ][ viewIndex ] = iCode; |
---|
| 1937 | READ_SVLC( iCode, "vps_cp_off" ); m_aaiTempOffset [ uiBaseIndex ][ viewIndex ] = iCode; |
---|
| 1938 | READ_SVLC( iCode, "vps_cp_inv_scale_plus_scale" ); m_aaiTempScale [ viewIndex ][ uiBaseIndex ] = iCode - m_aaiTempScale [ uiBaseIndex ][ viewIndex ]; |
---|
| 1939 | READ_SVLC( iCode, "vps_cp_inv_off_plus_off" ); m_aaiTempOffset [ viewIndex ][ uiBaseIndex ] = iCode - m_aaiTempOffset[ uiBaseIndex ][ viewIndex ]; |
---|
| 1940 | } |
---|
| 1941 | } |
---|
| 1942 | pcVPS->initCamParaVPS( viewIndex, bCamParPresentFlag, uiCamParPrecision, bCamParSlice, m_aaiTempScale, m_aaiTempOffset ); |
---|
| 1943 | #else |
---|
[758] | 1944 | for( UInt uiBaseIndex = 0; uiBaseIndex < viewIndex; uiBaseIndex++ ) |
---|
| 1945 | { |
---|
| 1946 | Int iCode; |
---|
| 1947 | READ_SVLC( iCode, "vps_cp_scale" ); m_aaiTempScale [ uiBaseIndex ][ viewIndex ] = iCode; |
---|
| 1948 | READ_SVLC( iCode, "vps_cp_off" ); m_aaiTempOffset [ uiBaseIndex ][ viewIndex ] = iCode; |
---|
| 1949 | READ_SVLC( iCode, "vps_cp_inv_scale_plus_scale" ); m_aaiTempScale [ viewIndex ][ uiBaseIndex ] = iCode - m_aaiTempScale [ uiBaseIndex ][ viewIndex ]; |
---|
| 1950 | READ_SVLC( iCode, "vps_cp_inv_off_plus_off" ); m_aaiTempOffset [ viewIndex ][ uiBaseIndex ] = iCode - m_aaiTempOffset[ uiBaseIndex ][ viewIndex ]; |
---|
| 1951 | } |
---|
| 1952 | } |
---|
| 1953 | pcVPS->initCamParaVPS( viewIndex, bCamParPresentFlag, uiCamParPrecision, bCamParSlice, m_aaiTempScale, m_aaiTempOffset ); |
---|
[1124] | 1954 | #endif |
---|
[758] | 1955 | } |
---|
| 1956 | } |
---|
[622] | 1957 | } |
---|
| 1958 | #endif |
---|
[976] | 1959 | #endif |
---|
| 1960 | #if H_MV |
---|
[964] | 1961 | Void TDecCavlc::parseSliceHeader (TComSlice*& rpcSlice, ParameterSetManagerDecoder *parameterSetManager, Int targetOlsIdx) |
---|
| 1962 | #else |
---|
[608] | 1963 | Void TDecCavlc::parseSliceHeader (TComSlice*& rpcSlice, ParameterSetManagerDecoder *parameterSetManager) |
---|
[964] | 1964 | #endif |
---|
[2] | 1965 | { |
---|
[56] | 1966 | UInt uiCode; |
---|
| 1967 | Int iCode; |
---|
[608] | 1968 | |
---|
[56] | 1969 | #if ENC_DEC_TRACE |
---|
| 1970 | xTraceSliceHeader(rpcSlice); |
---|
| 1971 | #endif |
---|
[608] | 1972 | TComPPS* pps = NULL; |
---|
| 1973 | TComSPS* sps = NULL; |
---|
| 1974 | #if H_MV |
---|
| 1975 | TComVPS* vps = NULL; |
---|
| 1976 | #endif |
---|
| 1977 | |
---|
| 1978 | UInt firstSliceSegmentInPic; |
---|
| 1979 | READ_FLAG( firstSliceSegmentInPic, "first_slice_segment_in_pic_flag" ); |
---|
| 1980 | if( rpcSlice->getRapPicFlag()) |
---|
| 1981 | { |
---|
[964] | 1982 | READ_FLAG( uiCode, "no_output_of_prior_pics_flag" ); //ignored -- updated already |
---|
| 1983 | #if SETTING_NO_OUT_PIC_PRIOR |
---|
| 1984 | rpcSlice->setNoOutputPriorPicsFlag(uiCode ? true : false); |
---|
| 1985 | #else |
---|
| 1986 | rpcSlice->setNoOutputPicPrior( false ); |
---|
| 1987 | #endif |
---|
[608] | 1988 | } |
---|
[964] | 1989 | |
---|
[608] | 1990 | READ_UVLC ( uiCode, "slice_pic_parameter_set_id" ); rpcSlice->setPPSId(uiCode); |
---|
| 1991 | pps = parameterSetManager->getPrefetchedPPS(uiCode); |
---|
| 1992 | //!KS: need to add error handling code here, if PPS is not available |
---|
| 1993 | assert(pps!=0); |
---|
| 1994 | sps = parameterSetManager->getPrefetchedSPS(pps->getSPSId()); |
---|
| 1995 | //!KS: need to add error handling code here, if SPS is not available |
---|
| 1996 | assert(sps!=0); |
---|
| 1997 | #if H_MV |
---|
| 1998 | vps = parameterSetManager->getPrefetchedVPS(sps->getVPSId()); |
---|
[622] | 1999 | assert( vps != NULL ); |
---|
| 2000 | |
---|
| 2001 | sps->inferRepFormat ( vps , rpcSlice->getLayerId() ); |
---|
| 2002 | sps->inferScalingList( parameterSetManager->getActiveSPS( sps->getSpsScalingListRefLayerId() ) ); |
---|
[964] | 2003 | sps->inferSpsMaxDecPicBufferingMinus1( vps, targetOlsIdx, rpcSlice->getLayerId(), false ); |
---|
| 2004 | |
---|
[738] | 2005 | if ( sps->getVuiParametersPresentFlag() ) |
---|
| 2006 | { |
---|
| 2007 | sps->getVuiParameters()->inferVideoSignalInfo( vps, rpcSlice->getLayerId() ); |
---|
| 2008 | } |
---|
[622] | 2009 | rpcSlice->setVPS(vps); |
---|
| 2010 | rpcSlice->setViewId ( vps->getViewId ( rpcSlice->getLayerId() ) ); |
---|
| 2011 | rpcSlice->setViewIndex( vps->getViewIndex( rpcSlice->getLayerId() ) ); |
---|
| 2012 | #if H_3D |
---|
| 2013 | rpcSlice->setIsDepth ( vps->getDepthId ( rpcSlice->getLayerId() ) == 1 ); |
---|
| 2014 | #endif |
---|
[608] | 2015 | #endif |
---|
| 2016 | rpcSlice->setSPS(sps); |
---|
[1124] | 2017 | #if H_3D |
---|
| 2018 | rpcSlice->init3dToolParameters(); |
---|
| 2019 | #endif |
---|
[608] | 2020 | rpcSlice->setPPS(pps); |
---|
| 2021 | if( pps->getDependentSliceSegmentsEnabledFlag() && ( !firstSliceSegmentInPic )) |
---|
[2] | 2022 | { |
---|
[608] | 2023 | READ_FLAG( uiCode, "dependent_slice_segment_flag" ); rpcSlice->setDependentSliceSegmentFlag(uiCode ? true : false); |
---|
[2] | 2024 | } |
---|
[608] | 2025 | else |
---|
[2] | 2026 | { |
---|
[608] | 2027 | rpcSlice->setDependentSliceSegmentFlag(false); |
---|
[2] | 2028 | } |
---|
[608] | 2029 | Int numCTUs = ((sps->getPicWidthInLumaSamples()+sps->getMaxCUWidth()-1)/sps->getMaxCUWidth())*((sps->getPicHeightInLumaSamples()+sps->getMaxCUHeight()-1)/sps->getMaxCUHeight()); |
---|
| 2030 | Int maxParts = (1<<(sps->getMaxCUDepth()<<1)); |
---|
| 2031 | UInt sliceSegmentAddress = 0; |
---|
| 2032 | Int bitsSliceSegmentAddress = 0; |
---|
| 2033 | while(numCTUs>(1<<bitsSliceSegmentAddress)) |
---|
[189] | 2034 | { |
---|
[608] | 2035 | bitsSliceSegmentAddress++; |
---|
[189] | 2036 | } |
---|
| 2037 | |
---|
[608] | 2038 | if(!firstSliceSegmentInPic) |
---|
[2] | 2039 | { |
---|
[608] | 2040 | READ_CODE( bitsSliceSegmentAddress, sliceSegmentAddress, "slice_segment_address" ); |
---|
[2] | 2041 | } |
---|
[608] | 2042 | //set uiCode to equal slice start address (or dependent slice start address) |
---|
| 2043 | Int startCuAddress = maxParts*sliceSegmentAddress; |
---|
| 2044 | rpcSlice->setSliceSegmentCurStartCUAddr( startCuAddress ); |
---|
| 2045 | rpcSlice->setSliceSegmentCurEndCUAddr(numCTUs*maxParts); |
---|
[2] | 2046 | |
---|
[608] | 2047 | if (rpcSlice->getDependentSliceSegmentFlag()) |
---|
[2] | 2048 | { |
---|
[608] | 2049 | rpcSlice->setNextSlice ( false ); |
---|
| 2050 | rpcSlice->setNextSliceSegment ( true ); |
---|
[2] | 2051 | } |
---|
| 2052 | else |
---|
| 2053 | { |
---|
[608] | 2054 | rpcSlice->setNextSlice ( true ); |
---|
| 2055 | rpcSlice->setNextSliceSegment ( false ); |
---|
| 2056 | |
---|
| 2057 | rpcSlice->setSliceCurStartCUAddr(startCuAddress); |
---|
| 2058 | rpcSlice->setSliceCurEndCUAddr(numCTUs*maxParts); |
---|
[2] | 2059 | } |
---|
[608] | 2060 | |
---|
[976] | 2061 | #if H_MV |
---|
[964] | 2062 | UInt slicePicOrderCntLsb = 0; |
---|
| 2063 | #endif |
---|
| 2064 | |
---|
[608] | 2065 | if(!rpcSlice->getDependentSliceSegmentFlag()) |
---|
| 2066 | { |
---|
| 2067 | #if H_MV |
---|
[622] | 2068 | Int esb = 0; //Don't use i, otherwise will shadow something below |
---|
| 2069 | |
---|
| 2070 | if ( rpcSlice->getPPS()->getNumExtraSliceHeaderBits() > esb ) |
---|
| 2071 | { |
---|
| 2072 | esb++; |
---|
| 2073 | READ_FLAG( uiCode, "discardable_flag" ); rpcSlice->setDiscardableFlag( uiCode == 1 ); |
---|
[1066] | 2074 | if ( uiCode == 1 ) |
---|
| 2075 | { |
---|
| 2076 | assert(rpcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_TRAIL_R && |
---|
| 2077 | rpcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_TSA_R && |
---|
| 2078 | rpcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_STSA_R && |
---|
| 2079 | rpcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_RADL_R && |
---|
| 2080 | rpcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_RASL_R); |
---|
| 2081 | } |
---|
[622] | 2082 | } |
---|
| 2083 | |
---|
[738] | 2084 | if ( rpcSlice->getPPS()->getNumExtraSliceHeaderBits() > esb ) |
---|
| 2085 | { |
---|
| 2086 | esb++; |
---|
| 2087 | READ_FLAG( uiCode, "cross_layer_bla_flag" ); rpcSlice->setCrossLayerBlaFlag( uiCode == 1 ); |
---|
| 2088 | } |
---|
| 2089 | rpcSlice->checkCrossLayerBlaFlag( ); |
---|
| 2090 | |
---|
| 2091 | |
---|
[622] | 2092 | for (; esb < rpcSlice->getPPS()->getNumExtraSliceHeaderBits(); esb++) |
---|
| 2093 | #else |
---|
[608] | 2094 | for (Int i = 0; i < rpcSlice->getPPS()->getNumExtraSliceHeaderBits(); i++) |
---|
| 2095 | #endif |
---|
| 2096 | { |
---|
| 2097 | READ_FLAG(uiCode, "slice_reserved_undetermined_flag[]"); // ignored |
---|
| 2098 | } |
---|
| 2099 | |
---|
| 2100 | READ_UVLC ( uiCode, "slice_type" ); rpcSlice->setSliceType((SliceType)uiCode); |
---|
[56] | 2101 | if( pps->getOutputFlagPresentFlag() ) |
---|
[2] | 2102 | { |
---|
[608] | 2103 | READ_FLAG( uiCode, "pic_output_flag" ); rpcSlice->setPicOutputFlag( uiCode ? true : false ); |
---|
[2] | 2104 | } |
---|
[56] | 2105 | else |
---|
| 2106 | { |
---|
| 2107 | rpcSlice->setPicOutputFlag( true ); |
---|
| 2108 | } |
---|
[608] | 2109 | // in the first version chroma_format_idc is equal to one, thus colour_plane_id will not be present |
---|
| 2110 | assert (sps->getChromaFormatIdc() == 1 ); |
---|
| 2111 | // if( separate_colour_plane_flag == 1 ) |
---|
| 2112 | // colour_plane_id u(2) |
---|
| 2113 | |
---|
[738] | 2114 | |
---|
[773] | 2115 | #if H_MV |
---|
[738] | 2116 | Int iPOClsb = slicePicOrderCntLsb; // Needed later |
---|
| 2117 | if ( (rpcSlice->getLayerId() > 0 && !vps->getPocLsbNotPresentFlag( rpcSlice->getLayerIdInVps())) || !rpcSlice->getIdrPicFlag() ) |
---|
| 2118 | { |
---|
| 2119 | READ_CODE(sps->getBitsForPOC(), slicePicOrderCntLsb, "slice_pic_order_cnt_lsb"); |
---|
| 2120 | } |
---|
[964] | 2121 | rpcSlice->setSlicePicOrderCntLsb( slicePicOrderCntLsb ); |
---|
[738] | 2122 | |
---|
| 2123 | Bool picOrderCntMSBZeroFlag = false; |
---|
| 2124 | |
---|
| 2125 | // as in HM code. However are all cases for IRAP picture with NoRaslOutputFlag equal to 1 covered?? |
---|
| 2126 | picOrderCntMSBZeroFlag = picOrderCntMSBZeroFlag || ( rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP ); |
---|
| 2127 | picOrderCntMSBZeroFlag = picOrderCntMSBZeroFlag || ( rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL ); |
---|
| 2128 | picOrderCntMSBZeroFlag = picOrderCntMSBZeroFlag || ( rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP ); |
---|
| 2129 | picOrderCntMSBZeroFlag = picOrderCntMSBZeroFlag || rpcSlice->getIdrPicFlag(); |
---|
| 2130 | |
---|
| 2131 | // TBD picOrderCntMSBZeroFlag = picOrderCntMSBZeroFlag || ( rpcSlice->getLayerId() > 0 && !rpcSlice->getFirstPicInLayerDecodedFlag() ); |
---|
| 2132 | |
---|
| 2133 | Int picOrderCntMSB = 0; |
---|
| 2134 | |
---|
| 2135 | if ( !picOrderCntMSBZeroFlag ) |
---|
| 2136 | { |
---|
| 2137 | Int prevPicOrderCnt = rpcSlice->getPrevTid0POC(); |
---|
| 2138 | Int maxPicOrderCntLsb = 1 << sps->getBitsForPOC(); |
---|
| 2139 | Int prevPicOrderCntLsb = prevPicOrderCnt & (maxPicOrderCntLsb - 1); |
---|
| 2140 | Int prevPicOrderCntMsb = prevPicOrderCnt - prevPicOrderCntLsb; |
---|
| 2141 | |
---|
| 2142 | if( ( slicePicOrderCntLsb < prevPicOrderCntLsb ) && ( ( prevPicOrderCntLsb - slicePicOrderCntLsb ) >= ( maxPicOrderCntLsb / 2 ) ) ) |
---|
| 2143 | { |
---|
| 2144 | picOrderCntMSB = prevPicOrderCntMsb + maxPicOrderCntLsb; |
---|
| 2145 | } |
---|
| 2146 | else if( (slicePicOrderCntLsb > prevPicOrderCntLsb ) && ( (slicePicOrderCntLsb - prevPicOrderCntLsb ) > ( maxPicOrderCntLsb / 2 ) ) ) |
---|
| 2147 | { |
---|
| 2148 | picOrderCntMSB = prevPicOrderCntMsb - maxPicOrderCntLsb; |
---|
| 2149 | } |
---|
| 2150 | else |
---|
| 2151 | { |
---|
| 2152 | picOrderCntMSB = prevPicOrderCntMsb; |
---|
| 2153 | } |
---|
| 2154 | } |
---|
| 2155 | |
---|
| 2156 | rpcSlice->setPOC( picOrderCntMSB + slicePicOrderCntLsb ); |
---|
| 2157 | if ( rpcSlice->getPocResetFlag() ) |
---|
| 2158 | { |
---|
| 2159 | rpcSlice->setPocBeforeReset ( rpcSlice->getPOC() ); |
---|
| 2160 | rpcSlice->setPOC ( 0 ); |
---|
| 2161 | } |
---|
| 2162 | #endif |
---|
| 2163 | |
---|
[608] | 2164 | if( rpcSlice->getIdrPicFlag() ) |
---|
| 2165 | { |
---|
[773] | 2166 | #if !H_MV |
---|
[56] | 2167 | rpcSlice->setPOC(0); |
---|
[738] | 2168 | #endif |
---|
[56] | 2169 | TComReferencePictureSet* rps = rpcSlice->getLocalRPS(); |
---|
| 2170 | rps->setNumberOfNegativePictures(0); |
---|
| 2171 | rps->setNumberOfPositivePictures(0); |
---|
| 2172 | rps->setNumberOfLongtermPictures(0); |
---|
| 2173 | rps->setNumberOfPictures(0); |
---|
| 2174 | rpcSlice->setRPS(rps); |
---|
[608] | 2175 | #if H_MV |
---|
| 2176 | rpcSlice->setEnableTMVPFlag(false); |
---|
| 2177 | #endif |
---|
[56] | 2178 | } |
---|
| 2179 | else |
---|
[2] | 2180 | { |
---|
[773] | 2181 | #if !H_MV |
---|
[56] | 2182 | READ_CODE(sps->getBitsForPOC(), uiCode, "pic_order_cnt_lsb"); |
---|
| 2183 | Int iPOClsb = uiCode; |
---|
[655] | 2184 | Int iPrevPOC = rpcSlice->getPrevTid0POC(); |
---|
[56] | 2185 | Int iMaxPOClsb = 1<< sps->getBitsForPOC(); |
---|
[655] | 2186 | Int iPrevPOClsb = iPrevPOC & (iMaxPOClsb - 1); |
---|
[56] | 2187 | Int iPrevPOCmsb = iPrevPOC-iPrevPOClsb; |
---|
| 2188 | Int iPOCmsb; |
---|
| 2189 | if( ( iPOClsb < iPrevPOClsb ) && ( ( iPrevPOClsb - iPOClsb ) >= ( iMaxPOClsb / 2 ) ) ) |
---|
[2] | 2190 | { |
---|
[56] | 2191 | iPOCmsb = iPrevPOCmsb + iMaxPOClsb; |
---|
[2] | 2192 | } |
---|
[56] | 2193 | else if( (iPOClsb > iPrevPOClsb ) && ( (iPOClsb - iPrevPOClsb ) > ( iMaxPOClsb / 2 ) ) ) |
---|
| 2194 | { |
---|
| 2195 | iPOCmsb = iPrevPOCmsb - iMaxPOClsb; |
---|
| 2196 | } |
---|
| 2197 | else |
---|
| 2198 | { |
---|
| 2199 | iPOCmsb = iPrevPOCmsb; |
---|
| 2200 | } |
---|
[608] | 2201 | if ( rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP |
---|
| 2202 | || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL |
---|
| 2203 | || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP ) |
---|
[56] | 2204 | { |
---|
[608] | 2205 | // For BLA picture types, POCmsb is set to 0. |
---|
| 2206 | iPOCmsb = 0; |
---|
[56] | 2207 | } |
---|
[608] | 2208 | rpcSlice->setPOC (iPOCmsb+iPOClsb); |
---|
[622] | 2209 | #endif |
---|
[608] | 2210 | TComReferencePictureSet* rps; |
---|
| 2211 | rps = rpcSlice->getLocalRPS(); |
---|
| 2212 | rpcSlice->setRPS(rps); |
---|
| 2213 | READ_FLAG( uiCode, "short_term_ref_pic_set_sps_flag" ); |
---|
| 2214 | if(uiCode == 0) // use short-term reference picture set explicitly signalled in slice header |
---|
[964] | 2215 | { |
---|
[608] | 2216 | parseShortTermRefPicSet(sps,rps, sps->getRPSList()->getNumberOfReferencePictureSets()); |
---|
[976] | 2217 | #if H_MV |
---|
[964] | 2218 | if ( !rps->getInterRPSPrediction( ) ) |
---|
| 2219 | { // check sum of num_positive_pics and num_negative_pics |
---|
| 2220 | rps->checkMaxNumPics( |
---|
| 2221 | vps->getVpsExtensionFlag(), |
---|
[1066] | 2222 | MAX_INT, // To be replaced by MaxDbpSize |
---|
[964] | 2223 | rpcSlice->getLayerId(), |
---|
| 2224 | sps->getMaxDecPicBuffering( sps->getSpsMaxSubLayersMinus1() ) - 1 ); |
---|
| 2225 | } |
---|
| 2226 | #endif |
---|
[608] | 2227 | } |
---|
| 2228 | else // use reference to short-term reference picture set in PPS |
---|
| 2229 | { |
---|
| 2230 | Int numBits = 0; |
---|
| 2231 | while ((1 << numBits) < rpcSlice->getSPS()->getRPSList()->getNumberOfReferencePictureSets()) |
---|
[56] | 2232 | { |
---|
[608] | 2233 | numBits++; |
---|
[56] | 2234 | } |
---|
[608] | 2235 | if (numBits > 0) |
---|
[56] | 2236 | { |
---|
[608] | 2237 | READ_CODE( numBits, uiCode, "short_term_ref_pic_set_idx"); |
---|
[56] | 2238 | } |
---|
[608] | 2239 | else |
---|
[56] | 2240 | { |
---|
[608] | 2241 | uiCode = 0; |
---|
| 2242 | } |
---|
| 2243 | *rps = *(sps->getRPSList()->getReferencePictureSet(uiCode)); |
---|
| 2244 | } |
---|
| 2245 | if(sps->getLongTermRefsPresent()) |
---|
| 2246 | { |
---|
| 2247 | Int offset = rps->getNumberOfNegativePictures()+rps->getNumberOfPositivePictures(); |
---|
| 2248 | UInt numOfLtrp = 0; |
---|
| 2249 | UInt numLtrpInSPS = 0; |
---|
| 2250 | if (rpcSlice->getSPS()->getNumLongTermRefPicSPS() > 0) |
---|
| 2251 | { |
---|
| 2252 | READ_UVLC( uiCode, "num_long_term_sps"); |
---|
| 2253 | numLtrpInSPS = uiCode; |
---|
| 2254 | numOfLtrp += numLtrpInSPS; |
---|
| 2255 | rps->setNumberOfLongtermPictures(numOfLtrp); |
---|
| 2256 | } |
---|
| 2257 | Int bitsForLtrpInSPS = 0; |
---|
| 2258 | while (rpcSlice->getSPS()->getNumLongTermRefPicSPS() > (1 << bitsForLtrpInSPS)) |
---|
| 2259 | { |
---|
| 2260 | bitsForLtrpInSPS++; |
---|
| 2261 | } |
---|
| 2262 | READ_UVLC( uiCode, "num_long_term_pics"); rps->setNumberOfLongtermPictures(uiCode); |
---|
| 2263 | numOfLtrp += uiCode; |
---|
| 2264 | rps->setNumberOfLongtermPictures(numOfLtrp); |
---|
| 2265 | Int maxPicOrderCntLSB = 1 << rpcSlice->getSPS()->getBitsForPOC(); |
---|
| 2266 | Int prevDeltaMSB = 0, deltaPocMSBCycleLT = 0;; |
---|
| 2267 | for(Int j=offset+rps->getNumberOfLongtermPictures()-1, k = 0; k < numOfLtrp; j--, k++) |
---|
| 2268 | { |
---|
| 2269 | Int pocLsbLt; |
---|
| 2270 | if (k < numLtrpInSPS) |
---|
[56] | 2271 | { |
---|
[608] | 2272 | uiCode = 0; |
---|
| 2273 | if (bitsForLtrpInSPS > 0) |
---|
| 2274 | { |
---|
| 2275 | READ_CODE(bitsForLtrpInSPS, uiCode, "lt_idx_sps[i]"); |
---|
| 2276 | } |
---|
| 2277 | Int usedByCurrFromSPS=rpcSlice->getSPS()->getUsedByCurrPicLtSPSFlag(uiCode); |
---|
[2] | 2278 | |
---|
[608] | 2279 | pocLsbLt = rpcSlice->getSPS()->getLtRefPicPocLsbSps(uiCode); |
---|
| 2280 | rps->setUsed(j,usedByCurrFromSPS); |
---|
| 2281 | } |
---|
| 2282 | else |
---|
| 2283 | { |
---|
| 2284 | READ_CODE(rpcSlice->getSPS()->getBitsForPOC(), uiCode, "poc_lsb_lt"); pocLsbLt= uiCode; |
---|
| 2285 | READ_FLAG( uiCode, "used_by_curr_pic_lt_flag"); rps->setUsed(j,uiCode); |
---|
| 2286 | } |
---|
| 2287 | READ_FLAG(uiCode,"delta_poc_msb_present_flag"); |
---|
| 2288 | Bool mSBPresentFlag = uiCode ? true : false; |
---|
| 2289 | if(mSBPresentFlag) |
---|
| 2290 | { |
---|
| 2291 | READ_UVLC( uiCode, "delta_poc_msb_cycle_lt[i]" ); |
---|
| 2292 | Bool deltaFlag = false; |
---|
| 2293 | // First LTRP || First LTRP from SH |
---|
| 2294 | if( (j == offset+rps->getNumberOfLongtermPictures()-1) || (j == offset+(numOfLtrp-numLtrpInSPS)-1) ) |
---|
[56] | 2295 | { |
---|
[608] | 2296 | deltaFlag = true; |
---|
[56] | 2297 | } |
---|
[608] | 2298 | if(deltaFlag) |
---|
| 2299 | { |
---|
| 2300 | deltaPocMSBCycleLT = uiCode; |
---|
| 2301 | } |
---|
[56] | 2302 | else |
---|
| 2303 | { |
---|
[608] | 2304 | deltaPocMSBCycleLT = uiCode + prevDeltaMSB; |
---|
[56] | 2305 | } |
---|
[608] | 2306 | |
---|
| 2307 | Int pocLTCurr = rpcSlice->getPOC() - deltaPocMSBCycleLT * maxPicOrderCntLSB |
---|
| 2308 | - iPOClsb + pocLsbLt; |
---|
| 2309 | rps->setPOC (j, pocLTCurr); |
---|
| 2310 | rps->setDeltaPOC(j, - rpcSlice->getPOC() + pocLTCurr); |
---|
| 2311 | rps->setCheckLTMSBPresent(j,true); |
---|
[56] | 2312 | } |
---|
[608] | 2313 | else |
---|
| 2314 | { |
---|
| 2315 | rps->setPOC (j, pocLsbLt); |
---|
| 2316 | rps->setDeltaPOC(j, - rpcSlice->getPOC() + pocLsbLt); |
---|
| 2317 | rps->setCheckLTMSBPresent(j,false); |
---|
[655] | 2318 | |
---|
| 2319 | // reset deltaPocMSBCycleLT for first LTRP from slice header if MSB not present |
---|
| 2320 | if( j == offset+(numOfLtrp-numLtrpInSPS)-1 ) |
---|
| 2321 | { |
---|
| 2322 | deltaPocMSBCycleLT = 0; |
---|
| 2323 | } |
---|
[608] | 2324 | } |
---|
| 2325 | prevDeltaMSB = deltaPocMSBCycleLT; |
---|
| 2326 | } |
---|
| 2327 | offset += rps->getNumberOfLongtermPictures(); |
---|
| 2328 | rps->setNumberOfPictures(offset); |
---|
| 2329 | } |
---|
[976] | 2330 | #if H_MV |
---|
[964] | 2331 | if ( !rps->getInterRPSPrediction( ) ) |
---|
| 2332 | { // check sum of NumPositivePics, NumNegativePics, num_long_term_sps and num_long_term_pics |
---|
| 2333 | rps->checkMaxNumPics( |
---|
| 2334 | vps->getVpsExtensionFlag(), |
---|
[1066] | 2335 | MAX_INT, // To be replaced by MaxDbpsize |
---|
[964] | 2336 | rpcSlice->getLayerId(), |
---|
| 2337 | sps->getMaxDecPicBuffering( sps->getSpsMaxSubLayersMinus1() ) - 1 ); |
---|
| 2338 | } |
---|
| 2339 | #endif |
---|
[608] | 2340 | if ( rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP |
---|
| 2341 | || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL |
---|
| 2342 | || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP ) |
---|
| 2343 | { |
---|
| 2344 | // In the case of BLA picture types, rps data is read from slice header but ignored |
---|
| 2345 | rps = rpcSlice->getLocalRPS(); |
---|
| 2346 | rps->setNumberOfNegativePictures(0); |
---|
| 2347 | rps->setNumberOfPositivePictures(0); |
---|
| 2348 | rps->setNumberOfLongtermPictures(0); |
---|
| 2349 | rps->setNumberOfPictures(0); |
---|
| 2350 | rpcSlice->setRPS(rps); |
---|
[56] | 2351 | } |
---|
[608] | 2352 | if (rpcSlice->getSPS()->getTMVPFlagsPresent()) |
---|
[2] | 2353 | { |
---|
[1084] | 2354 | #if H_MV |
---|
[1066] | 2355 | READ_FLAG( uiCode, "slice_temporal_mvp_enabled_flag" ); |
---|
| 2356 | #else |
---|
[608] | 2357 | READ_FLAG( uiCode, "slice_temporal_mvp_enable_flag" ); |
---|
[1066] | 2358 | #endif |
---|
[608] | 2359 | rpcSlice->setEnableTMVPFlag( uiCode == 1 ? true : false ); |
---|
[56] | 2360 | } |
---|
[608] | 2361 | else |
---|
[56] | 2362 | { |
---|
[608] | 2363 | rpcSlice->setEnableTMVPFlag(false); |
---|
| 2364 | } |
---|
| 2365 | } |
---|
| 2366 | #if H_MV |
---|
[738] | 2367 | Bool interLayerPredLayerIdcPresentFlag = false; |
---|
[622] | 2368 | Int layerId = rpcSlice->getLayerId(); |
---|
[1124] | 2369 | #if H_3D |
---|
| 2370 | if( rpcSlice->getLayerId() > 0 && !vps->getAllRefLayersActiveFlag() && vps->getNumRefListLayers( layerId ) > 0 ) |
---|
| 2371 | #else |
---|
[738] | 2372 | if( rpcSlice->getLayerId() > 0 && !vps->getAllRefLayersActiveFlag() && vps->getNumDirectRefLayers( layerId ) > 0 ) |
---|
[1124] | 2373 | #endif |
---|
[738] | 2374 | { |
---|
[622] | 2375 | READ_FLAG( uiCode, "inter_layer_pred_enabled_flag" ); rpcSlice->setInterLayerPredEnabledFlag( uiCode == 1 ); |
---|
[1124] | 2376 | #if H_3D |
---|
| 2377 | if( rpcSlice->getInterLayerPredEnabledFlag() && vps->getNumRefListLayers( layerId ) > 1 ) |
---|
| 2378 | #else |
---|
[622] | 2379 | if( rpcSlice->getInterLayerPredEnabledFlag() && vps->getNumDirectRefLayers( layerId ) > 1 ) |
---|
[1124] | 2380 | #endif |
---|
[622] | 2381 | { |
---|
| 2382 | if( !vps->getMaxOneActiveRefLayerFlag()) |
---|
| 2383 | { |
---|
| 2384 | READ_CODE( rpcSlice->getNumInterLayerRefPicsMinus1Len( ), uiCode, "num_inter_layer_ref_pics_minus1" ); rpcSlice->setNumInterLayerRefPicsMinus1( uiCode ); |
---|
| 2385 | } |
---|
[1124] | 2386 | #if H_3D |
---|
| 2387 | if ( rpcSlice->getNumActiveRefLayerPics() != vps->getNumRefListLayers( layerId ) ) |
---|
| 2388 | #else |
---|
[622] | 2389 | if ( rpcSlice->getNumActiveRefLayerPics() != vps->getNumDirectRefLayers( layerId ) ) |
---|
[1124] | 2390 | #endif |
---|
[622] | 2391 | { |
---|
[738] | 2392 | interLayerPredLayerIdcPresentFlag = true; |
---|
[622] | 2393 | for( Int idx = 0; idx < rpcSlice->getNumActiveRefLayerPics(); idx++ ) |
---|
| 2394 | { |
---|
| 2395 | READ_CODE( rpcSlice->getInterLayerPredLayerIdcLen( ), uiCode, "inter_layer_pred_layer_idc" ); rpcSlice->setInterLayerPredLayerIdc( idx, uiCode ); |
---|
| 2396 | } |
---|
| 2397 | } |
---|
| 2398 | } |
---|
| 2399 | } |
---|
[738] | 2400 | if ( !interLayerPredLayerIdcPresentFlag ) |
---|
| 2401 | { |
---|
| 2402 | for( Int i = 0; i < rpcSlice->getNumActiveRefLayerPics(); i++ ) |
---|
| 2403 | { |
---|
| 2404 | rpcSlice->setInterLayerPredLayerIdc( i, rpcSlice->getRefLayerPicIdc( i ) ); |
---|
| 2405 | } |
---|
| 2406 | } |
---|
[443] | 2407 | #endif |
---|
[608] | 2408 | if(sps->getUseSAO()) |
---|
| 2409 | { |
---|
| 2410 | READ_FLAG(uiCode, "slice_sao_luma_flag"); rpcSlice->setSaoEnabledFlag((Bool)uiCode); |
---|
| 2411 | READ_FLAG(uiCode, "slice_sao_chroma_flag"); rpcSlice->setSaoEnabledFlagChroma((Bool)uiCode); |
---|
[56] | 2412 | } |
---|
[608] | 2413 | |
---|
| 2414 | if (rpcSlice->getIdrPicFlag()) |
---|
| 2415 | { |
---|
| 2416 | rpcSlice->setEnableTMVPFlag(false); |
---|
| 2417 | } |
---|
[56] | 2418 | if (!rpcSlice->isIntra()) |
---|
| 2419 | { |
---|
[608] | 2420 | |
---|
[56] | 2421 | READ_FLAG( uiCode, "num_ref_idx_active_override_flag"); |
---|
| 2422 | if (uiCode) |
---|
[2] | 2423 | { |
---|
[608] | 2424 | READ_UVLC (uiCode, "num_ref_idx_l0_active_minus1" ); rpcSlice->setNumRefIdx( REF_PIC_LIST_0, uiCode + 1 ); |
---|
[56] | 2425 | if (rpcSlice->isInterB()) |
---|
[2] | 2426 | { |
---|
[608] | 2427 | READ_UVLC (uiCode, "num_ref_idx_l1_active_minus1" ); rpcSlice->setNumRefIdx( REF_PIC_LIST_1, uiCode + 1 ); |
---|
[2] | 2428 | } |
---|
| 2429 | else |
---|
| 2430 | { |
---|
[56] | 2431 | rpcSlice->setNumRefIdx(REF_PIC_LIST_1, 0); |
---|
[2] | 2432 | } |
---|
| 2433 | } |
---|
| 2434 | else |
---|
| 2435 | { |
---|
[608] | 2436 | rpcSlice->setNumRefIdx(REF_PIC_LIST_0, rpcSlice->getPPS()->getNumRefIdxL0DefaultActive()); |
---|
| 2437 | if (rpcSlice->isInterB()) |
---|
| 2438 | { |
---|
| 2439 | rpcSlice->setNumRefIdx(REF_PIC_LIST_1, rpcSlice->getPPS()->getNumRefIdxL1DefaultActive()); |
---|
| 2440 | } |
---|
| 2441 | else |
---|
| 2442 | { |
---|
| 2443 | rpcSlice->setNumRefIdx(REF_PIC_LIST_1,0); |
---|
| 2444 | } |
---|
[2] | 2445 | } |
---|
| 2446 | } |
---|
[608] | 2447 | // } |
---|
[56] | 2448 | TComRefPicListModification* refPicListModification = rpcSlice->getRefPicListModification(); |
---|
[608] | 2449 | if(!rpcSlice->isIntra()) |
---|
[2] | 2450 | { |
---|
[608] | 2451 | if( !rpcSlice->getPPS()->getListsModificationPresentFlag() || rpcSlice->getNumRpsCurrTempList() <= 1 ) |
---|
[2] | 2452 | { |
---|
[56] | 2453 | refPicListModification->setRefPicListModificationFlagL0( 0 ); |
---|
[2] | 2454 | } |
---|
| 2455 | else |
---|
| 2456 | { |
---|
[56] | 2457 | READ_FLAG( uiCode, "ref_pic_list_modification_flag_l0" ); refPicListModification->setRefPicListModificationFlagL0( uiCode ? 1 : 0 ); |
---|
[2] | 2458 | } |
---|
[608] | 2459 | |
---|
[56] | 2460 | if(refPicListModification->getRefPicListModificationFlagL0()) |
---|
[608] | 2461 | { |
---|
[56] | 2462 | uiCode = 0; |
---|
| 2463 | Int i = 0; |
---|
[608] | 2464 | Int numRpsCurrTempList0 = rpcSlice->getNumRpsCurrTempList(); |
---|
| 2465 | if ( numRpsCurrTempList0 > 1 ) |
---|
[56] | 2466 | { |
---|
| 2467 | Int length = 1; |
---|
[608] | 2468 | numRpsCurrTempList0 --; |
---|
| 2469 | while ( numRpsCurrTempList0 >>= 1) |
---|
[56] | 2470 | { |
---|
| 2471 | length ++; |
---|
| 2472 | } |
---|
| 2473 | for (i = 0; i < rpcSlice->getNumRefIdx(REF_PIC_LIST_0); i ++) |
---|
| 2474 | { |
---|
| 2475 | READ_CODE( length, uiCode, "list_entry_l0" ); |
---|
| 2476 | refPicListModification->setRefPicSetIdxL0(i, uiCode ); |
---|
| 2477 | } |
---|
| 2478 | } |
---|
| 2479 | else |
---|
| 2480 | { |
---|
| 2481 | for (i = 0; i < rpcSlice->getNumRefIdx(REF_PIC_LIST_0); i ++) |
---|
| 2482 | { |
---|
| 2483 | refPicListModification->setRefPicSetIdxL0(i, 0 ); |
---|
| 2484 | } |
---|
| 2485 | } |
---|
[2] | 2486 | } |
---|
| 2487 | } |
---|
[56] | 2488 | else |
---|
[2] | 2489 | { |
---|
[56] | 2490 | refPicListModification->setRefPicListModificationFlagL0(0); |
---|
[2] | 2491 | } |
---|
[56] | 2492 | if(rpcSlice->isInterB()) |
---|
[2] | 2493 | { |
---|
[608] | 2494 | if( !rpcSlice->getPPS()->getListsModificationPresentFlag() || rpcSlice->getNumRpsCurrTempList() <= 1 ) |
---|
[2] | 2495 | { |
---|
[56] | 2496 | refPicListModification->setRefPicListModificationFlagL1( 0 ); |
---|
[2] | 2497 | } |
---|
| 2498 | else |
---|
| 2499 | { |
---|
[56] | 2500 | READ_FLAG( uiCode, "ref_pic_list_modification_flag_l1" ); refPicListModification->setRefPicListModificationFlagL1( uiCode ? 1 : 0 ); |
---|
[2] | 2501 | } |
---|
[56] | 2502 | if(refPicListModification->getRefPicListModificationFlagL1()) |
---|
[2] | 2503 | { |
---|
[56] | 2504 | uiCode = 0; |
---|
| 2505 | Int i = 0; |
---|
[608] | 2506 | Int numRpsCurrTempList1 = rpcSlice->getNumRpsCurrTempList(); |
---|
| 2507 | if ( numRpsCurrTempList1 > 1 ) |
---|
[56] | 2508 | { |
---|
| 2509 | Int length = 1; |
---|
[608] | 2510 | numRpsCurrTempList1 --; |
---|
| 2511 | while ( numRpsCurrTempList1 >>= 1) |
---|
[56] | 2512 | { |
---|
| 2513 | length ++; |
---|
| 2514 | } |
---|
| 2515 | for (i = 0; i < rpcSlice->getNumRefIdx(REF_PIC_LIST_1); i ++) |
---|
| 2516 | { |
---|
| 2517 | READ_CODE( length, uiCode, "list_entry_l1" ); |
---|
| 2518 | refPicListModification->setRefPicSetIdxL1(i, uiCode ); |
---|
| 2519 | } |
---|
| 2520 | } |
---|
| 2521 | else |
---|
| 2522 | { |
---|
| 2523 | for (i = 0; i < rpcSlice->getNumRefIdx(REF_PIC_LIST_1); i ++) |
---|
| 2524 | { |
---|
| 2525 | refPicListModification->setRefPicSetIdxL1(i, 0 ); |
---|
| 2526 | } |
---|
| 2527 | } |
---|
[2] | 2528 | } |
---|
[56] | 2529 | } |
---|
| 2530 | else |
---|
[2] | 2531 | { |
---|
[56] | 2532 | refPicListModification->setRefPicListModificationFlagL1(0); |
---|
[2] | 2533 | } |
---|
[608] | 2534 | if (rpcSlice->isInterB()) |
---|
[2] | 2535 | { |
---|
[608] | 2536 | READ_FLAG( uiCode, "mvd_l1_zero_flag" ); rpcSlice->setMvdL1ZeroFlag( (uiCode ? true : false) ); |
---|
| 2537 | } |
---|
| 2538 | |
---|
| 2539 | rpcSlice->setCabacInitFlag( false ); // default |
---|
| 2540 | if(pps->getCabacInitPresentFlag() && !rpcSlice->isIntra()) |
---|
| 2541 | { |
---|
| 2542 | READ_FLAG(uiCode, "cabac_init_flag"); |
---|
| 2543 | rpcSlice->setCabacInitFlag( uiCode ? true : false ); |
---|
| 2544 | } |
---|
| 2545 | |
---|
| 2546 | if ( rpcSlice->getEnableTMVPFlag() ) |
---|
| 2547 | { |
---|
| 2548 | if ( rpcSlice->getSliceType() == B_SLICE ) |
---|
[56] | 2549 | { |
---|
[608] | 2550 | READ_FLAG( uiCode, "collocated_from_l0_flag" ); |
---|
| 2551 | rpcSlice->setColFromL0Flag(uiCode); |
---|
[2] | 2552 | } |
---|
| 2553 | else |
---|
| 2554 | { |
---|
[608] | 2555 | rpcSlice->setColFromL0Flag( 1 ); |
---|
[2] | 2556 | } |
---|
[608] | 2557 | |
---|
| 2558 | if ( rpcSlice->getSliceType() != I_SLICE && |
---|
| 2559 | ((rpcSlice->getColFromL0Flag() == 1 && rpcSlice->getNumRefIdx(REF_PIC_LIST_0) > 1)|| |
---|
| 2560 | (rpcSlice->getColFromL0Flag() == 0 && rpcSlice->getNumRefIdx(REF_PIC_LIST_1) > 1))) |
---|
| 2561 | { |
---|
| 2562 | READ_UVLC( uiCode, "collocated_ref_idx" ); |
---|
| 2563 | rpcSlice->setColRefIdx(uiCode); |
---|
| 2564 | } |
---|
| 2565 | else |
---|
| 2566 | { |
---|
| 2567 | rpcSlice->setColRefIdx(0); |
---|
| 2568 | } |
---|
[2] | 2569 | } |
---|
[608] | 2570 | if ( (pps->getUseWP() && rpcSlice->getSliceType()==P_SLICE) || (pps->getWPBiPred() && rpcSlice->getSliceType()==B_SLICE) ) |
---|
[2] | 2571 | { |
---|
[608] | 2572 | xParsePredWeightTable(rpcSlice); |
---|
| 2573 | rpcSlice->initWpScaling(); |
---|
[2] | 2574 | } |
---|
[608] | 2575 | #if H_3D_IC |
---|
[1124] | 2576 | else if( rpcSlice->getViewIndex() && ( rpcSlice->getSliceType() == P_SLICE || rpcSlice->getSliceType() == B_SLICE ) && !rpcSlice->getIsDepth() && vps->getNumRefListLayers( layerId ) > 0 ) |
---|
[608] | 2577 | { |
---|
| 2578 | UInt uiCodeTmp = 0; |
---|
[2] | 2579 | |
---|
[608] | 2580 | READ_FLAG ( uiCodeTmp, "slice_ic_enable_flag" ); |
---|
| 2581 | rpcSlice->setApplyIC( uiCodeTmp ); |
---|
| 2582 | |
---|
| 2583 | if ( uiCodeTmp ) |
---|
| 2584 | { |
---|
| 2585 | READ_FLAG ( uiCodeTmp, "ic_skip_mergeidx0" ); |
---|
| 2586 | rpcSlice->setIcSkipParseFlag( uiCodeTmp ); |
---|
| 2587 | } |
---|
| 2588 | } |
---|
| 2589 | #endif |
---|
| 2590 | if (!rpcSlice->isIntra()) |
---|
| 2591 | { |
---|
| 2592 | READ_UVLC( uiCode, "five_minus_max_num_merge_cand"); |
---|
| 2593 | #if H_3D_IV_MERGE |
---|
[1124] | 2594 | rpcSlice->setMaxNumMergeCand(( ( rpcSlice->getMpiFlag() || rpcSlice->getIvMvPredFlag() || rpcSlice->getViewSynthesisPredFlag() ) ? MRG_MAX_NUM_CANDS_MEM : MRG_MAX_NUM_CANDS) - uiCode); |
---|
| 2595 | #else |
---|
[608] | 2596 | rpcSlice->setMaxNumMergeCand(MRG_MAX_NUM_CANDS - uiCode); |
---|
[56] | 2597 | #endif |
---|
[608] | 2598 | } |
---|
[2] | 2599 | |
---|
[608] | 2600 | READ_SVLC( iCode, "slice_qp_delta" ); |
---|
[56] | 2601 | rpcSlice->setSliceQp (26 + pps->getPicInitQPMinus26() + iCode); |
---|
[2] | 2602 | |
---|
[56] | 2603 | assert( rpcSlice->getSliceQp() >= -sps->getQpBDOffsetY() ); |
---|
| 2604 | assert( rpcSlice->getSliceQp() <= 51 ); |
---|
[2] | 2605 | |
---|
[608] | 2606 | if (rpcSlice->getPPS()->getSliceChromaQpFlag()) |
---|
[2] | 2607 | { |
---|
[608] | 2608 | READ_SVLC( iCode, "slice_qp_delta_cb" ); |
---|
| 2609 | rpcSlice->setSliceQpDeltaCb( iCode ); |
---|
| 2610 | assert( rpcSlice->getSliceQpDeltaCb() >= -12 ); |
---|
| 2611 | assert( rpcSlice->getSliceQpDeltaCb() <= 12 ); |
---|
| 2612 | assert( (rpcSlice->getPPS()->getChromaCbQpOffset() + rpcSlice->getSliceQpDeltaCb()) >= -12 ); |
---|
| 2613 | assert( (rpcSlice->getPPS()->getChromaCbQpOffset() + rpcSlice->getSliceQpDeltaCb()) <= 12 ); |
---|
| 2614 | |
---|
| 2615 | READ_SVLC( iCode, "slice_qp_delta_cr" ); |
---|
| 2616 | rpcSlice->setSliceQpDeltaCr( iCode ); |
---|
| 2617 | assert( rpcSlice->getSliceQpDeltaCr() >= -12 ); |
---|
| 2618 | assert( rpcSlice->getSliceQpDeltaCr() <= 12 ); |
---|
| 2619 | assert( (rpcSlice->getPPS()->getChromaCrQpOffset() + rpcSlice->getSliceQpDeltaCr()) >= -12 ); |
---|
| 2620 | assert( (rpcSlice->getPPS()->getChromaCrQpOffset() + rpcSlice->getSliceQpDeltaCr()) <= 12 ); |
---|
| 2621 | } |
---|
| 2622 | |
---|
| 2623 | if (rpcSlice->getPPS()->getDeblockingFilterControlPresentFlag()) |
---|
| 2624 | { |
---|
| 2625 | if(rpcSlice->getPPS()->getDeblockingFilterOverrideEnabledFlag()) |
---|
[2] | 2626 | { |
---|
[608] | 2627 | READ_FLAG ( uiCode, "deblocking_filter_override_flag" ); rpcSlice->setDeblockingFilterOverrideFlag(uiCode ? true : false); |
---|
[2] | 2628 | } |
---|
[608] | 2629 | else |
---|
| 2630 | { |
---|
| 2631 | rpcSlice->setDeblockingFilterOverrideFlag(0); |
---|
| 2632 | } |
---|
| 2633 | if(rpcSlice->getDeblockingFilterOverrideFlag()) |
---|
[2] | 2634 | { |
---|
[608] | 2635 | READ_FLAG ( uiCode, "slice_disable_deblocking_filter_flag" ); rpcSlice->setDeblockingFilterDisable(uiCode ? 1 : 0); |
---|
| 2636 | if(!rpcSlice->getDeblockingFilterDisable()) |
---|
[56] | 2637 | { |
---|
[608] | 2638 | READ_SVLC( iCode, "slice_beta_offset_div2" ); rpcSlice->setDeblockingFilterBetaOffsetDiv2(iCode); |
---|
| 2639 | assert(rpcSlice->getDeblockingFilterBetaOffsetDiv2() >= -6 && |
---|
| 2640 | rpcSlice->getDeblockingFilterBetaOffsetDiv2() <= 6); |
---|
| 2641 | READ_SVLC( iCode, "slice_tc_offset_div2" ); rpcSlice->setDeblockingFilterTcOffsetDiv2(iCode); |
---|
| 2642 | assert(rpcSlice->getDeblockingFilterTcOffsetDiv2() >= -6 && |
---|
| 2643 | rpcSlice->getDeblockingFilterTcOffsetDiv2() <= 6); |
---|
[56] | 2644 | } |
---|
[2] | 2645 | } |
---|
[608] | 2646 | else |
---|
| 2647 | { |
---|
| 2648 | rpcSlice->setDeblockingFilterDisable ( rpcSlice->getPPS()->getPicDisableDeblockingFilterFlag() ); |
---|
| 2649 | rpcSlice->setDeblockingFilterBetaOffsetDiv2( rpcSlice->getPPS()->getDeblockingFilterBetaOffsetDiv2() ); |
---|
| 2650 | rpcSlice->setDeblockingFilterTcOffsetDiv2 ( rpcSlice->getPPS()->getDeblockingFilterTcOffsetDiv2() ); |
---|
| 2651 | } |
---|
| 2652 | } |
---|
| 2653 | else |
---|
| 2654 | { |
---|
| 2655 | rpcSlice->setDeblockingFilterDisable ( false ); |
---|
| 2656 | rpcSlice->setDeblockingFilterBetaOffsetDiv2( 0 ); |
---|
| 2657 | rpcSlice->setDeblockingFilterTcOffsetDiv2 ( 0 ); |
---|
| 2658 | } |
---|
| 2659 | |
---|
| 2660 | Bool isSAOEnabled = (!rpcSlice->getSPS()->getUseSAO())?(false):(rpcSlice->getSaoEnabledFlag()||rpcSlice->getSaoEnabledFlagChroma()); |
---|
| 2661 | Bool isDBFEnabled = (!rpcSlice->getDeblockingFilterDisable()); |
---|
| 2662 | |
---|
| 2663 | if(rpcSlice->getPPS()->getLoopFilterAcrossSlicesEnabledFlag() && ( isSAOEnabled || isDBFEnabled )) |
---|
[56] | 2664 | { |
---|
[608] | 2665 | READ_FLAG( uiCode, "slice_loop_filter_across_slices_enabled_flag"); |
---|
[2] | 2666 | } |
---|
[608] | 2667 | else |
---|
| 2668 | { |
---|
| 2669 | uiCode = rpcSlice->getPPS()->getLoopFilterAcrossSlicesEnabledFlag()?1:0; |
---|
| 2670 | } |
---|
| 2671 | rpcSlice->setLFCrossSliceBoundaryFlag( (uiCode==1)?true:false); |
---|
[56] | 2672 | |
---|
[608] | 2673 | } |
---|
| 2674 | |
---|
| 2675 | UInt *entryPointOffset = NULL; |
---|
| 2676 | UInt numEntryPointOffsets, offsetLenMinus1; |
---|
| 2677 | if( pps->getTilesEnabledFlag() || pps->getEntropyCodingSyncEnabledFlag() ) |
---|
| 2678 | { |
---|
| 2679 | READ_UVLC(numEntryPointOffsets, "num_entry_point_offsets"); rpcSlice->setNumEntryPointOffsets ( numEntryPointOffsets ); |
---|
| 2680 | if (numEntryPointOffsets>0) |
---|
[2] | 2681 | { |
---|
[608] | 2682 | READ_UVLC(offsetLenMinus1, "offset_len_minus1"); |
---|
[2] | 2683 | } |
---|
[608] | 2684 | entryPointOffset = new UInt[numEntryPointOffsets]; |
---|
| 2685 | for (UInt idx=0; idx<numEntryPointOffsets; idx++) |
---|
[2] | 2686 | { |
---|
[608] | 2687 | READ_CODE(offsetLenMinus1+1, uiCode, "entry_point_offset_minus1"); |
---|
| 2688 | entryPointOffset[ idx ] = uiCode + 1; |
---|
[2] | 2689 | } |
---|
| 2690 | } |
---|
[608] | 2691 | else |
---|
[2] | 2692 | { |
---|
[608] | 2693 | rpcSlice->setNumEntryPointOffsets ( 0 ); |
---|
| 2694 | } |
---|
| 2695 | |
---|
[773] | 2696 | #if H_3D |
---|
[1084] | 2697 | #if H_3D_FCO |
---|
[1066] | 2698 | if( rpcSlice->getVPS()->hasCamParInSliceHeader( rpcSlice->getViewIndex() ) && rpcSlice->getIsDepth() ) |
---|
| 2699 | #else |
---|
[758] | 2700 | if( rpcSlice->getVPS()->hasCamParInSliceHeader( rpcSlice->getViewIndex() ) && !rpcSlice->getIsDepth() ) |
---|
[1066] | 2701 | #endif |
---|
[758] | 2702 | { |
---|
| 2703 | UInt uiViewIndex = rpcSlice->getViewIndex(); |
---|
| 2704 | for( UInt uiBaseIndex = 0; uiBaseIndex < uiViewIndex; uiBaseIndex++ ) |
---|
| 2705 | { |
---|
| 2706 | READ_SVLC( iCode, "cp_scale" ); m_aaiTempScale [ uiBaseIndex ][ uiViewIndex ] = iCode; |
---|
| 2707 | READ_SVLC( iCode, "cp_off" ); m_aaiTempOffset[ uiBaseIndex ][ uiViewIndex ] = iCode; |
---|
| 2708 | READ_SVLC( iCode, "cp_inv_scale_plus_scale" ); m_aaiTempScale [ uiViewIndex ][ uiBaseIndex ] = iCode - m_aaiTempScale [ uiBaseIndex ][ uiViewIndex ]; |
---|
| 2709 | READ_SVLC( iCode, "cp_inv_off_plus_off" ); m_aaiTempOffset[ uiViewIndex ][ uiBaseIndex ] = iCode - m_aaiTempOffset[ uiBaseIndex ][ uiViewIndex ]; |
---|
| 2710 | } |
---|
| 2711 | rpcSlice->setCamparaSlice( m_aaiTempScale, m_aaiTempOffset ); |
---|
| 2712 | } |
---|
| 2713 | #endif |
---|
| 2714 | |
---|
[608] | 2715 | if(pps->getSliceHeaderExtensionPresentFlag()) |
---|
| 2716 | { |
---|
[872] | 2717 | #if H_MV |
---|
| 2718 | READ_UVLC( uiCode, "slice_segment_header_extension_length" ); rpcSlice->setSliceSegmentHeaderExtensionLength( uiCode ); |
---|
| 2719 | UInt posFollSliceSegHeaderExtLen = m_pcBitstream->getNumBitsRead(); |
---|
[608] | 2720 | |
---|
[872] | 2721 | if( rpcSlice->getPPS()->getPocResetInfoPresentFlag() ) |
---|
| 2722 | { |
---|
| 2723 | READ_CODE( 2, uiCode, "poc_reset_idc" ); rpcSlice->setPocResetIdc( uiCode ); |
---|
| 2724 | } |
---|
| 2725 | else |
---|
| 2726 | { |
---|
| 2727 | rpcSlice->setPocResetIdc( 0 ); |
---|
| 2728 | } |
---|
[964] | 2729 | rpcSlice->checkPocResetIdc(); |
---|
[872] | 2730 | |
---|
[964] | 2731 | if ( rpcSlice->getVPS()->getPocLsbNotPresentFlag(rpcSlice->getLayerId()) && slicePicOrderCntLsb > 0 ) |
---|
| 2732 | { |
---|
| 2733 | assert( rpcSlice->getPocResetIdc() != 2 ); |
---|
| 2734 | } |
---|
[976] | 2735 | |
---|
[872] | 2736 | if( rpcSlice->getPocResetIdc() != 0 ) |
---|
| 2737 | { |
---|
| 2738 | READ_CODE( 6, uiCode, "poc_reset_period_id" ); rpcSlice->setPocResetPeriodId( uiCode ); |
---|
| 2739 | } |
---|
| 2740 | else |
---|
| 2741 | { |
---|
| 2742 | // TODO Copy poc_reset_period from earlier picture |
---|
| 2743 | rpcSlice->setPocResetPeriodId( 0 ); |
---|
| 2744 | } |
---|
| 2745 | |
---|
| 2746 | if( rpcSlice->getPocResetIdc() == 3 ) |
---|
| 2747 | { |
---|
| 2748 | READ_FLAG( uiCode, "full_poc_reset_flag" ); rpcSlice->setFullPocResetFlag( uiCode == 1 ); |
---|
| 2749 | READ_CODE( rpcSlice->getPocLsbValLen() , uiCode, "poc_lsb_val" ); rpcSlice->setPocLsbVal( uiCode ); |
---|
| 2750 | } |
---|
[964] | 2751 | rpcSlice->checkPocLsbVal(); |
---|
[872] | 2752 | |
---|
[964] | 2753 | // Derive the value of PocMs8bValRequiredFlag |
---|
[872] | 2754 | |
---|
[1124] | 2755 | if( !rpcSlice->getPocMsbValRequiredFlag() && rpcSlice->getVPS()->getVpsPocLsbAlignedFlag() ) |
---|
[872] | 2756 | { |
---|
| 2757 | READ_FLAG( uiCode, "poc_msb_val_present_flag" ); rpcSlice->setPocMsbValPresentFlag( uiCode == 1 ); |
---|
| 2758 | } |
---|
| 2759 | else |
---|
| 2760 | { |
---|
[964] | 2761 | rpcSlice->setPocMsbValPresentFlag( rpcSlice->inferPocMsbValPresentFlag( ) ); |
---|
[872] | 2762 | } |
---|
| 2763 | |
---|
| 2764 | |
---|
| 2765 | if( rpcSlice->getPocMsbValPresentFlag() ) |
---|
| 2766 | { |
---|
| 2767 | READ_UVLC( uiCode, "poc_msb_val" ); rpcSlice->setPocMsbVal( uiCode ); |
---|
| 2768 | } |
---|
| 2769 | |
---|
| 2770 | while( ( m_pcBitstream->getNumBitsRead() - posFollSliceSegHeaderExtLen ) < rpcSlice->getSliceSegmentHeaderExtensionLength() * 8 ) |
---|
| 2771 | { |
---|
| 2772 | READ_FLAG( uiCode, "slice_segment_header_extension_data_bit" ); |
---|
| 2773 | } |
---|
| 2774 | assert( ( m_pcBitstream->getNumBitsRead() - posFollSliceSegHeaderExtLen ) == rpcSlice->getSliceSegmentHeaderExtensionLength() * 8 ); |
---|
[1084] | 2775 | } |
---|
[872] | 2776 | #else |
---|
| 2777 | READ_UVLC( uiCode, "slice_header_extension_length" ); |
---|
[608] | 2778 | for(Int i=0; i<uiCode; i++) |
---|
| 2779 | { |
---|
| 2780 | UInt ignore; |
---|
| 2781 | READ_CODE(8,ignore,"slice_header_extension_data_byte"); |
---|
[964] | 2782 | } |
---|
[872] | 2783 | } |
---|
[1066] | 2784 | #endif |
---|
[608] | 2785 | m_pcBitstream->readByteAlignment(); |
---|
[56] | 2786 | |
---|
[608] | 2787 | if( pps->getTilesEnabledFlag() || pps->getEntropyCodingSyncEnabledFlag() ) |
---|
[56] | 2788 | { |
---|
[608] | 2789 | Int endOfSliceHeaderLocation = m_pcBitstream->getByteLocation(); |
---|
| 2790 | |
---|
| 2791 | // Adjust endOfSliceHeaderLocation to account for emulation prevention bytes in the slice segment header |
---|
| 2792 | for ( UInt curByteIdx = 0; curByteIdx<m_pcBitstream->numEmulationPreventionBytesRead(); curByteIdx++ ) |
---|
[2] | 2793 | { |
---|
[608] | 2794 | if ( m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) < endOfSliceHeaderLocation ) |
---|
[2] | 2795 | { |
---|
[608] | 2796 | endOfSliceHeaderLocation++; |
---|
[2] | 2797 | } |
---|
[608] | 2798 | } |
---|
[56] | 2799 | |
---|
[608] | 2800 | Int curEntryPointOffset = 0; |
---|
| 2801 | Int prevEntryPointOffset = 0; |
---|
| 2802 | for (UInt idx=0; idx<numEntryPointOffsets; idx++) |
---|
| 2803 | { |
---|
| 2804 | curEntryPointOffset += entryPointOffset[ idx ]; |
---|
| 2805 | |
---|
| 2806 | Int emulationPreventionByteCount = 0; |
---|
| 2807 | for ( UInt curByteIdx = 0; curByteIdx<m_pcBitstream->numEmulationPreventionBytesRead(); curByteIdx++ ) |
---|
[2] | 2808 | { |
---|
[608] | 2809 | if ( m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) >= ( prevEntryPointOffset + endOfSliceHeaderLocation ) && |
---|
| 2810 | m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) < ( curEntryPointOffset + endOfSliceHeaderLocation ) ) |
---|
| 2811 | { |
---|
| 2812 | emulationPreventionByteCount++; |
---|
| 2813 | } |
---|
[2] | 2814 | } |
---|
[56] | 2815 | |
---|
[608] | 2816 | entryPointOffset[ idx ] -= emulationPreventionByteCount; |
---|
| 2817 | prevEntryPointOffset = curEntryPointOffset; |
---|
[2] | 2818 | } |
---|
[56] | 2819 | |
---|
[608] | 2820 | if ( pps->getTilesEnabledFlag() ) |
---|
| 2821 | { |
---|
| 2822 | rpcSlice->setTileLocationCount( numEntryPointOffsets ); |
---|
[56] | 2823 | |
---|
[608] | 2824 | UInt prevPos = 0; |
---|
| 2825 | for (Int idx=0; idx<rpcSlice->getTileLocationCount(); idx++) |
---|
| 2826 | { |
---|
| 2827 | rpcSlice->setTileLocation( idx, prevPos + entryPointOffset [ idx ] ); |
---|
| 2828 | prevPos += entryPointOffset[ idx ]; |
---|
| 2829 | } |
---|
[2] | 2830 | } |
---|
[608] | 2831 | else if ( pps->getEntropyCodingSyncEnabledFlag() ) |
---|
[2] | 2832 | { |
---|
[608] | 2833 | Int numSubstreams = rpcSlice->getNumEntryPointOffsets()+1; |
---|
| 2834 | rpcSlice->allocSubstreamSizes(numSubstreams); |
---|
| 2835 | UInt *pSubstreamSizes = rpcSlice->getSubstreamSizes(); |
---|
| 2836 | for (Int idx=0; idx<numSubstreams-1; idx++) |
---|
[2] | 2837 | { |
---|
[608] | 2838 | if ( idx < numEntryPointOffsets ) |
---|
| 2839 | { |
---|
| 2840 | pSubstreamSizes[ idx ] = ( entryPointOffset[ idx ] << 3 ) ; |
---|
| 2841 | } |
---|
| 2842 | else |
---|
| 2843 | { |
---|
| 2844 | pSubstreamSizes[ idx ] = 0; |
---|
| 2845 | } |
---|
[2] | 2846 | } |
---|
[56] | 2847 | } |
---|
[608] | 2848 | |
---|
| 2849 | if (entryPointOffset) |
---|
| 2850 | { |
---|
| 2851 | delete [] entryPointOffset; |
---|
| 2852 | } |
---|
[56] | 2853 | } |
---|
[2] | 2854 | |
---|
[608] | 2855 | return; |
---|
| 2856 | } |
---|
| 2857 | |
---|
| 2858 | Void TDecCavlc::parsePTL( TComPTL *rpcPTL, Bool profilePresentFlag, Int maxNumSubLayersMinus1 ) |
---|
| 2859 | { |
---|
| 2860 | UInt uiCode; |
---|
| 2861 | if(profilePresentFlag) |
---|
[56] | 2862 | { |
---|
[608] | 2863 | parseProfileTier(rpcPTL->getGeneralPTL()); |
---|
| 2864 | } |
---|
| 2865 | READ_CODE( 8, uiCode, "general_level_idc" ); rpcPTL->getGeneralPTL()->setLevelIdc(uiCode); |
---|
[2] | 2866 | |
---|
[608] | 2867 | for (Int i = 0; i < maxNumSubLayersMinus1; i++) |
---|
| 2868 | { |
---|
| 2869 | #if !H_MV |
---|
| 2870 | if(profilePresentFlag) |
---|
[56] | 2871 | { |
---|
[608] | 2872 | #endif |
---|
| 2873 | READ_FLAG( uiCode, "sub_layer_profile_present_flag[i]" ); rpcPTL->setSubLayerProfilePresentFlag(i, uiCode); |
---|
| 2874 | #if H_MV |
---|
[1066] | 2875 | // When profilePresentFlag is equal to 0, sub_layer_profile_present_flag[ i ] shall be equal to 0. |
---|
| 2876 | assert( profilePresentFlag || !rpcPTL->getSubLayerProfilePresentFlag(i) ); |
---|
| 2877 | #else |
---|
[56] | 2878 | } |
---|
[608] | 2879 | #endif |
---|
| 2880 | READ_FLAG( uiCode, "sub_layer_level_present_flag[i]" ); rpcPTL->setSubLayerLevelPresentFlag (i, uiCode); |
---|
[56] | 2881 | } |
---|
[608] | 2882 | |
---|
| 2883 | if (maxNumSubLayersMinus1 > 0) |
---|
[56] | 2884 | { |
---|
[608] | 2885 | for (Int i = maxNumSubLayersMinus1; i < 8; i++) |
---|
[56] | 2886 | { |
---|
[608] | 2887 | READ_CODE(2, uiCode, "reserved_zero_2bits"); |
---|
| 2888 | assert(uiCode == 0); |
---|
[2] | 2889 | } |
---|
[56] | 2890 | } |
---|
[608] | 2891 | |
---|
| 2892 | for(Int i = 0; i < maxNumSubLayersMinus1; i++) |
---|
[56] | 2893 | { |
---|
[1066] | 2894 | #if H_MV |
---|
| 2895 | if( rpcPTL->getSubLayerProfilePresentFlag(i) ) |
---|
| 2896 | #else |
---|
| 2897 | if( profilePresentFlag && rpcPTL->getSubLayerProfilePresentFlag(i) ) |
---|
| 2898 | #endif |
---|
[608] | 2899 | { |
---|
| 2900 | parseProfileTier(rpcPTL->getSubLayerPTL(i)); |
---|
| 2901 | } |
---|
| 2902 | if(rpcPTL->getSubLayerLevelPresentFlag(i)) |
---|
| 2903 | { |
---|
| 2904 | READ_CODE( 8, uiCode, "sub_layer_level_idc[i]" ); rpcPTL->getSubLayerPTL(i)->setLevelIdc(uiCode); |
---|
| 2905 | } |
---|
[56] | 2906 | } |
---|
[2] | 2907 | } |
---|
| 2908 | |
---|
[608] | 2909 | Void TDecCavlc::parseProfileTier(ProfileTierLevel *ptl) |
---|
[2] | 2910 | { |
---|
[608] | 2911 | UInt uiCode; |
---|
| 2912 | READ_CODE(2 , uiCode, "XXX_profile_space[]"); ptl->setProfileSpace(uiCode); |
---|
| 2913 | READ_FLAG( uiCode, "XXX_tier_flag[]" ); ptl->setTierFlag (uiCode ? 1 : 0); |
---|
| 2914 | READ_CODE(5 , uiCode, "XXX_profile_idc[]" ); ptl->setProfileIdc (uiCode); |
---|
| 2915 | for(Int j = 0; j < 32; j++) |
---|
[2] | 2916 | { |
---|
[608] | 2917 | READ_FLAG( uiCode, "XXX_profile_compatibility_flag[][j]"); ptl->setProfileCompatibilityFlag(j, uiCode ? 1 : 0); |
---|
[2] | 2918 | } |
---|
[608] | 2919 | READ_FLAG(uiCode, "general_progressive_source_flag"); |
---|
| 2920 | ptl->setProgressiveSourceFlag(uiCode ? true : false); |
---|
[2] | 2921 | |
---|
[608] | 2922 | READ_FLAG(uiCode, "general_interlaced_source_flag"); |
---|
| 2923 | ptl->setInterlacedSourceFlag(uiCode ? true : false); |
---|
| 2924 | |
---|
| 2925 | READ_FLAG(uiCode, "general_non_packed_constraint_flag"); |
---|
| 2926 | ptl->setNonPackedConstraintFlag(uiCode ? true : false); |
---|
| 2927 | |
---|
| 2928 | READ_FLAG(uiCode, "general_frame_only_constraint_flag"); |
---|
| 2929 | ptl->setFrameOnlyConstraintFlag(uiCode ? true : false); |
---|
| 2930 | |
---|
[1084] | 2931 | #if H_MV |
---|
[1066] | 2932 | if( ptl->getV2ConstraintsPresentFlag() ) |
---|
| 2933 | { |
---|
| 2934 | READ_FLAG( uiCode, "max_12bit_constraint_flag" ); ptl->setMax12bitConstraintFlag ( uiCode == 1 ); |
---|
| 2935 | READ_FLAG( uiCode, "max_10bit_constraint_flag" ); ptl->setMax10bitConstraintFlag ( uiCode == 1 ); |
---|
| 2936 | READ_FLAG( uiCode, "max_8bit_constraint_flag" ); ptl->setMax8bitConstraintFlag ( uiCode == 1 ); |
---|
| 2937 | READ_FLAG( uiCode, "max_422chroma_constraint_flag" ); ptl->setMax422chromaConstraintFlag ( uiCode == 1 ); |
---|
| 2938 | READ_FLAG( uiCode, "max_420chroma_constraint_flag" ); ptl->setMax420chromaConstraintFlag ( uiCode == 1 ); |
---|
| 2939 | READ_FLAG( uiCode, "max_monochrome_constraint_flag" ); ptl->setMaxMonochromeConstraintFlag ( uiCode == 1 ); |
---|
| 2940 | READ_FLAG( uiCode, "intra_constraint_flag" ); ptl->setIntraConstraintFlag ( uiCode == 1 ); |
---|
| 2941 | READ_FLAG( uiCode, "one_picture_only_constraint_flag" ); ptl->setOnePictureOnlyConstraintFlag( uiCode == 1 ); |
---|
| 2942 | READ_FLAG( uiCode, "lower_bit_rate_constraint_flag" ); ptl->setLowerBitRateConstraintFlag ( uiCode == 1 ); |
---|
| 2943 | READ_CODE(16, uiCode, "XXX_reserved_zero_34bits[0..15]"); |
---|
| 2944 | READ_CODE(16, uiCode, "XXX_reserved_zero_34bits[16..31]"); |
---|
| 2945 | READ_CODE(2 , uiCode, "XXX_reserved_zero_34bits[32..33]"); |
---|
| 2946 | } |
---|
| 2947 | else |
---|
| 2948 | { |
---|
| 2949 | READ_CODE(16, uiCode, "XXX_reserved_zero_43bits[0..15]"); |
---|
| 2950 | READ_CODE(16, uiCode, "XXX_reserved_zero_43bits[16..31]"); |
---|
| 2951 | READ_CODE(11, uiCode, "XXX_reserved_zero_43bits[32..42]"); |
---|
| 2952 | } |
---|
| 2953 | if( ptl->getInbldPresentFlag() ) |
---|
| 2954 | { |
---|
| 2955 | READ_FLAG( uiCode, "inbld_flag" ); ptl->setInbldFlag( uiCode == 1 ); |
---|
| 2956 | } |
---|
| 2957 | else |
---|
| 2958 | { |
---|
| 2959 | READ_FLAG(uiCode, "reserved_zero_bit"); |
---|
| 2960 | } |
---|
| 2961 | #else |
---|
[608] | 2962 | READ_CODE(16, uiCode, "XXX_reserved_zero_44bits[0..15]"); |
---|
| 2963 | READ_CODE(16, uiCode, "XXX_reserved_zero_44bits[16..31]"); |
---|
| 2964 | READ_CODE(12, uiCode, "XXX_reserved_zero_44bits[32..43]"); |
---|
[1066] | 2965 | #endif |
---|
[2] | 2966 | } |
---|
[56] | 2967 | |
---|
| 2968 | Void TDecCavlc::parseTerminatingBit( UInt& ruiBit ) |
---|
[2] | 2969 | { |
---|
[56] | 2970 | ruiBit = false; |
---|
| 2971 | Int iBitsLeft = m_pcBitstream->getNumBitsLeft(); |
---|
| 2972 | if(iBitsLeft <= 8) |
---|
[2] | 2973 | { |
---|
[56] | 2974 | UInt uiPeekValue = m_pcBitstream->peekBits(iBitsLeft); |
---|
| 2975 | if (uiPeekValue == (1<<(iBitsLeft-1))) |
---|
| 2976 | { |
---|
| 2977 | ruiBit = true; |
---|
| 2978 | } |
---|
[2] | 2979 | } |
---|
| 2980 | } |
---|
| 2981 | |
---|
[608] | 2982 | Void TDecCavlc::parseSkipFlag( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
[2] | 2983 | { |
---|
[56] | 2984 | assert(0); |
---|
| 2985 | } |
---|
[1084] | 2986 | #if H_3D_SINGLE_DEPTH |
---|
[1039] | 2987 | Void TDecCavlc::parseSingleDepthMode( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
| 2988 | { |
---|
| 2989 | assert(0); |
---|
| 2990 | } |
---|
| 2991 | #endif |
---|
[608] | 2992 | Void TDecCavlc::parseCUTransquantBypassFlag( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
[189] | 2993 | { |
---|
| 2994 | assert(0); |
---|
| 2995 | } |
---|
| 2996 | |
---|
[608] | 2997 | Void TDecCavlc::parseMVPIdx( Int& /*riMVPIdx*/ ) |
---|
[56] | 2998 | { |
---|
| 2999 | assert(0); |
---|
| 3000 | } |
---|
[2] | 3001 | |
---|
[608] | 3002 | Void TDecCavlc::parseSplitFlag ( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
[56] | 3003 | { |
---|
| 3004 | assert(0); |
---|
| 3005 | } |
---|
[2] | 3006 | |
---|
[608] | 3007 | Void TDecCavlc::parsePartSize( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
[56] | 3008 | { |
---|
| 3009 | assert(0); |
---|
| 3010 | } |
---|
[2] | 3011 | |
---|
[608] | 3012 | Void TDecCavlc::parsePredMode( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
[56] | 3013 | { |
---|
| 3014 | assert(0); |
---|
| 3015 | } |
---|
[2] | 3016 | |
---|
[56] | 3017 | /** Parse I_PCM information. |
---|
[608] | 3018 | * \param pcCU pointer to CU |
---|
| 3019 | * \param uiAbsPartIdx CU index |
---|
| 3020 | * \param uiDepth CU depth |
---|
| 3021 | * \returns Void |
---|
| 3022 | * |
---|
| 3023 | * If I_PCM flag indicates that the CU is I_PCM, parse its PCM alignment bits and codes. |
---|
| 3024 | */ |
---|
| 3025 | Void TDecCavlc::parseIPCMInfo( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
[56] | 3026 | { |
---|
| 3027 | assert(0); |
---|
[2] | 3028 | } |
---|
| 3029 | |
---|
[608] | 3030 | Void TDecCavlc::parseIntraDirLumaAng ( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
[56] | 3031 | { |
---|
| 3032 | assert(0); |
---|
[2] | 3033 | } |
---|
| 3034 | |
---|
[608] | 3035 | Void TDecCavlc::parseIntraDirChroma( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
[2] | 3036 | { |
---|
[56] | 3037 | assert(0); |
---|
[2] | 3038 | } |
---|
| 3039 | |
---|
[608] | 3040 | Void TDecCavlc::parseInterDir( TComDataCU* /*pcCU*/, UInt& /*ruiInterDir*/, UInt /*uiAbsPartIdx*/ ) |
---|
[2] | 3041 | { |
---|
[56] | 3042 | assert(0); |
---|
[2] | 3043 | } |
---|
| 3044 | |
---|
[608] | 3045 | Void TDecCavlc::parseRefFrmIdx( TComDataCU* /*pcCU*/, Int& /*riRefFrmIdx*/, RefPicList /*eRefList*/ ) |
---|
[2] | 3046 | { |
---|
[56] | 3047 | assert(0); |
---|
[2] | 3048 | } |
---|
| 3049 | |
---|
[608] | 3050 | Void TDecCavlc::parseMvd( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiPartIdx*/, UInt /*uiDepth*/, RefPicList /*eRefList*/ ) |
---|
[2] | 3051 | { |
---|
[56] | 3052 | assert(0); |
---|
[2] | 3053 | } |
---|
| 3054 | |
---|
[56] | 3055 | Void TDecCavlc::parseDeltaQP( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
[2] | 3056 | { |
---|
[56] | 3057 | Int qp; |
---|
| 3058 | Int iDQp; |
---|
[608] | 3059 | |
---|
[56] | 3060 | xReadSvlc( iDQp ); |
---|
[2] | 3061 | |
---|
[56] | 3062 | Int qpBdOffsetY = pcCU->getSlice()->getSPS()->getQpBDOffsetY(); |
---|
| 3063 | qp = (((Int) pcCU->getRefQP( uiAbsPartIdx ) + iDQp + 52 + 2*qpBdOffsetY )%(52+ qpBdOffsetY)) - qpBdOffsetY; |
---|
| 3064 | |
---|
[608] | 3065 | UInt uiAbsQpCUPartIdx = (uiAbsPartIdx>>((g_uiMaxCUDepth - pcCU->getSlice()->getPPS()->getMaxCuDQPDepth())<<1))<<((g_uiMaxCUDepth - pcCU->getSlice()->getPPS()->getMaxCuDQPDepth())<<1) ; |
---|
[56] | 3066 | UInt uiQpCUDepth = min(uiDepth,pcCU->getSlice()->getPPS()->getMaxCuDQPDepth()) ; |
---|
| 3067 | |
---|
| 3068 | pcCU->setQPSubParts( qp, uiAbsQpCUPartIdx, uiQpCUDepth ); |
---|
[2] | 3069 | } |
---|
| 3070 | |
---|
[608] | 3071 | Void TDecCavlc::parseCoeffNxN( TComDataCU* /*pcCU*/, TCoeff* /*pcCoef*/, UInt /*uiAbsPartIdx*/, UInt /*uiWidth*/, UInt /*uiHeight*/, UInt /*uiDepth*/, TextType /*eTType*/ ) |
---|
[2] | 3072 | { |
---|
[56] | 3073 | assert(0); |
---|
[2] | 3074 | } |
---|
| 3075 | |
---|
[608] | 3076 | Void TDecCavlc::parseTransformSubdivFlag( UInt& /*ruiSubdivFlag*/, UInt /*uiLog2TransformBlockSize*/ ) |
---|
[2] | 3077 | { |
---|
[56] | 3078 | assert(0); |
---|
[2] | 3079 | } |
---|
| 3080 | |
---|
[608] | 3081 | Void TDecCavlc::parseQtCbf( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, TextType /*eType*/, UInt /*uiTrDepth*/, UInt /*uiDepth*/ ) |
---|
[2] | 3082 | { |
---|
[56] | 3083 | assert(0); |
---|
[2] | 3084 | } |
---|
| 3085 | |
---|
[608] | 3086 | Void TDecCavlc::parseQtRootCbf( UInt /*uiAbsPartIdx*/, UInt& /*uiQtRootCbf*/ ) |
---|
[2] | 3087 | { |
---|
[56] | 3088 | assert(0); |
---|
[2] | 3089 | } |
---|
| 3090 | |
---|
[608] | 3091 | Void TDecCavlc::parseTransformSkipFlags (TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*width*/, UInt /*height*/, UInt /*uiDepth*/, TextType /*eTType*/) |
---|
[2] | 3092 | { |
---|
[56] | 3093 | assert(0); |
---|
[2] | 3094 | } |
---|
| 3095 | |
---|
[608] | 3096 | Void TDecCavlc::parseMergeFlag ( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/, UInt /*uiPUIdx*/ ) |
---|
[2] | 3097 | { |
---|
[56] | 3098 | assert(0); |
---|
[2] | 3099 | } |
---|
| 3100 | |
---|
[608] | 3101 | Void TDecCavlc::parseMergeIndex ( TComDataCU* /*pcCU*/, UInt& /*ruiMergeIndex*/ ) |
---|
[2] | 3102 | { |
---|
[56] | 3103 | assert(0); |
---|
[2] | 3104 | } |
---|
[608] | 3105 | |
---|
| 3106 | #if H_3D_ARP |
---|
[443] | 3107 | Void TDecCavlc::parseARPW( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 3108 | { |
---|
[608] | 3109 | assert(0); |
---|
[443] | 3110 | } |
---|
| 3111 | #endif |
---|
[608] | 3112 | #if H_3D_IC |
---|
| 3113 | Void TDecCavlc::parseICFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
[189] | 3114 | { |
---|
| 3115 | assert(0); |
---|
| 3116 | } |
---|
[608] | 3117 | #endif |
---|
[655] | 3118 | #if H_3D_INTER_SDC |
---|
[833] | 3119 | Void TDecCavlc::parseDeltaDC( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
| 3120 | { |
---|
| 3121 | assert(0); |
---|
| 3122 | } |
---|
| 3123 | |
---|
| 3124 | Void TDecCavlc::parseSDCFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 3125 | { |
---|
| 3126 | assert(0); |
---|
| 3127 | } |
---|
[608] | 3128 | |
---|
[189] | 3129 | #endif |
---|
[833] | 3130 | #if H_3D_DBBP |
---|
| 3131 | Void TDecCavlc::parseDBBPFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 3132 | { |
---|
| 3133 | assert(0); |
---|
| 3134 | } |
---|
| 3135 | #endif |
---|
[2] | 3136 | // ==================================================================================================================== |
---|
| 3137 | // Protected member functions |
---|
| 3138 | // ==================================================================================================================== |
---|
| 3139 | |
---|
[56] | 3140 | /** parse explicit wp tables |
---|
[608] | 3141 | * \param TComSlice* pcSlice |
---|
| 3142 | * \returns Void |
---|
| 3143 | */ |
---|
[56] | 3144 | Void TDecCavlc::xParsePredWeightTable( TComSlice* pcSlice ) |
---|
[2] | 3145 | { |
---|
[56] | 3146 | wpScalingParam *wp; |
---|
| 3147 | Bool bChroma = true; // color always present in HEVC ? |
---|
| 3148 | SliceType eSliceType = pcSlice->getSliceType(); |
---|
| 3149 | Int iNbRef = (eSliceType == B_SLICE ) ? (2) : (1); |
---|
| 3150 | UInt uiLog2WeightDenomLuma, uiLog2WeightDenomChroma; |
---|
[608] | 3151 | UInt uiTotalSignalledWeightFlags = 0; |
---|
| 3152 | |
---|
| 3153 | Int iDeltaDenom; |
---|
| 3154 | // decode delta_luma_log2_weight_denom : |
---|
| 3155 | READ_UVLC( uiLog2WeightDenomLuma, "luma_log2_weight_denom" ); // ue(v): luma_log2_weight_denom |
---|
| 3156 | assert( uiLog2WeightDenomLuma <= 7 ); |
---|
| 3157 | if( bChroma ) |
---|
| 3158 | { |
---|
| 3159 | READ_SVLC( iDeltaDenom, "delta_chroma_log2_weight_denom" ); // se(v): delta_chroma_log2_weight_denom |
---|
| 3160 | assert((iDeltaDenom + (Int)uiLog2WeightDenomLuma)>=0); |
---|
| 3161 | assert((iDeltaDenom + (Int)uiLog2WeightDenomLuma)<=7); |
---|
| 3162 | uiLog2WeightDenomChroma = (UInt)(iDeltaDenom + uiLog2WeightDenomLuma); |
---|
| 3163 | } |
---|
[2] | 3164 | |
---|
[608] | 3165 | for ( Int iNumRef=0 ; iNumRef<iNbRef ; iNumRef++ ) |
---|
[2] | 3166 | { |
---|
[608] | 3167 | RefPicList eRefPicList = ( iNumRef ? REF_PIC_LIST_1 : REF_PIC_LIST_0 ); |
---|
| 3168 | for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ ) |
---|
[2] | 3169 | { |
---|
[608] | 3170 | pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); |
---|
| 3171 | |
---|
| 3172 | wp[0].uiLog2WeightDenom = uiLog2WeightDenomLuma; |
---|
| 3173 | wp[1].uiLog2WeightDenom = uiLog2WeightDenomChroma; |
---|
| 3174 | wp[2].uiLog2WeightDenom = uiLog2WeightDenomChroma; |
---|
| 3175 | |
---|
| 3176 | UInt uiCode; |
---|
| 3177 | READ_FLAG( uiCode, "luma_weight_lX_flag" ); // u(1): luma_weight_l0_flag |
---|
| 3178 | wp[0].bPresentFlag = ( uiCode == 1 ); |
---|
| 3179 | uiTotalSignalledWeightFlags += wp[0].bPresentFlag; |
---|
[56] | 3180 | } |
---|
[608] | 3181 | if ( bChroma ) |
---|
[56] | 3182 | { |
---|
[608] | 3183 | UInt uiCode; |
---|
[56] | 3184 | for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ ) |
---|
[2] | 3185 | { |
---|
[56] | 3186 | pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); |
---|
[608] | 3187 | READ_FLAG( uiCode, "chroma_weight_lX_flag" ); // u(1): chroma_weight_l0_flag |
---|
| 3188 | wp[1].bPresentFlag = ( uiCode == 1 ); |
---|
| 3189 | wp[2].bPresentFlag = ( uiCode == 1 ); |
---|
| 3190 | uiTotalSignalledWeightFlags += 2*wp[1].bPresentFlag; |
---|
[2] | 3191 | } |
---|
| 3192 | } |
---|
[608] | 3193 | for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ ) |
---|
[2] | 3194 | { |
---|
[608] | 3195 | pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); |
---|
[56] | 3196 | if ( wp[0].bPresentFlag ) |
---|
[2] | 3197 | { |
---|
[56] | 3198 | Int iDeltaWeight; |
---|
[608] | 3199 | READ_SVLC( iDeltaWeight, "delta_luma_weight_lX" ); // se(v): delta_luma_weight_l0[i] |
---|
| 3200 | assert( iDeltaWeight >= -128 ); |
---|
| 3201 | assert( iDeltaWeight <= 127 ); |
---|
[56] | 3202 | wp[0].iWeight = (iDeltaWeight + (1<<wp[0].uiLog2WeightDenom)); |
---|
[608] | 3203 | READ_SVLC( wp[0].iOffset, "luma_offset_lX" ); // se(v): luma_offset_l0[i] |
---|
| 3204 | assert( wp[0].iOffset >= -128 ); |
---|
| 3205 | assert( wp[0].iOffset <= 127 ); |
---|
[2] | 3206 | } |
---|
[56] | 3207 | else |
---|
[2] | 3208 | { |
---|
[56] | 3209 | wp[0].iWeight = (1 << wp[0].uiLog2WeightDenom); |
---|
| 3210 | wp[0].iOffset = 0; |
---|
[2] | 3211 | } |
---|
[56] | 3212 | if ( bChroma ) |
---|
[2] | 3213 | { |
---|
[56] | 3214 | if ( wp[1].bPresentFlag ) |
---|
[2] | 3215 | { |
---|
[56] | 3216 | for ( Int j=1 ; j<3 ; j++ ) |
---|
[2] | 3217 | { |
---|
[56] | 3218 | Int iDeltaWeight; |
---|
[608] | 3219 | READ_SVLC( iDeltaWeight, "delta_chroma_weight_lX" ); // se(v): chroma_weight_l0[i][j] |
---|
| 3220 | assert( iDeltaWeight >= -128 ); |
---|
| 3221 | assert( iDeltaWeight <= 127 ); |
---|
[56] | 3222 | wp[j].iWeight = (iDeltaWeight + (1<<wp[1].uiLog2WeightDenom)); |
---|
| 3223 | |
---|
| 3224 | Int iDeltaChroma; |
---|
[608] | 3225 | READ_SVLC( iDeltaChroma, "delta_chroma_offset_lX" ); // se(v): delta_chroma_offset_l0[i][j] |
---|
| 3226 | assert( iDeltaChroma >= -512 ); |
---|
| 3227 | assert( iDeltaChroma <= 511 ); |
---|
| 3228 | Int pred = ( 128 - ( ( 128*wp[j].iWeight)>>(wp[j].uiLog2WeightDenom) ) ); |
---|
| 3229 | wp[j].iOffset = Clip3(-128, 127, (iDeltaChroma + pred) ); |
---|
[2] | 3230 | } |
---|
| 3231 | } |
---|
[56] | 3232 | else |
---|
[2] | 3233 | { |
---|
[56] | 3234 | for ( Int j=1 ; j<3 ; j++ ) |
---|
[2] | 3235 | { |
---|
[56] | 3236 | wp[j].iWeight = (1 << wp[j].uiLog2WeightDenom); |
---|
| 3237 | wp[j].iOffset = 0; |
---|
[2] | 3238 | } |
---|
| 3239 | } |
---|
| 3240 | } |
---|
| 3241 | } |
---|
| 3242 | |
---|
[608] | 3243 | for ( Int iRefIdx=pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx<MAX_NUM_REF ; iRefIdx++ ) |
---|
[2] | 3244 | { |
---|
[608] | 3245 | pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); |
---|
[2] | 3246 | |
---|
[56] | 3247 | wp[0].bPresentFlag = false; |
---|
| 3248 | wp[1].bPresentFlag = false; |
---|
| 3249 | wp[2].bPresentFlag = false; |
---|
[2] | 3250 | } |
---|
| 3251 | } |
---|
[608] | 3252 | assert(uiTotalSignalledWeightFlags<=24); |
---|
[2] | 3253 | } |
---|
| 3254 | |
---|
[56] | 3255 | /** decode quantization matrix |
---|
[608] | 3256 | * \param scalingList quantization matrix information |
---|
| 3257 | */ |
---|
[56] | 3258 | Void TDecCavlc::parseScalingList(TComScalingList* scalingList) |
---|
[2] | 3259 | { |
---|
[56] | 3260 | UInt code, sizeId, listId; |
---|
| 3261 | Bool scalingListPredModeFlag; |
---|
[608] | 3262 | //for each size |
---|
| 3263 | for(sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
[2] | 3264 | { |
---|
[608] | 3265 | for(listId = 0; listId < g_scalingListNum[sizeId]; listId++) |
---|
[2] | 3266 | { |
---|
[608] | 3267 | READ_FLAG( code, "scaling_list_pred_mode_flag"); |
---|
| 3268 | scalingListPredModeFlag = (code) ? true : false; |
---|
| 3269 | if(!scalingListPredModeFlag) //Copy Mode |
---|
[2] | 3270 | { |
---|
[608] | 3271 | READ_UVLC( code, "scaling_list_pred_matrix_id_delta"); |
---|
| 3272 | scalingList->setRefMatrixId (sizeId,listId,(UInt)((Int)(listId)-(code))); |
---|
| 3273 | if( sizeId > SCALING_LIST_8x8 ) |
---|
[2] | 3274 | { |
---|
[608] | 3275 | scalingList->setScalingListDC(sizeId,listId,((listId == scalingList->getRefMatrixId (sizeId,listId))? 16 :scalingList->getScalingListDC(sizeId, scalingList->getRefMatrixId (sizeId,listId)))); |
---|
[2] | 3276 | } |
---|
[608] | 3277 | scalingList->processRefMatrix( sizeId, listId, scalingList->getRefMatrixId (sizeId,listId)); |
---|
| 3278 | |
---|
[2] | 3279 | } |
---|
[608] | 3280 | else //DPCM Mode |
---|
| 3281 | { |
---|
| 3282 | xDecodeScalingList(scalingList, sizeId, listId); |
---|
| 3283 | } |
---|
[2] | 3284 | } |
---|
| 3285 | } |
---|
| 3286 | |
---|
| 3287 | return; |
---|
| 3288 | } |
---|
[56] | 3289 | /** decode DPCM |
---|
[608] | 3290 | * \param scalingList quantization matrix information |
---|
| 3291 | * \param sizeId size index |
---|
| 3292 | * \param listId list index |
---|
| 3293 | */ |
---|
[56] | 3294 | Void TDecCavlc::xDecodeScalingList(TComScalingList *scalingList, UInt sizeId, UInt listId) |
---|
[2] | 3295 | { |
---|
[56] | 3296 | Int i,coefNum = min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId]); |
---|
| 3297 | Int data; |
---|
| 3298 | Int scalingListDcCoefMinus8 = 0; |
---|
| 3299 | Int nextCoef = SCALING_LIST_START_VALUE; |
---|
[608] | 3300 | UInt* scan = (sizeId == 0) ? g_auiSigLastScan [ SCAN_DIAG ] [ 1 ] : g_sigLastScanCG32x32; |
---|
[56] | 3301 | Int *dst = scalingList->getScalingListAddress(sizeId, listId); |
---|
[2] | 3302 | |
---|
[56] | 3303 | if( sizeId > SCALING_LIST_8x8 ) |
---|
[2] | 3304 | { |
---|
[56] | 3305 | READ_SVLC( scalingListDcCoefMinus8, "scaling_list_dc_coef_minus8"); |
---|
| 3306 | scalingList->setScalingListDC(sizeId,listId,scalingListDcCoefMinus8 + 8); |
---|
[608] | 3307 | nextCoef = scalingList->getScalingListDC(sizeId,listId); |
---|
[2] | 3308 | } |
---|
| 3309 | |
---|
[608] | 3310 | for(i = 0; i < coefNum; i++) |
---|
[2] | 3311 | { |
---|
[608] | 3312 | READ_SVLC( data, "scaling_list_delta_coef"); |
---|
| 3313 | nextCoef = (nextCoef + data + 256 ) % 256; |
---|
| 3314 | dst[scan[i]] = nextCoef; |
---|
[2] | 3315 | } |
---|
| 3316 | } |
---|
| 3317 | |
---|
[56] | 3318 | Bool TDecCavlc::xMoreRbspData() |
---|
| 3319 | { |
---|
| 3320 | Int bitsLeft = m_pcBitstream->getNumBitsLeft(); |
---|
[2] | 3321 | |
---|
[56] | 3322 | // if there are more than 8 bits, it cannot be rbsp_trailing_bits |
---|
| 3323 | if (bitsLeft > 8) |
---|
[2] | 3324 | { |
---|
[56] | 3325 | return true; |
---|
| 3326 | } |
---|
[2] | 3327 | |
---|
[56] | 3328 | UChar lastByte = m_pcBitstream->peekBits(bitsLeft); |
---|
| 3329 | Int cnt = bitsLeft; |
---|
[2] | 3330 | |
---|
[56] | 3331 | // remove trailing bits equal to zero |
---|
| 3332 | while ((cnt>0) && ((lastByte & 1) == 0)) |
---|
| 3333 | { |
---|
| 3334 | lastByte >>= 1; |
---|
| 3335 | cnt--; |
---|
| 3336 | } |
---|
| 3337 | // remove bit equal to one |
---|
| 3338 | cnt--; |
---|
[2] | 3339 | |
---|
[56] | 3340 | // we should not have a negative number of bits |
---|
| 3341 | assert (cnt>=0); |
---|
[2] | 3342 | |
---|
[56] | 3343 | // we have more data, if cnt is not zero |
---|
| 3344 | return (cnt>0); |
---|
| 3345 | } |
---|
[2] | 3346 | |
---|
[56] | 3347 | //! \} |
---|
[608] | 3348 | |
---|