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