1 | /* The copyright in this software is being made available under the BSD |
---|
2 | * License, included below. This software may be subject to other third party |
---|
3 | * and contributor rights, including patent rights, and no such rights are |
---|
4 | * granted under this license. |
---|
5 | * |
---|
6 | * Copyright (c) 2010-2014, ITU/ISO/IEC |
---|
7 | * All rights reserved. |
---|
8 | * |
---|
9 | * Redistribution and use in source and binary forms, with or without |
---|
10 | * modification, are permitted provided that the following conditions are met: |
---|
11 | * |
---|
12 | * * Redistributions of source code must retain the above copyright notice, |
---|
13 | * this list of conditions and the following disclaimer. |
---|
14 | * * Redistributions in binary form must reproduce the above copyright notice, |
---|
15 | * this list of conditions and the following disclaimer in the documentation |
---|
16 | * and/or other materials provided with the distribution. |
---|
17 | * * Neither the name of the ITU/ISO/IEC nor the names of its contributors may |
---|
18 | * be used to endorse or promote products derived from this software without |
---|
19 | * specific prior written permission. |
---|
20 | * |
---|
21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
---|
22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
---|
23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
---|
24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS |
---|
25 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
---|
26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
---|
27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
---|
28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
---|
29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
---|
30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
---|
31 | * THE POSSIBILITY OF SUCH DAMAGE. |
---|
32 | */ |
---|
33 | |
---|
34 | /** \file TDecCAVLC.cpp |
---|
35 | \brief CAVLC decoder class |
---|
36 | */ |
---|
37 | |
---|
38 | #include "TDecCAVLC.h" |
---|
39 | #include "SEIread.h" |
---|
40 | #include "TDecSlice.h" |
---|
41 | |
---|
42 | //! \ingroup TLibDecoder |
---|
43 | //! \{ |
---|
44 | |
---|
45 | #if ENC_DEC_TRACE |
---|
46 | |
---|
47 | Void xTraceSPSHeader (TComSPS *pSPS) |
---|
48 | { |
---|
49 | #if H_MV_ENC_DEC_TRAC |
---|
50 | if ( g_disableHLSTrace ) |
---|
51 | { |
---|
52 | return; |
---|
53 | } |
---|
54 | // To avoid mismatches |
---|
55 | fprintf( g_hTrace, "=========== Sequence Parameter Set ===========\n" ); |
---|
56 | #else |
---|
57 | fprintf( g_hTrace, "=========== Sequence Parameter Set ID: %d ===========\n", pSPS->getSPSId() ); |
---|
58 | #endif |
---|
59 | } |
---|
60 | |
---|
61 | Void xTracePPSHeader (TComPPS *pPPS) |
---|
62 | { |
---|
63 | #if H_MV_ENC_DEC_TRAC |
---|
64 | if ( g_disableHLSTrace ) |
---|
65 | { |
---|
66 | return; |
---|
67 | } |
---|
68 | fprintf( g_hTrace, "=========== Picture Parameter Set ===========\n" ); |
---|
69 | #else |
---|
70 | fprintf( g_hTrace, "=========== Picture Parameter Set ID: %d ===========\n", pPPS->getPPSId() ); |
---|
71 | #endif |
---|
72 | } |
---|
73 | |
---|
74 | Void xTraceSliceHeader (TComSlice *pSlice) |
---|
75 | { |
---|
76 | #if H_MV_ENC_DEC_TRAC |
---|
77 | if ( g_disableHLSTrace ) |
---|
78 | { |
---|
79 | return; |
---|
80 | } |
---|
81 | #endif |
---|
82 | fprintf( g_hTrace, "=========== Slice ===========\n"); |
---|
83 | } |
---|
84 | |
---|
85 | #endif |
---|
86 | |
---|
87 | // ==================================================================================================================== |
---|
88 | // Constructor / destructor / create / destroy |
---|
89 | // ==================================================================================================================== |
---|
90 | |
---|
91 | TDecCavlc::TDecCavlc() |
---|
92 | { |
---|
93 | #if H_3D |
---|
94 | m_aaiTempScale = new Int* [ MAX_NUM_LAYERS ]; |
---|
95 | m_aaiTempOffset = new Int* [ MAX_NUM_LAYERS ]; |
---|
96 | for( UInt uiVId = 0; uiVId < MAX_NUM_LAYERS; uiVId++ ) |
---|
97 | { |
---|
98 | m_aaiTempScale [ uiVId ] = new Int [ MAX_NUM_LAYERS ]; |
---|
99 | m_aaiTempOffset [ uiVId ] = new Int [ MAX_NUM_LAYERS ]; |
---|
100 | } |
---|
101 | #endif |
---|
102 | } |
---|
103 | |
---|
104 | TDecCavlc::~TDecCavlc() |
---|
105 | { |
---|
106 | #if H_3D |
---|
107 | for( UInt uiVId = 0; uiVId < MAX_NUM_LAYERS; uiVId++ ) |
---|
108 | { |
---|
109 | delete [] m_aaiTempScale [ uiVId ]; |
---|
110 | delete [] m_aaiTempOffset [ uiVId ]; |
---|
111 | } |
---|
112 | delete [] m_aaiTempScale; |
---|
113 | delete [] m_aaiTempOffset; |
---|
114 | #endif |
---|
115 | } |
---|
116 | |
---|
117 | // ==================================================================================================================== |
---|
118 | // Public member functions |
---|
119 | // ==================================================================================================================== |
---|
120 | |
---|
121 | void TDecCavlc::parseShortTermRefPicSet( TComSPS* sps, TComReferencePictureSet* rps, Int idx ) |
---|
122 | { |
---|
123 | UInt code; |
---|
124 | UInt interRPSPred; |
---|
125 | if (idx > 0) |
---|
126 | { |
---|
127 | READ_FLAG(interRPSPred, "inter_ref_pic_set_prediction_flag"); rps->setInterRPSPrediction(interRPSPred); |
---|
128 | } |
---|
129 | else |
---|
130 | { |
---|
131 | interRPSPred = false; |
---|
132 | rps->setInterRPSPrediction(false); |
---|
133 | } |
---|
134 | |
---|
135 | if (interRPSPred) |
---|
136 | { |
---|
137 | UInt bit; |
---|
138 | if(idx == sps->getRPSList()->getNumberOfReferencePictureSets()) |
---|
139 | { |
---|
140 | READ_UVLC(code, "delta_idx_minus1" ); // delta index of the Reference Picture Set used for prediction minus 1 |
---|
141 | } |
---|
142 | else |
---|
143 | { |
---|
144 | code = 0; |
---|
145 | } |
---|
146 | 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 |
---|
147 | Int rIdx = idx - 1 - code; |
---|
148 | 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 |
---|
149 | TComReferencePictureSet* rpsRef = sps->getRPSList()->getReferencePictureSet(rIdx); |
---|
150 | Int k = 0, k0 = 0, k1 = 0; |
---|
151 | READ_CODE(1, bit, "delta_rps_sign"); // delta_RPS_sign |
---|
152 | READ_UVLC(code, "abs_delta_rps_minus1"); // absolute delta RPS minus 1 |
---|
153 | Int deltaRPS = (1 - 2 * bit) * (code + 1); // delta_RPS |
---|
154 | for(Int j=0 ; j <= rpsRef->getNumberOfPictures(); j++) |
---|
155 | { |
---|
156 | READ_CODE(1, bit, "used_by_curr_pic_flag" ); //first bit is "1" if Idc is 1 |
---|
157 | Int refIdc = bit; |
---|
158 | if (refIdc == 0) |
---|
159 | { |
---|
160 | READ_CODE(1, bit, "use_delta_flag" ); //second bit is "1" if Idc is 2, "0" otherwise. |
---|
161 | refIdc = bit<<1; //second bit is "1" if refIdc is 2, "0" if refIdc = 0. |
---|
162 | } |
---|
163 | if (refIdc == 1 || refIdc == 2) |
---|
164 | { |
---|
165 | Int deltaPOC = deltaRPS + ((j < rpsRef->getNumberOfPictures())? rpsRef->getDeltaPOC(j) : 0); |
---|
166 | rps->setDeltaPOC(k, deltaPOC); |
---|
167 | rps->setUsed(k, (refIdc == 1)); |
---|
168 | |
---|
169 | if (deltaPOC < 0) |
---|
170 | { |
---|
171 | k0++; |
---|
172 | } |
---|
173 | else |
---|
174 | { |
---|
175 | k1++; |
---|
176 | } |
---|
177 | k++; |
---|
178 | } |
---|
179 | rps->setRefIdc(j,refIdc); |
---|
180 | } |
---|
181 | rps->setNumRefIdc(rpsRef->getNumberOfPictures()+1); |
---|
182 | rps->setNumberOfPictures(k); |
---|
183 | rps->setNumberOfNegativePictures(k0); |
---|
184 | rps->setNumberOfPositivePictures(k1); |
---|
185 | rps->sortDeltaPOC(); |
---|
186 | } |
---|
187 | else |
---|
188 | { |
---|
189 | READ_UVLC(code, "num_negative_pics"); rps->setNumberOfNegativePictures(code); |
---|
190 | READ_UVLC(code, "num_positive_pics"); rps->setNumberOfPositivePictures(code); |
---|
191 | Int prev = 0; |
---|
192 | Int poc; |
---|
193 | for(Int j=0 ; j < rps->getNumberOfNegativePictures(); j++) |
---|
194 | { |
---|
195 | READ_UVLC(code, "delta_poc_s0_minus1"); |
---|
196 | poc = prev-code-1; |
---|
197 | prev = poc; |
---|
198 | rps->setDeltaPOC(j,poc); |
---|
199 | READ_FLAG(code, "used_by_curr_pic_s0_flag"); rps->setUsed(j,code); |
---|
200 | } |
---|
201 | prev = 0; |
---|
202 | for(Int j=rps->getNumberOfNegativePictures(); j < rps->getNumberOfNegativePictures()+rps->getNumberOfPositivePictures(); j++) |
---|
203 | { |
---|
204 | READ_UVLC(code, "delta_poc_s1_minus1"); |
---|
205 | poc = prev+code+1; |
---|
206 | prev = poc; |
---|
207 | rps->setDeltaPOC(j,poc); |
---|
208 | READ_FLAG(code, "used_by_curr_pic_s1_flag"); rps->setUsed(j,code); |
---|
209 | } |
---|
210 | rps->setNumberOfPictures(rps->getNumberOfNegativePictures()+rps->getNumberOfPositivePictures()); |
---|
211 | } |
---|
212 | #if PRINT_RPS_INFO |
---|
213 | rps->printDeltaPOC(); |
---|
214 | #endif |
---|
215 | } |
---|
216 | |
---|
217 | #if H_3D |
---|
218 | Void TDecCavlc::parsePPS(TComPPS* pcPPS, TComVPS* pcVPS ) |
---|
219 | #else |
---|
220 | Void TDecCavlc::parsePPS(TComPPS* pcPPS) |
---|
221 | #endif |
---|
222 | { |
---|
223 | #if ENC_DEC_TRACE |
---|
224 | xTracePPSHeader (pcPPS); |
---|
225 | #endif |
---|
226 | UInt uiCode; |
---|
227 | |
---|
228 | Int iCode; |
---|
229 | |
---|
230 | READ_UVLC( uiCode, "pps_pic_parameter_set_id"); |
---|
231 | assert(uiCode <= 63); |
---|
232 | pcPPS->setPPSId (uiCode); |
---|
233 | |
---|
234 | READ_UVLC( uiCode, "pps_seq_parameter_set_id"); |
---|
235 | assert(uiCode <= 15); |
---|
236 | pcPPS->setSPSId (uiCode); |
---|
237 | |
---|
238 | READ_FLAG( uiCode, "dependent_slice_segments_enabled_flag" ); pcPPS->setDependentSliceSegmentsEnabledFlag ( uiCode == 1 ); |
---|
239 | READ_FLAG( uiCode, "output_flag_present_flag" ); pcPPS->setOutputFlagPresentFlag( uiCode==1 ); |
---|
240 | |
---|
241 | READ_CODE(3, uiCode, "num_extra_slice_header_bits"); pcPPS->setNumExtraSliceHeaderBits(uiCode); |
---|
242 | READ_FLAG ( uiCode, "sign_data_hiding_flag" ); pcPPS->setSignHideFlag( uiCode ); |
---|
243 | |
---|
244 | READ_FLAG( uiCode, "cabac_init_present_flag" ); pcPPS->setCabacInitPresentFlag( uiCode ? true : false ); |
---|
245 | |
---|
246 | READ_UVLC(uiCode, "num_ref_idx_l0_default_active_minus1"); |
---|
247 | assert(uiCode <= 14); |
---|
248 | pcPPS->setNumRefIdxL0DefaultActive(uiCode+1); |
---|
249 | |
---|
250 | READ_UVLC(uiCode, "num_ref_idx_l1_default_active_minus1"); |
---|
251 | assert(uiCode <= 14); |
---|
252 | pcPPS->setNumRefIdxL1DefaultActive(uiCode+1); |
---|
253 | |
---|
254 | READ_SVLC(iCode, "init_qp_minus26" ); pcPPS->setPicInitQPMinus26(iCode); |
---|
255 | READ_FLAG( uiCode, "constrained_intra_pred_flag" ); pcPPS->setConstrainedIntraPred( uiCode ? true : false ); |
---|
256 | READ_FLAG( uiCode, "transform_skip_enabled_flag" ); |
---|
257 | pcPPS->setUseTransformSkip ( uiCode ? true : false ); |
---|
258 | |
---|
259 | READ_FLAG( uiCode, "cu_qp_delta_enabled_flag" ); pcPPS->setUseDQP( uiCode ? true : false ); |
---|
260 | if( pcPPS->getUseDQP() ) |
---|
261 | { |
---|
262 | READ_UVLC( uiCode, "diff_cu_qp_delta_depth" ); |
---|
263 | pcPPS->setMaxCuDQPDepth( uiCode ); |
---|
264 | } |
---|
265 | else |
---|
266 | { |
---|
267 | pcPPS->setMaxCuDQPDepth( 0 ); |
---|
268 | } |
---|
269 | READ_SVLC( iCode, "pps_cb_qp_offset"); |
---|
270 | pcPPS->setChromaCbQpOffset(iCode); |
---|
271 | assert( pcPPS->getChromaCbQpOffset() >= -12 ); |
---|
272 | assert( pcPPS->getChromaCbQpOffset() <= 12 ); |
---|
273 | |
---|
274 | READ_SVLC( iCode, "pps_cr_qp_offset"); |
---|
275 | pcPPS->setChromaCrQpOffset(iCode); |
---|
276 | assert( pcPPS->getChromaCrQpOffset() >= -12 ); |
---|
277 | assert( pcPPS->getChromaCrQpOffset() <= 12 ); |
---|
278 | |
---|
279 | READ_FLAG( uiCode, "pps_slice_chroma_qp_offsets_present_flag" ); |
---|
280 | pcPPS->setSliceChromaQpFlag( uiCode ? true : false ); |
---|
281 | |
---|
282 | READ_FLAG( uiCode, "weighted_pred_flag" ); // Use of Weighting Prediction (P_SLICE) |
---|
283 | pcPPS->setUseWP( uiCode==1 ); |
---|
284 | READ_FLAG( uiCode, "weighted_bipred_flag" ); // Use of Bi-Directional Weighting Prediction (B_SLICE) |
---|
285 | pcPPS->setWPBiPred( uiCode==1 ); |
---|
286 | |
---|
287 | READ_FLAG( uiCode, "transquant_bypass_enable_flag"); |
---|
288 | pcPPS->setTransquantBypassEnableFlag(uiCode ? true : false); |
---|
289 | READ_FLAG( uiCode, "tiles_enabled_flag" ); pcPPS->setTilesEnabledFlag ( uiCode == 1 ); |
---|
290 | READ_FLAG( uiCode, "entropy_coding_sync_enabled_flag" ); pcPPS->setEntropyCodingSyncEnabledFlag( uiCode == 1 ); |
---|
291 | |
---|
292 | if( pcPPS->getTilesEnabledFlag() ) |
---|
293 | { |
---|
294 | READ_UVLC ( uiCode, "num_tile_columns_minus1" ); pcPPS->setNumColumnsMinus1( uiCode ); |
---|
295 | READ_UVLC ( uiCode, "num_tile_rows_minus1" ); pcPPS->setNumRowsMinus1( uiCode ); |
---|
296 | READ_FLAG ( uiCode, "uniform_spacing_flag" ); pcPPS->setUniformSpacingFlag( uiCode ); |
---|
297 | |
---|
298 | if( !pcPPS->getUniformSpacingFlag()) |
---|
299 | { |
---|
300 | UInt* columnWidth = (UInt*)malloc(pcPPS->getNumColumnsMinus1()*sizeof(UInt)); |
---|
301 | for(UInt i=0; i<pcPPS->getNumColumnsMinus1(); i++) |
---|
302 | { |
---|
303 | READ_UVLC( uiCode, "column_width_minus1" ); |
---|
304 | columnWidth[i] = uiCode+1; |
---|
305 | } |
---|
306 | pcPPS->setColumnWidth(columnWidth); |
---|
307 | free(columnWidth); |
---|
308 | |
---|
309 | UInt* rowHeight = (UInt*)malloc(pcPPS->getNumRowsMinus1()*sizeof(UInt)); |
---|
310 | for(UInt i=0; i<pcPPS->getNumRowsMinus1(); i++) |
---|
311 | { |
---|
312 | READ_UVLC( uiCode, "row_height_minus1" ); |
---|
313 | rowHeight[i] = uiCode + 1; |
---|
314 | } |
---|
315 | pcPPS->setRowHeight(rowHeight); |
---|
316 | free(rowHeight); |
---|
317 | } |
---|
318 | |
---|
319 | if(pcPPS->getNumColumnsMinus1() !=0 || pcPPS->getNumRowsMinus1() !=0) |
---|
320 | { |
---|
321 | READ_FLAG ( uiCode, "loop_filter_across_tiles_enabled_flag" ); pcPPS->setLoopFilterAcrossTilesEnabledFlag( uiCode ? true : false ); |
---|
322 | } |
---|
323 | } |
---|
324 | READ_FLAG( uiCode, "loop_filter_across_slices_enabled_flag" ); pcPPS->setLoopFilterAcrossSlicesEnabledFlag( uiCode ? true : false ); |
---|
325 | READ_FLAG( uiCode, "deblocking_filter_control_present_flag" ); pcPPS->setDeblockingFilterControlPresentFlag( uiCode ? true : false ); |
---|
326 | if(pcPPS->getDeblockingFilterControlPresentFlag()) |
---|
327 | { |
---|
328 | READ_FLAG( uiCode, "deblocking_filter_override_enabled_flag" ); pcPPS->setDeblockingFilterOverrideEnabledFlag( uiCode ? true : false ); |
---|
329 | READ_FLAG( uiCode, "pps_disable_deblocking_filter_flag" ); pcPPS->setPicDisableDeblockingFilterFlag(uiCode ? true : false ); |
---|
330 | if(!pcPPS->getPicDisableDeblockingFilterFlag()) |
---|
331 | { |
---|
332 | READ_SVLC ( iCode, "pps_beta_offset_div2" ); pcPPS->setDeblockingFilterBetaOffsetDiv2( iCode ); |
---|
333 | READ_SVLC ( iCode, "pps_tc_offset_div2" ); pcPPS->setDeblockingFilterTcOffsetDiv2( iCode ); |
---|
334 | } |
---|
335 | } |
---|
336 | #if H_MV |
---|
337 | if ( pcPPS->getLayerId() > 0 ) |
---|
338 | { |
---|
339 | READ_FLAG( uiCode, "pps_infer_scaling_list_flag" ); pcPPS->setPpsInferScalingListFlag( uiCode == 1 ); |
---|
340 | } |
---|
341 | |
---|
342 | if( pcPPS->getPpsInferScalingListFlag( ) ) |
---|
343 | { |
---|
344 | READ_CODE( 6, uiCode, "pps_scaling_list_ref_layer_id" ); pcPPS->setPpsScalingListRefLayerId( uiCode ); |
---|
345 | } |
---|
346 | else |
---|
347 | { |
---|
348 | #endif |
---|
349 | READ_FLAG( uiCode, "pps_scaling_list_data_present_flag" ); pcPPS->setScalingListPresentFlag( uiCode ? true : false ); |
---|
350 | if(pcPPS->getScalingListPresentFlag ()) |
---|
351 | { |
---|
352 | parseScalingList( pcPPS->getScalingList() ); |
---|
353 | } |
---|
354 | #if H_MV |
---|
355 | } |
---|
356 | #endif |
---|
357 | |
---|
358 | READ_FLAG( uiCode, "lists_modification_present_flag"); |
---|
359 | pcPPS->setListsModificationPresentFlag(uiCode); |
---|
360 | |
---|
361 | READ_UVLC( uiCode, "log2_parallel_merge_level_minus2"); |
---|
362 | pcPPS->setLog2ParallelMergeLevelMinus2 (uiCode); |
---|
363 | |
---|
364 | READ_FLAG( uiCode, "slice_segment_header_extension_present_flag"); |
---|
365 | pcPPS->setSliceHeaderExtensionPresentFlag(uiCode); |
---|
366 | |
---|
367 | #if H_MV |
---|
368 | READ_FLAG( uiCode, "pps_extension_present_flag"); |
---|
369 | #else |
---|
370 | READ_FLAG( uiCode, "pps_extension_flag"); |
---|
371 | #endif |
---|
372 | if (uiCode) |
---|
373 | { |
---|
374 | |
---|
375 | #if H_MV |
---|
376 | READ_FLAG( uiCode, "pps_range_extensions_flag" ); pcPPS->setPpsRangeExtensionsFlag( uiCode == 1 ); |
---|
377 | READ_FLAG( uiCode, "pps_multilayer_extension_flag" ); pcPPS->setPpsMultilayerExtensionFlag( uiCode == 1 ); |
---|
378 | #if !H_3D |
---|
379 | READ_CODE( 6, uiCode, "pps_extension_6bits" ); pcPPS->setPpsExtension6bits( uiCode ); |
---|
380 | #else |
---|
381 | READ_FLAG( uiCode, "pps_3d_extension_flag" ); pcPPS->setPps3dExtensionFlag( uiCode == 1 ); |
---|
382 | READ_CODE( 5, uiCode, "pps_extension_5bits" ); pcPPS->setPpsExtension5bits( uiCode ); |
---|
383 | #endif |
---|
384 | if ( pcPPS->getPpsRangeExtensionsFlag() ) |
---|
385 | { |
---|
386 | assert(0); |
---|
387 | } |
---|
388 | |
---|
389 | if ( pcPPS->getPpsMultilayerExtensionFlag() ) |
---|
390 | { |
---|
391 | READ_FLAG( uiCode, "poc_reset_info_present_flag" ); pcPPS->setPocResetInfoPresentFlag( uiCode == 1 ); |
---|
392 | READ_FLAG( uiCode, "pps_extension_reserved_zero_flag" ); |
---|
393 | } |
---|
394 | #if !H_3D |
---|
395 | if ( pcPPS->getPpsExtension6bits() ) |
---|
396 | { |
---|
397 | #else |
---|
398 | if ( pcPPS->getPps3dExtensionFlag() ) |
---|
399 | { |
---|
400 | parsePPSExtension( pcPPS, pcVPS ); |
---|
401 | } |
---|
402 | if ( pcPPS->getPpsExtension5bits() ) |
---|
403 | { |
---|
404 | #endif |
---|
405 | |
---|
406 | #endif |
---|
407 | |
---|
408 | while ( xMoreRbspData() ) |
---|
409 | { |
---|
410 | READ_FLAG( uiCode, "pps_extension_data_flag"); |
---|
411 | } |
---|
412 | #if H_MV |
---|
413 | } |
---|
414 | #endif |
---|
415 | } |
---|
416 | } |
---|
417 | |
---|
418 | #if H_3D |
---|
419 | Void TDecCavlc::parsePPSExtension( TComPPS* pcPPS, TComVPS* pcVPS ) |
---|
420 | { |
---|
421 | //Ed.(GT): pcVPS should not be used here. Needs to be fixed. |
---|
422 | UInt uiCode = 0; |
---|
423 | TComDLT* pcDLT = new TComDLT; |
---|
424 | |
---|
425 | READ_FLAG(uiCode, "dlt_present_flag"); |
---|
426 | pcDLT->setDltPresentFlag( (uiCode == 1) ? true : false ); |
---|
427 | |
---|
428 | if ( pcDLT->getDltPresentFlag() ) |
---|
429 | { |
---|
430 | READ_CODE(6, uiCode, "pps_depth_layers_minus1"); |
---|
431 | pcDLT->setNumDepthViews( uiCode ); |
---|
432 | |
---|
433 | READ_CODE(4, uiCode, "pps_bit_depth_for_depth_views_minus8"); |
---|
434 | pcDLT->setDepthViewBitDepth( (uiCode+8) ); |
---|
435 | |
---|
436 | for( Int i = 0; i <= pcVPS->getMaxLayersMinus1(); i++ ) |
---|
437 | { |
---|
438 | if ( i != 0 ) |
---|
439 | { |
---|
440 | if( pcVPS->getDepthId( i ) == 1 ) |
---|
441 | { |
---|
442 | READ_FLAG(uiCode, "dlt_flag[i]"); |
---|
443 | pcDLT->setUseDLTFlag(i, (uiCode == 1) ? true : false); |
---|
444 | |
---|
445 | if ( pcDLT->getUseDLTFlag( i ) ) |
---|
446 | { |
---|
447 | Bool bDltBitMapRepFlag = false; |
---|
448 | UInt uiMaxDiff = 0xffffffff; |
---|
449 | UInt uiMinDiff = 0; |
---|
450 | UInt uiCodeLength = 0; |
---|
451 | |
---|
452 | READ_FLAG(uiCode, "inter_view_dlt_pred_enable_flag[ i ]"); |
---|
453 | |
---|
454 | if( uiCode ) |
---|
455 | { |
---|
456 | assert( pcDLT->getUseDLTFlag( 1 )); |
---|
457 | } |
---|
458 | pcDLT->setInterViewDltPredEnableFlag( i, (uiCode == 1) ? true : false ); |
---|
459 | |
---|
460 | if ( pcDLT->getInterViewDltPredEnableFlag( i ) == false ) |
---|
461 | { |
---|
462 | READ_FLAG(uiCode, "dlt_bit_map_rep_flag[ layerId ]"); |
---|
463 | bDltBitMapRepFlag = (uiCode == 1) ? true : false; |
---|
464 | } |
---|
465 | else |
---|
466 | { |
---|
467 | bDltBitMapRepFlag = false; |
---|
468 | } |
---|
469 | |
---|
470 | UInt uiNumDepthValues = 0; |
---|
471 | Int aiIdx2DepthValue[256]; |
---|
472 | |
---|
473 | // Bit map |
---|
474 | if ( bDltBitMapRepFlag ) |
---|
475 | { |
---|
476 | for (UInt d=0; d<256; d++) |
---|
477 | { |
---|
478 | READ_FLAG(uiCode, "dlt_bit_map_flag[ layerId ][ j ]"); |
---|
479 | if (uiCode == 1) |
---|
480 | { |
---|
481 | aiIdx2DepthValue[uiNumDepthValues] = d; |
---|
482 | uiNumDepthValues++; |
---|
483 | } |
---|
484 | } |
---|
485 | } |
---|
486 | // Diff Coding |
---|
487 | else |
---|
488 | { |
---|
489 | READ_CODE(8, uiNumDepthValues, "num_depth_values_in_dlt[i]"); // num_entry |
---|
490 | |
---|
491 | #if !H_3D_DELTA_DLT |
---|
492 | if ( pcDLT->getInterViewDltPredEnableFlag( i ) == false ) // Single-view DLT Diff Coding |
---|
493 | #endif |
---|
494 | { |
---|
495 | // The condition if( pcVPS->getNumDepthValues(i) > 0 ) is always true since for Single-view Diff Coding, there is at least one depth value in depth component. |
---|
496 | |
---|
497 | if (uiNumDepthValues > 1) |
---|
498 | { |
---|
499 | READ_CODE(8, uiCode, "max_diff[ layerId ]"); |
---|
500 | uiMaxDiff = uiCode; |
---|
501 | } |
---|
502 | else |
---|
503 | { |
---|
504 | uiMaxDiff = 0; // when there is only one value in DLT |
---|
505 | } |
---|
506 | |
---|
507 | if (uiNumDepthValues > 2) |
---|
508 | { |
---|
509 | uiCodeLength = (UInt) ceil(Log2(uiMaxDiff + 1)); |
---|
510 | READ_CODE(uiCodeLength, uiCode, "min_diff_minus1[ layerId ]"); |
---|
511 | uiMinDiff = uiCode + 1; |
---|
512 | } |
---|
513 | else |
---|
514 | { |
---|
515 | uiMinDiff = uiMaxDiff; // when there are only one or two values in DLT |
---|
516 | } |
---|
517 | |
---|
518 | READ_CODE(8, uiCode, "dlt_depth_value0[layerId]"); // entry0 |
---|
519 | aiIdx2DepthValue[0] = uiCode; |
---|
520 | |
---|
521 | if (uiMaxDiff == uiMinDiff) |
---|
522 | { |
---|
523 | for (UInt d=1; d<uiNumDepthValues; d++) |
---|
524 | { |
---|
525 | aiIdx2DepthValue[d] = aiIdx2DepthValue[d-1] + uiMinDiff + 0; |
---|
526 | } |
---|
527 | } |
---|
528 | else |
---|
529 | { |
---|
530 | uiCodeLength = (UInt) ceil(Log2(uiMaxDiff - uiMinDiff + 1)); |
---|
531 | for (UInt d=1; d<uiNumDepthValues; d++) |
---|
532 | { |
---|
533 | READ_CODE(uiCodeLength, uiCode, "dlt_depth_value_diff_minus_min[ layerId ][ j ]"); |
---|
534 | aiIdx2DepthValue[d] = aiIdx2DepthValue[d-1] + uiMinDiff + uiCode; |
---|
535 | } |
---|
536 | } |
---|
537 | |
---|
538 | } |
---|
539 | } |
---|
540 | |
---|
541 | #if H_3D_DELTA_DLT |
---|
542 | if( pcDLT->getInterViewDltPredEnableFlag( i ) ) |
---|
543 | { |
---|
544 | // interpret decoded values as delta DLT |
---|
545 | AOF( pcVPS->getDepthId( 1 ) == 1 ); |
---|
546 | AOF( i > 1 ); |
---|
547 | // assumes ref layer id to be 1 |
---|
548 | Int* piRefDLT = pcDLT->idx2DepthValue( 1 ); |
---|
549 | UInt uiRefNum = pcDLT->getNumDepthValues( 1 ); |
---|
550 | pcDLT->setDeltaDLT(i, piRefDLT, uiRefNum, aiIdx2DepthValue, uiNumDepthValues); |
---|
551 | } |
---|
552 | else |
---|
553 | { |
---|
554 | // store final DLT |
---|
555 | pcDLT->setDepthLUTs(i, aiIdx2DepthValue, uiNumDepthValues); |
---|
556 | } |
---|
557 | #else |
---|
558 | // store final DLT |
---|
559 | pcDLT->setDepthLUTs(i, aiIdx2DepthValue, uiNumDepthValues); |
---|
560 | #endif |
---|
561 | } |
---|
562 | } |
---|
563 | } |
---|
564 | } |
---|
565 | } |
---|
566 | |
---|
567 | pcPPS->setDLT( pcDLT ); |
---|
568 | } |
---|
569 | #endif |
---|
570 | |
---|
571 | Void TDecCavlc::parseVUI(TComVUI* pcVUI, TComSPS *pcSPS) |
---|
572 | { |
---|
573 | #if ENC_DEC_TRACE |
---|
574 | fprintf( g_hTrace, "----------- vui_parameters -----------\n"); |
---|
575 | #endif |
---|
576 | UInt uiCode; |
---|
577 | |
---|
578 | READ_FLAG( uiCode, "aspect_ratio_info_present_flag"); pcVUI->setAspectRatioInfoPresentFlag(uiCode); |
---|
579 | if (pcVUI->getAspectRatioInfoPresentFlag()) |
---|
580 | { |
---|
581 | READ_CODE(8, uiCode, "aspect_ratio_idc"); pcVUI->setAspectRatioIdc(uiCode); |
---|
582 | if (pcVUI->getAspectRatioIdc() == 255) |
---|
583 | { |
---|
584 | READ_CODE(16, uiCode, "sar_width"); pcVUI->setSarWidth(uiCode); |
---|
585 | READ_CODE(16, uiCode, "sar_height"); pcVUI->setSarHeight(uiCode); |
---|
586 | } |
---|
587 | } |
---|
588 | |
---|
589 | READ_FLAG( uiCode, "overscan_info_present_flag"); pcVUI->setOverscanInfoPresentFlag(uiCode); |
---|
590 | if (pcVUI->getOverscanInfoPresentFlag()) |
---|
591 | { |
---|
592 | READ_FLAG( uiCode, "overscan_appropriate_flag"); pcVUI->setOverscanAppropriateFlag(uiCode); |
---|
593 | } |
---|
594 | |
---|
595 | READ_FLAG( uiCode, "video_signal_type_present_flag"); pcVUI->setVideoSignalTypePresentFlag(uiCode); |
---|
596 | #if H_MV |
---|
597 | assert( pcSPS->getLayerId() == 0 || !pcVUI->getVideoSignalTypePresentFlag() ); |
---|
598 | #endif |
---|
599 | if (pcVUI->getVideoSignalTypePresentFlag()) |
---|
600 | { |
---|
601 | READ_CODE(3, uiCode, "video_format"); pcVUI->setVideoFormat(uiCode); |
---|
602 | READ_FLAG( uiCode, "video_full_range_flag"); pcVUI->setVideoFullRangeFlag(uiCode); |
---|
603 | READ_FLAG( uiCode, "colour_description_present_flag"); pcVUI->setColourDescriptionPresentFlag(uiCode); |
---|
604 | if (pcVUI->getColourDescriptionPresentFlag()) |
---|
605 | { |
---|
606 | READ_CODE(8, uiCode, "colour_primaries"); pcVUI->setColourPrimaries(uiCode); |
---|
607 | READ_CODE(8, uiCode, "transfer_characteristics"); pcVUI->setTransferCharacteristics(uiCode); |
---|
608 | READ_CODE(8, uiCode, "matrix_coefficients"); pcVUI->setMatrixCoefficients(uiCode); |
---|
609 | } |
---|
610 | } |
---|
611 | |
---|
612 | READ_FLAG( uiCode, "chroma_loc_info_present_flag"); pcVUI->setChromaLocInfoPresentFlag(uiCode); |
---|
613 | if (pcVUI->getChromaLocInfoPresentFlag()) |
---|
614 | { |
---|
615 | READ_UVLC( uiCode, "chroma_sample_loc_type_top_field" ); pcVUI->setChromaSampleLocTypeTopField(uiCode); |
---|
616 | READ_UVLC( uiCode, "chroma_sample_loc_type_bottom_field" ); pcVUI->setChromaSampleLocTypeBottomField(uiCode); |
---|
617 | } |
---|
618 | |
---|
619 | READ_FLAG( uiCode, "neutral_chroma_indication_flag"); pcVUI->setNeutralChromaIndicationFlag(uiCode); |
---|
620 | |
---|
621 | READ_FLAG( uiCode, "field_seq_flag"); pcVUI->setFieldSeqFlag(uiCode); |
---|
622 | |
---|
623 | READ_FLAG(uiCode, "frame_field_info_present_flag"); pcVUI->setFrameFieldInfoPresentFlag(uiCode); |
---|
624 | |
---|
625 | READ_FLAG( uiCode, "default_display_window_flag"); |
---|
626 | if (uiCode != 0) |
---|
627 | { |
---|
628 | Window &defDisp = pcVUI->getDefaultDisplayWindow(); |
---|
629 | #if H_MV |
---|
630 | defDisp.setScaledFlag( false ); |
---|
631 | READ_UVLC( uiCode, "def_disp_win_left_offset" ); defDisp.setWindowLeftOffset ( uiCode ); |
---|
632 | READ_UVLC( uiCode, "def_disp_win_right_offset" ); defDisp.setWindowRightOffset ( uiCode ); |
---|
633 | READ_UVLC( uiCode, "def_disp_win_top_offset" ); defDisp.setWindowTopOffset ( uiCode ); |
---|
634 | READ_UVLC( uiCode, "def_disp_win_bottom_offset" ); defDisp.setWindowBottomOffset( uiCode ); |
---|
635 | #else |
---|
636 | READ_UVLC( uiCode, "def_disp_win_left_offset" ); defDisp.setWindowLeftOffset ( uiCode * TComSPS::getWinUnitX( pcSPS->getChromaFormatIdc()) ); |
---|
637 | READ_UVLC( uiCode, "def_disp_win_right_offset" ); defDisp.setWindowRightOffset ( uiCode * TComSPS::getWinUnitX( pcSPS->getChromaFormatIdc()) ); |
---|
638 | READ_UVLC( uiCode, "def_disp_win_top_offset" ); defDisp.setWindowTopOffset ( uiCode * TComSPS::getWinUnitY( pcSPS->getChromaFormatIdc()) ); |
---|
639 | READ_UVLC( uiCode, "def_disp_win_bottom_offset" ); defDisp.setWindowBottomOffset( uiCode * TComSPS::getWinUnitY( pcSPS->getChromaFormatIdc()) ); |
---|
640 | #endif |
---|
641 | } |
---|
642 | TimingInfo *timingInfo = pcVUI->getTimingInfo(); |
---|
643 | READ_FLAG( uiCode, "vui_timing_info_present_flag"); timingInfo->setTimingInfoPresentFlag (uiCode ? true : false); |
---|
644 | if(timingInfo->getTimingInfoPresentFlag()) |
---|
645 | { |
---|
646 | READ_CODE( 32, uiCode, "vui_num_units_in_tick"); timingInfo->setNumUnitsInTick (uiCode); |
---|
647 | READ_CODE( 32, uiCode, "vui_time_scale"); timingInfo->setTimeScale (uiCode); |
---|
648 | READ_FLAG( uiCode, "vui_poc_proportional_to_timing_flag"); timingInfo->setPocProportionalToTimingFlag(uiCode ? true : false); |
---|
649 | if(timingInfo->getPocProportionalToTimingFlag()) |
---|
650 | { |
---|
651 | READ_UVLC( uiCode, "vui_num_ticks_poc_diff_one_minus1"); timingInfo->setNumTicksPocDiffOneMinus1 (uiCode); |
---|
652 | } |
---|
653 | READ_FLAG( uiCode, "hrd_parameters_present_flag"); pcVUI->setHrdParametersPresentFlag(uiCode); |
---|
654 | if( pcVUI->getHrdParametersPresentFlag() ) |
---|
655 | { |
---|
656 | parseHrdParameters( pcVUI->getHrdParameters(), 1, pcSPS->getMaxTLayers() - 1 ); |
---|
657 | } |
---|
658 | } |
---|
659 | READ_FLAG( uiCode, "bitstream_restriction_flag"); pcVUI->setBitstreamRestrictionFlag(uiCode); |
---|
660 | if (pcVUI->getBitstreamRestrictionFlag()) |
---|
661 | { |
---|
662 | READ_FLAG( uiCode, "tiles_fixed_structure_flag"); pcVUI->setTilesFixedStructureFlag(uiCode); |
---|
663 | READ_FLAG( uiCode, "motion_vectors_over_pic_boundaries_flag"); pcVUI->setMotionVectorsOverPicBoundariesFlag(uiCode); |
---|
664 | READ_FLAG( uiCode, "restricted_ref_pic_lists_flag"); pcVUI->setRestrictedRefPicListsFlag(uiCode); |
---|
665 | READ_UVLC( uiCode, "min_spatial_segmentation_idc"); pcVUI->setMinSpatialSegmentationIdc(uiCode); |
---|
666 | assert(uiCode < 4096); |
---|
667 | READ_UVLC( uiCode, "max_bytes_per_pic_denom" ); pcVUI->setMaxBytesPerPicDenom(uiCode); |
---|
668 | READ_UVLC( uiCode, "max_bits_per_mincu_denom" ); pcVUI->setMaxBitsPerMinCuDenom(uiCode); |
---|
669 | READ_UVLC( uiCode, "log2_max_mv_length_horizontal" ); pcVUI->setLog2MaxMvLengthHorizontal(uiCode); |
---|
670 | READ_UVLC( uiCode, "log2_max_mv_length_vertical" ); pcVUI->setLog2MaxMvLengthVertical(uiCode); |
---|
671 | } |
---|
672 | } |
---|
673 | |
---|
674 | Void TDecCavlc::parseHrdParameters(TComHRD *hrd, Bool commonInfPresentFlag, UInt maxNumSubLayersMinus1) |
---|
675 | { |
---|
676 | UInt uiCode; |
---|
677 | if( commonInfPresentFlag ) |
---|
678 | { |
---|
679 | READ_FLAG( uiCode, "nal_hrd_parameters_present_flag" ); hrd->setNalHrdParametersPresentFlag( uiCode == 1 ? true : false ); |
---|
680 | READ_FLAG( uiCode, "vcl_hrd_parameters_present_flag" ); hrd->setVclHrdParametersPresentFlag( uiCode == 1 ? true : false ); |
---|
681 | if( hrd->getNalHrdParametersPresentFlag() || hrd->getVclHrdParametersPresentFlag() ) |
---|
682 | { |
---|
683 | READ_FLAG( uiCode, "sub_pic_cpb_params_present_flag" ); hrd->setSubPicCpbParamsPresentFlag( uiCode == 1 ? true : false ); |
---|
684 | if( hrd->getSubPicCpbParamsPresentFlag() ) |
---|
685 | { |
---|
686 | READ_CODE( 8, uiCode, "tick_divisor_minus2" ); hrd->setTickDivisorMinus2( uiCode ); |
---|
687 | READ_CODE( 5, uiCode, "du_cpb_removal_delay_length_minus1" ); hrd->setDuCpbRemovalDelayLengthMinus1( uiCode ); |
---|
688 | READ_FLAG( uiCode, "sub_pic_cpb_params_in_pic_timing_sei_flag" ); hrd->setSubPicCpbParamsInPicTimingSEIFlag( uiCode == 1 ? true : false ); |
---|
689 | READ_CODE( 5, uiCode, "dpb_output_delay_du_length_minus1" ); hrd->setDpbOutputDelayDuLengthMinus1( uiCode ); |
---|
690 | } |
---|
691 | READ_CODE( 4, uiCode, "bit_rate_scale" ); hrd->setBitRateScale( uiCode ); |
---|
692 | READ_CODE( 4, uiCode, "cpb_size_scale" ); hrd->setCpbSizeScale( uiCode ); |
---|
693 | if( hrd->getSubPicCpbParamsPresentFlag() ) |
---|
694 | { |
---|
695 | READ_CODE( 4, uiCode, "cpb_size_du_scale" ); hrd->setDuCpbSizeScale( uiCode ); |
---|
696 | } |
---|
697 | READ_CODE( 5, uiCode, "initial_cpb_removal_delay_length_minus1" ); hrd->setInitialCpbRemovalDelayLengthMinus1( uiCode ); |
---|
698 | READ_CODE( 5, uiCode, "au_cpb_removal_delay_length_minus1" ); hrd->setCpbRemovalDelayLengthMinus1( uiCode ); |
---|
699 | READ_CODE( 5, uiCode, "dpb_output_delay_length_minus1" ); hrd->setDpbOutputDelayLengthMinus1( uiCode ); |
---|
700 | } |
---|
701 | } |
---|
702 | Int i, j, nalOrVcl; |
---|
703 | for( i = 0; i <= maxNumSubLayersMinus1; i ++ ) |
---|
704 | { |
---|
705 | READ_FLAG( uiCode, "fixed_pic_rate_general_flag" ); hrd->setFixedPicRateFlag( i, uiCode == 1 ? true : false ); |
---|
706 | if( !hrd->getFixedPicRateFlag( i ) ) |
---|
707 | { |
---|
708 | READ_FLAG( uiCode, "fixed_pic_rate_within_cvs_flag" ); hrd->setFixedPicRateWithinCvsFlag( i, uiCode == 1 ? true : false ); |
---|
709 | } |
---|
710 | else |
---|
711 | { |
---|
712 | hrd->setFixedPicRateWithinCvsFlag( i, true ); |
---|
713 | } |
---|
714 | hrd->setLowDelayHrdFlag( i, 0 ); // Infered to be 0 when not present |
---|
715 | hrd->setCpbCntMinus1 ( i, 0 ); // Infered to be 0 when not present |
---|
716 | if( hrd->getFixedPicRateWithinCvsFlag( i ) ) |
---|
717 | { |
---|
718 | READ_UVLC( uiCode, "elemental_duration_in_tc_minus1" ); hrd->setPicDurationInTcMinus1( i, uiCode ); |
---|
719 | } |
---|
720 | else |
---|
721 | { |
---|
722 | READ_FLAG( uiCode, "low_delay_hrd_flag" ); hrd->setLowDelayHrdFlag( i, uiCode == 1 ? true : false ); |
---|
723 | } |
---|
724 | if (!hrd->getLowDelayHrdFlag( i )) |
---|
725 | { |
---|
726 | READ_UVLC( uiCode, "cpb_cnt_minus1" ); hrd->setCpbCntMinus1( i, uiCode ); |
---|
727 | } |
---|
728 | for( nalOrVcl = 0; nalOrVcl < 2; nalOrVcl ++ ) |
---|
729 | { |
---|
730 | if( ( ( nalOrVcl == 0 ) && ( hrd->getNalHrdParametersPresentFlag() ) ) || |
---|
731 | ( ( nalOrVcl == 1 ) && ( hrd->getVclHrdParametersPresentFlag() ) ) ) |
---|
732 | { |
---|
733 | for( j = 0; j <= ( hrd->getCpbCntMinus1( i ) ); j ++ ) |
---|
734 | { |
---|
735 | READ_UVLC( uiCode, "bit_rate_value_minus1" ); hrd->setBitRateValueMinus1( i, j, nalOrVcl, uiCode ); |
---|
736 | READ_UVLC( uiCode, "cpb_size_value_minus1" ); hrd->setCpbSizeValueMinus1( i, j, nalOrVcl, uiCode ); |
---|
737 | if( hrd->getSubPicCpbParamsPresentFlag() ) |
---|
738 | { |
---|
739 | READ_UVLC( uiCode, "cpb_size_du_value_minus1" ); hrd->setDuCpbSizeValueMinus1( i, j, nalOrVcl, uiCode ); |
---|
740 | READ_UVLC( uiCode, "bit_rate_du_value_minus1" ); hrd->setDuBitRateValueMinus1( i, j, nalOrVcl, uiCode ); |
---|
741 | } |
---|
742 | READ_FLAG( uiCode, "cbr_flag" ); hrd->setCbrFlag( i, j, nalOrVcl, uiCode == 1 ? true : false ); |
---|
743 | } |
---|
744 | } |
---|
745 | } |
---|
746 | } |
---|
747 | } |
---|
748 | |
---|
749 | #if H_3D |
---|
750 | Void TDecCavlc::parseSPS(TComSPS* pcSPS, Int viewIndex, Bool depthFlag ) |
---|
751 | #else |
---|
752 | Void TDecCavlc::parseSPS(TComSPS* pcSPS) |
---|
753 | #endif |
---|
754 | { |
---|
755 | #if ENC_DEC_TRACE |
---|
756 | xTraceSPSHeader (pcSPS); |
---|
757 | #endif |
---|
758 | |
---|
759 | UInt uiCode; |
---|
760 | READ_CODE( 4, uiCode, "sps_video_parameter_set_id"); pcSPS->setVPSId ( uiCode ); |
---|
761 | #if H_MV |
---|
762 | if ( pcSPS->getLayerId() == 0 ) |
---|
763 | { |
---|
764 | #endif |
---|
765 | READ_CODE( 3, uiCode, "sps_max_sub_layers_minus1" ); pcSPS->setMaxTLayers ( uiCode+1 ); |
---|
766 | assert(uiCode <= 6); |
---|
767 | |
---|
768 | READ_FLAG( uiCode, "sps_temporal_id_nesting_flag" ); pcSPS->setTemporalIdNestingFlag ( uiCode > 0 ? true : false ); |
---|
769 | if ( pcSPS->getMaxTLayers() == 1 ) |
---|
770 | { |
---|
771 | // sps_temporal_id_nesting_flag must be 1 when sps_max_sub_layers_minus1 is 0 |
---|
772 | assert( uiCode == 1 ); |
---|
773 | } |
---|
774 | |
---|
775 | parsePTL(pcSPS->getPTL(), 1, pcSPS->getMaxTLayers() - 1); |
---|
776 | #if H_MV |
---|
777 | } |
---|
778 | #endif |
---|
779 | READ_UVLC( uiCode, "sps_seq_parameter_set_id" ); pcSPS->setSPSId( uiCode ); |
---|
780 | assert(uiCode <= 15); |
---|
781 | #if H_MV |
---|
782 | if ( pcSPS->getLayerId() > 0 ) |
---|
783 | { |
---|
784 | READ_FLAG( uiCode, "update_rep_format_flag" ); pcSPS->setUpdateRepFormatFlag( uiCode == 1 ); |
---|
785 | if ( pcSPS->getUpdateRepFormatFlag() ) |
---|
786 | { |
---|
787 | READ_CODE( 8, uiCode, "sps_rep_format_idx" ); pcSPS->setSpsRepFormatIdx( uiCode ); |
---|
788 | } |
---|
789 | } |
---|
790 | else |
---|
791 | { |
---|
792 | #endif |
---|
793 | READ_UVLC( uiCode, "chroma_format_idc" ); pcSPS->setChromaFormatIdc( uiCode ); |
---|
794 | assert(uiCode <= 3); |
---|
795 | // in the first version we only support chroma_format_idc equal to 1 (4:2:0), so separate_colour_plane_flag cannot appear in the bitstream |
---|
796 | assert (uiCode == 1); |
---|
797 | if( uiCode == 3 ) |
---|
798 | { |
---|
799 | READ_FLAG( uiCode, "separate_colour_plane_flag"); assert(uiCode == 0); |
---|
800 | } |
---|
801 | |
---|
802 | READ_UVLC ( uiCode, "pic_width_in_luma_samples" ); pcSPS->setPicWidthInLumaSamples ( uiCode ); |
---|
803 | READ_UVLC ( uiCode, "pic_height_in_luma_samples" ); pcSPS->setPicHeightInLumaSamples( uiCode ); |
---|
804 | #if H_MV |
---|
805 | } |
---|
806 | #endif |
---|
807 | READ_FLAG( uiCode, "conformance_window_flag"); |
---|
808 | if (uiCode != 0) |
---|
809 | { |
---|
810 | Window &conf = pcSPS->getConformanceWindow(); |
---|
811 | #if H_MV |
---|
812 | // Needs to be scaled later, when ChromaFormatIdc is known. |
---|
813 | conf.setScaledFlag( false ); |
---|
814 | READ_UVLC( uiCode, "conf_win_left_offset" ); conf.setWindowLeftOffset ( uiCode ); |
---|
815 | READ_UVLC( uiCode, "conf_win_right_offset" ); conf.setWindowRightOffset ( uiCode ); |
---|
816 | READ_UVLC( uiCode, "conf_win_top_offset" ); conf.setWindowTopOffset ( uiCode ); |
---|
817 | READ_UVLC( uiCode, "conf_win_bottom_offset" ); conf.setWindowBottomOffset( uiCode ); |
---|
818 | #else |
---|
819 | READ_UVLC( uiCode, "conf_win_left_offset" ); conf.setWindowLeftOffset ( uiCode * TComSPS::getWinUnitX( pcSPS->getChromaFormatIdc() ) ); |
---|
820 | READ_UVLC( uiCode, "conf_win_right_offset" ); conf.setWindowRightOffset ( uiCode * TComSPS::getWinUnitX( pcSPS->getChromaFormatIdc() ) ); |
---|
821 | READ_UVLC( uiCode, "conf_win_top_offset" ); conf.setWindowTopOffset ( uiCode * TComSPS::getWinUnitY( pcSPS->getChromaFormatIdc() ) ); |
---|
822 | READ_UVLC( uiCode, "conf_win_bottom_offset" ); conf.setWindowBottomOffset( uiCode * TComSPS::getWinUnitY( pcSPS->getChromaFormatIdc() ) ); |
---|
823 | #endif |
---|
824 | } |
---|
825 | |
---|
826 | #if H_MV |
---|
827 | if ( pcSPS->getLayerId() == 0 ) |
---|
828 | { |
---|
829 | #endif |
---|
830 | READ_UVLC( uiCode, "bit_depth_luma_minus8" ); |
---|
831 | assert(uiCode <= 6); |
---|
832 | pcSPS->setBitDepthY( uiCode + 8 ); |
---|
833 | pcSPS->setQpBDOffsetY( (Int) (6*uiCode) ); |
---|
834 | |
---|
835 | READ_UVLC( uiCode, "bit_depth_chroma_minus8" ); |
---|
836 | assert(uiCode <= 6); |
---|
837 | pcSPS->setBitDepthC( uiCode + 8 ); |
---|
838 | pcSPS->setQpBDOffsetC( (Int) (6*uiCode) ); |
---|
839 | #if H_MV |
---|
840 | } |
---|
841 | #endif |
---|
842 | |
---|
843 | READ_UVLC( uiCode, "log2_max_pic_order_cnt_lsb_minus4" ); pcSPS->setBitsForPOC( 4 + uiCode ); |
---|
844 | assert(uiCode <= 12); |
---|
845 | |
---|
846 | #if H_MV |
---|
847 | if ( pcSPS->getLayerId() == 0 ) |
---|
848 | { |
---|
849 | #endif |
---|
850 | UInt subLayerOrderingInfoPresentFlag; |
---|
851 | READ_FLAG(subLayerOrderingInfoPresentFlag, "sps_sub_layer_ordering_info_present_flag"); |
---|
852 | |
---|
853 | for(UInt i=0; i <= pcSPS->getMaxTLayers()-1; i++) |
---|
854 | { |
---|
855 | READ_UVLC ( uiCode, "sps_max_dec_pic_buffering_minus1[i]"); |
---|
856 | pcSPS->setMaxDecPicBuffering( uiCode + 1, i); |
---|
857 | READ_UVLC ( uiCode, "sps_num_reorder_pics[i]" ); |
---|
858 | pcSPS->setNumReorderPics(uiCode, i); |
---|
859 | READ_UVLC ( uiCode, "sps_max_latency_increase_plus1[i]"); |
---|
860 | pcSPS->setMaxLatencyIncrease( uiCode, i ); |
---|
861 | |
---|
862 | if (!subLayerOrderingInfoPresentFlag) |
---|
863 | { |
---|
864 | for (i++; i <= pcSPS->getMaxTLayers()-1; i++) |
---|
865 | { |
---|
866 | pcSPS->setMaxDecPicBuffering(pcSPS->getMaxDecPicBuffering(0), i); |
---|
867 | pcSPS->setNumReorderPics(pcSPS->getNumReorderPics(0), i); |
---|
868 | pcSPS->setMaxLatencyIncrease(pcSPS->getMaxLatencyIncrease(0), i); |
---|
869 | } |
---|
870 | break; |
---|
871 | } |
---|
872 | } |
---|
873 | #if H_MV |
---|
874 | } |
---|
875 | #endif |
---|
876 | |
---|
877 | READ_UVLC( uiCode, "log2_min_coding_block_size_minus3" ); |
---|
878 | Int log2MinCUSize = uiCode + 3; |
---|
879 | pcSPS->setLog2MinCodingBlockSize(log2MinCUSize); |
---|
880 | READ_UVLC( uiCode, "log2_diff_max_min_coding_block_size" ); |
---|
881 | pcSPS->setLog2DiffMaxMinCodingBlockSize(uiCode); |
---|
882 | |
---|
883 | if (pcSPS->getPTL()->getGeneralPTL()->getLevelIdc() >= Level::LEVEL5) |
---|
884 | { |
---|
885 | assert(log2MinCUSize + pcSPS->getLog2DiffMaxMinCodingBlockSize() >= 5); |
---|
886 | } |
---|
887 | |
---|
888 | Int maxCUDepthDelta = uiCode; |
---|
889 | pcSPS->setMaxCUWidth ( 1<<(log2MinCUSize + maxCUDepthDelta) ); |
---|
890 | pcSPS->setMaxCUHeight ( 1<<(log2MinCUSize + maxCUDepthDelta) ); |
---|
891 | READ_UVLC( uiCode, "log2_min_transform_block_size_minus2" ); pcSPS->setQuadtreeTULog2MinSize( uiCode + 2 ); |
---|
892 | |
---|
893 | READ_UVLC( uiCode, "log2_diff_max_min_transform_block_size" ); pcSPS->setQuadtreeTULog2MaxSize( uiCode + pcSPS->getQuadtreeTULog2MinSize() ); |
---|
894 | pcSPS->setMaxTrSize( 1<<(uiCode + pcSPS->getQuadtreeTULog2MinSize()) ); |
---|
895 | |
---|
896 | READ_UVLC( uiCode, "max_transform_hierarchy_depth_inter" ); pcSPS->setQuadtreeTUMaxDepthInter( uiCode+1 ); |
---|
897 | READ_UVLC( uiCode, "max_transform_hierarchy_depth_intra" ); pcSPS->setQuadtreeTUMaxDepthIntra( uiCode+1 ); |
---|
898 | |
---|
899 | Int addCuDepth = max (0, log2MinCUSize - (Int)pcSPS->getQuadtreeTULog2MinSize() ); |
---|
900 | pcSPS->setMaxCUDepth( maxCUDepthDelta + addCuDepth ); |
---|
901 | |
---|
902 | READ_FLAG( uiCode, "scaling_list_enabled_flag" ); pcSPS->setScalingListFlag ( uiCode ); |
---|
903 | if(pcSPS->getScalingListFlag()) |
---|
904 | { |
---|
905 | #if H_MV |
---|
906 | if ( pcSPS->getLayerId() > 0 ) |
---|
907 | { |
---|
908 | READ_FLAG( uiCode, "sps_infer_scaling_list_flag" ); pcSPS->setSpsInferScalingListFlag( uiCode == 1 ); |
---|
909 | } |
---|
910 | |
---|
911 | if ( pcSPS->getSpsInferScalingListFlag() ) |
---|
912 | { |
---|
913 | READ_CODE( 6, uiCode, "sps_scaling_list_ref_layer_id" ); pcSPS->setSpsScalingListRefLayerId( uiCode ); |
---|
914 | } |
---|
915 | else |
---|
916 | { |
---|
917 | #endif |
---|
918 | READ_FLAG( uiCode, "sps_scaling_list_data_present_flag" ); pcSPS->setScalingListPresentFlag ( uiCode ); |
---|
919 | if(pcSPS->getScalingListPresentFlag ()) |
---|
920 | { |
---|
921 | parseScalingList( pcSPS->getScalingList() ); |
---|
922 | } |
---|
923 | #if H_MV |
---|
924 | } |
---|
925 | #endif |
---|
926 | } |
---|
927 | READ_FLAG( uiCode, "amp_enabled_flag" ); pcSPS->setUseAMP( uiCode ); |
---|
928 | READ_FLAG( uiCode, "sample_adaptive_offset_enabled_flag" ); pcSPS->setUseSAO ( uiCode ? true : false ); |
---|
929 | |
---|
930 | READ_FLAG( uiCode, "pcm_enabled_flag" ); pcSPS->setUsePCM( uiCode ? true : false ); |
---|
931 | if( pcSPS->getUsePCM() ) |
---|
932 | { |
---|
933 | READ_CODE( 4, uiCode, "pcm_sample_bit_depth_luma_minus1" ); pcSPS->setPCMBitDepthLuma ( 1 + uiCode ); |
---|
934 | READ_CODE( 4, uiCode, "pcm_sample_bit_depth_chroma_minus1" ); pcSPS->setPCMBitDepthChroma ( 1 + uiCode ); |
---|
935 | READ_UVLC( uiCode, "log2_min_pcm_luma_coding_block_size_minus3" ); pcSPS->setPCMLog2MinSize (uiCode+3); |
---|
936 | READ_UVLC( uiCode, "log2_diff_max_min_pcm_luma_coding_block_size" ); pcSPS->setPCMLog2MaxSize ( uiCode+pcSPS->getPCMLog2MinSize() ); |
---|
937 | READ_FLAG( uiCode, "pcm_loop_filter_disable_flag" ); pcSPS->setPCMFilterDisableFlag ( uiCode ? true : false ); |
---|
938 | } |
---|
939 | |
---|
940 | READ_UVLC( uiCode, "num_short_term_ref_pic_sets" ); |
---|
941 | assert(uiCode <= 64); |
---|
942 | pcSPS->createRPSList(uiCode); |
---|
943 | |
---|
944 | TComRPSList* rpsList = pcSPS->getRPSList(); |
---|
945 | TComReferencePictureSet* rps; |
---|
946 | |
---|
947 | for(UInt i=0; i< rpsList->getNumberOfReferencePictureSets(); i++) |
---|
948 | { |
---|
949 | rps = rpsList->getReferencePictureSet(i); |
---|
950 | parseShortTermRefPicSet(pcSPS,rps,i); |
---|
951 | } |
---|
952 | READ_FLAG( uiCode, "long_term_ref_pics_present_flag" ); pcSPS->setLongTermRefsPresent(uiCode); |
---|
953 | if (pcSPS->getLongTermRefsPresent()) |
---|
954 | { |
---|
955 | READ_UVLC( uiCode, "num_long_term_ref_pic_sps" ); |
---|
956 | pcSPS->setNumLongTermRefPicSPS(uiCode); |
---|
957 | for (UInt k = 0; k < pcSPS->getNumLongTermRefPicSPS(); k++) |
---|
958 | { |
---|
959 | READ_CODE( pcSPS->getBitsForPOC(), uiCode, "lt_ref_pic_poc_lsb_sps" ); |
---|
960 | pcSPS->setLtRefPicPocLsbSps(k, uiCode); |
---|
961 | READ_FLAG( uiCode, "used_by_curr_pic_lt_sps_flag[i]"); |
---|
962 | pcSPS->setUsedByCurrPicLtSPSFlag(k, uiCode?1:0); |
---|
963 | } |
---|
964 | } |
---|
965 | READ_FLAG( uiCode, "sps_temporal_mvp_enable_flag" ); pcSPS->setTMVPFlagsPresent(uiCode); |
---|
966 | |
---|
967 | READ_FLAG( uiCode, "sps_strong_intra_smoothing_enable_flag" ); pcSPS->setUseStrongIntraSmoothing(uiCode); |
---|
968 | |
---|
969 | READ_FLAG( uiCode, "vui_parameters_present_flag" ); pcSPS->setVuiParametersPresentFlag(uiCode); |
---|
970 | |
---|
971 | if (pcSPS->getVuiParametersPresentFlag()) |
---|
972 | { |
---|
973 | parseVUI(pcSPS->getVuiParameters(), pcSPS); |
---|
974 | } |
---|
975 | |
---|
976 | |
---|
977 | #if H_MV |
---|
978 | READ_FLAG( uiCode, "sps_extension_present_flag"); |
---|
979 | pcSPS->setSpsExtensionPresentFlag( uiCode ); |
---|
980 | if (pcSPS->getSpsExtensionPresentFlag( ) ) |
---|
981 | #else |
---|
982 | READ_FLAG( uiCode, "sps_extension_flag"); |
---|
983 | if (uiCode) |
---|
984 | #endif |
---|
985 | { |
---|
986 | #if H_MV |
---|
987 | READ_FLAG( uiCode, "sps_range_extensions_flag" ); pcSPS->setSpsRangeExtensionsFlag( uiCode == 1 ); |
---|
988 | READ_FLAG( uiCode, "sps_multilayer_extension_flag" ); pcSPS->setSpsMultilayerExtensionFlag( uiCode == 1 ); |
---|
989 | #if !H_3D |
---|
990 | READ_CODE( 6, uiCode, "sps_extension_6bits" ); pcSPS->setSpsExtension6bits( uiCode ); |
---|
991 | #else |
---|
992 | READ_FLAG( uiCode, "sps_3d_extension_flag" ); pcSPS->setSps3dExtensionFlag( uiCode == 1 ); |
---|
993 | READ_CODE( 5, uiCode, "sps_extension_5bits" ); pcSPS->setSpsExtension5bits( uiCode ); |
---|
994 | #endif |
---|
995 | } |
---|
996 | |
---|
997 | if ( pcSPS->getSpsRangeExtensionsFlag() ) |
---|
998 | { |
---|
999 | assert( 0 ); |
---|
1000 | } |
---|
1001 | |
---|
1002 | if ( pcSPS->getSpsMultilayerExtensionFlag() ) |
---|
1003 | { |
---|
1004 | parseSPSExtension( pcSPS ); |
---|
1005 | } |
---|
1006 | |
---|
1007 | #if H_3D |
---|
1008 | if ( pcSPS->getSps3dExtensionFlag() ) |
---|
1009 | { |
---|
1010 | parseSPSExtension2( pcSPS, viewIndex, depthFlag ); |
---|
1011 | } |
---|
1012 | |
---|
1013 | if ( pcSPS->getSpsExtension5bits() ) |
---|
1014 | { |
---|
1015 | #else |
---|
1016 | if ( pcSPS->getSpsExtension6bits() ) |
---|
1017 | { |
---|
1018 | #endif |
---|
1019 | |
---|
1020 | #endif |
---|
1021 | while ( xMoreRbspData() ) |
---|
1022 | { |
---|
1023 | READ_FLAG( uiCode, "sps_extension_data_flag"); |
---|
1024 | } |
---|
1025 | } |
---|
1026 | } |
---|
1027 | |
---|
1028 | #if H_MV |
---|
1029 | Void TDecCavlc::parseSPSExtension( TComSPS* pcSPS ) |
---|
1030 | { |
---|
1031 | UInt uiCode; |
---|
1032 | READ_FLAG( uiCode, "inter_view_mv_vert_constraint_flag" ); pcSPS->setInterViewMvVertConstraintFlag(uiCode == 1 ? true : false); |
---|
1033 | |
---|
1034 | READ_UVLC( uiCode, "num_scaled_ref_layer_offsets" ); pcSPS->setNumScaledRefLayerOffsets( uiCode ); |
---|
1035 | |
---|
1036 | for( Int i = 0; i < pcSPS->getNumScaledRefLayerOffsets( ); i++) |
---|
1037 | { |
---|
1038 | READ_CODE( 6, uiCode, "scaled_ref_layer_id" ); pcSPS->setScaledRefLayerId( i, uiCode ); |
---|
1039 | |
---|
1040 | Int j = pcSPS->getScaledRefLayerId( i ); |
---|
1041 | Int iCode; |
---|
1042 | READ_SVLC( iCode, "scaled_ref_layer_left_offset" ); pcSPS->setScaledRefLayerLeftOffset( j, iCode ); |
---|
1043 | READ_SVLC( iCode, "scaled_ref_layer_top_offset" ); pcSPS->setScaledRefLayerTopOffset( j, iCode ); |
---|
1044 | READ_SVLC( iCode, "scaled_ref_layer_right_offset" ); pcSPS->setScaledRefLayerRightOffset( j, iCode ); |
---|
1045 | READ_SVLC( iCode, "scaled_ref_layer_bottom_offset" ); pcSPS->setScaledRefLayerBottomOffset( j, iCode ); |
---|
1046 | READ_FLAG( uiCode, "sps_multilayer_ext_reserved_zero_flag[ i ]" ); |
---|
1047 | } |
---|
1048 | } |
---|
1049 | |
---|
1050 | #if H_3D |
---|
1051 | Void TDecCavlc::parseSPSExtension2( TComSPS* pcSPS, Int viewIndex, Bool depthFlag ) |
---|
1052 | { |
---|
1053 | UInt uiCode; |
---|
1054 | #if H_3D_QTLPC |
---|
1055 | //GT: This has to go to VPS |
---|
1056 | if( depthFlag ) |
---|
1057 | { |
---|
1058 | READ_FLAG( uiCode, "use_qtl_flag" ); |
---|
1059 | pcSPS->setUseQTL( uiCode ); |
---|
1060 | READ_FLAG( uiCode, "use_pc_flag" ); |
---|
1061 | pcSPS->setUsePC( uiCode ); |
---|
1062 | } |
---|
1063 | #endif |
---|
1064 | } |
---|
1065 | #endif |
---|
1066 | #endif |
---|
1067 | |
---|
1068 | Void TDecCavlc::parseVPS(TComVPS* pcVPS) |
---|
1069 | { |
---|
1070 | UInt uiCode; |
---|
1071 | |
---|
1072 | READ_CODE( 4, uiCode, "vps_video_parameter_set_id" ); pcVPS->setVPSId( uiCode ); |
---|
1073 | #if H_MV |
---|
1074 | READ_FLAG( uiCode, "vps_base_layer_internal_flag" ); pcVPS->setVpsBaseLayerInternalFlag( uiCode == 1 ); |
---|
1075 | READ_FLAG( uiCode, "vps_reserved_one_bit" ); assert( uiCode == 1 ); |
---|
1076 | #else |
---|
1077 | READ_CODE( 2, uiCode, "vps_reserved_three_2bits" ); assert(uiCode == 3); |
---|
1078 | #endif |
---|
1079 | #if H_MV |
---|
1080 | READ_CODE( 6, uiCode, "vps_max_layers_minus1" ); pcVPS->setMaxLayersMinus1( std::min( uiCode, (UInt) ( MAX_NUM_LAYER_IDS-1) ) ); |
---|
1081 | #else |
---|
1082 | READ_CODE( 6, uiCode, "vps_reserved_zero_6bits" ); assert(uiCode == 0); |
---|
1083 | #endif |
---|
1084 | READ_CODE( 3, uiCode, "vps_max_sub_layers_minus1" ); pcVPS->setMaxTLayers( uiCode + 1 ); assert(uiCode+1 <= MAX_TLAYER); |
---|
1085 | READ_FLAG( uiCode, "vps_temporal_id_nesting_flag" ); pcVPS->setTemporalNestingFlag( uiCode ? true:false ); |
---|
1086 | assert (pcVPS->getMaxTLayers()>1||pcVPS->getTemporalNestingFlag()); |
---|
1087 | |
---|
1088 | READ_CODE( 16, uiCode, "vps_reserved_ffff_16bits" ); assert(uiCode == 0xffff); |
---|
1089 | parsePTL ( pcVPS->getPTL(), true, pcVPS->getMaxTLayers()-1); |
---|
1090 | UInt subLayerOrderingInfoPresentFlag; |
---|
1091 | READ_FLAG(subLayerOrderingInfoPresentFlag, "vps_sub_layer_ordering_info_present_flag"); |
---|
1092 | for(UInt i = 0; i <= pcVPS->getMaxTLayers()-1; i++) |
---|
1093 | { |
---|
1094 | READ_UVLC( uiCode, "vps_max_dec_pic_buffering_minus1[i]" ); pcVPS->setMaxDecPicBuffering( uiCode + 1, i ); |
---|
1095 | READ_UVLC( uiCode, "vps_num_reorder_pics[i]" ); pcVPS->setNumReorderPics( uiCode, i ); |
---|
1096 | READ_UVLC( uiCode, "vps_max_latency_increase_plus1[i]" ); pcVPS->setMaxLatencyIncrease( uiCode, i ); |
---|
1097 | |
---|
1098 | if (!subLayerOrderingInfoPresentFlag) |
---|
1099 | { |
---|
1100 | for (i++; i <= pcVPS->getMaxTLayers()-1; i++) |
---|
1101 | { |
---|
1102 | pcVPS->setMaxDecPicBuffering(pcVPS->getMaxDecPicBuffering(0), i); |
---|
1103 | pcVPS->setNumReorderPics(pcVPS->getNumReorderPics(0), i); |
---|
1104 | pcVPS->setMaxLatencyIncrease(pcVPS->getMaxLatencyIncrease(0), i); |
---|
1105 | } |
---|
1106 | break; |
---|
1107 | } |
---|
1108 | } |
---|
1109 | |
---|
1110 | assert( pcVPS->getNumHrdParameters() < MAX_VPS_OP_SETS_PLUS1 ); |
---|
1111 | #if H_MV |
---|
1112 | assert( pcVPS->getVpsMaxLayerId() < MAX_VPS_NUH_LAYER_ID_PLUS1 ); |
---|
1113 | READ_CODE( 6, uiCode, "vps_max_layer_id" ); pcVPS->setVpsMaxLayerId( uiCode ); |
---|
1114 | |
---|
1115 | READ_UVLC( uiCode, "vps_max_num_layer_sets_minus1" ); pcVPS->setVpsNumLayerSetsMinus1( uiCode ); |
---|
1116 | for( UInt opsIdx = 1; opsIdx <= pcVPS->getVpsNumLayerSetsMinus1(); opsIdx ++ ) |
---|
1117 | { |
---|
1118 | for( UInt i = 0; i <= pcVPS->getVpsMaxLayerId(); i ++ ) |
---|
1119 | #else |
---|
1120 | assert( pcVPS->getMaxNuhReservedZeroLayerId() < MAX_VPS_NUH_RESERVED_ZERO_LAYER_ID_PLUS1 ); |
---|
1121 | READ_CODE( 6, uiCode, "vps_max_nuh_reserved_zero_layer_id" ); pcVPS->setMaxNuhReservedZeroLayerId( uiCode ); |
---|
1122 | READ_UVLC( uiCode, "vps_max_op_sets_minus1" ); pcVPS->setMaxOpSets( uiCode + 1 ); |
---|
1123 | for( UInt opsIdx = 1; opsIdx <= ( pcVPS->getMaxOpSets() - 1 ); opsIdx ++ ) |
---|
1124 | { |
---|
1125 | // Operation point set |
---|
1126 | for( UInt i = 0; i <= pcVPS->getMaxNuhReservedZeroLayerId(); i ++ ) |
---|
1127 | #endif |
---|
1128 | { |
---|
1129 | READ_FLAG( uiCode, "layer_id_included_flag[opsIdx][i]" ); pcVPS->setLayerIdIncludedFlag( uiCode == 1 ? true : false, opsIdx, i ); |
---|
1130 | } |
---|
1131 | } |
---|
1132 | #if H_MV |
---|
1133 | pcVPS->deriveLayerSetLayerIdList(); |
---|
1134 | #endif |
---|
1135 | TimingInfo *timingInfo = pcVPS->getTimingInfo(); |
---|
1136 | READ_FLAG( uiCode, "vps_timing_info_present_flag"); timingInfo->setTimingInfoPresentFlag (uiCode ? true : false); |
---|
1137 | if(timingInfo->getTimingInfoPresentFlag()) |
---|
1138 | { |
---|
1139 | READ_CODE( 32, uiCode, "vps_num_units_in_tick"); timingInfo->setNumUnitsInTick (uiCode); |
---|
1140 | READ_CODE( 32, uiCode, "vps_time_scale"); timingInfo->setTimeScale (uiCode); |
---|
1141 | READ_FLAG( uiCode, "vps_poc_proportional_to_timing_flag"); timingInfo->setPocProportionalToTimingFlag(uiCode ? true : false); |
---|
1142 | if(timingInfo->getPocProportionalToTimingFlag()) |
---|
1143 | { |
---|
1144 | READ_UVLC( uiCode, "vps_num_ticks_poc_diff_one_minus1"); timingInfo->setNumTicksPocDiffOneMinus1 (uiCode); |
---|
1145 | } |
---|
1146 | READ_UVLC( uiCode, "vps_num_hrd_parameters" ); pcVPS->setNumHrdParameters( uiCode ); |
---|
1147 | |
---|
1148 | if( pcVPS->getNumHrdParameters() > 0 ) |
---|
1149 | { |
---|
1150 | pcVPS->createHrdParamBuffer(); |
---|
1151 | } |
---|
1152 | for( UInt i = 0; i < pcVPS->getNumHrdParameters(); i ++ ) |
---|
1153 | { |
---|
1154 | READ_UVLC( uiCode, "hrd_op_set_idx" ); pcVPS->setHrdOpSetIdx( uiCode, i ); |
---|
1155 | if( i > 0 ) |
---|
1156 | { |
---|
1157 | READ_FLAG( uiCode, "cprms_present_flag[i]" ); pcVPS->setCprmsPresentFlag( uiCode == 1 ? true : false, i ); |
---|
1158 | } |
---|
1159 | parseHrdParameters(pcVPS->getHrdParameters(i), pcVPS->getCprmsPresentFlag( i ), pcVPS->getMaxTLayers() - 1); |
---|
1160 | } |
---|
1161 | } |
---|
1162 | #if H_MV |
---|
1163 | READ_FLAG( uiCode, "vps_extension_flag" ); pcVPS->setVpsExtensionFlag( uiCode == 1 ? true : false ); |
---|
1164 | if ( pcVPS->getVpsExtensionFlag() ) |
---|
1165 | #else |
---|
1166 | READ_FLAG( uiCode, "vps_extension_flag" ); |
---|
1167 | if (uiCode) |
---|
1168 | #endif |
---|
1169 | { |
---|
1170 | #if H_MV |
---|
1171 | m_pcBitstream->readOutTrailingBits(); |
---|
1172 | parseVPSExtension( pcVPS ); |
---|
1173 | READ_FLAG( uiCode, "vps_extension2_flag" ); |
---|
1174 | if (uiCode) |
---|
1175 | { |
---|
1176 | #if H_3D |
---|
1177 | m_pcBitstream->readOutTrailingBits(); |
---|
1178 | pcVPS->createCamPars(pcVPS->getNumViews()); |
---|
1179 | parseVPSExtension2( pcVPS ); |
---|
1180 | READ_FLAG( uiCode, "vps_extension3_flag" ); |
---|
1181 | if (uiCode) |
---|
1182 | { |
---|
1183 | #endif |
---|
1184 | #endif |
---|
1185 | while ( xMoreRbspData() ) |
---|
1186 | { |
---|
1187 | READ_FLAG( uiCode, "vps_extension_data_flag"); |
---|
1188 | } |
---|
1189 | #if H_MV |
---|
1190 | #if H_3D |
---|
1191 | } |
---|
1192 | #endif |
---|
1193 | } |
---|
1194 | #endif |
---|
1195 | } |
---|
1196 | return; |
---|
1197 | } |
---|
1198 | |
---|
1199 | #if H_MV |
---|
1200 | Void TDecCavlc::parseVPSExtension( TComVPS* pcVPS ) |
---|
1201 | { |
---|
1202 | UInt uiCode; |
---|
1203 | |
---|
1204 | READ_FLAG( uiCode, "splitting_flag" ); pcVPS->setSplittingFlag( uiCode == 1 ? true : false ); |
---|
1205 | |
---|
1206 | for( Int sIdx = 0; sIdx < MAX_NUM_SCALABILITY_TYPES; sIdx++ ) |
---|
1207 | { |
---|
1208 | READ_FLAG( uiCode, "scalability_mask_flag[i]" ); pcVPS->setScalabilityMaskFlag( sIdx, uiCode == 1 ? true : false ); |
---|
1209 | } |
---|
1210 | |
---|
1211 | for( Int sIdx = 0; sIdx < pcVPS->getNumScalabilityTypes( ) - ( pcVPS->getSplittingFlag() ? 1 : 0 ); sIdx++ ) |
---|
1212 | { |
---|
1213 | READ_CODE( 3, uiCode, "dimension_id_len_minus1[j]" ); pcVPS->setDimensionIdLen( sIdx, uiCode + 1 ); |
---|
1214 | } |
---|
1215 | |
---|
1216 | if ( pcVPS->getSplittingFlag() ) |
---|
1217 | { |
---|
1218 | pcVPS->setDimensionIdLen( pcVPS->getNumScalabilityTypes( ) - 1, pcVPS->inferLastDimsionIdLenMinus1() ); |
---|
1219 | } |
---|
1220 | |
---|
1221 | READ_FLAG( uiCode, "vps_nuh_layer_id_present_flag" ); pcVPS->setVpsNuhLayerIdPresentFlag( uiCode == 1 ? true : false ); |
---|
1222 | |
---|
1223 | for( Int i = 1; i <= pcVPS->getMaxLayersMinus1(); i++ ) |
---|
1224 | { |
---|
1225 | if ( pcVPS->getVpsNuhLayerIdPresentFlag() ) |
---|
1226 | { |
---|
1227 | READ_CODE( 6, uiCode, "layer_id_in_nuh[i]" ); pcVPS->setLayerIdInNuh( i, uiCode ); |
---|
1228 | } |
---|
1229 | else |
---|
1230 | { |
---|
1231 | pcVPS->setLayerIdInNuh( i, i );; |
---|
1232 | } |
---|
1233 | |
---|
1234 | pcVPS->setLayerIdInVps( pcVPS->getLayerIdInNuh( i ), i ); |
---|
1235 | |
---|
1236 | for( Int j = 0; j < pcVPS->getNumScalabilityTypes() ; j++ ) |
---|
1237 | { |
---|
1238 | if ( !pcVPS->getSplittingFlag() ) |
---|
1239 | { |
---|
1240 | READ_CODE( pcVPS->getDimensionIdLen( j ), uiCode, "dimension_id[i][j]" ); pcVPS->setDimensionId( i, j, uiCode ); |
---|
1241 | } |
---|
1242 | else |
---|
1243 | { |
---|
1244 | pcVPS->setDimensionId( i, j, pcVPS->inferDimensionId( i, j) ); |
---|
1245 | } |
---|
1246 | } |
---|
1247 | } |
---|
1248 | |
---|
1249 | READ_CODE( 4, uiCode, "view_id_len" ); pcVPS->setViewIdLen( uiCode ); |
---|
1250 | |
---|
1251 | if ( pcVPS->getViewIdLen( ) > 0 ) |
---|
1252 | { |
---|
1253 | for( Int i = 0; i < pcVPS->getNumViews(); i++ ) |
---|
1254 | { |
---|
1255 | READ_CODE( pcVPS->getViewIdLen( ), uiCode, "view_id_val[i]" ); pcVPS->setViewIdVal( i, uiCode ); |
---|
1256 | } |
---|
1257 | } |
---|
1258 | else |
---|
1259 | { |
---|
1260 | for( Int i = 0; i < pcVPS->getNumViews(); i++ ) |
---|
1261 | { |
---|
1262 | pcVPS->setViewIdVal( i, 0 ); |
---|
1263 | } |
---|
1264 | } |
---|
1265 | |
---|
1266 | |
---|
1267 | for( Int i = 1; i <= pcVPS->getMaxLayersMinus1(); i++ ) |
---|
1268 | { |
---|
1269 | for( Int j = 0; j < i; j++ ) |
---|
1270 | { |
---|
1271 | READ_FLAG( uiCode, "direct_dependency_flag[i][j]" ); pcVPS->setDirectDependencyFlag( i, j, uiCode ); |
---|
1272 | } |
---|
1273 | } |
---|
1274 | pcVPS->setRefLayers(); |
---|
1275 | READ_FLAG( uiCode, "vps_sub_layers_max_minus1_present_flag" ); pcVPS->setVpsSubLayersMaxMinus1PresentFlag( uiCode == 1 ); |
---|
1276 | if ( pcVPS->getVpsSubLayersMaxMinus1PresentFlag() ) |
---|
1277 | { |
---|
1278 | for (Int i = 0; i <= pcVPS->getMaxLayersMinus1(); i++ ) |
---|
1279 | { |
---|
1280 | READ_CODE( 3, uiCode, "sub_layers_vps_max_minus1" ); pcVPS->setSubLayersVpsMaxMinus1( i, uiCode ); |
---|
1281 | pcVPS->checkSubLayersVpsMaxMinus1( i ); |
---|
1282 | } |
---|
1283 | } |
---|
1284 | else |
---|
1285 | { |
---|
1286 | for (Int i = 0; i <= pcVPS->getMaxLayersMinus1(); i++ ) |
---|
1287 | { |
---|
1288 | pcVPS->setSubLayersVpsMaxMinus1( i, pcVPS->getMaxTLayers( ) - 1); |
---|
1289 | } |
---|
1290 | } |
---|
1291 | READ_FLAG( uiCode, "max_tid_ref_present_flag" ); pcVPS->setMaxTidRefPresentFlag( uiCode == 1 ); |
---|
1292 | |
---|
1293 | if ( pcVPS->getMaxTidRefPresentFlag() ) |
---|
1294 | { |
---|
1295 | for( Int i = 0; i < pcVPS->getMaxLayersMinus1(); i++ ) |
---|
1296 | { |
---|
1297 | for( Int j = i + 1; j <= pcVPS->getMaxLayersMinus1(); j++ ) |
---|
1298 | { |
---|
1299 | if ( pcVPS->getDirectDependencyFlag(j,i) ) |
---|
1300 | { |
---|
1301 | READ_CODE( 3, uiCode, "max_tid_il_ref_pics_plus1" ); pcVPS->setMaxTidIlRefPicsPlus1( i, j, uiCode ); |
---|
1302 | } |
---|
1303 | } |
---|
1304 | } |
---|
1305 | } |
---|
1306 | |
---|
1307 | READ_FLAG( uiCode, "all_ref_layers_active_flag" ); pcVPS->setAllRefLayersActiveFlag( uiCode == 1 ); |
---|
1308 | READ_UVLC( uiCode, "vps_num_profile_tier_level_minus1" ); pcVPS->setVpsNumProfileTierLevelMinus1( uiCode ); |
---|
1309 | |
---|
1310 | for( Int i = 1; i <= pcVPS->getVpsNumProfileTierLevelMinus1(); i++ ) |
---|
1311 | { |
---|
1312 | READ_FLAG( uiCode, "vps_profile_present_flag[i]" ); pcVPS->setVpsProfilePresentFlag( i, uiCode == 1 ); |
---|
1313 | parsePTL ( pcVPS->getPTL( i ), pcVPS->getVpsProfilePresentFlag( i ), pcVPS->getMaxTLayers()-1); |
---|
1314 | if( !pcVPS->getVpsProfilePresentFlag( i ) ) |
---|
1315 | { |
---|
1316 | TComPTL temp = *pcVPS->getPTL( i ); |
---|
1317 | *pcVPS->getPTL( i ) = *pcVPS->getPTL( i - 1 ); |
---|
1318 | pcVPS->getPTL( i )->copyLevelFrom( &temp ); |
---|
1319 | } |
---|
1320 | } |
---|
1321 | |
---|
1322 | if ( pcVPS->getNumIndependentLayers() > 1 ) |
---|
1323 | { |
---|
1324 | READ_UVLC( uiCode, "num_add_layer_sets" ); pcVPS->setNumAddLayerSets( uiCode ); |
---|
1325 | } |
---|
1326 | for (Int i = 0; i < pcVPS->getNumAddLayerSets(); i++) |
---|
1327 | { |
---|
1328 | for (Int j = 0; j < pcVPS->getNumIndependentLayers(); j++) |
---|
1329 | { |
---|
1330 | READ_CODE( pcVPS->getHighestLayerIdxPlus1Len( j ) , uiCode, "highest_layer_idx_plus1" ); pcVPS->setHighestLayerIdxPlus1( i, j, uiCode ); |
---|
1331 | } |
---|
1332 | } |
---|
1333 | if (pcVPS->getNumLayerSets() > 1) |
---|
1334 | { |
---|
1335 | READ_UVLC( uiCode, "num_add_olss" ); pcVPS->setNumAddOlss( uiCode ); |
---|
1336 | READ_CODE( 2, uiCode, "default_output_layer_idc" ); pcVPS->setDefaultOutputLayerIdc( std::min( uiCode, (UInt) 2 ) ); |
---|
1337 | } |
---|
1338 | |
---|
1339 | pcVPS->initTargetLayerIdLists( ); |
---|
1340 | |
---|
1341 | |
---|
1342 | pcVPS->setOutputLayerFlag(0, 0, pcVPS->inferOutputLayerFlag( 0, 0 )); |
---|
1343 | pcVPS->setLayerSetIdxForOlsMinus1(0, -1); |
---|
1344 | |
---|
1345 | pcVPS->deriveTargetLayerIdList( 0 ); |
---|
1346 | |
---|
1347 | for( Int i = 1; i < pcVPS->getNumOutputLayerSets( ); i++ ) |
---|
1348 | { |
---|
1349 | if( i >= pcVPS->getNumLayerSets( ) ) |
---|
1350 | { |
---|
1351 | READ_UVLC( uiCode, "layer_set_idx_for_ols_minus1[i]" ); pcVPS->setLayerSetIdxForOlsMinus1( i, uiCode ); |
---|
1352 | } |
---|
1353 | |
---|
1354 | if ( i > pcVPS->getVpsNumLayerSetsMinus1() || pcVPS->getDefaultOutputLayerIdc() == 2 ) |
---|
1355 | { |
---|
1356 | for( Int j = 0; j < pcVPS->getNumLayersInIdList( pcVPS->olsIdxToLsIdx( i ) ); j++ ) |
---|
1357 | { |
---|
1358 | READ_FLAG( uiCode, "output_layer_flag" ); pcVPS->setOutputLayerFlag( i, j, uiCode == 1 ); |
---|
1359 | } |
---|
1360 | } |
---|
1361 | else |
---|
1362 | { |
---|
1363 | for( Int j = 0; j < pcVPS->getNumLayersInIdList( pcVPS->olsIdxToLsIdx( i ) ); j++ ) |
---|
1364 | { |
---|
1365 | pcVPS->setOutputLayerFlag(i,j, pcVPS->inferOutputLayerFlag( i, j )); |
---|
1366 | } |
---|
1367 | } |
---|
1368 | pcVPS->deriveTargetLayerIdList( i ); |
---|
1369 | |
---|
1370 | if ( pcVPS->getProfileLevelTierIdxLen() > 0 ) |
---|
1371 | { |
---|
1372 | READ_CODE( pcVPS->getProfileLevelTierIdxLen(), uiCode,"profile_level_tier_idx[ i ]" ); pcVPS->setProfileLevelTierIdx( i , uiCode ); |
---|
1373 | } |
---|
1374 | if( pcVPS->getNumOutputLayersInOutputLayerSet( i ) == 1 && pcVPS->getNumDirectRefLayers( pcVPS->getOlsHighestOutputLayerId( i ) ) > 0 ) |
---|
1375 | { |
---|
1376 | READ_FLAG( uiCode, "alt_output_layer_flag[ i ]" ); pcVPS->setAltOutputLayerFlag( i, uiCode == 1 ); |
---|
1377 | } |
---|
1378 | } |
---|
1379 | |
---|
1380 | READ_UVLC( uiCode, "vps_num_rep_formats_minus1" ); pcVPS->setVpsNumRepFormatsMinus1( uiCode ); |
---|
1381 | |
---|
1382 | for (Int i = 0; i <= pcVPS->getVpsNumRepFormatsMinus1(); i++ ) |
---|
1383 | { |
---|
1384 | assert( pcVPS->getRepFormat(i) == NULL ); |
---|
1385 | TComRepFormat* curRepFormat = new TComRepFormat(); |
---|
1386 | TComRepFormat* prevRepFormat = i > 0 ? pcVPS->getRepFormat( i - 1) : NULL; |
---|
1387 | parseRepFormat( i, curRepFormat , prevRepFormat); |
---|
1388 | pcVPS->setRepFormat(i, curRepFormat ); |
---|
1389 | } |
---|
1390 | |
---|
1391 | if ( pcVPS->getVpsNumRepFormatsMinus1() > 0 ) |
---|
1392 | { |
---|
1393 | READ_FLAG( uiCode, "rep_format_idx_present_flag" ); pcVPS->setRepFormatIdxPresentFlag( uiCode == 1 ); |
---|
1394 | } |
---|
1395 | if( pcVPS->getRepFormatIdxPresentFlag() ) |
---|
1396 | { |
---|
1397 | for( Int i = pcVPS->getVpsBaseLayerInternalFlag() ? 1 : 0; i <= pcVPS->getMaxLayersMinus1(); i++ ) |
---|
1398 | { |
---|
1399 | READ_CODE( pcVPS->getVpsRepFormatIdxLen(), uiCode, "vps_rep_format_idx[i]" ); pcVPS->setVpsRepFormatIdx( i, uiCode ); |
---|
1400 | } |
---|
1401 | } |
---|
1402 | else |
---|
1403 | { |
---|
1404 | for( Int i = pcVPS->getVpsBaseLayerInternalFlag() ? 1 : 0; i <= pcVPS->getMaxLayersMinus1(); i++ ) |
---|
1405 | { |
---|
1406 | pcVPS->setVpsRepFormatIdx( i, pcVPS->inferVpsRepFormatIdx( i ) ); |
---|
1407 | } |
---|
1408 | } |
---|
1409 | |
---|
1410 | READ_FLAG( uiCode, "max_one_active_ref_layer_flag" ); pcVPS->setMaxOneActiveRefLayerFlag ( uiCode == 1 ); |
---|
1411 | #if H_MV_HLS7_GEN |
---|
1412 | READ_FLAG( uiCode, "vps_poc_lsb_aligned_flag" ); pcVPS->setVpsPocLsbAlignedFlag( uiCode == 1 ); |
---|
1413 | #endif |
---|
1414 | for( Int i = 1; i <= pcVPS->getMaxLayersMinus1(); i++ ) |
---|
1415 | { |
---|
1416 | if( pcVPS->getNumDirectRefLayers( pcVPS->getLayerIdInNuh( i ) ) == 0 ) |
---|
1417 | { |
---|
1418 | READ_FLAG( uiCode, "poc_lsb_not_present_flag" ); pcVPS->setPocLsbNotPresentFlag( i, uiCode == 1 ); |
---|
1419 | } |
---|
1420 | } |
---|
1421 | |
---|
1422 | READ_FLAG( uiCode, "vps_reserved_zero_flag" ); |
---|
1423 | parseDpbSize( pcVPS ); |
---|
1424 | |
---|
1425 | READ_UVLC( uiCode, "direct_dep_type_len_minus2") ; pcVPS->setDirectDepTypeLenMinus2 ( uiCode ); |
---|
1426 | |
---|
1427 | READ_FLAG( uiCode, "default_direct_dependency_flag" ); pcVPS->setDefaultDirectDependencyFlag( uiCode == 1 ); |
---|
1428 | if ( pcVPS->getDefaultDirectDependencyFlag( ) ) |
---|
1429 | { |
---|
1430 | READ_CODE( pcVPS->getDirectDepTypeLenMinus2( ) + 2, uiCode, "default_direct_dependency_type" ); pcVPS->setDefaultDirectDependencyType( uiCode ); |
---|
1431 | } |
---|
1432 | |
---|
1433 | for( Int i = pcVPS->getVpsBaseLayerInternalFlag() ? 1 : 2; i <= pcVPS->getMaxLayersMinus1(); i++ ) |
---|
1434 | { |
---|
1435 | for( Int j = pcVPS->getVpsBaseLayerInternalFlag() ? 0 : 1; j < i; j++ ) |
---|
1436 | { |
---|
1437 | if (pcVPS->getDirectDependencyFlag( i, j) ) |
---|
1438 | { |
---|
1439 | if ( pcVPS->getDefaultDirectDependencyFlag( ) ) |
---|
1440 | { |
---|
1441 | pcVPS->setDirectDependencyType( i, j , pcVPS->getDefaultDirectDependencyType( ) ); |
---|
1442 | } |
---|
1443 | else |
---|
1444 | { |
---|
1445 | |
---|
1446 | READ_CODE( pcVPS->getDirectDepTypeLenMinus2( ) + 2, uiCode, "direct_dependency_type[i][j]" ); pcVPS->setDirectDependencyType( i, j , uiCode); |
---|
1447 | } |
---|
1448 | } |
---|
1449 | } |
---|
1450 | } |
---|
1451 | READ_UVLC( uiCode, "vps_non_vui_extension_length" ); pcVPS->setVpsNonVuiExtensionLength( uiCode ); |
---|
1452 | for ( Int i = 1; i <= pcVPS->getVpsNonVuiExtensionLength(); i++ ) |
---|
1453 | { |
---|
1454 | READ_CODE( 8, uiCode, "vps_non_vui_extension_data_byte" ); |
---|
1455 | } |
---|
1456 | READ_FLAG( uiCode, "vps_vui_present_flag" ); pcVPS->setVpsVuiPresentFlag( uiCode == 1 ); |
---|
1457 | if( pcVPS->getVpsVuiPresentFlag() ) |
---|
1458 | { |
---|
1459 | m_pcBitstream->readOutTrailingBits(); // vps_vui_alignment_bit_equal_to_one |
---|
1460 | parseVPSVUI( pcVPS ); |
---|
1461 | } |
---|
1462 | { |
---|
1463 | TComVPSVUI* pcVPSVUI = pcVPS->getVPSVUI( ); |
---|
1464 | assert( pcVPSVUI ); |
---|
1465 | pcVPSVUI->inferVpsVui( false ); |
---|
1466 | } |
---|
1467 | pcVPS->checkVPSExtensionSyntax(); |
---|
1468 | } |
---|
1469 | |
---|
1470 | Void TDecCavlc::parseRepFormat( Int i, TComRepFormat* pcRepFormat, TComRepFormat* pcPrevRepFormat ) |
---|
1471 | { |
---|
1472 | assert( pcRepFormat ); |
---|
1473 | |
---|
1474 | UInt uiCode; |
---|
1475 | |
---|
1476 | READ_CODE( 16, uiCode, "pic_width_vps_in_luma_samples" ); pcRepFormat->setPicWidthVpsInLumaSamples ( uiCode ); |
---|
1477 | READ_CODE( 16, uiCode, "pic_height_vps_in_luma_samples" ); pcRepFormat->setPicHeightVpsInLumaSamples( uiCode ); |
---|
1478 | READ_FLAG( uiCode, "chroma_and_bit_depth_vps_present_flag" ); pcRepFormat->setChromaAndBitDepthVpsPresentFlag( uiCode == 1 ); |
---|
1479 | |
---|
1480 | pcRepFormat->checkChromaAndBitDepthVpsPresentFlag( i ); |
---|
1481 | |
---|
1482 | if ( pcRepFormat->getChromaAndBitDepthVpsPresentFlag() ) |
---|
1483 | { |
---|
1484 | READ_CODE( 2, uiCode, "chroma_format_vps_idc" ); pcRepFormat->setChromaFormatVpsIdc ( uiCode ); |
---|
1485 | if ( pcRepFormat->getChromaFormatVpsIdc() == 3 ) |
---|
1486 | { |
---|
1487 | READ_FLAG( uiCode, "separate_colour_plane_vps_flag" ); pcRepFormat->setSeparateColourPlaneVpsFlag( uiCode == 1 ); |
---|
1488 | } |
---|
1489 | READ_CODE( 4, uiCode, "bit_depth_vps_luma_minus8" ); pcRepFormat->setBitDepthVpsLumaMinus8 ( uiCode ); |
---|
1490 | READ_CODE( 4, uiCode, "bit_depth_vps_chroma_minus8" ); pcRepFormat->setBitDepthVpsChromaMinus8 ( uiCode ); |
---|
1491 | } |
---|
1492 | else |
---|
1493 | { |
---|
1494 | pcRepFormat->inferChromaAndBitDepth(pcPrevRepFormat, false ); |
---|
1495 | } |
---|
1496 | } |
---|
1497 | |
---|
1498 | |
---|
1499 | Void TDecCavlc::parseVPSVUI( TComVPS* pcVPS ) |
---|
1500 | { |
---|
1501 | assert( pcVPS ); |
---|
1502 | |
---|
1503 | TComVPSVUI* pcVPSVUI = pcVPS->getVPSVUI( ); |
---|
1504 | |
---|
1505 | assert( pcVPSVUI ); |
---|
1506 | |
---|
1507 | UInt uiCode; |
---|
1508 | READ_FLAG( uiCode, "cross_layer_pic_type_aligned_flag" ); pcVPSVUI->setCrossLayerPicTypeAlignedFlag( uiCode == 1 ); |
---|
1509 | if ( !pcVPSVUI->getCrossLayerPicTypeAlignedFlag() ) |
---|
1510 | { |
---|
1511 | READ_FLAG( uiCode, "cross_layer_irap_aligned_flag" ); pcVPSVUI->setCrossLayerIrapAlignedFlag( uiCode == 1 ); |
---|
1512 | } |
---|
1513 | if( pcVPSVUI->getCrossLayerIrapAlignedFlag( ) ) |
---|
1514 | { |
---|
1515 | READ_FLAG( uiCode, "all_layers_idr_aligned_flag" ); pcVPSVUI->setAllLayersIdrAlignedFlag( uiCode == 1 ); |
---|
1516 | } |
---|
1517 | READ_FLAG( uiCode, "bit_rate_present_vps_flag" ); pcVPSVUI->setBitRatePresentVpsFlag( uiCode == 1 ); |
---|
1518 | READ_FLAG( uiCode, "pic_rate_present_vps_flag" ); pcVPSVUI->setPicRatePresentVpsFlag( uiCode == 1 ); |
---|
1519 | if( pcVPSVUI->getBitRatePresentVpsFlag( ) || pcVPSVUI->getPicRatePresentVpsFlag( ) ) |
---|
1520 | { |
---|
1521 | for( Int i = pcVPS->getVpsBaseLayerInternalFlag() ? 0 : 1; i <= pcVPS->getVpsNumLayerSetsMinus1(); i++ ) |
---|
1522 | { |
---|
1523 | for( Int j = 0; j <= pcVPS->getMaxSubLayersInLayerSetMinus1( i ); j++ ) |
---|
1524 | { |
---|
1525 | if( pcVPSVUI->getBitRatePresentVpsFlag( ) ) |
---|
1526 | { |
---|
1527 | READ_FLAG( uiCode, "bit_rate_present_flag" ); pcVPSVUI->setBitRatePresentFlag( i, j, uiCode == 1 ); |
---|
1528 | } |
---|
1529 | if( pcVPSVUI->getPicRatePresentVpsFlag( ) ) |
---|
1530 | { |
---|
1531 | READ_FLAG( uiCode, "pic_rate_present_flag" ); pcVPSVUI->setPicRatePresentFlag( i, j, uiCode == 1 ); |
---|
1532 | } |
---|
1533 | if( pcVPSVUI->getBitRatePresentFlag( i, j ) ) |
---|
1534 | { |
---|
1535 | READ_CODE( 16, uiCode, "avg_bit_rate" ); pcVPSVUI->setAvgBitRate( i, j, uiCode ); |
---|
1536 | READ_CODE( 16, uiCode, "max_bit_rate" ); pcVPSVUI->setMaxBitRate( i, j, uiCode ); |
---|
1537 | } |
---|
1538 | if( pcVPSVUI->getPicRatePresentFlag( i, j ) ) |
---|
1539 | { |
---|
1540 | READ_CODE( 2, uiCode, "constant_pic_rate_idc" ); pcVPSVUI->setConstantPicRateIdc( i, j, uiCode ); |
---|
1541 | READ_CODE( 16, uiCode, "avg_pic_rate" ); pcVPSVUI->setAvgPicRate( i, j, uiCode ); |
---|
1542 | } |
---|
1543 | } |
---|
1544 | } |
---|
1545 | } |
---|
1546 | |
---|
1547 | READ_FLAG( uiCode, "video_signal_info_idx_present_flag" ); pcVPSVUI->setVideoSignalInfoIdxPresentFlag( uiCode == 1 ); |
---|
1548 | if( pcVPSVUI->getVideoSignalInfoIdxPresentFlag() ) |
---|
1549 | { |
---|
1550 | READ_CODE( 4, uiCode, "vps_num_video_signal_info_minus1" ); pcVPSVUI->setVpsNumVideoSignalInfoMinus1( uiCode ); |
---|
1551 | } |
---|
1552 | else |
---|
1553 | { |
---|
1554 | pcVPSVUI->setVpsNumVideoSignalInfoMinus1( pcVPS->getMaxLayersMinus1() ); |
---|
1555 | } |
---|
1556 | |
---|
1557 | for( Int i = 0; i <= pcVPSVUI->getVpsNumVideoSignalInfoMinus1(); i++ ) |
---|
1558 | { |
---|
1559 | assert( pcVPSVUI->getVideoSignalInfo( i ) == NULL ); |
---|
1560 | TComVideoSignalInfo* curVideoSignalInfo = new TComVideoSignalInfo(); |
---|
1561 | parseVideoSignalInfo( curVideoSignalInfo ); |
---|
1562 | pcVPSVUI->setVideoSignalInfo(i, curVideoSignalInfo ); |
---|
1563 | } |
---|
1564 | |
---|
1565 | if( pcVPSVUI->getVideoSignalInfoIdxPresentFlag() && pcVPSVUI->getVpsNumVideoSignalInfoMinus1() > 0 ) |
---|
1566 | { |
---|
1567 | for( Int i = 1; i <= pcVPS->getMaxLayersMinus1(); i++ ) |
---|
1568 | { |
---|
1569 | READ_CODE( 4, uiCode, "vps_video_signal_info_idx" ); pcVPSVUI->setVpsVideoSignalInfoIdx( i, uiCode ); |
---|
1570 | assert( pcVPSVUI->getVpsVideoSignalInfoIdx( i ) >= 0 && pcVPSVUI->getVpsVideoSignalInfoIdx( i ) <= pcVPSVUI->getVpsNumVideoSignalInfoMinus1() ); |
---|
1571 | } |
---|
1572 | } |
---|
1573 | else |
---|
1574 | { |
---|
1575 | for( Int i = 1; i <= pcVPS->getMaxLayersMinus1(); i++ ) |
---|
1576 | { |
---|
1577 | pcVPSVUI->setVpsVideoSignalInfoIdx( i, pcVPSVUI->getVideoSignalInfoIdxPresentFlag() ? 0 : i ); |
---|
1578 | } |
---|
1579 | } |
---|
1580 | READ_FLAG( uiCode, "tiles_not_in_use_flag" ); pcVPSVUI->setTilesNotInUseFlag( uiCode == 1 ); |
---|
1581 | if( !pcVPSVUI->getTilesNotInUseFlag() ) |
---|
1582 | { |
---|
1583 | for( Int i = pcVPS->getVpsBaseLayerInternalFlag() ? 0 : 1; i <= pcVPS->getMaxLayersMinus1(); i++ ) |
---|
1584 | { |
---|
1585 | READ_FLAG( uiCode, "tiles_in_use_flag[i]" ); pcVPSVUI->setTilesInUseFlag( i, uiCode == 1 ); |
---|
1586 | if( pcVPSVUI->getTilesInUseFlag( i ) ) |
---|
1587 | { |
---|
1588 | READ_FLAG( uiCode, "loop_filter_not_across_tiles_flag[i]" ); pcVPSVUI->setLoopFilterNotAcrossTilesFlag( i, uiCode == 1 ); |
---|
1589 | } |
---|
1590 | } |
---|
1591 | for( Int i = pcVPS->getVpsBaseLayerInternalFlag() ? 1 : 2; i <= pcVPS->getMaxLayersMinus1(); i++ ) |
---|
1592 | { |
---|
1593 | for( Int j = 0; j < pcVPS->getNumDirectRefLayers( pcVPS->getLayerIdInNuh( i ) ) ; j++ ) |
---|
1594 | { |
---|
1595 | Int layerIdx = pcVPS->getLayerIdInVps(pcVPS->getRefLayerId(pcVPS->getLayerIdInNuh( i ) , j )); |
---|
1596 | if( pcVPSVUI->getTilesInUseFlag( i ) && pcVPSVUI->getTilesInUseFlag( layerIdx ) ) |
---|
1597 | { |
---|
1598 | READ_FLAG( uiCode, "tile_boundaries_aligned_flag[i][j]" ); pcVPSVUI->setTileBoundariesAlignedFlag( i, j, uiCode == 1 ); |
---|
1599 | } |
---|
1600 | } |
---|
1601 | } |
---|
1602 | } |
---|
1603 | |
---|
1604 | READ_FLAG( uiCode, "wpp_not_in_use_flag" ); pcVPSVUI->setWppNotInUseFlag( uiCode == 1 ); |
---|
1605 | |
---|
1606 | if( !pcVPSVUI->getWppNotInUseFlag( )) |
---|
1607 | { |
---|
1608 | for( Int i = 0; i <= pcVPS->getMaxLayersMinus1(); i++ ) |
---|
1609 | { |
---|
1610 | READ_FLAG( uiCode, "wpp_in_use_flag[i]" ); pcVPSVUI->setWppInUseFlag( i, uiCode == 1 ); |
---|
1611 | } |
---|
1612 | } |
---|
1613 | READ_CODE( 3, uiCode, "vps_vui_reserved_zero_3bits" ); |
---|
1614 | READ_FLAG( uiCode, "ilp_restricted_ref_layers_flag" ); pcVPSVUI->setIlpRestrictedRefLayersFlag( uiCode == 1 ); |
---|
1615 | |
---|
1616 | if( pcVPSVUI->getIlpRestrictedRefLayersFlag( ) ) |
---|
1617 | { |
---|
1618 | for( Int i = 1; i <= pcVPS->getMaxLayersMinus1(); i++ ) |
---|
1619 | { |
---|
1620 | for( Int j = 0; j < pcVPS->getNumDirectRefLayers( pcVPS->getLayerIdInNuh( i ) ); j++ ) |
---|
1621 | { |
---|
1622 | if( pcVPS->getVpsBaseLayerInternalFlag() || pcVPS->getRefLayerId( pcVPS->getLayerIdInNuh( i ), j ) > 0 ) |
---|
1623 | { |
---|
1624 | READ_UVLC( uiCode, "min_spatial_segment_offset_plus1" ); pcVPSVUI->setMinSpatialSegmentOffsetPlus1( i, j, uiCode ); |
---|
1625 | if( pcVPSVUI->getMinSpatialSegmentOffsetPlus1( i, j ) > 0 ) |
---|
1626 | { |
---|
1627 | READ_FLAG( uiCode, "ctu_based_offset_enabled_flag" ); pcVPSVUI->setCtuBasedOffsetEnabledFlag( i, j, uiCode == 1 ); |
---|
1628 | if( pcVPSVUI->getCtuBasedOffsetEnabledFlag( i, j ) ) |
---|
1629 | { |
---|
1630 | READ_UVLC( uiCode, "min_horizontal_ctu_offset_plus1" ); pcVPSVUI->setMinHorizontalCtuOffsetPlus1( i, j, uiCode ); |
---|
1631 | } |
---|
1632 | } |
---|
1633 | } |
---|
1634 | } |
---|
1635 | } |
---|
1636 | } |
---|
1637 | |
---|
1638 | READ_FLAG( uiCode, "vps_vui_bsp_hrd_present_flag" ); pcVPSVUI->setVpsVuiBspHrdPresentFlag( uiCode == 1 ); |
---|
1639 | if ( pcVPSVUI->getVpsVuiBspHrdPresentFlag( ) ) |
---|
1640 | { |
---|
1641 | parseVpsVuiBspHrdParameters( pcVPS ); |
---|
1642 | } |
---|
1643 | for( Int i = 1; i <= pcVPS->getMaxLayersMinus1(); i++ ) |
---|
1644 | { |
---|
1645 | if( pcVPS->getNumDirectRefLayers( pcVPS->getLayerIdInNuh( i )) == 0 ) |
---|
1646 | { |
---|
1647 | READ_FLAG( uiCode, "base_layer_parameter_set_compatibility_flag" ); pcVPSVUI->setBaseLayerParameterSetCompatibilityFlag( i, uiCode == 1 ); |
---|
1648 | } |
---|
1649 | } |
---|
1650 | } |
---|
1651 | |
---|
1652 | Void TDecCavlc::parseVpsVuiBspHrdParameters( TComVPS* pcVPS ) |
---|
1653 | { |
---|
1654 | assert( pcVPS ); |
---|
1655 | |
---|
1656 | TComVPSVUI* pcVPSVUI = pcVPS->getVPSVUI( ); |
---|
1657 | |
---|
1658 | assert( pcVPSVUI ); |
---|
1659 | |
---|
1660 | TComVpsVuiBspHrdParameters* vpsVuiBspHrdP = pcVPSVUI->getVpsVuiBspHrdParameters(); |
---|
1661 | |
---|
1662 | assert ( vpsVuiBspHrdP ); |
---|
1663 | |
---|
1664 | UInt uiCode; |
---|
1665 | READ_UVLC( uiCode, "vps_num_bsp_hrd_parameters_minus1" ); vpsVuiBspHrdP->setVpsNumBspHrdParametersMinus1( uiCode ); |
---|
1666 | for( Int i = 0; i <= vpsVuiBspHrdP->getVpsNumBspHrdParametersMinus1( ); i++ ) |
---|
1667 | { |
---|
1668 | if( i > 0 ) |
---|
1669 | { |
---|
1670 | READ_FLAG( uiCode, "bsp_cprms_present_flag" ); vpsVuiBspHrdP->setBspCprmsPresentFlag( i, uiCode == 1 ); |
---|
1671 | } |
---|
1672 | TComHRD* hrdParameters = vpsVuiBspHrdP->getHrdParametermeters( i ); |
---|
1673 | parseHrdParameters( hrdParameters, vpsVuiBspHrdP->getBspCprmsPresentFlag( i ), pcVPS->getMaxSubLayersMinus1() ); |
---|
1674 | } |
---|
1675 | for( Int h = 1; h <= pcVPS->getVpsNumLayerSetsMinus1(); h++ ) |
---|
1676 | { |
---|
1677 | READ_UVLC( uiCode, "num_bitstream_partitions" ); vpsVuiBspHrdP->setNumBitstreamPartitions( h, uiCode ); |
---|
1678 | for( Int i = 0; i < vpsVuiBspHrdP->getNumBitstreamPartitions( h ); i++ ) |
---|
1679 | { |
---|
1680 | for( Int j = 0; j < pcVPS->getNumLayersInIdList( h ); j++ ) |
---|
1681 | { |
---|
1682 | READ_FLAG( uiCode, "layer_in_bsp_flag" ); vpsVuiBspHrdP->setLayerInBspFlag( h, i, j, uiCode == 1 ); |
---|
1683 | } |
---|
1684 | } |
---|
1685 | vpsVuiBspHrdP->checkLayerInBspFlag( pcVPS, h ); |
---|
1686 | |
---|
1687 | if( vpsVuiBspHrdP->getNumBitstreamPartitions( h ) ) |
---|
1688 | { |
---|
1689 | READ_UVLC( uiCode, "num_bsp_sched_combinations_minus1" ); vpsVuiBspHrdP->setNumBspSchedCombinationsMinus1( h, uiCode ); |
---|
1690 | for( Int i = 0; i <= vpsVuiBspHrdP->getNumBspSchedCombinationsMinus1( h ); i++ ) |
---|
1691 | { |
---|
1692 | for( Int j = 0; j < vpsVuiBspHrdP->getNumBitstreamPartitions( h ); j++ ) |
---|
1693 | { |
---|
1694 | READ_CODE( vpsVuiBspHrdP->getBspCombHrdIdxLen(), uiCode, "bsp_comb_hrd_idx" ); vpsVuiBspHrdP->setBspCombHrdIdx( h, i, j, uiCode ); |
---|
1695 | READ_UVLC( uiCode, "bsp_comb_sched_idx" ); vpsVuiBspHrdP->setBspCombSchedIdx( h, i, j, uiCode ); |
---|
1696 | vpsVuiBspHrdP->checkBspCombHrdAndShedIdx( pcVPS, h, i, j ); |
---|
1697 | } |
---|
1698 | } |
---|
1699 | } |
---|
1700 | } |
---|
1701 | } |
---|
1702 | |
---|
1703 | Void TDecCavlc::parseVideoSignalInfo( TComVideoSignalInfo* pcVideoSignalInfo ) |
---|
1704 | { |
---|
1705 | UInt uiCode; |
---|
1706 | READ_CODE( 3, uiCode, "video_vps_format" ); pcVideoSignalInfo->setVideoVpsFormat( uiCode ); |
---|
1707 | READ_FLAG( uiCode, "video_full_range_vps_flag" ); pcVideoSignalInfo->setVideoFullRangeVpsFlag( uiCode == 1 ); |
---|
1708 | READ_CODE( 8, uiCode, "colour_primaries_vps" ); pcVideoSignalInfo->setColourPrimariesVps( uiCode ); |
---|
1709 | READ_CODE( 8, uiCode, "transfer_characteristics_vps" ); pcVideoSignalInfo->setTransferCharacteristicsVps( uiCode ); |
---|
1710 | READ_CODE( 8, uiCode, "matrix_coeffs_vps" ); pcVideoSignalInfo->setMatrixCoeffsVps( uiCode ); |
---|
1711 | } |
---|
1712 | |
---|
1713 | Void TDecCavlc::parseDpbSize( TComVPS* vps ) |
---|
1714 | { |
---|
1715 | UInt uiCode; |
---|
1716 | TComDpbSize* dpbSize = vps->getDpbSize(); |
---|
1717 | assert ( dpbSize != 0 ); |
---|
1718 | |
---|
1719 | for( Int i = 1; i < vps->getNumOutputLayerSets(); i++ ) |
---|
1720 | { |
---|
1721 | Int currLsIdx = vps->olsIdxToLsIdx( i ); |
---|
1722 | READ_FLAG( uiCode, "sub_layer_flag_info_present_flag" ); dpbSize->setSubLayerFlagInfoPresentFlag( i, uiCode == 1 ); |
---|
1723 | for( Int j = 0; j <= vps->getMaxSubLayersInLayerSetMinus1( currLsIdx ); j++ ) |
---|
1724 | { |
---|
1725 | if( j > 0 && dpbSize->getSubLayerDpbInfoPresentFlag( i, j ) ) |
---|
1726 | { |
---|
1727 | READ_FLAG( uiCode, "sub_layer_dpb_info_present_flag" ); dpbSize->setSubLayerDpbInfoPresentFlag( i, j, uiCode == 1 ); |
---|
1728 | } |
---|
1729 | if( dpbSize->getSubLayerDpbInfoPresentFlag( i, j ) ) |
---|
1730 | { |
---|
1731 | for( Int k = 0; k < vps->getNumLayersInIdList( currLsIdx ); k++ ) |
---|
1732 | { |
---|
1733 | READ_UVLC( uiCode, "max_vps_dec_pic_buffering_minus1" ); dpbSize->setMaxVpsDecPicBufferingMinus1( i, k, j, uiCode ); |
---|
1734 | } |
---|
1735 | READ_UVLC( uiCode, "max_vps_num_reorder_pics" ); dpbSize->setMaxVpsNumReorderPics( i, j, uiCode ); |
---|
1736 | READ_UVLC( uiCode, "max_vps_latency_increase_plus1" ); dpbSize->setMaxVpsLatencyIncreasePlus1( i, j, uiCode ); |
---|
1737 | } |
---|
1738 | else |
---|
1739 | { |
---|
1740 | if ( j > 0 ) |
---|
1741 | { |
---|
1742 | for( Int k = 0; k < vps->getNumLayersInIdList( vps->olsIdxToLsIdx( i ) ); k++ ) |
---|
1743 | { |
---|
1744 | dpbSize->setMaxVpsDecPicBufferingMinus1( i, k, j, dpbSize->getMaxVpsDecPicBufferingMinus1( i,k, j - 1 ) ); |
---|
1745 | } |
---|
1746 | dpbSize->setMaxVpsNumReorderPics ( i, j, dpbSize->getMaxVpsNumReorderPics ( i, j - 1 ) ); |
---|
1747 | dpbSize->setMaxVpsLatencyIncreasePlus1( i, j, dpbSize->getMaxVpsLatencyIncreasePlus1( i, j - 1 ) ); |
---|
1748 | } |
---|
1749 | } |
---|
1750 | } |
---|
1751 | } |
---|
1752 | } |
---|
1753 | |
---|
1754 | #if H_3D |
---|
1755 | Void TDecCavlc::parseVPSExtension2( TComVPS* pcVPS ) |
---|
1756 | { |
---|
1757 | UInt uiCode; |
---|
1758 | for( Int i = 0; i <= pcVPS->getMaxLayersMinus1(); i++ ) |
---|
1759 | { |
---|
1760 | #if H_3D_ARP |
---|
1761 | pcVPS->setUseAdvRP ( i, 0 ); |
---|
1762 | pcVPS->setARPStepNum( i, 1 ); |
---|
1763 | #endif |
---|
1764 | #if H_3D_SPIVMP |
---|
1765 | pcVPS->setSubPULog2Size(i, 0); |
---|
1766 | #endif |
---|
1767 | if ( i != 0 ) |
---|
1768 | { |
---|
1769 | if( !( pcVPS->getDepthId( i ) == 1 ) ) |
---|
1770 | { |
---|
1771 | #if H_3D_IV_MERGE |
---|
1772 | READ_FLAG( uiCode, "iv_mv_pred_flag[i]"); pcVPS->setIvMvPredFlag ( i, uiCode == 1 ? true : false ); |
---|
1773 | if( !pcVPS->getNumDirectRefLayers(i) ) |
---|
1774 | { |
---|
1775 | assert( !uiCode ); |
---|
1776 | } |
---|
1777 | #if H_3D_SPIVMP |
---|
1778 | READ_UVLC (uiCode, "log2_sub_PU_size_minus3[i]"); pcVPS->setSubPULog2Size(i, uiCode+3); |
---|
1779 | #endif |
---|
1780 | #endif |
---|
1781 | #if H_3D_ARP |
---|
1782 | READ_FLAG( uiCode, "iv_res_pred_flag[i]" ); pcVPS->setUseAdvRP ( i, uiCode ); pcVPS->setARPStepNum( i, uiCode ? H_3D_ARP_WFNR : 1 ); |
---|
1783 | if( !pcVPS->getNumDirectRefLayers(i) ) |
---|
1784 | { |
---|
1785 | assert( !uiCode ); |
---|
1786 | } |
---|
1787 | #endif |
---|
1788 | #if H_3D_NBDV_REF |
---|
1789 | READ_FLAG( uiCode, "depth_refinement_flag[i]"); pcVPS->setDepthRefinementFlag ( i, uiCode == 1 ? true : false ); |
---|
1790 | #endif |
---|
1791 | #if H_3D_VSP |
---|
1792 | READ_FLAG( uiCode, "view_synthesis_pred_flag[i]"); pcVPS->setViewSynthesisPredFlag( i, uiCode == 1 ? true : false ); |
---|
1793 | if( !pcVPS->getNumDirectRefLayers(i) ) |
---|
1794 | { |
---|
1795 | assert( !uiCode ); |
---|
1796 | } |
---|
1797 | #endif |
---|
1798 | #if H_3D_DBBP |
---|
1799 | READ_FLAG( uiCode, "use_dbbp_flag[i]" ); pcVPS->setUseDBBP( i, uiCode == 1 ? true : false ); |
---|
1800 | #endif |
---|
1801 | } |
---|
1802 | else |
---|
1803 | { |
---|
1804 | #if H_3D_IV_MERGE |
---|
1805 | if(i!=1) |
---|
1806 | { |
---|
1807 | READ_FLAG( uiCode, "iv_mv_pred_flag[i]"); pcVPS->setIvMvPredFlag ( i, uiCode == 1 ? true : false ); |
---|
1808 | if( !pcVPS->getNumDirectRefLayers(i) ) |
---|
1809 | { |
---|
1810 | assert( !uiCode ); |
---|
1811 | } |
---|
1812 | } |
---|
1813 | #endif |
---|
1814 | #if H_3D_SPIVMP |
---|
1815 | if (i!=1) |
---|
1816 | { |
---|
1817 | READ_UVLC (uiCode, "log2_sub_PU_size_minus3[i]"); pcVPS->setSubPULog2Size(i, uiCode+3); |
---|
1818 | } |
---|
1819 | #endif |
---|
1820 | #if H_3D_IV_MERGE |
---|
1821 | READ_FLAG( uiCode, "mpi_flag[i]" ); pcVPS->setMPIFlag( i, uiCode == 1 ? true : false ); |
---|
1822 | #endif |
---|
1823 | READ_FLAG( uiCode, "vps_depth_modes_flag[i]" ); pcVPS->setVpsDepthModesFlag( i, uiCode == 1 ? true : false ); |
---|
1824 | // READ_FLAG( uiCode, "lim_qt_pred_flag[i]"); pcVPS->setLimQtPreFlag ( i, uiCode == 1 ? true : false ); |
---|
1825 | #if H_3D_INTER_SDC |
---|
1826 | READ_FLAG( uiCode, "depth_inter_SDC_flag" ); pcVPS->setInterSDCFlag( i, uiCode ? true : false ); |
---|
1827 | #endif |
---|
1828 | } |
---|
1829 | } |
---|
1830 | } |
---|
1831 | |
---|
1832 | UInt uiCamParPrecision = 0; |
---|
1833 | Bool bCamParSlice = false; |
---|
1834 | Bool bCamParPresentFlag = false; |
---|
1835 | |
---|
1836 | READ_UVLC( uiCamParPrecision, "cp_precision" ); |
---|
1837 | for (UInt viewIndex=0; viewIndex<pcVPS->getNumViews(); viewIndex++) |
---|
1838 | { |
---|
1839 | pcVPS->setCamParPresent ( viewIndex, false ); |
---|
1840 | pcVPS->setHasCamParInSliceHeader( viewIndex, false ); |
---|
1841 | READ_FLAG( uiCode, "cp_present_flag[i]" ); bCamParPresentFlag = ( uiCode == 1); |
---|
1842 | if ( bCamParPresentFlag ) |
---|
1843 | { |
---|
1844 | READ_FLAG( uiCode, "cp_in_slice_segment_header_flag[i]" ); bCamParSlice = ( uiCode == 1); |
---|
1845 | if ( !bCamParSlice ) |
---|
1846 | { |
---|
1847 | for( UInt uiBaseIndex = 0; uiBaseIndex < viewIndex; uiBaseIndex++ ) |
---|
1848 | { |
---|
1849 | Int iCode; |
---|
1850 | READ_SVLC( iCode, "vps_cp_scale" ); m_aaiTempScale [ uiBaseIndex ][ viewIndex ] = iCode; |
---|
1851 | READ_SVLC( iCode, "vps_cp_off" ); m_aaiTempOffset [ uiBaseIndex ][ viewIndex ] = iCode; |
---|
1852 | READ_SVLC( iCode, "vps_cp_inv_scale_plus_scale" ); m_aaiTempScale [ viewIndex ][ uiBaseIndex ] = iCode - m_aaiTempScale [ uiBaseIndex ][ viewIndex ]; |
---|
1853 | READ_SVLC( iCode, "vps_cp_inv_off_plus_off" ); m_aaiTempOffset [ viewIndex ][ uiBaseIndex ] = iCode - m_aaiTempOffset[ uiBaseIndex ][ viewIndex ]; |
---|
1854 | } |
---|
1855 | } |
---|
1856 | pcVPS->initCamParaVPS( viewIndex, bCamParPresentFlag, uiCamParPrecision, bCamParSlice, m_aaiTempScale, m_aaiTempOffset ); |
---|
1857 | } |
---|
1858 | } |
---|
1859 | READ_UVLC (uiCode, "log2_sub_PU_MPI_size_minus3"); pcVPS->setSubPUMPILog2Size( uiCode + 3 ); |
---|
1860 | READ_FLAG( uiCode, "iv_mv_scaling_flag"); pcVPS->setIvMvScalingFlag( uiCode == 1 ? true : false ); |
---|
1861 | } |
---|
1862 | #endif |
---|
1863 | #endif |
---|
1864 | #if H_MV |
---|
1865 | Void TDecCavlc::parseSliceHeader (TComSlice*& rpcSlice, ParameterSetManagerDecoder *parameterSetManager, Int targetOlsIdx) |
---|
1866 | #else |
---|
1867 | Void TDecCavlc::parseSliceHeader (TComSlice*& rpcSlice, ParameterSetManagerDecoder *parameterSetManager) |
---|
1868 | #endif |
---|
1869 | { |
---|
1870 | UInt uiCode; |
---|
1871 | Int iCode; |
---|
1872 | |
---|
1873 | #if ENC_DEC_TRACE |
---|
1874 | xTraceSliceHeader(rpcSlice); |
---|
1875 | #endif |
---|
1876 | TComPPS* pps = NULL; |
---|
1877 | TComSPS* sps = NULL; |
---|
1878 | #if H_MV |
---|
1879 | TComVPS* vps = NULL; |
---|
1880 | #endif |
---|
1881 | |
---|
1882 | UInt firstSliceSegmentInPic; |
---|
1883 | READ_FLAG( firstSliceSegmentInPic, "first_slice_segment_in_pic_flag" ); |
---|
1884 | if( rpcSlice->getRapPicFlag()) |
---|
1885 | { |
---|
1886 | READ_FLAG( uiCode, "no_output_of_prior_pics_flag" ); //ignored -- updated already |
---|
1887 | #if SETTING_NO_OUT_PIC_PRIOR |
---|
1888 | rpcSlice->setNoOutputPriorPicsFlag(uiCode ? true : false); |
---|
1889 | #else |
---|
1890 | rpcSlice->setNoOutputPicPrior( false ); |
---|
1891 | #endif |
---|
1892 | } |
---|
1893 | |
---|
1894 | READ_UVLC ( uiCode, "slice_pic_parameter_set_id" ); rpcSlice->setPPSId(uiCode); |
---|
1895 | pps = parameterSetManager->getPrefetchedPPS(uiCode); |
---|
1896 | //!KS: need to add error handling code here, if PPS is not available |
---|
1897 | assert(pps!=0); |
---|
1898 | sps = parameterSetManager->getPrefetchedSPS(pps->getSPSId()); |
---|
1899 | //!KS: need to add error handling code here, if SPS is not available |
---|
1900 | assert(sps!=0); |
---|
1901 | #if H_MV |
---|
1902 | vps = parameterSetManager->getPrefetchedVPS(sps->getVPSId()); |
---|
1903 | assert( vps != NULL ); |
---|
1904 | |
---|
1905 | sps->inferRepFormat ( vps , rpcSlice->getLayerId() ); |
---|
1906 | sps->inferScalingList( parameterSetManager->getActiveSPS( sps->getSpsScalingListRefLayerId() ) ); |
---|
1907 | sps->inferSpsMaxDecPicBufferingMinus1( vps, targetOlsIdx, rpcSlice->getLayerId(), false ); |
---|
1908 | vps->inferDbpSizeLayerSetZero( sps, false ); |
---|
1909 | |
---|
1910 | if ( sps->getVuiParametersPresentFlag() ) |
---|
1911 | { |
---|
1912 | sps->getVuiParameters()->inferVideoSignalInfo( vps, rpcSlice->getLayerId() ); |
---|
1913 | } |
---|
1914 | rpcSlice->setVPS(vps); |
---|
1915 | rpcSlice->setViewId ( vps->getViewId ( rpcSlice->getLayerId() ) ); |
---|
1916 | rpcSlice->setViewIndex( vps->getViewIndex( rpcSlice->getLayerId() ) ); |
---|
1917 | #if H_3D |
---|
1918 | rpcSlice->setIsDepth ( vps->getDepthId ( rpcSlice->getLayerId() ) == 1 ); |
---|
1919 | #endif |
---|
1920 | #endif |
---|
1921 | rpcSlice->setSPS(sps); |
---|
1922 | rpcSlice->setPPS(pps); |
---|
1923 | if( pps->getDependentSliceSegmentsEnabledFlag() && ( !firstSliceSegmentInPic )) |
---|
1924 | { |
---|
1925 | READ_FLAG( uiCode, "dependent_slice_segment_flag" ); rpcSlice->setDependentSliceSegmentFlag(uiCode ? true : false); |
---|
1926 | } |
---|
1927 | else |
---|
1928 | { |
---|
1929 | rpcSlice->setDependentSliceSegmentFlag(false); |
---|
1930 | } |
---|
1931 | Int numCTUs = ((sps->getPicWidthInLumaSamples()+sps->getMaxCUWidth()-1)/sps->getMaxCUWidth())*((sps->getPicHeightInLumaSamples()+sps->getMaxCUHeight()-1)/sps->getMaxCUHeight()); |
---|
1932 | Int maxParts = (1<<(sps->getMaxCUDepth()<<1)); |
---|
1933 | UInt sliceSegmentAddress = 0; |
---|
1934 | Int bitsSliceSegmentAddress = 0; |
---|
1935 | while(numCTUs>(1<<bitsSliceSegmentAddress)) |
---|
1936 | { |
---|
1937 | bitsSliceSegmentAddress++; |
---|
1938 | } |
---|
1939 | |
---|
1940 | if(!firstSliceSegmentInPic) |
---|
1941 | { |
---|
1942 | READ_CODE( bitsSliceSegmentAddress, sliceSegmentAddress, "slice_segment_address" ); |
---|
1943 | } |
---|
1944 | //set uiCode to equal slice start address (or dependent slice start address) |
---|
1945 | Int startCuAddress = maxParts*sliceSegmentAddress; |
---|
1946 | rpcSlice->setSliceSegmentCurStartCUAddr( startCuAddress ); |
---|
1947 | rpcSlice->setSliceSegmentCurEndCUAddr(numCTUs*maxParts); |
---|
1948 | |
---|
1949 | if (rpcSlice->getDependentSliceSegmentFlag()) |
---|
1950 | { |
---|
1951 | rpcSlice->setNextSlice ( false ); |
---|
1952 | rpcSlice->setNextSliceSegment ( true ); |
---|
1953 | } |
---|
1954 | else |
---|
1955 | { |
---|
1956 | rpcSlice->setNextSlice ( true ); |
---|
1957 | rpcSlice->setNextSliceSegment ( false ); |
---|
1958 | |
---|
1959 | rpcSlice->setSliceCurStartCUAddr(startCuAddress); |
---|
1960 | rpcSlice->setSliceCurEndCUAddr(numCTUs*maxParts); |
---|
1961 | } |
---|
1962 | |
---|
1963 | #if H_MV |
---|
1964 | UInt slicePicOrderCntLsb = 0; |
---|
1965 | #endif |
---|
1966 | |
---|
1967 | if(!rpcSlice->getDependentSliceSegmentFlag()) |
---|
1968 | { |
---|
1969 | #if H_MV |
---|
1970 | Int esb = 0; //Don't use i, otherwise will shadow something below |
---|
1971 | |
---|
1972 | if ( rpcSlice->getPPS()->getNumExtraSliceHeaderBits() > esb ) |
---|
1973 | { |
---|
1974 | esb++; |
---|
1975 | READ_FLAG( uiCode, "discardable_flag" ); rpcSlice->setDiscardableFlag( uiCode == 1 ); |
---|
1976 | } |
---|
1977 | |
---|
1978 | if ( rpcSlice->getPPS()->getNumExtraSliceHeaderBits() > esb ) |
---|
1979 | { |
---|
1980 | esb++; |
---|
1981 | READ_FLAG( uiCode, "cross_layer_bla_flag" ); rpcSlice->setCrossLayerBlaFlag( uiCode == 1 ); |
---|
1982 | } |
---|
1983 | rpcSlice->checkCrossLayerBlaFlag( ); |
---|
1984 | |
---|
1985 | #if !H_MV_HLS7_GEN |
---|
1986 | if ( rpcSlice->getPPS()->getNumExtraSliceHeaderBits() > esb ) |
---|
1987 | { |
---|
1988 | esb++; |
---|
1989 | READ_FLAG( uiCode, "poc_reset_flag" ); rpcSlice->setPocResetFlag( uiCode == 1 ); |
---|
1990 | } |
---|
1991 | #endif |
---|
1992 | |
---|
1993 | for (; esb < rpcSlice->getPPS()->getNumExtraSliceHeaderBits(); esb++) |
---|
1994 | #else |
---|
1995 | for (Int i = 0; i < rpcSlice->getPPS()->getNumExtraSliceHeaderBits(); i++) |
---|
1996 | #endif |
---|
1997 | { |
---|
1998 | READ_FLAG(uiCode, "slice_reserved_undetermined_flag[]"); // ignored |
---|
1999 | } |
---|
2000 | |
---|
2001 | READ_UVLC ( uiCode, "slice_type" ); rpcSlice->setSliceType((SliceType)uiCode); |
---|
2002 | if( pps->getOutputFlagPresentFlag() ) |
---|
2003 | { |
---|
2004 | READ_FLAG( uiCode, "pic_output_flag" ); rpcSlice->setPicOutputFlag( uiCode ? true : false ); |
---|
2005 | } |
---|
2006 | else |
---|
2007 | { |
---|
2008 | rpcSlice->setPicOutputFlag( true ); |
---|
2009 | } |
---|
2010 | // in the first version chroma_format_idc is equal to one, thus colour_plane_id will not be present |
---|
2011 | assert (sps->getChromaFormatIdc() == 1 ); |
---|
2012 | // if( separate_colour_plane_flag == 1 ) |
---|
2013 | // colour_plane_id u(2) |
---|
2014 | |
---|
2015 | |
---|
2016 | #if H_MV |
---|
2017 | Int iPOClsb = slicePicOrderCntLsb; // Needed later |
---|
2018 | if ( (rpcSlice->getLayerId() > 0 && !vps->getPocLsbNotPresentFlag( rpcSlice->getLayerIdInVps())) || !rpcSlice->getIdrPicFlag() ) |
---|
2019 | { |
---|
2020 | READ_CODE(sps->getBitsForPOC(), slicePicOrderCntLsb, "slice_pic_order_cnt_lsb"); |
---|
2021 | } |
---|
2022 | rpcSlice->setSlicePicOrderCntLsb( slicePicOrderCntLsb ); |
---|
2023 | |
---|
2024 | Bool picOrderCntMSBZeroFlag = false; |
---|
2025 | |
---|
2026 | // as in HM code. However are all cases for IRAP picture with NoRaslOutputFlag equal to 1 covered?? |
---|
2027 | picOrderCntMSBZeroFlag = picOrderCntMSBZeroFlag || ( rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP ); |
---|
2028 | picOrderCntMSBZeroFlag = picOrderCntMSBZeroFlag || ( rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL ); |
---|
2029 | picOrderCntMSBZeroFlag = picOrderCntMSBZeroFlag || ( rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP ); |
---|
2030 | picOrderCntMSBZeroFlag = picOrderCntMSBZeroFlag || rpcSlice->getIdrPicFlag(); |
---|
2031 | |
---|
2032 | // TBD picOrderCntMSBZeroFlag = picOrderCntMSBZeroFlag || ( rpcSlice->getLayerId() > 0 && !rpcSlice->getFirstPicInLayerDecodedFlag() ); |
---|
2033 | |
---|
2034 | Int picOrderCntMSB = 0; |
---|
2035 | |
---|
2036 | if ( !picOrderCntMSBZeroFlag ) |
---|
2037 | { |
---|
2038 | Int prevPicOrderCnt = rpcSlice->getPrevTid0POC(); |
---|
2039 | Int maxPicOrderCntLsb = 1 << sps->getBitsForPOC(); |
---|
2040 | Int prevPicOrderCntLsb = prevPicOrderCnt & (maxPicOrderCntLsb - 1); |
---|
2041 | Int prevPicOrderCntMsb = prevPicOrderCnt - prevPicOrderCntLsb; |
---|
2042 | |
---|
2043 | if( ( slicePicOrderCntLsb < prevPicOrderCntLsb ) && ( ( prevPicOrderCntLsb - slicePicOrderCntLsb ) >= ( maxPicOrderCntLsb / 2 ) ) ) |
---|
2044 | { |
---|
2045 | picOrderCntMSB = prevPicOrderCntMsb + maxPicOrderCntLsb; |
---|
2046 | } |
---|
2047 | else if( (slicePicOrderCntLsb > prevPicOrderCntLsb ) && ( (slicePicOrderCntLsb - prevPicOrderCntLsb ) > ( maxPicOrderCntLsb / 2 ) ) ) |
---|
2048 | { |
---|
2049 | picOrderCntMSB = prevPicOrderCntMsb - maxPicOrderCntLsb; |
---|
2050 | } |
---|
2051 | else |
---|
2052 | { |
---|
2053 | picOrderCntMSB = prevPicOrderCntMsb; |
---|
2054 | } |
---|
2055 | } |
---|
2056 | |
---|
2057 | rpcSlice->setPOC( picOrderCntMSB + slicePicOrderCntLsb ); |
---|
2058 | if ( rpcSlice->getPocResetFlag() ) |
---|
2059 | { |
---|
2060 | rpcSlice->setPocBeforeReset ( rpcSlice->getPOC() ); |
---|
2061 | rpcSlice->setPOC ( 0 ); |
---|
2062 | } |
---|
2063 | #endif |
---|
2064 | |
---|
2065 | if( rpcSlice->getIdrPicFlag() ) |
---|
2066 | { |
---|
2067 | #if !H_MV |
---|
2068 | rpcSlice->setPOC(0); |
---|
2069 | #endif |
---|
2070 | TComReferencePictureSet* rps = rpcSlice->getLocalRPS(); |
---|
2071 | rps->setNumberOfNegativePictures(0); |
---|
2072 | rps->setNumberOfPositivePictures(0); |
---|
2073 | rps->setNumberOfLongtermPictures(0); |
---|
2074 | rps->setNumberOfPictures(0); |
---|
2075 | rpcSlice->setRPS(rps); |
---|
2076 | #if H_MV |
---|
2077 | rpcSlice->setEnableTMVPFlag(false); |
---|
2078 | #endif |
---|
2079 | } |
---|
2080 | else |
---|
2081 | { |
---|
2082 | #if !H_MV |
---|
2083 | READ_CODE(sps->getBitsForPOC(), uiCode, "pic_order_cnt_lsb"); |
---|
2084 | Int iPOClsb = uiCode; |
---|
2085 | Int iPrevPOC = rpcSlice->getPrevTid0POC(); |
---|
2086 | Int iMaxPOClsb = 1<< sps->getBitsForPOC(); |
---|
2087 | Int iPrevPOClsb = iPrevPOC & (iMaxPOClsb - 1); |
---|
2088 | Int iPrevPOCmsb = iPrevPOC-iPrevPOClsb; |
---|
2089 | Int iPOCmsb; |
---|
2090 | if( ( iPOClsb < iPrevPOClsb ) && ( ( iPrevPOClsb - iPOClsb ) >= ( iMaxPOClsb / 2 ) ) ) |
---|
2091 | { |
---|
2092 | iPOCmsb = iPrevPOCmsb + iMaxPOClsb; |
---|
2093 | } |
---|
2094 | else if( (iPOClsb > iPrevPOClsb ) && ( (iPOClsb - iPrevPOClsb ) > ( iMaxPOClsb / 2 ) ) ) |
---|
2095 | { |
---|
2096 | iPOCmsb = iPrevPOCmsb - iMaxPOClsb; |
---|
2097 | } |
---|
2098 | else |
---|
2099 | { |
---|
2100 | iPOCmsb = iPrevPOCmsb; |
---|
2101 | } |
---|
2102 | if ( rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP |
---|
2103 | || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL |
---|
2104 | || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP ) |
---|
2105 | { |
---|
2106 | // For BLA picture types, POCmsb is set to 0. |
---|
2107 | iPOCmsb = 0; |
---|
2108 | } |
---|
2109 | rpcSlice->setPOC (iPOCmsb+iPOClsb); |
---|
2110 | #endif |
---|
2111 | TComReferencePictureSet* rps; |
---|
2112 | rps = rpcSlice->getLocalRPS(); |
---|
2113 | rpcSlice->setRPS(rps); |
---|
2114 | READ_FLAG( uiCode, "short_term_ref_pic_set_sps_flag" ); |
---|
2115 | if(uiCode == 0) // use short-term reference picture set explicitly signalled in slice header |
---|
2116 | { |
---|
2117 | parseShortTermRefPicSet(sps,rps, sps->getRPSList()->getNumberOfReferencePictureSets()); |
---|
2118 | #if H_MV |
---|
2119 | if ( !rps->getInterRPSPrediction( ) ) |
---|
2120 | { // check sum of num_positive_pics and num_negative_pics |
---|
2121 | rps->checkMaxNumPics( |
---|
2122 | vps->getVpsExtensionFlag(), |
---|
2123 | vps->getMaxNumPics( rpcSlice->getLayerId() ), |
---|
2124 | rpcSlice->getLayerId(), |
---|
2125 | sps->getMaxDecPicBuffering( sps->getSpsMaxSubLayersMinus1() ) - 1 ); |
---|
2126 | } |
---|
2127 | #endif |
---|
2128 | } |
---|
2129 | else // use reference to short-term reference picture set in PPS |
---|
2130 | { |
---|
2131 | Int numBits = 0; |
---|
2132 | while ((1 << numBits) < rpcSlice->getSPS()->getRPSList()->getNumberOfReferencePictureSets()) |
---|
2133 | { |
---|
2134 | numBits++; |
---|
2135 | } |
---|
2136 | if (numBits > 0) |
---|
2137 | { |
---|
2138 | READ_CODE( numBits, uiCode, "short_term_ref_pic_set_idx"); |
---|
2139 | } |
---|
2140 | else |
---|
2141 | { |
---|
2142 | uiCode = 0; |
---|
2143 | } |
---|
2144 | *rps = *(sps->getRPSList()->getReferencePictureSet(uiCode)); |
---|
2145 | } |
---|
2146 | if(sps->getLongTermRefsPresent()) |
---|
2147 | { |
---|
2148 | Int offset = rps->getNumberOfNegativePictures()+rps->getNumberOfPositivePictures(); |
---|
2149 | UInt numOfLtrp = 0; |
---|
2150 | UInt numLtrpInSPS = 0; |
---|
2151 | if (rpcSlice->getSPS()->getNumLongTermRefPicSPS() > 0) |
---|
2152 | { |
---|
2153 | READ_UVLC( uiCode, "num_long_term_sps"); |
---|
2154 | numLtrpInSPS = uiCode; |
---|
2155 | numOfLtrp += numLtrpInSPS; |
---|
2156 | rps->setNumberOfLongtermPictures(numOfLtrp); |
---|
2157 | } |
---|
2158 | Int bitsForLtrpInSPS = 0; |
---|
2159 | while (rpcSlice->getSPS()->getNumLongTermRefPicSPS() > (1 << bitsForLtrpInSPS)) |
---|
2160 | { |
---|
2161 | bitsForLtrpInSPS++; |
---|
2162 | } |
---|
2163 | READ_UVLC( uiCode, "num_long_term_pics"); rps->setNumberOfLongtermPictures(uiCode); |
---|
2164 | numOfLtrp += uiCode; |
---|
2165 | rps->setNumberOfLongtermPictures(numOfLtrp); |
---|
2166 | Int maxPicOrderCntLSB = 1 << rpcSlice->getSPS()->getBitsForPOC(); |
---|
2167 | Int prevDeltaMSB = 0, deltaPocMSBCycleLT = 0;; |
---|
2168 | for(Int j=offset+rps->getNumberOfLongtermPictures()-1, k = 0; k < numOfLtrp; j--, k++) |
---|
2169 | { |
---|
2170 | Int pocLsbLt; |
---|
2171 | if (k < numLtrpInSPS) |
---|
2172 | { |
---|
2173 | uiCode = 0; |
---|
2174 | if (bitsForLtrpInSPS > 0) |
---|
2175 | { |
---|
2176 | READ_CODE(bitsForLtrpInSPS, uiCode, "lt_idx_sps[i]"); |
---|
2177 | } |
---|
2178 | Int usedByCurrFromSPS=rpcSlice->getSPS()->getUsedByCurrPicLtSPSFlag(uiCode); |
---|
2179 | |
---|
2180 | pocLsbLt = rpcSlice->getSPS()->getLtRefPicPocLsbSps(uiCode); |
---|
2181 | rps->setUsed(j,usedByCurrFromSPS); |
---|
2182 | } |
---|
2183 | else |
---|
2184 | { |
---|
2185 | READ_CODE(rpcSlice->getSPS()->getBitsForPOC(), uiCode, "poc_lsb_lt"); pocLsbLt= uiCode; |
---|
2186 | READ_FLAG( uiCode, "used_by_curr_pic_lt_flag"); rps->setUsed(j,uiCode); |
---|
2187 | } |
---|
2188 | READ_FLAG(uiCode,"delta_poc_msb_present_flag"); |
---|
2189 | Bool mSBPresentFlag = uiCode ? true : false; |
---|
2190 | if(mSBPresentFlag) |
---|
2191 | { |
---|
2192 | READ_UVLC( uiCode, "delta_poc_msb_cycle_lt[i]" ); |
---|
2193 | Bool deltaFlag = false; |
---|
2194 | // First LTRP || First LTRP from SH |
---|
2195 | if( (j == offset+rps->getNumberOfLongtermPictures()-1) || (j == offset+(numOfLtrp-numLtrpInSPS)-1) ) |
---|
2196 | { |
---|
2197 | deltaFlag = true; |
---|
2198 | } |
---|
2199 | if(deltaFlag) |
---|
2200 | { |
---|
2201 | deltaPocMSBCycleLT = uiCode; |
---|
2202 | } |
---|
2203 | else |
---|
2204 | { |
---|
2205 | deltaPocMSBCycleLT = uiCode + prevDeltaMSB; |
---|
2206 | } |
---|
2207 | |
---|
2208 | Int pocLTCurr = rpcSlice->getPOC() - deltaPocMSBCycleLT * maxPicOrderCntLSB |
---|
2209 | - iPOClsb + pocLsbLt; |
---|
2210 | rps->setPOC (j, pocLTCurr); |
---|
2211 | rps->setDeltaPOC(j, - rpcSlice->getPOC() + pocLTCurr); |
---|
2212 | rps->setCheckLTMSBPresent(j,true); |
---|
2213 | } |
---|
2214 | else |
---|
2215 | { |
---|
2216 | rps->setPOC (j, pocLsbLt); |
---|
2217 | rps->setDeltaPOC(j, - rpcSlice->getPOC() + pocLsbLt); |
---|
2218 | rps->setCheckLTMSBPresent(j,false); |
---|
2219 | |
---|
2220 | // reset deltaPocMSBCycleLT for first LTRP from slice header if MSB not present |
---|
2221 | if( j == offset+(numOfLtrp-numLtrpInSPS)-1 ) |
---|
2222 | { |
---|
2223 | deltaPocMSBCycleLT = 0; |
---|
2224 | } |
---|
2225 | } |
---|
2226 | prevDeltaMSB = deltaPocMSBCycleLT; |
---|
2227 | } |
---|
2228 | offset += rps->getNumberOfLongtermPictures(); |
---|
2229 | rps->setNumberOfPictures(offset); |
---|
2230 | } |
---|
2231 | #if H_MV |
---|
2232 | if ( !rps->getInterRPSPrediction( ) ) |
---|
2233 | { // check sum of NumPositivePics, NumNegativePics, num_long_term_sps and num_long_term_pics |
---|
2234 | rps->checkMaxNumPics( |
---|
2235 | vps->getVpsExtensionFlag(), |
---|
2236 | vps->getMaxNumPics( rpcSlice->getLayerId() ), |
---|
2237 | rpcSlice->getLayerId(), |
---|
2238 | sps->getMaxDecPicBuffering( sps->getSpsMaxSubLayersMinus1() ) - 1 ); |
---|
2239 | } |
---|
2240 | #endif |
---|
2241 | if ( rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP |
---|
2242 | || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL |
---|
2243 | || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP ) |
---|
2244 | { |
---|
2245 | // In the case of BLA picture types, rps data is read from slice header but ignored |
---|
2246 | rps = rpcSlice->getLocalRPS(); |
---|
2247 | rps->setNumberOfNegativePictures(0); |
---|
2248 | rps->setNumberOfPositivePictures(0); |
---|
2249 | rps->setNumberOfLongtermPictures(0); |
---|
2250 | rps->setNumberOfPictures(0); |
---|
2251 | rpcSlice->setRPS(rps); |
---|
2252 | } |
---|
2253 | if (rpcSlice->getSPS()->getTMVPFlagsPresent()) |
---|
2254 | { |
---|
2255 | READ_FLAG( uiCode, "slice_temporal_mvp_enable_flag" ); |
---|
2256 | rpcSlice->setEnableTMVPFlag( uiCode == 1 ? true : false ); |
---|
2257 | } |
---|
2258 | else |
---|
2259 | { |
---|
2260 | rpcSlice->setEnableTMVPFlag(false); |
---|
2261 | } |
---|
2262 | } |
---|
2263 | #if H_MV |
---|
2264 | Bool interLayerPredLayerIdcPresentFlag = false; |
---|
2265 | Int layerId = rpcSlice->getLayerId(); |
---|
2266 | if( rpcSlice->getLayerId() > 0 && !vps->getAllRefLayersActiveFlag() && vps->getNumDirectRefLayers( layerId ) > 0 ) |
---|
2267 | { |
---|
2268 | READ_FLAG( uiCode, "inter_layer_pred_enabled_flag" ); rpcSlice->setInterLayerPredEnabledFlag( uiCode == 1 ); |
---|
2269 | if( rpcSlice->getInterLayerPredEnabledFlag() && vps->getNumDirectRefLayers( layerId ) > 1 ) |
---|
2270 | { |
---|
2271 | if( !vps->getMaxOneActiveRefLayerFlag()) |
---|
2272 | { |
---|
2273 | READ_CODE( rpcSlice->getNumInterLayerRefPicsMinus1Len( ), uiCode, "num_inter_layer_ref_pics_minus1" ); rpcSlice->setNumInterLayerRefPicsMinus1( uiCode ); |
---|
2274 | } |
---|
2275 | if ( rpcSlice->getNumActiveRefLayerPics() != vps->getNumDirectRefLayers( layerId ) ) |
---|
2276 | { |
---|
2277 | interLayerPredLayerIdcPresentFlag = true; |
---|
2278 | for( Int idx = 0; idx < rpcSlice->getNumActiveRefLayerPics(); idx++ ) |
---|
2279 | { |
---|
2280 | READ_CODE( rpcSlice->getInterLayerPredLayerIdcLen( ), uiCode, "inter_layer_pred_layer_idc" ); rpcSlice->setInterLayerPredLayerIdc( idx, uiCode ); |
---|
2281 | } |
---|
2282 | } |
---|
2283 | } |
---|
2284 | } |
---|
2285 | if ( !interLayerPredLayerIdcPresentFlag ) |
---|
2286 | { |
---|
2287 | for( Int i = 0; i < rpcSlice->getNumActiveRefLayerPics(); i++ ) |
---|
2288 | { |
---|
2289 | rpcSlice->setInterLayerPredLayerIdc( i, rpcSlice->getRefLayerPicIdc( i ) ); |
---|
2290 | } |
---|
2291 | } |
---|
2292 | #endif |
---|
2293 | if(sps->getUseSAO()) |
---|
2294 | { |
---|
2295 | READ_FLAG(uiCode, "slice_sao_luma_flag"); rpcSlice->setSaoEnabledFlag((Bool)uiCode); |
---|
2296 | READ_FLAG(uiCode, "slice_sao_chroma_flag"); rpcSlice->setSaoEnabledFlagChroma((Bool)uiCode); |
---|
2297 | } |
---|
2298 | |
---|
2299 | if (rpcSlice->getIdrPicFlag()) |
---|
2300 | { |
---|
2301 | rpcSlice->setEnableTMVPFlag(false); |
---|
2302 | } |
---|
2303 | if (!rpcSlice->isIntra()) |
---|
2304 | { |
---|
2305 | |
---|
2306 | READ_FLAG( uiCode, "num_ref_idx_active_override_flag"); |
---|
2307 | if (uiCode) |
---|
2308 | { |
---|
2309 | READ_UVLC (uiCode, "num_ref_idx_l0_active_minus1" ); rpcSlice->setNumRefIdx( REF_PIC_LIST_0, uiCode + 1 ); |
---|
2310 | if (rpcSlice->isInterB()) |
---|
2311 | { |
---|
2312 | READ_UVLC (uiCode, "num_ref_idx_l1_active_minus1" ); rpcSlice->setNumRefIdx( REF_PIC_LIST_1, uiCode + 1 ); |
---|
2313 | } |
---|
2314 | else |
---|
2315 | { |
---|
2316 | rpcSlice->setNumRefIdx(REF_PIC_LIST_1, 0); |
---|
2317 | } |
---|
2318 | } |
---|
2319 | else |
---|
2320 | { |
---|
2321 | rpcSlice->setNumRefIdx(REF_PIC_LIST_0, rpcSlice->getPPS()->getNumRefIdxL0DefaultActive()); |
---|
2322 | if (rpcSlice->isInterB()) |
---|
2323 | { |
---|
2324 | rpcSlice->setNumRefIdx(REF_PIC_LIST_1, rpcSlice->getPPS()->getNumRefIdxL1DefaultActive()); |
---|
2325 | } |
---|
2326 | else |
---|
2327 | { |
---|
2328 | rpcSlice->setNumRefIdx(REF_PIC_LIST_1,0); |
---|
2329 | } |
---|
2330 | } |
---|
2331 | } |
---|
2332 | // } |
---|
2333 | TComRefPicListModification* refPicListModification = rpcSlice->getRefPicListModification(); |
---|
2334 | if(!rpcSlice->isIntra()) |
---|
2335 | { |
---|
2336 | if( !rpcSlice->getPPS()->getListsModificationPresentFlag() || rpcSlice->getNumRpsCurrTempList() <= 1 ) |
---|
2337 | { |
---|
2338 | refPicListModification->setRefPicListModificationFlagL0( 0 ); |
---|
2339 | } |
---|
2340 | else |
---|
2341 | { |
---|
2342 | READ_FLAG( uiCode, "ref_pic_list_modification_flag_l0" ); refPicListModification->setRefPicListModificationFlagL0( uiCode ? 1 : 0 ); |
---|
2343 | } |
---|
2344 | |
---|
2345 | if(refPicListModification->getRefPicListModificationFlagL0()) |
---|
2346 | { |
---|
2347 | uiCode = 0; |
---|
2348 | Int i = 0; |
---|
2349 | Int numRpsCurrTempList0 = rpcSlice->getNumRpsCurrTempList(); |
---|
2350 | if ( numRpsCurrTempList0 > 1 ) |
---|
2351 | { |
---|
2352 | Int length = 1; |
---|
2353 | numRpsCurrTempList0 --; |
---|
2354 | while ( numRpsCurrTempList0 >>= 1) |
---|
2355 | { |
---|
2356 | length ++; |
---|
2357 | } |
---|
2358 | for (i = 0; i < rpcSlice->getNumRefIdx(REF_PIC_LIST_0); i ++) |
---|
2359 | { |
---|
2360 | READ_CODE( length, uiCode, "list_entry_l0" ); |
---|
2361 | refPicListModification->setRefPicSetIdxL0(i, uiCode ); |
---|
2362 | } |
---|
2363 | } |
---|
2364 | else |
---|
2365 | { |
---|
2366 | for (i = 0; i < rpcSlice->getNumRefIdx(REF_PIC_LIST_0); i ++) |
---|
2367 | { |
---|
2368 | refPicListModification->setRefPicSetIdxL0(i, 0 ); |
---|
2369 | } |
---|
2370 | } |
---|
2371 | } |
---|
2372 | } |
---|
2373 | else |
---|
2374 | { |
---|
2375 | refPicListModification->setRefPicListModificationFlagL0(0); |
---|
2376 | } |
---|
2377 | if(rpcSlice->isInterB()) |
---|
2378 | { |
---|
2379 | if( !rpcSlice->getPPS()->getListsModificationPresentFlag() || rpcSlice->getNumRpsCurrTempList() <= 1 ) |
---|
2380 | { |
---|
2381 | refPicListModification->setRefPicListModificationFlagL1( 0 ); |
---|
2382 | } |
---|
2383 | else |
---|
2384 | { |
---|
2385 | READ_FLAG( uiCode, "ref_pic_list_modification_flag_l1" ); refPicListModification->setRefPicListModificationFlagL1( uiCode ? 1 : 0 ); |
---|
2386 | } |
---|
2387 | if(refPicListModification->getRefPicListModificationFlagL1()) |
---|
2388 | { |
---|
2389 | uiCode = 0; |
---|
2390 | Int i = 0; |
---|
2391 | Int numRpsCurrTempList1 = rpcSlice->getNumRpsCurrTempList(); |
---|
2392 | if ( numRpsCurrTempList1 > 1 ) |
---|
2393 | { |
---|
2394 | Int length = 1; |
---|
2395 | numRpsCurrTempList1 --; |
---|
2396 | while ( numRpsCurrTempList1 >>= 1) |
---|
2397 | { |
---|
2398 | length ++; |
---|
2399 | } |
---|
2400 | for (i = 0; i < rpcSlice->getNumRefIdx(REF_PIC_LIST_1); i ++) |
---|
2401 | { |
---|
2402 | READ_CODE( length, uiCode, "list_entry_l1" ); |
---|
2403 | refPicListModification->setRefPicSetIdxL1(i, uiCode ); |
---|
2404 | } |
---|
2405 | } |
---|
2406 | else |
---|
2407 | { |
---|
2408 | for (i = 0; i < rpcSlice->getNumRefIdx(REF_PIC_LIST_1); i ++) |
---|
2409 | { |
---|
2410 | refPicListModification->setRefPicSetIdxL1(i, 0 ); |
---|
2411 | } |
---|
2412 | } |
---|
2413 | } |
---|
2414 | } |
---|
2415 | else |
---|
2416 | { |
---|
2417 | refPicListModification->setRefPicListModificationFlagL1(0); |
---|
2418 | } |
---|
2419 | if (rpcSlice->isInterB()) |
---|
2420 | { |
---|
2421 | READ_FLAG( uiCode, "mvd_l1_zero_flag" ); rpcSlice->setMvdL1ZeroFlag( (uiCode ? true : false) ); |
---|
2422 | } |
---|
2423 | |
---|
2424 | rpcSlice->setCabacInitFlag( false ); // default |
---|
2425 | if(pps->getCabacInitPresentFlag() && !rpcSlice->isIntra()) |
---|
2426 | { |
---|
2427 | READ_FLAG(uiCode, "cabac_init_flag"); |
---|
2428 | rpcSlice->setCabacInitFlag( uiCode ? true : false ); |
---|
2429 | } |
---|
2430 | |
---|
2431 | if ( rpcSlice->getEnableTMVPFlag() ) |
---|
2432 | { |
---|
2433 | if ( rpcSlice->getSliceType() == B_SLICE ) |
---|
2434 | { |
---|
2435 | READ_FLAG( uiCode, "collocated_from_l0_flag" ); |
---|
2436 | rpcSlice->setColFromL0Flag(uiCode); |
---|
2437 | } |
---|
2438 | else |
---|
2439 | { |
---|
2440 | rpcSlice->setColFromL0Flag( 1 ); |
---|
2441 | } |
---|
2442 | |
---|
2443 | if ( rpcSlice->getSliceType() != I_SLICE && |
---|
2444 | ((rpcSlice->getColFromL0Flag() == 1 && rpcSlice->getNumRefIdx(REF_PIC_LIST_0) > 1)|| |
---|
2445 | (rpcSlice->getColFromL0Flag() == 0 && rpcSlice->getNumRefIdx(REF_PIC_LIST_1) > 1))) |
---|
2446 | { |
---|
2447 | READ_UVLC( uiCode, "collocated_ref_idx" ); |
---|
2448 | rpcSlice->setColRefIdx(uiCode); |
---|
2449 | } |
---|
2450 | else |
---|
2451 | { |
---|
2452 | rpcSlice->setColRefIdx(0); |
---|
2453 | } |
---|
2454 | } |
---|
2455 | if ( (pps->getUseWP() && rpcSlice->getSliceType()==P_SLICE) || (pps->getWPBiPred() && rpcSlice->getSliceType()==B_SLICE) ) |
---|
2456 | { |
---|
2457 | xParsePredWeightTable(rpcSlice); |
---|
2458 | rpcSlice->initWpScaling(); |
---|
2459 | } |
---|
2460 | #if H_3D_IC |
---|
2461 | else if( rpcSlice->getViewIndex() && ( rpcSlice->getSliceType() == P_SLICE || rpcSlice->getSliceType() == B_SLICE ) && !rpcSlice->getIsDepth()) |
---|
2462 | { |
---|
2463 | UInt uiCodeTmp = 0; |
---|
2464 | |
---|
2465 | READ_FLAG ( uiCodeTmp, "slice_ic_enable_flag" ); |
---|
2466 | rpcSlice->setApplyIC( uiCodeTmp ); |
---|
2467 | |
---|
2468 | if ( uiCodeTmp ) |
---|
2469 | { |
---|
2470 | READ_FLAG ( uiCodeTmp, "ic_skip_mergeidx0" ); |
---|
2471 | rpcSlice->setIcSkipParseFlag( uiCodeTmp ); |
---|
2472 | } |
---|
2473 | } |
---|
2474 | #endif |
---|
2475 | if (!rpcSlice->isIntra()) |
---|
2476 | { |
---|
2477 | READ_UVLC( uiCode, "five_minus_max_num_merge_cand"); |
---|
2478 | #if H_3D_IV_MERGE |
---|
2479 | if(rpcSlice->getIsDepth()) |
---|
2480 | { |
---|
2481 | Bool bMPIFlag = rpcSlice->getVPS()->getMPIFlag( rpcSlice->getLayerIdInVps() ) ; |
---|
2482 | Bool ivMvPredFlag = rpcSlice->getVPS()->getIvMvPredFlag( rpcSlice->getLayerIdInVps() ) ; |
---|
2483 | rpcSlice->setMaxNumMergeCand(( ( bMPIFlag || ivMvPredFlag ) ? MRG_MAX_NUM_CANDS_MEM : MRG_MAX_NUM_CANDS) - uiCode); |
---|
2484 | } |
---|
2485 | else |
---|
2486 | { |
---|
2487 | Bool ivMvPredFlag = rpcSlice->getVPS()->getIvMvPredFlag( rpcSlice->getLayerIdInVps() ) ; |
---|
2488 | rpcSlice->setMaxNumMergeCand(( ivMvPredFlag ? MRG_MAX_NUM_CANDS_MEM : MRG_MAX_NUM_CANDS) - uiCode); |
---|
2489 | } |
---|
2490 | |
---|
2491 | #else |
---|
2492 | rpcSlice->setMaxNumMergeCand(MRG_MAX_NUM_CANDS - uiCode); |
---|
2493 | #endif |
---|
2494 | } |
---|
2495 | |
---|
2496 | READ_SVLC( iCode, "slice_qp_delta" ); |
---|
2497 | rpcSlice->setSliceQp (26 + pps->getPicInitQPMinus26() + iCode); |
---|
2498 | |
---|
2499 | assert( rpcSlice->getSliceQp() >= -sps->getQpBDOffsetY() ); |
---|
2500 | assert( rpcSlice->getSliceQp() <= 51 ); |
---|
2501 | |
---|
2502 | if (rpcSlice->getPPS()->getSliceChromaQpFlag()) |
---|
2503 | { |
---|
2504 | READ_SVLC( iCode, "slice_qp_delta_cb" ); |
---|
2505 | rpcSlice->setSliceQpDeltaCb( iCode ); |
---|
2506 | assert( rpcSlice->getSliceQpDeltaCb() >= -12 ); |
---|
2507 | assert( rpcSlice->getSliceQpDeltaCb() <= 12 ); |
---|
2508 | assert( (rpcSlice->getPPS()->getChromaCbQpOffset() + rpcSlice->getSliceQpDeltaCb()) >= -12 ); |
---|
2509 | assert( (rpcSlice->getPPS()->getChromaCbQpOffset() + rpcSlice->getSliceQpDeltaCb()) <= 12 ); |
---|
2510 | |
---|
2511 | READ_SVLC( iCode, "slice_qp_delta_cr" ); |
---|
2512 | rpcSlice->setSliceQpDeltaCr( iCode ); |
---|
2513 | assert( rpcSlice->getSliceQpDeltaCr() >= -12 ); |
---|
2514 | assert( rpcSlice->getSliceQpDeltaCr() <= 12 ); |
---|
2515 | assert( (rpcSlice->getPPS()->getChromaCrQpOffset() + rpcSlice->getSliceQpDeltaCr()) >= -12 ); |
---|
2516 | assert( (rpcSlice->getPPS()->getChromaCrQpOffset() + rpcSlice->getSliceQpDeltaCr()) <= 12 ); |
---|
2517 | } |
---|
2518 | |
---|
2519 | if (rpcSlice->getPPS()->getDeblockingFilterControlPresentFlag()) |
---|
2520 | { |
---|
2521 | if(rpcSlice->getPPS()->getDeblockingFilterOverrideEnabledFlag()) |
---|
2522 | { |
---|
2523 | READ_FLAG ( uiCode, "deblocking_filter_override_flag" ); rpcSlice->setDeblockingFilterOverrideFlag(uiCode ? true : false); |
---|
2524 | } |
---|
2525 | else |
---|
2526 | { |
---|
2527 | rpcSlice->setDeblockingFilterOverrideFlag(0); |
---|
2528 | } |
---|
2529 | if(rpcSlice->getDeblockingFilterOverrideFlag()) |
---|
2530 | { |
---|
2531 | READ_FLAG ( uiCode, "slice_disable_deblocking_filter_flag" ); rpcSlice->setDeblockingFilterDisable(uiCode ? 1 : 0); |
---|
2532 | if(!rpcSlice->getDeblockingFilterDisable()) |
---|
2533 | { |
---|
2534 | READ_SVLC( iCode, "slice_beta_offset_div2" ); rpcSlice->setDeblockingFilterBetaOffsetDiv2(iCode); |
---|
2535 | assert(rpcSlice->getDeblockingFilterBetaOffsetDiv2() >= -6 && |
---|
2536 | rpcSlice->getDeblockingFilterBetaOffsetDiv2() <= 6); |
---|
2537 | READ_SVLC( iCode, "slice_tc_offset_div2" ); rpcSlice->setDeblockingFilterTcOffsetDiv2(iCode); |
---|
2538 | assert(rpcSlice->getDeblockingFilterTcOffsetDiv2() >= -6 && |
---|
2539 | rpcSlice->getDeblockingFilterTcOffsetDiv2() <= 6); |
---|
2540 | } |
---|
2541 | } |
---|
2542 | else |
---|
2543 | { |
---|
2544 | rpcSlice->setDeblockingFilterDisable ( rpcSlice->getPPS()->getPicDisableDeblockingFilterFlag() ); |
---|
2545 | rpcSlice->setDeblockingFilterBetaOffsetDiv2( rpcSlice->getPPS()->getDeblockingFilterBetaOffsetDiv2() ); |
---|
2546 | rpcSlice->setDeblockingFilterTcOffsetDiv2 ( rpcSlice->getPPS()->getDeblockingFilterTcOffsetDiv2() ); |
---|
2547 | } |
---|
2548 | } |
---|
2549 | else |
---|
2550 | { |
---|
2551 | rpcSlice->setDeblockingFilterDisable ( false ); |
---|
2552 | rpcSlice->setDeblockingFilterBetaOffsetDiv2( 0 ); |
---|
2553 | rpcSlice->setDeblockingFilterTcOffsetDiv2 ( 0 ); |
---|
2554 | } |
---|
2555 | |
---|
2556 | Bool isSAOEnabled = (!rpcSlice->getSPS()->getUseSAO())?(false):(rpcSlice->getSaoEnabledFlag()||rpcSlice->getSaoEnabledFlagChroma()); |
---|
2557 | Bool isDBFEnabled = (!rpcSlice->getDeblockingFilterDisable()); |
---|
2558 | |
---|
2559 | if(rpcSlice->getPPS()->getLoopFilterAcrossSlicesEnabledFlag() && ( isSAOEnabled || isDBFEnabled )) |
---|
2560 | { |
---|
2561 | READ_FLAG( uiCode, "slice_loop_filter_across_slices_enabled_flag"); |
---|
2562 | } |
---|
2563 | else |
---|
2564 | { |
---|
2565 | uiCode = rpcSlice->getPPS()->getLoopFilterAcrossSlicesEnabledFlag()?1:0; |
---|
2566 | } |
---|
2567 | rpcSlice->setLFCrossSliceBoundaryFlag( (uiCode==1)?true:false); |
---|
2568 | |
---|
2569 | } |
---|
2570 | |
---|
2571 | UInt *entryPointOffset = NULL; |
---|
2572 | UInt numEntryPointOffsets, offsetLenMinus1; |
---|
2573 | if( pps->getTilesEnabledFlag() || pps->getEntropyCodingSyncEnabledFlag() ) |
---|
2574 | { |
---|
2575 | READ_UVLC(numEntryPointOffsets, "num_entry_point_offsets"); rpcSlice->setNumEntryPointOffsets ( numEntryPointOffsets ); |
---|
2576 | if (numEntryPointOffsets>0) |
---|
2577 | { |
---|
2578 | READ_UVLC(offsetLenMinus1, "offset_len_minus1"); |
---|
2579 | } |
---|
2580 | entryPointOffset = new UInt[numEntryPointOffsets]; |
---|
2581 | for (UInt idx=0; idx<numEntryPointOffsets; idx++) |
---|
2582 | { |
---|
2583 | READ_CODE(offsetLenMinus1+1, uiCode, "entry_point_offset_minus1"); |
---|
2584 | entryPointOffset[ idx ] = uiCode + 1; |
---|
2585 | } |
---|
2586 | } |
---|
2587 | else |
---|
2588 | { |
---|
2589 | rpcSlice->setNumEntryPointOffsets ( 0 ); |
---|
2590 | } |
---|
2591 | |
---|
2592 | #if H_3D |
---|
2593 | if( rpcSlice->getVPS()->hasCamParInSliceHeader( rpcSlice->getViewIndex() ) && !rpcSlice->getIsDepth() ) |
---|
2594 | { |
---|
2595 | UInt uiViewIndex = rpcSlice->getViewIndex(); |
---|
2596 | for( UInt uiBaseIndex = 0; uiBaseIndex < uiViewIndex; uiBaseIndex++ ) |
---|
2597 | { |
---|
2598 | READ_SVLC( iCode, "cp_scale" ); m_aaiTempScale [ uiBaseIndex ][ uiViewIndex ] = iCode; |
---|
2599 | READ_SVLC( iCode, "cp_off" ); m_aaiTempOffset[ uiBaseIndex ][ uiViewIndex ] = iCode; |
---|
2600 | READ_SVLC( iCode, "cp_inv_scale_plus_scale" ); m_aaiTempScale [ uiViewIndex ][ uiBaseIndex ] = iCode - m_aaiTempScale [ uiBaseIndex ][ uiViewIndex ]; |
---|
2601 | READ_SVLC( iCode, "cp_inv_off_plus_off" ); m_aaiTempOffset[ uiViewIndex ][ uiBaseIndex ] = iCode - m_aaiTempOffset[ uiBaseIndex ][ uiViewIndex ]; |
---|
2602 | } |
---|
2603 | rpcSlice->setCamparaSlice( m_aaiTempScale, m_aaiTempOffset ); |
---|
2604 | } |
---|
2605 | #endif |
---|
2606 | |
---|
2607 | if(pps->getSliceHeaderExtensionPresentFlag()) |
---|
2608 | { |
---|
2609 | #if H_MV |
---|
2610 | READ_UVLC( uiCode, "slice_segment_header_extension_length" ); rpcSlice->setSliceSegmentHeaderExtensionLength( uiCode ); |
---|
2611 | UInt posFollSliceSegHeaderExtLen = m_pcBitstream->getNumBitsRead(); |
---|
2612 | |
---|
2613 | if( rpcSlice->getPPS()->getPocResetInfoPresentFlag() ) |
---|
2614 | { |
---|
2615 | READ_CODE( 2, uiCode, "poc_reset_idc" ); rpcSlice->setPocResetIdc( uiCode ); |
---|
2616 | } |
---|
2617 | else |
---|
2618 | { |
---|
2619 | rpcSlice->setPocResetIdc( 0 ); |
---|
2620 | } |
---|
2621 | rpcSlice->checkPocResetIdc(); |
---|
2622 | |
---|
2623 | if ( rpcSlice->getVPS()->getPocLsbNotPresentFlag(rpcSlice->getLayerId()) && slicePicOrderCntLsb > 0 ) |
---|
2624 | { |
---|
2625 | assert( rpcSlice->getPocResetIdc() != 2 ); |
---|
2626 | } |
---|
2627 | |
---|
2628 | if( rpcSlice->getPocResetIdc() != 0 ) |
---|
2629 | { |
---|
2630 | READ_CODE( 6, uiCode, "poc_reset_period_id" ); rpcSlice->setPocResetPeriodId( uiCode ); |
---|
2631 | } |
---|
2632 | else |
---|
2633 | { |
---|
2634 | // TODO Copy poc_reset_period from earlier picture |
---|
2635 | rpcSlice->setPocResetPeriodId( 0 ); |
---|
2636 | } |
---|
2637 | |
---|
2638 | if( rpcSlice->getPocResetIdc() == 3 ) |
---|
2639 | { |
---|
2640 | READ_FLAG( uiCode, "full_poc_reset_flag" ); rpcSlice->setFullPocResetFlag( uiCode == 1 ); |
---|
2641 | READ_CODE( rpcSlice->getPocLsbValLen() , uiCode, "poc_lsb_val" ); rpcSlice->setPocLsbVal( uiCode ); |
---|
2642 | } |
---|
2643 | rpcSlice->checkPocLsbVal(); |
---|
2644 | |
---|
2645 | // Derive the value of PocMs8bValRequiredFlag |
---|
2646 | rpcSlice->setPocMsbValRequiredFlag( rpcSlice->getCraPicFlag() || rpcSlice->getBlaPicFlag() |
---|
2647 | /* || TODO related to vps_poc_lsb_aligned_flag */ |
---|
2648 | ); |
---|
2649 | |
---|
2650 | if( !rpcSlice->getPocMsbValRequiredFlag() /* TODO && rpcSlice->getVPS()->getVpsPocLsbAlignedFlag() */ ) |
---|
2651 | { |
---|
2652 | READ_FLAG( uiCode, "poc_msb_val_present_flag" ); rpcSlice->setPocMsbValPresentFlag( uiCode == 1 ); |
---|
2653 | } |
---|
2654 | else |
---|
2655 | { |
---|
2656 | rpcSlice->setPocMsbValPresentFlag( rpcSlice->inferPocMsbValPresentFlag( ) ); |
---|
2657 | } |
---|
2658 | |
---|
2659 | |
---|
2660 | if( rpcSlice->getPocMsbValPresentFlag() ) |
---|
2661 | { |
---|
2662 | READ_UVLC( uiCode, "poc_msb_val" ); rpcSlice->setPocMsbVal( uiCode ); |
---|
2663 | } |
---|
2664 | |
---|
2665 | while( ( m_pcBitstream->getNumBitsRead() - posFollSliceSegHeaderExtLen ) < rpcSlice->getSliceSegmentHeaderExtensionLength() * 8 ) |
---|
2666 | { |
---|
2667 | READ_FLAG( uiCode, "slice_segment_header_extension_data_bit" ); |
---|
2668 | } |
---|
2669 | assert( ( m_pcBitstream->getNumBitsRead() - posFollSliceSegHeaderExtLen ) == rpcSlice->getSliceSegmentHeaderExtensionLength() * 8 ); |
---|
2670 | #else |
---|
2671 | READ_UVLC( uiCode, "slice_header_extension_length" ); |
---|
2672 | for(Int i=0; i<uiCode; i++) |
---|
2673 | { |
---|
2674 | UInt ignore; |
---|
2675 | READ_CODE(8,ignore,"slice_header_extension_data_byte"); |
---|
2676 | } |
---|
2677 | #endif |
---|
2678 | } |
---|
2679 | |
---|
2680 | |
---|
2681 | m_pcBitstream->readByteAlignment(); |
---|
2682 | |
---|
2683 | if( pps->getTilesEnabledFlag() || pps->getEntropyCodingSyncEnabledFlag() ) |
---|
2684 | { |
---|
2685 | Int endOfSliceHeaderLocation = m_pcBitstream->getByteLocation(); |
---|
2686 | |
---|
2687 | // Adjust endOfSliceHeaderLocation to account for emulation prevention bytes in the slice segment header |
---|
2688 | for ( UInt curByteIdx = 0; curByteIdx<m_pcBitstream->numEmulationPreventionBytesRead(); curByteIdx++ ) |
---|
2689 | { |
---|
2690 | if ( m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) < endOfSliceHeaderLocation ) |
---|
2691 | { |
---|
2692 | endOfSliceHeaderLocation++; |
---|
2693 | } |
---|
2694 | } |
---|
2695 | |
---|
2696 | Int curEntryPointOffset = 0; |
---|
2697 | Int prevEntryPointOffset = 0; |
---|
2698 | for (UInt idx=0; idx<numEntryPointOffsets; idx++) |
---|
2699 | { |
---|
2700 | curEntryPointOffset += entryPointOffset[ idx ]; |
---|
2701 | |
---|
2702 | Int emulationPreventionByteCount = 0; |
---|
2703 | for ( UInt curByteIdx = 0; curByteIdx<m_pcBitstream->numEmulationPreventionBytesRead(); curByteIdx++ ) |
---|
2704 | { |
---|
2705 | if ( m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) >= ( prevEntryPointOffset + endOfSliceHeaderLocation ) && |
---|
2706 | m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) < ( curEntryPointOffset + endOfSliceHeaderLocation ) ) |
---|
2707 | { |
---|
2708 | emulationPreventionByteCount++; |
---|
2709 | } |
---|
2710 | } |
---|
2711 | |
---|
2712 | entryPointOffset[ idx ] -= emulationPreventionByteCount; |
---|
2713 | prevEntryPointOffset = curEntryPointOffset; |
---|
2714 | } |
---|
2715 | |
---|
2716 | if ( pps->getTilesEnabledFlag() ) |
---|
2717 | { |
---|
2718 | rpcSlice->setTileLocationCount( numEntryPointOffsets ); |
---|
2719 | |
---|
2720 | UInt prevPos = 0; |
---|
2721 | for (Int idx=0; idx<rpcSlice->getTileLocationCount(); idx++) |
---|
2722 | { |
---|
2723 | rpcSlice->setTileLocation( idx, prevPos + entryPointOffset [ idx ] ); |
---|
2724 | prevPos += entryPointOffset[ idx ]; |
---|
2725 | } |
---|
2726 | } |
---|
2727 | else if ( pps->getEntropyCodingSyncEnabledFlag() ) |
---|
2728 | { |
---|
2729 | Int numSubstreams = rpcSlice->getNumEntryPointOffsets()+1; |
---|
2730 | rpcSlice->allocSubstreamSizes(numSubstreams); |
---|
2731 | UInt *pSubstreamSizes = rpcSlice->getSubstreamSizes(); |
---|
2732 | for (Int idx=0; idx<numSubstreams-1; idx++) |
---|
2733 | { |
---|
2734 | if ( idx < numEntryPointOffsets ) |
---|
2735 | { |
---|
2736 | pSubstreamSizes[ idx ] = ( entryPointOffset[ idx ] << 3 ) ; |
---|
2737 | } |
---|
2738 | else |
---|
2739 | { |
---|
2740 | pSubstreamSizes[ idx ] = 0; |
---|
2741 | } |
---|
2742 | } |
---|
2743 | } |
---|
2744 | |
---|
2745 | if (entryPointOffset) |
---|
2746 | { |
---|
2747 | delete [] entryPointOffset; |
---|
2748 | } |
---|
2749 | } |
---|
2750 | |
---|
2751 | return; |
---|
2752 | } |
---|
2753 | |
---|
2754 | Void TDecCavlc::parsePTL( TComPTL *rpcPTL, Bool profilePresentFlag, Int maxNumSubLayersMinus1 ) |
---|
2755 | { |
---|
2756 | UInt uiCode; |
---|
2757 | if(profilePresentFlag) |
---|
2758 | { |
---|
2759 | parseProfileTier(rpcPTL->getGeneralPTL()); |
---|
2760 | } |
---|
2761 | READ_CODE( 8, uiCode, "general_level_idc" ); rpcPTL->getGeneralPTL()->setLevelIdc(uiCode); |
---|
2762 | |
---|
2763 | for (Int i = 0; i < maxNumSubLayersMinus1; i++) |
---|
2764 | { |
---|
2765 | #if !H_MV |
---|
2766 | if(profilePresentFlag) |
---|
2767 | { |
---|
2768 | #endif |
---|
2769 | READ_FLAG( uiCode, "sub_layer_profile_present_flag[i]" ); rpcPTL->setSubLayerProfilePresentFlag(i, uiCode); |
---|
2770 | #if H_MV |
---|
2771 | rpcPTL->setSubLayerProfilePresentFlag( i, profilePresentFlag && rpcPTL->getSubLayerProfilePresentFlag(i) ); |
---|
2772 | #else |
---|
2773 | } |
---|
2774 | #endif |
---|
2775 | READ_FLAG( uiCode, "sub_layer_level_present_flag[i]" ); rpcPTL->setSubLayerLevelPresentFlag (i, uiCode); |
---|
2776 | } |
---|
2777 | |
---|
2778 | if (maxNumSubLayersMinus1 > 0) |
---|
2779 | { |
---|
2780 | for (Int i = maxNumSubLayersMinus1; i < 8; i++) |
---|
2781 | { |
---|
2782 | READ_CODE(2, uiCode, "reserved_zero_2bits"); |
---|
2783 | assert(uiCode == 0); |
---|
2784 | } |
---|
2785 | } |
---|
2786 | |
---|
2787 | for(Int i = 0; i < maxNumSubLayersMinus1; i++) |
---|
2788 | { |
---|
2789 | if( profilePresentFlag && rpcPTL->getSubLayerProfilePresentFlag(i) ) |
---|
2790 | { |
---|
2791 | parseProfileTier(rpcPTL->getSubLayerPTL(i)); |
---|
2792 | } |
---|
2793 | if(rpcPTL->getSubLayerLevelPresentFlag(i)) |
---|
2794 | { |
---|
2795 | READ_CODE( 8, uiCode, "sub_layer_level_idc[i]" ); rpcPTL->getSubLayerPTL(i)->setLevelIdc(uiCode); |
---|
2796 | } |
---|
2797 | } |
---|
2798 | } |
---|
2799 | |
---|
2800 | Void TDecCavlc::parseProfileTier(ProfileTierLevel *ptl) |
---|
2801 | { |
---|
2802 | UInt uiCode; |
---|
2803 | READ_CODE(2 , uiCode, "XXX_profile_space[]"); ptl->setProfileSpace(uiCode); |
---|
2804 | READ_FLAG( uiCode, "XXX_tier_flag[]" ); ptl->setTierFlag (uiCode ? 1 : 0); |
---|
2805 | READ_CODE(5 , uiCode, "XXX_profile_idc[]" ); ptl->setProfileIdc (uiCode); |
---|
2806 | for(Int j = 0; j < 32; j++) |
---|
2807 | { |
---|
2808 | READ_FLAG( uiCode, "XXX_profile_compatibility_flag[][j]"); ptl->setProfileCompatibilityFlag(j, uiCode ? 1 : 0); |
---|
2809 | } |
---|
2810 | READ_FLAG(uiCode, "general_progressive_source_flag"); |
---|
2811 | ptl->setProgressiveSourceFlag(uiCode ? true : false); |
---|
2812 | |
---|
2813 | READ_FLAG(uiCode, "general_interlaced_source_flag"); |
---|
2814 | ptl->setInterlacedSourceFlag(uiCode ? true : false); |
---|
2815 | |
---|
2816 | READ_FLAG(uiCode, "general_non_packed_constraint_flag"); |
---|
2817 | ptl->setNonPackedConstraintFlag(uiCode ? true : false); |
---|
2818 | |
---|
2819 | READ_FLAG(uiCode, "general_frame_only_constraint_flag"); |
---|
2820 | ptl->setFrameOnlyConstraintFlag(uiCode ? true : false); |
---|
2821 | |
---|
2822 | READ_CODE(16, uiCode, "XXX_reserved_zero_44bits[0..15]"); |
---|
2823 | READ_CODE(16, uiCode, "XXX_reserved_zero_44bits[16..31]"); |
---|
2824 | READ_CODE(12, uiCode, "XXX_reserved_zero_44bits[32..43]"); |
---|
2825 | } |
---|
2826 | |
---|
2827 | Void TDecCavlc::parseTerminatingBit( UInt& ruiBit ) |
---|
2828 | { |
---|
2829 | ruiBit = false; |
---|
2830 | Int iBitsLeft = m_pcBitstream->getNumBitsLeft(); |
---|
2831 | if(iBitsLeft <= 8) |
---|
2832 | { |
---|
2833 | UInt uiPeekValue = m_pcBitstream->peekBits(iBitsLeft); |
---|
2834 | if (uiPeekValue == (1<<(iBitsLeft-1))) |
---|
2835 | { |
---|
2836 | ruiBit = true; |
---|
2837 | } |
---|
2838 | } |
---|
2839 | } |
---|
2840 | |
---|
2841 | Void TDecCavlc::parseSkipFlag( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
2842 | { |
---|
2843 | assert(0); |
---|
2844 | } |
---|
2845 | |
---|
2846 | Void TDecCavlc::parseCUTransquantBypassFlag( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
2847 | { |
---|
2848 | assert(0); |
---|
2849 | } |
---|
2850 | |
---|
2851 | Void TDecCavlc::parseMVPIdx( Int& /*riMVPIdx*/ ) |
---|
2852 | { |
---|
2853 | assert(0); |
---|
2854 | } |
---|
2855 | |
---|
2856 | Void TDecCavlc::parseSplitFlag ( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
2857 | { |
---|
2858 | assert(0); |
---|
2859 | } |
---|
2860 | |
---|
2861 | Void TDecCavlc::parsePartSize( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
2862 | { |
---|
2863 | assert(0); |
---|
2864 | } |
---|
2865 | |
---|
2866 | Void TDecCavlc::parsePredMode( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
2867 | { |
---|
2868 | assert(0); |
---|
2869 | } |
---|
2870 | |
---|
2871 | /** Parse I_PCM information. |
---|
2872 | * \param pcCU pointer to CU |
---|
2873 | * \param uiAbsPartIdx CU index |
---|
2874 | * \param uiDepth CU depth |
---|
2875 | * \returns Void |
---|
2876 | * |
---|
2877 | * If I_PCM flag indicates that the CU is I_PCM, parse its PCM alignment bits and codes. |
---|
2878 | */ |
---|
2879 | Void TDecCavlc::parseIPCMInfo( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
2880 | { |
---|
2881 | assert(0); |
---|
2882 | } |
---|
2883 | |
---|
2884 | Void TDecCavlc::parseIntraDirLumaAng ( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
2885 | { |
---|
2886 | assert(0); |
---|
2887 | } |
---|
2888 | |
---|
2889 | Void TDecCavlc::parseIntraDirChroma( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
2890 | { |
---|
2891 | assert(0); |
---|
2892 | } |
---|
2893 | |
---|
2894 | Void TDecCavlc::parseInterDir( TComDataCU* /*pcCU*/, UInt& /*ruiInterDir*/, UInt /*uiAbsPartIdx*/ ) |
---|
2895 | { |
---|
2896 | assert(0); |
---|
2897 | } |
---|
2898 | |
---|
2899 | Void TDecCavlc::parseRefFrmIdx( TComDataCU* /*pcCU*/, Int& /*riRefFrmIdx*/, RefPicList /*eRefList*/ ) |
---|
2900 | { |
---|
2901 | assert(0); |
---|
2902 | } |
---|
2903 | |
---|
2904 | Void TDecCavlc::parseMvd( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiPartIdx*/, UInt /*uiDepth*/, RefPicList /*eRefList*/ ) |
---|
2905 | { |
---|
2906 | assert(0); |
---|
2907 | } |
---|
2908 | |
---|
2909 | Void TDecCavlc::parseDeltaQP( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2910 | { |
---|
2911 | Int qp; |
---|
2912 | Int iDQp; |
---|
2913 | |
---|
2914 | xReadSvlc( iDQp ); |
---|
2915 | |
---|
2916 | Int qpBdOffsetY = pcCU->getSlice()->getSPS()->getQpBDOffsetY(); |
---|
2917 | qp = (((Int) pcCU->getRefQP( uiAbsPartIdx ) + iDQp + 52 + 2*qpBdOffsetY )%(52+ qpBdOffsetY)) - qpBdOffsetY; |
---|
2918 | |
---|
2919 | UInt uiAbsQpCUPartIdx = (uiAbsPartIdx>>((g_uiMaxCUDepth - pcCU->getSlice()->getPPS()->getMaxCuDQPDepth())<<1))<<((g_uiMaxCUDepth - pcCU->getSlice()->getPPS()->getMaxCuDQPDepth())<<1) ; |
---|
2920 | UInt uiQpCUDepth = min(uiDepth,pcCU->getSlice()->getPPS()->getMaxCuDQPDepth()) ; |
---|
2921 | |
---|
2922 | pcCU->setQPSubParts( qp, uiAbsQpCUPartIdx, uiQpCUDepth ); |
---|
2923 | } |
---|
2924 | |
---|
2925 | Void TDecCavlc::parseCoeffNxN( TComDataCU* /*pcCU*/, TCoeff* /*pcCoef*/, UInt /*uiAbsPartIdx*/, UInt /*uiWidth*/, UInt /*uiHeight*/, UInt /*uiDepth*/, TextType /*eTType*/ ) |
---|
2926 | { |
---|
2927 | assert(0); |
---|
2928 | } |
---|
2929 | |
---|
2930 | Void TDecCavlc::parseTransformSubdivFlag( UInt& /*ruiSubdivFlag*/, UInt /*uiLog2TransformBlockSize*/ ) |
---|
2931 | { |
---|
2932 | assert(0); |
---|
2933 | } |
---|
2934 | |
---|
2935 | Void TDecCavlc::parseQtCbf( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, TextType /*eType*/, UInt /*uiTrDepth*/, UInt /*uiDepth*/ ) |
---|
2936 | { |
---|
2937 | assert(0); |
---|
2938 | } |
---|
2939 | |
---|
2940 | Void TDecCavlc::parseQtRootCbf( UInt /*uiAbsPartIdx*/, UInt& /*uiQtRootCbf*/ ) |
---|
2941 | { |
---|
2942 | assert(0); |
---|
2943 | } |
---|
2944 | |
---|
2945 | Void TDecCavlc::parseTransformSkipFlags (TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*width*/, UInt /*height*/, UInt /*uiDepth*/, TextType /*eTType*/) |
---|
2946 | { |
---|
2947 | assert(0); |
---|
2948 | } |
---|
2949 | |
---|
2950 | Void TDecCavlc::parseMergeFlag ( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/, UInt /*uiPUIdx*/ ) |
---|
2951 | { |
---|
2952 | assert(0); |
---|
2953 | } |
---|
2954 | |
---|
2955 | Void TDecCavlc::parseMergeIndex ( TComDataCU* /*pcCU*/, UInt& /*ruiMergeIndex*/ ) |
---|
2956 | { |
---|
2957 | assert(0); |
---|
2958 | } |
---|
2959 | |
---|
2960 | #if H_3D_ARP |
---|
2961 | Void TDecCavlc::parseARPW( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2962 | { |
---|
2963 | assert(0); |
---|
2964 | } |
---|
2965 | #endif |
---|
2966 | #if H_3D_IC |
---|
2967 | Void TDecCavlc::parseICFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2968 | { |
---|
2969 | assert(0); |
---|
2970 | } |
---|
2971 | #endif |
---|
2972 | #if H_3D_INTER_SDC |
---|
2973 | Void TDecCavlc::parseDeltaDC( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
2974 | { |
---|
2975 | assert(0); |
---|
2976 | } |
---|
2977 | |
---|
2978 | Void TDecCavlc::parseSDCFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2979 | { |
---|
2980 | assert(0); |
---|
2981 | } |
---|
2982 | |
---|
2983 | #endif |
---|
2984 | #if H_3D_DBBP |
---|
2985 | Void TDecCavlc::parseDBBPFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2986 | { |
---|
2987 | assert(0); |
---|
2988 | } |
---|
2989 | #endif |
---|
2990 | // ==================================================================================================================== |
---|
2991 | // Protected member functions |
---|
2992 | // ==================================================================================================================== |
---|
2993 | |
---|
2994 | /** parse explicit wp tables |
---|
2995 | * \param TComSlice* pcSlice |
---|
2996 | * \returns Void |
---|
2997 | */ |
---|
2998 | Void TDecCavlc::xParsePredWeightTable( TComSlice* pcSlice ) |
---|
2999 | { |
---|
3000 | wpScalingParam *wp; |
---|
3001 | Bool bChroma = true; // color always present in HEVC ? |
---|
3002 | SliceType eSliceType = pcSlice->getSliceType(); |
---|
3003 | Int iNbRef = (eSliceType == B_SLICE ) ? (2) : (1); |
---|
3004 | UInt uiLog2WeightDenomLuma, uiLog2WeightDenomChroma; |
---|
3005 | UInt uiTotalSignalledWeightFlags = 0; |
---|
3006 | |
---|
3007 | Int iDeltaDenom; |
---|
3008 | // decode delta_luma_log2_weight_denom : |
---|
3009 | READ_UVLC( uiLog2WeightDenomLuma, "luma_log2_weight_denom" ); // ue(v): luma_log2_weight_denom |
---|
3010 | assert( uiLog2WeightDenomLuma <= 7 ); |
---|
3011 | if( bChroma ) |
---|
3012 | { |
---|
3013 | READ_SVLC( iDeltaDenom, "delta_chroma_log2_weight_denom" ); // se(v): delta_chroma_log2_weight_denom |
---|
3014 | assert((iDeltaDenom + (Int)uiLog2WeightDenomLuma)>=0); |
---|
3015 | assert((iDeltaDenom + (Int)uiLog2WeightDenomLuma)<=7); |
---|
3016 | uiLog2WeightDenomChroma = (UInt)(iDeltaDenom + uiLog2WeightDenomLuma); |
---|
3017 | } |
---|
3018 | |
---|
3019 | for ( Int iNumRef=0 ; iNumRef<iNbRef ; iNumRef++ ) |
---|
3020 | { |
---|
3021 | RefPicList eRefPicList = ( iNumRef ? REF_PIC_LIST_1 : REF_PIC_LIST_0 ); |
---|
3022 | for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ ) |
---|
3023 | { |
---|
3024 | pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); |
---|
3025 | |
---|
3026 | wp[0].uiLog2WeightDenom = uiLog2WeightDenomLuma; |
---|
3027 | wp[1].uiLog2WeightDenom = uiLog2WeightDenomChroma; |
---|
3028 | wp[2].uiLog2WeightDenom = uiLog2WeightDenomChroma; |
---|
3029 | |
---|
3030 | UInt uiCode; |
---|
3031 | READ_FLAG( uiCode, "luma_weight_lX_flag" ); // u(1): luma_weight_l0_flag |
---|
3032 | wp[0].bPresentFlag = ( uiCode == 1 ); |
---|
3033 | uiTotalSignalledWeightFlags += wp[0].bPresentFlag; |
---|
3034 | } |
---|
3035 | if ( bChroma ) |
---|
3036 | { |
---|
3037 | UInt uiCode; |
---|
3038 | for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ ) |
---|
3039 | { |
---|
3040 | pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); |
---|
3041 | READ_FLAG( uiCode, "chroma_weight_lX_flag" ); // u(1): chroma_weight_l0_flag |
---|
3042 | wp[1].bPresentFlag = ( uiCode == 1 ); |
---|
3043 | wp[2].bPresentFlag = ( uiCode == 1 ); |
---|
3044 | uiTotalSignalledWeightFlags += 2*wp[1].bPresentFlag; |
---|
3045 | } |
---|
3046 | } |
---|
3047 | for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ ) |
---|
3048 | { |
---|
3049 | pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); |
---|
3050 | if ( wp[0].bPresentFlag ) |
---|
3051 | { |
---|
3052 | Int iDeltaWeight; |
---|
3053 | READ_SVLC( iDeltaWeight, "delta_luma_weight_lX" ); // se(v): delta_luma_weight_l0[i] |
---|
3054 | assert( iDeltaWeight >= -128 ); |
---|
3055 | assert( iDeltaWeight <= 127 ); |
---|
3056 | wp[0].iWeight = (iDeltaWeight + (1<<wp[0].uiLog2WeightDenom)); |
---|
3057 | READ_SVLC( wp[0].iOffset, "luma_offset_lX" ); // se(v): luma_offset_l0[i] |
---|
3058 | assert( wp[0].iOffset >= -128 ); |
---|
3059 | assert( wp[0].iOffset <= 127 ); |
---|
3060 | } |
---|
3061 | else |
---|
3062 | { |
---|
3063 | wp[0].iWeight = (1 << wp[0].uiLog2WeightDenom); |
---|
3064 | wp[0].iOffset = 0; |
---|
3065 | } |
---|
3066 | if ( bChroma ) |
---|
3067 | { |
---|
3068 | if ( wp[1].bPresentFlag ) |
---|
3069 | { |
---|
3070 | for ( Int j=1 ; j<3 ; j++ ) |
---|
3071 | { |
---|
3072 | Int iDeltaWeight; |
---|
3073 | READ_SVLC( iDeltaWeight, "delta_chroma_weight_lX" ); // se(v): chroma_weight_l0[i][j] |
---|
3074 | assert( iDeltaWeight >= -128 ); |
---|
3075 | assert( iDeltaWeight <= 127 ); |
---|
3076 | wp[j].iWeight = (iDeltaWeight + (1<<wp[1].uiLog2WeightDenom)); |
---|
3077 | |
---|
3078 | Int iDeltaChroma; |
---|
3079 | READ_SVLC( iDeltaChroma, "delta_chroma_offset_lX" ); // se(v): delta_chroma_offset_l0[i][j] |
---|
3080 | assert( iDeltaChroma >= -512 ); |
---|
3081 | assert( iDeltaChroma <= 511 ); |
---|
3082 | Int pred = ( 128 - ( ( 128*wp[j].iWeight)>>(wp[j].uiLog2WeightDenom) ) ); |
---|
3083 | wp[j].iOffset = Clip3(-128, 127, (iDeltaChroma + pred) ); |
---|
3084 | } |
---|
3085 | } |
---|
3086 | else |
---|
3087 | { |
---|
3088 | for ( Int j=1 ; j<3 ; j++ ) |
---|
3089 | { |
---|
3090 | wp[j].iWeight = (1 << wp[j].uiLog2WeightDenom); |
---|
3091 | wp[j].iOffset = 0; |
---|
3092 | } |
---|
3093 | } |
---|
3094 | } |
---|
3095 | } |
---|
3096 | |
---|
3097 | for ( Int iRefIdx=pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx<MAX_NUM_REF ; iRefIdx++ ) |
---|
3098 | { |
---|
3099 | pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); |
---|
3100 | |
---|
3101 | wp[0].bPresentFlag = false; |
---|
3102 | wp[1].bPresentFlag = false; |
---|
3103 | wp[2].bPresentFlag = false; |
---|
3104 | } |
---|
3105 | } |
---|
3106 | assert(uiTotalSignalledWeightFlags<=24); |
---|
3107 | } |
---|
3108 | |
---|
3109 | /** decode quantization matrix |
---|
3110 | * \param scalingList quantization matrix information |
---|
3111 | */ |
---|
3112 | Void TDecCavlc::parseScalingList(TComScalingList* scalingList) |
---|
3113 | { |
---|
3114 | UInt code, sizeId, listId; |
---|
3115 | Bool scalingListPredModeFlag; |
---|
3116 | //for each size |
---|
3117 | for(sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
3118 | { |
---|
3119 | for(listId = 0; listId < g_scalingListNum[sizeId]; listId++) |
---|
3120 | { |
---|
3121 | READ_FLAG( code, "scaling_list_pred_mode_flag"); |
---|
3122 | scalingListPredModeFlag = (code) ? true : false; |
---|
3123 | if(!scalingListPredModeFlag) //Copy Mode |
---|
3124 | { |
---|
3125 | READ_UVLC( code, "scaling_list_pred_matrix_id_delta"); |
---|
3126 | scalingList->setRefMatrixId (sizeId,listId,(UInt)((Int)(listId)-(code))); |
---|
3127 | if( sizeId > SCALING_LIST_8x8 ) |
---|
3128 | { |
---|
3129 | scalingList->setScalingListDC(sizeId,listId,((listId == scalingList->getRefMatrixId (sizeId,listId))? 16 :scalingList->getScalingListDC(sizeId, scalingList->getRefMatrixId (sizeId,listId)))); |
---|
3130 | } |
---|
3131 | scalingList->processRefMatrix( sizeId, listId, scalingList->getRefMatrixId (sizeId,listId)); |
---|
3132 | |
---|
3133 | } |
---|
3134 | else //DPCM Mode |
---|
3135 | { |
---|
3136 | xDecodeScalingList(scalingList, sizeId, listId); |
---|
3137 | } |
---|
3138 | } |
---|
3139 | } |
---|
3140 | |
---|
3141 | return; |
---|
3142 | } |
---|
3143 | /** decode DPCM |
---|
3144 | * \param scalingList quantization matrix information |
---|
3145 | * \param sizeId size index |
---|
3146 | * \param listId list index |
---|
3147 | */ |
---|
3148 | Void TDecCavlc::xDecodeScalingList(TComScalingList *scalingList, UInt sizeId, UInt listId) |
---|
3149 | { |
---|
3150 | Int i,coefNum = min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId]); |
---|
3151 | Int data; |
---|
3152 | Int scalingListDcCoefMinus8 = 0; |
---|
3153 | Int nextCoef = SCALING_LIST_START_VALUE; |
---|
3154 | UInt* scan = (sizeId == 0) ? g_auiSigLastScan [ SCAN_DIAG ] [ 1 ] : g_sigLastScanCG32x32; |
---|
3155 | Int *dst = scalingList->getScalingListAddress(sizeId, listId); |
---|
3156 | |
---|
3157 | if( sizeId > SCALING_LIST_8x8 ) |
---|
3158 | { |
---|
3159 | READ_SVLC( scalingListDcCoefMinus8, "scaling_list_dc_coef_minus8"); |
---|
3160 | scalingList->setScalingListDC(sizeId,listId,scalingListDcCoefMinus8 + 8); |
---|
3161 | nextCoef = scalingList->getScalingListDC(sizeId,listId); |
---|
3162 | } |
---|
3163 | |
---|
3164 | for(i = 0; i < coefNum; i++) |
---|
3165 | { |
---|
3166 | READ_SVLC( data, "scaling_list_delta_coef"); |
---|
3167 | nextCoef = (nextCoef + data + 256 ) % 256; |
---|
3168 | dst[scan[i]] = nextCoef; |
---|
3169 | } |
---|
3170 | } |
---|
3171 | |
---|
3172 | Bool TDecCavlc::xMoreRbspData() |
---|
3173 | { |
---|
3174 | Int bitsLeft = m_pcBitstream->getNumBitsLeft(); |
---|
3175 | |
---|
3176 | // if there are more than 8 bits, it cannot be rbsp_trailing_bits |
---|
3177 | if (bitsLeft > 8) |
---|
3178 | { |
---|
3179 | return true; |
---|
3180 | } |
---|
3181 | |
---|
3182 | UChar lastByte = m_pcBitstream->peekBits(bitsLeft); |
---|
3183 | Int cnt = bitsLeft; |
---|
3184 | |
---|
3185 | // remove trailing bits equal to zero |
---|
3186 | while ((cnt>0) && ((lastByte & 1) == 0)) |
---|
3187 | { |
---|
3188 | lastByte >>= 1; |
---|
3189 | cnt--; |
---|
3190 | } |
---|
3191 | // remove bit equal to one |
---|
3192 | cnt--; |
---|
3193 | |
---|
3194 | // we should not have a negative number of bits |
---|
3195 | assert (cnt>=0); |
---|
3196 | |
---|
3197 | // we have more data, if cnt is not zero |
---|
3198 | return (cnt>0); |
---|
3199 | } |
---|
3200 | |
---|
3201 | //! \} |
---|
3202 | |
---|