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 | |
---|
293 | #if SCALINGLIST_INFERRING |
---|
294 | if( pcPPS->getLayerId() > 0 ) |
---|
295 | { |
---|
296 | READ_FLAG( uiCode, "pps_infer_scaling_list_flag" ); |
---|
297 | pcPPS->setInferScalingListFlag( uiCode ); |
---|
298 | } |
---|
299 | |
---|
300 | if( pcPPS->getInferScalingListFlag() ) |
---|
301 | { |
---|
302 | READ_UVLC( uiCode, "pps_scaling_list_ref_layer_id" ); pcPPS->setScalingListRefLayerId( uiCode ); |
---|
303 | |
---|
304 | // The value of pps_scaling_list_ref_layer_id shall be in the range of 0 to 62, inclusive |
---|
305 | assert( pcPPS->getScalingListRefLayerId() <= 62 ); |
---|
306 | |
---|
307 | pcPPS->setScalingListPresentFlag( false ); |
---|
308 | } |
---|
309 | else |
---|
310 | { |
---|
311 | #endif |
---|
312 | |
---|
313 | READ_FLAG( uiCode, "pps_scaling_list_data_present_flag" ); pcPPS->setScalingListPresentFlag( uiCode ? true : false ); |
---|
314 | |
---|
315 | if(pcPPS->getScalingListPresentFlag ()) |
---|
316 | { |
---|
317 | parseScalingList( pcPPS->getScalingList() ); |
---|
318 | } |
---|
319 | |
---|
320 | #if SCALINGLIST_INFERRING |
---|
321 | } |
---|
322 | #endif |
---|
323 | |
---|
324 | READ_FLAG( uiCode, "lists_modification_present_flag"); |
---|
325 | pcPPS->setListsModificationPresentFlag(uiCode); |
---|
326 | |
---|
327 | READ_UVLC( uiCode, "log2_parallel_merge_level_minus2"); |
---|
328 | pcPPS->setLog2ParallelMergeLevelMinus2 (uiCode); |
---|
329 | |
---|
330 | READ_FLAG( uiCode, "slice_segment_header_extension_present_flag"); |
---|
331 | pcPPS->setSliceHeaderExtensionPresentFlag(uiCode); |
---|
332 | |
---|
333 | READ_FLAG( uiCode, "pps_extension_flag"); |
---|
334 | if (uiCode) |
---|
335 | { |
---|
336 | while ( xMoreRbspData() ) |
---|
337 | { |
---|
338 | READ_FLAG( uiCode, "pps_extension_data_flag"); |
---|
339 | } |
---|
340 | } |
---|
341 | } |
---|
342 | |
---|
343 | Void TDecCavlc::parseVUI(TComVUI* pcVUI, TComSPS *pcSPS) |
---|
344 | { |
---|
345 | #if ENC_DEC_TRACE |
---|
346 | fprintf( g_hTrace, "----------- vui_parameters -----------\n"); |
---|
347 | #endif |
---|
348 | UInt uiCode; |
---|
349 | |
---|
350 | READ_FLAG( uiCode, "aspect_ratio_info_present_flag"); pcVUI->setAspectRatioInfoPresentFlag(uiCode); |
---|
351 | if (pcVUI->getAspectRatioInfoPresentFlag()) |
---|
352 | { |
---|
353 | READ_CODE(8, uiCode, "aspect_ratio_idc"); pcVUI->setAspectRatioIdc(uiCode); |
---|
354 | if (pcVUI->getAspectRatioIdc() == 255) |
---|
355 | { |
---|
356 | READ_CODE(16, uiCode, "sar_width"); pcVUI->setSarWidth(uiCode); |
---|
357 | READ_CODE(16, uiCode, "sar_height"); pcVUI->setSarHeight(uiCode); |
---|
358 | } |
---|
359 | } |
---|
360 | |
---|
361 | READ_FLAG( uiCode, "overscan_info_present_flag"); pcVUI->setOverscanInfoPresentFlag(uiCode); |
---|
362 | if (pcVUI->getOverscanInfoPresentFlag()) |
---|
363 | { |
---|
364 | READ_FLAG( uiCode, "overscan_appropriate_flag"); pcVUI->setOverscanAppropriateFlag(uiCode); |
---|
365 | } |
---|
366 | |
---|
367 | READ_FLAG( uiCode, "video_signal_type_present_flag"); pcVUI->setVideoSignalTypePresentFlag(uiCode); |
---|
368 | if (pcVUI->getVideoSignalTypePresentFlag()) |
---|
369 | { |
---|
370 | READ_CODE(3, uiCode, "video_format"); pcVUI->setVideoFormat(uiCode); |
---|
371 | READ_FLAG( uiCode, "video_full_range_flag"); pcVUI->setVideoFullRangeFlag(uiCode); |
---|
372 | READ_FLAG( uiCode, "colour_description_present_flag"); pcVUI->setColourDescriptionPresentFlag(uiCode); |
---|
373 | if (pcVUI->getColourDescriptionPresentFlag()) |
---|
374 | { |
---|
375 | READ_CODE(8, uiCode, "colour_primaries"); pcVUI->setColourPrimaries(uiCode); |
---|
376 | READ_CODE(8, uiCode, "transfer_characteristics"); pcVUI->setTransferCharacteristics(uiCode); |
---|
377 | READ_CODE(8, uiCode, "matrix_coefficients"); pcVUI->setMatrixCoefficients(uiCode); |
---|
378 | } |
---|
379 | } |
---|
380 | |
---|
381 | READ_FLAG( uiCode, "chroma_loc_info_present_flag"); pcVUI->setChromaLocInfoPresentFlag(uiCode); |
---|
382 | if (pcVUI->getChromaLocInfoPresentFlag()) |
---|
383 | { |
---|
384 | READ_UVLC( uiCode, "chroma_sample_loc_type_top_field" ); pcVUI->setChromaSampleLocTypeTopField(uiCode); |
---|
385 | READ_UVLC( uiCode, "chroma_sample_loc_type_bottom_field" ); pcVUI->setChromaSampleLocTypeBottomField(uiCode); |
---|
386 | } |
---|
387 | |
---|
388 | READ_FLAG( uiCode, "neutral_chroma_indication_flag"); pcVUI->setNeutralChromaIndicationFlag(uiCode); |
---|
389 | |
---|
390 | READ_FLAG( uiCode, "field_seq_flag"); pcVUI->setFieldSeqFlag(uiCode); |
---|
391 | |
---|
392 | READ_FLAG(uiCode, "frame_field_info_present_flag"); pcVUI->setFrameFieldInfoPresentFlag(uiCode); |
---|
393 | |
---|
394 | READ_FLAG( uiCode, "default_display_window_flag"); |
---|
395 | if (uiCode != 0) |
---|
396 | { |
---|
397 | Window &defDisp = pcVUI->getDefaultDisplayWindow(); |
---|
398 | READ_UVLC( uiCode, "def_disp_win_left_offset" ); defDisp.setWindowLeftOffset ( uiCode * TComSPS::getWinUnitX( pcSPS->getChromaFormatIdc()) ); |
---|
399 | READ_UVLC( uiCode, "def_disp_win_right_offset" ); defDisp.setWindowRightOffset ( uiCode * TComSPS::getWinUnitX( pcSPS->getChromaFormatIdc()) ); |
---|
400 | READ_UVLC( uiCode, "def_disp_win_top_offset" ); defDisp.setWindowTopOffset ( uiCode * TComSPS::getWinUnitY( pcSPS->getChromaFormatIdc()) ); |
---|
401 | READ_UVLC( uiCode, "def_disp_win_bottom_offset" ); defDisp.setWindowBottomOffset( uiCode * TComSPS::getWinUnitY( pcSPS->getChromaFormatIdc()) ); |
---|
402 | } |
---|
403 | TimingInfo *timingInfo = pcVUI->getTimingInfo(); |
---|
404 | READ_FLAG( uiCode, "vui_timing_info_present_flag"); timingInfo->setTimingInfoPresentFlag (uiCode ? true : false); |
---|
405 | #if TIMING_INFO_NONZERO_LAYERID_SPS |
---|
406 | if( pcSPS->getLayerId() > 0 ) |
---|
407 | { |
---|
408 | assert( timingInfo->getTimingInfoPresentFlag() == false ); |
---|
409 | } |
---|
410 | #endif |
---|
411 | if(timingInfo->getTimingInfoPresentFlag()) |
---|
412 | { |
---|
413 | READ_CODE( 32, uiCode, "vui_num_units_in_tick"); timingInfo->setNumUnitsInTick (uiCode); |
---|
414 | READ_CODE( 32, uiCode, "vui_time_scale"); timingInfo->setTimeScale (uiCode); |
---|
415 | READ_FLAG( uiCode, "vui_poc_proportional_to_timing_flag"); timingInfo->setPocProportionalToTimingFlag(uiCode ? true : false); |
---|
416 | if(timingInfo->getPocProportionalToTimingFlag()) |
---|
417 | { |
---|
418 | READ_UVLC( uiCode, "vui_num_ticks_poc_diff_one_minus1"); timingInfo->setNumTicksPocDiffOneMinus1 (uiCode); |
---|
419 | } |
---|
420 | READ_FLAG( uiCode, "hrd_parameters_present_flag"); pcVUI->setHrdParametersPresentFlag(uiCode); |
---|
421 | if( pcVUI->getHrdParametersPresentFlag() ) |
---|
422 | { |
---|
423 | parseHrdParameters( pcVUI->getHrdParameters(), 1, pcSPS->getMaxTLayers() - 1 ); |
---|
424 | } |
---|
425 | } |
---|
426 | READ_FLAG( uiCode, "bitstream_restriction_flag"); pcVUI->setBitstreamRestrictionFlag(uiCode); |
---|
427 | if (pcVUI->getBitstreamRestrictionFlag()) |
---|
428 | { |
---|
429 | READ_FLAG( uiCode, "tiles_fixed_structure_flag"); pcVUI->setTilesFixedStructureFlag(uiCode); |
---|
430 | READ_FLAG( uiCode, "motion_vectors_over_pic_boundaries_flag"); pcVUI->setMotionVectorsOverPicBoundariesFlag(uiCode); |
---|
431 | READ_FLAG( uiCode, "restricted_ref_pic_lists_flag"); pcVUI->setRestrictedRefPicListsFlag(uiCode); |
---|
432 | READ_UVLC( uiCode, "min_spatial_segmentation_idc"); pcVUI->setMinSpatialSegmentationIdc(uiCode); |
---|
433 | assert(uiCode < 4096); |
---|
434 | READ_UVLC( uiCode, "max_bytes_per_pic_denom" ); pcVUI->setMaxBytesPerPicDenom(uiCode); |
---|
435 | READ_UVLC( uiCode, "max_bits_per_mincu_denom" ); pcVUI->setMaxBitsPerMinCuDenom(uiCode); |
---|
436 | READ_UVLC( uiCode, "log2_max_mv_length_horizontal" ); pcVUI->setLog2MaxMvLengthHorizontal(uiCode); |
---|
437 | READ_UVLC( uiCode, "log2_max_mv_length_vertical" ); pcVUI->setLog2MaxMvLengthVertical(uiCode); |
---|
438 | } |
---|
439 | } |
---|
440 | |
---|
441 | Void TDecCavlc::parseHrdParameters(TComHRD *hrd, Bool commonInfPresentFlag, UInt maxNumSubLayersMinus1) |
---|
442 | { |
---|
443 | UInt uiCode; |
---|
444 | if( commonInfPresentFlag ) |
---|
445 | { |
---|
446 | READ_FLAG( uiCode, "nal_hrd_parameters_present_flag" ); hrd->setNalHrdParametersPresentFlag( uiCode == 1 ? true : false ); |
---|
447 | READ_FLAG( uiCode, "vcl_hrd_parameters_present_flag" ); hrd->setVclHrdParametersPresentFlag( uiCode == 1 ? true : false ); |
---|
448 | if( hrd->getNalHrdParametersPresentFlag() || hrd->getVclHrdParametersPresentFlag() ) |
---|
449 | { |
---|
450 | READ_FLAG( uiCode, "sub_pic_cpb_params_present_flag" ); hrd->setSubPicCpbParamsPresentFlag( uiCode == 1 ? true : false ); |
---|
451 | if( hrd->getSubPicCpbParamsPresentFlag() ) |
---|
452 | { |
---|
453 | READ_CODE( 8, uiCode, "tick_divisor_minus2" ); hrd->setTickDivisorMinus2( uiCode ); |
---|
454 | READ_CODE( 5, uiCode, "du_cpb_removal_delay_length_minus1" ); hrd->setDuCpbRemovalDelayLengthMinus1( uiCode ); |
---|
455 | READ_FLAG( uiCode, "sub_pic_cpb_params_in_pic_timing_sei_flag" ); hrd->setSubPicCpbParamsInPicTimingSEIFlag( uiCode == 1 ? true : false ); |
---|
456 | READ_CODE( 5, uiCode, "dpb_output_delay_du_length_minus1" ); hrd->setDpbOutputDelayDuLengthMinus1( uiCode ); |
---|
457 | } |
---|
458 | READ_CODE( 4, uiCode, "bit_rate_scale" ); hrd->setBitRateScale( uiCode ); |
---|
459 | READ_CODE( 4, uiCode, "cpb_size_scale" ); hrd->setCpbSizeScale( uiCode ); |
---|
460 | if( hrd->getSubPicCpbParamsPresentFlag() ) |
---|
461 | { |
---|
462 | READ_CODE( 4, uiCode, "cpb_size_du_scale" ); hrd->setDuCpbSizeScale( uiCode ); |
---|
463 | } |
---|
464 | READ_CODE( 5, uiCode, "initial_cpb_removal_delay_length_minus1" ); hrd->setInitialCpbRemovalDelayLengthMinus1( uiCode ); |
---|
465 | READ_CODE( 5, uiCode, "au_cpb_removal_delay_length_minus1" ); hrd->setCpbRemovalDelayLengthMinus1( uiCode ); |
---|
466 | READ_CODE( 5, uiCode, "dpb_output_delay_length_minus1" ); hrd->setDpbOutputDelayLengthMinus1( uiCode ); |
---|
467 | } |
---|
468 | } |
---|
469 | Int i, j, nalOrVcl; |
---|
470 | for( i = 0; i <= maxNumSubLayersMinus1; i ++ ) |
---|
471 | { |
---|
472 | READ_FLAG( uiCode, "fixed_pic_rate_general_flag" ); hrd->setFixedPicRateFlag( i, uiCode == 1 ? true : false ); |
---|
473 | if( !hrd->getFixedPicRateFlag( i ) ) |
---|
474 | { |
---|
475 | READ_FLAG( uiCode, "fixed_pic_rate_within_cvs_flag" ); hrd->setFixedPicRateWithinCvsFlag( i, uiCode == 1 ? true : false ); |
---|
476 | } |
---|
477 | else |
---|
478 | { |
---|
479 | hrd->setFixedPicRateWithinCvsFlag( i, true ); |
---|
480 | } |
---|
481 | hrd->setLowDelayHrdFlag( i, 0 ); // Infered to be 0 when not present |
---|
482 | hrd->setCpbCntMinus1 ( i, 0 ); // Infered to be 0 when not present |
---|
483 | if( hrd->getFixedPicRateWithinCvsFlag( i ) ) |
---|
484 | { |
---|
485 | READ_UVLC( uiCode, "elemental_duration_in_tc_minus1" ); hrd->setPicDurationInTcMinus1( i, uiCode ); |
---|
486 | } |
---|
487 | else |
---|
488 | { |
---|
489 | READ_FLAG( uiCode, "low_delay_hrd_flag" ); hrd->setLowDelayHrdFlag( i, uiCode == 1 ? true : false ); |
---|
490 | } |
---|
491 | if (!hrd->getLowDelayHrdFlag( i )) |
---|
492 | { |
---|
493 | READ_UVLC( uiCode, "cpb_cnt_minus1" ); hrd->setCpbCntMinus1( i, uiCode ); |
---|
494 | } |
---|
495 | for( nalOrVcl = 0; nalOrVcl < 2; nalOrVcl ++ ) |
---|
496 | { |
---|
497 | if( ( ( nalOrVcl == 0 ) && ( hrd->getNalHrdParametersPresentFlag() ) ) || |
---|
498 | ( ( nalOrVcl == 1 ) && ( hrd->getVclHrdParametersPresentFlag() ) ) ) |
---|
499 | { |
---|
500 | for( j = 0; j <= ( hrd->getCpbCntMinus1( i ) ); j ++ ) |
---|
501 | { |
---|
502 | READ_UVLC( uiCode, "bit_rate_value_minus1" ); hrd->setBitRateValueMinus1( i, j, nalOrVcl, uiCode ); |
---|
503 | READ_UVLC( uiCode, "cpb_size_value_minus1" ); hrd->setCpbSizeValueMinus1( i, j, nalOrVcl, uiCode ); |
---|
504 | if( hrd->getSubPicCpbParamsPresentFlag() ) |
---|
505 | { |
---|
506 | READ_UVLC( uiCode, "cpb_size_du_value_minus1" ); hrd->setDuCpbSizeValueMinus1( i, j, nalOrVcl, uiCode ); |
---|
507 | READ_UVLC( uiCode, "bit_rate_du_value_minus1" ); hrd->setDuBitRateValueMinus1( i, j, nalOrVcl, uiCode ); |
---|
508 | } |
---|
509 | READ_FLAG( uiCode, "cbr_flag" ); hrd->setCbrFlag( i, j, nalOrVcl, uiCode == 1 ? true : false ); |
---|
510 | } |
---|
511 | } |
---|
512 | } |
---|
513 | } |
---|
514 | } |
---|
515 | |
---|
516 | #if SVC_EXTENSION |
---|
517 | Void TDecCavlc::parseSPS(TComSPS* pcSPS, ParameterSetManagerDecoder *parameterSetManager) |
---|
518 | #else |
---|
519 | Void TDecCavlc::parseSPS(TComSPS* pcSPS) |
---|
520 | #endif |
---|
521 | { |
---|
522 | #if ENC_DEC_TRACE |
---|
523 | xTraceSPSHeader (pcSPS); |
---|
524 | #endif |
---|
525 | |
---|
526 | UInt uiCode; |
---|
527 | READ_CODE( 4, uiCode, "sps_video_parameter_set_id"); pcSPS->setVPSId ( uiCode ); |
---|
528 | #if SVC_EXTENSION |
---|
529 | if(pcSPS->getLayerId() == 0) |
---|
530 | { |
---|
531 | #endif |
---|
532 | READ_CODE( 3, uiCode, "sps_max_sub_layers_minus1" ); pcSPS->setMaxTLayers ( uiCode+1 ); |
---|
533 | assert(uiCode <= 6); |
---|
534 | |
---|
535 | READ_FLAG( uiCode, "sps_temporal_id_nesting_flag" ); pcSPS->setTemporalIdNestingFlag ( uiCode > 0 ? true : false ); |
---|
536 | #if SVC_EXTENSION |
---|
537 | } |
---|
538 | else |
---|
539 | { |
---|
540 | pcSPS->setMaxTLayers ( parameterSetManager->getPrefetchedVPS(pcSPS->getVPSId())->getMaxTLayers() ); |
---|
541 | pcSPS->setTemporalIdNestingFlag( parameterSetManager->getPrefetchedVPS(pcSPS->getVPSId())->getTemporalNestingFlag() ); |
---|
542 | } |
---|
543 | #endif |
---|
544 | if ( pcSPS->getMaxTLayers() == 1 ) |
---|
545 | { |
---|
546 | // sps_temporal_id_nesting_flag must be 1 when sps_max_sub_layers_minus1 is 0 |
---|
547 | #if SVC_EXTENSION |
---|
548 | assert( pcSPS->getTemporalIdNestingFlag() == true ); |
---|
549 | #else |
---|
550 | assert( uiCode == 1 ); |
---|
551 | #endif |
---|
552 | } |
---|
553 | #ifdef SPS_PTL_FIX |
---|
554 | if ( pcSPS->getLayerId() == 0) |
---|
555 | { |
---|
556 | parsePTL(pcSPS->getPTL(), 1, pcSPS->getMaxTLayers() - 1); |
---|
557 | } |
---|
558 | #else |
---|
559 | parsePTL(pcSPS->getPTL(), 1, pcSPS->getMaxTLayers() - 1); |
---|
560 | #endif |
---|
561 | |
---|
562 | READ_UVLC( uiCode, "sps_seq_parameter_set_id" ); pcSPS->setSPSId( uiCode ); |
---|
563 | assert(uiCode <= 15); |
---|
564 | |
---|
565 | #if REPN_FORMAT_IN_VPS |
---|
566 | if( pcSPS->getLayerId() > 0 ) |
---|
567 | { |
---|
568 | READ_FLAG( uiCode, "update_rep_format_flag" ); |
---|
569 | pcSPS->setUpdateRepFormatFlag( uiCode ? true : false ); |
---|
570 | } |
---|
571 | else |
---|
572 | { |
---|
573 | pcSPS->setUpdateRepFormatFlag( true ); |
---|
574 | } |
---|
575 | #if O0096_REP_FORMAT_INDEX |
---|
576 | if( pcSPS->getLayerId() == 0 ) |
---|
577 | #else |
---|
578 | if( pcSPS->getLayerId() == 0 || pcSPS->getUpdateRepFormatFlag() ) |
---|
579 | #endif |
---|
580 | { |
---|
581 | #endif |
---|
582 | #if AUXILIARY_PICTURES |
---|
583 | READ_UVLC( uiCode, "chroma_format_idc" ); pcSPS->setChromaFormatIdc( ChromaFormat(uiCode) ); |
---|
584 | #else |
---|
585 | READ_UVLC( uiCode, "chroma_format_idc" ); pcSPS->setChromaFormatIdc( uiCode ); |
---|
586 | #endif |
---|
587 | assert(uiCode <= 3); |
---|
588 | // 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 |
---|
589 | assert (uiCode == 1); |
---|
590 | if( uiCode == 3 ) |
---|
591 | { |
---|
592 | READ_FLAG( uiCode, "separate_colour_plane_flag"); assert(uiCode == 0); |
---|
593 | } |
---|
594 | |
---|
595 | READ_UVLC ( uiCode, "pic_width_in_luma_samples" ); pcSPS->setPicWidthInLumaSamples ( uiCode ); |
---|
596 | READ_UVLC ( uiCode, "pic_height_in_luma_samples" ); pcSPS->setPicHeightInLumaSamples( uiCode ); |
---|
597 | #if REPN_FORMAT_IN_VPS |
---|
598 | } |
---|
599 | #if O0096_REP_FORMAT_INDEX |
---|
600 | else if ( pcSPS->getUpdateRepFormatFlag() ) |
---|
601 | { |
---|
602 | READ_CODE(8, uiCode, "update_rep_format_index"); |
---|
603 | pcSPS->setUpdateRepFormatIndex(uiCode); |
---|
604 | } |
---|
605 | #endif |
---|
606 | #endif |
---|
607 | READ_FLAG( uiCode, "conformance_window_flag"); |
---|
608 | if (uiCode != 0) |
---|
609 | { |
---|
610 | Window &conf = pcSPS->getConformanceWindow(); |
---|
611 | #if REPN_FORMAT_IN_VPS |
---|
612 | READ_UVLC( uiCode, "conf_win_left_offset" ); conf.setWindowLeftOffset ( uiCode ); |
---|
613 | READ_UVLC( uiCode, "conf_win_right_offset" ); conf.setWindowRightOffset ( uiCode ); |
---|
614 | READ_UVLC( uiCode, "conf_win_top_offset" ); conf.setWindowTopOffset ( uiCode ); |
---|
615 | READ_UVLC( uiCode, "conf_win_bottom_offset" ); conf.setWindowBottomOffset( uiCode ); |
---|
616 | #else |
---|
617 | READ_UVLC( uiCode, "conf_win_left_offset" ); conf.setWindowLeftOffset ( uiCode * TComSPS::getWinUnitX( pcSPS->getChromaFormatIdc() ) ); |
---|
618 | READ_UVLC( uiCode, "conf_win_right_offset" ); conf.setWindowRightOffset ( uiCode * TComSPS::getWinUnitX( pcSPS->getChromaFormatIdc() ) ); |
---|
619 | READ_UVLC( uiCode, "conf_win_top_offset" ); conf.setWindowTopOffset ( uiCode * TComSPS::getWinUnitY( pcSPS->getChromaFormatIdc() ) ); |
---|
620 | READ_UVLC( uiCode, "conf_win_bottom_offset" ); conf.setWindowBottomOffset( uiCode * TComSPS::getWinUnitY( pcSPS->getChromaFormatIdc() ) ); |
---|
621 | #endif |
---|
622 | } |
---|
623 | #if REPN_FORMAT_IN_VPS |
---|
624 | #if O0096_REP_FORMAT_INDEX |
---|
625 | if( pcSPS->getLayerId() == 0 ) |
---|
626 | #else |
---|
627 | if( pcSPS->getLayerId() == 0 || pcSPS->getUpdateRepFormatFlag() ) |
---|
628 | #endif |
---|
629 | { |
---|
630 | #endif |
---|
631 | READ_UVLC( uiCode, "bit_depth_luma_minus8" ); |
---|
632 | assert(uiCode <= 6); |
---|
633 | pcSPS->setBitDepthY( uiCode + 8 ); |
---|
634 | pcSPS->setQpBDOffsetY( (Int) (6*uiCode) ); |
---|
635 | |
---|
636 | READ_UVLC( uiCode, "bit_depth_chroma_minus8" ); |
---|
637 | assert(uiCode <= 6); |
---|
638 | pcSPS->setBitDepthC( uiCode + 8 ); |
---|
639 | pcSPS->setQpBDOffsetC( (Int) (6*uiCode) ); |
---|
640 | #if REPN_FORMAT_IN_VPS |
---|
641 | } |
---|
642 | #endif |
---|
643 | READ_UVLC( uiCode, "log2_max_pic_order_cnt_lsb_minus4" ); pcSPS->setBitsForPOC( 4 + uiCode ); |
---|
644 | assert(uiCode <= 12); |
---|
645 | |
---|
646 | UInt subLayerOrderingInfoPresentFlag; |
---|
647 | READ_FLAG(subLayerOrderingInfoPresentFlag, "sps_sub_layer_ordering_info_present_flag"); |
---|
648 | |
---|
649 | for(UInt i=0; i <= pcSPS->getMaxTLayers()-1; i++) |
---|
650 | { |
---|
651 | READ_UVLC ( uiCode, "sps_max_dec_pic_buffering_minus1"); |
---|
652 | pcSPS->setMaxDecPicBuffering( uiCode + 1, i); |
---|
653 | READ_UVLC ( uiCode, "sps_num_reorder_pics" ); |
---|
654 | pcSPS->setNumReorderPics(uiCode, i); |
---|
655 | READ_UVLC ( uiCode, "sps_max_latency_increase_plus1"); |
---|
656 | pcSPS->setMaxLatencyIncrease( uiCode, i ); |
---|
657 | |
---|
658 | if (!subLayerOrderingInfoPresentFlag) |
---|
659 | { |
---|
660 | for (i++; i <= pcSPS->getMaxTLayers()-1; i++) |
---|
661 | { |
---|
662 | pcSPS->setMaxDecPicBuffering(pcSPS->getMaxDecPicBuffering(0), i); |
---|
663 | pcSPS->setNumReorderPics(pcSPS->getNumReorderPics(0), i); |
---|
664 | pcSPS->setMaxLatencyIncrease(pcSPS->getMaxLatencyIncrease(0), i); |
---|
665 | } |
---|
666 | break; |
---|
667 | } |
---|
668 | } |
---|
669 | |
---|
670 | READ_UVLC( uiCode, "log2_min_coding_block_size_minus3" ); |
---|
671 | Int log2MinCUSize = uiCode + 3; |
---|
672 | pcSPS->setLog2MinCodingBlockSize(log2MinCUSize); |
---|
673 | READ_UVLC( uiCode, "log2_diff_max_min_coding_block_size" ); |
---|
674 | pcSPS->setLog2DiffMaxMinCodingBlockSize(uiCode); |
---|
675 | Int maxCUDepthDelta = uiCode; |
---|
676 | pcSPS->setMaxCUWidth ( 1<<(log2MinCUSize + maxCUDepthDelta) ); |
---|
677 | pcSPS->setMaxCUHeight ( 1<<(log2MinCUSize + maxCUDepthDelta) ); |
---|
678 | READ_UVLC( uiCode, "log2_min_transform_block_size_minus2" ); pcSPS->setQuadtreeTULog2MinSize( uiCode + 2 ); |
---|
679 | |
---|
680 | READ_UVLC( uiCode, "log2_diff_max_min_transform_block_size" ); pcSPS->setQuadtreeTULog2MaxSize( uiCode + pcSPS->getQuadtreeTULog2MinSize() ); |
---|
681 | pcSPS->setMaxTrSize( 1<<(uiCode + pcSPS->getQuadtreeTULog2MinSize()) ); |
---|
682 | |
---|
683 | READ_UVLC( uiCode, "max_transform_hierarchy_depth_inter" ); pcSPS->setQuadtreeTUMaxDepthInter( uiCode+1 ); |
---|
684 | READ_UVLC( uiCode, "max_transform_hierarchy_depth_intra" ); pcSPS->setQuadtreeTUMaxDepthIntra( uiCode+1 ); |
---|
685 | |
---|
686 | Int addCuDepth = max (0, log2MinCUSize - (Int)pcSPS->getQuadtreeTULog2MinSize() ); |
---|
687 | pcSPS->setMaxCUDepth( maxCUDepthDelta + addCuDepth ); |
---|
688 | READ_FLAG( uiCode, "scaling_list_enabled_flag" ); pcSPS->setScalingListFlag ( uiCode ); |
---|
689 | |
---|
690 | if(pcSPS->getScalingListFlag()) |
---|
691 | { |
---|
692 | #if SCALINGLIST_INFERRING |
---|
693 | if( pcSPS->getLayerId() > 0 ) |
---|
694 | { |
---|
695 | READ_FLAG( uiCode, "sps_infer_scaling_list_flag" ); pcSPS->setInferScalingListFlag( uiCode ); |
---|
696 | } |
---|
697 | |
---|
698 | if( pcSPS->getInferScalingListFlag() ) |
---|
699 | { |
---|
700 | READ_UVLC( uiCode, "sps_scaling_list_ref_layer_id" ); pcSPS->setScalingListRefLayerId( uiCode ); |
---|
701 | |
---|
702 | // The value of pps_scaling_list_ref_layer_id shall be in the range of 0 to 62, inclusive |
---|
703 | assert( pcSPS->getScalingListRefLayerId() <= 62 ); |
---|
704 | |
---|
705 | pcSPS->setScalingListPresentFlag( false ); |
---|
706 | } |
---|
707 | else |
---|
708 | { |
---|
709 | #endif |
---|
710 | READ_FLAG( uiCode, "sps_scaling_list_data_present_flag" ); pcSPS->setScalingListPresentFlag ( uiCode ); |
---|
711 | if(pcSPS->getScalingListPresentFlag ()) |
---|
712 | { |
---|
713 | parseScalingList( pcSPS->getScalingList() ); |
---|
714 | } |
---|
715 | #if SCALINGLIST_INFERRING |
---|
716 | } |
---|
717 | #endif |
---|
718 | } |
---|
719 | READ_FLAG( uiCode, "amp_enabled_flag" ); pcSPS->setUseAMP( uiCode ); |
---|
720 | READ_FLAG( uiCode, "sample_adaptive_offset_enabled_flag" ); pcSPS->setUseSAO ( uiCode ? true : false ); |
---|
721 | |
---|
722 | READ_FLAG( uiCode, "pcm_enabled_flag" ); pcSPS->setUsePCM( uiCode ? true : false ); |
---|
723 | if( pcSPS->getUsePCM() ) |
---|
724 | { |
---|
725 | READ_CODE( 4, uiCode, "pcm_sample_bit_depth_luma_minus1" ); pcSPS->setPCMBitDepthLuma ( 1 + uiCode ); |
---|
726 | READ_CODE( 4, uiCode, "pcm_sample_bit_depth_chroma_minus1" ); pcSPS->setPCMBitDepthChroma ( 1 + uiCode ); |
---|
727 | READ_UVLC( uiCode, "log2_min_pcm_luma_coding_block_size_minus3" ); pcSPS->setPCMLog2MinSize (uiCode+3); |
---|
728 | READ_UVLC( uiCode, "log2_diff_max_min_pcm_luma_coding_block_size" ); pcSPS->setPCMLog2MaxSize ( uiCode+pcSPS->getPCMLog2MinSize() ); |
---|
729 | READ_FLAG( uiCode, "pcm_loop_filter_disable_flag" ); pcSPS->setPCMFilterDisableFlag ( uiCode ? true : false ); |
---|
730 | } |
---|
731 | |
---|
732 | READ_UVLC( uiCode, "num_short_term_ref_pic_sets" ); |
---|
733 | assert(uiCode <= 64); |
---|
734 | pcSPS->createRPSList(uiCode); |
---|
735 | |
---|
736 | TComRPSList* rpsList = pcSPS->getRPSList(); |
---|
737 | TComReferencePictureSet* rps; |
---|
738 | |
---|
739 | for(UInt i=0; i< rpsList->getNumberOfReferencePictureSets(); i++) |
---|
740 | { |
---|
741 | rps = rpsList->getReferencePictureSet(i); |
---|
742 | parseShortTermRefPicSet(pcSPS,rps,i); |
---|
743 | } |
---|
744 | READ_FLAG( uiCode, "long_term_ref_pics_present_flag" ); pcSPS->setLongTermRefsPresent(uiCode); |
---|
745 | if (pcSPS->getLongTermRefsPresent()) |
---|
746 | { |
---|
747 | READ_UVLC( uiCode, "num_long_term_ref_pic_sps" ); |
---|
748 | pcSPS->setNumLongTermRefPicSPS(uiCode); |
---|
749 | for (UInt k = 0; k < pcSPS->getNumLongTermRefPicSPS(); k++) |
---|
750 | { |
---|
751 | READ_CODE( pcSPS->getBitsForPOC(), uiCode, "lt_ref_pic_poc_lsb_sps" ); |
---|
752 | pcSPS->setLtRefPicPocLsbSps(k, uiCode); |
---|
753 | READ_FLAG( uiCode, "used_by_curr_pic_lt_sps_flag[i]"); |
---|
754 | pcSPS->setUsedByCurrPicLtSPSFlag(k, uiCode?1:0); |
---|
755 | } |
---|
756 | } |
---|
757 | READ_FLAG( uiCode, "sps_temporal_mvp_enable_flag" ); pcSPS->setTMVPFlagsPresent(uiCode); |
---|
758 | #if REF_IDX_MFM |
---|
759 | #if !M0457_COL_PICTURE_SIGNALING |
---|
760 | if(pcSPS->getLayerId() > 0) |
---|
761 | { |
---|
762 | READ_FLAG( uiCode, "sps_enh_mfm_enable_flag" ); |
---|
763 | pcSPS->setMFMEnabledFlag( uiCode ? true : false ); |
---|
764 | } |
---|
765 | #endif |
---|
766 | #endif |
---|
767 | READ_FLAG( uiCode, "sps_strong_intra_smoothing_enable_flag" ); pcSPS->setUseStrongIntraSmoothing(uiCode); |
---|
768 | |
---|
769 | READ_FLAG( uiCode, "vui_parameters_present_flag" ); pcSPS->setVuiParametersPresentFlag(uiCode); |
---|
770 | |
---|
771 | if (pcSPS->getVuiParametersPresentFlag()) |
---|
772 | { |
---|
773 | parseVUI(pcSPS->getVuiParameters(), pcSPS); |
---|
774 | } |
---|
775 | |
---|
776 | READ_FLAG( uiCode, "sps_extension_flag"); |
---|
777 | if (uiCode) |
---|
778 | { |
---|
779 | #if SPS_EXTENSION |
---|
780 | |
---|
781 | #if O0142_CONDITIONAL_SPS_EXTENSION |
---|
782 | UInt spsExtensionTypeFlag[8]; |
---|
783 | for (UInt i = 0; i < 8; i++) |
---|
784 | { |
---|
785 | READ_FLAG( spsExtensionTypeFlag[i], "sps_extension_type_flag" ); |
---|
786 | } |
---|
787 | if (spsExtensionTypeFlag[1]) |
---|
788 | { |
---|
789 | parseSPSExtension( pcSPS ); |
---|
790 | } |
---|
791 | if (spsExtensionTypeFlag[7]) |
---|
792 | { |
---|
793 | #else |
---|
794 | parseSPSExtension( pcSPS ); |
---|
795 | READ_FLAG( uiCode, "sps_extension2_flag"); |
---|
796 | if(uiCode) |
---|
797 | { |
---|
798 | #endif |
---|
799 | |
---|
800 | #endif |
---|
801 | while ( xMoreRbspData() ) |
---|
802 | { |
---|
803 | READ_FLAG( uiCode, "sps_extension_data_flag"); |
---|
804 | } |
---|
805 | #if SPS_EXTENSION |
---|
806 | } |
---|
807 | #endif |
---|
808 | } |
---|
809 | } |
---|
810 | |
---|
811 | #if SPS_EXTENSION |
---|
812 | Void TDecCavlc::parseSPSExtension( TComSPS* pcSPS ) |
---|
813 | { |
---|
814 | UInt uiCode; |
---|
815 | // more syntax elements to be parsed here |
---|
816 | |
---|
817 | #if VERT_MV_CONSTRAINT |
---|
818 | READ_FLAG( uiCode, "inter_view_mv_vert_constraint_flag" ); |
---|
819 | // Vertical MV component restriction is not used in SHVC CTC |
---|
820 | assert( uiCode == 0 ); |
---|
821 | #endif |
---|
822 | if( pcSPS->getLayerId() > 0 ) |
---|
823 | { |
---|
824 | Int iCode; |
---|
825 | READ_UVLC( uiCode, "num_scaled_ref_layer_offsets" ); pcSPS->setNumScaledRefLayerOffsets(uiCode); |
---|
826 | for(Int i = 0; i < pcSPS->getNumScaledRefLayerOffsets(); i++) |
---|
827 | { |
---|
828 | Window& scaledWindow = pcSPS->getScaledRefLayerWindow(i); |
---|
829 | #if O0098_SCALED_REF_LAYER_ID |
---|
830 | READ_CODE( 6, uiCode, "scaled_ref_layer_left_id" ); pcSPS->setScaledRefLayerId( i, uiCode ); |
---|
831 | #endif |
---|
832 | READ_SVLC( iCode, "scaled_ref_layer_left_offset" ); scaledWindow.setWindowLeftOffset (iCode << 1); |
---|
833 | READ_SVLC( iCode, "scaled_ref_layer_top_offset" ); scaledWindow.setWindowTopOffset (iCode << 1); |
---|
834 | READ_SVLC( iCode, "scaled_ref_layer_right_offset" ); scaledWindow.setWindowRightOffset (iCode << 1); |
---|
835 | READ_SVLC( iCode, "scaled_ref_layer_bottom_offset" ); scaledWindow.setWindowBottomOffset(iCode << 1); |
---|
836 | } |
---|
837 | } |
---|
838 | #if M0463_VUI_EXT_ILP_REF |
---|
839 | //// sps_extension_vui_parameters( ) |
---|
840 | if( pcSPS->getVuiParameters()->getBitstreamRestrictionFlag() ) |
---|
841 | { |
---|
842 | READ_UVLC( uiCode, "num_ilp_restricted_ref_layers" ); pcSPS->setNumIlpRestrictedRefLayers( uiCode ); |
---|
843 | for( Int i = 0; i < pcSPS->getNumIlpRestrictedRefLayers( ); i++ ) |
---|
844 | { |
---|
845 | READ_UVLC( uiCode, "min_spatial_segment_offset_plus1" ); pcSPS->setMinSpatialSegmentOffsetPlus1( i, uiCode ); |
---|
846 | if( pcSPS->getMinSpatialSegmentOffsetPlus1( i ) > 0 ) |
---|
847 | { |
---|
848 | READ_FLAG( uiCode, "ctu_based_offset_enabled_flag[ i ]"); pcSPS->setCtuBasedOffsetEnabledFlag(i, uiCode == 1 ); |
---|
849 | if( pcSPS->getCtuBasedOffsetEnabledFlag( i ) ) |
---|
850 | { |
---|
851 | READ_UVLC( uiCode, "min_horizontal_ctu_offset_plus1[ i ]"); pcSPS->setMinHorizontalCtuOffsetPlus1( i, uiCode ); |
---|
852 | } |
---|
853 | } |
---|
854 | } |
---|
855 | } |
---|
856 | //// sps_extension_vui_parameters( ) END |
---|
857 | #endif |
---|
858 | } |
---|
859 | #endif |
---|
860 | |
---|
861 | Void TDecCavlc::parseVPS(TComVPS* pcVPS) |
---|
862 | { |
---|
863 | UInt uiCode; |
---|
864 | |
---|
865 | READ_CODE( 4, uiCode, "vps_video_parameter_set_id" ); pcVPS->setVPSId( uiCode ); |
---|
866 | READ_CODE( 2, uiCode, "vps_reserved_three_2bits" ); assert(uiCode == 3); |
---|
867 | #if VPS_RENAME |
---|
868 | #if O0137_MAX_LAYERID |
---|
869 | READ_CODE( 6, uiCode, "vps_max_layers_minus1" ); pcVPS->setMaxLayers( min( 62u, uiCode) + 1 ); |
---|
870 | #else |
---|
871 | READ_CODE( 6, uiCode, "vps_max_layers_minus1" ); pcVPS->setMaxLayers( uiCode + 1 ); |
---|
872 | #endif |
---|
873 | #else |
---|
874 | READ_CODE( 6, uiCode, "vps_reserved_zero_6bits" ); assert(uiCode == 0); |
---|
875 | #endif |
---|
876 | READ_CODE( 3, uiCode, "vps_max_sub_layers_minus1" ); pcVPS->setMaxTLayers( uiCode + 1 ); |
---|
877 | READ_FLAG( uiCode, "vps_temporal_id_nesting_flag" ); pcVPS->setTemporalNestingFlag( uiCode ? true:false ); |
---|
878 | assert (pcVPS->getMaxTLayers()>1||pcVPS->getTemporalNestingFlag()); |
---|
879 | #if VPS_EXTN_OFFSET |
---|
880 | READ_CODE( 16, uiCode, "vps_extension_offset" ); pcVPS->setExtensionOffset( uiCode ); |
---|
881 | #else |
---|
882 | READ_CODE( 16, uiCode, "vps_reserved_ffff_16bits" ); assert(uiCode == 0xffff); |
---|
883 | #endif |
---|
884 | parsePTL ( pcVPS->getPTL(), true, pcVPS->getMaxTLayers()-1); |
---|
885 | UInt subLayerOrderingInfoPresentFlag; |
---|
886 | READ_FLAG(subLayerOrderingInfoPresentFlag, "vps_sub_layer_ordering_info_present_flag"); |
---|
887 | for(UInt i = 0; i <= pcVPS->getMaxTLayers()-1; i++) |
---|
888 | { |
---|
889 | READ_UVLC( uiCode, "vps_max_dec_pic_buffering_minus1[i]" ); pcVPS->setMaxDecPicBuffering( uiCode + 1, i ); |
---|
890 | READ_UVLC( uiCode, "vps_num_reorder_pics[i]" ); pcVPS->setNumReorderPics( uiCode, i ); |
---|
891 | READ_UVLC( uiCode, "vps_max_latency_increase_plus1[i]" ); pcVPS->setMaxLatencyIncrease( uiCode, i ); |
---|
892 | |
---|
893 | if (!subLayerOrderingInfoPresentFlag) |
---|
894 | { |
---|
895 | for (i++; i <= pcVPS->getMaxTLayers()-1; i++) |
---|
896 | { |
---|
897 | pcVPS->setMaxDecPicBuffering(pcVPS->getMaxDecPicBuffering(0), i); |
---|
898 | pcVPS->setNumReorderPics(pcVPS->getNumReorderPics(0), i); |
---|
899 | pcVPS->setMaxLatencyIncrease(pcVPS->getMaxLatencyIncrease(0), i); |
---|
900 | } |
---|
901 | break; |
---|
902 | } |
---|
903 | } |
---|
904 | |
---|
905 | #if VPS_RENAME |
---|
906 | assert( pcVPS->getNumHrdParameters() < MAX_VPS_LAYER_SETS_PLUS1 ); |
---|
907 | assert( pcVPS->getMaxLayerId() < MAX_VPS_LAYER_ID_PLUS1 ); |
---|
908 | READ_CODE( 6, uiCode, "vps_max_layer_id" ); pcVPS->setMaxLayerId( uiCode ); |
---|
909 | READ_UVLC( uiCode, "vps_num_layer_sets_minus1" ); pcVPS->setNumLayerSets( uiCode + 1 ); |
---|
910 | for( UInt opsIdx = 1; opsIdx <= ( pcVPS->getNumLayerSets() - 1 ); opsIdx ++ ) |
---|
911 | { |
---|
912 | // Operation point set |
---|
913 | for( UInt i = 0; i <= pcVPS->getMaxLayerId(); i ++ ) |
---|
914 | #else |
---|
915 | assert( pcVPS->getNumHrdParameters() < MAX_VPS_OP_SETS_PLUS1 ); |
---|
916 | assert( pcVPS->getMaxNuhReservedZeroLayerId() < MAX_VPS_NUH_RESERVED_ZERO_LAYER_ID_PLUS1 ); |
---|
917 | READ_CODE( 6, uiCode, "vps_max_nuh_reserved_zero_layer_id" ); pcVPS->setMaxNuhReservedZeroLayerId( uiCode ); |
---|
918 | READ_UVLC( uiCode, "vps_max_op_sets_minus1" ); pcVPS->setMaxOpSets( uiCode + 1 ); |
---|
919 | for( UInt opsIdx = 1; opsIdx <= ( pcVPS->getMaxOpSets() - 1 ); opsIdx ++ ) |
---|
920 | { |
---|
921 | // Operation point set |
---|
922 | for( UInt i = 0; i <= pcVPS->getMaxNuhReservedZeroLayerId(); i ++ ) |
---|
923 | #endif |
---|
924 | { |
---|
925 | READ_FLAG( uiCode, "layer_id_included_flag[opsIdx][i]" ); pcVPS->setLayerIdIncludedFlag( uiCode == 1 ? true : false, opsIdx, i ); |
---|
926 | } |
---|
927 | } |
---|
928 | #if DERIVE_LAYER_ID_LIST_VARIABLES |
---|
929 | pcVPS->deriveLayerIdListVariables(); |
---|
930 | #endif |
---|
931 | TimingInfo *timingInfo = pcVPS->getTimingInfo(); |
---|
932 | READ_FLAG( uiCode, "vps_timing_info_present_flag"); timingInfo->setTimingInfoPresentFlag (uiCode ? true : false); |
---|
933 | if(timingInfo->getTimingInfoPresentFlag()) |
---|
934 | { |
---|
935 | READ_CODE( 32, uiCode, "vps_num_units_in_tick"); timingInfo->setNumUnitsInTick (uiCode); |
---|
936 | READ_CODE( 32, uiCode, "vps_time_scale"); timingInfo->setTimeScale (uiCode); |
---|
937 | READ_FLAG( uiCode, "vps_poc_proportional_to_timing_flag"); timingInfo->setPocProportionalToTimingFlag(uiCode ? true : false); |
---|
938 | if(timingInfo->getPocProportionalToTimingFlag()) |
---|
939 | { |
---|
940 | READ_UVLC( uiCode, "vps_num_ticks_poc_diff_one_minus1"); timingInfo->setNumTicksPocDiffOneMinus1 (uiCode); |
---|
941 | } |
---|
942 | READ_UVLC( uiCode, "vps_num_hrd_parameters" ); pcVPS->setNumHrdParameters( uiCode ); |
---|
943 | |
---|
944 | if( pcVPS->getNumHrdParameters() > 0 ) |
---|
945 | { |
---|
946 | pcVPS->createHrdParamBuffer(); |
---|
947 | } |
---|
948 | for( UInt i = 0; i < pcVPS->getNumHrdParameters(); i ++ ) |
---|
949 | { |
---|
950 | READ_UVLC( uiCode, "hrd_op_set_idx" ); pcVPS->setHrdOpSetIdx( uiCode, i ); |
---|
951 | if( i > 0 ) |
---|
952 | { |
---|
953 | READ_FLAG( uiCode, "cprms_present_flag[i]" ); pcVPS->setCprmsPresentFlag( uiCode == 1 ? true : false, i ); |
---|
954 | } |
---|
955 | parseHrdParameters(pcVPS->getHrdParameters(i), pcVPS->getCprmsPresentFlag( i ), pcVPS->getMaxTLayers() - 1); |
---|
956 | } |
---|
957 | } |
---|
958 | READ_FLAG( uiCode, "vps_extension_flag" ); |
---|
959 | if (uiCode) |
---|
960 | { |
---|
961 | #if VPS_EXTNS |
---|
962 | while ( m_pcBitstream->getNumBitsRead() % 8 != 0 ) |
---|
963 | { |
---|
964 | READ_FLAG( uiCode, "vps_extension_alignment_bit_equal_to_one"); assert(uiCode == 1); |
---|
965 | } |
---|
966 | parseVPSExtension(pcVPS); |
---|
967 | READ_FLAG( uiCode, "vps_entension2_flag" ); |
---|
968 | if(uiCode) |
---|
969 | { |
---|
970 | while ( xMoreRbspData() ) |
---|
971 | { |
---|
972 | READ_FLAG( uiCode, "vps_extension_data_flag"); |
---|
973 | } |
---|
974 | } |
---|
975 | #else |
---|
976 | while ( xMoreRbspData() ) |
---|
977 | { |
---|
978 | READ_FLAG( uiCode, "vps_extension_data_flag"); |
---|
979 | } |
---|
980 | #endif |
---|
981 | } |
---|
982 | |
---|
983 | return; |
---|
984 | } |
---|
985 | |
---|
986 | #if SVC_EXTENSION |
---|
987 | #if VPS_EXTNS |
---|
988 | Void TDecCavlc::parseVPSExtension(TComVPS *vps) |
---|
989 | { |
---|
990 | UInt uiCode; |
---|
991 | // ... More syntax elements to be parsed here |
---|
992 | #if VPS_EXTN_MASK_AND_DIM_INFO |
---|
993 | UInt numScalabilityTypes = 0, i = 0, j = 0; |
---|
994 | |
---|
995 | READ_FLAG( uiCode, "avc_base_layer_flag" ); vps->setAvcBaseLayerFlag(uiCode ? true : false); |
---|
996 | |
---|
997 | #if !P0307_REMOVE_VPS_VUI_OFFSET |
---|
998 | #if O0109_MOVE_VPS_VUI_FLAG |
---|
999 | READ_FLAG( uiCode, "vps_vui_present_flag"); vps->setVpsVuiPresentFlag(uiCode ? true : false); |
---|
1000 | if ( uiCode ) |
---|
1001 | { |
---|
1002 | #endif |
---|
1003 | #if VPS_VUI_OFFSET |
---|
1004 | READ_CODE( 16, uiCode, "vps_vui_offset" ); vps->setVpsVuiOffset( uiCode ); |
---|
1005 | #endif |
---|
1006 | #if O0109_MOVE_VPS_VUI_FLAG |
---|
1007 | } |
---|
1008 | #endif |
---|
1009 | #endif |
---|
1010 | READ_FLAG( uiCode, "splitting_flag" ); vps->setSplittingFlag(uiCode ? true : false); |
---|
1011 | |
---|
1012 | for(i = 0; i < MAX_VPS_NUM_SCALABILITY_TYPES; i++) |
---|
1013 | { |
---|
1014 | READ_FLAG( uiCode, "scalability_mask[i]" ); vps->setScalabilityMask(i, uiCode ? true : false); |
---|
1015 | numScalabilityTypes += uiCode; |
---|
1016 | } |
---|
1017 | vps->setNumScalabilityTypes(numScalabilityTypes); |
---|
1018 | |
---|
1019 | for(j = 0; j < numScalabilityTypes - vps->getSplittingFlag(); j++) |
---|
1020 | { |
---|
1021 | READ_CODE( 3, uiCode, "dimension_id_len_minus1[j]" ); vps->setDimensionIdLen(j, uiCode + 1); |
---|
1022 | } |
---|
1023 | |
---|
1024 | if(vps->getSplittingFlag()) |
---|
1025 | { |
---|
1026 | UInt numBits = 0; |
---|
1027 | for(j = 0; j < numScalabilityTypes - 1; j++) |
---|
1028 | { |
---|
1029 | numBits += vps->getDimensionIdLen(j); |
---|
1030 | } |
---|
1031 | assert( numBits < 6 ); |
---|
1032 | vps->setDimensionIdLen(numScalabilityTypes-1, 6 - numBits); |
---|
1033 | numBits = 6; |
---|
1034 | } |
---|
1035 | |
---|
1036 | READ_FLAG( uiCode, "vps_nuh_layer_id_present_flag" ); vps->setNuhLayerIdPresentFlag(uiCode ? true : false); |
---|
1037 | vps->setLayerIdInNuh(0, 0); |
---|
1038 | vps->setLayerIdInVps(0, 0); |
---|
1039 | for(i = 1; i < vps->getMaxLayers(); i++) |
---|
1040 | { |
---|
1041 | if( vps->getNuhLayerIdPresentFlag() ) |
---|
1042 | { |
---|
1043 | READ_CODE( 6, uiCode, "layer_id_in_nuh[i]" ); vps->setLayerIdInNuh(i, uiCode); |
---|
1044 | assert( uiCode > vps->getLayerIdInNuh(i-1) ); |
---|
1045 | } |
---|
1046 | else |
---|
1047 | { |
---|
1048 | vps->setLayerIdInNuh(i, i); |
---|
1049 | } |
---|
1050 | vps->setLayerIdInVps(vps->getLayerIdInNuh(i), i); |
---|
1051 | |
---|
1052 | if( !vps->getSplittingFlag() ) |
---|
1053 | { |
---|
1054 | for(j = 0; j < numScalabilityTypes; j++) |
---|
1055 | { |
---|
1056 | READ_CODE( vps->getDimensionIdLen(j), uiCode, "dimension_id[i][j]" ); vps->setDimensionId(i, j, uiCode); |
---|
1057 | #if !AUXILIARY_PICTURES |
---|
1058 | assert( uiCode <= vps->getMaxLayerId() ); |
---|
1059 | #endif |
---|
1060 | } |
---|
1061 | } |
---|
1062 | } |
---|
1063 | #endif |
---|
1064 | #if VIEW_ID_RELATED_SIGNALING |
---|
1065 | // if ( pcVPS->getNumViews() > 1 ) |
---|
1066 | // However, this is a bug in the text since, view_id_len_minus1 is needed to parse view_id_val. |
---|
1067 | { |
---|
1068 | #if O0109_VIEW_ID_LEN |
---|
1069 | READ_CODE( 4, uiCode, "view_id_len" ); vps->setViewIdLen( uiCode ); |
---|
1070 | #else |
---|
1071 | READ_CODE( 4, uiCode, "view_id_len_minus1" ); vps->setViewIdLenMinus1( uiCode ); |
---|
1072 | #endif |
---|
1073 | } |
---|
1074 | |
---|
1075 | #if O0109_VIEW_ID_LEN |
---|
1076 | if ( vps->getViewIdLen() > 0 ) |
---|
1077 | { |
---|
1078 | for( i = 0; i < vps->getNumViews(); i++ ) |
---|
1079 | { |
---|
1080 | READ_CODE( vps->getViewIdLen( ), uiCode, "view_id_val[i]" ); vps->setViewIdVal( i, uiCode ); |
---|
1081 | } |
---|
1082 | } |
---|
1083 | #else |
---|
1084 | for( i = 0; i < vps->getNumViews(); i++ ) |
---|
1085 | { |
---|
1086 | READ_CODE( vps->getViewIdLenMinus1( ) + 1, uiCode, "view_id_val[i]" ); vps->setViewIdVal( i, uiCode ); |
---|
1087 | } |
---|
1088 | #endif |
---|
1089 | #endif // view id related signaling |
---|
1090 | #if VPS_EXTN_DIRECT_REF_LAYERS |
---|
1091 | // For layer 0 |
---|
1092 | vps->setNumDirectRefLayers(0, 0); |
---|
1093 | // For other layers |
---|
1094 | for( Int layerCtr = 1; layerCtr <= vps->getMaxLayers() - 1; layerCtr++) |
---|
1095 | { |
---|
1096 | UInt numDirectRefLayers = 0; |
---|
1097 | for( Int refLayerCtr = 0; refLayerCtr < layerCtr; refLayerCtr++) |
---|
1098 | { |
---|
1099 | READ_FLAG(uiCode, "direct_dependency_flag[i][j]" ); vps->setDirectDependencyFlag(layerCtr, refLayerCtr, uiCode? true : false); |
---|
1100 | if(uiCode) |
---|
1101 | { |
---|
1102 | vps->setRefLayerId(layerCtr, numDirectRefLayers, refLayerCtr); |
---|
1103 | numDirectRefLayers++; |
---|
1104 | } |
---|
1105 | } |
---|
1106 | vps->setNumDirectRefLayers(layerCtr, numDirectRefLayers); |
---|
1107 | } |
---|
1108 | #endif |
---|
1109 | #if VPS_TSLAYERS |
---|
1110 | READ_FLAG( uiCode, "vps_sub_layers_max_minus1_present_flag"); vps->setMaxTSLayersPresentFlag(uiCode ? true : false); |
---|
1111 | if (vps->getMaxTSLayersPresentFlag()) |
---|
1112 | { |
---|
1113 | for(i = 0; i < vps->getMaxLayers() - 1; i++) |
---|
1114 | { |
---|
1115 | READ_CODE( 3, uiCode, "sub_layers_vps_max_minus1[i]" ); vps->setMaxTSLayersMinus1(i, uiCode); |
---|
1116 | } |
---|
1117 | } |
---|
1118 | else |
---|
1119 | { |
---|
1120 | for( i = 0; i < vps->getMaxLayers() - 1; i++) |
---|
1121 | { |
---|
1122 | vps->setMaxTSLayersMinus1(i, vps->getMaxTLayers()-1); |
---|
1123 | } |
---|
1124 | } |
---|
1125 | #endif |
---|
1126 | #if JCTVC_M0203_INTERLAYER_PRED_IDC |
---|
1127 | #if N0120_MAX_TID_REF_PRESENT_FLAG |
---|
1128 | READ_FLAG( uiCode, "max_tid_ref_present_flag"); vps->setMaxTidRefPresentFlag(uiCode ? true : false); |
---|
1129 | if (vps->getMaxTidRefPresentFlag()) |
---|
1130 | { |
---|
1131 | for(i = 0; i < vps->getMaxLayers() - 1; i++) |
---|
1132 | { |
---|
1133 | #if O0225_MAX_TID_FOR_REF_LAYERS |
---|
1134 | for( j = i+1; j <= vps->getMaxLayers() - 1; j++) |
---|
1135 | { |
---|
1136 | if(vps->getDirectDependencyFlag(j, i)) |
---|
1137 | { |
---|
1138 | READ_CODE( 3, uiCode, "max_tid_il_ref_pics_plus1[i][j]" ); vps->setMaxTidIlRefPicsPlus1(i, j, uiCode); |
---|
1139 | assert( uiCode <= vps->getMaxTLayers()); |
---|
1140 | } |
---|
1141 | } |
---|
1142 | #else |
---|
1143 | READ_CODE( 3, uiCode, "max_tid_il_ref_pics_plus1[i]" ); vps->setMaxTidIlRefPicsPlus1(i, uiCode); |
---|
1144 | #if N0120_MAX_TID_REF_CFG |
---|
1145 | assert( uiCode <= vps->getMaxTLayers()); |
---|
1146 | #else |
---|
1147 | assert( uiCode <= vps->getMaxTLayers()+ 1 ); |
---|
1148 | #endif |
---|
1149 | #endif |
---|
1150 | } |
---|
1151 | } |
---|
1152 | else |
---|
1153 | { |
---|
1154 | for(i = 0; i < vps->getMaxLayers() - 1; i++) |
---|
1155 | { |
---|
1156 | #if O0225_MAX_TID_FOR_REF_LAYERS |
---|
1157 | for( j = i+1; j <= vps->getMaxLayers() - 1; j++) |
---|
1158 | { |
---|
1159 | vps->setMaxTidIlRefPicsPlus1(i, j, 7); |
---|
1160 | } |
---|
1161 | #else |
---|
1162 | vps->setMaxTidIlRefPicsPlus1(i, 7); |
---|
1163 | #endif |
---|
1164 | } |
---|
1165 | } |
---|
1166 | #else |
---|
1167 | for(i = 0; i < vps->getMaxLayers() - 1; i++) |
---|
1168 | { |
---|
1169 | #if O0225_MAX_TID_FOR_REF_LAYERS |
---|
1170 | for( j = i+1; j <= vps->getMaxLayers() - 1; j++) |
---|
1171 | { |
---|
1172 | if(vps->getDirectDependencyFlag(j, i)) |
---|
1173 | { |
---|
1174 | READ_CODE( 3, uiCode, "max_tid_il_ref_pics_plus1[i][j]" ); vps->setMaxTidIlRefPicsPlus1(i, j, uiCode); |
---|
1175 | assert( uiCode <= vps->getMaxTLayers() ); |
---|
1176 | } |
---|
1177 | } |
---|
1178 | #else |
---|
1179 | READ_CODE( 3, uiCode, "max_tid_il_ref_pics_plus1[i]" ); vps->setMaxTidIlRefPicsPlus1(i, uiCode); |
---|
1180 | assert( uiCode <= vps->getMaxTLayers() ); |
---|
1181 | #endif |
---|
1182 | } |
---|
1183 | #endif |
---|
1184 | #endif |
---|
1185 | #if ILP_SSH_SIG |
---|
1186 | READ_FLAG( uiCode, "all_ref_layers_active_flag" ); vps->setIlpSshSignalingEnabledFlag(uiCode ? true : false); |
---|
1187 | #endif |
---|
1188 | #if VPS_EXTN_PROFILE_INFO |
---|
1189 | // Profile-tier-level signalling |
---|
1190 | READ_CODE( 10, uiCode, "vps_number_layer_sets_minus1" ); assert( uiCode == (vps->getNumLayerSets() - 1) ); |
---|
1191 | READ_CODE( 6, uiCode, "vps_num_profile_tier_level_minus1"); vps->setNumProfileTierLevel( uiCode + 1 ); |
---|
1192 | vps->getPTLForExtnPtr()->resize(vps->getNumProfileTierLevel()); |
---|
1193 | for(Int idx = 1; idx <= vps->getNumProfileTierLevel() - 1; idx++) |
---|
1194 | { |
---|
1195 | READ_FLAG( uiCode, "vps_profile_present_flag[i]" ); vps->setProfilePresentFlag(idx, uiCode ? true : false); |
---|
1196 | if( !vps->getProfilePresentFlag(idx) ) |
---|
1197 | { |
---|
1198 | #if P0048_REMOVE_PROFILE_REF |
---|
1199 | // Copy profile information from previous one |
---|
1200 | vps->getPTLForExtn(idx)->copyProfileInfo( (idx==1) ? vps->getPTL() : vps->getPTLForExtn( idx - 1 ) ); |
---|
1201 | #else |
---|
1202 | READ_CODE( 6, uiCode, "profile_ref_minus1[i]" ); vps->setProfileLayerSetRef(idx, uiCode + 1); |
---|
1203 | #if O0109_PROF_REF_MINUS1 |
---|
1204 | assert( vps->getProfileLayerSetRef(idx) <= idx ); |
---|
1205 | #else |
---|
1206 | assert( vps->getProfileLayerSetRef(idx) < idx ); |
---|
1207 | #endif |
---|
1208 | // Copy profile information as indicated |
---|
1209 | vps->getPTLForExtn(idx)->copyProfileInfo( vps->getPTLForExtn( vps->getProfileLayerSetRef(idx) ) ); |
---|
1210 | #endif |
---|
1211 | } |
---|
1212 | parsePTL( vps->getPTLForExtn(idx), vps->getProfilePresentFlag(idx), vps->getMaxTLayers() - 1 ); |
---|
1213 | } |
---|
1214 | #endif |
---|
1215 | |
---|
1216 | READ_FLAG( uiCode, "more_output_layer_sets_than_default_flag" ); vps->setMoreOutputLayerSetsThanDefaultFlag( uiCode ? true : false ); |
---|
1217 | Int numOutputLayerSets = 0; |
---|
1218 | if(! vps->getMoreOutputLayerSetsThanDefaultFlag() ) |
---|
1219 | { |
---|
1220 | numOutputLayerSets = vps->getNumLayerSets(); |
---|
1221 | } |
---|
1222 | else |
---|
1223 | { |
---|
1224 | READ_CODE( 10, uiCode, "num_add_output_layer_sets" ); vps->setNumAddOutputLayerSets( uiCode ); |
---|
1225 | numOutputLayerSets = vps->getNumLayerSets() + vps->getNumAddOutputLayerSets(); |
---|
1226 | } |
---|
1227 | if( numOutputLayerSets > 1 ) |
---|
1228 | { |
---|
1229 | #if O0109_DEFAULT_ONE_OUT_LAYER_IDC |
---|
1230 | READ_CODE( 2, uiCode, "default_one_target_output_layer_idc" ); vps->setDefaultOneTargetOutputLayerIdc( uiCode ); |
---|
1231 | #else |
---|
1232 | READ_FLAG( uiCode, "default_one_target_output_layer_flag" ); vps->setDefaultOneTargetOutputLayerFlag( uiCode ? true : false ); |
---|
1233 | #endif |
---|
1234 | } |
---|
1235 | vps->setNumOutputLayerSets( numOutputLayerSets ); |
---|
1236 | |
---|
1237 | for(i = 1; i < numOutputLayerSets; i++) |
---|
1238 | { |
---|
1239 | if( i > (vps->getNumLayerSets() - 1) ) |
---|
1240 | { |
---|
1241 | Int numBits = 1; |
---|
1242 | while ((1 << numBits) < (vps->getNumLayerSets() - 1)) |
---|
1243 | { |
---|
1244 | numBits++; |
---|
1245 | } |
---|
1246 | READ_CODE( numBits, uiCode, "output_layer_set_idx_minus1"); vps->setOutputLayerSetIdx( i, uiCode + 1); |
---|
1247 | Int lsIdx = vps->getOutputLayerSetIdx(i); |
---|
1248 | for(j = 0; j < vps->getNumLayersInIdList(lsIdx) - 1; j++) |
---|
1249 | { |
---|
1250 | READ_FLAG( uiCode, "output_layer_flag[i][j]"); vps->setOutputLayerFlag(i, j, uiCode); |
---|
1251 | } |
---|
1252 | } |
---|
1253 | else |
---|
1254 | { |
---|
1255 | #if VPS_DPB_SIZE_TABLE |
---|
1256 | vps->setOutputLayerSetIdx( i, i ); |
---|
1257 | #endif |
---|
1258 | // i <= (vps->getNumLayerSets() - 1) |
---|
1259 | // Assign OutputLayerFlag depending on default_one_target_output_layer_flag |
---|
1260 | Int lsIdx = i; |
---|
1261 | #if O0109_DEFAULT_ONE_OUT_LAYER_IDC |
---|
1262 | if( vps->getDefaultOneTargetOutputLayerIdc() == 1 ) |
---|
1263 | { |
---|
1264 | for(j = 0; j < vps->getNumLayersInIdList(lsIdx); j++) |
---|
1265 | { |
---|
1266 | #if O0135_DEFAULT_ONE_OUT_SEMANTIC |
---|
1267 | vps->setOutputLayerFlag(i, j, (j == (vps->getNumLayersInIdList(lsIdx)-1)) && (vps->getDimensionId(j,1)==0) ); |
---|
1268 | #else |
---|
1269 | vps->setOutputLayerFlag(i, j, (j == (vps->getNumLayersInIdList(lsIdx)-1))); |
---|
1270 | #endif |
---|
1271 | } |
---|
1272 | } |
---|
1273 | else if ( vps->getDefaultOneTargetOutputLayerIdc() == 0 ) |
---|
1274 | { |
---|
1275 | for(j = 0; j < vps->getNumLayersInIdList(lsIdx); j++) |
---|
1276 | { |
---|
1277 | vps->setOutputLayerFlag(i, j, 1); |
---|
1278 | } |
---|
1279 | } |
---|
1280 | else |
---|
1281 | { |
---|
1282 | // Other values of default_one_target_output_layer_idc than 0 and 1 are reserved for future use. |
---|
1283 | } |
---|
1284 | #else |
---|
1285 | if( vps->getDefaultOneTargetOutputLayerFlag() ) |
---|
1286 | { |
---|
1287 | for(j = 0; j < vps->getNumLayersInIdList(lsIdx); j++) |
---|
1288 | { |
---|
1289 | vps->setOutputLayerFlag(i, j, (j == (vps->getNumLayersInIdList(lsIdx)-1))); |
---|
1290 | } |
---|
1291 | } |
---|
1292 | else |
---|
1293 | { |
---|
1294 | for(j = 0; j < vps->getNumLayersInIdList(lsIdx); j++) |
---|
1295 | { |
---|
1296 | vps->setOutputLayerFlag(i, j, 1); |
---|
1297 | } |
---|
1298 | } |
---|
1299 | #endif |
---|
1300 | } |
---|
1301 | Int numBits = 1; |
---|
1302 | while ((1 << numBits) < (vps->getNumProfileTierLevel())) |
---|
1303 | { |
---|
1304 | numBits++; |
---|
1305 | } |
---|
1306 | READ_CODE( numBits, uiCode, "profile_level_tier_idx[i]" ); vps->setProfileLevelTierIdx(i, uiCode); |
---|
1307 | } |
---|
1308 | |
---|
1309 | #if O0153_ALT_OUTPUT_LAYER_FLAG |
---|
1310 | if( vps->getMaxLayers() > 1 ) |
---|
1311 | { |
---|
1312 | READ_FLAG( uiCode, "alt_output_layer_flag"); |
---|
1313 | vps->setAltOuputLayerFlag( uiCode ? true : false ); |
---|
1314 | } |
---|
1315 | #endif |
---|
1316 | |
---|
1317 | #if REPN_FORMAT_IN_VPS |
---|
1318 | READ_FLAG( uiCode, "rep_format_idx_present_flag"); |
---|
1319 | vps->setRepFormatIdxPresentFlag( uiCode ? true : false ); |
---|
1320 | |
---|
1321 | if( vps->getRepFormatIdxPresentFlag() ) |
---|
1322 | { |
---|
1323 | #if O0096_REP_FORMAT_INDEX |
---|
1324 | READ_CODE( 8, uiCode, "vps_num_rep_formats_minus1" ); |
---|
1325 | #else |
---|
1326 | READ_CODE( 4, uiCode, "vps_num_rep_formats_minus1" ); |
---|
1327 | #endif |
---|
1328 | vps->setVpsNumRepFormats( uiCode + 1 ); |
---|
1329 | } |
---|
1330 | else |
---|
1331 | { |
---|
1332 | // default assignment |
---|
1333 | assert (vps->getMaxLayers() <= 16); // If max_layers_is more than 15, num_rep_formats has to be signaled |
---|
1334 | vps->setVpsNumRepFormats( vps->getMaxLayers() ); |
---|
1335 | } |
---|
1336 | for(i = 0; i < vps->getVpsNumRepFormats(); i++) |
---|
1337 | { |
---|
1338 | // Read rep_format_structures |
---|
1339 | parseRepFormat( vps->getVpsRepFormat(i) ); |
---|
1340 | } |
---|
1341 | |
---|
1342 | // Default assignment for layer 0 |
---|
1343 | vps->setVpsRepFormatIdx( 0, 0 ); |
---|
1344 | if( vps->getRepFormatIdxPresentFlag() ) |
---|
1345 | { |
---|
1346 | for(i = 1; i < vps->getMaxLayers(); i++) |
---|
1347 | { |
---|
1348 | if( vps->getVpsNumRepFormats() > 1 ) |
---|
1349 | { |
---|
1350 | #if O0096_REP_FORMAT_INDEX |
---|
1351 | READ_CODE( 8, uiCode, "vps_rep_format_idx[i]" ); |
---|
1352 | #else |
---|
1353 | READ_CODE( 4, uiCode, "vps_rep_format_idx[i]" ); |
---|
1354 | #endif |
---|
1355 | vps->setVpsRepFormatIdx( i, uiCode ); |
---|
1356 | } |
---|
1357 | else |
---|
1358 | { |
---|
1359 | // default assignment - only one rep_format() structure |
---|
1360 | vps->setVpsRepFormatIdx( i, 0 ); |
---|
1361 | } |
---|
1362 | } |
---|
1363 | } |
---|
1364 | else |
---|
1365 | { |
---|
1366 | // default assignment - each layer assigned each rep_format() structure in the order signaled |
---|
1367 | for(i = 1; i < vps->getMaxLayers(); i++) |
---|
1368 | { |
---|
1369 | vps->setVpsRepFormatIdx( i, i ); |
---|
1370 | } |
---|
1371 | } |
---|
1372 | #endif |
---|
1373 | #if JCTVC_M0458_INTERLAYER_RPS_SIG |
---|
1374 | READ_FLAG(uiCode, "max_one_active_ref_layer_flag" ); |
---|
1375 | vps->setMaxOneActiveRefLayerFlag(uiCode); |
---|
1376 | #endif |
---|
1377 | #if O0062_POC_LSB_NOT_PRESENT_FLAG |
---|
1378 | for(i = 1; i< vps->getMaxLayers(); i++) |
---|
1379 | { |
---|
1380 | if( vps->getNumDirectRefLayers( vps->getLayerIdInNuh(i) ) == 0 ) |
---|
1381 | { |
---|
1382 | READ_FLAG(uiCode, "poc_lsb_not_present_flag[i]"); |
---|
1383 | vps->setPocLsbNotPresentFlag(i, uiCode); |
---|
1384 | } |
---|
1385 | } |
---|
1386 | #endif |
---|
1387 | #if O0215_PHASE_ALIGNMENT |
---|
1388 | READ_FLAG( uiCode, "cross_layer_phase_alignment_flag"); vps->setPhaseAlignFlag( uiCode == 1 ? true : false ); |
---|
1389 | #endif |
---|
1390 | |
---|
1391 | #if N0147_IRAP_ALIGN_FLAG && !IRAP_ALIGN_FLAG_IN_VPS_VUI |
---|
1392 | READ_FLAG(uiCode, "cross_layer_irap_aligned_flag" ); |
---|
1393 | vps->setCrossLayerIrapAlignFlag(uiCode); |
---|
1394 | #endif |
---|
1395 | |
---|
1396 | #if VPS_DPB_SIZE_TABLE |
---|
1397 | vps->deriveNumberOfSubDpbs(); |
---|
1398 | for(i = 1; i < vps->getNumOutputLayerSets(); i++) |
---|
1399 | { |
---|
1400 | READ_FLAG( uiCode, "sub_layer_flag_info_present_flag[i]"); vps->setSubLayerFlagInfoPresentFlag( i, uiCode ? true : false ); |
---|
1401 | for(j = 0; j < vps->getMaxTLayers(); j++) |
---|
1402 | { |
---|
1403 | if( j > 0 && vps->getSubLayerFlagInfoPresentFlag(i) ) |
---|
1404 | { |
---|
1405 | READ_FLAG( uiCode, "sub_layer_dpb_info_present_flag[i]"); vps->setSubLayerDpbInfoPresentFlag( i, j, uiCode ? true : false); |
---|
1406 | } |
---|
1407 | else |
---|
1408 | { |
---|
1409 | if( j == 0 ) // Always signal for the first sub-layer |
---|
1410 | { |
---|
1411 | vps->setSubLayerDpbInfoPresentFlag( i, j, true ); |
---|
1412 | } |
---|
1413 | else // if (j != 0) && !vps->getSubLayerFlagInfoPresentFlag(i) |
---|
1414 | { |
---|
1415 | vps->setSubLayerDpbInfoPresentFlag( i, j, false ); |
---|
1416 | } |
---|
1417 | } |
---|
1418 | if( vps->getSubLayerDpbInfoPresentFlag(i, j) ) // If sub-layer DPB information is present |
---|
1419 | { |
---|
1420 | for(Int k = 0; k < vps->getNumSubDpbs(i); k++) |
---|
1421 | { |
---|
1422 | READ_UVLC( uiCode, "max_vps_dec_pic_buffering_minus1[i][k][j]" ); vps->setMaxVpsDecPicBufferingMinus1( i, k, j, uiCode ); |
---|
1423 | } |
---|
1424 | READ_UVLC( uiCode, "max_vps_num_reorder_pics[i][j]" ); vps->setMaxVpsNumReorderPics( i, j, uiCode); |
---|
1425 | READ_UVLC( uiCode, "max_vps_latency_increase_plus1[i][j]" ); vps->setMaxVpsLatencyIncreasePlus1( i, j, uiCode); |
---|
1426 | } |
---|
1427 | } |
---|
1428 | } |
---|
1429 | #endif |
---|
1430 | #if VPS_EXTN_DIRECT_REF_LAYERS && M0457_PREDICTION_INDICATIONS |
---|
1431 | READ_UVLC( uiCode, "direct_dep_type_len_minus2"); vps->setDirectDepTypeLen(uiCode+2); |
---|
1432 | #if O0096_DEFAULT_DEPENDENCY_TYPE |
---|
1433 | READ_FLAG(uiCode, "default_direct_dependency_type_flag"); |
---|
1434 | vps->setDefaultDirectDependecyTypeFlag(uiCode == 1? true : false); |
---|
1435 | if (vps->getDefaultDirectDependencyTypeFlag()) |
---|
1436 | { |
---|
1437 | READ_CODE( vps->getDirectDepTypeLen(), uiCode, "default_direct_dependency_type" ); |
---|
1438 | vps->setDefaultDirectDependecyType(uiCode); |
---|
1439 | } |
---|
1440 | #endif |
---|
1441 | for(i = 1; i < vps->getMaxLayers(); i++) |
---|
1442 | { |
---|
1443 | for(j = 0; j < i; j++) |
---|
1444 | { |
---|
1445 | if (vps->getDirectDependencyFlag(i, j)) |
---|
1446 | { |
---|
1447 | #if O0096_DEFAULT_DEPENDENCY_TYPE |
---|
1448 | if (vps->getDefaultDirectDependencyTypeFlag()) |
---|
1449 | { |
---|
1450 | vps->setDirectDependencyType(i, j, vps->getDefaultDirectDependencyType()); |
---|
1451 | } |
---|
1452 | else |
---|
1453 | { |
---|
1454 | READ_CODE( vps->getDirectDepTypeLen(), uiCode, "direct_dependency_type[i][j]" ); |
---|
1455 | vps->setDirectDependencyType(i, j, uiCode); |
---|
1456 | } |
---|
1457 | #else |
---|
1458 | READ_CODE( vps->getDirectDepTypeLen(), uiCode, "direct_dependency_type[i][j]" ); |
---|
1459 | vps->setDirectDependencyType(i, j, uiCode); |
---|
1460 | #endif |
---|
1461 | } |
---|
1462 | } |
---|
1463 | } |
---|
1464 | #endif |
---|
1465 | #if O0092_0094_DEPENDENCY_CONSTRAINT |
---|
1466 | for(i = 1; i < vps->getMaxLayers(); i++) |
---|
1467 | { |
---|
1468 | vps->setNumRefLayers(vps->getLayerIdInNuh(i)); // identify the number of direct and indirect reference layers of current layer and set recursiveRefLayersFlags |
---|
1469 | } |
---|
1470 | if(vps->getMaxLayers() > MAX_REF_LAYERS) |
---|
1471 | { |
---|
1472 | for(i = 1;i < vps->getMaxLayers(); i++) |
---|
1473 | { |
---|
1474 | assert( vps->getNumRefLayers(vps->getLayerIdInNuh(i)) <= MAX_REF_LAYERS); |
---|
1475 | } |
---|
1476 | } |
---|
1477 | #endif |
---|
1478 | |
---|
1479 | #if P0307_VPS_NON_VUI_EXTENSION |
---|
1480 | READ_UVLC( uiCode, "vps_non_vui_extension_length"); vps->setVpsNonVuiExtLength((Int)uiCode); |
---|
1481 | if ( vps->getVpsNonVuiExtLength() > 0 ) |
---|
1482 | { |
---|
1483 | printf("\n\nUp to the current spec, the value of vps_non_vui_extension_length is supposed to be 0\n"); |
---|
1484 | } |
---|
1485 | #endif |
---|
1486 | |
---|
1487 | #if !O0109_O0199_FLAGS_TO_VUI |
---|
1488 | #if M0040_ADAPTIVE_RESOLUTION_CHANGE |
---|
1489 | READ_FLAG(uiCode, "single_layer_for_non_irap_flag" ); vps->setSingleLayerForNonIrapFlag(uiCode == 1 ? true : false); |
---|
1490 | #endif |
---|
1491 | #if HIGHER_LAYER_IRAP_SKIP_FLAG |
---|
1492 | READ_FLAG(uiCode, "higher_layer_irap_skip_flag" ); vps->setHigherLayerIrapSkipFlag(uiCode == 1 ? true : false); |
---|
1493 | #endif |
---|
1494 | #endif |
---|
1495 | |
---|
1496 | #if P0307_REMOVE_VPS_VUI_OFFSET |
---|
1497 | READ_FLAG( uiCode, "vps_vui_present_flag"); vps->setVpsVuiPresentFlag(uiCode ? true : false); |
---|
1498 | #endif |
---|
1499 | |
---|
1500 | #if O0109_MOVE_VPS_VUI_FLAG |
---|
1501 | if ( vps->getVpsVuiPresentFlag() ) |
---|
1502 | #else |
---|
1503 | READ_FLAG( uiCode, "vps_vui_present_flag" ); |
---|
1504 | if (uiCode) |
---|
1505 | #endif |
---|
1506 | { |
---|
1507 | #if VPS_VUI |
---|
1508 | while ( m_pcBitstream->getNumBitsRead() % 8 != 0 ) |
---|
1509 | { |
---|
1510 | READ_FLAG( uiCode, "vps_vui_alignment_bit_equal_to_one"); assert(uiCode == 1); |
---|
1511 | } |
---|
1512 | parseVPSVUI(vps); |
---|
1513 | #endif |
---|
1514 | } |
---|
1515 | } |
---|
1516 | #endif |
---|
1517 | #if REPN_FORMAT_IN_VPS |
---|
1518 | Void TDecCavlc::parseRepFormat ( RepFormat *repFormat ) |
---|
1519 | { |
---|
1520 | UInt uiCode; |
---|
1521 | #if REPN_FORMAT_CONTROL_FLAG |
---|
1522 | READ_FLAG ( uiCode, "chroma_and_bit_depth_vps_present_flag"); repFormat->setChromaAndBitDepthVpsPresentFlag(uiCode ? true : false); |
---|
1523 | READ_CODE ( 16, uiCode, "pic_width_in_luma_samples" ); repFormat->setPicWidthVpsInLumaSamples ( uiCode ); |
---|
1524 | READ_CODE ( 16, uiCode, "pic_height_in_luma_samples" ); repFormat->setPicHeightVpsInLumaSamples( uiCode ); |
---|
1525 | |
---|
1526 | if( repFormat->getChromaAndBitDepthVpsPresentFlag() ) |
---|
1527 | { |
---|
1528 | #if AUXILIARY_PICTURES |
---|
1529 | READ_CODE( 2, uiCode, "chroma_format_idc" ); repFormat->setChromaFormatVpsIdc( ChromaFormat(uiCode) ); |
---|
1530 | #else |
---|
1531 | READ_CODE( 2, uiCode, "chroma_format_idc" ); repFormat->setChromaFormatVpsIdc( uiCode ); |
---|
1532 | #endif |
---|
1533 | |
---|
1534 | if( repFormat->getChromaFormatVpsIdc() == 3 ) |
---|
1535 | { |
---|
1536 | READ_FLAG( uiCode, "separate_colour_plane_flag"); repFormat->setSeparateColourPlaneVpsFlag(uiCode ? true : false); |
---|
1537 | } |
---|
1538 | |
---|
1539 | |
---|
1540 | READ_CODE( 4, uiCode, "bit_depth_luma_minus8" ); repFormat->setBitDepthVpsLuma ( uiCode + 8 ); |
---|
1541 | READ_CODE( 4, uiCode, "bit_depth_chroma_minus8" ); repFormat->setBitDepthVpsChroma( uiCode + 8 ); |
---|
1542 | } |
---|
1543 | #else |
---|
1544 | #if AUXILIARY_PICTURES |
---|
1545 | READ_CODE( 2, uiCode, "chroma_format_idc" ); repFormat->setChromaFormatVpsIdc( ChromaFormat(uiCode) ); |
---|
1546 | #else |
---|
1547 | READ_CODE( 2, uiCode, "chroma_format_idc" ); repFormat->setChromaFormatVpsIdc( uiCode ); |
---|
1548 | #endif |
---|
1549 | |
---|
1550 | if( repFormat->getChromaFormatVpsIdc() == 3 ) |
---|
1551 | { |
---|
1552 | READ_FLAG( uiCode, "separate_colour_plane_flag"); repFormat->setSeparateColourPlaneVpsFlag(uiCode ? true : false); |
---|
1553 | } |
---|
1554 | |
---|
1555 | READ_CODE ( 16, uiCode, "pic_width_in_luma_samples" ); repFormat->setPicWidthVpsInLumaSamples ( uiCode ); |
---|
1556 | READ_CODE ( 16, uiCode, "pic_height_in_luma_samples" ); repFormat->setPicHeightVpsInLumaSamples( uiCode ); |
---|
1557 | |
---|
1558 | READ_CODE( 4, uiCode, "bit_depth_luma_minus8" ); repFormat->setBitDepthVpsLuma ( uiCode + 8 ); |
---|
1559 | READ_CODE( 4, uiCode, "bit_depth_chroma_minus8" ); repFormat->setBitDepthVpsChroma( uiCode + 8 ); |
---|
1560 | #endif |
---|
1561 | } |
---|
1562 | #endif |
---|
1563 | #if VPS_VUI |
---|
1564 | Void TDecCavlc::parseVPSVUI(TComVPS *vps) |
---|
1565 | { |
---|
1566 | UInt i,j; |
---|
1567 | UInt uiCode; |
---|
1568 | #if O0223_PICTURE_TYPES_ALIGN_FLAG |
---|
1569 | READ_FLAG(uiCode, "cross_layer_pic_type_aligned_flag" ); |
---|
1570 | vps->setCrossLayerPictureTypeAlignFlag(uiCode); |
---|
1571 | if (!uiCode) |
---|
1572 | { |
---|
1573 | #endif |
---|
1574 | #if IRAP_ALIGN_FLAG_IN_VPS_VUI |
---|
1575 | READ_FLAG(uiCode, "cross_layer_irap_aligned_flag" ); |
---|
1576 | vps->setCrossLayerIrapAlignFlag(uiCode); |
---|
1577 | #endif |
---|
1578 | #if O0223_PICTURE_TYPES_ALIGN_FLAG |
---|
1579 | } |
---|
1580 | else |
---|
1581 | { |
---|
1582 | vps->setCrossLayerIrapAlignFlag(true); |
---|
1583 | } |
---|
1584 | #endif |
---|
1585 | #if VPS_VUI_BITRATE_PICRATE |
---|
1586 | READ_FLAG( uiCode, "bit_rate_present_vps_flag" ); vps->setBitRatePresentVpsFlag( uiCode ? true : false ); |
---|
1587 | READ_FLAG( uiCode, "pic_rate_present_vps_flag" ); vps->setPicRatePresentVpsFlag( uiCode ? true : false ); |
---|
1588 | |
---|
1589 | Bool parseFlag = vps->getBitRatePresentVpsFlag() || vps->getPicRatePresentVpsFlag(); |
---|
1590 | { |
---|
1591 | for( i = 0; i < vps->getNumLayerSets(); i++ ) |
---|
1592 | { |
---|
1593 | for( j = 0; j < vps->getMaxTLayers(); j++ ) |
---|
1594 | { |
---|
1595 | if( parseFlag && vps->getBitRatePresentVpsFlag() ) |
---|
1596 | { |
---|
1597 | READ_FLAG( uiCode, "bit_rate_present_vps_flag[i][j]" ); vps->setBitRatePresentFlag( i, j, uiCode ? true : false ); |
---|
1598 | } |
---|
1599 | else |
---|
1600 | { |
---|
1601 | vps->setBitRatePresentFlag( i, j, false ); |
---|
1602 | } |
---|
1603 | if( parseFlag && vps->getPicRatePresentVpsFlag() ) |
---|
1604 | { |
---|
1605 | READ_FLAG( uiCode, "pic_rate_present_vps_flag[i][j]" ); vps->setPicRatePresentFlag( i, j, uiCode ? true : false ); |
---|
1606 | } |
---|
1607 | else |
---|
1608 | { |
---|
1609 | vps->setPicRatePresentFlag( i, j, false ); |
---|
1610 | } |
---|
1611 | if( parseFlag && vps->getBitRatePresentFlag(i, j) ) |
---|
1612 | { |
---|
1613 | READ_CODE( 16, uiCode, "avg_bit_rate[i][j]" ); vps->setAvgBitRate( i, j, uiCode ); |
---|
1614 | READ_CODE( 16, uiCode, "max_bit_rate[i][j]" ); vps->setMaxBitRate( i, j, uiCode ); |
---|
1615 | } |
---|
1616 | else |
---|
1617 | { |
---|
1618 | vps->setAvgBitRate( i, j, 0 ); |
---|
1619 | vps->setMaxBitRate( i, j, 0 ); |
---|
1620 | } |
---|
1621 | if( parseFlag && vps->getPicRatePresentFlag(i, j) ) |
---|
1622 | { |
---|
1623 | READ_CODE( 2 , uiCode, "constant_pic_rate_idc[i][j]" ); vps->setConstPicRateIdc( i, j, uiCode ); |
---|
1624 | READ_CODE( 16, uiCode, "avg_pic_rate[i][j]" ); vps->setAvgPicRate( i, j, uiCode ); |
---|
1625 | } |
---|
1626 | else |
---|
1627 | { |
---|
1628 | vps->setConstPicRateIdc( i, j, 0 ); |
---|
1629 | vps->setAvgPicRate ( i, j, 0 ); |
---|
1630 | } |
---|
1631 | } |
---|
1632 | } |
---|
1633 | } |
---|
1634 | #endif |
---|
1635 | #if VPS_VUI_TILES_NOT_IN_USE__FLAG |
---|
1636 | UInt layerIdx; |
---|
1637 | READ_FLAG( uiCode, "tiles_not_in_use_flag" ); vps->setTilesNotInUseFlag(uiCode == 1); |
---|
1638 | if (!uiCode) |
---|
1639 | { |
---|
1640 | for(i = 0; i < vps->getMaxLayers(); i++) |
---|
1641 | { |
---|
1642 | READ_FLAG( uiCode, "tiles_in_use_flag[ i ]" ); vps->setTilesInUseFlag(i, (uiCode == 1)); |
---|
1643 | if (uiCode) |
---|
1644 | { |
---|
1645 | READ_FLAG( uiCode, "loop_filter_not_across_tiles_flag[ i ]" ); vps->setLoopFilterNotAcrossTilesFlag(i, (uiCode == 1)); |
---|
1646 | } |
---|
1647 | else |
---|
1648 | { |
---|
1649 | vps->setLoopFilterNotAcrossTilesFlag(i, false); |
---|
1650 | } |
---|
1651 | } |
---|
1652 | #endif |
---|
1653 | #if TILE_BOUNDARY_ALIGNED_FLAG |
---|
1654 | for(i = 1; i < vps->getMaxLayers(); i++) |
---|
1655 | { |
---|
1656 | for(j = 0; j < vps->getNumDirectRefLayers(vps->getLayerIdInNuh(i)); j++) |
---|
1657 | { |
---|
1658 | #if VPS_VUI_TILES_NOT_IN_USE__FLAG |
---|
1659 | layerIdx = vps->getLayerIdInVps(vps->getRefLayerId(vps->getLayerIdInNuh(i), j)); |
---|
1660 | if (vps->getTilesInUseFlag(i) && vps->getTilesInUseFlag(layerIdx)) { |
---|
1661 | READ_FLAG( uiCode, "tile_boundaries_aligned_flag[i][j]" ); vps->setTileBoundariesAlignedFlag(i,j,(uiCode == 1)); |
---|
1662 | } |
---|
1663 | #else |
---|
1664 | READ_FLAG( uiCode, "tile_boundaries_aligned_flag[i][j]" ); vps->setTileBoundariesAlignedFlag(i,j,(uiCode == 1)); |
---|
1665 | #endif |
---|
1666 | } |
---|
1667 | } |
---|
1668 | #endif |
---|
1669 | #if VPS_VUI_TILES_NOT_IN_USE__FLAG |
---|
1670 | } |
---|
1671 | #endif |
---|
1672 | #if VPS_VUI_WPP_NOT_IN_USE__FLAG |
---|
1673 | READ_FLAG( uiCode, "wpp_not_in_use_flag" ); vps->setWppNotInUseFlag(uiCode == 1); |
---|
1674 | if (!uiCode) |
---|
1675 | { |
---|
1676 | for(i = 0; i < vps->getMaxLayers(); i++) |
---|
1677 | { |
---|
1678 | READ_FLAG( uiCode, "wpp_in_use_flag[ i ]" ); vps->setWppInUseFlag(i, (uiCode == 1)); |
---|
1679 | } |
---|
1680 | } |
---|
1681 | #endif |
---|
1682 | |
---|
1683 | #if O0109_O0199_FLAGS_TO_VUI |
---|
1684 | #if M0040_ADAPTIVE_RESOLUTION_CHANGE |
---|
1685 | READ_FLAG(uiCode, "single_layer_for_non_irap_flag" ); vps->setSingleLayerForNonIrapFlag(uiCode == 1 ? true : false); |
---|
1686 | #endif |
---|
1687 | #if HIGHER_LAYER_IRAP_SKIP_FLAG |
---|
1688 | READ_FLAG(uiCode, "higher_layer_irap_skip_flag" ); vps->setHigherLayerIrapSkipFlag(uiCode == 1 ? true : false); |
---|
1689 | #endif |
---|
1690 | #endif |
---|
1691 | |
---|
1692 | #if N0160_VUI_EXT_ILP_REF |
---|
1693 | READ_FLAG( uiCode, "ilp_restricted_ref_layers_flag" ); vps->setIlpRestrictedRefLayersFlag( uiCode == 1 ); |
---|
1694 | if( vps->getIlpRestrictedRefLayersFlag()) |
---|
1695 | { |
---|
1696 | for(i = 1; i < vps->getMaxLayers(); i++) |
---|
1697 | { |
---|
1698 | for(j = 0; j < vps->getNumDirectRefLayers(vps->getLayerIdInNuh(i)); j++) |
---|
1699 | { |
---|
1700 | READ_UVLC( uiCode, "min_spatial_segment_offset_plus1[i][j]" ); vps->setMinSpatialSegmentOffsetPlus1( i, j, uiCode ); |
---|
1701 | if( vps->getMinSpatialSegmentOffsetPlus1(i,j ) > 0 ) |
---|
1702 | { |
---|
1703 | READ_FLAG( uiCode, "ctu_based_offset_enabled_flag[i][j]"); vps->setCtuBasedOffsetEnabledFlag(i, j, uiCode == 1 ); |
---|
1704 | if(vps->getCtuBasedOffsetEnabledFlag(i,j)) |
---|
1705 | { |
---|
1706 | READ_UVLC( uiCode, "min_horizontal_ctu_offset_plus1[i][j]"); vps->setMinHorizontalCtuOffsetPlus1( i,j, uiCode ); |
---|
1707 | } |
---|
1708 | } |
---|
1709 | } |
---|
1710 | } |
---|
1711 | } |
---|
1712 | #endif |
---|
1713 | #if VPS_VUI_VIDEO_SIGNAL |
---|
1714 | READ_FLAG( uiCode, "video_signal_info_idx_present_flag" ); vps->setVideoSigPresentVpsFlag( uiCode == 1 ); |
---|
1715 | if (vps->getVideoSigPresentVpsFlag()) |
---|
1716 | { |
---|
1717 | READ_CODE(4, uiCode, "vps_num_video_signal_info_minus1" ); vps->setNumVideoSignalInfo(uiCode + 1); |
---|
1718 | } |
---|
1719 | else |
---|
1720 | { |
---|
1721 | vps->setNumVideoSignalInfo(vps->getMaxLayers()); |
---|
1722 | } |
---|
1723 | |
---|
1724 | |
---|
1725 | for(i = 0; i < vps->getNumVideoSignalInfo(); i++) |
---|
1726 | { |
---|
1727 | READ_CODE(3, uiCode, "video_vps_format" ); vps->setVideoVPSFormat(i,uiCode); |
---|
1728 | READ_FLAG(uiCode, "video_full_range_vps_flag" ); vps->setVideoFullRangeVpsFlag(i,uiCode); |
---|
1729 | READ_CODE(8, uiCode, "color_primaries_vps" ); vps->setColorPrimaries(i,uiCode); |
---|
1730 | READ_CODE(8, uiCode, "transfer_characteristics_vps" ); vps->setTransCharacter(i,uiCode); |
---|
1731 | READ_CODE(8, uiCode, "matrix_coeffs_vps" );vps->setMaxtrixCoeff(i,uiCode); |
---|
1732 | } |
---|
1733 | if(!vps->getVideoSigPresentVpsFlag()) |
---|
1734 | { |
---|
1735 | for (i=0; i < vps->getMaxLayers(); i++) |
---|
1736 | { |
---|
1737 | vps->setVideoSignalInfoIdx(i,i); |
---|
1738 | } |
---|
1739 | } |
---|
1740 | else { |
---|
1741 | vps->setVideoSignalInfoIdx(0,0); |
---|
1742 | if (vps->getNumVideoSignalInfo() > 1 ) |
---|
1743 | { |
---|
1744 | for (i=1; i < vps->getMaxLayers(); i++) |
---|
1745 | READ_CODE(4, uiCode, "vps_video_signal_info_idx" ); vps->setVideoSignalInfoIdx(i, uiCode); |
---|
1746 | } |
---|
1747 | else { |
---|
1748 | for (i=1; i < vps->getMaxLayers(); i++) |
---|
1749 | { |
---|
1750 | vps->setVideoSignalInfoIdx(i,0); |
---|
1751 | } |
---|
1752 | } |
---|
1753 | } |
---|
1754 | #endif |
---|
1755 | } |
---|
1756 | #endif |
---|
1757 | #endif //SVC_EXTENSION |
---|
1758 | |
---|
1759 | Void TDecCavlc::parseSliceHeader (TComSlice*& rpcSlice, ParameterSetManagerDecoder *parameterSetManager) |
---|
1760 | { |
---|
1761 | UInt uiCode; |
---|
1762 | Int iCode; |
---|
1763 | |
---|
1764 | #if ENC_DEC_TRACE |
---|
1765 | xTraceSliceHeader(rpcSlice); |
---|
1766 | #endif |
---|
1767 | TComPPS* pps = NULL; |
---|
1768 | TComSPS* sps = NULL; |
---|
1769 | |
---|
1770 | UInt firstSliceSegmentInPic; |
---|
1771 | READ_FLAG( firstSliceSegmentInPic, "first_slice_segment_in_pic_flag" ); |
---|
1772 | if( rpcSlice->getRapPicFlag()) |
---|
1773 | { |
---|
1774 | READ_FLAG( uiCode, "no_output_of_prior_pics_flag" ); //ignored |
---|
1775 | } |
---|
1776 | READ_UVLC ( uiCode, "slice_pic_parameter_set_id" ); rpcSlice->setPPSId(uiCode); |
---|
1777 | pps = parameterSetManager->getPrefetchedPPS(uiCode); |
---|
1778 | //!KS: need to add error handling code here, if PPS is not available |
---|
1779 | assert(pps!=0); |
---|
1780 | sps = parameterSetManager->getPrefetchedSPS(pps->getSPSId()); |
---|
1781 | //!KS: need to add error handling code here, if SPS is not available |
---|
1782 | assert(sps!=0); |
---|
1783 | rpcSlice->setSPS(sps); |
---|
1784 | rpcSlice->setPPS(pps); |
---|
1785 | if( pps->getDependentSliceSegmentsEnabledFlag() && ( !firstSliceSegmentInPic )) |
---|
1786 | { |
---|
1787 | READ_FLAG( uiCode, "dependent_slice_segment_flag" ); rpcSlice->setDependentSliceSegmentFlag(uiCode ? true : false); |
---|
1788 | } |
---|
1789 | else |
---|
1790 | { |
---|
1791 | rpcSlice->setDependentSliceSegmentFlag(false); |
---|
1792 | } |
---|
1793 | #if REPN_FORMAT_IN_VPS |
---|
1794 | Int numCTUs = ((rpcSlice->getPicWidthInLumaSamples()+sps->getMaxCUWidth()-1)/sps->getMaxCUWidth())*((rpcSlice->getPicHeightInLumaSamples()+sps->getMaxCUHeight()-1)/sps->getMaxCUHeight()); |
---|
1795 | #else |
---|
1796 | Int numCTUs = ((sps->getPicWidthInLumaSamples()+sps->getMaxCUWidth()-1)/sps->getMaxCUWidth())*((sps->getPicHeightInLumaSamples()+sps->getMaxCUHeight()-1)/sps->getMaxCUHeight()); |
---|
1797 | #endif |
---|
1798 | Int maxParts = (1<<(sps->getMaxCUDepth()<<1)); |
---|
1799 | UInt sliceSegmentAddress = 0; |
---|
1800 | Int bitsSliceSegmentAddress = 0; |
---|
1801 | while(numCTUs>(1<<bitsSliceSegmentAddress)) |
---|
1802 | { |
---|
1803 | bitsSliceSegmentAddress++; |
---|
1804 | } |
---|
1805 | |
---|
1806 | if(!firstSliceSegmentInPic) |
---|
1807 | { |
---|
1808 | READ_CODE( bitsSliceSegmentAddress, sliceSegmentAddress, "slice_segment_address" ); |
---|
1809 | } |
---|
1810 | //set uiCode to equal slice start address (or dependent slice start address) |
---|
1811 | Int startCuAddress = maxParts*sliceSegmentAddress; |
---|
1812 | rpcSlice->setSliceSegmentCurStartCUAddr( startCuAddress ); |
---|
1813 | rpcSlice->setSliceSegmentCurEndCUAddr(numCTUs*maxParts); |
---|
1814 | |
---|
1815 | if (rpcSlice->getDependentSliceSegmentFlag()) |
---|
1816 | { |
---|
1817 | rpcSlice->setNextSlice ( false ); |
---|
1818 | rpcSlice->setNextSliceSegment ( true ); |
---|
1819 | } |
---|
1820 | else |
---|
1821 | { |
---|
1822 | rpcSlice->setNextSlice ( true ); |
---|
1823 | rpcSlice->setNextSliceSegment ( false ); |
---|
1824 | |
---|
1825 | rpcSlice->setSliceCurStartCUAddr(startCuAddress); |
---|
1826 | rpcSlice->setSliceCurEndCUAddr(numCTUs*maxParts); |
---|
1827 | } |
---|
1828 | |
---|
1829 | if(!rpcSlice->getDependentSliceSegmentFlag()) |
---|
1830 | { |
---|
1831 | #if SVC_EXTENSION |
---|
1832 | #if POC_RESET_FLAG |
---|
1833 | Int iBits = 0; |
---|
1834 | if(rpcSlice->getPPS()->getNumExtraSliceHeaderBits() > iBits) |
---|
1835 | { |
---|
1836 | READ_FLAG(uiCode, "poc_reset_flag"); rpcSlice->setPocResetFlag( uiCode ? true : false ); |
---|
1837 | iBits++; |
---|
1838 | } |
---|
1839 | if(rpcSlice->getPPS()->getNumExtraSliceHeaderBits() > iBits) |
---|
1840 | { |
---|
1841 | READ_FLAG(uiCode, "discardable_flag"); // ignored |
---|
1842 | iBits++; |
---|
1843 | } |
---|
1844 | #if O0149_CROSS_LAYER_BLA_FLAG |
---|
1845 | if(rpcSlice->getPPS()->getNumExtraSliceHeaderBits() > iBits) |
---|
1846 | { |
---|
1847 | READ_FLAG(uiCode, "cross_layer_bla_flag"); rpcSlice->setCrossLayerBLAFlag( uiCode ? true : false ); |
---|
1848 | iBits++; |
---|
1849 | } |
---|
1850 | #endif |
---|
1851 | for (; iBits < rpcSlice->getPPS()->getNumExtraSliceHeaderBits(); iBits++) |
---|
1852 | { |
---|
1853 | READ_FLAG(uiCode, "slice_reserved_undetermined_flag[]"); // ignored |
---|
1854 | } |
---|
1855 | #else |
---|
1856 | if(rpcSlice->getPPS()->getNumExtraSliceHeaderBits()>0) |
---|
1857 | { |
---|
1858 | READ_FLAG(uiCode, "discardable_flag"); // ignored |
---|
1859 | } |
---|
1860 | for (Int i = 1; i < rpcSlice->getPPS()->getNumExtraSliceHeaderBits(); i++) |
---|
1861 | { |
---|
1862 | READ_FLAG(uiCode, "slice_reserved_undetermined_flag[]"); // ignored |
---|
1863 | } |
---|
1864 | #endif |
---|
1865 | #else //SVC_EXTENSION |
---|
1866 | for (Int i = 0; i < rpcSlice->getPPS()->getNumExtraSliceHeaderBits(); i++) |
---|
1867 | { |
---|
1868 | READ_FLAG(uiCode, "slice_reserved_undetermined_flag[]"); // ignored |
---|
1869 | } |
---|
1870 | #endif //SVC_EXTENSION |
---|
1871 | |
---|
1872 | READ_UVLC ( uiCode, "slice_type" ); rpcSlice->setSliceType((SliceType)uiCode); |
---|
1873 | if( pps->getOutputFlagPresentFlag() ) |
---|
1874 | { |
---|
1875 | READ_FLAG( uiCode, "pic_output_flag" ); rpcSlice->setPicOutputFlag( uiCode ? true : false ); |
---|
1876 | } |
---|
1877 | else |
---|
1878 | { |
---|
1879 | rpcSlice->setPicOutputFlag( true ); |
---|
1880 | } |
---|
1881 | // in the first version chroma_format_idc is equal to one, thus colour_plane_id will not be present |
---|
1882 | assert (sps->getChromaFormatIdc() == 1 ); |
---|
1883 | // if( separate_colour_plane_flag == 1 ) |
---|
1884 | // colour_plane_id u(2) |
---|
1885 | |
---|
1886 | if( rpcSlice->getIdrPicFlag() ) |
---|
1887 | { |
---|
1888 | rpcSlice->setPOC(0); |
---|
1889 | TComReferencePictureSet* rps = rpcSlice->getLocalRPS(); |
---|
1890 | rps->setNumberOfNegativePictures(0); |
---|
1891 | rps->setNumberOfPositivePictures(0); |
---|
1892 | rps->setNumberOfLongtermPictures(0); |
---|
1893 | rps->setNumberOfPictures(0); |
---|
1894 | rpcSlice->setRPS(rps); |
---|
1895 | } |
---|
1896 | #if N0065_LAYER_POC_ALIGNMENT |
---|
1897 | #if SHM_FIX7 |
---|
1898 | Int iPOClsb = 0; |
---|
1899 | #endif |
---|
1900 | #if O0062_POC_LSB_NOT_PRESENT_FLAG |
---|
1901 | if( ( rpcSlice->getLayerId() > 0 && !rpcSlice->getVPS()->getPocLsbNotPresentFlag( rpcSlice->getVPS()->getLayerIdInVps(rpcSlice->getLayerId())) ) || !rpcSlice->getIdrPicFlag()) |
---|
1902 | #else |
---|
1903 | if( rpcSlice->getLayerId() > 0 || !rpcSlice->getIdrPicFlag() ) |
---|
1904 | #endif |
---|
1905 | #else |
---|
1906 | else |
---|
1907 | #endif |
---|
1908 | { |
---|
1909 | READ_CODE(sps->getBitsForPOC(), uiCode, "pic_order_cnt_lsb"); |
---|
1910 | #if SHM_FIX7 |
---|
1911 | iPOClsb = uiCode; |
---|
1912 | #else |
---|
1913 | Int iPOClsb = uiCode; |
---|
1914 | #endif |
---|
1915 | Int iPrevPOC = rpcSlice->getPrevTid0POC(); |
---|
1916 | Int iMaxPOClsb = 1<< sps->getBitsForPOC(); |
---|
1917 | Int iPrevPOClsb = iPrevPOC & (iMaxPOClsb - 1); |
---|
1918 | Int iPrevPOCmsb = iPrevPOC-iPrevPOClsb; |
---|
1919 | Int iPOCmsb; |
---|
1920 | if( ( iPOClsb < iPrevPOClsb ) && ( ( iPrevPOClsb - iPOClsb ) >= ( iMaxPOClsb / 2 ) ) ) |
---|
1921 | { |
---|
1922 | iPOCmsb = iPrevPOCmsb + iMaxPOClsb; |
---|
1923 | } |
---|
1924 | else if( (iPOClsb > iPrevPOClsb ) && ( (iPOClsb - iPrevPOClsb ) > ( iMaxPOClsb / 2 ) ) ) |
---|
1925 | { |
---|
1926 | iPOCmsb = iPrevPOCmsb - iMaxPOClsb; |
---|
1927 | } |
---|
1928 | else |
---|
1929 | { |
---|
1930 | iPOCmsb = iPrevPOCmsb; |
---|
1931 | } |
---|
1932 | if ( rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP |
---|
1933 | || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL |
---|
1934 | || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP ) |
---|
1935 | { |
---|
1936 | // For BLA picture types, POCmsb is set to 0. |
---|
1937 | iPOCmsb = 0; |
---|
1938 | } |
---|
1939 | rpcSlice->setPOC (iPOCmsb+iPOClsb); |
---|
1940 | |
---|
1941 | #if N0065_LAYER_POC_ALIGNMENT |
---|
1942 | #if SHM_FIX7 |
---|
1943 | } |
---|
1944 | #endif |
---|
1945 | if( !rpcSlice->getIdrPicFlag() ) |
---|
1946 | { |
---|
1947 | #endif |
---|
1948 | TComReferencePictureSet* rps; |
---|
1949 | rps = rpcSlice->getLocalRPS(); |
---|
1950 | rpcSlice->setRPS(rps); |
---|
1951 | READ_FLAG( uiCode, "short_term_ref_pic_set_sps_flag" ); |
---|
1952 | if(uiCode == 0) // use short-term reference picture set explicitly signalled in slice header |
---|
1953 | { |
---|
1954 | parseShortTermRefPicSet(sps,rps, sps->getRPSList()->getNumberOfReferencePictureSets()); |
---|
1955 | } |
---|
1956 | else // use reference to short-term reference picture set in PPS |
---|
1957 | { |
---|
1958 | Int numBits = 0; |
---|
1959 | while ((1 << numBits) < rpcSlice->getSPS()->getRPSList()->getNumberOfReferencePictureSets()) |
---|
1960 | { |
---|
1961 | numBits++; |
---|
1962 | } |
---|
1963 | if (numBits > 0) |
---|
1964 | { |
---|
1965 | READ_CODE( numBits, uiCode, "short_term_ref_pic_set_idx"); |
---|
1966 | } |
---|
1967 | else |
---|
1968 | { |
---|
1969 | uiCode = 0; |
---|
1970 | } |
---|
1971 | *rps = *(sps->getRPSList()->getReferencePictureSet(uiCode)); |
---|
1972 | } |
---|
1973 | if(sps->getLongTermRefsPresent()) |
---|
1974 | { |
---|
1975 | Int offset = rps->getNumberOfNegativePictures()+rps->getNumberOfPositivePictures(); |
---|
1976 | UInt numOfLtrp = 0; |
---|
1977 | UInt numLtrpInSPS = 0; |
---|
1978 | if (rpcSlice->getSPS()->getNumLongTermRefPicSPS() > 0) |
---|
1979 | { |
---|
1980 | READ_UVLC( uiCode, "num_long_term_sps"); |
---|
1981 | numLtrpInSPS = uiCode; |
---|
1982 | numOfLtrp += numLtrpInSPS; |
---|
1983 | rps->setNumberOfLongtermPictures(numOfLtrp); |
---|
1984 | } |
---|
1985 | Int bitsForLtrpInSPS = 0; |
---|
1986 | while (rpcSlice->getSPS()->getNumLongTermRefPicSPS() > (1 << bitsForLtrpInSPS)) |
---|
1987 | { |
---|
1988 | bitsForLtrpInSPS++; |
---|
1989 | } |
---|
1990 | READ_UVLC( uiCode, "num_long_term_pics"); rps->setNumberOfLongtermPictures(uiCode); |
---|
1991 | numOfLtrp += uiCode; |
---|
1992 | rps->setNumberOfLongtermPictures(numOfLtrp); |
---|
1993 | Int maxPicOrderCntLSB = 1 << rpcSlice->getSPS()->getBitsForPOC(); |
---|
1994 | Int prevDeltaMSB = 0, deltaPocMSBCycleLT = 0;; |
---|
1995 | for(Int j=offset+rps->getNumberOfLongtermPictures()-1, k = 0; k < numOfLtrp; j--, k++) |
---|
1996 | { |
---|
1997 | Int pocLsbLt; |
---|
1998 | if (k < numLtrpInSPS) |
---|
1999 | { |
---|
2000 | uiCode = 0; |
---|
2001 | if (bitsForLtrpInSPS > 0) |
---|
2002 | { |
---|
2003 | READ_CODE(bitsForLtrpInSPS, uiCode, "lt_idx_sps[i]"); |
---|
2004 | } |
---|
2005 | Int usedByCurrFromSPS=rpcSlice->getSPS()->getUsedByCurrPicLtSPSFlag(uiCode); |
---|
2006 | |
---|
2007 | pocLsbLt = rpcSlice->getSPS()->getLtRefPicPocLsbSps(uiCode); |
---|
2008 | rps->setUsed(j,usedByCurrFromSPS); |
---|
2009 | } |
---|
2010 | else |
---|
2011 | { |
---|
2012 | READ_CODE(rpcSlice->getSPS()->getBitsForPOC(), uiCode, "poc_lsb_lt"); pocLsbLt= uiCode; |
---|
2013 | READ_FLAG( uiCode, "used_by_curr_pic_lt_flag"); rps->setUsed(j,uiCode); |
---|
2014 | } |
---|
2015 | READ_FLAG(uiCode,"delta_poc_msb_present_flag"); |
---|
2016 | Bool mSBPresentFlag = uiCode ? true : false; |
---|
2017 | if(mSBPresentFlag) |
---|
2018 | { |
---|
2019 | READ_UVLC( uiCode, "delta_poc_msb_cycle_lt[i]" ); |
---|
2020 | Bool deltaFlag = false; |
---|
2021 | // First LTRP || First LTRP from SH |
---|
2022 | if( (j == offset+rps->getNumberOfLongtermPictures()-1) || (j == offset+(numOfLtrp-numLtrpInSPS)-1) ) |
---|
2023 | { |
---|
2024 | deltaFlag = true; |
---|
2025 | } |
---|
2026 | if(deltaFlag) |
---|
2027 | { |
---|
2028 | deltaPocMSBCycleLT = uiCode; |
---|
2029 | } |
---|
2030 | else |
---|
2031 | { |
---|
2032 | deltaPocMSBCycleLT = uiCode + prevDeltaMSB; |
---|
2033 | } |
---|
2034 | |
---|
2035 | Int pocLTCurr = rpcSlice->getPOC() - deltaPocMSBCycleLT * maxPicOrderCntLSB |
---|
2036 | - iPOClsb + pocLsbLt; |
---|
2037 | rps->setPOC (j, pocLTCurr); |
---|
2038 | rps->setDeltaPOC(j, - rpcSlice->getPOC() + pocLTCurr); |
---|
2039 | rps->setCheckLTMSBPresent(j,true); |
---|
2040 | } |
---|
2041 | else |
---|
2042 | { |
---|
2043 | rps->setPOC (j, pocLsbLt); |
---|
2044 | rps->setDeltaPOC(j, - rpcSlice->getPOC() + pocLsbLt); |
---|
2045 | rps->setCheckLTMSBPresent(j,false); |
---|
2046 | |
---|
2047 | // reset deltaPocMSBCycleLT for first LTRP from slice header if MSB not present |
---|
2048 | if( j == offset+(numOfLtrp-numLtrpInSPS)-1 ) |
---|
2049 | { |
---|
2050 | deltaPocMSBCycleLT = 0; |
---|
2051 | } |
---|
2052 | } |
---|
2053 | prevDeltaMSB = deltaPocMSBCycleLT; |
---|
2054 | } |
---|
2055 | offset += rps->getNumberOfLongtermPictures(); |
---|
2056 | rps->setNumberOfPictures(offset); |
---|
2057 | } |
---|
2058 | if ( rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP |
---|
2059 | || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL |
---|
2060 | || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP ) |
---|
2061 | { |
---|
2062 | // In the case of BLA picture types, rps data is read from slice header but ignored |
---|
2063 | rps = rpcSlice->getLocalRPS(); |
---|
2064 | rps->setNumberOfNegativePictures(0); |
---|
2065 | rps->setNumberOfPositivePictures(0); |
---|
2066 | rps->setNumberOfLongtermPictures(0); |
---|
2067 | rps->setNumberOfPictures(0); |
---|
2068 | rpcSlice->setRPS(rps); |
---|
2069 | } |
---|
2070 | if (rpcSlice->getSPS()->getTMVPFlagsPresent()) |
---|
2071 | { |
---|
2072 | READ_FLAG( uiCode, "slice_temporal_mvp_enable_flag" ); |
---|
2073 | rpcSlice->setEnableTMVPFlag( uiCode == 1 ? true : false ); |
---|
2074 | } |
---|
2075 | else |
---|
2076 | { |
---|
2077 | rpcSlice->setEnableTMVPFlag(false); |
---|
2078 | } |
---|
2079 | #if N0065_LAYER_POC_ALIGNMENT && !SHM_FIX7 |
---|
2080 | } |
---|
2081 | #endif |
---|
2082 | } |
---|
2083 | |
---|
2084 | #if SVC_EXTENSION |
---|
2085 | #if JCTVC_M0458_INTERLAYER_RPS_SIG |
---|
2086 | rpcSlice->setActiveNumILRRefIdx(0); |
---|
2087 | #if ILP_SSH_SIG |
---|
2088 | #if ILP_SSH_SIG_FIX |
---|
2089 | if((sps->getLayerId() > 0) && !(rpcSlice->getVPS()->getIlpSshSignalingEnabledFlag()) && (rpcSlice->getNumILRRefIdx() > 0) ) |
---|
2090 | #else |
---|
2091 | if((sps->getLayerId() > 0) && rpcSlice->getVPS()->getIlpSshSignalingEnabledFlag() && (rpcSlice->getNumILRRefIdx() > 0) ) |
---|
2092 | #endif |
---|
2093 | #else |
---|
2094 | if((sps->getLayerId() > 0) && (rpcSlice->getNumILRRefIdx() > 0) ) |
---|
2095 | #endif |
---|
2096 | { |
---|
2097 | READ_FLAG(uiCode,"inter_layer_pred_enabled_flag"); |
---|
2098 | rpcSlice->setInterLayerPredEnabledFlag(uiCode); |
---|
2099 | if( rpcSlice->getInterLayerPredEnabledFlag()) |
---|
2100 | { |
---|
2101 | if(rpcSlice->getNumILRRefIdx() > 1) |
---|
2102 | { |
---|
2103 | Int numBits = 1; |
---|
2104 | while ((1 << numBits) < rpcSlice->getNumILRRefIdx()) |
---|
2105 | { |
---|
2106 | numBits++; |
---|
2107 | } |
---|
2108 | if( !rpcSlice->getVPS()->getMaxOneActiveRefLayerFlag()) |
---|
2109 | { |
---|
2110 | READ_CODE( numBits, uiCode,"num_inter_layer_ref_pics_minus1" ); |
---|
2111 | rpcSlice->setActiveNumILRRefIdx(uiCode + 1); |
---|
2112 | } |
---|
2113 | else |
---|
2114 | { |
---|
2115 | rpcSlice->setActiveNumILRRefIdx(1); |
---|
2116 | } |
---|
2117 | #if ILP_NUM_REF_CHK |
---|
2118 | if( rpcSlice->getActiveNumILRRefIdx() == rpcSlice->getNumILRRefIdx() ) |
---|
2119 | { |
---|
2120 | for( Int i = 0; i < rpcSlice->getActiveNumILRRefIdx(); i++ ) |
---|
2121 | { |
---|
2122 | rpcSlice->setInterLayerPredLayerIdc(i,i); |
---|
2123 | } |
---|
2124 | } |
---|
2125 | else |
---|
2126 | { |
---|
2127 | #endif |
---|
2128 | for(Int i = 0; i < rpcSlice->getActiveNumILRRefIdx(); i++ ) |
---|
2129 | { |
---|
2130 | READ_CODE( numBits,uiCode,"inter_layer_pred_layer_idc[i]" ); |
---|
2131 | rpcSlice->setInterLayerPredLayerIdc(uiCode,i); |
---|
2132 | } |
---|
2133 | #if ILP_NUM_REF_CHK |
---|
2134 | } |
---|
2135 | #endif |
---|
2136 | } |
---|
2137 | else |
---|
2138 | { |
---|
2139 | #if O0225_TID_BASED_IL_RPS_DERIV && TSLAYERS_IL_RPS |
---|
2140 | if( (rpcSlice->getVPS()->getMaxTidIlRefPicsPlus1(0,rpcSlice->getLayerId()) > rpcSlice->getTLayer()) && |
---|
2141 | (rpcSlice->getVPS()->getMaxTSLayersMinus1(0) >= rpcSlice->getTLayer()) ) |
---|
2142 | { |
---|
2143 | #endif |
---|
2144 | rpcSlice->setActiveNumILRRefIdx(1); |
---|
2145 | rpcSlice->setInterLayerPredLayerIdc(0,0); |
---|
2146 | #if O0225_TID_BASED_IL_RPS_DERIV && TSLAYERS_IL_RPS |
---|
2147 | } |
---|
2148 | #endif |
---|
2149 | } |
---|
2150 | } |
---|
2151 | } |
---|
2152 | #if ILP_SSH_SIG |
---|
2153 | #if ILP_SSH_SIG_FIX |
---|
2154 | else if( rpcSlice->getVPS()->getIlpSshSignalingEnabledFlag() == true && (rpcSlice->getLayerId() > 0 )) |
---|
2155 | #else |
---|
2156 | else if( rpcSlice->getVPS()->getIlpSshSignalingEnabledFlag() == false ) |
---|
2157 | #endif |
---|
2158 | { |
---|
2159 | rpcSlice->setInterLayerPredEnabledFlag(true); |
---|
2160 | |
---|
2161 | #if O0225_TID_BASED_IL_RPS_DERIV && TSLAYERS_IL_RPS |
---|
2162 | Int numRefLayerPics = 0; |
---|
2163 | Int i = 0; |
---|
2164 | Int refLayerPicIdc [MAX_VPS_LAYER_ID_PLUS1]; |
---|
2165 | for(i = 0, numRefLayerPics = 0; i < rpcSlice->getNumILRRefIdx(); i++ ) |
---|
2166 | { |
---|
2167 | if(rpcSlice->getVPS()->getMaxTidIlRefPicsPlus1(rpcSlice->getVPS()->getLayerIdInVps(i),rpcSlice->getLayerId()) > rpcSlice->getTLayer() && |
---|
2168 | (rpcSlice->getVPS()->getMaxTSLayersMinus1(rpcSlice->getVPS()->getLayerIdInVps(i)) >= rpcSlice->getTLayer()) ) |
---|
2169 | { |
---|
2170 | refLayerPicIdc[ numRefLayerPics++ ] = i; |
---|
2171 | } |
---|
2172 | } |
---|
2173 | rpcSlice->setActiveNumILRRefIdx(numRefLayerPics); |
---|
2174 | for( i = 0; i < rpcSlice->getActiveNumILRRefIdx(); i++ ) |
---|
2175 | { |
---|
2176 | rpcSlice->setInterLayerPredLayerIdc(refLayerPicIdc[i],i); |
---|
2177 | } |
---|
2178 | #else |
---|
2179 | rpcSlice->setActiveNumILRRefIdx(rpcSlice->getNumILRRefIdx()); |
---|
2180 | for( Int i = 0; i < rpcSlice->getActiveNumILRRefIdx(); i++ ) |
---|
2181 | { |
---|
2182 | rpcSlice->setInterLayerPredLayerIdc(i,i); |
---|
2183 | } |
---|
2184 | #endif |
---|
2185 | } |
---|
2186 | #endif |
---|
2187 | #if M0457_IL_SAMPLE_PRED_ONLY_FLAG |
---|
2188 | rpcSlice->setInterLayerSamplePredOnlyFlag( false ); |
---|
2189 | if( rpcSlice->getNumSamplePredRefLayers() > 0 && rpcSlice->getActiveNumILRRefIdx() > 0 ) |
---|
2190 | { |
---|
2191 | READ_FLAG( uiCode, "inter_layer_sample_pred_only_flag" ); |
---|
2192 | rpcSlice->setInterLayerSamplePredOnlyFlag( uiCode > 0 ); |
---|
2193 | } |
---|
2194 | #endif |
---|
2195 | #else |
---|
2196 | if( rpcSlice->getLayerId() > 0 ) |
---|
2197 | { |
---|
2198 | rpcSlice->setNumILRRefIdx( rpcSlice->getVPS()->getNumDirectRefLayers( rpcSlice->getLayerId() ) ); |
---|
2199 | } |
---|
2200 | #endif |
---|
2201 | #endif |
---|
2202 | |
---|
2203 | if(sps->getUseSAO()) |
---|
2204 | { |
---|
2205 | READ_FLAG(uiCode, "slice_sao_luma_flag"); rpcSlice->setSaoEnabledFlag((Bool)uiCode); |
---|
2206 | #if AUXILIARY_PICTURES |
---|
2207 | ChromaFormat format; |
---|
2208 | #if REPN_FORMAT_IN_VPS |
---|
2209 | #if O0096_REP_FORMAT_INDEX |
---|
2210 | if( sps->getLayerId() == 0 ) |
---|
2211 | { |
---|
2212 | format = sps->getChromaFormatIdc(); |
---|
2213 | } |
---|
2214 | else |
---|
2215 | { |
---|
2216 | format = rpcSlice->getVPS()->getVpsRepFormat( sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : rpcSlice->getVPS()->getVpsRepFormatIdx(sps->getLayerId()) )->getChromaFormatVpsIdc(); |
---|
2217 | } |
---|
2218 | #else |
---|
2219 | if( ( sps->getLayerId() == 0 ) || sps->getUpdateRepFormatFlag() ) |
---|
2220 | { |
---|
2221 | format = sps->getChromaFormatIdc(); |
---|
2222 | } |
---|
2223 | else |
---|
2224 | { |
---|
2225 | format = rpcSlice->getVPS()->getVpsRepFormat( rpcSlice->getVPS()->getVpsRepFormatIdx(sps->getLayerId()) )->getChromaFormatVpsIdc(); |
---|
2226 | } |
---|
2227 | #endif |
---|
2228 | #else |
---|
2229 | format = sps->getChromaFormatIdc(); |
---|
2230 | #endif |
---|
2231 | if (format != CHROMA_400) |
---|
2232 | { |
---|
2233 | #endif |
---|
2234 | READ_FLAG(uiCode, "slice_sao_chroma_flag"); rpcSlice->setSaoEnabledFlagChroma((Bool)uiCode); |
---|
2235 | #if AUXILIARY_PICTURES |
---|
2236 | } |
---|
2237 | else |
---|
2238 | { |
---|
2239 | rpcSlice->setSaoEnabledFlagChroma(false); |
---|
2240 | } |
---|
2241 | #endif |
---|
2242 | } |
---|
2243 | |
---|
2244 | if (rpcSlice->getIdrPicFlag()) |
---|
2245 | { |
---|
2246 | rpcSlice->setEnableTMVPFlag(false); |
---|
2247 | } |
---|
2248 | if (!rpcSlice->isIntra()) |
---|
2249 | { |
---|
2250 | |
---|
2251 | READ_FLAG( uiCode, "num_ref_idx_active_override_flag"); |
---|
2252 | if (uiCode) |
---|
2253 | { |
---|
2254 | READ_UVLC (uiCode, "num_ref_idx_l0_active_minus1" ); rpcSlice->setNumRefIdx( REF_PIC_LIST_0, uiCode + 1 ); |
---|
2255 | if (rpcSlice->isInterB()) |
---|
2256 | { |
---|
2257 | READ_UVLC (uiCode, "num_ref_idx_l1_active_minus1" ); rpcSlice->setNumRefIdx( REF_PIC_LIST_1, uiCode + 1 ); |
---|
2258 | } |
---|
2259 | else |
---|
2260 | { |
---|
2261 | rpcSlice->setNumRefIdx(REF_PIC_LIST_1, 0); |
---|
2262 | } |
---|
2263 | } |
---|
2264 | else |
---|
2265 | { |
---|
2266 | rpcSlice->setNumRefIdx(REF_PIC_LIST_0, rpcSlice->getPPS()->getNumRefIdxL0DefaultActive()); |
---|
2267 | if (rpcSlice->isInterB()) |
---|
2268 | { |
---|
2269 | rpcSlice->setNumRefIdx(REF_PIC_LIST_1, rpcSlice->getPPS()->getNumRefIdxL1DefaultActive()); |
---|
2270 | } |
---|
2271 | else |
---|
2272 | { |
---|
2273 | rpcSlice->setNumRefIdx(REF_PIC_LIST_1,0); |
---|
2274 | } |
---|
2275 | } |
---|
2276 | } |
---|
2277 | // } |
---|
2278 | TComRefPicListModification* refPicListModification = rpcSlice->getRefPicListModification(); |
---|
2279 | if(!rpcSlice->isIntra()) |
---|
2280 | { |
---|
2281 | if( !rpcSlice->getPPS()->getListsModificationPresentFlag() || rpcSlice->getNumRpsCurrTempList() <= 1 ) |
---|
2282 | { |
---|
2283 | refPicListModification->setRefPicListModificationFlagL0( 0 ); |
---|
2284 | } |
---|
2285 | else |
---|
2286 | { |
---|
2287 | READ_FLAG( uiCode, "ref_pic_list_modification_flag_l0" ); refPicListModification->setRefPicListModificationFlagL0( uiCode ? 1 : 0 ); |
---|
2288 | } |
---|
2289 | |
---|
2290 | if(refPicListModification->getRefPicListModificationFlagL0()) |
---|
2291 | { |
---|
2292 | uiCode = 0; |
---|
2293 | Int i = 0; |
---|
2294 | Int numRpsCurrTempList0 = rpcSlice->getNumRpsCurrTempList(); |
---|
2295 | if ( numRpsCurrTempList0 > 1 ) |
---|
2296 | { |
---|
2297 | Int length = 1; |
---|
2298 | numRpsCurrTempList0 --; |
---|
2299 | while ( numRpsCurrTempList0 >>= 1) |
---|
2300 | { |
---|
2301 | length ++; |
---|
2302 | } |
---|
2303 | for (i = 0; i < rpcSlice->getNumRefIdx(REF_PIC_LIST_0); i ++) |
---|
2304 | { |
---|
2305 | READ_CODE( length, uiCode, "list_entry_l0" ); |
---|
2306 | refPicListModification->setRefPicSetIdxL0(i, uiCode ); |
---|
2307 | } |
---|
2308 | } |
---|
2309 | else |
---|
2310 | { |
---|
2311 | for (i = 0; i < rpcSlice->getNumRefIdx(REF_PIC_LIST_0); i ++) |
---|
2312 | { |
---|
2313 | refPicListModification->setRefPicSetIdxL0(i, 0 ); |
---|
2314 | } |
---|
2315 | } |
---|
2316 | } |
---|
2317 | } |
---|
2318 | else |
---|
2319 | { |
---|
2320 | refPicListModification->setRefPicListModificationFlagL0(0); |
---|
2321 | } |
---|
2322 | if(rpcSlice->isInterB()) |
---|
2323 | { |
---|
2324 | if( !rpcSlice->getPPS()->getListsModificationPresentFlag() || rpcSlice->getNumRpsCurrTempList() <= 1 ) |
---|
2325 | { |
---|
2326 | refPicListModification->setRefPicListModificationFlagL1( 0 ); |
---|
2327 | } |
---|
2328 | else |
---|
2329 | { |
---|
2330 | READ_FLAG( uiCode, "ref_pic_list_modification_flag_l1" ); refPicListModification->setRefPicListModificationFlagL1( uiCode ? 1 : 0 ); |
---|
2331 | } |
---|
2332 | if(refPicListModification->getRefPicListModificationFlagL1()) |
---|
2333 | { |
---|
2334 | uiCode = 0; |
---|
2335 | Int i = 0; |
---|
2336 | Int numRpsCurrTempList1 = rpcSlice->getNumRpsCurrTempList(); |
---|
2337 | if ( numRpsCurrTempList1 > 1 ) |
---|
2338 | { |
---|
2339 | Int length = 1; |
---|
2340 | numRpsCurrTempList1 --; |
---|
2341 | while ( numRpsCurrTempList1 >>= 1) |
---|
2342 | { |
---|
2343 | length ++; |
---|
2344 | } |
---|
2345 | for (i = 0; i < rpcSlice->getNumRefIdx(REF_PIC_LIST_1); i ++) |
---|
2346 | { |
---|
2347 | READ_CODE( length, uiCode, "list_entry_l1" ); |
---|
2348 | refPicListModification->setRefPicSetIdxL1(i, uiCode ); |
---|
2349 | } |
---|
2350 | } |
---|
2351 | else |
---|
2352 | { |
---|
2353 | for (i = 0; i < rpcSlice->getNumRefIdx(REF_PIC_LIST_1); i ++) |
---|
2354 | { |
---|
2355 | refPicListModification->setRefPicSetIdxL1(i, 0 ); |
---|
2356 | } |
---|
2357 | } |
---|
2358 | } |
---|
2359 | } |
---|
2360 | else |
---|
2361 | { |
---|
2362 | refPicListModification->setRefPicListModificationFlagL1(0); |
---|
2363 | } |
---|
2364 | if (rpcSlice->isInterB()) |
---|
2365 | { |
---|
2366 | READ_FLAG( uiCode, "mvd_l1_zero_flag" ); rpcSlice->setMvdL1ZeroFlag( (uiCode ? true : false) ); |
---|
2367 | } |
---|
2368 | |
---|
2369 | rpcSlice->setCabacInitFlag( false ); // default |
---|
2370 | if(pps->getCabacInitPresentFlag() && !rpcSlice->isIntra()) |
---|
2371 | { |
---|
2372 | READ_FLAG(uiCode, "cabac_init_flag"); |
---|
2373 | rpcSlice->setCabacInitFlag( uiCode ? true : false ); |
---|
2374 | } |
---|
2375 | |
---|
2376 | if ( rpcSlice->getEnableTMVPFlag() ) |
---|
2377 | { |
---|
2378 | #if M0457_COL_PICTURE_SIGNALING |
---|
2379 | #if REMOVE_COL_PICTURE_SIGNALING |
---|
2380 | rpcSlice->setMFMEnabledFlag( ( rpcSlice->getNumMotionPredRefLayers() > 0 && rpcSlice->getActiveNumILRRefIdx() ) ? true : false ); |
---|
2381 | #else |
---|
2382 | rpcSlice->setMFMEnabledFlag( false ); |
---|
2383 | rpcSlice->setColRefLayerIdx( 0 ); |
---|
2384 | rpcSlice->setAltColIndicationFlag( false ); |
---|
2385 | if ( sps->getLayerId() > 0 && rpcSlice->getActiveNumILRRefIdx() > 0 && rpcSlice->getNumMotionPredRefLayers() > 0 ) |
---|
2386 | { |
---|
2387 | READ_FLAG( uiCode, "alt_collocated_indication_flag" ); |
---|
2388 | rpcSlice->setAltColIndicationFlag( uiCode == 1 ? true : false ); |
---|
2389 | rpcSlice->setMFMEnabledFlag( uiCode == 1 ? true : false ); |
---|
2390 | if ( rpcSlice->getNumMotionPredRefLayers() > 1 ) |
---|
2391 | { |
---|
2392 | READ_UVLC( uiCode, "collocated_ref_layer_idx" ); |
---|
2393 | rpcSlice->setColRefLayerIdx( uiCode ); |
---|
2394 | } |
---|
2395 | } |
---|
2396 | else |
---|
2397 | { |
---|
2398 | #endif //REMOVE_COL_PICTURE_SIGNALING |
---|
2399 | #endif |
---|
2400 | if ( rpcSlice->getSliceType() == B_SLICE ) |
---|
2401 | { |
---|
2402 | READ_FLAG( uiCode, "collocated_from_l0_flag" ); |
---|
2403 | rpcSlice->setColFromL0Flag(uiCode); |
---|
2404 | } |
---|
2405 | else |
---|
2406 | { |
---|
2407 | rpcSlice->setColFromL0Flag( 1 ); |
---|
2408 | } |
---|
2409 | |
---|
2410 | if ( rpcSlice->getSliceType() != I_SLICE && |
---|
2411 | ((rpcSlice->getColFromL0Flag() == 1 && rpcSlice->getNumRefIdx(REF_PIC_LIST_0) > 1)|| |
---|
2412 | (rpcSlice->getColFromL0Flag() == 0 && rpcSlice->getNumRefIdx(REF_PIC_LIST_1) > 1))) |
---|
2413 | { |
---|
2414 | READ_UVLC( uiCode, "collocated_ref_idx" ); |
---|
2415 | rpcSlice->setColRefIdx(uiCode); |
---|
2416 | } |
---|
2417 | else |
---|
2418 | { |
---|
2419 | rpcSlice->setColRefIdx(0); |
---|
2420 | } |
---|
2421 | #if M0457_COL_PICTURE_SIGNALING && !REMOVE_COL_PICTURE_SIGNALING |
---|
2422 | } |
---|
2423 | #endif |
---|
2424 | } |
---|
2425 | if ( (pps->getUseWP() && rpcSlice->getSliceType()==P_SLICE) || (pps->getWPBiPred() && rpcSlice->getSliceType()==B_SLICE) ) |
---|
2426 | { |
---|
2427 | xParsePredWeightTable(rpcSlice); |
---|
2428 | rpcSlice->initWpScaling(); |
---|
2429 | } |
---|
2430 | if (!rpcSlice->isIntra()) |
---|
2431 | { |
---|
2432 | READ_UVLC( uiCode, "five_minus_max_num_merge_cand"); |
---|
2433 | rpcSlice->setMaxNumMergeCand(MRG_MAX_NUM_CANDS - uiCode); |
---|
2434 | } |
---|
2435 | |
---|
2436 | READ_SVLC( iCode, "slice_qp_delta" ); |
---|
2437 | rpcSlice->setSliceQp (26 + pps->getPicInitQPMinus26() + iCode); |
---|
2438 | |
---|
2439 | #if REPN_FORMAT_IN_VPS |
---|
2440 | #if O0194_DIFFERENT_BITDEPTH_EL_BL |
---|
2441 | g_bitDepthYLayer[rpcSlice->getLayerId()] = rpcSlice->getBitDepthY(); |
---|
2442 | g_bitDepthCLayer[rpcSlice->getLayerId()] = rpcSlice->getBitDepthC(); |
---|
2443 | #endif |
---|
2444 | assert( rpcSlice->getSliceQp() >= -rpcSlice->getQpBDOffsetY() ); |
---|
2445 | #else |
---|
2446 | assert( rpcSlice->getSliceQp() >= -sps->getQpBDOffsetY() ); |
---|
2447 | #endif |
---|
2448 | assert( rpcSlice->getSliceQp() <= 51 ); |
---|
2449 | |
---|
2450 | if (rpcSlice->getPPS()->getSliceChromaQpFlag()) |
---|
2451 | { |
---|
2452 | READ_SVLC( iCode, "slice_qp_delta_cb" ); |
---|
2453 | rpcSlice->setSliceQpDeltaCb( iCode ); |
---|
2454 | assert( rpcSlice->getSliceQpDeltaCb() >= -12 ); |
---|
2455 | assert( rpcSlice->getSliceQpDeltaCb() <= 12 ); |
---|
2456 | assert( (rpcSlice->getPPS()->getChromaCbQpOffset() + rpcSlice->getSliceQpDeltaCb()) >= -12 ); |
---|
2457 | assert( (rpcSlice->getPPS()->getChromaCbQpOffset() + rpcSlice->getSliceQpDeltaCb()) <= 12 ); |
---|
2458 | |
---|
2459 | READ_SVLC( iCode, "slice_qp_delta_cr" ); |
---|
2460 | rpcSlice->setSliceQpDeltaCr( iCode ); |
---|
2461 | assert( rpcSlice->getSliceQpDeltaCr() >= -12 ); |
---|
2462 | assert( rpcSlice->getSliceQpDeltaCr() <= 12 ); |
---|
2463 | assert( (rpcSlice->getPPS()->getChromaCrQpOffset() + rpcSlice->getSliceQpDeltaCr()) >= -12 ); |
---|
2464 | assert( (rpcSlice->getPPS()->getChromaCrQpOffset() + rpcSlice->getSliceQpDeltaCr()) <= 12 ); |
---|
2465 | } |
---|
2466 | |
---|
2467 | if (rpcSlice->getPPS()->getDeblockingFilterControlPresentFlag()) |
---|
2468 | { |
---|
2469 | if(rpcSlice->getPPS()->getDeblockingFilterOverrideEnabledFlag()) |
---|
2470 | { |
---|
2471 | READ_FLAG ( uiCode, "deblocking_filter_override_flag" ); rpcSlice->setDeblockingFilterOverrideFlag(uiCode ? true : false); |
---|
2472 | } |
---|
2473 | else |
---|
2474 | { |
---|
2475 | rpcSlice->setDeblockingFilterOverrideFlag(0); |
---|
2476 | } |
---|
2477 | if(rpcSlice->getDeblockingFilterOverrideFlag()) |
---|
2478 | { |
---|
2479 | READ_FLAG ( uiCode, "slice_disable_deblocking_filter_flag" ); rpcSlice->setDeblockingFilterDisable(uiCode ? 1 : 0); |
---|
2480 | if(!rpcSlice->getDeblockingFilterDisable()) |
---|
2481 | { |
---|
2482 | READ_SVLC( iCode, "slice_beta_offset_div2" ); rpcSlice->setDeblockingFilterBetaOffsetDiv2(iCode); |
---|
2483 | assert(rpcSlice->getDeblockingFilterBetaOffsetDiv2() >= -6 && |
---|
2484 | rpcSlice->getDeblockingFilterBetaOffsetDiv2() <= 6); |
---|
2485 | READ_SVLC( iCode, "slice_tc_offset_div2" ); rpcSlice->setDeblockingFilterTcOffsetDiv2(iCode); |
---|
2486 | assert(rpcSlice->getDeblockingFilterTcOffsetDiv2() >= -6 && |
---|
2487 | rpcSlice->getDeblockingFilterTcOffsetDiv2() <= 6); |
---|
2488 | } |
---|
2489 | } |
---|
2490 | else |
---|
2491 | { |
---|
2492 | rpcSlice->setDeblockingFilterDisable ( rpcSlice->getPPS()->getPicDisableDeblockingFilterFlag() ); |
---|
2493 | rpcSlice->setDeblockingFilterBetaOffsetDiv2( rpcSlice->getPPS()->getDeblockingFilterBetaOffsetDiv2() ); |
---|
2494 | rpcSlice->setDeblockingFilterTcOffsetDiv2 ( rpcSlice->getPPS()->getDeblockingFilterTcOffsetDiv2() ); |
---|
2495 | } |
---|
2496 | } |
---|
2497 | else |
---|
2498 | { |
---|
2499 | rpcSlice->setDeblockingFilterDisable ( false ); |
---|
2500 | rpcSlice->setDeblockingFilterBetaOffsetDiv2( 0 ); |
---|
2501 | rpcSlice->setDeblockingFilterTcOffsetDiv2 ( 0 ); |
---|
2502 | } |
---|
2503 | |
---|
2504 | Bool isSAOEnabled = (!rpcSlice->getSPS()->getUseSAO())?(false):(rpcSlice->getSaoEnabledFlag()||rpcSlice->getSaoEnabledFlagChroma()); |
---|
2505 | Bool isDBFEnabled = (!rpcSlice->getDeblockingFilterDisable()); |
---|
2506 | |
---|
2507 | if(rpcSlice->getPPS()->getLoopFilterAcrossSlicesEnabledFlag() && ( isSAOEnabled || isDBFEnabled )) |
---|
2508 | { |
---|
2509 | READ_FLAG( uiCode, "slice_loop_filter_across_slices_enabled_flag"); |
---|
2510 | } |
---|
2511 | else |
---|
2512 | { |
---|
2513 | uiCode = rpcSlice->getPPS()->getLoopFilterAcrossSlicesEnabledFlag()?1:0; |
---|
2514 | } |
---|
2515 | rpcSlice->setLFCrossSliceBoundaryFlag( (uiCode==1)?true:false); |
---|
2516 | |
---|
2517 | } |
---|
2518 | |
---|
2519 | UInt *entryPointOffset = NULL; |
---|
2520 | UInt numEntryPointOffsets, offsetLenMinus1; |
---|
2521 | if( pps->getTilesEnabledFlag() || pps->getEntropyCodingSyncEnabledFlag() ) |
---|
2522 | { |
---|
2523 | READ_UVLC(numEntryPointOffsets, "num_entry_point_offsets"); rpcSlice->setNumEntryPointOffsets ( numEntryPointOffsets ); |
---|
2524 | if (numEntryPointOffsets>0) |
---|
2525 | { |
---|
2526 | READ_UVLC(offsetLenMinus1, "offset_len_minus1"); |
---|
2527 | } |
---|
2528 | entryPointOffset = new UInt[numEntryPointOffsets]; |
---|
2529 | for (UInt idx=0; idx<numEntryPointOffsets; idx++) |
---|
2530 | { |
---|
2531 | READ_CODE(offsetLenMinus1+1, uiCode, "entry_point_offset_minus1"); |
---|
2532 | entryPointOffset[ idx ] = uiCode + 1; |
---|
2533 | } |
---|
2534 | } |
---|
2535 | else |
---|
2536 | { |
---|
2537 | rpcSlice->setNumEntryPointOffsets ( 0 ); |
---|
2538 | } |
---|
2539 | |
---|
2540 | if(pps->getSliceHeaderExtensionPresentFlag()) |
---|
2541 | { |
---|
2542 | READ_UVLC(uiCode,"slice_header_extension_length"); |
---|
2543 | for(Int i=0; i<uiCode; i++) |
---|
2544 | { |
---|
2545 | UInt ignore; |
---|
2546 | READ_CODE(8,ignore,"slice_header_extension_data_byte"); |
---|
2547 | } |
---|
2548 | } |
---|
2549 | m_pcBitstream->readByteAlignment(); |
---|
2550 | |
---|
2551 | if( pps->getTilesEnabledFlag() || pps->getEntropyCodingSyncEnabledFlag() ) |
---|
2552 | { |
---|
2553 | Int endOfSliceHeaderLocation = m_pcBitstream->getByteLocation(); |
---|
2554 | |
---|
2555 | // Adjust endOfSliceHeaderLocation to account for emulation prevention bytes in the slice segment header |
---|
2556 | for ( UInt curByteIdx = 0; curByteIdx<m_pcBitstream->numEmulationPreventionBytesRead(); curByteIdx++ ) |
---|
2557 | { |
---|
2558 | if ( m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) < endOfSliceHeaderLocation ) |
---|
2559 | { |
---|
2560 | endOfSliceHeaderLocation++; |
---|
2561 | } |
---|
2562 | } |
---|
2563 | |
---|
2564 | Int curEntryPointOffset = 0; |
---|
2565 | Int prevEntryPointOffset = 0; |
---|
2566 | for (UInt idx=0; idx<numEntryPointOffsets; idx++) |
---|
2567 | { |
---|
2568 | curEntryPointOffset += entryPointOffset[ idx ]; |
---|
2569 | |
---|
2570 | Int emulationPreventionByteCount = 0; |
---|
2571 | for ( UInt curByteIdx = 0; curByteIdx<m_pcBitstream->numEmulationPreventionBytesRead(); curByteIdx++ ) |
---|
2572 | { |
---|
2573 | if ( m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) >= ( prevEntryPointOffset + endOfSliceHeaderLocation ) && |
---|
2574 | m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) < ( curEntryPointOffset + endOfSliceHeaderLocation ) ) |
---|
2575 | { |
---|
2576 | emulationPreventionByteCount++; |
---|
2577 | } |
---|
2578 | } |
---|
2579 | |
---|
2580 | entryPointOffset[ idx ] -= emulationPreventionByteCount; |
---|
2581 | prevEntryPointOffset = curEntryPointOffset; |
---|
2582 | } |
---|
2583 | |
---|
2584 | if ( pps->getTilesEnabledFlag() ) |
---|
2585 | { |
---|
2586 | rpcSlice->setTileLocationCount( numEntryPointOffsets ); |
---|
2587 | |
---|
2588 | UInt prevPos = 0; |
---|
2589 | for (Int idx=0; idx<rpcSlice->getTileLocationCount(); idx++) |
---|
2590 | { |
---|
2591 | rpcSlice->setTileLocation( idx, prevPos + entryPointOffset [ idx ] ); |
---|
2592 | prevPos += entryPointOffset[ idx ]; |
---|
2593 | } |
---|
2594 | } |
---|
2595 | else if ( pps->getEntropyCodingSyncEnabledFlag() ) |
---|
2596 | { |
---|
2597 | Int numSubstreams = rpcSlice->getNumEntryPointOffsets()+1; |
---|
2598 | rpcSlice->allocSubstreamSizes(numSubstreams); |
---|
2599 | UInt *pSubstreamSizes = rpcSlice->getSubstreamSizes(); |
---|
2600 | for (Int idx=0; idx<numSubstreams-1; idx++) |
---|
2601 | { |
---|
2602 | if ( idx < numEntryPointOffsets ) |
---|
2603 | { |
---|
2604 | pSubstreamSizes[ idx ] = ( entryPointOffset[ idx ] << 3 ) ; |
---|
2605 | } |
---|
2606 | else |
---|
2607 | { |
---|
2608 | pSubstreamSizes[ idx ] = 0; |
---|
2609 | } |
---|
2610 | } |
---|
2611 | } |
---|
2612 | |
---|
2613 | if (entryPointOffset) |
---|
2614 | { |
---|
2615 | delete [] entryPointOffset; |
---|
2616 | } |
---|
2617 | } |
---|
2618 | |
---|
2619 | return; |
---|
2620 | } |
---|
2621 | |
---|
2622 | Void TDecCavlc::parsePTL( TComPTL *rpcPTL, Bool profilePresentFlag, Int maxNumSubLayersMinus1 ) |
---|
2623 | { |
---|
2624 | UInt uiCode; |
---|
2625 | if(profilePresentFlag) |
---|
2626 | { |
---|
2627 | parseProfileTier(rpcPTL->getGeneralPTL()); |
---|
2628 | } |
---|
2629 | READ_CODE( 8, uiCode, "general_level_idc" ); rpcPTL->getGeneralPTL()->setLevelIdc(uiCode); |
---|
2630 | |
---|
2631 | for (Int i = 0; i < maxNumSubLayersMinus1; i++) |
---|
2632 | { |
---|
2633 | if(profilePresentFlag) |
---|
2634 | { |
---|
2635 | READ_FLAG( uiCode, "sub_layer_profile_present_flag[i]" ); rpcPTL->setSubLayerProfilePresentFlag(i, uiCode); |
---|
2636 | } |
---|
2637 | READ_FLAG( uiCode, "sub_layer_level_present_flag[i]" ); rpcPTL->setSubLayerLevelPresentFlag (i, uiCode); |
---|
2638 | } |
---|
2639 | |
---|
2640 | if (maxNumSubLayersMinus1 > 0) |
---|
2641 | { |
---|
2642 | for (Int i = maxNumSubLayersMinus1; i < 8; i++) |
---|
2643 | { |
---|
2644 | READ_CODE(2, uiCode, "reserved_zero_2bits"); |
---|
2645 | assert(uiCode == 0); |
---|
2646 | } |
---|
2647 | } |
---|
2648 | |
---|
2649 | for(Int i = 0; i < maxNumSubLayersMinus1; i++) |
---|
2650 | { |
---|
2651 | if( profilePresentFlag && rpcPTL->getSubLayerProfilePresentFlag(i) ) |
---|
2652 | { |
---|
2653 | parseProfileTier(rpcPTL->getSubLayerPTL(i)); |
---|
2654 | } |
---|
2655 | if(rpcPTL->getSubLayerLevelPresentFlag(i)) |
---|
2656 | { |
---|
2657 | READ_CODE( 8, uiCode, "sub_layer_level_idc[i]" ); rpcPTL->getSubLayerPTL(i)->setLevelIdc(uiCode); |
---|
2658 | } |
---|
2659 | } |
---|
2660 | } |
---|
2661 | |
---|
2662 | Void TDecCavlc::parseProfileTier(ProfileTierLevel *ptl) |
---|
2663 | { |
---|
2664 | UInt uiCode; |
---|
2665 | READ_CODE(2 , uiCode, "XXX_profile_space[]"); ptl->setProfileSpace(uiCode); |
---|
2666 | READ_FLAG( uiCode, "XXX_tier_flag[]" ); ptl->setTierFlag (uiCode ? 1 : 0); |
---|
2667 | READ_CODE(5 , uiCode, "XXX_profile_idc[]" ); ptl->setProfileIdc (uiCode); |
---|
2668 | for(Int j = 0; j < 32; j++) |
---|
2669 | { |
---|
2670 | READ_FLAG( uiCode, "XXX_profile_compatibility_flag[][j]"); ptl->setProfileCompatibilityFlag(j, uiCode ? 1 : 0); |
---|
2671 | } |
---|
2672 | READ_FLAG(uiCode, "general_progressive_source_flag"); |
---|
2673 | ptl->setProgressiveSourceFlag(uiCode ? true : false); |
---|
2674 | |
---|
2675 | READ_FLAG(uiCode, "general_interlaced_source_flag"); |
---|
2676 | ptl->setInterlacedSourceFlag(uiCode ? true : false); |
---|
2677 | |
---|
2678 | READ_FLAG(uiCode, "general_non_packed_constraint_flag"); |
---|
2679 | ptl->setNonPackedConstraintFlag(uiCode ? true : false); |
---|
2680 | |
---|
2681 | READ_FLAG(uiCode, "general_frame_only_constraint_flag"); |
---|
2682 | ptl->setFrameOnlyConstraintFlag(uiCode ? true : false); |
---|
2683 | |
---|
2684 | READ_CODE(16, uiCode, "XXX_reserved_zero_44bits[0..15]"); |
---|
2685 | READ_CODE(16, uiCode, "XXX_reserved_zero_44bits[16..31]"); |
---|
2686 | READ_CODE(12, uiCode, "XXX_reserved_zero_44bits[32..43]"); |
---|
2687 | } |
---|
2688 | |
---|
2689 | Void TDecCavlc::parseTerminatingBit( UInt& ruiBit ) |
---|
2690 | { |
---|
2691 | ruiBit = false; |
---|
2692 | Int iBitsLeft = m_pcBitstream->getNumBitsLeft(); |
---|
2693 | if(iBitsLeft <= 8) |
---|
2694 | { |
---|
2695 | UInt uiPeekValue = m_pcBitstream->peekBits(iBitsLeft); |
---|
2696 | if (uiPeekValue == (1<<(iBitsLeft-1))) |
---|
2697 | { |
---|
2698 | ruiBit = true; |
---|
2699 | } |
---|
2700 | } |
---|
2701 | } |
---|
2702 | |
---|
2703 | Void TDecCavlc::parseSkipFlag( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
2704 | { |
---|
2705 | assert(0); |
---|
2706 | } |
---|
2707 | |
---|
2708 | Void TDecCavlc::parseCUTransquantBypassFlag( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
2709 | { |
---|
2710 | assert(0); |
---|
2711 | } |
---|
2712 | |
---|
2713 | Void TDecCavlc::parseMVPIdx( Int& /*riMVPIdx*/ ) |
---|
2714 | { |
---|
2715 | assert(0); |
---|
2716 | } |
---|
2717 | |
---|
2718 | Void TDecCavlc::parseSplitFlag ( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
2719 | { |
---|
2720 | assert(0); |
---|
2721 | } |
---|
2722 | |
---|
2723 | Void TDecCavlc::parsePartSize( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
2724 | { |
---|
2725 | assert(0); |
---|
2726 | } |
---|
2727 | |
---|
2728 | Void TDecCavlc::parsePredMode( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
2729 | { |
---|
2730 | assert(0); |
---|
2731 | } |
---|
2732 | |
---|
2733 | /** Parse I_PCM information. |
---|
2734 | * \param pcCU pointer to CU |
---|
2735 | * \param uiAbsPartIdx CU index |
---|
2736 | * \param uiDepth CU depth |
---|
2737 | * \returns Void |
---|
2738 | * |
---|
2739 | * If I_PCM flag indicates that the CU is I_PCM, parse its PCM alignment bits and codes. |
---|
2740 | */ |
---|
2741 | Void TDecCavlc::parseIPCMInfo( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
2742 | { |
---|
2743 | assert(0); |
---|
2744 | } |
---|
2745 | |
---|
2746 | Void TDecCavlc::parseIntraDirLumaAng ( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
2747 | { |
---|
2748 | assert(0); |
---|
2749 | } |
---|
2750 | |
---|
2751 | Void TDecCavlc::parseIntraDirChroma( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
2752 | { |
---|
2753 | assert(0); |
---|
2754 | } |
---|
2755 | |
---|
2756 | Void TDecCavlc::parseInterDir( TComDataCU* /*pcCU*/, UInt& /*ruiInterDir*/, UInt /*uiAbsPartIdx*/ ) |
---|
2757 | { |
---|
2758 | assert(0); |
---|
2759 | } |
---|
2760 | |
---|
2761 | Void TDecCavlc::parseRefFrmIdx( TComDataCU* /*pcCU*/, Int& /*riRefFrmIdx*/, RefPicList /*eRefList*/ ) |
---|
2762 | { |
---|
2763 | assert(0); |
---|
2764 | } |
---|
2765 | |
---|
2766 | Void TDecCavlc::parseMvd( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiPartIdx*/, UInt /*uiDepth*/, RefPicList /*eRefList*/ ) |
---|
2767 | { |
---|
2768 | assert(0); |
---|
2769 | } |
---|
2770 | |
---|
2771 | Void TDecCavlc::parseDeltaQP( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2772 | { |
---|
2773 | Int qp; |
---|
2774 | Int iDQp; |
---|
2775 | |
---|
2776 | xReadSvlc( iDQp ); |
---|
2777 | |
---|
2778 | #if REPN_FORMAT_IN_VPS |
---|
2779 | Int qpBdOffsetY = pcCU->getSlice()->getQpBDOffsetY(); |
---|
2780 | #else |
---|
2781 | Int qpBdOffsetY = pcCU->getSlice()->getSPS()->getQpBDOffsetY(); |
---|
2782 | #endif |
---|
2783 | qp = (((Int) pcCU->getRefQP( uiAbsPartIdx ) + iDQp + 52 + 2*qpBdOffsetY )%(52+ qpBdOffsetY)) - qpBdOffsetY; |
---|
2784 | |
---|
2785 | UInt uiAbsQpCUPartIdx = (uiAbsPartIdx>>((g_uiMaxCUDepth - pcCU->getSlice()->getPPS()->getMaxCuDQPDepth())<<1))<<((g_uiMaxCUDepth - pcCU->getSlice()->getPPS()->getMaxCuDQPDepth())<<1) ; |
---|
2786 | UInt uiQpCUDepth = min(uiDepth,pcCU->getSlice()->getPPS()->getMaxCuDQPDepth()) ; |
---|
2787 | |
---|
2788 | pcCU->setQPSubParts( qp, uiAbsQpCUPartIdx, uiQpCUDepth ); |
---|
2789 | } |
---|
2790 | |
---|
2791 | Void TDecCavlc::parseCoeffNxN( TComDataCU* /*pcCU*/, TCoeff* /*pcCoef*/, UInt /*uiAbsPartIdx*/, UInt /*uiWidth*/, UInt /*uiHeight*/, UInt /*uiDepth*/, TextType /*eTType*/ ) |
---|
2792 | { |
---|
2793 | assert(0); |
---|
2794 | } |
---|
2795 | |
---|
2796 | Void TDecCavlc::parseTransformSubdivFlag( UInt& /*ruiSubdivFlag*/, UInt /*uiLog2TransformBlockSize*/ ) |
---|
2797 | { |
---|
2798 | assert(0); |
---|
2799 | } |
---|
2800 | |
---|
2801 | Void TDecCavlc::parseQtCbf( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, TextType /*eType*/, UInt /*uiTrDepth*/, UInt /*uiDepth*/ ) |
---|
2802 | { |
---|
2803 | assert(0); |
---|
2804 | } |
---|
2805 | |
---|
2806 | Void TDecCavlc::parseQtRootCbf( UInt /*uiAbsPartIdx*/, UInt& /*uiQtRootCbf*/ ) |
---|
2807 | { |
---|
2808 | assert(0); |
---|
2809 | } |
---|
2810 | |
---|
2811 | Void TDecCavlc::parseTransformSkipFlags (TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*width*/, UInt /*height*/, UInt /*uiDepth*/, TextType /*eTType*/) |
---|
2812 | { |
---|
2813 | assert(0); |
---|
2814 | } |
---|
2815 | |
---|
2816 | Void TDecCavlc::parseMergeFlag ( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/, UInt /*uiPUIdx*/ ) |
---|
2817 | { |
---|
2818 | assert(0); |
---|
2819 | } |
---|
2820 | |
---|
2821 | Void TDecCavlc::parseMergeIndex ( TComDataCU* /*pcCU*/, UInt& /*ruiMergeIndex*/ ) |
---|
2822 | { |
---|
2823 | assert(0); |
---|
2824 | } |
---|
2825 | |
---|
2826 | // ==================================================================================================================== |
---|
2827 | // Protected member functions |
---|
2828 | // ==================================================================================================================== |
---|
2829 | |
---|
2830 | /** parse explicit wp tables |
---|
2831 | * \param TComSlice* pcSlice |
---|
2832 | * \returns Void |
---|
2833 | */ |
---|
2834 | Void TDecCavlc::xParsePredWeightTable( TComSlice* pcSlice ) |
---|
2835 | { |
---|
2836 | wpScalingParam *wp; |
---|
2837 | Bool bChroma = true; // color always present in HEVC ? |
---|
2838 | SliceType eSliceType = pcSlice->getSliceType(); |
---|
2839 | Int iNbRef = (eSliceType == B_SLICE ) ? (2) : (1); |
---|
2840 | #if SVC_EXTENSION |
---|
2841 | UInt uiLog2WeightDenomLuma = 0, uiLog2WeightDenomChroma = 0; |
---|
2842 | #else |
---|
2843 | UInt uiLog2WeightDenomLuma, uiLog2WeightDenomChroma; |
---|
2844 | #endif |
---|
2845 | UInt uiTotalSignalledWeightFlags = 0; |
---|
2846 | |
---|
2847 | Int iDeltaDenom; |
---|
2848 | #if AUXILIARY_PICTURES |
---|
2849 | if (pcSlice->getChromaFormatIdc() == CHROMA_400) |
---|
2850 | { |
---|
2851 | bChroma = false; |
---|
2852 | } |
---|
2853 | #endif |
---|
2854 | // decode delta_luma_log2_weight_denom : |
---|
2855 | READ_UVLC( uiLog2WeightDenomLuma, "luma_log2_weight_denom" ); // ue(v): luma_log2_weight_denom |
---|
2856 | assert( uiLog2WeightDenomLuma <= 7 ); |
---|
2857 | if( bChroma ) |
---|
2858 | { |
---|
2859 | READ_SVLC( iDeltaDenom, "delta_chroma_log2_weight_denom" ); // se(v): delta_chroma_log2_weight_denom |
---|
2860 | assert((iDeltaDenom + (Int)uiLog2WeightDenomLuma)>=0); |
---|
2861 | assert((iDeltaDenom + (Int)uiLog2WeightDenomLuma)<=7); |
---|
2862 | uiLog2WeightDenomChroma = (UInt)(iDeltaDenom + uiLog2WeightDenomLuma); |
---|
2863 | } |
---|
2864 | |
---|
2865 | for ( Int iNumRef=0 ; iNumRef<iNbRef ; iNumRef++ ) |
---|
2866 | { |
---|
2867 | RefPicList eRefPicList = ( iNumRef ? REF_PIC_LIST_1 : REF_PIC_LIST_0 ); |
---|
2868 | for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ ) |
---|
2869 | { |
---|
2870 | pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); |
---|
2871 | |
---|
2872 | wp[0].uiLog2WeightDenom = uiLog2WeightDenomLuma; |
---|
2873 | #if AUXILIARY_PICTURES |
---|
2874 | if (!bChroma) |
---|
2875 | { |
---|
2876 | wp[1].uiLog2WeightDenom = 0; |
---|
2877 | wp[2].uiLog2WeightDenom = 0; |
---|
2878 | } |
---|
2879 | else |
---|
2880 | { |
---|
2881 | #endif |
---|
2882 | wp[1].uiLog2WeightDenom = uiLog2WeightDenomChroma; |
---|
2883 | wp[2].uiLog2WeightDenom = uiLog2WeightDenomChroma; |
---|
2884 | #if AUXILIARY_PICTURES |
---|
2885 | } |
---|
2886 | #endif |
---|
2887 | |
---|
2888 | UInt uiCode; |
---|
2889 | READ_FLAG( uiCode, "luma_weight_lX_flag" ); // u(1): luma_weight_l0_flag |
---|
2890 | wp[0].bPresentFlag = ( uiCode == 1 ); |
---|
2891 | uiTotalSignalledWeightFlags += wp[0].bPresentFlag; |
---|
2892 | } |
---|
2893 | if ( bChroma ) |
---|
2894 | { |
---|
2895 | UInt uiCode; |
---|
2896 | for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ ) |
---|
2897 | { |
---|
2898 | pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); |
---|
2899 | READ_FLAG( uiCode, "chroma_weight_lX_flag" ); // u(1): chroma_weight_l0_flag |
---|
2900 | wp[1].bPresentFlag = ( uiCode == 1 ); |
---|
2901 | wp[2].bPresentFlag = ( uiCode == 1 ); |
---|
2902 | uiTotalSignalledWeightFlags += 2*wp[1].bPresentFlag; |
---|
2903 | } |
---|
2904 | } |
---|
2905 | for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ ) |
---|
2906 | { |
---|
2907 | pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); |
---|
2908 | if ( wp[0].bPresentFlag ) |
---|
2909 | { |
---|
2910 | Int iDeltaWeight; |
---|
2911 | READ_SVLC( iDeltaWeight, "delta_luma_weight_lX" ); // se(v): delta_luma_weight_l0[i] |
---|
2912 | assert( iDeltaWeight >= -128 ); |
---|
2913 | assert( iDeltaWeight <= 127 ); |
---|
2914 | wp[0].iWeight = (iDeltaWeight + (1<<wp[0].uiLog2WeightDenom)); |
---|
2915 | READ_SVLC( wp[0].iOffset, "luma_offset_lX" ); // se(v): luma_offset_l0[i] |
---|
2916 | assert( wp[0].iOffset >= -128 ); |
---|
2917 | assert( wp[0].iOffset <= 127 ); |
---|
2918 | } |
---|
2919 | else |
---|
2920 | { |
---|
2921 | wp[0].iWeight = (1 << wp[0].uiLog2WeightDenom); |
---|
2922 | wp[0].iOffset = 0; |
---|
2923 | } |
---|
2924 | if ( bChroma ) |
---|
2925 | { |
---|
2926 | if ( wp[1].bPresentFlag ) |
---|
2927 | { |
---|
2928 | for ( Int j=1 ; j<3 ; j++ ) |
---|
2929 | { |
---|
2930 | Int iDeltaWeight; |
---|
2931 | READ_SVLC( iDeltaWeight, "delta_chroma_weight_lX" ); // se(v): chroma_weight_l0[i][j] |
---|
2932 | assert( iDeltaWeight >= -128 ); |
---|
2933 | assert( iDeltaWeight <= 127 ); |
---|
2934 | wp[j].iWeight = (iDeltaWeight + (1<<wp[1].uiLog2WeightDenom)); |
---|
2935 | |
---|
2936 | Int iDeltaChroma; |
---|
2937 | READ_SVLC( iDeltaChroma, "delta_chroma_offset_lX" ); // se(v): delta_chroma_offset_l0[i][j] |
---|
2938 | assert( iDeltaChroma >= -512 ); |
---|
2939 | assert( iDeltaChroma <= 511 ); |
---|
2940 | Int pred = ( 128 - ( ( 128*wp[j].iWeight)>>(wp[j].uiLog2WeightDenom) ) ); |
---|
2941 | wp[j].iOffset = Clip3(-128, 127, (iDeltaChroma + pred) ); |
---|
2942 | } |
---|
2943 | } |
---|
2944 | else |
---|
2945 | { |
---|
2946 | for ( Int j=1 ; j<3 ; j++ ) |
---|
2947 | { |
---|
2948 | wp[j].iWeight = (1 << wp[j].uiLog2WeightDenom); |
---|
2949 | wp[j].iOffset = 0; |
---|
2950 | } |
---|
2951 | } |
---|
2952 | } |
---|
2953 | } |
---|
2954 | |
---|
2955 | for ( Int iRefIdx=pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx<MAX_NUM_REF ; iRefIdx++ ) |
---|
2956 | { |
---|
2957 | pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); |
---|
2958 | |
---|
2959 | wp[0].bPresentFlag = false; |
---|
2960 | wp[1].bPresentFlag = false; |
---|
2961 | wp[2].bPresentFlag = false; |
---|
2962 | } |
---|
2963 | } |
---|
2964 | assert(uiTotalSignalledWeightFlags<=24); |
---|
2965 | } |
---|
2966 | |
---|
2967 | /** decode quantization matrix |
---|
2968 | * \param scalingList quantization matrix information |
---|
2969 | */ |
---|
2970 | Void TDecCavlc::parseScalingList(TComScalingList* scalingList) |
---|
2971 | { |
---|
2972 | UInt code, sizeId, listId; |
---|
2973 | Bool scalingListPredModeFlag; |
---|
2974 | //for each size |
---|
2975 | for(sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
2976 | { |
---|
2977 | for(listId = 0; listId < g_scalingListNum[sizeId]; listId++) |
---|
2978 | { |
---|
2979 | READ_FLAG( code, "scaling_list_pred_mode_flag"); |
---|
2980 | scalingListPredModeFlag = (code) ? true : false; |
---|
2981 | if(!scalingListPredModeFlag) //Copy Mode |
---|
2982 | { |
---|
2983 | READ_UVLC( code, "scaling_list_pred_matrix_id_delta"); |
---|
2984 | scalingList->setRefMatrixId (sizeId,listId,(UInt)((Int)(listId)-(code))); |
---|
2985 | if( sizeId > SCALING_LIST_8x8 ) |
---|
2986 | { |
---|
2987 | scalingList->setScalingListDC(sizeId,listId,((listId == scalingList->getRefMatrixId (sizeId,listId))? 16 :scalingList->getScalingListDC(sizeId, scalingList->getRefMatrixId (sizeId,listId)))); |
---|
2988 | } |
---|
2989 | scalingList->processRefMatrix( sizeId, listId, scalingList->getRefMatrixId (sizeId,listId)); |
---|
2990 | |
---|
2991 | } |
---|
2992 | else //DPCM Mode |
---|
2993 | { |
---|
2994 | xDecodeScalingList(scalingList, sizeId, listId); |
---|
2995 | } |
---|
2996 | } |
---|
2997 | } |
---|
2998 | |
---|
2999 | return; |
---|
3000 | } |
---|
3001 | /** decode DPCM |
---|
3002 | * \param scalingList quantization matrix information |
---|
3003 | * \param sizeId size index |
---|
3004 | * \param listId list index |
---|
3005 | */ |
---|
3006 | Void TDecCavlc::xDecodeScalingList(TComScalingList *scalingList, UInt sizeId, UInt listId) |
---|
3007 | { |
---|
3008 | Int i,coefNum = min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId]); |
---|
3009 | Int data; |
---|
3010 | Int scalingListDcCoefMinus8 = 0; |
---|
3011 | Int nextCoef = SCALING_LIST_START_VALUE; |
---|
3012 | UInt* scan = (sizeId == 0) ? g_auiSigLastScan [ SCAN_DIAG ] [ 1 ] : g_sigLastScanCG32x32; |
---|
3013 | Int *dst = scalingList->getScalingListAddress(sizeId, listId); |
---|
3014 | |
---|
3015 | if( sizeId > SCALING_LIST_8x8 ) |
---|
3016 | { |
---|
3017 | READ_SVLC( scalingListDcCoefMinus8, "scaling_list_dc_coef_minus8"); |
---|
3018 | scalingList->setScalingListDC(sizeId,listId,scalingListDcCoefMinus8 + 8); |
---|
3019 | nextCoef = scalingList->getScalingListDC(sizeId,listId); |
---|
3020 | } |
---|
3021 | |
---|
3022 | for(i = 0; i < coefNum; i++) |
---|
3023 | { |
---|
3024 | READ_SVLC( data, "scaling_list_delta_coef"); |
---|
3025 | nextCoef = (nextCoef + data + 256 ) % 256; |
---|
3026 | dst[scan[i]] = nextCoef; |
---|
3027 | } |
---|
3028 | } |
---|
3029 | |
---|
3030 | Bool TDecCavlc::xMoreRbspData() |
---|
3031 | { |
---|
3032 | Int bitsLeft = m_pcBitstream->getNumBitsLeft(); |
---|
3033 | |
---|
3034 | // if there are more than 8 bits, it cannot be rbsp_trailing_bits |
---|
3035 | if (bitsLeft > 8) |
---|
3036 | { |
---|
3037 | return true; |
---|
3038 | } |
---|
3039 | |
---|
3040 | UChar lastByte = m_pcBitstream->peekBits(bitsLeft); |
---|
3041 | Int cnt = bitsLeft; |
---|
3042 | |
---|
3043 | // remove trailing bits equal to zero |
---|
3044 | while ((cnt>0) && ((lastByte & 1) == 0)) |
---|
3045 | { |
---|
3046 | lastByte >>= 1; |
---|
3047 | cnt--; |
---|
3048 | } |
---|
3049 | // remove bit equal to one |
---|
3050 | cnt--; |
---|
3051 | |
---|
3052 | // we should not have a negative number of bits |
---|
3053 | assert (cnt>=0); |
---|
3054 | |
---|
3055 | // we have more data, if cnt is not zero |
---|
3056 | return (cnt>0); |
---|
3057 | } |
---|
3058 | |
---|
3059 | //! \} |
---|
3060 | |
---|