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