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-2013, 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 | |
---|
42 | //! \ingroup TLibDecoder |
---|
43 | //! \{ |
---|
44 | |
---|
45 | #if ENC_DEC_TRACE |
---|
46 | |
---|
47 | Void xTraceSPSHeader (TComSPS *pSPS) |
---|
48 | { |
---|
49 | fprintf( g_hTrace, "=========== Sequence Parameter Set ID: %d ===========\n", pSPS->getSPSId() ); |
---|
50 | } |
---|
51 | |
---|
52 | Void xTracePPSHeader (TComPPS *pPPS) |
---|
53 | { |
---|
54 | fprintf( g_hTrace, "=========== Picture Parameter Set ID: %d ===========\n", pPPS->getPPSId() ); |
---|
55 | } |
---|
56 | |
---|
57 | Void xTraceSliceHeader (TComSlice *pSlice) |
---|
58 | { |
---|
59 | fprintf( g_hTrace, "=========== Slice ===========\n"); |
---|
60 | } |
---|
61 | |
---|
62 | #endif |
---|
63 | |
---|
64 | // ==================================================================================================================== |
---|
65 | // Constructor / destructor / create / destroy |
---|
66 | // ==================================================================================================================== |
---|
67 | |
---|
68 | TDecCavlc::TDecCavlc() |
---|
69 | { |
---|
70 | } |
---|
71 | |
---|
72 | TDecCavlc::~TDecCavlc() |
---|
73 | { |
---|
74 | |
---|
75 | } |
---|
76 | |
---|
77 | // ==================================================================================================================== |
---|
78 | // Public member functions |
---|
79 | // ==================================================================================================================== |
---|
80 | |
---|
81 | void TDecCavlc::parseShortTermRefPicSet( TComSPS* sps, TComReferencePictureSet* rps, Int idx ) |
---|
82 | { |
---|
83 | UInt code; |
---|
84 | UInt interRPSPred; |
---|
85 | if (idx > 0) |
---|
86 | { |
---|
87 | READ_FLAG(interRPSPred, "inter_ref_pic_set_prediction_flag"); rps->setInterRPSPrediction(interRPSPred); |
---|
88 | } |
---|
89 | else |
---|
90 | { |
---|
91 | interRPSPred = false; |
---|
92 | rps->setInterRPSPrediction(false); |
---|
93 | } |
---|
94 | |
---|
95 | if (interRPSPred) |
---|
96 | { |
---|
97 | UInt bit; |
---|
98 | if(idx == sps->getRPSList()->getNumberOfReferencePictureSets()) |
---|
99 | { |
---|
100 | READ_UVLC(code, "delta_idx_minus1" ); // delta index of the Reference Picture Set used for prediction minus 1 |
---|
101 | } |
---|
102 | else |
---|
103 | { |
---|
104 | code = 0; |
---|
105 | } |
---|
106 | 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 |
---|
107 | Int rIdx = idx - 1 - code; |
---|
108 | 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 |
---|
109 | TComReferencePictureSet* rpsRef = sps->getRPSList()->getReferencePictureSet(rIdx); |
---|
110 | Int k = 0, k0 = 0, k1 = 0; |
---|
111 | READ_CODE(1, bit, "delta_rps_sign"); // delta_RPS_sign |
---|
112 | READ_UVLC(code, "abs_delta_rps_minus1"); // absolute delta RPS minus 1 |
---|
113 | Int deltaRPS = (1 - 2 * bit) * (code + 1); // delta_RPS |
---|
114 | for(Int j=0 ; j <= rpsRef->getNumberOfPictures(); j++) |
---|
115 | { |
---|
116 | READ_CODE(1, bit, "used_by_curr_pic_flag" ); //first bit is "1" if Idc is 1 |
---|
117 | Int refIdc = bit; |
---|
118 | if (refIdc == 0) |
---|
119 | { |
---|
120 | READ_CODE(1, bit, "use_delta_flag" ); //second bit is "1" if Idc is 2, "0" otherwise. |
---|
121 | refIdc = bit<<1; //second bit is "1" if refIdc is 2, "0" if refIdc = 0. |
---|
122 | } |
---|
123 | if (refIdc == 1 || refIdc == 2) |
---|
124 | { |
---|
125 | Int deltaPOC = deltaRPS + ((j < rpsRef->getNumberOfPictures())? rpsRef->getDeltaPOC(j) : 0); |
---|
126 | rps->setDeltaPOC(k, deltaPOC); |
---|
127 | rps->setUsed(k, (refIdc == 1)); |
---|
128 | |
---|
129 | if (deltaPOC < 0) |
---|
130 | { |
---|
131 | k0++; |
---|
132 | } |
---|
133 | else |
---|
134 | { |
---|
135 | k1++; |
---|
136 | } |
---|
137 | k++; |
---|
138 | } |
---|
139 | rps->setRefIdc(j,refIdc); |
---|
140 | } |
---|
141 | rps->setNumRefIdc(rpsRef->getNumberOfPictures()+1); |
---|
142 | rps->setNumberOfPictures(k); |
---|
143 | rps->setNumberOfNegativePictures(k0); |
---|
144 | rps->setNumberOfPositivePictures(k1); |
---|
145 | rps->sortDeltaPOC(); |
---|
146 | } |
---|
147 | else |
---|
148 | { |
---|
149 | READ_UVLC(code, "num_negative_pics"); rps->setNumberOfNegativePictures(code); |
---|
150 | READ_UVLC(code, "num_positive_pics"); rps->setNumberOfPositivePictures(code); |
---|
151 | Int prev = 0; |
---|
152 | Int poc; |
---|
153 | for(Int j=0 ; j < rps->getNumberOfNegativePictures(); j++) |
---|
154 | { |
---|
155 | READ_UVLC(code, "delta_poc_s0_minus1"); |
---|
156 | poc = prev-code-1; |
---|
157 | prev = poc; |
---|
158 | rps->setDeltaPOC(j,poc); |
---|
159 | READ_FLAG(code, "used_by_curr_pic_s0_flag"); rps->setUsed(j,code); |
---|
160 | } |
---|
161 | prev = 0; |
---|
162 | for(Int j=rps->getNumberOfNegativePictures(); j < rps->getNumberOfNegativePictures()+rps->getNumberOfPositivePictures(); j++) |
---|
163 | { |
---|
164 | READ_UVLC(code, "delta_poc_s1_minus1"); |
---|
165 | poc = prev+code+1; |
---|
166 | prev = poc; |
---|
167 | rps->setDeltaPOC(j,poc); |
---|
168 | READ_FLAG(code, "used_by_curr_pic_s1_flag"); rps->setUsed(j,code); |
---|
169 | } |
---|
170 | rps->setNumberOfPictures(rps->getNumberOfNegativePictures()+rps->getNumberOfPositivePictures()); |
---|
171 | } |
---|
172 | #if PRINT_RPS_INFO |
---|
173 | rps->printDeltaPOC(); |
---|
174 | #endif |
---|
175 | } |
---|
176 | |
---|
177 | Void TDecCavlc::parsePPS(TComPPS* pcPPS) |
---|
178 | { |
---|
179 | #if ENC_DEC_TRACE |
---|
180 | xTracePPSHeader (pcPPS); |
---|
181 | #endif |
---|
182 | UInt uiCode; |
---|
183 | |
---|
184 | Int iCode; |
---|
185 | |
---|
186 | READ_UVLC( uiCode, "pps_pic_parameter_set_id"); |
---|
187 | assert(uiCode <= 63); |
---|
188 | pcPPS->setPPSId (uiCode); |
---|
189 | |
---|
190 | READ_UVLC( uiCode, "pps_seq_parameter_set_id"); |
---|
191 | assert(uiCode <= 15); |
---|
192 | pcPPS->setSPSId (uiCode); |
---|
193 | |
---|
194 | READ_FLAG( uiCode, "dependent_slice_segments_enabled_flag" ); pcPPS->setDependentSliceSegmentsEnabledFlag ( uiCode == 1 ); |
---|
195 | READ_FLAG( uiCode, "output_flag_present_flag" ); pcPPS->setOutputFlagPresentFlag( uiCode==1 ); |
---|
196 | |
---|
197 | READ_CODE(3, uiCode, "num_extra_slice_header_bits"); pcPPS->setNumExtraSliceHeaderBits(uiCode); |
---|
198 | READ_FLAG ( uiCode, "sign_data_hiding_flag" ); pcPPS->setSignHideFlag( uiCode ); |
---|
199 | |
---|
200 | READ_FLAG( uiCode, "cabac_init_present_flag" ); pcPPS->setCabacInitPresentFlag( uiCode ? true : false ); |
---|
201 | |
---|
202 | READ_UVLC(uiCode, "num_ref_idx_l0_default_active_minus1"); |
---|
203 | assert(uiCode <= 14); |
---|
204 | pcPPS->setNumRefIdxL0DefaultActive(uiCode+1); |
---|
205 | |
---|
206 | READ_UVLC(uiCode, "num_ref_idx_l1_default_active_minus1"); |
---|
207 | assert(uiCode <= 14); |
---|
208 | pcPPS->setNumRefIdxL1DefaultActive(uiCode+1); |
---|
209 | |
---|
210 | READ_SVLC(iCode, "init_qp_minus26" ); pcPPS->setPicInitQPMinus26(iCode); |
---|
211 | READ_FLAG( uiCode, "constrained_intra_pred_flag" ); pcPPS->setConstrainedIntraPred( uiCode ? true : false ); |
---|
212 | READ_FLAG( uiCode, "transform_skip_enabled_flag" ); |
---|
213 | pcPPS->setUseTransformSkip ( uiCode ? true : false ); |
---|
214 | |
---|
215 | READ_FLAG( uiCode, "cu_qp_delta_enabled_flag" ); pcPPS->setUseDQP( uiCode ? true : false ); |
---|
216 | if( pcPPS->getUseDQP() ) |
---|
217 | { |
---|
218 | READ_UVLC( uiCode, "diff_cu_qp_delta_depth" ); |
---|
219 | pcPPS->setMaxCuDQPDepth( uiCode ); |
---|
220 | } |
---|
221 | else |
---|
222 | { |
---|
223 | pcPPS->setMaxCuDQPDepth( 0 ); |
---|
224 | } |
---|
225 | READ_SVLC( iCode, "pps_cb_qp_offset"); |
---|
226 | pcPPS->setChromaCbQpOffset(iCode); |
---|
227 | assert( pcPPS->getChromaCbQpOffset() >= -12 ); |
---|
228 | assert( pcPPS->getChromaCbQpOffset() <= 12 ); |
---|
229 | |
---|
230 | READ_SVLC( iCode, "pps_cr_qp_offset"); |
---|
231 | pcPPS->setChromaCrQpOffset(iCode); |
---|
232 | assert( pcPPS->getChromaCrQpOffset() >= -12 ); |
---|
233 | assert( pcPPS->getChromaCrQpOffset() <= 12 ); |
---|
234 | |
---|
235 | READ_FLAG( uiCode, "pps_slice_chroma_qp_offsets_present_flag" ); |
---|
236 | pcPPS->setSliceChromaQpFlag( uiCode ? true : false ); |
---|
237 | |
---|
238 | READ_FLAG( uiCode, "weighted_pred_flag" ); // Use of Weighting Prediction (P_SLICE) |
---|
239 | pcPPS->setUseWP( uiCode==1 ); |
---|
240 | READ_FLAG( uiCode, "weighted_bipred_flag" ); // Use of Bi-Directional Weighting Prediction (B_SLICE) |
---|
241 | pcPPS->setWPBiPred( uiCode==1 ); |
---|
242 | |
---|
243 | READ_FLAG( uiCode, "transquant_bypass_enable_flag"); |
---|
244 | pcPPS->setTransquantBypassEnableFlag(uiCode ? true : false); |
---|
245 | READ_FLAG( uiCode, "tiles_enabled_flag" ); pcPPS->setTilesEnabledFlag ( uiCode == 1 ); |
---|
246 | READ_FLAG( uiCode, "entropy_coding_sync_enabled_flag" ); pcPPS->setEntropyCodingSyncEnabledFlag( uiCode == 1 ); |
---|
247 | |
---|
248 | if( pcPPS->getTilesEnabledFlag() ) |
---|
249 | { |
---|
250 | READ_UVLC ( uiCode, "num_tile_columns_minus1" ); pcPPS->setNumColumnsMinus1( uiCode ); |
---|
251 | READ_UVLC ( uiCode, "num_tile_rows_minus1" ); pcPPS->setNumRowsMinus1( uiCode ); |
---|
252 | READ_FLAG ( uiCode, "uniform_spacing_flag" ); pcPPS->setUniformSpacingFlag( uiCode ); |
---|
253 | |
---|
254 | if( !pcPPS->getUniformSpacingFlag()) |
---|
255 | { |
---|
256 | UInt* columnWidth = (UInt*)malloc(pcPPS->getNumColumnsMinus1()*sizeof(UInt)); |
---|
257 | for(UInt i=0; i<pcPPS->getNumColumnsMinus1(); i++) |
---|
258 | { |
---|
259 | READ_UVLC( uiCode, "column_width_minus1" ); |
---|
260 | columnWidth[i] = uiCode+1; |
---|
261 | } |
---|
262 | pcPPS->setColumnWidth(columnWidth); |
---|
263 | free(columnWidth); |
---|
264 | |
---|
265 | UInt* rowHeight = (UInt*)malloc(pcPPS->getNumRowsMinus1()*sizeof(UInt)); |
---|
266 | for(UInt i=0; i<pcPPS->getNumRowsMinus1(); i++) |
---|
267 | { |
---|
268 | READ_UVLC( uiCode, "row_height_minus1" ); |
---|
269 | rowHeight[i] = uiCode + 1; |
---|
270 | } |
---|
271 | pcPPS->setRowHeight(rowHeight); |
---|
272 | free(rowHeight); |
---|
273 | } |
---|
274 | |
---|
275 | if(pcPPS->getNumColumnsMinus1() !=0 || pcPPS->getNumRowsMinus1() !=0) |
---|
276 | { |
---|
277 | READ_FLAG ( uiCode, "loop_filter_across_tiles_enabled_flag" ); pcPPS->setLoopFilterAcrossTilesEnabledFlag( uiCode ? true : false ); |
---|
278 | } |
---|
279 | } |
---|
280 | READ_FLAG( uiCode, "loop_filter_across_slices_enabled_flag" ); pcPPS->setLoopFilterAcrossSlicesEnabledFlag( uiCode ? true : false ); |
---|
281 | READ_FLAG( uiCode, "deblocking_filter_control_present_flag" ); pcPPS->setDeblockingFilterControlPresentFlag( uiCode ? true : false ); |
---|
282 | if(pcPPS->getDeblockingFilterControlPresentFlag()) |
---|
283 | { |
---|
284 | READ_FLAG( uiCode, "deblocking_filter_override_enabled_flag" ); pcPPS->setDeblockingFilterOverrideEnabledFlag( uiCode ? true : false ); |
---|
285 | READ_FLAG( uiCode, "pps_disable_deblocking_filter_flag" ); pcPPS->setPicDisableDeblockingFilterFlag(uiCode ? true : false ); |
---|
286 | if(!pcPPS->getPicDisableDeblockingFilterFlag()) |
---|
287 | { |
---|
288 | READ_SVLC ( iCode, "pps_beta_offset_div2" ); pcPPS->setDeblockingFilterBetaOffsetDiv2( iCode ); |
---|
289 | READ_SVLC ( iCode, "pps_tc_offset_div2" ); pcPPS->setDeblockingFilterTcOffsetDiv2( iCode ); |
---|
290 | } |
---|
291 | } |
---|
292 | READ_FLAG( uiCode, "pps_scaling_list_data_present_flag" ); pcPPS->setScalingListPresentFlag( uiCode ? true : false ); |
---|
293 | |
---|
294 | #if IL_SL_SIGNALLING_N0371 |
---|
295 | pcPPS->setPPS( pcPPS->getLayerId(), pcPPS ); |
---|
296 | #endif |
---|
297 | |
---|
298 | if(pcPPS->getScalingListPresentFlag ()) |
---|
299 | { |
---|
300 | #if IL_SL_SIGNALLING_N0371 |
---|
301 | pcPPS->getScalingList()->setLayerId( pcPPS->getLayerId() ); |
---|
302 | |
---|
303 | if( pcPPS->getLayerId() > 0 ) |
---|
304 | { |
---|
305 | READ_FLAG( uiCode, "pps_pred_scaling_list_flag" ); pcPPS->setPredScalingListFlag( uiCode ? true : false ); |
---|
306 | pcPPS->getScalingList()->setPredScalingListFlag( pcPPS->getPredScalingListFlag() ); |
---|
307 | |
---|
308 | if( pcPPS->getPredScalingListFlag() ) |
---|
309 | { |
---|
310 | READ_UVLC ( uiCode, "scaling_list_pps_ref_layer_id" ); pcPPS->setScalingListRefLayerId( uiCode ); |
---|
311 | |
---|
312 | // The value of pps_scaling_list_ref_layer_id shall be in the range of 0 to 62, inclusive |
---|
313 | assert( /*pcPPS->getScalingListRefLayerId() >= 0 &&*/ pcPPS->getScalingListRefLayerId() <= 62 ); |
---|
314 | |
---|
315 | // When avc_base_layer_flag is equal to 1, it is a requirement of bitstream conformance that the value of pps_scaling_list_ref_layer_id shall be greater than 0 |
---|
316 | if( pcPPS->getSPS()->getVPS()->getAvcBaseLayerFlag() ) |
---|
317 | { |
---|
318 | assert( pcPPS->getScalingListRefLayerId() > 0 ); |
---|
319 | } |
---|
320 | |
---|
321 | // It is a requirement of bitstream conformance that, when a PPS with nuh_layer_id equal to nuhLayerIdA is active for a layer with nuh_layer_id equal to nuhLayerIdB and |
---|
322 | // pps_infer_scaling_list_flag in the PPS is equal to 1, pps_infer_scaling_list_flag shall be equal to 0 for the PPS that is active for the layer with nuh_layer_id equal to pps_scaling_list_ref_layer_id |
---|
323 | assert( pcPPS->getPPS( pcPPS->getScalingListRefLayerId() )->getPredScalingListFlag() == false ); |
---|
324 | |
---|
325 | // It is a requirement of bitstream conformance that, when a PPS with nuh_layer_id equal to nuhLayerIdA is active for a layer with nuh_layer_id equal to nuhLayerIdB, |
---|
326 | // the layer with nuh_layer_id equal to pps_scaling_list_ref_layer_id shall be a direct or indirect reference layer of the layer with nuh_layer_id equal to nuhLayerIdB |
---|
327 | assert( pcPPS->getSPS()->getVPS()->getScalingListLayerDependency( pcPPS->getLayerId(), pcPPS->getScalingListRefLayerId() ) == true ); |
---|
328 | |
---|
329 | pcPPS->getScalingList()->setScalingListRefLayerId( pcPPS->getScalingListRefLayerId() ); |
---|
330 | parseScalingList( pcPPS->getScalingList() ); |
---|
331 | } |
---|
332 | else |
---|
333 | { |
---|
334 | parseScalingList( pcPPS->getScalingList() ); |
---|
335 | } |
---|
336 | } |
---|
337 | else |
---|
338 | { |
---|
339 | parseScalingList( pcPPS->getScalingList() ); |
---|
340 | } |
---|
341 | #else |
---|
342 | parseScalingList( pcPPS->getScalingList() ); |
---|
343 | #endif |
---|
344 | } |
---|
345 | |
---|
346 | READ_FLAG( uiCode, "lists_modification_present_flag"); |
---|
347 | pcPPS->setListsModificationPresentFlag(uiCode); |
---|
348 | |
---|
349 | READ_UVLC( uiCode, "log2_parallel_merge_level_minus2"); |
---|
350 | pcPPS->setLog2ParallelMergeLevelMinus2 (uiCode); |
---|
351 | |
---|
352 | READ_FLAG( uiCode, "slice_segment_header_extension_present_flag"); |
---|
353 | pcPPS->setSliceHeaderExtensionPresentFlag(uiCode); |
---|
354 | |
---|
355 | READ_FLAG( uiCode, "pps_extension_flag"); |
---|
356 | if (uiCode) |
---|
357 | { |
---|
358 | while ( xMoreRbspData() ) |
---|
359 | { |
---|
360 | READ_FLAG( uiCode, "pps_extension_data_flag"); |
---|
361 | } |
---|
362 | } |
---|
363 | } |
---|
364 | |
---|
365 | Void TDecCavlc::parseVUI(TComVUI* pcVUI, TComSPS *pcSPS) |
---|
366 | { |
---|
367 | #if ENC_DEC_TRACE |
---|
368 | fprintf( g_hTrace, "----------- vui_parameters -----------\n"); |
---|
369 | #endif |
---|
370 | UInt uiCode; |
---|
371 | |
---|
372 | READ_FLAG( uiCode, "aspect_ratio_info_present_flag"); pcVUI->setAspectRatioInfoPresentFlag(uiCode); |
---|
373 | if (pcVUI->getAspectRatioInfoPresentFlag()) |
---|
374 | { |
---|
375 | READ_CODE(8, uiCode, "aspect_ratio_idc"); pcVUI->setAspectRatioIdc(uiCode); |
---|
376 | if (pcVUI->getAspectRatioIdc() == 255) |
---|
377 | { |
---|
378 | READ_CODE(16, uiCode, "sar_width"); pcVUI->setSarWidth(uiCode); |
---|
379 | READ_CODE(16, uiCode, "sar_height"); pcVUI->setSarHeight(uiCode); |
---|
380 | } |
---|
381 | } |
---|
382 | |
---|
383 | READ_FLAG( uiCode, "overscan_info_present_flag"); pcVUI->setOverscanInfoPresentFlag(uiCode); |
---|
384 | if (pcVUI->getOverscanInfoPresentFlag()) |
---|
385 | { |
---|
386 | READ_FLAG( uiCode, "overscan_appropriate_flag"); pcVUI->setOverscanAppropriateFlag(uiCode); |
---|
387 | } |
---|
388 | |
---|
389 | READ_FLAG( uiCode, "video_signal_type_present_flag"); pcVUI->setVideoSignalTypePresentFlag(uiCode); |
---|
390 | if (pcVUI->getVideoSignalTypePresentFlag()) |
---|
391 | { |
---|
392 | READ_CODE(3, uiCode, "video_format"); pcVUI->setVideoFormat(uiCode); |
---|
393 | READ_FLAG( uiCode, "video_full_range_flag"); pcVUI->setVideoFullRangeFlag(uiCode); |
---|
394 | READ_FLAG( uiCode, "colour_description_present_flag"); pcVUI->setColourDescriptionPresentFlag(uiCode); |
---|
395 | if (pcVUI->getColourDescriptionPresentFlag()) |
---|
396 | { |
---|
397 | READ_CODE(8, uiCode, "colour_primaries"); pcVUI->setColourPrimaries(uiCode); |
---|
398 | READ_CODE(8, uiCode, "transfer_characteristics"); pcVUI->setTransferCharacteristics(uiCode); |
---|
399 | READ_CODE(8, uiCode, "matrix_coefficients"); pcVUI->setMatrixCoefficients(uiCode); |
---|
400 | } |
---|
401 | } |
---|
402 | |
---|
403 | READ_FLAG( uiCode, "chroma_loc_info_present_flag"); pcVUI->setChromaLocInfoPresentFlag(uiCode); |
---|
404 | if (pcVUI->getChromaLocInfoPresentFlag()) |
---|
405 | { |
---|
406 | READ_UVLC( uiCode, "chroma_sample_loc_type_top_field" ); pcVUI->setChromaSampleLocTypeTopField(uiCode); |
---|
407 | READ_UVLC( uiCode, "chroma_sample_loc_type_bottom_field" ); pcVUI->setChromaSampleLocTypeBottomField(uiCode); |
---|
408 | } |
---|
409 | |
---|
410 | READ_FLAG( uiCode, "neutral_chroma_indication_flag"); pcVUI->setNeutralChromaIndicationFlag(uiCode); |
---|
411 | |
---|
412 | READ_FLAG( uiCode, "field_seq_flag"); pcVUI->setFieldSeqFlag(uiCode); |
---|
413 | |
---|
414 | READ_FLAG(uiCode, "frame_field_info_present_flag"); pcVUI->setFrameFieldInfoPresentFlag(uiCode); |
---|
415 | |
---|
416 | READ_FLAG( uiCode, "default_display_window_flag"); |
---|
417 | if (uiCode != 0) |
---|
418 | { |
---|
419 | Window &defDisp = pcVUI->getDefaultDisplayWindow(); |
---|
420 | READ_UVLC( uiCode, "def_disp_win_left_offset" ); defDisp.setWindowLeftOffset ( uiCode * TComSPS::getWinUnitX( pcSPS->getChromaFormatIdc()) ); |
---|
421 | READ_UVLC( uiCode, "def_disp_win_right_offset" ); defDisp.setWindowRightOffset ( uiCode * TComSPS::getWinUnitX( pcSPS->getChromaFormatIdc()) ); |
---|
422 | READ_UVLC( uiCode, "def_disp_win_top_offset" ); defDisp.setWindowTopOffset ( uiCode * TComSPS::getWinUnitY( pcSPS->getChromaFormatIdc()) ); |
---|
423 | READ_UVLC( uiCode, "def_disp_win_bottom_offset" ); defDisp.setWindowBottomOffset( uiCode * TComSPS::getWinUnitY( pcSPS->getChromaFormatIdc()) ); |
---|
424 | } |
---|
425 | TimingInfo *timingInfo = pcVUI->getTimingInfo(); |
---|
426 | READ_FLAG( uiCode, "vui_timing_info_present_flag"); timingInfo->setTimingInfoPresentFlag (uiCode ? true : false); |
---|
427 | #if TIMING_INFO_NONZERO_LAYERID_SPS |
---|
428 | if( pcSPS->getLayerId() > 0 ) |
---|
429 | { |
---|
430 | assert( timingInfo->getTimingInfoPresentFlag() == false ); |
---|
431 | } |
---|
432 | #endif |
---|
433 | if(timingInfo->getTimingInfoPresentFlag()) |
---|
434 | { |
---|
435 | READ_CODE( 32, uiCode, "vui_num_units_in_tick"); timingInfo->setNumUnitsInTick (uiCode); |
---|
436 | READ_CODE( 32, uiCode, "vui_time_scale"); timingInfo->setTimeScale (uiCode); |
---|
437 | READ_FLAG( uiCode, "vui_poc_proportional_to_timing_flag"); timingInfo->setPocProportionalToTimingFlag(uiCode ? true : false); |
---|
438 | if(timingInfo->getPocProportionalToTimingFlag()) |
---|
439 | { |
---|
440 | READ_UVLC( uiCode, "vui_num_ticks_poc_diff_one_minus1"); timingInfo->setNumTicksPocDiffOneMinus1 (uiCode); |
---|
441 | } |
---|
442 | READ_FLAG( uiCode, "hrd_parameters_present_flag"); pcVUI->setHrdParametersPresentFlag(uiCode); |
---|
443 | if( pcVUI->getHrdParametersPresentFlag() ) |
---|
444 | { |
---|
445 | parseHrdParameters( pcVUI->getHrdParameters(), 1, pcSPS->getMaxTLayers() - 1 ); |
---|
446 | } |
---|
447 | } |
---|
448 | READ_FLAG( uiCode, "bitstream_restriction_flag"); pcVUI->setBitstreamRestrictionFlag(uiCode); |
---|
449 | if (pcVUI->getBitstreamRestrictionFlag()) |
---|
450 | { |
---|
451 | READ_FLAG( uiCode, "tiles_fixed_structure_flag"); pcVUI->setTilesFixedStructureFlag(uiCode); |
---|
452 | #if M0464_TILE_BOUNDARY_ALIGNED_FLAG |
---|
453 | if ( pcSPS->getLayerId() > 0 ) |
---|
454 | { |
---|
455 | READ_FLAG( uiCode, "tile_boundaries_aligned_flag" ); pcVUI->setTileBoundariesAlignedFlag( uiCode == 1 ); |
---|
456 | } |
---|
457 | #endif |
---|
458 | READ_FLAG( uiCode, "motion_vectors_over_pic_boundaries_flag"); pcVUI->setMotionVectorsOverPicBoundariesFlag(uiCode); |
---|
459 | READ_FLAG( uiCode, "restricted_ref_pic_lists_flag"); pcVUI->setRestrictedRefPicListsFlag(uiCode); |
---|
460 | READ_UVLC( uiCode, "min_spatial_segmentation_idc"); pcVUI->setMinSpatialSegmentationIdc(uiCode); |
---|
461 | assert(uiCode < 4096); |
---|
462 | READ_UVLC( uiCode, "max_bytes_per_pic_denom" ); pcVUI->setMaxBytesPerPicDenom(uiCode); |
---|
463 | READ_UVLC( uiCode, "max_bits_per_mincu_denom" ); pcVUI->setMaxBitsPerMinCuDenom(uiCode); |
---|
464 | READ_UVLC( uiCode, "log2_max_mv_length_horizontal" ); pcVUI->setLog2MaxMvLengthHorizontal(uiCode); |
---|
465 | READ_UVLC( uiCode, "log2_max_mv_length_vertical" ); pcVUI->setLog2MaxMvLengthVertical(uiCode); |
---|
466 | } |
---|
467 | } |
---|
468 | |
---|
469 | Void TDecCavlc::parseHrdParameters(TComHRD *hrd, Bool commonInfPresentFlag, UInt maxNumSubLayersMinus1) |
---|
470 | { |
---|
471 | UInt uiCode; |
---|
472 | if( commonInfPresentFlag ) |
---|
473 | { |
---|
474 | READ_FLAG( uiCode, "nal_hrd_parameters_present_flag" ); hrd->setNalHrdParametersPresentFlag( uiCode == 1 ? true : false ); |
---|
475 | READ_FLAG( uiCode, "vcl_hrd_parameters_present_flag" ); hrd->setVclHrdParametersPresentFlag( uiCode == 1 ? true : false ); |
---|
476 | if( hrd->getNalHrdParametersPresentFlag() || hrd->getVclHrdParametersPresentFlag() ) |
---|
477 | { |
---|
478 | READ_FLAG( uiCode, "sub_pic_cpb_params_present_flag" ); hrd->setSubPicCpbParamsPresentFlag( uiCode == 1 ? true : false ); |
---|
479 | if( hrd->getSubPicCpbParamsPresentFlag() ) |
---|
480 | { |
---|
481 | READ_CODE( 8, uiCode, "tick_divisor_minus2" ); hrd->setTickDivisorMinus2( uiCode ); |
---|
482 | READ_CODE( 5, uiCode, "du_cpb_removal_delay_length_minus1" ); hrd->setDuCpbRemovalDelayLengthMinus1( uiCode ); |
---|
483 | READ_FLAG( uiCode, "sub_pic_cpb_params_in_pic_timing_sei_flag" ); hrd->setSubPicCpbParamsInPicTimingSEIFlag( uiCode == 1 ? true : false ); |
---|
484 | READ_CODE( 5, uiCode, "dpb_output_delay_du_length_minus1" ); hrd->setDpbOutputDelayDuLengthMinus1( uiCode ); |
---|
485 | } |
---|
486 | READ_CODE( 4, uiCode, "bit_rate_scale" ); hrd->setBitRateScale( uiCode ); |
---|
487 | READ_CODE( 4, uiCode, "cpb_size_scale" ); hrd->setCpbSizeScale( uiCode ); |
---|
488 | if( hrd->getSubPicCpbParamsPresentFlag() ) |
---|
489 | { |
---|
490 | READ_CODE( 4, uiCode, "cpb_size_du_scale" ); hrd->setDuCpbSizeScale( uiCode ); |
---|
491 | } |
---|
492 | READ_CODE( 5, uiCode, "initial_cpb_removal_delay_length_minus1" ); hrd->setInitialCpbRemovalDelayLengthMinus1( uiCode ); |
---|
493 | READ_CODE( 5, uiCode, "au_cpb_removal_delay_length_minus1" ); hrd->setCpbRemovalDelayLengthMinus1( uiCode ); |
---|
494 | READ_CODE( 5, uiCode, "dpb_output_delay_length_minus1" ); hrd->setDpbOutputDelayLengthMinus1( uiCode ); |
---|
495 | } |
---|
496 | } |
---|
497 | Int i, j, nalOrVcl; |
---|
498 | for( i = 0; i <= maxNumSubLayersMinus1; i ++ ) |
---|
499 | { |
---|
500 | READ_FLAG( uiCode, "fixed_pic_rate_general_flag" ); hrd->setFixedPicRateFlag( i, uiCode == 1 ? true : false ); |
---|
501 | if( !hrd->getFixedPicRateFlag( i ) ) |
---|
502 | { |
---|
503 | READ_FLAG( uiCode, "fixed_pic_rate_within_cvs_flag" ); hrd->setFixedPicRateWithinCvsFlag( i, uiCode == 1 ? true : false ); |
---|
504 | } |
---|
505 | else |
---|
506 | { |
---|
507 | hrd->setFixedPicRateWithinCvsFlag( i, true ); |
---|
508 | } |
---|
509 | hrd->setLowDelayHrdFlag( i, 0 ); // Infered to be 0 when not present |
---|
510 | hrd->setCpbCntMinus1 ( i, 0 ); // Infered to be 0 when not present |
---|
511 | if( hrd->getFixedPicRateWithinCvsFlag( i ) ) |
---|
512 | { |
---|
513 | READ_UVLC( uiCode, "elemental_duration_in_tc_minus1" ); hrd->setPicDurationInTcMinus1( i, uiCode ); |
---|
514 | } |
---|
515 | else |
---|
516 | { |
---|
517 | READ_FLAG( uiCode, "low_delay_hrd_flag" ); hrd->setLowDelayHrdFlag( i, uiCode == 1 ? true : false ); |
---|
518 | } |
---|
519 | if (!hrd->getLowDelayHrdFlag( i )) |
---|
520 | { |
---|
521 | READ_UVLC( uiCode, "cpb_cnt_minus1" ); hrd->setCpbCntMinus1( i, uiCode ); |
---|
522 | } |
---|
523 | for( nalOrVcl = 0; nalOrVcl < 2; nalOrVcl ++ ) |
---|
524 | { |
---|
525 | if( ( ( nalOrVcl == 0 ) && ( hrd->getNalHrdParametersPresentFlag() ) ) || |
---|
526 | ( ( nalOrVcl == 1 ) && ( hrd->getVclHrdParametersPresentFlag() ) ) ) |
---|
527 | { |
---|
528 | for( j = 0; j <= ( hrd->getCpbCntMinus1( i ) ); j ++ ) |
---|
529 | { |
---|
530 | READ_UVLC( uiCode, "bit_rate_value_minus1" ); hrd->setBitRateValueMinus1( i, j, nalOrVcl, uiCode ); |
---|
531 | READ_UVLC( uiCode, "cpb_size_value_minus1" ); hrd->setCpbSizeValueMinus1( i, j, nalOrVcl, uiCode ); |
---|
532 | if( hrd->getSubPicCpbParamsPresentFlag() ) |
---|
533 | { |
---|
534 | READ_UVLC( uiCode, "cpb_size_du_value_minus1" ); hrd->setDuCpbSizeValueMinus1( i, j, nalOrVcl, uiCode ); |
---|
535 | READ_UVLC( uiCode, "bit_rate_du_value_minus1" ); hrd->setDuBitRateValueMinus1( i, j, nalOrVcl, uiCode ); |
---|
536 | } |
---|
537 | READ_FLAG( uiCode, "cbr_flag" ); hrd->setCbrFlag( i, j, nalOrVcl, uiCode == 1 ? true : false ); |
---|
538 | } |
---|
539 | } |
---|
540 | } |
---|
541 | } |
---|
542 | } |
---|
543 | |
---|
544 | #if SPS_SUB_LAYER_INFO |
---|
545 | Void TDecCavlc::parseSPS(TComSPS* pcSPS, ParameterSetManagerDecoder *parameterSetManager) |
---|
546 | #else |
---|
547 | Void TDecCavlc::parseSPS(TComSPS* pcSPS) |
---|
548 | #endif |
---|
549 | { |
---|
550 | #if ENC_DEC_TRACE |
---|
551 | xTraceSPSHeader (pcSPS); |
---|
552 | #endif |
---|
553 | |
---|
554 | UInt uiCode; |
---|
555 | READ_CODE( 4, uiCode, "sps_video_parameter_set_id"); pcSPS->setVPSId ( uiCode ); |
---|
556 | #if SPS_SUB_LAYER_INFO |
---|
557 | if(pcSPS->getLayerId() == 0) |
---|
558 | { |
---|
559 | #endif |
---|
560 | READ_CODE( 3, uiCode, "sps_max_sub_layers_minus1" ); pcSPS->setMaxTLayers ( uiCode+1 ); |
---|
561 | assert(uiCode <= 6); |
---|
562 | |
---|
563 | READ_FLAG( uiCode, "sps_temporal_id_nesting_flag" ); pcSPS->setTemporalIdNestingFlag ( uiCode > 0 ? true : false ); |
---|
564 | #if SPS_SUB_LAYER_INFO |
---|
565 | } |
---|
566 | else |
---|
567 | { |
---|
568 | pcSPS->setMaxTLayers ( parameterSetManager->getPrefetchedVPS(pcSPS->getVPSId())->getMaxTLayers() ); |
---|
569 | pcSPS->setTemporalIdNestingFlag( parameterSetManager->getPrefetchedVPS(pcSPS->getVPSId())->getTemporalNestingFlag() ); |
---|
570 | } |
---|
571 | #endif |
---|
572 | #if IL_SL_SIGNALLING_N0371 |
---|
573 | pcSPS->setVPS( parameterSetManager->getPrefetchedVPS(pcSPS->getVPSId()) ); |
---|
574 | pcSPS->setSPS( pcSPS->getLayerId(), pcSPS ); |
---|
575 | #endif |
---|
576 | if ( pcSPS->getMaxTLayers() == 1 ) |
---|
577 | { |
---|
578 | // sps_temporal_id_nesting_flag must be 1 when sps_max_sub_layers_minus1 is 0 |
---|
579 | #if SPS_SUB_LAYER_INFO |
---|
580 | assert( pcSPS->getTemporalIdNestingFlag() == true ); |
---|
581 | #else |
---|
582 | assert( uiCode == 1 ); |
---|
583 | #endif |
---|
584 | } |
---|
585 | #ifdef SPS_PTL_FIX |
---|
586 | if ( pcSPS->getLayerId() == 0) |
---|
587 | { |
---|
588 | parsePTL(pcSPS->getPTL(), 1, pcSPS->getMaxTLayers() - 1); |
---|
589 | } |
---|
590 | #else |
---|
591 | parsePTL(pcSPS->getPTL(), 1, pcSPS->getMaxTLayers() - 1); |
---|
592 | #endif |
---|
593 | |
---|
594 | READ_UVLC( uiCode, "sps_seq_parameter_set_id" ); pcSPS->setSPSId( uiCode ); |
---|
595 | assert(uiCode <= 15); |
---|
596 | |
---|
597 | #if REPN_FORMAT_IN_VPS |
---|
598 | if( pcSPS->getLayerId() > 0 ) |
---|
599 | { |
---|
600 | READ_FLAG( uiCode, "update_rep_format_flag" ); |
---|
601 | pcSPS->setUpdateRepFormatFlag( uiCode ? true : false ); |
---|
602 | } |
---|
603 | else |
---|
604 | { |
---|
605 | pcSPS->setUpdateRepFormatFlag( true ); |
---|
606 | } |
---|
607 | if( pcSPS->getLayerId() == 0 || pcSPS->getUpdateRepFormatFlag() ) |
---|
608 | { |
---|
609 | #endif |
---|
610 | READ_UVLC( uiCode, "chroma_format_idc" ); pcSPS->setChromaFormatIdc( uiCode ); |
---|
611 | assert(uiCode <= 3); |
---|
612 | // 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 |
---|
613 | assert (uiCode == 1); |
---|
614 | if( uiCode == 3 ) |
---|
615 | { |
---|
616 | READ_FLAG( uiCode, "separate_colour_plane_flag"); assert(uiCode == 0); |
---|
617 | } |
---|
618 | |
---|
619 | READ_UVLC ( uiCode, "pic_width_in_luma_samples" ); pcSPS->setPicWidthInLumaSamples ( uiCode ); |
---|
620 | READ_UVLC ( uiCode, "pic_height_in_luma_samples" ); pcSPS->setPicHeightInLumaSamples( uiCode ); |
---|
621 | #if REPN_FORMAT_IN_VPS |
---|
622 | } |
---|
623 | #endif |
---|
624 | READ_FLAG( uiCode, "conformance_window_flag"); |
---|
625 | if (uiCode != 0) |
---|
626 | { |
---|
627 | Window &conf = pcSPS->getConformanceWindow(); |
---|
628 | #if REPN_FORMAT_IN_VPS |
---|
629 | READ_UVLC( uiCode, "conf_win_left_offset" ); conf.setWindowLeftOffset ( uiCode ); |
---|
630 | READ_UVLC( uiCode, "conf_win_right_offset" ); conf.setWindowRightOffset ( uiCode ); |
---|
631 | READ_UVLC( uiCode, "conf_win_top_offset" ); conf.setWindowTopOffset ( uiCode ); |
---|
632 | READ_UVLC( uiCode, "conf_win_bottom_offset" ); conf.setWindowBottomOffset( uiCode ); |
---|
633 | #else |
---|
634 | READ_UVLC( uiCode, "conf_win_left_offset" ); conf.setWindowLeftOffset ( uiCode * TComSPS::getWinUnitX( pcSPS->getChromaFormatIdc() ) ); |
---|
635 | READ_UVLC( uiCode, "conf_win_right_offset" ); conf.setWindowRightOffset ( uiCode * TComSPS::getWinUnitX( pcSPS->getChromaFormatIdc() ) ); |
---|
636 | READ_UVLC( uiCode, "conf_win_top_offset" ); conf.setWindowTopOffset ( uiCode * TComSPS::getWinUnitY( pcSPS->getChromaFormatIdc() ) ); |
---|
637 | READ_UVLC( uiCode, "conf_win_bottom_offset" ); conf.setWindowBottomOffset( uiCode * TComSPS::getWinUnitY( pcSPS->getChromaFormatIdc() ) ); |
---|
638 | #endif |
---|
639 | } |
---|
640 | #if REPN_FORMAT_IN_VPS |
---|
641 | if( pcSPS->getLayerId() == 0 || pcSPS->getUpdateRepFormatFlag() ) |
---|
642 | { |
---|
643 | #endif |
---|
644 | READ_UVLC( uiCode, "bit_depth_luma_minus8" ); |
---|
645 | assert(uiCode <= 6); |
---|
646 | pcSPS->setBitDepthY( uiCode + 8 ); |
---|
647 | pcSPS->setQpBDOffsetY( (Int) (6*uiCode) ); |
---|
648 | |
---|
649 | READ_UVLC( uiCode, "bit_depth_chroma_minus8" ); |
---|
650 | assert(uiCode <= 6); |
---|
651 | pcSPS->setBitDepthC( uiCode + 8 ); |
---|
652 | pcSPS->setQpBDOffsetC( (Int) (6*uiCode) ); |
---|
653 | #if REPN_FORMAT_IN_VPS |
---|
654 | } |
---|
655 | #endif |
---|
656 | READ_UVLC( uiCode, "log2_max_pic_order_cnt_lsb_minus4" ); pcSPS->setBitsForPOC( 4 + uiCode ); |
---|
657 | assert(uiCode <= 12); |
---|
658 | |
---|
659 | UInt subLayerOrderingInfoPresentFlag; |
---|
660 | READ_FLAG(subLayerOrderingInfoPresentFlag, "sps_sub_layer_ordering_info_present_flag"); |
---|
661 | |
---|
662 | for(UInt i=0; i <= pcSPS->getMaxTLayers()-1; i++) |
---|
663 | { |
---|
664 | READ_UVLC ( uiCode, "sps_max_dec_pic_buffering_minus1"); |
---|
665 | pcSPS->setMaxDecPicBuffering( uiCode + 1, i); |
---|
666 | READ_UVLC ( uiCode, "sps_num_reorder_pics" ); |
---|
667 | pcSPS->setNumReorderPics(uiCode, i); |
---|
668 | READ_UVLC ( uiCode, "sps_max_latency_increase_plus1"); |
---|
669 | pcSPS->setMaxLatencyIncrease( uiCode, i ); |
---|
670 | |
---|
671 | if (!subLayerOrderingInfoPresentFlag) |
---|
672 | { |
---|
673 | for (i++; i <= pcSPS->getMaxTLayers()-1; i++) |
---|
674 | { |
---|
675 | pcSPS->setMaxDecPicBuffering(pcSPS->getMaxDecPicBuffering(0), i); |
---|
676 | pcSPS->setNumReorderPics(pcSPS->getNumReorderPics(0), i); |
---|
677 | pcSPS->setMaxLatencyIncrease(pcSPS->getMaxLatencyIncrease(0), i); |
---|
678 | } |
---|
679 | break; |
---|
680 | } |
---|
681 | } |
---|
682 | |
---|
683 | READ_UVLC( uiCode, "log2_min_coding_block_size_minus3" ); |
---|
684 | Int log2MinCUSize = uiCode + 3; |
---|
685 | pcSPS->setLog2MinCodingBlockSize(log2MinCUSize); |
---|
686 | READ_UVLC( uiCode, "log2_diff_max_min_coding_block_size" ); |
---|
687 | pcSPS->setLog2DiffMaxMinCodingBlockSize(uiCode); |
---|
688 | Int maxCUDepthDelta = uiCode; |
---|
689 | pcSPS->setMaxCUWidth ( 1<<(log2MinCUSize + maxCUDepthDelta) ); |
---|
690 | pcSPS->setMaxCUHeight ( 1<<(log2MinCUSize + maxCUDepthDelta) ); |
---|
691 | READ_UVLC( uiCode, "log2_min_transform_block_size_minus2" ); pcSPS->setQuadtreeTULog2MinSize( uiCode + 2 ); |
---|
692 | |
---|
693 | READ_UVLC( uiCode, "log2_diff_max_min_transform_block_size" ); pcSPS->setQuadtreeTULog2MaxSize( uiCode + pcSPS->getQuadtreeTULog2MinSize() ); |
---|
694 | pcSPS->setMaxTrSize( 1<<(uiCode + pcSPS->getQuadtreeTULog2MinSize()) ); |
---|
695 | |
---|
696 | READ_UVLC( uiCode, "max_transform_hierarchy_depth_inter" ); pcSPS->setQuadtreeTUMaxDepthInter( uiCode+1 ); |
---|
697 | READ_UVLC( uiCode, "max_transform_hierarchy_depth_intra" ); pcSPS->setQuadtreeTUMaxDepthIntra( uiCode+1 ); |
---|
698 | |
---|
699 | Int addCuDepth = max (0, log2MinCUSize - (Int)pcSPS->getQuadtreeTULog2MinSize() ); |
---|
700 | pcSPS->setMaxCUDepth( maxCUDepthDelta + addCuDepth ); |
---|
701 | READ_FLAG( uiCode, "scaling_list_enabled_flag" ); pcSPS->setScalingListFlag ( uiCode ); |
---|
702 | |
---|
703 | if(pcSPS->getScalingListFlag()) |
---|
704 | { |
---|
705 | READ_FLAG( uiCode, "sps_scaling_list_data_present_flag" ); pcSPS->setScalingListPresentFlag ( uiCode ); |
---|
706 | if(pcSPS->getScalingListPresentFlag ()) |
---|
707 | { |
---|
708 | |
---|
709 | #if IL_SL_SIGNALLING_N0371 |
---|
710 | pcSPS->getScalingList()->setLayerId( pcSPS->getLayerId() ); |
---|
711 | |
---|
712 | if( pcSPS->getLayerId() > 0 ) |
---|
713 | { |
---|
714 | READ_FLAG( uiCode, "sps_pred_scaling_list_flag" ); pcSPS->setPredScalingListFlag ( uiCode ); |
---|
715 | pcSPS->getScalingList()->setPredScalingListFlag( pcSPS->getPredScalingListFlag() ); |
---|
716 | |
---|
717 | if( pcSPS->getPredScalingListFlag() ) |
---|
718 | { |
---|
719 | READ_UVLC( uiCode, "scaling_list_sps_ref_layer_id" ); pcSPS->setScalingListRefLayerId( uiCode ); |
---|
720 | |
---|
721 | // The value of sps_scaling_list_ref_layer_id shall be in the range of 0 to 62, inclusive |
---|
722 | assert( /*pcSPS->getScalingListRefLayerId() >= 0 &&*/ pcSPS->getScalingListRefLayerId() <= 62 ); |
---|
723 | |
---|
724 | // When avc_base_layer_flag is equal to 1, it is a requirement of bitstream conformance that the value of sps_scaling_list_ref_layer_id shall be greater than 0 |
---|
725 | if( pcSPS->getVPS()->getAvcBaseLayerFlag() ) |
---|
726 | { |
---|
727 | assert( pcSPS->getScalingListRefLayerId() > 0 ); |
---|
728 | } |
---|
729 | |
---|
730 | // It is a requirement of bitstream conformance that, when an SPS with nuh_layer_id equal to nuhLayerIdA is active for a layer with nuh_layer_id equal to nuhLayerIdB and |
---|
731 | // sps_infer_scaling_list_flag in the SPS is equal to 1, sps_infer_scaling_list_flag shall be equal to 0 for the SPS that is active for the layer with nuh_layer_id equal to sps_scaling_list_ref_layer_id |
---|
732 | assert( pcSPS->getSPS( pcSPS->getScalingListRefLayerId() )->getPredScalingListFlag() == false ); |
---|
733 | |
---|
734 | // It is a requirement of bitstream conformance that, when an SPS with nuh_layer_id equal to nuhLayerIdA is active for a layer with nuh_layer_id equal to nuhLayerIdB, |
---|
735 | // the layer with nuh_layer_id equal to sps_scaling_list_ref_layer_id shall be a direct or indirect reference layer of the layer with nuh_layer_id equal to nuhLayerIdB |
---|
736 | assert( pcSPS->getVPS()->getScalingListLayerDependency( pcSPS->getLayerId(), pcSPS->getScalingListRefLayerId() ) == true ); |
---|
737 | |
---|
738 | pcSPS->getScalingList()->setScalingListRefLayerId( pcSPS->getScalingListRefLayerId() ); |
---|
739 | parseScalingList( pcSPS->getScalingList() ); |
---|
740 | } |
---|
741 | else |
---|
742 | { |
---|
743 | parseScalingList( pcSPS->getScalingList() ); |
---|
744 | } |
---|
745 | } |
---|
746 | else |
---|
747 | { |
---|
748 | parseScalingList( pcSPS->getScalingList() ); |
---|
749 | } |
---|
750 | #else |
---|
751 | parseScalingList( pcSPS->getScalingList() ); |
---|
752 | #endif |
---|
753 | |
---|
754 | } |
---|
755 | } |
---|
756 | READ_FLAG( uiCode, "amp_enabled_flag" ); pcSPS->setUseAMP( uiCode ); |
---|
757 | READ_FLAG( uiCode, "sample_adaptive_offset_enabled_flag" ); pcSPS->setUseSAO ( uiCode ? true : false ); |
---|
758 | |
---|
759 | READ_FLAG( uiCode, "pcm_enabled_flag" ); pcSPS->setUsePCM( uiCode ? true : false ); |
---|
760 | if( pcSPS->getUsePCM() ) |
---|
761 | { |
---|
762 | READ_CODE( 4, uiCode, "pcm_sample_bit_depth_luma_minus1" ); pcSPS->setPCMBitDepthLuma ( 1 + uiCode ); |
---|
763 | READ_CODE( 4, uiCode, "pcm_sample_bit_depth_chroma_minus1" ); pcSPS->setPCMBitDepthChroma ( 1 + uiCode ); |
---|
764 | READ_UVLC( uiCode, "log2_min_pcm_luma_coding_block_size_minus3" ); pcSPS->setPCMLog2MinSize (uiCode+3); |
---|
765 | READ_UVLC( uiCode, "log2_diff_max_min_pcm_luma_coding_block_size" ); pcSPS->setPCMLog2MaxSize ( uiCode+pcSPS->getPCMLog2MinSize() ); |
---|
766 | READ_FLAG( uiCode, "pcm_loop_filter_disable_flag" ); pcSPS->setPCMFilterDisableFlag ( uiCode ? true : false ); |
---|
767 | } |
---|
768 | |
---|
769 | READ_UVLC( uiCode, "num_short_term_ref_pic_sets" ); |
---|
770 | assert(uiCode <= 64); |
---|
771 | pcSPS->createRPSList(uiCode); |
---|
772 | |
---|
773 | TComRPSList* rpsList = pcSPS->getRPSList(); |
---|
774 | TComReferencePictureSet* rps; |
---|
775 | |
---|
776 | for(UInt i=0; i< rpsList->getNumberOfReferencePictureSets(); i++) |
---|
777 | { |
---|
778 | rps = rpsList->getReferencePictureSet(i); |
---|
779 | parseShortTermRefPicSet(pcSPS,rps,i); |
---|
780 | } |
---|
781 | READ_FLAG( uiCode, "long_term_ref_pics_present_flag" ); pcSPS->setLongTermRefsPresent(uiCode); |
---|
782 | if (pcSPS->getLongTermRefsPresent()) |
---|
783 | { |
---|
784 | READ_UVLC( uiCode, "num_long_term_ref_pic_sps" ); |
---|
785 | pcSPS->setNumLongTermRefPicSPS(uiCode); |
---|
786 | for (UInt k = 0; k < pcSPS->getNumLongTermRefPicSPS(); k++) |
---|
787 | { |
---|
788 | READ_CODE( pcSPS->getBitsForPOC(), uiCode, "lt_ref_pic_poc_lsb_sps" ); |
---|
789 | pcSPS->setLtRefPicPocLsbSps(k, uiCode); |
---|
790 | READ_FLAG( uiCode, "used_by_curr_pic_lt_sps_flag[i]"); |
---|
791 | pcSPS->setUsedByCurrPicLtSPSFlag(k, uiCode?1:0); |
---|
792 | } |
---|
793 | } |
---|
794 | READ_FLAG( uiCode, "sps_temporal_mvp_enable_flag" ); pcSPS->setTMVPFlagsPresent(uiCode); |
---|
795 | #if REF_IDX_MFM |
---|
796 | #if !M0457_COL_PICTURE_SIGNALING |
---|
797 | if(pcSPS->getLayerId() > 0) |
---|
798 | { |
---|
799 | READ_FLAG( uiCode, "sps_enh_mfm_enable_flag" ); |
---|
800 | pcSPS->setMFMEnabledFlag( uiCode ? true : false ); |
---|
801 | } |
---|
802 | #endif |
---|
803 | #endif |
---|
804 | READ_FLAG( uiCode, "sps_strong_intra_smoothing_enable_flag" ); pcSPS->setUseStrongIntraSmoothing(uiCode); |
---|
805 | |
---|
806 | READ_FLAG( uiCode, "vui_parameters_present_flag" ); pcSPS->setVuiParametersPresentFlag(uiCode); |
---|
807 | |
---|
808 | if (pcSPS->getVuiParametersPresentFlag()) |
---|
809 | { |
---|
810 | parseVUI(pcSPS->getVuiParameters(), pcSPS); |
---|
811 | } |
---|
812 | |
---|
813 | READ_FLAG( uiCode, "sps_extension_flag"); |
---|
814 | if (uiCode) |
---|
815 | { |
---|
816 | #if SPS_EXTENSION |
---|
817 | parseSPSExtension( pcSPS ); |
---|
818 | READ_FLAG( uiCode, "sps_extension2_flag"); |
---|
819 | if(uiCode) |
---|
820 | { |
---|
821 | #endif |
---|
822 | while ( xMoreRbspData() ) |
---|
823 | { |
---|
824 | READ_FLAG( uiCode, "sps_extension_data_flag"); |
---|
825 | } |
---|
826 | #if SPS_EXTENSION |
---|
827 | } |
---|
828 | #endif |
---|
829 | } |
---|
830 | } |
---|
831 | |
---|
832 | #if SPS_EXTENSION |
---|
833 | Void TDecCavlc::parseSPSExtension( TComSPS* pcSPS ) |
---|
834 | { |
---|
835 | UInt uiCode; |
---|
836 | // more syntax elements to be parsed here |
---|
837 | |
---|
838 | #if VERT_MV_CONSTRAINT |
---|
839 | READ_FLAG( uiCode, "inter_view_mv_vert_constraint_flag" ); |
---|
840 | // Vertical MV component restriction is not used in SHVC CTC |
---|
841 | assert( uiCode == 0 ); |
---|
842 | #endif |
---|
843 | #if SCALED_REF_LAYER_OFFSETS |
---|
844 | if( pcSPS->getLayerId() > 0 ) |
---|
845 | { |
---|
846 | Int iCode; |
---|
847 | READ_UVLC( uiCode, "num_scaled_ref_layer_offsets" ); pcSPS->setNumScaledRefLayerOffsets(uiCode); |
---|
848 | for(Int i = 0; i < pcSPS->getNumScaledRefLayerOffsets(); i++) |
---|
849 | { |
---|
850 | Window& scaledWindow = pcSPS->getScaledRefLayerWindow(i); |
---|
851 | READ_SVLC( iCode, "scaled_ref_layer_left_offset" ); scaledWindow.setWindowLeftOffset (iCode << 1); |
---|
852 | READ_SVLC( iCode, "scaled_ref_layer_top_offset" ); scaledWindow.setWindowTopOffset (iCode << 1); |
---|
853 | READ_SVLC( iCode, "scaled_ref_layer_right_offset" ); scaledWindow.setWindowRightOffset (iCode << 1); |
---|
854 | READ_SVLC( iCode, "scaled_ref_layer_bottom_offset" ); scaledWindow.setWindowBottomOffset(iCode << 1); |
---|
855 | } |
---|
856 | } |
---|
857 | #endif |
---|
858 | #if M0463_VUI_EXT_ILP_REF |
---|
859 | //// sps_extension_vui_parameters( ) |
---|
860 | if( pcSPS->getVuiParameters()->getBitstreamRestrictionFlag() ) |
---|
861 | { |
---|
862 | READ_UVLC( uiCode, "num_ilp_restricted_ref_layers" ); pcSPS->setNumIlpRestrictedRefLayers( uiCode ); |
---|
863 | for( Int i = 0; i < pcSPS->getNumIlpRestrictedRefLayers( ); i++ ) |
---|
864 | { |
---|
865 | READ_UVLC( uiCode, "min_spatial_segment_offset_plus1" ); pcSPS->setMinSpatialSegmentOffsetPlus1( i, uiCode ); |
---|
866 | if( pcSPS->getMinSpatialSegmentOffsetPlus1( i ) > 0 ) |
---|
867 | { |
---|
868 | READ_FLAG( uiCode, "ctu_based_offset_enabled_flag[ i ]"); pcSPS->setCtuBasedOffsetEnabledFlag(i, uiCode == 1 ); |
---|
869 | if( pcSPS->getCtuBasedOffsetEnabledFlag( i ) ) |
---|
870 | { |
---|
871 | READ_UVLC( uiCode, "min_horizontal_ctu_offset_plus1[ i ]"); pcSPS->setMinHorizontalCtuOffsetPlus1( i, uiCode ); |
---|
872 | } |
---|
873 | } |
---|
874 | } |
---|
875 | } |
---|
876 | //// sps_extension_vui_parameters( ) END |
---|
877 | #endif |
---|
878 | } |
---|
879 | #endif |
---|
880 | |
---|
881 | Void TDecCavlc::parseVPS(TComVPS* pcVPS) |
---|
882 | { |
---|
883 | UInt uiCode; |
---|
884 | |
---|
885 | READ_CODE( 4, uiCode, "vps_video_parameter_set_id" ); pcVPS->setVPSId( uiCode ); |
---|
886 | READ_CODE( 2, uiCode, "vps_reserved_three_2bits" ); assert(uiCode == 3); |
---|
887 | #if VPS_RENAME |
---|
888 | READ_CODE( 6, uiCode, "vps_max_layers_minus1" ); pcVPS->setMaxLayers( uiCode + 1); |
---|
889 | #else |
---|
890 | READ_CODE( 6, uiCode, "vps_reserved_zero_6bits" ); assert(uiCode == 0); |
---|
891 | #endif |
---|
892 | READ_CODE( 3, uiCode, "vps_max_sub_layers_minus1" ); pcVPS->setMaxTLayers( uiCode + 1 ); |
---|
893 | READ_FLAG( uiCode, "vps_temporal_id_nesting_flag" ); pcVPS->setTemporalNestingFlag( uiCode ? true:false ); |
---|
894 | assert (pcVPS->getMaxTLayers()>1||pcVPS->getTemporalNestingFlag()); |
---|
895 | #if VPS_EXTN_OFFSET |
---|
896 | READ_CODE( 16, uiCode, "vps_extension_offset" ); pcVPS->setExtensionOffset( uiCode ); |
---|
897 | #else |
---|
898 | READ_CODE( 16, uiCode, "vps_reserved_ffff_16bits" ); assert(uiCode == 0xffff); |
---|
899 | #endif |
---|
900 | parsePTL ( pcVPS->getPTL(), true, pcVPS->getMaxTLayers()-1); |
---|
901 | UInt subLayerOrderingInfoPresentFlag; |
---|
902 | READ_FLAG(subLayerOrderingInfoPresentFlag, "vps_sub_layer_ordering_info_present_flag"); |
---|
903 | for(UInt i = 0; i <= pcVPS->getMaxTLayers()-1; i++) |
---|
904 | { |
---|
905 | READ_UVLC( uiCode, "vps_max_dec_pic_buffering_minus1[i]" ); pcVPS->setMaxDecPicBuffering( uiCode + 1, i ); |
---|
906 | READ_UVLC( uiCode, "vps_num_reorder_pics[i]" ); pcVPS->setNumReorderPics( uiCode, i ); |
---|
907 | READ_UVLC( uiCode, "vps_max_latency_increase_plus1[i]" ); pcVPS->setMaxLatencyIncrease( uiCode, i ); |
---|
908 | |
---|
909 | if (!subLayerOrderingInfoPresentFlag) |
---|
910 | { |
---|
911 | for (i++; i <= pcVPS->getMaxTLayers()-1; i++) |
---|
912 | { |
---|
913 | pcVPS->setMaxDecPicBuffering(pcVPS->getMaxDecPicBuffering(0), i); |
---|
914 | pcVPS->setNumReorderPics(pcVPS->getNumReorderPics(0), i); |
---|
915 | pcVPS->setMaxLatencyIncrease(pcVPS->getMaxLatencyIncrease(0), i); |
---|
916 | } |
---|
917 | break; |
---|
918 | } |
---|
919 | } |
---|
920 | |
---|
921 | #if VPS_RENAME |
---|
922 | assert( pcVPS->getNumHrdParameters() < MAX_VPS_LAYER_SETS_PLUS1 ); |
---|
923 | assert( pcVPS->getMaxLayerId() < MAX_VPS_LAYER_ID_PLUS1 ); |
---|
924 | READ_CODE( 6, uiCode, "vps_max_layer_id" ); pcVPS->setMaxLayerId( uiCode ); |
---|
925 | READ_UVLC( uiCode, "vps_num_layer_sets_minus1" ); pcVPS->setNumLayerSets( uiCode + 1 ); |
---|
926 | for( UInt opsIdx = 1; opsIdx <= ( pcVPS->getNumLayerSets() - 1 ); opsIdx ++ ) |
---|
927 | { |
---|
928 | // Operation point set |
---|
929 | for( UInt i = 0; i <= pcVPS->getMaxLayerId(); i ++ ) |
---|
930 | #else |
---|
931 | assert( pcVPS->getNumHrdParameters() < MAX_VPS_OP_SETS_PLUS1 ); |
---|
932 | assert( pcVPS->getMaxNuhReservedZeroLayerId() < MAX_VPS_NUH_RESERVED_ZERO_LAYER_ID_PLUS1 ); |
---|
933 | READ_CODE( 6, uiCode, "vps_max_nuh_reserved_zero_layer_id" ); pcVPS->setMaxNuhReservedZeroLayerId( uiCode ); |
---|
934 | READ_UVLC( uiCode, "vps_max_op_sets_minus1" ); pcVPS->setMaxOpSets( uiCode + 1 ); |
---|
935 | for( UInt opsIdx = 1; opsIdx <= ( pcVPS->getMaxOpSets() - 1 ); opsIdx ++ ) |
---|
936 | { |
---|
937 | // Operation point set |
---|
938 | for( UInt i = 0; i <= pcVPS->getMaxNuhReservedZeroLayerId(); i ++ ) |
---|
939 | #endif |
---|
940 | { |
---|
941 | READ_FLAG( uiCode, "layer_id_included_flag[opsIdx][i]" ); pcVPS->setLayerIdIncludedFlag( uiCode == 1 ? true : false, opsIdx, i ); |
---|
942 | } |
---|
943 | } |
---|
944 | #if DERIVE_LAYER_ID_LIST_VARIABLES |
---|
945 | pcVPS->deriveLayerIdListVariables(); |
---|
946 | #endif |
---|
947 | TimingInfo *timingInfo = pcVPS->getTimingInfo(); |
---|
948 | READ_FLAG( uiCode, "vps_timing_info_present_flag"); timingInfo->setTimingInfoPresentFlag (uiCode ? true : false); |
---|
949 | if(timingInfo->getTimingInfoPresentFlag()) |
---|
950 | { |
---|
951 | READ_CODE( 32, uiCode, "vps_num_units_in_tick"); timingInfo->setNumUnitsInTick (uiCode); |
---|
952 | READ_CODE( 32, uiCode, "vps_time_scale"); timingInfo->setTimeScale (uiCode); |
---|
953 | READ_FLAG( uiCode, "vps_poc_proportional_to_timing_flag"); timingInfo->setPocProportionalToTimingFlag(uiCode ? true : false); |
---|
954 | if(timingInfo->getPocProportionalToTimingFlag()) |
---|
955 | { |
---|
956 | READ_UVLC( uiCode, "vps_num_ticks_poc_diff_one_minus1"); timingInfo->setNumTicksPocDiffOneMinus1 (uiCode); |
---|
957 | } |
---|
958 | READ_UVLC( uiCode, "vps_num_hrd_parameters" ); pcVPS->setNumHrdParameters( uiCode ); |
---|
959 | |
---|
960 | if( pcVPS->getNumHrdParameters() > 0 ) |
---|
961 | { |
---|
962 | pcVPS->createHrdParamBuffer(); |
---|
963 | } |
---|
964 | for( UInt i = 0; i < pcVPS->getNumHrdParameters(); i ++ ) |
---|
965 | { |
---|
966 | READ_UVLC( uiCode, "hrd_op_set_idx" ); pcVPS->setHrdOpSetIdx( uiCode, i ); |
---|
967 | if( i > 0 ) |
---|
968 | { |
---|
969 | READ_FLAG( uiCode, "cprms_present_flag[i]" ); pcVPS->setCprmsPresentFlag( uiCode == 1 ? true : false, i ); |
---|
970 | } |
---|
971 | parseHrdParameters(pcVPS->getHrdParameters(i), pcVPS->getCprmsPresentFlag( i ), pcVPS->getMaxTLayers() - 1); |
---|
972 | } |
---|
973 | } |
---|
974 | READ_FLAG( uiCode, "vps_extension_flag" ); |
---|
975 | if (uiCode) |
---|
976 | { |
---|
977 | #if VPS_EXTNS |
---|
978 | while ( m_pcBitstream->getNumBitsRead() % 8 != 0 ) |
---|
979 | { |
---|
980 | READ_FLAG( uiCode, "vps_extension_alignment_bit_equal_to_one"); assert(uiCode == 1); |
---|
981 | } |
---|
982 | parseVPSExtension(pcVPS); |
---|
983 | READ_FLAG( uiCode, "vps_entension2_flag" ); |
---|
984 | if(uiCode) |
---|
985 | { |
---|
986 | while ( xMoreRbspData() ) |
---|
987 | { |
---|
988 | READ_FLAG( uiCode, "vps_extension_data_flag"); |
---|
989 | } |
---|
990 | } |
---|
991 | #else |
---|
992 | while ( xMoreRbspData() ) |
---|
993 | { |
---|
994 | READ_FLAG( uiCode, "vps_extension_data_flag"); |
---|
995 | } |
---|
996 | #endif |
---|
997 | } |
---|
998 | |
---|
999 | return; |
---|
1000 | } |
---|
1001 | |
---|
1002 | #if VPS_EXTNS |
---|
1003 | Void TDecCavlc::parseVPSExtension(TComVPS *vps) |
---|
1004 | { |
---|
1005 | UInt uiCode; |
---|
1006 | // ... More syntax elements to be parsed here |
---|
1007 | #if VPS_EXTN_MASK_AND_DIM_INFO |
---|
1008 | UInt numScalabilityTypes = 0, i = 0, j = 0; |
---|
1009 | |
---|
1010 | READ_FLAG( uiCode, "avc_base_layer_flag" ); vps->setAvcBaseLayerFlag(uiCode ? true : false); |
---|
1011 | READ_FLAG( uiCode, "splitting_flag" ); vps->setSplittingFlag(uiCode ? true : false); |
---|
1012 | |
---|
1013 | for(i = 0; i < MAX_VPS_NUM_SCALABILITY_TYPES; i++) |
---|
1014 | { |
---|
1015 | READ_FLAG( uiCode, "scalability_mask[i]" ); vps->setScalabilityMask(i, uiCode ? true : false); |
---|
1016 | numScalabilityTypes += uiCode; |
---|
1017 | } |
---|
1018 | vps->setNumScalabilityTypes(numScalabilityTypes); |
---|
1019 | |
---|
1020 | #if VPS_SPLIT_FLAG |
---|
1021 | for(j = 0; j < numScalabilityTypes - vps->getSplittingFlag(); j++) |
---|
1022 | #else |
---|
1023 | for(j = 0; j < numScalabilityTypes; j++) |
---|
1024 | #endif |
---|
1025 | { |
---|
1026 | READ_CODE( 3, uiCode, "dimension_id_len_minus1[j]" ); vps->setDimensionIdLen(j, uiCode + 1); |
---|
1027 | } |
---|
1028 | #if VPS_SPLIT_FLAG |
---|
1029 | if(vps->getSplittingFlag()) |
---|
1030 | { |
---|
1031 | UInt numBits = 0; |
---|
1032 | for(j = 0; j < numScalabilityTypes - 1; j++) |
---|
1033 | { |
---|
1034 | numBits += vps->getDimensionIdLen(j); |
---|
1035 | } |
---|
1036 | assert( numBits < 6 ); |
---|
1037 | vps->setDimensionIdLen(numScalabilityTypes-1, 6 - numBits); |
---|
1038 | numBits = 6; |
---|
1039 | } |
---|
1040 | #else |
---|
1041 | if(vps->getSplittingFlag()) |
---|
1042 | { |
---|
1043 | UInt numBits = 0; |
---|
1044 | for(j = 0; j < numScalabilityTypes; j++) |
---|
1045 | { |
---|
1046 | numBits += vps->getDimensionIdLen(j); |
---|
1047 | } |
---|
1048 | assert( numBits <= 6 ); |
---|
1049 | } |
---|
1050 | #endif |
---|
1051 | |
---|
1052 | READ_FLAG( uiCode, "vps_nuh_layer_id_present_flag" ); vps->setNuhLayerIdPresentFlag(uiCode ? true : false); |
---|
1053 | vps->setLayerIdInNuh(0, 0); |
---|
1054 | vps->setLayerIdInVps(0, 0); |
---|
1055 | for(i = 1; i < vps->getMaxLayers(); i++) |
---|
1056 | { |
---|
1057 | if( vps->getNuhLayerIdPresentFlag() ) |
---|
1058 | { |
---|
1059 | READ_CODE( 6, uiCode, "layer_id_in_nuh[i]" ); vps->setLayerIdInNuh(i, uiCode); |
---|
1060 | assert( uiCode > vps->getLayerIdInNuh(i-1) ); |
---|
1061 | } |
---|
1062 | else |
---|
1063 | { |
---|
1064 | vps->setLayerIdInNuh(i, i); |
---|
1065 | } |
---|
1066 | vps->setLayerIdInVps(vps->getLayerIdInNuh(i), i); |
---|
1067 | |
---|
1068 | #if VPS_SPLIT_FLAG |
---|
1069 | if(!vps->getSplittingFlag()) |
---|
1070 | #endif |
---|
1071 | for(j = 0; j < numScalabilityTypes; j++) |
---|
1072 | { |
---|
1073 | READ_CODE( vps->getDimensionIdLen(j), uiCode, "dimension_id[i][j]" ); vps->setDimensionId(i, j, uiCode); |
---|
1074 | assert( uiCode <= vps->getMaxLayerId() ); |
---|
1075 | } |
---|
1076 | } |
---|
1077 | #endif |
---|
1078 | #if VIEW_ID_RELATED_SIGNALING |
---|
1079 | // if ( pcVPS->getNumViews() > 1 ) |
---|
1080 | // However, this is a bug in the text since, view_id_len_minus1 is needed to parse view_id_val. |
---|
1081 | { |
---|
1082 | READ_CODE( 4, uiCode, "view_id_len_minus1" ); vps->setViewIdLenMinus1( uiCode ); |
---|
1083 | } |
---|
1084 | |
---|
1085 | for( i = 0; i < vps->getNumViews(); i++ ) |
---|
1086 | { |
---|
1087 | READ_CODE( vps->getViewIdLenMinus1( ) + 1, uiCode, "view_id_val[i]" ); vps->setViewIdVal( i, uiCode ); |
---|
1088 | } |
---|
1089 | #endif |
---|
1090 | #if VPS_MOVE_DIR_DEPENDENCY_FLAG |
---|
1091 | #if VPS_EXTN_DIRECT_REF_LAYERS |
---|
1092 | // For layer 0 |
---|
1093 | vps->setNumDirectRefLayers(0, 0); |
---|
1094 | // For other layers |
---|
1095 | for( Int layerCtr = 1; layerCtr <= vps->getMaxLayers() - 1; layerCtr++) |
---|
1096 | { |
---|
1097 | UInt numDirectRefLayers = 0; |
---|
1098 | for( Int refLayerCtr = 0; refLayerCtr < layerCtr; refLayerCtr++) |
---|
1099 | { |
---|
1100 | READ_FLAG(uiCode, "direct_dependency_flag[i][j]" ); vps->setDirectDependencyFlag(layerCtr, refLayerCtr, uiCode? true : false); |
---|
1101 | if(uiCode) |
---|
1102 | { |
---|
1103 | vps->setRefLayerId(layerCtr, numDirectRefLayers, refLayerCtr); |
---|
1104 | numDirectRefLayers++; |
---|
1105 | } |
---|
1106 | } |
---|
1107 | vps->setNumDirectRefLayers(layerCtr, numDirectRefLayers); |
---|
1108 | } |
---|
1109 | #endif |
---|
1110 | #endif |
---|
1111 | #if JCTVC_M0203_INTERLAYER_PRED_IDC |
---|
1112 | #if N0120_MAX_TID_REF_PRESENT_FLAG |
---|
1113 | READ_FLAG( uiCode, "max_tid_ref_present_flag"); vps->setMaxTidRefPresentFlag(uiCode ? true : false); |
---|
1114 | if (vps->getMaxTidRefPresentFlag()) |
---|
1115 | { |
---|
1116 | for(i = 0; i < vps->getMaxLayers() - 1; i++) |
---|
1117 | { |
---|
1118 | READ_CODE( 3, uiCode, "max_tid_il_ref_pics_plus1[i]" ); vps->setMaxTidIlRefPicsPlus1(i, uiCode); |
---|
1119 | #if N0120_MAX_TID_REF_CFG |
---|
1120 | assert( uiCode <= vps->getMaxTLayers()); |
---|
1121 | #else |
---|
1122 | assert( uiCode <= vps->getMaxTLayers()+ 1 ); |
---|
1123 | #endif |
---|
1124 | } |
---|
1125 | } |
---|
1126 | else |
---|
1127 | { |
---|
1128 | for(i = 0; i < vps->getMaxLayers() - 1; i++) |
---|
1129 | { |
---|
1130 | vps->setMaxTidIlRefPicsPlus1(i, 7); |
---|
1131 | } |
---|
1132 | } |
---|
1133 | #else |
---|
1134 | for(i = 0; i < vps->getMaxLayers() - 1; i++) |
---|
1135 | { |
---|
1136 | READ_CODE( 3, uiCode, "max_tid_il_ref_pics_plus1[i]" ); vps->setMaxTidIlRefPicsPlus1(i, uiCode); |
---|
1137 | assert( uiCode <= vps->getMaxTLayers() ); |
---|
1138 | } |
---|
1139 | #endif |
---|
1140 | #endif |
---|
1141 | #if ILP_SSH_SIG |
---|
1142 | READ_FLAG( uiCode, "all_ref_layers_active_flag" ); vps->setIlpSshSignalingEnabledFlag(uiCode ? true : false); |
---|
1143 | #endif |
---|
1144 | #if VPS_EXTN_PROFILE_INFO |
---|
1145 | // Profile-tier-level signalling |
---|
1146 | #if VPS_PROFILE_OUTPUT_LAYERS |
---|
1147 | READ_CODE( 10, uiCode, "vps_number_layer_sets_minus1" ); assert( uiCode == (vps->getNumLayerSets() - 1) ); |
---|
1148 | READ_CODE( 6, uiCode, "vps_num_profile_tier_level_minus1"); vps->setNumProfileTierLevel( uiCode + 1 ); |
---|
1149 | vps->getPTLForExtnPtr()->resize(vps->getNumProfileTierLevel()); |
---|
1150 | for(Int idx = 1; idx <= vps->getNumProfileTierLevel() - 1; idx++) |
---|
1151 | #else |
---|
1152 | vps->getPTLForExtnPtr()->resize(vps->getNumLayerSets()); |
---|
1153 | for(Int idx = 1; idx <= vps->getNumLayerSets() - 1; idx++) |
---|
1154 | #endif |
---|
1155 | { |
---|
1156 | READ_FLAG( uiCode, "vps_profile_present_flag[i]" ); vps->setProfilePresentFlag(idx, uiCode ? true : false); |
---|
1157 | if( !vps->getProfilePresentFlag(idx) ) |
---|
1158 | { |
---|
1159 | #if VPS_PROFILE_OUTPUT_LAYERS |
---|
1160 | READ_CODE( 6, uiCode, "profile_ref_minus1[i]" ); vps->setProfileLayerSetRef(idx, uiCode + 1); |
---|
1161 | #else |
---|
1162 | READ_UVLC( uiCode, "vps_profile_layer_set_ref_minus1[i]" ); vps->setProfileLayerSetRef(idx, uiCode + 1); |
---|
1163 | #endif |
---|
1164 | assert( vps->getProfileLayerSetRef(idx) < idx ); |
---|
1165 | // Copy profile information as indicated |
---|
1166 | vps->getPTLForExtn(idx)->copyProfileInfo( vps->getPTLForExtn( vps->getProfileLayerSetRef(idx) ) ); |
---|
1167 | } |
---|
1168 | parsePTL( vps->getPTLForExtn(idx), vps->getProfilePresentFlag(idx), vps->getMaxTLayers() - 1 ); |
---|
1169 | } |
---|
1170 | #endif |
---|
1171 | |
---|
1172 | #if VPS_PROFILE_OUTPUT_LAYERS |
---|
1173 | READ_FLAG( uiCode, "more_output_layer_sets_than_default_flag" ); vps->setMoreOutputLayerSetsThanDefaultFlag( uiCode ? true : false ); |
---|
1174 | Int numOutputLayerSets = 0; |
---|
1175 | if(! vps->getMoreOutputLayerSetsThanDefaultFlag() ) |
---|
1176 | { |
---|
1177 | numOutputLayerSets = vps->getNumLayerSets(); |
---|
1178 | } |
---|
1179 | else |
---|
1180 | { |
---|
1181 | READ_CODE( 10, uiCode, "num_add_output_layer_sets" ); vps->setNumAddOutputLayerSets( uiCode ); |
---|
1182 | numOutputLayerSets = vps->getNumLayerSets() + vps->getNumAddOutputLayerSets(); |
---|
1183 | } |
---|
1184 | if( numOutputLayerSets > 1 ) |
---|
1185 | { |
---|
1186 | READ_FLAG( uiCode, "default_one_target_output_layer_flag" ); vps->setDefaultOneTargetOutputLayerFlag( uiCode ? true : false ); |
---|
1187 | } |
---|
1188 | vps->setNumOutputLayerSets( numOutputLayerSets ); |
---|
1189 | |
---|
1190 | for(i = 1; i < numOutputLayerSets; i++) |
---|
1191 | { |
---|
1192 | if( i > (vps->getNumLayerSets() - 1) ) |
---|
1193 | { |
---|
1194 | Int numBits = 1; |
---|
1195 | while ((1 << numBits) < (vps->getNumLayerSets() - 1)) |
---|
1196 | { |
---|
1197 | numBits++; |
---|
1198 | } |
---|
1199 | READ_CODE( numBits, uiCode, "output_layer_set_idx_minus1"); vps->setOutputLayerSetIdx( i, uiCode + 1); |
---|
1200 | Int lsIdx = vps->getOutputLayerSetIdx(i); |
---|
1201 | for(j = 0; j < vps->getNumLayersInIdList(lsIdx) - 1; j++) |
---|
1202 | { |
---|
1203 | READ_FLAG( uiCode, "output_layer_flag[i][j]"); vps->setOutputLayerFlag(i, j, uiCode); |
---|
1204 | } |
---|
1205 | } |
---|
1206 | else |
---|
1207 | { |
---|
1208 | // i <= (vps->getNumLayerSets() - 1) |
---|
1209 | // Assign OutputLayerFlag depending on default_one_target_output_layer_flag |
---|
1210 | Int lsIdx = i; |
---|
1211 | if( vps->getDefaultOneTargetOutputLayerFlag() ) |
---|
1212 | { |
---|
1213 | for(j = 0; j < vps->getNumLayersInIdList(lsIdx); j++) |
---|
1214 | { |
---|
1215 | vps->setOutputLayerFlag(i, j, (j == (vps->getNumLayersInIdList(lsIdx)-1))); |
---|
1216 | } |
---|
1217 | } |
---|
1218 | else |
---|
1219 | { |
---|
1220 | for(j = 0; j < vps->getNumLayersInIdList(lsIdx); j++) |
---|
1221 | { |
---|
1222 | vps->setOutputLayerFlag(i, j, 1); |
---|
1223 | } |
---|
1224 | } |
---|
1225 | } |
---|
1226 | Int numBits = 1; |
---|
1227 | while ((1 << numBits) < (vps->getNumProfileTierLevel())) |
---|
1228 | { |
---|
1229 | numBits++; |
---|
1230 | } |
---|
1231 | READ_CODE( numBits, uiCode, "profile_level_tier_idx[i]" ); vps->setProfileLevelTierIdx(i, uiCode); |
---|
1232 | } |
---|
1233 | #else |
---|
1234 | #if VPS_EXTN_OP_LAYER_SETS |
---|
1235 | // Target output layer signalling |
---|
1236 | READ_UVLC( uiCode, "vps_num_output_layer_sets"); vps->setNumOutputLayerSets(uiCode); |
---|
1237 | for(i = 0; i < vps->getNumOutputLayerSets(); i++) |
---|
1238 | { |
---|
1239 | #if VPS_OUTPUT_LAYER_SET_IDX |
---|
1240 | READ_UVLC( uiCode, "vps_output_layer_set_idx_minus1[i]"); vps->setOutputLayerSetIdx(i, uiCode + 1); |
---|
1241 | #else |
---|
1242 | READ_UVLC( uiCode, "vps_output_layer_set_idx[i]"); vps->setOutputLayerSetIdx(i, uiCode); |
---|
1243 | #endif |
---|
1244 | Int lsIdx = vps->getOutputLayerSetIdx(i); |
---|
1245 | for(j = 0; j <= vps->getMaxLayerId(); j++) |
---|
1246 | { |
---|
1247 | if(vps->getLayerIdIncludedFlag(lsIdx, j)) |
---|
1248 | { |
---|
1249 | READ_FLAG( uiCode, "vps_output_layer_flag[lsIdx][j]"); vps->setOutputLayerFlag(lsIdx, j, uiCode); |
---|
1250 | } |
---|
1251 | } |
---|
1252 | } |
---|
1253 | #endif |
---|
1254 | #endif |
---|
1255 | #if REPN_FORMAT_IN_VPS |
---|
1256 | READ_FLAG( uiCode, "rep_format_idx_present_flag"); |
---|
1257 | vps->setRepFormatIdxPresentFlag( uiCode ? true : false ); |
---|
1258 | |
---|
1259 | if( vps->getRepFormatIdxPresentFlag() ) |
---|
1260 | { |
---|
1261 | READ_CODE( 4, uiCode, "vps_num_rep_formats_minus1" ); |
---|
1262 | vps->setVpsNumRepFormats( uiCode + 1 ); |
---|
1263 | } |
---|
1264 | else |
---|
1265 | { |
---|
1266 | // default assignment |
---|
1267 | assert (vps->getMaxLayers() <= 16); // If max_layers_is more than 15, num_rep_formats has to be signaled |
---|
1268 | vps->setVpsNumRepFormats( vps->getMaxLayers() ); |
---|
1269 | } |
---|
1270 | for(i = 0; i < vps->getVpsNumRepFormats(); i++) |
---|
1271 | { |
---|
1272 | // Read rep_format_structures |
---|
1273 | parseRepFormat( vps->getVpsRepFormat(i) ); |
---|
1274 | } |
---|
1275 | |
---|
1276 | // Default assignment for layer 0 |
---|
1277 | vps->setVpsRepFormatIdx( 0, 0 ); |
---|
1278 | if( vps->getRepFormatIdxPresentFlag() ) |
---|
1279 | { |
---|
1280 | for(i = 1; i < vps->getMaxLayers(); i++) |
---|
1281 | { |
---|
1282 | if( vps->getVpsNumRepFormats() > 1 ) |
---|
1283 | { |
---|
1284 | READ_CODE( 4, uiCode, "vps_rep_format_idx[i]" ); |
---|
1285 | vps->setVpsRepFormatIdx( i, uiCode ); |
---|
1286 | } |
---|
1287 | else |
---|
1288 | { |
---|
1289 | // default assignment - only one rep_format() structure |
---|
1290 | vps->setVpsRepFormatIdx( i, 0 ); |
---|
1291 | } |
---|
1292 | } |
---|
1293 | } |
---|
1294 | else |
---|
1295 | { |
---|
1296 | // default assignment - each layer assigned each rep_format() structure in the order signaled |
---|
1297 | for(i = 1; i < vps->getMaxLayers(); i++) |
---|
1298 | { |
---|
1299 | vps->setVpsRepFormatIdx( i, i ); |
---|
1300 | } |
---|
1301 | } |
---|
1302 | #endif |
---|
1303 | #if JCTVC_M0458_INTERLAYER_RPS_SIG |
---|
1304 | READ_FLAG(uiCode, "max_one_active_ref_layer_flag" ); |
---|
1305 | vps->setMaxOneActiveRefLayerFlag(uiCode); |
---|
1306 | #endif |
---|
1307 | |
---|
1308 | #if N0147_IRAP_ALIGN_FLAG |
---|
1309 | READ_FLAG(uiCode, "cross_layer_irap_aligned_flag" ); |
---|
1310 | vps->setCrossLayerIrapAlignFlag(uiCode); |
---|
1311 | #endif |
---|
1312 | |
---|
1313 | #if !VPS_MOVE_DIR_DEPENDENCY_FLAG |
---|
1314 | #if VPS_EXTN_DIRECT_REF_LAYERS |
---|
1315 | // For layer 0 |
---|
1316 | vps->setNumDirectRefLayers(0, 0); |
---|
1317 | // For other layers |
---|
1318 | for( Int layerCtr = 1; layerCtr <= vps->getMaxLayers() - 1; layerCtr++) |
---|
1319 | { |
---|
1320 | UInt numDirectRefLayers = 0; |
---|
1321 | for( Int refLayerCtr = 0; refLayerCtr < layerCtr; refLayerCtr++) |
---|
1322 | { |
---|
1323 | READ_FLAG(uiCode, "direct_dependency_flag[i][j]" ); vps->setDirectDependencyFlag(layerCtr, refLayerCtr, uiCode? true : false); |
---|
1324 | if(uiCode) |
---|
1325 | { |
---|
1326 | vps->setRefLayerId(layerCtr, numDirectRefLayers, refLayerCtr); |
---|
1327 | numDirectRefLayers++; |
---|
1328 | } |
---|
1329 | } |
---|
1330 | vps->setNumDirectRefLayers(layerCtr, numDirectRefLayers); |
---|
1331 | } |
---|
1332 | #endif |
---|
1333 | #endif |
---|
1334 | #if VPS_EXTN_DIRECT_REF_LAYERS && M0457_PREDICTION_INDICATIONS |
---|
1335 | READ_UVLC( uiCode, "direct_dep_type_len_minus2"); vps->setDirectDepTypeLen(uiCode+2); |
---|
1336 | for(i = 1; i < vps->getMaxLayers(); i++) |
---|
1337 | { |
---|
1338 | for(j = 0; j < i; j++) |
---|
1339 | { |
---|
1340 | if (vps->getDirectDependencyFlag(i, j)) |
---|
1341 | { |
---|
1342 | READ_CODE( vps->getDirectDepTypeLen(), uiCode, "direct_dependency_type[i][j]" ); vps->setDirectDependencyType(i, j, uiCode); |
---|
1343 | } |
---|
1344 | } |
---|
1345 | } |
---|
1346 | |
---|
1347 | #endif |
---|
1348 | |
---|
1349 | #if IL_SL_SIGNALLING_N0371 |
---|
1350 | for(i = 1; i < vps->getMaxLayers(); i++) |
---|
1351 | { |
---|
1352 | for(j = 0; j < i; j++) |
---|
1353 | { |
---|
1354 | vps->setScalingListLayerDependency( i, j, vps->checkLayerDependency( i,j ) ); |
---|
1355 | } |
---|
1356 | } |
---|
1357 | #endif |
---|
1358 | |
---|
1359 | #if M0040_ADAPTIVE_RESOLUTION_CHANGE |
---|
1360 | READ_FLAG(uiCode, "single_layer_for_non_irap_flag" ); vps->setSingleLayerForNonIrapFlag(uiCode == 1 ? true : false); |
---|
1361 | #endif |
---|
1362 | |
---|
1363 | READ_FLAG( uiCode, "vps_vui_present_flag" ); |
---|
1364 | if (uiCode) |
---|
1365 | { |
---|
1366 | #if VPS_VUI |
---|
1367 | while ( m_pcBitstream->getNumBitsRead() % 8 != 0 ) |
---|
1368 | { |
---|
1369 | READ_FLAG( uiCode, "vps_vui_alignment_bit_equal_to_one"); assert(uiCode == 1); |
---|
1370 | } |
---|
1371 | parseVPSVUI(vps); |
---|
1372 | #endif |
---|
1373 | } |
---|
1374 | } |
---|
1375 | #endif |
---|
1376 | #if REPN_FORMAT_IN_VPS |
---|
1377 | Void TDecCavlc::parseRepFormat ( RepFormat *repFormat ) |
---|
1378 | { |
---|
1379 | UInt uiCode; |
---|
1380 | READ_CODE( 2, uiCode, "chroma_format_idc" ); repFormat->setChromaFormatVpsIdc( uiCode ); |
---|
1381 | |
---|
1382 | if( repFormat->getChromaFormatVpsIdc() == 3 ) |
---|
1383 | { |
---|
1384 | READ_FLAG( uiCode, "separate_colour_plane_flag"); repFormat->setSeparateColourPlaneVpsFlag(uiCode ? true : false); |
---|
1385 | } |
---|
1386 | |
---|
1387 | READ_CODE ( 16, uiCode, "pic_width_in_luma_samples" ); repFormat->setPicWidthVpsInLumaSamples ( uiCode ); |
---|
1388 | READ_CODE ( 16, uiCode, "pic_height_in_luma_samples" ); repFormat->setPicHeightVpsInLumaSamples( uiCode ); |
---|
1389 | |
---|
1390 | READ_CODE( 4, uiCode, "bit_depth_luma_minus8" ); repFormat->setBitDepthVpsLuma ( uiCode + 8 ); |
---|
1391 | READ_CODE( 4, uiCode, "bit_depth_chroma_minus8" ); repFormat->setBitDepthVpsChroma( uiCode + 8 ); |
---|
1392 | |
---|
1393 | } |
---|
1394 | #endif |
---|
1395 | #if VPS_VUI |
---|
1396 | Void TDecCavlc::parseVPSVUI(TComVPS *vps) |
---|
1397 | { |
---|
1398 | UInt i,j; |
---|
1399 | UInt uiCode; |
---|
1400 | #if VPS_VUI_BITRATE_PICRATE |
---|
1401 | READ_FLAG( uiCode, "bit_rate_present_vps_flag" ); vps->setBitRatePresentVpsFlag( uiCode ? true : false ); |
---|
1402 | READ_FLAG( uiCode, "pic_rate_present_vps_flag" ); vps->setPicRatePresentVpsFlag( uiCode ? true : false ); |
---|
1403 | |
---|
1404 | Bool parseFlag = vps->getBitRatePresentVpsFlag() || vps->getPicRatePresentVpsFlag(); |
---|
1405 | { |
---|
1406 | for( i = 0; i < vps->getNumLayerSets(); i++ ) |
---|
1407 | { |
---|
1408 | for( j = 0; j < vps->getMaxTLayers(); j++ ) |
---|
1409 | { |
---|
1410 | if( parseFlag && vps->getBitRatePresentVpsFlag() ) |
---|
1411 | { |
---|
1412 | READ_FLAG( uiCode, "bit_rate_present_vps_flag[i][j]" ); vps->setBitRatePresentFlag( i, j, uiCode ? true : false ); |
---|
1413 | } |
---|
1414 | else |
---|
1415 | { |
---|
1416 | vps->setBitRatePresentFlag( i, j, false ); |
---|
1417 | } |
---|
1418 | if( parseFlag && vps->getPicRatePresentVpsFlag() ) |
---|
1419 | { |
---|
1420 | READ_FLAG( uiCode, "pic_rate_present_vps_flag[i][j]" ); vps->setPicRatePresentFlag( i, j, uiCode ? true : false ); |
---|
1421 | } |
---|
1422 | else |
---|
1423 | { |
---|
1424 | vps->setPicRatePresentFlag( i, j, false ); |
---|
1425 | } |
---|
1426 | if( parseFlag && vps->getBitRatePresentFlag(i, j) ) |
---|
1427 | { |
---|
1428 | READ_CODE( 16, uiCode, "avg_bit_rate[i][j]" ); vps->setAvgBitRate( i, j, uiCode ); |
---|
1429 | READ_CODE( 16, uiCode, "max_bit_rate[i][j]" ); vps->setMaxBitRate( i, j, uiCode ); |
---|
1430 | } |
---|
1431 | else |
---|
1432 | { |
---|
1433 | vps->setAvgBitRate( i, j, 0 ); |
---|
1434 | vps->setMaxBitRate( i, j, 0 ); |
---|
1435 | } |
---|
1436 | if( parseFlag && vps->getPicRatePresentFlag(i, j) ) |
---|
1437 | { |
---|
1438 | READ_CODE( 2 , uiCode, "constant_pic_rate_idc[i][j]" ); vps->setConstPicRateIdc( i, j, uiCode ); |
---|
1439 | READ_CODE( 16, uiCode, "avg_pic_rate[i][j]" ); vps->setAvgPicRate( i, j, uiCode ); |
---|
1440 | } |
---|
1441 | else |
---|
1442 | { |
---|
1443 | vps->setConstPicRateIdc( i, j, 0 ); |
---|
1444 | vps->setAvgPicRate ( i, j, 0 ); |
---|
1445 | } |
---|
1446 | } |
---|
1447 | } |
---|
1448 | } |
---|
1449 | #endif |
---|
1450 | #if TILE_BOUNDARY_ALIGNED_FLAG |
---|
1451 | for(i = 1; i < vps->getMaxLayers(); i++) |
---|
1452 | { |
---|
1453 | for(j = 0; j < vps->getNumDirectRefLayers(vps->getLayerIdInNuh(i)); j++) |
---|
1454 | { |
---|
1455 | READ_FLAG( uiCode, "tile_boundaries_aligned_flag[i][j]" ); vps->setTileBoundariesAlignedFlag(i,j,(uiCode == 1)); |
---|
1456 | } |
---|
1457 | } |
---|
1458 | #endif |
---|
1459 | #if N0160_VUI_EXT_ILP_REF |
---|
1460 | READ_FLAG( uiCode, "num_ilp_restricted_ref_layers" ); vps->setNumIlpRestrictedRefLayers( uiCode == 1 ); |
---|
1461 | if( vps->getNumIlpRestrictedRefLayers()) |
---|
1462 | { |
---|
1463 | for(i = 1; i < vps->getMaxLayers(); i++) |
---|
1464 | { |
---|
1465 | for(j = 0; j < vps->getNumDirectRefLayers(vps->getLayerIdInNuh(i)); j++) |
---|
1466 | { |
---|
1467 | READ_UVLC( uiCode, "min_spatial_segment_offset_plus1[i][j]" ); vps->setMinSpatialSegmentOffsetPlus1( i, j, uiCode ); |
---|
1468 | if( vps->getMinSpatialSegmentOffsetPlus1(i,j ) > 0 ) |
---|
1469 | { |
---|
1470 | READ_FLAG( uiCode, "ctu_based_offset_enabled_flag[i][j]"); vps->setCtuBasedOffsetEnabledFlag(i, j, uiCode == 1 ); |
---|
1471 | if(vps->getCtuBasedOffsetEnabledFlag(i,j)) |
---|
1472 | { |
---|
1473 | READ_UVLC( uiCode, "min_horizontal_ctu_offset_plus1[i][j]"); vps->setMinHorizontalCtuOffsetPlus1( i,j, uiCode ); |
---|
1474 | } |
---|
1475 | } |
---|
1476 | } |
---|
1477 | } |
---|
1478 | } |
---|
1479 | #endif |
---|
1480 | } |
---|
1481 | #endif |
---|
1482 | Void TDecCavlc::parseSliceHeader (TComSlice*& rpcSlice, ParameterSetManagerDecoder *parameterSetManager) |
---|
1483 | { |
---|
1484 | UInt uiCode; |
---|
1485 | Int iCode; |
---|
1486 | |
---|
1487 | #if ENC_DEC_TRACE |
---|
1488 | xTraceSliceHeader(rpcSlice); |
---|
1489 | #endif |
---|
1490 | TComPPS* pps = NULL; |
---|
1491 | TComSPS* sps = NULL; |
---|
1492 | |
---|
1493 | UInt firstSliceSegmentInPic; |
---|
1494 | READ_FLAG( firstSliceSegmentInPic, "first_slice_segment_in_pic_flag" ); |
---|
1495 | if( rpcSlice->getRapPicFlag()) |
---|
1496 | { |
---|
1497 | READ_FLAG( uiCode, "no_output_of_prior_pics_flag" ); //ignored |
---|
1498 | } |
---|
1499 | READ_UVLC ( uiCode, "slice_pic_parameter_set_id" ); rpcSlice->setPPSId(uiCode); |
---|
1500 | pps = parameterSetManager->getPrefetchedPPS(uiCode); |
---|
1501 | //!KS: need to add error handling code here, if PPS is not available |
---|
1502 | assert(pps!=0); |
---|
1503 | sps = parameterSetManager->getPrefetchedSPS(pps->getSPSId()); |
---|
1504 | //!KS: need to add error handling code here, if SPS is not available |
---|
1505 | assert(sps!=0); |
---|
1506 | rpcSlice->setSPS(sps); |
---|
1507 | rpcSlice->setPPS(pps); |
---|
1508 | if( pps->getDependentSliceSegmentsEnabledFlag() && ( !firstSliceSegmentInPic )) |
---|
1509 | { |
---|
1510 | READ_FLAG( uiCode, "dependent_slice_segment_flag" ); rpcSlice->setDependentSliceSegmentFlag(uiCode ? true : false); |
---|
1511 | } |
---|
1512 | else |
---|
1513 | { |
---|
1514 | rpcSlice->setDependentSliceSegmentFlag(false); |
---|
1515 | } |
---|
1516 | #if REPN_FORMAT_IN_VPS |
---|
1517 | Int numCTUs = ((rpcSlice->getPicWidthInLumaSamples()+sps->getMaxCUWidth()-1)/sps->getMaxCUWidth())*((rpcSlice->getPicHeightInLumaSamples()+sps->getMaxCUHeight()-1)/sps->getMaxCUHeight()); |
---|
1518 | #else |
---|
1519 | Int numCTUs = ((sps->getPicWidthInLumaSamples()+sps->getMaxCUWidth()-1)/sps->getMaxCUWidth())*((sps->getPicHeightInLumaSamples()+sps->getMaxCUHeight()-1)/sps->getMaxCUHeight()); |
---|
1520 | #endif |
---|
1521 | Int maxParts = (1<<(sps->getMaxCUDepth()<<1)); |
---|
1522 | UInt sliceSegmentAddress = 0; |
---|
1523 | Int bitsSliceSegmentAddress = 0; |
---|
1524 | while(numCTUs>(1<<bitsSliceSegmentAddress)) |
---|
1525 | { |
---|
1526 | bitsSliceSegmentAddress++; |
---|
1527 | } |
---|
1528 | |
---|
1529 | if(!firstSliceSegmentInPic) |
---|
1530 | { |
---|
1531 | READ_CODE( bitsSliceSegmentAddress, sliceSegmentAddress, "slice_segment_address" ); |
---|
1532 | } |
---|
1533 | //set uiCode to equal slice start address (or dependent slice start address) |
---|
1534 | Int startCuAddress = maxParts*sliceSegmentAddress; |
---|
1535 | rpcSlice->setSliceSegmentCurStartCUAddr( startCuAddress ); |
---|
1536 | rpcSlice->setSliceSegmentCurEndCUAddr(numCTUs*maxParts); |
---|
1537 | |
---|
1538 | if (rpcSlice->getDependentSliceSegmentFlag()) |
---|
1539 | { |
---|
1540 | rpcSlice->setNextSlice ( false ); |
---|
1541 | rpcSlice->setNextSliceSegment ( true ); |
---|
1542 | } |
---|
1543 | else |
---|
1544 | { |
---|
1545 | rpcSlice->setNextSlice ( true ); |
---|
1546 | rpcSlice->setNextSliceSegment ( false ); |
---|
1547 | |
---|
1548 | rpcSlice->setSliceCurStartCUAddr(startCuAddress); |
---|
1549 | rpcSlice->setSliceCurEndCUAddr(numCTUs*maxParts); |
---|
1550 | } |
---|
1551 | |
---|
1552 | if(!rpcSlice->getDependentSliceSegmentFlag()) |
---|
1553 | { |
---|
1554 | #if POC_RESET_FLAG |
---|
1555 | Int iBits = 0; |
---|
1556 | if(rpcSlice->getPPS()->getNumExtraSliceHeaderBits() > iBits) |
---|
1557 | { |
---|
1558 | READ_FLAG(uiCode, "poc_reset_flag"); rpcSlice->setPocResetFlag( uiCode ? true : false ); |
---|
1559 | iBits++; |
---|
1560 | } |
---|
1561 | if(rpcSlice->getPPS()->getNumExtraSliceHeaderBits() > iBits) |
---|
1562 | { |
---|
1563 | READ_FLAG(uiCode, "discardable_flag"); // ignored |
---|
1564 | iBits++; |
---|
1565 | } |
---|
1566 | for (; iBits < rpcSlice->getPPS()->getNumExtraSliceHeaderBits(); iBits++) |
---|
1567 | { |
---|
1568 | READ_FLAG(uiCode, "slice_reserved_undetermined_flag[]"); // ignored |
---|
1569 | } |
---|
1570 | #else |
---|
1571 | #if SH_DISCARDABLE_FLAG |
---|
1572 | if(rpcSlice->getPPS()->getNumExtraSliceHeaderBits()>0) |
---|
1573 | { |
---|
1574 | READ_FLAG(uiCode, "discardable_flag"); // ignored |
---|
1575 | } |
---|
1576 | for (Int i = 1; i < rpcSlice->getPPS()->getNumExtraSliceHeaderBits(); i++) |
---|
1577 | { |
---|
1578 | READ_FLAG(uiCode, "slice_reserved_undetermined_flag[]"); // ignored |
---|
1579 | } |
---|
1580 | #else |
---|
1581 | for (Int i = 0; i < rpcSlice->getPPS()->getNumExtraSliceHeaderBits(); i++) |
---|
1582 | { |
---|
1583 | READ_FLAG(uiCode, "slice_reserved_undetermined_flag[]"); // ignored |
---|
1584 | } |
---|
1585 | #endif |
---|
1586 | #endif |
---|
1587 | |
---|
1588 | READ_UVLC ( uiCode, "slice_type" ); rpcSlice->setSliceType((SliceType)uiCode); |
---|
1589 | if( pps->getOutputFlagPresentFlag() ) |
---|
1590 | { |
---|
1591 | READ_FLAG( uiCode, "pic_output_flag" ); rpcSlice->setPicOutputFlag( uiCode ? true : false ); |
---|
1592 | } |
---|
1593 | else |
---|
1594 | { |
---|
1595 | rpcSlice->setPicOutputFlag( true ); |
---|
1596 | } |
---|
1597 | // in the first version chroma_format_idc is equal to one, thus colour_plane_id will not be present |
---|
1598 | assert (sps->getChromaFormatIdc() == 1 ); |
---|
1599 | // if( separate_colour_plane_flag == 1 ) |
---|
1600 | // colour_plane_id u(2) |
---|
1601 | |
---|
1602 | if( rpcSlice->getIdrPicFlag() ) |
---|
1603 | { |
---|
1604 | rpcSlice->setPOC(0); |
---|
1605 | TComReferencePictureSet* rps = rpcSlice->getLocalRPS(); |
---|
1606 | rps->setNumberOfNegativePictures(0); |
---|
1607 | rps->setNumberOfPositivePictures(0); |
---|
1608 | rps->setNumberOfLongtermPictures(0); |
---|
1609 | rps->setNumberOfPictures(0); |
---|
1610 | rpcSlice->setRPS(rps); |
---|
1611 | } |
---|
1612 | else |
---|
1613 | { |
---|
1614 | READ_CODE(sps->getBitsForPOC(), uiCode, "pic_order_cnt_lsb"); |
---|
1615 | Int iPOClsb = uiCode; |
---|
1616 | Int iPrevPOC = rpcSlice->getPrevPOC(); |
---|
1617 | Int iMaxPOClsb = 1<< sps->getBitsForPOC(); |
---|
1618 | Int iPrevPOClsb = iPrevPOC%iMaxPOClsb; |
---|
1619 | Int iPrevPOCmsb = iPrevPOC-iPrevPOClsb; |
---|
1620 | Int iPOCmsb; |
---|
1621 | if( ( iPOClsb < iPrevPOClsb ) && ( ( iPrevPOClsb - iPOClsb ) >= ( iMaxPOClsb / 2 ) ) ) |
---|
1622 | { |
---|
1623 | iPOCmsb = iPrevPOCmsb + iMaxPOClsb; |
---|
1624 | } |
---|
1625 | else if( (iPOClsb > iPrevPOClsb ) && ( (iPOClsb - iPrevPOClsb ) > ( iMaxPOClsb / 2 ) ) ) |
---|
1626 | { |
---|
1627 | iPOCmsb = iPrevPOCmsb - iMaxPOClsb; |
---|
1628 | } |
---|
1629 | else |
---|
1630 | { |
---|
1631 | iPOCmsb = iPrevPOCmsb; |
---|
1632 | } |
---|
1633 | if ( rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP |
---|
1634 | || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL |
---|
1635 | || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP ) |
---|
1636 | { |
---|
1637 | // For BLA picture types, POCmsb is set to 0. |
---|
1638 | iPOCmsb = 0; |
---|
1639 | } |
---|
1640 | rpcSlice->setPOC (iPOCmsb+iPOClsb); |
---|
1641 | |
---|
1642 | TComReferencePictureSet* rps; |
---|
1643 | rps = rpcSlice->getLocalRPS(); |
---|
1644 | rpcSlice->setRPS(rps); |
---|
1645 | READ_FLAG( uiCode, "short_term_ref_pic_set_sps_flag" ); |
---|
1646 | if(uiCode == 0) // use short-term reference picture set explicitly signalled in slice header |
---|
1647 | { |
---|
1648 | parseShortTermRefPicSet(sps,rps, sps->getRPSList()->getNumberOfReferencePictureSets()); |
---|
1649 | } |
---|
1650 | else // use reference to short-term reference picture set in PPS |
---|
1651 | { |
---|
1652 | Int numBits = 0; |
---|
1653 | while ((1 << numBits) < rpcSlice->getSPS()->getRPSList()->getNumberOfReferencePictureSets()) |
---|
1654 | { |
---|
1655 | numBits++; |
---|
1656 | } |
---|
1657 | if (numBits > 0) |
---|
1658 | { |
---|
1659 | READ_CODE( numBits, uiCode, "short_term_ref_pic_set_idx"); |
---|
1660 | } |
---|
1661 | else |
---|
1662 | { |
---|
1663 | uiCode = 0; |
---|
1664 | } |
---|
1665 | *rps = *(sps->getRPSList()->getReferencePictureSet(uiCode)); |
---|
1666 | } |
---|
1667 | if(sps->getLongTermRefsPresent()) |
---|
1668 | { |
---|
1669 | Int offset = rps->getNumberOfNegativePictures()+rps->getNumberOfPositivePictures(); |
---|
1670 | UInt numOfLtrp = 0; |
---|
1671 | UInt numLtrpInSPS = 0; |
---|
1672 | if (rpcSlice->getSPS()->getNumLongTermRefPicSPS() > 0) |
---|
1673 | { |
---|
1674 | READ_UVLC( uiCode, "num_long_term_sps"); |
---|
1675 | numLtrpInSPS = uiCode; |
---|
1676 | numOfLtrp += numLtrpInSPS; |
---|
1677 | rps->setNumberOfLongtermPictures(numOfLtrp); |
---|
1678 | } |
---|
1679 | Int bitsForLtrpInSPS = 0; |
---|
1680 | while (rpcSlice->getSPS()->getNumLongTermRefPicSPS() > (1 << bitsForLtrpInSPS)) |
---|
1681 | { |
---|
1682 | bitsForLtrpInSPS++; |
---|
1683 | } |
---|
1684 | READ_UVLC( uiCode, "num_long_term_pics"); rps->setNumberOfLongtermPictures(uiCode); |
---|
1685 | numOfLtrp += uiCode; |
---|
1686 | rps->setNumberOfLongtermPictures(numOfLtrp); |
---|
1687 | Int maxPicOrderCntLSB = 1 << rpcSlice->getSPS()->getBitsForPOC(); |
---|
1688 | Int prevDeltaMSB = 0, deltaPocMSBCycleLT = 0;; |
---|
1689 | for(Int j=offset+rps->getNumberOfLongtermPictures()-1, k = 0; k < numOfLtrp; j--, k++) |
---|
1690 | { |
---|
1691 | Int pocLsbLt; |
---|
1692 | if (k < numLtrpInSPS) |
---|
1693 | { |
---|
1694 | uiCode = 0; |
---|
1695 | if (bitsForLtrpInSPS > 0) |
---|
1696 | { |
---|
1697 | READ_CODE(bitsForLtrpInSPS, uiCode, "lt_idx_sps[i]"); |
---|
1698 | } |
---|
1699 | Int usedByCurrFromSPS=rpcSlice->getSPS()->getUsedByCurrPicLtSPSFlag(uiCode); |
---|
1700 | |
---|
1701 | pocLsbLt = rpcSlice->getSPS()->getLtRefPicPocLsbSps(uiCode); |
---|
1702 | rps->setUsed(j,usedByCurrFromSPS); |
---|
1703 | } |
---|
1704 | else |
---|
1705 | { |
---|
1706 | READ_CODE(rpcSlice->getSPS()->getBitsForPOC(), uiCode, "poc_lsb_lt"); pocLsbLt= uiCode; |
---|
1707 | READ_FLAG( uiCode, "used_by_curr_pic_lt_flag"); rps->setUsed(j,uiCode); |
---|
1708 | } |
---|
1709 | READ_FLAG(uiCode,"delta_poc_msb_present_flag"); |
---|
1710 | Bool mSBPresentFlag = uiCode ? true : false; |
---|
1711 | if(mSBPresentFlag) |
---|
1712 | { |
---|
1713 | READ_UVLC( uiCode, "delta_poc_msb_cycle_lt[i]" ); |
---|
1714 | Bool deltaFlag = false; |
---|
1715 | // First LTRP || First LTRP from SH |
---|
1716 | if( (j == offset+rps->getNumberOfLongtermPictures()-1) || (j == offset+(numOfLtrp-numLtrpInSPS)-1) ) |
---|
1717 | { |
---|
1718 | deltaFlag = true; |
---|
1719 | } |
---|
1720 | if(deltaFlag) |
---|
1721 | { |
---|
1722 | deltaPocMSBCycleLT = uiCode; |
---|
1723 | } |
---|
1724 | else |
---|
1725 | { |
---|
1726 | deltaPocMSBCycleLT = uiCode + prevDeltaMSB; |
---|
1727 | } |
---|
1728 | |
---|
1729 | Int pocLTCurr = rpcSlice->getPOC() - deltaPocMSBCycleLT * maxPicOrderCntLSB |
---|
1730 | - iPOClsb + pocLsbLt; |
---|
1731 | rps->setPOC (j, pocLTCurr); |
---|
1732 | rps->setDeltaPOC(j, - rpcSlice->getPOC() + pocLTCurr); |
---|
1733 | rps->setCheckLTMSBPresent(j,true); |
---|
1734 | } |
---|
1735 | else |
---|
1736 | { |
---|
1737 | rps->setPOC (j, pocLsbLt); |
---|
1738 | rps->setDeltaPOC(j, - rpcSlice->getPOC() + pocLsbLt); |
---|
1739 | rps->setCheckLTMSBPresent(j,false); |
---|
1740 | } |
---|
1741 | prevDeltaMSB = deltaPocMSBCycleLT; |
---|
1742 | } |
---|
1743 | offset += rps->getNumberOfLongtermPictures(); |
---|
1744 | rps->setNumberOfPictures(offset); |
---|
1745 | } |
---|
1746 | if ( rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP |
---|
1747 | || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL |
---|
1748 | || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP ) |
---|
1749 | { |
---|
1750 | // In the case of BLA picture types, rps data is read from slice header but ignored |
---|
1751 | rps = rpcSlice->getLocalRPS(); |
---|
1752 | rps->setNumberOfNegativePictures(0); |
---|
1753 | rps->setNumberOfPositivePictures(0); |
---|
1754 | rps->setNumberOfLongtermPictures(0); |
---|
1755 | rps->setNumberOfPictures(0); |
---|
1756 | rpcSlice->setRPS(rps); |
---|
1757 | } |
---|
1758 | if (rpcSlice->getSPS()->getTMVPFlagsPresent()) |
---|
1759 | { |
---|
1760 | READ_FLAG( uiCode, "slice_temporal_mvp_enable_flag" ); |
---|
1761 | rpcSlice->setEnableTMVPFlag( uiCode == 1 ? true : false ); |
---|
1762 | } |
---|
1763 | else |
---|
1764 | { |
---|
1765 | rpcSlice->setEnableTMVPFlag(false); |
---|
1766 | } |
---|
1767 | } |
---|
1768 | |
---|
1769 | #if SVC_EXTENSION |
---|
1770 | #if JCTVC_M0458_INTERLAYER_RPS_SIG |
---|
1771 | rpcSlice->setActiveNumILRRefIdx(0); |
---|
1772 | #if ILP_SSH_SIG |
---|
1773 | if((sps->getLayerId() > 0) && rpcSlice->getVPS()->getIlpSshSignalingEnabledFlag() && (rpcSlice->getNumILRRefIdx() > 0) ) |
---|
1774 | #else |
---|
1775 | if((sps->getLayerId() > 0) && (rpcSlice->getNumILRRefIdx() > 0) ) |
---|
1776 | #endif |
---|
1777 | { |
---|
1778 | READ_FLAG(uiCode,"inter_layer_pred_enabled_flag"); |
---|
1779 | rpcSlice->setInterLayerPredEnabledFlag(uiCode); |
---|
1780 | if( rpcSlice->getInterLayerPredEnabledFlag()) |
---|
1781 | { |
---|
1782 | if(rpcSlice->getNumILRRefIdx() > 1) |
---|
1783 | { |
---|
1784 | Int numBits = 1; |
---|
1785 | while ((1 << numBits) < rpcSlice->getNumILRRefIdx()) |
---|
1786 | { |
---|
1787 | numBits++; |
---|
1788 | } |
---|
1789 | if( !rpcSlice->getVPS()->getMaxOneActiveRefLayerFlag()) |
---|
1790 | { |
---|
1791 | READ_CODE( numBits, uiCode,"num_inter_layer_ref_pics_minus1" ); |
---|
1792 | rpcSlice->setActiveNumILRRefIdx(uiCode + 1); |
---|
1793 | } |
---|
1794 | else |
---|
1795 | { |
---|
1796 | rpcSlice->setActiveNumILRRefIdx(1); |
---|
1797 | } |
---|
1798 | #if ILP_NUM_REF_CHK |
---|
1799 | if( rpcSlice->getActiveNumILRRefIdx() == rpcSlice->getNumILRRefIdx() ) |
---|
1800 | { |
---|
1801 | for( Int i = 0; i < rpcSlice->getActiveNumILRRefIdx(); i++ ) |
---|
1802 | { |
---|
1803 | rpcSlice->setInterLayerPredLayerIdc(i,i); |
---|
1804 | } |
---|
1805 | } |
---|
1806 | else |
---|
1807 | { |
---|
1808 | #endif |
---|
1809 | for(Int i = 0; i < rpcSlice->getActiveNumILRRefIdx(); i++ ) |
---|
1810 | { |
---|
1811 | READ_CODE( numBits,uiCode,"inter_layer_pred_layer_idc[i]" ); |
---|
1812 | rpcSlice->setInterLayerPredLayerIdc(uiCode,i); |
---|
1813 | } |
---|
1814 | #if ILP_NUM_REF_CHK |
---|
1815 | } |
---|
1816 | #endif |
---|
1817 | } |
---|
1818 | else |
---|
1819 | { |
---|
1820 | rpcSlice->setActiveNumILRRefIdx(1); |
---|
1821 | rpcSlice->setInterLayerPredLayerIdc(0,0); |
---|
1822 | } |
---|
1823 | } |
---|
1824 | } |
---|
1825 | #if ILP_SSH_SIG |
---|
1826 | else if( rpcSlice->getVPS()->getIlpSshSignalingEnabledFlag() == false ) |
---|
1827 | { |
---|
1828 | rpcSlice->setInterLayerPredEnabledFlag(true); |
---|
1829 | rpcSlice->setActiveNumILRRefIdx(rpcSlice->getNumILRRefIdx()); |
---|
1830 | for( Int i = 0; i < rpcSlice->getActiveNumILRRefIdx(); i++ ) |
---|
1831 | { |
---|
1832 | rpcSlice->setInterLayerPredLayerIdc(i,i); |
---|
1833 | } |
---|
1834 | } |
---|
1835 | #endif |
---|
1836 | #if M0457_IL_SAMPLE_PRED_ONLY_FLAG |
---|
1837 | rpcSlice->setInterLayerSamplePredOnlyFlag( false ); |
---|
1838 | if( rpcSlice->getNumSamplePredRefLayers() > 0 && rpcSlice->getActiveNumILRRefIdx() > 0 ) |
---|
1839 | { |
---|
1840 | READ_FLAG( uiCode, "inter_layer_sample_pred_only_flag" ); |
---|
1841 | rpcSlice->setInterLayerSamplePredOnlyFlag( uiCode > 0 ); |
---|
1842 | } |
---|
1843 | #endif |
---|
1844 | #else |
---|
1845 | if( rpcSlice->getLayerId() > 0 ) |
---|
1846 | { |
---|
1847 | rpcSlice->setNumILRRefIdx( rpcSlice->getVPS()->getNumDirectRefLayers( rpcSlice->getLayerId() ) ); |
---|
1848 | } |
---|
1849 | #endif |
---|
1850 | #endif |
---|
1851 | |
---|
1852 | if(sps->getUseSAO()) |
---|
1853 | { |
---|
1854 | READ_FLAG(uiCode, "slice_sao_luma_flag"); rpcSlice->setSaoEnabledFlag((Bool)uiCode); |
---|
1855 | READ_FLAG(uiCode, "slice_sao_chroma_flag"); rpcSlice->setSaoEnabledFlagChroma((Bool)uiCode); |
---|
1856 | } |
---|
1857 | |
---|
1858 | if (rpcSlice->getIdrPicFlag()) |
---|
1859 | { |
---|
1860 | rpcSlice->setEnableTMVPFlag(false); |
---|
1861 | } |
---|
1862 | if (!rpcSlice->isIntra()) |
---|
1863 | { |
---|
1864 | |
---|
1865 | READ_FLAG( uiCode, "num_ref_idx_active_override_flag"); |
---|
1866 | if (uiCode) |
---|
1867 | { |
---|
1868 | READ_UVLC (uiCode, "num_ref_idx_l0_active_minus1" ); rpcSlice->setNumRefIdx( REF_PIC_LIST_0, uiCode + 1 ); |
---|
1869 | if (rpcSlice->isInterB()) |
---|
1870 | { |
---|
1871 | READ_UVLC (uiCode, "num_ref_idx_l1_active_minus1" ); rpcSlice->setNumRefIdx( REF_PIC_LIST_1, uiCode + 1 ); |
---|
1872 | } |
---|
1873 | else |
---|
1874 | { |
---|
1875 | rpcSlice->setNumRefIdx(REF_PIC_LIST_1, 0); |
---|
1876 | } |
---|
1877 | } |
---|
1878 | else |
---|
1879 | { |
---|
1880 | rpcSlice->setNumRefIdx(REF_PIC_LIST_0, rpcSlice->getPPS()->getNumRefIdxL0DefaultActive()); |
---|
1881 | if (rpcSlice->isInterB()) |
---|
1882 | { |
---|
1883 | rpcSlice->setNumRefIdx(REF_PIC_LIST_1, rpcSlice->getPPS()->getNumRefIdxL1DefaultActive()); |
---|
1884 | } |
---|
1885 | else |
---|
1886 | { |
---|
1887 | rpcSlice->setNumRefIdx(REF_PIC_LIST_1,0); |
---|
1888 | } |
---|
1889 | } |
---|
1890 | } |
---|
1891 | // } |
---|
1892 | TComRefPicListModification* refPicListModification = rpcSlice->getRefPicListModification(); |
---|
1893 | if(!rpcSlice->isIntra()) |
---|
1894 | { |
---|
1895 | if( !rpcSlice->getPPS()->getListsModificationPresentFlag() || rpcSlice->getNumRpsCurrTempList() <= 1 ) |
---|
1896 | { |
---|
1897 | refPicListModification->setRefPicListModificationFlagL0( 0 ); |
---|
1898 | } |
---|
1899 | else |
---|
1900 | { |
---|
1901 | READ_FLAG( uiCode, "ref_pic_list_modification_flag_l0" ); refPicListModification->setRefPicListModificationFlagL0( uiCode ? 1 : 0 ); |
---|
1902 | } |
---|
1903 | |
---|
1904 | if(refPicListModification->getRefPicListModificationFlagL0()) |
---|
1905 | { |
---|
1906 | uiCode = 0; |
---|
1907 | Int i = 0; |
---|
1908 | Int numRpsCurrTempList0 = rpcSlice->getNumRpsCurrTempList(); |
---|
1909 | if ( numRpsCurrTempList0 > 1 ) |
---|
1910 | { |
---|
1911 | Int length = 1; |
---|
1912 | numRpsCurrTempList0 --; |
---|
1913 | while ( numRpsCurrTempList0 >>= 1) |
---|
1914 | { |
---|
1915 | length ++; |
---|
1916 | } |
---|
1917 | for (i = 0; i < rpcSlice->getNumRefIdx(REF_PIC_LIST_0); i ++) |
---|
1918 | { |
---|
1919 | READ_CODE( length, uiCode, "list_entry_l0" ); |
---|
1920 | refPicListModification->setRefPicSetIdxL0(i, uiCode ); |
---|
1921 | } |
---|
1922 | } |
---|
1923 | else |
---|
1924 | { |
---|
1925 | for (i = 0; i < rpcSlice->getNumRefIdx(REF_PIC_LIST_0); i ++) |
---|
1926 | { |
---|
1927 | refPicListModification->setRefPicSetIdxL0(i, 0 ); |
---|
1928 | } |
---|
1929 | } |
---|
1930 | } |
---|
1931 | } |
---|
1932 | else |
---|
1933 | { |
---|
1934 | refPicListModification->setRefPicListModificationFlagL0(0); |
---|
1935 | } |
---|
1936 | if(rpcSlice->isInterB()) |
---|
1937 | { |
---|
1938 | if( !rpcSlice->getPPS()->getListsModificationPresentFlag() || rpcSlice->getNumRpsCurrTempList() <= 1 ) |
---|
1939 | { |
---|
1940 | refPicListModification->setRefPicListModificationFlagL1( 0 ); |
---|
1941 | } |
---|
1942 | else |
---|
1943 | { |
---|
1944 | READ_FLAG( uiCode, "ref_pic_list_modification_flag_l1" ); refPicListModification->setRefPicListModificationFlagL1( uiCode ? 1 : 0 ); |
---|
1945 | } |
---|
1946 | if(refPicListModification->getRefPicListModificationFlagL1()) |
---|
1947 | { |
---|
1948 | uiCode = 0; |
---|
1949 | Int i = 0; |
---|
1950 | Int numRpsCurrTempList1 = rpcSlice->getNumRpsCurrTempList(); |
---|
1951 | if ( numRpsCurrTempList1 > 1 ) |
---|
1952 | { |
---|
1953 | Int length = 1; |
---|
1954 | numRpsCurrTempList1 --; |
---|
1955 | while ( numRpsCurrTempList1 >>= 1) |
---|
1956 | { |
---|
1957 | length ++; |
---|
1958 | } |
---|
1959 | for (i = 0; i < rpcSlice->getNumRefIdx(REF_PIC_LIST_1); i ++) |
---|
1960 | { |
---|
1961 | READ_CODE( length, uiCode, "list_entry_l1" ); |
---|
1962 | refPicListModification->setRefPicSetIdxL1(i, uiCode ); |
---|
1963 | } |
---|
1964 | } |
---|
1965 | else |
---|
1966 | { |
---|
1967 | for (i = 0; i < rpcSlice->getNumRefIdx(REF_PIC_LIST_1); i ++) |
---|
1968 | { |
---|
1969 | refPicListModification->setRefPicSetIdxL1(i, 0 ); |
---|
1970 | } |
---|
1971 | } |
---|
1972 | } |
---|
1973 | } |
---|
1974 | else |
---|
1975 | { |
---|
1976 | refPicListModification->setRefPicListModificationFlagL1(0); |
---|
1977 | } |
---|
1978 | if (rpcSlice->isInterB()) |
---|
1979 | { |
---|
1980 | READ_FLAG( uiCode, "mvd_l1_zero_flag" ); rpcSlice->setMvdL1ZeroFlag( (uiCode ? true : false) ); |
---|
1981 | } |
---|
1982 | |
---|
1983 | rpcSlice->setCabacInitFlag( false ); // default |
---|
1984 | if(pps->getCabacInitPresentFlag() && !rpcSlice->isIntra()) |
---|
1985 | { |
---|
1986 | READ_FLAG(uiCode, "cabac_init_flag"); |
---|
1987 | rpcSlice->setCabacInitFlag( uiCode ? true : false ); |
---|
1988 | } |
---|
1989 | |
---|
1990 | if ( rpcSlice->getEnableTMVPFlag() ) |
---|
1991 | { |
---|
1992 | #if M0457_COL_PICTURE_SIGNALING |
---|
1993 | #if REMOVE_COL_PICTURE_SIGNALING |
---|
1994 | rpcSlice->setMFMEnabledFlag( rpcSlice->getNumMotionPredRefLayers() > 0 ? true : false ); |
---|
1995 | #else |
---|
1996 | rpcSlice->setMFMEnabledFlag( false ); |
---|
1997 | rpcSlice->setColRefLayerIdx( 0 ); |
---|
1998 | rpcSlice->setAltColIndicationFlag( false ); |
---|
1999 | if ( sps->getLayerId() > 0 && rpcSlice->getActiveNumILRRefIdx() > 0 && rpcSlice->getNumMotionPredRefLayers() > 0 ) |
---|
2000 | { |
---|
2001 | READ_FLAG( uiCode, "alt_collocated_indication_flag" ); |
---|
2002 | rpcSlice->setAltColIndicationFlag( uiCode == 1 ? true : false ); |
---|
2003 | rpcSlice->setMFMEnabledFlag( uiCode == 1 ? true : false ); |
---|
2004 | if ( rpcSlice->getNumMotionPredRefLayers() > 1 ) |
---|
2005 | { |
---|
2006 | READ_UVLC( uiCode, "collocated_ref_layer_idx" ); |
---|
2007 | rpcSlice->setColRefLayerIdx( uiCode ); |
---|
2008 | } |
---|
2009 | } |
---|
2010 | else |
---|
2011 | { |
---|
2012 | #endif //REMOVE_COL_PICTURE_SIGNALING |
---|
2013 | #endif |
---|
2014 | if ( rpcSlice->getSliceType() == B_SLICE ) |
---|
2015 | { |
---|
2016 | READ_FLAG( uiCode, "collocated_from_l0_flag" ); |
---|
2017 | rpcSlice->setColFromL0Flag(uiCode); |
---|
2018 | } |
---|
2019 | else |
---|
2020 | { |
---|
2021 | rpcSlice->setColFromL0Flag( 1 ); |
---|
2022 | } |
---|
2023 | |
---|
2024 | if ( rpcSlice->getSliceType() != I_SLICE && |
---|
2025 | ((rpcSlice->getColFromL0Flag() == 1 && rpcSlice->getNumRefIdx(REF_PIC_LIST_0) > 1)|| |
---|
2026 | (rpcSlice->getColFromL0Flag() == 0 && rpcSlice->getNumRefIdx(REF_PIC_LIST_1) > 1))) |
---|
2027 | { |
---|
2028 | READ_UVLC( uiCode, "collocated_ref_idx" ); |
---|
2029 | rpcSlice->setColRefIdx(uiCode); |
---|
2030 | } |
---|
2031 | else |
---|
2032 | { |
---|
2033 | rpcSlice->setColRefIdx(0); |
---|
2034 | } |
---|
2035 | #if M0457_COL_PICTURE_SIGNALING && !REMOVE_COL_PICTURE_SIGNALING |
---|
2036 | } |
---|
2037 | #endif |
---|
2038 | } |
---|
2039 | if ( (pps->getUseWP() && rpcSlice->getSliceType()==P_SLICE) || (pps->getWPBiPred() && rpcSlice->getSliceType()==B_SLICE) ) |
---|
2040 | { |
---|
2041 | xParsePredWeightTable(rpcSlice); |
---|
2042 | rpcSlice->initWpScaling(); |
---|
2043 | } |
---|
2044 | if (!rpcSlice->isIntra()) |
---|
2045 | { |
---|
2046 | READ_UVLC( uiCode, "five_minus_max_num_merge_cand"); |
---|
2047 | rpcSlice->setMaxNumMergeCand(MRG_MAX_NUM_CANDS - uiCode); |
---|
2048 | } |
---|
2049 | |
---|
2050 | READ_SVLC( iCode, "slice_qp_delta" ); |
---|
2051 | rpcSlice->setSliceQp (26 + pps->getPicInitQPMinus26() + iCode); |
---|
2052 | |
---|
2053 | #if REPN_FORMAT_IN_VPS |
---|
2054 | assert( rpcSlice->getSliceQp() >= -rpcSlice->getQpBDOffsetY() ); |
---|
2055 | #else |
---|
2056 | assert( rpcSlice->getSliceQp() >= -sps->getQpBDOffsetY() ); |
---|
2057 | #endif |
---|
2058 | assert( rpcSlice->getSliceQp() <= 51 ); |
---|
2059 | |
---|
2060 | if (rpcSlice->getPPS()->getSliceChromaQpFlag()) |
---|
2061 | { |
---|
2062 | READ_SVLC( iCode, "slice_qp_delta_cb" ); |
---|
2063 | rpcSlice->setSliceQpDeltaCb( iCode ); |
---|
2064 | assert( rpcSlice->getSliceQpDeltaCb() >= -12 ); |
---|
2065 | assert( rpcSlice->getSliceQpDeltaCb() <= 12 ); |
---|
2066 | assert( (rpcSlice->getPPS()->getChromaCbQpOffset() + rpcSlice->getSliceQpDeltaCb()) >= -12 ); |
---|
2067 | assert( (rpcSlice->getPPS()->getChromaCbQpOffset() + rpcSlice->getSliceQpDeltaCb()) <= 12 ); |
---|
2068 | |
---|
2069 | READ_SVLC( iCode, "slice_qp_delta_cr" ); |
---|
2070 | rpcSlice->setSliceQpDeltaCr( iCode ); |
---|
2071 | assert( rpcSlice->getSliceQpDeltaCr() >= -12 ); |
---|
2072 | assert( rpcSlice->getSliceQpDeltaCr() <= 12 ); |
---|
2073 | assert( (rpcSlice->getPPS()->getChromaCrQpOffset() + rpcSlice->getSliceQpDeltaCr()) >= -12 ); |
---|
2074 | assert( (rpcSlice->getPPS()->getChromaCrQpOffset() + rpcSlice->getSliceQpDeltaCr()) <= 12 ); |
---|
2075 | } |
---|
2076 | |
---|
2077 | if (rpcSlice->getPPS()->getDeblockingFilterControlPresentFlag()) |
---|
2078 | { |
---|
2079 | if(rpcSlice->getPPS()->getDeblockingFilterOverrideEnabledFlag()) |
---|
2080 | { |
---|
2081 | READ_FLAG ( uiCode, "deblocking_filter_override_flag" ); rpcSlice->setDeblockingFilterOverrideFlag(uiCode ? true : false); |
---|
2082 | } |
---|
2083 | else |
---|
2084 | { |
---|
2085 | rpcSlice->setDeblockingFilterOverrideFlag(0); |
---|
2086 | } |
---|
2087 | if(rpcSlice->getDeblockingFilterOverrideFlag()) |
---|
2088 | { |
---|
2089 | READ_FLAG ( uiCode, "slice_disable_deblocking_filter_flag" ); rpcSlice->setDeblockingFilterDisable(uiCode ? 1 : 0); |
---|
2090 | if(!rpcSlice->getDeblockingFilterDisable()) |
---|
2091 | { |
---|
2092 | READ_SVLC( iCode, "slice_beta_offset_div2" ); rpcSlice->setDeblockingFilterBetaOffsetDiv2(iCode); |
---|
2093 | assert(rpcSlice->getDeblockingFilterBetaOffsetDiv2() >= -6 && |
---|
2094 | rpcSlice->getDeblockingFilterBetaOffsetDiv2() <= 6); |
---|
2095 | READ_SVLC( iCode, "slice_tc_offset_div2" ); rpcSlice->setDeblockingFilterTcOffsetDiv2(iCode); |
---|
2096 | assert(rpcSlice->getDeblockingFilterTcOffsetDiv2() >= -6 && |
---|
2097 | rpcSlice->getDeblockingFilterTcOffsetDiv2() <= 6); |
---|
2098 | } |
---|
2099 | } |
---|
2100 | else |
---|
2101 | { |
---|
2102 | rpcSlice->setDeblockingFilterDisable ( rpcSlice->getPPS()->getPicDisableDeblockingFilterFlag() ); |
---|
2103 | rpcSlice->setDeblockingFilterBetaOffsetDiv2( rpcSlice->getPPS()->getDeblockingFilterBetaOffsetDiv2() ); |
---|
2104 | rpcSlice->setDeblockingFilterTcOffsetDiv2 ( rpcSlice->getPPS()->getDeblockingFilterTcOffsetDiv2() ); |
---|
2105 | } |
---|
2106 | } |
---|
2107 | else |
---|
2108 | { |
---|
2109 | rpcSlice->setDeblockingFilterDisable ( false ); |
---|
2110 | rpcSlice->setDeblockingFilterBetaOffsetDiv2( 0 ); |
---|
2111 | rpcSlice->setDeblockingFilterTcOffsetDiv2 ( 0 ); |
---|
2112 | } |
---|
2113 | |
---|
2114 | Bool isSAOEnabled = (!rpcSlice->getSPS()->getUseSAO())?(false):(rpcSlice->getSaoEnabledFlag()||rpcSlice->getSaoEnabledFlagChroma()); |
---|
2115 | Bool isDBFEnabled = (!rpcSlice->getDeblockingFilterDisable()); |
---|
2116 | |
---|
2117 | if(rpcSlice->getPPS()->getLoopFilterAcrossSlicesEnabledFlag() && ( isSAOEnabled || isDBFEnabled )) |
---|
2118 | { |
---|
2119 | READ_FLAG( uiCode, "slice_loop_filter_across_slices_enabled_flag"); |
---|
2120 | } |
---|
2121 | else |
---|
2122 | { |
---|
2123 | uiCode = rpcSlice->getPPS()->getLoopFilterAcrossSlicesEnabledFlag()?1:0; |
---|
2124 | } |
---|
2125 | rpcSlice->setLFCrossSliceBoundaryFlag( (uiCode==1)?true:false); |
---|
2126 | |
---|
2127 | } |
---|
2128 | |
---|
2129 | UInt *entryPointOffset = NULL; |
---|
2130 | UInt numEntryPointOffsets, offsetLenMinus1; |
---|
2131 | if( pps->getTilesEnabledFlag() || pps->getEntropyCodingSyncEnabledFlag() ) |
---|
2132 | { |
---|
2133 | READ_UVLC(numEntryPointOffsets, "num_entry_point_offsets"); rpcSlice->setNumEntryPointOffsets ( numEntryPointOffsets ); |
---|
2134 | if (numEntryPointOffsets>0) |
---|
2135 | { |
---|
2136 | READ_UVLC(offsetLenMinus1, "offset_len_minus1"); |
---|
2137 | } |
---|
2138 | entryPointOffset = new UInt[numEntryPointOffsets]; |
---|
2139 | for (UInt idx=0; idx<numEntryPointOffsets; idx++) |
---|
2140 | { |
---|
2141 | READ_CODE(offsetLenMinus1+1, uiCode, "entry_point_offset_minus1"); |
---|
2142 | entryPointOffset[ idx ] = uiCode + 1; |
---|
2143 | } |
---|
2144 | } |
---|
2145 | else |
---|
2146 | { |
---|
2147 | rpcSlice->setNumEntryPointOffsets ( 0 ); |
---|
2148 | } |
---|
2149 | |
---|
2150 | if(pps->getSliceHeaderExtensionPresentFlag()) |
---|
2151 | { |
---|
2152 | READ_UVLC(uiCode,"slice_header_extension_length"); |
---|
2153 | for(Int i=0; i<uiCode; i++) |
---|
2154 | { |
---|
2155 | UInt ignore; |
---|
2156 | READ_CODE(8,ignore,"slice_header_extension_data_byte"); |
---|
2157 | } |
---|
2158 | } |
---|
2159 | m_pcBitstream->readByteAlignment(); |
---|
2160 | |
---|
2161 | if( pps->getTilesEnabledFlag() || pps->getEntropyCodingSyncEnabledFlag() ) |
---|
2162 | { |
---|
2163 | Int endOfSliceHeaderLocation = m_pcBitstream->getByteLocation(); |
---|
2164 | |
---|
2165 | // Adjust endOfSliceHeaderLocation to account for emulation prevention bytes in the slice segment header |
---|
2166 | for ( UInt curByteIdx = 0; curByteIdx<m_pcBitstream->numEmulationPreventionBytesRead(); curByteIdx++ ) |
---|
2167 | { |
---|
2168 | if ( m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) < endOfSliceHeaderLocation ) |
---|
2169 | { |
---|
2170 | endOfSliceHeaderLocation++; |
---|
2171 | } |
---|
2172 | } |
---|
2173 | |
---|
2174 | Int curEntryPointOffset = 0; |
---|
2175 | Int prevEntryPointOffset = 0; |
---|
2176 | for (UInt idx=0; idx<numEntryPointOffsets; idx++) |
---|
2177 | { |
---|
2178 | curEntryPointOffset += entryPointOffset[ idx ]; |
---|
2179 | |
---|
2180 | Int emulationPreventionByteCount = 0; |
---|
2181 | for ( UInt curByteIdx = 0; curByteIdx<m_pcBitstream->numEmulationPreventionBytesRead(); curByteIdx++ ) |
---|
2182 | { |
---|
2183 | if ( m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) >= ( prevEntryPointOffset + endOfSliceHeaderLocation ) && |
---|
2184 | m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) < ( curEntryPointOffset + endOfSliceHeaderLocation ) ) |
---|
2185 | { |
---|
2186 | emulationPreventionByteCount++; |
---|
2187 | } |
---|
2188 | } |
---|
2189 | |
---|
2190 | entryPointOffset[ idx ] -= emulationPreventionByteCount; |
---|
2191 | prevEntryPointOffset = curEntryPointOffset; |
---|
2192 | } |
---|
2193 | |
---|
2194 | if ( pps->getTilesEnabledFlag() ) |
---|
2195 | { |
---|
2196 | rpcSlice->setTileLocationCount( numEntryPointOffsets ); |
---|
2197 | |
---|
2198 | UInt prevPos = 0; |
---|
2199 | for (Int idx=0; idx<rpcSlice->getTileLocationCount(); idx++) |
---|
2200 | { |
---|
2201 | rpcSlice->setTileLocation( idx, prevPos + entryPointOffset [ idx ] ); |
---|
2202 | prevPos += entryPointOffset[ idx ]; |
---|
2203 | } |
---|
2204 | } |
---|
2205 | else if ( pps->getEntropyCodingSyncEnabledFlag() ) |
---|
2206 | { |
---|
2207 | Int numSubstreams = rpcSlice->getNumEntryPointOffsets()+1; |
---|
2208 | rpcSlice->allocSubstreamSizes(numSubstreams); |
---|
2209 | UInt *pSubstreamSizes = rpcSlice->getSubstreamSizes(); |
---|
2210 | for (Int idx=0; idx<numSubstreams-1; idx++) |
---|
2211 | { |
---|
2212 | if ( idx < numEntryPointOffsets ) |
---|
2213 | { |
---|
2214 | pSubstreamSizes[ idx ] = ( entryPointOffset[ idx ] << 3 ) ; |
---|
2215 | } |
---|
2216 | else |
---|
2217 | { |
---|
2218 | pSubstreamSizes[ idx ] = 0; |
---|
2219 | } |
---|
2220 | } |
---|
2221 | } |
---|
2222 | |
---|
2223 | if (entryPointOffset) |
---|
2224 | { |
---|
2225 | delete [] entryPointOffset; |
---|
2226 | } |
---|
2227 | } |
---|
2228 | |
---|
2229 | return; |
---|
2230 | } |
---|
2231 | |
---|
2232 | Void TDecCavlc::parsePTL( TComPTL *rpcPTL, Bool profilePresentFlag, Int maxNumSubLayersMinus1 ) |
---|
2233 | { |
---|
2234 | UInt uiCode; |
---|
2235 | if(profilePresentFlag) |
---|
2236 | { |
---|
2237 | parseProfileTier(rpcPTL->getGeneralPTL()); |
---|
2238 | } |
---|
2239 | READ_CODE( 8, uiCode, "general_level_idc" ); rpcPTL->getGeneralPTL()->setLevelIdc(uiCode); |
---|
2240 | |
---|
2241 | for (Int i = 0; i < maxNumSubLayersMinus1; i++) |
---|
2242 | { |
---|
2243 | if(profilePresentFlag) |
---|
2244 | { |
---|
2245 | READ_FLAG( uiCode, "sub_layer_profile_present_flag[i]" ); rpcPTL->setSubLayerProfilePresentFlag(i, uiCode); |
---|
2246 | } |
---|
2247 | READ_FLAG( uiCode, "sub_layer_level_present_flag[i]" ); rpcPTL->setSubLayerLevelPresentFlag (i, uiCode); |
---|
2248 | } |
---|
2249 | |
---|
2250 | if (maxNumSubLayersMinus1 > 0) |
---|
2251 | { |
---|
2252 | for (Int i = maxNumSubLayersMinus1; i < 8; i++) |
---|
2253 | { |
---|
2254 | READ_CODE(2, uiCode, "reserved_zero_2bits"); |
---|
2255 | assert(uiCode == 0); |
---|
2256 | } |
---|
2257 | } |
---|
2258 | |
---|
2259 | for(Int i = 0; i < maxNumSubLayersMinus1; i++) |
---|
2260 | { |
---|
2261 | if( profilePresentFlag && rpcPTL->getSubLayerProfilePresentFlag(i) ) |
---|
2262 | { |
---|
2263 | parseProfileTier(rpcPTL->getSubLayerPTL(i)); |
---|
2264 | } |
---|
2265 | if(rpcPTL->getSubLayerLevelPresentFlag(i)) |
---|
2266 | { |
---|
2267 | READ_CODE( 8, uiCode, "sub_layer_level_idc[i]" ); rpcPTL->getSubLayerPTL(i)->setLevelIdc(uiCode); |
---|
2268 | } |
---|
2269 | } |
---|
2270 | } |
---|
2271 | |
---|
2272 | Void TDecCavlc::parseProfileTier(ProfileTierLevel *ptl) |
---|
2273 | { |
---|
2274 | UInt uiCode; |
---|
2275 | READ_CODE(2 , uiCode, "XXX_profile_space[]"); ptl->setProfileSpace(uiCode); |
---|
2276 | READ_FLAG( uiCode, "XXX_tier_flag[]" ); ptl->setTierFlag (uiCode ? 1 : 0); |
---|
2277 | READ_CODE(5 , uiCode, "XXX_profile_idc[]" ); ptl->setProfileIdc (uiCode); |
---|
2278 | for(Int j = 0; j < 32; j++) |
---|
2279 | { |
---|
2280 | READ_FLAG( uiCode, "XXX_profile_compatibility_flag[][j]"); ptl->setProfileCompatibilityFlag(j, uiCode ? 1 : 0); |
---|
2281 | } |
---|
2282 | READ_FLAG(uiCode, "general_progressive_source_flag"); |
---|
2283 | ptl->setProgressiveSourceFlag(uiCode ? true : false); |
---|
2284 | |
---|
2285 | READ_FLAG(uiCode, "general_interlaced_source_flag"); |
---|
2286 | ptl->setInterlacedSourceFlag(uiCode ? true : false); |
---|
2287 | |
---|
2288 | READ_FLAG(uiCode, "general_non_packed_constraint_flag"); |
---|
2289 | ptl->setNonPackedConstraintFlag(uiCode ? true : false); |
---|
2290 | |
---|
2291 | READ_FLAG(uiCode, "general_frame_only_constraint_flag"); |
---|
2292 | ptl->setFrameOnlyConstraintFlag(uiCode ? true : false); |
---|
2293 | |
---|
2294 | READ_CODE(16, uiCode, "XXX_reserved_zero_44bits[0..15]"); |
---|
2295 | READ_CODE(16, uiCode, "XXX_reserved_zero_44bits[16..31]"); |
---|
2296 | READ_CODE(12, uiCode, "XXX_reserved_zero_44bits[32..43]"); |
---|
2297 | } |
---|
2298 | |
---|
2299 | Void TDecCavlc::parseTerminatingBit( UInt& ruiBit ) |
---|
2300 | { |
---|
2301 | ruiBit = false; |
---|
2302 | Int iBitsLeft = m_pcBitstream->getNumBitsLeft(); |
---|
2303 | if(iBitsLeft <= 8) |
---|
2304 | { |
---|
2305 | UInt uiPeekValue = m_pcBitstream->peekBits(iBitsLeft); |
---|
2306 | if (uiPeekValue == (1<<(iBitsLeft-1))) |
---|
2307 | { |
---|
2308 | ruiBit = true; |
---|
2309 | } |
---|
2310 | } |
---|
2311 | } |
---|
2312 | |
---|
2313 | Void TDecCavlc::parseSkipFlag( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
2314 | { |
---|
2315 | assert(0); |
---|
2316 | } |
---|
2317 | |
---|
2318 | Void TDecCavlc::parseCUTransquantBypassFlag( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
2319 | { |
---|
2320 | assert(0); |
---|
2321 | } |
---|
2322 | |
---|
2323 | Void TDecCavlc::parseMVPIdx( Int& /*riMVPIdx*/ ) |
---|
2324 | { |
---|
2325 | assert(0); |
---|
2326 | } |
---|
2327 | |
---|
2328 | Void TDecCavlc::parseSplitFlag ( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
2329 | { |
---|
2330 | assert(0); |
---|
2331 | } |
---|
2332 | |
---|
2333 | Void TDecCavlc::parsePartSize( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
2334 | { |
---|
2335 | assert(0); |
---|
2336 | } |
---|
2337 | |
---|
2338 | Void TDecCavlc::parsePredMode( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
2339 | { |
---|
2340 | assert(0); |
---|
2341 | } |
---|
2342 | |
---|
2343 | /** Parse I_PCM information. |
---|
2344 | * \param pcCU pointer to CU |
---|
2345 | * \param uiAbsPartIdx CU index |
---|
2346 | * \param uiDepth CU depth |
---|
2347 | * \returns Void |
---|
2348 | * |
---|
2349 | * If I_PCM flag indicates that the CU is I_PCM, parse its PCM alignment bits and codes. |
---|
2350 | */ |
---|
2351 | Void TDecCavlc::parseIPCMInfo( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
2352 | { |
---|
2353 | assert(0); |
---|
2354 | } |
---|
2355 | |
---|
2356 | Void TDecCavlc::parseIntraDirLumaAng ( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
2357 | { |
---|
2358 | assert(0); |
---|
2359 | } |
---|
2360 | |
---|
2361 | Void TDecCavlc::parseIntraDirChroma( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
2362 | { |
---|
2363 | assert(0); |
---|
2364 | } |
---|
2365 | |
---|
2366 | Void TDecCavlc::parseInterDir( TComDataCU* /*pcCU*/, UInt& /*ruiInterDir*/, UInt /*uiAbsPartIdx*/ ) |
---|
2367 | { |
---|
2368 | assert(0); |
---|
2369 | } |
---|
2370 | |
---|
2371 | Void TDecCavlc::parseRefFrmIdx( TComDataCU* /*pcCU*/, Int& /*riRefFrmIdx*/, RefPicList /*eRefList*/ ) |
---|
2372 | { |
---|
2373 | assert(0); |
---|
2374 | } |
---|
2375 | |
---|
2376 | Void TDecCavlc::parseMvd( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiPartIdx*/, UInt /*uiDepth*/, RefPicList /*eRefList*/ ) |
---|
2377 | { |
---|
2378 | assert(0); |
---|
2379 | } |
---|
2380 | |
---|
2381 | Void TDecCavlc::parseDeltaQP( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2382 | { |
---|
2383 | Int qp; |
---|
2384 | Int iDQp; |
---|
2385 | |
---|
2386 | xReadSvlc( iDQp ); |
---|
2387 | |
---|
2388 | #if REPN_FORMAT_IN_VPS |
---|
2389 | Int qpBdOffsetY = pcCU->getSlice()->getQpBDOffsetY(); |
---|
2390 | #else |
---|
2391 | Int qpBdOffsetY = pcCU->getSlice()->getSPS()->getQpBDOffsetY(); |
---|
2392 | #endif |
---|
2393 | qp = (((Int) pcCU->getRefQP( uiAbsPartIdx ) + iDQp + 52 + 2*qpBdOffsetY )%(52+ qpBdOffsetY)) - qpBdOffsetY; |
---|
2394 | |
---|
2395 | UInt uiAbsQpCUPartIdx = (uiAbsPartIdx>>((g_uiMaxCUDepth - pcCU->getSlice()->getPPS()->getMaxCuDQPDepth())<<1))<<((g_uiMaxCUDepth - pcCU->getSlice()->getPPS()->getMaxCuDQPDepth())<<1) ; |
---|
2396 | UInt uiQpCUDepth = min(uiDepth,pcCU->getSlice()->getPPS()->getMaxCuDQPDepth()) ; |
---|
2397 | |
---|
2398 | pcCU->setQPSubParts( qp, uiAbsQpCUPartIdx, uiQpCUDepth ); |
---|
2399 | } |
---|
2400 | |
---|
2401 | Void TDecCavlc::parseCoeffNxN( TComDataCU* /*pcCU*/, TCoeff* /*pcCoef*/, UInt /*uiAbsPartIdx*/, UInt /*uiWidth*/, UInt /*uiHeight*/, UInt /*uiDepth*/, TextType /*eTType*/ ) |
---|
2402 | { |
---|
2403 | assert(0); |
---|
2404 | } |
---|
2405 | |
---|
2406 | Void TDecCavlc::parseTransformSubdivFlag( UInt& /*ruiSubdivFlag*/, UInt /*uiLog2TransformBlockSize*/ ) |
---|
2407 | { |
---|
2408 | assert(0); |
---|
2409 | } |
---|
2410 | |
---|
2411 | Void TDecCavlc::parseQtCbf( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, TextType /*eType*/, UInt /*uiTrDepth*/, UInt /*uiDepth*/ ) |
---|
2412 | { |
---|
2413 | assert(0); |
---|
2414 | } |
---|
2415 | |
---|
2416 | Void TDecCavlc::parseQtRootCbf( UInt /*uiAbsPartIdx*/, UInt& /*uiQtRootCbf*/ ) |
---|
2417 | { |
---|
2418 | assert(0); |
---|
2419 | } |
---|
2420 | |
---|
2421 | Void TDecCavlc::parseTransformSkipFlags (TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*width*/, UInt /*height*/, UInt /*uiDepth*/, TextType /*eTType*/) |
---|
2422 | { |
---|
2423 | assert(0); |
---|
2424 | } |
---|
2425 | |
---|
2426 | Void TDecCavlc::parseMergeFlag ( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/, UInt /*uiPUIdx*/ ) |
---|
2427 | { |
---|
2428 | assert(0); |
---|
2429 | } |
---|
2430 | |
---|
2431 | Void TDecCavlc::parseMergeIndex ( TComDataCU* /*pcCU*/, UInt& /*ruiMergeIndex*/ ) |
---|
2432 | { |
---|
2433 | assert(0); |
---|
2434 | } |
---|
2435 | |
---|
2436 | // ==================================================================================================================== |
---|
2437 | // Protected member functions |
---|
2438 | // ==================================================================================================================== |
---|
2439 | |
---|
2440 | /** parse explicit wp tables |
---|
2441 | * \param TComSlice* pcSlice |
---|
2442 | * \returns Void |
---|
2443 | */ |
---|
2444 | Void TDecCavlc::xParsePredWeightTable( TComSlice* pcSlice ) |
---|
2445 | { |
---|
2446 | wpScalingParam *wp; |
---|
2447 | Bool bChroma = true; // color always present in HEVC ? |
---|
2448 | SliceType eSliceType = pcSlice->getSliceType(); |
---|
2449 | Int iNbRef = (eSliceType == B_SLICE ) ? (2) : (1); |
---|
2450 | UInt uiLog2WeightDenomLuma, uiLog2WeightDenomChroma; |
---|
2451 | UInt uiTotalSignalledWeightFlags = 0; |
---|
2452 | |
---|
2453 | Int iDeltaDenom; |
---|
2454 | // decode delta_luma_log2_weight_denom : |
---|
2455 | READ_UVLC( uiLog2WeightDenomLuma, "luma_log2_weight_denom" ); // ue(v): luma_log2_weight_denom |
---|
2456 | assert( uiLog2WeightDenomLuma <= 7 ); |
---|
2457 | if( bChroma ) |
---|
2458 | { |
---|
2459 | READ_SVLC( iDeltaDenom, "delta_chroma_log2_weight_denom" ); // se(v): delta_chroma_log2_weight_denom |
---|
2460 | assert((iDeltaDenom + (Int)uiLog2WeightDenomLuma)>=0); |
---|
2461 | assert((iDeltaDenom + (Int)uiLog2WeightDenomLuma)<=7); |
---|
2462 | uiLog2WeightDenomChroma = (UInt)(iDeltaDenom + uiLog2WeightDenomLuma); |
---|
2463 | } |
---|
2464 | |
---|
2465 | for ( Int iNumRef=0 ; iNumRef<iNbRef ; iNumRef++ ) |
---|
2466 | { |
---|
2467 | RefPicList eRefPicList = ( iNumRef ? REF_PIC_LIST_1 : REF_PIC_LIST_0 ); |
---|
2468 | for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ ) |
---|
2469 | { |
---|
2470 | pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); |
---|
2471 | |
---|
2472 | wp[0].uiLog2WeightDenom = uiLog2WeightDenomLuma; |
---|
2473 | wp[1].uiLog2WeightDenom = uiLog2WeightDenomChroma; |
---|
2474 | wp[2].uiLog2WeightDenom = uiLog2WeightDenomChroma; |
---|
2475 | |
---|
2476 | UInt uiCode; |
---|
2477 | READ_FLAG( uiCode, "luma_weight_lX_flag" ); // u(1): luma_weight_l0_flag |
---|
2478 | wp[0].bPresentFlag = ( uiCode == 1 ); |
---|
2479 | uiTotalSignalledWeightFlags += wp[0].bPresentFlag; |
---|
2480 | } |
---|
2481 | if ( bChroma ) |
---|
2482 | { |
---|
2483 | UInt uiCode; |
---|
2484 | for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ ) |
---|
2485 | { |
---|
2486 | pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); |
---|
2487 | READ_FLAG( uiCode, "chroma_weight_lX_flag" ); // u(1): chroma_weight_l0_flag |
---|
2488 | wp[1].bPresentFlag = ( uiCode == 1 ); |
---|
2489 | wp[2].bPresentFlag = ( uiCode == 1 ); |
---|
2490 | uiTotalSignalledWeightFlags += 2*wp[1].bPresentFlag; |
---|
2491 | } |
---|
2492 | } |
---|
2493 | for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ ) |
---|
2494 | { |
---|
2495 | pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); |
---|
2496 | if ( wp[0].bPresentFlag ) |
---|
2497 | { |
---|
2498 | Int iDeltaWeight; |
---|
2499 | READ_SVLC( iDeltaWeight, "delta_luma_weight_lX" ); // se(v): delta_luma_weight_l0[i] |
---|
2500 | assert( iDeltaWeight >= -128 ); |
---|
2501 | assert( iDeltaWeight <= 127 ); |
---|
2502 | wp[0].iWeight = (iDeltaWeight + (1<<wp[0].uiLog2WeightDenom)); |
---|
2503 | READ_SVLC( wp[0].iOffset, "luma_offset_lX" ); // se(v): luma_offset_l0[i] |
---|
2504 | assert( wp[0].iOffset >= -128 ); |
---|
2505 | assert( wp[0].iOffset <= 127 ); |
---|
2506 | } |
---|
2507 | else |
---|
2508 | { |
---|
2509 | wp[0].iWeight = (1 << wp[0].uiLog2WeightDenom); |
---|
2510 | wp[0].iOffset = 0; |
---|
2511 | } |
---|
2512 | if ( bChroma ) |
---|
2513 | { |
---|
2514 | if ( wp[1].bPresentFlag ) |
---|
2515 | { |
---|
2516 | for ( Int j=1 ; j<3 ; j++ ) |
---|
2517 | { |
---|
2518 | Int iDeltaWeight; |
---|
2519 | READ_SVLC( iDeltaWeight, "delta_chroma_weight_lX" ); // se(v): chroma_weight_l0[i][j] |
---|
2520 | assert( iDeltaWeight >= -128 ); |
---|
2521 | assert( iDeltaWeight <= 127 ); |
---|
2522 | wp[j].iWeight = (iDeltaWeight + (1<<wp[1].uiLog2WeightDenom)); |
---|
2523 | |
---|
2524 | Int iDeltaChroma; |
---|
2525 | READ_SVLC( iDeltaChroma, "delta_chroma_offset_lX" ); // se(v): delta_chroma_offset_l0[i][j] |
---|
2526 | assert( iDeltaChroma >= -512 ); |
---|
2527 | assert( iDeltaChroma <= 511 ); |
---|
2528 | Int pred = ( 128 - ( ( 128*wp[j].iWeight)>>(wp[j].uiLog2WeightDenom) ) ); |
---|
2529 | wp[j].iOffset = Clip3(-128, 127, (iDeltaChroma + pred) ); |
---|
2530 | } |
---|
2531 | } |
---|
2532 | else |
---|
2533 | { |
---|
2534 | for ( Int j=1 ; j<3 ; j++ ) |
---|
2535 | { |
---|
2536 | wp[j].iWeight = (1 << wp[j].uiLog2WeightDenom); |
---|
2537 | wp[j].iOffset = 0; |
---|
2538 | } |
---|
2539 | } |
---|
2540 | } |
---|
2541 | } |
---|
2542 | |
---|
2543 | for ( Int iRefIdx=pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx<MAX_NUM_REF ; iRefIdx++ ) |
---|
2544 | { |
---|
2545 | pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); |
---|
2546 | |
---|
2547 | wp[0].bPresentFlag = false; |
---|
2548 | wp[1].bPresentFlag = false; |
---|
2549 | wp[2].bPresentFlag = false; |
---|
2550 | } |
---|
2551 | } |
---|
2552 | assert(uiTotalSignalledWeightFlags<=24); |
---|
2553 | } |
---|
2554 | |
---|
2555 | /** decode quantization matrix |
---|
2556 | * \param scalingList quantization matrix information |
---|
2557 | */ |
---|
2558 | Void TDecCavlc::parseScalingList(TComScalingList* scalingList) |
---|
2559 | { |
---|
2560 | UInt code, sizeId, listId; |
---|
2561 | Bool scalingListPredModeFlag; |
---|
2562 | |
---|
2563 | //for each size |
---|
2564 | for(sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
2565 | { |
---|
2566 | for(listId = 0; listId < g_scalingListNum[sizeId]; listId++) |
---|
2567 | { |
---|
2568 | #if IL_SL_SIGNALLING_N0371 |
---|
2569 | if ( scalingList->getLayerId() > 0 && scalingList->getPredScalingListFlag() ) |
---|
2570 | { |
---|
2571 | READ_FLAG( code, "scaling_list_pred_mode_flag"); |
---|
2572 | scalingListPredModeFlag = (code) ? true : false; |
---|
2573 | if(!scalingListPredModeFlag) //Copy Mode |
---|
2574 | { |
---|
2575 | READ_UVLC( code, "scaling_list_pred_matrix_id_delta"); |
---|
2576 | scalingList->setRefMatrixId (sizeId,listId,(UInt)((Int)(listId)-(code))); |
---|
2577 | if( sizeId > SCALING_LIST_8x8 ) |
---|
2578 | { |
---|
2579 | scalingList->setScalingListDC(sizeId,listId,((listId == scalingList->getRefMatrixId (sizeId,listId))? 16 :scalingList->getScalingListDC(sizeId, scalingList->getRefMatrixId (sizeId,listId)))); |
---|
2580 | } |
---|
2581 | scalingList->processRefMatrix( sizeId, listId, scalingList->getRefMatrixId (sizeId,listId)); |
---|
2582 | |
---|
2583 | } |
---|
2584 | else //DPCM Mode |
---|
2585 | { |
---|
2586 | xDecodeScalingList(scalingList, sizeId, listId); |
---|
2587 | } |
---|
2588 | } |
---|
2589 | else |
---|
2590 | { |
---|
2591 | READ_FLAG( code, "scaling_list_pred_mode_flag"); |
---|
2592 | scalingListPredModeFlag = (code) ? true : false; |
---|
2593 | if(!scalingListPredModeFlag) //Copy Mode |
---|
2594 | { |
---|
2595 | READ_UVLC( code, "scaling_list_pred_matrix_id_delta"); |
---|
2596 | scalingList->setRefMatrixId (sizeId,listId,(UInt)((Int)(listId)-(code))); |
---|
2597 | if( sizeId > SCALING_LIST_8x8 ) |
---|
2598 | { |
---|
2599 | scalingList->setScalingListDC(sizeId,listId,((listId == scalingList->getRefMatrixId (sizeId,listId))? 16 :scalingList->getScalingListDC(sizeId, scalingList->getRefMatrixId (sizeId,listId)))); |
---|
2600 | } |
---|
2601 | scalingList->processRefMatrix( sizeId, listId, scalingList->getRefMatrixId (sizeId,listId)); |
---|
2602 | |
---|
2603 | } |
---|
2604 | else //DPCM Mode |
---|
2605 | { |
---|
2606 | xDecodeScalingList(scalingList, sizeId, listId); |
---|
2607 | } |
---|
2608 | } |
---|
2609 | #else |
---|
2610 | READ_FLAG( code, "scaling_list_pred_mode_flag"); |
---|
2611 | scalingListPredModeFlag = (code) ? true : false; |
---|
2612 | if(!scalingListPredModeFlag) //Copy Mode |
---|
2613 | { |
---|
2614 | READ_UVLC( code, "scaling_list_pred_matrix_id_delta"); |
---|
2615 | scalingList->setRefMatrixId (sizeId,listId,(UInt)((Int)(listId)-(code))); |
---|
2616 | if( sizeId > SCALING_LIST_8x8 ) |
---|
2617 | { |
---|
2618 | scalingList->setScalingListDC(sizeId,listId,((listId == scalingList->getRefMatrixId (sizeId,listId))? 16 :scalingList->getScalingListDC(sizeId, scalingList->getRefMatrixId (sizeId,listId)))); |
---|
2619 | } |
---|
2620 | scalingList->processRefMatrix( sizeId, listId, scalingList->getRefMatrixId (sizeId,listId)); |
---|
2621 | |
---|
2622 | } |
---|
2623 | else //DPCM Mode |
---|
2624 | { |
---|
2625 | xDecodeScalingList(scalingList, sizeId, listId); |
---|
2626 | } |
---|
2627 | #endif |
---|
2628 | } |
---|
2629 | } |
---|
2630 | |
---|
2631 | return; |
---|
2632 | } |
---|
2633 | /** decode DPCM |
---|
2634 | * \param scalingList quantization matrix information |
---|
2635 | * \param sizeId size index |
---|
2636 | * \param listId list index |
---|
2637 | */ |
---|
2638 | Void TDecCavlc::xDecodeScalingList(TComScalingList *scalingList, UInt sizeId, UInt listId) |
---|
2639 | { |
---|
2640 | Int i,coefNum = min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId]); |
---|
2641 | Int data; |
---|
2642 | Int scalingListDcCoefMinus8 = 0; |
---|
2643 | Int nextCoef = SCALING_LIST_START_VALUE; |
---|
2644 | UInt* scan = (sizeId == 0) ? g_auiSigLastScan [ SCAN_DIAG ] [ 1 ] : g_sigLastScanCG32x32; |
---|
2645 | Int *dst = scalingList->getScalingListAddress(sizeId, listId); |
---|
2646 | |
---|
2647 | if( sizeId > SCALING_LIST_8x8 ) |
---|
2648 | { |
---|
2649 | #if IL_SL_SIGNALLING_N0371 |
---|
2650 | if( scalingList->getLayerId() > 0 && scalingList->getPredScalingListFlag() ) |
---|
2651 | { |
---|
2652 | ref_scalingListDC[scalingList->getLayerId()][sizeId][listId] = scalingList->getScalingListDC(sizeId,listId); |
---|
2653 | scalingList->setScalingListDC(sizeId,listId,ref_scalingListDC[scalingList->getScalingListRefLayerId()][sizeId][listId]); |
---|
2654 | } |
---|
2655 | else |
---|
2656 | { |
---|
2657 | READ_SVLC( scalingListDcCoefMinus8, "scaling_list_dc_coef_minus8"); |
---|
2658 | scalingList->setScalingListDC(sizeId,listId,scalingListDcCoefMinus8 + 8); |
---|
2659 | nextCoef = scalingList->getScalingListDC(sizeId,listId); |
---|
2660 | ref_scalingListDC[scalingList->getLayerId()][sizeId][listId] = scalingList->getScalingListDC(sizeId,listId); |
---|
2661 | } |
---|
2662 | #else |
---|
2663 | READ_SVLC( scalingListDcCoefMinus8, "scaling_list_dc_coef_minus8"); |
---|
2664 | scalingList->setScalingListDC(sizeId,listId,scalingListDcCoefMinus8 + 8); |
---|
2665 | nextCoef = scalingList->getScalingListDC(sizeId,listId); |
---|
2666 | #endif |
---|
2667 | } |
---|
2668 | |
---|
2669 | for(i = 0; i < coefNum; i++) |
---|
2670 | { |
---|
2671 | #if IL_SL_SIGNALLING_N0371 |
---|
2672 | if( scalingList->getLayerId() > 0 && scalingList->getPredScalingListFlag() ) |
---|
2673 | { |
---|
2674 | ref_scalingListCoef[scalingList->getLayerId()][sizeId][listId][i] = dst[scan[i]]; |
---|
2675 | dst[scan[i]] = ref_scalingListCoef[scalingList->getScalingListRefLayerId()][sizeId][listId][i]; |
---|
2676 | } |
---|
2677 | else |
---|
2678 | { |
---|
2679 | READ_SVLC( data, "scaling_list_delta_coef"); |
---|
2680 | nextCoef = (nextCoef + data + 256 ) % 256; |
---|
2681 | dst[scan[i]] = nextCoef; |
---|
2682 | ref_scalingListCoef[scalingList->getLayerId()][sizeId][listId][i] = dst[scan[i]]; |
---|
2683 | } |
---|
2684 | #else |
---|
2685 | READ_SVLC( data, "scaling_list_delta_coef"); |
---|
2686 | nextCoef = (nextCoef + data + 256 ) % 256; |
---|
2687 | dst[scan[i]] = nextCoef; |
---|
2688 | #endif |
---|
2689 | } |
---|
2690 | } |
---|
2691 | |
---|
2692 | Bool TDecCavlc::xMoreRbspData() |
---|
2693 | { |
---|
2694 | Int bitsLeft = m_pcBitstream->getNumBitsLeft(); |
---|
2695 | |
---|
2696 | // if there are more than 8 bits, it cannot be rbsp_trailing_bits |
---|
2697 | if (bitsLeft > 8) |
---|
2698 | { |
---|
2699 | return true; |
---|
2700 | } |
---|
2701 | |
---|
2702 | UChar lastByte = m_pcBitstream->peekBits(bitsLeft); |
---|
2703 | Int cnt = bitsLeft; |
---|
2704 | |
---|
2705 | // remove trailing bits equal to zero |
---|
2706 | while ((cnt>0) && ((lastByte & 1) == 0)) |
---|
2707 | { |
---|
2708 | lastByte >>= 1; |
---|
2709 | cnt--; |
---|
2710 | } |
---|
2711 | // remove bit equal to one |
---|
2712 | cnt--; |
---|
2713 | |
---|
2714 | // we should not have a negative number of bits |
---|
2715 | assert (cnt>=0); |
---|
2716 | |
---|
2717 | // we have more data, if cnt is not zero |
---|
2718 | return (cnt>0); |
---|
2719 | } |
---|
2720 | //! \} |
---|
2721 | |
---|