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