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