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