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