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