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-2015, 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 | #include "TLibCommon/TComChromaFormat.h" |
---|
42 | #if RExt__DECODER_DEBUG_BIT_STATISTICS |
---|
43 | #include "TLibCommon/TComCodingStatistics.h" |
---|
44 | #endif |
---|
45 | #if CGS_3D_ASYMLUT |
---|
46 | #include "../TLibCommon/TCom3DAsymLUT.h" |
---|
47 | #endif |
---|
48 | |
---|
49 | //! \ingroup TLibDecoder |
---|
50 | //! \{ |
---|
51 | |
---|
52 | #if ENC_DEC_TRACE |
---|
53 | |
---|
54 | Void xTraceSPSHeader (const TComSPS *pSPS) |
---|
55 | { |
---|
56 | fprintf( g_hTrace, "=========== Sequence Parameter Set ID: %d ===========\n", pSPS->getSPSId() ); |
---|
57 | } |
---|
58 | |
---|
59 | Void xTracePPSHeader (const TComPPS *pPPS) |
---|
60 | { |
---|
61 | fprintf( g_hTrace, "=========== Picture Parameter Set ID: %d ===========\n", pPPS->getPPSId() ); |
---|
62 | } |
---|
63 | |
---|
64 | Void xTraceSliceHeader (const TComSlice *pSlice) |
---|
65 | { |
---|
66 | fprintf( g_hTrace, "=========== Slice ===========\n"); |
---|
67 | } |
---|
68 | |
---|
69 | #endif |
---|
70 | |
---|
71 | // ==================================================================================================================== |
---|
72 | // Constructor / destructor / create / destroy |
---|
73 | // ==================================================================================================================== |
---|
74 | |
---|
75 | TDecCavlc::TDecCavlc() |
---|
76 | { |
---|
77 | } |
---|
78 | |
---|
79 | TDecCavlc::~TDecCavlc() |
---|
80 | { |
---|
81 | |
---|
82 | } |
---|
83 | |
---|
84 | // ==================================================================================================================== |
---|
85 | // Public member functions |
---|
86 | // ==================================================================================================================== |
---|
87 | |
---|
88 | Void TDecCavlc::parseShortTermRefPicSet( TComSPS* sps, TComReferencePictureSet* rps, Int idx ) |
---|
89 | { |
---|
90 | UInt code; |
---|
91 | UInt interRPSPred; |
---|
92 | if (idx > 0) |
---|
93 | { |
---|
94 | READ_FLAG(interRPSPred, "inter_ref_pic_set_prediction_flag"); rps->setInterRPSPrediction(interRPSPred); |
---|
95 | } |
---|
96 | else |
---|
97 | { |
---|
98 | interRPSPred = false; |
---|
99 | rps->setInterRPSPrediction(false); |
---|
100 | } |
---|
101 | |
---|
102 | if (interRPSPred) |
---|
103 | { |
---|
104 | UInt bit; |
---|
105 | if(idx == sps->getRPSList()->getNumberOfReferencePictureSets()) |
---|
106 | { |
---|
107 | READ_UVLC(code, "delta_idx_minus1" ); // delta index of the Reference Picture Set used for prediction minus 1 |
---|
108 | } |
---|
109 | else |
---|
110 | { |
---|
111 | code = 0; |
---|
112 | } |
---|
113 | 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 |
---|
114 | Int rIdx = idx - 1 - code; |
---|
115 | 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 |
---|
116 | TComReferencePictureSet* rpsRef = sps->getRPSList()->getReferencePictureSet(rIdx); |
---|
117 | Int k = 0, k0 = 0, k1 = 0; |
---|
118 | READ_CODE(1, bit, "delta_rps_sign"); // delta_RPS_sign |
---|
119 | READ_UVLC(code, "abs_delta_rps_minus1"); // absolute delta RPS minus 1 |
---|
120 | Int deltaRPS = (1 - 2 * bit) * (code + 1); // delta_RPS |
---|
121 | for(Int j=0 ; j <= rpsRef->getNumberOfPictures(); j++) |
---|
122 | { |
---|
123 | READ_CODE(1, bit, "used_by_curr_pic_flag" ); //first bit is "1" if Idc is 1 |
---|
124 | Int refIdc = bit; |
---|
125 | if (refIdc == 0) |
---|
126 | { |
---|
127 | READ_CODE(1, bit, "use_delta_flag" ); //second bit is "1" if Idc is 2, "0" otherwise. |
---|
128 | refIdc = bit<<1; //second bit is "1" if refIdc is 2, "0" if refIdc = 0. |
---|
129 | } |
---|
130 | if (refIdc == 1 || refIdc == 2) |
---|
131 | { |
---|
132 | Int deltaPOC = deltaRPS + ((j < rpsRef->getNumberOfPictures())? rpsRef->getDeltaPOC(j) : 0); |
---|
133 | rps->setDeltaPOC(k, deltaPOC); |
---|
134 | rps->setUsed(k, (refIdc == 1)); |
---|
135 | |
---|
136 | if (deltaPOC < 0) |
---|
137 | { |
---|
138 | k0++; |
---|
139 | } |
---|
140 | else |
---|
141 | { |
---|
142 | k1++; |
---|
143 | } |
---|
144 | k++; |
---|
145 | } |
---|
146 | rps->setRefIdc(j,refIdc); |
---|
147 | } |
---|
148 | rps->setNumRefIdc(rpsRef->getNumberOfPictures()+1); |
---|
149 | rps->setNumberOfPictures(k); |
---|
150 | rps->setNumberOfNegativePictures(k0); |
---|
151 | rps->setNumberOfPositivePictures(k1); |
---|
152 | rps->sortDeltaPOC(); |
---|
153 | } |
---|
154 | else |
---|
155 | { |
---|
156 | READ_UVLC(code, "num_negative_pics"); rps->setNumberOfNegativePictures(code); |
---|
157 | READ_UVLC(code, "num_positive_pics"); rps->setNumberOfPositivePictures(code); |
---|
158 | Int prev = 0; |
---|
159 | Int poc; |
---|
160 | for(Int j=0 ; j < rps->getNumberOfNegativePictures(); j++) |
---|
161 | { |
---|
162 | READ_UVLC(code, "delta_poc_s0_minus1"); |
---|
163 | poc = prev-code-1; |
---|
164 | prev = poc; |
---|
165 | rps->setDeltaPOC(j,poc); |
---|
166 | READ_FLAG(code, "used_by_curr_pic_s0_flag"); rps->setUsed(j,code); |
---|
167 | } |
---|
168 | prev = 0; |
---|
169 | for(Int j=rps->getNumberOfNegativePictures(); j < rps->getNumberOfNegativePictures()+rps->getNumberOfPositivePictures(); j++) |
---|
170 | { |
---|
171 | READ_UVLC(code, "delta_poc_s1_minus1"); |
---|
172 | poc = prev+code+1; |
---|
173 | prev = poc; |
---|
174 | rps->setDeltaPOC(j,poc); |
---|
175 | READ_FLAG(code, "used_by_curr_pic_s1_flag"); rps->setUsed(j,code); |
---|
176 | } |
---|
177 | rps->setNumberOfPictures(rps->getNumberOfNegativePictures()+rps->getNumberOfPositivePictures()); |
---|
178 | } |
---|
179 | #if PRINT_RPS_INFO |
---|
180 | rps->printDeltaPOC(); |
---|
181 | #endif |
---|
182 | } |
---|
183 | |
---|
184 | #if CGS_3D_ASYMLUT |
---|
185 | Void TDecCavlc::parsePPS(TComPPS* pcPPS, TCom3DAsymLUT * pc3DAsymLUT, Int nLayerID) |
---|
186 | #else |
---|
187 | Void TDecCavlc::parsePPS(TComPPS* pcPPS) |
---|
188 | #endif |
---|
189 | |
---|
190 | { |
---|
191 | #if ENC_DEC_TRACE |
---|
192 | xTracePPSHeader (pcPPS); |
---|
193 | #endif |
---|
194 | UInt uiCode; |
---|
195 | |
---|
196 | Int iCode; |
---|
197 | |
---|
198 | READ_UVLC( uiCode, "pps_pic_parameter_set_id"); |
---|
199 | assert(uiCode <= 63); |
---|
200 | pcPPS->setPPSId (uiCode); |
---|
201 | |
---|
202 | READ_UVLC( uiCode, "pps_seq_parameter_set_id"); |
---|
203 | assert(uiCode <= 15); |
---|
204 | pcPPS->setSPSId (uiCode); |
---|
205 | |
---|
206 | READ_FLAG( uiCode, "dependent_slice_segments_enabled_flag" ); pcPPS->setDependentSliceSegmentsEnabledFlag ( uiCode == 1 ); |
---|
207 | |
---|
208 | READ_FLAG( uiCode, "output_flag_present_flag" ); pcPPS->setOutputFlagPresentFlag( uiCode==1 ); |
---|
209 | |
---|
210 | READ_CODE(3, uiCode, "num_extra_slice_header_bits"); pcPPS->setNumExtraSliceHeaderBits(uiCode); |
---|
211 | |
---|
212 | READ_FLAG ( uiCode, "sign_data_hiding_flag" ); pcPPS->setSignHideFlag( uiCode ); |
---|
213 | |
---|
214 | READ_FLAG( uiCode, "cabac_init_present_flag" ); pcPPS->setCabacInitPresentFlag( uiCode ? true : false ); |
---|
215 | |
---|
216 | READ_UVLC(uiCode, "num_ref_idx_l0_default_active_minus1"); |
---|
217 | assert(uiCode <= 14); |
---|
218 | pcPPS->setNumRefIdxL0DefaultActive(uiCode+1); |
---|
219 | |
---|
220 | READ_UVLC(uiCode, "num_ref_idx_l1_default_active_minus1"); |
---|
221 | assert(uiCode <= 14); |
---|
222 | pcPPS->setNumRefIdxL1DefaultActive(uiCode+1); |
---|
223 | |
---|
224 | READ_SVLC(iCode, "init_qp_minus26" ); pcPPS->setPicInitQPMinus26(iCode); |
---|
225 | READ_FLAG( uiCode, "constrained_intra_pred_flag" ); pcPPS->setConstrainedIntraPred( uiCode ? true : false ); |
---|
226 | READ_FLAG( uiCode, "transform_skip_enabled_flag" ); |
---|
227 | pcPPS->setUseTransformSkip ( uiCode ? true : false ); |
---|
228 | |
---|
229 | READ_FLAG( uiCode, "cu_qp_delta_enabled_flag" ); pcPPS->setUseDQP( uiCode ? true : false ); |
---|
230 | if( pcPPS->getUseDQP() ) |
---|
231 | { |
---|
232 | READ_UVLC( uiCode, "diff_cu_qp_delta_depth" ); |
---|
233 | pcPPS->setMaxCuDQPDepth( uiCode ); |
---|
234 | } |
---|
235 | else |
---|
236 | { |
---|
237 | pcPPS->setMaxCuDQPDepth( 0 ); |
---|
238 | } |
---|
239 | READ_SVLC( iCode, "pps_cb_qp_offset"); |
---|
240 | pcPPS->setQpOffset(COMPONENT_Cb, iCode); |
---|
241 | assert( pcPPS->getQpOffset(COMPONENT_Cb) >= -12 ); |
---|
242 | assert( pcPPS->getQpOffset(COMPONENT_Cb) <= 12 ); |
---|
243 | |
---|
244 | READ_SVLC( iCode, "pps_cr_qp_offset"); |
---|
245 | pcPPS->setQpOffset(COMPONENT_Cr, iCode); |
---|
246 | assert( pcPPS->getQpOffset(COMPONENT_Cr) >= -12 ); |
---|
247 | assert( pcPPS->getQpOffset(COMPONENT_Cr) <= 12 ); |
---|
248 | |
---|
249 | assert(MAX_NUM_COMPONENT<=3); |
---|
250 | |
---|
251 | READ_FLAG( uiCode, "pps_slice_chroma_qp_offsets_present_flag" ); |
---|
252 | pcPPS->setSliceChromaQpFlag( uiCode ? true : false ); |
---|
253 | |
---|
254 | READ_FLAG( uiCode, "weighted_pred_flag" ); // Use of Weighting Prediction (P_SLICE) |
---|
255 | pcPPS->setUseWP( uiCode==1 ); |
---|
256 | READ_FLAG( uiCode, "weighted_bipred_flag" ); // Use of Bi-Directional Weighting Prediction (B_SLICE) |
---|
257 | pcPPS->setWPBiPred( uiCode==1 ); |
---|
258 | |
---|
259 | READ_FLAG( uiCode, "transquant_bypass_enable_flag"); |
---|
260 | pcPPS->setTransquantBypassEnableFlag(uiCode ? true : false); |
---|
261 | READ_FLAG( uiCode, "tiles_enabled_flag" ); pcPPS->setTilesEnabledFlag ( uiCode == 1 ); |
---|
262 | READ_FLAG( uiCode, "entropy_coding_sync_enabled_flag" ); pcPPS->setEntropyCodingSyncEnabledFlag( uiCode == 1 ); |
---|
263 | |
---|
264 | if( pcPPS->getTilesEnabledFlag() ) |
---|
265 | { |
---|
266 | READ_UVLC ( uiCode, "num_tile_columns_minus1" ); pcPPS->setNumTileColumnsMinus1( uiCode ); |
---|
267 | READ_UVLC ( uiCode, "num_tile_rows_minus1" ); pcPPS->setNumTileRowsMinus1( uiCode ); |
---|
268 | READ_FLAG ( uiCode, "uniform_spacing_flag" ); pcPPS->setTileUniformSpacingFlag( uiCode == 1 ); |
---|
269 | |
---|
270 | const UInt tileColumnsMinus1 = pcPPS->getNumTileColumnsMinus1(); |
---|
271 | const UInt tileRowsMinus1 = pcPPS->getNumTileRowsMinus1(); |
---|
272 | |
---|
273 | if ( !pcPPS->getTileUniformSpacingFlag()) |
---|
274 | { |
---|
275 | if (tileColumnsMinus1 > 0) |
---|
276 | { |
---|
277 | std::vector<Int> columnWidth(tileColumnsMinus1); |
---|
278 | for(UInt i = 0; i < tileColumnsMinus1; i++) |
---|
279 | { |
---|
280 | READ_UVLC( uiCode, "column_width_minus1" ); |
---|
281 | columnWidth[i] = uiCode+1; |
---|
282 | } |
---|
283 | pcPPS->setTileColumnWidth(columnWidth); |
---|
284 | } |
---|
285 | |
---|
286 | if (tileRowsMinus1 > 0) |
---|
287 | { |
---|
288 | std::vector<Int> rowHeight (tileRowsMinus1); |
---|
289 | for(UInt i = 0; i < tileRowsMinus1; i++) |
---|
290 | { |
---|
291 | READ_UVLC( uiCode, "row_height_minus1" ); |
---|
292 | rowHeight[i] = uiCode + 1; |
---|
293 | } |
---|
294 | pcPPS->setTileRowHeight(rowHeight); |
---|
295 | } |
---|
296 | } |
---|
297 | |
---|
298 | if ((tileColumnsMinus1 + tileRowsMinus1) != 0) |
---|
299 | { |
---|
300 | READ_FLAG ( uiCode, "loop_filter_across_tiles_enabled_flag" ); pcPPS->setLoopFilterAcrossTilesEnabledFlag( uiCode ? true : false ); |
---|
301 | } |
---|
302 | } |
---|
303 | READ_FLAG( uiCode, "pps_loop_filter_across_slices_enabled_flag" ); pcPPS->setLoopFilterAcrossSlicesEnabledFlag( uiCode ? true : false ); |
---|
304 | READ_FLAG( uiCode, "deblocking_filter_control_present_flag" ); pcPPS->setDeblockingFilterControlPresentFlag( uiCode ? true : false ); |
---|
305 | if(pcPPS->getDeblockingFilterControlPresentFlag()) |
---|
306 | { |
---|
307 | READ_FLAG( uiCode, "deblocking_filter_override_enabled_flag" ); pcPPS->setDeblockingFilterOverrideEnabledFlag( uiCode ? true : false ); |
---|
308 | READ_FLAG( uiCode, "pps_disable_deblocking_filter_flag" ); pcPPS->setPicDisableDeblockingFilterFlag(uiCode ? true : false ); |
---|
309 | if(!pcPPS->getPicDisableDeblockingFilterFlag()) |
---|
310 | { |
---|
311 | READ_SVLC ( iCode, "pps_beta_offset_div2" ); pcPPS->setDeblockingFilterBetaOffsetDiv2( iCode ); |
---|
312 | READ_SVLC ( iCode, "pps_tc_offset_div2" ); pcPPS->setDeblockingFilterTcOffsetDiv2( iCode ); |
---|
313 | } |
---|
314 | } |
---|
315 | READ_FLAG( uiCode, "pps_scaling_list_data_present_flag" ); pcPPS->setScalingListPresentFlag( uiCode ? true : false ); |
---|
316 | if(pcPPS->getScalingListPresentFlag ()) |
---|
317 | { |
---|
318 | parseScalingList( &(pcPPS->getScalingList()) ); |
---|
319 | } |
---|
320 | |
---|
321 | READ_FLAG( uiCode, "lists_modification_present_flag"); |
---|
322 | pcPPS->setListsModificationPresentFlag(uiCode); |
---|
323 | |
---|
324 | READ_UVLC( uiCode, "log2_parallel_merge_level_minus2"); |
---|
325 | pcPPS->setLog2ParallelMergeLevelMinus2 (uiCode); |
---|
326 | |
---|
327 | READ_FLAG( uiCode, "slice_segment_header_extension_present_flag"); |
---|
328 | pcPPS->setSliceHeaderExtensionPresentFlag(uiCode); |
---|
329 | |
---|
330 | READ_FLAG( uiCode, "pps_extension_present_flag"); |
---|
331 | |
---|
332 | #if SVC_EXTENSION |
---|
333 | pcPPS->setExtensionFlag( uiCode ? true : false ); |
---|
334 | if( pcPPS->getExtensionFlag() ) |
---|
335 | #else |
---|
336 | if (uiCode) |
---|
337 | #endif |
---|
338 | { |
---|
339 | #if ENC_DEC_TRACE || RExt__DECODER_DEBUG_BIT_STATISTICS |
---|
340 | static const char *syntaxStrings[]={ "pps_range_extension_flag", |
---|
341 | "pps_multilayer_extension_flag", |
---|
342 | "pps_extension_6bits[0]", |
---|
343 | "pps_extension_6bits[1]", |
---|
344 | "pps_extension_6bits[2]", |
---|
345 | "pps_extension_6bits[3]", |
---|
346 | "pps_extension_6bits[4]", |
---|
347 | "pps_extension_6bits[5]" }; |
---|
348 | #endif |
---|
349 | |
---|
350 | Bool pps_extension_flags[NUM_PPS_EXTENSION_FLAGS]; |
---|
351 | for(Int i=0; i<NUM_PPS_EXTENSION_FLAGS; i++) |
---|
352 | { |
---|
353 | READ_FLAG( uiCode, syntaxStrings[i] ); |
---|
354 | pps_extension_flags[i] = uiCode!=0; |
---|
355 | } |
---|
356 | |
---|
357 | Bool bSkipTrailingExtensionBits=false; |
---|
358 | for(Int i=0; i<NUM_PPS_EXTENSION_FLAGS; i++) // loop used so that the order is determined by the enum. |
---|
359 | { |
---|
360 | if (pps_extension_flags[i]) |
---|
361 | { |
---|
362 | switch (PPSExtensionFlagIndex(i)) |
---|
363 | { |
---|
364 | case PPS_EXT__REXT: |
---|
365 | { |
---|
366 | TComPPSRExt &ppsRangeExtension = pcPPS->getPpsRangeExtension(); |
---|
367 | assert(!bSkipTrailingExtensionBits); |
---|
368 | |
---|
369 | if (pcPPS->getUseTransformSkip()) |
---|
370 | { |
---|
371 | READ_UVLC( uiCode, "log2_max_transform_skip_block_size_minus2"); |
---|
372 | ppsRangeExtension.setLog2MaxTransformSkipBlockSize(uiCode+2); |
---|
373 | } |
---|
374 | |
---|
375 | READ_FLAG( uiCode, "cross_component_prediction_enabled_flag"); |
---|
376 | ppsRangeExtension.setCrossComponentPredictionEnabledFlag(uiCode != 0); |
---|
377 | |
---|
378 | READ_FLAG( uiCode, "chroma_qp_offset_list_enabled_flag"); |
---|
379 | if (uiCode == 0) |
---|
380 | { |
---|
381 | ppsRangeExtension.clearChromaQpOffsetList(); |
---|
382 | ppsRangeExtension.setDiffCuChromaQpOffsetDepth(0); |
---|
383 | } |
---|
384 | else |
---|
385 | { |
---|
386 | READ_UVLC(uiCode, "diff_cu_chroma_qp_offset_depth"); ppsRangeExtension.setDiffCuChromaQpOffsetDepth(uiCode); |
---|
387 | UInt tableSizeMinus1 = 0; |
---|
388 | READ_UVLC(tableSizeMinus1, "chroma_qp_offset_list_len_minus1"); |
---|
389 | assert(tableSizeMinus1 < MAX_QP_OFFSET_LIST_SIZE); |
---|
390 | |
---|
391 | for (Int cuChromaQpOffsetIdx = 0; cuChromaQpOffsetIdx <= (tableSizeMinus1); cuChromaQpOffsetIdx++) |
---|
392 | { |
---|
393 | Int cbOffset; |
---|
394 | Int crOffset; |
---|
395 | READ_SVLC(cbOffset, "cb_qp_offset_list[i]"); |
---|
396 | assert(cbOffset >= -12 && cbOffset <= 12); |
---|
397 | READ_SVLC(crOffset, "cr_qp_offset_list[i]"); |
---|
398 | assert(crOffset >= -12 && crOffset <= 12); |
---|
399 | // table uses +1 for index (see comment inside the function) |
---|
400 | ppsRangeExtension.setChromaQpOffsetListEntry(cuChromaQpOffsetIdx+1, cbOffset, crOffset); |
---|
401 | } |
---|
402 | assert(ppsRangeExtension.getChromaQpOffsetListLen() == tableSizeMinus1 + 1); |
---|
403 | } |
---|
404 | |
---|
405 | READ_UVLC( uiCode, "log2_sao_offset_scale_luma"); |
---|
406 | ppsRangeExtension.setLog2SaoOffsetScale(CHANNEL_TYPE_LUMA, uiCode); |
---|
407 | READ_UVLC( uiCode, "log2_sao_offset_scale_chroma"); |
---|
408 | ppsRangeExtension.setLog2SaoOffsetScale(CHANNEL_TYPE_CHROMA, uiCode); |
---|
409 | } |
---|
410 | break; |
---|
411 | |
---|
412 | #if SVC_EXTENSION |
---|
413 | case PPS_EXT__MLAYER: |
---|
414 | READ_FLAG( uiCode, "poc_reset_info_present_flag" ); |
---|
415 | pcPPS->setPocResetInfoPresentFlag(uiCode ? true : false); |
---|
416 | |
---|
417 | READ_FLAG( uiCode, "pps_infer_scaling_list_flag" ); |
---|
418 | pcPPS->setInferScalingListFlag( uiCode ); |
---|
419 | |
---|
420 | if( pcPPS->getInferScalingListFlag() ) |
---|
421 | { |
---|
422 | READ_CODE( 6, uiCode, "pps_scaling_list_ref_layer_id" ); |
---|
423 | pcPPS->setScalingListRefLayerId( uiCode ); |
---|
424 | // The value of pps_scaling_list_ref_layer_id shall be in the range of 0 to 62, inclusive |
---|
425 | assert( pcPPS->getScalingListRefLayerId() <= 62 ); |
---|
426 | pcPPS->setScalingListPresentFlag( false ); |
---|
427 | } |
---|
428 | |
---|
429 | READ_UVLC( uiCode, "num_ref_loc_offsets" ); pcPPS->setNumRefLayerLocationOffsets(uiCode); |
---|
430 | for(Int k = 0; k < pcPPS->getNumRefLayerLocationOffsets(); k++) |
---|
431 | { |
---|
432 | READ_CODE( 6, uiCode, "ref_loc_offset_layer_id" ); pcPPS->setRefLocationOffsetLayerId( k, uiCode ); |
---|
433 | READ_FLAG( uiCode, "scaled_ref_layer_offset_present_flag" ); pcPPS->setScaledRefLayerOffsetPresentFlag( k, uiCode ); |
---|
434 | if (uiCode) |
---|
435 | { |
---|
436 | Window& scaledWindow = pcPPS->getScaledRefLayerWindow(k); |
---|
437 | READ_SVLC( iCode, "scaled_ref_layer_left_offset" ); scaledWindow.setWindowLeftOffset (iCode << 1); |
---|
438 | READ_SVLC( iCode, "scaled_ref_layer_top_offset" ); scaledWindow.setWindowTopOffset (iCode << 1); |
---|
439 | READ_SVLC( iCode, "scaled_ref_layer_right_offset" ); scaledWindow.setWindowRightOffset (iCode << 1); |
---|
440 | READ_SVLC( iCode, "scaled_ref_layer_bottom_offset" ); scaledWindow.setWindowBottomOffset(iCode << 1); |
---|
441 | } |
---|
442 | READ_FLAG( uiCode, "ref_region_offset_present_flag" ); pcPPS->setRefRegionOffsetPresentFlag( k, uiCode ); |
---|
443 | if (uiCode) |
---|
444 | { |
---|
445 | Window& refWindow = pcPPS->getRefLayerWindow(k); |
---|
446 | READ_SVLC( iCode, "ref_region_left_offset" ); refWindow.setWindowLeftOffset (iCode << 1); |
---|
447 | READ_SVLC( iCode, "ref_region_top_offset" ); refWindow.setWindowTopOffset (iCode << 1); |
---|
448 | READ_SVLC( iCode, "ref_region_right_offset" ); refWindow.setWindowRightOffset (iCode << 1); |
---|
449 | READ_SVLC( iCode, "ref_region_bottom_offset" ); refWindow.setWindowBottomOffset(iCode << 1); |
---|
450 | } |
---|
451 | READ_FLAG( uiCode, "resample_phase_set_present_flag" ); pcPPS->setResamplePhaseSetPresentFlag( k, uiCode ); |
---|
452 | if (uiCode) |
---|
453 | { |
---|
454 | READ_UVLC( uiCode, "phase_hor_luma" ); pcPPS->setPhaseHorLuma ( k, uiCode ); |
---|
455 | READ_UVLC( uiCode, "phase_ver_luma" ); pcPPS->setPhaseVerLuma ( k, uiCode ); |
---|
456 | READ_UVLC( uiCode, "phase_hor_chroma_plus8" ); pcPPS->setPhaseHorChroma (k, uiCode - 8); |
---|
457 | READ_UVLC( uiCode, "phase_ver_chroma_plus8" ); pcPPS->setPhaseVerChroma (k, uiCode - 8); |
---|
458 | } |
---|
459 | } |
---|
460 | #if CGS_3D_ASYMLUT |
---|
461 | READ_FLAG( uiCode , "colour_mapping_enabled_flag" ); |
---|
462 | pcPPS->setCGSFlag( uiCode ); |
---|
463 | if( pcPPS->getCGSFlag() ) |
---|
464 | { |
---|
465 | // when pps_pic_parameter_set_id greater than or equal to 8, colour_mapping_enabled_flag shall be equal to 0 |
---|
466 | assert( pcPPS->getPPSId() < 8 ); |
---|
467 | |
---|
468 | xParse3DAsymLUT( pc3DAsymLUT ); |
---|
469 | pcPPS->setCGSOutputBitDepthY( pc3DAsymLUT->getOutputBitDepthY() ); |
---|
470 | pcPPS->setCGSOutputBitDepthC( pc3DAsymLUT->getOutputBitDepthC() ); |
---|
471 | } |
---|
472 | #endif |
---|
473 | break; |
---|
474 | #endif |
---|
475 | default: |
---|
476 | bSkipTrailingExtensionBits=true; |
---|
477 | break; |
---|
478 | } |
---|
479 | } |
---|
480 | } |
---|
481 | if (bSkipTrailingExtensionBits) |
---|
482 | { |
---|
483 | while ( xMoreRbspData() ) |
---|
484 | { |
---|
485 | READ_FLAG( uiCode, "pps_extension_data_flag"); |
---|
486 | } |
---|
487 | } |
---|
488 | } |
---|
489 | } |
---|
490 | |
---|
491 | Void TDecCavlc::parseVUI(TComVUI* pcVUI, TComSPS *pcSPS) |
---|
492 | { |
---|
493 | #if ENC_DEC_TRACE |
---|
494 | fprintf( g_hTrace, "----------- vui_parameters -----------\n"); |
---|
495 | #endif |
---|
496 | UInt uiCode; |
---|
497 | |
---|
498 | READ_FLAG( uiCode, "aspect_ratio_info_present_flag"); pcVUI->setAspectRatioInfoPresentFlag(uiCode); |
---|
499 | if (pcVUI->getAspectRatioInfoPresentFlag()) |
---|
500 | { |
---|
501 | READ_CODE(8, uiCode, "aspect_ratio_idc"); pcVUI->setAspectRatioIdc(uiCode); |
---|
502 | if (pcVUI->getAspectRatioIdc() == 255) |
---|
503 | { |
---|
504 | READ_CODE(16, uiCode, "sar_width"); pcVUI->setSarWidth(uiCode); |
---|
505 | READ_CODE(16, uiCode, "sar_height"); pcVUI->setSarHeight(uiCode); |
---|
506 | } |
---|
507 | } |
---|
508 | |
---|
509 | READ_FLAG( uiCode, "overscan_info_present_flag"); pcVUI->setOverscanInfoPresentFlag(uiCode); |
---|
510 | if (pcVUI->getOverscanInfoPresentFlag()) |
---|
511 | { |
---|
512 | READ_FLAG( uiCode, "overscan_appropriate_flag"); pcVUI->setOverscanAppropriateFlag(uiCode); |
---|
513 | } |
---|
514 | |
---|
515 | READ_FLAG( uiCode, "video_signal_type_present_flag"); pcVUI->setVideoSignalTypePresentFlag(uiCode); |
---|
516 | if (pcVUI->getVideoSignalTypePresentFlag()) |
---|
517 | { |
---|
518 | READ_CODE(3, uiCode, "video_format"); pcVUI->setVideoFormat(uiCode); |
---|
519 | READ_FLAG( uiCode, "video_full_range_flag"); pcVUI->setVideoFullRangeFlag(uiCode); |
---|
520 | READ_FLAG( uiCode, "colour_description_present_flag"); pcVUI->setColourDescriptionPresentFlag(uiCode); |
---|
521 | if (pcVUI->getColourDescriptionPresentFlag()) |
---|
522 | { |
---|
523 | READ_CODE(8, uiCode, "colour_primaries"); pcVUI->setColourPrimaries(uiCode); |
---|
524 | READ_CODE(8, uiCode, "transfer_characteristics"); pcVUI->setTransferCharacteristics(uiCode); |
---|
525 | READ_CODE(8, uiCode, "matrix_coeffs"); pcVUI->setMatrixCoefficients(uiCode); |
---|
526 | } |
---|
527 | } |
---|
528 | |
---|
529 | READ_FLAG( uiCode, "chroma_loc_info_present_flag"); pcVUI->setChromaLocInfoPresentFlag(uiCode); |
---|
530 | if (pcVUI->getChromaLocInfoPresentFlag()) |
---|
531 | { |
---|
532 | READ_UVLC( uiCode, "chroma_sample_loc_type_top_field" ); pcVUI->setChromaSampleLocTypeTopField(uiCode); |
---|
533 | READ_UVLC( uiCode, "chroma_sample_loc_type_bottom_field" ); pcVUI->setChromaSampleLocTypeBottomField(uiCode); |
---|
534 | } |
---|
535 | |
---|
536 | READ_FLAG( uiCode, "neutral_chroma_indication_flag"); pcVUI->setNeutralChromaIndicationFlag(uiCode); |
---|
537 | |
---|
538 | READ_FLAG( uiCode, "field_seq_flag"); pcVUI->setFieldSeqFlag(uiCode); |
---|
539 | |
---|
540 | READ_FLAG(uiCode, "frame_field_info_present_flag"); pcVUI->setFrameFieldInfoPresentFlag(uiCode); |
---|
541 | |
---|
542 | READ_FLAG( uiCode, "default_display_window_flag"); |
---|
543 | if (uiCode != 0) |
---|
544 | { |
---|
545 | Window &defDisp = pcVUI->getDefaultDisplayWindow(); |
---|
546 | READ_UVLC( uiCode, "def_disp_win_left_offset" ); defDisp.setWindowLeftOffset ( uiCode * TComSPS::getWinUnitX( pcSPS->getChromaFormatIdc()) ); |
---|
547 | READ_UVLC( uiCode, "def_disp_win_right_offset" ); defDisp.setWindowRightOffset ( uiCode * TComSPS::getWinUnitX( pcSPS->getChromaFormatIdc()) ); |
---|
548 | READ_UVLC( uiCode, "def_disp_win_top_offset" ); defDisp.setWindowTopOffset ( uiCode * TComSPS::getWinUnitY( pcSPS->getChromaFormatIdc()) ); |
---|
549 | READ_UVLC( uiCode, "def_disp_win_bottom_offset" ); defDisp.setWindowBottomOffset( uiCode * TComSPS::getWinUnitY( pcSPS->getChromaFormatIdc()) ); |
---|
550 | } |
---|
551 | |
---|
552 | TimingInfo *timingInfo = pcVUI->getTimingInfo(); |
---|
553 | READ_FLAG( uiCode, "vui_timing_info_present_flag"); timingInfo->setTimingInfoPresentFlag (uiCode ? true : false); |
---|
554 | #if SVC_EXTENSION |
---|
555 | if( pcSPS->getLayerId() > 0 ) |
---|
556 | { |
---|
557 | assert( timingInfo->getTimingInfoPresentFlag() == false ); |
---|
558 | } |
---|
559 | #endif |
---|
560 | if(timingInfo->getTimingInfoPresentFlag()) |
---|
561 | { |
---|
562 | READ_CODE( 32, uiCode, "vui_num_units_in_tick"); timingInfo->setNumUnitsInTick (uiCode); |
---|
563 | READ_CODE( 32, uiCode, "vui_time_scale"); timingInfo->setTimeScale (uiCode); |
---|
564 | READ_FLAG( uiCode, "vui_poc_proportional_to_timing_flag"); timingInfo->setPocProportionalToTimingFlag(uiCode ? true : false); |
---|
565 | if(timingInfo->getPocProportionalToTimingFlag()) |
---|
566 | { |
---|
567 | READ_UVLC( uiCode, "vui_num_ticks_poc_diff_one_minus1"); timingInfo->setNumTicksPocDiffOneMinus1 (uiCode); |
---|
568 | } |
---|
569 | |
---|
570 | READ_FLAG( uiCode, "vui_hrd_parameters_present_flag"); pcVUI->setHrdParametersPresentFlag(uiCode); |
---|
571 | if( pcVUI->getHrdParametersPresentFlag() ) |
---|
572 | { |
---|
573 | parseHrdParameters( pcVUI->getHrdParameters(), 1, pcSPS->getMaxTLayers() - 1 ); |
---|
574 | } |
---|
575 | } |
---|
576 | |
---|
577 | READ_FLAG( uiCode, "bitstream_restriction_flag"); pcVUI->setBitstreamRestrictionFlag(uiCode); |
---|
578 | if (pcVUI->getBitstreamRestrictionFlag()) |
---|
579 | { |
---|
580 | READ_FLAG( uiCode, "tiles_fixed_structure_flag"); pcVUI->setTilesFixedStructureFlag(uiCode); |
---|
581 | READ_FLAG( uiCode, "motion_vectors_over_pic_boundaries_flag"); pcVUI->setMotionVectorsOverPicBoundariesFlag(uiCode); |
---|
582 | READ_FLAG( uiCode, "restricted_ref_pic_lists_flag"); pcVUI->setRestrictedRefPicListsFlag(uiCode); |
---|
583 | READ_UVLC( uiCode, "min_spatial_segmentation_idc"); pcVUI->setMinSpatialSegmentationIdc(uiCode); |
---|
584 | assert(uiCode < 4096); |
---|
585 | READ_UVLC( uiCode, "max_bytes_per_pic_denom" ); pcVUI->setMaxBytesPerPicDenom(uiCode); |
---|
586 | READ_UVLC( uiCode, "max_bits_per_min_cu_denom" ); pcVUI->setMaxBitsPerMinCuDenom(uiCode); |
---|
587 | READ_UVLC( uiCode, "log2_max_mv_length_horizontal" ); pcVUI->setLog2MaxMvLengthHorizontal(uiCode); |
---|
588 | READ_UVLC( uiCode, "log2_max_mv_length_vertical" ); pcVUI->setLog2MaxMvLengthVertical(uiCode); |
---|
589 | } |
---|
590 | } |
---|
591 | |
---|
592 | Void TDecCavlc::parseHrdParameters(TComHRD *hrd, Bool commonInfPresentFlag, UInt maxNumSubLayersMinus1) |
---|
593 | { |
---|
594 | UInt uiCode; |
---|
595 | if( commonInfPresentFlag ) |
---|
596 | { |
---|
597 | READ_FLAG( uiCode, "nal_hrd_parameters_present_flag" ); hrd->setNalHrdParametersPresentFlag( uiCode == 1 ? true : false ); |
---|
598 | READ_FLAG( uiCode, "vcl_hrd_parameters_present_flag" ); hrd->setVclHrdParametersPresentFlag( uiCode == 1 ? true : false ); |
---|
599 | if( hrd->getNalHrdParametersPresentFlag() || hrd->getVclHrdParametersPresentFlag() ) |
---|
600 | { |
---|
601 | READ_FLAG( uiCode, "sub_pic_hrd_params_present_flag" ); hrd->setSubPicCpbParamsPresentFlag( uiCode == 1 ? true : false ); |
---|
602 | if( hrd->getSubPicCpbParamsPresentFlag() ) |
---|
603 | { |
---|
604 | READ_CODE( 8, uiCode, "tick_divisor_minus2" ); hrd->setTickDivisorMinus2( uiCode ); |
---|
605 | READ_CODE( 5, uiCode, "du_cpb_removal_delay_increment_length_minus1" ); hrd->setDuCpbRemovalDelayLengthMinus1( uiCode ); |
---|
606 | READ_FLAG( uiCode, "sub_pic_cpb_params_in_pic_timing_sei_flag" ); hrd->setSubPicCpbParamsInPicTimingSEIFlag( uiCode == 1 ? true : false ); |
---|
607 | READ_CODE( 5, uiCode, "dpb_output_delay_du_length_minus1" ); hrd->setDpbOutputDelayDuLengthMinus1( uiCode ); |
---|
608 | } |
---|
609 | READ_CODE( 4, uiCode, "bit_rate_scale" ); hrd->setBitRateScale( uiCode ); |
---|
610 | READ_CODE( 4, uiCode, "cpb_size_scale" ); hrd->setCpbSizeScale( uiCode ); |
---|
611 | if( hrd->getSubPicCpbParamsPresentFlag() ) |
---|
612 | { |
---|
613 | READ_CODE( 4, uiCode, "cpb_size_du_scale" ); hrd->setDuCpbSizeScale( uiCode ); |
---|
614 | } |
---|
615 | READ_CODE( 5, uiCode, "initial_cpb_removal_delay_length_minus1" ); hrd->setInitialCpbRemovalDelayLengthMinus1( uiCode ); |
---|
616 | READ_CODE( 5, uiCode, "au_cpb_removal_delay_length_minus1" ); hrd->setCpbRemovalDelayLengthMinus1( uiCode ); |
---|
617 | READ_CODE( 5, uiCode, "dpb_output_delay_length_minus1" ); hrd->setDpbOutputDelayLengthMinus1( uiCode ); |
---|
618 | } |
---|
619 | #if SVC_EXTENSION |
---|
620 | else |
---|
621 | { |
---|
622 | hrd->setInitialCpbRemovalDelayLengthMinus1( 23 ); |
---|
623 | // Add inferred values for other syntax elements here. |
---|
624 | } |
---|
625 | #endif |
---|
626 | } |
---|
627 | Int i, j, nalOrVcl; |
---|
628 | for( i = 0; i <= maxNumSubLayersMinus1; i ++ ) |
---|
629 | { |
---|
630 | READ_FLAG( uiCode, "fixed_pic_rate_general_flag" ); hrd->setFixedPicRateFlag( i, uiCode == 1 ? true : false ); |
---|
631 | if( !hrd->getFixedPicRateFlag( i ) ) |
---|
632 | { |
---|
633 | READ_FLAG( uiCode, "fixed_pic_rate_within_cvs_flag" ); hrd->setFixedPicRateWithinCvsFlag( i, uiCode == 1 ? true : false ); |
---|
634 | } |
---|
635 | else |
---|
636 | { |
---|
637 | hrd->setFixedPicRateWithinCvsFlag( i, true ); |
---|
638 | } |
---|
639 | |
---|
640 | hrd->setLowDelayHrdFlag( i, 0 ); // Infered to be 0 when not present |
---|
641 | hrd->setCpbCntMinus1 ( i, 0 ); // Infered to be 0 when not present |
---|
642 | |
---|
643 | if( hrd->getFixedPicRateWithinCvsFlag( i ) ) |
---|
644 | { |
---|
645 | READ_UVLC( uiCode, "elemental_duration_in_tc_minus1" ); hrd->setPicDurationInTcMinus1( i, uiCode ); |
---|
646 | } |
---|
647 | else |
---|
648 | { |
---|
649 | READ_FLAG( uiCode, "low_delay_hrd_flag" ); hrd->setLowDelayHrdFlag( i, uiCode == 1 ? true : false ); |
---|
650 | } |
---|
651 | if (!hrd->getLowDelayHrdFlag( i )) |
---|
652 | { |
---|
653 | READ_UVLC( uiCode, "cpb_cnt_minus1" ); hrd->setCpbCntMinus1( i, uiCode ); |
---|
654 | } |
---|
655 | |
---|
656 | for( nalOrVcl = 0; nalOrVcl < 2; nalOrVcl ++ ) |
---|
657 | { |
---|
658 | if( ( ( nalOrVcl == 0 ) && ( hrd->getNalHrdParametersPresentFlag() ) ) || |
---|
659 | ( ( nalOrVcl == 1 ) && ( hrd->getVclHrdParametersPresentFlag() ) ) ) |
---|
660 | { |
---|
661 | for( j = 0; j <= ( hrd->getCpbCntMinus1( i ) ); j ++ ) |
---|
662 | { |
---|
663 | READ_UVLC( uiCode, "bit_rate_value_minus1" ); hrd->setBitRateValueMinus1( i, j, nalOrVcl, uiCode ); |
---|
664 | READ_UVLC( uiCode, "cpb_size_value_minus1" ); hrd->setCpbSizeValueMinus1( i, j, nalOrVcl, uiCode ); |
---|
665 | if( hrd->getSubPicCpbParamsPresentFlag() ) |
---|
666 | { |
---|
667 | READ_UVLC( uiCode, "cpb_size_du_value_minus1" ); hrd->setDuCpbSizeValueMinus1( i, j, nalOrVcl, uiCode ); |
---|
668 | READ_UVLC( uiCode, "bit_rate_du_value_minus1" ); hrd->setDuBitRateValueMinus1( i, j, nalOrVcl, uiCode ); |
---|
669 | } |
---|
670 | READ_FLAG( uiCode, "cbr_flag" ); hrd->setCbrFlag( i, j, nalOrVcl, uiCode == 1 ? true : false ); |
---|
671 | } |
---|
672 | } |
---|
673 | } |
---|
674 | } |
---|
675 | } |
---|
676 | |
---|
677 | Void TDecCavlc::parseSPS(TComSPS* pcSPS) |
---|
678 | { |
---|
679 | #if ENC_DEC_TRACE |
---|
680 | xTraceSPSHeader (pcSPS); |
---|
681 | #endif |
---|
682 | |
---|
683 | UInt uiCode; |
---|
684 | READ_CODE( 4, uiCode, "sps_video_parameter_set_id"); pcSPS->setVPSId ( uiCode ); |
---|
685 | |
---|
686 | #if SVC_EXTENSION |
---|
687 | UInt uiTmp = 0; |
---|
688 | |
---|
689 | if(pcSPS->getLayerId() == 0) |
---|
690 | { |
---|
691 | #endif |
---|
692 | READ_CODE( 3, uiCode, "sps_max_sub_layers_minus1" ); pcSPS->setMaxTLayers ( uiCode+1 ); |
---|
693 | assert(uiCode <= 6); |
---|
694 | #if SVC_EXTENSION |
---|
695 | } |
---|
696 | else |
---|
697 | { |
---|
698 | READ_CODE( 3, uiCode, "sps_ext_or_max_sub_layers_minus1" ); uiTmp = uiCode; |
---|
699 | |
---|
700 | if( uiTmp != 7 ) |
---|
701 | { |
---|
702 | pcSPS->setMaxTLayers(uiTmp + 1); |
---|
703 | } |
---|
704 | } |
---|
705 | |
---|
706 | pcSPS->setMultiLayerExtSpsFlag( pcSPS->getLayerId() != 0 && uiTmp == 7 ); |
---|
707 | |
---|
708 | if( !pcSPS->getMultiLayerExtSpsFlag() ) |
---|
709 | { |
---|
710 | #endif |
---|
711 | READ_FLAG( uiCode, "sps_temporal_id_nesting_flag" ); pcSPS->setTemporalIdNestingFlag ( uiCode > 0 ? true : false ); |
---|
712 | parsePTL(pcSPS->getPTL(), 1, pcSPS->getMaxTLayers() - 1); |
---|
713 | #if SVC_EXTENSION |
---|
714 | } |
---|
715 | #else |
---|
716 | if ( pcSPS->getMaxTLayers() == 1 ) |
---|
717 | { |
---|
718 | // sps_temporal_id_nesting_flag must be 1 when sps_max_sub_layers_minus1 is 0 |
---|
719 | assert( uiCode == 1 ); |
---|
720 | } |
---|
721 | #endif |
---|
722 | |
---|
723 | READ_UVLC( uiCode, "sps_seq_parameter_set_id" ); pcSPS->setSPSId( uiCode ); |
---|
724 | assert(uiCode <= 15); |
---|
725 | |
---|
726 | #if SVC_EXTENSION |
---|
727 | if( pcSPS->getMultiLayerExtSpsFlag() ) |
---|
728 | { |
---|
729 | READ_FLAG( uiCode, "update_rep_format_flag" ); |
---|
730 | pcSPS->setUpdateRepFormatFlag( uiCode ? true : false ); |
---|
731 | |
---|
732 | if( pcSPS->getUpdateRepFormatFlag() ) |
---|
733 | { |
---|
734 | READ_CODE(8, uiCode, "sps_rep_format_idx"); |
---|
735 | pcSPS->setUpdateRepFormatIndex(uiCode); |
---|
736 | } |
---|
737 | } |
---|
738 | else |
---|
739 | { |
---|
740 | pcSPS->setUpdateRepFormatFlag( false ); |
---|
741 | #endif |
---|
742 | READ_UVLC( uiCode, "chroma_format_idc" ); pcSPS->setChromaFormatIdc( ChromaFormat(uiCode) ); |
---|
743 | assert(uiCode <= 3); |
---|
744 | |
---|
745 | if( pcSPS->getChromaFormatIdc() == CHROMA_444 ) |
---|
746 | { |
---|
747 | READ_FLAG( uiCode, "separate_colour_plane_flag"); assert(uiCode == 0); |
---|
748 | } |
---|
749 | |
---|
750 | READ_UVLC ( uiCode, "pic_width_in_luma_samples" ); pcSPS->setPicWidthInLumaSamples ( uiCode ); |
---|
751 | READ_UVLC ( uiCode, "pic_height_in_luma_samples" ); pcSPS->setPicHeightInLumaSamples( uiCode ); |
---|
752 | READ_FLAG( uiCode, "conformance_window_flag"); |
---|
753 | if (uiCode != 0) |
---|
754 | { |
---|
755 | Window &conf = pcSPS->getConformanceWindow(); |
---|
756 | #if SVC_EXTENSION |
---|
757 | READ_UVLC( uiCode, "conf_win_left_offset" ); conf.setWindowLeftOffset ( uiCode ); |
---|
758 | READ_UVLC( uiCode, "conf_win_right_offset" ); conf.setWindowRightOffset ( uiCode ); |
---|
759 | READ_UVLC( uiCode, "conf_win_top_offset" ); conf.setWindowTopOffset ( uiCode ); |
---|
760 | READ_UVLC( uiCode, "conf_win_bottom_offset" ); conf.setWindowBottomOffset( uiCode ); |
---|
761 | #else |
---|
762 | READ_UVLC( uiCode, "conf_win_left_offset" ); conf.setWindowLeftOffset ( uiCode * TComSPS::getWinUnitX( pcSPS->getChromaFormatIdc() ) ); |
---|
763 | READ_UVLC( uiCode, "conf_win_right_offset" ); conf.setWindowRightOffset ( uiCode * TComSPS::getWinUnitX( pcSPS->getChromaFormatIdc() ) ); |
---|
764 | READ_UVLC( uiCode, "conf_win_top_offset" ); conf.setWindowTopOffset ( uiCode * TComSPS::getWinUnitY( pcSPS->getChromaFormatIdc() ) ); |
---|
765 | READ_UVLC( uiCode, "conf_win_bottom_offset" ); conf.setWindowBottomOffset( uiCode * TComSPS::getWinUnitY( pcSPS->getChromaFormatIdc() ) ); |
---|
766 | #endif |
---|
767 | } |
---|
768 | |
---|
769 | READ_UVLC( uiCode, "bit_depth_luma_minus8" ); |
---|
770 | #if O0043_BEST_EFFORT_DECODING |
---|
771 | pcSPS->setStreamBitDepth(CHANNEL_TYPE_LUMA, 8 + uiCode); |
---|
772 | const UInt forceDecodeBitDepth = pcSPS->getForceDecodeBitDepth(); |
---|
773 | if (forceDecodeBitDepth != 0) |
---|
774 | { |
---|
775 | uiCode = forceDecodeBitDepth - 8; |
---|
776 | } |
---|
777 | #endif |
---|
778 | assert(uiCode <= 8); |
---|
779 | pcSPS->setBitDepth(CHANNEL_TYPE_LUMA, 8 + uiCode); |
---|
780 | |
---|
781 | #if O0043_BEST_EFFORT_DECODING |
---|
782 | pcSPS->setQpBDOffset(CHANNEL_TYPE_LUMA, (Int) (6*(pcSPS->getStreamBitDepth(CHANNEL_TYPE_LUMA)-8)) ); |
---|
783 | #else |
---|
784 | pcSPS->setQpBDOffset(CHANNEL_TYPE_LUMA, (Int) (6*uiCode) ); |
---|
785 | #endif |
---|
786 | |
---|
787 | READ_UVLC( uiCode, "bit_depth_chroma_minus8" ); |
---|
788 | #if O0043_BEST_EFFORT_DECODING |
---|
789 | pcSPS->setStreamBitDepth(CHANNEL_TYPE_CHROMA, 8 + uiCode); |
---|
790 | if (forceDecodeBitDepth != 0) |
---|
791 | { |
---|
792 | uiCode = forceDecodeBitDepth - 8; |
---|
793 | } |
---|
794 | #endif |
---|
795 | assert(uiCode <= 8); |
---|
796 | pcSPS->setBitDepth(CHANNEL_TYPE_CHROMA, 8 + uiCode); |
---|
797 | #if O0043_BEST_EFFORT_DECODING |
---|
798 | pcSPS->setQpBDOffset(CHANNEL_TYPE_CHROMA, (Int) (6*(pcSPS->getStreamBitDepth(CHANNEL_TYPE_CHROMA)-8)) ); |
---|
799 | #else |
---|
800 | pcSPS->setQpBDOffset(CHANNEL_TYPE_CHROMA, (Int) (6*uiCode) ); |
---|
801 | #endif |
---|
802 | |
---|
803 | #if SVC_EXTENSION |
---|
804 | } |
---|
805 | #endif |
---|
806 | |
---|
807 | |
---|
808 | READ_UVLC( uiCode, "log2_max_pic_order_cnt_lsb_minus4" ); pcSPS->setBitsForPOC( 4 + uiCode ); |
---|
809 | assert(uiCode <= 12); |
---|
810 | |
---|
811 | #if SVC_EXTENSION |
---|
812 | if( !pcSPS->getMultiLayerExtSpsFlag() ) |
---|
813 | { |
---|
814 | #endif |
---|
815 | UInt subLayerOrderingInfoPresentFlag; |
---|
816 | READ_FLAG(subLayerOrderingInfoPresentFlag, "sps_sub_layer_ordering_info_present_flag"); |
---|
817 | |
---|
818 | for(UInt i=0; i <= pcSPS->getMaxTLayers()-1; i++) |
---|
819 | { |
---|
820 | READ_UVLC ( uiCode, "sps_max_dec_pic_buffering_minus1[i]"); |
---|
821 | pcSPS->setMaxDecPicBuffering( uiCode + 1, i); |
---|
822 | READ_UVLC ( uiCode, "sps_max_num_reorder_pics[i]" ); |
---|
823 | pcSPS->setNumReorderPics(uiCode, i); |
---|
824 | READ_UVLC ( uiCode, "sps_max_latency_increase_plus1[i]"); |
---|
825 | pcSPS->setMaxLatencyIncrease( uiCode, i ); |
---|
826 | |
---|
827 | if (!subLayerOrderingInfoPresentFlag) |
---|
828 | { |
---|
829 | for (i++; i <= pcSPS->getMaxTLayers()-1; i++) |
---|
830 | { |
---|
831 | pcSPS->setMaxDecPicBuffering(pcSPS->getMaxDecPicBuffering(0), i); |
---|
832 | pcSPS->setNumReorderPics(pcSPS->getNumReorderPics(0), i); |
---|
833 | pcSPS->setMaxLatencyIncrease(pcSPS->getMaxLatencyIncrease(0), i); |
---|
834 | } |
---|
835 | break; |
---|
836 | } |
---|
837 | |
---|
838 | #if SVC_EXTENSION |
---|
839 | if( i > 0 ) |
---|
840 | { |
---|
841 | // When i is greater than 0, sps_max_dec_pic_buffering_minus1[ i ] shall be greater than or equal to sps_max_dec_pic_buffering_minus1[ i - 1 ]. |
---|
842 | assert( pcSPS->getMaxDecPicBuffering(i) >= pcSPS->getMaxDecPicBuffering(i-1) ); |
---|
843 | } |
---|
844 | #endif |
---|
845 | |
---|
846 | } |
---|
847 | #if SVC_EXTENSION |
---|
848 | } |
---|
849 | #endif |
---|
850 | READ_UVLC( uiCode, "log2_min_luma_coding_block_size_minus3" ); |
---|
851 | Int log2MinCUSize = uiCode + 3; |
---|
852 | pcSPS->setLog2MinCodingBlockSize(log2MinCUSize); |
---|
853 | READ_UVLC( uiCode, "log2_diff_max_min_luma_coding_block_size" ); |
---|
854 | pcSPS->setLog2DiffMaxMinCodingBlockSize(uiCode); |
---|
855 | |
---|
856 | if (pcSPS->getPTL()->getGeneralPTL()->getLevelIdc() >= Level::LEVEL5) |
---|
857 | { |
---|
858 | assert(log2MinCUSize + pcSPS->getLog2DiffMaxMinCodingBlockSize() >= 5); |
---|
859 | } |
---|
860 | |
---|
861 | Int maxCUDepthDelta = uiCode; |
---|
862 | pcSPS->setMaxCUWidth ( 1<<(log2MinCUSize + maxCUDepthDelta) ); |
---|
863 | pcSPS->setMaxCUHeight ( 1<<(log2MinCUSize + maxCUDepthDelta) ); |
---|
864 | READ_UVLC( uiCode, "log2_min_luma_transform_block_size_minus2" ); pcSPS->setQuadtreeTULog2MinSize( uiCode + 2 ); |
---|
865 | |
---|
866 | READ_UVLC( uiCode, "log2_diff_max_min_luma_transform_block_size" ); pcSPS->setQuadtreeTULog2MaxSize( uiCode + pcSPS->getQuadtreeTULog2MinSize() ); |
---|
867 | pcSPS->setMaxTrSize( 1<<(uiCode + pcSPS->getQuadtreeTULog2MinSize()) ); |
---|
868 | |
---|
869 | READ_UVLC( uiCode, "max_transform_hierarchy_depth_inter" ); pcSPS->setQuadtreeTUMaxDepthInter( uiCode+1 ); |
---|
870 | READ_UVLC( uiCode, "max_transform_hierarchy_depth_intra" ); pcSPS->setQuadtreeTUMaxDepthIntra( uiCode+1 ); |
---|
871 | |
---|
872 | Int addCuDepth = max (0, log2MinCUSize - (Int)pcSPS->getQuadtreeTULog2MinSize() ); |
---|
873 | pcSPS->setMaxTotalCUDepth( maxCUDepthDelta + addCuDepth + getMaxCUDepthOffset(pcSPS->getChromaFormatIdc(), pcSPS->getQuadtreeTULog2MinSize()) ); |
---|
874 | |
---|
875 | READ_FLAG( uiCode, "scaling_list_enabled_flag" ); pcSPS->setScalingListFlag ( uiCode ); |
---|
876 | if(pcSPS->getScalingListFlag()) |
---|
877 | { |
---|
878 | #if SVC_EXTENSION |
---|
879 | if( pcSPS->getMultiLayerExtSpsFlag() ) |
---|
880 | { |
---|
881 | READ_FLAG( uiCode, "sps_infer_scaling_list_flag" ); pcSPS->setInferScalingListFlag( uiCode ); |
---|
882 | } |
---|
883 | |
---|
884 | if( pcSPS->getInferScalingListFlag() ) |
---|
885 | { |
---|
886 | READ_CODE( 6, uiCode, "sps_scaling_list_ref_layer_id" ); pcSPS->setScalingListRefLayerId( uiCode ); |
---|
887 | |
---|
888 | // The value of sps_scaling_list_ref_layer_id shall be in the range of 0 to 62, inclusive |
---|
889 | assert( pcSPS->getScalingListRefLayerId() <= 62 ); |
---|
890 | |
---|
891 | pcSPS->setScalingListPresentFlag( false ); |
---|
892 | } |
---|
893 | else |
---|
894 | { |
---|
895 | #endif |
---|
896 | READ_FLAG( uiCode, "sps_scaling_list_data_present_flag" ); pcSPS->setScalingListPresentFlag ( uiCode ); |
---|
897 | if(pcSPS->getScalingListPresentFlag ()) |
---|
898 | { |
---|
899 | parseScalingList( &(pcSPS->getScalingList()) ); |
---|
900 | } |
---|
901 | #if SVC_EXTENSION |
---|
902 | } |
---|
903 | #endif |
---|
904 | } |
---|
905 | READ_FLAG( uiCode, "amp_enabled_flag" ); pcSPS->setUseAMP( uiCode ); |
---|
906 | READ_FLAG( uiCode, "sample_adaptive_offset_enabled_flag" ); pcSPS->setUseSAO ( uiCode ? true : false ); |
---|
907 | |
---|
908 | READ_FLAG( uiCode, "pcm_enabled_flag" ); pcSPS->setUsePCM( uiCode ? true : false ); |
---|
909 | if( pcSPS->getUsePCM() ) |
---|
910 | { |
---|
911 | READ_CODE( 4, uiCode, "pcm_sample_bit_depth_luma_minus1" ); pcSPS->setPCMBitDepth ( CHANNEL_TYPE_LUMA, 1 + uiCode ); |
---|
912 | READ_CODE( 4, uiCode, "pcm_sample_bit_depth_chroma_minus1" ); pcSPS->setPCMBitDepth ( CHANNEL_TYPE_CHROMA, 1 + uiCode ); |
---|
913 | READ_UVLC( uiCode, "log2_min_pcm_luma_coding_block_size_minus3" ); pcSPS->setPCMLog2MinSize (uiCode+3); |
---|
914 | READ_UVLC( uiCode, "log2_diff_max_min_pcm_luma_coding_block_size" ); pcSPS->setPCMLog2MaxSize ( uiCode+pcSPS->getPCMLog2MinSize() ); |
---|
915 | READ_FLAG( uiCode, "pcm_loop_filter_disable_flag" ); pcSPS->setPCMFilterDisableFlag ( uiCode ? true : false ); |
---|
916 | } |
---|
917 | |
---|
918 | READ_UVLC( uiCode, "num_short_term_ref_pic_sets" ); |
---|
919 | assert(uiCode <= 64); |
---|
920 | pcSPS->createRPSList(uiCode); |
---|
921 | |
---|
922 | TComRPSList* rpsList = pcSPS->getRPSList(); |
---|
923 | TComReferencePictureSet* rps; |
---|
924 | |
---|
925 | for(UInt i=0; i< rpsList->getNumberOfReferencePictureSets(); i++) |
---|
926 | { |
---|
927 | rps = rpsList->getReferencePictureSet(i); |
---|
928 | parseShortTermRefPicSet(pcSPS,rps,i); |
---|
929 | } |
---|
930 | READ_FLAG( uiCode, "long_term_ref_pics_present_flag" ); pcSPS->setLongTermRefsPresent(uiCode); |
---|
931 | if (pcSPS->getLongTermRefsPresent()) |
---|
932 | { |
---|
933 | READ_UVLC( uiCode, "num_long_term_ref_pics_sps" ); |
---|
934 | pcSPS->setNumLongTermRefPicSPS(uiCode); |
---|
935 | for (UInt k = 0; k < pcSPS->getNumLongTermRefPicSPS(); k++) |
---|
936 | { |
---|
937 | READ_CODE( pcSPS->getBitsForPOC(), uiCode, "lt_ref_pic_poc_lsb_sps" ); |
---|
938 | pcSPS->setLtRefPicPocLsbSps(k, uiCode); |
---|
939 | READ_FLAG( uiCode, "used_by_curr_pic_lt_sps_flag[i]"); |
---|
940 | pcSPS->setUsedByCurrPicLtSPSFlag(k, uiCode?1:0); |
---|
941 | } |
---|
942 | } |
---|
943 | READ_FLAG( uiCode, "sps_temporal_mvp_enable_flag" ); pcSPS->setTMVPFlagsPresent(uiCode); |
---|
944 | |
---|
945 | READ_FLAG( uiCode, "sps_strong_intra_smoothing_enable_flag" ); pcSPS->setUseStrongIntraSmoothing(uiCode); |
---|
946 | |
---|
947 | READ_FLAG( uiCode, "vui_parameters_present_flag" ); pcSPS->setVuiParametersPresentFlag(uiCode); |
---|
948 | |
---|
949 | if (pcSPS->getVuiParametersPresentFlag()) |
---|
950 | { |
---|
951 | parseVUI(pcSPS->getVuiParameters(), pcSPS); |
---|
952 | } |
---|
953 | |
---|
954 | READ_FLAG( uiCode, "sps_extension_present_flag"); |
---|
955 | |
---|
956 | #if SVC_EXTENSION |
---|
957 | pcSPS->setExtensionFlag( uiCode ? true : false ); |
---|
958 | |
---|
959 | if( pcSPS->getExtensionFlag() ) |
---|
960 | #else |
---|
961 | if (uiCode) |
---|
962 | #endif |
---|
963 | { |
---|
964 | #if ENC_DEC_TRACE || RExt__DECODER_DEBUG_BIT_STATISTICS |
---|
965 | static const char *syntaxStrings[]={ "sps_range_extension_flag", |
---|
966 | "sps_multilayer_extension_flag", |
---|
967 | "sps_extension_6bits[0]", |
---|
968 | "sps_extension_6bits[1]", |
---|
969 | "sps_extension_6bits[2]", |
---|
970 | "sps_extension_6bits[3]", |
---|
971 | "sps_extension_6bits[4]", |
---|
972 | "sps_extension_6bits[5]" }; |
---|
973 | #endif |
---|
974 | Bool sps_extension_flags[NUM_SPS_EXTENSION_FLAGS]; |
---|
975 | |
---|
976 | for(Int i=0; i<NUM_SPS_EXTENSION_FLAGS; i++) |
---|
977 | { |
---|
978 | READ_FLAG( uiCode, syntaxStrings[i] ); |
---|
979 | sps_extension_flags[i] = uiCode!=0; |
---|
980 | } |
---|
981 | |
---|
982 | Bool bSkipTrailingExtensionBits=false; |
---|
983 | for(Int i=0; i<NUM_SPS_EXTENSION_FLAGS; i++) // loop used so that the order is determined by the enum. |
---|
984 | { |
---|
985 | if (sps_extension_flags[i]) |
---|
986 | { |
---|
987 | switch (SPSExtensionFlagIndex(i)) |
---|
988 | { |
---|
989 | case SPS_EXT__REXT: |
---|
990 | assert(!bSkipTrailingExtensionBits); |
---|
991 | { |
---|
992 | TComSPSRExt &spsRangeExtension = pcSPS->getSpsRangeExtension(); |
---|
993 | READ_FLAG( uiCode, "transform_skip_rotation_enabled_flag"); spsRangeExtension.setTransformSkipRotationEnabledFlag(uiCode != 0); |
---|
994 | READ_FLAG( uiCode, "transform_skip_context_enabled_flag"); spsRangeExtension.setTransformSkipContextEnabledFlag (uiCode != 0); |
---|
995 | READ_FLAG( uiCode, "implicit_rdpcm_enabled_flag"); spsRangeExtension.setRdpcmEnabledFlag(RDPCM_SIGNAL_IMPLICIT, (uiCode != 0)); |
---|
996 | READ_FLAG( uiCode, "explicit_rdpcm_enabled_flag"); spsRangeExtension.setRdpcmEnabledFlag(RDPCM_SIGNAL_EXPLICIT, (uiCode != 0)); |
---|
997 | READ_FLAG( uiCode, "extended_precision_processing_flag"); spsRangeExtension.setExtendedPrecisionProcessingFlag (uiCode != 0); |
---|
998 | READ_FLAG( uiCode, "intra_smoothing_disabled_flag"); spsRangeExtension.setIntraSmoothingDisabledFlag (uiCode != 0); |
---|
999 | READ_FLAG( uiCode, "high_precision_offsets_enabled_flag"); spsRangeExtension.setHighPrecisionOffsetsEnabledFlag (uiCode != 0); |
---|
1000 | READ_FLAG( uiCode, "persistent_rice_adaptation_enabled_flag"); spsRangeExtension.setPersistentRiceAdaptationEnabledFlag (uiCode != 0); |
---|
1001 | READ_FLAG( uiCode, "cabac_bypass_alignment_enabled_flag"); spsRangeExtension.setCabacBypassAlignmentEnabledFlag (uiCode != 0); |
---|
1002 | } |
---|
1003 | break; |
---|
1004 | #if SVC_EXTENSION |
---|
1005 | case SPS_EXT__MLAYER: |
---|
1006 | parseSPSExtension( pcSPS ); |
---|
1007 | break; |
---|
1008 | #endif |
---|
1009 | default: |
---|
1010 | bSkipTrailingExtensionBits=true; |
---|
1011 | break; |
---|
1012 | } |
---|
1013 | } |
---|
1014 | } |
---|
1015 | if (bSkipTrailingExtensionBits) |
---|
1016 | { |
---|
1017 | while ( xMoreRbspData() ) |
---|
1018 | { |
---|
1019 | READ_FLAG( uiCode, "sps_extension_data_flag"); |
---|
1020 | } |
---|
1021 | } |
---|
1022 | } |
---|
1023 | } |
---|
1024 | |
---|
1025 | Void TDecCavlc::parseVPS(TComVPS* pcVPS) |
---|
1026 | { |
---|
1027 | UInt uiCode; |
---|
1028 | |
---|
1029 | READ_CODE( 4, uiCode, "vps_video_parameter_set_id" ); pcVPS->setVPSId( uiCode ); |
---|
1030 | #if SVC_EXTENSION |
---|
1031 | READ_FLAG( uiCode, "vps_base_layer_internal_flag"); pcVPS->setBaseLayerInternalFlag( uiCode ? true : false ); |
---|
1032 | READ_FLAG( uiCode, "vps_base_layer_available_flag"); pcVPS->setBaseLayerAvailableFlag( uiCode ? true : false ); |
---|
1033 | pcVPS->setNonHEVCBaseLayerFlag( (pcVPS->getBaseLayerAvailableFlag() && !pcVPS->getBaseLayerInternalFlag()) ? true : false); |
---|
1034 | |
---|
1035 | READ_CODE( 6, uiCode, "vps_max_layers_minus1" ); pcVPS->setMaxLayers( min( 62u, uiCode) + 1 ); |
---|
1036 | assert( pcVPS->getBaseLayerInternalFlag() || pcVPS->getMaxLayers() > 1 ); |
---|
1037 | #else |
---|
1038 | READ_FLAG( uiCode, "vps_base_layer_internal_flag" ); assert(uiCode == 1); |
---|
1039 | READ_FLAG( uiCode, "vps_base_layer_available_flag" ); assert(uiCode == 1); |
---|
1040 | READ_CODE( 6, uiCode, "vps_max_layers_minus1" ); |
---|
1041 | #endif |
---|
1042 | READ_CODE( 3, uiCode, "vps_max_sub_layers_minus1" ); pcVPS->setMaxTLayers( uiCode + 1 ); assert(uiCode+1 <= MAX_TLAYER); |
---|
1043 | READ_FLAG( uiCode, "vps_temporal_id_nesting_flag" ); pcVPS->setTemporalNestingFlag( uiCode ? true:false ); |
---|
1044 | assert (pcVPS->getMaxTLayers()>1||pcVPS->getTemporalNestingFlag()); |
---|
1045 | READ_CODE( 16, uiCode, "vps_reserved_0xffff_16bits" ); assert(uiCode == 0xffff); |
---|
1046 | parsePTL ( pcVPS->getPTL(), true, pcVPS->getMaxTLayers()-1); |
---|
1047 | UInt subLayerOrderingInfoPresentFlag; |
---|
1048 | READ_FLAG(subLayerOrderingInfoPresentFlag, "vps_sub_layer_ordering_info_present_flag"); |
---|
1049 | for(UInt i = 0; i <= pcVPS->getMaxTLayers()-1; i++) |
---|
1050 | { |
---|
1051 | READ_UVLC( uiCode, "vps_max_dec_pic_buffering_minus1[i]" ); pcVPS->setMaxDecPicBuffering( uiCode + 1, i ); |
---|
1052 | READ_UVLC( uiCode, "vps_max_num_reorder_pics[i]" ); pcVPS->setNumReorderPics( uiCode, i ); |
---|
1053 | READ_UVLC( uiCode, "vps_max_latency_increase_plus1[i]" ); pcVPS->setMaxLatencyIncrease( uiCode, i ); |
---|
1054 | |
---|
1055 | if (!subLayerOrderingInfoPresentFlag) |
---|
1056 | { |
---|
1057 | for (i++; i <= pcVPS->getMaxTLayers()-1; i++) |
---|
1058 | { |
---|
1059 | pcVPS->setMaxDecPicBuffering(pcVPS->getMaxDecPicBuffering(0), i); |
---|
1060 | pcVPS->setNumReorderPics(pcVPS->getNumReorderPics(0), i); |
---|
1061 | pcVPS->setMaxLatencyIncrease(pcVPS->getMaxLatencyIncrease(0), i); |
---|
1062 | } |
---|
1063 | break; |
---|
1064 | } |
---|
1065 | } |
---|
1066 | |
---|
1067 | #if SVC_EXTENSION |
---|
1068 | assert( pcVPS->getNumHrdParameters() < MAX_VPS_LAYER_SETS_PLUS1 ); |
---|
1069 | assert( pcVPS->getMaxLayerId() < MAX_NUM_LAYER_IDS ); |
---|
1070 | READ_CODE( 6, uiCode, "vps_max_layer_id" ); pcVPS->setMaxLayerId( uiCode ); |
---|
1071 | READ_UVLC(uiCode, "vps_num_layer_sets_minus1"); pcVPS->setVpsNumLayerSetsMinus1(uiCode); |
---|
1072 | pcVPS->setNumLayerSets(pcVPS->getVpsNumLayerSetsMinus1() + 1); |
---|
1073 | |
---|
1074 | for (UInt opsIdx = 1; opsIdx <= pcVPS->getVpsNumLayerSetsMinus1(); opsIdx++) |
---|
1075 | { |
---|
1076 | // Operation point set |
---|
1077 | for( UInt i = 0; i <= pcVPS->getMaxLayerId(); i ++ ) |
---|
1078 | #else |
---|
1079 | assert( pcVPS->getNumHrdParameters() < MAX_VPS_OP_SETS_PLUS1 ); |
---|
1080 | assert( pcVPS->getMaxNuhReservedZeroLayerId() < MAX_VPS_NUH_RESERVED_ZERO_LAYER_ID_PLUS1 ); |
---|
1081 | READ_CODE( 6, uiCode, "vps_max_layer_id" ); pcVPS->setMaxNuhReservedZeroLayerId( uiCode ); |
---|
1082 | READ_UVLC( uiCode, "vps_num_layer_sets_minus1" ); pcVPS->setMaxOpSets( uiCode + 1 ); |
---|
1083 | for( UInt opsIdx = 1; opsIdx <= ( pcVPS->getMaxOpSets() - 1 ); opsIdx ++ ) |
---|
1084 | { |
---|
1085 | // Operation point set |
---|
1086 | for( UInt i = 0; i <= pcVPS->getMaxNuhReservedZeroLayerId(); i ++ ) |
---|
1087 | #endif |
---|
1088 | { |
---|
1089 | READ_FLAG( uiCode, "layer_id_included_flag[opsIdx][i]" ); pcVPS->setLayerIdIncludedFlag( uiCode == 1 ? true : false, opsIdx, i ); |
---|
1090 | } |
---|
1091 | } |
---|
1092 | |
---|
1093 | #if SVC_EXTENSION |
---|
1094 | pcVPS->deriveLayerIdListVariables(); |
---|
1095 | #endif |
---|
1096 | |
---|
1097 | TimingInfo *timingInfo = pcVPS->getTimingInfo(); |
---|
1098 | READ_FLAG( uiCode, "vps_timing_info_present_flag"); timingInfo->setTimingInfoPresentFlag (uiCode ? true : false); |
---|
1099 | if(timingInfo->getTimingInfoPresentFlag()) |
---|
1100 | { |
---|
1101 | READ_CODE( 32, uiCode, "vps_num_units_in_tick"); timingInfo->setNumUnitsInTick (uiCode); |
---|
1102 | READ_CODE( 32, uiCode, "vps_time_scale"); timingInfo->setTimeScale (uiCode); |
---|
1103 | READ_FLAG( uiCode, "vps_poc_proportional_to_timing_flag"); timingInfo->setPocProportionalToTimingFlag(uiCode ? true : false); |
---|
1104 | if(timingInfo->getPocProportionalToTimingFlag()) |
---|
1105 | { |
---|
1106 | READ_UVLC( uiCode, "vps_num_ticks_poc_diff_one_minus1"); timingInfo->setNumTicksPocDiffOneMinus1 (uiCode); |
---|
1107 | } |
---|
1108 | |
---|
1109 | READ_UVLC( uiCode, "vps_num_hrd_parameters" ); pcVPS->setNumHrdParameters( uiCode ); |
---|
1110 | |
---|
1111 | if( pcVPS->getNumHrdParameters() > 0 ) |
---|
1112 | { |
---|
1113 | pcVPS->createHrdParamBuffer(); |
---|
1114 | } |
---|
1115 | for( UInt i = 0; i < pcVPS->getNumHrdParameters(); i ++ ) |
---|
1116 | { |
---|
1117 | READ_UVLC( uiCode, "hrd_layer_set_idx[i]" ); pcVPS->setHrdOpSetIdx( uiCode, i ); |
---|
1118 | if( i > 0 ) |
---|
1119 | { |
---|
1120 | READ_FLAG( uiCode, "cprms_present_flag[i]" ); pcVPS->setCprmsPresentFlag( uiCode == 1 ? true : false, i ); |
---|
1121 | } |
---|
1122 | else |
---|
1123 | { |
---|
1124 | pcVPS->setCprmsPresentFlag( true, i ); |
---|
1125 | } |
---|
1126 | |
---|
1127 | parseHrdParameters(pcVPS->getHrdParameters(i), pcVPS->getCprmsPresentFlag( i ), pcVPS->getMaxTLayers() - 1); |
---|
1128 | } |
---|
1129 | } |
---|
1130 | |
---|
1131 | #if SVC_EXTENSION |
---|
1132 | READ_FLAG( uiCode, "vps_extension_flag" ); pcVPS->setVpsExtensionFlag( uiCode ? true : false ); |
---|
1133 | |
---|
1134 | // When MaxLayersMinus1 is greater than 0, vps_extension_flag shall be equal to 1. |
---|
1135 | if( pcVPS->getMaxLayers() > 1 ) |
---|
1136 | { |
---|
1137 | assert( pcVPS->getVpsExtensionFlag() == true ); |
---|
1138 | } |
---|
1139 | |
---|
1140 | if( pcVPS->getVpsExtensionFlag() ) |
---|
1141 | { |
---|
1142 | while ( m_pcBitstream->getNumBitsRead() % 8 != 0 ) |
---|
1143 | { |
---|
1144 | READ_FLAG( uiCode, "vps_extension_alignment_bit_equal_to_one"); assert(uiCode == 1); |
---|
1145 | } |
---|
1146 | parseVPSExtension(pcVPS); |
---|
1147 | READ_FLAG( uiCode, "vps_extension2_flag" ); |
---|
1148 | if(uiCode) |
---|
1149 | { |
---|
1150 | while ( xMoreRbspData() ) |
---|
1151 | { |
---|
1152 | READ_FLAG( uiCode, "vps_extension_data_flag"); |
---|
1153 | } |
---|
1154 | } |
---|
1155 | } |
---|
1156 | else |
---|
1157 | { |
---|
1158 | // set default parameters when syntax elements are not present |
---|
1159 | defaultVPSExtension(pcVPS); |
---|
1160 | } |
---|
1161 | #else |
---|
1162 | READ_FLAG( uiCode, "vps_extension_flag" ); |
---|
1163 | if (uiCode) |
---|
1164 | { |
---|
1165 | while ( xMoreRbspData() ) |
---|
1166 | { |
---|
1167 | READ_FLAG( uiCode, "vps_extension_data_flag"); |
---|
1168 | } |
---|
1169 | } |
---|
1170 | #endif |
---|
1171 | |
---|
1172 | return; |
---|
1173 | } |
---|
1174 | |
---|
1175 | Void TDecCavlc::parseSliceHeader (TComSlice* pcSlice, ParameterSetManager *parameterSetManager, const Int prevTid0POC) |
---|
1176 | { |
---|
1177 | UInt uiCode; |
---|
1178 | Int iCode; |
---|
1179 | |
---|
1180 | #if ENC_DEC_TRACE |
---|
1181 | xTraceSliceHeader(pcSlice); |
---|
1182 | #endif |
---|
1183 | TComPPS* pps = NULL; |
---|
1184 | TComSPS* sps = NULL; |
---|
1185 | |
---|
1186 | UInt firstSliceSegmentInPic; |
---|
1187 | READ_FLAG( firstSliceSegmentInPic, "first_slice_segment_in_pic_flag" ); |
---|
1188 | |
---|
1189 | #if SVC_EXTENSION |
---|
1190 | pcSlice->setFirstSliceInPic( firstSliceSegmentInPic ); |
---|
1191 | #endif |
---|
1192 | |
---|
1193 | if( pcSlice->getRapPicFlag()) |
---|
1194 | { |
---|
1195 | READ_FLAG( uiCode, "no_output_of_prior_pics_flag" ); //ignored -- updated already |
---|
1196 | pcSlice->setNoOutputPriorPicsFlag(uiCode ? true : false); |
---|
1197 | } |
---|
1198 | READ_UVLC ( uiCode, "slice_pic_parameter_set_id" ); pcSlice->setPPSId(uiCode); |
---|
1199 | pps = parameterSetManager->getPPS(uiCode); |
---|
1200 | //!KS: need to add error handling code here, if PPS is not available |
---|
1201 | assert(pps!=0); |
---|
1202 | sps = parameterSetManager->getSPS(pps->getSPSId()); |
---|
1203 | //!KS: need to add error handling code here, if SPS is not available |
---|
1204 | assert(sps!=0); |
---|
1205 | |
---|
1206 | #if SVC_EXTENSION |
---|
1207 | pcSlice->setSPS(sps); |
---|
1208 | pcSlice->setPPS(pps); |
---|
1209 | |
---|
1210 | TComVPS* vps = parameterSetManager->getVPS(sps->getVPSId()); |
---|
1211 | pcSlice->setVPS(vps); |
---|
1212 | |
---|
1213 | Int iPOClsb = 0; |
---|
1214 | #endif |
---|
1215 | |
---|
1216 | const ChromaFormat chFmt = sps->getChromaFormatIdc(); |
---|
1217 | const UInt numValidComp=getNumberValidComponents(chFmt); |
---|
1218 | const Bool bChroma=(chFmt!=CHROMA_400); |
---|
1219 | |
---|
1220 | if( pps->getDependentSliceSegmentsEnabledFlag() && ( !firstSliceSegmentInPic )) |
---|
1221 | { |
---|
1222 | READ_FLAG( uiCode, "dependent_slice_segment_flag" ); pcSlice->setDependentSliceSegmentFlag(uiCode ? true : false); |
---|
1223 | } |
---|
1224 | else |
---|
1225 | { |
---|
1226 | pcSlice->setDependentSliceSegmentFlag(false); |
---|
1227 | } |
---|
1228 | #if SVC_EXTENSION |
---|
1229 | Int numCTUs = ((pcSlice->getPicWidthInLumaSamples()+sps->getMaxCUWidth()-1)/sps->getMaxCUWidth())*((pcSlice->getPicHeightInLumaSamples()+sps->getMaxCUHeight()-1)/sps->getMaxCUHeight()); |
---|
1230 | #else |
---|
1231 | Int numCTUs = ((sps->getPicWidthInLumaSamples()+sps->getMaxCUWidth()-1)/sps->getMaxCUWidth())*((sps->getPicHeightInLumaSamples()+sps->getMaxCUHeight()-1)/sps->getMaxCUHeight()); |
---|
1232 | #endif |
---|
1233 | UInt sliceSegmentAddress = 0; |
---|
1234 | Int bitsSliceSegmentAddress = 0; |
---|
1235 | while(numCTUs>(1<<bitsSliceSegmentAddress)) |
---|
1236 | { |
---|
1237 | bitsSliceSegmentAddress++; |
---|
1238 | } |
---|
1239 | |
---|
1240 | if(!firstSliceSegmentInPic) |
---|
1241 | { |
---|
1242 | READ_CODE( bitsSliceSegmentAddress, sliceSegmentAddress, "slice_segment_address" ); |
---|
1243 | } |
---|
1244 | //set uiCode to equal slice start address (or dependent slice start address) |
---|
1245 | pcSlice->setSliceSegmentCurStartCtuTsAddr( sliceSegmentAddress );// this is actually a Raster-Scan (RS) address, but we do not have the RS->TS conversion table defined yet. |
---|
1246 | pcSlice->setSliceSegmentCurEndCtuTsAddr(numCTUs); // Set end as the last CTU of the picture. |
---|
1247 | |
---|
1248 | if (!pcSlice->getDependentSliceSegmentFlag()) |
---|
1249 | { |
---|
1250 | pcSlice->setSliceCurStartCtuTsAddr(sliceSegmentAddress); // this is actually a Raster-Scan (RS) address, but we do not have the RS->TS conversion table defined yet. |
---|
1251 | pcSlice->setSliceCurEndCtuTsAddr(numCTUs); |
---|
1252 | } |
---|
1253 | |
---|
1254 | if(!pcSlice->getDependentSliceSegmentFlag()) |
---|
1255 | { |
---|
1256 | #if SVC_EXTENSION |
---|
1257 | Int iBits = 0; |
---|
1258 | if(pps->getNumExtraSliceHeaderBits() > iBits) |
---|
1259 | { |
---|
1260 | READ_FLAG(uiCode, "discardable_flag"); |
---|
1261 | pcSlice->setDiscardableFlag( uiCode ? true : false ); |
---|
1262 | |
---|
1263 | if( uiCode ) |
---|
1264 | { |
---|
1265 | assert(pcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_TRAIL_R && |
---|
1266 | pcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_TSA_R && |
---|
1267 | pcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_STSA_R && |
---|
1268 | pcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_RADL_R && |
---|
1269 | pcSlice->getNalUnitType() != NAL_UNIT_CODED_SLICE_RASL_R); |
---|
1270 | } |
---|
1271 | |
---|
1272 | iBits++; |
---|
1273 | } |
---|
1274 | |
---|
1275 | if(pps->getNumExtraSliceHeaderBits() > iBits) |
---|
1276 | { |
---|
1277 | READ_FLAG(uiCode, "cross_layer_bla_flag"); pcSlice->setCrossLayerBLAFlag( uiCode ? true : false ); |
---|
1278 | iBits++; |
---|
1279 | } |
---|
1280 | |
---|
1281 | for ( ; iBits < pps->getNumExtraSliceHeaderBits(); iBits++) |
---|
1282 | { |
---|
1283 | READ_FLAG(uiCode, "slice_reserved_undetermined_flag[]"); // ignored |
---|
1284 | } |
---|
1285 | #else //SVC_EXTENSION |
---|
1286 | for (Int i = 0; i < pps->getNumExtraSliceHeaderBits(); i++) |
---|
1287 | { |
---|
1288 | READ_FLAG(uiCode, "slice_reserved_flag[]"); // ignored |
---|
1289 | } |
---|
1290 | #endif //SVC_EXTENSION |
---|
1291 | |
---|
1292 | READ_UVLC ( uiCode, "slice_type" ); pcSlice->setSliceType((SliceType)uiCode); |
---|
1293 | if( pps->getOutputFlagPresentFlag() ) |
---|
1294 | { |
---|
1295 | READ_FLAG( uiCode, "pic_output_flag" ); pcSlice->setPicOutputFlag( uiCode ? true : false ); |
---|
1296 | } |
---|
1297 | else |
---|
1298 | { |
---|
1299 | pcSlice->setPicOutputFlag( true ); |
---|
1300 | } |
---|
1301 | |
---|
1302 | // if (separate_colour_plane_flag == 1) |
---|
1303 | // read colour_plane_id |
---|
1304 | // (separate_colour_plane_flag == 1) is not supported in this version of the standard. |
---|
1305 | |
---|
1306 | if( pcSlice->getIdrPicFlag() ) |
---|
1307 | { |
---|
1308 | pcSlice->setPOC(0); |
---|
1309 | TComReferencePictureSet* rps = pcSlice->getLocalRPS(); |
---|
1310 | rps->setNumberOfNegativePictures(0); |
---|
1311 | rps->setNumberOfPositivePictures(0); |
---|
1312 | rps->setNumberOfLongtermPictures(0); |
---|
1313 | rps->setNumberOfPictures(0); |
---|
1314 | pcSlice->setRPS(rps); |
---|
1315 | } |
---|
1316 | |
---|
1317 | #if SVC_EXTENSION |
---|
1318 | if( ( pcSlice->getLayerId() > 0 && !vps->getPocLsbNotPresentFlag( vps->getLayerIdxInVps(pcSlice->getLayerId())) ) || !pcSlice->getIdrPicFlag() ) |
---|
1319 | #else |
---|
1320 | else |
---|
1321 | #endif |
---|
1322 | { |
---|
1323 | READ_CODE(sps->getBitsForPOC(), uiCode, "slice_pic_order_cnt_lsb"); |
---|
1324 | #if SVC_EXTENSION |
---|
1325 | pcSlice->setPicOrderCntLsb( uiCode ); |
---|
1326 | |
---|
1327 | iPOClsb = uiCode; |
---|
1328 | #else |
---|
1329 | Int iPOClsb = uiCode; |
---|
1330 | #endif |
---|
1331 | Int iPrevPOC = prevTid0POC; |
---|
1332 | Int iMaxPOClsb = 1<< sps->getBitsForPOC(); |
---|
1333 | Int iPrevPOClsb = iPrevPOC & (iMaxPOClsb - 1); |
---|
1334 | Int iPrevPOCmsb = iPrevPOC-iPrevPOClsb; |
---|
1335 | Int iPOCmsb; |
---|
1336 | if( ( iPOClsb < iPrevPOClsb ) && ( ( iPrevPOClsb - iPOClsb ) >= ( iMaxPOClsb / 2 ) ) ) |
---|
1337 | { |
---|
1338 | iPOCmsb = iPrevPOCmsb + iMaxPOClsb; |
---|
1339 | } |
---|
1340 | else if( (iPOClsb > iPrevPOClsb ) && ( (iPOClsb - iPrevPOClsb ) > ( iMaxPOClsb / 2 ) ) ) |
---|
1341 | { |
---|
1342 | iPOCmsb = iPrevPOCmsb - iMaxPOClsb; |
---|
1343 | } |
---|
1344 | else |
---|
1345 | { |
---|
1346 | iPOCmsb = iPrevPOCmsb; |
---|
1347 | } |
---|
1348 | if ( pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP |
---|
1349 | || pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL |
---|
1350 | || pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP ) |
---|
1351 | { |
---|
1352 | // For BLA picture types, POCmsb is set to 0. |
---|
1353 | iPOCmsb = 0; |
---|
1354 | } |
---|
1355 | pcSlice->setPOC (iPOCmsb+iPOClsb); |
---|
1356 | |
---|
1357 | #if SVC_EXTENSION |
---|
1358 | } |
---|
1359 | else |
---|
1360 | { |
---|
1361 | pcSlice->setPicOrderCntLsb( 0 ); |
---|
1362 | } |
---|
1363 | |
---|
1364 | if( !pcSlice->getIdrPicFlag() ) |
---|
1365 | { |
---|
1366 | #endif |
---|
1367 | TComReferencePictureSet* rps; |
---|
1368 | rps = pcSlice->getLocalRPS(); |
---|
1369 | pcSlice->setRPS(rps); |
---|
1370 | READ_FLAG( uiCode, "short_term_ref_pic_set_sps_flag" ); |
---|
1371 | if(uiCode == 0) // use short-term reference picture set explicitly signalled in slice header |
---|
1372 | { |
---|
1373 | parseShortTermRefPicSet(sps,rps, sps->getRPSList()->getNumberOfReferencePictureSets()); |
---|
1374 | } |
---|
1375 | else // use reference to short-term reference picture set in PPS |
---|
1376 | { |
---|
1377 | Int numBits = 0; |
---|
1378 | while ((1 << numBits) < sps->getRPSList()->getNumberOfReferencePictureSets()) |
---|
1379 | { |
---|
1380 | numBits++; |
---|
1381 | } |
---|
1382 | if (numBits > 0) |
---|
1383 | { |
---|
1384 | READ_CODE( numBits, uiCode, "short_term_ref_pic_set_idx"); |
---|
1385 | } |
---|
1386 | else |
---|
1387 | { |
---|
1388 | uiCode = 0; |
---|
1389 | |
---|
1390 | } |
---|
1391 | *rps = *(sps->getRPSList()->getReferencePictureSet(uiCode)); |
---|
1392 | } |
---|
1393 | if(sps->getLongTermRefsPresent()) |
---|
1394 | { |
---|
1395 | Int offset = rps->getNumberOfNegativePictures()+rps->getNumberOfPositivePictures(); |
---|
1396 | UInt numOfLtrp = 0; |
---|
1397 | UInt numLtrpInSPS = 0; |
---|
1398 | if (sps->getNumLongTermRefPicSPS() > 0) |
---|
1399 | { |
---|
1400 | READ_UVLC( uiCode, "num_long_term_sps"); |
---|
1401 | numLtrpInSPS = uiCode; |
---|
1402 | numOfLtrp += numLtrpInSPS; |
---|
1403 | rps->setNumberOfLongtermPictures(numOfLtrp); |
---|
1404 | } |
---|
1405 | Int bitsForLtrpInSPS = 0; |
---|
1406 | while (sps->getNumLongTermRefPicSPS() > (1 << bitsForLtrpInSPS)) |
---|
1407 | { |
---|
1408 | bitsForLtrpInSPS++; |
---|
1409 | } |
---|
1410 | READ_UVLC( uiCode, "num_long_term_pics"); rps->setNumberOfLongtermPictures(uiCode); |
---|
1411 | numOfLtrp += uiCode; |
---|
1412 | rps->setNumberOfLongtermPictures(numOfLtrp); |
---|
1413 | Int maxPicOrderCntLSB = 1 << sps->getBitsForPOC(); |
---|
1414 | Int prevDeltaMSB = 0, deltaPocMSBCycleLT = 0; |
---|
1415 | for(Int j=offset+rps->getNumberOfLongtermPictures()-1, k = 0; k < numOfLtrp; j--, k++) |
---|
1416 | { |
---|
1417 | Int pocLsbLt; |
---|
1418 | if (k < numLtrpInSPS) |
---|
1419 | { |
---|
1420 | uiCode = 0; |
---|
1421 | if (bitsForLtrpInSPS > 0) |
---|
1422 | { |
---|
1423 | READ_CODE(bitsForLtrpInSPS, uiCode, "lt_idx_sps[i]"); |
---|
1424 | } |
---|
1425 | Bool usedByCurrFromSPS=sps->getUsedByCurrPicLtSPSFlag(uiCode); |
---|
1426 | |
---|
1427 | pocLsbLt = sps->getLtRefPicPocLsbSps(uiCode); |
---|
1428 | rps->setUsed(j,usedByCurrFromSPS); |
---|
1429 | } |
---|
1430 | else |
---|
1431 | { |
---|
1432 | READ_CODE(sps->getBitsForPOC(), uiCode, "poc_lsb_lt"); pocLsbLt= uiCode; |
---|
1433 | READ_FLAG( uiCode, "used_by_curr_pic_lt_flag"); rps->setUsed(j,uiCode); |
---|
1434 | } |
---|
1435 | READ_FLAG(uiCode,"delta_poc_msb_present_flag"); |
---|
1436 | Bool mSBPresentFlag = uiCode ? true : false; |
---|
1437 | if(mSBPresentFlag) |
---|
1438 | { |
---|
1439 | READ_UVLC( uiCode, "delta_poc_msb_cycle_lt[i]" ); |
---|
1440 | Bool deltaFlag = false; |
---|
1441 | // First LTRP || First LTRP from SH |
---|
1442 | if( (j == offset+rps->getNumberOfLongtermPictures()-1) || (j == offset+(numOfLtrp-numLtrpInSPS)-1) ) |
---|
1443 | { |
---|
1444 | deltaFlag = true; |
---|
1445 | } |
---|
1446 | if(deltaFlag) |
---|
1447 | { |
---|
1448 | deltaPocMSBCycleLT = uiCode; |
---|
1449 | } |
---|
1450 | else |
---|
1451 | { |
---|
1452 | deltaPocMSBCycleLT = uiCode + prevDeltaMSB; |
---|
1453 | } |
---|
1454 | |
---|
1455 | Int pocLTCurr = pcSlice->getPOC() - deltaPocMSBCycleLT * maxPicOrderCntLSB |
---|
1456 | - iPOClsb + pocLsbLt; |
---|
1457 | rps->setPOC (j, pocLTCurr); |
---|
1458 | rps->setDeltaPOC(j, - pcSlice->getPOC() + pocLTCurr); |
---|
1459 | rps->setCheckLTMSBPresent(j,true); |
---|
1460 | } |
---|
1461 | else |
---|
1462 | { |
---|
1463 | rps->setPOC (j, pocLsbLt); |
---|
1464 | rps->setDeltaPOC(j, - pcSlice->getPOC() + pocLsbLt); |
---|
1465 | rps->setCheckLTMSBPresent(j,false); |
---|
1466 | |
---|
1467 | // reset deltaPocMSBCycleLT for first LTRP from slice header if MSB not present |
---|
1468 | if( j == offset+(numOfLtrp-numLtrpInSPS)-1 ) |
---|
1469 | { |
---|
1470 | deltaPocMSBCycleLT = 0; |
---|
1471 | } |
---|
1472 | } |
---|
1473 | prevDeltaMSB = deltaPocMSBCycleLT; |
---|
1474 | } |
---|
1475 | offset += rps->getNumberOfLongtermPictures(); |
---|
1476 | rps->setNumberOfPictures(offset); |
---|
1477 | } |
---|
1478 | |
---|
1479 | #if SVC_EXTENSION |
---|
1480 | // DPB constraints |
---|
1481 | if( pcSlice->getVPS()->getVpsExtensionFlag() == 1 ) |
---|
1482 | { |
---|
1483 | for( Int ii = 1; ii < (pcSlice->getVPS()->getVpsNumLayerSetsMinus1() + 1); ii++ ) // prevent assert error when num_add_layer_sets > 0 |
---|
1484 | { |
---|
1485 | Int layerSetIdxForOutputLayerSet = pcSlice->getVPS()->getOutputLayerSetIdx( ii ); |
---|
1486 | Int chkAssert=0; |
---|
1487 | for(Int kk = 0; kk < pcSlice->getVPS()->getNumLayersInIdList(layerSetIdxForOutputLayerSet); kk++) |
---|
1488 | { |
---|
1489 | if( pcSlice->getVPS()->getNecessaryLayerFlag(ii, kk) && pcSlice->getLayerId() == pcSlice->getVPS()->getLayerSetLayerIdList(layerSetIdxForOutputLayerSet, kk) ) |
---|
1490 | { |
---|
1491 | chkAssert=1; |
---|
1492 | } |
---|
1493 | } |
---|
1494 | |
---|
1495 | if( chkAssert ) |
---|
1496 | { |
---|
1497 | UInt layerIdc = pcSlice->getVPS()->getLayerIdcForOls( ii, pcSlice->getLayerId() ); |
---|
1498 | assert(rps->getNumberOfNegativePictures() <= pcSlice->getVPS()->getMaxVpsDecPicBufferingMinus1(ii, layerIdc, pcSlice->getVPS()->getMaxSLayersInLayerSetMinus1(ii))); |
---|
1499 | assert(rps->getNumberOfPositivePictures() <= pcSlice->getVPS()->getMaxVpsDecPicBufferingMinus1(ii, layerIdc, pcSlice->getVPS()->getMaxSLayersInLayerSetMinus1(ii)) - rps->getNumberOfNegativePictures()); |
---|
1500 | assert((rps->getNumberOfPositivePictures() + rps->getNumberOfNegativePictures() + rps->getNumberOfLongtermPictures()) <= pcSlice->getVPS()->getMaxVpsDecPicBufferingMinus1(ii, layerIdc, pcSlice->getVPS()->getMaxSLayersInLayerSetMinus1(ii))); |
---|
1501 | } |
---|
1502 | } |
---|
1503 | } |
---|
1504 | |
---|
1505 | if(pcSlice->getLayerId() == 0) |
---|
1506 | { |
---|
1507 | assert(rps->getNumberOfNegativePictures() <= pcSlice->getSPS()->getMaxDecPicBuffering(pcSlice->getSPS()->getMaxTLayers()-1) ); |
---|
1508 | assert(rps->getNumberOfPositivePictures() <= pcSlice->getSPS()->getMaxDecPicBuffering(pcSlice->getSPS()->getMaxTLayers()-1) -rps->getNumberOfNegativePictures()); |
---|
1509 | assert((rps->getNumberOfPositivePictures() + rps->getNumberOfNegativePictures() + rps->getNumberOfLongtermPictures()) <= pcSlice->getSPS()->getMaxDecPicBuffering(pcSlice->getSPS()->getMaxTLayers()-1)); |
---|
1510 | } |
---|
1511 | #endif |
---|
1512 | |
---|
1513 | if ( pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP |
---|
1514 | || pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL |
---|
1515 | || pcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP ) |
---|
1516 | { |
---|
1517 | // In the case of BLA picture types, rps data is read from slice header but ignored |
---|
1518 | rps = pcSlice->getLocalRPS(); |
---|
1519 | rps->setNumberOfNegativePictures(0); |
---|
1520 | rps->setNumberOfPositivePictures(0); |
---|
1521 | rps->setNumberOfLongtermPictures(0); |
---|
1522 | rps->setNumberOfPictures(0); |
---|
1523 | pcSlice->setRPS(rps); |
---|
1524 | } |
---|
1525 | if (sps->getTMVPFlagsPresent()) |
---|
1526 | { |
---|
1527 | READ_FLAG( uiCode, "slice_temporal_mvp_enabled_flag" ); |
---|
1528 | pcSlice->setEnableTMVPFlag( uiCode == 1 ? true : false ); |
---|
1529 | } |
---|
1530 | else |
---|
1531 | { |
---|
1532 | pcSlice->setEnableTMVPFlag(false); |
---|
1533 | } |
---|
1534 | } |
---|
1535 | |
---|
1536 | #if SVC_EXTENSION |
---|
1537 | pcSlice->setActiveNumILRRefIdx(0); |
---|
1538 | if((pcSlice->getLayerId() > 0) && !(vps->getIlpSshSignalingEnabledFlag()) && (pcSlice->getNumILRRefIdx() > 0) ) |
---|
1539 | { |
---|
1540 | READ_FLAG(uiCode,"inter_layer_pred_enabled_flag"); |
---|
1541 | pcSlice->setInterLayerPredEnabledFlag(uiCode); |
---|
1542 | if( pcSlice->getInterLayerPredEnabledFlag()) |
---|
1543 | { |
---|
1544 | if(pcSlice->getNumILRRefIdx() > 1) |
---|
1545 | { |
---|
1546 | Int numBits = 1; |
---|
1547 | while ((1 << numBits) < pcSlice->getNumILRRefIdx()) |
---|
1548 | { |
---|
1549 | numBits++; |
---|
1550 | } |
---|
1551 | if( !vps->getMaxOneActiveRefLayerFlag()) |
---|
1552 | { |
---|
1553 | READ_CODE( numBits, uiCode,"num_inter_layer_ref_pics_minus1" ); |
---|
1554 | pcSlice->setActiveNumILRRefIdx(uiCode + 1); |
---|
1555 | } |
---|
1556 | else |
---|
1557 | { |
---|
1558 | for( Int i = 0; i < pcSlice->getNumILRRefIdx(); i++ ) |
---|
1559 | { |
---|
1560 | if( ( vps->getMaxTidIlRefPicsPlus1(vps->getLayerIdxInVps(i), pcSlice->getLayerIdx()) > pcSlice->getTLayer() || pcSlice->getTLayer()==0 ) && |
---|
1561 | vps->getMaxTSLayersMinus1(vps->getLayerIdxInVps(i)) >= pcSlice->getTLayer() ) |
---|
1562 | { |
---|
1563 | pcSlice->setActiveNumILRRefIdx(1); |
---|
1564 | break; |
---|
1565 | } |
---|
1566 | } |
---|
1567 | } |
---|
1568 | |
---|
1569 | if( pcSlice->getActiveNumILRRefIdx() == pcSlice->getNumILRRefIdx() ) |
---|
1570 | { |
---|
1571 | for( Int i = 0; i < pcSlice->getActiveNumILRRefIdx(); i++ ) |
---|
1572 | { |
---|
1573 | pcSlice->setInterLayerPredLayerIdc(i,i); |
---|
1574 | } |
---|
1575 | } |
---|
1576 | else |
---|
1577 | { |
---|
1578 | for(Int i = 0; i < pcSlice->getActiveNumILRRefIdx(); i++ ) |
---|
1579 | { |
---|
1580 | READ_CODE( numBits,uiCode,"inter_layer_pred_layer_idc[i]" ); |
---|
1581 | pcSlice->setInterLayerPredLayerIdc(uiCode, i); |
---|
1582 | } |
---|
1583 | } |
---|
1584 | } |
---|
1585 | else |
---|
1586 | { |
---|
1587 | Int refLayerId = vps->getRefLayerId(pcSlice->getLayerId(), 0); |
---|
1588 | Int refLayerIdx = vps->getLayerIdxInVps(refLayerId); |
---|
1589 | |
---|
1590 | if( ( vps->getMaxTidIlRefPicsPlus1(refLayerIdx, pcSlice->getLayerIdx()) > pcSlice->getTLayer() || pcSlice->getTLayer()==0 ) && |
---|
1591 | vps->getMaxTSLayersMinus1(refLayerIdx) >= pcSlice->getTLayer() ) |
---|
1592 | { |
---|
1593 | pcSlice->setActiveNumILRRefIdx(1); |
---|
1594 | pcSlice->setInterLayerPredLayerIdc(0, 0); |
---|
1595 | } |
---|
1596 | } |
---|
1597 | } |
---|
1598 | } |
---|
1599 | else if( vps->getIlpSshSignalingEnabledFlag() == true && (pcSlice->getLayerId() > 0 )) |
---|
1600 | { |
---|
1601 | pcSlice->setInterLayerPredEnabledFlag(true); |
---|
1602 | |
---|
1603 | Int numRefLayerPics = 0; |
---|
1604 | Int i = 0; |
---|
1605 | Int refLayerPicIdc [MAX_VPS_LAYER_IDX_PLUS1]; |
---|
1606 | for(i = 0, numRefLayerPics = 0; i < pcSlice->getNumILRRefIdx(); i++ ) |
---|
1607 | { |
---|
1608 | if( ( vps->getMaxTidIlRefPicsPlus1(vps->getLayerIdxInVps(i), pcSlice->getLayerIdx()) > pcSlice->getTLayer() || pcSlice->getTLayer()==0 ) && |
---|
1609 | vps->getMaxTSLayersMinus1(vps->getLayerIdxInVps(i)) >= pcSlice->getTLayer() ) |
---|
1610 | { |
---|
1611 | refLayerPicIdc[ numRefLayerPics++ ] = i; |
---|
1612 | } |
---|
1613 | } |
---|
1614 | pcSlice->setActiveNumILRRefIdx(numRefLayerPics); |
---|
1615 | for( i = 0; i < pcSlice->getActiveNumILRRefIdx(); i++ ) |
---|
1616 | { |
---|
1617 | pcSlice->setInterLayerPredLayerIdc(refLayerPicIdc[i], i); |
---|
1618 | } |
---|
1619 | } |
---|
1620 | #endif //SVC_EXTENSION |
---|
1621 | |
---|
1622 | if(sps->getUseSAO()) |
---|
1623 | { |
---|
1624 | READ_FLAG(uiCode, "slice_sao_luma_flag"); pcSlice->setSaoEnabledFlag(CHANNEL_TYPE_LUMA, (Bool)uiCode); |
---|
1625 | #if SVC_EXTENSION |
---|
1626 | ChromaFormat format; |
---|
1627 | if( sps->getLayerId() == 0 ) |
---|
1628 | { |
---|
1629 | format = sps->getChromaFormatIdc(); |
---|
1630 | } |
---|
1631 | else |
---|
1632 | { |
---|
1633 | format = vps->getVpsRepFormat( sps->getUpdateRepFormatFlag() ? sps->getUpdateRepFormatIndex() : vps->getVpsRepFormatIdx( vps->getLayerIdxInVps(sps->getLayerId()) ) )->getChromaFormatVpsIdc(); |
---|
1634 | |
---|
1635 | // conformance check |
---|
1636 | assert( (sps->getUpdateRepFormatFlag()==false && vps->getVpsNumRepFormats()==1) || vps->getVpsNumRepFormats() > 1 ); |
---|
1637 | } |
---|
1638 | if (format != CHROMA_400) |
---|
1639 | #else |
---|
1640 | if (bChroma) |
---|
1641 | #endif |
---|
1642 | { |
---|
1643 | READ_FLAG(uiCode, "slice_sao_chroma_flag"); pcSlice->setSaoEnabledFlag(CHANNEL_TYPE_CHROMA, (Bool)uiCode); |
---|
1644 | } |
---|
1645 | #if SVC_EXTENSION |
---|
1646 | else |
---|
1647 | { |
---|
1648 | pcSlice->setSaoEnabledFlag(CHANNEL_TYPE_CHROMA, false); |
---|
1649 | } |
---|
1650 | #endif |
---|
1651 | } |
---|
1652 | |
---|
1653 | if (pcSlice->getIdrPicFlag()) |
---|
1654 | { |
---|
1655 | pcSlice->setEnableTMVPFlag(false); |
---|
1656 | } |
---|
1657 | if (!pcSlice->isIntra()) |
---|
1658 | { |
---|
1659 | |
---|
1660 | READ_FLAG( uiCode, "num_ref_idx_active_override_flag"); |
---|
1661 | if (uiCode) |
---|
1662 | { |
---|
1663 | READ_UVLC (uiCode, "num_ref_idx_l0_active_minus1" ); pcSlice->setNumRefIdx( REF_PIC_LIST_0, uiCode + 1 ); |
---|
1664 | if (pcSlice->isInterB()) |
---|
1665 | { |
---|
1666 | READ_UVLC (uiCode, "num_ref_idx_l1_active_minus1" ); pcSlice->setNumRefIdx( REF_PIC_LIST_1, uiCode + 1 ); |
---|
1667 | } |
---|
1668 | else |
---|
1669 | { |
---|
1670 | pcSlice->setNumRefIdx(REF_PIC_LIST_1, 0); |
---|
1671 | } |
---|
1672 | } |
---|
1673 | else |
---|
1674 | { |
---|
1675 | pcSlice->setNumRefIdx(REF_PIC_LIST_0, pps->getNumRefIdxL0DefaultActive()); |
---|
1676 | if (pcSlice->isInterB()) |
---|
1677 | { |
---|
1678 | pcSlice->setNumRefIdx(REF_PIC_LIST_1, pps->getNumRefIdxL1DefaultActive()); |
---|
1679 | } |
---|
1680 | else |
---|
1681 | { |
---|
1682 | pcSlice->setNumRefIdx(REF_PIC_LIST_1,0); |
---|
1683 | } |
---|
1684 | } |
---|
1685 | } |
---|
1686 | // } |
---|
1687 | TComRefPicListModification* refPicListModification = pcSlice->getRefPicListModification(); |
---|
1688 | if(!pcSlice->isIntra()) |
---|
1689 | { |
---|
1690 | if( !pps->getListsModificationPresentFlag() || pcSlice->getNumRpsCurrTempList() <= 1 ) |
---|
1691 | { |
---|
1692 | refPicListModification->setRefPicListModificationFlagL0( 0 ); |
---|
1693 | } |
---|
1694 | else |
---|
1695 | { |
---|
1696 | READ_FLAG( uiCode, "ref_pic_list_modification_flag_l0" ); refPicListModification->setRefPicListModificationFlagL0( uiCode ? 1 : 0 ); |
---|
1697 | } |
---|
1698 | |
---|
1699 | if(refPicListModification->getRefPicListModificationFlagL0()) |
---|
1700 | { |
---|
1701 | uiCode = 0; |
---|
1702 | Int i = 0; |
---|
1703 | Int numRpsCurrTempList0 = pcSlice->getNumRpsCurrTempList(); |
---|
1704 | if ( numRpsCurrTempList0 > 1 ) |
---|
1705 | { |
---|
1706 | Int length = 1; |
---|
1707 | numRpsCurrTempList0 --; |
---|
1708 | while ( numRpsCurrTempList0 >>= 1) |
---|
1709 | { |
---|
1710 | length ++; |
---|
1711 | } |
---|
1712 | for (i = 0; i < pcSlice->getNumRefIdx(REF_PIC_LIST_0); i ++) |
---|
1713 | { |
---|
1714 | READ_CODE( length, uiCode, "list_entry_l0" ); |
---|
1715 | refPicListModification->setRefPicSetIdxL0(i, uiCode ); |
---|
1716 | } |
---|
1717 | } |
---|
1718 | else |
---|
1719 | { |
---|
1720 | for (i = 0; i < pcSlice->getNumRefIdx(REF_PIC_LIST_0); i ++) |
---|
1721 | { |
---|
1722 | refPicListModification->setRefPicSetIdxL0(i, 0 ); |
---|
1723 | } |
---|
1724 | } |
---|
1725 | } |
---|
1726 | } |
---|
1727 | else |
---|
1728 | { |
---|
1729 | refPicListModification->setRefPicListModificationFlagL0(0); |
---|
1730 | } |
---|
1731 | if(pcSlice->isInterB()) |
---|
1732 | { |
---|
1733 | if( !pps->getListsModificationPresentFlag() || pcSlice->getNumRpsCurrTempList() <= 1 ) |
---|
1734 | { |
---|
1735 | refPicListModification->setRefPicListModificationFlagL1( 0 ); |
---|
1736 | } |
---|
1737 | else |
---|
1738 | { |
---|
1739 | READ_FLAG( uiCode, "ref_pic_list_modification_flag_l1" ); refPicListModification->setRefPicListModificationFlagL1( uiCode ? 1 : 0 ); |
---|
1740 | } |
---|
1741 | if(refPicListModification->getRefPicListModificationFlagL1()) |
---|
1742 | { |
---|
1743 | uiCode = 0; |
---|
1744 | Int i = 0; |
---|
1745 | Int numRpsCurrTempList1 = pcSlice->getNumRpsCurrTempList(); |
---|
1746 | if ( numRpsCurrTempList1 > 1 ) |
---|
1747 | { |
---|
1748 | Int length = 1; |
---|
1749 | numRpsCurrTempList1 --; |
---|
1750 | while ( numRpsCurrTempList1 >>= 1) |
---|
1751 | { |
---|
1752 | length ++; |
---|
1753 | } |
---|
1754 | for (i = 0; i < pcSlice->getNumRefIdx(REF_PIC_LIST_1); i ++) |
---|
1755 | { |
---|
1756 | READ_CODE( length, uiCode, "list_entry_l1" ); |
---|
1757 | refPicListModification->setRefPicSetIdxL1(i, uiCode ); |
---|
1758 | } |
---|
1759 | } |
---|
1760 | else |
---|
1761 | { |
---|
1762 | for (i = 0; i < pcSlice->getNumRefIdx(REF_PIC_LIST_1); i ++) |
---|
1763 | { |
---|
1764 | refPicListModification->setRefPicSetIdxL1(i, 0 ); |
---|
1765 | } |
---|
1766 | } |
---|
1767 | } |
---|
1768 | } |
---|
1769 | else |
---|
1770 | { |
---|
1771 | refPicListModification->setRefPicListModificationFlagL1(0); |
---|
1772 | } |
---|
1773 | if (pcSlice->isInterB()) |
---|
1774 | { |
---|
1775 | READ_FLAG( uiCode, "mvd_l1_zero_flag" ); pcSlice->setMvdL1ZeroFlag( (uiCode ? true : false) ); |
---|
1776 | } |
---|
1777 | |
---|
1778 | pcSlice->setCabacInitFlag( false ); // default |
---|
1779 | if(pps->getCabacInitPresentFlag() && !pcSlice->isIntra()) |
---|
1780 | { |
---|
1781 | READ_FLAG(uiCode, "cabac_init_flag"); |
---|
1782 | pcSlice->setCabacInitFlag( uiCode ? true : false ); |
---|
1783 | } |
---|
1784 | |
---|
1785 | if ( pcSlice->getEnableTMVPFlag() ) |
---|
1786 | { |
---|
1787 | #if SVC_EXTENSION |
---|
1788 | // set motion mapping flag |
---|
1789 | pcSlice->setMFMEnabledFlag( ( pcSlice->getNumMotionPredRefLayers() > 0 && pcSlice->getActiveNumILRRefIdx() && !pcSlice->isIntra() ) ? true : false ); |
---|
1790 | #endif |
---|
1791 | if ( pcSlice->getSliceType() == B_SLICE ) |
---|
1792 | { |
---|
1793 | READ_FLAG( uiCode, "collocated_from_l0_flag" ); |
---|
1794 | pcSlice->setColFromL0Flag(uiCode); |
---|
1795 | } |
---|
1796 | else |
---|
1797 | { |
---|
1798 | pcSlice->setColFromL0Flag( 1 ); |
---|
1799 | } |
---|
1800 | |
---|
1801 | if ( pcSlice->getSliceType() != I_SLICE && |
---|
1802 | ((pcSlice->getColFromL0Flag() == 1 && pcSlice->getNumRefIdx(REF_PIC_LIST_0) > 1)|| |
---|
1803 | (pcSlice->getColFromL0Flag() == 0 && pcSlice->getNumRefIdx(REF_PIC_LIST_1) > 1))) |
---|
1804 | { |
---|
1805 | READ_UVLC( uiCode, "collocated_ref_idx" ); |
---|
1806 | pcSlice->setColRefIdx(uiCode); |
---|
1807 | } |
---|
1808 | else |
---|
1809 | { |
---|
1810 | pcSlice->setColRefIdx(0); |
---|
1811 | } |
---|
1812 | } |
---|
1813 | if ( (pps->getUseWP() && pcSlice->getSliceType()==P_SLICE) || (pps->getWPBiPred() && pcSlice->getSliceType()==B_SLICE) ) |
---|
1814 | { |
---|
1815 | xParsePredWeightTable(pcSlice, sps); |
---|
1816 | pcSlice->initWpScaling(sps); |
---|
1817 | } |
---|
1818 | if (!pcSlice->isIntra()) |
---|
1819 | { |
---|
1820 | READ_UVLC( uiCode, "five_minus_max_num_merge_cand"); |
---|
1821 | pcSlice->setMaxNumMergeCand(MRG_MAX_NUM_CANDS - uiCode); |
---|
1822 | } |
---|
1823 | |
---|
1824 | READ_SVLC( iCode, "slice_qp_delta" ); |
---|
1825 | pcSlice->setSliceQp (26 + pps->getPicInitQPMinus26() + iCode); |
---|
1826 | |
---|
1827 | #if SVC_EXTENSION |
---|
1828 | assert( pcSlice->getSliceQp() >= -pcSlice->getQpBDOffset(CHANNEL_TYPE_LUMA) ); |
---|
1829 | #else |
---|
1830 | assert( pcSlice->getSliceQp() >= -sps->getQpBDOffset(CHANNEL_TYPE_LUMA) ); |
---|
1831 | #endif |
---|
1832 | assert( pcSlice->getSliceQp() <= 51 ); |
---|
1833 | |
---|
1834 | if (pps->getSliceChromaQpFlag()) |
---|
1835 | { |
---|
1836 | if (numValidComp>COMPONENT_Cb) |
---|
1837 | { |
---|
1838 | READ_SVLC( iCode, "slice_cb_qp_offset" ); |
---|
1839 | pcSlice->setSliceChromaQpDelta(COMPONENT_Cb, iCode ); |
---|
1840 | assert( pcSlice->getSliceChromaQpDelta(COMPONENT_Cb) >= -12 ); |
---|
1841 | assert( pcSlice->getSliceChromaQpDelta(COMPONENT_Cb) <= 12 ); |
---|
1842 | assert( (pps->getQpOffset(COMPONENT_Cb) + pcSlice->getSliceChromaQpDelta(COMPONENT_Cb)) >= -12 ); |
---|
1843 | assert( (pps->getQpOffset(COMPONENT_Cb) + pcSlice->getSliceChromaQpDelta(COMPONENT_Cb)) <= 12 ); |
---|
1844 | } |
---|
1845 | |
---|
1846 | if (numValidComp>COMPONENT_Cr) |
---|
1847 | { |
---|
1848 | READ_SVLC( iCode, "slice_cr_qp_offset" ); |
---|
1849 | pcSlice->setSliceChromaQpDelta(COMPONENT_Cr, iCode ); |
---|
1850 | assert( pcSlice->getSliceChromaQpDelta(COMPONENT_Cr) >= -12 ); |
---|
1851 | assert( pcSlice->getSliceChromaQpDelta(COMPONENT_Cr) <= 12 ); |
---|
1852 | assert( (pps->getQpOffset(COMPONENT_Cr) + pcSlice->getSliceChromaQpDelta(COMPONENT_Cr)) >= -12 ); |
---|
1853 | assert( (pps->getQpOffset(COMPONENT_Cr) + pcSlice->getSliceChromaQpDelta(COMPONENT_Cr)) <= 12 ); |
---|
1854 | } |
---|
1855 | } |
---|
1856 | |
---|
1857 | if (pps->getPpsRangeExtension().getChromaQpOffsetListEnabledFlag()) |
---|
1858 | { |
---|
1859 | READ_FLAG(uiCode, "cu_chroma_qp_offset_enabled_flag"); pcSlice->setUseChromaQpAdj(uiCode != 0); |
---|
1860 | } |
---|
1861 | else |
---|
1862 | { |
---|
1863 | pcSlice->setUseChromaQpAdj(false); |
---|
1864 | } |
---|
1865 | |
---|
1866 | if (pps->getDeblockingFilterControlPresentFlag()) |
---|
1867 | { |
---|
1868 | if(pps->getDeblockingFilterOverrideEnabledFlag()) |
---|
1869 | { |
---|
1870 | READ_FLAG ( uiCode, "deblocking_filter_override_flag" ); pcSlice->setDeblockingFilterOverrideFlag(uiCode ? true : false); |
---|
1871 | } |
---|
1872 | else |
---|
1873 | { |
---|
1874 | pcSlice->setDeblockingFilterOverrideFlag(0); |
---|
1875 | } |
---|
1876 | if(pcSlice->getDeblockingFilterOverrideFlag()) |
---|
1877 | { |
---|
1878 | READ_FLAG ( uiCode, "slice_disable_deblocking_filter_flag" ); pcSlice->setDeblockingFilterDisable(uiCode ? 1 : 0); |
---|
1879 | if(!pcSlice->getDeblockingFilterDisable()) |
---|
1880 | { |
---|
1881 | READ_SVLC( iCode, "slice_beta_offset_div2" ); pcSlice->setDeblockingFilterBetaOffsetDiv2(iCode); |
---|
1882 | assert(pcSlice->getDeblockingFilterBetaOffsetDiv2() >= -6 && |
---|
1883 | pcSlice->getDeblockingFilterBetaOffsetDiv2() <= 6); |
---|
1884 | READ_SVLC( iCode, "slice_tc_offset_div2" ); pcSlice->setDeblockingFilterTcOffsetDiv2(iCode); |
---|
1885 | assert(pcSlice->getDeblockingFilterTcOffsetDiv2() >= -6 && |
---|
1886 | pcSlice->getDeblockingFilterTcOffsetDiv2() <= 6); |
---|
1887 | } |
---|
1888 | } |
---|
1889 | else |
---|
1890 | { |
---|
1891 | pcSlice->setDeblockingFilterDisable ( pps->getPicDisableDeblockingFilterFlag() ); |
---|
1892 | pcSlice->setDeblockingFilterBetaOffsetDiv2( pps->getDeblockingFilterBetaOffsetDiv2() ); |
---|
1893 | pcSlice->setDeblockingFilterTcOffsetDiv2 ( pps->getDeblockingFilterTcOffsetDiv2() ); |
---|
1894 | } |
---|
1895 | } |
---|
1896 | else |
---|
1897 | { |
---|
1898 | pcSlice->setDeblockingFilterDisable ( false ); |
---|
1899 | pcSlice->setDeblockingFilterBetaOffsetDiv2( 0 ); |
---|
1900 | pcSlice->setDeblockingFilterTcOffsetDiv2 ( 0 ); |
---|
1901 | } |
---|
1902 | |
---|
1903 | Bool isSAOEnabled = sps->getUseSAO() && (pcSlice->getSaoEnabledFlag(CHANNEL_TYPE_LUMA) || (bChroma && pcSlice->getSaoEnabledFlag(CHANNEL_TYPE_CHROMA))); |
---|
1904 | Bool isDBFEnabled = (!pcSlice->getDeblockingFilterDisable()); |
---|
1905 | |
---|
1906 | if(pps->getLoopFilterAcrossSlicesEnabledFlag() && ( isSAOEnabled || isDBFEnabled )) |
---|
1907 | { |
---|
1908 | READ_FLAG( uiCode, "slice_loop_filter_across_slices_enabled_flag"); |
---|
1909 | } |
---|
1910 | else |
---|
1911 | { |
---|
1912 | uiCode = pps->getLoopFilterAcrossSlicesEnabledFlag()?1:0; |
---|
1913 | } |
---|
1914 | pcSlice->setLFCrossSliceBoundaryFlag( (uiCode==1)?true:false); |
---|
1915 | |
---|
1916 | } |
---|
1917 | |
---|
1918 | std::vector<UInt> entryPointOffset; |
---|
1919 | if( pps->getTilesEnabledFlag() || pps->getEntropyCodingSyncEnabledFlag() ) |
---|
1920 | { |
---|
1921 | UInt numEntryPointOffsets; |
---|
1922 | UInt offsetLenMinus1; |
---|
1923 | READ_UVLC(numEntryPointOffsets, "num_entry_point_offsets"); |
---|
1924 | if (numEntryPointOffsets>0) |
---|
1925 | { |
---|
1926 | READ_UVLC(offsetLenMinus1, "offset_len_minus1"); |
---|
1927 | entryPointOffset.resize(numEntryPointOffsets); |
---|
1928 | for (UInt idx=0; idx<numEntryPointOffsets; idx++) |
---|
1929 | { |
---|
1930 | READ_CODE(offsetLenMinus1+1, uiCode, "entry_point_offset_minus1"); |
---|
1931 | entryPointOffset[ idx ] = uiCode + 1; |
---|
1932 | } |
---|
1933 | } |
---|
1934 | } |
---|
1935 | |
---|
1936 | #if SVC_EXTENSION |
---|
1937 | Int sliceHeaderExtensionLength = 0; |
---|
1938 | if(pps->getSliceHeaderExtensionPresentFlag()) |
---|
1939 | { |
---|
1940 | READ_UVLC( uiCode, "slice_segment_header_extension_length"); sliceHeaderExtensionLength = uiCode; |
---|
1941 | } |
---|
1942 | else |
---|
1943 | { |
---|
1944 | sliceHeaderExtensionLength = 0; |
---|
1945 | pcSlice->setPocMsbValPresentFlag( false ); |
---|
1946 | } |
---|
1947 | |
---|
1948 | UInt startBits = m_pcBitstream->getNumBitsRead(); // Start counter of # SH Extn bits |
---|
1949 | if( sliceHeaderExtensionLength > 0 ) |
---|
1950 | { |
---|
1951 | if( pcSlice->getPPS()->getPocResetInfoPresentFlag() ) |
---|
1952 | { |
---|
1953 | READ_CODE( 2, uiCode, "poc_reset_idc"); pcSlice->setPocResetIdc(uiCode); |
---|
1954 | |
---|
1955 | /* The value of poc_reset_idc shall not be equal to 1 or 2 for a RASL picture, a RADL picture, |
---|
1956 | a sub-layer non-reference picture, or a picture that has TemporalId greater than 0, |
---|
1957 | or a picture that has discardable_flag equal to 1. */ |
---|
1958 | if( pcSlice->getPocResetIdc() == 1 || pcSlice->getPocResetIdc() == 2 ) |
---|
1959 | { |
---|
1960 | assert( !pcSlice->isRASL() ); |
---|
1961 | assert( !pcSlice->isRADL() ); |
---|
1962 | assert( !pcSlice->isSLNR() ); |
---|
1963 | assert( pcSlice->getTLayer() == 0 ); |
---|
1964 | assert( pcSlice->getDiscardableFlag() == 0 ); |
---|
1965 | } |
---|
1966 | |
---|
1967 | // The value of poc_reset_idc of a CRA or BLA picture shall be less than 3. |
---|
1968 | if( pcSlice->getPocResetIdc() == 3) |
---|
1969 | { |
---|
1970 | assert( ! ( pcSlice->isCRA() || pcSlice->isBLA() ) ); |
---|
1971 | } |
---|
1972 | } |
---|
1973 | else |
---|
1974 | { |
---|
1975 | pcSlice->setPocResetIdc( 0 ); |
---|
1976 | } |
---|
1977 | |
---|
1978 | if( pcSlice->getVPS()->getPocLsbNotPresentFlag( pcSlice->getVPS()->getLayerIdxInVps(pcSlice->getLayerId()) ) && iPOClsb > 0 ) |
---|
1979 | { |
---|
1980 | assert( pcSlice->getPocResetIdc() != 2 ); |
---|
1981 | } |
---|
1982 | |
---|
1983 | if( pcSlice->getPocResetIdc() > 0 ) |
---|
1984 | { |
---|
1985 | READ_CODE(6, uiCode, "poc_reset_period_id"); pcSlice->setPocResetPeriodId(uiCode); |
---|
1986 | } |
---|
1987 | else |
---|
1988 | { |
---|
1989 | |
---|
1990 | pcSlice->setPocResetPeriodId( 0 ); |
---|
1991 | } |
---|
1992 | |
---|
1993 | if( pcSlice->getPocResetIdc() == 3 ) |
---|
1994 | { |
---|
1995 | READ_FLAG( uiCode, "full_poc_reset_flag"); pcSlice->setFullPocResetFlag((uiCode == 1) ? true : false); |
---|
1996 | READ_CODE(pcSlice->getSPS()->getBitsForPOC(), uiCode,"poc_lsb_val"); pcSlice->setPocLsbVal(uiCode); |
---|
1997 | |
---|
1998 | if( pcSlice->getVPS()->getPocLsbNotPresentFlag( pcSlice->getVPS()->getLayerIdxInVps(pcSlice->getLayerId()) ) && pcSlice->getFullPocResetFlag() ) |
---|
1999 | { |
---|
2000 | assert( pcSlice->getPocLsbVal() == 0 ); |
---|
2001 | } |
---|
2002 | } |
---|
2003 | |
---|
2004 | // Derive the value of PocMsbValRequiredFlag |
---|
2005 | pcSlice->setPocMsbValRequiredFlag( (pcSlice->getCraPicFlag() || pcSlice->getBlaPicFlag()) |
---|
2006 | && (!pcSlice->getVPS()->getVpsPocLsbAlignedFlag() || |
---|
2007 | (pcSlice->getVPS()->getVpsPocLsbAlignedFlag() && pcSlice->getVPS()->getNumDirectRefLayers(pcSlice->getLayerId()) == 0)) |
---|
2008 | ); |
---|
2009 | |
---|
2010 | if( !pcSlice->getPocMsbValRequiredFlag() && pcSlice->getVPS()->getVpsPocLsbAlignedFlag() ) |
---|
2011 | { |
---|
2012 | READ_FLAG(uiCode, "poc_msb_cycle_val_present_flag"); pcSlice->setPocMsbValPresentFlag(uiCode ? true : false); |
---|
2013 | } |
---|
2014 | else |
---|
2015 | { |
---|
2016 | if( pcSlice->getPocMsbValRequiredFlag() ) |
---|
2017 | { |
---|
2018 | pcSlice->setPocMsbValPresentFlag( true ); |
---|
2019 | } |
---|
2020 | else |
---|
2021 | { |
---|
2022 | pcSlice->setPocMsbValPresentFlag( false ); |
---|
2023 | } |
---|
2024 | } |
---|
2025 | |
---|
2026 | if( pcSlice->getPocMsbValPresentFlag() ) |
---|
2027 | { |
---|
2028 | READ_UVLC( uiCode, "poc_msb_cycle_val"); pcSlice->setPocMsbVal( uiCode ); |
---|
2029 | } |
---|
2030 | |
---|
2031 | // Read remaining bits in the slice header extension. |
---|
2032 | UInt endBits = m_pcBitstream->getNumBitsRead(); |
---|
2033 | Int counter = (endBits - startBits) % 8; |
---|
2034 | if( counter ) |
---|
2035 | { |
---|
2036 | counter = 8 - counter; |
---|
2037 | } |
---|
2038 | |
---|
2039 | while( counter ) |
---|
2040 | { |
---|
2041 | READ_FLAG( uiCode, "slice_segment_header_extension_data_bit" ); |
---|
2042 | counter--; |
---|
2043 | } |
---|
2044 | } |
---|
2045 | #else |
---|
2046 | if(pps->getSliceHeaderExtensionPresentFlag()) |
---|
2047 | { |
---|
2048 | READ_UVLC(uiCode,"slice_segment_header_extension_length"); |
---|
2049 | for(Int i=0; i<uiCode; i++) |
---|
2050 | { |
---|
2051 | UInt ignore; |
---|
2052 | READ_CODE(8,ignore,"slice_segment_header_extension_data_byte"); |
---|
2053 | } |
---|
2054 | } |
---|
2055 | #endif |
---|
2056 | #if RExt__DECODER_DEBUG_BIT_STATISTICS |
---|
2057 | TComCodingStatistics::IncrementStatisticEP(STATS__BYTE_ALIGNMENT_BITS,m_pcBitstream->readByteAlignment(),0); |
---|
2058 | #else |
---|
2059 | m_pcBitstream->readByteAlignment(); |
---|
2060 | #endif |
---|
2061 | |
---|
2062 | pcSlice->clearSubstreamSizes(); |
---|
2063 | |
---|
2064 | if( pps->getTilesEnabledFlag() || pps->getEntropyCodingSyncEnabledFlag() ) |
---|
2065 | { |
---|
2066 | Int endOfSliceHeaderLocation = m_pcBitstream->getByteLocation(); |
---|
2067 | |
---|
2068 | // Adjust endOfSliceHeaderLocation to account for emulation prevention bytes in the slice segment header |
---|
2069 | for ( UInt curByteIdx = 0; curByteIdx<m_pcBitstream->numEmulationPreventionBytesRead(); curByteIdx++ ) |
---|
2070 | { |
---|
2071 | if ( m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) < endOfSliceHeaderLocation ) |
---|
2072 | { |
---|
2073 | endOfSliceHeaderLocation++; |
---|
2074 | } |
---|
2075 | } |
---|
2076 | |
---|
2077 | Int curEntryPointOffset = 0; |
---|
2078 | Int prevEntryPointOffset = 0; |
---|
2079 | for (UInt idx=0; idx<entryPointOffset.size(); idx++) |
---|
2080 | { |
---|
2081 | curEntryPointOffset += entryPointOffset[ idx ]; |
---|
2082 | |
---|
2083 | Int emulationPreventionByteCount = 0; |
---|
2084 | for ( UInt curByteIdx = 0; curByteIdx<m_pcBitstream->numEmulationPreventionBytesRead(); curByteIdx++ ) |
---|
2085 | { |
---|
2086 | if ( m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) >= ( prevEntryPointOffset + endOfSliceHeaderLocation ) && |
---|
2087 | m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) < ( curEntryPointOffset + endOfSliceHeaderLocation ) ) |
---|
2088 | { |
---|
2089 | emulationPreventionByteCount++; |
---|
2090 | } |
---|
2091 | } |
---|
2092 | |
---|
2093 | entryPointOffset[ idx ] -= emulationPreventionByteCount; |
---|
2094 | prevEntryPointOffset = curEntryPointOffset; |
---|
2095 | pcSlice->addSubstreamSize(entryPointOffset [ idx ] ); |
---|
2096 | } |
---|
2097 | } |
---|
2098 | |
---|
2099 | return; |
---|
2100 | } |
---|
2101 | |
---|
2102 | Void TDecCavlc::parsePTL( TComPTL *rpcPTL, Bool profilePresentFlag, Int maxNumSubLayersMinus1 ) |
---|
2103 | { |
---|
2104 | UInt uiCode; |
---|
2105 | if(profilePresentFlag) |
---|
2106 | { |
---|
2107 | parseProfileTier(rpcPTL->getGeneralPTL(), false); |
---|
2108 | } |
---|
2109 | READ_CODE( 8, uiCode, "general_level_idc" ); rpcPTL->getGeneralPTL()->setLevelIdc(Level::Name(uiCode)); |
---|
2110 | |
---|
2111 | for (Int i = 0; i < maxNumSubLayersMinus1; i++) |
---|
2112 | { |
---|
2113 | READ_FLAG( uiCode, "sub_layer_profile_present_flag[i]" ); rpcPTL->setSubLayerProfilePresentFlag(i, uiCode); |
---|
2114 | READ_FLAG( uiCode, "sub_layer_level_present_flag[i]" ); rpcPTL->setSubLayerLevelPresentFlag (i, uiCode); |
---|
2115 | } |
---|
2116 | |
---|
2117 | if (maxNumSubLayersMinus1 > 0) |
---|
2118 | { |
---|
2119 | for (Int i = maxNumSubLayersMinus1; i < 8; i++) |
---|
2120 | { |
---|
2121 | READ_CODE(2, uiCode, "reserved_zero_2bits"); |
---|
2122 | assert(uiCode == 0); |
---|
2123 | } |
---|
2124 | } |
---|
2125 | |
---|
2126 | for(Int i = 0; i < maxNumSubLayersMinus1; i++) |
---|
2127 | { |
---|
2128 | if( rpcPTL->getSubLayerProfilePresentFlag(i) ) |
---|
2129 | { |
---|
2130 | parseProfileTier(rpcPTL->getSubLayerPTL(i), true); |
---|
2131 | } |
---|
2132 | if(rpcPTL->getSubLayerLevelPresentFlag(i)) |
---|
2133 | { |
---|
2134 | READ_CODE( 8, uiCode, "sub_layer_level_idc[i]" ); rpcPTL->getSubLayerPTL(i)->setLevelIdc(Level::Name(uiCode)); |
---|
2135 | } |
---|
2136 | } |
---|
2137 | } |
---|
2138 | |
---|
2139 | #if ENC_DEC_TRACE || RExt__DECODER_DEBUG_BIT_STATISTICS |
---|
2140 | Void TDecCavlc::parseProfileTier(ProfileTierLevel *ptl, const Bool bIsSubLayer) |
---|
2141 | #define PTL_TRACE_TEXT(txt) bIsSubLayer?("sub_layer_" txt) : ("general_" txt) |
---|
2142 | #else |
---|
2143 | Void TDecCavlc::parseProfileTier(ProfileTierLevel *ptl, const Bool /*bIsSubLayer*/) |
---|
2144 | #define PTL_TRACE_TEXT(txt) txt |
---|
2145 | #endif |
---|
2146 | { |
---|
2147 | UInt uiCode; |
---|
2148 | READ_CODE(2 , uiCode, PTL_TRACE_TEXT("profile_space" )); ptl->setProfileSpace(uiCode); |
---|
2149 | READ_FLAG( uiCode, PTL_TRACE_TEXT("tier_flag" )); ptl->setTierFlag (uiCode ? Level::HIGH : Level::MAIN); |
---|
2150 | READ_CODE(5 , uiCode, PTL_TRACE_TEXT("profile_idc" )); ptl->setProfileIdc (Profile::Name(uiCode)); |
---|
2151 | for(Int j = 0; j < 32; j++) |
---|
2152 | { |
---|
2153 | READ_FLAG( uiCode, PTL_TRACE_TEXT("profile_compatibility_flag[][j]" )); ptl->setProfileCompatibilityFlag(j, uiCode ? 1 : 0); |
---|
2154 | } |
---|
2155 | READ_FLAG(uiCode, PTL_TRACE_TEXT("progressive_source_flag" )); ptl->setProgressiveSourceFlag(uiCode ? true : false); |
---|
2156 | |
---|
2157 | READ_FLAG(uiCode, PTL_TRACE_TEXT("interlaced_source_flag" )); ptl->setInterlacedSourceFlag(uiCode ? true : false); |
---|
2158 | |
---|
2159 | READ_FLAG(uiCode, PTL_TRACE_TEXT("non_packed_constraint_flag" )); ptl->setNonPackedConstraintFlag(uiCode ? true : false); |
---|
2160 | |
---|
2161 | READ_FLAG(uiCode, PTL_TRACE_TEXT("frame_only_constraint_flag" )); ptl->setFrameOnlyConstraintFlag(uiCode ? true : false); |
---|
2162 | |
---|
2163 | if (ptl->getProfileIdc() == Profile::MAINREXT || ptl->getProfileCompatibilityFlag(Profile::MAINREXT) || |
---|
2164 | ptl->getProfileIdc() == Profile::HIGHTHROUGHPUTREXT || ptl->getProfileCompatibilityFlag(Profile::HIGHTHROUGHPUTREXT)) |
---|
2165 | { |
---|
2166 | UInt maxBitDepth=16; |
---|
2167 | READ_FLAG( uiCode, PTL_TRACE_TEXT("max_12bit_constraint_flag" )); if (uiCode) maxBitDepth=12; |
---|
2168 | READ_FLAG( uiCode, PTL_TRACE_TEXT("max_10bit_constraint_flag" )); if (uiCode) maxBitDepth=10; |
---|
2169 | READ_FLAG( uiCode, PTL_TRACE_TEXT("max_8bit_constraint_flag" )); if (uiCode) maxBitDepth=8; |
---|
2170 | ptl->setBitDepthConstraint(maxBitDepth); |
---|
2171 | ChromaFormat chromaFmtConstraint=CHROMA_444; |
---|
2172 | READ_FLAG( uiCode, PTL_TRACE_TEXT("max_422chroma_constraint_flag" )); if (uiCode) chromaFmtConstraint=CHROMA_422; |
---|
2173 | READ_FLAG( uiCode, PTL_TRACE_TEXT("max_420chroma_constraint_flag" )); if (uiCode) chromaFmtConstraint=CHROMA_420; |
---|
2174 | READ_FLAG( uiCode, PTL_TRACE_TEXT("max_monochrome_constraint_flag" )); if (uiCode) chromaFmtConstraint=CHROMA_400; |
---|
2175 | ptl->setChromaFormatConstraint(chromaFmtConstraint); |
---|
2176 | READ_FLAG( uiCode, PTL_TRACE_TEXT("intra_constraint_flag" )); ptl->setIntraConstraintFlag(uiCode != 0); |
---|
2177 | READ_FLAG( uiCode, PTL_TRACE_TEXT("one_picture_only_constraint_flag")); |
---|
2178 | READ_FLAG( uiCode, PTL_TRACE_TEXT("lower_bit_rate_constraint_flag" )); ptl->setLowerBitRateConstraintFlag(uiCode != 0); |
---|
2179 | #if SVC_EXTENSION |
---|
2180 | READ_CODE(32, uiCode, "general_reserved_zero_34bits"); READ_CODE(2, uiCode, "general_reserved_zero_34bits"); |
---|
2181 | } |
---|
2182 | else if( ptl->getProfileIdc() == Profile::SCALABLEMAIN ) |
---|
2183 | { |
---|
2184 | READ_FLAG( uiCode, "general_max_12bit_constraint_flag" ); assert (uiCode == 1); |
---|
2185 | READ_FLAG( uiCode, "general_max_10bit_constraint_flag" ); assert (uiCode == 1); |
---|
2186 | READ_FLAG( uiCode, "general_max_8bit_constraint_flag" ); ptl->setProfileIdc ((uiCode) ? Profile::SCALABLEMAIN : Profile::SCALABLEMAIN10); |
---|
2187 | READ_FLAG( uiCode, "general_max_422chroma_constraint_flag" ); assert (uiCode == 1); |
---|
2188 | READ_FLAG( uiCode, "general_max_420chroma_constraint_flag" ); assert (uiCode == 1); |
---|
2189 | READ_FLAG( uiCode, "general_max_monochrome_constraint_flag" ); assert (uiCode == 0); |
---|
2190 | READ_FLAG( uiCode, "general_intra_constraint_flag"); assert (uiCode == 0); |
---|
2191 | READ_FLAG( uiCode, "general_one_picture_only_constraint_flag"); assert (uiCode == 0); |
---|
2192 | READ_FLAG( uiCode, "general_lower_bit_rate_constraint_flag"); assert (uiCode == 1); |
---|
2193 | READ_CODE(32, uiCode, "general_reserved_zero_34bits"); READ_CODE(2, uiCode, "general_reserved_zero_34bits"); |
---|
2194 | } |
---|
2195 | else |
---|
2196 | { |
---|
2197 | ptl->setBitDepthConstraint((ptl->getProfileIdc() == Profile::MAIN10)?10:8); |
---|
2198 | ptl->setChromaFormatConstraint(CHROMA_420); |
---|
2199 | ptl->setIntraConstraintFlag(false); |
---|
2200 | ptl->setLowerBitRateConstraintFlag(true); |
---|
2201 | READ_CODE(32, uiCode, "general_reserved_zero_43bits"); READ_CODE(11, uiCode, "general_reserved_zero_43bits"); |
---|
2202 | } |
---|
2203 | #else |
---|
2204 | READ_CODE(16, uiCode, PTL_TRACE_TEXT("reserved_zero_34bits[0..15]" )); |
---|
2205 | READ_CODE(16, uiCode, PTL_TRACE_TEXT("reserved_zero_34bits[16..31]" )); |
---|
2206 | READ_CODE(2, uiCode, PTL_TRACE_TEXT("reserved_zero_34bits[32..33]" )); |
---|
2207 | } |
---|
2208 | else |
---|
2209 | { |
---|
2210 | ptl->setBitDepthConstraint((ptl->getProfileIdc() == Profile::MAIN10)?10:8); |
---|
2211 | ptl->setChromaFormatConstraint(CHROMA_420); |
---|
2212 | ptl->setIntraConstraintFlag(false); |
---|
2213 | ptl->setLowerBitRateConstraintFlag(true); |
---|
2214 | READ_CODE(16, uiCode, PTL_TRACE_TEXT("reserved_zero_43bits[0..15]" )); |
---|
2215 | READ_CODE(16, uiCode, PTL_TRACE_TEXT("reserved_zero_43bits[16..31]" )); |
---|
2216 | READ_CODE(11, uiCode, PTL_TRACE_TEXT("reserved_zero_43bits[32..42]" )); |
---|
2217 | } |
---|
2218 | #endif |
---|
2219 | |
---|
2220 | if ((ptl->getProfileIdc() >= Profile::MAIN && ptl->getProfileIdc() <= Profile::HIGHTHROUGHPUTREXT) || |
---|
2221 | ptl->getProfileCompatibilityFlag(Profile::MAIN) || |
---|
2222 | ptl->getProfileCompatibilityFlag(Profile::MAIN10) || |
---|
2223 | ptl->getProfileCompatibilityFlag(Profile::MAINSTILLPICTURE) || |
---|
2224 | ptl->getProfileCompatibilityFlag(Profile::MAINREXT) || |
---|
2225 | ptl->getProfileCompatibilityFlag(Profile::HIGHTHROUGHPUTREXT) ) |
---|
2226 | { |
---|
2227 | #if SVC_EXTENSION |
---|
2228 | READ_FLAG( uiCode, PTL_TRACE_TEXT("inbld_flag" )); |
---|
2229 | #else |
---|
2230 | READ_FLAG( uiCode, PTL_TRACE_TEXT("inbld_flag" )); assert(uiCode == 0); |
---|
2231 | #endif |
---|
2232 | } |
---|
2233 | else |
---|
2234 | { |
---|
2235 | #if SVC_EXTENSION |
---|
2236 | READ_FLAG( uiCode, PTL_TRACE_TEXT("inbld_flag" )); |
---|
2237 | #else |
---|
2238 | READ_FLAG( uiCode, PTL_TRACE_TEXT("reserved_zero_bit" )); |
---|
2239 | #endif |
---|
2240 | } |
---|
2241 | #undef PTL_TRACE_TEXT |
---|
2242 | } |
---|
2243 | |
---|
2244 | Void TDecCavlc::parseTerminatingBit( UInt& ruiBit ) |
---|
2245 | { |
---|
2246 | ruiBit = false; |
---|
2247 | Int iBitsLeft = m_pcBitstream->getNumBitsLeft(); |
---|
2248 | if(iBitsLeft <= 8) |
---|
2249 | { |
---|
2250 | UInt uiPeekValue = m_pcBitstream->peekBits(iBitsLeft); |
---|
2251 | if (uiPeekValue == (1<<(iBitsLeft-1))) |
---|
2252 | { |
---|
2253 | ruiBit = true; |
---|
2254 | } |
---|
2255 | } |
---|
2256 | } |
---|
2257 | |
---|
2258 | Void TDecCavlc::parseRemainingBytes( Bool noTrailingBytesExpected ) |
---|
2259 | { |
---|
2260 | if (noTrailingBytesExpected) |
---|
2261 | { |
---|
2262 | const UInt numberOfRemainingSubstreamBytes=m_pcBitstream->getNumBitsLeft(); |
---|
2263 | assert (numberOfRemainingSubstreamBytes == 0); |
---|
2264 | } |
---|
2265 | else |
---|
2266 | { |
---|
2267 | while (m_pcBitstream->getNumBitsLeft()) |
---|
2268 | { |
---|
2269 | UInt trailingNullByte=m_pcBitstream->readByte(); |
---|
2270 | if (trailingNullByte!=0) |
---|
2271 | { |
---|
2272 | printf("Trailing byte should be 0, but has value %02x\n", trailingNullByte); |
---|
2273 | assert(trailingNullByte==0); |
---|
2274 | } |
---|
2275 | } |
---|
2276 | } |
---|
2277 | } |
---|
2278 | |
---|
2279 | Void TDecCavlc::parseSkipFlag( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
2280 | { |
---|
2281 | assert(0); |
---|
2282 | } |
---|
2283 | |
---|
2284 | Void TDecCavlc::parseCUTransquantBypassFlag( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
2285 | { |
---|
2286 | assert(0); |
---|
2287 | } |
---|
2288 | |
---|
2289 | Void TDecCavlc::parseMVPIdx( Int& /*riMVPIdx*/ ) |
---|
2290 | { |
---|
2291 | assert(0); |
---|
2292 | } |
---|
2293 | |
---|
2294 | Void TDecCavlc::parseSplitFlag ( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
2295 | { |
---|
2296 | assert(0); |
---|
2297 | } |
---|
2298 | |
---|
2299 | Void TDecCavlc::parsePartSize( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
2300 | { |
---|
2301 | assert(0); |
---|
2302 | } |
---|
2303 | |
---|
2304 | Void TDecCavlc::parsePredMode( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
2305 | { |
---|
2306 | assert(0); |
---|
2307 | } |
---|
2308 | |
---|
2309 | /** Parse I_PCM information. |
---|
2310 | * \param pcCU pointer to CU |
---|
2311 | * \param uiAbsPartIdx CU index |
---|
2312 | * \param uiDepth CU depth |
---|
2313 | * \returns Void |
---|
2314 | * |
---|
2315 | * If I_PCM flag indicates that the CU is I_PCM, parse its PCM alignment bits and codes. |
---|
2316 | */ |
---|
2317 | Void TDecCavlc::parseIPCMInfo( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
2318 | { |
---|
2319 | assert(0); |
---|
2320 | } |
---|
2321 | |
---|
2322 | Void TDecCavlc::parseIntraDirLumaAng ( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
2323 | { |
---|
2324 | assert(0); |
---|
2325 | } |
---|
2326 | |
---|
2327 | Void TDecCavlc::parseIntraDirChroma( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
2328 | { |
---|
2329 | assert(0); |
---|
2330 | } |
---|
2331 | |
---|
2332 | Void TDecCavlc::parseInterDir( TComDataCU* /*pcCU*/, UInt& /*ruiInterDir*/, UInt /*uiAbsPartIdx*/ ) |
---|
2333 | { |
---|
2334 | assert(0); |
---|
2335 | } |
---|
2336 | |
---|
2337 | Void TDecCavlc::parseRefFrmIdx( TComDataCU* /*pcCU*/, Int& /*riRefFrmIdx*/, RefPicList /*eRefList*/ ) |
---|
2338 | { |
---|
2339 | assert(0); |
---|
2340 | } |
---|
2341 | |
---|
2342 | Void TDecCavlc::parseMvd( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiPartIdx*/, UInt /*uiDepth*/, RefPicList /*eRefList*/ ) |
---|
2343 | { |
---|
2344 | assert(0); |
---|
2345 | } |
---|
2346 | |
---|
2347 | Void TDecCavlc::parseCrossComponentPrediction( class TComTU& /*rTu*/, ComponentID /*compID*/ ) |
---|
2348 | { |
---|
2349 | assert(0); |
---|
2350 | } |
---|
2351 | |
---|
2352 | Void TDecCavlc::parseDeltaQP( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2353 | { |
---|
2354 | Int iDQp; |
---|
2355 | |
---|
2356 | #if RExt__DECODER_DEBUG_BIT_STATISTICS |
---|
2357 | READ_SVLC(iDQp, "delta_qp"); |
---|
2358 | #else |
---|
2359 | xReadSvlc( iDQp ); |
---|
2360 | #endif |
---|
2361 | |
---|
2362 | #if SVC_EXTENSION |
---|
2363 | Int qpBdOffsetY = pcCU->getSlice()->getQpBDOffset(CHANNEL_TYPE_LUMA); |
---|
2364 | #else |
---|
2365 | Int qpBdOffsetY = pcCU->getSlice()->getSPS()->getQpBDOffset(CHANNEL_TYPE_LUMA); |
---|
2366 | #endif |
---|
2367 | const Int qp = (((Int) pcCU->getRefQP( uiAbsPartIdx ) + iDQp + 52 + 2*qpBdOffsetY )%(52+ qpBdOffsetY)) - qpBdOffsetY; |
---|
2368 | |
---|
2369 | const UInt maxCUDepth = pcCU->getSlice()->getSPS()->getMaxTotalCUDepth(); |
---|
2370 | const UInt maxCuDQPDepth = pcCU->getSlice()->getPPS()->getMaxCuDQPDepth(); |
---|
2371 | const UInt doubleDepthDifference = ((maxCUDepth - maxCuDQPDepth)<<1); |
---|
2372 | const UInt uiAbsQpCUPartIdx = (uiAbsPartIdx>>doubleDepthDifference)<<doubleDepthDifference ; |
---|
2373 | const UInt uiQpCUDepth = min(uiDepth,pcCU->getSlice()->getPPS()->getMaxCuDQPDepth()) ; |
---|
2374 | |
---|
2375 | pcCU->setQPSubParts( qp, uiAbsQpCUPartIdx, uiQpCUDepth ); |
---|
2376 | } |
---|
2377 | |
---|
2378 | Void TDecCavlc::parseChromaQpAdjustment( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
2379 | { |
---|
2380 | assert(0); |
---|
2381 | } |
---|
2382 | |
---|
2383 | Void TDecCavlc::parseCoeffNxN( TComTU &/*rTu*/, ComponentID /*compID*/ ) |
---|
2384 | { |
---|
2385 | assert(0); |
---|
2386 | } |
---|
2387 | |
---|
2388 | Void TDecCavlc::parseTransformSubdivFlag( UInt& /*ruiSubdivFlag*/, UInt /*uiLog2TransformBlockSize*/ ) |
---|
2389 | { |
---|
2390 | assert(0); |
---|
2391 | } |
---|
2392 | |
---|
2393 | Void TDecCavlc::parseQtCbf( TComTU &/*rTu*/, const ComponentID /*compID*/, const Bool /*lowestLevel*/ ) |
---|
2394 | { |
---|
2395 | assert(0); |
---|
2396 | } |
---|
2397 | |
---|
2398 | Void TDecCavlc::parseQtRootCbf( UInt /*uiAbsPartIdx*/, UInt& /*uiQtRootCbf*/ ) |
---|
2399 | { |
---|
2400 | assert(0); |
---|
2401 | } |
---|
2402 | |
---|
2403 | Void TDecCavlc::parseTransformSkipFlags (TComTU &/*rTu*/, ComponentID /*component*/) |
---|
2404 | { |
---|
2405 | assert(0); |
---|
2406 | } |
---|
2407 | |
---|
2408 | Void TDecCavlc::parseMergeFlag ( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/, UInt /*uiPUIdx*/ ) |
---|
2409 | { |
---|
2410 | assert(0); |
---|
2411 | } |
---|
2412 | |
---|
2413 | Void TDecCavlc::parseMergeIndex ( TComDataCU* /*pcCU*/, UInt& /*ruiMergeIndex*/ ) |
---|
2414 | { |
---|
2415 | assert(0); |
---|
2416 | } |
---|
2417 | |
---|
2418 | // ==================================================================================================================== |
---|
2419 | // Protected member functions |
---|
2420 | // ==================================================================================================================== |
---|
2421 | |
---|
2422 | //! parse explicit wp tables |
---|
2423 | Void TDecCavlc::xParsePredWeightTable( TComSlice* pcSlice, const TComSPS *sps ) |
---|
2424 | { |
---|
2425 | WPScalingParam *wp; |
---|
2426 | const ChromaFormat chFmt = sps->getChromaFormatIdc(); |
---|
2427 | const Int numValidComp = Int(getNumberValidComponents(chFmt)); |
---|
2428 | const Bool bChroma = (chFmt!=CHROMA_400); |
---|
2429 | const SliceType eSliceType = pcSlice->getSliceType(); |
---|
2430 | const Int iNbRef = (eSliceType == B_SLICE ) ? (2) : (1); |
---|
2431 | UInt uiLog2WeightDenomLuma=0, uiLog2WeightDenomChroma=0; |
---|
2432 | UInt uiTotalSignalledWeightFlags = 0; |
---|
2433 | |
---|
2434 | Int iDeltaDenom; |
---|
2435 | // decode delta_luma_log2_weight_denom : |
---|
2436 | READ_UVLC( uiLog2WeightDenomLuma, "luma_log2_weight_denom" ); |
---|
2437 | assert( uiLog2WeightDenomLuma <= 7 ); |
---|
2438 | if( bChroma ) |
---|
2439 | { |
---|
2440 | READ_SVLC( iDeltaDenom, "delta_chroma_log2_weight_denom" ); |
---|
2441 | assert((iDeltaDenom + (Int)uiLog2WeightDenomLuma)>=0); |
---|
2442 | assert((iDeltaDenom + (Int)uiLog2WeightDenomLuma)<=7); |
---|
2443 | uiLog2WeightDenomChroma = (UInt)(iDeltaDenom + uiLog2WeightDenomLuma); |
---|
2444 | } |
---|
2445 | |
---|
2446 | for ( Int iNumRef=0 ; iNumRef<iNbRef ; iNumRef++ ) // loop over l0 and l1 syntax elements |
---|
2447 | { |
---|
2448 | RefPicList eRefPicList = ( iNumRef ? REF_PIC_LIST_1 : REF_PIC_LIST_0 ); |
---|
2449 | for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ ) |
---|
2450 | { |
---|
2451 | pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); |
---|
2452 | |
---|
2453 | wp[COMPONENT_Y].uiLog2WeightDenom = uiLog2WeightDenomLuma; |
---|
2454 | for(Int j=1; j<numValidComp; j++) |
---|
2455 | { |
---|
2456 | wp[j].uiLog2WeightDenom = uiLog2WeightDenomChroma; |
---|
2457 | } |
---|
2458 | |
---|
2459 | UInt uiCode; |
---|
2460 | READ_FLAG( uiCode, iNumRef==0?"luma_weight_l0_flag[i]":"luma_weight_l1_flag[i]" ); |
---|
2461 | wp[COMPONENT_Y].bPresentFlag = ( uiCode == 1 ); |
---|
2462 | uiTotalSignalledWeightFlags += wp[COMPONENT_Y].bPresentFlag; |
---|
2463 | } |
---|
2464 | if ( bChroma ) |
---|
2465 | { |
---|
2466 | UInt uiCode; |
---|
2467 | for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ ) |
---|
2468 | { |
---|
2469 | pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); |
---|
2470 | READ_FLAG( uiCode, iNumRef==0?"chroma_weight_l0_flag[i]":"chroma_weight_l1_flag[i]" ); |
---|
2471 | for(Int j=1; j<numValidComp; j++) |
---|
2472 | { |
---|
2473 | wp[j].bPresentFlag = ( uiCode == 1 ); |
---|
2474 | } |
---|
2475 | uiTotalSignalledWeightFlags += 2*wp[COMPONENT_Cb].bPresentFlag; |
---|
2476 | } |
---|
2477 | } |
---|
2478 | for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ ) |
---|
2479 | { |
---|
2480 | pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); |
---|
2481 | if ( wp[COMPONENT_Y].bPresentFlag ) |
---|
2482 | { |
---|
2483 | Int iDeltaWeight; |
---|
2484 | READ_SVLC( iDeltaWeight, iNumRef==0?"delta_luma_weight_l0[i]":"delta_luma_weight_l1[i]" ); |
---|
2485 | assert( iDeltaWeight >= -128 ); |
---|
2486 | assert( iDeltaWeight <= 127 ); |
---|
2487 | wp[COMPONENT_Y].iWeight = (iDeltaWeight + (1<<wp[COMPONENT_Y].uiLog2WeightDenom)); |
---|
2488 | READ_SVLC( wp[COMPONENT_Y].iOffset, iNumRef==0?"luma_offset_l0[i]":"luma_offset_l1[i]" ); |
---|
2489 | #if SVC_EXTENSION |
---|
2490 | Int range=sps->getSpsRangeExtension().getHighPrecisionOffsetsEnabledFlag() ? (1<<pcSlice->getBitDepth(CHANNEL_TYPE_LUMA))/2 : 128; |
---|
2491 | #else |
---|
2492 | Int range=sps->getSpsRangeExtension().getHighPrecisionOffsetsEnabledFlag() ? (1<<sps->getBitDepth(CHANNEL_TYPE_LUMA))/2 : 128; |
---|
2493 | #endif |
---|
2494 | assert( wp[0].iOffset >= -range ); |
---|
2495 | assert( wp[0].iOffset < range ); |
---|
2496 | } |
---|
2497 | else |
---|
2498 | { |
---|
2499 | wp[COMPONENT_Y].iWeight = (1 << wp[COMPONENT_Y].uiLog2WeightDenom); |
---|
2500 | wp[COMPONENT_Y].iOffset = 0; |
---|
2501 | } |
---|
2502 | if ( bChroma ) |
---|
2503 | { |
---|
2504 | if ( wp[COMPONENT_Cb].bPresentFlag ) |
---|
2505 | { |
---|
2506 | #if SVC_EXTENSION |
---|
2507 | Int range=sps->getSpsRangeExtension().getHighPrecisionOffsetsEnabledFlag() ? (1<<pcSlice->getBitDepth(CHANNEL_TYPE_CHROMA))/2 : 128; |
---|
2508 | #else |
---|
2509 | Int range=sps->getSpsRangeExtension().getHighPrecisionOffsetsEnabledFlag() ? (1<<sps->getBitDepth(CHANNEL_TYPE_CHROMA))/2 : 128; |
---|
2510 | #endif |
---|
2511 | for ( Int j=1 ; j<numValidComp ; j++ ) |
---|
2512 | { |
---|
2513 | Int iDeltaWeight; |
---|
2514 | READ_SVLC( iDeltaWeight, iNumRef==0?"delta_chroma_weight_l0[i]":"delta_chroma_weight_l1[i]" ); |
---|
2515 | assert( iDeltaWeight >= -128 ); |
---|
2516 | assert( iDeltaWeight <= 127 ); |
---|
2517 | wp[j].iWeight = (iDeltaWeight + (1<<wp[j].uiLog2WeightDenom)); |
---|
2518 | |
---|
2519 | Int iDeltaChroma; |
---|
2520 | READ_SVLC( iDeltaChroma, iNumRef==0?"delta_chroma_offset_l0[i]":"delta_chroma_offset_l1[i]" ); |
---|
2521 | assert( iDeltaChroma >= -4*range); |
---|
2522 | assert( iDeltaChroma < 4*range); |
---|
2523 | Int pred = ( range - ( ( range*wp[j].iWeight)>>(wp[j].uiLog2WeightDenom) ) ); |
---|
2524 | wp[j].iOffset = Clip3(-range, range-1, (iDeltaChroma + pred) ); |
---|
2525 | } |
---|
2526 | } |
---|
2527 | else |
---|
2528 | { |
---|
2529 | for ( Int j=1 ; j<numValidComp ; j++ ) |
---|
2530 | { |
---|
2531 | wp[j].iWeight = (1 << wp[j].uiLog2WeightDenom); |
---|
2532 | wp[j].iOffset = 0; |
---|
2533 | } |
---|
2534 | } |
---|
2535 | } |
---|
2536 | } |
---|
2537 | |
---|
2538 | for ( Int iRefIdx=pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx<MAX_NUM_REF ; iRefIdx++ ) |
---|
2539 | { |
---|
2540 | pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); |
---|
2541 | |
---|
2542 | wp[0].bPresentFlag = false; |
---|
2543 | wp[1].bPresentFlag = false; |
---|
2544 | wp[2].bPresentFlag = false; |
---|
2545 | } |
---|
2546 | } |
---|
2547 | assert(uiTotalSignalledWeightFlags<=24); |
---|
2548 | } |
---|
2549 | |
---|
2550 | /** decode quantization matrix |
---|
2551 | * \param scalingList quantization matrix information |
---|
2552 | */ |
---|
2553 | Void TDecCavlc::parseScalingList(TComScalingList* scalingList) |
---|
2554 | { |
---|
2555 | UInt code, sizeId, listId; |
---|
2556 | Bool scalingListPredModeFlag; |
---|
2557 | //for each size |
---|
2558 | for(sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
2559 | { |
---|
2560 | for(listId = 0; listId < SCALING_LIST_NUM; listId++) |
---|
2561 | { |
---|
2562 | if ((sizeId==SCALING_LIST_32x32) && (listId%(SCALING_LIST_NUM/NUMBER_OF_PREDICTION_MODES) != 0)) |
---|
2563 | { |
---|
2564 | Int *src = scalingList->getScalingListAddress(sizeId, listId); |
---|
2565 | const Int size = min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId]); |
---|
2566 | const Int *srcNextSmallerSize = scalingList->getScalingListAddress(sizeId-1, listId); |
---|
2567 | for(Int i=0; i<size; i++) |
---|
2568 | { |
---|
2569 | src[i] = srcNextSmallerSize[i]; |
---|
2570 | } |
---|
2571 | scalingList->setScalingListDC(sizeId,listId,(sizeId > SCALING_LIST_8x8) ? scalingList->getScalingListDC(sizeId-1, listId) : src[0]); |
---|
2572 | } |
---|
2573 | else |
---|
2574 | { |
---|
2575 | READ_FLAG( code, "scaling_list_pred_mode_flag"); |
---|
2576 | scalingListPredModeFlag = (code) ? true : false; |
---|
2577 | scalingList->setScalingListPredModeFlag(sizeId, listId, scalingListPredModeFlag); |
---|
2578 | if(!scalingListPredModeFlag) //Copy Mode |
---|
2579 | { |
---|
2580 | READ_UVLC( code, "scaling_list_pred_matrix_id_delta"); |
---|
2581 | |
---|
2582 | if (sizeId==SCALING_LIST_32x32) |
---|
2583 | { |
---|
2584 | code*=(SCALING_LIST_NUM/NUMBER_OF_PREDICTION_MODES); // Adjust the decoded code for this size, to cope with the missing 32x32 chroma entries. |
---|
2585 | } |
---|
2586 | |
---|
2587 | scalingList->setRefMatrixId (sizeId,listId,(UInt)((Int)(listId)-(code))); |
---|
2588 | if( sizeId > SCALING_LIST_8x8 ) |
---|
2589 | { |
---|
2590 | scalingList->setScalingListDC(sizeId,listId,((listId == scalingList->getRefMatrixId (sizeId,listId))? 16 :scalingList->getScalingListDC(sizeId, scalingList->getRefMatrixId (sizeId,listId)))); |
---|
2591 | } |
---|
2592 | scalingList->processRefMatrix( sizeId, listId, scalingList->getRefMatrixId (sizeId,listId)); |
---|
2593 | |
---|
2594 | } |
---|
2595 | else //DPCM Mode |
---|
2596 | { |
---|
2597 | xDecodeScalingList(scalingList, sizeId, listId); |
---|
2598 | } |
---|
2599 | } |
---|
2600 | } |
---|
2601 | } |
---|
2602 | |
---|
2603 | return; |
---|
2604 | } |
---|
2605 | /** decode DPCM |
---|
2606 | * \param scalingList quantization matrix information |
---|
2607 | * \param sizeId size index |
---|
2608 | * \param listId list index |
---|
2609 | */ |
---|
2610 | Void TDecCavlc::xDecodeScalingList(TComScalingList *scalingList, UInt sizeId, UInt listId) |
---|
2611 | { |
---|
2612 | Int i,coefNum = min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId]); |
---|
2613 | Int data; |
---|
2614 | Int scalingListDcCoefMinus8 = 0; |
---|
2615 | Int nextCoef = SCALING_LIST_START_VALUE; |
---|
2616 | UInt* scan = g_scanOrder[SCAN_UNGROUPED][SCAN_DIAG][sizeId==0 ? 2 : 3][sizeId==0 ? 2 : 3]; |
---|
2617 | Int *dst = scalingList->getScalingListAddress(sizeId, listId); |
---|
2618 | |
---|
2619 | if( sizeId > SCALING_LIST_8x8 ) |
---|
2620 | { |
---|
2621 | READ_SVLC( scalingListDcCoefMinus8, "scaling_list_dc_coef_minus8"); |
---|
2622 | scalingList->setScalingListDC(sizeId,listId,scalingListDcCoefMinus8 + 8); |
---|
2623 | nextCoef = scalingList->getScalingListDC(sizeId,listId); |
---|
2624 | } |
---|
2625 | |
---|
2626 | for(i = 0; i < coefNum; i++) |
---|
2627 | { |
---|
2628 | READ_SVLC( data, "scaling_list_delta_coef"); |
---|
2629 | nextCoef = (nextCoef + data + 256 ) % 256; |
---|
2630 | dst[scan[i]] = nextCoef; |
---|
2631 | } |
---|
2632 | } |
---|
2633 | |
---|
2634 | Bool TDecCavlc::xMoreRbspData() |
---|
2635 | { |
---|
2636 | Int bitsLeft = m_pcBitstream->getNumBitsLeft(); |
---|
2637 | |
---|
2638 | // if there are more than 8 bits, it cannot be rbsp_trailing_bits |
---|
2639 | if (bitsLeft > 8) |
---|
2640 | { |
---|
2641 | return true; |
---|
2642 | } |
---|
2643 | |
---|
2644 | UChar lastByte = m_pcBitstream->peekBits(bitsLeft); |
---|
2645 | Int cnt = bitsLeft; |
---|
2646 | |
---|
2647 | // remove trailing bits equal to zero |
---|
2648 | while ((cnt>0) && ((lastByte & 1) == 0)) |
---|
2649 | { |
---|
2650 | lastByte >>= 1; |
---|
2651 | cnt--; |
---|
2652 | } |
---|
2653 | // remove bit equal to one |
---|
2654 | cnt--; |
---|
2655 | |
---|
2656 | // we should not have a negative number of bits |
---|
2657 | assert (cnt>=0); |
---|
2658 | |
---|
2659 | // we have more data, if cnt is not zero |
---|
2660 | return (cnt>0); |
---|
2661 | } |
---|
2662 | |
---|
2663 | Void TDecCavlc::parseExplicitRdpcmMode( TComTU& /*rTu*/, ComponentID /*compID*/ ) |
---|
2664 | { |
---|
2665 | assert(0); |
---|
2666 | } |
---|
2667 | |
---|
2668 | #if SVC_EXTENSION |
---|
2669 | Void TDecCavlc::parseVPSExtension(TComVPS *vps) |
---|
2670 | { |
---|
2671 | UInt uiCode; |
---|
2672 | Int NumOutputLayersInOutputLayerSet[MAX_VPS_LAYER_SETS_PLUS1]; |
---|
2673 | Int OlsHighestOutputLayerId[MAX_VPS_LAYER_SETS_PLUS1]; |
---|
2674 | |
---|
2675 | if( vps->getMaxLayers() > 1 && vps->getBaseLayerInternalFlag() ) |
---|
2676 | { |
---|
2677 | vps->setProfilePresentFlag(1, false); |
---|
2678 | parsePTL( vps->getPTL(1), vps->getProfilePresentFlag(1), vps->getMaxTLayers() - 1 ); |
---|
2679 | } |
---|
2680 | |
---|
2681 | UInt numScalabilityTypes = 0, i = 0, j = 0; |
---|
2682 | |
---|
2683 | READ_FLAG( uiCode, "splitting_flag" ); vps->setSplittingFlag(uiCode ? true : false); |
---|
2684 | |
---|
2685 | for(i = 0; i < MAX_VPS_NUM_SCALABILITY_TYPES; i++) |
---|
2686 | { |
---|
2687 | READ_FLAG( uiCode, "scalability_mask[i]" ); vps->setScalabilityMask(i, uiCode ? true : false); |
---|
2688 | numScalabilityTypes += uiCode; |
---|
2689 | } |
---|
2690 | vps->setNumScalabilityTypes(numScalabilityTypes); |
---|
2691 | |
---|
2692 | for(j = 0; j < numScalabilityTypes - vps->getSplittingFlag(); j++) |
---|
2693 | { |
---|
2694 | READ_CODE( 3, uiCode, "dimension_id_len_minus1[j]" ); vps->setDimensionIdLen(j, uiCode + 1); |
---|
2695 | } |
---|
2696 | |
---|
2697 | // The value of dimBitOffset[ NumScalabilityTypes ] is set equal to 6. |
---|
2698 | if(vps->getSplittingFlag()) |
---|
2699 | { |
---|
2700 | UInt numBits = 0; |
---|
2701 | for(j = 0; j < numScalabilityTypes - 1; j++) |
---|
2702 | { |
---|
2703 | numBits += vps->getDimensionIdLen(j); |
---|
2704 | } |
---|
2705 | assert( numBits < 6 ); |
---|
2706 | vps->setDimensionIdLen(numScalabilityTypes-1, 6 - numBits); |
---|
2707 | numBits = 6; |
---|
2708 | } |
---|
2709 | |
---|
2710 | READ_FLAG( uiCode, "vps_nuh_layer_id_present_flag" ); vps->setNuhLayerIdPresentFlag(uiCode ? true : false); |
---|
2711 | vps->setLayerIdInNuh(0, 0); |
---|
2712 | vps->setLayerIdxInVps(0, 0); |
---|
2713 | for(i = 1; i < vps->getMaxLayers(); i++) |
---|
2714 | { |
---|
2715 | if( vps->getNuhLayerIdPresentFlag() ) |
---|
2716 | { |
---|
2717 | READ_CODE( 6, uiCode, "layer_id_in_nuh[i]" ); vps->setLayerIdInNuh(i, uiCode); |
---|
2718 | assert( uiCode > vps->getLayerIdInNuh(i-1) ); |
---|
2719 | } |
---|
2720 | else |
---|
2721 | { |
---|
2722 | vps->setLayerIdInNuh(i, i); |
---|
2723 | } |
---|
2724 | vps->setLayerIdxInVps(vps->getLayerIdInNuh(i), i); |
---|
2725 | |
---|
2726 | if( !vps->getSplittingFlag() ) |
---|
2727 | { |
---|
2728 | for(j = 0; j < numScalabilityTypes; j++) |
---|
2729 | { |
---|
2730 | READ_CODE( vps->getDimensionIdLen(j), uiCode, "dimension_id[i][j]" ); vps->setDimensionId(i, j, uiCode); |
---|
2731 | #if !AUXILIARY_PICTURES |
---|
2732 | assert( uiCode <= vps->getMaxLayerId() ); |
---|
2733 | #endif |
---|
2734 | } |
---|
2735 | } |
---|
2736 | } |
---|
2737 | |
---|
2738 | READ_CODE( 4, uiCode, "view_id_len" ); vps->setViewIdLen( uiCode ); |
---|
2739 | |
---|
2740 | if ( vps->getViewIdLen() > 0 ) |
---|
2741 | { |
---|
2742 | for( i = 0; i < vps->getNumViews(); i++ ) |
---|
2743 | { |
---|
2744 | READ_CODE( vps->getViewIdLen( ), uiCode, "view_id_val[i]" ); vps->setViewIdVal( i, uiCode ); |
---|
2745 | } |
---|
2746 | } |
---|
2747 | |
---|
2748 | // For layer 0 |
---|
2749 | vps->setNumDirectRefLayers(0, 0); |
---|
2750 | // For other layers |
---|
2751 | for( Int layerCtr = 1; layerCtr < vps->getMaxLayers(); layerCtr++) |
---|
2752 | { |
---|
2753 | UInt layerId = vps->getLayerIdInNuh(layerCtr); |
---|
2754 | UInt numDirectRefLayers = 0; |
---|
2755 | for( Int refLayerCtr = 0; refLayerCtr < layerCtr; refLayerCtr++) |
---|
2756 | { |
---|
2757 | READ_FLAG(uiCode, "direct_dependency_flag[i][j]" ); vps->setDirectDependencyFlag(layerCtr, refLayerCtr, uiCode? true : false); |
---|
2758 | if(uiCode) |
---|
2759 | { |
---|
2760 | vps->setRefLayerId(layerId, numDirectRefLayers, vps->getLayerIdInNuh(refLayerCtr)); |
---|
2761 | numDirectRefLayers++; |
---|
2762 | } |
---|
2763 | } |
---|
2764 | vps->setNumDirectRefLayers(layerId, numDirectRefLayers); |
---|
2765 | } |
---|
2766 | |
---|
2767 | // dependency constraint |
---|
2768 | vps->setNumRefLayers(); |
---|
2769 | |
---|
2770 | if (vps->getMaxLayers() > MAX_REF_LAYERS) |
---|
2771 | { |
---|
2772 | for (i = 1; i < vps->getMaxLayers(); i++) |
---|
2773 | { |
---|
2774 | assert(vps->getNumRefLayers(vps->getLayerIdInNuh(i)) <= MAX_REF_LAYERS); |
---|
2775 | } |
---|
2776 | } |
---|
2777 | |
---|
2778 | vps->setPredictedLayerIds(); |
---|
2779 | vps->setTreePartitionLayerIdList(); |
---|
2780 | |
---|
2781 | if( vps->getNumIndependentLayers() > 1 ) |
---|
2782 | { |
---|
2783 | READ_UVLC(uiCode, "num_add_layer_sets"); vps->setNumAddLayerSets(uiCode); |
---|
2784 | |
---|
2785 | for( i = 0; i < vps->getNumAddLayerSets(); i++ ) |
---|
2786 | { |
---|
2787 | for( j = 1; j < vps->getNumIndependentLayers(); j++ ) |
---|
2788 | { |
---|
2789 | Int len = 1; |
---|
2790 | while( (1 << len) < (vps->getNumLayersInTreePartition(j) + 1) ) |
---|
2791 | { |
---|
2792 | len++; |
---|
2793 | } |
---|
2794 | |
---|
2795 | READ_CODE(len, uiCode, "highest_layer_idx_plus1[i][j]"); vps->setHighestLayerIdxPlus1(i, j, uiCode); |
---|
2796 | } |
---|
2797 | } |
---|
2798 | vps->setNumLayerSets(vps->getNumLayerSets() + vps->getNumAddLayerSets()); |
---|
2799 | vps->deriveLayerIdListVariablesForAddLayerSets(); |
---|
2800 | } |
---|
2801 | else |
---|
2802 | { |
---|
2803 | vps->setNumAddLayerSets(0); |
---|
2804 | } |
---|
2805 | |
---|
2806 | READ_FLAG( uiCode, "vps_sub_layers_max_minus1_present_flag"); vps->setMaxTSLayersPresentFlag(uiCode ? true : false); |
---|
2807 | |
---|
2808 | if (vps->getMaxTSLayersPresentFlag()) |
---|
2809 | { |
---|
2810 | for(i = 0; i < vps->getMaxLayers(); i++) |
---|
2811 | { |
---|
2812 | READ_CODE( 3, uiCode, "sub_layers_vps_max_minus1[i]" ); vps->setMaxTSLayersMinus1(i, uiCode); |
---|
2813 | } |
---|
2814 | } |
---|
2815 | else |
---|
2816 | { |
---|
2817 | for( i = 0; i < vps->getMaxLayers(); i++) |
---|
2818 | { |
---|
2819 | vps->setMaxTSLayersMinus1(i, vps->getMaxTLayers()-1); |
---|
2820 | } |
---|
2821 | } |
---|
2822 | |
---|
2823 | READ_FLAG( uiCode, "max_tid_ref_present_flag"); vps->setMaxTidRefPresentFlag(uiCode ? true : false); |
---|
2824 | if( vps->getMaxTidRefPresentFlag() ) |
---|
2825 | { |
---|
2826 | for( i = 0; i < vps->getMaxLayers() - 1; i++ ) |
---|
2827 | { |
---|
2828 | for( j = i+1; j < vps->getMaxLayers(); j++ ) |
---|
2829 | { |
---|
2830 | if( vps->getDirectDependencyFlag(j, i) ) |
---|
2831 | { |
---|
2832 | READ_CODE( 3, uiCode, "max_tid_il_ref_pics_plus1[i][j]" ); vps->setMaxTidIlRefPicsPlus1(i, j, uiCode); |
---|
2833 | } |
---|
2834 | } |
---|
2835 | } |
---|
2836 | } |
---|
2837 | else |
---|
2838 | { |
---|
2839 | for(i = 0; i < vps->getMaxLayers() - 1; i++) |
---|
2840 | { |
---|
2841 | for( j = i+1; j < vps->getMaxLayers(); j++) |
---|
2842 | { |
---|
2843 | vps->setMaxTidIlRefPicsPlus1(i, j, 7); |
---|
2844 | } |
---|
2845 | } |
---|
2846 | } |
---|
2847 | READ_FLAG( uiCode, "all_ref_layers_active_flag" ); vps->setIlpSshSignalingEnabledFlag(uiCode ? true : false); |
---|
2848 | |
---|
2849 | // Profile-tier-level signalling |
---|
2850 | READ_UVLC( uiCode, "vps_num_profile_tier_level_minus1"); vps->setNumProfileTierLevel( uiCode + 1 ); |
---|
2851 | |
---|
2852 | Int const numBitsForPtlIdx = vps->calculateLenOfSyntaxElement( vps->getNumProfileTierLevel() ); |
---|
2853 | |
---|
2854 | for( Int idx = vps->getBaseLayerInternalFlag() ? 2 : 1; idx < vps->getNumProfileTierLevel(); idx++ ) |
---|
2855 | { |
---|
2856 | READ_FLAG( uiCode, "vps_profile_present_flag[i]" ); vps->setProfilePresentFlag(idx, uiCode ? true : false); |
---|
2857 | |
---|
2858 | if( !vps->getProfilePresentFlag(idx) ) |
---|
2859 | { |
---|
2860 | // Copy profile information from previous one |
---|
2861 | vps->getPTL(idx)->copyProfileInfo( vps->getPTL( idx - 1 ) ); |
---|
2862 | } |
---|
2863 | |
---|
2864 | parsePTL( vps->getPTL(idx), vps->getProfilePresentFlag(idx), vps->getMaxTLayers() - 1 ); |
---|
2865 | } |
---|
2866 | |
---|
2867 | if( vps->getNumLayerSets() > 1 ) |
---|
2868 | { |
---|
2869 | READ_UVLC( uiCode, "num_add_olss" ); vps->setNumAddOutputLayerSets( uiCode ); |
---|
2870 | READ_CODE( 2, uiCode, "default_output_layer_idc" ); vps->setDefaultTargetOutputLayerIdc( uiCode ); |
---|
2871 | } |
---|
2872 | else |
---|
2873 | { |
---|
2874 | vps->setNumAddOutputLayerSets( 0 ); |
---|
2875 | } |
---|
2876 | |
---|
2877 | // The value of num_add_olss shall be in the range of 0 to 1023, inclusive. |
---|
2878 | assert( vps->getNumAddOutputLayerSets() >= 0 && vps->getNumAddOutputLayerSets() < 1024 ); |
---|
2879 | |
---|
2880 | Int numOutputLayerSets = vps->getNumLayerSets() + vps->getNumAddOutputLayerSets(); |
---|
2881 | |
---|
2882 | vps->setNumOutputLayerSets( numOutputLayerSets ); |
---|
2883 | |
---|
2884 | // Default output layer set |
---|
2885 | vps->setOutputLayerSetIdx(0, 0); |
---|
2886 | vps->setOutputLayerFlag(0, 0, true); |
---|
2887 | vps->deriveNecessaryLayerFlag(0); |
---|
2888 | vps->getProfileLevelTierIdx()->resize(numOutputLayerSets); |
---|
2889 | vps->getProfileLevelTierIdx(0)->push_back( vps->getBaseLayerInternalFlag() && vps->getMaxLayers() > 1 ? 1 : 0); |
---|
2890 | |
---|
2891 | for(i = 1; i < numOutputLayerSets; i++) |
---|
2892 | { |
---|
2893 | if( vps->getNumLayerSets() > 2 && i >= vps->getNumLayerSets() ) |
---|
2894 | { |
---|
2895 | Int numBits = 1; |
---|
2896 | while ((1 << numBits) < (vps->getNumLayerSets() - 1)) |
---|
2897 | { |
---|
2898 | numBits++; |
---|
2899 | } |
---|
2900 | READ_CODE( numBits, uiCode, "layer_set_idx_for_ols_minus1"); vps->setOutputLayerSetIdx( i, uiCode + 1); |
---|
2901 | } |
---|
2902 | else |
---|
2903 | { |
---|
2904 | vps->setOutputLayerSetIdx( i, i ); |
---|
2905 | } |
---|
2906 | |
---|
2907 | Int layerSetIdxForOutputLayerSet = vps->getOutputLayerSetIdx(i); |
---|
2908 | |
---|
2909 | if( i > vps->getVpsNumLayerSetsMinus1() || vps->getDefaultTargetOutputLayerIdc() == 2 ) |
---|
2910 | { |
---|
2911 | for( j = 0; j < vps->getNumLayersInIdList(layerSetIdxForOutputLayerSet); j++ ) |
---|
2912 | { |
---|
2913 | READ_FLAG( uiCode, "output_layer_flag[i][j]"); vps->setOutputLayerFlag(i, j, uiCode); |
---|
2914 | } |
---|
2915 | } |
---|
2916 | else |
---|
2917 | { |
---|
2918 | // i <= (vps->getNumLayerSets() - 1) |
---|
2919 | // Assign OutputLayerFlag depending on default_one_target_output_layer_flag |
---|
2920 | if( vps->getDefaultTargetOutputLayerIdc() == 1 ) |
---|
2921 | { |
---|
2922 | for( j = 0; j < vps->getNumLayersInIdList(layerSetIdxForOutputLayerSet); j++ ) |
---|
2923 | { |
---|
2924 | vps->setOutputLayerFlag(i, j, (j == (vps->getNumLayersInIdList(layerSetIdxForOutputLayerSet)-1)) ); |
---|
2925 | } |
---|
2926 | } |
---|
2927 | else if( vps->getDefaultTargetOutputLayerIdc() == 0 ) |
---|
2928 | { |
---|
2929 | for( j = 0; j < vps->getNumLayersInIdList(layerSetIdxForOutputLayerSet); j++ ) |
---|
2930 | { |
---|
2931 | vps->setOutputLayerFlag(i, j, 1); |
---|
2932 | } |
---|
2933 | } |
---|
2934 | } |
---|
2935 | |
---|
2936 | vps->deriveNecessaryLayerFlag(i); |
---|
2937 | |
---|
2938 | vps->getProfileLevelTierIdx(i)->assign(vps->getNumLayersInIdList(layerSetIdxForOutputLayerSet), -1); |
---|
2939 | |
---|
2940 | for( j = 0; j < vps->getNumLayersInIdList(layerSetIdxForOutputLayerSet); j++ ) |
---|
2941 | { |
---|
2942 | if( vps->getNecessaryLayerFlag(i, j) && (vps->getNumProfileTierLevel()-1) > 0 ) |
---|
2943 | { |
---|
2944 | READ_CODE( numBitsForPtlIdx, uiCode, "profile_tier_level_idx[i]" ); |
---|
2945 | vps->setProfileLevelTierIdx(i, j, uiCode ); |
---|
2946 | |
---|
2947 | //For conformance checking |
---|
2948 | //Conformance of a layer in an output operation point associated with an OLS in a bitstream to the Scalable Main profile is indicated as follows: |
---|
2949 | //If OpTid of the output operation point is equal to vps_max_sub_layer_minus1, the conformance is indicated by general_profile_idc being equal to 7 or general_profile_compatibility_flag[ 7 ] being equal to 1 |
---|
2950 | //Conformance of a layer in an output operation point associated with an OLS in a bitstream to the Scalable Main 10 profile is indicated as follows: |
---|
2951 | //If OpTid of the output operation point is equal to vps_max_sub_layer_minus1, the conformance is indicated by general_profile_idc being equal to 7 or general_profile_compatibility_flag[ 7 ] being equal to 1 |
---|
2952 | //The following assert may be updated / upgraded to take care of general_profile_compatibility_flag. |
---|
2953 | |
---|
2954 | // The assertion below is not valid for independent non-base layers |
---|
2955 | if (vps->getNumAddLayerSets() == 0) |
---|
2956 | { |
---|
2957 | if( j > 0 && vps->getLayerSetLayerIdList(layerSetIdxForOutputLayerSet, j) != 0 && vps->getLayerSetLayerIdList(layerSetIdxForOutputLayerSet, j - 1) != 0 && vps->getNecessaryLayerFlag(i, j-1) ) |
---|
2958 | { |
---|
2959 | assert(vps->getPTL(vps->getProfileLevelTierIdx(i, j))->getGeneralPTL()->getProfileIdc() == vps->getPTL(vps->getProfileLevelTierIdx(i, j - 1))->getGeneralPTL()->getProfileIdc() || |
---|
2960 | vps->getPTL(vps->getProfileLevelTierIdx(i, j - 1))->getGeneralPTL()->getProfileCompatibilityFlag(vps->getPTL(vps->getProfileLevelTierIdx(i, j))->getGeneralPTL()->getProfileIdc()) || |
---|
2961 | vps->getPTL(vps->getProfileLevelTierIdx(i, j))->getGeneralPTL()->getProfileCompatibilityFlag(vps->getPTL(vps->getProfileLevelTierIdx(i, j - 1))->getGeneralPTL()->getProfileIdc()) ); |
---|
2962 | } |
---|
2963 | } |
---|
2964 | } |
---|
2965 | } |
---|
2966 | |
---|
2967 | NumOutputLayersInOutputLayerSet[i] = 0; |
---|
2968 | |
---|
2969 | for( j = 0; j < vps->getNumLayersInIdList(layerSetIdxForOutputLayerSet); j++ ) |
---|
2970 | { |
---|
2971 | NumOutputLayersInOutputLayerSet[i] += vps->getOutputLayerFlag(i, j); |
---|
2972 | if( vps->getOutputLayerFlag(i, j) ) |
---|
2973 | { |
---|
2974 | OlsHighestOutputLayerId[i] = vps->getLayerSetLayerIdList(layerSetIdxForOutputLayerSet, j); |
---|
2975 | } |
---|
2976 | } |
---|
2977 | |
---|
2978 | if( NumOutputLayersInOutputLayerSet[i] == 1 && vps->getNumDirectRefLayers(OlsHighestOutputLayerId[i]) > 0 ) |
---|
2979 | { |
---|
2980 | READ_FLAG(uiCode, "alt_output_layer_flag[i]"); |
---|
2981 | vps->setAltOuputLayerFlag(i, uiCode ? true : false); |
---|
2982 | } |
---|
2983 | else |
---|
2984 | { |
---|
2985 | vps->setAltOuputLayerFlag(i, false); |
---|
2986 | } |
---|
2987 | |
---|
2988 | assert( NumOutputLayersInOutputLayerSet[i] > 0 ); |
---|
2989 | } |
---|
2990 | |
---|
2991 | vps->checkNecessaryLayerFlagCondition(); |
---|
2992 | |
---|
2993 | READ_UVLC( uiCode, "vps_num_rep_formats_minus1" ); |
---|
2994 | vps->setVpsNumRepFormats( uiCode + 1 ); |
---|
2995 | |
---|
2996 | // The value of vps_num_rep_formats_minus1 shall be in the range of 0 to 255, inclusive. |
---|
2997 | assert( vps->getVpsNumRepFormats() > 0 && vps->getVpsNumRepFormats() <= 256 ); |
---|
2998 | |
---|
2999 | for(i = 0; i < vps->getVpsNumRepFormats(); i++) |
---|
3000 | { |
---|
3001 | // Read rep_format_structures |
---|
3002 | parseRepFormat( vps->getVpsRepFormat(i), i > 0 ? vps->getVpsRepFormat(i-1) : 0 ); |
---|
3003 | } |
---|
3004 | |
---|
3005 | // Default assignment for layer 0 |
---|
3006 | vps->setVpsRepFormatIdx( 0, 0 ); |
---|
3007 | |
---|
3008 | if( vps->getVpsNumRepFormats() > 1 ) |
---|
3009 | { |
---|
3010 | READ_FLAG( uiCode, "rep_format_idx_present_flag"); |
---|
3011 | vps->setRepFormatIdxPresentFlag( uiCode ? true : false ); |
---|
3012 | } |
---|
3013 | else |
---|
3014 | { |
---|
3015 | // When not present, the value of rep_format_idx_present_flag is inferred to be equal to 0 |
---|
3016 | vps->setRepFormatIdxPresentFlag( false ); |
---|
3017 | } |
---|
3018 | |
---|
3019 | if( vps->getRepFormatIdxPresentFlag() ) |
---|
3020 | { |
---|
3021 | for( i = vps->getBaseLayerInternalFlag() ? 1 : 0; i < vps->getMaxLayers(); i++ ) |
---|
3022 | { |
---|
3023 | Int numBits = 1; |
---|
3024 | while ((1 << numBits) < (vps->getVpsNumRepFormats())) |
---|
3025 | { |
---|
3026 | numBits++; |
---|
3027 | } |
---|
3028 | READ_CODE( numBits, uiCode, "vps_rep_format_idx[i]" ); |
---|
3029 | vps->setVpsRepFormatIdx( i, uiCode ); |
---|
3030 | } |
---|
3031 | } |
---|
3032 | else |
---|
3033 | { |
---|
3034 | // When not present, the value of vps_rep_format_idx[ i ] is inferred to be equal to Min (i, vps_num_rep_formats_minus1) |
---|
3035 | for(i = 1; i < vps->getMaxLayers(); i++) |
---|
3036 | { |
---|
3037 | vps->setVpsRepFormatIdx( i, min( (Int)i, vps->getVpsNumRepFormats()-1 ) ); |
---|
3038 | } |
---|
3039 | } |
---|
3040 | |
---|
3041 | READ_FLAG(uiCode, "max_one_active_ref_layer_flag" ); |
---|
3042 | vps->setMaxOneActiveRefLayerFlag(uiCode); |
---|
3043 | |
---|
3044 | READ_FLAG(uiCode, "vps_poc_lsb_aligned_flag"); |
---|
3045 | vps->setVpsPocLsbAlignedFlag(uiCode); |
---|
3046 | |
---|
3047 | for( i = 1; i< vps->getMaxLayers(); i++ ) |
---|
3048 | { |
---|
3049 | if( vps->getNumDirectRefLayers( vps->getLayerIdInNuh(i) ) == 0 ) |
---|
3050 | { |
---|
3051 | READ_FLAG(uiCode, "poc_lsb_not_present_flag[i]"); |
---|
3052 | vps->setPocLsbNotPresentFlag(i, uiCode); |
---|
3053 | } |
---|
3054 | } |
---|
3055 | |
---|
3056 | parseVpsDpbSizeTable(vps); |
---|
3057 | |
---|
3058 | READ_UVLC( uiCode, "direct_dep_type_len_minus2"); vps->setDirectDepTypeLen(uiCode+2); |
---|
3059 | |
---|
3060 | READ_FLAG(uiCode, "direct_dependency_all_layers_flag"); |
---|
3061 | vps->setDefaultDirectDependecyTypeFlag(uiCode == 1? true : false); |
---|
3062 | |
---|
3063 | if( vps->getDefaultDirectDependencyTypeFlag() ) |
---|
3064 | { |
---|
3065 | READ_CODE( vps->getDirectDepTypeLen(), uiCode, "direct_dependency_all_layers_type" ); |
---|
3066 | vps->setDefaultDirectDependecyType(uiCode); |
---|
3067 | } |
---|
3068 | |
---|
3069 | for( i = vps->getBaseLayerInternalFlag() ? 1 : 2; i < vps->getMaxLayers(); i++ ) |
---|
3070 | { |
---|
3071 | for( j = vps->getBaseLayerInternalFlag() ? 0 : 1; j < i; j++ ) |
---|
3072 | { |
---|
3073 | if( vps->getDirectDependencyFlag(i, j) ) |
---|
3074 | { |
---|
3075 | if (vps->getDefaultDirectDependencyTypeFlag()) |
---|
3076 | { |
---|
3077 | vps->setDirectDependencyType(i, j, vps->getDefaultDirectDependencyType()); |
---|
3078 | } |
---|
3079 | else |
---|
3080 | { |
---|
3081 | READ_CODE( vps->getDirectDepTypeLen(), uiCode, "direct_dependency_type[i][j]" ); |
---|
3082 | vps->setDirectDependencyType(i, j, uiCode); |
---|
3083 | } |
---|
3084 | } |
---|
3085 | } |
---|
3086 | } |
---|
3087 | |
---|
3088 | READ_UVLC( uiCode, "vps_non_vui_extension_length"); vps->setVpsNonVuiExtLength((Int)uiCode); |
---|
3089 | |
---|
3090 | // The value of vps_non_vui_extension_length shall be in the range of 0 to 4096, inclusive. |
---|
3091 | assert( vps->getVpsNonVuiExtLength() >= 0 && vps->getVpsNonVuiExtLength() <= 4096 ); |
---|
3092 | |
---|
3093 | Int nonVuiExtByte = uiCode; |
---|
3094 | for (i = 1; i <= nonVuiExtByte; i++) |
---|
3095 | { |
---|
3096 | READ_CODE( 8, uiCode, "vps_non_vui_extension_data_byte" ); //just parse and discard for now. |
---|
3097 | } |
---|
3098 | |
---|
3099 | READ_FLAG( uiCode, "vps_vui_present_flag"); vps->setVpsVuiPresentFlag(uiCode ? true : false); |
---|
3100 | |
---|
3101 | if ( vps->getVpsVuiPresentFlag() ) |
---|
3102 | { |
---|
3103 | while ( m_pcBitstream->getNumBitsRead() % 8 != 0 ) |
---|
3104 | { |
---|
3105 | READ_FLAG( uiCode, "vps_vui_alignment_bit_equal_to_one"); assert(uiCode == 1); |
---|
3106 | } |
---|
3107 | parseVPSVUI(vps); |
---|
3108 | } |
---|
3109 | else |
---|
3110 | { |
---|
3111 | // set default values for VPS VUI |
---|
3112 | defaultVPSVUI( vps ); |
---|
3113 | } |
---|
3114 | } |
---|
3115 | |
---|
3116 | Void TDecCavlc::defaultVPSExtension( TComVPS* vps ) |
---|
3117 | { |
---|
3118 | // set default parameters when they are not present |
---|
3119 | Int i, j; |
---|
3120 | |
---|
3121 | // When layer_id_in_nuh[ i ] is not present, the value is inferred to be equal to i. |
---|
3122 | for(i = 0; i < vps->getMaxLayers(); i++) |
---|
3123 | { |
---|
3124 | vps->setLayerIdInNuh(i, i); |
---|
3125 | vps->setLayerIdxInVps(vps->getLayerIdInNuh(i), i); |
---|
3126 | } |
---|
3127 | |
---|
3128 | // When not present, sub_layers_vps_max_minus1[ i ] is inferred to be equal to vps_max_sub_layers_minus1. |
---|
3129 | for( i = 0; i < vps->getMaxLayers(); i++) |
---|
3130 | { |
---|
3131 | vps->setMaxTSLayersMinus1(i, vps->getMaxTLayers()-1); |
---|
3132 | } |
---|
3133 | |
---|
3134 | // When not present, max_tid_il_ref_pics_plus1[ i ][ j ] is inferred to be equal to 7. |
---|
3135 | for( i = 0; i < vps->getMaxLayers() - 1; i++ ) |
---|
3136 | { |
---|
3137 | for( j = i + 1; j < vps->getMaxLayers(); j++ ) |
---|
3138 | { |
---|
3139 | vps->setMaxTidIlRefPicsPlus1(i, j, 7); |
---|
3140 | } |
---|
3141 | } |
---|
3142 | |
---|
3143 | // When not present, the value of num_add_olss is inferred to be equal to 0. |
---|
3144 | // NumOutputLayerSets = num_add_olss + NumLayerSets |
---|
3145 | vps->setNumOutputLayerSets( vps->getNumLayerSets() ); |
---|
3146 | |
---|
3147 | // For i in the range of 0 to NumOutputLayerSets-1, inclusive, the variable LayerSetIdxForOutputLayerSet[ i ] is derived as specified in the following: |
---|
3148 | // LayerSetIdxForOutputLayerSet[ i ] = ( i <= vps_number_layer_sets_minus1 ) ? i : layer_set_idx_for_ols_minus1[ i ] + 1 |
---|
3149 | for( i = 1; i < vps->getNumOutputLayerSets(); i++ ) |
---|
3150 | { |
---|
3151 | vps->setOutputLayerSetIdx( i, i ); |
---|
3152 | Int lsIdx = vps->getOutputLayerSetIdx(i); |
---|
3153 | |
---|
3154 | for( j = 0; j < vps->getNumLayersInIdList(lsIdx); j++ ) |
---|
3155 | { |
---|
3156 | vps->setOutputLayerFlag(i, j, 1); |
---|
3157 | } |
---|
3158 | } |
---|
3159 | |
---|
3160 | // Default output layer set |
---|
3161 | // The value of NumLayersInIdList[ 0 ] is set equal to 1 and the value of LayerSetLayerIdList[ 0 ][ 0 ] is set equal to 0. |
---|
3162 | vps->setOutputLayerSetIdx(0, 0); |
---|
3163 | |
---|
3164 | // The value of output_layer_flag[ 0 ][ 0 ] is inferred to be equal to 1. |
---|
3165 | vps->setOutputLayerFlag(0, 0, true); |
---|
3166 | |
---|
3167 | vps->deriveNecessaryLayerFlag(0); |
---|
3168 | |
---|
3169 | // The value of sub_layer_dpb_info_present_flag[ i ][ 0 ] for any possible value of i is inferred to be equal to 1 |
---|
3170 | // When not present, the value of sub_layer_dpb_info_present_flag[ i ][ j ] for j greater than 0 and any possible value of i, is inferred to be equal to be equal to 0. |
---|
3171 | for( i = 1; i < vps->getNumOutputLayerSets(); i++ ) |
---|
3172 | { |
---|
3173 | vps->setSubLayerDpbInfoPresentFlag( i, 0, true ); |
---|
3174 | } |
---|
3175 | |
---|
3176 | // When not present, the value of vps_num_rep_formats_minus1 is inferred to be equal to MaxLayersMinus1. |
---|
3177 | vps->setVpsNumRepFormats( vps->getMaxLayers() ); |
---|
3178 | |
---|
3179 | // When not present, the value of rep_format_idx_present_flag is inferred to be equal to 0 |
---|
3180 | vps->setRepFormatIdxPresentFlag( false ); |
---|
3181 | |
---|
3182 | if( !vps->getRepFormatIdxPresentFlag() ) |
---|
3183 | { |
---|
3184 | // When not present, the value of vps_rep_format_idx[ i ] is inferred to be equal to Min(i, vps_num_rep_formats_minus1). |
---|
3185 | for(i = 1; i < vps->getMaxLayers(); i++) |
---|
3186 | { |
---|
3187 | vps->setVpsRepFormatIdx( i, min( (Int)i, vps->getVpsNumRepFormats() - 1 ) ); |
---|
3188 | } |
---|
3189 | } |
---|
3190 | |
---|
3191 | vps->setVpsPocLsbAlignedFlag(false); |
---|
3192 | |
---|
3193 | // When not present, poc_lsb_not_present_flag[ i ] is inferred to be equal to 0. |
---|
3194 | for( i = 1; i< vps->getMaxLayers(); i++ ) |
---|
3195 | { |
---|
3196 | vps->setPocLsbNotPresentFlag(i, 0); |
---|
3197 | } |
---|
3198 | |
---|
3199 | // set default values for VPS VUI |
---|
3200 | defaultVPSVUI( vps ); |
---|
3201 | } |
---|
3202 | |
---|
3203 | Void TDecCavlc::defaultVPSVUI( TComVPS* vps ) |
---|
3204 | { |
---|
3205 | // When not present, the value of all_layers_idr_aligned_flag is inferred to be equal to 0. |
---|
3206 | vps->setCrossLayerIrapAlignFlag( false ); |
---|
3207 | |
---|
3208 | // When single_layer_for_non_irap_flag is not present, it is inferred to be equal to 0. |
---|
3209 | vps->setSingleLayerForNonIrapFlag( false ); |
---|
3210 | |
---|
3211 | // When higher_layer_irap_skip_flag is not present it is inferred to be equal to 0 |
---|
3212 | vps->setHigherLayerIrapSkipFlag( false ); |
---|
3213 | } |
---|
3214 | |
---|
3215 | Void TDecCavlc::parseRepFormat( RepFormat *repFormat, RepFormat *repFormatPrev ) |
---|
3216 | { |
---|
3217 | UInt uiCode; |
---|
3218 | READ_CODE( 16, uiCode, "pic_width_vps_in_luma_samples" ); repFormat->setPicWidthVpsInLumaSamples ( uiCode ); |
---|
3219 | READ_CODE( 16, uiCode, "pic_height_vps_in_luma_samples" ); repFormat->setPicHeightVpsInLumaSamples( uiCode ); |
---|
3220 | READ_FLAG( uiCode, "chroma_and_bit_depth_vps_present_flag" ); repFormat->setChromaAndBitDepthVpsPresentFlag( uiCode ? true : false ); |
---|
3221 | |
---|
3222 | if( !repFormatPrev ) |
---|
3223 | { |
---|
3224 | // The value of chroma_and_bit_depth_vps_present_flag of the first rep_format( ) syntax structure in the VPS shall be equal to 1 |
---|
3225 | assert( repFormat->getChromaAndBitDepthVpsPresentFlag() ); |
---|
3226 | } |
---|
3227 | |
---|
3228 | if( repFormat->getChromaAndBitDepthVpsPresentFlag() ) |
---|
3229 | { |
---|
3230 | READ_CODE( 2, uiCode, "chroma_format_vps_idc" ); |
---|
3231 | #if AUXILIARY_PICTURES |
---|
3232 | repFormat->setChromaFormatVpsIdc( ChromaFormat(uiCode) ); |
---|
3233 | #else |
---|
3234 | repFormat->setChromaFormatVpsIdc( uiCode ); |
---|
3235 | #endif |
---|
3236 | |
---|
3237 | if( repFormat->getChromaFormatVpsIdc() == 3 ) |
---|
3238 | { |
---|
3239 | READ_FLAG( uiCode, "separate_colour_plane_vps_flag" ); repFormat->setSeparateColourPlaneVpsFlag( uiCode ? true : false ); |
---|
3240 | } |
---|
3241 | |
---|
3242 | READ_CODE( 4, uiCode, "bit_depth_vps_luma_minus8" ); repFormat->setBitDepthVpsLuma ( uiCode + 8 ); |
---|
3243 | READ_CODE( 4, uiCode, "bit_depth_vps_chroma_minus8" ); repFormat->setBitDepthVpsChroma( uiCode + 8 ); |
---|
3244 | } |
---|
3245 | else if( repFormatPrev ) |
---|
3246 | { |
---|
3247 | // chroma_and_bit_depth_vps_present_flag equal to 0 specifies that the syntax elements, chroma_format_vps_idc, separate_colour_plane_vps_flag, bit_depth_vps_luma_minus8, and |
---|
3248 | // bit_depth_vps_chroma_minus8 are not present and inferred from the previous rep_format( ) syntax structure in the VPS. |
---|
3249 | |
---|
3250 | repFormat->setChromaFormatVpsIdc ( repFormatPrev->getChromaFormatVpsIdc() ); |
---|
3251 | repFormat->setSeparateColourPlaneVpsFlag( repFormatPrev->getSeparateColourPlaneVpsFlag() ); |
---|
3252 | repFormat->setBitDepthVpsLuma ( repFormatPrev->getBitDepthVpsLuma() ); |
---|
3253 | repFormat->setBitDepthVpsChroma ( repFormatPrev->getBitDepthVpsChroma() ); |
---|
3254 | } |
---|
3255 | |
---|
3256 | READ_FLAG( uiCode, "conformance_window_vps_flag" ); |
---|
3257 | if( uiCode != 0) |
---|
3258 | { |
---|
3259 | Window &conf = repFormat->getConformanceWindowVps(); |
---|
3260 | READ_UVLC( uiCode, "conf_win_vps_left_offset" ); conf.setWindowLeftOffset ( uiCode ); |
---|
3261 | READ_UVLC( uiCode, "conf_win_vps_right_offset" ); conf.setWindowRightOffset ( uiCode ); |
---|
3262 | READ_UVLC( uiCode, "conf_win_vps_top_offset" ); conf.setWindowTopOffset ( uiCode ); |
---|
3263 | READ_UVLC( uiCode, "conf_win_vps_bottom_offset" ); conf.setWindowBottomOffset( uiCode ); |
---|
3264 | } |
---|
3265 | } |
---|
3266 | |
---|
3267 | Void TDecCavlc::parseVpsDpbSizeTable( TComVPS *vps ) |
---|
3268 | { |
---|
3269 | UInt uiCode; |
---|
3270 | |
---|
3271 | vps->calculateMaxSLInLayerSets(); |
---|
3272 | vps->deriveNumberOfSubDpbs(); |
---|
3273 | |
---|
3274 | for(Int i = 1; i < vps->getNumOutputLayerSets(); i++) |
---|
3275 | { |
---|
3276 | Int layerSetIdxForOutputLayerSet = vps->getOutputLayerSetIdx( i ); |
---|
3277 | |
---|
3278 | READ_FLAG( uiCode, "sub_layer_flag_info_present_flag[i]"); vps->setSubLayerFlagInfoPresentFlag( i, uiCode ? true : false ); |
---|
3279 | |
---|
3280 | for(Int j = 0; j <= vps->getMaxSLayersInLayerSetMinus1( layerSetIdxForOutputLayerSet ); j++) |
---|
3281 | { |
---|
3282 | if( j > 0 && vps->getSubLayerFlagInfoPresentFlag(i) ) |
---|
3283 | { |
---|
3284 | READ_FLAG( uiCode, "sub_layer_dpb_info_present_flag[i]"); vps->setSubLayerDpbInfoPresentFlag( i, j, uiCode ? true : false); |
---|
3285 | } |
---|
3286 | else |
---|
3287 | { |
---|
3288 | if( j == 0 ) // Always signal for the first sub-layer |
---|
3289 | { |
---|
3290 | vps->setSubLayerDpbInfoPresentFlag( i, j, true ); |
---|
3291 | } |
---|
3292 | else // if (j != 0) && !vps->getSubLayerFlagInfoPresentFlag(i) |
---|
3293 | { |
---|
3294 | vps->setSubLayerDpbInfoPresentFlag( i, j, false ); |
---|
3295 | } |
---|
3296 | } |
---|
3297 | |
---|
3298 | if( vps->getSubLayerDpbInfoPresentFlag(i, j) ) // If sub-layer DPB information is present |
---|
3299 | { |
---|
3300 | for(Int k = 0; k < vps->getNumSubDpbs(layerSetIdxForOutputLayerSet); k++) |
---|
3301 | { |
---|
3302 | uiCode=0; |
---|
3303 | |
---|
3304 | if( vps->getNecessaryLayerFlag(i, k) && ( vps->getBaseLayerInternalFlag() || vps->getLayerSetLayerIdList(layerSetIdxForOutputLayerSet, k) ) ) |
---|
3305 | { |
---|
3306 | READ_UVLC( uiCode, "max_vps_dec_pic_buffering_minus1[i][k][j]" ); vps->setMaxVpsDecPicBufferingMinus1( i, k, j, uiCode ); |
---|
3307 | } |
---|
3308 | } |
---|
3309 | READ_UVLC( uiCode, "max_vps_num_reorder_pics[i][j]" ); vps->setMaxVpsNumReorderPics( i, j, uiCode); |
---|
3310 | |
---|
3311 | READ_UVLC( uiCode, "max_vps_latency_increase_plus1[i][j]" ); vps->setMaxVpsLatencyIncreasePlus1( i, j, uiCode); |
---|
3312 | } |
---|
3313 | } |
---|
3314 | for(Int j = vps->getMaxTLayers(); j < MAX_TLAYER; j++) |
---|
3315 | { |
---|
3316 | vps->setSubLayerDpbInfoPresentFlag( i, j, false ); |
---|
3317 | } |
---|
3318 | } |
---|
3319 | |
---|
3320 | // Infer values when not signalled |
---|
3321 | for(Int i = 1; i < vps->getNumOutputLayerSets(); i++) |
---|
3322 | { |
---|
3323 | Int layerSetIdxForOutputLayerSet = vps->getOutputLayerSetIdx( i ); |
---|
3324 | for(Int j = 0; j < MAX_TLAYER; j++) |
---|
3325 | { |
---|
3326 | if( !vps->getSubLayerDpbInfoPresentFlag(i, j) ) // If sub-layer DPB information is NOT present |
---|
3327 | { |
---|
3328 | for(Int k = 0; k < vps->getNumLayersInIdList( layerSetIdxForOutputLayerSet ); k++) |
---|
3329 | { |
---|
3330 | vps->setMaxVpsDecPicBufferingMinus1( i, k, j, vps->getMaxVpsDecPicBufferingMinus1( i, k, j - 1 ) ); |
---|
3331 | } |
---|
3332 | vps->setMaxVpsNumReorderPics( i, j, vps->getMaxVpsNumReorderPics( i, j - 1) ); |
---|
3333 | vps->setMaxVpsLatencyIncreasePlus1( i, j, vps->getMaxVpsLatencyIncreasePlus1( i, j - 1 ) ); |
---|
3334 | } |
---|
3335 | } |
---|
3336 | } |
---|
3337 | } |
---|
3338 | |
---|
3339 | Void TDecCavlc::parseVPSVUI(TComVPS *vps) |
---|
3340 | { |
---|
3341 | UInt i,j; |
---|
3342 | UInt uiCode; |
---|
3343 | READ_FLAG(uiCode, "cross_layer_pic_type_aligned_flag" ); |
---|
3344 | vps->setCrossLayerPictureTypeAlignFlag(uiCode); |
---|
3345 | |
---|
3346 | if( !uiCode ) |
---|
3347 | { |
---|
3348 | READ_FLAG(uiCode, "cross_layer_irap_aligned_flag" ); |
---|
3349 | vps->setCrossLayerIrapAlignFlag(uiCode); |
---|
3350 | } |
---|
3351 | else |
---|
3352 | { |
---|
3353 | vps->setCrossLayerIrapAlignFlag(true); |
---|
3354 | } |
---|
3355 | |
---|
3356 | if( vps->getCrossLayerIrapAlignFlag() ) |
---|
3357 | { |
---|
3358 | READ_FLAG( uiCode, "all_layers_idr_aligned_flag" ); |
---|
3359 | vps->setCrossLayerAlignedIdrOnlyFlag(uiCode); |
---|
3360 | } |
---|
3361 | |
---|
3362 | READ_FLAG( uiCode, "bit_rate_present_vps_flag" ); vps->setBitRatePresentVpsFlag( uiCode ? true : false ); |
---|
3363 | READ_FLAG( uiCode, "pic_rate_present_vps_flag" ); vps->setPicRatePresentVpsFlag( uiCode ? true : false ); |
---|
3364 | |
---|
3365 | if ( vps->getBitRatePresentVpsFlag() || vps->getPicRatePresentVpsFlag() ) |
---|
3366 | { |
---|
3367 | for( i = vps->getBaseLayerInternalFlag() ? 0 : 1; i < vps->getNumLayerSets(); i++ ) |
---|
3368 | { |
---|
3369 | for( j = 0; j <= vps->getMaxSLayersInLayerSetMinus1( i ); j++ ) |
---|
3370 | { |
---|
3371 | if( vps->getBitRatePresentVpsFlag() ) |
---|
3372 | { |
---|
3373 | READ_FLAG( uiCode, "bit_rate_present_flag[i][j]" ); vps->setBitRatePresentFlag( i, j, uiCode ? true : false ); |
---|
3374 | } |
---|
3375 | if( vps->getPicRatePresentVpsFlag( ) ) |
---|
3376 | { |
---|
3377 | READ_FLAG( uiCode, "pic_rate_present_flag[i][j]" ); vps->setPicRatePresentFlag( i, j, uiCode ? true : false ); |
---|
3378 | } |
---|
3379 | if( vps->getBitRatePresentFlag( i, j ) ) |
---|
3380 | { |
---|
3381 | READ_CODE( 16, uiCode, "avg_bit_rate" ); vps->setAvgBitRate( i, j, uiCode ); |
---|
3382 | READ_CODE( 16, uiCode, "max_bit_rate" ); vps->setMaxBitRate( i, j, uiCode ); |
---|
3383 | } |
---|
3384 | else |
---|
3385 | { |
---|
3386 | vps->setAvgBitRate( i, j, 0 ); |
---|
3387 | vps->setMaxBitRate( i, j, 0 ); |
---|
3388 | } |
---|
3389 | if( vps->getPicRatePresentFlag( i, j ) ) |
---|
3390 | { |
---|
3391 | READ_CODE( 2, uiCode, "constant_pic_rate_idc" ); vps->setConstPicRateIdc( i, j, uiCode ); |
---|
3392 | READ_CODE( 16, uiCode, "avg_pic_rate" ); vps->setAvgPicRate( i, j, uiCode ); |
---|
3393 | } |
---|
3394 | else |
---|
3395 | { |
---|
3396 | vps->setConstPicRateIdc( i, j, 0 ); |
---|
3397 | vps->setAvgPicRate( i, j, 0 ); |
---|
3398 | } |
---|
3399 | } |
---|
3400 | } |
---|
3401 | } |
---|
3402 | |
---|
3403 | READ_FLAG( uiCode, "video_signal_info_idx_present_flag" ); vps->setVideoSigPresentVpsFlag( uiCode == 1 ); |
---|
3404 | if (vps->getVideoSigPresentVpsFlag()) |
---|
3405 | { |
---|
3406 | READ_CODE(4, uiCode, "vps_num_video_signal_info_minus1" ); vps->setNumVideoSignalInfo(uiCode + 1); |
---|
3407 | } |
---|
3408 | else |
---|
3409 | { |
---|
3410 | vps->setNumVideoSignalInfo(vps->getMaxLayers() - vps->getBaseLayerInternalFlag() ? 0 : 1); |
---|
3411 | } |
---|
3412 | |
---|
3413 | for(i = 0; i < vps->getNumVideoSignalInfo(); i++) |
---|
3414 | { |
---|
3415 | READ_CODE(3, uiCode, "video_vps_format" ); vps->setVideoVPSFormat(i,uiCode); |
---|
3416 | READ_FLAG(uiCode, "video_full_range_vps_flag" ); vps->setVideoFullRangeVpsFlag(i,uiCode); |
---|
3417 | READ_CODE(8, uiCode, "color_primaries_vps" ); vps->setColorPrimaries(i,uiCode); |
---|
3418 | READ_CODE(8, uiCode, "transfer_characteristics_vps" ); vps->setTransCharacter(i,uiCode); |
---|
3419 | READ_CODE(8, uiCode, "matrix_coeffs_vps" );vps->setMaxtrixCoeff(i,uiCode); |
---|
3420 | } |
---|
3421 | |
---|
3422 | if( vps->getVideoSigPresentVpsFlag() && vps->getNumVideoSignalInfo() > 1 ) |
---|
3423 | { |
---|
3424 | for(i = vps->getBaseLayerInternalFlag() ? 0 : 1; i < vps->getMaxLayers(); i++) |
---|
3425 | { |
---|
3426 | READ_CODE(4, uiCode, "vps_video_signal_info_idx" ); vps->setVideoSignalInfoIdx(i, uiCode); |
---|
3427 | } |
---|
3428 | } |
---|
3429 | else if ( !vps->getVideoSigPresentVpsFlag() ) |
---|
3430 | { |
---|
3431 | for(i = vps->getBaseLayerInternalFlag() ? 0 : 1; i < vps->getMaxLayers(); i++) |
---|
3432 | { |
---|
3433 | vps->setVideoSignalInfoIdx( i, i ); |
---|
3434 | } |
---|
3435 | } |
---|
3436 | else // ( vps->getNumVideoSignalInfo() = 0 ) |
---|
3437 | { |
---|
3438 | for(i = vps->getBaseLayerInternalFlag() ? 0 : 1; i < vps->getMaxLayers(); i++) |
---|
3439 | { |
---|
3440 | vps->setVideoSignalInfoIdx( i, 0 ); |
---|
3441 | } |
---|
3442 | } |
---|
3443 | |
---|
3444 | READ_FLAG( uiCode, "tiles_not_in_use_flag" ); vps->setTilesNotInUseFlag(uiCode == 1); |
---|
3445 | |
---|
3446 | if( !uiCode ) |
---|
3447 | { |
---|
3448 | for( i = vps->getBaseLayerInternalFlag() ? 0 : 1; i < vps->getMaxLayers(); i++ ) |
---|
3449 | { |
---|
3450 | READ_FLAG( uiCode, "tiles_in_use_flag[ i ]" ); vps->setTilesInUseFlag(i, (uiCode == 1)); |
---|
3451 | |
---|
3452 | if( uiCode ) |
---|
3453 | { |
---|
3454 | READ_FLAG( uiCode, "loop_filter_not_across_tiles_flag[ i ]" ); vps->setLoopFilterNotAcrossTilesFlag(i, (uiCode == 1)); |
---|
3455 | } |
---|
3456 | else |
---|
3457 | { |
---|
3458 | vps->setLoopFilterNotAcrossTilesFlag(i, false); |
---|
3459 | } |
---|
3460 | } |
---|
3461 | |
---|
3462 | for( i = vps->getBaseLayerInternalFlag() ? 1 : 2; i < vps->getMaxLayers(); i++ ) |
---|
3463 | { |
---|
3464 | for( j = 0; j < vps->getNumDirectRefLayers(vps->getLayerIdInNuh(i)); j++ ) |
---|
3465 | { |
---|
3466 | UInt layerIdx = vps->getLayerIdxInVps(vps->getRefLayerId(vps->getLayerIdInNuh(i), j)); |
---|
3467 | |
---|
3468 | if( vps->getTilesInUseFlag(i) && vps->getTilesInUseFlag(layerIdx) ) |
---|
3469 | { |
---|
3470 | READ_FLAG( uiCode, "tile_boundaries_aligned_flag[i][j]" ); vps->setTileBoundariesAlignedFlag(i,j,(uiCode == 1)); |
---|
3471 | } |
---|
3472 | } |
---|
3473 | } |
---|
3474 | } |
---|
3475 | |
---|
3476 | READ_FLAG( uiCode, "wpp_not_in_use_flag" ); vps->setWppNotInUseFlag(uiCode == 1); |
---|
3477 | if( !uiCode ) |
---|
3478 | { |
---|
3479 | for( i = vps->getBaseLayerInternalFlag() ? 0 : 1; i < vps->getMaxLayers(); i++ ) |
---|
3480 | { |
---|
3481 | READ_FLAG( uiCode, "wpp_in_use_flag[ i ]" ); vps->setWppInUseFlag(i, (uiCode == 1)); |
---|
3482 | } |
---|
3483 | } |
---|
3484 | |
---|
3485 | READ_FLAG(uiCode, "single_layer_for_non_irap_flag" ); vps->setSingleLayerForNonIrapFlag(uiCode == 1 ? true : false); |
---|
3486 | |
---|
3487 | READ_FLAG(uiCode, "higher_layer_irap_skip_flag" ); vps->setHigherLayerIrapSkipFlag(uiCode == 1 ? true : false); |
---|
3488 | |
---|
3489 | // When single_layer_for_non_irap_flag is equal to 0, higher_layer_irap_skip_flag shall be equal to 0 |
---|
3490 | if( !vps->getSingleLayerForNonIrapFlag() ) |
---|
3491 | { |
---|
3492 | assert( !vps->getHigherLayerIrapSkipFlag() ); |
---|
3493 | } |
---|
3494 | |
---|
3495 | READ_FLAG( uiCode, "ilp_restricted_ref_layers_flag" ); vps->setIlpRestrictedRefLayersFlag( uiCode == 1 ); |
---|
3496 | if( vps->getIlpRestrictedRefLayersFlag()) |
---|
3497 | { |
---|
3498 | for(i = 1; i < vps->getMaxLayers(); i++) |
---|
3499 | { |
---|
3500 | for(j = 0; j < vps->getNumDirectRefLayers(vps->getLayerIdInNuh(i)); j++) |
---|
3501 | { |
---|
3502 | if( vps->getBaseLayerInternalFlag() || vps->getRefLayerId(vps->getLayerIdInNuh(i), j) ) |
---|
3503 | { |
---|
3504 | READ_UVLC( uiCode, "min_spatial_segment_offset_plus1[i][j]" ); vps->setMinSpatialSegmentOffsetPlus1( i, j, uiCode ); |
---|
3505 | if( vps->getMinSpatialSegmentOffsetPlus1(i,j ) > 0 ) |
---|
3506 | { |
---|
3507 | READ_FLAG( uiCode, "ctu_based_offset_enabled_flag[i][j]"); vps->setCtuBasedOffsetEnabledFlag(i, j, uiCode == 1 ); |
---|
3508 | if(vps->getCtuBasedOffsetEnabledFlag(i,j)) |
---|
3509 | { |
---|
3510 | READ_UVLC( uiCode, "min_horizontal_ctu_offset_plus1[i][j]"); vps->setMinHorizontalCtuOffsetPlus1( i,j, uiCode ); |
---|
3511 | } |
---|
3512 | } |
---|
3513 | } |
---|
3514 | } |
---|
3515 | } |
---|
3516 | } |
---|
3517 | |
---|
3518 | #if O0164_MULTI_LAYER_HRD |
---|
3519 | READ_FLAG(uiCode, "vps_vui_bsp_hrd_present_flag" ); vps->setVpsVuiBspHrdPresentFlag(uiCode); |
---|
3520 | |
---|
3521 | if( vps->getVpsVuiBspHrdPresentFlag() ) |
---|
3522 | { |
---|
3523 | parseVpsVuiBspHrdParams(vps); |
---|
3524 | } |
---|
3525 | #endif |
---|
3526 | |
---|
3527 | for( i = 1; i < vps->getMaxLayers(); i++ ) |
---|
3528 | { |
---|
3529 | if (vps->getNumRefLayers(vps->getLayerIdInNuh(i)) == 0) |
---|
3530 | { |
---|
3531 | READ_FLAG( uiCode, "base_layer_parameter_set_compatibility_flag" ); |
---|
3532 | vps->setBaseLayerPSCompatibilityFlag( i, uiCode ); |
---|
3533 | } |
---|
3534 | else |
---|
3535 | { |
---|
3536 | vps->setBaseLayerPSCompatibilityFlag( i, 0 ); |
---|
3537 | } |
---|
3538 | } |
---|
3539 | } |
---|
3540 | |
---|
3541 | Void TDecCavlc::parseSPSExtension( TComSPS* pcSPS ) |
---|
3542 | { |
---|
3543 | UInt uiCode; |
---|
3544 | // more syntax elements to be parsed here |
---|
3545 | |
---|
3546 | READ_FLAG( uiCode, "inter_view_mv_vert_constraint_flag" ); |
---|
3547 | // Vertical MV component restriction is not used in SHVC CTC |
---|
3548 | assert( uiCode == 0 ); |
---|
3549 | } |
---|
3550 | |
---|
3551 | #if CGS_3D_ASYMLUT |
---|
3552 | Void TDecCavlc::xParse3DAsymLUT( TCom3DAsymLUT * pc3DAsymLUT ) |
---|
3553 | { |
---|
3554 | UInt uiNumRefLayersM1; |
---|
3555 | READ_UVLC( uiNumRefLayersM1 , "num_cm_ref_layers_minus1" ); |
---|
3556 | assert( uiNumRefLayersM1 <= 61 ); |
---|
3557 | for( UInt i = 0 ; i <= uiNumRefLayersM1 ; i++ ) |
---|
3558 | { |
---|
3559 | UInt uiRefLayerId; |
---|
3560 | READ_CODE( 6 , uiRefLayerId , "cm_ref_layer_id" ); |
---|
3561 | pc3DAsymLUT->addRefLayerId( uiRefLayerId ); |
---|
3562 | } |
---|
3563 | |
---|
3564 | UInt uiCurOctantDepth, uiCurPartNumLog2, uiInputBitDepthM8, uiOutputBitDepthM8, uiResQaunBit, uiDeltaBits;; |
---|
3565 | |
---|
3566 | READ_CODE( 2 , uiCurOctantDepth , "cm_octant_depth" ); |
---|
3567 | READ_CODE( 2 , uiCurPartNumLog2 , "cm_y_part_num_log2" ); |
---|
3568 | |
---|
3569 | UInt uiChromaInputBitDepthM8 , uiChromaOutputBitDepthM8; |
---|
3570 | |
---|
3571 | READ_UVLC( uiInputBitDepthM8 , "cm_input_luma_bit_depth_minus8" ); |
---|
3572 | READ_UVLC( uiChromaInputBitDepthM8 , "cm_input_chroma_bit_depth_minus8" ); |
---|
3573 | READ_UVLC( uiOutputBitDepthM8 , "cm_output_luma_bit_depth_minus8" ); |
---|
3574 | READ_UVLC( uiChromaOutputBitDepthM8 , "cm_output_chroma_bit_depth_minus8" ); |
---|
3575 | READ_CODE( 2 , uiResQaunBit , "cm_res_quant_bit" ); |
---|
3576 | |
---|
3577 | READ_CODE( 2 , uiDeltaBits , "cm_flc_bits" ); |
---|
3578 | pc3DAsymLUT->setDeltaBits(uiDeltaBits + 1); |
---|
3579 | |
---|
3580 | Int nAdaptCThresholdU = 1 << ( uiChromaInputBitDepthM8 + 8 - 1 ); |
---|
3581 | Int nAdaptCThresholdV = 1 << ( uiChromaInputBitDepthM8 + 8 - 1 ); |
---|
3582 | |
---|
3583 | if( uiCurOctantDepth == 1 ) |
---|
3584 | { |
---|
3585 | Int delta = 0; |
---|
3586 | READ_SVLC( delta , "cm_adapt_threshold_u_delta" ); |
---|
3587 | nAdaptCThresholdU += delta; |
---|
3588 | READ_SVLC( delta , "cm_adapt_threshold_v_delta" ); |
---|
3589 | nAdaptCThresholdV += delta; |
---|
3590 | } |
---|
3591 | |
---|
3592 | pc3DAsymLUT->destroy(); |
---|
3593 | pc3DAsymLUT->create( uiCurOctantDepth, uiInputBitDepthM8 + 8, uiChromaInputBitDepthM8 + 8, uiOutputBitDepthM8 + 8, uiChromaOutputBitDepthM8 + 8, uiCurPartNumLog2, nAdaptCThresholdU, nAdaptCThresholdV ); |
---|
3594 | pc3DAsymLUT->setResQuantBit( uiResQaunBit ); |
---|
3595 | |
---|
3596 | #if R0164_CGS_LUT_BUGFIX_CHECK |
---|
3597 | pc3DAsymLUT->xInitCuboids(); |
---|
3598 | #endif |
---|
3599 | xParse3DAsymLUTOctant( pc3DAsymLUT , 0 , 0 , 0 , 0 , 1 << pc3DAsymLUT->getCurOctantDepth() ); |
---|
3600 | #if R0164_CGS_LUT_BUGFIX_CHECK |
---|
3601 | printf("============= Before 'xCuboidsFilledCheck()': ================\n"); |
---|
3602 | pc3DAsymLUT->display(); |
---|
3603 | pc3DAsymLUT->xCuboidsFilledCheck( false ); |
---|
3604 | printf("============= After 'xCuboidsFilledCheck()': =================\n"); |
---|
3605 | pc3DAsymLUT->display(); |
---|
3606 | #endif |
---|
3607 | } |
---|
3608 | |
---|
3609 | Void TDecCavlc::xParse3DAsymLUTOctant( TCom3DAsymLUT * pc3DAsymLUT , Int nDepth , Int yIdx , Int uIdx , Int vIdx , Int nLength ) |
---|
3610 | { |
---|
3611 | UInt uiOctantSplit = nDepth < pc3DAsymLUT->getCurOctantDepth(); |
---|
3612 | if( nDepth < pc3DAsymLUT->getCurOctantDepth() ) |
---|
3613 | READ_FLAG( uiOctantSplit , "split_octant_flag" ); |
---|
3614 | Int nYPartNum = 1 << pc3DAsymLUT->getCurYPartNumLog2(); |
---|
3615 | if( uiOctantSplit ) |
---|
3616 | { |
---|
3617 | Int nHalfLength = nLength >> 1; |
---|
3618 | for( Int l = 0 ; l < 2 ; l++ ) |
---|
3619 | { |
---|
3620 | for( Int m = 0 ; m < 2 ; m++ ) |
---|
3621 | { |
---|
3622 | for( Int n = 0 ; n < 2 ; n++ ) |
---|
3623 | { |
---|
3624 | xParse3DAsymLUTOctant( pc3DAsymLUT , nDepth + 1 , yIdx + l * nHalfLength * nYPartNum , uIdx + m * nHalfLength , vIdx + n * nHalfLength , nHalfLength ); |
---|
3625 | } |
---|
3626 | } |
---|
3627 | } |
---|
3628 | } |
---|
3629 | else |
---|
3630 | { |
---|
3631 | Int nFLCbits = pc3DAsymLUT->getMappingShift()-pc3DAsymLUT->getResQuantBit()-pc3DAsymLUT->getDeltaBits() ; |
---|
3632 | nFLCbits = nFLCbits >= 0 ? nFLCbits:0; |
---|
3633 | |
---|
3634 | for( Int l = 0 ; l < nYPartNum ; l++ ) |
---|
3635 | { |
---|
3636 | Int shift = pc3DAsymLUT->getCurOctantDepth() - nDepth; |
---|
3637 | |
---|
3638 | for( Int nVertexIdx = 0 ; nVertexIdx < 4 ; nVertexIdx++ ) |
---|
3639 | { |
---|
3640 | UInt uiCodeVertex = 0; |
---|
3641 | Int deltaY = 0 , deltaU = 0 , deltaV = 0; |
---|
3642 | READ_FLAG( uiCodeVertex , "coded_vertex_flag" ); |
---|
3643 | if( uiCodeVertex ) |
---|
3644 | { |
---|
3645 | xReadParam( deltaY, nFLCbits ); |
---|
3646 | xReadParam( deltaU, nFLCbits ); |
---|
3647 | xReadParam( deltaV, nFLCbits ); |
---|
3648 | } |
---|
3649 | |
---|
3650 | pc3DAsymLUT->setCuboidVertexResTree( yIdx + (l<<shift) , uIdx , vIdx , nVertexIdx , deltaY , deltaU , deltaV ); |
---|
3651 | |
---|
3652 | for( Int m = 1; m < (1<<shift); m++ ) |
---|
3653 | { |
---|
3654 | pc3DAsymLUT->setCuboidVertexResTree( yIdx + (l<<shift) + m , uIdx , vIdx , nVertexIdx , 0 , 0 , 0 ); |
---|
3655 | #if R0164_CGS_LUT_BUGFIX_CHECK |
---|
3656 | pc3DAsymLUT->xSetFilled( yIdx + (l<<shift) + m , uIdx , vIdx ); |
---|
3657 | #endif |
---|
3658 | } |
---|
3659 | } |
---|
3660 | #if R0164_CGS_LUT_BUGFIX_CHECK |
---|
3661 | pc3DAsymLUT->xSetExplicit( yIdx + (l<<shift) , uIdx , vIdx ); |
---|
3662 | #endif |
---|
3663 | } |
---|
3664 | |
---|
3665 | for( Int u=0; u<nLength; u++ ) |
---|
3666 | { |
---|
3667 | for( Int v=0; v<nLength; v++ ) |
---|
3668 | { |
---|
3669 | if( u!=0 || v!=0 ) |
---|
3670 | { |
---|
3671 | for( Int y=0 ; y<nLength*nYPartNum ; y++ ) |
---|
3672 | { |
---|
3673 | for( Int nVertexIdx = 0 ; nVertexIdx < 4 ; nVertexIdx++ ) |
---|
3674 | { |
---|
3675 | pc3DAsymLUT->setCuboidVertexResTree( yIdx + y , uIdx + u , vIdx + v , nVertexIdx , 0 , 0 , 0 ); |
---|
3676 | #if R0164_CGS_LUT_BUGFIX_CHECK |
---|
3677 | pc3DAsymLUT->xSetFilled( yIdx + y , uIdx + u , vIdx + v ); |
---|
3678 | #endif |
---|
3679 | } |
---|
3680 | } |
---|
3681 | } |
---|
3682 | } |
---|
3683 | } |
---|
3684 | } |
---|
3685 | } |
---|
3686 | |
---|
3687 | Void TDecCavlc::xReadParam( Int& param, Int rParam ) |
---|
3688 | { |
---|
3689 | UInt prefix; |
---|
3690 | UInt codeWord ; |
---|
3691 | UInt rSymbol; |
---|
3692 | UInt sign; |
---|
3693 | |
---|
3694 | READ_UVLC( prefix, "quotient") ; |
---|
3695 | READ_CODE (rParam, codeWord, "remainder"); |
---|
3696 | rSymbol = (prefix<<rParam) + codeWord; |
---|
3697 | |
---|
3698 | if(rSymbol) |
---|
3699 | { |
---|
3700 | READ_FLAG(sign, "sign"); |
---|
3701 | param = sign ? -(Int)(rSymbol) : (Int)(rSymbol); |
---|
3702 | } |
---|
3703 | else param = 0; |
---|
3704 | } |
---|
3705 | #endif |
---|
3706 | |
---|
3707 | Void TDecCavlc::parseVpsVuiBspHrdParams( TComVPS *vps ) |
---|
3708 | { |
---|
3709 | UInt uiCode; |
---|
3710 | assert (vps->getTimingInfo()->getTimingInfoPresentFlag() == 1); |
---|
3711 | READ_UVLC( uiCode, "vps_num_add_hrd_params" ); vps->setVpsNumAddHrdParams(uiCode); |
---|
3712 | vps->createBspHrdParamBuffer(vps->getVpsNumAddHrdParams()); // Also allocates m_cprmsAddPresentFlag and m_numSubLayerHrdMinus |
---|
3713 | |
---|
3714 | for( Int i = vps->getNumHrdParameters(), j = 0; i < vps->getNumHrdParameters() + vps->getVpsNumAddHrdParams(); i++, j++ ) // j = i - vps->getNumHrdParameters() |
---|
3715 | { |
---|
3716 | if( i > 0 ) |
---|
3717 | { |
---|
3718 | READ_FLAG( uiCode, "cprms_add_present_flag[i]" ); vps->setCprmsAddPresentFlag(j, uiCode ? true : false); |
---|
3719 | } |
---|
3720 | else |
---|
3721 | { |
---|
3722 | // i == 0 |
---|
3723 | if( vps->getNumHrdParameters() == 0 ) |
---|
3724 | { |
---|
3725 | vps->setCprmsAddPresentFlag(0, true); |
---|
3726 | } |
---|
3727 | } |
---|
3728 | |
---|
3729 | READ_UVLC( uiCode, "num_sub_layer_hrd_minus1[i]" ); vps->setNumSubLayerHrdMinus1(j, uiCode ); |
---|
3730 | assert( uiCode <= vps->getMaxTLayers() - 1 ); |
---|
3731 | |
---|
3732 | parseHrdParameters( vps->getBspHrd(j), vps->getCprmsAddPresentFlag(j), vps->getNumSubLayerHrdMinus1(j) ); |
---|
3733 | |
---|
3734 | if( i > 0 && !vps->getCprmsAddPresentFlag(i) ) |
---|
3735 | { |
---|
3736 | // Copy common information parameters |
---|
3737 | if( i == vps->getNumHrdParameters() ) |
---|
3738 | { |
---|
3739 | vps->getBspHrd(j)->copyCommonInformation( vps->getHrdParameters( vps->getNumHrdParameters() - 1 ) ); |
---|
3740 | } |
---|
3741 | else |
---|
3742 | { |
---|
3743 | vps->getBspHrd(j)->copyCommonInformation( vps->getBspHrd( j - 1 ) ); |
---|
3744 | } |
---|
3745 | } |
---|
3746 | } |
---|
3747 | |
---|
3748 | if( vps->getNumHrdParameters() + vps->getVpsNumAddHrdParams() > 0 ) |
---|
3749 | { |
---|
3750 | for (Int h = 1; h < vps->getNumOutputLayerSets(); h++) |
---|
3751 | { |
---|
3752 | Int lsIdx = vps->getOutputLayerSetIdx(h); |
---|
3753 | READ_UVLC(uiCode, "num_signalled_partitioning_schemes[h]"); vps->setNumSignalledPartitioningSchemes(h, uiCode); |
---|
3754 | |
---|
3755 | for (Int j = 1; j < vps->getNumSignalledPartitioningSchemes(h) + 1; j++) |
---|
3756 | { |
---|
3757 | READ_UVLC(uiCode, "num_partitions_in_scheme_minus1[h][j]"); vps->setNumPartitionsInSchemeMinus1(h, j, uiCode); |
---|
3758 | |
---|
3759 | for( Int k = 0; k <= vps->getNumPartitionsInSchemeMinus1(h, j); k++ ) |
---|
3760 | { |
---|
3761 | for( Int r = 0; r < vps->getNumLayersInIdList(lsIdx); r++ ) |
---|
3762 | { |
---|
3763 | READ_FLAG(uiCode, "layer_included_in_partition_flag[h][j][k][r]"); vps->setLayerIncludedInPartitionFlag(h, j, k, r, uiCode ? true : false); |
---|
3764 | } |
---|
3765 | } |
---|
3766 | } |
---|
3767 | |
---|
3768 | for( Int i = 0; i < vps->getNumSignalledPartitioningSchemes(h) + 1; i++ ) |
---|
3769 | { |
---|
3770 | for( Int t = 0; t <= vps->getMaxSLayersInLayerSetMinus1(lsIdx); t++ ) |
---|
3771 | { |
---|
3772 | READ_UVLC(uiCode, "num_bsp_schedules_minus1[h][i][t]"); vps->setNumBspSchedulesMinus1(h, i, t, uiCode); |
---|
3773 | |
---|
3774 | for( Int j = 0; j <= vps->getNumBspSchedulesMinus1(h, i, t); j++) |
---|
3775 | { |
---|
3776 | for( Int k = 0; k <= vps->getNumPartitionsInSchemeMinus1(h, i); k++ ) |
---|
3777 | { |
---|
3778 | if( vps->getNumHrdParameters() + vps->getVpsNumAddHrdParams() > 1 ) |
---|
3779 | { |
---|
3780 | Int numBits = 1; |
---|
3781 | |
---|
3782 | while( (1 << numBits) < (vps->getNumHrdParameters() + vps->getVpsNumAddHrdParams()) ) |
---|
3783 | { |
---|
3784 | numBits++; |
---|
3785 | } |
---|
3786 | |
---|
3787 | READ_CODE(numBits, uiCode, "bsp_hrd_idx[h][i][t][j][k]"); vps->setBspHrdIdx(h, i, t, j, k, uiCode); |
---|
3788 | } |
---|
3789 | |
---|
3790 | READ_UVLC(uiCode, "bsp_sched_idx[h][i][t][j][k]"); vps->setBspSchedIdx(h, i, t, j, k, uiCode); |
---|
3791 | } |
---|
3792 | } |
---|
3793 | } |
---|
3794 | } |
---|
3795 | |
---|
3796 | // To be done: Check each layer included in not more than one BSP in every partitioning scheme, |
---|
3797 | // and other related checks associated with layers in bitstream partitions. |
---|
3798 | |
---|
3799 | } |
---|
3800 | } |
---|
3801 | } |
---|
3802 | #endif //SVC_EXTENSION |
---|
3803 | //! \} |
---|
3804 | |
---|