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