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