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