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 | while ( m_pcBitstream->getNumBitsRead() % 8 != 0 ) |
---|
849 | { |
---|
850 | READ_FLAG( uiCode, "vps_extension_alignment_bit_equal_to_one"); assert(uiCode == 1); |
---|
851 | } |
---|
852 | parseVPSExtension(pcVPS); |
---|
853 | READ_FLAG( uiCode, "vps_entension2_flag" ); |
---|
854 | if(uiCode) |
---|
855 | { |
---|
856 | while ( xMoreRbspData() ) |
---|
857 | { |
---|
858 | READ_FLAG( uiCode, "vps_extension_data_flag"); |
---|
859 | } |
---|
860 | } |
---|
861 | #else |
---|
862 | while ( xMoreRbspData() ) |
---|
863 | { |
---|
864 | READ_FLAG( uiCode, "vps_extension_data_flag"); |
---|
865 | } |
---|
866 | #endif |
---|
867 | } |
---|
868 | |
---|
869 | return; |
---|
870 | } |
---|
871 | |
---|
872 | #if VPS_EXTNS |
---|
873 | Void TDecCavlc::parseVPSExtension(TComVPS *vps) |
---|
874 | { |
---|
875 | UInt uiCode; |
---|
876 | // ... More syntax elements to be parsed here |
---|
877 | #if VPS_EXTN_MASK_AND_DIM_INFO |
---|
878 | UInt numScalabilityTypes = 0, i = 0, j = 0; |
---|
879 | |
---|
880 | READ_FLAG( uiCode, "avc_base_layer_flag" ); vps->setAvcBaseLayerFlag(uiCode ? true : false); |
---|
881 | READ_FLAG( uiCode, "splitting_flag" ); vps->setSplittingFlag(uiCode ? true : false); |
---|
882 | |
---|
883 | for(i = 0; i < MAX_VPS_NUM_SCALABILITY_TYPES; i++) |
---|
884 | { |
---|
885 | READ_FLAG( uiCode, "scalability_mask[i]" ); vps->setScalabilityMask(i, uiCode ? true : false); |
---|
886 | numScalabilityTypes += uiCode; |
---|
887 | } |
---|
888 | vps->setNumScalabilityTypes(numScalabilityTypes); |
---|
889 | |
---|
890 | #if VPS_SPLIT_FLAG |
---|
891 | for(j = 0; j < numScalabilityTypes - vps->getSplittingFlag(); j++) |
---|
892 | #else |
---|
893 | for(j = 0; j < numScalabilityTypes; j++) |
---|
894 | #endif |
---|
895 | { |
---|
896 | READ_CODE( 3, uiCode, "dimension_id_len_minus1[j]" ); vps->setDimensionIdLen(j, uiCode + 1); |
---|
897 | } |
---|
898 | #if VPS_SPLIT_FLAG |
---|
899 | if(vps->getSplittingFlag()) |
---|
900 | { |
---|
901 | UInt numBits = 0; |
---|
902 | for(j = 0; j < numScalabilityTypes - 1; j++) |
---|
903 | { |
---|
904 | numBits += vps->getDimensionIdLen(j); |
---|
905 | } |
---|
906 | assert( numBits < 6 ); |
---|
907 | vps->setDimensionIdLen(numScalabilityTypes-1, 6 - numBits); |
---|
908 | numBits = 6; |
---|
909 | } |
---|
910 | #else |
---|
911 | if(vps->getSplittingFlag()) |
---|
912 | { |
---|
913 | UInt numBits = 0; |
---|
914 | for(j = 0; j < numScalabilityTypes; j++) |
---|
915 | { |
---|
916 | numBits += vps->getDimensionIdLen(j); |
---|
917 | } |
---|
918 | assert( numBits <= 6 ); |
---|
919 | } |
---|
920 | #endif |
---|
921 | |
---|
922 | READ_FLAG( uiCode, "vps_nuh_layer_id_present_flag" ); vps->setNuhLayerIdPresentFlag(uiCode ? true : false); |
---|
923 | vps->setLayerIdInNuh(0, 0); |
---|
924 | vps->setLayerIdInVps(0, 0); |
---|
925 | for(i = 1; i < vps->getMaxLayers(); i++) |
---|
926 | { |
---|
927 | if( vps->getNuhLayerIdPresentFlag() ) |
---|
928 | { |
---|
929 | READ_CODE( 6, uiCode, "layer_id_in_nuh[i]" ); vps->setLayerIdInNuh(i, uiCode); |
---|
930 | assert( uiCode > vps->getLayerIdInNuh(i-1) ); |
---|
931 | } |
---|
932 | else |
---|
933 | { |
---|
934 | vps->setLayerIdInNuh(i, i); |
---|
935 | } |
---|
936 | vps->setLayerIdInVps(vps->getLayerIdInNuh(i), i); |
---|
937 | |
---|
938 | #if VPS_SPLIT_FLAG |
---|
939 | if(!vps->getSplittingFlag()) |
---|
940 | #endif |
---|
941 | for(j = 0; j < numScalabilityTypes; j++) |
---|
942 | { |
---|
943 | READ_CODE( vps->getDimensionIdLen(j), uiCode, "dimension_id[i][j]" ); vps->setDimensionId(i, j, uiCode); |
---|
944 | assert( uiCode <= vps->getMaxLayerId() ); |
---|
945 | } |
---|
946 | } |
---|
947 | #endif |
---|
948 | #if VPS_MOVE_DIR_DEPENDENCY_FLAG |
---|
949 | #if VPS_EXTN_DIRECT_REF_LAYERS |
---|
950 | // For layer 0 |
---|
951 | vps->setNumDirectRefLayers(0, 0); |
---|
952 | // For other layers |
---|
953 | for( Int layerCtr = 1; layerCtr <= vps->getMaxLayers() - 1; layerCtr++) |
---|
954 | { |
---|
955 | UInt numDirectRefLayers = 0; |
---|
956 | for( Int refLayerCtr = 0; refLayerCtr < layerCtr; refLayerCtr++) |
---|
957 | { |
---|
958 | READ_FLAG(uiCode, "direct_dependency_flag[i][j]" ); vps->setDirectDependencyFlag(layerCtr, refLayerCtr, uiCode? true : false); |
---|
959 | if(uiCode) |
---|
960 | { |
---|
961 | vps->setRefLayerId(layerCtr, numDirectRefLayers, refLayerCtr); |
---|
962 | numDirectRefLayers++; |
---|
963 | } |
---|
964 | } |
---|
965 | vps->setNumDirectRefLayers(layerCtr, numDirectRefLayers); |
---|
966 | } |
---|
967 | #endif |
---|
968 | #endif |
---|
969 | #if JCTVC_M0203_INTERLAYER_PRED_IDC |
---|
970 | #if N0120_MAX_TID_REF_PRESENT_FLAG |
---|
971 | READ_FLAG( uiCode, "max_tid_il_ref_pics_plus1_present_flag"); vps->setMaxTidIlRefPicsPlus1PresentFlag(uiCode ? true : false); |
---|
972 | if (vps->getMaxTidIlRefPicsPlus1PresentFlag()) |
---|
973 | { |
---|
974 | for(i = 0; i < vps->getMaxLayers() - 1; i++) |
---|
975 | { |
---|
976 | READ_CODE( 3, uiCode, "max_sublayer_for_ilp_plus1[i]" ); vps->setMaxSublayerForIlpPlus1(i, uiCode); |
---|
977 | assert( uiCode <= vps->getMaxTLayers()+ 1 ); |
---|
978 | } |
---|
979 | } |
---|
980 | else |
---|
981 | { |
---|
982 | for(i = 0; i < vps->getMaxLayers() - 1; i++) |
---|
983 | { |
---|
984 | vps->setMaxSublayerForIlpPlus1(i, 7); |
---|
985 | } |
---|
986 | } |
---|
987 | #else |
---|
988 | for(i = 0; i < vps->getMaxLayers() - 1; i++) |
---|
989 | { |
---|
990 | READ_CODE( 3, uiCode, "max_sublayer_for_ilp_plus1[i]" ); vps->setMaxSublayerForIlpPlus1(i, uiCode); |
---|
991 | assert( uiCode <= vps->getMaxTLayers() ); |
---|
992 | } |
---|
993 | #endif |
---|
994 | #endif |
---|
995 | #if ILP_SSH_SIG |
---|
996 | READ_FLAG( uiCode, "all_ref_layers_active_flag" ); vps->setIlpSshSignalingEnabledFlag(uiCode ? true : false); |
---|
997 | #endif |
---|
998 | #if VPS_EXTN_PROFILE_INFO |
---|
999 | // Profile-tier-level signalling |
---|
1000 | #if VPS_PROFILE_OUTPUT_LAYERS |
---|
1001 | READ_CODE( 10, uiCode, "vps_number_layer_sets_minus1" ); assert( uiCode == (vps->getNumLayerSets() - 1) ); |
---|
1002 | READ_CODE( 6, uiCode, "vps_num_profile_tier_level_minus1"); vps->setNumProfileTierLevel( uiCode + 1 ); |
---|
1003 | vps->getPTLForExtnPtr()->resize(vps->getNumProfileTierLevel()); |
---|
1004 | for(Int idx = 1; idx <= vps->getNumProfileTierLevel() - 1; idx++) |
---|
1005 | #else |
---|
1006 | vps->getPTLForExtnPtr()->resize(vps->getNumLayerSets()); |
---|
1007 | for(Int idx = 1; idx <= vps->getNumLayerSets() - 1; idx++) |
---|
1008 | #endif |
---|
1009 | { |
---|
1010 | READ_FLAG( uiCode, "vps_profile_present_flag[i]" ); vps->setProfilePresentFlag(idx, uiCode ? true : false); |
---|
1011 | if( !vps->getProfilePresentFlag(idx) ) |
---|
1012 | { |
---|
1013 | #if VPS_PROFILE_OUTPUT_LAYERS |
---|
1014 | READ_CODE( 6, uiCode, "profile_ref_minus1[i]" ); vps->setProfileLayerSetRef(idx, uiCode + 1); |
---|
1015 | #else |
---|
1016 | READ_UVLC( uiCode, "vps_profile_layer_set_ref_minus1[i]" ); vps->setProfileLayerSetRef(idx, uiCode + 1); |
---|
1017 | #endif |
---|
1018 | assert( vps->getProfileLayerSetRef(idx) < idx ); |
---|
1019 | // Copy profile information as indicated |
---|
1020 | vps->getPTLForExtn(idx)->copyProfileInfo( vps->getPTLForExtn( vps->getProfileLayerSetRef(idx) ) ); |
---|
1021 | } |
---|
1022 | parsePTL( vps->getPTLForExtn(idx), vps->getProfilePresentFlag(idx), vps->getMaxTLayers() - 1 ); |
---|
1023 | } |
---|
1024 | #endif |
---|
1025 | |
---|
1026 | #if VPS_PROFILE_OUTPUT_LAYERS |
---|
1027 | READ_FLAG( uiCode, "more_output_layer_sets_than_default_flag" ); vps->setMoreOutputLayerSetsThanDefaultFlag( uiCode ? true : false ); |
---|
1028 | Int numOutputLayerSets = 0; |
---|
1029 | if(! vps->getMoreOutputLayerSetsThanDefaultFlag() ) |
---|
1030 | { |
---|
1031 | numOutputLayerSets = vps->getNumLayerSets(); |
---|
1032 | } |
---|
1033 | else |
---|
1034 | { |
---|
1035 | READ_CODE( 10, uiCode, "num_add_output_layer_sets" ); vps->setNumAddOutputLayerSets( uiCode ); |
---|
1036 | numOutputLayerSets = vps->getNumLayerSets() + vps->getNumAddOutputLayerSets(); |
---|
1037 | } |
---|
1038 | if( numOutputLayerSets > 1 ) |
---|
1039 | { |
---|
1040 | READ_FLAG( uiCode, "default_one_target_output_layer_flag" ); vps->setDefaultOneTargetOutputLayerFlag( uiCode ? true : false ); |
---|
1041 | } |
---|
1042 | vps->setNumOutputLayerSets( numOutputLayerSets ); |
---|
1043 | |
---|
1044 | for(i = 1; i < numOutputLayerSets; i++) |
---|
1045 | { |
---|
1046 | if( i > (vps->getNumLayerSets() - 1) ) |
---|
1047 | { |
---|
1048 | Int numBits = 1; |
---|
1049 | while ((1 << numBits) < (vps->getNumLayerSets() - 1)) |
---|
1050 | { |
---|
1051 | numBits++; |
---|
1052 | } |
---|
1053 | READ_CODE( numBits, uiCode, "output_layer_set_idx_minus1"); vps->setOutputLayerSetIdx( i, uiCode + 1); |
---|
1054 | Int lsIdx = vps->getOutputLayerSetIdx(i); |
---|
1055 | for(j = 0; j < vps->getNumLayersInIdList(lsIdx) - 1; j++) |
---|
1056 | { |
---|
1057 | READ_FLAG( uiCode, "output_layer_flag[i][j]"); vps->setOutputLayerFlag(i, j, uiCode); |
---|
1058 | } |
---|
1059 | } |
---|
1060 | else |
---|
1061 | { |
---|
1062 | // i <= (vps->getNumLayerSets() - 1) |
---|
1063 | // Assign OutputLayerFlag depending on default_one_target_output_layer_flag |
---|
1064 | Int lsIdx = i; |
---|
1065 | if( vps->getDefaultOneTargetOutputLayerFlag() ) |
---|
1066 | { |
---|
1067 | for(j = 0; j < vps->getNumLayersInIdList(lsIdx); j++) |
---|
1068 | { |
---|
1069 | vps->setOutputLayerFlag(i, j, (j == (vps->getNumLayersInIdList(lsIdx)-1))); |
---|
1070 | } |
---|
1071 | } |
---|
1072 | else |
---|
1073 | { |
---|
1074 | for(j = 0; j < vps->getNumLayersInIdList(lsIdx); j++) |
---|
1075 | { |
---|
1076 | vps->setOutputLayerFlag(i, j, 1); |
---|
1077 | } |
---|
1078 | } |
---|
1079 | } |
---|
1080 | Int numBits = 1; |
---|
1081 | while ((1 << numBits) < (vps->getNumProfileTierLevel())) |
---|
1082 | { |
---|
1083 | numBits++; |
---|
1084 | } |
---|
1085 | READ_CODE( numBits, uiCode, "profile_level_tier_idx[i]" ); vps->setProfileLevelTierIdx(i, uiCode); |
---|
1086 | } |
---|
1087 | #else |
---|
1088 | #if VPS_EXTN_OP_LAYER_SETS |
---|
1089 | // Target output layer signalling |
---|
1090 | READ_UVLC( uiCode, "vps_num_output_layer_sets"); vps->setNumOutputLayerSets(uiCode); |
---|
1091 | for(i = 0; i < vps->getNumOutputLayerSets(); i++) |
---|
1092 | { |
---|
1093 | #if VPS_OUTPUT_LAYER_SET_IDX |
---|
1094 | READ_UVLC( uiCode, "vps_output_layer_set_idx_minus1[i]"); vps->setOutputLayerSetIdx(i, uiCode + 1); |
---|
1095 | #else |
---|
1096 | READ_UVLC( uiCode, "vps_output_layer_set_idx[i]"); vps->setOutputLayerSetIdx(i, uiCode); |
---|
1097 | #endif |
---|
1098 | Int lsIdx = vps->getOutputLayerSetIdx(i); |
---|
1099 | for(j = 0; j <= vps->getMaxLayerId(); j++) |
---|
1100 | { |
---|
1101 | if(vps->getLayerIdIncludedFlag(lsIdx, j)) |
---|
1102 | { |
---|
1103 | READ_FLAG( uiCode, "vps_output_layer_flag[lsIdx][j]"); vps->setOutputLayerFlag(lsIdx, j, uiCode); |
---|
1104 | } |
---|
1105 | } |
---|
1106 | } |
---|
1107 | #endif |
---|
1108 | #endif |
---|
1109 | #if JCTVC_M0458_INTERLAYER_RPS_SIG |
---|
1110 | READ_FLAG(uiCode, "max_one_active_ref_layer_flag" ); |
---|
1111 | vps->setMaxOneActiveRefLayerFlag(uiCode); |
---|
1112 | #endif |
---|
1113 | |
---|
1114 | #if !VPS_MOVE_DIR_DEPENDENCY_FLAG |
---|
1115 | #if VPS_EXTN_DIRECT_REF_LAYERS |
---|
1116 | // For layer 0 |
---|
1117 | vps->setNumDirectRefLayers(0, 0); |
---|
1118 | // For other layers |
---|
1119 | for( Int layerCtr = 1; layerCtr <= vps->getMaxLayers() - 1; layerCtr++) |
---|
1120 | { |
---|
1121 | UInt numDirectRefLayers = 0; |
---|
1122 | for( Int refLayerCtr = 0; refLayerCtr < layerCtr; refLayerCtr++) |
---|
1123 | { |
---|
1124 | READ_FLAG(uiCode, "direct_dependency_flag[i][j]" ); vps->setDirectDependencyFlag(layerCtr, refLayerCtr, uiCode? true : false); |
---|
1125 | if(uiCode) |
---|
1126 | { |
---|
1127 | vps->setRefLayerId(layerCtr, numDirectRefLayers, refLayerCtr); |
---|
1128 | numDirectRefLayers++; |
---|
1129 | } |
---|
1130 | } |
---|
1131 | vps->setNumDirectRefLayers(layerCtr, numDirectRefLayers); |
---|
1132 | } |
---|
1133 | #endif |
---|
1134 | #endif |
---|
1135 | #if VPS_EXTN_DIRECT_REF_LAYERS && M0457_PREDICTION_INDICATIONS |
---|
1136 | READ_UVLC( uiCode, "direct_dep_type_len_minus2"); vps->setDirectDepTypeLen(uiCode+2); |
---|
1137 | for(i = 1; i < vps->getMaxLayers(); i++) |
---|
1138 | { |
---|
1139 | for(j = 0; j < i; j++) |
---|
1140 | { |
---|
1141 | if (vps->getDirectDependencyFlag(i, j)) |
---|
1142 | { |
---|
1143 | READ_CODE( vps->getDirectDepTypeLen(), uiCode, "direct_dependency_type[i][j]" ); vps->setDirectDependencyType(i, j, uiCode); |
---|
1144 | } |
---|
1145 | } |
---|
1146 | } |
---|
1147 | #endif |
---|
1148 | #if M0040_ADAPTIVE_RESOLUTION_CHANGE |
---|
1149 | READ_FLAG(uiCode, "single_layer_for_non_irap_flag" ); vps->setSingleLayerForNonIrapFlag(uiCode == 1 ? true : false); |
---|
1150 | #endif |
---|
1151 | |
---|
1152 | READ_FLAG( uiCode, "vps_vui_present_flag" ); |
---|
1153 | if (uiCode) |
---|
1154 | { |
---|
1155 | #if VPS_VUI |
---|
1156 | while ( m_pcBitstream->getNumBitsRead() % 8 != 0 ) |
---|
1157 | { |
---|
1158 | READ_FLAG( uiCode, "vps_vui_alignment_bit_equal_to_one"); assert(uiCode == 1); |
---|
1159 | } |
---|
1160 | parseVPSVUI(vps); |
---|
1161 | #endif |
---|
1162 | } |
---|
1163 | } |
---|
1164 | #endif |
---|
1165 | |
---|
1166 | #if VPS_VUI |
---|
1167 | Void TDecCavlc::parseVPSVUI(TComVPS *vps) |
---|
1168 | { |
---|
1169 | UInt i,j; |
---|
1170 | UInt uiCode; |
---|
1171 | #if VPS_VUI_BITRATE_PICRATE |
---|
1172 | READ_FLAG( uiCode, "bit_rate_present_vps_flag" ); vps->setBitRatePresentVpsFlag( uiCode ? true : false ); |
---|
1173 | READ_FLAG( uiCode, "pic_rate_present_vps_flag" ); vps->setPicRatePresentVpsFlag( uiCode ? true : false ); |
---|
1174 | |
---|
1175 | Bool parseFlag = vps->getBitRatePresentVpsFlag() || vps->getPicRatePresentVpsFlag(); |
---|
1176 | { |
---|
1177 | for( i = 0; i < vps->getNumLayerSets(); i++ ) |
---|
1178 | { |
---|
1179 | for( j = 0; j < vps->getMaxTLayers(); j++ ) |
---|
1180 | { |
---|
1181 | if( parseFlag && vps->getBitRatePresentVpsFlag() ) |
---|
1182 | { |
---|
1183 | READ_FLAG( uiCode, "bit_rate_present_vps_flag[i][j]" ); vps->setBitRatePresentFlag( i, j, uiCode ? true : false ); |
---|
1184 | } |
---|
1185 | else |
---|
1186 | { |
---|
1187 | vps->setBitRatePresentFlag( i, j, false ); |
---|
1188 | } |
---|
1189 | if( parseFlag && vps->getPicRatePresentVpsFlag() ) |
---|
1190 | { |
---|
1191 | READ_FLAG( uiCode, "pic_rate_present_vps_flag[i][j]" ); vps->setPicRatePresentFlag( i, j, uiCode ? true : false ); |
---|
1192 | } |
---|
1193 | else |
---|
1194 | { |
---|
1195 | vps->setPicRatePresentFlag( i, j, false ); |
---|
1196 | } |
---|
1197 | if( parseFlag && vps->getBitRatePresentFlag(i, j) ) |
---|
1198 | { |
---|
1199 | READ_CODE( 16, uiCode, "avg_bit_rate[i][j]" ); vps->setAvgBitRate( i, j, uiCode ); |
---|
1200 | READ_CODE( 16, uiCode, "max_bit_rate[i][j]" ); vps->setMaxBitRate( i, j, uiCode ); |
---|
1201 | } |
---|
1202 | else |
---|
1203 | { |
---|
1204 | vps->setAvgBitRate( i, j, 0 ); |
---|
1205 | vps->setMaxBitRate( i, j, 0 ); |
---|
1206 | } |
---|
1207 | if( parseFlag && vps->getPicRatePresentFlag(i, j) ) |
---|
1208 | { |
---|
1209 | READ_CODE( 2 , uiCode, "constant_pic_rate_idc[i][j]" ); vps->setConstPicRateIdc( i, j, uiCode ); |
---|
1210 | READ_CODE( 16, uiCode, "avg_pic_rate[i][j]" ); vps->setAvgPicRate( i, j, uiCode ); |
---|
1211 | } |
---|
1212 | else |
---|
1213 | { |
---|
1214 | vps->setConstPicRateIdc( i, j, 0 ); |
---|
1215 | vps->setAvgPicRate ( i, j, 0 ); |
---|
1216 | } |
---|
1217 | } |
---|
1218 | } |
---|
1219 | } |
---|
1220 | #endif |
---|
1221 | #if N0160_TILE_BOUNDARY_ALIGNED_FLAG |
---|
1222 | for(i = 1; i < vps->getMaxLayers(); i++) |
---|
1223 | { |
---|
1224 | for(j = 0; j < vps->getNumDirectRefLayers(vps->getLayerIdInNuh(i)); j++) |
---|
1225 | { |
---|
1226 | READ_FLAG( uiCode, "tile_boundaries_aligned_flag[i][j]" ); vps->setTileBoundariesAlignedFlag(i,j,(uiCode == 1)); |
---|
1227 | } |
---|
1228 | } |
---|
1229 | #endif |
---|
1230 | #if N0160_VUI_EXT_ILP_REF |
---|
1231 | READ_FLAG( uiCode, "num_ilp_restricted_ref_layers" ); vps->setNumIlpRestrictedRefLayers( uiCode == 1 ); |
---|
1232 | if( vps->getNumIlpRestrictedRefLayers()) |
---|
1233 | { |
---|
1234 | for(i = 1; i < vps->getMaxLayers(); i++) |
---|
1235 | { |
---|
1236 | for(j = 0; j < vps->getNumDirectRefLayers(vps->getLayerIdInNuh(i)); j++) |
---|
1237 | { |
---|
1238 | READ_UVLC( uiCode, "min_spatial_segment_offset_plus1[i][j]" ); vps->setMinSpatialSegmentOffsetPlus1( i, j, uiCode ); |
---|
1239 | if( vps->getMinSpatialSegmentOffsetPlus1(i,j ) > 0 ) |
---|
1240 | { |
---|
1241 | READ_FLAG( uiCode, "ctu_based_offset_enabled_flag[i][j]"); vps->setCtuBasedOffsetEnabledFlag(i, j, uiCode == 1 ); |
---|
1242 | if(vps->getCtuBasedOffsetEnabledFlag(i,j)) |
---|
1243 | { |
---|
1244 | READ_UVLC( uiCode, "min_horizontal_ctu_offset_plus1[i][j]"); vps->setMinHorizontalCtuOffsetPlus1( i,j, uiCode ); |
---|
1245 | } |
---|
1246 | } |
---|
1247 | } |
---|
1248 | } |
---|
1249 | } |
---|
1250 | #endif |
---|
1251 | } |
---|
1252 | #endif |
---|
1253 | Void TDecCavlc::parseSliceHeader (TComSlice*& rpcSlice, ParameterSetManagerDecoder *parameterSetManager) |
---|
1254 | { |
---|
1255 | UInt uiCode; |
---|
1256 | Int iCode; |
---|
1257 | |
---|
1258 | #if ENC_DEC_TRACE |
---|
1259 | xTraceSliceHeader(rpcSlice); |
---|
1260 | #endif |
---|
1261 | TComPPS* pps = NULL; |
---|
1262 | TComSPS* sps = NULL; |
---|
1263 | |
---|
1264 | UInt firstSliceSegmentInPic; |
---|
1265 | READ_FLAG( firstSliceSegmentInPic, "first_slice_segment_in_pic_flag" ); |
---|
1266 | if( rpcSlice->getRapPicFlag()) |
---|
1267 | { |
---|
1268 | READ_FLAG( uiCode, "no_output_of_prior_pics_flag" ); //ignored |
---|
1269 | } |
---|
1270 | READ_UVLC ( uiCode, "slice_pic_parameter_set_id" ); rpcSlice->setPPSId(uiCode); |
---|
1271 | pps = parameterSetManager->getPrefetchedPPS(uiCode); |
---|
1272 | //!KS: need to add error handling code here, if PPS is not available |
---|
1273 | assert(pps!=0); |
---|
1274 | sps = parameterSetManager->getPrefetchedSPS(pps->getSPSId()); |
---|
1275 | //!KS: need to add error handling code here, if SPS is not available |
---|
1276 | assert(sps!=0); |
---|
1277 | rpcSlice->setSPS(sps); |
---|
1278 | rpcSlice->setPPS(pps); |
---|
1279 | if( pps->getDependentSliceSegmentsEnabledFlag() && ( !firstSliceSegmentInPic )) |
---|
1280 | { |
---|
1281 | READ_FLAG( uiCode, "dependent_slice_segment_flag" ); rpcSlice->setDependentSliceSegmentFlag(uiCode ? true : false); |
---|
1282 | } |
---|
1283 | else |
---|
1284 | { |
---|
1285 | rpcSlice->setDependentSliceSegmentFlag(false); |
---|
1286 | } |
---|
1287 | Int numCTUs = ((sps->getPicWidthInLumaSamples()+sps->getMaxCUWidth()-1)/sps->getMaxCUWidth())*((sps->getPicHeightInLumaSamples()+sps->getMaxCUHeight()-1)/sps->getMaxCUHeight()); |
---|
1288 | Int maxParts = (1<<(sps->getMaxCUDepth()<<1)); |
---|
1289 | UInt sliceSegmentAddress = 0; |
---|
1290 | Int bitsSliceSegmentAddress = 0; |
---|
1291 | while(numCTUs>(1<<bitsSliceSegmentAddress)) |
---|
1292 | { |
---|
1293 | bitsSliceSegmentAddress++; |
---|
1294 | } |
---|
1295 | |
---|
1296 | if(!firstSliceSegmentInPic) |
---|
1297 | { |
---|
1298 | READ_CODE( bitsSliceSegmentAddress, sliceSegmentAddress, "slice_segment_address" ); |
---|
1299 | } |
---|
1300 | //set uiCode to equal slice start address (or dependent slice start address) |
---|
1301 | Int startCuAddress = maxParts*sliceSegmentAddress; |
---|
1302 | rpcSlice->setSliceSegmentCurStartCUAddr( startCuAddress ); |
---|
1303 | rpcSlice->setSliceSegmentCurEndCUAddr(numCTUs*maxParts); |
---|
1304 | |
---|
1305 | if (rpcSlice->getDependentSliceSegmentFlag()) |
---|
1306 | { |
---|
1307 | rpcSlice->setNextSlice ( false ); |
---|
1308 | rpcSlice->setNextSliceSegment ( true ); |
---|
1309 | } |
---|
1310 | else |
---|
1311 | { |
---|
1312 | rpcSlice->setNextSlice ( true ); |
---|
1313 | rpcSlice->setNextSliceSegment ( false ); |
---|
1314 | |
---|
1315 | rpcSlice->setSliceCurStartCUAddr(startCuAddress); |
---|
1316 | rpcSlice->setSliceCurEndCUAddr(numCTUs*maxParts); |
---|
1317 | } |
---|
1318 | |
---|
1319 | if(!rpcSlice->getDependentSliceSegmentFlag()) |
---|
1320 | { |
---|
1321 | |
---|
1322 | #if SH_DISCARDABLE_FLAG |
---|
1323 | if(rpcSlice->getPPS()->getNumExtraSliceHeaderBits()>0) |
---|
1324 | { |
---|
1325 | READ_FLAG(uiCode, "discardable_flag"); // ignored |
---|
1326 | } |
---|
1327 | for (Int i = 1; i < rpcSlice->getPPS()->getNumExtraSliceHeaderBits(); i++) |
---|
1328 | { |
---|
1329 | READ_FLAG(uiCode, "slice_reserved_undetermined_flag[]"); // ignored |
---|
1330 | } |
---|
1331 | #else |
---|
1332 | for (Int i = 0; i < rpcSlice->getPPS()->getNumExtraSliceHeaderBits(); i++) |
---|
1333 | { |
---|
1334 | READ_FLAG(uiCode, "slice_reserved_undetermined_flag[]"); // ignored |
---|
1335 | } |
---|
1336 | #endif |
---|
1337 | |
---|
1338 | READ_UVLC ( uiCode, "slice_type" ); rpcSlice->setSliceType((SliceType)uiCode); |
---|
1339 | if( pps->getOutputFlagPresentFlag() ) |
---|
1340 | { |
---|
1341 | READ_FLAG( uiCode, "pic_output_flag" ); rpcSlice->setPicOutputFlag( uiCode ? true : false ); |
---|
1342 | } |
---|
1343 | else |
---|
1344 | { |
---|
1345 | rpcSlice->setPicOutputFlag( true ); |
---|
1346 | } |
---|
1347 | // in the first version chroma_format_idc is equal to one, thus colour_plane_id will not be present |
---|
1348 | assert (sps->getChromaFormatIdc() == 1 ); |
---|
1349 | // if( separate_colour_plane_flag == 1 ) |
---|
1350 | // colour_plane_id u(2) |
---|
1351 | |
---|
1352 | if( rpcSlice->getIdrPicFlag() ) |
---|
1353 | { |
---|
1354 | rpcSlice->setPOC(0); |
---|
1355 | TComReferencePictureSet* rps = rpcSlice->getLocalRPS(); |
---|
1356 | rps->setNumberOfNegativePictures(0); |
---|
1357 | rps->setNumberOfPositivePictures(0); |
---|
1358 | rps->setNumberOfLongtermPictures(0); |
---|
1359 | rps->setNumberOfPictures(0); |
---|
1360 | rpcSlice->setRPS(rps); |
---|
1361 | } |
---|
1362 | else |
---|
1363 | { |
---|
1364 | READ_CODE(sps->getBitsForPOC(), uiCode, "pic_order_cnt_lsb"); |
---|
1365 | Int iPOClsb = uiCode; |
---|
1366 | Int iPrevPOC = rpcSlice->getPrevPOC(); |
---|
1367 | Int iMaxPOClsb = 1<< sps->getBitsForPOC(); |
---|
1368 | Int iPrevPOClsb = iPrevPOC%iMaxPOClsb; |
---|
1369 | Int iPrevPOCmsb = iPrevPOC-iPrevPOClsb; |
---|
1370 | Int iPOCmsb; |
---|
1371 | if( ( iPOClsb < iPrevPOClsb ) && ( ( iPrevPOClsb - iPOClsb ) >= ( iMaxPOClsb / 2 ) ) ) |
---|
1372 | { |
---|
1373 | iPOCmsb = iPrevPOCmsb + iMaxPOClsb; |
---|
1374 | } |
---|
1375 | else if( (iPOClsb > iPrevPOClsb ) && ( (iPOClsb - iPrevPOClsb ) > ( iMaxPOClsb / 2 ) ) ) |
---|
1376 | { |
---|
1377 | iPOCmsb = iPrevPOCmsb - iMaxPOClsb; |
---|
1378 | } |
---|
1379 | else |
---|
1380 | { |
---|
1381 | iPOCmsb = iPrevPOCmsb; |
---|
1382 | } |
---|
1383 | if ( rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP |
---|
1384 | || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL |
---|
1385 | || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP ) |
---|
1386 | { |
---|
1387 | // For BLA picture types, POCmsb is set to 0. |
---|
1388 | iPOCmsb = 0; |
---|
1389 | } |
---|
1390 | rpcSlice->setPOC (iPOCmsb+iPOClsb); |
---|
1391 | |
---|
1392 | TComReferencePictureSet* rps; |
---|
1393 | rps = rpcSlice->getLocalRPS(); |
---|
1394 | rpcSlice->setRPS(rps); |
---|
1395 | READ_FLAG( uiCode, "short_term_ref_pic_set_sps_flag" ); |
---|
1396 | if(uiCode == 0) // use short-term reference picture set explicitly signalled in slice header |
---|
1397 | { |
---|
1398 | parseShortTermRefPicSet(sps,rps, sps->getRPSList()->getNumberOfReferencePictureSets()); |
---|
1399 | } |
---|
1400 | else // use reference to short-term reference picture set in PPS |
---|
1401 | { |
---|
1402 | Int numBits = 0; |
---|
1403 | while ((1 << numBits) < rpcSlice->getSPS()->getRPSList()->getNumberOfReferencePictureSets()) |
---|
1404 | { |
---|
1405 | numBits++; |
---|
1406 | } |
---|
1407 | if (numBits > 0) |
---|
1408 | { |
---|
1409 | READ_CODE( numBits, uiCode, "short_term_ref_pic_set_idx"); |
---|
1410 | } |
---|
1411 | else |
---|
1412 | { |
---|
1413 | uiCode = 0; |
---|
1414 | } |
---|
1415 | *rps = *(sps->getRPSList()->getReferencePictureSet(uiCode)); |
---|
1416 | } |
---|
1417 | if(sps->getLongTermRefsPresent()) |
---|
1418 | { |
---|
1419 | Int offset = rps->getNumberOfNegativePictures()+rps->getNumberOfPositivePictures(); |
---|
1420 | UInt numOfLtrp = 0; |
---|
1421 | UInt numLtrpInSPS = 0; |
---|
1422 | if (rpcSlice->getSPS()->getNumLongTermRefPicSPS() > 0) |
---|
1423 | { |
---|
1424 | READ_UVLC( uiCode, "num_long_term_sps"); |
---|
1425 | numLtrpInSPS = uiCode; |
---|
1426 | numOfLtrp += numLtrpInSPS; |
---|
1427 | rps->setNumberOfLongtermPictures(numOfLtrp); |
---|
1428 | } |
---|
1429 | Int bitsForLtrpInSPS = 0; |
---|
1430 | while (rpcSlice->getSPS()->getNumLongTermRefPicSPS() > (1 << bitsForLtrpInSPS)) |
---|
1431 | { |
---|
1432 | bitsForLtrpInSPS++; |
---|
1433 | } |
---|
1434 | READ_UVLC( uiCode, "num_long_term_pics"); rps->setNumberOfLongtermPictures(uiCode); |
---|
1435 | numOfLtrp += uiCode; |
---|
1436 | rps->setNumberOfLongtermPictures(numOfLtrp); |
---|
1437 | Int maxPicOrderCntLSB = 1 << rpcSlice->getSPS()->getBitsForPOC(); |
---|
1438 | Int prevDeltaMSB = 0, deltaPocMSBCycleLT = 0;; |
---|
1439 | for(Int j=offset+rps->getNumberOfLongtermPictures()-1, k = 0; k < numOfLtrp; j--, k++) |
---|
1440 | { |
---|
1441 | Int pocLsbLt; |
---|
1442 | if (k < numLtrpInSPS) |
---|
1443 | { |
---|
1444 | uiCode = 0; |
---|
1445 | if (bitsForLtrpInSPS > 0) |
---|
1446 | { |
---|
1447 | READ_CODE(bitsForLtrpInSPS, uiCode, "lt_idx_sps[i]"); |
---|
1448 | } |
---|
1449 | Int usedByCurrFromSPS=rpcSlice->getSPS()->getUsedByCurrPicLtSPSFlag(uiCode); |
---|
1450 | |
---|
1451 | pocLsbLt = rpcSlice->getSPS()->getLtRefPicPocLsbSps(uiCode); |
---|
1452 | rps->setUsed(j,usedByCurrFromSPS); |
---|
1453 | } |
---|
1454 | else |
---|
1455 | { |
---|
1456 | READ_CODE(rpcSlice->getSPS()->getBitsForPOC(), uiCode, "poc_lsb_lt"); pocLsbLt= uiCode; |
---|
1457 | READ_FLAG( uiCode, "used_by_curr_pic_lt_flag"); rps->setUsed(j,uiCode); |
---|
1458 | } |
---|
1459 | READ_FLAG(uiCode,"delta_poc_msb_present_flag"); |
---|
1460 | Bool mSBPresentFlag = uiCode ? true : false; |
---|
1461 | if(mSBPresentFlag) |
---|
1462 | { |
---|
1463 | READ_UVLC( uiCode, "delta_poc_msb_cycle_lt[i]" ); |
---|
1464 | Bool deltaFlag = false; |
---|
1465 | // First LTRP || First LTRP from SH |
---|
1466 | if( (j == offset+rps->getNumberOfLongtermPictures()-1) || (j == offset+(numOfLtrp-numLtrpInSPS)-1) ) |
---|
1467 | { |
---|
1468 | deltaFlag = true; |
---|
1469 | } |
---|
1470 | if(deltaFlag) |
---|
1471 | { |
---|
1472 | deltaPocMSBCycleLT = uiCode; |
---|
1473 | } |
---|
1474 | else |
---|
1475 | { |
---|
1476 | deltaPocMSBCycleLT = uiCode + prevDeltaMSB; |
---|
1477 | } |
---|
1478 | |
---|
1479 | Int pocLTCurr = rpcSlice->getPOC() - deltaPocMSBCycleLT * maxPicOrderCntLSB |
---|
1480 | - iPOClsb + pocLsbLt; |
---|
1481 | rps->setPOC (j, pocLTCurr); |
---|
1482 | rps->setDeltaPOC(j, - rpcSlice->getPOC() + pocLTCurr); |
---|
1483 | rps->setCheckLTMSBPresent(j,true); |
---|
1484 | } |
---|
1485 | else |
---|
1486 | { |
---|
1487 | rps->setPOC (j, pocLsbLt); |
---|
1488 | rps->setDeltaPOC(j, - rpcSlice->getPOC() + pocLsbLt); |
---|
1489 | rps->setCheckLTMSBPresent(j,false); |
---|
1490 | } |
---|
1491 | prevDeltaMSB = deltaPocMSBCycleLT; |
---|
1492 | } |
---|
1493 | offset += rps->getNumberOfLongtermPictures(); |
---|
1494 | rps->setNumberOfPictures(offset); |
---|
1495 | } |
---|
1496 | if ( rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_LP |
---|
1497 | || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_W_RADL |
---|
1498 | || rpcSlice->getNalUnitType() == NAL_UNIT_CODED_SLICE_BLA_N_LP ) |
---|
1499 | { |
---|
1500 | // In the case of BLA picture types, rps data is read from slice header but ignored |
---|
1501 | rps = rpcSlice->getLocalRPS(); |
---|
1502 | rps->setNumberOfNegativePictures(0); |
---|
1503 | rps->setNumberOfPositivePictures(0); |
---|
1504 | rps->setNumberOfLongtermPictures(0); |
---|
1505 | rps->setNumberOfPictures(0); |
---|
1506 | rpcSlice->setRPS(rps); |
---|
1507 | } |
---|
1508 | if (rpcSlice->getSPS()->getTMVPFlagsPresent()) |
---|
1509 | { |
---|
1510 | READ_FLAG( uiCode, "slice_temporal_mvp_enable_flag" ); |
---|
1511 | rpcSlice->setEnableTMVPFlag( uiCode == 1 ? true : false ); |
---|
1512 | } |
---|
1513 | else |
---|
1514 | { |
---|
1515 | rpcSlice->setEnableTMVPFlag(false); |
---|
1516 | } |
---|
1517 | } |
---|
1518 | |
---|
1519 | #if SVC_EXTENSION |
---|
1520 | #if JCTVC_M0458_INTERLAYER_RPS_SIG |
---|
1521 | rpcSlice->setActiveNumILRRefIdx(0); |
---|
1522 | #if ILP_SSH_SIG |
---|
1523 | if((sps->getLayerId() > 0) && rpcSlice->getVPS()->getIlpSshSignalingEnabledFlag() && (rpcSlice->getNumILRRefIdx() > 0) ) |
---|
1524 | #else |
---|
1525 | if((sps->getLayerId() > 0) && (rpcSlice->getNumILRRefIdx() > 0) ) |
---|
1526 | #endif |
---|
1527 | { |
---|
1528 | READ_FLAG(uiCode,"inter_layer_pred_enabled_flag"); |
---|
1529 | rpcSlice->setInterLayerPredEnabledFlag(uiCode); |
---|
1530 | if( rpcSlice->getInterLayerPredEnabledFlag()) |
---|
1531 | { |
---|
1532 | if(rpcSlice->getNumILRRefIdx() > 1) |
---|
1533 | { |
---|
1534 | Int numBits = 1; |
---|
1535 | while ((1 << numBits) < rpcSlice->getNumILRRefIdx()) |
---|
1536 | { |
---|
1537 | numBits++; |
---|
1538 | } |
---|
1539 | if( !rpcSlice->getVPS()->getMaxOneActiveRefLayerFlag()) |
---|
1540 | { |
---|
1541 | READ_CODE( numBits, uiCode,"num_inter_layer_ref_pics_minus1" ); |
---|
1542 | rpcSlice->setActiveNumILRRefIdx(uiCode + 1); |
---|
1543 | } |
---|
1544 | else |
---|
1545 | { |
---|
1546 | rpcSlice->setActiveNumILRRefIdx(1); |
---|
1547 | } |
---|
1548 | #if ILP_NUM_REF_CHK |
---|
1549 | if( rpcSlice->getActiveNumILRRefIdx() == rpcSlice->getNumILRRefIdx() ) |
---|
1550 | { |
---|
1551 | for( Int i = 0; i < rpcSlice->getActiveNumILRRefIdx(); i++ ) |
---|
1552 | { |
---|
1553 | rpcSlice->setInterLayerPredLayerIdc(i,i); |
---|
1554 | } |
---|
1555 | } |
---|
1556 | else |
---|
1557 | { |
---|
1558 | #endif |
---|
1559 | for(Int i = 0; i < rpcSlice->getActiveNumILRRefIdx(); i++ ) |
---|
1560 | { |
---|
1561 | READ_CODE( numBits,uiCode,"inter_layer_pred_layer_idc[i]" ); |
---|
1562 | rpcSlice->setInterLayerPredLayerIdc(uiCode,i); |
---|
1563 | } |
---|
1564 | #if ILP_NUM_REF_CHK |
---|
1565 | } |
---|
1566 | #endif |
---|
1567 | } |
---|
1568 | else |
---|
1569 | { |
---|
1570 | rpcSlice->setActiveNumILRRefIdx(1); |
---|
1571 | rpcSlice->setInterLayerPredLayerIdc(0,0); |
---|
1572 | } |
---|
1573 | } |
---|
1574 | } |
---|
1575 | #if ILP_SSH_SIG |
---|
1576 | else if( rpcSlice->getVPS()->getIlpSshSignalingEnabledFlag() == false ) |
---|
1577 | { |
---|
1578 | rpcSlice->setInterLayerPredEnabledFlag(true); |
---|
1579 | rpcSlice->setActiveNumILRRefIdx(rpcSlice->getNumILRRefIdx()); |
---|
1580 | for( Int i = 0; i < rpcSlice->getActiveNumILRRefIdx(); i++ ) |
---|
1581 | { |
---|
1582 | rpcSlice->setInterLayerPredLayerIdc(i,i); |
---|
1583 | } |
---|
1584 | } |
---|
1585 | #endif |
---|
1586 | #if M0457_IL_SAMPLE_PRED_ONLY_FLAG |
---|
1587 | rpcSlice->setInterLayerSamplePredOnlyFlag( false ); |
---|
1588 | if( rpcSlice->getNumSamplePredRefLayers() > 0 && rpcSlice->getActiveNumILRRefIdx() > 0 ) |
---|
1589 | { |
---|
1590 | READ_FLAG( uiCode, "inter_layer_sample_pred_only_flag" ); |
---|
1591 | rpcSlice->setInterLayerSamplePredOnlyFlag( uiCode > 0 ); |
---|
1592 | } |
---|
1593 | #endif |
---|
1594 | #else |
---|
1595 | if( rpcSlice->getLayerId() > 0 ) |
---|
1596 | { |
---|
1597 | rpcSlice->setNumILRRefIdx( rpcSlice->getVPS()->getNumDirectRefLayers( rpcSlice->getLayerId() ) ); |
---|
1598 | } |
---|
1599 | #endif |
---|
1600 | #endif |
---|
1601 | |
---|
1602 | if(sps->getUseSAO()) |
---|
1603 | { |
---|
1604 | READ_FLAG(uiCode, "slice_sao_luma_flag"); rpcSlice->setSaoEnabledFlag((Bool)uiCode); |
---|
1605 | READ_FLAG(uiCode, "slice_sao_chroma_flag"); rpcSlice->setSaoEnabledFlagChroma((Bool)uiCode); |
---|
1606 | } |
---|
1607 | |
---|
1608 | if (rpcSlice->getIdrPicFlag()) |
---|
1609 | { |
---|
1610 | rpcSlice->setEnableTMVPFlag(false); |
---|
1611 | } |
---|
1612 | if (!rpcSlice->isIntra()) |
---|
1613 | { |
---|
1614 | |
---|
1615 | READ_FLAG( uiCode, "num_ref_idx_active_override_flag"); |
---|
1616 | if (uiCode) |
---|
1617 | { |
---|
1618 | READ_UVLC (uiCode, "num_ref_idx_l0_active_minus1" ); rpcSlice->setNumRefIdx( REF_PIC_LIST_0, uiCode + 1 ); |
---|
1619 | if (rpcSlice->isInterB()) |
---|
1620 | { |
---|
1621 | READ_UVLC (uiCode, "num_ref_idx_l1_active_minus1" ); rpcSlice->setNumRefIdx( REF_PIC_LIST_1, uiCode + 1 ); |
---|
1622 | } |
---|
1623 | else |
---|
1624 | { |
---|
1625 | rpcSlice->setNumRefIdx(REF_PIC_LIST_1, 0); |
---|
1626 | } |
---|
1627 | } |
---|
1628 | else |
---|
1629 | { |
---|
1630 | rpcSlice->setNumRefIdx(REF_PIC_LIST_0, rpcSlice->getPPS()->getNumRefIdxL0DefaultActive()); |
---|
1631 | if (rpcSlice->isInterB()) |
---|
1632 | { |
---|
1633 | rpcSlice->setNumRefIdx(REF_PIC_LIST_1, rpcSlice->getPPS()->getNumRefIdxL1DefaultActive()); |
---|
1634 | } |
---|
1635 | else |
---|
1636 | { |
---|
1637 | rpcSlice->setNumRefIdx(REF_PIC_LIST_1,0); |
---|
1638 | } |
---|
1639 | } |
---|
1640 | } |
---|
1641 | // } |
---|
1642 | TComRefPicListModification* refPicListModification = rpcSlice->getRefPicListModification(); |
---|
1643 | if(!rpcSlice->isIntra()) |
---|
1644 | { |
---|
1645 | if( !rpcSlice->getPPS()->getListsModificationPresentFlag() || rpcSlice->getNumRpsCurrTempList() <= 1 ) |
---|
1646 | { |
---|
1647 | refPicListModification->setRefPicListModificationFlagL0( 0 ); |
---|
1648 | } |
---|
1649 | else |
---|
1650 | { |
---|
1651 | READ_FLAG( uiCode, "ref_pic_list_modification_flag_l0" ); refPicListModification->setRefPicListModificationFlagL0( uiCode ? 1 : 0 ); |
---|
1652 | } |
---|
1653 | |
---|
1654 | if(refPicListModification->getRefPicListModificationFlagL0()) |
---|
1655 | { |
---|
1656 | uiCode = 0; |
---|
1657 | Int i = 0; |
---|
1658 | Int numRpsCurrTempList0 = rpcSlice->getNumRpsCurrTempList(); |
---|
1659 | if ( numRpsCurrTempList0 > 1 ) |
---|
1660 | { |
---|
1661 | Int length = 1; |
---|
1662 | numRpsCurrTempList0 --; |
---|
1663 | while ( numRpsCurrTempList0 >>= 1) |
---|
1664 | { |
---|
1665 | length ++; |
---|
1666 | } |
---|
1667 | for (i = 0; i < rpcSlice->getNumRefIdx(REF_PIC_LIST_0); i ++) |
---|
1668 | { |
---|
1669 | READ_CODE( length, uiCode, "list_entry_l0" ); |
---|
1670 | refPicListModification->setRefPicSetIdxL0(i, uiCode ); |
---|
1671 | } |
---|
1672 | } |
---|
1673 | else |
---|
1674 | { |
---|
1675 | for (i = 0; i < rpcSlice->getNumRefIdx(REF_PIC_LIST_0); i ++) |
---|
1676 | { |
---|
1677 | refPicListModification->setRefPicSetIdxL0(i, 0 ); |
---|
1678 | } |
---|
1679 | } |
---|
1680 | } |
---|
1681 | } |
---|
1682 | else |
---|
1683 | { |
---|
1684 | refPicListModification->setRefPicListModificationFlagL0(0); |
---|
1685 | } |
---|
1686 | if(rpcSlice->isInterB()) |
---|
1687 | { |
---|
1688 | if( !rpcSlice->getPPS()->getListsModificationPresentFlag() || rpcSlice->getNumRpsCurrTempList() <= 1 ) |
---|
1689 | { |
---|
1690 | refPicListModification->setRefPicListModificationFlagL1( 0 ); |
---|
1691 | } |
---|
1692 | else |
---|
1693 | { |
---|
1694 | READ_FLAG( uiCode, "ref_pic_list_modification_flag_l1" ); refPicListModification->setRefPicListModificationFlagL1( uiCode ? 1 : 0 ); |
---|
1695 | } |
---|
1696 | if(refPicListModification->getRefPicListModificationFlagL1()) |
---|
1697 | { |
---|
1698 | uiCode = 0; |
---|
1699 | Int i = 0; |
---|
1700 | Int numRpsCurrTempList1 = rpcSlice->getNumRpsCurrTempList(); |
---|
1701 | if ( numRpsCurrTempList1 > 1 ) |
---|
1702 | { |
---|
1703 | Int length = 1; |
---|
1704 | numRpsCurrTempList1 --; |
---|
1705 | while ( numRpsCurrTempList1 >>= 1) |
---|
1706 | { |
---|
1707 | length ++; |
---|
1708 | } |
---|
1709 | for (i = 0; i < rpcSlice->getNumRefIdx(REF_PIC_LIST_1); i ++) |
---|
1710 | { |
---|
1711 | READ_CODE( length, uiCode, "list_entry_l1" ); |
---|
1712 | refPicListModification->setRefPicSetIdxL1(i, uiCode ); |
---|
1713 | } |
---|
1714 | } |
---|
1715 | else |
---|
1716 | { |
---|
1717 | for (i = 0; i < rpcSlice->getNumRefIdx(REF_PIC_LIST_1); i ++) |
---|
1718 | { |
---|
1719 | refPicListModification->setRefPicSetIdxL1(i, 0 ); |
---|
1720 | } |
---|
1721 | } |
---|
1722 | } |
---|
1723 | } |
---|
1724 | else |
---|
1725 | { |
---|
1726 | refPicListModification->setRefPicListModificationFlagL1(0); |
---|
1727 | } |
---|
1728 | if (rpcSlice->isInterB()) |
---|
1729 | { |
---|
1730 | READ_FLAG( uiCode, "mvd_l1_zero_flag" ); rpcSlice->setMvdL1ZeroFlag( (uiCode ? true : false) ); |
---|
1731 | } |
---|
1732 | |
---|
1733 | rpcSlice->setCabacInitFlag( false ); // default |
---|
1734 | if(pps->getCabacInitPresentFlag() && !rpcSlice->isIntra()) |
---|
1735 | { |
---|
1736 | READ_FLAG(uiCode, "cabac_init_flag"); |
---|
1737 | rpcSlice->setCabacInitFlag( uiCode ? true : false ); |
---|
1738 | } |
---|
1739 | |
---|
1740 | if ( rpcSlice->getEnableTMVPFlag() ) |
---|
1741 | { |
---|
1742 | #if M0457_COL_PICTURE_SIGNALING |
---|
1743 | #if REMOVE_COL_PICTURE_SIGNALING |
---|
1744 | rpcSlice->setMFMEnabledFlag( rpcSlice->getNumMotionPredRefLayers() > 0 ? true : false ); |
---|
1745 | #else |
---|
1746 | rpcSlice->setMFMEnabledFlag( false ); |
---|
1747 | rpcSlice->setColRefLayerIdx( 0 ); |
---|
1748 | rpcSlice->setAltColIndicationFlag( false ); |
---|
1749 | if ( sps->getLayerId() > 0 && rpcSlice->getActiveNumILRRefIdx() > 0 && rpcSlice->getNumMotionPredRefLayers() > 0 ) |
---|
1750 | { |
---|
1751 | READ_FLAG( uiCode, "alt_collocated_indication_flag" ); |
---|
1752 | rpcSlice->setAltColIndicationFlag( uiCode == 1 ? true : false ); |
---|
1753 | rpcSlice->setMFMEnabledFlag( uiCode == 1 ? true : false ); |
---|
1754 | if ( rpcSlice->getNumMotionPredRefLayers() > 1 ) |
---|
1755 | { |
---|
1756 | READ_UVLC( uiCode, "collocated_ref_layer_idx" ); |
---|
1757 | rpcSlice->setColRefLayerIdx( uiCode ); |
---|
1758 | } |
---|
1759 | } |
---|
1760 | else |
---|
1761 | { |
---|
1762 | #endif //REMOVE_COL_PICTURE_SIGNALING |
---|
1763 | #endif |
---|
1764 | if ( rpcSlice->getSliceType() == B_SLICE ) |
---|
1765 | { |
---|
1766 | READ_FLAG( uiCode, "collocated_from_l0_flag" ); |
---|
1767 | rpcSlice->setColFromL0Flag(uiCode); |
---|
1768 | } |
---|
1769 | else |
---|
1770 | { |
---|
1771 | rpcSlice->setColFromL0Flag( 1 ); |
---|
1772 | } |
---|
1773 | |
---|
1774 | if ( rpcSlice->getSliceType() != I_SLICE && |
---|
1775 | ((rpcSlice->getColFromL0Flag() == 1 && rpcSlice->getNumRefIdx(REF_PIC_LIST_0) > 1)|| |
---|
1776 | (rpcSlice->getColFromL0Flag() == 0 && rpcSlice->getNumRefIdx(REF_PIC_LIST_1) > 1))) |
---|
1777 | { |
---|
1778 | READ_UVLC( uiCode, "collocated_ref_idx" ); |
---|
1779 | rpcSlice->setColRefIdx(uiCode); |
---|
1780 | } |
---|
1781 | else |
---|
1782 | { |
---|
1783 | rpcSlice->setColRefIdx(0); |
---|
1784 | } |
---|
1785 | #if M0457_COL_PICTURE_SIGNALING && !REMOVE_COL_PICTURE_SIGNALING |
---|
1786 | } |
---|
1787 | #endif |
---|
1788 | } |
---|
1789 | if ( (pps->getUseWP() && rpcSlice->getSliceType()==P_SLICE) || (pps->getWPBiPred() && rpcSlice->getSliceType()==B_SLICE) ) |
---|
1790 | { |
---|
1791 | xParsePredWeightTable(rpcSlice); |
---|
1792 | rpcSlice->initWpScaling(); |
---|
1793 | } |
---|
1794 | if (!rpcSlice->isIntra()) |
---|
1795 | { |
---|
1796 | READ_UVLC( uiCode, "five_minus_max_num_merge_cand"); |
---|
1797 | rpcSlice->setMaxNumMergeCand(MRG_MAX_NUM_CANDS - uiCode); |
---|
1798 | } |
---|
1799 | |
---|
1800 | READ_SVLC( iCode, "slice_qp_delta" ); |
---|
1801 | rpcSlice->setSliceQp (26 + pps->getPicInitQPMinus26() + iCode); |
---|
1802 | |
---|
1803 | assert( rpcSlice->getSliceQp() >= -sps->getQpBDOffsetY() ); |
---|
1804 | assert( rpcSlice->getSliceQp() <= 51 ); |
---|
1805 | |
---|
1806 | if (rpcSlice->getPPS()->getSliceChromaQpFlag()) |
---|
1807 | { |
---|
1808 | READ_SVLC( iCode, "slice_qp_delta_cb" ); |
---|
1809 | rpcSlice->setSliceQpDeltaCb( iCode ); |
---|
1810 | assert( rpcSlice->getSliceQpDeltaCb() >= -12 ); |
---|
1811 | assert( rpcSlice->getSliceQpDeltaCb() <= 12 ); |
---|
1812 | assert( (rpcSlice->getPPS()->getChromaCbQpOffset() + rpcSlice->getSliceQpDeltaCb()) >= -12 ); |
---|
1813 | assert( (rpcSlice->getPPS()->getChromaCbQpOffset() + rpcSlice->getSliceQpDeltaCb()) <= 12 ); |
---|
1814 | |
---|
1815 | READ_SVLC( iCode, "slice_qp_delta_cr" ); |
---|
1816 | rpcSlice->setSliceQpDeltaCr( iCode ); |
---|
1817 | assert( rpcSlice->getSliceQpDeltaCr() >= -12 ); |
---|
1818 | assert( rpcSlice->getSliceQpDeltaCr() <= 12 ); |
---|
1819 | assert( (rpcSlice->getPPS()->getChromaCrQpOffset() + rpcSlice->getSliceQpDeltaCr()) >= -12 ); |
---|
1820 | assert( (rpcSlice->getPPS()->getChromaCrQpOffset() + rpcSlice->getSliceQpDeltaCr()) <= 12 ); |
---|
1821 | } |
---|
1822 | |
---|
1823 | if (rpcSlice->getPPS()->getDeblockingFilterControlPresentFlag()) |
---|
1824 | { |
---|
1825 | if(rpcSlice->getPPS()->getDeblockingFilterOverrideEnabledFlag()) |
---|
1826 | { |
---|
1827 | READ_FLAG ( uiCode, "deblocking_filter_override_flag" ); rpcSlice->setDeblockingFilterOverrideFlag(uiCode ? true : false); |
---|
1828 | } |
---|
1829 | else |
---|
1830 | { |
---|
1831 | rpcSlice->setDeblockingFilterOverrideFlag(0); |
---|
1832 | } |
---|
1833 | if(rpcSlice->getDeblockingFilterOverrideFlag()) |
---|
1834 | { |
---|
1835 | READ_FLAG ( uiCode, "slice_disable_deblocking_filter_flag" ); rpcSlice->setDeblockingFilterDisable(uiCode ? 1 : 0); |
---|
1836 | if(!rpcSlice->getDeblockingFilterDisable()) |
---|
1837 | { |
---|
1838 | READ_SVLC( iCode, "slice_beta_offset_div2" ); rpcSlice->setDeblockingFilterBetaOffsetDiv2(iCode); |
---|
1839 | assert(rpcSlice->getDeblockingFilterBetaOffsetDiv2() >= -6 && |
---|
1840 | rpcSlice->getDeblockingFilterBetaOffsetDiv2() <= 6); |
---|
1841 | READ_SVLC( iCode, "slice_tc_offset_div2" ); rpcSlice->setDeblockingFilterTcOffsetDiv2(iCode); |
---|
1842 | assert(rpcSlice->getDeblockingFilterTcOffsetDiv2() >= -6 && |
---|
1843 | rpcSlice->getDeblockingFilterTcOffsetDiv2() <= 6); |
---|
1844 | } |
---|
1845 | } |
---|
1846 | else |
---|
1847 | { |
---|
1848 | rpcSlice->setDeblockingFilterDisable ( rpcSlice->getPPS()->getPicDisableDeblockingFilterFlag() ); |
---|
1849 | rpcSlice->setDeblockingFilterBetaOffsetDiv2( rpcSlice->getPPS()->getDeblockingFilterBetaOffsetDiv2() ); |
---|
1850 | rpcSlice->setDeblockingFilterTcOffsetDiv2 ( rpcSlice->getPPS()->getDeblockingFilterTcOffsetDiv2() ); |
---|
1851 | } |
---|
1852 | } |
---|
1853 | else |
---|
1854 | { |
---|
1855 | rpcSlice->setDeblockingFilterDisable ( false ); |
---|
1856 | rpcSlice->setDeblockingFilterBetaOffsetDiv2( 0 ); |
---|
1857 | rpcSlice->setDeblockingFilterTcOffsetDiv2 ( 0 ); |
---|
1858 | } |
---|
1859 | |
---|
1860 | Bool isSAOEnabled = (!rpcSlice->getSPS()->getUseSAO())?(false):(rpcSlice->getSaoEnabledFlag()||rpcSlice->getSaoEnabledFlagChroma()); |
---|
1861 | Bool isDBFEnabled = (!rpcSlice->getDeblockingFilterDisable()); |
---|
1862 | |
---|
1863 | if(rpcSlice->getPPS()->getLoopFilterAcrossSlicesEnabledFlag() && ( isSAOEnabled || isDBFEnabled )) |
---|
1864 | { |
---|
1865 | READ_FLAG( uiCode, "slice_loop_filter_across_slices_enabled_flag"); |
---|
1866 | } |
---|
1867 | else |
---|
1868 | { |
---|
1869 | uiCode = rpcSlice->getPPS()->getLoopFilterAcrossSlicesEnabledFlag()?1:0; |
---|
1870 | } |
---|
1871 | rpcSlice->setLFCrossSliceBoundaryFlag( (uiCode==1)?true:false); |
---|
1872 | |
---|
1873 | } |
---|
1874 | |
---|
1875 | UInt *entryPointOffset = NULL; |
---|
1876 | UInt numEntryPointOffsets, offsetLenMinus1; |
---|
1877 | if( pps->getTilesEnabledFlag() || pps->getEntropyCodingSyncEnabledFlag() ) |
---|
1878 | { |
---|
1879 | READ_UVLC(numEntryPointOffsets, "num_entry_point_offsets"); rpcSlice->setNumEntryPointOffsets ( numEntryPointOffsets ); |
---|
1880 | if (numEntryPointOffsets>0) |
---|
1881 | { |
---|
1882 | READ_UVLC(offsetLenMinus1, "offset_len_minus1"); |
---|
1883 | } |
---|
1884 | entryPointOffset = new UInt[numEntryPointOffsets]; |
---|
1885 | for (UInt idx=0; idx<numEntryPointOffsets; idx++) |
---|
1886 | { |
---|
1887 | READ_CODE(offsetLenMinus1+1, uiCode, "entry_point_offset_minus1"); |
---|
1888 | entryPointOffset[ idx ] = uiCode + 1; |
---|
1889 | } |
---|
1890 | } |
---|
1891 | else |
---|
1892 | { |
---|
1893 | rpcSlice->setNumEntryPointOffsets ( 0 ); |
---|
1894 | } |
---|
1895 | |
---|
1896 | if(pps->getSliceHeaderExtensionPresentFlag()) |
---|
1897 | { |
---|
1898 | READ_UVLC(uiCode,"slice_header_extension_length"); |
---|
1899 | for(Int i=0; i<uiCode; i++) |
---|
1900 | { |
---|
1901 | UInt ignore; |
---|
1902 | READ_CODE(8,ignore,"slice_header_extension_data_byte"); |
---|
1903 | } |
---|
1904 | } |
---|
1905 | m_pcBitstream->readByteAlignment(); |
---|
1906 | |
---|
1907 | if( pps->getTilesEnabledFlag() || pps->getEntropyCodingSyncEnabledFlag() ) |
---|
1908 | { |
---|
1909 | Int endOfSliceHeaderLocation = m_pcBitstream->getByteLocation(); |
---|
1910 | |
---|
1911 | // Adjust endOfSliceHeaderLocation to account for emulation prevention bytes in the slice segment header |
---|
1912 | for ( UInt curByteIdx = 0; curByteIdx<m_pcBitstream->numEmulationPreventionBytesRead(); curByteIdx++ ) |
---|
1913 | { |
---|
1914 | if ( m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) < endOfSliceHeaderLocation ) |
---|
1915 | { |
---|
1916 | endOfSliceHeaderLocation++; |
---|
1917 | } |
---|
1918 | } |
---|
1919 | |
---|
1920 | Int curEntryPointOffset = 0; |
---|
1921 | Int prevEntryPointOffset = 0; |
---|
1922 | for (UInt idx=0; idx<numEntryPointOffsets; idx++) |
---|
1923 | { |
---|
1924 | curEntryPointOffset += entryPointOffset[ idx ]; |
---|
1925 | |
---|
1926 | Int emulationPreventionByteCount = 0; |
---|
1927 | for ( UInt curByteIdx = 0; curByteIdx<m_pcBitstream->numEmulationPreventionBytesRead(); curByteIdx++ ) |
---|
1928 | { |
---|
1929 | if ( m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) >= ( prevEntryPointOffset + endOfSliceHeaderLocation ) && |
---|
1930 | m_pcBitstream->getEmulationPreventionByteLocation( curByteIdx ) < ( curEntryPointOffset + endOfSliceHeaderLocation ) ) |
---|
1931 | { |
---|
1932 | emulationPreventionByteCount++; |
---|
1933 | } |
---|
1934 | } |
---|
1935 | |
---|
1936 | entryPointOffset[ idx ] -= emulationPreventionByteCount; |
---|
1937 | prevEntryPointOffset = curEntryPointOffset; |
---|
1938 | } |
---|
1939 | |
---|
1940 | if ( pps->getTilesEnabledFlag() ) |
---|
1941 | { |
---|
1942 | rpcSlice->setTileLocationCount( numEntryPointOffsets ); |
---|
1943 | |
---|
1944 | UInt prevPos = 0; |
---|
1945 | for (Int idx=0; idx<rpcSlice->getTileLocationCount(); idx++) |
---|
1946 | { |
---|
1947 | rpcSlice->setTileLocation( idx, prevPos + entryPointOffset [ idx ] ); |
---|
1948 | prevPos += entryPointOffset[ idx ]; |
---|
1949 | } |
---|
1950 | } |
---|
1951 | else if ( pps->getEntropyCodingSyncEnabledFlag() ) |
---|
1952 | { |
---|
1953 | Int numSubstreams = rpcSlice->getNumEntryPointOffsets()+1; |
---|
1954 | rpcSlice->allocSubstreamSizes(numSubstreams); |
---|
1955 | UInt *pSubstreamSizes = rpcSlice->getSubstreamSizes(); |
---|
1956 | for (Int idx=0; idx<numSubstreams-1; idx++) |
---|
1957 | { |
---|
1958 | if ( idx < numEntryPointOffsets ) |
---|
1959 | { |
---|
1960 | pSubstreamSizes[ idx ] = ( entryPointOffset[ idx ] << 3 ) ; |
---|
1961 | } |
---|
1962 | else |
---|
1963 | { |
---|
1964 | pSubstreamSizes[ idx ] = 0; |
---|
1965 | } |
---|
1966 | } |
---|
1967 | } |
---|
1968 | |
---|
1969 | if (entryPointOffset) |
---|
1970 | { |
---|
1971 | delete [] entryPointOffset; |
---|
1972 | } |
---|
1973 | } |
---|
1974 | |
---|
1975 | return; |
---|
1976 | } |
---|
1977 | |
---|
1978 | Void TDecCavlc::parsePTL( TComPTL *rpcPTL, Bool profilePresentFlag, Int maxNumSubLayersMinus1 ) |
---|
1979 | { |
---|
1980 | UInt uiCode; |
---|
1981 | if(profilePresentFlag) |
---|
1982 | { |
---|
1983 | parseProfileTier(rpcPTL->getGeneralPTL()); |
---|
1984 | } |
---|
1985 | READ_CODE( 8, uiCode, "general_level_idc" ); rpcPTL->getGeneralPTL()->setLevelIdc(uiCode); |
---|
1986 | |
---|
1987 | for (Int i = 0; i < maxNumSubLayersMinus1; i++) |
---|
1988 | { |
---|
1989 | if(profilePresentFlag) |
---|
1990 | { |
---|
1991 | READ_FLAG( uiCode, "sub_layer_profile_present_flag[i]" ); rpcPTL->setSubLayerProfilePresentFlag(i, uiCode); |
---|
1992 | } |
---|
1993 | READ_FLAG( uiCode, "sub_layer_level_present_flag[i]" ); rpcPTL->setSubLayerLevelPresentFlag (i, uiCode); |
---|
1994 | } |
---|
1995 | |
---|
1996 | if (maxNumSubLayersMinus1 > 0) |
---|
1997 | { |
---|
1998 | for (Int i = maxNumSubLayersMinus1; i < 8; i++) |
---|
1999 | { |
---|
2000 | READ_CODE(2, uiCode, "reserved_zero_2bits"); |
---|
2001 | assert(uiCode == 0); |
---|
2002 | } |
---|
2003 | } |
---|
2004 | |
---|
2005 | for(Int i = 0; i < maxNumSubLayersMinus1; i++) |
---|
2006 | { |
---|
2007 | if( profilePresentFlag && rpcPTL->getSubLayerProfilePresentFlag(i) ) |
---|
2008 | { |
---|
2009 | parseProfileTier(rpcPTL->getSubLayerPTL(i)); |
---|
2010 | } |
---|
2011 | if(rpcPTL->getSubLayerLevelPresentFlag(i)) |
---|
2012 | { |
---|
2013 | READ_CODE( 8, uiCode, "sub_layer_level_idc[i]" ); rpcPTL->getSubLayerPTL(i)->setLevelIdc(uiCode); |
---|
2014 | } |
---|
2015 | } |
---|
2016 | } |
---|
2017 | |
---|
2018 | Void TDecCavlc::parseProfileTier(ProfileTierLevel *ptl) |
---|
2019 | { |
---|
2020 | UInt uiCode; |
---|
2021 | READ_CODE(2 , uiCode, "XXX_profile_space[]"); ptl->setProfileSpace(uiCode); |
---|
2022 | READ_FLAG( uiCode, "XXX_tier_flag[]" ); ptl->setTierFlag (uiCode ? 1 : 0); |
---|
2023 | READ_CODE(5 , uiCode, "XXX_profile_idc[]" ); ptl->setProfileIdc (uiCode); |
---|
2024 | for(Int j = 0; j < 32; j++) |
---|
2025 | { |
---|
2026 | READ_FLAG( uiCode, "XXX_profile_compatibility_flag[][j]"); ptl->setProfileCompatibilityFlag(j, uiCode ? 1 : 0); |
---|
2027 | } |
---|
2028 | READ_FLAG(uiCode, "general_progressive_source_flag"); |
---|
2029 | ptl->setProgressiveSourceFlag(uiCode ? true : false); |
---|
2030 | |
---|
2031 | READ_FLAG(uiCode, "general_interlaced_source_flag"); |
---|
2032 | ptl->setInterlacedSourceFlag(uiCode ? true : false); |
---|
2033 | |
---|
2034 | READ_FLAG(uiCode, "general_non_packed_constraint_flag"); |
---|
2035 | ptl->setNonPackedConstraintFlag(uiCode ? true : false); |
---|
2036 | |
---|
2037 | READ_FLAG(uiCode, "general_frame_only_constraint_flag"); |
---|
2038 | ptl->setFrameOnlyConstraintFlag(uiCode ? true : false); |
---|
2039 | |
---|
2040 | READ_CODE(16, uiCode, "XXX_reserved_zero_44bits[0..15]"); |
---|
2041 | READ_CODE(16, uiCode, "XXX_reserved_zero_44bits[16..31]"); |
---|
2042 | READ_CODE(12, uiCode, "XXX_reserved_zero_44bits[32..43]"); |
---|
2043 | } |
---|
2044 | |
---|
2045 | Void TDecCavlc::parseTerminatingBit( UInt& ruiBit ) |
---|
2046 | { |
---|
2047 | ruiBit = false; |
---|
2048 | Int iBitsLeft = m_pcBitstream->getNumBitsLeft(); |
---|
2049 | if(iBitsLeft <= 8) |
---|
2050 | { |
---|
2051 | UInt uiPeekValue = m_pcBitstream->peekBits(iBitsLeft); |
---|
2052 | if (uiPeekValue == (1<<(iBitsLeft-1))) |
---|
2053 | { |
---|
2054 | ruiBit = true; |
---|
2055 | } |
---|
2056 | } |
---|
2057 | } |
---|
2058 | |
---|
2059 | Void TDecCavlc::parseSkipFlag( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
2060 | { |
---|
2061 | assert(0); |
---|
2062 | } |
---|
2063 | |
---|
2064 | Void TDecCavlc::parseCUTransquantBypassFlag( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
2065 | { |
---|
2066 | assert(0); |
---|
2067 | } |
---|
2068 | |
---|
2069 | Void TDecCavlc::parseMVPIdx( Int& /*riMVPIdx*/ ) |
---|
2070 | { |
---|
2071 | assert(0); |
---|
2072 | } |
---|
2073 | |
---|
2074 | Void TDecCavlc::parseSplitFlag ( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
2075 | { |
---|
2076 | assert(0); |
---|
2077 | } |
---|
2078 | |
---|
2079 | Void TDecCavlc::parsePartSize( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
2080 | { |
---|
2081 | assert(0); |
---|
2082 | } |
---|
2083 | |
---|
2084 | Void TDecCavlc::parsePredMode( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
2085 | { |
---|
2086 | assert(0); |
---|
2087 | } |
---|
2088 | |
---|
2089 | /** Parse I_PCM information. |
---|
2090 | * \param pcCU pointer to CU |
---|
2091 | * \param uiAbsPartIdx CU index |
---|
2092 | * \param uiDepth CU depth |
---|
2093 | * \returns Void |
---|
2094 | * |
---|
2095 | * If I_PCM flag indicates that the CU is I_PCM, parse its PCM alignment bits and codes. |
---|
2096 | */ |
---|
2097 | Void TDecCavlc::parseIPCMInfo( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
2098 | { |
---|
2099 | assert(0); |
---|
2100 | } |
---|
2101 | |
---|
2102 | Void TDecCavlc::parseIntraDirLumaAng ( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
2103 | { |
---|
2104 | assert(0); |
---|
2105 | } |
---|
2106 | |
---|
2107 | Void TDecCavlc::parseIntraDirChroma( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/ ) |
---|
2108 | { |
---|
2109 | assert(0); |
---|
2110 | } |
---|
2111 | |
---|
2112 | Void TDecCavlc::parseInterDir( TComDataCU* /*pcCU*/, UInt& /*ruiInterDir*/, UInt /*uiAbsPartIdx*/ ) |
---|
2113 | { |
---|
2114 | assert(0); |
---|
2115 | } |
---|
2116 | |
---|
2117 | Void TDecCavlc::parseRefFrmIdx( TComDataCU* /*pcCU*/, Int& /*riRefFrmIdx*/, RefPicList /*eRefList*/ ) |
---|
2118 | { |
---|
2119 | assert(0); |
---|
2120 | } |
---|
2121 | |
---|
2122 | Void TDecCavlc::parseMvd( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiPartIdx*/, UInt /*uiDepth*/, RefPicList /*eRefList*/ ) |
---|
2123 | { |
---|
2124 | assert(0); |
---|
2125 | } |
---|
2126 | |
---|
2127 | Void TDecCavlc::parseDeltaQP( TComDataCU* pcCU, UInt uiAbsPartIdx, UInt uiDepth ) |
---|
2128 | { |
---|
2129 | Int qp; |
---|
2130 | Int iDQp; |
---|
2131 | |
---|
2132 | xReadSvlc( iDQp ); |
---|
2133 | |
---|
2134 | Int qpBdOffsetY = pcCU->getSlice()->getSPS()->getQpBDOffsetY(); |
---|
2135 | qp = (((Int) pcCU->getRefQP( uiAbsPartIdx ) + iDQp + 52 + 2*qpBdOffsetY )%(52+ qpBdOffsetY)) - qpBdOffsetY; |
---|
2136 | |
---|
2137 | UInt uiAbsQpCUPartIdx = (uiAbsPartIdx>>((g_uiMaxCUDepth - pcCU->getSlice()->getPPS()->getMaxCuDQPDepth())<<1))<<((g_uiMaxCUDepth - pcCU->getSlice()->getPPS()->getMaxCuDQPDepth())<<1) ; |
---|
2138 | UInt uiQpCUDepth = min(uiDepth,pcCU->getSlice()->getPPS()->getMaxCuDQPDepth()) ; |
---|
2139 | |
---|
2140 | pcCU->setQPSubParts( qp, uiAbsQpCUPartIdx, uiQpCUDepth ); |
---|
2141 | } |
---|
2142 | |
---|
2143 | Void TDecCavlc::parseCoeffNxN( TComDataCU* /*pcCU*/, TCoeff* /*pcCoef*/, UInt /*uiAbsPartIdx*/, UInt /*uiWidth*/, UInt /*uiHeight*/, UInt /*uiDepth*/, TextType /*eTType*/ ) |
---|
2144 | { |
---|
2145 | assert(0); |
---|
2146 | } |
---|
2147 | |
---|
2148 | Void TDecCavlc::parseTransformSubdivFlag( UInt& /*ruiSubdivFlag*/, UInt /*uiLog2TransformBlockSize*/ ) |
---|
2149 | { |
---|
2150 | assert(0); |
---|
2151 | } |
---|
2152 | |
---|
2153 | Void TDecCavlc::parseQtCbf( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, TextType /*eType*/, UInt /*uiTrDepth*/, UInt /*uiDepth*/ ) |
---|
2154 | { |
---|
2155 | assert(0); |
---|
2156 | } |
---|
2157 | |
---|
2158 | Void TDecCavlc::parseQtRootCbf( UInt /*uiAbsPartIdx*/, UInt& /*uiQtRootCbf*/ ) |
---|
2159 | { |
---|
2160 | assert(0); |
---|
2161 | } |
---|
2162 | |
---|
2163 | Void TDecCavlc::parseTransformSkipFlags (TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*width*/, UInt /*height*/, UInt /*uiDepth*/, TextType /*eTType*/) |
---|
2164 | { |
---|
2165 | assert(0); |
---|
2166 | } |
---|
2167 | |
---|
2168 | Void TDecCavlc::parseMergeFlag ( TComDataCU* /*pcCU*/, UInt /*uiAbsPartIdx*/, UInt /*uiDepth*/, UInt /*uiPUIdx*/ ) |
---|
2169 | { |
---|
2170 | assert(0); |
---|
2171 | } |
---|
2172 | |
---|
2173 | Void TDecCavlc::parseMergeIndex ( TComDataCU* /*pcCU*/, UInt& /*ruiMergeIndex*/ ) |
---|
2174 | { |
---|
2175 | assert(0); |
---|
2176 | } |
---|
2177 | |
---|
2178 | // ==================================================================================================================== |
---|
2179 | // Protected member functions |
---|
2180 | // ==================================================================================================================== |
---|
2181 | |
---|
2182 | /** parse explicit wp tables |
---|
2183 | * \param TComSlice* pcSlice |
---|
2184 | * \returns Void |
---|
2185 | */ |
---|
2186 | Void TDecCavlc::xParsePredWeightTable( TComSlice* pcSlice ) |
---|
2187 | { |
---|
2188 | wpScalingParam *wp; |
---|
2189 | Bool bChroma = true; // color always present in HEVC ? |
---|
2190 | SliceType eSliceType = pcSlice->getSliceType(); |
---|
2191 | Int iNbRef = (eSliceType == B_SLICE ) ? (2) : (1); |
---|
2192 | UInt uiLog2WeightDenomLuma, uiLog2WeightDenomChroma; |
---|
2193 | UInt uiTotalSignalledWeightFlags = 0; |
---|
2194 | |
---|
2195 | Int iDeltaDenom; |
---|
2196 | // decode delta_luma_log2_weight_denom : |
---|
2197 | READ_UVLC( uiLog2WeightDenomLuma, "luma_log2_weight_denom" ); // ue(v): luma_log2_weight_denom |
---|
2198 | assert( uiLog2WeightDenomLuma <= 7 ); |
---|
2199 | if( bChroma ) |
---|
2200 | { |
---|
2201 | READ_SVLC( iDeltaDenom, "delta_chroma_log2_weight_denom" ); // se(v): delta_chroma_log2_weight_denom |
---|
2202 | assert((iDeltaDenom + (Int)uiLog2WeightDenomLuma)>=0); |
---|
2203 | assert((iDeltaDenom + (Int)uiLog2WeightDenomLuma)<=7); |
---|
2204 | uiLog2WeightDenomChroma = (UInt)(iDeltaDenom + uiLog2WeightDenomLuma); |
---|
2205 | } |
---|
2206 | |
---|
2207 | for ( Int iNumRef=0 ; iNumRef<iNbRef ; iNumRef++ ) |
---|
2208 | { |
---|
2209 | RefPicList eRefPicList = ( iNumRef ? REF_PIC_LIST_1 : REF_PIC_LIST_0 ); |
---|
2210 | for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ ) |
---|
2211 | { |
---|
2212 | pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); |
---|
2213 | |
---|
2214 | wp[0].uiLog2WeightDenom = uiLog2WeightDenomLuma; |
---|
2215 | wp[1].uiLog2WeightDenom = uiLog2WeightDenomChroma; |
---|
2216 | wp[2].uiLog2WeightDenom = uiLog2WeightDenomChroma; |
---|
2217 | |
---|
2218 | UInt uiCode; |
---|
2219 | READ_FLAG( uiCode, "luma_weight_lX_flag" ); // u(1): luma_weight_l0_flag |
---|
2220 | wp[0].bPresentFlag = ( uiCode == 1 ); |
---|
2221 | uiTotalSignalledWeightFlags += wp[0].bPresentFlag; |
---|
2222 | } |
---|
2223 | if ( bChroma ) |
---|
2224 | { |
---|
2225 | UInt uiCode; |
---|
2226 | for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ ) |
---|
2227 | { |
---|
2228 | pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); |
---|
2229 | READ_FLAG( uiCode, "chroma_weight_lX_flag" ); // u(1): chroma_weight_l0_flag |
---|
2230 | wp[1].bPresentFlag = ( uiCode == 1 ); |
---|
2231 | wp[2].bPresentFlag = ( uiCode == 1 ); |
---|
2232 | uiTotalSignalledWeightFlags += 2*wp[1].bPresentFlag; |
---|
2233 | } |
---|
2234 | } |
---|
2235 | for ( Int iRefIdx=0 ; iRefIdx<pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx++ ) |
---|
2236 | { |
---|
2237 | pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); |
---|
2238 | if ( wp[0].bPresentFlag ) |
---|
2239 | { |
---|
2240 | Int iDeltaWeight; |
---|
2241 | READ_SVLC( iDeltaWeight, "delta_luma_weight_lX" ); // se(v): delta_luma_weight_l0[i] |
---|
2242 | assert( iDeltaWeight >= -128 ); |
---|
2243 | assert( iDeltaWeight <= 127 ); |
---|
2244 | wp[0].iWeight = (iDeltaWeight + (1<<wp[0].uiLog2WeightDenom)); |
---|
2245 | READ_SVLC( wp[0].iOffset, "luma_offset_lX" ); // se(v): luma_offset_l0[i] |
---|
2246 | assert( wp[0].iOffset >= -128 ); |
---|
2247 | assert( wp[0].iOffset <= 127 ); |
---|
2248 | } |
---|
2249 | else |
---|
2250 | { |
---|
2251 | wp[0].iWeight = (1 << wp[0].uiLog2WeightDenom); |
---|
2252 | wp[0].iOffset = 0; |
---|
2253 | } |
---|
2254 | if ( bChroma ) |
---|
2255 | { |
---|
2256 | if ( wp[1].bPresentFlag ) |
---|
2257 | { |
---|
2258 | for ( Int j=1 ; j<3 ; j++ ) |
---|
2259 | { |
---|
2260 | Int iDeltaWeight; |
---|
2261 | READ_SVLC( iDeltaWeight, "delta_chroma_weight_lX" ); // se(v): chroma_weight_l0[i][j] |
---|
2262 | assert( iDeltaWeight >= -128 ); |
---|
2263 | assert( iDeltaWeight <= 127 ); |
---|
2264 | wp[j].iWeight = (iDeltaWeight + (1<<wp[1].uiLog2WeightDenom)); |
---|
2265 | |
---|
2266 | Int iDeltaChroma; |
---|
2267 | READ_SVLC( iDeltaChroma, "delta_chroma_offset_lX" ); // se(v): delta_chroma_offset_l0[i][j] |
---|
2268 | assert( iDeltaChroma >= -512 ); |
---|
2269 | assert( iDeltaChroma <= 511 ); |
---|
2270 | Int pred = ( 128 - ( ( 128*wp[j].iWeight)>>(wp[j].uiLog2WeightDenom) ) ); |
---|
2271 | wp[j].iOffset = Clip3(-128, 127, (iDeltaChroma + pred) ); |
---|
2272 | } |
---|
2273 | } |
---|
2274 | else |
---|
2275 | { |
---|
2276 | for ( Int j=1 ; j<3 ; j++ ) |
---|
2277 | { |
---|
2278 | wp[j].iWeight = (1 << wp[j].uiLog2WeightDenom); |
---|
2279 | wp[j].iOffset = 0; |
---|
2280 | } |
---|
2281 | } |
---|
2282 | } |
---|
2283 | } |
---|
2284 | |
---|
2285 | for ( Int iRefIdx=pcSlice->getNumRefIdx(eRefPicList) ; iRefIdx<MAX_NUM_REF ; iRefIdx++ ) |
---|
2286 | { |
---|
2287 | pcSlice->getWpScaling(eRefPicList, iRefIdx, wp); |
---|
2288 | |
---|
2289 | wp[0].bPresentFlag = false; |
---|
2290 | wp[1].bPresentFlag = false; |
---|
2291 | wp[2].bPresentFlag = false; |
---|
2292 | } |
---|
2293 | } |
---|
2294 | assert(uiTotalSignalledWeightFlags<=24); |
---|
2295 | } |
---|
2296 | |
---|
2297 | /** decode quantization matrix |
---|
2298 | * \param scalingList quantization matrix information |
---|
2299 | */ |
---|
2300 | Void TDecCavlc::parseScalingList(TComScalingList* scalingList) |
---|
2301 | { |
---|
2302 | UInt code, sizeId, listId; |
---|
2303 | Bool scalingListPredModeFlag; |
---|
2304 | //for each size |
---|
2305 | for(sizeId = 0; sizeId < SCALING_LIST_SIZE_NUM; sizeId++) |
---|
2306 | { |
---|
2307 | for(listId = 0; listId < g_scalingListNum[sizeId]; listId++) |
---|
2308 | { |
---|
2309 | READ_FLAG( code, "scaling_list_pred_mode_flag"); |
---|
2310 | scalingListPredModeFlag = (code) ? true : false; |
---|
2311 | if(!scalingListPredModeFlag) //Copy Mode |
---|
2312 | { |
---|
2313 | READ_UVLC( code, "scaling_list_pred_matrix_id_delta"); |
---|
2314 | scalingList->setRefMatrixId (sizeId,listId,(UInt)((Int)(listId)-(code))); |
---|
2315 | if( sizeId > SCALING_LIST_8x8 ) |
---|
2316 | { |
---|
2317 | scalingList->setScalingListDC(sizeId,listId,((listId == scalingList->getRefMatrixId (sizeId,listId))? 16 :scalingList->getScalingListDC(sizeId, scalingList->getRefMatrixId (sizeId,listId)))); |
---|
2318 | } |
---|
2319 | scalingList->processRefMatrix( sizeId, listId, scalingList->getRefMatrixId (sizeId,listId)); |
---|
2320 | |
---|
2321 | } |
---|
2322 | else //DPCM Mode |
---|
2323 | { |
---|
2324 | xDecodeScalingList(scalingList, sizeId, listId); |
---|
2325 | } |
---|
2326 | } |
---|
2327 | } |
---|
2328 | |
---|
2329 | return; |
---|
2330 | } |
---|
2331 | /** decode DPCM |
---|
2332 | * \param scalingList quantization matrix information |
---|
2333 | * \param sizeId size index |
---|
2334 | * \param listId list index |
---|
2335 | */ |
---|
2336 | Void TDecCavlc::xDecodeScalingList(TComScalingList *scalingList, UInt sizeId, UInt listId) |
---|
2337 | { |
---|
2338 | Int i,coefNum = min(MAX_MATRIX_COEF_NUM,(Int)g_scalingListSize[sizeId]); |
---|
2339 | Int data; |
---|
2340 | Int scalingListDcCoefMinus8 = 0; |
---|
2341 | Int nextCoef = SCALING_LIST_START_VALUE; |
---|
2342 | UInt* scan = (sizeId == 0) ? g_auiSigLastScan [ SCAN_DIAG ] [ 1 ] : g_sigLastScanCG32x32; |
---|
2343 | Int *dst = scalingList->getScalingListAddress(sizeId, listId); |
---|
2344 | |
---|
2345 | if( sizeId > SCALING_LIST_8x8 ) |
---|
2346 | { |
---|
2347 | READ_SVLC( scalingListDcCoefMinus8, "scaling_list_dc_coef_minus8"); |
---|
2348 | scalingList->setScalingListDC(sizeId,listId,scalingListDcCoefMinus8 + 8); |
---|
2349 | nextCoef = scalingList->getScalingListDC(sizeId,listId); |
---|
2350 | } |
---|
2351 | |
---|
2352 | for(i = 0; i < coefNum; i++) |
---|
2353 | { |
---|
2354 | READ_SVLC( data, "scaling_list_delta_coef"); |
---|
2355 | nextCoef = (nextCoef + data + 256 ) % 256; |
---|
2356 | dst[scan[i]] = nextCoef; |
---|
2357 | } |
---|
2358 | } |
---|
2359 | |
---|
2360 | Bool TDecCavlc::xMoreRbspData() |
---|
2361 | { |
---|
2362 | Int bitsLeft = m_pcBitstream->getNumBitsLeft(); |
---|
2363 | |
---|
2364 | // if there are more than 8 bits, it cannot be rbsp_trailing_bits |
---|
2365 | if (bitsLeft > 8) |
---|
2366 | { |
---|
2367 | return true; |
---|
2368 | } |
---|
2369 | |
---|
2370 | UChar lastByte = m_pcBitstream->peekBits(bitsLeft); |
---|
2371 | Int cnt = bitsLeft; |
---|
2372 | |
---|
2373 | // remove trailing bits equal to zero |
---|
2374 | while ((cnt>0) && ((lastByte & 1) == 0)) |
---|
2375 | { |
---|
2376 | lastByte >>= 1; |
---|
2377 | cnt--; |
---|
2378 | } |
---|
2379 | // remove bit equal to one |
---|
2380 | cnt--; |
---|
2381 | |
---|
2382 | // we should not have a negative number of bits |
---|
2383 | assert (cnt>=0); |
---|
2384 | |
---|
2385 | // we have more data, if cnt is not zero |
---|
2386 | return (cnt>0); |
---|
2387 | } |
---|
2388 | //! \} |
---|
2389 | |
---|