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