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