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