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 | READ_FLAG( uiCode, "pps_scaling_list_data_present_flag" ); pcPPS->setScalingListPresentFlag( uiCode ? true : false ); |
---|
333 | if(pcPPS->getScalingListPresentFlag ()) |
---|
334 | { |
---|
335 | parseScalingList( pcPPS->getScalingList() ); |
---|
336 | } |
---|
337 | |
---|
338 | READ_FLAG( uiCode, "lists_modification_present_flag"); |
---|
339 | pcPPS->setListsModificationPresentFlag(uiCode); |
---|
340 | |
---|
341 | READ_UVLC( uiCode, "log2_parallel_merge_level_minus2"); |
---|
342 | pcPPS->setLog2ParallelMergeLevelMinus2 (uiCode); |
---|
343 | |
---|
344 | READ_FLAG( uiCode, "slice_segment_header_extension_present_flag"); |
---|
345 | pcPPS->setSliceHeaderExtensionPresentFlag(uiCode); |
---|
346 | |
---|
347 | READ_FLAG( uiCode, "pps_extension_flag"); |
---|
348 | if (uiCode) |
---|
349 | { |
---|
350 | while ( xMoreRbspData() ) |
---|
351 | { |
---|
352 | READ_FLAG( uiCode, "pps_extension_data_flag"); |
---|
353 | } |
---|
354 | } |
---|
355 | } |
---|
356 | |
---|
357 | Void TDecCavlc::parseVUI(TComVUI* pcVUI, TComSPS *pcSPS) |
---|
358 | { |
---|
359 | #if ENC_DEC_TRACE |
---|
360 | fprintf( g_hTrace, "----------- vui_parameters -----------\n"); |
---|
361 | #endif |
---|
362 | UInt uiCode; |
---|
363 | |
---|
364 | READ_FLAG( uiCode, "aspect_ratio_info_present_flag"); pcVUI->setAspectRatioInfoPresentFlag(uiCode); |
---|
365 | if (pcVUI->getAspectRatioInfoPresentFlag()) |
---|
366 | { |
---|
367 | READ_CODE(8, uiCode, "aspect_ratio_idc"); pcVUI->setAspectRatioIdc(uiCode); |
---|
368 | if (pcVUI->getAspectRatioIdc() == 255) |
---|
369 | { |
---|
370 | READ_CODE(16, uiCode, "sar_width"); pcVUI->setSarWidth(uiCode); |
---|
371 | READ_CODE(16, uiCode, "sar_height"); pcVUI->setSarHeight(uiCode); |
---|
372 | } |
---|
373 | } |
---|
374 | |
---|
375 | READ_FLAG( uiCode, "overscan_info_present_flag"); pcVUI->setOverscanInfoPresentFlag(uiCode); |
---|
376 | if (pcVUI->getOverscanInfoPresentFlag()) |
---|
377 | { |
---|
378 | READ_FLAG( uiCode, "overscan_appropriate_flag"); pcVUI->setOverscanAppropriateFlag(uiCode); |
---|
379 | } |
---|
380 | |
---|
381 | READ_FLAG( uiCode, "video_signal_type_present_flag"); pcVUI->setVideoSignalTypePresentFlag(uiCode); |
---|
382 | if (pcVUI->getVideoSignalTypePresentFlag()) |
---|
383 | { |
---|
384 | READ_CODE(3, uiCode, "video_format"); pcVUI->setVideoFormat(uiCode); |
---|
385 | READ_FLAG( uiCode, "video_full_range_flag"); pcVUI->setVideoFullRangeFlag(uiCode); |
---|
386 | READ_FLAG( uiCode, "colour_description_present_flag"); pcVUI->setColourDescriptionPresentFlag(uiCode); |
---|
387 | if (pcVUI->getColourDescriptionPresentFlag()) |
---|
388 | { |
---|
389 | READ_CODE(8, uiCode, "colour_primaries"); pcVUI->setColourPrimaries(uiCode); |
---|
390 | READ_CODE(8, uiCode, "transfer_characteristics"); pcVUI->setTransferCharacteristics(uiCode); |
---|
391 | READ_CODE(8, uiCode, "matrix_coefficients"); pcVUI->setMatrixCoefficients(uiCode); |
---|
392 | } |
---|
393 | } |
---|
394 | |
---|
395 | READ_FLAG( uiCode, "chroma_loc_info_present_flag"); pcVUI->setChromaLocInfoPresentFlag(uiCode); |
---|
396 | if (pcVUI->getChromaLocInfoPresentFlag()) |
---|
397 | { |
---|
398 | READ_UVLC( uiCode, "chroma_sample_loc_type_top_field" ); pcVUI->setChromaSampleLocTypeTopField(uiCode); |
---|
399 | READ_UVLC( uiCode, "chroma_sample_loc_type_bottom_field" ); pcVUI->setChromaSampleLocTypeBottomField(uiCode); |
---|
400 | } |
---|
401 | |
---|
402 | READ_FLAG( uiCode, "neutral_chroma_indication_flag"); pcVUI->setNeutralChromaIndicationFlag(uiCode); |
---|
403 | |
---|
404 | READ_FLAG( uiCode, "field_seq_flag"); pcVUI->setFieldSeqFlag(uiCode); |
---|
405 | |
---|
406 | READ_FLAG(uiCode, "frame_field_info_present_flag"); pcVUI->setFrameFieldInfoPresentFlag(uiCode); |
---|
407 | |
---|
408 | READ_FLAG( uiCode, "default_display_window_flag"); |
---|
409 | if (uiCode != 0) |
---|
410 | { |
---|
411 | Window &defDisp = pcVUI->getDefaultDisplayWindow(); |
---|
412 | READ_UVLC( uiCode, "def_disp_win_left_offset" ); defDisp.setWindowLeftOffset ( uiCode * TComSPS::getWinUnitX( pcSPS->getChromaFormatIdc()) ); |
---|
413 | READ_UVLC( uiCode, "def_disp_win_right_offset" ); defDisp.setWindowRightOffset ( uiCode * TComSPS::getWinUnitX( pcSPS->getChromaFormatIdc()) ); |
---|
414 | READ_UVLC( uiCode, "def_disp_win_top_offset" ); defDisp.setWindowTopOffset ( uiCode * TComSPS::getWinUnitY( pcSPS->getChromaFormatIdc()) ); |
---|
415 | READ_UVLC( uiCode, "def_disp_win_bottom_offset" ); defDisp.setWindowBottomOffset( uiCode * TComSPS::getWinUnitY( pcSPS->getChromaFormatIdc()) ); |
---|
416 | } |
---|
417 | TimingInfo *timingInfo = pcVUI->getTimingInfo(); |
---|
418 | READ_FLAG( uiCode, "vui_timing_info_present_flag"); timingInfo->setTimingInfoPresentFlag (uiCode ? true : false); |
---|
419 | if(timingInfo->getTimingInfoPresentFlag()) |
---|
420 | { |
---|
421 | READ_CODE( 32, uiCode, "vui_num_units_in_tick"); timingInfo->setNumUnitsInTick (uiCode); |
---|
422 | READ_CODE( 32, uiCode, "vui_time_scale"); timingInfo->setTimeScale (uiCode); |
---|
423 | READ_FLAG( uiCode, "vui_poc_proportional_to_timing_flag"); timingInfo->setPocProportionalToTimingFlag(uiCode ? true : false); |
---|
424 | if(timingInfo->getPocProportionalToTimingFlag()) |
---|
425 | { |
---|
426 | READ_UVLC( uiCode, "vui_num_ticks_poc_diff_one_minus1"); timingInfo->setNumTicksPocDiffOneMinus1 (uiCode); |
---|
427 | } |
---|
428 | READ_FLAG( uiCode, "hrd_parameters_present_flag"); pcVUI->setHrdParametersPresentFlag(uiCode); |
---|
429 | if( pcVUI->getHrdParametersPresentFlag() ) |
---|
430 | { |
---|
431 | parseHrdParameters( pcVUI->getHrdParameters(), 1, pcSPS->getMaxTLayers() - 1 ); |
---|
432 | } |
---|
433 | } |
---|
434 | READ_FLAG( uiCode, "bitstream_restriction_flag"); pcVUI->setBitstreamRestrictionFlag(uiCode); |
---|
435 | if (pcVUI->getBitstreamRestrictionFlag()) |
---|
436 | { |
---|
437 | READ_FLAG( uiCode, "tiles_fixed_structure_flag"); pcVUI->setTilesFixedStructureFlag(uiCode); |
---|
438 | #if H_MV |
---|
439 | if ( pcSPS->getLayerId() > 0 ) |
---|
440 | { |
---|
441 | READ_FLAG( uiCode, "tile_boundaries_aligned_flag" ); pcVUI->setTileBoundariesAlignedFlag( uiCode == 1 ); |
---|
442 | } |
---|
443 | #endif |
---|
444 | READ_FLAG( uiCode, "motion_vectors_over_pic_boundaries_flag"); pcVUI->setMotionVectorsOverPicBoundariesFlag(uiCode); |
---|
445 | READ_FLAG( uiCode, "restricted_ref_pic_lists_flag"); pcVUI->setRestrictedRefPicListsFlag(uiCode); |
---|
446 | READ_UVLC( uiCode, "min_spatial_segmentation_idc"); pcVUI->setMinSpatialSegmentationIdc(uiCode); |
---|
447 | assert(uiCode < 4096); |
---|
448 | READ_UVLC( uiCode, "max_bytes_per_pic_denom" ); pcVUI->setMaxBytesPerPicDenom(uiCode); |
---|
449 | READ_UVLC( uiCode, "max_bits_per_mincu_denom" ); pcVUI->setMaxBitsPerMinCuDenom(uiCode); |
---|
450 | READ_UVLC( uiCode, "log2_max_mv_length_horizontal" ); pcVUI->setLog2MaxMvLengthHorizontal(uiCode); |
---|
451 | READ_UVLC( uiCode, "log2_max_mv_length_vertical" ); pcVUI->setLog2MaxMvLengthVertical(uiCode); |
---|
452 | } |
---|
453 | } |
---|
454 | |
---|
455 | Void TDecCavlc::parseHrdParameters(TComHRD *hrd, Bool commonInfPresentFlag, UInt maxNumSubLayersMinus1) |
---|
456 | { |
---|
457 | UInt uiCode; |
---|
458 | if( commonInfPresentFlag ) |
---|
459 | { |
---|
460 | READ_FLAG( uiCode, "nal_hrd_parameters_present_flag" ); hrd->setNalHrdParametersPresentFlag( uiCode == 1 ? true : false ); |
---|
461 | READ_FLAG( uiCode, "vcl_hrd_parameters_present_flag" ); hrd->setVclHrdParametersPresentFlag( uiCode == 1 ? true : false ); |
---|
462 | if( hrd->getNalHrdParametersPresentFlag() || hrd->getVclHrdParametersPresentFlag() ) |
---|
463 | { |
---|
464 | READ_FLAG( uiCode, "sub_pic_cpb_params_present_flag" ); hrd->setSubPicCpbParamsPresentFlag( uiCode == 1 ? true : false ); |
---|
465 | if( hrd->getSubPicCpbParamsPresentFlag() ) |
---|
466 | { |
---|
467 | READ_CODE( 8, uiCode, "tick_divisor_minus2" ); hrd->setTickDivisorMinus2( uiCode ); |
---|
468 | READ_CODE( 5, uiCode, "du_cpb_removal_delay_length_minus1" ); hrd->setDuCpbRemovalDelayLengthMinus1( uiCode ); |
---|
469 | READ_FLAG( uiCode, "sub_pic_cpb_params_in_pic_timing_sei_flag" ); hrd->setSubPicCpbParamsInPicTimingSEIFlag( uiCode == 1 ? true : false ); |
---|
470 | READ_CODE( 5, uiCode, "dpb_output_delay_du_length_minus1" ); hrd->setDpbOutputDelayDuLengthMinus1( uiCode ); |
---|
471 | } |
---|
472 | READ_CODE( 4, uiCode, "bit_rate_scale" ); hrd->setBitRateScale( uiCode ); |
---|
473 | READ_CODE( 4, uiCode, "cpb_size_scale" ); hrd->setCpbSizeScale( uiCode ); |
---|
474 | if( hrd->getSubPicCpbParamsPresentFlag() ) |
---|
475 | { |
---|
476 | READ_CODE( 4, uiCode, "cpb_size_du_scale" ); hrd->setDuCpbSizeScale( uiCode ); |
---|
477 | } |
---|
478 | READ_CODE( 5, uiCode, "initial_cpb_removal_delay_length_minus1" ); hrd->setInitialCpbRemovalDelayLengthMinus1( uiCode ); |
---|
479 | READ_CODE( 5, uiCode, "au_cpb_removal_delay_length_minus1" ); hrd->setCpbRemovalDelayLengthMinus1( uiCode ); |
---|
480 | READ_CODE( 5, uiCode, "dpb_output_delay_length_minus1" ); hrd->setDpbOutputDelayLengthMinus1( uiCode ); |
---|
481 | } |
---|
482 | } |
---|
483 | Int i, j, nalOrVcl; |
---|
484 | for( i = 0; i <= maxNumSubLayersMinus1; i ++ ) |
---|
485 | { |
---|
486 | READ_FLAG( uiCode, "fixed_pic_rate_general_flag" ); hrd->setFixedPicRateFlag( i, uiCode == 1 ? true : false ); |
---|
487 | if( !hrd->getFixedPicRateFlag( i ) ) |
---|
488 | { |
---|
489 | READ_FLAG( uiCode, "fixed_pic_rate_within_cvs_flag" ); hrd->setFixedPicRateWithinCvsFlag( i, uiCode == 1 ? true : false ); |
---|
490 | } |
---|
491 | else |
---|
492 | { |
---|
493 | hrd->setFixedPicRateWithinCvsFlag( i, true ); |
---|
494 | } |
---|
495 | hrd->setLowDelayHrdFlag( i, 0 ); // Infered to be 0 when not present |
---|
496 | hrd->setCpbCntMinus1 ( i, 0 ); // Infered to be 0 when not present |
---|
497 | if( hrd->getFixedPicRateWithinCvsFlag( i ) ) |
---|
498 | { |
---|
499 | READ_UVLC( uiCode, "elemental_duration_in_tc_minus1" ); hrd->setPicDurationInTcMinus1( i, uiCode ); |
---|
500 | } |
---|
501 | else |
---|
502 | { |
---|
503 | READ_FLAG( uiCode, "low_delay_hrd_flag" ); hrd->setLowDelayHrdFlag( i, uiCode == 1 ? true : false ); |
---|
504 | } |
---|
505 | if (!hrd->getLowDelayHrdFlag( i )) |
---|
506 | { |
---|
507 | READ_UVLC( uiCode, "cpb_cnt_minus1" ); hrd->setCpbCntMinus1( i, uiCode ); |
---|
508 | } |
---|
509 | for( nalOrVcl = 0; nalOrVcl < 2; nalOrVcl ++ ) |
---|
510 | { |
---|
511 | if( ( ( nalOrVcl == 0 ) && ( hrd->getNalHrdParametersPresentFlag() ) ) || |
---|
512 | ( ( nalOrVcl == 1 ) && ( hrd->getVclHrdParametersPresentFlag() ) ) ) |
---|
513 | { |
---|
514 | for( j = 0; j <= ( hrd->getCpbCntMinus1( i ) ); j ++ ) |
---|
515 | { |
---|
516 | READ_UVLC( uiCode, "bit_rate_value_minus1" ); hrd->setBitRateValueMinus1( i, j, nalOrVcl, uiCode ); |
---|
517 | READ_UVLC( uiCode, "cpb_size_value_minus1" ); hrd->setCpbSizeValueMinus1( i, j, nalOrVcl, uiCode ); |
---|
518 | if( hrd->getSubPicCpbParamsPresentFlag() ) |
---|
519 | { |
---|
520 | READ_UVLC( uiCode, "cpb_size_du_value_minus1" ); hrd->setDuCpbSizeValueMinus1( i, j, nalOrVcl, uiCode ); |
---|
521 | READ_UVLC( uiCode, "bit_rate_du_value_minus1" ); hrd->setDuBitRateValueMinus1( i, j, nalOrVcl, uiCode ); |
---|
522 | } |
---|
523 | READ_FLAG( uiCode, "cbr_flag" ); hrd->setCbrFlag( i, j, nalOrVcl, uiCode == 1 ? true : false ); |
---|
524 | } |
---|
525 | } |
---|
526 | } |
---|
527 | } |
---|
528 | } |
---|
529 | |
---|
530 | #if H_3D |
---|
531 | Void TDecCavlc::parseSPS(TComSPS* pcSPS, Int viewIndex, Bool depthFlag ) |
---|
532 | #else |
---|
533 | Void TDecCavlc::parseSPS(TComSPS* pcSPS) |
---|
534 | #endif |
---|
535 | { |
---|
536 | #if ENC_DEC_TRACE |
---|
537 | xTraceSPSHeader (pcSPS); |
---|
538 | #endif |
---|
539 | |
---|
540 | UInt uiCode; |
---|
541 | READ_CODE( 4, uiCode, "sps_video_parameter_set_id"); pcSPS->setVPSId ( uiCode ); |
---|
542 | #if H_MV |
---|
543 | if ( pcSPS->getLayerId() == 0 ) |
---|
544 | { |
---|
545 | #endif |
---|
546 | READ_CODE( 3, uiCode, "sps_max_sub_layers_minus1" ); pcSPS->setMaxTLayers ( uiCode+1 ); |
---|
547 | assert(uiCode <= 6); |
---|
548 | |
---|
549 | READ_FLAG( uiCode, "sps_temporal_id_nesting_flag" ); pcSPS->setTemporalIdNestingFlag ( uiCode > 0 ? true : false ); |
---|
550 | if ( pcSPS->getMaxTLayers() == 1 ) |
---|
551 | { |
---|
552 | // sps_temporal_id_nesting_flag must be 1 when sps_max_sub_layers_minus1 is 0 |
---|
553 | assert( uiCode == 1 ); |
---|
554 | } |
---|
555 | |
---|
556 | parsePTL(pcSPS->getPTL(), 1, pcSPS->getMaxTLayers() - 1); |
---|
557 | #if H_MV |
---|
558 | } |
---|
559 | #endif |
---|
560 | READ_UVLC( uiCode, "sps_seq_parameter_set_id" ); pcSPS->setSPSId( uiCode ); |
---|
561 | assert(uiCode <= 15); |
---|
562 | |
---|
563 | READ_UVLC( uiCode, "chroma_format_idc" ); pcSPS->setChromaFormatIdc( uiCode ); |
---|
564 | assert(uiCode <= 3); |
---|
565 | // 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 |
---|
566 | assert (uiCode == 1); |
---|
567 | if( uiCode == 3 ) |
---|
568 | { |
---|
569 | READ_FLAG( uiCode, "separate_colour_plane_flag"); assert(uiCode == 0); |
---|
570 | } |
---|
571 | |
---|
572 | READ_UVLC ( uiCode, "pic_width_in_luma_samples" ); pcSPS->setPicWidthInLumaSamples ( uiCode ); |
---|
573 | READ_UVLC ( uiCode, "pic_height_in_luma_samples" ); pcSPS->setPicHeightInLumaSamples( uiCode ); |
---|
574 | READ_FLAG( uiCode, "conformance_window_flag"); |
---|
575 | if (uiCode != 0) |
---|
576 | { |
---|
577 | Window &conf = pcSPS->getConformanceWindow(); |
---|
578 | READ_UVLC( uiCode, "conf_win_left_offset" ); conf.setWindowLeftOffset ( uiCode * TComSPS::getWinUnitX( pcSPS->getChromaFormatIdc() ) ); |
---|
579 | READ_UVLC( uiCode, "conf_win_right_offset" ); conf.setWindowRightOffset ( uiCode * TComSPS::getWinUnitX( pcSPS->getChromaFormatIdc() ) ); |
---|
580 | READ_UVLC( uiCode, "conf_win_top_offset" ); conf.setWindowTopOffset ( uiCode * TComSPS::getWinUnitY( pcSPS->getChromaFormatIdc() ) ); |
---|
581 | READ_UVLC( uiCode, "conf_win_bottom_offset" ); conf.setWindowBottomOffset( uiCode * TComSPS::getWinUnitY( pcSPS->getChromaFormatIdc() ) ); |
---|
582 | } |
---|
583 | |
---|
584 | READ_UVLC( uiCode, "bit_depth_luma_minus8" ); |
---|
585 | assert(uiCode <= 6); |
---|
586 | pcSPS->setBitDepthY( uiCode + 8 ); |
---|
587 | pcSPS->setQpBDOffsetY( (Int) (6*uiCode) ); |
---|
588 | |
---|
589 | READ_UVLC( uiCode, "bit_depth_chroma_minus8" ); |
---|
590 | assert(uiCode <= 6); |
---|
591 | pcSPS->setBitDepthC( uiCode + 8 ); |
---|
592 | pcSPS->setQpBDOffsetC( (Int) (6*uiCode) ); |
---|
593 | |
---|
594 | READ_UVLC( uiCode, "log2_max_pic_order_cnt_lsb_minus4" ); pcSPS->setBitsForPOC( 4 + uiCode ); |
---|
595 | assert(uiCode <= 12); |
---|
596 | |
---|
597 | UInt subLayerOrderingInfoPresentFlag; |
---|
598 | READ_FLAG(subLayerOrderingInfoPresentFlag, "sps_sub_layer_ordering_info_present_flag"); |
---|
599 | |
---|
600 | for(UInt i=0; i <= pcSPS->getMaxTLayers()-1; i++) |
---|
601 | { |
---|
602 | #if H_MV |
---|
603 | READ_UVLC ( uiCode, "sps_max_dec_pic_buffering_minus1[i]"); |
---|
604 | #else |
---|
605 | READ_UVLC ( uiCode, "sps_max_dec_pic_buffering_minus1"); |
---|
606 | #endif |
---|
607 | pcSPS->setMaxDecPicBuffering( uiCode + 1, i); |
---|
608 | #if H_MV |
---|
609 | READ_UVLC ( uiCode, "sps_num_reorder_pics[i]" ); |
---|
610 | #else |
---|
611 | READ_UVLC ( uiCode, "sps_num_reorder_pics" ); |
---|
612 | #endif |
---|
613 | pcSPS->setNumReorderPics(uiCode, i); |
---|
614 | #if H_MV |
---|
615 | READ_UVLC ( uiCode, "sps_max_latency_increase[i]"); |
---|
616 | #else |
---|
617 | READ_UVLC ( uiCode, "sps_max_latency_increase"); |
---|
618 | #endif |
---|
619 | pcSPS->setMaxLatencyIncrease( uiCode, i ); |
---|
620 | |
---|
621 | if (!subLayerOrderingInfoPresentFlag) |
---|
622 | { |
---|
623 | for (i++; i <= pcSPS->getMaxTLayers()-1; i++) |
---|
624 | { |
---|
625 | pcSPS->setMaxDecPicBuffering(pcSPS->getMaxDecPicBuffering(0), i); |
---|
626 | pcSPS->setNumReorderPics(pcSPS->getNumReorderPics(0), i); |
---|
627 | pcSPS->setMaxLatencyIncrease(pcSPS->getMaxLatencyIncrease(0), i); |
---|
628 | } |
---|
629 | break; |
---|
630 | } |
---|
631 | } |
---|
632 | |
---|
633 | READ_UVLC( uiCode, "log2_min_coding_block_size_minus3" ); |
---|
634 | Int log2MinCUSize = uiCode + 3; |
---|
635 | pcSPS->setLog2MinCodingBlockSize(log2MinCUSize); |
---|
636 | READ_UVLC( uiCode, "log2_diff_max_min_coding_block_size" ); |
---|
637 | pcSPS->setLog2DiffMaxMinCodingBlockSize(uiCode); |
---|
638 | Int maxCUDepthDelta = uiCode; |
---|
639 | pcSPS->setMaxCUWidth ( 1<<(log2MinCUSize + maxCUDepthDelta) ); |
---|
640 | pcSPS->setMaxCUHeight ( 1<<(log2MinCUSize + maxCUDepthDelta) ); |
---|
641 | READ_UVLC( uiCode, "log2_min_transform_block_size_minus2" ); pcSPS->setQuadtreeTULog2MinSize( uiCode + 2 ); |
---|
642 | |
---|
643 | READ_UVLC( uiCode, "log2_diff_max_min_transform_block_size" ); pcSPS->setQuadtreeTULog2MaxSize( uiCode + pcSPS->getQuadtreeTULog2MinSize() ); |
---|
644 | pcSPS->setMaxTrSize( 1<<(uiCode + pcSPS->getQuadtreeTULog2MinSize()) ); |
---|
645 | |
---|
646 | READ_UVLC( uiCode, "max_transform_hierarchy_depth_inter" ); pcSPS->setQuadtreeTUMaxDepthInter( uiCode+1 ); |
---|
647 | READ_UVLC( uiCode, "max_transform_hierarchy_depth_intra" ); pcSPS->setQuadtreeTUMaxDepthIntra( uiCode+1 ); |
---|
648 | |
---|
649 | Int addCuDepth = max (0, log2MinCUSize - (Int)pcSPS->getQuadtreeTULog2MinSize() ); |
---|
650 | pcSPS->setMaxCUDepth( maxCUDepthDelta + addCuDepth ); |
---|
651 | |
---|
652 | READ_FLAG( uiCode, "scaling_list_enabled_flag" ); pcSPS->setScalingListFlag ( uiCode ); |
---|
653 | if(pcSPS->getScalingListFlag()) |
---|
654 | { |
---|
655 | READ_FLAG( uiCode, "sps_scaling_list_data_present_flag" ); pcSPS->setScalingListPresentFlag ( uiCode ); |
---|
656 | if(pcSPS->getScalingListPresentFlag ()) |
---|
657 | { |
---|
658 | parseScalingList( pcSPS->getScalingList() ); |
---|
659 | } |
---|
660 | } |
---|
661 | READ_FLAG( uiCode, "amp_enabled_flag" ); pcSPS->setUseAMP( uiCode ); |
---|
662 | READ_FLAG( uiCode, "sample_adaptive_offset_enabled_flag" ); pcSPS->setUseSAO ( uiCode ? true : false ); |
---|
663 | |
---|
664 | READ_FLAG( uiCode, "pcm_enabled_flag" ); pcSPS->setUsePCM( uiCode ? true : false ); |
---|
665 | if( pcSPS->getUsePCM() ) |
---|
666 | { |
---|
667 | READ_CODE( 4, uiCode, "pcm_sample_bit_depth_luma_minus1" ); pcSPS->setPCMBitDepthLuma ( 1 + uiCode ); |
---|
668 | READ_CODE( 4, uiCode, "pcm_sample_bit_depth_chroma_minus1" ); pcSPS->setPCMBitDepthChroma ( 1 + uiCode ); |
---|
669 | READ_UVLC( uiCode, "log2_min_pcm_luma_coding_block_size_minus3" ); pcSPS->setPCMLog2MinSize (uiCode+3); |
---|
670 | READ_UVLC( uiCode, "log2_diff_max_min_pcm_luma_coding_block_size" ); pcSPS->setPCMLog2MaxSize ( uiCode+pcSPS->getPCMLog2MinSize() ); |
---|
671 | READ_FLAG( uiCode, "pcm_loop_filter_disable_flag" ); pcSPS->setPCMFilterDisableFlag ( uiCode ? true : false ); |
---|
672 | } |
---|
673 | |
---|
674 | READ_UVLC( uiCode, "num_short_term_ref_pic_sets" ); |
---|
675 | assert(uiCode <= 64); |
---|
676 | pcSPS->createRPSList(uiCode); |
---|
677 | |
---|
678 | TComRPSList* rpsList = pcSPS->getRPSList(); |
---|
679 | TComReferencePictureSet* rps; |
---|
680 | |
---|
681 | for(UInt i=0; i< rpsList->getNumberOfReferencePictureSets(); i++) |
---|
682 | { |
---|
683 | rps = rpsList->getReferencePictureSet(i); |
---|
684 | parseShortTermRefPicSet(pcSPS,rps,i); |
---|
685 | } |
---|
686 | READ_FLAG( uiCode, "long_term_ref_pics_present_flag" ); pcSPS->setLongTermRefsPresent(uiCode); |
---|
687 | if (pcSPS->getLongTermRefsPresent()) |
---|
688 | { |
---|
689 | READ_UVLC( uiCode, "num_long_term_ref_pic_sps" ); |
---|
690 | pcSPS->setNumLongTermRefPicSPS(uiCode); |
---|
691 | for (UInt k = 0; k < pcSPS->getNumLongTermRefPicSPS(); k++) |
---|
692 | { |
---|
693 | READ_CODE( pcSPS->getBitsForPOC(), uiCode, "lt_ref_pic_poc_lsb_sps" ); |
---|
694 | pcSPS->setLtRefPicPocLsbSps(k, uiCode); |
---|
695 | READ_FLAG( uiCode, "used_by_curr_pic_lt_sps_flag[i]"); |
---|
696 | pcSPS->setUsedByCurrPicLtSPSFlag(k, uiCode?1:0); |
---|
697 | } |
---|
698 | } |
---|
699 | READ_FLAG( uiCode, "sps_temporal_mvp_enable_flag" ); pcSPS->setTMVPFlagsPresent(uiCode); |
---|
700 | |
---|
701 | READ_FLAG( uiCode, "sps_strong_intra_smoothing_enable_flag" ); pcSPS->setUseStrongIntraSmoothing(uiCode); |
---|
702 | |
---|
703 | READ_FLAG( uiCode, "vui_parameters_present_flag" ); pcSPS->setVuiParametersPresentFlag(uiCode); |
---|
704 | |
---|
705 | if (pcSPS->getVuiParametersPresentFlag()) |
---|
706 | { |
---|
707 | parseVUI(pcSPS->getVuiParameters(), pcSPS); |
---|
708 | } |
---|
709 | |
---|
710 | READ_FLAG( uiCode, "sps_extension_flag"); |
---|
711 | if (uiCode) |
---|
712 | { |
---|
713 | #if !H_MV |
---|
714 | while ( xMoreRbspData() ) |
---|
715 | { |
---|
716 | READ_FLAG( uiCode, "sps_extension_data_flag"); |
---|
717 | } |
---|
718 | #else |
---|
719 | READ_FLAG( uiCode, "inter_view_mv_vert_constraint_flag" ); pcSPS->setInterViewMvVertConstraintFlag(uiCode == 1 ? true : false); |
---|
720 | //// sps_extension_vui_parameters( ) |
---|
721 | if( pcSPS->getVuiParameters()->getBitstreamRestrictionFlag() ) |
---|
722 | { |
---|
723 | READ_UVLC( uiCode, "num_ilp_restricted_ref_layers" ); pcSPS->setNumIlpRestrictedRefLayers( uiCode ); |
---|
724 | for( Int i = 0; i < pcSPS->getNumIlpRestrictedRefLayers( ); i++ ) |
---|
725 | { |
---|
726 | READ_UVLC( uiCode, "min_spatial_segment_offset_plus1" ); pcSPS->setMinSpatialSegmentOffsetPlus1( i, uiCode ); |
---|
727 | if( pcSPS->getMinSpatialSegmentOffsetPlus1( i ) > 0 ) |
---|
728 | { |
---|
729 | READ_FLAG( uiCode, "ctu_based_offset_enabled_flag[ i ]"); pcSPS->setCtuBasedOffsetEnabledFlag(i, uiCode == 1 ); |
---|
730 | if( pcSPS->getCtuBasedOffsetEnabledFlag( i ) ) |
---|
731 | { |
---|
732 | READ_UVLC( uiCode, "min_horizontal_ctu_offset_plus1[ i ]"); pcSPS->setMinHorizontalCtuOffsetPlus1( i, uiCode ); |
---|
733 | } |
---|
734 | } |
---|
735 | } |
---|
736 | } |
---|
737 | |
---|
738 | #if H_3D_QTLPC |
---|
739 | if( depthFlag ) |
---|
740 | { |
---|
741 | READ_FLAG( uiCode, "use_qtl_flag" ); |
---|
742 | pcSPS->setUseQTL( uiCode ); |
---|
743 | READ_FLAG( uiCode, "use_pc_flag" ); |
---|
744 | pcSPS->setUsePC( uiCode ); |
---|
745 | } |
---|
746 | #endif |
---|
747 | //// sps_extension_vui_parameters( ) END |
---|
748 | READ_UVLC( uiCode, "sps_shvc_reserved_zero_idc" ); |
---|
749 | READ_FLAG( uiCode, "sps_extension2_flag"); |
---|
750 | if ( uiCode ) |
---|
751 | { |
---|
752 | #if !H_3D |
---|
753 | while ( xMoreRbspData() ) |
---|
754 | { |
---|
755 | READ_FLAG( uiCode, "sps_extension_data_flag"); |
---|
756 | } |
---|
757 | #else |
---|
758 | |
---|
759 | UInt uiCamParPrecision = 0; |
---|
760 | Bool bCamParSlice = false; |
---|
761 | if ( !depthFlag ) |
---|
762 | { |
---|
763 | READ_UVLC( uiCamParPrecision, "cp_precision" ); |
---|
764 | READ_FLAG( uiCode, "cp_in_slice_header_flag" ); bCamParSlice = ( uiCode == 1 ); |
---|
765 | if( !bCamParSlice ) |
---|
766 | { |
---|
767 | for( UInt uiBaseIndex = 0; uiBaseIndex < viewIndex; uiBaseIndex++ ) |
---|
768 | { |
---|
769 | Int iCode; |
---|
770 | READ_SVLC( iCode, "cp_scale" ); m_aaiTempScale [ uiBaseIndex ][ viewIndex ] = iCode; |
---|
771 | READ_SVLC( iCode, "cp_off" ); m_aaiTempOffset [ uiBaseIndex ][ viewIndex ] = iCode; |
---|
772 | READ_SVLC( iCode, "cp_inv_scale_plus_scale" ); m_aaiTempScale [ viewIndex ][ uiBaseIndex ] = iCode - m_aaiTempScale [ uiBaseIndex ][ viewIndex ]; |
---|
773 | READ_SVLC( iCode, "cp_inv_off_plus_off" ); m_aaiTempOffset [ viewIndex ][ uiBaseIndex ] = iCode - m_aaiTempOffset[ uiBaseIndex ][ viewIndex ]; |
---|
774 | } |
---|
775 | } |
---|
776 | } |
---|
777 | pcSPS->initCamParaSPS( viewIndex, uiCamParPrecision, bCamParSlice, m_aaiTempScale, m_aaiTempOffset ); |
---|
778 | READ_FLAG( uiCode, "sps_extension3_flag"); |
---|
779 | if ( uiCode ) |
---|
780 | { |
---|
781 | while ( xMoreRbspData() ) |
---|
782 | { |
---|
783 | READ_FLAG( uiCode, "sps_extension_data_flag"); |
---|
784 | } |
---|
785 | } |
---|
786 | #endif // !H_3D |
---|
787 | } |
---|
788 | #endif // !H_MV |
---|
789 | } |
---|
790 | } |
---|
791 | |
---|
792 | Void TDecCavlc::parseVPS(TComVPS* pcVPS) |
---|
793 | { |
---|
794 | UInt uiCode; |
---|
795 | |
---|
796 | READ_CODE( 4, uiCode, "vps_video_parameter_set_id" ); pcVPS->setVPSId( uiCode ); |
---|
797 | READ_CODE( 2, uiCode, "vps_reserved_three_2bits" ); assert(uiCode == 3); |
---|
798 | #if H_MV |
---|
799 | READ_CODE( 6, uiCode, "vps_max_layers_minus1" ); pcVPS->setMaxLayers( uiCode + 1 ); |
---|
800 | #else |
---|
801 | READ_CODE( 6, uiCode, "vps_reserved_zero_6bits" ); assert(uiCode == 0); |
---|
802 | #endif |
---|
803 | READ_CODE( 3, uiCode, "vps_max_sub_layers_minus1" ); pcVPS->setMaxTLayers( uiCode + 1 ); |
---|
804 | READ_FLAG( uiCode, "vps_temporal_id_nesting_flag" ); pcVPS->setTemporalNestingFlag( uiCode ? true:false ); |
---|
805 | assert (pcVPS->getMaxTLayers()>1||pcVPS->getTemporalNestingFlag()); |
---|
806 | #if H_MV |
---|
807 | READ_CODE( 16, uiCode, "vps_extension_offset" ); |
---|
808 | #else |
---|
809 | READ_CODE( 16, uiCode, "vps_reserved_ffff_16bits" ); assert(uiCode == 0xffff); |
---|
810 | #endif |
---|
811 | parsePTL ( pcVPS->getPTL(), true, pcVPS->getMaxTLayers()-1); |
---|
812 | UInt subLayerOrderingInfoPresentFlag; |
---|
813 | READ_FLAG(subLayerOrderingInfoPresentFlag, "vps_sub_layer_ordering_info_present_flag"); |
---|
814 | for(UInt i = 0; i <= pcVPS->getMaxTLayers()-1; i++) |
---|
815 | { |
---|
816 | READ_UVLC( uiCode, "vps_max_dec_pic_buffering_minus1[i]" ); pcVPS->setMaxDecPicBuffering( uiCode + 1, i ); |
---|
817 | READ_UVLC( uiCode, "vps_num_reorder_pics[i]" ); pcVPS->setNumReorderPics( uiCode, i ); |
---|
818 | READ_UVLC( uiCode, "vps_max_latency_increase_plus1[i]" ); pcVPS->setMaxLatencyIncrease( uiCode, i ); |
---|
819 | |
---|
820 | if (!subLayerOrderingInfoPresentFlag) |
---|
821 | { |
---|
822 | for (i++; i <= pcVPS->getMaxTLayers()-1; i++) |
---|
823 | { |
---|
824 | pcVPS->setMaxDecPicBuffering(pcVPS->getMaxDecPicBuffering(0), i); |
---|
825 | pcVPS->setNumReorderPics(pcVPS->getNumReorderPics(0), i); |
---|
826 | pcVPS->setMaxLatencyIncrease(pcVPS->getMaxLatencyIncrease(0), i); |
---|
827 | } |
---|
828 | break; |
---|
829 | } |
---|
830 | } |
---|
831 | |
---|
832 | assert( pcVPS->getNumHrdParameters() < MAX_VPS_OP_SETS_PLUS1 ); |
---|
833 | #if H_MV |
---|
834 | assert( pcVPS->getVpsMaxLayerId() < MAX_VPS_NUH_LAYER_ID_PLUS1 ); |
---|
835 | READ_CODE( 6, uiCode, "vps_max_layer_id" ); pcVPS->setVpsMaxLayerId( uiCode ); |
---|
836 | |
---|
837 | READ_UVLC( uiCode, "vps_max_num_layer_sets_minus1" ); pcVPS->setVpsNumLayerSetsMinus1( uiCode ); |
---|
838 | for( UInt opsIdx = 1; opsIdx <= pcVPS->getVpsNumLayerSetsMinus1(); opsIdx ++ ) |
---|
839 | { |
---|
840 | for( UInt i = 0; i <= pcVPS->getVpsMaxLayerId(); i ++ ) |
---|
841 | #else |
---|
842 | assert( pcVPS->getMaxNuhReservedZeroLayerId() < MAX_VPS_NUH_RESERVED_ZERO_LAYER_ID_PLUS1 ); |
---|
843 | READ_CODE( 6, uiCode, "vps_max_nuh_reserved_zero_layer_id" ); pcVPS->setMaxNuhReservedZeroLayerId( uiCode ); |
---|
844 | READ_UVLC( uiCode, "vps_max_op_sets_minus1" ); pcVPS->setMaxOpSets( uiCode + 1 ); |
---|
845 | for( UInt opsIdx = 1; opsIdx <= ( pcVPS->getMaxOpSets() - 1 ); opsIdx ++ ) |
---|
846 | { |
---|
847 | // Operation point set |
---|
848 | for( UInt i = 0; i <= pcVPS->getMaxNuhReservedZeroLayerId(); i ++ ) |
---|
849 | #endif |
---|
850 | { |
---|
851 | READ_FLAG( uiCode, "layer_id_included_flag[opsIdx][i]" ); pcVPS->setLayerIdIncludedFlag( uiCode == 1 ? true : false, opsIdx, i ); |
---|
852 | } |
---|
853 | } |
---|
854 | TimingInfo *timingInfo = pcVPS->getTimingInfo(); |
---|
855 | READ_FLAG( uiCode, "vps_timing_info_present_flag"); timingInfo->setTimingInfoPresentFlag (uiCode ? true : false); |
---|
856 | if(timingInfo->getTimingInfoPresentFlag()) |
---|
857 | { |
---|
858 | READ_CODE( 32, uiCode, "vps_num_units_in_tick"); timingInfo->setNumUnitsInTick (uiCode); |
---|
859 | READ_CODE( 32, uiCode, "vps_time_scale"); timingInfo->setTimeScale (uiCode); |
---|
860 | READ_FLAG( uiCode, "vps_poc_proportional_to_timing_flag"); timingInfo->setPocProportionalToTimingFlag(uiCode ? true : false); |
---|
861 | if(timingInfo->getPocProportionalToTimingFlag()) |
---|
862 | { |
---|
863 | READ_UVLC( uiCode, "vps_num_ticks_poc_diff_one_minus1"); timingInfo->setNumTicksPocDiffOneMinus1 (uiCode); |
---|
864 | } |
---|
865 | READ_UVLC( uiCode, "vps_num_hrd_parameters" ); pcVPS->setNumHrdParameters( uiCode ); |
---|
866 | |
---|
867 | if( pcVPS->getNumHrdParameters() > 0 ) |
---|
868 | { |
---|
869 | pcVPS->createHrdParamBuffer(); |
---|
870 | } |
---|
871 | for( UInt i = 0; i < pcVPS->getNumHrdParameters(); i ++ ) |
---|
872 | { |
---|
873 | READ_UVLC( uiCode, "hrd_op_set_idx" ); pcVPS->setHrdOpSetIdx( uiCode, i ); |
---|
874 | if( i > 0 ) |
---|
875 | { |
---|
876 | READ_FLAG( uiCode, "cprms_present_flag[i]" ); pcVPS->setCprmsPresentFlag( uiCode == 1 ? true : false, i ); |
---|
877 | } |
---|
878 | parseHrdParameters(pcVPS->getHrdParameters(i), pcVPS->getCprmsPresentFlag( i ), pcVPS->getMaxTLayers() - 1); |
---|
879 | } |
---|
880 | } |
---|
881 | READ_FLAG( uiCode, "vps_extension_flag" ); |
---|
882 | if (uiCode) |
---|
883 | { |
---|
884 | #if H_MV |
---|
885 | m_pcBitstream->readOutTrailingBits(); |
---|
886 | |
---|
887 | READ_FLAG( uiCode, "avc_base_layer_flag" ); pcVPS->setAvcBaseLayerFlag( uiCode == 1 ? true : false ); |
---|
888 | READ_FLAG( uiCode, "splitting_flag" ); pcVPS->setSplittingFlag( uiCode == 1 ? true : false ); |
---|
889 | |
---|
890 | for( Int sIdx = 0; sIdx < MAX_NUM_SCALABILITY_TYPES; sIdx++ ) |
---|
891 | { |
---|
892 | READ_FLAG( uiCode, "scalability_mask[i]" ); pcVPS->setScalabilityMask( sIdx, uiCode == 1 ? true : false ); |
---|
893 | } |
---|
894 | |
---|
895 | for( Int sIdx = 0; sIdx < pcVPS->getNumScalabilityTypes( ) - ( pcVPS->getSplittingFlag() ? 1 : 0 ); sIdx++ ) |
---|
896 | { |
---|
897 | READ_CODE( 3, uiCode, "dimension_id_len_minus1[j]" ); pcVPS->setDimensionIdLen( sIdx, uiCode + 1 ); |
---|
898 | } |
---|
899 | |
---|
900 | if ( pcVPS->getSplittingFlag() ) |
---|
901 | { |
---|
902 | pcVPS->setDimensionIdLen( pcVPS->getNumScalabilityTypes( ) - 1, pcVPS->inferLastDimsionIdLenMinus1() ); |
---|
903 | } |
---|
904 | |
---|
905 | READ_FLAG( uiCode, "vps_nuh_layer_id_present_flag" ); pcVPS->setVpsNuhLayerIdPresentFlag( uiCode == 1 ? true : false ); |
---|
906 | |
---|
907 | for( Int i = 0; i <= pcVPS->getMaxLayers() - 1; i++ ) |
---|
908 | { |
---|
909 | if ( pcVPS->getVpsNuhLayerIdPresentFlag() && ( i > 0 ) ) |
---|
910 | { |
---|
911 | READ_CODE( 6, uiCode, "layer_id_in_nuh[i]" ); pcVPS->setLayerIdInNuh( i, uiCode ); |
---|
912 | } |
---|
913 | else |
---|
914 | { |
---|
915 | pcVPS->setLayerIdInNuh( i, i );; |
---|
916 | } |
---|
917 | |
---|
918 | pcVPS->setLayerIdInVps( pcVPS->getLayerIdInNuh( i ), i ); |
---|
919 | |
---|
920 | for( Int j = 0; j < pcVPS->getNumScalabilityTypes() ; j++ ) |
---|
921 | { |
---|
922 | if ( !pcVPS->getSplittingFlag() ) |
---|
923 | { |
---|
924 | READ_CODE( pcVPS->getDimensionIdLen( j ), uiCode, "dimension_id[i][j]" ); pcVPS->setDimensionId( i, j, uiCode ); |
---|
925 | } |
---|
926 | else |
---|
927 | { |
---|
928 | pcVPS->setDimensionId( i, j, pcVPS->inferDimensionId( i, j) ); |
---|
929 | } |
---|
930 | } |
---|
931 | } |
---|
932 | |
---|
933 | |
---|
934 | for( Int i = 1; i <= pcVPS->getMaxLayers() - 1; i++ ) |
---|
935 | { |
---|
936 | for( Int j = 0; j < i; j++ ) |
---|
937 | { |
---|
938 | READ_FLAG( uiCode, "direct_dependency_flag[i][j]" ); pcVPS->setDirectDependencyFlag( i, j, uiCode ); |
---|
939 | } |
---|
940 | } |
---|
941 | |
---|
942 | for( Int i = 0; i < pcVPS->getMaxLayers() - 1; i++ ) |
---|
943 | { |
---|
944 | READ_CODE( 3, uiCode, "max_tid_il_ref_pics_plus1[i]" ); pcVPS->setMaxTidIlRefPicPlus1( i , uiCode ); |
---|
945 | } |
---|
946 | |
---|
947 | READ_CODE( 10, uiCode, "vps_number_layer_sets_minus1" ); pcVPS->setVpsNumberLayerSetsMinus1 ( uiCode ); |
---|
948 | READ_CODE( 6, uiCode, "vps_num_profile_tier_level_minus1" ); pcVPS->setVpsNumProfileTierLevelMinus1( uiCode ); |
---|
949 | |
---|
950 | for( Int i = 1; i <= pcVPS->getVpsNumProfileTierLevelMinus1(); i++ ) |
---|
951 | { |
---|
952 | READ_FLAG( uiCode, "vps_profile_present_flag[i]" ); pcVPS->setVpsProfilePresentFlag( i, uiCode == 1 ); |
---|
953 | if( !pcVPS->getVpsProfilePresentFlag( i ) ) |
---|
954 | { |
---|
955 | READ_CODE( 6, uiCode, "profile_ref_minus1[i]" ); pcVPS->setProfileRefMinus1( i, uiCode ); |
---|
956 | } |
---|
957 | parsePTL ( pcVPS->getPTL( i ), pcVPS->getVpsProfilePresentFlag( i ), pcVPS->getMaxTLayers()-1); |
---|
958 | if( !pcVPS->getVpsProfilePresentFlag( i ) ) |
---|
959 | { |
---|
960 | TComPTL temp = *pcVPS->getPTL( i ); |
---|
961 | *pcVPS->getPTL( i ) = *pcVPS->getPTL( pcVPS->getProfileRefMinus1( i ) + 1 ); |
---|
962 | pcVPS->getPTL( i )->copyLevelFrom( &temp ); |
---|
963 | } |
---|
964 | } |
---|
965 | |
---|
966 | Int numOutputLayerSets = pcVPS->getVpsNumberLayerSetsMinus1( ) + 1; |
---|
967 | |
---|
968 | READ_FLAG( uiCode, "more_output_layer_sets_than_default_flag" ); pcVPS->setMoreOutputLayerSetsThanDefaultFlag( uiCode == 1 ); |
---|
969 | |
---|
970 | if ( pcVPS->getMoreOutputLayerSetsThanDefaultFlag( ) ) |
---|
971 | { |
---|
972 | READ_CODE( 10, uiCode, "num_add_output_layer_sets_minus1" ); pcVPS->setNumAddOutputLayerSetsMinus1( uiCode ); |
---|
973 | numOutputLayerSets += ( pcVPS->getNumAddOutputLayerSetsMinus1( ) + 1); |
---|
974 | } |
---|
975 | |
---|
976 | if( numOutputLayerSets > 1) |
---|
977 | { |
---|
978 | READ_FLAG( uiCode, "default_one_target_output_layer_flag" ); pcVPS->setDefaultOneTargetOutputLayerFlag( uiCode == 1); |
---|
979 | } |
---|
980 | |
---|
981 | for( Int i = 1; i < numOutputLayerSets; i++ ) |
---|
982 | { |
---|
983 | if( i > pcVPS->getVpsNumberLayerSetsMinus1( ) ) |
---|
984 | { |
---|
985 | READ_UVLC( uiCode, "output_layer_set_idx_minus1[i]" ); pcVPS->setOutputLayerSetIdxMinus1( i, uiCode ); |
---|
986 | for( Int j = 0; j < pcVPS->getNumLayersInIdList( j ) - 1; j++ ) |
---|
987 | { |
---|
988 | READ_FLAG( uiCode, "output_layer_flag" ); pcVPS->setOutputLayerFlag( i, j, uiCode == 1 ); |
---|
989 | } |
---|
990 | } |
---|
991 | if ( pcVPS->getProfileLevelTierIdxLen() > 0 ) |
---|
992 | { |
---|
993 | READ_CODE( pcVPS->getProfileLevelTierIdxLen(), uiCode,"profile_level_tier_idx[ i ]" ); pcVPS->setProfileLevelTierIdx( i , uiCode ); |
---|
994 | } |
---|
995 | } |
---|
996 | |
---|
997 | READ_FLAG( uiCode , "max_one_active_ref_layer_flag" ); pcVPS->setMaxOneActiveRefLayerFlag( uiCode == 1 ); |
---|
998 | READ_UVLC( uiCode, "direct_dep_type_len_minus2"); pcVPS->setDirectDepTypeLenMinus2 ( uiCode ); |
---|
999 | |
---|
1000 | for( Int i = 1; i <= pcVPS->getMaxLayers() - 1; i++ ) |
---|
1001 | { |
---|
1002 | for( Int j = 0; j < i; j++ ) |
---|
1003 | { |
---|
1004 | if (pcVPS->getDirectDependencyFlag( i, j) ) |
---|
1005 | { |
---|
1006 | READ_CODE( pcVPS->getDirectDepTypeLenMinus2( ) + 2, uiCode, "direct_dependency_type[i][j]" ); pcVPS->setDirectDependencyType( i, j , uiCode); |
---|
1007 | } |
---|
1008 | } |
---|
1009 | } |
---|
1010 | |
---|
1011 | READ_FLAG ( uiCode, "vps_shvc_reserved_zero_flag" ); |
---|
1012 | |
---|
1013 | #if H_3D |
---|
1014 | READ_FLAG( uiCode, "vps_extension2_flag" ); |
---|
1015 | if (uiCode) |
---|
1016 | { |
---|
1017 | m_pcBitstream->readOutTrailingBits(); |
---|
1018 | |
---|
1019 | for( Int i = 0; i <= pcVPS->getMaxLayers() - 1; i++ ) |
---|
1020 | { |
---|
1021 | |
---|
1022 | #if H_3D_ARP |
---|
1023 | pcVPS->setUseAdvRP ( i, 0 ); |
---|
1024 | pcVPS->setARPStepNum( i, 1 ); |
---|
1025 | #endif |
---|
1026 | if ( i != 0 ) |
---|
1027 | { |
---|
1028 | if( !( pcVPS->getDepthId( i ) == 1 ) ) |
---|
1029 | { |
---|
1030 | #if H_3D_IV_MERGE |
---|
1031 | READ_FLAG( uiCode, "iv_mv_pred_flag[i]"); pcVPS->setIvMvPredFlag ( i, uiCode == 1 ? true : false ); |
---|
1032 | #endif |
---|
1033 | #if H_3D_ARP |
---|
1034 | READ_FLAG( uiCode, "iv_res_pred_flag[i]" ); pcVPS->setUseAdvRP ( i, uiCode ); pcVPS->setARPStepNum( i, uiCode ? H_3D_ARP_WFNR : 1 ); |
---|
1035 | |
---|
1036 | #endif |
---|
1037 | #if H_3D_NBDV_REF |
---|
1038 | READ_FLAG( uiCode, "depth_refinement_flag[i]"); pcVPS->setDepthRefinementFlag ( i, uiCode == 1 ? true : false ); |
---|
1039 | #endif |
---|
1040 | #if H_3D_VSP |
---|
1041 | READ_FLAG( uiCode, "view_synthesis_pred_flag[i]"); pcVPS->setViewSynthesisPredFlag( i, uiCode == 1 ? true : false ); |
---|
1042 | #endif |
---|
1043 | } |
---|
1044 | else |
---|
1045 | { |
---|
1046 | |
---|
1047 | READ_FLAG( uiCode, "vps_depth_modes_flag[i]" ); pcVPS->setVpsDepthModesFlag( i, uiCode == 1 ? true : false ); |
---|
1048 | // READ_FLAG( uiCode, "lim_qt_pred_flag[i]"); pcVPS->setLimQtPreFlag ( i, uiCode == 1 ? true : false ); |
---|
1049 | #if H_3D_DIM_DLT |
---|
1050 | if( pcVPS->getVpsDepthModesFlag( i ) ) |
---|
1051 | { |
---|
1052 | READ_FLAG( uiCode, "dlt_flag[i]" ); pcVPS->setUseDLTFlag( i, uiCode == 1 ? true : false ); |
---|
1053 | } |
---|
1054 | if( pcVPS->getUseDLTFlag( i ) ) |
---|
1055 | { |
---|
1056 | // decode mapping |
---|
1057 | UInt uiNumDepthValues; |
---|
1058 | // parse number of values in DLT |
---|
1059 | READ_UVLC(uiNumDepthValues, "num_depth_values_in_dlt[i]"); |
---|
1060 | |
---|
1061 | // parse actual DLT values |
---|
1062 | Int* aiIdx2DepthValue = (Int*) calloc(uiNumDepthValues, sizeof(Int)); |
---|
1063 | for(Int d=0; d<uiNumDepthValues; d++) |
---|
1064 | { |
---|
1065 | READ_UVLC(uiCode, "dlt_depth_value[i][d]"); |
---|
1066 | aiIdx2DepthValue[d] = (Int)uiCode; |
---|
1067 | } |
---|
1068 | |
---|
1069 | pcVPS->setDepthLUTs(i, aiIdx2DepthValue, uiNumDepthValues); |
---|
1070 | |
---|
1071 | // clean memory |
---|
1072 | free(aiIdx2DepthValue); |
---|
1073 | } |
---|
1074 | #endif |
---|
1075 | } |
---|
1076 | } |
---|
1077 | } |
---|
1078 | READ_FLAG( uiCode, "iv_mv_scaling_flag"); pcVPS->setIvMvScalingFlag( uiCode == 1 ? true : false ); |
---|
1079 | } |
---|
1080 | #endif |
---|
1081 | pcVPS->checkVPSExtensionSyntax(); |
---|
1082 | |
---|
1083 | pcVPS->setRefLayers(); |
---|
1084 | |
---|
1085 | #else |
---|
1086 | while ( xMoreRbspData() ) |
---|
1087 | { |
---|
1088 | READ_FLAG( uiCode, "vps_extension_data_flag"); |
---|
1089 | } |
---|
1090 | #endif |
---|
1091 | } |
---|
1092 | |
---|
1093 | #if H_3D |
---|
1094 | pcVPS->initViewIndex(); |
---|
1095 | #endif |
---|
1096 | return; |
---|
1097 | } |
---|
1098 | |
---|
1099 | Void TDecCavlc::parseSliceHeader (TComSlice*& rpcSlice, ParameterSetManagerDecoder *parameterSetManager) |
---|
1100 | { |
---|
1101 | UInt uiCode; |
---|
1102 | Int iCode; |
---|
1103 | |
---|
1104 | #if ENC_DEC_TRACE |
---|
1105 | xTraceSliceHeader(rpcSlice); |
---|
1106 | #endif |
---|
1107 | TComPPS* pps = NULL; |
---|
1108 | TComSPS* sps = NULL; |
---|
1109 | #if H_MV |
---|
1110 | TComVPS* vps = NULL; |
---|
1111 | #endif |
---|
1112 | |
---|
1113 | UInt firstSliceSegmentInPic; |
---|
1114 | READ_FLAG( firstSliceSegmentInPic, "first_slice_segment_in_pic_flag" ); |
---|
1115 | if( rpcSlice->getRapPicFlag()) |
---|
1116 | { |
---|
1117 | READ_FLAG( uiCode, "no_output_of_prior_pics_flag" ); //ignored |
---|
1118 | } |
---|
1119 | READ_UVLC ( uiCode, "slice_pic_parameter_set_id" ); rpcSlice->setPPSId(uiCode); |
---|
1120 | pps = parameterSetManager->getPrefetchedPPS(uiCode); |
---|
1121 | //!KS: need to add error handling code here, if PPS is not available |
---|
1122 | assert(pps!=0); |
---|
1123 | sps = parameterSetManager->getPrefetchedSPS(pps->getSPSId()); |
---|
1124 | //!KS: need to add error handling code here, if SPS is not available |
---|
1125 | assert(sps!=0); |
---|
1126 | #if H_MV |
---|
1127 | vps = parameterSetManager->getPrefetchedVPS(sps->getVPSId()); |
---|
1128 | assert(vps!=0); |
---|
1129 | rpcSlice->setVPS(vps); |
---|
1130 | rpcSlice->setViewId ( vps->getViewId ( rpcSlice->getLayerIdInVps() ) ); |
---|
1131 | #if H_3D |
---|
1132 | rpcSlice->setViewIndex( vps->getViewIndex( rpcSlice->getLayerIdInVps() ) ); |
---|
1133 | rpcSlice->setIsDepth ( vps->getDepthId ( rpcSlice->getLayerIdInVps() ) == 1 ); |
---|
1134 | #endif |
---|
1135 | #endif |
---|
1136 | rpcSlice->setSPS(sps); |
---|
1137 | rpcSlice->setPPS(pps); |
---|
1138 | if( pps->getDependentSliceSegmentsEnabledFlag() && ( !firstSliceSegmentInPic )) |
---|
1139 | { |
---|
1140 | READ_FLAG( uiCode, "dependent_slice_segment_flag" ); rpcSlice->setDependentSliceSegmentFlag(uiCode ? true : false); |
---|
1141 | } |
---|
1142 | else |
---|
1143 | { |
---|
1144 | rpcSlice->setDependentSliceSegmentFlag(false); |
---|
1145 | } |
---|
1146 | Int numCTUs = ((sps->getPicWidthInLumaSamples()+sps->getMaxCUWidth()-1)/sps->getMaxCUWidth())*((sps->getPicHeightInLumaSamples()+sps->getMaxCUHeight()-1)/sps->getMaxCUHeight()); |
---|
1147 | Int maxParts = (1<<(sps->getMaxCUDepth()<<1)); |
---|
1148 | UInt sliceSegmentAddress = 0; |
---|
1149 | Int bitsSliceSegmentAddress = 0; |
---|
1150 | while(numCTUs>(1<<bitsSliceSegmentAddress)) |
---|
1151 | { |
---|
1152 | bitsSliceSegmentAddress++; |
---|
1153 | } |
---|
1154 | |
---|
1155 | if(!firstSliceSegmentInPic) |
---|
1156 | { |
---|
1157 | READ_CODE( bitsSliceSegmentAddress, sliceSegmentAddress, "slice_segment_address" ); |
---|
1158 | } |
---|
1159 | //set uiCode to equal slice start address (or dependent slice start address) |
---|
1160 | Int startCuAddress = maxParts*sliceSegmentAddress; |
---|
1161 | rpcSlice->setSliceSegmentCurStartCUAddr( startCuAddress ); |
---|
1162 | rpcSlice->setSliceSegmentCurEndCUAddr(numCTUs*maxParts); |
---|
1163 | |
---|
1164 | if (rpcSlice->getDependentSliceSegmentFlag()) |
---|
1165 | { |
---|
1166 | rpcSlice->setNextSlice ( false ); |
---|
1167 | rpcSlice->setNextSliceSegment ( true ); |
---|
1168 | } |
---|
1169 | else |
---|
1170 | { |
---|
1171 | rpcSlice->setNextSlice ( true ); |
---|
1172 | rpcSlice->setNextSliceSegment ( false ); |
---|
1173 | |
---|
1174 | rpcSlice->setSliceCurStartCUAddr(startCuAddress); |
---|
1175 | rpcSlice->setSliceCurEndCUAddr(numCTUs*maxParts); |
---|
1176 | } |
---|
1177 | |
---|
1178 | if(!rpcSlice->getDependentSliceSegmentFlag()) |
---|
1179 | { |
---|
1180 | #if H_MV |
---|
1181 | if ( rpcSlice->getPPS()->getNumExtraSliceHeaderBits() > 0 ) |
---|
1182 | { |
---|
1183 | READ_FLAG( uiCode, "discardable_flag" ); rpcSlice->setDiscardableFlag( uiCode == 1 ); |
---|
1184 | } |
---|
1185 | |
---|
1186 | for (Int i = 1; i < rpcSlice->getPPS()->getNumExtraSliceHeaderBits(); i++) |
---|
1187 | #else |
---|
1188 | for (Int i = 0; i < rpcSlice->getPPS()->getNumExtraSliceHeaderBits(); i++) |
---|
1189 | #endif |
---|
1190 | { |
---|
1191 | READ_FLAG(uiCode, "slice_reserved_undetermined_flag[]"); // ignored |
---|
1192 | } |
---|
1193 | |
---|
1194 | READ_UVLC ( uiCode, "slice_type" ); rpcSlice->setSliceType((SliceType)uiCode); |
---|
1195 | if( pps->getOutputFlagPresentFlag() ) |
---|
1196 | { |
---|
1197 | READ_FLAG( uiCode, "pic_output_flag" ); rpcSlice->setPicOutputFlag( uiCode ? true : false ); |
---|
1198 | } |
---|
1199 | else |
---|
1200 | { |
---|
1201 | rpcSlice->setPicOutputFlag( true ); |
---|
1202 | } |
---|
1203 | // in the first version chroma_format_idc is equal to one, thus colour_plane_id will not be present |
---|
1204 | assert (sps->getChromaFormatIdc() == 1 ); |
---|
1205 | // if( separate_colour_plane_flag == 1 ) |
---|
1206 | // colour_plane_id u(2) |
---|
1207 | |
---|
1208 | if( rpcSlice->getIdrPicFlag() ) |
---|
1209 | { |
---|
1210 | rpcSlice->setPOC(0); |
---|
1211 | TComReferencePictureSet* rps = rpcSlice->getLocalRPS(); |
---|
1212 | rps->setNumberOfNegativePictures(0); |
---|
1213 | rps->setNumberOfPositivePictures(0); |
---|
1214 | rps->setNumberOfLongtermPictures(0); |
---|
1215 | rps->setNumberOfPictures(0); |
---|
1216 | rpcSlice->setRPS(rps); |
---|
1217 | #if H_MV |
---|
1218 | rpcSlice->setEnableTMVPFlag(false); |
---|
1219 | #endif |
---|
1220 | } |
---|
1221 | else |
---|
1222 | { |
---|
1223 | READ_CODE(sps->getBitsForPOC(), uiCode, "pic_order_cnt_lsb"); |
---|
1224 | Int iPOClsb = uiCode; |
---|
1225 | Int iPrevPOC = rpcSlice->getPrevPOC(); |
---|
1226 | Int iMaxPOClsb = 1<< sps->getBitsForPOC(); |
---|
1227 | Int iPrevPOClsb = iPrevPOC%iMaxPOClsb; |
---|
1228 | Int iPrevPOCmsb = iPrevPOC-iPrevPOClsb; |
---|
1229 | Int iPOCmsb; |
---|
1230 | if( ( iPOClsb < iPrevPOClsb ) && ( ( iPrevPOClsb - iPOClsb ) >= ( iMaxPOClsb / 2 ) ) ) |
---|
1231 | { |
---|
1232 | iPOCmsb = iPrevPOCmsb + iMaxPOClsb; |
---|
1233 | } |
---|
1234 | else if( (iPOClsb > iPrevPOClsb ) && ( (iPOClsb - iPrevPOClsb ) > ( iMaxPOClsb / 2 ) ) ) |
---|
1235 | { |
---|
1236 | iPOCmsb = iPrevPOCmsb - iMaxPOClsb; |
---|
1237 | } |
---|
1238 | else |
---|
1239 | { |
---|
1240 | iPOCmsb = iPrevPOCmsb; |
---|
1241 | } |
---|
1242 | if ( rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP |
---|
1243 | || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL |
---|
1244 | || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP ) |
---|
1245 | { |
---|
1246 | // For BLA picture types, POCmsb is set to 0. |
---|
1247 | iPOCmsb = 0; |
---|
1248 | } |
---|
1249 | rpcSlice->setPOC (iPOCmsb+iPOClsb); |
---|
1250 | |
---|
1251 | TComReferencePictureSet* rps; |
---|
1252 | rps = rpcSlice->getLocalRPS(); |
---|
1253 | rpcSlice->setRPS(rps); |
---|
1254 | READ_FLAG( uiCode, "short_term_ref_pic_set_sps_flag" ); |
---|
1255 | if(uiCode == 0) // use short-term reference picture set explicitly signalled in slice header |
---|
1256 | { |
---|
1257 | parseShortTermRefPicSet(sps,rps, sps->getRPSList()->getNumberOfReferencePictureSets()); |
---|
1258 | } |
---|
1259 | else // use reference to short-term reference picture set in PPS |
---|
1260 | { |
---|
1261 | Int numBits = 0; |
---|
1262 | while ((1 << numBits) < rpcSlice->getSPS()->getRPSList()->getNumberOfReferencePictureSets()) |
---|
1263 | { |
---|
1264 | numBits++; |
---|
1265 | } |
---|
1266 | if (numBits > 0) |
---|
1267 | { |
---|
1268 | READ_CODE( numBits, uiCode, "short_term_ref_pic_set_idx"); |
---|
1269 | } |
---|
1270 | else |
---|
1271 | { |
---|
1272 | uiCode = 0; |
---|
1273 | } |
---|
1274 | *rps = *(sps->getRPSList()->getReferencePictureSet(uiCode)); |
---|
1275 | } |
---|
1276 | if(sps->getLongTermRefsPresent()) |
---|
1277 | { |
---|
1278 | Int offset = rps->getNumberOfNegativePictures()+rps->getNumberOfPositivePictures(); |
---|
1279 | UInt numOfLtrp = 0; |
---|
1280 | UInt numLtrpInSPS = 0; |
---|
1281 | if (rpcSlice->getSPS()->getNumLongTermRefPicSPS() > 0) |
---|
1282 | { |
---|
1283 | READ_UVLC( uiCode, "num_long_term_sps"); |
---|
1284 | numLtrpInSPS = uiCode; |
---|
1285 | numOfLtrp += numLtrpInSPS; |
---|
1286 | rps->setNumberOfLongtermPictures(numOfLtrp); |
---|
1287 | } |
---|
1288 | Int bitsForLtrpInSPS = 0; |
---|
1289 | while (rpcSlice->getSPS()->getNumLongTermRefPicSPS() > (1 << bitsForLtrpInSPS)) |
---|
1290 | { |
---|
1291 | bitsForLtrpInSPS++; |
---|
1292 | } |
---|
1293 | READ_UVLC( uiCode, "num_long_term_pics"); rps->setNumberOfLongtermPictures(uiCode); |
---|
1294 | numOfLtrp += uiCode; |
---|
1295 | rps->setNumberOfLongtermPictures(numOfLtrp); |
---|
1296 | Int maxPicOrderCntLSB = 1 << rpcSlice->getSPS()->getBitsForPOC(); |
---|
1297 | Int prevDeltaMSB = 0, deltaPocMSBCycleLT = 0;; |
---|
1298 | for(Int j=offset+rps->getNumberOfLongtermPictures()-1, k = 0; k < numOfLtrp; j--, k++) |
---|
1299 | { |
---|
1300 | Int pocLsbLt; |
---|
1301 | if (k < numLtrpInSPS) |
---|
1302 | { |
---|
1303 | uiCode = 0; |
---|
1304 | if (bitsForLtrpInSPS > 0) |
---|
1305 | { |
---|
1306 | READ_CODE(bitsForLtrpInSPS, uiCode, "lt_idx_sps[i]"); |
---|
1307 | } |
---|
1308 | Int usedByCurrFromSPS=rpcSlice->getSPS()->getUsedByCurrPicLtSPSFlag(uiCode); |
---|
1309 | |
---|
1310 | pocLsbLt = rpcSlice->getSPS()->getLtRefPicPocLsbSps(uiCode); |
---|
1311 | rps->setUsed(j,usedByCurrFromSPS); |
---|
1312 | } |
---|
1313 | else |
---|
1314 | { |
---|
1315 | READ_CODE(rpcSlice->getSPS()->getBitsForPOC(), uiCode, "poc_lsb_lt"); pocLsbLt= uiCode; |
---|
1316 | READ_FLAG( uiCode, "used_by_curr_pic_lt_flag"); rps->setUsed(j,uiCode); |
---|
1317 | } |
---|
1318 | READ_FLAG(uiCode,"delta_poc_msb_present_flag"); |
---|
1319 | Bool mSBPresentFlag = uiCode ? true : false; |
---|
1320 | if(mSBPresentFlag) |
---|
1321 | { |
---|
1322 | READ_UVLC( uiCode, "delta_poc_msb_cycle_lt[i]" ); |
---|
1323 | Bool deltaFlag = false; |
---|
1324 | // First LTRP || First LTRP from SH |
---|
1325 | if( (j == offset+rps->getNumberOfLongtermPictures()-1) || (j == offset+(numOfLtrp-numLtrpInSPS)-1) ) |
---|
1326 | { |
---|
1327 | deltaFlag = true; |
---|
1328 | } |
---|
1329 | if(deltaFlag) |
---|
1330 | { |
---|
1331 | deltaPocMSBCycleLT = uiCode; |
---|
1332 | } |
---|
1333 | else |
---|
1334 | { |
---|
1335 | deltaPocMSBCycleLT = uiCode + prevDeltaMSB; |
---|
1336 | } |
---|
1337 | |
---|
1338 | Int pocLTCurr = rpcSlice->getPOC() - deltaPocMSBCycleLT * maxPicOrderCntLSB |
---|
1339 | - iPOClsb + pocLsbLt; |
---|
1340 | rps->setPOC (j, pocLTCurr); |
---|
1341 | rps->setDeltaPOC(j, - rpcSlice->getPOC() + pocLTCurr); |
---|
1342 | rps->setCheckLTMSBPresent(j,true); |
---|
1343 | } |
---|
1344 | else |
---|
1345 | { |
---|
1346 | rps->setPOC (j, pocLsbLt); |
---|
1347 | rps->setDeltaPOC(j, - rpcSlice->getPOC() + pocLsbLt); |
---|
1348 | rps->setCheckLTMSBPresent(j,false); |
---|
1349 | } |
---|
1350 | prevDeltaMSB = deltaPocMSBCycleLT; |
---|
1351 | } |
---|
1352 | offset += rps->getNumberOfLongtermPictures(); |
---|
1353 | rps->setNumberOfPictures(offset); |
---|
1354 | } |
---|
1355 | if ( rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP |
---|
1356 | || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL |
---|
1357 | || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP ) |
---|
1358 | { |
---|
1359 | // In the case of BLA picture types, rps data is read from slice header but ignored |
---|
1360 | rps = rpcSlice->getLocalRPS(); |
---|
1361 | rps->setNumberOfNegativePictures(0); |
---|
1362 | rps->setNumberOfPositivePictures(0); |
---|
1363 | rps->setNumberOfLongtermPictures(0); |
---|
1364 | rps->setNumberOfPictures(0); |
---|
1365 | rpcSlice->setRPS(rps); |
---|
1366 | } |
---|
1367 | if (rpcSlice->getSPS()->getTMVPFlagsPresent()) |
---|
1368 | { |
---|
1369 | READ_FLAG( uiCode, "slice_temporal_mvp_enable_flag" ); |
---|
1370 | rpcSlice->setEnableTMVPFlag( uiCode == 1 ? true : false ); |
---|
1371 | } |
---|
1372 | else |
---|
1373 | { |
---|
1374 | rpcSlice->setEnableTMVPFlag(false); |
---|
1375 | } |
---|
1376 | } |
---|
1377 | #if H_MV |
---|
1378 | Int layerIdInVps = rpcSlice->getLayerIdInVps(); |
---|
1379 | if( rpcSlice->getLayerId() > 0 && vps->getNumDirectRefLayers( layerIdInVps ) > 0 ) |
---|
1380 | { |
---|
1381 | READ_FLAG( uiCode, "inter_layer_pred_enabled_flag" ); rpcSlice->setInterLayerPredEnabledFlag( uiCode == 1 ); |
---|
1382 | if( rpcSlice->getInterLayerPredEnabledFlag() && vps->getNumDirectRefLayers( layerIdInVps ) > 1 ) |
---|
1383 | { |
---|
1384 | if( !vps->getMaxOneActiveRefLayerFlag()) |
---|
1385 | { |
---|
1386 | READ_CODE( rpcSlice->getNumInterLayerRefPicsMinus1Len( ), uiCode, "num_inter_layer_ref_pics_minus1" ); rpcSlice->setNumInterLayerRefPicsMinus1( uiCode ); |
---|
1387 | } |
---|
1388 | for( Int i = 0; i < rpcSlice->getNumActiveRefLayerPics(); i++ ) |
---|
1389 | { |
---|
1390 | READ_CODE( rpcSlice->getInterLayerPredLayerIdcLen( ), uiCode, "inter_layer_pred_layer_idc" ); rpcSlice->setInterLayerPredLayerIdc( i, uiCode ); |
---|
1391 | } |
---|
1392 | } |
---|
1393 | } |
---|
1394 | |
---|
1395 | rpcSlice->setActiveMotionPredRefLayers( ); |
---|
1396 | |
---|
1397 | if( vps->getNumSamplePredRefLayers( layerIdInVps ) > 0 && rpcSlice->getNumActiveRefLayerPics() > 0 ) |
---|
1398 | { |
---|
1399 | READ_FLAG( uiCode, "inter_layer_sample_pred_only_flag" ); rpcSlice->setInterLayerSamplePredOnlyFlag( uiCode == 1 ); |
---|
1400 | } |
---|
1401 | |
---|
1402 | #endif |
---|
1403 | if(sps->getUseSAO()) |
---|
1404 | { |
---|
1405 | READ_FLAG(uiCode, "slice_sao_luma_flag"); rpcSlice->setSaoEnabledFlag((Bool)uiCode); |
---|
1406 | READ_FLAG(uiCode, "slice_sao_chroma_flag"); rpcSlice->setSaoEnabledFlagChroma((Bool)uiCode); |
---|
1407 | } |
---|
1408 | |
---|
1409 | if (rpcSlice->getIdrPicFlag()) |
---|
1410 | { |
---|
1411 | rpcSlice->setEnableTMVPFlag(false); |
---|
1412 | } |
---|
1413 | if (!rpcSlice->isIntra()) |
---|
1414 | { |
---|
1415 | |
---|
1416 | READ_FLAG( uiCode, "num_ref_idx_active_override_flag"); |
---|
1417 | if (uiCode) |
---|
1418 | { |
---|
1419 | READ_UVLC (uiCode, "num_ref_idx_l0_active_minus1" ); rpcSlice->setNumRefIdx( REF_PIC_LIST_0, uiCode + 1 ); |
---|
1420 | if (rpcSlice->isInterB()) |
---|
1421 | { |
---|
1422 | READ_UVLC (uiCode, "num_ref_idx_l1_active_minus1" ); rpcSlice->setNumRefIdx( REF_PIC_LIST_1, uiCode + 1 ); |
---|
1423 | } |
---|
1424 | else |
---|
1425 | { |
---|
1426 | rpcSlice->setNumRefIdx(REF_PIC_LIST_1, 0); |
---|
1427 | } |
---|
1428 | } |
---|
1429 | else |
---|
1430 | { |
---|
1431 | rpcSlice->setNumRefIdx(REF_PIC_LIST_0, rpcSlice->getPPS()->getNumRefIdxL0DefaultActive()); |
---|
1432 | if (rpcSlice->isInterB()) |
---|
1433 | { |
---|
1434 | rpcSlice->setNumRefIdx(REF_PIC_LIST_1, rpcSlice->getPPS()->getNumRefIdxL1DefaultActive()); |
---|
1435 | } |
---|
1436 | else |
---|
1437 | { |
---|
1438 | rpcSlice->setNumRefIdx(REF_PIC_LIST_1,0); |
---|
1439 | } |
---|
1440 | } |
---|
1441 | } |
---|
1442 | // } |
---|
1443 | TComRefPicListModification* refPicListModification = rpcSlice->getRefPicListModification(); |
---|
1444 | if(!rpcSlice->isIntra()) |
---|
1445 | { |
---|
1446 | if( !rpcSlice->getPPS()->getListsModificationPresentFlag() || rpcSlice->getNumRpsCurrTempList() <= 1 ) |
---|
1447 | { |
---|
1448 | refPicListModification->setRefPicListModificationFlagL0( 0 ); |
---|
1449 | } |
---|
1450 | else |
---|
1451 | { |
---|
1452 | READ_FLAG( uiCode, "ref_pic_list_modification_flag_l0" ); refPicListModification->setRefPicListModificationFlagL0( uiCode ? 1 : 0 ); |
---|
1453 | } |
---|
1454 | |
---|
1455 | if(refPicListModification->getRefPicListModificationFlagL0()) |
---|
1456 | { |
---|
1457 | uiCode = 0; |
---|
1458 | Int i = 0; |
---|
1459 | Int numRpsCurrTempList0 = rpcSlice->getNumRpsCurrTempList(); |
---|
1460 | if ( numRpsCurrTempList0 > 1 ) |
---|
1461 | { |
---|
1462 | Int length = 1; |
---|
1463 | numRpsCurrTempList0 --; |
---|
1464 | while ( numRpsCurrTempList0 >>= 1) |
---|
1465 | { |
---|
1466 | length ++; |
---|
1467 | } |
---|
1468 | for (i = 0; i < rpcSlice->getNumRefIdx(REF_PIC_LIST_0); i ++) |
---|
1469 | { |
---|
1470 | READ_CODE( length, uiCode, "list_entry_l0" ); |
---|
1471 | refPicListModification->setRefPicSetIdxL0(i, uiCode ); |
---|
1472 | } |
---|
1473 | } |
---|
1474 | else |
---|
1475 | { |
---|
1476 | for (i = 0; i < rpcSlice->getNumRefIdx(REF_PIC_LIST_0); i ++) |
---|
1477 | { |
---|
1478 | refPicListModification->setRefPicSetIdxL0(i, 0 ); |
---|
1479 | } |
---|
1480 | } |
---|
1481 | } |
---|
1482 | } |
---|
1483 | else |
---|
1484 | { |
---|
1485 | refPicListModification->setRefPicListModificationFlagL0(0); |
---|
1486 | } |
---|
1487 | if(rpcSlice->isInterB()) |
---|
1488 | { |
---|
1489 | if( !rpcSlice->getPPS()->getListsModificationPresentFlag() || rpcSlice->getNumRpsCurrTempList() <= 1 ) |
---|
1490 | { |
---|
1491 | refPicListModification->setRefPicListModificationFlagL1( 0 ); |
---|
1492 | } |
---|
1493 | else |
---|
1494 | { |
---|
1495 | READ_FLAG( uiCode, "ref_pic_list_modification_flag_l1" ); refPicListModification->setRefPicListModificationFlagL1( uiCode ? 1 : 0 ); |
---|
1496 | } |
---|
1497 | if(refPicListModification->getRefPicListModificationFlagL1()) |
---|
1498 | { |
---|
1499 | uiCode = 0; |
---|
1500 | Int i = 0; |
---|
1501 | Int numRpsCurrTempList1 = rpcSlice->getNumRpsCurrTempList(); |
---|
1502 | if ( numRpsCurrTempList1 > 1 ) |
---|
1503 | { |
---|
1504 | Int length = 1; |
---|
1505 | numRpsCurrTempList1 --; |
---|
1506 | while ( numRpsCurrTempList1 >>= 1) |
---|
1507 | { |
---|
1508 | length ++; |
---|
1509 | } |
---|
1510 | for (i = 0; i < rpcSlice->getNumRefIdx(REF_PIC_LIST_1); i ++) |
---|
1511 | { |
---|
1512 | READ_CODE( length, uiCode, "list_entry_l1" ); |
---|
1513 | refPicListModification->setRefPicSetIdxL1(i, uiCode ); |
---|
1514 | } |
---|
1515 | } |
---|
1516 | else |
---|
1517 | { |
---|
1518 | for (i = 0; i < rpcSlice->getNumRefIdx(REF_PIC_LIST_1); i ++) |
---|
1519 | { |
---|
1520 | refPicListModification->setRefPicSetIdxL1(i, 0 ); |
---|
1521 | } |
---|
1522 | } |
---|
1523 | } |
---|
1524 | } |
---|
1525 | else |
---|
1526 | { |
---|
1527 | refPicListModification->setRefPicListModificationFlagL1(0); |
---|
1528 | } |
---|
1529 | if (rpcSlice->isInterB()) |
---|
1530 | { |
---|
1531 | READ_FLAG( uiCode, "mvd_l1_zero_flag" ); rpcSlice->setMvdL1ZeroFlag( (uiCode ? true : false) ); |
---|
1532 | } |
---|
1533 | |
---|
1534 | rpcSlice->setCabacInitFlag( false ); // default |
---|
1535 | if(pps->getCabacInitPresentFlag() && !rpcSlice->isIntra()) |
---|
1536 | { |
---|
1537 | READ_FLAG(uiCode, "cabac_init_flag"); |
---|
1538 | rpcSlice->setCabacInitFlag( uiCode ? true : false ); |
---|
1539 | } |
---|
1540 | |
---|
1541 | if ( rpcSlice->getEnableTMVPFlag() ) |
---|
1542 | { |
---|
1543 | #if H_MV |
---|
1544 | if( rpcSlice->getLayerId() > 0 && rpcSlice->getNumActiveMotionPredRefLayers() > 0 ) |
---|
1545 | { |
---|
1546 | READ_FLAG( uiCode, "alt_collocated_indication_flag" ); rpcSlice->setAltCollocatedIndicationFlag( uiCode == 1 ); |
---|
1547 | } |
---|
1548 | |
---|
1549 | if( rpcSlice->getAltCollocatedIndicationFlag() && rpcSlice->getNumActiveMotionPredRefLayers() > 1 ) |
---|
1550 | { |
---|
1551 | READ_UVLC( uiCode, "collocated_ref_layer_idx" ); rpcSlice->setCollocatedRefLayerIdx( uiCode ); |
---|
1552 | } |
---|
1553 | else |
---|
1554 | { |
---|
1555 | #endif |
---|
1556 | if ( rpcSlice->getSliceType() == B_SLICE ) |
---|
1557 | { |
---|
1558 | READ_FLAG( uiCode, "collocated_from_l0_flag" ); |
---|
1559 | rpcSlice->setColFromL0Flag(uiCode); |
---|
1560 | } |
---|
1561 | else |
---|
1562 | { |
---|
1563 | rpcSlice->setColFromL0Flag( 1 ); |
---|
1564 | } |
---|
1565 | |
---|
1566 | if ( rpcSlice->getSliceType() != I_SLICE && |
---|
1567 | ((rpcSlice->getColFromL0Flag() == 1 && rpcSlice->getNumRefIdx(REF_PIC_LIST_0) > 1)|| |
---|
1568 | (rpcSlice->getColFromL0Flag() == 0 && rpcSlice->getNumRefIdx(REF_PIC_LIST_1) > 1))) |
---|
1569 | { |
---|
1570 | READ_UVLC( uiCode, "collocated_ref_idx" ); |
---|
1571 | rpcSlice->setColRefIdx(uiCode); |
---|
1572 | } |
---|
1573 | else |
---|
1574 | { |
---|
1575 | rpcSlice->setColRefIdx(0); |
---|
1576 | } |
---|
1577 | #if H_MV |
---|
1578 | } |
---|
1579 | #endif |
---|
1580 | } |
---|
1581 | if ( (pps->getUseWP() && rpcSlice->getSliceType()==P_SLICE) || (pps->getWPBiPred() && rpcSlice->getSliceType()==B_SLICE) ) |
---|
1582 | { |
---|
1583 | xParsePredWeightTable(rpcSlice); |
---|
1584 | rpcSlice->initWpScaling(); |
---|
1585 | } |
---|
1586 | #if H_3D_IC |
---|
1587 | else if( rpcSlice->getViewIndex() && ( rpcSlice->getSliceType() == P_SLICE || rpcSlice->getSliceType() == B_SLICE ) ) |
---|
1588 | { |
---|
1589 | UInt uiCodeTmp = 0; |
---|
1590 | |
---|
1591 | READ_FLAG ( uiCodeTmp, "slice_ic_enable_flag" ); |
---|
1592 | rpcSlice->setApplyIC( uiCodeTmp ); |
---|
1593 | |
---|
1594 | if ( uiCodeTmp ) |
---|
1595 | { |
---|
1596 | READ_FLAG ( uiCodeTmp, "ic_skip_mergeidx0" ); |
---|
1597 | rpcSlice->setIcSkipParseFlag( uiCodeTmp ); |
---|
1598 | } |
---|
1599 | } |
---|
1600 | #endif |
---|
1601 | if (!rpcSlice->isIntra()) |
---|
1602 | { |
---|
1603 | READ_UVLC( uiCode, "five_minus_max_num_merge_cand"); |
---|
1604 | #if H_3D_IV_MERGE |
---|
1605 | Bool ivMvPredFlag = rpcSlice->getVPS()->getIvMvPredFlag( rpcSlice->getLayerIdInVps() ) ; |
---|
1606 | rpcSlice->setMaxNumMergeCand(( ivMvPredFlag ? MRG_MAX_NUM_CANDS_MEM : MRG_MAX_NUM_CANDS) - uiCode); |
---|
1607 | #else |
---|
1608 | rpcSlice->setMaxNumMergeCand(MRG_MAX_NUM_CANDS - uiCode); |
---|
1609 | #endif |
---|
1610 | } |
---|
1611 | |
---|
1612 | READ_SVLC( iCode, "slice_qp_delta" ); |
---|
1613 | rpcSlice->setSliceQp (26 + pps->getPicInitQPMinus26() + iCode); |
---|
1614 | |
---|
1615 | assert( rpcSlice->getSliceQp() >= -sps->getQpBDOffsetY() ); |
---|
1616 | assert( rpcSlice->getSliceQp() <= 51 ); |
---|
1617 | |
---|
1618 | if (rpcSlice->getPPS()->getSliceChromaQpFlag()) |
---|
1619 | { |
---|
1620 | READ_SVLC( iCode, "slice_qp_delta_cb" ); |
---|
1621 | rpcSlice->setSliceQpDeltaCb( iCode ); |
---|
1622 | assert( rpcSlice->getSliceQpDeltaCb() >= -12 ); |
---|
1623 | assert( rpcSlice->getSliceQpDeltaCb() <= 12 ); |
---|
1624 | assert( (rpcSlice->getPPS()->getChromaCbQpOffset() + rpcSlice->getSliceQpDeltaCb()) >= -12 ); |
---|
1625 | assert( (rpcSlice->getPPS()->getChromaCbQpOffset() + rpcSlice->getSliceQpDeltaCb()) <= 12 ); |
---|
1626 | |
---|
1627 | READ_SVLC( iCode, "slice_qp_delta_cr" ); |
---|
1628 | rpcSlice->setSliceQpDeltaCr( iCode ); |
---|
1629 | assert( rpcSlice->getSliceQpDeltaCr() >= -12 ); |
---|
1630 | assert( rpcSlice->getSliceQpDeltaCr() <= 12 ); |
---|
1631 | assert( (rpcSlice->getPPS()->getChromaCrQpOffset() + rpcSlice->getSliceQpDeltaCr()) >= -12 ); |
---|
1632 | assert( (rpcSlice->getPPS()->getChromaCrQpOffset() + rpcSlice->getSliceQpDeltaCr()) <= 12 ); |
---|
1633 | } |
---|
1634 | |
---|
1635 | if (rpcSlice->getPPS()->getDeblockingFilterControlPresentFlag()) |
---|
1636 | { |
---|
1637 | if(rpcSlice->getPPS()->getDeblockingFilterOverrideEnabledFlag()) |
---|
1638 | { |
---|
1639 | READ_FLAG ( uiCode, "deblocking_filter_override_flag" ); rpcSlice->setDeblockingFilterOverrideFlag(uiCode ? true : false); |
---|
1640 | } |
---|
1641 | else |
---|
1642 | { |
---|
1643 | rpcSlice->setDeblockingFilterOverrideFlag(0); |
---|
1644 | } |
---|
1645 | if(rpcSlice->getDeblockingFilterOverrideFlag()) |
---|
1646 | { |
---|
1647 | READ_FLAG ( uiCode, "slice_disable_deblocking_filter_flag" ); rpcSlice->setDeblockingFilterDisable(uiCode ? 1 : 0); |
---|
1648 | if(!rpcSlice->getDeblockingFilterDisable()) |
---|
1649 | { |
---|
1650 | READ_SVLC( iCode, "slice_beta_offset_div2" ); rpcSlice->setDeblockingFilterBetaOffsetDiv2(iCode); |
---|
1651 | assert(rpcSlice->getDeblockingFilterBetaOffsetDiv2() >= -6 && |
---|
1652 | rpcSlice->getDeblockingFilterBetaOffsetDiv2() <= 6); |
---|
1653 | READ_SVLC( iCode, "slice_tc_offset_div2" ); rpcSlice->setDeblockingFilterTcOffsetDiv2(iCode); |
---|
1654 | assert(rpcSlice->getDeblockingFilterTcOffsetDiv2() >= -6 && |
---|
1655 | rpcSlice->getDeblockingFilterTcOffsetDiv2() <= 6); |
---|
1656 | } |
---|
1657 | } |
---|
1658 | else |
---|
1659 | { |
---|
1660 | rpcSlice->setDeblockingFilterDisable ( rpcSlice->getPPS()->getPicDisableDeblockingFilterFlag() ); |
---|
1661 | rpcSlice->setDeblockingFilterBetaOffsetDiv2( rpcSlice->getPPS()->getDeblockingFilterBetaOffsetDiv2() ); |
---|
1662 | rpcSlice->setDeblockingFilterTcOffsetDiv2 ( rpcSlice->getPPS()->getDeblockingFilterTcOffsetDiv2() ); |
---|
1663 | } |
---|
1664 | } |
---|
1665 | else |
---|
1666 | { |
---|
1667 | rpcSlice->setDeblockingFilterDisable ( false ); |
---|
1668 | rpcSlice->setDeblockingFilterBetaOffsetDiv2( 0 ); |
---|
1669 | rpcSlice->setDeblockingFilterTcOffsetDiv2 ( 0 ); |
---|
1670 | } |
---|
1671 | |
---|
1672 | Bool isSAOEnabled = (!rpcSlice->getSPS()->getUseSAO())?(false):(rpcSlice->getSaoEnabledFlag()||rpcSlice->getSaoEnabledFlagChroma()); |
---|
1673 | Bool isDBFEnabled = (!rpcSlice->getDeblockingFilterDisable()); |
---|
1674 | |
---|
1675 | if(rpcSlice->getPPS()->getLoopFilterAcrossSlicesEnabledFlag() && ( isSAOEnabled || isDBFEnabled )) |
---|
1676 | { |
---|
1677 | READ_FLAG( uiCode, "slice_loop_filter_across_slices_enabled_flag"); |
---|
1678 | } |
---|
1679 | else |
---|
1680 | { |
---|
1681 | uiCode = rpcSlice->getPPS()->getLoopFilterAcrossSlicesEnabledFlag()?1:0; |
---|
1682 | } |
---|
1683 | rpcSlice->setLFCrossSliceBoundaryFlag( (uiCode==1)?true:false); |
---|
1684 | |
---|
1685 | } |
---|
1686 | |
---|
1687 | UInt *entryPointOffset = NULL; |
---|
1688 | UInt numEntryPointOffsets, offsetLenMinus1; |
---|
1689 | if( pps->getTilesEnabledFlag() || pps->getEntropyCodingSyncEnabledFlag() ) |
---|
1690 | { |
---|
1691 | READ_UVLC(numEntryPointOffsets, "num_entry_point_offsets"); rpcSlice->setNumEntryPointOffsets ( numEntryPointOffsets ); |
---|
1692 | if (numEntryPointOffsets>0) |
---|
1693 | { |
---|
1694 | READ_UVLC(offsetLenMinus1, "offset_len_minus1"); |
---|
1695 | } |
---|
1696 | entryPointOffset = new UInt[numEntryPointOffsets]; |
---|
1697 | for (UInt idx=0; idx<numEntryPointOffsets; idx++) |
---|
1698 | { |
---|
1699 | READ_CODE(offsetLenMinus1+1, uiCode, "entry_point_offset_minus1"); |
---|
1700 | entryPointOffset[ idx ] = uiCode + 1; |
---|
1701 | } |
---|
1702 | } |
---|
1703 | else |
---|
1704 | { |
---|
1705 | rpcSlice->setNumEntryPointOffsets ( 0 ); |
---|
1706 | } |
---|
1707 | |
---|
1708 | if(pps->getSliceHeaderExtensionPresentFlag()) |
---|
1709 | { |
---|
1710 | READ_UVLC(uiCode,"slice_header_extension_length"); |
---|
1711 | #if H_3D |
---|
1712 | if( rpcSlice->getSPS()->hasCamParInSliceHeader() ) |
---|
1713 | { |
---|
1714 | UInt uiViewIndex = rpcSlice->getViewIndex(); |
---|
1715 | for( UInt uiBaseIndex = 0; uiBaseIndex < uiViewIndex; uiBaseIndex++ ) |
---|
1716 | { |
---|
1717 | READ_SVLC( iCode, "cp_scale" ); m_aaiTempScale [ uiBaseIndex ][ uiViewIndex ] = iCode; |
---|
1718 | READ_SVLC( iCode, "cp_off" ); m_aaiTempOffset[ uiBaseIndex ][ uiViewIndex ] = iCode; |
---|
1719 | READ_SVLC( iCode, "cp_inv_scale_plus_scale" ); m_aaiTempScale [ uiViewIndex ][ uiBaseIndex ] = iCode - m_aaiTempScale [ uiBaseIndex ][ uiViewIndex ]; |
---|
1720 | READ_SVLC( iCode, "cp_inv_off_plus_off" ); m_aaiTempOffset[ uiViewIndex ][ uiBaseIndex ] = iCode - m_aaiTempOffset[ uiBaseIndex ][ uiViewIndex ]; |
---|
1721 | } |
---|
1722 | rpcSlice->setCamparaSlice( m_aaiTempScale, m_aaiTempOffset ); |
---|
1723 | } |
---|
1724 | |
---|
1725 | READ_FLAG(uiCode,"slice_segment_header_extension2_flag"); |
---|
1726 | if ( uiCode ) |
---|
1727 | { |
---|
1728 | READ_UVLC(uiCode,"slice_header_extension2_length"); |
---|
1729 | for(Int i=0; i<uiCode; i++) |
---|
1730 | { |
---|
1731 | UInt ignore; |
---|
1732 | READ_CODE(8,ignore,"slice_header_extension2_data_byte"); |
---|
1733 | } |
---|
1734 | } |
---|
1735 | } |
---|
1736 | #else |
---|
1737 | for(Int i=0; i<uiCode; i++) |
---|
1738 | { |
---|
1739 | UInt ignore; |
---|
1740 | READ_CODE(8,ignore,"slice_header_extension_data_byte"); |
---|
1741 | } |
---|
1742 | } |
---|
1743 | #endif |
---|
1744 | m_pcBitstream->readByteAlignment(); |
---|
1745 | |
---|
1746 | if( pps->getTilesEnabledFlag() || pps->getEntropyCodingSyncEnabledFlag() ) |
---|
1747 | { |
---|
1748 | Int endOfSliceHeaderLocation = m_pcBitstream->getByteLocation(); |
---|
1749 | |
---|
1750 | // Adjust endOfSliceHeaderLocation to account for emulation prevention bytes in the slice segment header |
---|
1751 | for ( UInt curByteIdx = 0; curByteIdx<m_pcBitstream->numEmulationPreventionBytesRead(); curByteIdx++ ) |
---|
1752 | { |
---|
1753 | if ( m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) < endOfSliceHeaderLocation ) |
---|
1754 | { |
---|
1755 | endOfSliceHeaderLocation++; |
---|
1756 | } |
---|
1757 | } |
---|
1758 | |
---|
1759 | Int curEntryPointOffset = 0; |
---|
1760 | Int prevEntryPointOffset = 0; |
---|
1761 | for (UInt idx=0; idx<numEntryPointOffsets; idx++) |
---|
1762 | { |
---|
1763 | curEntryPointOffset += entryPointOffset[ idx ]; |
---|
1764 | |
---|
1765 | Int emulationPreventionByteCount = 0; |
---|
1766 | for ( UInt curByteIdx = 0; curByteIdx<m_pcBitstream->numEmulationPreventionBytesRead(); curByteIdx++ ) |
---|
1767 | { |
---|
1768 | if ( m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) >= ( prevEntryPointOffset + endOfSliceHeaderLocation ) && |
---|
1769 | m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) < ( curEntryPointOffset + endOfSliceHeaderLocation ) ) |
---|
1770 | { |
---|
1771 | emulationPreventionByteCount++; |
---|
1772 | } |
---|
1773 | } |
---|
1774 | |
---|
1775 | entryPointOffset[ idx ] -= emulationPreventionByteCount; |
---|
1776 | prevEntryPointOffset = curEntryPointOffset; |
---|
1777 | } |
---|
1778 | |
---|
1779 | if ( pps->getTilesEnabledFlag() ) |
---|
1780 | { |
---|
1781 | rpcSlice->setTileLocationCount( numEntryPointOffsets ); |
---|
1782 | |
---|
1783 | UInt prevPos = 0; |
---|
1784 | for (Int idx=0; idx<rpcSlice->getTileLocationCount(); idx++) |
---|
1785 | { |
---|
1786 | rpcSlice->setTileLocation( idx, prevPos + entryPointOffset [ idx ] ); |
---|
1787 | prevPos += entryPointOffset[ idx ]; |
---|
1788 | } |
---|
1789 | } |
---|
1790 | else if ( pps->getEntropyCodingSyncEnabledFlag() ) |
---|
1791 | { |
---|
1792 | Int numSubstreams = rpcSlice->getNumEntryPointOffsets()+1; |
---|
1793 | rpcSlice->allocSubstreamSizes(numSubstreams); |
---|
1794 | UInt *pSubstreamSizes = rpcSlice->getSubstreamSizes(); |
---|
1795 | for (Int idx=0; idx<numSubstreams-1; idx++) |
---|
1796 | { |
---|
1797 | if ( idx < numEntryPointOffsets ) |
---|
1798 | { |
---|
1799 | pSubstreamSizes[ idx ] = ( entryPointOffset[ idx ] << 3 ) ; |
---|
1800 | } |
---|
1801 | else |
---|
1802 | { |
---|
1803 | pSubstreamSizes[ idx ] = 0; |
---|
1804 | } |
---|
1805 | } |
---|
1806 | } |
---|
1807 | |
---|
1808 | if (entryPointOffset) |
---|
1809 | { |
---|
1810 | delete [] entryPointOffset; |
---|
1811 | } |
---|
1812 | } |
---|
1813 | |
---|
1814 | return; |
---|
1815 | } |
---|
1816 | |
---|
1817 | Void TDecCavlc::parsePTL( TComPTL *rpcPTL, Bool profilePresentFlag, Int maxNumSubLayersMinus1 ) |
---|
1818 | { |
---|
1819 | UInt uiCode; |
---|
1820 | if(profilePresentFlag) |
---|
1821 | { |
---|
1822 | parseProfileTier(rpcPTL->getGeneralPTL()); |
---|
1823 | } |
---|
1824 | READ_CODE( 8, uiCode, "general_level_idc" ); rpcPTL->getGeneralPTL()->setLevelIdc(uiCode); |
---|
1825 | |
---|
1826 | for (Int i = 0; i < maxNumSubLayersMinus1; i++) |
---|
1827 | { |
---|
1828 | #if !H_MV |
---|
1829 | if(profilePresentFlag) |
---|
1830 | { |
---|
1831 | #endif |
---|
1832 | READ_FLAG( uiCode, "sub_layer_profile_present_flag[i]" ); rpcPTL->setSubLayerProfilePresentFlag(i, uiCode); |
---|
1833 | #if H_MV |
---|
1834 | rpcPTL->setSubLayerProfilePresentFlag( i, profilePresentFlag && rpcPTL->getSubLayerProfilePresentFlag(i) ); |
---|
1835 | #else |
---|
1836 | } |
---|
1837 | #endif |
---|
1838 | READ_FLAG( uiCode, "sub_layer_level_present_flag[i]" ); rpcPTL->setSubLayerLevelPresentFlag (i, uiCode); |
---|
1839 | } |
---|
1840 | |
---|
1841 | if (maxNumSubLayersMinus1 > 0) |
---|
1842 | { |
---|
1843 | for (Int i = maxNumSubLayersMinus1; i < 8; i++) |
---|
1844 | { |
---|
1845 | READ_CODE(2, uiCode, "reserved_zero_2bits"); |
---|
1846 | assert(uiCode == 0); |
---|
1847 | } |
---|
1848 | } |
---|
1849 | |
---|
1850 | for(Int i = 0; i < maxNumSubLayersMinus1; i++) |
---|
1851 | { |
---|
1852 | if( profilePresentFlag && rpcPTL->getSubLayerProfilePresentFlag(i) ) |
---|
1853 | { |
---|
1854 | parseProfileTier(rpcPTL->getSubLayerPTL(i)); |
---|
1855 | } |
---|
1856 | if(rpcPTL->getSubLayerLevelPresentFlag(i)) |
---|
1857 | { |
---|
1858 | READ_CODE( 8, uiCode, "sub_layer_level_idc[i]" ); rpcPTL->getSubLayerPTL(i)->setLevelIdc(uiCode); |
---|
1859 | } |
---|
1860 | } |
---|
1861 | } |
---|
1862 | |
---|
1863 | Void TDecCavlc::parseProfileTier(ProfileTierLevel *ptl) |
---|
1864 | { |
---|
1865 | UInt uiCode; |
---|
1866 | READ_CODE(2 , uiCode, "XXX_profile_space[]"); ptl->setProfileSpace(uiCode); |
---|
1867 | READ_FLAG( uiCode, "XXX_tier_flag[]" ); ptl->setTierFlag (uiCode ? 1 : 0); |
---|
1868 | READ_CODE(5 , uiCode, "XXX_profile_idc[]" ); ptl->setProfileIdc (uiCode); |
---|
1869 | for(Int j = 0; j < 32; j++) |
---|
1870 | { |
---|
1871 | READ_FLAG( uiCode, "XXX_profile_compatibility_flag[][j]"); ptl->setProfileCompatibilityFlag(j, uiCode ? 1 : 0); |
---|
1872 | } |
---|
1873 | READ_FLAG(uiCode, "general_progressive_source_flag"); |
---|
1874 | ptl->setProgressiveSourceFlag(uiCode ? true : false); |
---|
1875 | |
---|
1876 | READ_FLAG(uiCode, "general_interlaced_source_flag"); |
---|
1877 | ptl->setInterlacedSourceFlag(uiCode ? true : false); |
---|
1878 | |
---|
1879 | READ_FLAG(uiCode, "general_non_packed_constraint_flag"); |
---|
1880 | ptl->setNonPackedConstraintFlag(uiCode ? true : false); |
---|
1881 | |
---|
1882 | READ_FLAG(uiCode, "general_frame_only_constraint_flag"); |
---|
1883 | ptl->setFrameOnlyConstraintFlag(uiCode ? true : false); |
---|
1884 | |
---|
1885 | READ_CODE(16, uiCode, "XXX_reserved_zero_44bits[0..15]"); |
---|
1886 | READ_CODE(16, uiCode, "XXX_reserved_zero_44bits[16..31]"); |
---|
1887 | READ_CODE(12, uiCode, "XXX_reserved_zero_44bits[32..43]"); |
---|
1888 | } |
---|
1889 | |
---|
1890 | Void TDecCavlc::parseTerminatingBit( UInt& ruiBit ) |
---|
1891 | { |
---|
1892 | ruiBit = false; |
---|
1893 | Int iBitsLeft = m_pcBitstream->getNumBitsLeft(); |
---|
1894 | if(iBitsLeft <= 8) |
---|
1895 | { |
---|
1896 | UInt uiPeekValue = m_pcBitstream->peekBits(iBitsLeft); |
---|
1897 | if (uiPeekValue == (1<<(iBitsLeft-1))) |
---|
1898 | { |
---|
1899 | ruiBit = true; |
---|
1900 | } |
---|
1901 | } |
---|
1902 | } |
---|
1903 | |
---|
1904 | Void TDecCavlc::parseSkipFlag( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
1905 | { |
---|
1906 | assert(0); |
---|
1907 | } |
---|
1908 | |
---|
1909 | Void TDecCavlc::parseCUTransquantBypassFlag( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
1910 | { |
---|
1911 | assert(0); |
---|
1912 | } |
---|
1913 | |
---|
1914 | Void TDecCavlc::parseMVPIdx( Int& /*riMVPIdx*/ ) |
---|
1915 | { |
---|
1916 | assert(0); |
---|
1917 | } |
---|
1918 | |
---|
1919 | Void TDecCavlc::parseSplitFlag ( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
1920 | { |
---|
1921 | assert(0); |
---|
1922 | } |
---|
1923 | |
---|
1924 | Void TDecCavlc::parsePartSize( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
1925 | { |
---|
1926 | assert(0); |
---|
1927 | } |
---|
1928 | |
---|
1929 | Void TDecCavlc::parsePredMode( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
1930 | { |
---|
1931 | assert(0); |
---|
1932 | } |
---|
1933 | |
---|
1934 | /** Parse I_PCM information. |
---|
1935 | * \param pcCU pointer to CU |
---|
1936 | * \param uiAbsPartIdx CU index |
---|
1937 | * \param uiDepth CU depth |
---|
1938 | * \returns Void |
---|
1939 | * |
---|
1940 | * If I_PCM flag indicates that the CU is I_PCM, parse its PCM alignment bits and codes. |
---|
1941 | */ |
---|
1942 | Void TDecCavlc::parseIPCMInfo( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
1943 | { |
---|
1944 | assert(0); |
---|
1945 | } |
---|
1946 | |
---|
1947 | Void TDecCavlc::parseIntraDirLumaAng ( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
1948 | { |
---|
1949 | assert(0); |
---|
1950 | } |
---|
1951 | |
---|
1952 | Void TDecCavlc::parseIntraDirChroma( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
1953 | { |
---|
1954 | assert(0); |
---|
1955 | } |
---|
1956 | |
---|
1957 | Void TDecCavlc::parseInterDir( TComDataCU* /*pcCU*/, UInt& /*ruiInterDir*/, UInt /*uiAbsPartIdx*/ ) |
---|
1958 | { |
---|
1959 | assert(0); |
---|
1960 | } |
---|
1961 | |
---|
1962 | Void TDecCavlc::parseRefFrmIdx( TComDataCU* /*pcCU*/, Int& /*riRefFrmIdx*/, RefPicList /*eRefList*/ ) |
---|
1963 | { |
---|
1964 | assert(0); |
---|
1965 | } |
---|
1966 | |
---|
1967 | Void TDecCavlc::parseMvd( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiPartIdx*/, UInt /*uiDepth*/, RefPicList /*eRefList*/ ) |
---|
1968 | { |
---|
1969 | assert(0); |
---|
1970 | } |
---|
1971 | |
---|
1972 | Void TDecCavlc::parseDeltaQP( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
1973 | { |
---|
1974 | Int qp; |
---|
1975 | Int iDQp; |
---|
1976 | |
---|
1977 | xReadSvlc( iDQp ); |
---|
1978 | |
---|
1979 | Int qpBdOffsetY = pcCU->getSlice()->getSPS()->getQpBDOffsetY(); |
---|
1980 | qp = (((Int) pcCU->getRefQP( uiAbsPartIdx ) + iDQp + 52 + 2*qpBdOffsetY )%(52+ qpBdOffsetY)) - qpBdOffsetY; |
---|
1981 | |
---|
1982 | UInt uiAbsQpCUPartIdx = (uiAbsPartIdx>>((g_uiMaxCUDepth - pcCU->getSlice()->getPPS()->getMaxCuDQPDepth())<<1))<<((g_uiMaxCUDepth - pcCU->getSlice()->getPPS()->getMaxCuDQPDepth())<<1) ; |
---|
1983 | UInt uiQpCUDepth = min(uiDepth,pcCU->getSlice()->getPPS()->getMaxCuDQPDepth()) ; |
---|
1984 | |
---|
1985 | pcCU->setQPSubParts( qp, uiAbsQpCUPartIdx, uiQpCUDepth ); |
---|
1986 | } |
---|
1987 | |
---|
1988 | Void TDecCavlc::parseCoeffNxN( TComDataCU* /*pcCU*/, TCoeff* /*pcCoef*/, UInt /*uiAbsPartIdx*/, UInt /*uiWidth*/, UInt /*uiHeight*/, UInt /*uiDepth*/, TextType /*eTType*/ ) |
---|
1989 | { |
---|
1990 | assert(0); |
---|
1991 | } |
---|
1992 | |
---|
1993 | Void TDecCavlc::parseTransformSubdivFlag( UInt& /*ruiSubdivFlag*/, UInt /*uiLog2TransformBlockSize*/ ) |
---|
1994 | { |
---|
1995 | assert(0); |
---|
1996 | } |
---|
1997 | |
---|
1998 | Void TDecCavlc::parseQtCbf( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, TextType /*eType*/, UInt /*uiTrDepth*/, UInt /*uiDepth*/ ) |
---|
1999 | { |
---|
2000 | assert(0); |
---|
2001 | } |
---|
2002 | |
---|
2003 | Void TDecCavlc::parseQtRootCbf( UInt /*uiAbsPartIdx*/, UInt& /*uiQtRootCbf*/ ) |
---|
2004 | { |
---|
2005 | assert(0); |
---|
2006 | } |
---|
2007 | |
---|
2008 | Void TDecCavlc::parseTransformSkipFlags (TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*width*/, UInt /*height*/, UInt /*uiDepth*/, TextType /*eTType*/) |
---|
2009 | { |
---|
2010 | assert(0); |
---|
2011 | } |
---|
2012 | |
---|
2013 | Void TDecCavlc::parseMergeFlag ( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/, UInt /*uiPUIdx*/ ) |
---|
2014 | { |
---|
2015 | assert(0); |
---|
2016 | } |
---|
2017 | |
---|
2018 | Void TDecCavlc::parseMergeIndex ( TComDataCU* /*pcCU*/, UInt& /*ruiMergeIndex*/ ) |
---|
2019 | { |
---|
2020 | assert(0); |
---|
2021 | } |
---|
2022 | |
---|
2023 | #if H_3D_ARP |
---|
2024 | Void TDecCavlc::parseARPW( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2025 | { |
---|
2026 | assert(0); |
---|
2027 | } |
---|
2028 | #endif |
---|
2029 | #if H_3D_IC |
---|
2030 | Void TDecCavlc::parseICFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2031 | { |
---|
2032 | assert(0); |
---|
2033 | } |
---|
2034 | #endif |
---|
2035 | // ==================================================================================================================== |
---|
2036 | // Protected member functions |
---|
2037 | // ==================================================================================================================== |
---|
2038 | |
---|
2039 | /** parse explicit wp tables |
---|
2040 | * \param TComSlice* pcSlice |
---|
2041 | * \returns Void |
---|
2042 | */ |
---|
2043 | Void TDecCavlc::xParsePredWeightTable( TComSlice* pcSlice ) |
---|
2044 | { |
---|
2045 | wpScalingParam *wp; |
---|
2046 | Bool bChroma = true; // color always present in HEVC ? |
---|
2047 | SliceType eSliceType = pcSlice->getSliceType(); |
---|
2048 | Int iNbRef = (eSliceType == B_SLICE ) ? (2) : (1); |
---|
2049 | UInt uiLog2WeightDenomLuma, uiLog2WeightDenomChroma; |
---|
2050 | UInt uiTotalSignalledWeightFlags = 0; |
---|
2051 | |
---|
2052 | Int iDeltaDenom; |
---|
2053 | // decode delta_luma_log2_weight_denom : |
---|
2054 | READ_UVLC( uiLog2WeightDenomLuma, "luma_log2_weight_denom" ); // ue(v): luma_log2_weight_denom |
---|
2055 | assert( uiLog2WeightDenomLuma <= 7 ); |
---|
2056 | if( bChroma ) |
---|
2057 | { |
---|
2058 | READ_SVLC( iDeltaDenom, "delta_chroma_log2_weight_denom" ); // se(v): delta_chroma_log2_weight_denom |
---|
2059 | assert((iDeltaDenom + (Int)uiLog2WeightDenomLuma)>=0); |
---|
2060 | assert((iDeltaDenom + (Int)uiLog2WeightDenomLuma)<=7); |
---|
2061 | uiLog2WeightDenomChroma = (UInt)(iDeltaDenom + uiLog2WeightDenomLuma); |
---|
2062 | } |
---|
2063 | |
---|
2064 | for ( Int iNumRef=0 ; iNumRef<iNbRef ; iNumRef++ ) |
---|
2065 | { |
---|
2066 | RefPicList eRefPicList = ( iNumRef ? REF_PIC_LIST_1 : REF_PIC_LIST_0 ); |
---|
2067 | for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ ) |
---|
2068 | { |
---|
2069 | pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); |
---|
2070 | |
---|
2071 | wp[0].uiLog2WeightDenom = uiLog2WeightDenomLuma; |
---|
2072 | wp[1].uiLog2WeightDenom = uiLog2WeightDenomChroma; |
---|
2073 | wp[2].uiLog2WeightDenom = uiLog2WeightDenomChroma; |
---|
2074 | |
---|
2075 | UInt uiCode; |
---|
2076 | READ_FLAG( uiCode, "luma_weight_lX_flag" ); // u(1): luma_weight_l0_flag |
---|
2077 | wp[0].bPresentFlag = ( uiCode == 1 ); |
---|
2078 | uiTotalSignalledWeightFlags += wp[0].bPresentFlag; |
---|
2079 | } |
---|
2080 | if ( bChroma ) |
---|
2081 | { |
---|
2082 | UInt uiCode; |
---|
2083 | for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ ) |
---|
2084 | { |
---|
2085 | pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); |
---|
2086 | READ_FLAG( uiCode, "chroma_weight_lX_flag" ); // u(1): chroma_weight_l0_flag |
---|
2087 | wp[1].bPresentFlag = ( uiCode == 1 ); |
---|
2088 | wp[2].bPresentFlag = ( uiCode == 1 ); |
---|
2089 | uiTotalSignalledWeightFlags += 2*wp[1].bPresentFlag; |
---|
2090 | } |
---|
2091 | } |
---|
2092 | for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ ) |
---|
2093 | { |
---|
2094 | pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); |
---|
2095 | if ( wp[0].bPresentFlag ) |
---|
2096 | { |
---|
2097 | Int iDeltaWeight; |
---|
2098 | READ_SVLC( iDeltaWeight, "delta_luma_weight_lX" ); // se(v): delta_luma_weight_l0[i] |
---|
2099 | assert( iDeltaWeight >= -128 ); |
---|
2100 | assert( iDeltaWeight <= 127 ); |
---|
2101 | wp[0].iWeight = (iDeltaWeight + (1<<wp[0].uiLog2WeightDenom)); |
---|
2102 | READ_SVLC( wp[0].iOffset, "luma_offset_lX" ); // se(v): luma_offset_l0[i] |
---|
2103 | assert( wp[0].iOffset >= -128 ); |
---|
2104 | assert( wp[0].iOffset <= 127 ); |
---|
2105 | } |
---|
2106 | else |
---|
2107 | { |
---|
2108 | wp[0].iWeight = (1 << wp[0].uiLog2WeightDenom); |
---|
2109 | wp[0].iOffset = 0; |
---|
2110 | } |
---|
2111 | if ( bChroma ) |
---|
2112 | { |
---|
2113 | if ( wp[1].bPresentFlag ) |
---|
2114 | { |
---|
2115 | for ( Int j=1 ; j<3 ; j++ ) |
---|
2116 | { |
---|
2117 | Int iDeltaWeight; |
---|
2118 | READ_SVLC( iDeltaWeight, "delta_chroma_weight_lX" ); // se(v): chroma_weight_l0[i][j] |
---|
2119 | assert( iDeltaWeight >= -128 ); |
---|
2120 | assert( iDeltaWeight <= 127 ); |
---|
2121 | wp[j].iWeight = (iDeltaWeight + (1<<wp[1].uiLog2WeightDenom)); |
---|
2122 | |
---|
2123 | Int iDeltaChroma; |
---|
2124 | READ_SVLC( iDeltaChroma, "delta_chroma_offset_lX" ); // se(v): delta_chroma_offset_l0[i][j] |
---|
2125 | assert( iDeltaChroma >= -512 ); |
---|
2126 | assert( iDeltaChroma <= 511 ); |
---|
2127 | Int pred = ( 128 - ( ( 128*wp[j].iWeight)>>(wp[j].uiLog2WeightDenom) ) ); |
---|
2128 | wp[j].iOffset = Clip3(-128, 127, (iDeltaChroma + pred) ); |
---|
2129 | } |
---|
2130 | } |
---|
2131 | else |
---|
2132 | { |
---|
2133 | for ( Int j=1 ; j<3 ; j++ ) |
---|
2134 | { |
---|
2135 | wp[j].iWeight = (1 << wp[j].uiLog2WeightDenom); |
---|
2136 | wp[j].iOffset = 0; |
---|
2137 | } |
---|
2138 | } |
---|
2139 | } |
---|
2140 | } |
---|
2141 | |
---|
2142 | for ( Int iRefIdx=pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx<MAX_NUM_REF ; iRefIdx++ ) |
---|
2143 | { |
---|
2144 | pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); |
---|
2145 | |
---|
2146 | wp[0].bPresentFlag = false; |
---|
2147 | wp[1].bPresentFlag = false; |
---|
2148 | wp[2].bPresentFlag = false; |
---|
2149 | } |
---|
2150 | } |
---|
2151 | assert(uiTotalSignalledWeightFlags<=24); |
---|
2152 | } |
---|
2153 | |
---|
2154 | /** decode quantization matrix |
---|
2155 | * \param scalingList quantization matrix information |
---|
2156 | */ |
---|
2157 | Void TDecCavlc::parseScalingList(TComScalingList* scalingList) |
---|
2158 | { |
---|
2159 | UInt code, sizeId, listId; |
---|
2160 | Bool scalingListPredModeFlag; |
---|
2161 | //for each size |
---|
2162 | for(sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
2163 | { |
---|
2164 | for(listId = 0; listId < g_scalingListNum[sizeId]; listId++) |
---|
2165 | { |
---|
2166 | READ_FLAG( code, "scaling_list_pred_mode_flag"); |
---|
2167 | scalingListPredModeFlag = (code) ? true : false; |
---|
2168 | if(!scalingListPredModeFlag) //Copy Mode |
---|
2169 | { |
---|
2170 | READ_UVLC( code, "scaling_list_pred_matrix_id_delta"); |
---|
2171 | scalingList->setRefMatrixId (sizeId,listId,(UInt)((Int)(listId)-(code))); |
---|
2172 | if( sizeId > SCALING_LIST_8x8 ) |
---|
2173 | { |
---|
2174 | scalingList->setScalingListDC(sizeId,listId,((listId == scalingList->getRefMatrixId (sizeId,listId))? 16 :scalingList->getScalingListDC(sizeId, scalingList->getRefMatrixId (sizeId,listId)))); |
---|
2175 | } |
---|
2176 | scalingList->processRefMatrix( sizeId, listId, scalingList->getRefMatrixId (sizeId,listId)); |
---|
2177 | |
---|
2178 | } |
---|
2179 | else //DPCM Mode |
---|
2180 | { |
---|
2181 | xDecodeScalingList(scalingList, sizeId, listId); |
---|
2182 | } |
---|
2183 | } |
---|
2184 | } |
---|
2185 | |
---|
2186 | return; |
---|
2187 | } |
---|
2188 | /** decode DPCM |
---|
2189 | * \param scalingList quantization matrix information |
---|
2190 | * \param sizeId size index |
---|
2191 | * \param listId list index |
---|
2192 | */ |
---|
2193 | Void TDecCavlc::xDecodeScalingList(TComScalingList *scalingList, UInt sizeId, UInt listId) |
---|
2194 | { |
---|
2195 | Int i,coefNum = min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId]); |
---|
2196 | Int data; |
---|
2197 | Int scalingListDcCoefMinus8 = 0; |
---|
2198 | Int nextCoef = SCALING_LIST_START_VALUE; |
---|
2199 | UInt* scan = (sizeId == 0) ? g_auiSigLastScan [ SCAN_DIAG ] [ 1 ] : g_sigLastScanCG32x32; |
---|
2200 | Int *dst = scalingList->getScalingListAddress(sizeId, listId); |
---|
2201 | |
---|
2202 | if( sizeId > SCALING_LIST_8x8 ) |
---|
2203 | { |
---|
2204 | READ_SVLC( scalingListDcCoefMinus8, "scaling_list_dc_coef_minus8"); |
---|
2205 | scalingList->setScalingListDC(sizeId,listId,scalingListDcCoefMinus8 + 8); |
---|
2206 | nextCoef = scalingList->getScalingListDC(sizeId,listId); |
---|
2207 | } |
---|
2208 | |
---|
2209 | for(i = 0; i < coefNum; i++) |
---|
2210 | { |
---|
2211 | READ_SVLC( data, "scaling_list_delta_coef"); |
---|
2212 | nextCoef = (nextCoef + data + 256 ) % 256; |
---|
2213 | dst[scan[i]] = nextCoef; |
---|
2214 | } |
---|
2215 | } |
---|
2216 | |
---|
2217 | Bool TDecCavlc::xMoreRbspData() |
---|
2218 | { |
---|
2219 | Int bitsLeft = m_pcBitstream->getNumBitsLeft(); |
---|
2220 | |
---|
2221 | // if there are more than 8 bits, it cannot be rbsp_trailing_bits |
---|
2222 | if (bitsLeft > 8) |
---|
2223 | { |
---|
2224 | return true; |
---|
2225 | } |
---|
2226 | |
---|
2227 | UChar lastByte = m_pcBitstream->peekBits(bitsLeft); |
---|
2228 | Int cnt = bitsLeft; |
---|
2229 | |
---|
2230 | // remove trailing bits equal to zero |
---|
2231 | while ((cnt>0) && ((lastByte & 1) == 0)) |
---|
2232 | { |
---|
2233 | lastByte >>= 1; |
---|
2234 | cnt--; |
---|
2235 | } |
---|
2236 | // remove bit equal to one |
---|
2237 | cnt--; |
---|
2238 | |
---|
2239 | // we should not have a negative number of bits |
---|
2240 | assert (cnt>=0); |
---|
2241 | |
---|
2242 | // we have more data, if cnt is not zero |
---|
2243 | return (cnt>0); |
---|
2244 | } |
---|
2245 | |
---|
2246 | //! \} |
---|
2247 | |
---|