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