[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 |
---|
[622] | 1273 | READ_FLAG( uiCode, "vps_depth_modes_flag[i]" ); pcVPS->setVpsDepthModesFlag( i, uiCode == 1 ? true : false ); |
---|
| 1274 | // READ_FLAG( uiCode, "lim_qt_pred_flag[i]"); pcVPS->setLimQtPreFlag ( i, uiCode == 1 ? true : false ); |
---|
| 1275 | #if H_3D_DIM_DLT |
---|
| 1276 | if( pcVPS->getVpsDepthModesFlag( i ) ) |
---|
| 1277 | { |
---|
| 1278 | READ_FLAG( uiCode, "dlt_flag[i]" ); pcVPS->setUseDLTFlag( i, uiCode == 1 ? true : false ); |
---|
| 1279 | } |
---|
| 1280 | if( pcVPS->getUseDLTFlag( i ) ) |
---|
| 1281 | { |
---|
| 1282 | // decode mapping |
---|
| 1283 | UInt uiNumDepthValues; |
---|
| 1284 | // parse number of values in DLT |
---|
| 1285 | READ_UVLC(uiNumDepthValues, "num_depth_values_in_dlt[i]"); |
---|
| 1286 | |
---|
| 1287 | // parse actual DLT values |
---|
| 1288 | Int* aiIdx2DepthValue = (Int*) calloc(uiNumDepthValues, sizeof(Int)); |
---|
| 1289 | for(Int d=0; d<uiNumDepthValues; d++) |
---|
| 1290 | { |
---|
| 1291 | READ_UVLC(uiCode, "dlt_depth_value[i][d]"); |
---|
| 1292 | aiIdx2DepthValue[d] = (Int)uiCode; |
---|
| 1293 | } |
---|
| 1294 | |
---|
| 1295 | pcVPS->setDepthLUTs(i, aiIdx2DepthValue, uiNumDepthValues); |
---|
| 1296 | |
---|
| 1297 | // clean memory |
---|
| 1298 | free(aiIdx2DepthValue); |
---|
| 1299 | } |
---|
| 1300 | #endif |
---|
[655] | 1301 | #if H_3D_INTER_SDC |
---|
[622] | 1302 | READ_FLAG( uiCode, "depth_inter_SDC_flag" ); pcVPS->setInterSDCFlag( i, uiCode ? true : false ); |
---|
| 1303 | #endif |
---|
| 1304 | } |
---|
| 1305 | } |
---|
| 1306 | } |
---|
| 1307 | READ_FLAG( uiCode, "iv_mv_scaling_flag"); pcVPS->setIvMvScalingFlag( uiCode == 1 ? true : false ); |
---|
| 1308 | } |
---|
| 1309 | #endif |
---|
| 1310 | |
---|
[608] | 1311 | Void TDecCavlc::parseSliceHeader (TComSlice*& rpcSlice, ParameterSetManagerDecoder *parameterSetManager) |
---|
[2] | 1312 | { |
---|
[56] | 1313 | UInt uiCode; |
---|
| 1314 | Int iCode; |
---|
[608] | 1315 | |
---|
[56] | 1316 | #if ENC_DEC_TRACE |
---|
| 1317 | xTraceSliceHeader(rpcSlice); |
---|
| 1318 | #endif |
---|
[608] | 1319 | TComPPS* pps = NULL; |
---|
| 1320 | TComSPS* sps = NULL; |
---|
| 1321 | #if H_MV |
---|
| 1322 | TComVPS* vps = NULL; |
---|
| 1323 | #endif |
---|
| 1324 | |
---|
| 1325 | UInt firstSliceSegmentInPic; |
---|
| 1326 | READ_FLAG( firstSliceSegmentInPic, "first_slice_segment_in_pic_flag" ); |
---|
| 1327 | if( rpcSlice->getRapPicFlag()) |
---|
| 1328 | { |
---|
| 1329 | READ_FLAG( uiCode, "no_output_of_prior_pics_flag" ); //ignored |
---|
| 1330 | } |
---|
| 1331 | READ_UVLC ( uiCode, "slice_pic_parameter_set_id" ); rpcSlice->setPPSId(uiCode); |
---|
| 1332 | pps = parameterSetManager->getPrefetchedPPS(uiCode); |
---|
| 1333 | //!KS: need to add error handling code here, if PPS is not available |
---|
| 1334 | assert(pps!=0); |
---|
| 1335 | sps = parameterSetManager->getPrefetchedSPS(pps->getSPSId()); |
---|
| 1336 | //!KS: need to add error handling code here, if SPS is not available |
---|
| 1337 | assert(sps!=0); |
---|
| 1338 | #if H_MV |
---|
| 1339 | vps = parameterSetManager->getPrefetchedVPS(sps->getVPSId()); |
---|
[622] | 1340 | assert( vps != NULL ); |
---|
| 1341 | |
---|
| 1342 | sps->inferRepFormat ( vps , rpcSlice->getLayerId() ); |
---|
| 1343 | sps->inferScalingList( parameterSetManager->getActiveSPS( sps->getSpsScalingListRefLayerId() ) ); |
---|
| 1344 | |
---|
| 1345 | rpcSlice->setVPS(vps); |
---|
| 1346 | rpcSlice->setViewId ( vps->getViewId ( rpcSlice->getLayerId() ) ); |
---|
| 1347 | rpcSlice->setViewIndex( vps->getViewIndex( rpcSlice->getLayerId() ) ); |
---|
| 1348 | #if H_3D |
---|
| 1349 | rpcSlice->setIsDepth ( vps->getDepthId ( rpcSlice->getLayerId() ) == 1 ); |
---|
| 1350 | #endif |
---|
[608] | 1351 | #endif |
---|
| 1352 | rpcSlice->setSPS(sps); |
---|
| 1353 | rpcSlice->setPPS(pps); |
---|
| 1354 | if( pps->getDependentSliceSegmentsEnabledFlag() && ( !firstSliceSegmentInPic )) |
---|
[2] | 1355 | { |
---|
[608] | 1356 | READ_FLAG( uiCode, "dependent_slice_segment_flag" ); rpcSlice->setDependentSliceSegmentFlag(uiCode ? true : false); |
---|
[2] | 1357 | } |
---|
[608] | 1358 | else |
---|
[2] | 1359 | { |
---|
[608] | 1360 | rpcSlice->setDependentSliceSegmentFlag(false); |
---|
[2] | 1361 | } |
---|
[608] | 1362 | Int numCTUs = ((sps->getPicWidthInLumaSamples()+sps->getMaxCUWidth()-1)/sps->getMaxCUWidth())*((sps->getPicHeightInLumaSamples()+sps->getMaxCUHeight()-1)/sps->getMaxCUHeight()); |
---|
| 1363 | Int maxParts = (1<<(sps->getMaxCUDepth()<<1)); |
---|
| 1364 | UInt sliceSegmentAddress = 0; |
---|
| 1365 | Int bitsSliceSegmentAddress = 0; |
---|
| 1366 | while(numCTUs>(1<<bitsSliceSegmentAddress)) |
---|
[189] | 1367 | { |
---|
[608] | 1368 | bitsSliceSegmentAddress++; |
---|
[189] | 1369 | } |
---|
| 1370 | |
---|
[608] | 1371 | if(!firstSliceSegmentInPic) |
---|
[2] | 1372 | { |
---|
[608] | 1373 | READ_CODE( bitsSliceSegmentAddress, sliceSegmentAddress, "slice_segment_address" ); |
---|
[2] | 1374 | } |
---|
[608] | 1375 | //set uiCode to equal slice start address (or dependent slice start address) |
---|
| 1376 | Int startCuAddress = maxParts*sliceSegmentAddress; |
---|
| 1377 | rpcSlice->setSliceSegmentCurStartCUAddr( startCuAddress ); |
---|
| 1378 | rpcSlice->setSliceSegmentCurEndCUAddr(numCTUs*maxParts); |
---|
[2] | 1379 | |
---|
[608] | 1380 | if (rpcSlice->getDependentSliceSegmentFlag()) |
---|
[2] | 1381 | { |
---|
[608] | 1382 | rpcSlice->setNextSlice ( false ); |
---|
| 1383 | rpcSlice->setNextSliceSegment ( true ); |
---|
[2] | 1384 | } |
---|
| 1385 | else |
---|
| 1386 | { |
---|
[608] | 1387 | rpcSlice->setNextSlice ( true ); |
---|
| 1388 | rpcSlice->setNextSliceSegment ( false ); |
---|
| 1389 | |
---|
| 1390 | rpcSlice->setSliceCurStartCUAddr(startCuAddress); |
---|
| 1391 | rpcSlice->setSliceCurEndCUAddr(numCTUs*maxParts); |
---|
[2] | 1392 | } |
---|
[608] | 1393 | |
---|
| 1394 | if(!rpcSlice->getDependentSliceSegmentFlag()) |
---|
| 1395 | { |
---|
| 1396 | #if H_MV |
---|
[622] | 1397 | Int esb = 0; //Don't use i, otherwise will shadow something below |
---|
| 1398 | if ( rpcSlice->getPPS()->getNumExtraSliceHeaderBits() > esb ) |
---|
| 1399 | { |
---|
| 1400 | esb++; |
---|
| 1401 | READ_FLAG( uiCode, "poc_reset_flag" ); rpcSlice->setPocResetFlag( uiCode == 1 ); |
---|
| 1402 | } |
---|
| 1403 | |
---|
| 1404 | if ( rpcSlice->getPPS()->getNumExtraSliceHeaderBits() > esb ) |
---|
| 1405 | { |
---|
| 1406 | esb++; |
---|
| 1407 | READ_FLAG( uiCode, "discardable_flag" ); rpcSlice->setDiscardableFlag( uiCode == 1 ); |
---|
| 1408 | } |
---|
| 1409 | |
---|
| 1410 | for (; esb < rpcSlice->getPPS()->getNumExtraSliceHeaderBits(); esb++) |
---|
| 1411 | #else |
---|
[608] | 1412 | for (Int i = 0; i < rpcSlice->getPPS()->getNumExtraSliceHeaderBits(); i++) |
---|
| 1413 | #endif |
---|
| 1414 | { |
---|
| 1415 | READ_FLAG(uiCode, "slice_reserved_undetermined_flag[]"); // ignored |
---|
| 1416 | } |
---|
| 1417 | |
---|
| 1418 | READ_UVLC ( uiCode, "slice_type" ); rpcSlice->setSliceType((SliceType)uiCode); |
---|
[56] | 1419 | if( pps->getOutputFlagPresentFlag() ) |
---|
[2] | 1420 | { |
---|
[608] | 1421 | READ_FLAG( uiCode, "pic_output_flag" ); rpcSlice->setPicOutputFlag( uiCode ? true : false ); |
---|
[2] | 1422 | } |
---|
[56] | 1423 | else |
---|
| 1424 | { |
---|
| 1425 | rpcSlice->setPicOutputFlag( true ); |
---|
| 1426 | } |
---|
[608] | 1427 | // in the first version chroma_format_idc is equal to one, thus colour_plane_id will not be present |
---|
| 1428 | assert (sps->getChromaFormatIdc() == 1 ); |
---|
| 1429 | // if( separate_colour_plane_flag == 1 ) |
---|
| 1430 | // colour_plane_id u(2) |
---|
| 1431 | |
---|
| 1432 | if( rpcSlice->getIdrPicFlag() ) |
---|
| 1433 | { |
---|
[56] | 1434 | rpcSlice->setPOC(0); |
---|
| 1435 | TComReferencePictureSet* rps = rpcSlice->getLocalRPS(); |
---|
| 1436 | rps->setNumberOfNegativePictures(0); |
---|
| 1437 | rps->setNumberOfPositivePictures(0); |
---|
| 1438 | rps->setNumberOfLongtermPictures(0); |
---|
| 1439 | rps->setNumberOfPictures(0); |
---|
| 1440 | rpcSlice->setRPS(rps); |
---|
[608] | 1441 | #if H_MV |
---|
| 1442 | rpcSlice->setEnableTMVPFlag(false); |
---|
| 1443 | #endif |
---|
[56] | 1444 | } |
---|
| 1445 | else |
---|
[2] | 1446 | { |
---|
[56] | 1447 | READ_CODE(sps->getBitsForPOC(), uiCode, "pic_order_cnt_lsb"); |
---|
| 1448 | Int iPOClsb = uiCode; |
---|
[655] | 1449 | Int iPrevPOC = rpcSlice->getPrevTid0POC(); |
---|
[56] | 1450 | Int iMaxPOClsb = 1<< sps->getBitsForPOC(); |
---|
[655] | 1451 | Int iPrevPOClsb = iPrevPOC & (iMaxPOClsb - 1); |
---|
[56] | 1452 | Int iPrevPOCmsb = iPrevPOC-iPrevPOClsb; |
---|
| 1453 | Int iPOCmsb; |
---|
| 1454 | if( ( iPOClsb < iPrevPOClsb ) && ( ( iPrevPOClsb - iPOClsb ) >= ( iMaxPOClsb / 2 ) ) ) |
---|
[2] | 1455 | { |
---|
[56] | 1456 | iPOCmsb = iPrevPOCmsb + iMaxPOClsb; |
---|
[2] | 1457 | } |
---|
[56] | 1458 | else if( (iPOClsb > iPrevPOClsb ) && ( (iPOClsb - iPrevPOClsb ) > ( iMaxPOClsb / 2 ) ) ) |
---|
| 1459 | { |
---|
| 1460 | iPOCmsb = iPrevPOCmsb - iMaxPOClsb; |
---|
| 1461 | } |
---|
| 1462 | else |
---|
| 1463 | { |
---|
| 1464 | iPOCmsb = iPrevPOCmsb; |
---|
| 1465 | } |
---|
[608] | 1466 | if ( rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP |
---|
| 1467 | || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL |
---|
| 1468 | || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP ) |
---|
[56] | 1469 | { |
---|
[608] | 1470 | // For BLA picture types, POCmsb is set to 0. |
---|
| 1471 | iPOCmsb = 0; |
---|
[56] | 1472 | } |
---|
[608] | 1473 | rpcSlice->setPOC (iPOCmsb+iPOClsb); |
---|
[622] | 1474 | #if H_MV |
---|
| 1475 | if ( rpcSlice->getPocResetFlag() ) |
---|
| 1476 | { |
---|
| 1477 | rpcSlice->setPocBeforeReset ( rpcSlice->getPOC() ); |
---|
| 1478 | rpcSlice->setPOC ( 0 ); |
---|
[608] | 1479 | |
---|
[622] | 1480 | } |
---|
| 1481 | #endif |
---|
[608] | 1482 | TComReferencePictureSet* rps; |
---|
| 1483 | rps = rpcSlice->getLocalRPS(); |
---|
| 1484 | rpcSlice->setRPS(rps); |
---|
| 1485 | READ_FLAG( uiCode, "short_term_ref_pic_set_sps_flag" ); |
---|
| 1486 | if(uiCode == 0) // use short-term reference picture set explicitly signalled in slice header |
---|
[56] | 1487 | { |
---|
[608] | 1488 | parseShortTermRefPicSet(sps,rps, sps->getRPSList()->getNumberOfReferencePictureSets()); |
---|
| 1489 | } |
---|
| 1490 | else // use reference to short-term reference picture set in PPS |
---|
| 1491 | { |
---|
| 1492 | Int numBits = 0; |
---|
| 1493 | while ((1 << numBits) < rpcSlice->getSPS()->getRPSList()->getNumberOfReferencePictureSets()) |
---|
[56] | 1494 | { |
---|
[608] | 1495 | numBits++; |
---|
[56] | 1496 | } |
---|
[608] | 1497 | if (numBits > 0) |
---|
[56] | 1498 | { |
---|
[608] | 1499 | READ_CODE( numBits, uiCode, "short_term_ref_pic_set_idx"); |
---|
[56] | 1500 | } |
---|
[608] | 1501 | else |
---|
[56] | 1502 | { |
---|
[608] | 1503 | uiCode = 0; |
---|
| 1504 | } |
---|
| 1505 | *rps = *(sps->getRPSList()->getReferencePictureSet(uiCode)); |
---|
| 1506 | } |
---|
| 1507 | if(sps->getLongTermRefsPresent()) |
---|
| 1508 | { |
---|
| 1509 | Int offset = rps->getNumberOfNegativePictures()+rps->getNumberOfPositivePictures(); |
---|
| 1510 | UInt numOfLtrp = 0; |
---|
| 1511 | UInt numLtrpInSPS = 0; |
---|
| 1512 | if (rpcSlice->getSPS()->getNumLongTermRefPicSPS() > 0) |
---|
| 1513 | { |
---|
| 1514 | READ_UVLC( uiCode, "num_long_term_sps"); |
---|
| 1515 | numLtrpInSPS = uiCode; |
---|
| 1516 | numOfLtrp += numLtrpInSPS; |
---|
| 1517 | rps->setNumberOfLongtermPictures(numOfLtrp); |
---|
| 1518 | } |
---|
| 1519 | Int bitsForLtrpInSPS = 0; |
---|
| 1520 | while (rpcSlice->getSPS()->getNumLongTermRefPicSPS() > (1 << bitsForLtrpInSPS)) |
---|
| 1521 | { |
---|
| 1522 | bitsForLtrpInSPS++; |
---|
| 1523 | } |
---|
| 1524 | READ_UVLC( uiCode, "num_long_term_pics"); rps->setNumberOfLongtermPictures(uiCode); |
---|
| 1525 | numOfLtrp += uiCode; |
---|
| 1526 | rps->setNumberOfLongtermPictures(numOfLtrp); |
---|
| 1527 | Int maxPicOrderCntLSB = 1 << rpcSlice->getSPS()->getBitsForPOC(); |
---|
| 1528 | Int prevDeltaMSB = 0, deltaPocMSBCycleLT = 0;; |
---|
| 1529 | for(Int j=offset+rps->getNumberOfLongtermPictures()-1, k = 0; k < numOfLtrp; j--, k++) |
---|
| 1530 | { |
---|
| 1531 | Int pocLsbLt; |
---|
| 1532 | if (k < numLtrpInSPS) |
---|
[56] | 1533 | { |
---|
[608] | 1534 | uiCode = 0; |
---|
| 1535 | if (bitsForLtrpInSPS > 0) |
---|
| 1536 | { |
---|
| 1537 | READ_CODE(bitsForLtrpInSPS, uiCode, "lt_idx_sps[i]"); |
---|
| 1538 | } |
---|
| 1539 | Int usedByCurrFromSPS=rpcSlice->getSPS()->getUsedByCurrPicLtSPSFlag(uiCode); |
---|
[2] | 1540 | |
---|
[608] | 1541 | pocLsbLt = rpcSlice->getSPS()->getLtRefPicPocLsbSps(uiCode); |
---|
| 1542 | rps->setUsed(j,usedByCurrFromSPS); |
---|
| 1543 | } |
---|
| 1544 | else |
---|
| 1545 | { |
---|
| 1546 | READ_CODE(rpcSlice->getSPS()->getBitsForPOC(), uiCode, "poc_lsb_lt"); pocLsbLt= uiCode; |
---|
| 1547 | READ_FLAG( uiCode, "used_by_curr_pic_lt_flag"); rps->setUsed(j,uiCode); |
---|
| 1548 | } |
---|
| 1549 | READ_FLAG(uiCode,"delta_poc_msb_present_flag"); |
---|
| 1550 | Bool mSBPresentFlag = uiCode ? true : false; |
---|
| 1551 | if(mSBPresentFlag) |
---|
| 1552 | { |
---|
| 1553 | READ_UVLC( uiCode, "delta_poc_msb_cycle_lt[i]" ); |
---|
| 1554 | Bool deltaFlag = false; |
---|
| 1555 | // First LTRP || First LTRP from SH |
---|
| 1556 | if( (j == offset+rps->getNumberOfLongtermPictures()-1) || (j == offset+(numOfLtrp-numLtrpInSPS)-1) ) |
---|
[56] | 1557 | { |
---|
[608] | 1558 | deltaFlag = true; |
---|
[56] | 1559 | } |
---|
[608] | 1560 | if(deltaFlag) |
---|
| 1561 | { |
---|
| 1562 | deltaPocMSBCycleLT = uiCode; |
---|
| 1563 | } |
---|
[56] | 1564 | else |
---|
| 1565 | { |
---|
[608] | 1566 | deltaPocMSBCycleLT = uiCode + prevDeltaMSB; |
---|
[56] | 1567 | } |
---|
[608] | 1568 | |
---|
| 1569 | Int pocLTCurr = rpcSlice->getPOC() - deltaPocMSBCycleLT * maxPicOrderCntLSB |
---|
| 1570 | - iPOClsb + pocLsbLt; |
---|
| 1571 | rps->setPOC (j, pocLTCurr); |
---|
| 1572 | rps->setDeltaPOC(j, - rpcSlice->getPOC() + pocLTCurr); |
---|
| 1573 | rps->setCheckLTMSBPresent(j,true); |
---|
[56] | 1574 | } |
---|
[608] | 1575 | else |
---|
| 1576 | { |
---|
| 1577 | rps->setPOC (j, pocLsbLt); |
---|
| 1578 | rps->setDeltaPOC(j, - rpcSlice->getPOC() + pocLsbLt); |
---|
| 1579 | rps->setCheckLTMSBPresent(j,false); |
---|
[655] | 1580 | |
---|
| 1581 | // reset deltaPocMSBCycleLT for first LTRP from slice header if MSB not present |
---|
| 1582 | if( j == offset+(numOfLtrp-numLtrpInSPS)-1 ) |
---|
| 1583 | { |
---|
| 1584 | deltaPocMSBCycleLT = 0; |
---|
| 1585 | } |
---|
[608] | 1586 | } |
---|
| 1587 | prevDeltaMSB = deltaPocMSBCycleLT; |
---|
| 1588 | } |
---|
| 1589 | offset += rps->getNumberOfLongtermPictures(); |
---|
| 1590 | rps->setNumberOfPictures(offset); |
---|
| 1591 | } |
---|
| 1592 | if ( rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP |
---|
| 1593 | || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL |
---|
| 1594 | || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP ) |
---|
| 1595 | { |
---|
| 1596 | // In the case of BLA picture types, rps data is read from slice header but ignored |
---|
| 1597 | rps = rpcSlice->getLocalRPS(); |
---|
| 1598 | rps->setNumberOfNegativePictures(0); |
---|
| 1599 | rps->setNumberOfPositivePictures(0); |
---|
| 1600 | rps->setNumberOfLongtermPictures(0); |
---|
| 1601 | rps->setNumberOfPictures(0); |
---|
| 1602 | rpcSlice->setRPS(rps); |
---|
[56] | 1603 | } |
---|
[608] | 1604 | if (rpcSlice->getSPS()->getTMVPFlagsPresent()) |
---|
[2] | 1605 | { |
---|
[608] | 1606 | READ_FLAG( uiCode, "slice_temporal_mvp_enable_flag" ); |
---|
| 1607 | rpcSlice->setEnableTMVPFlag( uiCode == 1 ? true : false ); |
---|
[56] | 1608 | } |
---|
[608] | 1609 | else |
---|
[56] | 1610 | { |
---|
[608] | 1611 | rpcSlice->setEnableTMVPFlag(false); |
---|
| 1612 | } |
---|
| 1613 | } |
---|
| 1614 | #if H_MV |
---|
[622] | 1615 | Int layerId = rpcSlice->getLayerId(); |
---|
| 1616 | if( rpcSlice->getLayerId() > 0 && !vps->getAllRefLayersActiveFlag() && vps->getNumDirectRefLayers( layerId ) > 0 ) { |
---|
| 1617 | READ_FLAG( uiCode, "inter_layer_pred_enabled_flag" ); rpcSlice->setInterLayerPredEnabledFlag( uiCode == 1 ); |
---|
| 1618 | if( rpcSlice->getInterLayerPredEnabledFlag() && vps->getNumDirectRefLayers( layerId ) > 1 ) |
---|
| 1619 | { |
---|
| 1620 | if( !vps->getMaxOneActiveRefLayerFlag()) |
---|
| 1621 | { |
---|
| 1622 | READ_CODE( rpcSlice->getNumInterLayerRefPicsMinus1Len( ), uiCode, "num_inter_layer_ref_pics_minus1" ); rpcSlice->setNumInterLayerRefPicsMinus1( uiCode ); |
---|
| 1623 | } |
---|
| 1624 | if ( rpcSlice->getNumActiveRefLayerPics() != vps->getNumDirectRefLayers( layerId ) ) |
---|
| 1625 | { |
---|
| 1626 | for( Int idx = 0; idx < rpcSlice->getNumActiveRefLayerPics(); idx++ ) |
---|
| 1627 | { |
---|
| 1628 | READ_CODE( rpcSlice->getInterLayerPredLayerIdcLen( ), uiCode, "inter_layer_pred_layer_idc" ); rpcSlice->setInterLayerPredLayerIdc( idx, uiCode ); |
---|
| 1629 | } |
---|
| 1630 | } |
---|
| 1631 | } |
---|
| 1632 | } |
---|
[443] | 1633 | #endif |
---|
[608] | 1634 | if(sps->getUseSAO()) |
---|
| 1635 | { |
---|
| 1636 | READ_FLAG(uiCode, "slice_sao_luma_flag"); rpcSlice->setSaoEnabledFlag((Bool)uiCode); |
---|
| 1637 | READ_FLAG(uiCode, "slice_sao_chroma_flag"); rpcSlice->setSaoEnabledFlagChroma((Bool)uiCode); |
---|
[56] | 1638 | } |
---|
[608] | 1639 | |
---|
| 1640 | if (rpcSlice->getIdrPicFlag()) |
---|
| 1641 | { |
---|
| 1642 | rpcSlice->setEnableTMVPFlag(false); |
---|
| 1643 | } |
---|
[56] | 1644 | if (!rpcSlice->isIntra()) |
---|
| 1645 | { |
---|
[608] | 1646 | |
---|
[56] | 1647 | READ_FLAG( uiCode, "num_ref_idx_active_override_flag"); |
---|
| 1648 | if (uiCode) |
---|
[2] | 1649 | { |
---|
[608] | 1650 | READ_UVLC (uiCode, "num_ref_idx_l0_active_minus1" ); rpcSlice->setNumRefIdx( REF_PIC_LIST_0, uiCode + 1 ); |
---|
[56] | 1651 | if (rpcSlice->isInterB()) |
---|
[2] | 1652 | { |
---|
[608] | 1653 | READ_UVLC (uiCode, "num_ref_idx_l1_active_minus1" ); rpcSlice->setNumRefIdx( REF_PIC_LIST_1, uiCode + 1 ); |
---|
[2] | 1654 | } |
---|
| 1655 | else |
---|
| 1656 | { |
---|
[56] | 1657 | rpcSlice->setNumRefIdx(REF_PIC_LIST_1, 0); |
---|
[2] | 1658 | } |
---|
| 1659 | } |
---|
| 1660 | else |
---|
| 1661 | { |
---|
[608] | 1662 | rpcSlice->setNumRefIdx(REF_PIC_LIST_0, rpcSlice->getPPS()->getNumRefIdxL0DefaultActive()); |
---|
| 1663 | if (rpcSlice->isInterB()) |
---|
| 1664 | { |
---|
| 1665 | rpcSlice->setNumRefIdx(REF_PIC_LIST_1, rpcSlice->getPPS()->getNumRefIdxL1DefaultActive()); |
---|
| 1666 | } |
---|
| 1667 | else |
---|
| 1668 | { |
---|
| 1669 | rpcSlice->setNumRefIdx(REF_PIC_LIST_1,0); |
---|
| 1670 | } |
---|
[2] | 1671 | } |
---|
| 1672 | } |
---|
[608] | 1673 | // } |
---|
[56] | 1674 | TComRefPicListModification* refPicListModification = rpcSlice->getRefPicListModification(); |
---|
[608] | 1675 | if(!rpcSlice->isIntra()) |
---|
[2] | 1676 | { |
---|
[608] | 1677 | if( !rpcSlice->getPPS()->getListsModificationPresentFlag() || rpcSlice->getNumRpsCurrTempList() <= 1 ) |
---|
[2] | 1678 | { |
---|
[56] | 1679 | refPicListModification->setRefPicListModificationFlagL0( 0 ); |
---|
[2] | 1680 | } |
---|
| 1681 | else |
---|
| 1682 | { |
---|
[56] | 1683 | READ_FLAG( uiCode, "ref_pic_list_modification_flag_l0" ); refPicListModification->setRefPicListModificationFlagL0( uiCode ? 1 : 0 ); |
---|
[2] | 1684 | } |
---|
[608] | 1685 | |
---|
[56] | 1686 | if(refPicListModification->getRefPicListModificationFlagL0()) |
---|
[608] | 1687 | { |
---|
[56] | 1688 | uiCode = 0; |
---|
| 1689 | Int i = 0; |
---|
[608] | 1690 | Int numRpsCurrTempList0 = rpcSlice->getNumRpsCurrTempList(); |
---|
| 1691 | if ( numRpsCurrTempList0 > 1 ) |
---|
[56] | 1692 | { |
---|
| 1693 | Int length = 1; |
---|
[608] | 1694 | numRpsCurrTempList0 --; |
---|
| 1695 | while ( numRpsCurrTempList0 >>= 1) |
---|
[56] | 1696 | { |
---|
| 1697 | length ++; |
---|
| 1698 | } |
---|
| 1699 | for (i = 0; i < rpcSlice->getNumRefIdx(REF_PIC_LIST_0); i ++) |
---|
| 1700 | { |
---|
| 1701 | READ_CODE( length, uiCode, "list_entry_l0" ); |
---|
| 1702 | refPicListModification->setRefPicSetIdxL0(i, uiCode ); |
---|
| 1703 | } |
---|
| 1704 | } |
---|
| 1705 | else |
---|
| 1706 | { |
---|
| 1707 | for (i = 0; i < rpcSlice->getNumRefIdx(REF_PIC_LIST_0); i ++) |
---|
| 1708 | { |
---|
| 1709 | refPicListModification->setRefPicSetIdxL0(i, 0 ); |
---|
| 1710 | } |
---|
| 1711 | } |
---|
[2] | 1712 | } |
---|
| 1713 | } |
---|
[56] | 1714 | else |
---|
[2] | 1715 | { |
---|
[56] | 1716 | refPicListModification->setRefPicListModificationFlagL0(0); |
---|
[2] | 1717 | } |
---|
[56] | 1718 | if(rpcSlice->isInterB()) |
---|
[2] | 1719 | { |
---|
[608] | 1720 | if( !rpcSlice->getPPS()->getListsModificationPresentFlag() || rpcSlice->getNumRpsCurrTempList() <= 1 ) |
---|
[2] | 1721 | { |
---|
[56] | 1722 | refPicListModification->setRefPicListModificationFlagL1( 0 ); |
---|
[2] | 1723 | } |
---|
| 1724 | else |
---|
| 1725 | { |
---|
[56] | 1726 | READ_FLAG( uiCode, "ref_pic_list_modification_flag_l1" ); refPicListModification->setRefPicListModificationFlagL1( uiCode ? 1 : 0 ); |
---|
[2] | 1727 | } |
---|
[56] | 1728 | if(refPicListModification->getRefPicListModificationFlagL1()) |
---|
[2] | 1729 | { |
---|
[56] | 1730 | uiCode = 0; |
---|
| 1731 | Int i = 0; |
---|
[608] | 1732 | Int numRpsCurrTempList1 = rpcSlice->getNumRpsCurrTempList(); |
---|
| 1733 | if ( numRpsCurrTempList1 > 1 ) |
---|
[56] | 1734 | { |
---|
| 1735 | Int length = 1; |
---|
[608] | 1736 | numRpsCurrTempList1 --; |
---|
| 1737 | while ( numRpsCurrTempList1 >>= 1) |
---|
[56] | 1738 | { |
---|
| 1739 | length ++; |
---|
| 1740 | } |
---|
| 1741 | for (i = 0; i < rpcSlice->getNumRefIdx(REF_PIC_LIST_1); i ++) |
---|
| 1742 | { |
---|
| 1743 | READ_CODE( length, uiCode, "list_entry_l1" ); |
---|
| 1744 | refPicListModification->setRefPicSetIdxL1(i, uiCode ); |
---|
| 1745 | } |
---|
| 1746 | } |
---|
| 1747 | else |
---|
| 1748 | { |
---|
| 1749 | for (i = 0; i < rpcSlice->getNumRefIdx(REF_PIC_LIST_1); i ++) |
---|
| 1750 | { |
---|
| 1751 | refPicListModification->setRefPicSetIdxL1(i, 0 ); |
---|
| 1752 | } |
---|
| 1753 | } |
---|
[2] | 1754 | } |
---|
[56] | 1755 | } |
---|
| 1756 | else |
---|
[2] | 1757 | { |
---|
[56] | 1758 | refPicListModification->setRefPicListModificationFlagL1(0); |
---|
[2] | 1759 | } |
---|
[608] | 1760 | if (rpcSlice->isInterB()) |
---|
[2] | 1761 | { |
---|
[608] | 1762 | READ_FLAG( uiCode, "mvd_l1_zero_flag" ); rpcSlice->setMvdL1ZeroFlag( (uiCode ? true : false) ); |
---|
| 1763 | } |
---|
| 1764 | |
---|
| 1765 | rpcSlice->setCabacInitFlag( false ); // default |
---|
| 1766 | if(pps->getCabacInitPresentFlag() && !rpcSlice->isIntra()) |
---|
| 1767 | { |
---|
| 1768 | READ_FLAG(uiCode, "cabac_init_flag"); |
---|
| 1769 | rpcSlice->setCabacInitFlag( uiCode ? true : false ); |
---|
| 1770 | } |
---|
| 1771 | |
---|
| 1772 | if ( rpcSlice->getEnableTMVPFlag() ) |
---|
| 1773 | { |
---|
| 1774 | if ( rpcSlice->getSliceType() == B_SLICE ) |
---|
[56] | 1775 | { |
---|
[608] | 1776 | READ_FLAG( uiCode, "collocated_from_l0_flag" ); |
---|
| 1777 | rpcSlice->setColFromL0Flag(uiCode); |
---|
[2] | 1778 | } |
---|
| 1779 | else |
---|
| 1780 | { |
---|
[608] | 1781 | rpcSlice->setColFromL0Flag( 1 ); |
---|
[2] | 1782 | } |
---|
[608] | 1783 | |
---|
| 1784 | if ( rpcSlice->getSliceType() != I_SLICE && |
---|
| 1785 | ((rpcSlice->getColFromL0Flag() == 1 && rpcSlice->getNumRefIdx(REF_PIC_LIST_0) > 1)|| |
---|
| 1786 | (rpcSlice->getColFromL0Flag() == 0 && rpcSlice->getNumRefIdx(REF_PIC_LIST_1) > 1))) |
---|
| 1787 | { |
---|
| 1788 | READ_UVLC( uiCode, "collocated_ref_idx" ); |
---|
| 1789 | rpcSlice->setColRefIdx(uiCode); |
---|
| 1790 | } |
---|
| 1791 | else |
---|
| 1792 | { |
---|
| 1793 | rpcSlice->setColRefIdx(0); |
---|
| 1794 | } |
---|
[2] | 1795 | } |
---|
[608] | 1796 | if ( (pps->getUseWP() && rpcSlice->getSliceType()==P_SLICE) || (pps->getWPBiPred() && rpcSlice->getSliceType()==B_SLICE) ) |
---|
[2] | 1797 | { |
---|
[608] | 1798 | xParsePredWeightTable(rpcSlice); |
---|
| 1799 | rpcSlice->initWpScaling(); |
---|
[2] | 1800 | } |
---|
[608] | 1801 | #if H_3D_IC |
---|
| 1802 | else if( rpcSlice->getViewIndex() && ( rpcSlice->getSliceType() == P_SLICE || rpcSlice->getSliceType() == B_SLICE ) ) |
---|
| 1803 | { |
---|
| 1804 | UInt uiCodeTmp = 0; |
---|
[2] | 1805 | |
---|
[608] | 1806 | READ_FLAG ( uiCodeTmp, "slice_ic_enable_flag" ); |
---|
| 1807 | rpcSlice->setApplyIC( uiCodeTmp ); |
---|
| 1808 | |
---|
| 1809 | if ( uiCodeTmp ) |
---|
| 1810 | { |
---|
| 1811 | READ_FLAG ( uiCodeTmp, "ic_skip_mergeidx0" ); |
---|
| 1812 | rpcSlice->setIcSkipParseFlag( uiCodeTmp ); |
---|
| 1813 | } |
---|
| 1814 | } |
---|
| 1815 | #endif |
---|
| 1816 | if (!rpcSlice->isIntra()) |
---|
| 1817 | { |
---|
| 1818 | READ_UVLC( uiCode, "five_minus_max_num_merge_cand"); |
---|
| 1819 | #if H_3D_IV_MERGE |
---|
| 1820 | Bool ivMvPredFlag = rpcSlice->getVPS()->getIvMvPredFlag( rpcSlice->getLayerIdInVps() ) ; |
---|
| 1821 | rpcSlice->setMaxNumMergeCand(( ivMvPredFlag ? MRG_MAX_NUM_CANDS_MEM : MRG_MAX_NUM_CANDS) - uiCode); |
---|
[56] | 1822 | #else |
---|
[608] | 1823 | rpcSlice->setMaxNumMergeCand(MRG_MAX_NUM_CANDS - uiCode); |
---|
[56] | 1824 | #endif |
---|
[608] | 1825 | } |
---|
[2] | 1826 | |
---|
[608] | 1827 | READ_SVLC( iCode, "slice_qp_delta" ); |
---|
[56] | 1828 | rpcSlice->setSliceQp (26 + pps->getPicInitQPMinus26() + iCode); |
---|
[2] | 1829 | |
---|
[56] | 1830 | assert( rpcSlice->getSliceQp() >= -sps->getQpBDOffsetY() ); |
---|
| 1831 | assert( rpcSlice->getSliceQp() <= 51 ); |
---|
[2] | 1832 | |
---|
[608] | 1833 | if (rpcSlice->getPPS()->getSliceChromaQpFlag()) |
---|
[2] | 1834 | { |
---|
[608] | 1835 | READ_SVLC( iCode, "slice_qp_delta_cb" ); |
---|
| 1836 | rpcSlice->setSliceQpDeltaCb( iCode ); |
---|
| 1837 | assert( rpcSlice->getSliceQpDeltaCb() >= -12 ); |
---|
| 1838 | assert( rpcSlice->getSliceQpDeltaCb() <= 12 ); |
---|
| 1839 | assert( (rpcSlice->getPPS()->getChromaCbQpOffset() + rpcSlice->getSliceQpDeltaCb()) >= -12 ); |
---|
| 1840 | assert( (rpcSlice->getPPS()->getChromaCbQpOffset() + rpcSlice->getSliceQpDeltaCb()) <= 12 ); |
---|
| 1841 | |
---|
| 1842 | READ_SVLC( iCode, "slice_qp_delta_cr" ); |
---|
| 1843 | rpcSlice->setSliceQpDeltaCr( iCode ); |
---|
| 1844 | assert( rpcSlice->getSliceQpDeltaCr() >= -12 ); |
---|
| 1845 | assert( rpcSlice->getSliceQpDeltaCr() <= 12 ); |
---|
| 1846 | assert( (rpcSlice->getPPS()->getChromaCrQpOffset() + rpcSlice->getSliceQpDeltaCr()) >= -12 ); |
---|
| 1847 | assert( (rpcSlice->getPPS()->getChromaCrQpOffset() + rpcSlice->getSliceQpDeltaCr()) <= 12 ); |
---|
| 1848 | } |
---|
| 1849 | |
---|
| 1850 | if (rpcSlice->getPPS()->getDeblockingFilterControlPresentFlag()) |
---|
| 1851 | { |
---|
| 1852 | if(rpcSlice->getPPS()->getDeblockingFilterOverrideEnabledFlag()) |
---|
[2] | 1853 | { |
---|
[608] | 1854 | READ_FLAG ( uiCode, "deblocking_filter_override_flag" ); rpcSlice->setDeblockingFilterOverrideFlag(uiCode ? true : false); |
---|
[2] | 1855 | } |
---|
[608] | 1856 | else |
---|
| 1857 | { |
---|
| 1858 | rpcSlice->setDeblockingFilterOverrideFlag(0); |
---|
| 1859 | } |
---|
| 1860 | if(rpcSlice->getDeblockingFilterOverrideFlag()) |
---|
[2] | 1861 | { |
---|
[608] | 1862 | READ_FLAG ( uiCode, "slice_disable_deblocking_filter_flag" ); rpcSlice->setDeblockingFilterDisable(uiCode ? 1 : 0); |
---|
| 1863 | if(!rpcSlice->getDeblockingFilterDisable()) |
---|
[56] | 1864 | { |
---|
[608] | 1865 | READ_SVLC( iCode, "slice_beta_offset_div2" ); rpcSlice->setDeblockingFilterBetaOffsetDiv2(iCode); |
---|
| 1866 | assert(rpcSlice->getDeblockingFilterBetaOffsetDiv2() >= -6 && |
---|
| 1867 | rpcSlice->getDeblockingFilterBetaOffsetDiv2() <= 6); |
---|
| 1868 | READ_SVLC( iCode, "slice_tc_offset_div2" ); rpcSlice->setDeblockingFilterTcOffsetDiv2(iCode); |
---|
| 1869 | assert(rpcSlice->getDeblockingFilterTcOffsetDiv2() >= -6 && |
---|
| 1870 | rpcSlice->getDeblockingFilterTcOffsetDiv2() <= 6); |
---|
[56] | 1871 | } |
---|
[2] | 1872 | } |
---|
[608] | 1873 | else |
---|
| 1874 | { |
---|
| 1875 | rpcSlice->setDeblockingFilterDisable ( rpcSlice->getPPS()->getPicDisableDeblockingFilterFlag() ); |
---|
| 1876 | rpcSlice->setDeblockingFilterBetaOffsetDiv2( rpcSlice->getPPS()->getDeblockingFilterBetaOffsetDiv2() ); |
---|
| 1877 | rpcSlice->setDeblockingFilterTcOffsetDiv2 ( rpcSlice->getPPS()->getDeblockingFilterTcOffsetDiv2() ); |
---|
| 1878 | } |
---|
| 1879 | } |
---|
| 1880 | else |
---|
| 1881 | { |
---|
| 1882 | rpcSlice->setDeblockingFilterDisable ( false ); |
---|
| 1883 | rpcSlice->setDeblockingFilterBetaOffsetDiv2( 0 ); |
---|
| 1884 | rpcSlice->setDeblockingFilterTcOffsetDiv2 ( 0 ); |
---|
| 1885 | } |
---|
| 1886 | |
---|
| 1887 | Bool isSAOEnabled = (!rpcSlice->getSPS()->getUseSAO())?(false):(rpcSlice->getSaoEnabledFlag()||rpcSlice->getSaoEnabledFlagChroma()); |
---|
| 1888 | Bool isDBFEnabled = (!rpcSlice->getDeblockingFilterDisable()); |
---|
| 1889 | |
---|
| 1890 | if(rpcSlice->getPPS()->getLoopFilterAcrossSlicesEnabledFlag() && ( isSAOEnabled || isDBFEnabled )) |
---|
[56] | 1891 | { |
---|
[608] | 1892 | READ_FLAG( uiCode, "slice_loop_filter_across_slices_enabled_flag"); |
---|
[2] | 1893 | } |
---|
[608] | 1894 | else |
---|
| 1895 | { |
---|
| 1896 | uiCode = rpcSlice->getPPS()->getLoopFilterAcrossSlicesEnabledFlag()?1:0; |
---|
| 1897 | } |
---|
| 1898 | rpcSlice->setLFCrossSliceBoundaryFlag( (uiCode==1)?true:false); |
---|
[56] | 1899 | |
---|
[608] | 1900 | } |
---|
| 1901 | |
---|
| 1902 | UInt *entryPointOffset = NULL; |
---|
| 1903 | UInt numEntryPointOffsets, offsetLenMinus1; |
---|
| 1904 | if( pps->getTilesEnabledFlag() || pps->getEntropyCodingSyncEnabledFlag() ) |
---|
| 1905 | { |
---|
| 1906 | READ_UVLC(numEntryPointOffsets, "num_entry_point_offsets"); rpcSlice->setNumEntryPointOffsets ( numEntryPointOffsets ); |
---|
| 1907 | if (numEntryPointOffsets>0) |
---|
[2] | 1908 | { |
---|
[608] | 1909 | READ_UVLC(offsetLenMinus1, "offset_len_minus1"); |
---|
[2] | 1910 | } |
---|
[608] | 1911 | entryPointOffset = new UInt[numEntryPointOffsets]; |
---|
| 1912 | for (UInt idx=0; idx<numEntryPointOffsets; idx++) |
---|
[2] | 1913 | { |
---|
[608] | 1914 | READ_CODE(offsetLenMinus1+1, uiCode, "entry_point_offset_minus1"); |
---|
| 1915 | entryPointOffset[ idx ] = uiCode + 1; |
---|
[2] | 1916 | } |
---|
| 1917 | } |
---|
[608] | 1918 | else |
---|
[2] | 1919 | { |
---|
[608] | 1920 | rpcSlice->setNumEntryPointOffsets ( 0 ); |
---|
| 1921 | } |
---|
| 1922 | |
---|
| 1923 | if(pps->getSliceHeaderExtensionPresentFlag()) |
---|
| 1924 | { |
---|
| 1925 | READ_UVLC(uiCode,"slice_header_extension_length"); |
---|
| 1926 | #if H_3D |
---|
[56] | 1927 | if( rpcSlice->getSPS()->hasCamParInSliceHeader() ) |
---|
[2] | 1928 | { |
---|
[608] | 1929 | UInt uiViewIndex = rpcSlice->getViewIndex(); |
---|
| 1930 | for( UInt uiBaseIndex = 0; uiBaseIndex < uiViewIndex; uiBaseIndex++ ) |
---|
[2] | 1931 | { |
---|
[608] | 1932 | READ_SVLC( iCode, "cp_scale" ); m_aaiTempScale [ uiBaseIndex ][ uiViewIndex ] = iCode; |
---|
| 1933 | READ_SVLC( iCode, "cp_off" ); m_aaiTempOffset[ uiBaseIndex ][ uiViewIndex ] = iCode; |
---|
| 1934 | READ_SVLC( iCode, "cp_inv_scale_plus_scale" ); m_aaiTempScale [ uiViewIndex ][ uiBaseIndex ] = iCode - m_aaiTempScale [ uiBaseIndex ][ uiViewIndex ]; |
---|
| 1935 | READ_SVLC( iCode, "cp_inv_off_plus_off" ); m_aaiTempOffset[ uiViewIndex ][ uiBaseIndex ] = iCode - m_aaiTempOffset[ uiBaseIndex ][ uiViewIndex ]; |
---|
[2] | 1936 | } |
---|
[608] | 1937 | rpcSlice->setCamparaSlice( m_aaiTempScale, m_aaiTempOffset ); |
---|
[2] | 1938 | } |
---|
[608] | 1939 | |
---|
| 1940 | READ_FLAG(uiCode,"slice_segment_header_extension2_flag"); |
---|
| 1941 | if ( uiCode ) |
---|
| 1942 | { |
---|
| 1943 | READ_UVLC(uiCode,"slice_header_extension2_length"); |
---|
| 1944 | for(Int i=0; i<uiCode; i++) |
---|
| 1945 | { |
---|
| 1946 | UInt ignore; |
---|
| 1947 | READ_CODE(8,ignore,"slice_header_extension2_data_byte"); |
---|
| 1948 | } |
---|
| 1949 | } |
---|
[56] | 1950 | } |
---|
| 1951 | #else |
---|
[608] | 1952 | for(Int i=0; i<uiCode; i++) |
---|
| 1953 | { |
---|
| 1954 | UInt ignore; |
---|
| 1955 | READ_CODE(8,ignore,"slice_header_extension_data_byte"); |
---|
| 1956 | } |
---|
| 1957 | } |
---|
[56] | 1958 | #endif |
---|
[608] | 1959 | m_pcBitstream->readByteAlignment(); |
---|
[56] | 1960 | |
---|
[608] | 1961 | if( pps->getTilesEnabledFlag() || pps->getEntropyCodingSyncEnabledFlag() ) |
---|
[56] | 1962 | { |
---|
[608] | 1963 | Int endOfSliceHeaderLocation = m_pcBitstream->getByteLocation(); |
---|
| 1964 | |
---|
| 1965 | // Adjust endOfSliceHeaderLocation to account for emulation prevention bytes in the slice segment header |
---|
| 1966 | for ( UInt curByteIdx = 0; curByteIdx<m_pcBitstream->numEmulationPreventionBytesRead(); curByteIdx++ ) |
---|
[2] | 1967 | { |
---|
[608] | 1968 | if ( m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) < endOfSliceHeaderLocation ) |
---|
[2] | 1969 | { |
---|
[608] | 1970 | endOfSliceHeaderLocation++; |
---|
[2] | 1971 | } |
---|
[608] | 1972 | } |
---|
[56] | 1973 | |
---|
[608] | 1974 | Int curEntryPointOffset = 0; |
---|
| 1975 | Int prevEntryPointOffset = 0; |
---|
| 1976 | for (UInt idx=0; idx<numEntryPointOffsets; idx++) |
---|
| 1977 | { |
---|
| 1978 | curEntryPointOffset += entryPointOffset[ idx ]; |
---|
| 1979 | |
---|
| 1980 | Int emulationPreventionByteCount = 0; |
---|
| 1981 | for ( UInt curByteIdx = 0; curByteIdx<m_pcBitstream->numEmulationPreventionBytesRead(); curByteIdx++ ) |
---|
[2] | 1982 | { |
---|
[608] | 1983 | if ( m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) >= ( prevEntryPointOffset + endOfSliceHeaderLocation ) && |
---|
| 1984 | m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) < ( curEntryPointOffset + endOfSliceHeaderLocation ) ) |
---|
| 1985 | { |
---|
| 1986 | emulationPreventionByteCount++; |
---|
| 1987 | } |
---|
[2] | 1988 | } |
---|
[56] | 1989 | |
---|
[608] | 1990 | entryPointOffset[ idx ] -= emulationPreventionByteCount; |
---|
| 1991 | prevEntryPointOffset = curEntryPointOffset; |
---|
[2] | 1992 | } |
---|
[56] | 1993 | |
---|
[608] | 1994 | if ( pps->getTilesEnabledFlag() ) |
---|
| 1995 | { |
---|
| 1996 | rpcSlice->setTileLocationCount( numEntryPointOffsets ); |
---|
[56] | 1997 | |
---|
[608] | 1998 | UInt prevPos = 0; |
---|
| 1999 | for (Int idx=0; idx<rpcSlice->getTileLocationCount(); idx++) |
---|
| 2000 | { |
---|
| 2001 | rpcSlice->setTileLocation( idx, prevPos + entryPointOffset [ idx ] ); |
---|
| 2002 | prevPos += entryPointOffset[ idx ]; |
---|
| 2003 | } |
---|
[2] | 2004 | } |
---|
[608] | 2005 | else if ( pps->getEntropyCodingSyncEnabledFlag() ) |
---|
[2] | 2006 | { |
---|
[608] | 2007 | Int numSubstreams = rpcSlice->getNumEntryPointOffsets()+1; |
---|
| 2008 | rpcSlice->allocSubstreamSizes(numSubstreams); |
---|
| 2009 | UInt *pSubstreamSizes = rpcSlice->getSubstreamSizes(); |
---|
| 2010 | for (Int idx=0; idx<numSubstreams-1; idx++) |
---|
[2] | 2011 | { |
---|
[608] | 2012 | if ( idx < numEntryPointOffsets ) |
---|
| 2013 | { |
---|
| 2014 | pSubstreamSizes[ idx ] = ( entryPointOffset[ idx ] << 3 ) ; |
---|
| 2015 | } |
---|
| 2016 | else |
---|
| 2017 | { |
---|
| 2018 | pSubstreamSizes[ idx ] = 0; |
---|
| 2019 | } |
---|
[2] | 2020 | } |
---|
[56] | 2021 | } |
---|
[608] | 2022 | |
---|
| 2023 | if (entryPointOffset) |
---|
| 2024 | { |
---|
| 2025 | delete [] entryPointOffset; |
---|
| 2026 | } |
---|
[56] | 2027 | } |
---|
[2] | 2028 | |
---|
[608] | 2029 | return; |
---|
| 2030 | } |
---|
| 2031 | |
---|
| 2032 | Void TDecCavlc::parsePTL( TComPTL *rpcPTL, Bool profilePresentFlag, Int maxNumSubLayersMinus1 ) |
---|
| 2033 | { |
---|
| 2034 | UInt uiCode; |
---|
| 2035 | if(profilePresentFlag) |
---|
[56] | 2036 | { |
---|
[608] | 2037 | parseProfileTier(rpcPTL->getGeneralPTL()); |
---|
| 2038 | } |
---|
| 2039 | READ_CODE( 8, uiCode, "general_level_idc" ); rpcPTL->getGeneralPTL()->setLevelIdc(uiCode); |
---|
[2] | 2040 | |
---|
[608] | 2041 | for (Int i = 0; i < maxNumSubLayersMinus1; i++) |
---|
| 2042 | { |
---|
| 2043 | #if !H_MV |
---|
| 2044 | if(profilePresentFlag) |
---|
[56] | 2045 | { |
---|
[608] | 2046 | #endif |
---|
| 2047 | READ_FLAG( uiCode, "sub_layer_profile_present_flag[i]" ); rpcPTL->setSubLayerProfilePresentFlag(i, uiCode); |
---|
| 2048 | #if H_MV |
---|
| 2049 | rpcPTL->setSubLayerProfilePresentFlag( i, profilePresentFlag && rpcPTL->getSubLayerProfilePresentFlag(i) ); |
---|
| 2050 | #else |
---|
[56] | 2051 | } |
---|
[608] | 2052 | #endif |
---|
| 2053 | READ_FLAG( uiCode, "sub_layer_level_present_flag[i]" ); rpcPTL->setSubLayerLevelPresentFlag (i, uiCode); |
---|
[56] | 2054 | } |
---|
[608] | 2055 | |
---|
| 2056 | if (maxNumSubLayersMinus1 > 0) |
---|
[56] | 2057 | { |
---|
[608] | 2058 | for (Int i = maxNumSubLayersMinus1; i < 8; i++) |
---|
[56] | 2059 | { |
---|
[608] | 2060 | READ_CODE(2, uiCode, "reserved_zero_2bits"); |
---|
| 2061 | assert(uiCode == 0); |
---|
[2] | 2062 | } |
---|
[56] | 2063 | } |
---|
[608] | 2064 | |
---|
| 2065 | for(Int i = 0; i < maxNumSubLayersMinus1; i++) |
---|
[56] | 2066 | { |
---|
[608] | 2067 | if( profilePresentFlag && rpcPTL->getSubLayerProfilePresentFlag(i) ) |
---|
| 2068 | { |
---|
| 2069 | parseProfileTier(rpcPTL->getSubLayerPTL(i)); |
---|
| 2070 | } |
---|
| 2071 | if(rpcPTL->getSubLayerLevelPresentFlag(i)) |
---|
| 2072 | { |
---|
| 2073 | READ_CODE( 8, uiCode, "sub_layer_level_idc[i]" ); rpcPTL->getSubLayerPTL(i)->setLevelIdc(uiCode); |
---|
| 2074 | } |
---|
[56] | 2075 | } |
---|
[2] | 2076 | } |
---|
| 2077 | |
---|
[608] | 2078 | Void TDecCavlc::parseProfileTier(ProfileTierLevel *ptl) |
---|
[2] | 2079 | { |
---|
[608] | 2080 | UInt uiCode; |
---|
| 2081 | READ_CODE(2 , uiCode, "XXX_profile_space[]"); ptl->setProfileSpace(uiCode); |
---|
| 2082 | READ_FLAG( uiCode, "XXX_tier_flag[]" ); ptl->setTierFlag (uiCode ? 1 : 0); |
---|
| 2083 | READ_CODE(5 , uiCode, "XXX_profile_idc[]" ); ptl->setProfileIdc (uiCode); |
---|
| 2084 | for(Int j = 0; j < 32; j++) |
---|
[2] | 2085 | { |
---|
[608] | 2086 | READ_FLAG( uiCode, "XXX_profile_compatibility_flag[][j]"); ptl->setProfileCompatibilityFlag(j, uiCode ? 1 : 0); |
---|
[2] | 2087 | } |
---|
[608] | 2088 | READ_FLAG(uiCode, "general_progressive_source_flag"); |
---|
| 2089 | ptl->setProgressiveSourceFlag(uiCode ? true : false); |
---|
[2] | 2090 | |
---|
[608] | 2091 | READ_FLAG(uiCode, "general_interlaced_source_flag"); |
---|
| 2092 | ptl->setInterlacedSourceFlag(uiCode ? true : false); |
---|
| 2093 | |
---|
| 2094 | READ_FLAG(uiCode, "general_non_packed_constraint_flag"); |
---|
| 2095 | ptl->setNonPackedConstraintFlag(uiCode ? true : false); |
---|
| 2096 | |
---|
| 2097 | READ_FLAG(uiCode, "general_frame_only_constraint_flag"); |
---|
| 2098 | ptl->setFrameOnlyConstraintFlag(uiCode ? true : false); |
---|
| 2099 | |
---|
| 2100 | READ_CODE(16, uiCode, "XXX_reserved_zero_44bits[0..15]"); |
---|
| 2101 | READ_CODE(16, uiCode, "XXX_reserved_zero_44bits[16..31]"); |
---|
| 2102 | READ_CODE(12, uiCode, "XXX_reserved_zero_44bits[32..43]"); |
---|
[2] | 2103 | } |
---|
[56] | 2104 | |
---|
| 2105 | Void TDecCavlc::parseTerminatingBit( UInt& ruiBit ) |
---|
[2] | 2106 | { |
---|
[56] | 2107 | ruiBit = false; |
---|
| 2108 | Int iBitsLeft = m_pcBitstream->getNumBitsLeft(); |
---|
| 2109 | if(iBitsLeft <= 8) |
---|
[2] | 2110 | { |
---|
[56] | 2111 | UInt uiPeekValue = m_pcBitstream->peekBits(iBitsLeft); |
---|
| 2112 | if (uiPeekValue == (1<<(iBitsLeft-1))) |
---|
| 2113 | { |
---|
| 2114 | ruiBit = true; |
---|
| 2115 | } |
---|
[2] | 2116 | } |
---|
| 2117 | } |
---|
| 2118 | |
---|
[608] | 2119 | Void TDecCavlc::parseSkipFlag( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
[2] | 2120 | { |
---|
[56] | 2121 | assert(0); |
---|
| 2122 | } |
---|
[2] | 2123 | |
---|
[608] | 2124 | Void TDecCavlc::parseCUTransquantBypassFlag( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
[189] | 2125 | { |
---|
| 2126 | assert(0); |
---|
| 2127 | } |
---|
| 2128 | |
---|
[608] | 2129 | Void TDecCavlc::parseMVPIdx( Int& /*riMVPIdx*/ ) |
---|
[56] | 2130 | { |
---|
| 2131 | assert(0); |
---|
| 2132 | } |
---|
[2] | 2133 | |
---|
[608] | 2134 | Void TDecCavlc::parseSplitFlag ( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
[56] | 2135 | { |
---|
| 2136 | assert(0); |
---|
| 2137 | } |
---|
[2] | 2138 | |
---|
[608] | 2139 | Void TDecCavlc::parsePartSize( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
[56] | 2140 | { |
---|
| 2141 | assert(0); |
---|
| 2142 | } |
---|
[2] | 2143 | |
---|
[608] | 2144 | Void TDecCavlc::parsePredMode( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
[56] | 2145 | { |
---|
| 2146 | assert(0); |
---|
| 2147 | } |
---|
[2] | 2148 | |
---|
[56] | 2149 | /** Parse I_PCM information. |
---|
[608] | 2150 | * \param pcCU pointer to CU |
---|
| 2151 | * \param uiAbsPartIdx CU index |
---|
| 2152 | * \param uiDepth CU depth |
---|
| 2153 | * \returns Void |
---|
| 2154 | * |
---|
| 2155 | * If I_PCM flag indicates that the CU is I_PCM, parse its PCM alignment bits and codes. |
---|
| 2156 | */ |
---|
| 2157 | Void TDecCavlc::parseIPCMInfo( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
[56] | 2158 | { |
---|
| 2159 | assert(0); |
---|
[2] | 2160 | } |
---|
| 2161 | |
---|
[608] | 2162 | Void TDecCavlc::parseIntraDirLumaAng ( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
[56] | 2163 | { |
---|
| 2164 | assert(0); |
---|
[2] | 2165 | } |
---|
| 2166 | |
---|
[608] | 2167 | Void TDecCavlc::parseIntraDirChroma( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
[2] | 2168 | { |
---|
[56] | 2169 | assert(0); |
---|
[2] | 2170 | } |
---|
| 2171 | |
---|
[608] | 2172 | Void TDecCavlc::parseInterDir( TComDataCU* /*pcCU*/, UInt& /*ruiInterDir*/, UInt /*uiAbsPartIdx*/ ) |
---|
[2] | 2173 | { |
---|
[56] | 2174 | assert(0); |
---|
[2] | 2175 | } |
---|
| 2176 | |
---|
[608] | 2177 | Void TDecCavlc::parseRefFrmIdx( TComDataCU* /*pcCU*/, Int& /*riRefFrmIdx*/, RefPicList /*eRefList*/ ) |
---|
[2] | 2178 | { |
---|
[56] | 2179 | assert(0); |
---|
[2] | 2180 | } |
---|
| 2181 | |
---|
[608] | 2182 | Void TDecCavlc::parseMvd( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiPartIdx*/, UInt /*uiDepth*/, RefPicList /*eRefList*/ ) |
---|
[2] | 2183 | { |
---|
[56] | 2184 | assert(0); |
---|
[2] | 2185 | } |
---|
| 2186 | |
---|
[56] | 2187 | Void TDecCavlc::parseDeltaQP( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
[2] | 2188 | { |
---|
[56] | 2189 | Int qp; |
---|
| 2190 | Int iDQp; |
---|
[608] | 2191 | |
---|
[56] | 2192 | xReadSvlc( iDQp ); |
---|
[2] | 2193 | |
---|
[56] | 2194 | Int qpBdOffsetY = pcCU->getSlice()->getSPS()->getQpBDOffsetY(); |
---|
| 2195 | qp = (((Int) pcCU->getRefQP( uiAbsPartIdx ) + iDQp + 52 + 2*qpBdOffsetY )%(52+ qpBdOffsetY)) - qpBdOffsetY; |
---|
| 2196 | |
---|
[608] | 2197 | UInt uiAbsQpCUPartIdx = (uiAbsPartIdx>>((g_uiMaxCUDepth - pcCU->getSlice()->getPPS()->getMaxCuDQPDepth())<<1))<<((g_uiMaxCUDepth - pcCU->getSlice()->getPPS()->getMaxCuDQPDepth())<<1) ; |
---|
[56] | 2198 | UInt uiQpCUDepth = min(uiDepth,pcCU->getSlice()->getPPS()->getMaxCuDQPDepth()) ; |
---|
| 2199 | |
---|
| 2200 | pcCU->setQPSubParts( qp, uiAbsQpCUPartIdx, uiQpCUDepth ); |
---|
[2] | 2201 | } |
---|
| 2202 | |
---|
[608] | 2203 | Void TDecCavlc::parseCoeffNxN( TComDataCU* /*pcCU*/, TCoeff* /*pcCoef*/, UInt /*uiAbsPartIdx*/, UInt /*uiWidth*/, UInt /*uiHeight*/, UInt /*uiDepth*/, TextType /*eTType*/ ) |
---|
[2] | 2204 | { |
---|
[56] | 2205 | assert(0); |
---|
[2] | 2206 | } |
---|
| 2207 | |
---|
[608] | 2208 | Void TDecCavlc::parseTransformSubdivFlag( UInt& /*ruiSubdivFlag*/, UInt /*uiLog2TransformBlockSize*/ ) |
---|
[2] | 2209 | { |
---|
[56] | 2210 | assert(0); |
---|
[2] | 2211 | } |
---|
| 2212 | |
---|
[608] | 2213 | Void TDecCavlc::parseQtCbf( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, TextType /*eType*/, UInt /*uiTrDepth*/, UInt /*uiDepth*/ ) |
---|
[2] | 2214 | { |
---|
[56] | 2215 | assert(0); |
---|
[2] | 2216 | } |
---|
| 2217 | |
---|
[608] | 2218 | Void TDecCavlc::parseQtRootCbf( UInt /*uiAbsPartIdx*/, UInt& /*uiQtRootCbf*/ ) |
---|
[2] | 2219 | { |
---|
[56] | 2220 | assert(0); |
---|
[2] | 2221 | } |
---|
| 2222 | |
---|
[608] | 2223 | Void TDecCavlc::parseTransformSkipFlags (TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*width*/, UInt /*height*/, UInt /*uiDepth*/, TextType /*eTType*/) |
---|
[2] | 2224 | { |
---|
[56] | 2225 | assert(0); |
---|
[2] | 2226 | } |
---|
| 2227 | |
---|
[608] | 2228 | Void TDecCavlc::parseMergeFlag ( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/, UInt /*uiPUIdx*/ ) |
---|
[2] | 2229 | { |
---|
[56] | 2230 | assert(0); |
---|
[2] | 2231 | } |
---|
| 2232 | |
---|
[608] | 2233 | Void TDecCavlc::parseMergeIndex ( TComDataCU* /*pcCU*/, UInt& /*ruiMergeIndex*/ ) |
---|
[2] | 2234 | { |
---|
[56] | 2235 | assert(0); |
---|
[2] | 2236 | } |
---|
[608] | 2237 | |
---|
| 2238 | #if H_3D_ARP |
---|
[443] | 2239 | Void TDecCavlc::parseARPW( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
| 2240 | { |
---|
[608] | 2241 | assert(0); |
---|
[443] | 2242 | } |
---|
| 2243 | #endif |
---|
[608] | 2244 | #if H_3D_IC |
---|
| 2245 | Void TDecCavlc::parseICFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
[189] | 2246 | { |
---|
| 2247 | assert(0); |
---|
| 2248 | } |
---|
[608] | 2249 | #endif |
---|
[655] | 2250 | #if H_3D_INTER_SDC |
---|
[608] | 2251 | Void TDecCavlc::parseInterSDCFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
[189] | 2252 | { |
---|
| 2253 | assert(0); |
---|
| 2254 | } |
---|
[608] | 2255 | |
---|
| 2256 | Void TDecCavlc::parseInterSDCResidualData ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPart ) |
---|
[189] | 2257 | { |
---|
| 2258 | assert(0); |
---|
| 2259 | } |
---|
| 2260 | #endif |
---|
[2] | 2261 | // ==================================================================================================================== |
---|
| 2262 | // Protected member functions |
---|
| 2263 | // ==================================================================================================================== |
---|
| 2264 | |
---|
[56] | 2265 | /** parse explicit wp tables |
---|
[608] | 2266 | * \param TComSlice* pcSlice |
---|
| 2267 | * \returns Void |
---|
| 2268 | */ |
---|
[56] | 2269 | Void TDecCavlc::xParsePredWeightTable( TComSlice* pcSlice ) |
---|
[2] | 2270 | { |
---|
[56] | 2271 | wpScalingParam *wp; |
---|
| 2272 | Bool bChroma = true; // color always present in HEVC ? |
---|
| 2273 | SliceType eSliceType = pcSlice->getSliceType(); |
---|
| 2274 | Int iNbRef = (eSliceType == B_SLICE ) ? (2) : (1); |
---|
| 2275 | UInt uiLog2WeightDenomLuma, uiLog2WeightDenomChroma; |
---|
[608] | 2276 | UInt uiTotalSignalledWeightFlags = 0; |
---|
| 2277 | |
---|
| 2278 | Int iDeltaDenom; |
---|
| 2279 | // decode delta_luma_log2_weight_denom : |
---|
| 2280 | READ_UVLC( uiLog2WeightDenomLuma, "luma_log2_weight_denom" ); // ue(v): luma_log2_weight_denom |
---|
| 2281 | assert( uiLog2WeightDenomLuma <= 7 ); |
---|
| 2282 | if( bChroma ) |
---|
| 2283 | { |
---|
| 2284 | READ_SVLC( iDeltaDenom, "delta_chroma_log2_weight_denom" ); // se(v): delta_chroma_log2_weight_denom |
---|
| 2285 | assert((iDeltaDenom + (Int)uiLog2WeightDenomLuma)>=0); |
---|
| 2286 | assert((iDeltaDenom + (Int)uiLog2WeightDenomLuma)<=7); |
---|
| 2287 | uiLog2WeightDenomChroma = (UInt)(iDeltaDenom + uiLog2WeightDenomLuma); |
---|
| 2288 | } |
---|
[2] | 2289 | |
---|
[608] | 2290 | for ( Int iNumRef=0 ; iNumRef<iNbRef ; iNumRef++ ) |
---|
[2] | 2291 | { |
---|
[608] | 2292 | RefPicList eRefPicList = ( iNumRef ? REF_PIC_LIST_1 : REF_PIC_LIST_0 ); |
---|
| 2293 | for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ ) |
---|
[2] | 2294 | { |
---|
[608] | 2295 | pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); |
---|
| 2296 | |
---|
| 2297 | wp[0].uiLog2WeightDenom = uiLog2WeightDenomLuma; |
---|
| 2298 | wp[1].uiLog2WeightDenom = uiLog2WeightDenomChroma; |
---|
| 2299 | wp[2].uiLog2WeightDenom = uiLog2WeightDenomChroma; |
---|
| 2300 | |
---|
| 2301 | UInt uiCode; |
---|
| 2302 | READ_FLAG( uiCode, "luma_weight_lX_flag" ); // u(1): luma_weight_l0_flag |
---|
| 2303 | wp[0].bPresentFlag = ( uiCode == 1 ); |
---|
| 2304 | uiTotalSignalledWeightFlags += wp[0].bPresentFlag; |
---|
[56] | 2305 | } |
---|
[608] | 2306 | if ( bChroma ) |
---|
[56] | 2307 | { |
---|
[608] | 2308 | UInt uiCode; |
---|
[56] | 2309 | for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ ) |
---|
[2] | 2310 | { |
---|
[56] | 2311 | pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); |
---|
[608] | 2312 | READ_FLAG( uiCode, "chroma_weight_lX_flag" ); // u(1): chroma_weight_l0_flag |
---|
| 2313 | wp[1].bPresentFlag = ( uiCode == 1 ); |
---|
| 2314 | wp[2].bPresentFlag = ( uiCode == 1 ); |
---|
| 2315 | uiTotalSignalledWeightFlags += 2*wp[1].bPresentFlag; |
---|
[2] | 2316 | } |
---|
| 2317 | } |
---|
[608] | 2318 | for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ ) |
---|
[2] | 2319 | { |
---|
[608] | 2320 | pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); |
---|
[56] | 2321 | if ( wp[0].bPresentFlag ) |
---|
[2] | 2322 | { |
---|
[56] | 2323 | Int iDeltaWeight; |
---|
[608] | 2324 | READ_SVLC( iDeltaWeight, "delta_luma_weight_lX" ); // se(v): delta_luma_weight_l0[i] |
---|
| 2325 | assert( iDeltaWeight >= -128 ); |
---|
| 2326 | assert( iDeltaWeight <= 127 ); |
---|
[56] | 2327 | wp[0].iWeight = (iDeltaWeight + (1<<wp[0].uiLog2WeightDenom)); |
---|
[608] | 2328 | READ_SVLC( wp[0].iOffset, "luma_offset_lX" ); // se(v): luma_offset_l0[i] |
---|
| 2329 | assert( wp[0].iOffset >= -128 ); |
---|
| 2330 | assert( wp[0].iOffset <= 127 ); |
---|
[2] | 2331 | } |
---|
[56] | 2332 | else |
---|
[2] | 2333 | { |
---|
[56] | 2334 | wp[0].iWeight = (1 << wp[0].uiLog2WeightDenom); |
---|
| 2335 | wp[0].iOffset = 0; |
---|
[2] | 2336 | } |
---|
[56] | 2337 | if ( bChroma ) |
---|
[2] | 2338 | { |
---|
[56] | 2339 | if ( wp[1].bPresentFlag ) |
---|
[2] | 2340 | { |
---|
[56] | 2341 | for ( Int j=1 ; j<3 ; j++ ) |
---|
[2] | 2342 | { |
---|
[56] | 2343 | Int iDeltaWeight; |
---|
[608] | 2344 | READ_SVLC( iDeltaWeight, "delta_chroma_weight_lX" ); // se(v): chroma_weight_l0[i][j] |
---|
| 2345 | assert( iDeltaWeight >= -128 ); |
---|
| 2346 | assert( iDeltaWeight <= 127 ); |
---|
[56] | 2347 | wp[j].iWeight = (iDeltaWeight + (1<<wp[1].uiLog2WeightDenom)); |
---|
| 2348 | |
---|
| 2349 | Int iDeltaChroma; |
---|
[608] | 2350 | READ_SVLC( iDeltaChroma, "delta_chroma_offset_lX" ); // se(v): delta_chroma_offset_l0[i][j] |
---|
| 2351 | assert( iDeltaChroma >= -512 ); |
---|
| 2352 | assert( iDeltaChroma <= 511 ); |
---|
| 2353 | Int pred = ( 128 - ( ( 128*wp[j].iWeight)>>(wp[j].uiLog2WeightDenom) ) ); |
---|
| 2354 | wp[j].iOffset = Clip3(-128, 127, (iDeltaChroma + pred) ); |
---|
[2] | 2355 | } |
---|
| 2356 | } |
---|
[56] | 2357 | else |
---|
[2] | 2358 | { |
---|
[56] | 2359 | for ( Int j=1 ; j<3 ; j++ ) |
---|
[2] | 2360 | { |
---|
[56] | 2361 | wp[j].iWeight = (1 << wp[j].uiLog2WeightDenom); |
---|
| 2362 | wp[j].iOffset = 0; |
---|
[2] | 2363 | } |
---|
| 2364 | } |
---|
| 2365 | } |
---|
| 2366 | } |
---|
| 2367 | |
---|
[608] | 2368 | for ( Int iRefIdx=pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx<MAX_NUM_REF ; iRefIdx++ ) |
---|
[2] | 2369 | { |
---|
[608] | 2370 | pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); |
---|
[2] | 2371 | |
---|
[56] | 2372 | wp[0].bPresentFlag = false; |
---|
| 2373 | wp[1].bPresentFlag = false; |
---|
| 2374 | wp[2].bPresentFlag = false; |
---|
[2] | 2375 | } |
---|
| 2376 | } |
---|
[608] | 2377 | assert(uiTotalSignalledWeightFlags<=24); |
---|
[2] | 2378 | } |
---|
| 2379 | |
---|
[56] | 2380 | /** decode quantization matrix |
---|
[608] | 2381 | * \param scalingList quantization matrix information |
---|
| 2382 | */ |
---|
[56] | 2383 | Void TDecCavlc::parseScalingList(TComScalingList* scalingList) |
---|
[2] | 2384 | { |
---|
[56] | 2385 | UInt code, sizeId, listId; |
---|
| 2386 | Bool scalingListPredModeFlag; |
---|
[608] | 2387 | //for each size |
---|
| 2388 | for(sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
[2] | 2389 | { |
---|
[608] | 2390 | for(listId = 0; listId < g_scalingListNum[sizeId]; listId++) |
---|
[2] | 2391 | { |
---|
[608] | 2392 | READ_FLAG( code, "scaling_list_pred_mode_flag"); |
---|
| 2393 | scalingListPredModeFlag = (code) ? true : false; |
---|
| 2394 | if(!scalingListPredModeFlag) //Copy Mode |
---|
[2] | 2395 | { |
---|
[608] | 2396 | READ_UVLC( code, "scaling_list_pred_matrix_id_delta"); |
---|
| 2397 | scalingList->setRefMatrixId (sizeId,listId,(UInt)((Int)(listId)-(code))); |
---|
| 2398 | if( sizeId > SCALING_LIST_8x8 ) |
---|
[2] | 2399 | { |
---|
[608] | 2400 | scalingList->setScalingListDC(sizeId,listId,((listId == scalingList->getRefMatrixId (sizeId,listId))? 16 :scalingList->getScalingListDC(sizeId, scalingList->getRefMatrixId (sizeId,listId)))); |
---|
[2] | 2401 | } |
---|
[608] | 2402 | scalingList->processRefMatrix( sizeId, listId, scalingList->getRefMatrixId (sizeId,listId)); |
---|
| 2403 | |
---|
[2] | 2404 | } |
---|
[608] | 2405 | else //DPCM Mode |
---|
| 2406 | { |
---|
| 2407 | xDecodeScalingList(scalingList, sizeId, listId); |
---|
| 2408 | } |
---|
[2] | 2409 | } |
---|
| 2410 | } |
---|
| 2411 | |
---|
| 2412 | return; |
---|
| 2413 | } |
---|
[56] | 2414 | /** decode DPCM |
---|
[608] | 2415 | * \param scalingList quantization matrix information |
---|
| 2416 | * \param sizeId size index |
---|
| 2417 | * \param listId list index |
---|
| 2418 | */ |
---|
[56] | 2419 | Void TDecCavlc::xDecodeScalingList(TComScalingList *scalingList, UInt sizeId, UInt listId) |
---|
[2] | 2420 | { |
---|
[56] | 2421 | Int i,coefNum = min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId]); |
---|
| 2422 | Int data; |
---|
| 2423 | Int scalingListDcCoefMinus8 = 0; |
---|
| 2424 | Int nextCoef = SCALING_LIST_START_VALUE; |
---|
[608] | 2425 | UInt* scan = (sizeId == 0) ? g_auiSigLastScan [ SCAN_DIAG ] [ 1 ] : g_sigLastScanCG32x32; |
---|
[56] | 2426 | Int *dst = scalingList->getScalingListAddress(sizeId, listId); |
---|
[2] | 2427 | |
---|
[56] | 2428 | if( sizeId > SCALING_LIST_8x8 ) |
---|
[2] | 2429 | { |
---|
[56] | 2430 | READ_SVLC( scalingListDcCoefMinus8, "scaling_list_dc_coef_minus8"); |
---|
| 2431 | scalingList->setScalingListDC(sizeId,listId,scalingListDcCoefMinus8 + 8); |
---|
[608] | 2432 | nextCoef = scalingList->getScalingListDC(sizeId,listId); |
---|
[2] | 2433 | } |
---|
| 2434 | |
---|
[608] | 2435 | for(i = 0; i < coefNum; i++) |
---|
[2] | 2436 | { |
---|
[608] | 2437 | READ_SVLC( data, "scaling_list_delta_coef"); |
---|
| 2438 | nextCoef = (nextCoef + data + 256 ) % 256; |
---|
| 2439 | dst[scan[i]] = nextCoef; |
---|
[2] | 2440 | } |
---|
| 2441 | } |
---|
| 2442 | |
---|
[56] | 2443 | Bool TDecCavlc::xMoreRbspData() |
---|
| 2444 | { |
---|
| 2445 | Int bitsLeft = m_pcBitstream->getNumBitsLeft(); |
---|
[2] | 2446 | |
---|
[56] | 2447 | // if there are more than 8 bits, it cannot be rbsp_trailing_bits |
---|
| 2448 | if (bitsLeft > 8) |
---|
[2] | 2449 | { |
---|
[56] | 2450 | return true; |
---|
| 2451 | } |
---|
[2] | 2452 | |
---|
[56] | 2453 | UChar lastByte = m_pcBitstream->peekBits(bitsLeft); |
---|
| 2454 | Int cnt = bitsLeft; |
---|
[2] | 2455 | |
---|
[56] | 2456 | // remove trailing bits equal to zero |
---|
| 2457 | while ((cnt>0) && ((lastByte & 1) == 0)) |
---|
| 2458 | { |
---|
| 2459 | lastByte >>= 1; |
---|
| 2460 | cnt--; |
---|
| 2461 | } |
---|
| 2462 | // remove bit equal to one |
---|
| 2463 | cnt--; |
---|
[2] | 2464 | |
---|
[56] | 2465 | // we should not have a negative number of bits |
---|
| 2466 | assert (cnt>=0); |
---|
[2] | 2467 | |
---|
[56] | 2468 | // we have more data, if cnt is not zero |
---|
| 2469 | return (cnt>0); |
---|
| 2470 | } |
---|
[2] | 2471 | |
---|
[56] | 2472 | //! \} |
---|
[608] | 2473 | |
---|