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