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