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