[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 | * |
---|
| 6 | * Copyright (c) 2010-2013, ITU/ISO/IEC |
---|
| 7 | * All rights reserved. |
---|
| 8 | * |
---|
| 9 | * Redistribution and use in source and binary forms, with or without |
---|
| 10 | * modification, are permitted provided that the following conditions are met: |
---|
| 11 | * |
---|
| 12 | * * Redistributions of source code must retain the above copyright notice, |
---|
| 13 | * this list of conditions and the following disclaimer. |
---|
| 14 | * * Redistributions in binary form must reproduce the above copyright notice, |
---|
| 15 | * this list of conditions and the following disclaimer in the documentation |
---|
| 16 | * and/or other materials provided with the distribution. |
---|
| 17 | * * Neither the name of the ITU/ISO/IEC nor the names of its contributors may |
---|
| 18 | * be used to endorse or promote products derived from this software without |
---|
| 19 | * specific prior written permission. |
---|
| 20 | * |
---|
| 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
---|
| 22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
---|
| 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
---|
| 24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS |
---|
| 25 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
---|
| 26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
---|
| 27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
---|
| 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
---|
| 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
---|
| 30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
---|
| 31 | * THE POSSIBILITY OF SUCH DAMAGE. |
---|
| 32 | */ |
---|
[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 |
---|
| 55 | fprintf( g_hTrace, "=========== Sequence Parameter Set ===========\n" ); |
---|
| 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 | } |
---|
| 68 | fprintf( g_hTrace, "=========== Picture Parameter Set ===========\n" ); |
---|
| 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 | |
---|
[608] | 217 | Void TDecCavlc::parsePPS(TComPPS* pcPPS) |
---|
[2] | 218 | { |
---|
[56] | 219 | #if ENC_DEC_TRACE |
---|
[608] | 220 | xTracePPSHeader (pcPPS); |
---|
[2] | 221 | #endif |
---|
[608] | 222 | UInt uiCode; |
---|
[2] | 223 | |
---|
[608] | 224 | Int iCode; |
---|
[2] | 225 | |
---|
[608] | 226 | READ_UVLC( uiCode, "pps_pic_parameter_set_id"); |
---|
| 227 | assert(uiCode <= 63); |
---|
| 228 | pcPPS->setPPSId (uiCode); |
---|
| 229 | |
---|
| 230 | READ_UVLC( uiCode, "pps_seq_parameter_set_id"); |
---|
| 231 | assert(uiCode <= 15); |
---|
| 232 | pcPPS->setSPSId (uiCode); |
---|
| 233 | |
---|
| 234 | READ_FLAG( uiCode, "dependent_slice_segments_enabled_flag" ); pcPPS->setDependentSliceSegmentsEnabledFlag ( uiCode == 1 ); |
---|
| 235 | READ_FLAG( uiCode, "output_flag_present_flag" ); pcPPS->setOutputFlagPresentFlag( uiCode==1 ); |
---|
[2] | 236 | |
---|
[608] | 237 | READ_CODE(3, uiCode, "num_extra_slice_header_bits"); pcPPS->setNumExtraSliceHeaderBits(uiCode); |
---|
| 238 | READ_FLAG ( uiCode, "sign_data_hiding_flag" ); pcPPS->setSignHideFlag( uiCode ); |
---|
[2] | 239 | |
---|
[608] | 240 | READ_FLAG( uiCode, "cabac_init_present_flag" ); pcPPS->setCabacInitPresentFlag( uiCode ? true : false ); |
---|
[56] | 241 | |
---|
[608] | 242 | READ_UVLC(uiCode, "num_ref_idx_l0_default_active_minus1"); |
---|
| 243 | assert(uiCode <= 14); |
---|
| 244 | pcPPS->setNumRefIdxL0DefaultActive(uiCode+1); |
---|
| 245 | |
---|
| 246 | READ_UVLC(uiCode, "num_ref_idx_l1_default_active_minus1"); |
---|
| 247 | assert(uiCode <= 14); |
---|
| 248 | pcPPS->setNumRefIdxL1DefaultActive(uiCode+1); |
---|
| 249 | |
---|
| 250 | READ_SVLC(iCode, "init_qp_minus26" ); pcPPS->setPicInitQPMinus26(iCode); |
---|
| 251 | READ_FLAG( uiCode, "constrained_intra_pred_flag" ); pcPPS->setConstrainedIntraPred( uiCode ? true : false ); |
---|
| 252 | READ_FLAG( uiCode, "transform_skip_enabled_flag" ); |
---|
| 253 | pcPPS->setUseTransformSkip ( uiCode ? true : false ); |
---|
[2] | 254 | |
---|
[608] | 255 | READ_FLAG( uiCode, "cu_qp_delta_enabled_flag" ); pcPPS->setUseDQP( uiCode ? true : false ); |
---|
| 256 | if( pcPPS->getUseDQP() ) |
---|
[56] | 257 | { |
---|
[608] | 258 | READ_UVLC( uiCode, "diff_cu_qp_delta_depth" ); |
---|
| 259 | pcPPS->setMaxCuDQPDepth( uiCode ); |
---|
[56] | 260 | } |
---|
| 261 | else |
---|
| 262 | { |
---|
[608] | 263 | pcPPS->setMaxCuDQPDepth( 0 ); |
---|
[56] | 264 | } |
---|
[608] | 265 | READ_SVLC( iCode, "pps_cb_qp_offset"); |
---|
| 266 | pcPPS->setChromaCbQpOffset(iCode); |
---|
| 267 | assert( pcPPS->getChromaCbQpOffset() >= -12 ); |
---|
| 268 | assert( pcPPS->getChromaCbQpOffset() <= 12 ); |
---|
[2] | 269 | |
---|
[608] | 270 | READ_SVLC( iCode, "pps_cr_qp_offset"); |
---|
| 271 | pcPPS->setChromaCrQpOffset(iCode); |
---|
| 272 | assert( pcPPS->getChromaCrQpOffset() >= -12 ); |
---|
| 273 | assert( pcPPS->getChromaCrQpOffset() <= 12 ); |
---|
[56] | 274 | |
---|
[608] | 275 | READ_FLAG( uiCode, "pps_slice_chroma_qp_offsets_present_flag" ); |
---|
| 276 | pcPPS->setSliceChromaQpFlag( uiCode ? true : false ); |
---|
[56] | 277 | |
---|
[608] | 278 | READ_FLAG( uiCode, "weighted_pred_flag" ); // Use of Weighting Prediction (P_SLICE) |
---|
| 279 | pcPPS->setUseWP( uiCode==1 ); |
---|
| 280 | READ_FLAG( uiCode, "weighted_bipred_flag" ); // Use of Bi-Directional Weighting Prediction (B_SLICE) |
---|
| 281 | pcPPS->setWPBiPred( uiCode==1 ); |
---|
[56] | 282 | |
---|
[608] | 283 | READ_FLAG( uiCode, "transquant_bypass_enable_flag"); |
---|
| 284 | pcPPS->setTransquantBypassEnableFlag(uiCode ? true : false); |
---|
| 285 | READ_FLAG( uiCode, "tiles_enabled_flag" ); pcPPS->setTilesEnabledFlag ( uiCode == 1 ); |
---|
| 286 | READ_FLAG( uiCode, "entropy_coding_sync_enabled_flag" ); pcPPS->setEntropyCodingSyncEnabledFlag( uiCode == 1 ); |
---|
| 287 | |
---|
| 288 | if( pcPPS->getTilesEnabledFlag() ) |
---|
[56] | 289 | { |
---|
[608] | 290 | READ_UVLC ( uiCode, "num_tile_columns_minus1" ); pcPPS->setNumColumnsMinus1( uiCode ); |
---|
| 291 | READ_UVLC ( uiCode, "num_tile_rows_minus1" ); pcPPS->setNumRowsMinus1( uiCode ); |
---|
| 292 | READ_FLAG ( uiCode, "uniform_spacing_flag" ); pcPPS->setUniformSpacingFlag( uiCode ); |
---|
| 293 | |
---|
| 294 | if( !pcPPS->getUniformSpacingFlag()) |
---|
[2] | 295 | { |
---|
[608] | 296 | UInt* columnWidth = (UInt*)malloc(pcPPS->getNumColumnsMinus1()*sizeof(UInt)); |
---|
| 297 | for(UInt i=0; i<pcPPS->getNumColumnsMinus1(); i++) |
---|
| 298 | { |
---|
| 299 | READ_UVLC( uiCode, "column_width_minus1" ); |
---|
| 300 | columnWidth[i] = uiCode+1; |
---|
[56] | 301 | } |
---|
[608] | 302 | pcPPS->setColumnWidth(columnWidth); |
---|
| 303 | free(columnWidth); |
---|
| 304 | |
---|
| 305 | UInt* rowHeight = (UInt*)malloc(pcPPS->getNumRowsMinus1()*sizeof(UInt)); |
---|
| 306 | for(UInt i=0; i<pcPPS->getNumRowsMinus1(); i++) |
---|
[56] | 307 | { |
---|
[608] | 308 | READ_UVLC( uiCode, "row_height_minus1" ); |
---|
| 309 | rowHeight[i] = uiCode + 1; |
---|
[2] | 310 | } |
---|
[608] | 311 | pcPPS->setRowHeight(rowHeight); |
---|
| 312 | free(rowHeight); |
---|
[2] | 313 | } |
---|
[608] | 314 | |
---|
| 315 | if(pcPPS->getNumColumnsMinus1() !=0 || pcPPS->getNumRowsMinus1() !=0) |
---|
[2] | 316 | { |
---|
[608] | 317 | READ_FLAG ( uiCode, "loop_filter_across_tiles_enabled_flag" ); pcPPS->setLoopFilterAcrossTilesEnabledFlag( uiCode ? true : false ); |
---|
[2] | 318 | } |
---|
[56] | 319 | } |
---|
[608] | 320 | READ_FLAG( uiCode, "loop_filter_across_slices_enabled_flag" ); pcPPS->setLoopFilterAcrossSlicesEnabledFlag( uiCode ? true : false ); |
---|
| 321 | READ_FLAG( uiCode, "deblocking_filter_control_present_flag" ); pcPPS->setDeblockingFilterControlPresentFlag( uiCode ? true : false ); |
---|
| 322 | if(pcPPS->getDeblockingFilterControlPresentFlag()) |
---|
[56] | 323 | { |
---|
[608] | 324 | READ_FLAG( uiCode, "deblocking_filter_override_enabled_flag" ); pcPPS->setDeblockingFilterOverrideEnabledFlag( uiCode ? true : false ); |
---|
| 325 | READ_FLAG( uiCode, "pps_disable_deblocking_filter_flag" ); pcPPS->setPicDisableDeblockingFilterFlag(uiCode ? true : false ); |
---|
| 326 | if(!pcPPS->getPicDisableDeblockingFilterFlag()) |
---|
[56] | 327 | { |
---|
[608] | 328 | READ_SVLC ( iCode, "pps_beta_offset_div2" ); pcPPS->setDeblockingFilterBetaOffsetDiv2( iCode ); |
---|
| 329 | READ_SVLC ( iCode, "pps_tc_offset_div2" ); pcPPS->setDeblockingFilterTcOffsetDiv2( iCode ); |
---|
[56] | 330 | } |
---|
| 331 | } |
---|
[622] | 332 | #if H_MV5 |
---|
| 333 | #if H_MV |
---|
| 334 | if ( pcPPS->getLayerId() > 0 ) |
---|
| 335 | { |
---|
| 336 | READ_FLAG( uiCode, "pps_infer_scaling_list_flag" ); pcPPS->setPpsInferScalingListFlag( uiCode == 1 ); |
---|
| 337 | } |
---|
| 338 | |
---|
| 339 | if( pcPPS->getPpsInferScalingListFlag( ) ) |
---|
| 340 | { |
---|
| 341 | READ_CODE( 6, uiCode, "pps_scaling_list_ref_layer_id" ); pcPPS->setPpsScalingListRefLayerId( uiCode ); |
---|
| 342 | } |
---|
| 343 | else |
---|
| 344 | { |
---|
| 345 | #endif |
---|
| 346 | #endif |
---|
[608] | 347 | READ_FLAG( uiCode, "pps_scaling_list_data_present_flag" ); pcPPS->setScalingListPresentFlag( uiCode ? true : false ); |
---|
| 348 | if(pcPPS->getScalingListPresentFlag ()) |
---|
[2] | 349 | { |
---|
[608] | 350 | parseScalingList( pcPPS->getScalingList() ); |
---|
[2] | 351 | } |
---|
[622] | 352 | #if H_MV5 |
---|
| 353 | #if H_MV |
---|
| 354 | } |
---|
| 355 | #endif |
---|
| 356 | #endif |
---|
[2] | 357 | |
---|
[608] | 358 | READ_FLAG( uiCode, "lists_modification_present_flag"); |
---|
| 359 | pcPPS->setListsModificationPresentFlag(uiCode); |
---|
[2] | 360 | |
---|
[608] | 361 | READ_UVLC( uiCode, "log2_parallel_merge_level_minus2"); |
---|
| 362 | pcPPS->setLog2ParallelMergeLevelMinus2 (uiCode); |
---|
[2] | 363 | |
---|
[608] | 364 | READ_FLAG( uiCode, "slice_segment_header_extension_present_flag"); |
---|
| 365 | pcPPS->setSliceHeaderExtensionPresentFlag(uiCode); |
---|
[56] | 366 | |
---|
[608] | 367 | READ_FLAG( uiCode, "pps_extension_flag"); |
---|
| 368 | if (uiCode) |
---|
[2] | 369 | { |
---|
[608] | 370 | while ( xMoreRbspData() ) |
---|
[56] | 371 | { |
---|
[608] | 372 | READ_FLAG( uiCode, "pps_extension_data_flag"); |
---|
[56] | 373 | } |
---|
[2] | 374 | } |
---|
[56] | 375 | } |
---|
[2] | 376 | |
---|
[608] | 377 | Void TDecCavlc::parseVUI(TComVUI* pcVUI, TComSPS *pcSPS) |
---|
| 378 | { |
---|
| 379 | #if ENC_DEC_TRACE |
---|
| 380 | fprintf( g_hTrace, "----------- vui_parameters -----------\n"); |
---|
| 381 | #endif |
---|
| 382 | UInt uiCode; |
---|
[2] | 383 | |
---|
[608] | 384 | READ_FLAG( uiCode, "aspect_ratio_info_present_flag"); pcVUI->setAspectRatioInfoPresentFlag(uiCode); |
---|
| 385 | if (pcVUI->getAspectRatioInfoPresentFlag()) |
---|
[2] | 386 | { |
---|
[608] | 387 | READ_CODE(8, uiCode, "aspect_ratio_idc"); pcVUI->setAspectRatioIdc(uiCode); |
---|
| 388 | if (pcVUI->getAspectRatioIdc() == 255) |
---|
[2] | 389 | { |
---|
[608] | 390 | READ_CODE(16, uiCode, "sar_width"); pcVUI->setSarWidth(uiCode); |
---|
| 391 | READ_CODE(16, uiCode, "sar_height"); pcVUI->setSarHeight(uiCode); |
---|
[2] | 392 | } |
---|
| 393 | } |
---|
[608] | 394 | |
---|
| 395 | READ_FLAG( uiCode, "overscan_info_present_flag"); pcVUI->setOverscanInfoPresentFlag(uiCode); |
---|
| 396 | if (pcVUI->getOverscanInfoPresentFlag()) |
---|
[56] | 397 | { |
---|
[608] | 398 | READ_FLAG( uiCode, "overscan_appropriate_flag"); pcVUI->setOverscanAppropriateFlag(uiCode); |
---|
[56] | 399 | } |
---|
[2] | 400 | |
---|
[608] | 401 | READ_FLAG( uiCode, "video_signal_type_present_flag"); pcVUI->setVideoSignalTypePresentFlag(uiCode); |
---|
| 402 | if (pcVUI->getVideoSignalTypePresentFlag()) |
---|
[2] | 403 | { |
---|
[608] | 404 | READ_CODE(3, uiCode, "video_format"); pcVUI->setVideoFormat(uiCode); |
---|
| 405 | READ_FLAG( uiCode, "video_full_range_flag"); pcVUI->setVideoFullRangeFlag(uiCode); |
---|
| 406 | READ_FLAG( uiCode, "colour_description_present_flag"); pcVUI->setColourDescriptionPresentFlag(uiCode); |
---|
| 407 | if (pcVUI->getColourDescriptionPresentFlag()) |
---|
[2] | 408 | { |
---|
[608] | 409 | READ_CODE(8, uiCode, "colour_primaries"); pcVUI->setColourPrimaries(uiCode); |
---|
| 410 | READ_CODE(8, uiCode, "transfer_characteristics"); pcVUI->setTransferCharacteristics(uiCode); |
---|
| 411 | READ_CODE(8, uiCode, "matrix_coefficients"); pcVUI->setMatrixCoefficients(uiCode); |
---|
[2] | 412 | } |
---|
| 413 | } |
---|
[56] | 414 | |
---|
[608] | 415 | READ_FLAG( uiCode, "chroma_loc_info_present_flag"); pcVUI->setChromaLocInfoPresentFlag(uiCode); |
---|
| 416 | if (pcVUI->getChromaLocInfoPresentFlag()) |
---|
[2] | 417 | { |
---|
[608] | 418 | READ_UVLC( uiCode, "chroma_sample_loc_type_top_field" ); pcVUI->setChromaSampleLocTypeTopField(uiCode); |
---|
| 419 | READ_UVLC( uiCode, "chroma_sample_loc_type_bottom_field" ); pcVUI->setChromaSampleLocTypeBottomField(uiCode); |
---|
[2] | 420 | } |
---|
| 421 | |
---|
[608] | 422 | READ_FLAG( uiCode, "neutral_chroma_indication_flag"); pcVUI->setNeutralChromaIndicationFlag(uiCode); |
---|
[2] | 423 | |
---|
[608] | 424 | READ_FLAG( uiCode, "field_seq_flag"); pcVUI->setFieldSeqFlag(uiCode); |
---|
[2] | 425 | |
---|
[608] | 426 | READ_FLAG(uiCode, "frame_field_info_present_flag"); pcVUI->setFrameFieldInfoPresentFlag(uiCode); |
---|
[56] | 427 | |
---|
[608] | 428 | READ_FLAG( uiCode, "default_display_window_flag"); |
---|
| 429 | if (uiCode != 0) |
---|
[56] | 430 | { |
---|
[608] | 431 | Window &defDisp = pcVUI->getDefaultDisplayWindow(); |
---|
[622] | 432 | #if !H_MV5 |
---|
[608] | 433 | READ_UVLC( uiCode, "def_disp_win_left_offset" ); defDisp.setWindowLeftOffset ( uiCode * TComSPS::getWinUnitX( pcSPS->getChromaFormatIdc()) ); |
---|
| 434 | READ_UVLC( uiCode, "def_disp_win_right_offset" ); defDisp.setWindowRightOffset ( uiCode * TComSPS::getWinUnitX( pcSPS->getChromaFormatIdc()) ); |
---|
| 435 | READ_UVLC( uiCode, "def_disp_win_top_offset" ); defDisp.setWindowTopOffset ( uiCode * TComSPS::getWinUnitY( pcSPS->getChromaFormatIdc()) ); |
---|
| 436 | READ_UVLC( uiCode, "def_disp_win_bottom_offset" ); defDisp.setWindowBottomOffset( uiCode * TComSPS::getWinUnitY( pcSPS->getChromaFormatIdc()) ); |
---|
[622] | 437 | #else |
---|
| 438 | #if H_MV |
---|
| 439 | defDisp.setScaledFlag( false ); |
---|
| 440 | READ_UVLC( uiCode, "def_disp_win_left_offset" ); defDisp.setWindowLeftOffset ( uiCode ); |
---|
| 441 | READ_UVLC( uiCode, "def_disp_win_right_offset" ); defDisp.setWindowRightOffset ( uiCode ); |
---|
| 442 | READ_UVLC( uiCode, "def_disp_win_top_offset" ); defDisp.setWindowTopOffset ( uiCode ); |
---|
| 443 | READ_UVLC( uiCode, "def_disp_win_bottom_offset" ); defDisp.setWindowBottomOffset( uiCode ); |
---|
| 444 | #else |
---|
| 445 | READ_UVLC( uiCode, "def_disp_win_left_offset" ); defDisp.setWindowLeftOffset ( uiCode * TComSPS::getWinUnitX( pcSPS->getChromaFormatIdc()) ); |
---|
| 446 | READ_UVLC( uiCode, "def_disp_win_right_offset" ); defDisp.setWindowRightOffset ( uiCode * TComSPS::getWinUnitX( pcSPS->getChromaFormatIdc()) ); |
---|
| 447 | READ_UVLC( uiCode, "def_disp_win_top_offset" ); defDisp.setWindowTopOffset ( uiCode * TComSPS::getWinUnitY( pcSPS->getChromaFormatIdc()) ); |
---|
| 448 | READ_UVLC( uiCode, "def_disp_win_bottom_offset" ); defDisp.setWindowBottomOffset( uiCode * TComSPS::getWinUnitY( pcSPS->getChromaFormatIdc()) ); |
---|
| 449 | #endif |
---|
| 450 | #endif |
---|
[56] | 451 | } |
---|
[608] | 452 | TimingInfo *timingInfo = pcVUI->getTimingInfo(); |
---|
| 453 | READ_FLAG( uiCode, "vui_timing_info_present_flag"); timingInfo->setTimingInfoPresentFlag (uiCode ? true : false); |
---|
| 454 | if(timingInfo->getTimingInfoPresentFlag()) |
---|
[56] | 455 | { |
---|
[608] | 456 | READ_CODE( 32, uiCode, "vui_num_units_in_tick"); timingInfo->setNumUnitsInTick (uiCode); |
---|
| 457 | READ_CODE( 32, uiCode, "vui_time_scale"); timingInfo->setTimeScale (uiCode); |
---|
| 458 | READ_FLAG( uiCode, "vui_poc_proportional_to_timing_flag"); timingInfo->setPocProportionalToTimingFlag(uiCode ? true : false); |
---|
| 459 | if(timingInfo->getPocProportionalToTimingFlag()) |
---|
[2] | 460 | { |
---|
[608] | 461 | READ_UVLC( uiCode, "vui_num_ticks_poc_diff_one_minus1"); timingInfo->setNumTicksPocDiffOneMinus1 (uiCode); |
---|
[2] | 462 | } |
---|
[608] | 463 | READ_FLAG( uiCode, "hrd_parameters_present_flag"); pcVUI->setHrdParametersPresentFlag(uiCode); |
---|
| 464 | if( pcVUI->getHrdParametersPresentFlag() ) |
---|
[56] | 465 | { |
---|
[608] | 466 | parseHrdParameters( pcVUI->getHrdParameters(), 1, pcSPS->getMaxTLayers() - 1 ); |
---|
[56] | 467 | } |
---|
| 468 | } |
---|
[608] | 469 | READ_FLAG( uiCode, "bitstream_restriction_flag"); pcVUI->setBitstreamRestrictionFlag(uiCode); |
---|
| 470 | if (pcVUI->getBitstreamRestrictionFlag()) |
---|
[56] | 471 | { |
---|
[608] | 472 | READ_FLAG( uiCode, "tiles_fixed_structure_flag"); pcVUI->setTilesFixedStructureFlag(uiCode); |
---|
[622] | 473 | #if !H_MV5 |
---|
[608] | 474 | #if H_MV |
---|
| 475 | if ( pcSPS->getLayerId() > 0 ) |
---|
| 476 | { |
---|
| 477 | READ_FLAG( uiCode, "tile_boundaries_aligned_flag" ); pcVUI->setTileBoundariesAlignedFlag( uiCode == 1 ); |
---|
| 478 | } |
---|
| 479 | #endif |
---|
[622] | 480 | #endif |
---|
[608] | 481 | READ_FLAG( uiCode, "motion_vectors_over_pic_boundaries_flag"); pcVUI->setMotionVectorsOverPicBoundariesFlag(uiCode); |
---|
| 482 | READ_FLAG( uiCode, "restricted_ref_pic_lists_flag"); pcVUI->setRestrictedRefPicListsFlag(uiCode); |
---|
| 483 | READ_UVLC( uiCode, "min_spatial_segmentation_idc"); pcVUI->setMinSpatialSegmentationIdc(uiCode); |
---|
| 484 | assert(uiCode < 4096); |
---|
| 485 | READ_UVLC( uiCode, "max_bytes_per_pic_denom" ); pcVUI->setMaxBytesPerPicDenom(uiCode); |
---|
| 486 | READ_UVLC( uiCode, "max_bits_per_mincu_denom" ); pcVUI->setMaxBitsPerMinCuDenom(uiCode); |
---|
| 487 | READ_UVLC( uiCode, "log2_max_mv_length_horizontal" ); pcVUI->setLog2MaxMvLengthHorizontal(uiCode); |
---|
| 488 | READ_UVLC( uiCode, "log2_max_mv_length_vertical" ); pcVUI->setLog2MaxMvLengthVertical(uiCode); |
---|
[56] | 489 | } |
---|
[2] | 490 | } |
---|
[56] | 491 | |
---|
[608] | 492 | Void TDecCavlc::parseHrdParameters(TComHRD *hrd, Bool commonInfPresentFlag, UInt maxNumSubLayersMinus1) |
---|
[56] | 493 | { |
---|
| 494 | UInt uiCode; |
---|
[608] | 495 | if( commonInfPresentFlag ) |
---|
[2] | 496 | { |
---|
[608] | 497 | READ_FLAG( uiCode, "nal_hrd_parameters_present_flag" ); hrd->setNalHrdParametersPresentFlag( uiCode == 1 ? true : false ); |
---|
| 498 | READ_FLAG( uiCode, "vcl_hrd_parameters_present_flag" ); hrd->setVclHrdParametersPresentFlag( uiCode == 1 ? true : false ); |
---|
| 499 | if( hrd->getNalHrdParametersPresentFlag() || hrd->getVclHrdParametersPresentFlag() ) |
---|
[2] | 500 | { |
---|
[608] | 501 | READ_FLAG( uiCode, "sub_pic_cpb_params_present_flag" ); hrd->setSubPicCpbParamsPresentFlag( uiCode == 1 ? true : false ); |
---|
| 502 | if( hrd->getSubPicCpbParamsPresentFlag() ) |
---|
[2] | 503 | { |
---|
[608] | 504 | READ_CODE( 8, uiCode, "tick_divisor_minus2" ); hrd->setTickDivisorMinus2( uiCode ); |
---|
| 505 | READ_CODE( 5, uiCode, "du_cpb_removal_delay_length_minus1" ); hrd->setDuCpbRemovalDelayLengthMinus1( uiCode ); |
---|
| 506 | READ_FLAG( uiCode, "sub_pic_cpb_params_in_pic_timing_sei_flag" ); hrd->setSubPicCpbParamsInPicTimingSEIFlag( uiCode == 1 ? true : false ); |
---|
| 507 | READ_CODE( 5, uiCode, "dpb_output_delay_du_length_minus1" ); hrd->setDpbOutputDelayDuLengthMinus1( uiCode ); |
---|
[2] | 508 | } |
---|
[608] | 509 | READ_CODE( 4, uiCode, "bit_rate_scale" ); hrd->setBitRateScale( uiCode ); |
---|
| 510 | READ_CODE( 4, uiCode, "cpb_size_scale" ); hrd->setCpbSizeScale( uiCode ); |
---|
| 511 | if( hrd->getSubPicCpbParamsPresentFlag() ) |
---|
[2] | 512 | { |
---|
[608] | 513 | READ_CODE( 4, uiCode, "cpb_size_du_scale" ); hrd->setDuCpbSizeScale( uiCode ); |
---|
[2] | 514 | } |
---|
[608] | 515 | READ_CODE( 5, uiCode, "initial_cpb_removal_delay_length_minus1" ); hrd->setInitialCpbRemovalDelayLengthMinus1( uiCode ); |
---|
| 516 | READ_CODE( 5, uiCode, "au_cpb_removal_delay_length_minus1" ); hrd->setCpbRemovalDelayLengthMinus1( uiCode ); |
---|
| 517 | READ_CODE( 5, uiCode, "dpb_output_delay_length_minus1" ); hrd->setDpbOutputDelayLengthMinus1( uiCode ); |
---|
[2] | 518 | } |
---|
| 519 | } |
---|
[608] | 520 | Int i, j, nalOrVcl; |
---|
| 521 | for( i = 0; i <= maxNumSubLayersMinus1; i ++ ) |
---|
[56] | 522 | { |
---|
[608] | 523 | READ_FLAG( uiCode, "fixed_pic_rate_general_flag" ); hrd->setFixedPicRateFlag( i, uiCode == 1 ? true : false ); |
---|
| 524 | if( !hrd->getFixedPicRateFlag( i ) ) |
---|
[2] | 525 | { |
---|
[608] | 526 | READ_FLAG( uiCode, "fixed_pic_rate_within_cvs_flag" ); hrd->setFixedPicRateWithinCvsFlag( i, uiCode == 1 ? true : false ); |
---|
[2] | 527 | } |
---|
[608] | 528 | else |
---|
[210] | 529 | { |
---|
[608] | 530 | hrd->setFixedPicRateWithinCvsFlag( i, true ); |
---|
[210] | 531 | } |
---|
[608] | 532 | hrd->setLowDelayHrdFlag( i, 0 ); // Infered to be 0 when not present |
---|
| 533 | hrd->setCpbCntMinus1 ( i, 0 ); // Infered to be 0 when not present |
---|
| 534 | if( hrd->getFixedPicRateWithinCvsFlag( i ) ) |
---|
[210] | 535 | { |
---|
[608] | 536 | READ_UVLC( uiCode, "elemental_duration_in_tc_minus1" ); hrd->setPicDurationInTcMinus1( i, uiCode ); |
---|
[210] | 537 | } |
---|
[608] | 538 | else |
---|
| 539 | { |
---|
| 540 | READ_FLAG( uiCode, "low_delay_hrd_flag" ); hrd->setLowDelayHrdFlag( i, uiCode == 1 ? true : false ); |
---|
[210] | 541 | } |
---|
[608] | 542 | if (!hrd->getLowDelayHrdFlag( i )) |
---|
[210] | 543 | { |
---|
[608] | 544 | READ_UVLC( uiCode, "cpb_cnt_minus1" ); hrd->setCpbCntMinus1( i, uiCode ); |
---|
[210] | 545 | } |
---|
[608] | 546 | for( nalOrVcl = 0; nalOrVcl < 2; nalOrVcl ++ ) |
---|
[210] | 547 | { |
---|
[608] | 548 | if( ( ( nalOrVcl == 0 ) && ( hrd->getNalHrdParametersPresentFlag() ) ) || |
---|
| 549 | ( ( nalOrVcl == 1 ) && ( hrd->getVclHrdParametersPresentFlag() ) ) ) |
---|
[77] | 550 | { |
---|
[608] | 551 | for( j = 0; j <= ( hrd->getCpbCntMinus1( i ) ); j ++ ) |
---|
[77] | 552 | { |
---|
[608] | 553 | READ_UVLC( uiCode, "bit_rate_value_minus1" ); hrd->setBitRateValueMinus1( i, j, nalOrVcl, uiCode ); |
---|
| 554 | READ_UVLC( uiCode, "cpb_size_value_minus1" ); hrd->setCpbSizeValueMinus1( i, j, nalOrVcl, uiCode ); |
---|
| 555 | if( hrd->getSubPicCpbParamsPresentFlag() ) |
---|
| 556 | { |
---|
| 557 | READ_UVLC( uiCode, "cpb_size_du_value_minus1" ); hrd->setDuCpbSizeValueMinus1( i, j, nalOrVcl, uiCode ); |
---|
| 558 | READ_UVLC( uiCode, "bit_rate_du_value_minus1" ); hrd->setDuBitRateValueMinus1( i, j, nalOrVcl, uiCode ); |
---|
| 559 | } |
---|
| 560 | READ_FLAG( uiCode, "cbr_flag" ); hrd->setCbrFlag( i, j, nalOrVcl, uiCode == 1 ? true : false ); |
---|
[77] | 561 | } |
---|
| 562 | } |
---|
| 563 | } |
---|
| 564 | } |
---|
| 565 | } |
---|
| 566 | |
---|
[608] | 567 | #if H_3D |
---|
| 568 | Void TDecCavlc::parseSPS(TComSPS* pcSPS, Int viewIndex, Bool depthFlag ) |
---|
[56] | 569 | #else |
---|
| 570 | Void TDecCavlc::parseSPS(TComSPS* pcSPS) |
---|
[2] | 571 | #endif |
---|
| 572 | { |
---|
[56] | 573 | #if ENC_DEC_TRACE |
---|
| 574 | xTraceSPSHeader (pcSPS); |
---|
| 575 | #endif |
---|
[608] | 576 | |
---|
[56] | 577 | UInt uiCode; |
---|
[608] | 578 | READ_CODE( 4, uiCode, "sps_video_parameter_set_id"); pcSPS->setVPSId ( uiCode ); |
---|
| 579 | #if H_MV |
---|
| 580 | if ( pcSPS->getLayerId() == 0 ) |
---|
| 581 | { |
---|
[210] | 582 | #endif |
---|
[608] | 583 | READ_CODE( 3, uiCode, "sps_max_sub_layers_minus1" ); pcSPS->setMaxTLayers ( uiCode+1 ); |
---|
| 584 | assert(uiCode <= 6); |
---|
| 585 | |
---|
| 586 | READ_FLAG( uiCode, "sps_temporal_id_nesting_flag" ); pcSPS->setTemporalIdNestingFlag ( uiCode > 0 ? true : false ); |
---|
| 587 | if ( pcSPS->getMaxTLayers() == 1 ) |
---|
| 588 | { |
---|
| 589 | // sps_temporal_id_nesting_flag must be 1 when sps_max_sub_layers_minus1 is 0 |
---|
| 590 | assert( uiCode == 1 ); |
---|
| 591 | } |
---|
| 592 | |
---|
| 593 | parsePTL(pcSPS->getPTL(), 1, pcSPS->getMaxTLayers() - 1); |
---|
| 594 | #if H_MV |
---|
| 595 | } |
---|
[77] | 596 | #endif |
---|
[608] | 597 | READ_UVLC( uiCode, "sps_seq_parameter_set_id" ); pcSPS->setSPSId( uiCode ); |
---|
| 598 | assert(uiCode <= 15); |
---|
[622] | 599 | #if H_MV5 |
---|
| 600 | #if H_MV |
---|
| 601 | if ( pcSPS->getLayerId() > 0 ) |
---|
| 602 | { |
---|
| 603 | READ_FLAG( uiCode, "update_rep_format_flag" ); pcSPS->setUpdateRepFormatFlag( uiCode == 1 ); |
---|
| 604 | } |
---|
[608] | 605 | |
---|
[622] | 606 | if ( pcSPS->getUpdateRepFormatFlag() ) |
---|
| 607 | { |
---|
| 608 | #endif |
---|
| 609 | #endif |
---|
[56] | 610 | READ_UVLC( uiCode, "chroma_format_idc" ); pcSPS->setChromaFormatIdc( uiCode ); |
---|
[608] | 611 | assert(uiCode <= 3); |
---|
| 612 | // 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 |
---|
| 613 | assert (uiCode == 1); |
---|
| 614 | if( uiCode == 3 ) |
---|
| 615 | { |
---|
| 616 | READ_FLAG( uiCode, "separate_colour_plane_flag"); assert(uiCode == 0); |
---|
| 617 | } |
---|
| 618 | |
---|
[56] | 619 | READ_UVLC ( uiCode, "pic_width_in_luma_samples" ); pcSPS->setPicWidthInLumaSamples ( uiCode ); |
---|
| 620 | READ_UVLC ( uiCode, "pic_height_in_luma_samples" ); pcSPS->setPicHeightInLumaSamples( uiCode ); |
---|
[622] | 621 | #if H_MV5 |
---|
| 622 | #if H_MV |
---|
| 623 | } |
---|
| 624 | #endif |
---|
| 625 | #endif |
---|
[608] | 626 | READ_FLAG( uiCode, "conformance_window_flag"); |
---|
[56] | 627 | if (uiCode != 0) |
---|
[2] | 628 | { |
---|
[608] | 629 | Window &conf = pcSPS->getConformanceWindow(); |
---|
[622] | 630 | #if H_MV5 |
---|
| 631 | #if H_MV |
---|
| 632 | // Needs to be scaled later, when ChromaFormatIdc is known. |
---|
| 633 | conf.setScaledFlag( false ); |
---|
| 634 | READ_UVLC( uiCode, "conf_win_left_offset" ); conf.setWindowLeftOffset ( uiCode ); |
---|
| 635 | READ_UVLC( uiCode, "conf_win_right_offset" ); conf.setWindowRightOffset ( uiCode ); |
---|
| 636 | READ_UVLC( uiCode, "conf_win_top_offset" ); conf.setWindowTopOffset ( uiCode ); |
---|
| 637 | READ_UVLC( uiCode, "conf_win_bottom_offset" ); conf.setWindowBottomOffset( uiCode ); |
---|
| 638 | #else |
---|
[608] | 639 | READ_UVLC( uiCode, "conf_win_left_offset" ); conf.setWindowLeftOffset ( uiCode * TComSPS::getWinUnitX( pcSPS->getChromaFormatIdc() ) ); |
---|
| 640 | READ_UVLC( uiCode, "conf_win_right_offset" ); conf.setWindowRightOffset ( uiCode * TComSPS::getWinUnitX( pcSPS->getChromaFormatIdc() ) ); |
---|
| 641 | READ_UVLC( uiCode, "conf_win_top_offset" ); conf.setWindowTopOffset ( uiCode * TComSPS::getWinUnitY( pcSPS->getChromaFormatIdc() ) ); |
---|
| 642 | READ_UVLC( uiCode, "conf_win_bottom_offset" ); conf.setWindowBottomOffset( uiCode * TComSPS::getWinUnitY( pcSPS->getChromaFormatIdc() ) ); |
---|
[622] | 643 | #endif |
---|
| 644 | #else |
---|
| 645 | READ_UVLC( uiCode, "conf_win_left_offset" ); conf.setWindowLeftOffset ( uiCode * TComSPS::getWinUnitX( pcSPS->getChromaFormatIdc() ) ); |
---|
| 646 | READ_UVLC( uiCode, "conf_win_right_offset" ); conf.setWindowRightOffset ( uiCode * TComSPS::getWinUnitX( pcSPS->getChromaFormatIdc() ) ); |
---|
| 647 | READ_UVLC( uiCode, "conf_win_top_offset" ); conf.setWindowTopOffset ( uiCode * TComSPS::getWinUnitY( pcSPS->getChromaFormatIdc() ) ); |
---|
| 648 | READ_UVLC( uiCode, "conf_win_bottom_offset" ); conf.setWindowBottomOffset( uiCode * TComSPS::getWinUnitY( pcSPS->getChromaFormatIdc() ) ); |
---|
| 649 | #endif |
---|
[2] | 650 | } |
---|
| 651 | |
---|
[622] | 652 | #if H_MV5 |
---|
| 653 | #if H_MV |
---|
| 654 | if ( pcSPS->getUpdateRepFormatFlag() ) |
---|
| 655 | { |
---|
| 656 | #endif |
---|
| 657 | #endif |
---|
[56] | 658 | READ_UVLC( uiCode, "bit_depth_luma_minus8" ); |
---|
[608] | 659 | assert(uiCode <= 6); |
---|
| 660 | pcSPS->setBitDepthY( uiCode + 8 ); |
---|
[56] | 661 | pcSPS->setQpBDOffsetY( (Int) (6*uiCode) ); |
---|
[2] | 662 | |
---|
[56] | 663 | READ_UVLC( uiCode, "bit_depth_chroma_minus8" ); |
---|
[608] | 664 | assert(uiCode <= 6); |
---|
| 665 | pcSPS->setBitDepthC( uiCode + 8 ); |
---|
[56] | 666 | pcSPS->setQpBDOffsetC( (Int) (6*uiCode) ); |
---|
[622] | 667 | #if H_MV5 |
---|
| 668 | #if H_MV |
---|
| 669 | } |
---|
| 670 | #endif |
---|
| 671 | #endif |
---|
[2] | 672 | |
---|
[608] | 673 | READ_UVLC( uiCode, "log2_max_pic_order_cnt_lsb_minus4" ); pcSPS->setBitsForPOC( 4 + uiCode ); |
---|
| 674 | assert(uiCode <= 12); |
---|
[56] | 675 | |
---|
[608] | 676 | UInt subLayerOrderingInfoPresentFlag; |
---|
| 677 | READ_FLAG(subLayerOrderingInfoPresentFlag, "sps_sub_layer_ordering_info_present_flag"); |
---|
| 678 | |
---|
| 679 | for(UInt i=0; i <= pcSPS->getMaxTLayers()-1; i++) |
---|
[2] | 680 | { |
---|
[608] | 681 | #if H_MV |
---|
| 682 | READ_UVLC ( uiCode, "sps_max_dec_pic_buffering_minus1[i]"); |
---|
| 683 | #else |
---|
| 684 | READ_UVLC ( uiCode, "sps_max_dec_pic_buffering_minus1"); |
---|
[56] | 685 | #endif |
---|
[608] | 686 | pcSPS->setMaxDecPicBuffering( uiCode + 1, i); |
---|
| 687 | #if H_MV |
---|
| 688 | READ_UVLC ( uiCode, "sps_num_reorder_pics[i]" ); |
---|
| 689 | #else |
---|
| 690 | READ_UVLC ( uiCode, "sps_num_reorder_pics" ); |
---|
| 691 | #endif |
---|
[56] | 692 | pcSPS->setNumReorderPics(uiCode, i); |
---|
[608] | 693 | #if H_MV |
---|
[622] | 694 | #if H_MV5 |
---|
| 695 | READ_UVLC ( uiCode, "sps_max_latency_increase_plus1[i]"); |
---|
| 696 | #else |
---|
[608] | 697 | READ_UVLC ( uiCode, "sps_max_latency_increase[i]"); |
---|
[622] | 698 | #endif |
---|
[608] | 699 | #else |
---|
[622] | 700 | READ_UVLC ( uiCode, "sps_max_latency_increase_plus1"); |
---|
[608] | 701 | #endif |
---|
[56] | 702 | pcSPS->setMaxLatencyIncrease( uiCode, i ); |
---|
[608] | 703 | |
---|
| 704 | if (!subLayerOrderingInfoPresentFlag) |
---|
| 705 | { |
---|
| 706 | for (i++; i <= pcSPS->getMaxTLayers()-1; i++) |
---|
| 707 | { |
---|
| 708 | pcSPS->setMaxDecPicBuffering(pcSPS->getMaxDecPicBuffering(0), i); |
---|
| 709 | pcSPS->setNumReorderPics(pcSPS->getNumReorderPics(0), i); |
---|
| 710 | pcSPS->setMaxLatencyIncrease(pcSPS->getMaxLatencyIncrease(0), i); |
---|
| 711 | } |
---|
| 712 | break; |
---|
| 713 | } |
---|
[2] | 714 | } |
---|
| 715 | |
---|
[56] | 716 | READ_UVLC( uiCode, "log2_min_coding_block_size_minus3" ); |
---|
[608] | 717 | Int log2MinCUSize = uiCode + 3; |
---|
| 718 | pcSPS->setLog2MinCodingBlockSize(log2MinCUSize); |
---|
[56] | 719 | READ_UVLC( uiCode, "log2_diff_max_min_coding_block_size" ); |
---|
[608] | 720 | pcSPS->setLog2DiffMaxMinCodingBlockSize(uiCode); |
---|
| 721 | Int maxCUDepthDelta = uiCode; |
---|
| 722 | pcSPS->setMaxCUWidth ( 1<<(log2MinCUSize + maxCUDepthDelta) ); |
---|
| 723 | pcSPS->setMaxCUHeight ( 1<<(log2MinCUSize + maxCUDepthDelta) ); |
---|
[56] | 724 | READ_UVLC( uiCode, "log2_min_transform_block_size_minus2" ); pcSPS->setQuadtreeTULog2MinSize( uiCode + 2 ); |
---|
[2] | 725 | |
---|
[56] | 726 | READ_UVLC( uiCode, "log2_diff_max_min_transform_block_size" ); pcSPS->setQuadtreeTULog2MaxSize( uiCode + pcSPS->getQuadtreeTULog2MinSize() ); |
---|
| 727 | pcSPS->setMaxTrSize( 1<<(uiCode + pcSPS->getQuadtreeTULog2MinSize()) ); |
---|
[2] | 728 | |
---|
[608] | 729 | READ_UVLC( uiCode, "max_transform_hierarchy_depth_inter" ); pcSPS->setQuadtreeTUMaxDepthInter( uiCode+1 ); |
---|
| 730 | READ_UVLC( uiCode, "max_transform_hierarchy_depth_intra" ); pcSPS->setQuadtreeTUMaxDepthIntra( uiCode+1 ); |
---|
[2] | 731 | |
---|
[608] | 732 | Int addCuDepth = max (0, log2MinCUSize - (Int)pcSPS->getQuadtreeTULog2MinSize() ); |
---|
| 733 | pcSPS->setMaxCUDepth( maxCUDepthDelta + addCuDepth ); |
---|
[2] | 734 | |
---|
[56] | 735 | READ_FLAG( uiCode, "scaling_list_enabled_flag" ); pcSPS->setScalingListFlag ( uiCode ); |
---|
[608] | 736 | if(pcSPS->getScalingListFlag()) |
---|
[2] | 737 | { |
---|
[622] | 738 | #if H_MV5 |
---|
| 739 | #if H_MV |
---|
| 740 | if ( pcSPS->getLayerId() > 0 ) |
---|
| 741 | { |
---|
| 742 | READ_FLAG( uiCode, "sps_infer_scaling_list_flag" ); pcSPS->setSpsInferScalingListFlag( uiCode == 1 ); |
---|
| 743 | } |
---|
| 744 | |
---|
| 745 | if ( pcSPS->getSpsInferScalingListFlag() ) |
---|
| 746 | { |
---|
| 747 | READ_CODE( 6, uiCode, "sps_scaling_list_ref_layer_id" ); pcSPS->setSpsScalingListRefLayerId( uiCode ); |
---|
| 748 | } |
---|
| 749 | else |
---|
| 750 | { |
---|
| 751 | #endif |
---|
| 752 | #endif |
---|
[608] | 753 | READ_FLAG( uiCode, "sps_scaling_list_data_present_flag" ); pcSPS->setScalingListPresentFlag ( uiCode ); |
---|
| 754 | if(pcSPS->getScalingListPresentFlag ()) |
---|
| 755 | { |
---|
| 756 | parseScalingList( pcSPS->getScalingList() ); |
---|
| 757 | } |
---|
[622] | 758 | #if H_MV5 |
---|
| 759 | #if H_MV |
---|
| 760 | } |
---|
| 761 | #endif |
---|
| 762 | #endif |
---|
[56] | 763 | } |
---|
[608] | 764 | READ_FLAG( uiCode, "amp_enabled_flag" ); pcSPS->setUseAMP( uiCode ); |
---|
| 765 | READ_FLAG( uiCode, "sample_adaptive_offset_enabled_flag" ); pcSPS->setUseSAO ( uiCode ? true : false ); |
---|
| 766 | |
---|
| 767 | READ_FLAG( uiCode, "pcm_enabled_flag" ); pcSPS->setUsePCM( uiCode ? true : false ); |
---|
[56] | 768 | if( pcSPS->getUsePCM() ) |
---|
| 769 | { |
---|
[608] | 770 | READ_CODE( 4, uiCode, "pcm_sample_bit_depth_luma_minus1" ); pcSPS->setPCMBitDepthLuma ( 1 + uiCode ); |
---|
| 771 | READ_CODE( 4, uiCode, "pcm_sample_bit_depth_chroma_minus1" ); pcSPS->setPCMBitDepthChroma ( 1 + uiCode ); |
---|
| 772 | READ_UVLC( uiCode, "log2_min_pcm_luma_coding_block_size_minus3" ); pcSPS->setPCMLog2MinSize (uiCode+3); |
---|
| 773 | READ_UVLC( uiCode, "log2_diff_max_min_pcm_luma_coding_block_size" ); pcSPS->setPCMLog2MaxSize ( uiCode+pcSPS->getPCMLog2MinSize() ); |
---|
| 774 | READ_FLAG( uiCode, "pcm_loop_filter_disable_flag" ); pcSPS->setPCMFilterDisableFlag ( uiCode ? true : false ); |
---|
[56] | 775 | } |
---|
[2] | 776 | |
---|
[608] | 777 | READ_UVLC( uiCode, "num_short_term_ref_pic_sets" ); |
---|
| 778 | assert(uiCode <= 64); |
---|
| 779 | pcSPS->createRPSList(uiCode); |
---|
[2] | 780 | |
---|
[56] | 781 | TComRPSList* rpsList = pcSPS->getRPSList(); |
---|
| 782 | TComReferencePictureSet* rps; |
---|
[2] | 783 | |
---|
[56] | 784 | for(UInt i=0; i< rpsList->getNumberOfReferencePictureSets(); i++) |
---|
[2] | 785 | { |
---|
[56] | 786 | rps = rpsList->getReferencePictureSet(i); |
---|
| 787 | parseShortTermRefPicSet(pcSPS,rps,i); |
---|
[2] | 788 | } |
---|
[56] | 789 | READ_FLAG( uiCode, "long_term_ref_pics_present_flag" ); pcSPS->setLongTermRefsPresent(uiCode); |
---|
[608] | 790 | if (pcSPS->getLongTermRefsPresent()) |
---|
[56] | 791 | { |
---|
[608] | 792 | READ_UVLC( uiCode, "num_long_term_ref_pic_sps" ); |
---|
| 793 | pcSPS->setNumLongTermRefPicSPS(uiCode); |
---|
| 794 | for (UInt k = 0; k < pcSPS->getNumLongTermRefPicSPS(); k++) |
---|
| 795 | { |
---|
| 796 | READ_CODE( pcSPS->getBitsForPOC(), uiCode, "lt_ref_pic_poc_lsb_sps" ); |
---|
| 797 | pcSPS->setLtRefPicPocLsbSps(k, uiCode); |
---|
| 798 | READ_FLAG( uiCode, "used_by_curr_pic_lt_sps_flag[i]"); |
---|
| 799 | pcSPS->setUsedByCurrPicLtSPSFlag(k, uiCode?1:0); |
---|
| 800 | } |
---|
[56] | 801 | } |
---|
[608] | 802 | READ_FLAG( uiCode, "sps_temporal_mvp_enable_flag" ); pcSPS->setTMVPFlagsPresent(uiCode); |
---|
[2] | 803 | |
---|
[608] | 804 | READ_FLAG( uiCode, "sps_strong_intra_smoothing_enable_flag" ); pcSPS->setUseStrongIntraSmoothing(uiCode); |
---|
[2] | 805 | |
---|
[608] | 806 | READ_FLAG( uiCode, "vui_parameters_present_flag" ); pcSPS->setVuiParametersPresentFlag(uiCode); |
---|
| 807 | |
---|
| 808 | if (pcSPS->getVuiParametersPresentFlag()) |
---|
[2] | 809 | { |
---|
[608] | 810 | parseVUI(pcSPS->getVuiParameters(), pcSPS); |
---|
| 811 | } |
---|
| 812 | |
---|
| 813 | READ_FLAG( uiCode, "sps_extension_flag"); |
---|
| 814 | if (uiCode) |
---|
| 815 | { |
---|
[622] | 816 | #if !H_MV5 |
---|
[608] | 817 | #if !H_MV |
---|
| 818 | while ( xMoreRbspData() ) |
---|
[2] | 819 | { |
---|
[608] | 820 | READ_FLAG( uiCode, "sps_extension_data_flag"); |
---|
| 821 | } |
---|
| 822 | #else |
---|
| 823 | READ_FLAG( uiCode, "inter_view_mv_vert_constraint_flag" ); pcSPS->setInterViewMvVertConstraintFlag(uiCode == 1 ? true : false); |
---|
| 824 | //// sps_extension_vui_parameters( ) |
---|
| 825 | if( pcSPS->getVuiParameters()->getBitstreamRestrictionFlag() ) |
---|
| 826 | { |
---|
| 827 | READ_UVLC( uiCode, "num_ilp_restricted_ref_layers" ); pcSPS->setNumIlpRestrictedRefLayers( uiCode ); |
---|
| 828 | for( Int i = 0; i < pcSPS->getNumIlpRestrictedRefLayers( ); i++ ) |
---|
| 829 | { |
---|
| 830 | READ_UVLC( uiCode, "min_spatial_segment_offset_plus1" ); pcSPS->setMinSpatialSegmentOffsetPlus1( i, uiCode ); |
---|
| 831 | if( pcSPS->getMinSpatialSegmentOffsetPlus1( i ) > 0 ) |
---|
| 832 | { |
---|
| 833 | READ_FLAG( uiCode, "ctu_based_offset_enabled_flag[ i ]"); pcSPS->setCtuBasedOffsetEnabledFlag(i, uiCode == 1 ); |
---|
| 834 | if( pcSPS->getCtuBasedOffsetEnabledFlag( i ) ) |
---|
| 835 | { |
---|
| 836 | READ_UVLC( uiCode, "min_horizontal_ctu_offset_plus1[ i ]"); pcSPS->setMinHorizontalCtuOffsetPlus1( i, uiCode ); |
---|
| 837 | } |
---|
| 838 | } |
---|
| 839 | } |
---|
| 840 | } |
---|
| 841 | |
---|
| 842 | #if H_3D_QTLPC |
---|
| 843 | if( depthFlag ) |
---|
| 844 | { |
---|
| 845 | READ_FLAG( uiCode, "use_qtl_flag" ); |
---|
| 846 | pcSPS->setUseQTL( uiCode ); |
---|
| 847 | READ_FLAG( uiCode, "use_pc_flag" ); |
---|
| 848 | pcSPS->setUsePC( uiCode ); |
---|
| 849 | } |
---|
| 850 | #endif |
---|
| 851 | //// sps_extension_vui_parameters( ) END |
---|
| 852 | READ_UVLC( uiCode, "sps_shvc_reserved_zero_idc" ); |
---|
| 853 | READ_FLAG( uiCode, "sps_extension2_flag"); |
---|
| 854 | if ( uiCode ) |
---|
| 855 | { |
---|
| 856 | #if !H_3D |
---|
| 857 | while ( xMoreRbspData() ) |
---|
| 858 | { |
---|
| 859 | READ_FLAG( uiCode, "sps_extension_data_flag"); |
---|
[56] | 860 | } |
---|
[608] | 861 | #else |
---|
| 862 | |
---|
| 863 | UInt uiCamParPrecision = 0; |
---|
| 864 | Bool bCamParSlice = false; |
---|
| 865 | if ( !depthFlag ) |
---|
| 866 | { |
---|
| 867 | READ_UVLC( uiCamParPrecision, "cp_precision" ); |
---|
| 868 | READ_FLAG( uiCode, "cp_in_slice_header_flag" ); bCamParSlice = ( uiCode == 1 ); |
---|
| 869 | if( !bCamParSlice ) |
---|
| 870 | { |
---|
| 871 | for( UInt uiBaseIndex = 0; uiBaseIndex < viewIndex; uiBaseIndex++ ) |
---|
| 872 | { |
---|
| 873 | Int iCode; |
---|
| 874 | READ_SVLC( iCode, "cp_scale" ); m_aaiTempScale [ uiBaseIndex ][ viewIndex ] = iCode; |
---|
| 875 | READ_SVLC( iCode, "cp_off" ); m_aaiTempOffset [ uiBaseIndex ][ viewIndex ] = iCode; |
---|
| 876 | READ_SVLC( iCode, "cp_inv_scale_plus_scale" ); m_aaiTempScale [ viewIndex ][ uiBaseIndex ] = iCode - m_aaiTempScale [ uiBaseIndex ][ viewIndex ]; |
---|
| 877 | READ_SVLC( iCode, "cp_inv_off_plus_off" ); m_aaiTempOffset [ viewIndex ][ uiBaseIndex ] = iCode - m_aaiTempOffset[ uiBaseIndex ][ viewIndex ]; |
---|
| 878 | } |
---|
| 879 | } |
---|
| 880 | } |
---|
| 881 | pcSPS->initCamParaSPS( viewIndex, uiCamParPrecision, bCamParSlice, m_aaiTempScale, m_aaiTempOffset ); |
---|
| 882 | READ_FLAG( uiCode, "sps_extension3_flag"); |
---|
| 883 | if ( uiCode ) |
---|
| 884 | { |
---|
| 885 | while ( xMoreRbspData() ) |
---|
| 886 | { |
---|
| 887 | READ_FLAG( uiCode, "sps_extension_data_flag"); |
---|
| 888 | } |
---|
| 889 | } |
---|
| 890 | #endif // !H_3D |
---|
| 891 | } |
---|
| 892 | #endif // !H_MV |
---|
| 893 | } |
---|
| 894 | } |
---|
[622] | 895 | #else |
---|
| 896 | #if H_MV |
---|
| 897 | parseSPSExtension( pcSPS ); |
---|
| 898 | READ_FLAG( uiCode, "sps_extension2_flag"); |
---|
| 899 | if ( uiCode ) |
---|
| 900 | { |
---|
| 901 | #if H_3D |
---|
| 902 | parseSPSExtension2( pcSPS, viewIndex, depthFlag ); |
---|
| 903 | READ_FLAG( uiCode, "sps_extension3_flag"); |
---|
| 904 | if ( uiCode ) |
---|
| 905 | { |
---|
| 906 | #endif |
---|
| 907 | #endif |
---|
| 908 | while ( xMoreRbspData() ) |
---|
| 909 | { |
---|
| 910 | READ_FLAG( uiCode, "sps_extension_data_flag"); |
---|
| 911 | } |
---|
| 912 | #if H_MV |
---|
| 913 | #if H_3D |
---|
| 914 | } |
---|
| 915 | #endif |
---|
| 916 | } |
---|
| 917 | #endif |
---|
| 918 | } |
---|
| 919 | } |
---|
| 920 | #endif |
---|
| 921 | #if H_MV5 |
---|
| 922 | Void TDecCavlc::parseSPSExtension( TComSPS* pcSPS ) |
---|
| 923 | { |
---|
| 924 | UInt uiCode; |
---|
| 925 | READ_FLAG( uiCode, "inter_view_mv_vert_constraint_flag" ); pcSPS->setInterViewMvVertConstraintFlag(uiCode == 1 ? true : false); |
---|
| 926 | READ_UVLC( uiCode, "sps_shvc_reserved_zero_idc" ); |
---|
| 927 | } |
---|
[56] | 928 | |
---|
[622] | 929 | #if H_3D |
---|
| 930 | Void TDecCavlc::parseSPSExtension2( TComSPS* pcSPS, Int viewIndex, Bool depthFlag ) |
---|
| 931 | { |
---|
| 932 | UInt uiCode; |
---|
| 933 | #if H_3D_QTLPC |
---|
| 934 | //GT: This has to go to VPS |
---|
| 935 | if( depthFlag ) |
---|
| 936 | { |
---|
| 937 | READ_FLAG( uiCode, "use_qtl_flag" ); |
---|
| 938 | pcSPS->setUseQTL( uiCode ); |
---|
| 939 | READ_FLAG( uiCode, "use_pc_flag" ); |
---|
| 940 | pcSPS->setUsePC( uiCode ); |
---|
| 941 | } |
---|
| 942 | #endif |
---|
| 943 | |
---|
| 944 | UInt uiCamParPrecision = 0; |
---|
| 945 | Bool bCamParSlice = false; |
---|
| 946 | if ( !depthFlag ) |
---|
| 947 | { |
---|
| 948 | READ_UVLC( uiCamParPrecision, "cp_precision" ); |
---|
| 949 | READ_FLAG( uiCode, "cp_in_slice_header_flag" ); bCamParSlice = ( uiCode == 1 ); |
---|
| 950 | if( !bCamParSlice ) |
---|
| 951 | { |
---|
| 952 | for( UInt uiBaseIndex = 0; uiBaseIndex < viewIndex; uiBaseIndex++ ) |
---|
| 953 | { |
---|
| 954 | Int iCode; |
---|
| 955 | READ_SVLC( iCode, "cp_scale" ); m_aaiTempScale [ uiBaseIndex ][ viewIndex ] = iCode; |
---|
| 956 | READ_SVLC( iCode, "cp_off" ); m_aaiTempOffset [ uiBaseIndex ][ viewIndex ] = iCode; |
---|
| 957 | READ_SVLC( iCode, "cp_inv_scale_plus_scale" ); m_aaiTempScale [ viewIndex ][ uiBaseIndex ] = iCode - m_aaiTempScale [ uiBaseIndex ][ viewIndex ]; |
---|
| 958 | READ_SVLC( iCode, "cp_inv_off_plus_off" ); m_aaiTempOffset [ viewIndex ][ uiBaseIndex ] = iCode - m_aaiTempOffset[ uiBaseIndex ][ viewIndex ]; |
---|
| 959 | } |
---|
| 960 | } |
---|
| 961 | } |
---|
| 962 | pcSPS->initCamParaSPS( viewIndex, uiCamParPrecision, bCamParSlice, m_aaiTempScale, m_aaiTempOffset ); |
---|
| 963 | } |
---|
| 964 | #endif |
---|
| 965 | #endif |
---|
| 966 | |
---|
[608] | 967 | Void TDecCavlc::parseVPS(TComVPS* pcVPS) |
---|
| 968 | { |
---|
| 969 | UInt uiCode; |
---|
| 970 | |
---|
| 971 | READ_CODE( 4, uiCode, "vps_video_parameter_set_id" ); pcVPS->setVPSId( uiCode ); |
---|
| 972 | READ_CODE( 2, uiCode, "vps_reserved_three_2bits" ); assert(uiCode == 3); |
---|
| 973 | #if H_MV |
---|
[622] | 974 | #if H_MV5 |
---|
| 975 | READ_CODE( 6, uiCode, "vps_max_layers_minus1" ); pcVPS->setMaxLayersMinus1( uiCode ); |
---|
| 976 | #else |
---|
[608] | 977 | READ_CODE( 6, uiCode, "vps_max_layers_minus1" ); pcVPS->setMaxLayers( uiCode + 1 ); |
---|
[622] | 978 | #endif |
---|
[608] | 979 | #else |
---|
| 980 | READ_CODE( 6, uiCode, "vps_reserved_zero_6bits" ); assert(uiCode == 0); |
---|
| 981 | #endif |
---|
| 982 | READ_CODE( 3, uiCode, "vps_max_sub_layers_minus1" ); pcVPS->setMaxTLayers( uiCode + 1 ); |
---|
| 983 | READ_FLAG( uiCode, "vps_temporal_id_nesting_flag" ); pcVPS->setTemporalNestingFlag( uiCode ? true:false ); |
---|
| 984 | assert (pcVPS->getMaxTLayers()>1||pcVPS->getTemporalNestingFlag()); |
---|
| 985 | #if H_MV |
---|
| 986 | READ_CODE( 16, uiCode, "vps_extension_offset" ); |
---|
| 987 | #else |
---|
| 988 | READ_CODE( 16, uiCode, "vps_reserved_ffff_16bits" ); assert(uiCode == 0xffff); |
---|
| 989 | #endif |
---|
| 990 | parsePTL ( pcVPS->getPTL(), true, pcVPS->getMaxTLayers()-1); |
---|
| 991 | UInt subLayerOrderingInfoPresentFlag; |
---|
| 992 | READ_FLAG(subLayerOrderingInfoPresentFlag, "vps_sub_layer_ordering_info_present_flag"); |
---|
| 993 | for(UInt i = 0; i <= pcVPS->getMaxTLayers()-1; i++) |
---|
| 994 | { |
---|
| 995 | READ_UVLC( uiCode, "vps_max_dec_pic_buffering_minus1[i]" ); pcVPS->setMaxDecPicBuffering( uiCode + 1, i ); |
---|
| 996 | READ_UVLC( uiCode, "vps_num_reorder_pics[i]" ); pcVPS->setNumReorderPics( uiCode, i ); |
---|
| 997 | READ_UVLC( uiCode, "vps_max_latency_increase_plus1[i]" ); pcVPS->setMaxLatencyIncrease( uiCode, i ); |
---|
| 998 | |
---|
| 999 | if (!subLayerOrderingInfoPresentFlag) |
---|
| 1000 | { |
---|
| 1001 | for (i++; i <= pcVPS->getMaxTLayers()-1; i++) |
---|
[56] | 1002 | { |
---|
[608] | 1003 | pcVPS->setMaxDecPicBuffering(pcVPS->getMaxDecPicBuffering(0), i); |
---|
| 1004 | pcVPS->setNumReorderPics(pcVPS->getNumReorderPics(0), i); |
---|
| 1005 | pcVPS->setMaxLatencyIncrease(pcVPS->getMaxLatencyIncrease(0), i); |
---|
[56] | 1006 | } |
---|
[608] | 1007 | break; |
---|
[2] | 1008 | } |
---|
[608] | 1009 | } |
---|
[56] | 1010 | |
---|
[608] | 1011 | assert( pcVPS->getNumHrdParameters() < MAX_VPS_OP_SETS_PLUS1 ); |
---|
| 1012 | #if H_MV |
---|
| 1013 | assert( pcVPS->getVpsMaxLayerId() < MAX_VPS_NUH_LAYER_ID_PLUS1 ); |
---|
| 1014 | READ_CODE( 6, uiCode, "vps_max_layer_id" ); pcVPS->setVpsMaxLayerId( uiCode ); |
---|
| 1015 | |
---|
| 1016 | READ_UVLC( uiCode, "vps_max_num_layer_sets_minus1" ); pcVPS->setVpsNumLayerSetsMinus1( uiCode ); |
---|
| 1017 | for( UInt opsIdx = 1; opsIdx <= pcVPS->getVpsNumLayerSetsMinus1(); opsIdx ++ ) |
---|
| 1018 | { |
---|
| 1019 | for( UInt i = 0; i <= pcVPS->getVpsMaxLayerId(); i ++ ) |
---|
| 1020 | #else |
---|
| 1021 | assert( pcVPS->getMaxNuhReservedZeroLayerId() < MAX_VPS_NUH_RESERVED_ZERO_LAYER_ID_PLUS1 ); |
---|
| 1022 | READ_CODE( 6, uiCode, "vps_max_nuh_reserved_zero_layer_id" ); pcVPS->setMaxNuhReservedZeroLayerId( uiCode ); |
---|
| 1023 | READ_UVLC( uiCode, "vps_max_op_sets_minus1" ); pcVPS->setMaxOpSets( uiCode + 1 ); |
---|
| 1024 | for( UInt opsIdx = 1; opsIdx <= ( pcVPS->getMaxOpSets() - 1 ); opsIdx ++ ) |
---|
| 1025 | { |
---|
| 1026 | // Operation point set |
---|
| 1027 | for( UInt i = 0; i <= pcVPS->getMaxNuhReservedZeroLayerId(); i ++ ) |
---|
| 1028 | #endif |
---|
[2] | 1029 | { |
---|
[608] | 1030 | READ_FLAG( uiCode, "layer_id_included_flag[opsIdx][i]" ); pcVPS->setLayerIdIncludedFlag( uiCode == 1 ? true : false, opsIdx, i ); |
---|
[2] | 1031 | } |
---|
| 1032 | } |
---|
[608] | 1033 | TimingInfo *timingInfo = pcVPS->getTimingInfo(); |
---|
| 1034 | READ_FLAG( uiCode, "vps_timing_info_present_flag"); timingInfo->setTimingInfoPresentFlag (uiCode ? true : false); |
---|
| 1035 | if(timingInfo->getTimingInfoPresentFlag()) |
---|
[2] | 1036 | { |
---|
[608] | 1037 | READ_CODE( 32, uiCode, "vps_num_units_in_tick"); timingInfo->setNumUnitsInTick (uiCode); |
---|
| 1038 | READ_CODE( 32, uiCode, "vps_time_scale"); timingInfo->setTimeScale (uiCode); |
---|
| 1039 | READ_FLAG( uiCode, "vps_poc_proportional_to_timing_flag"); timingInfo->setPocProportionalToTimingFlag(uiCode ? true : false); |
---|
| 1040 | if(timingInfo->getPocProportionalToTimingFlag()) |
---|
[2] | 1041 | { |
---|
[608] | 1042 | READ_UVLC( uiCode, "vps_num_ticks_poc_diff_one_minus1"); timingInfo->setNumTicksPocDiffOneMinus1 (uiCode); |
---|
| 1043 | } |
---|
| 1044 | READ_UVLC( uiCode, "vps_num_hrd_parameters" ); pcVPS->setNumHrdParameters( uiCode ); |
---|
[56] | 1045 | |
---|
[608] | 1046 | if( pcVPS->getNumHrdParameters() > 0 ) |
---|
| 1047 | { |
---|
| 1048 | pcVPS->createHrdParamBuffer(); |
---|
| 1049 | } |
---|
| 1050 | for( UInt i = 0; i < pcVPS->getNumHrdParameters(); i ++ ) |
---|
| 1051 | { |
---|
| 1052 | READ_UVLC( uiCode, "hrd_op_set_idx" ); pcVPS->setHrdOpSetIdx( uiCode, i ); |
---|
| 1053 | if( i > 0 ) |
---|
[2] | 1054 | { |
---|
[608] | 1055 | READ_FLAG( uiCode, "cprms_present_flag[i]" ); pcVPS->setCprmsPresentFlag( uiCode == 1 ? true : false, i ); |
---|
[2] | 1056 | } |
---|
[608] | 1057 | parseHrdParameters(pcVPS->getHrdParameters(i), pcVPS->getCprmsPresentFlag( i ), pcVPS->getMaxTLayers() - 1); |
---|
[56] | 1058 | } |
---|
[608] | 1059 | } |
---|
| 1060 | READ_FLAG( uiCode, "vps_extension_flag" ); |
---|
| 1061 | if (uiCode) |
---|
| 1062 | { |
---|
[622] | 1063 | #if !H_MV5 |
---|
[608] | 1064 | #if H_MV |
---|
| 1065 | m_pcBitstream->readOutTrailingBits(); |
---|
[2] | 1066 | |
---|
[608] | 1067 | READ_FLAG( uiCode, "avc_base_layer_flag" ); pcVPS->setAvcBaseLayerFlag( uiCode == 1 ? true : false ); |
---|
| 1068 | READ_FLAG( uiCode, "splitting_flag" ); pcVPS->setSplittingFlag( uiCode == 1 ? true : false ); |
---|
[2] | 1069 | |
---|
[608] | 1070 | for( Int sIdx = 0; sIdx < MAX_NUM_SCALABILITY_TYPES; sIdx++ ) |
---|
[2] | 1071 | { |
---|
[608] | 1072 | READ_FLAG( uiCode, "scalability_mask[i]" ); pcVPS->setScalabilityMask( sIdx, uiCode == 1 ? true : false ); |
---|
[2] | 1073 | } |
---|
[608] | 1074 | |
---|
| 1075 | for( Int sIdx = 0; sIdx < pcVPS->getNumScalabilityTypes( ) - ( pcVPS->getSplittingFlag() ? 1 : 0 ); sIdx++ ) |
---|
[189] | 1076 | { |
---|
[608] | 1077 | READ_CODE( 3, uiCode, "dimension_id_len_minus1[j]" ); pcVPS->setDimensionIdLen( sIdx, uiCode + 1 ); |
---|
[189] | 1078 | } |
---|
[608] | 1079 | |
---|
| 1080 | if ( pcVPS->getSplittingFlag() ) |
---|
| 1081 | { |
---|
| 1082 | pcVPS->setDimensionIdLen( pcVPS->getNumScalabilityTypes( ) - 1, pcVPS->inferLastDimsionIdLenMinus1() ); |
---|
| 1083 | } |
---|
| 1084 | |
---|
| 1085 | READ_FLAG( uiCode, "vps_nuh_layer_id_present_flag" ); pcVPS->setVpsNuhLayerIdPresentFlag( uiCode == 1 ? true : false ); |
---|
| 1086 | |
---|
| 1087 | for( Int i = 0; i <= pcVPS->getMaxLayers() - 1; i++ ) |
---|
| 1088 | { |
---|
| 1089 | if ( pcVPS->getVpsNuhLayerIdPresentFlag() && ( i > 0 ) ) |
---|
| 1090 | { |
---|
| 1091 | READ_CODE( 6, uiCode, "layer_id_in_nuh[i]" ); pcVPS->setLayerIdInNuh( i, uiCode ); |
---|
| 1092 | } |
---|
| 1093 | else |
---|
| 1094 | { |
---|
| 1095 | pcVPS->setLayerIdInNuh( i, i );; |
---|
| 1096 | } |
---|
| 1097 | |
---|
| 1098 | pcVPS->setLayerIdInVps( pcVPS->getLayerIdInNuh( i ), i ); |
---|
[189] | 1099 | |
---|
[608] | 1100 | for( Int j = 0; j < pcVPS->getNumScalabilityTypes() ; j++ ) |
---|
[189] | 1101 | { |
---|
[608] | 1102 | if ( !pcVPS->getSplittingFlag() ) |
---|
[189] | 1103 | { |
---|
[608] | 1104 | READ_CODE( pcVPS->getDimensionIdLen( j ), uiCode, "dimension_id[i][j]" ); pcVPS->setDimensionId( i, j, uiCode ); |
---|
| 1105 | } |
---|
| 1106 | else |
---|
[189] | 1107 | { |
---|
[608] | 1108 | pcVPS->setDimensionId( i, j, pcVPS->inferDimensionId( i, j) ); |
---|
[189] | 1109 | } |
---|
| 1110 | } |
---|
| 1111 | } |
---|
[56] | 1112 | |
---|
[443] | 1113 | |
---|
[608] | 1114 | for( Int i = 1; i <= pcVPS->getMaxLayers() - 1; i++ ) |
---|
| 1115 | { |
---|
| 1116 | for( Int j = 0; j < i; j++ ) |
---|
| 1117 | { |
---|
| 1118 | READ_FLAG( uiCode, "direct_dependency_flag[i][j]" ); pcVPS->setDirectDependencyFlag( i, j, uiCode ); |
---|
| 1119 | } |
---|
[2] | 1120 | } |
---|
[608] | 1121 | |
---|
| 1122 | for( Int i = 0; i < pcVPS->getMaxLayers() - 1; i++ ) |
---|
[2] | 1123 | { |
---|
[608] | 1124 | READ_CODE( 3, uiCode, "max_tid_il_ref_pics_plus1[i]" ); pcVPS->setMaxTidIlRefPicPlus1( i , uiCode ); |
---|
| 1125 | } |
---|
| 1126 | |
---|
| 1127 | READ_CODE( 10, uiCode, "vps_number_layer_sets_minus1" ); pcVPS->setVpsNumberLayerSetsMinus1 ( uiCode ); |
---|
| 1128 | READ_CODE( 6, uiCode, "vps_num_profile_tier_level_minus1" ); pcVPS->setVpsNumProfileTierLevelMinus1( uiCode ); |
---|
| 1129 | |
---|
| 1130 | for( Int i = 1; i <= pcVPS->getVpsNumProfileTierLevelMinus1(); i++ ) |
---|
| 1131 | { |
---|
| 1132 | READ_FLAG( uiCode, "vps_profile_present_flag[i]" ); pcVPS->setVpsProfilePresentFlag( i, uiCode == 1 ); |
---|
| 1133 | if( !pcVPS->getVpsProfilePresentFlag( i ) ) |
---|
[56] | 1134 | { |
---|
[608] | 1135 | READ_CODE( 6, uiCode, "profile_ref_minus1[i]" ); pcVPS->setProfileRefMinus1( i, uiCode ); |
---|
| 1136 | } |
---|
| 1137 | parsePTL ( pcVPS->getPTL( i ), pcVPS->getVpsProfilePresentFlag( i ), pcVPS->getMaxTLayers()-1); |
---|
| 1138 | if( !pcVPS->getVpsProfilePresentFlag( i ) ) |
---|
| 1139 | { |
---|
| 1140 | TComPTL temp = *pcVPS->getPTL( i ); |
---|
| 1141 | *pcVPS->getPTL( i ) = *pcVPS->getPTL( pcVPS->getProfileRefMinus1( i ) + 1 ); |
---|
| 1142 | pcVPS->getPTL( i )->copyLevelFrom( &temp ); |
---|
| 1143 | } |
---|
| 1144 | } |
---|
[313] | 1145 | |
---|
[608] | 1146 | Int numOutputLayerSets = pcVPS->getVpsNumberLayerSetsMinus1( ) + 1; |
---|
| 1147 | |
---|
| 1148 | READ_FLAG( uiCode, "more_output_layer_sets_than_default_flag" ); pcVPS->setMoreOutputLayerSetsThanDefaultFlag( uiCode == 1 ); |
---|
| 1149 | |
---|
| 1150 | if ( pcVPS->getMoreOutputLayerSetsThanDefaultFlag( ) ) |
---|
| 1151 | { |
---|
| 1152 | READ_CODE( 10, uiCode, "num_add_output_layer_sets_minus1" ); pcVPS->setNumAddOutputLayerSetsMinus1( uiCode ); |
---|
| 1153 | numOutputLayerSets += ( pcVPS->getNumAddOutputLayerSetsMinus1( ) + 1); |
---|
| 1154 | } |
---|
| 1155 | |
---|
| 1156 | if( numOutputLayerSets > 1) |
---|
| 1157 | { |
---|
| 1158 | READ_FLAG( uiCode, "default_one_target_output_layer_flag" ); pcVPS->setDefaultOneTargetOutputLayerFlag( uiCode == 1); |
---|
| 1159 | } |
---|
| 1160 | |
---|
| 1161 | for( Int i = 1; i < numOutputLayerSets; i++ ) |
---|
| 1162 | { |
---|
| 1163 | if( i > pcVPS->getVpsNumberLayerSetsMinus1( ) ) |
---|
| 1164 | { |
---|
| 1165 | READ_UVLC( uiCode, "output_layer_set_idx_minus1[i]" ); pcVPS->setOutputLayerSetIdxMinus1( i, uiCode ); |
---|
| 1166 | for( Int j = 0; j < pcVPS->getNumLayersInIdList( j ) - 1; j++ ) |
---|
[313] | 1167 | { |
---|
[608] | 1168 | READ_FLAG( uiCode, "output_layer_flag" ); pcVPS->setOutputLayerFlag( i, j, uiCode == 1 ); |
---|
| 1169 | } |
---|
| 1170 | } |
---|
| 1171 | if ( pcVPS->getProfileLevelTierIdxLen() > 0 ) |
---|
| 1172 | { |
---|
| 1173 | READ_CODE( pcVPS->getProfileLevelTierIdxLen(), uiCode,"profile_level_tier_idx[ i ]" ); pcVPS->setProfileLevelTierIdx( i , uiCode ); |
---|
| 1174 | } |
---|
| 1175 | } |
---|
[313] | 1176 | |
---|
[608] | 1177 | READ_FLAG( uiCode , "max_one_active_ref_layer_flag" ); pcVPS->setMaxOneActiveRefLayerFlag( uiCode == 1 ); |
---|
| 1178 | READ_UVLC( uiCode, "direct_dep_type_len_minus2"); pcVPS->setDirectDepTypeLenMinus2 ( uiCode ); |
---|
[443] | 1179 | |
---|
[608] | 1180 | for( Int i = 1; i <= pcVPS->getMaxLayers() - 1; i++ ) |
---|
| 1181 | { |
---|
| 1182 | for( Int j = 0; j < i; j++ ) |
---|
[56] | 1183 | { |
---|
[608] | 1184 | if (pcVPS->getDirectDependencyFlag( i, j) ) |
---|
| 1185 | { |
---|
| 1186 | READ_CODE( pcVPS->getDirectDepTypeLenMinus2( ) + 2, uiCode, "direct_dependency_type[i][j]" ); pcVPS->setDirectDependencyType( i, j , uiCode); |
---|
[56] | 1187 | } |
---|
[608] | 1188 | } |
---|
| 1189 | } |
---|
[2] | 1190 | |
---|
[608] | 1191 | READ_FLAG ( uiCode, "vps_shvc_reserved_zero_flag" ); |
---|
| 1192 | |
---|
| 1193 | #if H_3D |
---|
| 1194 | READ_FLAG( uiCode, "vps_extension2_flag" ); |
---|
| 1195 | if (uiCode) |
---|
| 1196 | { |
---|
| 1197 | m_pcBitstream->readOutTrailingBits(); |
---|
| 1198 | |
---|
| 1199 | for( Int i = 0; i <= pcVPS->getMaxLayers() - 1; i++ ) |
---|
| 1200 | { |
---|
| 1201 | |
---|
| 1202 | #if H_3D_ARP |
---|
| 1203 | pcVPS->setUseAdvRP ( i, 0 ); |
---|
| 1204 | pcVPS->setARPStepNum( i, 1 ); |
---|
| 1205 | #endif |
---|
| 1206 | if ( i != 0 ) |
---|
[56] | 1207 | { |
---|
[608] | 1208 | if( !( pcVPS->getDepthId( i ) == 1 ) ) |
---|
[56] | 1209 | { |
---|
[608] | 1210 | #if H_3D_IV_MERGE |
---|
| 1211 | READ_FLAG( uiCode, "iv_mv_pred_flag[i]"); pcVPS->setIvMvPredFlag ( i, uiCode == 1 ? true : false ); |
---|
[56] | 1212 | #endif |
---|
[608] | 1213 | #if H_3D_ARP |
---|
| 1214 | READ_FLAG( uiCode, "iv_res_pred_flag[i]" ); pcVPS->setUseAdvRP ( i, uiCode ); pcVPS->setARPStepNum( i, uiCode ? H_3D_ARP_WFNR : 1 ); |
---|
| 1215 | |
---|
[56] | 1216 | #endif |
---|
[608] | 1217 | #if H_3D_NBDV_REF |
---|
| 1218 | READ_FLAG( uiCode, "depth_refinement_flag[i]"); pcVPS->setDepthRefinementFlag ( i, uiCode == 1 ? true : false ); |
---|
[56] | 1219 | #endif |
---|
[608] | 1220 | #if H_3D_VSP |
---|
| 1221 | READ_FLAG( uiCode, "view_synthesis_pred_flag[i]"); pcVPS->setViewSynthesisPredFlag( i, uiCode == 1 ? true : false ); |
---|
[56] | 1222 | #endif |
---|
[608] | 1223 | } |
---|
| 1224 | else |
---|
| 1225 | { |
---|
[443] | 1226 | |
---|
[608] | 1227 | READ_FLAG( uiCode, "vps_depth_modes_flag[i]" ); pcVPS->setVpsDepthModesFlag( i, uiCode == 1 ? true : false ); |
---|
| 1228 | // READ_FLAG( uiCode, "lim_qt_pred_flag[i]"); pcVPS->setLimQtPreFlag ( i, uiCode == 1 ? true : false ); |
---|
| 1229 | #if H_3D_DIM_DLT |
---|
| 1230 | if( pcVPS->getVpsDepthModesFlag( i ) ) |
---|
| 1231 | { |
---|
| 1232 | READ_FLAG( uiCode, "dlt_flag[i]" ); pcVPS->setUseDLTFlag( i, uiCode == 1 ? true : false ); |
---|
| 1233 | } |
---|
| 1234 | if( pcVPS->getUseDLTFlag( i ) ) |
---|
| 1235 | { |
---|
| 1236 | // decode mapping |
---|
| 1237 | UInt uiNumDepthValues; |
---|
| 1238 | // parse number of values in DLT |
---|
| 1239 | READ_UVLC(uiNumDepthValues, "num_depth_values_in_dlt[i]"); |
---|
[443] | 1240 | |
---|
[608] | 1241 | // parse actual DLT values |
---|
| 1242 | Int* aiIdx2DepthValue = (Int*) calloc(uiNumDepthValues, sizeof(Int)); |
---|
| 1243 | for(Int d=0; d<uiNumDepthValues; d++) |
---|
| 1244 | { |
---|
| 1245 | READ_UVLC(uiCode, "dlt_depth_value[i][d]"); |
---|
| 1246 | aiIdx2DepthValue[d] = (Int)uiCode; |
---|
| 1247 | } |
---|
[443] | 1248 | |
---|
[608] | 1249 | pcVPS->setDepthLUTs(i, aiIdx2DepthValue, uiNumDepthValues); |
---|
[443] | 1250 | |
---|
[608] | 1251 | // clean memory |
---|
| 1252 | free(aiIdx2DepthValue); |
---|
| 1253 | } |
---|
[443] | 1254 | #endif |
---|
[608] | 1255 | #if LGE_INTER_SDC_E0156 |
---|
| 1256 | READ_FLAG( uiCode, "depth_inter_SDC_flag" ); pcVPS->setInterSDCFlag( i, uiCode ? true : false ); |
---|
[443] | 1257 | #endif |
---|
[608] | 1258 | } |
---|
| 1259 | } |
---|
| 1260 | } |
---|
| 1261 | READ_FLAG( uiCode, "iv_mv_scaling_flag"); pcVPS->setIvMvScalingFlag( uiCode == 1 ? true : false ); |
---|
[2] | 1262 | } |
---|
[608] | 1263 | #endif |
---|
| 1264 | pcVPS->checkVPSExtensionSyntax(); |
---|
| 1265 | |
---|
| 1266 | pcVPS->setRefLayers(); |
---|
| 1267 | |
---|
| 1268 | #else |
---|
| 1269 | while ( xMoreRbspData() ) |
---|
[2] | 1270 | { |
---|
[608] | 1271 | READ_FLAG( uiCode, "vps_extension_data_flag"); |
---|
[2] | 1272 | } |
---|
[608] | 1273 | #endif |
---|
[2] | 1274 | } |
---|
[608] | 1275 | |
---|
| 1276 | #if H_3D |
---|
| 1277 | pcVPS->initViewIndex(); |
---|
[210] | 1278 | #endif |
---|
[608] | 1279 | return; |
---|
[2] | 1280 | } |
---|
[622] | 1281 | #else |
---|
| 1282 | #if H_MV |
---|
| 1283 | m_pcBitstream->readOutTrailingBits(); |
---|
| 1284 | parseVPSExtension( pcVPS ); |
---|
| 1285 | READ_FLAG( uiCode, "vps_extension2_flag" ); |
---|
| 1286 | if (uiCode) |
---|
| 1287 | { |
---|
| 1288 | #if H_3D |
---|
| 1289 | m_pcBitstream->readOutTrailingBits(); |
---|
| 1290 | parseVPSExtension2( pcVPS ); |
---|
| 1291 | READ_FLAG( uiCode, "vps_extension3_flag" ); |
---|
| 1292 | if (uiCode) |
---|
| 1293 | { |
---|
| 1294 | #endif |
---|
| 1295 | #endif |
---|
| 1296 | while ( xMoreRbspData() ) |
---|
| 1297 | { |
---|
| 1298 | READ_FLAG( uiCode, "vps_extension_data_flag"); |
---|
| 1299 | } |
---|
| 1300 | #if H_MV |
---|
| 1301 | #if H_3D |
---|
| 1302 | } |
---|
| 1303 | #endif |
---|
| 1304 | } |
---|
| 1305 | #endif |
---|
| 1306 | } |
---|
| 1307 | } |
---|
| 1308 | #endif |
---|
[2] | 1309 | |
---|
[622] | 1310 | #if H_MV5 |
---|
| 1311 | #if H_MV |
---|
| 1312 | Void TDecCavlc::parseVPSExtension( TComVPS* pcVPS ) |
---|
| 1313 | { |
---|
| 1314 | UInt uiCode; |
---|
| 1315 | READ_FLAG( uiCode, "avc_base_layer_flag" ); pcVPS->setAvcBaseLayerFlag( uiCode == 1 ? true : false ); |
---|
| 1316 | READ_CODE( 16, uiCode, "vps_vui_offset" ); pcVPS->setVpsVuiOffset( uiCode ); |
---|
| 1317 | READ_FLAG( uiCode, "splitting_flag" ); pcVPS->setSplittingFlag( uiCode == 1 ? true : false ); |
---|
| 1318 | |
---|
| 1319 | for( Int sIdx = 0; sIdx < MAX_NUM_SCALABILITY_TYPES; sIdx++ ) |
---|
| 1320 | { |
---|
| 1321 | READ_FLAG( uiCode, "scalability_mask_flag[i]" ); pcVPS->setScalabilityMaskFlag( sIdx, uiCode == 1 ? true : false ); |
---|
| 1322 | } |
---|
| 1323 | |
---|
| 1324 | for( Int sIdx = 0; sIdx < pcVPS->getNumScalabilityTypes( ) - ( pcVPS->getSplittingFlag() ? 1 : 0 ); sIdx++ ) |
---|
| 1325 | { |
---|
| 1326 | READ_CODE( 3, uiCode, "dimension_id_len_minus1[j]" ); pcVPS->setDimensionIdLen( sIdx, uiCode + 1 ); |
---|
| 1327 | } |
---|
| 1328 | |
---|
| 1329 | if ( pcVPS->getSplittingFlag() ) |
---|
| 1330 | { |
---|
| 1331 | pcVPS->setDimensionIdLen( pcVPS->getNumScalabilityTypes( ) - 1, pcVPS->inferLastDimsionIdLenMinus1() ); |
---|
| 1332 | } |
---|
| 1333 | |
---|
| 1334 | READ_FLAG( uiCode, "vps_nuh_layer_id_present_flag" ); pcVPS->setVpsNuhLayerIdPresentFlag( uiCode == 1 ? true : false ); |
---|
| 1335 | |
---|
| 1336 | for( Int i = 1; i <= pcVPS->getMaxLayersMinus1(); i++ ) |
---|
| 1337 | { |
---|
| 1338 | if ( pcVPS->getVpsNuhLayerIdPresentFlag() ) |
---|
| 1339 | { |
---|
| 1340 | READ_CODE( 6, uiCode, "layer_id_in_nuh[i]" ); pcVPS->setLayerIdInNuh( i, uiCode ); |
---|
| 1341 | } |
---|
| 1342 | else |
---|
| 1343 | { |
---|
| 1344 | pcVPS->setLayerIdInNuh( i, i );; |
---|
| 1345 | } |
---|
| 1346 | |
---|
| 1347 | pcVPS->setLayerIdInVps( pcVPS->getLayerIdInNuh( i ), i ); |
---|
| 1348 | |
---|
| 1349 | for( Int j = 0; j < pcVPS->getNumScalabilityTypes() ; j++ ) |
---|
| 1350 | { |
---|
| 1351 | if ( !pcVPS->getSplittingFlag() ) |
---|
| 1352 | { |
---|
| 1353 | READ_CODE( pcVPS->getDimensionIdLen( j ), uiCode, "dimension_id[i][j]" ); pcVPS->setDimensionId( i, j, uiCode ); |
---|
| 1354 | } |
---|
| 1355 | else |
---|
| 1356 | { |
---|
| 1357 | pcVPS->setDimensionId( i, j, pcVPS->inferDimensionId( i, j) ); |
---|
| 1358 | } |
---|
| 1359 | } |
---|
| 1360 | } |
---|
| 1361 | |
---|
| 1362 | // GT spec says: trac #39 |
---|
| 1363 | // if ( pcVPS->getNumViews() > 1 ) |
---|
| 1364 | // However, this is a bug in the text since, view_id_len_minus1 is needed to parse view_id_val. |
---|
| 1365 | { |
---|
| 1366 | READ_CODE( 4, uiCode, "view_id_len_minus1" ); pcVPS->setViewIdLenMinus1( uiCode ); |
---|
| 1367 | } |
---|
| 1368 | |
---|
| 1369 | for( Int i = 0; i < pcVPS->getNumViews(); i++ ) |
---|
| 1370 | { |
---|
| 1371 | READ_CODE( pcVPS->getViewIdLenMinus1( ) + 1, uiCode, "view_id_val[i]" ); pcVPS->setViewIdVal( i, uiCode ); |
---|
| 1372 | } |
---|
| 1373 | |
---|
| 1374 | for( Int i = 1; i <= pcVPS->getMaxLayersMinus1(); i++ ) |
---|
| 1375 | { |
---|
| 1376 | for( Int j = 0; j < i; j++ ) |
---|
| 1377 | { |
---|
| 1378 | READ_FLAG( uiCode, "direct_dependency_flag[i][j]" ); pcVPS->setDirectDependencyFlag( i, j, uiCode ); |
---|
| 1379 | } |
---|
| 1380 | } |
---|
| 1381 | |
---|
| 1382 | READ_FLAG( uiCode, "max_tid_ref_present_flag" ); pcVPS->setMaxTidRefPresentFlag( uiCode == 1 ); |
---|
| 1383 | |
---|
| 1384 | if ( pcVPS->getMaxTidRefPresentFlag() ) |
---|
| 1385 | { |
---|
| 1386 | for( Int i = 0; i < pcVPS->getMaxLayersMinus1(); i++ ) |
---|
| 1387 | { |
---|
| 1388 | READ_CODE( 3, uiCode, "max_tid_il_ref_pics_plus1[i]" ); pcVPS->setMaxTidIlRefPicPlus1( i , uiCode ); |
---|
| 1389 | } |
---|
| 1390 | } |
---|
| 1391 | |
---|
| 1392 | READ_FLAG( uiCode, "all_ref_layers_active_flag" ); pcVPS->setAllRefLayersActiveFlag( uiCode == 1 ); |
---|
| 1393 | READ_CODE( 10, uiCode, "vps_number_layer_sets_minus1" ); pcVPS->setVpsNumberLayerSetsMinus1 ( uiCode ); |
---|
| 1394 | READ_CODE( 6, uiCode, "vps_num_profile_tier_level_minus1" ); pcVPS->setVpsNumProfileTierLevelMinus1( uiCode ); |
---|
| 1395 | |
---|
| 1396 | for( Int i = 1; i <= pcVPS->getVpsNumProfileTierLevelMinus1(); i++ ) |
---|
| 1397 | { |
---|
| 1398 | READ_FLAG( uiCode, "vps_profile_present_flag[i]" ); pcVPS->setVpsProfilePresentFlag( i, uiCode == 1 ); |
---|
| 1399 | if( !pcVPS->getVpsProfilePresentFlag( i ) ) |
---|
| 1400 | { |
---|
| 1401 | READ_CODE( 6, uiCode, "profile_ref_minus1[i]" ); pcVPS->setProfileRefMinus1( i, uiCode ); |
---|
| 1402 | } |
---|
| 1403 | parsePTL ( pcVPS->getPTL( i ), pcVPS->getVpsProfilePresentFlag( i ), pcVPS->getMaxTLayers()-1); |
---|
| 1404 | if( !pcVPS->getVpsProfilePresentFlag( i ) ) |
---|
| 1405 | { |
---|
| 1406 | TComPTL temp = *pcVPS->getPTL( i ); |
---|
| 1407 | *pcVPS->getPTL( i ) = *pcVPS->getPTL( pcVPS->getProfileRefMinus1( i ) + 1 ); |
---|
| 1408 | pcVPS->getPTL( i )->copyLevelFrom( &temp ); |
---|
| 1409 | } |
---|
| 1410 | } |
---|
| 1411 | |
---|
| 1412 | Int numOutputLayerSets = pcVPS->getVpsNumberLayerSetsMinus1( ) + 1; |
---|
| 1413 | |
---|
| 1414 | READ_FLAG( uiCode, "more_output_layer_sets_than_default_flag" ); pcVPS->setMoreOutputLayerSetsThanDefaultFlag( uiCode == 1 ); |
---|
| 1415 | |
---|
| 1416 | if ( pcVPS->getMoreOutputLayerSetsThanDefaultFlag( ) ) |
---|
| 1417 | { |
---|
| 1418 | READ_CODE( 10, uiCode, "num_add_output_layer_sets_minus1" ); pcVPS->setNumAddOutputLayerSetsMinus1( uiCode ); |
---|
| 1419 | numOutputLayerSets += ( pcVPS->getNumAddOutputLayerSetsMinus1( ) + 1); |
---|
| 1420 | } |
---|
| 1421 | |
---|
| 1422 | if( numOutputLayerSets > 1) |
---|
| 1423 | { |
---|
| 1424 | READ_FLAG( uiCode, "default_one_target_output_layer_flag" ); pcVPS->setDefaultOneTargetOutputLayerFlag( uiCode == 1); |
---|
| 1425 | } |
---|
| 1426 | |
---|
| 1427 | for( Int i = 1; i < numOutputLayerSets; i++ ) |
---|
| 1428 | { |
---|
| 1429 | if( i > pcVPS->getVpsNumberLayerSetsMinus1( ) ) |
---|
| 1430 | { |
---|
| 1431 | READ_UVLC( uiCode, "output_layer_set_idx_minus1[i]" ); pcVPS->setOutputLayerSetIdxMinus1( i, uiCode ); |
---|
| 1432 | for( Int j = 0; j < pcVPS->getNumLayersInIdList( j ) - 1; j++ ) |
---|
| 1433 | { |
---|
| 1434 | READ_FLAG( uiCode, "output_layer_flag" ); pcVPS->setOutputLayerFlag( i, j, uiCode == 1 ); |
---|
| 1435 | } |
---|
| 1436 | } |
---|
| 1437 | if ( pcVPS->getProfileLevelTierIdxLen() > 0 ) |
---|
| 1438 | { |
---|
| 1439 | READ_CODE( pcVPS->getProfileLevelTierIdxLen(), uiCode,"profile_level_tier_idx[ i ]" ); pcVPS->setProfileLevelTierIdx( i , uiCode ); |
---|
| 1440 | } |
---|
| 1441 | } |
---|
| 1442 | |
---|
| 1443 | READ_FLAG( uiCode, "rep_format_idx_present_flag" ); pcVPS->setRepFormatIdxPresentFlag( uiCode == 1 ); |
---|
| 1444 | if ( pcVPS->getRepFormatIdxPresentFlag() ) |
---|
| 1445 | { |
---|
| 1446 | READ_CODE( 4, uiCode, "vps_num_rep_formats_minus1" ); pcVPS->setVpsNumRepFormatsMinus1( uiCode ); |
---|
| 1447 | } |
---|
| 1448 | |
---|
| 1449 | for (Int i = 0; i <= pcVPS->getVpsNumRepFormatsMinus1(); i++ ) |
---|
| 1450 | { |
---|
| 1451 | assert( pcVPS->getRepFormat(i) == NULL ); |
---|
| 1452 | TComRepFormat* repFormat = new TComRepFormat(); |
---|
| 1453 | parseRepFormat( repFormat ); |
---|
| 1454 | pcVPS->setRepFormat(i, repFormat ); |
---|
| 1455 | } |
---|
| 1456 | |
---|
| 1457 | if( pcVPS->getRepFormatIdxPresentFlag() ) |
---|
| 1458 | { |
---|
| 1459 | for( Int i = 1; i <= pcVPS->getMaxLayersMinus1(); i++ ) |
---|
| 1460 | { |
---|
| 1461 | if( pcVPS->getVpsNumRepFormatsMinus1() > 0 ) |
---|
| 1462 | { |
---|
| 1463 | READ_CODE( 4, uiCode, "vps_rep_format_idx" ); pcVPS->setVpsRepFormatIdx( i, uiCode ); |
---|
| 1464 | } |
---|
| 1465 | } |
---|
| 1466 | } |
---|
| 1467 | |
---|
| 1468 | READ_FLAG( uiCode, "max_one_active_ref_layer_flag" ); pcVPS->setMaxOneActiveRefLayerFlag ( uiCode == 1 ); |
---|
| 1469 | READ_FLAG( uiCode, "cross_layer_irap_aligned_flag" ); pcVPS->setCrossLayerIrapAlignedFlag( uiCode == 1 ); |
---|
| 1470 | READ_UVLC( uiCode, "direct_dep_type_len_minus2") ; pcVPS->setDirectDepTypeLenMinus2 ( uiCode ); |
---|
| 1471 | |
---|
| 1472 | for( Int i = 1; i <= pcVPS->getMaxLayersMinus1(); i++ ) |
---|
| 1473 | { |
---|
| 1474 | for( Int j = 0; j < i; j++ ) |
---|
| 1475 | { |
---|
| 1476 | if (pcVPS->getDirectDependencyFlag( i, j) ) |
---|
| 1477 | { |
---|
| 1478 | READ_CODE( pcVPS->getDirectDepTypeLenMinus2( ) + 2, uiCode, "direct_dependency_type[i][j]" ); pcVPS->setDirectDependencyType( i, j , uiCode); |
---|
| 1479 | } |
---|
| 1480 | } |
---|
| 1481 | } |
---|
| 1482 | |
---|
| 1483 | READ_FLAG( uiCode, "vps_shvc_reserved_zero_flag" ); |
---|
| 1484 | READ_FLAG( uiCode, "vps_vui_present_flag" ) ; pcVPS->setVpsVuiPresentFlag( uiCode == 1 ); |
---|
| 1485 | |
---|
| 1486 | if( pcVPS->getVpsVuiPresentFlag() ) |
---|
| 1487 | { |
---|
| 1488 | m_pcBitstream->readOutTrailingBits(); // vps_vui_alignment_bit_equal_to_one |
---|
| 1489 | parseVPSVUI( pcVPS ); |
---|
| 1490 | } |
---|
| 1491 | |
---|
| 1492 | pcVPS->checkVPSExtensionSyntax(); |
---|
| 1493 | pcVPS->setRefLayers(); |
---|
| 1494 | } |
---|
| 1495 | |
---|
| 1496 | Void TDecCavlc::parseRepFormat( TComRepFormat* pcRepFormat ) |
---|
| 1497 | { |
---|
| 1498 | assert( pcRepFormat ); |
---|
| 1499 | |
---|
| 1500 | UInt uiCode; |
---|
| 1501 | READ_CODE( 2, uiCode, "chroma_format_vps_idc" ); pcRepFormat->setChromaFormatVpsIdc ( uiCode ); |
---|
| 1502 | if ( pcRepFormat->getChromaFormatVpsIdc() == 3 ) |
---|
| 1503 | { |
---|
| 1504 | READ_FLAG( uiCode, "separate_colour_plane_vps_flag" ); pcRepFormat->setSeparateColourPlaneVpsFlag( uiCode == 1 ); |
---|
| 1505 | } |
---|
| 1506 | READ_CODE( 16, uiCode, "pic_width_vps_in_luma_samples" ); pcRepFormat->setPicWidthVpsInLumaSamples ( uiCode ); |
---|
| 1507 | READ_CODE( 16, uiCode, "pic_height_vps_in_luma_samples" ); pcRepFormat->setPicHeightVpsInLumaSamples( uiCode ); |
---|
| 1508 | READ_CODE( 4, uiCode, "bit_depth_vps_luma_minus8" ); pcRepFormat->setBitDepthVpsLumaMinus8 ( uiCode ); |
---|
| 1509 | READ_CODE( 4, uiCode, "bit_depth_vps_chroma_minus8" ); pcRepFormat->setBitDepthVpsChromaMinus8 ( uiCode ); |
---|
| 1510 | } |
---|
| 1511 | |
---|
| 1512 | |
---|
| 1513 | Void TDecCavlc::parseVPSVUI( TComVPS* pcVPS ) |
---|
| 1514 | { |
---|
| 1515 | assert( pcVPS ); |
---|
| 1516 | |
---|
| 1517 | TComVPSVUI* pcVPSVUI = pcVPS->getVPSVUI( ); |
---|
| 1518 | |
---|
| 1519 | assert( pcVPSVUI ); |
---|
| 1520 | |
---|
| 1521 | UInt uiCode; |
---|
| 1522 | READ_FLAG( uiCode, "bit_rate_present_vps_flag" ); pcVPSVUI->setBitRatePresentVpsFlag( uiCode == 1 ); |
---|
| 1523 | READ_FLAG( uiCode, "pic_rate_present_vps_flag" ); pcVPSVUI->setPicRatePresentVpsFlag( uiCode == 1 ); |
---|
| 1524 | if( pcVPSVUI->getBitRatePresentVpsFlag( ) || pcVPSVUI->getPicRatePresentVpsFlag( ) ) |
---|
| 1525 | { |
---|
| 1526 | for( Int i = 0; i <= pcVPS->getVpsNumberLayerSetsMinus1(); i++ ) |
---|
| 1527 | { |
---|
| 1528 | for( Int j = 0; j <= pcVPS->getMaxTLayers(); j++ ) |
---|
| 1529 | { |
---|
| 1530 | if( pcVPSVUI->getBitRatePresentVpsFlag( ) ) |
---|
| 1531 | { |
---|
| 1532 | READ_FLAG( uiCode, "bit_rate_present_flag" ); pcVPSVUI->setBitRatePresentFlag( i, j, uiCode == 1 ); |
---|
| 1533 | } |
---|
| 1534 | if( pcVPSVUI->getPicRatePresentVpsFlag( ) ) |
---|
| 1535 | { |
---|
| 1536 | READ_FLAG( uiCode, "pic_rate_present_flag" ); pcVPSVUI->setPicRatePresentFlag( i, j, uiCode == 1 ); |
---|
| 1537 | } |
---|
| 1538 | if( pcVPSVUI->getBitRatePresentFlag( i, j ) ) |
---|
| 1539 | { |
---|
| 1540 | READ_CODE( 16, uiCode, "avg_bit_rate" ); pcVPSVUI->setAvgBitRate( i, j, uiCode ); |
---|
| 1541 | READ_CODE( 16, uiCode, "max_bit_rate" ); pcVPSVUI->setMaxBitRate( i, j, uiCode ); |
---|
| 1542 | } |
---|
| 1543 | if( pcVPSVUI->getPicRatePresentFlag( i, j ) ) |
---|
| 1544 | { |
---|
| 1545 | READ_CODE( 2, uiCode, "constant_pic_rate_idc" ); pcVPSVUI->setConstantPicRateIdc( i, j, uiCode ); |
---|
| 1546 | READ_CODE( 16, uiCode, "avg_pic_rate" ); pcVPSVUI->setAvgPicRate( i, j, uiCode ); |
---|
| 1547 | } |
---|
| 1548 | } |
---|
| 1549 | } |
---|
| 1550 | } |
---|
| 1551 | |
---|
| 1552 | for( Int i = 1; i <= pcVPS->getMaxLayersMinus1(); i++ ) |
---|
| 1553 | { |
---|
| 1554 | for( Int j = 0; j < pcVPS->getNumDirectRefLayers( pcVPS->getLayerIdInNuh( i ) ); j++ ) |
---|
| 1555 | { |
---|
| 1556 | READ_FLAG( uiCode, "tile_boundaries_aligned_flag" ); pcVPSVUI->setTileBoundariesAlignedFlag( i, j, uiCode == 1 ); |
---|
| 1557 | } |
---|
| 1558 | } |
---|
| 1559 | |
---|
| 1560 | READ_FLAG( uiCode, "ilp_restricted_ref_layers_flag" ); pcVPSVUI->setIlpRestrictedRefLayersFlag( uiCode == 1 ); |
---|
| 1561 | |
---|
| 1562 | if( pcVPSVUI->getIlpRestrictedRefLayersFlag( ) ) |
---|
| 1563 | { |
---|
| 1564 | for( Int i = 1; i <= pcVPS->getMaxLayersMinus1(); i++ ) |
---|
| 1565 | { |
---|
| 1566 | for( Int j = 0; j < pcVPS->getNumDirectRefLayers( pcVPS->getLayerIdInNuh( i ) ); j++ ) |
---|
| 1567 | { |
---|
| 1568 | READ_UVLC( uiCode, "min_spatial_segment_offset_plus1" ); pcVPSVUI->setMinSpatialSegmentOffsetPlus1( i, j, uiCode ); |
---|
| 1569 | if( pcVPSVUI->getMinSpatialSegmentOffsetPlus1( i, j ) > 0 ) |
---|
| 1570 | { |
---|
| 1571 | READ_FLAG( uiCode, "ctu_based_offset_enabled_flag" ); pcVPSVUI->setCtuBasedOffsetEnabledFlag( i, j, uiCode == 1 ); |
---|
| 1572 | if( pcVPSVUI->getCtuBasedOffsetEnabledFlag( i, j ) ) |
---|
| 1573 | { |
---|
| 1574 | READ_UVLC( uiCode, "min_horizontal_ctu_offset_plus1" ); pcVPSVUI->setMinHorizontalCtuOffsetPlus1( i, j, uiCode ); |
---|
| 1575 | } |
---|
| 1576 | } |
---|
| 1577 | } |
---|
| 1578 | } |
---|
| 1579 | } |
---|
| 1580 | } |
---|
| 1581 | #endif |
---|
| 1582 | |
---|
| 1583 | #if H_3D |
---|
| 1584 | Void TDecCavlc::parseVPSExtension2( TComVPS* pcVPS ) |
---|
| 1585 | { |
---|
| 1586 | UInt uiCode; |
---|
| 1587 | for( Int i = 0; i <= pcVPS->getMaxLayersMinus1(); i++ ) |
---|
| 1588 | { |
---|
| 1589 | #if H_3D_ARP |
---|
| 1590 | pcVPS->setUseAdvRP ( i, 0 ); |
---|
| 1591 | pcVPS->setARPStepNum( i, 1 ); |
---|
| 1592 | #endif |
---|
| 1593 | if ( i != 0 ) |
---|
| 1594 | { |
---|
| 1595 | if( !( pcVPS->getDepthId( i ) == 1 ) ) |
---|
| 1596 | { |
---|
| 1597 | #if H_3D_IV_MERGE |
---|
| 1598 | READ_FLAG( uiCode, "iv_mv_pred_flag[i]"); pcVPS->setIvMvPredFlag ( i, uiCode == 1 ? true : false ); |
---|
| 1599 | #endif |
---|
| 1600 | #if H_3D_ARP |
---|
| 1601 | READ_FLAG( uiCode, "iv_res_pred_flag[i]" ); pcVPS->setUseAdvRP ( i, uiCode ); pcVPS->setARPStepNum( i, uiCode ? H_3D_ARP_WFNR : 1 ); |
---|
| 1602 | |
---|
| 1603 | #endif |
---|
| 1604 | #if H_3D_NBDV_REF |
---|
| 1605 | READ_FLAG( uiCode, "depth_refinement_flag[i]"); pcVPS->setDepthRefinementFlag ( i, uiCode == 1 ? true : false ); |
---|
| 1606 | #endif |
---|
| 1607 | #if H_3D_VSP |
---|
| 1608 | READ_FLAG( uiCode, "view_synthesis_pred_flag[i]"); pcVPS->setViewSynthesisPredFlag( i, uiCode == 1 ? true : false ); |
---|
| 1609 | #endif |
---|
| 1610 | } |
---|
| 1611 | else |
---|
| 1612 | { |
---|
| 1613 | |
---|
| 1614 | READ_FLAG( uiCode, "vps_depth_modes_flag[i]" ); pcVPS->setVpsDepthModesFlag( i, uiCode == 1 ? true : false ); |
---|
| 1615 | // READ_FLAG( uiCode, "lim_qt_pred_flag[i]"); pcVPS->setLimQtPreFlag ( i, uiCode == 1 ? true : false ); |
---|
| 1616 | #if H_3D_DIM_DLT |
---|
| 1617 | if( pcVPS->getVpsDepthModesFlag( i ) ) |
---|
| 1618 | { |
---|
| 1619 | READ_FLAG( uiCode, "dlt_flag[i]" ); pcVPS->setUseDLTFlag( i, uiCode == 1 ? true : false ); |
---|
| 1620 | } |
---|
| 1621 | if( pcVPS->getUseDLTFlag( i ) ) |
---|
| 1622 | { |
---|
| 1623 | // decode mapping |
---|
| 1624 | UInt uiNumDepthValues; |
---|
| 1625 | // parse number of values in DLT |
---|
| 1626 | READ_UVLC(uiNumDepthValues, "num_depth_values_in_dlt[i]"); |
---|
| 1627 | |
---|
| 1628 | // parse actual DLT values |
---|
| 1629 | Int* aiIdx2DepthValue = (Int*) calloc(uiNumDepthValues, sizeof(Int)); |
---|
| 1630 | for(Int d=0; d<uiNumDepthValues; d++) |
---|
| 1631 | { |
---|
| 1632 | READ_UVLC(uiCode, "dlt_depth_value[i][d]"); |
---|
| 1633 | aiIdx2DepthValue[d] = (Int)uiCode; |
---|
| 1634 | } |
---|
| 1635 | |
---|
| 1636 | pcVPS->setDepthLUTs(i, aiIdx2DepthValue, uiNumDepthValues); |
---|
| 1637 | |
---|
| 1638 | // clean memory |
---|
| 1639 | free(aiIdx2DepthValue); |
---|
| 1640 | } |
---|
| 1641 | #endif |
---|
| 1642 | #if LGE_INTER_SDC_E0156 |
---|
| 1643 | READ_FLAG( uiCode, "depth_inter_SDC_flag" ); pcVPS->setInterSDCFlag( i, uiCode ? true : false ); |
---|
| 1644 | #endif |
---|
| 1645 | } |
---|
| 1646 | } |
---|
| 1647 | } |
---|
| 1648 | READ_FLAG( uiCode, "iv_mv_scaling_flag"); pcVPS->setIvMvScalingFlag( uiCode == 1 ? true : false ); |
---|
| 1649 | } |
---|
| 1650 | #endif |
---|
| 1651 | #endif |
---|
| 1652 | |
---|
[608] | 1653 | Void TDecCavlc::parseSliceHeader (TComSlice*& rpcSlice, ParameterSetManagerDecoder *parameterSetManager) |
---|
[2] | 1654 | { |
---|
[56] | 1655 | UInt uiCode; |
---|
| 1656 | Int iCode; |
---|
[608] | 1657 | |
---|
[56] | 1658 | #if ENC_DEC_TRACE |
---|
| 1659 | xTraceSliceHeader(rpcSlice); |
---|
| 1660 | #endif |
---|
[608] | 1661 | TComPPS* pps = NULL; |
---|
| 1662 | TComSPS* sps = NULL; |
---|
| 1663 | #if H_MV |
---|
| 1664 | TComVPS* vps = NULL; |
---|
| 1665 | #endif |
---|
| 1666 | |
---|
| 1667 | UInt firstSliceSegmentInPic; |
---|
| 1668 | READ_FLAG( firstSliceSegmentInPic, "first_slice_segment_in_pic_flag" ); |
---|
| 1669 | if( rpcSlice->getRapPicFlag()) |
---|
| 1670 | { |
---|
| 1671 | READ_FLAG( uiCode, "no_output_of_prior_pics_flag" ); //ignored |
---|
| 1672 | } |
---|
| 1673 | READ_UVLC ( uiCode, "slice_pic_parameter_set_id" ); rpcSlice->setPPSId(uiCode); |
---|
| 1674 | pps = parameterSetManager->getPrefetchedPPS(uiCode); |
---|
| 1675 | //!KS: need to add error handling code here, if PPS is not available |
---|
| 1676 | assert(pps!=0); |
---|
| 1677 | sps = parameterSetManager->getPrefetchedSPS(pps->getSPSId()); |
---|
| 1678 | //!KS: need to add error handling code here, if SPS is not available |
---|
| 1679 | assert(sps!=0); |
---|
| 1680 | #if H_MV |
---|
| 1681 | vps = parameterSetManager->getPrefetchedVPS(sps->getVPSId()); |
---|
[622] | 1682 | #if H_MV5 |
---|
| 1683 | assert( vps != NULL ); |
---|
| 1684 | |
---|
| 1685 | sps->inferRepFormat ( vps , rpcSlice->getLayerId() ); |
---|
| 1686 | sps->inferScalingList( parameterSetManager->getActiveSPS( sps->getSpsScalingListRefLayerId() ) ); |
---|
| 1687 | |
---|
| 1688 | rpcSlice->setVPS(vps); |
---|
| 1689 | rpcSlice->setViewId ( vps->getViewId ( rpcSlice->getLayerId() ) ); |
---|
| 1690 | rpcSlice->setViewIndex( vps->getViewIndex( rpcSlice->getLayerId() ) ); |
---|
| 1691 | #if H_3D |
---|
| 1692 | rpcSlice->setIsDepth ( vps->getDepthId ( rpcSlice->getLayerId() ) == 1 ); |
---|
| 1693 | #endif |
---|
| 1694 | #else |
---|
[608] | 1695 | assert(vps!=0); |
---|
| 1696 | rpcSlice->setVPS(vps); |
---|
| 1697 | rpcSlice->setViewId ( vps->getViewId ( rpcSlice->getLayerIdInVps() ) ); |
---|
| 1698 | #if H_3D |
---|
| 1699 | rpcSlice->setViewIndex( vps->getViewIndex( rpcSlice->getLayerIdInVps() ) ); |
---|
| 1700 | rpcSlice->setIsDepth ( vps->getDepthId ( rpcSlice->getLayerIdInVps() ) == 1 ); |
---|
| 1701 | #endif |
---|
| 1702 | #endif |
---|
[622] | 1703 | #endif |
---|
[608] | 1704 | rpcSlice->setSPS(sps); |
---|
| 1705 | rpcSlice->setPPS(pps); |
---|
| 1706 | if( pps->getDependentSliceSegmentsEnabledFlag() && ( !firstSliceSegmentInPic )) |
---|
[2] | 1707 | { |
---|
[608] | 1708 | READ_FLAG( uiCode, "dependent_slice_segment_flag" ); rpcSlice->setDependentSliceSegmentFlag(uiCode ? true : false); |
---|
[2] | 1709 | } |
---|
[608] | 1710 | else |
---|
[2] | 1711 | { |
---|
[608] | 1712 | rpcSlice->setDependentSliceSegmentFlag(false); |
---|
[2] | 1713 | } |
---|
[608] | 1714 | Int numCTUs = ((sps->getPicWidthInLumaSamples()+sps->getMaxCUWidth()-1)/sps->getMaxCUWidth())*((sps->getPicHeightInLumaSamples()+sps->getMaxCUHeight()-1)/sps->getMaxCUHeight()); |
---|
| 1715 | Int maxParts = (1<<(sps->getMaxCUDepth()<<1)); |
---|
| 1716 | UInt sliceSegmentAddress = 0; |
---|
| 1717 | Int bitsSliceSegmentAddress = 0; |
---|
| 1718 | while(numCTUs>(1<<bitsSliceSegmentAddress)) |
---|
[189] | 1719 | { |
---|
[608] | 1720 | bitsSliceSegmentAddress++; |
---|
[189] | 1721 | } |
---|
| 1722 | |
---|
[608] | 1723 | if(!firstSliceSegmentInPic) |
---|
[2] | 1724 | { |
---|
[608] | 1725 | READ_CODE( bitsSliceSegmentAddress, sliceSegmentAddress, "slice_segment_address" ); |
---|
[2] | 1726 | } |
---|
[608] | 1727 | //set uiCode to equal slice start address (or dependent slice start address) |
---|
| 1728 | Int startCuAddress = maxParts*sliceSegmentAddress; |
---|
| 1729 | rpcSlice->setSliceSegmentCurStartCUAddr( startCuAddress ); |
---|
| 1730 | rpcSlice->setSliceSegmentCurEndCUAddr(numCTUs*maxParts); |
---|
[2] | 1731 | |
---|
[608] | 1732 | if (rpcSlice->getDependentSliceSegmentFlag()) |
---|
[2] | 1733 | { |
---|
[608] | 1734 | rpcSlice->setNextSlice ( false ); |
---|
| 1735 | rpcSlice->setNextSliceSegment ( true ); |
---|
[2] | 1736 | } |
---|
| 1737 | else |
---|
| 1738 | { |
---|
[608] | 1739 | rpcSlice->setNextSlice ( true ); |
---|
| 1740 | rpcSlice->setNextSliceSegment ( false ); |
---|
| 1741 | |
---|
| 1742 | rpcSlice->setSliceCurStartCUAddr(startCuAddress); |
---|
| 1743 | rpcSlice->setSliceCurEndCUAddr(numCTUs*maxParts); |
---|
[2] | 1744 | } |
---|
[608] | 1745 | |
---|
| 1746 | if(!rpcSlice->getDependentSliceSegmentFlag()) |
---|
| 1747 | { |
---|
| 1748 | #if H_MV |
---|
[622] | 1749 | #if H_MV5 |
---|
| 1750 | Int esb = 0; //Don't use i, otherwise will shadow something below |
---|
| 1751 | if ( rpcSlice->getPPS()->getNumExtraSliceHeaderBits() > esb ) |
---|
| 1752 | { |
---|
| 1753 | esb++; |
---|
| 1754 | READ_FLAG( uiCode, "poc_reset_flag" ); rpcSlice->setPocResetFlag( uiCode == 1 ); |
---|
| 1755 | } |
---|
| 1756 | |
---|
| 1757 | if ( rpcSlice->getPPS()->getNumExtraSliceHeaderBits() > esb ) |
---|
| 1758 | { |
---|
| 1759 | esb++; |
---|
| 1760 | READ_FLAG( uiCode, "discardable_flag" ); rpcSlice->setDiscardableFlag( uiCode == 1 ); |
---|
| 1761 | } |
---|
| 1762 | |
---|
| 1763 | for (; esb < rpcSlice->getPPS()->getNumExtraSliceHeaderBits(); esb++) |
---|
| 1764 | #else |
---|
[608] | 1765 | if ( rpcSlice->getPPS()->getNumExtraSliceHeaderBits() > 0 ) |
---|
| 1766 | { |
---|
| 1767 | READ_FLAG( uiCode, "discardable_flag" ); rpcSlice->setDiscardableFlag( uiCode == 1 ); |
---|
| 1768 | } |
---|
[2] | 1769 | |
---|
[608] | 1770 | for (Int i = 1; i < rpcSlice->getPPS()->getNumExtraSliceHeaderBits(); i++) |
---|
[622] | 1771 | #endif |
---|
[608] | 1772 | #else |
---|
| 1773 | for (Int i = 0; i < rpcSlice->getPPS()->getNumExtraSliceHeaderBits(); i++) |
---|
| 1774 | #endif |
---|
| 1775 | { |
---|
| 1776 | READ_FLAG(uiCode, "slice_reserved_undetermined_flag[]"); // ignored |
---|
| 1777 | } |
---|
| 1778 | |
---|
| 1779 | READ_UVLC ( uiCode, "slice_type" ); rpcSlice->setSliceType((SliceType)uiCode); |
---|
[56] | 1780 | if( pps->getOutputFlagPresentFlag() ) |
---|
[2] | 1781 | { |
---|
[608] | 1782 | READ_FLAG( uiCode, "pic_output_flag" ); rpcSlice->setPicOutputFlag( uiCode ? true : false ); |
---|
[2] | 1783 | } |
---|
[56] | 1784 | else |
---|
| 1785 | { |
---|
| 1786 | rpcSlice->setPicOutputFlag( true ); |
---|
| 1787 | } |
---|
[608] | 1788 | // in the first version chroma_format_idc is equal to one, thus colour_plane_id will not be present |
---|
| 1789 | assert (sps->getChromaFormatIdc() == 1 ); |
---|
| 1790 | // if( separate_colour_plane_flag == 1 ) |
---|
| 1791 | // colour_plane_id u(2) |
---|
| 1792 | |
---|
| 1793 | if( rpcSlice->getIdrPicFlag() ) |
---|
| 1794 | { |
---|
[56] | 1795 | rpcSlice->setPOC(0); |
---|
| 1796 | TComReferencePictureSet* rps = rpcSlice->getLocalRPS(); |
---|
| 1797 | rps->setNumberOfNegativePictures(0); |
---|
| 1798 | rps->setNumberOfPositivePictures(0); |
---|
| 1799 | rps->setNumberOfLongtermPictures(0); |
---|
| 1800 | rps->setNumberOfPictures(0); |
---|
| 1801 | rpcSlice->setRPS(rps); |
---|
[608] | 1802 | #if H_MV |
---|
| 1803 | rpcSlice->setEnableTMVPFlag(false); |
---|
| 1804 | #endif |
---|
[56] | 1805 | } |
---|
| 1806 | else |
---|
[2] | 1807 | { |
---|
[56] | 1808 | READ_CODE(sps->getBitsForPOC(), uiCode, "pic_order_cnt_lsb"); |
---|
| 1809 | Int iPOClsb = uiCode; |
---|
| 1810 | Int iPrevPOC = rpcSlice->getPrevPOC(); |
---|
| 1811 | Int iMaxPOClsb = 1<< sps->getBitsForPOC(); |
---|
| 1812 | Int iPrevPOClsb = iPrevPOC%iMaxPOClsb; |
---|
| 1813 | Int iPrevPOCmsb = iPrevPOC-iPrevPOClsb; |
---|
| 1814 | Int iPOCmsb; |
---|
| 1815 | if( ( iPOClsb < iPrevPOClsb ) && ( ( iPrevPOClsb - iPOClsb ) >= ( iMaxPOClsb / 2 ) ) ) |
---|
[2] | 1816 | { |
---|
[56] | 1817 | iPOCmsb = iPrevPOCmsb + iMaxPOClsb; |
---|
[2] | 1818 | } |
---|
[56] | 1819 | else if( (iPOClsb > iPrevPOClsb ) && ( (iPOClsb - iPrevPOClsb ) > ( iMaxPOClsb / 2 ) ) ) |
---|
| 1820 | { |
---|
| 1821 | iPOCmsb = iPrevPOCmsb - iMaxPOClsb; |
---|
| 1822 | } |
---|
| 1823 | else |
---|
| 1824 | { |
---|
| 1825 | iPOCmsb = iPrevPOCmsb; |
---|
| 1826 | } |
---|
[608] | 1827 | if ( rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP |
---|
| 1828 | || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL |
---|
| 1829 | || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP ) |
---|
[56] | 1830 | { |
---|
[608] | 1831 | // For BLA picture types, POCmsb is set to 0. |
---|
| 1832 | iPOCmsb = 0; |
---|
[56] | 1833 | } |
---|
[608] | 1834 | rpcSlice->setPOC (iPOCmsb+iPOClsb); |
---|
[622] | 1835 | #if H_MV5 |
---|
| 1836 | #if H_MV |
---|
| 1837 | if ( rpcSlice->getPocResetFlag() ) |
---|
| 1838 | { |
---|
| 1839 | rpcSlice->setPocBeforeReset ( rpcSlice->getPOC() ); |
---|
| 1840 | rpcSlice->setPOC ( 0 ); |
---|
[608] | 1841 | |
---|
[622] | 1842 | } |
---|
| 1843 | #endif |
---|
| 1844 | #endif |
---|
[608] | 1845 | TComReferencePictureSet* rps; |
---|
| 1846 | rps = rpcSlice->getLocalRPS(); |
---|
| 1847 | rpcSlice->setRPS(rps); |
---|
| 1848 | READ_FLAG( uiCode, "short_term_ref_pic_set_sps_flag" ); |
---|
| 1849 | if(uiCode == 0) // use short-term reference picture set explicitly signalled in slice header |
---|
[56] | 1850 | { |
---|
[608] | 1851 | parseShortTermRefPicSet(sps,rps, sps->getRPSList()->getNumberOfReferencePictureSets()); |
---|
| 1852 | } |
---|
| 1853 | else // use reference to short-term reference picture set in PPS |
---|
| 1854 | { |
---|
| 1855 | Int numBits = 0; |
---|
| 1856 | while ((1 << numBits) < rpcSlice->getSPS()->getRPSList()->getNumberOfReferencePictureSets()) |
---|
[56] | 1857 | { |
---|
[608] | 1858 | numBits++; |
---|
[56] | 1859 | } |
---|
[608] | 1860 | if (numBits > 0) |
---|
[56] | 1861 | { |
---|
[608] | 1862 | READ_CODE( numBits, uiCode, "short_term_ref_pic_set_idx"); |
---|
[56] | 1863 | } |
---|
[608] | 1864 | else |
---|
[56] | 1865 | { |
---|
[608] | 1866 | uiCode = 0; |
---|
| 1867 | } |
---|
| 1868 | *rps = *(sps->getRPSList()->getReferencePictureSet(uiCode)); |
---|
| 1869 | } |
---|
| 1870 | if(sps->getLongTermRefsPresent()) |
---|
| 1871 | { |
---|
| 1872 | Int offset = rps->getNumberOfNegativePictures()+rps->getNumberOfPositivePictures(); |
---|
| 1873 | UInt numOfLtrp = 0; |
---|
| 1874 | UInt numLtrpInSPS = 0; |
---|
| 1875 | if (rpcSlice->getSPS()->getNumLongTermRefPicSPS() > 0) |
---|
| 1876 | { |
---|
| 1877 | READ_UVLC( uiCode, "num_long_term_sps"); |
---|
| 1878 | numLtrpInSPS = uiCode; |
---|
| 1879 | numOfLtrp += numLtrpInSPS; |
---|
| 1880 | rps->setNumberOfLongtermPictures(numOfLtrp); |
---|
| 1881 | } |
---|
| 1882 | Int bitsForLtrpInSPS = 0; |
---|
| 1883 | while (rpcSlice->getSPS()->getNumLongTermRefPicSPS() > (1 << bitsForLtrpInSPS)) |
---|
| 1884 | { |
---|
| 1885 | bitsForLtrpInSPS++; |
---|
| 1886 | } |
---|
| 1887 | READ_UVLC( uiCode, "num_long_term_pics"); rps->setNumberOfLongtermPictures(uiCode); |
---|
| 1888 | numOfLtrp += uiCode; |
---|
| 1889 | rps->setNumberOfLongtermPictures(numOfLtrp); |
---|
| 1890 | Int maxPicOrderCntLSB = 1 << rpcSlice->getSPS()->getBitsForPOC(); |
---|
| 1891 | Int prevDeltaMSB = 0, deltaPocMSBCycleLT = 0;; |
---|
| 1892 | for(Int j=offset+rps->getNumberOfLongtermPictures()-1, k = 0; k < numOfLtrp; j--, k++) |
---|
| 1893 | { |
---|
| 1894 | Int pocLsbLt; |
---|
| 1895 | if (k < numLtrpInSPS) |
---|
[56] | 1896 | { |
---|
[608] | 1897 | uiCode = 0; |
---|
| 1898 | if (bitsForLtrpInSPS > 0) |
---|
| 1899 | { |
---|
| 1900 | READ_CODE(bitsForLtrpInSPS, uiCode, "lt_idx_sps[i]"); |
---|
| 1901 | } |
---|
| 1902 | Int usedByCurrFromSPS=rpcSlice->getSPS()->getUsedByCurrPicLtSPSFlag(uiCode); |
---|
[2] | 1903 | |
---|
[608] | 1904 | pocLsbLt = rpcSlice->getSPS()->getLtRefPicPocLsbSps(uiCode); |
---|
| 1905 | rps->setUsed(j,usedByCurrFromSPS); |
---|
| 1906 | } |
---|
| 1907 | else |
---|
| 1908 | { |
---|
| 1909 | READ_CODE(rpcSlice->getSPS()->getBitsForPOC(), uiCode, "poc_lsb_lt"); pocLsbLt= uiCode; |
---|
| 1910 | READ_FLAG( uiCode, "used_by_curr_pic_lt_flag"); rps->setUsed(j,uiCode); |
---|
| 1911 | } |
---|
| 1912 | READ_FLAG(uiCode,"delta_poc_msb_present_flag"); |
---|
| 1913 | Bool mSBPresentFlag = uiCode ? true : false; |
---|
| 1914 | if(mSBPresentFlag) |
---|
| 1915 | { |
---|
| 1916 | READ_UVLC( uiCode, "delta_poc_msb_cycle_lt[i]" ); |
---|
| 1917 | Bool deltaFlag = false; |
---|
| 1918 | // First LTRP || First LTRP from SH |
---|
| 1919 | if( (j == offset+rps->getNumberOfLongtermPictures()-1) || (j == offset+(numOfLtrp-numLtrpInSPS)-1) ) |
---|
[56] | 1920 | { |
---|
[608] | 1921 | deltaFlag = true; |
---|
[56] | 1922 | } |
---|
[608] | 1923 | if(deltaFlag) |
---|
| 1924 | { |
---|
| 1925 | deltaPocMSBCycleLT = uiCode; |
---|
| 1926 | } |
---|
[56] | 1927 | else |
---|
| 1928 | { |
---|
[608] | 1929 | deltaPocMSBCycleLT = uiCode + prevDeltaMSB; |
---|
[56] | 1930 | } |
---|
[608] | 1931 | |
---|
| 1932 | Int pocLTCurr = rpcSlice->getPOC() - deltaPocMSBCycleLT * maxPicOrderCntLSB |
---|
| 1933 | - iPOClsb + pocLsbLt; |
---|
| 1934 | rps->setPOC (j, pocLTCurr); |
---|
| 1935 | rps->setDeltaPOC(j, - rpcSlice->getPOC() + pocLTCurr); |
---|
| 1936 | rps->setCheckLTMSBPresent(j,true); |
---|
[56] | 1937 | } |
---|
[608] | 1938 | else |
---|
| 1939 | { |
---|
| 1940 | rps->setPOC (j, pocLsbLt); |
---|
| 1941 | rps->setDeltaPOC(j, - rpcSlice->getPOC() + pocLsbLt); |
---|
| 1942 | rps->setCheckLTMSBPresent(j,false); |
---|
| 1943 | } |
---|
| 1944 | prevDeltaMSB = deltaPocMSBCycleLT; |
---|
| 1945 | } |
---|
| 1946 | offset += rps->getNumberOfLongtermPictures(); |
---|
| 1947 | rps->setNumberOfPictures(offset); |
---|
| 1948 | } |
---|
| 1949 | if ( rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP |
---|
| 1950 | || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL |
---|
| 1951 | || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP ) |
---|
| 1952 | { |
---|
| 1953 | // In the case of BLA picture types, rps data is read from slice header but ignored |
---|
| 1954 | rps = rpcSlice->getLocalRPS(); |
---|
| 1955 | rps->setNumberOfNegativePictures(0); |
---|
| 1956 | rps->setNumberOfPositivePictures(0); |
---|
| 1957 | rps->setNumberOfLongtermPictures(0); |
---|
| 1958 | rps->setNumberOfPictures(0); |
---|
| 1959 | rpcSlice->setRPS(rps); |
---|
[56] | 1960 | } |
---|
[608] | 1961 | if (rpcSlice->getSPS()->getTMVPFlagsPresent()) |
---|
[2] | 1962 | { |
---|
[608] | 1963 | READ_FLAG( uiCode, "slice_temporal_mvp_enable_flag" ); |
---|
| 1964 | rpcSlice->setEnableTMVPFlag( uiCode == 1 ? true : false ); |
---|
[56] | 1965 | } |
---|
[608] | 1966 | else |
---|
[56] | 1967 | { |
---|
[608] | 1968 | rpcSlice->setEnableTMVPFlag(false); |
---|
| 1969 | } |
---|
| 1970 | } |
---|
| 1971 | #if H_MV |
---|
[622] | 1972 | #if H_MV5 |
---|
| 1973 | Int layerId = rpcSlice->getLayerId(); |
---|
| 1974 | if( rpcSlice->getLayerId() > 0 && !vps->getAllRefLayersActiveFlag() && vps->getNumDirectRefLayers( layerId ) > 0 ) { |
---|
| 1975 | READ_FLAG( uiCode, "inter_layer_pred_enabled_flag" ); rpcSlice->setInterLayerPredEnabledFlag( uiCode == 1 ); |
---|
| 1976 | if( rpcSlice->getInterLayerPredEnabledFlag() && vps->getNumDirectRefLayers( layerId ) > 1 ) |
---|
| 1977 | { |
---|
| 1978 | if( !vps->getMaxOneActiveRefLayerFlag()) |
---|
| 1979 | { |
---|
| 1980 | READ_CODE( rpcSlice->getNumInterLayerRefPicsMinus1Len( ), uiCode, "num_inter_layer_ref_pics_minus1" ); rpcSlice->setNumInterLayerRefPicsMinus1( uiCode ); |
---|
| 1981 | } |
---|
| 1982 | if ( rpcSlice->getNumActiveRefLayerPics() != vps->getNumDirectRefLayers( layerId ) ) |
---|
| 1983 | { |
---|
| 1984 | for( Int idx = 0; idx < rpcSlice->getNumActiveRefLayerPics(); idx++ ) |
---|
| 1985 | { |
---|
| 1986 | READ_CODE( rpcSlice->getInterLayerPredLayerIdcLen( ), uiCode, "inter_layer_pred_layer_idc" ); rpcSlice->setInterLayerPredLayerIdc( idx, uiCode ); |
---|
| 1987 | } |
---|
| 1988 | } |
---|
| 1989 | } |
---|
| 1990 | } |
---|
| 1991 | #else |
---|
[608] | 1992 | Int layerIdInVps = rpcSlice->getLayerIdInVps(); |
---|
| 1993 | if( rpcSlice->getLayerId() > 0 && vps->getNumDirectRefLayers( layerIdInVps ) > 0 ) |
---|
| 1994 | { |
---|
| 1995 | READ_FLAG( uiCode, "inter_layer_pred_enabled_flag" ); rpcSlice->setInterLayerPredEnabledFlag( uiCode == 1 ); |
---|
| 1996 | if( rpcSlice->getInterLayerPredEnabledFlag() && vps->getNumDirectRefLayers( layerIdInVps ) > 1 ) |
---|
| 1997 | { |
---|
| 1998 | if( !vps->getMaxOneActiveRefLayerFlag()) |
---|
[2] | 1999 | { |
---|
[608] | 2000 | READ_CODE( rpcSlice->getNumInterLayerRefPicsMinus1Len( ), uiCode, "num_inter_layer_ref_pics_minus1" ); rpcSlice->setNumInterLayerRefPicsMinus1( uiCode ); |
---|
[2] | 2001 | } |
---|
[608] | 2002 | for( Int i = 0; i < rpcSlice->getNumActiveRefLayerPics(); i++ ) |
---|
[2] | 2003 | { |
---|
[608] | 2004 | READ_CODE( rpcSlice->getInterLayerPredLayerIdcLen( ), uiCode, "inter_layer_pred_layer_idc" ); rpcSlice->setInterLayerPredLayerIdc( i, uiCode ); |
---|
[2] | 2005 | } |
---|
[608] | 2006 | } |
---|
| 2007 | } |
---|
| 2008 | |
---|
| 2009 | rpcSlice->setActiveMotionPredRefLayers( ); |
---|
| 2010 | |
---|
| 2011 | if( vps->getNumSamplePredRefLayers( layerIdInVps ) > 0 && rpcSlice->getNumActiveRefLayerPics() > 0 ) |
---|
| 2012 | { |
---|
| 2013 | READ_FLAG( uiCode, "inter_layer_sample_pred_only_flag" ); rpcSlice->setInterLayerSamplePredOnlyFlag( uiCode == 1 ); |
---|
| 2014 | } |
---|
[443] | 2015 | #endif |
---|
[622] | 2016 | #endif |
---|
[608] | 2017 | if(sps->getUseSAO()) |
---|
| 2018 | { |
---|
| 2019 | READ_FLAG(uiCode, "slice_sao_luma_flag"); rpcSlice->setSaoEnabledFlag((Bool)uiCode); |
---|
| 2020 | READ_FLAG(uiCode, "slice_sao_chroma_flag"); rpcSlice->setSaoEnabledFlagChroma((Bool)uiCode); |
---|
[56] | 2021 | } |
---|
[608] | 2022 | |
---|
| 2023 | if (rpcSlice->getIdrPicFlag()) |
---|
| 2024 | { |
---|
| 2025 | rpcSlice->setEnableTMVPFlag(false); |
---|
| 2026 | } |
---|
[56] | 2027 | if (!rpcSlice->isIntra()) |
---|
| 2028 | { |
---|
[608] | 2029 | |
---|
[56] | 2030 | READ_FLAG( uiCode, "num_ref_idx_active_override_flag"); |
---|
| 2031 | if (uiCode) |
---|
[2] | 2032 | { |
---|
[608] | 2033 | READ_UVLC (uiCode, "num_ref_idx_l0_active_minus1" ); rpcSlice->setNumRefIdx( REF_PIC_LIST_0, uiCode + 1 ); |
---|
[56] | 2034 | if (rpcSlice->isInterB()) |
---|
[2] | 2035 | { |
---|
[608] | 2036 | READ_UVLC (uiCode, "num_ref_idx_l1_active_minus1" ); rpcSlice->setNumRefIdx( REF_PIC_LIST_1, uiCode + 1 ); |
---|
[2] | 2037 | } |
---|
| 2038 | else |
---|
| 2039 | { |
---|
[56] | 2040 | rpcSlice->setNumRefIdx(REF_PIC_LIST_1, 0); |
---|
[2] | 2041 | } |
---|
| 2042 | } |
---|
| 2043 | else |
---|
| 2044 | { |
---|
[608] | 2045 | rpcSlice->setNumRefIdx(REF_PIC_LIST_0, rpcSlice->getPPS()->getNumRefIdxL0DefaultActive()); |
---|
| 2046 | if (rpcSlice->isInterB()) |
---|
| 2047 | { |
---|
| 2048 | rpcSlice->setNumRefIdx(REF_PIC_LIST_1, rpcSlice->getPPS()->getNumRefIdxL1DefaultActive()); |
---|
| 2049 | } |
---|
| 2050 | else |
---|
| 2051 | { |
---|
| 2052 | rpcSlice->setNumRefIdx(REF_PIC_LIST_1,0); |
---|
| 2053 | } |
---|
[2] | 2054 | } |
---|
| 2055 | } |
---|
[608] | 2056 | // } |
---|
[56] | 2057 | TComRefPicListModification* refPicListModification = rpcSlice->getRefPicListModification(); |
---|
[608] | 2058 | if(!rpcSlice->isIntra()) |
---|
[2] | 2059 | { |
---|
[608] | 2060 | if( !rpcSlice->getPPS()->getListsModificationPresentFlag() || rpcSlice->getNumRpsCurrTempList() <= 1 ) |
---|
[2] | 2061 | { |
---|
[56] | 2062 | refPicListModification->setRefPicListModificationFlagL0( 0 ); |
---|
[2] | 2063 | } |
---|
| 2064 | else |
---|
| 2065 | { |
---|
[56] | 2066 | READ_FLAG( uiCode, "ref_pic_list_modification_flag_l0" ); refPicListModification->setRefPicListModificationFlagL0( uiCode ? 1 : 0 ); |
---|
[2] | 2067 | } |
---|
[608] | 2068 | |
---|
[56] | 2069 | if(refPicListModification->getRefPicListModificationFlagL0()) |
---|
[608] | 2070 | { |
---|
[56] | 2071 | uiCode = 0; |
---|
| 2072 | Int i = 0; |
---|
[608] | 2073 | Int numRpsCurrTempList0 = rpcSlice->getNumRpsCurrTempList(); |
---|
| 2074 | if ( numRpsCurrTempList0 > 1 ) |
---|
[56] | 2075 | { |
---|
| 2076 | Int length = 1; |
---|
[608] | 2077 | numRpsCurrTempList0 --; |
---|
| 2078 | while ( numRpsCurrTempList0 >>= 1) |
---|
[56] | 2079 | { |
---|
| 2080 | length ++; |
---|
| 2081 | } |
---|
| 2082 | for (i = 0; i < rpcSlice->getNumRefIdx(REF_PIC_LIST_0); i ++) |
---|
| 2083 | { |
---|
| 2084 | READ_CODE( length, uiCode, "list_entry_l0" ); |
---|
| 2085 | refPicListModification->setRefPicSetIdxL0(i, uiCode ); |
---|
| 2086 | } |
---|
| 2087 | } |
---|
| 2088 | else |
---|
| 2089 | { |
---|
| 2090 | for (i = 0; i < rpcSlice->getNumRefIdx(REF_PIC_LIST_0); i ++) |
---|
| 2091 | { |
---|
| 2092 | refPicListModification->setRefPicSetIdxL0(i, 0 ); |
---|
| 2093 | } |
---|
| 2094 | } |
---|
[2] | 2095 | } |
---|
| 2096 | } |
---|
[56] | 2097 | else |
---|
[2] | 2098 | { |
---|
[56] | 2099 | refPicListModification->setRefPicListModificationFlagL0(0); |
---|
[2] | 2100 | } |
---|
[56] | 2101 | if(rpcSlice->isInterB()) |
---|
[2] | 2102 | { |
---|
[608] | 2103 | if( !rpcSlice->getPPS()->getListsModificationPresentFlag() || rpcSlice->getNumRpsCurrTempList() <= 1 ) |
---|
[2] | 2104 | { |
---|
[56] | 2105 | refPicListModification->setRefPicListModificationFlagL1( 0 ); |
---|
[2] | 2106 | } |
---|
| 2107 | else |
---|
| 2108 | { |
---|
[56] | 2109 | READ_FLAG( uiCode, "ref_pic_list_modification_flag_l1" ); refPicListModification->setRefPicListModificationFlagL1( uiCode ? 1 : 0 ); |
---|
[2] | 2110 | } |
---|
[56] | 2111 | if(refPicListModification->getRefPicListModificationFlagL1()) |
---|
[2] | 2112 | { |
---|
[56] | 2113 | uiCode = 0; |
---|
| 2114 | Int i = 0; |
---|
[608] | 2115 | Int numRpsCurrTempList1 = rpcSlice->getNumRpsCurrTempList(); |
---|
| 2116 | if ( numRpsCurrTempList1 > 1 ) |
---|
[56] | 2117 | { |
---|
| 2118 | Int length = 1; |
---|
[608] | 2119 | numRpsCurrTempList1 --; |
---|
| 2120 | while ( numRpsCurrTempList1 >>= 1) |
---|
[56] | 2121 | { |
---|
| 2122 | length ++; |
---|
| 2123 | } |
---|
| 2124 | for (i = 0; i < rpcSlice->getNumRefIdx(REF_PIC_LIST_1); i ++) |
---|
| 2125 | { |
---|
| 2126 | READ_CODE( length, uiCode, "list_entry_l1" ); |
---|
| 2127 | refPicListModification->setRefPicSetIdxL1(i, uiCode ); |
---|
| 2128 | } |
---|
| 2129 | } |
---|
| 2130 | else |
---|
| 2131 | { |
---|
| 2132 | for (i = 0; i < rpcSlice->getNumRefIdx(REF_PIC_LIST_1); i ++) |
---|
| 2133 | { |
---|
| 2134 | refPicListModification->setRefPicSetIdxL1(i, 0 ); |
---|
| 2135 | } |
---|
| 2136 | } |
---|
[2] | 2137 | } |
---|
[56] | 2138 | } |
---|
| 2139 | else |
---|
[2] | 2140 | { |
---|
[56] | 2141 | refPicListModification->setRefPicListModificationFlagL1(0); |
---|
[2] | 2142 | } |
---|
[608] | 2143 | if (rpcSlice->isInterB()) |
---|
[2] | 2144 | { |
---|
[608] | 2145 | READ_FLAG( uiCode, "mvd_l1_zero_flag" ); rpcSlice->setMvdL1ZeroFlag( (uiCode ? true : false) ); |
---|
| 2146 | } |
---|
| 2147 | |
---|
| 2148 | rpcSlice->setCabacInitFlag( false ); // default |
---|
| 2149 | if(pps->getCabacInitPresentFlag() && !rpcSlice->isIntra()) |
---|
| 2150 | { |
---|
| 2151 | READ_FLAG(uiCode, "cabac_init_flag"); |
---|
| 2152 | rpcSlice->setCabacInitFlag( uiCode ? true : false ); |
---|
| 2153 | } |
---|
| 2154 | |
---|
| 2155 | if ( rpcSlice->getEnableTMVPFlag() ) |
---|
| 2156 | { |
---|
[622] | 2157 | #if !H_MV5 |
---|
[608] | 2158 | #if H_MV |
---|
| 2159 | if( rpcSlice->getLayerId() > 0 && rpcSlice->getNumActiveMotionPredRefLayers() > 0 ) |
---|
| 2160 | { |
---|
| 2161 | READ_FLAG( uiCode, "alt_collocated_indication_flag" ); rpcSlice->setAltCollocatedIndicationFlag( uiCode == 1 ); |
---|
| 2162 | } |
---|
| 2163 | |
---|
| 2164 | if( rpcSlice->getAltCollocatedIndicationFlag() && rpcSlice->getNumActiveMotionPredRefLayers() > 1 ) |
---|
| 2165 | { |
---|
| 2166 | READ_UVLC( uiCode, "collocated_ref_layer_idx" ); rpcSlice->setCollocatedRefLayerIdx( uiCode ); |
---|
| 2167 | } |
---|
| 2168 | else |
---|
| 2169 | { |
---|
[210] | 2170 | #endif |
---|
[622] | 2171 | #endif |
---|
[608] | 2172 | if ( rpcSlice->getSliceType() == B_SLICE ) |
---|
[56] | 2173 | { |
---|
[608] | 2174 | READ_FLAG( uiCode, "collocated_from_l0_flag" ); |
---|
| 2175 | rpcSlice->setColFromL0Flag(uiCode); |
---|
[2] | 2176 | } |
---|
| 2177 | else |
---|
| 2178 | { |
---|
[608] | 2179 | rpcSlice->setColFromL0Flag( 1 ); |
---|
[2] | 2180 | } |
---|
[608] | 2181 | |
---|
| 2182 | if ( rpcSlice->getSliceType() != I_SLICE && |
---|
| 2183 | ((rpcSlice->getColFromL0Flag() == 1 && rpcSlice->getNumRefIdx(REF_PIC_LIST_0) > 1)|| |
---|
| 2184 | (rpcSlice->getColFromL0Flag() == 0 && rpcSlice->getNumRefIdx(REF_PIC_LIST_1) > 1))) |
---|
| 2185 | { |
---|
| 2186 | READ_UVLC( uiCode, "collocated_ref_idx" ); |
---|
| 2187 | rpcSlice->setColRefIdx(uiCode); |
---|
| 2188 | } |
---|
| 2189 | else |
---|
| 2190 | { |
---|
| 2191 | rpcSlice->setColRefIdx(0); |
---|
| 2192 | } |
---|
[622] | 2193 | #if !H_MV5 |
---|
[608] | 2194 | #if H_MV |
---|
| 2195 | } |
---|
| 2196 | #endif |
---|
[622] | 2197 | #endif |
---|
[2] | 2198 | } |
---|
[608] | 2199 | if ( (pps->getUseWP() && rpcSlice->getSliceType()==P_SLICE) || (pps->getWPBiPred() && rpcSlice->getSliceType()==B_SLICE) ) |
---|
[2] | 2200 | { |
---|
[608] | 2201 | xParsePredWeightTable(rpcSlice); |
---|
| 2202 | rpcSlice->initWpScaling(); |
---|
[2] | 2203 | } |
---|
[608] | 2204 | #if H_3D_IC |
---|
| 2205 | else if( rpcSlice->getViewIndex() && ( rpcSlice->getSliceType() == P_SLICE || rpcSlice->getSliceType() == B_SLICE ) ) |
---|
| 2206 | { |
---|
| 2207 | UInt uiCodeTmp = 0; |
---|
[2] | 2208 | |
---|
[608] | 2209 | READ_FLAG ( uiCodeTmp, "slice_ic_enable_flag" ); |
---|
| 2210 | rpcSlice->setApplyIC( uiCodeTmp ); |
---|
| 2211 | |
---|
| 2212 | if ( uiCodeTmp ) |
---|
| 2213 | { |
---|
| 2214 | READ_FLAG ( uiCodeTmp, "ic_skip_mergeidx0" ); |
---|
| 2215 | rpcSlice->setIcSkipParseFlag( uiCodeTmp ); |
---|
| 2216 | } |
---|
| 2217 | } |
---|
| 2218 | #endif |
---|
| 2219 | if (!rpcSlice->isIntra()) |
---|
| 2220 | { |
---|
| 2221 | READ_UVLC( uiCode, "five_minus_max_num_merge_cand"); |
---|
| 2222 | #if H_3D_IV_MERGE |
---|
| 2223 | Bool ivMvPredFlag = rpcSlice->getVPS()->getIvMvPredFlag( rpcSlice->getLayerIdInVps() ) ; |
---|
| 2224 | rpcSlice->setMaxNumMergeCand(( ivMvPredFlag ? MRG_MAX_NUM_CANDS_MEM : MRG_MAX_NUM_CANDS) - uiCode); |
---|
[56] | 2225 | #else |
---|
[608] | 2226 | rpcSlice->setMaxNumMergeCand(MRG_MAX_NUM_CANDS - uiCode); |
---|
[56] | 2227 | #endif |
---|
[608] | 2228 | } |
---|
[2] | 2229 | |
---|
[608] | 2230 | READ_SVLC( iCode, "slice_qp_delta" ); |
---|
[56] | 2231 | rpcSlice->setSliceQp (26 + pps->getPicInitQPMinus26() + iCode); |
---|
[2] | 2232 | |
---|
[56] | 2233 | assert( rpcSlice->getSliceQp() >= -sps->getQpBDOffsetY() ); |
---|
| 2234 | assert( rpcSlice->getSliceQp() <= 51 ); |
---|
[2] | 2235 | |
---|
[608] | 2236 | if (rpcSlice->getPPS()->getSliceChromaQpFlag()) |
---|
[2] | 2237 | { |
---|
[608] | 2238 | READ_SVLC( iCode, "slice_qp_delta_cb" ); |
---|
| 2239 | rpcSlice->setSliceQpDeltaCb( iCode ); |
---|
| 2240 | assert( rpcSlice->getSliceQpDeltaCb() >= -12 ); |
---|
| 2241 | assert( rpcSlice->getSliceQpDeltaCb() <= 12 ); |
---|
| 2242 | assert( (rpcSlice->getPPS()->getChromaCbQpOffset() + rpcSlice->getSliceQpDeltaCb()) >= -12 ); |
---|
| 2243 | assert( (rpcSlice->getPPS()->getChromaCbQpOffset() + rpcSlice->getSliceQpDeltaCb()) <= 12 ); |
---|
| 2244 | |
---|
| 2245 | READ_SVLC( iCode, "slice_qp_delta_cr" ); |
---|
| 2246 | rpcSlice->setSliceQpDeltaCr( iCode ); |
---|
| 2247 | assert( rpcSlice->getSliceQpDeltaCr() >= -12 ); |
---|
| 2248 | assert( rpcSlice->getSliceQpDeltaCr() <= 12 ); |
---|
| 2249 | assert( (rpcSlice->getPPS()->getChromaCrQpOffset() + rpcSlice->getSliceQpDeltaCr()) >= -12 ); |
---|
| 2250 | assert( (rpcSlice->getPPS()->getChromaCrQpOffset() + rpcSlice->getSliceQpDeltaCr()) <= 12 ); |
---|
| 2251 | } |
---|
| 2252 | |
---|
| 2253 | if (rpcSlice->getPPS()->getDeblockingFilterControlPresentFlag()) |
---|
| 2254 | { |
---|
| 2255 | if(rpcSlice->getPPS()->getDeblockingFilterOverrideEnabledFlag()) |
---|
[2] | 2256 | { |
---|
[608] | 2257 | READ_FLAG ( uiCode, "deblocking_filter_override_flag" ); rpcSlice->setDeblockingFilterOverrideFlag(uiCode ? true : false); |
---|
[2] | 2258 | } |
---|
[608] | 2259 | else |
---|
| 2260 | { |
---|
| 2261 | rpcSlice->setDeblockingFilterOverrideFlag(0); |
---|
| 2262 | } |
---|
| 2263 | if(rpcSlice->getDeblockingFilterOverrideFlag()) |
---|
[2] | 2264 | { |
---|
[608] | 2265 | READ_FLAG ( uiCode, "slice_disable_deblocking_filter_flag" ); rpcSlice->setDeblockingFilterDisable(uiCode ? 1 : 0); |
---|
| 2266 | if(!rpcSlice->getDeblockingFilterDisable()) |
---|
[56] | 2267 | { |
---|
[608] | 2268 | READ_SVLC( iCode, "slice_beta_offset_div2" ); rpcSlice->setDeblockingFilterBetaOffsetDiv2(iCode); |
---|
| 2269 | assert(rpcSlice->getDeblockingFilterBetaOffsetDiv2() >= -6 && |
---|
| 2270 | rpcSlice->getDeblockingFilterBetaOffsetDiv2() <= 6); |
---|
| 2271 | READ_SVLC( iCode, "slice_tc_offset_div2" ); rpcSlice->setDeblockingFilterTcOffsetDiv2(iCode); |
---|
| 2272 | assert(rpcSlice->getDeblockingFilterTcOffsetDiv2() >= -6 && |
---|
| 2273 | rpcSlice->getDeblockingFilterTcOffsetDiv2() <= 6); |
---|
[56] | 2274 | } |
---|
[2] | 2275 | } |
---|
[608] | 2276 | else |
---|
| 2277 | { |
---|
| 2278 | rpcSlice->setDeblockingFilterDisable ( rpcSlice->getPPS()->getPicDisableDeblockingFilterFlag() ); |
---|
| 2279 | rpcSlice->setDeblockingFilterBetaOffsetDiv2( rpcSlice->getPPS()->getDeblockingFilterBetaOffsetDiv2() ); |
---|
| 2280 | rpcSlice->setDeblockingFilterTcOffsetDiv2 ( rpcSlice->getPPS()->getDeblockingFilterTcOffsetDiv2() ); |
---|
| 2281 | } |
---|
| 2282 | } |
---|
| 2283 | else |
---|
| 2284 | { |
---|
| 2285 | rpcSlice->setDeblockingFilterDisable ( false ); |
---|
| 2286 | rpcSlice->setDeblockingFilterBetaOffsetDiv2( 0 ); |
---|
| 2287 | rpcSlice->setDeblockingFilterTcOffsetDiv2 ( 0 ); |
---|
| 2288 | } |
---|
| 2289 | |
---|
| 2290 | Bool isSAOEnabled = (!rpcSlice->getSPS()->getUseSAO())?(false):(rpcSlice->getSaoEnabledFlag()||rpcSlice->getSaoEnabledFlagChroma()); |
---|
| 2291 | Bool isDBFEnabled = (!rpcSlice->getDeblockingFilterDisable()); |
---|
| 2292 | |
---|
| 2293 | if(rpcSlice->getPPS()->getLoopFilterAcrossSlicesEnabledFlag() && ( isSAOEnabled || isDBFEnabled )) |
---|
[56] | 2294 | { |
---|
[608] | 2295 | READ_FLAG( uiCode, "slice_loop_filter_across_slices_enabled_flag"); |
---|
[2] | 2296 | } |
---|
[608] | 2297 | else |
---|
| 2298 | { |
---|
| 2299 | uiCode = rpcSlice->getPPS()->getLoopFilterAcrossSlicesEnabledFlag()?1:0; |
---|
| 2300 | } |
---|
| 2301 | rpcSlice->setLFCrossSliceBoundaryFlag( (uiCode==1)?true:false); |
---|
[56] | 2302 | |
---|
[608] | 2303 | } |
---|
| 2304 | |
---|
| 2305 | UInt *entryPointOffset = NULL; |
---|
| 2306 | UInt numEntryPointOffsets, offsetLenMinus1; |
---|
| 2307 | if( pps->getTilesEnabledFlag() || pps->getEntropyCodingSyncEnabledFlag() ) |
---|
| 2308 | { |
---|
| 2309 | READ_UVLC(numEntryPointOffsets, "num_entry_point_offsets"); rpcSlice->setNumEntryPointOffsets ( numEntryPointOffsets ); |
---|
| 2310 | if (numEntryPointOffsets>0) |
---|
[2] | 2311 | { |
---|
[608] | 2312 | READ_UVLC(offsetLenMinus1, "offset_len_minus1"); |
---|
[2] | 2313 | } |
---|
[608] | 2314 | entryPointOffset = new UInt[numEntryPointOffsets]; |
---|
| 2315 | for (UInt idx=0; idx<numEntryPointOffsets; idx++) |
---|
[2] | 2316 | { |
---|
[608] | 2317 | READ_CODE(offsetLenMinus1+1, uiCode, "entry_point_offset_minus1"); |
---|
| 2318 | entryPointOffset[ idx ] = uiCode + 1; |
---|
[2] | 2319 | } |
---|
| 2320 | } |
---|
[608] | 2321 | else |
---|
[2] | 2322 | { |
---|
[608] | 2323 | rpcSlice->setNumEntryPointOffsets ( 0 ); |
---|
| 2324 | } |
---|
| 2325 | |
---|
| 2326 | if(pps->getSliceHeaderExtensionPresentFlag()) |
---|
| 2327 | { |
---|
| 2328 | READ_UVLC(uiCode,"slice_header_extension_length"); |
---|
| 2329 | #if H_3D |
---|
[56] | 2330 | if( rpcSlice->getSPS()->hasCamParInSliceHeader() ) |
---|
[2] | 2331 | { |
---|
[608] | 2332 | UInt uiViewIndex = rpcSlice->getViewIndex(); |
---|
| 2333 | for( UInt uiBaseIndex = 0; uiBaseIndex < uiViewIndex; uiBaseIndex++ ) |
---|
[2] | 2334 | { |
---|
[608] | 2335 | READ_SVLC( iCode, "cp_scale" ); m_aaiTempScale [ uiBaseIndex ][ uiViewIndex ] = iCode; |
---|
| 2336 | READ_SVLC( iCode, "cp_off" ); m_aaiTempOffset[ uiBaseIndex ][ uiViewIndex ] = iCode; |
---|
| 2337 | READ_SVLC( iCode, "cp_inv_scale_plus_scale" ); m_aaiTempScale [ uiViewIndex ][ uiBaseIndex ] = iCode - m_aaiTempScale [ uiBaseIndex ][ uiViewIndex ]; |
---|
| 2338 | READ_SVLC( iCode, "cp_inv_off_plus_off" ); m_aaiTempOffset[ uiViewIndex ][ uiBaseIndex ] = iCode - m_aaiTempOffset[ uiBaseIndex ][ uiViewIndex ]; |
---|
[2] | 2339 | } |
---|
[608] | 2340 | rpcSlice->setCamparaSlice( m_aaiTempScale, m_aaiTempOffset ); |
---|
[2] | 2341 | } |
---|
[608] | 2342 | |
---|
| 2343 | READ_FLAG(uiCode,"slice_segment_header_extension2_flag"); |
---|
| 2344 | if ( uiCode ) |
---|
| 2345 | { |
---|
| 2346 | READ_UVLC(uiCode,"slice_header_extension2_length"); |
---|
| 2347 | for(Int i=0; i<uiCode; i++) |
---|
| 2348 | { |
---|
| 2349 | UInt ignore; |
---|
| 2350 | READ_CODE(8,ignore,"slice_header_extension2_data_byte"); |
---|
| 2351 | } |
---|
| 2352 | } |
---|
[56] | 2353 | } |
---|
| 2354 | #else |
---|
[608] | 2355 | for(Int i=0; i<uiCode; i++) |
---|
| 2356 | { |
---|
| 2357 | UInt ignore; |
---|
| 2358 | READ_CODE(8,ignore,"slice_header_extension_data_byte"); |
---|
| 2359 | } |
---|
| 2360 | } |
---|
[56] | 2361 | #endif |
---|
[608] | 2362 | m_pcBitstream->readByteAlignment(); |
---|
[56] | 2363 | |
---|
[608] | 2364 | if( pps->getTilesEnabledFlag() || pps->getEntropyCodingSyncEnabledFlag() ) |
---|
[56] | 2365 | { |
---|
[608] | 2366 | Int endOfSliceHeaderLocation = m_pcBitstream->getByteLocation(); |
---|
| 2367 | |
---|
| 2368 | // Adjust endOfSliceHeaderLocation to account for emulation prevention bytes in the slice segment header |
---|
| 2369 | for ( UInt curByteIdx = 0; curByteIdx<m_pcBitstream->numEmulationPreventionBytesRead(); curByteIdx++ ) |
---|
[2] | 2370 | { |
---|
[608] | 2371 | if ( m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) < endOfSliceHeaderLocation ) |
---|
[2] | 2372 | { |
---|
[608] | 2373 | endOfSliceHeaderLocation++; |
---|
[2] | 2374 | } |
---|
[608] | 2375 | } |
---|
[56] | 2376 | |
---|
[608] | 2377 | Int curEntryPointOffset = 0; |
---|
| 2378 | Int prevEntryPointOffset = 0; |
---|
| 2379 | for (UInt idx=0; idx<numEntryPointOffsets; idx++) |
---|
| 2380 | { |
---|
| 2381 | curEntryPointOffset += entryPointOffset[ idx ]; |
---|
| 2382 | |
---|
| 2383 | Int emulationPreventionByteCount = 0; |
---|
| 2384 | for ( UInt curByteIdx = 0; curByteIdx<m_pcBitstream->numEmulationPreventionBytesRead(); curByteIdx++ ) |
---|
[2] | 2385 | { |
---|
[608] | 2386 | if ( m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) >= ( prevEntryPointOffset + endOfSliceHeaderLocation ) && |
---|
| 2387 | m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) < ( curEntryPointOffset + endOfSliceHeaderLocation ) ) |
---|
| 2388 | { |
---|
| 2389 | emulationPreventionByteCount++; |
---|
| 2390 | } |
---|
[2] | 2391 | } |
---|
[56] | 2392 | |
---|
[608] | 2393 | entryPointOffset[ idx ] -= emulationPreventionByteCount; |
---|
| 2394 | prevEntryPointOffset = curEntryPointOffset; |
---|
[2] | 2395 | } |
---|
[56] | 2396 | |
---|
[608] | 2397 | if ( pps->getTilesEnabledFlag() ) |
---|
| 2398 | { |
---|
| 2399 | rpcSlice->setTileLocationCount( numEntryPointOffsets ); |
---|
[56] | 2400 | |
---|
[608] | 2401 | UInt prevPos = 0; |
---|
| 2402 | for (Int idx=0; idx<rpcSlice->getTileLocationCount(); idx++) |
---|
| 2403 | { |
---|
| 2404 | rpcSlice->setTileLocation( idx, prevPos + entryPointOffset [ idx ] ); |
---|
| 2405 | prevPos += entryPointOffset[ idx ]; |
---|
| 2406 | } |
---|
[2] | 2407 | } |
---|
[608] | 2408 | else if ( pps->getEntropyCodingSyncEnabledFlag() ) |
---|
[2] | 2409 | { |
---|
[608] | 2410 | Int numSubstreams = rpcSlice->getNumEntryPointOffsets()+1; |
---|
| 2411 | rpcSlice->allocSubstreamSizes(numSubstreams); |
---|
| 2412 | UInt *pSubstreamSizes = rpcSlice->getSubstreamSizes(); |
---|
| 2413 | for (Int idx=0; idx<numSubstreams-1; idx++) |
---|
[2] | 2414 | { |
---|
[608] | 2415 | if ( idx < numEntryPointOffsets ) |
---|
| 2416 | { |
---|
| 2417 | pSubstreamSizes[ idx ] = ( entryPointOffset[ idx ] << 3 ) ; |
---|
| 2418 | } |
---|
| 2419 | else |
---|
| 2420 | { |
---|
| 2421 | pSubstreamSizes[ idx ] = 0; |
---|
| 2422 | } |
---|
[2] | 2423 | } |
---|
[56] | 2424 | } |
---|
[608] | 2425 | |
---|
| 2426 | if (entryPointOffset) |
---|
| 2427 | { |
---|
| 2428 | delete [] entryPointOffset; |
---|
| 2429 | } |
---|
[56] | 2430 | } |
---|
[2] | 2431 | |
---|
[608] | 2432 | return; |
---|
| 2433 | } |
---|
| 2434 | |
---|
| 2435 | Void TDecCavlc::parsePTL( TComPTL *rpcPTL, Bool profilePresentFlag, Int maxNumSubLayersMinus1 ) |
---|
| 2436 | { |
---|
| 2437 | UInt uiCode; |
---|
| 2438 | if(profilePresentFlag) |
---|
[56] | 2439 | { |
---|
[608] | 2440 | parseProfileTier(rpcPTL->getGeneralPTL()); |
---|
| 2441 | } |
---|
| 2442 | READ_CODE( 8, uiCode, "general_level_idc" ); rpcPTL->getGeneralPTL()->setLevelIdc(uiCode); |
---|
[2] | 2443 | |
---|
[608] | 2444 | for (Int i = 0; i < maxNumSubLayersMinus1; i++) |
---|
| 2445 | { |
---|
| 2446 | #if !H_MV |
---|
| 2447 | if(profilePresentFlag) |
---|
[56] | 2448 | { |
---|
[608] | 2449 | #endif |
---|
| 2450 | READ_FLAG( uiCode, "sub_layer_profile_present_flag[i]" ); rpcPTL->setSubLayerProfilePresentFlag(i, uiCode); |
---|
| 2451 | #if H_MV |
---|
| 2452 | rpcPTL->setSubLayerProfilePresentFlag( i, profilePresentFlag && rpcPTL->getSubLayerProfilePresentFlag(i) ); |
---|
| 2453 | #else |
---|
[56] | 2454 | } |
---|
[608] | 2455 | #endif |
---|
| 2456 | READ_FLAG( uiCode, "sub_layer_level_present_flag[i]" ); rpcPTL->setSubLayerLevelPresentFlag (i, uiCode); |
---|
[56] | 2457 | } |
---|
[608] | 2458 | |
---|
| 2459 | if (maxNumSubLayersMinus1 > 0) |
---|
[56] | 2460 | { |
---|
[608] | 2461 | for (Int i = maxNumSubLayersMinus1; i < 8; i++) |
---|
[56] | 2462 | { |
---|
[608] | 2463 | READ_CODE(2, uiCode, "reserved_zero_2bits"); |
---|
| 2464 | assert(uiCode == 0); |
---|
[2] | 2465 | } |
---|
[56] | 2466 | } |
---|
[608] | 2467 | |
---|
| 2468 | for(Int i = 0; i < maxNumSubLayersMinus1; i++) |
---|
[56] | 2469 | { |
---|
[608] | 2470 | if( profilePresentFlag && rpcPTL->getSubLayerProfilePresentFlag(i) ) |
---|
| 2471 | { |
---|
| 2472 | parseProfileTier(rpcPTL->getSubLayerPTL(i)); |
---|
| 2473 | } |
---|
| 2474 | if(rpcPTL->getSubLayerLevelPresentFlag(i)) |
---|
| 2475 | { |
---|
| 2476 | READ_CODE( 8, uiCode, "sub_layer_level_idc[i]" ); rpcPTL->getSubLayerPTL(i)->setLevelIdc(uiCode); |
---|
| 2477 | } |
---|
[56] | 2478 | } |
---|
[2] | 2479 | } |
---|
| 2480 | |
---|
[608] | 2481 | Void TDecCavlc::parseProfileTier(ProfileTierLevel *ptl) |
---|
[2] | 2482 | { |
---|
[608] | 2483 | UInt uiCode; |
---|
| 2484 | READ_CODE(2 , uiCode, "XXX_profile_space[]"); ptl->setProfileSpace(uiCode); |
---|
| 2485 | READ_FLAG( uiCode, "XXX_tier_flag[]" ); ptl->setTierFlag (uiCode ? 1 : 0); |
---|
| 2486 | READ_CODE(5 , uiCode, "XXX_profile_idc[]" ); ptl->setProfileIdc (uiCode); |
---|
| 2487 | for(Int j = 0; j < 32; j++) |
---|
[2] | 2488 | { |
---|
[608] | 2489 | READ_FLAG( uiCode, "XXX_profile_compatibility_flag[][j]"); ptl->setProfileCompatibilityFlag(j, uiCode ? 1 : 0); |
---|
[2] | 2490 | } |
---|
[608] | 2491 | READ_FLAG(uiCode, "general_progressive_source_flag"); |
---|
| 2492 | ptl->setProgressiveSourceFlag(uiCode ? true : false); |
---|
[2] | 2493 | |
---|
[608] | 2494 | READ_FLAG(uiCode, "general_interlaced_source_flag"); |
---|
| 2495 | ptl->setInterlacedSourceFlag(uiCode ? true : false); |
---|
| 2496 | |
---|
| 2497 | READ_FLAG(uiCode, "general_non_packed_constraint_flag"); |
---|
| 2498 | ptl->setNonPackedConstraintFlag(uiCode ? true : false); |
---|
| 2499 | |
---|
| 2500 | READ_FLAG(uiCode, "general_frame_only_constraint_flag"); |
---|
| 2501 | ptl->setFrameOnlyConstraintFlag(uiCode ? true : false); |
---|
| 2502 | |
---|
| 2503 | READ_CODE(16, uiCode, "XXX_reserved_zero_44bits[0..15]"); |
---|
| 2504 | READ_CODE(16, uiCode, "XXX_reserved_zero_44bits[16..31]"); |
---|
| 2505 | READ_CODE(12, uiCode, "XXX_reserved_zero_44bits[32..43]"); |
---|
[2] | 2506 | } |
---|
[56] | 2507 | |
---|
| 2508 | Void TDecCavlc::parseTerminatingBit( UInt& ruiBit ) |
---|
[2] | 2509 | { |
---|
[56] | 2510 | ruiBit = false; |
---|
| 2511 | Int iBitsLeft = m_pcBitstream->getNumBitsLeft(); |
---|
| 2512 | if(iBitsLeft <= 8) |
---|
[2] | 2513 | { |
---|
[56] | 2514 | UInt uiPeekValue = m_pcBitstream->peekBits(iBitsLeft); |
---|
| 2515 | if (uiPeekValue == (1<<(iBitsLeft-1))) |
---|
| 2516 | { |
---|
| 2517 | ruiBit = true; |
---|
| 2518 | } |
---|
[2] | 2519 | } |
---|
| 2520 | } |
---|
| 2521 | |
---|
[608] | 2522 | Void TDecCavlc::parseSkipFlag( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
[2] | 2523 | { |
---|
[56] | 2524 | assert(0); |
---|
| 2525 | } |
---|
[2] | 2526 | |
---|
[608] | 2527 | Void TDecCavlc::parseCUTransquantBypassFlag( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
[189] | 2528 | { |
---|
| 2529 | assert(0); |
---|
| 2530 | } |
---|
| 2531 | |
---|
[608] | 2532 | Void TDecCavlc::parseMVPIdx( Int& /*riMVPIdx*/ ) |
---|
[56] | 2533 | { |
---|
| 2534 | assert(0); |
---|
| 2535 | } |
---|
[2] | 2536 | |
---|
[608] | 2537 | Void TDecCavlc::parseSplitFlag ( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
[56] | 2538 | { |
---|
| 2539 | assert(0); |
---|
| 2540 | } |
---|
[2] | 2541 | |
---|
[608] | 2542 | Void TDecCavlc::parsePartSize( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
[56] | 2543 | { |
---|
| 2544 | assert(0); |
---|
| 2545 | } |
---|
[2] | 2546 | |
---|
[608] | 2547 | Void TDecCavlc::parsePredMode( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
[56] | 2548 | { |
---|
| 2549 | assert(0); |
---|
| 2550 | } |
---|
[2] | 2551 | |
---|
[56] | 2552 | /** Parse I_PCM information. |
---|
[608] | 2553 | * \param pcCU pointer to CU |
---|
| 2554 | * \param uiAbsPartIdx CU index |
---|
| 2555 | * \param uiDepth CU depth |
---|
| 2556 | * \returns Void |
---|
| 2557 | * |
---|
| 2558 | * If I_PCM flag indicates that the CU is I_PCM, parse its PCM alignment bits and codes. |
---|
| 2559 | */ |
---|
| 2560 | Void TDecCavlc::parseIPCMInfo( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
[56] | 2561 | { |
---|
| 2562 | assert(0); |
---|
[2] | 2563 | } |
---|
| 2564 | |
---|
[608] | 2565 | Void TDecCavlc::parseIntraDirLumaAng ( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
[56] | 2566 | { |
---|
| 2567 | assert(0); |
---|
[2] | 2568 | } |
---|
| 2569 | |
---|
[608] | 2570 | Void TDecCavlc::parseIntraDirChroma( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
[2] | 2571 | { |
---|
[56] | 2572 | assert(0); |
---|
[2] | 2573 | } |
---|
| 2574 | |
---|
[608] | 2575 | Void TDecCavlc::parseInterDir( TComDataCU* /*pcCU*/, UInt& /*ruiInterDir*/, UInt /*uiAbsPartIdx*/ ) |
---|
[2] | 2576 | { |
---|
[56] | 2577 | assert(0); |
---|
[2] | 2578 | } |
---|
| 2579 | |
---|
[608] | 2580 | Void TDecCavlc::parseRefFrmIdx( TComDataCU* /*pcCU*/, Int& /*riRefFrmIdx*/, RefPicList /*eRefList*/ ) |
---|
[2] | 2581 | { |
---|
[56] | 2582 | assert(0); |
---|
[2] | 2583 | } |
---|
| 2584 | |
---|
[608] | 2585 | Void TDecCavlc::parseMvd( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiPartIdx*/, UInt /*uiDepth*/, RefPicList /*eRefList*/ ) |
---|
[2] | 2586 | { |
---|
[56] | 2587 | assert(0); |
---|
[2] | 2588 | } |
---|
| 2589 | |
---|
[56] | 2590 | Void TDecCavlc::parseDeltaQP( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
[2] | 2591 | { |
---|
[56] | 2592 | Int qp; |
---|
| 2593 | Int iDQp; |
---|
[608] | 2594 | |
---|
[56] | 2595 | xReadSvlc( iDQp ); |
---|
[2] | 2596 | |
---|
[56] | 2597 | Int qpBdOffsetY = pcCU->getSlice()->getSPS()->getQpBDOffsetY(); |
---|
| 2598 | qp = (((Int) pcCU->getRefQP( uiAbsPartIdx ) + iDQp + 52 + 2*qpBdOffsetY )%(52+ qpBdOffsetY)) - qpBdOffsetY; |
---|
| 2599 | |
---|
[608] | 2600 | UInt uiAbsQpCUPartIdx = (uiAbsPartIdx>>((g_uiMaxCUDepth - pcCU->getSlice()->getPPS()->getMaxCuDQPDepth())<<1))<<((g_uiMaxCUDepth - pcCU->getSlice()->getPPS()->getMaxCuDQPDepth())<<1) ; |
---|
[56] | 2601 | UInt uiQpCUDepth = min(uiDepth,pcCU->getSlice()->getPPS()->getMaxCuDQPDepth()) ; |
---|
| 2602 | |
---|
| 2603 | pcCU->setQPSubParts( qp, uiAbsQpCUPartIdx, uiQpCUDepth ); |
---|
[2] | 2604 | } |
---|
| 2605 | |
---|
[608] | 2606 | Void TDecCavlc::parseCoeffNxN( TComDataCU* /*pcCU*/, TCoeff* /*pcCoef*/, UInt /*uiAbsPartIdx*/, UInt /*uiWidth*/, UInt /*uiHeight*/, UInt /*uiDepth*/, TextType /*eTType*/ ) |
---|
[2] | 2607 | { |
---|
[56] | 2608 | assert(0); |
---|
[2] | 2609 | } |
---|
| 2610 | |
---|
[608] | 2611 | Void TDecCavlc::parseTransformSubdivFlag( UInt& /*ruiSubdivFlag*/, UInt /*uiLog2TransformBlockSize*/ ) |
---|
[2] | 2612 | { |
---|
[56] | 2613 | assert(0); |
---|
[2] | 2614 | } |
---|
| 2615 | |
---|
[608] | 2616 | Void TDecCavlc::parseQtCbf( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, TextType /*eType*/, UInt /*uiTrDepth*/, UInt /*uiDepth*/ ) |
---|
[2] | 2617 | { |
---|
[56] | 2618 | assert(0); |
---|
[2] | 2619 | } |
---|
| 2620 | |
---|
[608] | 2621 | Void TDecCavlc::parseQtRootCbf( UInt /*uiAbsPartIdx*/, UInt& /*uiQtRootCbf*/ ) |
---|
[2] | 2622 | { |
---|
[56] | 2623 | assert(0); |
---|
[2] | 2624 | } |
---|
| 2625 | |
---|
[608] | 2626 | Void TDecCavlc::parseTransformSkipFlags (TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*width*/, UInt /*height*/, UInt /*uiDepth*/, TextType /*eTType*/) |
---|
[2] | 2627 | { |
---|
[56] | 2628 | assert(0); |
---|
[2] | 2629 | } |
---|
| 2630 | |
---|
[608] | 2631 | Void TDecCavlc::parseMergeFlag ( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/, UInt /*uiPUIdx*/ ) |
---|
[2] | 2632 | { |
---|
[56] | 2633 | assert(0); |
---|
[2] | 2634 | } |
---|
| 2635 | |
---|
[608] | 2636 | Void TDecCavlc::parseMergeIndex ( TComDataCU* /*pcCU*/, UInt& /*ruiMergeIndex*/ ) |
---|
[2] | 2637 | { |
---|
[56] | 2638 | assert(0); |
---|
[2] | 2639 | } |
---|
[608] | 2640 | |
---|
| 2641 | #if H_3D_ARP |
---|
[443] | 2642 | Void TDecCavlc::parseARPW( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 2643 | { |
---|
[608] | 2644 | assert(0); |
---|
[443] | 2645 | } |
---|
| 2646 | #endif |
---|
[608] | 2647 | #if H_3D_IC |
---|
| 2648 | Void TDecCavlc::parseICFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
[189] | 2649 | { |
---|
| 2650 | assert(0); |
---|
| 2651 | } |
---|
[608] | 2652 | #endif |
---|
| 2653 | #if LGE_INTER_SDC_E0156 |
---|
| 2654 | Void TDecCavlc::parseInterSDCFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
[189] | 2655 | { |
---|
| 2656 | assert(0); |
---|
| 2657 | } |
---|
[608] | 2658 | |
---|
| 2659 | Void TDecCavlc::parseInterSDCResidualData ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPart ) |
---|
[189] | 2660 | { |
---|
| 2661 | assert(0); |
---|
| 2662 | } |
---|
| 2663 | #endif |
---|
[2] | 2664 | // ==================================================================================================================== |
---|
| 2665 | // Protected member functions |
---|
| 2666 | // ==================================================================================================================== |
---|
| 2667 | |
---|
[56] | 2668 | /** parse explicit wp tables |
---|
[608] | 2669 | * \param TComSlice* pcSlice |
---|
| 2670 | * \returns Void |
---|
| 2671 | */ |
---|
[56] | 2672 | Void TDecCavlc::xParsePredWeightTable( TComSlice* pcSlice ) |
---|
[2] | 2673 | { |
---|
[56] | 2674 | wpScalingParam *wp; |
---|
| 2675 | Bool bChroma = true; // color always present in HEVC ? |
---|
| 2676 | SliceType eSliceType = pcSlice->getSliceType(); |
---|
| 2677 | Int iNbRef = (eSliceType == B_SLICE ) ? (2) : (1); |
---|
| 2678 | UInt uiLog2WeightDenomLuma, uiLog2WeightDenomChroma; |
---|
[608] | 2679 | UInt uiTotalSignalledWeightFlags = 0; |
---|
| 2680 | |
---|
| 2681 | Int iDeltaDenom; |
---|
| 2682 | // decode delta_luma_log2_weight_denom : |
---|
| 2683 | READ_UVLC( uiLog2WeightDenomLuma, "luma_log2_weight_denom" ); // ue(v): luma_log2_weight_denom |
---|
| 2684 | assert( uiLog2WeightDenomLuma <= 7 ); |
---|
| 2685 | if( bChroma ) |
---|
| 2686 | { |
---|
| 2687 | READ_SVLC( iDeltaDenom, "delta_chroma_log2_weight_denom" ); // se(v): delta_chroma_log2_weight_denom |
---|
| 2688 | assert((iDeltaDenom + (Int)uiLog2WeightDenomLuma)>=0); |
---|
| 2689 | assert((iDeltaDenom + (Int)uiLog2WeightDenomLuma)<=7); |
---|
| 2690 | uiLog2WeightDenomChroma = (UInt)(iDeltaDenom + uiLog2WeightDenomLuma); |
---|
| 2691 | } |
---|
[2] | 2692 | |
---|
[608] | 2693 | for ( Int iNumRef=0 ; iNumRef<iNbRef ; iNumRef++ ) |
---|
[2] | 2694 | { |
---|
[608] | 2695 | RefPicList eRefPicList = ( iNumRef ? REF_PIC_LIST_1 : REF_PIC_LIST_0 ); |
---|
| 2696 | for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ ) |
---|
[2] | 2697 | { |
---|
[608] | 2698 | pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); |
---|
| 2699 | |
---|
| 2700 | wp[0].uiLog2WeightDenom = uiLog2WeightDenomLuma; |
---|
| 2701 | wp[1].uiLog2WeightDenom = uiLog2WeightDenomChroma; |
---|
| 2702 | wp[2].uiLog2WeightDenom = uiLog2WeightDenomChroma; |
---|
| 2703 | |
---|
| 2704 | UInt uiCode; |
---|
| 2705 | READ_FLAG( uiCode, "luma_weight_lX_flag" ); // u(1): luma_weight_l0_flag |
---|
| 2706 | wp[0].bPresentFlag = ( uiCode == 1 ); |
---|
| 2707 | uiTotalSignalledWeightFlags += wp[0].bPresentFlag; |
---|
[56] | 2708 | } |
---|
[608] | 2709 | if ( bChroma ) |
---|
[56] | 2710 | { |
---|
[608] | 2711 | UInt uiCode; |
---|
[56] | 2712 | for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ ) |
---|
[2] | 2713 | { |
---|
[56] | 2714 | pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); |
---|
[608] | 2715 | READ_FLAG( uiCode, "chroma_weight_lX_flag" ); // u(1): chroma_weight_l0_flag |
---|
| 2716 | wp[1].bPresentFlag = ( uiCode == 1 ); |
---|
| 2717 | wp[2].bPresentFlag = ( uiCode == 1 ); |
---|
| 2718 | uiTotalSignalledWeightFlags += 2*wp[1].bPresentFlag; |
---|
[2] | 2719 | } |
---|
| 2720 | } |
---|
[608] | 2721 | for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ ) |
---|
[2] | 2722 | { |
---|
[608] | 2723 | pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); |
---|
[56] | 2724 | if ( wp[0].bPresentFlag ) |
---|
[2] | 2725 | { |
---|
[56] | 2726 | Int iDeltaWeight; |
---|
[608] | 2727 | READ_SVLC( iDeltaWeight, "delta_luma_weight_lX" ); // se(v): delta_luma_weight_l0[i] |
---|
| 2728 | assert( iDeltaWeight >= -128 ); |
---|
| 2729 | assert( iDeltaWeight <= 127 ); |
---|
[56] | 2730 | wp[0].iWeight = (iDeltaWeight + (1<<wp[0].uiLog2WeightDenom)); |
---|
[608] | 2731 | READ_SVLC( wp[0].iOffset, "luma_offset_lX" ); // se(v): luma_offset_l0[i] |
---|
| 2732 | assert( wp[0].iOffset >= -128 ); |
---|
| 2733 | assert( wp[0].iOffset <= 127 ); |
---|
[2] | 2734 | } |
---|
[56] | 2735 | else |
---|
[2] | 2736 | { |
---|
[56] | 2737 | wp[0].iWeight = (1 << wp[0].uiLog2WeightDenom); |
---|
| 2738 | wp[0].iOffset = 0; |
---|
[2] | 2739 | } |
---|
[56] | 2740 | if ( bChroma ) |
---|
[2] | 2741 | { |
---|
[56] | 2742 | if ( wp[1].bPresentFlag ) |
---|
[2] | 2743 | { |
---|
[56] | 2744 | for ( Int j=1 ; j<3 ; j++ ) |
---|
[2] | 2745 | { |
---|
[56] | 2746 | Int iDeltaWeight; |
---|
[608] | 2747 | READ_SVLC( iDeltaWeight, "delta_chroma_weight_lX" ); // se(v): chroma_weight_l0[i][j] |
---|
| 2748 | assert( iDeltaWeight >= -128 ); |
---|
| 2749 | assert( iDeltaWeight <= 127 ); |
---|
[56] | 2750 | wp[j].iWeight = (iDeltaWeight + (1<<wp[1].uiLog2WeightDenom)); |
---|
| 2751 | |
---|
| 2752 | Int iDeltaChroma; |
---|
[608] | 2753 | READ_SVLC( iDeltaChroma, "delta_chroma_offset_lX" ); // se(v): delta_chroma_offset_l0[i][j] |
---|
| 2754 | assert( iDeltaChroma >= -512 ); |
---|
| 2755 | assert( iDeltaChroma <= 511 ); |
---|
| 2756 | Int pred = ( 128 - ( ( 128*wp[j].iWeight)>>(wp[j].uiLog2WeightDenom) ) ); |
---|
| 2757 | wp[j].iOffset = Clip3(-128, 127, (iDeltaChroma + pred) ); |
---|
[2] | 2758 | } |
---|
| 2759 | } |
---|
[56] | 2760 | else |
---|
[2] | 2761 | { |
---|
[56] | 2762 | for ( Int j=1 ; j<3 ; j++ ) |
---|
[2] | 2763 | { |
---|
[56] | 2764 | wp[j].iWeight = (1 << wp[j].uiLog2WeightDenom); |
---|
| 2765 | wp[j].iOffset = 0; |
---|
[2] | 2766 | } |
---|
| 2767 | } |
---|
| 2768 | } |
---|
| 2769 | } |
---|
| 2770 | |
---|
[608] | 2771 | for ( Int iRefIdx=pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx<MAX_NUM_REF ; iRefIdx++ ) |
---|
[2] | 2772 | { |
---|
[608] | 2773 | pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); |
---|
[2] | 2774 | |
---|
[56] | 2775 | wp[0].bPresentFlag = false; |
---|
| 2776 | wp[1].bPresentFlag = false; |
---|
| 2777 | wp[2].bPresentFlag = false; |
---|
[2] | 2778 | } |
---|
| 2779 | } |
---|
[608] | 2780 | assert(uiTotalSignalledWeightFlags<=24); |
---|
[2] | 2781 | } |
---|
| 2782 | |
---|
[56] | 2783 | /** decode quantization matrix |
---|
[608] | 2784 | * \param scalingList quantization matrix information |
---|
| 2785 | */ |
---|
[56] | 2786 | Void TDecCavlc::parseScalingList(TComScalingList* scalingList) |
---|
[2] | 2787 | { |
---|
[56] | 2788 | UInt code, sizeId, listId; |
---|
| 2789 | Bool scalingListPredModeFlag; |
---|
[608] | 2790 | //for each size |
---|
| 2791 | for(sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
[2] | 2792 | { |
---|
[608] | 2793 | for(listId = 0; listId < g_scalingListNum[sizeId]; listId++) |
---|
[2] | 2794 | { |
---|
[608] | 2795 | READ_FLAG( code, "scaling_list_pred_mode_flag"); |
---|
| 2796 | scalingListPredModeFlag = (code) ? true : false; |
---|
| 2797 | if(!scalingListPredModeFlag) //Copy Mode |
---|
[2] | 2798 | { |
---|
[608] | 2799 | READ_UVLC( code, "scaling_list_pred_matrix_id_delta"); |
---|
| 2800 | scalingList->setRefMatrixId (sizeId,listId,(UInt)((Int)(listId)-(code))); |
---|
| 2801 | if( sizeId > SCALING_LIST_8x8 ) |
---|
[2] | 2802 | { |
---|
[608] | 2803 | scalingList->setScalingListDC(sizeId,listId,((listId == scalingList->getRefMatrixId (sizeId,listId))? 16 :scalingList->getScalingListDC(sizeId, scalingList->getRefMatrixId (sizeId,listId)))); |
---|
[2] | 2804 | } |
---|
[608] | 2805 | scalingList->processRefMatrix( sizeId, listId, scalingList->getRefMatrixId (sizeId,listId)); |
---|
| 2806 | |
---|
[2] | 2807 | } |
---|
[608] | 2808 | else //DPCM Mode |
---|
| 2809 | { |
---|
| 2810 | xDecodeScalingList(scalingList, sizeId, listId); |
---|
| 2811 | } |
---|
[2] | 2812 | } |
---|
| 2813 | } |
---|
| 2814 | |
---|
| 2815 | return; |
---|
| 2816 | } |
---|
[56] | 2817 | /** decode DPCM |
---|
[608] | 2818 | * \param scalingList quantization matrix information |
---|
| 2819 | * \param sizeId size index |
---|
| 2820 | * \param listId list index |
---|
| 2821 | */ |
---|
[56] | 2822 | Void TDecCavlc::xDecodeScalingList(TComScalingList *scalingList, UInt sizeId, UInt listId) |
---|
[2] | 2823 | { |
---|
[56] | 2824 | Int i,coefNum = min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId]); |
---|
| 2825 | Int data; |
---|
| 2826 | Int scalingListDcCoefMinus8 = 0; |
---|
| 2827 | Int nextCoef = SCALING_LIST_START_VALUE; |
---|
[608] | 2828 | UInt* scan = (sizeId == 0) ? g_auiSigLastScan [ SCAN_DIAG ] [ 1 ] : g_sigLastScanCG32x32; |
---|
[56] | 2829 | Int *dst = scalingList->getScalingListAddress(sizeId, listId); |
---|
[2] | 2830 | |
---|
[56] | 2831 | if( sizeId > SCALING_LIST_8x8 ) |
---|
[2] | 2832 | { |
---|
[56] | 2833 | READ_SVLC( scalingListDcCoefMinus8, "scaling_list_dc_coef_minus8"); |
---|
| 2834 | scalingList->setScalingListDC(sizeId,listId,scalingListDcCoefMinus8 + 8); |
---|
[608] | 2835 | nextCoef = scalingList->getScalingListDC(sizeId,listId); |
---|
[2] | 2836 | } |
---|
| 2837 | |
---|
[608] | 2838 | for(i = 0; i < coefNum; i++) |
---|
[2] | 2839 | { |
---|
[608] | 2840 | READ_SVLC( data, "scaling_list_delta_coef"); |
---|
| 2841 | nextCoef = (nextCoef + data + 256 ) % 256; |
---|
| 2842 | dst[scan[i]] = nextCoef; |
---|
[2] | 2843 | } |
---|
| 2844 | } |
---|
| 2845 | |
---|
[56] | 2846 | Bool TDecCavlc::xMoreRbspData() |
---|
| 2847 | { |
---|
| 2848 | Int bitsLeft = m_pcBitstream->getNumBitsLeft(); |
---|
[2] | 2849 | |
---|
[56] | 2850 | // if there are more than 8 bits, it cannot be rbsp_trailing_bits |
---|
| 2851 | if (bitsLeft > 8) |
---|
[2] | 2852 | { |
---|
[56] | 2853 | return true; |
---|
| 2854 | } |
---|
[2] | 2855 | |
---|
[56] | 2856 | UChar lastByte = m_pcBitstream->peekBits(bitsLeft); |
---|
| 2857 | Int cnt = bitsLeft; |
---|
[2] | 2858 | |
---|
[56] | 2859 | // remove trailing bits equal to zero |
---|
| 2860 | while ((cnt>0) && ((lastByte & 1) == 0)) |
---|
| 2861 | { |
---|
| 2862 | lastByte >>= 1; |
---|
| 2863 | cnt--; |
---|
| 2864 | } |
---|
| 2865 | // remove bit equal to one |
---|
| 2866 | cnt--; |
---|
[2] | 2867 | |
---|
[56] | 2868 | // we should not have a negative number of bits |
---|
| 2869 | assert (cnt>=0); |
---|
[2] | 2870 | |
---|
[56] | 2871 | // we have more data, if cnt is not zero |
---|
| 2872 | return (cnt>0); |
---|
| 2873 | } |
---|
[2] | 2874 | |
---|
[56] | 2875 | //! \} |
---|
[608] | 2876 | |
---|