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->setNumRefLayerLocationOffsets(uiCode); |
---|
415 | for(Int k = 0; k < pcPPS->getNumRefLayerLocationOffsets(); k++) |
---|
416 | { |
---|
417 | READ_CODE( 6, uiCode, "ref_loc_offset_layer_id" ); pcPPS->setRefLocationOffsetLayerId( 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_IDX_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()->getLayerIdxInVps(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 | UInt layerIdx = pcSlice->getVPS()->getLayerIdxInVps(pcSlice->getLayerId()); |
---|
1539 | assert(rps->getNumberOfNegativePictures() <= pcSlice->getVPS()->getMaxVpsDecPicBufferingMinus1(ii, layerIdx, pcSlice->getVPS()->getMaxSLayersInLayerSetMinus1(ii))); |
---|
1540 | assert(rps->getNumberOfPositivePictures() <= pcSlice->getVPS()->getMaxVpsDecPicBufferingMinus1(ii, layerIdx, pcSlice->getVPS()->getMaxSLayersInLayerSetMinus1(ii)) - rps->getNumberOfNegativePictures()); |
---|
1541 | assert((rps->getNumberOfPositivePictures() + rps->getNumberOfNegativePictures() + rps->getNumberOfLongtermPictures()) <= pcSlice->getVPS()->getMaxVpsDecPicBufferingMinus1(ii, layerIdx, 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()->getLayerIdxInVps(i),pcSlice->getLayerId()) > pcSlice->getTLayer() || pcSlice->getTLayer()==0) && |
---|
1604 | (pcSlice->getVPS()->getMaxTSLayersMinus1(pcSlice->getVPS()->getLayerIdxInVps(i)) >= pcSlice->getTLayer()) ) |
---|
1605 | #else |
---|
1606 | if(pcSlice->getVPS()->getMaxTidIlRefPicsPlus1(pcSlice->getVPS()->getLayerIdxInVps(i),pcSlice->getLayerId()) > pcSlice->getTLayer() && |
---|
1607 | (pcSlice->getVPS()->getMaxTSLayersMinus1(pcSlice->getVPS()->getLayerIdxInVps(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_IDX_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()->getLayerIdxInVps(i),pcSlice->getLayerId()) > pcSlice->getTLayer() || pcSlice->getTLayer()==0) && |
---|
1667 | (pcSlice->getVPS()->getMaxTSLayersMinus1(pcSlice->getVPS()->getLayerIdxInVps(i)) >= pcSlice->getTLayer()) ) |
---|
1668 | #else |
---|
1669 | if(pcSlice->getVPS()->getMaxTidIlRefPicsPlus1(pcSlice->getVPS()->getLayerIdxInVps(i),pcSlice->getLayerId()) > pcSlice->getTLayer() && |
---|
1670 | (pcSlice->getVPS()->getMaxTSLayersMinus1(pcSlice->getVPS()->getLayerIdxInVps(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()->getLayerIdxInVps(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()->getLayerIdxInVps(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()->getLayerIdxInVps(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->setLayerIdxInVps(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->setLayerIdxInVps(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 O0109_VIEW_ID_LEN |
---|
2884 | READ_CODE( 4, uiCode, "view_id_len" ); vps->setViewIdLen( uiCode ); |
---|
2885 | #else |
---|
2886 | READ_CODE( 4, uiCode, "view_id_len_minus1" ); vps->setViewIdLenMinus1( uiCode ); |
---|
2887 | #endif |
---|
2888 | |
---|
2889 | #if O0109_VIEW_ID_LEN |
---|
2890 | if ( vps->getViewIdLen() > 0 ) |
---|
2891 | { |
---|
2892 | for( i = 0; i < vps->getNumViews(); i++ ) |
---|
2893 | { |
---|
2894 | READ_CODE( vps->getViewIdLen( ), uiCode, "view_id_val[i]" ); vps->setViewIdVal( i, uiCode ); |
---|
2895 | } |
---|
2896 | } |
---|
2897 | #else |
---|
2898 | for( i = 0; i < vps->getNumViews(); i++ ) |
---|
2899 | { |
---|
2900 | READ_CODE( vps->getViewIdLenMinus1( ) + 1, uiCode, "view_id_val[i]" ); vps->setViewIdVal( i, uiCode ); |
---|
2901 | } |
---|
2902 | #endif |
---|
2903 | #endif // view id related signaling |
---|
2904 | #if VPS_EXTN_DIRECT_REF_LAYERS |
---|
2905 | // For layer 0 |
---|
2906 | vps->setNumDirectRefLayers(0, 0); |
---|
2907 | // For other layers |
---|
2908 | for( Int layerCtr = 1; layerCtr < vps->getMaxLayers(); layerCtr++) |
---|
2909 | { |
---|
2910 | UInt layerId = vps->getLayerIdInNuh(layerCtr); |
---|
2911 | UInt numDirectRefLayers = 0; |
---|
2912 | for( Int refLayerCtr = 0; refLayerCtr < layerCtr; refLayerCtr++) |
---|
2913 | { |
---|
2914 | READ_FLAG(uiCode, "direct_dependency_flag[i][j]" ); vps->setDirectDependencyFlag(layerCtr, refLayerCtr, uiCode? true : false); |
---|
2915 | if(uiCode) |
---|
2916 | { |
---|
2917 | vps->setRefLayerId(layerId, numDirectRefLayers, vps->getLayerIdInNuh(refLayerCtr)); |
---|
2918 | numDirectRefLayers++; |
---|
2919 | } |
---|
2920 | } |
---|
2921 | vps->setNumDirectRefLayers(layerId, numDirectRefLayers); |
---|
2922 | } |
---|
2923 | #endif |
---|
2924 | #if Q0078_ADD_LAYER_SETS |
---|
2925 | #if O0092_0094_DEPENDENCY_CONSTRAINT // Moved here |
---|
2926 | vps->setNumRefLayers(); |
---|
2927 | |
---|
2928 | if (vps->getMaxLayers() > MAX_REF_LAYERS) |
---|
2929 | { |
---|
2930 | for (i = 1; i < vps->getMaxLayers(); i++) |
---|
2931 | { |
---|
2932 | assert(vps->getNumRefLayers(vps->getLayerIdInNuh(i)) <= MAX_REF_LAYERS); |
---|
2933 | } |
---|
2934 | } |
---|
2935 | #endif |
---|
2936 | vps->setPredictedLayerIds(); |
---|
2937 | vps->setTreePartitionLayerIdList(); |
---|
2938 | #endif |
---|
2939 | #if MOVE_ADDN_LS_SIGNALLING |
---|
2940 | #if Q0078_ADD_LAYER_SETS |
---|
2941 | if (vps->getNumIndependentLayers() > 1) |
---|
2942 | { |
---|
2943 | READ_UVLC(uiCode, "num_add_layer_sets"); vps->setNumAddLayerSets(uiCode); |
---|
2944 | for (i = 0; i < vps->getNumAddLayerSets(); i++) |
---|
2945 | { |
---|
2946 | for (j = 1; j < vps->getNumIndependentLayers(); j++) |
---|
2947 | { |
---|
2948 | int len = 1; |
---|
2949 | while ((1 << len) < (vps->getNumLayersInTreePartition(j) + 1)) |
---|
2950 | { |
---|
2951 | len++; |
---|
2952 | } |
---|
2953 | READ_CODE(len, uiCode, "highest_layer_idx_plus1[i][j]"); vps->setHighestLayerIdxPlus1(i, j, uiCode); |
---|
2954 | } |
---|
2955 | } |
---|
2956 | vps->setNumLayerSets(vps->getNumLayerSets() + vps->getNumAddLayerSets()); |
---|
2957 | #if FIX_LAYER_ID_INIT |
---|
2958 | vps->deriveLayerIdListVariablesForAddLayerSets(); |
---|
2959 | #else |
---|
2960 | vps->setLayerIdIncludedFlagsForAddLayerSets(); |
---|
2961 | #endif |
---|
2962 | } |
---|
2963 | else |
---|
2964 | { |
---|
2965 | vps->setNumAddLayerSets(0); |
---|
2966 | } |
---|
2967 | #endif |
---|
2968 | #endif |
---|
2969 | #if VPS_TSLAYERS |
---|
2970 | READ_FLAG( uiCode, "vps_sub_layers_max_minus1_present_flag"); vps->setMaxTSLayersPresentFlag(uiCode ? true : false); |
---|
2971 | |
---|
2972 | if (vps->getMaxTSLayersPresentFlag()) |
---|
2973 | { |
---|
2974 | for(i = 0; i < vps->getMaxLayers(); i++) |
---|
2975 | { |
---|
2976 | READ_CODE( 3, uiCode, "sub_layers_vps_max_minus1[i]" ); vps->setMaxTSLayersMinus1(i, uiCode); |
---|
2977 | } |
---|
2978 | } |
---|
2979 | else |
---|
2980 | { |
---|
2981 | for( i = 0; i < vps->getMaxLayers(); i++) |
---|
2982 | { |
---|
2983 | vps->setMaxTSLayersMinus1(i, vps->getMaxTLayers()-1); |
---|
2984 | } |
---|
2985 | } |
---|
2986 | #endif |
---|
2987 | READ_FLAG( uiCode, "max_tid_ref_present_flag"); vps->setMaxTidRefPresentFlag(uiCode ? true : false); |
---|
2988 | if (vps->getMaxTidRefPresentFlag()) |
---|
2989 | { |
---|
2990 | for(i = 0; i < vps->getMaxLayers() - 1; i++) |
---|
2991 | { |
---|
2992 | #if O0225_MAX_TID_FOR_REF_LAYERS |
---|
2993 | for( j = i+1; j < vps->getMaxLayers(); j++) |
---|
2994 | { |
---|
2995 | if(vps->getDirectDependencyFlag(j, i)) |
---|
2996 | { |
---|
2997 | READ_CODE( 3, uiCode, "max_tid_il_ref_pics_plus1[i][j]" ); vps->setMaxTidIlRefPicsPlus1(i, j, uiCode); |
---|
2998 | } |
---|
2999 | } |
---|
3000 | #else |
---|
3001 | READ_CODE( 3, uiCode, "max_tid_il_ref_pics_plus1[i]" ); vps->setMaxTidIlRefPicsPlus1(i, uiCode); |
---|
3002 | assert( uiCode <= vps->getMaxTLayers()); |
---|
3003 | #endif |
---|
3004 | } |
---|
3005 | } |
---|
3006 | else |
---|
3007 | { |
---|
3008 | for(i = 0; i < vps->getMaxLayers() - 1; i++) |
---|
3009 | { |
---|
3010 | #if O0225_MAX_TID_FOR_REF_LAYERS |
---|
3011 | for( j = i+1; j < vps->getMaxLayers(); j++) |
---|
3012 | { |
---|
3013 | vps->setMaxTidIlRefPicsPlus1(i, j, 7); |
---|
3014 | } |
---|
3015 | #else |
---|
3016 | vps->setMaxTidIlRefPicsPlus1(i, 7); |
---|
3017 | #endif |
---|
3018 | } |
---|
3019 | } |
---|
3020 | READ_FLAG( uiCode, "all_ref_layers_active_flag" ); vps->setIlpSshSignalingEnabledFlag(uiCode ? true : false); |
---|
3021 | #if VPS_EXTN_PROFILE_INFO |
---|
3022 | // Profile-tier-level signalling |
---|
3023 | #if !VPS_EXTN_UEV_CODING |
---|
3024 | READ_CODE( 10, uiCode, "vps_number_layer_sets_minus1" ); assert( uiCode == (vps->getNumLayerSets() - 1) ); |
---|
3025 | READ_CODE( 6, uiCode, "vps_num_profile_tier_level_minus1"); vps->setNumProfileTierLevel( uiCode + 1 ); |
---|
3026 | #else |
---|
3027 | READ_UVLC( uiCode, "vps_num_profile_tier_level_minus1"); vps->setNumProfileTierLevel( uiCode + 1 ); |
---|
3028 | #endif |
---|
3029 | #if PER_LAYER_PTL |
---|
3030 | Int const numBitsForPtlIdx = vps->calculateLenOfSyntaxElement( vps->getNumProfileTierLevel() ); |
---|
3031 | #endif |
---|
3032 | #if !MULTIPLE_PTL_SUPPORT |
---|
3033 | vps->getPTLForExtnPtr()->resize(vps->getNumProfileTierLevel()); |
---|
3034 | #endif |
---|
3035 | #if LIST_OF_PTL |
---|
3036 | for(Int idx = vps->getBaseLayerInternalFlag() ? 2 : 1; idx <= vps->getNumProfileTierLevel() - 1; idx++) |
---|
3037 | #else |
---|
3038 | for(Int idx = 1; idx <= vps->getNumProfileTierLevel() - 1; idx++) |
---|
3039 | #endif |
---|
3040 | { |
---|
3041 | READ_FLAG( uiCode, "vps_profile_present_flag[i]" ); vps->setProfilePresentFlag(idx, uiCode ? true : false); |
---|
3042 | if( !vps->getProfilePresentFlag(idx) ) |
---|
3043 | { |
---|
3044 | #if P0048_REMOVE_PROFILE_REF |
---|
3045 | // Copy profile information from previous one |
---|
3046 | #if MULTIPLE_PTL_SUPPORT |
---|
3047 | vps->getPTL(idx)->copyProfileInfo( vps->getPTL( idx - 1 ) ); |
---|
3048 | #else |
---|
3049 | vps->getPTLForExtn(idx)->copyProfileInfo( (idx==1) ? vps->getPTL() : vps->getPTLForExtn( idx - 1 ) ); |
---|
3050 | #endif |
---|
3051 | #else |
---|
3052 | READ_CODE( 6, uiCode, "profile_ref_minus1[i]" ); vps->setProfileLayerSetRef(idx, uiCode + 1); |
---|
3053 | #if O0109_PROF_REF_MINUS1 |
---|
3054 | assert( vps->getProfileLayerSetRef(idx) <= idx ); |
---|
3055 | #else |
---|
3056 | assert( vps->getProfileLayerSetRef(idx) < idx ); |
---|
3057 | #endif |
---|
3058 | // Copy profile information as indicated |
---|
3059 | vps->getPTLForExtn(idx)->copyProfileInfo( vps->getPTLForExtn( vps->getProfileLayerSetRef(idx) ) ); |
---|
3060 | #endif |
---|
3061 | } |
---|
3062 | #if MULTIPLE_PTL_SUPPORT |
---|
3063 | parsePTL( vps->getPTL(idx), vps->getProfilePresentFlag(idx), vps->getMaxTLayers() - 1 ); |
---|
3064 | #else |
---|
3065 | parsePTL( vps->getPTLForExtn(idx), vps->getProfilePresentFlag(idx), vps->getMaxTLayers() - 1 ); |
---|
3066 | #endif |
---|
3067 | } |
---|
3068 | #endif |
---|
3069 | |
---|
3070 | #if !MOVE_ADDN_LS_SIGNALLING |
---|
3071 | #if Q0078_ADD_LAYER_SETS |
---|
3072 | if (vps->getNumIndependentLayers() > 1) |
---|
3073 | { |
---|
3074 | READ_UVLC(uiCode, "num_add_layer_sets"); vps->setNumAddLayerSets(uiCode); |
---|
3075 | for (i = 0; i < vps->getNumAddLayerSets(); i++) |
---|
3076 | { |
---|
3077 | for (j = 1; j < vps->getNumIndependentLayers(); j++) |
---|
3078 | { |
---|
3079 | int len = 1; |
---|
3080 | while ((1 << len) < (vps->getNumLayersInTreePartition(j) + 1)) |
---|
3081 | { |
---|
3082 | len++; |
---|
3083 | } |
---|
3084 | READ_CODE(len, uiCode, "highest_layer_idx_plus1[i][j]"); vps->setHighestLayerIdxPlus1(i, j, uiCode); |
---|
3085 | } |
---|
3086 | } |
---|
3087 | vps->setNumLayerSets(vps->getNumLayerSets() + vps->getNumAddLayerSets()); |
---|
3088 | vps->setLayerIdIncludedFlagsForAddLayerSets(); |
---|
3089 | } |
---|
3090 | #endif |
---|
3091 | #endif |
---|
3092 | |
---|
3093 | #if !VPS_EXTN_UEV_CODING |
---|
3094 | READ_FLAG( uiCode, "more_output_layer_sets_than_default_flag" ); vps->setMoreOutputLayerSetsThanDefaultFlag( uiCode ? true : false ); |
---|
3095 | Int numOutputLayerSets = 0; |
---|
3096 | if(! vps->getMoreOutputLayerSetsThanDefaultFlag() ) |
---|
3097 | { |
---|
3098 | numOutputLayerSets = vps->getNumLayerSets(); |
---|
3099 | } |
---|
3100 | else |
---|
3101 | { |
---|
3102 | READ_CODE( 10, uiCode, "num_add_output_layer_sets" ); vps->setNumAddOutputLayerSets( uiCode ); |
---|
3103 | numOutputLayerSets = vps->getNumLayerSets() + vps->getNumAddOutputLayerSets(); |
---|
3104 | } |
---|
3105 | #else |
---|
3106 | |
---|
3107 | #if Q0165_NUM_ADD_OUTPUT_LAYER_SETS |
---|
3108 | if( vps->getNumLayerSets() > 1 ) |
---|
3109 | { |
---|
3110 | READ_UVLC( uiCode, "num_add_olss" ); vps->setNumAddOutputLayerSets( uiCode ); |
---|
3111 | READ_CODE( 2, uiCode, "default_output_layer_idc" ); vps->setDefaultTargetOutputLayerIdc( uiCode ); |
---|
3112 | } |
---|
3113 | else |
---|
3114 | { |
---|
3115 | vps->setNumAddOutputLayerSets( 0 ); |
---|
3116 | } |
---|
3117 | #else |
---|
3118 | READ_UVLC( uiCode, "num_add_output_layer_sets" ); vps->setNumAddOutputLayerSets( uiCode ); |
---|
3119 | #endif |
---|
3120 | |
---|
3121 | // The value of num_add_olss shall be in the range of 0 to 1023, inclusive. |
---|
3122 | assert( vps->getNumAddOutputLayerSets() >= 0 && vps->getNumAddOutputLayerSets() < 1024 ); |
---|
3123 | |
---|
3124 | Int numOutputLayerSets = vps->getNumLayerSets() + vps->getNumAddOutputLayerSets(); |
---|
3125 | #endif |
---|
3126 | |
---|
3127 | #if P0295_DEFAULT_OUT_LAYER_IDC |
---|
3128 | #if !Q0165_NUM_ADD_OUTPUT_LAYER_SETS |
---|
3129 | if( numOutputLayerSets > 1 ) |
---|
3130 | { |
---|
3131 | READ_CODE( 2, uiCode, "default_target_output_layer_idc" ); vps->setDefaultTargetOutputLayerIdc( uiCode ); |
---|
3132 | } |
---|
3133 | #endif |
---|
3134 | vps->setNumOutputLayerSets( numOutputLayerSets ); |
---|
3135 | #if NECESSARY_LAYER_FLAG |
---|
3136 | // Default output layer set |
---|
3137 | vps->setOutputLayerSetIdx(0, 0); |
---|
3138 | vps->setOutputLayerFlag(0, 0, true); |
---|
3139 | vps->deriveNecessaryLayerFlag(0); |
---|
3140 | #if PER_LAYER_PTL |
---|
3141 | vps->getProfileLevelTierIdx()->resize(numOutputLayerSets); |
---|
3142 | vps->getProfileLevelTierIdx(0)->push_back( vps->getBaseLayerInternalFlag() && vps->getMaxLayers() > 1 ? 1 : 0); |
---|
3143 | #endif |
---|
3144 | #endif |
---|
3145 | for(i = 1; i < numOutputLayerSets; i++) |
---|
3146 | { |
---|
3147 | #if VPS_FIX_TO_MATCH_SPEC |
---|
3148 | if( vps->getNumLayerSets() > 2 && i >= vps->getNumLayerSets() ) |
---|
3149 | #else |
---|
3150 | if( i > (vps->getNumLayerSets() - 1) ) |
---|
3151 | #endif |
---|
3152 | { |
---|
3153 | Int numBits = 1; |
---|
3154 | while ((1 << numBits) < (vps->getNumLayerSets() - 1)) |
---|
3155 | { |
---|
3156 | numBits++; |
---|
3157 | } |
---|
3158 | READ_CODE( numBits, uiCode, "layer_set_idx_for_ols_minus1"); vps->setOutputLayerSetIdx( i, uiCode + 1); |
---|
3159 | } |
---|
3160 | else |
---|
3161 | { |
---|
3162 | vps->setOutputLayerSetIdx( i, i ); |
---|
3163 | } |
---|
3164 | Int layerSetIdxForOutputLayerSet = vps->getOutputLayerSetIdx(i); |
---|
3165 | #if Q0078_ADD_LAYER_SETS |
---|
3166 | #if VPS_FIX_TO_MATCH_SPEC |
---|
3167 | if( i > vps->getVpsNumLayerSetsMinus1() || vps->getDefaultTargetOutputLayerIdc() == 2 ) |
---|
3168 | #else |
---|
3169 | if( i > vps->getVpsNumLayerSetsMinus1() || vps->getDefaultTargetOutputLayerIdc() >= 2 ) |
---|
3170 | #endif |
---|
3171 | #else |
---|
3172 | #if VPS_FIX_TO_MATCH_SPEC |
---|
3173 | if( i > (vps->getNumLayerSets() - 1) || vps->getDefaultTargetOutputLayerIdc() == 2 ) |
---|
3174 | #else |
---|
3175 | if( i > (vps->getNumLayerSets() - 1) || vps->getDefaultTargetOutputLayerIdc() >= 2 ) |
---|
3176 | #endif |
---|
3177 | #endif |
---|
3178 | { |
---|
3179 | #if NUM_OL_FLAGS |
---|
3180 | for(j = 0; j < vps->getNumLayersInIdList(layerSetIdxForOutputLayerSet); j++) |
---|
3181 | #else |
---|
3182 | for(j = 0; j < vps->getNumLayersInIdList(lsIdx) - 1; j++) |
---|
3183 | #endif |
---|
3184 | { |
---|
3185 | READ_FLAG( uiCode, "output_layer_flag[i][j]"); vps->setOutputLayerFlag(i, j, uiCode); |
---|
3186 | } |
---|
3187 | } |
---|
3188 | else |
---|
3189 | { |
---|
3190 | // i <= (vps->getNumLayerSets() - 1) |
---|
3191 | // Assign OutputLayerFlag depending on default_one_target_output_layer_flag |
---|
3192 | if( vps->getDefaultTargetOutputLayerIdc() == 1 ) |
---|
3193 | { |
---|
3194 | for(j = 0; j < vps->getNumLayersInIdList(layerSetIdxForOutputLayerSet); j++) |
---|
3195 | { |
---|
3196 | #if DEF_OPT_LAYER_IDC |
---|
3197 | vps->setOutputLayerFlag(i, j, (j == (vps->getNumLayersInIdList(layerSetIdxForOutputLayerSet)-1)) ); |
---|
3198 | |
---|
3199 | #else |
---|
3200 | vps->setOutputLayerFlag(i, j, (j == (vps->getNumLayersInIdList(layerSetIdxForOutputLayerSet)-1)) && (vps->getDimensionId(j,1) == 0) ); |
---|
3201 | #endif |
---|
3202 | } |
---|
3203 | } |
---|
3204 | else if ( vps->getDefaultTargetOutputLayerIdc() == 0 ) |
---|
3205 | { |
---|
3206 | for(j = 0; j < vps->getNumLayersInIdList(layerSetIdxForOutputLayerSet); j++) |
---|
3207 | { |
---|
3208 | vps->setOutputLayerFlag(i, j, 1); |
---|
3209 | } |
---|
3210 | } |
---|
3211 | } |
---|
3212 | #if NECESSARY_LAYER_FLAG |
---|
3213 | vps->deriveNecessaryLayerFlag(i); |
---|
3214 | #endif |
---|
3215 | #if PER_LAYER_PTL |
---|
3216 | vps->getProfileLevelTierIdx(i)->assign(vps->getNumLayersInIdList(layerSetIdxForOutputLayerSet), -1); |
---|
3217 | for(j = 0; j < vps->getNumLayersInIdList(layerSetIdxForOutputLayerSet) ; j++) |
---|
3218 | { |
---|
3219 | #if VPS_FIX_TO_MATCH_SPEC |
---|
3220 | if( vps->getNecessaryLayerFlag(i, j) && (vps->getNumProfileTierLevel()-1) > 0 ) |
---|
3221 | #else |
---|
3222 | if( vps->getNecessaryLayerFlag(i, j) ) |
---|
3223 | #endif |
---|
3224 | { |
---|
3225 | READ_CODE( numBitsForPtlIdx, uiCode, "profile_tier_level_idx[i]" ); |
---|
3226 | vps->setProfileLevelTierIdx(i, j, uiCode ); |
---|
3227 | |
---|
3228 | #if MULTIPLE_PTL_SUPPORT |
---|
3229 | //For conformance checking |
---|
3230 | //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: |
---|
3231 | //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 |
---|
3232 | //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: |
---|
3233 | //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 |
---|
3234 | //The following assert may be updated / upgraded to take care of general_profile_compatibility_flag. |
---|
3235 | #if R0235_SMALLEST_LAYER_ID |
---|
3236 | // The assertion below is not valid for independent non-base layers |
---|
3237 | if (vps->getNumAddLayerSets() == 0) |
---|
3238 | { |
---|
3239 | #endif |
---|
3240 | if( j > 0 && vps->getLayerSetLayerIdList(layerSetIdxForOutputLayerSet, j) != 0 && vps->getLayerSetLayerIdList(layerSetIdxForOutputLayerSet, j - 1) != 0 && vps->getNecessaryLayerFlag(i, j-1) ) |
---|
3241 | { |
---|
3242 | assert(vps->getPTL(vps->getProfileLevelTierIdx(i, j))->getGeneralPTL()->getProfileIdc() == vps->getPTL(vps->getProfileLevelTierIdx(i, j - 1))->getGeneralPTL()->getProfileIdc() || |
---|
3243 | vps->getPTL(vps->getProfileLevelTierIdx(i, j - 1))->getGeneralPTL()->getProfileCompatibilityFlag(vps->getPTL(vps->getProfileLevelTierIdx(i, j))->getGeneralPTL()->getProfileIdc()) || |
---|
3244 | vps->getPTL(vps->getProfileLevelTierIdx(i, j))->getGeneralPTL()->getProfileCompatibilityFlag(vps->getPTL(vps->getProfileLevelTierIdx(i, j - 1))->getGeneralPTL()->getProfileIdc()) ); |
---|
3245 | } |
---|
3246 | #if R0235_SMALLEST_LAYER_ID |
---|
3247 | } |
---|
3248 | #endif |
---|
3249 | #endif |
---|
3250 | } |
---|
3251 | } |
---|
3252 | #else |
---|
3253 | Int numBits = 1; |
---|
3254 | while ((1 << numBits) < (vps->getNumProfileTierLevel())) |
---|
3255 | { |
---|
3256 | numBits++; |
---|
3257 | } |
---|
3258 | READ_CODE( numBits, uiCode, "profile_tier_level_idx[i]" ); vps->setProfileLevelTierIdx(i, uiCode); |
---|
3259 | #endif |
---|
3260 | #if P0300_ALT_OUTPUT_LAYER_FLAG |
---|
3261 | NumOutputLayersInOutputLayerSet[i] = 0; |
---|
3262 | for (j = 0; j < vps->getNumLayersInIdList(layerSetIdxForOutputLayerSet); j++) |
---|
3263 | { |
---|
3264 | NumOutputLayersInOutputLayerSet[i] += vps->getOutputLayerFlag(i, j); |
---|
3265 | if (vps->getOutputLayerFlag(i, j)) |
---|
3266 | { |
---|
3267 | OlsHighestOutputLayerId[i] = vps->getLayerSetLayerIdList(layerSetIdxForOutputLayerSet, j); |
---|
3268 | } |
---|
3269 | } |
---|
3270 | if (NumOutputLayersInOutputLayerSet[i] == 1 && vps->getNumDirectRefLayers(OlsHighestOutputLayerId[i]) > 0) |
---|
3271 | { |
---|
3272 | READ_FLAG(uiCode, "alt_output_layer_flag[i]"); |
---|
3273 | vps->setAltOuputLayerFlag(i, uiCode ? true : false); |
---|
3274 | } |
---|
3275 | #if ALT_OPT_LAYER_FLAG |
---|
3276 | else |
---|
3277 | { |
---|
3278 | uiCode=0; |
---|
3279 | vps->setAltOuputLayerFlag(i, uiCode ? true : false); |
---|
3280 | } |
---|
3281 | #endif |
---|
3282 | #if Q0165_OUTPUT_LAYER_SET |
---|
3283 | assert( NumOutputLayersInOutputLayerSet[i]>0 ); |
---|
3284 | #endif |
---|
3285 | |
---|
3286 | #endif |
---|
3287 | } |
---|
3288 | #if NECESSARY_LAYER_FLAG |
---|
3289 | vps->checkNecessaryLayerFlagCondition(); |
---|
3290 | #endif |
---|
3291 | #else |
---|
3292 | if( numOutputLayerSets > 1 ) |
---|
3293 | { |
---|
3294 | #if O0109_DEFAULT_ONE_OUT_LAYER_IDC |
---|
3295 | READ_CODE( 2, uiCode, "default_one_target_output_layer_idc" ); vps->setDefaultOneTargetOutputLayerIdc( uiCode ); |
---|
3296 | #else |
---|
3297 | READ_FLAG( uiCode, "default_one_target_output_layer_flag" ); vps->setDefaultOneTargetOutputLayerFlag( uiCode ? true : false ); |
---|
3298 | #endif |
---|
3299 | } |
---|
3300 | vps->setNumOutputLayerSets( numOutputLayerSets ); |
---|
3301 | |
---|
3302 | for(i = 1; i < numOutputLayerSets; i++) |
---|
3303 | { |
---|
3304 | if( i > (vps->getNumLayerSets() - 1) ) |
---|
3305 | { |
---|
3306 | Int numBits = 1; |
---|
3307 | while ((1 << numBits) < (vps->getNumLayerSets() - 1)) |
---|
3308 | { |
---|
3309 | numBits++; |
---|
3310 | } |
---|
3311 | READ_CODE( numBits, uiCode, "output_layer_set_idx_minus1"); vps->setOutputLayerSetIdx( i, uiCode + 1); |
---|
3312 | Int lsIdx = vps->getOutputLayerSetIdx(i); |
---|
3313 | #if NUM_OL_FLAGS |
---|
3314 | for(j = 0; j < vps->getNumLayersInIdList(lsIdx) ; j++) |
---|
3315 | #else |
---|
3316 | for(j = 0; j < vps->getNumLayersInIdList(lsIdx) - 1; j++) |
---|
3317 | #endif |
---|
3318 | { |
---|
3319 | READ_FLAG( uiCode, "output_layer_flag[i][j]"); vps->setOutputLayerFlag(i, j, uiCode); |
---|
3320 | } |
---|
3321 | } |
---|
3322 | else |
---|
3323 | { |
---|
3324 | #if VPS_DPB_SIZE_TABLE |
---|
3325 | vps->setOutputLayerSetIdx( i, i ); |
---|
3326 | #endif |
---|
3327 | // i <= (vps->getNumLayerSets() - 1) |
---|
3328 | // Assign OutputLayerFlag depending on default_one_target_output_layer_flag |
---|
3329 | Int lsIdx = i; |
---|
3330 | #if O0109_DEFAULT_ONE_OUT_LAYER_IDC |
---|
3331 | if( vps->getDefaultOneTargetOutputLayerIdc() == 1 ) |
---|
3332 | { |
---|
3333 | for(j = 0; j < vps->getNumLayersInIdList(lsIdx); j++) |
---|
3334 | { |
---|
3335 | #if O0135_DEFAULT_ONE_OUT_SEMANTIC |
---|
3336 | #if DEF_OPT_LAYER_IDC |
---|
3337 | vps->setOutputLayerFlag(i, j, (j == (vps->getNumLayersInIdList(lsIdx)-1)) ); |
---|
3338 | #else |
---|
3339 | vps->setOutputLayerFlag(i, j, (j == (vps->getNumLayersInIdList(lsIdx)-1)) && (vps->getDimensionId(j,1)==0) ); |
---|
3340 | #endif |
---|
3341 | #else |
---|
3342 | vps->setOutputLayerFlag(i, j, (j == (vps->getNumLayersInIdList(lsIdx)-1))); |
---|
3343 | #endif |
---|
3344 | } |
---|
3345 | } |
---|
3346 | else if ( vps->getDefaultOneTargetOutputLayerIdc() == 0 ) |
---|
3347 | { |
---|
3348 | for(j = 0; j < vps->getNumLayersInIdList(lsIdx); j++) |
---|
3349 | { |
---|
3350 | vps->setOutputLayerFlag(i, j, 1); |
---|
3351 | } |
---|
3352 | } |
---|
3353 | else |
---|
3354 | { |
---|
3355 | // Other values of default_one_target_output_layer_idc than 0 and 1 are reserved for future use. |
---|
3356 | } |
---|
3357 | #else |
---|
3358 | if( vps->getDefaultOneTargetOutputLayerFlag() ) |
---|
3359 | { |
---|
3360 | for(j = 0; j < vps->getNumLayersInIdList(lsIdx); j++) |
---|
3361 | { |
---|
3362 | vps->setOutputLayerFlag(i, j, (j == (vps->getNumLayersInIdList(lsIdx)-1))); |
---|
3363 | } |
---|
3364 | } |
---|
3365 | else |
---|
3366 | { |
---|
3367 | for(j = 0; j < vps->getNumLayersInIdList(lsIdx); j++) |
---|
3368 | { |
---|
3369 | vps->setOutputLayerFlag(i, j, 1); |
---|
3370 | } |
---|
3371 | } |
---|
3372 | #endif |
---|
3373 | } |
---|
3374 | Int numBits = 1; |
---|
3375 | while ((1 << numBits) < (vps->getNumProfileTierLevel())) |
---|
3376 | { |
---|
3377 | numBits++; |
---|
3378 | } |
---|
3379 | READ_CODE( numBits, uiCode, "profile_level_tier_idx[i]" ); vps->setProfileLevelTierIdx(i, uiCode); |
---|
3380 | } |
---|
3381 | #endif |
---|
3382 | |
---|
3383 | #if !P0300_ALT_OUTPUT_LAYER_FLAG |
---|
3384 | #if O0153_ALT_OUTPUT_LAYER_FLAG |
---|
3385 | if( vps->getMaxLayers() > 1 ) |
---|
3386 | { |
---|
3387 | READ_FLAG( uiCode, "alt_output_layer_flag"); |
---|
3388 | vps->setAltOuputLayerFlag( uiCode ? true : false ); |
---|
3389 | } |
---|
3390 | #endif |
---|
3391 | #endif |
---|
3392 | |
---|
3393 | #if REPN_FORMAT_IN_VPS |
---|
3394 | #if Q0195_REP_FORMAT_CLEANUP |
---|
3395 | READ_UVLC( uiCode, "vps_num_rep_formats_minus1" ); |
---|
3396 | vps->setVpsNumRepFormats( uiCode + 1 ); |
---|
3397 | |
---|
3398 | // The value of vps_num_rep_formats_minus1 shall be in the range of 0 to 255, inclusive. |
---|
3399 | assert( vps->getVpsNumRepFormats() > 0 && vps->getVpsNumRepFormats() <= 256 ); |
---|
3400 | |
---|
3401 | for(i = 0; i < vps->getVpsNumRepFormats(); i++) |
---|
3402 | { |
---|
3403 | // Read rep_format_structures |
---|
3404 | parseRepFormat( vps->getVpsRepFormat(i), i > 0 ? vps->getVpsRepFormat(i-1) : 0 ); |
---|
3405 | } |
---|
3406 | |
---|
3407 | // Default assignment for layer 0 |
---|
3408 | vps->setVpsRepFormatIdx( 0, 0 ); |
---|
3409 | |
---|
3410 | if( vps->getVpsNumRepFormats() > 1 ) |
---|
3411 | { |
---|
3412 | READ_FLAG( uiCode, "rep_format_idx_present_flag"); |
---|
3413 | vps->setRepFormatIdxPresentFlag( uiCode ? true : false ); |
---|
3414 | } |
---|
3415 | else |
---|
3416 | { |
---|
3417 | // When not present, the value of rep_format_idx_present_flag is inferred to be equal to 0 |
---|
3418 | vps->setRepFormatIdxPresentFlag( false ); |
---|
3419 | } |
---|
3420 | |
---|
3421 | if( vps->getRepFormatIdxPresentFlag() ) |
---|
3422 | { |
---|
3423 | #if VPS_FIX_TO_MATCH_SPEC |
---|
3424 | for( i = vps->getBaseLayerInternalFlag() ? 1 : 0; i < vps->getMaxLayers(); i++ ) |
---|
3425 | #else |
---|
3426 | for (i = 1; i < vps->getMaxLayers(); i++) |
---|
3427 | #endif |
---|
3428 | { |
---|
3429 | Int numBits = 1; |
---|
3430 | while ((1 << numBits) < (vps->getVpsNumRepFormats())) |
---|
3431 | { |
---|
3432 | numBits++; |
---|
3433 | } |
---|
3434 | READ_CODE( numBits, uiCode, "vps_rep_format_idx[i]" ); |
---|
3435 | vps->setVpsRepFormatIdx( i, uiCode ); |
---|
3436 | } |
---|
3437 | } |
---|
3438 | else |
---|
3439 | { |
---|
3440 | // When not present, the value of vps_rep_format_idx[ i ] is inferred to be equal to Min (i, vps_num_rep_formats_minus1) |
---|
3441 | for(i = 1; i < vps->getMaxLayers(); i++) |
---|
3442 | { |
---|
3443 | vps->setVpsRepFormatIdx( i, min( (Int)i, vps->getVpsNumRepFormats()-1 ) ); |
---|
3444 | } |
---|
3445 | } |
---|
3446 | #else |
---|
3447 | READ_FLAG( uiCode, "rep_format_idx_present_flag"); |
---|
3448 | vps->setRepFormatIdxPresentFlag( uiCode ? true : false ); |
---|
3449 | |
---|
3450 | if( vps->getRepFormatIdxPresentFlag() ) |
---|
3451 | { |
---|
3452 | #if O0096_REP_FORMAT_INDEX |
---|
3453 | #if !VPS_EXTN_UEV_CODING |
---|
3454 | READ_CODE( 8, uiCode, "vps_num_rep_formats_minus1" ); |
---|
3455 | #else |
---|
3456 | READ_UVLC( uiCode, "vps_num_rep_formats_minus1" ); |
---|
3457 | #endif |
---|
3458 | #else |
---|
3459 | READ_CODE( 4, uiCode, "vps_num_rep_formats_minus1" ); |
---|
3460 | #endif |
---|
3461 | vps->setVpsNumRepFormats( uiCode + 1 ); |
---|
3462 | } |
---|
3463 | else |
---|
3464 | { |
---|
3465 | // default assignment |
---|
3466 | assert (vps->getMaxLayers() <= 16); // If max_layers_is more than 15, num_rep_formats has to be signaled |
---|
3467 | vps->setVpsNumRepFormats( vps->getMaxLayers() ); |
---|
3468 | } |
---|
3469 | |
---|
3470 | // The value of vps_num_rep_formats_minus1 shall be in the range of 0 to 255, inclusive. |
---|
3471 | assert( vps->getVpsNumRepFormats() > 0 && vps->getVpsNumRepFormats() <= 256 ); |
---|
3472 | |
---|
3473 | for(i = 0; i < vps->getVpsNumRepFormats(); i++) |
---|
3474 | { |
---|
3475 | // Read rep_format_structures |
---|
3476 | parseRepFormat( vps->getVpsRepFormat(i), i > 0 ? vps->getVpsRepFormat(i-1) : 0 ); |
---|
3477 | } |
---|
3478 | |
---|
3479 | // Default assignment for layer 0 |
---|
3480 | vps->setVpsRepFormatIdx( 0, 0 ); |
---|
3481 | if( vps->getRepFormatIdxPresentFlag() ) |
---|
3482 | { |
---|
3483 | for(i = 1; i < vps->getMaxLayers(); i++) |
---|
3484 | { |
---|
3485 | if( vps->getVpsNumRepFormats() > 1 ) |
---|
3486 | { |
---|
3487 | #if O0096_REP_FORMAT_INDEX |
---|
3488 | #if !VPS_EXTN_UEV_CODING |
---|
3489 | READ_CODE( 8, uiCode, "vps_rep_format_idx[i]" ); |
---|
3490 | #else |
---|
3491 | Int numBits = 1; |
---|
3492 | while ((1 << numBits) < (vps->getVpsNumRepFormats())) |
---|
3493 | { |
---|
3494 | numBits++; |
---|
3495 | } |
---|
3496 | READ_CODE( numBits, uiCode, "vps_rep_format_idx[i]" ); |
---|
3497 | #endif |
---|
3498 | #else |
---|
3499 | READ_CODE( 4, uiCode, "vps_rep_format_idx[i]" ); |
---|
3500 | #endif |
---|
3501 | vps->setVpsRepFormatIdx( i, uiCode ); |
---|
3502 | } |
---|
3503 | else |
---|
3504 | { |
---|
3505 | // default assignment - only one rep_format() structure |
---|
3506 | vps->setVpsRepFormatIdx( i, 0 ); |
---|
3507 | } |
---|
3508 | } |
---|
3509 | } |
---|
3510 | else |
---|
3511 | { |
---|
3512 | // default assignment - each layer assigned each rep_format() structure in the order signaled |
---|
3513 | for(i = 1; i < vps->getMaxLayers(); i++) |
---|
3514 | { |
---|
3515 | vps->setVpsRepFormatIdx( i, i ); |
---|
3516 | } |
---|
3517 | } |
---|
3518 | #endif |
---|
3519 | #endif |
---|
3520 | #if RESOLUTION_BASED_DPB |
---|
3521 | vps->assignSubDpbIndices(); |
---|
3522 | #endif |
---|
3523 | READ_FLAG(uiCode, "max_one_active_ref_layer_flag" ); |
---|
3524 | vps->setMaxOneActiveRefLayerFlag(uiCode); |
---|
3525 | #if P0297_VPS_POC_LSB_ALIGNED_FLAG |
---|
3526 | READ_FLAG(uiCode, "vps_poc_lsb_aligned_flag"); |
---|
3527 | vps->setVpsPocLsbAlignedFlag(uiCode); |
---|
3528 | #endif |
---|
3529 | #if O0062_POC_LSB_NOT_PRESENT_FLAG |
---|
3530 | for(i = 1; i< vps->getMaxLayers(); i++) |
---|
3531 | { |
---|
3532 | if( vps->getNumDirectRefLayers( vps->getLayerIdInNuh(i) ) == 0 ) |
---|
3533 | { |
---|
3534 | READ_FLAG(uiCode, "poc_lsb_not_present_flag[i]"); |
---|
3535 | vps->setPocLsbNotPresentFlag(i, uiCode); |
---|
3536 | } |
---|
3537 | } |
---|
3538 | #endif |
---|
3539 | #if O0215_PHASE_ALIGNMENT |
---|
3540 | READ_FLAG( uiCode, "cross_layer_phase_alignment_flag"); vps->setPhaseAlignFlag( uiCode == 1 ? true : false ); |
---|
3541 | #endif |
---|
3542 | |
---|
3543 | #if !IRAP_ALIGN_FLAG_IN_VPS_VUI |
---|
3544 | READ_FLAG(uiCode, "cross_layer_irap_aligned_flag" ); |
---|
3545 | vps->setCrossLayerIrapAlignFlag(uiCode); |
---|
3546 | #endif |
---|
3547 | |
---|
3548 | #if VPS_DPB_SIZE_TABLE |
---|
3549 | parseVpsDpbSizeTable(vps); |
---|
3550 | #endif |
---|
3551 | |
---|
3552 | #if VPS_EXTN_DIRECT_REF_LAYERS |
---|
3553 | READ_UVLC( uiCode, "direct_dep_type_len_minus2"); vps->setDirectDepTypeLen(uiCode+2); |
---|
3554 | #if O0096_DEFAULT_DEPENDENCY_TYPE |
---|
3555 | READ_FLAG(uiCode, "default_direct_dependency_type_flag"); |
---|
3556 | vps->setDefaultDirectDependecyTypeFlag(uiCode == 1? true : false); |
---|
3557 | if (vps->getDefaultDirectDependencyTypeFlag()) |
---|
3558 | { |
---|
3559 | READ_CODE( vps->getDirectDepTypeLen(), uiCode, "default_direct_dependency_type" ); |
---|
3560 | vps->setDefaultDirectDependecyType(uiCode); |
---|
3561 | } |
---|
3562 | #endif |
---|
3563 | |
---|
3564 | #if VPS_FIX_TO_MATCH_SPEC |
---|
3565 | for( i = vps->getBaseLayerInternalFlag() ? 1 : 2; i < vps->getMaxLayers(); i++ ) |
---|
3566 | #else |
---|
3567 | for(i = 1; i < vps->getMaxLayers(); i++) |
---|
3568 | #endif |
---|
3569 | { |
---|
3570 | #if VPS_FIX_TO_MATCH_SPEC |
---|
3571 | for( j = vps->getBaseLayerInternalFlag() ? 0 : 1; j < i; j++ ) |
---|
3572 | #else |
---|
3573 | for(j = 0; j < i; j++) |
---|
3574 | #endif |
---|
3575 | { |
---|
3576 | if (vps->getDirectDependencyFlag(i, j)) |
---|
3577 | { |
---|
3578 | #if O0096_DEFAULT_DEPENDENCY_TYPE |
---|
3579 | if (vps->getDefaultDirectDependencyTypeFlag()) |
---|
3580 | { |
---|
3581 | vps->setDirectDependencyType(i, j, vps->getDefaultDirectDependencyType()); |
---|
3582 | } |
---|
3583 | else |
---|
3584 | { |
---|
3585 | READ_CODE( vps->getDirectDepTypeLen(), uiCode, "direct_dependency_type[i][j]" ); |
---|
3586 | vps->setDirectDependencyType(i, j, uiCode); |
---|
3587 | } |
---|
3588 | #else |
---|
3589 | READ_CODE( vps->getDirectDepTypeLen(), uiCode, "direct_dependency_type[i][j]" ); |
---|
3590 | vps->setDirectDependencyType(i, j, uiCode); |
---|
3591 | #endif |
---|
3592 | } |
---|
3593 | } |
---|
3594 | } |
---|
3595 | #endif |
---|
3596 | #if !Q0078_ADD_LAYER_SETS |
---|
3597 | #if O0092_0094_DEPENDENCY_CONSTRAINT // Moved up |
---|
3598 | vps->setNumRefLayers(); |
---|
3599 | |
---|
3600 | if(vps->getMaxLayers() > MAX_REF_LAYERS) |
---|
3601 | { |
---|
3602 | for(i = 1;i < vps->getMaxLayers(); i++) |
---|
3603 | { |
---|
3604 | assert( vps->getNumRefLayers(vps->getLayerIdInNuh(i)) <= MAX_REF_LAYERS); |
---|
3605 | } |
---|
3606 | } |
---|
3607 | #endif |
---|
3608 | #endif |
---|
3609 | |
---|
3610 | #if P0307_VPS_NON_VUI_EXTENSION |
---|
3611 | READ_UVLC( uiCode, "vps_non_vui_extension_length"); vps->setVpsNonVuiExtLength((Int)uiCode); |
---|
3612 | |
---|
3613 | // The value of vps_non_vui_extension_length shall be in the range of 0 to 4096, inclusive. |
---|
3614 | assert( vps->getVpsNonVuiExtLength() >= 0 && vps->getVpsNonVuiExtLength() <= 4096 ); |
---|
3615 | |
---|
3616 | #if P0307_VPS_NON_VUI_EXT_UPDATE |
---|
3617 | Int nonVuiExtByte = uiCode; |
---|
3618 | for (i = 1; i <= nonVuiExtByte; i++) |
---|
3619 | { |
---|
3620 | READ_CODE( 8, uiCode, "vps_non_vui_extension_data_byte" ); //just parse and discard for now. |
---|
3621 | } |
---|
3622 | #else |
---|
3623 | if ( vps->getVpsNonVuiExtLength() > 0 ) |
---|
3624 | { |
---|
3625 | printf("\n\nUp to the current spec, the value of vps_non_vui_extension_length is supposed to be 0\n"); |
---|
3626 | } |
---|
3627 | #endif |
---|
3628 | #endif |
---|
3629 | |
---|
3630 | #if !O0109_O0199_FLAGS_TO_VUI |
---|
3631 | #if M0040_ADAPTIVE_RESOLUTION_CHANGE |
---|
3632 | READ_FLAG(uiCode, "single_layer_for_non_irap_flag" ); vps->setSingleLayerForNonIrapFlag(uiCode == 1 ? true : false); |
---|
3633 | #endif |
---|
3634 | #if HIGHER_LAYER_IRAP_SKIP_FLAG |
---|
3635 | READ_FLAG(uiCode, "higher_layer_irap_skip_flag" ); vps->setHigherLayerIrapSkipFlag(uiCode == 1 ? true : false); |
---|
3636 | #endif |
---|
3637 | #endif |
---|
3638 | |
---|
3639 | #if P0307_REMOVE_VPS_VUI_OFFSET |
---|
3640 | READ_FLAG( uiCode, "vps_vui_present_flag"); vps->setVpsVuiPresentFlag(uiCode ? true : false); |
---|
3641 | #endif |
---|
3642 | |
---|
3643 | #if O0109_MOVE_VPS_VUI_FLAG |
---|
3644 | if ( vps->getVpsVuiPresentFlag() ) |
---|
3645 | #else |
---|
3646 | READ_FLAG( uiCode, "vps_vui_present_flag" ); |
---|
3647 | if (uiCode) |
---|
3648 | #endif |
---|
3649 | { |
---|
3650 | while ( m_pcBitstream->getNumBitsRead() % 8 != 0 ) |
---|
3651 | { |
---|
3652 | READ_FLAG( uiCode, "vps_vui_alignment_bit_equal_to_one"); assert(uiCode == 1); |
---|
3653 | } |
---|
3654 | parseVPSVUI(vps); |
---|
3655 | } |
---|
3656 | else |
---|
3657 | { |
---|
3658 | // set default values for VPS VUI |
---|
3659 | defaultVPSVUI( vps ); |
---|
3660 | } |
---|
3661 | } |
---|
3662 | |
---|
3663 | Void TDecCavlc::defaultVPSExtension( TComVPS* vps ) |
---|
3664 | { |
---|
3665 | // set default parameters when they are not present |
---|
3666 | Int i, j; |
---|
3667 | |
---|
3668 | // When layer_id_in_nuh[ i ] is not present, the value is inferred to be equal to i. |
---|
3669 | for(i = 0; i < vps->getMaxLayers(); i++) |
---|
3670 | { |
---|
3671 | vps->setLayerIdInNuh(i, i); |
---|
3672 | vps->setLayerIdxInVps(vps->getLayerIdInNuh(i), i); |
---|
3673 | } |
---|
3674 | |
---|
3675 | // When not present, sub_layers_vps_max_minus1[ i ] is inferred to be equal to vps_max_sub_layers_minus1. |
---|
3676 | for( i = 0; i < vps->getMaxLayers(); i++) |
---|
3677 | { |
---|
3678 | vps->setMaxTSLayersMinus1(i, vps->getMaxTLayers()-1); |
---|
3679 | } |
---|
3680 | |
---|
3681 | // When not present, max_tid_il_ref_pics_plus1[ i ][ j ] is inferred to be equal to 7. |
---|
3682 | for( i = 0; i < vps->getMaxLayers() - 1; i++ ) |
---|
3683 | { |
---|
3684 | #if O0225_MAX_TID_FOR_REF_LAYERS |
---|
3685 | for( j = i + 1; j < vps->getMaxLayers(); j++ ) |
---|
3686 | { |
---|
3687 | vps->setMaxTidIlRefPicsPlus1(i, j, 7); |
---|
3688 | } |
---|
3689 | #else |
---|
3690 | vps->setMaxTidIlRefPicsPlus1(i, 7); |
---|
3691 | #endif |
---|
3692 | } |
---|
3693 | |
---|
3694 | // When not present, the value of num_add_olss is inferred to be equal to 0. |
---|
3695 | // NumOutputLayerSets = num_add_olss + NumLayerSets |
---|
3696 | vps->setNumOutputLayerSets( vps->getNumLayerSets() ); |
---|
3697 | |
---|
3698 | // For i in the range of 0 to NumOutputLayerSets-1, inclusive, the variable LayerSetIdxForOutputLayerSet[ i ] is derived as specified in the following: |
---|
3699 | // LayerSetIdxForOutputLayerSet[ i ] = ( i <= vps_number_layer_sets_minus1 ) ? i : layer_set_idx_for_ols_minus1[ i ] + 1 |
---|
3700 | for( i = 1; i < vps->getNumOutputLayerSets(); i++ ) |
---|
3701 | { |
---|
3702 | vps->setOutputLayerSetIdx( i, i ); |
---|
3703 | Int lsIdx = vps->getOutputLayerSetIdx(i); |
---|
3704 | |
---|
3705 | for( j = 0; j < vps->getNumLayersInIdList(lsIdx); j++ ) |
---|
3706 | { |
---|
3707 | vps->setOutputLayerFlag(i, j, 1); |
---|
3708 | } |
---|
3709 | } |
---|
3710 | |
---|
3711 | // The value of sub_layer_dpb_info_present_flag[ i ][ 0 ] for any possible value of i is inferred to be equal to 1 |
---|
3712 | // 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. |
---|
3713 | for( i = 1; i < vps->getNumOutputLayerSets(); i++ ) |
---|
3714 | { |
---|
3715 | vps->setSubLayerDpbInfoPresentFlag( i, 0, true ); |
---|
3716 | } |
---|
3717 | |
---|
3718 | // When not present, the value of vps_num_rep_formats_minus1 is inferred to be equal to MaxLayersMinus1. |
---|
3719 | vps->setVpsNumRepFormats( vps->getMaxLayers() ); |
---|
3720 | |
---|
3721 | // When not present, the value of rep_format_idx_present_flag is inferred to be equal to 0 |
---|
3722 | vps->setRepFormatIdxPresentFlag( false ); |
---|
3723 | |
---|
3724 | if( !vps->getRepFormatIdxPresentFlag() ) |
---|
3725 | { |
---|
3726 | // When not present, the value of vps_rep_format_idx[ i ] is inferred to be equal to Min(i, vps_num_rep_formats_minus1). |
---|
3727 | for(i = 1; i < vps->getMaxLayers(); i++) |
---|
3728 | { |
---|
3729 | vps->setVpsRepFormatIdx( i, min( (Int)i, vps->getVpsNumRepFormats() - 1 ) ); |
---|
3730 | } |
---|
3731 | } |
---|
3732 | |
---|
3733 | #if P0297_VPS_POC_LSB_ALIGNED_FLAG |
---|
3734 | vps->setVpsPocLsbAlignedFlag(false); |
---|
3735 | #endif |
---|
3736 | |
---|
3737 | #if O0062_POC_LSB_NOT_PRESENT_FLAG |
---|
3738 | // When not present, poc_lsb_not_present_flag[ i ] is inferred to be equal to 0. |
---|
3739 | for(i = 1; i< vps->getMaxLayers(); i++) |
---|
3740 | { |
---|
3741 | vps->setPocLsbNotPresentFlag(i, 0); |
---|
3742 | } |
---|
3743 | #endif |
---|
3744 | |
---|
3745 | // set default values for VPS VUI |
---|
3746 | defaultVPSVUI( vps ); |
---|
3747 | } |
---|
3748 | |
---|
3749 | Void TDecCavlc::defaultVPSVUI( TComVPS* vps ) |
---|
3750 | { |
---|
3751 | // When not present, the value of all_layers_idr_aligned_flag is inferred to be equal to 0. |
---|
3752 | vps->setCrossLayerIrapAlignFlag( false ); |
---|
3753 | |
---|
3754 | #if M0040_ADAPTIVE_RESOLUTION_CHANGE |
---|
3755 | // When single_layer_for_non_irap_flag is not present, it is inferred to be equal to 0. |
---|
3756 | vps->setSingleLayerForNonIrapFlag( false ); |
---|
3757 | #endif |
---|
3758 | |
---|
3759 | #if HIGHER_LAYER_IRAP_SKIP_FLAG |
---|
3760 | // When higher_layer_irap_skip_flag is not present it is inferred to be equal to 0 |
---|
3761 | vps->setHigherLayerIrapSkipFlag( false ); |
---|
3762 | #endif |
---|
3763 | } |
---|
3764 | |
---|
3765 | #if REPN_FORMAT_IN_VPS |
---|
3766 | Void TDecCavlc::parseRepFormat( RepFormat *repFormat, RepFormat *repFormatPrev ) |
---|
3767 | { |
---|
3768 | UInt uiCode; |
---|
3769 | #if REPN_FORMAT_CONTROL_FLAG |
---|
3770 | READ_CODE( 16, uiCode, "pic_width_vps_in_luma_samples" ); repFormat->setPicWidthVpsInLumaSamples ( uiCode ); |
---|
3771 | READ_CODE( 16, uiCode, "pic_height_vps_in_luma_samples" ); repFormat->setPicHeightVpsInLumaSamples( uiCode ); |
---|
3772 | READ_FLAG( uiCode, "chroma_and_bit_depth_vps_present_flag" ); repFormat->setChromaAndBitDepthVpsPresentFlag( uiCode ? true : false ); |
---|
3773 | |
---|
3774 | if( !repFormatPrev ) |
---|
3775 | { |
---|
3776 | // 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 |
---|
3777 | assert( repFormat->getChromaAndBitDepthVpsPresentFlag() ); |
---|
3778 | } |
---|
3779 | |
---|
3780 | if( repFormat->getChromaAndBitDepthVpsPresentFlag() ) |
---|
3781 | { |
---|
3782 | READ_CODE( 2, uiCode, "chroma_format_vps_idc" ); |
---|
3783 | #if AUXILIARY_PICTURES |
---|
3784 | repFormat->setChromaFormatVpsIdc( ChromaFormat(uiCode) ); |
---|
3785 | #else |
---|
3786 | repFormat->setChromaFormatVpsIdc( uiCode ); |
---|
3787 | #endif |
---|
3788 | |
---|
3789 | if( repFormat->getChromaFormatVpsIdc() == 3 ) |
---|
3790 | { |
---|
3791 | READ_FLAG( uiCode, "separate_colour_plane_vps_flag" ); repFormat->setSeparateColourPlaneVpsFlag( uiCode ? true : false ); |
---|
3792 | } |
---|
3793 | |
---|
3794 | READ_CODE( 4, uiCode, "bit_depth_vps_luma_minus8" ); repFormat->setBitDepthVpsLuma ( uiCode + 8 ); |
---|
3795 | READ_CODE( 4, uiCode, "bit_depth_vps_chroma_minus8" ); repFormat->setBitDepthVpsChroma( uiCode + 8 ); |
---|
3796 | } |
---|
3797 | else if( repFormatPrev ) |
---|
3798 | { |
---|
3799 | // 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 |
---|
3800 | // bit_depth_vps_chroma_minus8 are not present and inferred from the previous rep_format( ) syntax structure in the VPS. |
---|
3801 | |
---|
3802 | repFormat->setChromaFormatVpsIdc ( repFormatPrev->getChromaFormatVpsIdc() ); |
---|
3803 | repFormat->setSeparateColourPlaneVpsFlag( repFormatPrev->getSeparateColourPlaneVpsFlag() ); |
---|
3804 | repFormat->setBitDepthVpsLuma ( repFormatPrev->getBitDepthVpsLuma() ); |
---|
3805 | repFormat->setBitDepthVpsChroma ( repFormatPrev->getBitDepthVpsChroma() ); |
---|
3806 | } |
---|
3807 | |
---|
3808 | #else |
---|
3809 | #if AUXILIARY_PICTURES |
---|
3810 | READ_CODE( 2, uiCode, "chroma_format_idc" ); repFormat->setChromaFormatVpsIdc( ChromaFormat(uiCode) ); |
---|
3811 | #else |
---|
3812 | READ_CODE( 2, uiCode, "chroma_format_idc" ); repFormat->setChromaFormatVpsIdc( uiCode ); |
---|
3813 | #endif |
---|
3814 | |
---|
3815 | if( repFormat->getChromaFormatVpsIdc() == 3 ) |
---|
3816 | { |
---|
3817 | READ_FLAG( uiCode, "separate_colour_plane_flag"); repFormat->setSeparateColourPlaneVpsFlag(uiCode ? true : false); |
---|
3818 | } |
---|
3819 | |
---|
3820 | READ_CODE ( 16, uiCode, "pic_width_in_luma_samples" ); repFormat->setPicWidthVpsInLumaSamples ( uiCode ); |
---|
3821 | READ_CODE ( 16, uiCode, "pic_height_in_luma_samples" ); repFormat->setPicHeightVpsInLumaSamples( uiCode ); |
---|
3822 | |
---|
3823 | READ_CODE( 4, uiCode, "bit_depth_luma_minus8" ); repFormat->setBitDepthVpsLuma ( uiCode + 8 ); |
---|
3824 | READ_CODE( 4, uiCode, "bit_depth_chroma_minus8" ); repFormat->setBitDepthVpsChroma( uiCode + 8 ); |
---|
3825 | #endif |
---|
3826 | |
---|
3827 | #if R0156_CONF_WINDOW_IN_REP_FORMAT |
---|
3828 | READ_FLAG( uiCode, "conformance_window_vps_flag" ); |
---|
3829 | if( uiCode != 0) |
---|
3830 | { |
---|
3831 | Window &conf = repFormat->getConformanceWindowVps(); |
---|
3832 | READ_UVLC( uiCode, "conf_win_vps_left_offset" ); conf.setWindowLeftOffset ( uiCode ); |
---|
3833 | READ_UVLC( uiCode, "conf_win_vps_right_offset" ); conf.setWindowRightOffset ( uiCode ); |
---|
3834 | READ_UVLC( uiCode, "conf_win_vps_top_offset" ); conf.setWindowTopOffset ( uiCode ); |
---|
3835 | READ_UVLC( uiCode, "conf_win_vps_bottom_offset" ); conf.setWindowBottomOffset( uiCode ); |
---|
3836 | } |
---|
3837 | #endif |
---|
3838 | } |
---|
3839 | #endif |
---|
3840 | #if VPS_DPB_SIZE_TABLE |
---|
3841 | Void TDecCavlc::parseVpsDpbSizeTable( TComVPS *vps ) |
---|
3842 | { |
---|
3843 | UInt uiCode; |
---|
3844 | #if SUB_LAYERS_IN_LAYER_SET |
---|
3845 | vps->calculateMaxSLInLayerSets(); |
---|
3846 | #else |
---|
3847 | #if DPB_PARAMS_MAXTLAYERS |
---|
3848 | #if BITRATE_PICRATE_SIGNALLING |
---|
3849 | Int * MaxSubLayersInLayerSetMinus1 = new Int[vps->getNumLayerSets()]; |
---|
3850 | for(Int i = 0; i < vps->getNumLayerSets(); i++) |
---|
3851 | #else |
---|
3852 | Int * MaxSubLayersInLayerSetMinus1 = new Int[vps->getNumOutputLayerSets()]; |
---|
3853 | for(Int i = 1; i < vps->getNumOutputLayerSets(); i++) |
---|
3854 | #endif |
---|
3855 | { |
---|
3856 | UInt maxSLMinus1 = 0; |
---|
3857 | #if CHANGE_NUMSUBDPB_IDX |
---|
3858 | Int optLsIdx = vps->getOutputLayerSetIdx( i ); |
---|
3859 | #else |
---|
3860 | Int optLsIdx = i; |
---|
3861 | #endif |
---|
3862 | #if BITRATE_PICRATE_SIGNALLING |
---|
3863 | optLsIdx = i; |
---|
3864 | #endif |
---|
3865 | for(Int k = 0; k < vps->getNumLayersInIdList(optLsIdx); k++ ) { |
---|
3866 | Int lId = vps->getLayerSetLayerIdList(optLsIdx, k); |
---|
3867 | maxSLMinus1 = max(maxSLMinus1, vps->getMaxTSLayersMinus1(vps->getLayerIdxInVps(lId))); |
---|
3868 | } |
---|
3869 | MaxSubLayersInLayerSetMinus1[ i ] = maxSLMinus1; |
---|
3870 | #if BITRATE_PICRATE_SIGNALLING |
---|
3871 | vps->setMaxSLayersInLayerSetMinus1(i,MaxSubLayersInLayerSetMinus1[ i ]); |
---|
3872 | #endif |
---|
3873 | } |
---|
3874 | #endif |
---|
3875 | #endif |
---|
3876 | |
---|
3877 | #if !RESOLUTION_BASED_DPB |
---|
3878 | vps->deriveNumberOfSubDpbs(); |
---|
3879 | #endif |
---|
3880 | for(Int i = 1; i < vps->getNumOutputLayerSets(); i++) |
---|
3881 | { |
---|
3882 | #if CHANGE_NUMSUBDPB_IDX |
---|
3883 | Int layerSetIdxForOutputLayerSet = vps->getOutputLayerSetIdx( i ); |
---|
3884 | #endif |
---|
3885 | READ_FLAG( uiCode, "sub_layer_flag_info_present_flag[i]"); vps->setSubLayerFlagInfoPresentFlag( i, uiCode ? true : false ); |
---|
3886 | #if SUB_LAYERS_IN_LAYER_SET |
---|
3887 | for(Int j = 0; j <= vps->getMaxSLayersInLayerSetMinus1( layerSetIdxForOutputLayerSet ); j++) |
---|
3888 | #else |
---|
3889 | #if DPB_PARAMS_MAXTLAYERS |
---|
3890 | #if BITRATE_PICRATE_SIGNALLING |
---|
3891 | for(Int j = 0; j <= MaxSubLayersInLayerSetMinus1[ vps->getOutputLayerSetIdx( i ) ]; j++) |
---|
3892 | #else |
---|
3893 | for(Int j = 0; j <= MaxSubLayersInLayerSetMinus1[ i ]; j++) |
---|
3894 | #endif |
---|
3895 | #else |
---|
3896 | for(Int j = 0; j <= vps->getMaxTLayers(); j++) |
---|
3897 | #endif |
---|
3898 | #endif |
---|
3899 | { |
---|
3900 | if( j > 0 && vps->getSubLayerFlagInfoPresentFlag(i) ) |
---|
3901 | { |
---|
3902 | READ_FLAG( uiCode, "sub_layer_dpb_info_present_flag[i]"); vps->setSubLayerDpbInfoPresentFlag( i, j, uiCode ? true : false); |
---|
3903 | } |
---|
3904 | else |
---|
3905 | { |
---|
3906 | if( j == 0 ) // Always signal for the first sub-layer |
---|
3907 | { |
---|
3908 | vps->setSubLayerDpbInfoPresentFlag( i, j, true ); |
---|
3909 | } |
---|
3910 | else // if (j != 0) && !vps->getSubLayerFlagInfoPresentFlag(i) |
---|
3911 | { |
---|
3912 | vps->setSubLayerDpbInfoPresentFlag( i, j, false ); |
---|
3913 | } |
---|
3914 | } |
---|
3915 | if( vps->getSubLayerDpbInfoPresentFlag(i, j) ) // If sub-layer DPB information is present |
---|
3916 | { |
---|
3917 | #if CHANGE_NUMSUBDPB_IDX |
---|
3918 | for(Int k = 0; k < vps->getNumSubDpbs(layerSetIdxForOutputLayerSet); k++) |
---|
3919 | #else |
---|
3920 | for(Int k = 0; k < vps->getNumSubDpbs(i); k++) |
---|
3921 | #endif |
---|
3922 | { |
---|
3923 | #if DPB_INTERNAL_BL_SIG |
---|
3924 | uiCode=0; |
---|
3925 | |
---|
3926 | #if VPS_FIX_TO_MATCH_SPEC |
---|
3927 | if( vps->getNecessaryLayerFlag(i, k) && ( vps->getBaseLayerInternalFlag() || vps->getLayerSetLayerIdList(layerSetIdxForOutputLayerSet, k) ) ) |
---|
3928 | #else |
---|
3929 | if(vps->getBaseLayerInternalFlag() || ( vps->getLayerSetLayerIdList(layerSetIdxForOutputLayerSet, k) != 0 ) ) |
---|
3930 | #endif |
---|
3931 | #endif |
---|
3932 | READ_UVLC( uiCode, "max_vps_dec_pic_buffering_minus1[i][k][j]" ); vps->setMaxVpsDecPicBufferingMinus1( i, k, j, uiCode ); |
---|
3933 | } |
---|
3934 | READ_UVLC( uiCode, "max_vps_num_reorder_pics[i][j]" ); vps->setMaxVpsNumReorderPics( i, j, uiCode); |
---|
3935 | #if RESOLUTION_BASED_DPB |
---|
3936 | if( vps->getNumSubDpbs(layerSetIdxForOutputLayerSet) != vps->getNumLayersInIdList( layerSetIdxForOutputLayerSet ) ) |
---|
3937 | { |
---|
3938 | for(Int k = 0; k < vps->getNumLayersInIdList( layerSetIdxForOutputLayerSet ); k++) |
---|
3939 | { |
---|
3940 | READ_UVLC( uiCode, "max_vps_layer_dec_pic_buff_minus1[i][k][j]" ); vps->setMaxVpsLayerDecPicBuffMinus1( i, k, j, uiCode); |
---|
3941 | } |
---|
3942 | } |
---|
3943 | else // vps->getNumSubDpbs(layerSetIdxForOutputLayerSet) == vps->getNumLayersInIdList( layerSetIdxForOutputLayerSet ) |
---|
3944 | { |
---|
3945 | for(Int k = 0; k < vps->getNumLayersInIdList( layerSetIdxForOutputLayerSet ); k++) |
---|
3946 | { |
---|
3947 | vps->setMaxVpsLayerDecPicBuffMinus1( i, k, j, vps->getMaxVpsDecPicBufferingMinus1( i, k, j)); |
---|
3948 | } |
---|
3949 | } |
---|
3950 | #endif |
---|
3951 | READ_UVLC( uiCode, "max_vps_latency_increase_plus1[i][j]" ); vps->setMaxVpsLatencyIncreasePlus1( i, j, uiCode); |
---|
3952 | } |
---|
3953 | } |
---|
3954 | for(Int j = vps->getMaxTLayers(); j < MAX_TLAYER; j++) |
---|
3955 | { |
---|
3956 | vps->setSubLayerDpbInfoPresentFlag( i, j, false ); |
---|
3957 | } |
---|
3958 | } |
---|
3959 | |
---|
3960 | #if !SUB_LAYERS_IN_LAYER_SET |
---|
3961 | #if BITRATE_PICRATE_SIGNALLING |
---|
3962 | if( MaxSubLayersInLayerSetMinus1 ) |
---|
3963 | { |
---|
3964 | delete [] MaxSubLayersInLayerSetMinus1; |
---|
3965 | } |
---|
3966 | #endif |
---|
3967 | #endif |
---|
3968 | |
---|
3969 | // Infer values when not signalled |
---|
3970 | for(Int i = 1; i < vps->getNumOutputLayerSets(); i++) |
---|
3971 | { |
---|
3972 | Int layerSetIdxForOutputLayerSet = vps->getOutputLayerSetIdx( i ); |
---|
3973 | for(Int j = 0; j < MAX_TLAYER; j++) |
---|
3974 | { |
---|
3975 | if( !vps->getSubLayerDpbInfoPresentFlag(i, j) ) // If sub-layer DPB information is NOT present |
---|
3976 | { |
---|
3977 | #if RESOLUTION_BASED_DPB |
---|
3978 | for(Int k = 0; k < vps->getNumSubDpbs(layerSetIdxForOutputLayerSet); k++) |
---|
3979 | #else |
---|
3980 | for(Int k = 0; k < vps->getNumLayersInIdList( layerSetIdxForOutputLayerSet ); k++) |
---|
3981 | #endif |
---|
3982 | { |
---|
3983 | vps->setMaxVpsDecPicBufferingMinus1( i, k, j, vps->getMaxVpsDecPicBufferingMinus1( i, k, j - 1 ) ); |
---|
3984 | } |
---|
3985 | vps->setMaxVpsNumReorderPics( i, j, vps->getMaxVpsNumReorderPics( i, j - 1) ); |
---|
3986 | #if RESOLUTION_BASED_DPB |
---|
3987 | for(Int k = 0; k < vps->getNumLayersInIdList( layerSetIdxForOutputLayerSet ); k++) |
---|
3988 | { |
---|
3989 | vps->setMaxVpsLayerDecPicBuffMinus1( i, k, j, vps->getMaxVpsLayerDecPicBuffMinus1( i, k, j - 1)); |
---|
3990 | } |
---|
3991 | #endif |
---|
3992 | vps->setMaxVpsLatencyIncreasePlus1( i, j, vps->getMaxVpsLatencyIncreasePlus1( i, j - 1 ) ); |
---|
3993 | } |
---|
3994 | } |
---|
3995 | } |
---|
3996 | } |
---|
3997 | #endif |
---|
3998 | |
---|
3999 | Void TDecCavlc::parseVPSVUI(TComVPS *vps) |
---|
4000 | { |
---|
4001 | UInt i,j; |
---|
4002 | UInt uiCode; |
---|
4003 | #if O0223_PICTURE_TYPES_ALIGN_FLAG |
---|
4004 | READ_FLAG(uiCode, "cross_layer_pic_type_aligned_flag" ); |
---|
4005 | vps->setCrossLayerPictureTypeAlignFlag(uiCode); |
---|
4006 | if (!uiCode) |
---|
4007 | { |
---|
4008 | #endif |
---|
4009 | #if IRAP_ALIGN_FLAG_IN_VPS_VUI |
---|
4010 | READ_FLAG(uiCode, "cross_layer_irap_aligned_flag" ); |
---|
4011 | vps->setCrossLayerIrapAlignFlag(uiCode); |
---|
4012 | #endif |
---|
4013 | #if O0223_PICTURE_TYPES_ALIGN_FLAG |
---|
4014 | } |
---|
4015 | else |
---|
4016 | { |
---|
4017 | vps->setCrossLayerIrapAlignFlag(true); |
---|
4018 | } |
---|
4019 | #endif |
---|
4020 | #if P0068_CROSS_LAYER_ALIGNED_IDR_ONLY_FOR_IRAP_FLAG |
---|
4021 | if( uiCode ) |
---|
4022 | { |
---|
4023 | READ_FLAG( uiCode, "all_layers_idr_aligned_flag" ); |
---|
4024 | vps->setCrossLayerAlignedIdrOnlyFlag(uiCode); |
---|
4025 | } |
---|
4026 | #endif |
---|
4027 | |
---|
4028 | READ_FLAG( uiCode, "bit_rate_present_vps_flag" ); vps->setBitRatePresentVpsFlag( uiCode ? true : false ); |
---|
4029 | READ_FLAG( uiCode, "pic_rate_present_vps_flag" ); vps->setPicRatePresentVpsFlag( uiCode ? true : false ); |
---|
4030 | |
---|
4031 | #if SIGNALLING_BITRATE_PICRATE_FIX |
---|
4032 | if ( vps->getBitRatePresentVpsFlag() || vps->getPicRatePresentVpsFlag() ) |
---|
4033 | { |
---|
4034 | for( i = vps->getBaseLayerInternalFlag() ? 0 : 1; i < vps->getNumLayerSets(); i++ ) |
---|
4035 | { |
---|
4036 | for( j = 0; j <= vps->getMaxSLayersInLayerSetMinus1( i ); j++ ) |
---|
4037 | { |
---|
4038 | if( vps->getBitRatePresentVpsFlag() ) |
---|
4039 | { |
---|
4040 | READ_FLAG( uiCode, "bit_rate_present_flag[i][j]" ); vps->setBitRatePresentFlag( i, j, uiCode ? true : false ); |
---|
4041 | } |
---|
4042 | if( vps->getPicRatePresentVpsFlag( ) ) |
---|
4043 | { |
---|
4044 | READ_FLAG( uiCode, "pic_rate_present_flag[i][j]" ); vps->setPicRatePresentFlag( i, j, uiCode ? true : false ); |
---|
4045 | } |
---|
4046 | if( vps->getBitRatePresentFlag( i, j ) ) |
---|
4047 | { |
---|
4048 | READ_CODE( 16, uiCode, "avg_bit_rate" ); vps->setAvgBitRate( i, j, uiCode ); |
---|
4049 | READ_CODE( 16, uiCode, "max_bit_rate" ); vps->setMaxBitRate( i, j, uiCode ); |
---|
4050 | } |
---|
4051 | else |
---|
4052 | { |
---|
4053 | vps->setAvgBitRate( i, j, 0 ); |
---|
4054 | vps->setMaxBitRate( i, j, 0 ); |
---|
4055 | } |
---|
4056 | if( vps->getPicRatePresentFlag( i, j ) ) |
---|
4057 | { |
---|
4058 | READ_CODE( 2, uiCode, "constant_pic_rate_idc" ); vps->setConstPicRateIdc( i, j, uiCode ); |
---|
4059 | READ_CODE( 16, uiCode, "avg_pic_rate" ); vps->setAvgPicRate( i, j, uiCode ); |
---|
4060 | } |
---|
4061 | else |
---|
4062 | { |
---|
4063 | vps->setConstPicRateIdc( i, j, 0 ); |
---|
4064 | vps->setAvgPicRate( i, j, 0 ); |
---|
4065 | } |
---|
4066 | } |
---|
4067 | } |
---|
4068 | } |
---|
4069 | #else |
---|
4070 | Bool parseFlag = vps->getBitRatePresentVpsFlag() || vps->getPicRatePresentVpsFlag(); |
---|
4071 | |
---|
4072 | #if Q0078_ADD_LAYER_SETS |
---|
4073 | #if R0227_BR_PR_ADD_LAYER_SET |
---|
4074 | for( i = 0; i < vps->getNumLayerSets(); i++ ) |
---|
4075 | #else |
---|
4076 | for( i = 0; i <= vps->getVpsNumLayerSetsMinus1(); i++ ) |
---|
4077 | #endif |
---|
4078 | #else |
---|
4079 | for( i = 0; i < vps->getNumLayerSets(); i++ ) |
---|
4080 | #endif |
---|
4081 | { |
---|
4082 | #if BITRATE_PICRATE_SIGNALLING |
---|
4083 | for( j = 0; j <= vps->getMaxSLayersInLayerSetMinus1(i); j++ ) |
---|
4084 | #else |
---|
4085 | for( j = 0; j < vps->getMaxTLayers(); j++ ) |
---|
4086 | #endif |
---|
4087 | { |
---|
4088 | if( parseFlag && vps->getBitRatePresentVpsFlag() ) |
---|
4089 | { |
---|
4090 | READ_FLAG( uiCode, "bit_rate_present_flag[i][j]" ); vps->setBitRatePresentFlag( i, j, uiCode ? true : false ); |
---|
4091 | } |
---|
4092 | else |
---|
4093 | { |
---|
4094 | vps->setBitRatePresentFlag( i, j, false ); |
---|
4095 | } |
---|
4096 | if( parseFlag && vps->getPicRatePresentVpsFlag() ) |
---|
4097 | { |
---|
4098 | READ_FLAG( uiCode, "pic_rate_present_flag[i][j]" ); vps->setPicRatePresentFlag( i, j, uiCode ? true : false ); |
---|
4099 | } |
---|
4100 | else |
---|
4101 | { |
---|
4102 | vps->setPicRatePresentFlag( i, j, false ); |
---|
4103 | } |
---|
4104 | if( parseFlag && vps->getBitRatePresentFlag(i, j) ) |
---|
4105 | { |
---|
4106 | READ_CODE( 16, uiCode, "avg_bit_rate[i][j]" ); vps->setAvgBitRate( i, j, uiCode ); |
---|
4107 | READ_CODE( 16, uiCode, "max_bit_rate[i][j]" ); vps->setMaxBitRate( i, j, uiCode ); |
---|
4108 | } |
---|
4109 | else |
---|
4110 | { |
---|
4111 | vps->setAvgBitRate( i, j, 0 ); |
---|
4112 | vps->setMaxBitRate( i, j, 0 ); |
---|
4113 | } |
---|
4114 | if( parseFlag && vps->getPicRatePresentFlag(i, j) ) |
---|
4115 | { |
---|
4116 | READ_CODE( 2 , uiCode, "constant_pic_rate_idc[i][j]" ); vps->setConstPicRateIdc( i, j, uiCode ); |
---|
4117 | READ_CODE( 16, uiCode, "avg_pic_rate[i][j]" ); vps->setAvgPicRate( i, j, uiCode ); |
---|
4118 | } |
---|
4119 | else |
---|
4120 | { |
---|
4121 | vps->setConstPicRateIdc( i, j, 0 ); |
---|
4122 | vps->setAvgPicRate ( i, j, 0 ); |
---|
4123 | } |
---|
4124 | } |
---|
4125 | } |
---|
4126 | #endif |
---|
4127 | #if VPS_VUI_VIDEO_SIGNAL_MOVE |
---|
4128 | READ_FLAG( uiCode, "video_signal_info_idx_present_flag" ); vps->setVideoSigPresentVpsFlag( uiCode == 1 ); |
---|
4129 | if (vps->getVideoSigPresentVpsFlag()) |
---|
4130 | { |
---|
4131 | READ_CODE(4, uiCode, "vps_num_video_signal_info_minus1" ); vps->setNumVideoSignalInfo(uiCode + 1); |
---|
4132 | } |
---|
4133 | else |
---|
4134 | { |
---|
4135 | #if VPS_VUI_VST_PARAMS |
---|
4136 | vps->setNumVideoSignalInfo(vps->getMaxLayers() - vps->getBaseLayerInternalFlag() ? 0 : 1); |
---|
4137 | #else |
---|
4138 | vps->setNumVideoSignalInfo(vps->getMaxLayers()); |
---|
4139 | #endif |
---|
4140 | } |
---|
4141 | |
---|
4142 | for(i = 0; i < vps->getNumVideoSignalInfo(); i++) |
---|
4143 | { |
---|
4144 | READ_CODE(3, uiCode, "video_vps_format" ); vps->setVideoVPSFormat(i,uiCode); |
---|
4145 | READ_FLAG(uiCode, "video_full_range_vps_flag" ); vps->setVideoFullRangeVpsFlag(i,uiCode); |
---|
4146 | READ_CODE(8, uiCode, "color_primaries_vps" ); vps->setColorPrimaries(i,uiCode); |
---|
4147 | READ_CODE(8, uiCode, "transfer_characteristics_vps" ); vps->setTransCharacter(i,uiCode); |
---|
4148 | READ_CODE(8, uiCode, "matrix_coeffs_vps" );vps->setMaxtrixCoeff(i,uiCode); |
---|
4149 | } |
---|
4150 | #if VPS_VUI_VST_PARAMS |
---|
4151 | if( vps->getVideoSigPresentVpsFlag() && vps->getNumVideoSignalInfo() > 1 ) |
---|
4152 | { |
---|
4153 | for(i = vps->getBaseLayerInternalFlag() ? 0 : 1; i < vps->getMaxLayers(); i++) |
---|
4154 | { |
---|
4155 | READ_CODE(4, uiCode, "vps_video_signal_info_idx" ); vps->setVideoSignalInfoIdx(i, uiCode); |
---|
4156 | } |
---|
4157 | } |
---|
4158 | else if ( !vps->getVideoSigPresentVpsFlag() ) |
---|
4159 | { |
---|
4160 | for(i = vps->getBaseLayerInternalFlag() ? 0 : 1; i < vps->getMaxLayers(); i++) |
---|
4161 | { |
---|
4162 | vps->setVideoSignalInfoIdx( i, i ); |
---|
4163 | } |
---|
4164 | } |
---|
4165 | else // ( vps->getNumVideoSignalInfo() = 0 ) |
---|
4166 | { |
---|
4167 | for(i = vps->getBaseLayerInternalFlag() ? 0 : 1; i < vps->getMaxLayers(); i++) |
---|
4168 | { |
---|
4169 | vps->setVideoSignalInfoIdx( i, 0 ); |
---|
4170 | } |
---|
4171 | } |
---|
4172 | #else |
---|
4173 | if(!vps->getVideoSigPresentVpsFlag()) |
---|
4174 | { |
---|
4175 | for (i=0; i < vps->getMaxLayers(); i++) |
---|
4176 | { |
---|
4177 | vps->setVideoSignalInfoIdx(i,i); |
---|
4178 | } |
---|
4179 | } |
---|
4180 | else { |
---|
4181 | vps->setVideoSignalInfoIdx(0,0); |
---|
4182 | if (vps->getNumVideoSignalInfo() > 1 ) |
---|
4183 | { |
---|
4184 | for (i=1; i < vps->getMaxLayers(); i++) |
---|
4185 | READ_CODE(4, uiCode, "vps_video_signal_info_idx" ); vps->setVideoSignalInfoIdx(i, uiCode); |
---|
4186 | } |
---|
4187 | else { |
---|
4188 | for (i=1; i < vps->getMaxLayers(); i++) |
---|
4189 | { |
---|
4190 | vps->setVideoSignalInfoIdx(i,0); |
---|
4191 | } |
---|
4192 | } |
---|
4193 | } |
---|
4194 | #endif |
---|
4195 | #endif |
---|
4196 | #if VPS_VUI_TILES_NOT_IN_USE__FLAG |
---|
4197 | UInt layerIdx; |
---|
4198 | READ_FLAG( uiCode, "tiles_not_in_use_flag" ); vps->setTilesNotInUseFlag(uiCode == 1); |
---|
4199 | if (!uiCode) |
---|
4200 | { |
---|
4201 | #if VPS_FIX_TO_MATCH_SPEC |
---|
4202 | for( i = vps->getBaseLayerInternalFlag() ? 0 : 1; i < vps->getMaxLayers(); i++ ) |
---|
4203 | #else |
---|
4204 | for (i = 0; i < vps->getMaxLayers(); i++) |
---|
4205 | #endif |
---|
4206 | { |
---|
4207 | READ_FLAG( uiCode, "tiles_in_use_flag[ i ]" ); vps->setTilesInUseFlag(i, (uiCode == 1)); |
---|
4208 | if (uiCode) |
---|
4209 | { |
---|
4210 | READ_FLAG( uiCode, "loop_filter_not_across_tiles_flag[ i ]" ); vps->setLoopFilterNotAcrossTilesFlag(i, (uiCode == 1)); |
---|
4211 | } |
---|
4212 | else |
---|
4213 | { |
---|
4214 | vps->setLoopFilterNotAcrossTilesFlag(i, false); |
---|
4215 | } |
---|
4216 | } |
---|
4217 | #endif |
---|
4218 | |
---|
4219 | #if VPS_FIX_TO_MATCH_SPEC |
---|
4220 | for( i = vps->getBaseLayerInternalFlag() ? 1 : 2; i < vps->getMaxLayers(); i++ ) |
---|
4221 | #else |
---|
4222 | for (i = 1; i < vps->getMaxLayers(); i++) |
---|
4223 | #endif |
---|
4224 | { |
---|
4225 | for(j = 0; j < vps->getNumDirectRefLayers(vps->getLayerIdInNuh(i)); j++) |
---|
4226 | { |
---|
4227 | #if VPS_VUI_TILES_NOT_IN_USE__FLAG |
---|
4228 | layerIdx = vps->getLayerIdxInVps(vps->getRefLayerId(vps->getLayerIdInNuh(i), j)); |
---|
4229 | if (vps->getTilesInUseFlag(i) && vps->getTilesInUseFlag(layerIdx)) { |
---|
4230 | READ_FLAG( uiCode, "tile_boundaries_aligned_flag[i][j]" ); vps->setTileBoundariesAlignedFlag(i,j,(uiCode == 1)); |
---|
4231 | } |
---|
4232 | #else |
---|
4233 | READ_FLAG( uiCode, "tile_boundaries_aligned_flag[i][j]" ); vps->setTileBoundariesAlignedFlag(i,j,(uiCode == 1)); |
---|
4234 | #endif |
---|
4235 | } |
---|
4236 | } |
---|
4237 | #if VPS_VUI_TILES_NOT_IN_USE__FLAG |
---|
4238 | } |
---|
4239 | #endif |
---|
4240 | #if VPS_VUI_WPP_NOT_IN_USE__FLAG |
---|
4241 | READ_FLAG( uiCode, "wpp_not_in_use_flag" ); vps->setWppNotInUseFlag(uiCode == 1); |
---|
4242 | if (!uiCode) |
---|
4243 | { |
---|
4244 | #if VPS_FIX_TO_MATCH_SPEC |
---|
4245 | for (i = vps->getBaseLayerInternalFlag() ? 0 : 1; i < vps->getMaxLayers(); i++) |
---|
4246 | #else |
---|
4247 | for (i = 0; i < vps->getMaxLayers(); i++) |
---|
4248 | #endif |
---|
4249 | { |
---|
4250 | READ_FLAG( uiCode, "wpp_in_use_flag[ i ]" ); vps->setWppInUseFlag(i, (uiCode == 1)); |
---|
4251 | } |
---|
4252 | } |
---|
4253 | #endif |
---|
4254 | |
---|
4255 | #if O0109_O0199_FLAGS_TO_VUI |
---|
4256 | #if M0040_ADAPTIVE_RESOLUTION_CHANGE |
---|
4257 | READ_FLAG(uiCode, "single_layer_for_non_irap_flag" ); vps->setSingleLayerForNonIrapFlag(uiCode == 1 ? true : false); |
---|
4258 | #endif |
---|
4259 | #if HIGHER_LAYER_IRAP_SKIP_FLAG |
---|
4260 | READ_FLAG(uiCode, "higher_layer_irap_skip_flag" ); vps->setHigherLayerIrapSkipFlag(uiCode == 1 ? true : false); |
---|
4261 | |
---|
4262 | // When single_layer_for_non_irap_flag is equal to 0, higher_layer_irap_skip_flag shall be equal to 0 |
---|
4263 | if( !vps->getSingleLayerForNonIrapFlag() ) |
---|
4264 | { |
---|
4265 | assert( !vps->getHigherLayerIrapSkipFlag() ); |
---|
4266 | } |
---|
4267 | #endif |
---|
4268 | #endif |
---|
4269 | #if P0312_VERT_PHASE_ADJ |
---|
4270 | READ_FLAG( uiCode, "vps_vui_vert_phase_in_use_flag" ); vps->setVpsVuiVertPhaseInUseFlag(uiCode); |
---|
4271 | #endif |
---|
4272 | #if N0160_VUI_EXT_ILP_REF |
---|
4273 | READ_FLAG( uiCode, "ilp_restricted_ref_layers_flag" ); vps->setIlpRestrictedRefLayersFlag( uiCode == 1 ); |
---|
4274 | if( vps->getIlpRestrictedRefLayersFlag()) |
---|
4275 | { |
---|
4276 | for(i = 1; i < vps->getMaxLayers(); i++) |
---|
4277 | { |
---|
4278 | for(j = 0; j < vps->getNumDirectRefLayers(vps->getLayerIdInNuh(i)); j++) |
---|
4279 | { |
---|
4280 | #if VPS_FIX_TO_MATCH_SPEC |
---|
4281 | if( vps->getBaseLayerInternalFlag() || vps->getRefLayerId(vps->getLayerIdInNuh(i), j) ) |
---|
4282 | { |
---|
4283 | #endif |
---|
4284 | READ_UVLC( uiCode, "min_spatial_segment_offset_plus1[i][j]" ); vps->setMinSpatialSegmentOffsetPlus1( i, j, uiCode ); |
---|
4285 | if( vps->getMinSpatialSegmentOffsetPlus1(i,j ) > 0 ) |
---|
4286 | { |
---|
4287 | READ_FLAG( uiCode, "ctu_based_offset_enabled_flag[i][j]"); vps->setCtuBasedOffsetEnabledFlag(i, j, uiCode == 1 ); |
---|
4288 | if(vps->getCtuBasedOffsetEnabledFlag(i,j)) |
---|
4289 | { |
---|
4290 | READ_UVLC( uiCode, "min_horizontal_ctu_offset_plus1[i][j]"); vps->setMinHorizontalCtuOffsetPlus1( i,j, uiCode ); |
---|
4291 | } |
---|
4292 | } |
---|
4293 | #if VPS_FIX_TO_MATCH_SPEC |
---|
4294 | } |
---|
4295 | #endif |
---|
4296 | } |
---|
4297 | } |
---|
4298 | } |
---|
4299 | #endif |
---|
4300 | #if VPS_VUI_VIDEO_SIGNAL |
---|
4301 | #if VPS_VUI_VIDEO_SIGNAL_MOVE |
---|
4302 | #else |
---|
4303 | READ_FLAG( uiCode, "video_signal_info_idx_present_flag" ); vps->setVideoSigPresentVpsFlag( uiCode == 1 ); |
---|
4304 | if (vps->getVideoSigPresentVpsFlag()) |
---|
4305 | { |
---|
4306 | READ_CODE(4, uiCode, "vps_num_video_signal_info_minus1" ); vps->setNumVideoSignalInfo(uiCode + 1); |
---|
4307 | } |
---|
4308 | else |
---|
4309 | { |
---|
4310 | vps->setNumVideoSignalInfo(vps->getMaxLayers()); |
---|
4311 | } |
---|
4312 | |
---|
4313 | |
---|
4314 | for(i = 0; i < vps->getNumVideoSignalInfo(); i++) |
---|
4315 | { |
---|
4316 | READ_CODE(3, uiCode, "video_vps_format" ); vps->setVideoVPSFormat(i,uiCode); |
---|
4317 | READ_FLAG(uiCode, "video_full_range_vps_flag" ); vps->setVideoFullRangeVpsFlag(i,uiCode); |
---|
4318 | READ_CODE(8, uiCode, "color_primaries_vps" ); vps->setColorPrimaries(i,uiCode); |
---|
4319 | READ_CODE(8, uiCode, "transfer_characteristics_vps" ); vps->setTransCharacter(i,uiCode); |
---|
4320 | READ_CODE(8, uiCode, "matrix_coeffs_vps" );vps->setMaxtrixCoeff(i,uiCode); |
---|
4321 | } |
---|
4322 | if(!vps->getVideoSigPresentVpsFlag()) |
---|
4323 | { |
---|
4324 | for (i=0; i < vps->getMaxLayers(); i++) |
---|
4325 | { |
---|
4326 | vps->setVideoSignalInfoIdx(i,i); |
---|
4327 | } |
---|
4328 | } |
---|
4329 | else { |
---|
4330 | vps->setVideoSignalInfoIdx(0,0); |
---|
4331 | if (vps->getNumVideoSignalInfo() > 1 ) |
---|
4332 | { |
---|
4333 | for (i=1; i < vps->getMaxLayers(); i++) |
---|
4334 | READ_CODE(4, uiCode, "vps_video_signal_info_idx" ); vps->setVideoSignalInfoIdx(i, uiCode); |
---|
4335 | } |
---|
4336 | else { |
---|
4337 | for (i=1; i < vps->getMaxLayers(); i++) |
---|
4338 | { |
---|
4339 | vps->setVideoSignalInfoIdx(i,0); |
---|
4340 | } |
---|
4341 | } |
---|
4342 | } |
---|
4343 | #endif |
---|
4344 | #endif |
---|
4345 | |
---|
4346 | #if O0164_MULTI_LAYER_HRD |
---|
4347 | READ_FLAG(uiCode, "vps_vui_bsp_hrd_present_flag" ); vps->setVpsVuiBspHrdPresentFlag(uiCode); |
---|
4348 | if (vps->getVpsVuiBspHrdPresentFlag()) |
---|
4349 | { |
---|
4350 | #if VPS_VUI_BSP_HRD_PARAMS |
---|
4351 | parseVpsVuiBspHrdParams(vps); |
---|
4352 | #else |
---|
4353 | #if R0227_VUI_BSP_HRD_FLAG |
---|
4354 | assert (vps->getTimingInfo()->getTimingInfoPresentFlag() == 1); |
---|
4355 | #endif |
---|
4356 | READ_UVLC( uiCode, "vps_num_bsp_hrd_parameters_minus1" ); vps->setVpsNumBspHrdParametersMinus1(uiCode); |
---|
4357 | vps->createBspHrdParamBuffer(vps->getVpsNumBspHrdParametersMinus1() + 1); |
---|
4358 | for( i = 0; i <= vps->getVpsNumBspHrdParametersMinus1(); i++ ) |
---|
4359 | { |
---|
4360 | if( i > 0 ) |
---|
4361 | { |
---|
4362 | READ_FLAG( uiCode, "bsp_cprms_present_flag[i]" ); vps->setBspCprmsPresentFlag(i, uiCode); |
---|
4363 | } |
---|
4364 | parseHrdParameters(vps->getBspHrd(i), i==0 ? 1 : vps->getBspCprmsPresentFlag(i), vps->getMaxTLayers()-1); |
---|
4365 | } |
---|
4366 | #if Q0078_ADD_LAYER_SETS |
---|
4367 | for (UInt h = 1; h <= vps->getVpsNumLayerSetsMinus1(); h++) |
---|
4368 | #else |
---|
4369 | for( UInt h = 1; h <= (vps->getNumLayerSets()-1); h++ ) |
---|
4370 | #endif |
---|
4371 | { |
---|
4372 | READ_UVLC( uiCode, "num_bitstream_partitions[i]"); vps->setNumBitstreamPartitions(h, uiCode); |
---|
4373 | #if HRD_BPB |
---|
4374 | Int chkPart=0; |
---|
4375 | #endif |
---|
4376 | for( i = 0; i < vps->getNumBitstreamPartitions(h); i++ ) |
---|
4377 | { |
---|
4378 | for( j = 0; j <= (vps->getMaxLayers()-1); j++ ) |
---|
4379 | { |
---|
4380 | if( vps->getLayerIdIncludedFlag(h, j) ) |
---|
4381 | { |
---|
4382 | READ_FLAG( uiCode, "layer_in_bsp_flag[h][i][j]" ); vps->setLayerInBspFlag(h, i, j, uiCode); |
---|
4383 | } |
---|
4384 | } |
---|
4385 | #if HRD_BPB |
---|
4386 | chkPart+=vps->getLayerInBspFlag(h, i, j); |
---|
4387 | #endif |
---|
4388 | } |
---|
4389 | #if HRD_BPB |
---|
4390 | assert(chkPart<=1); |
---|
4391 | #endif |
---|
4392 | #if HRD_BPB |
---|
4393 | if(vps->getNumBitstreamPartitions(h)==1) |
---|
4394 | { |
---|
4395 | Int chkPartition1=0; Int chkPartition2=0; |
---|
4396 | for( j = 0; j <= (vps->getMaxLayers()-1); j++ ) |
---|
4397 | { |
---|
4398 | if( vps->getLayerIdIncludedFlag(h, j) ) |
---|
4399 | { |
---|
4400 | chkPartition1+=vps->getLayerInBspFlag(h, 0, j); |
---|
4401 | chkPartition2++; |
---|
4402 | } |
---|
4403 | } |
---|
4404 | assert(chkPartition1!=chkPartition2); |
---|
4405 | } |
---|
4406 | #endif |
---|
4407 | if (vps->getNumBitstreamPartitions(h)) |
---|
4408 | { |
---|
4409 | #if Q0182_MULTI_LAYER_HRD_UPDATE |
---|
4410 | READ_UVLC( uiCode, "num_bsp_sched_combinations_minus1[h]"); vps->setNumBspSchedCombinations(h, uiCode + 1); |
---|
4411 | #else |
---|
4412 | READ_UVLC( uiCode, "num_bsp_sched_combinations[h]"); vps->setNumBspSchedCombinations(h, uiCode); |
---|
4413 | #endif |
---|
4414 | for( i = 0; i < vps->getNumBspSchedCombinations(h); i++ ) |
---|
4415 | { |
---|
4416 | for( j = 0; j < vps->getNumBitstreamPartitions(h); j++ ) |
---|
4417 | { |
---|
4418 | READ_UVLC( uiCode, "bsp_comb_hrd_idx[h][i][j]"); vps->setBspCombHrdIdx(h, i, j, uiCode); |
---|
4419 | #if HRD_BPB |
---|
4420 | assert(uiCode <= vps->getVpsNumBspHrdParametersMinus1()); |
---|
4421 | #endif |
---|
4422 | |
---|
4423 | READ_UVLC( uiCode, "bsp_comb_sched_idx[h][i][j]"); vps->setBspCombSchedIdx(h, i, j, uiCode); |
---|
4424 | #if HRD_BPB |
---|
4425 | assert(uiCode <= vps->getBspHrdParamBufferCpbCntMinus1(uiCode,vps->getMaxTLayers()-1)); |
---|
4426 | #endif |
---|
4427 | } |
---|
4428 | } |
---|
4429 | } |
---|
4430 | } |
---|
4431 | #endif |
---|
4432 | } |
---|
4433 | #endif |
---|
4434 | #if P0182_VPS_VUI_PS_FLAG |
---|
4435 | for(i = 1; i < vps->getMaxLayers(); i++) |
---|
4436 | { |
---|
4437 | if (vps->getNumRefLayers(vps->getLayerIdInNuh(i)) == 0) |
---|
4438 | { |
---|
4439 | READ_FLAG( uiCode, "base_layer_parameter_set_compatibility_flag" ); |
---|
4440 | vps->setBaseLayerPSCompatibilityFlag( i, uiCode ); |
---|
4441 | } |
---|
4442 | else |
---|
4443 | { |
---|
4444 | vps->setBaseLayerPSCompatibilityFlag( i, 0 ); |
---|
4445 | } |
---|
4446 | } |
---|
4447 | #endif |
---|
4448 | } |
---|
4449 | |
---|
4450 | Void TDecCavlc::parseSPSExtension( TComSPS* pcSPS ) |
---|
4451 | { |
---|
4452 | UInt uiCode; |
---|
4453 | // more syntax elements to be parsed here |
---|
4454 | |
---|
4455 | READ_FLAG( uiCode, "inter_view_mv_vert_constraint_flag" ); |
---|
4456 | // Vertical MV component restriction is not used in SHVC CTC |
---|
4457 | assert( uiCode == 0 ); |
---|
4458 | |
---|
4459 | #if !MOVE_SCALED_OFFSET_TO_PPS |
---|
4460 | if( pcSPS->getLayerId() > 0 ) |
---|
4461 | { |
---|
4462 | Int iCode; |
---|
4463 | READ_UVLC( uiCode, "num_scaled_ref_layer_offsets" ); pcSPS->setNumScaledRefLayerOffsets(uiCode); |
---|
4464 | for(Int i = 0; i < pcSPS->getNumScaledRefLayerOffsets(); i++) |
---|
4465 | { |
---|
4466 | Window& scaledWindow = pcSPS->getScaledRefLayerWindow(i); |
---|
4467 | #if O0098_SCALED_REF_LAYER_ID |
---|
4468 | READ_CODE( 6, uiCode, "scaled_ref_layer_id" ); pcSPS->setScaledRefLayerId( i, uiCode ); |
---|
4469 | #endif |
---|
4470 | READ_SVLC( iCode, "scaled_ref_layer_left_offset" ); scaledWindow.setWindowLeftOffset (iCode << 1); |
---|
4471 | READ_SVLC( iCode, "scaled_ref_layer_top_offset" ); scaledWindow.setWindowTopOffset (iCode << 1); |
---|
4472 | READ_SVLC( iCode, "scaled_ref_layer_right_offset" ); scaledWindow.setWindowRightOffset (iCode << 1); |
---|
4473 | READ_SVLC( iCode, "scaled_ref_layer_bottom_offset" ); scaledWindow.setWindowBottomOffset(iCode << 1); |
---|
4474 | #if P0312_VERT_PHASE_ADJ |
---|
4475 | READ_FLAG( uiCode, "vert_phase_position_enable_flag" ); scaledWindow.setVertPhasePositionEnableFlag(uiCode); pcSPS->setVertPhasePositionEnableFlag( pcSPS->getScaledRefLayerId(i), uiCode); |
---|
4476 | #endif |
---|
4477 | } |
---|
4478 | } |
---|
4479 | #endif |
---|
4480 | } |
---|
4481 | #endif |
---|
4482 | |
---|
4483 | #if Q0048_CGS_3D_ASYMLUT |
---|
4484 | Void TDecCavlc::xParse3DAsymLUT( TCom3DAsymLUT * pc3DAsymLUT ) |
---|
4485 | { |
---|
4486 | #if R0150_CGS_SIGNAL_CONSTRAINTS |
---|
4487 | UInt uiNumRefLayersM1; |
---|
4488 | READ_UVLC( uiNumRefLayersM1 , "num_cm_ref_layers_minus1" ); |
---|
4489 | assert( uiNumRefLayersM1 <= 61 ); |
---|
4490 | for( UInt i = 0 ; i <= uiNumRefLayersM1 ; i++ ) |
---|
4491 | { |
---|
4492 | UInt uiRefLayerId; |
---|
4493 | READ_CODE( 6 , uiRefLayerId , "cm_ref_layer_id" ); |
---|
4494 | pc3DAsymLUT->addRefLayerId( uiRefLayerId ); |
---|
4495 | } |
---|
4496 | #endif |
---|
4497 | UInt uiCurOctantDepth , uiCurPartNumLog2 , uiInputBitDepthM8 , uiOutputBitDepthM8 , uiResQaunBit; |
---|
4498 | #if R0300_CGS_RES_COEFF_CODING |
---|
4499 | UInt uiDeltaBits; |
---|
4500 | #endif |
---|
4501 | READ_CODE( 2 , uiCurOctantDepth , "cm_octant_depth" ); |
---|
4502 | READ_CODE( 2 , uiCurPartNumLog2 , "cm_y_part_num_log2" ); |
---|
4503 | #if R0150_CGS_SIGNAL_CONSTRAINTS |
---|
4504 | UInt uiChromaInputBitDepthM8 , uiChromaOutputBitDepthM8; |
---|
4505 | READ_UVLC( uiInputBitDepthM8 , "cm_input_luma_bit_depth_minus8" ); |
---|
4506 | READ_UVLC( uiChromaInputBitDepthM8 , "cm_input_chroma_bit_depth_minus8" ); |
---|
4507 | READ_UVLC( uiOutputBitDepthM8 , "cm_output_luma_bit_depth_minus8" ); |
---|
4508 | READ_UVLC( uiChromaOutputBitDepthM8 , "cm_output_chroma_bit_depth_minus8" ); |
---|
4509 | #else |
---|
4510 | READ_CODE( 3 , uiInputBitDepthM8 , "cm_input_bit_depth_minus8" ); |
---|
4511 | Int iInputBitDepthCDelta; |
---|
4512 | READ_SVLC(iInputBitDepthCDelta, "cm_input_bit_depth_chroma delta"); |
---|
4513 | READ_CODE( 3 , uiOutputBitDepthM8 , "cm_output_bit_depth_minus8" ); |
---|
4514 | Int iOutputBitDepthCDelta; |
---|
4515 | READ_SVLC(iOutputBitDepthCDelta, "cm_output_bit_depth_chroma_delta"); |
---|
4516 | #endif |
---|
4517 | READ_CODE( 2 , uiResQaunBit , "cm_res_quant_bit" ); |
---|
4518 | #if R0300_CGS_RES_COEFF_CODING |
---|
4519 | READ_CODE( 2 , uiDeltaBits , "cm_flc_bits" ); |
---|
4520 | pc3DAsymLUT->setDeltaBits(uiDeltaBits + 1); |
---|
4521 | #endif |
---|
4522 | |
---|
4523 | #if R0151_CGS_3D_ASYMLUT_IMPROVE |
---|
4524 | #if R0150_CGS_SIGNAL_CONSTRAINTS |
---|
4525 | Int nAdaptCThresholdU = 1 << ( uiChromaInputBitDepthM8 + 8 - 1 ); |
---|
4526 | Int nAdaptCThresholdV = 1 << ( uiChromaInputBitDepthM8 + 8 - 1 ); |
---|
4527 | #else |
---|
4528 | Int nAdaptCThresholdU = 1 << ( uiInputBitDepthM8 + 8 + iInputBitDepthCDelta - 1 ); |
---|
4529 | Int nAdaptCThresholdV = 1 << ( uiInputBitDepthM8 + 8 + iInputBitDepthCDelta - 1 ); |
---|
4530 | #endif |
---|
4531 | if( uiCurOctantDepth == 1 ) |
---|
4532 | { |
---|
4533 | Int delta = 0; |
---|
4534 | READ_SVLC( delta , "cm_adapt_threshold_u_delta" ); |
---|
4535 | nAdaptCThresholdU += delta; |
---|
4536 | READ_SVLC( delta , "cm_adapt_threshold_v_delta" ); |
---|
4537 | nAdaptCThresholdV += delta; |
---|
4538 | } |
---|
4539 | #endif |
---|
4540 | pc3DAsymLUT->destroy(); |
---|
4541 | pc3DAsymLUT->create( uiCurOctantDepth , uiInputBitDepthM8 + 8 , |
---|
4542 | #if R0150_CGS_SIGNAL_CONSTRAINTS |
---|
4543 | uiChromaInputBitDepthM8 + 8 , |
---|
4544 | #else |
---|
4545 | uiInputBitDepthM8 + 8 + iInputBitDepthCDelta, |
---|
4546 | #endif |
---|
4547 | uiOutputBitDepthM8 + 8 , |
---|
4548 | #if R0150_CGS_SIGNAL_CONSTRAINTS |
---|
4549 | uiChromaOutputBitDepthM8 + 8 , |
---|
4550 | #else |
---|
4551 | uiOutputBitDepthM8 + 8 + iOutputBitDepthCDelta , |
---|
4552 | #endif |
---|
4553 | uiCurPartNumLog2 |
---|
4554 | #if R0151_CGS_3D_ASYMLUT_IMPROVE |
---|
4555 | , nAdaptCThresholdU , nAdaptCThresholdV |
---|
4556 | #endif |
---|
4557 | ); |
---|
4558 | pc3DAsymLUT->setResQuantBit( uiResQaunBit ); |
---|
4559 | |
---|
4560 | #if R0164_CGS_LUT_BUGFIX_CHECK |
---|
4561 | pc3DAsymLUT->xInitCuboids(); |
---|
4562 | #endif |
---|
4563 | xParse3DAsymLUTOctant( pc3DAsymLUT , 0 , 0 , 0 , 0 , 1 << pc3DAsymLUT->getCurOctantDepth() ); |
---|
4564 | #if R0164_CGS_LUT_BUGFIX |
---|
4565 | #if R0164_CGS_LUT_BUGFIX_CHECK |
---|
4566 | printf("============= Before 'xCuboidsFilledCheck()': ================\n"); |
---|
4567 | pc3DAsymLUT->display(); |
---|
4568 | pc3DAsymLUT->xCuboidsFilledCheck( false ); |
---|
4569 | printf("============= After 'xCuboidsFilledCheck()': =================\n"); |
---|
4570 | pc3DAsymLUT->display(); |
---|
4571 | #endif |
---|
4572 | #endif |
---|
4573 | } |
---|
4574 | |
---|
4575 | Void TDecCavlc::xParse3DAsymLUTOctant( TCom3DAsymLUT * pc3DAsymLUT , Int nDepth , Int yIdx , Int uIdx , Int vIdx , Int nLength ) |
---|
4576 | { |
---|
4577 | UInt uiOctantSplit = nDepth < pc3DAsymLUT->getCurOctantDepth(); |
---|
4578 | if( nDepth < pc3DAsymLUT->getCurOctantDepth() ) |
---|
4579 | READ_FLAG( uiOctantSplit , "split_octant_flag" ); |
---|
4580 | Int nYPartNum = 1 << pc3DAsymLUT->getCurYPartNumLog2(); |
---|
4581 | if( uiOctantSplit ) |
---|
4582 | { |
---|
4583 | Int nHalfLength = nLength >> 1; |
---|
4584 | for( Int l = 0 ; l < 2 ; l++ ) |
---|
4585 | { |
---|
4586 | for( Int m = 0 ; m < 2 ; m++ ) |
---|
4587 | { |
---|
4588 | for( Int n = 0 ; n < 2 ; n++ ) |
---|
4589 | { |
---|
4590 | xParse3DAsymLUTOctant( pc3DAsymLUT , nDepth + 1 , yIdx + l * nHalfLength * nYPartNum , uIdx + m * nHalfLength , vIdx + n * nHalfLength , nHalfLength ); |
---|
4591 | } |
---|
4592 | } |
---|
4593 | } |
---|
4594 | } |
---|
4595 | else |
---|
4596 | { |
---|
4597 | #if R0300_CGS_RES_COEFF_CODING |
---|
4598 | Int nFLCbits = pc3DAsymLUT->getMappingShift()-pc3DAsymLUT->getResQuantBit()-pc3DAsymLUT->getDeltaBits() ; |
---|
4599 | nFLCbits = nFLCbits >= 0 ? nFLCbits:0; |
---|
4600 | #endif |
---|
4601 | for( Int l = 0 ; l < nYPartNum ; l++ ) |
---|
4602 | { |
---|
4603 | #if R0164_CGS_LUT_BUGFIX |
---|
4604 | Int shift = pc3DAsymLUT->getCurOctantDepth() - nDepth ; |
---|
4605 | #endif |
---|
4606 | for( Int nVertexIdx = 0 ; nVertexIdx < 4 ; nVertexIdx++ ) |
---|
4607 | { |
---|
4608 | UInt uiCodeVertex = 0; |
---|
4609 | Int deltaY = 0 , deltaU = 0 , deltaV = 0; |
---|
4610 | READ_FLAG( uiCodeVertex , "coded_vertex_flag" ); |
---|
4611 | if( uiCodeVertex ) |
---|
4612 | { |
---|
4613 | #if R0151_CGS_3D_ASYMLUT_IMPROVE |
---|
4614 | #if R0300_CGS_RES_COEFF_CODING |
---|
4615 | xReadParam( deltaY, nFLCbits ); |
---|
4616 | xReadParam( deltaU, nFLCbits ); |
---|
4617 | xReadParam( deltaV, nFLCbits ); |
---|
4618 | #else |
---|
4619 | xReadParam( deltaY ); |
---|
4620 | xReadParam( deltaU ); |
---|
4621 | xReadParam( deltaV ); |
---|
4622 | #endif |
---|
4623 | #else |
---|
4624 | READ_SVLC( deltaY , "resY" ); |
---|
4625 | READ_SVLC( deltaU , "resU" ); |
---|
4626 | READ_SVLC( deltaV , "resV" ); |
---|
4627 | #endif |
---|
4628 | } |
---|
4629 | #if R0164_CGS_LUT_BUGFIX |
---|
4630 | pc3DAsymLUT->setCuboidVertexResTree( yIdx + (l<<shift) , uIdx , vIdx , nVertexIdx , deltaY , deltaU , deltaV ); |
---|
4631 | for (Int m = 1; m < (1<<shift); m++) { |
---|
4632 | pc3DAsymLUT->setCuboidVertexResTree( yIdx + (l<<shift) + m , uIdx , vIdx , nVertexIdx , 0 , 0 , 0 ); |
---|
4633 | #if R0164_CGS_LUT_BUGFIX_CHECK |
---|
4634 | pc3DAsymLUT->xSetFilled( yIdx + (l<<shift) + m , uIdx , vIdx ); |
---|
4635 | #endif |
---|
4636 | } |
---|
4637 | #else |
---|
4638 | pc3DAsymLUT->setCuboidVertexResTree( yIdx + l , uIdx , vIdx , nVertexIdx , deltaY , deltaU , deltaV ); |
---|
4639 | #endif |
---|
4640 | } |
---|
4641 | #if R0164_CGS_LUT_BUGFIX_CHECK |
---|
4642 | pc3DAsymLUT->xSetExplicit( yIdx + (l<<shift) , uIdx , vIdx ); |
---|
4643 | #endif |
---|
4644 | } |
---|
4645 | #if R0164_CGS_LUT_BUGFIX |
---|
4646 | for ( Int u=0 ; u<nLength ; u++ ) { |
---|
4647 | for ( Int v=0 ; v<nLength ; v++ ) { |
---|
4648 | if ( u!=0 || v!=0 ) { |
---|
4649 | for ( Int y=0 ; y<nLength*nYPartNum ; y++ ) { |
---|
4650 | for( Int nVertexIdx = 0 ; nVertexIdx < 4 ; nVertexIdx++ ) |
---|
4651 | { |
---|
4652 | pc3DAsymLUT->setCuboidVertexResTree( yIdx + y , uIdx + u , vIdx + v , nVertexIdx , 0 , 0 , 0 ); |
---|
4653 | #if R0164_CGS_LUT_BUGFIX_CHECK |
---|
4654 | pc3DAsymLUT->xSetFilled( yIdx + y , uIdx + u , vIdx + v ); |
---|
4655 | #endif |
---|
4656 | } |
---|
4657 | } |
---|
4658 | } |
---|
4659 | } |
---|
4660 | } |
---|
4661 | #endif |
---|
4662 | } |
---|
4663 | } |
---|
4664 | |
---|
4665 | #if R0151_CGS_3D_ASYMLUT_IMPROVE |
---|
4666 | #if R0300_CGS_RES_COEFF_CODING |
---|
4667 | Void TDecCavlc::xReadParam( Int& param, Int rParam ) |
---|
4668 | #else |
---|
4669 | Void TDecCavlc::xReadParam( Int& param ) |
---|
4670 | #endif |
---|
4671 | { |
---|
4672 | #if !R0300_CGS_RES_COEFF_CODING |
---|
4673 | const UInt rParam = 7; |
---|
4674 | #endif |
---|
4675 | UInt prefix; |
---|
4676 | UInt codeWord ; |
---|
4677 | UInt rSymbol; |
---|
4678 | UInt sign; |
---|
4679 | |
---|
4680 | READ_UVLC( prefix, "quotient") ; |
---|
4681 | READ_CODE (rParam, codeWord, "remainder"); |
---|
4682 | rSymbol = (prefix<<rParam) + codeWord; |
---|
4683 | |
---|
4684 | if(rSymbol) |
---|
4685 | { |
---|
4686 | READ_FLAG(sign, "sign"); |
---|
4687 | param = sign ? -(Int)(rSymbol) : (Int)(rSymbol); |
---|
4688 | } |
---|
4689 | else param = 0; |
---|
4690 | } |
---|
4691 | #endif |
---|
4692 | #if VPS_VUI_BSP_HRD_PARAMS |
---|
4693 | Void TDecCavlc::parseVpsVuiBspHrdParams( TComVPS *vps ) |
---|
4694 | { |
---|
4695 | UInt uiCode; |
---|
4696 | assert (vps->getTimingInfo()->getTimingInfoPresentFlag() == 1); |
---|
4697 | READ_UVLC( uiCode, "vps_num_add_hrd_params" ); vps->setVpsNumAddHrdParams(uiCode); |
---|
4698 | vps->createBspHrdParamBuffer(vps->getVpsNumAddHrdParams()); // Also allocates m_cprmsAddPresentFlag and m_numSubLayerHrdMinus |
---|
4699 | |
---|
4700 | for( Int i = vps->getNumHrdParameters(), j = 0; i < vps->getNumHrdParameters() + vps->getVpsNumAddHrdParams(); i++, j++ ) // j = i - vps->getNumHrdParameters() |
---|
4701 | { |
---|
4702 | if( i > 0 ) |
---|
4703 | { |
---|
4704 | READ_FLAG( uiCode, "cprms_add_present_flag[i]" ); vps->setCprmsAddPresentFlag(j, uiCode ? true : false); |
---|
4705 | } |
---|
4706 | else |
---|
4707 | { |
---|
4708 | // i == 0 |
---|
4709 | if( vps->getNumHrdParameters() == 0 ) |
---|
4710 | { |
---|
4711 | vps->setCprmsAddPresentFlag(0, true); |
---|
4712 | } |
---|
4713 | } |
---|
4714 | READ_UVLC( uiCode, "num_sub_layer_hrd_minus1[i]" ); vps->setNumSubLayerHrdMinus1(j, uiCode ); |
---|
4715 | assert( uiCode <= vps->getMaxTLayers() - 1 ); |
---|
4716 | |
---|
4717 | parseHrdParameters( vps->getBspHrd(j), vps->getCprmsAddPresentFlag(j), vps->getNumSubLayerHrdMinus1(j) ); |
---|
4718 | if( i > 0 && !vps->getCprmsAddPresentFlag(i) ) |
---|
4719 | { |
---|
4720 | // Copy common information parameters |
---|
4721 | if( i == vps->getNumHrdParameters() ) |
---|
4722 | { |
---|
4723 | vps->getBspHrd(j)->copyCommonInformation( vps->getHrdParameters( vps->getNumHrdParameters() - 1 ) ); |
---|
4724 | } |
---|
4725 | else |
---|
4726 | { |
---|
4727 | vps->getBspHrd(j)->copyCommonInformation( vps->getBspHrd( j - 1 ) ); |
---|
4728 | } |
---|
4729 | } |
---|
4730 | } |
---|
4731 | #if VPS_FIX_TO_MATCH_SPEC |
---|
4732 | if( vps->getNumHrdParameters() + vps->getVpsNumAddHrdParams() > 0 ) |
---|
4733 | { |
---|
4734 | #endif |
---|
4735 | for (Int h = 1; h < vps->getNumOutputLayerSets(); h++) |
---|
4736 | { |
---|
4737 | Int lsIdx = vps->getOutputLayerSetIdx(h); |
---|
4738 | READ_UVLC(uiCode, "num_signalled_partitioning_schemes[h]"); vps->setNumSignalledPartitioningSchemes(h, uiCode); |
---|
4739 | #if VPS_FIX_TO_MATCH_SPEC |
---|
4740 | for (Int j = 1; j < vps->getNumSignalledPartitioningSchemes(h) + 1; j++) |
---|
4741 | #else |
---|
4742 | for (Int j = 0; j < vps->getNumSignalledPartitioningSchemes(h); j++) |
---|
4743 | #endif |
---|
4744 | { |
---|
4745 | READ_UVLC(uiCode, "num_partitions_in_scheme_minus1[h][j]"); vps->setNumPartitionsInSchemeMinus1(h, j, uiCode); |
---|
4746 | for (Int k = 0; k <= vps->getNumPartitionsInSchemeMinus1(h, j); k++) |
---|
4747 | { |
---|
4748 | for (Int r = 0; r < vps->getNumLayersInIdList(lsIdx); r++) |
---|
4749 | { |
---|
4750 | READ_FLAG(uiCode, "layer_included_in_partition_flag[h][j][k][r]"); vps->setLayerIncludedInPartitionFlag(h, j, k, r, uiCode ? true : false); |
---|
4751 | } |
---|
4752 | } |
---|
4753 | } |
---|
4754 | for (Int i = 0; i < vps->getNumSignalledPartitioningSchemes(h) + 1; i++) |
---|
4755 | { |
---|
4756 | for (Int t = 0; t <= vps->getMaxSLayersInLayerSetMinus1(lsIdx); t++) |
---|
4757 | { |
---|
4758 | READ_UVLC(uiCode, "num_bsp_schedules_minus1[h][i][t]"); vps->setNumBspSchedulesMinus1(h, i, t, uiCode); |
---|
4759 | for (Int j = 0; j <= vps->getNumBspSchedulesMinus1(h, i, t); j++) |
---|
4760 | { |
---|
4761 | #if VPS_FIX_TO_MATCH_SPEC |
---|
4762 | for( Int k = 0; k <= vps->getNumPartitionsInSchemeMinus1(h, i); k++ ) |
---|
4763 | #else |
---|
4764 | for (Int k = 0; k < vps->getNumPartitionsInSchemeMinus1(h, i); k++) |
---|
4765 | #endif |
---|
4766 | { |
---|
4767 | #if VPS_FIX_TO_MATCH_SPEC |
---|
4768 | if( vps->getNumHrdParameters() + vps->getVpsNumAddHrdParams() > 1 ) |
---|
4769 | { |
---|
4770 | Int numBits = 1; |
---|
4771 | while ((1 << numBits) < (vps->getNumHrdParameters() + vps->getVpsNumAddHrdParams())) |
---|
4772 | { |
---|
4773 | numBits++; |
---|
4774 | } |
---|
4775 | READ_CODE(numBits, uiCode, "bsp_comb_hrd_idx[h][i][t][j][k]"); vps->setBspHrdIdx(h, i, t, j, k, uiCode); |
---|
4776 | } |
---|
4777 | #else |
---|
4778 | READ_UVLC(uiCode, "bsp_comb_hrd_idx[h][i][t][j][k]"); vps->setBspHrdIdx(h, i, t, j, k, uiCode); |
---|
4779 | #endif |
---|
4780 | READ_UVLC(uiCode, "bsp_comb_sched_idx[h][i][t][j][k]"); vps->setBspSchedIdx(h, i, t, j, k, uiCode); |
---|
4781 | } |
---|
4782 | } |
---|
4783 | } |
---|
4784 | } |
---|
4785 | |
---|
4786 | // To be done: Check each layer included in not more than one BSP in every partitioning scheme, |
---|
4787 | // and other related checks associated with layers in bitstream partitions. |
---|
4788 | |
---|
4789 | } |
---|
4790 | #if VPS_FIX_TO_MATCH_SPEC |
---|
4791 | } |
---|
4792 | #endif |
---|
4793 | } |
---|
4794 | #endif |
---|
4795 | #endif |
---|
4796 | //! \} |
---|
4797 | |
---|