1 | /* The copyright in this software is being made available under the BSD |
---|
2 | * License, included below. This software may be subject to other third party |
---|
3 | * and contributor rights, including patent rights, and no such rights are |
---|
4 | * granted under this license. |
---|
5 | * |
---|
6 | * Copyright (c) 2010-2013, ITU/ISO/IEC |
---|
7 | * All rights reserved. |
---|
8 | * |
---|
9 | * Redistribution and use in source and binary forms, with or without |
---|
10 | * modification, are permitted provided that the following conditions are met: |
---|
11 | * |
---|
12 | * * Redistributions of source code must retain the above copyright notice, |
---|
13 | * this list of conditions and the following disclaimer. |
---|
14 | * * Redistributions in binary form must reproduce the above copyright notice, |
---|
15 | * this list of conditions and the following disclaimer in the documentation |
---|
16 | * and/or other materials provided with the distribution. |
---|
17 | * * Neither the name of the ITU/ISO/IEC nor the names of its contributors may |
---|
18 | * be used to endorse or promote products derived from this software without |
---|
19 | * specific prior written permission. |
---|
20 | * |
---|
21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
---|
22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
---|
23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
---|
24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS |
---|
25 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
---|
26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
---|
27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
---|
28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
---|
29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
---|
30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
---|
31 | * THE POSSIBILITY OF SUCH DAMAGE. |
---|
32 | */ |
---|
33 | |
---|
34 | /** \file TDecCAVLC.cpp |
---|
35 | \brief CAVLC decoder class |
---|
36 | */ |
---|
37 | |
---|
38 | #include "TDecCAVLC.h" |
---|
39 | #include "SEIread.h" |
---|
40 | #include "TDecSlice.h" |
---|
41 | |
---|
42 | //! \ingroup TLibDecoder |
---|
43 | //! \{ |
---|
44 | |
---|
45 | #if ENC_DEC_TRACE |
---|
46 | |
---|
47 | Void xTraceSPSHeader (TComSPS *pSPS) |
---|
48 | { |
---|
49 | #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 | Int maxCUDepthDelta = uiCode; |
---|
851 | pcSPS->setMaxCUWidth ( 1<<(log2MinCUSize + maxCUDepthDelta) ); |
---|
852 | pcSPS->setMaxCUHeight ( 1<<(log2MinCUSize + maxCUDepthDelta) ); |
---|
853 | READ_UVLC( uiCode, "log2_min_transform_block_size_minus2" ); pcSPS->setQuadtreeTULog2MinSize( uiCode + 2 ); |
---|
854 | |
---|
855 | READ_UVLC( uiCode, "log2_diff_max_min_transform_block_size" ); pcSPS->setQuadtreeTULog2MaxSize( uiCode + pcSPS->getQuadtreeTULog2MinSize() ); |
---|
856 | pcSPS->setMaxTrSize( 1<<(uiCode + pcSPS->getQuadtreeTULog2MinSize()) ); |
---|
857 | |
---|
858 | READ_UVLC( uiCode, "max_transform_hierarchy_depth_inter" ); pcSPS->setQuadtreeTUMaxDepthInter( uiCode+1 ); |
---|
859 | READ_UVLC( uiCode, "max_transform_hierarchy_depth_intra" ); pcSPS->setQuadtreeTUMaxDepthIntra( uiCode+1 ); |
---|
860 | |
---|
861 | Int addCuDepth = max (0, log2MinCUSize - (Int)pcSPS->getQuadtreeTULog2MinSize() ); |
---|
862 | pcSPS->setMaxCUDepth( maxCUDepthDelta + addCuDepth ); |
---|
863 | |
---|
864 | READ_FLAG( uiCode, "scaling_list_enabled_flag" ); pcSPS->setScalingListFlag ( uiCode ); |
---|
865 | if(pcSPS->getScalingListFlag()) |
---|
866 | { |
---|
867 | #if H_MV |
---|
868 | if ( pcSPS->getLayerId() > 0 ) |
---|
869 | { |
---|
870 | READ_FLAG( uiCode, "sps_infer_scaling_list_flag" ); pcSPS->setSpsInferScalingListFlag( uiCode == 1 ); |
---|
871 | } |
---|
872 | |
---|
873 | if ( pcSPS->getSpsInferScalingListFlag() ) |
---|
874 | { |
---|
875 | READ_CODE( 6, uiCode, "sps_scaling_list_ref_layer_id" ); pcSPS->setSpsScalingListRefLayerId( uiCode ); |
---|
876 | } |
---|
877 | else |
---|
878 | { |
---|
879 | #endif |
---|
880 | READ_FLAG( uiCode, "sps_scaling_list_data_present_flag" ); pcSPS->setScalingListPresentFlag ( uiCode ); |
---|
881 | if(pcSPS->getScalingListPresentFlag ()) |
---|
882 | { |
---|
883 | parseScalingList( pcSPS->getScalingList() ); |
---|
884 | } |
---|
885 | #if H_MV |
---|
886 | } |
---|
887 | #endif |
---|
888 | } |
---|
889 | READ_FLAG( uiCode, "amp_enabled_flag" ); pcSPS->setUseAMP( uiCode ); |
---|
890 | READ_FLAG( uiCode, "sample_adaptive_offset_enabled_flag" ); pcSPS->setUseSAO ( uiCode ? true : false ); |
---|
891 | |
---|
892 | READ_FLAG( uiCode, "pcm_enabled_flag" ); pcSPS->setUsePCM( uiCode ? true : false ); |
---|
893 | if( pcSPS->getUsePCM() ) |
---|
894 | { |
---|
895 | READ_CODE( 4, uiCode, "pcm_sample_bit_depth_luma_minus1" ); pcSPS->setPCMBitDepthLuma ( 1 + uiCode ); |
---|
896 | READ_CODE( 4, uiCode, "pcm_sample_bit_depth_chroma_minus1" ); pcSPS->setPCMBitDepthChroma ( 1 + uiCode ); |
---|
897 | READ_UVLC( uiCode, "log2_min_pcm_luma_coding_block_size_minus3" ); pcSPS->setPCMLog2MinSize (uiCode+3); |
---|
898 | READ_UVLC( uiCode, "log2_diff_max_min_pcm_luma_coding_block_size" ); pcSPS->setPCMLog2MaxSize ( uiCode+pcSPS->getPCMLog2MinSize() ); |
---|
899 | READ_FLAG( uiCode, "pcm_loop_filter_disable_flag" ); pcSPS->setPCMFilterDisableFlag ( uiCode ? true : false ); |
---|
900 | } |
---|
901 | |
---|
902 | READ_UVLC( uiCode, "num_short_term_ref_pic_sets" ); |
---|
903 | assert(uiCode <= 64); |
---|
904 | pcSPS->createRPSList(uiCode); |
---|
905 | |
---|
906 | TComRPSList* rpsList = pcSPS->getRPSList(); |
---|
907 | TComReferencePictureSet* rps; |
---|
908 | |
---|
909 | for(UInt i=0; i< rpsList->getNumberOfReferencePictureSets(); i++) |
---|
910 | { |
---|
911 | rps = rpsList->getReferencePictureSet(i); |
---|
912 | parseShortTermRefPicSet(pcSPS,rps,i); |
---|
913 | } |
---|
914 | READ_FLAG( uiCode, "long_term_ref_pics_present_flag" ); pcSPS->setLongTermRefsPresent(uiCode); |
---|
915 | if (pcSPS->getLongTermRefsPresent()) |
---|
916 | { |
---|
917 | READ_UVLC( uiCode, "num_long_term_ref_pic_sps" ); |
---|
918 | pcSPS->setNumLongTermRefPicSPS(uiCode); |
---|
919 | for (UInt k = 0; k < pcSPS->getNumLongTermRefPicSPS(); k++) |
---|
920 | { |
---|
921 | READ_CODE( pcSPS->getBitsForPOC(), uiCode, "lt_ref_pic_poc_lsb_sps" ); |
---|
922 | pcSPS->setLtRefPicPocLsbSps(k, uiCode); |
---|
923 | READ_FLAG( uiCode, "used_by_curr_pic_lt_sps_flag[i]"); |
---|
924 | pcSPS->setUsedByCurrPicLtSPSFlag(k, uiCode?1:0); |
---|
925 | } |
---|
926 | } |
---|
927 | READ_FLAG( uiCode, "sps_temporal_mvp_enable_flag" ); pcSPS->setTMVPFlagsPresent(uiCode); |
---|
928 | |
---|
929 | READ_FLAG( uiCode, "sps_strong_intra_smoothing_enable_flag" ); pcSPS->setUseStrongIntraSmoothing(uiCode); |
---|
930 | |
---|
931 | READ_FLAG( uiCode, "vui_parameters_present_flag" ); pcSPS->setVuiParametersPresentFlag(uiCode); |
---|
932 | |
---|
933 | if (pcSPS->getVuiParametersPresentFlag()) |
---|
934 | { |
---|
935 | parseVUI(pcSPS->getVuiParameters(), pcSPS); |
---|
936 | } |
---|
937 | |
---|
938 | READ_FLAG( uiCode, "sps_extension_flag"); |
---|
939 | #if H_MV |
---|
940 | pcSPS->setSpsExtensionFlag( uiCode ); |
---|
941 | if (pcSPS->getSpsExtensionFlag( ) ) |
---|
942 | #else |
---|
943 | if (uiCode) |
---|
944 | #endif |
---|
945 | { |
---|
946 | #if H_MV |
---|
947 | for (Int i = 0; i < PS_EX_T_MAX_NUM; i++) |
---|
948 | { |
---|
949 | READ_FLAG( uiCode, "sps_extension_type_flag" ); pcSPS->setSpsExtensionTypeFlag( i, uiCode ); |
---|
950 | #if H_3D |
---|
951 | assert( !pcSPS->getSpsExtensionTypeFlag( i ) || i == PS_EX_T_MV || i == PS_EX_T_3D || i == PS_EX_T_ESC ); |
---|
952 | #else |
---|
953 | assert( !pcSPS->getSpsExtensionTypeFlag( i ) || i == PS_EX_T_MV || i == PS_EX_T_ESC ); |
---|
954 | #endif |
---|
955 | } |
---|
956 | |
---|
957 | if( pcSPS->getSpsExtensionTypeFlag( PS_EX_T_MV )) |
---|
958 | { |
---|
959 | parseSPSExtension( pcSPS ); |
---|
960 | } |
---|
961 | |
---|
962 | #if H_3D |
---|
963 | if( pcSPS->getSpsExtensionTypeFlag( PS_EX_T_3D )) |
---|
964 | { |
---|
965 | parseSPSExtension2( pcSPS, viewIndex, depthFlag ); |
---|
966 | } |
---|
967 | #endif |
---|
968 | |
---|
969 | if ( pcSPS->getSpsExtensionTypeFlag( PS_EX_T_ESC )) |
---|
970 | { |
---|
971 | #endif |
---|
972 | while ( xMoreRbspData() ) |
---|
973 | { |
---|
974 | READ_FLAG( uiCode, "sps_extension_data_flag"); |
---|
975 | } |
---|
976 | #if H_MV |
---|
977 | } |
---|
978 | #endif |
---|
979 | } |
---|
980 | } |
---|
981 | |
---|
982 | #if H_MV |
---|
983 | Void TDecCavlc::parseSPSExtension( TComSPS* pcSPS ) |
---|
984 | { |
---|
985 | UInt uiCode; |
---|
986 | READ_FLAG( uiCode, "inter_view_mv_vert_constraint_flag" ); pcSPS->setInterViewMvVertConstraintFlag(uiCode == 1 ? true : false); |
---|
987 | |
---|
988 | READ_UVLC( uiCode, "num_scaled_ref_layer_offsets" ); pcSPS->setNumScaledRefLayerOffsets( uiCode ); |
---|
989 | |
---|
990 | for( Int i = 0; i < pcSPS->getNumScaledRefLayerOffsets( ); i++) |
---|
991 | { |
---|
992 | READ_CODE( 6, uiCode, "scaled_ref_layer_id" ); pcSPS->setScaledRefLayerId( i, uiCode ); |
---|
993 | |
---|
994 | Int j = pcSPS->getScaledRefLayerId( i ); |
---|
995 | Int iCode; |
---|
996 | READ_SVLC( iCode, "scaled_ref_layer_left_offset" ); pcSPS->setScaledRefLayerLeftOffset( j, iCode ); |
---|
997 | READ_SVLC( iCode, "scaled_ref_layer_top_offset" ); pcSPS->setScaledRefLayerTopOffset( j, iCode ); |
---|
998 | READ_SVLC( iCode, "scaled_ref_layer_right_offset" ); pcSPS->setScaledRefLayerRightOffset( j, iCode ); |
---|
999 | READ_SVLC( iCode, "scaled_ref_layer_bottom_offset" ); pcSPS->setScaledRefLayerBottomOffset( j, iCode ); |
---|
1000 | } |
---|
1001 | } |
---|
1002 | |
---|
1003 | #if H_3D |
---|
1004 | Void TDecCavlc::parseSPSExtension2( TComSPS* pcSPS, Int viewIndex, Bool depthFlag ) |
---|
1005 | { |
---|
1006 | UInt uiCode; |
---|
1007 | #if H_3D_QTLPC |
---|
1008 | //GT: This has to go to VPS |
---|
1009 | if( depthFlag ) |
---|
1010 | { |
---|
1011 | READ_FLAG( uiCode, "use_qtl_flag" ); |
---|
1012 | pcSPS->setUseQTL( uiCode ); |
---|
1013 | READ_FLAG( uiCode, "use_pc_flag" ); |
---|
1014 | pcSPS->setUsePC( uiCode ); |
---|
1015 | } |
---|
1016 | #endif |
---|
1017 | } |
---|
1018 | #endif |
---|
1019 | #endif |
---|
1020 | |
---|
1021 | Void TDecCavlc::parseVPS(TComVPS* pcVPS) |
---|
1022 | { |
---|
1023 | UInt uiCode; |
---|
1024 | |
---|
1025 | READ_CODE( 4, uiCode, "vps_video_parameter_set_id" ); pcVPS->setVPSId( uiCode ); |
---|
1026 | READ_CODE( 2, uiCode, "vps_reserved_three_2bits" ); assert(uiCode == 3); |
---|
1027 | #if H_MV |
---|
1028 | READ_CODE( 6, uiCode, "vps_max_layers_minus1" ); pcVPS->setMaxLayersMinus1( std::min( uiCode, (UInt) ( MAX_NUM_LAYER_IDS-1) ) ); |
---|
1029 | #else |
---|
1030 | READ_CODE( 6, uiCode, "vps_reserved_zero_6bits" ); assert(uiCode == 0); |
---|
1031 | #endif |
---|
1032 | READ_CODE( 3, uiCode, "vps_max_sub_layers_minus1" ); pcVPS->setMaxTLayers( uiCode + 1 ); |
---|
1033 | READ_FLAG( uiCode, "vps_temporal_id_nesting_flag" ); pcVPS->setTemporalNestingFlag( uiCode ? true:false ); |
---|
1034 | assert (pcVPS->getMaxTLayers()>1||pcVPS->getTemporalNestingFlag()); |
---|
1035 | #if H_MV |
---|
1036 | READ_CODE( 16, uiCode, "vps_extension_offset" ); |
---|
1037 | #else |
---|
1038 | READ_CODE( 16, uiCode, "vps_reserved_ffff_16bits" ); assert(uiCode == 0xffff); |
---|
1039 | #endif |
---|
1040 | parsePTL ( pcVPS->getPTL(), true, pcVPS->getMaxTLayers()-1); |
---|
1041 | UInt subLayerOrderingInfoPresentFlag; |
---|
1042 | READ_FLAG(subLayerOrderingInfoPresentFlag, "vps_sub_layer_ordering_info_present_flag"); |
---|
1043 | for(UInt i = 0; i <= pcVPS->getMaxTLayers()-1; i++) |
---|
1044 | { |
---|
1045 | READ_UVLC( uiCode, "vps_max_dec_pic_buffering_minus1[i]" ); pcVPS->setMaxDecPicBuffering( uiCode + 1, i ); |
---|
1046 | READ_UVLC( uiCode, "vps_num_reorder_pics[i]" ); pcVPS->setNumReorderPics( uiCode, i ); |
---|
1047 | READ_UVLC( uiCode, "vps_max_latency_increase_plus1[i]" ); pcVPS->setMaxLatencyIncrease( uiCode, i ); |
---|
1048 | |
---|
1049 | if (!subLayerOrderingInfoPresentFlag) |
---|
1050 | { |
---|
1051 | for (i++; i <= pcVPS->getMaxTLayers()-1; i++) |
---|
1052 | { |
---|
1053 | pcVPS->setMaxDecPicBuffering(pcVPS->getMaxDecPicBuffering(0), i); |
---|
1054 | pcVPS->setNumReorderPics(pcVPS->getNumReorderPics(0), i); |
---|
1055 | pcVPS->setMaxLatencyIncrease(pcVPS->getMaxLatencyIncrease(0), i); |
---|
1056 | } |
---|
1057 | break; |
---|
1058 | } |
---|
1059 | } |
---|
1060 | |
---|
1061 | assert( pcVPS->getNumHrdParameters() < MAX_VPS_OP_SETS_PLUS1 ); |
---|
1062 | #if H_MV |
---|
1063 | assert( pcVPS->getVpsMaxLayerId() < MAX_VPS_NUH_LAYER_ID_PLUS1 ); |
---|
1064 | READ_CODE( 6, uiCode, "vps_max_layer_id" ); pcVPS->setVpsMaxLayerId( uiCode ); |
---|
1065 | |
---|
1066 | READ_UVLC( uiCode, "vps_max_num_layer_sets_minus1" ); pcVPS->setVpsNumLayerSetsMinus1( uiCode ); |
---|
1067 | for( UInt opsIdx = 1; opsIdx <= pcVPS->getVpsNumLayerSetsMinus1(); opsIdx ++ ) |
---|
1068 | { |
---|
1069 | for( UInt i = 0; i <= pcVPS->getVpsMaxLayerId(); i ++ ) |
---|
1070 | #else |
---|
1071 | assert( pcVPS->getMaxNuhReservedZeroLayerId() < MAX_VPS_NUH_RESERVED_ZERO_LAYER_ID_PLUS1 ); |
---|
1072 | READ_CODE( 6, uiCode, "vps_max_nuh_reserved_zero_layer_id" ); pcVPS->setMaxNuhReservedZeroLayerId( uiCode ); |
---|
1073 | READ_UVLC( uiCode, "vps_max_op_sets_minus1" ); pcVPS->setMaxOpSets( uiCode + 1 ); |
---|
1074 | for( UInt opsIdx = 1; opsIdx <= ( pcVPS->getMaxOpSets() - 1 ); opsIdx ++ ) |
---|
1075 | { |
---|
1076 | // Operation point set |
---|
1077 | for( UInt i = 0; i <= pcVPS->getMaxNuhReservedZeroLayerId(); i ++ ) |
---|
1078 | #endif |
---|
1079 | { |
---|
1080 | READ_FLAG( uiCode, "layer_id_included_flag[opsIdx][i]" ); pcVPS->setLayerIdIncludedFlag( uiCode == 1 ? true : false, opsIdx, i ); |
---|
1081 | } |
---|
1082 | } |
---|
1083 | #if H_MV |
---|
1084 | pcVPS->deriveLayerSetLayerIdList(); |
---|
1085 | #endif |
---|
1086 | TimingInfo *timingInfo = pcVPS->getTimingInfo(); |
---|
1087 | READ_FLAG( uiCode, "vps_timing_info_present_flag"); timingInfo->setTimingInfoPresentFlag (uiCode ? true : false); |
---|
1088 | if(timingInfo->getTimingInfoPresentFlag()) |
---|
1089 | { |
---|
1090 | READ_CODE( 32, uiCode, "vps_num_units_in_tick"); timingInfo->setNumUnitsInTick (uiCode); |
---|
1091 | READ_CODE( 32, uiCode, "vps_time_scale"); timingInfo->setTimeScale (uiCode); |
---|
1092 | READ_FLAG( uiCode, "vps_poc_proportional_to_timing_flag"); timingInfo->setPocProportionalToTimingFlag(uiCode ? true : false); |
---|
1093 | if(timingInfo->getPocProportionalToTimingFlag()) |
---|
1094 | { |
---|
1095 | READ_UVLC( uiCode, "vps_num_ticks_poc_diff_one_minus1"); timingInfo->setNumTicksPocDiffOneMinus1 (uiCode); |
---|
1096 | } |
---|
1097 | READ_UVLC( uiCode, "vps_num_hrd_parameters" ); pcVPS->setNumHrdParameters( uiCode ); |
---|
1098 | |
---|
1099 | if( pcVPS->getNumHrdParameters() > 0 ) |
---|
1100 | { |
---|
1101 | pcVPS->createHrdParamBuffer(); |
---|
1102 | } |
---|
1103 | for( UInt i = 0; i < pcVPS->getNumHrdParameters(); i ++ ) |
---|
1104 | { |
---|
1105 | READ_UVLC( uiCode, "hrd_op_set_idx" ); pcVPS->setHrdOpSetIdx( uiCode, i ); |
---|
1106 | if( i > 0 ) |
---|
1107 | { |
---|
1108 | READ_FLAG( uiCode, "cprms_present_flag[i]" ); pcVPS->setCprmsPresentFlag( uiCode == 1 ? true : false, i ); |
---|
1109 | } |
---|
1110 | parseHrdParameters(pcVPS->getHrdParameters(i), pcVPS->getCprmsPresentFlag( i ), pcVPS->getMaxTLayers() - 1); |
---|
1111 | } |
---|
1112 | } |
---|
1113 | READ_FLAG( uiCode, "vps_extension_flag" ); |
---|
1114 | if (uiCode) |
---|
1115 | { |
---|
1116 | #if H_MV |
---|
1117 | m_pcBitstream->readOutTrailingBits(); |
---|
1118 | parseVPSExtension( pcVPS ); |
---|
1119 | READ_FLAG( uiCode, "vps_extension2_flag" ); |
---|
1120 | if (uiCode) |
---|
1121 | { |
---|
1122 | #if H_3D |
---|
1123 | m_pcBitstream->readOutTrailingBits(); |
---|
1124 | pcVPS->createCamPars(pcVPS->getNumViews()); |
---|
1125 | parseVPSExtension2( pcVPS ); |
---|
1126 | READ_FLAG( uiCode, "vps_extension3_flag" ); |
---|
1127 | if (uiCode) |
---|
1128 | { |
---|
1129 | #endif |
---|
1130 | #endif |
---|
1131 | while ( xMoreRbspData() ) |
---|
1132 | { |
---|
1133 | READ_FLAG( uiCode, "vps_extension_data_flag"); |
---|
1134 | } |
---|
1135 | #if H_MV |
---|
1136 | #if H_3D |
---|
1137 | } |
---|
1138 | #endif |
---|
1139 | } |
---|
1140 | #endif |
---|
1141 | } |
---|
1142 | return; |
---|
1143 | } |
---|
1144 | |
---|
1145 | #if H_MV |
---|
1146 | Void TDecCavlc::parseVPSExtension( TComVPS* pcVPS ) |
---|
1147 | { |
---|
1148 | UInt uiCode; |
---|
1149 | READ_FLAG( uiCode, "avc_base_layer_flag" ); pcVPS->setAvcBaseLayerFlag( uiCode == 1 ? true : false ); |
---|
1150 | READ_FLAG( uiCode, "vps_vui_present_flag" ); pcVPS->setVpsVuiPresentFlag( uiCode == 1 ); if ( pcVPS->getVpsVuiPresentFlag() ) |
---|
1151 | { |
---|
1152 | READ_CODE( 16, uiCode, "vps_vui_offset" ); pcVPS->setVpsVuiOffset( uiCode ); |
---|
1153 | } |
---|
1154 | |
---|
1155 | READ_FLAG( uiCode, "splitting_flag" ); pcVPS->setSplittingFlag( uiCode == 1 ? true : false ); |
---|
1156 | |
---|
1157 | for( Int sIdx = 0; sIdx < MAX_NUM_SCALABILITY_TYPES; sIdx++ ) |
---|
1158 | { |
---|
1159 | READ_FLAG( uiCode, "scalability_mask_flag[i]" ); pcVPS->setScalabilityMaskFlag( sIdx, uiCode == 1 ? true : false ); |
---|
1160 | } |
---|
1161 | |
---|
1162 | for( Int sIdx = 0; sIdx < pcVPS->getNumScalabilityTypes( ) - ( pcVPS->getSplittingFlag() ? 1 : 0 ); sIdx++ ) |
---|
1163 | { |
---|
1164 | READ_CODE( 3, uiCode, "dimension_id_len_minus1[j]" ); pcVPS->setDimensionIdLen( sIdx, uiCode + 1 ); |
---|
1165 | } |
---|
1166 | |
---|
1167 | if ( pcVPS->getSplittingFlag() ) |
---|
1168 | { |
---|
1169 | pcVPS->setDimensionIdLen( pcVPS->getNumScalabilityTypes( ) - 1, pcVPS->inferLastDimsionIdLenMinus1() ); |
---|
1170 | } |
---|
1171 | |
---|
1172 | READ_FLAG( uiCode, "vps_nuh_layer_id_present_flag" ); pcVPS->setVpsNuhLayerIdPresentFlag( uiCode == 1 ? true : false ); |
---|
1173 | |
---|
1174 | for( Int i = 1; i <= pcVPS->getMaxLayersMinus1(); i++ ) |
---|
1175 | { |
---|
1176 | if ( pcVPS->getVpsNuhLayerIdPresentFlag() ) |
---|
1177 | { |
---|
1178 | READ_CODE( 6, uiCode, "layer_id_in_nuh[i]" ); pcVPS->setLayerIdInNuh( i, uiCode ); |
---|
1179 | } |
---|
1180 | else |
---|
1181 | { |
---|
1182 | pcVPS->setLayerIdInNuh( i, i );; |
---|
1183 | } |
---|
1184 | |
---|
1185 | pcVPS->setLayerIdInVps( pcVPS->getLayerIdInNuh( i ), i ); |
---|
1186 | |
---|
1187 | for( Int j = 0; j < pcVPS->getNumScalabilityTypes() ; j++ ) |
---|
1188 | { |
---|
1189 | if ( !pcVPS->getSplittingFlag() ) |
---|
1190 | { |
---|
1191 | READ_CODE( pcVPS->getDimensionIdLen( j ), uiCode, "dimension_id[i][j]" ); pcVPS->setDimensionId( i, j, uiCode ); |
---|
1192 | } |
---|
1193 | else |
---|
1194 | { |
---|
1195 | pcVPS->setDimensionId( i, j, pcVPS->inferDimensionId( i, j) ); |
---|
1196 | } |
---|
1197 | } |
---|
1198 | } |
---|
1199 | |
---|
1200 | READ_CODE( 4, uiCode, "view_id_len" ); pcVPS->setViewIdLen( uiCode ); |
---|
1201 | |
---|
1202 | if ( pcVPS->getViewIdLen( ) > 0 ) |
---|
1203 | { |
---|
1204 | for( Int i = 0; i < pcVPS->getNumViews(); i++ ) |
---|
1205 | { |
---|
1206 | READ_CODE( pcVPS->getViewIdLen( ), uiCode, "view_id_val[i]" ); pcVPS->setViewIdVal( i, uiCode ); |
---|
1207 | } |
---|
1208 | } |
---|
1209 | else |
---|
1210 | { |
---|
1211 | for( Int i = 0; i < pcVPS->getNumViews(); i++ ) |
---|
1212 | { |
---|
1213 | pcVPS->setViewIdVal( i, 0 ); |
---|
1214 | } |
---|
1215 | } |
---|
1216 | |
---|
1217 | |
---|
1218 | for( Int i = 1; i <= pcVPS->getMaxLayersMinus1(); i++ ) |
---|
1219 | { |
---|
1220 | for( Int j = 0; j < i; j++ ) |
---|
1221 | { |
---|
1222 | READ_FLAG( uiCode, "direct_dependency_flag[i][j]" ); pcVPS->setDirectDependencyFlag( i, j, uiCode ); |
---|
1223 | } |
---|
1224 | } |
---|
1225 | pcVPS->setRefLayers(); |
---|
1226 | READ_FLAG( uiCode, "vps_sub_layers_max_minus1_present_flag" ); pcVPS->setVpsSubLayersMaxMinus1PresentFlag( uiCode == 1 ); |
---|
1227 | if ( pcVPS->getVpsSubLayersMaxMinus1PresentFlag() ) |
---|
1228 | { |
---|
1229 | for (Int i = 0; i < pcVPS->getMaxLayersMinus1(); i++ ) |
---|
1230 | { |
---|
1231 | READ_CODE( 3, uiCode, "sub_layers_vps_max_minus1" ); pcVPS->setSubLayersVpsMaxMinus1( i, uiCode ); |
---|
1232 | pcVPS->checkSubLayersVpsMaxMinus1( i ); |
---|
1233 | |
---|
1234 | } |
---|
1235 | } |
---|
1236 | else |
---|
1237 | { |
---|
1238 | for (Int i = 0; i < pcVPS->getMaxLayersMinus1(); i++ ) |
---|
1239 | { |
---|
1240 | pcVPS->setSubLayersVpsMaxMinus1( i, pcVPS->getMaxTLayers( ) - 1); |
---|
1241 | } |
---|
1242 | } |
---|
1243 | READ_FLAG( uiCode, "max_tid_ref_present_flag" ); pcVPS->setMaxTidRefPresentFlag( uiCode == 1 ); |
---|
1244 | |
---|
1245 | if ( pcVPS->getMaxTidRefPresentFlag() ) |
---|
1246 | { |
---|
1247 | for( Int i = 0; i < pcVPS->getMaxLayersMinus1(); i++ ) |
---|
1248 | { |
---|
1249 | for( Int j = i + 1; j <= pcVPS->getMaxLayersMinus1(); j++ ) |
---|
1250 | { |
---|
1251 | if ( pcVPS->getDirectDependencyFlag(j,i) ) |
---|
1252 | { |
---|
1253 | READ_CODE( 3, uiCode, "max_tid_il_ref_pics_plus1" ); pcVPS->setMaxTidIlRefPicsPlus1( i, j, uiCode ); |
---|
1254 | } |
---|
1255 | } |
---|
1256 | } |
---|
1257 | } |
---|
1258 | |
---|
1259 | READ_FLAG( uiCode, "all_ref_layers_active_flag" ); pcVPS->setAllRefLayersActiveFlag( uiCode == 1 ); |
---|
1260 | READ_CODE( 10, uiCode, "vps_number_layer_sets_minus1" ); pcVPS->setVpsNumberLayerSetsMinus1 ( uiCode ); |
---|
1261 | READ_CODE( 6, uiCode, "vps_num_profile_tier_level_minus1" ); pcVPS->setVpsNumProfileTierLevelMinus1( uiCode ); |
---|
1262 | |
---|
1263 | for( Int i = 1; i <= pcVPS->getVpsNumProfileTierLevelMinus1(); i++ ) |
---|
1264 | { |
---|
1265 | READ_FLAG( uiCode, "vps_profile_present_flag[i]" ); pcVPS->setVpsProfilePresentFlag( i, uiCode == 1 ); |
---|
1266 | if( !pcVPS->getVpsProfilePresentFlag( i ) ) |
---|
1267 | { |
---|
1268 | READ_CODE( 6, uiCode, "profile_ref_minus1[i]" ); pcVPS->setProfileRefMinus1( i, uiCode ); |
---|
1269 | pcVPS->checkProfileRefMinus1( i ); |
---|
1270 | } |
---|
1271 | parsePTL ( pcVPS->getPTL( i ), pcVPS->getVpsProfilePresentFlag( i ), pcVPS->getMaxTLayers()-1); |
---|
1272 | if( !pcVPS->getVpsProfilePresentFlag( i ) ) |
---|
1273 | { |
---|
1274 | TComPTL temp = *pcVPS->getPTL( i ); |
---|
1275 | *pcVPS->getPTL( i ) = *pcVPS->getPTL( pcVPS->getProfileRefMinus1( i ) + 1 ); |
---|
1276 | pcVPS->getPTL( i )->copyLevelFrom( &temp ); |
---|
1277 | } |
---|
1278 | } |
---|
1279 | |
---|
1280 | Int numOutputLayerSets = pcVPS->getVpsNumberLayerSetsMinus1( ) + 1; |
---|
1281 | |
---|
1282 | READ_FLAG( uiCode, "more_output_layer_sets_than_default_flag" ); pcVPS->setMoreOutputLayerSetsThanDefaultFlag( uiCode == 1 ); |
---|
1283 | |
---|
1284 | if ( pcVPS->getMoreOutputLayerSetsThanDefaultFlag( ) ) |
---|
1285 | { |
---|
1286 | READ_CODE( 10, uiCode, "num_add_output_layer_sets_minus1" ); pcVPS->setNumAddOutputLayerSetsMinus1( uiCode ); |
---|
1287 | numOutputLayerSets += ( pcVPS->getNumAddOutputLayerSetsMinus1( ) + 1); |
---|
1288 | } |
---|
1289 | |
---|
1290 | if( numOutputLayerSets > 1) |
---|
1291 | { |
---|
1292 | READ_CODE( 2, uiCode, "default_one_target_output_layer_idc" ); pcVPS->setDefaultOneTargetOutputLayerIdc( uiCode ); |
---|
1293 | pcVPS->checkDefaultOneTargetOutputLayerIdc(); |
---|
1294 | } |
---|
1295 | |
---|
1296 | pcVPS->setOutputLayerFlag(0, 0, pcVPS->inferOutputLayerFlag( 0, 0 )); |
---|
1297 | pcVPS->setOutputLayerSetIdxMinus1(0, -1); |
---|
1298 | for( Int i = 1; i < numOutputLayerSets; i++ ) |
---|
1299 | { |
---|
1300 | if( i > pcVPS->getVpsNumberLayerSetsMinus1( ) ) |
---|
1301 | { |
---|
1302 | READ_UVLC( uiCode, "output_layer_set_idx_minus1[i]" ); pcVPS->setOutputLayerSetIdxMinus1( i, uiCode ); |
---|
1303 | for( Int j = 0; j < pcVPS->getNumLayersInIdList( j ) - 1; j++ ) |
---|
1304 | { |
---|
1305 | READ_FLAG( uiCode, "output_layer_flag" ); pcVPS->setOutputLayerFlag( i, j, uiCode == 1 ); |
---|
1306 | } |
---|
1307 | } |
---|
1308 | else |
---|
1309 | { // These inference rules would also be helpful in spec text |
---|
1310 | pcVPS->setOutputLayerSetIdxMinus1(i, i - 1 ); |
---|
1311 | for( Int j = 0; j < pcVPS->getNumLayersInIdList( j ) - 1; j++ ) |
---|
1312 | { |
---|
1313 | pcVPS->setOutputLayerFlag(i,j, pcVPS->inferOutputLayerFlag( i, j )); |
---|
1314 | } |
---|
1315 | } |
---|
1316 | |
---|
1317 | if ( pcVPS->getProfileLevelTierIdxLen() > 0 ) |
---|
1318 | { |
---|
1319 | READ_CODE( pcVPS->getProfileLevelTierIdxLen(), uiCode,"profile_level_tier_idx[ i ]" ); pcVPS->setProfileLevelTierIdx( i , uiCode ); |
---|
1320 | } |
---|
1321 | } |
---|
1322 | if( pcVPS->getMaxLayersMinus1() > 0 ) |
---|
1323 | { |
---|
1324 | READ_FLAG( uiCode, "alt_output_layer_flag" ); pcVPS->setAltOutputLayerFlag( uiCode == 1 ); |
---|
1325 | } |
---|
1326 | pcVPS->deriveTargetLayerIdLists(); |
---|
1327 | READ_FLAG( uiCode, "rep_format_idx_present_flag" ); pcVPS->setRepFormatIdxPresentFlag( uiCode == 1 ); |
---|
1328 | if ( pcVPS->getRepFormatIdxPresentFlag() ) |
---|
1329 | { |
---|
1330 | READ_CODE( 4, uiCode, "vps_num_rep_formats_minus1" ); pcVPS->setVpsNumRepFormatsMinus1( uiCode ); |
---|
1331 | } |
---|
1332 | |
---|
1333 | for (Int i = 0; i <= pcVPS->getVpsNumRepFormatsMinus1(); i++ ) |
---|
1334 | { |
---|
1335 | assert( pcVPS->getRepFormat(i) == NULL ); |
---|
1336 | TComRepFormat* curRepFormat = new TComRepFormat(); |
---|
1337 | TComRepFormat* prevRepFormat = i > 0 ? pcVPS->getRepFormat( i - 1) : NULL; |
---|
1338 | parseRepFormat( i, curRepFormat , prevRepFormat); |
---|
1339 | pcVPS->setRepFormat(i, curRepFormat ); |
---|
1340 | } |
---|
1341 | |
---|
1342 | if( pcVPS->getRepFormatIdxPresentFlag() ) |
---|
1343 | { |
---|
1344 | for( Int i = 1; i <= pcVPS->getMaxLayersMinus1(); i++ ) |
---|
1345 | { |
---|
1346 | if( pcVPS->getVpsNumRepFormatsMinus1() > 0 ) |
---|
1347 | { |
---|
1348 | READ_CODE( 8, uiCode, "vps_rep_format_idx" ); pcVPS->setVpsRepFormatIdx( i, uiCode ); |
---|
1349 | } |
---|
1350 | } |
---|
1351 | } |
---|
1352 | |
---|
1353 | READ_FLAG( uiCode, "max_one_active_ref_layer_flag" ); pcVPS->setMaxOneActiveRefLayerFlag ( uiCode == 1 ); |
---|
1354 | for( Int i = 1; i <= pcVPS->getMaxLayersMinus1(); i++ ) |
---|
1355 | { |
---|
1356 | if( pcVPS->getNumDirectRefLayers( pcVPS->getLayerIdInNuh( i ) ) == 0 ) |
---|
1357 | { |
---|
1358 | READ_FLAG( uiCode, "poc_lsb_not_present_flag" ); pcVPS->setPocLsbNotPresentFlag( i, uiCode == 1 ); |
---|
1359 | } |
---|
1360 | } |
---|
1361 | |
---|
1362 | parseDpbSize( pcVPS ); |
---|
1363 | |
---|
1364 | READ_UVLC( uiCode, "direct_dep_type_len_minus2") ; pcVPS->setDirectDepTypeLenMinus2 ( uiCode ); |
---|
1365 | |
---|
1366 | READ_FLAG( uiCode, "default_direct_dependency_flag" ); pcVPS->setDefaultDirectDependencyFlag( uiCode == 1 ); |
---|
1367 | if ( pcVPS->getDefaultDirectDependencyFlag( ) ) |
---|
1368 | { |
---|
1369 | READ_CODE( pcVPS->getDirectDepTypeLenMinus2( ) + 2, uiCode, "default_direct_dependency_type" ); pcVPS->setDefaultDirectDependencyType( uiCode ); |
---|
1370 | } |
---|
1371 | |
---|
1372 | for( Int i = 1; i <= pcVPS->getMaxLayersMinus1(); i++ ) |
---|
1373 | { |
---|
1374 | for( Int j = 0; j < i; j++ ) |
---|
1375 | { |
---|
1376 | if (pcVPS->getDirectDependencyFlag( i, j) ) |
---|
1377 | { |
---|
1378 | if ( pcVPS->getDefaultDirectDependencyFlag( ) ) |
---|
1379 | { |
---|
1380 | pcVPS->setDirectDependencyType( i, j , pcVPS->getDefaultDirectDependencyType( ) ); |
---|
1381 | } |
---|
1382 | else |
---|
1383 | { |
---|
1384 | READ_CODE( pcVPS->getDirectDepTypeLenMinus2( ) + 2, uiCode, "direct_dependency_type[i][j]" ); pcVPS->setDirectDependencyType( i, j , uiCode); |
---|
1385 | } |
---|
1386 | } |
---|
1387 | } |
---|
1388 | } |
---|
1389 | |
---|
1390 | READ_FLAG( uiCode, "vps_shvc_reserved_zero_flag" ); |
---|
1391 | |
---|
1392 | if( pcVPS->getVpsVuiPresentFlag() ) |
---|
1393 | { |
---|
1394 | m_pcBitstream->readOutTrailingBits(); // vps_vui_alignment_bit_equal_to_one |
---|
1395 | parseVPSVUI( pcVPS ); |
---|
1396 | } |
---|
1397 | |
---|
1398 | pcVPS->checkVPSExtensionSyntax(); |
---|
1399 | } |
---|
1400 | |
---|
1401 | Void TDecCavlc::parseRepFormat( Int i, TComRepFormat* pcRepFormat, TComRepFormat* pcPrevRepFormat ) |
---|
1402 | { |
---|
1403 | assert( pcRepFormat ); |
---|
1404 | |
---|
1405 | UInt uiCode; |
---|
1406 | |
---|
1407 | READ_CODE( 16, uiCode, "pic_width_vps_in_luma_samples" ); pcRepFormat->setPicWidthVpsInLumaSamples ( uiCode ); |
---|
1408 | READ_CODE( 16, uiCode, "pic_height_vps_in_luma_samples" ); pcRepFormat->setPicHeightVpsInLumaSamples( uiCode ); |
---|
1409 | READ_FLAG( uiCode, "chroma_and_bit_depth_vps_present_flag" ); pcRepFormat->setChromaAndBitDepthVpsPresentFlag( uiCode == 1 ); |
---|
1410 | |
---|
1411 | pcRepFormat->checkChromaAndBitDepthVpsPresentFlag( i ); |
---|
1412 | |
---|
1413 | if ( pcRepFormat->getChromaAndBitDepthVpsPresentFlag() ) |
---|
1414 | { |
---|
1415 | READ_CODE( 2, uiCode, "chroma_format_vps_idc" ); pcRepFormat->setChromaFormatVpsIdc ( uiCode ); |
---|
1416 | if ( pcRepFormat->getChromaFormatVpsIdc() == 3 ) |
---|
1417 | { |
---|
1418 | READ_FLAG( uiCode, "separate_colour_plane_vps_flag" ); pcRepFormat->setSeparateColourPlaneVpsFlag( uiCode == 1 ); |
---|
1419 | } |
---|
1420 | READ_CODE( 4, uiCode, "bit_depth_vps_luma_minus8" ); pcRepFormat->setBitDepthVpsLumaMinus8 ( uiCode ); |
---|
1421 | READ_CODE( 4, uiCode, "bit_depth_vps_chroma_minus8" ); pcRepFormat->setBitDepthVpsChromaMinus8 ( uiCode ); |
---|
1422 | } |
---|
1423 | else |
---|
1424 | { |
---|
1425 | pcRepFormat->inferChromaAndBitDepth(pcPrevRepFormat, false ); |
---|
1426 | } |
---|
1427 | } |
---|
1428 | |
---|
1429 | |
---|
1430 | Void TDecCavlc::parseVPSVUI( TComVPS* pcVPS ) |
---|
1431 | { |
---|
1432 | assert( pcVPS ); |
---|
1433 | |
---|
1434 | TComVPSVUI* pcVPSVUI = pcVPS->getVPSVUI( ); |
---|
1435 | |
---|
1436 | assert( pcVPSVUI ); |
---|
1437 | |
---|
1438 | UInt uiCode; |
---|
1439 | READ_FLAG( uiCode, "cross_layer_pic_type_aligned_flag" ); pcVPSVUI->setCrossLayerPicTypeAlignedFlag( uiCode == 1 ); |
---|
1440 | if ( !pcVPSVUI->getCrossLayerPicTypeAlignedFlag() ) |
---|
1441 | { |
---|
1442 | READ_FLAG( uiCode, "cross_layer_irap_aligned_flag" ); pcVPSVUI->setCrossLayerIrapAlignedFlag( uiCode == 1 ); |
---|
1443 | } |
---|
1444 | READ_FLAG( uiCode, "bit_rate_present_vps_flag" ); pcVPSVUI->setBitRatePresentVpsFlag( uiCode == 1 ); |
---|
1445 | READ_FLAG( uiCode, "pic_rate_present_vps_flag" ); pcVPSVUI->setPicRatePresentVpsFlag( uiCode == 1 ); |
---|
1446 | if( pcVPSVUI->getBitRatePresentVpsFlag( ) || pcVPSVUI->getPicRatePresentVpsFlag( ) ) |
---|
1447 | { |
---|
1448 | for( Int i = 0; i <= pcVPS->getVpsNumberLayerSetsMinus1(); i++ ) |
---|
1449 | { |
---|
1450 | for( Int j = 0; j <= pcVPS->getMaxTLayers(); j++ ) |
---|
1451 | { |
---|
1452 | if( pcVPSVUI->getBitRatePresentVpsFlag( ) ) |
---|
1453 | { |
---|
1454 | READ_FLAG( uiCode, "bit_rate_present_flag" ); pcVPSVUI->setBitRatePresentFlag( i, j, uiCode == 1 ); |
---|
1455 | } |
---|
1456 | if( pcVPSVUI->getPicRatePresentVpsFlag( ) ) |
---|
1457 | { |
---|
1458 | READ_FLAG( uiCode, "pic_rate_present_flag" ); pcVPSVUI->setPicRatePresentFlag( i, j, uiCode == 1 ); |
---|
1459 | } |
---|
1460 | if( pcVPSVUI->getBitRatePresentFlag( i, j ) ) |
---|
1461 | { |
---|
1462 | READ_CODE( 16, uiCode, "avg_bit_rate" ); pcVPSVUI->setAvgBitRate( i, j, uiCode ); |
---|
1463 | READ_CODE( 16, uiCode, "max_bit_rate" ); pcVPSVUI->setMaxBitRate( i, j, uiCode ); |
---|
1464 | } |
---|
1465 | if( pcVPSVUI->getPicRatePresentFlag( i, j ) ) |
---|
1466 | { |
---|
1467 | READ_CODE( 2, uiCode, "constant_pic_rate_idc" ); pcVPSVUI->setConstantPicRateIdc( i, j, uiCode ); |
---|
1468 | READ_CODE( 16, uiCode, "avg_pic_rate" ); pcVPSVUI->setAvgPicRate( i, j, uiCode ); |
---|
1469 | } |
---|
1470 | } |
---|
1471 | } |
---|
1472 | } |
---|
1473 | |
---|
1474 | READ_FLAG( uiCode, "tiles_not_in_use_flag" ); pcVPSVUI->setTilesNotInUseFlag( uiCode == 1 ); |
---|
1475 | if( !pcVPSVUI->getTilesNotInUseFlag() ) |
---|
1476 | { |
---|
1477 | for( Int i = 0; i <= pcVPS->getMaxLayersMinus1(); i++ ) |
---|
1478 | { |
---|
1479 | READ_FLAG( uiCode, "tiles_in_use_flag[i]" ); pcVPSVUI->setTilesInUseFlag( i, uiCode == 1 ); |
---|
1480 | if( pcVPSVUI->getTilesInUseFlag( i ) ) |
---|
1481 | { |
---|
1482 | READ_FLAG( uiCode, "loop_filter_not_across_tiles_flag[i]" ); pcVPSVUI->setLoopFilterNotAcrossTilesFlag( i, uiCode == 1 ); |
---|
1483 | } |
---|
1484 | } |
---|
1485 | |
---|
1486 | for( Int i = 1; i <= pcVPS->getMaxLayersMinus1(); i++ ) |
---|
1487 | { |
---|
1488 | for( Int j = 0; j < pcVPS->getNumDirectRefLayers( pcVPS->getLayerIdInNuh( i ) ) ; j++ ) |
---|
1489 | { |
---|
1490 | Int layerIdx = pcVPS->getLayerIdInVps(pcVPS->getRefLayerId(pcVPS->getLayerIdInNuh( i ) , j )); |
---|
1491 | if( pcVPSVUI->getTilesInUseFlag( i ) && pcVPSVUI->getTilesInUseFlag( layerIdx ) ) |
---|
1492 | { |
---|
1493 | READ_FLAG( uiCode, "tile_boundaries_aligned_flag[i][j]" ); pcVPSVUI->setTileBoundariesAlignedFlag( i, j, uiCode == 1 ); |
---|
1494 | } |
---|
1495 | } |
---|
1496 | } |
---|
1497 | } |
---|
1498 | |
---|
1499 | READ_FLAG( uiCode, "wpp_not_in_use_flag" ); pcVPSVUI->setWppNotInUseFlag( uiCode == 1 ); |
---|
1500 | |
---|
1501 | if( !pcVPSVUI->getWppNotInUseFlag( )) |
---|
1502 | { |
---|
1503 | for( Int i = 0; i <= pcVPS->getMaxLayersMinus1(); i++ ) |
---|
1504 | { |
---|
1505 | READ_FLAG( uiCode, "wpp_in_use_flag[i]" ); pcVPSVUI->setWppInUseFlag( i, uiCode == 1 ); |
---|
1506 | } |
---|
1507 | } |
---|
1508 | |
---|
1509 | READ_FLAG( uiCode, "ilp_restricted_ref_layers_flag" ); pcVPSVUI->setIlpRestrictedRefLayersFlag( uiCode == 1 ); |
---|
1510 | |
---|
1511 | if( pcVPSVUI->getIlpRestrictedRefLayersFlag( ) ) |
---|
1512 | { |
---|
1513 | for( Int i = 1; i <= pcVPS->getMaxLayersMinus1(); i++ ) |
---|
1514 | { |
---|
1515 | for( Int j = 0; j < pcVPS->getNumDirectRefLayers( pcVPS->getLayerIdInNuh( i ) ); j++ ) |
---|
1516 | { |
---|
1517 | READ_UVLC( uiCode, "min_spatial_segment_offset_plus1" ); pcVPSVUI->setMinSpatialSegmentOffsetPlus1( i, j, uiCode ); |
---|
1518 | if( pcVPSVUI->getMinSpatialSegmentOffsetPlus1( i, j ) > 0 ) |
---|
1519 | { |
---|
1520 | READ_FLAG( uiCode, "ctu_based_offset_enabled_flag" ); pcVPSVUI->setCtuBasedOffsetEnabledFlag( i, j, uiCode == 1 ); |
---|
1521 | if( pcVPSVUI->getCtuBasedOffsetEnabledFlag( i, j ) ) |
---|
1522 | { |
---|
1523 | READ_UVLC( uiCode, "min_horizontal_ctu_offset_plus1" ); pcVPSVUI->setMinHorizontalCtuOffsetPlus1( i, j, uiCode ); |
---|
1524 | } |
---|
1525 | } |
---|
1526 | } |
---|
1527 | } |
---|
1528 | } |
---|
1529 | |
---|
1530 | READ_FLAG( uiCode, "video_signal_info_idx_present_flag" ); pcVPSVUI->setVideoSignalInfoIdxPresentFlag( uiCode == 1 ); |
---|
1531 | if( pcVPSVUI->getVideoSignalInfoIdxPresentFlag() ) |
---|
1532 | { |
---|
1533 | READ_CODE( 4, uiCode, "vps_num_video_signal_info_minus1" ); pcVPSVUI->setVpsNumVideoSignalInfoMinus1( uiCode ); |
---|
1534 | } |
---|
1535 | else |
---|
1536 | { |
---|
1537 | pcVPSVUI->setVpsNumVideoSignalInfoMinus1( pcVPS->getMaxLayersMinus1() ); |
---|
1538 | } |
---|
1539 | |
---|
1540 | for( Int i = 0; i <= pcVPSVUI->getVpsNumVideoSignalInfoMinus1(); i++ ) |
---|
1541 | { |
---|
1542 | assert( pcVPSVUI->getVideoSignalInfo( i ) == NULL ); |
---|
1543 | TComVideoSignalInfo* curVideoSignalInfo = new TComVideoSignalInfo(); |
---|
1544 | parseVideoSignalInfo( curVideoSignalInfo ); |
---|
1545 | pcVPSVUI->setVideoSignalInfo(i, curVideoSignalInfo ); |
---|
1546 | } |
---|
1547 | |
---|
1548 | if( pcVPSVUI->getVideoSignalInfoIdxPresentFlag() && pcVPSVUI->getVpsNumVideoSignalInfoMinus1() > 0 ) |
---|
1549 | { |
---|
1550 | for( Int i = 1; i <= pcVPS->getMaxLayersMinus1(); i++ ) |
---|
1551 | { |
---|
1552 | READ_CODE( 4, uiCode, "vps_video_signal_info_idx" ); pcVPSVUI->setVpsVideoSignalInfoIdx( i, uiCode ); |
---|
1553 | assert( pcVPSVUI->getVpsVideoSignalInfoIdx( i ) >= 0 && pcVPSVUI->getVpsVideoSignalInfoIdx( i ) <= pcVPSVUI->getVpsNumVideoSignalInfoMinus1() ); |
---|
1554 | } |
---|
1555 | } |
---|
1556 | else |
---|
1557 | { |
---|
1558 | for( Int i = 1; i <= pcVPS->getMaxLayersMinus1(); i++ ) |
---|
1559 | { |
---|
1560 | pcVPSVUI->setVpsVideoSignalInfoIdx( i, pcVPSVUI->getVideoSignalInfoIdxPresentFlag() ? 0 : i ); |
---|
1561 | } |
---|
1562 | } |
---|
1563 | READ_FLAG( uiCode, "vps_vui_bsp_hrd_present_flag" ); pcVPSVUI->setVpsVuiBspHrdPresentFlag( uiCode == 1 ); |
---|
1564 | if ( pcVPSVUI->getVpsVuiBspHrdPresentFlag( ) ) |
---|
1565 | { |
---|
1566 | parseVpsVuiBspHrdParameters( pcVPS ); |
---|
1567 | } |
---|
1568 | } |
---|
1569 | |
---|
1570 | Void TDecCavlc::parseVpsVuiBspHrdParameters( TComVPS* pcVPS ) |
---|
1571 | { |
---|
1572 | assert( pcVPS ); |
---|
1573 | |
---|
1574 | TComVPSVUI* pcVPSVUI = pcVPS->getVPSVUI( ); |
---|
1575 | |
---|
1576 | assert( pcVPSVUI ); |
---|
1577 | |
---|
1578 | TComVpsVuiBspHrdParameters* vpsVuiBspHrdP = pcVPSVUI->getVpsVuiBspHrdParameters(); |
---|
1579 | |
---|
1580 | assert ( vpsVuiBspHrdP ); |
---|
1581 | |
---|
1582 | UInt uiCode; |
---|
1583 | READ_UVLC( uiCode, "vps_num_bsp_hrd_parameters_minus1" ); vpsVuiBspHrdP->setVpsNumBspHrdParametersMinus1( uiCode ); |
---|
1584 | for( Int i = 0; i <= vpsVuiBspHrdP->getVpsNumBspHrdParametersMinus1( ); i++ ) |
---|
1585 | { |
---|
1586 | if( i > 0 ) |
---|
1587 | { |
---|
1588 | READ_FLAG( uiCode, "bsp_cprms_present_flag" ); vpsVuiBspHrdP->setBspCprmsPresentFlag( i, uiCode == 1 ); |
---|
1589 | } |
---|
1590 | TComHRD* hrdParameters = vpsVuiBspHrdP->getHrdParametermeters( i ); |
---|
1591 | parseHrdParameters( hrdParameters, vpsVuiBspHrdP->getBspCprmsPresentFlag( i ), pcVPS->getMaxSubLayersMinus1() ); |
---|
1592 | } |
---|
1593 | for( Int h = 1; h <= pcVPS->getVpsNumLayerSetsMinus1(); h++ ) |
---|
1594 | { |
---|
1595 | READ_UVLC( uiCode, "num_bitstream_partitions" ); vpsVuiBspHrdP->setNumBitstreamPartitions( h, uiCode ); |
---|
1596 | for( Int i = 0; i < vpsVuiBspHrdP->getNumBitstreamPartitions( h ); i++ ) |
---|
1597 | { |
---|
1598 | for( Int j = 0; j <= pcVPS->getMaxLayersMinus1(); j++ ) |
---|
1599 | { |
---|
1600 | if( pcVPS->getLayerIdIncludedFlag( h ,j ) ) |
---|
1601 | { |
---|
1602 | READ_FLAG( uiCode, "layer_in_bsp_flag" ); vpsVuiBspHrdP->setLayerInBspFlag( h, i, j, uiCode == 1 ); |
---|
1603 | } |
---|
1604 | else |
---|
1605 | { |
---|
1606 | vpsVuiBspHrdP->setLayerInBspFlag( h, i, j, false ); // This inference seems to be missing in spec |
---|
1607 | } |
---|
1608 | } |
---|
1609 | } |
---|
1610 | vpsVuiBspHrdP->checkLayerInBspFlag( pcVPS, h ); |
---|
1611 | |
---|
1612 | if( vpsVuiBspHrdP->getNumBitstreamPartitions( h ) ) |
---|
1613 | { |
---|
1614 | READ_UVLC( uiCode, "num_bsp_sched_combinations" ); vpsVuiBspHrdP->setNumBspSchedCombinations( h, uiCode ); |
---|
1615 | for( Int i = 0; i < vpsVuiBspHrdP->getNumBspSchedCombinations( h ); i++ ) |
---|
1616 | { |
---|
1617 | for( Int j = 0; j < vpsVuiBspHrdP->getNumBitstreamPartitions( h ); j++ ) |
---|
1618 | { |
---|
1619 | READ_UVLC( uiCode, "bsp_comb_hrd_idx" ); vpsVuiBspHrdP->setBspCombHrdIdx( h, i, j, uiCode ); |
---|
1620 | READ_UVLC( uiCode, "bsp_comb_sched_idx" ); vpsVuiBspHrdP->setBspCombSchedIdx( h, i, j, uiCode ); |
---|
1621 | } |
---|
1622 | } |
---|
1623 | } |
---|
1624 | } |
---|
1625 | } |
---|
1626 | |
---|
1627 | Void TDecCavlc::parseVideoSignalInfo( TComVideoSignalInfo* pcVideoSignalInfo ) |
---|
1628 | { |
---|
1629 | UInt uiCode; |
---|
1630 | READ_CODE( 3, uiCode, "video_vps_format" ); pcVideoSignalInfo->setVideoVpsFormat( uiCode ); |
---|
1631 | READ_FLAG( uiCode, "video_full_range_vps_flag" ); pcVideoSignalInfo->setVideoFullRangeVpsFlag( uiCode == 1 ); |
---|
1632 | READ_CODE( 8, uiCode, "colour_primaries_vps" ); pcVideoSignalInfo->setColourPrimariesVps( uiCode ); |
---|
1633 | READ_CODE( 8, uiCode, "transfer_characteristics_vps" ); pcVideoSignalInfo->setTransferCharacteristicsVps( uiCode ); |
---|
1634 | READ_CODE( 8, uiCode, "matrix_coeffs_vps" ); pcVideoSignalInfo->setMatrixCoeffsVps( uiCode ); |
---|
1635 | } |
---|
1636 | |
---|
1637 | Void TDecCavlc::parseDpbSize( TComVPS* vps ) |
---|
1638 | { |
---|
1639 | UInt uiCode; |
---|
1640 | TComDpbSize* dpbSize = vps->getDpbSize(); |
---|
1641 | assert ( dpbSize != 0 ); |
---|
1642 | |
---|
1643 | for( Int i = 1; i < vps->getNumOutputLayerSets(); i++ ) |
---|
1644 | { |
---|
1645 | READ_FLAG( uiCode, "sub_layer_flag_info_present_flag" ); dpbSize->setSubLayerFlagInfoPresentFlag( i, uiCode == 1 ); |
---|
1646 | |
---|
1647 | for( Int j = 0; j <= vps->getMaxTLayers() - 1 ; j++ ) |
---|
1648 | { |
---|
1649 | if( j > 0 && dpbSize->getSubLayerDpbInfoPresentFlag( i, j ) ) |
---|
1650 | { |
---|
1651 | READ_FLAG( uiCode, "sub_layer_dpb_info_present_flag" ); dpbSize->setSubLayerDpbInfoPresentFlag( i, j, uiCode == 1 ); |
---|
1652 | } |
---|
1653 | if( dpbSize->getSubLayerDpbInfoPresentFlag( i, j ) ) |
---|
1654 | { |
---|
1655 | for( Int k = 0; k < vps->getNumSubDpbs( vps->getOutputLayerSetIdxMinus1( i ) + 1 ); k++ ) |
---|
1656 | { |
---|
1657 | READ_UVLC( uiCode, "max_vps_dec_pic_buffering_minus1" ); dpbSize->setMaxVpsDecPicBufferingMinus1( i, k, j, uiCode ); |
---|
1658 | } |
---|
1659 | READ_UVLC( uiCode, "max_vps_num_reorder_pics" ); dpbSize->setMaxVpsNumReorderPics( i, j, uiCode ); |
---|
1660 | READ_UVLC( uiCode, "max_vps_latency_increase_plus1" ); dpbSize->setMaxVpsLatencyIncreasePlus1( i, j, uiCode ); |
---|
1661 | } |
---|
1662 | else |
---|
1663 | { |
---|
1664 | if ( j > 0 ) |
---|
1665 | { |
---|
1666 | for( Int k = 0; k < vps->getNumSubDpbs( vps->getOutputLayerSetIdxMinus1( i ) + 1 ); k++ ) |
---|
1667 | { |
---|
1668 | dpbSize->setMaxVpsDecPicBufferingMinus1( i, k, j, dpbSize->getMaxVpsDecPicBufferingMinus1( i,k, j - 1 ) ); |
---|
1669 | } |
---|
1670 | dpbSize->setMaxVpsNumReorderPics ( i, j, dpbSize->getMaxVpsNumReorderPics ( i, j - 1 ) ); |
---|
1671 | dpbSize->setMaxVpsLatencyIncreasePlus1( i, j, dpbSize->getMaxVpsLatencyIncreasePlus1( i, j - 1 ) ); |
---|
1672 | } |
---|
1673 | } |
---|
1674 | } |
---|
1675 | } |
---|
1676 | } |
---|
1677 | #endif |
---|
1678 | |
---|
1679 | #if H_3D |
---|
1680 | Void TDecCavlc::parseVPSExtension2( TComVPS* pcVPS ) |
---|
1681 | { |
---|
1682 | UInt uiCode; |
---|
1683 | for( Int i = 0; i <= pcVPS->getMaxLayersMinus1(); i++ ) |
---|
1684 | { |
---|
1685 | #if H_3D_ARP |
---|
1686 | pcVPS->setUseAdvRP ( i, 0 ); |
---|
1687 | pcVPS->setARPStepNum( i, 1 ); |
---|
1688 | #endif |
---|
1689 | #if H_3D_SPIVMP |
---|
1690 | pcVPS->setSubPULog2Size(i, 0); |
---|
1691 | #endif |
---|
1692 | if ( i != 0 ) |
---|
1693 | { |
---|
1694 | if( !( pcVPS->getDepthId( i ) == 1 ) ) |
---|
1695 | { |
---|
1696 | #if H_3D_IV_MERGE |
---|
1697 | READ_FLAG( uiCode, "iv_mv_pred_flag[i]"); pcVPS->setIvMvPredFlag ( i, uiCode == 1 ? true : false ); |
---|
1698 | #if H_3D_SPIVMP |
---|
1699 | READ_UVLC (uiCode, "log2_sub_PU_size_minus2"); pcVPS->setSubPULog2Size(i, uiCode+2); |
---|
1700 | #endif |
---|
1701 | #endif |
---|
1702 | #if H_3D_ARP |
---|
1703 | READ_FLAG( uiCode, "iv_res_pred_flag[i]" ); pcVPS->setUseAdvRP ( i, uiCode ); pcVPS->setARPStepNum( i, uiCode ? H_3D_ARP_WFNR : 1 ); |
---|
1704 | |
---|
1705 | #endif |
---|
1706 | #if H_3D_NBDV_REF |
---|
1707 | READ_FLAG( uiCode, "depth_refinement_flag[i]"); pcVPS->setDepthRefinementFlag ( i, uiCode == 1 ? true : false ); |
---|
1708 | #endif |
---|
1709 | #if H_3D_VSP |
---|
1710 | READ_FLAG( uiCode, "view_synthesis_pred_flag[i]"); pcVPS->setViewSynthesisPredFlag( i, uiCode == 1 ? true : false ); |
---|
1711 | #endif |
---|
1712 | } |
---|
1713 | else |
---|
1714 | { |
---|
1715 | #if H_3D_IV_MERGE |
---|
1716 | if(i!=1) |
---|
1717 | { |
---|
1718 | READ_FLAG( uiCode, "iv_mv_pred_flag[i]"); pcVPS->setIvMvPredFlag ( i, uiCode == 1 ? true : false ); |
---|
1719 | } |
---|
1720 | #endif |
---|
1721 | #if H_3D_SPIVMP |
---|
1722 | if (i!=1) |
---|
1723 | { |
---|
1724 | READ_UVLC (uiCode, "log2_sub_PU_size_minus2[i]"); pcVPS->setSubPULog2Size(i, uiCode+2); |
---|
1725 | } |
---|
1726 | #endif |
---|
1727 | #if H_3D_IV_MERGE |
---|
1728 | READ_FLAG( uiCode, "mpi_flag[i]" ); pcVPS->setMPIFlag( i, uiCode == 1 ? true : false ); |
---|
1729 | #endif |
---|
1730 | READ_FLAG( uiCode, "vps_depth_modes_flag[i]" ); pcVPS->setVpsDepthModesFlag( i, uiCode == 1 ? true : false ); |
---|
1731 | // READ_FLAG( uiCode, "lim_qt_pred_flag[i]"); pcVPS->setLimQtPreFlag ( i, uiCode == 1 ? true : false ); |
---|
1732 | #if H_3D_INTER_SDC |
---|
1733 | READ_FLAG( uiCode, "depth_inter_SDC_flag" ); pcVPS->setInterSDCFlag( i, uiCode ? true : false ); |
---|
1734 | #endif |
---|
1735 | } |
---|
1736 | } |
---|
1737 | } |
---|
1738 | |
---|
1739 | UInt uiCamParPrecision = 0; |
---|
1740 | Bool bCamParSlice = false; |
---|
1741 | Bool bCamParPresentFlag = false; |
---|
1742 | |
---|
1743 | READ_UVLC( uiCamParPrecision, "cp_precision" ); |
---|
1744 | for (UInt viewIndex=0; viewIndex<pcVPS->getNumViews(); viewIndex++) |
---|
1745 | { |
---|
1746 | READ_FLAG( uiCode, "cp_present_flag[i]" ); bCamParPresentFlag = ( uiCode == 1); |
---|
1747 | if ( bCamParPresentFlag ) |
---|
1748 | { |
---|
1749 | READ_FLAG( uiCode, "cp_in_slice_segment_header_flag[i]" ); bCamParSlice = ( uiCode == 1); |
---|
1750 | if ( !bCamParSlice ) |
---|
1751 | { |
---|
1752 | for( UInt uiBaseIndex = 0; uiBaseIndex < viewIndex; uiBaseIndex++ ) |
---|
1753 | { |
---|
1754 | Int iCode; |
---|
1755 | READ_SVLC( iCode, "vps_cp_scale" ); m_aaiTempScale [ uiBaseIndex ][ viewIndex ] = iCode; |
---|
1756 | READ_SVLC( iCode, "vps_cp_off" ); m_aaiTempOffset [ uiBaseIndex ][ viewIndex ] = iCode; |
---|
1757 | READ_SVLC( iCode, "vps_cp_inv_scale_plus_scale" ); m_aaiTempScale [ viewIndex ][ uiBaseIndex ] = iCode - m_aaiTempScale [ uiBaseIndex ][ viewIndex ]; |
---|
1758 | READ_SVLC( iCode, "vps_cp_inv_off_plus_off" ); m_aaiTempOffset [ viewIndex ][ uiBaseIndex ] = iCode - m_aaiTempOffset[ uiBaseIndex ][ viewIndex ]; |
---|
1759 | } |
---|
1760 | } |
---|
1761 | pcVPS->initCamParaVPS( viewIndex, bCamParPresentFlag, uiCamParPrecision, bCamParSlice, m_aaiTempScale, m_aaiTempOffset ); |
---|
1762 | } |
---|
1763 | } |
---|
1764 | |
---|
1765 | READ_FLAG( uiCode, "iv_mv_scaling_flag"); pcVPS->setIvMvScalingFlag( uiCode == 1 ? true : false ); |
---|
1766 | } |
---|
1767 | #endif |
---|
1768 | |
---|
1769 | Void TDecCavlc::parseSliceHeader (TComSlice*& rpcSlice, ParameterSetManagerDecoder *parameterSetManager) |
---|
1770 | { |
---|
1771 | UInt uiCode; |
---|
1772 | Int iCode; |
---|
1773 | |
---|
1774 | #if ENC_DEC_TRACE |
---|
1775 | xTraceSliceHeader(rpcSlice); |
---|
1776 | #endif |
---|
1777 | TComPPS* pps = NULL; |
---|
1778 | TComSPS* sps = NULL; |
---|
1779 | #if H_MV |
---|
1780 | TComVPS* vps = NULL; |
---|
1781 | #endif |
---|
1782 | |
---|
1783 | UInt firstSliceSegmentInPic; |
---|
1784 | READ_FLAG( firstSliceSegmentInPic, "first_slice_segment_in_pic_flag" ); |
---|
1785 | if( rpcSlice->getRapPicFlag()) |
---|
1786 | { |
---|
1787 | READ_FLAG( uiCode, "no_output_of_prior_pics_flag" ); //ignored |
---|
1788 | } |
---|
1789 | READ_UVLC ( uiCode, "slice_pic_parameter_set_id" ); rpcSlice->setPPSId(uiCode); |
---|
1790 | pps = parameterSetManager->getPrefetchedPPS(uiCode); |
---|
1791 | //!KS: need to add error handling code here, if PPS is not available |
---|
1792 | assert(pps!=0); |
---|
1793 | sps = parameterSetManager->getPrefetchedSPS(pps->getSPSId()); |
---|
1794 | //!KS: need to add error handling code here, if SPS is not available |
---|
1795 | assert(sps!=0); |
---|
1796 | #if H_MV |
---|
1797 | vps = parameterSetManager->getPrefetchedVPS(sps->getVPSId()); |
---|
1798 | assert( vps != NULL ); |
---|
1799 | |
---|
1800 | sps->inferRepFormat ( vps , rpcSlice->getLayerId() ); |
---|
1801 | sps->inferScalingList( parameterSetManager->getActiveSPS( sps->getSpsScalingListRefLayerId() ) ); |
---|
1802 | if ( sps->getVuiParametersPresentFlag() ) |
---|
1803 | { |
---|
1804 | sps->getVuiParameters()->inferVideoSignalInfo( vps, rpcSlice->getLayerId() ); |
---|
1805 | } |
---|
1806 | rpcSlice->setVPS(vps); |
---|
1807 | rpcSlice->setViewId ( vps->getViewId ( rpcSlice->getLayerId() ) ); |
---|
1808 | rpcSlice->setViewIndex( vps->getViewIndex( rpcSlice->getLayerId() ) ); |
---|
1809 | #if H_3D |
---|
1810 | rpcSlice->setIsDepth ( vps->getDepthId ( rpcSlice->getLayerId() ) == 1 ); |
---|
1811 | #endif |
---|
1812 | #endif |
---|
1813 | rpcSlice->setSPS(sps); |
---|
1814 | rpcSlice->setPPS(pps); |
---|
1815 | if( pps->getDependentSliceSegmentsEnabledFlag() && ( !firstSliceSegmentInPic )) |
---|
1816 | { |
---|
1817 | READ_FLAG( uiCode, "dependent_slice_segment_flag" ); rpcSlice->setDependentSliceSegmentFlag(uiCode ? true : false); |
---|
1818 | } |
---|
1819 | else |
---|
1820 | { |
---|
1821 | rpcSlice->setDependentSliceSegmentFlag(false); |
---|
1822 | } |
---|
1823 | Int numCTUs = ((sps->getPicWidthInLumaSamples()+sps->getMaxCUWidth()-1)/sps->getMaxCUWidth())*((sps->getPicHeightInLumaSamples()+sps->getMaxCUHeight()-1)/sps->getMaxCUHeight()); |
---|
1824 | Int maxParts = (1<<(sps->getMaxCUDepth()<<1)); |
---|
1825 | UInt sliceSegmentAddress = 0; |
---|
1826 | Int bitsSliceSegmentAddress = 0; |
---|
1827 | while(numCTUs>(1<<bitsSliceSegmentAddress)) |
---|
1828 | { |
---|
1829 | bitsSliceSegmentAddress++; |
---|
1830 | } |
---|
1831 | |
---|
1832 | if(!firstSliceSegmentInPic) |
---|
1833 | { |
---|
1834 | READ_CODE( bitsSliceSegmentAddress, sliceSegmentAddress, "slice_segment_address" ); |
---|
1835 | } |
---|
1836 | //set uiCode to equal slice start address (or dependent slice start address) |
---|
1837 | Int startCuAddress = maxParts*sliceSegmentAddress; |
---|
1838 | rpcSlice->setSliceSegmentCurStartCUAddr( startCuAddress ); |
---|
1839 | rpcSlice->setSliceSegmentCurEndCUAddr(numCTUs*maxParts); |
---|
1840 | |
---|
1841 | if (rpcSlice->getDependentSliceSegmentFlag()) |
---|
1842 | { |
---|
1843 | rpcSlice->setNextSlice ( false ); |
---|
1844 | rpcSlice->setNextSliceSegment ( true ); |
---|
1845 | } |
---|
1846 | else |
---|
1847 | { |
---|
1848 | rpcSlice->setNextSlice ( true ); |
---|
1849 | rpcSlice->setNextSliceSegment ( false ); |
---|
1850 | |
---|
1851 | rpcSlice->setSliceCurStartCUAddr(startCuAddress); |
---|
1852 | rpcSlice->setSliceCurEndCUAddr(numCTUs*maxParts); |
---|
1853 | } |
---|
1854 | |
---|
1855 | if(!rpcSlice->getDependentSliceSegmentFlag()) |
---|
1856 | { |
---|
1857 | #if H_MV |
---|
1858 | Int esb = 0; //Don't use i, otherwise will shadow something below |
---|
1859 | |
---|
1860 | if ( rpcSlice->getPPS()->getNumExtraSliceHeaderBits() > esb ) |
---|
1861 | { |
---|
1862 | esb++; |
---|
1863 | READ_FLAG( uiCode, "discardable_flag" ); rpcSlice->setDiscardableFlag( uiCode == 1 ); |
---|
1864 | } |
---|
1865 | |
---|
1866 | if ( rpcSlice->getPPS()->getNumExtraSliceHeaderBits() > esb ) |
---|
1867 | { |
---|
1868 | esb++; |
---|
1869 | READ_FLAG( uiCode, "cross_layer_bla_flag" ); rpcSlice->setCrossLayerBlaFlag( uiCode == 1 ); |
---|
1870 | } |
---|
1871 | rpcSlice->checkCrossLayerBlaFlag( ); |
---|
1872 | |
---|
1873 | if ( rpcSlice->getPPS()->getNumExtraSliceHeaderBits() > esb ) |
---|
1874 | { |
---|
1875 | esb++; |
---|
1876 | READ_FLAG( uiCode, "poc_reset_flag" ); rpcSlice->setPocResetFlag( uiCode == 1 ); |
---|
1877 | } |
---|
1878 | |
---|
1879 | for (; esb < rpcSlice->getPPS()->getNumExtraSliceHeaderBits(); esb++) |
---|
1880 | #else |
---|
1881 | for (Int i = 0; i < rpcSlice->getPPS()->getNumExtraSliceHeaderBits(); i++) |
---|
1882 | #endif |
---|
1883 | { |
---|
1884 | READ_FLAG(uiCode, "slice_reserved_undetermined_flag[]"); // ignored |
---|
1885 | } |
---|
1886 | |
---|
1887 | READ_UVLC ( uiCode, "slice_type" ); rpcSlice->setSliceType((SliceType)uiCode); |
---|
1888 | if( pps->getOutputFlagPresentFlag() ) |
---|
1889 | { |
---|
1890 | READ_FLAG( uiCode, "pic_output_flag" ); rpcSlice->setPicOutputFlag( uiCode ? true : false ); |
---|
1891 | } |
---|
1892 | else |
---|
1893 | { |
---|
1894 | rpcSlice->setPicOutputFlag( true ); |
---|
1895 | } |
---|
1896 | // in the first version chroma_format_idc is equal to one, thus colour_plane_id will not be present |
---|
1897 | assert (sps->getChromaFormatIdc() == 1 ); |
---|
1898 | // if( separate_colour_plane_flag == 1 ) |
---|
1899 | // colour_plane_id u(2) |
---|
1900 | |
---|
1901 | |
---|
1902 | #if H_MV |
---|
1903 | UInt slicePicOrderCntLsb = 0; |
---|
1904 | Int iPOClsb = slicePicOrderCntLsb; // Needed later |
---|
1905 | if ( (rpcSlice->getLayerId() > 0 && !vps->getPocLsbNotPresentFlag( rpcSlice->getLayerIdInVps())) || !rpcSlice->getIdrPicFlag() ) |
---|
1906 | { |
---|
1907 | READ_CODE(sps->getBitsForPOC(), slicePicOrderCntLsb, "slice_pic_order_cnt_lsb"); |
---|
1908 | } |
---|
1909 | |
---|
1910 | Bool picOrderCntMSBZeroFlag = false; |
---|
1911 | |
---|
1912 | // as in HM code. However are all cases for IRAP picture with NoRaslOutputFlag equal to 1 covered?? |
---|
1913 | picOrderCntMSBZeroFlag = picOrderCntMSBZeroFlag || ( rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP ); |
---|
1914 | picOrderCntMSBZeroFlag = picOrderCntMSBZeroFlag || ( rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL ); |
---|
1915 | picOrderCntMSBZeroFlag = picOrderCntMSBZeroFlag || ( rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP ); |
---|
1916 | picOrderCntMSBZeroFlag = picOrderCntMSBZeroFlag || rpcSlice->getIdrPicFlag(); |
---|
1917 | |
---|
1918 | // TBD picOrderCntMSBZeroFlag = picOrderCntMSBZeroFlag || ( rpcSlice->getLayerId() > 0 && !rpcSlice->getFirstPicInLayerDecodedFlag() ); |
---|
1919 | |
---|
1920 | Int picOrderCntMSB = 0; |
---|
1921 | |
---|
1922 | if ( !picOrderCntMSBZeroFlag ) |
---|
1923 | { |
---|
1924 | Int prevPicOrderCnt = rpcSlice->getPrevTid0POC(); |
---|
1925 | Int maxPicOrderCntLsb = 1 << sps->getBitsForPOC(); |
---|
1926 | Int prevPicOrderCntLsb = prevPicOrderCnt & (maxPicOrderCntLsb - 1); |
---|
1927 | Int prevPicOrderCntMsb = prevPicOrderCnt - prevPicOrderCntLsb; |
---|
1928 | |
---|
1929 | if( ( slicePicOrderCntLsb < prevPicOrderCntLsb ) && ( ( prevPicOrderCntLsb - slicePicOrderCntLsb ) >= ( maxPicOrderCntLsb / 2 ) ) ) |
---|
1930 | { |
---|
1931 | picOrderCntMSB = prevPicOrderCntMsb + maxPicOrderCntLsb; |
---|
1932 | } |
---|
1933 | else if( (slicePicOrderCntLsb > prevPicOrderCntLsb ) && ( (slicePicOrderCntLsb - prevPicOrderCntLsb ) > ( maxPicOrderCntLsb / 2 ) ) ) |
---|
1934 | { |
---|
1935 | picOrderCntMSB = prevPicOrderCntMsb - maxPicOrderCntLsb; |
---|
1936 | } |
---|
1937 | else |
---|
1938 | { |
---|
1939 | picOrderCntMSB = prevPicOrderCntMsb; |
---|
1940 | } |
---|
1941 | } |
---|
1942 | |
---|
1943 | rpcSlice->setPOC( picOrderCntMSB + slicePicOrderCntLsb ); |
---|
1944 | if ( rpcSlice->getPocResetFlag() ) |
---|
1945 | { |
---|
1946 | rpcSlice->setPocBeforeReset ( rpcSlice->getPOC() ); |
---|
1947 | rpcSlice->setPOC ( 0 ); |
---|
1948 | } |
---|
1949 | #endif |
---|
1950 | |
---|
1951 | if( rpcSlice->getIdrPicFlag() ) |
---|
1952 | { |
---|
1953 | #if !H_MV |
---|
1954 | rpcSlice->setPOC(0); |
---|
1955 | #endif |
---|
1956 | TComReferencePictureSet* rps = rpcSlice->getLocalRPS(); |
---|
1957 | rps->setNumberOfNegativePictures(0); |
---|
1958 | rps->setNumberOfPositivePictures(0); |
---|
1959 | rps->setNumberOfLongtermPictures(0); |
---|
1960 | rps->setNumberOfPictures(0); |
---|
1961 | rpcSlice->setRPS(rps); |
---|
1962 | #if H_MV |
---|
1963 | rpcSlice->setEnableTMVPFlag(false); |
---|
1964 | #endif |
---|
1965 | } |
---|
1966 | else |
---|
1967 | { |
---|
1968 | #if !H_MV |
---|
1969 | READ_CODE(sps->getBitsForPOC(), uiCode, "pic_order_cnt_lsb"); |
---|
1970 | Int iPOClsb = uiCode; |
---|
1971 | Int iPrevPOC = rpcSlice->getPrevTid0POC(); |
---|
1972 | Int iMaxPOClsb = 1<< sps->getBitsForPOC(); |
---|
1973 | Int iPrevPOClsb = iPrevPOC & (iMaxPOClsb - 1); |
---|
1974 | Int iPrevPOCmsb = iPrevPOC-iPrevPOClsb; |
---|
1975 | Int iPOCmsb; |
---|
1976 | if( ( iPOClsb < iPrevPOClsb ) && ( ( iPrevPOClsb - iPOClsb ) >= ( iMaxPOClsb / 2 ) ) ) |
---|
1977 | { |
---|
1978 | iPOCmsb = iPrevPOCmsb + iMaxPOClsb; |
---|
1979 | } |
---|
1980 | else if( (iPOClsb > iPrevPOClsb ) && ( (iPOClsb - iPrevPOClsb ) > ( iMaxPOClsb / 2 ) ) ) |
---|
1981 | { |
---|
1982 | iPOCmsb = iPrevPOCmsb - iMaxPOClsb; |
---|
1983 | } |
---|
1984 | else |
---|
1985 | { |
---|
1986 | iPOCmsb = iPrevPOCmsb; |
---|
1987 | } |
---|
1988 | if ( rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP |
---|
1989 | || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL |
---|
1990 | || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP ) |
---|
1991 | { |
---|
1992 | // For BLA picture types, POCmsb is set to 0. |
---|
1993 | iPOCmsb = 0; |
---|
1994 | } |
---|
1995 | rpcSlice->setPOC (iPOCmsb+iPOClsb); |
---|
1996 | #endif |
---|
1997 | TComReferencePictureSet* rps; |
---|
1998 | rps = rpcSlice->getLocalRPS(); |
---|
1999 | rpcSlice->setRPS(rps); |
---|
2000 | READ_FLAG( uiCode, "short_term_ref_pic_set_sps_flag" ); |
---|
2001 | if(uiCode == 0) // use short-term reference picture set explicitly signalled in slice header |
---|
2002 | { |
---|
2003 | parseShortTermRefPicSet(sps,rps, sps->getRPSList()->getNumberOfReferencePictureSets()); |
---|
2004 | } |
---|
2005 | else // use reference to short-term reference picture set in PPS |
---|
2006 | { |
---|
2007 | Int numBits = 0; |
---|
2008 | while ((1 << numBits) < rpcSlice->getSPS()->getRPSList()->getNumberOfReferencePictureSets()) |
---|
2009 | { |
---|
2010 | numBits++; |
---|
2011 | } |
---|
2012 | if (numBits > 0) |
---|
2013 | { |
---|
2014 | READ_CODE( numBits, uiCode, "short_term_ref_pic_set_idx"); |
---|
2015 | } |
---|
2016 | else |
---|
2017 | { |
---|
2018 | uiCode = 0; |
---|
2019 | } |
---|
2020 | *rps = *(sps->getRPSList()->getReferencePictureSet(uiCode)); |
---|
2021 | } |
---|
2022 | if(sps->getLongTermRefsPresent()) |
---|
2023 | { |
---|
2024 | Int offset = rps->getNumberOfNegativePictures()+rps->getNumberOfPositivePictures(); |
---|
2025 | UInt numOfLtrp = 0; |
---|
2026 | UInt numLtrpInSPS = 0; |
---|
2027 | if (rpcSlice->getSPS()->getNumLongTermRefPicSPS() > 0) |
---|
2028 | { |
---|
2029 | READ_UVLC( uiCode, "num_long_term_sps"); |
---|
2030 | numLtrpInSPS = uiCode; |
---|
2031 | numOfLtrp += numLtrpInSPS; |
---|
2032 | rps->setNumberOfLongtermPictures(numOfLtrp); |
---|
2033 | } |
---|
2034 | Int bitsForLtrpInSPS = 0; |
---|
2035 | while (rpcSlice->getSPS()->getNumLongTermRefPicSPS() > (1 << bitsForLtrpInSPS)) |
---|
2036 | { |
---|
2037 | bitsForLtrpInSPS++; |
---|
2038 | } |
---|
2039 | READ_UVLC( uiCode, "num_long_term_pics"); rps->setNumberOfLongtermPictures(uiCode); |
---|
2040 | numOfLtrp += uiCode; |
---|
2041 | rps->setNumberOfLongtermPictures(numOfLtrp); |
---|
2042 | Int maxPicOrderCntLSB = 1 << rpcSlice->getSPS()->getBitsForPOC(); |
---|
2043 | Int prevDeltaMSB = 0, deltaPocMSBCycleLT = 0;; |
---|
2044 | for(Int j=offset+rps->getNumberOfLongtermPictures()-1, k = 0; k < numOfLtrp; j--, k++) |
---|
2045 | { |
---|
2046 | Int pocLsbLt; |
---|
2047 | if (k < numLtrpInSPS) |
---|
2048 | { |
---|
2049 | uiCode = 0; |
---|
2050 | if (bitsForLtrpInSPS > 0) |
---|
2051 | { |
---|
2052 | READ_CODE(bitsForLtrpInSPS, uiCode, "lt_idx_sps[i]"); |
---|
2053 | } |
---|
2054 | Int usedByCurrFromSPS=rpcSlice->getSPS()->getUsedByCurrPicLtSPSFlag(uiCode); |
---|
2055 | |
---|
2056 | pocLsbLt = rpcSlice->getSPS()->getLtRefPicPocLsbSps(uiCode); |
---|
2057 | rps->setUsed(j,usedByCurrFromSPS); |
---|
2058 | } |
---|
2059 | else |
---|
2060 | { |
---|
2061 | READ_CODE(rpcSlice->getSPS()->getBitsForPOC(), uiCode, "poc_lsb_lt"); pocLsbLt= uiCode; |
---|
2062 | READ_FLAG( uiCode, "used_by_curr_pic_lt_flag"); rps->setUsed(j,uiCode); |
---|
2063 | } |
---|
2064 | READ_FLAG(uiCode,"delta_poc_msb_present_flag"); |
---|
2065 | Bool mSBPresentFlag = uiCode ? true : false; |
---|
2066 | if(mSBPresentFlag) |
---|
2067 | { |
---|
2068 | READ_UVLC( uiCode, "delta_poc_msb_cycle_lt[i]" ); |
---|
2069 | Bool deltaFlag = false; |
---|
2070 | // First LTRP || First LTRP from SH |
---|
2071 | if( (j == offset+rps->getNumberOfLongtermPictures()-1) || (j == offset+(numOfLtrp-numLtrpInSPS)-1) ) |
---|
2072 | { |
---|
2073 | deltaFlag = true; |
---|
2074 | } |
---|
2075 | if(deltaFlag) |
---|
2076 | { |
---|
2077 | deltaPocMSBCycleLT = uiCode; |
---|
2078 | } |
---|
2079 | else |
---|
2080 | { |
---|
2081 | deltaPocMSBCycleLT = uiCode + prevDeltaMSB; |
---|
2082 | } |
---|
2083 | |
---|
2084 | Int pocLTCurr = rpcSlice->getPOC() - deltaPocMSBCycleLT * maxPicOrderCntLSB |
---|
2085 | - iPOClsb + pocLsbLt; |
---|
2086 | rps->setPOC (j, pocLTCurr); |
---|
2087 | rps->setDeltaPOC(j, - rpcSlice->getPOC() + pocLTCurr); |
---|
2088 | rps->setCheckLTMSBPresent(j,true); |
---|
2089 | } |
---|
2090 | else |
---|
2091 | { |
---|
2092 | rps->setPOC (j, pocLsbLt); |
---|
2093 | rps->setDeltaPOC(j, - rpcSlice->getPOC() + pocLsbLt); |
---|
2094 | rps->setCheckLTMSBPresent(j,false); |
---|
2095 | |
---|
2096 | // reset deltaPocMSBCycleLT for first LTRP from slice header if MSB not present |
---|
2097 | if( j == offset+(numOfLtrp-numLtrpInSPS)-1 ) |
---|
2098 | { |
---|
2099 | deltaPocMSBCycleLT = 0; |
---|
2100 | } |
---|
2101 | } |
---|
2102 | prevDeltaMSB = deltaPocMSBCycleLT; |
---|
2103 | } |
---|
2104 | offset += rps->getNumberOfLongtermPictures(); |
---|
2105 | rps->setNumberOfPictures(offset); |
---|
2106 | } |
---|
2107 | if ( rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP |
---|
2108 | || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL |
---|
2109 | || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP ) |
---|
2110 | { |
---|
2111 | // In the case of BLA picture types, rps data is read from slice header but ignored |
---|
2112 | rps = rpcSlice->getLocalRPS(); |
---|
2113 | rps->setNumberOfNegativePictures(0); |
---|
2114 | rps->setNumberOfPositivePictures(0); |
---|
2115 | rps->setNumberOfLongtermPictures(0); |
---|
2116 | rps->setNumberOfPictures(0); |
---|
2117 | rpcSlice->setRPS(rps); |
---|
2118 | } |
---|
2119 | if (rpcSlice->getSPS()->getTMVPFlagsPresent()) |
---|
2120 | { |
---|
2121 | READ_FLAG( uiCode, "slice_temporal_mvp_enable_flag" ); |
---|
2122 | rpcSlice->setEnableTMVPFlag( uiCode == 1 ? true : false ); |
---|
2123 | } |
---|
2124 | else |
---|
2125 | { |
---|
2126 | rpcSlice->setEnableTMVPFlag(false); |
---|
2127 | } |
---|
2128 | } |
---|
2129 | #if H_MV |
---|
2130 | Bool interLayerPredLayerIdcPresentFlag = false; |
---|
2131 | Int layerId = rpcSlice->getLayerId(); |
---|
2132 | if( rpcSlice->getLayerId() > 0 && !vps->getAllRefLayersActiveFlag() && vps->getNumDirectRefLayers( layerId ) > 0 ) |
---|
2133 | { |
---|
2134 | READ_FLAG( uiCode, "inter_layer_pred_enabled_flag" ); rpcSlice->setInterLayerPredEnabledFlag( uiCode == 1 ); |
---|
2135 | if( rpcSlice->getInterLayerPredEnabledFlag() && vps->getNumDirectRefLayers( layerId ) > 1 ) |
---|
2136 | { |
---|
2137 | if( !vps->getMaxOneActiveRefLayerFlag()) |
---|
2138 | { |
---|
2139 | READ_CODE( rpcSlice->getNumInterLayerRefPicsMinus1Len( ), uiCode, "num_inter_layer_ref_pics_minus1" ); rpcSlice->setNumInterLayerRefPicsMinus1( uiCode ); |
---|
2140 | } |
---|
2141 | if ( rpcSlice->getNumActiveRefLayerPics() != vps->getNumDirectRefLayers( layerId ) ) |
---|
2142 | { |
---|
2143 | interLayerPredLayerIdcPresentFlag = true; |
---|
2144 | for( Int idx = 0; idx < rpcSlice->getNumActiveRefLayerPics(); idx++ ) |
---|
2145 | { |
---|
2146 | READ_CODE( rpcSlice->getInterLayerPredLayerIdcLen( ), uiCode, "inter_layer_pred_layer_idc" ); rpcSlice->setInterLayerPredLayerIdc( idx, uiCode ); |
---|
2147 | } |
---|
2148 | } |
---|
2149 | } |
---|
2150 | } |
---|
2151 | if ( !interLayerPredLayerIdcPresentFlag ) |
---|
2152 | { |
---|
2153 | for( Int i = 0; i < rpcSlice->getNumActiveRefLayerPics(); i++ ) |
---|
2154 | { |
---|
2155 | rpcSlice->setInterLayerPredLayerIdc( i, rpcSlice->getRefLayerPicIdc( i ) ); |
---|
2156 | } |
---|
2157 | } |
---|
2158 | #endif |
---|
2159 | if(sps->getUseSAO()) |
---|
2160 | { |
---|
2161 | READ_FLAG(uiCode, "slice_sao_luma_flag"); rpcSlice->setSaoEnabledFlag((Bool)uiCode); |
---|
2162 | READ_FLAG(uiCode, "slice_sao_chroma_flag"); rpcSlice->setSaoEnabledFlagChroma((Bool)uiCode); |
---|
2163 | } |
---|
2164 | |
---|
2165 | if (rpcSlice->getIdrPicFlag()) |
---|
2166 | { |
---|
2167 | rpcSlice->setEnableTMVPFlag(false); |
---|
2168 | } |
---|
2169 | if (!rpcSlice->isIntra()) |
---|
2170 | { |
---|
2171 | |
---|
2172 | READ_FLAG( uiCode, "num_ref_idx_active_override_flag"); |
---|
2173 | if (uiCode) |
---|
2174 | { |
---|
2175 | READ_UVLC (uiCode, "num_ref_idx_l0_active_minus1" ); rpcSlice->setNumRefIdx( REF_PIC_LIST_0, uiCode + 1 ); |
---|
2176 | if (rpcSlice->isInterB()) |
---|
2177 | { |
---|
2178 | READ_UVLC (uiCode, "num_ref_idx_l1_active_minus1" ); rpcSlice->setNumRefIdx( REF_PIC_LIST_1, uiCode + 1 ); |
---|
2179 | } |
---|
2180 | else |
---|
2181 | { |
---|
2182 | rpcSlice->setNumRefIdx(REF_PIC_LIST_1, 0); |
---|
2183 | } |
---|
2184 | } |
---|
2185 | else |
---|
2186 | { |
---|
2187 | rpcSlice->setNumRefIdx(REF_PIC_LIST_0, rpcSlice->getPPS()->getNumRefIdxL0DefaultActive()); |
---|
2188 | if (rpcSlice->isInterB()) |
---|
2189 | { |
---|
2190 | rpcSlice->setNumRefIdx(REF_PIC_LIST_1, rpcSlice->getPPS()->getNumRefIdxL1DefaultActive()); |
---|
2191 | } |
---|
2192 | else |
---|
2193 | { |
---|
2194 | rpcSlice->setNumRefIdx(REF_PIC_LIST_1,0); |
---|
2195 | } |
---|
2196 | } |
---|
2197 | } |
---|
2198 | // } |
---|
2199 | TComRefPicListModification* refPicListModification = rpcSlice->getRefPicListModification(); |
---|
2200 | if(!rpcSlice->isIntra()) |
---|
2201 | { |
---|
2202 | if( !rpcSlice->getPPS()->getListsModificationPresentFlag() || rpcSlice->getNumRpsCurrTempList() <= 1 ) |
---|
2203 | { |
---|
2204 | refPicListModification->setRefPicListModificationFlagL0( 0 ); |
---|
2205 | } |
---|
2206 | else |
---|
2207 | { |
---|
2208 | READ_FLAG( uiCode, "ref_pic_list_modification_flag_l0" ); refPicListModification->setRefPicListModificationFlagL0( uiCode ? 1 : 0 ); |
---|
2209 | } |
---|
2210 | |
---|
2211 | if(refPicListModification->getRefPicListModificationFlagL0()) |
---|
2212 | { |
---|
2213 | uiCode = 0; |
---|
2214 | Int i = 0; |
---|
2215 | Int numRpsCurrTempList0 = rpcSlice->getNumRpsCurrTempList(); |
---|
2216 | if ( numRpsCurrTempList0 > 1 ) |
---|
2217 | { |
---|
2218 | Int length = 1; |
---|
2219 | numRpsCurrTempList0 --; |
---|
2220 | while ( numRpsCurrTempList0 >>= 1) |
---|
2221 | { |
---|
2222 | length ++; |
---|
2223 | } |
---|
2224 | for (i = 0; i < rpcSlice->getNumRefIdx(REF_PIC_LIST_0); i ++) |
---|
2225 | { |
---|
2226 | READ_CODE( length, uiCode, "list_entry_l0" ); |
---|
2227 | refPicListModification->setRefPicSetIdxL0(i, uiCode ); |
---|
2228 | } |
---|
2229 | } |
---|
2230 | else |
---|
2231 | { |
---|
2232 | for (i = 0; i < rpcSlice->getNumRefIdx(REF_PIC_LIST_0); i ++) |
---|
2233 | { |
---|
2234 | refPicListModification->setRefPicSetIdxL0(i, 0 ); |
---|
2235 | } |
---|
2236 | } |
---|
2237 | } |
---|
2238 | } |
---|
2239 | else |
---|
2240 | { |
---|
2241 | refPicListModification->setRefPicListModificationFlagL0(0); |
---|
2242 | } |
---|
2243 | if(rpcSlice->isInterB()) |
---|
2244 | { |
---|
2245 | if( !rpcSlice->getPPS()->getListsModificationPresentFlag() || rpcSlice->getNumRpsCurrTempList() <= 1 ) |
---|
2246 | { |
---|
2247 | refPicListModification->setRefPicListModificationFlagL1( 0 ); |
---|
2248 | } |
---|
2249 | else |
---|
2250 | { |
---|
2251 | READ_FLAG( uiCode, "ref_pic_list_modification_flag_l1" ); refPicListModification->setRefPicListModificationFlagL1( uiCode ? 1 : 0 ); |
---|
2252 | } |
---|
2253 | if(refPicListModification->getRefPicListModificationFlagL1()) |
---|
2254 | { |
---|
2255 | uiCode = 0; |
---|
2256 | Int i = 0; |
---|
2257 | Int numRpsCurrTempList1 = rpcSlice->getNumRpsCurrTempList(); |
---|
2258 | if ( numRpsCurrTempList1 > 1 ) |
---|
2259 | { |
---|
2260 | Int length = 1; |
---|
2261 | numRpsCurrTempList1 --; |
---|
2262 | while ( numRpsCurrTempList1 >>= 1) |
---|
2263 | { |
---|
2264 | length ++; |
---|
2265 | } |
---|
2266 | for (i = 0; i < rpcSlice->getNumRefIdx(REF_PIC_LIST_1); i ++) |
---|
2267 | { |
---|
2268 | READ_CODE( length, uiCode, "list_entry_l1" ); |
---|
2269 | refPicListModification->setRefPicSetIdxL1(i, uiCode ); |
---|
2270 | } |
---|
2271 | } |
---|
2272 | else |
---|
2273 | { |
---|
2274 | for (i = 0; i < rpcSlice->getNumRefIdx(REF_PIC_LIST_1); i ++) |
---|
2275 | { |
---|
2276 | refPicListModification->setRefPicSetIdxL1(i, 0 ); |
---|
2277 | } |
---|
2278 | } |
---|
2279 | } |
---|
2280 | } |
---|
2281 | else |
---|
2282 | { |
---|
2283 | refPicListModification->setRefPicListModificationFlagL1(0); |
---|
2284 | } |
---|
2285 | if (rpcSlice->isInterB()) |
---|
2286 | { |
---|
2287 | READ_FLAG( uiCode, "mvd_l1_zero_flag" ); rpcSlice->setMvdL1ZeroFlag( (uiCode ? true : false) ); |
---|
2288 | } |
---|
2289 | |
---|
2290 | rpcSlice->setCabacInitFlag( false ); // default |
---|
2291 | if(pps->getCabacInitPresentFlag() && !rpcSlice->isIntra()) |
---|
2292 | { |
---|
2293 | READ_FLAG(uiCode, "cabac_init_flag"); |
---|
2294 | rpcSlice->setCabacInitFlag( uiCode ? true : false ); |
---|
2295 | } |
---|
2296 | |
---|
2297 | if ( rpcSlice->getEnableTMVPFlag() ) |
---|
2298 | { |
---|
2299 | if ( rpcSlice->getSliceType() == B_SLICE ) |
---|
2300 | { |
---|
2301 | READ_FLAG( uiCode, "collocated_from_l0_flag" ); |
---|
2302 | rpcSlice->setColFromL0Flag(uiCode); |
---|
2303 | } |
---|
2304 | else |
---|
2305 | { |
---|
2306 | rpcSlice->setColFromL0Flag( 1 ); |
---|
2307 | } |
---|
2308 | |
---|
2309 | if ( rpcSlice->getSliceType() != I_SLICE && |
---|
2310 | ((rpcSlice->getColFromL0Flag() == 1 && rpcSlice->getNumRefIdx(REF_PIC_LIST_0) > 1)|| |
---|
2311 | (rpcSlice->getColFromL0Flag() == 0 && rpcSlice->getNumRefIdx(REF_PIC_LIST_1) > 1))) |
---|
2312 | { |
---|
2313 | READ_UVLC( uiCode, "collocated_ref_idx" ); |
---|
2314 | rpcSlice->setColRefIdx(uiCode); |
---|
2315 | } |
---|
2316 | else |
---|
2317 | { |
---|
2318 | rpcSlice->setColRefIdx(0); |
---|
2319 | } |
---|
2320 | } |
---|
2321 | if ( (pps->getUseWP() && rpcSlice->getSliceType()==P_SLICE) || (pps->getWPBiPred() && rpcSlice->getSliceType()==B_SLICE) ) |
---|
2322 | { |
---|
2323 | xParsePredWeightTable(rpcSlice); |
---|
2324 | rpcSlice->initWpScaling(); |
---|
2325 | } |
---|
2326 | #if H_3D_IC |
---|
2327 | else if( rpcSlice->getViewIndex() && ( rpcSlice->getSliceType() == P_SLICE || rpcSlice->getSliceType() == B_SLICE ) && !rpcSlice->getIsDepth()) |
---|
2328 | { |
---|
2329 | UInt uiCodeTmp = 0; |
---|
2330 | |
---|
2331 | READ_FLAG ( uiCodeTmp, "slice_ic_enable_flag" ); |
---|
2332 | rpcSlice->setApplyIC( uiCodeTmp ); |
---|
2333 | |
---|
2334 | if ( uiCodeTmp ) |
---|
2335 | { |
---|
2336 | READ_FLAG ( uiCodeTmp, "ic_skip_mergeidx0" ); |
---|
2337 | rpcSlice->setIcSkipParseFlag( uiCodeTmp ); |
---|
2338 | } |
---|
2339 | } |
---|
2340 | #endif |
---|
2341 | if (!rpcSlice->isIntra()) |
---|
2342 | { |
---|
2343 | READ_UVLC( uiCode, "five_minus_max_num_merge_cand"); |
---|
2344 | #if H_3D_IV_MERGE |
---|
2345 | if(rpcSlice->getIsDepth()) |
---|
2346 | { |
---|
2347 | Bool bMPIFlag = rpcSlice->getVPS()->getMPIFlag( rpcSlice->getLayerIdInVps() ) ; |
---|
2348 | Bool ivMvPredFlag = rpcSlice->getVPS()->getIvMvPredFlag( rpcSlice->getLayerIdInVps() ) ; |
---|
2349 | rpcSlice->setMaxNumMergeCand(( ( bMPIFlag || ivMvPredFlag ) ? MRG_MAX_NUM_CANDS_MEM : MRG_MAX_NUM_CANDS) - uiCode); |
---|
2350 | } |
---|
2351 | else |
---|
2352 | { |
---|
2353 | Bool ivMvPredFlag = rpcSlice->getVPS()->getIvMvPredFlag( rpcSlice->getLayerIdInVps() ) ; |
---|
2354 | rpcSlice->setMaxNumMergeCand(( ivMvPredFlag ? MRG_MAX_NUM_CANDS_MEM : MRG_MAX_NUM_CANDS) - uiCode); |
---|
2355 | } |
---|
2356 | |
---|
2357 | #else |
---|
2358 | rpcSlice->setMaxNumMergeCand(MRG_MAX_NUM_CANDS - uiCode); |
---|
2359 | #endif |
---|
2360 | } |
---|
2361 | |
---|
2362 | READ_SVLC( iCode, "slice_qp_delta" ); |
---|
2363 | rpcSlice->setSliceQp (26 + pps->getPicInitQPMinus26() + iCode); |
---|
2364 | |
---|
2365 | assert( rpcSlice->getSliceQp() >= -sps->getQpBDOffsetY() ); |
---|
2366 | assert( rpcSlice->getSliceQp() <= 51 ); |
---|
2367 | |
---|
2368 | if (rpcSlice->getPPS()->getSliceChromaQpFlag()) |
---|
2369 | { |
---|
2370 | READ_SVLC( iCode, "slice_qp_delta_cb" ); |
---|
2371 | rpcSlice->setSliceQpDeltaCb( iCode ); |
---|
2372 | assert( rpcSlice->getSliceQpDeltaCb() >= -12 ); |
---|
2373 | assert( rpcSlice->getSliceQpDeltaCb() <= 12 ); |
---|
2374 | assert( (rpcSlice->getPPS()->getChromaCbQpOffset() + rpcSlice->getSliceQpDeltaCb()) >= -12 ); |
---|
2375 | assert( (rpcSlice->getPPS()->getChromaCbQpOffset() + rpcSlice->getSliceQpDeltaCb()) <= 12 ); |
---|
2376 | |
---|
2377 | READ_SVLC( iCode, "slice_qp_delta_cr" ); |
---|
2378 | rpcSlice->setSliceQpDeltaCr( iCode ); |
---|
2379 | assert( rpcSlice->getSliceQpDeltaCr() >= -12 ); |
---|
2380 | assert( rpcSlice->getSliceQpDeltaCr() <= 12 ); |
---|
2381 | assert( (rpcSlice->getPPS()->getChromaCrQpOffset() + rpcSlice->getSliceQpDeltaCr()) >= -12 ); |
---|
2382 | assert( (rpcSlice->getPPS()->getChromaCrQpOffset() + rpcSlice->getSliceQpDeltaCr()) <= 12 ); |
---|
2383 | } |
---|
2384 | |
---|
2385 | if (rpcSlice->getPPS()->getDeblockingFilterControlPresentFlag()) |
---|
2386 | { |
---|
2387 | if(rpcSlice->getPPS()->getDeblockingFilterOverrideEnabledFlag()) |
---|
2388 | { |
---|
2389 | READ_FLAG ( uiCode, "deblocking_filter_override_flag" ); rpcSlice->setDeblockingFilterOverrideFlag(uiCode ? true : false); |
---|
2390 | } |
---|
2391 | else |
---|
2392 | { |
---|
2393 | rpcSlice->setDeblockingFilterOverrideFlag(0); |
---|
2394 | } |
---|
2395 | if(rpcSlice->getDeblockingFilterOverrideFlag()) |
---|
2396 | { |
---|
2397 | READ_FLAG ( uiCode, "slice_disable_deblocking_filter_flag" ); rpcSlice->setDeblockingFilterDisable(uiCode ? 1 : 0); |
---|
2398 | if(!rpcSlice->getDeblockingFilterDisable()) |
---|
2399 | { |
---|
2400 | READ_SVLC( iCode, "slice_beta_offset_div2" ); rpcSlice->setDeblockingFilterBetaOffsetDiv2(iCode); |
---|
2401 | assert(rpcSlice->getDeblockingFilterBetaOffsetDiv2() >= -6 && |
---|
2402 | rpcSlice->getDeblockingFilterBetaOffsetDiv2() <= 6); |
---|
2403 | READ_SVLC( iCode, "slice_tc_offset_div2" ); rpcSlice->setDeblockingFilterTcOffsetDiv2(iCode); |
---|
2404 | assert(rpcSlice->getDeblockingFilterTcOffsetDiv2() >= -6 && |
---|
2405 | rpcSlice->getDeblockingFilterTcOffsetDiv2() <= 6); |
---|
2406 | } |
---|
2407 | } |
---|
2408 | else |
---|
2409 | { |
---|
2410 | rpcSlice->setDeblockingFilterDisable ( rpcSlice->getPPS()->getPicDisableDeblockingFilterFlag() ); |
---|
2411 | rpcSlice->setDeblockingFilterBetaOffsetDiv2( rpcSlice->getPPS()->getDeblockingFilterBetaOffsetDiv2() ); |
---|
2412 | rpcSlice->setDeblockingFilterTcOffsetDiv2 ( rpcSlice->getPPS()->getDeblockingFilterTcOffsetDiv2() ); |
---|
2413 | } |
---|
2414 | } |
---|
2415 | else |
---|
2416 | { |
---|
2417 | rpcSlice->setDeblockingFilterDisable ( false ); |
---|
2418 | rpcSlice->setDeblockingFilterBetaOffsetDiv2( 0 ); |
---|
2419 | rpcSlice->setDeblockingFilterTcOffsetDiv2 ( 0 ); |
---|
2420 | } |
---|
2421 | |
---|
2422 | Bool isSAOEnabled = (!rpcSlice->getSPS()->getUseSAO())?(false):(rpcSlice->getSaoEnabledFlag()||rpcSlice->getSaoEnabledFlagChroma()); |
---|
2423 | Bool isDBFEnabled = (!rpcSlice->getDeblockingFilterDisable()); |
---|
2424 | |
---|
2425 | if(rpcSlice->getPPS()->getLoopFilterAcrossSlicesEnabledFlag() && ( isSAOEnabled || isDBFEnabled )) |
---|
2426 | { |
---|
2427 | READ_FLAG( uiCode, "slice_loop_filter_across_slices_enabled_flag"); |
---|
2428 | } |
---|
2429 | else |
---|
2430 | { |
---|
2431 | uiCode = rpcSlice->getPPS()->getLoopFilterAcrossSlicesEnabledFlag()?1:0; |
---|
2432 | } |
---|
2433 | rpcSlice->setLFCrossSliceBoundaryFlag( (uiCode==1)?true:false); |
---|
2434 | |
---|
2435 | } |
---|
2436 | |
---|
2437 | UInt *entryPointOffset = NULL; |
---|
2438 | UInt numEntryPointOffsets, offsetLenMinus1; |
---|
2439 | if( pps->getTilesEnabledFlag() || pps->getEntropyCodingSyncEnabledFlag() ) |
---|
2440 | { |
---|
2441 | READ_UVLC(numEntryPointOffsets, "num_entry_point_offsets"); rpcSlice->setNumEntryPointOffsets ( numEntryPointOffsets ); |
---|
2442 | if (numEntryPointOffsets>0) |
---|
2443 | { |
---|
2444 | READ_UVLC(offsetLenMinus1, "offset_len_minus1"); |
---|
2445 | } |
---|
2446 | entryPointOffset = new UInt[numEntryPointOffsets]; |
---|
2447 | for (UInt idx=0; idx<numEntryPointOffsets; idx++) |
---|
2448 | { |
---|
2449 | READ_CODE(offsetLenMinus1+1, uiCode, "entry_point_offset_minus1"); |
---|
2450 | entryPointOffset[ idx ] = uiCode + 1; |
---|
2451 | } |
---|
2452 | } |
---|
2453 | else |
---|
2454 | { |
---|
2455 | rpcSlice->setNumEntryPointOffsets ( 0 ); |
---|
2456 | } |
---|
2457 | |
---|
2458 | #if H_3D |
---|
2459 | if( rpcSlice->getVPS()->hasCamParInSliceHeader( rpcSlice->getViewIndex() ) && !rpcSlice->getIsDepth() ) |
---|
2460 | { |
---|
2461 | UInt uiViewIndex = rpcSlice->getViewIndex(); |
---|
2462 | for( UInt uiBaseIndex = 0; uiBaseIndex < uiViewIndex; uiBaseIndex++ ) |
---|
2463 | { |
---|
2464 | READ_SVLC( iCode, "cp_scale" ); m_aaiTempScale [ uiBaseIndex ][ uiViewIndex ] = iCode; |
---|
2465 | READ_SVLC( iCode, "cp_off" ); m_aaiTempOffset[ uiBaseIndex ][ uiViewIndex ] = iCode; |
---|
2466 | READ_SVLC( iCode, "cp_inv_scale_plus_scale" ); m_aaiTempScale [ uiViewIndex ][ uiBaseIndex ] = iCode - m_aaiTempScale [ uiBaseIndex ][ uiViewIndex ]; |
---|
2467 | READ_SVLC( iCode, "cp_inv_off_plus_off" ); m_aaiTempOffset[ uiViewIndex ][ uiBaseIndex ] = iCode - m_aaiTempOffset[ uiBaseIndex ][ uiViewIndex ]; |
---|
2468 | } |
---|
2469 | rpcSlice->setCamparaSlice( m_aaiTempScale, m_aaiTempOffset ); |
---|
2470 | } |
---|
2471 | #endif |
---|
2472 | |
---|
2473 | if(pps->getSliceHeaderExtensionPresentFlag()) |
---|
2474 | { |
---|
2475 | READ_UVLC(uiCode,"slice_header_extension_length"); |
---|
2476 | |
---|
2477 | for(Int i=0; i<uiCode; i++) |
---|
2478 | { |
---|
2479 | UInt ignore; |
---|
2480 | READ_CODE(8,ignore,"slice_header_extension_data_byte"); |
---|
2481 | } |
---|
2482 | } |
---|
2483 | |
---|
2484 | m_pcBitstream->readByteAlignment(); |
---|
2485 | |
---|
2486 | if( pps->getTilesEnabledFlag() || pps->getEntropyCodingSyncEnabledFlag() ) |
---|
2487 | { |
---|
2488 | Int endOfSliceHeaderLocation = m_pcBitstream->getByteLocation(); |
---|
2489 | |
---|
2490 | // Adjust endOfSliceHeaderLocation to account for emulation prevention bytes in the slice segment header |
---|
2491 | for ( UInt curByteIdx = 0; curByteIdx<m_pcBitstream->numEmulationPreventionBytesRead(); curByteIdx++ ) |
---|
2492 | { |
---|
2493 | if ( m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) < endOfSliceHeaderLocation ) |
---|
2494 | { |
---|
2495 | endOfSliceHeaderLocation++; |
---|
2496 | } |
---|
2497 | } |
---|
2498 | |
---|
2499 | Int curEntryPointOffset = 0; |
---|
2500 | Int prevEntryPointOffset = 0; |
---|
2501 | for (UInt idx=0; idx<numEntryPointOffsets; idx++) |
---|
2502 | { |
---|
2503 | curEntryPointOffset += entryPointOffset[ idx ]; |
---|
2504 | |
---|
2505 | Int emulationPreventionByteCount = 0; |
---|
2506 | for ( UInt curByteIdx = 0; curByteIdx<m_pcBitstream->numEmulationPreventionBytesRead(); curByteIdx++ ) |
---|
2507 | { |
---|
2508 | if ( m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) >= ( prevEntryPointOffset + endOfSliceHeaderLocation ) && |
---|
2509 | m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) < ( curEntryPointOffset + endOfSliceHeaderLocation ) ) |
---|
2510 | { |
---|
2511 | emulationPreventionByteCount++; |
---|
2512 | } |
---|
2513 | } |
---|
2514 | |
---|
2515 | entryPointOffset[ idx ] -= emulationPreventionByteCount; |
---|
2516 | prevEntryPointOffset = curEntryPointOffset; |
---|
2517 | } |
---|
2518 | |
---|
2519 | if ( pps->getTilesEnabledFlag() ) |
---|
2520 | { |
---|
2521 | rpcSlice->setTileLocationCount( numEntryPointOffsets ); |
---|
2522 | |
---|
2523 | UInt prevPos = 0; |
---|
2524 | for (Int idx=0; idx<rpcSlice->getTileLocationCount(); idx++) |
---|
2525 | { |
---|
2526 | rpcSlice->setTileLocation( idx, prevPos + entryPointOffset [ idx ] ); |
---|
2527 | prevPos += entryPointOffset[ idx ]; |
---|
2528 | } |
---|
2529 | } |
---|
2530 | else if ( pps->getEntropyCodingSyncEnabledFlag() ) |
---|
2531 | { |
---|
2532 | Int numSubstreams = rpcSlice->getNumEntryPointOffsets()+1; |
---|
2533 | rpcSlice->allocSubstreamSizes(numSubstreams); |
---|
2534 | UInt *pSubstreamSizes = rpcSlice->getSubstreamSizes(); |
---|
2535 | for (Int idx=0; idx<numSubstreams-1; idx++) |
---|
2536 | { |
---|
2537 | if ( idx < numEntryPointOffsets ) |
---|
2538 | { |
---|
2539 | pSubstreamSizes[ idx ] = ( entryPointOffset[ idx ] << 3 ) ; |
---|
2540 | } |
---|
2541 | else |
---|
2542 | { |
---|
2543 | pSubstreamSizes[ idx ] = 0; |
---|
2544 | } |
---|
2545 | } |
---|
2546 | } |
---|
2547 | |
---|
2548 | if (entryPointOffset) |
---|
2549 | { |
---|
2550 | delete [] entryPointOffset; |
---|
2551 | } |
---|
2552 | } |
---|
2553 | |
---|
2554 | return; |
---|
2555 | } |
---|
2556 | |
---|
2557 | Void TDecCavlc::parsePTL( TComPTL *rpcPTL, Bool profilePresentFlag, Int maxNumSubLayersMinus1 ) |
---|
2558 | { |
---|
2559 | UInt uiCode; |
---|
2560 | if(profilePresentFlag) |
---|
2561 | { |
---|
2562 | parseProfileTier(rpcPTL->getGeneralPTL()); |
---|
2563 | } |
---|
2564 | READ_CODE( 8, uiCode, "general_level_idc" ); rpcPTL->getGeneralPTL()->setLevelIdc(uiCode); |
---|
2565 | |
---|
2566 | for (Int i = 0; i < maxNumSubLayersMinus1; i++) |
---|
2567 | { |
---|
2568 | #if !H_MV |
---|
2569 | if(profilePresentFlag) |
---|
2570 | { |
---|
2571 | #endif |
---|
2572 | READ_FLAG( uiCode, "sub_layer_profile_present_flag[i]" ); rpcPTL->setSubLayerProfilePresentFlag(i, uiCode); |
---|
2573 | #if H_MV |
---|
2574 | rpcPTL->setSubLayerProfilePresentFlag( i, profilePresentFlag && rpcPTL->getSubLayerProfilePresentFlag(i) ); |
---|
2575 | #else |
---|
2576 | } |
---|
2577 | #endif |
---|
2578 | READ_FLAG( uiCode, "sub_layer_level_present_flag[i]" ); rpcPTL->setSubLayerLevelPresentFlag (i, uiCode); |
---|
2579 | } |
---|
2580 | |
---|
2581 | if (maxNumSubLayersMinus1 > 0) |
---|
2582 | { |
---|
2583 | for (Int i = maxNumSubLayersMinus1; i < 8; i++) |
---|
2584 | { |
---|
2585 | READ_CODE(2, uiCode, "reserved_zero_2bits"); |
---|
2586 | assert(uiCode == 0); |
---|
2587 | } |
---|
2588 | } |
---|
2589 | |
---|
2590 | for(Int i = 0; i < maxNumSubLayersMinus1; i++) |
---|
2591 | { |
---|
2592 | if( profilePresentFlag && rpcPTL->getSubLayerProfilePresentFlag(i) ) |
---|
2593 | { |
---|
2594 | parseProfileTier(rpcPTL->getSubLayerPTL(i)); |
---|
2595 | } |
---|
2596 | if(rpcPTL->getSubLayerLevelPresentFlag(i)) |
---|
2597 | { |
---|
2598 | READ_CODE( 8, uiCode, "sub_layer_level_idc[i]" ); rpcPTL->getSubLayerPTL(i)->setLevelIdc(uiCode); |
---|
2599 | } |
---|
2600 | } |
---|
2601 | } |
---|
2602 | |
---|
2603 | Void TDecCavlc::parseProfileTier(ProfileTierLevel *ptl) |
---|
2604 | { |
---|
2605 | UInt uiCode; |
---|
2606 | READ_CODE(2 , uiCode, "XXX_profile_space[]"); ptl->setProfileSpace(uiCode); |
---|
2607 | READ_FLAG( uiCode, "XXX_tier_flag[]" ); ptl->setTierFlag (uiCode ? 1 : 0); |
---|
2608 | READ_CODE(5 , uiCode, "XXX_profile_idc[]" ); ptl->setProfileIdc (uiCode); |
---|
2609 | for(Int j = 0; j < 32; j++) |
---|
2610 | { |
---|
2611 | READ_FLAG( uiCode, "XXX_profile_compatibility_flag[][j]"); ptl->setProfileCompatibilityFlag(j, uiCode ? 1 : 0); |
---|
2612 | } |
---|
2613 | READ_FLAG(uiCode, "general_progressive_source_flag"); |
---|
2614 | ptl->setProgressiveSourceFlag(uiCode ? true : false); |
---|
2615 | |
---|
2616 | READ_FLAG(uiCode, "general_interlaced_source_flag"); |
---|
2617 | ptl->setInterlacedSourceFlag(uiCode ? true : false); |
---|
2618 | |
---|
2619 | READ_FLAG(uiCode, "general_non_packed_constraint_flag"); |
---|
2620 | ptl->setNonPackedConstraintFlag(uiCode ? true : false); |
---|
2621 | |
---|
2622 | READ_FLAG(uiCode, "general_frame_only_constraint_flag"); |
---|
2623 | ptl->setFrameOnlyConstraintFlag(uiCode ? true : false); |
---|
2624 | |
---|
2625 | READ_CODE(16, uiCode, "XXX_reserved_zero_44bits[0..15]"); |
---|
2626 | READ_CODE(16, uiCode, "XXX_reserved_zero_44bits[16..31]"); |
---|
2627 | READ_CODE(12, uiCode, "XXX_reserved_zero_44bits[32..43]"); |
---|
2628 | } |
---|
2629 | |
---|
2630 | Void TDecCavlc::parseTerminatingBit( UInt& ruiBit ) |
---|
2631 | { |
---|
2632 | ruiBit = false; |
---|
2633 | Int iBitsLeft = m_pcBitstream->getNumBitsLeft(); |
---|
2634 | if(iBitsLeft <= 8) |
---|
2635 | { |
---|
2636 | UInt uiPeekValue = m_pcBitstream->peekBits(iBitsLeft); |
---|
2637 | if (uiPeekValue == (1<<(iBitsLeft-1))) |
---|
2638 | { |
---|
2639 | ruiBit = true; |
---|
2640 | } |
---|
2641 | } |
---|
2642 | } |
---|
2643 | |
---|
2644 | Void TDecCavlc::parseSkipFlag( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
2645 | { |
---|
2646 | assert(0); |
---|
2647 | } |
---|
2648 | |
---|
2649 | Void TDecCavlc::parseCUTransquantBypassFlag( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
2650 | { |
---|
2651 | assert(0); |
---|
2652 | } |
---|
2653 | |
---|
2654 | Void TDecCavlc::parseMVPIdx( Int& /*riMVPIdx*/ ) |
---|
2655 | { |
---|
2656 | assert(0); |
---|
2657 | } |
---|
2658 | |
---|
2659 | Void TDecCavlc::parseSplitFlag ( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
2660 | { |
---|
2661 | assert(0); |
---|
2662 | } |
---|
2663 | |
---|
2664 | Void TDecCavlc::parsePartSize( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
2665 | { |
---|
2666 | assert(0); |
---|
2667 | } |
---|
2668 | |
---|
2669 | Void TDecCavlc::parsePredMode( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
2670 | { |
---|
2671 | assert(0); |
---|
2672 | } |
---|
2673 | |
---|
2674 | /** Parse I_PCM information. |
---|
2675 | * \param pcCU pointer to CU |
---|
2676 | * \param uiAbsPartIdx CU index |
---|
2677 | * \param uiDepth CU depth |
---|
2678 | * \returns Void |
---|
2679 | * |
---|
2680 | * If I_PCM flag indicates that the CU is I_PCM, parse its PCM alignment bits and codes. |
---|
2681 | */ |
---|
2682 | Void TDecCavlc::parseIPCMInfo( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
2683 | { |
---|
2684 | assert(0); |
---|
2685 | } |
---|
2686 | |
---|
2687 | Void TDecCavlc::parseIntraDirLumaAng ( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
2688 | { |
---|
2689 | assert(0); |
---|
2690 | } |
---|
2691 | |
---|
2692 | Void TDecCavlc::parseIntraDirChroma( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
2693 | { |
---|
2694 | assert(0); |
---|
2695 | } |
---|
2696 | |
---|
2697 | Void TDecCavlc::parseInterDir( TComDataCU* /*pcCU*/, UInt& /*ruiInterDir*/, UInt /*uiAbsPartIdx*/ ) |
---|
2698 | { |
---|
2699 | assert(0); |
---|
2700 | } |
---|
2701 | |
---|
2702 | Void TDecCavlc::parseRefFrmIdx( TComDataCU* /*pcCU*/, Int& /*riRefFrmIdx*/, RefPicList /*eRefList*/ ) |
---|
2703 | { |
---|
2704 | assert(0); |
---|
2705 | } |
---|
2706 | |
---|
2707 | Void TDecCavlc::parseMvd( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiPartIdx*/, UInt /*uiDepth*/, RefPicList /*eRefList*/ ) |
---|
2708 | { |
---|
2709 | assert(0); |
---|
2710 | } |
---|
2711 | |
---|
2712 | Void TDecCavlc::parseDeltaQP( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2713 | { |
---|
2714 | Int qp; |
---|
2715 | Int iDQp; |
---|
2716 | |
---|
2717 | xReadSvlc( iDQp ); |
---|
2718 | |
---|
2719 | Int qpBdOffsetY = pcCU->getSlice()->getSPS()->getQpBDOffsetY(); |
---|
2720 | qp = (((Int) pcCU->getRefQP( uiAbsPartIdx ) + iDQp + 52 + 2*qpBdOffsetY )%(52+ qpBdOffsetY)) - qpBdOffsetY; |
---|
2721 | |
---|
2722 | UInt uiAbsQpCUPartIdx = (uiAbsPartIdx>>((g_uiMaxCUDepth - pcCU->getSlice()->getPPS()->getMaxCuDQPDepth())<<1))<<((g_uiMaxCUDepth - pcCU->getSlice()->getPPS()->getMaxCuDQPDepth())<<1) ; |
---|
2723 | UInt uiQpCUDepth = min(uiDepth,pcCU->getSlice()->getPPS()->getMaxCuDQPDepth()) ; |
---|
2724 | |
---|
2725 | pcCU->setQPSubParts( qp, uiAbsQpCUPartIdx, uiQpCUDepth ); |
---|
2726 | } |
---|
2727 | |
---|
2728 | Void TDecCavlc::parseCoeffNxN( TComDataCU* /*pcCU*/, TCoeff* /*pcCoef*/, UInt /*uiAbsPartIdx*/, UInt /*uiWidth*/, UInt /*uiHeight*/, UInt /*uiDepth*/, TextType /*eTType*/ ) |
---|
2729 | { |
---|
2730 | assert(0); |
---|
2731 | } |
---|
2732 | |
---|
2733 | Void TDecCavlc::parseTransformSubdivFlag( UInt& /*ruiSubdivFlag*/, UInt /*uiLog2TransformBlockSize*/ ) |
---|
2734 | { |
---|
2735 | assert(0); |
---|
2736 | } |
---|
2737 | |
---|
2738 | Void TDecCavlc::parseQtCbf( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, TextType /*eType*/, UInt /*uiTrDepth*/, UInt /*uiDepth*/ ) |
---|
2739 | { |
---|
2740 | assert(0); |
---|
2741 | } |
---|
2742 | |
---|
2743 | Void TDecCavlc::parseQtRootCbf( UInt /*uiAbsPartIdx*/, UInt& /*uiQtRootCbf*/ ) |
---|
2744 | { |
---|
2745 | assert(0); |
---|
2746 | } |
---|
2747 | |
---|
2748 | Void TDecCavlc::parseTransformSkipFlags (TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*width*/, UInt /*height*/, UInt /*uiDepth*/, TextType /*eTType*/) |
---|
2749 | { |
---|
2750 | assert(0); |
---|
2751 | } |
---|
2752 | |
---|
2753 | Void TDecCavlc::parseMergeFlag ( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/, UInt /*uiPUIdx*/ ) |
---|
2754 | { |
---|
2755 | assert(0); |
---|
2756 | } |
---|
2757 | |
---|
2758 | Void TDecCavlc::parseMergeIndex ( TComDataCU* /*pcCU*/, UInt& /*ruiMergeIndex*/ ) |
---|
2759 | { |
---|
2760 | assert(0); |
---|
2761 | } |
---|
2762 | |
---|
2763 | #if H_3D_ARP |
---|
2764 | Void TDecCavlc::parseARPW( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2765 | { |
---|
2766 | assert(0); |
---|
2767 | } |
---|
2768 | #endif |
---|
2769 | #if H_3D_IC |
---|
2770 | Void TDecCavlc::parseICFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2771 | { |
---|
2772 | assert(0); |
---|
2773 | } |
---|
2774 | #endif |
---|
2775 | #if H_3D_INTER_SDC |
---|
2776 | #if QC_SDC_UNIFY_G0130 |
---|
2777 | Void TDecCavlc::parseDeltaDC( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
2778 | { |
---|
2779 | assert(0); |
---|
2780 | } |
---|
2781 | |
---|
2782 | Void TDecCavlc::parseSDCFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2783 | { |
---|
2784 | assert(0); |
---|
2785 | } |
---|
2786 | #else |
---|
2787 | Void TDecCavlc::parseInterSDCFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2788 | { |
---|
2789 | assert(0); |
---|
2790 | } |
---|
2791 | |
---|
2792 | Void TDecCavlc::parseInterSDCResidualData ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPart ) |
---|
2793 | { |
---|
2794 | assert(0); |
---|
2795 | } |
---|
2796 | #endif |
---|
2797 | #endif |
---|
2798 | // ==================================================================================================================== |
---|
2799 | // Protected member functions |
---|
2800 | // ==================================================================================================================== |
---|
2801 | |
---|
2802 | /** parse explicit wp tables |
---|
2803 | * \param TComSlice* pcSlice |
---|
2804 | * \returns Void |
---|
2805 | */ |
---|
2806 | Void TDecCavlc::xParsePredWeightTable( TComSlice* pcSlice ) |
---|
2807 | { |
---|
2808 | wpScalingParam *wp; |
---|
2809 | Bool bChroma = true; // color always present in HEVC ? |
---|
2810 | SliceType eSliceType = pcSlice->getSliceType(); |
---|
2811 | Int iNbRef = (eSliceType == B_SLICE ) ? (2) : (1); |
---|
2812 | UInt uiLog2WeightDenomLuma, uiLog2WeightDenomChroma; |
---|
2813 | UInt uiTotalSignalledWeightFlags = 0; |
---|
2814 | |
---|
2815 | Int iDeltaDenom; |
---|
2816 | // decode delta_luma_log2_weight_denom : |
---|
2817 | READ_UVLC( uiLog2WeightDenomLuma, "luma_log2_weight_denom" ); // ue(v): luma_log2_weight_denom |
---|
2818 | assert( uiLog2WeightDenomLuma <= 7 ); |
---|
2819 | if( bChroma ) |
---|
2820 | { |
---|
2821 | READ_SVLC( iDeltaDenom, "delta_chroma_log2_weight_denom" ); // se(v): delta_chroma_log2_weight_denom |
---|
2822 | assert((iDeltaDenom + (Int)uiLog2WeightDenomLuma)>=0); |
---|
2823 | assert((iDeltaDenom + (Int)uiLog2WeightDenomLuma)<=7); |
---|
2824 | uiLog2WeightDenomChroma = (UInt)(iDeltaDenom + uiLog2WeightDenomLuma); |
---|
2825 | } |
---|
2826 | |
---|
2827 | for ( Int iNumRef=0 ; iNumRef<iNbRef ; iNumRef++ ) |
---|
2828 | { |
---|
2829 | RefPicList eRefPicList = ( iNumRef ? REF_PIC_LIST_1 : REF_PIC_LIST_0 ); |
---|
2830 | for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ ) |
---|
2831 | { |
---|
2832 | pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); |
---|
2833 | |
---|
2834 | wp[0].uiLog2WeightDenom = uiLog2WeightDenomLuma; |
---|
2835 | wp[1].uiLog2WeightDenom = uiLog2WeightDenomChroma; |
---|
2836 | wp[2].uiLog2WeightDenom = uiLog2WeightDenomChroma; |
---|
2837 | |
---|
2838 | UInt uiCode; |
---|
2839 | READ_FLAG( uiCode, "luma_weight_lX_flag" ); // u(1): luma_weight_l0_flag |
---|
2840 | wp[0].bPresentFlag = ( uiCode == 1 ); |
---|
2841 | uiTotalSignalledWeightFlags += wp[0].bPresentFlag; |
---|
2842 | } |
---|
2843 | if ( bChroma ) |
---|
2844 | { |
---|
2845 | UInt uiCode; |
---|
2846 | for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ ) |
---|
2847 | { |
---|
2848 | pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); |
---|
2849 | READ_FLAG( uiCode, "chroma_weight_lX_flag" ); // u(1): chroma_weight_l0_flag |
---|
2850 | wp[1].bPresentFlag = ( uiCode == 1 ); |
---|
2851 | wp[2].bPresentFlag = ( uiCode == 1 ); |
---|
2852 | uiTotalSignalledWeightFlags += 2*wp[1].bPresentFlag; |
---|
2853 | } |
---|
2854 | } |
---|
2855 | for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ ) |
---|
2856 | { |
---|
2857 | pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); |
---|
2858 | if ( wp[0].bPresentFlag ) |
---|
2859 | { |
---|
2860 | Int iDeltaWeight; |
---|
2861 | READ_SVLC( iDeltaWeight, "delta_luma_weight_lX" ); // se(v): delta_luma_weight_l0[i] |
---|
2862 | assert( iDeltaWeight >= -128 ); |
---|
2863 | assert( iDeltaWeight <= 127 ); |
---|
2864 | wp[0].iWeight = (iDeltaWeight + (1<<wp[0].uiLog2WeightDenom)); |
---|
2865 | READ_SVLC( wp[0].iOffset, "luma_offset_lX" ); // se(v): luma_offset_l0[i] |
---|
2866 | assert( wp[0].iOffset >= -128 ); |
---|
2867 | assert( wp[0].iOffset <= 127 ); |
---|
2868 | } |
---|
2869 | else |
---|
2870 | { |
---|
2871 | wp[0].iWeight = (1 << wp[0].uiLog2WeightDenom); |
---|
2872 | wp[0].iOffset = 0; |
---|
2873 | } |
---|
2874 | if ( bChroma ) |
---|
2875 | { |
---|
2876 | if ( wp[1].bPresentFlag ) |
---|
2877 | { |
---|
2878 | for ( Int j=1 ; j<3 ; j++ ) |
---|
2879 | { |
---|
2880 | Int iDeltaWeight; |
---|
2881 | READ_SVLC( iDeltaWeight, "delta_chroma_weight_lX" ); // se(v): chroma_weight_l0[i][j] |
---|
2882 | assert( iDeltaWeight >= -128 ); |
---|
2883 | assert( iDeltaWeight <= 127 ); |
---|
2884 | wp[j].iWeight = (iDeltaWeight + (1<<wp[1].uiLog2WeightDenom)); |
---|
2885 | |
---|
2886 | Int iDeltaChroma; |
---|
2887 | READ_SVLC( iDeltaChroma, "delta_chroma_offset_lX" ); // se(v): delta_chroma_offset_l0[i][j] |
---|
2888 | assert( iDeltaChroma >= -512 ); |
---|
2889 | assert( iDeltaChroma <= 511 ); |
---|
2890 | Int pred = ( 128 - ( ( 128*wp[j].iWeight)>>(wp[j].uiLog2WeightDenom) ) ); |
---|
2891 | wp[j].iOffset = Clip3(-128, 127, (iDeltaChroma + pred) ); |
---|
2892 | } |
---|
2893 | } |
---|
2894 | else |
---|
2895 | { |
---|
2896 | for ( Int j=1 ; j<3 ; j++ ) |
---|
2897 | { |
---|
2898 | wp[j].iWeight = (1 << wp[j].uiLog2WeightDenom); |
---|
2899 | wp[j].iOffset = 0; |
---|
2900 | } |
---|
2901 | } |
---|
2902 | } |
---|
2903 | } |
---|
2904 | |
---|
2905 | for ( Int iRefIdx=pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx<MAX_NUM_REF ; iRefIdx++ ) |
---|
2906 | { |
---|
2907 | pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); |
---|
2908 | |
---|
2909 | wp[0].bPresentFlag = false; |
---|
2910 | wp[1].bPresentFlag = false; |
---|
2911 | wp[2].bPresentFlag = false; |
---|
2912 | } |
---|
2913 | } |
---|
2914 | assert(uiTotalSignalledWeightFlags<=24); |
---|
2915 | } |
---|
2916 | |
---|
2917 | /** decode quantization matrix |
---|
2918 | * \param scalingList quantization matrix information |
---|
2919 | */ |
---|
2920 | Void TDecCavlc::parseScalingList(TComScalingList* scalingList) |
---|
2921 | { |
---|
2922 | UInt code, sizeId, listId; |
---|
2923 | Bool scalingListPredModeFlag; |
---|
2924 | //for each size |
---|
2925 | for(sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
2926 | { |
---|
2927 | for(listId = 0; listId < g_scalingListNum[sizeId]; listId++) |
---|
2928 | { |
---|
2929 | READ_FLAG( code, "scaling_list_pred_mode_flag"); |
---|
2930 | scalingListPredModeFlag = (code) ? true : false; |
---|
2931 | if(!scalingListPredModeFlag) //Copy Mode |
---|
2932 | { |
---|
2933 | READ_UVLC( code, "scaling_list_pred_matrix_id_delta"); |
---|
2934 | scalingList->setRefMatrixId (sizeId,listId,(UInt)((Int)(listId)-(code))); |
---|
2935 | if( sizeId > SCALING_LIST_8x8 ) |
---|
2936 | { |
---|
2937 | scalingList->setScalingListDC(sizeId,listId,((listId == scalingList->getRefMatrixId (sizeId,listId))? 16 :scalingList->getScalingListDC(sizeId, scalingList->getRefMatrixId (sizeId,listId)))); |
---|
2938 | } |
---|
2939 | scalingList->processRefMatrix( sizeId, listId, scalingList->getRefMatrixId (sizeId,listId)); |
---|
2940 | |
---|
2941 | } |
---|
2942 | else //DPCM Mode |
---|
2943 | { |
---|
2944 | xDecodeScalingList(scalingList, sizeId, listId); |
---|
2945 | } |
---|
2946 | } |
---|
2947 | } |
---|
2948 | |
---|
2949 | return; |
---|
2950 | } |
---|
2951 | /** decode DPCM |
---|
2952 | * \param scalingList quantization matrix information |
---|
2953 | * \param sizeId size index |
---|
2954 | * \param listId list index |
---|
2955 | */ |
---|
2956 | Void TDecCavlc::xDecodeScalingList(TComScalingList *scalingList, UInt sizeId, UInt listId) |
---|
2957 | { |
---|
2958 | Int i,coefNum = min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId]); |
---|
2959 | Int data; |
---|
2960 | Int scalingListDcCoefMinus8 = 0; |
---|
2961 | Int nextCoef = SCALING_LIST_START_VALUE; |
---|
2962 | UInt* scan = (sizeId == 0) ? g_auiSigLastScan [ SCAN_DIAG ] [ 1 ] : g_sigLastScanCG32x32; |
---|
2963 | Int *dst = scalingList->getScalingListAddress(sizeId, listId); |
---|
2964 | |
---|
2965 | if( sizeId > SCALING_LIST_8x8 ) |
---|
2966 | { |
---|
2967 | READ_SVLC( scalingListDcCoefMinus8, "scaling_list_dc_coef_minus8"); |
---|
2968 | scalingList->setScalingListDC(sizeId,listId,scalingListDcCoefMinus8 + 8); |
---|
2969 | nextCoef = scalingList->getScalingListDC(sizeId,listId); |
---|
2970 | } |
---|
2971 | |
---|
2972 | for(i = 0; i < coefNum; i++) |
---|
2973 | { |
---|
2974 | READ_SVLC( data, "scaling_list_delta_coef"); |
---|
2975 | nextCoef = (nextCoef + data + 256 ) % 256; |
---|
2976 | dst[scan[i]] = nextCoef; |
---|
2977 | } |
---|
2978 | } |
---|
2979 | |
---|
2980 | Bool TDecCavlc::xMoreRbspData() |
---|
2981 | { |
---|
2982 | Int bitsLeft = m_pcBitstream->getNumBitsLeft(); |
---|
2983 | |
---|
2984 | // if there are more than 8 bits, it cannot be rbsp_trailing_bits |
---|
2985 | if (bitsLeft > 8) |
---|
2986 | { |
---|
2987 | return true; |
---|
2988 | } |
---|
2989 | |
---|
2990 | UChar lastByte = m_pcBitstream->peekBits(bitsLeft); |
---|
2991 | Int cnt = bitsLeft; |
---|
2992 | |
---|
2993 | // remove trailing bits equal to zero |
---|
2994 | while ((cnt>0) && ((lastByte & 1) == 0)) |
---|
2995 | { |
---|
2996 | lastByte >>= 1; |
---|
2997 | cnt--; |
---|
2998 | } |
---|
2999 | // remove bit equal to one |
---|
3000 | cnt--; |
---|
3001 | |
---|
3002 | // we should not have a negative number of bits |
---|
3003 | assert (cnt>=0); |
---|
3004 | |
---|
3005 | // we have more data, if cnt is not zero |
---|
3006 | return (cnt>0); |
---|
3007 | } |
---|
3008 | |
---|
3009 | //! \} |
---|
3010 | |
---|