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 ( i != 0 ) |
---|
1248 | { |
---|
1249 | if( !( pcVPS->getDepthId( i ) == 1 ) ) |
---|
1250 | { |
---|
1251 | #if H_3D_IV_MERGE |
---|
1252 | READ_FLAG( uiCode, "iv_mv_pred_flag[i]"); pcVPS->setIvMvPredFlag ( i, uiCode == 1 ? true : false ); |
---|
1253 | #endif |
---|
1254 | #if H_3D_ARP |
---|
1255 | READ_FLAG( uiCode, "iv_res_pred_flag[i]" ); pcVPS->setUseAdvRP ( i, uiCode ); pcVPS->setARPStepNum( i, uiCode ? H_3D_ARP_WFNR : 1 ); |
---|
1256 | |
---|
1257 | #endif |
---|
1258 | #if H_3D_NBDV_REF |
---|
1259 | READ_FLAG( uiCode, "depth_refinement_flag[i]"); pcVPS->setDepthRefinementFlag ( i, uiCode == 1 ? true : false ); |
---|
1260 | #endif |
---|
1261 | #if H_3D_VSP |
---|
1262 | READ_FLAG( uiCode, "view_synthesis_pred_flag[i]"); pcVPS->setViewSynthesisPredFlag( i, uiCode == 1 ? true : false ); |
---|
1263 | #endif |
---|
1264 | } |
---|
1265 | else |
---|
1266 | { |
---|
1267 | |
---|
1268 | READ_FLAG( uiCode, "vps_depth_modes_flag[i]" ); pcVPS->setVpsDepthModesFlag( i, uiCode == 1 ? true : false ); |
---|
1269 | // READ_FLAG( uiCode, "lim_qt_pred_flag[i]"); pcVPS->setLimQtPreFlag ( i, uiCode == 1 ? true : false ); |
---|
1270 | #if H_3D_DIM_DLT |
---|
1271 | if( pcVPS->getVpsDepthModesFlag( i ) ) |
---|
1272 | { |
---|
1273 | READ_FLAG( uiCode, "dlt_flag[i]" ); pcVPS->setUseDLTFlag( i, uiCode == 1 ? true : false ); |
---|
1274 | } |
---|
1275 | if( pcVPS->getUseDLTFlag( i ) ) |
---|
1276 | { |
---|
1277 | // decode mapping |
---|
1278 | UInt uiNumDepthValues; |
---|
1279 | // parse number of values in DLT |
---|
1280 | READ_UVLC(uiNumDepthValues, "num_depth_values_in_dlt[i]"); |
---|
1281 | |
---|
1282 | // parse actual DLT values |
---|
1283 | Int* aiIdx2DepthValue = (Int*) calloc(uiNumDepthValues, sizeof(Int)); |
---|
1284 | for(Int d=0; d<uiNumDepthValues; d++) |
---|
1285 | { |
---|
1286 | READ_UVLC(uiCode, "dlt_depth_value[i][d]"); |
---|
1287 | aiIdx2DepthValue[d] = (Int)uiCode; |
---|
1288 | } |
---|
1289 | |
---|
1290 | pcVPS->setDepthLUTs(i, aiIdx2DepthValue, uiNumDepthValues); |
---|
1291 | |
---|
1292 | // clean memory |
---|
1293 | free(aiIdx2DepthValue); |
---|
1294 | } |
---|
1295 | #endif |
---|
1296 | #if H_3D_INTER_SDC |
---|
1297 | READ_FLAG( uiCode, "depth_inter_SDC_flag" ); pcVPS->setInterSDCFlag( i, uiCode ? true : false ); |
---|
1298 | #endif |
---|
1299 | } |
---|
1300 | } |
---|
1301 | } |
---|
1302 | READ_FLAG( uiCode, "iv_mv_scaling_flag"); pcVPS->setIvMvScalingFlag( uiCode == 1 ? true : false ); |
---|
1303 | } |
---|
1304 | #endif |
---|
1305 | |
---|
1306 | Void TDecCavlc::parseSliceHeader (TComSlice*& rpcSlice, ParameterSetManagerDecoder *parameterSetManager) |
---|
1307 | { |
---|
1308 | UInt uiCode; |
---|
1309 | Int iCode; |
---|
1310 | |
---|
1311 | #if ENC_DEC_TRACE |
---|
1312 | xTraceSliceHeader(rpcSlice); |
---|
1313 | #endif |
---|
1314 | TComPPS* pps = NULL; |
---|
1315 | TComSPS* sps = NULL; |
---|
1316 | #if H_MV |
---|
1317 | TComVPS* vps = NULL; |
---|
1318 | #endif |
---|
1319 | |
---|
1320 | UInt firstSliceSegmentInPic; |
---|
1321 | READ_FLAG( firstSliceSegmentInPic, "first_slice_segment_in_pic_flag" ); |
---|
1322 | if( rpcSlice->getRapPicFlag()) |
---|
1323 | { |
---|
1324 | READ_FLAG( uiCode, "no_output_of_prior_pics_flag" ); //ignored |
---|
1325 | } |
---|
1326 | READ_UVLC ( uiCode, "slice_pic_parameter_set_id" ); rpcSlice->setPPSId(uiCode); |
---|
1327 | pps = parameterSetManager->getPrefetchedPPS(uiCode); |
---|
1328 | //!KS: need to add error handling code here, if PPS is not available |
---|
1329 | assert(pps!=0); |
---|
1330 | sps = parameterSetManager->getPrefetchedSPS(pps->getSPSId()); |
---|
1331 | //!KS: need to add error handling code here, if SPS is not available |
---|
1332 | assert(sps!=0); |
---|
1333 | #if H_MV |
---|
1334 | vps = parameterSetManager->getPrefetchedVPS(sps->getVPSId()); |
---|
1335 | assert( vps != NULL ); |
---|
1336 | |
---|
1337 | sps->inferRepFormat ( vps , rpcSlice->getLayerId() ); |
---|
1338 | sps->inferScalingList( parameterSetManager->getActiveSPS( sps->getSpsScalingListRefLayerId() ) ); |
---|
1339 | |
---|
1340 | rpcSlice->setVPS(vps); |
---|
1341 | rpcSlice->setViewId ( vps->getViewId ( rpcSlice->getLayerId() ) ); |
---|
1342 | rpcSlice->setViewIndex( vps->getViewIndex( rpcSlice->getLayerId() ) ); |
---|
1343 | #if H_3D |
---|
1344 | rpcSlice->setIsDepth ( vps->getDepthId ( rpcSlice->getLayerId() ) == 1 ); |
---|
1345 | #endif |
---|
1346 | #endif |
---|
1347 | rpcSlice->setSPS(sps); |
---|
1348 | rpcSlice->setPPS(pps); |
---|
1349 | if( pps->getDependentSliceSegmentsEnabledFlag() && ( !firstSliceSegmentInPic )) |
---|
1350 | { |
---|
1351 | READ_FLAG( uiCode, "dependent_slice_segment_flag" ); rpcSlice->setDependentSliceSegmentFlag(uiCode ? true : false); |
---|
1352 | } |
---|
1353 | else |
---|
1354 | { |
---|
1355 | rpcSlice->setDependentSliceSegmentFlag(false); |
---|
1356 | } |
---|
1357 | Int numCTUs = ((sps->getPicWidthInLumaSamples()+sps->getMaxCUWidth()-1)/sps->getMaxCUWidth())*((sps->getPicHeightInLumaSamples()+sps->getMaxCUHeight()-1)/sps->getMaxCUHeight()); |
---|
1358 | Int maxParts = (1<<(sps->getMaxCUDepth()<<1)); |
---|
1359 | UInt sliceSegmentAddress = 0; |
---|
1360 | Int bitsSliceSegmentAddress = 0; |
---|
1361 | while(numCTUs>(1<<bitsSliceSegmentAddress)) |
---|
1362 | { |
---|
1363 | bitsSliceSegmentAddress++; |
---|
1364 | } |
---|
1365 | |
---|
1366 | if(!firstSliceSegmentInPic) |
---|
1367 | { |
---|
1368 | READ_CODE( bitsSliceSegmentAddress, sliceSegmentAddress, "slice_segment_address" ); |
---|
1369 | } |
---|
1370 | //set uiCode to equal slice start address (or dependent slice start address) |
---|
1371 | Int startCuAddress = maxParts*sliceSegmentAddress; |
---|
1372 | rpcSlice->setSliceSegmentCurStartCUAddr( startCuAddress ); |
---|
1373 | rpcSlice->setSliceSegmentCurEndCUAddr(numCTUs*maxParts); |
---|
1374 | |
---|
1375 | if (rpcSlice->getDependentSliceSegmentFlag()) |
---|
1376 | { |
---|
1377 | rpcSlice->setNextSlice ( false ); |
---|
1378 | rpcSlice->setNextSliceSegment ( true ); |
---|
1379 | } |
---|
1380 | else |
---|
1381 | { |
---|
1382 | rpcSlice->setNextSlice ( true ); |
---|
1383 | rpcSlice->setNextSliceSegment ( false ); |
---|
1384 | |
---|
1385 | rpcSlice->setSliceCurStartCUAddr(startCuAddress); |
---|
1386 | rpcSlice->setSliceCurEndCUAddr(numCTUs*maxParts); |
---|
1387 | } |
---|
1388 | |
---|
1389 | if(!rpcSlice->getDependentSliceSegmentFlag()) |
---|
1390 | { |
---|
1391 | #if H_MV |
---|
1392 | Int esb = 0; //Don't use i, otherwise will shadow something below |
---|
1393 | if ( rpcSlice->getPPS()->getNumExtraSliceHeaderBits() > esb ) |
---|
1394 | { |
---|
1395 | esb++; |
---|
1396 | READ_FLAG( uiCode, "poc_reset_flag" ); rpcSlice->setPocResetFlag( uiCode == 1 ); |
---|
1397 | } |
---|
1398 | |
---|
1399 | if ( rpcSlice->getPPS()->getNumExtraSliceHeaderBits() > esb ) |
---|
1400 | { |
---|
1401 | esb++; |
---|
1402 | READ_FLAG( uiCode, "discardable_flag" ); rpcSlice->setDiscardableFlag( uiCode == 1 ); |
---|
1403 | } |
---|
1404 | |
---|
1405 | for (; esb < rpcSlice->getPPS()->getNumExtraSliceHeaderBits(); esb++) |
---|
1406 | #else |
---|
1407 | for (Int i = 0; i < rpcSlice->getPPS()->getNumExtraSliceHeaderBits(); i++) |
---|
1408 | #endif |
---|
1409 | { |
---|
1410 | READ_FLAG(uiCode, "slice_reserved_undetermined_flag[]"); // ignored |
---|
1411 | } |
---|
1412 | |
---|
1413 | READ_UVLC ( uiCode, "slice_type" ); rpcSlice->setSliceType((SliceType)uiCode); |
---|
1414 | if( pps->getOutputFlagPresentFlag() ) |
---|
1415 | { |
---|
1416 | READ_FLAG( uiCode, "pic_output_flag" ); rpcSlice->setPicOutputFlag( uiCode ? true : false ); |
---|
1417 | } |
---|
1418 | else |
---|
1419 | { |
---|
1420 | rpcSlice->setPicOutputFlag( true ); |
---|
1421 | } |
---|
1422 | // in the first version chroma_format_idc is equal to one, thus colour_plane_id will not be present |
---|
1423 | assert (sps->getChromaFormatIdc() == 1 ); |
---|
1424 | // if( separate_colour_plane_flag == 1 ) |
---|
1425 | // colour_plane_id u(2) |
---|
1426 | |
---|
1427 | if( rpcSlice->getIdrPicFlag() ) |
---|
1428 | { |
---|
1429 | rpcSlice->setPOC(0); |
---|
1430 | TComReferencePictureSet* rps = rpcSlice->getLocalRPS(); |
---|
1431 | rps->setNumberOfNegativePictures(0); |
---|
1432 | rps->setNumberOfPositivePictures(0); |
---|
1433 | rps->setNumberOfLongtermPictures(0); |
---|
1434 | rps->setNumberOfPictures(0); |
---|
1435 | rpcSlice->setRPS(rps); |
---|
1436 | #if H_MV |
---|
1437 | rpcSlice->setEnableTMVPFlag(false); |
---|
1438 | #endif |
---|
1439 | } |
---|
1440 | else |
---|
1441 | { |
---|
1442 | READ_CODE(sps->getBitsForPOC(), uiCode, "pic_order_cnt_lsb"); |
---|
1443 | Int iPOClsb = uiCode; |
---|
1444 | Int iPrevPOC = rpcSlice->getPrevTid0POC(); |
---|
1445 | Int iMaxPOClsb = 1<< sps->getBitsForPOC(); |
---|
1446 | Int iPrevPOClsb = iPrevPOC & (iMaxPOClsb - 1); |
---|
1447 | Int iPrevPOCmsb = iPrevPOC-iPrevPOClsb; |
---|
1448 | Int iPOCmsb; |
---|
1449 | if( ( iPOClsb < iPrevPOClsb ) && ( ( iPrevPOClsb - iPOClsb ) >= ( iMaxPOClsb / 2 ) ) ) |
---|
1450 | { |
---|
1451 | iPOCmsb = iPrevPOCmsb + iMaxPOClsb; |
---|
1452 | } |
---|
1453 | else if( (iPOClsb > iPrevPOClsb ) && ( (iPOClsb - iPrevPOClsb ) > ( iMaxPOClsb / 2 ) ) ) |
---|
1454 | { |
---|
1455 | iPOCmsb = iPrevPOCmsb - iMaxPOClsb; |
---|
1456 | } |
---|
1457 | else |
---|
1458 | { |
---|
1459 | iPOCmsb = iPrevPOCmsb; |
---|
1460 | } |
---|
1461 | if ( rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP |
---|
1462 | || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL |
---|
1463 | || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP ) |
---|
1464 | { |
---|
1465 | // For BLA picture types, POCmsb is set to 0. |
---|
1466 | iPOCmsb = 0; |
---|
1467 | } |
---|
1468 | rpcSlice->setPOC (iPOCmsb+iPOClsb); |
---|
1469 | #if H_MV |
---|
1470 | if ( rpcSlice->getPocResetFlag() ) |
---|
1471 | { |
---|
1472 | rpcSlice->setPocBeforeReset ( rpcSlice->getPOC() ); |
---|
1473 | rpcSlice->setPOC ( 0 ); |
---|
1474 | |
---|
1475 | } |
---|
1476 | #endif |
---|
1477 | TComReferencePictureSet* rps; |
---|
1478 | rps = rpcSlice->getLocalRPS(); |
---|
1479 | rpcSlice->setRPS(rps); |
---|
1480 | READ_FLAG( uiCode, "short_term_ref_pic_set_sps_flag" ); |
---|
1481 | if(uiCode == 0) // use short-term reference picture set explicitly signalled in slice header |
---|
1482 | { |
---|
1483 | parseShortTermRefPicSet(sps,rps, sps->getRPSList()->getNumberOfReferencePictureSets()); |
---|
1484 | } |
---|
1485 | else // use reference to short-term reference picture set in PPS |
---|
1486 | { |
---|
1487 | Int numBits = 0; |
---|
1488 | while ((1 << numBits) < rpcSlice->getSPS()->getRPSList()->getNumberOfReferencePictureSets()) |
---|
1489 | { |
---|
1490 | numBits++; |
---|
1491 | } |
---|
1492 | if (numBits > 0) |
---|
1493 | { |
---|
1494 | READ_CODE( numBits, uiCode, "short_term_ref_pic_set_idx"); |
---|
1495 | } |
---|
1496 | else |
---|
1497 | { |
---|
1498 | uiCode = 0; |
---|
1499 | } |
---|
1500 | *rps = *(sps->getRPSList()->getReferencePictureSet(uiCode)); |
---|
1501 | } |
---|
1502 | if(sps->getLongTermRefsPresent()) |
---|
1503 | { |
---|
1504 | Int offset = rps->getNumberOfNegativePictures()+rps->getNumberOfPositivePictures(); |
---|
1505 | UInt numOfLtrp = 0; |
---|
1506 | UInt numLtrpInSPS = 0; |
---|
1507 | if (rpcSlice->getSPS()->getNumLongTermRefPicSPS() > 0) |
---|
1508 | { |
---|
1509 | READ_UVLC( uiCode, "num_long_term_sps"); |
---|
1510 | numLtrpInSPS = uiCode; |
---|
1511 | numOfLtrp += numLtrpInSPS; |
---|
1512 | rps->setNumberOfLongtermPictures(numOfLtrp); |
---|
1513 | } |
---|
1514 | Int bitsForLtrpInSPS = 0; |
---|
1515 | while (rpcSlice->getSPS()->getNumLongTermRefPicSPS() > (1 << bitsForLtrpInSPS)) |
---|
1516 | { |
---|
1517 | bitsForLtrpInSPS++; |
---|
1518 | } |
---|
1519 | READ_UVLC( uiCode, "num_long_term_pics"); rps->setNumberOfLongtermPictures(uiCode); |
---|
1520 | numOfLtrp += uiCode; |
---|
1521 | rps->setNumberOfLongtermPictures(numOfLtrp); |
---|
1522 | Int maxPicOrderCntLSB = 1 << rpcSlice->getSPS()->getBitsForPOC(); |
---|
1523 | Int prevDeltaMSB = 0, deltaPocMSBCycleLT = 0;; |
---|
1524 | for(Int j=offset+rps->getNumberOfLongtermPictures()-1, k = 0; k < numOfLtrp; j--, k++) |
---|
1525 | { |
---|
1526 | Int pocLsbLt; |
---|
1527 | if (k < numLtrpInSPS) |
---|
1528 | { |
---|
1529 | uiCode = 0; |
---|
1530 | if (bitsForLtrpInSPS > 0) |
---|
1531 | { |
---|
1532 | READ_CODE(bitsForLtrpInSPS, uiCode, "lt_idx_sps[i]"); |
---|
1533 | } |
---|
1534 | Int usedByCurrFromSPS=rpcSlice->getSPS()->getUsedByCurrPicLtSPSFlag(uiCode); |
---|
1535 | |
---|
1536 | pocLsbLt = rpcSlice->getSPS()->getLtRefPicPocLsbSps(uiCode); |
---|
1537 | rps->setUsed(j,usedByCurrFromSPS); |
---|
1538 | } |
---|
1539 | else |
---|
1540 | { |
---|
1541 | READ_CODE(rpcSlice->getSPS()->getBitsForPOC(), uiCode, "poc_lsb_lt"); pocLsbLt= uiCode; |
---|
1542 | READ_FLAG( uiCode, "used_by_curr_pic_lt_flag"); rps->setUsed(j,uiCode); |
---|
1543 | } |
---|
1544 | READ_FLAG(uiCode,"delta_poc_msb_present_flag"); |
---|
1545 | Bool mSBPresentFlag = uiCode ? true : false; |
---|
1546 | if(mSBPresentFlag) |
---|
1547 | { |
---|
1548 | READ_UVLC( uiCode, "delta_poc_msb_cycle_lt[i]" ); |
---|
1549 | Bool deltaFlag = false; |
---|
1550 | // First LTRP || First LTRP from SH |
---|
1551 | if( (j == offset+rps->getNumberOfLongtermPictures()-1) || (j == offset+(numOfLtrp-numLtrpInSPS)-1) ) |
---|
1552 | { |
---|
1553 | deltaFlag = true; |
---|
1554 | } |
---|
1555 | if(deltaFlag) |
---|
1556 | { |
---|
1557 | deltaPocMSBCycleLT = uiCode; |
---|
1558 | } |
---|
1559 | else |
---|
1560 | { |
---|
1561 | deltaPocMSBCycleLT = uiCode + prevDeltaMSB; |
---|
1562 | } |
---|
1563 | |
---|
1564 | Int pocLTCurr = rpcSlice->getPOC() - deltaPocMSBCycleLT * maxPicOrderCntLSB |
---|
1565 | - iPOClsb + pocLsbLt; |
---|
1566 | rps->setPOC (j, pocLTCurr); |
---|
1567 | rps->setDeltaPOC(j, - rpcSlice->getPOC() + pocLTCurr); |
---|
1568 | rps->setCheckLTMSBPresent(j,true); |
---|
1569 | } |
---|
1570 | else |
---|
1571 | { |
---|
1572 | rps->setPOC (j, pocLsbLt); |
---|
1573 | rps->setDeltaPOC(j, - rpcSlice->getPOC() + pocLsbLt); |
---|
1574 | rps->setCheckLTMSBPresent(j,false); |
---|
1575 | |
---|
1576 | // reset deltaPocMSBCycleLT for first LTRP from slice header if MSB not present |
---|
1577 | if( j == offset+(numOfLtrp-numLtrpInSPS)-1 ) |
---|
1578 | { |
---|
1579 | deltaPocMSBCycleLT = 0; |
---|
1580 | } |
---|
1581 | } |
---|
1582 | prevDeltaMSB = deltaPocMSBCycleLT; |
---|
1583 | } |
---|
1584 | offset += rps->getNumberOfLongtermPictures(); |
---|
1585 | rps->setNumberOfPictures(offset); |
---|
1586 | } |
---|
1587 | if ( rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP |
---|
1588 | || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL |
---|
1589 | || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP ) |
---|
1590 | { |
---|
1591 | // In the case of BLA picture types, rps data is read from slice header but ignored |
---|
1592 | rps = rpcSlice->getLocalRPS(); |
---|
1593 | rps->setNumberOfNegativePictures(0); |
---|
1594 | rps->setNumberOfPositivePictures(0); |
---|
1595 | rps->setNumberOfLongtermPictures(0); |
---|
1596 | rps->setNumberOfPictures(0); |
---|
1597 | rpcSlice->setRPS(rps); |
---|
1598 | } |
---|
1599 | if (rpcSlice->getSPS()->getTMVPFlagsPresent()) |
---|
1600 | { |
---|
1601 | READ_FLAG( uiCode, "slice_temporal_mvp_enable_flag" ); |
---|
1602 | rpcSlice->setEnableTMVPFlag( uiCode == 1 ? true : false ); |
---|
1603 | } |
---|
1604 | else |
---|
1605 | { |
---|
1606 | rpcSlice->setEnableTMVPFlag(false); |
---|
1607 | } |
---|
1608 | } |
---|
1609 | #if H_MV |
---|
1610 | Int layerId = rpcSlice->getLayerId(); |
---|
1611 | if( rpcSlice->getLayerId() > 0 && !vps->getAllRefLayersActiveFlag() && vps->getNumDirectRefLayers( layerId ) > 0 ) { |
---|
1612 | READ_FLAG( uiCode, "inter_layer_pred_enabled_flag" ); rpcSlice->setInterLayerPredEnabledFlag( uiCode == 1 ); |
---|
1613 | if( rpcSlice->getInterLayerPredEnabledFlag() && vps->getNumDirectRefLayers( layerId ) > 1 ) |
---|
1614 | { |
---|
1615 | if( !vps->getMaxOneActiveRefLayerFlag()) |
---|
1616 | { |
---|
1617 | READ_CODE( rpcSlice->getNumInterLayerRefPicsMinus1Len( ), uiCode, "num_inter_layer_ref_pics_minus1" ); rpcSlice->setNumInterLayerRefPicsMinus1( uiCode ); |
---|
1618 | } |
---|
1619 | if ( rpcSlice->getNumActiveRefLayerPics() != vps->getNumDirectRefLayers( layerId ) ) |
---|
1620 | { |
---|
1621 | for( Int idx = 0; idx < rpcSlice->getNumActiveRefLayerPics(); idx++ ) |
---|
1622 | { |
---|
1623 | READ_CODE( rpcSlice->getInterLayerPredLayerIdcLen( ), uiCode, "inter_layer_pred_layer_idc" ); rpcSlice->setInterLayerPredLayerIdc( idx, uiCode ); |
---|
1624 | } |
---|
1625 | } |
---|
1626 | } |
---|
1627 | } |
---|
1628 | #endif |
---|
1629 | if(sps->getUseSAO()) |
---|
1630 | { |
---|
1631 | READ_FLAG(uiCode, "slice_sao_luma_flag"); rpcSlice->setSaoEnabledFlag((Bool)uiCode); |
---|
1632 | READ_FLAG(uiCode, "slice_sao_chroma_flag"); rpcSlice->setSaoEnabledFlagChroma((Bool)uiCode); |
---|
1633 | } |
---|
1634 | |
---|
1635 | if (rpcSlice->getIdrPicFlag()) |
---|
1636 | { |
---|
1637 | rpcSlice->setEnableTMVPFlag(false); |
---|
1638 | } |
---|
1639 | if (!rpcSlice->isIntra()) |
---|
1640 | { |
---|
1641 | |
---|
1642 | READ_FLAG( uiCode, "num_ref_idx_active_override_flag"); |
---|
1643 | if (uiCode) |
---|
1644 | { |
---|
1645 | READ_UVLC (uiCode, "num_ref_idx_l0_active_minus1" ); rpcSlice->setNumRefIdx( REF_PIC_LIST_0, uiCode + 1 ); |
---|
1646 | if (rpcSlice->isInterB()) |
---|
1647 | { |
---|
1648 | READ_UVLC (uiCode, "num_ref_idx_l1_active_minus1" ); rpcSlice->setNumRefIdx( REF_PIC_LIST_1, uiCode + 1 ); |
---|
1649 | } |
---|
1650 | else |
---|
1651 | { |
---|
1652 | rpcSlice->setNumRefIdx(REF_PIC_LIST_1, 0); |
---|
1653 | } |
---|
1654 | } |
---|
1655 | else |
---|
1656 | { |
---|
1657 | rpcSlice->setNumRefIdx(REF_PIC_LIST_0, rpcSlice->getPPS()->getNumRefIdxL0DefaultActive()); |
---|
1658 | if (rpcSlice->isInterB()) |
---|
1659 | { |
---|
1660 | rpcSlice->setNumRefIdx(REF_PIC_LIST_1, rpcSlice->getPPS()->getNumRefIdxL1DefaultActive()); |
---|
1661 | } |
---|
1662 | else |
---|
1663 | { |
---|
1664 | rpcSlice->setNumRefIdx(REF_PIC_LIST_1,0); |
---|
1665 | } |
---|
1666 | } |
---|
1667 | } |
---|
1668 | // } |
---|
1669 | TComRefPicListModification* refPicListModification = rpcSlice->getRefPicListModification(); |
---|
1670 | if(!rpcSlice->isIntra()) |
---|
1671 | { |
---|
1672 | if( !rpcSlice->getPPS()->getListsModificationPresentFlag() || rpcSlice->getNumRpsCurrTempList() <= 1 ) |
---|
1673 | { |
---|
1674 | refPicListModification->setRefPicListModificationFlagL0( 0 ); |
---|
1675 | } |
---|
1676 | else |
---|
1677 | { |
---|
1678 | READ_FLAG( uiCode, "ref_pic_list_modification_flag_l0" ); refPicListModification->setRefPicListModificationFlagL0( uiCode ? 1 : 0 ); |
---|
1679 | } |
---|
1680 | |
---|
1681 | if(refPicListModification->getRefPicListModificationFlagL0()) |
---|
1682 | { |
---|
1683 | uiCode = 0; |
---|
1684 | Int i = 0; |
---|
1685 | Int numRpsCurrTempList0 = rpcSlice->getNumRpsCurrTempList(); |
---|
1686 | if ( numRpsCurrTempList0 > 1 ) |
---|
1687 | { |
---|
1688 | Int length = 1; |
---|
1689 | numRpsCurrTempList0 --; |
---|
1690 | while ( numRpsCurrTempList0 >>= 1) |
---|
1691 | { |
---|
1692 | length ++; |
---|
1693 | } |
---|
1694 | for (i = 0; i < rpcSlice->getNumRefIdx(REF_PIC_LIST_0); i ++) |
---|
1695 | { |
---|
1696 | READ_CODE( length, uiCode, "list_entry_l0" ); |
---|
1697 | refPicListModification->setRefPicSetIdxL0(i, uiCode ); |
---|
1698 | } |
---|
1699 | } |
---|
1700 | else |
---|
1701 | { |
---|
1702 | for (i = 0; i < rpcSlice->getNumRefIdx(REF_PIC_LIST_0); i ++) |
---|
1703 | { |
---|
1704 | refPicListModification->setRefPicSetIdxL0(i, 0 ); |
---|
1705 | } |
---|
1706 | } |
---|
1707 | } |
---|
1708 | } |
---|
1709 | else |
---|
1710 | { |
---|
1711 | refPicListModification->setRefPicListModificationFlagL0(0); |
---|
1712 | } |
---|
1713 | if(rpcSlice->isInterB()) |
---|
1714 | { |
---|
1715 | if( !rpcSlice->getPPS()->getListsModificationPresentFlag() || rpcSlice->getNumRpsCurrTempList() <= 1 ) |
---|
1716 | { |
---|
1717 | refPicListModification->setRefPicListModificationFlagL1( 0 ); |
---|
1718 | } |
---|
1719 | else |
---|
1720 | { |
---|
1721 | READ_FLAG( uiCode, "ref_pic_list_modification_flag_l1" ); refPicListModification->setRefPicListModificationFlagL1( uiCode ? 1 : 0 ); |
---|
1722 | } |
---|
1723 | if(refPicListModification->getRefPicListModificationFlagL1()) |
---|
1724 | { |
---|
1725 | uiCode = 0; |
---|
1726 | Int i = 0; |
---|
1727 | Int numRpsCurrTempList1 = rpcSlice->getNumRpsCurrTempList(); |
---|
1728 | if ( numRpsCurrTempList1 > 1 ) |
---|
1729 | { |
---|
1730 | Int length = 1; |
---|
1731 | numRpsCurrTempList1 --; |
---|
1732 | while ( numRpsCurrTempList1 >>= 1) |
---|
1733 | { |
---|
1734 | length ++; |
---|
1735 | } |
---|
1736 | for (i = 0; i < rpcSlice->getNumRefIdx(REF_PIC_LIST_1); i ++) |
---|
1737 | { |
---|
1738 | READ_CODE( length, uiCode, "list_entry_l1" ); |
---|
1739 | refPicListModification->setRefPicSetIdxL1(i, uiCode ); |
---|
1740 | } |
---|
1741 | } |
---|
1742 | else |
---|
1743 | { |
---|
1744 | for (i = 0; i < rpcSlice->getNumRefIdx(REF_PIC_LIST_1); i ++) |
---|
1745 | { |
---|
1746 | refPicListModification->setRefPicSetIdxL1(i, 0 ); |
---|
1747 | } |
---|
1748 | } |
---|
1749 | } |
---|
1750 | } |
---|
1751 | else |
---|
1752 | { |
---|
1753 | refPicListModification->setRefPicListModificationFlagL1(0); |
---|
1754 | } |
---|
1755 | if (rpcSlice->isInterB()) |
---|
1756 | { |
---|
1757 | READ_FLAG( uiCode, "mvd_l1_zero_flag" ); rpcSlice->setMvdL1ZeroFlag( (uiCode ? true : false) ); |
---|
1758 | } |
---|
1759 | |
---|
1760 | rpcSlice->setCabacInitFlag( false ); // default |
---|
1761 | if(pps->getCabacInitPresentFlag() && !rpcSlice->isIntra()) |
---|
1762 | { |
---|
1763 | READ_FLAG(uiCode, "cabac_init_flag"); |
---|
1764 | rpcSlice->setCabacInitFlag( uiCode ? true : false ); |
---|
1765 | } |
---|
1766 | |
---|
1767 | if ( rpcSlice->getEnableTMVPFlag() ) |
---|
1768 | { |
---|
1769 | if ( rpcSlice->getSliceType() == B_SLICE ) |
---|
1770 | { |
---|
1771 | READ_FLAG( uiCode, "collocated_from_l0_flag" ); |
---|
1772 | rpcSlice->setColFromL0Flag(uiCode); |
---|
1773 | } |
---|
1774 | else |
---|
1775 | { |
---|
1776 | rpcSlice->setColFromL0Flag( 1 ); |
---|
1777 | } |
---|
1778 | |
---|
1779 | if ( rpcSlice->getSliceType() != I_SLICE && |
---|
1780 | ((rpcSlice->getColFromL0Flag() == 1 && rpcSlice->getNumRefIdx(REF_PIC_LIST_0) > 1)|| |
---|
1781 | (rpcSlice->getColFromL0Flag() == 0 && rpcSlice->getNumRefIdx(REF_PIC_LIST_1) > 1))) |
---|
1782 | { |
---|
1783 | READ_UVLC( uiCode, "collocated_ref_idx" ); |
---|
1784 | rpcSlice->setColRefIdx(uiCode); |
---|
1785 | } |
---|
1786 | else |
---|
1787 | { |
---|
1788 | rpcSlice->setColRefIdx(0); |
---|
1789 | } |
---|
1790 | } |
---|
1791 | if ( (pps->getUseWP() && rpcSlice->getSliceType()==P_SLICE) || (pps->getWPBiPred() && rpcSlice->getSliceType()==B_SLICE) ) |
---|
1792 | { |
---|
1793 | xParsePredWeightTable(rpcSlice); |
---|
1794 | rpcSlice->initWpScaling(); |
---|
1795 | } |
---|
1796 | #if H_3D_IC |
---|
1797 | else if( rpcSlice->getViewIndex() && ( rpcSlice->getSliceType() == P_SLICE || rpcSlice->getSliceType() == B_SLICE ) ) |
---|
1798 | { |
---|
1799 | UInt uiCodeTmp = 0; |
---|
1800 | |
---|
1801 | READ_FLAG ( uiCodeTmp, "slice_ic_enable_flag" ); |
---|
1802 | rpcSlice->setApplyIC( uiCodeTmp ); |
---|
1803 | |
---|
1804 | if ( uiCodeTmp ) |
---|
1805 | { |
---|
1806 | READ_FLAG ( uiCodeTmp, "ic_skip_mergeidx0" ); |
---|
1807 | rpcSlice->setIcSkipParseFlag( uiCodeTmp ); |
---|
1808 | } |
---|
1809 | } |
---|
1810 | #endif |
---|
1811 | if (!rpcSlice->isIntra()) |
---|
1812 | { |
---|
1813 | READ_UVLC( uiCode, "five_minus_max_num_merge_cand"); |
---|
1814 | #if H_3D_IV_MERGE |
---|
1815 | Bool ivMvPredFlag = rpcSlice->getVPS()->getIvMvPredFlag( rpcSlice->getLayerIdInVps() ) ; |
---|
1816 | rpcSlice->setMaxNumMergeCand(( ivMvPredFlag ? MRG_MAX_NUM_CANDS_MEM : MRG_MAX_NUM_CANDS) - uiCode); |
---|
1817 | #else |
---|
1818 | rpcSlice->setMaxNumMergeCand(MRG_MAX_NUM_CANDS - uiCode); |
---|
1819 | #endif |
---|
1820 | } |
---|
1821 | |
---|
1822 | READ_SVLC( iCode, "slice_qp_delta" ); |
---|
1823 | rpcSlice->setSliceQp (26 + pps->getPicInitQPMinus26() + iCode); |
---|
1824 | |
---|
1825 | assert( rpcSlice->getSliceQp() >= -sps->getQpBDOffsetY() ); |
---|
1826 | assert( rpcSlice->getSliceQp() <= 51 ); |
---|
1827 | |
---|
1828 | if (rpcSlice->getPPS()->getSliceChromaQpFlag()) |
---|
1829 | { |
---|
1830 | READ_SVLC( iCode, "slice_qp_delta_cb" ); |
---|
1831 | rpcSlice->setSliceQpDeltaCb( iCode ); |
---|
1832 | assert( rpcSlice->getSliceQpDeltaCb() >= -12 ); |
---|
1833 | assert( rpcSlice->getSliceQpDeltaCb() <= 12 ); |
---|
1834 | assert( (rpcSlice->getPPS()->getChromaCbQpOffset() + rpcSlice->getSliceQpDeltaCb()) >= -12 ); |
---|
1835 | assert( (rpcSlice->getPPS()->getChromaCbQpOffset() + rpcSlice->getSliceQpDeltaCb()) <= 12 ); |
---|
1836 | |
---|
1837 | READ_SVLC( iCode, "slice_qp_delta_cr" ); |
---|
1838 | rpcSlice->setSliceQpDeltaCr( iCode ); |
---|
1839 | assert( rpcSlice->getSliceQpDeltaCr() >= -12 ); |
---|
1840 | assert( rpcSlice->getSliceQpDeltaCr() <= 12 ); |
---|
1841 | assert( (rpcSlice->getPPS()->getChromaCrQpOffset() + rpcSlice->getSliceQpDeltaCr()) >= -12 ); |
---|
1842 | assert( (rpcSlice->getPPS()->getChromaCrQpOffset() + rpcSlice->getSliceQpDeltaCr()) <= 12 ); |
---|
1843 | } |
---|
1844 | |
---|
1845 | if (rpcSlice->getPPS()->getDeblockingFilterControlPresentFlag()) |
---|
1846 | { |
---|
1847 | if(rpcSlice->getPPS()->getDeblockingFilterOverrideEnabledFlag()) |
---|
1848 | { |
---|
1849 | READ_FLAG ( uiCode, "deblocking_filter_override_flag" ); rpcSlice->setDeblockingFilterOverrideFlag(uiCode ? true : false); |
---|
1850 | } |
---|
1851 | else |
---|
1852 | { |
---|
1853 | rpcSlice->setDeblockingFilterOverrideFlag(0); |
---|
1854 | } |
---|
1855 | if(rpcSlice->getDeblockingFilterOverrideFlag()) |
---|
1856 | { |
---|
1857 | READ_FLAG ( uiCode, "slice_disable_deblocking_filter_flag" ); rpcSlice->setDeblockingFilterDisable(uiCode ? 1 : 0); |
---|
1858 | if(!rpcSlice->getDeblockingFilterDisable()) |
---|
1859 | { |
---|
1860 | READ_SVLC( iCode, "slice_beta_offset_div2" ); rpcSlice->setDeblockingFilterBetaOffsetDiv2(iCode); |
---|
1861 | assert(rpcSlice->getDeblockingFilterBetaOffsetDiv2() >= -6 && |
---|
1862 | rpcSlice->getDeblockingFilterBetaOffsetDiv2() <= 6); |
---|
1863 | READ_SVLC( iCode, "slice_tc_offset_div2" ); rpcSlice->setDeblockingFilterTcOffsetDiv2(iCode); |
---|
1864 | assert(rpcSlice->getDeblockingFilterTcOffsetDiv2() >= -6 && |
---|
1865 | rpcSlice->getDeblockingFilterTcOffsetDiv2() <= 6); |
---|
1866 | } |
---|
1867 | } |
---|
1868 | else |
---|
1869 | { |
---|
1870 | rpcSlice->setDeblockingFilterDisable ( rpcSlice->getPPS()->getPicDisableDeblockingFilterFlag() ); |
---|
1871 | rpcSlice->setDeblockingFilterBetaOffsetDiv2( rpcSlice->getPPS()->getDeblockingFilterBetaOffsetDiv2() ); |
---|
1872 | rpcSlice->setDeblockingFilterTcOffsetDiv2 ( rpcSlice->getPPS()->getDeblockingFilterTcOffsetDiv2() ); |
---|
1873 | } |
---|
1874 | } |
---|
1875 | else |
---|
1876 | { |
---|
1877 | rpcSlice->setDeblockingFilterDisable ( false ); |
---|
1878 | rpcSlice->setDeblockingFilterBetaOffsetDiv2( 0 ); |
---|
1879 | rpcSlice->setDeblockingFilterTcOffsetDiv2 ( 0 ); |
---|
1880 | } |
---|
1881 | |
---|
1882 | Bool isSAOEnabled = (!rpcSlice->getSPS()->getUseSAO())?(false):(rpcSlice->getSaoEnabledFlag()||rpcSlice->getSaoEnabledFlagChroma()); |
---|
1883 | Bool isDBFEnabled = (!rpcSlice->getDeblockingFilterDisable()); |
---|
1884 | |
---|
1885 | if(rpcSlice->getPPS()->getLoopFilterAcrossSlicesEnabledFlag() && ( isSAOEnabled || isDBFEnabled )) |
---|
1886 | { |
---|
1887 | READ_FLAG( uiCode, "slice_loop_filter_across_slices_enabled_flag"); |
---|
1888 | } |
---|
1889 | else |
---|
1890 | { |
---|
1891 | uiCode = rpcSlice->getPPS()->getLoopFilterAcrossSlicesEnabledFlag()?1:0; |
---|
1892 | } |
---|
1893 | rpcSlice->setLFCrossSliceBoundaryFlag( (uiCode==1)?true:false); |
---|
1894 | |
---|
1895 | } |
---|
1896 | |
---|
1897 | UInt *entryPointOffset = NULL; |
---|
1898 | UInt numEntryPointOffsets, offsetLenMinus1; |
---|
1899 | if( pps->getTilesEnabledFlag() || pps->getEntropyCodingSyncEnabledFlag() ) |
---|
1900 | { |
---|
1901 | READ_UVLC(numEntryPointOffsets, "num_entry_point_offsets"); rpcSlice->setNumEntryPointOffsets ( numEntryPointOffsets ); |
---|
1902 | if (numEntryPointOffsets>0) |
---|
1903 | { |
---|
1904 | READ_UVLC(offsetLenMinus1, "offset_len_minus1"); |
---|
1905 | } |
---|
1906 | entryPointOffset = new UInt[numEntryPointOffsets]; |
---|
1907 | for (UInt idx=0; idx<numEntryPointOffsets; idx++) |
---|
1908 | { |
---|
1909 | READ_CODE(offsetLenMinus1+1, uiCode, "entry_point_offset_minus1"); |
---|
1910 | entryPointOffset[ idx ] = uiCode + 1; |
---|
1911 | } |
---|
1912 | } |
---|
1913 | else |
---|
1914 | { |
---|
1915 | rpcSlice->setNumEntryPointOffsets ( 0 ); |
---|
1916 | } |
---|
1917 | |
---|
1918 | if(pps->getSliceHeaderExtensionPresentFlag()) |
---|
1919 | { |
---|
1920 | READ_UVLC(uiCode,"slice_header_extension_length"); |
---|
1921 | #if H_3D |
---|
1922 | if( rpcSlice->getSPS()->hasCamParInSliceHeader() ) |
---|
1923 | { |
---|
1924 | UInt uiViewIndex = rpcSlice->getViewIndex(); |
---|
1925 | for( UInt uiBaseIndex = 0; uiBaseIndex < uiViewIndex; uiBaseIndex++ ) |
---|
1926 | { |
---|
1927 | READ_SVLC( iCode, "cp_scale" ); m_aaiTempScale [ uiBaseIndex ][ uiViewIndex ] = iCode; |
---|
1928 | READ_SVLC( iCode, "cp_off" ); m_aaiTempOffset[ uiBaseIndex ][ uiViewIndex ] = iCode; |
---|
1929 | READ_SVLC( iCode, "cp_inv_scale_plus_scale" ); m_aaiTempScale [ uiViewIndex ][ uiBaseIndex ] = iCode - m_aaiTempScale [ uiBaseIndex ][ uiViewIndex ]; |
---|
1930 | READ_SVLC( iCode, "cp_inv_off_plus_off" ); m_aaiTempOffset[ uiViewIndex ][ uiBaseIndex ] = iCode - m_aaiTempOffset[ uiBaseIndex ][ uiViewIndex ]; |
---|
1931 | } |
---|
1932 | rpcSlice->setCamparaSlice( m_aaiTempScale, m_aaiTempOffset ); |
---|
1933 | } |
---|
1934 | |
---|
1935 | READ_FLAG(uiCode,"slice_segment_header_extension2_flag"); |
---|
1936 | if ( uiCode ) |
---|
1937 | { |
---|
1938 | READ_UVLC(uiCode,"slice_header_extension2_length"); |
---|
1939 | for(Int i=0; i<uiCode; i++) |
---|
1940 | { |
---|
1941 | UInt ignore; |
---|
1942 | READ_CODE(8,ignore,"slice_header_extension2_data_byte"); |
---|
1943 | } |
---|
1944 | } |
---|
1945 | } |
---|
1946 | #else |
---|
1947 | for(Int i=0; i<uiCode; i++) |
---|
1948 | { |
---|
1949 | UInt ignore; |
---|
1950 | READ_CODE(8,ignore,"slice_header_extension_data_byte"); |
---|
1951 | } |
---|
1952 | } |
---|
1953 | #endif |
---|
1954 | m_pcBitstream->readByteAlignment(); |
---|
1955 | |
---|
1956 | if( pps->getTilesEnabledFlag() || pps->getEntropyCodingSyncEnabledFlag() ) |
---|
1957 | { |
---|
1958 | Int endOfSliceHeaderLocation = m_pcBitstream->getByteLocation(); |
---|
1959 | |
---|
1960 | // Adjust endOfSliceHeaderLocation to account for emulation prevention bytes in the slice segment header |
---|
1961 | for ( UInt curByteIdx = 0; curByteIdx<m_pcBitstream->numEmulationPreventionBytesRead(); curByteIdx++ ) |
---|
1962 | { |
---|
1963 | if ( m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) < endOfSliceHeaderLocation ) |
---|
1964 | { |
---|
1965 | endOfSliceHeaderLocation++; |
---|
1966 | } |
---|
1967 | } |
---|
1968 | |
---|
1969 | Int curEntryPointOffset = 0; |
---|
1970 | Int prevEntryPointOffset = 0; |
---|
1971 | for (UInt idx=0; idx<numEntryPointOffsets; idx++) |
---|
1972 | { |
---|
1973 | curEntryPointOffset += entryPointOffset[ idx ]; |
---|
1974 | |
---|
1975 | Int emulationPreventionByteCount = 0; |
---|
1976 | for ( UInt curByteIdx = 0; curByteIdx<m_pcBitstream->numEmulationPreventionBytesRead(); curByteIdx++ ) |
---|
1977 | { |
---|
1978 | if ( m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) >= ( prevEntryPointOffset + endOfSliceHeaderLocation ) && |
---|
1979 | m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) < ( curEntryPointOffset + endOfSliceHeaderLocation ) ) |
---|
1980 | { |
---|
1981 | emulationPreventionByteCount++; |
---|
1982 | } |
---|
1983 | } |
---|
1984 | |
---|
1985 | entryPointOffset[ idx ] -= emulationPreventionByteCount; |
---|
1986 | prevEntryPointOffset = curEntryPointOffset; |
---|
1987 | } |
---|
1988 | |
---|
1989 | if ( pps->getTilesEnabledFlag() ) |
---|
1990 | { |
---|
1991 | rpcSlice->setTileLocationCount( numEntryPointOffsets ); |
---|
1992 | |
---|
1993 | UInt prevPos = 0; |
---|
1994 | for (Int idx=0; idx<rpcSlice->getTileLocationCount(); idx++) |
---|
1995 | { |
---|
1996 | rpcSlice->setTileLocation( idx, prevPos + entryPointOffset [ idx ] ); |
---|
1997 | prevPos += entryPointOffset[ idx ]; |
---|
1998 | } |
---|
1999 | } |
---|
2000 | else if ( pps->getEntropyCodingSyncEnabledFlag() ) |
---|
2001 | { |
---|
2002 | Int numSubstreams = rpcSlice->getNumEntryPointOffsets()+1; |
---|
2003 | rpcSlice->allocSubstreamSizes(numSubstreams); |
---|
2004 | UInt *pSubstreamSizes = rpcSlice->getSubstreamSizes(); |
---|
2005 | for (Int idx=0; idx<numSubstreams-1; idx++) |
---|
2006 | { |
---|
2007 | if ( idx < numEntryPointOffsets ) |
---|
2008 | { |
---|
2009 | pSubstreamSizes[ idx ] = ( entryPointOffset[ idx ] << 3 ) ; |
---|
2010 | } |
---|
2011 | else |
---|
2012 | { |
---|
2013 | pSubstreamSizes[ idx ] = 0; |
---|
2014 | } |
---|
2015 | } |
---|
2016 | } |
---|
2017 | |
---|
2018 | if (entryPointOffset) |
---|
2019 | { |
---|
2020 | delete [] entryPointOffset; |
---|
2021 | } |
---|
2022 | } |
---|
2023 | |
---|
2024 | return; |
---|
2025 | } |
---|
2026 | |
---|
2027 | Void TDecCavlc::parsePTL( TComPTL *rpcPTL, Bool profilePresentFlag, Int maxNumSubLayersMinus1 ) |
---|
2028 | { |
---|
2029 | UInt uiCode; |
---|
2030 | if(profilePresentFlag) |
---|
2031 | { |
---|
2032 | parseProfileTier(rpcPTL->getGeneralPTL()); |
---|
2033 | } |
---|
2034 | READ_CODE( 8, uiCode, "general_level_idc" ); rpcPTL->getGeneralPTL()->setLevelIdc(uiCode); |
---|
2035 | |
---|
2036 | for (Int i = 0; i < maxNumSubLayersMinus1; i++) |
---|
2037 | { |
---|
2038 | #if !H_MV |
---|
2039 | if(profilePresentFlag) |
---|
2040 | { |
---|
2041 | #endif |
---|
2042 | READ_FLAG( uiCode, "sub_layer_profile_present_flag[i]" ); rpcPTL->setSubLayerProfilePresentFlag(i, uiCode); |
---|
2043 | #if H_MV |
---|
2044 | rpcPTL->setSubLayerProfilePresentFlag( i, profilePresentFlag && rpcPTL->getSubLayerProfilePresentFlag(i) ); |
---|
2045 | #else |
---|
2046 | } |
---|
2047 | #endif |
---|
2048 | READ_FLAG( uiCode, "sub_layer_level_present_flag[i]" ); rpcPTL->setSubLayerLevelPresentFlag (i, uiCode); |
---|
2049 | } |
---|
2050 | |
---|
2051 | if (maxNumSubLayersMinus1 > 0) |
---|
2052 | { |
---|
2053 | for (Int i = maxNumSubLayersMinus1; i < 8; i++) |
---|
2054 | { |
---|
2055 | READ_CODE(2, uiCode, "reserved_zero_2bits"); |
---|
2056 | assert(uiCode == 0); |
---|
2057 | } |
---|
2058 | } |
---|
2059 | |
---|
2060 | for(Int i = 0; i < maxNumSubLayersMinus1; i++) |
---|
2061 | { |
---|
2062 | if( profilePresentFlag && rpcPTL->getSubLayerProfilePresentFlag(i) ) |
---|
2063 | { |
---|
2064 | parseProfileTier(rpcPTL->getSubLayerPTL(i)); |
---|
2065 | } |
---|
2066 | if(rpcPTL->getSubLayerLevelPresentFlag(i)) |
---|
2067 | { |
---|
2068 | READ_CODE( 8, uiCode, "sub_layer_level_idc[i]" ); rpcPTL->getSubLayerPTL(i)->setLevelIdc(uiCode); |
---|
2069 | } |
---|
2070 | } |
---|
2071 | } |
---|
2072 | |
---|
2073 | Void TDecCavlc::parseProfileTier(ProfileTierLevel *ptl) |
---|
2074 | { |
---|
2075 | UInt uiCode; |
---|
2076 | READ_CODE(2 , uiCode, "XXX_profile_space[]"); ptl->setProfileSpace(uiCode); |
---|
2077 | READ_FLAG( uiCode, "XXX_tier_flag[]" ); ptl->setTierFlag (uiCode ? 1 : 0); |
---|
2078 | READ_CODE(5 , uiCode, "XXX_profile_idc[]" ); ptl->setProfileIdc (uiCode); |
---|
2079 | for(Int j = 0; j < 32; j++) |
---|
2080 | { |
---|
2081 | READ_FLAG( uiCode, "XXX_profile_compatibility_flag[][j]"); ptl->setProfileCompatibilityFlag(j, uiCode ? 1 : 0); |
---|
2082 | } |
---|
2083 | READ_FLAG(uiCode, "general_progressive_source_flag"); |
---|
2084 | ptl->setProgressiveSourceFlag(uiCode ? true : false); |
---|
2085 | |
---|
2086 | READ_FLAG(uiCode, "general_interlaced_source_flag"); |
---|
2087 | ptl->setInterlacedSourceFlag(uiCode ? true : false); |
---|
2088 | |
---|
2089 | READ_FLAG(uiCode, "general_non_packed_constraint_flag"); |
---|
2090 | ptl->setNonPackedConstraintFlag(uiCode ? true : false); |
---|
2091 | |
---|
2092 | READ_FLAG(uiCode, "general_frame_only_constraint_flag"); |
---|
2093 | ptl->setFrameOnlyConstraintFlag(uiCode ? true : false); |
---|
2094 | |
---|
2095 | READ_CODE(16, uiCode, "XXX_reserved_zero_44bits[0..15]"); |
---|
2096 | READ_CODE(16, uiCode, "XXX_reserved_zero_44bits[16..31]"); |
---|
2097 | READ_CODE(12, uiCode, "XXX_reserved_zero_44bits[32..43]"); |
---|
2098 | } |
---|
2099 | |
---|
2100 | Void TDecCavlc::parseTerminatingBit( UInt& ruiBit ) |
---|
2101 | { |
---|
2102 | ruiBit = false; |
---|
2103 | Int iBitsLeft = m_pcBitstream->getNumBitsLeft(); |
---|
2104 | if(iBitsLeft <= 8) |
---|
2105 | { |
---|
2106 | UInt uiPeekValue = m_pcBitstream->peekBits(iBitsLeft); |
---|
2107 | if (uiPeekValue == (1<<(iBitsLeft-1))) |
---|
2108 | { |
---|
2109 | ruiBit = true; |
---|
2110 | } |
---|
2111 | } |
---|
2112 | } |
---|
2113 | |
---|
2114 | Void TDecCavlc::parseSkipFlag( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
2115 | { |
---|
2116 | assert(0); |
---|
2117 | } |
---|
2118 | |
---|
2119 | Void TDecCavlc::parseCUTransquantBypassFlag( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
2120 | { |
---|
2121 | assert(0); |
---|
2122 | } |
---|
2123 | |
---|
2124 | Void TDecCavlc::parseMVPIdx( Int& /*riMVPIdx*/ ) |
---|
2125 | { |
---|
2126 | assert(0); |
---|
2127 | } |
---|
2128 | |
---|
2129 | Void TDecCavlc::parseSplitFlag ( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
2130 | { |
---|
2131 | assert(0); |
---|
2132 | } |
---|
2133 | |
---|
2134 | Void TDecCavlc::parsePartSize( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
2135 | { |
---|
2136 | assert(0); |
---|
2137 | } |
---|
2138 | |
---|
2139 | Void TDecCavlc::parsePredMode( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
2140 | { |
---|
2141 | assert(0); |
---|
2142 | } |
---|
2143 | |
---|
2144 | /** Parse I_PCM information. |
---|
2145 | * \param pcCU pointer to CU |
---|
2146 | * \param uiAbsPartIdx CU index |
---|
2147 | * \param uiDepth CU depth |
---|
2148 | * \returns Void |
---|
2149 | * |
---|
2150 | * If I_PCM flag indicates that the CU is I_PCM, parse its PCM alignment bits and codes. |
---|
2151 | */ |
---|
2152 | Void TDecCavlc::parseIPCMInfo( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
2153 | { |
---|
2154 | assert(0); |
---|
2155 | } |
---|
2156 | |
---|
2157 | Void TDecCavlc::parseIntraDirLumaAng ( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
2158 | { |
---|
2159 | assert(0); |
---|
2160 | } |
---|
2161 | |
---|
2162 | Void TDecCavlc::parseIntraDirChroma( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
2163 | { |
---|
2164 | assert(0); |
---|
2165 | } |
---|
2166 | |
---|
2167 | Void TDecCavlc::parseInterDir( TComDataCU* /*pcCU*/, UInt& /*ruiInterDir*/, UInt /*uiAbsPartIdx*/ ) |
---|
2168 | { |
---|
2169 | assert(0); |
---|
2170 | } |
---|
2171 | |
---|
2172 | Void TDecCavlc::parseRefFrmIdx( TComDataCU* /*pcCU*/, Int& /*riRefFrmIdx*/, RefPicList /*eRefList*/ ) |
---|
2173 | { |
---|
2174 | assert(0); |
---|
2175 | } |
---|
2176 | |
---|
2177 | Void TDecCavlc::parseMvd( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiPartIdx*/, UInt /*uiDepth*/, RefPicList /*eRefList*/ ) |
---|
2178 | { |
---|
2179 | assert(0); |
---|
2180 | } |
---|
2181 | |
---|
2182 | Void TDecCavlc::parseDeltaQP( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2183 | { |
---|
2184 | Int qp; |
---|
2185 | Int iDQp; |
---|
2186 | |
---|
2187 | xReadSvlc( iDQp ); |
---|
2188 | |
---|
2189 | Int qpBdOffsetY = pcCU->getSlice()->getSPS()->getQpBDOffsetY(); |
---|
2190 | qp = (((Int) pcCU->getRefQP( uiAbsPartIdx ) + iDQp + 52 + 2*qpBdOffsetY )%(52+ qpBdOffsetY)) - qpBdOffsetY; |
---|
2191 | |
---|
2192 | UInt uiAbsQpCUPartIdx = (uiAbsPartIdx>>((g_uiMaxCUDepth - pcCU->getSlice()->getPPS()->getMaxCuDQPDepth())<<1))<<((g_uiMaxCUDepth - pcCU->getSlice()->getPPS()->getMaxCuDQPDepth())<<1) ; |
---|
2193 | UInt uiQpCUDepth = min(uiDepth,pcCU->getSlice()->getPPS()->getMaxCuDQPDepth()) ; |
---|
2194 | |
---|
2195 | pcCU->setQPSubParts( qp, uiAbsQpCUPartIdx, uiQpCUDepth ); |
---|
2196 | } |
---|
2197 | |
---|
2198 | Void TDecCavlc::parseCoeffNxN( TComDataCU* /*pcCU*/, TCoeff* /*pcCoef*/, UInt /*uiAbsPartIdx*/, UInt /*uiWidth*/, UInt /*uiHeight*/, UInt /*uiDepth*/, TextType /*eTType*/ ) |
---|
2199 | { |
---|
2200 | assert(0); |
---|
2201 | } |
---|
2202 | |
---|
2203 | Void TDecCavlc::parseTransformSubdivFlag( UInt& /*ruiSubdivFlag*/, UInt /*uiLog2TransformBlockSize*/ ) |
---|
2204 | { |
---|
2205 | assert(0); |
---|
2206 | } |
---|
2207 | |
---|
2208 | Void TDecCavlc::parseQtCbf( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, TextType /*eType*/, UInt /*uiTrDepth*/, UInt /*uiDepth*/ ) |
---|
2209 | { |
---|
2210 | assert(0); |
---|
2211 | } |
---|
2212 | |
---|
2213 | Void TDecCavlc::parseQtRootCbf( UInt /*uiAbsPartIdx*/, UInt& /*uiQtRootCbf*/ ) |
---|
2214 | { |
---|
2215 | assert(0); |
---|
2216 | } |
---|
2217 | |
---|
2218 | Void TDecCavlc::parseTransformSkipFlags (TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*width*/, UInt /*height*/, UInt /*uiDepth*/, TextType /*eTType*/) |
---|
2219 | { |
---|
2220 | assert(0); |
---|
2221 | } |
---|
2222 | |
---|
2223 | Void TDecCavlc::parseMergeFlag ( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/, UInt /*uiPUIdx*/ ) |
---|
2224 | { |
---|
2225 | assert(0); |
---|
2226 | } |
---|
2227 | |
---|
2228 | Void TDecCavlc::parseMergeIndex ( TComDataCU* /*pcCU*/, UInt& /*ruiMergeIndex*/ ) |
---|
2229 | { |
---|
2230 | assert(0); |
---|
2231 | } |
---|
2232 | |
---|
2233 | #if H_3D_ARP |
---|
2234 | Void TDecCavlc::parseARPW( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2235 | { |
---|
2236 | assert(0); |
---|
2237 | } |
---|
2238 | #endif |
---|
2239 | #if H_3D_IC |
---|
2240 | Void TDecCavlc::parseICFlag( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2241 | { |
---|
2242 | assert(0); |
---|
2243 | } |
---|
2244 | #endif |
---|
2245 | #if H_3D_INTER_SDC |
---|
2246 | Void TDecCavlc::parseInterSDCFlag ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2247 | { |
---|
2248 | assert(0); |
---|
2249 | } |
---|
2250 | |
---|
2251 | Void TDecCavlc::parseInterSDCResidualData ( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth, UInt uiPart ) |
---|
2252 | { |
---|
2253 | assert(0); |
---|
2254 | } |
---|
2255 | #endif |
---|
2256 | // ==================================================================================================================== |
---|
2257 | // Protected member functions |
---|
2258 | // ==================================================================================================================== |
---|
2259 | |
---|
2260 | /** parse explicit wp tables |
---|
2261 | * \param TComSlice* pcSlice |
---|
2262 | * \returns Void |
---|
2263 | */ |
---|
2264 | Void TDecCavlc::xParsePredWeightTable( TComSlice* pcSlice ) |
---|
2265 | { |
---|
2266 | wpScalingParam *wp; |
---|
2267 | Bool bChroma = true; // color always present in HEVC ? |
---|
2268 | SliceType eSliceType = pcSlice->getSliceType(); |
---|
2269 | Int iNbRef = (eSliceType == B_SLICE ) ? (2) : (1); |
---|
2270 | UInt uiLog2WeightDenomLuma, uiLog2WeightDenomChroma; |
---|
2271 | UInt uiTotalSignalledWeightFlags = 0; |
---|
2272 | |
---|
2273 | Int iDeltaDenom; |
---|
2274 | // decode delta_luma_log2_weight_denom : |
---|
2275 | READ_UVLC( uiLog2WeightDenomLuma, "luma_log2_weight_denom" ); // ue(v): luma_log2_weight_denom |
---|
2276 | assert( uiLog2WeightDenomLuma <= 7 ); |
---|
2277 | if( bChroma ) |
---|
2278 | { |
---|
2279 | READ_SVLC( iDeltaDenom, "delta_chroma_log2_weight_denom" ); // se(v): delta_chroma_log2_weight_denom |
---|
2280 | assert((iDeltaDenom + (Int)uiLog2WeightDenomLuma)>=0); |
---|
2281 | assert((iDeltaDenom + (Int)uiLog2WeightDenomLuma)<=7); |
---|
2282 | uiLog2WeightDenomChroma = (UInt)(iDeltaDenom + uiLog2WeightDenomLuma); |
---|
2283 | } |
---|
2284 | |
---|
2285 | for ( Int iNumRef=0 ; iNumRef<iNbRef ; iNumRef++ ) |
---|
2286 | { |
---|
2287 | RefPicList eRefPicList = ( iNumRef ? REF_PIC_LIST_1 : REF_PIC_LIST_0 ); |
---|
2288 | for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ ) |
---|
2289 | { |
---|
2290 | pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); |
---|
2291 | |
---|
2292 | wp[0].uiLog2WeightDenom = uiLog2WeightDenomLuma; |
---|
2293 | wp[1].uiLog2WeightDenom = uiLog2WeightDenomChroma; |
---|
2294 | wp[2].uiLog2WeightDenom = uiLog2WeightDenomChroma; |
---|
2295 | |
---|
2296 | UInt uiCode; |
---|
2297 | READ_FLAG( uiCode, "luma_weight_lX_flag" ); // u(1): luma_weight_l0_flag |
---|
2298 | wp[0].bPresentFlag = ( uiCode == 1 ); |
---|
2299 | uiTotalSignalledWeightFlags += wp[0].bPresentFlag; |
---|
2300 | } |
---|
2301 | if ( bChroma ) |
---|
2302 | { |
---|
2303 | UInt uiCode; |
---|
2304 | for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ ) |
---|
2305 | { |
---|
2306 | pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); |
---|
2307 | READ_FLAG( uiCode, "chroma_weight_lX_flag" ); // u(1): chroma_weight_l0_flag |
---|
2308 | wp[1].bPresentFlag = ( uiCode == 1 ); |
---|
2309 | wp[2].bPresentFlag = ( uiCode == 1 ); |
---|
2310 | uiTotalSignalledWeightFlags += 2*wp[1].bPresentFlag; |
---|
2311 | } |
---|
2312 | } |
---|
2313 | for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ ) |
---|
2314 | { |
---|
2315 | pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); |
---|
2316 | if ( wp[0].bPresentFlag ) |
---|
2317 | { |
---|
2318 | Int iDeltaWeight; |
---|
2319 | READ_SVLC( iDeltaWeight, "delta_luma_weight_lX" ); // se(v): delta_luma_weight_l0[i] |
---|
2320 | assert( iDeltaWeight >= -128 ); |
---|
2321 | assert( iDeltaWeight <= 127 ); |
---|
2322 | wp[0].iWeight = (iDeltaWeight + (1<<wp[0].uiLog2WeightDenom)); |
---|
2323 | READ_SVLC( wp[0].iOffset, "luma_offset_lX" ); // se(v): luma_offset_l0[i] |
---|
2324 | assert( wp[0].iOffset >= -128 ); |
---|
2325 | assert( wp[0].iOffset <= 127 ); |
---|
2326 | } |
---|
2327 | else |
---|
2328 | { |
---|
2329 | wp[0].iWeight = (1 << wp[0].uiLog2WeightDenom); |
---|
2330 | wp[0].iOffset = 0; |
---|
2331 | } |
---|
2332 | if ( bChroma ) |
---|
2333 | { |
---|
2334 | if ( wp[1].bPresentFlag ) |
---|
2335 | { |
---|
2336 | for ( Int j=1 ; j<3 ; j++ ) |
---|
2337 | { |
---|
2338 | Int iDeltaWeight; |
---|
2339 | READ_SVLC( iDeltaWeight, "delta_chroma_weight_lX" ); // se(v): chroma_weight_l0[i][j] |
---|
2340 | assert( iDeltaWeight >= -128 ); |
---|
2341 | assert( iDeltaWeight <= 127 ); |
---|
2342 | wp[j].iWeight = (iDeltaWeight + (1<<wp[1].uiLog2WeightDenom)); |
---|
2343 | |
---|
2344 | Int iDeltaChroma; |
---|
2345 | READ_SVLC( iDeltaChroma, "delta_chroma_offset_lX" ); // se(v): delta_chroma_offset_l0[i][j] |
---|
2346 | assert( iDeltaChroma >= -512 ); |
---|
2347 | assert( iDeltaChroma <= 511 ); |
---|
2348 | Int pred = ( 128 - ( ( 128*wp[j].iWeight)>>(wp[j].uiLog2WeightDenom) ) ); |
---|
2349 | wp[j].iOffset = Clip3(-128, 127, (iDeltaChroma + pred) ); |
---|
2350 | } |
---|
2351 | } |
---|
2352 | else |
---|
2353 | { |
---|
2354 | for ( Int j=1 ; j<3 ; j++ ) |
---|
2355 | { |
---|
2356 | wp[j].iWeight = (1 << wp[j].uiLog2WeightDenom); |
---|
2357 | wp[j].iOffset = 0; |
---|
2358 | } |
---|
2359 | } |
---|
2360 | } |
---|
2361 | } |
---|
2362 | |
---|
2363 | for ( Int iRefIdx=pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx<MAX_NUM_REF ; iRefIdx++ ) |
---|
2364 | { |
---|
2365 | pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); |
---|
2366 | |
---|
2367 | wp[0].bPresentFlag = false; |
---|
2368 | wp[1].bPresentFlag = false; |
---|
2369 | wp[2].bPresentFlag = false; |
---|
2370 | } |
---|
2371 | } |
---|
2372 | assert(uiTotalSignalledWeightFlags<=24); |
---|
2373 | } |
---|
2374 | |
---|
2375 | /** decode quantization matrix |
---|
2376 | * \param scalingList quantization matrix information |
---|
2377 | */ |
---|
2378 | Void TDecCavlc::parseScalingList(TComScalingList* scalingList) |
---|
2379 | { |
---|
2380 | UInt code, sizeId, listId; |
---|
2381 | Bool scalingListPredModeFlag; |
---|
2382 | //for each size |
---|
2383 | for(sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
2384 | { |
---|
2385 | for(listId = 0; listId < g_scalingListNum[sizeId]; listId++) |
---|
2386 | { |
---|
2387 | READ_FLAG( code, "scaling_list_pred_mode_flag"); |
---|
2388 | scalingListPredModeFlag = (code) ? true : false; |
---|
2389 | if(!scalingListPredModeFlag) //Copy Mode |
---|
2390 | { |
---|
2391 | READ_UVLC( code, "scaling_list_pred_matrix_id_delta"); |
---|
2392 | scalingList->setRefMatrixId (sizeId,listId,(UInt)((Int)(listId)-(code))); |
---|
2393 | if( sizeId > SCALING_LIST_8x8 ) |
---|
2394 | { |
---|
2395 | scalingList->setScalingListDC(sizeId,listId,((listId == scalingList->getRefMatrixId (sizeId,listId))? 16 :scalingList->getScalingListDC(sizeId, scalingList->getRefMatrixId (sizeId,listId)))); |
---|
2396 | } |
---|
2397 | scalingList->processRefMatrix( sizeId, listId, scalingList->getRefMatrixId (sizeId,listId)); |
---|
2398 | |
---|
2399 | } |
---|
2400 | else //DPCM Mode |
---|
2401 | { |
---|
2402 | xDecodeScalingList(scalingList, sizeId, listId); |
---|
2403 | } |
---|
2404 | } |
---|
2405 | } |
---|
2406 | |
---|
2407 | return; |
---|
2408 | } |
---|
2409 | /** decode DPCM |
---|
2410 | * \param scalingList quantization matrix information |
---|
2411 | * \param sizeId size index |
---|
2412 | * \param listId list index |
---|
2413 | */ |
---|
2414 | Void TDecCavlc::xDecodeScalingList(TComScalingList *scalingList, UInt sizeId, UInt listId) |
---|
2415 | { |
---|
2416 | Int i,coefNum = min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId]); |
---|
2417 | Int data; |
---|
2418 | Int scalingListDcCoefMinus8 = 0; |
---|
2419 | Int nextCoef = SCALING_LIST_START_VALUE; |
---|
2420 | UInt* scan = (sizeId == 0) ? g_auiSigLastScan [ SCAN_DIAG ] [ 1 ] : g_sigLastScanCG32x32; |
---|
2421 | Int *dst = scalingList->getScalingListAddress(sizeId, listId); |
---|
2422 | |
---|
2423 | if( sizeId > SCALING_LIST_8x8 ) |
---|
2424 | { |
---|
2425 | READ_SVLC( scalingListDcCoefMinus8, "scaling_list_dc_coef_minus8"); |
---|
2426 | scalingList->setScalingListDC(sizeId,listId,scalingListDcCoefMinus8 + 8); |
---|
2427 | nextCoef = scalingList->getScalingListDC(sizeId,listId); |
---|
2428 | } |
---|
2429 | |
---|
2430 | for(i = 0; i < coefNum; i++) |
---|
2431 | { |
---|
2432 | READ_SVLC( data, "scaling_list_delta_coef"); |
---|
2433 | nextCoef = (nextCoef + data + 256 ) % 256; |
---|
2434 | dst[scan[i]] = nextCoef; |
---|
2435 | } |
---|
2436 | } |
---|
2437 | |
---|
2438 | Bool TDecCavlc::xMoreRbspData() |
---|
2439 | { |
---|
2440 | Int bitsLeft = m_pcBitstream->getNumBitsLeft(); |
---|
2441 | |
---|
2442 | // if there are more than 8 bits, it cannot be rbsp_trailing_bits |
---|
2443 | if (bitsLeft > 8) |
---|
2444 | { |
---|
2445 | return true; |
---|
2446 | } |
---|
2447 | |
---|
2448 | UChar lastByte = m_pcBitstream->peekBits(bitsLeft); |
---|
2449 | Int cnt = bitsLeft; |
---|
2450 | |
---|
2451 | // remove trailing bits equal to zero |
---|
2452 | while ((cnt>0) && ((lastByte & 1) == 0)) |
---|
2453 | { |
---|
2454 | lastByte >>= 1; |
---|
2455 | cnt--; |
---|
2456 | } |
---|
2457 | // remove bit equal to one |
---|
2458 | cnt--; |
---|
2459 | |
---|
2460 | // we should not have a negative number of bits |
---|
2461 | assert (cnt>=0); |
---|
2462 | |
---|
2463 | // we have more data, if cnt is not zero |
---|
2464 | return (cnt>0); |
---|
2465 | } |
---|
2466 | |
---|
2467 | //! \} |
---|
2468 | |
---|