1 | /* The copyright in this software is being made available under the BSD |
---|
2 | * License, included below. This software may be subject to other third party |
---|
3 | * and contributor rights, including patent rights, and no such rights are |
---|
4 | * granted under this license. |
---|
5 | * |
---|
6 | * Copyright (c) 2010-2014, ITU/ISO/IEC |
---|
7 | * All rights reserved. |
---|
8 | * |
---|
9 | * Redistribution and use in source and binary forms, with or without |
---|
10 | * modification, are permitted provided that the following conditions are met: |
---|
11 | * |
---|
12 | * * Redistributions of source code must retain the above copyright notice, |
---|
13 | * this list of conditions and the following disclaimer. |
---|
14 | * * Redistributions in binary form must reproduce the above copyright notice, |
---|
15 | * this list of conditions and the following disclaimer in the documentation |
---|
16 | * and/or other materials provided with the distribution. |
---|
17 | * * Neither the name of the ITU/ISO/IEC nor the names of its contributors may |
---|
18 | * be used to endorse or promote products derived from this software without |
---|
19 | * specific prior written permission. |
---|
20 | * |
---|
21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
---|
22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
---|
23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
---|
24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS |
---|
25 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
---|
26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
---|
27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
---|
28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
---|
29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
---|
30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
---|
31 | * THE POSSIBILITY OF SUCH DAMAGE. |
---|
32 | */ |
---|
33 | |
---|
34 | /** \file TDecCAVLC.cpp |
---|
35 | \brief CAVLC decoder class |
---|
36 | */ |
---|
37 | |
---|
38 | #include "TDecCAVLC.h" |
---|
39 | #include "SEIread.h" |
---|
40 | #include "TDecSlice.h" |
---|
41 | #include "TLibCommon/TComChromaFormat.h" |
---|
42 | #if RExt__DECODER_DEBUG_BIT_STATISTICS |
---|
43 | #include "TLibCommon/TComCodingStatistics.h" |
---|
44 | #endif |
---|
45 | #if Q0048_CGS_3D_ASYMLUT |
---|
46 | #include "../TLibCommon/TCom3DAsymLUT.h" |
---|
47 | #endif |
---|
48 | |
---|
49 | //! \ingroup TLibDecoder |
---|
50 | //! \{ |
---|
51 | |
---|
52 | #if ENC_DEC_TRACE |
---|
53 | |
---|
54 | Void xTraceSPSHeader (TComSPS *pSPS) |
---|
55 | { |
---|
56 | fprintf( g_hTrace, "=========== Sequence Parameter Set ID: %d ===========\n", pSPS->getSPSId() ); |
---|
57 | } |
---|
58 | |
---|
59 | Void xTracePPSHeader (TComPPS *pPPS) |
---|
60 | { |
---|
61 | fprintf( g_hTrace, "=========== Picture Parameter Set ID: %d ===========\n", pPPS->getPPSId() ); |
---|
62 | } |
---|
63 | |
---|
64 | Void xTraceSliceHeader (TComSlice *pSlice) |
---|
65 | { |
---|
66 | fprintf( g_hTrace, "=========== Slice ===========\n"); |
---|
67 | } |
---|
68 | |
---|
69 | #endif |
---|
70 | |
---|
71 | // ==================================================================================================================== |
---|
72 | // Constructor / destructor / create / destroy |
---|
73 | // ==================================================================================================================== |
---|
74 | |
---|
75 | TDecCavlc::TDecCavlc() |
---|
76 | { |
---|
77 | } |
---|
78 | |
---|
79 | TDecCavlc::~TDecCavlc() |
---|
80 | { |
---|
81 | |
---|
82 | } |
---|
83 | |
---|
84 | // ==================================================================================================================== |
---|
85 | // Public member functions |
---|
86 | // ==================================================================================================================== |
---|
87 | |
---|
88 | Void TDecCavlc::parseShortTermRefPicSet( TComSPS* sps, TComReferencePictureSet* rps, Int idx ) |
---|
89 | { |
---|
90 | UInt code; |
---|
91 | UInt interRPSPred; |
---|
92 | if (idx > 0) |
---|
93 | { |
---|
94 | READ_FLAG(interRPSPred, "inter_ref_pic_set_prediction_flag"); rps->setInterRPSPrediction(interRPSPred); |
---|
95 | } |
---|
96 | else |
---|
97 | { |
---|
98 | interRPSPred = false; |
---|
99 | rps->setInterRPSPrediction(false); |
---|
100 | } |
---|
101 | |
---|
102 | if (interRPSPred) |
---|
103 | { |
---|
104 | UInt bit; |
---|
105 | if(idx == sps->getRPSList()->getNumberOfReferencePictureSets()) |
---|
106 | { |
---|
107 | READ_UVLC(code, "delta_idx_minus1" ); // delta index of the Reference Picture Set used for prediction minus 1 |
---|
108 | } |
---|
109 | else |
---|
110 | { |
---|
111 | code = 0; |
---|
112 | } |
---|
113 | 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 |
---|
114 | Int rIdx = idx - 1 - code; |
---|
115 | 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 |
---|
116 | TComReferencePictureSet* rpsRef = sps->getRPSList()->getReferencePictureSet(rIdx); |
---|
117 | Int k = 0, k0 = 0, k1 = 0; |
---|
118 | READ_CODE(1, bit, "delta_rps_sign"); // delta_RPS_sign |
---|
119 | READ_UVLC(code, "abs_delta_rps_minus1"); // absolute delta RPS minus 1 |
---|
120 | Int deltaRPS = (1 - 2 * bit) * (code + 1); // delta_RPS |
---|
121 | for(Int j=0 ; j <= rpsRef->getNumberOfPictures(); j++) |
---|
122 | { |
---|
123 | READ_CODE(1, bit, "used_by_curr_pic_flag" ); //first bit is "1" if Idc is 1 |
---|
124 | Int refIdc = bit; |
---|
125 | if (refIdc == 0) |
---|
126 | { |
---|
127 | READ_CODE(1, bit, "use_delta_flag" ); //second bit is "1" if Idc is 2, "0" otherwise. |
---|
128 | refIdc = bit<<1; //second bit is "1" if refIdc is 2, "0" if refIdc = 0. |
---|
129 | } |
---|
130 | if (refIdc == 1 || refIdc == 2) |
---|
131 | { |
---|
132 | Int deltaPOC = deltaRPS + ((j < rpsRef->getNumberOfPictures())? rpsRef->getDeltaPOC(j) : 0); |
---|
133 | rps->setDeltaPOC(k, deltaPOC); |
---|
134 | rps->setUsed(k, (refIdc == 1)); |
---|
135 | |
---|
136 | if (deltaPOC < 0) |
---|
137 | { |
---|
138 | k0++; |
---|
139 | } |
---|
140 | else |
---|
141 | { |
---|
142 | k1++; |
---|
143 | } |
---|
144 | k++; |
---|
145 | } |
---|
146 | rps->setRefIdc(j,refIdc); |
---|
147 | } |
---|
148 | rps->setNumRefIdc(rpsRef->getNumberOfPictures()+1); |
---|
149 | rps->setNumberOfPictures(k); |
---|
150 | rps->setNumberOfNegativePictures(k0); |
---|
151 | rps->setNumberOfPositivePictures(k1); |
---|
152 | rps->sortDeltaPOC(); |
---|
153 | } |
---|
154 | else |
---|
155 | { |
---|
156 | READ_UVLC(code, "num_negative_pics"); rps->setNumberOfNegativePictures(code); |
---|
157 | READ_UVLC(code, "num_positive_pics"); rps->setNumberOfPositivePictures(code); |
---|
158 | Int prev = 0; |
---|
159 | Int poc; |
---|
160 | for(Int j=0 ; j < rps->getNumberOfNegativePictures(); j++) |
---|
161 | { |
---|
162 | READ_UVLC(code, "delta_poc_s0_minus1"); |
---|
163 | poc = prev-code-1; |
---|
164 | prev = poc; |
---|
165 | rps->setDeltaPOC(j,poc); |
---|
166 | READ_FLAG(code, "used_by_curr_pic_s0_flag"); rps->setUsed(j,code); |
---|
167 | } |
---|
168 | prev = 0; |
---|
169 | for(Int j=rps->getNumberOfNegativePictures(); j < rps->getNumberOfNegativePictures()+rps->getNumberOfPositivePictures(); j++) |
---|
170 | { |
---|
171 | READ_UVLC(code, "delta_poc_s1_minus1"); |
---|
172 | poc = prev+code+1; |
---|
173 | prev = poc; |
---|
174 | rps->setDeltaPOC(j,poc); |
---|
175 | READ_FLAG(code, "used_by_curr_pic_s1_flag"); rps->setUsed(j,code); |
---|
176 | } |
---|
177 | rps->setNumberOfPictures(rps->getNumberOfNegativePictures()+rps->getNumberOfPositivePictures()); |
---|
178 | } |
---|
179 | #if PRINT_RPS_INFO |
---|
180 | rps->printDeltaPOC(); |
---|
181 | #endif |
---|
182 | } |
---|
183 | |
---|
184 | #if Q0048_CGS_3D_ASYMLUT |
---|
185 | Void TDecCavlc::parsePPS(TComPPS* pcPPS, TCom3DAsymLUT * pc3DAsymLUT, Int nLayerID) |
---|
186 | #else |
---|
187 | Void TDecCavlc::parsePPS(TComPPS* pcPPS) |
---|
188 | #endif |
---|
189 | |
---|
190 | { |
---|
191 | #if ENC_DEC_TRACE |
---|
192 | xTracePPSHeader (pcPPS); |
---|
193 | #endif |
---|
194 | UInt uiCode; |
---|
195 | |
---|
196 | Int iCode; |
---|
197 | |
---|
198 | READ_UVLC( uiCode, "pps_pic_parameter_set_id"); |
---|
199 | assert(uiCode <= 63); |
---|
200 | pcPPS->setPPSId (uiCode); |
---|
201 | |
---|
202 | READ_UVLC( uiCode, "pps_seq_parameter_set_id"); |
---|
203 | assert(uiCode <= 15); |
---|
204 | pcPPS->setSPSId (uiCode); |
---|
205 | |
---|
206 | READ_FLAG( uiCode, "dependent_slice_segments_enabled_flag" ); pcPPS->setDependentSliceSegmentsEnabledFlag ( uiCode == 1 ); |
---|
207 | |
---|
208 | READ_FLAG( uiCode, "output_flag_present_flag" ); pcPPS->setOutputFlagPresentFlag( uiCode==1 ); |
---|
209 | |
---|
210 | READ_CODE(3, uiCode, "num_extra_slice_header_bits"); pcPPS->setNumExtraSliceHeaderBits(uiCode); |
---|
211 | |
---|
212 | READ_FLAG ( uiCode, "sign_data_hiding_flag" ); pcPPS->setSignHideFlag( uiCode ); |
---|
213 | |
---|
214 | READ_FLAG( uiCode, "cabac_init_present_flag" ); pcPPS->setCabacInitPresentFlag( uiCode ? true : false ); |
---|
215 | |
---|
216 | READ_UVLC(uiCode, "num_ref_idx_l0_default_active_minus1"); |
---|
217 | assert(uiCode <= 14); |
---|
218 | pcPPS->setNumRefIdxL0DefaultActive(uiCode+1); |
---|
219 | |
---|
220 | READ_UVLC(uiCode, "num_ref_idx_l1_default_active_minus1"); |
---|
221 | assert(uiCode <= 14); |
---|
222 | pcPPS->setNumRefIdxL1DefaultActive(uiCode+1); |
---|
223 | |
---|
224 | READ_SVLC(iCode, "init_qp_minus26" ); pcPPS->setPicInitQPMinus26(iCode); |
---|
225 | READ_FLAG( uiCode, "constrained_intra_pred_flag" ); pcPPS->setConstrainedIntraPred( uiCode ? true : false ); |
---|
226 | READ_FLAG( uiCode, "transform_skip_enabled_flag" ); |
---|
227 | pcPPS->setUseTransformSkip ( uiCode ? true : false ); |
---|
228 | |
---|
229 | READ_FLAG( uiCode, "cu_qp_delta_enabled_flag" ); pcPPS->setUseDQP( uiCode ? true : false ); |
---|
230 | if( pcPPS->getUseDQP() ) |
---|
231 | { |
---|
232 | READ_UVLC( uiCode, "diff_cu_qp_delta_depth" ); |
---|
233 | pcPPS->setMaxCuDQPDepth( uiCode ); |
---|
234 | } |
---|
235 | else |
---|
236 | { |
---|
237 | pcPPS->setMaxCuDQPDepth( 0 ); |
---|
238 | } |
---|
239 | READ_SVLC( iCode, "pps_cb_qp_offset"); |
---|
240 | pcPPS->setQpOffset(COMPONENT_Cb, iCode); |
---|
241 | assert( pcPPS->getQpOffset(COMPONENT_Cb) >= -12 ); |
---|
242 | assert( pcPPS->getQpOffset(COMPONENT_Cb) <= 12 ); |
---|
243 | |
---|
244 | READ_SVLC( iCode, "pps_cr_qp_offset"); |
---|
245 | pcPPS->setQpOffset(COMPONENT_Cr, iCode); |
---|
246 | assert( pcPPS->getQpOffset(COMPONENT_Cr) >= -12 ); |
---|
247 | assert( pcPPS->getQpOffset(COMPONENT_Cr) <= 12 ); |
---|
248 | |
---|
249 | assert(MAX_NUM_COMPONENT<=3); |
---|
250 | |
---|
251 | READ_FLAG( uiCode, "pps_slice_chroma_qp_offsets_present_flag" ); |
---|
252 | pcPPS->setSliceChromaQpFlag( uiCode ? true : false ); |
---|
253 | |
---|
254 | READ_FLAG( uiCode, "weighted_pred_flag" ); // Use of Weighting Prediction (P_SLICE) |
---|
255 | pcPPS->setUseWP( uiCode==1 ); |
---|
256 | READ_FLAG( uiCode, "weighted_bipred_flag" ); // Use of Bi-Directional Weighting Prediction (B_SLICE) |
---|
257 | pcPPS->setWPBiPred( uiCode==1 ); |
---|
258 | |
---|
259 | READ_FLAG( uiCode, "transquant_bypass_enable_flag"); |
---|
260 | pcPPS->setTransquantBypassEnableFlag(uiCode ? true : false); |
---|
261 | READ_FLAG( uiCode, "tiles_enabled_flag" ); pcPPS->setTilesEnabledFlag ( uiCode == 1 ); |
---|
262 | READ_FLAG( uiCode, "entropy_coding_sync_enabled_flag" ); pcPPS->setEntropyCodingSyncEnabledFlag( uiCode == 1 ); |
---|
263 | |
---|
264 | if( pcPPS->getTilesEnabledFlag() ) |
---|
265 | { |
---|
266 | READ_UVLC ( uiCode, "num_tile_columns_minus1" ); pcPPS->setNumTileColumnsMinus1( uiCode ); |
---|
267 | READ_UVLC ( uiCode, "num_tile_rows_minus1" ); pcPPS->setNumTileRowsMinus1( uiCode ); |
---|
268 | READ_FLAG ( uiCode, "uniform_spacing_flag" ); pcPPS->setTileUniformSpacingFlag( uiCode == 1 ); |
---|
269 | |
---|
270 | const UInt tileColumnsMinus1 = pcPPS->getNumTileColumnsMinus1(); |
---|
271 | const UInt tileRowsMinus1 = pcPPS->getNumTileRowsMinus1(); |
---|
272 | |
---|
273 | if ( !pcPPS->getTileUniformSpacingFlag()) |
---|
274 | { |
---|
275 | if (tileColumnsMinus1 > 0) |
---|
276 | { |
---|
277 | std::vector<Int> columnWidth(tileColumnsMinus1); |
---|
278 | for(UInt i = 0; i < tileColumnsMinus1; i++) |
---|
279 | { |
---|
280 | READ_UVLC( uiCode, "column_width_minus1" ); |
---|
281 | columnWidth[i] = uiCode+1; |
---|
282 | } |
---|
283 | pcPPS->setTileColumnWidth(columnWidth); |
---|
284 | } |
---|
285 | |
---|
286 | if (tileRowsMinus1 > 0) |
---|
287 | { |
---|
288 | std::vector<Int> rowHeight (tileRowsMinus1); |
---|
289 | for(UInt i = 0; i < tileRowsMinus1; i++) |
---|
290 | { |
---|
291 | READ_UVLC( uiCode, "row_height_minus1" ); |
---|
292 | rowHeight[i] = uiCode + 1; |
---|
293 | } |
---|
294 | pcPPS->setTileRowHeight(rowHeight); |
---|
295 | } |
---|
296 | } |
---|
297 | |
---|
298 | if ((tileColumnsMinus1 + tileRowsMinus1) != 0) |
---|
299 | { |
---|
300 | READ_FLAG ( uiCode, "loop_filter_across_tiles_enabled_flag" ); pcPPS->setLoopFilterAcrossTilesEnabledFlag( uiCode ? true : false ); |
---|
301 | } |
---|
302 | } |
---|
303 | READ_FLAG( uiCode, "loop_filter_across_slices_enabled_flag" ); pcPPS->setLoopFilterAcrossSlicesEnabledFlag( uiCode ? true : false ); |
---|
304 | READ_FLAG( uiCode, "deblocking_filter_control_present_flag" ); pcPPS->setDeblockingFilterControlPresentFlag( uiCode ? true : false ); |
---|
305 | if(pcPPS->getDeblockingFilterControlPresentFlag()) |
---|
306 | { |
---|
307 | READ_FLAG( uiCode, "deblocking_filter_override_enabled_flag" ); pcPPS->setDeblockingFilterOverrideEnabledFlag( uiCode ? true : false ); |
---|
308 | READ_FLAG( uiCode, "pps_disable_deblocking_filter_flag" ); pcPPS->setPicDisableDeblockingFilterFlag(uiCode ? true : false ); |
---|
309 | if(!pcPPS->getPicDisableDeblockingFilterFlag()) |
---|
310 | { |
---|
311 | READ_SVLC ( iCode, "pps_beta_offset_div2" ); pcPPS->setDeblockingFilterBetaOffsetDiv2( iCode ); |
---|
312 | READ_SVLC ( iCode, "pps_tc_offset_div2" ); pcPPS->setDeblockingFilterTcOffsetDiv2( iCode ); |
---|
313 | } |
---|
314 | } |
---|
315 | READ_FLAG( uiCode, "pps_scaling_list_data_present_flag" ); pcPPS->setScalingListPresentFlag( uiCode ? true : false ); |
---|
316 | if(pcPPS->getScalingListPresentFlag ()) |
---|
317 | { |
---|
318 | parseScalingList( pcPPS->getScalingList() ); |
---|
319 | } |
---|
320 | |
---|
321 | READ_FLAG( uiCode, "lists_modification_present_flag"); |
---|
322 | pcPPS->setListsModificationPresentFlag(uiCode); |
---|
323 | |
---|
324 | READ_UVLC( uiCode, "log2_parallel_merge_level_minus2"); |
---|
325 | pcPPS->setLog2ParallelMergeLevelMinus2 (uiCode); |
---|
326 | |
---|
327 | READ_FLAG( uiCode, "slice_segment_header_extension_present_flag"); |
---|
328 | pcPPS->setSliceHeaderExtensionPresentFlag(uiCode); |
---|
329 | |
---|
330 | READ_FLAG( uiCode, "pps_extension_present_flag"); |
---|
331 | |
---|
332 | #if SVC_EXTENSION |
---|
333 | pcPPS->setExtensionFlag( uiCode ? true : false ); |
---|
334 | if( pcPPS->getExtensionFlag() ) |
---|
335 | #else |
---|
336 | if (uiCode) |
---|
337 | #endif |
---|
338 | { |
---|
339 | Bool pps_extension_flags[NUM_PPS_EXTENSION_FLAGS]; |
---|
340 | for(Int i=0; i<NUM_PPS_EXTENSION_FLAGS; i++) |
---|
341 | { |
---|
342 | READ_FLAG( uiCode, "pps_extension_flag[]" ); |
---|
343 | pps_extension_flags[i] = uiCode!=0; |
---|
344 | } |
---|
345 | |
---|
346 | Bool bSkipTrailingExtensionBits=false; |
---|
347 | for(Int i=0; i<NUM_PPS_EXTENSION_FLAGS; i++) // loop used so that the order is determined by the enum. |
---|
348 | { |
---|
349 | if (pps_extension_flags[i]) |
---|
350 | { |
---|
351 | switch (PPSExtensionFlagIndex(i)) |
---|
352 | { |
---|
353 | case PPS_EXT__REXT: |
---|
354 | assert(!bSkipTrailingExtensionBits); |
---|
355 | |
---|
356 | if (pcPPS->getUseTransformSkip()) |
---|
357 | { |
---|
358 | READ_UVLC( uiCode, "log2_transform_skip_max_size_minus2"); |
---|
359 | pcPPS->setTransformSkipLog2MaxSize(uiCode+2); |
---|
360 | } |
---|
361 | |
---|
362 | READ_FLAG( uiCode, "cross_component_prediction_flag"); |
---|
363 | pcPPS->setUseCrossComponentPrediction(uiCode != 0); |
---|
364 | |
---|
365 | READ_FLAG( uiCode, "chroma_qp_adjustment_enabled_flag"); |
---|
366 | if (uiCode == 0) |
---|
367 | { |
---|
368 | pcPPS->clearChromaQpAdjTable(); |
---|
369 | pcPPS->setMaxCuChromaQpAdjDepth(0); |
---|
370 | } |
---|
371 | else |
---|
372 | { |
---|
373 | READ_UVLC(uiCode, "diff_cu_chroma_qp_adjustment_depth"); pcPPS->setMaxCuChromaQpAdjDepth(uiCode); |
---|
374 | UInt tableSizeMinus1 = 0; |
---|
375 | READ_UVLC(tableSizeMinus1, "chroma_qp_adjustment_table_size_minus1"); |
---|
376 | /* skip zero index */ |
---|
377 | for (Int chromaQpAdjustmentIndex = 1; chromaQpAdjustmentIndex <= (tableSizeMinus1 + 1); chromaQpAdjustmentIndex++) |
---|
378 | { |
---|
379 | Int cbOffset; |
---|
380 | Int crOffset; |
---|
381 | READ_SVLC(cbOffset, "cb_qp_adjustnemt[i]"); |
---|
382 | READ_SVLC(crOffset, "cr_qp_adjustnemt[i]"); |
---|
383 | pcPPS->setChromaQpAdjTableAt(chromaQpAdjustmentIndex, cbOffset, crOffset); |
---|
384 | } |
---|
385 | assert(pcPPS->getChromaQpAdjTableSize() == tableSizeMinus1 + 1); |
---|
386 | } |
---|
387 | |
---|
388 | READ_UVLC( uiCode, "sao_luma_bit_shift"); |
---|
389 | pcPPS->setSaoOffsetBitShift(CHANNEL_TYPE_LUMA, uiCode); |
---|
390 | READ_UVLC( uiCode, "sao_chroma_bit_shift"); |
---|
391 | pcPPS->setSaoOffsetBitShift(CHANNEL_TYPE_CHROMA, uiCode); |
---|
392 | break; |
---|
393 | |
---|
394 | #if SVC_EXTENSION |
---|
395 | case PPS_EXT__MLAYER: |
---|
396 | READ_FLAG( uiCode, "poc_reset_info_present_flag" ); |
---|
397 | pcPPS->setPocResetInfoPresentFlag(uiCode ? true : false); |
---|
398 | |
---|
399 | #if SCALINGLIST_INFERRING |
---|
400 | READ_FLAG( uiCode, "pps_infer_scaling_list_flag" ); |
---|
401 | pcPPS->setInferScalingListFlag( uiCode ); |
---|
402 | |
---|
403 | if( pcPPS->getInferScalingListFlag() ) |
---|
404 | { |
---|
405 | READ_CODE( 6, uiCode, "pps_scaling_list_ref_layer_id" ); |
---|
406 | pcPPS->setScalingListRefLayerId( uiCode ); |
---|
407 | // The value of pps_scaling_list_ref_layer_id shall be in the range of 0 to 62, inclusive |
---|
408 | assert( pcPPS->getScalingListRefLayerId() <= 62 ); |
---|
409 | pcPPS->setScalingListPresentFlag( false ); |
---|
410 | } |
---|
411 | #endif |
---|
412 | |
---|
413 | #if REF_REGION_OFFSET |
---|
414 | READ_UVLC( uiCode, "num_ref_loc_offsets" ); pcPPS->setNumScaledRefLayerOffsets(uiCode); |
---|
415 | for(Int k = 0; k < pcPPS->getNumScaledRefLayerOffsets(); k++) |
---|
416 | { |
---|
417 | READ_CODE( 6, uiCode, "ref_loc_offset_layer_id" ); pcPPS->setScaledRefLayerId( k, uiCode ); |
---|
418 | READ_FLAG( uiCode, "scaled_ref_layer_offset_present_flag" ); pcPPS->setScaledRefLayerOffsetPresentFlag( k, uiCode ); |
---|
419 | if (uiCode) |
---|
420 | { |
---|
421 | Window& scaledWindow = pcPPS->getScaledRefLayerWindow(k); |
---|
422 | READ_SVLC( iCode, "scaled_ref_layer_left_offset" ); scaledWindow.setWindowLeftOffset (iCode << 1); |
---|
423 | READ_SVLC( iCode, "scaled_ref_layer_top_offset" ); scaledWindow.setWindowTopOffset (iCode << 1); |
---|
424 | READ_SVLC( iCode, "scaled_ref_layer_right_offset" ); scaledWindow.setWindowRightOffset (iCode << 1); |
---|
425 | READ_SVLC( iCode, "scaled_ref_layer_bottom_offset" ); scaledWindow.setWindowBottomOffset(iCode << 1); |
---|
426 | #if P0312_VERT_PHASE_ADJ |
---|
427 | READ_FLAG( uiCode, "vert_phase_position_enable_flag" ); scaledWindow.setVertPhasePositionEnableFlag(uiCode); pcPPS->setVertPhasePositionEnableFlag( pcPPS->getScaledRefLayerId(i), uiCode); |
---|
428 | #endif |
---|
429 | } |
---|
430 | READ_FLAG( uiCode, "ref_region_offset_present_flag" ); pcPPS->setRefRegionOffsetPresentFlag( k, uiCode ); |
---|
431 | if (uiCode) |
---|
432 | { |
---|
433 | Window& refWindow = pcPPS->getRefLayerWindow(k); |
---|
434 | READ_SVLC( iCode, "ref_region_left_offset" ); refWindow.setWindowLeftOffset (iCode << 1); |
---|
435 | READ_SVLC( iCode, "ref_region_top_offset" ); refWindow.setWindowTopOffset (iCode << 1); |
---|
436 | READ_SVLC( iCode, "ref_region_right_offset" ); refWindow.setWindowRightOffset (iCode << 1); |
---|
437 | READ_SVLC( iCode, "ref_region_bottom_offset" ); refWindow.setWindowBottomOffset(iCode << 1); |
---|
438 | } |
---|
439 | #if R0209_GENERIC_PHASE |
---|
440 | READ_FLAG( uiCode, "resample_phase_set_present_flag" ); pcPPS->setResamplePhaseSetPresentFlag( k, uiCode ); |
---|
441 | if (uiCode) |
---|
442 | { |
---|
443 | READ_UVLC( uiCode, "phase_hor_luma" ); pcPPS->setPhaseHorLuma ( k, uiCode ); |
---|
444 | READ_UVLC( uiCode, "phase_ver_luma" ); pcPPS->setPhaseVerLuma ( k, uiCode ); |
---|
445 | READ_UVLC( uiCode, "phase_hor_chroma_plus8" ); pcPPS->setPhaseHorChroma (k, uiCode - 8); |
---|
446 | READ_UVLC( uiCode, "phase_ver_chroma_plus8" ); pcPPS->setPhaseVerChroma (k, uiCode - 8); |
---|
447 | } |
---|
448 | #endif |
---|
449 | } |
---|
450 | #else |
---|
451 | #if MOVE_SCALED_OFFSET_TO_PPS |
---|
452 | READ_UVLC( uiCode, "num_scaled_ref_layer_offsets" ); pcPPS->setNumScaledRefLayerOffsets(uiCode); |
---|
453 | for(Int k = 0; k < pcPPS->getNumScaledRefLayerOffsets(); k++) |
---|
454 | { |
---|
455 | Window& scaledWindow = pcPPS->getScaledRefLayerWindow(k); |
---|
456 | #if O0098_SCALED_REF_LAYER_ID |
---|
457 | READ_CODE( 6, uiCode, "scaled_ref_layer_id" ); pcPPS->setScaledRefLayerId( k, uiCode ); |
---|
458 | #endif |
---|
459 | READ_SVLC( iCode, "scaled_ref_layer_left_offset" ); scaledWindow.setWindowLeftOffset (iCode << 1); |
---|
460 | READ_SVLC( iCode, "scaled_ref_layer_top_offset" ); scaledWindow.setWindowTopOffset (iCode << 1); |
---|
461 | READ_SVLC( iCode, "scaled_ref_layer_right_offset" ); scaledWindow.setWindowRightOffset (iCode << 1); |
---|
462 | READ_SVLC( iCode, "scaled_ref_layer_bottom_offset" ); scaledWindow.setWindowBottomOffset(iCode << 1); |
---|
463 | #if P0312_VERT_PHASE_ADJ |
---|
464 | READ_FLAG( uiCode, "vert_phase_position_enable_flag" ); scaledWindow.setVertPhasePositionEnableFlag(uiCode); pcPPS->setVertPhasePositionEnableFlag( pcPPS->getScaledRefLayerId(k), uiCode); |
---|
465 | #endif |
---|
466 | } |
---|
467 | #endif |
---|
468 | #endif |
---|
469 | #if Q0048_CGS_3D_ASYMLUT |
---|
470 | READ_FLAG( uiCode , "colour_mapping_enabled_flag" ); |
---|
471 | pcPPS->setCGSFlag( uiCode ); |
---|
472 | if( pcPPS->getCGSFlag() ) |
---|
473 | { |
---|
474 | #if R0157_RESTRICT_PPSID_FOR_CGS_LUT |
---|
475 | // when pps_pic_parameter_set_id greater than or equal to 8, colour_mapping_enabled_flag shall be equal to 0 |
---|
476 | assert( pcPPS->getPPSId() < 8 ); |
---|
477 | #endif |
---|
478 | xParse3DAsymLUT( pc3DAsymLUT ); |
---|
479 | pcPPS->setCGSOutputBitDepthY( pc3DAsymLUT->getOutputBitDepthY() ); |
---|
480 | pcPPS->setCGSOutputBitDepthC( pc3DAsymLUT->getOutputBitDepthC() ); |
---|
481 | } |
---|
482 | #endif |
---|
483 | break; |
---|
484 | #endif |
---|
485 | default: |
---|
486 | bSkipTrailingExtensionBits=true; |
---|
487 | break; |
---|
488 | } |
---|
489 | } |
---|
490 | } |
---|
491 | if (bSkipTrailingExtensionBits) |
---|
492 | { |
---|
493 | while ( xMoreRbspData() ) |
---|
494 | { |
---|
495 | READ_FLAG( uiCode, "pps_extension_data_flag"); |
---|
496 | } |
---|
497 | } |
---|
498 | } |
---|
499 | } |
---|
500 | |
---|
501 | Void TDecCavlc::parseVUI(TComVUI* pcVUI, TComSPS *pcSPS) |
---|
502 | { |
---|
503 | #if ENC_DEC_TRACE |
---|
504 | fprintf( g_hTrace, "----------- vui_parameters -----------\n"); |
---|
505 | #endif |
---|
506 | UInt uiCode; |
---|
507 | |
---|
508 | READ_FLAG( uiCode, "aspect_ratio_info_present_flag"); pcVUI->setAspectRatioInfoPresentFlag(uiCode); |
---|
509 | if (pcVUI->getAspectRatioInfoPresentFlag()) |
---|
510 | { |
---|
511 | READ_CODE(8, uiCode, "aspect_ratio_idc"); pcVUI->setAspectRatioIdc(uiCode); |
---|
512 | if (pcVUI->getAspectRatioIdc() == 255) |
---|
513 | { |
---|
514 | READ_CODE(16, uiCode, "sar_width"); pcVUI->setSarWidth(uiCode); |
---|
515 | READ_CODE(16, uiCode, "sar_height"); pcVUI->setSarHeight(uiCode); |
---|
516 | } |
---|
517 | } |
---|
518 | |
---|
519 | READ_FLAG( uiCode, "overscan_info_present_flag"); pcVUI->setOverscanInfoPresentFlag(uiCode); |
---|
520 | if (pcVUI->getOverscanInfoPresentFlag()) |
---|
521 | { |
---|
522 | READ_FLAG( uiCode, "overscan_appropriate_flag"); pcVUI->setOverscanAppropriateFlag(uiCode); |
---|
523 | } |
---|
524 | |
---|
525 | READ_FLAG( uiCode, "video_signal_type_present_flag"); pcVUI->setVideoSignalTypePresentFlag(uiCode); |
---|
526 | if (pcVUI->getVideoSignalTypePresentFlag()) |
---|
527 | { |
---|
528 | READ_CODE(3, uiCode, "video_format"); pcVUI->setVideoFormat(uiCode); |
---|
529 | READ_FLAG( uiCode, "video_full_range_flag"); pcVUI->setVideoFullRangeFlag(uiCode); |
---|
530 | READ_FLAG( uiCode, "colour_description_present_flag"); pcVUI->setColourDescriptionPresentFlag(uiCode); |
---|
531 | if (pcVUI->getColourDescriptionPresentFlag()) |
---|
532 | { |
---|
533 | READ_CODE(8, uiCode, "colour_primaries"); pcVUI->setColourPrimaries(uiCode); |
---|
534 | READ_CODE(8, uiCode, "transfer_characteristics"); pcVUI->setTransferCharacteristics(uiCode); |
---|
535 | READ_CODE(8, uiCode, "matrix_coefficients"); pcVUI->setMatrixCoefficients(uiCode); |
---|
536 | } |
---|
537 | } |
---|
538 | |
---|
539 | READ_FLAG( uiCode, "chroma_loc_info_present_flag"); pcVUI->setChromaLocInfoPresentFlag(uiCode); |
---|
540 | if (pcVUI->getChromaLocInfoPresentFlag()) |
---|
541 | { |
---|
542 | READ_UVLC( uiCode, "chroma_sample_loc_type_top_field" ); pcVUI->setChromaSampleLocTypeTopField(uiCode); |
---|
543 | READ_UVLC( uiCode, "chroma_sample_loc_type_bottom_field" ); pcVUI->setChromaSampleLocTypeBottomField(uiCode); |
---|
544 | } |
---|
545 | |
---|
546 | READ_FLAG( uiCode, "neutral_chroma_indication_flag"); pcVUI->setNeutralChromaIndicationFlag(uiCode); |
---|
547 | |
---|
548 | READ_FLAG( uiCode, "field_seq_flag"); pcVUI->setFieldSeqFlag(uiCode); |
---|
549 | |
---|
550 | READ_FLAG(uiCode, "frame_field_info_present_flag"); pcVUI->setFrameFieldInfoPresentFlag(uiCode); |
---|
551 | |
---|
552 | READ_FLAG( uiCode, "default_display_window_flag"); |
---|
553 | if (uiCode != 0) |
---|
554 | { |
---|
555 | Window &defDisp = pcVUI->getDefaultDisplayWindow(); |
---|
556 | READ_UVLC( uiCode, "def_disp_win_left_offset" ); defDisp.setWindowLeftOffset ( uiCode * TComSPS::getWinUnitX( pcSPS->getChromaFormatIdc()) ); |
---|
557 | READ_UVLC( uiCode, "def_disp_win_right_offset" ); defDisp.setWindowRightOffset ( uiCode * TComSPS::getWinUnitX( pcSPS->getChromaFormatIdc()) ); |
---|
558 | READ_UVLC( uiCode, "def_disp_win_top_offset" ); defDisp.setWindowTopOffset ( uiCode * TComSPS::getWinUnitY( pcSPS->getChromaFormatIdc()) ); |
---|
559 | READ_UVLC( uiCode, "def_disp_win_bottom_offset" ); defDisp.setWindowBottomOffset( uiCode * TComSPS::getWinUnitY( pcSPS->getChromaFormatIdc()) ); |
---|
560 | } |
---|
561 | |
---|
562 | TimingInfo *timingInfo = pcVUI->getTimingInfo(); |
---|
563 | READ_FLAG( uiCode, "vui_timing_info_present_flag"); timingInfo->setTimingInfoPresentFlag (uiCode ? true : false); |
---|
564 | #if SVC_EXTENSION |
---|
565 | if( pcSPS->getLayerId() > 0 ) |
---|
566 | { |
---|
567 | assert( timingInfo->getTimingInfoPresentFlag() == false ); |
---|
568 | } |
---|
569 | #endif |
---|
570 | if(timingInfo->getTimingInfoPresentFlag()) |
---|
571 | { |
---|
572 | READ_CODE( 32, uiCode, "vui_num_units_in_tick"); timingInfo->setNumUnitsInTick (uiCode); |
---|
573 | READ_CODE( 32, uiCode, "vui_time_scale"); timingInfo->setTimeScale (uiCode); |
---|
574 | READ_FLAG( uiCode, "vui_poc_proportional_to_timing_flag"); timingInfo->setPocProportionalToTimingFlag(uiCode ? true : false); |
---|
575 | if(timingInfo->getPocProportionalToTimingFlag()) |
---|
576 | { |
---|
577 | READ_UVLC( uiCode, "vui_num_ticks_poc_diff_one_minus1"); timingInfo->setNumTicksPocDiffOneMinus1 (uiCode); |
---|
578 | } |
---|
579 | |
---|
580 | READ_FLAG( uiCode, "hrd_parameters_present_flag"); pcVUI->setHrdParametersPresentFlag(uiCode); |
---|
581 | if( pcVUI->getHrdParametersPresentFlag() ) |
---|
582 | { |
---|
583 | parseHrdParameters( pcVUI->getHrdParameters(), 1, pcSPS->getMaxTLayers() - 1 ); |
---|
584 | } |
---|
585 | } |
---|
586 | |
---|
587 | READ_FLAG( uiCode, "bitstream_restriction_flag"); pcVUI->setBitstreamRestrictionFlag(uiCode); |
---|
588 | if (pcVUI->getBitstreamRestrictionFlag()) |
---|
589 | { |
---|
590 | READ_FLAG( uiCode, "tiles_fixed_structure_flag"); pcVUI->setTilesFixedStructureFlag(uiCode); |
---|
591 | READ_FLAG( uiCode, "motion_vectors_over_pic_boundaries_flag"); pcVUI->setMotionVectorsOverPicBoundariesFlag(uiCode); |
---|
592 | READ_FLAG( uiCode, "restricted_ref_pic_lists_flag"); pcVUI->setRestrictedRefPicListsFlag(uiCode); |
---|
593 | READ_UVLC( uiCode, "min_spatial_segmentation_idc"); pcVUI->setMinSpatialSegmentationIdc(uiCode); |
---|
594 | assert(uiCode < 4096); |
---|
595 | READ_UVLC( uiCode, "max_bytes_per_pic_denom" ); pcVUI->setMaxBytesPerPicDenom(uiCode); |
---|
596 | READ_UVLC( uiCode, "max_bits_per_mincu_denom" ); pcVUI->setMaxBitsPerMinCuDenom(uiCode); |
---|
597 | READ_UVLC( uiCode, "log2_max_mv_length_horizontal" ); pcVUI->setLog2MaxMvLengthHorizontal(uiCode); |
---|
598 | READ_UVLC( uiCode, "log2_max_mv_length_vertical" ); pcVUI->setLog2MaxMvLengthVertical(uiCode); |
---|
599 | } |
---|
600 | } |
---|
601 | |
---|
602 | Void TDecCavlc::parseHrdParameters(TComHRD *hrd, Bool commonInfPresentFlag, UInt maxNumSubLayersMinus1) |
---|
603 | { |
---|
604 | UInt uiCode; |
---|
605 | if( commonInfPresentFlag ) |
---|
606 | { |
---|
607 | READ_FLAG( uiCode, "nal_hrd_parameters_present_flag" ); hrd->setNalHrdParametersPresentFlag( uiCode == 1 ? true : false ); |
---|
608 | READ_FLAG( uiCode, "vcl_hrd_parameters_present_flag" ); hrd->setVclHrdParametersPresentFlag( uiCode == 1 ? true : false ); |
---|
609 | if( hrd->getNalHrdParametersPresentFlag() || hrd->getVclHrdParametersPresentFlag() ) |
---|
610 | { |
---|
611 | READ_FLAG( uiCode, "sub_pic_cpb_params_present_flag" ); hrd->setSubPicCpbParamsPresentFlag( uiCode == 1 ? true : false ); |
---|
612 | if( hrd->getSubPicCpbParamsPresentFlag() ) |
---|
613 | { |
---|
614 | READ_CODE( 8, uiCode, "tick_divisor_minus2" ); hrd->setTickDivisorMinus2( uiCode ); |
---|
615 | READ_CODE( 5, uiCode, "du_cpb_removal_delay_length_minus1" ); hrd->setDuCpbRemovalDelayLengthMinus1( uiCode ); |
---|
616 | READ_FLAG( uiCode, "sub_pic_cpb_params_in_pic_timing_sei_flag" ); hrd->setSubPicCpbParamsInPicTimingSEIFlag( uiCode == 1 ? true : false ); |
---|
617 | READ_CODE( 5, uiCode, "dpb_output_delay_du_length_minus1" ); hrd->setDpbOutputDelayDuLengthMinus1( uiCode ); |
---|
618 | } |
---|
619 | READ_CODE( 4, uiCode, "bit_rate_scale" ); hrd->setBitRateScale( uiCode ); |
---|
620 | READ_CODE( 4, uiCode, "cpb_size_scale" ); hrd->setCpbSizeScale( uiCode ); |
---|
621 | if( hrd->getSubPicCpbParamsPresentFlag() ) |
---|
622 | { |
---|
623 | READ_CODE( 4, uiCode, "cpb_size_du_scale" ); hrd->setDuCpbSizeScale( uiCode ); |
---|
624 | } |
---|
625 | READ_CODE( 5, uiCode, "initial_cpb_removal_delay_length_minus1" ); hrd->setInitialCpbRemovalDelayLengthMinus1( uiCode ); |
---|
626 | READ_CODE( 5, uiCode, "au_cpb_removal_delay_length_minus1" ); hrd->setCpbRemovalDelayLengthMinus1( uiCode ); |
---|
627 | READ_CODE( 5, uiCode, "dpb_output_delay_length_minus1" ); hrd->setDpbOutputDelayLengthMinus1( uiCode ); |
---|
628 | } |
---|
629 | #if VPS_VUI_BSP_HRD_PARAMS |
---|
630 | else |
---|
631 | { |
---|
632 | hrd->setInitialCpbRemovalDelayLengthMinus1( 23 ); |
---|
633 | // Add inferred values for other syntax elements here. |
---|
634 | } |
---|
635 | #endif |
---|
636 | } |
---|
637 | Int i, j, nalOrVcl; |
---|
638 | for( i = 0; i <= maxNumSubLayersMinus1; i ++ ) |
---|
639 | { |
---|
640 | READ_FLAG( uiCode, "fixed_pic_rate_general_flag" ); hrd->setFixedPicRateFlag( i, uiCode == 1 ? true : false ); |
---|
641 | if( !hrd->getFixedPicRateFlag( i ) ) |
---|
642 | { |
---|
643 | READ_FLAG( uiCode, "fixed_pic_rate_within_cvs_flag" ); hrd->setFixedPicRateWithinCvsFlag( i, uiCode == 1 ? true : false ); |
---|
644 | } |
---|
645 | else |
---|
646 | { |
---|
647 | hrd->setFixedPicRateWithinCvsFlag( i, true ); |
---|
648 | } |
---|
649 | |
---|
650 | hrd->setLowDelayHrdFlag( i, 0 ); // Infered to be 0 when not present |
---|
651 | hrd->setCpbCntMinus1 ( i, 0 ); // Infered to be 0 when not present |
---|
652 | |
---|
653 | if( hrd->getFixedPicRateWithinCvsFlag( i ) ) |
---|
654 | { |
---|
655 | READ_UVLC( uiCode, "elemental_duration_in_tc_minus1" ); hrd->setPicDurationInTcMinus1( i, uiCode ); |
---|
656 | } |
---|
657 | else |
---|
658 | { |
---|
659 | READ_FLAG( uiCode, "low_delay_hrd_flag" ); hrd->setLowDelayHrdFlag( i, uiCode == 1 ? true : false ); |
---|
660 | } |
---|
661 | if (!hrd->getLowDelayHrdFlag( i )) |
---|
662 | { |
---|
663 | READ_UVLC( uiCode, "cpb_cnt_minus1" ); hrd->setCpbCntMinus1( i, uiCode ); |
---|
664 | } |
---|
665 | |
---|
666 | for( nalOrVcl = 0; nalOrVcl < 2; nalOrVcl ++ ) |
---|
667 | { |
---|
668 | if( ( ( nalOrVcl == 0 ) && ( hrd->getNalHrdParametersPresentFlag() ) ) || |
---|
669 | ( ( nalOrVcl == 1 ) && ( hrd->getVclHrdParametersPresentFlag() ) ) ) |
---|
670 | { |
---|
671 | for( j = 0; j <= ( hrd->getCpbCntMinus1( i ) ); j ++ ) |
---|
672 | { |
---|
673 | READ_UVLC( uiCode, "bit_rate_value_minus1" ); hrd->setBitRateValueMinus1( i, j, nalOrVcl, uiCode ); |
---|
674 | READ_UVLC( uiCode, "cpb_size_value_minus1" ); hrd->setCpbSizeValueMinus1( i, j, nalOrVcl, uiCode ); |
---|
675 | if( hrd->getSubPicCpbParamsPresentFlag() ) |
---|
676 | { |
---|
677 | READ_UVLC( uiCode, "cpb_size_du_value_minus1" ); hrd->setDuCpbSizeValueMinus1( i, j, nalOrVcl, uiCode ); |
---|
678 | READ_UVLC( uiCode, "bit_rate_du_value_minus1" ); hrd->setDuBitRateValueMinus1( i, j, nalOrVcl, uiCode ); |
---|
679 | } |
---|
680 | READ_FLAG( uiCode, "cbr_flag" ); hrd->setCbrFlag( i, j, nalOrVcl, uiCode == 1 ? true : false ); |
---|
681 | } |
---|
682 | } |
---|
683 | } |
---|
684 | } |
---|
685 | } |
---|
686 | |
---|
687 | Void TDecCavlc::parseSPS(TComSPS* pcSPS) |
---|
688 | { |
---|
689 | #if ENC_DEC_TRACE |
---|
690 | xTraceSPSHeader (pcSPS); |
---|
691 | #endif |
---|
692 | |
---|
693 | UInt uiCode; |
---|
694 | READ_CODE( 4, uiCode, "sps_video_parameter_set_id"); pcSPS->setVPSId ( uiCode ); |
---|
695 | |
---|
696 | #if SVC_EXTENSION |
---|
697 | UInt uiTmp = 0; |
---|
698 | |
---|
699 | if(pcSPS->getLayerId() == 0) |
---|
700 | { |
---|
701 | #endif |
---|
702 | READ_CODE( 3, uiCode, "sps_max_sub_layers_minus1" ); pcSPS->setMaxTLayers ( uiCode+1 ); |
---|
703 | assert(uiCode <= 6); |
---|
704 | #if SVC_EXTENSION |
---|
705 | } |
---|
706 | else |
---|
707 | { |
---|
708 | READ_CODE( 3, uiCode, "sps_ext_or_max_sub_layers_minus1" ); uiTmp = uiCode; |
---|
709 | |
---|
710 | if( uiTmp != 7 ) |
---|
711 | { |
---|
712 | pcSPS->setMaxTLayers(uiTmp + 1); |
---|
713 | } |
---|
714 | } |
---|
715 | |
---|
716 | Bool V1CompatibleSPSFlag = !( pcSPS->getLayerId() != 0 && uiTmp == 7 ); |
---|
717 | |
---|
718 | if( V1CompatibleSPSFlag ) |
---|
719 | { |
---|
720 | #endif |
---|
721 | READ_FLAG( uiCode, "sps_temporal_id_nesting_flag" ); pcSPS->setTemporalIdNestingFlag ( uiCode > 0 ? true : false ); |
---|
722 | parsePTL(pcSPS->getPTL(), 1, pcSPS->getMaxTLayers() - 1); |
---|
723 | #if SVC_EXTENSION |
---|
724 | } |
---|
725 | #else |
---|
726 | if ( pcSPS->getMaxTLayers() == 1 ) |
---|
727 | { |
---|
728 | // sps_temporal_id_nesting_flag must be 1 when sps_max_sub_layers_minus1 is 0 |
---|
729 | assert( uiCode == 1 ); |
---|
730 | } |
---|
731 | #endif |
---|
732 | |
---|
733 | READ_UVLC( uiCode, "sps_seq_parameter_set_id" ); pcSPS->setSPSId( uiCode ); |
---|
734 | assert(uiCode <= 15); |
---|
735 | |
---|
736 | #if SVC_EXTENSION |
---|
737 | if( !V1CompatibleSPSFlag ) |
---|
738 | { |
---|
739 | READ_FLAG( uiCode, "update_rep_format_flag" ); |
---|
740 | pcSPS->setUpdateRepFormatFlag( uiCode ? true : false ); |
---|
741 | |
---|
742 | if( pcSPS->getUpdateRepFormatFlag() ) |
---|
743 | { |
---|
744 | READ_CODE(8, uiCode, "sps_rep_format_idx"); |
---|
745 | pcSPS->setUpdateRepFormatIndex(uiCode); |
---|
746 | } |
---|
747 | } |
---|
748 | else |
---|
749 | { |
---|
750 | pcSPS->setUpdateRepFormatFlag( false ); |
---|
751 | #endif |
---|
752 | READ_UVLC( uiCode, "chroma_format_idc" ); pcSPS->setChromaFormatIdc( ChromaFormat(uiCode) ); |
---|
753 | assert(uiCode <= 3); |
---|
754 | |
---|
755 | if( pcSPS->getChromaFormatIdc() == CHROMA_444 ) |
---|
756 | { |
---|
757 | READ_FLAG( uiCode, "separate_colour_plane_flag"); assert(uiCode == 0); |
---|
758 | } |
---|
759 | |
---|
760 | READ_UVLC ( uiCode, "pic_width_in_luma_samples" ); pcSPS->setPicWidthInLumaSamples ( uiCode ); |
---|
761 | READ_UVLC ( uiCode, "pic_height_in_luma_samples" ); pcSPS->setPicHeightInLumaSamples( uiCode ); |
---|
762 | READ_FLAG( uiCode, "conformance_window_flag"); |
---|
763 | if (uiCode != 0) |
---|
764 | { |
---|
765 | Window &conf = pcSPS->getConformanceWindow(); |
---|
766 | #if REPN_FORMAT_IN_VPS |
---|
767 | READ_UVLC( uiCode, "conf_win_left_offset" ); conf.setWindowLeftOffset ( uiCode ); |
---|
768 | READ_UVLC( uiCode, "conf_win_right_offset" ); conf.setWindowRightOffset ( uiCode ); |
---|
769 | READ_UVLC( uiCode, "conf_win_top_offset" ); conf.setWindowTopOffset ( uiCode ); |
---|
770 | READ_UVLC( uiCode, "conf_win_bottom_offset" ); conf.setWindowBottomOffset( uiCode ); |
---|
771 | #else |
---|
772 | READ_UVLC( uiCode, "conf_win_left_offset" ); conf.setWindowLeftOffset ( uiCode * TComSPS::getWinUnitX( pcSPS->getChromaFormatIdc() ) ); |
---|
773 | READ_UVLC( uiCode, "conf_win_right_offset" ); conf.setWindowRightOffset ( uiCode * TComSPS::getWinUnitX( pcSPS->getChromaFormatIdc() ) ); |
---|
774 | READ_UVLC( uiCode, "conf_win_top_offset" ); conf.setWindowTopOffset ( uiCode * TComSPS::getWinUnitY( pcSPS->getChromaFormatIdc() ) ); |
---|
775 | READ_UVLC( uiCode, "conf_win_bottom_offset" ); conf.setWindowBottomOffset( uiCode * TComSPS::getWinUnitY( pcSPS->getChromaFormatIdc() ) ); |
---|
776 | #endif |
---|
777 | } |
---|
778 | |
---|
779 | READ_UVLC( uiCode, "bit_depth_luma_minus8" ); |
---|
780 | #if O0043_BEST_EFFORT_DECODING |
---|
781 | const UInt forceDecodeBitDepth = pcSPS->getForceDecodeBitDepth(); |
---|
782 | g_bitDepthInStream[CHANNEL_TYPE_LUMA] = 8 + uiCode; |
---|
783 | if (forceDecodeBitDepth != 0) |
---|
784 | { |
---|
785 | uiCode = forceDecodeBitDepth - 8; |
---|
786 | } |
---|
787 | #endif |
---|
788 | assert(uiCode <= 8); |
---|
789 | |
---|
790 | pcSPS->setBitDepth(CHANNEL_TYPE_LUMA, 8 + uiCode); |
---|
791 | #if O0043_BEST_EFFORT_DECODING |
---|
792 | pcSPS->setQpBDOffset(CHANNEL_TYPE_LUMA, (Int) (6*(g_bitDepthInStream[CHANNEL_TYPE_LUMA]-8)) ); |
---|
793 | #else |
---|
794 | pcSPS->setQpBDOffset(CHANNEL_TYPE_LUMA, (Int) (6*uiCode) ); |
---|
795 | #endif |
---|
796 | |
---|
797 | READ_UVLC( uiCode, "bit_depth_chroma_minus8" ); |
---|
798 | #if O0043_BEST_EFFORT_DECODING |
---|
799 | g_bitDepthInStream[CHANNEL_TYPE_CHROMA] = 8 + uiCode; |
---|
800 | if (forceDecodeBitDepth != 0) |
---|
801 | { |
---|
802 | uiCode = forceDecodeBitDepth - 8; |
---|
803 | } |
---|
804 | #endif |
---|
805 | assert(uiCode <= 8); |
---|
806 | pcSPS->setBitDepth(CHANNEL_TYPE_CHROMA, 8 + uiCode); |
---|
807 | #if O0043_BEST_EFFORT_DECODING |
---|
808 | pcSPS->setQpBDOffset(CHANNEL_TYPE_CHROMA, (Int) (6*(g_bitDepthInStream[CHANNEL_TYPE_CHROMA]-8)) ); |
---|
809 | #else |
---|
810 | pcSPS->setQpBDOffset(CHANNEL_TYPE_CHROMA, (Int) (6*uiCode) ); |
---|
811 | #endif |
---|
812 | |
---|
813 | #if SVC_EXTENSION |
---|
814 | } |
---|
815 | #endif |
---|
816 | |
---|
817 | |
---|
818 | READ_UVLC( uiCode, "log2_max_pic_order_cnt_lsb_minus4" ); pcSPS->setBitsForPOC( 4 + uiCode ); |
---|
819 | assert(uiCode <= 12); |
---|
820 | |
---|
821 | #if SVC_EXTENSION |
---|
822 | if( V1CompatibleSPSFlag ) |
---|
823 | { |
---|
824 | #endif |
---|
825 | UInt subLayerOrderingInfoPresentFlag; |
---|
826 | READ_FLAG(subLayerOrderingInfoPresentFlag, "sps_sub_layer_ordering_info_present_flag"); |
---|
827 | |
---|
828 | for(UInt i=0; i <= pcSPS->getMaxTLayers()-1; i++) |
---|
829 | { |
---|
830 | READ_UVLC ( uiCode, "sps_max_dec_pic_buffering_minus1[i]"); |
---|
831 | pcSPS->setMaxDecPicBuffering( uiCode + 1, i); |
---|
832 | READ_UVLC ( uiCode, "sps_num_reorder_pics[i]" ); |
---|
833 | pcSPS->setNumReorderPics(uiCode, i); |
---|
834 | READ_UVLC ( uiCode, "sps_max_latency_increase_plus1[i]"); |
---|
835 | pcSPS->setMaxLatencyIncrease( uiCode, i ); |
---|
836 | |
---|
837 | if (!subLayerOrderingInfoPresentFlag) |
---|
838 | { |
---|
839 | for (i++; i <= pcSPS->getMaxTLayers()-1; i++) |
---|
840 | { |
---|
841 | pcSPS->setMaxDecPicBuffering(pcSPS->getMaxDecPicBuffering(0), i); |
---|
842 | pcSPS->setNumReorderPics(pcSPS->getNumReorderPics(0), i); |
---|
843 | pcSPS->setMaxLatencyIncrease(pcSPS->getMaxLatencyIncrease(0), i); |
---|
844 | } |
---|
845 | break; |
---|
846 | } |
---|
847 | } |
---|
848 | #if SVC_EXTENSION |
---|
849 | } |
---|
850 | #endif |
---|
851 | READ_UVLC( uiCode, "log2_min_coding_block_size_minus3" ); |
---|
852 | Int log2MinCUSize = uiCode + 3; |
---|
853 | pcSPS->setLog2MinCodingBlockSize(log2MinCUSize); |
---|
854 | READ_UVLC( uiCode, "log2_diff_max_min_coding_block_size" ); |
---|
855 | pcSPS->setLog2DiffMaxMinCodingBlockSize(uiCode); |
---|
856 | |
---|
857 | if (pcSPS->getPTL()->getGeneralPTL()->getLevelIdc() >= Level::LEVEL5) |
---|
858 | { |
---|
859 | assert(log2MinCUSize + pcSPS->getLog2DiffMaxMinCodingBlockSize() >= 5); |
---|
860 | } |
---|
861 | |
---|
862 | Int maxCUDepthDelta = uiCode; |
---|
863 | pcSPS->setMaxCUWidth ( 1<<(log2MinCUSize + maxCUDepthDelta) ); |
---|
864 | pcSPS->setMaxCUHeight ( 1<<(log2MinCUSize + maxCUDepthDelta) ); |
---|
865 | READ_UVLC( uiCode, "log2_min_transform_block_size_minus2" ); pcSPS->setQuadtreeTULog2MinSize( uiCode + 2 ); |
---|
866 | |
---|
867 | READ_UVLC( uiCode, "log2_diff_max_min_transform_block_size" ); pcSPS->setQuadtreeTULog2MaxSize( uiCode + pcSPS->getQuadtreeTULog2MinSize() ); |
---|
868 | pcSPS->setMaxTrSize( 1<<(uiCode + pcSPS->getQuadtreeTULog2MinSize()) ); |
---|
869 | |
---|
870 | READ_UVLC( uiCode, "max_transform_hierarchy_depth_inter" ); pcSPS->setQuadtreeTUMaxDepthInter( uiCode+1 ); |
---|
871 | READ_UVLC( uiCode, "max_transform_hierarchy_depth_intra" ); pcSPS->setQuadtreeTUMaxDepthIntra( uiCode+1 ); |
---|
872 | |
---|
873 | Int addCuDepth = max (0, log2MinCUSize - (Int)pcSPS->getQuadtreeTULog2MinSize() ); |
---|
874 | pcSPS->setMaxCUDepth( maxCUDepthDelta + addCuDepth + getMaxCUDepthOffset(pcSPS->getChromaFormatIdc(), pcSPS->getQuadtreeTULog2MinSize()) ); |
---|
875 | |
---|
876 | READ_FLAG( uiCode, "scaling_list_enabled_flag" ); pcSPS->setScalingListFlag ( uiCode ); |
---|
877 | if(pcSPS->getScalingListFlag()) |
---|
878 | { |
---|
879 | #if SVC_EXTENSION |
---|
880 | if( !V1CompatibleSPSFlag ) |
---|
881 | { |
---|
882 | READ_FLAG( uiCode, "sps_infer_scaling_list_flag" ); pcSPS->setInferScalingListFlag( uiCode ); |
---|
883 | } |
---|
884 | |
---|
885 | if( pcSPS->getInferScalingListFlag() ) |
---|
886 | { |
---|
887 | READ_CODE( 6, uiCode, "sps_scaling_list_ref_layer_id" ); pcSPS->setScalingListRefLayerId( uiCode ); |
---|
888 | |
---|
889 | // The value of sps_scaling_list_ref_layer_id shall be in the range of 0 to 62, inclusive |
---|
890 | assert( pcSPS->getScalingListRefLayerId() <= 62 ); |
---|
891 | |
---|
892 | pcSPS->setScalingListPresentFlag( false ); |
---|
893 | } |
---|
894 | else |
---|
895 | { |
---|
896 | #endif |
---|
897 | READ_FLAG( uiCode, "sps_scaling_list_data_present_flag" ); pcSPS->setScalingListPresentFlag ( uiCode ); |
---|
898 | if(pcSPS->getScalingListPresentFlag ()) |
---|
899 | { |
---|
900 | parseScalingList( pcSPS->getScalingList() ); |
---|
901 | } |
---|
902 | #if SVC_EXTENSION |
---|
903 | } |
---|
904 | #endif |
---|
905 | } |
---|
906 | READ_FLAG( uiCode, "amp_enabled_flag" ); pcSPS->setUseAMP( uiCode ); |
---|
907 | READ_FLAG( uiCode, "sample_adaptive_offset_enabled_flag" ); pcSPS->setUseSAO ( uiCode ? true : false ); |
---|
908 | |
---|
909 | READ_FLAG( uiCode, "pcm_enabled_flag" ); pcSPS->setUsePCM( uiCode ? true : false ); |
---|
910 | if( pcSPS->getUsePCM() ) |
---|
911 | { |
---|
912 | READ_CODE( 4, uiCode, "pcm_sample_bit_depth_luma_minus1" ); pcSPS->setPCMBitDepth ( CHANNEL_TYPE_LUMA, 1 + uiCode ); |
---|
913 | READ_CODE( 4, uiCode, "pcm_sample_bit_depth_chroma_minus1" ); pcSPS->setPCMBitDepth ( CHANNEL_TYPE_CHROMA, 1 + uiCode ); |
---|
914 | READ_UVLC( uiCode, "log2_min_pcm_luma_coding_block_size_minus3" ); pcSPS->setPCMLog2MinSize (uiCode+3); |
---|
915 | READ_UVLC( uiCode, "log2_diff_max_min_pcm_luma_coding_block_size" ); pcSPS->setPCMLog2MaxSize ( uiCode+pcSPS->getPCMLog2MinSize() ); |
---|
916 | READ_FLAG( uiCode, "pcm_loop_filter_disable_flag" ); pcSPS->setPCMFilterDisableFlag ( uiCode ? true : false ); |
---|
917 | } |
---|
918 | |
---|
919 | READ_UVLC( uiCode, "num_short_term_ref_pic_sets" ); |
---|
920 | assert(uiCode <= 64); |
---|
921 | pcSPS->createRPSList(uiCode); |
---|
922 | |
---|
923 | TComRPSList* rpsList = pcSPS->getRPSList(); |
---|
924 | TComReferencePictureSet* rps; |
---|
925 | |
---|
926 | for(UInt i=0; i< rpsList->getNumberOfReferencePictureSets(); i++) |
---|
927 | { |
---|
928 | rps = rpsList->getReferencePictureSet(i); |
---|
929 | parseShortTermRefPicSet(pcSPS,rps,i); |
---|
930 | } |
---|
931 | READ_FLAG( uiCode, "long_term_ref_pics_present_flag" ); pcSPS->setLongTermRefsPresent(uiCode); |
---|
932 | if (pcSPS->getLongTermRefsPresent()) |
---|
933 | { |
---|
934 | READ_UVLC( uiCode, "num_long_term_ref_pic_sps" ); |
---|
935 | pcSPS->setNumLongTermRefPicSPS(uiCode); |
---|
936 | for (UInt k = 0; k < pcSPS->getNumLongTermRefPicSPS(); k++) |
---|
937 | { |
---|
938 | READ_CODE( pcSPS->getBitsForPOC(), uiCode, "lt_ref_pic_poc_lsb_sps" ); |
---|
939 | pcSPS->setLtRefPicPocLsbSps(k, uiCode); |
---|
940 | READ_FLAG( uiCode, "used_by_curr_pic_lt_sps_flag[i]"); |
---|
941 | pcSPS->setUsedByCurrPicLtSPSFlag(k, uiCode?1:0); |
---|
942 | } |
---|
943 | } |
---|
944 | READ_FLAG( uiCode, "sps_temporal_mvp_enable_flag" ); pcSPS->setTMVPFlagsPresent(uiCode); |
---|
945 | |
---|
946 | READ_FLAG( uiCode, "sps_strong_intra_smoothing_enable_flag" ); pcSPS->setUseStrongIntraSmoothing(uiCode); |
---|
947 | |
---|
948 | READ_FLAG( uiCode, "vui_parameters_present_flag" ); pcSPS->setVuiParametersPresentFlag(uiCode); |
---|
949 | |
---|
950 | if (pcSPS->getVuiParametersPresentFlag()) |
---|
951 | { |
---|
952 | parseVUI(pcSPS->getVuiParameters(), pcSPS); |
---|
953 | } |
---|
954 | |
---|
955 | READ_FLAG( uiCode, "sps_extension_present_flag"); |
---|
956 | |
---|
957 | #if SVC_EXTENSION |
---|
958 | pcSPS->setExtensionFlag( uiCode ? true : false ); |
---|
959 | |
---|
960 | if( pcSPS->getExtensionFlag() ) |
---|
961 | #else |
---|
962 | if (uiCode) |
---|
963 | #endif |
---|
964 | { |
---|
965 | Bool sps_extension_flags[NUM_SPS_EXTENSION_FLAGS]; |
---|
966 | for(Int i=0; i<NUM_SPS_EXTENSION_FLAGS; i++) |
---|
967 | { |
---|
968 | READ_FLAG( uiCode, "sps_extension_flag[]" ); |
---|
969 | sps_extension_flags[i] = uiCode!=0; |
---|
970 | } |
---|
971 | |
---|
972 | Bool bSkipTrailingExtensionBits=false; |
---|
973 | for(Int i=0; i<NUM_SPS_EXTENSION_FLAGS; i++) // loop used so that the order is determined by the enum. |
---|
974 | { |
---|
975 | if (sps_extension_flags[i]) |
---|
976 | { |
---|
977 | switch (SPSExtensionFlagIndex(i)) |
---|
978 | { |
---|
979 | case SPS_EXT__REXT: |
---|
980 | assert(!bSkipTrailingExtensionBits); |
---|
981 | |
---|
982 | READ_FLAG( uiCode, "transform_skip_rotation_enabled_flag"); pcSPS->setUseResidualRotation (uiCode != 0); |
---|
983 | READ_FLAG( uiCode, "transform_skip_context_enabled_flag"); pcSPS->setUseSingleSignificanceMapContext (uiCode != 0); |
---|
984 | READ_FLAG( uiCode, "residual_dpcm_implicit_enabled_flag"); pcSPS->setUseResidualDPCM(RDPCM_SIGNAL_IMPLICIT, (uiCode != 0)); |
---|
985 | READ_FLAG( uiCode, "residual_dpcm_explicit_enabled_flag"); pcSPS->setUseResidualDPCM(RDPCM_SIGNAL_EXPLICIT, (uiCode != 0)); |
---|
986 | READ_FLAG( uiCode, "extended_precision_processing_flag"); pcSPS->setUseExtendedPrecision (uiCode != 0); |
---|
987 | READ_FLAG( uiCode, "intra_smoothing_disabled_flag"); pcSPS->setDisableIntraReferenceSmoothing (uiCode != 0); |
---|
988 | READ_FLAG( uiCode, "high_precision_prediction_weighting_flag"); pcSPS->setUseHighPrecisionPredictionWeighting (uiCode != 0); |
---|
989 | READ_FLAG( uiCode, "golomb_rice_parameter_adaptation_flag"); pcSPS->setUseGolombRiceParameterAdaptation (uiCode != 0); |
---|
990 | READ_FLAG( uiCode, "cabac_bypass_alignment_enabled_flag"); pcSPS->setAlignCABACBeforeBypass (uiCode != 0); |
---|
991 | break; |
---|
992 | #if SVC_EXTENSION |
---|
993 | case SPS_EXT__MLAYER: |
---|
994 | parseSPSExtension( pcSPS ); |
---|
995 | break; |
---|
996 | #endif |
---|
997 | default: |
---|
998 | bSkipTrailingExtensionBits=true; |
---|
999 | break; |
---|
1000 | } |
---|
1001 | } |
---|
1002 | } |
---|
1003 | if (bSkipTrailingExtensionBits) |
---|
1004 | { |
---|
1005 | while ( xMoreRbspData() ) |
---|
1006 | { |
---|
1007 | READ_FLAG( uiCode, "sps_extension_data_flag"); |
---|
1008 | } |
---|
1009 | } |
---|
1010 | } |
---|
1011 | } |
---|
1012 | |
---|
1013 | Void TDecCavlc::parseVPS(TComVPS* pcVPS) |
---|
1014 | { |
---|
1015 | UInt uiCode; |
---|
1016 | |
---|
1017 | READ_CODE( 4, uiCode, "vps_video_parameter_set_id" ); pcVPS->setVPSId( uiCode ); |
---|
1018 | #if VPS_RESERVED_FLAGS |
---|
1019 | READ_FLAG( uiCode, "vps_base_layer_internal_flag"); pcVPS->setBaseLayerInternalFlag( uiCode ? true : false ); |
---|
1020 | READ_FLAG( uiCode, "vps_base_layer_available_flag"); pcVPS->setBaseLayerAvailableFlag( uiCode ? true : false ); |
---|
1021 | #if VPS_AVC_BL_FLAG_REMOVAL |
---|
1022 | pcVPS->setNonHEVCBaseLayerFlag( (pcVPS->getBaseLayerAvailableFlag() && !pcVPS->getBaseLayerInternalFlag()) ? true : false); |
---|
1023 | #endif |
---|
1024 | #else |
---|
1025 | READ_CODE( 2, uiCode, "vps_reserved_three_2bits" ); assert(uiCode == 3); |
---|
1026 | #endif |
---|
1027 | #if SVC_EXTENSION |
---|
1028 | #if O0137_MAX_LAYERID |
---|
1029 | READ_CODE( 6, uiCode, "vps_max_layers_minus1" ); pcVPS->setMaxLayers( min( 62u, uiCode) + 1 ); |
---|
1030 | #else |
---|
1031 | READ_CODE( 6, uiCode, "vps_max_layers_minus1" ); pcVPS->setMaxLayers( uiCode + 1 ); |
---|
1032 | #endif |
---|
1033 | assert( pcVPS->getBaseLayerInternalFlag() || pcVPS->getMaxLayers() > 1 ); |
---|
1034 | #else |
---|
1035 | READ_CODE( 6, uiCode, "vps_reserved_zero_6bits" ); assert(uiCode == 0); |
---|
1036 | #endif |
---|
1037 | READ_CODE( 3, uiCode, "vps_max_sub_layers_minus1" ); pcVPS->setMaxTLayers( uiCode + 1 ); assert(uiCode+1 <= MAX_TLAYER); |
---|
1038 | READ_FLAG( uiCode, "vps_temporal_id_nesting_flag" ); pcVPS->setTemporalNestingFlag( uiCode ? true:false ); |
---|
1039 | assert (pcVPS->getMaxTLayers()>1||pcVPS->getTemporalNestingFlag()); |
---|
1040 | #if !P0125_REVERT_VPS_EXTN_OFFSET_TO_RESERVED |
---|
1041 | #if VPS_EXTN_OFFSET |
---|
1042 | READ_CODE( 16, uiCode, "vps_extension_offset" ); pcVPS->setExtensionOffset( uiCode ); |
---|
1043 | #else |
---|
1044 | READ_CODE( 16, uiCode, "vps_reserved_ffff_16bits" ); assert(uiCode == 0xffff); |
---|
1045 | #endif |
---|
1046 | #else |
---|
1047 | READ_CODE( 16, uiCode, "vps_reserved_ffff_16bits" ); assert(uiCode == 0xffff); |
---|
1048 | #endif |
---|
1049 | parsePTL ( pcVPS->getPTL(), true, pcVPS->getMaxTLayers()-1); |
---|
1050 | UInt subLayerOrderingInfoPresentFlag; |
---|
1051 | READ_FLAG(subLayerOrderingInfoPresentFlag, "vps_sub_layer_ordering_info_present_flag"); |
---|
1052 | for(UInt i = 0; i <= pcVPS->getMaxTLayers()-1; i++) |
---|
1053 | { |
---|
1054 | READ_UVLC( uiCode, "vps_max_dec_pic_buffering_minus1[i]" ); pcVPS->setMaxDecPicBuffering( uiCode + 1, i ); |
---|
1055 | READ_UVLC( uiCode, "vps_num_reorder_pics[i]" ); pcVPS->setNumReorderPics( uiCode, i ); |
---|
1056 | READ_UVLC( uiCode, "vps_max_latency_increase_plus1[i]" ); pcVPS->setMaxLatencyIncrease( uiCode, i ); |
---|
1057 | |
---|
1058 | if (!subLayerOrderingInfoPresentFlag) |
---|
1059 | { |
---|
1060 | for (i++; i <= pcVPS->getMaxTLayers()-1; i++) |
---|
1061 | { |
---|
1062 | pcVPS->setMaxDecPicBuffering(pcVPS->getMaxDecPicBuffering(0), i); |
---|
1063 | pcVPS->setNumReorderPics(pcVPS->getNumReorderPics(0), i); |
---|
1064 | pcVPS->setMaxLatencyIncrease(pcVPS->getMaxLatencyIncrease(0), i); |
---|
1065 | } |
---|
1066 | break; |
---|
1067 | } |
---|
1068 | } |
---|
1069 | |
---|
1070 | #if SVC_EXTENSION |
---|
1071 | assert( pcVPS->getNumHrdParameters() < MAX_VPS_LAYER_SETS_PLUS1 ); |
---|
1072 | assert( pcVPS->getMaxLayerId() < MAX_VPS_LAYER_ID_PLUS1 ); |
---|
1073 | READ_CODE( 6, uiCode, "vps_max_layer_id" ); pcVPS->setMaxLayerId( uiCode ); |
---|
1074 | #if Q0078_ADD_LAYER_SETS |
---|
1075 | READ_UVLC(uiCode, "vps_num_layer_sets_minus1"); pcVPS->setVpsNumLayerSetsMinus1(uiCode); |
---|
1076 | pcVPS->setNumLayerSets(pcVPS->getVpsNumLayerSetsMinus1() + 1); |
---|
1077 | for (UInt opsIdx = 1; opsIdx <= pcVPS->getVpsNumLayerSetsMinus1(); opsIdx++) |
---|
1078 | #else |
---|
1079 | READ_UVLC( uiCode, "vps_num_layer_sets_minus1" ); pcVPS->setNumLayerSets( uiCode + 1 ); |
---|
1080 | for( UInt opsIdx = 1; opsIdx <= ( pcVPS->getNumLayerSets() - 1 ); opsIdx ++ ) |
---|
1081 | #endif |
---|
1082 | { |
---|
1083 | // Operation point set |
---|
1084 | for( UInt i = 0; i <= pcVPS->getMaxLayerId(); i ++ ) |
---|
1085 | #else |
---|
1086 | assert( pcVPS->getNumHrdParameters() < MAX_VPS_OP_SETS_PLUS1 ); |
---|
1087 | assert( pcVPS->getMaxNuhReservedZeroLayerId() < MAX_VPS_NUH_RESERVED_ZERO_LAYER_ID_PLUS1 ); |
---|
1088 | READ_CODE( 6, uiCode, "vps_max_nuh_reserved_zero_layer_id" ); pcVPS->setMaxNuhReservedZeroLayerId( uiCode ); |
---|
1089 | READ_UVLC( uiCode, "vps_max_op_sets_minus1" ); pcVPS->setMaxOpSets( uiCode + 1 ); |
---|
1090 | for( UInt opsIdx = 1; opsIdx <= ( pcVPS->getMaxOpSets() - 1 ); opsIdx ++ ) |
---|
1091 | { |
---|
1092 | // Operation point set |
---|
1093 | for( UInt i = 0; i <= pcVPS->getMaxNuhReservedZeroLayerId(); i ++ ) |
---|
1094 | #endif |
---|
1095 | { |
---|
1096 | READ_FLAG( uiCode, "layer_id_included_flag[opsIdx][i]" ); pcVPS->setLayerIdIncludedFlag( uiCode == 1 ? true : false, opsIdx, i ); |
---|
1097 | } |
---|
1098 | } |
---|
1099 | #if DERIVE_LAYER_ID_LIST_VARIABLES |
---|
1100 | pcVPS->deriveLayerIdListVariables(); |
---|
1101 | #endif |
---|
1102 | TimingInfo *timingInfo = pcVPS->getTimingInfo(); |
---|
1103 | READ_FLAG( uiCode, "vps_timing_info_present_flag"); timingInfo->setTimingInfoPresentFlag (uiCode ? true : false); |
---|
1104 | if(timingInfo->getTimingInfoPresentFlag()) |
---|
1105 | { |
---|
1106 | READ_CODE( 32, uiCode, "vps_num_units_in_tick"); timingInfo->setNumUnitsInTick (uiCode); |
---|
1107 | READ_CODE( 32, uiCode, "vps_time_scale"); timingInfo->setTimeScale (uiCode); |
---|
1108 | READ_FLAG( uiCode, "vps_poc_proportional_to_timing_flag"); timingInfo->setPocProportionalToTimingFlag(uiCode ? true : false); |
---|
1109 | if(timingInfo->getPocProportionalToTimingFlag()) |
---|
1110 | { |
---|
1111 | READ_UVLC( uiCode, "vps_num_ticks_poc_diff_one_minus1"); timingInfo->setNumTicksPocDiffOneMinus1 (uiCode); |
---|
1112 | } |
---|
1113 | |
---|
1114 | READ_UVLC( uiCode, "vps_num_hrd_parameters" ); pcVPS->setNumHrdParameters( uiCode ); |
---|
1115 | |
---|
1116 | if( pcVPS->getNumHrdParameters() > 0 ) |
---|
1117 | { |
---|
1118 | pcVPS->createHrdParamBuffer(); |
---|
1119 | } |
---|
1120 | for( UInt i = 0; i < pcVPS->getNumHrdParameters(); i ++ ) |
---|
1121 | { |
---|
1122 | READ_UVLC( uiCode, "hrd_op_set_idx" ); pcVPS->setHrdOpSetIdx( uiCode, i ); |
---|
1123 | if( i > 0 ) |
---|
1124 | { |
---|
1125 | READ_FLAG( uiCode, "cprms_present_flag[i]" ); pcVPS->setCprmsPresentFlag( uiCode == 1 ? true : false, i ); |
---|
1126 | } |
---|
1127 | else |
---|
1128 | { |
---|
1129 | pcVPS->setCprmsPresentFlag( true, i ); |
---|
1130 | } |
---|
1131 | |
---|
1132 | parseHrdParameters(pcVPS->getHrdParameters(i), pcVPS->getCprmsPresentFlag( i ), pcVPS->getMaxTLayers() - 1); |
---|
1133 | } |
---|
1134 | } |
---|
1135 | |
---|
1136 | #if SVC_EXTENSION |
---|
1137 | READ_FLAG( uiCode, "vps_extension_flag" ); pcVPS->setVpsExtensionFlag( uiCode ? true : false ); |
---|
1138 | |
---|
1139 | // When MaxLayersMinus1 is greater than 0, vps_extension_flag shall be equal to 1. |
---|
1140 | if( pcVPS->getMaxLayers() > 1 ) |
---|
1141 | { |
---|
1142 | assert( pcVPS->getVpsExtensionFlag() == true ); |
---|
1143 | } |
---|
1144 | |
---|
1145 | if( pcVPS->getVpsExtensionFlag() ) |
---|
1146 | { |
---|
1147 | while ( m_pcBitstream->getNumBitsRead() % 8 != 0 ) |
---|
1148 | { |
---|
1149 | READ_FLAG( uiCode, "vps_extension_alignment_bit_equal_to_one"); assert(uiCode == 1); |
---|
1150 | } |
---|
1151 | parseVPSExtension(pcVPS); |
---|
1152 | READ_FLAG( uiCode, "vps_entension2_flag" ); |
---|
1153 | if(uiCode) |
---|
1154 | { |
---|
1155 | while ( xMoreRbspData() ) |
---|
1156 | { |
---|
1157 | READ_FLAG( uiCode, "vps_extension_data_flag"); |
---|
1158 | } |
---|
1159 | } |
---|
1160 | } |
---|
1161 | else |
---|
1162 | { |
---|
1163 | // set default parameters when syntax elements are not present |
---|
1164 | defaultVPSExtension(pcVPS); |
---|
1165 | } |
---|
1166 | #else |
---|
1167 | READ_FLAG( uiCode, "vps_extension_flag" ); |
---|
1168 | if (uiCode) |
---|
1169 | { |
---|
1170 | while ( xMoreRbspData() ) |
---|
1171 | { |
---|
1172 | READ_FLAG( uiCode, "vps_extension_data_flag"); |
---|
1173 | } |
---|
1174 | } |
---|
1175 | #endif |
---|
1176 | |
---|
1177 | return; |
---|
1178 | } |
---|
1179 | |
---|
1180 | Void TDecCavlc::parseSliceHeader (TComSlice* pcSlice, ParameterSetManagerDecoder *parameterSetManager) |
---|
1181 | { |
---|
1182 | UInt uiCode; |
---|
1183 | Int iCode; |
---|
1184 | |
---|
1185 | #if ENC_DEC_TRACE |
---|
1186 | xTraceSliceHeader(pcSlice); |
---|
1187 | #endif |
---|
1188 | TComPPS* pps = NULL; |
---|
1189 | TComSPS* sps = NULL; |
---|
1190 | |
---|
1191 | UInt firstSliceSegmentInPic; |
---|
1192 | READ_FLAG( firstSliceSegmentInPic, "first_slice_segment_in_pic_flag" ); |
---|
1193 | if( pcSlice->getRapPicFlag()) |
---|
1194 | { |
---|
1195 | READ_FLAG( uiCode, "no_output_of_prior_pics_flag" ); //ignored -- updated already |
---|
1196 | pcSlice->setNoOutputPriorPicsFlag(uiCode ? true : false); |
---|
1197 | } |
---|
1198 | READ_UVLC ( uiCode, "slice_pic_parameter_set_id" ); pcSlice->setPPSId(uiCode); |
---|
1199 | pps = parameterSetManager->getPrefetchedPPS(uiCode); |
---|
1200 | //!KS: need to add error handling code here, if PPS is not available |
---|
1201 | assert(pps!=0); |
---|
1202 | sps = parameterSetManager->getPrefetchedSPS(pps->getSPSId()); |
---|
1203 | //!KS: need to add error handling code here, if SPS is not available |
---|
1204 | assert(sps!=0); |
---|
1205 | pcSlice->setSPS(sps); |
---|
1206 | pcSlice->setPPS(pps); |
---|
1207 | |
---|
1208 | const ChromaFormat chFmt = sps->getChromaFormatIdc(); |
---|
1209 | const UInt numValidComp=getNumberValidComponents(chFmt); |
---|
1210 | const Bool bChroma=(chFmt!=CHROMA_400); |
---|
1211 | |
---|
1212 | if( pps->getDependentSliceSegmentsEnabledFlag() && ( !firstSliceSegmentInPic )) |
---|
1213 | { |
---|
1214 | READ_FLAG( uiCode, "dependent_slice_segment_flag" ); pcSlice->setDependentSliceSegmentFlag(uiCode ? true : false); |
---|
1215 | } |
---|
1216 | else |
---|
1217 | { |
---|
1218 | pcSlice->setDependentSliceSegmentFlag(false); |
---|
1219 | } |
---|
1220 | #if REPN_FORMAT_IN_VPS |
---|
1221 | Int numCTUs = ((pcSlice->getPicWidthInLumaSamples()+sps->getMaxCUWidth()-1)/sps->getMaxCUWidth())*((pcSlice->getPicHeightInLumaSamples()+sps->getMaxCUHeight()-1)/sps->getMaxCUHeight()); |
---|
1222 | #else |
---|
1223 | Int numCTUs = ((sps->getPicWidthInLumaSamples()+sps->getMaxCUWidth()-1)/sps->getMaxCUWidth())*((sps->getPicHeightInLumaSamples()+sps->getMaxCUHeight()-1)/sps->getMaxCUHeight()); |
---|
1224 | #endif |
---|
1225 | UInt sliceSegmentAddress = 0; |
---|
1226 | Int bitsSliceSegmentAddress = 0; |
---|
1227 | while(numCTUs>(1<<bitsSliceSegmentAddress)) |
---|
1228 | { |
---|
1229 | bitsSliceSegmentAddress++; |
---|
1230 | } |
---|
1231 | |
---|
1232 | if(!firstSliceSegmentInPic) |
---|
1233 | { |
---|
1234 | READ_CODE( bitsSliceSegmentAddress, sliceSegmentAddress, "slice_segment_address" ); |
---|
1235 | } |
---|
1236 | //set uiCode to equal slice start address (or dependent slice start address) |
---|
1237 | pcSlice->setSliceSegmentCurStartCtuTsAddr( sliceSegmentAddress );// this is actually a Raster-Scan (RS) address, but we do not have the RS->TS conversion table defined yet. |
---|
1238 | pcSlice->setSliceSegmentCurEndCtuTsAddr(numCTUs); // Set end as the last CTU of the picture. |
---|
1239 | |
---|
1240 | if (!pcSlice->getDependentSliceSegmentFlag()) |
---|
1241 | { |
---|
1242 | pcSlice->setSliceCurStartCtuTsAddr(sliceSegmentAddress); // this is actually a Raster-Scan (RS) address, but we do not have the RS->TS conversion table defined yet. |
---|
1243 | pcSlice->setSliceCurEndCtuTsAddr(numCTUs); |
---|
1244 | } |
---|
1245 | |
---|
1246 | #if Q0142_POC_LSB_NOT_PRESENT |
---|
1247 | #if SHM_FIX7 |
---|
1248 | Int iPOClsb = 0; |
---|
1249 | #endif |
---|
1250 | #endif |
---|
1251 | |
---|
1252 | if(!pcSlice->getDependentSliceSegmentFlag()) |
---|
1253 | { |
---|
1254 | #if SVC_EXTENSION |
---|
1255 | #if POC_RESET_FLAG |
---|
1256 | Int iBits = 0; |
---|
1257 | if(pcSlice->getPPS()->getNumExtraSliceHeaderBits() > iBits) |
---|
1258 | { |
---|
1259 | READ_FLAG(uiCode, "poc_reset_flag"); pcSlice->setPocResetFlag( uiCode ? true : false ); |
---|
1260 | iBits++; |
---|
1261 | } |
---|
1262 | if(pcSlice->getPPS()->getNumExtraSliceHeaderBits() > iBits) |
---|
1263 | { |
---|
1264 | #if DISCARDABLE_PIC_RPS |
---|
1265 | READ_FLAG(uiCode, "discardable_flag"); pcSlice->setDiscardableFlag( uiCode ? true : false ); |
---|
1266 | #else |
---|
1267 | READ_FLAG(uiCode, "discardable_flag"); // ignored |
---|
1268 | #endif |
---|
1269 | iBits++; |
---|
1270 | } |
---|
1271 | #if O0149_CROSS_LAYER_BLA_FLAG |
---|
1272 | if(pcSlice->getPPS()->getNumExtraSliceHeaderBits() > iBits) |
---|
1273 | { |
---|
1274 | READ_FLAG(uiCode, "cross_layer_bla_flag"); pcSlice->setCrossLayerBLAFlag( uiCode ? true : false ); |
---|
1275 | iBits++; |
---|
1276 | } |
---|
1277 | #endif |
---|
1278 | for (; iBits < pcSlice->getPPS()->getNumExtraSliceHeaderBits(); iBits++) |
---|
1279 | { |
---|
1280 | READ_FLAG(uiCode, "slice_reserved_undetermined_flag[]"); // ignored |
---|
1281 | } |
---|
1282 | #else |
---|
1283 | #if CROSS_LAYER_BLA_FLAG_FIX |
---|
1284 | Int iBits = 0; |
---|
1285 | if(pcSlice->getPPS()->getNumExtraSliceHeaderBits() > iBits) |
---|
1286 | #else |
---|
1287 | if(pcSlice->getPPS()->getNumExtraSliceHeaderBits()>0) |
---|
1288 | #endif |
---|
1289 | { |
---|
1290 | READ_FLAG(uiCode, "discardable_flag"); // ignored |
---|
1291 | #if NON_REF_NAL_TYPE_DISCARDABLE |
---|
1292 | pcSlice->setDiscardableFlag( uiCode ? true : false ); |
---|
1293 | if (uiCode) |
---|
1294 | { |
---|
1295 | assert(pcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_TRAIL_R && |
---|
1296 | pcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_TSA_R && |
---|
1297 | pcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_STSA_R && |
---|
1298 | pcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_RADL_R && |
---|
1299 | pcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_RASL_R); |
---|
1300 | } |
---|
1301 | #endif |
---|
1302 | #if CROSS_LAYER_BLA_FLAG_FIX |
---|
1303 | iBits++; |
---|
1304 | #endif |
---|
1305 | } |
---|
1306 | #if CROSS_LAYER_BLA_FLAG_FIX |
---|
1307 | if(pcSlice->getPPS()->getNumExtraSliceHeaderBits() > iBits) |
---|
1308 | { |
---|
1309 | READ_FLAG(uiCode, "cross_layer_bla_flag"); pcSlice->setCrossLayerBLAFlag( uiCode ? true : false ); |
---|
1310 | iBits++; |
---|
1311 | } |
---|
1312 | for ( ; iBits < pcSlice->getPPS()->getNumExtraSliceHeaderBits(); iBits++) |
---|
1313 | #else |
---|
1314 | for (Int i = 1; i < pcSlice->getPPS()->getNumExtraSliceHeaderBits(); i++) |
---|
1315 | #endif |
---|
1316 | { |
---|
1317 | READ_FLAG(uiCode, "slice_reserved_undetermined_flag[]"); // ignored |
---|
1318 | } |
---|
1319 | #endif |
---|
1320 | #else //SVC_EXTENSION |
---|
1321 | for (Int i = 0; i < pcSlice->getPPS()->getNumExtraSliceHeaderBits(); i++) |
---|
1322 | { |
---|
1323 | READ_FLAG(uiCode, "slice_reserved_undetermined_flag[]"); // ignored |
---|
1324 | } |
---|
1325 | #endif //SVC_EXTENSION |
---|
1326 | |
---|
1327 | READ_UVLC ( uiCode, "slice_type" ); pcSlice->setSliceType((SliceType)uiCode); |
---|
1328 | if( pps->getOutputFlagPresentFlag() ) |
---|
1329 | { |
---|
1330 | READ_FLAG( uiCode, "pic_output_flag" ); pcSlice->setPicOutputFlag( uiCode ? true : false ); |
---|
1331 | } |
---|
1332 | else |
---|
1333 | { |
---|
1334 | pcSlice->setPicOutputFlag( true ); |
---|
1335 | } |
---|
1336 | |
---|
1337 | if( pcSlice->getIdrPicFlag() ) |
---|
1338 | { |
---|
1339 | pcSlice->setPOC(0); |
---|
1340 | TComReferencePictureSet* rps = pcSlice->getLocalRPS(); |
---|
1341 | rps->setNumberOfNegativePictures(0); |
---|
1342 | rps->setNumberOfPositivePictures(0); |
---|
1343 | rps->setNumberOfLongtermPictures(0); |
---|
1344 | rps->setNumberOfPictures(0); |
---|
1345 | pcSlice->setRPS(rps); |
---|
1346 | } |
---|
1347 | #if N0065_LAYER_POC_ALIGNMENT |
---|
1348 | #if O0062_POC_LSB_NOT_PRESENT_FLAG |
---|
1349 | if( ( pcSlice->getLayerId() > 0 && !pcSlice->getVPS()->getPocLsbNotPresentFlag( pcSlice->getVPS()->getLayerIdInVps(pcSlice->getLayerId())) ) || !pcSlice->getIdrPicFlag() ) |
---|
1350 | #else |
---|
1351 | if( pcSlice->getLayerId() > 0 || !pcSlice->getIdrPicFlag() ) |
---|
1352 | #endif |
---|
1353 | #else |
---|
1354 | else |
---|
1355 | #endif |
---|
1356 | { |
---|
1357 | READ_CODE(sps->getBitsForPOC(), uiCode, "pic_order_cnt_lsb"); |
---|
1358 | #if POC_RESET_IDC_DECODER |
---|
1359 | pcSlice->setPicOrderCntLsb( uiCode ); |
---|
1360 | #endif |
---|
1361 | #if SVC_EXTENSION |
---|
1362 | iPOClsb = uiCode; |
---|
1363 | #else |
---|
1364 | Int iPOClsb = uiCode; |
---|
1365 | #endif |
---|
1366 | Int iPrevPOC = pcSlice->getPrevTid0POC(); |
---|
1367 | Int iMaxPOClsb = 1<< sps->getBitsForPOC(); |
---|
1368 | Int iPrevPOClsb = iPrevPOC & (iMaxPOClsb - 1); |
---|
1369 | Int iPrevPOCmsb = iPrevPOC-iPrevPOClsb; |
---|
1370 | Int iPOCmsb; |
---|
1371 | if( ( iPOClsb < iPrevPOClsb ) && ( ( iPrevPOClsb - iPOClsb ) >= ( iMaxPOClsb / 2 ) ) ) |
---|
1372 | { |
---|
1373 | iPOCmsb = iPrevPOCmsb + iMaxPOClsb; |
---|
1374 | } |
---|
1375 | else if( (iPOClsb > iPrevPOClsb ) && ( (iPOClsb - iPrevPOClsb ) > ( iMaxPOClsb / 2 ) ) ) |
---|
1376 | { |
---|
1377 | iPOCmsb = iPrevPOCmsb - iMaxPOClsb; |
---|
1378 | } |
---|
1379 | else |
---|
1380 | { |
---|
1381 | iPOCmsb = iPrevPOCmsb; |
---|
1382 | } |
---|
1383 | if ( pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP |
---|
1384 | || pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL |
---|
1385 | || pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP ) |
---|
1386 | { |
---|
1387 | // For BLA picture types, POCmsb is set to 0. |
---|
1388 | iPOCmsb = 0; |
---|
1389 | } |
---|
1390 | pcSlice->setPOC (iPOCmsb+iPOClsb); |
---|
1391 | |
---|
1392 | #if N0065_LAYER_POC_ALIGNMENT |
---|
1393 | } |
---|
1394 | #if POC_RESET_IDC_DECODER |
---|
1395 | else |
---|
1396 | { |
---|
1397 | pcSlice->setPicOrderCntLsb( 0 ); |
---|
1398 | } |
---|
1399 | #endif |
---|
1400 | if( !pcSlice->getIdrPicFlag() ) |
---|
1401 | { |
---|
1402 | #endif |
---|
1403 | TComReferencePictureSet* rps; |
---|
1404 | rps = pcSlice->getLocalRPS(); |
---|
1405 | pcSlice->setRPS(rps); |
---|
1406 | READ_FLAG( uiCode, "short_term_ref_pic_set_sps_flag" ); |
---|
1407 | if(uiCode == 0) // use short-term reference picture set explicitly signalled in slice header |
---|
1408 | { |
---|
1409 | parseShortTermRefPicSet(sps,rps, sps->getRPSList()->getNumberOfReferencePictureSets()); |
---|
1410 | } |
---|
1411 | else // use reference to short-term reference picture set in PPS |
---|
1412 | { |
---|
1413 | Int numBits = 0; |
---|
1414 | while ((1 << numBits) < pcSlice->getSPS()->getRPSList()->getNumberOfReferencePictureSets()) |
---|
1415 | { |
---|
1416 | numBits++; |
---|
1417 | } |
---|
1418 | if (numBits > 0) |
---|
1419 | { |
---|
1420 | READ_CODE( numBits, uiCode, "short_term_ref_pic_set_idx"); |
---|
1421 | } |
---|
1422 | else |
---|
1423 | { |
---|
1424 | uiCode = 0; |
---|
1425 | |
---|
1426 | } |
---|
1427 | *rps = *(sps->getRPSList()->getReferencePictureSet(uiCode)); |
---|
1428 | } |
---|
1429 | if(sps->getLongTermRefsPresent()) |
---|
1430 | { |
---|
1431 | Int offset = rps->getNumberOfNegativePictures()+rps->getNumberOfPositivePictures(); |
---|
1432 | UInt numOfLtrp = 0; |
---|
1433 | UInt numLtrpInSPS = 0; |
---|
1434 | if (pcSlice->getSPS()->getNumLongTermRefPicSPS() > 0) |
---|
1435 | { |
---|
1436 | READ_UVLC( uiCode, "num_long_term_sps"); |
---|
1437 | numLtrpInSPS = uiCode; |
---|
1438 | numOfLtrp += numLtrpInSPS; |
---|
1439 | rps->setNumberOfLongtermPictures(numOfLtrp); |
---|
1440 | } |
---|
1441 | Int bitsForLtrpInSPS = 0; |
---|
1442 | while (pcSlice->getSPS()->getNumLongTermRefPicSPS() > (1 << bitsForLtrpInSPS)) |
---|
1443 | { |
---|
1444 | bitsForLtrpInSPS++; |
---|
1445 | } |
---|
1446 | READ_UVLC( uiCode, "num_long_term_pics"); rps->setNumberOfLongtermPictures(uiCode); |
---|
1447 | numOfLtrp += uiCode; |
---|
1448 | rps->setNumberOfLongtermPictures(numOfLtrp); |
---|
1449 | Int maxPicOrderCntLSB = 1 << pcSlice->getSPS()->getBitsForPOC(); |
---|
1450 | Int prevDeltaMSB = 0, deltaPocMSBCycleLT = 0; |
---|
1451 | for(Int j=offset+rps->getNumberOfLongtermPictures()-1, k = 0; k < numOfLtrp; j--, k++) |
---|
1452 | { |
---|
1453 | Int pocLsbLt; |
---|
1454 | if (k < numLtrpInSPS) |
---|
1455 | { |
---|
1456 | uiCode = 0; |
---|
1457 | if (bitsForLtrpInSPS > 0) |
---|
1458 | { |
---|
1459 | READ_CODE(bitsForLtrpInSPS, uiCode, "lt_idx_sps[i]"); |
---|
1460 | } |
---|
1461 | Int usedByCurrFromSPS=pcSlice->getSPS()->getUsedByCurrPicLtSPSFlag(uiCode); |
---|
1462 | |
---|
1463 | pocLsbLt = pcSlice->getSPS()->getLtRefPicPocLsbSps(uiCode); |
---|
1464 | rps->setUsed(j,usedByCurrFromSPS); |
---|
1465 | } |
---|
1466 | else |
---|
1467 | { |
---|
1468 | READ_CODE(pcSlice->getSPS()->getBitsForPOC(), uiCode, "poc_lsb_lt"); pocLsbLt= uiCode; |
---|
1469 | READ_FLAG( uiCode, "used_by_curr_pic_lt_flag"); rps->setUsed(j,uiCode); |
---|
1470 | } |
---|
1471 | READ_FLAG(uiCode,"delta_poc_msb_present_flag"); |
---|
1472 | Bool mSBPresentFlag = uiCode ? true : false; |
---|
1473 | if(mSBPresentFlag) |
---|
1474 | { |
---|
1475 | READ_UVLC( uiCode, "delta_poc_msb_cycle_lt[i]" ); |
---|
1476 | Bool deltaFlag = false; |
---|
1477 | // First LTRP || First LTRP from SH |
---|
1478 | if( (j == offset+rps->getNumberOfLongtermPictures()-1) || (j == offset+(numOfLtrp-numLtrpInSPS)-1) ) |
---|
1479 | { |
---|
1480 | deltaFlag = true; |
---|
1481 | } |
---|
1482 | if(deltaFlag) |
---|
1483 | { |
---|
1484 | deltaPocMSBCycleLT = uiCode; |
---|
1485 | } |
---|
1486 | else |
---|
1487 | { |
---|
1488 | deltaPocMSBCycleLT = uiCode + prevDeltaMSB; |
---|
1489 | } |
---|
1490 | |
---|
1491 | Int pocLTCurr = pcSlice->getPOC() - deltaPocMSBCycleLT * maxPicOrderCntLSB |
---|
1492 | - iPOClsb + pocLsbLt; |
---|
1493 | rps->setPOC (j, pocLTCurr); |
---|
1494 | rps->setDeltaPOC(j, - pcSlice->getPOC() + pocLTCurr); |
---|
1495 | rps->setCheckLTMSBPresent(j,true); |
---|
1496 | } |
---|
1497 | else |
---|
1498 | { |
---|
1499 | rps->setPOC (j, pocLsbLt); |
---|
1500 | rps->setDeltaPOC(j, - pcSlice->getPOC() + pocLsbLt); |
---|
1501 | rps->setCheckLTMSBPresent(j,false); |
---|
1502 | |
---|
1503 | // reset deltaPocMSBCycleLT for first LTRP from slice header if MSB not present |
---|
1504 | if( j == offset+(numOfLtrp-numLtrpInSPS)-1 ) |
---|
1505 | { |
---|
1506 | deltaPocMSBCycleLT = 0; |
---|
1507 | } |
---|
1508 | } |
---|
1509 | prevDeltaMSB = deltaPocMSBCycleLT; |
---|
1510 | } |
---|
1511 | offset += rps->getNumberOfLongtermPictures(); |
---|
1512 | rps->setNumberOfPictures(offset); |
---|
1513 | } |
---|
1514 | #if DPB_CONSTRAINTS |
---|
1515 | if(pcSlice->getVPS()->getVpsExtensionFlag()==1) |
---|
1516 | { |
---|
1517 | #if Q0078_ADD_LAYER_SETS |
---|
1518 | for (Int ii = 1; ii < (pcSlice->getVPS()->getVpsNumLayerSetsMinus1() + 1); ii++) // prevent assert error when num_add_layer_sets > 0 |
---|
1519 | #else |
---|
1520 | for (Int ii=1; ii< pcSlice->getVPS()->getNumOutputLayerSets(); ii++ ) |
---|
1521 | #endif |
---|
1522 | { |
---|
1523 | Int layerSetIdxForOutputLayerSet = pcSlice->getVPS()->getOutputLayerSetIdx( ii ); |
---|
1524 | Int chkAssert=0; |
---|
1525 | for(Int kk = 0; kk < pcSlice->getVPS()->getNumLayersInIdList(layerSetIdxForOutputLayerSet); kk++) |
---|
1526 | { |
---|
1527 | #if R0235_SMALLEST_LAYER_ID |
---|
1528 | if( pcSlice->getVPS()->getNecessaryLayerFlag(ii, kk) && pcSlice->getLayerId() == pcSlice->getVPS()->getLayerSetLayerIdList(layerSetIdxForOutputLayerSet, kk) ) |
---|
1529 | #else |
---|
1530 | if(pcSlice->getLayerId() == pcSlice->getVPS()->getLayerSetLayerIdList(layerSetIdxForOutputLayerSet, kk)) |
---|
1531 | #endif |
---|
1532 | { |
---|
1533 | chkAssert=1; |
---|
1534 | } |
---|
1535 | } |
---|
1536 | if(chkAssert) |
---|
1537 | { |
---|
1538 | // There may be something wrong here (layer id assumed to be layer idx?) |
---|
1539 | assert(rps->getNumberOfNegativePictures() <= pcSlice->getVPS()->getMaxVpsDecPicBufferingMinus1(ii , pcSlice->getLayerId() , pcSlice->getVPS()->getMaxSLayersInLayerSetMinus1(ii))); |
---|
1540 | assert(rps->getNumberOfPositivePictures() <= pcSlice->getVPS()->getMaxVpsDecPicBufferingMinus1(ii , pcSlice->getLayerId() , pcSlice->getVPS()->getMaxSLayersInLayerSetMinus1(ii)) - rps->getNumberOfNegativePictures()); |
---|
1541 | assert((rps->getNumberOfPositivePictures() + rps->getNumberOfNegativePictures() + rps->getNumberOfLongtermPictures()) <= pcSlice->getVPS()->getMaxVpsDecPicBufferingMinus1(ii , pcSlice->getLayerId() , pcSlice->getVPS()->getMaxSLayersInLayerSetMinus1(ii))); |
---|
1542 | } |
---|
1543 | } |
---|
1544 | |
---|
1545 | |
---|
1546 | } |
---|
1547 | if(pcSlice->getLayerId() == 0) |
---|
1548 | { |
---|
1549 | assert(rps->getNumberOfNegativePictures() <= pcSlice->getSPS()->getMaxDecPicBuffering(pcSlice->getSPS()->getMaxTLayers()-1) ); |
---|
1550 | assert(rps->getNumberOfPositivePictures() <= pcSlice->getSPS()->getMaxDecPicBuffering(pcSlice->getSPS()->getMaxTLayers()-1) -rps->getNumberOfNegativePictures()); |
---|
1551 | assert((rps->getNumberOfPositivePictures() + rps->getNumberOfNegativePictures() + rps->getNumberOfLongtermPictures()) <= pcSlice->getSPS()->getMaxDecPicBuffering(pcSlice->getSPS()->getMaxTLayers()-1)); |
---|
1552 | } |
---|
1553 | #endif |
---|
1554 | if ( pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP |
---|
1555 | || pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL |
---|
1556 | || pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP ) |
---|
1557 | { |
---|
1558 | // In the case of BLA picture types, rps data is read from slice header but ignored |
---|
1559 | rps = pcSlice->getLocalRPS(); |
---|
1560 | rps->setNumberOfNegativePictures(0); |
---|
1561 | rps->setNumberOfPositivePictures(0); |
---|
1562 | rps->setNumberOfLongtermPictures(0); |
---|
1563 | rps->setNumberOfPictures(0); |
---|
1564 | pcSlice->setRPS(rps); |
---|
1565 | } |
---|
1566 | if (pcSlice->getSPS()->getTMVPFlagsPresent()) |
---|
1567 | { |
---|
1568 | READ_FLAG( uiCode, "slice_temporal_mvp_enable_flag" ); |
---|
1569 | pcSlice->setEnableTMVPFlag( uiCode == 1 ? true : false ); |
---|
1570 | } |
---|
1571 | else |
---|
1572 | { |
---|
1573 | pcSlice->setEnableTMVPFlag(false); |
---|
1574 | } |
---|
1575 | } |
---|
1576 | |
---|
1577 | #if SVC_EXTENSION |
---|
1578 | pcSlice->setActiveNumILRRefIdx(0); |
---|
1579 | if((pcSlice->getLayerId() > 0) && !(pcSlice->getVPS()->getIlpSshSignalingEnabledFlag()) && (pcSlice->getNumILRRefIdx() > 0) ) |
---|
1580 | { |
---|
1581 | READ_FLAG(uiCode,"inter_layer_pred_enabled_flag"); |
---|
1582 | pcSlice->setInterLayerPredEnabledFlag(uiCode); |
---|
1583 | if( pcSlice->getInterLayerPredEnabledFlag()) |
---|
1584 | { |
---|
1585 | if(pcSlice->getNumILRRefIdx() > 1) |
---|
1586 | { |
---|
1587 | Int numBits = 1; |
---|
1588 | while ((1 << numBits) < pcSlice->getNumILRRefIdx()) |
---|
1589 | { |
---|
1590 | numBits++; |
---|
1591 | } |
---|
1592 | if( !pcSlice->getVPS()->getMaxOneActiveRefLayerFlag()) |
---|
1593 | { |
---|
1594 | READ_CODE( numBits, uiCode,"num_inter_layer_ref_pics_minus1" ); |
---|
1595 | pcSlice->setActiveNumILRRefIdx(uiCode + 1); |
---|
1596 | } |
---|
1597 | else |
---|
1598 | { |
---|
1599 | #if P0079_DERIVE_NUMACTIVE_REF_PICS |
---|
1600 | for( Int i = 0; i < pcSlice->getNumILRRefIdx(); i++ ) |
---|
1601 | { |
---|
1602 | #if Q0060_MAX_TID_REF_EQUAL_TO_ZERO |
---|
1603 | if((pcSlice->getVPS()->getMaxTidIlRefPicsPlus1(pcSlice->getVPS()->getLayerIdInVps(i),pcSlice->getLayerId()) > pcSlice->getTLayer() || pcSlice->getTLayer()==0) && |
---|
1604 | (pcSlice->getVPS()->getMaxTSLayersMinus1(pcSlice->getVPS()->getLayerIdInVps(i)) >= pcSlice->getTLayer()) ) |
---|
1605 | #else |
---|
1606 | if(pcSlice->getVPS()->getMaxTidIlRefPicsPlus1(pcSlice->getVPS()->getLayerIdInVps(i),pcSlice->getLayerId()) > pcSlice->getTLayer() && |
---|
1607 | (pcSlice->getVPS()->getMaxTSLayersMinus1(pcSlice->getVPS()->getLayerIdInVps(i)) >= pcSlice->getTLayer()) ) |
---|
1608 | #endif |
---|
1609 | { |
---|
1610 | pcSlice->setActiveNumILRRefIdx(1); |
---|
1611 | break; |
---|
1612 | } |
---|
1613 | } |
---|
1614 | #else |
---|
1615 | pcSlice->setActiveNumILRRefIdx(1); |
---|
1616 | #endif |
---|
1617 | } |
---|
1618 | |
---|
1619 | if( pcSlice->getActiveNumILRRefIdx() == pcSlice->getNumILRRefIdx() ) |
---|
1620 | { |
---|
1621 | for( Int i = 0; i < pcSlice->getActiveNumILRRefIdx(); i++ ) |
---|
1622 | { |
---|
1623 | pcSlice->setInterLayerPredLayerIdc(i,i); |
---|
1624 | } |
---|
1625 | } |
---|
1626 | else |
---|
1627 | { |
---|
1628 | for(Int i = 0; i < pcSlice->getActiveNumILRRefIdx(); i++ ) |
---|
1629 | { |
---|
1630 | READ_CODE( numBits,uiCode,"inter_layer_pred_layer_idc[i]" ); |
---|
1631 | pcSlice->setInterLayerPredLayerIdc(uiCode,i); |
---|
1632 | } |
---|
1633 | } |
---|
1634 | } |
---|
1635 | else |
---|
1636 | { |
---|
1637 | #if O0225_TID_BASED_IL_RPS_DERIV && TSLAYERS_IL_RPS |
---|
1638 | #if Q0060_MAX_TID_REF_EQUAL_TO_ZERO |
---|
1639 | if((pcSlice->getVPS()->getMaxTidIlRefPicsPlus1(0,pcSlice->getLayerId()) > pcSlice->getTLayer() || pcSlice->getTLayer()==0) && |
---|
1640 | (pcSlice->getVPS()->getMaxTSLayersMinus1(0) >= pcSlice->getTLayer()) ) |
---|
1641 | #else |
---|
1642 | if( (pcSlice->getVPS()->getMaxTidIlRefPicsPlus1(0,pcSlice->getLayerId()) > pcSlice->getTLayer()) && |
---|
1643 | (pcSlice->getVPS()->getMaxTSLayersMinus1(0) >= pcSlice->getTLayer()) ) |
---|
1644 | #endif |
---|
1645 | { |
---|
1646 | #endif |
---|
1647 | pcSlice->setActiveNumILRRefIdx(1); |
---|
1648 | pcSlice->setInterLayerPredLayerIdc(0,0); |
---|
1649 | #if O0225_TID_BASED_IL_RPS_DERIV && TSLAYERS_IL_RPS |
---|
1650 | } |
---|
1651 | #endif |
---|
1652 | } |
---|
1653 | } |
---|
1654 | } |
---|
1655 | else if( pcSlice->getVPS()->getIlpSshSignalingEnabledFlag() == true && (pcSlice->getLayerId() > 0 )) |
---|
1656 | { |
---|
1657 | pcSlice->setInterLayerPredEnabledFlag(true); |
---|
1658 | |
---|
1659 | #if O0225_TID_BASED_IL_RPS_DERIV && TSLAYERS_IL_RPS |
---|
1660 | Int numRefLayerPics = 0; |
---|
1661 | Int i = 0; |
---|
1662 | Int refLayerPicIdc [MAX_VPS_LAYER_ID_PLUS1]; |
---|
1663 | for(i = 0, numRefLayerPics = 0; i < pcSlice->getNumILRRefIdx(); i++ ) |
---|
1664 | { |
---|
1665 | #if Q0060_MAX_TID_REF_EQUAL_TO_ZERO |
---|
1666 | if((pcSlice->getVPS()->getMaxTidIlRefPicsPlus1(pcSlice->getVPS()->getLayerIdInVps(i),pcSlice->getLayerId()) > pcSlice->getTLayer() || pcSlice->getTLayer()==0) && |
---|
1667 | (pcSlice->getVPS()->getMaxTSLayersMinus1(pcSlice->getVPS()->getLayerIdInVps(i)) >= pcSlice->getTLayer()) ) |
---|
1668 | #else |
---|
1669 | if(pcSlice->getVPS()->getMaxTidIlRefPicsPlus1(pcSlice->getVPS()->getLayerIdInVps(i),pcSlice->getLayerId()) > pcSlice->getTLayer() && |
---|
1670 | (pcSlice->getVPS()->getMaxTSLayersMinus1(pcSlice->getVPS()->getLayerIdInVps(i)) >= pcSlice->getTLayer()) ) |
---|
1671 | #endif |
---|
1672 | { |
---|
1673 | refLayerPicIdc[ numRefLayerPics++ ] = i; |
---|
1674 | } |
---|
1675 | } |
---|
1676 | pcSlice->setActiveNumILRRefIdx(numRefLayerPics); |
---|
1677 | for( i = 0; i < pcSlice->getActiveNumILRRefIdx(); i++ ) |
---|
1678 | { |
---|
1679 | pcSlice->setInterLayerPredLayerIdc(refLayerPicIdc[i],i); |
---|
1680 | } |
---|
1681 | #else |
---|
1682 | pcSlice->setActiveNumILRRefIdx(pcSlice->getNumILRRefIdx()); |
---|
1683 | for( Int i = 0; i < pcSlice->getActiveNumILRRefIdx(); i++ ) |
---|
1684 | { |
---|
1685 | pcSlice->setInterLayerPredLayerIdc(i,i); |
---|
1686 | } |
---|
1687 | #endif |
---|
1688 | } |
---|
1689 | #if P0312_VERT_PHASE_ADJ |
---|
1690 | for(Int i = 0; i < pcSlice->getActiveNumILRRefIdx(); i++ ) |
---|
1691 | { |
---|
1692 | UInt refLayerIdc = pcSlice->getInterLayerPredLayerIdc(i); |
---|
1693 | #if !MOVE_SCALED_OFFSET_TO_PPS |
---|
1694 | if( pcSlice->getSPS()->getVertPhasePositionEnableFlag(refLayerIdc) ) |
---|
1695 | #else |
---|
1696 | if( pcSlice->getPPS()->getVertPhasePositionEnableFlag(refLayerIdc) ) |
---|
1697 | #endif |
---|
1698 | { |
---|
1699 | READ_FLAG( uiCode, "vert_phase_position_flag" ); pcSlice->setVertPhasePositionFlag( uiCode? true : false, refLayerIdc ); |
---|
1700 | } |
---|
1701 | } |
---|
1702 | #endif |
---|
1703 | #endif //SVC_EXTENSION |
---|
1704 | |
---|
1705 | if(sps->getUseSAO()) |
---|
1706 | { |
---|
1707 | READ_FLAG(uiCode, "slice_sao_luma_flag"); pcSlice->setSaoEnabledFlag(CHANNEL_TYPE_LUMA, (Bool)uiCode); |
---|
1708 | #if SVC_EXTENSION |
---|
1709 | ChromaFormat format; |
---|
1710 | if( sps->getLayerId() == 0 ) |
---|
1711 | { |
---|
1712 | format = sps->getChromaFormatIdc(); |
---|
1713 | } |
---|
1714 | else |
---|
1715 | { |
---|
1716 | format = pcSlice->getVPS()->getVpsRepFormat( sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : pcSlice->getVPS()->getVpsRepFormatIdx( pcSlice->getVPS()->getLayerIdInVps(sps->getLayerId()) ) )->getChromaFormatVpsIdc(); |
---|
1717 | #if Q0195_REP_FORMAT_CLEANUP |
---|
1718 | assert( (sps->getUpdateRepFormatFlag()==false && pcSlice->getVPS()->getVpsNumRepFormats()==1) || pcSlice->getVPS()->getVpsNumRepFormats() > 1 ); //conformance check |
---|
1719 | #endif |
---|
1720 | } |
---|
1721 | if (format != CHROMA_400) |
---|
1722 | #else |
---|
1723 | if (bChroma) |
---|
1724 | #endif |
---|
1725 | { |
---|
1726 | READ_FLAG(uiCode, "slice_sao_chroma_flag"); pcSlice->setSaoEnabledFlag(CHANNEL_TYPE_CHROMA, (Bool)uiCode); |
---|
1727 | } |
---|
1728 | #if SVC_EXTENSION |
---|
1729 | else |
---|
1730 | { |
---|
1731 | pcSlice->setSaoEnabledFlag(CHANNEL_TYPE_CHROMA, false); |
---|
1732 | } |
---|
1733 | #endif |
---|
1734 | } |
---|
1735 | |
---|
1736 | if (pcSlice->getIdrPicFlag()) |
---|
1737 | { |
---|
1738 | pcSlice->setEnableTMVPFlag(false); |
---|
1739 | } |
---|
1740 | if (!pcSlice->isIntra()) |
---|
1741 | { |
---|
1742 | |
---|
1743 | READ_FLAG( uiCode, "num_ref_idx_active_override_flag"); |
---|
1744 | if (uiCode) |
---|
1745 | { |
---|
1746 | READ_UVLC (uiCode, "num_ref_idx_l0_active_minus1" ); pcSlice->setNumRefIdx( REF_PIC_LIST_0, uiCode + 1 ); |
---|
1747 | if (pcSlice->isInterB()) |
---|
1748 | { |
---|
1749 | READ_UVLC (uiCode, "num_ref_idx_l1_active_minus1" ); pcSlice->setNumRefIdx( REF_PIC_LIST_1, uiCode + 1 ); |
---|
1750 | } |
---|
1751 | else |
---|
1752 | { |
---|
1753 | pcSlice->setNumRefIdx(REF_PIC_LIST_1, 0); |
---|
1754 | } |
---|
1755 | } |
---|
1756 | else |
---|
1757 | { |
---|
1758 | pcSlice->setNumRefIdx(REF_PIC_LIST_0, pcSlice->getPPS()->getNumRefIdxL0DefaultActive()); |
---|
1759 | if (pcSlice->isInterB()) |
---|
1760 | { |
---|
1761 | pcSlice->setNumRefIdx(REF_PIC_LIST_1, pcSlice->getPPS()->getNumRefIdxL1DefaultActive()); |
---|
1762 | } |
---|
1763 | else |
---|
1764 | { |
---|
1765 | pcSlice->setNumRefIdx(REF_PIC_LIST_1,0); |
---|
1766 | } |
---|
1767 | } |
---|
1768 | } |
---|
1769 | // } |
---|
1770 | TComRefPicListModification* refPicListModification = pcSlice->getRefPicListModification(); |
---|
1771 | if(!pcSlice->isIntra()) |
---|
1772 | { |
---|
1773 | if( !pcSlice->getPPS()->getListsModificationPresentFlag() || pcSlice->getNumRpsCurrTempList() <= 1 ) |
---|
1774 | { |
---|
1775 | refPicListModification->setRefPicListModificationFlagL0( 0 ); |
---|
1776 | } |
---|
1777 | else |
---|
1778 | { |
---|
1779 | READ_FLAG( uiCode, "ref_pic_list_modification_flag_l0" ); refPicListModification->setRefPicListModificationFlagL0( uiCode ? 1 : 0 ); |
---|
1780 | } |
---|
1781 | |
---|
1782 | if(refPicListModification->getRefPicListModificationFlagL0()) |
---|
1783 | { |
---|
1784 | uiCode = 0; |
---|
1785 | Int i = 0; |
---|
1786 | Int numRpsCurrTempList0 = pcSlice->getNumRpsCurrTempList(); |
---|
1787 | if ( numRpsCurrTempList0 > 1 ) |
---|
1788 | { |
---|
1789 | Int length = 1; |
---|
1790 | numRpsCurrTempList0 --; |
---|
1791 | while ( numRpsCurrTempList0 >>= 1) |
---|
1792 | { |
---|
1793 | length ++; |
---|
1794 | } |
---|
1795 | for (i = 0; i < pcSlice->getNumRefIdx(REF_PIC_LIST_0); i ++) |
---|
1796 | { |
---|
1797 | READ_CODE( length, uiCode, "list_entry_l0" ); |
---|
1798 | refPicListModification->setRefPicSetIdxL0(i, uiCode ); |
---|
1799 | } |
---|
1800 | } |
---|
1801 | else |
---|
1802 | { |
---|
1803 | for (i = 0; i < pcSlice->getNumRefIdx(REF_PIC_LIST_0); i ++) |
---|
1804 | { |
---|
1805 | refPicListModification->setRefPicSetIdxL0(i, 0 ); |
---|
1806 | } |
---|
1807 | } |
---|
1808 | } |
---|
1809 | } |
---|
1810 | else |
---|
1811 | { |
---|
1812 | refPicListModification->setRefPicListModificationFlagL0(0); |
---|
1813 | } |
---|
1814 | if(pcSlice->isInterB()) |
---|
1815 | { |
---|
1816 | if( !pcSlice->getPPS()->getListsModificationPresentFlag() || pcSlice->getNumRpsCurrTempList() <= 1 ) |
---|
1817 | { |
---|
1818 | refPicListModification->setRefPicListModificationFlagL1( 0 ); |
---|
1819 | } |
---|
1820 | else |
---|
1821 | { |
---|
1822 | READ_FLAG( uiCode, "ref_pic_list_modification_flag_l1" ); refPicListModification->setRefPicListModificationFlagL1( uiCode ? 1 : 0 ); |
---|
1823 | } |
---|
1824 | if(refPicListModification->getRefPicListModificationFlagL1()) |
---|
1825 | { |
---|
1826 | uiCode = 0; |
---|
1827 | Int i = 0; |
---|
1828 | Int numRpsCurrTempList1 = pcSlice->getNumRpsCurrTempList(); |
---|
1829 | if ( numRpsCurrTempList1 > 1 ) |
---|
1830 | { |
---|
1831 | Int length = 1; |
---|
1832 | numRpsCurrTempList1 --; |
---|
1833 | while ( numRpsCurrTempList1 >>= 1) |
---|
1834 | { |
---|
1835 | length ++; |
---|
1836 | } |
---|
1837 | for (i = 0; i < pcSlice->getNumRefIdx(REF_PIC_LIST_1); i ++) |
---|
1838 | { |
---|
1839 | READ_CODE( length, uiCode, "list_entry_l1" ); |
---|
1840 | refPicListModification->setRefPicSetIdxL1(i, uiCode ); |
---|
1841 | } |
---|
1842 | } |
---|
1843 | else |
---|
1844 | { |
---|
1845 | for (i = 0; i < pcSlice->getNumRefIdx(REF_PIC_LIST_1); i ++) |
---|
1846 | { |
---|
1847 | refPicListModification->setRefPicSetIdxL1(i, 0 ); |
---|
1848 | } |
---|
1849 | } |
---|
1850 | } |
---|
1851 | } |
---|
1852 | else |
---|
1853 | { |
---|
1854 | refPicListModification->setRefPicListModificationFlagL1(0); |
---|
1855 | } |
---|
1856 | if (pcSlice->isInterB()) |
---|
1857 | { |
---|
1858 | READ_FLAG( uiCode, "mvd_l1_zero_flag" ); pcSlice->setMvdL1ZeroFlag( (uiCode ? true : false) ); |
---|
1859 | } |
---|
1860 | |
---|
1861 | pcSlice->setCabacInitFlag( false ); // default |
---|
1862 | if(pps->getCabacInitPresentFlag() && !pcSlice->isIntra()) |
---|
1863 | { |
---|
1864 | READ_FLAG(uiCode, "cabac_init_flag"); |
---|
1865 | pcSlice->setCabacInitFlag( uiCode ? true : false ); |
---|
1866 | } |
---|
1867 | |
---|
1868 | if ( pcSlice->getEnableTMVPFlag() ) |
---|
1869 | { |
---|
1870 | #if SVC_EXTENSION && REF_IDX_MFM |
---|
1871 | // set motion mapping flag |
---|
1872 | pcSlice->setMFMEnabledFlag( ( pcSlice->getNumMotionPredRefLayers() > 0 && pcSlice->getActiveNumILRRefIdx() && !pcSlice->isIntra() ) ? true : false ); |
---|
1873 | #endif |
---|
1874 | if ( pcSlice->getSliceType() == B_SLICE ) |
---|
1875 | { |
---|
1876 | READ_FLAG( uiCode, "collocated_from_l0_flag" ); |
---|
1877 | pcSlice->setColFromL0Flag(uiCode); |
---|
1878 | } |
---|
1879 | else |
---|
1880 | { |
---|
1881 | pcSlice->setColFromL0Flag( 1 ); |
---|
1882 | } |
---|
1883 | |
---|
1884 | if ( pcSlice->getSliceType() != I_SLICE && |
---|
1885 | ((pcSlice->getColFromL0Flag() == 1 && pcSlice->getNumRefIdx(REF_PIC_LIST_0) > 1)|| |
---|
1886 | (pcSlice->getColFromL0Flag() == 0 && pcSlice->getNumRefIdx(REF_PIC_LIST_1) > 1))) |
---|
1887 | { |
---|
1888 | READ_UVLC( uiCode, "collocated_ref_idx" ); |
---|
1889 | pcSlice->setColRefIdx(uiCode); |
---|
1890 | } |
---|
1891 | else |
---|
1892 | { |
---|
1893 | pcSlice->setColRefIdx(0); |
---|
1894 | } |
---|
1895 | } |
---|
1896 | if ( (pps->getUseWP() && pcSlice->getSliceType()==P_SLICE) || (pps->getWPBiPred() && pcSlice->getSliceType()==B_SLICE) ) |
---|
1897 | { |
---|
1898 | xParsePredWeightTable(pcSlice); |
---|
1899 | pcSlice->initWpScaling(); |
---|
1900 | } |
---|
1901 | if (!pcSlice->isIntra()) |
---|
1902 | { |
---|
1903 | READ_UVLC( uiCode, "five_minus_max_num_merge_cand"); |
---|
1904 | pcSlice->setMaxNumMergeCand(MRG_MAX_NUM_CANDS - uiCode); |
---|
1905 | } |
---|
1906 | |
---|
1907 | READ_SVLC( iCode, "slice_qp_delta" ); |
---|
1908 | pcSlice->setSliceQp (26 + pps->getPicInitQPMinus26() + iCode); |
---|
1909 | |
---|
1910 | #if REPN_FORMAT_IN_VPS |
---|
1911 | #if O0194_DIFFERENT_BITDEPTH_EL_BL |
---|
1912 | g_bitDepthLayer[CHANNEL_TYPE_LUMA][pcSlice->getLayerId()] = pcSlice->getBitDepthY(); |
---|
1913 | g_bitDepthLayer[CHANNEL_TYPE_CHROMA][pcSlice->getLayerId()] = pcSlice->getBitDepthC(); |
---|
1914 | #endif |
---|
1915 | assert( pcSlice->getSliceQp() >= -pcSlice->getQpBDOffsetY() ); |
---|
1916 | #else |
---|
1917 | assert( pcSlice->getSliceQp() >= -sps->getQpBDOffset(CHANNEL_TYPE_LUMA) ); |
---|
1918 | #endif |
---|
1919 | assert( pcSlice->getSliceQp() <= 51 ); |
---|
1920 | |
---|
1921 | if (pcSlice->getPPS()->getSliceChromaQpFlag()) |
---|
1922 | { |
---|
1923 | if (numValidComp>COMPONENT_Cb) |
---|
1924 | { |
---|
1925 | READ_SVLC( iCode, "slice_qp_delta_cb" ); |
---|
1926 | pcSlice->setSliceChromaQpDelta(COMPONENT_Cb, iCode ); |
---|
1927 | assert( pcSlice->getSliceChromaQpDelta(COMPONENT_Cb) >= -12 ); |
---|
1928 | assert( pcSlice->getSliceChromaQpDelta(COMPONENT_Cb) <= 12 ); |
---|
1929 | assert( (pcSlice->getPPS()->getQpOffset(COMPONENT_Cb) + pcSlice->getSliceChromaQpDelta(COMPONENT_Cb)) >= -12 ); |
---|
1930 | assert( (pcSlice->getPPS()->getQpOffset(COMPONENT_Cb) + pcSlice->getSliceChromaQpDelta(COMPONENT_Cb)) <= 12 ); |
---|
1931 | } |
---|
1932 | |
---|
1933 | if (numValidComp>COMPONENT_Cr) |
---|
1934 | { |
---|
1935 | READ_SVLC( iCode, "slice_qp_delta_cr" ); |
---|
1936 | pcSlice->setSliceChromaQpDelta(COMPONENT_Cr, iCode ); |
---|
1937 | assert( pcSlice->getSliceChromaQpDelta(COMPONENT_Cr) >= -12 ); |
---|
1938 | assert( pcSlice->getSliceChromaQpDelta(COMPONENT_Cr) <= 12 ); |
---|
1939 | assert( (pcSlice->getPPS()->getQpOffset(COMPONENT_Cr) + pcSlice->getSliceChromaQpDelta(COMPONENT_Cr)) >= -12 ); |
---|
1940 | assert( (pcSlice->getPPS()->getQpOffset(COMPONENT_Cr) + pcSlice->getSliceChromaQpDelta(COMPONENT_Cr)) <= 12 ); |
---|
1941 | } |
---|
1942 | } |
---|
1943 | |
---|
1944 | if (pcSlice->getPPS()->getChromaQpAdjTableSize() > 0) |
---|
1945 | { |
---|
1946 | READ_FLAG(uiCode, "slice_chroma_qp_adjustment_enabled_flag"); pcSlice->setUseChromaQpAdj(uiCode != 0); |
---|
1947 | } |
---|
1948 | else pcSlice->setUseChromaQpAdj(false); |
---|
1949 | |
---|
1950 | if (pcSlice->getPPS()->getDeblockingFilterControlPresentFlag()) |
---|
1951 | { |
---|
1952 | if(pcSlice->getPPS()->getDeblockingFilterOverrideEnabledFlag()) |
---|
1953 | { |
---|
1954 | READ_FLAG ( uiCode, "deblocking_filter_override_flag" ); pcSlice->setDeblockingFilterOverrideFlag(uiCode ? true : false); |
---|
1955 | } |
---|
1956 | else |
---|
1957 | { |
---|
1958 | pcSlice->setDeblockingFilterOverrideFlag(0); |
---|
1959 | } |
---|
1960 | if(pcSlice->getDeblockingFilterOverrideFlag()) |
---|
1961 | { |
---|
1962 | READ_FLAG ( uiCode, "slice_disable_deblocking_filter_flag" ); pcSlice->setDeblockingFilterDisable(uiCode ? 1 : 0); |
---|
1963 | if(!pcSlice->getDeblockingFilterDisable()) |
---|
1964 | { |
---|
1965 | READ_SVLC( iCode, "slice_beta_offset_div2" ); pcSlice->setDeblockingFilterBetaOffsetDiv2(iCode); |
---|
1966 | assert(pcSlice->getDeblockingFilterBetaOffsetDiv2() >= -6 && |
---|
1967 | pcSlice->getDeblockingFilterBetaOffsetDiv2() <= 6); |
---|
1968 | READ_SVLC( iCode, "slice_tc_offset_div2" ); pcSlice->setDeblockingFilterTcOffsetDiv2(iCode); |
---|
1969 | assert(pcSlice->getDeblockingFilterTcOffsetDiv2() >= -6 && |
---|
1970 | pcSlice->getDeblockingFilterTcOffsetDiv2() <= 6); |
---|
1971 | } |
---|
1972 | } |
---|
1973 | else |
---|
1974 | { |
---|
1975 | pcSlice->setDeblockingFilterDisable ( pcSlice->getPPS()->getPicDisableDeblockingFilterFlag() ); |
---|
1976 | pcSlice->setDeblockingFilterBetaOffsetDiv2( pcSlice->getPPS()->getDeblockingFilterBetaOffsetDiv2() ); |
---|
1977 | pcSlice->setDeblockingFilterTcOffsetDiv2 ( pcSlice->getPPS()->getDeblockingFilterTcOffsetDiv2() ); |
---|
1978 | } |
---|
1979 | } |
---|
1980 | else |
---|
1981 | { |
---|
1982 | pcSlice->setDeblockingFilterDisable ( false ); |
---|
1983 | pcSlice->setDeblockingFilterBetaOffsetDiv2( 0 ); |
---|
1984 | pcSlice->setDeblockingFilterTcOffsetDiv2 ( 0 ); |
---|
1985 | } |
---|
1986 | |
---|
1987 | Bool isSAOEnabled = pcSlice->getSPS()->getUseSAO() && (pcSlice->getSaoEnabledFlag(CHANNEL_TYPE_LUMA) || (bChroma && pcSlice->getSaoEnabledFlag(CHANNEL_TYPE_CHROMA))); |
---|
1988 | Bool isDBFEnabled = (!pcSlice->getDeblockingFilterDisable()); |
---|
1989 | |
---|
1990 | if(pcSlice->getPPS()->getLoopFilterAcrossSlicesEnabledFlag() && ( isSAOEnabled || isDBFEnabled )) |
---|
1991 | { |
---|
1992 | READ_FLAG( uiCode, "slice_loop_filter_across_slices_enabled_flag"); |
---|
1993 | } |
---|
1994 | else |
---|
1995 | { |
---|
1996 | uiCode = pcSlice->getPPS()->getLoopFilterAcrossSlicesEnabledFlag()?1:0; |
---|
1997 | } |
---|
1998 | pcSlice->setLFCrossSliceBoundaryFlag( (uiCode==1)?true:false); |
---|
1999 | |
---|
2000 | } |
---|
2001 | |
---|
2002 | std::vector<UInt> entryPointOffset; |
---|
2003 | if( pps->getTilesEnabledFlag() || pps->getEntropyCodingSyncEnabledFlag() ) |
---|
2004 | { |
---|
2005 | UInt numEntryPointOffsets; |
---|
2006 | UInt offsetLenMinus1; |
---|
2007 | READ_UVLC(numEntryPointOffsets, "num_entry_point_offsets"); |
---|
2008 | if (numEntryPointOffsets>0) |
---|
2009 | { |
---|
2010 | READ_UVLC(offsetLenMinus1, "offset_len_minus1"); |
---|
2011 | entryPointOffset.resize(numEntryPointOffsets); |
---|
2012 | for (UInt idx=0; idx<numEntryPointOffsets; idx++) |
---|
2013 | { |
---|
2014 | READ_CODE(offsetLenMinus1+1, uiCode, "entry_point_offset_minus1"); |
---|
2015 | entryPointOffset[ idx ] = uiCode + 1; |
---|
2016 | } |
---|
2017 | } |
---|
2018 | } |
---|
2019 | |
---|
2020 | #if POC_RESET_IDC_SIGNALLING |
---|
2021 | Int sliceHeaderExtensionLength = 0; |
---|
2022 | if(pps->getSliceHeaderExtensionPresentFlag()) |
---|
2023 | { |
---|
2024 | READ_UVLC( uiCode, "slice_header_extension_length"); sliceHeaderExtensionLength = uiCode; |
---|
2025 | } |
---|
2026 | else |
---|
2027 | { |
---|
2028 | sliceHeaderExtensionLength = 0; |
---|
2029 | #if INFERENCE_POC_MSB_VAL_PRESENT |
---|
2030 | pcSlice->setPocMsbValPresentFlag( false ); |
---|
2031 | #endif |
---|
2032 | } |
---|
2033 | UInt startBits = m_pcBitstream->getNumBitsRead(); // Start counter of # SH Extn bits |
---|
2034 | if( sliceHeaderExtensionLength > 0 ) |
---|
2035 | { |
---|
2036 | if( pcSlice->getPPS()->getPocResetInfoPresentFlag() ) |
---|
2037 | { |
---|
2038 | READ_CODE( 2, uiCode, "poc_reset_idc"); pcSlice->setPocResetIdc(uiCode); |
---|
2039 | #if POC_RESET_RESTRICTIONS |
---|
2040 | /* The value of poc_reset_idc shall not be equal to 1 or 2 for a RASL picture, a RADL picture, |
---|
2041 | a sub-layer non-reference picture, or a picture that has TemporalId greater than 0, |
---|
2042 | or a picture that has discardable_flag equal to 1. */ |
---|
2043 | if( pcSlice->getPocResetIdc() == 1 || pcSlice->getPocResetIdc() == 2 ) |
---|
2044 | { |
---|
2045 | assert( !pcSlice->isRASL() ); |
---|
2046 | assert( !pcSlice->isRADL() ); |
---|
2047 | assert( !pcSlice->isSLNR() ); |
---|
2048 | assert( pcSlice->getTLayer() == 0 ); |
---|
2049 | assert( pcSlice->getDiscardableFlag() == 0 ); |
---|
2050 | } |
---|
2051 | |
---|
2052 | // The value of poc_reset_idc of a CRA or BLA picture shall be less than 3. |
---|
2053 | if( pcSlice->getPocResetIdc() == 3) |
---|
2054 | { |
---|
2055 | assert( ! ( pcSlice->isCRA() || pcSlice->isBLA() ) ); |
---|
2056 | } |
---|
2057 | #endif |
---|
2058 | } |
---|
2059 | else |
---|
2060 | { |
---|
2061 | pcSlice->setPocResetIdc( 0 ); |
---|
2062 | } |
---|
2063 | #if Q0142_POC_LSB_NOT_PRESENT |
---|
2064 | if ( pcSlice->getVPS()->getPocLsbNotPresentFlag( pcSlice->getVPS()->getLayerIdInVps(pcSlice->getLayerId()) ) && iPOClsb > 0 ) |
---|
2065 | { |
---|
2066 | assert( pcSlice->getPocResetIdc() != 2 ); |
---|
2067 | } |
---|
2068 | #endif |
---|
2069 | if( pcSlice->getPocResetIdc() > 0 ) |
---|
2070 | { |
---|
2071 | READ_CODE(6, uiCode, "poc_reset_period_id"); pcSlice->setPocResetPeriodId(uiCode); |
---|
2072 | } |
---|
2073 | else |
---|
2074 | { |
---|
2075 | |
---|
2076 | pcSlice->setPocResetPeriodId( 0 ); |
---|
2077 | } |
---|
2078 | |
---|
2079 | if (pcSlice->getPocResetIdc() == 3) |
---|
2080 | { |
---|
2081 | READ_FLAG( uiCode, "full_poc_reset_flag"); pcSlice->setFullPocResetFlag((uiCode == 1) ? true : false); |
---|
2082 | READ_CODE(pcSlice->getSPS()->getBitsForPOC(), uiCode,"poc_lsb_val"); pcSlice->setPocLsbVal(uiCode); |
---|
2083 | #if Q0142_POC_LSB_NOT_PRESENT |
---|
2084 | if ( pcSlice->getVPS()->getPocLsbNotPresentFlag( pcSlice->getVPS()->getLayerIdInVps(pcSlice->getLayerId()) ) && pcSlice->getFullPocResetFlag() ) |
---|
2085 | { |
---|
2086 | assert( pcSlice->getPocLsbVal() == 0 ); |
---|
2087 | } |
---|
2088 | #endif |
---|
2089 | } |
---|
2090 | |
---|
2091 | // Derive the value of PocMsbValRequiredFlag |
---|
2092 | #if P0297_VPS_POC_LSB_ALIGNED_FLAG |
---|
2093 | pcSlice->setPocMsbValRequiredFlag( (pcSlice->getCraPicFlag() || pcSlice->getBlaPicFlag()) |
---|
2094 | && (!pcSlice->getVPS()->getVpsPocLsbAlignedFlag() || |
---|
2095 | (pcSlice->getVPS()->getVpsPocLsbAlignedFlag() && pcSlice->getVPS()->getNumDirectRefLayers(pcSlice->getLayerId()) == 0)) |
---|
2096 | ); |
---|
2097 | #else |
---|
2098 | pcSlice->setPocMsbValRequiredFlag( pcSlice->getCraPicFlag() || pcSlice->getBlaPicFlag() ); |
---|
2099 | #endif |
---|
2100 | |
---|
2101 | #if P0297_VPS_POC_LSB_ALIGNED_FLAG |
---|
2102 | if (!pcSlice->getPocMsbValRequiredFlag() && pcSlice->getVPS()->getVpsPocLsbAlignedFlag()) |
---|
2103 | #else |
---|
2104 | if (!pcSlice->getPocMsbValRequiredFlag() /* vps_poc_lsb_aligned_flag */) |
---|
2105 | #endif |
---|
2106 | { |
---|
2107 | #if P0297_VPS_POC_LSB_ALIGNED_FLAG |
---|
2108 | READ_FLAG(uiCode, "poc_msb_cycle_val_present_flag"); pcSlice->setPocMsbValPresentFlag(uiCode ? true : false); |
---|
2109 | #else |
---|
2110 | READ_FLAG(uiCode, "poc_msb_val_present_flag"); pcSlice->setPocMsbValPresentFlag(uiCode ? true : false); |
---|
2111 | #endif |
---|
2112 | } |
---|
2113 | else |
---|
2114 | { |
---|
2115 | #if POC_MSB_VAL_PRESENT_FLAG_SEM |
---|
2116 | if( sliceHeaderExtensionLength == 0 ) |
---|
2117 | { |
---|
2118 | pcSlice->setPocMsbValPresentFlag( false ); |
---|
2119 | } |
---|
2120 | else if( pcSlice->getPocMsbValRequiredFlag() ) |
---|
2121 | #else |
---|
2122 | if( pcSlice->getPocMsbValRequiredFlag() ) |
---|
2123 | #endif |
---|
2124 | { |
---|
2125 | pcSlice->setPocMsbValPresentFlag( true ); |
---|
2126 | } |
---|
2127 | else |
---|
2128 | { |
---|
2129 | pcSlice->setPocMsbValPresentFlag( false ); |
---|
2130 | } |
---|
2131 | } |
---|
2132 | |
---|
2133 | #if !POC_RESET_IDC_DECODER |
---|
2134 | Int maxPocLsb = 1 << pcSlice->getSPS()->getBitsForPOC(); |
---|
2135 | #endif |
---|
2136 | if( pcSlice->getPocMsbValPresentFlag() ) |
---|
2137 | { |
---|
2138 | #if P0297_VPS_POC_LSB_ALIGNED_FLAG |
---|
2139 | READ_UVLC( uiCode, "poc_msb_cycle_val"); pcSlice->setPocMsbVal( uiCode ); |
---|
2140 | #else |
---|
2141 | READ_UVLC( uiCode, "poc_msb_val"); pcSlice->setPocMsbVal( uiCode ); |
---|
2142 | #endif |
---|
2143 | |
---|
2144 | #if !POC_RESET_IDC_DECODER |
---|
2145 | // Update POC of the slice based on this MSB val |
---|
2146 | Int pocLsb = pcSlice->getPOC() % maxPocLsb; |
---|
2147 | pcSlice->setPOC((pcSlice->getPocMsbVal() * maxPocLsb) + pocLsb); |
---|
2148 | } |
---|
2149 | else |
---|
2150 | { |
---|
2151 | pcSlice->setPocMsbVal( pcSlice->getPOC() / maxPocLsb ); |
---|
2152 | #endif |
---|
2153 | } |
---|
2154 | |
---|
2155 | // Read remaining bits in the slice header extension. |
---|
2156 | UInt endBits = m_pcBitstream->getNumBitsRead(); |
---|
2157 | Int counter = (endBits - startBits) % 8; |
---|
2158 | if( counter ) |
---|
2159 | { |
---|
2160 | counter = 8 - counter; |
---|
2161 | } |
---|
2162 | |
---|
2163 | while( counter ) |
---|
2164 | { |
---|
2165 | #if Q0146_SSH_EXT_DATA_BIT |
---|
2166 | READ_FLAG( uiCode, "slice_segment_header_extension_data_bit" ); |
---|
2167 | #else |
---|
2168 | READ_FLAG( uiCode, "slice_segment_header_extension_reserved_bit" ); assert( uiCode == 1 ); |
---|
2169 | #endif |
---|
2170 | counter--; |
---|
2171 | } |
---|
2172 | } |
---|
2173 | #else |
---|
2174 | if(pps->getSliceHeaderExtensionPresentFlag()) |
---|
2175 | { |
---|
2176 | READ_UVLC(uiCode,"slice_header_extension_length"); |
---|
2177 | for(Int i=0; i<uiCode; i++) |
---|
2178 | { |
---|
2179 | UInt ignore; |
---|
2180 | READ_CODE(8,ignore,"slice_header_extension_data_byte"); |
---|
2181 | } |
---|
2182 | } |
---|
2183 | #endif |
---|
2184 | #if RExt__DECODER_DEBUG_BIT_STATISTICS |
---|
2185 | TComCodingStatistics::IncrementStatisticEP(STATS__BYTE_ALIGNMENT_BITS,m_pcBitstream->readByteAlignment(),0); |
---|
2186 | #else |
---|
2187 | m_pcBitstream->readByteAlignment(); |
---|
2188 | #endif |
---|
2189 | |
---|
2190 | pcSlice->clearSubstreamSizes(); |
---|
2191 | |
---|
2192 | if( pps->getTilesEnabledFlag() || pps->getEntropyCodingSyncEnabledFlag() ) |
---|
2193 | { |
---|
2194 | Int endOfSliceHeaderLocation = m_pcBitstream->getByteLocation(); |
---|
2195 | |
---|
2196 | // Adjust endOfSliceHeaderLocation to account for emulation prevention bytes in the slice segment header |
---|
2197 | for ( UInt curByteIdx = 0; curByteIdx<m_pcBitstream->numEmulationPreventionBytesRead(); curByteIdx++ ) |
---|
2198 | { |
---|
2199 | if ( m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) < endOfSliceHeaderLocation ) |
---|
2200 | { |
---|
2201 | endOfSliceHeaderLocation++; |
---|
2202 | } |
---|
2203 | } |
---|
2204 | |
---|
2205 | Int curEntryPointOffset = 0; |
---|
2206 | Int prevEntryPointOffset = 0; |
---|
2207 | for (UInt idx=0; idx<entryPointOffset.size(); idx++) |
---|
2208 | { |
---|
2209 | curEntryPointOffset += entryPointOffset[ idx ]; |
---|
2210 | |
---|
2211 | Int emulationPreventionByteCount = 0; |
---|
2212 | for ( UInt curByteIdx = 0; curByteIdx<m_pcBitstream->numEmulationPreventionBytesRead(); curByteIdx++ ) |
---|
2213 | { |
---|
2214 | if ( m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) >= ( prevEntryPointOffset + endOfSliceHeaderLocation ) && |
---|
2215 | m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) < ( curEntryPointOffset + endOfSliceHeaderLocation ) ) |
---|
2216 | { |
---|
2217 | emulationPreventionByteCount++; |
---|
2218 | } |
---|
2219 | } |
---|
2220 | |
---|
2221 | entryPointOffset[ idx ] -= emulationPreventionByteCount; |
---|
2222 | prevEntryPointOffset = curEntryPointOffset; |
---|
2223 | pcSlice->addSubstreamSize(entryPointOffset [ idx ] ); |
---|
2224 | } |
---|
2225 | } |
---|
2226 | |
---|
2227 | return; |
---|
2228 | } |
---|
2229 | |
---|
2230 | Void TDecCavlc::parsePTL( TComPTL *rpcPTL, Bool profilePresentFlag, Int maxNumSubLayersMinus1 ) |
---|
2231 | { |
---|
2232 | UInt uiCode; |
---|
2233 | if(profilePresentFlag) |
---|
2234 | { |
---|
2235 | parseProfileTier(rpcPTL->getGeneralPTL()); |
---|
2236 | } |
---|
2237 | READ_CODE( 8, uiCode, "general_level_idc" ); rpcPTL->getGeneralPTL()->setLevelIdc(Level::Name(uiCode)); |
---|
2238 | |
---|
2239 | for (Int i = 0; i < maxNumSubLayersMinus1; i++) |
---|
2240 | { |
---|
2241 | #if MULTIPLE_PTL_SUPPORT |
---|
2242 | READ_FLAG( uiCode, "sub_layer_profile_present_flag[i]" ); rpcPTL->setSubLayerProfilePresentFlag(i, uiCode); |
---|
2243 | #else |
---|
2244 | if(profilePresentFlag) |
---|
2245 | { |
---|
2246 | READ_FLAG( uiCode, "sub_layer_profile_present_flag[i]" ); rpcPTL->setSubLayerProfilePresentFlag(i, uiCode); |
---|
2247 | } |
---|
2248 | #endif |
---|
2249 | READ_FLAG( uiCode, "sub_layer_level_present_flag[i]" ); rpcPTL->setSubLayerLevelPresentFlag (i, uiCode); |
---|
2250 | } |
---|
2251 | |
---|
2252 | if (maxNumSubLayersMinus1 > 0) |
---|
2253 | { |
---|
2254 | for (Int i = maxNumSubLayersMinus1; i < 8; i++) |
---|
2255 | { |
---|
2256 | READ_CODE(2, uiCode, "reserved_zero_2bits"); |
---|
2257 | assert(uiCode == 0); |
---|
2258 | } |
---|
2259 | } |
---|
2260 | |
---|
2261 | for(Int i = 0; i < maxNumSubLayersMinus1; i++) |
---|
2262 | { |
---|
2263 | #if MULTIPLE_PTL_SUPPORT |
---|
2264 | if( rpcPTL->getSubLayerProfilePresentFlag(i) ) |
---|
2265 | #else |
---|
2266 | if( profilePresentFlag && rpcPTL->getSubLayerProfilePresentFlag(i) ) |
---|
2267 | #endif |
---|
2268 | { |
---|
2269 | parseProfileTier(rpcPTL->getSubLayerPTL(i)); |
---|
2270 | } |
---|
2271 | if(rpcPTL->getSubLayerLevelPresentFlag(i)) |
---|
2272 | { |
---|
2273 | READ_CODE( 8, uiCode, "sub_layer_level_idc[i]" ); rpcPTL->getSubLayerPTL(i)->setLevelIdc(Level::Name(uiCode)); |
---|
2274 | } |
---|
2275 | } |
---|
2276 | } |
---|
2277 | |
---|
2278 | Void TDecCavlc::parseProfileTier(ProfileTierLevel *ptl) |
---|
2279 | { |
---|
2280 | UInt uiCode; |
---|
2281 | READ_CODE(2 , uiCode, "XXX_profile_space[]"); ptl->setProfileSpace(uiCode); |
---|
2282 | READ_FLAG( uiCode, "XXX_tier_flag[]" ); ptl->setTierFlag (uiCode ? Level::HIGH : Level::MAIN); |
---|
2283 | READ_CODE(5 , uiCode, "XXX_profile_idc[]" ); ptl->setProfileIdc (Profile::Name(uiCode)); |
---|
2284 | for(Int j = 0; j < 32; j++) |
---|
2285 | { |
---|
2286 | READ_FLAG( uiCode, "XXX_profile_compatibility_flag[][j]"); ptl->setProfileCompatibilityFlag(j, uiCode ? 1 : 0); |
---|
2287 | } |
---|
2288 | READ_FLAG(uiCode, "general_progressive_source_flag"); |
---|
2289 | ptl->setProgressiveSourceFlag(uiCode ? true : false); |
---|
2290 | |
---|
2291 | READ_FLAG(uiCode, "general_interlaced_source_flag"); |
---|
2292 | ptl->setInterlacedSourceFlag(uiCode ? true : false); |
---|
2293 | |
---|
2294 | READ_FLAG(uiCode, "general_non_packed_constraint_flag"); |
---|
2295 | ptl->setNonPackedConstraintFlag(uiCode ? true : false); |
---|
2296 | |
---|
2297 | READ_FLAG(uiCode, "general_frame_only_constraint_flag"); |
---|
2298 | ptl->setFrameOnlyConstraintFlag(uiCode ? true : false); |
---|
2299 | |
---|
2300 | if (ptl->getProfileIdc() == Profile::MAINREXT || ptl->getProfileIdc() == Profile::HIGHTHROUGHPUTREXT ) |
---|
2301 | { |
---|
2302 | UInt maxBitDepth=16; |
---|
2303 | READ_FLAG( uiCode, "general_max_12bit_constraint_flag" ); if (uiCode) maxBitDepth=12; |
---|
2304 | READ_FLAG( uiCode, "general_max_10bit_constraint_flag" ); if (uiCode) maxBitDepth=10; |
---|
2305 | READ_FLAG( uiCode, "general_max_8bit_constraint_flag" ); if (uiCode) maxBitDepth=8; |
---|
2306 | ptl->setBitDepthConstraint(maxBitDepth); |
---|
2307 | ChromaFormat chromaFmtConstraint=CHROMA_444; |
---|
2308 | READ_FLAG( uiCode, "general_max_422chroma_constraint_flag" ); if (uiCode) chromaFmtConstraint=CHROMA_422; |
---|
2309 | READ_FLAG( uiCode, "general_max_420chroma_constraint_flag" ); if (uiCode) chromaFmtConstraint=CHROMA_420; |
---|
2310 | READ_FLAG( uiCode, "general_max_monochrome_constraint_flag" ); if (uiCode) chromaFmtConstraint=CHROMA_400; |
---|
2311 | ptl->setChromaFormatConstraint(chromaFmtConstraint); |
---|
2312 | READ_FLAG( uiCode, "general_intra_constraint_flag"); ptl->setIntraConstraintFlag(uiCode != 0); |
---|
2313 | READ_FLAG( uiCode, "general_one_picture_only_constraint_flag"); |
---|
2314 | READ_FLAG( uiCode, "general_lower_bit_rate_constraint_flag"); ptl->setLowerBitRateConstraintFlag(uiCode != 0); |
---|
2315 | #if MULTIPLE_PTL_SUPPORT |
---|
2316 | READ_CODE(32, uiCode, "general_reserved_zero_34bits"); READ_CODE(2, uiCode, "general_reserved_zero_34bits"); |
---|
2317 | } |
---|
2318 | else if( ptl->getProfileIdc() == Profile::SCALABLEMAIN ) |
---|
2319 | { |
---|
2320 | READ_FLAG( uiCode, "general_max_12bit_constraint_flag" ); assert (uiCode == 1); |
---|
2321 | READ_FLAG( uiCode, "general_max_10bit_constraint_flag" ); assert (uiCode == 1); |
---|
2322 | READ_FLAG( uiCode, "general_max_8bit_constraint_flag" ); ptl->setProfileIdc ((uiCode) ? Profile::SCALABLEMAIN : Profile::SCALABLEMAIN10); |
---|
2323 | READ_FLAG( uiCode, "general_max_422chroma_constraint_flag" ); assert (uiCode == 1); |
---|
2324 | READ_FLAG( uiCode, "general_max_420chroma_constraint_flag" ); assert (uiCode == 1); |
---|
2325 | READ_FLAG( uiCode, "general_max_monochrome_constraint_flag" ); assert (uiCode == 0); |
---|
2326 | READ_FLAG( uiCode, "general_intra_constraint_flag"); assert (uiCode == 0); |
---|
2327 | READ_FLAG( uiCode, "general_one_picture_only_constraint_flag"); assert (uiCode == 0); |
---|
2328 | READ_FLAG( uiCode, "general_lower_bit_rate_constraint_flag"); assert (uiCode == 1); |
---|
2329 | READ_CODE(32, uiCode, "general_reserved_zero_34bits"); READ_CODE(2, uiCode, "general_reserved_zero_34bits"); |
---|
2330 | } |
---|
2331 | else |
---|
2332 | { |
---|
2333 | ptl->setBitDepthConstraint((ptl->getProfileIdc() == Profile::MAIN10)?10:8); |
---|
2334 | ptl->setChromaFormatConstraint(CHROMA_420); |
---|
2335 | ptl->setIntraConstraintFlag(false); |
---|
2336 | ptl->setLowerBitRateConstraintFlag(true); |
---|
2337 | READ_CODE(32, uiCode, "general_reserved_zero_43bits"); READ_CODE(11, uiCode, "general_reserved_zero_43bits"); |
---|
2338 | } |
---|
2339 | |
---|
2340 | if( ( ptl->getProfileIdc() >= 1 && ptl->getProfileIdc() <= 5 ) || |
---|
2341 | ptl->getProfileCompatibilityFlag(1) || ptl->getProfileCompatibilityFlag(2) || |
---|
2342 | ptl->getProfileCompatibilityFlag(3) || ptl->getProfileCompatibilityFlag(4) || |
---|
2343 | ptl->getProfileCompatibilityFlag(5) ) |
---|
2344 | { |
---|
2345 | READ_FLAG(uiCode, "general_inbld_flag"); |
---|
2346 | } |
---|
2347 | else |
---|
2348 | { |
---|
2349 | READ_FLAG(uiCode, "general_reserved_zero_bit"); |
---|
2350 | } |
---|
2351 | #else |
---|
2352 | READ_CODE(16, uiCode, "XXX_reserved_zero_35bits[0..15]"); |
---|
2353 | READ_CODE(16, uiCode, "XXX_reserved_zero_35bits[16..31]"); |
---|
2354 | READ_CODE(3, uiCode, "XXX_reserved_zero_35bits[32..34]"); |
---|
2355 | } |
---|
2356 | else |
---|
2357 | { |
---|
2358 | ptl->setBitDepthConstraint((ptl->getProfileIdc() == Profile::MAIN10)?10:8); |
---|
2359 | ptl->setChromaFormatConstraint(CHROMA_420); |
---|
2360 | ptl->setIntraConstraintFlag(false); |
---|
2361 | ptl->setLowerBitRateConstraintFlag(true); |
---|
2362 | READ_CODE(16, uiCode, "XXX_reserved_zero_44bits[0..15]"); |
---|
2363 | READ_CODE(16, uiCode, "XXX_reserved_zero_44bits[16..31]"); |
---|
2364 | READ_CODE(12, uiCode, "XXX_reserved_zero_44bits[32..43]"); |
---|
2365 | } |
---|
2366 | #endif |
---|
2367 | } |
---|
2368 | |
---|
2369 | Void TDecCavlc::parseTerminatingBit( UInt& ruiBit ) |
---|
2370 | { |
---|
2371 | ruiBit = false; |
---|
2372 | Int iBitsLeft = m_pcBitstream->getNumBitsLeft(); |
---|
2373 | if(iBitsLeft <= 8) |
---|
2374 | { |
---|
2375 | UInt uiPeekValue = m_pcBitstream->peekBits(iBitsLeft); |
---|
2376 | if (uiPeekValue == (1<<(iBitsLeft-1))) |
---|
2377 | { |
---|
2378 | ruiBit = true; |
---|
2379 | } |
---|
2380 | } |
---|
2381 | } |
---|
2382 | |
---|
2383 | Void TDecCavlc::parseRemainingBytes( Bool noTrailingBytesExpected ) |
---|
2384 | { |
---|
2385 | if (noTrailingBytesExpected) |
---|
2386 | { |
---|
2387 | const UInt numberOfRemainingSubstreamBytes=m_pcBitstream->getNumBitsLeft(); |
---|
2388 | assert (numberOfRemainingSubstreamBytes == 0); |
---|
2389 | } |
---|
2390 | else |
---|
2391 | { |
---|
2392 | while (m_pcBitstream->getNumBitsLeft()) |
---|
2393 | { |
---|
2394 | UInt trailingNullByte=m_pcBitstream->readByte(); |
---|
2395 | if (trailingNullByte!=0) |
---|
2396 | { |
---|
2397 | printf("Trailing byte should be 0, but has value %02x\n", trailingNullByte); |
---|
2398 | assert(trailingNullByte==0); |
---|
2399 | } |
---|
2400 | } |
---|
2401 | } |
---|
2402 | } |
---|
2403 | |
---|
2404 | Void TDecCavlc::parseSkipFlag( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
2405 | { |
---|
2406 | assert(0); |
---|
2407 | } |
---|
2408 | |
---|
2409 | Void TDecCavlc::parseCUTransquantBypassFlag( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
2410 | { |
---|
2411 | assert(0); |
---|
2412 | } |
---|
2413 | |
---|
2414 | Void TDecCavlc::parseMVPIdx( Int& /*riMVPIdx*/ ) |
---|
2415 | { |
---|
2416 | assert(0); |
---|
2417 | } |
---|
2418 | |
---|
2419 | Void TDecCavlc::parseSplitFlag ( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
2420 | { |
---|
2421 | assert(0); |
---|
2422 | } |
---|
2423 | |
---|
2424 | Void TDecCavlc::parsePartSize( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
2425 | { |
---|
2426 | assert(0); |
---|
2427 | } |
---|
2428 | |
---|
2429 | Void TDecCavlc::parsePredMode( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
2430 | { |
---|
2431 | assert(0); |
---|
2432 | } |
---|
2433 | |
---|
2434 | /** Parse I_PCM information. |
---|
2435 | * \param pcCU pointer to CU |
---|
2436 | * \param uiAbsPartIdx CU index |
---|
2437 | * \param uiDepth CU depth |
---|
2438 | * \returns Void |
---|
2439 | * |
---|
2440 | * If I_PCM flag indicates that the CU is I_PCM, parse its PCM alignment bits and codes. |
---|
2441 | */ |
---|
2442 | Void TDecCavlc::parseIPCMInfo( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
2443 | { |
---|
2444 | assert(0); |
---|
2445 | } |
---|
2446 | |
---|
2447 | Void TDecCavlc::parseIntraDirLumaAng ( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
2448 | { |
---|
2449 | assert(0); |
---|
2450 | } |
---|
2451 | |
---|
2452 | Void TDecCavlc::parseIntraDirChroma( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
2453 | { |
---|
2454 | assert(0); |
---|
2455 | } |
---|
2456 | |
---|
2457 | Void TDecCavlc::parseInterDir( TComDataCU* /*pcCU*/, UInt& /*ruiInterDir*/, UInt /*uiAbsPartIdx*/ ) |
---|
2458 | { |
---|
2459 | assert(0); |
---|
2460 | } |
---|
2461 | |
---|
2462 | Void TDecCavlc::parseRefFrmIdx( TComDataCU* /*pcCU*/, Int& /*riRefFrmIdx*/, RefPicList /*eRefList*/ ) |
---|
2463 | { |
---|
2464 | assert(0); |
---|
2465 | } |
---|
2466 | |
---|
2467 | Void TDecCavlc::parseMvd( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiPartIdx*/, UInt /*uiDepth*/, RefPicList /*eRefList*/ ) |
---|
2468 | { |
---|
2469 | assert(0); |
---|
2470 | } |
---|
2471 | |
---|
2472 | Void TDecCavlc::parseCrossComponentPrediction( class TComTU& /*rTu*/, ComponentID /*compID*/ ) |
---|
2473 | { |
---|
2474 | assert(0); |
---|
2475 | } |
---|
2476 | |
---|
2477 | Void TDecCavlc::parseDeltaQP( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2478 | { |
---|
2479 | Int qp; |
---|
2480 | Int iDQp; |
---|
2481 | |
---|
2482 | #if RExt__DECODER_DEBUG_BIT_STATISTICS |
---|
2483 | READ_SVLC(iDQp, "delta_qp"); |
---|
2484 | #else |
---|
2485 | xReadSvlc( iDQp ); |
---|
2486 | #endif |
---|
2487 | |
---|
2488 | #if REPN_FORMAT_IN_VPS |
---|
2489 | Int qpBdOffsetY = pcCU->getSlice()->getQpBDOffsetY(); |
---|
2490 | #else |
---|
2491 | Int qpBdOffsetY = pcCU->getSlice()->getSPS()->getQpBDOffset(CHANNEL_TYPE_LUMA); |
---|
2492 | #endif |
---|
2493 | qp = (((Int) pcCU->getRefQP( uiAbsPartIdx ) + iDQp + 52 + 2*qpBdOffsetY )%(52+ qpBdOffsetY)) - qpBdOffsetY; |
---|
2494 | |
---|
2495 | UInt uiAbsQpCUPartIdx = (uiAbsPartIdx>>((g_uiMaxCUDepth - pcCU->getSlice()->getPPS()->getMaxCuDQPDepth())<<1))<<((g_uiMaxCUDepth - pcCU->getSlice()->getPPS()->getMaxCuDQPDepth())<<1) ; |
---|
2496 | UInt uiQpCUDepth = min(uiDepth,pcCU->getSlice()->getPPS()->getMaxCuDQPDepth()) ; |
---|
2497 | |
---|
2498 | pcCU->setQPSubParts( qp, uiAbsQpCUPartIdx, uiQpCUDepth ); |
---|
2499 | } |
---|
2500 | |
---|
2501 | Void TDecCavlc::parseChromaQpAdjustment( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
2502 | { |
---|
2503 | assert(0); |
---|
2504 | } |
---|
2505 | |
---|
2506 | Void TDecCavlc::parseCoeffNxN( TComTU &/*rTu*/, ComponentID /*compID*/ ) |
---|
2507 | { |
---|
2508 | assert(0); |
---|
2509 | } |
---|
2510 | |
---|
2511 | Void TDecCavlc::parseTransformSubdivFlag( UInt& /*ruiSubdivFlag*/, UInt /*uiLog2TransformBlockSize*/ ) |
---|
2512 | { |
---|
2513 | assert(0); |
---|
2514 | } |
---|
2515 | |
---|
2516 | Void TDecCavlc::parseQtCbf( TComTU &/*rTu*/, const ComponentID /*compID*/, const Bool /*lowestLevel*/ ) |
---|
2517 | { |
---|
2518 | assert(0); |
---|
2519 | } |
---|
2520 | |
---|
2521 | Void TDecCavlc::parseQtRootCbf( UInt /*uiAbsPartIdx*/, UInt& /*uiQtRootCbf*/ ) |
---|
2522 | { |
---|
2523 | assert(0); |
---|
2524 | } |
---|
2525 | |
---|
2526 | Void TDecCavlc::parseTransformSkipFlags (TComTU &/*rTu*/, ComponentID /*component*/) |
---|
2527 | { |
---|
2528 | assert(0); |
---|
2529 | } |
---|
2530 | |
---|
2531 | Void TDecCavlc::parseMergeFlag ( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/, UInt /*uiPUIdx*/ ) |
---|
2532 | { |
---|
2533 | assert(0); |
---|
2534 | } |
---|
2535 | |
---|
2536 | Void TDecCavlc::parseMergeIndex ( TComDataCU* /*pcCU*/, UInt& /*ruiMergeIndex*/ ) |
---|
2537 | { |
---|
2538 | assert(0); |
---|
2539 | } |
---|
2540 | |
---|
2541 | // ==================================================================================================================== |
---|
2542 | // Protected member functions |
---|
2543 | // ==================================================================================================================== |
---|
2544 | |
---|
2545 | /** parse explicit wp tables |
---|
2546 | * \param TComSlice* pcSlice |
---|
2547 | * \returns Void |
---|
2548 | */ |
---|
2549 | Void TDecCavlc::xParsePredWeightTable( TComSlice* pcSlice ) |
---|
2550 | { |
---|
2551 | WPScalingParam *wp; |
---|
2552 | TComSPS *sps = pcSlice->getSPS(); |
---|
2553 | const ChromaFormat chFmt = sps->getChromaFormatIdc(); |
---|
2554 | const Int numValidComp = Int(getNumberValidComponents(chFmt)); |
---|
2555 | const Bool bChroma = (chFmt!=CHROMA_400); |
---|
2556 | const SliceType eSliceType = pcSlice->getSliceType(); |
---|
2557 | const Int iNbRef = (eSliceType == B_SLICE ) ? (2) : (1); |
---|
2558 | UInt uiLog2WeightDenomLuma=0, uiLog2WeightDenomChroma=0; |
---|
2559 | UInt uiTotalSignalledWeightFlags = 0; |
---|
2560 | |
---|
2561 | Int iDeltaDenom; |
---|
2562 | // decode delta_luma_log2_weight_denom : |
---|
2563 | READ_UVLC( uiLog2WeightDenomLuma, "luma_log2_weight_denom" ); // ue(v): luma_log2_weight_denom |
---|
2564 | assert( uiLog2WeightDenomLuma <= 7 ); |
---|
2565 | if( bChroma ) |
---|
2566 | { |
---|
2567 | READ_SVLC( iDeltaDenom, "delta_chroma_log2_weight_denom" ); // se(v): delta_chroma_log2_weight_denom |
---|
2568 | assert((iDeltaDenom + (Int)uiLog2WeightDenomLuma)>=0); |
---|
2569 | assert((iDeltaDenom + (Int)uiLog2WeightDenomLuma)<=7); |
---|
2570 | uiLog2WeightDenomChroma = (UInt)(iDeltaDenom + uiLog2WeightDenomLuma); |
---|
2571 | } |
---|
2572 | |
---|
2573 | for ( Int iNumRef=0 ; iNumRef<iNbRef ; iNumRef++ ) |
---|
2574 | { |
---|
2575 | RefPicList eRefPicList = ( iNumRef ? REF_PIC_LIST_1 : REF_PIC_LIST_0 ); |
---|
2576 | for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ ) |
---|
2577 | { |
---|
2578 | pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); |
---|
2579 | |
---|
2580 | wp[COMPONENT_Y].uiLog2WeightDenom = uiLog2WeightDenomLuma; |
---|
2581 | for(Int j=1; j<numValidComp; j++) |
---|
2582 | { |
---|
2583 | wp[j].uiLog2WeightDenom = uiLog2WeightDenomChroma; |
---|
2584 | } |
---|
2585 | |
---|
2586 | UInt uiCode; |
---|
2587 | READ_FLAG( uiCode, "luma_weight_lX_flag" ); // u(1): luma_weight_l0_flag |
---|
2588 | wp[COMPONENT_Y].bPresentFlag = ( uiCode == 1 ); |
---|
2589 | uiTotalSignalledWeightFlags += wp[COMPONENT_Y].bPresentFlag; |
---|
2590 | } |
---|
2591 | if ( bChroma ) |
---|
2592 | { |
---|
2593 | UInt uiCode; |
---|
2594 | for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ ) |
---|
2595 | { |
---|
2596 | pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); |
---|
2597 | READ_FLAG( uiCode, "chroma_weight_lX_flag" ); // u(1): chroma_weight_l0_flag |
---|
2598 | for(Int j=1; j<numValidComp; j++) |
---|
2599 | { |
---|
2600 | wp[j].bPresentFlag = ( uiCode == 1 ); |
---|
2601 | } |
---|
2602 | uiTotalSignalledWeightFlags += 2*wp[COMPONENT_Cb].bPresentFlag; |
---|
2603 | } |
---|
2604 | } |
---|
2605 | for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ ) |
---|
2606 | { |
---|
2607 | pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); |
---|
2608 | if ( wp[COMPONENT_Y].bPresentFlag ) |
---|
2609 | { |
---|
2610 | Int iDeltaWeight; |
---|
2611 | READ_SVLC( iDeltaWeight, "delta_luma_weight_lX" ); // se(v): delta_luma_weight_l0[i] |
---|
2612 | assert( iDeltaWeight >= -128 ); |
---|
2613 | assert( iDeltaWeight <= 127 ); |
---|
2614 | wp[COMPONENT_Y].iWeight = (iDeltaWeight + (1<<wp[COMPONENT_Y].uiLog2WeightDenom)); |
---|
2615 | READ_SVLC( wp[COMPONENT_Y].iOffset, "luma_offset_lX" ); // se(v): luma_offset_l0[i] |
---|
2616 | Int range=sps->getUseHighPrecisionPredictionWeighting() ? (1<<g_bitDepth[CHANNEL_TYPE_LUMA])/2 : 128; |
---|
2617 | assert( wp[0].iOffset >= -range ); |
---|
2618 | assert( wp[0].iOffset < range ); |
---|
2619 | } |
---|
2620 | else |
---|
2621 | { |
---|
2622 | wp[COMPONENT_Y].iWeight = (1 << wp[COMPONENT_Y].uiLog2WeightDenom); |
---|
2623 | wp[COMPONENT_Y].iOffset = 0; |
---|
2624 | } |
---|
2625 | if ( bChroma ) |
---|
2626 | { |
---|
2627 | if ( wp[COMPONENT_Cb].bPresentFlag ) |
---|
2628 | { |
---|
2629 | Int range=sps->getUseHighPrecisionPredictionWeighting() ? (1<<g_bitDepth[CHANNEL_TYPE_CHROMA])/2 : 128; |
---|
2630 | for ( Int j=1 ; j<numValidComp ; j++ ) |
---|
2631 | { |
---|
2632 | Int iDeltaWeight; |
---|
2633 | READ_SVLC( iDeltaWeight, "delta_chroma_weight_lX" ); // se(v): chroma_weight_l0[i][j] |
---|
2634 | assert( iDeltaWeight >= -128 ); |
---|
2635 | assert( iDeltaWeight <= 127 ); |
---|
2636 | wp[j].iWeight = (iDeltaWeight + (1<<wp[j].uiLog2WeightDenom)); |
---|
2637 | |
---|
2638 | Int iDeltaChroma; |
---|
2639 | READ_SVLC( iDeltaChroma, "delta_chroma_offset_lX" ); // se(v): delta_chroma_offset_l0[i][j] |
---|
2640 | assert( iDeltaChroma >= -4*range); |
---|
2641 | assert( iDeltaChroma < 4*range); |
---|
2642 | Int pred = ( range - ( ( range*wp[j].iWeight)>>(wp[j].uiLog2WeightDenom) ) ); |
---|
2643 | wp[j].iOffset = Clip3(-range, range-1, (iDeltaChroma + pred) ); |
---|
2644 | } |
---|
2645 | } |
---|
2646 | else |
---|
2647 | { |
---|
2648 | for ( Int j=1 ; j<numValidComp ; j++ ) |
---|
2649 | { |
---|
2650 | wp[j].iWeight = (1 << wp[j].uiLog2WeightDenom); |
---|
2651 | wp[j].iOffset = 0; |
---|
2652 | } |
---|
2653 | } |
---|
2654 | } |
---|
2655 | } |
---|
2656 | |
---|
2657 | for ( Int iRefIdx=pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx<MAX_NUM_REF ; iRefIdx++ ) |
---|
2658 | { |
---|
2659 | pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); |
---|
2660 | |
---|
2661 | wp[0].bPresentFlag = false; |
---|
2662 | wp[1].bPresentFlag = false; |
---|
2663 | wp[2].bPresentFlag = false; |
---|
2664 | } |
---|
2665 | } |
---|
2666 | assert(uiTotalSignalledWeightFlags<=24); |
---|
2667 | } |
---|
2668 | |
---|
2669 | /** decode quantization matrix |
---|
2670 | * \param scalingList quantization matrix information |
---|
2671 | */ |
---|
2672 | Void TDecCavlc::parseScalingList(TComScalingList* scalingList) |
---|
2673 | { |
---|
2674 | UInt code, sizeId, listId; |
---|
2675 | Bool scalingListPredModeFlag; |
---|
2676 | //for each size |
---|
2677 | for(sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
2678 | { |
---|
2679 | for(listId = 0; listId < SCALING_LIST_NUM; listId++) |
---|
2680 | { |
---|
2681 | if ((sizeId==SCALING_LIST_32x32) && (listId%(SCALING_LIST_NUM/NUMBER_OF_PREDICTION_MODES) != 0)) |
---|
2682 | { |
---|
2683 | Int *src = scalingList->getScalingListAddress(sizeId, listId); |
---|
2684 | const Int size = min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId]); |
---|
2685 | const Int *srcNextSmallerSize = scalingList->getScalingListAddress(sizeId-1, listId); |
---|
2686 | for(Int i=0; i<size; i++) |
---|
2687 | { |
---|
2688 | src[i] = srcNextSmallerSize[i]; |
---|
2689 | } |
---|
2690 | scalingList->setScalingListDC(sizeId,listId,(sizeId > SCALING_LIST_8x8) ? scalingList->getScalingListDC(sizeId-1, listId) : src[0]); |
---|
2691 | } |
---|
2692 | else |
---|
2693 | { |
---|
2694 | READ_FLAG( code, "scaling_list_pred_mode_flag"); |
---|
2695 | scalingListPredModeFlag = (code) ? true : false; |
---|
2696 | if(!scalingListPredModeFlag) //Copy Mode |
---|
2697 | { |
---|
2698 | READ_UVLC( code, "scaling_list_pred_matrix_id_delta"); |
---|
2699 | |
---|
2700 | if (sizeId==SCALING_LIST_32x32) |
---|
2701 | code*=(SCALING_LIST_NUM/NUMBER_OF_PREDICTION_MODES); // Adjust the decoded code for this size, to cope with the missing 32x32 chroma entries. |
---|
2702 | |
---|
2703 | scalingList->setRefMatrixId (sizeId,listId,(UInt)((Int)(listId)-(code))); |
---|
2704 | if( sizeId > SCALING_LIST_8x8 ) |
---|
2705 | { |
---|
2706 | scalingList->setScalingListDC(sizeId,listId,((listId == scalingList->getRefMatrixId (sizeId,listId))? 16 :scalingList->getScalingListDC(sizeId, scalingList->getRefMatrixId (sizeId,listId)))); |
---|
2707 | } |
---|
2708 | scalingList->processRefMatrix( sizeId, listId, scalingList->getRefMatrixId (sizeId,listId)); |
---|
2709 | |
---|
2710 | } |
---|
2711 | else //DPCM Mode |
---|
2712 | { |
---|
2713 | xDecodeScalingList(scalingList, sizeId, listId); |
---|
2714 | } |
---|
2715 | } |
---|
2716 | } |
---|
2717 | } |
---|
2718 | |
---|
2719 | return; |
---|
2720 | } |
---|
2721 | /** decode DPCM |
---|
2722 | * \param scalingList quantization matrix information |
---|
2723 | * \param sizeId size index |
---|
2724 | * \param listId list index |
---|
2725 | */ |
---|
2726 | Void TDecCavlc::xDecodeScalingList(TComScalingList *scalingList, UInt sizeId, UInt listId) |
---|
2727 | { |
---|
2728 | Int i,coefNum = min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId]); |
---|
2729 | Int data; |
---|
2730 | Int scalingListDcCoefMinus8 = 0; |
---|
2731 | Int nextCoef = SCALING_LIST_START_VALUE; |
---|
2732 | UInt* scan = g_scanOrder[SCAN_UNGROUPED][SCAN_DIAG][sizeId==0 ? 2 : 3][sizeId==0 ? 2 : 3]; |
---|
2733 | Int *dst = scalingList->getScalingListAddress(sizeId, listId); |
---|
2734 | |
---|
2735 | if( sizeId > SCALING_LIST_8x8 ) |
---|
2736 | { |
---|
2737 | READ_SVLC( scalingListDcCoefMinus8, "scaling_list_dc_coef_minus8"); |
---|
2738 | scalingList->setScalingListDC(sizeId,listId,scalingListDcCoefMinus8 + 8); |
---|
2739 | nextCoef = scalingList->getScalingListDC(sizeId,listId); |
---|
2740 | } |
---|
2741 | |
---|
2742 | for(i = 0; i < coefNum; i++) |
---|
2743 | { |
---|
2744 | READ_SVLC( data, "scaling_list_delta_coef"); |
---|
2745 | nextCoef = (nextCoef + data + 256 ) % 256; |
---|
2746 | dst[scan[i]] = nextCoef; |
---|
2747 | } |
---|
2748 | } |
---|
2749 | |
---|
2750 | Bool TDecCavlc::xMoreRbspData() |
---|
2751 | { |
---|
2752 | Int bitsLeft = m_pcBitstream->getNumBitsLeft(); |
---|
2753 | |
---|
2754 | // if there are more than 8 bits, it cannot be rbsp_trailing_bits |
---|
2755 | if (bitsLeft > 8) |
---|
2756 | { |
---|
2757 | return true; |
---|
2758 | } |
---|
2759 | |
---|
2760 | UChar lastByte = m_pcBitstream->peekBits(bitsLeft); |
---|
2761 | Int cnt = bitsLeft; |
---|
2762 | |
---|
2763 | // remove trailing bits equal to zero |
---|
2764 | while ((cnt>0) && ((lastByte & 1) == 0)) |
---|
2765 | { |
---|
2766 | lastByte >>= 1; |
---|
2767 | cnt--; |
---|
2768 | } |
---|
2769 | // remove bit equal to one |
---|
2770 | cnt--; |
---|
2771 | |
---|
2772 | // we should not have a negative number of bits |
---|
2773 | assert (cnt>=0); |
---|
2774 | |
---|
2775 | // we have more data, if cnt is not zero |
---|
2776 | return (cnt>0); |
---|
2777 | } |
---|
2778 | |
---|
2779 | Void TDecCavlc::parseExplicitRdpcmMode( TComTU &rTu, ComponentID compID ) |
---|
2780 | { |
---|
2781 | assert(0); |
---|
2782 | } |
---|
2783 | |
---|
2784 | #if SVC_EXTENSION |
---|
2785 | Void TDecCavlc::parseVPSExtension(TComVPS *vps) |
---|
2786 | { |
---|
2787 | UInt uiCode; |
---|
2788 | // ... More syntax elements to be parsed here |
---|
2789 | #if P0300_ALT_OUTPUT_LAYER_FLAG |
---|
2790 | Int NumOutputLayersInOutputLayerSet[MAX_VPS_LAYER_SETS_PLUS1]; |
---|
2791 | Int OlsHighestOutputLayerId[MAX_VPS_LAYER_SETS_PLUS1]; |
---|
2792 | #endif |
---|
2793 | #if LIST_OF_PTL |
---|
2794 | if( vps->getMaxLayers() > 1 && vps->getBaseLayerInternalFlag() ) |
---|
2795 | { |
---|
2796 | vps->setProfilePresentFlag(1, false); |
---|
2797 | #if MULTIPLE_PTL_SUPPORT |
---|
2798 | parsePTL( vps->getPTL(1), vps->getProfilePresentFlag(1), vps->getMaxTLayers() - 1 ); |
---|
2799 | #else |
---|
2800 | vps->getPTLForExtnPtr()->empty(); |
---|
2801 | vps->getPTLForExtnPtr()->resize(2); |
---|
2802 | vps->getPTLForExtn(1)->copyProfileInfo( vps->getPTL() ); |
---|
2803 | parsePTL( vps->getPTLForExtn(1), vps->getProfilePresentFlag(1), vps->getMaxTLayers() - 1 ); |
---|
2804 | #endif |
---|
2805 | } |
---|
2806 | #endif |
---|
2807 | #if VPS_EXTN_MASK_AND_DIM_INFO |
---|
2808 | UInt numScalabilityTypes = 0, i = 0, j = 0; |
---|
2809 | |
---|
2810 | #if !VPS_AVC_BL_FLAG_REMOVAL |
---|
2811 | READ_FLAG( uiCode, "avc_base_layer_flag" ); vps->setAvcBaseLayerFlag(uiCode ? true : false); |
---|
2812 | #endif |
---|
2813 | |
---|
2814 | #if !P0307_REMOVE_VPS_VUI_OFFSET |
---|
2815 | #if O0109_MOVE_VPS_VUI_FLAG |
---|
2816 | READ_FLAG( uiCode, "vps_vui_present_flag"); vps->setVpsVuiPresentFlag(uiCode ? true : false); |
---|
2817 | if ( uiCode ) |
---|
2818 | { |
---|
2819 | #endif |
---|
2820 | #if VPS_VUI_OFFSET |
---|
2821 | READ_CODE( 16, uiCode, "vps_vui_offset" ); vps->setVpsVuiOffset( uiCode ); |
---|
2822 | #endif |
---|
2823 | #if O0109_MOVE_VPS_VUI_FLAG |
---|
2824 | } |
---|
2825 | #endif |
---|
2826 | #endif |
---|
2827 | READ_FLAG( uiCode, "splitting_flag" ); vps->setSplittingFlag(uiCode ? true : false); |
---|
2828 | |
---|
2829 | for(i = 0; i < MAX_VPS_NUM_SCALABILITY_TYPES; i++) |
---|
2830 | { |
---|
2831 | READ_FLAG( uiCode, "scalability_mask[i]" ); vps->setScalabilityMask(i, uiCode ? true : false); |
---|
2832 | numScalabilityTypes += uiCode; |
---|
2833 | } |
---|
2834 | vps->setNumScalabilityTypes(numScalabilityTypes); |
---|
2835 | |
---|
2836 | for(j = 0; j < numScalabilityTypes - vps->getSplittingFlag(); j++) |
---|
2837 | { |
---|
2838 | READ_CODE( 3, uiCode, "dimension_id_len_minus1[j]" ); vps->setDimensionIdLen(j, uiCode + 1); |
---|
2839 | } |
---|
2840 | |
---|
2841 | // The value of dimBitOffset[ NumScalabilityTypes ] is set equal to 6. |
---|
2842 | if(vps->getSplittingFlag()) |
---|
2843 | { |
---|
2844 | UInt numBits = 0; |
---|
2845 | for(j = 0; j < numScalabilityTypes - 1; j++) |
---|
2846 | { |
---|
2847 | numBits += vps->getDimensionIdLen(j); |
---|
2848 | } |
---|
2849 | assert( numBits < 6 ); |
---|
2850 | vps->setDimensionIdLen(numScalabilityTypes-1, 6 - numBits); |
---|
2851 | numBits = 6; |
---|
2852 | } |
---|
2853 | |
---|
2854 | READ_FLAG( uiCode, "vps_nuh_layer_id_present_flag" ); vps->setNuhLayerIdPresentFlag(uiCode ? true : false); |
---|
2855 | vps->setLayerIdInNuh(0, 0); |
---|
2856 | vps->setLayerIdInVps(0, 0); |
---|
2857 | for(i = 1; i < vps->getMaxLayers(); i++) |
---|
2858 | { |
---|
2859 | if( vps->getNuhLayerIdPresentFlag() ) |
---|
2860 | { |
---|
2861 | READ_CODE( 6, uiCode, "layer_id_in_nuh[i]" ); vps->setLayerIdInNuh(i, uiCode); |
---|
2862 | assert( uiCode > vps->getLayerIdInNuh(i-1) ); |
---|
2863 | } |
---|
2864 | else |
---|
2865 | { |
---|
2866 | vps->setLayerIdInNuh(i, i); |
---|
2867 | } |
---|
2868 | vps->setLayerIdInVps(vps->getLayerIdInNuh(i), i); |
---|
2869 | |
---|
2870 | if( !vps->getSplittingFlag() ) |
---|
2871 | { |
---|
2872 | for(j = 0; j < numScalabilityTypes; j++) |
---|
2873 | { |
---|
2874 | READ_CODE( vps->getDimensionIdLen(j), uiCode, "dimension_id[i][j]" ); vps->setDimensionId(i, j, uiCode); |
---|
2875 | #if !AUXILIARY_PICTURES |
---|
2876 | assert( uiCode <= vps->getMaxLayerId() ); |
---|
2877 | #endif |
---|
2878 | } |
---|
2879 | } |
---|
2880 | } |
---|
2881 | #endif |
---|
2882 | #if VIEW_ID_RELATED_SIGNALING |
---|
2883 | // if ( pcVPS->getNumViews() > 1 ) |
---|
2884 | // However, this is a bug in the text since, view_id_len_minus1 is needed to parse view_id_val. |
---|
2885 | { |
---|
2886 | #if O0109_VIEW_ID_LEN |
---|
2887 | READ_CODE( 4, uiCode, "view_id_len" ); vps->setViewIdLen( uiCode ); |
---|
2888 | #else |
---|
2889 | READ_CODE( 4, uiCode, "view_id_len_minus1" ); vps->setViewIdLenMinus1( uiCode ); |
---|
2890 | #endif |
---|
2891 | } |
---|
2892 | |
---|
2893 | #if O0109_VIEW_ID_LEN |
---|
2894 | if ( vps->getViewIdLen() > 0 ) |
---|
2895 | { |
---|
2896 | for( i = 0; i < vps->getNumViews(); i++ ) |
---|
2897 | { |
---|
2898 | READ_CODE( vps->getViewIdLen( ), uiCode, "view_id_val[i]" ); vps->setViewIdVal( i, uiCode ); |
---|
2899 | } |
---|
2900 | } |
---|
2901 | #else |
---|
2902 | for( i = 0; i < vps->getNumViews(); i++ ) |
---|
2903 | { |
---|
2904 | READ_CODE( vps->getViewIdLenMinus1( ) + 1, uiCode, "view_id_val[i]" ); vps->setViewIdVal( i, uiCode ); |
---|
2905 | } |
---|
2906 | #endif |
---|
2907 | #endif // view id related signaling |
---|
2908 | #if VPS_EXTN_DIRECT_REF_LAYERS |
---|
2909 | // For layer 0 |
---|
2910 | vps->setNumDirectRefLayers(0, 0); |
---|
2911 | // For other layers |
---|
2912 | for( Int layerCtr = 1; layerCtr <= vps->getMaxLayers() - 1; layerCtr++) |
---|
2913 | { |
---|
2914 | UInt numDirectRefLayers = 0; |
---|
2915 | for( Int refLayerCtr = 0; refLayerCtr < layerCtr; refLayerCtr++) |
---|
2916 | { |
---|
2917 | READ_FLAG(uiCode, "direct_dependency_flag[i][j]" ); vps->setDirectDependencyFlag(layerCtr, refLayerCtr, uiCode? true : false); |
---|
2918 | if(uiCode) |
---|
2919 | { |
---|
2920 | vps->setRefLayerId(layerCtr, numDirectRefLayers, refLayerCtr); |
---|
2921 | numDirectRefLayers++; |
---|
2922 | } |
---|
2923 | } |
---|
2924 | vps->setNumDirectRefLayers(layerCtr, numDirectRefLayers); |
---|
2925 | } |
---|
2926 | #endif |
---|
2927 | #if Q0078_ADD_LAYER_SETS |
---|
2928 | #if O0092_0094_DEPENDENCY_CONSTRAINT // Moved here |
---|
2929 | vps->setNumRefLayers(); |
---|
2930 | |
---|
2931 | if (vps->getMaxLayers() > MAX_REF_LAYERS) |
---|
2932 | { |
---|
2933 | for (i = 1; i < vps->getMaxLayers(); i++) |
---|
2934 | { |
---|
2935 | assert(vps->getNumRefLayers(vps->getLayerIdInNuh(i)) <= MAX_REF_LAYERS); |
---|
2936 | } |
---|
2937 | } |
---|
2938 | #endif |
---|
2939 | vps->setPredictedLayerIds(); |
---|
2940 | vps->setTreePartitionLayerIdList(); |
---|
2941 | #endif |
---|
2942 | #if MOVE_ADDN_LS_SIGNALLING |
---|
2943 | #if Q0078_ADD_LAYER_SETS |
---|
2944 | if (vps->getNumIndependentLayers() > 1) |
---|
2945 | { |
---|
2946 | READ_UVLC(uiCode, "num_add_layer_sets"); vps->setNumAddLayerSets(uiCode); |
---|
2947 | for (i = 0; i < vps->getNumAddLayerSets(); i++) |
---|
2948 | { |
---|
2949 | for (j = 1; j < vps->getNumIndependentLayers(); j++) |
---|
2950 | { |
---|
2951 | int len = 1; |
---|
2952 | while ((1 << len) < (vps->getNumLayersInTreePartition(j) + 1)) |
---|
2953 | { |
---|
2954 | len++; |
---|
2955 | } |
---|
2956 | READ_CODE(len, uiCode, "highest_layer_idx_plus1[i][j]"); vps->setHighestLayerIdxPlus1(i, j, uiCode); |
---|
2957 | } |
---|
2958 | } |
---|
2959 | vps->setNumLayerSets(vps->getNumLayerSets() + vps->getNumAddLayerSets()); |
---|
2960 | #if FIX_LAYER_ID_INIT |
---|
2961 | vps->deriveLayerIdListVariablesForAddLayerSets(); |
---|
2962 | #else |
---|
2963 | vps->setLayerIdIncludedFlagsForAddLayerSets(); |
---|
2964 | #endif |
---|
2965 | } |
---|
2966 | else |
---|
2967 | { |
---|
2968 | vps->setNumAddLayerSets(0); |
---|
2969 | } |
---|
2970 | #endif |
---|
2971 | #endif |
---|
2972 | #if VPS_TSLAYERS |
---|
2973 | READ_FLAG( uiCode, "vps_sub_layers_max_minus1_present_flag"); vps->setMaxTSLayersPresentFlag(uiCode ? true : false); |
---|
2974 | |
---|
2975 | if (vps->getMaxTSLayersPresentFlag()) |
---|
2976 | { |
---|
2977 | for(i = 0; i < vps->getMaxLayers(); i++) |
---|
2978 | { |
---|
2979 | READ_CODE( 3, uiCode, "sub_layers_vps_max_minus1[i]" ); vps->setMaxTSLayersMinus1(i, uiCode); |
---|
2980 | } |
---|
2981 | } |
---|
2982 | else |
---|
2983 | { |
---|
2984 | for( i = 0; i < vps->getMaxLayers(); i++) |
---|
2985 | { |
---|
2986 | vps->setMaxTSLayersMinus1(i, vps->getMaxTLayers()-1); |
---|
2987 | } |
---|
2988 | } |
---|
2989 | #endif |
---|
2990 | READ_FLAG( uiCode, "max_tid_ref_present_flag"); vps->setMaxTidRefPresentFlag(uiCode ? true : false); |
---|
2991 | if (vps->getMaxTidRefPresentFlag()) |
---|
2992 | { |
---|
2993 | for(i = 0; i < vps->getMaxLayers() - 1; i++) |
---|
2994 | { |
---|
2995 | #if O0225_MAX_TID_FOR_REF_LAYERS |
---|
2996 | for( j = i+1; j <= vps->getMaxLayers() - 1; j++) |
---|
2997 | { |
---|
2998 | if(vps->getDirectDependencyFlag(j, i)) |
---|
2999 | { |
---|
3000 | READ_CODE( 3, uiCode, "max_tid_il_ref_pics_plus1[i][j]" ); vps->setMaxTidIlRefPicsPlus1(i, j, uiCode); |
---|
3001 | } |
---|
3002 | } |
---|
3003 | #else |
---|
3004 | READ_CODE( 3, uiCode, "max_tid_il_ref_pics_plus1[i]" ); vps->setMaxTidIlRefPicsPlus1(i, uiCode); |
---|
3005 | assert( uiCode <= vps->getMaxTLayers()); |
---|
3006 | #endif |
---|
3007 | } |
---|
3008 | } |
---|
3009 | else |
---|
3010 | { |
---|
3011 | for(i = 0; i < vps->getMaxLayers() - 1; i++) |
---|
3012 | { |
---|
3013 | #if O0225_MAX_TID_FOR_REF_LAYERS |
---|
3014 | for( j = i+1; j <= vps->getMaxLayers() - 1; j++) |
---|
3015 | { |
---|
3016 | vps->setMaxTidIlRefPicsPlus1(i, j, 7); |
---|
3017 | } |
---|
3018 | #else |
---|
3019 | vps->setMaxTidIlRefPicsPlus1(i, 7); |
---|
3020 | #endif |
---|
3021 | } |
---|
3022 | } |
---|
3023 | READ_FLAG( uiCode, "all_ref_layers_active_flag" ); vps->setIlpSshSignalingEnabledFlag(uiCode ? true : false); |
---|
3024 | #if VPS_EXTN_PROFILE_INFO |
---|
3025 | // Profile-tier-level signalling |
---|
3026 | #if !VPS_EXTN_UEV_CODING |
---|
3027 | READ_CODE( 10, uiCode, "vps_number_layer_sets_minus1" ); assert( uiCode == (vps->getNumLayerSets() - 1) ); |
---|
3028 | READ_CODE( 6, uiCode, "vps_num_profile_tier_level_minus1"); vps->setNumProfileTierLevel( uiCode + 1 ); |
---|
3029 | #else |
---|
3030 | READ_UVLC( uiCode, "vps_num_profile_tier_level_minus1"); vps->setNumProfileTierLevel( uiCode + 1 ); |
---|
3031 | #endif |
---|
3032 | #if PER_LAYER_PTL |
---|
3033 | Int const numBitsForPtlIdx = vps->calculateLenOfSyntaxElement( vps->getNumProfileTierLevel() ); |
---|
3034 | #endif |
---|
3035 | #if !MULTIPLE_PTL_SUPPORT |
---|
3036 | vps->getPTLForExtnPtr()->resize(vps->getNumProfileTierLevel()); |
---|
3037 | #endif |
---|
3038 | #if LIST_OF_PTL |
---|
3039 | for(Int idx = vps->getBaseLayerInternalFlag() ? 2 : 1; idx <= vps->getNumProfileTierLevel() - 1; idx++) |
---|
3040 | #else |
---|
3041 | for(Int idx = 1; idx <= vps->getNumProfileTierLevel() - 1; idx++) |
---|
3042 | #endif |
---|
3043 | { |
---|
3044 | READ_FLAG( uiCode, "vps_profile_present_flag[i]" ); vps->setProfilePresentFlag(idx, uiCode ? true : false); |
---|
3045 | if( !vps->getProfilePresentFlag(idx) ) |
---|
3046 | { |
---|
3047 | #if P0048_REMOVE_PROFILE_REF |
---|
3048 | // Copy profile information from previous one |
---|
3049 | #if MULTIPLE_PTL_SUPPORT |
---|
3050 | vps->getPTL(idx)->copyProfileInfo( vps->getPTL( idx - 1 ) ); |
---|
3051 | #else |
---|
3052 | vps->getPTLForExtn(idx)->copyProfileInfo( (idx==1) ? vps->getPTL() : vps->getPTLForExtn( idx - 1 ) ); |
---|
3053 | #endif |
---|
3054 | #else |
---|
3055 | READ_CODE( 6, uiCode, "profile_ref_minus1[i]" ); vps->setProfileLayerSetRef(idx, uiCode + 1); |
---|
3056 | #if O0109_PROF_REF_MINUS1 |
---|
3057 | assert( vps->getProfileLayerSetRef(idx) <= idx ); |
---|
3058 | #else |
---|
3059 | assert( vps->getProfileLayerSetRef(idx) < idx ); |
---|
3060 | #endif |
---|
3061 | // Copy profile information as indicated |
---|
3062 | vps->getPTLForExtn(idx)->copyProfileInfo( vps->getPTLForExtn( vps->getProfileLayerSetRef(idx) ) ); |
---|
3063 | #endif |
---|
3064 | } |
---|
3065 | #if MULTIPLE_PTL_SUPPORT |
---|
3066 | parsePTL( vps->getPTL(idx), vps->getProfilePresentFlag(idx), vps->getMaxTLayers() - 1 ); |
---|
3067 | #else |
---|
3068 | parsePTL( vps->getPTLForExtn(idx), vps->getProfilePresentFlag(idx), vps->getMaxTLayers() - 1 ); |
---|
3069 | #endif |
---|
3070 | } |
---|
3071 | #endif |
---|
3072 | |
---|
3073 | #if !MOVE_ADDN_LS_SIGNALLING |
---|
3074 | #if Q0078_ADD_LAYER_SETS |
---|
3075 | if (vps->getNumIndependentLayers() > 1) |
---|
3076 | { |
---|
3077 | READ_UVLC(uiCode, "num_add_layer_sets"); vps->setNumAddLayerSets(uiCode); |
---|
3078 | for (i = 0; i < vps->getNumAddLayerSets(); i++) |
---|
3079 | { |
---|
3080 | for (j = 1; j < vps->getNumIndependentLayers(); j++) |
---|
3081 | { |
---|
3082 | int len = 1; |
---|
3083 | while ((1 << len) < (vps->getNumLayersInTreePartition(j) + 1)) |
---|
3084 | { |
---|
3085 | len++; |
---|
3086 | } |
---|
3087 | READ_CODE(len, uiCode, "highest_layer_idx_plus1[i][j]"); vps->setHighestLayerIdxPlus1(i, j, uiCode); |
---|
3088 | } |
---|
3089 | } |
---|
3090 | vps->setNumLayerSets(vps->getNumLayerSets() + vps->getNumAddLayerSets()); |
---|
3091 | vps->setLayerIdIncludedFlagsForAddLayerSets(); |
---|
3092 | } |
---|
3093 | #endif |
---|
3094 | #endif |
---|
3095 | |
---|
3096 | #if !VPS_EXTN_UEV_CODING |
---|
3097 | READ_FLAG( uiCode, "more_output_layer_sets_than_default_flag" ); vps->setMoreOutputLayerSetsThanDefaultFlag( uiCode ? true : false ); |
---|
3098 | Int numOutputLayerSets = 0; |
---|
3099 | if(! vps->getMoreOutputLayerSetsThanDefaultFlag() ) |
---|
3100 | { |
---|
3101 | numOutputLayerSets = vps->getNumLayerSets(); |
---|
3102 | } |
---|
3103 | else |
---|
3104 | { |
---|
3105 | READ_CODE( 10, uiCode, "num_add_output_layer_sets" ); vps->setNumAddOutputLayerSets( uiCode ); |
---|
3106 | numOutputLayerSets = vps->getNumLayerSets() + vps->getNumAddOutputLayerSets(); |
---|
3107 | } |
---|
3108 | #else |
---|
3109 | |
---|
3110 | #if Q0165_NUM_ADD_OUTPUT_LAYER_SETS |
---|
3111 | if( vps->getNumLayerSets() > 1 ) |
---|
3112 | { |
---|
3113 | READ_UVLC( uiCode, "num_add_olss" ); vps->setNumAddOutputLayerSets( uiCode ); |
---|
3114 | READ_CODE( 2, uiCode, "default_output_layer_idc" ); vps->setDefaultTargetOutputLayerIdc( uiCode ); |
---|
3115 | } |
---|
3116 | else |
---|
3117 | { |
---|
3118 | vps->setNumAddOutputLayerSets( 0 ); |
---|
3119 | } |
---|
3120 | #else |
---|
3121 | READ_UVLC( uiCode, "num_add_output_layer_sets" ); vps->setNumAddOutputLayerSets( uiCode ); |
---|
3122 | #endif |
---|
3123 | |
---|
3124 | // The value of num_add_olss shall be in the range of 0 to 1023, inclusive. |
---|
3125 | assert( vps->getNumAddOutputLayerSets() >= 0 && vps->getNumAddOutputLayerSets() < 1024 ); |
---|
3126 | |
---|
3127 | Int numOutputLayerSets = vps->getNumLayerSets() + vps->getNumAddOutputLayerSets(); |
---|
3128 | #endif |
---|
3129 | |
---|
3130 | #if P0295_DEFAULT_OUT_LAYER_IDC |
---|
3131 | #if !Q0165_NUM_ADD_OUTPUT_LAYER_SETS |
---|
3132 | if( numOutputLayerSets > 1 ) |
---|
3133 | { |
---|
3134 | READ_CODE( 2, uiCode, "default_target_output_layer_idc" ); vps->setDefaultTargetOutputLayerIdc( uiCode ); |
---|
3135 | } |
---|
3136 | #endif |
---|
3137 | vps->setNumOutputLayerSets( numOutputLayerSets ); |
---|
3138 | #if NECESSARY_LAYER_FLAG |
---|
3139 | // Default output layer set |
---|
3140 | vps->setOutputLayerSetIdx(0, 0); |
---|
3141 | vps->setOutputLayerFlag(0, 0, true); |
---|
3142 | vps->deriveNecessaryLayerFlag(0); |
---|
3143 | #if PER_LAYER_PTL |
---|
3144 | vps->getProfileLevelTierIdx()->resize(numOutputLayerSets); |
---|
3145 | vps->getProfileLevelTierIdx(0)->push_back( vps->getBaseLayerInternalFlag() && vps->getMaxLayers() > 1 ? 1 : 0); |
---|
3146 | #endif |
---|
3147 | #endif |
---|
3148 | for(i = 1; i < numOutputLayerSets; i++) |
---|
3149 | { |
---|
3150 | #if VPS_FIX_TO_MATCH_SPEC |
---|
3151 | if( vps->getNumLayerSets() > 2 && i >= vps->getNumLayerSets() ) |
---|
3152 | #else |
---|
3153 | if( i > (vps->getNumLayerSets() - 1) ) |
---|
3154 | #endif |
---|
3155 | { |
---|
3156 | Int numBits = 1; |
---|
3157 | while ((1 << numBits) < (vps->getNumLayerSets() - 1)) |
---|
3158 | { |
---|
3159 | numBits++; |
---|
3160 | } |
---|
3161 | READ_CODE( numBits, uiCode, "layer_set_idx_for_ols_minus1"); vps->setOutputLayerSetIdx( i, uiCode + 1); |
---|
3162 | } |
---|
3163 | else |
---|
3164 | { |
---|
3165 | vps->setOutputLayerSetIdx( i, i ); |
---|
3166 | } |
---|
3167 | Int layerSetIdxForOutputLayerSet = vps->getOutputLayerSetIdx(i); |
---|
3168 | #if Q0078_ADD_LAYER_SETS |
---|
3169 | #if VPS_FIX_TO_MATCH_SPEC |
---|
3170 | if( i > vps->getVpsNumLayerSetsMinus1() || vps->getDefaultTargetOutputLayerIdc() == 2 ) |
---|
3171 | #else |
---|
3172 | if( i > vps->getVpsNumLayerSetsMinus1() || vps->getDefaultTargetOutputLayerIdc() >= 2 ) |
---|
3173 | #endif |
---|
3174 | #else |
---|
3175 | #if VPS_FIX_TO_MATCH_SPEC |
---|
3176 | if( i > (vps->getNumLayerSets() - 1) || vps->getDefaultTargetOutputLayerIdc() == 2 ) |
---|
3177 | #else |
---|
3178 | if( i > (vps->getNumLayerSets() - 1) || vps->getDefaultTargetOutputLayerIdc() >= 2 ) |
---|
3179 | #endif |
---|
3180 | #endif |
---|
3181 | { |
---|
3182 | #if NUM_OL_FLAGS |
---|
3183 | for(j = 0; j < vps->getNumLayersInIdList(layerSetIdxForOutputLayerSet); j++) |
---|
3184 | #else |
---|
3185 | for(j = 0; j < vps->getNumLayersInIdList(lsIdx) - 1; j++) |
---|
3186 | #endif |
---|
3187 | { |
---|
3188 | READ_FLAG( uiCode, "output_layer_flag[i][j]"); vps->setOutputLayerFlag(i, j, uiCode); |
---|
3189 | } |
---|
3190 | } |
---|
3191 | else |
---|
3192 | { |
---|
3193 | // i <= (vps->getNumLayerSets() - 1) |
---|
3194 | // Assign OutputLayerFlag depending on default_one_target_output_layer_flag |
---|
3195 | if( vps->getDefaultTargetOutputLayerIdc() == 1 ) |
---|
3196 | { |
---|
3197 | for(j = 0; j < vps->getNumLayersInIdList(layerSetIdxForOutputLayerSet); j++) |
---|
3198 | { |
---|
3199 | #if DEF_OPT_LAYER_IDC |
---|
3200 | vps->setOutputLayerFlag(i, j, (j == (vps->getNumLayersInIdList(layerSetIdxForOutputLayerSet)-1)) ); |
---|
3201 | |
---|
3202 | #else |
---|
3203 | vps->setOutputLayerFlag(i, j, (j == (vps->getNumLayersInIdList(layerSetIdxForOutputLayerSet)-1)) && (vps->getDimensionId(j,1) == 0) ); |
---|
3204 | #endif |
---|
3205 | } |
---|
3206 | } |
---|
3207 | else if ( vps->getDefaultTargetOutputLayerIdc() == 0 ) |
---|
3208 | { |
---|
3209 | for(j = 0; j < vps->getNumLayersInIdList(layerSetIdxForOutputLayerSet); j++) |
---|
3210 | { |
---|
3211 | vps->setOutputLayerFlag(i, j, 1); |
---|
3212 | } |
---|
3213 | } |
---|
3214 | } |
---|
3215 | #if NECESSARY_LAYER_FLAG |
---|
3216 | vps->deriveNecessaryLayerFlag(i); |
---|
3217 | #endif |
---|
3218 | #if PER_LAYER_PTL |
---|
3219 | vps->getProfileLevelTierIdx(i)->assign(vps->getNumLayersInIdList(layerSetIdxForOutputLayerSet), -1); |
---|
3220 | for(j = 0; j < vps->getNumLayersInIdList(layerSetIdxForOutputLayerSet) ; j++) |
---|
3221 | { |
---|
3222 | #if VPS_FIX_TO_MATCH_SPEC |
---|
3223 | if( vps->getNecessaryLayerFlag(i, j) && (vps->getNumProfileTierLevel()-1) > 0 ) |
---|
3224 | #else |
---|
3225 | if( vps->getNecessaryLayerFlag(i, j) ) |
---|
3226 | #endif |
---|
3227 | { |
---|
3228 | READ_CODE( numBitsForPtlIdx, uiCode, "profile_tier_level_idx[i]" ); |
---|
3229 | vps->setProfileLevelTierIdx(i, j, uiCode ); |
---|
3230 | |
---|
3231 | #if MULTIPLE_PTL_SUPPORT |
---|
3232 | //For conformance checking |
---|
3233 | //Conformance of a layer in an output operation point associated with an OLS in a bitstream to the Scalable Main profile is indicated as follows: |
---|
3234 | //If OpTid of the output operation point is equal to vps_max_sub_layer_minus1, the conformance is indicated by general_profile_idc being equal to 7 or general_profile_compatibility_flag[ 7 ] being equal to 1 |
---|
3235 | //Conformance of a layer in an output operation point associated with an OLS in a bitstream to the Scalable Main 10 profile is indicated as follows: |
---|
3236 | //If OpTid of the output operation point is equal to vps_max_sub_layer_minus1, the conformance is indicated by general_profile_idc being equal to 7 or general_profile_compatibility_flag[ 7 ] being equal to 1 |
---|
3237 | //The following assert may be updated / upgraded to take care of general_profile_compatibility_flag. |
---|
3238 | #if R0235_SMALLEST_LAYER_ID |
---|
3239 | // The assertion below is not valid for independent non-base layers |
---|
3240 | if (vps->getNumAddLayerSets() == 0) |
---|
3241 | { |
---|
3242 | #endif |
---|
3243 | if( j > 0 && vps->getLayerSetLayerIdList(layerSetIdxForOutputLayerSet, j) != 0 && vps->getLayerSetLayerIdList(layerSetIdxForOutputLayerSet, j - 1) != 0 && vps->getNecessaryLayerFlag(i, j-1) ) |
---|
3244 | { |
---|
3245 | assert(vps->getPTL(vps->getProfileLevelTierIdx(i, j))->getGeneralPTL()->getProfileIdc() == vps->getPTL(vps->getProfileLevelTierIdx(i, j - 1))->getGeneralPTL()->getProfileIdc() || |
---|
3246 | vps->getPTL(vps->getProfileLevelTierIdx(i, j - 1))->getGeneralPTL()->getProfileCompatibilityFlag(vps->getPTL(vps->getProfileLevelTierIdx(i, j))->getGeneralPTL()->getProfileIdc()) || |
---|
3247 | vps->getPTL(vps->getProfileLevelTierIdx(i, j))->getGeneralPTL()->getProfileCompatibilityFlag(vps->getPTL(vps->getProfileLevelTierIdx(i, j - 1))->getGeneralPTL()->getProfileIdc()) ); |
---|
3248 | } |
---|
3249 | #if R0235_SMALLEST_LAYER_ID |
---|
3250 | } |
---|
3251 | #endif |
---|
3252 | #endif |
---|
3253 | } |
---|
3254 | } |
---|
3255 | #else |
---|
3256 | Int numBits = 1; |
---|
3257 | while ((1 << numBits) < (vps->getNumProfileTierLevel())) |
---|
3258 | { |
---|
3259 | numBits++; |
---|
3260 | } |
---|
3261 | READ_CODE( numBits, uiCode, "profile_tier_level_idx[i]" ); vps->setProfileLevelTierIdx(i, uiCode); |
---|
3262 | #endif |
---|
3263 | #if P0300_ALT_OUTPUT_LAYER_FLAG |
---|
3264 | NumOutputLayersInOutputLayerSet[i] = 0; |
---|
3265 | for (j = 0; j < vps->getNumLayersInIdList(layerSetIdxForOutputLayerSet); j++) |
---|
3266 | { |
---|
3267 | NumOutputLayersInOutputLayerSet[i] += vps->getOutputLayerFlag(i, j); |
---|
3268 | if (vps->getOutputLayerFlag(i, j)) |
---|
3269 | { |
---|
3270 | OlsHighestOutputLayerId[i] = vps->getLayerSetLayerIdList(layerSetIdxForOutputLayerSet, j); |
---|
3271 | } |
---|
3272 | } |
---|
3273 | if (NumOutputLayersInOutputLayerSet[i] == 1 && vps->getNumDirectRefLayers(OlsHighestOutputLayerId[i]) > 0) |
---|
3274 | { |
---|
3275 | READ_FLAG(uiCode, "alt_output_layer_flag[i]"); |
---|
3276 | vps->setAltOuputLayerFlag(i, uiCode ? true : false); |
---|
3277 | } |
---|
3278 | #if ALT_OPT_LAYER_FLAG |
---|
3279 | else |
---|
3280 | { |
---|
3281 | uiCode=0; |
---|
3282 | vps->setAltOuputLayerFlag(i, uiCode ? true : false); |
---|
3283 | } |
---|
3284 | #endif |
---|
3285 | #if Q0165_OUTPUT_LAYER_SET |
---|
3286 | assert( NumOutputLayersInOutputLayerSet[i]>0 ); |
---|
3287 | #endif |
---|
3288 | |
---|
3289 | #endif |
---|
3290 | } |
---|
3291 | #if NECESSARY_LAYER_FLAG |
---|
3292 | vps->checkNecessaryLayerFlagCondition(); |
---|
3293 | #endif |
---|
3294 | #else |
---|
3295 | if( numOutputLayerSets > 1 ) |
---|
3296 | { |
---|
3297 | #if O0109_DEFAULT_ONE_OUT_LAYER_IDC |
---|
3298 | READ_CODE( 2, uiCode, "default_one_target_output_layer_idc" ); vps->setDefaultOneTargetOutputLayerIdc( uiCode ); |
---|
3299 | #else |
---|
3300 | READ_FLAG( uiCode, "default_one_target_output_layer_flag" ); vps->setDefaultOneTargetOutputLayerFlag( uiCode ? true : false ); |
---|
3301 | #endif |
---|
3302 | } |
---|
3303 | vps->setNumOutputLayerSets( numOutputLayerSets ); |
---|
3304 | |
---|
3305 | for(i = 1; i < numOutputLayerSets; i++) |
---|
3306 | { |
---|
3307 | if( i > (vps->getNumLayerSets() - 1) ) |
---|
3308 | { |
---|
3309 | Int numBits = 1; |
---|
3310 | while ((1 << numBits) < (vps->getNumLayerSets() - 1)) |
---|
3311 | { |
---|
3312 | numBits++; |
---|
3313 | } |
---|
3314 | READ_CODE( numBits, uiCode, "output_layer_set_idx_minus1"); vps->setOutputLayerSetIdx( i, uiCode + 1); |
---|
3315 | Int lsIdx = vps->getOutputLayerSetIdx(i); |
---|
3316 | #if NUM_OL_FLAGS |
---|
3317 | for(j = 0; j < vps->getNumLayersInIdList(lsIdx) ; j++) |
---|
3318 | #else |
---|
3319 | for(j = 0; j < vps->getNumLayersInIdList(lsIdx) - 1; j++) |
---|
3320 | #endif |
---|
3321 | { |
---|
3322 | READ_FLAG( uiCode, "output_layer_flag[i][j]"); vps->setOutputLayerFlag(i, j, uiCode); |
---|
3323 | } |
---|
3324 | } |
---|
3325 | else |
---|
3326 | { |
---|
3327 | #if VPS_DPB_SIZE_TABLE |
---|
3328 | vps->setOutputLayerSetIdx( i, i ); |
---|
3329 | #endif |
---|
3330 | // i <= (vps->getNumLayerSets() - 1) |
---|
3331 | // Assign OutputLayerFlag depending on default_one_target_output_layer_flag |
---|
3332 | Int lsIdx = i; |
---|
3333 | #if O0109_DEFAULT_ONE_OUT_LAYER_IDC |
---|
3334 | if( vps->getDefaultOneTargetOutputLayerIdc() == 1 ) |
---|
3335 | { |
---|
3336 | for(j = 0; j < vps->getNumLayersInIdList(lsIdx); j++) |
---|
3337 | { |
---|
3338 | #if O0135_DEFAULT_ONE_OUT_SEMANTIC |
---|
3339 | #if DEF_OPT_LAYER_IDC |
---|
3340 | vps->setOutputLayerFlag(i, j, (j == (vps->getNumLayersInIdList(lsIdx)-1)) ); |
---|
3341 | #else |
---|
3342 | vps->setOutputLayerFlag(i, j, (j == (vps->getNumLayersInIdList(lsIdx)-1)) && (vps->getDimensionId(j,1)==0) ); |
---|
3343 | #endif |
---|
3344 | #else |
---|
3345 | vps->setOutputLayerFlag(i, j, (j == (vps->getNumLayersInIdList(lsIdx)-1))); |
---|
3346 | #endif |
---|
3347 | } |
---|
3348 | } |
---|
3349 | else if ( vps->getDefaultOneTargetOutputLayerIdc() == 0 ) |
---|
3350 | { |
---|
3351 | for(j = 0; j < vps->getNumLayersInIdList(lsIdx); j++) |
---|
3352 | { |
---|
3353 | vps->setOutputLayerFlag(i, j, 1); |
---|
3354 | } |
---|
3355 | } |
---|
3356 | else |
---|
3357 | { |
---|
3358 | // Other values of default_one_target_output_layer_idc than 0 and 1 are reserved for future use. |
---|
3359 | } |
---|
3360 | #else |
---|
3361 | if( vps->getDefaultOneTargetOutputLayerFlag() ) |
---|
3362 | { |
---|
3363 | for(j = 0; j < vps->getNumLayersInIdList(lsIdx); j++) |
---|
3364 | { |
---|
3365 | vps->setOutputLayerFlag(i, j, (j == (vps->getNumLayersInIdList(lsIdx)-1))); |
---|
3366 | } |
---|
3367 | } |
---|
3368 | else |
---|
3369 | { |
---|
3370 | for(j = 0; j < vps->getNumLayersInIdList(lsIdx); j++) |
---|
3371 | { |
---|
3372 | vps->setOutputLayerFlag(i, j, 1); |
---|
3373 | } |
---|
3374 | } |
---|
3375 | #endif |
---|
3376 | } |
---|
3377 | Int numBits = 1; |
---|
3378 | while ((1 << numBits) < (vps->getNumProfileTierLevel())) |
---|
3379 | { |
---|
3380 | numBits++; |
---|
3381 | } |
---|
3382 | READ_CODE( numBits, uiCode, "profile_level_tier_idx[i]" ); vps->setProfileLevelTierIdx(i, uiCode); |
---|
3383 | } |
---|
3384 | #endif |
---|
3385 | |
---|
3386 | #if !P0300_ALT_OUTPUT_LAYER_FLAG |
---|
3387 | #if O0153_ALT_OUTPUT_LAYER_FLAG |
---|
3388 | if( vps->getMaxLayers() > 1 ) |
---|
3389 | { |
---|
3390 | READ_FLAG( uiCode, "alt_output_layer_flag"); |
---|
3391 | vps->setAltOuputLayerFlag( uiCode ? true : false ); |
---|
3392 | } |
---|
3393 | #endif |
---|
3394 | #endif |
---|
3395 | |
---|
3396 | #if REPN_FORMAT_IN_VPS |
---|
3397 | #if Q0195_REP_FORMAT_CLEANUP |
---|
3398 | READ_UVLC( uiCode, "vps_num_rep_formats_minus1" ); |
---|
3399 | vps->setVpsNumRepFormats( uiCode + 1 ); |
---|
3400 | |
---|
3401 | // The value of vps_num_rep_formats_minus1 shall be in the range of 0 to 255, inclusive. |
---|
3402 | assert( vps->getVpsNumRepFormats() > 0 && vps->getVpsNumRepFormats() <= 256 ); |
---|
3403 | |
---|
3404 | for(i = 0; i < vps->getVpsNumRepFormats(); i++) |
---|
3405 | { |
---|
3406 | // Read rep_format_structures |
---|
3407 | parseRepFormat( vps->getVpsRepFormat(i), i > 0 ? vps->getVpsRepFormat(i-1) : 0 ); |
---|
3408 | } |
---|
3409 | |
---|
3410 | // Default assignment for layer 0 |
---|
3411 | vps->setVpsRepFormatIdx( 0, 0 ); |
---|
3412 | |
---|
3413 | if( vps->getVpsNumRepFormats() > 1 ) |
---|
3414 | { |
---|
3415 | READ_FLAG( uiCode, "rep_format_idx_present_flag"); |
---|
3416 | vps->setRepFormatIdxPresentFlag( uiCode ? true : false ); |
---|
3417 | } |
---|
3418 | else |
---|
3419 | { |
---|
3420 | // When not present, the value of rep_format_idx_present_flag is inferred to be equal to 0 |
---|
3421 | vps->setRepFormatIdxPresentFlag( false ); |
---|
3422 | } |
---|
3423 | |
---|
3424 | if( vps->getRepFormatIdxPresentFlag() ) |
---|
3425 | { |
---|
3426 | #if VPS_FIX_TO_MATCH_SPEC |
---|
3427 | for( i = vps->getBaseLayerInternalFlag() ? 1 : 0; i < vps->getMaxLayers(); i++ ) |
---|
3428 | #else |
---|
3429 | for (i = 1; i < vps->getMaxLayers(); i++) |
---|
3430 | #endif |
---|
3431 | { |
---|
3432 | Int numBits = 1; |
---|
3433 | while ((1 << numBits) < (vps->getVpsNumRepFormats())) |
---|
3434 | { |
---|
3435 | numBits++; |
---|
3436 | } |
---|
3437 | READ_CODE( numBits, uiCode, "vps_rep_format_idx[i]" ); |
---|
3438 | vps->setVpsRepFormatIdx( i, uiCode ); |
---|
3439 | } |
---|
3440 | } |
---|
3441 | else |
---|
3442 | { |
---|
3443 | // When not present, the value of vps_rep_format_idx[ i ] is inferred to be equal to Min (i, vps_num_rep_formats_minus1) |
---|
3444 | for(i = 1; i < vps->getMaxLayers(); i++) |
---|
3445 | { |
---|
3446 | vps->setVpsRepFormatIdx( i, min( (Int)i, vps->getVpsNumRepFormats()-1 ) ); |
---|
3447 | } |
---|
3448 | } |
---|
3449 | #else |
---|
3450 | READ_FLAG( uiCode, "rep_format_idx_present_flag"); |
---|
3451 | vps->setRepFormatIdxPresentFlag( uiCode ? true : false ); |
---|
3452 | |
---|
3453 | if( vps->getRepFormatIdxPresentFlag() ) |
---|
3454 | { |
---|
3455 | #if O0096_REP_FORMAT_INDEX |
---|
3456 | #if !VPS_EXTN_UEV_CODING |
---|
3457 | READ_CODE( 8, uiCode, "vps_num_rep_formats_minus1" ); |
---|
3458 | #else |
---|
3459 | READ_UVLC( uiCode, "vps_num_rep_formats_minus1" ); |
---|
3460 | #endif |
---|
3461 | #else |
---|
3462 | READ_CODE( 4, uiCode, "vps_num_rep_formats_minus1" ); |
---|
3463 | #endif |
---|
3464 | vps->setVpsNumRepFormats( uiCode + 1 ); |
---|
3465 | } |
---|
3466 | else |
---|
3467 | { |
---|
3468 | // default assignment |
---|
3469 | assert (vps->getMaxLayers() <= 16); // If max_layers_is more than 15, num_rep_formats has to be signaled |
---|
3470 | vps->setVpsNumRepFormats( vps->getMaxLayers() ); |
---|
3471 | } |
---|
3472 | |
---|
3473 | // The value of vps_num_rep_formats_minus1 shall be in the range of 0 to 255, inclusive. |
---|
3474 | assert( vps->getVpsNumRepFormats() > 0 && vps->getVpsNumRepFormats() <= 256 ); |
---|
3475 | |
---|
3476 | for(i = 0; i < vps->getVpsNumRepFormats(); i++) |
---|
3477 | { |
---|
3478 | // Read rep_format_structures |
---|
3479 | parseRepFormat( vps->getVpsRepFormat(i), i > 0 ? vps->getVpsRepFormat(i-1) : 0 ); |
---|
3480 | } |
---|
3481 | |
---|
3482 | // Default assignment for layer 0 |
---|
3483 | vps->setVpsRepFormatIdx( 0, 0 ); |
---|
3484 | if( vps->getRepFormatIdxPresentFlag() ) |
---|
3485 | { |
---|
3486 | for(i = 1; i < vps->getMaxLayers(); i++) |
---|
3487 | { |
---|
3488 | if( vps->getVpsNumRepFormats() > 1 ) |
---|
3489 | { |
---|
3490 | #if O0096_REP_FORMAT_INDEX |
---|
3491 | #if !VPS_EXTN_UEV_CODING |
---|
3492 | READ_CODE( 8, uiCode, "vps_rep_format_idx[i]" ); |
---|
3493 | #else |
---|
3494 | Int numBits = 1; |
---|
3495 | while ((1 << numBits) < (vps->getVpsNumRepFormats())) |
---|
3496 | { |
---|
3497 | numBits++; |
---|
3498 | } |
---|
3499 | READ_CODE( numBits, uiCode, "vps_rep_format_idx[i]" ); |
---|
3500 | #endif |
---|
3501 | #else |
---|
3502 | READ_CODE( 4, uiCode, "vps_rep_format_idx[i]" ); |
---|
3503 | #endif |
---|
3504 | vps->setVpsRepFormatIdx( i, uiCode ); |
---|
3505 | } |
---|
3506 | else |
---|
3507 | { |
---|
3508 | // default assignment - only one rep_format() structure |
---|
3509 | vps->setVpsRepFormatIdx( i, 0 ); |
---|
3510 | } |
---|
3511 | } |
---|
3512 | } |
---|
3513 | else |
---|
3514 | { |
---|
3515 | // default assignment - each layer assigned each rep_format() structure in the order signaled |
---|
3516 | for(i = 1; i < vps->getMaxLayers(); i++) |
---|
3517 | { |
---|
3518 | vps->setVpsRepFormatIdx( i, i ); |
---|
3519 | } |
---|
3520 | } |
---|
3521 | #endif |
---|
3522 | #endif |
---|
3523 | #if RESOLUTION_BASED_DPB |
---|
3524 | vps->assignSubDpbIndices(); |
---|
3525 | #endif |
---|
3526 | READ_FLAG(uiCode, "max_one_active_ref_layer_flag" ); |
---|
3527 | vps->setMaxOneActiveRefLayerFlag(uiCode); |
---|
3528 | #if P0297_VPS_POC_LSB_ALIGNED_FLAG |
---|
3529 | READ_FLAG(uiCode, "vps_poc_lsb_aligned_flag"); |
---|
3530 | vps->setVpsPocLsbAlignedFlag(uiCode); |
---|
3531 | #endif |
---|
3532 | #if O0062_POC_LSB_NOT_PRESENT_FLAG |
---|
3533 | for(i = 1; i< vps->getMaxLayers(); i++) |
---|
3534 | { |
---|
3535 | if( vps->getNumDirectRefLayers( vps->getLayerIdInNuh(i) ) == 0 ) |
---|
3536 | { |
---|
3537 | READ_FLAG(uiCode, "poc_lsb_not_present_flag[i]"); |
---|
3538 | vps->setPocLsbNotPresentFlag(i, uiCode); |
---|
3539 | } |
---|
3540 | } |
---|
3541 | #endif |
---|
3542 | #if O0215_PHASE_ALIGNMENT |
---|
3543 | READ_FLAG( uiCode, "cross_layer_phase_alignment_flag"); vps->setPhaseAlignFlag( uiCode == 1 ? true : false ); |
---|
3544 | #endif |
---|
3545 | |
---|
3546 | #if !IRAP_ALIGN_FLAG_IN_VPS_VUI |
---|
3547 | READ_FLAG(uiCode, "cross_layer_irap_aligned_flag" ); |
---|
3548 | vps->setCrossLayerIrapAlignFlag(uiCode); |
---|
3549 | #endif |
---|
3550 | |
---|
3551 | #if VPS_DPB_SIZE_TABLE |
---|
3552 | parseVpsDpbSizeTable(vps); |
---|
3553 | #endif |
---|
3554 | |
---|
3555 | #if VPS_EXTN_DIRECT_REF_LAYERS |
---|
3556 | READ_UVLC( uiCode, "direct_dep_type_len_minus2"); vps->setDirectDepTypeLen(uiCode+2); |
---|
3557 | #if O0096_DEFAULT_DEPENDENCY_TYPE |
---|
3558 | READ_FLAG(uiCode, "default_direct_dependency_type_flag"); |
---|
3559 | vps->setDefaultDirectDependecyTypeFlag(uiCode == 1? true : false); |
---|
3560 | if (vps->getDefaultDirectDependencyTypeFlag()) |
---|
3561 | { |
---|
3562 | READ_CODE( vps->getDirectDepTypeLen(), uiCode, "default_direct_dependency_type" ); |
---|
3563 | vps->setDefaultDirectDependecyType(uiCode); |
---|
3564 | } |
---|
3565 | #endif |
---|
3566 | |
---|
3567 | #if VPS_FIX_TO_MATCH_SPEC |
---|
3568 | for( i = vps->getBaseLayerInternalFlag() ? 1 : 2; i < vps->getMaxLayers(); i++ ) |
---|
3569 | #else |
---|
3570 | for(i = 1; i < vps->getMaxLayers(); i++) |
---|
3571 | #endif |
---|
3572 | { |
---|
3573 | #if VPS_FIX_TO_MATCH_SPEC |
---|
3574 | for( j = vps->getBaseLayerInternalFlag() ? 0 : 1; j < i; j++ ) |
---|
3575 | #else |
---|
3576 | for(j = 0; j < i; j++) |
---|
3577 | #endif |
---|
3578 | { |
---|
3579 | if (vps->getDirectDependencyFlag(i, j)) |
---|
3580 | { |
---|
3581 | #if O0096_DEFAULT_DEPENDENCY_TYPE |
---|
3582 | if (vps->getDefaultDirectDependencyTypeFlag()) |
---|
3583 | { |
---|
3584 | vps->setDirectDependencyType(i, j, vps->getDefaultDirectDependencyType()); |
---|
3585 | } |
---|
3586 | else |
---|
3587 | { |
---|
3588 | READ_CODE( vps->getDirectDepTypeLen(), uiCode, "direct_dependency_type[i][j]" ); |
---|
3589 | vps->setDirectDependencyType(i, j, uiCode); |
---|
3590 | } |
---|
3591 | #else |
---|
3592 | READ_CODE( vps->getDirectDepTypeLen(), uiCode, "direct_dependency_type[i][j]" ); |
---|
3593 | vps->setDirectDependencyType(i, j, uiCode); |
---|
3594 | #endif |
---|
3595 | } |
---|
3596 | } |
---|
3597 | } |
---|
3598 | #endif |
---|
3599 | #if !Q0078_ADD_LAYER_SETS |
---|
3600 | #if O0092_0094_DEPENDENCY_CONSTRAINT // Moved up |
---|
3601 | vps->setNumRefLayers(); |
---|
3602 | |
---|
3603 | if(vps->getMaxLayers() > MAX_REF_LAYERS) |
---|
3604 | { |
---|
3605 | for(i = 1;i < vps->getMaxLayers(); i++) |
---|
3606 | { |
---|
3607 | assert( vps->getNumRefLayers(vps->getLayerIdInNuh(i)) <= MAX_REF_LAYERS); |
---|
3608 | } |
---|
3609 | } |
---|
3610 | #endif |
---|
3611 | #endif |
---|
3612 | |
---|
3613 | #if P0307_VPS_NON_VUI_EXTENSION |
---|
3614 | READ_UVLC( uiCode, "vps_non_vui_extension_length"); vps->setVpsNonVuiExtLength((Int)uiCode); |
---|
3615 | |
---|
3616 | // The value of vps_non_vui_extension_length shall be in the range of 0 to 4096, inclusive. |
---|
3617 | assert( vps->getVpsNonVuiExtLength() >= 0 && vps->getVpsNonVuiExtLength() <= 4096 ); |
---|
3618 | |
---|
3619 | #if P0307_VPS_NON_VUI_EXT_UPDATE |
---|
3620 | Int nonVuiExtByte = uiCode; |
---|
3621 | for (i = 1; i <= nonVuiExtByte; i++) |
---|
3622 | { |
---|
3623 | READ_CODE( 8, uiCode, "vps_non_vui_extension_data_byte" ); //just parse and discard for now. |
---|
3624 | } |
---|
3625 | #else |
---|
3626 | if ( vps->getVpsNonVuiExtLength() > 0 ) |
---|
3627 | { |
---|
3628 | printf("\n\nUp to the current spec, the value of vps_non_vui_extension_length is supposed to be 0\n"); |
---|
3629 | } |
---|
3630 | #endif |
---|
3631 | #endif |
---|
3632 | |
---|
3633 | #if !O0109_O0199_FLAGS_TO_VUI |
---|
3634 | #if M0040_ADAPTIVE_RESOLUTION_CHANGE |
---|
3635 | READ_FLAG(uiCode, "single_layer_for_non_irap_flag" ); vps->setSingleLayerForNonIrapFlag(uiCode == 1 ? true : false); |
---|
3636 | #endif |
---|
3637 | #if HIGHER_LAYER_IRAP_SKIP_FLAG |
---|
3638 | READ_FLAG(uiCode, "higher_layer_irap_skip_flag" ); vps->setHigherLayerIrapSkipFlag(uiCode == 1 ? true : false); |
---|
3639 | #endif |
---|
3640 | #endif |
---|
3641 | |
---|
3642 | #if P0307_REMOVE_VPS_VUI_OFFSET |
---|
3643 | READ_FLAG( uiCode, "vps_vui_present_flag"); vps->setVpsVuiPresentFlag(uiCode ? true : false); |
---|
3644 | #endif |
---|
3645 | |
---|
3646 | #if O0109_MOVE_VPS_VUI_FLAG |
---|
3647 | if ( vps->getVpsVuiPresentFlag() ) |
---|
3648 | #else |
---|
3649 | READ_FLAG( uiCode, "vps_vui_present_flag" ); |
---|
3650 | if (uiCode) |
---|
3651 | #endif |
---|
3652 | { |
---|
3653 | while ( m_pcBitstream->getNumBitsRead() % 8 != 0 ) |
---|
3654 | { |
---|
3655 | READ_FLAG( uiCode, "vps_vui_alignment_bit_equal_to_one"); assert(uiCode == 1); |
---|
3656 | } |
---|
3657 | parseVPSVUI(vps); |
---|
3658 | } |
---|
3659 | else |
---|
3660 | { |
---|
3661 | // set default values for VPS VUI |
---|
3662 | defaultVPSVUI( vps ); |
---|
3663 | } |
---|
3664 | } |
---|
3665 | |
---|
3666 | Void TDecCavlc::defaultVPSExtension( TComVPS* vps ) |
---|
3667 | { |
---|
3668 | // set default parameters when they are not present |
---|
3669 | Int i, j; |
---|
3670 | |
---|
3671 | // When layer_id_in_nuh[ i ] is not present, the value is inferred to be equal to i. |
---|
3672 | for(i = 0; i < vps->getMaxLayers(); i++) |
---|
3673 | { |
---|
3674 | vps->setLayerIdInNuh(i, i); |
---|
3675 | vps->setLayerIdInVps(vps->getLayerIdInNuh(i), i); |
---|
3676 | } |
---|
3677 | |
---|
3678 | // When not present, sub_layers_vps_max_minus1[ i ] is inferred to be equal to vps_max_sub_layers_minus1. |
---|
3679 | for( i = 0; i < vps->getMaxLayers(); i++) |
---|
3680 | { |
---|
3681 | vps->setMaxTSLayersMinus1(i, vps->getMaxTLayers()-1); |
---|
3682 | } |
---|
3683 | |
---|
3684 | // When not present, max_tid_il_ref_pics_plus1[ i ][ j ] is inferred to be equal to 7. |
---|
3685 | for( i = 0; i < vps->getMaxLayers() - 1; i++ ) |
---|
3686 | { |
---|
3687 | #if O0225_MAX_TID_FOR_REF_LAYERS |
---|
3688 | for( j = i + 1; j < vps->getMaxLayers(); j++ ) |
---|
3689 | { |
---|
3690 | vps->setMaxTidIlRefPicsPlus1(i, j, 7); |
---|
3691 | } |
---|
3692 | #else |
---|
3693 | vps->setMaxTidIlRefPicsPlus1(i, 7); |
---|
3694 | #endif |
---|
3695 | } |
---|
3696 | |
---|
3697 | // When not present, the value of num_add_olss is inferred to be equal to 0. |
---|
3698 | // NumOutputLayerSets = num_add_olss + NumLayerSets |
---|
3699 | vps->setNumOutputLayerSets( vps->getNumLayerSets() ); |
---|
3700 | |
---|
3701 | // For i in the range of 0 to NumOutputLayerSets-1, inclusive, the variable LayerSetIdxForOutputLayerSet[ i ] is derived as specified in the following: |
---|
3702 | // LayerSetIdxForOutputLayerSet[ i ] = ( i <= vps_number_layer_sets_minus1 ) ? i : layer_set_idx_for_ols_minus1[ i ] + 1 |
---|
3703 | for( i = 1; i < vps->getNumOutputLayerSets(); i++ ) |
---|
3704 | { |
---|
3705 | vps->setOutputLayerSetIdx( i, i ); |
---|
3706 | Int lsIdx = vps->getOutputLayerSetIdx(i); |
---|
3707 | |
---|
3708 | for( j = 0; j < vps->getNumLayersInIdList(lsIdx); j++ ) |
---|
3709 | { |
---|
3710 | vps->setOutputLayerFlag(i, j, 1); |
---|
3711 | } |
---|
3712 | } |
---|
3713 | |
---|
3714 | // The value of sub_layer_dpb_info_present_flag[ i ][ 0 ] for any possible value of i is inferred to be equal to 1 |
---|
3715 | // When not present, the value of sub_layer_dpb_info_present_flag[ i ][ j ] for j greater than 0 and any possible value of i, is inferred to be equal to be equal to 0. |
---|
3716 | for( i = 1; i < vps->getNumOutputLayerSets(); i++ ) |
---|
3717 | { |
---|
3718 | vps->setSubLayerDpbInfoPresentFlag( i, 0, true ); |
---|
3719 | } |
---|
3720 | |
---|
3721 | // When not present, the value of vps_num_rep_formats_minus1 is inferred to be equal to MaxLayersMinus1. |
---|
3722 | vps->setVpsNumRepFormats( vps->getMaxLayers() ); |
---|
3723 | |
---|
3724 | // When not present, the value of rep_format_idx_present_flag is inferred to be equal to 0 |
---|
3725 | vps->setRepFormatIdxPresentFlag( false ); |
---|
3726 | |
---|
3727 | if( !vps->getRepFormatIdxPresentFlag() ) |
---|
3728 | { |
---|
3729 | // When not present, the value of vps_rep_format_idx[ i ] is inferred to be equal to Min(i, vps_num_rep_formats_minus1). |
---|
3730 | for(i = 1; i < vps->getMaxLayers(); i++) |
---|
3731 | { |
---|
3732 | vps->setVpsRepFormatIdx( i, min( (Int)i, vps->getVpsNumRepFormats() - 1 ) ); |
---|
3733 | } |
---|
3734 | } |
---|
3735 | |
---|
3736 | #if P0297_VPS_POC_LSB_ALIGNED_FLAG |
---|
3737 | vps->setVpsPocLsbAlignedFlag(false); |
---|
3738 | #endif |
---|
3739 | |
---|
3740 | #if O0062_POC_LSB_NOT_PRESENT_FLAG |
---|
3741 | // When not present, poc_lsb_not_present_flag[ i ] is inferred to be equal to 0. |
---|
3742 | for(i = 1; i< vps->getMaxLayers(); i++) |
---|
3743 | { |
---|
3744 | vps->setPocLsbNotPresentFlag(i, 0); |
---|
3745 | } |
---|
3746 | #endif |
---|
3747 | |
---|
3748 | // set default values for VPS VUI |
---|
3749 | defaultVPSVUI( vps ); |
---|
3750 | } |
---|
3751 | |
---|
3752 | Void TDecCavlc::defaultVPSVUI( TComVPS* vps ) |
---|
3753 | { |
---|
3754 | // When not present, the value of all_layers_idr_aligned_flag is inferred to be equal to 0. |
---|
3755 | vps->setCrossLayerIrapAlignFlag( false ); |
---|
3756 | |
---|
3757 | #if M0040_ADAPTIVE_RESOLUTION_CHANGE |
---|
3758 | // When single_layer_for_non_irap_flag is not present, it is inferred to be equal to 0. |
---|
3759 | vps->setSingleLayerForNonIrapFlag( false ); |
---|
3760 | #endif |
---|
3761 | |
---|
3762 | #if HIGHER_LAYER_IRAP_SKIP_FLAG |
---|
3763 | // When higher_layer_irap_skip_flag is not present it is inferred to be equal to 0 |
---|
3764 | vps->setHigherLayerIrapSkipFlag( false ); |
---|
3765 | #endif |
---|
3766 | } |
---|
3767 | |
---|
3768 | #if REPN_FORMAT_IN_VPS |
---|
3769 | Void TDecCavlc::parseRepFormat( RepFormat *repFormat, RepFormat *repFormatPrev ) |
---|
3770 | { |
---|
3771 | UInt uiCode; |
---|
3772 | #if REPN_FORMAT_CONTROL_FLAG |
---|
3773 | READ_CODE( 16, uiCode, "pic_width_vps_in_luma_samples" ); repFormat->setPicWidthVpsInLumaSamples ( uiCode ); |
---|
3774 | READ_CODE( 16, uiCode, "pic_height_vps_in_luma_samples" ); repFormat->setPicHeightVpsInLumaSamples( uiCode ); |
---|
3775 | READ_FLAG( uiCode, "chroma_and_bit_depth_vps_present_flag" ); repFormat->setChromaAndBitDepthVpsPresentFlag( uiCode ? true : false ); |
---|
3776 | |
---|
3777 | if( !repFormatPrev ) |
---|
3778 | { |
---|
3779 | // The value of chroma_and_bit_depth_vps_present_flag of the first rep_format( ) syntax structure in the VPS shall be equal to 1 |
---|
3780 | assert( repFormat->getChromaAndBitDepthVpsPresentFlag() ); |
---|
3781 | } |
---|
3782 | |
---|
3783 | if( repFormat->getChromaAndBitDepthVpsPresentFlag() ) |
---|
3784 | { |
---|
3785 | READ_CODE( 2, uiCode, "chroma_format_vps_idc" ); |
---|
3786 | #if AUXILIARY_PICTURES |
---|
3787 | repFormat->setChromaFormatVpsIdc( ChromaFormat(uiCode) ); |
---|
3788 | #else |
---|
3789 | repFormat->setChromaFormatVpsIdc( uiCode ); |
---|
3790 | #endif |
---|
3791 | |
---|
3792 | if( repFormat->getChromaFormatVpsIdc() == 3 ) |
---|
3793 | { |
---|
3794 | READ_FLAG( uiCode, "separate_colour_plane_vps_flag" ); repFormat->setSeparateColourPlaneVpsFlag( uiCode ? true : false ); |
---|
3795 | } |
---|
3796 | |
---|
3797 | READ_CODE( 4, uiCode, "bit_depth_vps_luma_minus8" ); repFormat->setBitDepthVpsLuma ( uiCode + 8 ); |
---|
3798 | READ_CODE( 4, uiCode, "bit_depth_vps_chroma_minus8" ); repFormat->setBitDepthVpsChroma( uiCode + 8 ); |
---|
3799 | } |
---|
3800 | else if( repFormatPrev ) |
---|
3801 | { |
---|
3802 | // chroma_and_bit_depth_vps_present_flag equal to 0 specifies that the syntax elements, chroma_format_vps_idc, separate_colour_plane_vps_flag, bit_depth_vps_luma_minus8, and |
---|
3803 | // bit_depth_vps_chroma_minus8 are not present and inferred from the previous rep_format( ) syntax structure in the VPS. |
---|
3804 | |
---|
3805 | repFormat->setChromaFormatVpsIdc ( repFormatPrev->getChromaFormatVpsIdc() ); |
---|
3806 | repFormat->setSeparateColourPlaneVpsFlag( repFormatPrev->getSeparateColourPlaneVpsFlag() ); |
---|
3807 | repFormat->setBitDepthVpsLuma ( repFormatPrev->getBitDepthVpsLuma() ); |
---|
3808 | repFormat->setBitDepthVpsChroma ( repFormatPrev->getBitDepthVpsChroma() ); |
---|
3809 | } |
---|
3810 | |
---|
3811 | #else |
---|
3812 | #if AUXILIARY_PICTURES |
---|
3813 | READ_CODE( 2, uiCode, "chroma_format_idc" ); repFormat->setChromaFormatVpsIdc( ChromaFormat(uiCode) ); |
---|
3814 | #else |
---|
3815 | READ_CODE( 2, uiCode, "chroma_format_idc" ); repFormat->setChromaFormatVpsIdc( uiCode ); |
---|
3816 | #endif |
---|
3817 | |
---|
3818 | if( repFormat->getChromaFormatVpsIdc() == 3 ) |
---|
3819 | { |
---|
3820 | READ_FLAG( uiCode, "separate_colour_plane_flag"); repFormat->setSeparateColourPlaneVpsFlag(uiCode ? true : false); |
---|
3821 | } |
---|
3822 | |
---|
3823 | READ_CODE ( 16, uiCode, "pic_width_in_luma_samples" ); repFormat->setPicWidthVpsInLumaSamples ( uiCode ); |
---|
3824 | READ_CODE ( 16, uiCode, "pic_height_in_luma_samples" ); repFormat->setPicHeightVpsInLumaSamples( uiCode ); |
---|
3825 | |
---|
3826 | READ_CODE( 4, uiCode, "bit_depth_luma_minus8" ); repFormat->setBitDepthVpsLuma ( uiCode + 8 ); |
---|
3827 | READ_CODE( 4, uiCode, "bit_depth_chroma_minus8" ); repFormat->setBitDepthVpsChroma( uiCode + 8 ); |
---|
3828 | #endif |
---|
3829 | |
---|
3830 | #if R0156_CONF_WINDOW_IN_REP_FORMAT |
---|
3831 | READ_FLAG( uiCode, "conformance_window_vps_flag" ); |
---|
3832 | if( uiCode != 0) |
---|
3833 | { |
---|
3834 | Window &conf = repFormat->getConformanceWindowVps(); |
---|
3835 | READ_UVLC( uiCode, "conf_win_vps_left_offset" ); conf.setWindowLeftOffset ( uiCode ); |
---|
3836 | READ_UVLC( uiCode, "conf_win_vps_right_offset" ); conf.setWindowRightOffset ( uiCode ); |
---|
3837 | READ_UVLC( uiCode, "conf_win_vps_top_offset" ); conf.setWindowTopOffset ( uiCode ); |
---|
3838 | READ_UVLC( uiCode, "conf_win_vps_bottom_offset" ); conf.setWindowBottomOffset( uiCode ); |
---|
3839 | } |
---|
3840 | #endif |
---|
3841 | } |
---|
3842 | #endif |
---|
3843 | #if VPS_DPB_SIZE_TABLE |
---|
3844 | Void TDecCavlc::parseVpsDpbSizeTable( TComVPS *vps ) |
---|
3845 | { |
---|
3846 | UInt uiCode; |
---|
3847 | #if SUB_LAYERS_IN_LAYER_SET |
---|
3848 | vps->calculateMaxSLInLayerSets(); |
---|
3849 | #else |
---|
3850 | #if DPB_PARAMS_MAXTLAYERS |
---|
3851 | #if BITRATE_PICRATE_SIGNALLING |
---|
3852 | Int * MaxSubLayersInLayerSetMinus1 = new Int[vps->getNumLayerSets()]; |
---|
3853 | for(Int i = 0; i < vps->getNumLayerSets(); i++) |
---|
3854 | #else |
---|
3855 | Int * MaxSubLayersInLayerSetMinus1 = new Int[vps->getNumOutputLayerSets()]; |
---|
3856 | for(Int i = 1; i < vps->getNumOutputLayerSets(); i++) |
---|
3857 | #endif |
---|
3858 | { |
---|
3859 | UInt maxSLMinus1 = 0; |
---|
3860 | #if CHANGE_NUMSUBDPB_IDX |
---|
3861 | Int optLsIdx = vps->getOutputLayerSetIdx( i ); |
---|
3862 | #else |
---|
3863 | Int optLsIdx = i; |
---|
3864 | #endif |
---|
3865 | #if BITRATE_PICRATE_SIGNALLING |
---|
3866 | optLsIdx = i; |
---|
3867 | #endif |
---|
3868 | for(Int k = 0; k < vps->getNumLayersInIdList(optLsIdx); k++ ) { |
---|
3869 | Int lId = vps->getLayerSetLayerIdList(optLsIdx, k); |
---|
3870 | maxSLMinus1 = max(maxSLMinus1, vps->getMaxTSLayersMinus1(vps->getLayerIdInVps(lId))); |
---|
3871 | } |
---|
3872 | MaxSubLayersInLayerSetMinus1[ i ] = maxSLMinus1; |
---|
3873 | #if BITRATE_PICRATE_SIGNALLING |
---|
3874 | vps->setMaxSLayersInLayerSetMinus1(i,MaxSubLayersInLayerSetMinus1[ i ]); |
---|
3875 | #endif |
---|
3876 | } |
---|
3877 | #endif |
---|
3878 | #endif |
---|
3879 | |
---|
3880 | #if !RESOLUTION_BASED_DPB |
---|
3881 | vps->deriveNumberOfSubDpbs(); |
---|
3882 | #endif |
---|
3883 | for(Int i = 1; i < vps->getNumOutputLayerSets(); i++) |
---|
3884 | { |
---|
3885 | #if CHANGE_NUMSUBDPB_IDX |
---|
3886 | Int layerSetIdxForOutputLayerSet = vps->getOutputLayerSetIdx( i ); |
---|
3887 | #endif |
---|
3888 | READ_FLAG( uiCode, "sub_layer_flag_info_present_flag[i]"); vps->setSubLayerFlagInfoPresentFlag( i, uiCode ? true : false ); |
---|
3889 | #if SUB_LAYERS_IN_LAYER_SET |
---|
3890 | for(Int j = 0; j <= vps->getMaxSLayersInLayerSetMinus1( layerSetIdxForOutputLayerSet ); j++) |
---|
3891 | #else |
---|
3892 | #if DPB_PARAMS_MAXTLAYERS |
---|
3893 | #if BITRATE_PICRATE_SIGNALLING |
---|
3894 | for(Int j = 0; j <= MaxSubLayersInLayerSetMinus1[ vps->getOutputLayerSetIdx( i ) ]; j++) |
---|
3895 | #else |
---|
3896 | for(Int j = 0; j <= MaxSubLayersInLayerSetMinus1[ i ]; j++) |
---|
3897 | #endif |
---|
3898 | #else |
---|
3899 | for(Int j = 0; j <= vps->getMaxTLayers(); j++) |
---|
3900 | #endif |
---|
3901 | #endif |
---|
3902 | { |
---|
3903 | if( j > 0 && vps->getSubLayerFlagInfoPresentFlag(i) ) |
---|
3904 | { |
---|
3905 | READ_FLAG( uiCode, "sub_layer_dpb_info_present_flag[i]"); vps->setSubLayerDpbInfoPresentFlag( i, j, uiCode ? true : false); |
---|
3906 | } |
---|
3907 | else |
---|
3908 | { |
---|
3909 | if( j == 0 ) // Always signal for the first sub-layer |
---|
3910 | { |
---|
3911 | vps->setSubLayerDpbInfoPresentFlag( i, j, true ); |
---|
3912 | } |
---|
3913 | else // if (j != 0) && !vps->getSubLayerFlagInfoPresentFlag(i) |
---|
3914 | { |
---|
3915 | vps->setSubLayerDpbInfoPresentFlag( i, j, false ); |
---|
3916 | } |
---|
3917 | } |
---|
3918 | if( vps->getSubLayerDpbInfoPresentFlag(i, j) ) // If sub-layer DPB information is present |
---|
3919 | { |
---|
3920 | #if CHANGE_NUMSUBDPB_IDX |
---|
3921 | for(Int k = 0; k < vps->getNumSubDpbs(layerSetIdxForOutputLayerSet); k++) |
---|
3922 | #else |
---|
3923 | for(Int k = 0; k < vps->getNumSubDpbs(i); k++) |
---|
3924 | #endif |
---|
3925 | { |
---|
3926 | #if DPB_INTERNAL_BL_SIG |
---|
3927 | uiCode=0; |
---|
3928 | |
---|
3929 | #if VPS_FIX_TO_MATCH_SPEC |
---|
3930 | if( vps->getNecessaryLayerFlag(i, k) && ( vps->getBaseLayerInternalFlag() || vps->getLayerSetLayerIdList(layerSetIdxForOutputLayerSet, k) ) ) |
---|
3931 | #else |
---|
3932 | if(vps->getBaseLayerInternalFlag() || ( vps->getLayerSetLayerIdList(layerSetIdxForOutputLayerSet, k) != 0 ) ) |
---|
3933 | #endif |
---|
3934 | #endif |
---|
3935 | READ_UVLC( uiCode, "max_vps_dec_pic_buffering_minus1[i][k][j]" ); vps->setMaxVpsDecPicBufferingMinus1( i, k, j, uiCode ); |
---|
3936 | } |
---|
3937 | READ_UVLC( uiCode, "max_vps_num_reorder_pics[i][j]" ); vps->setMaxVpsNumReorderPics( i, j, uiCode); |
---|
3938 | #if RESOLUTION_BASED_DPB |
---|
3939 | if( vps->getNumSubDpbs(layerSetIdxForOutputLayerSet) != vps->getNumLayersInIdList( layerSetIdxForOutputLayerSet ) ) |
---|
3940 | { |
---|
3941 | for(Int k = 0; k < vps->getNumLayersInIdList( layerSetIdxForOutputLayerSet ); k++) |
---|
3942 | { |
---|
3943 | READ_UVLC( uiCode, "max_vps_layer_dec_pic_buff_minus1[i][k][j]" ); vps->setMaxVpsLayerDecPicBuffMinus1( i, k, j, uiCode); |
---|
3944 | } |
---|
3945 | } |
---|
3946 | else // vps->getNumSubDpbs(layerSetIdxForOutputLayerSet) == vps->getNumLayersInIdList( layerSetIdxForOutputLayerSet ) |
---|
3947 | { |
---|
3948 | for(Int k = 0; k < vps->getNumLayersInIdList( layerSetIdxForOutputLayerSet ); k++) |
---|
3949 | { |
---|
3950 | vps->setMaxVpsLayerDecPicBuffMinus1( i, k, j, vps->getMaxVpsDecPicBufferingMinus1( i, k, j)); |
---|
3951 | } |
---|
3952 | } |
---|
3953 | #endif |
---|
3954 | READ_UVLC( uiCode, "max_vps_latency_increase_plus1[i][j]" ); vps->setMaxVpsLatencyIncreasePlus1( i, j, uiCode); |
---|
3955 | } |
---|
3956 | } |
---|
3957 | for(Int j = vps->getMaxTLayers(); j < MAX_TLAYER; j++) |
---|
3958 | { |
---|
3959 | vps->setSubLayerDpbInfoPresentFlag( i, j, false ); |
---|
3960 | } |
---|
3961 | } |
---|
3962 | |
---|
3963 | #if !SUB_LAYERS_IN_LAYER_SET |
---|
3964 | #if BITRATE_PICRATE_SIGNALLING |
---|
3965 | if( MaxSubLayersInLayerSetMinus1 ) |
---|
3966 | { |
---|
3967 | delete [] MaxSubLayersInLayerSetMinus1; |
---|
3968 | } |
---|
3969 | #endif |
---|
3970 | #endif |
---|
3971 | |
---|
3972 | // Infer values when not signalled |
---|
3973 | for(Int i = 1; i < vps->getNumOutputLayerSets(); i++) |
---|
3974 | { |
---|
3975 | Int layerSetIdxForOutputLayerSet = vps->getOutputLayerSetIdx( i ); |
---|
3976 | for(Int j = 0; j < MAX_TLAYER; j++) |
---|
3977 | { |
---|
3978 | if( !vps->getSubLayerDpbInfoPresentFlag(i, j) ) // If sub-layer DPB information is NOT present |
---|
3979 | { |
---|
3980 | #if RESOLUTION_BASED_DPB |
---|
3981 | for(Int k = 0; k < vps->getNumSubDpbs(layerSetIdxForOutputLayerSet); k++) |
---|
3982 | #else |
---|
3983 | for(Int k = 0; k < vps->getNumLayersInIdList( layerSetIdxForOutputLayerSet ); k++) |
---|
3984 | #endif |
---|
3985 | { |
---|
3986 | vps->setMaxVpsDecPicBufferingMinus1( i, k, j, vps->getMaxVpsDecPicBufferingMinus1( i, k, j - 1 ) ); |
---|
3987 | } |
---|
3988 | vps->setMaxVpsNumReorderPics( i, j, vps->getMaxVpsNumReorderPics( i, j - 1) ); |
---|
3989 | #if RESOLUTION_BASED_DPB |
---|
3990 | for(Int k = 0; k < vps->getNumLayersInIdList( layerSetIdxForOutputLayerSet ); k++) |
---|
3991 | { |
---|
3992 | vps->setMaxVpsLayerDecPicBuffMinus1( i, k, j, vps->getMaxVpsLayerDecPicBuffMinus1( i, k, j - 1)); |
---|
3993 | } |
---|
3994 | #endif |
---|
3995 | vps->setMaxVpsLatencyIncreasePlus1( i, j, vps->getMaxVpsLatencyIncreasePlus1( i, j - 1 ) ); |
---|
3996 | } |
---|
3997 | } |
---|
3998 | } |
---|
3999 | } |
---|
4000 | #endif |
---|
4001 | |
---|
4002 | Void TDecCavlc::parseVPSVUI(TComVPS *vps) |
---|
4003 | { |
---|
4004 | UInt i,j; |
---|
4005 | UInt uiCode; |
---|
4006 | #if O0223_PICTURE_TYPES_ALIGN_FLAG |
---|
4007 | READ_FLAG(uiCode, "cross_layer_pic_type_aligned_flag" ); |
---|
4008 | vps->setCrossLayerPictureTypeAlignFlag(uiCode); |
---|
4009 | if (!uiCode) |
---|
4010 | { |
---|
4011 | #endif |
---|
4012 | #if IRAP_ALIGN_FLAG_IN_VPS_VUI |
---|
4013 | READ_FLAG(uiCode, "cross_layer_irap_aligned_flag" ); |
---|
4014 | vps->setCrossLayerIrapAlignFlag(uiCode); |
---|
4015 | #endif |
---|
4016 | #if O0223_PICTURE_TYPES_ALIGN_FLAG |
---|
4017 | } |
---|
4018 | else |
---|
4019 | { |
---|
4020 | vps->setCrossLayerIrapAlignFlag(true); |
---|
4021 | } |
---|
4022 | #endif |
---|
4023 | #if P0068_CROSS_LAYER_ALIGNED_IDR_ONLY_FOR_IRAP_FLAG |
---|
4024 | if( uiCode ) |
---|
4025 | { |
---|
4026 | READ_FLAG( uiCode, "all_layers_idr_aligned_flag" ); |
---|
4027 | vps->setCrossLayerAlignedIdrOnlyFlag(uiCode); |
---|
4028 | } |
---|
4029 | #endif |
---|
4030 | |
---|
4031 | READ_FLAG( uiCode, "bit_rate_present_vps_flag" ); vps->setBitRatePresentVpsFlag( uiCode ? true : false ); |
---|
4032 | READ_FLAG( uiCode, "pic_rate_present_vps_flag" ); vps->setPicRatePresentVpsFlag( uiCode ? true : false ); |
---|
4033 | |
---|
4034 | #if SIGNALLING_BITRATE_PICRATE_FIX |
---|
4035 | if ( vps->getBitRatePresentVpsFlag() || vps->getPicRatePresentVpsFlag() ) |
---|
4036 | { |
---|
4037 | for( i = vps->getBaseLayerInternalFlag() ? 0 : 1; i < vps->getNumLayerSets(); i++ ) |
---|
4038 | { |
---|
4039 | for( j = 0; j <= vps->getMaxSLayersInLayerSetMinus1( i ); j++ ) |
---|
4040 | { |
---|
4041 | if( vps->getBitRatePresentVpsFlag() ) |
---|
4042 | { |
---|
4043 | READ_FLAG( uiCode, "bit_rate_present_flag[i][j]" ); vps->setBitRatePresentFlag( i, j, uiCode ? true : false ); |
---|
4044 | } |
---|
4045 | if( vps->getPicRatePresentVpsFlag( ) ) |
---|
4046 | { |
---|
4047 | READ_FLAG( uiCode, "pic_rate_present_flag[i][j]" ); vps->setPicRatePresentFlag( i, j, uiCode ? true : false ); |
---|
4048 | } |
---|
4049 | if( vps->getBitRatePresentFlag( i, j ) ) |
---|
4050 | { |
---|
4051 | READ_CODE( 16, uiCode, "avg_bit_rate" ); vps->setAvgBitRate( i, j, uiCode ); |
---|
4052 | READ_CODE( 16, uiCode, "max_bit_rate" ); vps->setMaxBitRate( i, j, uiCode ); |
---|
4053 | } |
---|
4054 | else |
---|
4055 | { |
---|
4056 | vps->setAvgBitRate( i, j, 0 ); |
---|
4057 | vps->setMaxBitRate( i, j, 0 ); |
---|
4058 | } |
---|
4059 | if( vps->getPicRatePresentFlag( i, j ) ) |
---|
4060 | { |
---|
4061 | READ_CODE( 2, uiCode, "constant_pic_rate_idc" ); vps->setConstPicRateIdc( i, j, uiCode ); |
---|
4062 | READ_CODE( 16, uiCode, "avg_pic_rate" ); vps->setAvgPicRate( i, j, uiCode ); |
---|
4063 | } |
---|
4064 | else |
---|
4065 | { |
---|
4066 | vps->setConstPicRateIdc( i, j, 0 ); |
---|
4067 | vps->setAvgPicRate( i, j, 0 ); |
---|
4068 | } |
---|
4069 | } |
---|
4070 | } |
---|
4071 | } |
---|
4072 | #else |
---|
4073 | Bool parseFlag = vps->getBitRatePresentVpsFlag() || vps->getPicRatePresentVpsFlag(); |
---|
4074 | |
---|
4075 | #if Q0078_ADD_LAYER_SETS |
---|
4076 | #if R0227_BR_PR_ADD_LAYER_SET |
---|
4077 | for( i = 0; i < vps->getNumLayerSets(); i++ ) |
---|
4078 | #else |
---|
4079 | for( i = 0; i <= vps->getVpsNumLayerSetsMinus1(); i++ ) |
---|
4080 | #endif |
---|
4081 | #else |
---|
4082 | for( i = 0; i < vps->getNumLayerSets(); i++ ) |
---|
4083 | #endif |
---|
4084 | { |
---|
4085 | #if BITRATE_PICRATE_SIGNALLING |
---|
4086 | for( j = 0; j <= vps->getMaxSLayersInLayerSetMinus1(i); j++ ) |
---|
4087 | #else |
---|
4088 | for( j = 0; j < vps->getMaxTLayers(); j++ ) |
---|
4089 | #endif |
---|
4090 | { |
---|
4091 | if( parseFlag && vps->getBitRatePresentVpsFlag() ) |
---|
4092 | { |
---|
4093 | READ_FLAG( uiCode, "bit_rate_present_flag[i][j]" ); vps->setBitRatePresentFlag( i, j, uiCode ? true : false ); |
---|
4094 | } |
---|
4095 | else |
---|
4096 | { |
---|
4097 | vps->setBitRatePresentFlag( i, j, false ); |
---|
4098 | } |
---|
4099 | if( parseFlag && vps->getPicRatePresentVpsFlag() ) |
---|
4100 | { |
---|
4101 | READ_FLAG( uiCode, "pic_rate_present_flag[i][j]" ); vps->setPicRatePresentFlag( i, j, uiCode ? true : false ); |
---|
4102 | } |
---|
4103 | else |
---|
4104 | { |
---|
4105 | vps->setPicRatePresentFlag( i, j, false ); |
---|
4106 | } |
---|
4107 | if( parseFlag && vps->getBitRatePresentFlag(i, j) ) |
---|
4108 | { |
---|
4109 | READ_CODE( 16, uiCode, "avg_bit_rate[i][j]" ); vps->setAvgBitRate( i, j, uiCode ); |
---|
4110 | READ_CODE( 16, uiCode, "max_bit_rate[i][j]" ); vps->setMaxBitRate( i, j, uiCode ); |
---|
4111 | } |
---|
4112 | else |
---|
4113 | { |
---|
4114 | vps->setAvgBitRate( i, j, 0 ); |
---|
4115 | vps->setMaxBitRate( i, j, 0 ); |
---|
4116 | } |
---|
4117 | if( parseFlag && vps->getPicRatePresentFlag(i, j) ) |
---|
4118 | { |
---|
4119 | READ_CODE( 2 , uiCode, "constant_pic_rate_idc[i][j]" ); vps->setConstPicRateIdc( i, j, uiCode ); |
---|
4120 | READ_CODE( 16, uiCode, "avg_pic_rate[i][j]" ); vps->setAvgPicRate( i, j, uiCode ); |
---|
4121 | } |
---|
4122 | else |
---|
4123 | { |
---|
4124 | vps->setConstPicRateIdc( i, j, 0 ); |
---|
4125 | vps->setAvgPicRate ( i, j, 0 ); |
---|
4126 | } |
---|
4127 | } |
---|
4128 | } |
---|
4129 | #endif |
---|
4130 | #if VPS_VUI_VIDEO_SIGNAL_MOVE |
---|
4131 | READ_FLAG( uiCode, "video_signal_info_idx_present_flag" ); vps->setVideoSigPresentVpsFlag( uiCode == 1 ); |
---|
4132 | if (vps->getVideoSigPresentVpsFlag()) |
---|
4133 | { |
---|
4134 | READ_CODE(4, uiCode, "vps_num_video_signal_info_minus1" ); vps->setNumVideoSignalInfo(uiCode + 1); |
---|
4135 | } |
---|
4136 | else |
---|
4137 | { |
---|
4138 | #if VPS_VUI_VST_PARAMS |
---|
4139 | vps->setNumVideoSignalInfo(vps->getMaxLayers() - vps->getBaseLayerInternalFlag() ? 0 : 1); |
---|
4140 | #else |
---|
4141 | vps->setNumVideoSignalInfo(vps->getMaxLayers()); |
---|
4142 | #endif |
---|
4143 | } |
---|
4144 | |
---|
4145 | for(i = 0; i < vps->getNumVideoSignalInfo(); i++) |
---|
4146 | { |
---|
4147 | READ_CODE(3, uiCode, "video_vps_format" ); vps->setVideoVPSFormat(i,uiCode); |
---|
4148 | READ_FLAG(uiCode, "video_full_range_vps_flag" ); vps->setVideoFullRangeVpsFlag(i,uiCode); |
---|
4149 | READ_CODE(8, uiCode, "color_primaries_vps" ); vps->setColorPrimaries(i,uiCode); |
---|
4150 | READ_CODE(8, uiCode, "transfer_characteristics_vps" ); vps->setTransCharacter(i,uiCode); |
---|
4151 | READ_CODE(8, uiCode, "matrix_coeffs_vps" );vps->setMaxtrixCoeff(i,uiCode); |
---|
4152 | } |
---|
4153 | #if VPS_VUI_VST_PARAMS |
---|
4154 | if( vps->getVideoSigPresentVpsFlag() && vps->getNumVideoSignalInfo() > 1 ) |
---|
4155 | { |
---|
4156 | for(i = vps->getBaseLayerInternalFlag() ? 0 : 1; i < vps->getMaxLayers(); i++) |
---|
4157 | { |
---|
4158 | READ_CODE(4, uiCode, "vps_video_signal_info_idx" ); vps->setVideoSignalInfoIdx(i, uiCode); |
---|
4159 | } |
---|
4160 | } |
---|
4161 | else if ( !vps->getVideoSigPresentVpsFlag() ) |
---|
4162 | { |
---|
4163 | for(i = vps->getBaseLayerInternalFlag() ? 0 : 1; i < vps->getMaxLayers(); i++) |
---|
4164 | { |
---|
4165 | vps->setVideoSignalInfoIdx( i, i ); |
---|
4166 | } |
---|
4167 | } |
---|
4168 | else // ( vps->getNumVideoSignalInfo() = 0 ) |
---|
4169 | { |
---|
4170 | for(i = vps->getBaseLayerInternalFlag() ? 0 : 1; i < vps->getMaxLayers(); i++) |
---|
4171 | { |
---|
4172 | vps->setVideoSignalInfoIdx( i, 0 ); |
---|
4173 | } |
---|
4174 | } |
---|
4175 | #else |
---|
4176 | if(!vps->getVideoSigPresentVpsFlag()) |
---|
4177 | { |
---|
4178 | for (i=0; i < vps->getMaxLayers(); i++) |
---|
4179 | { |
---|
4180 | vps->setVideoSignalInfoIdx(i,i); |
---|
4181 | } |
---|
4182 | } |
---|
4183 | else { |
---|
4184 | vps->setVideoSignalInfoIdx(0,0); |
---|
4185 | if (vps->getNumVideoSignalInfo() > 1 ) |
---|
4186 | { |
---|
4187 | for (i=1; i < vps->getMaxLayers(); i++) |
---|
4188 | READ_CODE(4, uiCode, "vps_video_signal_info_idx" ); vps->setVideoSignalInfoIdx(i, uiCode); |
---|
4189 | } |
---|
4190 | else { |
---|
4191 | for (i=1; i < vps->getMaxLayers(); i++) |
---|
4192 | { |
---|
4193 | vps->setVideoSignalInfoIdx(i,0); |
---|
4194 | } |
---|
4195 | } |
---|
4196 | } |
---|
4197 | #endif |
---|
4198 | #endif |
---|
4199 | #if VPS_VUI_TILES_NOT_IN_USE__FLAG |
---|
4200 | UInt layerIdx; |
---|
4201 | READ_FLAG( uiCode, "tiles_not_in_use_flag" ); vps->setTilesNotInUseFlag(uiCode == 1); |
---|
4202 | if (!uiCode) |
---|
4203 | { |
---|
4204 | #if VPS_FIX_TO_MATCH_SPEC |
---|
4205 | for( i = vps->getBaseLayerInternalFlag() ? 0 : 1; i < vps->getMaxLayers(); i++ ) |
---|
4206 | #else |
---|
4207 | for (i = 0; i < vps->getMaxLayers(); i++) |
---|
4208 | #endif |
---|
4209 | { |
---|
4210 | READ_FLAG( uiCode, "tiles_in_use_flag[ i ]" ); vps->setTilesInUseFlag(i, (uiCode == 1)); |
---|
4211 | if (uiCode) |
---|
4212 | { |
---|
4213 | READ_FLAG( uiCode, "loop_filter_not_across_tiles_flag[ i ]" ); vps->setLoopFilterNotAcrossTilesFlag(i, (uiCode == 1)); |
---|
4214 | } |
---|
4215 | else |
---|
4216 | { |
---|
4217 | vps->setLoopFilterNotAcrossTilesFlag(i, false); |
---|
4218 | } |
---|
4219 | } |
---|
4220 | #endif |
---|
4221 | |
---|
4222 | #if VPS_FIX_TO_MATCH_SPEC |
---|
4223 | for( i = vps->getBaseLayerInternalFlag() ? 1 : 2; i < vps->getMaxLayers(); i++ ) |
---|
4224 | #else |
---|
4225 | for (i = 1; i < vps->getMaxLayers(); i++) |
---|
4226 | #endif |
---|
4227 | { |
---|
4228 | for(j = 0; j < vps->getNumDirectRefLayers(vps->getLayerIdInNuh(i)); j++) |
---|
4229 | { |
---|
4230 | #if VPS_VUI_TILES_NOT_IN_USE__FLAG |
---|
4231 | layerIdx = vps->getLayerIdInVps(vps->getRefLayerId(vps->getLayerIdInNuh(i), j)); |
---|
4232 | if (vps->getTilesInUseFlag(i) && vps->getTilesInUseFlag(layerIdx)) { |
---|
4233 | READ_FLAG( uiCode, "tile_boundaries_aligned_flag[i][j]" ); vps->setTileBoundariesAlignedFlag(i,j,(uiCode == 1)); |
---|
4234 | } |
---|
4235 | #else |
---|
4236 | READ_FLAG( uiCode, "tile_boundaries_aligned_flag[i][j]" ); vps->setTileBoundariesAlignedFlag(i,j,(uiCode == 1)); |
---|
4237 | #endif |
---|
4238 | } |
---|
4239 | } |
---|
4240 | #if VPS_VUI_TILES_NOT_IN_USE__FLAG |
---|
4241 | } |
---|
4242 | #endif |
---|
4243 | #if VPS_VUI_WPP_NOT_IN_USE__FLAG |
---|
4244 | READ_FLAG( uiCode, "wpp_not_in_use_flag" ); vps->setWppNotInUseFlag(uiCode == 1); |
---|
4245 | if (!uiCode) |
---|
4246 | { |
---|
4247 | #if VPS_FIX_TO_MATCH_SPEC |
---|
4248 | for (i = vps->getBaseLayerInternalFlag() ? 0 : 1; i < vps->getMaxLayers(); i++) |
---|
4249 | #else |
---|
4250 | for (i = 0; i < vps->getMaxLayers(); i++) |
---|
4251 | #endif |
---|
4252 | { |
---|
4253 | READ_FLAG( uiCode, "wpp_in_use_flag[ i ]" ); vps->setWppInUseFlag(i, (uiCode == 1)); |
---|
4254 | } |
---|
4255 | } |
---|
4256 | #endif |
---|
4257 | |
---|
4258 | #if O0109_O0199_FLAGS_TO_VUI |
---|
4259 | #if M0040_ADAPTIVE_RESOLUTION_CHANGE |
---|
4260 | READ_FLAG(uiCode, "single_layer_for_non_irap_flag" ); vps->setSingleLayerForNonIrapFlag(uiCode == 1 ? true : false); |
---|
4261 | #endif |
---|
4262 | #if HIGHER_LAYER_IRAP_SKIP_FLAG |
---|
4263 | READ_FLAG(uiCode, "higher_layer_irap_skip_flag" ); vps->setHigherLayerIrapSkipFlag(uiCode == 1 ? true : false); |
---|
4264 | |
---|
4265 | // When single_layer_for_non_irap_flag is equal to 0, higher_layer_irap_skip_flag shall be equal to 0 |
---|
4266 | if( !vps->getSingleLayerForNonIrapFlag() ) |
---|
4267 | { |
---|
4268 | assert( !vps->getHigherLayerIrapSkipFlag() ); |
---|
4269 | } |
---|
4270 | #endif |
---|
4271 | #endif |
---|
4272 | #if P0312_VERT_PHASE_ADJ |
---|
4273 | READ_FLAG( uiCode, "vps_vui_vert_phase_in_use_flag" ); vps->setVpsVuiVertPhaseInUseFlag(uiCode); |
---|
4274 | #endif |
---|
4275 | #if N0160_VUI_EXT_ILP_REF |
---|
4276 | READ_FLAG( uiCode, "ilp_restricted_ref_layers_flag" ); vps->setIlpRestrictedRefLayersFlag( uiCode == 1 ); |
---|
4277 | if( vps->getIlpRestrictedRefLayersFlag()) |
---|
4278 | { |
---|
4279 | for(i = 1; i < vps->getMaxLayers(); i++) |
---|
4280 | { |
---|
4281 | for(j = 0; j < vps->getNumDirectRefLayers(vps->getLayerIdInNuh(i)); j++) |
---|
4282 | { |
---|
4283 | #if VPS_FIX_TO_MATCH_SPEC |
---|
4284 | if( vps->getBaseLayerInternalFlag() || vps->getRefLayerId(vps->getLayerIdInNuh(i), j) ) |
---|
4285 | { |
---|
4286 | #endif |
---|
4287 | READ_UVLC( uiCode, "min_spatial_segment_offset_plus1[i][j]" ); vps->setMinSpatialSegmentOffsetPlus1( i, j, uiCode ); |
---|
4288 | if( vps->getMinSpatialSegmentOffsetPlus1(i,j ) > 0 ) |
---|
4289 | { |
---|
4290 | READ_FLAG( uiCode, "ctu_based_offset_enabled_flag[i][j]"); vps->setCtuBasedOffsetEnabledFlag(i, j, uiCode == 1 ); |
---|
4291 | if(vps->getCtuBasedOffsetEnabledFlag(i,j)) |
---|
4292 | { |
---|
4293 | READ_UVLC( uiCode, "min_horizontal_ctu_offset_plus1[i][j]"); vps->setMinHorizontalCtuOffsetPlus1( i,j, uiCode ); |
---|
4294 | } |
---|
4295 | } |
---|
4296 | #if VPS_FIX_TO_MATCH_SPEC |
---|
4297 | } |
---|
4298 | #endif |
---|
4299 | } |
---|
4300 | } |
---|
4301 | } |
---|
4302 | #endif |
---|
4303 | #if VPS_VUI_VIDEO_SIGNAL |
---|
4304 | #if VPS_VUI_VIDEO_SIGNAL_MOVE |
---|
4305 | #else |
---|
4306 | READ_FLAG( uiCode, "video_signal_info_idx_present_flag" ); vps->setVideoSigPresentVpsFlag( uiCode == 1 ); |
---|
4307 | if (vps->getVideoSigPresentVpsFlag()) |
---|
4308 | { |
---|
4309 | READ_CODE(4, uiCode, "vps_num_video_signal_info_minus1" ); vps->setNumVideoSignalInfo(uiCode + 1); |
---|
4310 | } |
---|
4311 | else |
---|
4312 | { |
---|
4313 | vps->setNumVideoSignalInfo(vps->getMaxLayers()); |
---|
4314 | } |
---|
4315 | |
---|
4316 | |
---|
4317 | for(i = 0; i < vps->getNumVideoSignalInfo(); i++) |
---|
4318 | { |
---|
4319 | READ_CODE(3, uiCode, "video_vps_format" ); vps->setVideoVPSFormat(i,uiCode); |
---|
4320 | READ_FLAG(uiCode, "video_full_range_vps_flag" ); vps->setVideoFullRangeVpsFlag(i,uiCode); |
---|
4321 | READ_CODE(8, uiCode, "color_primaries_vps" ); vps->setColorPrimaries(i,uiCode); |
---|
4322 | READ_CODE(8, uiCode, "transfer_characteristics_vps" ); vps->setTransCharacter(i,uiCode); |
---|
4323 | READ_CODE(8, uiCode, "matrix_coeffs_vps" );vps->setMaxtrixCoeff(i,uiCode); |
---|
4324 | } |
---|
4325 | if(!vps->getVideoSigPresentVpsFlag()) |
---|
4326 | { |
---|
4327 | for (i=0; i < vps->getMaxLayers(); i++) |
---|
4328 | { |
---|
4329 | vps->setVideoSignalInfoIdx(i,i); |
---|
4330 | } |
---|
4331 | } |
---|
4332 | else { |
---|
4333 | vps->setVideoSignalInfoIdx(0,0); |
---|
4334 | if (vps->getNumVideoSignalInfo() > 1 ) |
---|
4335 | { |
---|
4336 | for (i=1; i < vps->getMaxLayers(); i++) |
---|
4337 | READ_CODE(4, uiCode, "vps_video_signal_info_idx" ); vps->setVideoSignalInfoIdx(i, uiCode); |
---|
4338 | } |
---|
4339 | else { |
---|
4340 | for (i=1; i < vps->getMaxLayers(); i++) |
---|
4341 | { |
---|
4342 | vps->setVideoSignalInfoIdx(i,0); |
---|
4343 | } |
---|
4344 | } |
---|
4345 | } |
---|
4346 | #endif |
---|
4347 | #endif |
---|
4348 | |
---|
4349 | #if O0164_MULTI_LAYER_HRD |
---|
4350 | READ_FLAG(uiCode, "vps_vui_bsp_hrd_present_flag" ); vps->setVpsVuiBspHrdPresentFlag(uiCode); |
---|
4351 | if (vps->getVpsVuiBspHrdPresentFlag()) |
---|
4352 | { |
---|
4353 | #if VPS_VUI_BSP_HRD_PARAMS |
---|
4354 | parseVpsVuiBspHrdParams(vps); |
---|
4355 | #else |
---|
4356 | #if R0227_VUI_BSP_HRD_FLAG |
---|
4357 | assert (vps->getTimingInfo()->getTimingInfoPresentFlag() == 1); |
---|
4358 | #endif |
---|
4359 | READ_UVLC( uiCode, "vps_num_bsp_hrd_parameters_minus1" ); vps->setVpsNumBspHrdParametersMinus1(uiCode); |
---|
4360 | vps->createBspHrdParamBuffer(vps->getVpsNumBspHrdParametersMinus1() + 1); |
---|
4361 | for( i = 0; i <= vps->getVpsNumBspHrdParametersMinus1(); i++ ) |
---|
4362 | { |
---|
4363 | if( i > 0 ) |
---|
4364 | { |
---|
4365 | READ_FLAG( uiCode, "bsp_cprms_present_flag[i]" ); vps->setBspCprmsPresentFlag(i, uiCode); |
---|
4366 | } |
---|
4367 | parseHrdParameters(vps->getBspHrd(i), i==0 ? 1 : vps->getBspCprmsPresentFlag(i), vps->getMaxTLayers()-1); |
---|
4368 | } |
---|
4369 | #if Q0078_ADD_LAYER_SETS |
---|
4370 | for (UInt h = 1; h <= vps->getVpsNumLayerSetsMinus1(); h++) |
---|
4371 | #else |
---|
4372 | for( UInt h = 1; h <= (vps->getNumLayerSets()-1); h++ ) |
---|
4373 | #endif |
---|
4374 | { |
---|
4375 | READ_UVLC( uiCode, "num_bitstream_partitions[i]"); vps->setNumBitstreamPartitions(h, uiCode); |
---|
4376 | #if HRD_BPB |
---|
4377 | Int chkPart=0; |
---|
4378 | #endif |
---|
4379 | for( i = 0; i < vps->getNumBitstreamPartitions(h); i++ ) |
---|
4380 | { |
---|
4381 | for( j = 0; j <= (vps->getMaxLayers()-1); j++ ) |
---|
4382 | { |
---|
4383 | if( vps->getLayerIdIncludedFlag(h, j) ) |
---|
4384 | { |
---|
4385 | READ_FLAG( uiCode, "layer_in_bsp_flag[h][i][j]" ); vps->setLayerInBspFlag(h, i, j, uiCode); |
---|
4386 | } |
---|
4387 | } |
---|
4388 | #if HRD_BPB |
---|
4389 | chkPart+=vps->getLayerInBspFlag(h, i, j); |
---|
4390 | #endif |
---|
4391 | } |
---|
4392 | #if HRD_BPB |
---|
4393 | assert(chkPart<=1); |
---|
4394 | #endif |
---|
4395 | #if HRD_BPB |
---|
4396 | if(vps->getNumBitstreamPartitions(h)==1) |
---|
4397 | { |
---|
4398 | Int chkPartition1=0; Int chkPartition2=0; |
---|
4399 | for( j = 0; j <= (vps->getMaxLayers()-1); j++ ) |
---|
4400 | { |
---|
4401 | if( vps->getLayerIdIncludedFlag(h, j) ) |
---|
4402 | { |
---|
4403 | chkPartition1+=vps->getLayerInBspFlag(h, 0, j); |
---|
4404 | chkPartition2++; |
---|
4405 | } |
---|
4406 | } |
---|
4407 | assert(chkPartition1!=chkPartition2); |
---|
4408 | } |
---|
4409 | #endif |
---|
4410 | if (vps->getNumBitstreamPartitions(h)) |
---|
4411 | { |
---|
4412 | #if Q0182_MULTI_LAYER_HRD_UPDATE |
---|
4413 | READ_UVLC( uiCode, "num_bsp_sched_combinations_minus1[h]"); vps->setNumBspSchedCombinations(h, uiCode + 1); |
---|
4414 | #else |
---|
4415 | READ_UVLC( uiCode, "num_bsp_sched_combinations[h]"); vps->setNumBspSchedCombinations(h, uiCode); |
---|
4416 | #endif |
---|
4417 | for( i = 0; i < vps->getNumBspSchedCombinations(h); i++ ) |
---|
4418 | { |
---|
4419 | for( j = 0; j < vps->getNumBitstreamPartitions(h); j++ ) |
---|
4420 | { |
---|
4421 | READ_UVLC( uiCode, "bsp_comb_hrd_idx[h][i][j]"); vps->setBspCombHrdIdx(h, i, j, uiCode); |
---|
4422 | #if HRD_BPB |
---|
4423 | assert(uiCode <= vps->getVpsNumBspHrdParametersMinus1()); |
---|
4424 | #endif |
---|
4425 | |
---|
4426 | READ_UVLC( uiCode, "bsp_comb_sched_idx[h][i][j]"); vps->setBspCombSchedIdx(h, i, j, uiCode); |
---|
4427 | #if HRD_BPB |
---|
4428 | assert(uiCode <= vps->getBspHrdParamBufferCpbCntMinus1(uiCode,vps->getMaxTLayers()-1)); |
---|
4429 | #endif |
---|
4430 | } |
---|
4431 | } |
---|
4432 | } |
---|
4433 | } |
---|
4434 | #endif |
---|
4435 | } |
---|
4436 | #endif |
---|
4437 | #if P0182_VPS_VUI_PS_FLAG |
---|
4438 | for(i = 1; i < vps->getMaxLayers(); i++) |
---|
4439 | { |
---|
4440 | if (vps->getNumRefLayers(vps->getLayerIdInNuh(i)) == 0) |
---|
4441 | { |
---|
4442 | READ_FLAG( uiCode, "base_layer_parameter_set_compatibility_flag" ); |
---|
4443 | vps->setBaseLayerPSCompatibilityFlag( i, uiCode ); |
---|
4444 | } |
---|
4445 | else |
---|
4446 | { |
---|
4447 | vps->setBaseLayerPSCompatibilityFlag( i, 0 ); |
---|
4448 | } |
---|
4449 | } |
---|
4450 | #endif |
---|
4451 | } |
---|
4452 | |
---|
4453 | Void TDecCavlc::parseSPSExtension( TComSPS* pcSPS ) |
---|
4454 | { |
---|
4455 | UInt uiCode; |
---|
4456 | // more syntax elements to be parsed here |
---|
4457 | |
---|
4458 | READ_FLAG( uiCode, "inter_view_mv_vert_constraint_flag" ); |
---|
4459 | // Vertical MV component restriction is not used in SHVC CTC |
---|
4460 | assert( uiCode == 0 ); |
---|
4461 | |
---|
4462 | #if !MOVE_SCALED_OFFSET_TO_PPS |
---|
4463 | if( pcSPS->getLayerId() > 0 ) |
---|
4464 | { |
---|
4465 | Int iCode; |
---|
4466 | READ_UVLC( uiCode, "num_scaled_ref_layer_offsets" ); pcSPS->setNumScaledRefLayerOffsets(uiCode); |
---|
4467 | for(Int i = 0; i < pcSPS->getNumScaledRefLayerOffsets(); i++) |
---|
4468 | { |
---|
4469 | Window& scaledWindow = pcSPS->getScaledRefLayerWindow(i); |
---|
4470 | #if O0098_SCALED_REF_LAYER_ID |
---|
4471 | READ_CODE( 6, uiCode, "scaled_ref_layer_id" ); pcSPS->setScaledRefLayerId( i, uiCode ); |
---|
4472 | #endif |
---|
4473 | READ_SVLC( iCode, "scaled_ref_layer_left_offset" ); scaledWindow.setWindowLeftOffset (iCode << 1); |
---|
4474 | READ_SVLC( iCode, "scaled_ref_layer_top_offset" ); scaledWindow.setWindowTopOffset (iCode << 1); |
---|
4475 | READ_SVLC( iCode, "scaled_ref_layer_right_offset" ); scaledWindow.setWindowRightOffset (iCode << 1); |
---|
4476 | READ_SVLC( iCode, "scaled_ref_layer_bottom_offset" ); scaledWindow.setWindowBottomOffset(iCode << 1); |
---|
4477 | #if P0312_VERT_PHASE_ADJ |
---|
4478 | READ_FLAG( uiCode, "vert_phase_position_enable_flag" ); scaledWindow.setVertPhasePositionEnableFlag(uiCode); pcSPS->setVertPhasePositionEnableFlag( pcSPS->getScaledRefLayerId(i), uiCode); |
---|
4479 | #endif |
---|
4480 | } |
---|
4481 | } |
---|
4482 | #endif |
---|
4483 | } |
---|
4484 | #endif |
---|
4485 | |
---|
4486 | #if Q0048_CGS_3D_ASYMLUT |
---|
4487 | Void TDecCavlc::xParse3DAsymLUT( TCom3DAsymLUT * pc3DAsymLUT ) |
---|
4488 | { |
---|
4489 | #if R0150_CGS_SIGNAL_CONSTRAINTS |
---|
4490 | UInt uiNumRefLayersM1; |
---|
4491 | READ_UVLC( uiNumRefLayersM1 , "num_cm_ref_layers_minus1" ); |
---|
4492 | assert( uiNumRefLayersM1 <= 61 ); |
---|
4493 | for( UInt i = 0 ; i <= uiNumRefLayersM1 ; i++ ) |
---|
4494 | { |
---|
4495 | UInt uiRefLayerId; |
---|
4496 | READ_CODE( 6 , uiRefLayerId , "cm_ref_layer_id" ); |
---|
4497 | pc3DAsymLUT->addRefLayerId( uiRefLayerId ); |
---|
4498 | } |
---|
4499 | #endif |
---|
4500 | UInt uiCurOctantDepth , uiCurPartNumLog2 , uiInputBitDepthM8 , uiOutputBitDepthM8 , uiResQaunBit; |
---|
4501 | #if R0300_CGS_RES_COEFF_CODING |
---|
4502 | UInt uiDeltaBits; |
---|
4503 | #endif |
---|
4504 | READ_CODE( 2 , uiCurOctantDepth , "cm_octant_depth" ); |
---|
4505 | READ_CODE( 2 , uiCurPartNumLog2 , "cm_y_part_num_log2" ); |
---|
4506 | #if R0150_CGS_SIGNAL_CONSTRAINTS |
---|
4507 | UInt uiChromaInputBitDepthM8 , uiChromaOutputBitDepthM8; |
---|
4508 | READ_UVLC( uiInputBitDepthM8 , "cm_input_luma_bit_depth_minus8" ); |
---|
4509 | READ_UVLC( uiChromaInputBitDepthM8 , "cm_input_chroma_bit_depth_minus8" ); |
---|
4510 | READ_UVLC( uiOutputBitDepthM8 , "cm_output_luma_bit_depth_minus8" ); |
---|
4511 | READ_UVLC( uiChromaOutputBitDepthM8 , "cm_output_chroma_bit_depth_minus8" ); |
---|
4512 | #else |
---|
4513 | READ_CODE( 3 , uiInputBitDepthM8 , "cm_input_bit_depth_minus8" ); |
---|
4514 | Int iInputBitDepthCDelta; |
---|
4515 | READ_SVLC(iInputBitDepthCDelta, "cm_input_bit_depth_chroma delta"); |
---|
4516 | READ_CODE( 3 , uiOutputBitDepthM8 , "cm_output_bit_depth_minus8" ); |
---|
4517 | Int iOutputBitDepthCDelta; |
---|
4518 | READ_SVLC(iOutputBitDepthCDelta, "cm_output_bit_depth_chroma_delta"); |
---|
4519 | #endif |
---|
4520 | READ_CODE( 2 , uiResQaunBit , "cm_res_quant_bit" ); |
---|
4521 | #if R0300_CGS_RES_COEFF_CODING |
---|
4522 | READ_CODE( 2 , uiDeltaBits , "cm_flc_bits" ); |
---|
4523 | pc3DAsymLUT->setDeltaBits(uiDeltaBits + 1); |
---|
4524 | #endif |
---|
4525 | |
---|
4526 | #if R0151_CGS_3D_ASYMLUT_IMPROVE |
---|
4527 | #if R0150_CGS_SIGNAL_CONSTRAINTS |
---|
4528 | Int nAdaptCThresholdU = 1 << ( uiChromaInputBitDepthM8 + 8 - 1 ); |
---|
4529 | Int nAdaptCThresholdV = 1 << ( uiChromaInputBitDepthM8 + 8 - 1 ); |
---|
4530 | #else |
---|
4531 | Int nAdaptCThresholdU = 1 << ( uiInputBitDepthM8 + 8 + iInputBitDepthCDelta - 1 ); |
---|
4532 | Int nAdaptCThresholdV = 1 << ( uiInputBitDepthM8 + 8 + iInputBitDepthCDelta - 1 ); |
---|
4533 | #endif |
---|
4534 | if( uiCurOctantDepth == 1 ) |
---|
4535 | { |
---|
4536 | Int delta = 0; |
---|
4537 | READ_SVLC( delta , "cm_adapt_threshold_u_delta" ); |
---|
4538 | nAdaptCThresholdU += delta; |
---|
4539 | READ_SVLC( delta , "cm_adapt_threshold_v_delta" ); |
---|
4540 | nAdaptCThresholdV += delta; |
---|
4541 | } |
---|
4542 | #endif |
---|
4543 | pc3DAsymLUT->destroy(); |
---|
4544 | pc3DAsymLUT->create( uiCurOctantDepth , uiInputBitDepthM8 + 8 , |
---|
4545 | #if R0150_CGS_SIGNAL_CONSTRAINTS |
---|
4546 | uiChromaInputBitDepthM8 + 8 , |
---|
4547 | #else |
---|
4548 | uiInputBitDepthM8 + 8 + iInputBitDepthCDelta, |
---|
4549 | #endif |
---|
4550 | uiOutputBitDepthM8 + 8 , |
---|
4551 | #if R0150_CGS_SIGNAL_CONSTRAINTS |
---|
4552 | uiChromaOutputBitDepthM8 + 8 , |
---|
4553 | #else |
---|
4554 | uiOutputBitDepthM8 + 8 + iOutputBitDepthCDelta , |
---|
4555 | #endif |
---|
4556 | uiCurPartNumLog2 |
---|
4557 | #if R0151_CGS_3D_ASYMLUT_IMPROVE |
---|
4558 | , nAdaptCThresholdU , nAdaptCThresholdV |
---|
4559 | #endif |
---|
4560 | ); |
---|
4561 | pc3DAsymLUT->setResQuantBit( uiResQaunBit ); |
---|
4562 | |
---|
4563 | #if R0164_CGS_LUT_BUGFIX_CHECK |
---|
4564 | pc3DAsymLUT->xInitCuboids(); |
---|
4565 | #endif |
---|
4566 | xParse3DAsymLUTOctant( pc3DAsymLUT , 0 , 0 , 0 , 0 , 1 << pc3DAsymLUT->getCurOctantDepth() ); |
---|
4567 | #if R0164_CGS_LUT_BUGFIX |
---|
4568 | #if R0164_CGS_LUT_BUGFIX_CHECK |
---|
4569 | printf("============= Before 'xCuboidsFilledCheck()': ================\n"); |
---|
4570 | pc3DAsymLUT->display(); |
---|
4571 | pc3DAsymLUT->xCuboidsFilledCheck( false ); |
---|
4572 | printf("============= After 'xCuboidsFilledCheck()': =================\n"); |
---|
4573 | pc3DAsymLUT->display(); |
---|
4574 | #endif |
---|
4575 | #endif |
---|
4576 | } |
---|
4577 | |
---|
4578 | Void TDecCavlc::xParse3DAsymLUTOctant( TCom3DAsymLUT * pc3DAsymLUT , Int nDepth , Int yIdx , Int uIdx , Int vIdx , Int nLength ) |
---|
4579 | { |
---|
4580 | UInt uiOctantSplit = nDepth < pc3DAsymLUT->getCurOctantDepth(); |
---|
4581 | if( nDepth < pc3DAsymLUT->getCurOctantDepth() ) |
---|
4582 | READ_FLAG( uiOctantSplit , "split_octant_flag" ); |
---|
4583 | Int nYPartNum = 1 << pc3DAsymLUT->getCurYPartNumLog2(); |
---|
4584 | if( uiOctantSplit ) |
---|
4585 | { |
---|
4586 | Int nHalfLength = nLength >> 1; |
---|
4587 | for( Int l = 0 ; l < 2 ; l++ ) |
---|
4588 | { |
---|
4589 | for( Int m = 0 ; m < 2 ; m++ ) |
---|
4590 | { |
---|
4591 | for( Int n = 0 ; n < 2 ; n++ ) |
---|
4592 | { |
---|
4593 | xParse3DAsymLUTOctant( pc3DAsymLUT , nDepth + 1 , yIdx + l * nHalfLength * nYPartNum , uIdx + m * nHalfLength , vIdx + n * nHalfLength , nHalfLength ); |
---|
4594 | } |
---|
4595 | } |
---|
4596 | } |
---|
4597 | } |
---|
4598 | else |
---|
4599 | { |
---|
4600 | #if R0300_CGS_RES_COEFF_CODING |
---|
4601 | Int nFLCbits = pc3DAsymLUT->getMappingShift()-pc3DAsymLUT->getResQuantBit()-pc3DAsymLUT->getDeltaBits() ; |
---|
4602 | nFLCbits = nFLCbits >= 0 ? nFLCbits:0; |
---|
4603 | #endif |
---|
4604 | for( Int l = 0 ; l < nYPartNum ; l++ ) |
---|
4605 | { |
---|
4606 | #if R0164_CGS_LUT_BUGFIX |
---|
4607 | Int shift = pc3DAsymLUT->getCurOctantDepth() - nDepth ; |
---|
4608 | #endif |
---|
4609 | for( Int nVertexIdx = 0 ; nVertexIdx < 4 ; nVertexIdx++ ) |
---|
4610 | { |
---|
4611 | UInt uiCodeVertex = 0; |
---|
4612 | Int deltaY = 0 , deltaU = 0 , deltaV = 0; |
---|
4613 | READ_FLAG( uiCodeVertex , "coded_vertex_flag" ); |
---|
4614 | if( uiCodeVertex ) |
---|
4615 | { |
---|
4616 | #if R0151_CGS_3D_ASYMLUT_IMPROVE |
---|
4617 | #if R0300_CGS_RES_COEFF_CODING |
---|
4618 | xReadParam( deltaY, nFLCbits ); |
---|
4619 | xReadParam( deltaU, nFLCbits ); |
---|
4620 | xReadParam( deltaV, nFLCbits ); |
---|
4621 | #else |
---|
4622 | xReadParam( deltaY ); |
---|
4623 | xReadParam( deltaU ); |
---|
4624 | xReadParam( deltaV ); |
---|
4625 | #endif |
---|
4626 | #else |
---|
4627 | READ_SVLC( deltaY , "resY" ); |
---|
4628 | READ_SVLC( deltaU , "resU" ); |
---|
4629 | READ_SVLC( deltaV , "resV" ); |
---|
4630 | #endif |
---|
4631 | } |
---|
4632 | #if R0164_CGS_LUT_BUGFIX |
---|
4633 | pc3DAsymLUT->setCuboidVertexResTree( yIdx + (l<<shift) , uIdx , vIdx , nVertexIdx , deltaY , deltaU , deltaV ); |
---|
4634 | for (Int m = 1; m < (1<<shift); m++) { |
---|
4635 | pc3DAsymLUT->setCuboidVertexResTree( yIdx + (l<<shift) + m , uIdx , vIdx , nVertexIdx , 0 , 0 , 0 ); |
---|
4636 | #if R0164_CGS_LUT_BUGFIX_CHECK |
---|
4637 | pc3DAsymLUT->xSetFilled( yIdx + (l<<shift) + m , uIdx , vIdx ); |
---|
4638 | #endif |
---|
4639 | } |
---|
4640 | #else |
---|
4641 | pc3DAsymLUT->setCuboidVertexResTree( yIdx + l , uIdx , vIdx , nVertexIdx , deltaY , deltaU , deltaV ); |
---|
4642 | #endif |
---|
4643 | } |
---|
4644 | #if R0164_CGS_LUT_BUGFIX_CHECK |
---|
4645 | pc3DAsymLUT->xSetExplicit( yIdx + (l<<shift) , uIdx , vIdx ); |
---|
4646 | #endif |
---|
4647 | } |
---|
4648 | #if R0164_CGS_LUT_BUGFIX |
---|
4649 | for ( Int u=0 ; u<nLength ; u++ ) { |
---|
4650 | for ( Int v=0 ; v<nLength ; v++ ) { |
---|
4651 | if ( u!=0 || v!=0 ) { |
---|
4652 | for ( Int y=0 ; y<nLength*nYPartNum ; y++ ) { |
---|
4653 | for( Int nVertexIdx = 0 ; nVertexIdx < 4 ; nVertexIdx++ ) |
---|
4654 | { |
---|
4655 | pc3DAsymLUT->setCuboidVertexResTree( yIdx + y , uIdx + u , vIdx + v , nVertexIdx , 0 , 0 , 0 ); |
---|
4656 | #if R0164_CGS_LUT_BUGFIX_CHECK |
---|
4657 | pc3DAsymLUT->xSetFilled( yIdx + y , uIdx + u , vIdx + v ); |
---|
4658 | #endif |
---|
4659 | } |
---|
4660 | } |
---|
4661 | } |
---|
4662 | } |
---|
4663 | } |
---|
4664 | #endif |
---|
4665 | } |
---|
4666 | } |
---|
4667 | |
---|
4668 | #if R0151_CGS_3D_ASYMLUT_IMPROVE |
---|
4669 | #if R0300_CGS_RES_COEFF_CODING |
---|
4670 | Void TDecCavlc::xReadParam( Int& param, Int rParam ) |
---|
4671 | #else |
---|
4672 | Void TDecCavlc::xReadParam( Int& param ) |
---|
4673 | #endif |
---|
4674 | { |
---|
4675 | #if !R0300_CGS_RES_COEFF_CODING |
---|
4676 | const UInt rParam = 7; |
---|
4677 | #endif |
---|
4678 | UInt prefix; |
---|
4679 | UInt codeWord ; |
---|
4680 | UInt rSymbol; |
---|
4681 | UInt sign; |
---|
4682 | |
---|
4683 | READ_UVLC( prefix, "quotient") ; |
---|
4684 | READ_CODE (rParam, codeWord, "remainder"); |
---|
4685 | rSymbol = (prefix<<rParam) + codeWord; |
---|
4686 | |
---|
4687 | if(rSymbol) |
---|
4688 | { |
---|
4689 | READ_FLAG(sign, "sign"); |
---|
4690 | param = sign ? -(Int)(rSymbol) : (Int)(rSymbol); |
---|
4691 | } |
---|
4692 | else param = 0; |
---|
4693 | } |
---|
4694 | #endif |
---|
4695 | #if VPS_VUI_BSP_HRD_PARAMS |
---|
4696 | Void TDecCavlc::parseVpsVuiBspHrdParams( TComVPS *vps ) |
---|
4697 | { |
---|
4698 | UInt uiCode; |
---|
4699 | assert (vps->getTimingInfo()->getTimingInfoPresentFlag() == 1); |
---|
4700 | READ_UVLC( uiCode, "vps_num_add_hrd_params" ); vps->setVpsNumAddHrdParams(uiCode); |
---|
4701 | vps->createBspHrdParamBuffer(vps->getVpsNumAddHrdParams()); // Also allocates m_cprmsAddPresentFlag and m_numSubLayerHrdMinus |
---|
4702 | |
---|
4703 | for( Int i = vps->getNumHrdParameters(), j = 0; i < vps->getNumHrdParameters() + vps->getVpsNumAddHrdParams(); i++, j++ ) // j = i - vps->getNumHrdParameters() |
---|
4704 | { |
---|
4705 | if( i > 0 ) |
---|
4706 | { |
---|
4707 | READ_FLAG( uiCode, "cprms_add_present_flag[i]" ); vps->setCprmsAddPresentFlag(j, uiCode ? true : false); |
---|
4708 | } |
---|
4709 | else |
---|
4710 | { |
---|
4711 | // i == 0 |
---|
4712 | if( vps->getNumHrdParameters() == 0 ) |
---|
4713 | { |
---|
4714 | vps->setCprmsAddPresentFlag(0, true); |
---|
4715 | } |
---|
4716 | } |
---|
4717 | READ_UVLC( uiCode, "num_sub_layer_hrd_minus1[i]" ); vps->setNumSubLayerHrdMinus1(j, uiCode ); |
---|
4718 | assert( uiCode <= vps->getMaxTLayers() - 1 ); |
---|
4719 | |
---|
4720 | parseHrdParameters( vps->getBspHrd(j), vps->getCprmsAddPresentFlag(j), vps->getNumSubLayerHrdMinus1(j) ); |
---|
4721 | if( i > 0 && !vps->getCprmsAddPresentFlag(i) ) |
---|
4722 | { |
---|
4723 | // Copy common information parameters |
---|
4724 | if( i == vps->getNumHrdParameters() ) |
---|
4725 | { |
---|
4726 | vps->getBspHrd(j)->copyCommonInformation( vps->getHrdParameters( vps->getNumHrdParameters() - 1 ) ); |
---|
4727 | } |
---|
4728 | else |
---|
4729 | { |
---|
4730 | vps->getBspHrd(j)->copyCommonInformation( vps->getBspHrd( j - 1 ) ); |
---|
4731 | } |
---|
4732 | } |
---|
4733 | } |
---|
4734 | #if VPS_FIX_TO_MATCH_SPEC |
---|
4735 | if( vps->getNumHrdParameters() + vps->getVpsNumAddHrdParams() > 0 ) |
---|
4736 | { |
---|
4737 | #endif |
---|
4738 | for (Int h = 1; h < vps->getNumOutputLayerSets(); h++) |
---|
4739 | { |
---|
4740 | Int lsIdx = vps->getOutputLayerSetIdx(h); |
---|
4741 | READ_UVLC(uiCode, "num_signalled_partitioning_schemes[h]"); vps->setNumSignalledPartitioningSchemes(h, uiCode); |
---|
4742 | #if VPS_FIX_TO_MATCH_SPEC |
---|
4743 | for (Int j = 1; j < vps->getNumSignalledPartitioningSchemes(h) + 1; j++) |
---|
4744 | #else |
---|
4745 | for (Int j = 0; j < vps->getNumSignalledPartitioningSchemes(h); j++) |
---|
4746 | #endif |
---|
4747 | { |
---|
4748 | READ_UVLC(uiCode, "num_partitions_in_scheme_minus1[h][j]"); vps->setNumPartitionsInSchemeMinus1(h, j, uiCode); |
---|
4749 | for (Int k = 0; k <= vps->getNumPartitionsInSchemeMinus1(h, j); k++) |
---|
4750 | { |
---|
4751 | for (Int r = 0; r < vps->getNumLayersInIdList(lsIdx); r++) |
---|
4752 | { |
---|
4753 | READ_FLAG(uiCode, "layer_included_in_partition_flag[h][j][k][r]"); vps->setLayerIncludedInPartitionFlag(h, j, k, r, uiCode ? true : false); |
---|
4754 | } |
---|
4755 | } |
---|
4756 | } |
---|
4757 | for (Int i = 0; i < vps->getNumSignalledPartitioningSchemes(h) + 1; i++) |
---|
4758 | { |
---|
4759 | for (Int t = 0; t <= vps->getMaxSLayersInLayerSetMinus1(lsIdx); t++) |
---|
4760 | { |
---|
4761 | READ_UVLC(uiCode, "num_bsp_schedules_minus1[h][i][t]"); vps->setNumBspSchedulesMinus1(h, i, t, uiCode); |
---|
4762 | for (Int j = 0; j <= vps->getNumBspSchedulesMinus1(h, i, t); j++) |
---|
4763 | { |
---|
4764 | #if VPS_FIX_TO_MATCH_SPEC |
---|
4765 | for( Int k = 0; k <= vps->getNumPartitionsInSchemeMinus1(h, i); k++ ) |
---|
4766 | #else |
---|
4767 | for (Int k = 0; k < vps->getNumPartitionsInSchemeMinus1(h, i); k++) |
---|
4768 | #endif |
---|
4769 | { |
---|
4770 | #if VPS_FIX_TO_MATCH_SPEC |
---|
4771 | if( vps->getNumHrdParameters() + vps->getVpsNumAddHrdParams() > 1 ) |
---|
4772 | { |
---|
4773 | Int numBits = 1; |
---|
4774 | while ((1 << numBits) < (vps->getNumHrdParameters() + vps->getVpsNumAddHrdParams())) |
---|
4775 | { |
---|
4776 | numBits++; |
---|
4777 | } |
---|
4778 | READ_CODE(numBits, uiCode, "bsp_comb_hrd_idx[h][i][t][j][k]"); vps->setBspHrdIdx(h, i, t, j, k, uiCode); |
---|
4779 | } |
---|
4780 | #else |
---|
4781 | READ_UVLC(uiCode, "bsp_comb_hrd_idx[h][i][t][j][k]"); vps->setBspHrdIdx(h, i, t, j, k, uiCode); |
---|
4782 | #endif |
---|
4783 | READ_UVLC(uiCode, "bsp_comb_sched_idx[h][i][t][j][k]"); vps->setBspSchedIdx(h, i, t, j, k, uiCode); |
---|
4784 | } |
---|
4785 | } |
---|
4786 | } |
---|
4787 | } |
---|
4788 | |
---|
4789 | // To be done: Check each layer included in not more than one BSP in every partitioning scheme, |
---|
4790 | // and other related checks associated with layers in bitstream partitions. |
---|
4791 | |
---|
4792 | } |
---|
4793 | #if VPS_FIX_TO_MATCH_SPEC |
---|
4794 | } |
---|
4795 | #endif |
---|
4796 | } |
---|
4797 | #endif |
---|
4798 | #endif |
---|
4799 | //! \} |
---|
4800 | |
---|