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