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