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 | #ifdef SPS_PTL_FIX |
---|
528 | if ( pcSPS->getLayerId() == 0) |
---|
529 | { |
---|
530 | parsePTL(pcSPS->getPTL(), 1, pcSPS->getMaxTLayers() - 1); |
---|
531 | } |
---|
532 | #else |
---|
533 | parsePTL(pcSPS->getPTL(), 1, pcSPS->getMaxTLayers() - 1); |
---|
534 | #endif |
---|
535 | |
---|
536 | READ_UVLC( uiCode, "sps_seq_parameter_set_id" ); pcSPS->setSPSId( uiCode ); |
---|
537 | assert(uiCode <= 15); |
---|
538 | |
---|
539 | READ_UVLC( uiCode, "chroma_format_idc" ); pcSPS->setChromaFormatIdc( uiCode ); |
---|
540 | assert(uiCode <= 3); |
---|
541 | // 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 |
---|
542 | assert (uiCode == 1); |
---|
543 | if( uiCode == 3 ) |
---|
544 | { |
---|
545 | READ_FLAG( uiCode, "separate_colour_plane_flag"); assert(uiCode == 0); |
---|
546 | } |
---|
547 | |
---|
548 | READ_UVLC ( uiCode, "pic_width_in_luma_samples" ); pcSPS->setPicWidthInLumaSamples ( uiCode ); |
---|
549 | READ_UVLC ( uiCode, "pic_height_in_luma_samples" ); pcSPS->setPicHeightInLumaSamples( uiCode ); |
---|
550 | READ_FLAG( uiCode, "conformance_window_flag"); |
---|
551 | if (uiCode != 0) |
---|
552 | { |
---|
553 | Window &conf = pcSPS->getConformanceWindow(); |
---|
554 | READ_UVLC( uiCode, "conf_win_left_offset" ); conf.setWindowLeftOffset ( uiCode * TComSPS::getWinUnitX( pcSPS->getChromaFormatIdc() ) ); |
---|
555 | READ_UVLC( uiCode, "conf_win_right_offset" ); conf.setWindowRightOffset ( uiCode * TComSPS::getWinUnitX( pcSPS->getChromaFormatIdc() ) ); |
---|
556 | READ_UVLC( uiCode, "conf_win_top_offset" ); conf.setWindowTopOffset ( uiCode * TComSPS::getWinUnitY( pcSPS->getChromaFormatIdc() ) ); |
---|
557 | READ_UVLC( uiCode, "conf_win_bottom_offset" ); conf.setWindowBottomOffset( uiCode * TComSPS::getWinUnitY( pcSPS->getChromaFormatIdc() ) ); |
---|
558 | } |
---|
559 | |
---|
560 | READ_UVLC( uiCode, "bit_depth_luma_minus8" ); |
---|
561 | assert(uiCode <= 6); |
---|
562 | pcSPS->setBitDepthY( uiCode + 8 ); |
---|
563 | pcSPS->setQpBDOffsetY( (Int) (6*uiCode) ); |
---|
564 | |
---|
565 | READ_UVLC( uiCode, "bit_depth_chroma_minus8" ); |
---|
566 | assert(uiCode <= 6); |
---|
567 | pcSPS->setBitDepthC( uiCode + 8 ); |
---|
568 | pcSPS->setQpBDOffsetC( (Int) (6*uiCode) ); |
---|
569 | |
---|
570 | READ_UVLC( uiCode, "log2_max_pic_order_cnt_lsb_minus4" ); pcSPS->setBitsForPOC( 4 + uiCode ); |
---|
571 | assert(uiCode <= 12); |
---|
572 | |
---|
573 | UInt subLayerOrderingInfoPresentFlag; |
---|
574 | READ_FLAG(subLayerOrderingInfoPresentFlag, "sps_sub_layer_ordering_info_present_flag"); |
---|
575 | |
---|
576 | for(UInt i=0; i <= pcSPS->getMaxTLayers()-1; i++) |
---|
577 | { |
---|
578 | READ_UVLC ( uiCode, "sps_max_dec_pic_buffering_minus1"); |
---|
579 | pcSPS->setMaxDecPicBuffering( uiCode + 1, i); |
---|
580 | READ_UVLC ( uiCode, "sps_num_reorder_pics" ); |
---|
581 | pcSPS->setNumReorderPics(uiCode, i); |
---|
582 | READ_UVLC ( uiCode, "sps_max_latency_increase_plus1"); |
---|
583 | pcSPS->setMaxLatencyIncrease( uiCode, i ); |
---|
584 | |
---|
585 | if (!subLayerOrderingInfoPresentFlag) |
---|
586 | { |
---|
587 | for (i++; i <= pcSPS->getMaxTLayers()-1; i++) |
---|
588 | { |
---|
589 | pcSPS->setMaxDecPicBuffering(pcSPS->getMaxDecPicBuffering(0), i); |
---|
590 | pcSPS->setNumReorderPics(pcSPS->getNumReorderPics(0), i); |
---|
591 | pcSPS->setMaxLatencyIncrease(pcSPS->getMaxLatencyIncrease(0), i); |
---|
592 | } |
---|
593 | break; |
---|
594 | } |
---|
595 | } |
---|
596 | |
---|
597 | READ_UVLC( uiCode, "log2_min_coding_block_size_minus3" ); |
---|
598 | Int log2MinCUSize = uiCode + 3; |
---|
599 | pcSPS->setLog2MinCodingBlockSize(log2MinCUSize); |
---|
600 | READ_UVLC( uiCode, "log2_diff_max_min_coding_block_size" ); |
---|
601 | pcSPS->setLog2DiffMaxMinCodingBlockSize(uiCode); |
---|
602 | Int maxCUDepthDelta = uiCode; |
---|
603 | pcSPS->setMaxCUWidth ( 1<<(log2MinCUSize + maxCUDepthDelta) ); |
---|
604 | pcSPS->setMaxCUHeight ( 1<<(log2MinCUSize + maxCUDepthDelta) ); |
---|
605 | READ_UVLC( uiCode, "log2_min_transform_block_size_minus2" ); pcSPS->setQuadtreeTULog2MinSize( uiCode + 2 ); |
---|
606 | |
---|
607 | READ_UVLC( uiCode, "log2_diff_max_min_transform_block_size" ); pcSPS->setQuadtreeTULog2MaxSize( uiCode + pcSPS->getQuadtreeTULog2MinSize() ); |
---|
608 | pcSPS->setMaxTrSize( 1<<(uiCode + pcSPS->getQuadtreeTULog2MinSize()) ); |
---|
609 | |
---|
610 | READ_UVLC( uiCode, "max_transform_hierarchy_depth_inter" ); pcSPS->setQuadtreeTUMaxDepthInter( uiCode+1 ); |
---|
611 | READ_UVLC( uiCode, "max_transform_hierarchy_depth_intra" ); pcSPS->setQuadtreeTUMaxDepthIntra( uiCode+1 ); |
---|
612 | |
---|
613 | Int addCuDepth = max (0, log2MinCUSize - (Int)pcSPS->getQuadtreeTULog2MinSize() ); |
---|
614 | pcSPS->setMaxCUDepth( maxCUDepthDelta + addCuDepth ); |
---|
615 | |
---|
616 | READ_FLAG( uiCode, "scaling_list_enabled_flag" ); pcSPS->setScalingListFlag ( uiCode ); |
---|
617 | if(pcSPS->getScalingListFlag()) |
---|
618 | { |
---|
619 | READ_FLAG( uiCode, "sps_scaling_list_data_present_flag" ); pcSPS->setScalingListPresentFlag ( uiCode ); |
---|
620 | if(pcSPS->getScalingListPresentFlag ()) |
---|
621 | { |
---|
622 | parseScalingList( pcSPS->getScalingList() ); |
---|
623 | } |
---|
624 | } |
---|
625 | READ_FLAG( uiCode, "amp_enabled_flag" ); pcSPS->setUseAMP( uiCode ); |
---|
626 | READ_FLAG( uiCode, "sample_adaptive_offset_enabled_flag" ); pcSPS->setUseSAO ( uiCode ? true : false ); |
---|
627 | |
---|
628 | READ_FLAG( uiCode, "pcm_enabled_flag" ); pcSPS->setUsePCM( uiCode ? true : false ); |
---|
629 | if( pcSPS->getUsePCM() ) |
---|
630 | { |
---|
631 | READ_CODE( 4, uiCode, "pcm_sample_bit_depth_luma_minus1" ); pcSPS->setPCMBitDepthLuma ( 1 + uiCode ); |
---|
632 | READ_CODE( 4, uiCode, "pcm_sample_bit_depth_chroma_minus1" ); pcSPS->setPCMBitDepthChroma ( 1 + uiCode ); |
---|
633 | READ_UVLC( uiCode, "log2_min_pcm_luma_coding_block_size_minus3" ); pcSPS->setPCMLog2MinSize (uiCode+3); |
---|
634 | READ_UVLC( uiCode, "log2_diff_max_min_pcm_luma_coding_block_size" ); pcSPS->setPCMLog2MaxSize ( uiCode+pcSPS->getPCMLog2MinSize() ); |
---|
635 | READ_FLAG( uiCode, "pcm_loop_filter_disable_flag" ); pcSPS->setPCMFilterDisableFlag ( uiCode ? true : false ); |
---|
636 | } |
---|
637 | |
---|
638 | READ_UVLC( uiCode, "num_short_term_ref_pic_sets" ); |
---|
639 | assert(uiCode <= 64); |
---|
640 | pcSPS->createRPSList(uiCode); |
---|
641 | |
---|
642 | TComRPSList* rpsList = pcSPS->getRPSList(); |
---|
643 | TComReferencePictureSet* rps; |
---|
644 | |
---|
645 | for(UInt i=0; i< rpsList->getNumberOfReferencePictureSets(); i++) |
---|
646 | { |
---|
647 | rps = rpsList->getReferencePictureSet(i); |
---|
648 | parseShortTermRefPicSet(pcSPS,rps,i); |
---|
649 | } |
---|
650 | READ_FLAG( uiCode, "long_term_ref_pics_present_flag" ); pcSPS->setLongTermRefsPresent(uiCode); |
---|
651 | if (pcSPS->getLongTermRefsPresent()) |
---|
652 | { |
---|
653 | READ_UVLC( uiCode, "num_long_term_ref_pic_sps" ); |
---|
654 | pcSPS->setNumLongTermRefPicSPS(uiCode); |
---|
655 | for (UInt k = 0; k < pcSPS->getNumLongTermRefPicSPS(); k++) |
---|
656 | { |
---|
657 | READ_CODE( pcSPS->getBitsForPOC(), uiCode, "lt_ref_pic_poc_lsb_sps" ); |
---|
658 | pcSPS->setLtRefPicPocLsbSps(k, uiCode); |
---|
659 | READ_FLAG( uiCode, "used_by_curr_pic_lt_sps_flag[i]"); |
---|
660 | pcSPS->setUsedByCurrPicLtSPSFlag(k, uiCode?1:0); |
---|
661 | } |
---|
662 | } |
---|
663 | READ_FLAG( uiCode, "sps_temporal_mvp_enable_flag" ); pcSPS->setTMVPFlagsPresent(uiCode); |
---|
664 | #if REF_IDX_MFM |
---|
665 | #if !M0457_COL_PICTURE_SIGNALING |
---|
666 | if(pcSPS->getLayerId() > 0) |
---|
667 | { |
---|
668 | READ_FLAG( uiCode, "sps_enh_mfm_enable_flag" ); |
---|
669 | pcSPS->setMFMEnabledFlag( uiCode ? true : false ); |
---|
670 | } |
---|
671 | #endif |
---|
672 | #endif |
---|
673 | READ_FLAG( uiCode, "sps_strong_intra_smoothing_enable_flag" ); pcSPS->setUseStrongIntraSmoothing(uiCode); |
---|
674 | |
---|
675 | READ_FLAG( uiCode, "vui_parameters_present_flag" ); pcSPS->setVuiParametersPresentFlag(uiCode); |
---|
676 | |
---|
677 | if (pcSPS->getVuiParametersPresentFlag()) |
---|
678 | { |
---|
679 | parseVUI(pcSPS->getVuiParameters(), pcSPS); |
---|
680 | } |
---|
681 | |
---|
682 | READ_FLAG( uiCode, "sps_extension_flag"); |
---|
683 | if (uiCode) |
---|
684 | { |
---|
685 | #if SPS_EXTENSION |
---|
686 | parseSPSExtension( pcSPS ); |
---|
687 | READ_FLAG( uiCode, "sps_extension2_flag"); |
---|
688 | if(uiCode) |
---|
689 | { |
---|
690 | #endif |
---|
691 | while ( xMoreRbspData() ) |
---|
692 | { |
---|
693 | READ_FLAG( uiCode, "sps_extension_data_flag"); |
---|
694 | } |
---|
695 | #if SPS_EXTENSION |
---|
696 | } |
---|
697 | #endif |
---|
698 | } |
---|
699 | } |
---|
700 | |
---|
701 | #if SPS_EXTENSION |
---|
702 | Void TDecCavlc::parseSPSExtension( TComSPS* pcSPS ) |
---|
703 | { |
---|
704 | UInt uiCode; |
---|
705 | // more syntax elements to be parsed here |
---|
706 | #if SCALED_REF_LAYER_OFFSETS |
---|
707 | #if SCALED_REF_LAYER_OFFSET_FLAG |
---|
708 | READ_FLAG( uiCode, "scaled_ref_layer_offset_present_flag" ); |
---|
709 | if( uiCode ) |
---|
710 | #else |
---|
711 | if( pcSPS->getLayerId() > 0 ) |
---|
712 | #endif |
---|
713 | { |
---|
714 | Int iCode; |
---|
715 | READ_UVLC( uiCode, "num_scaled_ref_layer_offsets" ); pcSPS->setNumScaledRefLayerOffsets(uiCode); |
---|
716 | for(Int i = 0; i < pcSPS->getNumScaledRefLayerOffsets(); i++) |
---|
717 | { |
---|
718 | Window& scaledWindow = pcSPS->getScaledRefLayerWindow(i); |
---|
719 | READ_SVLC( iCode, "scaled_ref_layer_left_offset" ); scaledWindow.setWindowLeftOffset (iCode << 1); |
---|
720 | READ_SVLC( iCode, "scaled_ref_layer_top_offset" ); scaledWindow.setWindowTopOffset (iCode << 1); |
---|
721 | READ_SVLC( iCode, "scaled_ref_layer_right_offset" ); scaledWindow.setWindowRightOffset (iCode << 1); |
---|
722 | READ_SVLC( iCode, "scaled_ref_layer_bottom_offset" ); scaledWindow.setWindowBottomOffset(iCode << 1); |
---|
723 | } |
---|
724 | } |
---|
725 | #endif |
---|
726 | #if M0463_VUI_EXT_ILP_REF |
---|
727 | //// sps_extension_vui_parameters( ) |
---|
728 | if( pcSPS->getVuiParameters()->getBitstreamRestrictionFlag() ) |
---|
729 | { |
---|
730 | READ_UVLC( uiCode, "num_ilp_restricted_ref_layers" ); pcSPS->setNumIlpRestrictedRefLayers( uiCode ); |
---|
731 | for( Int i = 0; i < pcSPS->getNumIlpRestrictedRefLayers( ); i++ ) |
---|
732 | { |
---|
733 | READ_UVLC( uiCode, "min_spatial_segment_offset_plus1" ); pcSPS->setMinSpatialSegmentOffsetPlus1( i, uiCode ); |
---|
734 | if( pcSPS->getMinSpatialSegmentOffsetPlus1( i ) > 0 ) |
---|
735 | { |
---|
736 | READ_FLAG( uiCode, "ctu_based_offset_enabled_flag[ i ]"); pcSPS->setCtuBasedOffsetEnabledFlag(i, uiCode == 1 ); |
---|
737 | if( pcSPS->getCtuBasedOffsetEnabledFlag( i ) ) |
---|
738 | { |
---|
739 | READ_UVLC( uiCode, "min_horizontal_ctu_offset_plus1[ i ]"); pcSPS->setMinHorizontalCtuOffsetPlus1( i, uiCode ); |
---|
740 | } |
---|
741 | } |
---|
742 | } |
---|
743 | } |
---|
744 | //// sps_extension_vui_parameters( ) END |
---|
745 | #endif |
---|
746 | } |
---|
747 | #endif |
---|
748 | |
---|
749 | Void TDecCavlc::parseVPS(TComVPS* pcVPS) |
---|
750 | { |
---|
751 | UInt uiCode; |
---|
752 | |
---|
753 | READ_CODE( 4, uiCode, "vps_video_parameter_set_id" ); pcVPS->setVPSId( uiCode ); |
---|
754 | READ_CODE( 2, uiCode, "vps_reserved_three_2bits" ); assert(uiCode == 3); |
---|
755 | #if VPS_RENAME |
---|
756 | READ_CODE( 6, uiCode, "vps_max_layers_minus1" ); pcVPS->setMaxLayers( uiCode + 1); |
---|
757 | #else |
---|
758 | READ_CODE( 6, uiCode, "vps_reserved_zero_6bits" ); assert(uiCode == 0); |
---|
759 | #endif |
---|
760 | READ_CODE( 3, uiCode, "vps_max_sub_layers_minus1" ); pcVPS->setMaxTLayers( uiCode + 1 ); |
---|
761 | READ_FLAG( uiCode, "vps_temporal_id_nesting_flag" ); pcVPS->setTemporalNestingFlag( uiCode ? true:false ); |
---|
762 | assert (pcVPS->getMaxTLayers()>1||pcVPS->getTemporalNestingFlag()); |
---|
763 | READ_CODE( 16, uiCode, "vps_reserved_ffff_16bits" ); assert(uiCode == 0xffff); |
---|
764 | parsePTL ( pcVPS->getPTL(), true, pcVPS->getMaxTLayers()-1); |
---|
765 | UInt subLayerOrderingInfoPresentFlag; |
---|
766 | READ_FLAG(subLayerOrderingInfoPresentFlag, "vps_sub_layer_ordering_info_present_flag"); |
---|
767 | for(UInt i = 0; i <= pcVPS->getMaxTLayers()-1; i++) |
---|
768 | { |
---|
769 | READ_UVLC( uiCode, "vps_max_dec_pic_buffering_minus1[i]" ); pcVPS->setMaxDecPicBuffering( uiCode + 1, i ); |
---|
770 | READ_UVLC( uiCode, "vps_num_reorder_pics[i]" ); pcVPS->setNumReorderPics( uiCode, i ); |
---|
771 | READ_UVLC( uiCode, "vps_max_latency_increase_plus1[i]" ); pcVPS->setMaxLatencyIncrease( uiCode, i ); |
---|
772 | |
---|
773 | if (!subLayerOrderingInfoPresentFlag) |
---|
774 | { |
---|
775 | for (i++; i <= pcVPS->getMaxTLayers()-1; i++) |
---|
776 | { |
---|
777 | pcVPS->setMaxDecPicBuffering(pcVPS->getMaxDecPicBuffering(0), i); |
---|
778 | pcVPS->setNumReorderPics(pcVPS->getNumReorderPics(0), i); |
---|
779 | pcVPS->setMaxLatencyIncrease(pcVPS->getMaxLatencyIncrease(0), i); |
---|
780 | } |
---|
781 | break; |
---|
782 | } |
---|
783 | } |
---|
784 | |
---|
785 | #if VPS_RENAME |
---|
786 | assert( pcVPS->getNumHrdParameters() < MAX_VPS_LAYER_SETS_PLUS1 ); |
---|
787 | assert( pcVPS->getMaxLayerId() < MAX_VPS_LAYER_ID_PLUS1 ); |
---|
788 | READ_CODE( 6, uiCode, "vps_max_layer_id" ); pcVPS->setMaxLayerId( uiCode ); |
---|
789 | READ_UVLC( uiCode, "vps_num_layer_sets_minus1" ); pcVPS->setNumLayerSets( uiCode + 1 ); |
---|
790 | for( UInt opsIdx = 1; opsIdx <= ( pcVPS->getNumLayerSets() - 1 ); opsIdx ++ ) |
---|
791 | { |
---|
792 | // Operation point set |
---|
793 | for( UInt i = 0; i <= pcVPS->getMaxLayerId(); i ++ ) |
---|
794 | #else |
---|
795 | assert( pcVPS->getNumHrdParameters() < MAX_VPS_OP_SETS_PLUS1 ); |
---|
796 | assert( pcVPS->getMaxNuhReservedZeroLayerId() < MAX_VPS_NUH_RESERVED_ZERO_LAYER_ID_PLUS1 ); |
---|
797 | READ_CODE( 6, uiCode, "vps_max_nuh_reserved_zero_layer_id" ); pcVPS->setMaxNuhReservedZeroLayerId( uiCode ); |
---|
798 | READ_UVLC( uiCode, "vps_max_op_sets_minus1" ); pcVPS->setMaxOpSets( uiCode + 1 ); |
---|
799 | for( UInt opsIdx = 1; opsIdx <= ( pcVPS->getMaxOpSets() - 1 ); opsIdx ++ ) |
---|
800 | { |
---|
801 | // Operation point set |
---|
802 | for( UInt i = 0; i <= pcVPS->getMaxNuhReservedZeroLayerId(); i ++ ) |
---|
803 | #endif |
---|
804 | { |
---|
805 | READ_FLAG( uiCode, "layer_id_included_flag[opsIdx][i]" ); pcVPS->setLayerIdIncludedFlag( uiCode == 1 ? true : false, opsIdx, i ); |
---|
806 | } |
---|
807 | } |
---|
808 | #if DERIVE_LAYER_ID_LIST_VARIABLES |
---|
809 | pcVPS->deriveLayerIdListVariables(); |
---|
810 | #endif |
---|
811 | TimingInfo *timingInfo = pcVPS->getTimingInfo(); |
---|
812 | READ_FLAG( uiCode, "vps_timing_info_present_flag"); timingInfo->setTimingInfoPresentFlag (uiCode ? true : false); |
---|
813 | if(timingInfo->getTimingInfoPresentFlag()) |
---|
814 | { |
---|
815 | READ_CODE( 32, uiCode, "vps_num_units_in_tick"); timingInfo->setNumUnitsInTick (uiCode); |
---|
816 | READ_CODE( 32, uiCode, "vps_time_scale"); timingInfo->setTimeScale (uiCode); |
---|
817 | READ_FLAG( uiCode, "vps_poc_proportional_to_timing_flag"); timingInfo->setPocProportionalToTimingFlag(uiCode ? true : false); |
---|
818 | if(timingInfo->getPocProportionalToTimingFlag()) |
---|
819 | { |
---|
820 | READ_UVLC( uiCode, "vps_num_ticks_poc_diff_one_minus1"); timingInfo->setNumTicksPocDiffOneMinus1 (uiCode); |
---|
821 | } |
---|
822 | READ_UVLC( uiCode, "vps_num_hrd_parameters" ); pcVPS->setNumHrdParameters( uiCode ); |
---|
823 | |
---|
824 | if( pcVPS->getNumHrdParameters() > 0 ) |
---|
825 | { |
---|
826 | pcVPS->createHrdParamBuffer(); |
---|
827 | } |
---|
828 | for( UInt i = 0; i < pcVPS->getNumHrdParameters(); i ++ ) |
---|
829 | { |
---|
830 | READ_UVLC( uiCode, "hrd_op_set_idx" ); pcVPS->setHrdOpSetIdx( uiCode, i ); |
---|
831 | if( i > 0 ) |
---|
832 | { |
---|
833 | READ_FLAG( uiCode, "cprms_present_flag[i]" ); pcVPS->setCprmsPresentFlag( uiCode == 1 ? true : false, i ); |
---|
834 | } |
---|
835 | parseHrdParameters(pcVPS->getHrdParameters(i), pcVPS->getCprmsPresentFlag( i ), pcVPS->getMaxTLayers() - 1); |
---|
836 | } |
---|
837 | } |
---|
838 | READ_FLAG( uiCode, "vps_extension_flag" ); |
---|
839 | if (uiCode) |
---|
840 | { |
---|
841 | #if VPS_EXTNS |
---|
842 | parseVPSExtension(pcVPS); |
---|
843 | READ_FLAG( uiCode, "vps_entension2_flag" ); |
---|
844 | if(uiCode) |
---|
845 | { |
---|
846 | while ( xMoreRbspData() ) |
---|
847 | { |
---|
848 | READ_FLAG( uiCode, "vps_extension_data_flag"); |
---|
849 | } |
---|
850 | } |
---|
851 | #else |
---|
852 | while ( xMoreRbspData() ) |
---|
853 | { |
---|
854 | READ_FLAG( uiCode, "vps_extension_data_flag"); |
---|
855 | } |
---|
856 | #endif |
---|
857 | } |
---|
858 | |
---|
859 | return; |
---|
860 | } |
---|
861 | |
---|
862 | #if VPS_EXTNS |
---|
863 | Void TDecCavlc::parseVPSExtension(TComVPS *vps) |
---|
864 | { |
---|
865 | UInt uiCode; |
---|
866 | // ... More syntax elements to be parsed here |
---|
867 | #if VPS_EXTN_MASK_AND_DIM_INFO |
---|
868 | UInt numScalabilityTypes = 0, i = 0, j = 0; |
---|
869 | |
---|
870 | READ_FLAG( uiCode, "avc_base_layer_flag" ); vps->setAvcBaseLayerFlag(uiCode ? true : false); |
---|
871 | READ_FLAG( uiCode, "splitting_flag" ); vps->setSplittingFlag(uiCode ? true : false); |
---|
872 | |
---|
873 | for(i = 0; i < MAX_VPS_NUM_SCALABILITY_TYPES; i++) |
---|
874 | { |
---|
875 | READ_FLAG( uiCode, "scalability_mask[i]" ); vps->setScalabilityMask(i, uiCode ? true : false); |
---|
876 | numScalabilityTypes += uiCode; |
---|
877 | } |
---|
878 | vps->setNumScalabilityTypes(numScalabilityTypes); |
---|
879 | |
---|
880 | #if VPS_SPLIT_FLAG |
---|
881 | for(j = 0; j < numScalabilityTypes - vps->getSplittingFlag(); j++) |
---|
882 | #else |
---|
883 | for(j = 0; j < numScalabilityTypes; j++) |
---|
884 | #endif |
---|
885 | { |
---|
886 | READ_CODE( 3, uiCode, "dimension_id_len_minus1[j]" ); vps->setDimensionIdLen(j, uiCode + 1); |
---|
887 | } |
---|
888 | #if VPS_SPLIT_FLAG |
---|
889 | if(vps->getSplittingFlag()) |
---|
890 | { |
---|
891 | UInt numBits = 0; |
---|
892 | for(j = 0; j < numScalabilityTypes - 1; j++) |
---|
893 | { |
---|
894 | numBits += vps->getDimensionIdLen(j); |
---|
895 | } |
---|
896 | assert( numBits < 6 ); |
---|
897 | vps->setDimensionIdLen(numScalabilityTypes-1, 6 - numBits); |
---|
898 | numBits = 6; |
---|
899 | } |
---|
900 | #else |
---|
901 | if(vps->getSplittingFlag()) |
---|
902 | { |
---|
903 | UInt numBits = 0; |
---|
904 | for(j = 0; j < numScalabilityTypes; j++) |
---|
905 | { |
---|
906 | numBits += vps->getDimensionIdLen(j); |
---|
907 | } |
---|
908 | assert( numBits <= 6 ); |
---|
909 | } |
---|
910 | #endif |
---|
911 | |
---|
912 | READ_FLAG( uiCode, "vps_nuh_layer_id_present_flag" ); vps->setNuhLayerIdPresentFlag(uiCode ? true : false); |
---|
913 | vps->setLayerIdInNuh(0, 0); |
---|
914 | vps->setLayerIdInVps(0, 0); |
---|
915 | for(i = 1; i < vps->getMaxLayers(); i++) |
---|
916 | { |
---|
917 | if( vps->getNuhLayerIdPresentFlag() ) |
---|
918 | { |
---|
919 | READ_CODE( 6, uiCode, "layer_id_in_nuh[i]" ); vps->setLayerIdInNuh(i, uiCode); |
---|
920 | assert( uiCode > vps->getLayerIdInNuh(i-1) ); |
---|
921 | } |
---|
922 | else |
---|
923 | { |
---|
924 | vps->setLayerIdInNuh(i, i); |
---|
925 | } |
---|
926 | vps->setLayerIdInVps(vps->getLayerIdInNuh(i), i); |
---|
927 | |
---|
928 | #if VPS_SPLIT_FLAG |
---|
929 | if(!vps->getSplittingFlag()) |
---|
930 | #endif |
---|
931 | for(j = 0; j < numScalabilityTypes; j++) |
---|
932 | { |
---|
933 | READ_CODE( vps->getDimensionIdLen(j), uiCode, "dimension_id[i][j]" ); vps->setDimensionId(i, j, uiCode); |
---|
934 | assert( uiCode <= vps->getMaxLayerId() ); |
---|
935 | } |
---|
936 | } |
---|
937 | #endif |
---|
938 | #if VPS_MOVE_DIR_DEPENDENCY_FLAG |
---|
939 | #if VPS_EXTN_DIRECT_REF_LAYERS |
---|
940 | // For layer 0 |
---|
941 | vps->setNumDirectRefLayers(0, 0); |
---|
942 | // For other layers |
---|
943 | for( Int layerCtr = 1; layerCtr <= vps->getMaxLayers() - 1; layerCtr++) |
---|
944 | { |
---|
945 | UInt numDirectRefLayers = 0; |
---|
946 | for( Int refLayerCtr = 0; refLayerCtr < layerCtr; refLayerCtr++) |
---|
947 | { |
---|
948 | READ_FLAG(uiCode, "direct_dependency_flag[i][j]" ); vps->setDirectDependencyFlag(layerCtr, refLayerCtr, uiCode? true : false); |
---|
949 | if(uiCode) |
---|
950 | { |
---|
951 | vps->setRefLayerId(layerCtr, numDirectRefLayers, refLayerCtr); |
---|
952 | numDirectRefLayers++; |
---|
953 | } |
---|
954 | } |
---|
955 | vps->setNumDirectRefLayers(layerCtr, numDirectRefLayers); |
---|
956 | } |
---|
957 | #endif |
---|
958 | #endif |
---|
959 | #if JCTVC_M0203_INTERLAYER_PRED_IDC |
---|
960 | #if N0120_MAX_TID_REF_PRESENT_FLAG |
---|
961 | READ_FLAG( uiCode, "max_tid_il_ref_pics_plus1_present_flag"); vps->setMaxTidIlRefPicsPlus1PresentFlag(uiCode ? true : false); |
---|
962 | if (vps->getMaxTidIlRefPicsPlus1PresentFlag()) |
---|
963 | { |
---|
964 | for(i = 0; i < vps->getMaxLayers() - 1; i++) |
---|
965 | { |
---|
966 | READ_CODE( 3, uiCode, "max_sublayer_for_ilp_plus1[i]" ); vps->setMaxSublayerForIlpPlus1(i, uiCode); |
---|
967 | assert( uiCode <= vps->getMaxTLayers() ); |
---|
968 | } |
---|
969 | } |
---|
970 | else |
---|
971 | { |
---|
972 | for(i = 0; i < vps->getMaxLayers() - 1; i++) |
---|
973 | { |
---|
974 | vps->setMaxSublayerForIlpPlus1(i, 7); |
---|
975 | } |
---|
976 | } |
---|
977 | #else |
---|
978 | for(i = 0; i < vps->getMaxLayers() - 1; i++) |
---|
979 | { |
---|
980 | READ_CODE( 3, uiCode, "max_sublayer_for_ilp_plus1[i]" ); vps->setMaxSublayerForIlpPlus1(i, uiCode); |
---|
981 | assert( uiCode <= vps->getMaxTLayers() ); |
---|
982 | } |
---|
983 | #endif |
---|
984 | #endif |
---|
985 | #if ILP_SSH_SIG |
---|
986 | READ_FLAG( uiCode, "all_ref_layers_active_flag" ); vps->setIlpSshSignalingEnabledFlag(uiCode ? true : false); |
---|
987 | #endif |
---|
988 | #if VPS_EXTN_PROFILE_INFO |
---|
989 | // Profile-tier-level signalling |
---|
990 | #if VPS_PROFILE_OUTPUT_LAYERS |
---|
991 | READ_CODE( 10, uiCode, "vps_number_layer_sets_minus1" ); assert( uiCode == (vps->getNumLayerSets() - 1) ); |
---|
992 | READ_CODE( 6, uiCode, "vps_num_profile_tier_level_minus1"); vps->setNumProfileTierLevel( uiCode + 1 ); |
---|
993 | vps->getPTLForExtnPtr()->resize(vps->getNumProfileTierLevel()); |
---|
994 | for(Int idx = 1; idx <= vps->getNumProfileTierLevel() - 1; idx++) |
---|
995 | #else |
---|
996 | vps->getPTLForExtnPtr()->resize(vps->getNumLayerSets()); |
---|
997 | for(Int idx = 1; idx <= vps->getNumLayerSets() - 1; idx++) |
---|
998 | #endif |
---|
999 | { |
---|
1000 | READ_FLAG( uiCode, "vps_profile_present_flag[i]" ); vps->setProfilePresentFlag(idx, uiCode ? true : false); |
---|
1001 | if( !vps->getProfilePresentFlag(idx) ) |
---|
1002 | { |
---|
1003 | #if VPS_PROFILE_OUTPUT_LAYERS |
---|
1004 | READ_CODE( 6, uiCode, "profile_ref_minus1[i]" ); vps->setProfileLayerSetRef(idx, uiCode + 1); |
---|
1005 | #else |
---|
1006 | READ_UVLC( uiCode, "vps_profile_layer_set_ref_minus1[i]" ); vps->setProfileLayerSetRef(idx, uiCode + 1); |
---|
1007 | #endif |
---|
1008 | assert( vps->getProfileLayerSetRef(idx) < idx ); |
---|
1009 | // Copy profile information as indicated |
---|
1010 | vps->getPTLForExtn(idx)->copyProfileInfo( vps->getPTLForExtn( vps->getProfileLayerSetRef(idx) ) ); |
---|
1011 | } |
---|
1012 | parsePTL( vps->getPTLForExtn(idx), vps->getProfilePresentFlag(idx), vps->getMaxTLayers() - 1 ); |
---|
1013 | } |
---|
1014 | #endif |
---|
1015 | |
---|
1016 | #if VPS_PROFILE_OUTPUT_LAYERS |
---|
1017 | READ_FLAG( uiCode, "more_output_layer_sets_than_default_flag" ); vps->setMoreOutputLayerSetsThanDefaultFlag( uiCode ? true : false ); |
---|
1018 | Int numOutputLayerSets = 0; |
---|
1019 | if(! vps->getMoreOutputLayerSetsThanDefaultFlag() ) |
---|
1020 | { |
---|
1021 | numOutputLayerSets = vps->getNumLayerSets(); |
---|
1022 | } |
---|
1023 | else |
---|
1024 | { |
---|
1025 | READ_CODE( 10, uiCode, "num_add_output_layer_sets" ); vps->setNumAddOutputLayerSets( uiCode ); |
---|
1026 | numOutputLayerSets = vps->getNumLayerSets() + vps->getNumAddOutputLayerSets(); |
---|
1027 | } |
---|
1028 | if( numOutputLayerSets > 1 ) |
---|
1029 | { |
---|
1030 | READ_FLAG( uiCode, "default_one_target_output_layer_flag" ); vps->setDefaultOneTargetOutputLayerFlag( uiCode ? true : false ); |
---|
1031 | } |
---|
1032 | vps->setNumOutputLayerSets( numOutputLayerSets ); |
---|
1033 | |
---|
1034 | for(i = 1; i < numOutputLayerSets; i++) |
---|
1035 | { |
---|
1036 | if( i > (vps->getNumLayerSets() - 1) ) |
---|
1037 | { |
---|
1038 | Int numBits = 1; |
---|
1039 | while ((1 << numBits) < (vps->getNumLayerSets() - 1)) |
---|
1040 | { |
---|
1041 | numBits++; |
---|
1042 | } |
---|
1043 | READ_CODE( numBits, uiCode, "output_layer_set_idx_minus1"); vps->setOutputLayerSetIdx( i, uiCode + 1); |
---|
1044 | Int lsIdx = vps->getOutputLayerSetIdx(i); |
---|
1045 | for(j = 0; j < vps->getNumLayersInIdList(lsIdx) - 1; j++) |
---|
1046 | { |
---|
1047 | READ_FLAG( uiCode, "output_layer_flag[i][j]"); vps->setOutputLayerFlag(i, j, uiCode); |
---|
1048 | } |
---|
1049 | } |
---|
1050 | else |
---|
1051 | { |
---|
1052 | // i <= (vps->getNumLayerSets() - 1) |
---|
1053 | // Assign OutputLayerFlag depending on default_one_target_output_layer_flag |
---|
1054 | Int lsIdx = i; |
---|
1055 | if( vps->getDefaultOneTargetOutputLayerFlag() ) |
---|
1056 | { |
---|
1057 | for(j = 0; j < vps->getNumLayersInIdList(lsIdx); j++) |
---|
1058 | { |
---|
1059 | vps->setOutputLayerFlag(i, j, (j == (vps->getNumLayersInIdList(lsIdx)-1))); |
---|
1060 | } |
---|
1061 | } |
---|
1062 | else |
---|
1063 | { |
---|
1064 | for(j = 0; j < vps->getNumLayersInIdList(lsIdx); j++) |
---|
1065 | { |
---|
1066 | vps->setOutputLayerFlag(i, j, 1); |
---|
1067 | } |
---|
1068 | } |
---|
1069 | } |
---|
1070 | Int numBits = 1; |
---|
1071 | while ((1 << numBits) < (vps->getNumProfileTierLevel())) |
---|
1072 | { |
---|
1073 | numBits++; |
---|
1074 | } |
---|
1075 | READ_CODE( numBits, uiCode, "profile_level_tier_idx[i]" ); vps->setProfileLevelTierIdx(i, uiCode); |
---|
1076 | } |
---|
1077 | #else |
---|
1078 | #if VPS_EXTN_OP_LAYER_SETS |
---|
1079 | // Target output layer signalling |
---|
1080 | READ_UVLC( uiCode, "vps_num_output_layer_sets"); vps->setNumOutputLayerSets(uiCode); |
---|
1081 | for(i = 0; i < vps->getNumOutputLayerSets(); i++) |
---|
1082 | { |
---|
1083 | #if VPS_OUTPUT_LAYER_SET_IDX |
---|
1084 | READ_UVLC( uiCode, "vps_output_layer_set_idx_minus1[i]"); vps->setOutputLayerSetIdx(i, uiCode + 1); |
---|
1085 | #else |
---|
1086 | READ_UVLC( uiCode, "vps_output_layer_set_idx[i]"); vps->setOutputLayerSetIdx(i, uiCode); |
---|
1087 | #endif |
---|
1088 | Int lsIdx = vps->getOutputLayerSetIdx(i); |
---|
1089 | for(j = 0; j <= vps->getMaxLayerId(); j++) |
---|
1090 | { |
---|
1091 | if(vps->getLayerIdIncludedFlag(lsIdx, j)) |
---|
1092 | { |
---|
1093 | READ_FLAG( uiCode, "vps_output_layer_flag[lsIdx][j]"); vps->setOutputLayerFlag(lsIdx, j, uiCode); |
---|
1094 | } |
---|
1095 | } |
---|
1096 | } |
---|
1097 | #endif |
---|
1098 | #endif |
---|
1099 | #if JCTVC_M0458_INTERLAYER_RPS_SIG |
---|
1100 | READ_FLAG(uiCode, "max_one_active_ref_layer_flag" ); |
---|
1101 | vps->setMaxOneActiveRefLayerFlag(uiCode); |
---|
1102 | #endif |
---|
1103 | |
---|
1104 | #if !VPS_MOVE_DIR_DEPENDENCY_FLAG |
---|
1105 | #if VPS_EXTN_DIRECT_REF_LAYERS |
---|
1106 | // For layer 0 |
---|
1107 | vps->setNumDirectRefLayers(0, 0); |
---|
1108 | // For other layers |
---|
1109 | for( Int layerCtr = 1; layerCtr <= vps->getMaxLayers() - 1; layerCtr++) |
---|
1110 | { |
---|
1111 | UInt numDirectRefLayers = 0; |
---|
1112 | for( Int refLayerCtr = 0; refLayerCtr < layerCtr; refLayerCtr++) |
---|
1113 | { |
---|
1114 | READ_FLAG(uiCode, "direct_dependency_flag[i][j]" ); vps->setDirectDependencyFlag(layerCtr, refLayerCtr, uiCode? true : false); |
---|
1115 | if(uiCode) |
---|
1116 | { |
---|
1117 | vps->setRefLayerId(layerCtr, numDirectRefLayers, refLayerCtr); |
---|
1118 | numDirectRefLayers++; |
---|
1119 | } |
---|
1120 | } |
---|
1121 | vps->setNumDirectRefLayers(layerCtr, numDirectRefLayers); |
---|
1122 | } |
---|
1123 | #endif |
---|
1124 | #endif |
---|
1125 | #if VPS_EXTN_DIRECT_REF_LAYERS && M0457_PREDICTION_INDICATIONS |
---|
1126 | READ_UVLC( uiCode, "direct_dep_type_len_minus2"); vps->setDirectDepTypeLen(uiCode+2); |
---|
1127 | for(i = 1; i < vps->getMaxLayers(); i++) |
---|
1128 | { |
---|
1129 | for(j = 0; j < i; j++) |
---|
1130 | { |
---|
1131 | if (vps->getDirectDependencyFlag(i, j)) |
---|
1132 | { |
---|
1133 | READ_CODE( vps->getDirectDepTypeLen(), uiCode, "direct_dependency_type[i][j]" ); vps->setDirectDependencyType(i, j, uiCode); |
---|
1134 | } |
---|
1135 | } |
---|
1136 | } |
---|
1137 | #endif |
---|
1138 | #if M0040_ADAPTIVE_RESOLUTION_CHANGE |
---|
1139 | READ_FLAG(uiCode, "single_layer_for_non_irap_flag" ); vps->setSingleLayerForNonIrapFlag(uiCode == 1 ? true : false); |
---|
1140 | #endif |
---|
1141 | } |
---|
1142 | #endif |
---|
1143 | |
---|
1144 | Void TDecCavlc::parseSliceHeader (TComSlice*& rpcSlice, ParameterSetManagerDecoder *parameterSetManager) |
---|
1145 | { |
---|
1146 | UInt uiCode; |
---|
1147 | Int iCode; |
---|
1148 | |
---|
1149 | #if ENC_DEC_TRACE |
---|
1150 | xTraceSliceHeader(rpcSlice); |
---|
1151 | #endif |
---|
1152 | TComPPS* pps = NULL; |
---|
1153 | TComSPS* sps = NULL; |
---|
1154 | |
---|
1155 | UInt firstSliceSegmentInPic; |
---|
1156 | READ_FLAG( firstSliceSegmentInPic, "first_slice_segment_in_pic_flag" ); |
---|
1157 | if( rpcSlice->getRapPicFlag()) |
---|
1158 | { |
---|
1159 | READ_FLAG( uiCode, "no_output_of_prior_pics_flag" ); //ignored |
---|
1160 | } |
---|
1161 | READ_UVLC ( uiCode, "slice_pic_parameter_set_id" ); rpcSlice->setPPSId(uiCode); |
---|
1162 | pps = parameterSetManager->getPrefetchedPPS(uiCode); |
---|
1163 | //!KS: need to add error handling code here, if PPS is not available |
---|
1164 | assert(pps!=0); |
---|
1165 | sps = parameterSetManager->getPrefetchedSPS(pps->getSPSId()); |
---|
1166 | //!KS: need to add error handling code here, if SPS is not available |
---|
1167 | assert(sps!=0); |
---|
1168 | rpcSlice->setSPS(sps); |
---|
1169 | rpcSlice->setPPS(pps); |
---|
1170 | if( pps->getDependentSliceSegmentsEnabledFlag() && ( !firstSliceSegmentInPic )) |
---|
1171 | { |
---|
1172 | READ_FLAG( uiCode, "dependent_slice_segment_flag" ); rpcSlice->setDependentSliceSegmentFlag(uiCode ? true : false); |
---|
1173 | } |
---|
1174 | else |
---|
1175 | { |
---|
1176 | rpcSlice->setDependentSliceSegmentFlag(false); |
---|
1177 | } |
---|
1178 | Int numCTUs = ((sps->getPicWidthInLumaSamples()+sps->getMaxCUWidth()-1)/sps->getMaxCUWidth())*((sps->getPicHeightInLumaSamples()+sps->getMaxCUHeight()-1)/sps->getMaxCUHeight()); |
---|
1179 | Int maxParts = (1<<(sps->getMaxCUDepth()<<1)); |
---|
1180 | UInt sliceSegmentAddress = 0; |
---|
1181 | Int bitsSliceSegmentAddress = 0; |
---|
1182 | while(numCTUs>(1<<bitsSliceSegmentAddress)) |
---|
1183 | { |
---|
1184 | bitsSliceSegmentAddress++; |
---|
1185 | } |
---|
1186 | |
---|
1187 | if(!firstSliceSegmentInPic) |
---|
1188 | { |
---|
1189 | READ_CODE( bitsSliceSegmentAddress, sliceSegmentAddress, "slice_segment_address" ); |
---|
1190 | } |
---|
1191 | //set uiCode to equal slice start address (or dependent slice start address) |
---|
1192 | Int startCuAddress = maxParts*sliceSegmentAddress; |
---|
1193 | rpcSlice->setSliceSegmentCurStartCUAddr( startCuAddress ); |
---|
1194 | rpcSlice->setSliceSegmentCurEndCUAddr(numCTUs*maxParts); |
---|
1195 | |
---|
1196 | if (rpcSlice->getDependentSliceSegmentFlag()) |
---|
1197 | { |
---|
1198 | rpcSlice->setNextSlice ( false ); |
---|
1199 | rpcSlice->setNextSliceSegment ( true ); |
---|
1200 | } |
---|
1201 | else |
---|
1202 | { |
---|
1203 | rpcSlice->setNextSlice ( true ); |
---|
1204 | rpcSlice->setNextSliceSegment ( false ); |
---|
1205 | |
---|
1206 | rpcSlice->setSliceCurStartCUAddr(startCuAddress); |
---|
1207 | rpcSlice->setSliceCurEndCUAddr(numCTUs*maxParts); |
---|
1208 | } |
---|
1209 | |
---|
1210 | if(!rpcSlice->getDependentSliceSegmentFlag()) |
---|
1211 | { |
---|
1212 | |
---|
1213 | #if SH_DISCARDABLE_FLAG |
---|
1214 | if(rpcSlice->getPPS()->getNumExtraSliceHeaderBits()>0) |
---|
1215 | { |
---|
1216 | READ_FLAG(uiCode, "discardable_flag"); // ignored |
---|
1217 | } |
---|
1218 | for (Int i = 1; i < rpcSlice->getPPS()->getNumExtraSliceHeaderBits(); i++) |
---|
1219 | { |
---|
1220 | READ_FLAG(uiCode, "slice_reserved_undetermined_flag[]"); // ignored |
---|
1221 | } |
---|
1222 | #else |
---|
1223 | for (Int i = 0; i < rpcSlice->getPPS()->getNumExtraSliceHeaderBits(); i++) |
---|
1224 | { |
---|
1225 | READ_FLAG(uiCode, "slice_reserved_undetermined_flag[]"); // ignored |
---|
1226 | } |
---|
1227 | #endif |
---|
1228 | |
---|
1229 | READ_UVLC ( uiCode, "slice_type" ); rpcSlice->setSliceType((SliceType)uiCode); |
---|
1230 | if( pps->getOutputFlagPresentFlag() ) |
---|
1231 | { |
---|
1232 | READ_FLAG( uiCode, "pic_output_flag" ); rpcSlice->setPicOutputFlag( uiCode ? true : false ); |
---|
1233 | } |
---|
1234 | else |
---|
1235 | { |
---|
1236 | rpcSlice->setPicOutputFlag( true ); |
---|
1237 | } |
---|
1238 | // in the first version chroma_format_idc is equal to one, thus colour_plane_id will not be present |
---|
1239 | assert (sps->getChromaFormatIdc() == 1 ); |
---|
1240 | // if( separate_colour_plane_flag == 1 ) |
---|
1241 | // colour_plane_id u(2) |
---|
1242 | |
---|
1243 | if( rpcSlice->getIdrPicFlag() ) |
---|
1244 | { |
---|
1245 | rpcSlice->setPOC(0); |
---|
1246 | TComReferencePictureSet* rps = rpcSlice->getLocalRPS(); |
---|
1247 | rps->setNumberOfNegativePictures(0); |
---|
1248 | rps->setNumberOfPositivePictures(0); |
---|
1249 | rps->setNumberOfLongtermPictures(0); |
---|
1250 | rps->setNumberOfPictures(0); |
---|
1251 | rpcSlice->setRPS(rps); |
---|
1252 | } |
---|
1253 | else |
---|
1254 | { |
---|
1255 | READ_CODE(sps->getBitsForPOC(), uiCode, "pic_order_cnt_lsb"); |
---|
1256 | Int iPOClsb = uiCode; |
---|
1257 | Int iPrevPOC = rpcSlice->getPrevPOC(); |
---|
1258 | Int iMaxPOClsb = 1<< sps->getBitsForPOC(); |
---|
1259 | Int iPrevPOClsb = iPrevPOC%iMaxPOClsb; |
---|
1260 | Int iPrevPOCmsb = iPrevPOC-iPrevPOClsb; |
---|
1261 | Int iPOCmsb; |
---|
1262 | if( ( iPOClsb < iPrevPOClsb ) && ( ( iPrevPOClsb - iPOClsb ) >= ( iMaxPOClsb / 2 ) ) ) |
---|
1263 | { |
---|
1264 | iPOCmsb = iPrevPOCmsb + iMaxPOClsb; |
---|
1265 | } |
---|
1266 | else if( (iPOClsb > iPrevPOClsb ) && ( (iPOClsb - iPrevPOClsb ) > ( iMaxPOClsb / 2 ) ) ) |
---|
1267 | { |
---|
1268 | iPOCmsb = iPrevPOCmsb - iMaxPOClsb; |
---|
1269 | } |
---|
1270 | else |
---|
1271 | { |
---|
1272 | iPOCmsb = iPrevPOCmsb; |
---|
1273 | } |
---|
1274 | if ( rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP |
---|
1275 | || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL |
---|
1276 | || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP ) |
---|
1277 | { |
---|
1278 | // For BLA picture types, POCmsb is set to 0. |
---|
1279 | iPOCmsb = 0; |
---|
1280 | } |
---|
1281 | rpcSlice->setPOC (iPOCmsb+iPOClsb); |
---|
1282 | |
---|
1283 | TComReferencePictureSet* rps; |
---|
1284 | rps = rpcSlice->getLocalRPS(); |
---|
1285 | rpcSlice->setRPS(rps); |
---|
1286 | READ_FLAG( uiCode, "short_term_ref_pic_set_sps_flag" ); |
---|
1287 | if(uiCode == 0) // use short-term reference picture set explicitly signalled in slice header |
---|
1288 | { |
---|
1289 | parseShortTermRefPicSet(sps,rps, sps->getRPSList()->getNumberOfReferencePictureSets()); |
---|
1290 | } |
---|
1291 | else // use reference to short-term reference picture set in PPS |
---|
1292 | { |
---|
1293 | Int numBits = 0; |
---|
1294 | while ((1 << numBits) < rpcSlice->getSPS()->getRPSList()->getNumberOfReferencePictureSets()) |
---|
1295 | { |
---|
1296 | numBits++; |
---|
1297 | } |
---|
1298 | if (numBits > 0) |
---|
1299 | { |
---|
1300 | READ_CODE( numBits, uiCode, "short_term_ref_pic_set_idx"); |
---|
1301 | } |
---|
1302 | else |
---|
1303 | { |
---|
1304 | uiCode = 0; |
---|
1305 | } |
---|
1306 | *rps = *(sps->getRPSList()->getReferencePictureSet(uiCode)); |
---|
1307 | } |
---|
1308 | if(sps->getLongTermRefsPresent()) |
---|
1309 | { |
---|
1310 | Int offset = rps->getNumberOfNegativePictures()+rps->getNumberOfPositivePictures(); |
---|
1311 | UInt numOfLtrp = 0; |
---|
1312 | UInt numLtrpInSPS = 0; |
---|
1313 | if (rpcSlice->getSPS()->getNumLongTermRefPicSPS() > 0) |
---|
1314 | { |
---|
1315 | READ_UVLC( uiCode, "num_long_term_sps"); |
---|
1316 | numLtrpInSPS = uiCode; |
---|
1317 | numOfLtrp += numLtrpInSPS; |
---|
1318 | rps->setNumberOfLongtermPictures(numOfLtrp); |
---|
1319 | } |
---|
1320 | Int bitsForLtrpInSPS = 0; |
---|
1321 | while (rpcSlice->getSPS()->getNumLongTermRefPicSPS() > (1 << bitsForLtrpInSPS)) |
---|
1322 | { |
---|
1323 | bitsForLtrpInSPS++; |
---|
1324 | } |
---|
1325 | READ_UVLC( uiCode, "num_long_term_pics"); rps->setNumberOfLongtermPictures(uiCode); |
---|
1326 | numOfLtrp += uiCode; |
---|
1327 | rps->setNumberOfLongtermPictures(numOfLtrp); |
---|
1328 | Int maxPicOrderCntLSB = 1 << rpcSlice->getSPS()->getBitsForPOC(); |
---|
1329 | Int prevDeltaMSB = 0, deltaPocMSBCycleLT = 0;; |
---|
1330 | for(Int j=offset+rps->getNumberOfLongtermPictures()-1, k = 0; k < numOfLtrp; j--, k++) |
---|
1331 | { |
---|
1332 | Int pocLsbLt; |
---|
1333 | if (k < numLtrpInSPS) |
---|
1334 | { |
---|
1335 | uiCode = 0; |
---|
1336 | if (bitsForLtrpInSPS > 0) |
---|
1337 | { |
---|
1338 | READ_CODE(bitsForLtrpInSPS, uiCode, "lt_idx_sps[i]"); |
---|
1339 | } |
---|
1340 | Int usedByCurrFromSPS=rpcSlice->getSPS()->getUsedByCurrPicLtSPSFlag(uiCode); |
---|
1341 | |
---|
1342 | pocLsbLt = rpcSlice->getSPS()->getLtRefPicPocLsbSps(uiCode); |
---|
1343 | rps->setUsed(j,usedByCurrFromSPS); |
---|
1344 | } |
---|
1345 | else |
---|
1346 | { |
---|
1347 | READ_CODE(rpcSlice->getSPS()->getBitsForPOC(), uiCode, "poc_lsb_lt"); pocLsbLt= uiCode; |
---|
1348 | READ_FLAG( uiCode, "used_by_curr_pic_lt_flag"); rps->setUsed(j,uiCode); |
---|
1349 | } |
---|
1350 | READ_FLAG(uiCode,"delta_poc_msb_present_flag"); |
---|
1351 | Bool mSBPresentFlag = uiCode ? true : false; |
---|
1352 | if(mSBPresentFlag) |
---|
1353 | { |
---|
1354 | READ_UVLC( uiCode, "delta_poc_msb_cycle_lt[i]" ); |
---|
1355 | Bool deltaFlag = false; |
---|
1356 | // First LTRP || First LTRP from SH |
---|
1357 | if( (j == offset+rps->getNumberOfLongtermPictures()-1) || (j == offset+(numOfLtrp-numLtrpInSPS)-1) ) |
---|
1358 | { |
---|
1359 | deltaFlag = true; |
---|
1360 | } |
---|
1361 | if(deltaFlag) |
---|
1362 | { |
---|
1363 | deltaPocMSBCycleLT = uiCode; |
---|
1364 | } |
---|
1365 | else |
---|
1366 | { |
---|
1367 | deltaPocMSBCycleLT = uiCode + prevDeltaMSB; |
---|
1368 | } |
---|
1369 | |
---|
1370 | Int pocLTCurr = rpcSlice->getPOC() - deltaPocMSBCycleLT * maxPicOrderCntLSB |
---|
1371 | - iPOClsb + pocLsbLt; |
---|
1372 | rps->setPOC (j, pocLTCurr); |
---|
1373 | rps->setDeltaPOC(j, - rpcSlice->getPOC() + pocLTCurr); |
---|
1374 | rps->setCheckLTMSBPresent(j,true); |
---|
1375 | } |
---|
1376 | else |
---|
1377 | { |
---|
1378 | rps->setPOC (j, pocLsbLt); |
---|
1379 | rps->setDeltaPOC(j, - rpcSlice->getPOC() + pocLsbLt); |
---|
1380 | rps->setCheckLTMSBPresent(j,false); |
---|
1381 | } |
---|
1382 | prevDeltaMSB = deltaPocMSBCycleLT; |
---|
1383 | } |
---|
1384 | offset += rps->getNumberOfLongtermPictures(); |
---|
1385 | rps->setNumberOfPictures(offset); |
---|
1386 | } |
---|
1387 | if ( rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP |
---|
1388 | || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL |
---|
1389 | || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP ) |
---|
1390 | { |
---|
1391 | // In the case of BLA picture types, rps data is read from slice header but ignored |
---|
1392 | rps = rpcSlice->getLocalRPS(); |
---|
1393 | rps->setNumberOfNegativePictures(0); |
---|
1394 | rps->setNumberOfPositivePictures(0); |
---|
1395 | rps->setNumberOfLongtermPictures(0); |
---|
1396 | rps->setNumberOfPictures(0); |
---|
1397 | rpcSlice->setRPS(rps); |
---|
1398 | } |
---|
1399 | if (rpcSlice->getSPS()->getTMVPFlagsPresent()) |
---|
1400 | { |
---|
1401 | READ_FLAG( uiCode, "slice_temporal_mvp_enable_flag" ); |
---|
1402 | rpcSlice->setEnableTMVPFlag( uiCode == 1 ? true : false ); |
---|
1403 | } |
---|
1404 | else |
---|
1405 | { |
---|
1406 | rpcSlice->setEnableTMVPFlag(false); |
---|
1407 | } |
---|
1408 | } |
---|
1409 | |
---|
1410 | #if REF_IDX_FRAMEWORK |
---|
1411 | #if JCTVC_M0458_INTERLAYER_RPS_SIG |
---|
1412 | rpcSlice->setActiveNumILRRefIdx(0); |
---|
1413 | #if ILP_SSH_SIG |
---|
1414 | if((sps->getLayerId() > 0) && rpcSlice->getVPS()->getIlpSshSignalingEnabledFlag() && (rpcSlice->getNumILRRefIdx() > 0) ) |
---|
1415 | #else |
---|
1416 | if((sps->getLayerId() > 0) && (rpcSlice->getNumILRRefIdx() > 0) ) |
---|
1417 | #endif |
---|
1418 | { |
---|
1419 | READ_FLAG(uiCode,"inter_layer_pred_enabled_flag"); |
---|
1420 | rpcSlice->setInterLayerPredEnabledFlag(uiCode); |
---|
1421 | if( rpcSlice->getInterLayerPredEnabledFlag()) |
---|
1422 | { |
---|
1423 | if(rpcSlice->getNumILRRefIdx() > 1) |
---|
1424 | { |
---|
1425 | Int numBits = 1; |
---|
1426 | while ((1 << numBits) < rpcSlice->getNumILRRefIdx()) |
---|
1427 | { |
---|
1428 | numBits++; |
---|
1429 | } |
---|
1430 | if( !rpcSlice->getVPS()->getMaxOneActiveRefLayerFlag()) |
---|
1431 | { |
---|
1432 | READ_CODE( numBits, uiCode,"num_inter_layer_ref_pics_minus1" ); |
---|
1433 | rpcSlice->setActiveNumILRRefIdx(uiCode + 1); |
---|
1434 | } |
---|
1435 | else |
---|
1436 | { |
---|
1437 | rpcSlice->setActiveNumILRRefIdx(1); |
---|
1438 | } |
---|
1439 | #if ILP_NUM_REF_CHK |
---|
1440 | if( rpcSlice->getActiveNumILRRefIdx() == rpcSlice->getNumILRRefIdx() ) |
---|
1441 | { |
---|
1442 | for( Int i = 0; i < rpcSlice->getActiveNumILRRefIdx(); i++ ) |
---|
1443 | { |
---|
1444 | rpcSlice->setInterLayerPredLayerIdc(i,i); |
---|
1445 | } |
---|
1446 | } |
---|
1447 | else |
---|
1448 | { |
---|
1449 | #endif |
---|
1450 | for(Int i = 0; i < rpcSlice->getActiveNumILRRefIdx(); i++ ) |
---|
1451 | { |
---|
1452 | READ_CODE( numBits,uiCode,"inter_layer_pred_layer_idc[i]" ); |
---|
1453 | rpcSlice->setInterLayerPredLayerIdc(uiCode,i); |
---|
1454 | } |
---|
1455 | #if ILP_NUM_REF_CHK |
---|
1456 | } |
---|
1457 | #endif |
---|
1458 | } |
---|
1459 | else |
---|
1460 | { |
---|
1461 | rpcSlice->setActiveNumILRRefIdx(1); |
---|
1462 | rpcSlice->setInterLayerPredLayerIdc(0,0); |
---|
1463 | } |
---|
1464 | } |
---|
1465 | } |
---|
1466 | #if ILP_SSH_SIG |
---|
1467 | else if( rpcSlice->getVPS()->getIlpSshSignalingEnabledFlag() == false ) |
---|
1468 | { |
---|
1469 | rpcSlice->setInterLayerPredEnabledFlag(true); |
---|
1470 | rpcSlice->setActiveNumILRRefIdx(rpcSlice->getNumILRRefIdx()); |
---|
1471 | for( Int i = 0; i < rpcSlice->getActiveNumILRRefIdx(); i++ ) |
---|
1472 | { |
---|
1473 | rpcSlice->setInterLayerPredLayerIdc(i,i); |
---|
1474 | } |
---|
1475 | } |
---|
1476 | #endif |
---|
1477 | #if M0457_IL_SAMPLE_PRED_ONLY_FLAG |
---|
1478 | rpcSlice->setInterLayerSamplePredOnlyFlag( false ); |
---|
1479 | if( rpcSlice->getNumSamplePredRefLayers() > 0 && rpcSlice->getActiveNumILRRefIdx() > 0 ) |
---|
1480 | { |
---|
1481 | READ_FLAG( uiCode, "inter_layer_sample_pred_only_flag" ); |
---|
1482 | rpcSlice->setInterLayerSamplePredOnlyFlag( uiCode > 0 ); |
---|
1483 | } |
---|
1484 | #endif |
---|
1485 | #else |
---|
1486 | if( rpcSlice->getLayerId() > 0 ) |
---|
1487 | { |
---|
1488 | rpcSlice->setNumILRRefIdx( rpcSlice->getVPS()->getNumDirectRefLayers( rpcSlice->getLayerId() ) ); |
---|
1489 | } |
---|
1490 | #endif |
---|
1491 | #endif |
---|
1492 | |
---|
1493 | if(sps->getUseSAO()) |
---|
1494 | { |
---|
1495 | READ_FLAG(uiCode, "slice_sao_luma_flag"); rpcSlice->setSaoEnabledFlag((Bool)uiCode); |
---|
1496 | READ_FLAG(uiCode, "slice_sao_chroma_flag"); rpcSlice->setSaoEnabledFlagChroma((Bool)uiCode); |
---|
1497 | } |
---|
1498 | |
---|
1499 | if (rpcSlice->getIdrPicFlag()) |
---|
1500 | { |
---|
1501 | rpcSlice->setEnableTMVPFlag(false); |
---|
1502 | } |
---|
1503 | if (!rpcSlice->isIntra()) |
---|
1504 | { |
---|
1505 | |
---|
1506 | READ_FLAG( uiCode, "num_ref_idx_active_override_flag"); |
---|
1507 | if (uiCode) |
---|
1508 | { |
---|
1509 | READ_UVLC (uiCode, "num_ref_idx_l0_active_minus1" ); rpcSlice->setNumRefIdx( REF_PIC_LIST_0, uiCode + 1 ); |
---|
1510 | if (rpcSlice->isInterB()) |
---|
1511 | { |
---|
1512 | READ_UVLC (uiCode, "num_ref_idx_l1_active_minus1" ); rpcSlice->setNumRefIdx( REF_PIC_LIST_1, uiCode + 1 ); |
---|
1513 | } |
---|
1514 | else |
---|
1515 | { |
---|
1516 | rpcSlice->setNumRefIdx(REF_PIC_LIST_1, 0); |
---|
1517 | } |
---|
1518 | } |
---|
1519 | else |
---|
1520 | { |
---|
1521 | rpcSlice->setNumRefIdx(REF_PIC_LIST_0, rpcSlice->getPPS()->getNumRefIdxL0DefaultActive()); |
---|
1522 | if (rpcSlice->isInterB()) |
---|
1523 | { |
---|
1524 | rpcSlice->setNumRefIdx(REF_PIC_LIST_1, rpcSlice->getPPS()->getNumRefIdxL1DefaultActive()); |
---|
1525 | } |
---|
1526 | else |
---|
1527 | { |
---|
1528 | rpcSlice->setNumRefIdx(REF_PIC_LIST_1,0); |
---|
1529 | } |
---|
1530 | } |
---|
1531 | } |
---|
1532 | // } |
---|
1533 | TComRefPicListModification* refPicListModification = rpcSlice->getRefPicListModification(); |
---|
1534 | if(!rpcSlice->isIntra()) |
---|
1535 | { |
---|
1536 | if( !rpcSlice->getPPS()->getListsModificationPresentFlag() || rpcSlice->getNumRpsCurrTempList() <= 1 ) |
---|
1537 | { |
---|
1538 | refPicListModification->setRefPicListModificationFlagL0( 0 ); |
---|
1539 | } |
---|
1540 | else |
---|
1541 | { |
---|
1542 | READ_FLAG( uiCode, "ref_pic_list_modification_flag_l0" ); refPicListModification->setRefPicListModificationFlagL0( uiCode ? 1 : 0 ); |
---|
1543 | } |
---|
1544 | |
---|
1545 | if(refPicListModification->getRefPicListModificationFlagL0()) |
---|
1546 | { |
---|
1547 | uiCode = 0; |
---|
1548 | Int i = 0; |
---|
1549 | Int numRpsCurrTempList0 = rpcSlice->getNumRpsCurrTempList(); |
---|
1550 | if ( numRpsCurrTempList0 > 1 ) |
---|
1551 | { |
---|
1552 | Int length = 1; |
---|
1553 | numRpsCurrTempList0 --; |
---|
1554 | while ( numRpsCurrTempList0 >>= 1) |
---|
1555 | { |
---|
1556 | length ++; |
---|
1557 | } |
---|
1558 | for (i = 0; i < rpcSlice->getNumRefIdx(REF_PIC_LIST_0); i ++) |
---|
1559 | { |
---|
1560 | READ_CODE( length, uiCode, "list_entry_l0" ); |
---|
1561 | refPicListModification->setRefPicSetIdxL0(i, uiCode ); |
---|
1562 | } |
---|
1563 | } |
---|
1564 | else |
---|
1565 | { |
---|
1566 | for (i = 0; i < rpcSlice->getNumRefIdx(REF_PIC_LIST_0); i ++) |
---|
1567 | { |
---|
1568 | refPicListModification->setRefPicSetIdxL0(i, 0 ); |
---|
1569 | } |
---|
1570 | } |
---|
1571 | } |
---|
1572 | } |
---|
1573 | else |
---|
1574 | { |
---|
1575 | refPicListModification->setRefPicListModificationFlagL0(0); |
---|
1576 | } |
---|
1577 | if(rpcSlice->isInterB()) |
---|
1578 | { |
---|
1579 | if( !rpcSlice->getPPS()->getListsModificationPresentFlag() || rpcSlice->getNumRpsCurrTempList() <= 1 ) |
---|
1580 | { |
---|
1581 | refPicListModification->setRefPicListModificationFlagL1( 0 ); |
---|
1582 | } |
---|
1583 | else |
---|
1584 | { |
---|
1585 | READ_FLAG( uiCode, "ref_pic_list_modification_flag_l1" ); refPicListModification->setRefPicListModificationFlagL1( uiCode ? 1 : 0 ); |
---|
1586 | } |
---|
1587 | if(refPicListModification->getRefPicListModificationFlagL1()) |
---|
1588 | { |
---|
1589 | uiCode = 0; |
---|
1590 | Int i = 0; |
---|
1591 | Int numRpsCurrTempList1 = rpcSlice->getNumRpsCurrTempList(); |
---|
1592 | if ( numRpsCurrTempList1 > 1 ) |
---|
1593 | { |
---|
1594 | Int length = 1; |
---|
1595 | numRpsCurrTempList1 --; |
---|
1596 | while ( numRpsCurrTempList1 >>= 1) |
---|
1597 | { |
---|
1598 | length ++; |
---|
1599 | } |
---|
1600 | for (i = 0; i < rpcSlice->getNumRefIdx(REF_PIC_LIST_1); i ++) |
---|
1601 | { |
---|
1602 | READ_CODE( length, uiCode, "list_entry_l1" ); |
---|
1603 | refPicListModification->setRefPicSetIdxL1(i, uiCode ); |
---|
1604 | } |
---|
1605 | } |
---|
1606 | else |
---|
1607 | { |
---|
1608 | for (i = 0; i < rpcSlice->getNumRefIdx(REF_PIC_LIST_1); i ++) |
---|
1609 | { |
---|
1610 | refPicListModification->setRefPicSetIdxL1(i, 0 ); |
---|
1611 | } |
---|
1612 | } |
---|
1613 | } |
---|
1614 | } |
---|
1615 | else |
---|
1616 | { |
---|
1617 | refPicListModification->setRefPicListModificationFlagL1(0); |
---|
1618 | } |
---|
1619 | if (rpcSlice->isInterB()) |
---|
1620 | { |
---|
1621 | READ_FLAG( uiCode, "mvd_l1_zero_flag" ); rpcSlice->setMvdL1ZeroFlag( (uiCode ? true : false) ); |
---|
1622 | } |
---|
1623 | |
---|
1624 | rpcSlice->setCabacInitFlag( false ); // default |
---|
1625 | if(pps->getCabacInitPresentFlag() && !rpcSlice->isIntra()) |
---|
1626 | { |
---|
1627 | READ_FLAG(uiCode, "cabac_init_flag"); |
---|
1628 | rpcSlice->setCabacInitFlag( uiCode ? true : false ); |
---|
1629 | } |
---|
1630 | |
---|
1631 | if ( rpcSlice->getEnableTMVPFlag() ) |
---|
1632 | { |
---|
1633 | #if REF_IDX_FRAMEWORK && M0457_COL_PICTURE_SIGNALING |
---|
1634 | #if REMOVE_COL_PICTURE_SIGNALING |
---|
1635 | rpcSlice->setMFMEnabledFlag( rpcSlice->getNumMotionPredRefLayers() > 0 ? true : false ); |
---|
1636 | #else |
---|
1637 | rpcSlice->setMFMEnabledFlag( false ); |
---|
1638 | rpcSlice->setColRefLayerIdx( 0 ); |
---|
1639 | rpcSlice->setAltColIndicationFlag( false ); |
---|
1640 | if ( sps->getLayerId() > 0 && rpcSlice->getActiveNumILRRefIdx() > 0 && rpcSlice->getNumMotionPredRefLayers() > 0 ) |
---|
1641 | { |
---|
1642 | READ_FLAG( uiCode, "alt_collocated_indication_flag" ); |
---|
1643 | rpcSlice->setAltColIndicationFlag( uiCode == 1 ? true : false ); |
---|
1644 | rpcSlice->setMFMEnabledFlag( uiCode == 1 ? true : false ); |
---|
1645 | if ( rpcSlice->getNumMotionPredRefLayers() > 1 ) |
---|
1646 | { |
---|
1647 | READ_UVLC( uiCode, "collocated_ref_layer_idx" ); |
---|
1648 | rpcSlice->setColRefLayerIdx( uiCode ); |
---|
1649 | } |
---|
1650 | } |
---|
1651 | else |
---|
1652 | { |
---|
1653 | #endif //REMOVE_COL_PICTURE_SIGNALING |
---|
1654 | #endif |
---|
1655 | if ( rpcSlice->getSliceType() == B_SLICE ) |
---|
1656 | { |
---|
1657 | READ_FLAG( uiCode, "collocated_from_l0_flag" ); |
---|
1658 | rpcSlice->setColFromL0Flag(uiCode); |
---|
1659 | } |
---|
1660 | else |
---|
1661 | { |
---|
1662 | rpcSlice->setColFromL0Flag( 1 ); |
---|
1663 | } |
---|
1664 | |
---|
1665 | if ( rpcSlice->getSliceType() != I_SLICE && |
---|
1666 | ((rpcSlice->getColFromL0Flag() == 1 && rpcSlice->getNumRefIdx(REF_PIC_LIST_0) > 1)|| |
---|
1667 | (rpcSlice->getColFromL0Flag() == 0 && rpcSlice->getNumRefIdx(REF_PIC_LIST_1) > 1))) |
---|
1668 | { |
---|
1669 | READ_UVLC( uiCode, "collocated_ref_idx" ); |
---|
1670 | rpcSlice->setColRefIdx(uiCode); |
---|
1671 | } |
---|
1672 | else |
---|
1673 | { |
---|
1674 | rpcSlice->setColRefIdx(0); |
---|
1675 | } |
---|
1676 | #if REF_IDX_FRAMEWORK && M0457_COL_PICTURE_SIGNALING && !REMOVE_COL_PICTURE_SIGNALING |
---|
1677 | } |
---|
1678 | #endif |
---|
1679 | } |
---|
1680 | if ( (pps->getUseWP() && rpcSlice->getSliceType()==P_SLICE) || (pps->getWPBiPred() && rpcSlice->getSliceType()==B_SLICE) ) |
---|
1681 | { |
---|
1682 | xParsePredWeightTable(rpcSlice); |
---|
1683 | rpcSlice->initWpScaling(); |
---|
1684 | } |
---|
1685 | if (!rpcSlice->isIntra()) |
---|
1686 | { |
---|
1687 | READ_UVLC( uiCode, "five_minus_max_num_merge_cand"); |
---|
1688 | rpcSlice->setMaxNumMergeCand(MRG_MAX_NUM_CANDS - uiCode); |
---|
1689 | } |
---|
1690 | |
---|
1691 | READ_SVLC( iCode, "slice_qp_delta" ); |
---|
1692 | rpcSlice->setSliceQp (26 + pps->getPicInitQPMinus26() + iCode); |
---|
1693 | |
---|
1694 | assert( rpcSlice->getSliceQp() >= -sps->getQpBDOffsetY() ); |
---|
1695 | assert( rpcSlice->getSliceQp() <= 51 ); |
---|
1696 | |
---|
1697 | if (rpcSlice->getPPS()->getSliceChromaQpFlag()) |
---|
1698 | { |
---|
1699 | READ_SVLC( iCode, "slice_qp_delta_cb" ); |
---|
1700 | rpcSlice->setSliceQpDeltaCb( iCode ); |
---|
1701 | assert( rpcSlice->getSliceQpDeltaCb() >= -12 ); |
---|
1702 | assert( rpcSlice->getSliceQpDeltaCb() <= 12 ); |
---|
1703 | assert( (rpcSlice->getPPS()->getChromaCbQpOffset() + rpcSlice->getSliceQpDeltaCb()) >= -12 ); |
---|
1704 | assert( (rpcSlice->getPPS()->getChromaCbQpOffset() + rpcSlice->getSliceQpDeltaCb()) <= 12 ); |
---|
1705 | |
---|
1706 | READ_SVLC( iCode, "slice_qp_delta_cr" ); |
---|
1707 | rpcSlice->setSliceQpDeltaCr( iCode ); |
---|
1708 | assert( rpcSlice->getSliceQpDeltaCr() >= -12 ); |
---|
1709 | assert( rpcSlice->getSliceQpDeltaCr() <= 12 ); |
---|
1710 | assert( (rpcSlice->getPPS()->getChromaCrQpOffset() + rpcSlice->getSliceQpDeltaCr()) >= -12 ); |
---|
1711 | assert( (rpcSlice->getPPS()->getChromaCrQpOffset() + rpcSlice->getSliceQpDeltaCr()) <= 12 ); |
---|
1712 | } |
---|
1713 | |
---|
1714 | if (rpcSlice->getPPS()->getDeblockingFilterControlPresentFlag()) |
---|
1715 | { |
---|
1716 | if(rpcSlice->getPPS()->getDeblockingFilterOverrideEnabledFlag()) |
---|
1717 | { |
---|
1718 | READ_FLAG ( uiCode, "deblocking_filter_override_flag" ); rpcSlice->setDeblockingFilterOverrideFlag(uiCode ? true : false); |
---|
1719 | } |
---|
1720 | else |
---|
1721 | { |
---|
1722 | rpcSlice->setDeblockingFilterOverrideFlag(0); |
---|
1723 | } |
---|
1724 | if(rpcSlice->getDeblockingFilterOverrideFlag()) |
---|
1725 | { |
---|
1726 | READ_FLAG ( uiCode, "slice_disable_deblocking_filter_flag" ); rpcSlice->setDeblockingFilterDisable(uiCode ? 1 : 0); |
---|
1727 | if(!rpcSlice->getDeblockingFilterDisable()) |
---|
1728 | { |
---|
1729 | READ_SVLC( iCode, "slice_beta_offset_div2" ); rpcSlice->setDeblockingFilterBetaOffsetDiv2(iCode); |
---|
1730 | assert(rpcSlice->getDeblockingFilterBetaOffsetDiv2() >= -6 && |
---|
1731 | rpcSlice->getDeblockingFilterBetaOffsetDiv2() <= 6); |
---|
1732 | READ_SVLC( iCode, "slice_tc_offset_div2" ); rpcSlice->setDeblockingFilterTcOffsetDiv2(iCode); |
---|
1733 | assert(rpcSlice->getDeblockingFilterTcOffsetDiv2() >= -6 && |
---|
1734 | rpcSlice->getDeblockingFilterTcOffsetDiv2() <= 6); |
---|
1735 | } |
---|
1736 | } |
---|
1737 | else |
---|
1738 | { |
---|
1739 | rpcSlice->setDeblockingFilterDisable ( rpcSlice->getPPS()->getPicDisableDeblockingFilterFlag() ); |
---|
1740 | rpcSlice->setDeblockingFilterBetaOffsetDiv2( rpcSlice->getPPS()->getDeblockingFilterBetaOffsetDiv2() ); |
---|
1741 | rpcSlice->setDeblockingFilterTcOffsetDiv2 ( rpcSlice->getPPS()->getDeblockingFilterTcOffsetDiv2() ); |
---|
1742 | } |
---|
1743 | } |
---|
1744 | else |
---|
1745 | { |
---|
1746 | rpcSlice->setDeblockingFilterDisable ( false ); |
---|
1747 | rpcSlice->setDeblockingFilterBetaOffsetDiv2( 0 ); |
---|
1748 | rpcSlice->setDeblockingFilterTcOffsetDiv2 ( 0 ); |
---|
1749 | } |
---|
1750 | |
---|
1751 | Bool isSAOEnabled = (!rpcSlice->getSPS()->getUseSAO())?(false):(rpcSlice->getSaoEnabledFlag()||rpcSlice->getSaoEnabledFlagChroma()); |
---|
1752 | Bool isDBFEnabled = (!rpcSlice->getDeblockingFilterDisable()); |
---|
1753 | |
---|
1754 | if(rpcSlice->getPPS()->getLoopFilterAcrossSlicesEnabledFlag() && ( isSAOEnabled || isDBFEnabled )) |
---|
1755 | { |
---|
1756 | READ_FLAG( uiCode, "slice_loop_filter_across_slices_enabled_flag"); |
---|
1757 | } |
---|
1758 | else |
---|
1759 | { |
---|
1760 | uiCode = rpcSlice->getPPS()->getLoopFilterAcrossSlicesEnabledFlag()?1:0; |
---|
1761 | } |
---|
1762 | rpcSlice->setLFCrossSliceBoundaryFlag( (uiCode==1)?true:false); |
---|
1763 | |
---|
1764 | } |
---|
1765 | |
---|
1766 | UInt *entryPointOffset = NULL; |
---|
1767 | UInt numEntryPointOffsets, offsetLenMinus1; |
---|
1768 | if( pps->getTilesEnabledFlag() || pps->getEntropyCodingSyncEnabledFlag() ) |
---|
1769 | { |
---|
1770 | READ_UVLC(numEntryPointOffsets, "num_entry_point_offsets"); rpcSlice->setNumEntryPointOffsets ( numEntryPointOffsets ); |
---|
1771 | if (numEntryPointOffsets>0) |
---|
1772 | { |
---|
1773 | READ_UVLC(offsetLenMinus1, "offset_len_minus1"); |
---|
1774 | } |
---|
1775 | entryPointOffset = new UInt[numEntryPointOffsets]; |
---|
1776 | for (UInt idx=0; idx<numEntryPointOffsets; idx++) |
---|
1777 | { |
---|
1778 | READ_CODE(offsetLenMinus1+1, uiCode, "entry_point_offset_minus1"); |
---|
1779 | entryPointOffset[ idx ] = uiCode + 1; |
---|
1780 | } |
---|
1781 | } |
---|
1782 | else |
---|
1783 | { |
---|
1784 | rpcSlice->setNumEntryPointOffsets ( 0 ); |
---|
1785 | } |
---|
1786 | |
---|
1787 | if(pps->getSliceHeaderExtensionPresentFlag()) |
---|
1788 | { |
---|
1789 | READ_UVLC(uiCode,"slice_header_extension_length"); |
---|
1790 | for(Int i=0; i<uiCode; i++) |
---|
1791 | { |
---|
1792 | UInt ignore; |
---|
1793 | READ_CODE(8,ignore,"slice_header_extension_data_byte"); |
---|
1794 | } |
---|
1795 | } |
---|
1796 | m_pcBitstream->readByteAlignment(); |
---|
1797 | |
---|
1798 | if( pps->getTilesEnabledFlag() || pps->getEntropyCodingSyncEnabledFlag() ) |
---|
1799 | { |
---|
1800 | Int endOfSliceHeaderLocation = m_pcBitstream->getByteLocation(); |
---|
1801 | |
---|
1802 | // Adjust endOfSliceHeaderLocation to account for emulation prevention bytes in the slice segment header |
---|
1803 | for ( UInt curByteIdx = 0; curByteIdx<m_pcBitstream->numEmulationPreventionBytesRead(); curByteIdx++ ) |
---|
1804 | { |
---|
1805 | if ( m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) < endOfSliceHeaderLocation ) |
---|
1806 | { |
---|
1807 | endOfSliceHeaderLocation++; |
---|
1808 | } |
---|
1809 | } |
---|
1810 | |
---|
1811 | Int curEntryPointOffset = 0; |
---|
1812 | Int prevEntryPointOffset = 0; |
---|
1813 | for (UInt idx=0; idx<numEntryPointOffsets; idx++) |
---|
1814 | { |
---|
1815 | curEntryPointOffset += entryPointOffset[ idx ]; |
---|
1816 | |
---|
1817 | Int emulationPreventionByteCount = 0; |
---|
1818 | for ( UInt curByteIdx = 0; curByteIdx<m_pcBitstream->numEmulationPreventionBytesRead(); curByteIdx++ ) |
---|
1819 | { |
---|
1820 | if ( m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) >= ( prevEntryPointOffset + endOfSliceHeaderLocation ) && |
---|
1821 | m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) < ( curEntryPointOffset + endOfSliceHeaderLocation ) ) |
---|
1822 | { |
---|
1823 | emulationPreventionByteCount++; |
---|
1824 | } |
---|
1825 | } |
---|
1826 | |
---|
1827 | entryPointOffset[ idx ] -= emulationPreventionByteCount; |
---|
1828 | prevEntryPointOffset = curEntryPointOffset; |
---|
1829 | } |
---|
1830 | |
---|
1831 | if ( pps->getTilesEnabledFlag() ) |
---|
1832 | { |
---|
1833 | rpcSlice->setTileLocationCount( numEntryPointOffsets ); |
---|
1834 | |
---|
1835 | UInt prevPos = 0; |
---|
1836 | for (Int idx=0; idx<rpcSlice->getTileLocationCount(); idx++) |
---|
1837 | { |
---|
1838 | rpcSlice->setTileLocation( idx, prevPos + entryPointOffset [ idx ] ); |
---|
1839 | prevPos += entryPointOffset[ idx ]; |
---|
1840 | } |
---|
1841 | } |
---|
1842 | else if ( pps->getEntropyCodingSyncEnabledFlag() ) |
---|
1843 | { |
---|
1844 | Int numSubstreams = rpcSlice->getNumEntryPointOffsets()+1; |
---|
1845 | rpcSlice->allocSubstreamSizes(numSubstreams); |
---|
1846 | UInt *pSubstreamSizes = rpcSlice->getSubstreamSizes(); |
---|
1847 | for (Int idx=0; idx<numSubstreams-1; idx++) |
---|
1848 | { |
---|
1849 | if ( idx < numEntryPointOffsets ) |
---|
1850 | { |
---|
1851 | pSubstreamSizes[ idx ] = ( entryPointOffset[ idx ] << 3 ) ; |
---|
1852 | } |
---|
1853 | else |
---|
1854 | { |
---|
1855 | pSubstreamSizes[ idx ] = 0; |
---|
1856 | } |
---|
1857 | } |
---|
1858 | } |
---|
1859 | |
---|
1860 | if (entryPointOffset) |
---|
1861 | { |
---|
1862 | delete [] entryPointOffset; |
---|
1863 | } |
---|
1864 | } |
---|
1865 | |
---|
1866 | return; |
---|
1867 | } |
---|
1868 | |
---|
1869 | Void TDecCavlc::parsePTL( TComPTL *rpcPTL, Bool profilePresentFlag, Int maxNumSubLayersMinus1 ) |
---|
1870 | { |
---|
1871 | UInt uiCode; |
---|
1872 | if(profilePresentFlag) |
---|
1873 | { |
---|
1874 | parseProfileTier(rpcPTL->getGeneralPTL()); |
---|
1875 | } |
---|
1876 | READ_CODE( 8, uiCode, "general_level_idc" ); rpcPTL->getGeneralPTL()->setLevelIdc(uiCode); |
---|
1877 | |
---|
1878 | for (Int i = 0; i < maxNumSubLayersMinus1; i++) |
---|
1879 | { |
---|
1880 | if(profilePresentFlag) |
---|
1881 | { |
---|
1882 | READ_FLAG( uiCode, "sub_layer_profile_present_flag[i]" ); rpcPTL->setSubLayerProfilePresentFlag(i, uiCode); |
---|
1883 | } |
---|
1884 | READ_FLAG( uiCode, "sub_layer_level_present_flag[i]" ); rpcPTL->setSubLayerLevelPresentFlag (i, uiCode); |
---|
1885 | } |
---|
1886 | |
---|
1887 | if (maxNumSubLayersMinus1 > 0) |
---|
1888 | { |
---|
1889 | for (Int i = maxNumSubLayersMinus1; i < 8; i++) |
---|
1890 | { |
---|
1891 | READ_CODE(2, uiCode, "reserved_zero_2bits"); |
---|
1892 | assert(uiCode == 0); |
---|
1893 | } |
---|
1894 | } |
---|
1895 | |
---|
1896 | for(Int i = 0; i < maxNumSubLayersMinus1; i++) |
---|
1897 | { |
---|
1898 | if( profilePresentFlag && rpcPTL->getSubLayerProfilePresentFlag(i) ) |
---|
1899 | { |
---|
1900 | parseProfileTier(rpcPTL->getSubLayerPTL(i)); |
---|
1901 | } |
---|
1902 | if(rpcPTL->getSubLayerLevelPresentFlag(i)) |
---|
1903 | { |
---|
1904 | READ_CODE( 8, uiCode, "sub_layer_level_idc[i]" ); rpcPTL->getSubLayerPTL(i)->setLevelIdc(uiCode); |
---|
1905 | } |
---|
1906 | } |
---|
1907 | } |
---|
1908 | |
---|
1909 | Void TDecCavlc::parseProfileTier(ProfileTierLevel *ptl) |
---|
1910 | { |
---|
1911 | UInt uiCode; |
---|
1912 | READ_CODE(2 , uiCode, "XXX_profile_space[]"); ptl->setProfileSpace(uiCode); |
---|
1913 | READ_FLAG( uiCode, "XXX_tier_flag[]" ); ptl->setTierFlag (uiCode ? 1 : 0); |
---|
1914 | READ_CODE(5 , uiCode, "XXX_profile_idc[]" ); ptl->setProfileIdc (uiCode); |
---|
1915 | for(Int j = 0; j < 32; j++) |
---|
1916 | { |
---|
1917 | READ_FLAG( uiCode, "XXX_profile_compatibility_flag[][j]"); ptl->setProfileCompatibilityFlag(j, uiCode ? 1 : 0); |
---|
1918 | } |
---|
1919 | READ_FLAG(uiCode, "general_progressive_source_flag"); |
---|
1920 | ptl->setProgressiveSourceFlag(uiCode ? true : false); |
---|
1921 | |
---|
1922 | READ_FLAG(uiCode, "general_interlaced_source_flag"); |
---|
1923 | ptl->setInterlacedSourceFlag(uiCode ? true : false); |
---|
1924 | |
---|
1925 | READ_FLAG(uiCode, "general_non_packed_constraint_flag"); |
---|
1926 | ptl->setNonPackedConstraintFlag(uiCode ? true : false); |
---|
1927 | |
---|
1928 | READ_FLAG(uiCode, "general_frame_only_constraint_flag"); |
---|
1929 | ptl->setFrameOnlyConstraintFlag(uiCode ? true : false); |
---|
1930 | |
---|
1931 | READ_CODE(16, uiCode, "XXX_reserved_zero_44bits[0..15]"); |
---|
1932 | READ_CODE(16, uiCode, "XXX_reserved_zero_44bits[16..31]"); |
---|
1933 | READ_CODE(12, uiCode, "XXX_reserved_zero_44bits[32..43]"); |
---|
1934 | } |
---|
1935 | |
---|
1936 | Void TDecCavlc::parseTerminatingBit( UInt& ruiBit ) |
---|
1937 | { |
---|
1938 | ruiBit = false; |
---|
1939 | Int iBitsLeft = m_pcBitstream->getNumBitsLeft(); |
---|
1940 | if(iBitsLeft <= 8) |
---|
1941 | { |
---|
1942 | UInt uiPeekValue = m_pcBitstream->peekBits(iBitsLeft); |
---|
1943 | if (uiPeekValue == (1<<(iBitsLeft-1))) |
---|
1944 | { |
---|
1945 | ruiBit = true; |
---|
1946 | } |
---|
1947 | } |
---|
1948 | } |
---|
1949 | |
---|
1950 | Void TDecCavlc::parseSkipFlag( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
1951 | { |
---|
1952 | assert(0); |
---|
1953 | } |
---|
1954 | |
---|
1955 | Void TDecCavlc::parseCUTransquantBypassFlag( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
1956 | { |
---|
1957 | assert(0); |
---|
1958 | } |
---|
1959 | |
---|
1960 | Void TDecCavlc::parseMVPIdx( Int& /*riMVPIdx*/ ) |
---|
1961 | { |
---|
1962 | assert(0); |
---|
1963 | } |
---|
1964 | |
---|
1965 | Void TDecCavlc::parseSplitFlag ( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
1966 | { |
---|
1967 | assert(0); |
---|
1968 | } |
---|
1969 | |
---|
1970 | Void TDecCavlc::parsePartSize( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
1971 | { |
---|
1972 | assert(0); |
---|
1973 | } |
---|
1974 | |
---|
1975 | Void TDecCavlc::parsePredMode( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
1976 | { |
---|
1977 | assert(0); |
---|
1978 | } |
---|
1979 | |
---|
1980 | /** Parse I_PCM information. |
---|
1981 | * \param pcCU pointer to CU |
---|
1982 | * \param uiAbsPartIdx CU index |
---|
1983 | * \param uiDepth CU depth |
---|
1984 | * \returns Void |
---|
1985 | * |
---|
1986 | * If I_PCM flag indicates that the CU is I_PCM, parse its PCM alignment bits and codes. |
---|
1987 | */ |
---|
1988 | Void TDecCavlc::parseIPCMInfo( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
1989 | { |
---|
1990 | assert(0); |
---|
1991 | } |
---|
1992 | |
---|
1993 | Void TDecCavlc::parseIntraDirLumaAng ( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
1994 | { |
---|
1995 | assert(0); |
---|
1996 | } |
---|
1997 | |
---|
1998 | Void TDecCavlc::parseIntraDirChroma( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
1999 | { |
---|
2000 | assert(0); |
---|
2001 | } |
---|
2002 | |
---|
2003 | Void TDecCavlc::parseInterDir( TComDataCU* /*pcCU*/, UInt& /*ruiInterDir*/, UInt /*uiAbsPartIdx*/ ) |
---|
2004 | { |
---|
2005 | assert(0); |
---|
2006 | } |
---|
2007 | |
---|
2008 | Void TDecCavlc::parseRefFrmIdx( TComDataCU* /*pcCU*/, Int& /*riRefFrmIdx*/, RefPicList /*eRefList*/ ) |
---|
2009 | { |
---|
2010 | assert(0); |
---|
2011 | } |
---|
2012 | |
---|
2013 | Void TDecCavlc::parseMvd( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiPartIdx*/, UInt /*uiDepth*/, RefPicList /*eRefList*/ ) |
---|
2014 | { |
---|
2015 | assert(0); |
---|
2016 | } |
---|
2017 | |
---|
2018 | Void TDecCavlc::parseDeltaQP( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2019 | { |
---|
2020 | Int qp; |
---|
2021 | Int iDQp; |
---|
2022 | |
---|
2023 | xReadSvlc( iDQp ); |
---|
2024 | |
---|
2025 | Int qpBdOffsetY = pcCU->getSlice()->getSPS()->getQpBDOffsetY(); |
---|
2026 | qp = (((Int) pcCU->getRefQP( uiAbsPartIdx ) + iDQp + 52 + 2*qpBdOffsetY )%(52+ qpBdOffsetY)) - qpBdOffsetY; |
---|
2027 | |
---|
2028 | UInt uiAbsQpCUPartIdx = (uiAbsPartIdx>>((g_uiMaxCUDepth - pcCU->getSlice()->getPPS()->getMaxCuDQPDepth())<<1))<<((g_uiMaxCUDepth - pcCU->getSlice()->getPPS()->getMaxCuDQPDepth())<<1) ; |
---|
2029 | UInt uiQpCUDepth = min(uiDepth,pcCU->getSlice()->getPPS()->getMaxCuDQPDepth()) ; |
---|
2030 | |
---|
2031 | pcCU->setQPSubParts( qp, uiAbsQpCUPartIdx, uiQpCUDepth ); |
---|
2032 | } |
---|
2033 | |
---|
2034 | Void TDecCavlc::parseCoeffNxN( TComDataCU* /*pcCU*/, TCoeff* /*pcCoef*/, UInt /*uiAbsPartIdx*/, UInt /*uiWidth*/, UInt /*uiHeight*/, UInt /*uiDepth*/, TextType /*eTType*/ ) |
---|
2035 | { |
---|
2036 | assert(0); |
---|
2037 | } |
---|
2038 | |
---|
2039 | Void TDecCavlc::parseTransformSubdivFlag( UInt& /*ruiSubdivFlag*/, UInt /*uiLog2TransformBlockSize*/ ) |
---|
2040 | { |
---|
2041 | assert(0); |
---|
2042 | } |
---|
2043 | |
---|
2044 | Void TDecCavlc::parseQtCbf( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, TextType /*eType*/, UInt /*uiTrDepth*/, UInt /*uiDepth*/ ) |
---|
2045 | { |
---|
2046 | assert(0); |
---|
2047 | } |
---|
2048 | |
---|
2049 | Void TDecCavlc::parseQtRootCbf( UInt /*uiAbsPartIdx*/, UInt& /*uiQtRootCbf*/ ) |
---|
2050 | { |
---|
2051 | assert(0); |
---|
2052 | } |
---|
2053 | |
---|
2054 | Void TDecCavlc::parseTransformSkipFlags (TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*width*/, UInt /*height*/, UInt /*uiDepth*/, TextType /*eTType*/) |
---|
2055 | { |
---|
2056 | assert(0); |
---|
2057 | } |
---|
2058 | |
---|
2059 | Void TDecCavlc::parseMergeFlag ( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/, UInt /*uiPUIdx*/ ) |
---|
2060 | { |
---|
2061 | assert(0); |
---|
2062 | } |
---|
2063 | |
---|
2064 | Void TDecCavlc::parseMergeIndex ( TComDataCU* /*pcCU*/, UInt& /*ruiMergeIndex*/ ) |
---|
2065 | { |
---|
2066 | assert(0); |
---|
2067 | } |
---|
2068 | |
---|
2069 | // ==================================================================================================================== |
---|
2070 | // Protected member functions |
---|
2071 | // ==================================================================================================================== |
---|
2072 | |
---|
2073 | /** parse explicit wp tables |
---|
2074 | * \param TComSlice* pcSlice |
---|
2075 | * \returns Void |
---|
2076 | */ |
---|
2077 | Void TDecCavlc::xParsePredWeightTable( TComSlice* pcSlice ) |
---|
2078 | { |
---|
2079 | wpScalingParam *wp; |
---|
2080 | Bool bChroma = true; // color always present in HEVC ? |
---|
2081 | SliceType eSliceType = pcSlice->getSliceType(); |
---|
2082 | Int iNbRef = (eSliceType == B_SLICE ) ? (2) : (1); |
---|
2083 | UInt uiLog2WeightDenomLuma, uiLog2WeightDenomChroma; |
---|
2084 | UInt uiTotalSignalledWeightFlags = 0; |
---|
2085 | |
---|
2086 | Int iDeltaDenom; |
---|
2087 | // decode delta_luma_log2_weight_denom : |
---|
2088 | READ_UVLC( uiLog2WeightDenomLuma, "luma_log2_weight_denom" ); // ue(v): luma_log2_weight_denom |
---|
2089 | assert( uiLog2WeightDenomLuma <= 7 ); |
---|
2090 | if( bChroma ) |
---|
2091 | { |
---|
2092 | READ_SVLC( iDeltaDenom, "delta_chroma_log2_weight_denom" ); // se(v): delta_chroma_log2_weight_denom |
---|
2093 | assert((iDeltaDenom + (Int)uiLog2WeightDenomLuma)>=0); |
---|
2094 | assert((iDeltaDenom + (Int)uiLog2WeightDenomLuma)<=7); |
---|
2095 | uiLog2WeightDenomChroma = (UInt)(iDeltaDenom + uiLog2WeightDenomLuma); |
---|
2096 | } |
---|
2097 | |
---|
2098 | for ( Int iNumRef=0 ; iNumRef<iNbRef ; iNumRef++ ) |
---|
2099 | { |
---|
2100 | RefPicList eRefPicList = ( iNumRef ? REF_PIC_LIST_1 : REF_PIC_LIST_0 ); |
---|
2101 | for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ ) |
---|
2102 | { |
---|
2103 | pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); |
---|
2104 | |
---|
2105 | wp[0].uiLog2WeightDenom = uiLog2WeightDenomLuma; |
---|
2106 | wp[1].uiLog2WeightDenom = uiLog2WeightDenomChroma; |
---|
2107 | wp[2].uiLog2WeightDenom = uiLog2WeightDenomChroma; |
---|
2108 | |
---|
2109 | UInt uiCode; |
---|
2110 | READ_FLAG( uiCode, "luma_weight_lX_flag" ); // u(1): luma_weight_l0_flag |
---|
2111 | wp[0].bPresentFlag = ( uiCode == 1 ); |
---|
2112 | uiTotalSignalledWeightFlags += wp[0].bPresentFlag; |
---|
2113 | } |
---|
2114 | if ( bChroma ) |
---|
2115 | { |
---|
2116 | UInt uiCode; |
---|
2117 | for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ ) |
---|
2118 | { |
---|
2119 | pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); |
---|
2120 | READ_FLAG( uiCode, "chroma_weight_lX_flag" ); // u(1): chroma_weight_l0_flag |
---|
2121 | wp[1].bPresentFlag = ( uiCode == 1 ); |
---|
2122 | wp[2].bPresentFlag = ( uiCode == 1 ); |
---|
2123 | uiTotalSignalledWeightFlags += 2*wp[1].bPresentFlag; |
---|
2124 | } |
---|
2125 | } |
---|
2126 | for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ ) |
---|
2127 | { |
---|
2128 | pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); |
---|
2129 | if ( wp[0].bPresentFlag ) |
---|
2130 | { |
---|
2131 | Int iDeltaWeight; |
---|
2132 | READ_SVLC( iDeltaWeight, "delta_luma_weight_lX" ); // se(v): delta_luma_weight_l0[i] |
---|
2133 | assert( iDeltaWeight >= -128 ); |
---|
2134 | assert( iDeltaWeight <= 127 ); |
---|
2135 | wp[0].iWeight = (iDeltaWeight + (1<<wp[0].uiLog2WeightDenom)); |
---|
2136 | READ_SVLC( wp[0].iOffset, "luma_offset_lX" ); // se(v): luma_offset_l0[i] |
---|
2137 | assert( wp[0].iOffset >= -128 ); |
---|
2138 | assert( wp[0].iOffset <= 127 ); |
---|
2139 | } |
---|
2140 | else |
---|
2141 | { |
---|
2142 | wp[0].iWeight = (1 << wp[0].uiLog2WeightDenom); |
---|
2143 | wp[0].iOffset = 0; |
---|
2144 | } |
---|
2145 | if ( bChroma ) |
---|
2146 | { |
---|
2147 | if ( wp[1].bPresentFlag ) |
---|
2148 | { |
---|
2149 | for ( Int j=1 ; j<3 ; j++ ) |
---|
2150 | { |
---|
2151 | Int iDeltaWeight; |
---|
2152 | READ_SVLC( iDeltaWeight, "delta_chroma_weight_lX" ); // se(v): chroma_weight_l0[i][j] |
---|
2153 | assert( iDeltaWeight >= -128 ); |
---|
2154 | assert( iDeltaWeight <= 127 ); |
---|
2155 | wp[j].iWeight = (iDeltaWeight + (1<<wp[1].uiLog2WeightDenom)); |
---|
2156 | |
---|
2157 | Int iDeltaChroma; |
---|
2158 | READ_SVLC( iDeltaChroma, "delta_chroma_offset_lX" ); // se(v): delta_chroma_offset_l0[i][j] |
---|
2159 | assert( iDeltaChroma >= -512 ); |
---|
2160 | assert( iDeltaChroma <= 511 ); |
---|
2161 | Int pred = ( 128 - ( ( 128*wp[j].iWeight)>>(wp[j].uiLog2WeightDenom) ) ); |
---|
2162 | wp[j].iOffset = Clip3(-128, 127, (iDeltaChroma + pred) ); |
---|
2163 | } |
---|
2164 | } |
---|
2165 | else |
---|
2166 | { |
---|
2167 | for ( Int j=1 ; j<3 ; j++ ) |
---|
2168 | { |
---|
2169 | wp[j].iWeight = (1 << wp[j].uiLog2WeightDenom); |
---|
2170 | wp[j].iOffset = 0; |
---|
2171 | } |
---|
2172 | } |
---|
2173 | } |
---|
2174 | } |
---|
2175 | |
---|
2176 | for ( Int iRefIdx=pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx<MAX_NUM_REF ; iRefIdx++ ) |
---|
2177 | { |
---|
2178 | pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); |
---|
2179 | |
---|
2180 | wp[0].bPresentFlag = false; |
---|
2181 | wp[1].bPresentFlag = false; |
---|
2182 | wp[2].bPresentFlag = false; |
---|
2183 | } |
---|
2184 | } |
---|
2185 | assert(uiTotalSignalledWeightFlags<=24); |
---|
2186 | } |
---|
2187 | |
---|
2188 | /** decode quantization matrix |
---|
2189 | * \param scalingList quantization matrix information |
---|
2190 | */ |
---|
2191 | Void TDecCavlc::parseScalingList(TComScalingList* scalingList) |
---|
2192 | { |
---|
2193 | UInt code, sizeId, listId; |
---|
2194 | Bool scalingListPredModeFlag; |
---|
2195 | //for each size |
---|
2196 | for(sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
2197 | { |
---|
2198 | for(listId = 0; listId < g_scalingListNum[sizeId]; listId++) |
---|
2199 | { |
---|
2200 | READ_FLAG( code, "scaling_list_pred_mode_flag"); |
---|
2201 | scalingListPredModeFlag = (code) ? true : false; |
---|
2202 | if(!scalingListPredModeFlag) //Copy Mode |
---|
2203 | { |
---|
2204 | READ_UVLC( code, "scaling_list_pred_matrix_id_delta"); |
---|
2205 | scalingList->setRefMatrixId (sizeId,listId,(UInt)((Int)(listId)-(code))); |
---|
2206 | if( sizeId > SCALING_LIST_8x8 ) |
---|
2207 | { |
---|
2208 | scalingList->setScalingListDC(sizeId,listId,((listId == scalingList->getRefMatrixId (sizeId,listId))? 16 :scalingList->getScalingListDC(sizeId, scalingList->getRefMatrixId (sizeId,listId)))); |
---|
2209 | } |
---|
2210 | scalingList->processRefMatrix( sizeId, listId, scalingList->getRefMatrixId (sizeId,listId)); |
---|
2211 | |
---|
2212 | } |
---|
2213 | else //DPCM Mode |
---|
2214 | { |
---|
2215 | xDecodeScalingList(scalingList, sizeId, listId); |
---|
2216 | } |
---|
2217 | } |
---|
2218 | } |
---|
2219 | |
---|
2220 | return; |
---|
2221 | } |
---|
2222 | /** decode DPCM |
---|
2223 | * \param scalingList quantization matrix information |
---|
2224 | * \param sizeId size index |
---|
2225 | * \param listId list index |
---|
2226 | */ |
---|
2227 | Void TDecCavlc::xDecodeScalingList(TComScalingList *scalingList, UInt sizeId, UInt listId) |
---|
2228 | { |
---|
2229 | Int i,coefNum = min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId]); |
---|
2230 | Int data; |
---|
2231 | Int scalingListDcCoefMinus8 = 0; |
---|
2232 | Int nextCoef = SCALING_LIST_START_VALUE; |
---|
2233 | UInt* scan = (sizeId == 0) ? g_auiSigLastScan [ SCAN_DIAG ] [ 1 ] : g_sigLastScanCG32x32; |
---|
2234 | Int *dst = scalingList->getScalingListAddress(sizeId, listId); |
---|
2235 | |
---|
2236 | if( sizeId > SCALING_LIST_8x8 ) |
---|
2237 | { |
---|
2238 | READ_SVLC( scalingListDcCoefMinus8, "scaling_list_dc_coef_minus8"); |
---|
2239 | scalingList->setScalingListDC(sizeId,listId,scalingListDcCoefMinus8 + 8); |
---|
2240 | nextCoef = scalingList->getScalingListDC(sizeId,listId); |
---|
2241 | } |
---|
2242 | |
---|
2243 | for(i = 0; i < coefNum; i++) |
---|
2244 | { |
---|
2245 | READ_SVLC( data, "scaling_list_delta_coef"); |
---|
2246 | nextCoef = (nextCoef + data + 256 ) % 256; |
---|
2247 | dst[scan[i]] = nextCoef; |
---|
2248 | } |
---|
2249 | } |
---|
2250 | |
---|
2251 | Bool TDecCavlc::xMoreRbspData() |
---|
2252 | { |
---|
2253 | Int bitsLeft = m_pcBitstream->getNumBitsLeft(); |
---|
2254 | |
---|
2255 | // if there are more than 8 bits, it cannot be rbsp_trailing_bits |
---|
2256 | if (bitsLeft > 8) |
---|
2257 | { |
---|
2258 | return true; |
---|
2259 | } |
---|
2260 | |
---|
2261 | UChar lastByte = m_pcBitstream->peekBits(bitsLeft); |
---|
2262 | Int cnt = bitsLeft; |
---|
2263 | |
---|
2264 | // remove trailing bits equal to zero |
---|
2265 | while ((cnt>0) && ((lastByte & 1) == 0)) |
---|
2266 | { |
---|
2267 | lastByte >>= 1; |
---|
2268 | cnt--; |
---|
2269 | } |
---|
2270 | // remove bit equal to one |
---|
2271 | cnt--; |
---|
2272 | |
---|
2273 | // we should not have a negative number of bits |
---|
2274 | assert (cnt>=0); |
---|
2275 | |
---|
2276 | // we have more data, if cnt is not zero |
---|
2277 | return (cnt>0); |
---|
2278 | } |
---|
2279 | //! \} |
---|
2280 | |
---|